diff options
author | Vasu Dev <vasu.dev@intel.com> | 2009-03-17 14:42:18 -0400 |
---|---|---|
committer | James Bottomley <James.Bottomley@HansenPartnership.com> | 2009-04-03 10:23:05 -0400 |
commit | 5e80f7f7c87990ffe7856a0d35a94ea52b8f4c59 (patch) | |
tree | da71459b4bfa17c9b3f7f0bb63fd07aee2c702cf /drivers | |
parent | 9b34ecffd59d6ed66fdd6906e8a092a33e7c8564 (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')
-rw-r--r-- | drivers/scsi/fcoe/fcoe.c | 64 | ||||
-rw-r--r-- | 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 23983c789429..42eee5b7e5c5 100644 --- a/drivers/scsi/fcoe/fcoe.c +++ b/drivers/scsi/fcoe/fcoe.c | |||
@@ -1766,47 +1766,6 @@ int fcoe_reset(struct Scsi_Host *shost) | |||
1766 | EXPORT_SYMBOL_GPL(fcoe_reset); | 1766 | EXPORT_SYMBOL_GPL(fcoe_reset); |
1767 | 1767 | ||
1768 | /** | 1768 | /** |
1769 | * fcoe_wwn_from_mac() - Converts 48-bit IEEE MAC address to 64-bit FC WWN. | ||
1770 | * @mac: mac address | ||
1771 | * @scheme: check port | ||
1772 | * @port: port indicator for converting | ||
1773 | * | ||
1774 | * Returns: u64 fc world wide name | ||
1775 | */ | ||
1776 | u64 fcoe_wwn_from_mac(unsigned char mac[MAX_ADDR_LEN], | ||
1777 | unsigned int scheme, unsigned int port) | ||
1778 | { | ||
1779 | u64 wwn; | ||
1780 | u64 host_mac; | ||
1781 | |||
1782 | /* The MAC is in NO, so flip only the low 48 bits */ | ||
1783 | host_mac = ((u64) mac[0] << 40) | | ||
1784 | ((u64) mac[1] << 32) | | ||
1785 | ((u64) mac[2] << 24) | | ||
1786 | ((u64) mac[3] << 16) | | ||
1787 | ((u64) mac[4] << 8) | | ||
1788 | (u64) mac[5]; | ||
1789 | |||
1790 | WARN_ON(host_mac >= (1ULL << 48)); | ||
1791 | wwn = host_mac | ((u64) scheme << 60); | ||
1792 | switch (scheme) { | ||
1793 | case 1: | ||
1794 | WARN_ON(port != 0); | ||
1795 | break; | ||
1796 | case 2: | ||
1797 | WARN_ON(port >= 0xfff); | ||
1798 | wwn |= (u64) port << 48; | ||
1799 | break; | ||
1800 | default: | ||
1801 | WARN_ON(1); | ||
1802 | break; | ||
1803 | } | ||
1804 | |||
1805 | return wwn; | ||
1806 | } | ||
1807 | EXPORT_SYMBOL_GPL(fcoe_wwn_from_mac); | ||
1808 | |||
1809 | /** | ||
1810 | * fcoe_hostlist_lookup_softc() - find the corresponding lport by a given device | 1769 | * fcoe_hostlist_lookup_softc() - find the corresponding lport by a given device |
1811 | * @device: this is currently ptr to net_device | 1770 | * @device: this is currently ptr to net_device |
1812 | * | 1771 | * |
@@ -1886,29 +1845,6 @@ int fcoe_hostlist_remove(const struct fc_lport *lp) | |||
1886 | EXPORT_SYMBOL_GPL(fcoe_hostlist_remove); | 1845 | EXPORT_SYMBOL_GPL(fcoe_hostlist_remove); |
1887 | 1846 | ||
1888 | /** | 1847 | /** |
1889 | * fcoe_libfc_config() - sets up libfc related properties for lport | ||
1890 | * @lp: ptr to the fc_lport | ||
1891 | * @tt: libfc function template | ||
1892 | * | ||
1893 | * Returns : 0 for success | ||
1894 | */ | ||
1895 | int fcoe_libfc_config(struct fc_lport *lp, struct libfc_function_template *tt) | ||
1896 | { | ||
1897 | /* Set the function pointers set by the LLDD */ | ||
1898 | memcpy(&lp->tt, tt, sizeof(*tt)); | ||
1899 | if (fc_fcp_init(lp)) | ||
1900 | return -ENOMEM; | ||
1901 | fc_exch_init(lp); | ||
1902 | fc_elsct_init(lp); | ||
1903 | fc_lport_init(lp); | ||
1904 | fc_rport_init(lp); | ||
1905 | fc_disc_init(lp); | ||
1906 | |||
1907 | return 0; | ||
1908 | } | ||
1909 | EXPORT_SYMBOL_GPL(fcoe_libfc_config); | ||
1910 | |||
1911 | /** | ||
1912 | * fcoe_init() - fcoe module loading initialization | 1848 | * fcoe_init() - fcoe module loading initialization |
1913 | * | 1849 | * |
1914 | * Returns 0 on success, negative on failure | 1850 | * Returns 0 on success, negative on failure |
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 | ||
22 | MODULE_AUTHOR("Open-FCoE.org"); | 25 | MODULE_AUTHOR("Open-FCoE.org"); |
23 | MODULE_DESCRIPTION("FCoE"); | 26 | MODULE_DESCRIPTION("FCoE"); |
24 | MODULE_LICENSE("GPL v2"); | 27 | MODULE_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 | */ | ||
37 | u64 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 | } | ||
68 | EXPORT_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 | */ | ||
77 | int 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 | } | ||
91 | EXPORT_SYMBOL_GPL(fcoe_libfc_config); | ||