ethtool: add FEC bins histogramm report
Subsystems (15)
RFC PATCH v2 1/1 ethtool: add FEC bins histogramm report
IEEE 802.3ck-2022 defines counters for FEC bins and 802.3df-2024 clarifies it a bit further. Implement reporting interface through as addition to FEC stats available in ethtool.
---
With this RFC I would like to get early feedback from the community about implementing FEC histogram statistics while we are waiting for some vendors to actually implement it in their drivers. I implemented the simplest solution in netdevsim driver to show how API looks like. The example query is the same as usual FEC statistics while the answer is a bit more verbose:
[vmuser@archvm9 linux]$ ./tools/net/ynl/pyynl/cli.py --spec Documentation/netlink/specs/ethtool.yaml --do fec-get --json '{"header":{"dev-index": 10, "flags": 4}}' {'auto': 0,
'header': {'dev-index': 10, 'dev-name': 'eni10np1'},
'modes': {'bits': {}, 'nomask': True, 'size': 121},
'stats': {'corr-bits': [],
'corrected': [123],
'hist': [{'bin-high': 0,
'bin-low': 0,
'bin-val': 345,
'bin-val-per-lane': [125, 120, 100, 100]},
{'bin-high': 3, 'bin-low': 1, 'bin-val': 12},
{'bin-high': 7, 'bin-low': 4, 'bin-val': 2}],
'uncorr': [4]}}RFC v2:
- adjust yaml spec to avoid nesting histogram attributes and use flexible types
- add support for per-lane histogram together with total values
- remove sentinel (-1, -1) and use (0, 0) as common array break. bin (0, 0) is still possible but only as a first element of ranges array
--- Documentation/netlink/specs/ethtool.yaml | 24 +++++++++ Documentation/networking/ethtool-netlink.rst | 5 ++ .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 3 +- .../ethernet/fungible/funeth/funeth_ethtool.c | 3 +- .../ethernet/hisilicon/hns3/hns3_ethtool.c | 3 +- drivers/net/ethernet/intel/ice/ice_ethtool.c | 3 +- .../marvell/octeontx2/nic/otx2_ethtool.c | 3 +- .../ethernet/mellanox/mlx5/core/en_ethtool.c | 3 +- drivers/net/ethernet/sfc/ethtool.c | 3 +- drivers/net/ethernet/sfc/siena/ethtool.c | 3 +- drivers/net/netdevsim/ethtool.c | 15 +++++- include/linux/ethtool.h | 16 +++++- .../uapi/linux/ethtool_netlink_generated.h | 4 ++ net/ethtool/fec.c | 53 ++++++++++++++++++- 14 files changed, 129 insertions(+), 12 deletions(-)
Documentation/netlink/specs/ethtool.yaml +24 -0
@@ -1239,6 +1239,30 @@ attribute-sets: name: corr-bits type: binary sub-type: u64 + - + name: hist + type: nest + multi-attr: True + nested-attributes: fec-hist + - + name: fec-hist-bin-low + type: uint + - + name: fec-hist-bin-high + type: uint + - + name: fec-hist-bin-val + type: uint + - + name: fec-hist + subset-of: fec-stat + attributes: + - + name: fec-hist-bin-low + - + name: fec-hist-bin-high + - + name: fec-hist-bin-val - name: fec attr-cnt-name: __ethtool-a-fec-cnt
Documentation/networking/ethtool-netlink.rst +5 -0
@@ -1541,6 +1541,11 @@ Drivers fill in the statistics in the following structure: .. kernel-doc:: include/linux/ethtool.h :identifiers: ethtool_fec_stats +Statistics may have FEC bins histogram attribute ``ETHTOOL_A_FEC_STAT_HIST`` +as defined in IEEE 802.3ck-2022 and 802.3df-2024. Nested attributes will have +the range of FEC errors in the bin (inclusive) and the amount of error events +in the bin. + FEC_SET =======
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +2 -1
@@ -3185,7 +3185,8 @@ static int bnxt_get_fecparam(struct net_device *dev, }static void bnxt_get_fec_stats (struct net_device *dev, -struct ethtool_fec_stats *fec_stats) +struct ethtool_fec_stats *fec_stats, +const struct ethtool_fec_hist_range **ranges) {struct bnxt *bp =netdev_priv (dev);u64 *rx;
drivers/net/ethernet/fungible/funeth/funeth_ethtool.c +2 -1
@@ -930,7 +930,8 @@ static void fun_get_rmon_stats(struct net_device *netdev, }static void fun_get_fec_stats (struct net_device *netdev, -struct ethtool_fec_stats *stats) +struct ethtool_fec_stats *stats, +const struct ethtool_fec_hist_range **ranges) {const struct funeth_priv *fp =netdev_priv (netdev);
drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c +2 -1
@@ -1659,7 +1659,8 @@ static void hns3_set_msglevel(struct net_device *netdev, u32 msg_level) }static void hns3_get_fec_stats (struct net_device *netdev, -struct ethtool_fec_stats *fec_stats) +struct ethtool_fec_stats *fec_stats, +const struct ethtool_fec_hist_range **ranges) {struct hnae3_handle *handle =hns3_get_handle (netdev);struct hnae3_ae_dev *ae_dev =hns3_get_ae_dev (handle);
drivers/net/ethernet/intel/ice/ice_ethtool.c +2 -1
@@ -4623,7 +4623,8 @@ static int ice_get_port_fec_stats(struct ice_hw *hw, u16 pcs_quad, u16 pcs_port,* */ static void ice_get_fec_stats (struct net_device *netdev, -struct ethtool_fec_stats *fec_stats) +struct ethtool_fec_stats *fec_stats, +const struct ethtool_fec_hist_range **ranges) {struct ice_netdev_priv *np =netdev_priv (netdev);struct ice_port_topology port_topology;
drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c +2 -1
@@ -1283,7 +1283,8 @@ static int otx2_set_link_ksettings(struct net_device *netdev, }static void otx2_get_fec_stats (struct net_device *netdev, -struct ethtool_fec_stats *fec_stats) +struct ethtool_fec_stats *fec_stats, +const struct ethtool_fec_hist_range **ranges) {struct otx2_nic *pfvf =netdev_priv (netdev);struct cgx_fw_data *rsp;
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +2 -1
@@ -1927,7 +1927,8 @@ static int mlx5e_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol) }static void mlx5e_get_fec_stats (struct net_device *netdev, -struct ethtool_fec_stats *fec_stats) +struct ethtool_fec_stats *fec_stats, +const struct ethtool_fec_hist_range **ranges) {struct mlx5e_priv *priv =netdev_priv (netdev);
drivers/net/ethernet/sfc/ethtool.c +2 -1
@@ -217,7 +217,8 @@ static int efx_ethtool_set_wol(struct net_device *net_dev, }static void efx_ethtool_get_fec_stats (struct net_device *net_dev, -struct ethtool_fec_stats *fec_stats) +struct ethtool_fec_stats *fec_stats, +const struct ethtool_fec_hist_range **ranges) {struct efx_nic *efx =efx_netdev_priv (net_dev);
drivers/net/ethernet/sfc/siena/ethtool.c +2 -1
@@ -217,7 +217,8 @@ static int efx_ethtool_set_wol(struct net_device *net_dev, }static void efx_ethtool_get_fec_stats (struct net_device *net_dev, -struct ethtool_fec_stats *fec_stats) +struct ethtool_fec_stats *fec_stats, +const struct ethtool_fec_hist_range **ranges) {struct efx_nic *efx =netdev_priv (net_dev);
drivers/net/netdevsim/ethtool.c +14 -1
@@ -164,12 +164,25 @@ nsim_set_fecparam(struct net_device *dev, struct ethtool_fecparam *fecparam) ns->ethtool.fec.active_fec =1 << (fls (fec) -1 );return 0 ; } +static const struct ethtool_fec_hist_range netdevsim_fec_ranges[] = { + {0 ,0 }, + {1 ,3 }, + {4 ,7 }, + {-1 ,-1 } +};static void -nsim_get_fec_stats (struct net_device *dev,struct ethtool_fec_stats *fec_stats) +nsim_get_fec_stats (struct net_device *dev,struct ethtool_fec_stats *fec_stats, +const struct ethtool_fec_hist_range **ranges) { + *ranges = netdevsim_fec_ranges; + fec_stats->corrected_blocks.total =123 ; fec_stats->uncorrectable_blocks.total =4 ; + + fec_stats->hist[0 ] =345 ; + fec_stats->hist[1 ] =12 ; + fec_stats->hist[2 ] =2 ; } static int nsim_get_ts_info(struct net_device *dev,
include/linux/ethtool.h +15 -1
@@ -492,6 +492,18 @@ struct ethtool_pause_stats { };#define ETHTOOL_MAX_LANES 8 +#define ETHTOOL_FEC_HIST_MAX 18 +/** +* struct ethtool_fec_hist_range - error bits range for FEC bins histogram +* statistics +* sentinel value of { -1, -1 } is used as marker for end of bins array +* @low: low bound of the bin (inclusive) +* @high: high bound of the bin (inclusive) +*/ +struct ethtool_fec_hist_range { +s16 low; +s16 high; +};/** * struct ethtool_fec_stats - statistics for IEEE 802.3 FEC
@@ -524,6 +536,7 @@ struct ethtool_fec_stats {u64 total;u64 lanes[ETHTOOL_MAX_LANES ]; } corrected_blocks, uncorrectable_blocks, corrected_bits; +u64 hist[ETHTOOL_FEC_HIST_MAX ]; };/**
@@ -1212,7 +1225,8 @@ struct ethtool_ops {int (*set_link_ksettings)(struct net_device *,const struct ethtool_link_ksettings *);void (*get_fec_stats)(struct net_device *dev, -struct ethtool_fec_stats *fec_stats); +struct ethtool_fec_stats *fec_stats, +const struct ethtool_fec_hist_range **ranges);int (*get_fecparam)(struct net_device *,struct ethtool_fecparam *); int (*set_fecparam)(struct net_device *,
include/uapi/linux/ethtool_netlink_generated.h +4 -0
@@ -567,6 +567,10 @@ enum {ETHTOOL_A_FEC_STAT_CORRECTED ,ETHTOOL_A_FEC_STAT_UNCORR ,ETHTOOL_A_FEC_STAT_CORR_BITS , +ETHTOOL_A_FEC_STAT_HIST , +ETHTOOL_A_FEC_STAT_FEC_HIST_BIN_LOW , +ETHTOOL_A_FEC_STAT_FEC_HIST_BIN_HIGH , +ETHTOOL_A_FEC_STAT_FEC_HIST_BIN_VAL , __ETHTOOL_A_FEC_STAT_CNT,ETHTOOL_A_FEC_STAT_MAX = (__ETHTOOL_A_FEC_STAT_CNT -1 )
net/ethtool/fec.c +51 -2
87 lines not on this page · raw message
Signature · 1 line
2.47.3
Jakub Kicinski
maintainerQuoted 3 lines · On Thu, 31 Jul 2025 16:10:19 -0700 Vadim Fedorenko wrote:
- remove sentinel (-1, -1) and use (0, 0) as common array break. bin (0, 0) is still possible but only as a first element of ranges array
I don't see this change in the diff? It's still -1,-1
Also, not seeing per-lane support here.
Quoted 9 lines
Documentation/netlink/specs/ethtool.yaml +1
-0@@ -1239,6 +1239,30 @@ attribute-sets: name: corr-bits type: binary sub-type: u64 + -
Documentation/netlink/specs/ethtool.yaml attribute-sets: · line 1252
Quoted 10 lines
Documentation/netlink/specs/ethtool.yaml +10
-0+ name: hist + type: nest + multi-attr: True + nested-attributes: fec-hist + - + name: fec-hist-bin-low + type: uint + - + name: fec-hist-bin-high + type: uint
The bounds can be u32, TBH. The value really is a u16 but we don't want to waste space on padding in Netlink. Still, no need to go all the way to uint.
Quoted 2 lines
Documentation/netlink/specs/ethtool.yaml +2
-0+ name: fec-hist-bin-val + type: uint
Quoted 8 lines · Jakub Kicinski
Quoted 3 lines · On Thu, 31 Jul 2025 16:10:19 -0700 Vadim Fedorenko wrote:
- remove sentinel (-1, -1) and use (0, 0) as common array break. bin (0, 0) is still possible but only as a first element of ranges array
I don't see this change in the diff? It's still -1,-1
Also, not seeing per-lane support here.
My bad, didn't commit after testing :(
I'll wait 24h and submit v3...
Quoted 15 lines
Quoted 15 lines
Documentation/netlink/specs/ethtool.yaml +7
-0@@ -1239,6 +1239,30 @@ attribute-sets: name: corr-bits type: binary sub-type: u64 + - + name: hist + type: nest + multi-attr: True + nested-attributes: fec-hist + - + name: fec-hist-bin-low
Quoted 8 lines
Documentation/netlink/specs/ethtool.yaml attribute-sets: · line 1252
Quoted 4 lines
Documentation/netlink/specs/ethtool.yaml +4
-0+ type: uint + - + name: fec-hist-bin-high + type: uintThe bounds can be u32, TBH. The value really is a u16 but we don't want to waste space on padding in Netlink. Still, no need to go all the way to uint.
Got it
Quoted 2 lines
Quoted 2 lines
Documentation/netlink/specs/ethtool.yaml +2
-0+ name: fec-hist-bin-val + type: uint