FC Sysfs and FCoE attributes
v2 cover FC Sysfs and FCoE attributes
v2: First posting came from a scsi-misc tree with two additional fcoe patches. The posting did not include the two initial fcoe patches. Those first two patches are unrelated to this body of work, but are needed for later patches to apply. V2 includes these two patches.
---
The following series adds a new FC subsystem/sysfs layout to the kernel. It also adds FCoE attributes to the new devices. An initial usage by libfc, libfcoe, fcoe and fnic is also in this series.
This change is quite large and touches a lot of things. My current TODO list is:
1) target support
2) user space
- libhbalinux: have a start on support, but not complete
- libVirt
3) bnx2fc
4) sysfs usage: not sure I'm doing things correctly
At this point I have working code, but I would appreciate any review comments as there are a lot of design decisions to be made.
I apologize for the very large patches. I am not sure how to break them up better. I have tried a few ways, but the resultant patches tend to be more complicated than when they are merged. Any suggestions on how to make these patches smaller or more easily reviewable would be appreciated as well.
---
Robert Love (10):
libfcoe: Remove mutex_trylock/restart_syscall checks
fcoe: Remove mutex_trylock/restart_syscall checks
fc: Create FC sybsystem
scsi_transport_fcp: Create FC/SCSI interaction layer libfc, libfcoe, fcoe: Make use of FC subsystem
fc: Add FCoE attributes to FC sysfs
libfcoe, fcoe: Use FCoE attributes
fnic: Convert to new FC Sysfs infrastructure
fc: Add a hbaapi_lib attribute to the fcport structure
Documentation: Add fc_sysfs document
Documentation/fc/fc_sysfs.txt | 192 ++++ Documentation/fc/libfc_libfcoe_fcoe.txt | 17 drivers/Kconfig | 2 drivers/Makefile | 1 drivers/fc/Kconfig | 8 drivers/fc/Makefile | 10 drivers/fc/fcfabric.c | 547 +++++++++++ drivers/fc/fcfabric_fcoe.c | 123 ++ drivers/fc/fcport.c | 453 +++++++++ drivers/fc/fcport_fcoe.c | 134 +++ drivers/fc/fcrport.c | 1012 ++++++++++++++++++++ drivers/fc/fcsysfs.c | 176 +++ drivers/fc/fcsysfs.h | 102 ++ drivers/fc/fcvport.c | 695 ++++++++++++++ drivers/fc/fcvport_fcoe.c | 118 ++ drivers/scsi/Kconfig | 12 drivers/scsi/Makefile | 1 drivers/scsi/fcoe/fcoe.c | 770 ++++++++------- drivers/scsi/fcoe/fcoe.h | 6 drivers/scsi/fcoe/fcoe_ctlr.c | 310 ++++-- drivers/scsi/fcoe/fcoe_transport.c | 36 - drivers/scsi/fcoe/libfcoe.h | 4 drivers/scsi/fnic/fnic.h | 33 - drivers/scsi/fnic/fnic_fcs.c | 32 - drivers/scsi/fnic/fnic_isr.c | 13 drivers/scsi/fnic/fnic_main.c | 412 ++++---- drivers/scsi/fnic/fnic_res.c | 47 - drivers/scsi/fnic/fnic_scsi.c | 193 ++-- drivers/scsi/libfc/fc_disc.c | 4 drivers/scsi/libfc/fc_exch.c | 11 drivers/scsi/libfc/fc_fcp.c | 120 +- drivers/scsi/libfc/fc_libfc.h | 40 - drivers/scsi/libfc/fc_lport.c | 208 ++-- drivers/scsi/libfc/fc_npiv.c | 87 +- drivers/scsi/libfc/fc_rport.c | 19 drivers/scsi/scsi_transport_fcp.c | 1571 +++++++++++++++++++++++++++++++ include/fc/fc.h | 1055 +++++++++++++++++++++ include/scsi/fc_encode.h | 40 - include/scsi/libfc.h | 96 +- include/scsi/libfcoe.h | 18 include/scsi/scsi_transport_fcp.h | 307 ++++++ 41 files changed, 7926 insertions(+), 1109 deletions(-) create mode 100644 Documentation/fc/fc_sysfs.txt create mode 100644 Documentation/fc/libfc_libfcoe_fcoe.txt create mode 100644 drivers/fc/Kconfig create mode 100644 drivers/fc/Makefile create mode 100644 drivers/fc/fcfabric.c create mode 100644 drivers/fc/fcfabric_fcoe.c create mode 100644 drivers/fc/fcport.c create mode 100644 drivers/fc/fcport_fcoe.c create mode 100644 drivers/fc/fcrport.c create mode 100644 drivers/fc/fcsysfs.c create mode 100644 drivers/fc/fcsysfs.h create mode 100644 drivers/fc/fcvport.c create mode 100644 drivers/fc/fcvport_fcoe.c create mode 100644 drivers/scsi/scsi_transport_fcp.c create mode 100644 include/fc/fc.h create mode 100644 include/scsi/scsi_transport_fcp.h
Signature · 1 line
Thanks, //Rob
RFC PATCH v2 1/10 libfcoe: Remove mutex_trylock/restart_syscall checks
This code was incorrectly ported from fcoe.c when the fcoe transport infrastructure was put into place. It was originally needed in fcoe.c when dealing with the rtnl mutex. In that code it was only needed to avoid a lockdep false positive. In libfcoe we don't deal with the rtnl mutex, we don't get the lockdep false positive and therefore we don't need these checks.
--- drivers/scsi/fcoe/fcoe_transport.c | 36 +++++++++++------------------------- 1 files changed, 11 insertions(+), 25 deletions(-)
drivers/scsi/fcoe/fcoe_transport.c +11 -25
@@ -530,9 +530,6 @@ static int fcoe_transport_create(const char *buffer, struct kernel_param *kp)struct fcoe_transport *ft =NULL ;enum fip_state fip_mode = (enum fip_state )(long )kp->arg; -if (!mutex_trylock (&ft_mutex)) -return restart_syscall (); -#ifdef CONFIG_LIBFCOE_MODULE /* * Make sure the module has been initialized, and is not about to be
@@ -543,6 +540,8 @@ static int fcoe_transport_create(const char *buffer, struct kernel_param *kp) goto out_nodev;#endif +mutex_lock (&ft_mutex); + netdev =fcoe_if_to_netdev (buffer);if (!netdev) {LIBFCOE_TRANSPORT_DBG ("Invalid device %s.\n" , buffer);
@@ -586,10 +585,7 @@ out_putdev:dev_put (netdev); out_nodev:mutex_unlock (&ft_mutex); -if (rc == -ERESTARTSYS ) -return restart_syscall (); -else -return rc; +return rc; }/**
@@ -608,9 +604,6 @@ static int fcoe_transport_destroy(const char *buffer, struct kernel_param *kp)struct net_device *netdev =NULL ;struct fcoe_transport *ft =NULL ; -if (!mutex_trylock (&ft_mutex)) -return restart_syscall (); -#ifdef CONFIG_LIBFCOE_MODULE /* * Make sure the module has been initialized, and is not about to be
@@ -621,6 +614,8 @@ static int fcoe_transport_destroy(const char *buffer, struct kernel_param *kp) goto out_nodev;#endif +mutex_lock (&ft_mutex); + netdev =fcoe_if_to_netdev (buffer);if (!netdev) {LIBFCOE_TRANSPORT_DBG ("invalid device %s.\n" , buffer);
@@ -645,11 +640,7 @@ out_putdev:dev_put (netdev); out_nodev:mutex_unlock (&ft_mutex); - -if (rc == -ERESTARTSYS ) -return restart_syscall (); -else -return rc; +return rc; }/**
@@ -667,9 +658,6 @@ static int fcoe_transport_disable(const char *buffer, struct kernel_param *kp)struct net_device *netdev =NULL ;struct fcoe_transport *ft =NULL ; -if (!mutex_trylock (&ft_mutex)) -return restart_syscall (); -#ifdef CONFIG_LIBFCOE_MODULE /* * Make sure the module has been initialized, and is not about to be
@@ -680,6 +668,8 @@ static int fcoe_transport_disable(const char *buffer, struct kernel_param *kp) goto out_nodev;#endif +mutex_lock (&ft_mutex); + netdev =fcoe_if_to_netdev (buffer);if (!netdev) goto out_nodev;
@@ -716,9 +706,6 @@ static int fcoe_transport_enable(const char *buffer, struct kernel_param *kp)struct net_device *netdev =NULL ;struct fcoe_transport *ft =NULL ; -if (!mutex_trylock (&ft_mutex)) -return restart_syscall (); -#ifdef CONFIG_LIBFCOE_MODULE /* * Make sure the module has been initialized, and is not about to be
@@ -729,6 +716,8 @@ static int fcoe_transport_enable(const char *buffer, struct kernel_param *kp) goto out_nodev;#endif +mutex_lock (&ft_mutex); + netdev =fcoe_if_to_netdev (buffer);if (!netdev) goto out_nodev;
@@ -743,10 +732,7 @@ out_putdev:dev_put (netdev); out_nodev:mutex_unlock (&ft_mutex); -if (rc == -ERESTARTSYS ) -return restart_syscall (); -else -return rc; +return rc; }/**
RFC PATCH v2 2/10 fcoe: Remove mutex_trylock/restart_syscall checks
In reply to Robert LoveThese checks were initially added to avoid a lockdep false positive when dealing with the s_active, rtnl and fcoe_config_mutex mutexes. Recently the create, destroy, enable and disable sysfs entries were moved from fcoe.ko to libfcoe.ko. With this change the mutex usage was shuffled around and the lockdep false positive stopped happening. We can now remove these checks.
--- drivers/scsi/fcoe/fcoe.c | 24 ++++-------------------- 1 files changed, 4 insertions(+), 20 deletions(-)
drivers/scsi/fcoe/fcoe.c +4 -20
@@ -1797,11 +1797,7 @@ static int fcoe_disable(struct net_device *netdev) }#endif -if (!rtnl_trylock ()) { -mutex_unlock (&fcoe_config_mutex); -return -ERESTARTSYS ; - } - +rtnl_lock (); fcoe =fcoe_hostlist_lookup_port (netdev);rtnl_unlock ();
@@ -1841,11 +1837,7 @@ static int fcoe_enable(struct net_device *netdev) goto out_nodev; }#endif -if (!rtnl_trylock ()) { -mutex_unlock (&fcoe_config_mutex); -return -ERESTARTSYS ; - } - +rtnl_lock (); fcoe =fcoe_hostlist_lookup_port (netdev);rtnl_unlock ();
@@ -1884,11 +1876,7 @@ static int fcoe_destroy(struct net_device *netdev) goto out_nodev; }#endif -if (!rtnl_trylock ()) { -mutex_unlock (&fcoe_config_mutex); -return -ERESTARTSYS ; - } - +rtnl_lock (); fcoe =fcoe_hostlist_lookup_port (netdev);if (!fcoe) {rtnl_unlock ();
@@ -1950,11 +1938,7 @@ static int fcoe_create(struct net_device *netdev, enum fip_state fip_mode)struct fc_lport *lport;mutex_lock (&fcoe_config_mutex); - -if (!rtnl_trylock ()) { -mutex_unlock (&fcoe_config_mutex); -return -ERESTARTSYS ; - } +rtnl_lock ();#ifdef CONFIG_FCOE_MODULE /*
RFC PATCH v2 3/10 fc: Create FC sybsystem
In reply to Robert LoveThis patch creates a Fibre Channel subsystem. This new FC layer allows different FC4 types to register with it; it also allows LLDs to register with it. When a LLD supports one of the FC4s registered, the FC layer allows the FC4 to be transported over the LLD.
This patch creates files under drivers/fc/ that expose APIs to both the FC4s and LLDs. The API to the FC4s allow FC4s to register with FC so that they can be used by LLDs. The API to the LLDs allows the LLDs to add fcports, fcfabrics, fcvports and fcrports to sysfs and to make use of the registered FC4s.
The patch creates the following FC devices. The attributes for each new device are taken from the existing FC Transport code.
fcport: Represents physical port
Attributes: maxframe_size
supported_speeds
speed
supported_fc4s
active_fc4s
supported_classes
serial_number
fcfabric: Represents the FC fabric and switch (FCF for FCoE)
Attributes: fabric_name
max_npiv_vports npiv_vports_inuse vport_create
vport_delete
vport_disable
fcvport: Represents either an N_Port or VN_Port
Attributes: port_id
node_name
port_name
port_type
vport_state
vport_last_state
roles
vport_type (duplicate)
symbolic_name
tgtid_bind_type
issue_lip
fcrport: Represents FC remote ports
Attributes: fast_io_fail_tmo
port_id
port_state
roles
node_name
port_name
supported_classes
maxframe_size
dev_loss_tmo
One major thing to note is that there is not an object-wise distinction between N_Ports and VN_Ports; all instances are of type struct fc_vport.
--- drivers/Kconfig | 2 drivers/Makefile | 1 drivers/fc/Kconfig | 8 drivers/fc/Makefile | 7 drivers/fc/fcfabric.c | 540 ++++++++++++++++++++++++++ drivers/fc/fcport.c | 445 ++++++++++++++++++++++ drivers/fc/fcrport.c | 1012 +++++++++++++++++++++++++++++++++++++++++++++++++ drivers/fc/fcsysfs.c | 176 +++++++++ drivers/fc/fcsysfs.h | 92 ++++ drivers/fc/fcvport.c | 687 +++++++++++++++++++++++++++++++++ include/fc/fc.h | 952 ++++++++++++++++++++++++++++++++++++++++++++++ 11 files changed, 3922 insertions(+), 0 deletions(-) create mode 100644 drivers/fc/Kconfig create mode 100644 drivers/fc/Makefile create mode 100644 drivers/fc/fcfabric.c create mode 100644 drivers/fc/fcport.c create mode 100644 drivers/fc/fcrport.c create mode 100644 drivers/fc/fcsysfs.c create mode 100644 drivers/fc/fcsysfs.h create mode 100644 drivers/fc/fcvport.c create mode 100644 include/fc/fc.h
drivers/Kconfig +2 -0
@@ -30,6 +30,8 @@ source "drivers/target/Kconfig" source "drivers/message/fusion/Kconfig" +source "drivers/fc/Kconfig" + source "drivers/firewire/Kconfig" source "drivers/message/i2o/Kconfig"
drivers/Makefile +1 -0
@@ -52,6 +52,7 @@ obj-y += net/ obj-$(CONFIG_ATM) += atm/ obj-$(CONFIG_FUSION) += message/ obj-y += firewire/ +obj-$(CONFIG_FC) += fc/ obj-$(CONFIG_UIO) += uio/ obj-y += cdrom/ obj-y += auxdisplay/
drivers/fc/Kconfig new file +8 -0
@@ -0,0 +1,8 @@ +menu "Experimental Fibre Channel Support" + +config FC + tristate "Fibre Channel Support" + ---help--- + Experimental Fibre Channel Support + +endmenu
drivers/fc/Makefile new file +7 -0
@@ -0,0 +1,7 @@ +obj-$(CONFIG_FC) += fc.o + +fc-objs := fcsysfs.o \ + fcport.o \ + fcfabric.o \ + fcvport.o \ + fcrport.o
drivers/fc/fcfabric.c new file +540 -0
540 lines not on this page · raw message
drivers/fc/fcport.c new file +445 -0
445 lines not on this page · raw message
drivers/fc/fcrport.c new file +1012 -0
1,012 lines not on this page · raw message
drivers/fc/fcsysfs.c new file +176 -0
176 lines not on this page · raw message
drivers/fc/fcsysfs.h new file +92 -0
92 lines not on this page · raw message
drivers/fc/fcvport.c new file +687 -0
687 lines not on this page · raw message
include/fc/fc.h new file +952 -0
18 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
RFC PATCH v2 4/10 scsi_transport_fcp: Create FC/SCSI interaction layer
In reply to Robert LoveThis patch adds SCSI (initiator) as FC4 type that registers with the FC layer. This layer bridges the FC subsystem and the SCSI subsystem. When a fcvport is created in the FC layer a callback is made to scsi_transport_fcp and a fcpinit and Scsi_Host are allocated and added to sysfs. When a fcrport is created in the FC layer a callback is made to scsi_transport_fcp and a fcptarg is allocated, added to sysfs and SCSI is notified to scan.
The devices created by scsi_transport_fcp are:
fcpinit: Object that bridges fcvport and Scsi_Host
Attributes: fcp_statistics
fcptarg: Object that bridges fcrports and stargets
Attributes: scsi_target_id
The fcptarg is not linked to the scsi targets in sysfs right now.
--- drivers/scsi/Kconfig | 10 drivers/scsi/Makefile | 1 drivers/scsi/scsi_transport_fcp.c | 1571 +++++++++++++++++++++++++++++++++++++ include/scsi/scsi_transport_fcp.h | 307 +++++++ 4 files changed, 1889 insertions(+), 0 deletions(-) create mode 100644 drivers/scsi/scsi_transport_fcp.c create mode 100644 include/scsi/scsi_transport_fcp.h
drivers/scsi/Kconfig +10 -0
@@ -299,6 +299,16 @@ config SCSI_FC_ATTRS each attached FiberChannel device to sysfs, say Y. Otherwise, say N. +config SCSI_FCP_ATTRS + tristate "Experimental Fiber Channel Protocol Transport Attributes" + depends on SCSI + depends on FC + select SCSI_NETLINK + help + If you wish to export transport-specific information about + each attached FiberChannel device to sysfs, say Y. + Otherwise, say N. + config SCSI_FC_TGT_ATTRS bool "SCSI target support for FiberChannel Transport Attributes" depends on SCSI_FC_ATTRS
drivers/scsi/Makefile +1 -0
@@ -30,6 +30,7 @@ obj-$(CONFIG_RAID_ATTRS) += raid_class.o # -------------------------- obj-$(CONFIG_SCSI_SPI_ATTRS) += scsi_transport_spi.o obj-$(CONFIG_SCSI_FC_ATTRS) += scsi_transport_fc.o +obj-$(CONFIG_SCSI_FCP_ATTRS) += scsi_transport_fcp.o obj-$(CONFIG_SCSI_ISCSI_ATTRS) += scsi_transport_iscsi.o obj-$(CONFIG_SCSI_SAS_ATTRS) += scsi_transport_sas.o obj-$(CONFIG_SCSI_SAS_LIBSAS) += libsas/
drivers/scsi/scsi_transport_fcp.c new file +1571 -0
1,571 lines not on this page · raw message
include/scsi/scsi_transport_fcp.h new file +307 -0
307 lines not on this page · raw message
RFC PATCH v2 5/10 libfc, libfcoe, fcoe: Make use of FC subsystem
In reply to Robert LoveThis patch makes libfc, libfcoe and fcoe use the FC subsystem instead of directly interacting with existing FC Transport. The FC devices are allocated, added to sysfs, deleted from sysfs and freed as follows:
Allocate/Add
* fcport allocated/added when an fcoe interface is created
* fcvport allocated when an fcoe interface is created
* fcfabric allocated/added when a FCF is discovered
* fcvport added when FLOGI ACC is received
Delete/Free
* fcvport deleted when LOGO sent
* fcfabric deleted/freed when FCFs are removed
* fcvport freed when an fcoe interface is created
* fcport deleted/freed when an fcoe interface is created
The allocation scheme for libfc, libfcoe and fcoe's primary data structures is illustrated here:
http://www.open-fcoe.org/open-fcoe/wiki/fc-sysfs-diagrams
--- drivers/scsi/Kconfig | 1 drivers/scsi/fcoe/fcoe.c | 643 +++++++++++++++++++++-------------------- drivers/scsi/fcoe/fcoe.h | 6 drivers/scsi/fcoe/fcoe_ctlr.c | 299 ++++++++++++------- drivers/scsi/fcoe/libfcoe.h | 4 drivers/scsi/libfc/fc_disc.c | 4 drivers/scsi/libfc/fc_exch.c | 11 - drivers/scsi/libfc/fc_fcp.c | 120 +++----- drivers/scsi/libfc/fc_libfc.h | 40 +-- drivers/scsi/libfc/fc_lport.c | 206 +++++++------ drivers/scsi/libfc/fc_npiv.c | 87 +++--- drivers/scsi/libfc/fc_rport.c | 19 + include/scsi/fc_encode.h | 40 ++- include/scsi/libfc.h | 95 ++++-- include/scsi/libfcoe.h | 18 + 15 files changed, 878 insertions(+), 715 deletions(-)
drivers/scsi/Kconfig +1 -0
@@ -692,6 +692,7 @@ config LIBFCOE config FCOE tristate "FCoE module" depends on PCI + select SCSI_FCP_ATTRS select LIBFCOE ---help--- Fibre Channel over Ethernet module
drivers/scsi/fcoe/fcoe.c +324 -319
941 lines not on this page · raw message
drivers/scsi/fcoe/fcoe.h +6 -0
@@ -89,6 +89,12 @@ struct fcoe_interface {#define fcoe_from_ctlr (fip) container_of(fip, struct fcoe_interface, ctlr) +#define fcoe_to_fcport (fcoe) \ + ((struct fc_port *)(((struct fc_port *)(fcoe)) - 1)) + +#define ctlr_to_fcport (x) \ + fcoe_to_fcport(container_of((x), struct fcoe_interface, ctlr)); +/** * fcoe_netdev() - Return the net device associated with a local port * @lport: The local port to get the net device from
drivers/scsi/fcoe/fcoe_ctlr.c +196 -103
720 lines not on this page · raw message
drivers/scsi/fcoe/libfcoe.h +2 -2
@@ -20,8 +20,8 @@ do { \ #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);) + printk(KERN_INFO "fcport%u: fip: " fmt, \ + fc_port_id((fip)->lp->fcport), ##args);) #define LIBFCOE_TRANSPORT_DBG(fmt, args...) \ LIBFCOE_CHECK_LOGGING(LIBFCOE_TRANSPORT_LOGGING, \
drivers/scsi/libfc/fc_disc.c +3 -1
@@ -382,6 +382,7 @@ err:*/ static int fc_disc_gpn_ft_parse (struct fc_disc *disc,void *buf,size_t len) { +struct fc_vport *fcvport;struct fc_lport *lport;struct fc_gpn_ft_resp *np;char *bp;
@@ -392,6 +393,7 @@ static int fc_disc_gpn_ft_parse(struct fc_disc *disc, void *buf, size_t len)struct fc_rport_priv *rdata; lport =fc_disc_lport (disc); + fcvport =lport_to_fcvport (lport); disc->seq_count++;/*
@@ -436,7 +438,7 @@ static int fc_disc_gpn_ft_parse(struct fc_disc *disc, void *buf, size_t len) ids.port_name =ntohll (np->fp_wwpn);if (ids.port_id != lport->port_id && - ids.port_name != lport->wwpn) { + ids.port_name !=fc_vport_port_name (fcvport)) { rdata = lport->tt.rport_create (lport, ids.port_id);if (rdata) { rdata->ids.port_name = ids.port_name;
drivers/scsi/libfc/fc_exch.c +4 -7
@@ -1826,8 +1826,7 @@ static void fc_exch_els_rec(struct fc_frame *rfp) rxid =ntohs (rp->rec_rx_id); oxid =ntohs (rp->rec_ox_id); - ep =fc_exch_lookup (lport, - sid ==fc_host_port_id (lport->host) ? oxid : rxid); + ep =fc_exch_lookup (lport, sid == lport->port_id ? oxid : rxid); explan =ELS_EXPL_OXID_RXID ;if (!ep) goto reject;
@@ -1994,13 +1993,11 @@ err:*/ static void fc_exch_rrq (struct fc_exch *ep) { -struct fc_lport *lport; +struct fc_lport *lport = ep->lp;struct fc_els_rrq *rrq;struct fc_frame *fp;u32 did; - lport = ep->lp; - fp =fc_frame_alloc (lport,sizeof (*rrq));if (!fp) goto retry;
@@ -2060,8 +2057,8 @@ static void fc_exch_els_rrq(struct fc_frame *fp)* lookup subject exchange. */ sid =ntoh24 (rp->rrq_s_id);/* subject source */ - xid =fc_host_port_id (lport->host) == sid ? -ntohs (rp->rrq_ox_id) :ntohs (rp->rrq_rx_id); + xid = lport->port_id == sid ? +ntohs (rp->rrq_ox_id) :ntohs (rp->rrq_rx_id); ep =fc_exch_lookup (lport, xid); explan =ELS_EXPL_OXID_RXID ;if (!ep)
drivers/scsi/libfc/fc_fcp.c +53 -67
271 lines not on this page · raw message
drivers/scsi/libfc/fc_libfc.h +20 -20
@@ -45,20 +45,20 @@ extern unsigned int fc_debug_logging; #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, \ + printk(KERN_INFO "fcport%u: lport %6x: " fmt, \ + fc_port_id((lport)->fcport), \ (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, \ +#define FC_DISC_DBG(disc, fmt, args...) \ + FC_CHECK_LOGGING(FC_DISC_LOGGING, \ + printk(KERN_INFO "fcport%u: disc: " fmt, \ + fc_port_id(fc_disc_lport(disc)->fcport), \ ##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, \ + printk(KERN_INFO "fcport%u: rport %6x: " fmt, \ + fc_port_id((lport)->fcport), \ (port_id), ##args)) #define FC_RPORT_DBG(rdata, fmt, args...) \
@@ -70,28 +70,28 @@ 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: " \ - "xid %04x-%04x: " fmt, \ - (pkt)->lp->host->host_no, \ - (pkt)->rport->port_id, \ - (_ep)->oxid, (_ep)->rxid, ##args); \ + printk(KERN_INFO "fcport%u: fcp: %6.6x: " \ + "xid %04x-%04x: " fmt, \ + fc_port_id((pkt)->lp->fcport), \ + (pkt)->rport->port_id, \ + (_ep)->oxid, (_ep)->rxid, ##args); \ } else { \ - printk(KERN_INFO "host%u: fcp: %6.6x: " fmt, \ - (pkt)->lp->host->host_no, \ - (pkt)->rport->port_id, ##args); \ + printk(KERN_INFO "fcport%u: fcp: %6.6x: " fmt, \ + fc_port_id((pkt)->lp->fcport), \ + (pkt)->rport->port_id, ##args); \ } \ }) #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, \ + printk(KERN_INFO "fcport%u: xid %4x: " fmt, \ + fc_port_id((exch)->lp->fcport), \ 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)) + printk(KERN_INFO "fcport%u: scsi: " fmt, \ + fc_port_id((lport)->fcport), ##args))/* * FC-4 Providers.
drivers/scsi/libfc/fc_lport.c +115 -91
480 lines not on this page · raw message
drivers/scsi/libfc/fc_npiv.c +53 -34
136 lines not on this page · raw message
drivers/scsi/libfc/fc_rport.c +11 -8
@@ -256,6 +256,7 @@ static void fc_rport_work(struct work_struct *work)struct fc_rport_libfc_priv *rpriv;enum fc_rport_event event;struct fc_lport *lport = rdata->local_port; +struct fc_vport *fcvport =lport_to_fcvport (lport);struct fc_rport_operations *rport_ops;struct fc_rport_identifiers ids;struct fc_rport *rport;
@@ -278,7 +279,7 @@ static void fc_rport_work(struct work_struct *work)mutex_unlock (&rdata->rp_mutex);if (!rport) - rport =fc_remote_port_add (lport->host,0 , &ids); + rport =fc_rport_add (fcvport, &ids);if (!rport) {FC_RPORT_DBG (rdata,"Failed to add the rport\n" ); lport->tt.rport_logoff (rdata);
@@ -293,11 +294,11 @@ static void fc_rport_work(struct work_struct *work) rport->supported_classes = rdata->supported_classes; rpriv = rport->dd_data; - rpriv->local_port = lport; rpriv->rp_state = rdata->rp_state; rpriv->flags = rdata->flags; rpriv->e_d_tov = rdata->e_d_tov; rpriv->r_a_tov = rdata->r_a_tov; + rpriv->local_port = lport;mutex_unlock (&rdata->rp_mutex);if (rport_ops && rport_ops->event_callback) {
@@ -348,7 +349,7 @@ static void fc_rport_work(struct work_struct *work)mutex_lock (&rdata->rp_mutex); rdata->rport =NULL ;mutex_unlock (&rdata->rp_mutex); -fc_remote_port_delete (rport); +fc_rport_del (rport); }mutex_lock (&lport->disc.disc_mutex);
@@ -1102,7 +1103,7 @@ static void fc_rport_enter_prli(struct fc_rport_priv *rdata) }fc_fill_fc_hdr (fp,FC_RCTL_ELS_REQ , rdata->ids.port_id, -fc_host_port_id (lport->host),FC_TYPE_ELS , + lport->port_id,FC_TYPE_ELS ,FC_FC_FIRST_SEQ |FC_FC_END_SEQ |FC_FC_SEQ_INIT ,0 ); if (!lport->tt.exch_seq_send(lport, fp, fc_rport_prli_resp,
@@ -1387,12 +1388,13 @@ static void fc_rport_recv_rls_req(struct fc_rport_priv *rdata, {struct fc_lport *lport = rdata->local_port; +struct fc_fcp_internal *si =fc_get_scsi_internal (lport);struct fc_frame *fp;struct fc_els_rls *rls;struct fc_els_rls_resp *rsp;struct fc_els_lesb *lesb;struct fc_seq_els_data rjt_data; -struct fc_host_statistics *hst; +struct fcp_init_statistics *hst;FC_RPORT_DBG (rdata,"Received RLS request while in state %s\n" ,fc_rport_state (rdata));
@@ -1419,8 +1421,8 @@ static void fc_rport_recv_rls_req(struct fc_rport_priv *rdata,/* get LESB from LLD if it supports it */ lport->tt.get_lesb (lport, lesb); }else { -fc_get_host_stats (lport->host); - hst = &lport->host_stats; +fc_get_fcpinit_stats (lport->fcpinit); + hst = &si->fcpinit_stats; lesb->lesb_link_fail =htonl (hst->link_failure_count); lesb->lesb_sync_loss =htonl (hst->loss_of_sync_count); lesb->lesb_sig_loss =htonl (hst->loss_of_signal_count);
@@ -1564,6 +1566,7 @@ void fc_rport_recv_req(struct fc_lport *lport, struct fc_frame *fp)static void fc_rport_recv_plogi_req (struct fc_lport *lport,struct fc_frame *rx_fp) { +struct fc_vport *fcvport =lport_to_fcvport (lport);struct fc_disc *disc;struct fc_rport_priv *rdata;struct fc_frame *fp = rx_fp;
@@ -1619,7 +1622,7 @@ static void fc_rport_recv_plogi_req(struct fc_lport *lport,break ;case RPORT_ST_PLOGI :FC_RPORT_DBG (rdata,"Received PLOGI in PLOGI state\n" ); -if (rdata->ids.port_name < lport->wwpn) { +if (rdata->ids.port_name <fc_vport_port_name (fcvport)) {mutex_unlock (&rdata->rp_mutex); rjt_data.reason =ELS_RJT_INPROG ; rjt_data.explan =ELS_EXPL_NONE ;
include/scsi/fc_encode.h +25 -15
@@ -82,13 +82,16 @@ static inline void fc_fill_fc_hdr(struct fc_frame *fp, enum fc_rctl r_ctl,*/ static inline void fc_adisc_fill (struct fc_lport *lport,struct fc_frame *fp) { +struct fc_vport *fcvport =lport_to_fcvport (lport);struct fc_els_adisc *adisc; adisc =fc_frame_payload_get (fp,sizeof (*adisc));memset (adisc,0 ,sizeof (*adisc)); adisc->adisc_cmd =ELS_ADISC ; -put_unaligned_be64 (lport->wwpn, &adisc->adisc_wwpn); -put_unaligned_be64 (lport->wwnn, &adisc->adisc_wwnn); +put_unaligned_be64 (fc_vport_port_name (fcvport), + &adisc->adisc_wwpn); +put_unaligned_be64 (fc_vport_node_name (fcvport), + &adisc->adisc_wwnn);hton24 (adisc->adisc_port_id, lport->port_id); }
@@ -126,6 +129,7 @@ static inline int fc_ct_fill(struct fc_lport *lport, unsigned int op, enum fc_rctl *r_ctl, enum fc_fh_type *fh_type) { + struct fc_vport *fcvport = lport_to_fcvport(lport);struct fc_ct_req *ct;size_t len;
@@ -159,24 +163,26 @@ static inline int fc_ct_fill(struct fc_lport *lport,case FC_NS_RNN_ID : ct =fc_ct_hdr_fill (fp, op,sizeof (struct fc_ns_rn_id ));hton24 (ct->payload.rn.fr_fid.fp_fid, lport->port_id); -put_unaligned_be64 (lport->wwnn, &ct->payload.rn.fr_wwn); +put_unaligned_be64 (fc_vport_node_name (fcvport), + &ct->payload.rn.fr_wwn);break ;case FC_NS_RSPN_ID : - len =strnlen (fc_host_symbolic_name (lport->host),255 ); + len =strnlen (fc_vport_symbolic_name (fcvport),255 ); ct =fc_ct_hdr_fill (fp, op,sizeof (struct fc_ns_rspn ) + len);hton24 (ct->payload.spn.fr_fid.fp_fid, lport->port_id);strncpy (ct->payload.spn.fr_name, -fc_host_symbolic_name (lport->host), len); +fc_vport_symbolic_name (fcvport), len); ct->payload.spn.fr_name_len = len;break ;case FC_NS_RSNN_NN : - len =strnlen (fc_host_symbolic_name (lport->host),255 ); + len =strnlen (fc_vport_symbolic_name (fcvport),255 ); ct =fc_ct_hdr_fill (fp, op,sizeof (struct fc_ns_rsnn ) + len); -put_unaligned_be64 (lport->wwnn, &ct->payload.snn.fr_wwn); +put_unaligned_be64 (fc_vport_node_name (fcvport), + &ct->payload.snn.fr_wwn);strncpy (ct->payload.snn.fr_name, -fc_host_symbolic_name (lport->host), len); +fc_vport_symbolic_name (fcvport), len); ct->payload.snn.fr_name_len = len;break ;
@@ -194,6 +200,7 @@ static inline int fc_ct_fill(struct fc_lport *lport,static inline void fc_plogi_fill (struct fc_lport *lport,struct fc_frame *fp,unsigned int op) { +struct fc_vport *fcvport =lport_to_fcvport (lport);struct fc_els_flogi *plogi;struct fc_els_csp *csp;struct fc_els_cssp *cp;
@@ -201,8 +208,8 @@ static inline void fc_plogi_fill(struct fc_lport *lport, struct fc_frame *fp, plogi =fc_frame_payload_get (fp,sizeof (*plogi));memset (plogi,0 ,sizeof (*plogi)); plogi->fl_cmd = (u8 ) op; -put_unaligned_be64 (lport->wwpn, &plogi->fl_wwpn); -put_unaligned_be64 (lport->wwnn, &plogi->fl_wwnn); +put_unaligned_be64 (fc_vport_port_name (fcvport), &plogi->fl_wwpn); +put_unaligned_be64 (fc_vport_node_name (fcvport), &plogi->fl_wwnn); csp = &plogi->fl_csp; csp->sp_hi_ver =0x20 ;
@@ -226,6 +233,7 @@ static inline void fc_plogi_fill(struct fc_lport *lport, struct fc_frame *fp,*/ static inline void fc_flogi_fill (struct fc_lport *lport,struct fc_frame *fp) { +struct fc_vport *fcvport =lport_to_fcvport (lport);struct fc_els_csp *sp;struct fc_els_cssp *cp;struct fc_els_flogi *flogi;
@@ -233,8 +241,8 @@ static inline void fc_flogi_fill(struct fc_lport *lport, struct fc_frame *fp) flogi =fc_frame_payload_get (fp,sizeof (*flogi));memset (flogi,0 ,sizeof (*flogi)); flogi->fl_cmd = (u8 )ELS_FLOGI ; -put_unaligned_be64 (lport->wwpn, &flogi->fl_wwpn); -put_unaligned_be64 (lport->wwnn, &flogi->fl_wwnn); +put_unaligned_be64 (fc_vport_port_name (fcvport), &flogi->fl_wwpn); +put_unaligned_be64 (fc_vport_node_name (fcvport), &flogi->fl_wwnn); sp = &flogi->fl_csp; sp->sp_hi_ver =0x20 ; sp->sp_lo_ver =0x20 ;
@@ -251,6 +259,7 @@ static inline void fc_flogi_fill(struct fc_lport *lport, struct fc_frame *fp)*/ static inline void fc_fdisc_fill (struct fc_lport *lport,struct fc_frame *fp) { +struct fc_vport *fcvport =lport_to_fcvport (lport);struct fc_els_csp *sp;struct fc_els_cssp *cp;struct fc_els_flogi *fdisc;
@@ -258,8 +267,8 @@ static inline void fc_fdisc_fill(struct fc_lport *lport, struct fc_frame *fp) fdisc =fc_frame_payload_get (fp,sizeof (*fdisc));memset (fdisc,0 ,sizeof (*fdisc)); fdisc->fl_cmd = (u8 )ELS_FDISC ; -put_unaligned_be64 (lport->wwpn, &fdisc->fl_wwpn); -put_unaligned_be64 (lport->wwnn, &fdisc->fl_wwnn); +put_unaligned_be64 (fc_vport_port_name (fcvport), &fdisc->fl_wwpn); +put_unaligned_be64 (fc_vport_node_name (fcvport), &fdisc->fl_wwnn); sp = &fdisc->fl_csp; sp->sp_hi_ver =0x20 ; sp->sp_lo_ver =0x20 ;
@@ -274,13 +283,14 @@ static inline void fc_fdisc_fill(struct fc_lport *lport, struct fc_frame *fp)*/ static inline void fc_logo_fill (struct fc_lport *lport,struct fc_frame *fp) { +struct fc_vport *fcvport =lport_to_fcvport (lport);struct fc_els_logo *logo; logo =fc_frame_payload_get (fp,sizeof (*logo));memset (logo,0 ,sizeof (*logo)); logo->fl_cmd =ELS_LOGO ;hton24 (logo->fl_n_port_id, lport->port_id); - logo->fl_n_port_wwn =htonll (lport->wwpn); + logo->fl_n_port_wwn =htonll (fc_vport_port_name (fcvport)); }/**
include/scsi/libfc.h +55 -40
95 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
RFC PATCH v2 6/10 fc: Add FCoE attributes to FC sysfs
In reply to Robert LoveThis patch adds fcoe attributes to the FC subsystem.
fcport: Represents physical port
Attributes: enode_mac_address
vlan_id
vn_port_mac_address
fcfabric: Represents the FC fabric and switch (FCF for FCoE)
Attributes: fc_map
fka_period
mac_address
priority
vfid
fcvport: Represents either an N_Port or VN_Port
Attributes: err_block_count (Link Error Status Block)
fcs_err_count (LESB) link_failure_count (LESB) miss_fka_count (LESB) symb_err_count (LESB) vlink_failure_count (LESB)
NOTE: Currently I'm using kobj directly to add a fcoe/ subdirectory under the fc devices. I don't think this is the right thing to do. I would appreciate any advice on the correct way to add a subdirectory.
--- drivers/fc/Makefile | 5 +- drivers/fc/fcfabric.c | 9 ++- drivers/fc/fcfabric_fcoe.c | 123 ++++++++++++++++++++++++++++++++++++++ drivers/fc/fcport.c | 8 ++ drivers/fc/fcport_fcoe.c | 134 +++++++++++++++++++++++++++++++++++++++++ drivers/fc/fcsysfs.h | 10 +++ drivers/fc/fcvport.c | 10 +++ drivers/fc/fcvport_fcoe.c | 118 ++++++++++++++++++++++++++++++++++++ drivers/scsi/fcoe/fcoe.c | 2 - drivers/scsi/fcoe/fcoe_ctlr.c | 5 +- drivers/scsi/libfc/fc_lport.c | 4 + include/fc/fc.h | 103 ++++++++++++++++++++++++++++++-- 12 files changed, 518 insertions(+), 13 deletions(-) create mode 100644 drivers/fc/fcfabric_fcoe.c create mode 100644 drivers/fc/fcport_fcoe.c create mode 100644 drivers/fc/fcvport_fcoe.c
drivers/fc/Makefile +4 -1
@@ -4,4 +4,7 @@ fc-objs := fcsysfs.o \ fcport.o \ fcfabric.o \ fcvport.o \ - fcrport.o + fcrport.o \ + fcport_fcoe.o \ + fcfabric_fcoe.o \ + fcvport_fcoe.o
drivers/fc/fcfabric.c +8 -1
@@ -383,6 +383,9 @@ static void fc_fabric_final_delete(struct work_struct *work)mutex_unlock (&fcport->lock); +if (fcfabric->private_fcfabric_fcoe_kobj) +fc_fabric_del_fcoe_attrs (fcfabric); +device_del (&fcfabric->dev);put_device (&fcfabric->dev);/* self-reference */ }
@@ -457,7 +460,8 @@ struct class fcfabric_class = {*/ struct fc_fabric *fc_fabric_add (struct fc_port *fcport,struct fc_fabric_function_template *fcn_tmpl, -struct fc_fabric *new_fcfabric) +struct fc_fabric *new_fcfabric, +struct fc_fabric_fcoe_attrs *fcoe_attrs) {struct fc_fabric *fcfabric;int error =0 ;
@@ -526,6 +530,9 @@ struct fc_fabric *fc_fabric_add(struct fc_port *fcport,if (error || count !=0 ) goto out_del_dev; +if (fcoe_attrs) +fc_fabric_add_fcoe_attrs (fcfabric, fcoe_attrs); +return fcfabric; out_del_dev:
drivers/fc/fcfabric_fcoe.c new file +123 -0
123 lines not on this page · raw message
drivers/fc/fcport.c +7 -1
@@ -225,6 +225,9 @@ void fc_port_del(struct fc_port *fcport)destroy_workqueue (fcport->work_q); fcport->work_q =NULL ; +if (fcport->private_fcport_fcoe_kobj) +fc_port_del_fcoe_attrs (fcport); +device_del (&fcport->dev);put_device (&fcport->dev);/* self-reference */ }
@@ -242,7 +245,7 @@ EXPORT_SYMBOL(fc_port_del);*/ struct fc_port *fc_port_add (struct device *pdev,struct fc_port_function_template *fcn_tmpl, -void *fc4_f) +void *fc4_f,struct fc_port_fcoe_attrs *fcoe_attrs) {struct fc_port *fcport;int count =0 ;
@@ -316,6 +319,9 @@ struct fc_port *fc_port_add(struct device *pdev,if (error || count !=0 ) goto out_del_dev; +if (fcoe_attrs) +fc_port_add_fcoe_attrs (fcport, fcoe_attrs); +return fcport; out_del_dev:
drivers/fc/fcport_fcoe.c new file +134 -0
134 lines not on this page · raw message
drivers/fc/fcsysfs.h +10 -0
@@ -89,4 +89,14 @@ const char *get_fc_port_state_name(enum fc_port_state table_key);const char *get_fc_vport_state_name (enum fc_vport_state table_key); +/* FCoE Attribute Interfaces */ +int fc_port_add_fcoe_attrs (struct fc_port *fcport, +struct fc_port_fcoe_attrs *fcoe_attrs); +void fc_port_del_fcoe_attrs (struct fc_port *fcport); +int fc_fabric_add_fcoe_attrs (struct fc_fabric *fcfabric, +struct fc_fabric_fcoe_attrs *fcoe_attrs); +void fc_fabric_del_fcoe_attrs (struct fc_fabric *fcfabric); +int fc_vport_add_fcoe_attrs (struct fc_vport *fcvport); +void fc_vport_del_fcoe_attrs (struct fc_vport *fcvport); +#endif /*_FC_SYSFS_H_*/
drivers/fc/fcvport.c +9 -1
@@ -356,6 +356,9 @@ void fc_vport_del(struct fc_vport *fcvport)fc_vport_flush_work (fcvport); +if (fcvport->private_fcvport_fcoe_kobj) +fc_vport_del_fcoe_attrs (fcvport); +put_device (&fcvport->dev);/* For rports list */ device_del (&fcvport->dev);put_device (fcvport->dev.parent);
@@ -481,13 +484,15 @@ EXPORT_SYMBOL(fc_vport_alloc);/** * fc_vport_add() - Add a FC vport to a FC fabric +* @fcfabric: The Fabric to add the vport to * @fcvport: The FC vport to add +* @fcoe: Is the FC vport a FCoE vport? * * Add the device to sysfs and then populate it with * attributes. */ int fc_vport_add (struct fc_fabric *fcfabric, -struct fc_vport *fcvport) +struct fc_vport *fcvport,int fcoe) {int count =0 ;int error =0 ;
@@ -545,6 +550,9 @@ int fc_vport_add(struct fc_fabric *fcfabric,if (error || count !=0 ) goto out_del_dev; +if (fcoe) +fc_vport_add_fcoe_attrs (fcvport); +return 0 ; out_del_dev:
drivers/fc/fcvport_fcoe.c new file +118 -0
118 lines not on this page · raw message
drivers/scsi/fcoe/fcoe.c +1 -1
@@ -399,7 +399,7 @@ static struct fcoe_interface *fcoe_interface_create(struct net_device *netdev, } fcport =fc_port_add ((struct device *)&netdev->dev.parent, - &fcoe_fcport_fcn_tmpl, &fcoe_fcp_template); + &fcoe_fcport_fcn_tmpl, &fcoe_fcp_template,NULL );if (!fcport) {printk (KERN_ERR "Failed to add a fcport\n" ); fcoe =ERR_PTR (-ENOMEM );
drivers/scsi/fcoe/fcoe_ctlr.c +3 -2
@@ -956,7 +956,7 @@ static void fcoe_ctlr_recv_adv(struct fcoe_ctlr *fip, struct sk_buff *skb) first =list_empty (&fcport->fabrics); fcfabric =fc_fabric_add (fcport, fip->fcfabric_f, - new_fcfabric); + new_fcfabric,NULL );if (unlikely (!fcfabric)) goto out;
@@ -2733,7 +2733,8 @@ unlock:/* If port ID is new, notify local port after dropping ctlr_mutex */ if (new_port_id) { - fcvport->fcfabric =fc_fabric_add (fcport, fip->fcfabric_f,0 ); + fcvport->fcfabric =fc_fabric_add (fcport, fip->fcfabric_f, +0 ,NULL );fc_lport_set_local_id (fip->lp, new_port_id); } }
drivers/scsi/libfc/fc_lport.c +2 -2
@@ -760,7 +760,7 @@ void fc_lport_set_local_id(struct fc_lport *lport, u32 port_id)case LPORT_ST_FLOGI :if (port_id) {mutex_lock (&fcport->lock); -fc_vport_add (lport->fcfabric, fcvport); +fc_vport_add (lport->fcfabric, fcvport,0 );mutex_unlock (&fcport->lock);fc_lport_enter_ready (lport);
@@ -1554,7 +1554,7 @@ void fc_lport_flogi_resp(struct fc_seq *sp, struct fc_frame *fp,fc_lport_set_port_id (lport, did, fp);mutex_lock (&fcport->lock); -fc_vport_add (lport->fcfabric, fcvport); +fc_vport_add (lport->fcfabric, fcvport,0 );mutex_unlock (&fcport->lock);fc_lport_enter_dns (lport);
include/fc/fc.h +99 -4
180 lines not on this page · raw message
RFC PATCH v2 7/10 libfcoe, fcoe: Use FCoE attributes
In reply to Robert LoveUse the new interfaces to add fcoe attributes to the FC syfs layout.
--- drivers/scsi/fcoe/fcoe.c | 101 ++++++++++++++++++++++++++++++++++------- drivers/scsi/fcoe/fcoe_ctlr.c | 24 ++++++---- drivers/scsi/libfc/fc_lport.c | 6 ++ include/scsi/libfc.h | 1 4 files changed, 104 insertions(+), 28 deletions(-)
drivers/scsi/fcoe/fcoe.c +84 -17
@@ -123,6 +123,10 @@ static void fcoe_get_vport_ids(struct fc_lport *lport,struct fc_vport_identifiers *ids); */ +static void fcoe_get_fcport_vn_port_mac_address (struct fc_port *); +static int fcoe_get_fcvport_fcoe_lesb (struct fc_vport *, +struct fc_vport_fcoe_lesb *); +/* notification function for packets from net device */ static struct notifier_block fcoe_notifier = { .notifier_call = fcoe_device_notification,
@@ -211,6 +215,8 @@ struct fc_port_function_template fcoe_fcport_fcn_tmpl = { .dd_fcvport_size = (sizeof(struct fc_lport) + sizeof(struct fcoe_port)), + .get_fcvport_fcoe_lesb = fcoe_get_fcvport_fcoe_lesb, + .fcrport_f = { .dd_fcrport_size = sizeof(struct fc_rport_libfc_priv), .show_rport_maxframe_size = 1,
@@ -220,6 +226,11 @@ struct fc_port_function_template fcoe_fcport_fcn_tmpl = { .terminate_rport_io = fc_rport_terminate_io, }, }, + + .show_fcport_enode_mac_address = 1, + .show_fcport_vlan_id = 1, + + .get_fcport_vn_port_mac_address = fcoe_get_fcport_vn_port_mac_address, };struct fc_fabric_function_template fcoe_fcfabric_fcn_tmpl = {
@@ -228,6 +239,12 @@ struct fc_fabric_function_template fcoe_fcfabric_fcn_tmpl = { .show_fcfabric_fabric_name = 1, .show_fcfabric_dev_loss_tmo = 1, .dd_fcfabric_size = sizeof(struct fcoe_fcf), + + .show_fcfabric_fc_map = 1, + .show_fcfabric_vfid = 1, + .show_fcfabric_mac_address = 1, + .show_fcfabric_priority = 1, + .show_fcfabric_fka_period = 1, }; static void _fcoe_get_vport_ids(struct fcoe_interface *fcoe,
@@ -288,6 +305,32 @@ static void fcoe_set_port_name(struct fc_lport *lport)} */ + +static int fcoe_get_san_mac (struct net_device *netdev,u8 mac_addr[ETH_ALEN ]) +{ +struct netdev_hw_addr *ha; +struct net_device *real_dev; +int ret = -ENOENT ; + +/* look for SAN MAC address, if multiple SAN MACs exist, only +* use the first one for SPMA */ + real_dev = (netdev->priv_flags &IFF_802_1Q_VLAN ) ? +vlan_dev_real_dev (netdev) : netdev; +rcu_read_lock (); +for_each_dev_addr (real_dev, ha) { +if ((ha->type ==NETDEV_HW_ADDR_T_SAN ) && + (is_valid_ether_addr (ha->addr))) { +memcpy (mac_addr, ha->addr,ETH_ALEN ); + ret =0 ; +break ; + } + } +rcu_read_unlock (); + +return ret; +} + +/** * fcoe_interface_setup() - Setup a FCoE interface * @fcoe: The new FCoE interface
@@ -300,8 +343,6 @@ static int fcoe_interface_setup(struct fcoe_interface *fcoe, struct net_device *netdev) {struct fcoe_ctlr *fip = &fcoe->ctlr; -struct netdev_hw_addr *ha; -struct net_device *real_dev;u8 flogi_maddr[ETH_ALEN ];const struct net_device_ops *ops;
@@ -326,20 +367,9 @@ static int fcoe_interface_setup(struct fcoe_interface *fcoe,return -EOPNOTSUPP ; } -/* look for SAN MAC address, if multiple SAN MACs exist, only -* use the first one for SPMA */ - real_dev = (netdev->priv_flags &IFF_802_1Q_VLAN ) ? -vlan_dev_real_dev (netdev) : netdev; -rcu_read_lock (); -for_each_dev_addr (real_dev, ha) { -if ((ha->type ==NETDEV_HW_ADDR_T_SAN ) && - (is_valid_ether_addr (ha->addr))) { -memcpy (fip->ctl_src_addr, ha->addr,ETH_ALEN ); - fip->spma =1 ; -break ; - } - } -rcu_read_unlock (); +/* Will not change ctlr_src_addr if there is no SAN MAC */ +if (!fcoe_get_san_mac (netdev, fip->ctl_src_addr)) + fip->spma =1 ;/* setup Source Mac Address */ if (!fip->spma)
@@ -388,9 +418,14 @@ static struct fcoe_interface *fcoe_interface_create(struct net_device *netdev, enum fip_state fip_mode) {struct fc_port *fcport; +struct fc_port_fcoe_attrs fcoe_attrs;struct fcoe_interface *fcoe;int err; +fcoe_get_san_mac (netdev, fcoe_attrs.enode_mac_address); +if (netdev->priv_flags &IFF_802_1Q_VLAN ) + fcoe_attrs.vlan_id =vlan_dev_vlan_id (netdev); +if (!try_module_get (THIS_MODULE )) {FCOE_NETDEV_DBG (netdev,"Could not get a reference to the module\n" );
@@ -399,7 +434,8 @@ static struct fcoe_interface *fcoe_interface_create(struct net_device *netdev, } fcport =fc_port_add ((struct device *)&netdev->dev.parent, - &fcoe_fcport_fcn_tmpl, &fcoe_fcp_template,NULL ); + &fcoe_fcport_fcn_tmpl, &fcoe_fcp_template, + &fcoe_attrs);if (!fcport) {printk (KERN_ERR "Failed to add a fcport\n" ); fcoe =ERR_PTR (-ENOMEM );
@@ -585,6 +621,7 @@ static u8 *fcoe_get_src_mac(struct fc_lport *lport)*/ static int fcoe_lport_config (struct fc_lport *lport) { + lport->fcoe =1 ; lport->link_up =0 ; lport->qfull =0 ; lport->max_retry_count =3 ;
@@ -2559,3 +2596,33 @@ static void fcoe_set_port_id(struct fc_lport *lport,if (fp &&fc_frame_payload_op (fp) ==ELS_FLOGI )fcoe_ctlr_recv_flogi (&fcoe->ctlr, lport, fp); } + +static void fcoe_get_fcport_vn_port_mac_address (struct fc_port *fcport) +{ +struct fcoe_interface *fcoe =fc_port_priv (fcport); +struct fc_lport *lport = fcoe->ctlr.lp; +struct fcoe_port *port =lport_priv (lport); + +memcpy (fcport->fcoe_attrs.vn_port_mac_address, + port->data_src_addr,ETH_ALEN ); +} + +static int fcoe_get_fcvport_fcoe_lesb (struct fc_vport *fcvport, +struct fc_vport_fcoe_lesb *lesb) +{ +struct fc_lport *lport =fc_vport_priv (fcvport); +struct fc_els_lesb fc_lesb; +struct fcoe_fc_els_lesb *fcoe_lesb; + +fcoe_get_lesb (lport, &fc_lesb); + fcoe_lesb = (struct fcoe_fc_els_lesb *)(&fc_lesb); + + lesb->link_failure_count = fcoe_lesb->lesb_link_fail; + lesb->vlink_failure_count = fcoe_lesb->lesb_vlink_fail; + lesb->miss_fka_count = fcoe_lesb->lesb_miss_fka; + lesb->symb_err_count = fcoe_lesb->lesb_symb_err; + lesb->err_block_count = fcoe_lesb->lesb_err_block; + lesb->fcs_err_count = fcoe_lesb->lesb_fcs_error; + +return 0 ; +}
drivers/scsi/fcoe/fcoe_ctlr.c +15 -9
@@ -190,14 +190,12 @@ static void fcoe_ctlr_reset_fcfs(struct fcoe_ctlr *fip)void fcoe_ctlr_destroy (struct fcoe_ctlr *fip) {struct fc_port *fcport = fip->lp->fcport; -struct fc_vport *fcvport =lport_to_fcvport (fip->lp);cancel_work_sync (&fip->recv_work);skb_queue_purge (&fip->fip_recv_list);mutex_lock (&fcport->lock);fcoe_ctlr_set_state (fip,FIP_ST_DISABLED ); - fcvport->fcfabric =NULL ;fcoe_ctlr_reset_fcfs (fip);mutex_unlock (&fcport->lock);del_timer_sync (&fip->timer);
@@ -931,6 +929,7 @@ static void fcoe_ctlr_recv_adv(struct fcoe_ctlr *fip, struct sk_buff *skb)struct fc_fabric *fcfabric;struct fcoe_fcf *fcf;struct fcoe_fcf new; +struct fc_fabric_fcoe_attrs fcoe_attrs;unsigned long sol_tov =msecs_to_jiffies (FCOE_CTRL_SOL_TOV );int first =0 ;int mtu_valid;
@@ -955,8 +954,14 @@ static void fcoe_ctlr_recv_adv(struct fcoe_ctlr *fip, struct sk_buff *skb)*/ first =list_empty (&fcport->fabrics); + fcoe_attrs.fc_map = new.fc_map; + fcoe_attrs.vfid = new.vfid; +memcpy (fcoe_attrs.mac_address, new.fcf_mac,ETH_ALEN ); + fcoe_attrs.priority = new.pri; + fcoe_attrs.fka_period = new.fka_period; + fcfabric =fc_fabric_add (fcport, fip->fcfabric_f, - new_fcfabric,NULL ); + new_fcfabric, &fcoe_attrs);if (unlikely (!fcfabric)) goto out;
@@ -2732,11 +2737,13 @@ unlock:mutex_unlock (&fcport->lock);/* If port ID is new, notify local port after dropping ctlr_mutex */ -if (new_port_id) { - fcvport->fcfabric =fc_fabric_add (fcport, fip->fcfabric_f, -0 ,NULL ); -fc_lport_set_local_id (fip->lp, new_port_id); - } +if (new_port_id) { +struct fc_fabric_fcoe_attrs fcoe_attrs; +/* Add a dummy fabric for VN2VN */ + fcvport->fcfabric =fc_fabric_add (fcport, fip->fcfabric_f, +NULL , &fcoe_attrs); +fc_lport_set_local_id (fip->lp, new_port_id); + } }/**
@@ -2744,7 +2751,6 @@ unlock:* @lp: The local port to configure libfc for * @fip: The FCoE controller in use by the local port * @tt: The libfc function template -* @init_fcp: If non-zero, the FCP portion of libfc should be initialized * * Returns : 0 for success */
drivers/scsi/libfc/fc_lport.c +4 -2
@@ -760,7 +760,8 @@ void fc_lport_set_local_id(struct fc_lport *lport, u32 port_id)case LPORT_ST_FLOGI :if (port_id) {mutex_lock (&fcport->lock); -fc_vport_add (lport->fcfabric, fcvport,0 ); +fc_vport_add (lport->fcfabric, fcvport, + lport->fcoe);mutex_unlock (&fcport->lock);fc_lport_enter_ready (lport);
@@ -1554,7 +1555,8 @@ void fc_lport_flogi_resp(struct fc_seq *sp, struct fc_frame *fp,fc_lport_set_port_id (lport, did, fp);mutex_lock (&fcport->lock); -fc_vport_add (lport->fcfabric, fcvport,0 ); +fc_vport_add (lport->fcfabric, fcvport, + lport->fcoe);mutex_unlock (&fcport->lock);fc_lport_enter_dns (lport);
include/scsi/libfc.h +1 -0
@@ -872,6 +872,7 @@ struct fc_lport {struct fc_els_rnid_gen rnid_gen;/* Capabilities */ + u32 fcoe:1; u32 sg_supp:1; u32 seq_offload:1; u32 crc_offload:1;
RFC PATCH v2 8/10 fnic: Convert to new FC Sysfs infrastructure
In reply to Robert LoveThis patch converts the fnic driver to use the new FC Sysfs infrastructure by removing the existing FC transport and replacing it. This patch was only compile tested due to not having hardware.
One open that I have is that most of fnic_get_fcport_speed is currently commented out. The function receives a fcport as an argument, but the speed information is stored in a fnic instance. I'm not sure how to get from the fcport to the fnic. Since fnic allocates a fcvport at the same time it allocates/adds a fcport we could put a pointer to the root fcvport in the fcport or maybe just make it private data on the end of the fcport since libfc doesn't need an N_Port fcvport pointer in the fcport.
--- drivers/scsi/Kconfig | 1 drivers/scsi/fnic/fnic.h | 33 ++- drivers/scsi/fnic/fnic_fcs.c | 32 ++- drivers/scsi/fnic/fnic_isr.c | 13 + drivers/scsi/fnic/fnic_main.c | 412 +++++++++++++++++++++++------------------ drivers/scsi/fnic/fnic_res.c | 47 ++--- drivers/scsi/fnic/fnic_scsi.c | 193 ++++++++++--------- 7 files changed, 400 insertions(+), 331 deletions(-)
drivers/scsi/Kconfig +1 -0
@@ -700,6 +700,7 @@ config FCOE config FCOE_FNIC tristate "Cisco FNIC Driver" depends on PCI && X86 + select SCSI_FCP_ATTRS select LIBFCOE help This is support for the Cisco PCI-Express FCoE HBA.
drivers/scsi/fnic/fnic.h +20 -13
@@ -89,21 +89,28 @@ do { \ } while (0); \ } while (0) -#define FNIC_MAIN_DBG(kern_level, host, fmt, args...) \ - FNIC_CHECK_LOGGING(FNIC_MAIN_LOGGING, \ - shost_printk(kern_level, host, fmt, ##args);) +#define FNIC_MAIN_DBG(kern_level, lport, fmt, args...) \ + FNIC_CHECK_LOGGING(FNIC_MAIN_LOGGING, \ + printk(KERN_INFO "fcport%u: " fmt, \ + fc_port_id((lport)->fcport), \ + ##args);) -#define FNIC_FCS_DBG(kern_level, host, fmt, args...) \ - FNIC_CHECK_LOGGING(FNIC_FCS_LOGGING, \ - shost_printk(kern_level, host, fmt, ##args);) +#define FNIC_FCS_DBG(kern_level, lport, fmt, args...) \ + FNIC_CHECK_LOGGING(FNIC_FCS_LOGGING, \ + printk(KERN_INFO "fcport%u: " fmt, \ + fc_port_id((lport)->fcport), \ + ##args);) -#define FNIC_SCSI_DBG(kern_level, host, fmt, args...) \ - FNIC_CHECK_LOGGING(FNIC_SCSI_LOGGING, \ - shost_printk(kern_level, host, fmt, ##args);) +#define FNIC_SCSI_DBG(kern_level, host, fmt, args...) \ + FNIC_CHECK_LOGGING(FNIC_SCSI_LOGGING, \ + shost_printk(kern_level, host, fmt, ##args);) + +#define FNIC_ISR_DBG(kern_level, lport, fmt, args...) \ + FNIC_CHECK_LOGGING(FNIC_ISR_LOGGING, \ + printk(KERN_INFO "fcport%u: " fmt, \ + fc_port_id((lport)->fcport), \ + ##args);) -#define FNIC_ISR_DBG(kern_level, host, fmt, args...) \ - FNIC_CHECK_LOGGING(FNIC_ISR_LOGGING, \ - shost_printk(kern_level, host, fmt, ##args);)extern const char *fnic_state_str[];
@@ -250,7 +257,7 @@ int fnic_queuecommand(struct Scsi_Host *, struct scsi_cmnd *);int fnic_abort_cmd (struct scsi_cmnd *);int fnic_device_reset (struct scsi_cmnd *);int fnic_host_reset (struct scsi_cmnd *); -int fnic_reset (struct Scsi_Host *); +int fnic_fcvport_reset (struct fc_vport *);void fnic_scsi_cleanup (struct fc_lport *);void fnic_scsi_abort_io (struct fc_lport *);void fnic_empty_scsi_cleanup (struct fc_lport *);
drivers/scsi/fnic/fnic_fcs.c +18 -14
@@ -41,6 +41,9 @@ static void fnic_set_eth_mode(struct fnic *);void fnic_handle_link (struct work_struct *work) { struct fnic *fnic = container_of(work, struct fnic, link_work); +struct fc_lport *lport = fnic->lport; +struct fcp_init *fcpinit = lport->fcpinit; +struct fc_fcp_internal *si =fcp_init_priv (fcpinit);unsigned long flags;int old_link_status;u32 old_link_down_cnt;
@@ -64,12 +67,12 @@ void fnic_handle_link(struct work_struct *work)else {if (old_link_down_cnt != fnic->link_down_cnt) {/* UP -> DOWN -> UP */ - fnic->lport->host_stats.link_failure_count++; + si->fcpinit_stats.link_failure_count++;spin_unlock_irqrestore (&fnic->fnic_lock, flags); -FNIC_FCS_DBG (KERN_DEBUG , fnic->lport->host, +FNIC_FCS_DBG (KERN_DEBUG , fnic->lport,"link down\n" );fcoe_ctlr_link_down (&fnic->ctlr); -FNIC_FCS_DBG (KERN_DEBUG , fnic->lport->host, +FNIC_FCS_DBG (KERN_DEBUG , fnic->lport,"link up\n" );fcoe_ctlr_link_up (&fnic->ctlr); }else
@@ -79,13 +82,13 @@ void fnic_handle_link(struct work_struct *work) }else if (fnic->link_status) {/* DOWN -> UP */ spin_unlock_irqrestore (&fnic->fnic_lock, flags); -FNIC_FCS_DBG (KERN_DEBUG , fnic->lport->host,"link up\n" ); +FNIC_FCS_DBG (KERN_DEBUG , fnic->lport,"link up\n" );fcoe_ctlr_link_up (&fnic->ctlr); }else {/* UP -> DOWN */ - fnic->lport->host_stats.link_failure_count++; + si->fcpinit_stats.link_failure_count++;spin_unlock_irqrestore (&fnic->fnic_lock, flags); -FNIC_FCS_DBG (KERN_DEBUG , fnic->lport->host,"link down\n" ); +FNIC_FCS_DBG (KERN_DEBUG , fnic->lport,"link down\n" );fcoe_ctlr_link_down (&fnic->ctlr); }
@@ -194,7 +197,7 @@ void fnic_update_mac_locked(struct fnic *fnic, u8 *new) new = ctl;if (!compare_ether_addr (data, new))return ; -FNIC_FCS_DBG (KERN_DEBUG , fnic->lport->host,"update_mac %pM\n" , new); +FNIC_FCS_DBG (KERN_DEBUG , fnic->lport,"update_mac %pM\n" , new);if (!is_zero_ether_addr (data) &&compare_ether_addr (data, ctl))vnic_dev_del_addr (fnic->vdev, data);memcpy (data, new,ETH_ALEN );
@@ -236,7 +239,7 @@ void fnic_set_port_id(struct fc_lport *lport, u32 port_id, struct fc_frame *fp)u8 *mac;int ret; -FNIC_FCS_DBG (KERN_DEBUG , lport->host,"set port_id %x fp %p\n" , +FNIC_FCS_DBG (KERN_DEBUG , lport,"set port_id %x fp %p\n" , port_id, fp);/*
@@ -263,7 +266,7 @@ void fnic_set_port_id(struct fc_lport *lport, u32 port_id, struct fc_frame *fp)if (fnic->state ==FNIC_IN_ETH_MODE || fnic->state ==FNIC_IN_FC_MODE ) fnic->state =FNIC_IN_ETH_TRANS_FC_MODE ;else { -FNIC_FCS_DBG (KERN_DEBUG , fnic->lport->host, +FNIC_FCS_DBG (KERN_DEBUG , fnic->lport,"Unexpected fnic state %s while" " processing flogi resp\n" ,fnic_state_to_str (fnic->state));
@@ -344,7 +347,7 @@ static void fnic_rq_cmpl_frame_recv(struct vnic_rq *rq, struct cq_desc eth_hdrs_stripped =0 ;skb_trim (skb, bytes_written);if (!fcs_ok) { -FNIC_FCS_DBG (KERN_DEBUG , fnic->lport->host, +FNIC_FCS_DBG (KERN_DEBUG , fnic->lport,"fcs error. dropping packet.\n" ); goto drop; }
@@ -353,13 +356,13 @@ static void fnic_rq_cmpl_frame_recv(struct vnic_rq *rq, struct cq_desc }else {/* wrong CQ type*/ -shost_printk (KERN_ERR , fnic->lport->host, +shost_printk (KERN_ERR , fnic->lport->fcpinit->shost,"fnic rq_cmpl wrong cq type x%x\n" , type); goto drop; }if (!fcs_ok || packet_error || !fcoe_fc_crc_ok || fcoe_enc_error) { - FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host, + FNIC_FCS_DBG(KERN_DEBUG, fnic->lport, "fnic rq_cmpl fcoe x%x fcsok x%x" " pkterr x%x fcoe_fc_crc_ok x%x, fcoe_enc_err" " x%x\n",
@@ -410,7 +413,8 @@ int fnic_rq_cmpl_handler(struct fnic *fnic, int rq_work_to_do)if (cur_work_done) { err =vnic_rq_fill (&fnic->rq[i], fnic_alloc_rq_frame);if (err) -shost_printk (KERN_ERR , fnic->lport->host, +shost_printk (KERN_ERR , + fnic->lport->fcpinit->shost,"fnic_alloc_rq_frame cant alloc" " frame\n" ); }
@@ -435,7 +439,7 @@ int fnic_alloc_rq_frame(struct vnic_rq *rq) len =FC_FRAME_HEADROOM +FC_MAX_FRAME +FC_FRAME_TAILROOM ; skb =dev_alloc_skb (len);if (!skb) { -FNIC_FCS_DBG (KERN_DEBUG , fnic->lport->host, +FNIC_FCS_DBG (KERN_DEBUG , fnic->lport,"Unable to allocate RQ sk_buff\n" );return -ENOMEM ; }
drivers/scsi/fnic/fnic_isr.c +7 -6
@@ -197,9 +197,10 @@ int fnic_request_intr(struct fnic *fnic) fnic->msix[i].devname, fnic->msix[i].devid);if (err) { -shost_printk (KERN_ERR , fnic->lport->host, -"MSIX: request_irq" -" failed %d\n" , err); +printk (KERN_ERR "fcport%u: MSIX: request_irq" +" failed %d\n" , +fc_port_id (fnic->lport->fcport), + err);fnic_free_intr (fnic);break ; }
@@ -249,7 +250,7 @@ int fnic_set_intr_mode(struct fnic *fnic) fnic->intr_count = n + m + o +1 ; fnic->err_intr_offset =FNIC_MSIX_ERR_NOTIFY ; -FNIC_ISR_DBG (KERN_DEBUG , fnic->lport->host, +FNIC_ISR_DBG (KERN_DEBUG , fnic->lport,"Using MSI-X Interrupts\n" );vnic_dev_set_intr_mode (fnic->vdev,VNIC_DEV_INTR_MODE_MSIX );
@@ -276,7 +277,7 @@ int fnic_set_intr_mode(struct fnic *fnic) fnic->intr_count =1 ; fnic->err_intr_offset =0 ; -FNIC_ISR_DBG (KERN_DEBUG , fnic->lport->host, +FNIC_ISR_DBG (KERN_DEBUG , fnic->lport,"Using MSI Interrupts\n" );vnic_dev_set_intr_mode (fnic->vdev,VNIC_DEV_INTR_MODE_MSI );
@@ -302,7 +303,7 @@ int fnic_set_intr_mode(struct fnic *fnic) fnic->cq_count =3 ; fnic->intr_count =3 ; -FNIC_ISR_DBG (KERN_DEBUG , fnic->lport->host, +FNIC_ISR_DBG (KERN_DEBUG , fnic->lport,"Using Legacy Interrupts\n" );vnic_dev_set_intr_mode (fnic->vdev,VNIC_DEV_INTR_MODE_INTX );
drivers/scsi/fnic/fnic_main.c +228 -184
691 lines not on this page · raw message
drivers/scsi/fnic/fnic_res.c +24 -23
108 lines not on this page · raw message
drivers/scsi/fnic/fnic_scsi.c +102 -91
539 lines not on this page · raw message
RFC PATCH v2 9/10 fc: Add a hbaapi_lib attribute to the fcport structure
In reply to Robert LoveCurrently, libhbalinux, a LGPL implementation of the HBAAPI interface relies on the sub-string " over " in the host's symbolic_name to determine if the library is responsible for the driver. This is obviously error prone, so this patch adds a new attribute so the LLD can specify it's HBAAPI library.
Since both fcoe and fnic use libhbalinux I've update those drivers to use this new attribute.
--- drivers/fc/fcport.c | 2 ++ drivers/scsi/fcoe/fcoe.c | 4 ++++ include/fc/fc.h | 10 +++++++++- 3 files changed, 15 insertions(+), 1 deletions(-)
drivers/fc/fcport.c +2 -0
@@ -113,6 +113,7 @@ static FC_DEVICE_ATTR(fcport, speed, S_IRUGO, show_port_speed, NULL);fc_port_rd_attr (maxframe_size,"%u bytes\n" ,20 );fc_port_rd_attr (serial_number,"%s\n" , (FC_SERIAL_NUMBER_SIZE +1 )); +fc_port_rd_attr (hbaapi_lib,"%s\n" , (FC_HBAAPI_LIB_SIZE +1 ));/* used by supported_speeds */ static ssize_t show_port_supported_speeds(struct device *dev,
@@ -312,6 +313,7 @@ struct fc_port *fc_port_add(struct device *pdev,FC_SETUP_COND_ATTR_RD (fcport, supported_classes);FC_SETUP_COND_ATTR_RD (fcport, serial_number);FC_SETUP_COND_ATTR_RD (fcport, speed); +FC_SETUP_COND_ATTR_RD (fcport, hbaapi_lib);BUG_ON (count >FC_PORT_NUM_ATTRS );FC_CREATE_ATTRS (fcport, count);
drivers/scsi/fcoe/fcoe.c +4 -0
@@ -195,6 +195,7 @@ struct fc_port_function_template fcoe_fcport_fcn_tmpl = { .show_fcport_supported_fc4s = 1, .show_fcport_active_fc4s = 1, .show_fcport_serial_number = 1, + .show_fcport_hbaapi_lib = 1, .dd_fcport_size = sizeof(struct fcoe_interface),
@@ -442,6 +443,9 @@ static struct fcoe_interface *fcoe_interface_create(struct net_device *netdev, goto out; } +strncpy (fc_port_hbaapi_lib (fcport),LIBHBALINUX , +strlen (LIBHBALINUX )); + fcoe =fc_port_priv (fcport);dev_hold (netdev);
include/fc/fc.h +9 -1
@@ -359,7 +359,7 @@ struct _fc_cos_names {#define dev_to_fcrport (d) \ container_of((d), struct fc_rport, dev) -#define FC_PORT_NUM_ATTRS 9 +#define FC_PORT_NUM_ATTRS 10#define FC_VPORT_NUM_ATTRS 16#define FC_RPORT_NUM_ATTRS 9#define FC_FABRIC_NUM_ATTRS 6
@@ -591,6 +591,9 @@ static inline void *fc_fabric_priv(const struct fc_fabric *fcfabric)#define fcfabric_to_fcport (x) \ dev_to_fcport((x)->dev.parent) +#define FC_HBAAPI_LIB_SIZE 80 +#define LIBHBALINUX "libhbalinux" +struct fc_port_function_template {void (*get_fcport_speed)(struct fc_port *);void (*get_fcport_active_fc4s)(struct fc_port *);
@@ -605,6 +608,7 @@ struct fc_port_function_template { unsigned long show_fcport_active_fc4s:1; unsigned long show_fcport_supported_classes:1; unsigned long show_fcport_serial_number:1; + unsigned long show_fcport_hbaapi_lib:1;u32 dd_fcport_size;
@@ -640,6 +644,8 @@ struct fc_port {u32 maxframe_size;u32 supported_classes;char serial_number[FC_SERIAL_NUMBER_SIZE ]; +char hbaapi_lib[FC_HBAAPI_LIB_SIZE ]; +/* Dynamic Attributes*/ u8 active_fc4s[FC_FC4_LIST_SIZE ];
@@ -690,6 +696,8 @@ static inline void *fc_port_priv(const struct fc_port *fcport) ((x)->supported_classes)#define fc_port_serial_number (x) \ ((x)->serial_number) +#define fc_port_hbaapi_lib (x) \ + ((x)->hbaapi_lib)/* * FC Virtual Port Attributes
RFC PATCH v2 10/10 Documentation: Add fc_sysfs document
In reply to Robert LoveDocument explaining some of the basics of the
Fibre Channel subsystem. It covers features,
design decisions and implementation details
regarding the libfc/libfcoe/fcoe usage of this
subsystem.
--- Documentation/fc/fc_sysfs.txt | 192 +++++++++++++++++++++++++++++++ Documentation/fc/libfc_libfcoe_fcoe.txt | 17 +++ 2 files changed, 209 insertions(+), 0 deletions(-) create mode 100644 Documentation/fc/fc_sysfs.txt create mode 100644 Documentation/fc/libfc_libfcoe_fcoe.txt
Documentation/fc/fc_sysfs.txt new file +192 -0
@@ -0,0 +1,192 @@ +Fibre Channel sysfs Representation + +Summary +------------------------------- + +The Fibre Channel subsystem is designed to represent a +fabric (or fabric-less) topology in sysfs. It allows FC +drivers to create the following instances as the driver +gains awareness of them. + +fc_port - The physical port on a CNA/HBA/NIC. + +fc_fabric - The switch that the physical port has discovered. + +fc_vport - The host's representation of a single fabric login. + +fc_rport - The host's representation of a discovered fabric + entity (usually a target). + + +Differences between FC and FCoE +------------------------------- + +FCoE uses a discovery protocol named FIP (FCoE Initialization +Protocol) to discover which switch/fabric it should login to. +Traditional FC HBAs connect directly to their switch, so no +discovery is needed. + +FCoE LLDs will first create a fc_port and then as FCFs (FCoE +switchs) are discovered the LLD will add fc_fabric(s) to the +system. FC LLDs will simply create a fc_fabric immediately +after the fc_port is created sicne switch/fabric information +will immediately be available. + + +Locking +------------------------------- + +Locking is based on the fact that no child devices should +exist without their parent. For example, you should never +have a fc_fabric without a fc_port. If the fc_port is deleted +then all of its children, fc_fabric(s), should have been +deleted first. + +fc_port +* locking primative: mutex +* Used to synchronize the addition and deletion of + fc_fabrics as well as lookup a fc_fabric within the + fc_port's list of fc_fabrics. +* Used to synchronize the addition and deletion of + fc_vports on the fc_fabric as well as lookup a fc_vport + within the fc_fabric's list of fc_vports. +* Used to synchronize the fc_fabric's npiv_vports_inuse field. + +fc_fabric +* locking primative: none +* The fc_fabric uses the fc_port's lock (see above). + +fc_vport +* locking primative: spinlock_t +* Used to protect the fc_vport's 'flags'. +* Used to synchronize the addition and deletion of + fc_rports on the fc_vport as well as lookup a fc_rport + within the fc_vport's list of fc_rports, as well as + the fc_vport's list of fc_rport bindings. + +APIs +---- + +fc_port_add: No locking requirement +fc_port_del: No locking requirement +fc_port_del_fabrics: fc_port lock held +fc_fabric_add: fc_port lock held +fc_fabric_del: fc_port lock held +fc_vport_alloc: No locking requirement +fc_vport_free: No locking requirement +fc_vport_add: fc_port lock held +fc_rport_add: No locking requirement +fc_rport_del: No locking requirement + +TODO: This is a bit odd that some routines need the +lock held and others don't, can I remove the locking +requirements and isolate the locking to drivers/fc/? + + +FC4 Registration/Unregistration +------------------------------- + +Since Fibre Channel is capable of transporting multiple +protocols (the FC4 layer in FC terms) the FC subsystem +allows the LLD to register the FC4s it supports with the +fc_port and it selects the FC4 for use with each fc_vport. +Currently only SCSI-FCP (Initiator) is supported and is +implemented in the scsi_transport_fcp.{ch} files. + +A bus/driver model is used to represent this architecture. +The fc_vport and fc_rport instances are each bus devices +and fcp_init and fcp_targ instances are drivers for these +busses, respectively. + +In the simplist sense when a fc_vport is created a +fcp_init is also created. When a fc_rport is created +a fcp_targ is created. + +You can think of the FC4 layer as a 'glue' layer that +ties the FC4 protocol to the FC subsystem. If the LLD +supports a FC4 protocol it must implement the necessary +callbacks to initialize any FC4 instances created. + + +SCSI-FCP Devices +------------------------------- + +fcp_init +* 1:1 with the Scsi_Host and fc_vport +* Allocated with the Scsi_Host +* Replaces the fc_host_attrs from the previous FC Transport + +fcp_targ +* 1:1 with scsi_target (assuming the device is a target) + and the fc_rport +* Not a child of the fc_rport in sysfs; its parent is the + scsi_target. + + +Device Loss +------------------------------- + +If the link between the HBA/CNA/NIC and the switch is +broken it may be for a short or long period of time. If +it is short we simply want to disable the discovered +devices and then enable them when the link is +re-established. Both the fc_rports and fc_fabrics use +device loss timers to determine when they can be removed +from the system. + + +Memory Allocation +------------------------------- + +The FC subsystem allows LLDs to specify a ammount of +memory that the LLD can use for private data that will +be associated with the devices that the FC subsystem +creates. + +The fc_port, fc_fabric, fc_rport and fc_vport all allow +for LLD private data. In addition the SCSI-FCP layer +allows for LLD private data on the fcp_init device. + +libfc/libfcoe/fcoe +------------------ + +fc_port/fcoe_interface +fc_fabric/fcoe_fcf +fc_vport/fc_lport/fcoe_port +fc_rport/fc_rport_libfc_priv + +fcp_init/fc_fcp_internal + + +FCoE Attributes / Quirks +------------------------------- + +Attributes +---------- + +FCoE attributes are added to FC subsystem devices if +the LLD chooses to. + +The fc_port, fc_fabric and fc_vport devices all have +FCoE attributes that can be added if desired. + + +Multiple fc_fabrics +------------------- + +Since FCoE discovers FCFs there needs to be a way to +determine if a discovered FCF was previously discovered +or not, otherwise the fc_port's list of fc_fabrics could +contain duplicate entries. + +There isn't really any good FC attribute that can be used +to uniquely identify a fc_fabric. Also, traditional FC HBAs +will only add one fc_fabric to the system. This means that +duplicate fc_fabrics is only a problem for FCoE HBA/CNA/NICs. + +The solution is for the LLD to provide a fabric_match +callback that the FC subsystem can use to see if two +fc_fabrics are really the same instance. This allows each +LLD to match fc_fabrics however it wants. For FCoE LLDs +it allows them to check FCoE attributes when looking +for duplicates.
Documentation/fc/libfc_libfcoe_fcoe.txt new file +17 -0
@@ -0,0 +1,17 @@ +libfc/libfcoe/fcoe Usage +------------------------------- + +Every FC device created is created and added to the +system with the same fc.h function: fc_port_add, +fc_fabric_add, etc... Unfortunately, libfc/libfcoe/fcoe +needs the fc_lport instance before a fc_fabric is +discovered. Since the fc_lport is created with the +fc_vport it needs to be allocated before FCF discovery. + +Because of this the fc_vport_add and fc_vport_del +routines only add and remove an instance from sysfs. +The fc_vport_alloc and fc_vport_free routines are used +to simply allocate and free a fc_vport instance. This +allows libfc/libfcoe/fcoe to allocate a fc_vport/fc_lport +early and add that fc_vport to the system once it has +logged into the fabric.