From: Pei Lee Ling <pei.lee.ling@intel.com>
To: andrew@lunn.ch, netdev@vger.kernel.org
Cc: shubham.das@intel.com, siddaraju.dh@intel.com,
balaji.chintalapalle@intel.com, pei.lee.ling@intel.com
Subject: [RFC PATCH net-next 1/1] ethtool: Add Clear-fec-stats ethtool handler
Date: Mon, 21 Sep 2026 10:46:37 -0500 [thread overview]
Message-ID: <20260921154637.2376544-2-pei.lee.ling@intel.com> (raw)
In-Reply-To: <20260921154637.2376544-1-pei.lee.ling@intel.com>
In high-speed links such as 25G, 100G, and 200G, FEC counters continuously
accumulate over time. When troubleshooting intermittent physical-layer
issues, users need to establish a clean baseline without resetting the
entire device interface. Therefore, this dedicated
FEC counter clear operation avoids unnecessary operational disruptions.
Adding a fec-clear command would also help to standardize the interface
across different network drivers, providing a more consistent and predictable
user experience.
To clear-fec-stats:
ethtool --clear-fec-stats <ETH1>
Signed-off-by: Pei Lee Ling <pei.lee.ling@intel.com>
---
Documentation/netlink/specs/ethtool.yaml | 3 +++
include/linux/ethtool.h | 1 +
include/uapi/linux/ethtool_netlink_generated.h | 1 +
net/ethtool/fec.c | 11 ++++++++++-
net/ethtool/netlink.h | 2 +-
5 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/Documentation/netlink/specs/ethtool.yaml b/Documentation/netlink/specs/ethtool.yaml
index 5dd4d1b5d94b..6943a6280f35 100644
--- a/Documentation/netlink/specs/ethtool.yaml
+++ b/Documentation/netlink/specs/ethtool.yaml
@@ -1312,6 +1312,9 @@ attribute-sets:
name: stats
type: nest
nested-attributes: fec-stat
+ -
+ name: stats-clear
+ type: u8
-
name: module-eeprom
attr-cnt-name: __ethtool-a-module-eeprom-cnt
diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
index 12683b5d125e..d5ec9f415adc 100644
--- a/include/linux/ethtool.h
+++ b/include/linux/ethtool.h
@@ -1319,6 +1319,7 @@ struct ethtool_ops {
void (*get_fec_stats)(struct net_device *dev,
struct ethtool_fec_stats *fec_stats,
struct ethtool_fec_hist *hist);
+ int (*clear_fec_stats)(struct net_device *dev);
int (*get_fecparam)(struct net_device *,
struct ethtool_fecparam *);
int (*set_fecparam)(struct net_device *,
diff --git a/include/uapi/linux/ethtool_netlink_generated.h b/include/uapi/linux/ethtool_netlink_generated.h
index 8134baf7860f..01c5b754c3db 100644
--- a/include/uapi/linux/ethtool_netlink_generated.h
+++ b/include/uapi/linux/ethtool_netlink_generated.h
@@ -595,6 +595,7 @@ enum {
ETHTOOL_A_FEC_AUTO,
ETHTOOL_A_FEC_ACTIVE,
ETHTOOL_A_FEC_STATS,
+ ETHTOOL_A_FEC_STATS_CLEAR,
__ETHTOOL_A_FEC_CNT,
ETHTOOL_A_FEC_MAX = (__ETHTOOL_A_FEC_CNT - 1)
diff --git a/net/ethtool/fec.c b/net/ethtool/fec.c
index e2d539271060..edfa535477cb 100644
--- a/net/ethtool/fec.c
+++ b/net/ethtool/fec.c
@@ -290,10 +290,11 @@ static int fec_fill_reply(struct sk_buff *skb,
/* FEC_SET */
-const struct nla_policy ethnl_fec_set_policy[ETHTOOL_A_FEC_AUTO + 1] = {
+const struct nla_policy ethnl_fec_set_policy[ETHTOOL_A_FEC_MAX + 1] = {
[ETHTOOL_A_FEC_HEADER] = NLA_POLICY_NESTED(ethnl_header_policy),
[ETHTOOL_A_FEC_MODES] = { .type = NLA_NESTED },
[ETHTOOL_A_FEC_AUTO] = NLA_POLICY_MAX(NLA_U8, 1),
+ [ETHTOOL_A_FEC_STATS_CLEAR] = NLA_POLICY_MAX(NLA_U8, 1),
};
static int
@@ -315,6 +316,14 @@ ethnl_set_fec(struct ethnl_req_info *req_info, struct genl_info *info)
u8 fec_auto;
int ret;
+ if (tb[ETHTOOL_A_FEC_STATS_CLEAR]) {
+ if (!dev->ethtool_ops->clear_fec_stats)
+ return -EOPNOTSUPP;
+
+ ret = dev->ethtool_ops->clear_fec_stats(dev);
+ return ret < 0 ? ret : 1;
+ }
+
ret = dev->ethtool_ops->get_fecparam(dev, &fec);
if (ret < 0)
return ret;
diff --git a/net/ethtool/netlink.h b/net/ethtool/netlink.h
index 3e969a070f9f..2a2096066b7d 100644
--- a/net/ethtool/netlink.h
+++ b/net/ethtool/netlink.h
@@ -508,7 +508,7 @@ extern const struct nla_policy ethnl_cable_test_act_policy[ETHTOOL_A_CABLE_TEST_
extern const struct nla_policy ethnl_cable_test_tdr_act_policy[ETHTOOL_A_CABLE_TEST_TDR_CFG + 1];
extern const struct nla_policy ethnl_tunnel_info_get_policy[ETHTOOL_A_TUNNEL_INFO_HEADER + 1];
extern const struct nla_policy ethnl_fec_get_policy[ETHTOOL_A_FEC_HEADER + 1];
-extern const struct nla_policy ethnl_fec_set_policy[ETHTOOL_A_FEC_AUTO + 1];
+extern const struct nla_policy ethnl_fec_set_policy[ETHTOOL_A_FEC_MAX + 1];
extern const struct nla_policy ethnl_module_eeprom_get_policy[ETHTOOL_A_MODULE_EEPROM_I2C_ADDRESS + 1];
extern const struct nla_policy ethnl_stats_get_policy[ETHTOOL_A_STATS_SRC + 1];
extern const struct nla_policy ethnl_phc_vclocks_get_policy[ETHTOOL_A_PHC_VCLOCKS_HEADER + 1];
--
2.43.0
next prev parent reply other threads:[~2026-09-21 15:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-21 15:46 [RFC PATCH net-next 0/1] Add Clear fec-stats ethtool handler Pei Lee Ling
2026-09-21 15:46 ` Pei Lee Ling [this message]
2026-09-21 18:48 ` Andrew Lunn
2026-09-21 20:13 ` 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=20260921154637.2376544-2-pei.lee.ling@intel.com \
--to=pei.lee.ling@intel.com \
--cc=andrew@lunn.ch \
--cc=balaji.chintalapalle@intel.com \
--cc=netdev@vger.kernel.org \
--cc=shubham.das@intel.com \
--cc=siddaraju.dh@intel.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