aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/fcoe/libfcoe.c
diff options
context:
space:
mode:
authorVasu Dev <vasu.dev@intel.com>2009-03-17 14:42:18 -0400
committerJames Bottomley <James.Bottomley@HansenPartnership.com>2009-04-03 10:23:05 -0400
commit5e80f7f7c87990ffe7856a0d35a94ea52b8f4c59 (patch)
treeda71459b4bfa17c9b3f7f0bb63fd07aee2c702cf /drivers/scsi/fcoe/libfcoe.c
parent9b34ecffd59d6ed66fdd6906e8a092a33e7c8564 (diff)
[SCSI] fcoe: moves common FCoE library API functions to libfcoe module
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> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Diffstat (limited to 'drivers/scsi/fcoe/libfcoe.c')
-rw-r--r--drivers/scsi/fcoe/libfcoe.c67
1 files changed, 67 insertions, 0 deletions
diff --git a/drivers/scsi/fcoe/libfcoe.c b/drivers/scsi/fcoe/libfcoe.c
index 17acbcc025aa..dff97fcf8837 100644
--- a/drivers/scsi/fcoe/libfcoe.c
+++ b/drivers/scsi/fcoe/libfcoe.c
@@ -18,7 +18,74 @@
18 */ 18 */
19 19
20#include <linux/module.h> 20#include <linux/module.h>
21#include <linux/netdevice.h>
22
23#include <scsi/libfc.h>
21 24
22MODULE_AUTHOR("Open-FCoE.org"); 25MODULE_AUTHOR("Open-FCoE.org");
23MODULE_DESCRIPTION("FCoE"); 26MODULE_DESCRIPTION("FCoE");
24MODULE_LICENSE("GPL v2"); 27MODULE_LICENSE("GPL v2");
28
29/**
30 * fcoe_wwn_from_mac() - Converts 48-bit IEEE MAC address to 64-bit FC WWN.
31 * @mac: mac address
32 * @scheme: check port
33 * @port: port indicator for converting
34 *
35 * Returns: u64 fc world wide name
36 */
37u64 fcoe_wwn_from_mac(unsigned char mac[MAX_ADDR_LEN],
38 unsigned int scheme, unsigned int port)
39{
40 u64 wwn;
41 u64 host_mac;
42
43 /* The MAC is in NO, so flip only the low 48 bits */
44 host_mac = ((u64) mac[0] << 40) |
45 ((u64) mac[1] << 32) |
46 ((u64) mac[2] << 24) |
47 ((u64) mac[3] << 16) |
48 ((u64) mac[4] << 8) |
49 (u64) mac[5];
50
51 WARN_ON(host_mac >= (1ULL << 48));
52 wwn = host_mac | ((u64) scheme << 60);
53 switch (scheme) {
54 case 1:
55 WARN_ON(port != 0);
56 break;
57 case 2:
58 WARN_ON(port >= 0xfff);
59 wwn |= (u64) port << 48;
60 break;
61 default:
62 WARN_ON(1);
63 break;
64 }
65
66 return wwn;
67}
68EXPORT_SYMBOL_GPL(fcoe_wwn_from_mac);
69
70/**
71 * fcoe_libfc_config() - sets up libfc related properties for lport
72 * @lp: ptr to the fc_lport
73 * @tt: libfc function template
74 *
75 * Returns : 0 for success
76 */
77int fcoe_libfc_config(struct fc_lport *lp, struct libfc_function_template *tt)
78{
79 /* Set the function pointers set by the LLDD */
80 memcpy(&lp->tt, tt, sizeof(*tt));
81 if (fc_fcp_init(lp))
82 return -ENOMEM;
83 fc_exch_init(lp);
84 fc_elsct_init(lp);
85 fc_lport_init(lp);
86 fc_rport_init(lp);
87 fc_disc_init(lp);
88
89 return 0;
90}
91EXPORT_SYMBOL_GPL(fcoe_libfc_config);