[ipxe-devel] [Patch] Add fcoestat command
Steven Clark
sclark at crossbeam.com
Wed Jun 27 17:20:09 UTC 2012
Add an fcoestat command to list fcoe interfaces.
Listed information is currently just netdev name, portname and nodename.
fcoestat is enabled by NET_PROTO_FCOE
diff --git a/src/config/config_ethernet.c b/src/config/config_ethernet.c
index d13bd61..559b43d 100644
--- a/src/config/config_ethernet.c
+++ b/src/config/config_ethernet.c
@@ -23,4 +23,5 @@ REQUIRE_OBJECT ( aoe );
#endif
#ifdef NET_PROTO_FCOE
REQUIRE_OBJECT ( fcoe );
+REQUIRE_OBJECT ( fcoemgmt_cmd );
#endif
diff --git a/src/hci/commands/fcoemgmt_cmd.c b/src/hci/commands/fcoemgmt_cmd.c
new file mode 100644
index 0000000..a47a9d1
--- /dev/null
+++ b/src/hci/commands/fcoemgmt_cmd.c
@@ -0,0 +1,89 @@
+/*
+ * Based on fcmgmt_cmd.c by:
+ * Copyright (C) 2010 Michael Brown <mbrown at fensystems.co.uk>.
+ * FCoE code added by:
+ * Steven Clark <sclark at crossbeam.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER );
+
+#include <stdio.h>
+#include <errno.h>
+#include <getopt.h>
+#include <strings.h>
+#include <ipxe/command.h>
+#include <ipxe/parseopt.h>
+#include <ipxe/tables.h>
+#include <ipxe/fcoe.h>
+
+/** @file
+ *
+ * FCoE management commands
+ *
+ */
+
+/**
+ * Print status of FCoE port
+ *
+ * @v port FCoE port
+ */
+void fcoeportstat ( struct fcoe_port *port ) {
+ printf ("%s: port %s", port->netdev->name,
+ fc_ntoa(&port->port_wwn.fc));
+ printf (" node %s\n", fc_ntoa(&port->node_wwn.fc));
+}
+
+/** "fcoestat" options */
+struct fcoestat_options {};
+
+/** "fcoestat" option list */
+static struct option_descriptor fcoestat_opts[] = {};
+
+/** "fcoestat" command descriptor */
+static struct command_descriptor fcoestat_cmd =
+ COMMAND_DESC ( struct fcoestat_options, fcoestat_opts, 0, 0, "" );
+
+/**
+ * The "fcoestat" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Return status code
+ */
+static int fcoestat_exec ( int argc, char **argv ) {
+ struct fcoestat_options opts;
+ struct fcoe_port *port;
+ int rc;
+
+ /* Parse options */
+ if ( ( rc = parse_options ( argc, argv, &fcoestat_cmd, &opts ) ) != 0 )
+ return rc;
+
+ list_for_each_entry ( port, &fcoe_ports, list )
+ fcoeportstat ( port );
+
+ return 0;
+}
+
+
+/** FCoE management commands */
+struct command fcoemgmt_commands[] __command = {
+ {
+ .name = "fcoestat",
+ .exec = fcoestat_exec,
+ },
+};
diff --git a/src/include/ipxe/fcoe.h b/src/include/ipxe/fcoe.h
index 6ba5b40..6d4eff3 100644
--- a/src/include/ipxe/fcoe.h
+++ b/src/include/ipxe/fcoe.h
@@ -13,6 +13,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
#include <stdint.h>
#include <ipxe/fc.h>
#include <ipxe/if_ether.h>
+#include <ipxe/netdevice.h>
/** An FCoE name */
union fcoe_name {
@@ -89,4 +90,54 @@ enum fcoe_eof {
/** FCoE VLAN priority */
#define FCOE_VLAN_PRIORITY 3
+/** An FCoE port */
+struct fcoe_port {
+ /** Reference count */
+ struct refcnt refcnt;
+ /** List of FCoE ports */
+ struct list_head list;
+ /** Transport interface */
+ struct interface transport;
+ /** Network device */
+ struct net_device *netdev;
+
+ /** Node WWN */
+ union fcoe_name node_wwn;
+ /** Port WWN */
+ union fcoe_name port_wwn;
+
+ /** FIP retransmission timer */
+ struct retry_timer timer;
+ /** FIP timeout counter */
+ unsigned int timeouts;
+ /** Flags */
+ unsigned int flags;
+ /** FCoE forwarder priority */
+ unsigned int priority;
+ /** Keepalive delay (in ms) */
+ unsigned int keepalive;
+ /** FCoE forwarder MAC address */
+ uint8_t fcf_mac[ETH_ALEN];
+ /** Local MAC address */
+ uint8_t local_mac[ETH_ALEN];
+};
+
+/** FCoE flags */
+enum fcoe_flags {
+ /** Underlying network device is available */
+ FCOE_HAVE_NETWORK = 0x0001,
+ /** We have selected an FCoE forwarder to use */
+ FCOE_HAVE_FCF = 0x0002,
+ /** We have a FIP-capable FCoE forwarder available to be used */
+ FCOE_HAVE_FIP_FCF = 0x0004,
+ /** FCoE forwarder supports server-provided MAC addresses */
+ FCOE_FCF_ALLOWS_SPMA = 0x0008,
+ /** An alternative VLAN has been found */
+ FCOE_VLAN_FOUND = 0x0010,
+ /** VLAN discovery has timed out */
+ FCOE_VLAN_TIMED_OUT = 0x0020,
+};
+
+extern struct list_head fcoe_ports;
+
#endif /* _IPXE_FCOE_H */
diff --git a/src/net/fcoe.c b/src/net/fcoe.c
index c54d1b4..0eaeca7 100644
--- a/src/net/fcoe.c
+++ b/src/net/fcoe.c
@@ -62,54 +62,6 @@ FEATURE ( FEATURE_PROTOCOL, "FCoE", DHCP_EB_FEATURE_FCOE, 1 );
#define EINFO_EINVAL_EOF \
__einfo_uniqify ( EINFO_EINVAL, 0x04, "Invalid EoF delimiter" )
-/** An FCoE port */
-struct fcoe_port {
- /** Reference count */
- struct refcnt refcnt;
- /** List of FCoE ports */
- struct list_head list;
- /** Transport interface */
- struct interface transport;
- /** Network device */
- struct net_device *netdev;
-
- /** Node WWN */
- union fcoe_name node_wwn;
- /** Port WWN */
- union fcoe_name port_wwn;
-
- /** FIP retransmission timer */
- struct retry_timer timer;
- /** FIP timeout counter */
- unsigned int timeouts;
- /** Flags */
- unsigned int flags;
- /** FCoE forwarder priority */
- unsigned int priority;
- /** Keepalive delay (in ms) */
- unsigned int keepalive;
- /** FCoE forwarder MAC address */
- uint8_t fcf_mac[ETH_ALEN];
- /** Local MAC address */
- uint8_t local_mac[ETH_ALEN];
-};
-
-/** FCoE flags */
-enum fcoe_flags {
- /** Underlying network device is available */
- FCOE_HAVE_NETWORK = 0x0001,
- /** We have selected an FCoE forwarder to use */
- FCOE_HAVE_FCF = 0x0002,
- /** We have a FIP-capable FCoE forwarder available to be used */
- FCOE_HAVE_FIP_FCF = 0x0004,
- /** FCoE forwarder supports server-provided MAC addresses */
- FCOE_FCF_ALLOWS_SPMA = 0x0008,
- /** An alternative VLAN has been found */
- FCOE_VLAN_FOUND = 0x0010,
- /** VLAN discovery has timed out */
- FCOE_VLAN_TIMED_OUT = 0x0020,
-};
-
struct net_protocol fcoe_protocol __net_protocol;
struct net_protocol fip_protocol __net_protocol;
@@ -148,7 +100,7 @@ static uint8_t default_fcf_mac[ETH_ALEN] =
#define FCOE_MAX_FIP_MISSING_KEEPALIVES 4
/** List of FCoE ports */
-static LIST_HEAD ( fcoe_ports );
+LIST_HEAD ( fcoe_ports );
/******************************************************************************
*
More information about the ipxe-devel
mailing list