From: Robert Love <robert.w.love@intel.com>
To: netdev@vger.kernel.org, gregkh@linuxfoundation.org,
linux-scsi@vger.kernel.org, bprakash@broadcom.com
Cc: devel@open-fcoe.org
Subject: [RFC PATCH 3/5] fcoe: Use new fcoe_sysfs control interface
Date: Mon, 10 Sep 2012 15:59:25 -0700 [thread overview]
Message-ID: <20120910225924.13140.84794.stgit@fritz> (raw)
In-Reply-To: <20120910225908.13140.97277.stgit@fritz>
Convert fcoe to use the new fcoe_sysfs create, delete,
enable, disable, start and mode.
Signed-off-by: Robert Love <robert.w.love@intel.com>
---
drivers/scsi/fcoe/fcoe.c | 229 +++++++++++++++++++++++-----------------------
1 file changed, 115 insertions(+), 114 deletions(-)
diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c
index fe30b1b..fe9ce98 100644
--- a/drivers/scsi/fcoe/fcoe.c
+++ b/drivers/scsi/fcoe/fcoe.c
@@ -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,
};
/**
next prev parent reply other threads:[~2012-09-10 22:59 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-10 22:59 [RFC PATCH 0/5] Reorganize libfcoe control interfaces Robert Love
2012-09-10 22:59 ` [RFC PATCH 1/5] libfcoe, fcoe: Allow user to set a ctlr's mode Robert Love
2012-09-10 23:12 ` Greg KH
2012-09-11 5:51 ` Bart Van Assche
2012-09-12 19:24 ` Love, Robert W
2012-09-10 22:59 ` [RFC PATCH 2/5] libfcoe: Create new libfcoe control interfaces Robert Love
2012-09-14 7:06 ` Bhanu Prakash Gollapudi
2012-09-10 22:59 ` Robert Love [this message]
2012-09-10 22:59 ` [RFC PATCH 4/5] bnx2fc: Use new fcoe_sysfs control interface Robert Love
2012-09-14 7:28 ` Bhanu Prakash Gollapudi
2012-09-10 22:59 ` [RFC PATCH 5/5] libfcoe, fcoe: Remove libfcoe module parameters Robert Love
2012-09-11 0:05 ` [RFC PATCH 0/5] Reorganize libfcoe control interfaces Bhanu Prakash Gollapudi
2012-09-11 1:41 ` Love, Robert W
2012-09-11 5:46 ` Bhanu Prakash Gollapudi
2012-09-11 17:12 ` Chris Leech
2012-09-11 17:43 ` Love, Robert W
2012-09-11 17:06 ` Chris Leech
2012-09-11 17:36 ` Love, Robert W
2012-09-11 17:46 ` [Open-FCoE] " Love, Robert W
2012-09-11 18:31 ` Bhanu Prakash Gollapudi
2012-09-11 18:47 ` Love, Robert W
[not found] ` <504F76A1.50809-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2012-09-12 19:35 ` Love, Robert W
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120910225924.13140.84794.stgit@fritz \
--to=robert.w.love@intel.com \
--cc=bprakash@broadcom.com \
--cc=devel@open-fcoe.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-scsi@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).