aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/qlcnic/qlcnic_main.c
diff options
context:
space:
mode:
authorGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
committerGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
commitc71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch)
treeecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /drivers/net/qlcnic/qlcnic_main.c
parentea53c912f8a86a8567697115b6a0d8152beee5c8 (diff)
parent6a00f206debf8a5c8899055726ad127dbeeed098 (diff)
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts: litmus/sched_cedf.c
Diffstat (limited to 'drivers/net/qlcnic/qlcnic_main.c')
-rw-r--r--drivers/net/qlcnic/qlcnic_main.c1815
1 files changed, 1239 insertions, 576 deletions
diff --git a/drivers/net/qlcnic/qlcnic_main.c b/drivers/net/qlcnic/qlcnic_main.c
index 66eea5972020..0f6af5c61a7c 100644
--- a/drivers/net/qlcnic/qlcnic_main.c
+++ b/drivers/net/qlcnic/qlcnic_main.c
@@ -1,25 +1,8 @@
1/* 1/*
2 * Copyright (C) 2009 - QLogic Corporation. 2 * QLogic qlcnic NIC Driver
3 * All rights reserved. 3 * Copyright (c) 2009-2010 QLogic Corporation
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18 * MA 02111-1307, USA.
19 *
20 * The full GNU General Public License is included in this distribution
21 * in the file called "COPYING".
22 * 4 *
5 * See LICENSE.qlcnic for copyright and licensing details.
23 */ 6 */
24 7
25#include <linux/slab.h> 8#include <linux/slab.h>
@@ -28,13 +11,14 @@
28 11
29#include "qlcnic.h" 12#include "qlcnic.h"
30 13
14#include <linux/swab.h>
31#include <linux/dma-mapping.h> 15#include <linux/dma-mapping.h>
32#include <linux/if_vlan.h>
33#include <net/ip.h> 16#include <net/ip.h>
34#include <linux/ipv6.h> 17#include <linux/ipv6.h>
35#include <linux/inetdevice.h> 18#include <linux/inetdevice.h>
36#include <linux/sysfs.h> 19#include <linux/sysfs.h>
37#include <linux/aer.h> 20#include <linux/aer.h>
21#include <linux/log2.h>
38 22
39MODULE_DESCRIPTION("QLogic 1/10 GbE Converged/Intelligent Ethernet Driver"); 23MODULE_DESCRIPTION("QLogic 1/10 GbE Converged/Intelligent Ethernet Driver");
40MODULE_LICENSE("GPL"); 24MODULE_LICENSE("GPL");
@@ -45,29 +29,29 @@ char qlcnic_driver_name[] = "qlcnic";
45static const char qlcnic_driver_string[] = "QLogic 1/10 GbE " 29static const char qlcnic_driver_string[] = "QLogic 1/10 GbE "
46 "Converged/Intelligent Ethernet Driver v" QLCNIC_LINUX_VERSIONID; 30 "Converged/Intelligent Ethernet Driver v" QLCNIC_LINUX_VERSIONID;
47 31
48static int port_mode = QLCNIC_PORT_MODE_AUTO_NEG; 32static struct workqueue_struct *qlcnic_wq;
49 33static int qlcnic_mac_learn;
50/* Default to restricted 1G auto-neg mode */ 34module_param(qlcnic_mac_learn, int, 0444);
51static int wol_port_mode = 5; 35MODULE_PARM_DESC(qlcnic_mac_learn, "Mac Filter (0=disabled, 1=enabled)");
52 36
53static int use_msi = 1; 37static int use_msi = 1;
54module_param(use_msi, int, 0644); 38module_param(use_msi, int, 0444);
55MODULE_PARM_DESC(use_msi, "MSI interrupt (0=disabled, 1=enabled"); 39MODULE_PARM_DESC(use_msi, "MSI interrupt (0=disabled, 1=enabled");
56 40
57static int use_msi_x = 1; 41static int use_msi_x = 1;
58module_param(use_msi_x, int, 0644); 42module_param(use_msi_x, int, 0444);
59MODULE_PARM_DESC(use_msi_x, "MSI-X interrupt (0=disabled, 1=enabled"); 43MODULE_PARM_DESC(use_msi_x, "MSI-X interrupt (0=disabled, 1=enabled");
60 44
61static int auto_fw_reset = AUTO_FW_RESET_ENABLED; 45static int auto_fw_reset = 1;
62module_param(auto_fw_reset, int, 0644); 46module_param(auto_fw_reset, int, 0644);
63MODULE_PARM_DESC(auto_fw_reset, "Auto firmware reset (0=disabled, 1=enabled"); 47MODULE_PARM_DESC(auto_fw_reset, "Auto firmware reset (0=disabled, 1=enabled");
64 48
65static int load_fw_file; 49static int load_fw_file;
66module_param(load_fw_file, int, 0644); 50module_param(load_fw_file, int, 0444);
67MODULE_PARM_DESC(load_fw_file, "Load firmware from (0=flash, 1=file"); 51MODULE_PARM_DESC(load_fw_file, "Load firmware from (0=flash, 1=file");
68 52
69static int qlcnic_config_npars; 53static int qlcnic_config_npars;
70module_param(qlcnic_config_npars, int, 0644); 54module_param(qlcnic_config_npars, int, 0444);
71MODULE_PARM_DESC(qlcnic_config_npars, "Configure NPARs (0=disabled, 1=enabled"); 55MODULE_PARM_DESC(qlcnic_config_npars, "Configure NPARs (0=disabled, 1=enabled");
72 56
73static int __devinit qlcnic_probe(struct pci_dev *pdev, 57static int __devinit qlcnic_probe(struct pci_dev *pdev,
@@ -94,7 +78,7 @@ static void qlcnic_create_diag_entries(struct qlcnic_adapter *adapter);
94static void qlcnic_remove_diag_entries(struct qlcnic_adapter *adapter); 78static void qlcnic_remove_diag_entries(struct qlcnic_adapter *adapter);
95 79
96static void qlcnic_idc_debug_info(struct qlcnic_adapter *adapter, u8 encoding); 80static void qlcnic_idc_debug_info(struct qlcnic_adapter *adapter, u8 encoding);
97static void qlcnic_clr_all_drv_state(struct qlcnic_adapter *adapter); 81static void qlcnic_clr_all_drv_state(struct qlcnic_adapter *adapter, u8);
98static int qlcnic_can_start_firmware(struct qlcnic_adapter *adapter); 82static int qlcnic_can_start_firmware(struct qlcnic_adapter *adapter);
99 83
100static irqreturn_t qlcnic_tmp_intr(int irq, void *data); 84static irqreturn_t qlcnic_tmp_intr(int irq, void *data);
@@ -103,13 +87,20 @@ static irqreturn_t qlcnic_msi_intr(int irq, void *data);
103static irqreturn_t qlcnic_msix_intr(int irq, void *data); 87static irqreturn_t qlcnic_msix_intr(int irq, void *data);
104 88
105static struct net_device_stats *qlcnic_get_stats(struct net_device *netdev); 89static struct net_device_stats *qlcnic_get_stats(struct net_device *netdev);
106static void qlcnic_config_indev_addr(struct net_device *dev, unsigned long); 90static void qlcnic_restore_indev_addr(struct net_device *dev, unsigned long);
107static int qlcnic_start_firmware(struct qlcnic_adapter *); 91static int qlcnic_start_firmware(struct qlcnic_adapter *);
108 92
93static void qlcnic_alloc_lb_filters_mem(struct qlcnic_adapter *adapter);
94static void qlcnic_free_lb_filters_mem(struct qlcnic_adapter *adapter);
109static void qlcnic_dev_set_npar_ready(struct qlcnic_adapter *); 95static void qlcnic_dev_set_npar_ready(struct qlcnic_adapter *);
110static int qlcnicvf_config_led(struct qlcnic_adapter *, u32, u32); 96static int qlcnicvf_config_led(struct qlcnic_adapter *, u32, u32);
111static int qlcnicvf_config_bridged_mode(struct qlcnic_adapter *, u32); 97static int qlcnicvf_config_bridged_mode(struct qlcnic_adapter *, u32);
112static int qlcnicvf_start_firmware(struct qlcnic_adapter *); 98static int qlcnicvf_start_firmware(struct qlcnic_adapter *);
99static void qlcnic_set_netdev_features(struct qlcnic_adapter *,
100 struct qlcnic_esw_func_cfg *);
101static void qlcnic_vlan_rx_add(struct net_device *, u16);
102static void qlcnic_vlan_rx_del(struct net_device *, u16);
103
113/* PCI Device ID Table */ 104/* PCI Device ID Table */
114#define ENTRY(device) \ 105#define ENTRY(device) \
115 {PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, (device)), \ 106 {PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, (device)), \
@@ -125,7 +116,7 @@ static DEFINE_PCI_DEVICE_TABLE(qlcnic_pci_tbl) = {
125MODULE_DEVICE_TABLE(pci, qlcnic_pci_tbl); 116MODULE_DEVICE_TABLE(pci, qlcnic_pci_tbl);
126 117
127 118
128void 119inline void
129qlcnic_update_cmd_producer(struct qlcnic_adapter *adapter, 120qlcnic_update_cmd_producer(struct qlcnic_adapter *adapter,
130 struct qlcnic_host_tx_ring *tx_ring) 121 struct qlcnic_host_tx_ring *tx_ring)
131{ 122{
@@ -164,7 +155,7 @@ qlcnic_alloc_sds_rings(struct qlcnic_recv_context *recv_ctx, int count)
164 155
165 recv_ctx->sds_rings = kzalloc(size, GFP_KERNEL); 156 recv_ctx->sds_rings = kzalloc(size, GFP_KERNEL);
166 157
167 return (recv_ctx->sds_rings == NULL); 158 return recv_ctx->sds_rings == NULL;
168} 159}
169 160
170static void 161static void
@@ -181,7 +172,7 @@ qlcnic_napi_add(struct qlcnic_adapter *adapter, struct net_device *netdev)
181{ 172{
182 int ring; 173 int ring;
183 struct qlcnic_host_sds_ring *sds_ring; 174 struct qlcnic_host_sds_ring *sds_ring;
184 struct qlcnic_recv_context *recv_ctx = &adapter->recv_ctx; 175 struct qlcnic_recv_context *recv_ctx = adapter->recv_ctx;
185 176
186 if (qlcnic_alloc_sds_rings(recv_ctx, adapter->max_sds_rings)) 177 if (qlcnic_alloc_sds_rings(recv_ctx, adapter->max_sds_rings))
187 return -ENOMEM; 178 return -ENOMEM;
@@ -205,14 +196,14 @@ qlcnic_napi_del(struct qlcnic_adapter *adapter)
205{ 196{
206 int ring; 197 int ring;
207 struct qlcnic_host_sds_ring *sds_ring; 198 struct qlcnic_host_sds_ring *sds_ring;
208 struct qlcnic_recv_context *recv_ctx = &adapter->recv_ctx; 199 struct qlcnic_recv_context *recv_ctx = adapter->recv_ctx;
209 200
210 for (ring = 0; ring < adapter->max_sds_rings; ring++) { 201 for (ring = 0; ring < adapter->max_sds_rings; ring++) {
211 sds_ring = &recv_ctx->sds_rings[ring]; 202 sds_ring = &recv_ctx->sds_rings[ring];
212 netif_napi_del(&sds_ring->napi); 203 netif_napi_del(&sds_ring->napi);
213 } 204 }
214 205
215 qlcnic_free_sds_rings(&adapter->recv_ctx); 206 qlcnic_free_sds_rings(adapter->recv_ctx);
216} 207}
217 208
218static void 209static void
@@ -220,7 +211,7 @@ qlcnic_napi_enable(struct qlcnic_adapter *adapter)
220{ 211{
221 int ring; 212 int ring;
222 struct qlcnic_host_sds_ring *sds_ring; 213 struct qlcnic_host_sds_ring *sds_ring;
223 struct qlcnic_recv_context *recv_ctx = &adapter->recv_ctx; 214 struct qlcnic_recv_context *recv_ctx = adapter->recv_ctx;
224 215
225 if (adapter->is_up != QLCNIC_ADAPTER_UP_MAGIC) 216 if (adapter->is_up != QLCNIC_ADAPTER_UP_MAGIC)
226 return; 217 return;
@@ -237,7 +228,7 @@ qlcnic_napi_disable(struct qlcnic_adapter *adapter)
237{ 228{
238 int ring; 229 int ring;
239 struct qlcnic_host_sds_ring *sds_ring; 230 struct qlcnic_host_sds_ring *sds_ring;
240 struct qlcnic_recv_context *recv_ctx = &adapter->recv_ctx; 231 struct qlcnic_recv_context *recv_ctx = adapter->recv_ctx;
241 232
242 if (adapter->is_up != QLCNIC_ADAPTER_UP_MAGIC) 233 if (adapter->is_up != QLCNIC_ADAPTER_UP_MAGIC)
243 return; 234 return;
@@ -255,40 +246,6 @@ static void qlcnic_clear_stats(struct qlcnic_adapter *adapter)
255 memset(&adapter->stats, 0, sizeof(adapter->stats)); 246 memset(&adapter->stats, 0, sizeof(adapter->stats));
256} 247}
257 248
258static void qlcnic_set_port_mode(struct qlcnic_adapter *adapter)
259{
260 u32 val, data;
261
262 val = adapter->ahw.board_type;
263 if ((val == QLCNIC_BRDTYPE_P3_HMEZ) ||
264 (val == QLCNIC_BRDTYPE_P3_XG_LOM)) {
265 if (port_mode == QLCNIC_PORT_MODE_802_3_AP) {
266 data = QLCNIC_PORT_MODE_802_3_AP;
267 QLCWR32(adapter, QLCNIC_PORT_MODE_ADDR, data);
268 } else if (port_mode == QLCNIC_PORT_MODE_XG) {
269 data = QLCNIC_PORT_MODE_XG;
270 QLCWR32(adapter, QLCNIC_PORT_MODE_ADDR, data);
271 } else if (port_mode == QLCNIC_PORT_MODE_AUTO_NEG_1G) {
272 data = QLCNIC_PORT_MODE_AUTO_NEG_1G;
273 QLCWR32(adapter, QLCNIC_PORT_MODE_ADDR, data);
274 } else if (port_mode == QLCNIC_PORT_MODE_AUTO_NEG_XG) {
275 data = QLCNIC_PORT_MODE_AUTO_NEG_XG;
276 QLCWR32(adapter, QLCNIC_PORT_MODE_ADDR, data);
277 } else {
278 data = QLCNIC_PORT_MODE_AUTO_NEG;
279 QLCWR32(adapter, QLCNIC_PORT_MODE_ADDR, data);
280 }
281
282 if ((wol_port_mode != QLCNIC_PORT_MODE_802_3_AP) &&
283 (wol_port_mode != QLCNIC_PORT_MODE_XG) &&
284 (wol_port_mode != QLCNIC_PORT_MODE_AUTO_NEG_1G) &&
285 (wol_port_mode != QLCNIC_PORT_MODE_AUTO_NEG_XG)) {
286 wol_port_mode = QLCNIC_PORT_MODE_AUTO_NEG;
287 }
288 QLCWR32(adapter, QLCNIC_WOL_PORT_MODE, wol_port_mode);
289 }
290}
291
292static void qlcnic_set_msix_bit(struct pci_dev *pdev, int enable) 249static void qlcnic_set_msix_bit(struct pci_dev *pdev, int enable)
293{ 250{
294 u32 control; 251 u32 control;
@@ -320,7 +277,7 @@ qlcnic_read_mac_addr(struct qlcnic_adapter *adapter)
320 struct net_device *netdev = adapter->netdev; 277 struct net_device *netdev = adapter->netdev;
321 struct pci_dev *pdev = adapter->pdev; 278 struct pci_dev *pdev = adapter->pdev;
322 279
323 if (adapter->nic_ops->get_mac_addr(adapter, mac_addr) != 0) 280 if (qlcnic_get_mac_address(adapter, mac_addr) != 0)
324 return -EIO; 281 return -EIO;
325 282
326 memcpy(netdev->dev_addr, mac_addr, ETH_ALEN); 283 memcpy(netdev->dev_addr, mac_addr, ETH_ALEN);
@@ -341,6 +298,9 @@ static int qlcnic_set_mac(struct net_device *netdev, void *p)
341 struct qlcnic_adapter *adapter = netdev_priv(netdev); 298 struct qlcnic_adapter *adapter = netdev_priv(netdev);
342 struct sockaddr *addr = p; 299 struct sockaddr *addr = p;
343 300
301 if ((adapter->flags & QLCNIC_MAC_OVERRIDE_DISABLED))
302 return -EOPNOTSUPP;
303
344 if (!is_valid_ether_addr(addr->sa_data)) 304 if (!is_valid_ether_addr(addr->sa_data))
345 return -EINVAL; 305 return -EINVAL;
346 306
@@ -369,92 +329,109 @@ static const struct net_device_ops qlcnic_netdev_ops = {
369 .ndo_set_multicast_list = qlcnic_set_multi, 329 .ndo_set_multicast_list = qlcnic_set_multi,
370 .ndo_set_mac_address = qlcnic_set_mac, 330 .ndo_set_mac_address = qlcnic_set_mac,
371 .ndo_change_mtu = qlcnic_change_mtu, 331 .ndo_change_mtu = qlcnic_change_mtu,
332 .ndo_fix_features = qlcnic_fix_features,
333 .ndo_set_features = qlcnic_set_features,
372 .ndo_tx_timeout = qlcnic_tx_timeout, 334 .ndo_tx_timeout = qlcnic_tx_timeout,
335 .ndo_vlan_rx_add_vid = qlcnic_vlan_rx_add,
336 .ndo_vlan_rx_kill_vid = qlcnic_vlan_rx_del,
373#ifdef CONFIG_NET_POLL_CONTROLLER 337#ifdef CONFIG_NET_POLL_CONTROLLER
374 .ndo_poll_controller = qlcnic_poll_controller, 338 .ndo_poll_controller = qlcnic_poll_controller,
375#endif 339#endif
376}; 340};
377 341
378static struct qlcnic_nic_template qlcnic_ops = { 342static struct qlcnic_nic_template qlcnic_ops = {
379 .get_mac_addr = qlcnic_get_mac_address,
380 .config_bridged_mode = qlcnic_config_bridged_mode, 343 .config_bridged_mode = qlcnic_config_bridged_mode,
381 .config_led = qlcnic_config_led, 344 .config_led = qlcnic_config_led,
382 .start_firmware = qlcnic_start_firmware 345 .start_firmware = qlcnic_start_firmware
383}; 346};
384 347
385static struct qlcnic_nic_template qlcnic_vf_ops = { 348static struct qlcnic_nic_template qlcnic_vf_ops = {
386 .get_mac_addr = qlcnic_get_mac_address,
387 .config_bridged_mode = qlcnicvf_config_bridged_mode, 349 .config_bridged_mode = qlcnicvf_config_bridged_mode,
388 .config_led = qlcnicvf_config_led, 350 .config_led = qlcnicvf_config_led,
389 .start_firmware = qlcnicvf_start_firmware 351 .start_firmware = qlcnicvf_start_firmware
390}; 352};
391 353
392static void 354static int qlcnic_enable_msix(struct qlcnic_adapter *adapter, u32 num_msix)
393qlcnic_setup_intr(struct qlcnic_adapter *adapter)
394{ 355{
395 const struct qlcnic_legacy_intr_set *legacy_intrp;
396 struct pci_dev *pdev = adapter->pdev; 356 struct pci_dev *pdev = adapter->pdev;
397 int err, num_msix; 357 int err = -1;
398
399 if (adapter->rss_supported) {
400 num_msix = (num_online_cpus() >= MSIX_ENTRIES_PER_ADAPTER) ?
401 MSIX_ENTRIES_PER_ADAPTER : 2;
402 } else
403 num_msix = 1;
404 358
405 adapter->max_sds_rings = 1; 359 adapter->max_sds_rings = 1;
406
407 adapter->flags &= ~(QLCNIC_MSI_ENABLED | QLCNIC_MSIX_ENABLED); 360 adapter->flags &= ~(QLCNIC_MSI_ENABLED | QLCNIC_MSIX_ENABLED);
408
409 legacy_intrp = &legacy_intr[adapter->ahw.pci_func];
410
411 adapter->int_vec_bit = legacy_intrp->int_vec_bit;
412 adapter->tgt_status_reg = qlcnic_get_ioaddr(adapter,
413 legacy_intrp->tgt_status_reg);
414 adapter->tgt_mask_reg = qlcnic_get_ioaddr(adapter,
415 legacy_intrp->tgt_mask_reg);
416 adapter->isr_int_vec = qlcnic_get_ioaddr(adapter, ISR_INT_VECTOR);
417
418 adapter->crb_int_state_reg = qlcnic_get_ioaddr(adapter,
419 ISR_INT_STATE_REG);
420
421 qlcnic_set_msix_bit(pdev, 0); 361 qlcnic_set_msix_bit(pdev, 0);
422 362
423 if (adapter->msix_supported) { 363 if (adapter->msix_supported) {
424 364 enable_msix:
425 qlcnic_init_msix_entries(adapter, num_msix); 365 qlcnic_init_msix_entries(adapter, num_msix);
426 err = pci_enable_msix(pdev, adapter->msix_entries, num_msix); 366 err = pci_enable_msix(pdev, adapter->msix_entries, num_msix);
427 if (err == 0) { 367 if (err == 0) {
428 adapter->flags |= QLCNIC_MSIX_ENABLED; 368 adapter->flags |= QLCNIC_MSIX_ENABLED;
429 qlcnic_set_msix_bit(pdev, 1); 369 qlcnic_set_msix_bit(pdev, 1);
430 370
431 if (adapter->rss_supported) 371 adapter->max_sds_rings = num_msix;
432 adapter->max_sds_rings = num_msix;
433 372
434 dev_info(&pdev->dev, "using msi-x interrupts\n"); 373 dev_info(&pdev->dev, "using msi-x interrupts\n");
435 return; 374 return err;
375 }
376 if (err > 0) {
377 num_msix = rounddown_pow_of_two(err);
378 if (num_msix)
379 goto enable_msix;
436 } 380 }
381 }
382 return err;
383}
437 384
438 if (err > 0)
439 pci_disable_msix(pdev);
440 385
441 /* fall through for msi */ 386static void qlcnic_enable_msi_legacy(struct qlcnic_adapter *adapter)
442 } 387{
388 const struct qlcnic_legacy_intr_set *legacy_intrp;
389 struct pci_dev *pdev = adapter->pdev;
443 390
444 if (use_msi && !pci_enable_msi(pdev)) { 391 if (use_msi && !pci_enable_msi(pdev)) {
445 adapter->flags |= QLCNIC_MSI_ENABLED; 392 adapter->flags |= QLCNIC_MSI_ENABLED;
446 adapter->tgt_status_reg = qlcnic_get_ioaddr(adapter, 393 adapter->tgt_status_reg = qlcnic_get_ioaddr(adapter,
447 msi_tgt_status[adapter->ahw.pci_func]); 394 msi_tgt_status[adapter->ahw->pci_func]);
448 dev_info(&pdev->dev, "using msi interrupts\n"); 395 dev_info(&pdev->dev, "using msi interrupts\n");
449 adapter->msix_entries[0].vector = pdev->irq; 396 adapter->msix_entries[0].vector = pdev->irq;
450 return; 397 return;
451 } 398 }
452 399
400 legacy_intrp = &legacy_intr[adapter->ahw->pci_func];
401
402 adapter->int_vec_bit = legacy_intrp->int_vec_bit;
403 adapter->tgt_status_reg = qlcnic_get_ioaddr(adapter,
404 legacy_intrp->tgt_status_reg);
405 adapter->tgt_mask_reg = qlcnic_get_ioaddr(adapter,
406 legacy_intrp->tgt_mask_reg);
407 adapter->isr_int_vec = qlcnic_get_ioaddr(adapter, ISR_INT_VECTOR);
408
409 adapter->crb_int_state_reg = qlcnic_get_ioaddr(adapter,
410 ISR_INT_STATE_REG);
453 dev_info(&pdev->dev, "using legacy interrupts\n"); 411 dev_info(&pdev->dev, "using legacy interrupts\n");
454 adapter->msix_entries[0].vector = pdev->irq; 412 adapter->msix_entries[0].vector = pdev->irq;
455} 413}
456 414
457static void 415static void
416qlcnic_setup_intr(struct qlcnic_adapter *adapter)
417{
418 int num_msix;
419
420 if (adapter->msix_supported) {
421 num_msix = (num_online_cpus() >=
422 QLCNIC_DEF_NUM_STS_DESC_RINGS) ?
423 QLCNIC_DEF_NUM_STS_DESC_RINGS :
424 QLCNIC_MIN_NUM_RSS_RINGS;
425 } else
426 num_msix = 1;
427
428 if (!qlcnic_enable_msix(adapter, num_msix))
429 return;
430
431 qlcnic_enable_msi_legacy(adapter);
432}
433
434static void
458qlcnic_teardown_intr(struct qlcnic_adapter *adapter) 435qlcnic_teardown_intr(struct qlcnic_adapter *adapter)
459{ 436{
460 if (adapter->flags & QLCNIC_MSIX_ENABLED) 437 if (adapter->flags & QLCNIC_MSIX_ENABLED)
@@ -466,15 +443,15 @@ qlcnic_teardown_intr(struct qlcnic_adapter *adapter)
466static void 443static void
467qlcnic_cleanup_pci_map(struct qlcnic_adapter *adapter) 444qlcnic_cleanup_pci_map(struct qlcnic_adapter *adapter)
468{ 445{
469 if (adapter->ahw.pci_base0 != NULL) 446 if (adapter->ahw->pci_base0 != NULL)
470 iounmap(adapter->ahw.pci_base0); 447 iounmap(adapter->ahw->pci_base0);
471} 448}
472 449
473static int 450static int
474qlcnic_init_pci_info(struct qlcnic_adapter *adapter) 451qlcnic_init_pci_info(struct qlcnic_adapter *adapter)
475{ 452{
476 struct qlcnic_pci_info *pci_info; 453 struct qlcnic_pci_info *pci_info;
477 int i, ret = 0, err; 454 int i, ret = 0;
478 u8 pfn; 455 u8 pfn;
479 456
480 pci_info = kcalloc(QLCNIC_MAX_PCI_FUNC, sizeof(*pci_info), GFP_KERNEL); 457 pci_info = kcalloc(QLCNIC_MAX_PCI_FUNC, sizeof(*pci_info), GFP_KERNEL);
@@ -484,14 +461,14 @@ qlcnic_init_pci_info(struct qlcnic_adapter *adapter)
484 adapter->npars = kzalloc(sizeof(struct qlcnic_npar_info) * 461 adapter->npars = kzalloc(sizeof(struct qlcnic_npar_info) *
485 QLCNIC_MAX_PCI_FUNC, GFP_KERNEL); 462 QLCNIC_MAX_PCI_FUNC, GFP_KERNEL);
486 if (!adapter->npars) { 463 if (!adapter->npars) {
487 err = -ENOMEM; 464 ret = -ENOMEM;
488 goto err_pci_info; 465 goto err_pci_info;
489 } 466 }
490 467
491 adapter->eswitch = kzalloc(sizeof(struct qlcnic_eswitch) * 468 adapter->eswitch = kzalloc(sizeof(struct qlcnic_eswitch) *
492 QLCNIC_NIU_MAX_XG_PORTS, GFP_KERNEL); 469 QLCNIC_NIU_MAX_XG_PORTS, GFP_KERNEL);
493 if (!adapter->eswitch) { 470 if (!adapter->eswitch) {
494 err = -ENOMEM; 471 ret = -ENOMEM;
495 goto err_npars; 472 goto err_npars;
496 } 473 }
497 474
@@ -501,12 +478,13 @@ qlcnic_init_pci_info(struct qlcnic_adapter *adapter)
501 478
502 for (i = 0; i < QLCNIC_MAX_PCI_FUNC; i++) { 479 for (i = 0; i < QLCNIC_MAX_PCI_FUNC; i++) {
503 pfn = pci_info[i].id; 480 pfn = pci_info[i].id;
504 if (pfn > QLCNIC_MAX_PCI_FUNC) 481 if (pfn > QLCNIC_MAX_PCI_FUNC) {
505 return QL_STATUS_INVALID_PARAM; 482 ret = QL_STATUS_INVALID_PARAM;
506 adapter->npars[pfn].active = pci_info[i].active; 483 goto err_eswitch;
507 adapter->npars[pfn].type = pci_info[i].type; 484 }
508 adapter->npars[pfn].phy_port = pci_info[i].default_port; 485 adapter->npars[pfn].active = (u8)pci_info[i].active;
509 adapter->npars[pfn].mac_learning = DEFAULT_MAC_LEARN; 486 adapter->npars[pfn].type = (u8)pci_info[i].type;
487 adapter->npars[pfn].phy_port = (u8)pci_info[i].default_port;
510 adapter->npars[pfn].min_bw = pci_info[i].tx_min_bw; 488 adapter->npars[pfn].min_bw = pci_info[i].tx_min_bw;
511 adapter->npars[pfn].max_bw = pci_info[i].tx_max_bw; 489 adapter->npars[pfn].max_bw = pci_info[i].tx_max_bw;
512 } 490 }
@@ -536,111 +514,71 @@ qlcnic_set_function_modes(struct qlcnic_adapter *adapter)
536 u32 ref_count; 514 u32 ref_count;
537 int i, ret = 1; 515 int i, ret = 1;
538 u32 data = QLCNIC_MGMT_FUNC; 516 u32 data = QLCNIC_MGMT_FUNC;
539 void __iomem *priv_op = adapter->ahw.pci_base0 + QLCNIC_DRV_OP_MODE; 517 void __iomem *priv_op = adapter->ahw->pci_base0 + QLCNIC_DRV_OP_MODE;
540 518
541 /* If other drivers are not in use set their privilege level */ 519 /* If other drivers are not in use set their privilege level */
542 ref_count = QLCRD32(adapter, QLCNIC_CRB_DEV_REF_COUNT); 520 ref_count = QLCRD32(adapter, QLCNIC_CRB_DRV_ACTIVE);
543 ret = qlcnic_api_lock(adapter); 521 ret = qlcnic_api_lock(adapter);
544 if (ret) 522 if (ret)
545 goto err_lock; 523 goto err_lock;
546 if (QLC_DEV_CLR_REF_CNT(ref_count, adapter->ahw.pci_func))
547 goto err_npar;
548 524
549 if (qlcnic_config_npars) { 525 if (qlcnic_config_npars) {
550 for (i = 0; i < QLCNIC_MAX_PCI_FUNC; i++) { 526 for (i = 0; i < QLCNIC_MAX_PCI_FUNC; i++) {
551 id = i; 527 id = i;
552 if (adapter->npars[i].type != QLCNIC_TYPE_NIC || 528 if (adapter->npars[i].type != QLCNIC_TYPE_NIC ||
553 id == adapter->ahw.pci_func) 529 id == adapter->ahw->pci_func)
554 continue; 530 continue;
555 data |= (qlcnic_config_npars & 531 data |= (qlcnic_config_npars &
556 QLC_DEV_SET_DRV(0xf, id)); 532 QLC_DEV_SET_DRV(0xf, id));
557 } 533 }
558 } else { 534 } else {
559 data = readl(priv_op); 535 data = readl(priv_op);
560 data = (data & ~QLC_DEV_SET_DRV(0xf, adapter->ahw.pci_func)) | 536 data = (data & ~QLC_DEV_SET_DRV(0xf, adapter->ahw->pci_func)) |
561 (QLC_DEV_SET_DRV(QLCNIC_MGMT_FUNC, 537 (QLC_DEV_SET_DRV(QLCNIC_MGMT_FUNC,
562 adapter->ahw.pci_func)); 538 adapter->ahw->pci_func));
563 } 539 }
564 writel(data, priv_op); 540 writel(data, priv_op);
565err_npar:
566 qlcnic_api_unlock(adapter); 541 qlcnic_api_unlock(adapter);
567err_lock: 542err_lock:
568 return ret; 543 return ret;
569} 544}
570 545
571static u32 546static void
572qlcnic_get_driver_mode(struct qlcnic_adapter *adapter) 547qlcnic_check_vf(struct qlcnic_adapter *adapter)
573{ 548{
574 void __iomem *msix_base_addr; 549 void __iomem *msix_base_addr;
575 void __iomem *priv_op; 550 void __iomem *priv_op;
576 struct qlcnic_info nic_info;
577 u32 func; 551 u32 func;
578 u32 msix_base; 552 u32 msix_base;
579 u32 op_mode, priv_level; 553 u32 op_mode, priv_level;
580 554
581 /* Determine FW API version */ 555 /* Determine FW API version */
582 adapter->fw_hal_version = readl(adapter->ahw.pci_base0 + QLCNIC_FW_API); 556 adapter->fw_hal_version = readl(adapter->ahw->pci_base0 +
557 QLCNIC_FW_API);
583 558
584 /* Find PCI function number */ 559 /* Find PCI function number */
585 pci_read_config_dword(adapter->pdev, QLCNIC_MSIX_TABLE_OFFSET, &func); 560 pci_read_config_dword(adapter->pdev, QLCNIC_MSIX_TABLE_OFFSET, &func);
586 msix_base_addr = adapter->ahw.pci_base0 + QLCNIC_MSIX_BASE; 561 msix_base_addr = adapter->ahw->pci_base0 + QLCNIC_MSIX_BASE;
587 msix_base = readl(msix_base_addr); 562 msix_base = readl(msix_base_addr);
588 func = (func - msix_base)/QLCNIC_MSIX_TBL_PGSIZE; 563 func = (func - msix_base)/QLCNIC_MSIX_TBL_PGSIZE;
589 adapter->ahw.pci_func = func; 564 adapter->ahw->pci_func = func;
590
591 if (!qlcnic_get_nic_info(adapter, &nic_info, adapter->ahw.pci_func)) {
592 adapter->capabilities = nic_info.capabilities;
593
594 if (adapter->capabilities & BIT_6)
595 adapter->flags |= QLCNIC_ESWITCH_ENABLED;
596 else
597 adapter->flags &= ~QLCNIC_ESWITCH_ENABLED;
598 }
599
600 if (!(adapter->flags & QLCNIC_ESWITCH_ENABLED)) {
601 adapter->nic_ops = &qlcnic_ops;
602 return adapter->fw_hal_version;
603 }
604 565
605 /* Determine function privilege level */ 566 /* Determine function privilege level */
606 priv_op = adapter->ahw.pci_base0 + QLCNIC_DRV_OP_MODE; 567 priv_op = adapter->ahw->pci_base0 + QLCNIC_DRV_OP_MODE;
607 op_mode = readl(priv_op); 568 op_mode = readl(priv_op);
608 if (op_mode == QLC_DEV_DRV_DEFAULT) 569 if (op_mode == QLC_DEV_DRV_DEFAULT)
609 priv_level = QLCNIC_MGMT_FUNC; 570 priv_level = QLCNIC_MGMT_FUNC;
610 else 571 else
611 priv_level = QLC_DEV_GET_DRV(op_mode, adapter->ahw.pci_func); 572 priv_level = QLC_DEV_GET_DRV(op_mode, adapter->ahw->pci_func);
612 573
613 switch (priv_level) { 574 if (priv_level == QLCNIC_NON_PRIV_FUNC) {
614 case QLCNIC_MGMT_FUNC:
615 adapter->op_mode = QLCNIC_MGMT_FUNC;
616 adapter->nic_ops = &qlcnic_ops;
617 qlcnic_init_pci_info(adapter);
618 /* Set privilege level for other functions */
619 qlcnic_set_function_modes(adapter);
620 dev_info(&adapter->pdev->dev,
621 "HAL Version: %d, Management function\n",
622 adapter->fw_hal_version);
623 break;
624 case QLCNIC_PRIV_FUNC:
625 adapter->op_mode = QLCNIC_PRIV_FUNC;
626 dev_info(&adapter->pdev->dev,
627 "HAL Version: %d, Privileged function\n",
628 adapter->fw_hal_version);
629 adapter->nic_ops = &qlcnic_ops;
630 break;
631 case QLCNIC_NON_PRIV_FUNC:
632 adapter->op_mode = QLCNIC_NON_PRIV_FUNC; 575 adapter->op_mode = QLCNIC_NON_PRIV_FUNC;
633 dev_info(&adapter->pdev->dev, 576 dev_info(&adapter->pdev->dev,
634 "HAL Version: %d Non Privileged function\n", 577 "HAL Version: %d Non Privileged function\n",
635 adapter->fw_hal_version); 578 adapter->fw_hal_version);
636 adapter->nic_ops = &qlcnic_vf_ops; 579 adapter->nic_ops = &qlcnic_vf_ops;
637 break; 580 } else
638 default: 581 adapter->nic_ops = &qlcnic_ops;
639 dev_info(&adapter->pdev->dev, "Unknown function mode: %d\n",
640 priv_level);
641 return 0;
642 }
643 return adapter->fw_hal_version;
644} 582}
645 583
646static int 584static int
@@ -670,16 +608,14 @@ qlcnic_setup_pci_map(struct qlcnic_adapter *adapter)
670 608
671 dev_info(&pdev->dev, "%dMB memory map\n", (int)(mem_len>>20)); 609 dev_info(&pdev->dev, "%dMB memory map\n", (int)(mem_len>>20));
672 610
673 adapter->ahw.pci_base0 = mem_ptr0; 611 adapter->ahw->pci_base0 = mem_ptr0;
674 adapter->ahw.pci_len0 = pci_len0; 612 adapter->ahw->pci_len0 = pci_len0;
675 613
676 if (!qlcnic_get_driver_mode(adapter)) { 614 qlcnic_check_vf(adapter);
677 iounmap(adapter->ahw.pci_base0);
678 return -EIO;
679 }
680 615
681 adapter->ahw.ocm_win_crb = qlcnic_get_ioaddr(adapter, 616 adapter->ahw->ocm_win_crb = qlcnic_get_ioaddr(adapter,
682 QLCNIC_PCIX_PS_REG(PCIX_OCM_WINDOW_REG(adapter->ahw.pci_func))); 617 QLCNIC_PCIX_PS_REG(PCIX_OCM_WINDOW_REG(
618 adapter->ahw->pci_func)));
683 619
684 return 0; 620 return 0;
685} 621}
@@ -711,25 +647,7 @@ static void
711qlcnic_check_options(struct qlcnic_adapter *adapter) 647qlcnic_check_options(struct qlcnic_adapter *adapter)
712{ 648{
713 u32 fw_major, fw_minor, fw_build; 649 u32 fw_major, fw_minor, fw_build;
714 char brd_name[QLCNIC_MAX_BOARD_NAME_LEN];
715 char serial_num[32];
716 int i, offset, val;
717 int *ptr32;
718 struct pci_dev *pdev = adapter->pdev; 650 struct pci_dev *pdev = adapter->pdev;
719 struct qlcnic_info nic_info;
720 adapter->driver_mismatch = 0;
721
722 ptr32 = (int *)&serial_num;
723 offset = QLCNIC_FW_SERIAL_NUM_OFFSET;
724 for (i = 0; i < 8; i++) {
725 if (qlcnic_rom_fast_read(adapter, offset, &val) == -1) {
726 dev_err(&pdev->dev, "error reading board info\n");
727 adapter->driver_mismatch = 1;
728 return;
729 }
730 ptr32[i] = cpu_to_le32(val);
731 offset += sizeof(u32);
732 }
733 651
734 fw_major = QLCRD32(adapter, QLCNIC_FW_VERSION_MAJOR); 652 fw_major = QLCRD32(adapter, QLCNIC_FW_VERSION_MAJOR);
735 fw_minor = QLCRD32(adapter, QLCNIC_FW_VERSION_MINOR); 653 fw_minor = QLCRD32(adapter, QLCNIC_FW_VERSION_MINOR);
@@ -737,157 +655,399 @@ qlcnic_check_options(struct qlcnic_adapter *adapter)
737 655
738 adapter->fw_version = QLCNIC_VERSION_CODE(fw_major, fw_minor, fw_build); 656 adapter->fw_version = QLCNIC_VERSION_CODE(fw_major, fw_minor, fw_build);
739 657
740 if (adapter->portnum == 0) {
741 get_brd_name(adapter, brd_name);
742
743 pr_info("%s: %s Board Chip rev 0x%x\n",
744 module_name(THIS_MODULE),
745 brd_name, adapter->ahw.revision_id);
746 }
747
748 dev_info(&pdev->dev, "firmware v%d.%d.%d\n", 658 dev_info(&pdev->dev, "firmware v%d.%d.%d\n",
749 fw_major, fw_minor, fw_build); 659 fw_major, fw_minor, fw_build);
660 if (adapter->ahw->port_type == QLCNIC_XGBE) {
661 if (adapter->flags & QLCNIC_ESWITCH_ENABLED) {
662 adapter->num_rxd = DEFAULT_RCV_DESCRIPTORS_VF;
663 adapter->max_rxd = MAX_RCV_DESCRIPTORS_VF;
664 } else {
665 adapter->num_rxd = DEFAULT_RCV_DESCRIPTORS_10G;
666 adapter->max_rxd = MAX_RCV_DESCRIPTORS_10G;
667 }
750 668
751 adapter->flags &= ~QLCNIC_LRO_ENABLED;
752
753 if (adapter->ahw.port_type == QLCNIC_XGBE) {
754 adapter->num_rxd = DEFAULT_RCV_DESCRIPTORS_10G;
755 adapter->num_jumbo_rxd = MAX_JUMBO_RCV_DESCRIPTORS_10G; 669 adapter->num_jumbo_rxd = MAX_JUMBO_RCV_DESCRIPTORS_10G;
756 } else if (adapter->ahw.port_type == QLCNIC_GBE) { 670 adapter->max_jumbo_rxd = MAX_JUMBO_RCV_DESCRIPTORS_10G;
671
672 } else if (adapter->ahw->port_type == QLCNIC_GBE) {
757 adapter->num_rxd = DEFAULT_RCV_DESCRIPTORS_1G; 673 adapter->num_rxd = DEFAULT_RCV_DESCRIPTORS_1G;
758 adapter->num_jumbo_rxd = MAX_JUMBO_RCV_DESCRIPTORS_1G; 674 adapter->num_jumbo_rxd = MAX_JUMBO_RCV_DESCRIPTORS_1G;
759 } 675 adapter->max_jumbo_rxd = MAX_JUMBO_RCV_DESCRIPTORS_1G;
760 676 adapter->max_rxd = MAX_RCV_DESCRIPTORS_1G;
761 if (!qlcnic_get_nic_info(adapter, &nic_info, adapter->ahw.pci_func)) {
762 adapter->physical_port = nic_info.phys_port;
763 adapter->switch_mode = nic_info.switch_mode;
764 adapter->max_tx_ques = nic_info.max_tx_ques;
765 adapter->max_rx_ques = nic_info.max_rx_ques;
766 adapter->capabilities = nic_info.capabilities;
767 adapter->max_mac_filters = nic_info.max_mac_filters;
768 adapter->max_mtu = nic_info.max_mtu;
769 } 677 }
770 678
771 adapter->msix_supported = !!use_msi_x; 679 adapter->msix_supported = !!use_msi_x;
772 adapter->rss_supported = !!use_msi_x;
773 680
774 adapter->num_txd = MAX_CMD_DESCRIPTORS; 681 adapter->num_txd = MAX_CMD_DESCRIPTORS;
775 682
776 adapter->max_rds_rings = 2; 683 adapter->max_rds_rings = MAX_RDS_RINGS;
684}
685
686static int
687qlcnic_initialize_nic(struct qlcnic_adapter *adapter)
688{
689 int err;
690 struct qlcnic_info nic_info;
691
692 err = qlcnic_get_nic_info(adapter, &nic_info, adapter->ahw->pci_func);
693 if (err)
694 return err;
695
696 adapter->physical_port = (u8)nic_info.phys_port;
697 adapter->switch_mode = nic_info.switch_mode;
698 adapter->max_tx_ques = nic_info.max_tx_ques;
699 adapter->max_rx_ques = nic_info.max_rx_ques;
700 adapter->capabilities = nic_info.capabilities;
701 adapter->max_mac_filters = nic_info.max_mac_filters;
702 adapter->max_mtu = nic_info.max_mtu;
703
704 if (adapter->capabilities & BIT_6)
705 adapter->flags |= QLCNIC_ESWITCH_ENABLED;
706 else
707 adapter->flags &= ~QLCNIC_ESWITCH_ENABLED;
708
709 return err;
710}
711
712static void
713qlcnic_set_vlan_config(struct qlcnic_adapter *adapter,
714 struct qlcnic_esw_func_cfg *esw_cfg)
715{
716 if (esw_cfg->discard_tagged)
717 adapter->flags &= ~QLCNIC_TAGGING_ENABLED;
718 else
719 adapter->flags |= QLCNIC_TAGGING_ENABLED;
720
721 if (esw_cfg->vlan_id)
722 adapter->pvid = esw_cfg->vlan_id;
723 else
724 adapter->pvid = 0;
725}
726
727static void
728qlcnic_vlan_rx_add(struct net_device *netdev, u16 vid)
729{
730 struct qlcnic_adapter *adapter = netdev_priv(netdev);
731 set_bit(vid, adapter->vlans);
732}
733
734static void
735qlcnic_vlan_rx_del(struct net_device *netdev, u16 vid)
736{
737 struct qlcnic_adapter *adapter = netdev_priv(netdev);
738
739 qlcnic_restore_indev_addr(netdev, NETDEV_DOWN);
740 clear_bit(vid, adapter->vlans);
741}
742
743static void
744qlcnic_set_eswitch_port_features(struct qlcnic_adapter *adapter,
745 struct qlcnic_esw_func_cfg *esw_cfg)
746{
747 adapter->flags &= ~(QLCNIC_MACSPOOF | QLCNIC_MAC_OVERRIDE_DISABLED |
748 QLCNIC_PROMISC_DISABLED);
749
750 if (esw_cfg->mac_anti_spoof)
751 adapter->flags |= QLCNIC_MACSPOOF;
752
753 if (!esw_cfg->mac_override)
754 adapter->flags |= QLCNIC_MAC_OVERRIDE_DISABLED;
755
756 if (!esw_cfg->promisc_mode)
757 adapter->flags |= QLCNIC_PROMISC_DISABLED;
758
759 qlcnic_set_netdev_features(adapter, esw_cfg);
760}
761
762static int
763qlcnic_set_eswitch_port_config(struct qlcnic_adapter *adapter)
764{
765 struct qlcnic_esw_func_cfg esw_cfg;
766
767 if (!(adapter->flags & QLCNIC_ESWITCH_ENABLED))
768 return 0;
769
770 esw_cfg.pci_func = adapter->ahw->pci_func;
771 if (qlcnic_get_eswitch_port_config(adapter, &esw_cfg))
772 return -EIO;
773 qlcnic_set_vlan_config(adapter, &esw_cfg);
774 qlcnic_set_eswitch_port_features(adapter, &esw_cfg);
775
776 return 0;
777}
778
779static void
780qlcnic_set_netdev_features(struct qlcnic_adapter *adapter,
781 struct qlcnic_esw_func_cfg *esw_cfg)
782{
783 struct net_device *netdev = adapter->netdev;
784 unsigned long features, vlan_features;
785
786 features = (NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_RXCSUM |
787 NETIF_F_IPV6_CSUM | NETIF_F_GRO);
788 vlan_features = (NETIF_F_SG | NETIF_F_IP_CSUM |
789 NETIF_F_IPV6_CSUM | NETIF_F_HW_VLAN_FILTER);
790
791 if (adapter->capabilities & QLCNIC_FW_CAPABILITY_TSO) {
792 features |= (NETIF_F_TSO | NETIF_F_TSO6);
793 vlan_features |= (NETIF_F_TSO | NETIF_F_TSO6);
794 }
795
796 if (netdev->features & NETIF_F_LRO)
797 features |= NETIF_F_LRO;
798
799 if (esw_cfg->offload_flags & BIT_0) {
800 netdev->features |= features;
801 if (!(esw_cfg->offload_flags & BIT_1))
802 netdev->features &= ~NETIF_F_TSO;
803 if (!(esw_cfg->offload_flags & BIT_2))
804 netdev->features &= ~NETIF_F_TSO6;
805 } else {
806 netdev->features &= ~features;
807 }
808
809 netdev->vlan_features = (features & vlan_features);
810}
811
812static int
813qlcnic_check_eswitch_mode(struct qlcnic_adapter *adapter)
814{
815 void __iomem *priv_op;
816 u32 op_mode, priv_level;
817 int err = 0;
818
819 err = qlcnic_initialize_nic(adapter);
820 if (err)
821 return err;
822
823 if (adapter->flags & QLCNIC_ADAPTER_INITIALIZED)
824 return 0;
825
826 priv_op = adapter->ahw->pci_base0 + QLCNIC_DRV_OP_MODE;
827 op_mode = readl(priv_op);
828 priv_level = QLC_DEV_GET_DRV(op_mode, adapter->ahw->pci_func);
829
830 if (op_mode == QLC_DEV_DRV_DEFAULT)
831 priv_level = QLCNIC_MGMT_FUNC;
832 else
833 priv_level = QLC_DEV_GET_DRV(op_mode, adapter->ahw->pci_func);
834
835 if (adapter->flags & QLCNIC_ESWITCH_ENABLED) {
836 if (priv_level == QLCNIC_MGMT_FUNC) {
837 adapter->op_mode = QLCNIC_MGMT_FUNC;
838 err = qlcnic_init_pci_info(adapter);
839 if (err)
840 return err;
841 /* Set privilege level for other functions */
842 qlcnic_set_function_modes(adapter);
843 dev_info(&adapter->pdev->dev,
844 "HAL Version: %d, Management function\n",
845 adapter->fw_hal_version);
846 } else if (priv_level == QLCNIC_PRIV_FUNC) {
847 adapter->op_mode = QLCNIC_PRIV_FUNC;
848 dev_info(&adapter->pdev->dev,
849 "HAL Version: %d, Privileged function\n",
850 adapter->fw_hal_version);
851 }
852 }
853
854 adapter->flags |= QLCNIC_ADAPTER_INITIALIZED;
855
856 return err;
857}
858
859static int
860qlcnic_set_default_offload_settings(struct qlcnic_adapter *adapter)
861{
862 struct qlcnic_esw_func_cfg esw_cfg;
863 struct qlcnic_npar_info *npar;
864 u8 i;
865
866 if (adapter->need_fw_reset)
867 return 0;
868
869 for (i = 0; i < QLCNIC_MAX_PCI_FUNC; i++) {
870 if (adapter->npars[i].type != QLCNIC_TYPE_NIC)
871 continue;
872 memset(&esw_cfg, 0, sizeof(struct qlcnic_esw_func_cfg));
873 esw_cfg.pci_func = i;
874 esw_cfg.offload_flags = BIT_0;
875 esw_cfg.mac_override = BIT_0;
876 esw_cfg.promisc_mode = BIT_0;
877 if (adapter->capabilities & QLCNIC_FW_CAPABILITY_TSO)
878 esw_cfg.offload_flags |= (BIT_1 | BIT_2);
879 if (qlcnic_config_switch_port(adapter, &esw_cfg))
880 return -EIO;
881 npar = &adapter->npars[i];
882 npar->pvid = esw_cfg.vlan_id;
883 npar->mac_override = esw_cfg.mac_override;
884 npar->mac_anti_spoof = esw_cfg.mac_anti_spoof;
885 npar->discard_tagged = esw_cfg.discard_tagged;
886 npar->promisc_mode = esw_cfg.promisc_mode;
887 npar->offload_flags = esw_cfg.offload_flags;
888 }
889
890 return 0;
891}
892
893static int
894qlcnic_reset_eswitch_config(struct qlcnic_adapter *adapter,
895 struct qlcnic_npar_info *npar, int pci_func)
896{
897 struct qlcnic_esw_func_cfg esw_cfg;
898 esw_cfg.op_mode = QLCNIC_PORT_DEFAULTS;
899 esw_cfg.pci_func = pci_func;
900 esw_cfg.vlan_id = npar->pvid;
901 esw_cfg.mac_override = npar->mac_override;
902 esw_cfg.discard_tagged = npar->discard_tagged;
903 esw_cfg.mac_anti_spoof = npar->mac_anti_spoof;
904 esw_cfg.offload_flags = npar->offload_flags;
905 esw_cfg.promisc_mode = npar->promisc_mode;
906 if (qlcnic_config_switch_port(adapter, &esw_cfg))
907 return -EIO;
908
909 esw_cfg.op_mode = QLCNIC_ADD_VLAN;
910 if (qlcnic_config_switch_port(adapter, &esw_cfg))
911 return -EIO;
912
913 return 0;
777} 914}
778 915
779static int 916static int
780qlcnic_reset_npar_config(struct qlcnic_adapter *adapter) 917qlcnic_reset_npar_config(struct qlcnic_adapter *adapter)
781{ 918{
782 int i, err = 0; 919 int i, err;
783 struct qlcnic_npar_info *npar; 920 struct qlcnic_npar_info *npar;
784 struct qlcnic_info nic_info; 921 struct qlcnic_info nic_info;
785 922
786 if (!(adapter->flags & QLCNIC_ESWITCH_ENABLED) || 923 if (!adapter->need_fw_reset)
787 !adapter->need_fw_reset)
788 return 0; 924 return 0;
789 925
790 if (adapter->op_mode == QLCNIC_MGMT_FUNC) { 926 /* Set the NPAR config data after FW reset */
791 /* Set the NPAR config data after FW reset */ 927 for (i = 0; i < QLCNIC_MAX_PCI_FUNC; i++) {
792 for (i = 0; i < QLCNIC_MAX_PCI_FUNC; i++) { 928 npar = &adapter->npars[i];
793 npar = &adapter->npars[i]; 929 if (npar->type != QLCNIC_TYPE_NIC)
794 if (npar->type != QLCNIC_TYPE_NIC) 930 continue;
795 continue; 931 err = qlcnic_get_nic_info(adapter, &nic_info, i);
796 err = qlcnic_get_nic_info(adapter, &nic_info, i); 932 if (err)
797 if (err) 933 return err;
798 goto err_out; 934 nic_info.min_tx_bw = npar->min_bw;
799 nic_info.min_tx_bw = npar->min_bw; 935 nic_info.max_tx_bw = npar->max_bw;
800 nic_info.max_tx_bw = npar->max_bw; 936 err = qlcnic_set_nic_info(adapter, &nic_info);
801 err = qlcnic_set_nic_info(adapter, &nic_info); 937 if (err)
938 return err;
939
940 if (npar->enable_pm) {
941 err = qlcnic_config_port_mirroring(adapter,
942 npar->dest_npar, 1, i);
802 if (err) 943 if (err)
803 goto err_out; 944 return err;
945 }
946 err = qlcnic_reset_eswitch_config(adapter, npar, i);
947 if (err)
948 return err;
949 }
950 return 0;
951}
804 952
805 if (npar->enable_pm) { 953static int qlcnic_check_npar_opertional(struct qlcnic_adapter *adapter)
806 err = qlcnic_config_port_mirroring(adapter, 954{
807 npar->dest_npar, 1, i); 955 u8 npar_opt_timeo = QLCNIC_DEV_NPAR_OPER_TIMEO;
808 if (err) 956 u32 npar_state;
809 goto err_out;
810 957
811 } 958 if (adapter->op_mode == QLCNIC_MGMT_FUNC)
812 npar->mac_learning = DEFAULT_MAC_LEARN; 959 return 0;
813 npar->host_vlan_tag = 0; 960
814 npar->promisc_mode = 0; 961 npar_state = QLCRD32(adapter, QLCNIC_CRB_DEV_NPAR_STATE);
815 npar->discard_tagged = 0; 962 while (npar_state != QLCNIC_DEV_NPAR_OPER && --npar_opt_timeo) {
816 npar->vlan_id = 0; 963 msleep(1000);
817 } 964 npar_state = QLCRD32(adapter, QLCNIC_CRB_DEV_NPAR_STATE);
818 } 965 }
819err_out: 966 if (!npar_opt_timeo) {
967 dev_err(&adapter->pdev->dev,
968 "Waiting for NPAR state to opertional timeout\n");
969 return -EIO;
970 }
971 return 0;
972}
973
974static int
975qlcnic_set_mgmt_operations(struct qlcnic_adapter *adapter)
976{
977 int err;
978
979 if (!(adapter->flags & QLCNIC_ESWITCH_ENABLED) ||
980 adapter->op_mode != QLCNIC_MGMT_FUNC)
981 return 0;
982
983 err = qlcnic_set_default_offload_settings(adapter);
984 if (err)
985 return err;
986
987 err = qlcnic_reset_npar_config(adapter);
988 if (err)
989 return err;
990
991 qlcnic_dev_set_npar_ready(adapter);
992
820 return err; 993 return err;
821} 994}
822 995
823static int 996static int
824qlcnic_start_firmware(struct qlcnic_adapter *adapter) 997qlcnic_start_firmware(struct qlcnic_adapter *adapter)
825{ 998{
826 int val, err, first_boot; 999 int err;
827 1000
828 err = qlcnic_can_start_firmware(adapter); 1001 err = qlcnic_can_start_firmware(adapter);
829 if (err < 0) 1002 if (err < 0)
830 return err; 1003 return err;
831 else if (!err) 1004 else if (!err)
832 goto wait_init; 1005 goto check_fw_status;
833
834 first_boot = QLCRD32(adapter, QLCNIC_CAM_RAM(0x1fc));
835 if (first_boot == 0x55555555)
836 /* This is the first boot after power up */
837 QLCWR32(adapter, QLCNIC_CAM_RAM(0x1fc), QLCNIC_BDINFO_MAGIC);
838 1006
839 if (load_fw_file) 1007 if (load_fw_file)
840 qlcnic_request_firmware(adapter); 1008 qlcnic_request_firmware(adapter);
841 else { 1009 else {
842 if (qlcnic_check_flash_fw_ver(adapter)) 1010 err = qlcnic_check_flash_fw_ver(adapter);
1011 if (err)
843 goto err_out; 1012 goto err_out;
844 1013
845 adapter->fw_type = QLCNIC_FLASH_ROMIMAGE; 1014 adapter->fw_type = QLCNIC_FLASH_ROMIMAGE;
846 } 1015 }
847 1016
848 err = qlcnic_need_fw_reset(adapter); 1017 err = qlcnic_need_fw_reset(adapter);
849 if (err < 0)
850 goto err_out;
851 if (err == 0) 1018 if (err == 0)
852 goto wait_init; 1019 goto check_fw_status;
853
854 if (first_boot != 0x55555555) {
855 QLCWR32(adapter, CRB_CMDPEG_STATE, 0);
856 QLCWR32(adapter, CRB_RCVPEG_STATE, 0);
857 qlcnic_pinit_from_rom(adapter);
858 msleep(1);
859 }
860 1020
861 QLCWR32(adapter, QLCNIC_PEG_HALT_STATUS1, 0); 1021 err = qlcnic_pinit_from_rom(adapter);
862 QLCWR32(adapter, QLCNIC_PEG_HALT_STATUS2, 0); 1022 if (err)
863 1023 goto err_out;
864 qlcnic_set_port_mode(adapter);
865 1024
866 err = qlcnic_load_firmware(adapter); 1025 err = qlcnic_load_firmware(adapter);
867 if (err) 1026 if (err)
868 goto err_out; 1027 goto err_out;
869 1028
870 qlcnic_release_firmware(adapter); 1029 qlcnic_release_firmware(adapter);
1030 QLCWR32(adapter, CRB_DRIVER_VERSION, QLCNIC_DRIVER_VERSION);
871 1031
872 val = (_QLCNIC_LINUX_MAJOR << 16) 1032check_fw_status:
873 | ((_QLCNIC_LINUX_MINOR << 8)) 1033 err = qlcnic_check_fw_status(adapter);
874 | (_QLCNIC_LINUX_SUBVERSION);
875 QLCWR32(adapter, CRB_DRIVER_VERSION, val);
876
877wait_init:
878 /* Handshake with the card before we register the devices. */
879 err = qlcnic_init_firmware(adapter);
880 if (err) 1034 if (err)
881 goto err_out; 1035 goto err_out;
882 1036
883 QLCWR32(adapter, QLCNIC_CRB_DEV_STATE, QLCNIC_DEV_READY); 1037 QLCWR32(adapter, QLCNIC_CRB_DEV_STATE, QLCNIC_DEV_READY);
884 qlcnic_idc_debug_info(adapter, 1); 1038 qlcnic_idc_debug_info(adapter, 1);
885 1039
886 qlcnic_check_options(adapter); 1040 err = qlcnic_check_eswitch_mode(adapter);
887 if (qlcnic_reset_npar_config(adapter)) 1041 if (err) {
1042 dev_err(&adapter->pdev->dev,
1043 "Memory allocation failed for eswitch\n");
1044 goto err_out;
1045 }
1046 err = qlcnic_set_mgmt_operations(adapter);
1047 if (err)
888 goto err_out; 1048 goto err_out;
889 qlcnic_dev_set_npar_ready(adapter);
890 1049
1050 qlcnic_check_options(adapter);
891 adapter->need_fw_reset = 0; 1051 adapter->need_fw_reset = 0;
892 1052
893 qlcnic_release_firmware(adapter); 1053 qlcnic_release_firmware(adapter);
@@ -896,6 +1056,7 @@ wait_init:
896err_out: 1056err_out:
897 QLCWR32(adapter, QLCNIC_CRB_DEV_STATE, QLCNIC_DEV_FAILED); 1057 QLCWR32(adapter, QLCNIC_CRB_DEV_STATE, QLCNIC_DEV_FAILED);
898 dev_err(&adapter->pdev->dev, "Device state set to failed\n"); 1058 dev_err(&adapter->pdev->dev, "Device state set to failed\n");
1059
899 qlcnic_release_firmware(adapter); 1060 qlcnic_release_firmware(adapter);
900 return err; 1061 return err;
901} 1062}
@@ -909,7 +1070,7 @@ qlcnic_request_irq(struct qlcnic_adapter *adapter)
909 1070
910 unsigned long flags = 0; 1071 unsigned long flags = 0;
911 struct net_device *netdev = adapter->netdev; 1072 struct net_device *netdev = adapter->netdev;
912 struct qlcnic_recv_context *recv_ctx = &adapter->recv_ctx; 1073 struct qlcnic_recv_context *recv_ctx = adapter->recv_ctx;
913 1074
914 if (adapter->diag_test == QLCNIC_INTERRUPT_TEST) { 1075 if (adapter->diag_test == QLCNIC_INTERRUPT_TEST) {
915 handler = qlcnic_tmp_intr; 1076 handler = qlcnic_tmp_intr;
@@ -946,7 +1107,7 @@ qlcnic_free_irq(struct qlcnic_adapter *adapter)
946 int ring; 1107 int ring;
947 struct qlcnic_host_sds_ring *sds_ring; 1108 struct qlcnic_host_sds_ring *sds_ring;
948 1109
949 struct qlcnic_recv_context *recv_ctx = &adapter->recv_ctx; 1110 struct qlcnic_recv_context *recv_ctx = adapter->recv_ctx;
950 1111
951 for (ring = 0; ring < adapter->max_sds_rings; ring++) { 1112 for (ring = 0; ring < adapter->max_sds_rings; ring++) {
952 sds_ring = &recv_ctx->sds_rings[ring]; 1113 sds_ring = &recv_ctx->sds_rings[ring];
@@ -954,20 +1115,6 @@ qlcnic_free_irq(struct qlcnic_adapter *adapter)
954 } 1115 }
955} 1116}
956 1117
957static void
958qlcnic_init_coalesce_defaults(struct qlcnic_adapter *adapter)
959{
960 adapter->coal.flags = QLCNIC_INTR_DEFAULT;
961 adapter->coal.normal.data.rx_time_us =
962 QLCNIC_DEFAULT_INTR_COALESCE_RX_TIME_US;
963 adapter->coal.normal.data.rx_packets =
964 QLCNIC_DEFAULT_INTR_COALESCE_RX_PACKETS;
965 adapter->coal.normal.data.tx_time_us =
966 QLCNIC_DEFAULT_INTR_COALESCE_TX_TIME_US;
967 adapter->coal.normal.data.tx_packets =
968 QLCNIC_DEFAULT_INTR_COALESCE_TX_PACKETS;
969}
970
971static int 1118static int
972__qlcnic_up(struct qlcnic_adapter *adapter, struct net_device *netdev) 1119__qlcnic_up(struct qlcnic_adapter *adapter, struct net_device *netdev)
973{ 1120{
@@ -979,26 +1126,28 @@ __qlcnic_up(struct qlcnic_adapter *adapter, struct net_device *netdev)
979 1126
980 if (test_bit(__QLCNIC_DEV_UP, &adapter->state)) 1127 if (test_bit(__QLCNIC_DEV_UP, &adapter->state))
981 return 0; 1128 return 0;
1129 if (qlcnic_set_eswitch_port_config(adapter))
1130 return -EIO;
982 1131
983 if (qlcnic_fw_create_ctx(adapter)) 1132 if (qlcnic_fw_create_ctx(adapter))
984 return -EIO; 1133 return -EIO;
985 1134
986 for (ring = 0; ring < adapter->max_rds_rings; ring++) { 1135 for (ring = 0; ring < adapter->max_rds_rings; ring++) {
987 rds_ring = &adapter->recv_ctx.rds_rings[ring]; 1136 rds_ring = &adapter->recv_ctx->rds_rings[ring];
988 qlcnic_post_rx_buffers(adapter, ring, rds_ring); 1137 qlcnic_post_rx_buffers(adapter, rds_ring);
989 } 1138 }
990 1139
991 qlcnic_set_multi(netdev); 1140 qlcnic_set_multi(netdev);
992 qlcnic_fw_cmd_set_mtu(adapter, netdev->mtu); 1141 qlcnic_fw_cmd_set_mtu(adapter, netdev->mtu);
993 1142
994 adapter->ahw.linkup = 0; 1143 adapter->ahw->linkup = 0;
995 1144
996 if (adapter->max_sds_rings > 1) 1145 if (adapter->max_sds_rings > 1)
997 qlcnic_config_rss(adapter, 1); 1146 qlcnic_config_rss(adapter, 1);
998 1147
999 qlcnic_config_intr_coalesce(adapter); 1148 qlcnic_config_intr_coalesce(adapter);
1000 1149
1001 if (adapter->capabilities & QLCNIC_FW_CAPABILITY_HW_LRO) 1150 if (netdev->features & NETIF_F_LRO)
1002 qlcnic_config_hw_lro(adapter, QLCNIC_LRO_ENABLED); 1151 qlcnic_config_hw_lro(adapter, QLCNIC_LRO_ENABLED);
1003 1152
1004 qlcnic_napi_enable(adapter); 1153 qlcnic_napi_enable(adapter);
@@ -1041,6 +1190,9 @@ __qlcnic_down(struct qlcnic_adapter *adapter, struct net_device *netdev)
1041 1190
1042 qlcnic_free_mac_list(adapter); 1191 qlcnic_free_mac_list(adapter);
1043 1192
1193 if (adapter->fhash.fnum)
1194 qlcnic_delete_lb_filters(adapter);
1195
1044 qlcnic_nic_set_promisc(adapter, QLCNIC_NIU_NON_PROMISC_MODE); 1196 qlcnic_nic_set_promisc(adapter, QLCNIC_NIU_NON_PROMISC_MODE);
1045 1197
1046 qlcnic_napi_disable(adapter); 1198 qlcnic_napi_disable(adapter);
@@ -1096,8 +1248,6 @@ qlcnic_attach(struct qlcnic_adapter *adapter)
1096 goto err_out_free_hw; 1248 goto err_out_free_hw;
1097 } 1249 }
1098 1250
1099 qlcnic_init_coalesce_defaults(adapter);
1100
1101 qlcnic_create_sysfs_entries(adapter); 1251 qlcnic_create_sysfs_entries(adapter);
1102 1252
1103 adapter->is_up = QLCNIC_ADAPTER_UP_MAGIC; 1253 adapter->is_up = QLCNIC_ADAPTER_UP_MAGIC;
@@ -1138,7 +1288,7 @@ void qlcnic_diag_free_res(struct net_device *netdev, int max_sds_rings)
1138 clear_bit(__QLCNIC_DEV_UP, &adapter->state); 1288 clear_bit(__QLCNIC_DEV_UP, &adapter->state);
1139 if (adapter->diag_test == QLCNIC_INTERRUPT_TEST) { 1289 if (adapter->diag_test == QLCNIC_INTERRUPT_TEST) {
1140 for (ring = 0; ring < adapter->max_sds_rings; ring++) { 1290 for (ring = 0; ring < adapter->max_sds_rings; ring++) {
1141 sds_ring = &adapter->recv_ctx.sds_rings[ring]; 1291 sds_ring = &adapter->recv_ctx->sds_rings[ring];
1142 qlcnic_disable_int(sds_ring); 1292 qlcnic_disable_int(sds_ring);
1143 } 1293 }
1144 } 1294 }
@@ -1159,6 +1309,48 @@ out:
1159 netif_device_attach(netdev); 1309 netif_device_attach(netdev);
1160} 1310}
1161 1311
1312static int qlcnic_alloc_adapter_resources(struct qlcnic_adapter *adapter)
1313{
1314 int err = 0;
1315 adapter->ahw = kzalloc(sizeof(struct qlcnic_hardware_context),
1316 GFP_KERNEL);
1317 if (!adapter->ahw) {
1318 dev_err(&adapter->pdev->dev,
1319 "Failed to allocate recv ctx resources for adapter\n");
1320 err = -ENOMEM;
1321 goto err_out;
1322 }
1323 adapter->recv_ctx = kzalloc(sizeof(struct qlcnic_recv_context),
1324 GFP_KERNEL);
1325 if (!adapter->recv_ctx) {
1326 dev_err(&adapter->pdev->dev,
1327 "Failed to allocate recv ctx resources for adapter\n");
1328 kfree(adapter->ahw);
1329 adapter->ahw = NULL;
1330 err = -ENOMEM;
1331 goto err_out;
1332 }
1333 /* Initialize interrupt coalesce parameters */
1334 adapter->ahw->coal.flag = QLCNIC_INTR_DEFAULT;
1335 adapter->ahw->coal.rx_time_us = QLCNIC_DEFAULT_INTR_COALESCE_RX_TIME_US;
1336 adapter->ahw->coal.rx_packets = QLCNIC_DEFAULT_INTR_COALESCE_RX_PACKETS;
1337err_out:
1338 return err;
1339}
1340
1341static void qlcnic_free_adapter_resources(struct qlcnic_adapter *adapter)
1342{
1343 kfree(adapter->recv_ctx);
1344 adapter->recv_ctx = NULL;
1345
1346 if (adapter->ahw->fw_dump.tmpl_hdr) {
1347 vfree(adapter->ahw->fw_dump.tmpl_hdr);
1348 adapter->ahw->fw_dump.tmpl_hdr = NULL;
1349 }
1350 kfree(adapter->ahw);
1351 adapter->ahw = NULL;
1352}
1353
1162int qlcnic_diag_alloc_res(struct net_device *netdev, int test) 1354int qlcnic_diag_alloc_res(struct net_device *netdev, int test)
1163{ 1355{
1164 struct qlcnic_adapter *adapter = netdev_priv(netdev); 1356 struct qlcnic_adapter *adapter = netdev_priv(netdev);
@@ -1191,13 +1383,13 @@ int qlcnic_diag_alloc_res(struct net_device *netdev, int test)
1191 } 1383 }
1192 1384
1193 for (ring = 0; ring < adapter->max_rds_rings; ring++) { 1385 for (ring = 0; ring < adapter->max_rds_rings; ring++) {
1194 rds_ring = &adapter->recv_ctx.rds_rings[ring]; 1386 rds_ring = &adapter->recv_ctx->rds_rings[ring];
1195 qlcnic_post_rx_buffers(adapter, ring, rds_ring); 1387 qlcnic_post_rx_buffers(adapter, rds_ring);
1196 } 1388 }
1197 1389
1198 if (adapter->diag_test == QLCNIC_INTERRUPT_TEST) { 1390 if (adapter->diag_test == QLCNIC_INTERRUPT_TEST) {
1199 for (ring = 0; ring < adapter->max_sds_rings; ring++) { 1391 for (ring = 0; ring < adapter->max_sds_rings; ring++) {
1200 sds_ring = &adapter->recv_ctx.sds_rings[ring]; 1392 sds_ring = &adapter->recv_ctx->sds_rings[ring];
1201 qlcnic_enable_int(sds_ring); 1393 qlcnic_enable_int(sds_ring);
1202 } 1394 }
1203 } 1395 }
@@ -1265,7 +1457,6 @@ qlcnic_setup_netdev(struct qlcnic_adapter *adapter,
1265 int err; 1457 int err;
1266 struct pci_dev *pdev = adapter->pdev; 1458 struct pci_dev *pdev = adapter->pdev;
1267 1459
1268 adapter->rx_csum = 1;
1269 adapter->mc_enabled = 0; 1460 adapter->mc_enabled = 0;
1270 adapter->max_mc_count = 38; 1461 adapter->max_mc_count = 38;
1271 1462
@@ -1276,34 +1467,27 @@ qlcnic_setup_netdev(struct qlcnic_adapter *adapter,
1276 1467
1277 SET_ETHTOOL_OPS(netdev, &qlcnic_ethtool_ops); 1468 SET_ETHTOOL_OPS(netdev, &qlcnic_ethtool_ops);
1278 1469
1279 netdev->features |= (NETIF_F_SG | NETIF_F_IP_CSUM | 1470 netdev->hw_features = NETIF_F_SG | NETIF_F_IP_CSUM |
1280 NETIF_F_IPV6_CSUM | NETIF_F_GRO); 1471 NETIF_F_IPV6_CSUM | NETIF_F_RXCSUM;
1281 netdev->vlan_features |= (NETIF_F_SG | NETIF_F_IP_CSUM |
1282 NETIF_F_IPV6_CSUM);
1283 1472
1284 if (adapter->capabilities & QLCNIC_FW_CAPABILITY_TSO) { 1473 if (adapter->capabilities & QLCNIC_FW_CAPABILITY_TSO)
1285 netdev->features |= (NETIF_F_TSO | NETIF_F_TSO6); 1474 netdev->hw_features |= NETIF_F_TSO | NETIF_F_TSO6;
1286 netdev->vlan_features |= (NETIF_F_TSO | NETIF_F_TSO6); 1475 if (pci_using_dac)
1287 } 1476 netdev->hw_features |= NETIF_F_HIGHDMA;
1288 1477
1289 if (pci_using_dac) { 1478 netdev->vlan_features = netdev->hw_features;
1290 netdev->features |= NETIF_F_HIGHDMA;
1291 netdev->vlan_features |= NETIF_F_HIGHDMA;
1292 }
1293 1479
1294 if (adapter->capabilities & QLCNIC_FW_CAPABILITY_FVLANTX) 1480 if (adapter->capabilities & QLCNIC_FW_CAPABILITY_FVLANTX)
1295 netdev->features |= (NETIF_F_HW_VLAN_TX); 1481 netdev->hw_features |= NETIF_F_HW_VLAN_TX;
1296
1297 if (adapter->capabilities & QLCNIC_FW_CAPABILITY_HW_LRO) 1482 if (adapter->capabilities & QLCNIC_FW_CAPABILITY_HW_LRO)
1298 netdev->features |= NETIF_F_LRO; 1483 netdev->hw_features |= NETIF_F_LRO;
1299 1484
1300 netdev->irq = adapter->msix_entries[0].vector; 1485 netdev->features |= netdev->hw_features |
1486 NETIF_F_HW_VLAN_RX | NETIF_F_HW_VLAN_FILTER;
1301 1487
1302 if (qlcnic_read_mac_addr(adapter)) 1488 netdev->irq = adapter->msix_entries[0].vector;
1303 dev_warn(&pdev->dev, "failed to read mac addr\n");
1304 1489
1305 netif_carrier_off(netdev); 1490 netif_carrier_off(netdev);
1306 netif_stop_queue(netdev);
1307 1491
1308 err = register_netdev(netdev); 1492 err = register_netdev(netdev);
1309 if (err) { 1493 if (err) {
@@ -1330,6 +1514,19 @@ static int qlcnic_set_dma_mask(struct pci_dev *pdev, u8 *pci_using_dac)
1330 return 0; 1514 return 0;
1331} 1515}
1332 1516
1517static int
1518qlcnic_alloc_msix_entries(struct qlcnic_adapter *adapter, u16 count)
1519{
1520 adapter->msix_entries = kcalloc(count, sizeof(struct msix_entry),
1521 GFP_KERNEL);
1522
1523 if (adapter->msix_entries)
1524 return 0;
1525
1526 dev_err(&adapter->pdev->dev, "failed allocating msix_entries\n");
1527 return -ENOMEM;
1528}
1529
1333static int __devinit 1530static int __devinit
1334qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) 1531qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1335{ 1532{
@@ -1338,6 +1535,7 @@ qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1338 int err; 1535 int err;
1339 uint8_t revision_id; 1536 uint8_t revision_id;
1340 uint8_t pci_using_dac; 1537 uint8_t pci_using_dac;
1538 char brd_name[QLCNIC_MAX_BOARD_NAME_LEN];
1341 1539
1342 err = pci_enable_device(pdev); 1540 err = pci_enable_device(pdev);
1343 if (err) 1541 if (err)
@@ -1371,23 +1569,30 @@ qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1371 adapter = netdev_priv(netdev); 1569 adapter = netdev_priv(netdev);
1372 adapter->netdev = netdev; 1570 adapter->netdev = netdev;
1373 adapter->pdev = pdev; 1571 adapter->pdev = pdev;
1374 adapter->dev_rst_time = jiffies;
1375 1572
1573 if (qlcnic_alloc_adapter_resources(adapter))
1574 goto err_out_free_netdev;
1575
1576 adapter->dev_rst_time = jiffies;
1376 revision_id = pdev->revision; 1577 revision_id = pdev->revision;
1377 adapter->ahw.revision_id = revision_id; 1578 adapter->ahw->revision_id = revision_id;
1378 1579
1379 rwlock_init(&adapter->ahw.crb_lock); 1580 rwlock_init(&adapter->ahw->crb_lock);
1380 mutex_init(&adapter->ahw.mem_lock); 1581 mutex_init(&adapter->ahw->mem_lock);
1381 1582
1382 spin_lock_init(&adapter->tx_clean_lock); 1583 spin_lock_init(&adapter->tx_clean_lock);
1383 INIT_LIST_HEAD(&adapter->mac_list); 1584 INIT_LIST_HEAD(&adapter->mac_list);
1384 1585
1385 err = qlcnic_setup_pci_map(adapter); 1586 err = qlcnic_setup_pci_map(adapter);
1386 if (err) 1587 if (err)
1387 goto err_out_free_netdev; 1588 goto err_out_free_hw;
1388 1589
1389 /* This will be reset for mezz cards */ 1590 /* This will be reset for mezz cards */
1390 adapter->portnum = adapter->ahw.pci_func; 1591 adapter->portnum = adapter->ahw->pci_func;
1592
1593 /* Get FW dump template and store it */
1594 if (adapter->op_mode != QLCNIC_NON_PRIV_FUNC)
1595 qlcnic_fw_cmd_get_minidump_temp(adapter);
1391 1596
1392 err = qlcnic_get_board_info(adapter); 1597 err = qlcnic_get_board_info(adapter);
1393 if (err) { 1598 if (err) {
@@ -1395,20 +1600,35 @@ qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1395 goto err_out_iounmap; 1600 goto err_out_iounmap;
1396 } 1601 }
1397 1602
1398 if (qlcnic_read_mac_addr(adapter)) 1603 err = qlcnic_setup_idc_param(adapter);
1399 dev_warn(&pdev->dev, "failed to read mac addr\n"); 1604 if (err)
1400
1401 if (qlcnic_setup_idc_param(adapter))
1402 goto err_out_iounmap; 1605 goto err_out_iounmap;
1403 1606
1607 adapter->flags |= QLCNIC_NEED_FLR;
1608
1404 err = adapter->nic_ops->start_firmware(adapter); 1609 err = adapter->nic_ops->start_firmware(adapter);
1405 if (err) { 1610 if (err) {
1406 dev_err(&pdev->dev, "Loading fw failed.Please Reboot\n"); 1611 dev_err(&pdev->dev, "Loading fw failed.Please Reboot\n");
1407 goto err_out_decr_ref; 1612 goto err_out_decr_ref;
1408 } 1613 }
1409 1614
1615 if (qlcnic_read_mac_addr(adapter))
1616 dev_warn(&pdev->dev, "failed to read mac addr\n");
1617
1618 if (adapter->portnum == 0) {
1619 get_brd_name(adapter, brd_name);
1620
1621 pr_info("%s: %s Board Chip rev 0x%x\n",
1622 module_name(THIS_MODULE),
1623 brd_name, adapter->ahw->revision_id);
1624 }
1625
1410 qlcnic_clear_stats(adapter); 1626 qlcnic_clear_stats(adapter);
1411 1627
1628 err = qlcnic_alloc_msix_entries(adapter, adapter->max_rx_ques);
1629 if (err)
1630 goto err_out_decr_ref;
1631
1412 qlcnic_setup_intr(adapter); 1632 qlcnic_setup_intr(adapter);
1413 1633
1414 err = qlcnic_setup_netdev(adapter, netdev, pci_using_dac); 1634 err = qlcnic_setup_netdev(adapter, netdev, pci_using_dac);
@@ -1419,7 +1639,7 @@ qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1419 1639
1420 qlcnic_schedule_work(adapter, qlcnic_fw_poll_work, FW_POLL_DELAY); 1640 qlcnic_schedule_work(adapter, qlcnic_fw_poll_work, FW_POLL_DELAY);
1421 1641
1422 switch (adapter->ahw.port_type) { 1642 switch (adapter->ahw->port_type) {
1423 case QLCNIC_GBE: 1643 case QLCNIC_GBE:
1424 dev_info(&adapter->pdev->dev, "%s: GbE port initialized\n", 1644 dev_info(&adapter->pdev->dev, "%s: GbE port initialized\n",
1425 adapter->netdev->name); 1645 adapter->netdev->name);
@@ -1430,19 +1650,24 @@ qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1430 break; 1650 break;
1431 } 1651 }
1432 1652
1653 qlcnic_alloc_lb_filters_mem(adapter);
1433 qlcnic_create_diag_entries(adapter); 1654 qlcnic_create_diag_entries(adapter);
1434 1655
1435 return 0; 1656 return 0;
1436 1657
1437err_out_disable_msi: 1658err_out_disable_msi:
1438 qlcnic_teardown_intr(adapter); 1659 qlcnic_teardown_intr(adapter);
1660 kfree(adapter->msix_entries);
1439 1661
1440err_out_decr_ref: 1662err_out_decr_ref:
1441 qlcnic_clr_all_drv_state(adapter); 1663 qlcnic_clr_all_drv_state(adapter, 0);
1442 1664
1443err_out_iounmap: 1665err_out_iounmap:
1444 qlcnic_cleanup_pci_map(adapter); 1666 qlcnic_cleanup_pci_map(adapter);
1445 1667
1668err_out_free_hw:
1669 qlcnic_free_adapter_resources(adapter);
1670
1446err_out_free_netdev: 1671err_out_free_netdev:
1447 free_netdev(netdev); 1672 free_netdev(netdev);
1448 1673
@@ -1477,11 +1702,14 @@ static void __devexit qlcnic_remove(struct pci_dev *pdev)
1477 if (adapter->eswitch != NULL) 1702 if (adapter->eswitch != NULL)
1478 kfree(adapter->eswitch); 1703 kfree(adapter->eswitch);
1479 1704
1480 qlcnic_clr_all_drv_state(adapter); 1705 qlcnic_clr_all_drv_state(adapter, 0);
1481 1706
1482 clear_bit(__QLCNIC_RESETTING, &adapter->state); 1707 clear_bit(__QLCNIC_RESETTING, &adapter->state);
1483 1708
1709 qlcnic_free_lb_filters_mem(adapter);
1710
1484 qlcnic_teardown_intr(adapter); 1711 qlcnic_teardown_intr(adapter);
1712 kfree(adapter->msix_entries);
1485 1713
1486 qlcnic_remove_diag_entries(adapter); 1714 qlcnic_remove_diag_entries(adapter);
1487 1715
@@ -1494,6 +1722,7 @@ static void __devexit qlcnic_remove(struct pci_dev *pdev)
1494 pci_disable_device(pdev); 1722 pci_disable_device(pdev);
1495 pci_set_drvdata(pdev, NULL); 1723 pci_set_drvdata(pdev, NULL);
1496 1724
1725 qlcnic_free_adapter_resources(adapter);
1497 free_netdev(netdev); 1726 free_netdev(netdev);
1498} 1727}
1499static int __qlcnic_shutdown(struct pci_dev *pdev) 1728static int __qlcnic_shutdown(struct pci_dev *pdev)
@@ -1509,7 +1738,7 @@ static int __qlcnic_shutdown(struct pci_dev *pdev)
1509 if (netif_running(netdev)) 1738 if (netif_running(netdev))
1510 qlcnic_down(adapter, netdev); 1739 qlcnic_down(adapter, netdev);
1511 1740
1512 qlcnic_clr_all_drv_state(adapter); 1741 qlcnic_clr_all_drv_state(adapter, 0);
1513 1742
1514 clear_bit(__QLCNIC_RESETTING, &adapter->state); 1743 clear_bit(__QLCNIC_RESETTING, &adapter->state);
1515 1744
@@ -1573,7 +1802,7 @@ qlcnic_resume(struct pci_dev *pdev)
1573 if (err) 1802 if (err)
1574 goto done; 1803 goto done;
1575 1804
1576 qlcnic_config_indev_addr(netdev, NETDEV_UP); 1805 qlcnic_restore_indev_addr(netdev, NETDEV_UP);
1577 } 1806 }
1578done: 1807done:
1579 netif_device_attach(netdev); 1808 netif_device_attach(netdev);
@@ -1587,9 +1816,6 @@ static int qlcnic_open(struct net_device *netdev)
1587 struct qlcnic_adapter *adapter = netdev_priv(netdev); 1816 struct qlcnic_adapter *adapter = netdev_priv(netdev);
1588 int err; 1817 int err;
1589 1818
1590 if (adapter->driver_mismatch)
1591 return -EIO;
1592
1593 err = qlcnic_attach(adapter); 1819 err = qlcnic_attach(adapter);
1594 if (err) 1820 if (err)
1595 return err; 1821 return err;
@@ -1619,69 +1845,242 @@ static int qlcnic_close(struct net_device *netdev)
1619} 1845}
1620 1846
1621static void 1847static void
1622qlcnic_tso_check(struct net_device *netdev, 1848qlcnic_alloc_lb_filters_mem(struct qlcnic_adapter *adapter)
1849{
1850 void *head;
1851 int i;
1852
1853 if (!qlcnic_mac_learn)
1854 return;
1855
1856 spin_lock_init(&adapter->mac_learn_lock);
1857
1858 head = kcalloc(QLCNIC_LB_MAX_FILTERS, sizeof(struct hlist_head),
1859 GFP_KERNEL);
1860 if (!head)
1861 return;
1862
1863 adapter->fhash.fmax = QLCNIC_LB_MAX_FILTERS;
1864 adapter->fhash.fhead = (struct hlist_head *)head;
1865
1866 for (i = 0; i < adapter->fhash.fmax; i++)
1867 INIT_HLIST_HEAD(&adapter->fhash.fhead[i]);
1868}
1869
1870static void qlcnic_free_lb_filters_mem(struct qlcnic_adapter *adapter)
1871{
1872 if (adapter->fhash.fmax && adapter->fhash.fhead)
1873 kfree(adapter->fhash.fhead);
1874
1875 adapter->fhash.fhead = NULL;
1876 adapter->fhash.fmax = 0;
1877}
1878
1879static void qlcnic_change_filter(struct qlcnic_adapter *adapter,
1880 u64 uaddr, __le16 vlan_id, struct qlcnic_host_tx_ring *tx_ring)
1881{
1882 struct cmd_desc_type0 *hwdesc;
1883 struct qlcnic_nic_req *req;
1884 struct qlcnic_mac_req *mac_req;
1885 struct qlcnic_vlan_req *vlan_req;
1886 u32 producer;
1887 u64 word;
1888
1889 producer = tx_ring->producer;
1890 hwdesc = &tx_ring->desc_head[tx_ring->producer];
1891
1892 req = (struct qlcnic_nic_req *)hwdesc;
1893 memset(req, 0, sizeof(struct qlcnic_nic_req));
1894 req->qhdr = cpu_to_le64(QLCNIC_REQUEST << 23);
1895
1896 word = QLCNIC_MAC_EVENT | ((u64)(adapter->portnum) << 16);
1897 req->req_hdr = cpu_to_le64(word);
1898
1899 mac_req = (struct qlcnic_mac_req *)&(req->words[0]);
1900 mac_req->op = vlan_id ? QLCNIC_MAC_VLAN_ADD : QLCNIC_MAC_ADD;
1901 memcpy(mac_req->mac_addr, &uaddr, ETH_ALEN);
1902
1903 vlan_req = (struct qlcnic_vlan_req *)&req->words[1];
1904 vlan_req->vlan_id = vlan_id;
1905
1906 tx_ring->producer = get_next_index(producer, tx_ring->num_desc);
1907 smp_mb();
1908}
1909
1910#define QLCNIC_MAC_HASH(MAC)\
1911 ((((MAC) & 0x70000) >> 0x10) | (((MAC) & 0x70000000000ULL) >> 0x25))
1912
1913static void
1914qlcnic_send_filter(struct qlcnic_adapter *adapter,
1623 struct qlcnic_host_tx_ring *tx_ring, 1915 struct qlcnic_host_tx_ring *tx_ring,
1624 struct cmd_desc_type0 *first_desc, 1916 struct cmd_desc_type0 *first_desc,
1625 struct sk_buff *skb) 1917 struct sk_buff *skb)
1626{ 1918{
1627 u8 opcode = TX_ETHER_PKT; 1919 struct ethhdr *phdr = (struct ethhdr *)(skb->data);
1628 __be16 protocol = skb->protocol; 1920 struct qlcnic_filter *fil, *tmp_fil;
1629 u16 flags = 0, vid = 0; 1921 struct hlist_node *tmp_hnode, *n;
1630 int copied, offset, copy_len, hdr_len = 0, tso = 0, vlan_oob = 0; 1922 struct hlist_head *head;
1923 u64 src_addr = 0;
1924 __le16 vlan_id = 0;
1925 u8 hindex;
1926
1927 if (!compare_ether_addr(phdr->h_source, adapter->mac_addr))
1928 return;
1929
1930 if (adapter->fhash.fnum >= adapter->fhash.fmax)
1931 return;
1932
1933 /* Only NPAR capable devices support vlan based learning*/
1934 if (adapter->flags & QLCNIC_ESWITCH_ENABLED)
1935 vlan_id = first_desc->vlan_TCI;
1936 memcpy(&src_addr, phdr->h_source, ETH_ALEN);
1937 hindex = QLCNIC_MAC_HASH(src_addr) & (QLCNIC_LB_MAX_FILTERS - 1);
1938 head = &(adapter->fhash.fhead[hindex]);
1939
1940 hlist_for_each_entry_safe(tmp_fil, tmp_hnode, n, head, fnode) {
1941 if (!memcmp(tmp_fil->faddr, &src_addr, ETH_ALEN) &&
1942 tmp_fil->vlan_id == vlan_id) {
1943
1944 if (jiffies >
1945 (QLCNIC_READD_AGE * HZ + tmp_fil->ftime))
1946 qlcnic_change_filter(adapter, src_addr, vlan_id,
1947 tx_ring);
1948 tmp_fil->ftime = jiffies;
1949 return;
1950 }
1951 }
1952
1953 fil = kzalloc(sizeof(struct qlcnic_filter), GFP_ATOMIC);
1954 if (!fil)
1955 return;
1956
1957 qlcnic_change_filter(adapter, src_addr, vlan_id, tx_ring);
1958
1959 fil->ftime = jiffies;
1960 fil->vlan_id = vlan_id;
1961 memcpy(fil->faddr, &src_addr, ETH_ALEN);
1962 spin_lock(&adapter->mac_learn_lock);
1963 hlist_add_head(&(fil->fnode), head);
1964 adapter->fhash.fnum++;
1965 spin_unlock(&adapter->mac_learn_lock);
1966}
1967
1968static int
1969qlcnic_tx_pkt(struct qlcnic_adapter *adapter,
1970 struct cmd_desc_type0 *first_desc,
1971 struct sk_buff *skb)
1972{
1973 u8 opcode = 0, hdr_len = 0;
1974 u16 flags = 0, vlan_tci = 0;
1975 int copied, offset, copy_len;
1631 struct cmd_desc_type0 *hwdesc; 1976 struct cmd_desc_type0 *hwdesc;
1632 struct vlan_ethhdr *vh; 1977 struct vlan_ethhdr *vh;
1633 struct qlcnic_adapter *adapter = netdev_priv(netdev); 1978 struct qlcnic_host_tx_ring *tx_ring = adapter->tx_ring;
1979 u16 protocol = ntohs(skb->protocol);
1634 u32 producer = tx_ring->producer; 1980 u32 producer = tx_ring->producer;
1635 1981
1636 if (protocol == cpu_to_be16(ETH_P_8021Q)) { 1982 if (protocol == ETH_P_8021Q) {
1637
1638 vh = (struct vlan_ethhdr *)skb->data; 1983 vh = (struct vlan_ethhdr *)skb->data;
1639 protocol = vh->h_vlan_encapsulated_proto;
1640 flags = FLAGS_VLAN_TAGGED; 1984 flags = FLAGS_VLAN_TAGGED;
1641 1985 vlan_tci = vh->h_vlan_TCI;
1642 } else if (vlan_tx_tag_present(skb)) { 1986 } else if (vlan_tx_tag_present(skb)) {
1987 flags = FLAGS_VLAN_OOB;
1988 vlan_tci = vlan_tx_tag_get(skb);
1989 }
1990 if (unlikely(adapter->pvid)) {
1991 if (vlan_tci && !(adapter->flags & QLCNIC_TAGGING_ENABLED))
1992 return -EIO;
1993 if (vlan_tci && (adapter->flags & QLCNIC_TAGGING_ENABLED))
1994 goto set_flags;
1643 1995
1644 flags = FLAGS_VLAN_OOB; 1996 flags = FLAGS_VLAN_OOB;
1645 vid = vlan_tx_tag_get(skb); 1997 vlan_tci = adapter->pvid;
1646 qlcnic_set_tx_vlan_tci(first_desc, vid);
1647 vlan_oob = 1;
1648 } 1998 }
1999set_flags:
2000 qlcnic_set_tx_vlan_tci(first_desc, vlan_tci);
2001 qlcnic_set_tx_flags_opcode(first_desc, flags, opcode);
1649 2002
1650 if (*(skb->data) & BIT_0) { 2003 if (*(skb->data) & BIT_0) {
1651 flags |= BIT_0; 2004 flags |= BIT_0;
1652 memcpy(&first_desc->eth_addr, skb->data, ETH_ALEN); 2005 memcpy(&first_desc->eth_addr, skb->data, ETH_ALEN);
1653 } 2006 }
1654 2007 opcode = TX_ETHER_PKT;
1655 if ((netdev->features & (NETIF_F_TSO | NETIF_F_TSO6)) && 2008 if ((adapter->netdev->features & (NETIF_F_TSO | NETIF_F_TSO6)) &&
1656 skb_shinfo(skb)->gso_size > 0) { 2009 skb_shinfo(skb)->gso_size > 0) {
1657 2010
1658 hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb); 2011 hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
1659 2012
1660 first_desc->mss = cpu_to_le16(skb_shinfo(skb)->gso_size); 2013 first_desc->mss = cpu_to_le16(skb_shinfo(skb)->gso_size);
1661 first_desc->total_hdr_length = hdr_len; 2014 first_desc->total_hdr_length = hdr_len;
1662 if (vlan_oob) { 2015
2016 opcode = (protocol == ETH_P_IPV6) ? TX_TCP_LSO6 : TX_TCP_LSO;
2017
2018 /* For LSO, we need to copy the MAC/IP/TCP headers into
2019 * the descriptor ring */
2020 copied = 0;
2021 offset = 2;
2022
2023 if (flags & FLAGS_VLAN_OOB) {
1663 first_desc->total_hdr_length += VLAN_HLEN; 2024 first_desc->total_hdr_length += VLAN_HLEN;
1664 first_desc->tcp_hdr_offset = VLAN_HLEN; 2025 first_desc->tcp_hdr_offset = VLAN_HLEN;
1665 first_desc->ip_hdr_offset = VLAN_HLEN; 2026 first_desc->ip_hdr_offset = VLAN_HLEN;
1666 /* Only in case of TSO on vlan device */ 2027 /* Only in case of TSO on vlan device */
1667 flags |= FLAGS_VLAN_TAGGED; 2028 flags |= FLAGS_VLAN_TAGGED;
2029
2030 /* Create a TSO vlan header template for firmware */
2031
2032 hwdesc = &tx_ring->desc_head[producer];
2033 tx_ring->cmd_buf_arr[producer].skb = NULL;
2034
2035 copy_len = min((int)sizeof(struct cmd_desc_type0) -
2036 offset, hdr_len + VLAN_HLEN);
2037
2038 vh = (struct vlan_ethhdr *)((char *) hwdesc + 2);
2039 skb_copy_from_linear_data(skb, vh, 12);
2040 vh->h_vlan_proto = htons(ETH_P_8021Q);
2041 vh->h_vlan_TCI = htons(vlan_tci);
2042
2043 skb_copy_from_linear_data_offset(skb, 12,
2044 (char *)vh + 16, copy_len - 16);
2045
2046 copied = copy_len - VLAN_HLEN;
2047 offset = 0;
2048
2049 producer = get_next_index(producer, tx_ring->num_desc);
2050 }
2051
2052 while (copied < hdr_len) {
2053
2054 copy_len = min((int)sizeof(struct cmd_desc_type0) -
2055 offset, (hdr_len - copied));
2056
2057 hwdesc = &tx_ring->desc_head[producer];
2058 tx_ring->cmd_buf_arr[producer].skb = NULL;
2059
2060 skb_copy_from_linear_data_offset(skb, copied,
2061 (char *) hwdesc + offset, copy_len);
2062
2063 copied += copy_len;
2064 offset = 0;
2065
2066 producer = get_next_index(producer, tx_ring->num_desc);
1668 } 2067 }
1669 2068
1670 opcode = (protocol == cpu_to_be16(ETH_P_IPV6)) ? 2069 tx_ring->producer = producer;
1671 TX_TCP_LSO6 : TX_TCP_LSO; 2070 smp_mb();
1672 tso = 1; 2071 adapter->stats.lso_frames++;
1673 2072
1674 } else if (skb->ip_summed == CHECKSUM_PARTIAL) { 2073 } else if (skb->ip_summed == CHECKSUM_PARTIAL) {
1675 u8 l4proto; 2074 u8 l4proto;
1676 2075
1677 if (protocol == cpu_to_be16(ETH_P_IP)) { 2076 if (protocol == ETH_P_IP) {
1678 l4proto = ip_hdr(skb)->protocol; 2077 l4proto = ip_hdr(skb)->protocol;
1679 2078
1680 if (l4proto == IPPROTO_TCP) 2079 if (l4proto == IPPROTO_TCP)
1681 opcode = TX_TCP_PKT; 2080 opcode = TX_TCP_PKT;
1682 else if (l4proto == IPPROTO_UDP) 2081 else if (l4proto == IPPROTO_UDP)
1683 opcode = TX_UDP_PKT; 2082 opcode = TX_UDP_PKT;
1684 } else if (protocol == cpu_to_be16(ETH_P_IPV6)) { 2083 } else if (protocol == ETH_P_IPV6) {
1685 l4proto = ipv6_hdr(skb)->nexthdr; 2084 l4proto = ipv6_hdr(skb)->nexthdr;
1686 2085
1687 if (l4proto == IPPROTO_TCP) 2086 if (l4proto == IPPROTO_TCP)
@@ -1690,62 +2089,11 @@ qlcnic_tso_check(struct net_device *netdev,
1690 opcode = TX_UDPV6_PKT; 2089 opcode = TX_UDPV6_PKT;
1691 } 2090 }
1692 } 2091 }
1693
1694 first_desc->tcp_hdr_offset += skb_transport_offset(skb); 2092 first_desc->tcp_hdr_offset += skb_transport_offset(skb);
1695 first_desc->ip_hdr_offset += skb_network_offset(skb); 2093 first_desc->ip_hdr_offset += skb_network_offset(skb);
1696 qlcnic_set_tx_flags_opcode(first_desc, flags, opcode); 2094 qlcnic_set_tx_flags_opcode(first_desc, flags, opcode);
1697 2095
1698 if (!tso) 2096 return 0;
1699 return;
1700
1701 /* For LSO, we need to copy the MAC/IP/TCP headers into
1702 * the descriptor ring
1703 */
1704 copied = 0;
1705 offset = 2;
1706
1707 if (vlan_oob) {
1708 /* Create a TSO vlan header template for firmware */
1709
1710 hwdesc = &tx_ring->desc_head[producer];
1711 tx_ring->cmd_buf_arr[producer].skb = NULL;
1712
1713 copy_len = min((int)sizeof(struct cmd_desc_type0) - offset,
1714 hdr_len + VLAN_HLEN);
1715
1716 vh = (struct vlan_ethhdr *)((char *)hwdesc + 2);
1717 skb_copy_from_linear_data(skb, vh, 12);
1718 vh->h_vlan_proto = htons(ETH_P_8021Q);
1719 vh->h_vlan_TCI = htons(vid);
1720 skb_copy_from_linear_data_offset(skb, 12,
1721 (char *)vh + 16, copy_len - 16);
1722
1723 copied = copy_len - VLAN_HLEN;
1724 offset = 0;
1725
1726 producer = get_next_index(producer, tx_ring->num_desc);
1727 }
1728
1729 while (copied < hdr_len) {
1730
1731 copy_len = min((int)sizeof(struct cmd_desc_type0) - offset,
1732 (hdr_len - copied));
1733
1734 hwdesc = &tx_ring->desc_head[producer];
1735 tx_ring->cmd_buf_arr[producer].skb = NULL;
1736
1737 skb_copy_from_linear_data_offset(skb, copied,
1738 (char *)hwdesc + offset, copy_len);
1739
1740 copied += copy_len;
1741 offset = 0;
1742
1743 producer = get_next_index(producer, tx_ring->num_desc);
1744 }
1745
1746 tx_ring->producer = producer;
1747 barrier();
1748 adapter->stats.lso_frames++;
1749} 2097}
1750 2098
1751static int 2099static int
@@ -1796,11 +2144,30 @@ out_err:
1796 return -ENOMEM; 2144 return -ENOMEM;
1797} 2145}
1798 2146
2147static void
2148qlcnic_unmap_buffers(struct pci_dev *pdev, struct sk_buff *skb,
2149 struct qlcnic_cmd_buffer *pbuf)
2150{
2151 struct qlcnic_skb_frag *nf = &pbuf->frag_array[0];
2152 int nr_frags = skb_shinfo(skb)->nr_frags;
2153 int i;
2154
2155 for (i = 0; i < nr_frags; i++) {
2156 nf = &pbuf->frag_array[i+1];
2157 pci_unmap_page(pdev, nf->dma, nf->length, PCI_DMA_TODEVICE);
2158 }
2159
2160 nf = &pbuf->frag_array[0];
2161 pci_unmap_single(pdev, nf->dma, skb_headlen(skb), PCI_DMA_TODEVICE);
2162 pbuf->skb = NULL;
2163}
2164
1799static inline void 2165static inline void
1800qlcnic_clear_cmddesc(u64 *desc) 2166qlcnic_clear_cmddesc(u64 *desc)
1801{ 2167{
1802 desc[0] = 0ULL; 2168 desc[0] = 0ULL;
1803 desc[2] = 0ULL; 2169 desc[2] = 0ULL;
2170 desc[7] = 0ULL;
1804} 2171}
1805 2172
1806netdev_tx_t 2173netdev_tx_t
@@ -1812,10 +2179,12 @@ qlcnic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
1812 struct qlcnic_skb_frag *buffrag; 2179 struct qlcnic_skb_frag *buffrag;
1813 struct cmd_desc_type0 *hwdesc, *first_desc; 2180 struct cmd_desc_type0 *hwdesc, *first_desc;
1814 struct pci_dev *pdev; 2181 struct pci_dev *pdev;
2182 struct ethhdr *phdr;
2183 int delta = 0;
1815 int i, k; 2184 int i, k;
1816 2185
1817 u32 producer; 2186 u32 producer;
1818 int frag_count, no_of_desc; 2187 int frag_count;
1819 u32 num_txd = tx_ring->num_desc; 2188 u32 num_txd = tx_ring->num_desc;
1820 2189
1821 if (!test_bit(__QLCNIC_DEV_UP, &adapter->state)) { 2190 if (!test_bit(__QLCNIC_DEV_UP, &adapter->state)) {
@@ -1823,14 +2192,30 @@ qlcnic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
1823 return NETDEV_TX_BUSY; 2192 return NETDEV_TX_BUSY;
1824 } 2193 }
1825 2194
2195 if (adapter->flags & QLCNIC_MACSPOOF) {
2196 phdr = (struct ethhdr *)skb->data;
2197 if (compare_ether_addr(phdr->h_source,
2198 adapter->mac_addr))
2199 goto drop_packet;
2200 }
2201
1826 frag_count = skb_shinfo(skb)->nr_frags + 1; 2202 frag_count = skb_shinfo(skb)->nr_frags + 1;
2203 /* 14 frags supported for normal packet and
2204 * 32 frags supported for TSO packet
2205 */
2206 if (!skb_is_gso(skb) && frag_count > QLCNIC_MAX_FRAGS_PER_TX) {
1827 2207
1828 /* 4 fragments per cmd des */ 2208 for (i = 0; i < (frag_count - QLCNIC_MAX_FRAGS_PER_TX); i++)
1829 no_of_desc = (frag_count + 3) >> 2; 2209 delta += skb_shinfo(skb)->frags[i].size;
2210
2211 if (!__pskb_pull_tail(skb, delta))
2212 goto drop_packet;
2213
2214 frag_count = 1 + skb_shinfo(skb)->nr_frags;
2215 }
1830 2216
1831 if (unlikely(qlcnic_tx_avail(tx_ring) <= TX_STOP_THRESH)) { 2217 if (unlikely(qlcnic_tx_avail(tx_ring) <= TX_STOP_THRESH)) {
1832 netif_stop_queue(netdev); 2218 netif_stop_queue(netdev);
1833 smp_mb();
1834 if (qlcnic_tx_avail(tx_ring) > TX_STOP_THRESH) 2219 if (qlcnic_tx_avail(tx_ring) > TX_STOP_THRESH)
1835 netif_start_queue(netdev); 2220 netif_start_queue(netdev);
1836 else { 2221 else {
@@ -1844,6 +2229,9 @@ qlcnic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
1844 2229
1845 pdev = adapter->pdev; 2230 pdev = adapter->pdev;
1846 2231
2232 first_desc = hwdesc = &tx_ring->desc_head[producer];
2233 qlcnic_clear_cmddesc((u64 *)hwdesc);
2234
1847 if (qlcnic_map_tx_skb(pdev, skb, pbuf)) { 2235 if (qlcnic_map_tx_skb(pdev, skb, pbuf)) {
1848 adapter->stats.tx_dma_map_error++; 2236 adapter->stats.tx_dma_map_error++;
1849 goto drop_packet; 2237 goto drop_packet;
@@ -1852,9 +2240,6 @@ qlcnic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
1852 pbuf->skb = skb; 2240 pbuf->skb = skb;
1853 pbuf->frag_count = frag_count; 2241 pbuf->frag_count = frag_count;
1854 2242
1855 first_desc = hwdesc = &tx_ring->desc_head[producer];
1856 qlcnic_clear_cmddesc((u64 *)hwdesc);
1857
1858 qlcnic_set_tx_frags_len(first_desc, frag_count, skb->len); 2243 qlcnic_set_tx_frags_len(first_desc, frag_count, skb->len);
1859 qlcnic_set_tx_port(first_desc, adapter->portnum); 2244 qlcnic_set_tx_port(first_desc, adapter->portnum);
1860 2245
@@ -1890,8 +2275,13 @@ qlcnic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
1890 } 2275 }
1891 2276
1892 tx_ring->producer = get_next_index(producer, num_txd); 2277 tx_ring->producer = get_next_index(producer, num_txd);
2278 smp_mb();
2279
2280 if (unlikely(qlcnic_tx_pkt(adapter, first_desc, skb)))
2281 goto unwind_buff;
1893 2282
1894 qlcnic_tso_check(netdev, tx_ring, first_desc, skb); 2283 if (qlcnic_mac_learn)
2284 qlcnic_send_filter(adapter, tx_ring, first_desc, skb);
1895 2285
1896 qlcnic_update_cmd_producer(adapter, tx_ring); 2286 qlcnic_update_cmd_producer(adapter, tx_ring);
1897 2287
@@ -1900,6 +2290,8 @@ qlcnic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
1900 2290
1901 return NETDEV_TX_OK; 2291 return NETDEV_TX_OK;
1902 2292
2293unwind_buff:
2294 qlcnic_unmap_buffers(pdev, skb, pbuf);
1903drop_packet: 2295drop_packet:
1904 adapter->stats.txdropped++; 2296 adapter->stats.txdropped++;
1905 dev_kfree_skb_any(skb); 2297 dev_kfree_skb_any(skb);
@@ -1946,16 +2338,16 @@ void qlcnic_advert_link_change(struct qlcnic_adapter *adapter, int linkup)
1946{ 2338{
1947 struct net_device *netdev = adapter->netdev; 2339 struct net_device *netdev = adapter->netdev;
1948 2340
1949 if (adapter->ahw.linkup && !linkup) { 2341 if (adapter->ahw->linkup && !linkup) {
1950 dev_info(&netdev->dev, "NIC Link is down\n"); 2342 netdev_info(netdev, "NIC Link is down\n");
1951 adapter->ahw.linkup = 0; 2343 adapter->ahw->linkup = 0;
1952 if (netif_running(netdev)) { 2344 if (netif_running(netdev)) {
1953 netif_carrier_off(netdev); 2345 netif_carrier_off(netdev);
1954 netif_stop_queue(netdev); 2346 netif_stop_queue(netdev);
1955 } 2347 }
1956 } else if (!adapter->ahw.linkup && linkup) { 2348 } else if (!adapter->ahw->linkup && linkup) {
1957 dev_info(&netdev->dev, "NIC Link is up\n"); 2349 netdev_info(netdev, "NIC Link is up\n");
1958 adapter->ahw.linkup = 1; 2350 adapter->ahw->linkup = 1;
1959 if (netif_running(netdev)) { 2351 if (netif_running(netdev)) {
1960 netif_carrier_on(netdev); 2352 netif_carrier_on(netdev);
1961 netif_wake_queue(netdev); 2353 netif_wake_queue(netdev);
@@ -2191,7 +2583,7 @@ static void qlcnic_poll_controller(struct net_device *netdev)
2191 int ring; 2583 int ring;
2192 struct qlcnic_host_sds_ring *sds_ring; 2584 struct qlcnic_host_sds_ring *sds_ring;
2193 struct qlcnic_adapter *adapter = netdev_priv(netdev); 2585 struct qlcnic_adapter *adapter = netdev_priv(netdev);
2194 struct qlcnic_recv_context *recv_ctx = &adapter->recv_ctx; 2586 struct qlcnic_recv_context *recv_ctx = adapter->recv_ctx;
2195 2587
2196 disable_irq(adapter->irq); 2588 disable_irq(adapter->irq);
2197 for (ring = 0; ring < adapter->max_sds_rings; ring++) { 2589 for (ring = 0; ring < adapter->max_sds_rings; ring++) {
@@ -2258,18 +2650,22 @@ qlcnic_clr_drv_state(struct qlcnic_adapter *adapter)
2258} 2650}
2259 2651
2260static void 2652static void
2261qlcnic_clr_all_drv_state(struct qlcnic_adapter *adapter) 2653qlcnic_clr_all_drv_state(struct qlcnic_adapter *adapter, u8 failed)
2262{ 2654{
2263 u32 val; 2655 u32 val;
2264 2656
2265 if (qlcnic_api_lock(adapter)) 2657 if (qlcnic_api_lock(adapter))
2266 goto err; 2658 goto err;
2267 2659
2268 val = QLCRD32(adapter, QLCNIC_CRB_DEV_REF_COUNT); 2660 val = QLCRD32(adapter, QLCNIC_CRB_DRV_ACTIVE);
2269 QLC_DEV_CLR_REF_CNT(val, adapter->portnum); 2661 QLC_DEV_CLR_REF_CNT(val, adapter->portnum);
2270 QLCWR32(adapter, QLCNIC_CRB_DEV_REF_COUNT, val); 2662 QLCWR32(adapter, QLCNIC_CRB_DRV_ACTIVE, val);
2271 2663
2272 if (!(val & 0x11111111)) 2664 if (failed) {
2665 QLCWR32(adapter, QLCNIC_CRB_DEV_STATE, QLCNIC_DEV_FAILED);
2666 dev_info(&adapter->pdev->dev,
2667 "Device state set to Failed. Please Reboot\n");
2668 } else if (!(val & 0x11111111))
2273 QLCWR32(adapter, QLCNIC_CRB_DEV_STATE, QLCNIC_DEV_COLD); 2669 QLCWR32(adapter, QLCNIC_CRB_DEV_STATE, QLCNIC_DEV_COLD);
2274 2670
2275 val = QLCRD32(adapter, QLCNIC_CRB_DRV_STATE); 2671 val = QLCRD32(adapter, QLCNIC_CRB_DRV_STATE);
@@ -2290,7 +2686,7 @@ qlcnic_check_drv_state(struct qlcnic_adapter *adapter)
2290 int act, state; 2686 int act, state;
2291 2687
2292 state = QLCRD32(adapter, QLCNIC_CRB_DRV_STATE); 2688 state = QLCRD32(adapter, QLCNIC_CRB_DRV_STATE);
2293 act = QLCRD32(adapter, QLCNIC_CRB_DEV_REF_COUNT); 2689 act = QLCRD32(adapter, QLCNIC_CRB_DRV_ACTIVE);
2294 2690
2295 if (((state & 0x11111111) == (act & 0x11111111)) || 2691 if (((state & 0x11111111) == (act & 0x11111111)) ||
2296 ((act & 0x11111111) == ((state >> 1) & 0x11111111))) 2692 ((act & 0x11111111) == ((state >> 1) & 0x11111111)))
@@ -2325,10 +2721,10 @@ qlcnic_can_start_firmware(struct qlcnic_adapter *adapter)
2325 if (qlcnic_api_lock(adapter)) 2721 if (qlcnic_api_lock(adapter))
2326 return -1; 2722 return -1;
2327 2723
2328 val = QLCRD32(adapter, QLCNIC_CRB_DEV_REF_COUNT); 2724 val = QLCRD32(adapter, QLCNIC_CRB_DRV_ACTIVE);
2329 if (!(val & (1 << (portnum * 4)))) { 2725 if (!(val & (1 << (portnum * 4)))) {
2330 QLC_DEV_SET_REF_CNT(val, portnum); 2726 QLC_DEV_SET_REF_CNT(val, portnum);
2331 QLCWR32(adapter, QLCNIC_CRB_DEV_REF_COUNT, val); 2727 QLCWR32(adapter, QLCNIC_CRB_DRV_ACTIVE, val);
2332 } 2728 }
2333 2729
2334 prev_state = QLCRD32(adapter, QLCNIC_CRB_DEV_STATE); 2730 prev_state = QLCRD32(adapter, QLCNIC_CRB_DEV_STATE);
@@ -2403,13 +2799,14 @@ qlcnic_fwinit_work(struct work_struct *work)
2403{ 2799{
2404 struct qlcnic_adapter *adapter = container_of(work, 2800 struct qlcnic_adapter *adapter = container_of(work,
2405 struct qlcnic_adapter, fw_work.work); 2801 struct qlcnic_adapter, fw_work.work);
2406 u32 dev_state = 0xf, npar_state; 2802 u32 dev_state = 0xf;
2407 2803
2408 if (qlcnic_api_lock(adapter)) 2804 if (qlcnic_api_lock(adapter))
2409 goto err_ret; 2805 goto err_ret;
2410 2806
2411 dev_state = QLCRD32(adapter, QLCNIC_CRB_DEV_STATE); 2807 dev_state = QLCRD32(adapter, QLCNIC_CRB_DEV_STATE);
2412 if (dev_state == QLCNIC_DEV_QUISCENT) { 2808 if (dev_state == QLCNIC_DEV_QUISCENT ||
2809 dev_state == QLCNIC_DEV_NEED_QUISCENT) {
2413 qlcnic_api_unlock(adapter); 2810 qlcnic_api_unlock(adapter);
2414 qlcnic_schedule_work(adapter, qlcnic_fwinit_work, 2811 qlcnic_schedule_work(adapter, qlcnic_fwinit_work,
2415 FW_POLL_DELAY * 2); 2812 FW_POLL_DELAY * 2);
@@ -2417,16 +2814,8 @@ qlcnic_fwinit_work(struct work_struct *work)
2417 } 2814 }
2418 2815
2419 if (adapter->op_mode == QLCNIC_NON_PRIV_FUNC) { 2816 if (adapter->op_mode == QLCNIC_NON_PRIV_FUNC) {
2420 npar_state = QLCRD32(adapter, QLCNIC_CRB_DEV_NPAR_STATE); 2817 qlcnic_api_unlock(adapter);
2421 if (npar_state == QLCNIC_DEV_NPAR_RDY) { 2818 goto wait_npar;
2422 qlcnic_api_unlock(adapter);
2423 goto wait_npar;
2424 } else {
2425 qlcnic_schedule_work(adapter, qlcnic_fwinit_work,
2426 FW_POLL_DELAY);
2427 qlcnic_api_unlock(adapter);
2428 return;
2429 }
2430 } 2819 }
2431 2820
2432 if (adapter->fw_wait_cnt++ > adapter->reset_ack_timeo) { 2821 if (adapter->fw_wait_cnt++ > adapter->reset_ack_timeo) {
@@ -2439,30 +2828,21 @@ qlcnic_fwinit_work(struct work_struct *work)
2439skip_ack_check: 2828skip_ack_check:
2440 dev_state = QLCRD32(adapter, QLCNIC_CRB_DEV_STATE); 2829 dev_state = QLCRD32(adapter, QLCNIC_CRB_DEV_STATE);
2441 2830
2442 if (dev_state == QLCNIC_DEV_NEED_QUISCENT) {
2443 QLCWR32(adapter, QLCNIC_CRB_DEV_STATE,
2444 QLCNIC_DEV_QUISCENT);
2445 qlcnic_schedule_work(adapter, qlcnic_fwinit_work,
2446 FW_POLL_DELAY * 2);
2447 QLCDB(adapter, DRV, "Quiscing the driver\n");
2448 qlcnic_idc_debug_info(adapter, 0);
2449
2450 qlcnic_api_unlock(adapter);
2451 return;
2452 }
2453
2454 if (dev_state == QLCNIC_DEV_NEED_RESET) { 2831 if (dev_state == QLCNIC_DEV_NEED_RESET) {
2455 QLCWR32(adapter, QLCNIC_CRB_DEV_STATE, 2832 QLCWR32(adapter, QLCNIC_CRB_DEV_STATE,
2456 QLCNIC_DEV_INITIALIZING); 2833 QLCNIC_DEV_INITIALIZING);
2457 set_bit(__QLCNIC_START_FW, &adapter->state); 2834 set_bit(__QLCNIC_START_FW, &adapter->state);
2458 QLCDB(adapter, DRV, "Restarting fw\n"); 2835 QLCDB(adapter, DRV, "Restarting fw\n");
2459 qlcnic_idc_debug_info(adapter, 0); 2836 qlcnic_idc_debug_info(adapter, 0);
2837 QLCDB(adapter, DRV, "Take FW dump\n");
2838 qlcnic_dump_fw(adapter);
2460 } 2839 }
2461 2840
2462 qlcnic_api_unlock(adapter); 2841 qlcnic_api_unlock(adapter);
2463 2842
2464 if (!adapter->nic_ops->start_firmware(adapter)) { 2843 if (!adapter->nic_ops->start_firmware(adapter)) {
2465 qlcnic_schedule_work(adapter, qlcnic_attach_work, 0); 2844 qlcnic_schedule_work(adapter, qlcnic_attach_work, 0);
2845 adapter->fw_wait_cnt = 0;
2466 return; 2846 return;
2467 } 2847 }
2468 goto err_ret; 2848 goto err_ret;
@@ -2475,27 +2855,25 @@ wait_npar:
2475 QLCDB(adapter, HW, "Func waiting: Device state=%u\n", dev_state); 2855 QLCDB(adapter, HW, "Func waiting: Device state=%u\n", dev_state);
2476 2856
2477 switch (dev_state) { 2857 switch (dev_state) {
2478 case QLCNIC_DEV_QUISCENT: 2858 case QLCNIC_DEV_READY:
2479 case QLCNIC_DEV_NEED_QUISCENT:
2480 case QLCNIC_DEV_NEED_RESET:
2481 qlcnic_schedule_work(adapter,
2482 qlcnic_fwinit_work, FW_POLL_DELAY);
2483 return;
2484 case QLCNIC_DEV_FAILED:
2485 break;
2486
2487 default:
2488 if (!adapter->nic_ops->start_firmware(adapter)) { 2859 if (!adapter->nic_ops->start_firmware(adapter)) {
2489 qlcnic_schedule_work(adapter, qlcnic_attach_work, 0); 2860 qlcnic_schedule_work(adapter, qlcnic_attach_work, 0);
2861 adapter->fw_wait_cnt = 0;
2490 return; 2862 return;
2491 } 2863 }
2864 case QLCNIC_DEV_FAILED:
2865 break;
2866 default:
2867 qlcnic_schedule_work(adapter,
2868 qlcnic_fwinit_work, FW_POLL_DELAY);
2869 return;
2492 } 2870 }
2493 2871
2494err_ret: 2872err_ret:
2495 dev_err(&adapter->pdev->dev, "Fwinit work failed state=%u " 2873 dev_err(&adapter->pdev->dev, "Fwinit work failed state=%u "
2496 "fw_wait_cnt=%u\n", dev_state, adapter->fw_wait_cnt); 2874 "fw_wait_cnt=%u\n", dev_state, adapter->fw_wait_cnt);
2497 netif_device_attach(adapter->netdev); 2875 netif_device_attach(adapter->netdev);
2498 qlcnic_clr_all_drv_state(adapter); 2876 qlcnic_clr_all_drv_state(adapter, 0);
2499} 2877}
2500 2878
2501static void 2879static void
@@ -2508,7 +2886,12 @@ qlcnic_detach_work(struct work_struct *work)
2508 2886
2509 netif_device_detach(netdev); 2887 netif_device_detach(netdev);
2510 2888
2511 qlcnic_down(adapter, netdev); 2889 /* Dont grab rtnl lock during Quiscent mode */
2890 if (adapter->dev_state == QLCNIC_DEV_NEED_QUISCENT) {
2891 if (netif_running(netdev))
2892 __qlcnic_down(adapter, netdev);
2893 } else
2894 qlcnic_down(adapter, netdev);
2512 2895
2513 status = QLCRD32(adapter, QLCNIC_PEG_HALT_STATUS1); 2896 status = QLCRD32(adapter, QLCNIC_PEG_HALT_STATUS1);
2514 2897
@@ -2531,12 +2914,27 @@ err_ret:
2531 dev_err(&adapter->pdev->dev, "detach failed; status=%d temp=%d\n", 2914 dev_err(&adapter->pdev->dev, "detach failed; status=%d temp=%d\n",
2532 status, adapter->temp); 2915 status, adapter->temp);
2533 netif_device_attach(netdev); 2916 netif_device_attach(netdev);
2534 qlcnic_clr_all_drv_state(adapter); 2917 qlcnic_clr_all_drv_state(adapter, 1);
2918}
2919
2920/*Transit NPAR state to NON Operational */
2921static void
2922qlcnic_set_npar_non_operational(struct qlcnic_adapter *adapter)
2923{
2924 u32 state;
2925
2926 state = QLCRD32(adapter, QLCNIC_CRB_DEV_NPAR_STATE);
2927 if (state == QLCNIC_DEV_NPAR_NON_OPER)
2928 return;
2535 2929
2930 if (qlcnic_api_lock(adapter))
2931 return;
2932 QLCWR32(adapter, QLCNIC_CRB_DEV_NPAR_STATE, QLCNIC_DEV_NPAR_NON_OPER);
2933 qlcnic_api_unlock(adapter);
2536} 2934}
2537 2935
2538/*Transit to RESET state from READY state only */ 2936/*Transit to RESET state from READY state only */
2539static void 2937void
2540qlcnic_dev_request_reset(struct qlcnic_adapter *adapter) 2938qlcnic_dev_request_reset(struct qlcnic_adapter *adapter)
2541{ 2939{
2542 u32 state; 2940 u32 state;
@@ -2553,6 +2951,7 @@ qlcnic_dev_request_reset(struct qlcnic_adapter *adapter)
2553 qlcnic_idc_debug_info(adapter, 0); 2951 qlcnic_idc_debug_info(adapter, 0);
2554 } 2952 }
2555 2953
2954 QLCWR32(adapter, QLCNIC_CRB_DEV_NPAR_STATE, QLCNIC_DEV_NPAR_NON_OPER);
2556 qlcnic_api_unlock(adapter); 2955 qlcnic_api_unlock(adapter);
2557} 2956}
2558 2957
@@ -2560,21 +2959,11 @@ qlcnic_dev_request_reset(struct qlcnic_adapter *adapter)
2560static void 2959static void
2561qlcnic_dev_set_npar_ready(struct qlcnic_adapter *adapter) 2960qlcnic_dev_set_npar_ready(struct qlcnic_adapter *adapter)
2562{ 2961{
2563 u32 state;
2564
2565 if (!(adapter->flags & QLCNIC_ESWITCH_ENABLED) ||
2566 adapter->op_mode == QLCNIC_NON_PRIV_FUNC)
2567 return;
2568 if (qlcnic_api_lock(adapter)) 2962 if (qlcnic_api_lock(adapter))
2569 return; 2963 return;
2570 2964
2571 state = QLCRD32(adapter, QLCNIC_CRB_DEV_NPAR_STATE); 2965 QLCWR32(adapter, QLCNIC_CRB_DEV_NPAR_STATE, QLCNIC_DEV_NPAR_OPER);
2572 2966 QLCDB(adapter, DRV, "NPAR operational state set\n");
2573 if (state != QLCNIC_DEV_NPAR_RDY) {
2574 QLCWR32(adapter, QLCNIC_CRB_DEV_NPAR_STATE,
2575 QLCNIC_DEV_NPAR_RDY);
2576 QLCDB(adapter, DRV, "NPAR READY state set\n");
2577 }
2578 2967
2579 qlcnic_api_unlock(adapter); 2968 qlcnic_api_unlock(adapter);
2580} 2969}
@@ -2587,7 +2976,8 @@ qlcnic_schedule_work(struct qlcnic_adapter *adapter,
2587 return; 2976 return;
2588 2977
2589 INIT_DELAYED_WORK(&adapter->fw_work, func); 2978 INIT_DELAYED_WORK(&adapter->fw_work, func);
2590 schedule_delayed_work(&adapter->fw_work, round_jiffies_relative(delay)); 2979 queue_delayed_work(qlcnic_wq, &adapter->fw_work,
2980 round_jiffies_relative(delay));
2591} 2981}
2592 2982
2593static void 2983static void
@@ -2605,12 +2995,26 @@ qlcnic_attach_work(struct work_struct *work)
2605 struct qlcnic_adapter *adapter = container_of(work, 2995 struct qlcnic_adapter *adapter = container_of(work,
2606 struct qlcnic_adapter, fw_work.work); 2996 struct qlcnic_adapter, fw_work.work);
2607 struct net_device *netdev = adapter->netdev; 2997 struct net_device *netdev = adapter->netdev;
2998 u32 npar_state;
2608 2999
3000 if (adapter->op_mode != QLCNIC_MGMT_FUNC) {
3001 npar_state = QLCRD32(adapter, QLCNIC_CRB_DEV_NPAR_STATE);
3002 if (adapter->fw_wait_cnt++ > QLCNIC_DEV_NPAR_OPER_TIMEO)
3003 qlcnic_clr_all_drv_state(adapter, 0);
3004 else if (npar_state != QLCNIC_DEV_NPAR_OPER)
3005 qlcnic_schedule_work(adapter, qlcnic_attach_work,
3006 FW_POLL_DELAY);
3007 else
3008 goto attach;
3009 QLCDB(adapter, DRV, "Waiting for NPAR state to operational\n");
3010 return;
3011 }
3012attach:
2609 if (netif_running(netdev)) { 3013 if (netif_running(netdev)) {
2610 if (qlcnic_up(adapter, netdev)) 3014 if (qlcnic_up(adapter, netdev))
2611 goto done; 3015 goto done;
2612 3016
2613 qlcnic_config_indev_addr(netdev, NETDEV_UP); 3017 qlcnic_restore_indev_addr(netdev, NETDEV_UP);
2614 } 3018 }
2615 3019
2616done: 3020done:
@@ -2626,7 +3030,7 @@ done:
2626static int 3030static int
2627qlcnic_check_health(struct qlcnic_adapter *adapter) 3031qlcnic_check_health(struct qlcnic_adapter *adapter)
2628{ 3032{
2629 u32 state = 0, heartbit; 3033 u32 state = 0, heartbeat;
2630 struct net_device *netdev = adapter->netdev; 3034 struct net_device *netdev = adapter->netdev;
2631 3035
2632 if (qlcnic_check_temp(adapter)) 3036 if (qlcnic_check_temp(adapter))
@@ -2636,18 +3040,20 @@ qlcnic_check_health(struct qlcnic_adapter *adapter)
2636 qlcnic_dev_request_reset(adapter); 3040 qlcnic_dev_request_reset(adapter);
2637 3041
2638 state = QLCRD32(adapter, QLCNIC_CRB_DEV_STATE); 3042 state = QLCRD32(adapter, QLCNIC_CRB_DEV_STATE);
2639 if (state == QLCNIC_DEV_NEED_RESET || state == QLCNIC_DEV_NEED_QUISCENT) 3043 if (state == QLCNIC_DEV_NEED_RESET) {
3044 qlcnic_set_npar_non_operational(adapter);
2640 adapter->need_fw_reset = 1; 3045 adapter->need_fw_reset = 1;
3046 } else if (state == QLCNIC_DEV_NEED_QUISCENT)
3047 goto detach;
2641 3048
2642 heartbit = QLCRD32(adapter, QLCNIC_PEG_ALIVE_COUNTER); 3049 heartbeat = QLCRD32(adapter, QLCNIC_PEG_ALIVE_COUNTER);
2643 if (heartbit != adapter->heartbit) { 3050 if (heartbeat != adapter->heartbeat) {
2644 adapter->heartbit = heartbit; 3051 adapter->heartbeat = heartbeat;
2645 adapter->fw_fail_cnt = 0; 3052 adapter->fw_fail_cnt = 0;
2646 if (adapter->need_fw_reset) 3053 if (adapter->need_fw_reset)
2647 goto detach; 3054 goto detach;
2648 3055
2649 if (adapter->reset_context && 3056 if (adapter->reset_context && auto_fw_reset) {
2650 auto_fw_reset == AUTO_FW_RESET_ENABLED) {
2651 qlcnic_reset_hw_context(adapter); 3057 qlcnic_reset_hw_context(adapter);
2652 adapter->netdev->trans_start = jiffies; 3058 adapter->netdev->trans_start = jiffies;
2653 } 3059 }
@@ -2660,7 +3066,7 @@ qlcnic_check_health(struct qlcnic_adapter *adapter)
2660 3066
2661 qlcnic_dev_request_reset(adapter); 3067 qlcnic_dev_request_reset(adapter);
2662 3068
2663 if ((auto_fw_reset == AUTO_FW_RESET_ENABLED)) 3069 if (auto_fw_reset)
2664 clear_bit(__QLCNIC_FW_ATTACHED, &adapter->state); 3070 clear_bit(__QLCNIC_FW_ATTACHED, &adapter->state);
2665 3071
2666 dev_info(&netdev->dev, "firmware hang detected\n"); 3072 dev_info(&netdev->dev, "firmware hang detected\n");
@@ -2669,7 +3075,7 @@ detach:
2669 adapter->dev_state = (state == QLCNIC_DEV_NEED_QUISCENT) ? state : 3075 adapter->dev_state = (state == QLCNIC_DEV_NEED_QUISCENT) ? state :
2670 QLCNIC_DEV_NEED_RESET; 3076 QLCNIC_DEV_NEED_RESET;
2671 3077
2672 if ((auto_fw_reset == AUTO_FW_RESET_ENABLED) && 3078 if (auto_fw_reset &&
2673 !test_and_set_bit(__QLCNIC_RESETTING, &adapter->state)) { 3079 !test_and_set_bit(__QLCNIC_RESETTING, &adapter->state)) {
2674 3080
2675 qlcnic_schedule_work(adapter, qlcnic_detach_work, 0); 3081 qlcnic_schedule_work(adapter, qlcnic_detach_work, 0);
@@ -2692,6 +3098,9 @@ qlcnic_fw_poll_work(struct work_struct *work)
2692 if (qlcnic_check_health(adapter)) 3098 if (qlcnic_check_health(adapter))
2693 return; 3099 return;
2694 3100
3101 if (adapter->fhash.fnum)
3102 qlcnic_prune_lb_filters(adapter);
3103
2695reschedule: 3104reschedule:
2696 qlcnic_schedule_work(adapter, qlcnic_fw_poll_work, FW_POLL_DELAY); 3105 qlcnic_schedule_work(adapter, qlcnic_fw_poll_work, FW_POLL_DELAY);
2697} 3106}
@@ -2738,7 +3147,7 @@ static int qlcnic_attach_func(struct pci_dev *pdev)
2738 if (qlcnic_api_lock(adapter)) 3147 if (qlcnic_api_lock(adapter))
2739 return -EINVAL; 3148 return -EINVAL;
2740 3149
2741 if (first_func) { 3150 if (adapter->op_mode != QLCNIC_NON_PRIV_FUNC && first_func) {
2742 adapter->need_fw_reset = 1; 3151 adapter->need_fw_reset = 1;
2743 set_bit(__QLCNIC_START_FW, &adapter->state); 3152 set_bit(__QLCNIC_START_FW, &adapter->state);
2744 QLCWR32(adapter, QLCNIC_CRB_DEV_STATE, QLCNIC_DEV_INITIALIZING); 3153 QLCWR32(adapter, QLCNIC_CRB_DEV_STATE, QLCNIC_DEV_INITIALIZING);
@@ -2756,7 +3165,7 @@ static int qlcnic_attach_func(struct pci_dev *pdev)
2756 if (netif_running(netdev)) { 3165 if (netif_running(netdev)) {
2757 err = qlcnic_attach(adapter); 3166 err = qlcnic_attach(adapter);
2758 if (err) { 3167 if (err) {
2759 qlcnic_clr_all_drv_state(adapter); 3168 qlcnic_clr_all_drv_state(adapter, 1);
2760 clear_bit(__QLCNIC_AER, &adapter->state); 3169 clear_bit(__QLCNIC_AER, &adapter->state);
2761 netif_device_attach(netdev); 3170 netif_device_attach(netdev);
2762 return err; 3171 return err;
@@ -2766,7 +3175,7 @@ static int qlcnic_attach_func(struct pci_dev *pdev)
2766 if (err) 3175 if (err)
2767 goto done; 3176 goto done;
2768 3177
2769 qlcnic_config_indev_addr(netdev, NETDEV_UP); 3178 qlcnic_restore_indev_addr(netdev, NETDEV_UP);
2770 } 3179 }
2771 done: 3180 done:
2772 netif_device_attach(netdev); 3181 netif_device_attach(netdev);
@@ -2822,7 +3231,6 @@ static void qlcnic_io_resume(struct pci_dev *pdev)
2822 FW_POLL_DELAY); 3231 FW_POLL_DELAY);
2823} 3232}
2824 3233
2825
2826static int 3234static int
2827qlcnicvf_start_firmware(struct qlcnic_adapter *adapter) 3235qlcnicvf_start_firmware(struct qlcnic_adapter *adapter)
2828{ 3236{
@@ -2832,8 +3240,20 @@ qlcnicvf_start_firmware(struct qlcnic_adapter *adapter)
2832 if (err) 3240 if (err)
2833 return err; 3241 return err;
2834 3242
3243 err = qlcnic_check_npar_opertional(adapter);
3244 if (err)
3245 return err;
3246
3247 err = qlcnic_initialize_nic(adapter);
3248 if (err)
3249 return err;
3250
2835 qlcnic_check_options(adapter); 3251 qlcnic_check_options(adapter);
2836 3252
3253 err = qlcnic_set_eswitch_port_config(adapter);
3254 if (err)
3255 return err;
3256
2837 adapter->need_fw_reset = 0; 3257 adapter->need_fw_reset = 0;
2838 3258
2839 return err; 3259 return err;
@@ -2926,6 +3346,56 @@ static struct device_attribute dev_attr_diag_mode = {
2926 .store = qlcnic_store_diag_mode, 3346 .store = qlcnic_store_diag_mode,
2927}; 3347};
2928 3348
3349int qlcnic_validate_max_rss(struct net_device *netdev, u8 max_hw, u8 val)
3350{
3351 if (!use_msi_x && !use_msi) {
3352 netdev_info(netdev, "no msix or msi support, hence no rss\n");
3353 return -EINVAL;
3354 }
3355
3356 if ((val > max_hw) || (val < 2) || !is_power_of_2(val)) {
3357 netdev_info(netdev, "rss_ring valid range [2 - %x] in "
3358 " powers of 2\n", max_hw);
3359 return -EINVAL;
3360 }
3361 return 0;
3362
3363}
3364
3365int qlcnic_set_max_rss(struct qlcnic_adapter *adapter, u8 data)
3366{
3367 struct net_device *netdev = adapter->netdev;
3368 int err = 0;
3369
3370 if (test_and_set_bit(__QLCNIC_RESETTING, &adapter->state))
3371 return -EBUSY;
3372
3373 netif_device_detach(netdev);
3374 if (netif_running(netdev))
3375 __qlcnic_down(adapter, netdev);
3376 qlcnic_detach(adapter);
3377 qlcnic_teardown_intr(adapter);
3378
3379 if (qlcnic_enable_msix(adapter, data)) {
3380 netdev_info(netdev, "failed setting max_rss; rss disabled\n");
3381 qlcnic_enable_msi_legacy(adapter);
3382 }
3383
3384 if (netif_running(netdev)) {
3385 err = qlcnic_attach(adapter);
3386 if (err)
3387 goto done;
3388 err = __qlcnic_up(adapter, netdev);
3389 if (err)
3390 goto done;
3391 qlcnic_restore_indev_addr(netdev, NETDEV_UP);
3392 }
3393 done:
3394 netif_device_attach(netdev);
3395 clear_bit(__QLCNIC_RESETTING, &adapter->state);
3396 return err;
3397}
3398
2929static int 3399static int
2930qlcnic_sysfs_validate_crb(struct qlcnic_adapter *adapter, 3400qlcnic_sysfs_validate_crb(struct qlcnic_adapter *adapter,
2931 loff_t offset, size_t size) 3401 loff_t offset, size_t size)
@@ -3056,7 +3526,6 @@ qlcnic_sysfs_write_mem(struct file *filp, struct kobject *kobj,
3056 return size; 3526 return size;
3057} 3527}
3058 3528
3059
3060static struct bin_attribute bin_attr_crb = { 3529static struct bin_attribute bin_attr_crb = {
3061 .attr = {.name = "crb", .mode = (S_IRUGO | S_IWUSR)}, 3530 .attr = {.name = "crb", .mode = (S_IRUGO | S_IWUSR)},
3062 .size = 0, 3531 .size = 0,
@@ -3093,9 +3562,6 @@ validate_pm_config(struct qlcnic_adapter *adapter,
3093 if (adapter->npars[dest_pci_func].type != QLCNIC_TYPE_NIC) 3562 if (adapter->npars[dest_pci_func].type != QLCNIC_TYPE_NIC)
3094 return QL_STATUS_INVALID_PARAM; 3563 return QL_STATUS_INVALID_PARAM;
3095 3564
3096 if (!IS_VALID_MODE(pm_cfg[i].action))
3097 return QL_STATUS_INVALID_PARAM;
3098
3099 s_esw_id = adapter->npars[src_pci_func].phy_port; 3565 s_esw_id = adapter->npars[src_pci_func].phy_port;
3100 d_esw_id = adapter->npars[dest_pci_func].phy_port; 3566 d_esw_id = adapter->npars[dest_pci_func].phy_port;
3101 3567
@@ -3129,7 +3595,7 @@ qlcnic_sysfs_write_pm_config(struct file *filp, struct kobject *kobj,
3129 return ret; 3595 return ret;
3130 for (i = 0; i < count; i++) { 3596 for (i = 0; i < count; i++) {
3131 pci_func = pm_cfg[i].pci_func; 3597 pci_func = pm_cfg[i].pci_func;
3132 action = pm_cfg[i].action; 3598 action = !!pm_cfg[i].action;
3133 id = adapter->npars[pci_func].phy_port; 3599 id = adapter->npars[pci_func].phy_port;
3134 ret = qlcnic_config_port_mirroring(adapter, id, 3600 ret = qlcnic_config_port_mirroring(adapter, id,
3135 action, pci_func); 3601 action, pci_func);
@@ -3140,7 +3606,7 @@ qlcnic_sysfs_write_pm_config(struct file *filp, struct kobject *kobj,
3140 for (i = 0; i < count; i++) { 3606 for (i = 0; i < count; i++) {
3141 pci_func = pm_cfg[i].pci_func; 3607 pci_func = pm_cfg[i].pci_func;
3142 id = adapter->npars[pci_func].phy_port; 3608 id = adapter->npars[pci_func].phy_port;
3143 adapter->npars[pci_func].enable_pm = pm_cfg[i].action; 3609 adapter->npars[pci_func].enable_pm = !!pm_cfg[i].action;
3144 adapter->npars[pci_func].dest_npar = id; 3610 adapter->npars[pci_func].dest_npar = id;
3145 } 3611 }
3146 return size; 3612 return size;
@@ -3172,30 +3638,49 @@ qlcnic_sysfs_read_pm_config(struct file *filp, struct kobject *kobj,
3172 3638
3173static int 3639static int
3174validate_esw_config(struct qlcnic_adapter *adapter, 3640validate_esw_config(struct qlcnic_adapter *adapter,
3175 struct qlcnic_esw_func_cfg *esw_cfg, int count) 3641 struct qlcnic_esw_func_cfg *esw_cfg, int count)
3176{ 3642{
3643 u32 op_mode;
3177 u8 pci_func; 3644 u8 pci_func;
3178 int i; 3645 int i;
3179 3646
3647 op_mode = readl(adapter->ahw->pci_base0 + QLCNIC_DRV_OP_MODE);
3648
3180 for (i = 0; i < count; i++) { 3649 for (i = 0; i < count; i++) {
3181 pci_func = esw_cfg[i].pci_func; 3650 pci_func = esw_cfg[i].pci_func;
3182 if (pci_func >= QLCNIC_MAX_PCI_FUNC) 3651 if (pci_func >= QLCNIC_MAX_PCI_FUNC)
3183 return QL_STATUS_INVALID_PARAM; 3652 return QL_STATUS_INVALID_PARAM;
3184 3653
3185 if (adapter->npars[i].type != QLCNIC_TYPE_NIC) 3654 if (adapter->op_mode == QLCNIC_MGMT_FUNC)
3186 return QL_STATUS_INVALID_PARAM; 3655 if (adapter->npars[pci_func].type != QLCNIC_TYPE_NIC)
3656 return QL_STATUS_INVALID_PARAM;
3187 3657
3188 if (esw_cfg->host_vlan_tag == 1) 3658 switch (esw_cfg[i].op_mode) {
3659 case QLCNIC_PORT_DEFAULTS:
3660 if (QLC_DEV_GET_DRV(op_mode, pci_func) !=
3661 QLCNIC_NON_PRIV_FUNC) {
3662 if (esw_cfg[i].mac_anti_spoof != 0)
3663 return QL_STATUS_INVALID_PARAM;
3664 if (esw_cfg[i].mac_override != 1)
3665 return QL_STATUS_INVALID_PARAM;
3666 if (esw_cfg[i].promisc_mode != 1)
3667 return QL_STATUS_INVALID_PARAM;
3668 }
3669 break;
3670 case QLCNIC_ADD_VLAN:
3189 if (!IS_VALID_VLAN(esw_cfg[i].vlan_id)) 3671 if (!IS_VALID_VLAN(esw_cfg[i].vlan_id))
3190 return QL_STATUS_INVALID_PARAM; 3672 return QL_STATUS_INVALID_PARAM;
3191 3673 if (!esw_cfg[i].op_type)
3192 if (!IS_VALID_MODE(esw_cfg[i].promisc_mode) 3674 return QL_STATUS_INVALID_PARAM;
3193 || !IS_VALID_MODE(esw_cfg[i].host_vlan_tag) 3675 break;
3194 || !IS_VALID_MODE(esw_cfg[i].mac_learning) 3676 case QLCNIC_DEL_VLAN:
3195 || !IS_VALID_MODE(esw_cfg[i].discard_tagged)) 3677 if (!esw_cfg[i].op_type)
3678 return QL_STATUS_INVALID_PARAM;
3679 break;
3680 default:
3196 return QL_STATUS_INVALID_PARAM; 3681 return QL_STATUS_INVALID_PARAM;
3682 }
3197 } 3683 }
3198
3199 return 0; 3684 return 0;
3200} 3685}
3201 3686
@@ -3206,8 +3691,9 @@ qlcnic_sysfs_write_esw_config(struct file *file, struct kobject *kobj,
3206 struct device *dev = container_of(kobj, struct device, kobj); 3691 struct device *dev = container_of(kobj, struct device, kobj);
3207 struct qlcnic_adapter *adapter = dev_get_drvdata(dev); 3692 struct qlcnic_adapter *adapter = dev_get_drvdata(dev);
3208 struct qlcnic_esw_func_cfg *esw_cfg; 3693 struct qlcnic_esw_func_cfg *esw_cfg;
3694 struct qlcnic_npar_info *npar;
3209 int count, rem, i, ret; 3695 int count, rem, i, ret;
3210 u8 id, pci_func; 3696 u8 pci_func, op_mode = 0;
3211 3697
3212 count = size / sizeof(struct qlcnic_esw_func_cfg); 3698 count = size / sizeof(struct qlcnic_esw_func_cfg);
3213 rem = size % sizeof(struct qlcnic_esw_func_cfg); 3699 rem = size % sizeof(struct qlcnic_esw_func_cfg);
@@ -3220,30 +3706,55 @@ qlcnic_sysfs_write_esw_config(struct file *file, struct kobject *kobj,
3220 return ret; 3706 return ret;
3221 3707
3222 for (i = 0; i < count; i++) { 3708 for (i = 0; i < count; i++) {
3223 pci_func = esw_cfg[i].pci_func; 3709 if (adapter->op_mode == QLCNIC_MGMT_FUNC)
3224 id = adapter->npars[pci_func].phy_port; 3710 if (qlcnic_config_switch_port(adapter, &esw_cfg[i]))
3225 ret = qlcnic_config_switch_port(adapter, id, 3711 return QL_STATUS_INVALID_PARAM;
3226 esw_cfg[i].host_vlan_tag, 3712
3227 esw_cfg[i].discard_tagged, 3713 if (adapter->ahw->pci_func != esw_cfg[i].pci_func)
3228 esw_cfg[i].promisc_mode, 3714 continue;
3229 esw_cfg[i].mac_learning, 3715
3230 esw_cfg[i].pci_func, 3716 op_mode = esw_cfg[i].op_mode;
3231 esw_cfg[i].vlan_id); 3717 qlcnic_get_eswitch_port_config(adapter, &esw_cfg[i]);
3232 if (ret) 3718 esw_cfg[i].op_mode = op_mode;
3233 return ret; 3719 esw_cfg[i].pci_func = adapter->ahw->pci_func;
3720
3721 switch (esw_cfg[i].op_mode) {
3722 case QLCNIC_PORT_DEFAULTS:
3723 qlcnic_set_eswitch_port_features(adapter, &esw_cfg[i]);
3724 break;
3725 case QLCNIC_ADD_VLAN:
3726 qlcnic_set_vlan_config(adapter, &esw_cfg[i]);
3727 break;
3728 case QLCNIC_DEL_VLAN:
3729 esw_cfg[i].vlan_id = 0;
3730 qlcnic_set_vlan_config(adapter, &esw_cfg[i]);
3731 break;
3732 }
3234 } 3733 }
3235 3734
3735 if (adapter->op_mode != QLCNIC_MGMT_FUNC)
3736 goto out;
3737
3236 for (i = 0; i < count; i++) { 3738 for (i = 0; i < count; i++) {
3237 pci_func = esw_cfg[i].pci_func; 3739 pci_func = esw_cfg[i].pci_func;
3238 adapter->npars[pci_func].promisc_mode = esw_cfg[i].promisc_mode; 3740 npar = &adapter->npars[pci_func];
3239 adapter->npars[pci_func].mac_learning = esw_cfg[i].mac_learning; 3741 switch (esw_cfg[i].op_mode) {
3240 adapter->npars[pci_func].vlan_id = esw_cfg[i].vlan_id; 3742 case QLCNIC_PORT_DEFAULTS:
3241 adapter->npars[pci_func].discard_tagged = 3743 npar->promisc_mode = esw_cfg[i].promisc_mode;
3242 esw_cfg[i].discard_tagged; 3744 npar->mac_override = esw_cfg[i].mac_override;
3243 adapter->npars[pci_func].host_vlan_tag = 3745 npar->offload_flags = esw_cfg[i].offload_flags;
3244 esw_cfg[i].host_vlan_tag; 3746 npar->mac_anti_spoof = esw_cfg[i].mac_anti_spoof;
3747 npar->discard_tagged = esw_cfg[i].discard_tagged;
3748 break;
3749 case QLCNIC_ADD_VLAN:
3750 npar->pvid = esw_cfg[i].vlan_id;
3751 break;
3752 case QLCNIC_DEL_VLAN:
3753 npar->pvid = 0;
3754 break;
3755 }
3245 } 3756 }
3246 3757out:
3247 return size; 3758 return size;
3248} 3759}
3249 3760
@@ -3254,7 +3765,7 @@ qlcnic_sysfs_read_esw_config(struct file *file, struct kobject *kobj,
3254 struct device *dev = container_of(kobj, struct device, kobj); 3765 struct device *dev = container_of(kobj, struct device, kobj);
3255 struct qlcnic_adapter *adapter = dev_get_drvdata(dev); 3766 struct qlcnic_adapter *adapter = dev_get_drvdata(dev);
3256 struct qlcnic_esw_func_cfg esw_cfg[QLCNIC_MAX_PCI_FUNC]; 3767 struct qlcnic_esw_func_cfg esw_cfg[QLCNIC_MAX_PCI_FUNC];
3257 int i; 3768 u8 i;
3258 3769
3259 if (size != sizeof(esw_cfg)) 3770 if (size != sizeof(esw_cfg))
3260 return QL_STATUS_INVALID_PARAM; 3771 return QL_STATUS_INVALID_PARAM;
@@ -3262,12 +3773,9 @@ qlcnic_sysfs_read_esw_config(struct file *file, struct kobject *kobj,
3262 for (i = 0; i < QLCNIC_MAX_PCI_FUNC; i++) { 3773 for (i = 0; i < QLCNIC_MAX_PCI_FUNC; i++) {
3263 if (adapter->npars[i].type != QLCNIC_TYPE_NIC) 3774 if (adapter->npars[i].type != QLCNIC_TYPE_NIC)
3264 continue; 3775 continue;
3265 3776 esw_cfg[i].pci_func = i;
3266 esw_cfg[i].host_vlan_tag = adapter->npars[i].host_vlan_tag; 3777 if (qlcnic_get_eswitch_port_config(adapter, &esw_cfg[i]))
3267 esw_cfg[i].promisc_mode = adapter->npars[i].promisc_mode; 3778 return QL_STATUS_INVALID_PARAM;
3268 esw_cfg[i].discard_tagged = adapter->npars[i].discard_tagged;
3269 esw_cfg[i].vlan_id = adapter->npars[i].vlan_id;
3270 esw_cfg[i].mac_learning = adapter->npars[i].mac_learning;
3271 } 3779 }
3272 memcpy(buf, &esw_cfg, size); 3780 memcpy(buf, &esw_cfg, size);
3273 3781
@@ -3288,10 +3796,8 @@ validate_npar_config(struct qlcnic_adapter *adapter,
3288 if (adapter->npars[pci_func].type != QLCNIC_TYPE_NIC) 3796 if (adapter->npars[pci_func].type != QLCNIC_TYPE_NIC)
3289 return QL_STATUS_INVALID_PARAM; 3797 return QL_STATUS_INVALID_PARAM;
3290 3798
3291 if (!IS_VALID_BW(np_cfg[i].min_bw) 3799 if (!IS_VALID_BW(np_cfg[i].min_bw) ||
3292 || !IS_VALID_BW(np_cfg[i].max_bw) 3800 !IS_VALID_BW(np_cfg[i].max_bw))
3293 || !IS_VALID_RX_QUEUES(np_cfg[i].max_rx_queues)
3294 || !IS_VALID_TX_QUEUES(np_cfg[i].max_tx_queues))
3295 return QL_STATUS_INVALID_PARAM; 3801 return QL_STATUS_INVALID_PARAM;
3296 } 3802 }
3297 return 0; 3803 return 0;
@@ -3357,7 +3863,7 @@ qlcnic_sysfs_read_npar_config(struct file *file, struct kobject *kobj,
3357 return ret; 3863 return ret;
3358 3864
3359 np_cfg[i].pci_func = i; 3865 np_cfg[i].pci_func = i;
3360 np_cfg[i].op_mode = nic_info.op_mode; 3866 np_cfg[i].op_mode = (u8)nic_info.op_mode;
3361 np_cfg[i].port_num = nic_info.phys_port; 3867 np_cfg[i].port_num = nic_info.phys_port;
3362 np_cfg[i].fw_capab = nic_info.capabilities; 3868 np_cfg[i].fw_capab = nic_info.capabilities;
3363 np_cfg[i].min_bw = nic_info.min_tx_bw ; 3869 np_cfg[i].min_bw = nic_info.min_tx_bw ;
@@ -3370,6 +3876,115 @@ qlcnic_sysfs_read_npar_config(struct file *file, struct kobject *kobj,
3370} 3876}
3371 3877
3372static ssize_t 3878static ssize_t
3879qlcnic_sysfs_get_port_stats(struct file *file, struct kobject *kobj,
3880 struct bin_attribute *attr, char *buf, loff_t offset, size_t size)
3881{
3882 struct device *dev = container_of(kobj, struct device, kobj);
3883 struct qlcnic_adapter *adapter = dev_get_drvdata(dev);
3884 struct qlcnic_esw_statistics port_stats;
3885 int ret;
3886
3887 if (size != sizeof(struct qlcnic_esw_statistics))
3888 return QL_STATUS_INVALID_PARAM;
3889
3890 if (offset >= QLCNIC_MAX_PCI_FUNC)
3891 return QL_STATUS_INVALID_PARAM;
3892
3893 memset(&port_stats, 0, size);
3894 ret = qlcnic_get_port_stats(adapter, offset, QLCNIC_QUERY_RX_COUNTER,
3895 &port_stats.rx);
3896 if (ret)
3897 return ret;
3898
3899 ret = qlcnic_get_port_stats(adapter, offset, QLCNIC_QUERY_TX_COUNTER,
3900 &port_stats.tx);
3901 if (ret)
3902 return ret;
3903
3904 memcpy(buf, &port_stats, size);
3905 return size;
3906}
3907
3908static ssize_t
3909qlcnic_sysfs_get_esw_stats(struct file *file, struct kobject *kobj,
3910 struct bin_attribute *attr, char *buf, loff_t offset, size_t size)
3911{
3912 struct device *dev = container_of(kobj, struct device, kobj);
3913 struct qlcnic_adapter *adapter = dev_get_drvdata(dev);
3914 struct qlcnic_esw_statistics esw_stats;
3915 int ret;
3916
3917 if (size != sizeof(struct qlcnic_esw_statistics))
3918 return QL_STATUS_INVALID_PARAM;
3919
3920 if (offset >= QLCNIC_NIU_MAX_XG_PORTS)
3921 return QL_STATUS_INVALID_PARAM;
3922
3923 memset(&esw_stats, 0, size);
3924 ret = qlcnic_get_eswitch_stats(adapter, offset, QLCNIC_QUERY_RX_COUNTER,
3925 &esw_stats.rx);
3926 if (ret)
3927 return ret;
3928
3929 ret = qlcnic_get_eswitch_stats(adapter, offset, QLCNIC_QUERY_TX_COUNTER,
3930 &esw_stats.tx);
3931 if (ret)
3932 return ret;
3933
3934 memcpy(buf, &esw_stats, size);
3935 return size;
3936}
3937
3938static ssize_t
3939qlcnic_sysfs_clear_esw_stats(struct file *file, struct kobject *kobj,
3940 struct bin_attribute *attr, char *buf, loff_t offset, size_t size)
3941{
3942 struct device *dev = container_of(kobj, struct device, kobj);
3943 struct qlcnic_adapter *adapter = dev_get_drvdata(dev);
3944 int ret;
3945
3946 if (offset >= QLCNIC_NIU_MAX_XG_PORTS)
3947 return QL_STATUS_INVALID_PARAM;
3948
3949 ret = qlcnic_clear_esw_stats(adapter, QLCNIC_STATS_ESWITCH, offset,
3950 QLCNIC_QUERY_RX_COUNTER);
3951 if (ret)
3952 return ret;
3953
3954 ret = qlcnic_clear_esw_stats(adapter, QLCNIC_STATS_ESWITCH, offset,
3955 QLCNIC_QUERY_TX_COUNTER);
3956 if (ret)
3957 return ret;
3958
3959 return size;
3960}
3961
3962static ssize_t
3963qlcnic_sysfs_clear_port_stats(struct file *file, struct kobject *kobj,
3964 struct bin_attribute *attr, char *buf, loff_t offset, size_t size)
3965{
3966
3967 struct device *dev = container_of(kobj, struct device, kobj);
3968 struct qlcnic_adapter *adapter = dev_get_drvdata(dev);
3969 int ret;
3970
3971 if (offset >= QLCNIC_MAX_PCI_FUNC)
3972 return QL_STATUS_INVALID_PARAM;
3973
3974 ret = qlcnic_clear_esw_stats(adapter, QLCNIC_STATS_PORT, offset,
3975 QLCNIC_QUERY_RX_COUNTER);
3976 if (ret)
3977 return ret;
3978
3979 ret = qlcnic_clear_esw_stats(adapter, QLCNIC_STATS_PORT, offset,
3980 QLCNIC_QUERY_TX_COUNTER);
3981 if (ret)
3982 return ret;
3983
3984 return size;
3985}
3986
3987static ssize_t
3373qlcnic_sysfs_read_pci_config(struct file *file, struct kobject *kobj, 3988qlcnic_sysfs_read_pci_config(struct file *file, struct kobject *kobj,
3374 struct bin_attribute *attr, char *buf, loff_t offset, size_t size) 3989 struct bin_attribute *attr, char *buf, loff_t offset, size_t size)
3375{ 3990{
@@ -3418,6 +4033,20 @@ static struct bin_attribute bin_attr_pci_config = {
3418 .write = NULL, 4033 .write = NULL,
3419}; 4034};
3420 4035
4036static struct bin_attribute bin_attr_port_stats = {
4037 .attr = {.name = "port_stats", .mode = (S_IRUGO | S_IWUSR)},
4038 .size = 0,
4039 .read = qlcnic_sysfs_get_port_stats,
4040 .write = qlcnic_sysfs_clear_port_stats,
4041};
4042
4043static struct bin_attribute bin_attr_esw_stats = {
4044 .attr = {.name = "esw_stats", .mode = (S_IRUGO | S_IWUSR)},
4045 .size = 0,
4046 .read = qlcnic_sysfs_get_esw_stats,
4047 .write = qlcnic_sysfs_clear_esw_stats,
4048};
4049
3421static struct bin_attribute bin_attr_esw_config = { 4050static struct bin_attribute bin_attr_esw_config = {
3422 .attr = {.name = "esw_config", .mode = (S_IRUGO | S_IWUSR)}, 4051 .attr = {.name = "esw_config", .mode = (S_IRUGO | S_IWUSR)},
3423 .size = 0, 4052 .size = 0,
@@ -3457,6 +4086,9 @@ qlcnic_create_diag_entries(struct qlcnic_adapter *adapter)
3457{ 4086{
3458 struct device *dev = &adapter->pdev->dev; 4087 struct device *dev = &adapter->pdev->dev;
3459 4088
4089 if (device_create_bin_file(dev, &bin_attr_port_stats))
4090 dev_info(dev, "failed to create port stats sysfs entry");
4091
3460 if (adapter->op_mode == QLCNIC_NON_PRIV_FUNC) 4092 if (adapter->op_mode == QLCNIC_NON_PRIV_FUNC)
3461 return; 4093 return;
3462 if (device_create_file(dev, &dev_attr_diag_mode)) 4094 if (device_create_file(dev, &dev_attr_diag_mode))
@@ -3465,18 +4097,20 @@ qlcnic_create_diag_entries(struct qlcnic_adapter *adapter)
3465 dev_info(dev, "failed to create crb sysfs entry\n"); 4097 dev_info(dev, "failed to create crb sysfs entry\n");
3466 if (device_create_bin_file(dev, &bin_attr_mem)) 4098 if (device_create_bin_file(dev, &bin_attr_mem))
3467 dev_info(dev, "failed to create mem sysfs entry\n"); 4099 dev_info(dev, "failed to create mem sysfs entry\n");
3468 if (!(adapter->flags & QLCNIC_ESWITCH_ENABLED) ||
3469 adapter->op_mode != QLCNIC_MGMT_FUNC)
3470 return;
3471 if (device_create_bin_file(dev, &bin_attr_pci_config)) 4100 if (device_create_bin_file(dev, &bin_attr_pci_config))
3472 dev_info(dev, "failed to create pci config sysfs entry"); 4101 dev_info(dev, "failed to create pci config sysfs entry");
3473 if (device_create_bin_file(dev, &bin_attr_npar_config)) 4102 if (!(adapter->flags & QLCNIC_ESWITCH_ENABLED))
3474 dev_info(dev, "failed to create npar config sysfs entry"); 4103 return;
3475 if (device_create_bin_file(dev, &bin_attr_esw_config)) 4104 if (device_create_bin_file(dev, &bin_attr_esw_config))
3476 dev_info(dev, "failed to create esw config sysfs entry"); 4105 dev_info(dev, "failed to create esw config sysfs entry");
4106 if (adapter->op_mode != QLCNIC_MGMT_FUNC)
4107 return;
4108 if (device_create_bin_file(dev, &bin_attr_npar_config))
4109 dev_info(dev, "failed to create npar config sysfs entry");
3477 if (device_create_bin_file(dev, &bin_attr_pm_config)) 4110 if (device_create_bin_file(dev, &bin_attr_pm_config))
3478 dev_info(dev, "failed to create pm config sysfs entry"); 4111 dev_info(dev, "failed to create pm config sysfs entry");
3479 4112 if (device_create_bin_file(dev, &bin_attr_esw_stats))
4113 dev_info(dev, "failed to create eswitch stats sysfs entry");
3480} 4114}
3481 4115
3482static void 4116static void
@@ -3484,18 +4118,22 @@ qlcnic_remove_diag_entries(struct qlcnic_adapter *adapter)
3484{ 4118{
3485 struct device *dev = &adapter->pdev->dev; 4119 struct device *dev = &adapter->pdev->dev;
3486 4120
4121 device_remove_bin_file(dev, &bin_attr_port_stats);
4122
3487 if (adapter->op_mode == QLCNIC_NON_PRIV_FUNC) 4123 if (adapter->op_mode == QLCNIC_NON_PRIV_FUNC)
3488 return; 4124 return;
3489 device_remove_file(dev, &dev_attr_diag_mode); 4125 device_remove_file(dev, &dev_attr_diag_mode);
3490 device_remove_bin_file(dev, &bin_attr_crb); 4126 device_remove_bin_file(dev, &bin_attr_crb);
3491 device_remove_bin_file(dev, &bin_attr_mem); 4127 device_remove_bin_file(dev, &bin_attr_mem);
3492 if (!(adapter->flags & QLCNIC_ESWITCH_ENABLED) ||
3493 adapter->op_mode != QLCNIC_MGMT_FUNC)
3494 return;
3495 device_remove_bin_file(dev, &bin_attr_pci_config); 4128 device_remove_bin_file(dev, &bin_attr_pci_config);
3496 device_remove_bin_file(dev, &bin_attr_npar_config); 4129 if (!(adapter->flags & QLCNIC_ESWITCH_ENABLED))
4130 return;
3497 device_remove_bin_file(dev, &bin_attr_esw_config); 4131 device_remove_bin_file(dev, &bin_attr_esw_config);
4132 if (adapter->op_mode != QLCNIC_MGMT_FUNC)
4133 return;
4134 device_remove_bin_file(dev, &bin_attr_npar_config);
3498 device_remove_bin_file(dev, &bin_attr_pm_config); 4135 device_remove_bin_file(dev, &bin_attr_pm_config);
4136 device_remove_bin_file(dev, &bin_attr_esw_stats);
3499} 4137}
3500 4138
3501#ifdef CONFIG_INET 4139#ifdef CONFIG_INET
@@ -3503,10 +4141,10 @@ qlcnic_remove_diag_entries(struct qlcnic_adapter *adapter)
3503#define is_qlcnic_netdev(dev) (dev->netdev_ops == &qlcnic_netdev_ops) 4141#define is_qlcnic_netdev(dev) (dev->netdev_ops == &qlcnic_netdev_ops)
3504 4142
3505static void 4143static void
3506qlcnic_config_indev_addr(struct net_device *dev, unsigned long event) 4144qlcnic_config_indev_addr(struct qlcnic_adapter *adapter,
4145 struct net_device *dev, unsigned long event)
3507{ 4146{
3508 struct in_device *indev; 4147 struct in_device *indev;
3509 struct qlcnic_adapter *adapter = netdev_priv(dev);
3510 4148
3511 indev = in_dev_get(dev); 4149 indev = in_dev_get(dev);
3512 if (!indev) 4150 if (!indev)
@@ -3530,6 +4168,23 @@ qlcnic_config_indev_addr(struct net_device *dev, unsigned long event)
3530 in_dev_put(indev); 4168 in_dev_put(indev);
3531} 4169}
3532 4170
4171static void
4172qlcnic_restore_indev_addr(struct net_device *netdev, unsigned long event)
4173{
4174 struct qlcnic_adapter *adapter = netdev_priv(netdev);
4175 struct net_device *dev;
4176 u16 vid;
4177
4178 qlcnic_config_indev_addr(adapter, netdev, event);
4179
4180 for_each_set_bit(vid, adapter->vlans, VLAN_N_VID) {
4181 dev = vlan_find_dev(netdev, vid);
4182 if (!dev)
4183 continue;
4184 qlcnic_config_indev_addr(adapter, dev, event);
4185 }
4186}
4187
3533static int qlcnic_netdev_event(struct notifier_block *this, 4188static int qlcnic_netdev_event(struct notifier_block *this,
3534 unsigned long event, void *ptr) 4189 unsigned long event, void *ptr)
3535{ 4190{
@@ -3556,7 +4211,7 @@ recheck:
3556 if (!test_bit(__QLCNIC_DEV_UP, &adapter->state)) 4211 if (!test_bit(__QLCNIC_DEV_UP, &adapter->state))
3557 goto done; 4212 goto done;
3558 4213
3559 qlcnic_config_indev_addr(dev, event); 4214 qlcnic_config_indev_addr(adapter, dev, event);
3560done: 4215done:
3561 return NOTIFY_DONE; 4216 return NOTIFY_DONE;
3562} 4217}
@@ -3573,7 +4228,7 @@ qlcnic_inetaddr_event(struct notifier_block *this,
3573 dev = ifa->ifa_dev ? ifa->ifa_dev->dev : NULL; 4228 dev = ifa->ifa_dev ? ifa->ifa_dev->dev : NULL;
3574 4229
3575recheck: 4230recheck:
3576 if (dev == NULL || !netif_running(dev)) 4231 if (dev == NULL)
3577 goto done; 4232 goto done;
3578 4233
3579 if (dev->priv_flags & IFF_802_1Q_VLAN) { 4234 if (dev->priv_flags & IFF_802_1Q_VLAN) {
@@ -3616,7 +4271,7 @@ static struct notifier_block qlcnic_inetaddr_cb = {
3616}; 4271};
3617#else 4272#else
3618static void 4273static void
3619qlcnic_config_indev_addr(struct net_device *dev, unsigned long event) 4274qlcnic_restore_indev_addr(struct net_device *dev, unsigned long event)
3620{ } 4275{ }
3621#endif 4276#endif
3622static struct pci_error_handlers qlcnic_err_handler = { 4277static struct pci_error_handlers qlcnic_err_handler = {
@@ -3645,6 +4300,12 @@ static int __init qlcnic_init_module(void)
3645 4300
3646 printk(KERN_INFO "%s\n", qlcnic_driver_string); 4301 printk(KERN_INFO "%s\n", qlcnic_driver_string);
3647 4302
4303 qlcnic_wq = create_singlethread_workqueue("qlcnic");
4304 if (qlcnic_wq == NULL) {
4305 printk(KERN_ERR "qlcnic: cannot create workqueue\n");
4306 return -ENOMEM;
4307 }
4308
3648#ifdef CONFIG_INET 4309#ifdef CONFIG_INET
3649 register_netdevice_notifier(&qlcnic_netdev_cb); 4310 register_netdevice_notifier(&qlcnic_netdev_cb);
3650 register_inetaddr_notifier(&qlcnic_inetaddr_cb); 4311 register_inetaddr_notifier(&qlcnic_inetaddr_cb);
@@ -3656,6 +4317,7 @@ static int __init qlcnic_init_module(void)
3656 unregister_inetaddr_notifier(&qlcnic_inetaddr_cb); 4317 unregister_inetaddr_notifier(&qlcnic_inetaddr_cb);
3657 unregister_netdevice_notifier(&qlcnic_netdev_cb); 4318 unregister_netdevice_notifier(&qlcnic_netdev_cb);
3658#endif 4319#endif
4320 destroy_workqueue(qlcnic_wq);
3659 } 4321 }
3660 4322
3661 return ret; 4323 return ret;
@@ -3672,6 +4334,7 @@ static void __exit qlcnic_exit_module(void)
3672 unregister_inetaddr_notifier(&qlcnic_inetaddr_cb); 4334 unregister_inetaddr_notifier(&qlcnic_inetaddr_cb);
3673 unregister_netdevice_notifier(&qlcnic_netdev_cb); 4335 unregister_netdevice_notifier(&qlcnic_netdev_cb);
3674#endif 4336#endif
4337 destroy_workqueue(qlcnic_wq);
3675} 4338}
3676 4339
3677module_exit(qlcnic_exit_module); 4340module_exit(qlcnic_exit_module);