From: <nshettyj@marvell.com>
To: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Cc: Viswajith Murali <viswajithm@marvell.com>,
Nitin Shetty J <nshettyj@marvell.com>,
Jiri Pirko <jiri@resnulli.us>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>, Jonathan Corbet <corbet@lwn.net>,
Shuah Khan <skhan@linuxfoundation.org>,
Sunil Goutham <sgoutham@marvell.com>,
"Ratheesh Kannoth" <rkannoth@marvell.com>,
Geetha sowjanya <gakula@marvell.com>,
Subbaraya Sundeep <sbhatta@marvell.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
Bharat Bhushan <bbhushan2@marvell.com>
Subject: [PATCH net-next] octeontx2-pf: add devlink param to reset MAC stats
Date: Fri, 14 Aug 2026 16:12:55 +0530 [thread overview]
Message-ID: <20260814104256.743844-1-nshettyj@marvell.com> (raw)
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
next reply other threads:[~2026-08-14 10:43 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-14 10:42 nshettyj [this message]
2026-08-14 17:01 ` [PATCH net-next] octeontx2-pf: add devlink param to reset MAC stats Jakub Kicinski
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=20260814104256.743844-1-nshettyj@marvell.com \
--to=nshettyj@marvell.com \
--cc=andrew+netdev@lunn.ch \
--cc=bbhushan2@marvell.com \
--cc=corbet@lwn.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gakula@marvell.com \
--cc=horms@kernel.org \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=rkannoth@marvell.com \
--cc=sbhatta@marvell.com \
--cc=sgoutham@marvell.com \
--cc=skhan@linuxfoundation.org \
--cc=viswajithm@marvell.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