2 * Copyright (C) 2003 - 2009 NetXen, Inc.
3 * Copyright (C) 2009 - QLogic Corporation.
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
21 * The full GNU General Public License is included in this distribution
22 * in the file called "COPYING".
26 #include <linux/slab.h>
27 #include <linux/vmalloc.h>
28 #include <linux/interrupt.h>
29 #include "netxen_nic_hw.h"
31 #include "netxen_nic.h"
33 #include <linux/dma-mapping.h>
34 #include <linux/if_vlan.h>
36 #include <linux/ipv6.h>
37 #include <linux/inetdevice.h>
38 #include <linux/sysfs.h>
39 #include <linux/aer.h>
41 MODULE_DESCRIPTION("QLogic/NetXen (1/10) GbE Intelligent Ethernet Driver");
42 MODULE_LICENSE("GPL");
43 MODULE_VERSION(NETXEN_NIC_LINUX_VERSIONID);
44 MODULE_FIRMWARE(NX_UNIFIED_ROMIMAGE_NAME);
46 char netxen_nic_driver_name[] = "netxen_nic";
47 static char netxen_nic_driver_string[] = "QLogic/NetXen Network Driver v"
48 NETXEN_NIC_LINUX_VERSIONID;
50 static int port_mode = NETXEN_PORT_MODE_AUTO_NEG;
52 /* Default to restricted 1G auto-neg mode */
53 static int wol_port_mode = 5;
55 static int use_msi = 1;
57 static int use_msi_x = 1;
59 static int auto_fw_reset = AUTO_FW_RESET_ENABLED;
60 module_param(auto_fw_reset, int, 0644);
61 MODULE_PARM_DESC(auto_fw_reset,"Auto firmware reset (0=disabled, 1=enabled");
63 static int __devinit netxen_nic_probe(struct pci_dev *pdev,
64 const struct pci_device_id *ent);
65 static void __devexit netxen_nic_remove(struct pci_dev *pdev);
66 static int netxen_nic_open(struct net_device *netdev);
67 static int netxen_nic_close(struct net_device *netdev);
68 static netdev_tx_t netxen_nic_xmit_frame(struct sk_buff *,
70 static void netxen_tx_timeout(struct net_device *netdev);
71 static void netxen_tx_timeout_task(struct work_struct *work);
72 static void netxen_fw_poll_work(struct work_struct *work);
73 static void netxen_schedule_work(struct netxen_adapter *adapter,
74 work_func_t func, int delay);
75 static void netxen_cancel_fw_work(struct netxen_adapter *adapter);
76 static int netxen_nic_poll(struct napi_struct *napi, int budget);
77 #ifdef CONFIG_NET_POLL_CONTROLLER
78 static void netxen_nic_poll_controller(struct net_device *netdev);
81 static void netxen_create_sysfs_entries(struct netxen_adapter *adapter);
82 static void netxen_remove_sysfs_entries(struct netxen_adapter *adapter);
83 static void netxen_create_diag_entries(struct netxen_adapter *adapter);
84 static void netxen_remove_diag_entries(struct netxen_adapter *adapter);
85 static int nx_dev_request_aer(struct netxen_adapter *adapter);
86 static int nx_decr_dev_ref_cnt(struct netxen_adapter *adapter);
87 static int netxen_can_start_firmware(struct netxen_adapter *adapter);
89 static irqreturn_t netxen_intr(int irq, void *data);
90 static irqreturn_t netxen_msi_intr(int irq, void *data);
91 static irqreturn_t netxen_msix_intr(int irq, void *data);
93 static void netxen_free_vlan_ip_list(struct netxen_adapter *);
94 static void netxen_restore_indev_addr(struct net_device *dev, unsigned long);
95 static struct rtnl_link_stats64 *netxen_nic_get_stats(struct net_device *dev,
96 struct rtnl_link_stats64 *stats);
97 static int netxen_nic_set_mac(struct net_device *netdev, void *p);
99 /* PCI Device ID Table */
100 #define ENTRY(device) \
101 {PCI_DEVICE(PCI_VENDOR_ID_NETXEN, (device)), \
102 .class = PCI_CLASS_NETWORK_ETHERNET << 8, .class_mask = ~0}
104 static DEFINE_PCI_DEVICE_TABLE(netxen_pci_tbl) = {
105 ENTRY(PCI_DEVICE_ID_NX2031_10GXSR),
106 ENTRY(PCI_DEVICE_ID_NX2031_10GCX4),
107 ENTRY(PCI_DEVICE_ID_NX2031_4GCU),
108 ENTRY(PCI_DEVICE_ID_NX2031_IMEZ),
109 ENTRY(PCI_DEVICE_ID_NX2031_HMEZ),
110 ENTRY(PCI_DEVICE_ID_NX2031_XG_MGMT),
111 ENTRY(PCI_DEVICE_ID_NX2031_XG_MGMT2),
112 ENTRY(PCI_DEVICE_ID_NX3031),
116 MODULE_DEVICE_TABLE(pci, netxen_pci_tbl);
118 static uint32_t crb_cmd_producer[4] = {
119 CRB_CMD_PRODUCER_OFFSET, CRB_CMD_PRODUCER_OFFSET_1,
120 CRB_CMD_PRODUCER_OFFSET_2, CRB_CMD_PRODUCER_OFFSET_3
124 netxen_nic_update_cmd_producer(struct netxen_adapter *adapter,
125 struct nx_host_tx_ring *tx_ring)
127 NXWRIO(adapter, tx_ring->crb_cmd_producer, tx_ring->producer);
130 static uint32_t crb_cmd_consumer[4] = {
131 CRB_CMD_CONSUMER_OFFSET, CRB_CMD_CONSUMER_OFFSET_1,
132 CRB_CMD_CONSUMER_OFFSET_2, CRB_CMD_CONSUMER_OFFSET_3
136 netxen_nic_update_cmd_consumer(struct netxen_adapter *adapter,
137 struct nx_host_tx_ring *tx_ring)
139 NXWRIO(adapter, tx_ring->crb_cmd_consumer, tx_ring->sw_consumer);
142 static uint32_t msi_tgt_status[8] = {
143 ISR_INT_TARGET_STATUS, ISR_INT_TARGET_STATUS_F1,
144 ISR_INT_TARGET_STATUS_F2, ISR_INT_TARGET_STATUS_F3,
145 ISR_INT_TARGET_STATUS_F4, ISR_INT_TARGET_STATUS_F5,
146 ISR_INT_TARGET_STATUS_F6, ISR_INT_TARGET_STATUS_F7
149 static struct netxen_legacy_intr_set legacy_intr[] = NX_LEGACY_INTR_CONFIG;
151 static inline void netxen_nic_disable_int(struct nx_host_sds_ring *sds_ring)
153 struct netxen_adapter *adapter = sds_ring->adapter;
155 NXWRIO(adapter, sds_ring->crb_intr_mask, 0);
158 static inline void netxen_nic_enable_int(struct nx_host_sds_ring *sds_ring)
160 struct netxen_adapter *adapter = sds_ring->adapter;
162 NXWRIO(adapter, sds_ring->crb_intr_mask, 0x1);
164 if (!NETXEN_IS_MSI_FAMILY(adapter))
165 NXWRIO(adapter, adapter->tgt_mask_reg, 0xfbff);
169 netxen_alloc_sds_rings(struct netxen_recv_context *recv_ctx, int count)
171 int size = sizeof(struct nx_host_sds_ring) * count;
173 recv_ctx->sds_rings = kzalloc(size, GFP_KERNEL);
175 return recv_ctx->sds_rings == NULL;
179 netxen_free_sds_rings(struct netxen_recv_context *recv_ctx)
181 if (recv_ctx->sds_rings != NULL)
182 kfree(recv_ctx->sds_rings);
184 recv_ctx->sds_rings = NULL;
188 netxen_napi_add(struct netxen_adapter *adapter, struct net_device *netdev)
191 struct nx_host_sds_ring *sds_ring;
192 struct netxen_recv_context *recv_ctx = &adapter->recv_ctx;
194 if (netxen_alloc_sds_rings(recv_ctx, adapter->max_sds_rings))
197 for (ring = 0; ring < adapter->max_sds_rings; ring++) {
198 sds_ring = &recv_ctx->sds_rings[ring];
199 netif_napi_add(netdev, &sds_ring->napi,
200 netxen_nic_poll, NETXEN_NETDEV_WEIGHT);
207 netxen_napi_del(struct netxen_adapter *adapter)
210 struct nx_host_sds_ring *sds_ring;
211 struct netxen_recv_context *recv_ctx = &adapter->recv_ctx;
213 for (ring = 0; ring < adapter->max_sds_rings; ring++) {
214 sds_ring = &recv_ctx->sds_rings[ring];
215 netif_napi_del(&sds_ring->napi);
218 netxen_free_sds_rings(&adapter->recv_ctx);
222 netxen_napi_enable(struct netxen_adapter *adapter)
225 struct nx_host_sds_ring *sds_ring;
226 struct netxen_recv_context *recv_ctx = &adapter->recv_ctx;
228 for (ring = 0; ring < adapter->max_sds_rings; ring++) {
229 sds_ring = &recv_ctx->sds_rings[ring];
230 napi_enable(&sds_ring->napi);
231 netxen_nic_enable_int(sds_ring);
236 netxen_napi_disable(struct netxen_adapter *adapter)
239 struct nx_host_sds_ring *sds_ring;
240 struct netxen_recv_context *recv_ctx = &adapter->recv_ctx;
242 for (ring = 0; ring < adapter->max_sds_rings; ring++) {
243 sds_ring = &recv_ctx->sds_rings[ring];
244 netxen_nic_disable_int(sds_ring);
245 napi_synchronize(&sds_ring->napi);
246 napi_disable(&sds_ring->napi);
250 static int nx_set_dma_mask(struct netxen_adapter *adapter)
252 struct pci_dev *pdev = adapter->pdev;
253 uint64_t mask, cmask;
255 adapter->pci_using_dac = 0;
257 mask = DMA_BIT_MASK(32);
258 cmask = DMA_BIT_MASK(32);
260 if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) {
262 mask = DMA_BIT_MASK(35);
265 mask = DMA_BIT_MASK(39);
269 if (pci_set_dma_mask(pdev, mask) == 0 &&
270 pci_set_consistent_dma_mask(pdev, cmask) == 0) {
271 adapter->pci_using_dac = 1;
278 /* Update addressable range if firmware supports it */
280 nx_update_dma_mask(struct netxen_adapter *adapter)
282 int change, shift, err;
283 uint64_t mask, old_mask, old_cmask;
284 struct pci_dev *pdev = adapter->pdev;
288 shift = NXRD32(adapter, CRB_DMA_SHIFT);
292 if (NX_IS_REVISION_P3(adapter->ahw.revision_id) && (shift > 9))
294 else if ((adapter->ahw.revision_id == NX_P2_C1) && (shift <= 4))
298 old_mask = pdev->dma_mask;
299 old_cmask = pdev->dev.coherent_dma_mask;
301 mask = DMA_BIT_MASK(32+shift);
303 err = pci_set_dma_mask(pdev, mask);
307 if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) {
309 err = pci_set_consistent_dma_mask(pdev, mask);
313 dev_info(&pdev->dev, "using %d-bit dma mask\n", 32+shift);
319 pci_set_dma_mask(pdev, old_mask);
320 pci_set_consistent_dma_mask(pdev, old_cmask);
325 netxen_check_hw_init(struct netxen_adapter *adapter, int first_boot)
329 if (first_boot == 0x55555555) {
330 /* This is the first boot after power up */
331 NXWR32(adapter, NETXEN_CAM_RAM(0x1fc), NETXEN_BDINFO_MAGIC);
333 if (!NX_IS_REVISION_P2(adapter->ahw.revision_id))
336 /* PCI bus master workaround */
337 first_boot = NXRD32(adapter, NETXEN_PCIE_REG(0x4));
338 if (!(first_boot & 0x4)) {
340 NXWR32(adapter, NETXEN_PCIE_REG(0x4), first_boot);
341 NXRD32(adapter, NETXEN_PCIE_REG(0x4));
344 /* This is the first boot after power up */
345 first_boot = NXRD32(adapter, NETXEN_ROMUSB_GLB_SW_RESET);
346 if (first_boot != 0x80000f) {
347 /* clear the register for future unloads/loads */
348 NXWR32(adapter, NETXEN_CAM_RAM(0x1fc), 0);
352 /* Start P2 boot loader */
353 val = NXRD32(adapter, NETXEN_ROMUSB_GLB_PEGTUNE_DONE);
354 NXWR32(adapter, NETXEN_ROMUSB_GLB_PEGTUNE_DONE, val | 0x1);
358 val = NXRD32(adapter, NETXEN_CAM_RAM(0x1fc));
360 if (++timeout > 5000)
363 } while (val == NETXEN_BDINFO_MAGIC);
368 static void netxen_set_port_mode(struct netxen_adapter *adapter)
372 val = adapter->ahw.board_type;
373 if ((val == NETXEN_BRDTYPE_P3_HMEZ) ||
374 (val == NETXEN_BRDTYPE_P3_XG_LOM)) {
375 if (port_mode == NETXEN_PORT_MODE_802_3_AP) {
376 data = NETXEN_PORT_MODE_802_3_AP;
377 NXWR32(adapter, NETXEN_PORT_MODE_ADDR, data);
378 } else if (port_mode == NETXEN_PORT_MODE_XG) {
379 data = NETXEN_PORT_MODE_XG;
380 NXWR32(adapter, NETXEN_PORT_MODE_ADDR, data);
381 } else if (port_mode == NETXEN_PORT_MODE_AUTO_NEG_1G) {
382 data = NETXEN_PORT_MODE_AUTO_NEG_1G;
383 NXWR32(adapter, NETXEN_PORT_MODE_ADDR, data);
384 } else if (port_mode == NETXEN_PORT_MODE_AUTO_NEG_XG) {
385 data = NETXEN_PORT_MODE_AUTO_NEG_XG;
386 NXWR32(adapter, NETXEN_PORT_MODE_ADDR, data);
388 data = NETXEN_PORT_MODE_AUTO_NEG;
389 NXWR32(adapter, NETXEN_PORT_MODE_ADDR, data);
392 if ((wol_port_mode != NETXEN_PORT_MODE_802_3_AP) &&
393 (wol_port_mode != NETXEN_PORT_MODE_XG) &&
394 (wol_port_mode != NETXEN_PORT_MODE_AUTO_NEG_1G) &&
395 (wol_port_mode != NETXEN_PORT_MODE_AUTO_NEG_XG)) {
396 wol_port_mode = NETXEN_PORT_MODE_AUTO_NEG;
398 NXWR32(adapter, NETXEN_WOL_PORT_MODE, wol_port_mode);
402 #define PCI_CAP_ID_GEN 0x10
404 static void netxen_pcie_strap_init(struct netxen_adapter *adapter)
411 struct pci_dev *pdev;
413 pdev = adapter->pdev;
415 chicken = NXRD32(adapter, NETXEN_PCIE_REG(PCIE_CHICKEN3));
416 /* clear chicken3.25:24 */
417 chicken &= 0xFCFFFFFF;
419 * if gen1 and B0, set F1020 - if gen 2, do nothing
420 * if gen2 set to F1000
422 pos = pci_find_capability(pdev, PCI_CAP_ID_GEN);
424 pci_read_config_dword(pdev, pos + 0x10, &control);
425 if ((control & 0x000F0000) != 0x00020000) {
426 /* set chicken3.24 if gen1 */
427 chicken |= 0x01000000;
429 dev_info(&adapter->pdev->dev, "Gen2 strapping detected\n");
432 /* set chicken3.24 if gen1 */
433 chicken |= 0x01000000;
434 dev_info(&adapter->pdev->dev, "Gen1 strapping detected\n");
435 if (adapter->ahw.revision_id == NX_P3_B0)
441 NXWR32(adapter, NETXEN_PCIE_REG(PCIE_CHICKEN3), chicken);
446 pdevfuncsave = pdev->devfn;
447 if (pdevfuncsave & 0x07)
450 for (i = 0; i < 8; i++) {
451 pci_read_config_dword(pdev, pos + 8, &control);
452 pci_read_config_dword(pdev, pos + 8, &control);
453 pci_write_config_dword(pdev, pos + 8, c8c9value);
456 pdev->devfn = pdevfuncsave;
459 static void netxen_set_msix_bit(struct pci_dev *pdev, int enable)
464 pos = pci_find_capability(pdev, PCI_CAP_ID_MSIX);
466 pci_read_config_dword(pdev, pos, &control);
468 control |= PCI_MSIX_FLAGS_ENABLE;
471 pci_write_config_dword(pdev, pos, control);
475 static void netxen_init_msix_entries(struct netxen_adapter *adapter, int count)
479 for (i = 0; i < count; i++)
480 adapter->msix_entries[i].entry = i;
484 netxen_read_mac_addr(struct netxen_adapter *adapter)
489 struct net_device *netdev = adapter->netdev;
490 struct pci_dev *pdev = adapter->pdev;
492 if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) {
493 if (netxen_p3_get_mac_addr(adapter, &mac_addr) != 0)
496 if (netxen_get_flash_mac_addr(adapter, &mac_addr) != 0)
500 p = (unsigned char *)&mac_addr;
501 for (i = 0; i < 6; i++)
502 netdev->dev_addr[i] = *(p + 5 - i);
504 memcpy(netdev->perm_addr, netdev->dev_addr, netdev->addr_len);
505 memcpy(adapter->mac_addr, netdev->dev_addr, netdev->addr_len);
507 /* set station address */
509 if (!is_valid_ether_addr(netdev->perm_addr))
510 dev_warn(&pdev->dev, "Bad MAC address %pM.\n", netdev->dev_addr);
515 static int netxen_nic_set_mac(struct net_device *netdev, void *p)
517 struct netxen_adapter *adapter = netdev_priv(netdev);
518 struct sockaddr *addr = p;
520 if (!is_valid_ether_addr(addr->sa_data))
521 return -EADDRNOTAVAIL;
523 if (netif_running(netdev)) {
524 netif_device_detach(netdev);
525 netxen_napi_disable(adapter);
528 memcpy(adapter->mac_addr, addr->sa_data, netdev->addr_len);
529 memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
530 adapter->macaddr_set(adapter, addr->sa_data);
532 if (netif_running(netdev)) {
533 netif_device_attach(netdev);
534 netxen_napi_enable(adapter);
539 static void netxen_set_multicast_list(struct net_device *dev)
541 struct netxen_adapter *adapter = netdev_priv(dev);
543 adapter->set_multi(dev);
546 static netdev_features_t netxen_fix_features(struct net_device *dev,
547 netdev_features_t features)
549 if (!(features & NETIF_F_RXCSUM)) {
550 netdev_info(dev, "disabling LRO as RXCSUM is off\n");
552 features &= ~NETIF_F_LRO;
558 static int netxen_set_features(struct net_device *dev,
559 netdev_features_t features)
561 struct netxen_adapter *adapter = netdev_priv(dev);
564 if (!((dev->features ^ features) & NETIF_F_LRO))
567 hw_lro = (features & NETIF_F_LRO) ? NETXEN_NIC_LRO_ENABLED
568 : NETXEN_NIC_LRO_DISABLED;
570 if (netxen_config_hw_lro(adapter, hw_lro))
573 if (!(features & NETIF_F_LRO) && netxen_send_lro_cleanup(adapter))
579 static const struct net_device_ops netxen_netdev_ops = {
580 .ndo_open = netxen_nic_open,
581 .ndo_stop = netxen_nic_close,
582 .ndo_start_xmit = netxen_nic_xmit_frame,
583 .ndo_get_stats64 = netxen_nic_get_stats,
584 .ndo_validate_addr = eth_validate_addr,
585 .ndo_set_rx_mode = netxen_set_multicast_list,
586 .ndo_set_mac_address = netxen_nic_set_mac,
587 .ndo_change_mtu = netxen_nic_change_mtu,
588 .ndo_tx_timeout = netxen_tx_timeout,
589 .ndo_fix_features = netxen_fix_features,
590 .ndo_set_features = netxen_set_features,
591 #ifdef CONFIG_NET_POLL_CONTROLLER
592 .ndo_poll_controller = netxen_nic_poll_controller,
597 netxen_setup_intr(struct netxen_adapter *adapter)
599 struct netxen_legacy_intr_set *legacy_intrp;
600 struct pci_dev *pdev = adapter->pdev;
603 if (adapter->rss_supported) {
604 num_msix = (num_online_cpus() >= MSIX_ENTRIES_PER_ADAPTER) ?
605 MSIX_ENTRIES_PER_ADAPTER : 2;
609 adapter->max_sds_rings = 1;
611 adapter->flags &= ~(NETXEN_NIC_MSI_ENABLED | NETXEN_NIC_MSIX_ENABLED);
613 if (adapter->ahw.revision_id >= NX_P3_B0)
614 legacy_intrp = &legacy_intr[adapter->ahw.pci_func];
616 legacy_intrp = &legacy_intr[0];
618 adapter->int_vec_bit = legacy_intrp->int_vec_bit;
619 adapter->tgt_status_reg = netxen_get_ioaddr(adapter,
620 legacy_intrp->tgt_status_reg);
621 adapter->tgt_mask_reg = netxen_get_ioaddr(adapter,
622 legacy_intrp->tgt_mask_reg);
623 adapter->pci_int_reg = netxen_get_ioaddr(adapter,
624 legacy_intrp->pci_int_reg);
625 adapter->isr_int_vec = netxen_get_ioaddr(adapter, ISR_INT_VECTOR);
627 if (adapter->ahw.revision_id >= NX_P3_B1)
628 adapter->crb_int_state_reg = netxen_get_ioaddr(adapter,
631 adapter->crb_int_state_reg = netxen_get_ioaddr(adapter,
634 netxen_set_msix_bit(pdev, 0);
636 if (adapter->msix_supported) {
638 netxen_init_msix_entries(adapter, num_msix);
639 err = pci_enable_msix(pdev, adapter->msix_entries, num_msix);
641 adapter->flags |= NETXEN_NIC_MSIX_ENABLED;
642 netxen_set_msix_bit(pdev, 1);
644 if (adapter->rss_supported)
645 adapter->max_sds_rings = num_msix;
647 dev_info(&pdev->dev, "using msi-x interrupts\n");
652 pci_disable_msix(pdev);
654 /* fall through for msi */
657 if (use_msi && !pci_enable_msi(pdev)) {
658 adapter->flags |= NETXEN_NIC_MSI_ENABLED;
659 adapter->tgt_status_reg = netxen_get_ioaddr(adapter,
660 msi_tgt_status[adapter->ahw.pci_func]);
661 dev_info(&pdev->dev, "using msi interrupts\n");
662 adapter->msix_entries[0].vector = pdev->irq;
666 dev_info(&pdev->dev, "using legacy interrupts\n");
667 adapter->msix_entries[0].vector = pdev->irq;
671 netxen_teardown_intr(struct netxen_adapter *adapter)
673 if (adapter->flags & NETXEN_NIC_MSIX_ENABLED)
674 pci_disable_msix(adapter->pdev);
675 if (adapter->flags & NETXEN_NIC_MSI_ENABLED)
676 pci_disable_msi(adapter->pdev);
680 netxen_cleanup_pci_map(struct netxen_adapter *adapter)
682 if (adapter->ahw.db_base != NULL)
683 iounmap(adapter->ahw.db_base);
684 if (adapter->ahw.pci_base0 != NULL)
685 iounmap(adapter->ahw.pci_base0);
686 if (adapter->ahw.pci_base1 != NULL)
687 iounmap(adapter->ahw.pci_base1);
688 if (adapter->ahw.pci_base2 != NULL)
689 iounmap(adapter->ahw.pci_base2);
693 netxen_setup_pci_map(struct netxen_adapter *adapter)
695 void __iomem *db_ptr = NULL;
697 resource_size_t mem_base, db_base;
698 unsigned long mem_len, db_len = 0;
700 struct pci_dev *pdev = adapter->pdev;
701 int pci_func = adapter->ahw.pci_func;
702 struct netxen_hardware_context *ahw = &adapter->ahw;
707 * Set the CRB window to invalid. If any register in window 0 is
708 * accessed it should set the window to 0 and then reset it to 1.
710 adapter->ahw.crb_win = -1;
711 adapter->ahw.ocm_win = -1;
713 /* remap phys address */
714 mem_base = pci_resource_start(pdev, 0); /* 0 is for BAR 0 */
715 mem_len = pci_resource_len(pdev, 0);
717 /* 128 Meg of memory */
718 if (mem_len == NETXEN_PCI_128MB_SIZE) {
720 ahw->pci_base0 = ioremap(mem_base, FIRST_PAGE_GROUP_SIZE);
721 ahw->pci_base1 = ioremap(mem_base + SECOND_PAGE_GROUP_START,
722 SECOND_PAGE_GROUP_SIZE);
723 ahw->pci_base2 = ioremap(mem_base + THIRD_PAGE_GROUP_START,
724 THIRD_PAGE_GROUP_SIZE);
725 if (ahw->pci_base0 == NULL || ahw->pci_base1 == NULL ||
726 ahw->pci_base2 == NULL) {
727 dev_err(&pdev->dev, "failed to map PCI bar 0\n");
732 ahw->pci_len0 = FIRST_PAGE_GROUP_SIZE;
734 } else if (mem_len == NETXEN_PCI_32MB_SIZE) {
736 ahw->pci_base1 = ioremap(mem_base, SECOND_PAGE_GROUP_SIZE);
737 ahw->pci_base2 = ioremap(mem_base + THIRD_PAGE_GROUP_START -
738 SECOND_PAGE_GROUP_START, THIRD_PAGE_GROUP_SIZE);
739 if (ahw->pci_base1 == NULL || ahw->pci_base2 == NULL) {
740 dev_err(&pdev->dev, "failed to map PCI bar 0\n");
745 } else if (mem_len == NETXEN_PCI_2MB_SIZE) {
747 ahw->pci_base0 = pci_ioremap_bar(pdev, 0);
748 if (ahw->pci_base0 == NULL) {
749 dev_err(&pdev->dev, "failed to map PCI bar 0\n");
752 ahw->pci_len0 = mem_len;
757 netxen_setup_hwops(adapter);
759 dev_info(&pdev->dev, "%dMB memory map\n", (int)(mem_len>>20));
761 if (NX_IS_REVISION_P3P(adapter->ahw.revision_id)) {
762 adapter->ahw.ocm_win_crb = netxen_get_ioaddr(adapter,
763 NETXEN_PCIX_PS_REG(PCIX_OCM_WINDOW_REG(pci_func)));
765 } else if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) {
766 adapter->ahw.ocm_win_crb = netxen_get_ioaddr(adapter,
767 NETXEN_PCIX_PS_REG(PCIE_MN_WINDOW_REG(pci_func)));
770 if (NX_IS_REVISION_P3(adapter->ahw.revision_id))
773 db_base = pci_resource_start(pdev, 4); /* doorbell is on bar 4 */
774 db_len = pci_resource_len(pdev, 4);
777 printk(KERN_ERR "%s: doorbell is disabled\n",
778 netxen_nic_driver_name);
783 db_ptr = ioremap(db_base, NETXEN_DB_MAPSIZE_BYTES);
785 printk(KERN_ERR "%s: Failed to allocate doorbell map.",
786 netxen_nic_driver_name);
792 adapter->ahw.db_base = db_ptr;
793 adapter->ahw.db_len = db_len;
797 netxen_cleanup_pci_map(adapter);
802 netxen_check_options(struct netxen_adapter *adapter)
804 u32 fw_major, fw_minor, fw_build, prev_fw_version;
805 char brd_name[NETXEN_MAX_SHORT_NAME];
807 int i, offset, val, err;
809 struct pci_dev *pdev = adapter->pdev;
811 adapter->driver_mismatch = 0;
813 ptr32 = (int *)&serial_num;
814 offset = NX_FW_SERIAL_NUM_OFFSET;
815 for (i = 0; i < 8; i++) {
816 if (netxen_rom_fast_read(adapter, offset, &val) == -1) {
817 dev_err(&pdev->dev, "error reading board info\n");
818 adapter->driver_mismatch = 1;
821 ptr32[i] = cpu_to_le32(val);
822 offset += sizeof(u32);
825 fw_major = NXRD32(adapter, NETXEN_FW_VERSION_MAJOR);
826 fw_minor = NXRD32(adapter, NETXEN_FW_VERSION_MINOR);
827 fw_build = NXRD32(adapter, NETXEN_FW_VERSION_SUB);
828 prev_fw_version = adapter->fw_version;
829 adapter->fw_version = NETXEN_VERSION_CODE(fw_major, fw_minor, fw_build);
831 /* Get FW Mini Coredump template and store it */
832 if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) {
833 if (adapter->mdump.md_template == NULL ||
834 adapter->fw_version > prev_fw_version) {
835 kfree(adapter->mdump.md_template);
836 adapter->mdump.md_template = NULL;
837 err = netxen_setup_minidump(adapter);
839 dev_err(&adapter->pdev->dev,
840 "Failed to setup minidump rcode = %d\n", err);
844 if (adapter->portnum == 0) {
845 get_brd_name_by_type(adapter->ahw.board_type, brd_name);
847 pr_info("%s: %s Board S/N %s Chip rev 0x%x\n",
848 module_name(THIS_MODULE),
849 brd_name, serial_num, adapter->ahw.revision_id);
852 if (adapter->fw_version < NETXEN_VERSION_CODE(3, 4, 216)) {
853 adapter->driver_mismatch = 1;
854 dev_warn(&pdev->dev, "firmware version %d.%d.%d unsupported\n",
855 fw_major, fw_minor, fw_build);
859 if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) {
860 i = NXRD32(adapter, NETXEN_SRE_MISC);
861 adapter->ahw.cut_through = (i & 0x8000) ? 1 : 0;
864 dev_info(&pdev->dev, "firmware v%d.%d.%d [%s]\n",
865 fw_major, fw_minor, fw_build,
866 adapter->ahw.cut_through ? "cut-through" : "legacy");
868 if (adapter->fw_version >= NETXEN_VERSION_CODE(4, 0, 222))
869 adapter->capabilities = NXRD32(adapter, CRB_FW_CAPABILITIES_1);
871 if (adapter->ahw.port_type == NETXEN_NIC_XGBE) {
872 adapter->num_rxd = DEFAULT_RCV_DESCRIPTORS_10G;
873 adapter->num_jumbo_rxd = MAX_JUMBO_RCV_DESCRIPTORS_10G;
874 } else if (adapter->ahw.port_type == NETXEN_NIC_GBE) {
875 adapter->num_rxd = DEFAULT_RCV_DESCRIPTORS_1G;
876 adapter->num_jumbo_rxd = MAX_JUMBO_RCV_DESCRIPTORS_1G;
879 adapter->msix_supported = 0;
880 if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) {
881 adapter->msix_supported = !!use_msi_x;
882 adapter->rss_supported = !!use_msi_x;
885 netxen_rom_fast_read(adapter,
886 NX_FW_VERSION_OFFSET, (int *)&flashed_ver);
887 flashed_ver = NETXEN_DECODE_VERSION(flashed_ver);
889 if (flashed_ver >= NETXEN_VERSION_CODE(3, 4, 336)) {
890 switch (adapter->ahw.board_type) {
891 case NETXEN_BRDTYPE_P2_SB31_10G:
892 case NETXEN_BRDTYPE_P2_SB31_10G_CX4:
893 adapter->msix_supported = !!use_msi_x;
894 adapter->rss_supported = !!use_msi_x;
902 adapter->num_txd = MAX_CMD_DESCRIPTORS;
904 if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) {
905 adapter->num_lro_rxd = MAX_LRO_RCV_DESCRIPTORS;
906 adapter->max_rds_rings = 3;
908 adapter->num_lro_rxd = 0;
909 adapter->max_rds_rings = 2;
914 netxen_start_firmware(struct netxen_adapter *adapter)
916 int val, err, first_boot;
917 struct pci_dev *pdev = adapter->pdev;
919 /* required for NX2031 dummy dma */
920 err = nx_set_dma_mask(adapter);
924 err = netxen_can_start_firmware(adapter);
932 first_boot = NXRD32(adapter, NETXEN_CAM_RAM(0x1fc));
934 err = netxen_check_hw_init(adapter, first_boot);
936 dev_err(&pdev->dev, "error in init HW init sequence\n");
940 netxen_request_firmware(adapter);
942 err = netxen_need_fw_reset(adapter);
946 goto pcie_strap_init;
948 if (first_boot != 0x55555555) {
949 NXWR32(adapter, CRB_CMDPEG_STATE, 0);
950 netxen_pinit_from_rom(adapter);
954 NXWR32(adapter, CRB_DMA_SHIFT, 0x55555555);
955 NXWR32(adapter, NETXEN_PEG_HALT_STATUS1, 0);
956 NXWR32(adapter, NETXEN_PEG_HALT_STATUS2, 0);
958 if (NX_IS_REVISION_P3(adapter->ahw.revision_id))
959 netxen_set_port_mode(adapter);
961 err = netxen_load_firmware(adapter);
965 netxen_release_firmware(adapter);
967 if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) {
969 /* Initialize multicast addr pool owners */
971 if (adapter->ahw.port_type == NETXEN_NIC_XGBE)
973 NXWR32(adapter, NETXEN_MAC_ADDR_CNTL_REG, val);
977 err = netxen_init_dummy_dma(adapter);
982 * Tell the hardware our version number.
984 val = (_NETXEN_NIC_LINUX_MAJOR << 16)
985 | ((_NETXEN_NIC_LINUX_MINOR << 8))
986 | (_NETXEN_NIC_LINUX_SUBVERSION);
987 NXWR32(adapter, CRB_DRIVER_VERSION, val);
990 if (NX_IS_REVISION_P3(adapter->ahw.revision_id))
991 netxen_pcie_strap_init(adapter);
994 /* Handshake with the card before we register the devices. */
995 err = netxen_phantom_init(adapter, NETXEN_NIC_PEG_TUNE);
997 netxen_free_dummy_dma(adapter);
1001 NXWR32(adapter, NX_CRB_DEV_STATE, NX_DEV_READY);
1003 nx_update_dma_mask(adapter);
1005 netxen_check_options(adapter);
1007 adapter->need_fw_reset = 0;
1009 /* fall through and release firmware */
1012 netxen_release_firmware(adapter);
1017 netxen_nic_request_irq(struct netxen_adapter *adapter)
1019 irq_handler_t handler;
1020 struct nx_host_sds_ring *sds_ring;
1023 unsigned long flags = 0;
1024 struct net_device *netdev = adapter->netdev;
1025 struct netxen_recv_context *recv_ctx = &adapter->recv_ctx;
1027 if (adapter->flags & NETXEN_NIC_MSIX_ENABLED)
1028 handler = netxen_msix_intr;
1029 else if (adapter->flags & NETXEN_NIC_MSI_ENABLED)
1030 handler = netxen_msi_intr;
1032 flags |= IRQF_SHARED;
1033 handler = netxen_intr;
1035 adapter->irq = netdev->irq;
1037 for (ring = 0; ring < adapter->max_sds_rings; ring++) {
1038 sds_ring = &recv_ctx->sds_rings[ring];
1039 sprintf(sds_ring->name, "%s[%d]", netdev->name, ring);
1040 err = request_irq(sds_ring->irq, handler,
1041 flags, sds_ring->name, sds_ring);
1050 netxen_nic_free_irq(struct netxen_adapter *adapter)
1053 struct nx_host_sds_ring *sds_ring;
1055 struct netxen_recv_context *recv_ctx = &adapter->recv_ctx;
1057 for (ring = 0; ring < adapter->max_sds_rings; ring++) {
1058 sds_ring = &recv_ctx->sds_rings[ring];
1059 free_irq(sds_ring->irq, sds_ring);
1064 netxen_nic_init_coalesce_defaults(struct netxen_adapter *adapter)
1066 adapter->coal.flags = NETXEN_NIC_INTR_DEFAULT;
1067 adapter->coal.normal.data.rx_time_us =
1068 NETXEN_DEFAULT_INTR_COALESCE_RX_TIME_US;
1069 adapter->coal.normal.data.rx_packets =
1070 NETXEN_DEFAULT_INTR_COALESCE_RX_PACKETS;
1071 adapter->coal.normal.data.tx_time_us =
1072 NETXEN_DEFAULT_INTR_COALESCE_TX_TIME_US;
1073 adapter->coal.normal.data.tx_packets =
1074 NETXEN_DEFAULT_INTR_COALESCE_TX_PACKETS;
1077 /* with rtnl_lock */
1079 __netxen_nic_up(struct netxen_adapter *adapter, struct net_device *netdev)
1083 if (adapter->is_up != NETXEN_ADAPTER_UP_MAGIC)
1086 err = adapter->init_port(adapter, adapter->physical_port);
1088 printk(KERN_ERR "%s: Failed to initialize port %d\n",
1089 netxen_nic_driver_name, adapter->portnum);
1092 if (NX_IS_REVISION_P2(adapter->ahw.revision_id))
1093 adapter->macaddr_set(adapter, adapter->mac_addr);
1095 adapter->set_multi(netdev);
1096 adapter->set_mtu(adapter, netdev->mtu);
1098 adapter->ahw.linkup = 0;
1100 if (adapter->max_sds_rings > 1)
1101 netxen_config_rss(adapter, 1);
1103 if (NX_IS_REVISION_P3(adapter->ahw.revision_id))
1104 netxen_config_intr_coalesce(adapter);
1106 if (netdev->features & NETIF_F_LRO)
1107 netxen_config_hw_lro(adapter, NETXEN_NIC_LRO_ENABLED);
1109 netxen_napi_enable(adapter);
1111 if (adapter->capabilities & NX_FW_CAPABILITY_LINK_NOTIFICATION)
1112 netxen_linkevent_request(adapter, 1);
1114 netxen_nic_set_link_parameters(adapter);
1116 set_bit(__NX_DEV_UP, &adapter->state);
1120 /* Usage: During resume and firmware recovery module.*/
1123 netxen_nic_up(struct netxen_adapter *adapter, struct net_device *netdev)
1128 if (netif_running(netdev))
1129 err = __netxen_nic_up(adapter, netdev);
1135 /* with rtnl_lock */
1137 __netxen_nic_down(struct netxen_adapter *adapter, struct net_device *netdev)
1139 if (adapter->is_up != NETXEN_ADAPTER_UP_MAGIC)
1142 if (!test_and_clear_bit(__NX_DEV_UP, &adapter->state))
1146 spin_lock(&adapter->tx_clean_lock);
1147 netif_carrier_off(netdev);
1148 netif_tx_disable(netdev);
1150 if (adapter->capabilities & NX_FW_CAPABILITY_LINK_NOTIFICATION)
1151 netxen_linkevent_request(adapter, 0);
1153 if (adapter->stop_port)
1154 adapter->stop_port(adapter);
1156 if (NX_IS_REVISION_P3(adapter->ahw.revision_id))
1157 netxen_p3_free_mac_list(adapter);
1159 adapter->set_promisc(adapter, NETXEN_NIU_NON_PROMISC_MODE);
1161 netxen_napi_disable(adapter);
1163 netxen_release_tx_buffers(adapter);
1164 spin_unlock(&adapter->tx_clean_lock);
1167 /* Usage: During suspend and firmware recovery module */
1170 netxen_nic_down(struct netxen_adapter *adapter, struct net_device *netdev)
1173 if (netif_running(netdev))
1174 __netxen_nic_down(adapter, netdev);
1180 netxen_nic_attach(struct netxen_adapter *adapter)
1182 struct net_device *netdev = adapter->netdev;
1183 struct pci_dev *pdev = adapter->pdev;
1185 struct nx_host_rds_ring *rds_ring;
1186 struct nx_host_tx_ring *tx_ring;
1188 if (adapter->is_up == NETXEN_ADAPTER_UP_MAGIC)
1191 err = netxen_init_firmware(adapter);
1195 err = netxen_napi_add(adapter, netdev);
1199 err = netxen_alloc_sw_resources(adapter);
1201 printk(KERN_ERR "%s: Error in setting sw resources\n",
1206 err = netxen_alloc_hw_resources(adapter);
1208 printk(KERN_ERR "%s: Error in setting hw resources\n",
1210 goto err_out_free_sw;
1213 if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) {
1214 tx_ring = adapter->tx_ring;
1215 tx_ring->crb_cmd_producer = netxen_get_ioaddr(adapter,
1216 crb_cmd_producer[adapter->portnum]);
1217 tx_ring->crb_cmd_consumer = netxen_get_ioaddr(adapter,
1218 crb_cmd_consumer[adapter->portnum]);
1220 tx_ring->producer = 0;
1221 tx_ring->sw_consumer = 0;
1223 netxen_nic_update_cmd_producer(adapter, tx_ring);
1224 netxen_nic_update_cmd_consumer(adapter, tx_ring);
1227 for (ring = 0; ring < adapter->max_rds_rings; ring++) {
1228 rds_ring = &adapter->recv_ctx.rds_rings[ring];
1229 netxen_post_rx_buffers(adapter, ring, rds_ring);
1232 err = netxen_nic_request_irq(adapter);
1234 dev_err(&pdev->dev, "%s: failed to setup interrupt\n",
1236 goto err_out_free_rxbuf;
1239 if (NX_IS_REVISION_P3(adapter->ahw.revision_id))
1240 netxen_nic_init_coalesce_defaults(adapter);
1242 netxen_create_sysfs_entries(adapter);
1244 adapter->is_up = NETXEN_ADAPTER_UP_MAGIC;
1248 netxen_release_rx_buffers(adapter);
1249 netxen_free_hw_resources(adapter);
1251 netxen_free_sw_resources(adapter);
1256 netxen_nic_detach(struct netxen_adapter *adapter)
1258 if (adapter->is_up != NETXEN_ADAPTER_UP_MAGIC)
1261 netxen_remove_sysfs_entries(adapter);
1263 netxen_free_hw_resources(adapter);
1264 netxen_release_rx_buffers(adapter);
1265 netxen_nic_free_irq(adapter);
1266 netxen_napi_del(adapter);
1267 netxen_free_sw_resources(adapter);
1273 netxen_nic_reset_context(struct netxen_adapter *adapter)
1276 struct net_device *netdev = adapter->netdev;
1278 if (test_and_set_bit(__NX_RESETTING, &adapter->state))
1281 if (adapter->is_up == NETXEN_ADAPTER_UP_MAGIC) {
1283 netif_device_detach(netdev);
1285 if (netif_running(netdev))
1286 __netxen_nic_down(adapter, netdev);
1288 netxen_nic_detach(adapter);
1290 if (netif_running(netdev)) {
1291 err = netxen_nic_attach(adapter);
1293 err = __netxen_nic_up(adapter, netdev);
1299 netif_device_attach(netdev);
1303 clear_bit(__NX_RESETTING, &adapter->state);
1308 netxen_setup_netdev(struct netxen_adapter *adapter,
1309 struct net_device *netdev)
1312 struct pci_dev *pdev = adapter->pdev;
1314 adapter->mc_enabled = 0;
1315 if (NX_IS_REVISION_P3(adapter->ahw.revision_id))
1316 adapter->max_mc_count = 38;
1318 adapter->max_mc_count = 16;
1320 netdev->netdev_ops = &netxen_netdev_ops;
1321 netdev->watchdog_timeo = 5*HZ;
1323 netxen_nic_change_mtu(netdev, netdev->mtu);
1325 SET_ETHTOOL_OPS(netdev, &netxen_nic_ethtool_ops);
1327 netdev->hw_features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO |
1330 if (NX_IS_REVISION_P3(adapter->ahw.revision_id))
1331 netdev->hw_features |= NETIF_F_IPV6_CSUM | NETIF_F_TSO6;
1333 netdev->vlan_features |= netdev->hw_features;
1335 if (adapter->pci_using_dac) {
1336 netdev->features |= NETIF_F_HIGHDMA;
1337 netdev->vlan_features |= NETIF_F_HIGHDMA;
1340 if (adapter->capabilities & NX_FW_CAPABILITY_FVLANTX)
1341 netdev->hw_features |= NETIF_F_HW_VLAN_TX;
1343 if (adapter->capabilities & NX_FW_CAPABILITY_HW_LRO)
1344 netdev->hw_features |= NETIF_F_LRO;
1346 netdev->features |= netdev->hw_features;
1348 netdev->irq = adapter->msix_entries[0].vector;
1350 INIT_WORK(&adapter->tx_timeout_task, netxen_tx_timeout_task);
1352 if (netxen_read_mac_addr(adapter))
1353 dev_warn(&pdev->dev, "failed to read mac addr\n");
1355 netif_carrier_off(netdev);
1357 err = register_netdev(netdev);
1359 dev_err(&pdev->dev, "failed to register net device\n");
1366 #ifdef CONFIG_PCIEAER
1367 static void netxen_mask_aer_correctable(struct netxen_adapter *adapter)
1369 struct pci_dev *pdev = adapter->pdev;
1370 struct pci_dev *root = pdev->bus->self;
1373 if (adapter->ahw.board_type != NETXEN_BRDTYPE_P3_4_GB_MM &&
1374 adapter->ahw.board_type != NETXEN_BRDTYPE_P3_10G_TP)
1377 if (root->pcie_type != PCI_EXP_TYPE_ROOT_PORT)
1380 aer_pos = pci_find_ext_capability(root, PCI_EXT_CAP_ID_ERR);
1384 pci_write_config_dword(root, aer_pos + PCI_ERR_COR_MASK, 0xffff);
1388 static int __devinit
1389 netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1391 struct net_device *netdev = NULL;
1392 struct netxen_adapter *adapter = NULL;
1394 int pci_func_id = PCI_FUNC(pdev->devfn);
1395 uint8_t revision_id;
1398 if (pdev->revision >= NX_P3_A0 && pdev->revision <= NX_P3_B1) {
1399 pr_warning("%s: chip revisions between 0x%x-0x%x "
1400 "will not be enabled.\n",
1401 module_name(THIS_MODULE), NX_P3_A0, NX_P3_B1);
1405 if ((err = pci_enable_device(pdev)))
1408 if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) {
1410 goto err_out_disable_pdev;
1413 if ((err = pci_request_regions(pdev, netxen_nic_driver_name)))
1414 goto err_out_disable_pdev;
1416 if (NX_IS_REVISION_P3(pdev->revision))
1417 pci_enable_pcie_error_reporting(pdev);
1419 pci_set_master(pdev);
1421 netdev = alloc_etherdev(sizeof(struct netxen_adapter));
1424 goto err_out_free_res;
1427 SET_NETDEV_DEV(netdev, &pdev->dev);
1429 adapter = netdev_priv(netdev);
1430 adapter->netdev = netdev;
1431 adapter->pdev = pdev;
1432 adapter->ahw.pci_func = pci_func_id;
1434 revision_id = pdev->revision;
1435 adapter->ahw.revision_id = revision_id;
1437 rwlock_init(&adapter->ahw.crb_lock);
1438 spin_lock_init(&adapter->ahw.mem_lock);
1440 spin_lock_init(&adapter->tx_clean_lock);
1441 INIT_LIST_HEAD(&adapter->mac_list);
1442 INIT_LIST_HEAD(&adapter->vlan_ip_list);
1444 err = netxen_setup_pci_map(adapter);
1446 goto err_out_free_netdev;
1448 /* This will be reset for mezz cards */
1449 adapter->portnum = pci_func_id;
1451 err = netxen_nic_get_board_info(adapter);
1453 dev_err(&pdev->dev, "Error getting board config info.\n");
1454 goto err_out_iounmap;
1457 #ifdef CONFIG_PCIEAER
1458 netxen_mask_aer_correctable(adapter);
1461 /* Mezz cards have PCI function 0,2,3 enabled */
1462 switch (adapter->ahw.board_type) {
1463 case NETXEN_BRDTYPE_P2_SB31_10G_IMEZ:
1464 case NETXEN_BRDTYPE_P2_SB31_10G_HMEZ:
1465 if (pci_func_id >= 2)
1466 adapter->portnum = pci_func_id - 2;
1472 err = netxen_check_flash_fw_compatibility(adapter);
1474 goto err_out_iounmap;
1476 if (adapter->portnum == 0) {
1477 val = NXRD32(adapter, NX_CRB_DEV_REF_COUNT);
1478 if (val != 0xffffffff && val != 0) {
1479 NXWR32(adapter, NX_CRB_DEV_REF_COUNT, 0);
1480 adapter->need_fw_reset = 1;
1484 err = netxen_start_firmware(adapter);
1486 goto err_out_decr_ref;
1489 * See if the firmware gave us a virtual-physical port mapping.
1491 adapter->physical_port = adapter->portnum;
1492 if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) {
1493 i = NXRD32(adapter, CRB_V2P(adapter->portnum));
1494 if (i != 0x55555555)
1495 adapter->physical_port = i;
1498 netxen_nic_clear_stats(adapter);
1500 netxen_setup_intr(adapter);
1502 err = netxen_setup_netdev(adapter, netdev);
1504 goto err_out_disable_msi;
1506 pci_set_drvdata(pdev, adapter);
1508 netxen_schedule_work(adapter, netxen_fw_poll_work, FW_POLL_DELAY);
1510 switch (adapter->ahw.port_type) {
1511 case NETXEN_NIC_GBE:
1512 dev_info(&adapter->pdev->dev, "%s: GbE port initialized\n",
1513 adapter->netdev->name);
1515 case NETXEN_NIC_XGBE:
1516 dev_info(&adapter->pdev->dev, "%s: XGbE port initialized\n",
1517 adapter->netdev->name);
1521 netxen_create_diag_entries(adapter);
1525 err_out_disable_msi:
1526 netxen_teardown_intr(adapter);
1528 netxen_free_dummy_dma(adapter);
1531 nx_decr_dev_ref_cnt(adapter);
1534 netxen_cleanup_pci_map(adapter);
1536 err_out_free_netdev:
1537 free_netdev(netdev);
1540 pci_release_regions(pdev);
1542 err_out_disable_pdev:
1543 pci_set_drvdata(pdev, NULL);
1544 pci_disable_device(pdev);
1549 void netxen_cleanup_minidump(struct netxen_adapter *adapter)
1551 kfree(adapter->mdump.md_template);
1552 adapter->mdump.md_template = NULL;
1554 if (adapter->mdump.md_capture_buff) {
1555 vfree(adapter->mdump.md_capture_buff);
1556 adapter->mdump.md_capture_buff = NULL;
1560 static void __devexit netxen_nic_remove(struct pci_dev *pdev)
1562 struct netxen_adapter *adapter;
1563 struct net_device *netdev;
1565 adapter = pci_get_drvdata(pdev);
1566 if (adapter == NULL)
1569 netdev = adapter->netdev;
1571 netxen_cancel_fw_work(adapter);
1573 unregister_netdev(netdev);
1575 cancel_work_sync(&adapter->tx_timeout_task);
1577 netxen_free_vlan_ip_list(adapter);
1578 netxen_nic_detach(adapter);
1580 nx_decr_dev_ref_cnt(adapter);
1582 if (adapter->portnum == 0)
1583 netxen_free_dummy_dma(adapter);
1585 clear_bit(__NX_RESETTING, &adapter->state);
1587 netxen_teardown_intr(adapter);
1589 netxen_remove_diag_entries(adapter);
1591 netxen_cleanup_pci_map(adapter);
1593 netxen_release_firmware(adapter);
1595 if (NX_IS_REVISION_P3(pdev->revision)) {
1596 netxen_cleanup_minidump(adapter);
1597 pci_disable_pcie_error_reporting(pdev);
1600 pci_release_regions(pdev);
1601 pci_disable_device(pdev);
1602 pci_set_drvdata(pdev, NULL);
1604 free_netdev(netdev);
1607 static void netxen_nic_detach_func(struct netxen_adapter *adapter)
1609 struct net_device *netdev = adapter->netdev;
1611 netif_device_detach(netdev);
1613 netxen_cancel_fw_work(adapter);
1615 if (netif_running(netdev))
1616 netxen_nic_down(adapter, netdev);
1618 cancel_work_sync(&adapter->tx_timeout_task);
1620 netxen_nic_detach(adapter);
1622 if (adapter->portnum == 0)
1623 netxen_free_dummy_dma(adapter);
1625 nx_decr_dev_ref_cnt(adapter);
1627 clear_bit(__NX_RESETTING, &adapter->state);
1630 static int netxen_nic_attach_func(struct pci_dev *pdev)
1632 struct netxen_adapter *adapter = pci_get_drvdata(pdev);
1633 struct net_device *netdev = adapter->netdev;
1636 err = pci_enable_device(pdev);
1640 pci_set_power_state(pdev, PCI_D0);
1641 pci_set_master(pdev);
1642 pci_restore_state(pdev);
1644 adapter->ahw.crb_win = -1;
1645 adapter->ahw.ocm_win = -1;
1647 err = netxen_start_firmware(adapter);
1649 dev_err(&pdev->dev, "failed to start firmware\n");
1653 if (netif_running(netdev)) {
1654 err = netxen_nic_attach(adapter);
1658 err = netxen_nic_up(adapter, netdev);
1660 goto err_out_detach;
1662 netxen_restore_indev_addr(netdev, NETDEV_UP);
1665 netif_device_attach(netdev);
1666 netxen_schedule_work(adapter, netxen_fw_poll_work, FW_POLL_DELAY);
1670 netxen_nic_detach(adapter);
1672 nx_decr_dev_ref_cnt(adapter);
1676 static pci_ers_result_t netxen_io_error_detected(struct pci_dev *pdev,
1677 pci_channel_state_t state)
1679 struct netxen_adapter *adapter = pci_get_drvdata(pdev);
1681 if (state == pci_channel_io_perm_failure)
1682 return PCI_ERS_RESULT_DISCONNECT;
1684 if (nx_dev_request_aer(adapter))
1685 return PCI_ERS_RESULT_RECOVERED;
1687 netxen_nic_detach_func(adapter);
1689 pci_disable_device(pdev);
1691 return PCI_ERS_RESULT_NEED_RESET;
1694 static pci_ers_result_t netxen_io_slot_reset(struct pci_dev *pdev)
1698 err = netxen_nic_attach_func(pdev);
1700 return err ? PCI_ERS_RESULT_DISCONNECT : PCI_ERS_RESULT_RECOVERED;
1703 static void netxen_io_resume(struct pci_dev *pdev)
1705 pci_cleanup_aer_uncorrect_error_status(pdev);
1708 static void netxen_nic_shutdown(struct pci_dev *pdev)
1710 struct netxen_adapter *adapter = pci_get_drvdata(pdev);
1712 netxen_nic_detach_func(adapter);
1714 if (pci_save_state(pdev))
1717 if (netxen_nic_wol_supported(adapter)) {
1718 pci_enable_wake(pdev, PCI_D3cold, 1);
1719 pci_enable_wake(pdev, PCI_D3hot, 1);
1722 pci_disable_device(pdev);
1727 netxen_nic_suspend(struct pci_dev *pdev, pm_message_t state)
1729 struct netxen_adapter *adapter = pci_get_drvdata(pdev);
1732 netxen_nic_detach_func(adapter);
1734 retval = pci_save_state(pdev);
1738 if (netxen_nic_wol_supported(adapter)) {
1739 pci_enable_wake(pdev, PCI_D3cold, 1);
1740 pci_enable_wake(pdev, PCI_D3hot, 1);
1743 pci_disable_device(pdev);
1744 pci_set_power_state(pdev, pci_choose_state(pdev, state));
1750 netxen_nic_resume(struct pci_dev *pdev)
1752 return netxen_nic_attach_func(pdev);
1756 static int netxen_nic_open(struct net_device *netdev)
1758 struct netxen_adapter *adapter = netdev_priv(netdev);
1761 if (adapter->driver_mismatch)
1764 err = netxen_nic_attach(adapter);
1768 err = __netxen_nic_up(adapter, netdev);
1772 netif_start_queue(netdev);
1777 netxen_nic_detach(adapter);
1782 * netxen_nic_close - Disables a network interface entry point
1784 static int netxen_nic_close(struct net_device *netdev)
1786 struct netxen_adapter *adapter = netdev_priv(netdev);
1788 __netxen_nic_down(adapter, netdev);
1793 netxen_tso_check(struct net_device *netdev,
1794 struct nx_host_tx_ring *tx_ring,
1795 struct cmd_desc_type0 *first_desc,
1796 struct sk_buff *skb)
1798 u8 opcode = TX_ETHER_PKT;
1799 __be16 protocol = skb->protocol;
1800 u16 flags = 0, vid = 0;
1802 int copied, offset, copy_len, hdr_len = 0, tso = 0, vlan_oob = 0;
1803 struct cmd_desc_type0 *hwdesc;
1804 struct vlan_ethhdr *vh;
1806 if (protocol == cpu_to_be16(ETH_P_8021Q)) {
1808 vh = (struct vlan_ethhdr *)skb->data;
1809 protocol = vh->h_vlan_encapsulated_proto;
1810 flags = FLAGS_VLAN_TAGGED;
1812 } else if (vlan_tx_tag_present(skb)) {
1814 flags = FLAGS_VLAN_OOB;
1815 vid = vlan_tx_tag_get(skb);
1816 netxen_set_tx_vlan_tci(first_desc, vid);
1820 if ((netdev->features & (NETIF_F_TSO | NETIF_F_TSO6)) &&
1821 skb_shinfo(skb)->gso_size > 0) {
1823 hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
1825 first_desc->mss = cpu_to_le16(skb_shinfo(skb)->gso_size);
1826 first_desc->total_hdr_length = hdr_len;
1828 first_desc->total_hdr_length += VLAN_HLEN;
1829 first_desc->tcp_hdr_offset = VLAN_HLEN;
1830 first_desc->ip_hdr_offset = VLAN_HLEN;
1831 /* Only in case of TSO on vlan device */
1832 flags |= FLAGS_VLAN_TAGGED;
1835 opcode = (protocol == cpu_to_be16(ETH_P_IPV6)) ?
1836 TX_TCP_LSO6 : TX_TCP_LSO;
1839 } else if (skb->ip_summed == CHECKSUM_PARTIAL) {
1842 if (protocol == cpu_to_be16(ETH_P_IP)) {
1843 l4proto = ip_hdr(skb)->protocol;
1845 if (l4proto == IPPROTO_TCP)
1846 opcode = TX_TCP_PKT;
1847 else if(l4proto == IPPROTO_UDP)
1848 opcode = TX_UDP_PKT;
1849 } else if (protocol == cpu_to_be16(ETH_P_IPV6)) {
1850 l4proto = ipv6_hdr(skb)->nexthdr;
1852 if (l4proto == IPPROTO_TCP)
1853 opcode = TX_TCPV6_PKT;
1854 else if(l4proto == IPPROTO_UDP)
1855 opcode = TX_UDPV6_PKT;
1859 first_desc->tcp_hdr_offset += skb_transport_offset(skb);
1860 first_desc->ip_hdr_offset += skb_network_offset(skb);
1861 netxen_set_tx_flags_opcode(first_desc, flags, opcode);
1866 /* For LSO, we need to copy the MAC/IP/TCP headers into
1867 * the descriptor ring
1869 producer = tx_ring->producer;
1874 /* Create a TSO vlan header template for firmware */
1876 hwdesc = &tx_ring->desc_head[producer];
1877 tx_ring->cmd_buf_arr[producer].skb = NULL;
1879 copy_len = min((int)sizeof(struct cmd_desc_type0) - offset,
1880 hdr_len + VLAN_HLEN);
1882 vh = (struct vlan_ethhdr *)((char *)hwdesc + 2);
1883 skb_copy_from_linear_data(skb, vh, 12);
1884 vh->h_vlan_proto = htons(ETH_P_8021Q);
1885 vh->h_vlan_TCI = htons(vid);
1886 skb_copy_from_linear_data_offset(skb, 12,
1887 (char *)vh + 16, copy_len - 16);
1889 copied = copy_len - VLAN_HLEN;
1892 producer = get_next_index(producer, tx_ring->num_desc);
1895 while (copied < hdr_len) {
1897 copy_len = min((int)sizeof(struct cmd_desc_type0) - offset,
1898 (hdr_len - copied));
1900 hwdesc = &tx_ring->desc_head[producer];
1901 tx_ring->cmd_buf_arr[producer].skb = NULL;
1903 skb_copy_from_linear_data_offset(skb, copied,
1904 (char *)hwdesc + offset, copy_len);
1909 producer = get_next_index(producer, tx_ring->num_desc);
1912 tx_ring->producer = producer;
1917 netxen_map_tx_skb(struct pci_dev *pdev,
1918 struct sk_buff *skb, struct netxen_cmd_buffer *pbuf)
1920 struct netxen_skb_frag *nf;
1921 struct skb_frag_struct *frag;
1925 nr_frags = skb_shinfo(skb)->nr_frags;
1926 nf = &pbuf->frag_array[0];
1928 map = pci_map_single(pdev, skb->data,
1929 skb_headlen(skb), PCI_DMA_TODEVICE);
1930 if (pci_dma_mapping_error(pdev, map))
1934 nf->length = skb_headlen(skb);
1936 for (i = 0; i < nr_frags; i++) {
1937 frag = &skb_shinfo(skb)->frags[i];
1938 nf = &pbuf->frag_array[i+1];
1940 map = skb_frag_dma_map(&pdev->dev, frag, 0, skb_frag_size(frag),
1942 if (dma_mapping_error(&pdev->dev, map))
1946 nf->length = skb_frag_size(frag);
1953 nf = &pbuf->frag_array[i+1];
1954 pci_unmap_page(pdev, nf->dma, nf->length, PCI_DMA_TODEVICE);
1957 nf = &pbuf->frag_array[0];
1958 pci_unmap_single(pdev, nf->dma, skb_headlen(skb), PCI_DMA_TODEVICE);
1965 netxen_clear_cmddesc(u64 *desc)
1972 netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
1974 struct netxen_adapter *adapter = netdev_priv(netdev);
1975 struct nx_host_tx_ring *tx_ring = adapter->tx_ring;
1976 struct netxen_cmd_buffer *pbuf;
1977 struct netxen_skb_frag *buffrag;
1978 struct cmd_desc_type0 *hwdesc, *first_desc;
1979 struct pci_dev *pdev;
1982 struct skb_frag_struct *frag;
1985 int frag_count, no_of_desc;
1986 u32 num_txd = tx_ring->num_desc;
1988 frag_count = skb_shinfo(skb)->nr_frags + 1;
1990 /* 14 frags supported for normal packet and
1991 * 32 frags supported for TSO packet
1993 if (!skb_is_gso(skb) && frag_count > NETXEN_MAX_FRAGS_PER_TX) {
1995 for (i = 0; i < (frag_count - NETXEN_MAX_FRAGS_PER_TX); i++) {
1996 frag = &skb_shinfo(skb)->frags[i];
1997 delta += skb_frag_size(frag);
2000 if (!__pskb_pull_tail(skb, delta))
2003 frag_count = 1 + skb_shinfo(skb)->nr_frags;
2005 /* 4 fragments per cmd des */
2006 no_of_desc = (frag_count + 3) >> 2;
2008 if (unlikely(netxen_tx_avail(tx_ring) <= TX_STOP_THRESH)) {
2009 netif_stop_queue(netdev);
2011 if (netxen_tx_avail(tx_ring) > TX_STOP_THRESH)
2012 netif_start_queue(netdev);
2014 return NETDEV_TX_BUSY;
2017 producer = tx_ring->producer;
2018 pbuf = &tx_ring->cmd_buf_arr[producer];
2020 pdev = adapter->pdev;
2022 if (netxen_map_tx_skb(pdev, skb, pbuf))
2026 pbuf->frag_count = frag_count;
2028 first_desc = hwdesc = &tx_ring->desc_head[producer];
2029 netxen_clear_cmddesc((u64 *)hwdesc);
2031 netxen_set_tx_frags_len(first_desc, frag_count, skb->len);
2032 netxen_set_tx_port(first_desc, adapter->portnum);
2034 for (i = 0; i < frag_count; i++) {
2038 if ((k == 0) && (i > 0)) {
2039 /* move to next desc.*/
2040 producer = get_next_index(producer, num_txd);
2041 hwdesc = &tx_ring->desc_head[producer];
2042 netxen_clear_cmddesc((u64 *)hwdesc);
2043 tx_ring->cmd_buf_arr[producer].skb = NULL;
2046 buffrag = &pbuf->frag_array[i];
2048 hwdesc->buffer_length[k] = cpu_to_le16(buffrag->length);
2051 hwdesc->addr_buffer1 = cpu_to_le64(buffrag->dma);
2054 hwdesc->addr_buffer2 = cpu_to_le64(buffrag->dma);
2057 hwdesc->addr_buffer3 = cpu_to_le64(buffrag->dma);
2060 hwdesc->addr_buffer4 = cpu_to_le64(buffrag->dma);
2065 tx_ring->producer = get_next_index(producer, num_txd);
2067 netxen_tso_check(netdev, tx_ring, first_desc, skb);
2069 adapter->stats.txbytes += skb->len;
2070 adapter->stats.xmitcalled++;
2072 netxen_nic_update_cmd_producer(adapter, tx_ring);
2074 return NETDEV_TX_OK;
2077 adapter->stats.txdropped++;
2078 dev_kfree_skb_any(skb);
2079 return NETDEV_TX_OK;
2082 static int netxen_nic_check_temp(struct netxen_adapter *adapter)
2084 struct net_device *netdev = adapter->netdev;
2085 uint32_t temp, temp_state, temp_val;
2088 temp = NXRD32(adapter, CRB_TEMP_STATE);
2090 temp_state = nx_get_temp_state(temp);
2091 temp_val = nx_get_temp_val(temp);
2093 if (temp_state == NX_TEMP_PANIC) {
2095 "%s: Device temperature %d degrees C exceeds"
2096 " maximum allowed. Hardware has been shut down.\n",
2097 netdev->name, temp_val);
2099 } else if (temp_state == NX_TEMP_WARN) {
2100 if (adapter->temp == NX_TEMP_NORMAL) {
2102 "%s: Device temperature %d degrees C "
2103 "exceeds operating range."
2104 " Immediate action needed.\n",
2105 netdev->name, temp_val);
2108 if (adapter->temp == NX_TEMP_WARN) {
2110 "%s: Device temperature is now %d degrees C"
2111 " in normal range.\n", netdev->name,
2115 adapter->temp = temp_state;
2119 void netxen_advert_link_change(struct netxen_adapter *adapter, int linkup)
2121 struct net_device *netdev = adapter->netdev;
2123 if (adapter->ahw.linkup && !linkup) {
2124 printk(KERN_INFO "%s: %s NIC Link is down\n",
2125 netxen_nic_driver_name, netdev->name);
2126 adapter->ahw.linkup = 0;
2127 if (netif_running(netdev)) {
2128 netif_carrier_off(netdev);
2129 netif_stop_queue(netdev);
2131 adapter->link_changed = !adapter->has_link_events;
2132 } else if (!adapter->ahw.linkup && linkup) {
2133 printk(KERN_INFO "%s: %s NIC Link is up\n",
2134 netxen_nic_driver_name, netdev->name);
2135 adapter->ahw.linkup = 1;
2136 if (netif_running(netdev)) {
2137 netif_carrier_on(netdev);
2138 netif_wake_queue(netdev);
2140 adapter->link_changed = !adapter->has_link_events;
2144 static void netxen_nic_handle_phy_intr(struct netxen_adapter *adapter)
2146 u32 val, port, linkup;
2148 port = adapter->physical_port;
2150 if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) {
2151 val = NXRD32(adapter, CRB_XG_STATE_P3);
2152 val = XG_LINK_STATE_P3(adapter->ahw.pci_func, val);
2153 linkup = (val == XG_LINK_UP_P3);
2155 val = NXRD32(adapter, CRB_XG_STATE);
2156 val = (val >> port*8) & 0xff;
2157 linkup = (val == XG_LINK_UP);
2160 netxen_advert_link_change(adapter, linkup);
2163 static void netxen_tx_timeout(struct net_device *netdev)
2165 struct netxen_adapter *adapter = netdev_priv(netdev);
2167 if (test_bit(__NX_RESETTING, &adapter->state))
2170 dev_err(&netdev->dev, "transmit timeout, resetting.\n");
2171 schedule_work(&adapter->tx_timeout_task);
2174 static void netxen_tx_timeout_task(struct work_struct *work)
2176 struct netxen_adapter *adapter =
2177 container_of(work, struct netxen_adapter, tx_timeout_task);
2179 if (!netif_running(adapter->netdev))
2182 if (test_and_set_bit(__NX_RESETTING, &adapter->state))
2185 if (++adapter->tx_timeo_cnt >= NX_MAX_TX_TIMEOUTS)
2189 if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) {
2190 /* try to scrub interrupt */
2191 netxen_napi_disable(adapter);
2193 netxen_napi_enable(adapter);
2195 netif_wake_queue(adapter->netdev);
2197 clear_bit(__NX_RESETTING, &adapter->state);
2199 clear_bit(__NX_RESETTING, &adapter->state);
2200 if (netxen_nic_reset_context(adapter)) {
2205 adapter->netdev->trans_start = jiffies;
2210 adapter->need_fw_reset = 1;
2211 clear_bit(__NX_RESETTING, &adapter->state);
2214 static struct rtnl_link_stats64 *netxen_nic_get_stats(struct net_device *netdev,
2215 struct rtnl_link_stats64 *stats)
2217 struct netxen_adapter *adapter = netdev_priv(netdev);
2219 stats->rx_packets = adapter->stats.rx_pkts + adapter->stats.lro_pkts;
2220 stats->tx_packets = adapter->stats.xmitfinished;
2221 stats->rx_bytes = adapter->stats.rxbytes;
2222 stats->tx_bytes = adapter->stats.txbytes;
2223 stats->rx_dropped = adapter->stats.rxdropped;
2224 stats->tx_dropped = adapter->stats.txdropped;
2229 static irqreturn_t netxen_intr(int irq, void *data)
2231 struct nx_host_sds_ring *sds_ring = data;
2232 struct netxen_adapter *adapter = sds_ring->adapter;
2235 status = readl(adapter->isr_int_vec);
2237 if (!(status & adapter->int_vec_bit))
2240 if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) {
2241 /* check interrupt state machine, to be sure */
2242 status = readl(adapter->crb_int_state_reg);
2243 if (!ISR_LEGACY_INT_TRIGGERED(status))
2247 unsigned long our_int = 0;
2249 our_int = readl(adapter->crb_int_state_reg);
2251 /* not our interrupt */
2252 if (!test_and_clear_bit((7 + adapter->portnum), &our_int))
2255 /* claim interrupt */
2256 writel((our_int & 0xffffffff), adapter->crb_int_state_reg);
2258 /* clear interrupt */
2259 netxen_nic_disable_int(sds_ring);
2262 writel(0xffffffff, adapter->tgt_status_reg);
2263 /* read twice to ensure write is flushed */
2264 readl(adapter->isr_int_vec);
2265 readl(adapter->isr_int_vec);
2267 napi_schedule(&sds_ring->napi);
2272 static irqreturn_t netxen_msi_intr(int irq, void *data)
2274 struct nx_host_sds_ring *sds_ring = data;
2275 struct netxen_adapter *adapter = sds_ring->adapter;
2277 /* clear interrupt */
2278 writel(0xffffffff, adapter->tgt_status_reg);
2280 napi_schedule(&sds_ring->napi);
2284 static irqreturn_t netxen_msix_intr(int irq, void *data)
2286 struct nx_host_sds_ring *sds_ring = data;
2288 napi_schedule(&sds_ring->napi);
2292 static int netxen_nic_poll(struct napi_struct *napi, int budget)
2294 struct nx_host_sds_ring *sds_ring =
2295 container_of(napi, struct nx_host_sds_ring, napi);
2297 struct netxen_adapter *adapter = sds_ring->adapter;
2302 tx_complete = netxen_process_cmd_ring(adapter);
2304 work_done = netxen_process_rcv_ring(sds_ring, budget);
2306 if ((work_done < budget) && tx_complete) {
2307 napi_complete(&sds_ring->napi);
2308 if (test_bit(__NX_DEV_UP, &adapter->state))
2309 netxen_nic_enable_int(sds_ring);
2315 #ifdef CONFIG_NET_POLL_CONTROLLER
2316 static void netxen_nic_poll_controller(struct net_device *netdev)
2319 struct nx_host_sds_ring *sds_ring;
2320 struct netxen_adapter *adapter = netdev_priv(netdev);
2321 struct netxen_recv_context *recv_ctx = &adapter->recv_ctx;
2323 disable_irq(adapter->irq);
2324 for (ring = 0; ring < adapter->max_sds_rings; ring++) {
2325 sds_ring = &recv_ctx->sds_rings[ring];
2326 netxen_intr(adapter->irq, sds_ring);
2328 enable_irq(adapter->irq);
2333 nx_incr_dev_ref_cnt(struct netxen_adapter *adapter)
2336 if (netxen_api_lock(adapter))
2339 count = NXRD32(adapter, NX_CRB_DEV_REF_COUNT);
2341 NXWR32(adapter, NX_CRB_DEV_REF_COUNT, ++count);
2343 netxen_api_unlock(adapter);
2348 nx_decr_dev_ref_cnt(struct netxen_adapter *adapter)
2351 if (netxen_api_lock(adapter))
2354 count = NXRD32(adapter, NX_CRB_DEV_REF_COUNT);
2355 WARN_ON(count == 0);
2357 NXWR32(adapter, NX_CRB_DEV_REF_COUNT, --count);
2358 state = NXRD32(adapter, NX_CRB_DEV_STATE);
2360 if (count == 0 && state != NX_DEV_FAILED)
2361 NXWR32(adapter, NX_CRB_DEV_STATE, NX_DEV_COLD);
2363 netxen_api_unlock(adapter);
2368 nx_dev_request_aer(struct netxen_adapter *adapter)
2373 if (netxen_api_lock(adapter))
2376 state = NXRD32(adapter, NX_CRB_DEV_STATE);
2378 if (state == NX_DEV_NEED_AER)
2380 else if (state == NX_DEV_READY) {
2381 NXWR32(adapter, NX_CRB_DEV_STATE, NX_DEV_NEED_AER);
2385 netxen_api_unlock(adapter);
2390 nx_dev_request_reset(struct netxen_adapter *adapter)
2395 if (netxen_api_lock(adapter))
2398 state = NXRD32(adapter, NX_CRB_DEV_STATE);
2400 if (state == NX_DEV_NEED_RESET || state == NX_DEV_FAILED)
2402 else if (state != NX_DEV_INITALIZING && state != NX_DEV_NEED_AER) {
2403 NXWR32(adapter, NX_CRB_DEV_STATE, NX_DEV_NEED_RESET);
2404 adapter->flags |= NETXEN_FW_RESET_OWNER;
2408 netxen_api_unlock(adapter);
2414 netxen_can_start_firmware(struct netxen_adapter *adapter)
2419 if (netxen_api_lock(adapter)) {
2420 nx_incr_dev_ref_cnt(adapter);
2424 count = NXRD32(adapter, NX_CRB_DEV_REF_COUNT);
2426 if ((count < 0) || (count >= NX_MAX_PCI_FUNC))
2431 NXWR32(adapter, NX_CRB_DEV_STATE, NX_DEV_INITALIZING);
2434 NXWR32(adapter, NX_CRB_DEV_REF_COUNT, ++count);
2436 netxen_api_unlock(adapter);
2442 netxen_schedule_work(struct netxen_adapter *adapter,
2443 work_func_t func, int delay)
2445 INIT_DELAYED_WORK(&adapter->fw_work, func);
2446 schedule_delayed_work(&adapter->fw_work, delay);
2450 netxen_cancel_fw_work(struct netxen_adapter *adapter)
2452 while (test_and_set_bit(__NX_RESETTING, &adapter->state))
2455 cancel_delayed_work_sync(&adapter->fw_work);
2459 netxen_attach_work(struct work_struct *work)
2461 struct netxen_adapter *adapter = container_of(work,
2462 struct netxen_adapter, fw_work.work);
2463 struct net_device *netdev = adapter->netdev;
2466 if (netif_running(netdev)) {
2467 err = netxen_nic_attach(adapter);
2471 err = netxen_nic_up(adapter, netdev);
2473 netxen_nic_detach(adapter);
2477 netxen_restore_indev_addr(netdev, NETDEV_UP);
2480 netif_device_attach(netdev);
2483 adapter->fw_fail_cnt = 0;
2484 clear_bit(__NX_RESETTING, &adapter->state);
2485 netxen_schedule_work(adapter, netxen_fw_poll_work, FW_POLL_DELAY);
2489 netxen_fwinit_work(struct work_struct *work)
2491 struct netxen_adapter *adapter = container_of(work,
2492 struct netxen_adapter, fw_work.work);
2495 dev_state = NXRD32(adapter, NX_CRB_DEV_STATE);
2496 if (adapter->flags & NETXEN_FW_RESET_OWNER) {
2497 count = NXRD32(adapter, NX_CRB_DEV_REF_COUNT);
2498 WARN_ON(count == 0);
2500 if (adapter->mdump.md_enabled) {
2502 netxen_dump_fw(adapter);
2505 adapter->flags &= ~NETXEN_FW_RESET_OWNER;
2506 if (netxen_api_lock(adapter)) {
2507 clear_bit(__NX_RESETTING, &adapter->state);
2508 NXWR32(adapter, NX_CRB_DEV_STATE,
2512 count = NXRD32(adapter, NX_CRB_DEV_REF_COUNT);
2513 NXWR32(adapter, NX_CRB_DEV_REF_COUNT, --count);
2514 NXWR32(adapter, NX_CRB_DEV_STATE, NX_DEV_COLD);
2515 dev_state = NX_DEV_COLD;
2516 netxen_api_unlock(adapter);
2520 switch (dev_state) {
2523 if (!netxen_start_firmware(adapter)) {
2524 netxen_schedule_work(adapter, netxen_attach_work, 0);
2529 case NX_DEV_NEED_RESET:
2530 case NX_DEV_INITALIZING:
2531 netxen_schedule_work(adapter,
2532 netxen_fwinit_work, 2 * FW_POLL_DELAY);
2537 nx_incr_dev_ref_cnt(adapter);
2541 if (netxen_api_lock(adapter)) {
2542 clear_bit(__NX_RESETTING, &adapter->state);
2545 NXWR32(adapter, NX_CRB_DEV_STATE, NX_DEV_FAILED);
2546 netxen_api_unlock(adapter);
2547 dev_err(&adapter->pdev->dev, "%s: Device initialization Failed\n",
2548 adapter->netdev->name);
2550 clear_bit(__NX_RESETTING, &adapter->state);
2554 netxen_detach_work(struct work_struct *work)
2556 struct netxen_adapter *adapter = container_of(work,
2557 struct netxen_adapter, fw_work.work);
2558 struct net_device *netdev = adapter->netdev;
2559 int ref_cnt = 0, delay;
2562 netif_device_detach(netdev);
2564 netxen_nic_down(adapter, netdev);
2567 netxen_nic_detach(adapter);
2570 status = NXRD32(adapter, NETXEN_PEG_HALT_STATUS1);
2572 if (status & NX_RCODE_FATAL_ERROR)
2575 if (adapter->temp == NX_TEMP_PANIC)
2578 if (!(adapter->flags & NETXEN_FW_RESET_OWNER))
2579 ref_cnt = nx_decr_dev_ref_cnt(adapter);
2581 if (ref_cnt == -EIO)
2584 delay = (ref_cnt == 0) ? 0 : (2 * FW_POLL_DELAY);
2586 adapter->fw_wait_cnt = 0;
2587 netxen_schedule_work(adapter, netxen_fwinit_work, delay);
2592 clear_bit(__NX_RESETTING, &adapter->state);
2596 netxen_check_health(struct netxen_adapter *adapter)
2598 u32 state, heartbit;
2600 struct net_device *netdev = adapter->netdev;
2602 state = NXRD32(adapter, NX_CRB_DEV_STATE);
2603 if (state == NX_DEV_NEED_AER)
2606 if (netxen_nic_check_temp(adapter))
2609 if (adapter->need_fw_reset) {
2610 if (nx_dev_request_reset(adapter))
2615 /* NX_DEV_NEED_RESET, this state can be marked in two cases
2616 * 1. Tx timeout 2. Fw hang
2617 * Send request to destroy context in case of tx timeout only
2618 * and doesn't required in case of Fw hang
2620 if (state == NX_DEV_NEED_RESET || state == NX_DEV_FAILED) {
2621 adapter->need_fw_reset = 1;
2622 if (NX_IS_REVISION_P2(adapter->ahw.revision_id))
2626 if (NX_IS_REVISION_P2(adapter->ahw.revision_id))
2629 heartbit = NXRD32(adapter, NETXEN_PEG_ALIVE_COUNTER);
2630 if (heartbit != adapter->heartbit) {
2631 adapter->heartbit = heartbit;
2632 adapter->fw_fail_cnt = 0;
2633 if (adapter->need_fw_reset)
2638 if (++adapter->fw_fail_cnt < FW_FAIL_THRESH)
2641 if (nx_dev_request_reset(adapter))
2644 clear_bit(__NX_FW_ATTACHED, &adapter->state);
2646 dev_err(&netdev->dev, "firmware hang detected\n");
2647 peg_status = NXRD32(adapter, NETXEN_PEG_HALT_STATUS1);
2648 dev_err(&adapter->pdev->dev, "Dumping hw/fw registers\n"
2649 "PEG_HALT_STATUS1: 0x%x, PEG_HALT_STATUS2: 0x%x,\n"
2650 "PEG_NET_0_PC: 0x%x, PEG_NET_1_PC: 0x%x,\n"
2651 "PEG_NET_2_PC: 0x%x, PEG_NET_3_PC: 0x%x,\n"
2652 "PEG_NET_4_PC: 0x%x\n",
2654 NXRD32(adapter, NETXEN_PEG_HALT_STATUS2),
2655 NXRD32(adapter, NETXEN_CRB_PEG_NET_0 + 0x3c),
2656 NXRD32(adapter, NETXEN_CRB_PEG_NET_1 + 0x3c),
2657 NXRD32(adapter, NETXEN_CRB_PEG_NET_2 + 0x3c),
2658 NXRD32(adapter, NETXEN_CRB_PEG_NET_3 + 0x3c),
2659 NXRD32(adapter, NETXEN_CRB_PEG_NET_4 + 0x3c));
2660 if (NX_FWERROR_PEGSTAT1(peg_status) == 0x67)
2661 dev_err(&adapter->pdev->dev,
2662 "Firmware aborted with error code 0x00006700. "
2663 "Device is being reset.\n");
2665 if ((auto_fw_reset == AUTO_FW_RESET_ENABLED) &&
2666 !test_and_set_bit(__NX_RESETTING, &adapter->state))
2667 netxen_schedule_work(adapter, netxen_detach_work, 0);
2672 netxen_fw_poll_work(struct work_struct *work)
2674 struct netxen_adapter *adapter = container_of(work,
2675 struct netxen_adapter, fw_work.work);
2677 if (test_bit(__NX_RESETTING, &adapter->state))
2680 if (test_bit(__NX_DEV_UP, &adapter->state)) {
2681 if (!adapter->has_link_events) {
2683 netxen_nic_handle_phy_intr(adapter);
2685 if (adapter->link_changed)
2686 netxen_nic_set_link_parameters(adapter);
2690 if (netxen_check_health(adapter))
2694 netxen_schedule_work(adapter, netxen_fw_poll_work, FW_POLL_DELAY);
2698 netxen_store_bridged_mode(struct device *dev,
2699 struct device_attribute *attr, const char *buf, size_t len)
2701 struct net_device *net = to_net_dev(dev);
2702 struct netxen_adapter *adapter = netdev_priv(net);
2706 if (!(adapter->capabilities & NX_FW_CAPABILITY_BDG))
2709 if (adapter->is_up != NETXEN_ADAPTER_UP_MAGIC)
2712 if (strict_strtoul(buf, 2, &new))
2715 if (!netxen_config_bridged_mode(adapter, !!new))
2723 netxen_show_bridged_mode(struct device *dev,
2724 struct device_attribute *attr, char *buf)
2726 struct net_device *net = to_net_dev(dev);
2727 struct netxen_adapter *adapter;
2728 int bridged_mode = 0;
2730 adapter = netdev_priv(net);
2732 if (adapter->capabilities & NX_FW_CAPABILITY_BDG)
2733 bridged_mode = !!(adapter->flags & NETXEN_NIC_BRIDGE_ENABLED);
2735 return sprintf(buf, "%d\n", bridged_mode);
2738 static struct device_attribute dev_attr_bridged_mode = {
2739 .attr = {.name = "bridged_mode", .mode = (S_IRUGO | S_IWUSR)},
2740 .show = netxen_show_bridged_mode,
2741 .store = netxen_store_bridged_mode,
2745 netxen_store_diag_mode(struct device *dev,
2746 struct device_attribute *attr, const char *buf, size_t len)
2748 struct netxen_adapter *adapter = dev_get_drvdata(dev);
2751 if (strict_strtoul(buf, 2, &new))
2754 if (!!new != !!(adapter->flags & NETXEN_NIC_DIAG_ENABLED))
2755 adapter->flags ^= NETXEN_NIC_DIAG_ENABLED;
2761 netxen_show_diag_mode(struct device *dev,
2762 struct device_attribute *attr, char *buf)
2764 struct netxen_adapter *adapter = dev_get_drvdata(dev);
2766 return sprintf(buf, "%d\n",
2767 !!(adapter->flags & NETXEN_NIC_DIAG_ENABLED));
2770 static struct device_attribute dev_attr_diag_mode = {
2771 .attr = {.name = "diag_mode", .mode = (S_IRUGO | S_IWUSR)},
2772 .show = netxen_show_diag_mode,
2773 .store = netxen_store_diag_mode,
2777 netxen_sysfs_validate_crb(struct netxen_adapter *adapter,
2778 loff_t offset, size_t size)
2780 size_t crb_size = 4;
2782 if (!(adapter->flags & NETXEN_NIC_DIAG_ENABLED))
2785 if (offset < NETXEN_PCI_CRBSPACE) {
2786 if (NX_IS_REVISION_P2(adapter->ahw.revision_id))
2789 if (ADDR_IN_RANGE(offset, NETXEN_PCI_CAMQM,
2790 NETXEN_PCI_CAMQM_2M_END))
2796 if ((size != crb_size) || (offset & (crb_size-1)))
2803 netxen_sysfs_read_crb(struct file *filp, struct kobject *kobj,
2804 struct bin_attribute *attr,
2805 char *buf, loff_t offset, size_t size)
2807 struct device *dev = container_of(kobj, struct device, kobj);
2808 struct netxen_adapter *adapter = dev_get_drvdata(dev);
2813 ret = netxen_sysfs_validate_crb(adapter, offset, size);
2817 if (NX_IS_REVISION_P3(adapter->ahw.revision_id) &&
2818 ADDR_IN_RANGE(offset, NETXEN_PCI_CAMQM,
2819 NETXEN_PCI_CAMQM_2M_END)) {
2820 netxen_pci_camqm_read_2M(adapter, offset, &qmdata);
2821 memcpy(buf, &qmdata, size);
2823 data = NXRD32(adapter, offset);
2824 memcpy(buf, &data, size);
2831 netxen_sysfs_write_crb(struct file *filp, struct kobject *kobj,
2832 struct bin_attribute *attr,
2833 char *buf, loff_t offset, size_t size)
2835 struct device *dev = container_of(kobj, struct device, kobj);
2836 struct netxen_adapter *adapter = dev_get_drvdata(dev);
2841 ret = netxen_sysfs_validate_crb(adapter, offset, size);
2845 if (NX_IS_REVISION_P3(adapter->ahw.revision_id) &&
2846 ADDR_IN_RANGE(offset, NETXEN_PCI_CAMQM,
2847 NETXEN_PCI_CAMQM_2M_END)) {
2848 memcpy(&qmdata, buf, size);
2849 netxen_pci_camqm_write_2M(adapter, offset, qmdata);
2851 memcpy(&data, buf, size);
2852 NXWR32(adapter, offset, data);
2859 netxen_sysfs_validate_mem(struct netxen_adapter *adapter,
2860 loff_t offset, size_t size)
2862 if (!(adapter->flags & NETXEN_NIC_DIAG_ENABLED))
2865 if ((size != 8) || (offset & 0x7))
2872 netxen_sysfs_read_mem(struct file *filp, struct kobject *kobj,
2873 struct bin_attribute *attr,
2874 char *buf, loff_t offset, size_t size)
2876 struct device *dev = container_of(kobj, struct device, kobj);
2877 struct netxen_adapter *adapter = dev_get_drvdata(dev);
2881 ret = netxen_sysfs_validate_mem(adapter, offset, size);
2885 if (adapter->pci_mem_read(adapter, offset, &data))
2888 memcpy(buf, &data, size);
2893 static ssize_t netxen_sysfs_write_mem(struct file *filp, struct kobject *kobj,
2894 struct bin_attribute *attr, char *buf,
2895 loff_t offset, size_t size)
2897 struct device *dev = container_of(kobj, struct device, kobj);
2898 struct netxen_adapter *adapter = dev_get_drvdata(dev);
2902 ret = netxen_sysfs_validate_mem(adapter, offset, size);
2906 memcpy(&data, buf, size);
2908 if (adapter->pci_mem_write(adapter, offset, data))
2915 static struct bin_attribute bin_attr_crb = {
2916 .attr = {.name = "crb", .mode = (S_IRUGO | S_IWUSR)},
2918 .read = netxen_sysfs_read_crb,
2919 .write = netxen_sysfs_write_crb,
2922 static struct bin_attribute bin_attr_mem = {
2923 .attr = {.name = "mem", .mode = (S_IRUGO | S_IWUSR)},
2925 .read = netxen_sysfs_read_mem,
2926 .write = netxen_sysfs_write_mem,
2931 netxen_create_sysfs_entries(struct netxen_adapter *adapter)
2933 struct device *dev = &adapter->pdev->dev;
2935 if (adapter->capabilities & NX_FW_CAPABILITY_BDG) {
2936 /* bridged_mode control */
2937 if (device_create_file(dev, &dev_attr_bridged_mode)) {
2939 "failed to create bridged_mode sysfs entry\n");
2945 netxen_remove_sysfs_entries(struct netxen_adapter *adapter)
2947 struct device *dev = &adapter->pdev->dev;
2949 if (adapter->capabilities & NX_FW_CAPABILITY_BDG)
2950 device_remove_file(dev, &dev_attr_bridged_mode);
2954 netxen_create_diag_entries(struct netxen_adapter *adapter)
2956 struct pci_dev *pdev = adapter->pdev;
2960 if (device_create_file(dev, &dev_attr_diag_mode))
2961 dev_info(dev, "failed to create diag_mode sysfs entry\n");
2962 if (device_create_bin_file(dev, &bin_attr_crb))
2963 dev_info(dev, "failed to create crb sysfs entry\n");
2964 if (device_create_bin_file(dev, &bin_attr_mem))
2965 dev_info(dev, "failed to create mem sysfs entry\n");
2970 netxen_remove_diag_entries(struct netxen_adapter *adapter)
2972 struct pci_dev *pdev = adapter->pdev;
2973 struct device *dev = &pdev->dev;
2975 device_remove_file(dev, &dev_attr_diag_mode);
2976 device_remove_bin_file(dev, &bin_attr_crb);
2977 device_remove_bin_file(dev, &bin_attr_mem);
2982 #define is_netxen_netdev(dev) (dev->netdev_ops == &netxen_netdev_ops)
2985 netxen_destip_supported(struct netxen_adapter *adapter)
2987 if (NX_IS_REVISION_P2(adapter->ahw.revision_id))
2990 if (adapter->ahw.cut_through)
2997 netxen_free_vlan_ip_list(struct netxen_adapter *adapter)
2999 struct nx_vlan_ip_list *cur;
3000 struct list_head *head = &adapter->vlan_ip_list;
3002 while (!list_empty(head)) {
3003 cur = list_entry(head->next, struct nx_vlan_ip_list, list);
3004 netxen_config_ipaddr(adapter, cur->ip_addr, NX_IP_DOWN);
3005 list_del(&cur->list);
3011 netxen_list_config_vlan_ip(struct netxen_adapter *adapter,
3012 struct in_ifaddr *ifa, unsigned long event)
3014 struct net_device *dev;
3015 struct nx_vlan_ip_list *cur, *tmp_cur;
3016 struct list_head *head;
3018 dev = ifa->ifa_dev ? ifa->ifa_dev->dev : NULL;
3023 if (!is_vlan_dev(dev))
3028 list_for_each(head, &adapter->vlan_ip_list) {
3029 cur = list_entry(head, struct nx_vlan_ip_list, list);
3031 if (cur->ip_addr == ifa->ifa_address)
3035 cur = kzalloc(sizeof(struct nx_vlan_ip_list), GFP_ATOMIC);
3037 printk(KERN_ERR "%s: failed to add vlan ip to list\n",
3038 adapter->netdev->name);
3042 cur->ip_addr = ifa->ifa_address;
3043 list_add_tail(&cur->list, &adapter->vlan_ip_list);
3046 list_for_each_entry_safe(cur, tmp_cur,
3047 &adapter->vlan_ip_list, list) {
3048 if (cur->ip_addr == ifa->ifa_address) {
3049 list_del(&cur->list);
3057 netxen_config_indev_addr(struct netxen_adapter *adapter,
3058 struct net_device *dev, unsigned long event)
3060 struct in_device *indev;
3062 if (!netxen_destip_supported(adapter))
3065 indev = in_dev_get(dev);
3072 netxen_config_ipaddr(adapter,
3073 ifa->ifa_address, NX_IP_UP);
3074 netxen_list_config_vlan_ip(adapter, ifa, NX_IP_UP);
3077 netxen_config_ipaddr(adapter,
3078 ifa->ifa_address, NX_IP_DOWN);
3079 netxen_list_config_vlan_ip(adapter, ifa, NX_IP_DOWN);
3084 } endfor_ifa(indev);
3090 netxen_restore_indev_addr(struct net_device *netdev, unsigned long event)
3093 struct netxen_adapter *adapter = netdev_priv(netdev);
3094 struct nx_vlan_ip_list *pos, *tmp_pos;
3095 unsigned long ip_event;
3097 ip_event = (event == NETDEV_UP) ? NX_IP_UP : NX_IP_DOWN;
3098 netxen_config_indev_addr(adapter, netdev, event);
3100 list_for_each_entry_safe(pos, tmp_pos, &adapter->vlan_ip_list, list) {
3101 netxen_config_ipaddr(adapter, pos->ip_addr, ip_event);
3105 static int netxen_netdev_event(struct notifier_block *this,
3106 unsigned long event, void *ptr)
3108 struct netxen_adapter *adapter;
3109 struct net_device *dev = (struct net_device *)ptr;
3110 struct net_device *orig_dev = dev;
3116 if (dev->priv_flags & IFF_802_1Q_VLAN) {
3117 dev = vlan_dev_real_dev(dev);
3121 if (!is_netxen_netdev(dev))
3124 adapter = netdev_priv(dev);
3129 if (adapter->is_up != NETXEN_ADAPTER_UP_MAGIC)
3132 netxen_config_indev_addr(adapter, orig_dev, event);
3138 netxen_inetaddr_event(struct notifier_block *this,
3139 unsigned long event, void *ptr)
3141 struct netxen_adapter *adapter;
3142 struct net_device *dev;
3144 struct in_ifaddr *ifa = (struct in_ifaddr *)ptr;
3146 dev = ifa->ifa_dev ? ifa->ifa_dev->dev : NULL;
3152 if (dev->priv_flags & IFF_802_1Q_VLAN) {
3153 dev = vlan_dev_real_dev(dev);
3157 if (!is_netxen_netdev(dev))
3160 adapter = netdev_priv(dev);
3162 if (!adapter || !netxen_destip_supported(adapter))
3165 if (adapter->is_up != NETXEN_ADAPTER_UP_MAGIC)
3170 netxen_config_ipaddr(adapter, ifa->ifa_address, NX_IP_UP);
3171 netxen_list_config_vlan_ip(adapter, ifa, NX_IP_UP);
3174 netxen_config_ipaddr(adapter, ifa->ifa_address, NX_IP_DOWN);
3175 netxen_list_config_vlan_ip(adapter, ifa, NX_IP_DOWN);
3185 static struct notifier_block netxen_netdev_cb = {
3186 .notifier_call = netxen_netdev_event,
3189 static struct notifier_block netxen_inetaddr_cb = {
3190 .notifier_call = netxen_inetaddr_event,
3194 netxen_restore_indev_addr(struct net_device *dev, unsigned long event)
3197 netxen_free_vlan_ip_list(struct netxen_adapter *adapter)
3201 static struct pci_error_handlers netxen_err_handler = {
3202 .error_detected = netxen_io_error_detected,
3203 .slot_reset = netxen_io_slot_reset,
3204 .resume = netxen_io_resume,
3207 static struct pci_driver netxen_driver = {
3208 .name = netxen_nic_driver_name,
3209 .id_table = netxen_pci_tbl,
3210 .probe = netxen_nic_probe,
3211 .remove = __devexit_p(netxen_nic_remove),
3213 .suspend = netxen_nic_suspend,
3214 .resume = netxen_nic_resume,
3216 .shutdown = netxen_nic_shutdown,
3217 .err_handler = &netxen_err_handler
3220 static int __init netxen_init_module(void)
3222 printk(KERN_INFO "%s\n", netxen_nic_driver_string);
3225 register_netdevice_notifier(&netxen_netdev_cb);
3226 register_inetaddr_notifier(&netxen_inetaddr_cb);
3228 return pci_register_driver(&netxen_driver);
3231 module_init(netxen_init_module);
3233 static void __exit netxen_exit_module(void)
3235 pci_unregister_driver(&netxen_driver);
3238 unregister_inetaddr_notifier(&netxen_inetaddr_cb);
3239 unregister_netdevice_notifier(&netxen_netdev_cb);
3243 module_exit(netxen_exit_module);