aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
diff options
context:
space:
mode:
authorJames Bottomley <JBottomley@Parallels.com>2013-03-01 04:09:51 -0500
committerJames Bottomley <JBottomley@Parallels.com>2013-03-01 04:10:08 -0500
commit3e34c1fc2b51f117045e4a2472572f14ac91df6e (patch)
tree12c7c79931e657483f965bc944861bc8a6a9694d /drivers/scsi/bnx2fc/bnx2fc_fcoe.c
parentc157750a901d767ecb95f1dbabd0972dee396b1e (diff)
parent1f953b0dbc2549318afcc0a70af5542dffbce34a (diff)
[SCSI] Merge tag 'fcoe-02-19-13' into for-linus
FCoE Updates for 3.9 Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers/scsi/bnx2fc/bnx2fc_fcoe.c')
-rw-r--r--drivers/scsi/bnx2fc/bnx2fc_fcoe.c256
1 files changed, 149 insertions, 107 deletions
diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
index 6401db494ef5..2daf4b0da434 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
@@ -62,6 +62,10 @@ static int bnx2fc_destroy(struct net_device *net_device);
62static int bnx2fc_enable(struct net_device *netdev); 62static int bnx2fc_enable(struct net_device *netdev);
63static int bnx2fc_disable(struct net_device *netdev); 63static int bnx2fc_disable(struct net_device *netdev);
64 64
65/* fcoe_syfs control interface handlers */
66static int bnx2fc_ctlr_alloc(struct net_device *netdev);
67static int bnx2fc_ctlr_enabled(struct fcoe_ctlr_device *cdev);
68
65static void bnx2fc_recv_frame(struct sk_buff *skb); 69static void bnx2fc_recv_frame(struct sk_buff *skb);
66 70
67static void bnx2fc_start_disc(struct bnx2fc_interface *interface); 71static void bnx2fc_start_disc(struct bnx2fc_interface *interface);
@@ -89,7 +93,6 @@ static void bnx2fc_port_shutdown(struct fc_lport *lport);
89static void bnx2fc_stop(struct bnx2fc_interface *interface); 93static void bnx2fc_stop(struct bnx2fc_interface *interface);
90static int __init bnx2fc_mod_init(void); 94static int __init bnx2fc_mod_init(void);
91static void __exit bnx2fc_mod_exit(void); 95static void __exit bnx2fc_mod_exit(void);
92static void bnx2fc_ctlr_get_lesb(struct fcoe_ctlr_device *ctlr_dev);
93 96
94unsigned int bnx2fc_debug_level; 97unsigned int bnx2fc_debug_level;
95module_param_named(debug_logging, bnx2fc_debug_level, int, S_IRUGO|S_IWUSR); 98module_param_named(debug_logging, bnx2fc_debug_level, int, S_IRUGO|S_IWUSR);
@@ -107,44 +110,6 @@ static inline struct net_device *bnx2fc_netdev(const struct fc_lport *lport)
107 ((struct fcoe_port *)lport_priv(lport))->priv)->netdev; 110 ((struct fcoe_port *)lport_priv(lport))->priv)->netdev;
108} 111}
109 112
110/**
111 * bnx2fc_get_lesb() - Fill the FCoE Link Error Status Block
112 * @lport: the local port
113 * @fc_lesb: the link error status block
114 */
115static void bnx2fc_get_lesb(struct fc_lport *lport,
116 struct fc_els_lesb *fc_lesb)
117{
118 struct net_device *netdev = bnx2fc_netdev(lport);
119
120 __fcoe_get_lesb(lport, fc_lesb, netdev);
121}
122
123static void bnx2fc_ctlr_get_lesb(struct fcoe_ctlr_device *ctlr_dev)
124{
125 struct fcoe_ctlr *fip = fcoe_ctlr_device_priv(ctlr_dev);
126 struct net_device *netdev = bnx2fc_netdev(fip->lp);
127 struct fcoe_fc_els_lesb *fcoe_lesb;
128 struct fc_els_lesb fc_lesb;
129
130 __fcoe_get_lesb(fip->lp, &fc_lesb, netdev);
131 fcoe_lesb = (struct fcoe_fc_els_lesb *)(&fc_lesb);
132
133 ctlr_dev->lesb.lesb_link_fail =
134 ntohl(fcoe_lesb->lesb_link_fail);
135 ctlr_dev->lesb.lesb_vlink_fail =
136 ntohl(fcoe_lesb->lesb_vlink_fail);
137 ctlr_dev->lesb.lesb_miss_fka =
138 ntohl(fcoe_lesb->lesb_miss_fka);
139 ctlr_dev->lesb.lesb_symb_err =
140 ntohl(fcoe_lesb->lesb_symb_err);
141 ctlr_dev->lesb.lesb_err_block =
142 ntohl(fcoe_lesb->lesb_err_block);
143 ctlr_dev->lesb.lesb_fcs_error =
144 ntohl(fcoe_lesb->lesb_fcs_error);
145}
146EXPORT_SYMBOL(bnx2fc_ctlr_get_lesb);
147
148static void bnx2fc_fcf_get_vlan_id(struct fcoe_fcf_device *fcf_dev) 113static void bnx2fc_fcf_get_vlan_id(struct fcoe_fcf_device *fcf_dev)
149{ 114{
150 struct fcoe_ctlr_device *ctlr_dev = 115 struct fcoe_ctlr_device *ctlr_dev =
@@ -741,35 +706,6 @@ static int bnx2fc_shost_config(struct fc_lport *lport, struct device *dev)
741 return 0; 706 return 0;
742} 707}
743 708
744static void bnx2fc_link_speed_update(struct fc_lport *lport)
745{
746 struct fcoe_port *port = lport_priv(lport);
747 struct bnx2fc_interface *interface = port->priv;
748 struct net_device *netdev = interface->netdev;
749 struct ethtool_cmd ecmd;
750
751 if (!__ethtool_get_settings(netdev, &ecmd)) {
752 lport->link_supported_speeds &=
753 ~(FC_PORTSPEED_1GBIT | FC_PORTSPEED_10GBIT);
754 if (ecmd.supported & (SUPPORTED_1000baseT_Half |
755 SUPPORTED_1000baseT_Full))
756 lport->link_supported_speeds |= FC_PORTSPEED_1GBIT;
757 if (ecmd.supported & SUPPORTED_10000baseT_Full)
758 lport->link_supported_speeds |= FC_PORTSPEED_10GBIT;
759
760 switch (ethtool_cmd_speed(&ecmd)) {
761 case SPEED_1000:
762 lport->link_speed = FC_PORTSPEED_1GBIT;
763 break;
764 case SPEED_2500:
765 lport->link_speed = FC_PORTSPEED_2GBIT;
766 break;
767 case SPEED_10000:
768 lport->link_speed = FC_PORTSPEED_10GBIT;
769 break;
770 }
771 }
772}
773static int bnx2fc_link_ok(struct fc_lport *lport) 709static int bnx2fc_link_ok(struct fc_lport *lport)
774{ 710{
775 struct fcoe_port *port = lport_priv(lport); 711 struct fcoe_port *port = lport_priv(lport);
@@ -827,7 +763,7 @@ static int bnx2fc_net_config(struct fc_lport *lport, struct net_device *netdev)
827 port->fcoe_pending_queue_active = 0; 763 port->fcoe_pending_queue_active = 0;
828 setup_timer(&port->timer, fcoe_queue_timer, (unsigned long) lport); 764 setup_timer(&port->timer, fcoe_queue_timer, (unsigned long) lport);
829 765
830 bnx2fc_link_speed_update(lport); 766 fcoe_link_speed_update(lport);
831 767
832 if (!lport->vport) { 768 if (!lport->vport) {
833 if (fcoe_get_wwn(netdev, &wwnn, NETDEV_FCOE_WWNN)) 769 if (fcoe_get_wwn(netdev, &wwnn, NETDEV_FCOE_WWNN))
@@ -871,6 +807,7 @@ static void bnx2fc_indicate_netevent(void *context, unsigned long event,
871 u16 vlan_id) 807 u16 vlan_id)
872{ 808{
873 struct bnx2fc_hba *hba = (struct bnx2fc_hba *)context; 809 struct bnx2fc_hba *hba = (struct bnx2fc_hba *)context;
810 struct fcoe_ctlr_device *cdev;
874 struct fc_lport *lport; 811 struct fc_lport *lport;
875 struct fc_lport *vport; 812 struct fc_lport *vport;
876 struct bnx2fc_interface *interface, *tmp; 813 struct bnx2fc_interface *interface, *tmp;
@@ -930,30 +867,47 @@ static void bnx2fc_indicate_netevent(void *context, unsigned long event,
930 BNX2FC_HBA_DBG(lport, "netevent handler - event=%s %ld\n", 867 BNX2FC_HBA_DBG(lport, "netevent handler - event=%s %ld\n",
931 interface->netdev->name, event); 868 interface->netdev->name, event);
932 869
933 bnx2fc_link_speed_update(lport); 870 fcoe_link_speed_update(lport);
871
872 cdev = fcoe_ctlr_to_ctlr_dev(ctlr);
934 873
935 if (link_possible && !bnx2fc_link_ok(lport)) { 874 if (link_possible && !bnx2fc_link_ok(lport)) {
936 /* Reset max recv frame size to default */ 875 switch (cdev->enabled) {
937 fc_set_mfs(lport, BNX2FC_MFS); 876 case FCOE_CTLR_DISABLED:
938 /* 877 pr_info("Link up while interface is disabled.\n");
939 * ctlr link up will only be handled during 878 break;
940 * enable to avoid sending discovery solicitation 879 case FCOE_CTLR_ENABLED:
941 * on a stale vlan 880 case FCOE_CTLR_UNUSED:
942 */ 881 /* Reset max recv frame size to default */
943 if (interface->enabled) 882 fc_set_mfs(lport, BNX2FC_MFS);
944 fcoe_ctlr_link_up(ctlr); 883 /*
884 * ctlr link up will only be handled during
885 * enable to avoid sending discovery
886 * solicitation on a stale vlan
887 */
888 if (interface->enabled)
889 fcoe_ctlr_link_up(ctlr);
890 };
945 } else if (fcoe_ctlr_link_down(ctlr)) { 891 } else if (fcoe_ctlr_link_down(ctlr)) {
946 mutex_lock(&lport->lp_mutex); 892 switch (cdev->enabled) {
947 list_for_each_entry(vport, &lport->vports, list) 893 case FCOE_CTLR_DISABLED:
948 fc_host_port_type(vport->host) = 894 pr_info("Link down while interface is disabled.\n");
949 FC_PORTTYPE_UNKNOWN; 895 break;
950 mutex_unlock(&lport->lp_mutex); 896 case FCOE_CTLR_ENABLED:
951 fc_host_port_type(lport->host) = FC_PORTTYPE_UNKNOWN; 897 case FCOE_CTLR_UNUSED:
952 per_cpu_ptr(lport->stats, 898 mutex_lock(&lport->lp_mutex);
953 get_cpu())->LinkFailureCount++; 899 list_for_each_entry(vport, &lport->vports, list)
954 put_cpu(); 900 fc_host_port_type(vport->host) =
955 fcoe_clean_pending_queue(lport); 901 FC_PORTTYPE_UNKNOWN;
956 wait_for_upload = 1; 902 mutex_unlock(&lport->lp_mutex);
903 fc_host_port_type(lport->host) =
904 FC_PORTTYPE_UNKNOWN;
905 per_cpu_ptr(lport->stats,
906 get_cpu())->LinkFailureCount++;
907 put_cpu();
908 fcoe_clean_pending_queue(lport);
909 wait_for_upload = 1;
910 };
957 } 911 }
958 } 912 }
959 mutex_unlock(&bnx2fc_dev_lock); 913 mutex_unlock(&bnx2fc_dev_lock);
@@ -1484,6 +1438,7 @@ static struct fc_lport *bnx2fc_if_create(struct bnx2fc_interface *interface,
1484 port = lport_priv(lport); 1438 port = lport_priv(lport);
1485 port->lport = lport; 1439 port->lport = lport;
1486 port->priv = interface; 1440 port->priv = interface;
1441 port->get_netdev = bnx2fc_netdev;
1487 INIT_WORK(&port->destroy_work, bnx2fc_destroy_work); 1442 INIT_WORK(&port->destroy_work, bnx2fc_destroy_work);
1488 1443
1489 /* Configure fcoe_port */ 1444 /* Configure fcoe_port */
@@ -2003,7 +1958,9 @@ static void bnx2fc_ulp_init(struct cnic_dev *dev)
2003 set_bit(BNX2FC_CNIC_REGISTERED, &hba->reg_with_cnic); 1958 set_bit(BNX2FC_CNIC_REGISTERED, &hba->reg_with_cnic);
2004} 1959}
2005 1960
2006 1961/**
1962 * Deperecated: Use bnx2fc_enabled()
1963 */
2007static int bnx2fc_disable(struct net_device *netdev) 1964static int bnx2fc_disable(struct net_device *netdev)
2008{ 1965{
2009 struct bnx2fc_interface *interface; 1966 struct bnx2fc_interface *interface;
@@ -2029,7 +1986,9 @@ static int bnx2fc_disable(struct net_device *netdev)
2029 return rc; 1986 return rc;
2030} 1987}
2031 1988
2032 1989/**
1990 * Deprecated: Use bnx2fc_enabled()
1991 */
2033static int bnx2fc_enable(struct net_device *netdev) 1992static int bnx2fc_enable(struct net_device *netdev)
2034{ 1993{
2035 struct bnx2fc_interface *interface; 1994 struct bnx2fc_interface *interface;
@@ -2055,17 +2014,57 @@ static int bnx2fc_enable(struct net_device *netdev)
2055} 2014}
2056 2015
2057/** 2016/**
2058 * bnx2fc_create - Create bnx2fc FCoE interface 2017 * bnx2fc_ctlr_enabled() - Enable or disable an FCoE Controller
2018 * @cdev: The FCoE Controller that is being enabled or disabled
2019 *
2020 * fcoe_sysfs will ensure that the state of 'enabled' has
2021 * changed, so no checking is necessary here. This routine simply
2022 * calls fcoe_enable or fcoe_disable, both of which are deprecated.
2023 * When those routines are removed the functionality can be merged
2024 * here.
2025 */
2026static int bnx2fc_ctlr_enabled(struct fcoe_ctlr_device *cdev)
2027{
2028 struct fcoe_ctlr *ctlr = fcoe_ctlr_device_priv(cdev);
2029 struct fc_lport *lport = ctlr->lp;
2030 struct net_device *netdev = bnx2fc_netdev(lport);
2031
2032 switch (cdev->enabled) {
2033 case FCOE_CTLR_ENABLED:
2034 return bnx2fc_enable(netdev);
2035 case FCOE_CTLR_DISABLED:
2036 return bnx2fc_disable(netdev);
2037 case FCOE_CTLR_UNUSED:
2038 default:
2039 return -ENOTSUPP;
2040 };
2041}
2042
2043enum bnx2fc_create_link_state {
2044 BNX2FC_CREATE_LINK_DOWN,
2045 BNX2FC_CREATE_LINK_UP,
2046};
2047
2048/**
2049 * _bnx2fc_create() - Create bnx2fc FCoE interface
2050 * @netdev : The net_device object the Ethernet interface to create on
2051 * @fip_mode: The FIP mode for this creation
2052 * @link_state: The ctlr link state on creation
2059 * 2053 *
2060 * @buffer: The name of Ethernet interface to create on 2054 * Called from either the libfcoe 'create' module parameter
2061 * @kp: The associated kernel param 2055 * via fcoe_create or from fcoe_syfs's ctlr_create file.
2062 * 2056 *
2063 * Called from sysfs. 2057 * libfcoe's 'create' module parameter is deprecated so some
2058 * consolidation of code can be done when that interface is
2059 * removed.
2064 * 2060 *
2065 * Returns: 0 for success 2061 * Returns: 0 for success
2066 */ 2062 */
2067static int bnx2fc_create(struct net_device *netdev, enum fip_state fip_mode) 2063static int _bnx2fc_create(struct net_device *netdev,
2064 enum fip_state fip_mode,
2065 enum bnx2fc_create_link_state link_state)
2068{ 2066{
2067 struct fcoe_ctlr_device *cdev;
2069 struct fcoe_ctlr *ctlr; 2068 struct fcoe_ctlr *ctlr;
2070 struct bnx2fc_interface *interface; 2069 struct bnx2fc_interface *interface;
2071 struct bnx2fc_hba *hba; 2070 struct bnx2fc_hba *hba;
@@ -2160,7 +2159,15 @@ static int bnx2fc_create(struct net_device *netdev, enum fip_state fip_mode)
2160 /* Make this master N_port */ 2159 /* Make this master N_port */
2161 ctlr->lp = lport; 2160 ctlr->lp = lport;
2162 2161
2163 if (!bnx2fc_link_ok(lport)) { 2162 cdev = fcoe_ctlr_to_ctlr_dev(ctlr);
2163
2164 if (link_state == BNX2FC_CREATE_LINK_UP)
2165 cdev->enabled = FCOE_CTLR_ENABLED;
2166 else
2167 cdev->enabled = FCOE_CTLR_DISABLED;
2168
2169 if (link_state == BNX2FC_CREATE_LINK_UP &&
2170 !bnx2fc_link_ok(lport)) {
2164 fcoe_ctlr_link_up(ctlr); 2171 fcoe_ctlr_link_up(ctlr);
2165 fc_host_port_type(lport->host) = FC_PORTTYPE_NPORT; 2172 fc_host_port_type(lport->host) = FC_PORTTYPE_NPORT;
2166 set_bit(ADAPTER_STATE_READY, &interface->hba->adapter_state); 2173 set_bit(ADAPTER_STATE_READY, &interface->hba->adapter_state);
@@ -2168,7 +2175,10 @@ static int bnx2fc_create(struct net_device *netdev, enum fip_state fip_mode)
2168 2175
2169 BNX2FC_HBA_DBG(lport, "create: START DISC\n"); 2176 BNX2FC_HBA_DBG(lport, "create: START DISC\n");
2170 bnx2fc_start_disc(interface); 2177 bnx2fc_start_disc(interface);
2171 interface->enabled = true; 2178
2179 if (link_state == BNX2FC_CREATE_LINK_UP)
2180 interface->enabled = true;
2181
2172 /* 2182 /*
2173 * Release from kref_init in bnx2fc_interface_setup, on success 2183 * Release from kref_init in bnx2fc_interface_setup, on success
2174 * lport should be holding a reference taken in bnx2fc_if_create 2184 * lport should be holding a reference taken in bnx2fc_if_create
@@ -2194,6 +2204,37 @@ mod_err:
2194} 2204}
2195 2205
2196/** 2206/**
2207 * bnx2fc_create() - Create a bnx2fc interface
2208 * @netdev : The net_device object the Ethernet interface to create on
2209 * @fip_mode: The FIP mode for this creation
2210 *
2211 * Called from fcoe transport
2212 *
2213 * Returns: 0 for success
2214 */
2215static int bnx2fc_create(struct net_device *netdev, enum fip_state fip_mode)
2216{
2217 return _bnx2fc_create(netdev, fip_mode, BNX2FC_CREATE_LINK_UP);
2218}
2219
2220/**
2221 * bnx2fc_ctlr_alloc() - Allocate a bnx2fc interface from fcoe_sysfs
2222 * @netdev: The net_device to be used by the allocated FCoE Controller
2223 *
2224 * This routine is called from fcoe_sysfs. It will start the fcoe_ctlr
2225 * in a link_down state. The allows the user an opportunity to configure
2226 * the FCoE Controller from sysfs before enabling the FCoE Controller.
2227 *
2228 * Creating in with this routine starts the FCoE Controller in Fabric
2229 * mode. The user can change to VN2VN or another mode before enabling.
2230 */
2231static int bnx2fc_ctlr_alloc(struct net_device *netdev)
2232{
2233 return _bnx2fc_create(netdev, FIP_MODE_FABRIC,
2234 BNX2FC_CREATE_LINK_DOWN);
2235}
2236
2237/**
2197 * bnx2fc_find_hba_for_cnic - maps cnic instance to bnx2fc hba instance 2238 * bnx2fc_find_hba_for_cnic - maps cnic instance to bnx2fc hba instance
2198 * 2239 *
2199 * @cnic: Pointer to cnic device instance 2240 * @cnic: Pointer to cnic device instance
@@ -2318,6 +2359,7 @@ static struct fcoe_transport bnx2fc_transport = {
2318 .name = {"bnx2fc"}, 2359 .name = {"bnx2fc"},
2319 .attached = false, 2360 .attached = false,
2320 .list = LIST_HEAD_INIT(bnx2fc_transport.list), 2361 .list = LIST_HEAD_INIT(bnx2fc_transport.list),
2362 .alloc = bnx2fc_ctlr_alloc,
2321 .match = bnx2fc_match, 2363 .match = bnx2fc_match,
2322 .create = bnx2fc_create, 2364 .create = bnx2fc_create,
2323 .destroy = bnx2fc_destroy, 2365 .destroy = bnx2fc_destroy,
@@ -2562,13 +2604,13 @@ module_init(bnx2fc_mod_init);
2562module_exit(bnx2fc_mod_exit); 2604module_exit(bnx2fc_mod_exit);
2563 2605
2564static struct fcoe_sysfs_function_template bnx2fc_fcoe_sysfs_templ = { 2606static struct fcoe_sysfs_function_template bnx2fc_fcoe_sysfs_templ = {
2565 .get_fcoe_ctlr_mode = fcoe_ctlr_get_fip_mode, 2607 .set_fcoe_ctlr_enabled = bnx2fc_ctlr_enabled,
2566 .get_fcoe_ctlr_link_fail = bnx2fc_ctlr_get_lesb, 2608 .get_fcoe_ctlr_link_fail = fcoe_ctlr_get_lesb,
2567 .get_fcoe_ctlr_vlink_fail = bnx2fc_ctlr_get_lesb, 2609 .get_fcoe_ctlr_vlink_fail = fcoe_ctlr_get_lesb,
2568 .get_fcoe_ctlr_miss_fka = bnx2fc_ctlr_get_lesb, 2610 .get_fcoe_ctlr_miss_fka = fcoe_ctlr_get_lesb,
2569 .get_fcoe_ctlr_symb_err = bnx2fc_ctlr_get_lesb, 2611 .get_fcoe_ctlr_symb_err = fcoe_ctlr_get_lesb,
2570 .get_fcoe_ctlr_err_block = bnx2fc_ctlr_get_lesb, 2612 .get_fcoe_ctlr_err_block = fcoe_ctlr_get_lesb,
2571 .get_fcoe_ctlr_fcs_error = bnx2fc_ctlr_get_lesb, 2613 .get_fcoe_ctlr_fcs_error = fcoe_ctlr_get_lesb,
2572 2614
2573 .get_fcoe_fcf_selected = fcoe_fcf_get_selected, 2615 .get_fcoe_fcf_selected = fcoe_fcf_get_selected,
2574 .get_fcoe_fcf_vlan_id = bnx2fc_fcf_get_vlan_id, 2616 .get_fcoe_fcf_vlan_id = bnx2fc_fcf_get_vlan_id,
@@ -2675,7 +2717,7 @@ static struct libfc_function_template bnx2fc_libfc_fcn_templ = {
2675 .elsct_send = bnx2fc_elsct_send, 2717 .elsct_send = bnx2fc_elsct_send,
2676 .fcp_abort_io = bnx2fc_abort_io, 2718 .fcp_abort_io = bnx2fc_abort_io,
2677 .fcp_cleanup = bnx2fc_cleanup, 2719 .fcp_cleanup = bnx2fc_cleanup,
2678 .get_lesb = bnx2fc_get_lesb, 2720 .get_lesb = fcoe_get_lesb,
2679 .rport_event_callback = bnx2fc_rport_event_handler, 2721 .rport_event_callback = bnx2fc_rport_event_handler,
2680}; 2722};
2681 2723