Skip to contentSkip to conversation

FC subsystem update

RFC PATCH In review Robert Love 3 participants 8 messages May 12, 2010 – May 13, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover FC subsystem update

This series represents the continuation of the RFC archived here:
http://marc.info/?l=linux-scsi&m=126463466126962&w=2. The sysfs organization has taken shape and object allocations make more sense than the previous RFC. The patches have undergone my own developer testing, which has mostly focused on NPIV port creation and deletion and some I/O.

This series creates a Fibre Channel subsystem that has an improved sysfs device tree (the port's view of the fabric) and begins to abstract itself from SCSI.

This RFC is to solicit any feedback before I continue to refine these patches. I've created two diagrams to help people understand the change. The first shows the current sysfs device layout and the second shows the allocation scheme for libfc and fcoe's primary data structures.

http://open-fcoe.org/rwlove/fc_sysfs.jpg
http://open-fcoe.org/rwlove/libfc_alloc.jpg

These patches apply to scsi-misc + the recently submitted fcoe patches, which is the same as the fcoe-next tree on open-fcoe.org.

Overview of N_Port creation/login (for fcoe.ko):

1) First, fc.ko is installed and then scsi_transport_fcp.ko is installed. scsi_transport_fcp.ko registers itself (SCSI initiator) as a FC4 with fc.ko.

2) When a fcoe port is "created" from
'echo ethX > /sys/module/fcoe/parameters/create' a fcport is allocated and added to sysfs. All of the port's physical properties are added as attributes.

<PCI root>/fcport_0

3) At this point libfc/libfcoe/fcoe needs an lport and an fcoe_port. The lport and fcoe_ports are private data of a fcvport so a fcvport is allocated, but not added to sysfs.

4) libfcoe.ko discovers FCFs and allocates/adds them as fcfabrics to sysfs as they are discovered.

[ I think that we may want to revisit the idea of having a fcfport between
the fcport and fcfabric. Right now I'm creating a fcfabric for each FCF that is discovered at the FIP phase, but that doesn't make much sense since multiple FCFs on the same fabric can be discovered. Adding a fcfport for each FCF discovered might be more correct. ]

<PCI root>/fcport_0/fcfabric_0

5) libfc.ko will FLOGI into the fabric and upon the FLOGI ACC the fcvport will be added to sysfs.

<PCI root>/fcport_0/fcfabric_0/fcvport_0

5.1) The FC layer will call fc4_init_add in the fc4_template. If SCSI
is the FC4, fcp_init_add (scsi_transport_fcp) will be called. This routine calls scsi_host_alloc/scsi_add_host. There is also a callback down to the LLD so that it can setup any SCSI-FCP private data.

[ I'm not sure how non-FCoE HBAs will do this. I imagine they will just
create all three sysfs devices (fcport, fcfabric and fcvport) on the FLOGI ACC since they do not rely on a discovery protocol. ]

<PCI root>/fcport_0/fcfabric_0/fcvport_0/fcpinit_X/hostX

6) libfc will start discovery and as remote ports are discovered libfc will notify FC to create and add fcrports to sysfs.

<PCI root>/fcport_0/fcfabric_0/fcvport_0/fcpinit_X/hostX

					/fcrport_0

6.1) When the fcrports are created the FC layer will call fc4_targ_add in
the fc4_template. If SCSI is the FC4, fcp_targ_add (scsi_transport_fcp) will be called. This routine will allocate a fcptarg device, add it to sysfs and notify SCSI to scan it.

<PCI root>/fcport_0/fcfabric_0/fcvport_0/fcpinit_X/hostX

					/fcrport_0/fcptargX:0-0

The current series shortcomings are:

1) The FC4 interface needs work to become more FC4 agnostic. (end of include/fc/fc.h)

2) Point-to-Point mode needs to be addressed

3) BSG needs to be tested and STGT should become another FC4 that is registered with FC. Since libfc/fcoe doesn't plug into STGT yet this will be a challenge.

4) user space updates - For the fcoe-utils package, libhbalinux (user space HBA API library) needs to be updated to read the new layout before heavy testing of the new layout can be done.

5) Miscellaneous problems like error handling, fcfabric deletion cleaning up vports, using attribute containers / scsi transport style for SCSI-FCP devices, warnings, etc...

6) FCoE attributes...

Other thoughts:

I would love to collaborate with someone who maintains a HBA that supports native FC since I'm not aware of the specific needs of traditional HBAs.

I would hope that this new layout could be added to the kernel (when ready) and the existing FC Transport deprecated as I'm not sure how to get all HBA maintainers to switch their drivers at the same time. I think that only adding FCoE attributes to this layout would be an incentive to get LLDs to migrate.

I've tried to keep this covermail brief, so there are plenty of details left out. Please ask if you have a question.

Thanks, //Rob

---

Robert Love (3):
libfc, libfcoe, fcoe: Make use of FC subsystem
scsi_transport_fcp: Create FC/SCSI interaction layer
fc: Create FC sybsystem

 drivers/Kconfig                   |    2 
 drivers/Makefile                  |    1 
 drivers/fc/Kconfig                |    8 
 drivers/fc/Makefile               |    7 
 drivers/fc/fcfabric.c             |  425 ++++++++++
 drivers/fc/fcport.c               |  205 +++++
 drivers/fc/fcrport.c              | 1034 ++++++++++++++++++++++++
 drivers/fc/fcsysfs.c              |  180 ++++
 drivers/fc/fcsysfs.h              |   76 ++
 drivers/fc/fcvport.c              |  714 +++++++++++++++++
 drivers/scsi/Kconfig              |   11 
 drivers/scsi/Makefile             |    1 
 drivers/scsi/fcoe/fcoe.c          |  619 ++++++++------
 drivers/scsi/fcoe/libfcoe.c       |  167 +++-
 drivers/scsi/libfc/fc_disc.c      |    4 
 drivers/scsi/libfc/fc_exch.c      |    2 
 drivers/scsi/libfc/fc_fcp.c       |  130 +--
 drivers/scsi/libfc/fc_libfc.h     |   28 -
 drivers/scsi/libfc/fc_lport.c     |  195 ++---
 drivers/scsi/libfc/fc_npiv.c      |   44 -
 drivers/scsi/libfc/fc_rport.c     |   15 
 drivers/scsi/scsi_transport_fcp.c | 1598 +++++++++++++++++++++++++++++++++++++
 include/fc/fc.h                   |  843 ++++++++++++++++++++
 include/scsi/fc_encode.h          |   34 -
 include/scsi/libfc.h              |  119 +--
 include/scsi/libfcoe.h            |   17 
 include/scsi/scsi_transport_fcp.h |  325 ++++++++
 27 files changed, 6241 insertions(+), 563 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 drivers/scsi/scsi_transport_fcp.c
 create mode 100644 include/fc/fc.h
 create mode 100644 include/scsi/scsi_transport_fcp.h
#1 lore raw

RFC PATCH 1/3 fc: Create FC sybsystem

This 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:

fcport: Represents physical port
Attributes: maxframe_size
supported_speeds
speed (misplaced?)
supported_fc4s
active_fc4s (misplaced?)
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

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

---

 drivers/Kconfig       |    2 
 drivers/Makefile      |    1 
 drivers/fc/Kconfig    |    8 
 drivers/fc/Makefile   |    7 
 drivers/fc/fcfabric.c |  425 ++++++++++++++++++++
 drivers/fc/fcport.c   |  205 ++++++++++
 drivers/fc/fcrport.c  | 1034 +++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/fc/fcsysfs.c  |  180 +++++++++
 drivers/fc/fcsysfs.h  |   76 ++++
 drivers/fc/fcvport.c  |  714 ++++++++++++++++++++++++++++++++++
 include/fc/fc.h       |  843 ++++++++++++++++++++++++++++++++++++++++
 11 files changed, 3495 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
index a2b902f..6eb6e22 100644
@@ -28,6 +28,8 @@ source "drivers/md/Kconfig"
 
 source "drivers/message/fusion/Kconfig"
 
+source "drivers/fc/Kconfig"
+
 source "drivers/firewire/Kconfig"
 
 source "drivers/message/i2o/Kconfig"
drivers/Makefile +1 -0
index 34f1e10..bf15da8 100644
@@ -48,6 +48,7 @@ obj-$(CONFIG_SPI)		+= spi/
 obj-y				+= net/
 obj-$(CONFIG_ATM)		+= atm/
 obj-$(CONFIG_FUSION)		+= message/
+obj-$(CONFIG_FC)		+= fc/
 obj-$(CONFIG_FIREWIRE)		+= firewire/
 obj-y				+= ieee1394/
 obj-$(CONFIG_UIO)		+= uio/
drivers/fc/Kconfig new file +8 -0
new file mode 100644
index 0000000..bcd5444
@@ -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
new file mode 100644
index 0000000..fa1d60e
@@ -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 +425 -0

425 lines not on this page · raw message

drivers/fc/fcport.c new file +205 -0

205 lines not on this page · raw message

drivers/fc/fcrport.c new file +1034 -0

1,034 lines not on this page · raw message

drivers/fc/fcsysfs.c new file +180 -0

180 lines not on this page · raw message

drivers/fc/fcsysfs.h new file +76 -0

76 lines not on this page · raw message

drivers/fc/fcvport.c new file +714 -0

714 lines not on this page · raw message

include/fc/fc.h new file +843 -0

336 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.

#2 lore raw

RFC PATCH 2/3 scsi_transport_fcp: Create FC/SCSI interaction layer

In reply to Robert Love

This 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: permanent_port_name (misplaced?)
port_state (misplaced?) system_hostname (misplaced?)

I'm not sure these are in the right place. These attributes seem like they should be moved to the fcport within the FC subsystem.

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 | 1598 +++++++++++++++++++++++++++++++++++++
 include/scsi/scsi_transport_fcp.h |  325 ++++++++
 4 files changed, 1934 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
index 75f2336..f0e56ce 100644
@@ -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
index 1c7ac49..c68fcfa 100644
@@ -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 +1598 -0

1,598 lines not on this page · raw message

include/scsi/scsi_transport_fcp.h new file +325 -0

325 lines not on this page · raw message

#3 lore raw

RFC PATCH 3/3 libfc, libfcoe, fcoe: Make use of FC subsystem

In reply to Robert Love

This 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://open-fcoe.org/rwlove/libfc_alloc.jpg

---

 drivers/scsi/Kconfig          |    1 
 drivers/scsi/fcoe/fcoe.c      |  619 ++++++++++++++++++++++++-----------------
 drivers/scsi/fcoe/libfcoe.c   |  167 +++++++++--
 drivers/scsi/libfc/fc_disc.c  |    4 
 drivers/scsi/libfc/fc_exch.c  |    2 
 drivers/scsi/libfc/fc_fcp.c   |  130 ++++-----
 drivers/scsi/libfc/fc_libfc.h |   28 +-
 drivers/scsi/libfc/fc_lport.c |  195 +++++++------
 drivers/scsi/libfc/fc_npiv.c  |   44 +--
 drivers/scsi/libfc/fc_rport.c |   15 +
 include/scsi/fc_encode.h      |   34 +-
 include/scsi/libfc.h          |  119 ++++----
 include/scsi/libfcoe.h        |   17 +
 13 files changed, 812 insertions(+), 563 deletions(-)
drivers/scsi/Kconfig +1 -0
index f0e56ce..54ef2c7 100644
@@ -682,6 +682,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 +358 -261

898 lines not on this page · raw message

drivers/scsi/fcoe/libfcoe.c +139 -28

334 lines not on this page · raw message

drivers/scsi/libfc/fc_disc.c +3 -1
index c7985da..bae5014 100644
@@ -388,6 +388,7 @@ err:
 static int fc_disc_gpn_ft_parse(struct fc_disc *disc, void *buf, size_t len)
 {
 	struct fc_lport *lport;
+	struct fc_fcp_internal *si;
 	struct fc_gpn_ft_resp *np;
 	char *bp;
 	size_t plen;
@@ -397,6 +398,7 @@ static int fc_disc_gpn_ft_parse(struct fc_disc *disc, void *buf, size_t len)
 	struct fc_rport_priv *rdata;
 
 	lport = disc->lport;
+	si = fc_get_scsi_internal(lport);
 	disc->seq_count++;
 
 	/*
@@ -441,7 +443,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 != fcvport_port_name(lport->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 +2 -0
index 104e0fb..c73df63 100644
@@ -1905,11 +1905,13 @@ err:
 static void fc_exch_rrq(struct fc_exch *ep)
 {
 	struct fc_lport *lport;
+	struct fc_fcp_internal *si;
 	struct fc_els_rrq *rrq;
 	struct fc_frame *fp;
 	u32 did;
 
 	lport = ep->lp;
+	si = fc_get_scsi_internal(lport);
 
 	fp = fc_frame_alloc(lport, sizeof(*rrq));
 	if (!fp)
drivers/scsi/libfc/fc_fcp.c +63 -67

318 lines not on this page · raw message

drivers/scsi/libfc/fc_libfc.h +14 -14
index f5c0ca4..e5ec03e 100644
@@ -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,	\
+				(lport)->fcport->id,			\
 				(lport)->port_id, ##args))
 
-#define FC_DISC_DBG(disc, fmt, args...)				\
-	FC_CHECK_LOGGING(FC_DISC_LOGGING,			\
-			 printk(KERN_INFO "host%u: disc: " fmt,	\
-				(disc)->lport->host->host_no,	\
+#define FC_DISC_DBG(disc, fmt, args...)					\
+	FC_CHECK_LOGGING(FC_DISC_LOGGING,				\
+			 printk(KERN_INFO "fcport%u: disc: " fmt,	\
+				(disc)->lport->fcport->id,		\
 				##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,	\
+				(lport)->fcport->id,			\
 				(port_id), ##args))
 
 #define FC_RPORT_DBG(rdata, fmt, args...)				\
@@ -66,20 +66,20 @@ extern unsigned int fc_debug_logging;
 
 #define FC_FCP_DBG(pkt, fmt, args...)					\
 	FC_CHECK_LOGGING(FC_FCP_LOGGING,				\
-			 printk(KERN_INFO "host%u: fcp: %6.6x: " fmt,	\
-				(pkt)->lp->host->host_no,		\
+			 printk(KERN_INFO "fcport%u: fcp: %6x: " fmt,	\
+				(pkt)->lp->fcport->id,			\
 				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,	\
+				(exch)->lp->fcport->id,			\
 				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,	\
+				(lport)->fcport->id,	##args))
 
 /*
  * Set up direct-data placement for this I/O request
drivers/scsi/libfc/fc_lport.c +105 -90

391 lines not on this page · raw message

drivers/scsi/libfc/fc_npiv.c +19 -25

76 lines not on this page · raw message

drivers/scsi/libfc/fc_rport.c +9 -6
index 39e440f..a1b445a 100644
@@ -263,7 +263,9 @@ 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_fcrport_add(lport->fcvport,
+					       lport->fcrport_f,
+					       0, &ids);
 		if (!rport) {
 			FC_RPORT_DBG(rdata, "Failed to add the rport\n");
 			lport->tt.rport_logoff(rdata);
@@ -334,7 +336,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_fcrport_del(rport);
 		}
 		if (restart) {
 			mutex_lock(&rdata->rp_mutex);
@@ -1113,13 +1115,14 @@ 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_exch *ep = fc_seq_exch(sp);
 	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 fcpinit_statistics *hst;
 	u32 f_ctl;
 
 	FC_RPORT_DBG(rdata, "Received RLS request while in state %s\n",
@@ -1147,8 +1150,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);
@@ -1360,7 +1363,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 < fcvport_port_name(lport->fcvport)) {
 			mutex_unlock(&rdata->rp_mutex);
 			rjt_data.reason = ELS_RJT_INPROG;
 			rjt_data.explan = ELS_EXPL_NONE;
include/scsi/fc_encode.h +19 -15
index 9b4867c..bb5c2cc 100644
@@ -72,8 +72,10 @@ static inline void fc_adisc_fill(struct fc_lport *lport, struct fc_frame *fp)
 	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(fcvport_port_name(lport->fcvport),
+			   &adisc->adisc_wwpn);
+	put_unaligned_be64(fcvport_node_name(lport->fcvport),
+			   &adisc->adisc_wwnn);
 	hton24(adisc->adisc_port_id, lport->port_id);
 }
 
@@ -144,24 +146,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(fcvport_node_name(lport->fcvport),
+				   &ct->payload.rn.fr_wwn);
 		break;
 
 	case FC_NS_RSPN_ID:
-		len = strnlen(fc_host_symbolic_name(lport->host), 255);
+		len = strnlen(fcvport_symbolic_name(lport->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);
+			fcvport_symbolic_name(lport->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(fcvport_symbolic_name(lport->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(fcvport_node_name(lport->fcvport),
+				   &ct->payload.snn.fr_wwn);
 		strncpy(ct->payload.snn.fr_name,
-			fc_host_symbolic_name(lport->host), len);
+			fcvport_symbolic_name(lport->fcvport), len);
 		ct->payload.snn.fr_name_len = len;
 		break;
 
@@ -186,8 +190,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(fcvport_port_name(lport->fcvport), &plogi->fl_wwpn);
+	put_unaligned_be64(fcvport_node_name(lport->fcvport), &plogi->fl_wwnn);
 
 	csp = &plogi->fl_csp;
 	csp->sp_hi_ver = 0x20;
@@ -218,8 +222,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(fcvport_port_name(lport->fcvport), &flogi->fl_wwpn);
+	put_unaligned_be64(fcvport_node_name(lport->fcvport), &flogi->fl_wwnn);
 	sp = &flogi->fl_csp;
 	sp->sp_hi_ver = 0x20;
 	sp->sp_lo_ver = 0x20;
@@ -243,8 +247,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(fcvport_port_name(lport->fcvport), &fdisc->fl_wwpn);
+	put_unaligned_be64(fcvport_node_name(lport->fcvport), &fdisc->fl_wwnn);
 	sp = &fdisc->fl_csp;
 	sp->sp_hi_ver = 0x20;
 	sp->sp_lo_ver = 0x20;
@@ -265,7 +269,7 @@ static inline void fc_logo_fill(struct fc_lport *lport, struct fc_frame *fp)
 	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(fcvport_port_name(lport->fcvport));
 }
 
 /**
include/scsi/libfc.h +64 -55

211 lines not on this page · raw message

include/scsi/libfcoe.h +16 -1
index ec13f51..c901b2f 100644
@@ -114,11 +114,19 @@ struct fcoe_ctlr {
 	u8 dest_addr[ETH_ALEN];
 	u8 ctl_src_addr[ETH_ALEN];
 
+	char work_q_name[20];
+	struct workqueue_struct *work_q;
+
 	void (*send)(struct fcoe_ctlr *, struct sk_buff *);
 	void (*update_mac)(struct fc_lport *, u8 *addr);
 	u8 * (*get_src_addr)(struct fc_lport *);
 	spinlock_t lock;
 };
+#define fcoe_ctlr_work_q(x)			\
+	((x)->work_q)
+#define fcoe_ctlr_work_q_name(x)		\
+	((x)->work_q_name)
+
 
 /**
  * struct fcoe_fcf - Fibre-Channel Forwarder
@@ -154,6 +162,13 @@ struct fcoe_fcf {
 	u16 flags;
 	u32 fka_period;
 	u8 fd_flags:1;
+
+	struct fc_fcfabric *fcfabric;
+	struct fcfabric_function_template *fcfabric_f;
+	struct fcvport_function_template *fcvport_f;
+	struct fc_fcport *fcport;
+
+	struct work_struct fcf_work;
 };
 
 /* FIP API functions */
@@ -168,6 +183,6 @@ int fcoe_ctlr_recv_flogi(struct fcoe_ctlr *, struct fc_lport *,
 
 /* libfcoe funcs */
 u64 fcoe_wwn_from_mac(unsigned char mac[], unsigned int, unsigned int);
-int fcoe_libfc_config(struct fc_lport *, struct libfc_function_template *);
+void fcoe_libfc_config(struct fc_lport *, struct libfc_function_template *);
 
 #endif /* _LIBFCOE_H */
#4 lore raw
In reply to Robert Love
Quoted 111 lines · Robert Love

This series represents the continuation of the RFC archived here:
http://marc.info/?l=linux-scsi&m=126463466126962&w=2. The sysfs organization has taken shape and object allocations make more sense than the previous RFC. The patches have undergone my own developer testing, which has mostly focused on NPIV port creation and deletion and some I/O.

This series creates a Fibre Channel subsystem that has an improved sysfs device tree (the port's view of the fabric) and begins to abstract itself from SCSI.

This RFC is to solicit any feedback before I continue to refine these patches. I've created two diagrams to help people understand the change. The first shows the current sysfs device layout and the second shows the allocation scheme for libfc and fcoe's primary data structures.

http://open-fcoe.org/rwlove/fc_sysfs.jpg
http://open-fcoe.org/rwlove/libfc_alloc.jpg

These patches apply to scsi-misc + the recently submitted fcoe patches, which is the same as the fcoe-next tree on open-fcoe.org.

Overview of N_Port creation/login (for fcoe.ko):

1) First, fc.ko is installed and then scsi_transport_fcp.ko is installed. scsi_transport_fcp.ko registers itself (SCSI initiator) as a FC4 with fc.ko.

2) When a fcoe port is "created" from
'echo ethX > /sys/module/fcoe/parameters/create' a fcport is allocated and added to sysfs. All of the port's physical properties are added as attributes.

<PCI root>/fcport_0

3) At this point libfc/libfcoe/fcoe needs an lport and an fcoe_port. The lport and fcoe_ports are private data of a fcvport so a fcvport is allocated, but not added to sysfs.

4) libfcoe.ko discovers FCFs and allocates/adds them as fcfabrics to sysfs as they are discovered.

[ I think that we may want to revisit the idea of having a fcfport between
the fcport and fcfabric. Right now I'm creating a fcfabric for each FCF that is discovered at the FIP phase, but that doesn't make much sense since multiple FCFs on the same fabric can be discovered. Adding a fcfport for each FCF discovered might be more correct. ]

<PCI root>/fcport_0/fcfabric_0

5) libfc.ko will FLOGI into the fabric and upon the FLOGI ACC the fcvport will be added to sysfs.

<PCI root>/fcport_0/fcfabric_0/fcvport_0

5.1) The FC layer will call fc4_init_add in the fc4_template. If SCSI
is the FC4, fcp_init_add (scsi_transport_fcp) will be called. This routine calls scsi_host_alloc/scsi_add_host. There is also a callback down to the LLD so that it can setup any SCSI-FCP private data.

[ I'm not sure how non-FCoE HBAs will do this. I imagine they will just
create all three sysfs devices (fcport, fcfabric and fcvport) on the FLOGI ACC since they do not rely on a discovery protocol. ]

<PCI root>/fcport_0/fcfabric_0/fcvport_0/fcpinit_X/hostX

6) libfc will start discovery and as remote ports are discovered libfc will notify FC to create and add fcrports to sysfs.

<PCI root>/fcport_0/fcfabric_0/fcvport_0/fcpinit_X/hostX

					/fcrport_0

6.1) When the fcrports are created the FC layer will call fc4_targ_add in
the fc4_template. If SCSI is the FC4, fcp_targ_add (scsi_transport_fcp) will be called. This routine will allocate a fcptarg device, add it to sysfs and notify SCSI to scan it.

<PCI root>/fcport_0/fcfabric_0/fcvport_0/fcpinit_X/hostX

					/fcrport_0/fcptargX:0-0

The current series shortcomings are:

1) The FC4 interface needs work to become more FC4 agnostic. (end of include/fc/fc.h)

2) Point-to-Point mode needs to be addressed

3) BSG needs to be tested and STGT should become another FC4 that is registered with FC. Since libfc/fcoe doesn't plug into STGT yet this will be a challenge.

4) user space updates - For the fcoe-utils package, libhbalinux (user space HBA API library) needs to be updated to read the new layout before heavy testing of the new layout can be done.

5) Miscellaneous problems like error handling, fcfabric deletion cleaning up vports, using attribute containers / scsi transport style for SCSI-FCP devices, warnings, etc...

6) FCoE attributes...

Other thoughts:

I would love to collaborate with someone who maintains a HBA that supports native FC since I'm not aware of the specific needs of traditional HBAs.

I would hope that this new layout could be added to the kernel (when ready) and the existing FC Transport deprecated as I'm not sure how to get all HBA maintainers to switch their drivers at the same time. I think that only adding FCoE attributes to this layout would be an incentive to get LLDs to migrate.

Quoted 4 lines

I've tried to keep this covermail brief, so there are plenty of details left out. Please ask if you have a question.

Thanks, //Rob

<snip>

Hi Rob,

I'm running the patches and they work OK (very lightly used).

I'd prefer we kept the naming in /sys/class shorter and keep underscores after "fc" like we currently have in fc_remote_port. Maybe you could continue to use the existing names where they apply, after getting the other transport code converted.

Here are my suggested name changes:

fcvport becomes fc_vport
fcvport/fcvport_0 becomes fc_vport/0
fcpinit_4 becomes fcp_init4
fcptarg-X:0-1 becomes fcp_targ/1
fcrport:xxx-0 becomes fc_rport/0 (or fc_remote_ports/xxx eventually) fcfabric/fcfabric_0 becomes fc_fabric/0
fcport/fcport_0 becomes fc_port/0

When we have local FCP target ports (as opposed to remote ones) how will we represent that? You could include that in the diagram.

When we see remote initiators, how do we show them? Maybe we just don't create anything under fcport_N in that case.

I may have more comments later after I look through the code a bit further. I'm modifying fcc to handle the new trees.

Minor issues: I noticed that fnic no longer compiles and checkpatch spots some issues, but I'm sure those will be fixed later.

Regards,
Joe

#5 lore raw
Quoted 112 lines · Joe Eykholt
Quoted 111 lines · Robert Love

This series represents the continuation of the RFC archived here:
http://marc.info/?l=linux-scsi&m=126463466126962&w=2. The sysfs organization has taken shape and object allocations make more sense than the previous RFC. The patches have undergone my own developer testing, which has mostly focused on NPIV port creation and deletion and some I/O.

This series creates a Fibre Channel subsystem that has an improved sysfs device tree (the port's view of the fabric) and begins to abstract itself from SCSI.

This RFC is to solicit any feedback before I continue to refine these patches. I've created two diagrams to help people understand the change. The first shows the current sysfs device layout and the second shows the allocation scheme for libfc and fcoe's primary data structures.

http://open-fcoe.org/rwlove/fc_sysfs.jpg
http://open-fcoe.org/rwlove/libfc_alloc.jpg

These patches apply to scsi-misc + the recently submitted fcoe patches, which is the same as the fcoe-next tree on open-fcoe.org.

Overview of N_Port creation/login (for fcoe.ko):

1) First, fc.ko is installed and then scsi_transport_fcp.ko is installed. scsi_transport_fcp.ko registers itself (SCSI initiator) as a FC4 with fc.ko.

2) When a fcoe port is "created" from
'echo ethX > /sys/module/fcoe/parameters/create' a fcport is allocated and added to sysfs. All of the port's physical properties are added as attributes.

<PCI root>/fcport_0

3) At this point libfc/libfcoe/fcoe needs an lport and an fcoe_port. The lport and fcoe_ports are private data of a fcvport so a fcvport is allocated, but not added to sysfs.

4) libfcoe.ko discovers FCFs and allocates/adds them as fcfabrics to sysfs as they are discovered.

[ I think that we may want to revisit the idea of having a fcfport between
the fcport and fcfabric. Right now I'm creating a fcfabric for each FCF that is discovered at the FIP phase, but that doesn't make much sense since multiple FCFs on the same fabric can be discovered. Adding a fcfport for each FCF discovered might be more correct. ]

<PCI root>/fcport_0/fcfabric_0

5) libfc.ko will FLOGI into the fabric and upon the FLOGI ACC the fcvport will be added to sysfs.

<PCI root>/fcport_0/fcfabric_0/fcvport_0

5.1) The FC layer will call fc4_init_add in the fc4_template. If SCSI
is the FC4, fcp_init_add (scsi_transport_fcp) will be called. This routine calls scsi_host_alloc/scsi_add_host. There is also a callback down to the LLD so that it can setup any SCSI-FCP private data.

[ I'm not sure how non-FCoE HBAs will do this. I imagine they will just
create all three sysfs devices (fcport, fcfabric and fcvport) on the FLOGI ACC since they do not rely on a discovery protocol. ]

<PCI root>/fcport_0/fcfabric_0/fcvport_0/fcpinit_X/hostX

6) libfc will start discovery and as remote ports are discovered libfc will notify FC to create and add fcrports to sysfs.

<PCI root>/fcport_0/fcfabric_0/fcvport_0/fcpinit_X/hostX

					/fcrport_0

6.1) When the fcrports are created the FC layer will call fc4_targ_add in
the fc4_template. If SCSI is the FC4, fcp_targ_add (scsi_transport_fcp) will be called. This routine will allocate a fcptarg device, add it to sysfs and notify SCSI to scan it.

<PCI root>/fcport_0/fcfabric_0/fcvport_0/fcpinit_X/hostX

					/fcrport_0/fcptargX:0-0

The current series shortcomings are:

1) The FC4 interface needs work to become more FC4 agnostic. (end of include/fc/fc.h)

2) Point-to-Point mode needs to be addressed

3) BSG needs to be tested and STGT should become another FC4 that is registered with FC. Since libfc/fcoe doesn't plug into STGT yet this will be a challenge.

4) user space updates - For the fcoe-utils package, libhbalinux (user space HBA API library) needs to be updated to read the new layout before heavy testing of the new layout can be done.

5) Miscellaneous problems like error handling, fcfabric deletion cleaning up vports, using attribute containers / scsi transport style for SCSI-FCP devices, warnings, etc...

6) FCoE attributes...

Other thoughts:

I would love to collaborate with someone who maintains a HBA that supports native FC since I'm not aware of the specific needs of traditional HBAs.

I would hope that this new layout could be added to the kernel (when ready) and the existing FC Transport deprecated as I'm not sure how to get all HBA maintainers to switch their drivers at the same time. I think that only adding FCoE attributes to this layout would be an incentive to get LLDs to migrate.

Quoted 9 lines
Quoted 4 lines

I've tried to keep this covermail brief, so there are plenty of details left out. Please ask if you have a question.

Thanks, //Rob

<snip>

Hi Rob,

Hi Joe, thanks for taking a look.

Quoted 9 lines

I'm running the patches and they work OK (very lightly used).

I'd prefer we kept the naming in /sys/class shorter and keep underscores after "fc" like we currently have in fc_remote_port. Maybe you could continue to use the existing names where they apply, after getting the other transport code converted.

Here are my suggested name changes:

Quoted 8 lines

fcvport becomes fc_vport
fcvport/fcvport_0 becomes fc_vport/0
fcpinit_4 becomes fcp_init4
fcptarg-X:0-1 becomes fcp_targ/1
fcrport:xxx-0 becomes fc_rport/0 (or fc_remote_ports/xxx eventually) fcfabric/fcfabric_0 becomes fc_fabric/0
fcport/fcport_0 becomes fc_port/0

Sure, that sounds reasonable. I think I've got too much fc_fc* stuff in general- device names, function names, etc...

Quoted 3 lines

When we have local FCP target ports (as opposed to remote ones) how will we represent that? You could include that in the diagram.

This is something that I've got to figure out so that I don't lose any existing functionality. I need a way to test whatever scheme is agreed upon and since stgt isn't integrated with libfc/fcoe I'll either need to integrate it or use one of the out-of-tree target infrastructures to create local target ports.

Quoted 3 lines

When we see remote initiators, how do we show them? Maybe we just don't create anything under fcport_N in that case.

The FC layer could create an fc_rport and notify the registered FC4. I haven't really thought out if the SCSI-FCP layer would do anything though.

Another related question is if a discovered target is represented by the same device/structure when the host is an initiator or target. The same question applies to discovered initiators.

Quoted 3 lines

I may have more comments later after I look through the code a bit further. I'm modifying fcc to handle the new trees.

Very cool. Let me know when you have it done as I'd love to use it for testing.

Quoted 2 lines

Minor issues: I noticed that fnic no longer compiles and checkpatch spots some issues, but I'm sure those will be fixed later.

Yeah, sorry about fnic. :)

I tried to clean up a lot of the checkpatch warnings, many were the result of code moved from scsi_transport_fc, so I tried to clean up all of the issues that I introduced and some of the existing ones. I'll clean up all that stuff once this code matures.

#6 lore raw
Quoted 143 lines · Robert Love
Quoted 112 lines · Joe Eykholt
Quoted 111 lines · Robert Love

This series represents the continuation of the RFC archived here:
http://marc.info/?l=linux-scsi&m=126463466126962&w=2. The sysfs organization has taken shape and object allocations make more sense than the previous RFC. The patches have undergone my own developer testing, which has mostly focused on NPIV port creation and deletion and some I/O.

This series creates a Fibre Channel subsystem that has an improved sysfs device tree (the port's view of the fabric) and begins to abstract itself from SCSI.

This RFC is to solicit any feedback before I continue to refine these patches. I've created two diagrams to help people understand the change. The first shows the current sysfs device layout and the second shows the allocation scheme for libfc and fcoe's primary data structures.

http://open-fcoe.org/rwlove/fc_sysfs.jpg
http://open-fcoe.org/rwlove/libfc_alloc.jpg

These patches apply to scsi-misc + the recently submitted fcoe patches, which is the same as the fcoe-next tree on open-fcoe.org.

Overview of N_Port creation/login (for fcoe.ko):

1) First, fc.ko is installed and then scsi_transport_fcp.ko is installed. scsi_transport_fcp.ko registers itself (SCSI initiator) as a FC4 with fc.ko.

2) When a fcoe port is "created" from
'echo ethX > /sys/module/fcoe/parameters/create' a fcport is allocated and added to sysfs. All of the port's physical properties are added as attributes.

<PCI root>/fcport_0

3) At this point libfc/libfcoe/fcoe needs an lport and an fcoe_port. The lport and fcoe_ports are private data of a fcvport so a fcvport is allocated, but not added to sysfs.

4) libfcoe.ko discovers FCFs and allocates/adds them as fcfabrics to sysfs as they are discovered.

[ I think that we may want to revisit the idea of having a fcfport between
the fcport and fcfabric. Right now I'm creating a fcfabric for each FCF that is discovered at the FIP phase, but that doesn't make much sense since multiple FCFs on the same fabric can be discovered. Adding a fcfport for each FCF discovered might be more correct. ]

<PCI root>/fcport_0/fcfabric_0

5) libfc.ko will FLOGI into the fabric and upon the FLOGI ACC the fcvport will be added to sysfs.

<PCI root>/fcport_0/fcfabric_0/fcvport_0

5.1) The FC layer will call fc4_init_add in the fc4_template. If SCSI
is the FC4, fcp_init_add (scsi_transport_fcp) will be called. This routine calls scsi_host_alloc/scsi_add_host. There is also a callback down to the LLD so that it can setup any SCSI-FCP private data.

[ I'm not sure how non-FCoE HBAs will do this. I imagine they will just
create all three sysfs devices (fcport, fcfabric and fcvport) on the FLOGI ACC since they do not rely on a discovery protocol. ]

<PCI root>/fcport_0/fcfabric_0/fcvport_0/fcpinit_X/hostX

6) libfc will start discovery and as remote ports are discovered libfc will notify FC to create and add fcrports to sysfs.

<PCI root>/fcport_0/fcfabric_0/fcvport_0/fcpinit_X/hostX

					/fcrport_0

6.1) When the fcrports are created the FC layer will call fc4_targ_add in
the fc4_template. If SCSI is the FC4, fcp_targ_add (scsi_transport_fcp) will be called. This routine will allocate a fcptarg device, add it to sysfs and notify SCSI to scan it.

<PCI root>/fcport_0/fcfabric_0/fcvport_0/fcpinit_X/hostX

					/fcrport_0/fcptargX:0-0

The current series shortcomings are:

1) The FC4 interface needs work to become more FC4 agnostic. (end of include/fc/fc.h)

2) Point-to-Point mode needs to be addressed

3) BSG needs to be tested and STGT should become another FC4 that is registered with FC. Since libfc/fcoe doesn't plug into STGT yet this will be a challenge.

4) user space updates - For the fcoe-utils package, libhbalinux (user space HBA API library) needs to be updated to read the new layout before heavy testing of the new layout can be done.

5) Miscellaneous problems like error handling, fcfabric deletion cleaning up vports, using attribute containers / scsi transport style for SCSI-FCP devices, warnings, etc...

6) FCoE attributes...

Other thoughts:

I would love to collaborate with someone who maintains a HBA that supports native FC since I'm not aware of the specific needs of traditional HBAs.

I would hope that this new layout could be added to the kernel (when ready) and the existing FC Transport deprecated as I'm not sure how to get all HBA maintainers to switch their drivers at the same time. I think that only adding FCoE attributes to this layout would be an incentive to get LLDs to migrate.

Quoted 8 lines
Quoted 4 lines

I've tried to keep this covermail brief, so there are plenty of details left out. Please ask if you have a question.

Thanks, //Rob

<snip>

Hi Rob,

Hi Joe, thanks for taking a look.

Quoted 9 lines

I'm running the patches and they work OK (very lightly used).

I'd prefer we kept the naming in /sys/class shorter and keep underscores after "fc" like we currently have in fc_remote_port. Maybe you could continue to use the existing names where they apply, after getting the other transport code converted.

Here are my suggested name changes:

Quoted 8 lines

fcvport becomes fc_vport
fcvport/fcvport_0 becomes fc_vport/0
fcpinit_4 becomes fcp_init4
fcptarg-X:0-1 becomes fcp_targ/1
fcrport:xxx-0 becomes fc_rport/0 (or fc_remote_ports/xxx eventually) fcfabric/fcfabric_0 becomes fc_fabric/0
fcport/fcport_0 becomes fc_port/0

Sure, that sounds reasonable. I think I've got too much fc_fc* stuff in general- device names, function names, etc...

Quoted 8 lines
Quoted 3 lines

When we have local FCP target ports (as opposed to remote ones) how will we represent that? You could include that in the diagram.

This is something that I've got to figure out so that I don't lose any existing functionality. I need a way to test whatever scheme is agreed upon and since stgt isn't integrated with libfc/fcoe I'll either need to integrate it or use one of the out-of-tree target infrastructures to create local target ports.

You wouldn't have to implement it, I just wanted to know what the names would be. Depending on the target module, they each have their own management, and if/when they get into the kernel, we can add something to this scheme. scsi_tgt, being all in user land, doesn't even show up in /sys.

Quoted 14 lines
Quoted 3 lines

When we see remote initiators, how do we show them? Maybe we just don't create anything under fcport_N in that case.

The FC layer could create an fc_rport and notify the registered FC4. I haven't really thought out if the SCSI-FCP layer would do anything though.

Another related question is if a discovered target is represented by the same device/structure when the host is an initiator or target. The same question applies to discovered initiators.

Quoted 3 lines

I may have more comments later after I look through the code a bit further. I'm modifying fcc to handle the new trees.

Quoted 7 lines

Very cool. Let me know when you have it done as I'd love to use it for testing.

Quoted 2 lines

Minor issues: I noticed that fnic no longer compiles and checkpatch spots some issues, but I'm sure those will be fixed later.

Yeah, sorry about fnic. :)

No biggie. It makes sense to convert one LLD first and then then other.

Quoted 4 lines

I tried to clean up a lot of the checkpatch warnings, many were the result of code moved from scsi_transport_fc, so I tried to clean up all of the issues that I introduced and some of the existing ones. I'll clean up all that stuff once this code matures.

Oh, right. I remember that now. Maybe checkpatch should be smart enough to realize the code had just moved ... not easy, though.

Regards,
Joe

#7 lore raw
Quoted 20 lines · Joe Eykholt
Quoted 19 lines · Robert Love
Quoted 18 lines · Joe Eykholt
Quoted 17 lines · Robert Love

This series represents the continuation of the RFC archived here:
http://marc.info/?l=linux-scsi&m=126463466126962&w=2. The sysfs organization has taken shape and object allocations make more sense than the previous RFC. The patches have undergone my own developer testing, which has mostly focused on NPIV port creation and deletion and some I/O.

This series creates a Fibre Channel subsystem that has an improved sysfs device tree (the port's view of the fabric) and begins to abstract itself from SCSI.

This RFC is to solicit any feedback before I continue to refine these patches. I've created two diagrams to help people understand the change. The first shows the current sysfs device layout and the second shows the allocation scheme for libfc and fcoe's primary data structures.

http://open-fcoe.org/rwlove/fc_sysfs.jpg
http://open-fcoe.org/rwlove/libfc_alloc.jpg

<SNIP>

Quoted 23 lines
Quoted 14 lines
Quoted 11 lines

Here are my suggested name changes:

fcvport becomes fc_vport
fcvport/fcvport_0 becomes fc_vport/0
fcpinit_4 becomes fcp_init4
fcptarg-X:0-1 becomes fcp_targ/1
fcrport:xxx-0 becomes fc_rport/0 (or fc_remote_ports/xxx eventually) fcfabric/fcfabric_0 becomes fc_fabric/0
fcport/fcport_0 becomes fc_port/0

Sure, that sounds reasonable. I think I've got too much fc_fc* stuff in general- device names, function names, etc...

Quoted 8 lines
Quoted 3 lines

When we have local FCP target ports (as opposed to remote ones) how will we represent that? You could include that in the diagram.

This is something that I've got to figure out so that I don't lose any existing functionality. I need a way to test whatever scheme is agreed upon and since stgt isn't integrated with libfc/fcoe I'll either need to integrate it or use one of the out-of-tree target infrastructures to create local target ports.

Quoted 6 lines

You wouldn't have to implement it, I just wanted to know what the names would be. Depending on the target module, they each have their own management, and if/when they get into the kernel, we can add something to this scheme. scsi_tgt, being all in user land, doesn't even show up in /sys.

Hi Joe and Robert,

So for FC capable target fabric modules, one of this things that would be really useful is a method exposed by libfc to allow the explict creation/release of local FCP target ports as they are configured on the fly by TCM_FC with configfs. Currently when a individual lport WWPN is created with:

mkdir -p /sys/kernel/config/target/fc/XX:XX:XX:XX:XX:XX:XX:XX

the internal struct ft_lport_acl gets allocated, but we cannot tell if the passed lport WWPN contains a reference to a underlying piece of FC or FCoE capable hardware. This is of course because the TCM_FC code is driven by Joe's patched libfc that forwards PLOGI into struct fc4_prov->ft_prli() that search for a matching struct ft_lport_acl->wwpn to reference a individual TCM_FC target port.

So for making libfc explictly aware of externally configured FCP target ports, we would need something like:

*) A function that accepts a TCM_FC provided lport WWPN string and previously registered struct fc4_prov pointer that returns reference to a libfc target port descriptor. (eg: looks matching hardware WWPN)

*) A function thats then accepts the above libfc target port descriptor and creates FCP target port group+attributes in sysfs once the TCM_FC lport has been successfully configured.

*) And a function to explictly release the FCP target port. This order is obviously going to depend a great deal on what target logic that libfc ends up exposing.

I know that Joe's original patches to provide target mode hooks for struct fc4_prov for I_T Nexus and I/O path logic still need to be resolved for upstream, but I think having libfc support some form of explict FCP target port configuration accessable by fabric modules would be a reasonable next step.

Best,

--nab