libfc, libfcoe and fcoe updates for 3.9
cover libfc, libfcoe and fcoe updates for 3.9
This series is mostly a resend of previously sent patches. The primary change in this series is the addition of the fcoe_sysfs "control" interfaces. Additionally there are a few fix/cleanup patches and UAPI conversions. Almost all of these patches have already been reviewed on linux-scsi.
I will compose a pull-request and send it soon, but I wanted to make sure the most recent versions of these patches were posted to linux-scsi first.
---
Al Viro (1):
debris left by "[SCSI] libfcoe: Remove mutex_trylock/restart_syscall checks"
Bhanu Prakash Gollapudi (1):
libfcoe: Handle CVL while waiting to select an FCF
David Howells (1):
UAPI: (Scripted) Disintegrate include/scsi/fc
Krishna Mohan (1):
libfc: XenServer fails to mount root filesystem.
Neerav Parikh (1):
fcoe: Fix deadlock while deleting FCoE interface with NPIV ports
Neil Horman (1):
fcoe: close race on link speed detection in fcoe code
Robert Love (7):
Documentation: Add missing devices/ to devices path
libfcoe: Save some memory and optimize name lookups
libfcoe: Add fcoe_sysfs debug logging level libfcoe, fcoe, bnx2fc: Add new fcoe control interface
fcoe: Use the fcoe_sysfs control interface
bnx2fc: Use the fcoe_sysfs control interface libfc, libfcoe, fcoe: Convert debug_logging macros to pr_info
Vasu Dev (1):
libfc: fix REC handling
Yi Zou (7):
fcoe: prep work to start consolidate the usage of fcoe_netdev
fcoe: add support to the get_netdev() for fcoe_interface libfcoe, fcoe: move fcoe_link_speed_update() to libfcoe and export it libfcoe, fcoe: consolidate the fcoe_ctlr_get_lesb/fcoe_get_lesb
bnx2fc: add support to get_netdev for bnx2f_interface
bnx2fc: use fcoe_link_speed_update() from the exported symbol in libfcoe
bnx2fc: use fcoe_get_lesb/fcoe_ctlr_get_lesb() directly from libfcoe
Documentation/ABI/testing/sysfs-bus-fcoe | 45 ++ drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 256 +++++---- drivers/scsi/fcoe/fcoe.c | 266 ++++++---- drivers/scsi/fcoe/fcoe.h | 6 drivers/scsi/fcoe/fcoe_ctlr.c | 27 + drivers/scsi/fcoe/fcoe_sysfs.c | 186 +++++-- drivers/scsi/fcoe/fcoe_transport.c | 199 +++++++ drivers/scsi/fcoe/libfcoe.h | 20 - drivers/scsi/libfc/fc_fcp.c | 6 drivers/scsi/libfc/fc_libfc.h | 38 + drivers/scsi/libfc/fc_rport.c | 2 include/scsi/fc/Kbuild | 4 include/scsi/fc/fc_els.h | 831 ------------------------------ include/scsi/fc/fc_fs.h | 348 ------------- include/scsi/fc/fc_gs.h | 96 --- include/scsi/fc/fc_ns.h | 208 -------- include/scsi/fcoe_sysfs.h | 11 include/scsi/libfcoe.h | 32 + include/uapi/scsi/fc/Kbuild | 4 include/uapi/scsi/fc/fc_els.h | 831 ++++++++++++++++++++++++++++++ include/uapi/scsi/fc/fc_fs.h | 348 +++++++++++++ include/uapi/scsi/fc/fc_gs.h | 96 +++ include/uapi/scsi/fc/fc_ns.h | 208 ++++++++ 23 files changed, 2296 insertions(+), 1772 deletions(-) delete mode 100644 include/scsi/fc/fc_els.h delete mode 100644 include/scsi/fc/fc_fs.h delete mode 100644 include/scsi/fc/fc_gs.h delete mode 100644 include/scsi/fc/fc_ns.h create mode 100644 include/uapi/scsi/fc/fc_els.h create mode 100644 include/uapi/scsi/fc/fc_fs.h create mode 100644 include/uapi/scsi/fc/fc_gs.h create mode 100644 include/uapi/scsi/fc/fc_ns.h
Signature · 1 line
Thanks, //Rob
PATCH 1/21 libfc: fix REC handling
From: Vasu Dev <[email protected]>
Currently fc_fcp_timeout doesn't check FC_RP_FLAGS_REC_SUPPORTED flag first, this prevents REC request ever going out at all to the target having REC support. So this patches fixes the fc_fcp_timeout by checking FC_RP_FLAGS_REC_SUPPORTED flag first.
The changed order won't cause any issue during clearing FC_RP_FLAGS_REC_SUPPORTED on failed IO with target not supporting FC_RP_FLAGS_REC_SUPPORTED, since retry on failed IO would succeed.
--- drivers/scsi/libfc/fc_fcp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/scsi/libfc/fc_fcp.c +3 -3
@@ -1381,10 +1381,10 @@ static void fc_fcp_timeout(unsigned long data) fsp->state |=FC_SRB_FCP_PROCESSING_TMO ; -if (fsp->state &FC_SRB_RCV_STATUS ) -fc_fcp_complete_locked (fsp); -else if (rpriv->flags &FC_RP_FLAGS_REC_SUPPORTED ) +if (rpriv->flags &FC_RP_FLAGS_REC_SUPPORTED )fc_fcp_rec (fsp); +else if (fsp->state &FC_SRB_RCV_STATUS ) +fc_fcp_complete_locked (fsp);else fc_fcp_recovery (fsp,FC_TIMED_OUT ); fsp->state &= ~FC_SRB_FCP_PROCESSING_TMO ;
PATCH 2/21 Documentation: Add missing devices/ to devices path
In reply to Robert LoveAdd missing 'devices/ subdirectory to /sys/bus/fcoe/devices/ctlr_X and /sys/bus/fcoe/devices/fcf_X references.
--- Documentation/ABI/testing/sysfs-bus-fcoe | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Documentation/ABI/testing/sysfs-bus-fcoe +2 -2
@@ -1,4 +1,4 @@ -What: /sys/bus/fcoe/ctlr_X +What: /sys/bus/fcoe/devices/ctlr_X Date: March 2012 KernelVersion: TBD Contact: Robert Love <[email protected]>, [email protected]
@@ -26,7 +26,7 @@ Attributes: Notes: ctlr_X (global increment starting at 0) -What: /sys/bus/fcoe/fcf_X +What: /sys/bus/fcoe/devices/fcf_X Date: March 2012 KernelVersion: TBD Contact: Robert Love <[email protected]>, [email protected]
PATCH 3/21 libfcoe: Save some memory and optimize name lookups
In reply to Robert LoveInstead of creating a structure with an enum and a pointer to a string, simply allocate an array of strings and use the enum values for the indicies.
This means that we do not need to iterate through the list of entries when looking up a string name by its enum key.
This will also help with a latter patch that will add more fcoe_sysfs attributes that will also use the fcoe_enum_name_search macro. One attribute will also do a reverse lookup which requires less code when the enum-to-string mappings are organized as this patch makes them to be.
--- drivers/scsi/fcoe/fcoe_sysfs.c | 44 +++++++++++++++------------------------- 1 file changed, 16 insertions(+), 28 deletions(-)
drivers/scsi/fcoe/fcoe_sysfs.c +16 -28
@@ -210,25 +210,23 @@ static ssize_t show_fcoe_fcf_device_##field(struct device *dev, \#define fcoe_enum_name_search (title, table_type, table) \ static const char *get_fcoe_##title##_name(enum table_type table_key) \ { \ - int i; \ - char *name = NULL; \ - \ - for (i = 0; i < ARRAY_SIZE(table); i++) { \ - if (table[i].value == table_key) { \ - name = table[i].name; \ - break; \ - } \ - } \ - return name; \ + if (table_key < 0 || table_key >= ARRAY_SIZE(table)) \ + return NULL; \ + return table[table_key]; \ } -static struct { -enum fcf_state value; -char *name; -} fcf_state_names[] = { - {FCOE_FCF_STATE_UNKNOWN ,"Unknown" }, - {FCOE_FCF_STATE_DISCONNECTED ,"Disconnected" }, - {FCOE_FCF_STATE_CONNECTED ,"Connected" }, +static char *fip_conn_type_names[] = { + [FIP_CONN_TYPE_UNKNOWN ] ="Unknown" , + [FIP_CONN_TYPE_FABRIC ] ="Fabric" , + [FIP_CONN_TYPE_VN2VN ] ="VN2VN" , +}; +fcoe_enum_name_search(ctlr_mode, fip_conn_type, fip_conn_type_names) +#define FCOE_CTLR_MODE_MAX_NAMELEN 50 + +static char *fcf_state_names[] = { + [FCOE_FCF_STATE_UNKNOWN ] ="Unknown" , + [FCOE_FCF_STATE_DISCONNECTED ] ="Disconnected" , + [FCOE_FCF_STATE_CONNECTED ] ="Connected" , }; fcoe_enum_name_search(fcf_state, fcf_state, fcf_state_names)#define FCOE_FCF_STATE_MAX_NAMELEN 50
@@ -246,17 +244,7 @@ static ssize_t show_fcf_state(struct device *dev, } static FCOE_DEVICE_ATTR(fcf, state, S_IRUGO, show_fcf_state, NULL); -static struct { -enum fip_conn_type value; -char *name; -} fip_conn_type_names[] = { - {FIP_CONN_TYPE_UNKNOWN ,"Unknown" }, - {FIP_CONN_TYPE_FABRIC ,"Fabric" }, - {FIP_CONN_TYPE_VN2VN ,"VN2VN" }, -}; -fcoe_enum_name_search(ctlr_mode, fip_conn_type, fip_conn_type_names) -#define FCOE_CTLR_MODE_MAX_NAMELEN 50 - +#define FCOE_MAX_MODENAME_LEN 20static ssize_t show_ctlr_mode (struct device *dev,struct device_attribute *attr,char *buf)
PATCH 4/21 libfcoe: Add fcoe_sysfs debug logging level
In reply to Robert LoveAdd a macro to print fcoe_sysfs debug statements.
--- drivers/scsi/fcoe/fcoe_sysfs.c | 7 +++++++ drivers/scsi/fcoe/libfcoe.h | 11 ++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-)
drivers/scsi/fcoe/fcoe_sysfs.c +7 -0
@@ -24,6 +24,13 @@#include <scsi/fcoe_sysfs.h> +/* +* OK to include local libfcoe.h for debug_logging, but cannot include +* <scsi/libfcoe.h> otherwise non-netdev based fcoe solutions would have +* have to include more than fcoe_sysfs.h. +*/ +#include "libfcoe.h" +static atomic_t ctlr_num;static atomic_t fcf_num;
drivers/scsi/fcoe/libfcoe.h +8 -3
@@ -2,9 +2,10 @@#define _FCOE_LIBFCOE_H_extern unsigned int libfcoe_debug_logging; -#define LIBFCOE_LOGGING 0x01/* General logging, not categorized */ -#define LIBFCOE_FIP_LOGGING 0x02/* FIP logging */ -#define LIBFCOE_TRANSPORT_LOGGING 0x04/* FCoE transport logging */ +#define LIBFCOE_LOGGING 0x01/* General logging, not categorized */ +#define LIBFCOE_FIP_LOGGING 0x02/* FIP logging */ +#define LIBFCOE_TRANSPORT_LOGGING 0x04/* FCoE transport logging */ +#define LIBFCOE_SYSFS_LOGGING 0x08/* fcoe_sysfs logging */ #define LIBFCOE_CHECK_LOGGING (LEVEL ,CMD ) \ do { \
@@ -28,4 +29,8 @@ do { \ printk(KERN_INFO "%s: " fmt, \ __func__, ##args);) +#define LIBFCOE_SYSFS_DBG(cdev, fmt, args...) \ + LIBFCOE_CHECK_LOGGING(LIBFCOE_SYSFS_LOGGING, \ + pr_info("ctlr_%d: " fmt, cdev->id, ##args);) +#endif /* _FCOE_LIBFCOE_H_ */
PATCH 5/21 libfcoe, fcoe, bnx2fc: Add new fcoe control interface
In reply to Robert LoveThis patch does a few things.
1) Makes /sys/bus/fcoe/ctlr_{create,destroy} interfaces. These interfaces take an <ifname> and will either create an FCoE Controller or destroy an FCoE Controller depending on which file is written to.
The new FCoE Controller will start in a DISABLED state and will not do discovery or login until it is ENABLED. This pause will allow us to configure the FCoE Controller before enabling it.
2) Makes the 'mode' attribute of a fcoe_ctlr_device writale. This allows the user to configure the mode in which the FCoE Controller will start in when it is ENABLED.
Possible modes are 'Fabric', or 'VN2VN'.
The default mode for a fcoe_ctlr{,_device} is 'Fabric'. Drivers must implement the set_fcoe_ctlr_mode routine to support this feature.
libfcoe offers an exported routine to set a FCoE Controller's mode. The mode can only be changed when the FCoE Controller is DISABLED.
This patch also removes the get_fcoe_ctlr_mode pointer in the fcoe_sysfs function template, the code in fcoe_ctlr.c to get the mode and the assignment of the fcoe_sysfs function pointer to the fcoe_ctlr.c implementation (in fcoe and bnx2fc). fcoe_sysfs can return that value for the mode without consulting the LLD.
3) Make a 'enabled' attribute of a fcoe_ctlr_device. On a read, fcoe_sysfs will return the attribute's value. On a write, fcoe_sysfs will call the LLD (if there is a callback) to notifiy that the enalbed state has changed.
This patch maintains the old FCoE control interfaces as module parameters, but it adds comments pointing out that the old interfaces are deprecated.
--- Documentation/ABI/testing/sysfs-bus-fcoe | 41 +++++++++ drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 1 drivers/scsi/fcoe/fcoe.c | 1 drivers/scsi/fcoe/fcoe_sysfs.c | 137 ++++++++++++++++++++++++++++-- drivers/scsi/fcoe/fcoe_transport.c | 104 +++++++++++++++++++++++ include/scsi/fcoe_sysfs.h | 11 ++ include/scsi/libfcoe.h | 16 +++- 7 files changed, 298 insertions(+), 13 deletions(-)
Documentation/ABI/testing/sysfs-bus-fcoe +40 -1
@@ -1,14 +1,53 @@ +What: /sys/bus/fcoe/ +Date: August 2012 +KernelVersion: TBD +Contact: Robert Love <[email protected]>, [email protected] +Description: The FCoE bus. Attributes in this directory are control interfaces. +Attributes: + + ctlr_create: 'FCoE Controller' instance creation interface. Writing an + <ifname> to this file will allocate and populate sysfs with a + fcoe_ctlr_device (ctlr_X). The user can then configure any + per-port settings and finally write to the fcoe_ctlr_device's + 'start' attribute to begin the kernel's discovery and login + process. + + ctlr_destroy: 'FCoE Controller' instance removal interface. Writing a + fcoe_ctlr_device's sysfs name to this file will log the + fcoe_ctlr_device out of the fabric or otherwise connected + FCoE devices. It will also free all kernel memory allocated + for this fcoe_ctlr_device and any structures associated + with it, this includes the scsi_host. + What: /sys/bus/fcoe/devices/ctlr_X Date: March 2012 KernelVersion: TBD Contact: Robert Love <[email protected]>, [email protected] -Description: 'FCoE Controller' instances on the fcoe bus +Description: 'FCoE Controller' instances on the fcoe bus. + The FCoE Controller now has a three stage creation process. + 1) Write interface name to ctlr_create 2) Configure the FCoE + Controller (ctlr_X) 3) Enable the FCoE Controller to begin + discovery and login. The FCoE Controller is destroyed by + writing it's name, i.e. ctlr_X to the ctlr_delete file. + Attributes: fcf_dev_loss_tmo: Device loss timeout peroid (see below). Changing this value will change the dev_loss_tmo for all FCFs discovered by this controller. + mode: Display or change the FCoE Controller's mode. Possible + modes are 'Fabric' and 'VN2VN'. If a FCoE Controller + is started in 'Fabric' mode then FIP FCF discovery is + initiated and ultimately a fabric login is attempted. + If a FCoE Controller is started in 'VN2VN' mode then + FIP VN2VN discovery and login is performed. A FCoE + Controller only supports one mode at a time. + + enabled: Whether an FCoE controller is enabled or disabled. + 0 if disabled, 1 if enabled. Writing either 0 or 1 + to this file will enable or disable the FCoE controller. + lesb/link_fail: Link Error Status Block (LESB) link failure count. lesb/vlink_fail: Link Error Status Block (LESB) virtual link
drivers/scsi/bnx2fc/bnx2fc_fcoe.c +0 -1
@@ -2555,7 +2555,6 @@ module_init(bnx2fc_mod_init);module_exit (bnx2fc_mod_exit);static struct fcoe_sysfs_function_template bnx2fc_fcoe_sysfs_templ = { - .get_fcoe_ctlr_mode = fcoe_ctlr_get_fip_mode, .get_fcoe_ctlr_link_fail = bnx2fc_ctlr_get_lesb, .get_fcoe_ctlr_vlink_fail = bnx2fc_ctlr_get_lesb, .get_fcoe_ctlr_miss_fka = bnx2fc_ctlr_get_lesb,
drivers/scsi/fcoe/fcoe.c +0 -1
@@ -155,7 +155,6 @@ static void fcoe_ctlr_get_lesb(struct fcoe_ctlr_device *);static void fcoe_fcf_get_vlan_id (struct fcoe_fcf_device *);static struct fcoe_sysfs_function_template fcoe_sysfs_templ = { - .get_fcoe_ctlr_mode = fcoe_ctlr_get_fip_mode, .get_fcoe_ctlr_link_fail = fcoe_ctlr_get_lesb, .get_fcoe_ctlr_vlink_fail = fcoe_ctlr_get_lesb, .get_fcoe_ctlr_miss_fka = fcoe_ctlr_get_lesb,
drivers/scsi/fcoe/fcoe_sysfs.c +130 -7
189 lines not on this page · raw message
drivers/scsi/fcoe/fcoe_transport.c +104 -0
110 lines not on this page · raw message
include/scsi/fcoe_sysfs.h +10 -1
@@ -34,7 +34,8 @@ struct fcoe_sysfs_function_template {void (*get_fcoe_ctlr_symb_err)(struct fcoe_ctlr_device *);void (*get_fcoe_ctlr_err_block)(struct fcoe_ctlr_device *);void (*get_fcoe_ctlr_fcs_error)(struct fcoe_ctlr_device *); -void (*get_fcoe_ctlr_mode)(struct fcoe_ctlr_device *); +void (*set_fcoe_ctlr_mode)(struct fcoe_ctlr_device *); +int (*set_fcoe_ctlr_enabled)(struct fcoe_ctlr_device *);void (*get_fcoe_fcf_selected)(struct fcoe_fcf_device *);void (*get_fcoe_fcf_vlan_id)(struct fcoe_fcf_device *); };
@@ -48,6 +49,12 @@ enum fip_conn_type { FIP_CONN_TYPE_VN2VN, }; +enum ctlr_enabled_state { +FCOE_CTLR_ENABLED , +FCOE_CTLR_DISABLED , +FCOE_CTLR_UNUSED , +}; +struct fcoe_ctlr_device {u32 id;
@@ -64,6 +71,8 @@ struct fcoe_ctlr_device {int fcf_dev_loss_tmo;enum fip_conn_type mode; +enum ctlr_enabled_state enabled; +/* expected in host order for displaying */ struct fcoe_fc_els_lesb lesb; };
include/scsi/libfcoe.h +14 -2
@@ -289,8 +289,11 @@ static inline bool is_fip_mode(struct fcoe_ctlr *fip)* @attached: whether this transport is already attached * @list: list linkage to all attached transports * @match: handler to allow the transport driver to match up a given netdev +* @alloc: handler to allocate per-instance FCoE structures +* (no discovery or login) * @create: handler to sysfs entry of create for FCoE instances -* @destroy: handler to sysfs entry of destroy for FCoE instances +* @destroy: handler to delete per-instance FCoE structures +* (frees all memory) * @enable: handler to sysfs entry of enable for FCoE instances * @disable: handler to sysfs entry of disable for FCoE instances */
@@ -299,6 +302,7 @@ struct fcoe_transport {bool attached;struct list_head list;bool (*match) (struct net_device *device); +int (*alloc) (struct net_device *device);int (*create) (struct net_device *device,enum fip_state fip_mode);int (*destroy) (struct net_device *device);int (*enable) (struct net_device *device);
@@ -356,7 +360,7 @@ int fcoe_get_paged_crc_eof(struct sk_buff *skb, int tlen,/* FCoE Sysfs helpers */ void fcoe_fcf_get_selected (struct fcoe_fcf_device *); -void fcoe_ctlr_get_fip_mode (struct fcoe_ctlr_device *); +void fcoe_ctlr_set_fip_mode (struct fcoe_ctlr_device *);/** * struct netdev_list
@@ -372,4 +376,12 @@ struct fcoe_netdev_mapping {int fcoe_transport_attach (struct fcoe_transport *ft);int fcoe_transport_detach (struct fcoe_transport *ft); +/* sysfs store handler for ctrl_control interface */ +ssize_t fcoe_ctlr_create_store (struct bus_type *bus, +const char *buf,size_t count); +ssize_t fcoe_ctlr_destroy_store (struct bus_type *bus, +const char *buf,size_t count); +#endif /* _LIBFCOE_H */ + +
PATCH 6/21 fcoe: Use the fcoe_sysfs control interface
In reply to Robert LoveThis patch adds support for the new fcoe_sysfs control interface to fcoe.ko. It keeps the deprecated interface in tact and therefore either the legacy or the new control interfaces can be used. A mixed mode is not supported. A user must either use the new interfaces or the old ones, but not both.
The fcoe_ctlr's link state is now driven by both the netdev link state as well as the fcoe_ctlr_device's enabled attribute. The link must be up and the fcoe_ctlr_device must be enabled before the FCoE Controller starts discovery or login.
--- drivers/scsi/fcoe/fcoe.c | 147 +++++++++++++++++++++++++++++++++++++---- drivers/scsi/fcoe/fcoe_ctlr.c | 17 ++--- 2 files changed, 140 insertions(+), 24 deletions(-)
drivers/scsi/fcoe/fcoe.c +132 -15
@@ -117,6 +117,11 @@ static int fcoe_destroy(struct net_device *netdev);static int fcoe_enable (struct net_device *netdev);static int fcoe_disable (struct net_device *netdev); +/* fcoe_syfs control interface handlers */ +static int fcoe_ctlr_alloc (struct net_device *netdev); +static int fcoe_ctlr_enabled (struct fcoe_ctlr_device *cdev); + + static struct fc_seq *fcoe_elsct_send(struct fc_lport *, u32 did, struct fc_frame *, unsigned int op,
@@ -155,6 +160,8 @@ static void fcoe_ctlr_get_lesb(struct fcoe_ctlr_device *);static void fcoe_fcf_get_vlan_id (struct fcoe_fcf_device *);static struct fcoe_sysfs_function_template fcoe_sysfs_templ = { + .set_fcoe_ctlr_mode = fcoe_ctlr_set_fip_mode, + .set_fcoe_ctlr_enabled = fcoe_ctlr_enabled, .get_fcoe_ctlr_link_fail = fcoe_ctlr_get_lesb, .get_fcoe_ctlr_vlink_fail = fcoe_ctlr_get_lesb, .get_fcoe_ctlr_miss_fka = fcoe_ctlr_get_lesb,
@@ -1963,6 +1970,7 @@ static int fcoe_dcb_app_notification(struct notifier_block *notifier,static int fcoe_device_notification (struct notifier_block *notifier,ulong event,void *ptr) { +struct fcoe_ctlr_device *cdev;struct fc_lport *lport =NULL ;struct net_device *netdev = ptr;struct fcoe_ctlr *ctlr;
@@ -2019,13 +2027,29 @@ static int fcoe_device_notification(struct notifier_block *notifier,fcoe_link_speed_update (lport); -if (link_possible && !fcoe_link_ok (lport)) -fcoe_ctlr_link_up (ctlr); -else if (fcoe_ctlr_link_down (ctlr)) { - stats =per_cpu_ptr (lport->stats,get_cpu ()); - stats->LinkFailureCount++; -put_cpu (); -fcoe_clean_pending_queue (lport); + cdev =fcoe_ctlr_to_ctlr_dev (ctlr); + +if (link_possible && !fcoe_link_ok (lport)) { +switch (cdev->enabled) { +case FCOE_CTLR_DISABLED : +pr_info ("Link up while interface is disabled.\n" ); +break ; +case FCOE_CTLR_ENABLED : +case FCOE_CTLR_UNUSED : +fcoe_ctlr_link_up (ctlr); + }; + }else if (fcoe_ctlr_link_down (ctlr)) { +switch (cdev->enabled) { +case FCOE_CTLR_DISABLED : +pr_info ("Link down while interface is disabled.\n" ); +break ; +case FCOE_CTLR_ENABLED : +case FCOE_CTLR_UNUSED : + stats =per_cpu_ptr (lport->stats,get_cpu ()); + stats->LinkFailureCount++; +put_cpu (); +fcoe_clean_pending_queue (lport); + }; } out:return rc;
@@ -2038,6 +2062,8 @@ out:* Called from fcoe transport. * * Returns: 0 for success +* +* Deprecated: use fcoe_ctlr_enabled() */ static int fcoe_disable (struct net_device *netdev) {
@@ -2097,6 +2123,33 @@ out: }/** +* fcoe_ctlr_enabled() - Enable or disable an FCoE Controller +* @cdev: The FCoE Controller that is being enabled or disabled +* +* fcoe_sysfs will ensure that the state of 'enabled' has +* changed, so no checking is necessary here. This routine simply +* calls fcoe_enable or fcoe_disable, both of which are deprecated. +* When those routines are removed the functionality can be merged +* here. +*/ +static int fcoe_ctlr_enabled (struct fcoe_ctlr_device *cdev) +{ +struct fcoe_ctlr *ctlr =fcoe_ctlr_device_priv (cdev); +struct fc_lport *lport = ctlr->lp; +struct net_device *netdev =fcoe_netdev (lport); + +switch (cdev->enabled) { +case FCOE_CTLR_ENABLED : +return fcoe_enable (netdev); +case FCOE_CTLR_DISABLED : +return fcoe_disable (netdev); +case FCOE_CTLR_UNUSED : +default : +return -ENOTSUPP ; + }; +} + +/** * fcoe_destroy() - Destroy a FCoE interface * @netdev : The net_device object the Ethernet interface to create on *
@@ -2203,16 +2256,26 @@ static void fcoe_dcb_create(struct fcoe_interface *fcoe)#endif } +enum fcoe_create_link_state { +FCOE_CREATE_LINK_DOWN , +FCOE_CREATE_LINK_UP , +}; +/** -* fcoe_create() - Create a fcoe interface -* @netdev : The net_device object the Ethernet interface to create on -* @fip_mode: The FIP mode for this creation +* _fcoe_create() - (internal) Create a fcoe interface +* @netdev : The net_device object the Ethernet interface to create on +* @fip_mode: The FIP mode for this creation +* @link_state: The ctlr link state on creation * -* Called from fcoe transport +* Called from either the libfcoe 'create' module parameter +* via fcoe_create or from fcoe_syfs's ctlr_create file. * -* Returns: 0 for success +* libfcoe's 'create' module parameter is deprecated so some +* consolidation of code can be done when that interface is +* removed. */ -static int fcoe_create (struct net_device *netdev,enum fip_state fip_mode) +static int _fcoe_create (struct net_device *netdev,enum fip_state fip_mode, +enum fcoe_create_link_state link_state) {int rc =0 ;struct fcoe_ctlr_device *ctlr_dev;
@@ -2259,7 +2322,26 @@ static int fcoe_create(struct net_device *netdev, enum fip_state fip_mode)/* start FIP Discovery and FLOGI */ lport->boot_time = jiffies;fc_fabric_login (lport); -if (!fcoe_link_ok (lport)) { + +/* +* If the fcoe_ctlr_device is to be set to DISABLED +* it must be done after the lport is added to the +* hostlist, but before the rtnl_lock is released. +* This is because the rtnl_lock protects the +* hostlist that fcoe_device_notification uses. If +* the FCoE Controller is intended to be created +* DISABLED then 'enabled' needs to be considered +* handling link events. 'enabled' must be set +* before the lport can be found in the hostlist +* when a link up event is received. +*/ +if (link_state ==FCOE_CREATE_LINK_UP ) + ctlr_dev->enabled =FCOE_CTLR_ENABLED ; +else + ctlr_dev->enabled =FCOE_CTLR_DISABLED ; + +if (link_state ==FCOE_CREATE_LINK_UP && + !fcoe_link_ok (lport)) {rtnl_unlock ();fcoe_ctlr_link_up (ctlr);mutex_unlock (&fcoe_config_mutex);
@@ -2274,6 +2356,37 @@ out_nortnl: }/** +* fcoe_create() - Create a fcoe interface +* @netdev : The net_device object the Ethernet interface to create on +* @fip_mode: The FIP mode for this creation +* +* Called from fcoe transport +* +* Returns: 0 for success +*/ +static int fcoe_create (struct net_device *netdev,enum fip_state fip_mode) +{ +return _fcoe_create (netdev, fip_mode,FCOE_CREATE_LINK_UP ); +} + +/** +* fcoe_ctlr_alloc() - Allocate a fcoe interface from fcoe_sysfs +* @netdev: The net_device to be used by the allocated FCoE Controller +* +* This routine is called from fcoe_sysfs. It will start the fcoe_ctlr +* in a link_down state. The allows the user an opportunity to configure +* the FCoE Controller from sysfs before enabling the FCoE Controller. +* +* Creating in with this routine starts the FCoE Controller in Fabric +* mode. The user can change to VN2VN or another mode before enabling. +*/ +static int fcoe_ctlr_alloc (struct net_device *netdev) +{ +return _fcoe_create (netdev,FIP_MODE_FABRIC , +FCOE_CREATE_LINK_DOWN ); +} + +/** * fcoe_link_speed_update() - Update the supported and actual link speeds * @lport: The local port to update speeds for *
@@ -2374,10 +2487,13 @@ static int fcoe_reset(struct Scsi_Host *shost)struct fcoe_port *port =lport_priv (lport);struct fcoe_interface *fcoe = port->priv;struct fcoe_ctlr *ctlr =fcoe_to_ctlr (fcoe); +struct fcoe_ctlr_device *cdev =fcoe_ctlr_to_ctlr_dev (ctlr);fcoe_ctlr_link_down (ctlr);fcoe_clean_pending_queue (ctlr->lp); -if (!fcoe_link_ok (ctlr->lp)) + +if (cdev->enabled !=FCOE_CTLR_DISABLED && + !fcoe_link_ok (ctlr->lp))fcoe_ctlr_link_up (ctlr);return 0 ; }
@@ -2450,6 +2566,7 @@ static struct fcoe_transport fcoe_sw_transport = { .attached = false, .list = LIST_HEAD_INIT(fcoe_sw_transport.list), .match = fcoe_match, + .alloc = fcoe_ctlr_alloc, .create = fcoe_create, .destroy = fcoe_destroy, .enable = fcoe_enable,
drivers/scsi/fcoe/fcoe_ctlr.c +8 -9
@@ -2864,22 +2864,21 @@ void fcoe_fcf_get_selected(struct fcoe_fcf_device *fcf_dev) }EXPORT_SYMBOL (fcoe_fcf_get_selected); -void fcoe_ctlr_get_fip_mode (struct fcoe_ctlr_device *ctlr_dev) +void fcoe_ctlr_set_fip_mode (struct fcoe_ctlr_device *ctlr_dev) {struct fcoe_ctlr *ctlr =fcoe_ctlr_device_priv (ctlr_dev);mutex_lock (&ctlr->ctlr_mutex); -switch (ctlr->mode) { -case FIP_MODE_FABRIC : - ctlr_dev->mode =FIP_CONN_TYPE_FABRIC ; -break ; -case FIP_MODE_VN2VN : - ctlr_dev->mode =FIP_CONN_TYPE_VN2VN ; +switch (ctlr_dev->mode) { +case FIP_CONN_TYPE_VN2VN : + ctlr->mode =FIP_MODE_VN2VN ;break ; +case FIP_CONN_TYPE_FABRIC :default : - ctlr_dev->mode =FIP_CONN_TYPE_UNKNOWN ; + ctlr->mode =FIP_MODE_FABRIC ;break ; } +mutex_unlock (&ctlr->ctlr_mutex); } -EXPORT_SYMBOL (fcoe_ctlr_get_fip_mode); +EXPORT_SYMBOL (fcoe_ctlr_set_fip_mode);
PATCH 7/21 bnx2fc: Use the fcoe_sysfs control interface
In reply to Robert LoveThis patch adds support for the new fcoe_sysfs control interface to bnx2fc.ko. It keeps the deprecated interface in tact and therefore either the legacy or the new control interfaces can be used. A mixed mode is not supported. A user must either use the new interfaces or the old ones, but not both.
The fcoe_ctlr's link state is now driven by both the netdev link state as well as the fcoe_ctlr_device's enabled attribute. The link must be up and the fcoe_ctlr_device must be enabled before the FCoE Controller starts discovery or login.
--- drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 168 +++++++++++++++++++++++++++++++------ 1 file changed, 139 insertions(+), 29 deletions(-)
drivers/scsi/bnx2fc/bnx2fc_fcoe.c +139 -29
@@ -62,6 +62,10 @@ static int bnx2fc_destroy(struct net_device *net_device);static int bnx2fc_enable (struct net_device *netdev);static int bnx2fc_disable (struct net_device *netdev); +/* fcoe_syfs control interface handlers */ +static int bnx2fc_ctlr_alloc (struct net_device *netdev); +static int bnx2fc_ctlr_enabled (struct fcoe_ctlr_device *cdev); +static void bnx2fc_recv_frame (struct sk_buff *skb);static void bnx2fc_start_disc (struct bnx2fc_interface *interface);
@@ -864,6 +868,7 @@ static void bnx2fc_indicate_netevent(void *context, unsigned long event, u16 vlan_id) {struct bnx2fc_hba *hba = (struct bnx2fc_hba *)context; +struct fcoe_ctlr_device *cdev;struct fc_lport *lport;struct fc_lport *vport;struct bnx2fc_interface *interface, *tmp;
@@ -925,28 +930,45 @@ static void bnx2fc_indicate_netevent(void *context, unsigned long event,bnx2fc_link_speed_update (lport); + cdev =fcoe_ctlr_to_ctlr_dev (ctlr); +if (link_possible && !bnx2fc_link_ok (lport)) { -/* Reset max recv frame size to default */ -fc_set_mfs (lport,BNX2FC_MFS ); -/* -* ctlr link up will only be handled during -* enable to avoid sending discovery solicitation -* on a stale vlan -*/ -if (interface->enabled) -fcoe_ctlr_link_up (ctlr); +switch (cdev->enabled) { +case FCOE_CTLR_DISABLED : +pr_info ("Link up while interface is disabled.\n" ); +break ; +case FCOE_CTLR_ENABLED : +case FCOE_CTLR_UNUSED : +/* Reset max recv frame size to default */ +fc_set_mfs (lport,BNX2FC_MFS ); +/* +* ctlr link up will only be handled during +* enable to avoid sending discovery +* solicitation on a stale vlan +*/ +if (interface->enabled) +fcoe_ctlr_link_up (ctlr); + }; }else if (fcoe_ctlr_link_down (ctlr)) { -mutex_lock (&lport->lp_mutex); -list_for_each_entry (vport, &lport->vports, list) -fc_host_port_type (vport->host) = -FC_PORTTYPE_UNKNOWN ; -mutex_unlock (&lport->lp_mutex); -fc_host_port_type (lport->host) =FC_PORTTYPE_UNKNOWN ; -per_cpu_ptr (lport->stats, -get_cpu ())->LinkFailureCount++; -put_cpu (); -fcoe_clean_pending_queue (lport); - wait_for_upload =1 ; +switch (cdev->enabled) { +case FCOE_CTLR_DISABLED : +pr_info ("Link down while interface is disabled.\n" ); +break ; +case FCOE_CTLR_ENABLED : +case FCOE_CTLR_UNUSED : +mutex_lock (&lport->lp_mutex); +list_for_each_entry (vport, &lport->vports, list) +fc_host_port_type (vport->host) = +FC_PORTTYPE_UNKNOWN ; +mutex_unlock (&lport->lp_mutex); +fc_host_port_type (lport->host) = +FC_PORTTYPE_UNKNOWN ; +per_cpu_ptr (lport->stats, +get_cpu ())->LinkFailureCount++; +put_cpu (); +fcoe_clean_pending_queue (lport); + wait_for_upload =1 ; + }; } }mutex_unlock (&bnx2fc_dev_lock);
@@ -1996,7 +2018,9 @@ static void bnx2fc_ulp_init(struct cnic_dev *dev)set_bit (BNX2FC_CNIC_REGISTERED , &hba->reg_with_cnic); } - +/** +* Deperecated: Use bnx2fc_enabled() +*/ static int bnx2fc_disable (struct net_device *netdev) {struct bnx2fc_interface *interface;
@@ -2022,7 +2046,9 @@ static int bnx2fc_disable(struct net_device *netdev)return rc; } - +/** +* Deprecated: Use bnx2fc_enabled() +*/ static int bnx2fc_enable (struct net_device *netdev) {struct bnx2fc_interface *interface;
@@ -2048,17 +2074,57 @@ static int bnx2fc_enable(struct net_device *netdev) }/** -* bnx2fc_create - Create bnx2fc FCoE interface +* bnx2fc_ctlr_enabled() - Enable or disable an FCoE Controller +* @cdev: The FCoE Controller that is being enabled or disabled * -* @buffer: The name of Ethernet interface to create on -* @kp: The associated kernel param +* fcoe_sysfs will ensure that the state of 'enabled' has +* changed, so no checking is necessary here. This routine simply +* calls fcoe_enable or fcoe_disable, both of which are deprecated. +* When those routines are removed the functionality can be merged +* here. +*/ +static int bnx2fc_ctlr_enabled (struct fcoe_ctlr_device *cdev) +{ +struct fcoe_ctlr *ctlr =fcoe_ctlr_device_priv (cdev); +struct fc_lport *lport = ctlr->lp; +struct net_device *netdev =bnx2fc_netdev (lport); + +switch (cdev->enabled) { +case FCOE_CTLR_ENABLED : +return bnx2fc_enable (netdev); +case FCOE_CTLR_DISABLED : +return bnx2fc_disable (netdev); +case FCOE_CTLR_UNUSED : +default : +return -ENOTSUPP ; + }; +} + +enum bnx2fc_create_link_state { +BNX2FC_CREATE_LINK_DOWN , +BNX2FC_CREATE_LINK_UP , +}; + +/** +* _bnx2fc_create() - Create bnx2fc FCoE interface +* @netdev : The net_device object the Ethernet interface to create on +* @fip_mode: The FIP mode for this creation +* @link_state: The ctlr link state on creation * -* Called from sysfs. +* Called from either the libfcoe 'create' module parameter +* via fcoe_create or from fcoe_syfs's ctlr_create file. +* +* libfcoe's 'create' module parameter is deprecated so some +* consolidation of code can be done when that interface is +* removed. * * Returns: 0 for success */ -static int bnx2fc_create (struct net_device *netdev,enum fip_state fip_mode) +static int _bnx2fc_create (struct net_device *netdev, +enum fip_state fip_mode, +enum bnx2fc_create_link_state link_state) { +struct fcoe_ctlr_device *cdev;struct fcoe_ctlr *ctlr;struct bnx2fc_interface *interface;struct bnx2fc_hba *hba;
@@ -2153,7 +2219,15 @@ static int bnx2fc_create(struct net_device *netdev, enum fip_state fip_mode)/* Make this master N_port */ ctlr->lp = lport; -if (!bnx2fc_link_ok (lport)) { + cdev =fcoe_ctlr_to_ctlr_dev (ctlr); + +if (link_state ==BNX2FC_CREATE_LINK_UP ) + cdev->enabled =FCOE_CTLR_ENABLED ; +else + cdev->enabled =FCOE_CTLR_DISABLED ; + +if (link_state ==BNX2FC_CREATE_LINK_UP && + !bnx2fc_link_ok (lport)) {fcoe_ctlr_link_up (ctlr);fc_host_port_type (lport->host) =FC_PORTTYPE_NPORT ;set_bit (ADAPTER_STATE_READY , &interface->hba->adapter_state);
@@ -2161,7 +2235,10 @@ static int bnx2fc_create(struct net_device *netdev, enum fip_state fip_mode)BNX2FC_HBA_DBG (lport,"create: START DISC\n" );bnx2fc_start_disc (interface); - interface->enabled = true; + +if (link_state ==BNX2FC_CREATE_LINK_UP ) + interface->enabled = true; +/* * Release from kref_init in bnx2fc_interface_setup, on success * lport should be holding a reference taken in bnx2fc_if_create
@@ -2187,6 +2264,37 @@ mod_err: }/** +* bnx2fc_create() - Create a bnx2fc interface +* @netdev : The net_device object the Ethernet interface to create on +* @fip_mode: The FIP mode for this creation +* +* Called from fcoe transport +* +* Returns: 0 for success +*/ +static int bnx2fc_create (struct net_device *netdev,enum fip_state fip_mode) +{ +return _bnx2fc_create (netdev, fip_mode,BNX2FC_CREATE_LINK_UP ); +} + +/** +* bnx2fc_ctlr_alloc() - Allocate a bnx2fc interface from fcoe_sysfs +* @netdev: The net_device to be used by the allocated FCoE Controller +* +* This routine is called from fcoe_sysfs. It will start the fcoe_ctlr +* in a link_down state. The allows the user an opportunity to configure +* the FCoE Controller from sysfs before enabling the FCoE Controller. +* +* Creating in with this routine starts the FCoE Controller in Fabric +* mode. The user can change to VN2VN or another mode before enabling. +*/ +static int bnx2fc_ctlr_alloc (struct net_device *netdev) +{ +return _bnx2fc_create (netdev,FIP_MODE_FABRIC , +BNX2FC_CREATE_LINK_DOWN ); +} + +/** * bnx2fc_find_hba_for_cnic - maps cnic instance to bnx2fc hba instance * * @cnic: Pointer to cnic device instance
@@ -2311,6 +2419,7 @@ static struct fcoe_transport bnx2fc_transport = { .name = {"bnx2fc"}, .attached = false, .list = LIST_HEAD_INIT(bnx2fc_transport.list), + .alloc = bnx2fc_ctlr_alloc, .match = bnx2fc_match, .create = bnx2fc_create, .destroy = bnx2fc_destroy,
@@ -2555,6 +2664,7 @@ module_init(bnx2fc_mod_init);module_exit (bnx2fc_mod_exit);static struct fcoe_sysfs_function_template bnx2fc_fcoe_sysfs_templ = { + .set_fcoe_ctlr_enabled = bnx2fc_ctlr_enabled, .get_fcoe_ctlr_link_fail = bnx2fc_ctlr_get_lesb, .get_fcoe_ctlr_vlink_fail = bnx2fc_ctlr_get_lesb, .get_fcoe_ctlr_miss_fka = bnx2fc_ctlr_get_lesb,
PATCH 8/21 libfc, libfcoe, fcoe: Convert debug_logging macros to pr_info
In reply to Robert LoveConvert libfc, libfcoe and fcoe's debug_logging macros to use pr_info() instead of printk(KERN_INFO, ...). checkpatch.pl now complains about this, so convert libfcoe to preferred method.
--- drivers/scsi/fcoe/fcoe.h | 6 +++--- drivers/scsi/fcoe/libfcoe.h | 9 ++++----- drivers/scsi/libfc/fc_libfc.h | 38 +++++++++++++++++++------------------- 3 files changed, 26 insertions(+), 27 deletions(-)
drivers/scsi/fcoe/fcoe.h +3 -3
@@ -55,12 +55,12 @@ do { \ #define FCOE_DBG(fmt, args...) \ FCOE_CHECK_LOGGING(FCOE_LOGGING, \ - printk(KERN_INFO "fcoe: " fmt, ##args);) + pr_info("fcoe: " fmt, ##args);) #define FCOE_NETDEV_DBG(netdev, fmt, args...) \ FCOE_CHECK_LOGGING(FCOE_NETDEV_LOGGING, \ - printk(KERN_INFO "fcoe: %s: " fmt, \ - netdev->name, ##args);) + pr_info("fcoe: %s: " fmt, \ + netdev->name, ##args);)/** * struct fcoe_interface - A FCoE interface
drivers/scsi/fcoe/libfcoe.h +4 -5
@@ -17,17 +17,16 @@ do { \ #define LIBFCOE_DBG(fmt, args...) \ LIBFCOE_CHECK_LOGGING(LIBFCOE_LOGGING, \ - printk(KERN_INFO "libfcoe: " fmt, ##args);) + pr_info("libfcoe: " fmt, ##args);) #define LIBFCOE_FIP_DBG(fip, fmt, args...) \ LIBFCOE_CHECK_LOGGING(LIBFCOE_FIP_LOGGING, \ - printk(KERN_INFO "host%d: fip: " fmt, \ - (fip)->lp->host->host_no, ##args);) + pr_info("host%d: fip: " fmt, \ + (fip)->lp->host->host_no, ##args);) #define LIBFCOE_TRANSPORT_DBG(fmt, args...) \ LIBFCOE_CHECK_LOGGING(LIBFCOE_TRANSPORT_LOGGING, \ - printk(KERN_INFO "%s: " fmt, \ - __func__, ##args);) + pr_info("%s: " fmt, __func__, ##args);) #define LIBFCOE_SYSFS_DBG(cdev, fmt, args...) \ LIBFCOE_CHECK_LOGGING(LIBFCOE_SYSFS_LOGGING, \
drivers/scsi/libfc/fc_libfc.h +19 -19
@@ -41,25 +41,25 @@ extern unsigned int fc_debug_logging; #define FC_LIBFC_DBG(fmt, args...) \ FC_CHECK_LOGGING(FC_LIBFC_LOGGING, \ - printk(KERN_INFO "libfc: " fmt, ##args)) + pr_info("libfc: " fmt, ##args)) #define FC_LPORT_DBG(lport, fmt, args...) \ FC_CHECK_LOGGING(FC_LPORT_LOGGING, \ - printk(KERN_INFO "host%u: lport %6.6x: " fmt, \ - (lport)->host->host_no, \ - (lport)->port_id, ##args)) + pr_info("host%u: lport %6.6x: " fmt, \ + (lport)->host->host_no, \ + (lport)->port_id, ##args)) -#define FC_DISC_DBG(disc, fmt, args...) \ - FC_CHECK_LOGGING(FC_DISC_LOGGING, \ - printk(KERN_INFO "host%u: disc: " fmt, \ - fc_disc_lport(disc)->host->host_no, \ - ##args)) +#define FC_DISC_DBG(disc, fmt, args...) \ + FC_CHECK_LOGGING(FC_DISC_LOGGING, \ + pr_info("host%u: disc: " fmt, \ + fc_disc_lport(disc)->host->host_no, \ + ##args)) #define FC_RPORT_ID_DBG(lport, port_id, fmt, args...) \ FC_CHECK_LOGGING(FC_RPORT_LOGGING, \ - printk(KERN_INFO "host%u: rport %6.6x: " fmt, \ - (lport)->host->host_no, \ - (port_id), ##args)) + pr_info("host%u: rport %6.6x: " fmt, \ + (lport)->host->host_no, \ + (port_id), ##args)) #define FC_RPORT_DBG(rdata, fmt, args...) \ FC_RPORT_ID_DBG((rdata)->local_port, (rdata)->ids.port_id, fmt, ##args)
@@ -70,13 +70,13 @@ extern unsigned int fc_debug_logging;if ((pkt)->seq_ptr) { \struct fc_exch *_ep =NULL ; \ _ep =fc_seq_exch ((pkt)->seq_ptr); \ - printk(KERN_INFO "host%u: fcp: %6.6x: " \ + pr_info("host%u: fcp: %6.6x: " \ "xid %04x-%04x: " fmt, \ (pkt)->lp->host->host_no, \ (pkt)->rport->port_id, \ (_ep)->oxid, (_ep)->rxid, ##args); \ } else { \ - printk(KERN_INFO "host%u: fcp: %6.6x: " fmt, \ + pr_info("host%u: fcp: %6.6x: " fmt, \ (pkt)->lp->host->host_no, \ (pkt)->rport->port_id, ##args); \ } \
@@ -84,14 +84,14 @@ extern unsigned int fc_debug_logging; #define FC_EXCH_DBG(exch, fmt, args...) \ FC_CHECK_LOGGING(FC_EXCH_LOGGING, \ - printk(KERN_INFO "host%u: xid %4x: " fmt, \ - (exch)->lp->host->host_no, \ - exch->xid, ##args)) + pr_info("host%u: xid %4x: " fmt, \ + (exch)->lp->host->host_no, \ + exch->xid, ##args)) #define FC_SCSI_DBG(lport, fmt, args...) \ FC_CHECK_LOGGING(FC_SCSI_LOGGING, \ - printk(KERN_INFO "host%u: scsi: " fmt, \ - (lport)->host->host_no, ##args)) + pr_info("host%u: scsi: " fmt, \ + (lport)->host->host_no, ##args))/* * FC-4 Providers.
PATCH 9/21 fcoe: prep work to start consolidate the usage of fcoe_netdev
In reply to Robert LoveFrom: Yi Zou <[email protected]>
Currently, in the default kernel fcoe driver, it is needed to get to the underlying private per fcoe transport's private structure, e.g., fcoe_interface in fcoe.ko, and returns the associated netdev. The similar logic exists in other fcoe drivers, e.g., bnx2fc, so we add a function pointer into the common fcoe_port struct to allow individual fcoe transport implementaion (fcoe and bnx2fc) to get the corresponding netdev associated with a give lport.
Then a inline fcoe_get_netdev() is added as part of libfcoe for all underlying fcoe transport drivers to use regardless of its individual fcoe transport driver, and also allows move more common code such as fcoe_link_speed_update or fcoe_ctlr_get_lesb to be in libfcoe, rather than specific to fcoe.
This patch is a prep work that adds aforementioned fucntion pointer, and followed by the actual code changes to make use of it.
--- include/scsi/libfcoe.h | 1 + 1 file changed, 1 insertion(+)
include/scsi/libfcoe.h +1 -0
@@ -351,6 +351,7 @@ struct fcoe_port {struct timer_list timer;struct work_struct destroy_work;u8 data_src_addr[ETH_ALEN ]; +struct net_device * (*get_netdev)(const struct fc_lport *lport); };void fcoe_clean_pending_queue (struct fc_lport *);void fcoe_check_wait_queue (struct fc_lport *lport,struct sk_buff *skb);
PATCH 10/21 fcoe: add support to the get_netdev() for fcoe_interface
In reply to Robert LoveFrom: Yi Zou <[email protected]>
Adds support to fcoe_port's newly added get_netdev fucntion pointer.
--- drivers/scsi/fcoe/fcoe.c | 1 + include/scsi/libfcoe.h | 12 ++++++++++++ 2 files changed, 13 insertions(+)
drivers/scsi/fcoe/fcoe.c +1 -0
@@ -1118,6 +1118,7 @@ static struct fc_lport *fcoe_if_create(struct fcoe_interface *fcoe, port =lport_priv (lport); port->lport = lport; port->priv = fcoe; + port->get_netdev = fcoe_netdev; port->max_queue_depth =FCOE_MAX_QUEUE_DEPTH ; port->min_queue_depth =FCOE_MIN_QUEUE_DEPTH ;INIT_WORK (&port->destroy_work, fcoe_destroy_work);
include/scsi/libfcoe.h +12 -0
@@ -353,6 +353,18 @@ struct fcoe_port {u8 data_src_addr[ETH_ALEN ];struct net_device * (*get_netdev)(const struct fc_lport *lport); }; + +/** +* fcoe_get_netdev() - Return the net device associated with a local port +* @lport: The local port to get the net device from +*/ +static inline struct net_device *fcoe_get_netdev (const struct fc_lport *lport) +{ +struct fcoe_port *port = ((struct fcoe_port *)lport_priv (lport)); + +return (port->get_netdev) ? port->get_netdev (lport) :NULL ; +} +void fcoe_clean_pending_queue (struct fc_lport *);void fcoe_check_wait_queue (struct fc_lport *lport,struct sk_buff *skb);void fcoe_queue_timer (ulong lport);
PATCH 11/21 libfcoe, fcoe: move fcoe_link_speed_update() to libfcoe and export it
In reply to Robert LoveFrom: Yi Zou <[email protected]>
With the previous patch, fcoe_link_speed_update() can be moved into libfcoe and exported to used by fcoe, bnx2fc, and etc.
--- drivers/scsi/fcoe/fcoe.c | 35 ----------------------------------- drivers/scsi/fcoe/fcoe_transport.c | 35 +++++++++++++++++++++++++++++++++++ include/scsi/libfcoe.h | 1 + 3 files changed, 36 insertions(+), 35 deletions(-)
drivers/scsi/fcoe/fcoe.c +0 -35
@@ -82,7 +82,6 @@ static int fcoe_rcv(struct sk_buff *, struct net_device *, struct packet_type *, struct net_device *);static int fcoe_percpu_receive_thread (void *);static void fcoe_percpu_clean (struct fc_lport *); -static int fcoe_link_speed_update (struct fc_lport *);static int fcoe_link_ok (struct fc_lport *);static struct fc_lport *fcoe_hostlist_lookup (const struct net_device *);
@@ -2388,40 +2387,6 @@ static int fcoe_ctlr_alloc(struct net_device *netdev) }/** -* fcoe_link_speed_update() - Update the supported and actual link speeds -* @lport: The local port to update speeds for -* -* Returns: 0 if the ethtool query was successful -* -1 if the ethtool query failed -*/ -static int fcoe_link_speed_update (struct fc_lport *lport) -{ -struct net_device *netdev =fcoe_netdev (lport); -struct ethtool_cmd ecmd; - -if (!__ethtool_get_settings (netdev, &ecmd)) { - lport->link_supported_speeds &= - ~(FC_PORTSPEED_1GBIT |FC_PORTSPEED_10GBIT ); -if (ecmd.supported & (SUPPORTED_1000baseT_Half | - SUPPORTED_1000baseT_Full)) - lport->link_supported_speeds |=FC_PORTSPEED_1GBIT ; -if (ecmd.supported & SUPPORTED_10000baseT_Full) - lport->link_supported_speeds |= -FC_PORTSPEED_10GBIT ; -switch (ethtool_cmd_speed (&ecmd)) { -case SPEED_1000 : - lport->link_speed =FC_PORTSPEED_1GBIT ; -break ; -case SPEED_10000 : - lport->link_speed =FC_PORTSPEED_10GBIT ; -break ; - } -return 0 ; - } -return -1 ; -} - -/** * fcoe_link_ok() - Check if the link is OK for a local port * @lport: The local port to check link on *
drivers/scsi/fcoe/fcoe_transport.c +35 -0
@@ -83,6 +83,41 @@ static struct notifier_block libfcoe_notifier = { .notifier_call = libfcoe_device_notification, }; +/** +* fcoe_link_speed_update() - Update the supported and actual link speeds +* @lport: The local port to update speeds for +* +* Returns: 0 if the ethtool query was successful +* -1 if the ethtool query failed +*/ +int fcoe_link_speed_update (struct fc_lport *lport) +{ +struct net_device *netdev =fcoe_get_netdev (lport); +struct ethtool_cmd ecmd; + +if (!__ethtool_get_settings (netdev, &ecmd)) { + lport->link_supported_speeds &= + ~(FC_PORTSPEED_1GBIT |FC_PORTSPEED_10GBIT ); +if (ecmd.supported & (SUPPORTED_1000baseT_Half | + SUPPORTED_1000baseT_Full)) + lport->link_supported_speeds |=FC_PORTSPEED_1GBIT ; +if (ecmd.supported & SUPPORTED_10000baseT_Full) + lport->link_supported_speeds |= +FC_PORTSPEED_10GBIT ; +switch (ethtool_cmd_speed (&ecmd)) { +case SPEED_1000 : + lport->link_speed =FC_PORTSPEED_1GBIT ; +break ; +case SPEED_10000 : + lport->link_speed =FC_PORTSPEED_10GBIT ; +break ; + } +return 0 ; + } +return -1 ; +} +EXPORT_SYMBOL_GPL (fcoe_link_speed_update); +void __fcoe_get_lesb (struct fc_lport *lport,struct fc_els_lesb *fc_lesb,struct net_device *netdev)
include/scsi/libfcoe.h +1 -0
@@ -260,6 +260,7 @@ void __fcoe_get_lesb(struct fc_lport *lport, struct fc_els_lesb *fc_lesb, struct net_device *netdev);void fcoe_wwn_to_str (u64 wwn,char *buf,int len);int fcoe_validate_vport_create (struct fc_vport *vport); +int fcoe_link_speed_update (struct fc_lport *);/** * is_fip_mode() - returns true if FIP mode selected.
PATCH 12/21 libfcoe, fcoe: consolidate the fcoe_ctlr_get_lesb/fcoe_get_lesb
In reply to Robert LoveFrom: Yi Zou <[email protected]>
Similarly they can be moved into libfcoe instead of being private to fcoe now. Also add comments particularly on the term LESB to the corresponding function.
--- drivers/scsi/fcoe/fcoe.c | 40 --------------------------- drivers/scsi/fcoe/fcoe_transport.c | 54 ++++++++++++++++++++++++++++++++++++ include/scsi/libfcoe.h | 2 + 3 files changed, 56 insertions(+), 40 deletions(-)
drivers/scsi/fcoe/fcoe.c +0 -40
@@ -130,8 +130,6 @@ static struct fc_seq *fcoe_elsct_send(struct fc_lport *, void *, u32 timeout);static void fcoe_recv_frame (struct sk_buff *skb); -static void fcoe_get_lesb (struct fc_lport *,struct fc_els_lesb *); -/* notification function for packets from net device */ static struct notifier_block fcoe_notifier = { .notifier_call = fcoe_device_notification,
@@ -155,7 +153,6 @@ static int fcoe_vport_create(struct fc_vport *, bool disabled);static int fcoe_vport_disable (struct fc_vport *,bool disable);static void fcoe_set_vport_symbolic_name (struct fc_vport *);static void fcoe_set_port_id (struct fc_lport *,u32 ,struct fc_frame *); -static void fcoe_ctlr_get_lesb (struct fcoe_ctlr_device *);static void fcoe_fcf_get_vlan_id (struct fcoe_fcf_device *);static struct fcoe_sysfs_function_template fcoe_sysfs_templ = {
@@ -2858,43 +2855,6 @@ static void fcoe_set_vport_symbolic_name(struct fc_vport *vport) NULL, NULL, 3 * lport->r_a_tov); } -/** -* fcoe_get_lesb() - Fill the FCoE Link Error Status Block -* @lport: the local port -* @fc_lesb: the link error status block -*/ -static void fcoe_get_lesb (struct fc_lport *lport, -struct fc_els_lesb *fc_lesb) -{ -struct net_device *netdev =fcoe_netdev (lport); - -__fcoe_get_lesb (lport, fc_lesb, netdev); -} - -static void fcoe_ctlr_get_lesb (struct fcoe_ctlr_device *ctlr_dev) -{ -struct fcoe_ctlr *fip =fcoe_ctlr_device_priv (ctlr_dev); -struct net_device *netdev =fcoe_netdev (fip->lp); -struct fcoe_fc_els_lesb *fcoe_lesb; -struct fc_els_lesb fc_lesb; - -__fcoe_get_lesb (fip->lp, &fc_lesb, netdev); - fcoe_lesb = (struct fcoe_fc_els_lesb *)(&fc_lesb); - - ctlr_dev->lesb.lesb_link_fail = -ntohl (fcoe_lesb->lesb_link_fail); - ctlr_dev->lesb.lesb_vlink_fail = -ntohl (fcoe_lesb->lesb_vlink_fail); - ctlr_dev->lesb.lesb_miss_fka = -ntohl (fcoe_lesb->lesb_miss_fka); - ctlr_dev->lesb.lesb_symb_err = -ntohl (fcoe_lesb->lesb_symb_err); - ctlr_dev->lesb.lesb_err_block = -ntohl (fcoe_lesb->lesb_err_block); - ctlr_dev->lesb.lesb_fcs_error = -ntohl (fcoe_lesb->lesb_fcs_error); -} -static void fcoe_fcf_get_vlan_id (struct fcoe_fcf_device *fcf_dev) { struct fcoe_ctlr_device *ctlr_dev =
drivers/scsi/fcoe/fcoe_transport.c +54 -0
66 lines not on this page · raw message
include/scsi/libfcoe.h +2 -0
@@ -261,6 +261,8 @@ void __fcoe_get_lesb(struct fc_lport *lport, struct fc_els_lesb *fc_lesb,void fcoe_wwn_to_str (u64 wwn,char *buf,int len);int fcoe_validate_vport_create (struct fc_vport *vport);int fcoe_link_speed_update (struct fc_lport *); +void fcoe_get_lesb (struct fc_lport *,struct fc_els_lesb *); +void fcoe_ctlr_get_lesb (struct fcoe_ctlr_device *ctlr_dev);/** * is_fip_mode() - returns true if FIP mode selected.
PATCH 13/21 bnx2fc: add support to get_netdev for bnx2f_interface
In reply to Robert LoveFrom: Yi Zou <[email protected]>
Adds support to fcoe_port's newly added get_netdev fucntion pointer for bnx2fc.
--- drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/scsi/bnx2fc/bnx2fc_fcoe.c +3 -2
@@ -119,7 +119,7 @@ static inline struct net_device *bnx2fc_netdev(const struct fc_lport *lport)static void bnx2fc_get_lesb (struct fc_lport *lport,struct fc_els_lesb *fc_lesb) { -struct net_device *netdev =bnx2fc_netdev (lport); +struct net_device *netdev =fcoe_get_netdev (lport);__fcoe_get_lesb (lport, fc_lesb, netdev); }
@@ -127,7 +127,7 @@ static void bnx2fc_get_lesb(struct fc_lport *lport,static void bnx2fc_ctlr_get_lesb (struct fcoe_ctlr_device *ctlr_dev) {struct fcoe_ctlr *fip =fcoe_ctlr_device_priv (ctlr_dev); -struct net_device *netdev =bnx2fc_netdev (fip->lp); +struct net_device *netdev =fcoe_get_netdev (fip->lp);struct fcoe_fc_els_lesb *fcoe_lesb;struct fc_els_lesb fc_lesb;
@@ -1499,6 +1499,7 @@ static struct fc_lport *bnx2fc_if_create(struct bnx2fc_interface *interface, port =lport_priv (lport); port->lport = lport; port->priv = interface; + port->get_netdev = bnx2fc_netdev;INIT_WORK (&port->destroy_work, bnx2fc_destroy_work);/* Configure fcoe_port */
PATCH 14/21 bnx2fc: use fcoe_link_speed_update() from the exported symbol in libfcoe
In reply to Robert LoveFrom: Yi Zou <[email protected]>
We have fcoe_link_speed_update() in libfcoe ready for use now, take out the bnx2fc version which is almost the same.
--- drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 33 ++------------------------------- 1 file changed, 2 insertions(+), 31 deletions(-)
drivers/scsi/bnx2fc/bnx2fc_fcoe.c +2 -31
@@ -738,35 +738,6 @@ static int bnx2fc_shost_config(struct fc_lport *lport, struct device *dev)return 0 ; } -static void bnx2fc_link_speed_update (struct fc_lport *lport) -{ -struct fcoe_port *port =lport_priv (lport); -struct bnx2fc_interface *interface = port->priv; -struct net_device *netdev = interface->netdev; -struct ethtool_cmd ecmd; - -if (!__ethtool_get_settings (netdev, &ecmd)) { - lport->link_supported_speeds &= - ~(FC_PORTSPEED_1GBIT |FC_PORTSPEED_10GBIT ); -if (ecmd.supported & (SUPPORTED_1000baseT_Half | - SUPPORTED_1000baseT_Full)) - lport->link_supported_speeds |=FC_PORTSPEED_1GBIT ; -if (ecmd.supported & SUPPORTED_10000baseT_Full) - lport->link_supported_speeds |=FC_PORTSPEED_10GBIT ; - -switch (ethtool_cmd_speed (&ecmd)) { -case SPEED_1000 : - lport->link_speed =FC_PORTSPEED_1GBIT ; -break ; -case SPEED_2500 : - lport->link_speed =FC_PORTSPEED_2GBIT ; -break ; -case SPEED_10000 : - lport->link_speed =FC_PORTSPEED_10GBIT ; -break ; - } - } -}static int bnx2fc_link_ok (struct fc_lport *lport) {struct fcoe_port *port =lport_priv (lport);
@@ -824,7 +795,7 @@ static int bnx2fc_net_config(struct fc_lport *lport, struct net_device *netdev) port->fcoe_pending_queue_active =0 ;setup_timer (&port->timer, fcoe_queue_timer, (unsigned long ) lport); -bnx2fc_link_speed_update (lport); +fcoe_link_speed_update (lport);if (!lport->vport) {if (fcoe_get_wwn (netdev, &wwnn,NETDEV_FCOE_WWNN ))
@@ -928,7 +899,7 @@ static void bnx2fc_indicate_netevent(void *context, unsigned long event,BNX2FC_HBA_DBG (lport,"netevent handler - event=%s %ld\n" , interface->netdev->name, event); -bnx2fc_link_speed_update (lport); +fcoe_link_speed_update (lport); cdev =fcoe_ctlr_to_ctlr_dev (ctlr);
PATCH 15/21 bnx2fc: use fcoe_get_lesb/fcoe_ctlr_get_lesb() directly from libfcoe
In reply to Robert LoveFrom: Yi Zou <[email protected]>
Drop the bnx2fc_xxx versions as they are basically the same.
--- drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 53 +++++-------------------------------- 1 file changed, 7 insertions(+), 46 deletions(-)
drivers/scsi/bnx2fc/bnx2fc_fcoe.c +7 -46
@@ -93,7 +93,6 @@ static void bnx2fc_port_shutdown(struct fc_lport *lport);static void bnx2fc_stop (struct bnx2fc_interface *interface);static int __init bnx2fc_mod_init (void ); static void __exit bnx2fc_mod_exit(void); -static void bnx2fc_ctlr_get_lesb (struct fcoe_ctlr_device *ctlr_dev);unsigned int bnx2fc_debug_level;module_param_named (debug_logging, bnx2fc_debug_level, int,S_IRUGO |S_IWUSR );
@@ -111,44 +110,6 @@ static inline struct net_device *bnx2fc_netdev(const struct fc_lport *lport) ((struct fcoe_port *)lport_priv(lport))->priv)->netdev; } -/** -* bnx2fc_get_lesb() - Fill the FCoE Link Error Status Block -* @lport: the local port -* @fc_lesb: the link error status block -*/ -static void bnx2fc_get_lesb (struct fc_lport *lport, -struct fc_els_lesb *fc_lesb) -{ -struct net_device *netdev =fcoe_get_netdev (lport); - -__fcoe_get_lesb (lport, fc_lesb, netdev); -} - -static void bnx2fc_ctlr_get_lesb (struct fcoe_ctlr_device *ctlr_dev) -{ -struct fcoe_ctlr *fip =fcoe_ctlr_device_priv (ctlr_dev); -struct net_device *netdev =fcoe_get_netdev (fip->lp); -struct fcoe_fc_els_lesb *fcoe_lesb; -struct fc_els_lesb fc_lesb; - -__fcoe_get_lesb (fip->lp, &fc_lesb, netdev); - fcoe_lesb = (struct fcoe_fc_els_lesb *)(&fc_lesb); - - ctlr_dev->lesb.lesb_link_fail = -ntohl (fcoe_lesb->lesb_link_fail); - ctlr_dev->lesb.lesb_vlink_fail = -ntohl (fcoe_lesb->lesb_vlink_fail); - ctlr_dev->lesb.lesb_miss_fka = -ntohl (fcoe_lesb->lesb_miss_fka); - ctlr_dev->lesb.lesb_symb_err = -ntohl (fcoe_lesb->lesb_symb_err); - ctlr_dev->lesb.lesb_err_block = -ntohl (fcoe_lesb->lesb_err_block); - ctlr_dev->lesb.lesb_fcs_error = -ntohl (fcoe_lesb->lesb_fcs_error); -} -EXPORT_SYMBOL (bnx2fc_ctlr_get_lesb); -static void bnx2fc_fcf_get_vlan_id (struct fcoe_fcf_device *fcf_dev) { struct fcoe_ctlr_device *ctlr_dev =
@@ -2637,12 +2598,12 @@ module_exit(bnx2fc_mod_exit);static struct fcoe_sysfs_function_template bnx2fc_fcoe_sysfs_templ = { .set_fcoe_ctlr_enabled = bnx2fc_ctlr_enabled, - .get_fcoe_ctlr_link_fail = bnx2fc_ctlr_get_lesb, - .get_fcoe_ctlr_vlink_fail = bnx2fc_ctlr_get_lesb, - .get_fcoe_ctlr_miss_fka = bnx2fc_ctlr_get_lesb, - .get_fcoe_ctlr_symb_err = bnx2fc_ctlr_get_lesb, - .get_fcoe_ctlr_err_block = bnx2fc_ctlr_get_lesb, - .get_fcoe_ctlr_fcs_error = bnx2fc_ctlr_get_lesb, + .get_fcoe_ctlr_link_fail = fcoe_ctlr_get_lesb, + .get_fcoe_ctlr_vlink_fail = fcoe_ctlr_get_lesb, + .get_fcoe_ctlr_miss_fka = fcoe_ctlr_get_lesb, + .get_fcoe_ctlr_symb_err = fcoe_ctlr_get_lesb, + .get_fcoe_ctlr_err_block = fcoe_ctlr_get_lesb, + .get_fcoe_ctlr_fcs_error = fcoe_ctlr_get_lesb, .get_fcoe_fcf_selected = fcoe_fcf_get_selected, .get_fcoe_fcf_vlan_id = bnx2fc_fcf_get_vlan_id,
@@ -2749,7 +2710,7 @@ static struct libfc_function_template bnx2fc_libfc_fcn_templ = { .elsct_send = bnx2fc_elsct_send, .fcp_abort_io = bnx2fc_abort_io, .fcp_cleanup = bnx2fc_cleanup, - .get_lesb = bnx2fc_get_lesb, + .get_lesb = fcoe_get_lesb, .rport_event_callback = bnx2fc_rport_event_handler, };
PATCH 16/21 debris left by "[SCSI] libfcoe: Remove mutex_trylock/restart_syscall checks"
In reply to Robert LoveFrom: Al Viro <[email protected]>
AFAICS, the situation for fcoe_transport_disable() seems to be
the same as for fcoe_transport_enable(). IOW, shouldn't it have restart_syscall() removed as well? I don't see any in-tree ->disable() instances that could return -ERESTARTSYS, anyway...
--- drivers/scsi/fcoe/fcoe_transport.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/scsi/fcoe/fcoe_transport.c +1 -5
@@ -962,11 +962,7 @@ out_putdev:dev_put (netdev); out_nodev:mutex_unlock (&ft_mutex); - -if (rc == -ERESTARTSYS ) -return restart_syscall (); -else -return rc; +return rc; }/**
PATCH 17/21 UAPI: (Scripted) Disintegrate include/scsi/fc
In reply to Robert LoveFrom: David Howells <[email protected]>
--- include/scsi/fc/Kbuild | 4 include/scsi/fc/fc_els.h | 831 ----------------------------------------- include/scsi/fc/fc_fs.h | 348 ----------------- include/scsi/fc/fc_gs.h | 96 ----- include/scsi/fc/fc_ns.h | 208 ---------- include/uapi/scsi/fc/Kbuild | 4 include/uapi/scsi/fc/fc_els.h | 831 +++++++++++++++++++++++++++++++++++++++++ include/uapi/scsi/fc/fc_fs.h | 348 +++++++++++++++++ include/uapi/scsi/fc/fc_gs.h | 96 +++++ include/uapi/scsi/fc/fc_ns.h | 208 ++++++++++ 10 files changed, 1487 insertions(+), 1487 deletions(-) delete mode 100644 include/scsi/fc/fc_els.h delete mode 100644 include/scsi/fc/fc_fs.h delete mode 100644 include/scsi/fc/fc_gs.h delete mode 100644 include/scsi/fc/fc_ns.h create mode 100644 include/uapi/scsi/fc/fc_els.h create mode 100644 include/uapi/scsi/fc/fc_fs.h create mode 100644 include/uapi/scsi/fc/fc_gs.h create mode 100644 include/uapi/scsi/fc/fc_ns.h
include/scsi/fc/Kbuild +0 -4
@@ -1,4 +0,0 @@ -header-y += fc_els.h -header-y += fc_fs.h -header-y += fc_gs.h -header-y += fc_ns.h
include/scsi/fc/fc_els.h deleted +0 -831
831 lines not on this page · raw message
include/scsi/fc/fc_fs.h deleted +0 -348
348 lines not on this page · raw message
include/scsi/fc/fc_gs.h deleted +0 -96
96 lines not on this page · raw message
include/scsi/fc/fc_ns.h deleted +0 -208
208 lines not on this page · raw message
include/uapi/scsi/fc/Kbuild +4 -0
@@ -1 +1,5 @@ # UAPI Header export list +header-y += fc_els.h +header-y += fc_fs.h +header-y += fc_gs.h +header-y += fc_ns.h
include/uapi/scsi/fc/fc_els.h new file +831 -0
831 lines not on this page · raw message
include/uapi/scsi/fc/fc_fs.h new file +348 -0
348 lines not on this page · raw message
include/uapi/scsi/fc/fc_gs.h new file +96 -0
96 lines not on this page · raw message
include/uapi/scsi/fc/fc_ns.h new file +208 -0
208 lines not on this page · raw message
PATCH 18/21 fcoe: close race on link speed detection in fcoe code
In reply to Robert LoveFrom: Neil Horman <[email protected]>
When creating an fcoe interfce, we call fcoe_link_speed_update before we add the lports fcoe interface to the fc_hostlist. Since network device events like NETDEV_CHANGE are only processed if an fcoe interface is found with an underlying netdev that matches the netdev of the event. Since this processing in fcoe_device_notification is how link_speed changes get communicated to the libfc code (via fcoe_link_speed_update), we have a race condition - if a NETDEV_CHANGE event is sent after the call to fcoe_link_speed_update in fcoe_netdev_config, but before we add the interface to the fc_hostlist, we will loose the event and attributes like /sys/class/fc_host/hostX/speed will not get updated properly.
Fix this by moving the add to the fc_hostlist above the serialized call to fcoe_netdev_config, ensuring that we catch netdev envents before we make a direct call to fcoe_link_speed_update.
Also use this opportunity to clean up access to the fc_hostlist a bit by creating a fcoe_hostlist_del accessor and replacing the cleanup in fcoe_exit to use it properly.
Tested by myself successfully
[ Comment over 80 chars broken into multi-line by Robert Love to
satisfy checkpatch.pl ]
--- drivers/scsi/fcoe/fcoe.c | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-)
drivers/scsi/fcoe/fcoe.c +27 -4
@@ -86,6 +86,7 @@ static int fcoe_link_ok(struct fc_lport *);static struct fc_lport *fcoe_hostlist_lookup (const struct net_device *);static int fcoe_hostlist_add (const struct fc_lport *); +static void fcoe_hostlist_del (const struct fc_lport *);static int fcoe_device_notification (struct notifier_block *,ulong ,void *);static void fcoe_dev_setup (void );
@@ -1119,6 +1120,12 @@ static struct fc_lport *fcoe_if_create(struct fcoe_interface *fcoe, port->min_queue_depth =FCOE_MIN_QUEUE_DEPTH ;INIT_WORK (&port->destroy_work, fcoe_destroy_work); +/* +* Need to add the lport to the hostlist +* so we catch NETDEV_CHANGE events. +*/ +fcoe_hostlist_add (lport); +/* configure a fc_lport including the exchange manager */ rc =fcoe_lport_config (lport);if (rc) {
@@ -1190,6 +1197,7 @@ static struct fc_lport *fcoe_if_create(struct fcoe_interface *fcoe, out_lp_destroy:fc_exch_mgr_free (lport); out_host_put: +fcoe_hostlist_del (lport);scsi_host_put (lport->host); out:return ERR_PTR (rc);
@@ -2313,9 +2321,6 @@ static int _fcoe_create(struct net_device *netdev, enum fip_state fip_mode,/* setup DCB priority attributes. */ fcoe_dcb_create (fcoe); -/* add to lports list */ -fcoe_hostlist_add (lport); -/* start FIP Discovery and FLOGI */ lport->boot_time = jiffies;fc_fabric_login (lport);
@@ -2523,6 +2528,24 @@ static int fcoe_hostlist_add(const struct fc_lport *lport)return 0 ; } +/** +* fcoe_hostlist_del() - Remove the FCoE interface identified by a local +* port to the hostlist +* @lport: The local port that identifies the FCoE interface to be added +* +* Locking: must be called with the RTNL mutex held +* +*/ +static void fcoe_hostlist_del (const struct fc_lport *lport) +{ +struct fcoe_interface *fcoe; +struct fcoe_port *port; + + port =lport_priv (lport); + fcoe = port->priv; +list_del (&fcoe->list); +return ; +}static struct fcoe_transport fcoe_sw_transport = { .name = {FCOE_TRANSPORT_DEFAULT },
@@ -2613,9 +2636,9 @@ static void __exit fcoe_exit(void)/* releases the associated fcoe hosts */ rtnl_lock ();list_for_each_entry_safe (fcoe, tmp, &fcoe_hostlist, list) { -list_del (&fcoe->list); ctlr =fcoe_to_ctlr (fcoe); port =lport_priv (ctlr->lp); +fcoe_hostlist_del (port->lport);queue_work (fcoe_wq, &port->destroy_work); }rtnl_unlock ();
PATCH 19/21 fcoe: Fix deadlock while deleting FCoE interface with NPIV ports
In reply to Robert LoveFrom: Neerav Parikh <[email protected]>
This patch fixes following deadlock caused by destroying of an FCoE interface with active NPIV ports on that interface.
Call Trace:
[<ffffffff814b7e88>] schedule+0x64/0x66
[<ffffffff814b6b4f>] schedule_timeout+0x36/0xe3
[<ffffffff81070c55>] ? update_curr+0xd6/0x110
[<ffffffff81071f6b>] ? hrtick_update+0x1b/0x4d
[<ffffffff81072405>] ? dequeue_task_fair+0x1ca/0x1d9
[<ffffffff8106a369>] ? need_resched+0x1e/0x28
[<ffffffff814b7d14>] wait_for_common+0x9b/0xf1
[<ffffffff8106e7be>] ? try_to_wake_up+0x1e0/0x1e0
[<ffffffff814b7e22>] wait_for_completion+0x1d/0x1f
[<ffffffff8105ae82>] flush_workqueue+0x116/0x2a1
[<ffffffff8105b357>] drain_workqueue+0x66/0x14c
[<ffffffff8105b8ef>] destroy_workqueue+0x1a/0xcf
[<ffffffffa009211e>] fc_remove_host+0x154/0x17f [scsi_transport_fc]
[<ffffffffa00edbb8>] fcoe_if_destroy+0x184/0x1c9 [fcoe]
[<ffffffffa00edc28>] fcoe_destroy_work+0x2b/0x44 [fcoe]
[<ffffffff8105a82a>] process_one_work+0x1a8/0x2a4
[<ffffffffa00edbfd>] ? fcoe_if_destroy+0x1c9/0x1c9 [fcoe]
[<ffffffff8105c396>] worker_thread+0x1db/0x268
[<ffffffff810604a3>] ? wake_up_bit+0x2a/0x2a
[<ffffffff8105c1bb>] ? manage_workers.clone.16+0x1f6/0x1f6
[<ffffffff8105ffd6>] kthread+0x6f/0x77
[<ffffffff814c0304>] kernel_thread_helper+0x4/0x10
[<ffffffff8105ff67>] ? kthread_freezable_should_stop+0x4b/0x4b
Call Trace:
[<ffffffff814b7e88>] schedule+0x64/0x66
[<ffffffff814b8041>] schedule_preempt_disabled+0xe/0x10
[<ffffffff814b70a1>] __mutex_lock_common.clone.5+0x117/0x17a
[<ffffffff814b7117>] __mutex_lock_slowpath+0x13/0x15
[<ffffffff814b6f76>] mutex_lock+0x23/0x37
[<ffffffff8125b890>] ? list_del+0x11/0x30
[<ffffffffa00edc84>] fcoe_vport_destroy+0x43/0x5f [fcoe]
[<ffffffffa009130a>] fc_vport_terminate+0x48/0x110 [scsi_transport_fc]
[<ffffffffa00913ef>] fc_vport_sched_delete+0x1d/0x79 [scsi_transport_fc]
[<ffffffff8105a82a>] process_one_work+0x1a8/0x2a4
[<ffffffffa00913d2>] ? fc_vport_terminate+0x110/0x110 [scsi_transport_fc]
[<ffffffff8105c396>] worker_thread+0x1db/0x268
[<ffffffff8105c1bb>] ? manage_workers.clone.16+0x1f6/0x1f6
[<ffffffff8105ffd6>] kthread+0x6f/0x77
[<ffffffff814c0304>] kernel_thread_helper+0x4/0x10
[<ffffffff8105ff67>] ? kthread_freezable_should_stop+0x4b/0x4b
[<ffffffff814c0300>] ? gs_change+0x13/0x13A prior attempt to fix this issue is posted here:
http://lists.open-fcoe.org/pipermail/devel/2012-October/012318.html
or
http://article.gmane.org/gmane.linux.scsi.open-fcoe.devel/11924
Based on feedback and discussion with Neil Horman it seems that the above patch may have a case where the fcoe_vport_destroy() and fcoe_destroy_work() can race; hence that patch has been withdrawn with this patch that is trying to solve the same problem in a different way.
In the current approach instead of removing the fcoe_config_mutex from the vport_delete callback function; I've chosen to delete all the NPIV ports first on a given root lport before continuing with the removal of the root lport.
--- drivers/scsi/fcoe/fcoe.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
drivers/scsi/fcoe/fcoe.c +23 -0
@@ -2196,8 +2196,31 @@ static void fcoe_destroy_work(struct work_struct *work) {struct fcoe_port *port;struct fcoe_interface *fcoe; +struct Scsi_Host *shost; +struct fc_host_attrs *fc_host; +unsigned long flags; +struct fc_vport *vport; +struct fc_vport *next_vport; port = container_of(work, struct fcoe_port, destroy_work); + shost = port->lport->host; + fc_host =shost_to_fc_host (shost); + +/* Loop through all the vports and mark them for deletion */ +spin_lock_irqsave (shost->host_lock, flags); +list_for_each_entry_safe (vport, next_vport, &fc_host->vports, peers) { +if (vport->flags & (FC_VPORT_DEL |FC_VPORT_CREATING )) { +continue ; + }else { + vport->flags |=FC_VPORT_DELETING ; +queue_work (fc_host_work_q (shost), + &vport->vport_delete_work); + } + } +spin_unlock_irqrestore (shost->host_lock, flags); + +flush_workqueue (fc_host_work_q (shost)); +mutex_lock (&fcoe_config_mutex); fcoe = port->priv;
PATCH 20/21 libfcoe: Handle CVL while waiting to select an FCF
In reply to Robert LoveFrom: Bhanu Prakash Gollapudi <[email protected]>
When a CVL is received while we wait to select best FCF, we drop it without handling it. This causes initiator and the switch to go out-of-sync. Initiator proceeds selecting one of the FCFs and tries to send FIP FLOGI. However the switch may reject the FLOGI, as it has cleared its internal state, and expects the initiator to start FIP discovery protocol. Fix this condition by resetting the fcoe controller.
--- drivers/scsi/fcoe/fcoe_ctlr.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/scsi/fcoe/fcoe_ctlr.c +9 -1
@@ -1291,8 +1291,16 @@ static void fcoe_ctlr_recv_clr_vlink(struct fcoe_ctlr *fip,LIBFCOE_FIP_DBG (fip,"Clear Virtual Link received\n" ); -if (!fcf || !lport->port_id) +if (!fcf || !lport->port_id) { +/* +* We are yet to select best FCF, but we got CVL in the +* meantime. reset the ctlr and let it rediscover the FCF +*/ +mutex_lock (&fip->ctlr_mutex); +fcoe_ctlr_reset (fip); +mutex_unlock (&fip->ctlr_mutex);return ; + }/* * mask of required descriptors. Validating each one clears its bit.
PATCH 21/21 libfc: XenServer fails to mount root filesystem.
In reply to Robert LoveFrom: Krishna Mohan <[email protected]>
schedule_delayed_work() is using msec instead of jiffies. On PLOGI reject from target, remote port retry is scheduled @ 20 sec instead of 2sec(FC_DEF_E_D_TOV).
XenServer dom0 kernel is configured with CONFIG_HZ=100Hz
--- drivers/scsi/libfc/fc_rport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/libfc/fc_rport.c +1 -1
@@ -582,7 +582,7 @@ static void fc_rport_error(struct fc_rport_priv *rdata, struct fc_frame *fp)static void fc_rport_error_retry (struct fc_rport_priv *rdata,struct fc_frame *fp) { -unsigned long delay =FC_DEF_E_D_TOV ; +unsigned long delay =msecs_to_jiffies (FC_DEF_E_D_TOV );/* make sure this isn't an FC_EX_CLOSED error, never retry those */ if (PTR_ERR (fp) == -FC_EX_CLOSED )
Quoted 6 lines · Robert Love
This series is mostly a resend of previously sent patches. The primary change in this series is the addition of the
fcoe_sysfs"control" interfaces. Additionally there are a few fix/cleanup patches and UAPI conversions. Almost all of these patches have already been reviewed on linux-scsi.I will compose a pull-request and send it soon, but I wanted to make sure the most recent versions of these patches were posted to linux-scsi first.
---
I missed one patch in this series. I will send it now. It is included in the patch set covered by the signed-tag in the forthcoming request-pull mail. Sorry for the confusion.
Thanks, //Rob