This patch adds the '-f|--fcfs' option to the fcoeadm application. These options allow the user to list the discovered Fibre Channel Forwarders (FCFs).
Please see the man page update or --help for usage. This patch also reorders the options as they are listed so that 'interface', 'fcfs', 'target' and 'lun' are grouped together. Previously, 'scan' was between 'interface' and 'target'. It seemed to make more sense to have 'scan' closer to 'reset' and not in the middle of the FCoE instance listing progression. Signed-off-by: Robert Love <[email protected]> Tested-by: Ross Brattain <[email protected]> --- doc/fcoeadm.8 | 28 +++++++++++++++++----- doc/fcoeadm.txt | 17 +++++++++---- fcoeadm.c | 24 ++++++++++++++++++- fcoeadm_display.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++ fcoeadm_display.h | 1 + 5 files changed, 126 insertions(+), 12 deletions(-) diff --git a/doc/fcoeadm.8 b/doc/fcoeadm.8 index 3df0082..e04291f 100644 --- a/doc/fcoeadm.8 +++ b/doc/fcoeadm.8 @@ -1,13 +1,22 @@ '\" t .\" Title: fcoeadm .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/> -.\" Date: 10/18/2011 +.\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/> +.\" Date: 01/30/2012 .\" Manual: Open-FCoE Tools .\" Source: Open-FCoE .\" Language: English .\" -.TH "FCOEADM" "8" "10/18/2011" "Open\-FCoE" "Open\-FCoE Tools" +.TH "FCOEADM" "8" "01/30/2012" "Open\-FCoE" "Open\-FCoE Tools" +.\" ----------------------------------------------------------------- +.\" * Define some portability stuff +.\" ----------------------------------------------------------------- +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.\" http://bugs.debian.org/507673 +.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- @@ -26,9 +35,11 @@ fcoeadm \- The Open\-FCoE Administration Tool .sp \fBfcoeadm\fR \-r|\-\-reset \fIethX\fR .sp +\fBfcoeadm\fR \-S|\-\-Scan [\fIethX\fR] +.sp \fBfcoeadm\fR \-i|\-\-interface [\fIethX\fR] .sp -\fBfcoeadm\fR \-S|\-\-Scan [\fIethX\fR] +\fBfcoeadm\fR \-f|\-\-fcfs [\fIethX\fR] .sp \fBfcoeadm\fR \-t|\-\-target [\fIethX\fR] .sp @@ -62,14 +73,19 @@ Destroys the FCoE instance on the specified network interface\&. This will not d Resets the FCoE instance on the specified network interface\&. This will not reset FCoE instances created by fipvlan\&. .RE .PP +\fB\-S\fR, \fB\-\-Scan\fR \fIethX\fR +.RS 4 +Rescan for new targets and LUNs on the provided instance\&. This command will not rescan any NPIV instances created on the same port\&. This will not rescan any FCoE instance created by fipvlan\&. +.RE +.PP \fB\-i\fR, \fB\-\-interface\fR [\fIethX\fR] .RS 4 Show information about the FCoE instance on the specified network interface, or all FCoE instances if no network interface is specified\&. .RE .PP -\fB\-S\fR, \fB\-\-Scan\fR \fIethX\fR +\fB\-f\fR, \fB\-\-fcfs\fR [\fIethX\fR] .RS 4 -Rescan for new targets and LUNs on the provided instance\&. This command will not rescan any NPIV instances created on the same port\&. This will not rescan any FCoE instance created by fipvlan\&. +Show information about the discovered Fibre Channel Forwarders (FCFs) on the specified network interface, or all discovered FCFs if no network interface is specified\&. .RE .PP \fB\-t\fR, \fB\-\-target\fR [\fIethX\fR] diff --git a/doc/fcoeadm.txt b/doc/fcoeadm.txt index e70dd7f..3624a45 100644 --- a/doc/fcoeadm.txt +++ b/doc/fcoeadm.txt @@ -25,9 +25,11 @@ SYNOPSIS *fcoeadm* -r|--reset _ethX_ +*fcoeadm* -S|--Scan [_ethX_] + *fcoeadm* -i|--interface [_ethX_] -*fcoeadm* -S|--Scan [_ethX_] +*fcoeadm* -f|--fcfs [_ethX_] *fcoeadm* -t|--target [_ethX_] @@ -68,15 +70,20 @@ OPTIONS Resets the FCoE instance on the specified network interface. This will not reset FCoE instances created by fipvlan. -*-i*, *--interface* [_ethX_]:: - Show information about the FCoE instance on the specified network - interface, or all FCoE instances if no network interface is specified. - *-S*, *--Scan* _ethX_:: Rescan for new targets and LUNs on the provided instance. This command will not rescan any NPIV instances created on the same port. This will not rescan any FCoE instance created by fipvlan. +*-i*, *--interface* [_ethX_]:: + Show information about the FCoE instance on the specified network + interface, or all FCoE instances if no network interface is specified. + +*-f*, *--fcfs* [_ethX_]:: + Show information about the discovered Fibre Channel Forwarders (FCFs) + on the specified network interface, or all discovered FCFs if no + network interface is specified. + *-t*, *--target* [_ethX_]:: Show information about the discovered targets associated with the FCoE instance on the specified network interface. diff --git a/fcoeadm.c b/fcoeadm.c index 1685a42..0784ccd 100644 --- a/fcoeadm.c +++ b/fcoeadm.c @@ -33,13 +33,14 @@ #include "fcoe_clif.h" #include "fcoeadm_display.h" -static const char *optstring = "c:d:r:S:itlshv"; +static const char *optstring = "c:d:r:S:iftlshv"; static struct option fcoeadm_opts[] = { {"create", required_argument, 0, 'c'}, {"destroy", required_argument, 0, 'd'}, {"reset", required_argument, 0, 'r'}, {"interface", no_argument, 0, 'i'}, {"Scan", required_argument, 0, 'S'}, + {"fcf", no_argument, 0, 'f'}, {"target", no_argument, 0, 't'}, {"lun", no_argument, 0, 'l'}, {"stats", no_argument, 0, 's'}, @@ -59,6 +60,7 @@ static void fcoeadm_help(void) "\t [-r|--reset] <ethX>\n" "\t [-S|--Scan] <ethX>\n" "\t [-i|--interface] [<ethX>]\n" + "\t [-f]--fcf] [<ethX>]\n" "\t [-t|--target] [<ethX>]\n" "\t [-l|--lun] [<ethX>]\n" "\t [-s|--stats] <ethX> [<interval>]\n" @@ -272,6 +274,26 @@ int main(int argc, char *argv[]) break; + case 'f': + if (argc > 3) { + rc = EBADNUMARGS; + break; + } + + /* + * If there's an aditional argument + * treat it as the interface name. + */ + if (optind != argc) { + ifname = argv[optind]; + rc = fcoe_validate_fcoe_conn(ifname); + } + + if (!rc) + rc = display_fcf_info(ifname); + + break; + case 't': if (argc > 3) { rc = EBADNUMARGS; diff --git a/fcoeadm_display.c b/fcoeadm_display.c index 75d20d0..e973065 100644 --- a/fcoeadm_display.c +++ b/fcoeadm_display.c @@ -42,6 +42,7 @@ #include "fcoeadm_display.h" #include "fcoe_utils.h" #include "fcoemon_utils.h" +#include "libopenfcoe.h" /* #define TEST_HBAAPI_V1 */ #ifdef TEST_HBAAPI_V1 @@ -66,6 +67,8 @@ #define FCP_TARG_STR "FCP Target" +#define SYSFS_HOST_DIR "/sys/class/fc_host" + /* * HBA and port objects are one-to-one since there * is one host created per Ethernet port (vlan). @@ -1401,3 +1404,68 @@ out: return rc; } + +static struct sa_table fcoe_ctlr_table; + +void print_fcoe_fcf_device(void *ep, void *arg) +{ + struct fcoe_fcf_device *fcf = (struct fcoe_fcf_device *)ep; + char temp[MAX_STR_LEN]; + char mac[MAX_STR_LEN]; + int len = sizeof(temp); + const char *buf; + + printf("\n"); + printf(" FCF #%u Information\n", fcf->index); + buf = sa_enum_decode(temp, len, fcf_state_table, fcf->state); + if (!buf) + buf = temp; + printf(" Connection Mode: %s\n", buf); + printf(" Fabric Name: 0x%016lx\n", fcf->fabric_name); + printf(" Switch Name 0x%016lx\n", fcf->switch_name); + mac2str(fcf->mac, mac, MAX_STR_LEN); + printf(" MAC Address: %s\n", mac); + printf(" FCF Priority: %u\n", fcf->priority); + printf(" FKA Period: %u seconds\n", fcf->fka_period); + printf(" Selected: "); + (fcf->selected == 1) ? printf("Yes\n") : printf("No\n"); + printf(" VLAN ID: %u\n", fcf->vlan_id); + printf("\n"); +} + +void print_interface_fcoe_fcf_device(void *ep, void *arg) +{ + struct fcoe_ctlr_device *ctlr = (struct fcoe_ctlr_device *)ep; + const char *ifname = arg; + const char *buf; + char temp[MAX_STR_LEN]; + int len = sizeof(temp); + + if (!ifname || !strncmp(ifname, ctlr->ifname, IFNAMSIZ)) { + printf(" Interface: %s\n", ctlr->ifname); + buf = sa_enum_decode(temp, len, fip_conn_type_table, + ctlr->mode); + if (!buf) + buf = temp; + printf(" Connection Type: %s\n", buf); + + sa_table_iterate(&ctlr->fcfs, print_fcoe_fcf_device, NULL); + } +} + +/* + * NULL ifname indicates to dispaly all fcfs + */ +enum fcoe_status display_fcf_info(const char *ifname) +{ + enum fcoe_status rc = SUCCESS; + + sa_table_init(&fcoe_ctlr_table); + read_fcoe_ctlr(&fcoe_ctlr_table); + + sa_table_iterate(&fcoe_ctlr_table, print_interface_fcoe_fcf_device, + (void *)ifname); + sa_table_iterate(&fcoe_ctlr_table, free_fcoe_ctlr_device, NULL); + + return rc; +} diff --git a/fcoeadm_display.h b/fcoeadm_display.h index 2120aba..10c78f2 100644 --- a/fcoeadm_display.h +++ b/fcoeadm_display.h @@ -28,6 +28,7 @@ enum disp_style { }; enum fcoe_status display_adapter_info(const char *ifname); +enum fcoe_status display_fcf_info(const char *ifname); enum fcoe_status display_target_info(const char *ifname, enum disp_style style); enum fcoe_status display_port_stats(const char *ifname, _______________________________________________ devel mailing list [email protected] https://lists.open-fcoe.org/mailman/listinfo/devel
