ethtool: Add clear FEC stats Support
Subsystems (2)
RFC PATCH 1/1 ethtool: Add clear FEC stats Support
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-stats-clear operation avoids unnecessary operational disruptions.
Introducing a fec-clear command would also help to standardize behavior 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 <[email protected]>
--- ethtool.c | 5 ++++ netlink/extapi.h | 2 ++ netlink/fec.c | 40 ++++++++++++++++++++++++++ uapi/linux/ethtool_netlink_generated.h | 1 + 4 files changed, 48 insertions(+)
ethtool.c +5 -0
@@ -6389,6 +6389,11 @@ static const struct option args[] = { .help = "Set FEC settings", .xhelp = " [ encoding auto|off|rs|baser|llrs [...] ]\n" }, + { + .opts = "--clear-fec-stats", + .nlfunc = nl_cfecstats, + .help = "Clear FEC statistics", + }, { .opts = "-Q|--per-queue", .func = do_perqueue,
netlink/extapi.h +2 -0
@@ -43,6 +43,7 @@ int nl_cable_test_tdr(struct cmd_context *ctx);int nl_gtunnels (struct cmd_context *ctx);int nl_gfec (struct cmd_context *ctx);int nl_sfec (struct cmd_context *ctx); +int nl_cfecstats (struct cmd_context *ctx);bool nl_gstats_chk (struct cmd_context *ctx);int nl_gstats (struct cmd_context *ctx);int nl_gmodule (struct cmd_context *ctx);
@@ -124,6 +125,7 @@ nl_get_eeprom_page(struct cmd_context *ctx __maybe_unused,#define nl_gtunnels NULL#define nl_gfec NULL#define nl_sfec NULL +#define nl_cfecstats NULL#define nl_gstats_chk NULL#define nl_gstats NULL#define nl_getmodule NULL
netlink/fec.c +40 -0
@@ -438,3 +438,43 @@ int nl_sfec(struct cmd_context *ctx)else return nlctx->exit_code ?:83 ; } + +/* FEC_STATS_CLEAR */ + +int nl_cfecstats (struct cmd_context *ctx) +{ +struct nl_context *nlctx = ctx->nlctx; +struct nl_msg_buff *msgbuff; +struct nl_socket *nlsk; +u32 flags =0 ; +int ret; + +if (netlink_cmd_check (ctx,ETHTOOL_MSG_FEC_SET , false)) +return -EOPNOTSUPP ; + + nlctx->devname = ctx->devname; + nlsk = nlctx->ethnl_socket; + msgbuff = &nlsk->msgbuff; + + ret =msg_init (nlctx, msgbuff,ETHTOOL_MSG_FEC_SET , +NLM_F_REQUEST |NLM_F_ACK ); +if (ret <0 ) +return 2 ; + +if (ethnla_fill_header (msgbuff,ETHTOOL_A_FEC_HEADER , + ctx->devname,0 )) +return -EMSGSIZE ; + +if (ethnla_put_u8 (msgbuff,ETHTOOL_A_FEC_STATS_CLEAR , flags)) +return -EMSGSIZE ; + + ret =nlsock_sendmsg (nlsk,NULL ); +if (ret <0 ) +return 83 ; + + ret =nlsock_process_reply (nlsk, nomsg_reply_cb, nlctx); +if (ret ==0 ) +return 0 ; +else +return nlctx->exit_code ?:83 ; +}
uapi/linux/ethtool_netlink_generated.h +1 -0
@@ -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 )
Signature · 1 line
2.43.0