Skip to contentSkip to conversation

Work In Progress: FC sysfs

RFC PATCH In review Robert Love 3 participants 10 messages Jan 27, 2010 – Feb 2, 2010

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

cover Work In Progress: FC sysfs

This series is the beginning of a FC sysfs reorganization. The new layout as suggested in this post, http://marc.info/?l=linux-scsi&m=124404278711785&w=2,
creates more sysfs objects to expose FC session information and decouples the FC sysfs layout from SCSI until FC attaches to the SCSI mid-layer.

The first four patches in this series are just preparation patches that have not been merged. They can mostly be ignored. The fifth patch introduces FC sysfs and the last patch modifies libfc, libfcoe and fcoe to use the new FC sysfs interface.

These patches move code out of scsi_transport_fc.[ch] and into individual files for each of the new sysfs objects. Compilation creates a new fc_sysfs.ko module. I'm not sure if this is a good overall approach, but I wanted to make sure that I didn't overlook any relationships as I made changes. This results in a patch that doesn't show a good progression of changes, rather a big change combined with code moving from file(s) to other file(s). This can be addressed when the patch series is further along in development.

To review, it might be easier to apply the patches and look at drivers/scsi/fc/ and include/scsi/fc.h.

Functionally both real and NPIV port creation and deletion is working under libfc/fcoe, with most if not all attributes showing correct values. I did not spend much time on error handling or cleanliness, these are things that I'd prefer to address once I'm further along.

These patches create the following sysfs layout-

Device tree:
/sys/devices/virtual/net/eth3.101/fcport1/fcfport_2001000deca31e81/fcfabric_0/fcvport_0/host6/fcpinit/host6/

LDM tree:
/sys/class/fcport/fcport1/fcfport_2001000deca31e81/fcfabric_0/fcvport_0/host6/fcpinit/host6/

Each object has redistributed attributes:
#ls /sys/devices/virtual/net/eth3.101/fcport1/
active_fc4s device fcfport_2001000deca31e81 maxframe_size power serial_number speed subsystem supported_classes supported_fc4s supported_speeds uevent

# ls /sys/devices/virtual/net/eth3.101/fcport1/fcfport_2001000deca31e81/
fcfabric_0  power  uevent
# ls /sys/devices/virtual/net/eth3.101/fcport1/fcfport_2001000deca31e81/fcfabric_0/
fabric_name  fcvport_0  fcvport_1  max_npiv_vports  npiv_vports_inuse  power  uevent  vport_create  vport_delete
# ls /sys/devices/virtual/net/eth3.101/fcport1/fcfport_2001000deca31e81/fcfabric_0/fcvport_0/
host6  node_name  port_id  port_name  port_type  power  roles  symbolic_name  uevent  vport_last_state  vport_state  vport_type
# ls /sys/devices/virtual/net/eth3.101/fcport1/fcfport_2001000deca31e81/fcfabric_0/fcvport_0/host6/
bsg  fcpinit  power  rport-6:0-0  rport-6:0-2  scsi_host  subsystem  uevent
# ls /sys/devices/virtual/net/eth3.101/fcport1/fcfport_2001000deca31e81/fcfabric_0/fcvport_0/host6/fcpinit/
host6
# ls /sys/devices/virtual/net/eth3.101/fcport1/fcfport_2001000deca31e81/fcfabric_0/fcvport_0/host6/fcpinit/host6/
device  issue_lip  port_state  power  statistics  subsystem  tgtid_bind_type  uevent

VN_Ports ports show up just like N_Ports: (notice fcvport_1, not fcvport_0)

# ls /sys/devices/virtual/net/eth3.101/fcport1/fcfport_2001000deca31e81/fcfabric_0/fcvport_1/
host7  node_name  port_id  port_name  port_type  power  roles  symbolic_name  uevent  vport_last_state  vport_state  vport_type

My open questions are:

1) How is the FC4 choice made?

If FC sysfs allows an FC HBA to support other FC4 types, then how and when is the selection made? It seems that this decision would either need to be hard-coded or provided by the user. fcoe.ko requires user action to start a connection. It would be easy for us to also require a FC4 selection (maybe it defaults to SCSI-FCP (init)). HW adapters generally FLOGI on link up and do not require user interaction. How would this decision be made?

2) How do I reorder fc_host and scsi_host?

Previously the fc_host is attached as a child of the scsi_host. The new layout has the scsi_host as a child of fcpinit. These patches have the fcpinit object created by the scsi transport and attribute container code. I'm not sure if/how to re-order these objects, it might require changes to the scsi transport and AC code.

3) What do I do about remote_ports?

Currently the remote_ports are created by the scsi transport and AC code which places them as children of the fc_host. I believe this problem is essentially the same as #2, but with remote ports instead of the fc_host.

4) What should the FC sysfs objects be?

Should they be class objects? I just made them of type 'struct device' to keep them as flexible as possible. I made the fcport a class object so that it could be anchored at /sys/class/.

(last minute note: I just saw in the link referenced above, that the
objects were referred to as classes. I missed that initiatlly, is there no concern about adding too many classes to /sys?)

5) How should the FC sysfs objects be named?

Currently I have two styles. The fcport, fcfabric and fcvport objects are all enumerated. The fcfport is given a name from its WWPN/WWNN. It's pretty ugly as is, and the naming needs more consideration.

I don't really like N_Ports being referred to as vports in sysfs either.

6) What about complicated relationships between objects?

Right now this layout cannot elegantly support multiple physical ports connected to the same F_Port. Each port will have it's own sysfs directory tree and the two trees will not converge even if they share the same F_Port/fabric/etc... vports under a physical port will show up under the physical port's sysfs directory tree.

7) Should vport_create/destroy be under fcfabric or fcport?

I've currently put the vport_create/destroy attributes under the fcfabric. I think this is fine for now, since there are no complicated object relationships being presented. There's a one to one relationship between a fcport and a fcfabric so it's fairly easy to go back to the fcport, which is needed to be passed to the LLD so it can create a vport. If there were more than one fcport per fcfabric it would complicate this. Should the vport_create/destroy be moved to be attributes of the fcport instead to avoid a potential lookup if things get more complicated in the future?

8) Should the fcfport and fcfabric be consolidated?

The fcfport doesn't show much other than its name. The fcfabric doesn't have many attributes either. Most of its attributes are vport related. I could see adding some FIP information to the fcfport, but I'm not sure we need two objects here, especially if the vport attributes need to be moved to the fcport.

9) Is this change worth all of the changes that will need to happen?

This is probably the most difficult question. I view this change as positive overall, but it's very heavy lifting. Not only does the FC transport need an overhaul, but it looks like the scsi transport and AC code might need some additions. Every HBA will need to be modified and every HBA's HBAAPI vendor library will need to change too. (I hope this would be a catalyst to move to an OS library that everyone shares)

I'd like to hear other opinions about this because this really is going to be something that all HBAs will need to be involved in.

---

Robert Love (6):
libfc, libfcoe, fcoe: Make use of FC sysfs
fc_sysfs: Rearrange the FC transport to create FC sysfs
libfc: Move the port_id into lport
fcoe: move link speed checking into its own routine
libfc: Remove extra pointer check
libfc: Remove unused fc_get_host_port_type

 drivers/scsi/Kconfig             |    6 
 drivers/scsi/Makefile            |    1 
 drivers/scsi/fc/Makefile         |    8 
 drivers/scsi/fc/fc_sysfs.h       |   35 +
 drivers/scsi/fc/fcfabric.c       |  441 ++++++++++++
 drivers/scsi/fc/fcfport.c        |   73 ++
 drivers/scsi/fc/fcpinit.c        |   66 ++
 drivers/scsi/fc/fcport.c         |  217 ++++++
 drivers/scsi/fc/fcsysfs.c        |   41 +
 drivers/scsi/fc/fcvport.c        |  485 +++++++++++++
 drivers/scsi/fcoe/fcoe.c         |  558 ++++++++++-----
 drivers/scsi/fcoe/libfcoe.c      |   55 +
 drivers/scsi/libfc/fc_disc.c     |    6 
 drivers/scsi/libfc/fc_elsct.c    |    2 
 drivers/scsi/libfc/fc_exch.c     |    4 
 drivers/scsi/libfc/fc_fcp.c      |  145 ++--
 drivers/scsi/libfc/fc_libfc.h    |   32 -
 drivers/scsi/libfc/fc_lport.c    |  208 +++---
 drivers/scsi/libfc/fc_npiv.c     |   56 +-
 drivers/scsi/libfc/fc_rport.c    |   12 
 drivers/scsi/scsi_transport_fc.c | 1411 ++++++--------------------------------
 include/scsi/fc.h                |  460 ++++++++++++
 include/scsi/fc_encode.h         |   48 +
 include/scsi/libfc.h             |  130 ++--
 include/scsi/scsi_transport_fc.h |  329 ++-------
 25 files changed, 2893 insertions(+), 1936 deletions(-)
 create mode 100644 drivers/scsi/fc/Makefile
 create mode 100644 drivers/scsi/fc/fc_sysfs.h
 create mode 100644 drivers/scsi/fc/fcfabric.c
 create mode 100644 drivers/scsi/fc/fcfport.c
 create mode 100644 drivers/scsi/fc/fcpinit.c
 create mode 100644 drivers/scsi/fc/fcport.c
 create mode 100644 drivers/scsi/fc/fcsysfs.c
 create mode 100644 drivers/scsi/fc/fcvport.c
 create mode 100644 include/scsi/fc.h
Signature · 1 line
//Rob
#1 lore raw

RFC PATCH 1/6 libfc: Remove unused fc_get_host_port_type

Remove an unused routine.

---

 drivers/scsi/libfc/fc_lport.c |   11 -----------
 include/scsi/libfc.h          |    1 -
 2 files changed, 0 insertions(+), 12 deletions(-)
drivers/scsi/libfc/fc_lport.c +0 -11
index 7ec8ce7..d35fc49 100644
@@ -240,17 +240,6 @@ static void fc_lport_ptp_setup(struct fc_lport *lport,
 }
 
 /**
- * fc_get_host_port_type() - Return the port type of the given Scsi_Host
- * @shost: The SCSI host whose port type is to be determined
- */
-void fc_get_host_port_type(struct Scsi_Host *shost)
-{
-	/* TODO - currently just NPORT */
-	fc_host_port_type(shost) = FC_PORTTYPE_NPORT;
-}
-EXPORT_SYMBOL(fc_get_host_port_type);
-
-/**
  * fc_get_host_port_state() - Return the port state of the given Scsi_Host
  * @shost:  The SCSI host whose port state is to be determined
  */
include/scsi/libfc.h +0 -1
index 4b912ee..e31150a 100644
@@ -1053,7 +1053,6 @@ void fc_exch_mgr_reset(struct fc_lport *, u32 s_id, u32 d_id);
  * Functions for fc_functions_template
  */
 void fc_get_host_speed(struct Scsi_Host *);
-void fc_get_host_port_type(struct Scsi_Host *);
 void fc_get_host_port_state(struct Scsi_Host *);
 void fc_set_rport_loss_tmo(struct fc_rport *, u32 timeout);
 struct fc_host_statistics *fc_get_host_stats(struct Scsi_Host *);
#2 lore raw

RFC PATCH 2/6 libfc: Remove extra pointer check

In reply to Robert Love

The fcf pointer is checked immediately after this call making this call redundant. Remote the first check.

---

 drivers/scsi/fcoe/libfcoe.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
drivers/scsi/fcoe/libfcoe.c +1 -2
index 511cb6b..5dae90e 100644
@@ -941,8 +941,7 @@ static void fcoe_ctlr_recv_clr_vlink(struct fcoe_ctlr *fip,
 	u32	desc_mask;
 
 	LIBFCOE_FIP_DBG(fip, "Clear Virtual Link received\n");
-	if (!fcf)
-		return;
+
 	if (!fcf || !fc_host_port_id(lport->host))
 		return;
 
#3 lore raw

RFC PATCH 3/6 fcoe: move link speed checking into its own routine

In reply to Robert Love

It doesn't make sense to update the link speed in the is_link_ok() routine. Move it to it's own routine and acquire the device speed when we're configuring the device initially as well as if there are any netdev events received.

---

 drivers/scsi/fcoe/fcoe.c |   42 +++++++++++++++++++++++++++++-------------
 1 files changed, 29 insertions(+), 13 deletions(-)
drivers/scsi/fcoe/fcoe.c +29 -13
index 10be9f3..a719994 100644
@@ -73,6 +73,7 @@ static int fcoe_rcv(struct sk_buff *, struct net_device *,
 static int fcoe_percpu_receive_thread(void *);
 static void fcoe_clean_pending_queue(struct fc_lport *);
 static void fcoe_percpu_clean(struct fc_lport *);
+static int fcoe_link_speed_update(struct fc_lport *);
 static int fcoe_link_ok(struct fc_lport *);
 
 static struct fc_lport *fcoe_hostlist_lookup(const struct net_device *);
@@ -628,6 +629,8 @@ static int fcoe_netdev_config(struct fc_lport *lport, struct net_device *netdev)
 	port->fcoe_pending_queue_active = 0;
 	setup_timer(&port->timer, fcoe_queue_timer, (unsigned long)lport);
 
+	fcoe_link_speed_update(lport);
+
 	if (!lport->vport) {
 		/*
 		 * Use NAA 1&2 (FC-FS Rev. 2.0, Sec. 15) to generate WWNN/WWPN:
@@ -1834,6 +1837,9 @@ static int fcoe_device_notification(struct notifier_block *notifier,
 		FCOE_NETDEV_DBG(netdev, "Unknown event %ld "
 				"from netdev netlink\n", event);
 	}
+
+	fcoe_link_speed_update(lport);
+
 	if (link_possible && !fcoe_link_ok(lport))
 		fcoe_ctlr_link_up(&fcoe->ctlr);
 	else if (fcoe_ctlr_link_down(&fcoe->ctlr)) {
@@ -2115,27 +2121,20 @@ out_nodev:
 }
 
 /**
- * fcoe_link_ok() - Check if the link is OK for a local port
- * @lport: The local port to check link on
- *
- * Any permanently-disqualifying conditions have been previously checked.
- * This also updates the speed setting, which may change with link for 100/1000.
+ * fcoe_link_speed_update() - Update the supported and actual link speeds
+ * @lport: The local port to update speeds for
  *
- * This function should probably be checking for PAUSE support at some point
- * in the future. Currently Per-priority-pause is not determinable using
- * ethtool, so we shouldn't be restrictive until that problem is resolved.
- *
- * Returns: 0 if link is OK for use by FCoE.
+ * Returns: 0 if the ethtool query was successful
+ *          -1 if the ethtool query failed
  *
  */
-int fcoe_link_ok(struct fc_lport *lport)
+int fcoe_link_speed_update(struct fc_lport *lport)
 {
 	struct fcoe_port *port = lport_priv(lport);
 	struct net_device *netdev = port->fcoe->netdev;
 	struct ethtool_cmd ecmd = { ETHTOOL_GSET };
 
-	if ((netdev->flags & IFF_UP) && netif_carrier_ok(netdev) &&
-	    (!dev_ethtool_get_settings(netdev, &ecmd))) {
+	if (!dev_ethtool_get_settings(netdev, &ecmd)) {
 		lport->link_supported_speeds &=
 			~(FC_PORTSPEED_1GBIT | FC_PORTSPEED_10GBIT);
 		if (ecmd.supported & (SUPPORTED_1000baseT_Half |
@@ -2155,6 +2154,23 @@ int fcoe_link_ok(struct fc_lport *lport)
 }
 
 /**
+ * fcoe_link_ok() - Check if the link is OK for a local port
+ * @lport: The local port to check link on
+ *
+ * Returns: 0 if link is UP and OK, -1 if not
+ *
+ */
+int fcoe_link_ok(struct fc_lport *lport)
+{
+	struct fcoe_port *port = lport_priv(lport);
+	struct net_device *netdev = port->fcoe->netdev;
+
+	if ((netdev->flags & IFF_UP) && netif_carrier_ok(netdev))
+		return 0;
+	return -1;
+}
+
+/**
  * fcoe_percpu_clean() - Clear all pending skbs for an local port
  * @lport: The local port whose skbs are to be cleared
  *
#4 lore raw

RFC PATCH 4/6 libfc: Move the port_id into lport

In reply to Robert Love

This patch probably isn't complete. libfc was relying too much on members of the fc_host. Since the later patches in this series reduce libfc's dependecy on the scsi-ml I had to duplicate some of the fc_host information in the lport.

port_id was one member that I duplicated in the fc_lport, but I think this patch should be broader and clearly separate the operational data (i.e. the stuff in lport) from the presentation layer.

---

 drivers/scsi/fcoe/libfcoe.c   |    9 ++++-----
 drivers/scsi/libfc/fc_disc.c  |    2 +-
 drivers/scsi/libfc/fc_elsct.c |    2 +-
 drivers/scsi/libfc/fc_exch.c  |    2 +-
 drivers/scsi/libfc/fc_fcp.c   |   15 +++++++--------
 drivers/scsi/libfc/fc_libfc.h |    2 +-
 drivers/scsi/libfc/fc_lport.c |   14 +++++++-------
 drivers/scsi/libfc/fc_npiv.c  |    4 ++--
 include/scsi/fc_encode.h      |   18 +++++++-----------
 include/scsi/libfc.h          |    2 ++
 10 files changed, 33 insertions(+), 37 deletions(-)
drivers/scsi/fcoe/libfcoe.c +4 -5
index 5dae90e..a554672 100644
@@ -348,7 +348,7 @@ static void fcoe_ctlr_send_keep_alive(struct fcoe_ctlr *fip,
 
 	fcf = fip->sel_fcf;
 	lp = fip->lp;
-	if (!fcf || !fc_host_port_id(lp->host))
+	if (!fcf || !lp->port_id)
 		return;
 
 	len = sizeof(*kal) + ports * sizeof(*vn);
@@ -379,7 +379,7 @@ static void fcoe_ctlr_send_keep_alive(struct fcoe_ctlr *fip,
 		vn->fd_desc.fip_dtype = FIP_DT_VN_ID;
 		vn->fd_desc.fip_dlen = sizeof(*vn) / FIP_BPW;
 		memcpy(vn->fd_mac, fip->get_src_addr(lport), ETH_ALEN);
-		hton24(vn->fd_fc_id, fc_host_port_id(lp->host));
+		hton24(vn->fd_fc_id, lp->port_id);
 		put_unaligned_be64(lp->wwpn, &vn->fd_wwpn);
 	}
 	skb_put(skb, len);
@@ -942,7 +942,7 @@ static void fcoe_ctlr_recv_clr_vlink(struct fcoe_ctlr *fip,
 
 	LIBFCOE_FIP_DBG(fip, "Clear Virtual Link received\n");
 
-	if (!fcf || !fc_host_port_id(lport->host))
+	if (!fcf || !lport->port_id)
 		return;
 
 	/*
@@ -980,8 +980,7 @@ static void fcoe_ctlr_recv_clr_vlink(struct fcoe_ctlr *fip,
 			if (compare_ether_addr(vp->fd_mac,
 					       fip->get_src_addr(lport)) == 0 &&
 			    get_unaligned_be64(&vp->fd_wwpn) == lport->wwpn &&
-			    ntoh24(vp->fd_fc_id) ==
-			    fc_host_port_id(lport->host))
+			    ntoh24(vp->fd_fc_id) == lport->port_id)
 				desc_mask &= ~BIT(FIP_DT_VN_ID);
 			break;
 		default:
drivers/scsi/libfc/fc_disc.c +1 -1
index 9b0a519..dd703fd 100644
@@ -439,7 +439,7 @@ static int fc_disc_gpn_ft_parse(struct fc_disc *disc, void *buf, size_t len)
 		ids.port_id = ntoh24(np->fp_fid);
 		ids.port_name = ntohll(np->fp_wwpn);
 
-		if (ids.port_id != fc_host_port_id(lport->host) &&
+		if (ids.port_id != lport->port_id &&
 		    ids.port_name != lport->wwpn) {
 			rdata = lport->tt.rport_create(lport, ids.port_id);
 			if (rdata) {
drivers/scsi/libfc/fc_elsct.c +1 -1
index 5374872..e9412b7 100644
@@ -63,7 +63,7 @@ struct fc_seq *fc_elsct_send(struct fc_lport *lport, u32 did,
 		return NULL;
 	}
 
-	fc_fill_fc_hdr(fp, r_ctl, did, fc_host_port_id(lport->host), fh_type,
+	fc_fill_fc_hdr(fp, r_ctl, did, lport->port_id, fh_type,
 		       FC_FC_FIRST_SEQ | FC_FC_END_SEQ | FC_FC_SEQ_INIT, 0);
 
 	return lport->tt.exch_seq_send(lport, fp, resp, NULL, arg, timer_msec);
drivers/scsi/libfc/fc_exch.c +1 -1
index 7f43647..425f4dd 100644
@@ -1944,7 +1944,7 @@ static void fc_exch_rrq(struct fc_exch *ep)
 		did = ep->sid;
 
 	fc_fill_fc_hdr(fp, FC_RCTL_ELS_REQ, did,
-		       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 (fc_exch_seq_send(lport, fp, fc_exch_rrq_resp, NULL, ep,
drivers/scsi/libfc/fc_fcp.c +7 -8
index 6fde2fa..d2da31e 100644
@@ -483,7 +483,7 @@ crc_err:
 			if (stats->InvalidCRCCount++ < 5)
 				printk(KERN_WARNING "libfc: CRC error on data "
 				       "frame for port (%6x)\n",
-				       fc_host_port_id(lport->host));
+				       lport->port_id);
 			/*
 			 * Assume the frame is total garbage.
 			 * We may have copied it over the good part
@@ -1099,7 +1099,7 @@ static int fc_fcp_cmd_send(struct fc_lport *lport, struct fc_fcp_pkt *fsp,
 	rpriv = rport->dd_data;
 
 	fc_fill_fc_hdr(fp, FC_RCTL_DD_UNSOL_CMD, rport->port_id,
-		       fc_host_port_id(rpriv->local_port->host), FC_TYPE_FCP,
+		       rpriv->local_port->port_id, FC_TYPE_FCP,
 		       FC_FC_FIRST_SEQ | FC_FC_END_SEQ | FC_FC_SEQ_INIT, 0);
 
 	seq = lport->tt.exch_seq_send(lport, fp, resp, fc_fcp_pkt_destroy,
@@ -1372,7 +1372,7 @@ static void fc_fcp_rec(struct fc_fcp_pkt *fsp)
 
 	fr_seq(fp) = fsp->seq_ptr;
 	fc_fill_fc_hdr(fp, FC_RCTL_ELS_REQ, rport->port_id,
-		       fc_host_port_id(rpriv->local_port->host), FC_TYPE_ELS,
+		       rpriv->local_port->port_id, FC_TYPE_ELS,
 		       FC_FC_FIRST_SEQ | FC_FC_END_SEQ | FC_FC_SEQ_INIT, 0);
 	if (lport->tt.elsct_send(lport, rport->port_id, fp, ELS_REC,
 				 fc_fcp_rec_resp, fsp,
@@ -1630,7 +1630,7 @@ static void fc_fcp_srr(struct fc_fcp_pkt *fsp, enum fc_rctl r_ctl, u32 offset)
 	srr->srr_rel_off = htonl(offset);
 
 	fc_fill_fc_hdr(fp, FC_RCTL_ELS4_REQ, rport->port_id,
-		       fc_host_port_id(rpriv->local_port->host), FC_TYPE_FCP,
+		       rpriv->local_port->port_id, FC_TYPE_FCP,
 		       FC_FC_FIRST_SEQ | FC_FC_END_SEQ | FC_FC_SEQ_INIT, 0);
 
 	seq = lport->tt.exch_seq_send(lport, fp, fc_fcp_srr_resp, NULL,
@@ -2075,12 +2075,11 @@ int fc_eh_host_reset(struct scsi_cmnd *sc_cmd)
 
 	if (fc_fcp_lport_queue_ready(lport)) {
 		shost_printk(KERN_INFO, shost, "libfc: Host reset succeeded "
-			     "on port (%6x)\n", fc_host_port_id(lport->host));
+			     "on port (%6x)\n", lport->port_id);
 		return SUCCESS;
 	} else {
 		shost_printk(KERN_INFO, shost, "libfc: Host reset failed, "
-			     "port (%6x) is not ready.\n",
-			     fc_host_port_id(lport->host));
+			     "port (%6x) is not ready.\n", lport->port_id);
 		return FAILED;
 	}
 }
@@ -2165,7 +2164,7 @@ void fc_fcp_destroy(struct fc_lport *lport)
 
 	if (!list_empty(&si->scsi_pkt_queue))
 		printk(KERN_ERR "libfc: Leaked SCSI packets when destroying "
-		       "port (%6x)\n", fc_host_port_id(lport->host));
+		       "port (%6x)\n", lport->port_id);
 
 	mempool_destroy(si->scsi_pkt_pool);
 	kfree(si);
drivers/scsi/libfc/fc_libfc.h +1 -1
index 741fd5c..a79c42d 100644
@@ -47,7 +47,7 @@ extern unsigned int fc_debug_logging;
 	FC_CHECK_LOGGING(FC_LPORT_LOGGING,				\
 			 printk(KERN_INFO "host%u: lport %6x: " fmt,	\
 				(lport)->host->host_no,			\
-				fc_host_port_id((lport)->host), ##args))
+				(lport)->port_id, ##args))
 
 #define FC_DISC_DBG(disc, fmt, args...)				\
 	FC_CHECK_LOGGING(FC_DISC_LOGGING,			\
drivers/scsi/libfc/fc_lport.c +7 -7
index d35fc49..9da4c15 100644
@@ -561,7 +561,7 @@ void __fc_linkup(struct fc_lport *lport)
 void fc_linkup(struct fc_lport *lport)
 {
 	printk(KERN_INFO "host%d: libfc: Link up on port (%6x)\n",
-	       lport->host->host_no, fc_host_port_id(lport->host));
+	       lport->host->host_no, lport->port_id);
 
 	mutex_lock(&lport->lp_mutex);
 	__fc_linkup(lport);
@@ -591,7 +591,7 @@ void __fc_linkdown(struct fc_lport *lport)
 void fc_linkdown(struct fc_lport *lport)
 {
 	printk(KERN_INFO "host%d: libfc: Link down on port (%6x)\n",
-	       lport->host->host_no, fc_host_port_id(lport->host));
+	       lport->host->host_no, lport->port_id);
 
 	mutex_lock(&lport->lp_mutex);
 	__fc_linkdown(lport);
@@ -693,7 +693,7 @@ void fc_lport_disc_callback(struct fc_lport *lport, enum fc_disc_event event)
 	case DISC_EV_FAILED:
 		printk(KERN_ERR "host%d: libfc: "
 		       "Discovery failed for port (%6x)\n",
-		       lport->host->host_no, fc_host_port_id(lport->host));
+		       lport->host->host_no, lport->port_id);
 		mutex_lock(&lport->lp_mutex);
 		fc_lport_enter_reset(lport);
 		mutex_unlock(&lport->lp_mutex);
@@ -741,7 +741,7 @@ static void fc_lport_set_port_id(struct fc_lport *lport, u32 port_id,
 		printk(KERN_INFO "host%d: Assigned Port ID %6x\n",
 		       lport->host->host_no, port_id);
 
-	fc_host_port_id(lport->host) = port_id;
+	lport->port_id = port_id;
 	if (lport->tt.lport_set_port_id)
 		lport->tt.lport_set_port_id(lport, port_id, fp);
 }
@@ -942,7 +942,7 @@ static void fc_lport_reset_locked(struct fc_lport *lport)
 	lport->tt.exch_mgr_reset(lport, 0, 0);
 	fc_host_fabric_name(lport->host) = 0;
 
-	if (fc_host_port_id(lport->host))
+	if (lport->port_id)
 		fc_lport_set_port_id(lport, 0, NULL);
 }
 
@@ -1687,7 +1687,7 @@ static int fc_lport_els_request(struct fc_bsg_job *job,
 	fh = fc_frame_header_get(fp);
 	fh->fh_r_ctl = FC_RCTL_ELS_REQ;
 	hton24(fh->fh_d_id, did);
-	hton24(fh->fh_s_id, fc_host_port_id(lport->host));
+	hton24(fh->fh_s_id, lport->port_id);
 	fh->fh_type = FC_TYPE_ELS;
 	hton24(fh->fh_f_ctl, FC_FC_FIRST_SEQ |
 	       FC_FC_END_SEQ | FC_FC_SEQ_INIT);
@@ -1747,7 +1747,7 @@ static int fc_lport_ct_request(struct fc_bsg_job *job,
 	fh = fc_frame_header_get(fp);
 	fh->fh_r_ctl = FC_RCTL_DD_UNSOL_CTL;
 	hton24(fh->fh_d_id, did);
-	hton24(fh->fh_s_id, fc_host_port_id(lport->host));
+	hton24(fh->fh_s_id, lport->port_id);
 	fh->fh_type = FC_TYPE_CT;
 	hton24(fh->fh_f_ctl, FC_FC_FIRST_SEQ |
 	       FC_FC_END_SEQ | FC_FC_SEQ_INIT);
drivers/scsi/libfc/fc_npiv.c +2 -2
index c68f6c7..0e90f00 100644
@@ -69,12 +69,12 @@ struct fc_lport *fc_vport_id_lookup(struct fc_lport *n_port, u32 port_id)
 	struct fc_lport *lport = NULL;
 	struct fc_lport *vn_port;
 
-	if (fc_host_port_id(n_port->host) == port_id)
+	if (n_port->port_id == port_id)
 		return n_port;
 
 	mutex_lock(&n_port->lp_mutex);
 	list_for_each_entry(vn_port, &n_port->vports, list) {
-		if (fc_host_port_id(vn_port->host) == port_id) {
+		if (vn_port->port_id == port_id) {
 			lport = vn_port;
 			break;
 		}
include/scsi/fc_encode.h +7 -11
index 8eb0a0f..9b4867c 100644
@@ -74,7 +74,7 @@ static inline void fc_adisc_fill(struct fc_lport *lport, struct fc_frame *fp)
 	adisc->adisc_cmd = ELS_ADISC;
 	put_unaligned_be64(lport->wwpn, &adisc->adisc_wwpn);
 	put_unaligned_be64(lport->wwnn, &adisc->adisc_wwnn);
-	hton24(adisc->adisc_port_id, fc_host_port_id(lport->host));
+	hton24(adisc->adisc_port_id, lport->port_id);
 }
 
 /**
@@ -127,15 +127,13 @@ static inline int fc_ct_fill(struct fc_lport *lport,
 
 	case FC_NS_RFT_ID:
 		ct = fc_ct_hdr_fill(fp, op, sizeof(struct fc_ns_rft));
-		hton24(ct->payload.rft.fid.fp_fid,
-		       fc_host_port_id(lport->host));
+		hton24(ct->payload.rft.fid.fp_fid, lport->port_id);
 		ct->payload.rft.fts = lport->fcts;
 		break;
 
 	case FC_NS_RFF_ID:
 		ct = fc_ct_hdr_fill(fp, op, sizeof(struct fc_ns_rff_id));
-		hton24(ct->payload.rff.fr_fid.fp_fid,
-		       fc_host_port_id(lport->host));
+		hton24(ct->payload.rff.fr_fid.fp_fid, lport->port_id);
 		ct->payload.rff.fr_type = FC_TYPE_FCP;
 		if (lport->service_params & FCP_SPPF_INIT_FCN)
 			ct->payload.rff.fr_feat = FCP_FEAT_INIT;
@@ -145,16 +143,14 @@ 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,
-		       fc_host_port_id(lport->host));
+		hton24(ct->payload.rn.fr_fid.fp_fid, lport->port_id);
 		put_unaligned_be64(lport->wwnn, &ct->payload.rn.fr_wwn);
 		break;
 
 	case FC_NS_RSPN_ID:
 		len = strnlen(fc_host_symbolic_name(lport->host), 255);
 		ct = fc_ct_hdr_fill(fp, op, sizeof(struct fc_ns_rspn) + len);
-		hton24(ct->payload.spn.fr_fid.fp_fid,
-		       fc_host_port_id(lport->host));
+		hton24(ct->payload.spn.fr_fid.fp_fid, lport->port_id);
 		strncpy(ct->payload.spn.fr_name,
 			fc_host_symbolic_name(lport->host), len);
 		ct->payload.spn.fr_name_len = len;
@@ -268,7 +264,7 @@ static inline void fc_logo_fill(struct fc_lport *lport, struct fc_frame *fp)
 	logo = fc_frame_payload_get(fp, sizeof(*logo));
 	memset(logo, 0, sizeof(*logo));
 	logo->fl_cmd = ELS_LOGO;
-	hton24(logo->fl_n_port_id, fc_host_port_id(lport->host));
+	hton24(logo->fl_n_port_id, lport->port_id);
 	logo->fl_n_port_wwn = htonll(lport->wwpn);
 }
 
@@ -295,7 +291,7 @@ static inline void fc_rec_fill(struct fc_lport *lport, struct fc_frame *fp)
 	rec = fc_frame_payload_get(fp, sizeof(*rec));
 	memset(rec, 0, sizeof(*rec));
 	rec->rec_cmd = ELS_REC;
-	hton24(rec->rec_s_id, fc_host_port_id(lport->host));
+	hton24(rec->rec_s_id, lport->port_id);
 	rec->rec_ox_id = htons(ep->oxid);
 	rec->rec_rx_id = htons(ep->rxid);
 }
include/scsi/libfc.h +2 -0
index e31150a..0919409 100644
@@ -848,6 +848,8 @@ struct fc_lport {
 	struct mutex                   lp_mutex;
 	struct list_head               list;
 	struct delayed_work	       retry_work;
+
+	u32                            port_id;
 };
 
 /*
#5 lore raw

RFC PATCH 5/6 fc_sysfs: Rearrange the FC transport to create FC sysfs

In reply to Robert Love

This patch moves code from scsi_transport_fc.[ch] into drivers/scsi/fc/* and include/scsi/fc.h. It creates new sysfs objects to represent various FC entities in the FC/FCoE environment. Currently it only modifies FC objects and attributes, but I would want FCoE attributes added once the layout matures.

---

 drivers/scsi/Kconfig             |    6 
 drivers/scsi/Makefile            |    1 
 drivers/scsi/fc/Makefile         |    8 
 drivers/scsi/fc/fc_sysfs.h       |   35 +
 drivers/scsi/fc/fcfabric.c       |  441 ++++++++++++
 drivers/scsi/fc/fcfport.c        |   73 ++
 drivers/scsi/fc/fcpinit.c        |   66 ++
 drivers/scsi/fc/fcport.c         |  217 ++++++
 drivers/scsi/fc/fcsysfs.c        |   41 +
 drivers/scsi/fc/fcvport.c        |  485 +++++++++++++
 drivers/scsi/scsi_transport_fc.c | 1411 ++++++--------------------------------
 include/scsi/fc.h                |  461 ++++++++++++
 include/scsi/scsi_transport_fc.h |  329 ++-------
 13 files changed, 2140 insertions(+), 1434 deletions(-)
 create mode 100644 drivers/scsi/fc/Makefile
 create mode 100644 drivers/scsi/fc/fc_sysfs.h
 create mode 100644 drivers/scsi/fc/fcfabric.c
 create mode 100644 drivers/scsi/fc/fcfport.c
 create mode 100644 drivers/scsi/fc/fcpinit.c
 create mode 100644 drivers/scsi/fc/fcport.c
 create mode 100644 drivers/scsi/fc/fcsysfs.c
 create mode 100644 drivers/scsi/fc/fcvport.c
 create mode 100644 include/scsi/fc.h
drivers/scsi/Kconfig +6 -0
index 9191d1e..f9130ab 100644
@@ -650,9 +650,15 @@ config VMWARE_PVSCSI
 	  To compile this driver as a module, choose M here: the
 	  module will be called vmw_pvscsi.
 
+config FC_SYSFS
+       tristate "Fibre Channel sysfs representation"
+       ---help---
+	 Expiramental representation of FC objects in sysfs
+
 config LIBFC
 	tristate "LibFC module"
 	select SCSI_FC_ATTRS
+	select FC_SYSFS
 	select CRC32
 	---help---
 	  Fibre Channel library module
drivers/scsi/Makefile +1 -0
index 92a8c50..071b757 100644
@@ -36,6 +36,7 @@ obj-$(CONFIG_SCSI_SAS_LIBSAS)	+= libsas/
 obj-$(CONFIG_SCSI_SRP_ATTRS)	+= scsi_transport_srp.o
 obj-$(CONFIG_SCSI_DH)		+= device_handler/
 
+obj-$(CONFIG_FC_SYSFS)		+= fc/
 obj-$(CONFIG_LIBFC)		+= libfc/
 obj-$(CONFIG_LIBFCOE)		+= fcoe/
 obj-$(CONFIG_FCOE)		+= fcoe/
drivers/scsi/fc/Makefile new file +8 -0
new file mode 100644
index 0000000..c3393b6
@@ -0,0 +1,8 @@
+obj-$(CONFIG_FC_SYSFS) += fc_sysfs.o
+
+fc_sysfs-objs := fcsysfs.o \
+		 fcport.o \
+		 fcfport.o \
+		 fcfabric.o \
+		 fcvport.o \
+		 fcpinit.o
\ No newline at end of file
drivers/scsi/fc/fc_sysfs.h new file +35 -0
new file mode 100644
index 0000000..757d5c1
@@ -0,0 +1,35 @@
+/*
+ * Copyright(c) 2009 Intel Corporation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef _FC_SYSFS_H_
+#define _FC_SYSFS_H_
+
+#include <linux/device.h>
+#include <linux/spinlock.h>
+#include <scsi/fc.h>
+
+extern struct class fc_class;
+
+int fc_class_del_children(struct device *dev, void *data);
+int fc_fcfport_del_children(struct device *dev, void *data);
+int fc_fcfabric_del_children(struct device *dev, void *data);
+int fc_fcvport_del_children(struct device *dev, void *data);
+int fc_fcpinit_del_children(struct device *dev, void *data);
+
+int fc_vport_terminate(struct fc_fcfabric *, struct fc_fcvport *vport);
+
+#endif /*_FC_SYSFS_H_*/
drivers/scsi/fc/fcfabric.c new file +441 -0

441 lines not on this page · raw message

drivers/scsi/fc/fcfport.c new file +73 -0

73 lines not on this page · raw message

drivers/scsi/fc/fcpinit.c new file +66 -0

66 lines not on this page · raw message

drivers/scsi/fc/fcport.c new file +217 -0

217 lines not on this page · raw message

drivers/scsi/fc/fcsysfs.c new file +41 -0

41 lines not on this page · raw message

drivers/scsi/fc/fcvport.c new file +485 -0

485 lines not on this page · raw message

drivers/scsi/scsi_transport_fc.c +234 -1177

1,611 lines not on this page · raw message

include/scsi/fc.h new file +461 -0

461 lines not on this page · raw message

include/scsi/scsi_transport_fc.h +72 -257

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

#6 lore raw

RFC PATCH 6/6 libfc, libfcoe, fcoe: Make use of FC sysfs

In reply to Robert Love

Previously the lport was allocated with the scsi_host, but with FC sysfs the scsi_host is not allocated until the lport is READY. This patch changes libfc such that the lport is allocated with the fcport and not with the scsi_host. FCP information is still allocated with the scsi_host.

libfc, libfcoe and fcoe also needed to create the various FC sysfs object as information was discovered durring login.

---

 drivers/scsi/fcoe/fcoe.c      |  522 ++++++++++++++++++++++++++---------------
 drivers/scsi/fcoe/libfcoe.c   |   43 ++-
 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 |  189 ++++++++-------
 drivers/scsi/libfc/fc_npiv.c  |   52 ++--
 drivers/scsi/libfc/fc_rport.c |   12 +
 include/scsi/fc.h             |    3 
 include/scsi/fc_encode.h      |   30 +-
 include/scsi/libfc.h          |  127 +++++++---
 12 files changed, 697 insertions(+), 445 deletions(-)
drivers/scsi/fcoe/fcoe.c +331 -191
index a719994..7734638 100644
@@ -40,6 +40,7 @@
 #include <scsi/fc/fc_fip.h>
 
 #include <scsi/libfc.h>
+#include <scsi/fc.h>
 #include <scsi/fc_frame.h>
 #include <scsi/libfcoe.h>
 
@@ -116,6 +117,15 @@ static void fcoe_recv_frame(struct sk_buff *skb);
 
 static void fcoe_get_lesb(struct fc_lport *, struct fc_els_lesb *);
 
+static void fcoe_shost_config(struct fc_lport *lport, struct fc_fcp_internal *si);
+static void fcoe_set_symbolic_name(struct fc_lport *);
+static void fcoe_set_node_name(struct fc_lport *);
+static void fcoe_set_port_name(struct fc_lport *);
+static void fcoe_set_max_npiv_vports(struct fc_lport *);
+static void fcoe_get_vport_ids(struct fc_lport *lport,
+			       struct fc_vport_identifiers *ids);
+
+
 module_param_call(create, fcoe_create, NULL, NULL, S_IWUSR);
 __MODULE_PARM_TYPE(create, "string");
 MODULE_PARM_DESC(create, " Creates fcoe instance on a ethernet interface");
@@ -142,10 +152,29 @@ static struct notifier_block fcoe_cpu_notifier = {
 static struct scsi_transport_template *fcoe_transport_template;
 static struct scsi_transport_template *fcoe_vport_transport_template;
 
-static int fcoe_vport_destroy(struct fc_vport *);
-static int fcoe_vport_create(struct fc_vport *, bool disabled);
-static int fcoe_vport_disable(struct fc_vport *, bool disable);
-static void fcoe_set_vport_symbolic_name(struct fc_vport *);
+static int fcoe_vport_destroy(void *, struct fc_fcvport *);
+static int fcoe_vport_create(void *, struct fc_fcvport *, bool disabled);
+static int fcoe_vport_disable(struct fc_fcvport *, bool disable);
+static void fcoe_set_vport_symbolic_name(struct fc_fcvport *);
+
+static struct scsi_host_template fcoe_shost_template = {
+	.module = THIS_MODULE,
+	.name = "FCoE Driver",
+	.proc_name = FCOE_NAME,
+	.queuecommand = fc_queuecommand,
+	.eh_abort_handler = fc_eh_abort,
+	.eh_device_reset_handler = fc_eh_device_reset,
+	.eh_host_reset_handler = fc_eh_host_reset,
+	.slave_alloc = fc_slave_alloc,
+	.change_queue_depth = fc_change_queue_depth,
+	.change_queue_type = fc_change_queue_type,
+	.this_id = -1,
+	.cmd_per_lun = 3,
+	.can_queue = FCOE_MAX_OUTSTANDING_COMMANDS,
+	.use_clustering = ENABLE_CLUSTERING,
+	.sg_tablesize = SG_ALL,
+	.max_sectors = 0xffff,
+};
 
 static struct libfc_function_template fcoe_libfc_fcn_templ = {
 	.frame_send = fcoe_xmit,
@@ -153,102 +182,169 @@ static struct libfc_function_template fcoe_libfc_fcn_templ = {
 	.ddp_done = fcoe_ddp_done,
 	.elsct_send = fcoe_elsct_send,
 	.get_lesb = fcoe_get_lesb,
+	.shost_template = &fcoe_shost_template,
+	.shost_config = fcoe_shost_config,
+	.set_fcvport_symbolic_name = fcoe_set_symbolic_name,
+	.set_fcvport_node_name = fcoe_set_node_name,
+	.set_fcvport_port_name = fcoe_set_port_name,
+	.set_fcfabric_max_npiv_vports = fcoe_set_max_npiv_vports,
+	.get_vport_ids = fcoe_get_vport_ids,
 };
 
 struct fc_function_template fcoe_transport_function = {
-	.show_host_node_name = 1,
-	.show_host_port_name = 1,
-	.show_host_supported_classes = 1,
-	.show_host_supported_fc4s = 1,
-	.show_host_active_fc4s = 1,
-	.show_host_maxframe_size = 1,
-
-	.show_host_port_id = 1,
-	.show_host_supported_speeds = 1,
-	.get_host_speed = fc_get_host_speed,
-	.show_host_speed = 1,
-	.show_host_port_type = 1,
 	.get_host_port_state = fc_get_host_port_state,
 	.show_host_port_state = 1,
-	.show_host_symbolic_name = 1,
 
 	.dd_fcrport_size = sizeof(struct fc_rport_libfc_priv),
 	.show_rport_maxframe_size = 1,
 	.show_rport_supported_classes = 1,
 
-	.show_host_fabric_name = 1,
 	.show_starget_node_name = 1,
 	.show_starget_port_name = 1,
 	.show_starget_port_id = 1,
 	.set_rport_dev_loss_tmo = fc_set_rport_loss_tmo,
 	.show_rport_dev_loss_tmo = 1,
-	.get_fc_host_stats = fc_get_host_stats,
-	.issue_fc_host_lip = fcoe_reset,
+	.get_fcpinit_stats = fc_get_host_stats,
+	.issue_fcpinit_lip = fcoe_reset,
 
 	.terminate_rport_io = fc_rport_terminate_io,
 
-	.vport_create = fcoe_vport_create,
-	.vport_delete = fcoe_vport_destroy,
-	.vport_disable = fcoe_vport_disable,
-	.set_vport_symbolic_name = fcoe_set_vport_symbolic_name,
-
 	.bsg_request = fc_lport_bsg_request,
 };
 
 struct fc_function_template fcoe_vport_transport_function = {
-	.show_host_node_name = 1,
-	.show_host_port_name = 1,
-	.show_host_supported_classes = 1,
-	.show_host_supported_fc4s = 1,
-	.show_host_active_fc4s = 1,
-	.show_host_maxframe_size = 1,
-
-	.show_host_port_id = 1,
-	.show_host_supported_speeds = 1,
-	.get_host_speed = fc_get_host_speed,
-	.show_host_speed = 1,
-	.show_host_port_type = 1,
 	.get_host_port_state = fc_get_host_port_state,
 	.show_host_port_state = 1,
-	.show_host_symbolic_name = 1,
 
 	.dd_fcrport_size = sizeof(struct fc_rport_libfc_priv),
 	.show_rport_maxframe_size = 1,
 	.show_rport_supported_classes = 1,
 
-	.show_host_fabric_name = 1,
 	.show_starget_node_name = 1,
 	.show_starget_port_name = 1,
 	.show_starget_port_id = 1,
 	.set_rport_dev_loss_tmo = fc_set_rport_loss_tmo,
 	.show_rport_dev_loss_tmo = 1,
-	.get_fc_host_stats = fc_get_host_stats,
-	.issue_fc_host_lip = fcoe_reset,
+	.get_fcpinit_stats = fc_get_host_stats,
+	.issue_fcpinit_lip = fcoe_reset,
 
 	.terminate_rport_io = fc_rport_terminate_io,
 
 	.bsg_request = fc_lport_bsg_request,
 };
 
-static struct scsi_host_template fcoe_shost_template = {
-	.module = THIS_MODULE,
-	.name = "FCoE Driver",
-	.proc_name = FCOE_NAME,
-	.queuecommand = fc_queuecommand,
-	.eh_abort_handler = fc_eh_abort,
-	.eh_device_reset_handler = fc_eh_device_reset,
-	.eh_host_reset_handler = fc_eh_host_reset,
-	.slave_alloc = fc_slave_alloc,
-	.change_queue_depth = fc_change_queue_depth,
-	.change_queue_type = fc_change_queue_type,
-	.this_id = -1,
-	.cmd_per_lun = 3,
-	.can_queue = FCOE_MAX_OUTSTANDING_COMMANDS,
-	.use_clustering = ENABLE_CLUSTERING,
-	.sg_tablesize = SG_ALL,
-	.max_sectors = 0xffff,
+struct fcport_function_template fcoe_fcport_fcn_tmpl = {
+	.show_fcport_maxframe_size = 1,
+	.show_fcport_supported_speeds = 1,
+	.show_fcport_supported_classes = 1,
+	.show_fcport_speed = 1,
+	.show_fcport_supported_fc4s = 1,
+	.show_fcport_active_fc4s = 1,
+	.show_fcport_serial_number = 1,
 };
 
+struct fcfabric_function_template fcoe_fcfabric_fcn_tmpl = {
+	.vport_create = fcoe_vport_create,
+	.vport_delete = fcoe_vport_destroy,
+	.vport_disable = fcoe_vport_disable,
+
+	.show_fcfabric_fabric_name = 1,
+};
+
+struct fcvport_function_template fcoe_fcvport_fcn_tmpl = {
+	.show_fcvport_port_id = 1,
+	.show_fcvport_symbolic_name = 1,
+	.show_fcvport_node_name = 1,
+	.show_fcvport_port_name = 1,
+	.show_fcvport_port_type = 1,
+};
+
+static void fcoe_get_vport_ids(struct fc_lport *lport,
+			       struct fc_vport_identifiers *ids)
+{
+	struct fcoe_port *port = lport_priv(lport);
+	struct fcoe_interface *fcoe = port->fcoe;
+	int vid = 0;
+
+	if (fcoe->netdev->priv_flags & IFF_802_1Q_VLAN)
+		vid = vlan_dev_vlan_id(fcoe->netdev);
+
+	ids->node_name = fcoe_wwn_from_mac(fcoe->ctlr.ctl_src_addr, 1, 0);
+	ids->port_name = fcoe_wwn_from_mac(fcoe->ctlr.ctl_src_addr, 2, vid);
+
+	/*
+	 * TODO: This needs to be determined, not hard coded.
+	 */
+	ids->roles = FC_PORT_ROLE_FCP_INITIATOR;
+
+	/*
+	 * TODO: I don't know where these values should come from,
+	 * guess that disable should be 0 and NPIV.
+	 */
+	ids->disable = 0;
+	ids->vport_type = FC_PORTTYPE_NPIV;
+
+	snprintf(ids->symbolic_name, FC_SYMBOLIC_NAME_SIZE,
+		 "%s v%s over %s", FCOE_NAME, FCOE_VERSION,
+		 fcoe_netdev(lport)->name);
+}
+
+static void fcoe_set_max_npiv_vports(struct fc_lport *lport)
+{
+	fcfabric_max_npiv_vports(lport->fcfabric) = USHORT_MAX;
+}
+
+static void fcoe_set_symbolic_name(struct fc_lport *lport)
+{
+	snprintf(lport->fcvport->symbolic_name, FC_SYMBOLIC_NAME_SIZE,
+		 "%s v%s over %s", FCOE_NAME, FCOE_VERSION,
+		 fcoe_netdev(lport)->name);
+}
+
+static void fcoe_set_node_name(struct fc_lport *lport)
+{
+	struct fcoe_port *port = lport_priv(lport);
+	struct fcoe_interface *fcoe = port->fcoe;
+	int vid = 0;
+
+	/*
+	  RWL - removed a if(!lport->vport) check, since this routine shoud
+	  be used for all vports (real or virtual) I think it should be OK 
+	*/
+
+	/*
+	 * Use NAA 1&2 (FC-FS Rev. 2.0, Sec. 15) to generate WWNN/WWPN:
+	 * For WWNN, we use NAA 1 w/ bit 27-16 of word 0 as 0.
+	 * For WWPN, we use NAA 2 w/ bit 27-16 of word 0 from VLAN ID
+	 */
+	if (fcoe->netdev->priv_flags & IFF_802_1Q_VLAN)
+		vid = vlan_dev_vlan_id(fcoe->netdev);
+	fcvport_node_name(lport->fcvport) =
+		fcoe_wwn_from_mac(fcoe->ctlr.ctl_src_addr, 1, 0);
+}
+
+static void fcoe_set_port_name(struct fc_lport *lport)
+{
+	struct fcoe_port *port = lport_priv(lport);
+	struct fcoe_interface *fcoe = port->fcoe;
+	int vid = 0;
+
+	/*
+	  RWL - removed a if(!lport->vport) check, since this routine shoud
+	  be used for all vports (real or virtual) I think it should be OK 
+	*/
+
+	/*
+	 * Use NAA 1&2 (FC-FS Rev. 2.0, Sec. 15) to generate WWNN/WWPN:
+	 * For WWNN, we use NAA 1 w/ bit 27-16 of word 0 as 0.
+	 * For WWPN, we use NAA 2 w/ bit 27-16 of word 0 from VLAN ID
+	 */
+	if (fcoe->netdev->priv_flags & IFF_802_1Q_VLAN)
+		vid = vlan_dev_vlan_id(fcoe->netdev);
+	fcvport_port_name(lport->fcvport) =
+		fcoe_wwn_from_mac(fcoe->ctlr.ctl_src_addr, 2, vid);
+}
+
 /**
  * fcoe_interface_setup() - Setup a FCoE interface
  * @fcoe:   The new FCoE interface
@@ -517,8 +613,10 @@ static u8 *fcoe_get_src_mac(struct fc_lport *lport)
  */
 static int fcoe_lport_config(struct fc_lport *lport)
 {
+	lport->fcfabric_f = &fcoe_fcfabric_fcn_tmpl;
+	lport->fcvport_f = &fcoe_fcvport_fcn_tmpl;
+
 	lport->link_up = 0;
-	lport->qfull = 0;
 	lport->max_retry_count = 3;
 	lport->max_rport_retry_count = 3;
 	lport->e_d_tov = 2 * 1000;	/* FC-FS default */
@@ -582,10 +680,8 @@ static int fcoe_get_wwn(struct net_device *netdev, u64 *wwn, int type)
 static int fcoe_netdev_config(struct fc_lport *lport, struct net_device *netdev)
 {
 	u32 mfs;
-	u64 wwnn, wwpn;
 	struct fcoe_interface *fcoe;
 	struct fcoe_port *port;
-	int vid = 0;
 
 	/* Setup lport private data to point to fcoe softc */
 	port = lport_priv(lport);
@@ -629,25 +725,12 @@ static int fcoe_netdev_config(struct fc_lport *lport, struct net_device *netdev)
 	port->fcoe_pending_queue_active = 0;
 	setup_timer(&port->timer, fcoe_queue_timer, (unsigned long)lport);
 
-	fcoe_link_speed_update(lport);
-
-	if (!lport->vport) {
-		/*
-		 * Use NAA 1&2 (FC-FS Rev. 2.0, Sec. 15) to generate WWNN/WWPN:
-		 * For WWNN, we use NAA 1 w/ bit 27-16 of word 0 as 0.
-		 * For WWPN, we use NAA 2 w/ bit 27-16 of word 0 from VLAN ID
-		 */
-		if (netdev->priv_flags & IFF_802_1Q_VLAN)
-			vid = vlan_dev_vlan_id(netdev);
-
-		if (fcoe_get_wwn(netdev, &wwnn, NETDEV_FCOE_WWNN))
-			wwnn = fcoe_wwn_from_mac(fcoe->ctlr.ctl_src_addr, 1, 0);
-		fc_set_wwnn(lport, wwnn);
-		if (fcoe_get_wwn(netdev, &wwpn, NETDEV_FCOE_WWPN))
-			wwpn = fcoe_wwn_from_mac(fcoe->ctlr.ctl_src_addr,
-						 2, vid);
-		fc_set_wwpn(lport, wwpn);
-	}
+	/*
+	 * TODO: This is a bad to have a special case for the N_Port
+	 * lport.
+	 */
+	if (lport->fcport)
+		fcoe_link_speed_update(lport);
 
 	return 0;
 }
@@ -656,42 +739,25 @@ static int fcoe_netdev_config(struct fc_lport *lport, struct net_device *netdev)
  * fcoe_shost_config() - Set up the SCSI host associated with a local port
  * @lport: The local port
  * @shost: The SCSI host to associate with the local port
- * @dev:   The device associated with the SCSI host
  *
  * Must be called after fcoe_lport_config() and fcoe_netdev_config()
  *
  * Returns: 0 for success
  */
-static int fcoe_shost_config(struct fc_lport *lport, struct Scsi_Host *shost,
-			     struct device *dev)
+static void fcoe_shost_config(struct fc_lport *lport, struct fc_fcp_internal *si)
 {
-	int rc = 0;
-
 	/* lport scsi host config */
-	lport->host->max_lun = FCOE_MAX_LUN;
-	lport->host->max_id = FCOE_MAX_FCP_TARGET;
-	lport->host->max_channel = 0;
-	if (lport->vport)
-		lport->host->transportt = fcoe_vport_transport_template;
-	else
-		lport->host->transportt = fcoe_transport_template;
+	si->host->max_lun = FCOE_MAX_LUN;
+	si->host->max_id = FCOE_MAX_FCP_TARGET;
+	si->host->max_channel = 0;
 
-	/* add the new host to the SCSI-ml */
-	rc = scsi_add_host(lport->host, dev);
-	if (rc) {
-		FCOE_NETDEV_DBG(fcoe_netdev(lport), "fcoe_shost_config: "
-				"error on scsi_add_host\n");
-		return rc;
-	}
+	/* RWL - Should this directly change the scsi_host? what is this val used for */
+	si->qfull = 0;
 
-	if (!lport->vport)
-		fc_host_max_npiv_vports(lport->host) = USHORT_MAX;
-
-	snprintf(fc_host_symbolic_name(lport->host), FC_SYMBOLIC_NAME_SIZE,
-		 "%s v%s over %s", FCOE_NAME, FCOE_VERSION,
-		 fcoe_netdev(lport)->name);
-
-	return 0;
+	if (!fc_fcvport_is_nport(&lport->fcvport->gendev, NULL))
+		si->host->transportt = fcoe_vport_transport_template;
+	else
+		si->host->transportt = fcoe_transport_template;
 }
 
 /**
@@ -812,8 +878,15 @@ static void fcoe_if_destroy(struct fc_lport *lport)
 
 	/* Cleanup the fc_lport */
 	fc_lport_destroy(lport);
+
+	/*
+	 * TODO: It cannot be assumed that FCP was initiatlized.
+	 */
 	fc_fcp_destroy(lport);
 
+	if (!lport->fcpinit)
+		printk(KERN_ERR "RWL: fcoe_if_destroy - NO fcpinit\n");
+
 	/* Stop the transmit retry timer */
 	del_timer_sync(&port->timer);
 
@@ -831,18 +904,17 @@ static void fcoe_if_destroy(struct fc_lport *lport)
 	/* Free queued packets for the per-CPU receive threads */
 	fcoe_percpu_clean(lport);
 
-	/* Detach from the scsi-ml */
-	fc_remove_host(lport->host);
-	scsi_remove_host(lport->host);
-
 	/* There are no more rports or I/O, free the EM */
 	fc_exch_mgr_free(lport);
 
 	/* Free memory used by statistical counters */
 	fc_lport_free_stats(lport);
 
-	/* Release the Scsi_Host */
-	scsi_host_put(lport->host);
+	/*
+	 * TODO: Where does the fcport get freed?
+	 */
+
+	fc_lport_free(lport);
 }
 
 /**
@@ -883,6 +955,25 @@ static int fcoe_ddp_done(struct fc_lport *lport, u16 xid)
 	return 0;
 }
 
+static struct fc_lport *fcoe_lport_create(struct fcoe_interface *fcoe)
+{
+	struct fc_lport *lport;
+	struct fcoe_port *port;
+
+	lport = fc_lport_alloc(sizeof(struct fcoe_port));
+	if (!lport)
+		return NULL;
+
+	port = lport_priv(lport);
+
+	port->lport = lport;
+	port->fcoe = fcoe;
+	INIT_WORK(&port->destroy_work, fcoe_destroy_work);
+
+	return lport;
+}
+
+
 /**
  * fcoe_if_create() - Create a FCoE instance on an interface
  * @fcoe:   The FCoE interface to create a local port on
@@ -893,53 +984,24 @@ static int fcoe_ddp_done(struct fc_lport *lport, u16 xid)
  *
  * Returns: The allocated fc_lport or an error pointer
  */
-static struct fc_lport *fcoe_if_create(struct fcoe_interface *fcoe,
-				       struct device *parent, int npiv)
+static int fcoe_if_create(struct fc_lport *lport, struct fcoe_interface *fcoe,
+			  struct device *parent, int npiv)
 {
 	struct net_device *netdev = fcoe->netdev;
-	struct fc_lport *lport = NULL;
-	struct fcoe_port *port;
-	struct Scsi_Host *shost;
-	int rc;
+	int rc = 0;
 	/*
 	 * parent is only a vport if npiv is 1,
 	 * but we'll only use vport in that case so go ahead and set it
 	 */
-	struct fc_vport *vport = dev_to_vport(parent);
 
 	FCOE_NETDEV_DBG(netdev, "Create Interface\n");
 
-	if (!npiv) {
-		lport = libfc_host_alloc(&fcoe_shost_template,
-					 sizeof(struct fcoe_port));
-	} else	{
-		lport = libfc_vport_create(vport,
-					   sizeof(struct fcoe_port));
-	}
-	if (!lport) {
-		FCOE_NETDEV_DBG(netdev, "Could not allocate host structure\n");
-		rc = -ENOMEM;
-		goto out;
-	}
-	shost = lport->host;
-	port = lport_priv(lport);
-	port->lport = lport;
-	port->fcoe = fcoe;
-	INIT_WORK(&port->destroy_work, fcoe_destroy_work);
-
 	/* configure a fc_lport including the exchange manager */
 	rc = fcoe_lport_config(lport);
 	if (rc) {
 		FCOE_NETDEV_DBG(netdev, "Could not configure lport for the "
 				"interface\n");
-		goto out_host_put;
-	}
-
-	if (npiv) {
-		FCOE_NETDEV_DBG(netdev, "Setting vport names, 0x%llX 0x%llX\n",
-				vport->node_name, vport->port_name);
-		fc_set_wwnn(lport, vport->node_name);
-		fc_set_wwpn(lport, vport->port_name);
+		goto out;
 	}
 
 	/* configure lport network properties */
@@ -950,14 +1012,6 @@ static struct fc_lport *fcoe_if_create(struct fcoe_interface *fcoe,
 		goto out_lp_destroy;
 	}
 
-	/* configure lport scsi host properties */
-	rc = fcoe_shost_config(lport, shost, parent);
-	if (rc) {
-		FCOE_NETDEV_DBG(netdev, "Could not configure shost for the "
-				"interface\n");
-		goto out_lp_destroy;
-	}
-
 	/* Initialize the library */
 	rc = fcoe_libfc_config(lport, &fcoe_libfc_fcn_templ);
 	if (rc) {
@@ -987,14 +1041,13 @@ static struct fc_lport *fcoe_if_create(struct fcoe_interface *fcoe,
 	}
 
 	fcoe_interface_get(fcoe);
-	return lport;
+
+	return rc;
 
 out_lp_destroy:
 	fc_exch_mgr_free(lport);
-out_host_put:
-	scsi_host_put(lport->host);
 out:
-	return ERR_PTR(rc);
+	return rc;
 }
 
 /**
@@ -1717,6 +1770,7 @@ int fcoe_percpu_receive_thread(void *arg)
 static void fcoe_check_wait_queue(struct fc_lport *lport, struct sk_buff *skb)
 {
 	struct fcoe_port *port = lport_priv(lport);
+	struct fc_fcp_internal *si = fc_get_scsi_internal(lport);
 	int rc;
 
 	spin_lock_bh(&port->fcoe_pending_queue.lock);
@@ -1748,13 +1802,13 @@ static void fcoe_check_wait_queue(struct fc_lport *lport, struct sk_buff *skb)
 	}
 
 	if (port->fcoe_pending_queue.qlen < FCOE_LOW_QUEUE_DEPTH)
-		lport->qfull = 0;
+		si->qfull = 0;
 	if (port->fcoe_pending_queue.qlen && !timer_pending(&port->timer))
 		mod_timer(&port->timer, jiffies + 2);
 	port->fcoe_pending_queue_active = 0;
 out:
 	if (port->fcoe_pending_queue.qlen > FCOE_MAX_QUEUE_DEPTH)
-		lport->qfull = 1;
+		si->qfull = 1;
 	spin_unlock_bh(&port->fcoe_pending_queue.lock);
 	return;
 }
@@ -1838,7 +1892,13 @@ static int fcoe_device_notification(struct notifier_block *notifier,
 				"from netdev netlink\n", event);
 	}
 
-	fcoe_link_speed_update(lport);
+	/*
+	 * TODO: This is bad to have a special case for
+	 * the N_Port since it's the only vport/lport with
+	 * a fcport.
+	 */
+	if (lport->fcport)
+		fcoe_link_speed_update(lport);
 
 	if (link_possible && !fcoe_link_ok(lport))
 		fcoe_ctlr_link_up(&fcoe->ctlr);
@@ -2015,6 +2075,7 @@ static int fcoe_destroy(const char *buffer, struct kernel_param *kp)
 	fcoe_interface_cleanup(fcoe);
 	rtnl_unlock();
 	fcoe_if_destroy(fcoe->ctlr.lp);
+
 out_putdev:
 	dev_put(netdev);
 out_nodev:
@@ -2047,7 +2108,12 @@ static void fcoe_destroy_work(struct work_struct *work)
  */
 static int fcoe_create(const char *buffer, struct kernel_param *kp)
 {
-	int rc;
+	/*
+	 * TODO: rc and error can probably be consolidated.
+	 */
+	int rc = 0;
+	int error = 0;
+	struct fc_vport_identifiers ids;
 	struct fcoe_interface *fcoe;
 	struct fc_lport *lport;
 	struct net_device *netdev;
@@ -2084,8 +2150,31 @@ static int fcoe_create(const char *buffer, struct kernel_param *kp)
 		goto out_putdev;
 	}
 
-	lport = fcoe_if_create(fcoe, &netdev->dev, 0);
-	if (IS_ERR(lport)) {
+	/*
+	 * TODO: Check error conditions here and from the return of fc_fcport_add
+	 */
+	lport = fcoe_lport_create(fcoe);
+	if (!lport) {
+		FCOE_NETDEV_DBG(netdev, "Could not allocate host structure\n");
+		rc = -ENOMEM;
+		/*
+		 * TODO: This is probably very incorrect.
+		 */
+		goto out;
+	}
+
+	lport->fcport = fc_fcport_add((struct device *)&netdev->dev.parent, &fcoe_fcport_fcn_tmpl);
+	if (!lport->fcport) {
+		printk(KERN_ERR "Failed to add a fcport\n");
+		goto out_free;
+	}
+
+	fc_lport_port_config(lport->fcport);
+
+	lport->fcport->maxframe_size = lport->mfs;
+
+	error = fcoe_if_create(lport, fcoe, &netdev->dev, 0);
+	if (error) {
 		printk(KERN_ERR "fcoe: Failed to create interface (%s)\n",
 		       netdev->name);
 		rc = -EIO;
@@ -2096,6 +2185,24 @@ static int fcoe_create(const char *buffer, struct kernel_param *kp)
 	/* Make this the "master" N_Port */
 	fcoe->ctlr.lp = lport;
 
+	/* replace individual set_*() routines below with a
+	 * get_vport_identifiers routine, or don't require ids
+	 * in fcvport_alloc().
+	 */
+	fcoe_get_vport_ids(lport, &ids);
+	lport->fcvport = fc_fcvport_alloc(NULL, &ids, lport->fcvport_f, 0);
+	lport->fcvport->priv_data = lport;
+	fcvport_port_type(lport->fcvport) = FC_PORTTYPE_NPORT;
+
+	if (!lport->fcvport) {
+		/*
+		 * RWL - TODO: remove the fcfabric. I don't think that it will
+		 * come to that though. I think the fabric_add will move instead.
+		 * Let's not worry about it now.
+		 */
+		return rc;
+	}
+
 	/* add to lports list */
 	fcoe_hostlist_add(lport);
 
@@ -2117,6 +2224,7 @@ out_putdev:
 out_nodev:
 	rtnl_unlock();
 	mutex_unlock(&fcoe_config_mutex);
+out:
 	return rc;
 }
 
@@ -2134,19 +2242,21 @@ int fcoe_link_speed_update(struct fc_lport *lport)
 	struct net_device *netdev = port->fcoe->netdev;
 	struct ethtool_cmd ecmd = { ETHTOOL_GSET };
 
+	u32 link_supported_speeds = FC_PORTSPEED_UNKNOWN;
+
 	if (!dev_ethtool_get_settings(netdev, &ecmd)) {
-		lport->link_supported_speeds &=
-			~(FC_PORTSPEED_1GBIT | FC_PORTSPEED_10GBIT);
 		if (ecmd.supported & (SUPPORTED_1000baseT_Half |
 				      SUPPORTED_1000baseT_Full))
-			lport->link_supported_speeds |= FC_PORTSPEED_1GBIT;
+			link_supported_speeds |= FC_PORTSPEED_1GBIT;
 		if (ecmd.supported & SUPPORTED_10000baseT_Full)
-			lport->link_supported_speeds |=
-				FC_PORTSPEED_10GBIT;
+			link_supported_speeds |= FC_PORTSPEED_10GBIT;
+
+		fcport_supported_speeds(lport->fcport) = link_supported_speeds;
+
 		if (ecmd.speed == SPEED_1000)
-			lport->link_speed = FC_PORTSPEED_1GBIT;
+			fcport_speed(lport->fcport) = FC_PORTSPEED_1GBIT;
 		if (ecmd.speed == SPEED_10000)
-			lport->link_speed = FC_PORTSPEED_10GBIT;
+			fcport_speed(lport->fcport) = FC_PORTSPEED_10GBIT;
 
 		return 0;
 	}
@@ -2252,7 +2362,8 @@ void fcoe_clean_pending_queue(struct fc_lport *lport)
  */
 int fcoe_reset(struct Scsi_Host *shost)
 {
-	struct fc_lport *lport = shost_priv(shost);
+	struct fc_fcp_internal *si = shost_priv(shost);
+	struct fc_lport *lport = si->lport;
 	fc_lport_reset(lport);
 	return 0;
 }
@@ -2501,24 +2612,53 @@ static struct fc_seq *fcoe_elsct_send(struct fc_lport *lport, u32 did,
  *
  * Returns: 0 for success
  */
-static int fcoe_vport_create(struct fc_vport *vport, bool disabled)
+static int fcoe_vport_create(void *data, struct fc_fcvport *vport, bool disabled)
 {
-	struct Scsi_Host *shost = vport_to_shost(vport);
-	struct fc_lport *n_port = shost_priv(shost);
-	struct fcoe_port *port = lport_priv(n_port);
-	struct fcoe_interface *fcoe = port->fcoe;
-	struct net_device *netdev = fcoe->netdev;
+	struct fc_lport *lport;
+	struct fcoe_port *port;
+	struct fcoe_interface *fcoe;
+	struct net_device *netdev;
 	struct fc_lport *vn_port;
+	int error = 0;
+
+	lport = (struct fc_lport *)data;
+
+	port = lport_priv(lport);
+	fcoe = port->fcoe;
+	netdev = fcoe->netdev;
+
+	vn_port = fcoe_lport_create(fcoe);
+	if (!vn_port) {
+		FCOE_NETDEV_DBG(netdev, "Could not allocate host structure\n");
+		return -ENOMEM;
+	}	
 
 	mutex_lock(&fcoe_config_mutex);
-	vn_port = fcoe_if_create(fcoe, &vport->dev, 1);
+	error = fcoe_if_create(vn_port, fcoe, &vport->gendev, 1);
 	mutex_unlock(&fcoe_config_mutex);
 
-	if (IS_ERR(vn_port)) {
-		printk(KERN_ERR "fcoe: fcoe_vport_create(%s) failed\n",
-		       netdev->name);
+	/*
+	 * TODO: Need to free the vn_port (lport) in this case.
+	 */
+	if (error)
+		return error;
+
+	/*
+	 * TODO: Check the failure case here.
+	 */
+	error = libfc_vport_config(lport, vn_port, vport);
+	if (error)
 		return -EIO;
-	}
+
+	if (IS_ERR(vn_port))
+		return -EIO;
+
+	/*
+	 * TODO: This routine is not currently setting a unique
+	 * name for the vports.
+	 */
+	fcoe_set_symbolic_name(lport);
+
 
 	if (disabled) {
 		fc_vport_set_state(vport, FC_VPORT_DISABLED);
@@ -2527,6 +2667,7 @@ static int fcoe_vport_create(struct fc_vport *vport, bool disabled)
 		fc_fabric_login(vn_port);
 		fc_vport_setlink(vn_port);
 	}
+
 	return 0;
 }
 
@@ -2536,10 +2677,9 @@ static int fcoe_vport_create(struct fc_vport *vport, bool disabled)
  *
  * Returns: 0 for success
  */
-static int fcoe_vport_destroy(struct fc_vport *vport)
+static int fcoe_vport_destroy(void *data, struct fc_fcvport *vport)
 {
-	struct Scsi_Host *shost = vport_to_shost(vport);
-	struct fc_lport *n_port = shost_priv(shost);
+	struct fc_lport *n_port = data;
 	struct fc_lport *vn_port = vport->dd_data;
 	struct fcoe_port *port = lport_priv(vn_port);
 
@@ -2555,7 +2695,7 @@ static int fcoe_vport_destroy(struct fc_vport *vport)
  * @vport: vport to bring online/offline
  * @disable: should the vport be disabled?
  */
-static int fcoe_vport_disable(struct fc_vport *vport, bool disable)
+static int fcoe_vport_disable(struct fc_fcvport *vport, bool disable)
 {
 	struct fc_lport *lport = vport->dd_data;
 
@@ -2579,20 +2719,20 @@ static int fcoe_vport_disable(struct fc_vport *vport, bool disable)
  * sent to the name server.  There is no response handler, so if it fails
  * for some reason it will not be retried.
  */
-static void fcoe_set_vport_symbolic_name(struct fc_vport *vport)
+static void fcoe_set_vport_symbolic_name(struct fc_fcvport *vport)
 {
 	struct fc_lport *lport = vport->dd_data;
 	struct fc_frame *fp;
 	size_t len;
-
-	snprintf(fc_host_symbolic_name(lport->host), FC_SYMBOLIC_NAME_SIZE,
+	
+	snprintf(fcvport_symbolic_name(lport->fcvport), FC_SYMBOLIC_NAME_SIZE,
 		 "%s v%s over %s : %s", FCOE_NAME, FCOE_VERSION,
 		 fcoe_netdev(lport)->name, vport->symbolic_name);
 
 	if (lport->state != LPORT_ST_READY)
 		return;
 
-	len = strnlen(fc_host_symbolic_name(lport->host), 255);
+	len = strnlen(fcvport_symbolic_name(lport->fcvport), 255);
 	fp = fc_frame_alloc(lport,
 			    sizeof(struct fc_ct_hdr) +
 			    sizeof(struct fc_ns_rspn) + len);
drivers/scsi/fcoe/libfcoe.c +28 -15

141 lines not on this page · raw message

drivers/scsi/libfc/fc_disc.c +3 -1
index dd703fd..dd0344d 100644
@@ -387,6 +387,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;
@@ -396,6 +397,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++;
 
 	/*
@@ -440,7 +442,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 425f4dd..3cffbb3 100644
@@ -1922,11 +1922,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 +76 -54

303 lines not on this page · raw message

drivers/scsi/libfc/fc_libfc.h +14 -14
index a79c42d..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 %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 %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: %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 +107 -82

370 lines not on this page · raw message

drivers/scsi/libfc/fc_npiv.c +29 -23

83 lines not on this page · raw message

drivers/scsi/libfc/fc_rport.c +7 -5
index 97923bb..29b9683 100644
@@ -246,6 +246,7 @@ static void fc_rport_work(struct work_struct *work)
 	struct fc_rport_identifiers ids;
 	struct fc_rport *rport;
 	int restart = 0;
+	struct fc_fcp_internal *si = fc_get_scsi_internal(lport);
 
 	mutex_lock(&rdata->rp_mutex);
 	event = rdata->event;
@@ -262,7 +263,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_remote_port_add(si->host, 0, &ids);
 		if (!rport) {
 			FC_RPORT_DBG(rdata, "Failed to add the rport\n");
 			lport->tt.rport_logoff(rdata);
@@ -1112,13 +1113,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",
@@ -1146,8 +1148,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_host_stats(si->host);
+		hst = &si->host_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);
@@ -1359,7 +1361,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.h +1 -2
index 7ca20fb..27e7f03 100644
@@ -381,8 +381,7 @@ struct fc_fcfport *fc_fcfport_lookup(struct fc_fcport *fcport, const u64 name);
 struct fc_fcvport *fc_fcvport_lookup(struct fc_fcfabric *fcfabric, const u32 id);
 
 struct fc_fcport *fc_fcport_add(struct device *pdev, 
-				struct fcport_function_template *,
-				int priv_size);
+				struct fcport_function_template *);
 struct fc_fcfport *fc_fcfport_add(struct fc_fcport *fcport, const u64 name);
 struct fc_fcfabric *fc_fcfabric_add(struct fc_fcfport *fcfport,
 				    struct fcfabric_function_template *);
include/scsi/fc_encode.h +15 -15
index 9b4867c..d8e8904 100644
@@ -72,8 +72,8 @@ 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 +144,24 @@ 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 +186,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 +218,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 +243,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 +265,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 +84 -43

220 lines not on this page · raw message

maintainer
#7 lore raw
In reply to Robert Love
Quoted 36 lines · Robert Love

This series is the beginning of a FC sysfs reorganization. The new layout as suggested in this post, http://marc.info/?l=linux-scsi&m=124404278711785&w=2,
creates more sysfs objects to expose FC session information and decouples the FC sysfs layout from SCSI until FC attaches to the SCSI mid-layer.

The first four patches in this series are just preparation patches that have not been merged. They can mostly be ignored. The fifth patch introduces FC sysfs and the last patch modifies libfc, libfcoe and fcoe to use the new FC sysfs interface.

These patches move code out of scsi_transport_fc.[ch] and into individual files for each of the new sysfs objects. Compilation creates a new fc_sysfs.ko module. I'm not sure if this is a good overall approach, but I wanted to make sure that I didn't overlook any relationships as I made changes. This results in a patch that doesn't show a good progression of changes, rather a big change combined with code moving from file(s) to other file(s). This can be addressed when the patch series is further along in development.

To review, it might be easier to apply the patches and look at drivers/scsi/fc/ and include/scsi/fc.h.

Functionally both real and NPIV port creation and deletion is working under libfc/fcoe, with most if not all attributes showing correct values. I did not spend much time on error handling or cleanliness, these are things that I'd prefer to address once I'm further along.

These patches create the following sysfs layout-

Device tree:
/sys/devices/virtual/net/eth3.101/fcport1/fcfport_2001000deca31e81/fcfabric_0/fcvport_0/host6/fcpinit/host6/

LDM tree:
/sys/class/fcport/fcport1/fcfport_2001000deca31e81/fcfabric_0/fcvport_0/host6/fcpinit/host6/

Quoted 7 lines

Each object has redistributed attributes:
#ls /sys/devices/virtual/net/eth3.101/fcport1/
active_fc4s device fcfport_2001000deca31e81 maxframe_size power serial_number speed subsystem supported_classes supported_fc4s supported_speeds uevent

# ls /sys/devices/virtual/net/eth3.101/fcport1/fcfport_2001000deca31e81/
fcfabric_0  power  uevent

Please don't.
Do _not_ use physical names in the path names; rather the logical names should be used. So something like
/sys/devices/virtual/net/eth3.101/fcport1/fcfport-1:0/

would be preferred.

Quoted 3 lines
# ls /sys/devices/virtual/net/eth3.101/fcport1/fcfport_2001000deca31e81/fcfabric_0/
fabric_name  fcvport_0  fcvport_1  max_npiv_vports  npiv_vports_inuse  power  uevent  vport_create  vport_delete

Consistent numbering. Either use '_' as a separator always or for none. This mix-up doesn't make sense.

And, why doesn't the fcfport doesn't show up under the fabric? One would assume that the fcfport is part of the fabric, too.

And what about the remote ports? Do they not participate in the fabric?

If the 'fcfabric' element is _not_ the actual fabric I would get rid of it altogether as it'll only serve to confuse the users. Like just has been happened with me :-)

Quoted 6 lines
# ls /sys/devices/virtual/net/eth3.101/fcport1/fcfport_2001000deca31e81/fcfabric_0/fcvport_0/
host6  node_name  port_id  port_name  port_type  power  roles  symbolic_name  uevent  vport_last_state  vport_state  vport_type
# ls /sys/devices/virtual/net/eth3.101/fcport1/fcfport_2001000deca31e81/fcfabric_0/fcvport_0/host6/
bsg  fcpinit  power  rport-6:0-0  rport-6:0-2  scsi_host  subsystem  uevent

See above. Why are the remote ports grouped under the 'host', and not under the fabric?

Quoted 3 lines
# ls /sys/devices/virtual/net/eth3.101/fcport1/fcfport_2001000deca31e81/fcfabric_0/fcvport_0/host6/fcpinit/
host6

fcpinit? What's this for?

Quoted 13 lines
# ls /sys/devices/virtual/net/eth3.101/fcport1/fcfport_2001000deca31e81/fcfabric_0/fcvport_0/host6/fcpinit/host6/
device  issue_lip  port_state  power  statistics  subsystem  tgtid_bind_type  uevent

VN_Ports ports show up just like N_Ports: (notice fcvport_1, not fcvport_0)

# ls /sys/devices/virtual/net/eth3.101/fcport1/fcfport_2001000deca31e81/fcfabric_0/fcvport_1/
host7  node_name  port_id  port_name  port_type  power  roles  symbolic_name  uevent  vport_last_state  vport_state  vport_type

My open questions are:

1) How is the FC4 choice made?

Quoted 8 lines

If FC sysfs allows an FC HBA to support other FC4 types, then how and when is the selection made? It seems that this decision would either need to be hard-coded or provided by the user. fcoe.ko requires user action to start a connection. It would be easy for us to also require a FC4 selection (maybe it defaults to SCSI-FCP (init)). HW adapters generally FLOGI on link up and do not require user interaction. How would this decision be made?

I would consider FCP only currently. Other types would be handled by different subsystems anyway (ie net), which again have a totally different sysfs layout.

Quoted 8 lines

2) How do I reorder fc_host and scsi_host?

Previously the fc_host is attached as a child of the scsi_host. The new layout has the scsi_host as a child of fcpinit. These patches have the fcpinit object created by the scsi transport and attribute container code. I'm not sure if/how to re-order these objects, it might require changes to the scsi transport and AC code.

Easiest would be to use the same counter, so that a fc_host preallocates a scsi_host id, too. Not sure if that's possible, though. Alternatively you could create a scsi_host, but _not_ register it with sysfs. This way you would have a number preallocated, too. And when restricting this layout to FCP we will allocate a scsi_host anyway...

Quoted 7 lines

3) What do I do about remote_ports?

Currently the remote_ports are created by the scsi transport and AC code which places them as children of the fc_host. I believe this problem is essentially the same as #2, but with remote ports instead of the fc_host.

We should try to avoid separate directories for objects which ultimatively map onto the same device. IE it should be possible to gather _all_ information from walking up the devpath only, without having to recurse on other side directories.
This way we can match on the various attributes from udev rules; with separate directories this is impossible without a helper script.

I'm happy to mail my 'path_id' script around, just to get you an idea where you end up with the separate directory approach :-)

Quoted 10 lines

4) What should the FC sysfs objects be?

Should they be class objects? I just made them of type 'struct device' to keep them as flexible as possible. I made the fcport a class object so that it could be anchored at /sys/class/.

(last minute note: I just saw in the link referenced above, that the
objects were referred to as classes. I missed that initiatlly, is there no concern about adding too many classes to /sys?)

The 'class' and 'device' distinction is basically gone with the newer sysfs code.
The elements in 'class' are just pointers into the 'device' structure.

Quoted 6 lines

5) How should the FC sysfs objects be named?

Currently I have two styles. The fcport, fcfabric and fcvport objects are all enumerated. The fcfport is given a name from its WWPN/WWNN. It's pretty ugly as is, and the naming needs more consideration.

As mentioned above, yes, it is. Please use logical names.

Quoted 12 lines

I don't really like N_Ports being referred to as vports in sysfs either.

6) What about complicated relationships between objects?

Right now this layout cannot elegantly support multiple physical ports connected to the same F_Port. Each port will have it's own sysfs directory tree and the two trees will not converge even if they share the same F_Port/fabric/etc... vports under a physical port will show up under the physical port's sysfs directory tree.

7) Should vport_create/destroy be under fcfabric or fcport?

Quoted 11 lines

I've currently put the vport_create/destroy attributes under the fcfabric. I think this is fine for now, since there are no complicated object relationships being presented. There's a one to one relationship between a fcport and a fcfabric so it's fairly easy to go back to the fcport, which is needed to be passed to the LLD so it can create a vport. If there were more than one fcport per fcfabric it would complicate this. Should the vport_create/destroy be moved to be attributes of the fcport instead to avoid a potential lookup if things get more complicated in the future?

Once the fcfabric is consolidated with fcfport they'll end up under fcport anyway :-)

Quoted 8 lines

8) Should the fcfport and fcfabric be consolidated?

The fcfport doesn't show much other than its name. The fcfabric doesn't have many attributes either. Most of its attributes are vport related. I could see adding some FIP information to the fcfport, but I'm not sure we need two objects here, especially if the vport attributes need to be moved to the fcport.

See above. Yes.

Quoted 10 lines

9) Is this change worth all of the changes that will need to happen?

This is probably the most difficult question. I view this change as positive overall, but it's very heavy lifting. Not only does the FC transport need an overhaul, but it looks like the scsi transport and AC code might need some additions. Every HBA will need to be modified and every HBA's HBAAPI vendor library will need to change too. (I hope this would be a catalyst to move to an OS library that everyone shares)

Quoted 3 lines

I'd like to hear other opinions about this because this really is going to be something that all HBAs will need to be involved in.

I think it's quite a valid goal.

Cheers,

Hannes

Signature · 8 lines
Dr. Hannes Reinecke		      zSeries & Storage
[email protected]			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Markus Rex, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#8 lore raw
Quoted 45 lines · Hannes Reinecke
Quoted 36 lines · Robert Love

This series is the beginning of a FC sysfs reorganization. The new layout as suggested in this post, http://marc.info/?l=linux-scsi&m=124404278711785&w=2,
creates more sysfs objects to expose FC session information and decouples the FC sysfs layout from SCSI until FC attaches to the SCSI mid-layer.

The first four patches in this series are just preparation patches that have not been merged. They can mostly be ignored. The fifth patch introduces FC sysfs and the last patch modifies libfc, libfcoe and fcoe to use the new FC sysfs interface.

These patches move code out of scsi_transport_fc.[ch] and into individual files for each of the new sysfs objects. Compilation creates a new fc_sysfs.ko module. I'm not sure if this is a good overall approach, but I wanted to make sure that I didn't overlook any relationships as I made changes. This results in a patch that doesn't show a good progression of changes, rather a big change combined with code moving from file(s) to other file(s). This can be addressed when the patch series is further along in development.

To review, it might be easier to apply the patches and look at drivers/scsi/fc/ and include/scsi/fc.h.

Functionally both real and NPIV port creation and deletion is working under libfc/fcoe, with most if not all attributes showing correct values. I did not spend much time on error handling or cleanliness, these are things that I'd prefer to address once I'm further along.

These patches create the following sysfs layout-

Device tree:
/sys/devices/virtual/net/eth3.101/fcport1/fcfport_2001000deca31e81/fcfabric_0/fcvport_0/host6/fcpinit/host6/

LDM tree:
/sys/class/fcport/fcport1/fcfport_2001000deca31e81/fcfabric_0/fcvport_0/host6/fcpinit/host6/

Quoted 7 lines

Each object has redistributed attributes:
#ls /sys/devices/virtual/net/eth3.101/fcport1/
active_fc4s device fcfport_2001000deca31e81 maxframe_size power serial_number speed subsystem supported_classes supported_fc4s supported_speeds uevent

# ls /sys/devices/virtual/net/eth3.101/fcport1/fcfport_2001000deca31e81/
fcfabric_0  power  uevent
Quoted 7 lines

Please don't.
Do _not_ use physical names in the path names; rather the logical names should be used. So something like
/sys/devices/virtual/net/eth3.101/fcport1/fcfport-1:0/

would be preferred.

Did you put "1:0" to indicate that it's the 0th fcfport on the 1st fcport? Isn't the the relationship of the fcfport0 being a child of the fcport1 enough?

It seems to be redundant to me, but I might be missing something.

Quoted 6 lines
Quoted 3 lines
# ls /sys/devices/virtual/net/eth3.101/fcport1/fcfport_2001000deca31e81/fcfabric_0/
fabric_name  fcvport_0  fcvport_1  max_npiv_vports  npiv_vports_inuse  power  uevent  vport_create  vport_delete

Consistent numbering. Either use '_' as a separator always or for none. This mix-up doesn't make sense.

Quoted 8 lines

And, why doesn't the fcfport doesn't show up under the fabric? One would assume that the fcfport is part of the fabric, too.

And what about the remote ports? Do they not participate in the fabric?

If the 'fcfabric' element is _not_ the actual fabric I would get rid of it altogether as it'll only serve to confuse the users. Like just has been happened with me :-)

Yeah, they should be under the fcfabric. This work is just incomplete in that area.

Quoted 6 lines
Quoted 6 lines
# ls /sys/devices/virtual/net/eth3.101/fcport1/fcfport_2001000deca31e81/fcfabric_0/fcvport_0/
host6  node_name  port_id  port_name  port_type  power  roles  symbolic_name  uevent  vport_last_state  vport_state  vport_type
# ls /sys/devices/virtual/net/eth3.101/fcport1/fcfport_2001000deca31e81/fcfabric_0/fcvport_0/host6/
bsg  fcpinit  power  rport-6:0-0  rport-6:0-2  scsi_host  subsystem  uevent
Quoted 7 lines

See above. Why are the remote ports grouped under the 'host', and not under the fabric?

Quoted 3 lines
# ls /sys/devices/virtual/net/eth3.101/fcport1/fcfport_2001000deca31e81/fcfabric_0/fcvport_0/host6/fcpinit/
host6

fcpinit? What's this for?

It had been suggested. I imagine having a fcptarg that hooks into stgt at some point.

I don't have any attributes in mind for the fcpinit or fcptarg right now. Also, I'm still allocating libfc's fcp private data with the scsi_host, so fcpinit is pretty hollow right now. I might just leave it as a placeholder for the short-term.

Whether fcpinit should exist or not is related to the open item below regarding the FC4 decision. If there is eventually a fcpinit and fcptarg there would need to be a mechanism to choose between the two.

Quoted 33 lines
Quoted 13 lines
# ls /sys/devices/virtual/net/eth3.101/fcport1/fcfport_2001000deca31e81/fcfabric_0/fcvport_0/host6/fcpinit/host6/
device  issue_lip  port_state  power  statistics  subsystem  tgtid_bind_type  uevent

VN_Ports ports show up just like N_Ports: (notice fcvport_1, not fcvport_0)

# ls /sys/devices/virtual/net/eth3.101/fcport1/fcfport_2001000deca31e81/fcfabric_0/fcvport_1/
host7  node_name  port_id  port_name  port_type  power  roles  symbolic_name  uevent  vport_last_state  vport_state  vport_type

My open questions are:

1) How is the FC4 choice made?

Quoted 8 lines

If FC sysfs allows an FC HBA to support other FC4 types, then how and when is the selection made? It seems that this decision would either need to be hard-coded or provided by the user. fcoe.ko requires user action to start a connection. It would be easy for us to also require a FC4 selection (maybe it defaults to SCSI-FCP (init)). HW adapters generally FLOGI on link up and do not require user interaction. How would this decision be made?

I would consider FCP only currently. Other types would be handled by different subsystems anyway (ie net), which again have a totally different sysfs layout.

Quoted 8 lines

2) How do I reorder fc_host and scsi_host?

Previously the fc_host is attached as a child of the scsi_host. The new layout has the scsi_host as a child of fcpinit. These patches have the fcpinit object created by the scsi transport and attribute container code. I'm not sure if/how to re-order these objects, it might require changes to the scsi transport and AC code.

Quoted 7 lines

Easiest would be to use the same counter, so that a fc_host preallocates a scsi_host id, too. Not sure if that's possible, though. Alternatively you could create a scsi_host, but _not_ register it with sysfs. This way you would have a number preallocated, too. And when restricting this layout to FCP we will allocate a scsi_host anyway...

I'll play around with this. Thanks for the suggestions.

Quoted 11 lines
Quoted 7 lines

3) What do I do about remote_ports?

Currently the remote_ports are created by the scsi transport and AC code which places them as children of the fc_host. I believe this problem is essentially the same as #2, but with remote ports instead of the fc_host.

We should try to avoid separate directories for objects which ultimatively map onto the same device. IE it should be possible to gather _all_ information from walking up the devpath only, without having to recurse on other side directories.

Sounds good.

Quoted 51 lines

This way we can match on the various attributes from udev rules; with separate directories this is impossible without a helper script.

I'm happy to mail my 'path_id' script around, just to get you an idea where you end up with the separate directory approach :-)

Quoted 10 lines

4) What should the FC sysfs objects be?

Should they be class objects? I just made them of type 'struct device' to keep them as flexible as possible. I made the fcport a class object so that it could be anchored at /sys/class/.

(last minute note: I just saw in the link referenced above, that the
objects were referred to as classes. I missed that initiatlly, is there no concern about adding too many classes to /sys?)

The 'class' and 'device' distinction is basically gone with the newer sysfs code.
The elements in 'class' are just pointers into the 'device' structure.

Quoted 6 lines

5) How should the FC sysfs objects be named?

Currently I have two styles. The fcport, fcfabric and fcvport objects are all enumerated. The fcfport is given a name from its WWPN/WWNN. It's pretty ugly as is, and the naming needs more consideration.

As mentioned above, yes, it is. Please use logical names.

Quoted 12 lines

I don't really like N_Ports being referred to as vports in sysfs either.

6) What about complicated relationships between objects?

Right now this layout cannot elegantly support multiple physical ports connected to the same F_Port. Each port will have it's own sysfs directory tree and the two trees will not converge even if they share the same F_Port/fabric/etc... vports under a physical port will show up under the physical port's sysfs directory tree.

7) Should vport_create/destroy be under fcfabric or fcport?

Quoted 11 lines

I've currently put the vport_create/destroy attributes under the fcfabric. I think this is fine for now, since there are no complicated object relationships being presented. There's a one to one relationship between a fcport and a fcfabric so it's fairly easy to go back to the fcport, which is needed to be passed to the LLD so it can create a vport. If there were more than one fcport per fcfabric it would complicate this. Should the vport_create/destroy be moved to be attributes of the fcport instead to avoid a potential lookup if things get more complicated in the future?

Quoted 3 lines

Once the fcfabric is consolidated with fcfport they'll end up under fcport anyway :-)

Yeah, consolidating these two should make getting to the fcport from the fcfabric easier- just go to the parent.

However, I think #7 is just wrong. What's the patches do now is to allocate the libfc per-instance data (the lport) with the vport (that represents the N_Port). When the fcfabric is told to allocate a NPIV port it just needs to look through its list of vports to find the N_Port and pass it down to the LLD's vport_create function.

Quoted 20 lines
Quoted 8 lines

8) Should the fcfport and fcfabric be consolidated?

The fcfport doesn't show much other than its name. The fcfabric doesn't have many attributes either. Most of its attributes are vport related. I could see adding some FIP information to the fcfport, but I'm not sure we need two objects here, especially if the vport attributes need to be moved to the fcport.

See above. Yes.

Quoted 10 lines

9) Is this change worth all of the changes that will need to happen?

This is probably the most difficult question. I view this change as positive overall, but it's very heavy lifting. Not only does the FC transport need an overhaul, but it looks like the scsi transport and AC code might need some additions. Every HBA will need to be modified and every HBA's HBAAPI vendor library will need to change too. (I hope this would be a catalyst to move to an OS library that everyone shares)

Quoted 5 lines
Quoted 3 lines

I'd like to hear other opinions about this because this really is going to be something that all HBAs will need to be involved in.

I think it's quite a valid goal.

Thanks for the comments Hannes.

#9 lore raw
Quoted 2 lines · Robert Love
Quoted 1 line · Hannes Reinecke

Robert Love wrote:

[...]

Quoted 9 lines
Quoted 9 lines
Quoted 3 lines
# ls /sys/devices/virtual/net/eth3.101/fcport1/fcfport_2001000deca31e81/fcfabric_0/
fabric_name  fcvport_0  fcvport_1  max_npiv_vports  npiv_vports_inuse  power  uevent  vport_create  vport_delete

Consistent numbering. Either use '_' as a separator always or for none. This mix-up doesn't make sense.

And, why doesn't the fcfport doesn't show up under the fabric? One would assume that the fcfport is part of the fabric, too.

Quoted 7 lines
Quoted 5 lines

And what about the remote ports? Do they not participate in the fabric?

If the 'fcfabric' element is _not_ the actual fabric I would get rid of it altogether as it'll only serve to confuse the users. Like just has been happened with me :-)

Yeah, they should be under the fcfabric. This work is just incomplete in that area.

Besides the fabric, FC also has the arbitrated loop and point-to-point support. If there is a fcfabric element, would the "point-to-point remote port" be placed under the fcfabric? Or might this be another point for not having the fcfabric element?

[...]

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

9) Is this change worth all of the changes that will need to happen?

This is probably the most difficult question. I view this change as positive overall, but it's very heavy lifting. Not only does the FC transport need an overhaul, but it looks like the scsi transport and AC code might need some additions. Every HBA will need to be modified and every HBA's HBAAPI vendor library will need to change too. (I hope this would be a catalyst to move to an OS library that everyone shares)

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

I'd like to hear other opinions about this because this really is going to be something that all HBAs will need to be involved in.

The changes required for "all HBAs" also include the zfcp driver, i am looking at this from zfcp's point of view. With zfcp, we only support FCP/SCSI with point-to-point or fabric attached storage, so we don't need as much flexibility as other HBAs.

I assume the LLD driver will report the available hardware resources with fc_fcport_add, fc_fcpinit_add or whatever the entry points will be called in the final version. Reporting the new FC elements instead of FC host and SCSI host should be doable for zfcp.

--
Christof