Patchwork [Open-FCoE,04/10] fcoemon: Add VN2VN support

login
register
mail settings
Submitter Mark Rustad
Date March 19, 2013, 11:33 p.m.
Message ID <20130319233339.3241.64941.stgit@host1-mdrustad.localdomain>
Download mbox | patch
Permalink /patch/23/
State Accepted
Headers show

Comments

Mark Rustad - March 19, 2013, 11:33 p.m.
Add code to detect the VN2VN flag in create requests and configure
a created fcoe controller appropriately.

Signed-off-by: Mark Rustad <mark.d.rustad@intel.com>
Tested-by: Jack Morgan <jack.morgan@intel.com>
---

 fcoemon.c            |   30 ++++++++++++++++++++++++++++--
 include/fcoe_utils.h |    2 ++
 2 files changed, 30 insertions(+), 2 deletions(-)

Patch

diff --git a/fcoemon.c b/fcoemon.c
index 1d869b3..982c4a9 100644
--- a/fcoemon.c
+++ b/fcoemon.c
@@ -182,7 +182,18 @@  static const struct libfcoe_interface_template *libfcoe_control;
 
 static enum fcoe_status fcm_module_create(struct fcm_netif *ff, struct fcoe_port *p)
 {
-	enum fcoe_status rc = fcm_fcoe_if_action(FCOE_CREATE, p->ifname);
+	enum fcoe_status rc;
+
+	switch (p->mode) {
+	case FCOE_MODE_VN2VN:
+		rc = fcm_fcoe_if_action(FCOE_CREATE_VN2VN, p->ifname);
+		break;
+
+	case FCOE_MODE_FABRIC:
+	default:
+		rc = fcm_fcoe_if_action(FCOE_CREATE, p->ifname);
+		break;
+	}
 	if (rc)
 		return rc;
 
@@ -227,6 +238,17 @@  static enum fcoe_status fcm_bus_enable(struct fcm_netif *ff,
 	return fcm_write_str_to_ctlr_attr(p->ctlr, FCOE_CTLR_ATTR_ENABLED, "1");
 }
 
+static int fcm_bus_configure(struct fcm_netif *ff, struct fcoe_port *p)
+{
+	int rc;
+
+	if (p->mode != FCOE_MODE_VN2VN)
+		return 0;
+
+	rc = fcm_write_str_to_ctlr_attr(p->ctlr, FCOE_CTLR_ATTR_MODE, "vn2vn");
+	return rc;
+}
+
 static enum fcoe_status fcm_bus_create(struct fcm_netif *ff,
 				       struct fcoe_port *p)
 {
@@ -256,7 +278,11 @@  static enum fcoe_status fcm_bus_create(struct fcm_netif *ff,
 		return ENOSYSFS;
 	}
 
-	return fcm_bus_enable(ff, p);
+	rc = fcm_bus_configure(ff, p);
+	if (!rc)
+		rc = fcm_bus_enable(ff, p);
+
+	return rc;
 }
 
 static enum fcoe_status fcm_bus_destroy(struct fcm_netif *ff,
diff --git a/include/fcoe_utils.h b/include/fcoe_utils.h
index 531acab..5fb875d 100644
--- a/include/fcoe_utils.h
+++ b/include/fcoe_utils.h
@@ -43,6 +43,7 @@ 
 
 #define SYSFS_FCOE   SYSFS_MOUNT "/module/libfcoe/parameters" /* legacy */
 #define FCOE_CREATE  SYSFS_FCOE  "/create"  /* legacy */
+#define FCOE_CREATE_VN2VN  SYSFS_FCOE  "/create_vn2vn"  /* legacy */
 #define FCOE_DESTROY SYSFS_FCOE  "/destroy" /* legacy */
 #define FCOE_ENABLE  SYSFS_FCOE  "/enable"  /* legacy */
 #define FCOE_DISABLE SYSFS_FCOE  "/disable" /* legacy */
@@ -50,6 +51,7 @@ 
 #define FCOE_BUS_CREATE        SYSFS_FCOE_BUS "/ctlr_create"
 #define FCOE_BUS_DESTROY       SYSFS_FCOE_BUS "/ctlr_destroy"
 #define FCOE_CTLR_ATTR_ENABLED "/enabled"
+#define FCOE_CTLR_ATTR_MODE    "/mode"
 
 #define FCHOSTBUFLEN 64