This patch adds a new '--lesb' option to the fcoeadm. This option will print a header and then repeatedly list the Link Error Statistics Block information for an interface. This command behaves in the same way as the '--stats' option currently does.
As an aside, should fcoeadm repeat the statistics or should it just print once and then the user could use 'watch' to repeat the operation at an interval? Please check the man page or '--help' for usage. Signed-off-by: Robert Love <[email protected]> Tested-by: Ross Brattain <[email protected]> --- doc/fcoeadm.8 | 13 ++++++++++++ doc/fcoeadm.txt | 10 +++++++++ fcoeadm.c | 27 +++++++++++++++++++++++- fcoeadm_display.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++ fcoeadm_display.h | 2 ++ 5 files changed, 110 insertions(+), 1 deletion(-) diff --git a/doc/fcoeadm.8 b/doc/fcoeadm.8 index e04291f..2a696b3 100644 --- a/doc/fcoeadm.8 +++ b/doc/fcoeadm.8 @@ -47,6 +47,8 @@ fcoeadm \- The Open\-FCoE Administration Tool .sp \fBfcoeadm\fR \-s|\-\-stats \fIethX\fR [\fIinterval\fR] .sp +\fBfcoeadm\fR \-b|\-\-lesb \fIethX\fR [\fIinterval\fR] +.sp \fBfcoeadm\fR \-h|\-\-help .sp \fBfcoeadm\fR \-v|\-\-version @@ -107,6 +109,17 @@ should be specified in whole integers greater than 0\&. It specifies the time in is not specified, the default interval is one second\&. .RE .PP +\fB\-b\fR, \fB\-\-lesb\fR \fIethX\fR [\fIinterval\fR] +.RS 4 +Show the Link Error Statistics Block (LESB) of the FCoE connection on the specified network interface\&. The information will be displayed repeatedly until the user cancels the command\&. The LESB statistics will be printed every specified +\fIinterval\fR +(in seconds)\&. +\fIinterval\fR +should be specified in whole integers greater than 0\&. If the +\fIinterval\fR +is not specified, a default interval of one second is used\&. +.RE +.PP \fB\-h\fR, \fB\-\-help\fR .RS 4 Displays the usage message of the diff --git a/doc/fcoeadm.txt b/doc/fcoeadm.txt index 3624a45..4069978 100644 --- a/doc/fcoeadm.txt +++ b/doc/fcoeadm.txt @@ -37,6 +37,8 @@ SYNOPSIS *fcoeadm* -s|--stats _ethX_ [_interval_] +*fcoeadm* -b|--lesb _ethX_ [_interval_] + *fcoeadm* -h|--help *fcoeadm* -v|--version @@ -105,6 +107,14 @@ OPTIONS seconds. If _interval_ is not specified, the default interval is one second. +*-b*, *--lesb* _ethX_ [_interval_]:: + Show the Link Error Statistics Block (LESB) of the FCoE connection + on the specified network interface. The information will be displayed + repeatedly until the user cancels the command. The LESB statistics + will be printed every specified _interval_ (in seconds). _interval_ + should be specified in whole integers greater than 0. If the + _interval_ is not specified, a default interval of one second is used. + *-h*, *--help*:: Displays the usage message of the *fcoeadm* command. diff --git a/fcoeadm.c b/fcoeadm.c index 0784ccd..795b12a 100644 --- a/fcoeadm.c +++ b/fcoeadm.c @@ -33,7 +33,7 @@ #include "fcoe_clif.h" #include "fcoeadm_display.h" -static const char *optstring = "c:d:r:S:iftlshv"; +static const char *optstring = "c:d:r:S:iftlsbhv"; static struct option fcoeadm_opts[] = { {"create", required_argument, 0, 'c'}, {"destroy", required_argument, 0, 'd'}, @@ -44,6 +44,7 @@ static struct option fcoeadm_opts[] = { {"target", no_argument, 0, 't'}, {"lun", no_argument, 0, 'l'}, {"stats", no_argument, 0, 's'}, + {"lesb", no_argument, 0, 'b'}, {"help", no_argument, 0, 'h'}, {"version", no_argument, 0, 'v'}, {0, 0, 0, 0} @@ -64,6 +65,7 @@ static void fcoeadm_help(void) "\t [-t|--target] [<ethX>]\n" "\t [-l|--lun] [<ethX>]\n" "\t [-s|--stats] <ethX> [<interval>]\n" + "\t [-b|--lesb] <ethX> [<interval>]\n" "\t [-v|--version]\n" "\t [-h|--help]\n\n", progname); } @@ -356,6 +358,29 @@ int main(int argc, char *argv[]) rc = display_port_stats(ifname, stat_interval); break; + case 'b': + if (argc > 4) { + rc = EBADNUMARGS; + break; + } + + if (optind != argc) { + ifname = argv[optind]; + rc = fcoe_validate_fcoe_conn(ifname); + } + + if (!rc && ++optind != argc) { + stat_interval = atoi(argv[optind]); + if (stat_interval <= 0) + rc = EINVALARG; + } else if (!rc && optind == argc) + stat_interval = DEFAULT_STATS_INTERVAL; + + if (!rc) + rc = display_port_lesb_stats(ifname, + stat_interval); + break; + case 'v': if (argc > 2) { rc = EBADNUMARGS; diff --git a/fcoeadm_display.c b/fcoeadm_display.c index e973065..56401dc 100644 --- a/fcoeadm_display.c +++ b/fcoeadm_display.c @@ -1469,3 +1469,62 @@ enum fcoe_status display_fcf_info(const char *ifname) return rc; } + +void print_interface_fcoe_lesb_stats(void *ep, void *arg) +{ + struct fcoe_ctlr_device *ctlr = (struct fcoe_ctlr_device *)ep; + const char *ifname = arg; + + if (!ifname || !strncmp(ifname, ctlr->ifname, IFNAMSIZ)) { + printf("%-8u ", ctlr->lesb_link_fail); + printf("%-9u ", ctlr->lesb_vlink_fail); + printf("%-7u ", ctlr->lesb_miss_fka); + printf("%-7u ", ctlr->lesb_symb_err); + printf("%-9u ", ctlr->lesb_err_block); + printf("%-9u ", ctlr->lesb_fcs_error); + printf("\n"); + } +} + +void print_interface_fcoe_lesb_stats_header(const char *ifname, + int interval) +{ + printf("\n"); + printf("%-7s interval: %-2d\n", ifname, interval); + printf("LinkFail VLinkFail MissFKA SymbErr ErrBlkCnt FCSErrCnt\n"); + printf("-------- --------- ------- ------- --------- ---------\n"); +} + +enum fcoe_status display_port_lesb_stats(const char *ifname, + int interval) +{ + enum fcoe_status rc = SUCCESS; + int i = 0; + + while (1) { + unsigned int secs_left; + + sa_table_init(&fcoe_ctlr_table); + read_fcoe_ctlr(&fcoe_ctlr_table); + + if (!(i % 52)) + print_interface_fcoe_lesb_stats_header(ifname, + interval); + + sa_table_iterate(&fcoe_ctlr_table, + print_interface_fcoe_lesb_stats, + (void *)ifname); + + sa_table_iterate(&fcoe_ctlr_table, + free_fcoe_ctlr_device, NULL); + + i++; + + secs_left = interval; + do { + secs_left = sleep(secs_left); + } while (secs_left); + } + + return rc; +} diff --git a/fcoeadm_display.h b/fcoeadm_display.h index 10c78f2..358abf3 100644 --- a/fcoeadm_display.h +++ b/fcoeadm_display.h @@ -33,5 +33,7 @@ enum fcoe_status display_target_info(const char *ifname, enum disp_style style); enum fcoe_status display_port_stats(const char *ifname, int stat_interval); +enum fcoe_status display_port_lesb_stats(const char *ifname, + int stat_interval); #endif /* _FCOEADM_DISPLAY_H_ */ _______________________________________________ devel mailing list [email protected] https://lists.open-fcoe.org/mailman/listinfo/devel
