From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 867C8606A32F for ; Fri, 4 Dec 2026 07:10:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=ETJdksEb; 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=hl4QoWA0 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-Type: Content-Transfer-Encoding:References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post: List-Owner; bh=5ptDMXuA/ZFpKsdePQ7UnI9cF2P14szY/VGcWXIBwzc=; b=ETJdksEb3rmq0U 2+S3Kk3hdgz3mJyCudmSoYwsDfzl5H6EsCVHWDKELFpz9rub3ZJyjfYy9s9uNpk4iUsWZhQrj5fK3 +AgT1oqqTZS5CSqC5fvqJNLCUzgF3n/PmEFvZ9y4vMN1IjQMOkEKukEd6f8RjfZCPtPqn51OXFPPy OZr1y8BNhmYMaPpciGvWKupsA2I6hvDl+EhQfKNQ50ZVlWSdeCt4MQyThMeHYARe5Bu3yU/Qa12wY 2EWpO3O1REw9/KSYNyuYYeBV90JBrM+mfbed8sOz3UljMLmFsHyIZZnfXMdnlsXOyzpSKLseqk/pv l5h8MI/dsNcRRcV7tOfQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZNQp-0000000GsaZ-3Hjr; Fri, 04 Dec 2026 07:10:13 +0000 Received: from mail-francesouthazlp170110003.outbound.protection.outlook.com ([2a01:111:f403:c207::3] helo=MRWPR03CU001.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZNQi-0000000GsDq-0Uug for linux-arm-kernel@lists.infradead.org; Fri, 04 Dec 2026 07:10:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ScK0JElPO/4WLJizGSrmwxF9kkJWM1rWf1DLG+NinQWvSfOt3g4S1aiirfPqUbNM77PO4t2WvIejqvPgxb+VeavC6lloAoypIeJltZAzeMG0E1D5fR3MxppYnMAZICuG3S5j5DO7vIr10fyNR6LCkzRg+SzRHlVradu3eETuw2TAYwD4fGQ385NGdNmVf9tkAbKyNZwtBV2eX85sCROK/nInVlAK8Nk4AjAyyNIb1w1YeP2PJF0P3ZsS/ph4Z3FvPSoyB68UYOwkOnFAVui4UriaHhVH3aj2rdcMl/kd2nPjGOqj8qTcszU9oQdv4hYJdP1AUJ7q/OkVp7MOSv5MZw== 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=5ptDMXuA/ZFpKsdePQ7UnI9cF2P14szY/VGcWXIBwzc=; b=htmYUTHdkHkJUcYBC8IAKNI1bIvj4NJiSIuoOq6vM1fxliWZGFgG4IFuLt2SdSSZ7dBS9/p06Ml3OQ77ARJ2c3x7iiPnatvqfbZkCdPxQiPn72chFHHeRO6bg2Am2PvWqFWqTD9j2MHRpk2FJ5h4KpKMikltvIZcKyYDHGTziFKBb5vtraFUXR5Cxc+TikHD4omyw6y6EfLspF8pLEc8ni1c5o8OmD/JfCi1F7u0qBohW4iNrU7RsylNLoYW43x+4psEF3oHnfD+4Au6Z2Vt9CXet/mFVqPGEXGDLVcKxA1bPzcYKR1LAIuF7iqgwMdasT/lg/GcWWNAXZngWnH1jg== 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=5ptDMXuA/ZFpKsdePQ7UnI9cF2P14szY/VGcWXIBwzc=; b=hl4QoWA0ub4UZOX+rzLuWeFYDx/oI5qa+URtghUwer6r6UCpLnykyeLymMGJJ36Cx0T8NdDW6Iay+hbgkq3pqlt8EyYRCoHNRWTmb65cJpexfM0dC2OHFhkUmb9yeoDr7XXAztNeQTOBjG4Q3NJqsULMRxD6iXccw6uDIA8ta7I3pBetKxmGaXSFb0LgHpHaMzFFcq74cJ8vPOUhQfy++ClPBkkJRZwWPqe4n/IXkq+61mbgtm1UAqXgkXRNFD7MOZt7TR3J3463oXuX8r/zF/io9XSuFOS+pG9kDdAt0fvgvsoyT4mgxAxRiBzsgWfA9j+pnq9YeAU+GiCNPPKx/g== 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:52 +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:52 +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 08/14] net: enetc: add generic ntmp_add_entry_by_id() helper Date: Fri, 4 Dec 2026 15:14:04 +0800 Message-Id: <20261204071410.692071-9-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: SI2PR02CA0007.apcprd02.prod.outlook.com (2603:1096:4:194::23) To VE1PR04MB7216.eurprd04.prod.outlook.com (2603:10a6:800:1b0::22) X-Archived-By: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR04MB7216:EE_|AMBPR04MB11763:EE_ X-MS-Office365-Filtering-Correlation-Id: f169ad66-9f1f-4bc3-9469-08df51d5976b 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: P0HTLrvOrNGegX63HtPQ0w7icIEFS021Tblk+VxSy9Cwzf2V2Y7E8zkgl6gdIzjcxB2EjE4zdfbeNiX+NiftEz2PlpfqN+SFJcde/6xUh5HOLhApPkyx1HDdezJn7xBx6dg6pV9eYUx/hIUiuZucKhgQRyJX+zzod1Vj7tvt094NSbWa1oO5WDu7laO9tA/TEQv705GvFEf/fUAKzFQLfLJBP3sRo2zSffprY/FvMy5bh1xkj2/qsSYFFmFUKI8VBG9/APhIxo42RWhb9c1QFBpkmpngRhRcI74JGQypUDiOpnHFOJMQ4W8oy1vjt+sNr72lP7ayHmtkyfmsP6vyNXJN6KkYJr8TCMg/G/QjQ4jj3LQeEgzoLrVRDnRo3fh6l3tGQw65Tzt/eT/vseJKaxR6s4+0bfjEWJbVNlqOrd9U7WMOjkJWIZF9rBcJf4Lra+fLyQ+UPvsITc9JXA/3pRrJd09KD895Bem5glsdNLFPvMOhRJhe4gTheuylVgD3qZVmsx3FW1iLO0XZf6IXv3K8UclwGhEta0Gznba0mPwxKpb7ZdVW8AaLoDi5EiBfwTRwPpjAUs3XSg8UjgRtiDIvjdt34gED2HqxHOJkGG/VP8sHee3OYkL6fR+OzCUiR0Z1bGfJvReYQlM4M/LbVoRb9IuWiXyg0NSSXdRSV9zsL8AzKAbh73512eDyVS3yimxmAARQgaICd+rt9N71qQ== 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?0TKXnUbhMi719vBKmUXNInDqQZnoy87EoMI/hP4LbNBm1QdZmFg4kbu47flq?= =?us-ascii?Q?otgn8Nk0zt3i4AqaorTJaVf/MS19VeJUC7oJWPJJ30ZEY+ttDx4s39gYLIMm?= =?us-ascii?Q?b64wmicEZUXCDtnK07rwXvMCSVFrLoSKudCdUukAlSyxGna6YwP1i+BME655?= =?us-ascii?Q?OB0+O+w43Q8pLKinoBLeMVvDT4TYiXFDtM7J0T9bmpYhd5CxFbmw4c0jXo9l?= =?us-ascii?Q?zn924HTH09/OYpXMFKCIfYHwvScI5KpLGaj+AENzzZ57Cv2odaB+6S9rmiYf?= =?us-ascii?Q?Pbany3LTBacGNZ5r5716RwIiFukJYM6QO5QhND6TALl7kvN6iNIwEFCgLAwi?= =?us-ascii?Q?fKfNFXjR4Ffln/iZowBeRr9f4VmKqA6MIxmFL35M05gqHHqrUVfInya0wf/g?= =?us-ascii?Q?w/FHISMpNho0JPtAWZjkVhBrq5ZMHW7oDpPe5m83uDxJIXz7ywGWUsvw2NGu?= =?us-ascii?Q?BRiI3mWTwnEveH5E2Z8cdizaUsu1agnBJ6mP6PdvS0BTnFydgBFivet11EQb?= =?us-ascii?Q?S5mwRrl1kCdewO2VRODEi/hDVjQKMjK07TYOoB9MEEWGMwHO99zk/sFYG8sT?= =?us-ascii?Q?q0bZQjAqw/xejspLvL4wS7uRWm7RtUzaD42bfMHUOeMxZQ1Gfz2z2LYj3iAp?= =?us-ascii?Q?/qQRGOQ+68JOLX9/UIHP/W6Hpe624LK3q93iVYcpZM+W8v8Pf9Mmjz9XaH0f?= =?us-ascii?Q?UTg5QlXEHJjlzGTI9QhHwJI2nISkFhfuAayZWUbuC564Ckfge3Ra9cO1JgmJ?= =?us-ascii?Q?oJ05lk6ZH+t/X28RgaP292gZIJYcVcifrNXH1daQ0rgG8DVsAHYHgWCOHRaW?= =?us-ascii?Q?lHuz/LjBjoXpNIsjLOB/FujspwSJQCY57sPq3LJilbZgGSUDp1pjjIwJlPAO?= =?us-ascii?Q?L/sjryjGUnE1vUDKzA9tbK1A3nITsnRLabi1iWP1B6u6eX2hyf5uSFKjoxMv?= =?us-ascii?Q?aI8Q6FNDQ62ktMYy43yDK/ENBPreTGsgJhFP3DiCQElRKYW6tkTAGnxSFbEZ?= =?us-ascii?Q?h/Sc3yZeEcaz9D5U38eA+39YUFBg2S1tYzedHt8mOUsKr80Vktcwwyj9PU0d?= =?us-ascii?Q?FPTFfcln6bX87CeQ4hbXyLI2sN0elFUSdBNGJ7qDCcPS1Ml2PG7JStdA+3O6?= =?us-ascii?Q?nSbMBUs564bkP6eazH9+tPhqJdzuF2v2YqH0D04KirUlVUvU9UJ9pRbgUz5T?= =?us-ascii?Q?nf+ClpHmJcBCxlJRmb/zxnbTR5OIpttiVeKR2fEsZ9qfgf9TQhSA2ILKmQar?= =?us-ascii?Q?wY6S6CbjEOC1pgA43a0bq9BUmyYik6xuARZ2eIZqXmPA3zpKUExLlIoaTUeW?= =?us-ascii?Q?WA6wPPuXr+PrSfSA+ZDGxHtp7HuPWMV1cetc9PiOiP3ItTsy0CaMS3b21lSj?= =?us-ascii?Q?vmaWl+90wk89q6PTWdjJZC2OWyNCJ0H7BRbWhNOUdzgyfT8fNlMkWzKiiG5H?= =?us-ascii?Q?O8tPhM+wIvRashj0LQnFGwU7CP4Xnx0MT70lDTYWFqcrG/9wnbIe/OV8frl6?= =?us-ascii?Q?o6xdgrAKNDGzJw0Utt8Ouejn5LTaFWBt+hyicM7gOHpXYgAhHT2mkFEbTGtt?= =?us-ascii?Q?8bzGmywJclmkvkLQn7/SYPlb7ch2G5OtL7DEoszZq9UaZ2dEtwPyT0SGYLKS?= =?us-ascii?Q?RKIbNZ6yzRmERnrIE+mn5Q1Gvrm3jcd6Vn+KtIp5y0Ud/B8u9R6oGM5a5rxA?= =?us-ascii?Q?8qubq/W5w1dC+LVZ0Pg7S/zrCqfYf4A9Vp8ebgPtvs/frcP4xRMWDdGb/ykN?= =?us-ascii?Q?qz+PaJb3ANxW64WWONTGU/+0/t6GXRnIsrlNNmkhZCpZOSfi6bCB?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f169ad66-9f1f-4bc3-9469-08df51d5976b 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:52.1851 (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: iPRWk2khE45H/fys7IUYj2vczakjOTJCViuDANL2jW9GISgwZ1N7S9JW4sCaRww0lVb3CqcATrGAebADYh5w+5zP3ZRkVAmkLbkPQagLM5Uh42bGJR/1CSznvpp01jVf X-MS-Exchange-Transport-CrossTenantHeadersStamped: AMBPR04MB11763 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261203_231004_330890_483A5EBA X-CRM114-Status: GOOD ( 20.02 ) X-Spam-Score: 0.0 (/) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-17.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 From: Wei Fang Some NTMP tables have their entry IDs allocated by software, and adding a new entry to them follows the same logic: look up the table ops, allocate the request buffer, fill the common request data and header, then issue the add command over a CBDR. Adding such a table today means duplicating this boilerplate. Introduce ntmp_add_entry_by_id() to factor out this common logic, along with ntmp_table_ops() to select the table ops by table ID. The update actions are passed in so callers can request the needed element updates. Convert the MAFT and ETT add paths to use the new helper. More tables will reuse it later. Signed-off-by: Wei Fang --- drivers/net/ethernet/freescale/enetc/ntmp.c | 182 +++++++++++--------- 1 file changed, 96 insertions(+), 86 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/ntmp.c b/drivers/net/ethernet/freescale/enetc/ntmp.c index 07a9117273220..fec6c3fcfd2e4 100644 --- a/drivers/net/ethernet/freescale/enetc/ntmp.c +++ b/drivers/net/ethernet/freescale/enetc/ntmp.c @@ -640,6 +640,76 @@ static const struct ntmp_tbl_ops *ntmp_get_bpt_ops(u8 version) } } +static const struct ntmp_tbl_ops *ntmp_table_ops(int tbl_id, u8 version) +{ + switch (tbl_id) { + case NTMP_MAFT_ID: + return ntmp_get_maft_ops(version); + case NTMP_IPFT_ID: + return ntmp_get_ipft_ops(version); + case NTMP_FDBT_ID: + return ntmp_get_fdbt_ops(version); + case NTMP_VFT_ID: + return ntmp_get_vft_ops(version); + case NTMP_ETT_ID: + return ntmp_get_ett_ops(version); + case NTMP_BPT_ID: + return ntmp_get_bpt_ops(version); + default: + return NULL; + } +} + +/** + * ntmp_add_entry_by_id - add a new entry to a table whose entry ID is + * allocated by software + * @user: target ntmp_user struct + * @tbl_id: ID of the target table + * @entry_id: the software-allocated entry ID + * @entry: the logical entry data to be packed into the request buffer + * @ua: update actions applied to the entry, 0 if none + * + * A generic helper for tables that add a new entry with a software-allocated + * entry ID. It looks up the table ops for the current version, allocates the + * request buffer, packs the entry data and issues the add command over a CBDR. + * + * Return: 0 on success, otherwise a negative error code + */ +static int ntmp_add_entry_by_id(struct ntmp_user *user, int tbl_id, + u32 entry_id, void *entry, u16 ua) +{ + u8 version = user->tbl_ver[tbl_id]; + const struct ntmp_tbl_ops *ops; + struct netc_swcbd swcbd; + struct netc_cbdr *cbdr; + union netc_cbd cbd; + void *buf; + int err; + + ops = ntmp_table_ops(tbl_id, version); + if (!ops) + return -EOPNOTSUPP; + + swcbd.size = ops->req_ua_len; + err = ntmp_alloc_data_mem(user->dev, &swcbd, &buf); + if (err) + return err; + + ntmp_fill_crd_eid(buf, version, 0, ua, entry_id); + ops->pack(entry, buf, NTMP_AM_ENTRY_ID); + ntmp_fill_request_hdr(&cbd, swcbd.dma, NTMP_LEN(ops->req_ua_len, 0), + tbl_id, NTMP_CMD_ADD, NTMP_AM_ENTRY_ID); + + ntmp_select_and_lock_cbdr(user, &cbdr); + err = netc_xmit_ntmp_cmd(cbdr, &cbd, &swcbd); + if (err) + dev_err(user->dev, "Failed to add %s entry 0x%x, err: %pe\n", + ntmp_table_name(tbl_id), entry_id, ERR_PTR(err)); + ntmp_unlock_cbdr(cbdr); + + return err; +} + static int ntmp_delete_entry_by_id(struct ntmp_user *user, int tbl_id, u32 entry_id, u32 req_len, u32 resp_len) { @@ -716,39 +786,8 @@ static int ntmp_query_entry_by_id(struct netc_cbdr *cbdr, int tbl_id, int ntmp_maft_add_entry(struct ntmp_user *user, struct maft_entry_data *entry) { - u8 version = user->tbl_ver[NTMP_MAFT_ID]; - const struct ntmp_tbl_ops *ops; - struct netc_swcbd swcbd; - struct netc_cbdr *cbdr; - union netc_cbd cbd; - void *buf; - int err; - - ops = ntmp_get_maft_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; - - /* Set mac address filter table request data buffer */ - ntmp_fill_crd_eid(buf, version, 0, 0, entry->entry_id); - ops->pack(entry, buf, 0); - - ntmp_fill_request_hdr(&cbd, swcbd.dma, NTMP_LEN(swcbd.size, 0), - NTMP_MAFT_ID, NTMP_CMD_ADD, NTMP_AM_ENTRY_ID); - - ntmp_select_and_lock_cbdr(user, &cbdr); - err = netc_xmit_ntmp_cmd(cbdr, &cbd, &swcbd); - if (err) - dev_err(user->dev, "Failed to add %s entry 0x%x, err: %pe\n", - ntmp_table_name(NTMP_MAFT_ID), entry->entry_id, - ERR_PTR(err)); - ntmp_unlock_cbdr(cbdr); - - return err; + return ntmp_add_entry_by_id(user, NTMP_MAFT_ID, entry->entry_id, + (void *)entry, 0); } EXPORT_SYMBOL_GPL(ntmp_maft_add_entry); @@ -1460,17 +1499,32 @@ int ntmp_vft_delete_entry(struct ntmp_user *user, u16 vid) EXPORT_SYMBOL_GPL(ntmp_vft_delete_entry); /** - * ntmp_ett_set_entry - add a new entry to the egress treatment table or - * update the configuration element data of the specified entry + * ntmp_ett_add_entry - add a new entry to the egress treatment table * @user: target ntmp_user struct - * @cmd: command type, NTMP_CMD_ADD or NTMP_CMD_UPDATE - * @entry: the entry data, entry->entry_id selects the entry and the + * @entry: the entry data, entry->entry_id is the entry ID and the * configuration element data provides the values * * Return: 0 on success, otherwise a negative error code */ -static int ntmp_ett_set_entry(struct ntmp_user *user, int cmd, - const struct ett_entry_data *entry) +int ntmp_ett_add_entry(struct ntmp_user *user, + const struct ett_entry_data *entry) +{ + return ntmp_add_entry_by_id(user, NTMP_ETT_ID, entry->entry_id, + (void *)entry, NTMP_GEN_UA_CFGEU); +} +EXPORT_SYMBOL_GPL(ntmp_ett_add_entry); + +/** + * ntmp_ett_update_entry - update the configuration element data of the + * specified entry + * @user: target ntmp_user struct + * @entry: the entry data, entry->entry_id selects the entry and the + * configuration element data provides the new values + * + * Return: 0 on success, otherwise a negative error code + */ +int ntmp_ett_update_entry(struct ntmp_user *user, + const struct ett_entry_data *entry) { u8 version = user->tbl_ver[NTMP_ETT_ID]; const struct ntmp_tbl_ops *ops; @@ -1480,9 +1534,6 @@ static int ntmp_ett_set_entry(struct ntmp_user *user, int cmd, void *buf; int err; - if (cmd != NTMP_CMD_ADD && cmd != NTMP_CMD_UPDATE) - return -EINVAL; - ops = ntmp_get_ett_ops(version); if (!ops) return -EOPNOTSUPP; @@ -1499,59 +1550,18 @@ static int ntmp_ett_set_entry(struct ntmp_user *user, int cmd, /* Request header */ ntmp_fill_request_hdr(&cbd, swcbd.dma, NTMP_LEN(swcbd.size, 0), - NTMP_ETT_ID, cmd, NTMP_AM_ENTRY_ID); + NTMP_ETT_ID, NTMP_CMD_UPDATE, NTMP_AM_ENTRY_ID); ntmp_select_and_lock_cbdr(user, &cbdr); err = netc_xmit_ntmp_cmd(cbdr, &cbd, &swcbd); - ntmp_unlock_cbdr(cbdr); - - return err; -} - -/** - * ntmp_ett_add_entry - add a new entry to the egress treatment table - * @user: target ntmp_user struct - * @entry: the entry data, entry->entry_id is the entry ID and the - * configuration element data provides the values - * - * Return: 0 on success, otherwise a negative error code - */ -int ntmp_ett_add_entry(struct ntmp_user *user, - const struct ett_entry_data *entry) -{ - int err; - - err = ntmp_ett_set_entry(user, NTMP_CMD_ADD, entry); - if (err) - dev_err(user->dev, "Failed to add %s entry 0x%x, err: %pe\n", - ntmp_table_name(NTMP_ETT_ID), entry->entry_id, - ERR_PTR(err)); - - return err; -} -EXPORT_SYMBOL_GPL(ntmp_ett_add_entry); - -/** - * ntmp_ett_update_entry - update the configuration element data of the - * specified entry - * @user: target ntmp_user struct - * @entry: the entry data, entry->entry_id selects the entry and the - * configuration element data provides the new values - * - * Return: 0 on success, otherwise a negative error code - */ -int ntmp_ett_update_entry(struct ntmp_user *user, - const struct ett_entry_data *entry) -{ - int err; - - err = ntmp_ett_set_entry(user, NTMP_CMD_UPDATE, entry); if (err) dev_err(user->dev, "Failed to update %s entry 0x%x, err: %pe\n", ntmp_table_name(NTMP_ETT_ID), entry->entry_id, ERR_PTR(err)); + ntmp_unlock_cbdr(cbdr); + return err; } EXPORT_SYMBOL_GPL(ntmp_ett_update_entry); -- 2.34.1