Skip to contentSkip to conversation

fc_transport: (update on top of) Add an API to allow an LLD to create vports

PATCH New James Smart 2 participants 2 messages Jul 18, 2008

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

PATCH 1/1 fc_transport: (update on top of) Add an API to allow an LLD to create vports

Andrew,

Sorry for not commenting sooner on the RFC. The reorg is fine, but I have a couple of comments.

Re: scsi_fc_transport.txt
Add a function prototype for fc_vport_terminate similar to what's done for fc_vport_create

Re: fc_vport_create
I recommend we pass the channel number in fc_vport_create rather than fixing it at zero.

Also, ids->vport_type should be set to FC_PORTTYPE_NPIV prior to calling fc_vport_create. The comment is also meaningless.

I've appended a patch for the above.

-- james s

---

 Documentation/scsi/scsi_fc_transport.txt |    2 ++
 drivers/scsi/scsi_transport_fc.c         |    9 +++++----
 include/scsi/scsi_transport_fc.h         |    2 +-
 3 files changed, 8 insertions(+), 5 deletions(-)
Documentation/scsi/scsi_fc_transport.txt +2 -0
diff -upNr a/Documentation/scsi/scsi_fc_transport.txt b/Documentation/scsi/scsi_fc_transport.txt
@@ -468,6 +468,8 @@ fc_vport_create(struct Scsi_Host *shost,
  * Notes:
  *      This routine assumes no locks are held on entry.
  */
+int
+fc_vport_terminate(struct fc_vport *vport)
 
 
 Credits
drivers/scsi/scsi_transport_fc.c +5 -4
diff -upNr a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
@@ -3209,6 +3209,7 @@ delete_vport:
 /**
  * fc_vport_create - Admin App or LLDD requests creation of a vport
  * @shost:	scsi host the virtual port is connected to.
+ * @channel:	channel on shost port connected to.
  * @ids:	The world wide names, FC4 port roles, etc for
  *              the virtual port.
  *
@@ -3216,14 +3217,14 @@ delete_vport:
  *	This routine assumes no locks are held on entry.
  */
 struct fc_vport *
-fc_vport_create(struct Scsi_Host *shost, struct fc_vport_identifiers *ids)
+fc_vport_create(struct Scsi_Host *shost, int channel,
+	struct fc_vport_identifiers *ids)
 {
 	int stat;
 	struct fc_vport *vport;
 
-	/* We only create vports here. */
-	ids->vport_type = FC_PORTTYPE_NPIV;
-	stat = fc_vport_setup(shost, 0, &shost->shost_gendev, ids, &vport);
+	stat = fc_vport_setup(shost, channel, &shost->shost_gendev,
+		 ids, &vport);
 	return stat ? NULL : vport;
 }
 EXPORT_SYMBOL(fc_vport_create);
include/scsi/scsi_transport_fc.h +1 -1
diff -upNr a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
@@ -751,7 +751,7 @@ void fc_host_post_vendor_event(struct Sc
 	 *   be sure to read the Vendor Type and ID formatting requirements
 	 *   specified in scsi_netlink.h
 	 */
-struct fc_vport *fc_vport_create(struct Scsi_Host *shost,
+struct fc_vport *fc_vport_create(struct Scsi_Host *shost, int channel,
 		struct fc_vport_identifiers *);
 int fc_vport_terminate(struct fc_vport *vport);
 
#1 lore raw

PATCH v3 1/1 fc_transport: Add an API to allow an LLD to create vports

There's already a fc_vport_termintate() call exported by the transport. This patch adds a symmetric call to the API to allow an NPIV-capable LLD to instantiate vports sans user intervention.

Additional comments/updates:

Re: scsi_fc_transport.txt
Add a function prototype for fc_vport_terminate similar to what's done for fc_vport_create

Re: fc_vport_create
I recommend we pass the channel number in fc_vport_create rather than fixing it at zero.

Also, ids->vport_type should be set to FC_PORTTYPE_NPIV prior to calling fc_vport_create. The comment is also meaningless.

Added-by and

---

Quoted 7 lines · James Smart

Sorry for not commenting sooner on the RFC. The reorg is fine, but I have a couple of comments.

Re: scsi_fc_transport.txt
Add a function prototype for fc_vport_terminate similar to what's done for fc_vport_create

Quoted 8 lines

Re: fc_vport_create
I recommend we pass the channel number in fc_vport_create rather than fixing it at zero.

Also, ids->vport_type should be set to FC_PORTTYPE_NPIV prior to calling fc_vport_create. The comment is also meaningless.

I've appended a patch for the above.

Ok, great... I've squashed your comments and changes into a v3.

James B. Please apply this version...

Thanks, AV

 Documentation/scsi/scsi_fc_transport.txt |   36 ++++++++++++++++++++
 drivers/scsi/scsi_transport_fc.c         |   54 ++++++++++++++---------------
 include/scsi/scsi_transport_fc.h         |   23 ++++++++++++-
 3 files changed, 84 insertions(+), 29 deletions(-)
Documentation/scsi/scsi_fc_transport.txt +36 -0
index d403e46..8305bee 100644
@@ -436,6 +436,42 @@ Other:
     was updated to remove all vports for the fc_host as well.
 
 
+Transport supplied functions
+----------------------------
+
+The following functions are supplied by the FC-transport for use by LLDs.
+
+   fc_vport_create - create a vport
+   fc_vport_terminate - detach and remove a vport
+
+Details:
+
+/**
+ * fc_vport_create - Admin App or LLDD requests creation of a vport
+ * @shost:     scsi host the virtual port is connected to.
+ * @ids:       The world wide names, FC4 port roles, etc for
+ *              the virtual port.
+ *
+ * Notes:
+ *     This routine assumes no locks are held on entry.
+ */
+struct fc_vport *
+fc_vport_create(struct Scsi_Host *shost, struct fc_vport_identifiers *ids)
+
+/**
+ * fc_vport_terminate - Admin App or LLDD requests termination of a vport
+ * @vport:      fc_vport to be terminated
+ *
+ * Calls the LLDD vport_delete() function, then deallocates and removes
+ * the vport from the shost and object tree.
+ *
+ * Notes:
+ *      This routine assumes no locks are held on entry.
+ */
+int
+fc_vport_terminate(struct fc_vport *vport)
+
+
 Credits
 =======
 The following people have contributed to this document:
drivers/scsi/scsi_transport_fc.c +26 -28

84 lines not on this page · raw message

include/scsi/scsi_transport_fc.h +22 -1
index 06f72ba..c0a1369 100644
@@ -167,6 +167,26 @@ enum fc_tgtid_binding_type  {
 struct device_attribute dev_attr_vport_##_name = 	\
 	__ATTR(_name,_mode,_show,_store)
 
+/*
+ * fc_vport_identifiers: This set of data contains all elements
+ * to uniquely identify and instantiate a FC virtual port.
+ *
+ * Notes:
+ *   symbolic_name: The driver is to append the symbolic_name string data
+ *      to the symbolic_node_name data that it generates by default.
+ *      the resulting combination should then be registered with the switch.
+ *      It is expected that things like Xen may stuff a VM title into
+ *      this field.
+ */
+#define FC_VPORT_SYMBOLIC_NAMELEN		64
+struct fc_vport_identifiers {
+	u64 node_name;
+	u64 port_name;
+	u32 roles;
+	bool disable;
+	enum fc_port_type vport_type;	/* only FC_PORTTYPE_NPIV allowed */
+	char symbolic_name[FC_VPORT_SYMBOLIC_NAMELEN];
+};
 
 /*
  * FC Virtual Port Attributes
@@ -197,7 +217,6 @@ struct device_attribute dev_attr_vport_##_name = 	\
  * managed by the transport w/o driver interaction.
  */
 
-#define FC_VPORT_SYMBOLIC_NAMELEN		64
 struct fc_vport {
 	/* Fixed Attributes */
 
@@ -732,6 +751,8 @@ void fc_host_post_vendor_event(struct Scsi_Host *shost, u32 event_number,
 	 *   be sure to read the Vendor Type and ID formatting requirements
 	 *   specified in scsi_netlink.h
 	 */
+struct fc_vport *fc_vport_create(struct Scsi_Host *shost, int channel,
+		struct fc_vport_identifiers *);
 int fc_vport_terminate(struct fc_vport *vport);
 
 #endif /* SCSI_TRANSPORT_FC_H */
Signature · 1 line
1.5.6.3.384.gfcab4