All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] octeontx2-pf: add devlink param to reset MAC stats
@ 2026-08-14 10:42 nshettyj
  2026-08-14 17:01 ` Jakub Kicinski
  0 siblings, 1 reply; 2+ messages in thread
From: nshettyj @ 2026-08-14 10:42 UTC (permalink / raw)
  To: netdev, linux-kernel
  Cc: Viswajith Murali, Nitin Shetty J, Jiri Pirko, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
	Jonathan Corbet, Shuah Khan, Sunil Goutham, Ratheesh Kannoth,
	Geetha sowjanya, Subbaraya Sundeep, Andrew Lunn, Bharat Bhushan

From: Viswajith Murali <viswajithm@marvell.com>

Add a runtime devlink parameter to reset CGX/RPM MAC hardware
statistics.

Signed-off-by: Nitin Shetty J <nshettyj@marvell.com>
Signed-off-by: Viswajith Murali <viswajithm@marvell.com>
---
 .../networking/devlink/octeontx2.rst          |  9 +++++
 .../ethernet/marvell/octeontx2/af/rvu_cgx.c   |  2 +-
 .../marvell/octeontx2/nic/otx2_devlink.c      | 39 +++++++++++++++++++
 3 files changed, 49 insertions(+), 1 deletion(-)

diff --git a/Documentation/networking/devlink/octeontx2.rst b/Documentation/networking/devlink/octeontx2.rst
index 84206537aedb..1463cb52ae54 100644
--- a/Documentation/networking/devlink/octeontx2.rst
+++ b/Documentation/networking/devlink/octeontx2.rst
@@ -77,3 +77,12 @@ The ``octeontx2 PF`` driver implements the following driver-specific parameters.
      - Set the maximum number of unicast filters that can be programmed for
        the device. This can be used to achieve better device resource
        utilization, avoiding over consumption of unused MCAM table entries.
+   * - ``mac_stats_reset``
+     - bool
+     - runtime
+     - One-shot trigger to reset CGX/RPM MAC hardware statistics.
+       Write true to reset the counters; reading this parameter always returns
+       false. Supported only on CGX/RPM mapped PF netdevs. The reset fails with
+       ``-EBUSY`` when the CGX port is in use by more than one interface, such
+       as when the PF netdev and one or more VF netdevs are active. Other
+       failures return ``-EIO``.
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c
index 87d21889dc49..7e09ca25101d 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c
@@ -649,7 +649,7 @@ int rvu_mbox_handler_cgx_stats_rst(struct rvu *rvu, struct msg_req *req,
 	 */
 	if (parent_pf->cgx_users > 1) {
 		dev_info(rvu->dev, "CGX busy, could not reset statistics\n");
-		return 0;
+		return -EBUSY;
 	}
 
 	rvu_get_cgx_lmac_id(rvu->pf2cgxlmac_map[pf], &cgx_idx, &lmac);
diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_devlink.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_devlink.c
index 4a5ce0e67dda..daa8fb37f392 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_devlink.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_devlink.c
@@ -125,10 +125,43 @@ static int otx2_dl_ucast_flt_cnt_validate(struct devlink *devlink, u32 id,
 	return 0;
 }
 
+static int otx2_dl_mac_stats_reset_get(struct devlink *devlink, u32 id,
+				       struct devlink_param_gset_ctx *ctx,
+				       struct netlink_ext_ack *extack)
+{
+	/* This is a one-shot trigger, so it has no state */
+	ctx->val.vbool = false;
+	return 0;
+}
+
+static int otx2_dl_mac_stats_reset_set(struct devlink *devlink, u32 id,
+				       struct devlink_param_gset_ctx *ctx,
+				       struct netlink_ext_ack *extack)
+{
+	struct otx2_devlink *otx2_dl = devlink_priv(devlink);
+	struct otx2_nic *pfvf = otx2_dl->pfvf;
+	int err;
+
+	if (!ctx->val.vbool)
+		return 0;
+
+	err = otx2_reset_mac_stats(pfvf);
+	if (err == -EBUSY) {
+		NL_SET_ERR_MSG_MOD(extack,
+				   "CGX port shared by multiple interfaces, cannot reset MAC stats");
+		return -EBUSY;
+	} else if (err) {
+		return -EIO;
+	}
+
+	return 0;
+}
+
 enum otx2_dl_param_id {
 	OTX2_DEVLINK_PARAM_ID_BASE = DEVLINK_PARAM_GENERIC_ID_MAX,
 	OTX2_DEVLINK_PARAM_ID_MCAM_COUNT,
 	OTX2_DEVLINK_PARAM_ID_UCAST_FLT_CNT,
+	OTX2_DEVLINK_PARAM_ID_MAC_STATS_RST,
 };
 
 static const struct devlink_param otx2_dl_params[] = {
@@ -142,6 +175,12 @@ static const struct devlink_param otx2_dl_params[] = {
 			     BIT(DEVLINK_PARAM_CMODE_RUNTIME),
 			     otx2_dl_ucast_flt_cnt_get, otx2_dl_ucast_flt_cnt_set,
 			     otx2_dl_ucast_flt_cnt_validate),
+	DEVLINK_PARAM_DRIVER(OTX2_DEVLINK_PARAM_ID_MAC_STATS_RST,
+			     "mac_stats_reset", DEVLINK_PARAM_TYPE_BOOL,
+			     BIT(DEVLINK_PARAM_CMODE_RUNTIME),
+			     otx2_dl_mac_stats_reset_get,
+			     otx2_dl_mac_stats_reset_set,
+			     NULL),
 };
 
 #ifdef CONFIG_RVU_ESWITCH
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net-next] octeontx2-pf: add devlink param to reset MAC stats
  2026-08-14 10:42 [PATCH net-next] octeontx2-pf: add devlink param to reset MAC stats nshettyj
@ 2026-08-14 17:01 ` Jakub Kicinski
  0 siblings, 0 replies; 2+ messages in thread
From: Jakub Kicinski @ 2026-08-14 17:01 UTC (permalink / raw)
  To: nshettyj
  Cc: netdev, linux-kernel, Viswajith Murali, Jiri Pirko,
	David S. Miller, Eric Dumazet, Paolo Abeni, Simon Horman,
	Jonathan Corbet, Shuah Khan, Sunil Goutham, Ratheesh Kannoth,
	Geetha sowjanya, Subbaraya Sundeep, Andrew Lunn, Bharat Bhushan

On Fri, 14 Aug 2026 16:12:55 +0530 nshettyj@marvell.com wrote:
> Add a runtime devlink parameter to reset CGX/RPM MAC hardware
> statistics.

parameters are not actions, you should be looking at reset APIs.
There's already one for resetting netdev blocks via ethtool
-- 
pw-bot: cr

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-08-14 17:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-14 10:42 [PATCH net-next] octeontx2-pf: add devlink param to reset MAC stats nshettyj
2026-08-14 17:01 ` Jakub Kicinski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.