aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet
diff options
context:
space:
mode:
authorSony Chacko <sony.chacko@qlogic.com>2012-12-31 22:20:26 -0500
committerDavid S. Miller <davem@davemloft.net>2013-01-02 05:43:27 -0500
commitd71170fb9d54833c4b26b1bf9ab5a077f1d65324 (patch)
tree09dc8adaad0a9de1be36e24b00592b063e71be92 /drivers/net/ethernet
parent81d0aeb0a4fff6c274f956644a837caac14a7c21 (diff)
qlcnic: enable 83xx virtual NIC mode
Enable 83xx virtual NIC mode Signed-off-by: Rajesh Borundia <rajesh.borundia@qlogic.com> Signed-off-by: Sony Chacko <sony.chacko@qlogic.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet')
-rw-r--r--drivers/net/ethernet/qlogic/qlcnic/Makefile2
-rw-r--r--drivers/net/ethernet/qlogic/qlcnic/qlcnic.h5
-rw-r--r--drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.h7
-rw-r--r--drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c53
-rw-r--r--drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c216
-rw-r--r--drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c9
6 files changed, 285 insertions, 7 deletions
diff --git a/drivers/net/ethernet/qlogic/qlcnic/Makefile b/drivers/net/ethernet/qlogic/qlcnic/Makefile
index 799325db5c79..25b73f163886 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/Makefile
+++ b/drivers/net/ethernet/qlogic/qlcnic/Makefile
@@ -7,4 +7,4 @@ obj-$(CONFIG_QLCNIC) := qlcnic.o
7qlcnic-y := qlcnic_hw.o qlcnic_main.o qlcnic_init.o \ 7qlcnic-y := qlcnic_hw.o qlcnic_main.o qlcnic_init.o \
8 qlcnic_ethtool.o qlcnic_ctx.o qlcnic_io.o \ 8 qlcnic_ethtool.o qlcnic_ctx.o qlcnic_io.o \
9 qlcnic_sysfs.o qlcnic_minidump.o qlcnic_83xx_hw.o \ 9 qlcnic_sysfs.o qlcnic_minidump.o qlcnic_83xx_hw.o \
10 qlcnic_83xx_init.o 10 qlcnic_83xx_init.o qlcnic_83xx_vnic.o
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h b/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h
index 5b36d92b237d..af8510bdfb9e 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h
@@ -1523,7 +1523,10 @@ int __qlcnic_up(struct qlcnic_adapter *, struct net_device *);
1523void qlcnic_restore_indev_addr(struct net_device *, unsigned long); 1523void qlcnic_restore_indev_addr(struct net_device *, unsigned long);
1524 1524
1525int qlcnic_check_temp(struct qlcnic_adapter *); 1525int qlcnic_check_temp(struct qlcnic_adapter *);
1526 1526int qlcnic_init_pci_info(struct qlcnic_adapter *);
1527int qlcnic_set_default_offload_settings(struct qlcnic_adapter *);
1528int qlcnic_reset_npar_config(struct qlcnic_adapter *);
1529int qlcnic_set_eswitch_port_config(struct qlcnic_adapter *);
1527/* 1530/*
1528 * QLOGIC Board information 1531 * QLOGIC Board information
1529 */ 1532 */
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.h b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.h
index 969bda8e32c4..f378d2171615 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.h
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.h
@@ -400,4 +400,11 @@ int qlcnic_83xx_lock_driver(struct qlcnic_adapter *);
400void qlcnic_83xx_unlock_driver(struct qlcnic_adapter *); 400void qlcnic_83xx_unlock_driver(struct qlcnic_adapter *);
401int qlcnic_83xx_set_default_offload_settings(struct qlcnic_adapter *); 401int qlcnic_83xx_set_default_offload_settings(struct qlcnic_adapter *);
402int qlcnic_83xx_ms_mem_write128(struct qlcnic_adapter *, u64, u32 *, u32); 402int qlcnic_83xx_ms_mem_write128(struct qlcnic_adapter *, u64, u32 *, u32);
403int qlcnic_83xx_idc_vnic_pf_entry(struct qlcnic_adapter *);
404int qlcnic_83xx_enable_vnic_mode(struct qlcnic_adapter *, int);
405int qlcnic_83xx_disable_vnic_mode(struct qlcnic_adapter *, int);
406int qlcnic_83xx_config_vnic_opmode(struct qlcnic_adapter *);
407int qlcnic_83xx_get_vnic_vport_info(struct qlcnic_adapter *,
408 struct qlcnic_info *, u8);
409int qlcnic_83xx_get_vnic_pf_info(struct qlcnic_adapter *, struct qlcnic_info *);
403#endif 410#endif
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
index d222ee291e7c..b14fb83fcdd6 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
@@ -643,6 +643,52 @@ int qlcnic_83xx_idc_ready_state_entry(struct qlcnic_adapter *adapter)
643 return 0; 643 return 0;
644} 644}
645 645
646/**
647 * qlcnic_83xx_idc_vnic_pf_entry
648 *
649 * @adapter: adapter structure
650 *
651 * Ensure vNIC mode privileged function starts only after vNIC mode is
652 * enabled by management function.
653 * If vNIC mode is ready, start initialization.
654 *
655 * Returns: -EIO or 0
656 *
657 **/
658int qlcnic_83xx_idc_vnic_pf_entry(struct qlcnic_adapter *adapter)
659{
660 u32 state;
661 struct qlcnic_hardware_context *ahw = adapter->ahw;
662
663 /* Privileged function waits till mgmt function enables VNIC mode */
664 state = QLCRDX(adapter->ahw, QLC_83XX_VNIC_STATE);
665 if (state != QLCNIC_DEV_NPAR_OPER) {
666 if (!ahw->idc.vnic_wait_limit--) {
667 qlcnic_83xx_idc_enter_failed_state(adapter, 1);
668 return -EIO;
669 }
670 dev_info(&adapter->pdev->dev, "vNIC mode disabled\n");
671 return -EIO;
672
673 } else {
674 /* Perform one time initialization from ready state */
675 if (ahw->idc.vnic_state != QLCNIC_DEV_NPAR_OPER) {
676 qlcnic_83xx_idc_update_idc_params(adapter);
677
678 /* If the previous state is UNKNOWN, device will be
679 already attached properly by Init routine*/
680 if (ahw->idc.prev_state != QLC_83XX_IDC_DEV_UNKNOWN) {
681 if (qlcnic_83xx_idc_reattach_driver(adapter))
682 return -EIO;
683 }
684 adapter->ahw->idc.vnic_state = QLCNIC_DEV_NPAR_OPER;
685 dev_info(&adapter->pdev->dev, "vNIC mode enabled\n");
686 }
687 }
688
689 return 0;
690}
691
646static int qlcnic_83xx_idc_unknown_state(struct qlcnic_adapter *adapter) 692static int qlcnic_83xx_idc_unknown_state(struct qlcnic_adapter *adapter)
647{ 693{
648 adapter->ahw->idc.err_code = -EIO; 694 adapter->ahw->idc.err_code = -EIO;
@@ -802,6 +848,8 @@ static int qlcnic_83xx_idc_need_reset_state(struct qlcnic_adapter *adapter)
802 qlcnic_83xx_idc_update_audit_reg(adapter, 0, 1); 848 qlcnic_83xx_idc_update_audit_reg(adapter, 0, 1);
803 set_bit(__QLCNIC_RESETTING, &adapter->state); 849 set_bit(__QLCNIC_RESETTING, &adapter->state);
804 clear_bit(QLC_83XX_MBX_READY, &adapter->ahw->idc.status); 850 clear_bit(QLC_83XX_MBX_READY, &adapter->ahw->idc.status);
851 if (adapter->ahw->nic_mode == QLC_83XX_VIRTUAL_NIC_MODE)
852 qlcnic_83xx_disable_vnic_mode(adapter, 1);
805 qlcnic_83xx_idc_detach_driver(adapter); 853 qlcnic_83xx_idc_detach_driver(adapter);
806 } 854 }
807 855
@@ -1887,7 +1935,10 @@ static int qlcnic_83xx_configure_opmode(struct qlcnic_adapter *adapter)
1887 if (ret == -EIO) 1935 if (ret == -EIO)
1888 return -EIO; 1936 return -EIO;
1889 1937
1890 if (ret == QLC_83XX_DEFAULT_MODE) { 1938 if (ret == QLC_83XX_VIRTUAL_NIC_MODE) {
1939 if (qlcnic_83xx_config_vnic_opmode(adapter))
1940 return -EIO;
1941 } else if (ret == QLC_83XX_DEFAULT_MODE) {
1891 if (qlcnic_83xx_config_default_opmode(adapter)) 1942 if (qlcnic_83xx_config_default_opmode(adapter))
1892 return -EIO; 1943 return -EIO;
1893 } 1944 }
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
new file mode 100644
index 000000000000..d39447104228
--- /dev/null
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
@@ -0,0 +1,216 @@
1#include "qlcnic.h"
2#include "qlcnic_hw.h"
3
4int qlcnic_83xx_enable_vnic_mode(struct qlcnic_adapter *adapter, int lock)
5{
6 if (lock) {
7 if (qlcnic_83xx_lock_driver(adapter))
8 return -EBUSY;
9 }
10 QLCWRX(adapter->ahw, QLC_83XX_VNIC_STATE, QLCNIC_DEV_NPAR_OPER);
11 if (lock)
12 qlcnic_83xx_unlock_driver(adapter);
13
14 return 0;
15}
16
17int qlcnic_83xx_disable_vnic_mode(struct qlcnic_adapter *adapter, int lock)
18{
19 struct qlcnic_hardware_context *ahw = adapter->ahw;
20
21 if (lock) {
22 if (qlcnic_83xx_lock_driver(adapter))
23 return -EBUSY;
24 }
25
26 QLCWRX(adapter->ahw, QLC_83XX_VNIC_STATE, QLCNIC_DEV_NPAR_NON_OPER);
27 ahw->idc.vnic_state = QLCNIC_DEV_NPAR_NON_OPER;
28
29 if (lock)
30 qlcnic_83xx_unlock_driver(adapter);
31
32 return 0;
33}
34
35static int qlcnic_83xx_set_vnic_opmode(struct qlcnic_adapter *adapter)
36{
37 u8 id;
38 int i, ret = -EBUSY;
39 u32 data = QLCNIC_MGMT_FUNC;
40 struct qlcnic_hardware_context *ahw = adapter->ahw;
41
42 if (qlcnic_83xx_lock_driver(adapter))
43 return ret;
44
45 if (qlcnic_config_npars) {
46 for (i = 0; i < ahw->act_pci_func; i++) {
47 id = adapter->npars[i].pci_func;
48 if (id == ahw->pci_func)
49 continue;
50 data |= qlcnic_config_npars &
51 QLC_83XX_SET_FUNC_OPMODE(0x3, id);
52 }
53 } else {
54 data = QLCRDX(adapter->ahw, QLC_83XX_DRV_OP_MODE);
55 data = (data & ~QLC_83XX_SET_FUNC_OPMODE(0x3, ahw->pci_func)) |
56 QLC_83XX_SET_FUNC_OPMODE(QLCNIC_MGMT_FUNC,
57 ahw->pci_func);
58 }
59 QLCWRX(adapter->ahw, QLC_83XX_DRV_OP_MODE, data);
60
61 qlcnic_83xx_unlock_driver(adapter);
62
63 return 0;
64}
65
66static void
67qlcnic_83xx_config_vnic_buff_descriptors(struct qlcnic_adapter *adapter)
68{
69 struct qlcnic_hardware_context *ahw = adapter->ahw;
70
71 if (ahw->port_type == QLCNIC_XGBE) {
72 adapter->num_rxd = DEFAULT_RCV_DESCRIPTORS_VF;
73 adapter->max_rxd = MAX_RCV_DESCRIPTORS_VF;
74 adapter->num_jumbo_rxd = MAX_JUMBO_RCV_DESCRIPTORS_10G;
75 adapter->max_jumbo_rxd = MAX_JUMBO_RCV_DESCRIPTORS_10G;
76
77 } else if (ahw->port_type == QLCNIC_GBE) {
78 adapter->num_rxd = DEFAULT_RCV_DESCRIPTORS_1G;
79 adapter->num_jumbo_rxd = MAX_JUMBO_RCV_DESCRIPTORS_1G;
80 adapter->max_jumbo_rxd = MAX_JUMBO_RCV_DESCRIPTORS_1G;
81 adapter->max_rxd = MAX_RCV_DESCRIPTORS_1G;
82 }
83 adapter->num_txd = MAX_CMD_DESCRIPTORS;
84 adapter->max_rds_rings = MAX_RDS_RINGS;
85}
86
87
88/**
89 * qlcnic_83xx_init_mgmt_vnic
90 *
91 * @adapter: adapter structure
92 * Management virtual NIC sets the operational mode of other vNIC's and
93 * configures embedded switch (ESWITCH).
94 * Returns: Success(0) or error code.
95 *
96 **/
97static int qlcnic_83xx_init_mgmt_vnic(struct qlcnic_adapter *adapter)
98{
99 int err = -EIO;
100
101 if (!(adapter->flags & QLCNIC_ADAPTER_INITIALIZED)) {
102 if (qlcnic_init_pci_info(adapter))
103 return err;
104
105 if (qlcnic_83xx_set_vnic_opmode(adapter))
106 return err;
107
108 if (qlcnic_set_default_offload_settings(adapter))
109 return err;
110 } else {
111 if (qlcnic_reset_npar_config(adapter))
112 return err;
113 }
114
115 if (qlcnic_83xx_get_port_info(adapter))
116 return err;
117
118 qlcnic_83xx_config_vnic_buff_descriptors(adapter);
119 adapter->ahw->msix_supported = !!qlcnic_use_msi_x;
120 adapter->flags |= QLCNIC_ADAPTER_INITIALIZED;
121 qlcnic_83xx_enable_vnic_mode(adapter, 1);
122
123 dev_info(&adapter->pdev->dev, "HAL Version: %d, Management function\n",
124 adapter->ahw->fw_hal_version);
125
126 return 0;
127}
128
129static int qlcnic_83xx_init_privileged_vnic(struct qlcnic_adapter *adapter)
130{
131 int err = -EIO;
132
133 if (qlcnic_83xx_get_port_info(adapter))
134 return err;
135
136 qlcnic_83xx_config_vnic_buff_descriptors(adapter);
137 adapter->ahw->msix_supported = !!qlcnic_use_msi_x;
138 adapter->flags |= QLCNIC_ADAPTER_INITIALIZED;
139
140 dev_info(&adapter->pdev->dev,
141 "HAL Version: %d, Privileged function\n",
142 adapter->ahw->fw_hal_version);
143 return 0;
144}
145
146static int qlcnic_83xx_init_non_privileged_vnic(struct qlcnic_adapter *adapter)
147{
148 int err = -EIO;
149
150 qlcnic_83xx_get_fw_version(adapter);
151 if (qlcnic_set_eswitch_port_config(adapter))
152 return err;
153
154 if (qlcnic_83xx_get_port_info(adapter))
155 return err;
156
157 qlcnic_83xx_config_vnic_buff_descriptors(adapter);
158 adapter->ahw->msix_supported = !!qlcnic_use_msi_x;
159 adapter->flags |= QLCNIC_ADAPTER_INITIALIZED;
160
161 dev_info(&adapter->pdev->dev, "HAL Version: %d, Virtual function\n",
162 adapter->ahw->fw_hal_version);
163
164 return 0;
165}
166
167/**
168 * qlcnic_83xx_vnic_opmode
169 *
170 * @adapter: adapter structure
171 * Identify virtual NIC operational modes.
172 *
173 * Returns: Success(0) or error code.
174 *
175 **/
176int qlcnic_83xx_config_vnic_opmode(struct qlcnic_adapter *adapter)
177{
178 u32 op_mode, priv_level;
179 struct qlcnic_hardware_context *ahw = adapter->ahw;
180 struct qlcnic_nic_template *nic_ops = adapter->nic_ops;
181
182 qlcnic_get_func_no(adapter);
183 op_mode = QLCRDX(adapter->ahw, QLC_83XX_DRV_OP_MODE);
184
185 if (op_mode == QLC_83XX_DEFAULT_OPMODE)
186 priv_level = QLCNIC_MGMT_FUNC;
187 else
188 priv_level = QLC_83XX_GET_FUNC_PRIVILEGE(op_mode,
189 ahw->pci_func);
190
191 if (priv_level == QLCNIC_NON_PRIV_FUNC) {
192 ahw->op_mode = QLCNIC_NON_PRIV_FUNC;
193 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
194 nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
195 } else if (priv_level == QLCNIC_PRIV_FUNC) {
196 ahw->op_mode = QLCNIC_PRIV_FUNC;
197 ahw->idc.state_entry = qlcnic_83xx_idc_vnic_pf_entry;
198 nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
199 } else if (priv_level == QLCNIC_MGMT_FUNC) {
200 ahw->op_mode = QLCNIC_MGMT_FUNC;
201 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
202 nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
203 } else {
204 return -EIO;
205 }
206
207 if (ahw->capabilities & BIT_23)
208 adapter->flags |= QLCNIC_ESWITCH_ENABLED;
209 else
210 adapter->flags &= ~QLCNIC_ESWITCH_ENABLED;
211
212 adapter->ahw->idc.vnic_state = QLCNIC_DEV_NPAR_NON_OPER;
213 adapter->ahw->idc.vnic_wait_limit = QLCNIC_DEV_NPAR_OPER_TIMEO;
214
215 return 0;
216}
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
index c71e1dc7295d..da04432f36ec 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
@@ -502,7 +502,8 @@ static int qlcnic_get_act_pci_func(struct qlcnic_adapter *adapter)
502 kfree(pci_info); 502 kfree(pci_info);
503 return ret; 503 return ret;
504} 504}
505static int qlcnic_init_pci_info(struct qlcnic_adapter *adapter) 505
506int qlcnic_init_pci_info(struct qlcnic_adapter *adapter)
506{ 507{
507 struct qlcnic_pci_info *pci_info; 508 struct qlcnic_pci_info *pci_info;
508 int i, ret = 0, j = 0; 509 int i, ret = 0, j = 0;
@@ -851,7 +852,7 @@ void qlcnic_set_eswitch_port_features(struct qlcnic_adapter *adapter,
851 qlcnic_set_netdev_features(adapter, esw_cfg); 852 qlcnic_set_netdev_features(adapter, esw_cfg);
852} 853}
853 854
854static int qlcnic_set_eswitch_port_config(struct qlcnic_adapter *adapter) 855int qlcnic_set_eswitch_port_config(struct qlcnic_adapter *adapter)
855{ 856{
856 struct qlcnic_esw_func_cfg esw_cfg; 857 struct qlcnic_esw_func_cfg esw_cfg;
857 858
@@ -950,7 +951,7 @@ qlcnic_check_eswitch_mode(struct qlcnic_adapter *adapter)
950 return err; 951 return err;
951} 952}
952 953
953static int qlcnic_set_default_offload_settings(struct qlcnic_adapter *adapter) 954int qlcnic_set_default_offload_settings(struct qlcnic_adapter *adapter)
954{ 955{
955 struct qlcnic_esw_func_cfg esw_cfg; 956 struct qlcnic_esw_func_cfg esw_cfg;
956 struct qlcnic_npar_info *npar; 957 struct qlcnic_npar_info *npar;
@@ -1007,7 +1008,7 @@ qlcnic_reset_eswitch_config(struct qlcnic_adapter *adapter,
1007 return 0; 1008 return 0;
1008} 1009}
1009 1010
1010static int qlcnic_reset_npar_config(struct qlcnic_adapter *adapter) 1011int qlcnic_reset_npar_config(struct qlcnic_adapter *adapter)
1011{ 1012{
1012 int i, err; 1013 int i, err;
1013 struct qlcnic_npar_info *npar; 1014 struct qlcnic_npar_info *npar;