From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.72.5 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796368189; b=1lz4sU41E7cDJkVFNbocR8OGClN8x7B2/AVjSGAvyF1B9Aq6C+jETTwvheTPYeLj+w1B QuOJnmzyx86aDlH8IdyceC1WQ1ysu2TyBX6mFQ38PawBlL5/2L3SpeSPF6C+hLByJkwwR LI5o7ge1kMfU2N1mZHLfYZS9tH5td+5m8d8zxCfKDJql1KUHvq7iO3FiqhNrEXI3Tl9Du UrepYebTcJSgQkNxNvenTA/L8Ut1+xGZ0V0o/E3acdbI7E7/jNNOKzBcHnVSMhfqCBuO7 GnTC8kOiu1LD7H+V+wtHvgdbrjcUP4dqQhidx1tQ8/4XamKOdP8GfRbWtCbKdmrWDcg== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796368189; h=DMARC-Filter:DKIM-Signature:Received:Received:From:To:Cc:Subject: Date:Message-Id:X-Mailer:In-Reply-To:References: Content-Transfer-Encoding:Content-Type:X-ClientProxiedBy:MIME-Version: X-MS-PublicTrafficType:X-MS-TrafficTypeDiagnostic: X-MS-Office365-Filtering-Correlation-Id:X-MS-Exchange-SenderADCheck: X-MS-Exchange-AntiSpam-Relay:X-Microsoft-Antispam: X-Microsoft-Antispam-Message-Info:X-Forefront-Antispam-Report: X-MS-Exchange-AntiSpam-MessageData-ChunkCount: X-MS-Exchange-AntiSpam-MessageData-0:X-OriginatorOrg: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-AuthSource:X-MS-Exchange-CrossTenant-AuthAs: X-MS-Exchange-CrossTenant-OriginalArrivalTime: X-MS-Exchange-CrossTenant-FromEntityHeader: X-MS-Exchange-CrossTenant-Id:X-MS-Exchange-CrossTenant-MailboxType: X-MS-Exchange-CrossTenant-UserPrincipalName: X-MS-Exchange-Transport-CrossTenantHeadersStamped; bh=uAVqep8zeNcvf1TVMnwwEbNX9V79Xs/aXJsGStbjvPo=; b=lLFK8nGWLvRu/j7xfKaBtIlRwk6b0PIazNTuuwi+Za2PXAltrmFycAc7tcyNFcgeV5vl 2DTRjK8dxI10OXLabQRqRBxqO4i7wK2WoLljavkOtksIpaIR4uIZfU5Fds29b9MKI+2q5 DnyKFFD3Y1aEhUXwZeUznr7KrAbMqBUI2EIHGclzmrHGEcpOzdhuTDVpklYfcWL8Xu5bT qtGznhNsOgiSUWH+i4mHWEbhHdYUgwdzfxVd5w9Wl+dXIkI6h9xZuNTm9ytFzIpPesx2J ULSqOcPNI3xc94tO7yO82kGOtVRmQJc0+BhPJg7oRF/GAi6bO7gGvgOcnfIwsyz8kaQ== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass header.from=oss.nxp.com; spf=pass smtp.mailfrom=oss.nxp.com; dkim=pass header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.a=rsa-sha256 header.s=selector1-NXP1-onmicrosoft-com header.b=Em8UDuk0; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.72.5 Received: from AM0PR02CU008.outbound.protection.outlook.com (mail-westeuropeazon11013005.outbound.protection.outlook.com [52.101.72.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (secp384r1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B792F606A322 for ; Fri, 4 Dec 2026 07:09:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B792F606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.a=rsa-sha256 header.s=selector1-NXP1-onmicrosoft-com header.b=Em8UDuk0 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=LEUBLgap5k+NYpZVdTWUAQmHLyXT89wswVEKQ1Ru82yBcXsMy+krgIO4jECqyQiirbETro1fZz2j4OQvdOrznHysm/EX6aQas/7iE/lsbgyo7OIQTotejWiwtaehu4H/a73ACCErwxEwShKHyxK7YzWrqoboEi12HdcwKiBBUhOtzQWE0gAzz0OTbPk/E6KpIulXeJU82AafA7Ecm10t/GtBfwk1b8eKHu4j1QxvPVLIuZm6BhI51RAhp4x/FNVYNdV8IfZgU9zxt0xVvchTm3d84XzERDuR13iD2j112mt27Xzr6LSKW/UvdyKuVdFciH2Xs17l8r7Yzt9kpZyEqw== 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=uAVqep8zeNcvf1TVMnwwEbNX9V79Xs/aXJsGStbjvPo=; b=SdFhar+TgwFBz8gZpcrUeHvPiVaei8EqH7kykluqoWv2Qninfz+nUoOLdvssNhq4GclWw545au8MLPnlCaC1zoRRxJkGEFl+fxONWaqX7FffHwuYSIHBBZYqVCxd81FwjIDFytsCPIPwAT5YYuA0QY2GEkxaJVlsuaWgWmp2fEgQYvThhu21hRe/l5PDH/uYWJQCsF6QDJwkZ43nMEFolO18PnoHF2S93/QbzFzOkkIVQO/qQvBoTEzkm7zP+TwsoGypQjsarKTv4AUIs4aWK5dz/Z2aolVhAtfl5iXLO6J+IRXSSGETNuB6Gj1GYY6EcxNzLd5wcIN0IPhqRY/+yQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector1-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uAVqep8zeNcvf1TVMnwwEbNX9V79Xs/aXJsGStbjvPo=; b=Em8UDuk049jK3Q5pO0Lr9PJF/lZ6OVu+wSRqYJOjLRItpuupU5GPnrNbSY+DIB2FWfD9LHuiaM4ZuZGDHjYE7peHRHin6WFevljusvqeHsiXfgeJF8LtglJw2Bfbk2fTB31lWQStIgYeEeFuUZJnarMzN7Twm7QRvjcrtLhYlDDEGsP1B7A3RSo6jpAcY5d13eBYs1/ANN1ahea32DWYFam7KHoBgOpuiR1R6fEHFWeVJK6bcypMrExDwfVw4SDVq0BvDcCkxgXT/JxYGW6ZpU3ysswhykcYLdr7elE/IxViaG+G8ebRXR4/szfYCTMsqCic7WDMMC63ioz1vTm4IA== Authentication-Results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from VE1PR04MB7216.eurprd04.prod.outlook.com (2603:10a6:800:1b0::22) by AMBPR04MB11763.eurprd04.prod.outlook.com (2603:10a6:20b:6f2::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.13; Fri, 4 Dec 2026 07:09:46 +0000 Received: from VE1PR04MB7216.eurprd04.prod.outlook.com ([fe80::a9a5:cf83:dbe8:1f74]) by VE1PR04MB7216.eurprd04.prod.outlook.com ([fe80::a9a5:cf83:dbe8:1f74%6]) with mapi id 15.21.0688.009; Fri, 4 Dec 2026 07:09:46 +0000 From: wei.fang@oss.nxp.com To: xiaoning.wang@nxp.com, claudiu.manoil@nxp.com, vladimir.oltean@nxp.com, andrew@lunn.ch, olteanv@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, chleroy@kernel.org, richardcochran@gmail.com Cc: wei.fang@nxp.com, imx@lists.linux.dev, netdev@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH net-next 07/14] net: enetc: decouple BPT logical config from hardware wire format Date: Fri, 4 Dec 2026 15:14:03 +0800 Message-Id: <20261204071410.692071-8-wei.fang@oss.nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20261204071410.692071-1-wei.fang@oss.nxp.com> References: <20261204071410.692071-1-wei.fang@oss.nxp.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SI2P153CA0004.APCP153.PROD.OUTLOOK.COM (2603:1096:4:140::23) To VE1PR04MB7216.eurprd04.prod.outlook.com (2603:10a6:800:1b0::22) X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR04MB7216:EE_|AMBPR04MB11763:EE_ X-MS-Office365-Filtering-Correlation-Id: d71c18ce-d3df-473e-69f8-08df51d593ec X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|7416014|23010399003|19092799006|22082099003|18002099003|921020|10067099003|56012099006|260925021911599003|260925021311599003|260925022911599003|261026140227099003|261022105027099003|261022075727099003|261028144727099003|261026121527099003|261021123027099003|261021121427099003|261102123227099003|261102130727099003|261009223027099003|11063799006|6133799003; X-Microsoft-Antispam-Message-Info: iD+JfWybFLhV1SmAgYSbkeuhnT2kLNpgy2+id1nakLbkKH7se2uE8NXIWBVVSQTMFot2rfhImNgDl4GHBdy8witZl3HygAHJb0m0oORnRMEJLKJON0c/eu5XT839Hgj+F/PNsYxKnjXDkfH89jZ3wrbGk5ABvb2NKtz4Z043kPVfYm7ztZQnROvNnYMYmXSdw+6PLf9dKTbN/BvQmS50huoHPGhp9ee0pCOj+qm4Xu+D6s4hRfoKmvYvr5mNBgFx/kuSAmY9sQxibb2i18U6iHOsjDxY91PTUsSLPhzhaxFRZeBrQEj9T9vXE77Pg7mS96+Xb1TaMkwt2gf+YCwEJvs7dKFKSfTtcfL+JhXU+TfekKxw3wRVRcuaDLMfBw+WlsQNkYfUNjMsSZ6QZWVNGhqr+gYqypn4RBjgXxbROodAPZ7/v/KEoVW36iE1/xk6K6xqiqofmO+l6jJDgh4685Xu2KFvqlzAqnB0cH4FVUUbPPKgJnRzecKvURLQkR+drPf3JISztCzG8TqXJurqKvJA8cfIdpKwq41oVcxYGEc0dQGeKQzQ/Vbj8MPS2juMSSOa7UXcBNSUye1Z8N6OdGTcs8AJ8mudXA7m/mAe4foq5W3fOZ0pQUw3uWUbLPSYMklNeqwz81i9/dcQEDsLuiFXy2CeFDHGhNm0W5+HZRBjB8KpF9ek1zg/hyGYvy5+4yl2Bz9fymzUYmTqGbGgDQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VE1PR04MB7216.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014)(7416014)(23010399003)(19092799006)(22082099003)(18002099003)(921020)(10067099003)(56012099006)(260925021911599003)(260925021311599003)(260925022911599003)(261026140227099003)(261022105027099003)(261022075727099003)(261028144727099003)(261026121527099003)(261021123027099003)(261021121427099003)(261102123227099003)(261102130727099003)(261009223027099003)(11063799006)(6133799003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?AJkydfARwvsbwv0knWBiyDdgvCZY/B3jcrFue6UPECKjIE47s7SqjBiYHNZZ?= =?us-ascii?Q?TeyLgZ6Dq1GwUNyRbfIfPDQ0zV2zrl5GFKElDDZHhnOzoTvc+/LAISYNpTPW?= =?us-ascii?Q?6lTnPJ+n2ZJeQqLQXSAIegZbbqyd1yCVSol2deG0kocV7D7IEk1yV+DfTbfL?= =?us-ascii?Q?0YKJCKvV7iKfFu5hAqJnSyhQBzAhb1wBq2PKJkkgpJnD3a9xsciVyPcmyREP?= =?us-ascii?Q?JFnqd+Cm2l+qazMC1JzcQhW87EDDL1ZJZ8HyaxdvN4bkmCvgfbIMlpqWyJ3+?= =?us-ascii?Q?zHnLtXyakKs9crIovfTqVoP0P9ueeHUFqqe+GmUschXO0EOwX+wLkI4WSiRR?= =?us-ascii?Q?dTKiFQymzgLdUCpg9/ePzI/3ll8LJMhCW0Oqlo1GzGaDQ44fJco5+vf37co8?= =?us-ascii?Q?ciiKFJagT/qv1OFyACyJ6O+g6CkXdXImncn+4Xv6cUXyIHb24Vn3vDqg/LZC?= =?us-ascii?Q?rw/iLHn3HzuJbb5xFX4cVDMliWDXQDRDU2hXPVCFHAmEMistEO8h/hI7vcjL?= =?us-ascii?Q?VISq0/5fpWO4bdVhjs73KqvqzbndNNOzl6XCmP1e2wi3eJA2hUr7btsKRey9?= =?us-ascii?Q?rteaveEhP11+3MYJhEWINcPzWwDNSer7IxEmNthiAjeJns/n7yPYQiOdO0uJ?= =?us-ascii?Q?LWEuSAA/2C/oIBpTCnTUWSJxeWjf/gTOsRIvarvrbqC7RnYTPrdd3fVXU9QM?= =?us-ascii?Q?0xL9KaN4kXBmfqrilJZpwRaaz6pSLlCi+BjtNyodgae+eEJFh7unVUjh82EN?= =?us-ascii?Q?pGVekBevFnaK4gK6WCk83gQEoQdN2AOv0zk6+7jAedQ1RIoCqqpxWM8OrXqn?= =?us-ascii?Q?8A5Dfj4gX8NMNMIzUz/v+pdQvRFun6oi6HgtC/WnToxiBO3YwJb+MOQdCsBx?= =?us-ascii?Q?EHuoGuvSJmM2ir0cg/9PqfehEKpytyPgXs2WsfB4MVSTs7LdIoYtGn0IKCF4?= =?us-ascii?Q?HX535ADQ5SerHtzFKpZPirH9U6RSvSKN5WuobWeptAI/bD/PUoGtJoUCxukH?= =?us-ascii?Q?dA/2NaJYSuV7xT1Hpm0E/+QB1CssPVnygOIgIygsHXFi0nejgHRjgwAg2ssK?= =?us-ascii?Q?soU5mmZ2pF9NtdQS1/2APzPmDRe5S+nV+iJIVeZeDgsNSeSGW8U/2KeO/AZi?= =?us-ascii?Q?n3Hc8tL7EdRkcX7mDXxP+pxFxpwOFWWimvASF8TijJce9UdC/5PHwg0RDGS2?= =?us-ascii?Q?7/+dMjwlc83VSr6v6GAPskANiH8uM4UpVbggicu5/LJIxaEGz2vCTKA5rN2p?= =?us-ascii?Q?U6hrjKATnG1Qxrs2QEzbO0WIpT8OO0Vumu2+G04Bn8G9EfpF7VXE07vNlWpy?= =?us-ascii?Q?53mBqYpWsxHfXem47/+vY1XfyzDMT7ZYnS3bmgi9zoDlK+hck13t1fhAKUno?= =?us-ascii?Q?k8cxG4CHrxc3eZBJOBd8IDsIaG3uJK+tTDZ5fyhmNoQHlFkMMNzDPEbThCi8?= =?us-ascii?Q?lypWNwP/K2DF3mbMomqqHzo/QVi/TnvB4Psa1kc0JDLrss0xEU0esIPhpbW/?= =?us-ascii?Q?cGuC8jMV/odxFKlsftgfTGRnwi3EE+MANCyCJDMVC9sCYNtYSdMji8S0xPLc?= =?us-ascii?Q?VjZn6C+NGHUH0wuwZ1Z7aZpYJVj3mgX/2Bucn5bQEUKjBJztY6D9sbSPgbGD?= =?us-ascii?Q?L4SVHYb4PxLaPHZBHAwJYqg1tUxaRfpe1gZtDQEPfA0hQRXiBaf01JA+In1m?= =?us-ascii?Q?A787QnVfRjtN2Q5rqNmOk9OD0qZrsijyzzunIokdWqKA1gQ9DF2iQd3zD6rW?= =?us-ascii?Q?yOS7huM5mVmZonN1dhGiZrJ5nDCb9IwhoMcxq1ttLoyba47dXZLu?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d71c18ce-d3df-473e-69f8-08df51d593ec X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB7216.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Dec 2026 07:09:46.3266 (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: sBZeuK7CZKkCk2ZIS6jupm+cDuu79Sc33/0t+xNsmW6OMSebnyzH7QLi/ZnCqlh+FxJR9xTR5X/UUI3sTJSt6lZT7C/Nn9GEoef7XDh03++Zb/Nl6UxBiWpwiz2w8hll X-MS-Exchange-Transport-CrossTenantHeadersStamped: AMBPR04MB11763 From: Wei Fang Current SoCs only implement BPT version 0, but future versions may extend the table with a different buffer layout and size. Today struct bpt_cfge_data and struct bpt_bpse_data are the hardware CFGE and BPSE structures, so callers must know the wire format and open-code endianness conversions. This interface is hard to extend: once a new version changes the buffer layout or size, updating the callers becomes cumbersome. Add a version-agnostic struct bpt_entry_data that uses native CPU types and also carries the entry ID, and move the wire structures into ntmp_private.h to keep them internal to the NTMP layer. Add a struct ntmp_tbl_ops instance holding the buffer size and a pack() callback, and select it via ntmp_get_bpt_ops(), following the other NTMP tables. Reshape the BPT interface around the logical config. ntmp_bpt_update_entry() now takes a struct bpt_entry_data pointer instead of an entry ID and a separate cfge pointer, and the driver caches struct bpt_entry_data. A future version can then be added within the NTMP layer by providing its wire structures, pack helper and ops instance. Callers may still need small adjustments, but they no longer deal with the wire format or endianness. Signed-off-by: Wei Fang --- drivers/net/dsa/netc/netc_main.c | 34 ++++++----- drivers/net/dsa/netc/netc_switch.h | 2 +- drivers/net/ethernet/freescale/enetc/ntmp.c | 59 +++++++++++++++---- .../ethernet/freescale/enetc/ntmp_private.h | 20 +++++++ include/linux/fsl/ntmp.h | 35 +++++------ 5 files changed, 106 insertions(+), 44 deletions(-) diff --git a/drivers/net/dsa/netc/netc_main.c b/drivers/net/dsa/netc/netc_main.c index 1ac6ec0087aa0..c8c653b23d63e 100644 --- a/drivers/net/dsa/netc/netc_main.c +++ b/drivers/net/dsa/netc/netc_main.c @@ -958,10 +958,11 @@ static int netc_switch_bpt_default_config(struct netc_switch *priv) /* Initialize the maximum threshold of each buffer pool entry */ for (int i = 0; i < priv->num_bp; i++) { - struct bpt_cfge_data *cfge = &priv->bpt_list[i]; + struct bpt_entry_data *entry = &priv->bpt_list[i]; - cfge->max_thresh = cpu_to_le16(NETC_BP_THRESH); - err = ntmp_bpt_update_entry(&priv->ntmp, i, cfge); + entry->entry_id = i; + entry->max_thresh = NETC_BP_THRESH; + err = ntmp_bpt_update_entry(&priv->ntmp, entry); if (err) goto free_bpt_list; } @@ -2395,24 +2396,25 @@ static void netc_port_set_tx_pause(struct netc_port *np, bool tx_pause) num_bp = priv->num_bp / priv->info->num_ports; for (i = 0, j = port * num_bp; i < num_bp; i++, j++) { - struct bpt_cfge_data *cfge = &priv->bpt_list[j]; - struct bpt_cfge_data old_cfge = *cfge; + struct bpt_entry_data *entry = &priv->bpt_list[j]; + struct bpt_entry_data old_entry = *entry; if (tx_pause) { - cfge->fc_on_thresh = cpu_to_le16(NETC_FC_THRESH_ON); - cfge->fc_off_thresh = cpu_to_le16(NETC_FC_THRESH_OFF); - cfge->fccfg_sbpen = FIELD_PREP(BPT_FC_CFG, - BPT_FC_CFG_EN_BPFC); - cfge->fc_ports = cpu_to_le32(BIT(port)); + entry->fc_on_thresh = NETC_FC_THRESH_ON; + entry->fc_off_thresh = NETC_FC_THRESH_OFF; + entry->fccfg_sbpen = FIELD_PREP(BPT_FC_CFG, + BPT_FC_CFG_EN_BPFC); + entry->fc_ports = BIT(port); } else { - cfge->fc_on_thresh = cpu_to_le16(0); - cfge->fc_off_thresh = cpu_to_le16(0); - cfge->fccfg_sbpen = 0; - cfge->fc_ports = cpu_to_le32(0); + entry->fc_on_thresh = 0; + entry->fc_off_thresh = 0; + entry->fccfg_sbpen = 0; + entry->fc_ports = 0; } - if (ntmp_bpt_update_entry(&priv->ntmp, j, cfge)) { - *cfge = old_cfge; + entry->entry_id = j; + if (ntmp_bpt_update_entry(&priv->ntmp, entry)) { + *entry = old_entry; dev_warn(priv->dev, "Failed to %s TX pause of buffer pool %d (swp%d)\n", tx_pause ? "enable" : "disable", j, port); diff --git a/drivers/net/dsa/netc/netc_switch.h b/drivers/net/dsa/netc/netc_switch.h index c61d3e3a366a0..f0a370dbcffca 100644 --- a/drivers/net/dsa/netc/netc_switch.h +++ b/drivers/net/dsa/netc/netc_switch.h @@ -178,7 +178,7 @@ struct netc_switch { u32 htmcapr_num_words; u32 num_bp; - struct bpt_cfge_data *bpt_list; + struct bpt_entry_data *bpt_list; struct pci_dev *tmr_dev; /* The PTP Timer PCI device */ }; diff --git a/drivers/net/ethernet/freescale/enetc/ntmp.c b/drivers/net/ethernet/freescale/enetc/ntmp.c index c967439ad3589..07a9117273220 100644 --- a/drivers/net/ethernet/freescale/enetc/ntmp.c +++ b/drivers/net/ethernet/freescale/enetc/ntmp.c @@ -608,6 +608,38 @@ static const struct ntmp_tbl_ops *ntmp_get_ett_ops(u8 version) } } +static void ntmp_bpt_pack_v0(const void *entry, void *buf, int access_method) +{ + const struct bpt_entry_data *_entry = entry; + struct bpt_req_update *req = buf; + struct bpt_cfge_data *cfge; + + cfge = &req->cfge; + cfge->fccfg_sbpen = _entry->fccfg_sbpen; + cfge->pfc_vector = _entry->pfc_vector; + cfge->max_thresh = cpu_to_le16(_entry->max_thresh); + cfge->fc_on_thresh = cpu_to_le16(_entry->fc_on_thresh); + cfge->fc_off_thresh = cpu_to_le16(_entry->fc_off_thresh); + cfge->sbp_thresh = cpu_to_le16(_entry->sbp_thresh); + cfge->sbp_eid = cpu_to_le32(_entry->sbp_eid); + cfge->fc_ports = cpu_to_le32(_entry->fc_ports); +} + +static const struct ntmp_tbl_ops bpt_ops_v0 = { + .req_ua_len = sizeof(struct bpt_req_update), + .pack = ntmp_bpt_pack_v0, +}; + +static const struct ntmp_tbl_ops *ntmp_get_bpt_ops(u8 version) +{ + switch (version) { + case NTMP_TBL_V(0): + return &bpt_ops_v0; + default: + return NULL; + } +} + static int ntmp_delete_entry_by_id(struct ntmp_user *user, int tbl_id, u32 entry_id, u32 req_len, u32 resp_len) { @@ -1580,17 +1612,23 @@ int ntmp_ect_update_entry(struct ntmp_user *user, u32 entry_id) } EXPORT_SYMBOL_GPL(ntmp_ect_update_entry); -int ntmp_bpt_update_entry(struct ntmp_user *user, u32 entry_id, - const struct bpt_cfge_data *cfge) +int ntmp_bpt_update_entry(struct ntmp_user *user, + struct bpt_entry_data *entry) { - struct bpt_req_update *req; + u8 version = user->tbl_ver[NTMP_BPT_ID]; + const struct ntmp_tbl_ops *ops; struct netc_swcbd swcbd; struct netc_cbdr *cbdr; union netc_cbd cbd; + void *buf; int err; - swcbd.size = sizeof(*req); - err = ntmp_alloc_data_mem(user->dev, &swcbd, (void **)&req); + ops = ntmp_get_bpt_ops(version); + if (!ops) + return -EOPNOTSUPP; + + swcbd.size = ops->req_ua_len; + err = ntmp_alloc_data_mem(user->dev, &swcbd, &buf); if (err) return err; @@ -1598,10 +1636,10 @@ int ntmp_bpt_update_entry(struct ntmp_user *user, u32 entry_id, * which is maintained by the hardware. The BPSE_DATA is not present in * the request data for 'Update' operation. */ - ntmp_fill_crd_eid(&req->rbe, user->tbl_ver[NTMP_BPT_ID], 0, - NTMP_GEN_UA_CFGEU | BPT_UA_BPSEU, entry_id); - req->cfge = *cfge; - ntmp_fill_request_hdr(&cbd, swcbd.dma, NTMP_LEN(swcbd.size, 0), + ntmp_fill_crd_eid(buf, version, 0, NTMP_GEN_UA_CFGEU | BPT_UA_BPSEU, + entry->entry_id); + ops->pack(entry, buf, 0); + ntmp_fill_request_hdr(&cbd, swcbd.dma, NTMP_LEN(ops->req_ua_len, 0), NTMP_BPT_ID, NTMP_CMD_UPDATE, NTMP_AM_ENTRY_ID); ntmp_select_and_lock_cbdr(user, &cbdr); @@ -1609,7 +1647,8 @@ int ntmp_bpt_update_entry(struct ntmp_user *user, u32 entry_id, if (err) dev_err(user->dev, "Failed to update %s entry 0x%x, err: %pe\n", - ntmp_table_name(NTMP_BPT_ID), entry_id, ERR_PTR(err)); + ntmp_table_name(NTMP_BPT_ID), entry->entry_id, + ERR_PTR(err)); ntmp_unlock_cbdr(cbdr); diff --git a/drivers/net/ethernet/freescale/enetc/ntmp_private.h b/drivers/net/ethernet/freescale/enetc/ntmp_private.h index 710ab88560c7d..c356060a17bb9 100644 --- a/drivers/net/ethernet/freescale/enetc/ntmp_private.h +++ b/drivers/net/ethernet/freescale/enetc/ntmp_private.h @@ -350,6 +350,26 @@ struct ett_req_ua { struct ett_cfge_data cfge; }; +/* Buffer Pool Table Statistics Element Data */ +struct bpt_bpse_data { + __le32 amount_used; + __le32 amount_used_hwm; + u8 bpd_fc_state; +} __packed; + +/* Buffer Pool Table Configuration Element Data */ +struct bpt_cfge_data { + u8 fccfg_sbpen; + u8 pfc_vector; + __le16 max_thresh; + __le16 fc_on_thresh; + __le16 fc_off_thresh; + __le16 sbp_thresh; + __le16 resv; + __le32 sbp_eid; + __le32 fc_ports; +}; + /* Buffer Pool Table Request Data Buffer Format of Update action */ struct bpt_req_update { struct ntmp_req_by_eid rbe; diff --git a/include/linux/fsl/ntmp.h b/include/linux/fsl/ntmp.h index 23a612ec0b969..c54bf95739960 100644 --- a/include/linux/fsl/ntmp.h +++ b/include/linux/fsl/ntmp.h @@ -242,26 +242,27 @@ struct ett_entry_data { u32 esqa_tgt_eid; }; -struct bpt_bpse_data { - __le32 amount_used; - __le32 amount_used_hwm; - u8 bpd_fc_state; -#define BPT_FC_STATE BIT(0) -#define BPT_BPD BIT(1) -} __packed; +struct bpt_entry_data { + u32 entry_id; -struct bpt_cfge_data { + /* CFGE_DATA */ u8 fccfg_sbpen; #define BPT_FC_CFG GENMASK(2, 1) #define BPT_FC_CFG_EN_BPFC 1 u8 pfc_vector; - __le16 max_thresh; - __le16 fc_on_thresh; - __le16 fc_off_thresh; - __le16 sbp_thresh; - __le16 resv; - __le32 sbp_eid; - __le32 fc_ports; + u16 max_thresh; + u16 fc_on_thresh; + u16 fc_off_thresh; + u16 sbp_thresh; + u32 sbp_eid; + u32 fc_ports; + + /* BPSE_DATA */ + u32 amount_used; + u32 amount_used_hwm; + u8 bpd_fc_state; +#define BPT_FC_STATE BIT(0) +#define BPT_BPD BIT(1) }; union ntmp_fmt_eid { @@ -319,8 +320,8 @@ int ntmp_ett_update_entry(struct ntmp_user *user, const struct ett_entry_data *entry); int ntmp_ett_delete_entry(struct ntmp_user *user, u32 entry_id); int ntmp_ect_update_entry(struct ntmp_user *user, u32 entry_id); -int ntmp_bpt_update_entry(struct ntmp_user *user, u32 entry_id, - const struct bpt_cfge_data *cfge); +int ntmp_bpt_update_entry(struct ntmp_user *user, + struct bpt_entry_data *entry); #else static inline int ntmp_init_cbdr(struct netc_cbdr *cbdr, struct device *dev, const struct netc_cbdr_regs *regs) -- 2.34.1