* [RFC PATCH net-next 1/1] ethtool: Add Clear-fec-stats ethtool handler
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
2026-09-21 18:48 ` [RFC PATCH net-next 0/1] Add Clear fec-stats " Andrew Lunn
2026-09-21 20:13 ` Jakub Kicinski
2 siblings, 0 replies; 4+ messages in thread
From: Pei Lee Ling @ 2026-09-21 15:46 UTC (permalink / raw)
To: andrew, netdev
Cc: shubham.das, siddaraju.dh, balaji.chintalapalle, pei.lee.ling
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
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [RFC PATCH net-next 0/1] Add Clear fec-stats ethtool handler
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 ` [RFC PATCH net-next 1/1] ethtool: Add Clear-fec-stats " Pei Lee Ling
@ 2026-09-21 18:48 ` Andrew Lunn
2026-09-21 20:13 ` Jakub Kicinski
2 siblings, 0 replies; 4+ messages in thread
From: Andrew Lunn @ 2026-09-21 18:48 UTC (permalink / raw)
To: Pei Lee Ling; +Cc: netdev, shubham.das, siddaraju.dh, balaji.chintalapalle
On Mon, Sep 21, 2026 at 10:46:36AM -0500, Pei Lee Ling wrote:
> ethtool: Add Clear fec-stats ethtool handler
>
> During optical cable re-seating, transceiver swaps, or Bit Error Rate (BER)
> troubleshooting on 25G/100G/400G+ links, operators need to establish
> a clean baseline for physical-layer FEC error counters (corrected/uncorrectable blocks).
>
> Introduce a standardized netlink fec-clear operation using the ETHTOOL_MSG_FEC_SET
> message type with an ETHTOOL_A_FEC_STATS_CLEAR attribute.
What makes FEC statistic counters special? As far as i know, no other
network statistic can be set back to zero.
Because no other statistic can be reset, user space already has the
code to handle delta in counters when needed.
Andrew
^ permalink raw reply [flat|nested] 4+ messages in thread