From d69f5fddc1dcec152c150df746374983ef6e66e5 Mon Sep 17 00:00:00 2001 From: np Date: Wed, 10 Oct 2012 20:09:19 +0000 Subject: Add a "clearstats" subcommand to cxgbetool that lets you clear the MAC statistics for any port. For example: # cxgbetool t4nex0 clearstats 0 Submitted by: gnn@ MFC after: 3 days --- tools/tools/cxgbetool/cxgbetool.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tools/tools/cxgbetool/cxgbetool.c b/tools/tools/cxgbetool/cxgbetool.c index 74ebd8c..7d0faa6 100644 --- a/tools/tools/cxgbetool/cxgbetool.c +++ b/tools/tools/cxgbetool/cxgbetool.c @@ -82,6 +82,7 @@ usage(FILE *fp) { fprintf(fp, "Usage: %s [operation]\n", progname); fprintf(fp, + "\tclearstats clear port statistics\n" "\tcontext show an SGE context\n" "\tfilter [ ] ... set a filter\n" "\tfilter delete|clear delete a filter\n" @@ -1578,6 +1579,28 @@ read_i2c(int argc, const char *argv[]) } static int +clearstats(int argc, const char *argv[]) +{ + char *p; + long l; + uint32_t port; + + if (argc != 1) { + warnx("incorrect number of arguments."); + return (EINVAL); + } + + p = str_to_number(argv[0], &l, NULL); + if (*p) { + warnx("invalid port id \"%s\"", argv[0]); + return (EINVAL); + } + port = l; + + return doit(CHELSIO_T4_CLEAR_STATS, &port); +} + +static int run_cmd(int argc, const char *argv[]) { int rc = -1; @@ -1605,6 +1628,8 @@ run_cmd(int argc, const char *argv[]) rc = read_tcb(argc, argv); else if (!strcmp(cmd, "i2c")) rc = read_i2c(argc, argv); + else if (!strcmp(cmd, "clearstats")) + rc = clearstats(argc, argv); else { rc = EINVAL; warnx("invalid command \"%s\"", cmd); -- cgit v1.1