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.69.67 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796368201; b=zIgGHtHiLzAtU8pz+6VuNXFvSVVSPzwvZ4tmn03LolAWe3fnIVv7oJn4NILHZ6OMW55n lSOV5zCwy7PPCxc2OjPTX49+Ha9pknQVdQwPBgWD4U857fGvK5r6bs2a5Ur7lSFkNwWuR PjTg6R7e9N+UX5wdBce9oYNXGfT+xyqiRGkoJer7FGKHpul6hOyymKAFm8Qgwf5TNfCjV 2YxSgumu3RYam3FQuvJWI935uIYRnJwAdeLsZfBiDKFx9qU6u3hzBU79y36WzUSbO7gx1 lVVFQ1vjCO94hyEYVJd/dCgXem8ayOVUvsi8A0UcrN8+RVOWD9mHGGenlmm3OmC9+WA== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796368201; 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=XAVZ/QHFuRQKj6fMrcwp9ULnbRTdTIEE72QdyWE7dDo=; b=l/tc6GyCL5FI7rEgzDNFwahkuxVuC+0oVNTW+YYbwH6bow9LeKNS3vkTYFrGJOukdTsM foC/ng7/Pg28YrhNQNyNIEv9J8Z82YHFFTMLMDzOHFPeMUp7ufb3jeomlSj/F6yQ7mxIb IfPGKzMSZBXXYeQAH94BdirINStly1bCviN9Pl+nxa0GQQ8Xg9B45jhT9/w+pd6/Lcg6B CZJuALQfUg5NNEwsJ29nJ+hYVa6kEO6XiUIENtS0tv68GZ0pwXrmL3YNfYbf5m7tkiIDp N/cECvwoQ/HyPCGtToicfYie/V+1uzNlpnzVscePop+3hKQslFAx4pLjKdbwIZFJhXA== 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=ZHmo82ht; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.69.67 Received: from AM0PR83CU005.outbound.protection.outlook.com (mail-westeuropeazon11010067.outbound.protection.outlook.com [52.101.69.67]) (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 E42EA606A322 for ; Fri, 4 Dec 2026 07:10:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E42EA606A322 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=ZHmo82ht ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=UEeKTO6+43teGyAdpTFMmkVe5+NjijFWiDo7dNAtAIy1xA+UHMHMXqN9kl+2udP86YKACLM9j1OAj7Qj7FONab+kXizn2ccX+OStMpX0U9r7bE+wcqlVjVRVtvdtLGiBoJsKSyMZZxuqPbxsGXFYzmnlTGxx8eMKOZuyqvjDou1sEVajXiMBPN6gyEG/R5/rb8wFB1+gNRxZ4o3xpArLYStQaIurpOS2slbFtfyI/k+XUDFlSwlgJvRu57/fYmI3XPVFVLY5Ag6kzE+0+Os2twu2v6KUO4i6Zp3oTG4coIjyvWpg/KVkHby6B9vwh1jzJQZWujILYEHpD8GBOMvWlA== 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=XAVZ/QHFuRQKj6fMrcwp9ULnbRTdTIEE72QdyWE7dDo=; b=KmkG8Flefw/jBzdLMzCu5LZxz8ZHUdO6TC7+TR3YviK18iY+1DpJ8ojynqh7Di8w9A5iJhY/DaYcpwrpMA4ZxJoqhbAzAgSV+LD3rfcsVL/JvE/BQyBZPgbBj7pBMtxrNU2s63K6SNF6tNg0rzSck11w4SQVCp4SZObsCLZu0QDOJ7uKEcBnBXlYBVaQecSxDuTaLMvSgDs9qF/7THrpoFv+74ggR/8PW2vZhVFJkuxX65sB4dmSNQWcl8+9bH3zTLKJqvUTprPLrI9KkxrkhPo7jVu05mIkosgexHqHu49EhOpnnNL1cbeToHaQpDay3WdXXyRbJWHTeMQiHBTMlw== 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=XAVZ/QHFuRQKj6fMrcwp9ULnbRTdTIEE72QdyWE7dDo=; b=ZHmo82htA96kHQM3mJe+I5scP/3HGq7XewUffhdbbJYXSdqEVDpWIc/8/oFHtQZQzUoTbLsF9AoDo6cinzY35bLFv+Zn9fvsso27+aJcDcP/ErXHdUndEd8ON2dDnsaKnVKoFLwC8wT8zS/LU5Xh/bPJtDVoyiNZa5o8cU8bcqFVaaBHQ0gO7yazHKkvWUWw9+bSAtZRFB/wDKnN8BvHDvlRwYeErO2hKw1KiuBz4+lgFcQYANEzDQnTNsarqOP/r45MxZ90y+5CxIlHzYOq+saG/Pu5RNgsuGMqSVoCfM30gNGY8YkhpoCIHspvYzfMlSds0Q0/jo6X80ox7o2R3g== 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:58 +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:58 +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 09/14] net: enetc: simplify callers of ntmp_query_entry_by_id() Date: Fri, 4 Dec 2026 15:14:05 +0800 Message-Id: <20261204071410.692071-10-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: SI2PR06CA0012.apcprd06.prod.outlook.com (2603:1096:4:186::13) 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: 74808d5b-944b-4b64-9141-08df51d59b25 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; X-Microsoft-Antispam-Message-Info: oh1F4Us6PxFnW89mo+8UD12iNRih0ZDd6Jr4iHtO6gumTTVYCxI0iGP3JnzzoqhIEFqfSX4jztN4l6NvbxYOxtc78V0wEJ6avkLBo+eWgH7oZfzBSWqdemobC/0XtrAOTO2jDTI2dFtna2+afmbjUrGpRnjr8qt+hHD9IhU9zwGQYwChIow6gZ31bQaUAF5CcF+rEAyo0gKXLCSYPCWilXqvPvR/jGruemnQavpUs1cUKMEKqpH91QZJEAtRa4zxvmkcozt/cBybu9cCGCCFnz9nLkJdrHOlRaNtWXMbNBleigA5hyIlK8TMjr4Pu+6Hm2YLMnW8b/JGVKLEBsKI7zD4wVErjft3Je5VQ+aKhekoi/o7/c0jV/JckOp8xE6Pz27QSURllh1l6uoUY8O1DDPBm3fRfW8CN6cy0zRYPapxrzwc0Z0lMnSO42/M7ImYPkiISHAO9826vtlwH+5D53+N9Y+X7dwcZuvjZJLVWjBg1nOHGhIxe7LNOGxEau5Ns6xcW1sLUH5E9ZrcK2uuoztNGeQYqxdFrq84ZDBitxlbtklessmwxsbHptlKuMjgbjeg6Wf/g3Y38JnQ5+r30j9yh+zffG3Tlx3Sdprpf8nvnBzpRa6pVRA6CZ+7KRLqWZj3NSubSN49r7xO37vouuCqnioobbQEtPzPpbzfJCLXL9MnZY3YBG6qmQvOaVdXdgW0WqpCWDdUvpLY2F0HxA== 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);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?ahCi89KD+VGQXh2IBmw9RRuxm3cauTIKIMdVAbzvmc4Dlgpu0UAhh7QFC0Wd?= =?us-ascii?Q?YSsc428sxw8io0Im8vRbAp+YG0Qef+wyXmrcgbm8EGaABDWaEi5yUlNNhg6g?= =?us-ascii?Q?FauNwHOAt6p7NIDyXhf4OHDgGSrYiuP69nQlz2OxFfPucYIOcTVgMjmR934E?= =?us-ascii?Q?apWnPxFU/b0rCf+q2sPsS6ijdaoI+cBasp8nEob75DFoozOFBmlheJtKdGiW?= =?us-ascii?Q?kut1toXP9Wi9d8arxPkbRU4fy82ly58tbwWzgtOweejb4+DsBxFesVIaKPY4?= =?us-ascii?Q?i/OhY7q4iksH97w/Mefkw6GqtG08N7mPcLPrrpL0zYhvi9SjZyvM2WpZsBJl?= =?us-ascii?Q?w0dnXL2wVgn4zwyX2Rc5S5Th45LTyY3iCYg5L2khD8O3kcfSKGLwd+LBMMYP?= =?us-ascii?Q?pOj4x+Tb2BeTWuxFbYxMUU7wmAxEtRETeCpioOdsoreMCPIT7Eb8UgTKP9zm?= =?us-ascii?Q?NcqHFhxkMERbsaFJJIpWOyNZH8R5HubFCqdQgkk+ok8OVRp7C/WD3A58JD85?= =?us-ascii?Q?QBip3f/O4E9qH7J8EUBIB59VYtTMUOeeluq6aFlOzGZoz1iym6rN8qZUls1n?= =?us-ascii?Q?rLJL6AHEhXGe8Qz3+0giIMH0f1wYEx1nKnDFPMHWkVDhjdb49Qzpa3PmMoMy?= =?us-ascii?Q?k42AKD6D9GlyS1Hj/99Ps162FnbwATvd6F58/PICPDHXjkwSSGr8PgaFHGY7?= =?us-ascii?Q?ciV9jkACFwyrCr5AMO6TFh7IqmSYRLIdNPxw5thoUZxwzccg2tSqAVMxJISg?= =?us-ascii?Q?pvZoWP4VzQmogzmxc+5y7UIgqx6/J7SqKuLSZBUpkS3OFxx4swNjewD2M2mH?= =?us-ascii?Q?Eckn9Tmg+MNld4RVuP551v8Kj0PyL6uWOj0ipfkzFfS5S117Xe+8Lw9E7sl8?= =?us-ascii?Q?Hl1NWzAl8iupJVc0WESvd4Z2rtCkPNMLZJ3mcc1pyw2ynHKb/vM0/CVMUuNL?= =?us-ascii?Q?fQE5qvh4/ry/Wkymnm5sJicla5tI7L0Q/7ogvnr4N1C4ofQnGuwIlBT5EyUL?= =?us-ascii?Q?o8YX+U7vOIj4JHCK1LZjJWaYPEy4b330xANj3bQv7ZtghkJvtwOYG7GIP9W1?= =?us-ascii?Q?fCXVa74UP0mggCY2StjXXtFhdun/jpHyBLk74le9z+1r3l78XMZ3ffYuZVxC?= =?us-ascii?Q?LXnTpH3Yere14dPKHaez1Dv70Y6luJBdSIpiGyMyPWc0gG7r6xVVCQuqbkzV?= =?us-ascii?Q?fzg6MV8/LsUlrD71d2BmwQYDCiIKZzq4cIYV0LGYeWdhWi6+3RmUTvvYn2uI?= =?us-ascii?Q?xhUn8DNSsIfjzaY5pVF0DCHhB5+RITXj7h56keH3Y3ONwiIrl6xO+WDgmTxe?= =?us-ascii?Q?1YstoLyGVuDxTrM2VFMNVkpmyVf8nWR2fNn2gONWJXoerftY9HugK+FD0ul0?= =?us-ascii?Q?GgOAS/c4mRBgZrIx63H1OZXz7dJSfW0XNdKVQoPwbazc6uMAIelenY+n+z6v?= =?us-ascii?Q?kzgHbjhBX201wDMvC0mCniKGT86IQKUwYp98Q1x8XDMEN4CzcBdvXT6W/dBZ?= =?us-ascii?Q?AUAmLmN5/zfxQ16wO/jVNDXQRd+iPA6g06JM4oDXmLRV3x0VZhPiXK/oMUrL?= =?us-ascii?Q?8SqJQQqwzSQt7d6CzDhsWN+j/4Z8tkCAZNAJJXyhQGHknO4d5zziRoTs521k?= =?us-ascii?Q?1qA7D/X4UXgMXKY23THdeXAEMW3Pk15SZwvE3xdr5Pn1gm5mQ2Idc/rt8rYQ?= =?us-ascii?Q?9n6IqTs1Q89QAeusTS+1tNegmmoqxrsANfQw4bhUqPGSNKgfwSKTB3zgRFlj?= =?us-ascii?Q?yHHVWlKgi6jakZ6iapHQN3x5NuBxJotkg6yb6o6q5ljzcwPcNRNN?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 74808d5b-944b-4b64-9141-08df51d59b25 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:58.4424 (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: OvO2kXoXkIP95pUwBt2/5K0hAT/RfmCtkujB8n9AselATdjVq4GnZUH8ttCKZ9IVRYww5Vz4wsufGL/gVEhINRHZCStvvjHXjKXaCRi+mV4p/LMcBnARka8srIKou3u4 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AMBPR04MB11763 From: Wei Fang Most NTMP tables can query an entry by its entry ID, and they follow the same logic. The current ntmp_query_entry_by_id() still leaves the table ops lookup, buffer allocation, request filling, CBDR locking and response unpacking to each caller, so every query wrapper duplicates that boilerplate. Move this common handling into ntmp_query_entry_by_id() and take the user, table ID, entry ID and entry data directly, so a caller only needs a single call. The response entry ID is now read from the first field of the response buffer, which lets the one-field struct ntmp_cmn_resp_query be dropped. Convert the MAFT query path to the reworked helper. More tables will reuse it later. Signed-off-by: Wei Fang --- drivers/net/ethernet/freescale/enetc/ntmp.c | 105 ++++++++++-------- .../ethernet/freescale/enetc/ntmp_private.h | 4 - 2 files changed, 56 insertions(+), 53 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/ntmp.c b/drivers/net/ethernet/freescale/enetc/ntmp.c index fec6c3fcfd2e4..40085fd2fe61d 100644 --- a/drivers/net/ethernet/freescale/enetc/ntmp.c +++ b/drivers/net/ethernet/freescale/enetc/ntmp.c @@ -740,48 +740,82 @@ static int ntmp_delete_entry_by_id(struct ntmp_user *user, int tbl_id, return err; } -static int ntmp_query_entry_by_id(struct netc_cbdr *cbdr, int tbl_id, - struct ntmp_req_by_eid *req, - struct netc_swcbd *swcbd, +/** + * ntmp_query_entry_by_id - query an entry of a table by its entry ID + * @user: target ntmp_user struct + * @tbl_id: ID of the target table + * @entry_id: the entry ID to query + * @entry: used to store the queried entry data + * @ua: update actions, some tables support resetting the statistics + * after the query, in which case the caller passes the update actions, + * otherwise 0 + * @compare_eid: whether to compare the queried entry ID against the + * entry ID returned by the hardware. Only a table whose response data + * starts with the entry_id field can set this. + * + * Return: 0 on success, otherwise a negative error code + */ +static int ntmp_query_entry_by_id(struct ntmp_user *user, int tbl_id, + u32 entry_id, void *entry, u16 ua, bool compare_eid) { - u32 len = NTMP_LEN(sizeof(*req), swcbd->size); - struct ntmp_cmn_resp_query *resp; - int cmd = NTMP_CMD_QUERY; + u32 req_len = sizeof(struct ntmp_req_by_eid); + int cmd = ua ? NTMP_CMD_QU : NTMP_CMD_QUERY; + 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; - u32 entry_id; + __le32 *resp_eid; + void *buf; + u32 len; int err; - entry_id = le32_to_cpu(req->entry_id); - if (le16_to_cpu(req->crd.update_act)) - cmd = NTMP_CMD_QU; + ops = ntmp_table_ops(tbl_id, version); + if (!ops) + return -EOPNOTSUPP; + + swcbd.size = max(req_len, ops->resp_query_len); + err = ntmp_alloc_data_mem(user->dev, &swcbd, &buf); + if (err) + return err; - /* Request header */ - ntmp_fill_request_hdr(&cbd, swcbd->dma, len, tbl_id, cmd, + len = NTMP_LEN(req_len, ops->resp_query_len); + ntmp_fill_crd_eid(buf, version, 0, ua, entry_id); + ntmp_fill_request_hdr(&cbd, swcbd.dma, len, tbl_id, cmd, NTMP_AM_ENTRY_ID); - err = netc_xmit_ntmp_cmd(cbdr, &cbd, swcbd); + + ntmp_select_and_lock_cbdr(user, &cbdr); + err = netc_xmit_ntmp_cmd(cbdr, &cbd, &swcbd); if (err) { dev_err(cbdr->dev, "Failed to query entry 0x%x of %s, err: %pe\n", entry_id, ntmp_table_name(tbl_id), ERR_PTR(err)); - return err; + goto unlock_cbdr; } /* For a few tables, the first field of their response data is not * entry_id, so directly return success. */ if (!compare_eid) - return 0; + goto unpack_resp_data; - resp = (struct ntmp_cmn_resp_query *)req; - if (unlikely(le32_to_cpu(resp->entry_id) != entry_id)) { + resp_eid = buf; + if (unlikely(le32_to_cpu(*resp_eid) != entry_id)) { dev_err(cbdr->dev, "%s: query EID 0x%x doesn't match response EID 0x%x\n", - ntmp_table_name(tbl_id), entry_id, le32_to_cpu(resp->entry_id)); - return -EIO; + ntmp_table_name(tbl_id), entry_id, + le32_to_cpu(*resp_eid)); + err = -EIO; + goto unlock_cbdr; } - return 0; +unpack_resp_data: + ops->unpack(buf, entry, false); +unlock_cbdr: + ntmp_unlock_cbdr(cbdr); + + return err; } int ntmp_maft_add_entry(struct ntmp_user *user, struct maft_entry_data *entry) @@ -794,35 +828,8 @@ EXPORT_SYMBOL_GPL(ntmp_maft_add_entry); int ntmp_maft_query_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; - void *buf; - int err; - - ops = ntmp_get_maft_ops(version); - if (!ops) - return -EOPNOTSUPP; - - swcbd.size = ops->resp_query_len; - err = ntmp_alloc_data_mem(user->dev, &swcbd, &buf); - if (err) - return err; - - ntmp_fill_crd_eid(buf, version, 0, 0, entry->entry_id); - - ntmp_select_and_lock_cbdr(user, &cbdr); - err = ntmp_query_entry_by_id(cbdr, NTMP_MAFT_ID, buf, &swcbd, true); - if (err) - goto unlock_cbdr; - - ops->unpack(buf, entry, false); - -unlock_cbdr: - ntmp_unlock_cbdr(cbdr); - - return err; + return ntmp_query_entry_by_id(user, NTMP_MAFT_ID, entry->entry_id, + (void *)entry, 0, true); } EXPORT_SYMBOL_GPL(ntmp_maft_query_entry); diff --git a/drivers/net/ethernet/freescale/enetc/ntmp_private.h b/drivers/net/ethernet/freescale/enetc/ntmp_private.h index c356060a17bb9..3b16429708653 100644 --- a/drivers/net/ethernet/freescale/enetc/ntmp_private.h +++ b/drivers/net/ethernet/freescale/enetc/ntmp_private.h @@ -69,10 +69,6 @@ struct ntmp_cmn_req_data { ((a) & NTMP_QUERY_ACT)) }; -struct ntmp_cmn_resp_query { - __le32 entry_id; -}; - /* Generic structure for request data by entry ID */ struct ntmp_req_by_eid { struct ntmp_cmn_req_data crd; -- 2.34.1