From: Robert Love <robert.w.love@intel.com>
To: James.Bottomley@HansenPartnership.com, linux-scsi@vger.kernel.org
Subject: [PATCH 10/14] fcoe: moves common FCoE library API functions to libfcoe module
Date: Tue, 17 Mar 2009 11:42:18 -0700 [thread overview]
Message-ID: <20090317184218.22987.4843.stgit@fritz> (raw)
In-Reply-To: <20090317184124.22987.65368.stgit@fritz>
From: Vasu Dev <vasu.dev@intel.com>
Moves these functions as-is from fcoe.c to libfcoe.c, since
they're are common routines:
- fcoe_wwn_from_mac
- fcoe_libfc_config
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
---
drivers/scsi/fcoe/fcoe.c | 64 -----------------------------------------
drivers/scsi/fcoe/libfcoe.c | 67 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 67 insertions(+), 64 deletions(-)
diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c
index af40410..e9c3d26 100644
--- a/drivers/scsi/fcoe/fcoe.c
+++ b/drivers/scsi/fcoe/fcoe.c
@@ -1755,47 +1755,6 @@ int fcoe_reset(struct Scsi_Host *shost)
EXPORT_SYMBOL_GPL(fcoe_reset);
/**
- * fcoe_wwn_from_mac() - Converts 48-bit IEEE MAC address to 64-bit FC WWN.
- * @mac: mac address
- * @scheme: check port
- * @port: port indicator for converting
- *
- * Returns: u64 fc world wide name
- */
-u64 fcoe_wwn_from_mac(unsigned char mac[MAX_ADDR_LEN],
- unsigned int scheme, unsigned int port)
-{
- u64 wwn;
- u64 host_mac;
-
- /* The MAC is in NO, so flip only the low 48 bits */
- host_mac = ((u64) mac[0] << 40) |
- ((u64) mac[1] << 32) |
- ((u64) mac[2] << 24) |
- ((u64) mac[3] << 16) |
- ((u64) mac[4] << 8) |
- (u64) mac[5];
-
- WARN_ON(host_mac >= (1ULL << 48));
- wwn = host_mac | ((u64) scheme << 60);
- switch (scheme) {
- case 1:
- WARN_ON(port != 0);
- break;
- case 2:
- WARN_ON(port >= 0xfff);
- wwn |= (u64) port << 48;
- break;
- default:
- WARN_ON(1);
- break;
- }
-
- return wwn;
-}
-EXPORT_SYMBOL_GPL(fcoe_wwn_from_mac);
-
-/**
* fcoe_hostlist_lookup_softc() - find the corresponding lport by a given device
* @device: this is currently ptr to net_device
*
@@ -1875,29 +1834,6 @@ int fcoe_hostlist_remove(const struct fc_lport *lp)
EXPORT_SYMBOL_GPL(fcoe_hostlist_remove);
/**
- * fcoe_libfc_config() - sets up libfc related properties for lport
- * @lp: ptr to the fc_lport
- * @tt: libfc function template
- *
- * Returns : 0 for success
- */
-int fcoe_libfc_config(struct fc_lport *lp, struct libfc_function_template *tt)
-{
- /* Set the function pointers set by the LLDD */
- memcpy(&lp->tt, tt, sizeof(*tt));
- if (fc_fcp_init(lp))
- return -ENOMEM;
- fc_exch_init(lp);
- fc_elsct_init(lp);
- fc_lport_init(lp);
- fc_rport_init(lp);
- fc_disc_init(lp);
-
- return 0;
-}
-EXPORT_SYMBOL_GPL(fcoe_libfc_config);
-
-/**
* fcoe_init() - fcoe module loading initialization
*
* Returns 0 on success, negative on failure
diff --git a/drivers/scsi/fcoe/libfcoe.c b/drivers/scsi/fcoe/libfcoe.c
index 17acbcc..dff97fc 100644
--- a/drivers/scsi/fcoe/libfcoe.c
+++ b/drivers/scsi/fcoe/libfcoe.c
@@ -18,7 +18,74 @@
*/
#include <linux/module.h>
+#include <linux/netdevice.h>
+
+#include <scsi/libfc.h>
MODULE_AUTHOR("Open-FCoE.org");
MODULE_DESCRIPTION("FCoE");
MODULE_LICENSE("GPL v2");
+
+/**
+ * fcoe_wwn_from_mac() - Converts 48-bit IEEE MAC address to 64-bit FC WWN.
+ * @mac: mac address
+ * @scheme: check port
+ * @port: port indicator for converting
+ *
+ * Returns: u64 fc world wide name
+ */
+u64 fcoe_wwn_from_mac(unsigned char mac[MAX_ADDR_LEN],
+ unsigned int scheme, unsigned int port)
+{
+ u64 wwn;
+ u64 host_mac;
+
+ /* The MAC is in NO, so flip only the low 48 bits */
+ host_mac = ((u64) mac[0] << 40) |
+ ((u64) mac[1] << 32) |
+ ((u64) mac[2] << 24) |
+ ((u64) mac[3] << 16) |
+ ((u64) mac[4] << 8) |
+ (u64) mac[5];
+
+ WARN_ON(host_mac >= (1ULL << 48));
+ wwn = host_mac | ((u64) scheme << 60);
+ switch (scheme) {
+ case 1:
+ WARN_ON(port != 0);
+ break;
+ case 2:
+ WARN_ON(port >= 0xfff);
+ wwn |= (u64) port << 48;
+ break;
+ default:
+ WARN_ON(1);
+ break;
+ }
+
+ return wwn;
+}
+EXPORT_SYMBOL_GPL(fcoe_wwn_from_mac);
+
+/**
+ * fcoe_libfc_config() - sets up libfc related properties for lport
+ * @lp: ptr to the fc_lport
+ * @tt: libfc function template
+ *
+ * Returns : 0 for success
+ */
+int fcoe_libfc_config(struct fc_lport *lp, struct libfc_function_template *tt)
+{
+ /* Set the function pointers set by the LLDD */
+ memcpy(&lp->tt, tt, sizeof(*tt));
+ if (fc_fcp_init(lp))
+ return -ENOMEM;
+ fc_exch_init(lp);
+ fc_elsct_init(lp);
+ fc_lport_init(lp);
+ fc_rport_init(lp);
+ fc_disc_init(lp);
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(fcoe_libfc_config);
next prev parent reply other threads:[~2009-03-17 18:42 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-17 18:41 [PATCH 00/14] Open-FCoE fixes and features for 2.6.30 merge window Robert Love
2009-03-17 18:41 ` [PATCH 01/14] fcoe: Initialize all possilbe skb_queue(s) when module is loaded Robert Love
2009-03-17 18:41 ` [PATCH 02/14] fcoe: Use percpu kernel funcs for struct fcoe_percpu_s Robert Love
2009-03-17 18:41 ` [PATCH 03/14] fcoe: Use per-CPU kernel function for dev_stats instead of an array Robert Love
2009-03-31 22:51 ` [PATCH 3/14 v2] " Robert Love
2009-03-17 18:41 ` [PATCH 04/14] fcoe: create/destroy fcoe Rx threads on CPU hotplug events Robert Love
2009-03-23 0:59 ` James Bottomley
2009-03-23 19:42 ` Robert Love
2009-03-24 3:50 ` James Bottomley
2009-03-17 18:41 ` [PATCH 05/14] fcoe: prep work to completely remove fc_transport_fcoe code Robert Love
2009-03-24 23:19 ` [PATCH] " Robert Love
2009-03-26 3:03 ` [PATCH] PM port setting and attached SATA port selector in discover Andy Yan
2009-03-27 16:52 ` James Bottomley
2009-03-27 16:03 ` [PATCH] fcoe: prep work to completely remove fc_transport_fcoe code Robert Love
2009-03-27 16:12 ` Love, Robert W
2009-03-17 18:41 ` [PATCH 06/14] fcoe: removes fc_transport_fcoe.[ch] code files Robert Love
2009-03-24 23:24 ` [PATCH] " Robert Love
2009-03-27 16:05 ` Robert Love
2009-03-17 18:42 ` [PATCH 07/14] fcoe: removes default sw transport code file fcoe_sw.c Robert Love
2009-03-24 23:27 ` [PATCH] " Robert Love
2009-03-27 16:06 ` Robert Love
2009-03-17 18:42 ` [PATCH 08/14] fcoe: renames libfcoe.c to fcoe.c as the only fcoe module file Robert Love
2009-03-24 23:27 ` [PATCH] " Robert Love
2009-03-27 16:07 ` Robert Love
2009-03-17 18:42 ` [PATCH 09/14] fcoe, libfc, scsi: adds libfcoe module Robert Love
2009-03-17 18:42 ` Robert Love [this message]
2009-03-17 18:42 ` [PATCH 11/14] fcoe: cleans up libfcoe.h and adds fcoe.h for fcoe module Robert Love
2009-03-17 18:42 ` [PATCH 12/14] fcoe, libfc: fix double fcoe_softc memory alloc Robert Love
2009-03-17 18:42 ` [PATCH 13/14] fcoe: Add a header file defining the FIP protocol for FCoE Robert Love
2009-03-17 18:42 ` [PATCH 14/14] fcoe, libfcoe: Add support for FIP. FCoE discovery and keep-alive Robert Love
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=20090317184218.22987.4843.stgit@fritz \
--to=robert.w.love@intel.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=linux-scsi@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