ethtool: Support ETHTOOL_GSTATS2 API.
Subsystems (2)
PATCH 1/1 ethtool: Support ETHTOOL_GSTATS2 API.
From: Ben Greear <[email protected]>
This allows users to specify flags to the get-stats API, potentially saving expensive stats queries when they are not desired.
Signed-off-by Ben Greear <[email protected]>
--- ethtool-copy.h | 9 +++++++++ ethtool.c | 25 ++++++++++++++++++++----- 2 files changed, 29 insertions(+), 5 deletions(-)
ethtool-copy.h +9 -0
@@ -1390,11 +1390,20 @@ enum ethtool_fec_config_bits {#define ETHTOOL_PHY_STUNABLE 0x0000004f/* Set PHY tunable configuration */ #define ETHTOOL_GFECPARAM 0x00000050/* Get FEC settings */ #define ETHTOOL_SFECPARAM 0x00000051/* Set FEC settings */ +#define ETHTOOL_GSTATS2 0x00000052/* get NIC-specific statistics +* with ability to specify flags. +* See ETHTOOL_GS2* below. +*/ /* compatibility with older code */ #define SPARC_ETH_GSET ETHTOOL_GSET#define SPARC_ETH_SSET ETHTOOL_SSET +/* GSTATS2 flags */ +#define ETHTOOL_GS2_SKIP_NONE (0)/* default is to update all stats */ +#define ETHTOOL_GS2_SKIP_FW (1<<0)/* Skip reading stats that probe firmware, +* and thus are slow/expensive. +*/ /* Link mode bit indices */ enum ethtool_link_mode_bit_indices { ETHTOOL_LINK_MODE_10baseT_Half_BIT =0 ,
ethtool.c +20 -5
@@ -3440,14 +3440,14 @@ static int do_phys_id(struct cmd_context *ctx) }static int do_gstats (struct cmd_context *ctx,int cmd,int stringset, -const char *name) +const char *name,u32 flags) {struct ethtool_gstrings *strings;struct ethtool_stats *stats;unsigned int n_stats, sz_stats, i;int err; -if (ctx->argc !=0 ) +if ((ctx->argc !=0 ) && (flags ==ETHTOOL_GS2_SKIP_NONE ))exit_bad_args (); strings = get_stringset(ctx, stringset,
@@ -3475,7 +3475,10 @@ static int do_gstats(struct cmd_context *ctx, int cmd, int stringset, } stats->cmd = cmd; - stats->n_stats = n_stats; +if (cmd ==ETHTOOL_GSTATS2 ) + stats->n_stats = flags; +else + stats->n_stats = n_stats; err =send_ioctl (ctx, stats);if (err <0 ) {perror ("Cannot get stats information" );
@@ -3500,12 +3503,22 @@ static int do_gstats(struct cmd_context *ctx, int cmd, int stringset,static int do_gnicstats (struct cmd_context *ctx) { -return do_gstats (ctx,ETHTOOL_GSTATS ,ETH_SS_STATS ,"NIC" ); +return do_gstats (ctx,ETHTOOL_GSTATS ,ETH_SS_STATS ,"NIC" ,ETHTOOL_GS2_SKIP_NONE ); +} + +static int do_gnicstats2 (struct cmd_context *ctx) +{ +u32 flags =ETHTOOL_GS2_SKIP_NONE ; +if (ctx->argc >=1 ) +if (strcmp (ctx->argp[0 ],"nofw" ) ==0 ) + flags |=ETHTOOL_GS2_SKIP_FW ; +return do_gstats (ctx,ETHTOOL_GSTATS2 ,ETH_SS_STATS ,"NIC" , flags); }static int do_gphystats (struct cmd_context *ctx) { -return do_gstats (ctx,ETHTOOL_GPHYSTATS ,ETH_SS_PHY_STATS ,"PHY" ); +return do_gstats (ctx,ETHTOOL_GPHYSTATS ,ETH_SS_PHY_STATS ,"PHY" , +ETHTOOL_GS2_SKIP_NONE ); } static int do_srxntuple(struct cmd_context *ctx,
@@ -5118,6 +5131,8 @@ static const struct option { {"-t|--test" ,1 , do_test,"Execute adapter self test" , " [ online | offline | external_lb ]\n" }, { "-S|--statistics", 1, do_gnicstats, "Show adapter statistics" }, + { "-2|--S2", 1, do_gnicstats2, "Show adapter statistics with flags", + " [ nofw ]\n" }, { "--phy-statistics", 1, do_gphystats, "Show phy statistics" }, { "-n|-u|--show-nfc|--show-ntuple", 1, do_grxclass,
Signature · 1 line
2.4.11