Netdev List
 help / color / mirror / Atom feed
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 12/14] net: enetc: convert ntmp_ect_update_entry() to the generic update helper
Date: Fri,  4 Dec 2026 15:14:08 +0800	[thread overview]
Message-ID: <20261204071410.692071-13-wei.fang@oss.nxp.com> (raw)
In-Reply-To: <20261204071410.692071-1-wei.fang@oss.nxp.com>

From: Wei Fang <wei.fang@nxp.com>

ntmp_ect_update_entry() still open-codes the update sequence while the
other tables now route through ntmp_update_entry_by_id(). To let the
Egress Count Table (ECT) reuse the generic helper, it needs a table ops
instance.

Add ect_ops_v0 and register it in ntmp_table_ops(). The ECT is a static
bounded-index table whose entries are always present, so it has no "Add"
operation, and its "Update" only resets the counter with no CFGE_DATA to
carry, hence its pack() callback is empty. Convert ntmp_ect_update_entry()
to call ntmp_update_entry_by_id(), which removes the duplicated
boilerplate.

Signed-off-by: Wei Fang <wei.fang@nxp.com>
---
 drivers/net/ethernet/freescale/enetc/ntmp.c | 58 ++++++++++-----------
 1 file changed, 29 insertions(+), 29 deletions(-)

diff --git a/drivers/net/ethernet/freescale/enetc/ntmp.c b/drivers/net/ethernet/freescale/enetc/ntmp.c
index a0605f0d0b106..3f8a39df78b6f 100644
--- a/drivers/net/ethernet/freescale/enetc/ntmp.c
+++ b/drivers/net/ethernet/freescale/enetc/ntmp.c
@@ -608,6 +608,31 @@ static const struct ntmp_tbl_ops *ntmp_get_ett_ops(u8 version)
 	}
 }
 
+static void ntmp_ect_pack_v0(const void *entry, void *buf, int access_method)
+{
+	/* Egress Count table is a static bounded index table, its entries
+	 * are always present, so it does not support "Add" operation. The
+	 * "Update" operation only resets the counter, so there is no
+	 * CFGE_DATA to be updated. Therefore, there's no need to pack any
+	 * data here.
+	 */
+}
+
+static const struct ntmp_tbl_ops ect_ops_v0 = {
+	.req_ua_len = sizeof(struct ntmp_req_by_eid),
+	.pack = ntmp_ect_pack_v0,
+};
+
+static const struct ntmp_tbl_ops *ntmp_get_ect_ops(u8 version)
+{
+	switch (version) {
+	case NTMP_TBL_V(0):
+		return &ect_ops_v0;
+	default:
+		return NULL;
+	}
+}
+
 static void ntmp_bpt_pack_v0(const void *entry, void *buf, int access_method)
 {
 	const struct bpt_entry_data *_entry = entry;
@@ -653,6 +678,8 @@ static const struct ntmp_tbl_ops *ntmp_table_ops(int tbl_id, u8 version)
 		return ntmp_get_vft_ops(version);
 	case NTMP_ETT_ID:
 		return ntmp_get_ett_ops(version);
+	case NTMP_ECT_ID:
+		return ntmp_get_ect_ops(version);
 	case NTMP_BPT_ID:
 		return ntmp_get_bpt_ops(version);
 	default:
@@ -1594,35 +1621,8 @@ EXPORT_SYMBOL_GPL(ntmp_ett_delete_entry);
  */
 int ntmp_ect_update_entry(struct ntmp_user *user, u32 entry_id)
 {
-	struct ntmp_req_by_eid *req;
-	struct netc_swcbd swcbd;
-	struct netc_cbdr *cbdr;
-	union netc_cbd cbd;
-	int err;
-
-	swcbd.size = sizeof(*req);
-	err = ntmp_alloc_data_mem(user->dev, &swcbd, (void **)&req);
-	if (err)
-		return err;
-
-	/* Request data */
-	ntmp_fill_crd_eid(req, user->tbl_ver[NTMP_ECT_ID], 0,
-			  ECT_UA_STSEU, entry_id);
-
-	/* Request header */
-	ntmp_fill_request_hdr(&cbd, swcbd.dma, NTMP_LEN(swcbd.size, 0),
-			      NTMP_ECT_ID, NTMP_CMD_UPDATE, 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 update %s entry 0x%x, err: %pe\n",
-			ntmp_table_name(NTMP_ECT_ID), entry_id, ERR_PTR(err));
-
-	ntmp_unlock_cbdr(cbdr);
-
-	return err;
+	return ntmp_update_entry_by_id(user, NTMP_ECT_ID, entry_id, NULL,
+				       ECT_UA_STSEU, 0);
 }
 EXPORT_SYMBOL_GPL(ntmp_ect_update_entry);
 
-- 
2.34.1


  parent reply	other threads:[~2026-12-04  7:10 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04  7:13 [PATCH net-next 00/14] net: enetc: refactor NTMP table handling and add generic helpers wei.fang
2026-12-04  7:13 ` [PATCH net-next 01/14] net: enetc: use an ID-indexed array to track NTMP table versions wei.fang
2026-12-04  7:13 ` [PATCH net-next 02/14] net: enetc: decouple MAFT logical config from hardware wire format wei.fang
2026-12-04  7:13 ` [PATCH net-next 03/14] net: enetc: decouple IPFT " wei.fang
2026-12-04  7:14 ` [PATCH net-next 04/14] net: enetc: decouple FDBT " wei.fang
2026-12-04  7:14 ` [PATCH net-next 05/14] net: enetc: decouple VFT " wei.fang
2026-12-04  7:14 ` [PATCH net-next 06/14] net: enetc: decouple ETT " wei.fang
2026-12-04  7:14 ` [PATCH net-next 07/14] net: enetc: decouple BPT " wei.fang
2026-12-04  7:14 ` [PATCH net-next 08/14] net: enetc: add generic ntmp_add_entry_by_id() helper wei.fang
2026-12-04  7:14 ` [PATCH net-next 09/14] net: enetc: simplify callers of ntmp_query_entry_by_id() wei.fang
2026-12-04  7:14 ` [PATCH net-next 10/14] net: enetc: add kernel-doc for ntmp_delete_entry_by_id() wei.fang
2026-12-04  7:14 ` [PATCH net-next 11/14] net: enetc: add a generic helper to update an NTMP entry by entry ID wei.fang
2026-12-04  7:14 ` wei.fang [this message]
2026-12-04  7:14 ` [PATCH net-next 13/14] net: enetc: add a generic helper to add an NTMP entry by key wei.fang
2026-12-04  7:14 ` [PATCH net-next 14/14] net: enetc: convert the RSST to the generic NTMP entry helpers wei.fang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261204071410.692071-13-wei.fang@oss.nxp.com \
    --to=wei.fang@oss.nxp.com \
    --cc=andrew@lunn.ch \
    --cc=chleroy@kernel.org \
    --cc=claudiu.manoil@nxp.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=imx@lists.linux.dev \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=pabeni@redhat.com \
    --cc=richardcochran@gmail.com \
    --cc=vladimir.oltean@nxp.com \
    --cc=wei.fang@nxp.com \
    --cc=xiaoning.wang@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox