[PATCH net-next 12/14] net: enetc: convert ntmp_ect_update_entry() to the generic update helper
wei.fang at oss.nxp.com
wei.fang at oss.nxp.com
Thu Dec 3 23:14:08 PST 2026
From: Wei Fang <wei.fang at 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 at 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
More information about the linux-arm-kernel
mailing list