From patchwork Fri Jan 3 06:05:57 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Fang X-Patchwork-Id: 13925199 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2055.outbound.protection.outlook.com [40.107.104.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5522E191F89; Fri, 3 Jan 2025 06:23:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.104.55 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735885390; cv=fail; b=XXfwmeth4xKzJwE38dVbPscWLIqPW6q30MY+sAgLD8ow77afXejB2JZ3+6rEgqpnqdHijUe4soPMO72LglBA0cXhi5nReux0Pz7S75v5shLkGH/AWRyak2KIcRePQ8Q4QAXgUBNP+7D/pwRFgUtIM6AFvYvfNLq7KQEp1XrAGRw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735885390; c=relaxed/simple; bh=g2d4ANNwwbrEzT2YJlEa8AlHb1dJ+NXvbEeNfZEyd8w=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=YtfZwUxCXswPBallkPLRRG6CgNC86HekZz4cQd6ComPhskYoXUBhj79i1RV0PiPVw8iK+Mvpiw3bDGi1hUgjW11Y/oOImMMZTHrzAuSlZK0Y4+oGZCHCLMPgTZr5LNOD2CYbz7bv0XbtmDqoPl/uiEA472+3x0EI2QFCkucHo+k= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=gi0alg5I; arc=fail smtp.client-ip=40.107.104.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="gi0alg5I" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=x6RT7heEkrFqbvCCAgPu79Dtb3rY/Og7nYdfWbhdAU4lB0wLKDw/xMM+3lhO7D1E9OmWXwNzvIo7W1Yy6EIwm+4C1kXKmBWT1zXRuaHkiVYAsOkvFd8WL2ofGK1Dk0pRXcObHrYtE2JDSwtnhqgWHQGtcwXNISDpLQ+lf9cDxXBPwuiBHplEPByHgYoErlaXqn43BiImr08Co5ReCC1sjEGJW8+KrM7CAzRKaorf2P260fHeZ6F1mfnj5Ts5+9Uo/0RZgpXIdlVDuoobQUaZtdwFB/5hlBYdYAxjtJA8/LHCQsHn1sZgd8JoIYdLV3qsKvw6utiKGniMpwCc0oSLiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=upJmHynMc4Cc8QASXsyTnsPh0WTdjKNx++fnhKoegD0=; b=io/0xl5wA1hjzOLvhoCWoTQKPsqUwjqVa7INMNUdVgfx4rchJm2FGaEkR1lE2xwpdPTqai0c8gyBnU4vkDtpXIXiHea4woOS7VZySNyLNzcyYdcXdMhJX+gw8IGd9yfQiNWoKYj2Whu2OJIY5vcutCscwdYTTCGk4wlYekesmI6wV/fSHhjyuDnQU13aRB2ylRZHcMEN9VuDXn9j8yZzA5YoqHwn1Nyn2PYlpnuN5SZje/7hdwrvonResOyUQlH/OGB+io0726mtmNHkwNIhM9TlPjv5OlW6AUyBp9sXJuR77XL4M7BpXbeWT834zPZ1JOfULC2zV58+VIvpgFCnJA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=upJmHynMc4Cc8QASXsyTnsPh0WTdjKNx++fnhKoegD0=; b=gi0alg5IpLuZfFbgLvI328B3wI24ihAh0E8F8eZ1Botsvu0FyLNgwLV6vOl36bsARj1o9SxcJ5Kv+Mq5rhHODisIQyvCXGRk4szlILF8d6+7NjMmF/ZNzpIwfhO+5k26ok1PfGKvfGOnXrYhJAGBBKoUofC96/WwNuEI+c2GIMkxOwK7fQEkfOtzqYY+k+/bJjv8zXVwLE2MEOjjiLEMGZBnPUdxoknXjoHIMj2HhsSiMKtrgzYrhBcEmZhCFlTaJfBtIwpORCVTsAlfcJxYKzlLmH3oM6QFGRVegM0wYrlEucUOWgKG05z56G16PZ68dsKk8uMWAe8+J+QZUd7WEQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) by DB9PR04MB9331.eurprd04.prod.outlook.com (2603:10a6:10:36d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.12; Fri, 3 Jan 2025 06:23:02 +0000 Received: from PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db]) by PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db%6]) with mapi id 15.20.8314.013; Fri, 3 Jan 2025 06:23:02 +0000 From: Wei Fang To: claudiu.manoil@nxp.com, vladimir.oltean@nxp.com, xiaoning.wang@nxp.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, christophe.leroy@csgroup.eu Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, imx@lists.linux.dev Subject: [PATCH net-next 01/13] net: enetc: add initial netc-lib driver to support NTMP Date: Fri, 3 Jan 2025 14:05:57 +0800 Message-Id: <20250103060610.2233908-2-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250103060610.2233908-1-wei.fang@nxp.com> References: <20250103060610.2233908-1-wei.fang@nxp.com> X-ClientProxiedBy: SG2PR03CA0127.apcprd03.prod.outlook.com (2603:1096:4:91::31) To PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8510:EE_|DB9PR04MB9331:EE_ X-MS-Office365-Filtering-Correlation-Id: 670aa11e-800e-4e31-57a9-08dd2bbf1343 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|1800799024|7416014|366016|38350700014; X-Microsoft-Antispam-Message-Info: Z7/Mz+D+1unCDzdbsFH5xmQOPA7k0FTaejiQZ0VzysHWSvXj+Ebi9eJqNnns0FuXwivFw4eBNLMDTa5f/Ved4msxGtI9zxtaj6YfiOWTzG+dvRGXiPpu26KvqJrWfUBUOHcT2OUMdkCbVe32mGjMDfRjvdHUtiV+aUUdQomIhpEkNZw9l54BDEkf+8kMK3ccELYRpKBVg1Hr1Q5TZIGkdbX54RL1Ac7gwwzmpRLcUwiBANyuIUY3uIUVU2YQuxAOimN7h7q1pWtxz9soBQF0ihaTXTpdenBUmUpwbEkag+zzOxGrSW0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+8UuTWOHYS5zFdUCeI/q5jvYLViDxH2jDtspiGJ+pVRhjxBBbqvktwHReZ6GOnYCZMPGnBxb216n178NIniLKt4s73RHI9gzXlNGW X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8510.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(376014)(1800799024)(7416014)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 8iX8pESJsLIZ/c+QsfkbnxUyUA57WQNpdZZ2N7Pf2LzFeh2sGDk57cc/TeN3cM1rWORZm6IJo8bxQDdkMrW7nLzRcCLkWX27X57ivk+BsIAtQ7BO0uc5r4fTVT0x8nmG1rQfwIBsDSMHAt4ExPopFfl5WVGThZrQ8+j7ecHOZB8zSrRJl8yusr7vHtqcHHSvknvkOlDIgBZCa7gDSWy84bhpq9iQ+nH4saJchsx84tDr61Rxuv60RA/cMS0kwYmfbZGqCOOVcZZqVW3FTZPshVO5GCMbDpODU61mpm/hUHoJ4i4HhA9F6G7IJQaiD2VwQGHf2AA0v1RI+TVAF56trThpxwfbk+a6GTgs2lEa6qi2wW7AxDeK7NCjlrsj7XshKUtJBzMgoMYRqKWQL9Xpc3ZNc4FkDxGC6oGW5dfsA7gKZGS60QJq+XCKlw2Yp/jJJWKCi2eWb301xp76AVJaH50OVkVK2XC6cdShCvOHmXtceTitQZCGHPUDftcGT2WMsqWuyI0EAtn9r3syVAmTqNdhZ4KehVxxIiWPPoC9bW8/AjcqE0TgFK93s2di8htsyjJ75ilzvSrrxbRvfDnmiqQRszCXkw7glHk/uWfxIRXApP7YFrCsNpTiaaOlBn/N625yqVE4C+JZFNXaTKs/BNaVDbnDKXTLiDHZ9ZgcH/Aow52HB7VCBnzajF6VTbHG32XTwhj2SflOqy3xe9R3z5NG7L7InV1ShqpcJMdY+XiXuRQgFHNMprH+u5plDsJ9Ao4n4La0a3pEsCvaIwC8hee6OvtNSxFTWFibxO4OTKZ3+4m4KOZA2ZF+5UQWx+AK7AWHbSLKnvWA4/45pSRUHtnMKHtTSMGX10x9Ya5pVGvcmws9nCGNJw+t1Zvr0dyJCXVKpA3l4wGZaLlZIlXPmThlLijKF0CLScfbQW23NsDMKZ3CJZ8uP4LbNqCNjKrtj9uWgRXDaqtGWf9ZpHZLnRSrshhXfKYVRxmQNXw46hW3+y20mJQu/d/ZJGbN1fB7DOSwV77hUOndWr9+ZdDQMG09eIOKrc3eP1DGYWXgGzgrfIa3fD8NHiDfzBThqYiMCLdXrHBwFSzZQW2paumYW4XoqG6rUUwRIDJbgddp4iEZ24jYGN85n+poXbIU2aDscvBJ2J5DT2t0TCvXPzJa4ApGFS6Op4KCLjytnH2st7iCnKIGrQaQ1ijmq6usW9bJRdLeREd0ara3+kvh83Ja31NNA+IWeKWkkgr/ws52D0F4IS8Y8s4UWQz0w2Wu9IsDH03Z6jT2oPQ4RVtCyWVzgMjEK9ssHr3dTbssA9rEZPDXICuEBG0OAXGKUX/04OlfHuxm0Eux3fG4FO3BR2Doqj3xVTV7lz3hN2JAZtq8C0/qswEH6CKEDsKIqE/1hIQN4WldB9ecSq06NPEjvRlNBpxpKuQdpohbH05rdTkRF15sOVvDSRFIhpNG58K7TA03XDVOBbNSVrIdvfzwLY2P69L/WqdfAF4FKulguLE4E+9tLB4PaXfk+L8TMXpsTalFVdil/mnZlAsuXhAtXwe7lL1QRy9Dq3JwVwB2OWRpIOTbR7hPsa3Hhlj8f6YwwqbG X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 670aa11e-800e-4e31-57a9-08dd2bbf1343 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jan 2025 06:23:02.3808 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: mpFDvZJWN4LaoIGs475q/U93xm8VQFUhVsXEiwD7jQCK2aZCAwEit/Ig8TPpo5jrCg1NapPAts2cF9D2hAzCcQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB9331 X-Patchwork-Delegate: kuba@kernel.org Some NETC functionality is controlled using control messages sent to the hardware using BD ring interface with 32B descriptor similar to transmit BD ring used on ENETC. This BD ring interface is referred to as command BD ring. It is used to configure functionality where the underlying resources may be shared between different entities or being too large to configure using direct registers. Therefore, a messaging protocol called NETC Table Management Protocol (NTMP) is provided for exchanging configuration and management information between the software and the hardware using the command BD ring interface. For i.MX95, NTMP has been upgraded to version 2.0, which is incompatible with LS1028A, because the message formats have been changed. Therefore, add the netc-lib driver to support NTMP 2.0 to operate various tables. Note that, only MAC address filter table and RSS table are supported at the moment. More tables will be supported in subsequent patches. It is worth mentioning that the purpose of the netc-lib driver is to provide some NTMP-based generic interfaces for ENETC and NETC Switch drivers. Currently, it only supports the configurations of some tables. Interfaces such as tc flower and debugfs will be added in the future. Signed-off-by: Wei Fang --- drivers/net/ethernet/freescale/enetc/Kconfig | 11 + drivers/net/ethernet/freescale/enetc/Makefile | 3 + drivers/net/ethernet/freescale/enetc/ntmp.c | 468 ++++++++++++++++++ .../ethernet/freescale/enetc/ntmp_formats.h | 61 +++ include/linux/fsl/ntmp.h | 178 +++++++ 5 files changed, 721 insertions(+) create mode 100644 drivers/net/ethernet/freescale/enetc/ntmp.c create mode 100644 drivers/net/ethernet/freescale/enetc/ntmp_formats.h create mode 100644 include/linux/fsl/ntmp.h diff --git a/drivers/net/ethernet/freescale/enetc/Kconfig b/drivers/net/ethernet/freescale/enetc/Kconfig index 6c2779047dcd..94db8e8d0eb3 100644 --- a/drivers/net/ethernet/freescale/enetc/Kconfig +++ b/drivers/net/ethernet/freescale/enetc/Kconfig @@ -15,6 +15,16 @@ config NXP_ENETC_PF_COMMON If compiled as module (M), the module name is nxp-enetc-pf-common. +config NXP_NETC_LIB + tristate "NETC Library" + help + This module provides common functionalities for both ENETC and NETC + Switch, such as NETC Table Management Protocol (NTMP) 2.0, common tc + flower and debugfs interfaces and so on. + + If compiled as module (M), the module name is nxp-netc-lib. + + config FSL_ENETC tristate "ENETC PF driver" depends on PCI_MSI @@ -40,6 +50,7 @@ config NXP_ENETC4 select FSL_ENETC_CORE select FSL_ENETC_MDIO select NXP_ENETC_PF_COMMON + select NXP_NETC_LIB select PHYLINK select DIMLIB help diff --git a/drivers/net/ethernet/freescale/enetc/Makefile b/drivers/net/ethernet/freescale/enetc/Makefile index 6fd27ee4fcd1..707a68e26971 100644 --- a/drivers/net/ethernet/freescale/enetc/Makefile +++ b/drivers/net/ethernet/freescale/enetc/Makefile @@ -6,6 +6,9 @@ fsl-enetc-core-y := enetc.o enetc_cbdr.o enetc_ethtool.o obj-$(CONFIG_NXP_ENETC_PF_COMMON) += nxp-enetc-pf-common.o nxp-enetc-pf-common-y := enetc_pf_common.o +obj-$(CONFIG_NXP_NETC_LIB) += nxp-netc-lib.o +nxp-netc-lib-y := ntmp.o + obj-$(CONFIG_FSL_ENETC) += fsl-enetc.o fsl-enetc-y := enetc_pf.o fsl-enetc-$(CONFIG_PCI_IOV) += enetc_msg.o diff --git a/drivers/net/ethernet/freescale/enetc/ntmp.c b/drivers/net/ethernet/freescale/enetc/ntmp.c new file mode 100644 index 000000000000..bcbccede9644 --- /dev/null +++ b/drivers/net/ethernet/freescale/enetc/ntmp.c @@ -0,0 +1,468 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) +/* + * NETC NTMP (NETC Table Management Protocol) 2.0 Library + * Copyright 2025 NXP + */ + +#include +#include +#include + +#include "ntmp_formats.h" + +#define NETC_CBDR_TIMEOUT 1000 /* us */ +#define NETC_CBDR_MR_EN BIT(31) + +#define NTMP_BASE_ADDR_ALIGN 128 +#define NTMP_DATA_ADDR_ALIGN 32 + +/* Define NTMP Table ID */ +#define NTMP_MAFT_ID 1 +#define NTMP_RSST_ID 3 + +/* Generic Update Actions for most tables */ +#define NTMP_GEN_UA_CFGEU BIT(0) +#define NTMP_GEN_UA_STSEU BIT(1) + +#define NTMP_ENTRY_ID_SIZE 4 +#define RSST_ENTRY_NUM 64 +#define RSST_STSE_DATA_SIZE(n) ((n) * 8) +#define RSST_CFGE_DATA_SIZE(n) (n) + +#define NTMP_FILL_CRD(crd, tblv, qa, ua) \ +({ \ + typeof(crd) _crd = (crd); \ + (_crd)->update_act = cpu_to_le16(ua); \ + (_crd)->tblv_qact = NTMP_TBLV_QACT(tblv, qa); \ +}) + +#define NTMP_FILL_CRD_EID(req, tblv, qa, ua, eid) \ +({ \ + typeof(req) _req = (req); \ + NTMP_FILL_CRD(&(_req)->crd, tblv, qa, ua); \ + (_req)->entry_id = cpu_to_le32(eid); \ +}) + +int netc_setup_cbdr(struct device *dev, int cbd_num, + struct netc_cbdr_regs *regs, + struct netc_cbdr *cbdr) +{ + int size; + + size = cbd_num * sizeof(union netc_cbd) + NTMP_BASE_ADDR_ALIGN; + + cbdr->addr_base = dma_alloc_coherent(dev, size, &cbdr->dma_base, + GFP_KERNEL); + if (!cbdr->addr_base) + return -ENOMEM; + + cbdr->dma_size = size; + cbdr->bd_num = cbd_num; + cbdr->regs = *regs; + + /* The base address of the Control BD Ring must be 128 bytes aligned */ + cbdr->dma_base_align = ALIGN(cbdr->dma_base, NTMP_BASE_ADDR_ALIGN); + cbdr->addr_base_align = PTR_ALIGN(cbdr->addr_base, + NTMP_BASE_ADDR_ALIGN); + + cbdr->next_to_clean = 0; + cbdr->next_to_use = 0; + spin_lock_init(&cbdr->ring_lock); + + /* Step 1: Configure the base address of the Control BD Ring */ + netc_write(cbdr->regs.bar0, lower_32_bits(cbdr->dma_base_align)); + netc_write(cbdr->regs.bar1, upper_32_bits(cbdr->dma_base_align)); + + /* Step 2: Configure the producer index register */ + netc_write(cbdr->regs.pir, cbdr->next_to_clean); + + /* Step 3: Configure the consumer index register */ + netc_write(cbdr->regs.cir, cbdr->next_to_use); + + /* Step4: Configure the number of BDs of the Control BD Ring */ + netc_write(cbdr->regs.lenr, cbdr->bd_num); + + /* Step 5: Enable the Control BD Ring */ + netc_write(cbdr->regs.mr, NETC_CBDR_MR_EN); + + return 0; +} +EXPORT_SYMBOL_GPL(netc_setup_cbdr); + +void netc_teardown_cbdr(struct device *dev, struct netc_cbdr *cbdr) +{ + /* Disable the Control BD Ring */ + netc_write(cbdr->regs.mr, 0); + dma_free_coherent(dev, cbdr->dma_size, cbdr->addr_base, + cbdr->dma_base); + memset(cbdr, 0, sizeof(*cbdr)); +} +EXPORT_SYMBOL_GPL(netc_teardown_cbdr); + +static int netc_get_free_cbd_num(struct netc_cbdr *cbdr) +{ + return (cbdr->next_to_clean - cbdr->next_to_use - 1 + + cbdr->bd_num) % cbdr->bd_num; +} + +static union netc_cbd *netc_get_cbd(struct netc_cbdr *cbdr, int index) +{ + return &((union netc_cbd *)(cbdr->addr_base_align))[index]; +} + +static void netc_clean_cbdr(struct netc_cbdr *cbdr) +{ + union netc_cbd *cbd; + int i; + + i = cbdr->next_to_clean; + while (netc_read(cbdr->regs.cir) != i) { + cbd = netc_get_cbd(cbdr, i); + memset(cbd, 0, sizeof(*cbd)); + i = (i + 1) % cbdr->bd_num; + } + + cbdr->next_to_clean = i; +} + +static struct netc_cbdr *netc_select_cbdr(struct netc_cbdrs *cbdrs) +{ + int i; + + for (i = 0; i < cbdrs->cbdr_num; i++) { + if (spin_is_locked(&cbdrs->ring[i].ring_lock)) + continue; + + return &cbdrs->ring[i]; + } + + return &cbdrs->ring[smp_processor_id() % cbdrs->cbdr_num]; +} + +static int netc_xmit_ntmp_cmd(struct netc_cbdrs *cbdrs, union netc_cbd *cbd) +{ + union netc_cbd *cur_cbd; + struct netc_cbdr *cbdr; + int i, err; + u16 status; + u32 val; + + if (cbdrs->cbdr_num == 1) + cbdr = &cbdrs->ring[0]; + else + cbdr = netc_select_cbdr(cbdrs); + + spin_lock_bh(&cbdr->ring_lock); + + if (unlikely(!netc_get_free_cbd_num(cbdr))) + netc_clean_cbdr(cbdr); + + i = cbdr->next_to_use; + cur_cbd = netc_get_cbd(cbdr, i); + *cur_cbd = *cbd; + + /* Update producer index of both software and hardware */ + i = (i + 1) % cbdr->bd_num; + cbdr->next_to_use = i; + dma_wmb(); + netc_write(cbdr->regs.pir, i); + + err = read_poll_timeout_atomic(netc_read, val, val == i, + 10, NETC_CBDR_TIMEOUT, true, + cbdr->regs.cir); + if (unlikely(err)) + goto cbdr_unlock; + + dma_rmb(); + /* Get the writeback command BD, because the caller may need + * to check some other fields of the response header. + */ + *cbd = *cur_cbd; + + /* Check the writeback error status */ + status = le16_to_cpu(cbd->resp_hdr.error_rr) & NTMP_RESP_ERROR; + if (unlikely(status)) { + err = -EIO; + dev_err(cbdrs->dma_dev, "Command BD error: 0x%04x\n", status); + } + + netc_clean_cbdr(cbdr); + dma_wmb(); + +cbdr_unlock: + spin_unlock_bh(&cbdr->ring_lock); + + return err; +} + +static void *ntmp_alloc_data_mem(struct device *dev, int size, + dma_addr_t *dma, void **data_align) +{ + void *data; + + data = dma_alloc_coherent(dev, size + NTMP_DATA_ADDR_ALIGN, + dma, GFP_ATOMIC); + if (!data) + return NULL; + + *data_align = PTR_ALIGN(data, NTMP_DATA_ADDR_ALIGN); + + return data; +} + +static void ntmp_free_data_mem(struct device *dev, int size, + void *data, dma_addr_t dma) +{ + dma_free_coherent(dev, size + NTMP_DATA_ADDR_ALIGN, data, dma); +} + +static void ntmp_fill_request_headr(union netc_cbd *cbd, dma_addr_t dma, + int len, int table_id, int cmd, + int access_method) +{ + dma_addr_t dma_align; + + memset(cbd, 0, sizeof(*cbd)); + dma_align = ALIGN(dma, NTMP_DATA_ADDR_ALIGN); + cbd->req_hdr.addr = cpu_to_le64(dma_align); + cbd->req_hdr.len = cpu_to_le32(len); + cbd->req_hdr.cmd = cmd; + cbd->req_hdr.access_method = FIELD_PREP(NTMP_ACCESS_METHOD, + access_method); + cbd->req_hdr.table_id = table_id; + cbd->req_hdr.ver_cci_rr = FIELD_PREP(NTMP_HDR_VERSION, + NTMP_HDR_VER2); + /* For NTMP version 2.0 or later version */ + cbd->req_hdr.npf = cpu_to_le32(NTMP_NPF); +} + +static int ntmp_delete_entry_by_id(struct netc_cbdrs *cbdrs, int tbl_id, + u8 tbl_ver, u32 entry_id, u32 req_len, + u32 resp_len) +{ + struct device *dev = cbdrs->dma_dev; + struct ntmp_req_by_eid *req; + union netc_cbd cbd; + u32 len, dma_len; + dma_addr_t dma; + void *tmp; + int err; + + if (entry_id == NTMP_NULL_ENTRY_ID) + return 0; + + /* If the req_len is 0, indicates the requested length is the + * standard length. + */ + if (!req_len) + req_len = sizeof(*req); + + dma_len = req_len >= resp_len ? req_len : resp_len; + tmp = ntmp_alloc_data_mem(dev, dma_len, &dma, (void **)&req); + if (!tmp) + return -ENOMEM; + + NTMP_FILL_CRD_EID(req, tbl_ver, 0, 0, entry_id); + len = NTMP_LEN(req_len, resp_len); + ntmp_fill_request_headr(&cbd, dma, len, tbl_id, + NTMP_CMD_DELETE, NTMP_AM_ENTRY_ID); + + err = netc_xmit_ntmp_cmd(cbdrs, &cbd); + if (err) + dev_err(dev, "Delete table (id: %d) entry failed: %d!", + tbl_id, err); + + ntmp_free_data_mem(dev, dma_len, tmp, dma); + + return err; +} + +static int ntmp_query_entry_by_id(struct netc_cbdrs *cbdrs, int tbl_id, + u32 len, struct ntmp_req_by_eid *req, + dma_addr_t *dma, bool compare_eid) +{ + struct device *dev = cbdrs->dma_dev; + struct common_resp_query *resp; + int cmd = NTMP_CMD_QUERY; + union netc_cbd cbd; + u32 entry_id; + int err; + + entry_id = le32_to_cpu(req->entry_id); + if (le16_to_cpu(req->crd.update_act)) + cmd = NTMP_CMD_QU; + + /* Request header */ + ntmp_fill_request_headr(&cbd, *dma, len, tbl_id, + cmd, NTMP_AM_ENTRY_ID); + + err = netc_xmit_ntmp_cmd(cbdrs, &cbd); + if (err) { + dev_err(dev, "Query table (id: %d) entry failed: %d\n", + tbl_id, err); + return err; + } + + /* For a few tables, the first field of its response data is not + * entry_id, so directly return success. + */ + if (!compare_eid) + return 0; + + resp = (struct common_resp_query *)req; + if (unlikely(le32_to_cpu(resp->entry_id) != entry_id)) { + dev_err(dev, "Table (id: %d) query EID:0x%0x, response EID:0x%x\n", + tbl_id, entry_id, le32_to_cpu(resp->entry_id)); + return -EIO; + } + + return 0; +} + +int ntmp_maft_add_entry(struct netc_cbdrs *cbdrs, u32 entry_id, + struct maft_entry_data *data) +{ + struct device *dev = cbdrs->dma_dev; + struct maft_req_add *req; + union netc_cbd cbd; + dma_addr_t dma; + u32 req_len; + void *tmp; + int err; + + req_len = sizeof(*req); + tmp = ntmp_alloc_data_mem(dev, req_len, &dma, (void **)&req); + if (!tmp) + return -ENOMEM; + + /* Set mac address filter table request data buffer */ + NTMP_FILL_CRD_EID(req, cbdrs->tbl.maft_ver, 0, 0, entry_id); + req->keye = data->keye; + req->cfge = data->cfge; + + ntmp_fill_request_headr(&cbd, dma, NTMP_LEN(req_len, 0), + NTMP_MAFT_ID, NTMP_CMD_ADD, + NTMP_AM_ENTRY_ID); + err = netc_xmit_ntmp_cmd(cbdrs, &cbd); + if (err) + dev_err(dev, "Add MAFT entry failed (%d)!", err); + + ntmp_free_data_mem(dev, req_len, tmp, dma); + + return err; +} +EXPORT_SYMBOL_GPL(ntmp_maft_add_entry); + +int ntmp_maft_query_entry(struct netc_cbdrs *cbdrs, u32 entry_id, + struct maft_entry_data *data) +{ + struct device *dev = cbdrs->dma_dev; + struct maft_resp_query *resp; + u32 resp_len = sizeof(*resp); + struct ntmp_req_by_eid *req; + u32 req_len = sizeof(*req); + void *tmp = NULL; + dma_addr_t dma; + int err; + + if (entry_id == NTMP_NULL_ENTRY_ID) + return -EINVAL; + + tmp = ntmp_alloc_data_mem(dev, resp_len, &dma, (void **)&req); + if (!tmp) + return -ENOMEM; + + NTMP_FILL_CRD_EID(req, cbdrs->tbl.maft_ver, 0, 0, entry_id); + err = ntmp_query_entry_by_id(cbdrs, NTMP_MAFT_ID, + NTMP_LEN(req_len, resp_len), + req, &dma, true); + if (err) + goto end; + + resp = (struct maft_resp_query *)req; + data->keye = resp->keye; + data->cfge = resp->cfge; + +end: + ntmp_free_data_mem(dev, resp_len, tmp, dma); + + return err; +} +EXPORT_SYMBOL_GPL(ntmp_maft_query_entry); + +int ntmp_maft_delete_entry(struct netc_cbdrs *cbdrs, u32 entry_id) +{ + return ntmp_delete_entry_by_id(cbdrs, NTMP_MAFT_ID, + cbdrs->tbl.maft_ver, + entry_id, 0, 0); +} +EXPORT_SYMBOL_GPL(ntmp_maft_delete_entry); + +int ntmp_rsst_query_or_update_entry(struct netc_cbdrs *cbdrs, u32 *table, + int count, bool query) +{ + struct device *dev = cbdrs->dma_dev; + struct rsst_req_update *requ; + struct ntmp_req_by_eid *req; + union netc_cbd cbd; + u32 len, data_size; + dma_addr_t dma; + int err, i; + void *tmp; + + if (count != RSST_ENTRY_NUM) + /* HW only takes in a full 64 entry table */ + return -EINVAL; + + if (query) + data_size = NTMP_ENTRY_ID_SIZE + RSST_STSE_DATA_SIZE(count) + + RSST_CFGE_DATA_SIZE(count); + else + data_size = struct_size(requ, groups, count); + + tmp = ntmp_alloc_data_mem(dev, data_size, &dma, (void **)&req); + if (!tmp) + return -ENOMEM; + + /* Set the request data buffer */ + if (query) { + NTMP_FILL_CRD_EID(req, cbdrs->tbl.rsst_ver, 0, 0, 0); + len = NTMP_LEN(sizeof(*req), data_size); + ntmp_fill_request_headr(&cbd, dma, len, NTMP_RSST_ID, + NTMP_CMD_QUERY, NTMP_AM_ENTRY_ID); + } else { + requ = (struct rsst_req_update *)req; + NTMP_FILL_CRD_EID(requ, cbdrs->tbl.rsst_ver, 0, + NTMP_GEN_UA_CFGEU | NTMP_GEN_UA_STSEU, 0); + for (i = 0; i < count; i++) + requ->groups[i] = (u8)(table[i]); + + len = NTMP_LEN(data_size, 0); + ntmp_fill_request_headr(&cbd, dma, len, NTMP_RSST_ID, + NTMP_CMD_UPDATE, NTMP_AM_ENTRY_ID); + } + + err = netc_xmit_ntmp_cmd(cbdrs, &cbd); + if (err) { + dev_err(dev, "%s RSS table entry failed (%d)!", + query ? "Query" : "Update", err); + goto end; + } + + if (query) { + u8 *group = (u8 *)req; + + group += NTMP_ENTRY_ID_SIZE + RSST_STSE_DATA_SIZE(count); + for (i = 0; i < count; i++) + table[i] = group[i]; + } + +end: + ntmp_free_data_mem(dev, data_size, tmp, dma); + + return err; +} +EXPORT_SYMBOL_GPL(ntmp_rsst_query_or_update_entry); + +MODULE_DESCRIPTION("NXP NETC Library"); +MODULE_LICENSE("Dual BSD/GPL"); diff --git a/drivers/net/ethernet/freescale/enetc/ntmp_formats.h b/drivers/net/ethernet/freescale/enetc/ntmp_formats.h new file mode 100644 index 000000000000..3fab5a0f2cc5 --- /dev/null +++ b/drivers/net/ethernet/freescale/enetc/ntmp_formats.h @@ -0,0 +1,61 @@ +/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */ +/* + * NTMP table request and response data buffer formats + * Copyright 2025 NXP + */ + +#ifndef __NTMP_FORMATS_H +#define __NTMP_FORMATS_H +#include + +#pragma pack(1) + +struct common_req_data { + __le16 update_act; + u8 dbg_opt; + u8 tblv_qact; +#define NTMP_QUERY_ACT GENMASK(3, 0) +#define NTMP_TBL_VER GENMASK(7, 0) +#define NTMP_TBLV_QACT(v, a) (FIELD_PREP(NTMP_TBL_VER, (v)) | \ + ((a) & NTMP_QUERY_ACT)) +}; + +struct common_resp_query { + __le32 entry_id; +}; + +struct common_resp_nq { + __le32 status; +}; + +/* Generic structure for request data by entry ID */ +struct ntmp_req_by_eid { + struct common_req_data crd; + __le32 entry_id; +}; + +/* MAC Address Filter Table Request Data Buffer Format of Add action */ +struct maft_req_add { + struct common_req_data crd; + __le32 entry_id; + struct maft_keye_data keye; + struct maft_cfge_data cfge; +}; + +/* MAC Address Filter Table Response Data Buffer Format of Query action */ +struct maft_resp_query { + __le32 entry_id; + struct maft_keye_data keye; + struct maft_cfge_data cfge; +}; + +/* RSS Table Request Data Buffer Format of Update action */ +struct rsst_req_update { + struct common_req_data crd; + __le32 entry_id; + u8 groups[]; +}; + +#pragma pack() + +#endif diff --git a/include/linux/fsl/ntmp.h b/include/linux/fsl/ntmp.h new file mode 100644 index 000000000000..7cf322a1c8e3 --- /dev/null +++ b/include/linux/fsl/ntmp.h @@ -0,0 +1,178 @@ +/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */ +/* Copyright 2025 NXP */ +#ifndef __NETC_NTMP_H +#define __NETC_NTMP_H + +#include +#include + +#define NTMP_NULL_ENTRY_ID 0xffffffffU +#define NETC_CBDR_BD_NUM 256 + +#pragma pack(1) + +union netc_cbd { + struct { + __le64 addr; + __le32 len; +#define NTMP_RESP_LEN GENMASK(19, 0) +#define NTMP_REQ_LEN GENMASK(31, 20) +#define NTMP_LEN(req, resp) (FIELD_PREP(NTMP_REQ_LEN, (req)) | \ + ((resp) & NTMP_RESP_LEN)) + u8 cmd; +#define NTMP_CMD_DELETE BIT(0) +#define NTMP_CMD_UPDATE BIT(1) +#define NTMP_CMD_QUERY BIT(2) +#define NTMP_CMD_ADD BIT(3) +#define NTMP_CMD_QD (NTMP_CMD_QUERY | NTMP_CMD_DELETE) +#define NTMP_CMD_QU (NTMP_CMD_QUERY | NTMP_CMD_UPDATE) +#define NTMP_CMD_AU (NTMP_CMD_ADD | NTMP_CMD_UPDATE) +#define NTMP_CMD_AQ (NTMP_CMD_ADD | NTMP_CMD_QUERY) +#define NTMP_CMD_AQU (NTMP_CMD_AQ | NTMP_CMD_UPDATE) + u8 access_method; +#define NTMP_ACCESS_METHOD GENMASK(7, 4) +#define NTMP_AM_ENTRY_ID 0 +#define NTMP_AM_EXACT_KEY 1 +#define NTMP_AM_SEARCH 2 +#define NTMP_AM_TERNARY_KEY 3 + u8 table_id; + u8 ver_cci_rr; +#define NTMP_HDR_VERSION GENMASK(5, 0) +#define NTMP_HDR_VER2 2 +#define NTMP_CCI BIT(6) +#define NTMP_RR BIT(7) + __le32 resv[3]; + __le32 npf; +#define NTMP_NPF BIT(15) + } req_hdr; /* NTMP Request Message Header Format */ + + struct { + __le32 resv0[3]; + __le16 num_matched; + __le16 error_rr; +#define NTMP_RESP_ERROR GENMASK(11, 0) +#define NTMP_RESP_RR BIT(15) + __le32 resv1[4]; + } resp_hdr; /* NTMP Response Message Header Format */ +}; + +struct maft_keye_data { + u8 mac_addr[ETH_ALEN]; + __le16 resv; +}; + +struct maft_cfge_data { + __le16 si_bitmap; + __le16 resv; +}; + +#pragma pack() + +struct netc_cbdr_regs { + void __iomem *pir; + void __iomem *cir; + void __iomem *mr; + + void __iomem *bar0; + void __iomem *bar1; + void __iomem *lenr; +}; + +struct netc_tbl_vers { + u8 maft_ver; + u8 rsst_ver; +}; + +struct netc_cbdr { + struct netc_cbdr_regs regs; + + int bd_num; + int next_to_use; + int next_to_clean; + + int dma_size; + void *addr_base; + void *addr_base_align; + dma_addr_t dma_base; + dma_addr_t dma_base_align; + + spinlock_t ring_lock; /* Avoid race condition */ +}; + +struct netc_cbdrs { + int cbdr_num; /* number of control BD ring */ + int cbdr_size; /* number of BDs per control BD ring */ + struct device *dma_dev; + struct netc_cbdr *ring; + struct netc_tbl_vers tbl; +}; + +enum netc_dev_type { + NETC_DEV_ENETC, + NETC_DEV_SWITCH +}; + +struct ntmp_priv { + enum netc_dev_type dev_type; + struct netc_cbdrs cbdrs; +}; + +struct maft_entry_data { + struct maft_keye_data keye; + struct maft_cfge_data cfge; +}; + +#if IS_ENABLED(CONFIG_NXP_NETC_LIB) +int netc_setup_cbdr(struct device *dev, int cbd_num, + struct netc_cbdr_regs *regs, + struct netc_cbdr *cbdr); +void netc_teardown_cbdr(struct device *dev, struct netc_cbdr *cbdr); + +/* NTMP APIs */ +int ntmp_maft_add_entry(struct netc_cbdrs *cbdrs, u32 entry_id, + struct maft_entry_data *data); +int ntmp_maft_query_entry(struct netc_cbdrs *cbdrs, u32 entry_id, + struct maft_entry_data *data); +int ntmp_maft_delete_entry(struct netc_cbdrs *cbdrs, u32 entry_id); +int ntmp_rsst_query_or_update_entry(struct netc_cbdrs *cbdrs, + u32 *table, int count, bool query); +#else +static inline int netc_setup_cbdr(struct device *dev, int cbd_num, + struct netc_cbdr_regs *regs, + struct netc_cbdr *cbdr) +{ + return 0; +} + +static inline void netc_teardown_cbdr(struct device *dev, + struct netc_cbdr *cbdr) +{ +} + +static inline int ntmp_maft_add_entry(struct netc_cbdrs *cbdrs, u32 entry_id, + struct maft_entry_data *data) +{ + return 0; +} + +static inline int ntmp_maft_query_entry(struct netc_cbdrs *cbdrs, u32 entry_id, + struct maft_entry_data *data) +{ + return 0; +} + +static inline int ntmp_maft_delete_entry(struct netc_cbdrs *cbdrs, u32 entry_id) +{ + return 0; +} + +static inline int ntmp_rsst_query_or_update_entry(struct netc_cbdrs *cbdrs, + u32 *table, int count, + bool query) +{ + return 0; +} + +#endif + +#endif From patchwork Fri Jan 3 06:05:58 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Wei Fang X-Patchwork-Id: 13925200 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2064.outbound.protection.outlook.com [40.107.105.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 76C8419D8BB; Fri, 3 Jan 2025 06:23:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.105.64 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735885396; cv=fail; b=Gbu4mfarftQRZe+ndwVcciqPanEqvJCOTQoka6IVaOn7pc/aVdJJg6RgJeIF2UtLbV90oXmctj7kpzE2KtbKr1ltLDUMFjnOB59NlMTzbclmXPzXD6OFCokGMck6gm1PqeFeS8/l9E4Yk3D4NFx38WKpnts+jvZBkz34mB+8zO4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735885396; c=relaxed/simple; bh=o6VL3RaUt3YsbC0KkiWpqYdlXrslh4N8+5eB0P5BKFs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=ATCn2EFpmDL3Oeco/Ttjf1TcuAZsh/+CawRPul9LrGdie3QRmGaZlTdIARBrgMb4U/rTYi+Hn4iSUvK68HfMd2DEFMD2QYEqa3rK+rctisS+fpceZ+YSAfTkJd6A87Yb+h4nGk7OdOLdFfJw7NbKAAShD6isGoStJZTuMdvGpPk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=JwyziDuR; arc=fail smtp.client-ip=40.107.105.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="JwyziDuR" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=FWvcp309hUKMWBcSs29B0QXBZyKE1jKbv5J2aHOCTMvojMASbu16efGaTcwxbYIFY7EiKHOdTklX7EDebQXA1+sQyFB670rEsEb5+Au1glvviaoynJwcWpcOYpTEBMs7fPlbD/Uk0WFogjcAfqlsOEfoLi0w2Kcf/l15q4Z/tW8x8/5Vde/oPkmi7/jYLvisiKRgDNr0mn2FY1A/32fA0dDr+2oziSBjgbGAT9+B8bHWkA6vxRQAyv0ErMBaoa7PnPjBMpysTqubb5R8Ufjm6KBcs/gKwbEpW70H5TmrZ/zGbHF0uMp4MvV8nFI9M134tHe8Djj3Frmldf2B4duJyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=9bCQNiwK7K1F2JDZJALRi13v1jEviPQA8zZUG2DI5Qo=; b=Keh8zDpL2sHPitG1O6JBAuz53zlrAyW1d7iVR2ppXKsjQlAeOAsjyrNEzRO8YtCSGHeeEwLj0Y09TYgMIoADYXxksp8wkBkKOlS6MCizCboqLo4+XvglXS584t0G2tjPTWAJomFvUlOdVpmw0G86XnlBF9Dz7A2OYPVOfuChzvJKO7XeTzg4JBy32v7SeF2gOTMhSKSRo7++OLhkq04OFGRBDhtG4rVWTFV/rLPRMgkh6F41n8CN0punYnOsjzQtUT8Pdfbd0Nl/18GHr3YtQBmLAhZPbmM9JwIsOZI0l6IInx5pUkQBIFkEI/Tw1mtK/spVdb9YQudeqbBIPlPFMA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9bCQNiwK7K1F2JDZJALRi13v1jEviPQA8zZUG2DI5Qo=; b=JwyziDuRgiiVt6wwqsPY4c2EjeHY7LBjMdz92Lq0oDPMutrUAoWn7HtnqLhkRv4BFxBkPr/VSjzQe+4QcOYy/Q1rym/PY40I2442+e8jAZItZiSjn5N6j97FclerFWbohPhh5XY95QTH1RjDIq4AXTKW8qDCTSExEw5xww+N+YTTChNV1VpIqGyaBsBbjUn26XCI1nh1/b7Kfp52DoOsvKuhH+03TBGIVOlUw/GN3Ttk+JzZMfLkDgygnfDeuEACWBXNG/PmLvr56EDhS+A6E7f7dKAY406q3JJc+TaDPdasggaKHPLhLr+oPqnq8RjmQG4Oo/wkkxWHGzZKGdmrMw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) by DB9PR04MB9331.eurprd04.prod.outlook.com (2603:10a6:10:36d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.12; Fri, 3 Jan 2025 06:23:06 +0000 Received: from PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db]) by PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db%6]) with mapi id 15.20.8314.013; Fri, 3 Jan 2025 06:23:06 +0000 From: Wei Fang To: claudiu.manoil@nxp.com, vladimir.oltean@nxp.com, xiaoning.wang@nxp.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, christophe.leroy@csgroup.eu Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, imx@lists.linux.dev Subject: [PATCH net-next 02/13] net: enetc: add command BD ring support for i.MX95 ENETC Date: Fri, 3 Jan 2025 14:05:58 +0800 Message-Id: <20250103060610.2233908-3-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250103060610.2233908-1-wei.fang@nxp.com> References: <20250103060610.2233908-1-wei.fang@nxp.com> X-ClientProxiedBy: SG2PR03CA0127.apcprd03.prod.outlook.com (2603:1096:4:91::31) To PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8510:EE_|DB9PR04MB9331:EE_ X-MS-Office365-Filtering-Correlation-Id: 9ad913ab-763f-4d55-5ef7-08dd2bbf1610 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|1800799024|7416014|366016|38350700014; X-Microsoft-Antispam-Message-Info: RVm/TgfHbz+ZLzrmUyP0hH9QIjtiBQYDH6zsWAnvaQZbUT16nzgqGsWBiWI2mYFCJBGSFCnm61Bnty5ZLDZzUE3hjDd8IUGYLghWIQNMPsqmWGL8OnA71MpdSyMBzHbIF09S2x5+b141yOu2U99p7DAD4Noje+hLtZAcqY+09tI5NjBS4iGClOoFiMD/ulsl4Q6U4nWY/lvYKIEK0HDDrIPhzuvCWoI9ZUcIBX2xkLZRQU/rhgBho5Q7uolk1nqifooOpd6/f4OL1iYSBpSWMtl6jDLV2IZQpqDFgoriunyOc5blJTLPEnfM3Pq8l2G2EgMRqLKvxlhz/yBY8iYm51GimcyZIA5PBrtcyM46Tl0hVcDqsGkK9XMhPlEIbClD3F9Z110ajDKMAtM70B+NZdptfZ41wX/yKLR4/a+irzFAeYQtSdqEkgXyDI2B5+1bGzoNKnKgmi5XDY+fQtXraJr9HulmXPN73g/7b+ygxrplf3Q61jKvJ7xXxeqeA6wpFqgT826YVC6FW91ouDS12kqXOzY2tD97Ac9AYswmsTT1Ps1h2TFCYPN+PXJOznRXNHbU5TMNRMWyuCuYa3S4rF30PV1IhnWDj8ToTfgwNWIUY1blHb5Mj9YDkaZTskqI6X1TPQNDT69NQ5pWHRj3Qh7GLEG1ZoRsI+J4f/gPDc9pDTexnVLJlLClN6pY/BGLkxVjaYZ7/kaOh0Bo/ClIdjCxOQbFfQDYl1XLk+5fLATUzmdbwI3oqdmCL+safoQl/SlprYdj+S5yrh2uEY1g3TzB/gWNkTRwWIDPlC39lhEYWnVwGDJ1n0UI5kbW6dc6KRNNIDYjvPtvz4iwoI8Xar/qjgieRIkyfhvmPwp2Qp31v+g/YGs0DAimeagIv37+ecN27BBitEITPUNBdWs8+Uan4HZkqunKBP3I7ZuwecQ6/wkfHQ+4HXUgt0Q5AaOk2QJGlvi7v7XR0z9WoBNv3Cx+z2VXNmCe0njpvaTqc4FzyxOvCCGMQK3I+bTqrMhNcG5Q1oTxcEQ7gfTJSwVKcjegQz6mu1+LcYwTVRemIMh1iNCk5Wu0OtSJNHso7AEUJTS9fflsnuP1VmEviAL/uQ2VateNqiz2gz0rbbTW+4wmEpFkF3+avRbyouBqrPiPSYgzmnDkUWT8yQ0Dd9MdyxrFw939FbWnsUIl+X7bNjm7DroK6f7FcskmUgBFTRp2lNwklq75Es1PwbBkScBHBPvCuzxcJ1dyaydFSaccOhv84tr72VrpC6ye4g6K0wUNaJ4AuaC5qlXv+soo2UQ8ERMRd6wxsZYYxD2Z/1hOo8aWPUpb1tRTB1UY385lda005vC2DuuciQ3FM1p6raOpT1Jozo94fI24bg4PuG/cJQIwUQmykwssSN2p3frkb/s1l4iQDbjI/LWV9yilVfj9SYd8tT9Mb3OLCmgE7usSTiptQglcDWz+K+eUy8+dmRIN X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8510.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(376014)(1800799024)(7416014)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: nODKiQMHOmjI3RvAVnrwxQkz3pCevYQRqoiuo40KaoSX8pCswmPWU9y+XOCxM9bYX2nmHveG3BTHj9dLSQmXRAgDZsX9CReXbzfkdh+igYfCU3OzckZVcgLm8mWz93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acaXmT+lLDEB+0pnrCM5e2j1V2uqoszUdRz/sK3rauwp8rHrbQ0VTtAnRSIn0893KylbyzHDZx5MzNjR4enHGxp/tCZs0mOTLJqNOfh9YDMDHHXJpu+r4lTtJOorVIxD28HCqZFCm6xdm4LFz/dBNvm73aOSsOwhoXc8B0TT4K+GesijF76dIJCeHVJV5U2ilDy8x5qWRhyzqUGrTzUzC2RarcCrwiQlOOOGNbarx36rFcopBQuSjF6jy0i345/1U/CE6StbJ0RZInHztsV33MU6iaNNN1pFJ57EduPZBwq2w7hQi8JEhNU08lDZr5EgoDAgYPoaaCH0yV1ya3HEQ6oW730M5haSGJ1Bj9PSswDgFnpjBf24uH67omBymqzLPJBZDymay2iTUdYGhWJcPajV4lE X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9ad913ab-763f-4d55-5ef7-08dd2bbf1610 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jan 2025 06:23:06.9052 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: HQ6EhtHEVpdisj0i1+VaSMrZWKPJogPBczgdL5jnGX8JAm53bvS0VH2ujyfvdP5nPXIF5RgWi3m1FYKfWDTHLA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB9331 X-Patchwork-Delegate: kuba@kernel.org The command BD ring is used to configure functionality where the underlying resources may be shared between different entities or being too large to configure using direct registers (such as lookup tables). Because the command BD and table formats of i.MX95 and LS1028A are very different, the software processing logic is also different. In order to ensure driver compatibility, struct enetc_si_ops is introduced. This structure defines some hooks shared by VSI and PSI. Different hardware driver will register different hooks, For example, setup_cbdr() is used to initialize the command BD ring, and teardown_cbdr() is used to free the command BD ring. Signed-off-by: Wei Fang --- drivers/net/ethernet/freescale/enetc/enetc.h | 27 ++++++++-- .../net/ethernet/freescale/enetc/enetc4_pf.c | 47 ++++++++++++++++- .../net/ethernet/freescale/enetc/enetc_cbdr.c | 51 ++++++++++++++++--- .../net/ethernet/freescale/enetc/enetc_pf.c | 13 +++-- .../net/ethernet/freescale/enetc/enetc_vf.c | 13 +++-- 5 files changed, 132 insertions(+), 19 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.h b/drivers/net/ethernet/freescale/enetc/enetc.h index 4ad4eb5c5a74..4ff0957e69be 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.h +++ b/drivers/net/ethernet/freescale/enetc/enetc.h @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -266,6 +267,19 @@ struct enetc_platform_info { const struct enetc_drvdata *data; }; +struct enetc_si; + +/* + * This structure defines the some common hooks for ENETC PSI and VSI. + * In addition, since VSI only uses the struct enetc_si as its private + * driver data, so this structure also define some hooks specifically + * for VSI. For VSI-specific hooks, the format is ‘vf_*()’. + */ +struct enetc_si_ops { + int (*setup_cbdr)(struct enetc_si *si); + void (*teardown_cbdr)(struct enetc_si *si); +}; + /* PCI IEP device data */ struct enetc_si { struct pci_dev *pdev; @@ -274,7 +288,10 @@ struct enetc_si { struct net_device *ndev; /* back ref. */ - struct enetc_cbdr cbd_ring; + union { + struct enetc_cbdr cbd_ring; /* Only ENETC 1.0 */ + struct ntmp_priv ntmp; /* ENETC 4.1 and later */ + }; int num_rx_rings; /* how many rings are available in the SI */ int num_tx_rings; @@ -284,6 +301,7 @@ struct enetc_si { u16 revision; int hw_features; const struct enetc_drvdata *drvdata; + const struct enetc_si_ops *ops; }; #define ENETC_SI_ALIGN 32 @@ -490,9 +508,10 @@ void enetc_mm_link_state_update(struct enetc_ndev_priv *priv, bool link); void enetc_mm_commit_preemptible_tcs(struct enetc_ndev_priv *priv); /* control buffer descriptor ring (CBDR) */ -int enetc_setup_cbdr(struct device *dev, struct enetc_hw *hw, int bd_count, - struct enetc_cbdr *cbdr); -void enetc_teardown_cbdr(struct enetc_cbdr *cbdr); +int enetc_setup_cbdr(struct enetc_si *si); +void enetc_teardown_cbdr(struct enetc_si *si); +int enetc4_setup_cbdr(struct enetc_si *si); +void enetc4_teardown_cbdr(struct enetc_si *si); int enetc_set_mac_flt_entry(struct enetc_si *si, int index, char *mac_addr, int si_map); int enetc_clear_mac_flt_entry(struct enetc_si *si, int index); diff --git a/drivers/net/ethernet/freescale/enetc/enetc4_pf.c b/drivers/net/ethernet/freescale/enetc/enetc4_pf.c index fc41078c4f5d..b957e92e3a00 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc4_pf.c +++ b/drivers/net/ethernet/freescale/enetc/enetc4_pf.c @@ -260,6 +260,23 @@ static void enetc4_configure_port(struct enetc_pf *pf) enetc4_enable_trx(pf); } +static int enetc4_init_ntmp_priv(struct enetc_si *si) +{ + struct ntmp_priv *ntmp = &si->ntmp; + + ntmp->dev_type = NETC_DEV_ENETC; + + /* For ENETC 4.1, all table versions are 0 */ + memset(&ntmp->cbdrs.tbl, 0, sizeof(ntmp->cbdrs.tbl)); + + return si->ops->setup_cbdr(si); +} + +static void enetc4_free_ntmp_priv(struct enetc_si *si) +{ + si->ops->teardown_cbdr(si); +} + static int enetc4_pf_init(struct enetc_pf *pf) { struct device *dev = &pf->si->pdev->dev; @@ -272,11 +289,22 @@ static int enetc4_pf_init(struct enetc_pf *pf) return err; } + err = enetc4_init_ntmp_priv(pf->si); + if (err) { + dev_err(dev, "Failed to init CBDR\n"); + return err; + } + enetc4_configure_port(pf); return 0; } +static void enetc4_pf_free(struct enetc_pf *pf) +{ + enetc4_free_ntmp_priv(pf->si); +} + static const struct net_device_ops enetc4_ndev_ops = { .ndo_open = enetc_open, .ndo_stop = enetc_close, @@ -688,6 +716,11 @@ static void enetc4_pf_netdev_destroy(struct enetc_si *si) free_netdev(ndev); } +static const struct enetc_si_ops enetc4_psi_ops = { + .setup_cbdr = enetc4_setup_cbdr, + .teardown_cbdr = enetc4_teardown_cbdr, +}; + static int enetc4_pf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { @@ -712,6 +745,7 @@ static int enetc4_pf_probe(struct pci_dev *pdev, "Couldn't map PF only space\n"); si->revision = enetc_get_ip_revision(&si->hw); + si->ops = &enetc4_psi_ops; err = enetc_get_driver_data(si); if (err) return dev_err_probe(dev, err, @@ -728,14 +762,25 @@ static int enetc4_pf_probe(struct pci_dev *pdev, enetc_get_si_caps(si); - return enetc4_pf_netdev_create(si); + err = enetc4_pf_netdev_create(si); + if (err) + goto err_netdev_create; + + return 0; + +err_netdev_create: + enetc4_pf_free(pf); + + return err; } static void enetc4_pf_remove(struct pci_dev *pdev) { struct enetc_si *si = pci_get_drvdata(pdev); + struct enetc_pf *pf = enetc_si_priv(si); enetc4_pf_netdev_destroy(si); + enetc4_pf_free(pf); } static const struct pci_device_id enetc4_pf_id_table[] = { diff --git a/drivers/net/ethernet/freescale/enetc/enetc_cbdr.c b/drivers/net/ethernet/freescale/enetc/enetc_cbdr.c index 20bfdf7fb4b4..31bb82ee512d 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_cbdr.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_cbdr.c @@ -3,10 +3,12 @@ #include "enetc.h" -int enetc_setup_cbdr(struct device *dev, struct enetc_hw *hw, int bd_count, - struct enetc_cbdr *cbdr) +int enetc_setup_cbdr(struct enetc_si *si) { - int size = bd_count * sizeof(struct enetc_cbd); + int size = ENETC_CBDR_DEFAULT_SIZE * sizeof(struct enetc_cbd); + struct enetc_cbdr *cbdr = &si->cbd_ring; + struct device *dev = &si->pdev->dev; + struct enetc_hw *hw = &si->hw; cbdr->bd_base = dma_alloc_coherent(dev, size, &cbdr->bd_dma_base, GFP_KERNEL); @@ -23,7 +25,7 @@ int enetc_setup_cbdr(struct device *dev, struct enetc_hw *hw, int bd_count, cbdr->next_to_clean = 0; cbdr->next_to_use = 0; cbdr->dma_dev = dev; - cbdr->bd_count = bd_count; + cbdr->bd_count = ENETC_CBDR_DEFAULT_SIZE; cbdr->pir = hw->reg + ENETC_SICBDRPIR; cbdr->cir = hw->reg + ENETC_SICBDRCIR; @@ -46,13 +48,41 @@ int enetc_setup_cbdr(struct device *dev, struct enetc_hw *hw, int bd_count, } EXPORT_SYMBOL_GPL(enetc_setup_cbdr); -void enetc_teardown_cbdr(struct enetc_cbdr *cbdr) +int enetc4_setup_cbdr(struct enetc_si *si) { - int size = cbdr->bd_count * sizeof(struct enetc_cbd); + struct netc_cbdrs *cbdrs = &si->ntmp.cbdrs; + struct device *dev = &si->pdev->dev; + struct enetc_hw *hw = &si->hw; + struct netc_cbdr_regs regs; + + cbdrs->cbdr_num = 1; + cbdrs->cbdr_size = NETC_CBDR_BD_NUM; + cbdrs->dma_dev = dev; + cbdrs->ring = devm_kcalloc(dev, cbdrs->cbdr_num, + sizeof(struct netc_cbdr), GFP_KERNEL); + if (!cbdrs->ring) + return -ENOMEM; + + regs.pir = hw->reg + ENETC_SICBDRPIR; + regs.cir = hw->reg + ENETC_SICBDRCIR; + regs.mr = hw->reg + ENETC_SICBDRMR; + regs.bar0 = hw->reg + ENETC_SICBDRBAR0; + regs.bar1 = hw->reg + ENETC_SICBDRBAR1; + regs.lenr = hw->reg + ENETC_SICBDRLENR; + + return netc_setup_cbdr(dev, cbdrs->cbdr_size, ®s, cbdrs->ring); +} +EXPORT_SYMBOL_GPL(enetc4_setup_cbdr); + +void enetc_teardown_cbdr(struct enetc_si *si) +{ + struct enetc_cbdr *cbdr = &si->cbd_ring; + int size; /* disable ring */ enetc_wr_reg(cbdr->mr, 0); + size = cbdr->bd_count * sizeof(struct enetc_cbd); dma_free_coherent(cbdr->dma_dev, size, cbdr->bd_base, cbdr->bd_dma_base); cbdr->bd_base = NULL; @@ -60,6 +90,15 @@ void enetc_teardown_cbdr(struct enetc_cbdr *cbdr) } EXPORT_SYMBOL_GPL(enetc_teardown_cbdr); +void enetc4_teardown_cbdr(struct enetc_si *si) +{ + struct netc_cbdrs *cbdrs = &si->ntmp.cbdrs; + + netc_teardown_cbdr(cbdrs->dma_dev, cbdrs->ring); + cbdrs->dma_dev = NULL; +} +EXPORT_SYMBOL_GPL(enetc4_teardown_cbdr); + static void enetc_clean_cbdr(struct enetc_cbdr *ring) { struct enetc_cbd *dest_cbd; diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf.c b/drivers/net/ethernet/freescale/enetc/enetc_pf.c index 203862ec1114..a214749a4af6 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_pf.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf.c @@ -939,6 +939,11 @@ static int enetc_pf_register_with_ierb(struct pci_dev *pdev) return enetc_ierb_register_pf(ierb_pdev, pdev); } +static const struct enetc_si_ops enetc_psi_ops = { + .setup_cbdr = enetc_setup_cbdr, + .teardown_cbdr = enetc_teardown_cbdr, +}; + static struct enetc_si *enetc_psi_create(struct pci_dev *pdev) { struct enetc_si *si; @@ -957,6 +962,7 @@ static struct enetc_si *enetc_psi_create(struct pci_dev *pdev) goto out_pci_remove; } + si->ops = &enetc_psi_ops; si->revision = enetc_get_ip_revision(&si->hw); err = enetc_get_driver_data(si); if (err) { @@ -964,8 +970,7 @@ static struct enetc_si *enetc_psi_create(struct pci_dev *pdev) goto out_pci_remove; } - err = enetc_setup_cbdr(&pdev->dev, &si->hw, ENETC_CBDR_DEFAULT_SIZE, - &si->cbd_ring); + err = si->ops->setup_cbdr(si); if (err) goto out_pci_remove; @@ -984,7 +989,7 @@ static struct enetc_si *enetc_psi_create(struct pci_dev *pdev) return si; out_teardown_cbdr: - enetc_teardown_cbdr(&si->cbd_ring); + si->ops->teardown_cbdr(si); out_pci_remove: enetc_pci_remove(pdev); out: @@ -995,7 +1000,7 @@ static void enetc_psi_destroy(struct pci_dev *pdev) { struct enetc_si *si = pci_get_drvdata(pdev); - enetc_teardown_cbdr(&si->cbd_ring); + si->ops->teardown_cbdr(si); enetc_pci_remove(pdev); } diff --git a/drivers/net/ethernet/freescale/enetc/enetc_vf.c b/drivers/net/ethernet/freescale/enetc/enetc_vf.c index 3768752b6008..d7d9a720069b 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_vf.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_vf.c @@ -162,6 +162,11 @@ static void enetc_vf_netdev_setup(struct enetc_si *si, struct net_device *ndev, enetc_load_primary_mac_addr(&si->hw, ndev); } +static const struct enetc_si_ops enetc_vsi_ops = { + .setup_cbdr = enetc_setup_cbdr, + .teardown_cbdr = enetc_teardown_cbdr, +}; + static int enetc_vf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { @@ -176,6 +181,7 @@ static int enetc_vf_probe(struct pci_dev *pdev, si = pci_get_drvdata(pdev); si->revision = ENETC_REV_1_0; + si->ops = &enetc_vsi_ops; err = enetc_get_driver_data(si); if (err) { dev_err_probe(&pdev->dev, err, @@ -198,8 +204,7 @@ static int enetc_vf_probe(struct pci_dev *pdev, enetc_init_si_rings_params(priv); - err = enetc_setup_cbdr(priv->dev, &si->hw, ENETC_CBDR_DEFAULT_SIZE, - &si->cbd_ring); + err = si->ops->setup_cbdr(si); if (err) goto err_setup_cbdr; @@ -235,7 +240,7 @@ static int enetc_vf_probe(struct pci_dev *pdev, err_alloc_msix: enetc_free_si_resources(priv); err_alloc_si_res: - enetc_teardown_cbdr(&si->cbd_ring); + si->ops->teardown_cbdr(si); err_setup_cbdr: si->ndev = NULL; free_netdev(ndev); @@ -256,7 +261,7 @@ static void enetc_vf_remove(struct pci_dev *pdev) enetc_free_msix(priv); enetc_free_si_resources(priv); - enetc_teardown_cbdr(&si->cbd_ring); + si->ops->teardown_cbdr(si); free_netdev(si->ndev); From patchwork Fri Jan 3 06:05:59 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Fang X-Patchwork-Id: 13925201 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2075.outbound.protection.outlook.com [40.107.105.75]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5D3F91BCA1C; Fri, 3 Jan 2025 06:23:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.105.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735885401; cv=fail; b=WyUGAayaJnHv+aD5UB/DU6oSVyIRnVevsJxMX0aJX1W9Xcd8HvDSbiI6EpR1PjWUyz2gjJR2qHQZvG/IwYOSQ78ISUdYHbS/MyeIIANfj0hEwpXMk53AqSjSLLq8rLCsbujjXJzE1n4Y30XRKfhD8I6kte0+13EC0dsjXUoMitg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735885401; c=relaxed/simple; bh=w2h3k7ke/MFo8OegnFadOItp0it/c5Zi47WgLYVU1zQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=UFVlVXjvfVhHtxn1X/8uS6idEhO4kCobNt0uJQvoT1fcOhlu2R3Fjuk0WwzLgtdvI0JMxwoCkPc1IAgz7ZYaksrYaD4P+INC/Xy4suzrA0obM50PFAZDbP6sS835FycUDORMh+96X6fW/7vaTmLZUXWODrMCaptAIY0Td7PCyqs= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=RaQSY6ph; arc=fail smtp.client-ip=40.107.105.75 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="RaQSY6ph" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=UY47bMNaXkVsVxMv7E65/gpoajYi89vIKTv4eXG369SFxxdbjFLF+0mnj1DBMYA6JdiytpnFG5r9l4ONjQCaXn918haUKEP13+DDa41asuzElmSnmGuESZ6Rxu5Unps3fVladmacDFqVOpAIQ/kcYUeroT0njcLUT9sjtlkd4TB+/BjwK573uqgb2o/64eH2hlFc4Wt4n1M+a89oey1ofg6qmmONu5pvWXVjwM7noHIQp0pf3KQvBiP0DwZ7t5jWS1QuR+H9w/Rq7eLlBdQUd9gGahm+rV1cQEz6BXfB7o0wHNfl+Bj9bbfT967aICIyWfarz7C8gTA0QYVXGzsCxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=BaE2Ypc92Ok6czI2zettvmxX+IrZP2lNiBLQFEzkJOI=; b=StoMw9yPFx427UTk+P8TyciKESpq7CFgY5mJ6Xm7WdI2wzRipBUVKXr/51mQhBgDRtXV844Vh+9oVyc0Uv+98aDG49FTA7vIXu0RWYkz8kTW/0afEmpPv9ihNcDjVFEEaYqNF8gtxTYDWhch7rqzwjkUASxWslXsdSvz1NrGhxg135XBI9wntxfzYBusskdAwrSrvtOQewhUZjctwEr0yn162/wgoH/RzKhpUMIgULrIJ20rgeTPBXDWEsNCKzqdwKFP9hLp6A4qjsdYcBeBCcQJamDhrCqNKieLkxcPhFlmmV5KaoRRns0sm4RhEckoXrH3KQoQyvULMC51xDm5tA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BaE2Ypc92Ok6czI2zettvmxX+IrZP2lNiBLQFEzkJOI=; b=RaQSY6phZ/1dva4RGqhPudO8a9EctMYhNhd5ekmdsGbl+CIgLRQWdo3TgWjovV5mUquXCXPJKLDcrlffltSOanVriJ4oU8OdcReu1YQNjrZvem/74bJ/ivZT5WBh7q79kwA3qcaruB0eM9JyXJhqS9xMcMnoTH2lH9os+t36Z0NIIqkfUkci6gExzss1V/blfsV+nHxNiG8r2hehfZhqKjubYSgsmdL/Lq3NMSMc4hQf8yAzIf8Dj0Y8iMuMR5t/G53QFs5YKHQqs/Q01AVT7X6kGfxidWLq0HARQfEDAHwFG+9LukN/uPqQvctmilEnT9MvSmG7yOBI+yrcFmhahA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) by DB9PR04MB9331.eurprd04.prod.outlook.com (2603:10a6:10:36d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.12; Fri, 3 Jan 2025 06:23:12 +0000 Received: from PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db]) by PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db%6]) with mapi id 15.20.8314.013; Fri, 3 Jan 2025 06:23:12 +0000 From: Wei Fang To: claudiu.manoil@nxp.com, vladimir.oltean@nxp.com, xiaoning.wang@nxp.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, christophe.leroy@csgroup.eu Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, imx@lists.linux.dev Subject: [PATCH net-next 03/13] net: enetc: move generic MAC filterng interfaces to enetc-core Date: Fri, 3 Jan 2025 14:05:59 +0800 Message-Id: <20250103060610.2233908-4-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250103060610.2233908-1-wei.fang@nxp.com> References: <20250103060610.2233908-1-wei.fang@nxp.com> X-ClientProxiedBy: SG2PR03CA0127.apcprd03.prod.outlook.com (2603:1096:4:91::31) To PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8510:EE_|DB9PR04MB9331:EE_ X-MS-Office365-Filtering-Correlation-Id: 61c9b662-0f68-48eb-4ba1-08dd2bbf1902 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|1800799024|7416014|366016|38350700014; X-Microsoft-Antispam-Message-Info: QqdVEpzqOvrQ9iHUV49MABjRBqjneFOWX2+6LRYCDS1Wm77xSz445s1fsr4wmZCzqsYcZrndIKMvNU/sY+yI0nFD03Nd8QhKE+6A3mYL47qMnBtZjKQcJJh4BiwPk9iiO2VpCdV1+VUg8zkSZPuK7Gf82SANuB0LB3VevbhlVpkIp10W1Hr1ful5YR2xq1w83nmRYvMy1MLiO+WZMv51VusUI3nPx5RJ+m8xWL3MfjOGwF4KFC8ZROjbfy9HofE1bOqoaVYNHOriP9kZX2dkIOcdpUvLzpAWQcuIAYrDnzyIOomvt8BtAU9gmLstG3+Sn7nksDKAyfkbxNIatBX5hGcDedKBbpPv6U8jPhYFJwccKs+QVSctFFpUQojr611awBfBrraWRuIkBub9mA4gPHSgyG2CWZxFuiRI1wLNOTLBL2iO+qfwljZL02+EaddFPdJpvhVT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V:NSPM;H:PAXPR04MB8510.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(376014)(1800799024)(7416014)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: VM36ZKUVFz+SqX8Gq70Pc9L2GYyIUVARSWtK0CIo1nY11WjT8xA9mtBsMu8n4lEpOiJXsSPB8UJzsqq5GbIPyYvohGCAqmNNoE5rRNTH8oOLMbgm77L87/rIY5z6/alhomHh6C2161zSVzY6C4PLq600OB9n7P2IZ+X7EKC9qA0gtMIwZ8JgLUU9R+vLeWTUN37p3GLfJfSp7xbt1phmVwBltik267o3Dt3J4T0WzXE62rf0xCIAy3bZMj7XtYD9jsJzo7DuzMpxUz7IRi+xWk23z9QQa1MhWoNcVvoqDTQC3RVxIkHU8nGgOF6xSG8+BGTtqxYL5OJFnAmyN8expZI1vWbnkhw+XphiXqZIN47tMCk9AzUdj+uqpkhDj+Q5hDBDKdnzn6dT0H3gi9dmywjxrzmvN7zMsa6XuiWCklzNJFMPflI+NwgtX2EzijxotVJK1+aMPgYAHopQz/NY9HWEgBjuS5DiYsJmDdrCfIV1bY2crqdq8lU9MK0wnKV1OJw5BM+vnzpmIPS2ojCGgP3qNYK3wrDsyPSQ9FW4/NNaSoZ3hPFe4Cc4cZTqMQOvRBUKXC0PQXf4iwp8jAzl4afQC84SHt1QDYLWXc7lNdoG4fJ1PFlHNDGetz5P5LkurVD7bnueGHobQ0GJdmypPnfW/hka1XgJA7VRAiVcy471WjA+K+wU74++iMLhgBxTUv0+MOFAMDQRsVxyNYryAwnWyqRY03ftNlPQdjvRCNMflYbcqJQAVgHPqZovM48okUvc2nhpN3WDnCfrdYeC2MOFnAEEvIc0luSjYxIu14/a84/hel8Cp28AECEC0FslfG9/ruNJDM8pqxDxCLw7nMAeoLsHKJNRRwZZSLXf7SJvSwJLX3dHR72glvk/xBbx2HrNHxgA1h4yA3F7h+AW3I4dwhAU5GKU9geSXu1JBPgXr8ToKUJ1nOZ2k0PqzNu3si5wIBld9RwZw7kFa7O++xpfeJsudD98sjP4dIA5eLBAb9BNe9bNmgRDom3BeuvHY7cIeWBrbc/jef4V1VHaDw+Gf3SBU9Y8uxTp+vpDrV27osZZGd9kH6GEiPLtXj4QojuwSCMD37wXNm91GXDYHO/QSJlHVaydlfvNOQzcxkpYwF4HPBW3GHHY2Dqrv8Lp+mQnppfpl9WLlSosUsvWNFLVzbWQdOqF0kHTH2pfTmmWpYtiVx+/gnrrnUPheQhhYyLTBAB/NHBAl8egoj31bt4L950/zlYdfGLChrJx46DmAyVbH0Q3qcUeuMxA2Lx8KcMIDvHkcJYfAWHL9fLGXR3+wOW8RyseMINcwWPzrw7kEe3ubKzHG6mjeGkqtdsnTnbyrf7SA8PYKA9+lATTKpSWf++HEd3y+jOTczewoD+CcKsFcnt+3pFxx4hj1IBP1jz+0XOHtzpaUPLHzD9/v9mO7odfAaL0ZJnJk8fhwmAdZ6j3TJiM70rK9U9iArydmbYChu3WS+WAqqIkBqGaku/CFpSbugP6d0nrof5bEpNiwOAQXMpDufWmauOx8HdMrHtOqI12irKaA4Qyj8GiaNqK9b+mxZ/ytK+afSkTgGZvG5kXdPsXfbLKE/A2p1Sb X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 61c9b662-0f68-48eb-4ba1-08dd2bbf1902 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jan 2025 06:23:11.9980 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: HTlhQVk6uiBNM0fxHB1Psgv8kZJ97mE0cAxDBY6Y1ZH+kdUnqZGpJd0JiWsBkV2J+fkNI7tj2gk8ZbpucEhNkg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB9331 X-Patchwork-Delegate: kuba@kernel.org Although only ENETC PF can access the MAC address filter table, the table entries can specify MAC address filtering for one or more SIs based on SI_BITMAP, which means that the table also supports MAC address filtering for VFs. Currently, only the ENETC v1 PF driver supports MAC address filtering. In order to add the MAC address filtering support for the ENETC v4 PF driver and VF driver in the future, the relevant generic interfaces are moved to the enetc-core driver. At the same time, the struct enetc_mac_filter is moved from enetc_pf to enetc_si, because enetc_si is a structure shared by PF and VFs. This lays the basis for i.MX95 ENETC PF and VFs to support MAC address filtering. Signed-off-by: Wei Fang --- drivers/net/ethernet/freescale/enetc/enetc.c | 36 ++++++++++++++ drivers/net/ethernet/freescale/enetc/enetc.h | 17 +++++++ .../net/ethernet/freescale/enetc/enetc_pf.c | 49 +++---------------- .../net/ethernet/freescale/enetc/enetc_pf.h | 14 ------ 4 files changed, 60 insertions(+), 56 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c index 6a6fc819dfde..6d21c133e418 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -36,6 +36,42 @@ static void enetc_change_preemptible_tcs(struct enetc_ndev_priv *priv, enetc_mm_commit_preemptible_tcs(priv); } +static int enetc_mac_addr_hash_idx(const u8 *addr) +{ + u64 fold = __swab64(ether_addr_to_u64(addr)) >> 16; + u64 mask = 0; + int res = 0; + int i; + + for (i = 0; i < 8; i++) + mask |= BIT_ULL(i * 6); + + for (i = 0; i < 6; i++) + res |= (hweight64(fold & (mask << i)) & 0x1) << i; + + return res; +} + +void enetc_add_mac_addr_ht_filter(struct enetc_mac_filter *filter, + const unsigned char *addr) +{ + int idx = enetc_mac_addr_hash_idx(addr); + + /* add hash table entry */ + __set_bit(idx, filter->mac_hash_table); + filter->mac_addr_cnt++; +} +EXPORT_SYMBOL_GPL(enetc_add_mac_addr_ht_filter); + +void enetc_reset_mac_addr_filter(struct enetc_mac_filter *filter) +{ + filter->mac_addr_cnt = 0; + + bitmap_zero(filter->mac_hash_table, + ENETC_MADDR_HASH_TBL_SZ); +} +EXPORT_SYMBOL_GPL(enetc_reset_mac_addr_filter); + static int enetc_num_stack_tx_queues(struct enetc_ndev_priv *priv) { int num_tx_rings = priv->num_tx_rings; diff --git a/drivers/net/ethernet/freescale/enetc/enetc.h b/drivers/net/ethernet/freescale/enetc/enetc.h index 4ff0957e69be..9380d3e8ca01 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.h +++ b/drivers/net/ethernet/freescale/enetc/enetc.h @@ -23,6 +23,18 @@ #define ENETC_CBD_DATA_MEM_ALIGN 64 +#define ENETC_MADDR_HASH_TBL_SZ 64 + +enum enetc_mac_addr_type {UC, MC, MADDR_TYPE}; + +struct enetc_mac_filter { + union { + char mac_addr[ETH_ALEN]; + DECLARE_BITMAP(mac_hash_table, ENETC_MADDR_HASH_TBL_SZ); + }; + int mac_addr_cnt; +}; + struct enetc_tx_swbd { union { struct sk_buff *skb; @@ -302,6 +314,8 @@ struct enetc_si { int hw_features; const struct enetc_drvdata *drvdata; const struct enetc_si_ops *ops; + + struct enetc_mac_filter mac_filter[MADDR_TYPE]; }; #define ENETC_SI_ALIGN 32 @@ -484,6 +498,9 @@ int enetc_alloc_si_resources(struct enetc_ndev_priv *priv); void enetc_free_si_resources(struct enetc_ndev_priv *priv); int enetc_configure_si(struct enetc_ndev_priv *priv); int enetc_get_driver_data(struct enetc_si *si); +void enetc_add_mac_addr_ht_filter(struct enetc_mac_filter *filter, + const unsigned char *addr); +void enetc_reset_mac_addr_filter(struct enetc_mac_filter *filter); int enetc_open(struct net_device *ndev); int enetc_close(struct net_device *ndev); diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf.c b/drivers/net/ethernet/freescale/enetc/enetc_pf.c index a214749a4af6..cc3e52bd3096 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_pf.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf.c @@ -72,30 +72,6 @@ static void enetc_set_isol_vlan(struct enetc_hw *hw, int si, u16 vlan, u8 qos) enetc_port_wr(hw, ENETC_PSIVLANR(si), val); } -static int enetc_mac_addr_hash_idx(const u8 *addr) -{ - u64 fold = __swab64(ether_addr_to_u64(addr)) >> 16; - u64 mask = 0; - int res = 0; - int i; - - for (i = 0; i < 8; i++) - mask |= BIT_ULL(i * 6); - - for (i = 0; i < 6; i++) - res |= (hweight64(fold & (mask << i)) & 0x1) << i; - - return res; -} - -static void enetc_reset_mac_addr_filter(struct enetc_mac_filter *filter) -{ - filter->mac_addr_cnt = 0; - - bitmap_zero(filter->mac_hash_table, - ENETC_MADDR_HASH_TBL_SZ); -} - static void enetc_add_mac_addr_em_filter(struct enetc_mac_filter *filter, const unsigned char *addr) { @@ -104,16 +80,6 @@ static void enetc_add_mac_addr_em_filter(struct enetc_mac_filter *filter, filter->mac_addr_cnt++; } -static void enetc_add_mac_addr_ht_filter(struct enetc_mac_filter *filter, - const unsigned char *addr) -{ - int idx = enetc_mac_addr_hash_idx(addr); - - /* add hash table entry */ - __set_bit(idx, filter->mac_hash_table); - filter->mac_addr_cnt++; -} - static void enetc_clear_mac_ht_flt(struct enetc_si *si, int si_idx, int type) { bool err = si->errata & ENETC_ERR_UCMCSWP; @@ -145,10 +111,9 @@ static void enetc_set_mac_ht_flt(struct enetc_si *si, int si_idx, int type, } } -static void enetc_sync_mac_filters(struct enetc_pf *pf) +static void enetc_sync_mac_filters(struct enetc_si *si) { - struct enetc_mac_filter *f = pf->mac_filter; - struct enetc_si *si = pf->si; + struct enetc_mac_filter *f = si->mac_filter; int i, pos; pos = EMETC_MAC_ADDR_FILT_RES; @@ -192,10 +157,10 @@ static void enetc_sync_mac_filters(struct enetc_pf *pf) static void enetc_pf_set_rx_mode(struct net_device *ndev) { struct enetc_ndev_priv *priv = netdev_priv(ndev); - struct enetc_pf *pf = enetc_si_priv(priv->si); - struct enetc_hw *hw = &priv->si->hw; bool uprom = false, mprom = false; struct enetc_mac_filter *filter; + struct enetc_si *si = priv->si; + struct enetc_hw *hw = &si->hw; struct netdev_hw_addr *ha; u32 psipmr = 0; bool em; @@ -214,7 +179,7 @@ static void enetc_pf_set_rx_mode(struct net_device *ndev) /* first 2 filter entries belong to PF */ if (!uprom) { /* Update unicast filters */ - filter = &pf->mac_filter[UC]; + filter = &si->mac_filter[UC]; enetc_reset_mac_addr_filter(filter); em = (netdev_uc_count(ndev) == 1); @@ -230,7 +195,7 @@ static void enetc_pf_set_rx_mode(struct net_device *ndev) if (!mprom) { /* Update multicast filters */ - filter = &pf->mac_filter[MC]; + filter = &si->mac_filter[MC]; enetc_reset_mac_addr_filter(filter); netdev_for_each_mc_addr(ha, ndev) { @@ -243,7 +208,7 @@ static void enetc_pf_set_rx_mode(struct net_device *ndev) if (!uprom || !mprom) /* update PF entries */ - enetc_sync_mac_filters(pf); + enetc_sync_mac_filters(si); psipmr |= enetc_port_rd(hw, ENETC_PSIPMR) & ~(ENETC_PSIPMR_SET_UP(0) | ENETC_PSIPMR_SET_MP(0)); diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf.h b/drivers/net/ethernet/freescale/enetc/enetc_pf.h index a26a12863855..2b9d0f625f01 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_pf.h +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf.h @@ -6,18 +6,6 @@ #define ENETC_PF_NUM_RINGS 8 -enum enetc_mac_addr_type {UC, MC, MADDR_TYPE}; -#define ENETC_MAX_NUM_MAC_FLT ((ENETC_MAX_NUM_VFS + 1) * MADDR_TYPE) - -#define ENETC_MADDR_HASH_TBL_SZ 64 -struct enetc_mac_filter { - union { - char mac_addr[ETH_ALEN]; - DECLARE_BITMAP(mac_hash_table, ENETC_MADDR_HASH_TBL_SZ); - }; - int mac_addr_cnt; -}; - #define ENETC_VLAN_HT_SIZE 64 enum enetc_vf_flags { @@ -52,8 +40,6 @@ struct enetc_pf { int total_vfs; /* max number of VFs, set for PF at probe */ struct enetc_vf_state *vf_state; - struct enetc_mac_filter mac_filter[ENETC_MAX_NUM_MAC_FLT]; - struct enetc_msg_swbd rxmsg[ENETC_MAX_NUM_VFS]; struct work_struct msg_task; char msg_int_name[ENETC_INT_NAME_MAX]; From patchwork Fri Jan 3 06:06:00 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Fang X-Patchwork-Id: 13925202 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2075.outbound.protection.outlook.com [40.107.105.75]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 582851BD9E9; Fri, 3 Jan 2025 06:23:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.105.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735885406; cv=fail; b=ZBYU0G9R8qMve3x8nnlqthM280u2Fc/2OgExufx+d7V2HTuRnytz8A+yWxVXCK2C9zr2hX/Xjx11ERGSUdpcBVMFEOSkz+OgyiO6+LDqTaYR4DJzSuHApY/72y01x1qM/AlOrXNd0o01+h9rRNpt1ScBU1BLbT9yv88lr98ZV6w= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735885406; c=relaxed/simple; bh=to9YBlwm9o/igKrlKjnJ2ws9XNnMSsYtKygHGI1VDgc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=JJ0XTVfMnumm5uH/CS9/YnV4HHOX80UlcspDgOURhzvKqx2J5y2k9OvQE0bTa5DEMiPaz9pS9oOzdXEFGIoBEjrz4uDbhf42maGZJ9FEm9wM69nSEVjIk6VaxBKI9GztllzEHPKM0LrylCpq4cnFNYJ6jtjATuq86Y4XmvbX3Og= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=QRPBYAMM; arc=fail smtp.client-ip=40.107.105.75 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="QRPBYAMM" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=rRlD2OGbEu1Ud5kyTekjw/wAFS4EmohBmfY5OtNyoe4jMwpMqU2pH/ubOjGFoPosDrjowdtJCc/hf1H2emTWDsIWl52VdoNBQnWz6D5rYWcQaO5MrUr95N91kzC33pOi3DJnyMLmc5bxVtqa0Q3zKirLPKou7nYEOf+P3lYBztZtoM7cujxgFhZ129JuZkqGufvX4zgPYiJ+VZnpO2YEWVQwhH6S2f1JYVEqAVevL9pyv9HQAMNXwZsxxML/2FCfvo1WCDHcJn/Tj4IeLcrZZqVoiAKj5rL+zv1caEDqsTaeWfd584EwwwqgG/El+lbk10lwXh8mB1Vh3jTWxDc2nA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Frje4D6TNqQF+pyuj9y2OYoAXlHlQgjqBjLKkPyV0UE=; b=iYOmMNn0YNfr+PGxNGahKFsA8pkyjni5zrTLgTbmFRMaur0figj9LIaFEZTioLthOJUfR+s3J7ED99hNTp+pAW2OgDNBCC0Y86rwa8SaT5rC/+ZLyZFB4c+FFwZPI6KC1rN/m3qIHLJQLiG4zn/NKPnof9jWMFFcY9K2HSipeg8A5nq9ZOsNaNDuthtCki8cIkQmaILGEs+qdz+uAxmt8yyz+T0mtxCw1JcW3yHv+SG3RdpkfjGq7oMBJ0VLtqQ4qNxsk6hS2JtT4yDyqqfAvf/tepBuxCfT/da1dkcwWjyhnAoQxV6RuUFzhVyIk5EEzbD3Tu+WRGX8r6bXKfT8Xg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Frje4D6TNqQF+pyuj9y2OYoAXlHlQgjqBjLKkPyV0UE=; b=QRPBYAMM9d1aI/WAmLrWQORu723chsLUYlEegoojc8Ldj6cZhw4itczjo/o6PrIyYJ8swNXqLTJJryFD1mJhC+m5gA34g24gfjZLcOaUrVPEmYVPs/x6zurL1ts+r7l1hZBd1KGEO5kspXFDLUgs+Ik5Vc8XjC93fQEU72lMMTF84/h/NhJLACS7xOyKFKSSaB8UksDVe5dfJIXuxtOlYLbxCmLReylsdNNExwDbiy3oMWUOFbiHykXke5JI7BZ66ukAu0A0peE84+m9zh9/trAmIjg3LS3Em1XbVJ3kF9ot9W03PI/llIjLxFZyEZoy54KklQ3DRKlKOjr4BSUK/w== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) by DB9PR04MB9331.eurprd04.prod.outlook.com (2603:10a6:10:36d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.12; Fri, 3 Jan 2025 06:23:17 +0000 Received: from PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db]) by PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db%6]) with mapi id 15.20.8314.013; Fri, 3 Jan 2025 06:23:16 +0000 From: Wei Fang To: claudiu.manoil@nxp.com, vladimir.oltean@nxp.com, xiaoning.wang@nxp.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, christophe.leroy@csgroup.eu Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, imx@lists.linux.dev Subject: [PATCH net-next 04/13] net: enetc: add MAC filter for i.MX95 ENETC PF Date: Fri, 3 Jan 2025 14:06:00 +0800 Message-Id: <20250103060610.2233908-5-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250103060610.2233908-1-wei.fang@nxp.com> References: <20250103060610.2233908-1-wei.fang@nxp.com> X-ClientProxiedBy: SG2PR03CA0127.apcprd03.prod.outlook.com (2603:1096:4:91::31) To PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8510:EE_|DB9PR04MB9331:EE_ X-MS-Office365-Filtering-Correlation-Id: 59e287a3-9d51-4a0b-f214-08dd2bbf1c11 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|1800799024|7416014|366016|38350700014; X-Microsoft-Antispam-Message-Info: nVF5ybJovqumJB8Jn4amt0SPcunZ35DCMXFgSzmegxMZNlWYALUkWrTXvYNaQIGnRTTaQOkNlUt6dLnVuMSfaGWXB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1e52cGOa4y2N+QpePu6lMWe51OfGkXMYu+ubkPD7/5KEGLWVkgfRfQT0sDh75By2SjbFy7J8AaPmxwuFUnIIes+SU4k8v1DBSM/SVuXEFbZDp7OzpjANi6dCmz4qh5aaxQ4lqR5/+rrKTmRqjoCum/UYN0AR4XqHIA8VlIdZJo4LGwgwTqwC4jMzHJkmkx3Jn+dPGqr/XKqhEYTY40dW98ufyczHvisXp8C5Joy3Pb7TrafiE1G/C2kvKhsnV/pFkXfvIn4m4BQZZ0l5NnPZbcg1JCCzbpJBeJ X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8510.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(376014)(1800799024)(7416014)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: B7W3wsnLbzNLtlOC3bR/frLgeaHqOaugYPF4NWFxBgGSCtVd3CDqkqTU+vualHqIqsWer60SrrbMwOVE8X7yyTDJr04G1bOGf9pyDU3ibbJcckCAldpCO53RSFChiqCSCsPBrHzBdZkDxmaqbUWfImW2gDXc9DT5zfbK1bPaewRw2k9VtZuEMwygKv0FlXyueYqzCcYxyzCOz2awi31qGqqtIUZHQKXIZoCK/uMf16zfnPD2PW5TR6Wq2sjushZT2yQ1fQgBGZO2r39ToOATFMu0Aot/F+ACFAzr/AJKHO6fZVHaGJiXJaMzNMY9Y29CkV3MoDErHWeHM6sM2041R7xBkq9uV7KSfCf7knl14CQ4Z1Or2qxWTgxswTr7P0MW+3hn1PTB4Fu74dgOb/yq3iFilf/bA2rOx8jzGjtpcy8TsVxUOUAbXeiAy/Ud8ALcAXJz2KlmFEInignn1IZlNxoKu/fb8LLJIjwN56myozMh8ODpMg+TDisbnxcFcDo4TNBkr1YDVgLOcQMLssdBKK7RcyjDuRthElB1Y0ZiMXHm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rossTenant-Network-Message-Id: 59e287a3-9d51-4a0b-f214-08dd2bbf1c11 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jan 2025 06:23:16.9177 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: p3eAsITxdAZxRBx+6Q1v3LWgzwMLMK2WLb4JJxPRnvxByCLO2K6APKmgQsCIfT71APaXmhBd+SuyLE/Gl5vrmw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB9331 X-Patchwork-Delegate: kuba@kernel.org The i.MX95 ENETC supports both MAC hash filter and MAC exact filter. MAC hash filter is implenented through a 64-bits hash table to match against the hashed addresses, PF and VFs each have two MAC hash tables, one is for unicast and the other one is for multicast. But MAC exact filter is shared between SIs (PF and VFs), each table entry contains a MAC address that may be unicast or multicast and the entry also contains an SI bitmap field that indicates for which SIs the entry is valid. For i.MX95 ENETC, MAC exact filter only has 4 entries. According to the observation of the system default network configuration, the MAC filter will be configured with multiple multicast addresses, so MAC exact filter does not have enough entries to implement multicast filtering. Therefore, the current MAC exact filter is only used for unicast filtering. If the number of unicast addresses exceeds 4, then MAC hash filter is used. Note that both MAC hash filter and MAC exact filter can only be accessed by PF, VFs can notify PF to set its corresponding MAC filter through the mailbox mechanism of ENETC. But currently MAC filter is only added for i.MX95 ENETC PF. The MAC filter support of ENETC VFs will be supported in subsequent patches. Signed-off-by: Wei Fang --- drivers/net/ethernet/freescale/enetc/enetc.h | 2 + .../net/ethernet/freescale/enetc/enetc4_hw.h | 8 + .../net/ethernet/freescale/enetc/enetc4_pf.c | 411 +++++++++++++++++- .../net/ethernet/freescale/enetc/enetc_hw.h | 6 + .../net/ethernet/freescale/enetc/enetc_pf.h | 11 + 5 files changed, 437 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.h b/drivers/net/ethernet/freescale/enetc/enetc.h index 9380d3e8ca01..4dba91408e3d 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.h +++ b/drivers/net/ethernet/freescale/enetc/enetc.h @@ -316,6 +316,8 @@ struct enetc_si { const struct enetc_si_ops *ops; struct enetc_mac_filter mac_filter[MADDR_TYPE]; + struct workqueue_struct *workqueue; + struct work_struct rx_mode_task; }; #define ENETC_SI_ALIGN 32 diff --git a/drivers/net/ethernet/freescale/enetc/enetc4_hw.h b/drivers/net/ethernet/freescale/enetc/enetc4_hw.h index 695cb07c74bc..826359004850 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc4_hw.h +++ b/drivers/net/ethernet/freescale/enetc/enetc4_hw.h @@ -99,6 +99,14 @@ #define ENETC4_PSICFGR2(a) ((a) * 0x80 + 0x2018) #define PSICFGR2_NUM_MSIX GENMASK(5, 0) +/* Port station interface a unicast MAC hash filter register 0/1 */ +#define ENETC4_PSIUMHFR0(a) ((a) * 0x80 + 0x2050) +#define ENETC4_PSIUMHFR1(a) ((a) * 0x80 + 0x2054) + +/* Port station interface a multicast MAC hash filter register 0/1 */ +#define ENETC4_PSIMMHFR0(a) ((a) * 0x80 + 0x2058) +#define ENETC4_PSIMMHFR1(a) ((a) * 0x80 + 0x205c) + #define ENETC4_PMCAPR 0x4004 #define PMCAPR_HD BIT(8) #define PMCAPR_FP GENMASK(10, 9) diff --git a/drivers/net/ethernet/freescale/enetc/enetc4_pf.c b/drivers/net/ethernet/freescale/enetc/enetc4_pf.c index b957e92e3a00..6ec849949267 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc4_pf.c +++ b/drivers/net/ethernet/freescale/enetc/enetc4_pf.c @@ -11,6 +11,15 @@ #define ENETC_SI_MAX_RING_NUM 8 +#define ENETC_MAC_FILTER_TYPE_UC BIT(0) +#define ENETC_MAC_FILTER_TYPE_MC BIT(1) +#define ENETC_MAC_FILTER_TYPE_ALL (ENETC_MAC_FILTER_TYPE_UC | \ + ENETC_MAC_FILTER_TYPE_MC) + +struct enetc_mac_addr { + u8 addr[ETH_ALEN]; +}; + static void enetc4_get_port_caps(struct enetc_pf *pf) { struct enetc_hw *hw = &pf->si->hw; @@ -26,6 +35,9 @@ static void enetc4_get_port_caps(struct enetc_pf *pf) val = enetc_port_rd(hw, ENETC4_PMCAPR); pf->caps.half_duplex = (val & PMCAPR_HD) ? 1 : 0; + + val = enetc_port_rd(hw, ENETC4_PSIMAFCAPR); + pf->caps.mac_filter_num = val & PSIMAFCAPR_NUM_MAC_AFTE; } static void enetc4_pf_set_si_primary_mac(struct enetc_hw *hw, int si, @@ -71,9 +83,33 @@ static int enetc4_pf_struct_init(struct enetc_si *si) enetc4_get_port_caps(pf); + INIT_HLIST_HEAD(&pf->mac_list); + mutex_init(&pf->mac_list_lock); + return 0; } +static void enetc4_pf_destroy_mac_list(struct enetc_pf *pf) +{ + struct enetc_mac_list_entry *entry; + struct hlist_node *tmp; + + scoped_guard(mutex, &pf->mac_list_lock) { + hlist_for_each_entry_safe(entry, tmp, &pf->mac_list, node) { + hlist_del(&entry->node); + kfree(entry); + } + + pf->num_mfe = 0; + } +} + +static void enetc4_pf_struct_free(struct enetc_pf *pf) +{ + enetc4_pf_destroy_mac_list(pf); + mutex_destroy(&pf->mac_list_lock); +} + static u32 enetc4_psicfgr0_val_construct(bool is_vf, u32 num_tx_bdr, u32 num_rx_bdr) { u32 val; @@ -305,12 +341,362 @@ static void enetc4_pf_free(struct enetc_pf *pf) enetc4_free_ntmp_priv(pf->si); } +static void enetc4_pf_set_si_mac_promisc(struct enetc_hw *hw, int si, + int type, bool en) +{ + u32 val = enetc_port_rd(hw, ENETC4_PSIPMMR); + + if (type == UC) { + if (en) + val |= PSIPMMR_SI_MAC_UP(si); + else + val &= ~PSIPMMR_SI_MAC_UP(si); + } else { /* Multicast promiscuous mode. */ + if (en) + val |= PSIPMMR_SI_MAC_MP(si); + else + val &= ~PSIPMMR_SI_MAC_MP(si); + } + + enetc_port_wr(hw, ENETC4_PSIPMMR, val); +} + +static void enetc4_pf_set_si_mac_hash_filter(struct enetc_hw *hw, int si, + int type, u64 hash) +{ + if (type == UC) { + enetc_port_wr(hw, ENETC4_PSIUMHFR0(si), lower_32_bits(hash)); + enetc_port_wr(hw, ENETC4_PSIUMHFR1(si), upper_32_bits(hash)); + } else { /* MC */ + enetc_port_wr(hw, ENETC4_PSIMMHFR0(si), lower_32_bits(hash)); + enetc_port_wr(hw, ENETC4_PSIMMHFR1(si), upper_32_bits(hash)); + } +} + +static bool enetc_mac_filter_type_check(int type, const u8 *addr) +{ + if (type == ENETC_MAC_FILTER_TYPE_UC) + return !is_multicast_ether_addr(addr); + else if (type == ENETC_MAC_FILTER_TYPE_MC) + return is_multicast_ether_addr(addr); + else + return true; +} + +static struct enetc_mac_list_entry * +enetc_mac_list_lookup_entry(struct enetc_pf *pf, const unsigned char *addr) +{ + struct enetc_mac_list_entry *entry; + + hlist_for_each_entry(entry, &pf->mac_list, node) + if (ether_addr_equal(entry->mac, addr)) + return entry; + + return NULL; +} + +static void enetc_mac_list_add_entry(struct enetc_pf *pf, + struct enetc_mac_list_entry *entry) +{ + hlist_add_head(&entry->node, &pf->mac_list); +} + +static void enetc_mac_list_del_entry(struct enetc_mac_list_entry *entry) +{ + hlist_del(&entry->node); + kfree(entry); +} + +static void enetc_mac_list_del_matched_entries(struct enetc_pf *pf, u16 si_bit, + struct enetc_mac_addr *mac, + int mac_cnt) +{ + struct enetc_mac_list_entry *entry; + int i; + + for (i = 0; i < mac_cnt; i++) { + entry = enetc_mac_list_lookup_entry(pf, mac[i].addr); + if (entry) { + entry->si_bitmap &= ~si_bit; + if (!entry->si_bitmap) { + enetc_mac_list_del_entry(entry); + pf->num_mfe--; + } + } + } +} + +static bool enetc_mac_list_is_available(struct enetc_pf *pf, + struct enetc_mac_addr *mac, + int mac_cnt) +{ + int max_num_mfe = pf->caps.mac_filter_num; + struct enetc_mac_list_entry *entry; + int cur_num_mfe = pf->num_mfe; + int i, new_mac_cnt = 0; + + if (mac_cnt > max_num_mfe) + return false; + + /* Check MAC filter table whether has enough available entries */ + hlist_for_each_entry(entry, &pf->mac_list, node) { + for (i = 0; i < mac_cnt; i++) { + if (ether_addr_equal(entry->mac, mac[i].addr)) + break; + } + + if (i == mac_cnt) + new_mac_cnt++; + + if ((cur_num_mfe + new_mac_cnt) > max_num_mfe) + return false; + } + + return true; +} + +static int enetc4_pf_set_mac_address_filter(struct enetc_pf *pf, int si_id, + struct enetc_mac_addr *mac, + int mac_cnt) +{ + struct enetc_mac_list_entry *entry; + struct maft_entry_data data = {0}; + struct enetc_si *si = pf->si; + u16 si_bit = BIT(si_id); + int i, num_mfe, err = 0; + + mutex_lock(&pf->mac_list_lock); + + if (!enetc_mac_list_is_available(pf, mac, mac_cnt)) { + err = -ENOSPC; + goto mac_list_unlock; + } + + num_mfe = pf->num_mfe; + /* Update mac_list */ + for (i = 0; i < mac_cnt; i++) { + entry = enetc_mac_list_lookup_entry(pf, mac[i].addr); + if (!entry) { + entry = kzalloc(sizeof(*entry), GFP_KERNEL); + if (unlikely(!entry)) { + /* Restore MAC list to the state before the update + * if an error occurs. + */ + enetc_mac_list_del_matched_entries(pf, si_bit, + mac, i + 1); + err = -ENOMEM; + goto mac_list_unlock; + } + + ether_addr_copy(entry->mac, mac[i].addr); + entry->si_bitmap = si_bit; + enetc_mac_list_add_entry(pf, entry); + pf->num_mfe++; + } else { + entry->si_bitmap |= si_bit; + } + } + + /* Clear MAC filter table */ + for (i = 0; i < num_mfe; i++) + ntmp_maft_delete_entry(&si->ntmp.cbdrs, i); + + i = 0; + hlist_for_each_entry(entry, &pf->mac_list, node) { + data.cfge.si_bitmap = cpu_to_le16(entry->si_bitmap); + ether_addr_copy(data.keye.mac_addr, entry->mac); + ntmp_maft_add_entry(&si->ntmp.cbdrs, i++, &data); + } + +mac_list_unlock: + mutex_unlock(&pf->mac_list_lock); + + return err; +} + +static void enetc4_pf_flush_mac_exact_filter(struct enetc_pf *pf, int si_id, + int mac_type) +{ + struct enetc_mac_list_entry *entry; + struct maft_entry_data data = {0}; + struct enetc_si *si = pf->si; + u16 si_bit = BIT(si_id); + struct hlist_node *tmp; + int i, num_mfe; + + mutex_lock(&pf->mac_list_lock); + + num_mfe = pf->num_mfe; + hlist_for_each_entry_safe(entry, tmp, &pf->mac_list, node) { + if (enetc_mac_filter_type_check(mac_type, entry->mac) && + entry->si_bitmap & si_bit) { + entry->si_bitmap ^= si_bit; + if (!entry->si_bitmap) { + enetc_mac_list_del_entry(entry); + pf->num_mfe--; + } + } + } + + for (i = 0; i < num_mfe; i++) + ntmp_maft_delete_entry(&si->ntmp.cbdrs, i); + + i = 0; + hlist_for_each_entry(entry, &pf->mac_list, node) { + data.cfge.si_bitmap = cpu_to_le16(entry->si_bitmap); + ether_addr_copy(data.keye.mac_addr, entry->mac); + ntmp_maft_add_entry(&si->ntmp.cbdrs, i++, &data); + } + + mutex_unlock(&pf->mac_list_lock); +} + +static int enetc4_pf_set_mac_exact_filter(struct enetc_pf *pf, int type) +{ + struct enetc_mac_addr *mac_tbl __free(kfree); + int max_num_mfe = pf->caps.mac_filter_num; + struct net_device *ndev = pf->si->ndev; + struct netdev_hw_addr *ha; + u8 si_mac[ETH_ALEN]; + int mac_cnt = 0; + + mac_tbl = kcalloc(max_num_mfe, sizeof(*mac_tbl), GFP_KERNEL); + if (!mac_tbl) + return -ENOMEM; + + enetc_get_primary_mac_addr(&pf->si->hw, si_mac); + + netif_addr_lock_bh(ndev); + if (type & ENETC_MAC_FILTER_TYPE_UC) { + netdev_for_each_uc_addr(ha, ndev) { + if (!is_valid_ether_addr(ha->addr) || + ether_addr_equal(ha->addr, si_mac)) + continue; + + if (mac_cnt >= max_num_mfe) + goto err_nospace_out; + + ether_addr_copy(mac_tbl[mac_cnt++].addr, ha->addr); + } + } + + if (type & ENETC_MAC_FILTER_TYPE_MC) { + netdev_for_each_mc_addr(ha, ndev) { + if (!is_multicast_ether_addr(ha->addr)) + continue; + + if (mac_cnt >= max_num_mfe) + goto err_nospace_out; + + ether_addr_copy(mac_tbl[mac_cnt++].addr, ha->addr); + } + } + netif_addr_unlock_bh(ndev); + + return enetc4_pf_set_mac_address_filter(pf, 0, mac_tbl, mac_cnt); + +err_nospace_out: + netif_addr_unlock_bh(ndev); + + return -ENOSPC; +} + +static void enetc4_pf_set_mac_hash_filter(struct enetc_pf *pf, int type) +{ + struct net_device *ndev = pf->si->ndev; + struct enetc_mac_filter *mac_filter; + struct enetc_hw *hw = &pf->si->hw; + struct enetc_si *si = pf->si; + struct netdev_hw_addr *ha; + + netif_addr_lock_bh(ndev); + if (type & ENETC_MAC_FILTER_TYPE_UC) { + mac_filter = &si->mac_filter[UC]; + enetc_reset_mac_addr_filter(mac_filter); + netdev_for_each_uc_addr(ha, ndev) + enetc_add_mac_addr_ht_filter(mac_filter, ha->addr); + + enetc4_pf_set_si_mac_hash_filter(hw, 0, UC, + *mac_filter->mac_hash_table); + } + + if (type & ENETC_MAC_FILTER_TYPE_MC) { + mac_filter = &si->mac_filter[MC]; + enetc_reset_mac_addr_filter(mac_filter); + netdev_for_each_mc_addr(ha, ndev) + enetc_add_mac_addr_ht_filter(mac_filter, ha->addr); + + enetc4_pf_set_si_mac_hash_filter(hw, 0, MC, + *mac_filter->mac_hash_table); + } + netif_addr_unlock_bh(ndev); +} + +static void enetc4_pf_set_mac_filter(struct enetc_pf *pf, int type) +{ + /* Currently, the MAC address filter table only has 4 entries, and the + * table is shared by PF and VFs. In the default network configuration, + * the MAC filter will be configured with multiple multicast addresses, + * so it is only suitable for unicast filtering. If the number of unicast + * addresses exceeds the table capacity, the MAC hash filter will be used. + */ + if (type & ENETC_MAC_FILTER_TYPE_UC) { + if (enetc4_pf_set_mac_exact_filter(pf, ENETC_MAC_FILTER_TYPE_UC)) + /* Fall back to the MAC hash filter */ + enetc4_pf_set_mac_hash_filter(pf, ENETC_MAC_FILTER_TYPE_UC); + } + + if (type & ENETC_MAC_FILTER_TYPE_MC) + enetc4_pf_set_mac_hash_filter(pf, ENETC_MAC_FILTER_TYPE_MC); +} + +static void enetc4_pf_do_set_rx_mode(struct work_struct *work) +{ + struct enetc_si *si = container_of(work, struct enetc_si, rx_mode_task); + struct enetc_pf *pf = enetc_si_priv(si); + struct net_device *ndev = si->ndev; + struct enetc_hw *hw = &si->hw; + bool uc_promisc = false; + bool mc_promisc = false; + int type = 0; + + if (ndev->flags & IFF_PROMISC) { + uc_promisc = true; + mc_promisc = true; + } else if (ndev->flags & IFF_ALLMULTI) { + mc_promisc = true; + type = ENETC_MAC_FILTER_TYPE_UC; + } else { + type = ENETC_MAC_FILTER_TYPE_ALL; + } + + enetc4_pf_set_si_mac_promisc(hw, 0, UC, uc_promisc); + enetc4_pf_set_si_mac_promisc(hw, 0, MC, mc_promisc); + + /* Clear Old MAC filter */ + enetc4_pf_flush_mac_exact_filter(pf, 0, ENETC_MAC_FILTER_TYPE_ALL); + enetc4_pf_set_si_mac_hash_filter(hw, 0, UC, 0); + enetc4_pf_set_si_mac_hash_filter(hw, 0, MC, 0); + + /* Set new MAC filter */ + enetc4_pf_set_mac_filter(pf, type); +} + +static void enetc4_pf_set_rx_mode(struct net_device *ndev) +{ + struct enetc_ndev_priv *priv = netdev_priv(ndev); + struct enetc_si *si = priv->si; + + queue_work(si->workqueue, &si->rx_mode_task); +} + static const struct net_device_ops enetc4_ndev_ops = { .ndo_open = enetc_open, .ndo_stop = enetc_close, .ndo_start_xmit = enetc_xmit, .ndo_get_stats = enetc_get_stats, .ndo_set_mac_address = enetc_pf_set_mac_addr, + .ndo_set_rx_mode = enetc4_pf_set_rx_mode, }; static struct phylink_pcs * @@ -721,6 +1107,19 @@ static const struct enetc_si_ops enetc4_psi_ops = { .teardown_cbdr = enetc4_teardown_cbdr, }; +static int enetc4_pf_wq_task_init(struct enetc_si *si) +{ + char wq_name[24]; + + INIT_WORK(&si->rx_mode_task, enetc4_pf_do_set_rx_mode); + snprintf(wq_name, sizeof(wq_name), "enetc-%s", pci_name(si->pdev)); + si->workqueue = create_singlethread_workqueue(wq_name); + if (!si->workqueue) + return -ENOMEM; + + return 0; +} + static int enetc4_pf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { @@ -755,10 +1154,14 @@ static int enetc4_pf_probe(struct pci_dev *pdev, if (err) return err; + err = enetc4_pf_wq_task_init(si); + if (err) + goto err_wq_task_init; + pf = enetc_si_priv(si); err = enetc4_pf_init(pf); if (err) - return err; + goto err_pf_init; enetc_get_si_caps(si); @@ -770,6 +1173,10 @@ static int enetc4_pf_probe(struct pci_dev *pdev, err_netdev_create: enetc4_pf_free(pf); +err_pf_init: + destroy_workqueue(si->workqueue); +err_wq_task_init: + enetc4_pf_struct_free(pf); return err; } @@ -781,6 +1188,8 @@ static void enetc4_pf_remove(struct pci_dev *pdev) enetc4_pf_netdev_destroy(si); enetc4_pf_free(pf); + destroy_workqueue(si->workqueue); + enetc4_pf_struct_free(pf); } static const struct pci_device_id enetc4_pf_id_table[] = { diff --git a/drivers/net/ethernet/freescale/enetc/enetc_hw.h b/drivers/net/ethernet/freescale/enetc/enetc_hw.h index 4098f01479bc..2e676212d230 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_hw.h +++ b/drivers/net/ethernet/freescale/enetc/enetc_hw.h @@ -712,6 +712,12 @@ static inline void enetc_load_primary_mac_addr(struct enetc_hw *hw, eth_hw_addr_set(ndev, addr); } +static inline void enetc_get_primary_mac_addr(struct enetc_hw *hw, u8 *addr) +{ + *(u32 *)addr = __raw_readl(hw->reg + ENETC_SIPMAR0); + *(u16 *)(addr + 4) = __raw_readw(hw->reg + ENETC_SIPMAR1); +} + #define ENETC_SI_INT_IDX 0 /* base index for Rx/Tx interrupts */ #define ENETC_BDR_INT_BASE_IDX 1 diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf.h b/drivers/net/ethernet/freescale/enetc/enetc_pf.h index 2b9d0f625f01..3b0cb0d8bf48 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_pf.h +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf.h @@ -22,6 +22,13 @@ struct enetc_port_caps { int num_msix; int num_rx_bdr; int num_tx_bdr; + int mac_filter_num; +}; + +struct enetc_mac_list_entry { + u8 mac[ETH_ALEN]; + u16 si_bitmap; + struct hlist_node node; }; struct enetc_pf; @@ -57,6 +64,10 @@ struct enetc_pf { struct enetc_port_caps caps; const struct enetc_pf_ops *ops; + + struct hlist_head mac_list; /* MAC address filter table */ + struct mutex mac_list_lock; /* mac_list lock */ + int num_mfe; /* number of mac address filter table entries */ }; #define phylink_to_enetc_pf(config) \ From patchwork Fri Jan 3 06:06:01 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Fang X-Patchwork-Id: 13925203 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2075.outbound.protection.outlook.com [40.107.105.75]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8BB721BDA91; Fri, 3 Jan 2025 06:23:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.105.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735885408; cv=fail; b=aRBlbXpYeNImLdn3HeurRA5OpU+TqgFGcqGOdYOET88/jl4fNTNy53L0KuxWnsinY1nWr717kU/OGEuj4uG4fCJ/nh4eY3fjzkVkzU2FTqMrx+W3yTP75Tf3d40aAcXbOi9FIj4lhURzUP6vfzRbJAPBQn3urEUzYs52BzxHi1k= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735885408; c=relaxed/simple; bh=3WM6gf6d144fcrw0cpmTs6ssWr3uZc9Abr85XKgHaNM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=rsBinQJP21dCtdakjDfVOMjKZ2c/i+2Ob1GWbLzYSoJtus2OB3uxY3ikA6t2o4djrftEPd0hj/vgNANkeLQp6ipIFDA+zYGJ+n9yxGmDnatngnX2OxjVGfsj0neyZfjH8R6auWS2M/jHOW5tECEMcwMsm0XXlR2yB6aZ0L/rMVA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=Gj2yhs8V; arc=fail smtp.client-ip=40.107.105.75 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="Gj2yhs8V" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=x84wA4aH09TQRsBpyd0EuIPMKT9hujEWd3p5CAErPjV2/CRIJFFtw0rF0x2+/XkR4vk9Z2+AfHtIXtqn3Je/cr/MIm05Os5fXtGBA8+QW9nq2BQZ20eq5iSBJqXTObWCkiYappVKEY8LPH8XkUcSYhx5ThTc0FWz3oHo1Os6eawQdSgDf+Raqqky+XDVKfCKqVd/KTQ6uAsfNtA77CSQAMHL+YUS7JopEimn4vAkHfa7+rn/KKeL4k28IPKr4nxsAu994ck9hGUB8Q3zczy7SFZ4hQlUM/1p0e9GqwEDFlowdEJdRIvJaY7gHlXuPc78OuOc1QIbxCvJ15+6pIwPcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=uq57KfeaiJQsMzv4tbxyCcNUdmsqzxYB4eTARgBL3PA=; b=DWZWTYtdzXt+9OxV+YcAZYwE78qJgTY5RAuuxeqFbbq08hZwZEq0nbCZjYgwGNSS4SeqWVFCNPZ36MqzrbIF0CvOVcShvcC8F3WycVCag2dFUdW21UeB2pIyGnfyiGyIkOY+WHsHy8RJkmV7u6rJRt7OQO62ha0XxS3QVzAMMOQLRy8eFmUWgigAJlhDpst+u8QBFWI8G0GGf97EUmxkniciewAMpscOGmMGp5mJ0vD9umNCYGM8Pr7kI2i8bj4CZfhd+A13i9gJaE3CnCQgIYE7z1cTxkr5R32+8/e+4pWBHUN/VXF/wnb3UsYbLzwBrz/ys+PBrHB+wmCwOPV5Xw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uq57KfeaiJQsMzv4tbxyCcNUdmsqzxYB4eTARgBL3PA=; b=Gj2yhs8VkAkujr+YMrsn38Sn/u6jH2yXy4sIdlLUTVwdKS9ppijUuHgICX2z/aktjj7Z7/VOor2/S5cm/bddpWY2Xl2hntJ6UKG8wcCTrJeGVx8RXpO5lc07QXun02KH5DyXfUA+NvN7g8AmwbT2gr0BXQ2Ize/iQ5YxT0P0oX37UCHKBNdo1nJziS6A2d8f1orJhpcczGPI746Uc18OzF69tfr/64rWcYYM48OVeLAVmsAXG46aJIjUBq1OJf3Cni493Xbe8Y6WCYb81aSOWiGjHCyXs4AmnYcisbcU6F92TwrN/tk2aVBfHzEOF6wzzzQWO/HsWU/v9RHgJgxmIg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) by DB9PR04MB9331.eurprd04.prod.outlook.com (2603:10a6:10:36d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.12; Fri, 3 Jan 2025 06:23:21 +0000 Received: from PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db]) by PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db%6]) with mapi id 15.20.8314.013; Fri, 3 Jan 2025 06:23:21 +0000 From: Wei Fang To: claudiu.manoil@nxp.com, vladimir.oltean@nxp.com, xiaoning.wang@nxp.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, christophe.leroy@csgroup.eu Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, imx@lists.linux.dev Subject: [PATCH net-next 05/13] net: enetc: add debugfs interface to dump MAC filter Date: Fri, 3 Jan 2025 14:06:01 +0800 Message-Id: <20250103060610.2233908-6-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250103060610.2233908-1-wei.fang@nxp.com> References: <20250103060610.2233908-1-wei.fang@nxp.com> X-ClientProxiedBy: SG2PR03CA0127.apcprd03.prod.outlook.com (2603:1096:4:91::31) To PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8510:EE_|DB9PR04MB9331:EE_ X-MS-Office365-Filtering-Correlation-Id: 803ec32f-5487-4338-bf6a-08dd2bbf1ebf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|1800799024|7416014|366016|38350700014; X-Microsoft-Antispam-Message-Info: AEXGOpsd7c4fsZu8zRn1E89A7iRBQ7BwEV6dkmp1BXPJbKXCz87TgBwmdSl6x9azDvgpodwTBY3hb7dJRH0jZzt0ucz8sptoa4lbg5b8g9AK7k0y8pRC3Mg8BoOWq7rLcRG3QSfpZD0t2c2UWxF7xw41zky6ey1wg0ej06c/19A5+bHLp8q+ONK42WZ8OKXsJ2/tBn9ijTIIt+gQdGdRHMn39VcwH9u0gBr15IJ3PVFC2kXNuQ9emtHc15FpALUjsBNb+zXs/AHQUZz47fS8jputQm8gvUMib5uxqUIARlmEkif/sAzig0e7hWTH67sUR5iND0ogWii2S5khtcT9liccsHYr2eoZvmLFiDEUiUxTgPZ+lOKiSOdAsudzDdthSs5sHwAtHv4dCu0yE9Xh3hldG+ZXsDWAlynyYVSf7KMTKhjR7+fZkX/9QBb+yD8aUXE2A0UZma+zqItIci3dh5Kyne0rNxi/PO4OUA2QfiSE1YFMIP3827E6ugqnHtiFId+BAoTijxFFRtEKhRxyIjWhWTGD170gShfWA904BqVEaiq79F6S7QyjT70YA3CmOK5TDsf3inhH8o4aJcru7MSWRuKCnW+0nqGOjgytlqyQbWbaeEeUyWP23YdGefrJ7iTXrol+3Q7cUqIZGCAUvP8kFoL9bJ8USZ/mVLwPJFwqUdO+7v8w09SCtSIfqmWaRy1ctPylGpMjMzASxnrIQT7vARI7v9EDrnhX80xZrad+MUXe2lZklrdfqHuI+ulv3Eqz33EuhaH3CtBepOqf3IrDo2+MD5NiSIsdm0iI2najBuj1pHMsBfThQgsEgX48mh9Id6OT3dkJINtQMxpDk5Vt9xsxZm4zUteO3Xh1fTBPz4RfPeYwMf79xPTQsYBt5lYX50iXSGyRnyLNMdJPqCs8NN3C5QR18FVVBLsn/hB+On1DauyGC0c818b7q4r3nT2uH4Upz+nKGrnX7wxwqcIh0jiCfNhHAK883YNrSGNooui+pw2c0kiHtzyQ2DZKXh2NDw2Eu46c4OfXsXoFdDKtdIBetqHoVFIF+RAHyQbIE2FtHEPhc2sahKkU2OE4eZiC5AMqOF009dXRXJDmfm/OgJDFoSx2ptKNSOiBrJg8mHl22FE7khxxSAQ89tv7TBGd8WPjWzVHa9pVQTuJwg9K6y/kDcuR1F51X+hFLm3+ySb1DhdVyjzdURHa+vH6aZ5vg7fNJ76ZVZGC/JOO01rY7zvYVLGb7o++mNczd3YvVXne0ktNX3H5ovKvG9PPF4ieIW3qBjF8zBGN9oh4yVDvBWGwRSedj6cKJM3lWUXKhzbUOTSThnJpBLOvKU0Re0ycunv2AJM6yyv0mvidc6n0WnuwP/cmMua1+zejRYWk28i2fyt1qiSNkzsc4alyqitgCm0kcqb5NiF8YlTSZnYSBoe1uAA0rUEFKxPBuqbEynJy55Y08SMGEqKYMFYU X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8510.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(376014)(1800799024)(7416014)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2e3mpWqCs9ia9Bc/raD4B5o1f0FoGqPBqLYAveS6uTH0RSVxg0usVwxwWuG12YlQmxZskld6gR64azDBHteqt6zq4O462q8KBjfxModhwiglKhnL5u21F4qimb+BgeELPrW46nYy3llA2iMVBxNL5dhzwcJj9ty+V801UHLGLrP71cFZNqCYWYiv1B1TPRI3TOko2xGuy3m183nwWhS0GjHKHI5I1NrBAn0/TPwFhNUBI0xrRqoebGxZ2qHxgsby3JzQsspyApGFyWyvu5wAdIiCMHwOGO0eW5Y1/LJNeyxfW/dz9GUMd2dE2JBV3ZLNxMxM1+7wj/o16T+rQp/0IazLjFHWUtcZns+HIOz7gZTG2yRsGgqgwsXUQG1nSt4pj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K+Jc++JbTol/G7cHk04WXBQfK5NM7/n/tyS1h6nk6K31uXpFlPptYodq5JRxG1yYe+2wC16NRiY6/pHukvTivQrzRdGcsQxZs9pXlaMf77xwMT3ffT2n4diZ6yX X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 803ec32f-5487-4338-bf6a-08dd2bbf1ebf X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jan 2025 06:23:21.3482 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: HEMeBpjddjhaqmWHIlC6MFfLxMzLxW52IiffgXhZAu66iZCXekBusm6oimkEdnG2/HQ3YKZPcWl7pedujCzwLw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB9331 X-Patchwork-Delegate: kuba@kernel.org ENETC's MAC filter consists of hash MAC filter and exact MAC filter. Hash MAC filter is a 64-entry hash table consisting of two 32-bit registers. Exact MAC filter is implemented by configuring MAC address filter table through command BD ring. The table is stored in ENETC's internal memory and needs to be read through command BD ring. In order to facilitate debugging, added a debugfs interface to get the relevant information about MAC filter. Signed-off-by: Wei Fang --- drivers/net/ethernet/freescale/enetc/Makefile | 1 + drivers/net/ethernet/freescale/enetc/enetc.h | 1 + .../ethernet/freescale/enetc/enetc4_debugfs.c | 93 +++++++++++++++++++ .../ethernet/freescale/enetc/enetc4_debugfs.h | 20 ++++ .../net/ethernet/freescale/enetc/enetc4_pf.c | 4 + 5 files changed, 119 insertions(+) create mode 100644 drivers/net/ethernet/freescale/enetc/enetc4_debugfs.c create mode 100644 drivers/net/ethernet/freescale/enetc/enetc4_debugfs.h diff --git a/drivers/net/ethernet/freescale/enetc/Makefile b/drivers/net/ethernet/freescale/enetc/Makefile index 707a68e26971..f1c5ad45fd76 100644 --- a/drivers/net/ethernet/freescale/enetc/Makefile +++ b/drivers/net/ethernet/freescale/enetc/Makefile @@ -16,6 +16,7 @@ fsl-enetc-$(CONFIG_FSL_ENETC_QOS) += enetc_qos.o obj-$(CONFIG_NXP_ENETC4) += nxp-enetc4.o nxp-enetc4-y := enetc4_pf.o +nxp-enetc4-$(CONFIG_DEBUG_FS) += enetc4_debugfs.o obj-$(CONFIG_FSL_ENETC_VF) += fsl-enetc-vf.o fsl-enetc-vf-y := enetc_vf.o diff --git a/drivers/net/ethernet/freescale/enetc/enetc.h b/drivers/net/ethernet/freescale/enetc/enetc.h index 4dba91408e3d..ca1bc85c0ac9 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.h +++ b/drivers/net/ethernet/freescale/enetc/enetc.h @@ -318,6 +318,7 @@ struct enetc_si { struct enetc_mac_filter mac_filter[MADDR_TYPE]; struct workqueue_struct *workqueue; struct work_struct rx_mode_task; + struct dentry *debugfs_root; }; #define ENETC_SI_ALIGN 32 diff --git a/drivers/net/ethernet/freescale/enetc/enetc4_debugfs.c b/drivers/net/ethernet/freescale/enetc/enetc4_debugfs.c new file mode 100644 index 000000000000..3a660c80344a --- /dev/null +++ b/drivers/net/ethernet/freescale/enetc/enetc4_debugfs.c @@ -0,0 +1,93 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* Copyright 2025 NXP */ + +#include +#include +#include + +#include "enetc_pf.h" +#include "enetc4_debugfs.h" + +#define is_en(x) (x) ? "Enabled" : "Disabled" + +static void enetc_show_si_mac_hash_filter(struct seq_file *s, int i) +{ + struct enetc_si *si = s->private; + struct enetc_hw *hw = &si->hw; + u32 hash_h, hash_l; + + hash_l = enetc_port_rd(hw, ENETC4_PSIUMHFR0(i)); + hash_h = enetc_port_rd(hw, ENETC4_PSIUMHFR1(i)); + seq_printf(s, "SI %d unicast MAC hash filter: 0x%08x%08x\n", + i, hash_h, hash_l); + + hash_l = enetc_port_rd(hw, ENETC4_PSIMMHFR0(i)); + hash_h = enetc_port_rd(hw, ENETC4_PSIMMHFR1(i)); + seq_printf(s, "SI %d multicast MAC hash filter: 0x%08x%08x\n", + i, hash_h, hash_l); +} + +static int enetc_mac_filter_show(struct seq_file *s, void *data) +{ + struct maft_entry_data maft_data; + struct enetc_si *si = s->private; + struct enetc_hw *hw = &si->hw; + struct maft_keye_data *keye; + struct enetc_pf *pf; + int i, err, num_si; + u32 val; + + pf = enetc_si_priv(si); + num_si = pf->caps.num_vsi + 1; + + val = enetc_port_rd(hw, ENETC4_PSIPMMR); + for (i = 0; i < num_si; i++) { + seq_printf(s, "SI %d Unicast Promiscuous mode: %s\n", + i, is_en(PSIPMMR_SI_MAC_UP(i) & val)); + seq_printf(s, "SI %d Multicast Promiscuous mode: %s\n", + i, is_en(PSIPMMR_SI_MAC_MP(i) & val)); + } + + /* MAC hash filter table */ + for (i = 0; i < num_si; i++) + enetc_show_si_mac_hash_filter(s, i); + + if (!pf->num_mfe) + return 0; + + /* MAC address filter table */ + seq_puts(s, "Show MAC address filter table\n"); + for (i = 0; i < pf->num_mfe; i++) { + memset(&maft_data, 0, sizeof(maft_data)); + err = ntmp_maft_query_entry(&si->ntmp.cbdrs, i, &maft_data); + if (err) + return err; + + keye = &maft_data.keye; + seq_printf(s, "Entry %d, MAC: %pM, SI bitmap: 0x%04x\n", i, + keye->mac_addr, le16_to_cpu(maft_data.cfge.si_bitmap)); + } + + return 0; +} +DEFINE_SHOW_ATTRIBUTE(enetc_mac_filter); + +void enetc_create_debugfs(struct enetc_si *si) +{ + struct net_device *ndev = si->ndev; + struct dentry *root; + + root = debugfs_create_dir(netdev_name(ndev), NULL); + if (IS_ERR(root)) + return; + + si->debugfs_root = root; + + debugfs_create_file("mac_filter", 0444, root, si, &enetc_mac_filter_fops); +} + +void enetc_remove_debugfs(struct enetc_si *si) +{ + debugfs_remove_recursive(si->debugfs_root); + si->debugfs_root = NULL; +} diff --git a/drivers/net/ethernet/freescale/enetc/enetc4_debugfs.h b/drivers/net/ethernet/freescale/enetc/enetc4_debugfs.h new file mode 100644 index 000000000000..96caca35f79d --- /dev/null +++ b/drivers/net/ethernet/freescale/enetc/enetc4_debugfs.h @@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */ +/* Copyright 2025 NXP */ + +#ifndef __ENETC4_DEBUGFS_H +#define __ENETC4_DEBUGFS_H + +#if IS_ENABLED(CONFIG_DEBUG_FS) +void enetc_create_debugfs(struct enetc_si *si); +void enetc_remove_debugfs(struct enetc_si *si); +#else +static inline void enetc_create_debugfs(struct enetc_si *si) +{ +} + +static inline void enetc_remove_debugfs(struct enetc_si *si) +{ +} +#endif + +#endif diff --git a/drivers/net/ethernet/freescale/enetc/enetc4_pf.c b/drivers/net/ethernet/freescale/enetc/enetc4_pf.c index 6ec849949267..6de571b5b425 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc4_pf.c +++ b/drivers/net/ethernet/freescale/enetc/enetc4_pf.c @@ -8,6 +8,7 @@ #include #include "enetc_pf_common.h" +#include "enetc4_debugfs.h" #define ENETC_SI_MAX_RING_NUM 8 @@ -1169,6 +1170,8 @@ static int enetc4_pf_probe(struct pci_dev *pdev, if (err) goto err_netdev_create; + enetc_create_debugfs(si); + return 0; err_netdev_create: @@ -1186,6 +1189,7 @@ static void enetc4_pf_remove(struct pci_dev *pdev) struct enetc_si *si = pci_get_drvdata(pdev); struct enetc_pf *pf = enetc_si_priv(si); + enetc_remove_debugfs(si); enetc4_pf_netdev_destroy(si); enetc4_pf_free(pf); destroy_workqueue(si->workqueue); From patchwork Fri Jan 3 06:06:02 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Fang X-Patchwork-Id: 13925204 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2085.outbound.protection.outlook.com [40.107.105.85]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 82AA41BEF7F; Fri, 3 Jan 2025 06:23:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.105.85 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735885415; cv=fail; b=dg9bx1ioSF7+3az5qJBrZOu6fGZE7ZIM6hlRy7VJ8xXtJPsipHIilSIdhdy4NxSpZfTmoh8UJqfEjdySiK9y8gBp/8IrlEfSjL28p1s2CpyLrxNs/J26VgE8x2UzQo2vIysp7/MXG/XHFzkRzg8EGDrcvMZBe4JYBXhzrGEjuA0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735885415; c=relaxed/simple; bh=Wh1nROYi3GJCa4V69d/jYlVBAdaVKlkA3viWgnyu1SM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=UJ66ripxjYCvC1FFybtQQ3QdyVvRKVglTZvBFVCIBvm5ntdtdj2WtEe+VNTWP4aZ1HprP8sd1uzxcp+PbR9qhyW5w6M+aAutG0uA865NqovgIvnepGJum/ZXEaA+V6uj9qSbADPme5NqzDWELDs6OujHE0EhUvV2yDrwZASzf5E= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=g2h7YMRc; arc=fail smtp.client-ip=40.107.105.85 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="g2h7YMRc" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=sPClOuCBTH0wo5ohAtKPfcaPJRt9AmYGg3m9mQPjqAnVPok+ZwyoLLZ6qmdyEaRSp/YU6JanqVye5NFajJd4v/rHRGPs6A97cPjfXSJPHhYJk0oOgrUfVPeXVUSJ7RB7aCRRz6GP3MgKxioIabgwKetNMOT0jltMPeJSH7WlEHm+/T6uwURdlIZ2KCYJjP3USxGB0hJYNny+NEC64mkJBKA0C22pKpqyZrdEMVbeMhVNe1wJtcguu2bfTq29QyOEMjdlbf+h48Es1JHOchi6FccpordrXcA5728eBA7iY/dGtgKS+q0ascN5QdcPF6uKS19i4dLY3DMiPWCdtjX+8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=LL0zpCYuNsrm+dSQosKaPelH0k3flvNhybnHr5dmcQ0=; b=hi5c8DPBMiU6NMGRe2GpiaY687Gqg7CLrCYWM0LA7lI6Izgn3tBOEOf7ib4m7hD49qBW8C68a1YOqH0xdBgBNUcAQZ7VjFrodlvmRw3hegBM7U+kmd1ueEnAxNOXF/dktqBvV2PxmDtRv4Wx4HSIynPVjv4SClRTAIsH+YZdB4acnxwPd5SWcpWTmRBVcXzNzrXFDsNWQbLvq+TtnP5l5LPl/QcBat5mrUIHFOtljXIgXH8D+09Z5n68eTivZpJhyBDuTVAa0iHY7jWJaPbvc1l6i/+fCH+X++8r6CH37JBLYD3RWFfc/x0jSSIk0kUMU1WQEtYUjJx39tqKLe/03A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LL0zpCYuNsrm+dSQosKaPelH0k3flvNhybnHr5dmcQ0=; b=g2h7YMRcxseaFvWlHvq5x54d6POzxBSk9mPosbb3RuzMlXXDFwyxKFrqaFg6Ndc7ivOa7rEu80VOzszmcASNmcgKn9MVG1IVPzY4DG0E1eDn6daIatHkYXiQxswhKRjZXBmKH3ma7Gez3bFeWmvNJZlVyOkTmDH5AAXp+6gpMXFwJF/oewo7JGH6I4d2ybhtrcTtklBZujrektsiATzY0z2H6ljJJOzLUpA9jIIPDwVMyZa6DseC4/taJQc4sGmUN7bmpI6wRVsPfzHT7oxrz6wbtwwrR4INWWLdQPj63aYvy60iFTN3OC0CsEJojGTee+SjirDM7rbkONg3mAZuWg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) by DB9PR04MB9331.eurprd04.prod.outlook.com (2603:10a6:10:36d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.12; Fri, 3 Jan 2025 06:23:25 +0000 Received: from PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db]) by PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db%6]) with mapi id 15.20.8314.013; Fri, 3 Jan 2025 06:23:25 +0000 From: Wei Fang To: claudiu.manoil@nxp.com, vladimir.oltean@nxp.com, xiaoning.wang@nxp.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, christophe.leroy@csgroup.eu Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, imx@lists.linux.dev Subject: [PATCH net-next 06/13] net: enetc: make enetc_set_rxfh() and enetc_get_rxfh() reusable Date: Fri, 3 Jan 2025 14:06:02 +0800 Message-Id: <20250103060610.2233908-7-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250103060610.2233908-1-wei.fang@nxp.com> References: <20250103060610.2233908-1-wei.fang@nxp.com> X-ClientProxiedBy: SG2PR03CA0127.apcprd03.prod.outlook.com (2603:1096:4:91::31) To PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8510:EE_|DB9PR04MB9331:EE_ X-MS-Office365-Filtering-Correlation-Id: 1a2e6f1f-78a5-44e4-1694-08dd2bbf2165 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|1800799024|7416014|366016|38350700014; X-Microsoft-Antispam-Message-Info: A/MTYyiGK5DZHJL4E8jvq3aJUGkKj6Ue8GT3fDiwqL0A3tMMsk3/hPOJ1V/GpWKkAvMJ/cDCPZq+yOwdbk04YDM+W0XrqXvSjFH2LEU+AvEgrkJLeVwg+jCZiGWMXq9lts6cxn2lXDYKR/xCIRwwYMQtmpFYtltKRoebvTfzFiichI7OPFckLkC0geeyaOrXRqCy90e+/7MjSAEkSaG3pX+M2xqLyHXtYvynQSUNq7tG+zqMj59r24b5IUZmYIdih4cBkcL4/5l5EkmvORDNa0y/29Lq87jRHsa136ogWP5PVhGCkGI4mx9eDEnXlM8NbuQF2AsiQIsnkHRpEe8CuE+iHyYOgpHptkHBgre1MYkwHfE2kwhq/vDYbAXMLwJqzS+EBwHNgPk9YYW2azjZidlPQYM/n6m8jrS87cnwi+oV66MW/gIIO07NQFY5WaVfnrmtWjMHooVVjjB4C1Z9/o6YjY8eQFZzu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urprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(376014)(1800799024)(7416014)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: PJaOp3S6om2GmWyjT5LXcBKebmWswdsfwSiszLY0SbsFVoby+P9OnvRWRPcYOjZ9UW3iDSzItdqTxAIp10s91MxdeVETLmlejW9wFJc2fLa5Em3jc/+4tL4+JnUxQAgvxPkRfhzuyp5rO6xQKoV/TJzTAsSKHXE1P937qDvPOuvuA8Ul1VK8Pg1S80r0EPU+oqKx/dD9tgrD+MzGSHSC3QCpB4QUSrL4hwPtOV9p0QClcIIFlzs+KzIo0fcoDwbk6zsfbT2k/QH7d3WWDDdB29eedNn2yTG/6aYt+RnPjcNq0tZdkqVyaSVfUqMBavo+aS6sr5tLsPMC/Fs49fnmc74W6TEU13uxvjkhaNV9Wy0en2L4K3uYlXb5TNPCjH9Tt7+RGTZ2WfCFFfQcTHLqMYvrFc03j89wj3xXU8PCzsYZj15I7SUA9fsHIVg2bpcrXd+fq9MhIxWs7d+b3a3ObRM1+UJczbRkqDeuzy205cvhCollRyh2QPK82B1qfZf9+uIMdKmlrXCz2CSgMwIpsRkx2p0B7dyrzPxA0hdQ4eWpR4KUYiMpJXEwNz3GWF3lwKdgyo3pUK0SAclaIgMoc6VQgQ4IGsSsQrQ4Fff1+Abibrmq0wXKrn1y/p6d2TVB1aAfg6pJ80fuKU5M9yQ4Isj4eVGECjuMtnLtsNew1pp1upyV8yg0sSzlBvjjmPYftJwXegxqMM0TJbW1Y+gEQP4uSC1phWZzCEATTY/q4DQb5+3sfPD+0ZThrqV8vN430b2GdXq6V9JVHJrJ9z2IMdG5TpYxvt53D8fd/2ovucoZOaDMPvAcwPxd9FnoShsibLc05yGCU5SDpsXWbGH8zk8XtxuHzpzJIqQ9HjfXOHagWHPhlwpCNp9NMeFXSehL0vizngQyhiP1IVk0wNbvp6XxSYJF4Mkwj4TtrgVLZt94Mt8Epw8x0twdWl0y4D9ViX5tzanIAhHSlOiUvFhBJLz3tQDtGFZ+4zHLC0nNKUzM9PCqawcHzN3q9iAd+FXKeSPnRflrPHfgtvMY0SdBve7VstgL+LUAQtizvjultKgMZl9puQ6B5YBXU0VFMk+gMySj03gbc7r5sJyPXFCyXDH2DGUwa2CaLNlxKrJgN4O9qPAOJYQt+A77w0u5V8B33LeZL8PNhvU+fr0+HYy1710rG7lM1aRgE0v9KiS+xWevlYTwlpiA7aNuTYU7f7EmKJq0NDsXOStET46Hr3dW+jdrGv9jd4x9YCWXojt3lpLLLxSFJaceKdt9NwLQ3ktjeEV/Umg8/BfyA6yXKCxyRy9SXK+UX6DjdSXRdtAlk5VNvI+WYCs67ZTht8rpgfBt1d0Cm0U7cSXEu5wIFWWk6wY8lGp9tult4J2luCJJl/CGxNQrttAarm8B1E8/l2UOLGSv37nN3PNVBJulclTHHq2JuXfLFRVvLt9xx+0zZYQUCr3VhR3Vkg3xmwo3izU7skw2cQ0IdxLrb2Iw2083HYfxuvnQaOk9CfqpzEhjnPq6BaDQGjP2G3du98H1NYoOJjBM3D8NU+mSYW/qp+KP3+vGaYVpExmdd0UJIk9UqEjT6pYis0+9F8yDP20XY4nF X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1a2e6f1f-78a5-44e4-1694-08dd2bbf2165 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jan 2025 06:23:25.7751 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: oUh+o968Yc0ZoE3+XjbbFiV5rVPMWB0/VDacj6Ow11aTtz/a8xTPVtI9sJVt16wE9JHSxy/hP/eh7Q5jjaxygQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB9331 X-Patchwork-Delegate: kuba@kernel.org Both ENETC v1 and v4 support Receive Side Scaling (RSS), but the offset of the RSS key registers is different. In order to make enetc_get_rxfh() and enetc_set_rxfh() be reused by ENETC v4, the .set_rss_key() and .get_rss_key() interfaces are added to enect_pf_ops. Signed-off-by: Wei Fang --- drivers/net/ethernet/freescale/enetc/enetc.h | 1 - .../ethernet/freescale/enetc/enetc_ethtool.c | 42 +++++++++---------- .../net/ethernet/freescale/enetc/enetc_pf.c | 18 ++++++++ .../net/ethernet/freescale/enetc/enetc_pf.h | 2 + 4 files changed, 39 insertions(+), 24 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.h b/drivers/net/ethernet/freescale/enetc/enetc.h index ca1bc85c0ac9..fb53fb961364 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.h +++ b/drivers/net/ethernet/freescale/enetc/enetc.h @@ -537,7 +537,6 @@ int enetc_set_mac_flt_entry(struct enetc_si *si, int index, int enetc_clear_mac_flt_entry(struct enetc_si *si, int index); int enetc_set_fs_entry(struct enetc_si *si, struct enetc_cmd_rfse *rfse, int index); -void enetc_set_rss_key(struct enetc_hw *hw, const u8 *bytes); int enetc_get_rss_table(struct enetc_si *si, u32 *table, int count); int enetc_set_rss_table(struct enetc_si *si, const u32 *table, int count); int enetc_send_cmd(struct enetc_si *si, struct enetc_cbd *cbd); diff --git a/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c b/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c index bf34b5bb1e35..56ba82830279 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c @@ -4,7 +4,8 @@ #include #include #include -#include "enetc.h" + +#include "enetc_pf.h" static const u32 enetc_si_regs[] = { ENETC_SIMR, ENETC_SIPMAR0, ENETC_SIPMAR1, ENETC_SICBDRMR, @@ -681,51 +682,46 @@ static int enetc_get_rxfh(struct net_device *ndev, struct ethtool_rxfh_param *rxfh) { struct enetc_ndev_priv *priv = netdev_priv(ndev); - struct enetc_hw *hw = &priv->si->hw; - int err = 0, i; + struct enetc_si *si = priv->si; + struct enetc_hw *hw = &si->hw; + int err = 0; /* return hash function */ rxfh->hfunc = ETH_RSS_HASH_TOP; /* return hash key */ - if (rxfh->key && hw->port) - for (i = 0; i < ENETC_RSSHASH_KEY_SIZE / 4; i++) - ((u32 *)rxfh->key)[i] = enetc_port_rd(hw, - ENETC_PRSSK(i)); + if (rxfh->key && enetc_si_is_pf(si)) { + struct enetc_pf *pf = enetc_si_priv(si); + + pf->ops->get_rss_key(hw, rxfh->key); + } /* return RSS table */ if (rxfh->indir) - err = enetc_get_rss_table(priv->si, rxfh->indir, - priv->si->num_rss); + err = enetc_get_rss_table(si, rxfh->indir, si->num_rss); return err; } -void enetc_set_rss_key(struct enetc_hw *hw, const u8 *bytes) -{ - int i; - - for (i = 0; i < ENETC_RSSHASH_KEY_SIZE / 4; i++) - enetc_port_wr(hw, ENETC_PRSSK(i), ((u32 *)bytes)[i]); -} -EXPORT_SYMBOL_GPL(enetc_set_rss_key); - static int enetc_set_rxfh(struct net_device *ndev, struct ethtool_rxfh_param *rxfh, struct netlink_ext_ack *extack) { struct enetc_ndev_priv *priv = netdev_priv(ndev); - struct enetc_hw *hw = &priv->si->hw; + struct enetc_si *si = priv->si; + struct enetc_hw *hw = &si->hw; int err = 0; /* set hash key, if PF */ - if (rxfh->key && hw->port) - enetc_set_rss_key(hw, rxfh->key); + if (rxfh->key && enetc_si_is_pf(si)) { + struct enetc_pf *pf = enetc_si_priv(si); + + pf->ops->set_rss_key(hw, rxfh->key); + } /* set RSS table */ if (rxfh->indir) - err = enetc_set_rss_table(priv->si, rxfh->indir, - priv->si->num_rss); + err = enetc_set_rss_table(si, rxfh->indir, si->num_rss); return err; } diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf.c b/drivers/net/ethernet/freescale/enetc/enetc_pf.c index cc3e52bd3096..f050cf039733 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_pf.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf.c @@ -512,6 +512,22 @@ static void enetc_mac_enable(struct enetc_si *si, bool en) enetc_port_mac_wr(si, ENETC_PM0_CMD_CFG, val); } +static void enetc_set_rss_key(struct enetc_hw *hw, const u8 *key) +{ + int i; + + for (i = 0; i < ENETC_RSSHASH_KEY_SIZE / 4; i++) + enetc_port_wr(hw, ENETC_PRSSK(i), ((u32 *)key)[i]); +} + +static void enetc_get_rss_key(struct enetc_hw *hw, u8 *key) +{ + int i; + + for (i = 0; i < ENETC_RSSHASH_KEY_SIZE / 4; i++) + ((u32 *)key)[i] = enetc_port_rd(hw, ENETC_PRSSK(i)); +} + static void enetc_configure_port(struct enetc_pf *pf) { u8 hash_key[ENETC_RSSHASH_KEY_SIZE]; @@ -975,6 +991,8 @@ static const struct enetc_pf_ops enetc_pf_ops = { .create_pcs = enetc_pf_create_pcs, .destroy_pcs = enetc_pf_destroy_pcs, .enable_psfp = enetc_psfp_enable, + .set_rss_key = enetc_set_rss_key, + .get_rss_key = enetc_get_rss_key, }; static int enetc_pf_probe(struct pci_dev *pdev, diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf.h b/drivers/net/ethernet/freescale/enetc/enetc_pf.h index 3b0cb0d8bf48..916818d2fdb5 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_pf.h +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf.h @@ -39,6 +39,8 @@ struct enetc_pf_ops { struct phylink_pcs *(*create_pcs)(struct enetc_pf *pf, struct mii_bus *bus); void (*destroy_pcs)(struct phylink_pcs *pcs); int (*enable_psfp)(struct enetc_ndev_priv *priv); + void (*set_rss_key)(struct enetc_hw *hw, const u8 *key); + void (*get_rss_key)(struct enetc_hw *hw, u8 *key); }; struct enetc_pf { From patchwork Fri Jan 3 06:06:03 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Fang X-Patchwork-Id: 13925205 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2085.outbound.protection.outlook.com [40.107.105.85]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A66641BEF92; Fri, 3 Jan 2025 06:23:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.105.85 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735885418; cv=fail; b=k7z3U/9/71qsiyDWtXqtVU0h6YkXIPEKfpthWhmwsVB1mzzqu7F+IU1DO/ygx7CeC2P8Tf6bekbJHx2pEqA0Km3an7wEkMPP8LUOZ6uut4AJcxyqGe+LQ6uNXnCZcC1nf12lk5YJmXBh0L1ewoT2Kssbbrlu7VoxE9SlACNwfxI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735885418; c=relaxed/simple; bh=vPHPcuDOytwCICRVWsP6j483YuiHJf72VFAClmq7ZXI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=O1EIK8N01knjwDefJXQm4II3N//98iHCb+nQ74qNpgKgjGI2vhxHCdILiuoUoGL04P0Z61E7JNvR6naEP17HOcUWXRuxq7FLg6/YdCmmx349X9DY6Zg9DBODBouLZ4MSHxaOM21l2bIRc6kWY0Ww6Shta8kvQBKzp23VyVch2YU= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=ZwMfl/YX; arc=fail smtp.client-ip=40.107.105.85 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="ZwMfl/YX" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=yGkH+W9VCJGXAE/TQBgJjfasGgwT491tX6lFRQgCjtU7GhIXnJt5ZjX8/GilmXHSdmUAVx3+1xpQfZV1tR/Kk6dOADWrQu1fOinkAnvAhGBrdvZ1SLiU2+ZFD9fINkyfMk3EffqeG2FklkPPAeRnTs30TlDLIKyd80iOzXFSEUo0UrlrPkrcLZ+xuX3hr2PJpalNBb3yCMlGssRD6H8xfBXiDea2ZxqH4H5zlulGLKfBy0JBWKpGNUlFMR2CZ0EgNa3N6TDFBpEbg/pg8lk2bMJAgr/wMckO/HgtNte0+WefjHeANMp39H5nIHAqFY5qs8Nu7Im1//vZCHdS+4TP9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=wox8ejjVa0BEuHvgvzDrLCuwp+xjoQ4z+lM051MhcWE=; b=I294i6eZ7s9I891gKoSduF5clM911DE+H/wbp+9lwtWvA76X1ygpVNqNmee1vKnB+pFQMbGALAMbVp5C/wNRc66Ptn+aelVZI1773ui9DwT6LMbKdv10qQEg3RLeoJU2awEfigOD4Sx2a49Rwbg5fECrZCCB018e4cJUl10wb0qzzPvztTFh6DQ4OtOloMJIajlDX8S6fkj/QyZskHYPdOtQcsz7PuZTNp/RzO4Q1z4w+6tUsCwDBoz4+5429j84O6DLZBQUFZw0hJJOkdx8Auyfbx9BAuCGsEGK+Bbp8lHyNFGWAHAz+AkQFH1l5LNNHZC+ziQrtv2fA7YUATYNWQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wox8ejjVa0BEuHvgvzDrLCuwp+xjoQ4z+lM051MhcWE=; b=ZwMfl/YXpwleMf0QOOGs3kwuq1eEdeaUm9EtxPjKDNTAgzrV4chM6o9mN2k3XlJrwpiXnmn8ZXOev1GUs1E4enqL/PkJIK8drvaX+4wegTOxPNQ8A1G3hAtWWmYwwESdom36yo+4f6tJrnLpqH/NQpabvZZzXXsPBRBZd9hbVdFZv1wQXHNt92Y7RhZAjX/xF9HyHC1GlkiY6CUhGXvjKb6z2UW7s2o5JaiF6tUEODmG5MDHx7hjxOXEG6NCmR1lxNgrQQxFQYYxaCLLrVCh4Y+e/qFw+9mGg0DIun5gVq5rXVtQVbJPUHC3fPgZYMFkB88H7mJ/9pTOJmFHhcfhng== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) by DB9PR04MB9331.eurprd04.prod.outlook.com (2603:10a6:10:36d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.12; Fri, 3 Jan 2025 06:23:30 +0000 Received: from PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db]) by PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db%6]) with mapi id 15.20.8314.013; Fri, 3 Jan 2025 06:23:30 +0000 From: Wei Fang To: claudiu.manoil@nxp.com, vladimir.oltean@nxp.com, xiaoning.wang@nxp.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, christophe.leroy@csgroup.eu Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, imx@lists.linux.dev Subject: [PATCH net-next 07/13] net: enetc: add RSS support for i.MX95 ENETC PF Date: Fri, 3 Jan 2025 14:06:03 +0800 Message-Id: <20250103060610.2233908-8-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250103060610.2233908-1-wei.fang@nxp.com> References: <20250103060610.2233908-1-wei.fang@nxp.com> X-ClientProxiedBy: SG2PR03CA0127.apcprd03.prod.outlook.com (2603:1096:4:91::31) To PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8510:EE_|DB9PR04MB9331:EE_ X-MS-Office365-Filtering-Correlation-Id: 469925d1-9bdf-47f6-4ca6-08dd2bbf23ff X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|1800799024|7416014|366016|38350700014; X-Microsoft-Antispam-Message-Info: l234m5s7mjOd8mq61/jU7Zp9NUKwNYvCtug2onouxhvr3SZUpi4s9SGuz7dohw4UvwD5V6PzlFbMRX2IDJojYA+i1mqcjq1kxHdP691tdI+EwFdWTEksgqkANLyvTJyrBvDy/A+6aQ98Y/rnGUtCZMWzrJEt597yzwgDXYOHY5Jtk+TZ6ARm/lOSQyJrvMd88RcanpX+/L4VLKBGcfpA6S6/IiQw1m2sGTDr6V+IaAeKXjrjFjJLP4wyky73uAS1AvTslHoWQxJh+io3ejsly9mkO7dYo3GHYaumde47pLob+wO1bHK/CugqtpGxJfY9vG1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0+6cDkiV9YYRn9SQzAoE1wn1vq2cSAFV1aE3758zyKp4uJuMfb1thLtBPdgd/ejH+h3uv9sZIDda X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8510.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(376014)(1800799024)(7416014)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: kvh9oyelmimH/JSd2DARAqnj0T9gUDJlFZgkYP8YN2HNAQAXYItAycTdr3HoruOXgcpKDkLfm3BHr7tVTsB6qW2bhhD8tjgakmJ3cgA0LgVtaYuDVWuivqA2d06Y/w4NwKtTf4SBHi3QwIlt/lSF1AAAmQfDkLAgJyGcUq/0RBE4D0++ZKpHGZ6FIPUAHE/HkRMdKiJtiJKZxZsb+36eXU6Brvq6MzRMO1mIrS6MzH1WLH9kThmxjDatLqouxf5ecQ5yI9gVDepVY3bfGUU7q1Z2YxrloAfJLZD/SyuQyDfXJ6zHbwGckcqo793wmv1U5q0AHYIiBgYdOTiWSIr4Use4jJ7mLe3Sqik+7Dgqqo8we8bFd5bBB0fNzM4VOaFxpMdSrrJKv64J7BsDImGqKL1Y4AjAHzBOZulzNrRfXHSenwbXXGYYgGtqQc8xAJT6LSQ0MFp/F+RwDINK9IlZ+PLCKhVSQvfQg7m/Mdhw5LDK6QZ5UcmYK5ny5K25QC8OrvqB+DAd09sXtOZQYZpWUJ8FqJk7scksj4EuSTw2PSlGn32KqohQEva2jmNox9JDsWUB10G/CFSn3IhrltYsgLz8V/DfYAbztYi9U9gHtsQrkeBZRA9L1slk9pf4Ln8i3RGj5cnO6KWTCOEbWXrEonEgay31xouyyb/dy5QuzWSg/pqc7EgOcPjD9xxZjXaO2wsODpricAXqZVyzyK5KzLUvkOSBIzrP+hl94en4smq+7WkwprVWmpV6dsuhByhJScgi0PcSjkBF4AYTluLGtRqxLnvVj2LLN+JjIfSQaUVyeUFpZa4Cbr6h/rknnYvKU1Sd1L/47agR4sWPBW8hyn3bJrYx/rwKpxh/pA5nANNtEuKT58fLsUrqu1KN2Ot2i3dLk1KeR1H1g3Ua+6PckkZHK9AaaZoa8FGsD7H4FJI9UrTSbtWI18HKvbRtyEgeLnr6klgyZRWxgwarcsaLuvtRbhnxFro7GW4ZdELLsjsQBrJztCuZGBzu4wNVXOUmreO21puSyNEDj69zFS9Ovnx1ZMBMJV7JjMrTVV3quzkO+oQn5lmL98/kMR+b8A7yK5AR3BGnZsPQlKHMNREUkDq7Ds44muFlbh7EGia3WkP9JZiuSFAR+n9ErQaqctmNRwYPb63JeHhkCNvBDbLkV8mphprUU3QNrleN8m7ye3JeY/X6ZDhODU3GNqVbj2hBZj3o/CqVsLa/KWKGumS05SFg8mo03LOztev4AehW+yrCFwRtVNuI/nGGMy3mjxlm2g6j7agW1SIjJW7UAPTmbn2b9sKsshTOQg/ui4QfWFzvsPHX0bKUH9EDv0P9F+dCW4lSsCCzIoMLGaJj5JU5ugUjAKodmBBjFGroZZgIb3MiAevg9oLvvI/Y2VtQy5cCuADZxMaSjVLmqI8t0EnZelgo/+4/GSA28xx448le/vS52nyVAEbXNJMCON+eqL9nKSCBJIC+mgHz4En53VmzsARAu50Bu6dxhbGCjmSqXFEATzW/yaOx15gcAH5xCkSUoBAg//JLPOZbSIAuUHCGcJQ+CV0AJ8t9kZNC3+n3URyEe1T2sWn6EgF9p9TDeScM X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 469925d1-9bdf-47f6-4ca6-08dd2bbf23ff X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jan 2025 06:23:30.2316 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: q4kir84HTPEKy/6SHbciZZ4/Z2Pkt5wITorq7/WECiY97OAOTivrFiCl/dbjNZNRG0RY/rRM+gPdEvv8w+dO9w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB9331 X-Patchwork-Delegate: kuba@kernel.org Add Receive side scaling (RSS) support for i.MX95 ENETC PF to improve the network performance and balance the CPU loading. In addition, since both ENETC v1 and ENETC v4 only support the toeplitz algorithm, so a check for hfunc was added. Signed-off-by: Wei Fang --- drivers/net/ethernet/freescale/enetc/enetc.c | 7 +--- drivers/net/ethernet/freescale/enetc/enetc.h | 4 ++ .../net/ethernet/freescale/enetc/enetc4_pf.c | 37 +++++++++++++++---- .../net/ethernet/freescale/enetc/enetc_cbdr.c | 14 +++++++ .../ethernet/freescale/enetc/enetc_ethtool.c | 33 ++++++++++++++++- .../net/ethernet/freescale/enetc/enetc_pf.c | 2 + .../freescale/enetc/enetc_pf_common.c | 6 +-- .../net/ethernet/freescale/enetc/enetc_vf.c | 2 + 8 files changed, 87 insertions(+), 18 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c index 6d21c133e418..233f58e57a20 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -2363,7 +2363,7 @@ static int enetc_setup_default_rss_table(struct enetc_si *si, int num_groups) for (i = 0; i < si->num_rss; i++) rss_table[i] = i % num_groups; - enetc_set_rss_table(si, rss_table, si->num_rss); + si->ops->set_rss_table(si, rss_table, si->num_rss); kfree(rss_table); @@ -2394,10 +2394,7 @@ int enetc_configure_si(struct enetc_ndev_priv *priv) if (si->hw_features & ENETC_SI_F_LSO) enetc_set_lso_flags_mask(hw); - /* TODO: RSS support for i.MX95 will be supported later, and the - * is_enetc_rev1() condition will be removed - */ - if (si->num_rss && is_enetc_rev1(si)) { + if (si->num_rss) { err = enetc_setup_default_rss_table(si, priv->num_rx_rings); if (err) return err; diff --git a/drivers/net/ethernet/freescale/enetc/enetc.h b/drivers/net/ethernet/freescale/enetc/enetc.h index fb53fb961364..2b0d27ed924d 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.h +++ b/drivers/net/ethernet/freescale/enetc/enetc.h @@ -290,6 +290,8 @@ struct enetc_si; struct enetc_si_ops { int (*setup_cbdr)(struct enetc_si *si); void (*teardown_cbdr)(struct enetc_si *si); + int (*get_rss_table)(struct enetc_si *si, u32 *table, int count); + int (*set_rss_table)(struct enetc_si *si, const u32 *table, int count); }; /* PCI IEP device data */ @@ -540,6 +542,8 @@ int enetc_set_fs_entry(struct enetc_si *si, struct enetc_cmd_rfse *rfse, int enetc_get_rss_table(struct enetc_si *si, u32 *table, int count); int enetc_set_rss_table(struct enetc_si *si, const u32 *table, int count); int enetc_send_cmd(struct enetc_si *si, struct enetc_cbd *cbd); +int enetc4_get_rss_table(struct enetc_si *si, u32 *table, int count); +int enetc4_set_rss_table(struct enetc_si *si, const u32 *table, int count); static inline void *enetc_cbd_alloc_data_mem(struct enetc_si *si, struct enetc_cbd *cbd, diff --git a/drivers/net/ethernet/freescale/enetc/enetc4_pf.c b/drivers/net/ethernet/freescale/enetc/enetc4_pf.c index 6de571b5b425..4cd0931baea0 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc4_pf.c +++ b/drivers/net/ethernet/freescale/enetc/enetc4_pf.c @@ -69,9 +69,27 @@ static void enetc4_pf_get_si_primary_mac(struct enetc_hw *hw, int si, put_unaligned_le16(lower, addr + 4); } +static void enetc4_set_rss_key(struct enetc_hw *hw, const u8 *key) +{ + int i; + + for (i = 0; i < ENETC_RSSHASH_KEY_SIZE / 4; i++) + enetc_port_wr(hw, ENETC4_PRSSKR(i), ((u32 *)key)[i]); +} + +static void enetc4_get_rss_key(struct enetc_hw *hw, u8 *key) +{ + int i; + + for (i = 0; i < ENETC_RSSHASH_KEY_SIZE / 4; i++) + ((u32 *)key)[i] = enetc_port_rd(hw, ENETC4_PRSSKR(i)); +} + static const struct enetc_pf_ops enetc4_pf_ops = { .set_si_primary_mac = enetc4_pf_set_si_primary_mac, .get_si_primary_mac = enetc4_pf_get_si_primary_mac, + .set_rss_key = enetc4_set_rss_key, + .get_rss_key = enetc4_get_rss_key, }; static int enetc4_pf_struct_init(struct enetc_si *si) @@ -263,14 +281,6 @@ static void enetc4_set_trx_frame_size(struct enetc_pf *pf) enetc4_pf_reset_tc_msdu(&si->hw); } -static void enetc4_set_rss_key(struct enetc_hw *hw, const u8 *bytes) -{ - int i; - - for (i = 0; i < ENETC_RSSHASH_KEY_SIZE / 4; i++) - enetc_port_wr(hw, ENETC4_PRSSKR(i), ((u32 *)bytes)[i]); -} - static void enetc4_set_default_rss_key(struct enetc_pf *pf) { u8 hash_key[ENETC_RSSHASH_KEY_SIZE] = {0}; @@ -691,6 +701,14 @@ static void enetc4_pf_set_rx_mode(struct net_device *ndev) queue_work(si->workqueue, &si->rx_mode_task); } +static int enetc4_pf_set_features(struct net_device *ndev, + netdev_features_t features) +{ + enetc_set_features(ndev, features); + + return 0; +} + static const struct net_device_ops enetc4_ndev_ops = { .ndo_open = enetc_open, .ndo_stop = enetc_close, @@ -698,6 +716,7 @@ static const struct net_device_ops enetc4_ndev_ops = { .ndo_get_stats = enetc_get_stats, .ndo_set_mac_address = enetc_pf_set_mac_addr, .ndo_set_rx_mode = enetc4_pf_set_rx_mode, + .ndo_set_features = enetc4_pf_set_features, }; static struct phylink_pcs * @@ -1106,6 +1125,8 @@ static void enetc4_pf_netdev_destroy(struct enetc_si *si) static const struct enetc_si_ops enetc4_psi_ops = { .setup_cbdr = enetc4_setup_cbdr, .teardown_cbdr = enetc4_teardown_cbdr, + .get_rss_table = enetc4_get_rss_table, + .set_rss_table = enetc4_set_rss_table, }; static int enetc4_pf_wq_task_init(struct enetc_si *si) diff --git a/drivers/net/ethernet/freescale/enetc/enetc_cbdr.c b/drivers/net/ethernet/freescale/enetc/enetc_cbdr.c index 31bb82ee512d..6d85c0caa04f 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_cbdr.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_cbdr.c @@ -295,3 +295,17 @@ int enetc_set_rss_table(struct enetc_si *si, const u32 *table, int count) return enetc_cmd_rss_table(si, (u32 *)table, count, false); } EXPORT_SYMBOL_GPL(enetc_set_rss_table); + +int enetc4_get_rss_table(struct enetc_si *si, u32 *table, int count) +{ + return ntmp_rsst_query_or_update_entry(&si->ntmp.cbdrs, + table, count, true); +} +EXPORT_SYMBOL_GPL(enetc4_get_rss_table); + +int enetc4_set_rss_table(struct enetc_si *si, const u32 *table, int count) +{ + return ntmp_rsst_query_or_update_entry(&si->ntmp.cbdrs, + (u32 *)table, count, false); +} +EXPORT_SYMBOL_GPL(enetc4_set_rss_table); diff --git a/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c b/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c index 56ba82830279..a3059498f146 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c @@ -626,6 +626,24 @@ static int enetc_get_rxnfc(struct net_device *ndev, struct ethtool_rxnfc *rxnfc, return 0; } +static int enetc4_get_rxnfc(struct net_device *ndev, struct ethtool_rxnfc *rxnfc, + u32 *rule_locs) +{ + struct enetc_ndev_priv *priv = netdev_priv(ndev); + + switch (rxnfc->cmd) { + case ETHTOOL_GRXRINGS: + rxnfc->data = priv->num_rx_rings; + break; + case ETHTOOL_GRXFH: + return enetc_get_rsshash(rxnfc); + default: + return -EOPNOTSUPP; + } + + return 0; +} + static int enetc_set_rxnfc(struct net_device *ndev, struct ethtool_rxnfc *rxnfc) { struct enetc_ndev_priv *priv = netdev_priv(ndev); @@ -698,7 +716,7 @@ static int enetc_get_rxfh(struct net_device *ndev, /* return RSS table */ if (rxfh->indir) - err = enetc_get_rss_table(si, rxfh->indir, si->num_rss); + err = si->ops->get_rss_table(si, rxfh->indir, si->num_rss); return err; } @@ -712,6 +730,12 @@ static int enetc_set_rxfh(struct net_device *ndev, struct enetc_hw *hw = &si->hw; int err = 0; + if (rxfh->hfunc != ETH_RSS_HASH_NO_CHANGE && + rxfh->hfunc != ETH_RSS_HASH_TOP) { + netdev_err(ndev, "Only toeplitz hash function is supported\n"); + return -EOPNOTSUPP; + } + /* set hash key, if PF */ if (rxfh->key && enetc_si_is_pf(si)) { struct enetc_pf *pf = enetc_si_priv(si); @@ -721,7 +745,7 @@ static int enetc_set_rxfh(struct net_device *ndev, /* set RSS table */ if (rxfh->indir) - err = enetc_set_rss_table(si, rxfh->indir, si->num_rss); + err = si->ops->set_rss_table(si, rxfh->indir, si->num_rss); return err; } @@ -1233,6 +1257,11 @@ const struct ethtool_ops enetc4_pf_ethtool_ops = { .set_wol = enetc_set_wol, .get_pauseparam = enetc_get_pauseparam, .set_pauseparam = enetc_set_pauseparam, + .get_rxnfc = enetc4_get_rxnfc, + .get_rxfh_key_size = enetc_get_rxfh_key_size, + .get_rxfh_indir_size = enetc_get_rxfh_indir_size, + .get_rxfh = enetc_get_rxfh, + .set_rxfh = enetc_set_rxfh, }; void enetc_set_ethtool_ops(struct net_device *ndev) diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf.c b/drivers/net/ethernet/freescale/enetc/enetc_pf.c index f050cf039733..59039d087695 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_pf.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf.c @@ -923,6 +923,8 @@ static int enetc_pf_register_with_ierb(struct pci_dev *pdev) static const struct enetc_si_ops enetc_psi_ops = { .setup_cbdr = enetc_setup_cbdr, .teardown_cbdr = enetc_teardown_cbdr, + .get_rss_table = enetc_get_rss_table, + .set_rss_table = enetc_set_rss_table, }; static struct enetc_si *enetc_psi_create(struct pci_dev *pdev) diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c b/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c index 3fd9b0727875..c346e0e3ad37 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c @@ -128,15 +128,15 @@ void enetc_pf_netdev_setup(struct enetc_si *si, struct net_device *ndev, if (si->hw_features & ENETC_SI_F_LSO) priv->active_offloads |= ENETC_F_LSO; + if (si->num_rss) + ndev->hw_features |= NETIF_F_RXHASH; + /* TODO: currently, i.MX95 ENETC driver does not support advanced features */ if (!is_enetc_rev1(si)) { ndev->hw_features &= ~(NETIF_F_HW_VLAN_CTAG_FILTER | NETIF_F_LOOPBACK); goto end; } - if (si->num_rss) - ndev->hw_features |= NETIF_F_RXHASH; - ndev->xdp_features = NETDEV_XDP_ACT_BASIC | NETDEV_XDP_ACT_REDIRECT | NETDEV_XDP_ACT_NDO_XMIT | NETDEV_XDP_ACT_RX_SG | NETDEV_XDP_ACT_NDO_XMIT_SG; diff --git a/drivers/net/ethernet/freescale/enetc/enetc_vf.c b/drivers/net/ethernet/freescale/enetc/enetc_vf.c index d7d9a720069b..072e5b40a199 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_vf.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_vf.c @@ -165,6 +165,8 @@ static void enetc_vf_netdev_setup(struct enetc_si *si, struct net_device *ndev, static const struct enetc_si_ops enetc_vsi_ops = { .setup_cbdr = enetc_setup_cbdr, .teardown_cbdr = enetc_teardown_cbdr, + .get_rss_table = enetc_get_rss_table, + .set_rss_table = enetc_set_rss_table, }; static int enetc_vf_probe(struct pci_dev *pdev, From patchwork Fri Jan 3 06:06:04 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Fang X-Patchwork-Id: 13925206 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR03-VI1-obe.outbound.protection.outlook.com (mail-vi1eur03on2088.outbound.protection.outlook.com [40.107.103.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A3D1A1B2183; Fri, 3 Jan 2025 06:23:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.103.88 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735885424; cv=fail; b=GP4ygaWRBYsir20JQIN9w194sWW4Ox+O6jmCpOPMKLfK3I5MD3dgRSTCDn1NKrdCcAtmWu4tYBJKlh4OWp1qP0O0lHc5siMPqvT79l/EAsskJ/u3jE9hOV/NS6uaBVNopEtM4k9FtX1rlymXnQr7NYz14m1GfjadPmxHajrzl2o= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735885424; c=relaxed/simple; bh=7rFRv+QFGSor6bou53ANciafI/s6SbREgrM8l7OQP8c=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=qHwPiEG/hmMCaBfgtuHlYw+x3VyhA0ktXoI3AhTJc1j4urRLdbeHzNBwP/6ojQQFdepHpzhsskA800K2Jvuva1yFatU93O2VYflqyp5i/iPnSMFrGCP5uRX/9MZW04J3MpH3KnUvLOtCsbube/YiY93nyuuoH1pWiZAZ8uvRbEo= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=LddhqLa7; arc=fail smtp.client-ip=40.107.103.88 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="LddhqLa7" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=VNPdM3U2cQt4wNzwBnvgUTn3v4zAB+3SdzgEkX+epFFXbSVO9+OvlW7LdBfWJWROYgyFAkQjdW2Khz0vIgRjCGjszCw9uzTpcDsHvEwByXCyJerQg1vT/Ov8fOe5qSXux1eBy4LT+RXl+EXxbTZL8rxQfVZ34WO3ycKahscxwBNPnBlm9hF5+cbiZHypOCnTLnZMwo1KT22tJrSmGhmC2v7LI0Hq+phMhsWcXws9wmiCZVUQprlZI9x483RjsySqbU3ZmtRio963GdXOA78SbjDmgy0AgKgOUEPQ/tvetyfxZ37zH7e+SEzdULFLeS5+96mgst0aDosycqrFN9yqkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=SKmbdyjlUOnASRV1UUrBtrrn//m7/BQBjZhIlweh76w=; b=Uw86rrG+90qFt1lECsBBInVVPh3yIaDEgjIRT6Aypp6XAXRGJbBy5d20tsRoMj63Ckn//nLr30jgPxnr9O3p1Yqer86CMmmwpXU6dGi5kFLd/ngwl2X85bZBUEWgreJUPhSi2p6fU6ZiKEoJ4LmyzGBrS+o/viokHxchUDJjUtnvQ0tIFpTsd0Didehfywu05bmayg7ar6A8m0y7gUTSBGK7fDlhI+sK9GJEcSHSFORIUilNnI8hO4nEWL0GpGXJFziLikwMwwtNulYDenqzqaqVm1wQwSJtbKUONWIWqA9XJnZE/ep5h+G/uPCzHUKl1MNs/dcmstnGyz0IElDyWw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SKmbdyjlUOnASRV1UUrBtrrn//m7/BQBjZhIlweh76w=; b=LddhqLa71Q1J/I5/UiyWMnIgQTBCNyACZ3VdXlihd5szeQ/D6ovZRYUOJgwzlkKrHNVQo9gCuKD+839eQTB2Q21s5vRDQBuQ5dzeIHAoYdTjha4j43j6wEixojx/98AxCV5O6nrDEq8sRonP5dcT/IUmyI+37CxxfIra4ArzW4AJ6Ps3bVe3BS+Cj9MVjUbIAhJxtwP2/XSpFUDOautJfiZsMp3g56HwxkEAFo0CFQyPx6NsRIlGvyzPr2CFbMUNExTkCBzPwiqIxIQ4P5ggSK6FtABNognhzP+WjD+uAHLRr9XUJJDmkbPXWwMofRwmQAdb/sEO8jGRYSSOwdo+QA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) by DB9PR04MB9331.eurprd04.prod.outlook.com (2603:10a6:10:36d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.12; Fri, 3 Jan 2025 06:23:34 +0000 Received: from PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db]) by PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db%6]) with mapi id 15.20.8314.013; Fri, 3 Jan 2025 06:23:34 +0000 From: Wei Fang To: claudiu.manoil@nxp.com, vladimir.oltean@nxp.com, xiaoning.wang@nxp.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, christophe.leroy@csgroup.eu Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, imx@lists.linux.dev Subject: [PATCH net-next 08/13] net: enetc: enable RSS feature by default Date: Fri, 3 Jan 2025 14:06:04 +0800 Message-Id: <20250103060610.2233908-9-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250103060610.2233908-1-wei.fang@nxp.com> References: <20250103060610.2233908-1-wei.fang@nxp.com> X-ClientProxiedBy: SG2PR03CA0127.apcprd03.prod.outlook.com (2603:1096:4:91::31) To PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8510:EE_|DB9PR04MB9331:EE_ X-MS-Office365-Filtering-Correlation-Id: 2064172a-1899-47df-ed00-08dd2bbf26af X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|1800799024|7416014|366016|38350700014; X-Microsoft-Antispam-Message-Info: EKyXHaR0n0tSiZioKvjc1PGJ8UoDdwNncuFbw1yE0Q4vKkzQblzE2DcZGTjs5Y4s+SUtsIPeXW3d6DkVUWVQ241/AbjUwQ3cOD90GYQzIH4M7YD2wPpFjtDBWpeF8HdNGPD/PI1hEtAjiJdObJKqgF0lxbie2OTZvvFwj10tQ2rExizZURhR6MyRY0K2RtnDYNQY74Uzc4BFGtGPTDHunCJbx5xV5iVU+qRvESlLnbfULMLXIWn707q/hOE70TWU8Mkum+NWwqspIiBOJkgED+unxRuD/ecPNxsDVHSLgrQtg4aln6q7oAUpvnZSVH0IPjkprPP3XhhKmWQbI46JZp/zHh9t8aR1FCPUCWxzE7RFrPbnX1riOkW+2ai+7w1ON7XlUEaOYFFaBD3Xpx7hmCX4bPuQs/orOTTPGxUASf+7xYOu9D+V1ZNslM5lDB5DlaU8GL40+rpNtSObEUo7117mrrdZ7mevp/nz1MuONPHzApEIXuNBCV+eQJ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:(13230040)(52116014)(376014)(1800799024)(7416014)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 8OVgjBIta+AVFL7JE7GpRlp42pL3nqqVTZZxo4ZDr6Bjy8xblB57MWN1LzC61gDBIG/er+zTNAFdriy0s+JE0ciV0P7RYIU/aRIKmZxDuhxvPtlTLqvMtUorpvdQzOVZXBBzwtRY5d3sXVCZCLtvO1WzpC2EK3NyX7ae57ve152d662tiD/5bwvTD+Uoqk4lV0X0Z88Xx3/gaHoODlw0TtKeIZSr7ieINXOFuUKh0ZILpDw7VwSi4bgpwWksG8GSOWyavgds/wy/1WLPLxhRh+Ht/hphQpfWqXr5lzVGgjvajWS3KaNYzbKkufV4g7Cc7pPE12rlmxK/k5y/R2BgIe5S8f1i68ea+PszNk5s73giBgnt6XrhJRhWgFYE2FDWMKfUVKnRpKAI9Fw7e6+KqKvSawG6B6HFvxam2zOEiClxzj8duAD2e+HVDlnvARb5HxVBSSLhk5TgnT/sGlWl7qXRwZKyiyRR+JPVkFIaUf5HUCpoY1X5eHwm2oRbyPaY2DBtribNCq0dBIPQofac3YZldV5/aP4h6dNTNk3Gs7cQaQJAKXFr2BYOI1V64bM5n+WHcUNCwsJeRlfgGwT7CdQOBCWv3VUUaf3PvBhnm5o0E7UL37g92c8Z58z39ibHRwWqk1/nkDlvBKGoFM+rXRdbzVJ13rpeVn3D1QbUhomPO1ZmpuFaI6TRWsB06TZkzqF8awOqzwc6x5fqxJ+MepBcKqlGaIGdmlpZ4QQ5ZaG3lv3epEMYVq4rFHCVYWMrQMiA0BttXDlqy1mwK0PM+LguG1/CReh6qgdjZ0p/o7KuTVx2zbkg5RoFGNpTrP4yCeKZ2Euv4h+HOsl3G2C1BEqo9IwME8uR+CGODkVjCtrbxNvKkEp8d2eqzZva/b2FrFcVWtvpAlf5bqZKhW6H+9qeZ31nCBIdxEblXdI+xYn0aB9ok/HTJLszUBihKn6rEHinERH4X3RExuxuV5FtqLnwwtEiDapbCLPufs/WUTwj1C9qWJz2Xe++dA4tY0nwSwxkZzlCjoiHBRfZELbO2PuZEchohsffikGeGTvaicMm25yDnqSRQ3gXzKqfAAG9d3ZbFry94S2Vj4wvPWp85M8is4fLPilBEl5pj8QrbOtKlXZYDNI4uPjgELSkmv97CwUWRoyBay6pvLvZ4pApfvsgqL3YCdvAzivNrHlc4pbDaBYLJC0a7Xbzxo3Cg8atHFp6NqYCEjZoLtmSNpPqEb0kmp14uK6gNSm0yAHHy5QnYQ57m8AIJ5lOj8w1PskKaLOAGxVKtxh3G9IeESpaKCaqP/JS9FKFGc7XkUs+AU5PMSGYmO9XaS2Gj+iu0FBUImDEvl0zW18oSgqTLwDmaAQzUj5Og6DHyUkal7O5r74F8q8XD6//HLSkX3k6I4XuMY33yFWhKhoz5aTQnAFp60GD07jOOIuXEj16zffnoi3nPxelCK/zNo2N3n14sUSWbLzfuUPGI9N1dMeSeY/ysb34Iu97BMn/TPizk00vO+gk6TgtDlJhsLEik+644Mne1qH8OuhGI8Lx5tbhJ+1vcczLaPs8019lYS4yUeKGGsXY+MbNpjC2mH0psbFnzx0o X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2064172a-1899-47df-ed00-08dd2bbf26af X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jan 2025 06:23:34.6351 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: BiJzmxKRC97dk7hSnfa+pqNSuDocSVZqd5x6oU14NIAv+82/vpjwSHtzasLy7x5Z5S/u9RzQX5dLWbO0ByYl7g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB9331 X-Patchwork-Delegate: kuba@kernel.org Receive side scaling (RSS) is a network driver technology that enables the efficient distribution of network receive processing across multiple CPUs in multiprocessor systems. Therefore, it is better to enable RSS by default so that the CPU load can be balanced and network performance can be improved when then network is enabled. Signed-off-by: Wei Fang --- drivers/net/ethernet/freescale/enetc/enetc.c | 35 ++++++++++--------- .../freescale/enetc/enetc_pf_common.c | 4 ++- .../net/ethernet/freescale/enetc/enetc_vf.c | 4 ++- 3 files changed, 25 insertions(+), 18 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c index 233f58e57a20..e27b031c4f46 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -2378,6 +2378,22 @@ static void enetc_set_lso_flags_mask(struct enetc_hw *hw) enetc_wr(hw, ENETC4_SILSOSFMR1, 0); } +static int enetc_set_rss(struct net_device *ndev, int en) +{ + struct enetc_ndev_priv *priv = netdev_priv(ndev); + struct enetc_hw *hw = &priv->si->hw; + u32 reg; + + enetc_wr(hw, ENETC_SIRBGCR, priv->num_rx_rings); + + reg = enetc_rd(hw, ENETC_SIMR); + reg &= ~ENETC_SIMR_RSSE; + reg |= (en) ? ENETC_SIMR_RSSE : 0; + enetc_wr(hw, ENETC_SIMR, reg); + + return 0; +} + int enetc_configure_si(struct enetc_ndev_priv *priv) { struct enetc_si *si = priv->si; @@ -2398,6 +2414,9 @@ int enetc_configure_si(struct enetc_ndev_priv *priv) err = enetc_setup_default_rss_table(si, priv->num_rx_rings); if (err) return err; + + if (priv->ndev->features & NETIF_F_RXHASH) + enetc_set_rss(priv->ndev, true); } return 0; @@ -3190,22 +3209,6 @@ struct net_device_stats *enetc_get_stats(struct net_device *ndev) } EXPORT_SYMBOL_GPL(enetc_get_stats); -static int enetc_set_rss(struct net_device *ndev, int en) -{ - struct enetc_ndev_priv *priv = netdev_priv(ndev); - struct enetc_hw *hw = &priv->si->hw; - u32 reg; - - enetc_wr(hw, ENETC_SIRBGCR, priv->num_rx_rings); - - reg = enetc_rd(hw, ENETC_SIMR); - reg &= ~ENETC_SIMR_RSSE; - reg |= (en) ? ENETC_SIMR_RSSE : 0; - enetc_wr(hw, ENETC_SIMR, reg); - - return 0; -} - static void enetc_enable_rxvlan(struct net_device *ndev, bool en) { struct enetc_ndev_priv *priv = netdev_priv(ndev); diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c b/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c index c346e0e3ad37..a737a7f8c79e 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c @@ -128,8 +128,10 @@ void enetc_pf_netdev_setup(struct enetc_si *si, struct net_device *ndev, if (si->hw_features & ENETC_SI_F_LSO) priv->active_offloads |= ENETC_F_LSO; - if (si->num_rss) + if (si->num_rss) { ndev->hw_features |= NETIF_F_RXHASH; + ndev->features |= NETIF_F_RXHASH; + } /* TODO: currently, i.MX95 ENETC driver does not support advanced features */ if (!is_enetc_rev1(si)) { diff --git a/drivers/net/ethernet/freescale/enetc/enetc_vf.c b/drivers/net/ethernet/freescale/enetc/enetc_vf.c index 072e5b40a199..3372a9a779a6 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_vf.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_vf.c @@ -155,8 +155,10 @@ static void enetc_vf_netdev_setup(struct enetc_si *si, struct net_device *ndev, ndev->vlan_features = NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_TSO | NETIF_F_TSO6; - if (si->num_rss) + if (si->num_rss) { ndev->hw_features |= NETIF_F_RXHASH; + ndev->features |= NETIF_F_RXHASH; + } /* pick up primary MAC address from SI */ enetc_load_primary_mac_addr(&si->hw, ndev); From patchwork Fri Jan 3 06:06:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Fang X-Patchwork-Id: 13925207 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR03-VI1-obe.outbound.protection.outlook.com (mail-vi1eur03on2088.outbound.protection.outlook.com [40.107.103.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2E3551C174E; Fri, 3 Jan 2025 06:23:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.103.88 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735885427; cv=fail; b=qux6qtk7Ez4OChHcXvl6PwrUxqQsmnxbUufWtGbome7lrVHenNacQ18bTeETn6B2Ir0p7iB4EY78mgUUGmr5u69eKALn20DdVk+M2KvtNf5umVVntmPLwcfAMCqoGdJxANND8SNaJtM0lBkZPluj4rPtfCP7TozaLODBjZyWItk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735885427; c=relaxed/simple; bh=I53O6bZp0ffnMWDFz38YY1xyCg4AfgxQo/D3qqhStCI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=lHWSTH62JjAJH8m47+SiccVRJaKOvsfl49OSQ0vh+U/scnNZnN8YkGnyZ9OsNfFqQzCtKrmLuCxHPaVZ777rqoDswLNCU8QPVGvmT+5evY7rgOkIdX+x46e1mJ6mLpK1LQ5pvJ6hQOGCFgFg7Xiq7voCQgTcuCbN4/cypcaX2/4= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=h3rvB4hm; arc=fail smtp.client-ip=40.107.103.88 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="h3rvB4hm" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=JXfkquVZQNNLKQ1WslJXBNcUtHG71Ls6ULNv0UYJEgc2ZhJLsV4FAAomGGQQfxFD76H1fwVSBHthTOz0M2hUXJxhI1PlmyCpnafTTB4wARKvO9rEv6Hv/HfThLDvcioJQ75HdO9GO/0C6YPua2At4d4Hv2wPkoES9u96httXWqNaIYVnTvs5n8QwKzVBuGKm23BSjR5rI7ywZ8CgsnWTW083RyfcSJARzk+HsBhsk9xjLtc0gJ90AfAsQ6UmduckYWOQB8X2Wt24BSll2LbTNAqy+5nI+f5VlQyo9ZgEyi4TxpCzHdHcGL1JXaWMTQjHl69Pt+xUc0vAvBBxMCy3SQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=9Eut/oSc+g1Go8gtsL2w0y3LR6sstdGSy8Cm6RIW0js=; b=nw8dKiD4eDW4YKKwtAWO8LTlriFwI8mNNsfsjOY2r5jfXoQVOHxjw9MNvGcafQojCKaqXwkEm9ikVuq48dw7SxSYJyUorzyOd+SW/xqxycEvPp6dmZ3PX4AM5Z/+LWcPtsSHAKLWzNVyM5cT3RKAD87IG3XeQNqqnlYs5AaAJWFkHanLrU5D84j4YJ3VeaDSLt4X42V2FqfDPTunPAVvcw85iEn8fUCm+3sf/WUE5/qVu+ZR8vuFbtK7pIHoHe3ZSM16UGEKI8iPmjkjjNaTD7z1KBgtU6OmfF2SJETPD3EZTb+L/k+YKlrRvzVYTe+sXRbGiqHNu+qiOVhivc5JGQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9Eut/oSc+g1Go8gtsL2w0y3LR6sstdGSy8Cm6RIW0js=; b=h3rvB4hmnEBpc67ekHmNNXrJgpnBGDRatfsVCIUmgASACn2VUZ9cqholf8DfRFAGaELjBQ5/bEFaKvSBKAF4YMuFIU3wgRgaJnAtDmzjYD4Qy17p+JFXEkOuRFdpTxSopCuJyP8rZbNoZUNyRYDegty+GiO/0Dogu8gVZycBQEqbdx4XpvfMOmXScF9XqrQI1lCn1xpnoKTcW6S3kCDuPqJAzcxLy2qYVeYRJhMoG3ctwruAdBQQMrwhJiAPmpUJ+qURrqFhH2v6fXpp4aiZ5FynZj87WUXzB2KrkQTPwhqllAtH8Cq2C/CpaXGCu0rlipNWWO5kuwk0c642gllaYw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) by DB9PR04MB9331.eurprd04.prod.outlook.com (2603:10a6:10:36d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.12; Fri, 3 Jan 2025 06:23:39 +0000 Received: from PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db]) by PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db%6]) with mapi id 15.20.8314.013; Fri, 3 Jan 2025 06:23:39 +0000 From: Wei Fang To: claudiu.manoil@nxp.com, vladimir.oltean@nxp.com, xiaoning.wang@nxp.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, christophe.leroy@csgroup.eu Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, imx@lists.linux.dev Subject: [PATCH net-next 09/13] net: enetc: move generic VLAN filter interfaces to enetc-core Date: Fri, 3 Jan 2025 14:06:05 +0800 Message-Id: <20250103060610.2233908-10-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250103060610.2233908-1-wei.fang@nxp.com> References: <20250103060610.2233908-1-wei.fang@nxp.com> X-ClientProxiedBy: SG2PR03CA0127.apcprd03.prod.outlook.com (2603:1096:4:91::31) To PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8510:EE_|DB9PR04MB9331:EE_ X-MS-Office365-Filtering-Correlation-Id: 467a6731-1647-44b4-3985-08dd2bbf294e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|1800799024|7416014|366016|38350700014; X-Microsoft-Antispam-Message-Info: //Zpj8AWbLfzMSm65y8+qvW9PpznK0+PQhE1KvK03OOnWkpeSVmrMiMD4Q87hkg6/s+XFrwOAgS+8L6pz/DqHeOTnAq8ISZ7/PVndzAUgQ/0LJnWPDtxAqloDRKqcond4tlqwLhUUzarZ76okXgxJ4zdJAWJR8gqJRBTVki0ZSM99umL92DH10voHk9nJWC0EfwUHA7hfV4uWvpAZ1KiXGPM0Zh8pJIINyHAqalBPK3VEYYzf2DIRGTyb/boM8qiNWaTX7kxPUeJDaXQPZI9B6NcIZIZpqj93x1C6YOCFog+7v3+U6QLann4gTQlQGBFG57sHAdoYv5wiY1b5L/Om+SeyZdNqZZOhFpkrxPG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WLr6R8TBYKtlSr/cDLHx2hz9otpTqKGXQ0a X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8510.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(376014)(1800799024)(7416014)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: syf3i25/DVCfNlJ1a/Or9x2mtqh5UDZ2C6kK4kKjXoWT2iAHk90uYQhZxC8yH7HUuf7FyXljPtcKkWkQRYXFVkJh2rWUzHlwA7BFW49tQKwZZ0+4barpg/HKxtiYUMsYuUPvPajUIK8ovrEwRqpohR3SrGNbiNOE8P35sBUbcz6ZCj+Lx9fUvwYx6IJ9QH8YZYa0TcVsXiKZx4ON3I0LRphzfCq4SHcAEdJNHZaLfH0czZVxQDfCMyDMw1Uu7W+ODQWhEtbOsR28udQhOSM4QqdXZX2zhqM2ZcVMR2oQXSjMQrJeOrHOf43MQGJFcvyAgwhRKxWyMYOsv4jfKbJHLWH4LMRLykbchKHBZgv/4W37dOs2Bj6kJiu07RUQkJJl3T7Ki4PF14puFI3DZef5+BnIbdpZA+Rn9pd5Ws+7HTIjF+ruaJ7aFjSks8GvJDlkTiEvdjhTVP3xWiceA2R2xIjYVSzTHa9b1kBmBx8nUEV4GtEuw2SH+Z0GtF0hs97ibqy/JqQZpY0ER3YIR1cGdimTYbucEvthA+clKk3UpE3BtZCxlWQg4chcQCVCZfGpIDrLZeOq0qnZlCL+ZxY7ZzXyzOkH9VbzW+ZeXAvNSVAurlM5vLyVgOgoyCymWVL03lmD+EEONbkUntc3/dfVA8XVfMA8mQNQKzMuUtrLFUQqZQ6+EBrnZv1g7LlfYePVjHX37rnY9J8bvpLjcVnkAe7AeaZYy3hcdsMg7ZcCQ3gCJUen6SenkoYjyKpFHKyuwl9bMye9SqES7s4ojuONOjvVvS9oRnDTIEhfHlN3yhcw+we2jE0qSPd7bpVB0YZSf30w5Jdix6WXpnPnBJ0t2GOavfcf301jMQ3GFdde+cpwYePfTIbQ3/uqilqtLoozbMYhNn76B4T7cCxnOixhsh9ylYkPfQP61B9u1JxvBUDC2YIMPWg6zC/gjC2PqSjAK08H0LLkau5gszE7BrXmRV7K+5Sqs0CHIyzpY1b95uHwXLxWyNAj1zkvWCGSEc9cOLGF9fBS6ftaObE6ZlbF23c/H38WOg0shvm4o5Lc3tBi2l1f1cCiOil5LQixLAJgQCw/SIxdGd5EDhEvEh4YW0MMjqpohAxfmAABstXMMgSejsDoIOobqRxktU5vL75DXnI1KIqNAx/f92FCyUWEexwNgyb6rVqO/7dUw8iBPZjLRLu7nwh/movFu7FgvBc1JYKLKrdxcwzmA9eyq4GVuMKBuk1RFEI1EG/ZwVh6gGyOrw2+p7DIh5G5/hYV4C/fLJtu8g1a7W1Nx6IguSWfHuwQBkp/JQCwlxbeCoFpHblSuABZU6kne1zXBI1rScyum2vPT4O5pvmCIHLL7/z5FNaxhJs5Ayid6PYKbX97WC69C9Pda2wYDBymh+WHBVMMzQP5mp0f5yY4Z6inLNnTysnFWQYejJpOvJoAOWhncDNOIV9gG2wQnsi9d9szQZ1NyM1RqDX/DUsUS8n+97lM+e28RDkP9LeN2LMQdEG3MJk/VAi7Vt//4kohdgFE44JtRxzIxm669MMHjmSLhoWpeZqHEssEeYPGAdwfyOW1B9Mq3ZL8Yu7hHIAeMC5QNE5R X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 467a6731-1647-44b4-3985-08dd2bbf294e X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jan 2025 06:23:39.0409 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 35x5gljgss/Z9rfwW7x6pro4vi25ENKo3r49yCVToWR9G7Z/BWa0Zr+5UqJJPvgv7L9WZ6kjzSEUyKgTqrOwYQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB9331 X-Patchwork-Delegate: kuba@kernel.org For ENETC, each SI has a corresponding VLAN hash table. That is to say, both PF and VFs can support VLAN filter. However, currently only ENETC v1 PF driver supports VLAN filter. In order to make i.MX95 ENETC (v4) PF and VF drivers also support VLAN filter, some related macros are moved from enetc_pf.h to enetc.h, and the related structure variables are moved from enetc_pf to enetc_si. Besides, enetc_vid_hash_idx() as a generic function is moved to enetc.c. Extract enetc_refresh_vlan_ht_filter() from enetc_sync_vlan_ht_filter() so that it can be shared by PF and VF drivers. This will make it easier to add VLAN filter support for i.MX95 ENETC later. Signed-off-by: Wei Fang --- drivers/net/ethernet/freescale/enetc/enetc.c | 25 ++++++++++ drivers/net/ethernet/freescale/enetc/enetc.h | 6 +++ .../net/ethernet/freescale/enetc/enetc_pf.c | 46 +++++-------------- .../net/ethernet/freescale/enetc/enetc_pf.h | 4 -- 4 files changed, 42 insertions(+), 39 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c index e27b031c4f46..8b4a004f51a4 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -72,6 +72,31 @@ void enetc_reset_mac_addr_filter(struct enetc_mac_filter *filter) } EXPORT_SYMBOL_GPL(enetc_reset_mac_addr_filter); +int enetc_vid_hash_idx(unsigned int vid) +{ + int res = 0; + int i; + + for (i = 0; i < 6; i++) + res |= (hweight8(vid & (BIT(i) | BIT(i + 6))) & 0x1) << i; + + return res; +} +EXPORT_SYMBOL_GPL(enetc_vid_hash_idx); + +void enetc_refresh_vlan_ht_filter(struct enetc_si *si) +{ + int i; + + bitmap_zero(si->vlan_ht_filter, ENETC_VLAN_HT_SIZE); + for_each_set_bit(i, si->active_vlans, VLAN_N_VID) { + int hidx = enetc_vid_hash_idx(i); + + __set_bit(hidx, si->vlan_ht_filter); + } +} +EXPORT_SYMBOL_GPL(enetc_refresh_vlan_ht_filter); + static int enetc_num_stack_tx_queues(struct enetc_ndev_priv *priv) { int num_tx_rings = priv->num_tx_rings; diff --git a/drivers/net/ethernet/freescale/enetc/enetc.h b/drivers/net/ethernet/freescale/enetc/enetc.h index 2b0d27ed924d..0ecec9da6148 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.h +++ b/drivers/net/ethernet/freescale/enetc/enetc.h @@ -24,6 +24,7 @@ #define ENETC_CBD_DATA_MEM_ALIGN 64 #define ENETC_MADDR_HASH_TBL_SZ 64 +#define ENETC_VLAN_HT_SIZE 64 enum enetc_mac_addr_type {UC, MC, MADDR_TYPE}; @@ -321,6 +322,9 @@ struct enetc_si { struct workqueue_struct *workqueue; struct work_struct rx_mode_task; struct dentry *debugfs_root; + + DECLARE_BITMAP(vlan_ht_filter, ENETC_VLAN_HT_SIZE); + DECLARE_BITMAP(active_vlans, VLAN_N_VID); }; #define ENETC_SI_ALIGN 32 @@ -506,6 +510,8 @@ int enetc_get_driver_data(struct enetc_si *si); void enetc_add_mac_addr_ht_filter(struct enetc_mac_filter *filter, const unsigned char *addr); void enetc_reset_mac_addr_filter(struct enetc_mac_filter *filter); +int enetc_vid_hash_idx(unsigned int vid); +void enetc_refresh_vlan_ht_filter(struct enetc_si *si); int enetc_open(struct net_device *ndev); int enetc_close(struct net_device *ndev); diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf.c b/drivers/net/ethernet/freescale/enetc/enetc_pf.c index 59039d087695..c0aaf6349b0b 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_pf.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf.c @@ -222,45 +222,18 @@ static void enetc_set_vlan_ht_filter(struct enetc_hw *hw, int si_idx, enetc_port_wr(hw, ENETC_PSIVHFR1(si_idx), upper_32_bits(hash)); } -static int enetc_vid_hash_idx(unsigned int vid) -{ - int res = 0; - int i; - - for (i = 0; i < 6; i++) - res |= (hweight8(vid & (BIT(i) | BIT(i + 6))) & 0x1) << i; - - return res; -} - -static void enetc_sync_vlan_ht_filter(struct enetc_pf *pf, bool rehash) -{ - int i; - - if (rehash) { - bitmap_zero(pf->vlan_ht_filter, ENETC_VLAN_HT_SIZE); - - for_each_set_bit(i, pf->active_vlans, VLAN_N_VID) { - int hidx = enetc_vid_hash_idx(i); - - __set_bit(hidx, pf->vlan_ht_filter); - } - } - - enetc_set_vlan_ht_filter(&pf->si->hw, 0, *pf->vlan_ht_filter); -} - static int enetc_vlan_rx_add_vid(struct net_device *ndev, __be16 prot, u16 vid) { struct enetc_ndev_priv *priv = netdev_priv(ndev); - struct enetc_pf *pf = enetc_si_priv(priv->si); + struct enetc_si *si = priv->si; + struct enetc_hw *hw = &si->hw; int idx; - __set_bit(vid, pf->active_vlans); + __set_bit(vid, si->active_vlans); idx = enetc_vid_hash_idx(vid); - if (!__test_and_set_bit(idx, pf->vlan_ht_filter)) - enetc_sync_vlan_ht_filter(pf, false); + if (!__test_and_set_bit(idx, si->vlan_ht_filter)) + enetc_set_vlan_ht_filter(hw, 0, *si->vlan_ht_filter); return 0; } @@ -268,10 +241,13 @@ static int enetc_vlan_rx_add_vid(struct net_device *ndev, __be16 prot, u16 vid) static int enetc_vlan_rx_del_vid(struct net_device *ndev, __be16 prot, u16 vid) { struct enetc_ndev_priv *priv = netdev_priv(ndev); - struct enetc_pf *pf = enetc_si_priv(priv->si); + struct enetc_si *si = priv->si; + struct enetc_hw *hw = &si->hw; - __clear_bit(vid, pf->active_vlans); - enetc_sync_vlan_ht_filter(pf, true); + if (__test_and_clear_bit(vid, si->active_vlans)) { + enetc_refresh_vlan_ht_filter(si); + enetc_set_vlan_ht_filter(hw, 0, *si->vlan_ht_filter); + } return 0; } diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf.h b/drivers/net/ethernet/freescale/enetc/enetc_pf.h index 916818d2fdb5..d56b381b9da9 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_pf.h +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf.h @@ -6,8 +6,6 @@ #define ENETC_PF_NUM_RINGS 8 -#define ENETC_VLAN_HT_SIZE 64 - enum enetc_vf_flags { ENETC_VF_FLAG_PF_SET_MAC = BIT(0), }; @@ -54,8 +52,6 @@ struct enetc_pf { char msg_int_name[ENETC_INT_NAME_MAX]; char vlan_promisc_simap; /* bitmap of SIs in VLAN promisc mode */ - DECLARE_BITMAP(vlan_ht_filter, ENETC_VLAN_HT_SIZE); - DECLARE_BITMAP(active_vlans, VLAN_N_VID); struct mii_bus *mdio; /* saved for cleanup */ struct mii_bus *imdio; From patchwork Fri Jan 3 06:06:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Fang X-Patchwork-Id: 13925208 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2050.outbound.protection.outlook.com [40.107.104.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EEBCA1C2304; Fri, 3 Jan 2025 06:23:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.104.50 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735885432; cv=fail; b=CrOCNd7nQUy0EXRKGnCf/4O/h5SXjfCyX833Iil8kY/ynDEI8xYp8xE9WPqAnjFW2BVZGRS8jkz2sHdw6Pv6YNZvWCzzxmzmmzMeGBZwl+nBVM58gqC7r9T51g7VUR01fJcjCQqql8VW8HdqQLSlqOW5/6HOPNoWF+jNijLlKCE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735885432; c=relaxed/simple; bh=Bnou1bbhVRNe+Bh8EnXhERm+89rQi68IDBnMUQdUVB8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=fauUmgx1017dq0fly79T6Tig4Qq5+e/DcqUmR1R01Ke66WioGMXRuGu6Wn41mwbmz1u+Xa2AARCrLRXRpi4FYCqEMvBcjmdjL8/L/GZWILIi14bXwbgzWV6GK75U69F6P4asXtDecevRlv+k7V4V0ZoAPYudR0+BRlUjXJ5Iypo= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=K+/tBl8y; arc=fail smtp.client-ip=40.107.104.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="K+/tBl8y" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Sd2DSKmcMOT/+etBKuV6Cayc75SwlUE52UpkY1Dgvxilqb9unDNaZWK+3KsUEL96FfcTHAWevvL29Mib+1pgbH+tzeq+gYlmhahoIvrSDkV7FTQhxbgxw1xo+ZwCFwuOsTw+I7oyQN2uEyV/q5wBBn0qgPSccmI2goquyHhIxL+2FhYEXdCKr8WtMzBD17v61YKiM3by4sY+285Cg5nNlGu1HHUuY3kyX8SxhiihP4k3auhCj3ONB3uHNKZ2TIjG0bvCbIZB1fd9lB60la8Xh8XiXIN3pIMqLUy2/LrLAOD9MwaHE0f3an/1SwoZ7h/gt5TybJuc3FjuUNVIsEMYQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=IvI+Qtevc4/gpebHs+HCKRERnuaKPkBcj1HPAJ3Rn4A=; b=QWdNRrnI2QSGccKYg0KEYWVQ/xeZEdaArH/uAIaLOLVJOIOCufPs9v9NIFyI6bcrAhU7L1UdOPWE6FIedUcayz6RfgTYKjryJdzUcgkUCQLP9CoacF8kihK6/w83xXt39e7zuhvsHlIn1HmP/eWXOnXxTka/Fh4xVxfpUJ8U0M6lpWSogsbLzr1hb3e1FmQCYT9KsHdHpqcNzH1CTH+v721vnf7vkxhXZxlunDMouOYSRl1HOKusWkEI3vLJlyPOpAd6qoXGxgQV5HmpJnO5r3XsdjyKQExI4RpK90CrbxEr1qqwRMw5CEDLSiLaIoWgX5EDE/og3q5Sbcmuyq1yCA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IvI+Qtevc4/gpebHs+HCKRERnuaKPkBcj1HPAJ3Rn4A=; b=K+/tBl8y6fT9OGkSASLqdDDqU1tJEAg3vhel4w28NjVrdQl1KIqRKW8TJqeaO3XpydxyCBzLH4Qr37fsSFr0ZQwMxM3mIIxJxZo2y54Pw77RIXVSZFLkTslfs0o4uFVJboU+yMsU/fi56p76m9JzJBobDRldsuTM9cBeE2ZmcEGNEAR+HZnpG8MOTu7iY0CZZPnjUaEpRajs6mt7oRlXl3v853f0hWuovC+JsTiOUr6IBKTYqWyx5rDg7KvXDhP9Q3+NTV3r4g2dT6pR9RMkRYRFH8Jylzl/ZGFPFHQIrPRmJRfsNffLg0nl8qdLLlAfvWl37VhrYa26S8F3kmmzXA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) by DB9PR04MB9331.eurprd04.prod.outlook.com (2603:10a6:10:36d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.12; Fri, 3 Jan 2025 06:23:43 +0000 Received: from PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db]) by PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db%6]) with mapi id 15.20.8314.013; Fri, 3 Jan 2025 06:23:43 +0000 From: Wei Fang To: claudiu.manoil@nxp.com, vladimir.oltean@nxp.com, xiaoning.wang@nxp.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, christophe.leroy@csgroup.eu Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, imx@lists.linux.dev Subject: [PATCH net-next 10/13] net: enetc: move generic VLAN hash filter functions to enetc_pf_common.c Date: Fri, 3 Jan 2025 14:06:06 +0800 Message-Id: <20250103060610.2233908-11-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250103060610.2233908-1-wei.fang@nxp.com> References: <20250103060610.2233908-1-wei.fang@nxp.com> X-ClientProxiedBy: SG2PR03CA0127.apcprd03.prod.outlook.com (2603:1096:4:91::31) To PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8510:EE_|DB9PR04MB9331:EE_ X-MS-Office365-Filtering-Correlation-Id: 9eb0faf6-def3-485f-7104-08dd2bbf2be0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|1800799024|7416014|366016|38350700014; X-Microsoft-Antispam-Message-Info: JVxr+VXmUMr1CS/u4IAnG1hnMwC5uJZ6CGFeQOGXF/QjaZ7ch3DxIisKe1OGbRTmn4SDyM1Bf5dJW26Z559mTxWVmRfAxhmBGdl6GShcrRlutorC7zMFfCEr4FRjkeu83NhhqzEEnUMo2JQtWa/IP9iDkuBEqRNjma0RpWveFJM8pnBj3yw9rrnRrUAvpSV9kYT07cLL7PaBYsW5Sb+LdI+sfAhLZwey7rDUvosVEFsfmuu8Pv0tHuKjGUslFNpEqNbYKGPLVGTnVEyDBo89MXf4UtP7lWZZ6w+8jYa4cjasoXGRmIUeQA1kPwOKL2vqvDD0hlHH5hPTAe1raKN8y3pcZAtrrntJKImd0ZNJ+be517Jd8ynQUoZPpHQCJ1dDfywe8rBgBzXs/xqZCJ9UrN8dzUr0rcI+ppZQ206Vq2Ag3Q4bOd3BPOb82TWlO6TQzG66gornv74ptJkmVTiSfVbmn+WSB1+mOyXNiDUC0xxUUWWYVmwyZ8w7nVC5jz4Pxs30OSCTHefr2sLeJNC6Ev8Y88W3sfuslmiDaybAgw8dbBwFs/am7kHqrzYumbMzDl/KNUYW2hqeu0zKwa/xiqp+aaImme5bJAvwiCcDXcr8sCjVG9scRE4N6bJlVLOvwBu3Ho2LcS49koaa4NYp1twM+nsnevHY7Q1ErNRXOuFU5VNPWe+uQdDc++2WrJbVmQlFcOmUgFdWtQSaOu4Kmvo1W0MNPl9x/er+y2uG/uivpLv0H1NgTRVXzncW0aeMfZFoEmitUq/K3OOH8zVFF3zQhl3fl5r5/cIATOKQ6RnlS0JyvSJE2kvEXulDG9eOz/HZciGhlNfNY6QzSeVqpwWIRxE+GuNnCpdpM3Y5zKgrkfXPSOfXUnDerUCirkiLcTeOfBCYBtj8cYuYBnlOQn8mMOlSQOrZkIo3LdyqyT7czYHvFw0Gtb2m0b9XgFPw9ROgUleDRJ8LsPPuLrCPAUHb84Px+k29IcBYLPjxORDzJF/dW4iacwbZA7zFlgxYzI51eDYl3X0yQyP2mSqJFuC2jpl4BsKnmoA261HZkItFu/PT5rUBrjP2LWIvc6pP9cHXZU34zpGr6ja/QcSPQOIa/rrtN+pLu1w/ghxYZE/natoLCckk0Th2YVBFK+HeUmt2h9sVKYYNBEUtSUkyIF1bpmSiXKITM0Qlzk55NbSygo/QIgR754PSDbbOEiX8b5/QI3vud5VXq2I79/NO91vxnnG56tkqH9J8zk7VFExL0ZMjlpVyBHopEgmR/NBI/7S4p9pY4ibfFZNtvWoY/zaoRGuH3H9hwvw0qmq05cHpM10xGa4ecMUZK34Lx62mrAsRjC5Vki1ukqR0Sx4mvVRDNadqGI/WrYe3d4pRiI0QYzbqZaF2y2eT/jbVeI+jndltMuaODPOkGaw/a6oL1t5j8+XKkXfa6Qg+B9teaPSkqWIzyllyhDBm6vMwCtw7 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8510.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(376014)(1800799024)(7416014)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 3c+uDYh8ZQ9GR1dwOlnxEcz9LFx98150ThwjmUbH6ji9c3sqRpTjq4juXUuLwv6+RMK/hB8H66qEVoE0x0Mo6jFFQ5viSi25ah167x41NZ2UUJNCK8TU4jADaNd8fTRh9ZByK2NW9SHD3r3aDz3y55OuA3y0CFG6pm9Nc+b7VPh6WfBeBuzbKg5XqzQPHOKi8oLBtVZ+ssrpIR8JUwTjx6hz8mRCWHn0ynm5LHjeMe4iFGd+O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KnCxlNMBQADPQzntj9y/gFIlld/kvtbEE95M9wGAVmmQ95TAx6Xpsfa+qRX+tocvRxYOQCiLWHbGUIUsAyG97MXmVR56Z81FXHvcESkqmAa1g4VbI2zIPSwV7qPKE9dYkKt1UlChzWCGEWFHbBHilKScu3jzGaqnAm5j5McdkwJOylSnFW0KMymCpfoPXvusci+UM9PhIWcBZMvjKlZEjypT2OEEEHrPHlLLYbHkdHJDBOHFv7VGQ/AVKr7Pgq85o8nm0kJan6s90KosU32 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9eb0faf6-def3-485f-7104-08dd2bbf2be0 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jan 2025 06:23:43.3493 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Ce2urAadZq5RbtlAcsM0ObLNMNq3dudQtK59XJ15GCvLGf86YdD3FeIMKL8cbCd57WDQn0ldkId8/bTL97CncA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB9331 X-Patchwork-Delegate: kuba@kernel.org Since the VLAN hash filter of ENETC v1 and v4 is the basically same, the only difference is the offset of the VLAN hash filter registers. So, the .set_si_vlan_hash_filter() hook is added to struct enetc_pf_ops to set the registers of the corresponding platform. In addition, the common VLAN hash filter functions enetc_vlan_rx_add_vid() and enetc_vlan_rx_del_vid() are moved to enetc_pf_common.c. Signed-off-by: Wei Fang --- .../net/ethernet/freescale/enetc/enetc_pf.c | 34 ++----------------- .../net/ethernet/freescale/enetc/enetc_pf.h | 1 + .../freescale/enetc/enetc_pf_common.c | 34 +++++++++++++++++++ .../freescale/enetc/enetc_pf_common.h | 2 ++ 4 files changed, 39 insertions(+), 32 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf.c b/drivers/net/ethernet/freescale/enetc/enetc_pf.c index c0aaf6349b0b..d9c1ebd180db 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_pf.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf.c @@ -215,43 +215,12 @@ static void enetc_pf_set_rx_mode(struct net_device *ndev) enetc_port_wr(hw, ENETC_PSIPMR, psipmr); } -static void enetc_set_vlan_ht_filter(struct enetc_hw *hw, int si_idx, - unsigned long hash) +static void enetc_set_vlan_ht_filter(struct enetc_hw *hw, int si_idx, u64 hash) { enetc_port_wr(hw, ENETC_PSIVHFR0(si_idx), lower_32_bits(hash)); enetc_port_wr(hw, ENETC_PSIVHFR1(si_idx), upper_32_bits(hash)); } -static int enetc_vlan_rx_add_vid(struct net_device *ndev, __be16 prot, u16 vid) -{ - struct enetc_ndev_priv *priv = netdev_priv(ndev); - struct enetc_si *si = priv->si; - struct enetc_hw *hw = &si->hw; - int idx; - - __set_bit(vid, si->active_vlans); - - idx = enetc_vid_hash_idx(vid); - if (!__test_and_set_bit(idx, si->vlan_ht_filter)) - enetc_set_vlan_ht_filter(hw, 0, *si->vlan_ht_filter); - - return 0; -} - -static int enetc_vlan_rx_del_vid(struct net_device *ndev, __be16 prot, u16 vid) -{ - struct enetc_ndev_priv *priv = netdev_priv(ndev); - struct enetc_si *si = priv->si; - struct enetc_hw *hw = &si->hw; - - if (__test_and_clear_bit(vid, si->active_vlans)) { - enetc_refresh_vlan_ht_filter(si); - enetc_set_vlan_ht_filter(hw, 0, *si->vlan_ht_filter); - } - - return 0; -} - static void enetc_set_loopback(struct net_device *ndev, bool en) { struct enetc_ndev_priv *priv = netdev_priv(ndev); @@ -971,6 +940,7 @@ static const struct enetc_pf_ops enetc_pf_ops = { .enable_psfp = enetc_psfp_enable, .set_rss_key = enetc_set_rss_key, .get_rss_key = enetc_get_rss_key, + .set_si_vlan_hash_filter = enetc_set_vlan_ht_filter, }; static int enetc_pf_probe(struct pci_dev *pdev, diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf.h b/drivers/net/ethernet/freescale/enetc/enetc_pf.h index d56b381b9da9..7a0fa5fba8bf 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_pf.h +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf.h @@ -39,6 +39,7 @@ struct enetc_pf_ops { int (*enable_psfp)(struct enetc_ndev_priv *priv); void (*set_rss_key)(struct enetc_hw *hw, const u8 *key); void (*get_rss_key)(struct enetc_hw *hw, u8 *key); + void (*set_si_vlan_hash_filter)(struct enetc_hw *hw, int si, u64 hash); }; struct enetc_pf { diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c b/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c index a737a7f8c79e..9f812c1af7a3 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c @@ -343,5 +343,39 @@ void enetc_phylink_destroy(struct enetc_ndev_priv *priv) } EXPORT_SYMBOL_GPL(enetc_phylink_destroy); +int enetc_vlan_rx_add_vid(struct net_device *ndev, __be16 prot, u16 vid) +{ + struct enetc_ndev_priv *priv = netdev_priv(ndev); + struct enetc_pf *pf = enetc_si_priv(priv->si); + struct enetc_si *si = priv->si; + struct enetc_hw *hw = &si->hw; + int idx; + + __set_bit(vid, si->active_vlans); + + idx = enetc_vid_hash_idx(vid); + if (!__test_and_set_bit(idx, si->vlan_ht_filter)) + pf->ops->set_si_vlan_hash_filter(hw, 0, *si->vlan_ht_filter); + + return 0; +} +EXPORT_SYMBOL_GPL(enetc_vlan_rx_add_vid); + +int enetc_vlan_rx_del_vid(struct net_device *ndev, __be16 prot, u16 vid) +{ + struct enetc_ndev_priv *priv = netdev_priv(ndev); + struct enetc_pf *pf = enetc_si_priv(priv->si); + struct enetc_si *si = priv->si; + struct enetc_hw *hw = &si->hw; + + if (__test_and_clear_bit(vid, si->active_vlans)) { + enetc_refresh_vlan_ht_filter(si); + pf->ops->set_si_vlan_hash_filter(hw, 0, *si->vlan_ht_filter); + } + + return 0; +} +EXPORT_SYMBOL_GPL(enetc_vlan_rx_del_vid); + MODULE_DESCRIPTION("NXP ENETC PF common functionality driver"); MODULE_LICENSE("Dual BSD/GPL"); diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf_common.h b/drivers/net/ethernet/freescale/enetc/enetc_pf_common.h index 48f55ee743ad..253310859ca1 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_pf_common.h +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf_common.h @@ -12,6 +12,8 @@ void enetc_mdiobus_destroy(struct enetc_pf *pf); int enetc_phylink_create(struct enetc_ndev_priv *priv, struct device_node *node, const struct phylink_mac_ops *ops); void enetc_phylink_destroy(struct enetc_ndev_priv *priv); +int enetc_vlan_rx_add_vid(struct net_device *ndev, __be16 prot, u16 vid); +int enetc_vlan_rx_del_vid(struct net_device *ndev, __be16 prot, u16 vid); static inline u16 enetc_get_ip_revision(struct enetc_hw *hw) { From patchwork Fri Jan 3 06:06:07 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Fang X-Patchwork-Id: 13925209 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2060.outbound.protection.outlook.com [40.107.105.60]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 51A991C330D; Fri, 3 Jan 2025 06:23:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.105.60 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735885436; cv=fail; b=pmG5FnC5oPHOaFhJptITN86BgZF0Ij3RDZpyk7E7XuAuwNcT5nMcv2+GOVHvrjw7DFwfJErtnjLwkrvzsYCJBnE6BYmZWdRk+9M6aOCpj/f5gd5C6/9TPLU7F7oS6it2bcLtTLKnS4KkTzN7mppYwyamNUR+dBViPpPkb3o8niI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735885436; c=relaxed/simple; bh=GGYFRo21NlULNAFyhFLdNJIlzx4Om2wI8RgQRWfykmw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=QMVgIMJ6W3z0lb7cSdrVYOFXoB1rhtArdI6+QBf8bl5qcxvHHDKWXfXJ7kvfWZY8VaRhFf7m/tdxX74Mr5ZzWDjUzxCZZuvPHlDHqU2Rfj2xwyXVLZF4o+mR7WKO7L0rH6QbCyb1pKlH349/OOy9bqi9lVvxMzoMBFJFUl/gwW8= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=HeChS4jd; arc=fail smtp.client-ip=40.107.105.60 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="HeChS4jd" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=VR8iYVsr7Y6kdldQF5H1H4SGH93lqtnidxpqK4Acy+W3n8Q0jRg+f0NW+sNUMDPfs9Gf2RsSho3pP9CdTgUIBItO1WVhZNWp3yFX/aBi9r2aP5LFxBXJJceImdWPmpQho0ZT6L8k0C9S9AatILSWY1m0nEvLnF1babXEkTv+v406dw9jEquTYeRdzUGg5bKGIsI78FeZ8jfrqHX8AUakV30WhqHxHQkpX68RgxyRiekMQBskpqL9vA9Y9QLSJUaENcceuG4/Kl7B/HyN5D7F6iL698zvBlUUPeGNse80Js1Kr9mOukZ+xZpvb+/Er4aJjjWQp8eIJlh2/SUiomiqJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=CX2D655hcMFUyMvofunkFGwzwcuxYlVeeLQenY9dSqA=; b=lJF9CmgT9331/xLIXM1XrGEZOYr9Qxj0O0wDESE4uja5dRxg+CqLf+iRJSu5F7qbbXnVbj/r82GN7KSH69irbkXkeZfxqmLYThF2Uyzoso+MORym3m25/Ilj647CoKLqAzY0DEqK4mYUdcVs+RHjJBzY8diTnlAHCZnDEKqSFm2imLqPG9xLCZNDQ02U1kSeGU1X8KSvfYoIwDiax+dFJvAkvfJjbJ4NWSLo3H74xJxWqaIyp4POp4azHqYESbmQS1f+Anvdu3yuE/8bwOnBCDG1I2LUeBn5+y1I+zOug4F+NnmJtef1iE6h5bzDmQ0sf/AzL7Ksy/+vQsgSzdz8Og== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CX2D655hcMFUyMvofunkFGwzwcuxYlVeeLQenY9dSqA=; b=HeChS4jda+Yqtiu53R0eeKBGaZTP/F2qL1HBdovaCDxjG0aXwHa5OsZ/eGePZGH6O8J9jVPDdYTt+M+mpI72iS5gF73ry2mAkP40zRmJ3nC1CeGAMr2qwKCM4jpPAHGEht5CswaTE2CCJifd3lsNMcvDM89hy1Bcrs9V46d3rPvTOEYlxGz8q8LEFGNvtFqji7o8y5t5Rz1VQS8PTOxkoNWA0HorX9awHNmvsOJV/USn7KWfmXX39sHxQv8L8wyLBbGAls0l507ccawLmNsmFi9kzoPiJzjxMLjGDBV/TZzJs4MawsvKmEzKq0psOyYN26xV9FjFc6aRhoo6TP08ag== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) by DB9PR04MB9331.eurprd04.prod.outlook.com (2603:10a6:10:36d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.12; Fri, 3 Jan 2025 06:23:47 +0000 Received: from PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db]) by PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db%6]) with mapi id 15.20.8314.013; Fri, 3 Jan 2025 06:23:47 +0000 From: Wei Fang To: claudiu.manoil@nxp.com, vladimir.oltean@nxp.com, xiaoning.wang@nxp.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, christophe.leroy@csgroup.eu Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, imx@lists.linux.dev Subject: [PATCH net-next 11/13] net: enetc: add VLAN filtering support for i.MX95 ENETC PF Date: Fri, 3 Jan 2025 14:06:07 +0800 Message-Id: <20250103060610.2233908-12-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250103060610.2233908-1-wei.fang@nxp.com> References: <20250103060610.2233908-1-wei.fang@nxp.com> X-ClientProxiedBy: SG2PR03CA0127.apcprd03.prod.outlook.com (2603:1096:4:91::31) To PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8510:EE_|DB9PR04MB9331:EE_ X-MS-Office365-Filtering-Correlation-Id: a53bc9f4-c8db-4000-7dc5-08dd2bbf2e7b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|1800799024|7416014|366016|38350700014; X-Microsoft-Antispam-Message-Info: c3nqkw5YCeOeT7nS0BnV7JPLTCYl7gsIUqZ3ne+oK1CRwkCkJFXpPEnu0yBxjk55dvysFetqoJj8qLbm4cYTMxea6WVmUSHrsr7nQoIKS1Cg1xY3h8dx0ItHXlmV0pHKLh8bb2dSbfkbPxuEm1GqICsZl5OClVU4rK6497WdN+vQr8wU+ZXjxhOItnTVbF/TbHiXLtqLakO94h81/WSjmME1qV6hnDP66Zk3TngYCzTiA9Is8CWDoAR3eEYcaj+t2tNAXgCfDodMsi+JelL/FltERpMZ6jZBwCkSNWpD3jDJ1Xv1luo8wQiClH6dZeIwI9sVuhueQ9WR398tAZZdGb1ALpSzLkXGPzXq9s+p14NhXI1OslkyRUKv4v1PROb4BvKh1vzOE7DutytP3XhIJqZhLusk7rFMbFM8lVWOTg/z1YB3JIzFE3gu/7pnch5XEWlwhOZKQrbA8Vd+tvQ6fPI2FP09oGoD56Jz9sX6zuzhLjNHidrudrjzq6f7zTPo0dHf0e2vz3wIK3sFuegL0fcc5gCZJ7qk/WFqBrQHPAqdWcf4hO1RlwOENV5gRYWoC7PWlYlTJaIEexHvxDg6ynexGJZp077MBzoTYtpgla1rFdwyei8UweXodJgNAtXKolKaKPI6p8olXz23xO6XMFGtCoIhuwPMJctpIjkGbIWDtei9k4ZyPVbNxo04A5IWzkyOeztYikP+eEjisK7M1bLrCiAVthCgXuHrXKjAz+i42vSC+fDQA6pcu6E/lly2/YfjJZkw1yI375nZYXo7hdictZE5I5SWZ4StLPhmsnnTk8ZOFk6WsdHfIJ2yr8IsLdiTKnhIF46ipGw4Mr8IcLgvsT9/HljyK2qsIREpymVpEqQU0ltPfit+hkGmt+2k3UHVSqMjo/zpgzbnNNfPRbmAppz8RqS2Sct886GJO/6OSn24DKqEEq8GOsS4KdHF6izil52/tcR1LRoZPW9/wlDxzyXtFrMsfR38ZMhpPz4rgpEAVblCUR+dXf0kGxquSzGsnqBq3FeBVVxbi4Z6x0gXI6oVVnJTZcTl4iNFrPe9jyPQ/+mKbqhhfxChEHX/hhCq1pfV9K5RVoALXdYnV4wKBw9qZwxZ66D1b1OdbY13s7AfndFqdyC+H/OyA4WRxF/ZKQkN50GYLCjqJQmaMUEgElwVEeHt4WGyd7rsNNLEL5UxfpW7VIFB/6EiA4LDK8nA/BsfqMemnCLNpVvnywjaNVEj/vsijRETSTDUL7ngXnNr/JIAL0HXD9X4/hHtcNgdAPDZp7rRjvWvhq3BUu8UfpC+ktrKDb0NDUw6NTyWOVoguTxb8dWSR2mwDj60sfD7aZgH7r0aRpz3M3UCA6+XI8/Mf4nTFStBdlywqgWzE8ilMvAIPMl+jCYcNb6YLnVBsroCY88wNJkWYwOUAgpx4AmfvzVUALLRannC5eX6O3IC9a9A77JbMfamyIEc X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8510.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(376014)(1800799024)(7416014)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GPg/TkkamfxhaQRN4gcZgr6c3ZLzvWSgQ6mpEHS5DyhpUWZLXXRO+QzhdrOQY1TWKx11zCMVBpPX1EVFI8KBJJtxSoPej6mCwhtxpcyOwotXITtqJdJmpOcAWCAYYrEZXKsPLaiOU2p0hPXQKFay2kGu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haiiI7ivaE1ylvG8pP8+aH6Ph56HttlILYdy0aab65kjoxaXLkdvxNHY+3qiHlfteJYajkNvRTc7pB2ThMD4K9zOUYrsRIY+KDMYdKooXsI8Y8KyokWbu8BMkGwOx1HbZAyKndYH0dfQ0btN9RWj0rB+uEw729OLt7wT5bGy/Tm8zcaSkc+ixt5rQxiKVxx+zP73g0GBZM4JH3Z/ENDe53ML4I5wW11rH04VMSBHLYwoE9pmdYFlmnF69MzjT79HgQvwJqLGGR8vWktC+FedMo6rCIq3f61BPpD0LpFFk7u7UTQohJfi1+c6thVZKxevONwimRwXoKZjP9ZpgkEk17tmh6lxgBC74B2lVXxFYWsD0f+9H79WLVfE3 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a53bc9f4-c8db-4000-7dc5-08dd2bbf2e7b X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jan 2025 06:23:47.6905 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 9nVZ3V47yQGRRVZS6eawUoByhTd4UBv6mqYTqH4yJXuWefRdPO0CUzUYFieCO5B3p/UbuiTfmn/VsBveqLqRqg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB9331 X-Patchwork-Delegate: kuba@kernel.org Add VLAN hash filter support for i.MX95 ENETC PF. If VLAN filtering is disabled, then VLAN promiscuous mode will be enabled, which means that PF qualifies for reception of all VLAN tags. Signed-off-by: Wei Fang --- .../net/ethernet/freescale/enetc/enetc4_hw.h | 4 ++++ .../net/ethernet/freescale/enetc/enetc4_pf.c | 20 +++++++++++++++++++ .../freescale/enetc/enetc_pf_common.c | 2 +- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc4_hw.h b/drivers/net/ethernet/freescale/enetc/enetc4_hw.h index 826359004850..aa25b445d301 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc4_hw.h +++ b/drivers/net/ethernet/freescale/enetc/enetc4_hw.h @@ -107,6 +107,10 @@ #define ENETC4_PSIMMHFR0(a) ((a) * 0x80 + 0x2058) #define ENETC4_PSIMMHFR1(a) ((a) * 0x80 + 0x205c) +/* Port station interface a VLAN hash filter register 0/1 */ +#define ENETC4_PSIVHFR0(a) ((a) * 0x80 + 0x2060) +#define ENETC4_PSIVHFR1(a) ((a) * 0x80 + 0x2064) + #define ENETC4_PMCAPR 0x4004 #define PMCAPR_HD BIT(8) #define PMCAPR_FP GENMASK(10, 9) diff --git a/drivers/net/ethernet/freescale/enetc/enetc4_pf.c b/drivers/net/ethernet/freescale/enetc/enetc4_pf.c index 4cd0931baea0..e2eca28eec06 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc4_pf.c +++ b/drivers/net/ethernet/freescale/enetc/enetc4_pf.c @@ -85,11 +85,19 @@ static void enetc4_get_rss_key(struct enetc_hw *hw, u8 *key) ((u32 *)key)[i] = enetc_port_rd(hw, ENETC4_PRSSKR(i)); } +static void enetc4_pf_set_si_vlan_hash_filter(struct enetc_hw *hw, + int si, u64 hash) +{ + enetc_port_wr(hw, ENETC4_PSIVHFR0(si), lower_32_bits(hash)); + enetc_port_wr(hw, ENETC4_PSIVHFR1(si), upper_32_bits(hash)); +} + static const struct enetc_pf_ops enetc4_pf_ops = { .set_si_primary_mac = enetc4_pf_set_si_primary_mac, .get_si_primary_mac = enetc4_pf_get_si_primary_mac, .set_rss_key = enetc4_set_rss_key, .get_rss_key = enetc4_get_rss_key, + .set_si_vlan_hash_filter = enetc4_pf_set_si_vlan_hash_filter, }; static int enetc4_pf_struct_init(struct enetc_si *si) @@ -704,6 +712,16 @@ static void enetc4_pf_set_rx_mode(struct net_device *ndev) static int enetc4_pf_set_features(struct net_device *ndev, netdev_features_t features) { + netdev_features_t changed = ndev->features ^ features; + struct enetc_ndev_priv *priv = netdev_priv(ndev); + struct enetc_hw *hw = &priv->si->hw; + + if (changed & NETIF_F_HW_VLAN_CTAG_FILTER) { + bool promisc_en = !(features & NETIF_F_HW_VLAN_CTAG_FILTER); + + enetc4_pf_set_si_vlan_promisc(hw, 0, promisc_en); + } + enetc_set_features(ndev, features); return 0; @@ -717,6 +735,8 @@ static const struct net_device_ops enetc4_ndev_ops = { .ndo_set_mac_address = enetc_pf_set_mac_addr, .ndo_set_rx_mode = enetc4_pf_set_rx_mode, .ndo_set_features = enetc4_pf_set_features, + .ndo_vlan_rx_add_vid = enetc_vlan_rx_add_vid, + .ndo_vlan_rx_kill_vid = enetc_vlan_rx_del_vid, }; static struct phylink_pcs * diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c b/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c index 9f812c1af7a3..3f7ccc482301 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c @@ -135,7 +135,7 @@ void enetc_pf_netdev_setup(struct enetc_si *si, struct net_device *ndev, /* TODO: currently, i.MX95 ENETC driver does not support advanced features */ if (!is_enetc_rev1(si)) { - ndev->hw_features &= ~(NETIF_F_HW_VLAN_CTAG_FILTER | NETIF_F_LOOPBACK); + ndev->hw_features &= ~NETIF_F_LOOPBACK; goto end; } From patchwork Fri Jan 3 06:06:08 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Fang X-Patchwork-Id: 13925210 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2060.outbound.protection.outlook.com [40.107.105.60]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EA36F1C3BE3; Fri, 3 Jan 2025 06:23:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.105.60 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735885439; cv=fail; b=gKmCk3SfZAala8nuBs8wO7QaSRNd8NIQCkBYLyUpN7JGrj3nBWkocX8zQ8t+9rfSaHgvmkhz+hwTbDVL5F+yVihSOyFRzweg4pMRWxpaMjaU8L824VOlB74wjcuMNp+yrunHLuSBkWNFj04wBuX59j4Icdv54wbTi48iovMiykg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735885439; c=relaxed/simple; bh=/epvdDZJBKzCJs7Uw0jrLS9xujnOkH2XJpHVnFAJZHE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=by4MUJ6ZIu21/2Ex6BmCMwlBJQVvDl+7vO/6febTDYm665f7a6nVQxEL2faIrkzpAdtihBxYHOuv5xserZI1Nr2H95QAdKGEYOM4tTO9fGlJ0o8RXfobE6KuWOdQwyOiEd29zcSM7UXKt3CbFHC2hOkjt41/XUaA7p3yEnVGV/4= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=YwGh/TgQ; arc=fail smtp.client-ip=40.107.105.60 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="YwGh/TgQ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=YjrsUfQrGTbQvkbeAvpgmG62VYKol3rYuIxElNze/Bfr+QWDjcihRcrrkU7aNsb2ZzCFqsrS041Nc09r5h8DFUAVk+yA0xvtI7wUxpVD/O1l6BVGPj2aJVi9i1l1DA7KlgjvyPrqOWRsyfaACwaB6PZ+6N/tXAnQIj1rsAMs8GZhWTv8F0Gph+QJXibTi01Xik8+Ma5kWqCI3grzx7zUkdfdaYLnfkKzlu/2PTNd8KNZDaT4reYguOQbeTeVyS0cd7I21KkDruNtx59I/vXatK1YxL5YNg86yj90aKSB1hJie0+3ZvRijvS1Yu2BuLhYJ1lnFGdTCPGnZ4IkzHYH1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Y+s06cyqpvZyiMaZkqGsEMJeuscE91SUhnNDLLyCPlM=; b=lo5d6r+3HKeMVmm+7benZwznZUfQAer8EGkXsUinuEgYjvt1ENudR/1J43Y/+hw1Py0ppJTlrtzkCbHe9BEF9CBaqhEr9VHJ6nTi8X084IsYkjlVyI0+Spbj3NsSelak7FrIQZkGjkTpGIKwdfx4GUlU0fBAqEztY3pgIWfh+/oB37qUQrvthDUiEuLTSek4qNDIjF2SP7p34NdJvGbKHEOz5/HwHtSkvQ6RP9GLb7qf8Aq3AuPndkyo6EjxeZJMwg/Qs97OjMT9qQs4WLm/kozbztJzOBvtBlSksofyCkJAxzJFdUNvI4vbd0k5B+bfj+58pavZNtGDr862Zybmsg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Y+s06cyqpvZyiMaZkqGsEMJeuscE91SUhnNDLLyCPlM=; b=YwGh/TgQ7LVlw630lQPBj+WoNTDlYSWfpyq8uCfVJ1md//1FAdyKqd6zgG1QjoLpatvPqQHiJV5jc8/4FWYBzxQY0m/zbUTyxB3qNbKhfJHhJebqa0uEPTJ0uJKhfgtuSWeHRJhdtXDl52WHCMAaLiUnlcfdVd99Ab7tId7ndFc7jIHfUZfYtfNa2du+lMhHDNiYnt7lDKH1SXiOANtod8jFQWhpQWiIzLpR3I/EX5Ys5leWvFEcpg2IVonimtT+vaea/GQ20+c5DxTgw03hGA1EmT8QuLu45ShL36+vZqD2KSqkZnU3jEsZyjN1km257zBO4WihmSCneV6r/07Q4g== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) by DB9PR04MB9331.eurprd04.prod.outlook.com (2603:10a6:10:36d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.12; Fri, 3 Jan 2025 06:23:52 +0000 Received: from PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db]) by PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db%6]) with mapi id 15.20.8314.013; Fri, 3 Jan 2025 06:23:52 +0000 From: Wei Fang To: claudiu.manoil@nxp.com, vladimir.oltean@nxp.com, xiaoning.wang@nxp.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, christophe.leroy@csgroup.eu Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, imx@lists.linux.dev Subject: [PATCH net-next 12/13] net: enetc: add loopback support for i.MX95 ENETC PF Date: Fri, 3 Jan 2025 14:06:08 +0800 Message-Id: <20250103060610.2233908-13-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250103060610.2233908-1-wei.fang@nxp.com> References: <20250103060610.2233908-1-wei.fang@nxp.com> X-ClientProxiedBy: SG2PR03CA0127.apcprd03.prod.outlook.com (2603:1096:4:91::31) To PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8510:EE_|DB9PR04MB9331:EE_ X-MS-Office365-Filtering-Correlation-Id: 60b1bd02-191f-4837-34bf-08dd2bbf310c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|1800799024|7416014|366016|38350700014; X-Microsoft-Antispam-Message-Info: kWRrV7bg7pZ1qXl3IgRcVnlZxIFTAlM39jO2nFraqHCC9siS7tt5zwI3ayEGItKCuaQijyhye8Bcx55ZXptNF49L0CrEQJ2oKC0umsmTjtl/ZDarV3SCbQz9H0Uauh/T1XzFjT0mM6Jc5BN5se/g23lpwZMxDQVVmt3Y6lvuo2C3orP8pnXr8wC7XJD5HGxE6YWp9+i7H1jSpPrMUgrnbygOmgN4P7AnBPeEE1wkd++bMr4Y5v01WibtY+Y2134xuGqKLFIbfKh2hkOkGPWtveNVj+im/5fHXfuo43G+wlqChrfePflcXWW5PtujQZtLEp6SycIuq8oIEzN82FZLVm3YJOYYl6pCfuBG8IHWWf3w0DkTAoIACjUai8F21/3amurI2mX/00nyUFQTfQJMjRfngWtSfVAQe6gnDyYQzaX7K1ufn+8hVG66fJtDTq0BilvzCuy5TbTeq6zwUd3Nni5HYgTy/R9+WzBhxGtsScSaymbnsASY7KtUqQ9anVr8wY0QhJ362PZucKGpyM60vRSmh9PV/bVdiObNhLJasvnaiNGLiYhNMNuLk2XqUOtTxr5tZ9wm/emvdS7wkhJJd+dyD7SKMqO5BoI3gokYxNvp0EUUwwqbbTW+e6pIshzEdgYnAC/j6UhuCNx6i/dkGg+ysLfBiAvkYGAEZErGQatnZwp8Noj/iglFDPAlElWR/gm6pnEEg994NIkJlFb3pudsSB3R4Gb1gtq69a1tXkxyWHB4LAVb3lSiQSfZOYtgl4lDsOOtPQrbcOje/57wvX5yNYlnGikfOw16cBUbj9k7XcELLEjy+0sYpqu2fp7Q085N+RN4tHJUpBSVSXtT5X2eejXhwY3/ICrVBKm46YAeS6Q6lRxMqSGSVl/dFeI3JWZt0/MWSbWDZZx1UF2kO38SuQj+jS8q89hO0uiSWLfj0Q/2eYEcXTC9xDemtuwkc0KpqJQdlcK9sRZ2U45atxVQiP6sSQyj0fsvj9vf+bVy6GEgJeevZ7Ac/KkvGRjVerFPL+oZPEbhoy0xySRiUwGw01dBHdTif+2Naim9BMJupR/LcLNCWLo6/271D7RkUS8ZrZcGm7twHvQTbf4G19TCzOGXcFmGJ8J6XMxwerbXMM4rEHVGbqMDlNLY4eDlUtF5jEM3cOrbX+tDs5agIXW0s//ZnXwBPhJ1qvtSb4hTW85xlp903YivVKiawABbKQhv57A2ff+PzCniH0Qaa12X2GujqF6CCPvOmfVjYxZRcUoZe12oJnhikXhjh5Xd7W0VHi1ISDdsnr3wy9HBl3gIBaFOi1yZDKrZgogUy2DeKGLZcTPQMLj2nkEgTi73bgTPr1Z+pjV3v3IdiVZ//tdixtgQdR8gS0pvySvrodzlgXviAY1BAYJxzWNsIzTiqeZfumEPfeFp0Q6yrqQfpOc3WcAH7WLvOI5CcKt8CN0OmAgcG+LkedOG/VzfaGXG X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8510.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(376014)(1800799024)(7416014)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange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Kt5BqX23CS/ChxwWHQMwl89WTKM7BFiHi+OiFw+zvTxL5IvxxvlxWs9zv/fVBnqzf23XIp2gzSv+jALj8svn5hRmMTtBAZYk/3MKjdibbfmDFhn1qxBNXX7oBv3p4dd2HVXzJ3vd86+kyu6EXfZJNqbwcQuC144k4XiFHmBSoIou1o6nwiS4vDdBwHuqaVcMXQBTL/FpuNM7FgwtHO6n812cI3Q3YJl9H9TnmkzzrGEJi/R4t8BY9zq6j0cYf9dQyVFaTRoDZxq+p/cZplM8P9KLBOhIkkh58XtLDpFypmTM9FAZs84n+fDtr8x1DD/OodSNwywMw3j3eAgcQpT0f4IFbTBQGnPKHmuPGCOvs2BBrTQvALAZgXE5Y9ZGvsgGPHDqSIzIkM4rzFb0vGYsnAAfw2Dd2rCPB+SuW++rC/LmbgIJermFs/WH5tHST7poLBbEtOzqFZWFDsx3GZvKAVGJv0dBiLjYrBhjPQePOcs9E3uzCTQzMqZXnzfVJjH8qQLkt7QpLvNh2YIEvH10SMRl4TEUE6UntLnGmkDkqJ3Ua8e7fxj5 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 60b1bd02-191f-4837-34bf-08dd2bbf310c X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jan 2025 06:23:52.0108 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: FDIIF8zDfC2rsNfc4Iv8prbn3R+Hiky9G5NcpX7KUxUxeQowhf97wHMAkOl5MhNL3X7qRUT9g0TKqXhP/N5LFw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB9331 X-Patchwork-Delegate: kuba@kernel.org Add internal loopback support for i.MX95 ENETC PF, the default loopback mode is MAC level loopback, the MAC Tx data is looped back onto the Rx. The MAC interface runs at a fixed 1:8 ratio of NETC clock in MAC-level loopback mode, with no dependency on Tx clock. Signed-off-by: Wei Fang --- .../net/ethernet/freescale/enetc/enetc4_pf.c | 18 ++++++++++++++++++ .../ethernet/freescale/enetc/enetc_pf_common.c | 4 +--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc4_pf.c b/drivers/net/ethernet/freescale/enetc/enetc4_pf.c index e2eca28eec06..d460d75647f7 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc4_pf.c +++ b/drivers/net/ethernet/freescale/enetc/enetc4_pf.c @@ -709,6 +709,21 @@ static void enetc4_pf_set_rx_mode(struct net_device *ndev) queue_work(si->workqueue, &si->rx_mode_task); } +static void enetc4_pf_set_loopback(struct net_device *ndev, bool en) +{ + struct enetc_ndev_priv *priv = netdev_priv(ndev); + struct enetc_si *si = priv->si; + u32 val; + + val = enetc_port_mac_rd(si, ENETC4_PM_CMD_CFG(0)); + val = u32_replace_bits(val, en ? 1 : 0, PM_CMD_CFG_LOOP_EN); + /* Default to select MAC level loopback mode if loopback is enabled. */ + val = u32_replace_bits(val, en ? LPBCK_MODE_MAC_LEVEL : 0, + PM_CMD_CFG_LPBK_MODE); + + enetc_port_mac_wr(si, ENETC4_PM_CMD_CFG(0), val); +} + static int enetc4_pf_set_features(struct net_device *ndev, netdev_features_t features) { @@ -722,6 +737,9 @@ static int enetc4_pf_set_features(struct net_device *ndev, enetc4_pf_set_si_vlan_promisc(hw, 0, promisc_en); } + if (changed & NETIF_F_LOOPBACK) + enetc4_pf_set_loopback(ndev, !!(features & NETIF_F_LOOPBACK)); + enetc_set_features(ndev, features); return 0; diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c b/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c index 3f7ccc482301..0a2b8769a175 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c @@ -134,10 +134,8 @@ void enetc_pf_netdev_setup(struct enetc_si *si, struct net_device *ndev, } /* TODO: currently, i.MX95 ENETC driver does not support advanced features */ - if (!is_enetc_rev1(si)) { - ndev->hw_features &= ~NETIF_F_LOOPBACK; + if (!is_enetc_rev1(si)) goto end; - } ndev->xdp_features = NETDEV_XDP_ACT_BASIC | NETDEV_XDP_ACT_REDIRECT | NETDEV_XDP_ACT_NDO_XMIT | NETDEV_XDP_ACT_RX_SG | From patchwork Fri Jan 3 06:06:09 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Fang X-Patchwork-Id: 13925225 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2089.outbound.protection.outlook.com [40.107.105.89]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 266041C3C1A; Fri, 3 Jan 2025 06:24:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.105.89 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735885445; cv=fail; b=smLoLZLoVit4wdam927CvucINjmMGzaquEV4Ol1nixAWuNzgkWqGmGdRieZzsDagrpIPQfglYE+JpA2DQ6iOutR1IjkK+3M4iQ9Hzztdu+L15+impAWhYbadirlhrPIVpkKLhgQVPUEE7DHmkBWV4PJp8b6ap8TWint2xRi7Iko= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735885445; c=relaxed/simple; bh=UZNEr5/duhRXZHkkjrpj4T9IL/BXng+qKAzz3U5mun4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=UzyY71E0buril3iaABnfUjBQ82YPld0IdF462tuXHhlu8vC1oChsVdsv1ZIiyBfWsoVwzc48yiBK5a+ZRPSfuHB3DanYkchqXYLSAjC9vfmKL57HV5P+ULJE+bCMdHyUqI6jarm3JMxJOSEoL9js+em0RNvu01BMUI+G8a4CGx4= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=bmIqEecy; arc=fail smtp.client-ip=40.107.105.89 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="bmIqEecy" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=yX7JlO6rDZ8BgPtDS9n+yLOnIYa09EDU8DQT08t72P4oyahITtMpMnbZKfEQGlaBlEgMkK3led1sK2nvpSu4T42E5nIgDfgwt61KF6IFVaUbIHC3y3Ah3luS8A3XD1q+PfxKhHMwD6ubQXvnGPIMa9qFMnJbtdeVNUakjYJ19PAjG2oVeRS6Nqwe74Gf6Ouhjz4qxuMAr6PBUiNavjJW2Ek+62V1b9GM1SnmKq9gjkzDmIBSuYxc85RMAInEfz/svV3woeahPv9XSARSLHtzkKCjWq69MdEjSX+iy2eqBjBnhi+dhTUIBXqRR1dEukaOdqksT0bsvDGTP+NcMMuEmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=awuFpiNnGnu8PB/g+d5F5dMPKyhjVA8lFpOWRmvZ6yU=; b=xwzwF2MD7Cd6tJp0O6fotOV3mU1f3hcAFpJM0aWnA/vVLjCHlCKUxVnN19BGguB6n9khLBx7GlIw0qqNndubHNuPSunyQoa1tRGsSc0zawLZ+pu/EXgWFuk3pTo3DRJ9OReTwmA6mhjf6GGmxrkJyhNje81Rm/9WAVfOunK2rL0fWblWVCF6DDB+13E/apPCP9ZJZ+Ug4eKw44Ha8UczYw+oNh3dJRlCRvg3+YXTU3NFfDy7LZ/gipQKxaPQHHY9ijP8dT3bz0A0Sok9AUItiFsdV2Rv6xaSOUYP7WjZvIntev936XvQKhqmza4XNX4UGaljAgukTydM9fLaymzsnA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=awuFpiNnGnu8PB/g+d5F5dMPKyhjVA8lFpOWRmvZ6yU=; b=bmIqEecyf2i5PFWidAGWMT5e5gFi3tJeDCMhKvXXT21B5MmQyGOE4ijz8QUPny1+IS+dEoWKOzHVPYTE+e91T0XZ2dyFsI7kVNFnyXkWfVq63Q+B5EwTfPC+jJTpZCpX+s2KuB6Kniti9VHbnVyLHZNVFD89pR6AYhDXcZ1FjFvSwIvv+Y0SWd0xTJCcSRrJj+bNkXnxxcERAYv09giOlbnYzi4Tg0oP/OpLa5/fQ05Jug3KRnutW5zmHHi+M47tFf26eFFz/jtrVHINuQkssr6teZz+MspnMHeMr8ivFniKiMoBuSAZPsXw0auVQxVtb/yQNFLIF4CT+JHBOmHs5A== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) by DB9PR04MB9331.eurprd04.prod.outlook.com (2603:10a6:10:36d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.12; Fri, 3 Jan 2025 06:23:56 +0000 Received: from PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db]) by PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db%6]) with mapi id 15.20.8314.013; Fri, 3 Jan 2025 06:23:56 +0000 From: Wei Fang To: claudiu.manoil@nxp.com, vladimir.oltean@nxp.com, xiaoning.wang@nxp.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, christophe.leroy@csgroup.eu Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, imx@lists.linux.dev Subject: [PATCH net-next 13/13] MAINTAINERS: add new file ntmp.h to ENETC driver Date: Fri, 3 Jan 2025 14:06:09 +0800 Message-Id: <20250103060610.2233908-14-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250103060610.2233908-1-wei.fang@nxp.com> References: <20250103060610.2233908-1-wei.fang@nxp.com> X-ClientProxiedBy: SG2PR03CA0127.apcprd03.prod.outlook.com (2603:1096:4:91::31) To PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8510:EE_|DB9PR04MB9331:EE_ X-MS-Office365-Filtering-Correlation-Id: a7eceb04-a176-4565-faf1-08dd2bbf33b8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|1800799024|7416014|366016|38350700014; X-Microsoft-Antispam-Message-Info: MHGPrw6IGJy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BeS0sQ2+hywcpnDDBZoneDEmm3jzyjBxwtlIzwi0bhwZ/+B61F2SbOHJfYxJxuFo/6DsGaLgc3nJFXvxahmOWTIrBOCvk36jYaVvaJosyyw2v1lf73wObp3Es2ETWl+pCGuV3hcxbBVj/4vxiCzC0jdmCTgPJL/QXaQ/N5xh06FnF9xomWqePkPp2T9der2JztopeHBZ/l3LSGkUNRAxNafg+oieD/cfOvvcEbNO13PZX+ccmWApvw670v9lvjQ/UAtKLpIGPJL3/JPUxhwqRuRfjTGq++SNGbBt+SHG7tqFcAPiU7ppVdF8fX0VFDriuWXkPD+LzdDaVjMcaOEBRLpFrOI9Zq9Db8pvEB7FJJVAruQno+k/l3g76s4/irT X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8510.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(376014)(1800799024)(7416014)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1BA1dQyZjLNcOAMV4dByXH2H6E00ULUr/UtPfe9XqyfthS1vL0nHjvEoOxPpcbHXVFMZ1ReUr+gzo/RIcw/OYcLXO30p+vKypGowiWfDPaeQvatmfLPKIWYkxSL2nnX+I/kEdq/sRVHEk+pLzJku81GcODtLd5MEvk7PdncPlGmuAhGLb4KDN5VOmTCied91dMv08DyKoPfCqeBGUZEZPdQi9MZnbkSztMX23L9Dj6rUHk9Zq3674qr9eJyCD1ot5vbfd9cODqM7MYZd80BQPCbojSSbY9LAxu8Yq6USw1VQMX8r27BMrTqy9GWArZrv1YdEYBLk/Ou/rUiWaBtCUPHP82709A8cF/5/HJX4e2mJ3vjPrxz1srbEC36TKaEvZNbuRy4CrR+TLEcpqTn+G6QV5+l0x+AjcKklmiM1c7ABcdGF5e5dhmjUmeyU/JRPYBcuin/Lv4pYpSyf4a2U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p27LI8g6XOk8+F/tZze6OeOZSC7y2BNFcceVZOeHJwt1txaH4s5hXIqwNNq X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a7eceb04-a176-4565-faf1-08dd2bbf33b8 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jan 2025 06:23:56.5958 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: B5VnC3AFJptb+l/OTt+5PnO3Bu86IJvsflKUY/4VvY4yyISpbwGv9+RTer5Rj9ixW60IWRkIrnL05tVw4hi0FA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB9331 X-Patchwork-Delegate: kuba@kernel.org Add new file ntmp.h. to ENETC driver. Signed-off-by: Wei Fang --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index 1579124ef426..ac28154f7eb5 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -9099,6 +9099,7 @@ F: Documentation/devicetree/bindings/net/nxp,netc-blk-ctrl.yaml F: drivers/net/ethernet/freescale/enetc/ F: include/linux/fsl/enetc_mdio.h F: include/linux/fsl/netc_global.h +F: include/linux/fsl/ntmp.h FREESCALE eTSEC ETHERNET DRIVER (GIANFAR) M: Claudiu Manoil