Skip to contentSkip to conversation

Reorganize libfcoe control interfaces

RFC PATCH In review Robert Love 7 participants 22 messages Sep 10, 2012 – Sep 14, 2012 1 message not in the archive

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

cover Reorganize libfcoe control interfaces

The following series implements a move from using module parameters as control interfaces to /sys/bus/fcoe based interfaces. A sysfs infrastructure was added to the kernel a few cycles ago, this series builds on that work.

It moves the create, vn2vn_create, destroy, enable and disable interfaces from /sys/module/libfcoe/parameters/ to various places under /sys/bus/fcoe/. These interfaces simply are not module configurations- they are control interfaces.

A second goal of this series is to change the initialization sequence for a FCoE device. The result of this series is that interfaces created using libfcoe.ko interfaces (i.e. fcoe.ko or bnx2fc.ko) will have the following starting steps-

1) Create/alloc the port
- Allocate kernel memory and create per-instance sysfs devices
- No discovery or login

2) Configure the port
- Change mode, set ddp_min, etc...

3) Start the port
- Begins discovery and/or login (depending on mode)

4) Destroy the port
- Logout and free all memory

I'm looking for feedback on using sysfs files as control interfaces that the user (application) would write interface names to. I modeled this series off of the bonding sysfs interface, but it was suggested to me that it might not be a good example. I belive bonding uses two values per-file a '+' or a '-" to add or delete and then the ifname apended. I am simply writing the ifname to the ctlr_create or ctlr_destroy.

Series compiled and tested against v3.5. libfcoe.ko compile warning fixed upstream after v3.5, anyone who compiles this can ignore section mismatch warning. Also note that a modified fcoemon is needed to use the fcoe system service against this kernel modification. I'd be happy to provide that fcoemon code on request.

---

Robert Love (5):
libfcoe, fcoe: Allow user to set a ctlr's mode
libfcoe: Create new libfcoe control interfaces
fcoe: Use new fcoe_sysfs control interface
bnx2fc: Use new fcoe_sysfs control interface libfcoe, fcoe: Remove libfcoe module parameters

 Documentation/ABI/testing/sysfs-bus-fcoe |   51 +++++++
 drivers/scsi/bnx2fc/bnx2fc_fcoe.c        |   98 ++++++++-----
 drivers/scsi/fcoe/fcoe.c                 |  229 +++++++++++++++---------------
 drivers/scsi/fcoe/fcoe.h                 |    9 +
 drivers/scsi/fcoe/fcoe_ctlr.c            |   24 +++
 drivers/scsi/fcoe/fcoe_sysfs.c           |  139 ++++++++++++++++++
 drivers/scsi/fcoe/fcoe_transport.c       |  174 ++++-------------------
 include/scsi/fcoe_sysfs.h                |    5 +
 include/scsi/libfcoe.h                   |   20 ++-
 9 files changed, 445 insertions(+), 304 deletions(-)
Signature · 1 line
Thanks, //Rob
#1 lore raw

RFC PATCH 1/5 libfcoe, fcoe: Allow user to set a ctlr's mode

This patch makes the 'mode' attribute of a fcoe_ctlr_device writale. This allows the user to store the mode with with the ctlr will be in.

Possible modes would be 'Fabric', or 'VN2VN'.

The default mode for a fcoe_ctlr{,_device} is 'Fabric'. Drivers must implement the set_fcoe_ctlr_mode routine to support this feature.

libfcoe offers an exported routine to set a fcoe_ctlr's mode.

---
 Documentation/ABI/testing/sysfs-bus-fcoe |    8 ++++
 drivers/scsi/fcoe/fcoe_ctlr.c            |   22 +++++++++++
 drivers/scsi/fcoe/fcoe_sysfs.c           |   61 +++++++++++++++++++++++++++++-
 include/scsi/fcoe_sysfs.h                |    1 
 include/scsi/libfcoe.h                   |    1 
 5 files changed, 91 insertions(+), 2 deletions(-)
Documentation/ABI/testing/sysfs-bus-fcoe +8 -0
index 469d09c..1b06ec1 100644
@@ -9,6 +9,14 @@ Attributes:
 			  this value will change the dev_loss_tmo for all
 			  FCFs discovered by this controller.
 
+	mode:		  Display or change the FCoE Controller's mode. Possible
+			  modes are 'Fabric' and 'VN2VN'. If a FCoE Controller
+			  is started in 'Fabric' mode then FIP FCF discovery is
+			  initiated and ultimately a fabric login is attempted.
+			  If a FCoE Controller is started in 'VN2VN' mode then
+			  FIP VN2VN discovery and login is performed. A FCoE
+			  Controller only supports one mode at a time.
+
 	lesb_link_fail:   Link Error Status Block (LESB) link failure count.
 
 	lesb_vlink_fail:  Link Error Status Block (LESB) virtual link
drivers/scsi/fcoe/fcoe_ctlr.c +22 -0
index d68d572..bd899bf 100644
@@ -2884,3 +2884,25 @@ void fcoe_ctlr_get_fip_mode(struct fcoe_ctlr_device *ctlr_dev)
 	mutex_unlock(&ctlr->ctlr_mutex);
 }
 EXPORT_SYMBOL(fcoe_ctlr_get_fip_mode);
+
+void fcoe_ctlr_set_fip_mode(struct fcoe_ctlr_device *ctlr_dev)
+{
+	struct fcoe_ctlr *ctlr = fcoe_ctlr_device_priv(ctlr_dev);
+
+	mutex_lock(&ctlr->ctlr_mutex);
+	switch (ctlr_dev->mode) {
+	case FIP_CONN_TYPE_VN2VN:
+		ctlr->mode = FIP_MODE_VN2VN;
+		break;
+	case FIP_CONN_TYPE_FABRIC:
+	default:
+		ctlr->mode = FIP_MODE_FABRIC;
+		break;
+	}
+
+	/* TODO: Probably need to restart the state machine */
+
+	mutex_unlock(&ctlr->ctlr_mutex);
+
+}
+EXPORT_SYMBOL(fcoe_ctlr_set_fip_mode);
drivers/scsi/fcoe/fcoe_sysfs.c +59 -2

79 lines not on this page · raw message

include/scsi/fcoe_sysfs.h +1 -0
index 604cb9b..421ae67 100644
@@ -35,6 +35,7 @@ struct fcoe_sysfs_function_template {
 	void (*get_fcoe_ctlr_err_block)(struct fcoe_ctlr_device *);
 	void (*get_fcoe_ctlr_fcs_error)(struct fcoe_ctlr_device *);
 	void (*get_fcoe_ctlr_mode)(struct fcoe_ctlr_device *);
+	void (*set_fcoe_ctlr_mode)(struct fcoe_ctlr_device *);
 	void (*get_fcoe_fcf_selected)(struct fcoe_fcf_device *);
 	void (*get_fcoe_fcf_vlan_id)(struct fcoe_fcf_device *);
 };
include/scsi/libfcoe.h +1 -0
index 22b07cc..20533cc 100644
@@ -359,6 +359,7 @@ int fcoe_get_paged_crc_eof(struct sk_buff *skb, int tlen,
 /* FCoE Sysfs helpers */
 void fcoe_fcf_get_selected(struct fcoe_fcf_device *);
 void fcoe_ctlr_get_fip_mode(struct fcoe_ctlr_device *);
+void fcoe_ctlr_set_fip_mode(struct fcoe_ctlr_device *);
 
 /**
  * struct netdev_list
Acked-by on v1 1/5
#2 lore raw

Re: [RFC PATCH 1/5] libfcoe, fcoe: Allow user to set a ctlr's mode

Quoted 6 lines · Robert Love

This patch makes the 'mode' attribute of a fcoe_ctlr_device writale. This allows the user to store the mode with with the ctlr will be in.

Possible modes would be 'Fabric', or 'VN2VN'.

Quoted 8 lines

The default mode for a fcoe_ctlr{,_device} is 'Fabric'. Drivers must implement the set_fcoe_ctlr_mode routine to support this feature.

libfcoe offers an exported routine to set a fcoe_ctlr's mode.

#3 lore raw

Re: [RFC PATCH 1/5] libfcoe, fcoe: Allow user to set a ctlr's mode

In reply to Robert Love

drivers/scsi/fcoe/fcoe_sysfs.c MODULE_PARM_DESC(fcf_dev_loss_tmo, · line 64

Quoted 9 lines · Robert Love
drivers/scsi/fcoe/fcoe_sysfs.c +9 -0
+static enum fip_conn_type fcoe_parse_mode(const char *buf,
+				  const struct fcoe_ctlr_mode_table *tbl)
+{
+	int modeint = -1, i, rv;
+	char *p, modestr[FCOE_MAX_MODENAME_LEN + 1] = { 0, };
+
+	for (p = (char *)buf; *p; p++)
+		if (!(isdigit(*p) || isspace(*p)))
+			break;

If you change the declaration of p from "char *p" into "const char *p" you won't need a cast in the above for loop.

[ ... ]

drivers/scsi/fcoe/fcoe_sysfs.c static ssize_t show_ctlr_mode(struct device *dev, · line 327

Quoted 13 lines
drivers/scsi/fcoe/fcoe_sysfs.c +11 -2
-static FCOE_DEVICE_ATTR(ctlr, mode, S_IRUGO,
-			show_ctlr_mode, NULL);
+
+static ssize_t store_ctlr_mode(struct device *dev,
+			       struct device_attribute *attr,
+			       const char *buf, size_t count)
+{
+	struct fcoe_ctlr_device *ctlr = dev_to_ctlr(dev);
+
+	if (!ctlr->f->set_fcoe_ctlr_mode)
+		return -EINVAL;
+
+	ctlr->mode = fcoe_parse_mode(buf, ctlr_mode_tbl);

As far as I know sysfs doesn't terminate buf with a '\0' before calling a store method. Does that mean that you are passing a string that is not '\0'-terminated to a function that expects a '\0'-terminated string ?

Bart.

#4 lore raw

Re: [RFC PATCH 1/5] libfcoe, fcoe: Allow user to set a ctlr's mode

Quoted 34 lines · Bart Van Assche

drivers/scsi/fcoe/fcoe_sysfs.c MODULE_PARM_DESC(fcf_dev_loss_tmo, · line 64

Quoted 9 lines · Robert Love
drivers/scsi/fcoe/fcoe_sysfs.c +9 -0
+static enum fip_conn_type fcoe_parse_mode(const char *buf,
+				  const struct fcoe_ctlr_mode_table *tbl)
+{
+	int modeint = -1, i, rv;
+	char *p, modestr[FCOE_MAX_MODENAME_LEN + 1] = { 0, };
+
+	for (p = (char *)buf; *p; p++)
+		if (!(isdigit(*p) || isspace(*p)))
+			break;

If you change the declaration of p from "char *p" into "const char *p" you won't need a cast in the above for loop.

[ ... ]

drivers/scsi/fcoe/fcoe_sysfs.c static ssize_t show_ctlr_mode(struct device *dev, · line 327

Quoted 13 lines
drivers/scsi/fcoe/fcoe_sysfs.c +11 -2
-static FCOE_DEVICE_ATTR(ctlr, mode, S_IRUGO,
-			show_ctlr_mode, NULL);
+
+static ssize_t store_ctlr_mode(struct device *dev,
+			       struct device_attribute *attr,
+			       const char *buf, size_t count)
+{
+	struct fcoe_ctlr_device *ctlr = dev_to_ctlr(dev);
+
+	if (!ctlr->f->set_fcoe_ctlr_mode)
+		return -EINVAL;
+
+	ctlr->mode = fcoe_parse_mode(buf, ctlr_mode_tbl);

As far as I know sysfs doesn't terminate buf with a '\0' before calling a store method. Does that mean that you are passing a string that is not '\0'-terminated to a function that expects a '\0'-terminated string ?

Quoted 1 line

Bart.

Hey Bart. I just wanted to acknowledge your comments. I will make sure that they're addressed after figuring out if sysfs is the right place for the interfaces.

Thanks, //Rob

#5 lore raw

RFC PATCH 2/5 libfcoe: Create new libfcoe control interfaces

In reply to Robert Love

This patch is the first in a series that will remove libfcoe's create, destroy, enable and disable module parameters and replace them with interface files in the new /sys/bus/fcoe subsystem.

Old layout:

/sys/module/libfcoe/parameters/{create,destroy,enable,disable,vn2vn_create}

New layout:

/sys/bus/fcoe/ctlr_{create,destroy}
/sys/bus/fcoe/ctlr_X/{enable,disable,start}

This patch moves fcoe drivers to the following initialization sequence-

1) create/alloc
2) configure
3) start

A control sysfs interface at /sys/bus/fcoe/ctlr_create is added. Writing the interface name to this file will allocate memory and create a sysfs entry for a new fcoe_ctlr_device. The user may then tune the interface in any desired way. After configuration the user will echo any value into the /sys/bus/fcoe/devices/ctlr_X/start interface to proceed with logging in.

VN2VN logins will still use the module parameters. A follow up patch to this one will make the 'mode' attribute of the fcoe_ctlr_device writable. Which will allow a user to change the ctlr's mode to 'VN2VN'.

---
 Documentation/ABI/testing/sysfs-bus-fcoe |   43 ++++++++++++
 drivers/scsi/fcoe/fcoe.h                 |    9 +++
 drivers/scsi/fcoe/fcoe_ctlr.c            |    2 -
 drivers/scsi/fcoe/fcoe_sysfs.c           |   78 ++++++++++++++++++++++
 drivers/scsi/fcoe/fcoe_transport.c       |  105 +++++++++++++++++++++++++++++-
 include/scsi/fcoe_sysfs.h                |    4 +
 include/scsi/libfcoe.h                   |   14 ++++
 7 files changed, 250 insertions(+), 5 deletions(-)
Documentation/ABI/testing/sysfs-bus-fcoe +42 -1
index 1b06ec1..242d4a1 100644
@@ -1,8 +1,37 @@
+What:		/sys/bus/fcoe/
+Date:		August 2012
+KernelVersion:	TBD
+Contact:	Robert Love <[email protected]>, [email protected]
+Description:	The FCoE bus. Attributes in this directory are control interfaces.
+Attributes:
+
+	ctlr_create: 'FCoE Controller' instance creation interface. Writing an
+		     <ifname> to this file will allocate and populate sysfs with a
+		     fcoe_ctlr_device (ctlr_X). The user can then configure any
+		     per-port settings and finally write to the fcoe_ctlr_device's
+		     'start' attribute to begin the kernel's discovery and login
+		     process.
+
+	ctlr_destroy: 'FCoE Controller' instance removal interface. Writing a
+		       fcoe_ctlr_device's sysfs name to this file will log the
+		       fcoe_ctlr_device out of the fabric or otherwise connected
+		       FCoE devices. It will also free all kernel memory allocated
+		       for this fcoe_ctlr_device and any structures associated
+		       with it, this includes the scsi_host.
+
 What:		/sys/bus/fcoe/ctlr_X
 Date:		March 2012
 KernelVersion:	TBD
 Contact:	Robert Love <[email protected]>, [email protected]
-Description:	'FCoE Controller' instances on the fcoe bus
+Description:	'FCoE Controller' instances on the fcoe bus.
+
+		The FCoE Controller now has a three stage creation process.
+		1) Write interface name to ctlr_create 2) Configure the FCoE
+		Controller (ctlr_X) 3) Write anything to the FCoE
+		Controller's 'start' file to begin discovery and login. The
+		FCoE Controller is destroyed by writing it's name, i.e. ctlr_X
+		to the ctlr_delete file.
+
 Attributes:
 
 	fcf_dev_loss_tmo: Device loss timeout peroid (see below). Changing
@@ -17,6 +46,18 @@ Attributes:
 			  FIP VN2VN discovery and login is performed. A FCoE
 			  Controller only supports one mode at a time.
 
+	start:		  Start the FCoE controller.
+
+	disable:	  Allow FCoE controller's that support disabling
+			  to be disabled when any value is written to this
+			  file. This attribute is only displayed if the
+			  driver supports it.
+
+	enable:           Allow FCoE controller's that support enabling
+			  to be enabled when any value is written to this
+			  file. This attribute is only displayed if the
+			  driver supports it.
+
 	lesb_link_fail:   Link Error Status Block (LESB) link failure count.
 
 	lesb_vlink_fail:  Link Error Status Block (LESB) virtual link
drivers/scsi/fcoe/fcoe.h +9 -0
index a624add..e984627 100644
@@ -22,6 +22,7 @@
 
 #include <linux/skbuff.h>
 #include <linux/kthread.h>
+#include <scsi/libfc.h>
 
 #define FCOE_MAX_QUEUE_DEPTH	256
 #define FCOE_MIN_QUEUE_DEPTH	32
@@ -99,4 +100,12 @@ static inline struct net_device *fcoe_netdev(const struct fc_lport *lport)
 			((struct fcoe_port *)lport_priv(lport))->priv)->netdev;
 }
 
+struct net_device *fcoe_ctlr_to_netdev(
+	const struct fcoe_ctlr_device *ctlr_dev)
+{
+	struct fcoe_ctlr *ctlr = fcoe_ctlr_device_priv(ctlr_dev);
+	struct fc_lport *lport = ctlr->lp;
+	return fcoe_netdev(lport);
+}
+
 #endif /* _FCOE_H_ */
drivers/scsi/fcoe/fcoe_ctlr.c +1 -1
index bd899bf..ccb92323 100644
@@ -147,7 +147,7 @@ static void fcoe_ctlr_map_dest(struct fcoe_ctlr *fip)
  */
 void fcoe_ctlr_init(struct fcoe_ctlr *fip, enum fip_state mode)
 {
-	fcoe_ctlr_set_state(fip, FIP_ST_LINK_WAIT);
+	fcoe_ctlr_set_state(fip, FIP_ST_DISABLED);
 	fip->mode = mode;
 	INIT_LIST_HEAD(&fip->fcfs);
 	mutex_init(&fip->ctlr_mutex);
drivers/scsi/fcoe/fcoe_sysfs.c +78 -0

108 lines not on this page · raw message

drivers/scsi/fcoe/fcoe_transport.c +103 -2

118 lines not on this page · raw message

include/scsi/fcoe_sysfs.h +4 -0
index 421ae67..8c5ea70 100644
@@ -36,6 +36,9 @@ struct fcoe_sysfs_function_template {
 	void (*get_fcoe_ctlr_fcs_error)(struct fcoe_ctlr_device *);
 	void (*get_fcoe_ctlr_mode)(struct fcoe_ctlr_device *);
 	void (*set_fcoe_ctlr_mode)(struct fcoe_ctlr_device *);
+	int  (*set_fcoe_ctlr_start)(struct fcoe_ctlr_device *);
+	int  (*set_fcoe_ctlr_enable)(struct fcoe_ctlr_device *);
+	int  (*set_fcoe_ctlr_disable)(struct fcoe_ctlr_device *);
 	void (*get_fcoe_fcf_selected)(struct fcoe_fcf_device *);
 	void (*get_fcoe_fcf_vlan_id)(struct fcoe_fcf_device *);
 };
@@ -64,6 +67,7 @@ struct fcoe_ctlr_device {
 
 	int                             fcf_dev_loss_tmo;
 	enum fip_conn_type              mode;
+	u8                              started:1;
 
 	/* expected in host order for displaying */
 	struct fcoe_fc_els_lesb         lesb;
include/scsi/libfcoe.h +13 -1
index 20533cc..b19a489 100644
@@ -289,8 +289,11 @@ static inline bool is_fip_mode(struct fcoe_ctlr *fip)
  * @attached:	whether this transport is already attached
  * @list:	list linkage to all attached transports
  * @match:	handler to allow the transport driver to match up a given netdev
+ * @alloc:      handler to allocate per-instance FCoE structures
+ *		(no discovery or login)
  * @create:	handler to sysfs entry of create for FCoE instances
- * @destroy:	handler to sysfs entry of destroy for FCoE instances
+ * @destroy:    handler to delete per-instance FCoE structures
+ *		(frees all memory)
  * @enable:	handler to sysfs entry of enable for FCoE instances
  * @disable:	handler to sysfs entry of disable for FCoE instances
  */
@@ -299,6 +302,7 @@ struct fcoe_transport {
 	bool attached;
 	struct list_head list;
 	bool (*match) (struct net_device *device);
+	int (*alloc) (struct net_device *device);
 	int (*create) (struct net_device *device, enum fip_state fip_mode);
 	int (*destroy) (struct net_device *device);
 	int (*enable) (struct net_device *device);
@@ -375,4 +379,12 @@ struct fcoe_netdev_mapping {
 int fcoe_transport_attach(struct fcoe_transport *ft);
 int fcoe_transport_detach(struct fcoe_transport *ft);
 
+/* sysfs store handler for ctrl_control interface */
+ssize_t fcoe_ctlr_create_store(struct bus_type *bus,
+			       const char *buf, size_t count);
+ssize_t fcoe_ctlr_destroy_store(struct bus_type *bus,
+				const char *buf, size_t count);
+
 #endif /* _LIBFCOE_H */
+
+
#6 lore raw

Re: [RFC PATCH 2/5] libfcoe: Create new libfcoe control interfaces

Quoted 45 lines · Robert Love

This patch is the first in a series that will remove libfcoe's create, destroy, enable and disable module parameters and replace them with interface files in the new /sys/bus/fcoe subsystem.

Old layout:

/sys/module/libfcoe/parameters/{create,destroy,enable,disable,vn2vn_create}

New layout:

/sys/bus/fcoe/ctlr_{create,destroy}
/sys/bus/fcoe/ctlr_X/{enable,disable,start}

This patch moves fcoe drivers to the following initialization sequence-

1) create/alloc
2) configure
3) start

A control sysfs interface at /sys/bus/fcoe/ctlr_create is added. Writing the interface name to this file will allocate memory and create a sysfs entry for a new fcoe_ctlr_device. The user may then tune the interface in any desired way. After configuration the user will echo any value into the /sys/bus/fcoe/devices/ctlr_X/start interface to proceed with logging in.

VN2VN logins will still use the module parameters. A follow up patch to this one will make the 'mode' attribute of the fcoe_ctlr_device writable. Which will allow a user to change the ctlr's mode to 'VN2VN'.

---
  Documentation/ABI/testing/sysfs-bus-fcoe |   43 ++++++++++++
  drivers/scsi/fcoe/fcoe.h                 |    9 +++
  drivers/scsi/fcoe/fcoe_ctlr.c            |    2 -
  drivers/scsi/fcoe/fcoe_sysfs.c           |   78 ++++++++++++++++++++++
  drivers/scsi/fcoe/fcoe_transport.c       |  105 +++++++++++++++++++++++++++++-
  include/scsi/fcoe_sysfs.h                |    4 +
  include/scsi/libfcoe.h                   |   14 ++++
  7 files changed, 250 insertions(+), 5 deletions(-)

<snip>

drivers/scsi/fcoe/fcoe_ctlr.c static void fcoe_ctlr_map_dest(struct fcoe_ctlr *fip) · line 150

Quoted 10 lines
drivers/scsi/fcoe/fcoe_ctlr.c +1 -1
index bd899bf..ccb92323 100644
@@ -147,7 +147,7 @@ static void fcoe_ctlr_map_dest(struct fcoe_ctlr *fip)
   */
  void fcoe_ctlr_init(struct fcoe_ctlr *fip, enum fip_state mode)
  {
-	fcoe_ctlr_set_state(fip, FIP_ST_LINK_WAIT);
+	fcoe_ctlr_set_state(fip, FIP_ST_DISABLED);

Robert, what is the reason for initializing it to DISABLED? Unless the FIP state is FIP_ST_LINK_WAIT, fcoe_ctlr_link_up() doesnt set lport->link_up and hence does not allow any FIP/FCoE frames to be sent out.

Quoted 3 lines
drivers/scsi/fcoe/fcoe_ctlr.c +0 -0
  	fip->mode = mode;
  	INIT_LIST_HEAD(&fip->fcfs);
  	mutex_init(&fip->ctlr_mutex);

<snip>

Quoted 49 lines
drivers/scsi/fcoe/fcoe_ctlr.c +45 -0
@@ -627,6 +626,108 @@ static int libfcoe_device_notification(struct notifier_block *notifier,
  	return NOTIFY_OK;
  }
 
+ssize_t fcoe_ctlr_create_store(struct bus_type *bus,
+			       const char *buf, size_t count)
+{
+	struct net_device *netdev = NULL;
+	struct fcoe_transport *ft = NULL;
+	struct fcoe_ctlr_device *ctlr_dev = NULL;
+	int rc = -ENODEV;
+	int err;
+
+	mutex_lock(&ft_mutex);
+
+	netdev = fcoe_if_to_netdev(buf);
+	if (!netdev) {
+		LIBFCOE_TRANSPORT_DBG("Invalid device %s.\n", buf);
+		rc = -ENODEV;
+		goto out_nodev;
+	}
+
+	ft = fcoe_netdev_map_lookup(netdev);
+	if (ft) {
+		LIBFCOE_TRANSPORT_DBG("transport %s already has existing "
+				      "FCoE instance on %s.\n",
+				      ft->name, netdev->name);
+		rc = -EEXIST;
+		goto out_putdev;
+	}
+
+	ft = fcoe_transport_lookup(netdev);
+	if (!ft) {
+		LIBFCOE_TRANSPORT_DBG("no FCoE transport found for %s.\n",
+				      netdev->name);
+		rc = -ENODEV;
+		goto out_putdev;
+	}
+
+	/* pass to transport create */
+	err = ft->alloc ? ft->alloc(netdev) : -ENODEV;
+	if (err) {
+		fcoe_del_netdev_mapping(netdev);
+		rc = -ENOMEM;
+		goto out_putdev;
+	}
+
+	err = fcoe_add_netdev_mapping(netdev, ft);
+	if (err) {

drivers/scsi/fcoe/fcoe_ctlr.c static int libfcoe_device_notification(struct notifier_block *notifier, · line 683

Quoted 10 lines
drivers/scsi/fcoe/fcoe_ctlr.c +10 -0
+		LIBFCOE_TRANSPORT_DBG("failed to add new netdev mapping "
+				      "for FCoE transport %s for %s.\n",
+				      ft->name, netdev->name);
+		rc = -ENODEV;
+		goto out_putdev;
+	}
+
+	LIBFCOE_TRANSPORT_DBG("transport %s %s to create fcoe on %s.\n",
+			      ft->name, (ctlr_dev) ? "succeeded" : "failed",
+			      netdev->name);

Where is ctlr_dev updated? I guess you're intending to check return status of ft->alloc() here.

Quoted 112 lines
drivers/scsi/fcoe/fcoe_ctlr.c +47 -0
+
+out_putdev:
+	dev_put(netdev);
+out_nodev:
+	mutex_unlock(&ft_mutex);
+	return rc;
+}
+
+ssize_t fcoe_ctlr_destroy_store(struct bus_type *bus,
+				const char *buf, size_t count)
+{
+	int rc = -ENODEV;
+	struct net_device *netdev = NULL;
+	struct fcoe_transport *ft = NULL;
+
+	mutex_lock(&ft_mutex);
+
+	netdev = fcoe_if_to_netdev(buf);
+	if (!netdev) {
+		LIBFCOE_TRANSPORT_DBG("invalid device %s.\n", buf);
+		goto out_nodev;
+	}
+
+	ft = fcoe_netdev_map_lookup(netdev);
+	if (!ft) {
+		LIBFCOE_TRANSPORT_DBG("no FCoE transport found for %s.\n",
+				      netdev->name);
+		goto out_putdev;
+	}
+
+	/* pass to transport destroy */
+	rc = ft->destroy(netdev);
+	if (rc)
+		goto out_putdev;
+
+	fcoe_del_netdev_mapping(netdev);
+	LIBFCOE_TRANSPORT_DBG("transport %s %s to destroy fcoe on %s.\n",
+			      ft->name, (rc) ? "failed" : "succeeded",
+			      netdev->name);
+	rc = count; /* required for successful return */
+out_putdev:
+	dev_put(netdev);
+out_nodev:
+	mutex_unlock(&ft_mutex);
+	return rc;
+}
+EXPORT_SYMBOL(fcoe_ctlr_destroy_store);
 
  /**
   * fcoe_transport_create() - Create a fcoe interface
include/scsi/fcoe_sysfs.h +4 -0
index 421ae67..8c5ea70 100644
@@ -36,6 +36,9 @@ struct fcoe_sysfs_function_template {
  	void (*get_fcoe_ctlr_fcs_error)(struct fcoe_ctlr_device *);
  	void (*get_fcoe_ctlr_mode)(struct fcoe_ctlr_device *);
  	void (*set_fcoe_ctlr_mode)(struct fcoe_ctlr_device *);
+	int  (*set_fcoe_ctlr_start)(struct fcoe_ctlr_device *);
+	int  (*set_fcoe_ctlr_enable)(struct fcoe_ctlr_device *);
+	int  (*set_fcoe_ctlr_disable)(struct fcoe_ctlr_device *);
  	void (*get_fcoe_fcf_selected)(struct fcoe_fcf_device *);
  	void (*get_fcoe_fcf_vlan_id)(struct fcoe_fcf_device *);
  };
@@ -64,6 +67,7 @@ struct fcoe_ctlr_device {
 
  	int                             fcf_dev_loss_tmo;
  	enum fip_conn_type              mode;
+	u8                              started:1;
 
  	/* expected in host order for displaying */
  	struct fcoe_fc_els_lesb         lesb;
include/scsi/libfcoe.h +13 -1
index 20533cc..b19a489 100644
@@ -289,8 +289,11 @@ static inline bool is_fip_mode(struct fcoe_ctlr *fip)
   * @attached:	whether this transport is already attached
   * @list:	list linkage to all attached transports
   * @match:	handler to allow the transport driver to match up a given netdev
+ * @alloc:      handler to allocate per-instance FCoE structures
+ *		(no discovery or login)
   * @create:	handler to sysfs entry of create for FCoE instances
- * @destroy:	handler to sysfs entry of destroy for FCoE instances
+ * @destroy:    handler to delete per-instance FCoE structures
+ *		(frees all memory)
   * @enable:	handler to sysfs entry of enable for FCoE instances
   * @disable:	handler to sysfs entry of disable for FCoE instances
   */
@@ -299,6 +302,7 @@ struct fcoe_transport {
  	bool attached;
  	struct list_head list;
  	bool (*match) (struct net_device *device);
+	int (*alloc) (struct net_device *device);
  	int (*create) (struct net_device *device, enum fip_state fip_mode);
  	int (*destroy) (struct net_device *device);
  	int (*enable) (struct net_device *device);
@@ -375,4 +379,12 @@ struct fcoe_netdev_mapping {
  int fcoe_transport_attach(struct fcoe_transport *ft);
  int fcoe_transport_detach(struct fcoe_transport *ft);
 
+/* sysfs store handler for ctrl_control interface */
+ssize_t fcoe_ctlr_create_store(struct bus_type *bus,
+			       const char *buf, size_t count);
+ssize_t fcoe_ctlr_destroy_store(struct bus_type *bus,
+				const char *buf, size_t count);
+
  #endif /* _LIBFCOE_H */
+
+
#7 lore raw

RFC PATCH 3/5 fcoe: Use new fcoe_sysfs control interface

In reply to Robert Love

Convert fcoe to use the new fcoe_sysfs create, delete, enable, disable, start and mode.

---
 drivers/scsi/fcoe/fcoe.c |  229 +++++++++++++++++++++++-----------------------
 1 file changed, 115 insertions(+), 114 deletions(-)
drivers/scsi/fcoe/fcoe.c +115 -114
index fe30b1b..fe9ce98 100644
@@ -112,10 +112,10 @@ static int fcoe_dcb_app_notification(struct notifier_block *notifier,
 				     ulong event, void *ptr);
 
 static bool fcoe_match(struct net_device *netdev);
-static int fcoe_create(struct net_device *netdev, enum fip_state fip_mode);
+static int fcoe_start(struct fcoe_ctlr_device *cdev);
 static int fcoe_destroy(struct net_device *netdev);
-static int fcoe_enable(struct net_device *netdev);
-static int fcoe_disable(struct net_device *netdev);
+static int fcoe_enable(struct fcoe_ctlr_device *cdev);
+static int fcoe_disable(struct fcoe_ctlr_device *cdev);
 
 static struct fc_seq *fcoe_elsct_send(struct fc_lport *,
 				      u32 did, struct fc_frame *,
@@ -155,6 +155,10 @@ static void fcoe_ctlr_get_lesb(struct fcoe_ctlr_device *);
 static void fcoe_fcf_get_vlan_id(struct fcoe_fcf_device *);
 
 static struct fcoe_sysfs_function_template fcoe_sysfs_templ = {
+	.set_fcoe_ctlr_mode = fcoe_ctlr_set_fip_mode,
+	.set_fcoe_ctlr_start = fcoe_start,
+	.set_fcoe_ctlr_enable = fcoe_enable,
+	.set_fcoe_ctlr_disable = fcoe_disable,
 	.get_fcoe_ctlr_mode = fcoe_ctlr_get_fip_mode,
 	.get_fcoe_ctlr_link_fail = fcoe_ctlr_get_lesb,
 	.get_fcoe_ctlr_vlink_fail = fcoe_ctlr_get_lesb,
@@ -2034,105 +2038,6 @@ out:
 }
 
 /**
- * fcoe_disable() - Disables a FCoE interface
- * @netdev  : The net_device object the Ethernet interface to create on
- *
- * Called from fcoe transport.
- *
- * Returns: 0 for success
- */
-static int fcoe_disable(struct net_device *netdev)
-{
-	struct fcoe_ctlr *ctlr;
-	struct fcoe_interface *fcoe;
-	int rc = 0;
-
-	mutex_lock(&fcoe_config_mutex);
-
-	rtnl_lock();
-	fcoe = fcoe_hostlist_lookup_port(netdev);
-	rtnl_unlock();
-
-	if (fcoe) {
-		ctlr = fcoe_to_ctlr(fcoe);
-		fcoe_ctlr_link_down(ctlr);
-		fcoe_clean_pending_queue(ctlr->lp);
-	} else
-		rc = -ENODEV;
-
-	mutex_unlock(&fcoe_config_mutex);
-	return rc;
-}
-
-/**
- * fcoe_enable() - Enables a FCoE interface
- * @netdev  : The net_device object the Ethernet interface to create on
- *
- * Called from fcoe transport.
- *
- * Returns: 0 for success
- */
-static int fcoe_enable(struct net_device *netdev)
-{
-	struct fcoe_ctlr *ctlr;
-	struct fcoe_interface *fcoe;
-	int rc = 0;
-
-	mutex_lock(&fcoe_config_mutex);
-	rtnl_lock();
-	fcoe = fcoe_hostlist_lookup_port(netdev);
-	rtnl_unlock();
-
-	if (!fcoe) {
-		rc = -ENODEV;
-		goto out;
-	}
-
-	ctlr = fcoe_to_ctlr(fcoe);
-
-	if (!fcoe_link_ok(ctlr->lp))
-		fcoe_ctlr_link_up(ctlr);
-
-out:
-	mutex_unlock(&fcoe_config_mutex);
-	return rc;
-}
-
-/**
- * fcoe_destroy() - Destroy a FCoE interface
- * @netdev  : The net_device object the Ethernet interface to create on
- *
- * Called from fcoe transport
- *
- * Returns: 0 for success
- */
-static int fcoe_destroy(struct net_device *netdev)
-{
-	struct fcoe_ctlr *ctlr;
-	struct fcoe_interface *fcoe;
-	struct fc_lport *lport;
-	struct fcoe_port *port;
-	int rc = 0;
-
-	mutex_lock(&fcoe_config_mutex);
-	rtnl_lock();
-	fcoe = fcoe_hostlist_lookup_port(netdev);
-	if (!fcoe) {
-		rc = -ENODEV;
-		goto out_nodev;
-	}
-	ctlr = fcoe_to_ctlr(fcoe);
-	lport = ctlr->lp;
-	port = lport_priv(lport);
-	list_del(&fcoe->list);
-	queue_work(fcoe_wq, &port->destroy_work);
-out_nodev:
-	rtnl_unlock();
-	mutex_unlock(&fcoe_config_mutex);
-	return rc;
-}
-
-/**
  * fcoe_destroy_work() - Destroy a FCoE port in a deferred work context
  * @work: Handle to the FCoE port to be destroyed
  */
@@ -2207,18 +2112,17 @@ static void fcoe_dcb_create(struct fcoe_interface *fcoe)
 }
 
 /**
- * fcoe_create() - Create a fcoe interface
+ * fcoe_alloc() - Allocate memory for a fcoe interface
  * @netdev  : The net_device object the Ethernet interface to create on
- * @fip_mode: The FIP mode for this creation
  *
  * Called from fcoe transport
  *
  * Returns: 0 for success
  */
-static int fcoe_create(struct net_device *netdev, enum fip_state fip_mode)
+static int fcoe_alloc(struct net_device *netdev)
 {
 	int rc = 0;
-	struct fcoe_ctlr_device *ctlr_dev;
+	struct fcoe_ctlr_device *ctlr_dev = NULL;
 	struct fcoe_ctlr *ctlr;
 	struct fcoe_interface *fcoe;
 	struct fc_lport *lport;
@@ -2232,7 +2136,10 @@ static int fcoe_create(struct net_device *netdev, enum fip_state fip_mode)
 		goto out_nodev;
 	}
 
-	fcoe = fcoe_interface_create(netdev, fip_mode);
+	/*
+	 * Create the interface with the default 'Fabric' mode.
+	 */
+	fcoe = fcoe_interface_create(netdev, FIP_MODE_FABRIC);
 	if (IS_ERR(fcoe)) {
 		rc = PTR_ERR(fcoe);
 		goto out_nodev;
@@ -2250,14 +2157,36 @@ static int fcoe_create(struct net_device *netdev, enum fip_state fip_mode)
 		goto out_nortnl;
 	}
 
+	/* add to lports list */
+	fcoe_hostlist_add(lport);
+
 	/* Make this the "master" N_Port */
 	ctlr->lp = lport;
 
 	/* setup DCB priority attributes. */
 	fcoe_dcb_create(fcoe);
 
-	/* add to lports list */
-	fcoe_hostlist_add(lport);
+out_nodev:
+	rtnl_unlock();
+out_nortnl:
+	mutex_unlock(&fcoe_config_mutex);
+	return rc;
+}
+
+/**
+ * fcoe_start() - Start the controller on a fcoe interface
+ * @cdev  : The FCoE Controller Device to start
+ *
+ * Returns: 0 for success
+ */
+int fcoe_start(struct fcoe_ctlr_device *cdev)
+{
+	struct fcoe_ctlr *ctlr = fcoe_ctlr_device_priv(cdev);
+	struct fc_lport *lport = ctlr->lp;
+	int rc = 0;
+
+	mutex_lock(&fcoe_config_mutex);
+	rtnl_lock();
 
 	/* start FIP Discovery and FLOGI */
 	lport->boot_time = jiffies;
@@ -2269,14 +2198,88 @@ static int fcoe_create(struct net_device *netdev, enum fip_state fip_mode)
 		return rc;
 	}
 
-out_nodev:
 	rtnl_unlock();
-out_nortnl:
 	mutex_unlock(&fcoe_config_mutex);
+
 	return rc;
 }
 
 /**
+ * fcoe_destroy() - Destroy the controller on a fcoe interface
+ * @netdev: The netdevice associated with the controller to destroy
+ *
+ * Called from fcoe transport
+ *
+ * Returns: 0 for success
+ */
+int fcoe_destroy(struct net_device *netdev)
+{
+	struct fcoe_ctlr *ctlr;
+	struct fcoe_interface *fcoe;
+	struct fcoe_port *port;
+	int rc = 0;
+
+	mutex_lock(&fcoe_config_mutex);
+	rtnl_lock();
+
+	fcoe = fcoe_hostlist_lookup_port(netdev);
+	if (!fcoe) {
+		rc = -ENODEV;
+		goto out_nodev;
+	}
+
+	ctlr = fcoe_to_ctlr(fcoe);
+	port = lport_priv(ctlr->lp);
+	list_del(&fcoe->list);
+	queue_work(fcoe_wq, &port->destroy_work);
+
+out_nodev:
+	rtnl_unlock();
+	mutex_unlock(&fcoe_config_mutex);
+	return 0;
+}
+
+/**
+ * fcoe_enable() - Enable the controller on a fcoe interface
+ * @cdev  : The FCoE Controller Device to enable
+ *
+ * Returns: 0 for success
+ */
+int fcoe_enable(struct fcoe_ctlr_device *cdev)
+{
+	struct fcoe_ctlr *ctlr = fcoe_ctlr_device_priv(cdev);
+
+	mutex_lock(&fcoe_config_mutex);
+
+	if (!fcoe_link_ok(ctlr->lp))
+		fcoe_ctlr_link_up(ctlr);
+
+	mutex_unlock(&fcoe_config_mutex);
+
+	return 0;
+}
+
+/**
+ * fcoe_disable() - Disable the controller on a fcoe interface
+ * @cdev  : The FCoE Controller Device to disable
+ *
+ * Returns: 0 for success
+ */
+int fcoe_disable(struct fcoe_ctlr_device *cdev)
+{
+	struct fcoe_ctlr *ctlr = fcoe_ctlr_device_priv(cdev);
+
+	mutex_lock(&fcoe_config_mutex);
+
+	fcoe_ctlr_link_down(ctlr);
+	fcoe_clean_pending_queue(ctlr->lp);
+
+	mutex_unlock(&fcoe_config_mutex);
+
+	return 0;
+}
+
+/**
  * fcoe_link_speed_update() - Update the supported and actual link speeds
  * @lport: The local port to update speeds for
  *
@@ -2453,10 +2456,8 @@ static struct fcoe_transport fcoe_sw_transport = {
 	.attached = false,
 	.list = LIST_HEAD_INIT(fcoe_sw_transport.list),
 	.match = fcoe_match,
-	.create = fcoe_create,
+	.alloc = fcoe_alloc,
 	.destroy = fcoe_destroy,
-	.enable = fcoe_enable,
-	.disable = fcoe_disable,
 };
 
 /**
#8 lore raw

RFC PATCH 4/5 bnx2fc: Use new fcoe_sysfs control interface

In reply to Robert Love

Convert bnx2fc to use the new fcoe_sysfs create, delete,
enable, disable, start and mode.

bnx2fc doesn't support VN2VN. bnx2fc will not initialize the set_fcoe_ctlr_mode routine and therefore its instances will always be in FABRIC mode. There was previously an explicit check for the ctlr's mode, but this is no longer needed because not implementing set_fcoe_ctlr_mode implies that the ctlr cannot change from the FABRIC mode.

---
 drivers/scsi/bnx2fc/bnx2fc_fcoe.c |   98 +++++++++++++++++++++++--------------
 1 file changed, 60 insertions(+), 38 deletions(-)
drivers/scsi/bnx2fc/bnx2fc_fcoe.c +60 -38
index f52f668f..560c8c8 100644
@@ -56,11 +56,12 @@ static struct scsi_host_template bnx2fc_shost_template;
 static struct fc_function_template bnx2fc_transport_function;
 static struct fcoe_sysfs_function_template bnx2fc_fcoe_sysfs_templ;
 static struct fc_function_template bnx2fc_vport_xport_function;
-static int bnx2fc_create(struct net_device *netdev, enum fip_state fip_mode);
+
+static int bnx2fc_start(struct fcoe_ctlr_device *);
+static int bnx2fc_enable(struct fcoe_ctlr_device *);
+static int bnx2fc_disable(struct fcoe_ctlr_device *);
+
 static void __bnx2fc_destroy(struct bnx2fc_interface *interface);
-static int bnx2fc_destroy(struct net_device *net_device);
-static int bnx2fc_enable(struct net_device *netdev);
-static int bnx2fc_disable(struct net_device *netdev);
 
 static void bnx2fc_recv_frame(struct sk_buff *skb);
 
@@ -1594,8 +1595,7 @@ static void __bnx2fc_destroy(struct bnx2fc_interface *interface)
 /**
  * bnx2fc_destroy - Destroy a bnx2fc FCoE interface
  *
- * @buffer: The name of the Ethernet interface to be destroyed
- * @kp:     The associated kernel parameter
+ * @netdev: The name of the Ethernet interface to be destroyed
  *
  * Called from sysfs.
  *
@@ -1954,10 +1954,11 @@ static void bnx2fc_ulp_init(struct cnic_dev *dev)
 }
 
 
-static int bnx2fc_disable(struct net_device *netdev)
+static int bnx2fc_disable(struct fcoe_ctlr_device *cdev)
 {
+	struct fcoe_ctlr *ctlr = fcoe_ctlr_device_priv(cdev);
+	struct net_device *netdev = bnx2fc_netdev(ctlr->lp);
 	struct bnx2fc_interface *interface;
-	struct fcoe_ctlr *ctlr;
 	int rc = 0;
 
 	rtnl_lock();
@@ -1980,10 +1981,11 @@ static int bnx2fc_disable(struct net_device *netdev)
 }
 
 
-static int bnx2fc_enable(struct net_device *netdev)
+static int bnx2fc_enable(struct fcoe_ctlr_device *cdev)
 {
+	struct fcoe_ctlr *ctlr = fcoe_ctlr_device_priv(cdev);
+	struct net_device *netdev = bnx2fc_netdev(ctlr->lp);
 	struct bnx2fc_interface *interface;
-	struct fcoe_ctlr *ctlr;
 	int rc = 0;
 
 	rtnl_lock();
@@ -2005,17 +2007,17 @@ static int bnx2fc_enable(struct net_device *netdev)
 }
 
 /**
- * bnx2fc_create - Create bnx2fc FCoE interface
+ * bnx2fc_alloc - Alocate a bnx2fc FCoE interface
  *
- * @buffer: The name of Ethernet interface to create on
- * @kp:     The associated kernel param
+ * @netdev: The name of Ethernet interface to allocate on
  *
  * Called from sysfs.
  *
  * Returns: 0 for success
  */
-static int bnx2fc_create(struct net_device *netdev, enum fip_state fip_mode)
+static int bnx2fc_alloc(struct net_device *netdev)
 {
+	struct fcoe_ctlr_device *cdev;
 	struct fcoe_ctlr *ctlr;
 	struct bnx2fc_interface *interface;
 	struct bnx2fc_hba *hba;
@@ -2025,12 +2027,6 @@ static int bnx2fc_create(struct net_device *netdev, enum fip_state fip_mode)
 	int rc = 0;
 	int vlan_id;
 
-	BNX2FC_MISC_DBG("Entered bnx2fc_create\n");
-	if (fip_mode != FIP_MODE_FABRIC) {
-		printk(KERN_ERR "fip mode not FABRIC\n");
-		return -EIO;
-	}
-
 	rtnl_lock();
 
 	mutex_lock(&bnx2fc_dev_lock);
@@ -2077,13 +2073,17 @@ static int bnx2fc_create(struct net_device *netdev, enum fip_state fip_mode)
 		goto netdev_err;
 	}
 
-	interface = bnx2fc_interface_create(hba, netdev, fip_mode);
+	/*
+	 * Create the interface with the default 'Fabric' mode.
+	 */
+	interface = bnx2fc_interface_create(hba, netdev, FIP_MODE_FABRIC);
 	if (!interface) {
 		printk(KERN_ERR PFX "bnx2fc_interface_create failed\n");
 		goto ifput_err;
 	}
 
 	ctlr = bnx2fc_to_ctlr(interface);
+	cdev = fcoe_ctlr_to_ctlr_dev(ctlr);
 	interface->vlan_id = vlan_id;
 	interface->vlan_enabled = 1;
 
@@ -2106,20 +2106,6 @@ static int bnx2fc_create(struct net_device *netdev, enum fip_state fip_mode)
 	/* Add interface to if_list */
 	list_add_tail(&interface->list, &if_list);
 
-	lport->boot_time = jiffies;
-
-	/* Make this master N_port */
-	ctlr->lp = lport;
-
-	if (!bnx2fc_link_ok(lport)) {
-		fcoe_ctlr_link_up(ctlr);
-		fc_host_port_type(lport->host) = FC_PORTTYPE_NPORT;
-		set_bit(ADAPTER_STATE_READY, &interface->hba->adapter_state);
-	}
-
-	BNX2FC_HBA_DBG(lport, "create: START DISC\n");
-	bnx2fc_start_disc(interface);
-	interface->enabled = true;
 	/*
 	 * Release from kref_init in bnx2fc_interface_setup, on success
 	 * lport should be holding a reference taken in bnx2fc_if_create
@@ -2128,6 +2114,7 @@ static int bnx2fc_create(struct net_device *netdev, enum fip_state fip_mode)
 	/* put netdev that was held while calling dev_get_by_name */
 	mutex_unlock(&bnx2fc_dev_lock);
 	rtnl_unlock();
+
 	return 0;
 
 if_create_err:
@@ -2145,6 +2132,40 @@ mod_err:
 }
 
 /**
+ * bnx2fc_alloc - Alocate a bnx2fc FCoE interface
+ *
+ * @cdev: The FCoE Controller Device to start
+ *
+ * Called from sysfs.
+ *
+ * Returns: 0 for success
+ */
+static int bnx2fc_start(struct fcoe_ctlr_device *cdev)
+{
+	struct fcoe_ctlr *ctlr = fcoe_ctlr_device_priv(cdev);
+	struct fc_lport *lport = ctlr->lp;
+	struct fcoe_port *port = lport_priv(lport);
+	struct bnx2fc_interface *interface = port->priv;
+
+	lport->boot_time = jiffies;
+
+	/* Make this master N_port */
+	ctlr->lp = lport;
+
+	if (!bnx2fc_link_ok(lport)) {
+		fcoe_ctlr_link_up(ctlr);
+		fc_host_port_type(lport->host) = FC_PORTTYPE_NPORT;
+		set_bit(ADAPTER_STATE_READY, &interface->hba->adapter_state);
+	}
+
+	BNX2FC_HBA_DBG(lport, "create: START DISC\n");
+	bnx2fc_start_disc(interface);
+	interface->enabled = true;
+
+	return 0;
+}
+
+/**
  * bnx2fc_find_hba_for_cnic - maps cnic instance to bnx2fc hba instance
  *
  * @cnic:	Pointer to cnic device instance
@@ -2271,10 +2292,8 @@ static struct fcoe_transport bnx2fc_transport = {
 	.attached = false,
 	.list = LIST_HEAD_INIT(bnx2fc_transport.list),
 	.match = bnx2fc_match,
-	.create = bnx2fc_create,
+	.alloc = bnx2fc_alloc,
 	.destroy = bnx2fc_destroy,
-	.enable = bnx2fc_enable,
-	.disable = bnx2fc_disable,
 };
 
 /**
@@ -2514,6 +2533,9 @@ module_init(bnx2fc_mod_init);
 module_exit(bnx2fc_mod_exit);
 
 static struct fcoe_sysfs_function_template bnx2fc_fcoe_sysfs_templ = {
+	.set_fcoe_ctlr_start = bnx2fc_start,
+	.set_fcoe_ctlr_enable = bnx2fc_enable,
+	.set_fcoe_ctlr_disable = bnx2fc_disable,
 	.get_fcoe_ctlr_mode = fcoe_ctlr_get_fip_mode,
 	.get_fcoe_ctlr_link_fail = bnx2fc_ctlr_get_lesb,
 	.get_fcoe_ctlr_vlink_fail = bnx2fc_ctlr_get_lesb,
#9 lore raw

Re: [RFC PATCH 4/5] bnx2fc: Use new fcoe_sysfs control interface

Quoted 19 lines · Robert Love

Convert bnx2fc to use the new fcoe_sysfs create, delete,
enable, disable, start and mode.

bnx2fc doesn't support VN2VN. bnx2fc will not initialize the set_fcoe_ctlr_mode routine and therefore its instances will always be in FABRIC mode. There was previously an explicit check for the ctlr's mode, but this is no longer needed because not implementing set_fcoe_ctlr_mode implies that the ctlr cannot change from the FABRIC mode.

---
  drivers/scsi/bnx2fc/bnx2fc_fcoe.c |   98 +++++++++++++++++++++++--------------
  1 file changed, 60 insertions(+), 38 deletions(-)
drivers/scsi/bnx2fc/bnx2fc_fcoe.c +0 -0
index f52f668f..560c8c8 100644

<snip>

Quoted 10 lines

/**
+ * bnx2fc_alloc - Alocate a bnx2fc FCoE interface
+ *
+ * @cdev: The FCoE Controller Device to start
+ *
+ * Called from sysfs.
+ *
+ * Returns: 0 for success
+ */

drivers/scsi/bnx2fc/bnx2fc_fcoe.c +1 -0
+static int bnx2fc_start(struct fcoe_ctlr_device *cdev)

drivers/scsi/bnx2fc/bnx2fc_fcoe.c mod_err: · line 2153

Quoted 10 lines
drivers/scsi/bnx2fc/bnx2fc_fcoe.c +10 -0
+{
+	struct fcoe_ctlr *ctlr = fcoe_ctlr_device_priv(cdev);
+	struct fc_lport *lport = ctlr->lp;
+	struct fcoe_port *port = lport_priv(lport);
+	struct bnx2fc_interface *interface = port->priv;
+
+	lport->boot_time = jiffies;
+
+	/* Make this master N_port */
+	ctlr->lp = lport;

ctlr->lp should be set in bnx2fc_alloc() as we access it here in the beginning of this function.

drivers/scsi/bnx2fc/bnx2fc_fcoe.c mod_err: · line 2162

Quoted 9 lines
drivers/scsi/bnx2fc/bnx2fc_fcoe.c +9 -0
+
+	if (!bnx2fc_link_ok(lport)) {
+		fcoe_ctlr_link_up(ctlr);
+		fc_host_port_type(lport->host) = FC_PORTTYPE_NPORT;
+		set_bit(ADAPTER_STATE_READY, &interface->hba->adapter_state);
+	}
+
+	BNX2FC_HBA_DBG(lport, "create: START DISC\n");
+	bnx2fc_start_disc(interface);

I think more changes are required for bnx2fc as fc_lport_init() is called just before calling fc_fabric_login() - whcih is called during 'start'. Because of this, if we just call 'create' followed by 'destroy' without calling 'start', lport is not initialized and I expect to see some panics when destroy is called.

Let me try testing your patches and send you any fixes that are required.

Quoted 33 lines
drivers/scsi/bnx2fc/bnx2fc_fcoe.c +10 -3
+	interface->enabled = true;
+
+	return 0;
+}
+
+/**
   * bnx2fc_find_hba_for_cnic - maps cnic instance to bnx2fc hba instance
   *
   * @cnic:	Pointer to cnic device instance
@@ -2271,10 +2292,8 @@ static struct fcoe_transport bnx2fc_transport = {
  	.attached = false,
  	.list = LIST_HEAD_INIT(bnx2fc_transport.list),
  	.match = bnx2fc_match,
-	.create = bnx2fc_create,
+	.alloc = bnx2fc_alloc,
  	.destroy = bnx2fc_destroy,
-	.enable = bnx2fc_enable,
-	.disable = bnx2fc_disable,
  };
 
  /**
@@ -2514,6 +2533,9 @@ module_init(bnx2fc_mod_init);
  module_exit(bnx2fc_mod_exit);
 
  static struct fcoe_sysfs_function_template bnx2fc_fcoe_sysfs_templ = {
+	.set_fcoe_ctlr_start = bnx2fc_start,
+	.set_fcoe_ctlr_enable = bnx2fc_enable,
+	.set_fcoe_ctlr_disable = bnx2fc_disable,
  	.get_fcoe_ctlr_mode = fcoe_ctlr_get_fip_mode,
  	.get_fcoe_ctlr_link_fail = bnx2fc_ctlr_get_lesb,
  	.get_fcoe_ctlr_vlink_fail = bnx2fc_ctlr_get_lesb,
#10 lore raw

RFC PATCH 5/5 libfcoe, fcoe: Remove libfcoe module parameters

In reply to Robert Love

This patch removes the create, create_vn2vn, destroy, enable and disable module parameters. Previous patches have added these interfaces to the fcoe_sysfs layout and these misplaced interfaces are no longer necessary.

---
 drivers/scsi/fcoe/fcoe_transport.c |  211 ------------------------------------
 include/scsi/libfcoe.h             |    7 -
 2 files changed, 1 insertion(+), 217 deletions(-)
drivers/scsi/fcoe/fcoe_transport.c +1 -210
index 8e50d9a..f9e6e67 100644
@@ -32,15 +32,11 @@ MODULE_AUTHOR("Open-FCoE.org");
 MODULE_DESCRIPTION("FIP discovery protocol and FCoE transport for FCoE HBAs");
 MODULE_LICENSE("GPL v2");
 
-static int fcoe_transport_create(const char *, struct kernel_param *);
-static int fcoe_transport_destroy(const char *, struct kernel_param *);
 static int fcoe_transport_show(char *buffer, const struct kernel_param *kp);
 static struct fcoe_transport *fcoe_transport_lookup(struct net_device *device);
 static struct fcoe_transport *fcoe_netdev_map_lookup(struct net_device *device);
-static int fcoe_transport_enable(const char *, struct kernel_param *);
-static int fcoe_transport_disable(const char *, struct kernel_param *);
 static int libfcoe_device_notification(struct notifier_block *notifier,
-				    ulong event, void *ptr);
+				       ulong event, void *ptr);
 
 static LIST_HEAD(fcoe_transports);
 static DEFINE_MUTEX(ft_mutex);
@@ -55,29 +51,6 @@ module_param_call(show, NULL, fcoe_transport_show, NULL, S_IRUSR);
 __MODULE_PARM_TYPE(show, "string");
 MODULE_PARM_DESC(show, " Show attached FCoE transports");
 
-module_param_call(create, fcoe_transport_create, NULL,
-		  (void *)FIP_MODE_FABRIC, S_IWUSR);
-__MODULE_PARM_TYPE(create, "string");
-MODULE_PARM_DESC(create, " Creates fcoe instance on a ethernet interface");
-
-module_param_call(create_vn2vn, fcoe_transport_create, NULL,
-		  (void *)FIP_MODE_VN2VN, S_IWUSR);
-__MODULE_PARM_TYPE(create_vn2vn, "string");
-MODULE_PARM_DESC(create_vn2vn, " Creates a VN_node to VN_node FCoE instance "
-		 "on an Ethernet interface");
-
-module_param_call(destroy, fcoe_transport_destroy, NULL, NULL, S_IWUSR);
-__MODULE_PARM_TYPE(destroy, "string");
-MODULE_PARM_DESC(destroy, " Destroys fcoe instance on a ethernet interface");
-
-module_param_call(enable, fcoe_transport_enable, NULL, NULL, S_IWUSR);
-__MODULE_PARM_TYPE(enable, "string");
-MODULE_PARM_DESC(enable, " Enables fcoe on a ethernet interface.");
-
-module_param_call(disable, fcoe_transport_disable, NULL, NULL, S_IWUSR);
-__MODULE_PARM_TYPE(disable, "string");
-MODULE_PARM_DESC(disable, " Disables fcoe on a ethernet interface.");
-
 /* notification function for packets from net device */
 static struct notifier_block libfcoe_notifier = {
 	.notifier_call = libfcoe_device_notification,
@@ -730,188 +703,6 @@ out_nodev:
 EXPORT_SYMBOL(fcoe_ctlr_destroy_store);
 
 /**
- * fcoe_transport_create() - Create a fcoe interface
- * @buffer: The name of the Ethernet interface to create on
- * @kp:	    The associated kernel param
- *
- * Called from sysfs. This holds the ft_mutex while calling the
- * registered fcoe transport's create function.
- *
- * Returns: 0 for success
- */
-static int fcoe_transport_create(const char *buffer, struct kernel_param *kp)
-{
-	int rc = -ENODEV;
-	struct net_device *netdev = NULL;
-	struct fcoe_transport *ft = NULL;
-	enum fip_state fip_mode = (enum fip_state)(long)kp->arg;
-
-	mutex_lock(&ft_mutex);
-
-	netdev = fcoe_if_to_netdev(buffer);
-	if (!netdev) {
-		LIBFCOE_TRANSPORT_DBG("Invalid device %s.\n", buffer);
-		goto out_nodev;
-	}
-
-	ft = fcoe_netdev_map_lookup(netdev);
-	if (ft) {
-		LIBFCOE_TRANSPORT_DBG("transport %s already has existing "
-				      "FCoE instance on %s.\n",
-				      ft->name, netdev->name);
-		rc = -EEXIST;
-		goto out_putdev;
-	}
-
-	ft = fcoe_transport_lookup(netdev);
-	if (!ft) {
-		LIBFCOE_TRANSPORT_DBG("no FCoE transport found for %s.\n",
-				      netdev->name);
-		goto out_putdev;
-	}
-
-	rc = fcoe_add_netdev_mapping(netdev, ft);
-	if (rc) {
-		LIBFCOE_TRANSPORT_DBG("failed to add new netdev mapping "
-				      "for FCoE transport %s for %s.\n",
-				      ft->name, netdev->name);
-		goto out_putdev;
-	}
-
-	/* pass to transport create */
-	rc = ft->create ? ft->create(netdev, fip_mode) : -ENODEV;
-	if (rc)
-		fcoe_del_netdev_mapping(netdev);
-
-	LIBFCOE_TRANSPORT_DBG("transport %s %s to create fcoe on %s.\n",
-			      ft->name, (rc) ? "failed" : "succeeded",
-			      netdev->name);
-
-out_putdev:
-	dev_put(netdev);
-out_nodev:
-	mutex_unlock(&ft_mutex);
-	return rc;
-}
-
-/**
- * fcoe_transport_destroy() - Destroy a FCoE interface
- * @buffer: The name of the Ethernet interface to be destroyed
- * @kp:	    The associated kernel parameter
- *
- * Called from sysfs. This holds the ft_mutex while calling the
- * registered fcoe transport's destroy function.
- *
- * Returns: 0 for success
- */
-static int fcoe_transport_destroy(const char *buffer, struct kernel_param *kp)
-{
-	int rc = -ENODEV;
-	struct net_device *netdev = NULL;
-	struct fcoe_transport *ft = NULL;
-
-	mutex_lock(&ft_mutex);
-
-	netdev = fcoe_if_to_netdev(buffer);
-	if (!netdev) {
-		LIBFCOE_TRANSPORT_DBG("invalid device %s.\n", buffer);
-		goto out_nodev;
-	}
-
-	ft = fcoe_netdev_map_lookup(netdev);
-	if (!ft) {
-		LIBFCOE_TRANSPORT_DBG("no FCoE transport found for %s.\n",
-				      netdev->name);
-		goto out_putdev;
-	}
-
-	/* pass to transport destroy */
-	rc = ft->destroy ? ft->destroy(netdev) : -ENODEV;
-	fcoe_del_netdev_mapping(netdev);
-	LIBFCOE_TRANSPORT_DBG("transport %s %s to destroy fcoe on %s.\n",
-			      ft->name, (rc) ? "failed" : "succeeded",
-			      netdev->name);
-
-out_putdev:
-	dev_put(netdev);
-out_nodev:
-	mutex_unlock(&ft_mutex);
-	return rc;
-}
-
-/**
- * fcoe_transport_disable() - Disables a FCoE interface
- * @buffer: The name of the Ethernet interface to be disabled
- * @kp:	    The associated kernel parameter
- *
- * Called from sysfs.
- *
- * Returns: 0 for success
- */
-static int fcoe_transport_disable(const char *buffer, struct kernel_param *kp)
-{
-	int rc = -ENODEV;
-	struct net_device *netdev = NULL;
-	struct fcoe_transport *ft = NULL;
-
-	mutex_lock(&ft_mutex);
-
-	netdev = fcoe_if_to_netdev(buffer);
-	if (!netdev)
-		goto out_nodev;
-
-	ft = fcoe_netdev_map_lookup(netdev);
-	if (!ft)
-		goto out_putdev;
-
-	rc = ft->disable ? ft->disable(netdev) : -ENODEV;
-
-out_putdev:
-	dev_put(netdev);
-out_nodev:
-	mutex_unlock(&ft_mutex);
-
-	if (rc == -ERESTARTSYS)
-		return restart_syscall();
-	else
-		return rc;
-}
-
-/**
- * fcoe_transport_enable() - Enables a FCoE interface
- * @buffer: The name of the Ethernet interface to be enabled
- * @kp:     The associated kernel parameter
- *
- * Called from sysfs.
- *
- * Returns: 0 for success
- */
-static int fcoe_transport_enable(const char *buffer, struct kernel_param *kp)
-{
-	int rc = -ENODEV;
-	struct net_device *netdev = NULL;
-	struct fcoe_transport *ft = NULL;
-
-	mutex_lock(&ft_mutex);
-
-	netdev = fcoe_if_to_netdev(buffer);
-	if (!netdev)
-		goto out_nodev;
-
-	ft = fcoe_netdev_map_lookup(netdev);
-	if (!ft)
-		goto out_putdev;
-
-	rc = ft->enable ? ft->enable(netdev) : -ENODEV;
-
-out_putdev:
-	dev_put(netdev);
-out_nodev:
-	mutex_unlock(&ft_mutex);
-	return rc;
-}
-
-/**
  * libfcoe_init() - Initialization routine for libfcoe.ko
  */
 static int __init libfcoe_init(void)
include/scsi/libfcoe.h +0 -7
index b19a489..af2e444 100644
@@ -291,11 +291,7 @@ static inline bool is_fip_mode(struct fcoe_ctlr *fip)
  * @match:	handler to allow the transport driver to match up a given netdev
  * @alloc:      handler to allocate per-instance FCoE structures
  *		(no discovery or login)
- * @create:	handler to sysfs entry of create for FCoE instances
  * @destroy:    handler to delete per-instance FCoE structures
- *		(frees all memory)
- * @enable:	handler to sysfs entry of enable for FCoE instances
- * @disable:	handler to sysfs entry of disable for FCoE instances
  */
 struct fcoe_transport {
 	char name[IFNAMSIZ];
@@ -303,10 +299,7 @@ struct fcoe_transport {
 	struct list_head list;
 	bool (*match) (struct net_device *device);
 	int (*alloc) (struct net_device *device);
-	int (*create) (struct net_device *device, enum fip_state fip_mode);
 	int (*destroy) (struct net_device *device);
-	int (*enable) (struct net_device *device);
-	int (*disable) (struct net_device *device);
 };
 
 /**
#11 lore raw
In reply to Robert Love
Quoted 18 lines · Robert Love

The following series implements a move from using module parameters as control interfaces to /sys/bus/fcoe based interfaces. A sysfs infrastructure was added to the kernel a few cycles ago, this series builds on that work.

It moves the create, vn2vn_create, destroy, enable and disable interfaces from /sys/module/libfcoe/parameters/ to various places under /sys/bus/fcoe/. These interfaces simply are not module configurations- they are control interfaces.

A second goal of this series is to change the initialization sequence for a FCoE device. The result of this series is that interfaces created using libfcoe.ko interfaces (i.e. fcoe.ko or bnx2fc.ko) will have the following starting steps-

1) Create/alloc the port
- Allocate kernel memory and create per-instance sysfs devices
- No discovery or login

Quoted 8 lines

2) Configure the port
- Change mode, set ddp_min, etc...

3) Start the port
- Begins discovery and/or login (depending on mode)

4) Destroy the port
- Logout and free all memory

Robert, Can you please let me now what is the motivation for this change and what problem are we solving with this approach? Is this primarily to allow user to set the mode?

I'm concerned that we will be breaking user space compatibility with this change, as there should be a corresponding fcoemon/fipvlan change along with this, and existing utilities will not work. Also the way we start fcoe will be completely different and the user may need to do the scripting changes, if any.

Thanks,
Bhanu

Quoted 35 lines

I'm looking for feedback on using sysfs files as control interfaces that the user (application) would write interface names to. I modeled this series off of the bonding sysfs interface, but it was suggested to me that it might not be a good example. I belive bonding uses two values per-file a '+' or a '-" to add or delete and then the ifname apended. I am simply writing the ifname to the ctlr_create or ctlr_destroy.

Series compiled and tested against v3.5. libfcoe.ko compile warning fixed upstream after v3.5, anyone who compiles this can ignore section mismatch warning. Also note that a modified fcoemon is needed to use the fcoe system service against this kernel modification. I'd be happy to provide that fcoemon code on request.

---

Robert Love (5):
libfcoe, fcoe: Allow user to set a ctlr's mode
libfcoe: Create new libfcoe control interfaces
fcoe: Use new fcoe_sysfs control interface
bnx2fc: Use new fcoe_sysfs control interface libfcoe, fcoe: Remove libfcoe module parameters

  Documentation/ABI/testing/sysfs-bus-fcoe |   51 +++++++
  drivers/scsi/bnx2fc/bnx2fc_fcoe.c        |   98 ++++++++-----
  drivers/scsi/fcoe/fcoe.c                 |  229 +++++++++++++++---------------
  drivers/scsi/fcoe/fcoe.h                 |    9 +
  drivers/scsi/fcoe/fcoe_ctlr.c            |   24 +++
  drivers/scsi/fcoe/fcoe_sysfs.c           |  139 ++++++++++++++++++
  drivers/scsi/fcoe/fcoe_transport.c       |  174 ++++-------------------
  include/scsi/fcoe_sysfs.h                |    5 +
  include/scsi/libfcoe.h                   |   20 ++-
  9 files changed, 445 insertions(+), 304 deletions(-)
#12 lore raw
Quoted 32 lines · Bhanu Prakash Gollapudi
Quoted 31 lines · Robert Love

The following series implements a move from using module parameters as control interfaces to /sys/bus/fcoe based interfaces. A sysfs infrastructure
was added to the kernel a few cycles ago, this series builds on that work.

It moves the create, vn2vn_create, destroy, enable and disable interfaces
from /sys/module/libfcoe/parameters/ to various places under /sys/bus/fcoe/.
These interfaces simply are not module configurations- they are control interfaces.

A second goal of this series is to change the initialization sequence for
a FCoE device. The result of this series is that interfaces created using
libfcoe.ko interfaces (i.e. fcoe.ko or bnx2fc.ko) will have the following
starting steps-

1) Create/alloc the port
- Allocate kernel memory and create per-instance sysfs devices
- No discovery or login

2) Configure the port
- Change mode, set ddp_min, etc...

3) Start the port
- Begins discovery and/or login (depending on mode)

Quoted 7 lines
Quoted 2 lines

4) Destroy the port
- Logout and free all memory

Robert, Can you please let me now what is the motivation for this change and what problem are we solving with this approach? Is this primarily to allow user to set the mode?

The main problem is that our control interfaces shouldn't be module parameters. I think of module parameters as things that globally alter the module.

I also think that moving to a create/configure/start model gives us more flexibility going forward. We don't have too many FC/FCoE knobs to tune right now, but if we wanted to add more we don't have a good way to do it without starting the whole discovery/login process and then making changes during the discovery/login.

I think the module parameter problem is the justification, but I'm trying to be comprehensive in coming up with a flexible interface that will allow us to evolve as well.

Quoted 5 lines

I'm concerned that we will be breaking user space compatibility with this change, as there should be a corresponding fcoemon/fipvlan change along with this, and existing utilities will not work. Also the way we start fcoe will be completely different and the user may need to do the scripting changes, if any.

See the last statement from my initial posting (it's below). I have patches to modify fcoemon to use these new interfaces. I'd be happy to share them, I just didn't want to spam this broad of a audience.

Quoted 22 lines

Thanks,
Bhanu

Quoted 18 lines

I'm looking for feedback on using sysfs files as control interfaces that the user (application) would write interface names to. I modeled this series off of the bonding sysfs interface, but it was suggested to me that
it might not be a good example. I belive bonding uses two values per-file
a '+' or a '-" to add or delete and then the ifname apended. I am simply writing the ifname to the ctlr_create or ctlr_destroy.

Series compiled and tested against v3.5. libfcoe.ko compile warning fixed
upstream after v3.5, anyone who compiles this can ignore section mismatch
warning. Also note that a modified fcoemon is needed to use the fcoe system
service against this kernel modification. I'd be happy to provide that fcoemon code on request.

#13 lore raw
Quoted 61 lines · Robert W
Quoted 32 lines · Bhanu Prakash Gollapudi
Quoted 31 lines · Robert Love

The following series implements a move from using module parameters as control interfaces to /sys/bus/fcoe based interfaces. A sysfs infrastructure
was added to the kernel a few cycles ago, this series builds on that work.

It moves the create, vn2vn_create, destroy, enable and disable interfaces
from /sys/module/libfcoe/parameters/ to various places under /sys/bus/fcoe/.
These interfaces simply are not module configurations- they are control interfaces.

A second goal of this series is to change the initialization sequence for
a FCoE device. The result of this series is that interfaces created using
libfcoe.ko interfaces (i.e. fcoe.ko or bnx2fc.ko) will have the following
starting steps-

1) Create/alloc the port
- Allocate kernel memory and create per-instance sysfs devices
- No discovery or login

2) Configure the port
- Change mode, set ddp_min, etc...

3) Start the port
- Begins discovery and/or login (depending on mode)

Quoted 7 lines
Quoted 2 lines

4) Destroy the port
- Logout and free all memory

Robert, Can you please let me now what is the motivation for this change and what problem are we solving with this approach? Is this primarily to allow user to set the mode?

The main problem is that our control interfaces shouldn't be module parameters. I think of module parameters as things that globally alter the module.

I also think that moving to a create/configure/start model gives us more flexibility going forward. We don't have too many FC/FCoE knobs to tune right now, but if we wanted to add more we don't have a good way to do it without starting the whole discovery/login process and then making changes during the discovery/login.

I think the module parameter problem is the justification, but I'm trying to be comprehensive in coming up with a flexible interface that will allow us to evolve as well.

Quoted 5 lines

I'm concerned that we will be breaking user space compatibility with this change, as there should be a corresponding fcoemon/fipvlan change along with this, and existing utilities will not work. Also the way we start fcoe will be completely different and the user may need to do the scripting changes, if any.

Quoted 4 lines

See the last statement from my initial posting (it's below). I have patches to modify fcoemon to use these new interfaces. I'd be happy to share them, I just didn't want to spam this broad of a audience.

Thanks Robert for the explanation. Appreciate if you could share the fcoeutils patches also.

#14 lore raw
In reply to Bhanu Prakash Gollapudi
Quoted 7 lines · Bhanu Prakash Gollapudi

I'm concerned that we will be breaking user space compatibility with this change, as there should be a corresponding fcoemon/fipvlan change along with this, and existing utilities will not work. Also the way we start fcoe will be completely different and the user may need to do the scripting changes, if any.

I agree with Bhanu on these concerns, even though I hope everyone's using fcoeadm/fcoemon/fipvlan. I think there needs to be more of a transition plan than requiring everyone moving to a new kernel to update the user-space tools at the same time. Removing the module parameters with the last patch might be rushed, they should probably remain for a few kernel cycles with a warning. When the tools are updated for the new interface, they should probably maintain fallback support for the module parameters for a while as well.

- Chris

#15 lore raw
Quoted 10 lines · Chris Leech
Quoted 7 lines · Bhanu Prakash Gollapudi

I'm concerned that we will be breaking user space compatibility with this change, as there should be a corresponding fcoemon/fipvlan change along with this, and existing utilities will not work. Also the way we start fcoe will be completely different and the user may need to do the scripting changes, if any.

Quoted 9 lines

I agree with Bhanu on these concerns, even though I hope everyone's using fcoeadm/fcoemon/fipvlan. I think there needs to be more of a transition plan than requiring everyone moving to a new kernel to update the user-space tools at the same time. Removing the module parameters with the last patch might be rushed, they should probably remain for a few kernel cycles with a warning. When the tools are updated for the new interface, they should probably maintain fallback support for the module parameters for a while as well.

Deprecating the old interfaces instead of immediately removing them sounds like a good idea to me.

I hope everyone is using fcoeadm/fcoemon/fipvlan too. We do still carry the 'fcc.sh' script in fcoe-utils.git/contrib/. I don't use it, but I know others do. I did not update 'fcc.sh' with my user space change.

I'll post the fcoemon changes to [email protected]. I think I have a bunch of cleanup patches that the change depends on, so the series will probably be half cleanup and half feature.

Thanks, //Rob

#16 lore raw
In reply to Robert Love
Quoted 27 lines · Robert Love

The following series implements a move from using module parameters as control interfaces to /sys/bus/fcoe based interfaces. A sysfs infrastructure was added to the kernel a few cycles ago, this series builds on that work.

It moves the create, vn2vn_create, destroy, enable and disable interfaces from /sys/module/libfcoe/parameters/ to various places under /sys/bus/fcoe/. These interfaces simply are not module configurations- they are control interfaces.

A second goal of this series is to change the initialization sequence for a FCoE device. The result of this series is that interfaces created using libfcoe.ko interfaces (i.e. fcoe.ko or bnx2fc.ko) will have the following starting steps-

1) Create/alloc the port
- Allocate kernel memory and create per-instance sysfs devices
- No discovery or login

2) Configure the port
- Change mode, set ddp_min, etc...

3) Start the port
- Begins discovery and/or login (depending on mode)

4) Destroy the port
- Logout and free all memory

Quoted 6 lines

I'm looking for feedback on using sysfs files as control interfaces that the user (application) would write interface names to. I modeled this series off of the bonding sysfs interface, but it was suggested to me that it might not be a good example. I belive bonding uses two values per-file a '+' or a '-" to add or delete and then the ifname apended. I am simply writing the ifname to the ctlr_create or ctlr_destroy.

Can you give an example session that goes through the 4 steps above and what the sysfs hierarchy looks like at each step? I mostly get it from the patch descriptions, but I think it would help discussion of your proposed interfaces to see an example of them in use.

This feels a little awkward with all the special control files. Have you thought about something designed for creating kernel objects, like configfs? Similarly the separate start, enable, disable files vs. having some sort of status attribute that can take different values. I feel like these need to be rethought as attributes instead of triggers. Is there a big difference between start and enable? Can you achieve the split between create and start by having it come up in a disabled state by default?

That being said, I'm glad this is being reworked. Do you have any other functionality in mind that this is laying the groundwork for?

- Chris

#17 lore raw
Quoted 1 line · Chris Leech

On Mon, Sep 10, 2012 at 3:59 PM, Robert Love <[email protected]> wrote:

<snip>

Quoted 4 lines
Quoted 4 lines

1) Create/alloc the port
- Allocate kernel memory and create per-instance sysfs devices
- No discovery or login

# echo eth3.172-fcoe > /sys/bus/fcoe/ctlr_create

results in:

/sys/bus/fcoe/devices/ctlr_0/

Quoted 3 lines
Quoted 3 lines

2) Configure the port
- Change mode, set ddp_min, etc...

# echo "Fabric" > /sys/bus/fcoe/devices/ctlr_0/mode

no visible change

Quoted 3 lines
Quoted 3 lines

3) Start the port
- Begins discovery and/or login (depending on mode)

# echo 1 > /sys/bus/fcoe/devices/ctlr_0/start

Begins discovery and login. Assuming there are FCFs then results in:

/sys/bus/fcoe/devices/fcf_0

Quoted 2 lines
Quoted 2 lines

4) Destroy the port
- Logout and free all memory

# echo eth3.172-fcoe > /sys/bus/fcoe/ctlr_destroy

/sys/bus/fcoe/devices/ctlr_0 is removed.

Quoted 8 lines
Quoted 7 lines

I'm looking for feedback on using sysfs files as control interfaces that the user (application) would write interface names to. I modeled this series off of the bonding sysfs interface, but it was suggested to me that it might not be a good example. I belive bonding uses two values per-file a '+' or a '-" to add or delete and then the ifname apended. I am simply writing the ifname to the ctlr_create or ctlr_destroy.

Quoted 5 lines

Can you give an example session that goes through the 4 steps above and what the sysfs hierarchy looks like at each step? I mostly get it from the patch descriptions, but I think it would help discussion of your proposed interfaces to see an example of them in use.

See above. bash-style.

Quoted 3 lines

This feels a little awkward with all the special control files. Have you thought about something designed for creating kernel objects, like configfs? Similarly the separate start, enable, disable files vs.

Let me do some more reading about configfs. I may not have given it enough thought.

Quoted 6 lines

having some sort of status attribute that can take different values. I feel like these need to be rethought as attributes instead of triggers. Is there a big difference between start and enable? Can you achieve the split between create and start by having it come up in a disabled state by default?

It's a good idea. I'll look into it.

Quoted 3 lines

That being said, I'm glad this is being reworked. Do you have any other functionality in mind that this is laying the groundwork for?

I have one feature and a few ideas. I currently have a patch that adds a fabric selection feature. I add another RW attribute to the ctlr_X device. If the user writes fabric name to the file libfcoe uses it in it's FCF selection algorithm. Here's my commit message from that patch. I can share the patch if people would like to see it too. The current implementation also allows the user to force the login through a specific FCF.

libfcoe, bnx2fc, fcoe: Add 'selection' attribute

This patch adds a 'selection' attribute to the fcoe_ctlr_device. The user can write either a '0x' prefixed fabric name or a ':' separated MAC address to this file. If a fabric name is provided the fcoe ctlr will only consider FCFs with the fabric name when choosing a FCF to login to. If a MAC address is provided the initiator will only login to a FCF with the given Ethernet address. Only one selection is valid at a time.

There are corresponding changes to fcoe-utils
to take advantage of this kernel feature and
to make it more accessible for the user.

To accompany this feature I created a new fipfcf application based on fipvlan that sends out a discovery solicitation and displays advertising FCFs.

I've also been talking with Mark Rustad about doing an 'auto' mode where Fabric discovery is attempted first and if it fails then it tries VN2VN discovery, but so for we've only had hallway conversations about it and nothing has been flushed out.

Thanks, //Rob

#18 lore raw
Quoted 2 lines · Robert W
Quoted 1 line · Chris Leech

On Mon, Sep 10, 2012 at 3:59 PM, Robert Love <[email protected]> wrote:

<snip>

Quoted 4 lines
Quoted 3 lines

That being said, I'm glad this is being reworked. Do you have any other functionality in mind that this is laying the groundwork for?

Quoted 8 lines

I have one feature and a few ideas. I currently have a patch that adds a fabric selection feature. I add another RW attribute to the ctlr_X device. If the user writes fabric name to the file libfcoe uses it in it's FCF selection algorithm. Here's my commit message from that patch. I can share the patch if people would like to see it too. The current implementation also allows the user to force the login through a specific FCF.

My fcoe-utils.git change here also allows the user to drive this fabric selection using a new variable in the /etc/fcoe/cfg-ethX files that the 'fcoe service' uses.

#19 lore raw
In reply to Love, Robert W
Quoted 11 lines · Robert W
Quoted 1 line · Chris Leech

On Mon, Sep 10, 2012 at 3:59 PM, Robert Love <[email protected]> wrote:

<snip>

Quoted 4 lines
Quoted 4 lines

1) Create/alloc the port
- Allocate kernel memory and create per-instance sysfs devices
- No discovery or login

# echo eth3.172-fcoe > /sys/bus/fcoe/ctlr_create

I'm assuming the existing functionality of automatically creating the vlan interface by fcoemon (using the cfg-ethX) continues to exist and the above is not a replacement for fcoeadm -c.

Quoted 17 lines

results in:

/sys/bus/fcoe/devices/ctlr_0/

Quoted 3 lines
Quoted 3 lines

2) Configure the port
- Change mode, set ddp_min, etc...

# echo "Fabric" > /sys/bus/fcoe/devices/ctlr_0/mode

no visible change

Quoted 3 lines
Quoted 3 lines

3) Start the port
- Begins discovery and/or login (depending on mode)

Quoted 5 lines
# echo 1 > /sys/bus/fcoe/devices/ctlr_0/start

Begins discovery and login. Assuming there are FCFs then results in:

/sys/bus/fcoe/devices/fcf_0

I'm also assuming that the above three steps can be clubbed by fcoeutils, perhaps by adding 'mode' parameter into the cfg-ethX file. That way 'service fcoe start' will be no different with the proposed model, except that there will be multiple entry points into the driver (alloc, config, start) instead of just one (create).

Quoted 72 lines
Quoted 3 lines
Quoted 3 lines

4) Destroy the port
- Logout and free all memory

# echo eth3.172-fcoe > /sys/bus/fcoe/ctlr_destroy

/sys/bus/fcoe/devices/ctlr_0 is removed.

Quoted 8 lines
Quoted 7 lines

I'm looking for feedback on using sysfs files as control interfaces that the user (application) would write interface names to. I modeled this series off of the bonding sysfs interface, but it was suggested to me that it might not be a good example. I belive bonding uses two values per-file a '+' or a '-" to add or delete and then the ifname apended. I am simply writing the ifname to the ctlr_create or ctlr_destroy.

Quoted 5 lines

Can you give an example session that goes through the 4 steps above and what the sysfs hierarchy looks like at each step? I mostly get it from the patch descriptions, but I think it would help discussion of your proposed interfaces to see an example of them in use.

See above. bash-style.

Quoted 3 lines

This feels a little awkward with all the special control files. Have you thought about something designed for creating kernel objects, like configfs? Similarly the separate start, enable, disable files vs.

Let me do some more reading about configfs. I may not have given it enough thought.

Quoted 6 lines

having some sort of status attribute that can take different values. I feel like these need to be rethought as attributes instead of triggers. Is there a big difference between start and enable? Can you achieve the split between create and start by having it come up in a disabled state by default?

It's a good idea. I'll look into it.

Quoted 3 lines

That being said, I'm glad this is being reworked. Do you have any other functionality in mind that this is laying the groundwork for?

I have one feature and a few ideas. I currently have a patch that adds a fabric selection feature. I add another RW attribute to the ctlr_X device. If the user writes fabric name to the file libfcoe uses it in it's FCF selection algorithm. Here's my commit message from that patch. I can share the patch if people would like to see it too. The current implementation also allows the user to force the login through a specific FCF.

libfcoe, bnx2fc, fcoe: Add 'selection' attribute

This patch adds a 'selection' attribute to the fcoe_ctlr_device. The user can write either a '0x' prefixed fabric name or a ':' separated MAC address to this file. If a fabric name is provided the fcoe ctlr will only consider FCFs with the fabric name when choosing a FCF to login to. If a MAC address is provided the initiator will only login to a FCF with the given Ethernet address. Only one selection is valid at a time.

There are corresponding changes to fcoe-utils to take advantage of this kernel feature and to make it more accessible for the user.

To accompany this feature I created a new fipfcf application based on fipvlan that sends out a discovery solicitation and displays advertising FCFs.

Quoted 7 lines

I've also been talking with Mark Rustad about doing an 'auto' mode where Fabric discovery is attempted first and if it fails then it tries VN2VN discovery, but so for we've only had hallway conversations about it and nothing has been flushed out.

Thanks, //Rob�{.n�+�������+%��lzwm��b�맲��r��zX���(����ܨ}���Ơz�&j:+v�������zZ+��+zf���h���~����i���z��w���?����&�)ߢf

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

#20 lore raw
Quoted 12 lines · Bhanu Prakash Gollapudi
Quoted 11 lines · Robert W
Quoted 2 lines · Chris Leech

On Mon, Sep 10, 2012 at 3:59 PM, Robert Love
<[email protected]> wrote:

<snip>

Quoted 4 lines
Quoted 4 lines

1) Create/alloc the port
- Allocate kernel memory and create per-instance sysfs devices
- No discovery or login

Quoted 6 lines
Quoted 1 line
# echo eth3.172-fcoe > /sys/bus/fcoe/ctlr_create

I'm assuming the existing functionality of automatically creating the vlan interface by fcoemon (using the cfg-ethX) continues to exist and the above is not a replacement for fcoeadm -c.

Yes, you're right. These examples are only if you were using the interfaces from BASH. It's all coded up for fcoemon and there shouldn't be any user experience change with the new code. I'll post that code to [email protected] once I get it rebased and quickly tested.

Quoted 21 lines
Quoted 21 lines

results in:

/sys/bus/fcoe/devices/ctlr_0/

Quoted 3 lines
Quoted 3 lines

2) Configure the port
- Change mode, set ddp_min, etc...

# echo "Fabric" > /sys/bus/fcoe/devices/ctlr_0/mode

no visible change

Quoted 3 lines
Quoted 3 lines

3) Start the port
- Begins discovery and/or login (depending on mode)

# echo 1 > /sys/bus/fcoe/devices/ctlr_0/start

Begins discovery and login. Assuming there are FCFs then results in:

Quoted 8 lines
Quoted 1 line

/sys/bus/fcoe/devices/fcf_0

I'm also assuming that the above three steps can be clubbed by fcoeutils, perhaps by adding 'mode' parameter into the cfg-ethX file. That way 'service fcoe start' will be no different with the proposed model, except that there will be multiple entry points into the driver (alloc, config, start) instead of just one (create).

Yes, you're right here too. However, the default is 'Fabric' so fcoemon won't actually have to change the mode. However, I'd like to see VN2VN support added to fcoeadm/fcoemon. It's on the TODO list. Once that's implemented fcoemon would need to change the mode depending on the user's selection.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#22 lore raw
Quoted 2 lines · Robert W
Quoted 1 line · Chris Leech

On Mon, Sep 10, 2012 at 3:59 PM, Robert Love <[email protected]> wrote:

<snip>

Quoted 5 lines

This feels a little awkward with all the special control files. Have you thought about something designed for creating kernel objects, like configfs? Similarly the separate start, enable, disable files vs. Let me do some more reading about configfs. I may not have given it enough thought.

I read though the configfs documentation and the fact that it's designed for user driven object creation does fit with what I'm trying to do. I have a couple concerns that I'm trying to sort through now-

1) This adds a new dependency for boot. I don't know if that is a problem or not. Are there any examples of configfs being mounted in an initrd?

2) Using configfs would likely mean that I'd be creating controller instances and possibly FCF instances in configfs, since they're already there in sysfs these objects would be duplicated. I'm not sure there's harm in that, but it certainly feels disjointed and messy. I suppose we could remove the /sys/bus/fcoe stuff in favor of configfs if it's the right thing to do.

Thanks, //Rob