2 * QLogic qlcnic NIC Driver
3 * Copyright (c) 2009-2013 QLogic Corporation
5 * See LICENSE.qlcnic for copyright and licensing details.
11 int qlcnic_83xx_enable_vnic_mode(struct qlcnic_adapter *adapter, int lock)
14 if (qlcnic_83xx_lock_driver(adapter))
17 QLCWRX(adapter->ahw, QLC_83XX_VNIC_STATE, QLCNIC_DEV_NPAR_OPER);
19 qlcnic_83xx_unlock_driver(adapter);
24 int qlcnic_83xx_disable_vnic_mode(struct qlcnic_adapter *adapter, int lock)
26 struct qlcnic_hardware_context *ahw = adapter->ahw;
29 if (qlcnic_83xx_lock_driver(adapter))
33 QLCWRX(adapter->ahw, QLC_83XX_VNIC_STATE, QLCNIC_DEV_NPAR_NON_OPER);
34 ahw->idc.vnic_state = QLCNIC_DEV_NPAR_NON_OPER;
37 qlcnic_83xx_unlock_driver(adapter);
42 int qlcnic_83xx_set_vnic_opmode(struct qlcnic_adapter *adapter)
46 u32 data = QLCNIC_MGMT_FUNC;
47 struct qlcnic_hardware_context *ahw = adapter->ahw;
49 if (qlcnic_83xx_lock_driver(adapter))
53 data = QLCRDX(adapter->ahw, QLC_83XX_DRV_OP_MODE);
54 data = (data & ~QLC_83XX_SET_FUNC_OPMODE(0x3, id)) |
55 QLC_83XX_SET_FUNC_OPMODE(QLCNIC_MGMT_FUNC, id);
57 QLCWRX(adapter->ahw, QLC_83XX_DRV_OP_MODE, data);
59 qlcnic_83xx_unlock_driver(adapter);
65 qlcnic_83xx_config_vnic_buff_descriptors(struct qlcnic_adapter *adapter)
67 struct qlcnic_hardware_context *ahw = adapter->ahw;
69 if (ahw->port_type == QLCNIC_XGBE) {
70 adapter->num_rxd = DEFAULT_RCV_DESCRIPTORS_VF;
71 adapter->max_rxd = MAX_RCV_DESCRIPTORS_VF;
72 adapter->num_jumbo_rxd = MAX_JUMBO_RCV_DESCRIPTORS_10G;
73 adapter->max_jumbo_rxd = MAX_JUMBO_RCV_DESCRIPTORS_10G;
75 } else if (ahw->port_type == QLCNIC_GBE) {
76 adapter->num_rxd = DEFAULT_RCV_DESCRIPTORS_1G;
77 adapter->num_jumbo_rxd = MAX_JUMBO_RCV_DESCRIPTORS_1G;
78 adapter->max_jumbo_rxd = MAX_JUMBO_RCV_DESCRIPTORS_1G;
79 adapter->max_rxd = MAX_RCV_DESCRIPTORS_1G;
81 adapter->num_txd = MAX_CMD_DESCRIPTORS;
82 adapter->max_rds_rings = MAX_RDS_RINGS;
87 * qlcnic_83xx_init_mgmt_vnic
89 * @adapter: adapter structure
90 * Management virtual NIC sets the operational mode of other vNIC's and
91 * configures embedded switch (ESWITCH).
92 * Returns: Success(0) or error code.
95 static int qlcnic_83xx_init_mgmt_vnic(struct qlcnic_adapter *adapter)
99 qlcnic_83xx_get_minidump_template(adapter);
100 if (!(adapter->flags & QLCNIC_ADAPTER_INITIALIZED)) {
101 if (qlcnic_init_pci_info(adapter))
104 if (qlcnic_83xx_set_vnic_opmode(adapter))
107 if (qlcnic_set_default_offload_settings(adapter))
110 if (qlcnic_reset_npar_config(adapter))
114 if (qlcnic_83xx_get_port_info(adapter))
117 qlcnic_83xx_config_vnic_buff_descriptors(adapter);
118 adapter->ahw->msix_supported = !!qlcnic_use_msi_x;
119 adapter->flags |= QLCNIC_ADAPTER_INITIALIZED;
120 qlcnic_83xx_enable_vnic_mode(adapter, 1);
122 dev_info(&adapter->pdev->dev, "HAL Version: %d, Management function\n",
123 adapter->ahw->fw_hal_version);
128 static int qlcnic_83xx_init_privileged_vnic(struct qlcnic_adapter *adapter)
132 qlcnic_83xx_get_minidump_template(adapter);
133 if (qlcnic_83xx_get_port_info(adapter))
136 qlcnic_83xx_config_vnic_buff_descriptors(adapter);
137 adapter->ahw->msix_supported = !!qlcnic_use_msi_x;
138 adapter->flags |= QLCNIC_ADAPTER_INITIALIZED;
140 dev_info(&adapter->pdev->dev,
141 "HAL Version: %d, Privileged function\n",
142 adapter->ahw->fw_hal_version);
146 static int qlcnic_83xx_init_non_privileged_vnic(struct qlcnic_adapter *adapter)
150 qlcnic_83xx_get_fw_version(adapter);
151 if (qlcnic_set_eswitch_port_config(adapter))
154 if (qlcnic_83xx_get_port_info(adapter))
157 qlcnic_83xx_config_vnic_buff_descriptors(adapter);
158 adapter->ahw->msix_supported = !!qlcnic_use_msi_x;
159 adapter->flags |= QLCNIC_ADAPTER_INITIALIZED;
161 dev_info(&adapter->pdev->dev, "HAL Version: %d, Virtual function\n",
162 adapter->ahw->fw_hal_version);
168 * qlcnic_83xx_vnic_opmode
170 * @adapter: adapter structure
171 * Identify virtual NIC operational modes.
173 * Returns: Success(0) or error code.
176 int qlcnic_83xx_config_vnic_opmode(struct qlcnic_adapter *adapter)
178 u32 op_mode, priv_level;
179 struct qlcnic_hardware_context *ahw = adapter->ahw;
180 struct qlcnic_nic_template *nic_ops = adapter->nic_ops;
182 qlcnic_get_func_no(adapter);
183 op_mode = QLCRDX(adapter->ahw, QLC_83XX_DRV_OP_MODE);
185 if (op_mode == QLC_83XX_DEFAULT_OPMODE)
186 priv_level = QLCNIC_MGMT_FUNC;
188 priv_level = QLC_83XX_GET_FUNC_PRIVILEGE(op_mode,
190 switch (priv_level) {
191 case 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;
196 case QLCNIC_PRIV_FUNC:
197 ahw->op_mode = QLCNIC_PRIV_FUNC;
198 ahw->idc.state_entry = qlcnic_83xx_idc_vnic_pf_entry;
199 nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
201 case QLCNIC_MGMT_FUNC:
202 ahw->op_mode = QLCNIC_MGMT_FUNC;
203 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
204 nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
207 dev_err(&adapter->pdev->dev, "Invalid Virtual NIC opmode\n");
211 if (ahw->capabilities & BIT_23)
212 adapter->flags |= QLCNIC_ESWITCH_ENABLED;
214 adapter->flags &= ~QLCNIC_ESWITCH_ENABLED;
216 ahw->idc.vnic_state = QLCNIC_DEV_NPAR_NON_OPER;
217 ahw->idc.vnic_wait_limit = QLCNIC_DEV_NPAR_OPER_TIMEO;
222 int qlcnic_83xx_check_vnic_state(struct qlcnic_adapter *adapter)
224 struct qlcnic_hardware_context *ahw = adapter->ahw;
225 struct qlc_83xx_idc *idc = &ahw->idc;
228 state = QLCRDX(ahw, QLC_83XX_VNIC_STATE);
229 while (state != QLCNIC_DEV_NPAR_OPER && idc->vnic_wait_limit--) {
231 state = QLCRDX(ahw, QLC_83XX_VNIC_STATE);
234 if (!idc->vnic_wait_limit) {
235 dev_err(&adapter->pdev->dev,
236 "vNIC mode not operational, state check timed out.\n");