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
);
86 static int nx_dev_request_aer(struct netxen_adapter
*adapter
);
87 static int nx_decr_dev_ref_cnt(struct netxen_adapter
*adapter
);
88 static int netxen_can_start_firmware(struct netxen_adapter
*adapter
);
90 static irqreturn_t
netxen_intr(int irq
, void *data
);
91 static irqreturn_t
netxen_msi_intr(int irq
, void *data
);
92 static irqreturn_t
netxen_msix_intr(int irq
, void *data
);
94 static void netxen_config_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 static void netxen_set_msix_bit(struct pci_dev
*pdev
, int enable
)
407 pos
= pci_find_capability(pdev
, PCI_CAP_ID_MSIX
);
409 pci_read_config_dword(pdev
, pos
, &control
);
411 control
|= PCI_MSIX_FLAGS_ENABLE
;
414 pci_write_config_dword(pdev
, pos
, control
);
418 static void netxen_init_msix_entries(struct netxen_adapter
*adapter
, int count
)
422 for (i
= 0; i
< count
; i
++)
423 adapter
->msix_entries
[i
].entry
= i
;
427 netxen_read_mac_addr(struct netxen_adapter
*adapter
)
432 struct net_device
*netdev
= adapter
->netdev
;
433 struct pci_dev
*pdev
= adapter
->pdev
;
435 if (NX_IS_REVISION_P3(adapter
->ahw
.revision_id
)) {
436 if (netxen_p3_get_mac_addr(adapter
, &mac_addr
) != 0)
439 if (netxen_get_flash_mac_addr(adapter
, &mac_addr
) != 0)
443 p
= (unsigned char *)&mac_addr
;
444 for (i
= 0; i
< 6; i
++)
445 netdev
->dev_addr
[i
] = *(p
+ 5 - i
);
447 memcpy(netdev
->perm_addr
, netdev
->dev_addr
, netdev
->addr_len
);
448 memcpy(adapter
->mac_addr
, netdev
->dev_addr
, netdev
->addr_len
);
450 /* set station address */
452 if (!is_valid_ether_addr(netdev
->perm_addr
))
453 dev_warn(&pdev
->dev
, "Bad MAC address %pM.\n", netdev
->dev_addr
);
458 static int netxen_nic_set_mac(struct net_device
*netdev
, void *p
)
460 struct netxen_adapter
*adapter
= netdev_priv(netdev
);
461 struct sockaddr
*addr
= p
;
463 if (!is_valid_ether_addr(addr
->sa_data
))
466 if (netif_running(netdev
)) {
467 netif_device_detach(netdev
);
468 netxen_napi_disable(adapter
);
471 memcpy(adapter
->mac_addr
, addr
->sa_data
, netdev
->addr_len
);
472 memcpy(netdev
->dev_addr
, addr
->sa_data
, netdev
->addr_len
);
473 adapter
->macaddr_set(adapter
, addr
->sa_data
);
475 if (netif_running(netdev
)) {
476 netif_device_attach(netdev
);
477 netxen_napi_enable(adapter
);
482 static void netxen_set_multicast_list(struct net_device
*dev
)
484 struct netxen_adapter
*adapter
= netdev_priv(dev
);
486 adapter
->set_multi(dev
);
489 static u32
netxen_fix_features(struct net_device
*dev
, u32 features
)
491 if (!(features
& NETIF_F_RXCSUM
)) {
492 netdev_info(dev
, "disabling LRO as RXCSUM is off\n");
494 features
&= ~NETIF_F_LRO
;
500 static int netxen_set_features(struct net_device
*dev
, u32 features
)
502 struct netxen_adapter
*adapter
= netdev_priv(dev
);
505 if (!((dev
->features
^ features
) & NETIF_F_LRO
))
508 hw_lro
= (features
& NETIF_F_LRO
) ? NETXEN_NIC_LRO_ENABLED
509 : NETXEN_NIC_LRO_DISABLED
;
511 if (netxen_config_hw_lro(adapter
, hw_lro
))
514 if (!(features
& NETIF_F_LRO
) && netxen_send_lro_cleanup(adapter
))
520 static const struct net_device_ops netxen_netdev_ops
= {
521 .ndo_open
= netxen_nic_open
,
522 .ndo_stop
= netxen_nic_close
,
523 .ndo_start_xmit
= netxen_nic_xmit_frame
,
524 .ndo_get_stats64
= netxen_nic_get_stats
,
525 .ndo_validate_addr
= eth_validate_addr
,
526 .ndo_set_multicast_list
= netxen_set_multicast_list
,
527 .ndo_set_mac_address
= netxen_nic_set_mac
,
528 .ndo_change_mtu
= netxen_nic_change_mtu
,
529 .ndo_tx_timeout
= netxen_tx_timeout
,
530 .ndo_fix_features
= netxen_fix_features
,
531 .ndo_set_features
= netxen_set_features
,
532 #ifdef CONFIG_NET_POLL_CONTROLLER
533 .ndo_poll_controller
= netxen_nic_poll_controller
,
538 netxen_setup_intr(struct netxen_adapter
*adapter
)
540 struct netxen_legacy_intr_set
*legacy_intrp
;
541 struct pci_dev
*pdev
= adapter
->pdev
;
544 if (adapter
->rss_supported
) {
545 num_msix
= (num_online_cpus() >= MSIX_ENTRIES_PER_ADAPTER
) ?
546 MSIX_ENTRIES_PER_ADAPTER
: 2;
550 adapter
->max_sds_rings
= 1;
552 adapter
->flags
&= ~(NETXEN_NIC_MSI_ENABLED
| NETXEN_NIC_MSIX_ENABLED
);
554 if (adapter
->ahw
.revision_id
>= NX_P3_B0
)
555 legacy_intrp
= &legacy_intr
[adapter
->ahw
.pci_func
];
557 legacy_intrp
= &legacy_intr
[0];
559 adapter
->int_vec_bit
= legacy_intrp
->int_vec_bit
;
560 adapter
->tgt_status_reg
= netxen_get_ioaddr(adapter
,
561 legacy_intrp
->tgt_status_reg
);
562 adapter
->tgt_mask_reg
= netxen_get_ioaddr(adapter
,
563 legacy_intrp
->tgt_mask_reg
);
564 adapter
->pci_int_reg
= netxen_get_ioaddr(adapter
,
565 legacy_intrp
->pci_int_reg
);
566 adapter
->isr_int_vec
= netxen_get_ioaddr(adapter
, ISR_INT_VECTOR
);
568 if (adapter
->ahw
.revision_id
>= NX_P3_B1
)
569 adapter
->crb_int_state_reg
= netxen_get_ioaddr(adapter
,
572 adapter
->crb_int_state_reg
= netxen_get_ioaddr(adapter
,
575 netxen_set_msix_bit(pdev
, 0);
577 if (adapter
->msix_supported
) {
579 netxen_init_msix_entries(adapter
, num_msix
);
580 err
= pci_enable_msix(pdev
, adapter
->msix_entries
, num_msix
);
582 adapter
->flags
|= NETXEN_NIC_MSIX_ENABLED
;
583 netxen_set_msix_bit(pdev
, 1);
585 if (adapter
->rss_supported
)
586 adapter
->max_sds_rings
= num_msix
;
588 dev_info(&pdev
->dev
, "using msi-x interrupts\n");
593 pci_disable_msix(pdev
);
595 /* fall through for msi */
598 if (use_msi
&& !pci_enable_msi(pdev
)) {
599 adapter
->flags
|= NETXEN_NIC_MSI_ENABLED
;
600 adapter
->tgt_status_reg
= netxen_get_ioaddr(adapter
,
601 msi_tgt_status
[adapter
->ahw
.pci_func
]);
602 dev_info(&pdev
->dev
, "using msi interrupts\n");
603 adapter
->msix_entries
[0].vector
= pdev
->irq
;
607 dev_info(&pdev
->dev
, "using legacy interrupts\n");
608 adapter
->msix_entries
[0].vector
= pdev
->irq
;
612 netxen_teardown_intr(struct netxen_adapter
*adapter
)
614 if (adapter
->flags
& NETXEN_NIC_MSIX_ENABLED
)
615 pci_disable_msix(adapter
->pdev
);
616 if (adapter
->flags
& NETXEN_NIC_MSI_ENABLED
)
617 pci_disable_msi(adapter
->pdev
);
621 netxen_cleanup_pci_map(struct netxen_adapter
*adapter
)
623 if (adapter
->ahw
.db_base
!= NULL
)
624 iounmap(adapter
->ahw
.db_base
);
625 if (adapter
->ahw
.pci_base0
!= NULL
)
626 iounmap(adapter
->ahw
.pci_base0
);
627 if (adapter
->ahw
.pci_base1
!= NULL
)
628 iounmap(adapter
->ahw
.pci_base1
);
629 if (adapter
->ahw
.pci_base2
!= NULL
)
630 iounmap(adapter
->ahw
.pci_base2
);
634 netxen_setup_pci_map(struct netxen_adapter
*adapter
)
636 void __iomem
*db_ptr
= NULL
;
638 resource_size_t mem_base
, db_base
;
639 unsigned long mem_len
, db_len
= 0;
641 struct pci_dev
*pdev
= adapter
->pdev
;
642 int pci_func
= adapter
->ahw
.pci_func
;
643 struct netxen_hardware_context
*ahw
= &adapter
->ahw
;
648 * Set the CRB window to invalid. If any register in window 0 is
649 * accessed it should set the window to 0 and then reset it to 1.
651 adapter
->ahw
.crb_win
= -1;
652 adapter
->ahw
.ocm_win
= -1;
654 /* remap phys address */
655 mem_base
= pci_resource_start(pdev
, 0); /* 0 is for BAR 0 */
656 mem_len
= pci_resource_len(pdev
, 0);
658 /* 128 Meg of memory */
659 if (mem_len
== NETXEN_PCI_128MB_SIZE
) {
661 ahw
->pci_base0
= ioremap(mem_base
, FIRST_PAGE_GROUP_SIZE
);
662 ahw
->pci_base1
= ioremap(mem_base
+ SECOND_PAGE_GROUP_START
,
663 SECOND_PAGE_GROUP_SIZE
);
664 ahw
->pci_base2
= ioremap(mem_base
+ THIRD_PAGE_GROUP_START
,
665 THIRD_PAGE_GROUP_SIZE
);
666 if (ahw
->pci_base0
== NULL
|| ahw
->pci_base1
== NULL
||
667 ahw
->pci_base2
== NULL
) {
668 dev_err(&pdev
->dev
, "failed to map PCI bar 0\n");
673 ahw
->pci_len0
= FIRST_PAGE_GROUP_SIZE
;
675 } else if (mem_len
== NETXEN_PCI_32MB_SIZE
) {
677 ahw
->pci_base1
= ioremap(mem_base
, SECOND_PAGE_GROUP_SIZE
);
678 ahw
->pci_base2
= ioremap(mem_base
+ THIRD_PAGE_GROUP_START
-
679 SECOND_PAGE_GROUP_START
, THIRD_PAGE_GROUP_SIZE
);
680 if (ahw
->pci_base1
== NULL
|| ahw
->pci_base2
== NULL
) {
681 dev_err(&pdev
->dev
, "failed to map PCI bar 0\n");
686 } else if (mem_len
== NETXEN_PCI_2MB_SIZE
) {
688 ahw
->pci_base0
= pci_ioremap_bar(pdev
, 0);
689 if (ahw
->pci_base0
== NULL
) {
690 dev_err(&pdev
->dev
, "failed to map PCI bar 0\n");
693 ahw
->pci_len0
= mem_len
;
698 netxen_setup_hwops(adapter
);
700 dev_info(&pdev
->dev
, "%dMB memory map\n", (int)(mem_len
>>20));
702 if (NX_IS_REVISION_P3P(adapter
->ahw
.revision_id
)) {
703 adapter
->ahw
.ocm_win_crb
= netxen_get_ioaddr(adapter
,
704 NETXEN_PCIX_PS_REG(PCIX_OCM_WINDOW_REG(pci_func
)));
706 } else if (NX_IS_REVISION_P3(adapter
->ahw
.revision_id
)) {
707 adapter
->ahw
.ocm_win_crb
= netxen_get_ioaddr(adapter
,
708 NETXEN_PCIX_PS_REG(PCIE_MN_WINDOW_REG(pci_func
)));
711 if (NX_IS_REVISION_P3(adapter
->ahw
.revision_id
))
714 db_base
= pci_resource_start(pdev
, 4); /* doorbell is on bar 4 */
715 db_len
= pci_resource_len(pdev
, 4);
718 printk(KERN_ERR
"%s: doorbell is disabled\n",
719 netxen_nic_driver_name
);
724 db_ptr
= ioremap(db_base
, NETXEN_DB_MAPSIZE_BYTES
);
726 printk(KERN_ERR
"%s: Failed to allocate doorbell map.",
727 netxen_nic_driver_name
);
733 adapter
->ahw
.db_base
= db_ptr
;
734 adapter
->ahw
.db_len
= db_len
;
738 netxen_cleanup_pci_map(adapter
);
743 netxen_check_options(struct netxen_adapter
*adapter
)
745 u32 fw_major
, fw_minor
, fw_build
;
746 char brd_name
[NETXEN_MAX_SHORT_NAME
];
750 struct pci_dev
*pdev
= adapter
->pdev
;
752 adapter
->driver_mismatch
= 0;
754 ptr32
= (int *)&serial_num
;
755 offset
= NX_FW_SERIAL_NUM_OFFSET
;
756 for (i
= 0; i
< 8; i
++) {
757 if (netxen_rom_fast_read(adapter
, offset
, &val
) == -1) {
758 dev_err(&pdev
->dev
, "error reading board info\n");
759 adapter
->driver_mismatch
= 1;
762 ptr32
[i
] = cpu_to_le32(val
);
763 offset
+= sizeof(u32
);
766 fw_major
= NXRD32(adapter
, NETXEN_FW_VERSION_MAJOR
);
767 fw_minor
= NXRD32(adapter
, NETXEN_FW_VERSION_MINOR
);
768 fw_build
= NXRD32(adapter
, NETXEN_FW_VERSION_SUB
);
770 adapter
->fw_version
= NETXEN_VERSION_CODE(fw_major
, fw_minor
, fw_build
);
772 if (adapter
->portnum
== 0) {
773 get_brd_name_by_type(adapter
->ahw
.board_type
, brd_name
);
775 pr_info("%s: %s Board S/N %s Chip rev 0x%x\n",
776 module_name(THIS_MODULE
),
777 brd_name
, serial_num
, adapter
->ahw
.revision_id
);
780 if (adapter
->fw_version
< NETXEN_VERSION_CODE(3, 4, 216)) {
781 adapter
->driver_mismatch
= 1;
782 dev_warn(&pdev
->dev
, "firmware version %d.%d.%d unsupported\n",
783 fw_major
, fw_minor
, fw_build
);
787 if (NX_IS_REVISION_P3(adapter
->ahw
.revision_id
)) {
788 i
= NXRD32(adapter
, NETXEN_SRE_MISC
);
789 adapter
->ahw
.cut_through
= (i
& 0x8000) ? 1 : 0;
792 dev_info(&pdev
->dev
, "firmware v%d.%d.%d [%s]\n",
793 fw_major
, fw_minor
, fw_build
,
794 adapter
->ahw
.cut_through
? "cut-through" : "legacy");
796 if (adapter
->fw_version
>= NETXEN_VERSION_CODE(4, 0, 222))
797 adapter
->capabilities
= NXRD32(adapter
, CRB_FW_CAPABILITIES_1
);
799 if (adapter
->ahw
.port_type
== NETXEN_NIC_XGBE
) {
800 adapter
->num_rxd
= DEFAULT_RCV_DESCRIPTORS_10G
;
801 adapter
->num_jumbo_rxd
= MAX_JUMBO_RCV_DESCRIPTORS_10G
;
802 } else if (adapter
->ahw
.port_type
== NETXEN_NIC_GBE
) {
803 adapter
->num_rxd
= DEFAULT_RCV_DESCRIPTORS_1G
;
804 adapter
->num_jumbo_rxd
= MAX_JUMBO_RCV_DESCRIPTORS_1G
;
807 adapter
->msix_supported
= 0;
808 if (NX_IS_REVISION_P3(adapter
->ahw
.revision_id
)) {
809 adapter
->msix_supported
= !!use_msi_x
;
810 adapter
->rss_supported
= !!use_msi_x
;
813 netxen_rom_fast_read(adapter
,
814 NX_FW_VERSION_OFFSET
, (int *)&flashed_ver
);
815 flashed_ver
= NETXEN_DECODE_VERSION(flashed_ver
);
817 if (flashed_ver
>= NETXEN_VERSION_CODE(3, 4, 336)) {
818 switch (adapter
->ahw
.board_type
) {
819 case NETXEN_BRDTYPE_P2_SB31_10G
:
820 case NETXEN_BRDTYPE_P2_SB31_10G_CX4
:
821 adapter
->msix_supported
= !!use_msi_x
;
822 adapter
->rss_supported
= !!use_msi_x
;
830 adapter
->num_txd
= MAX_CMD_DESCRIPTORS
;
832 if (NX_IS_REVISION_P2(adapter
->ahw
.revision_id
)) {
833 adapter
->num_lro_rxd
= MAX_LRO_RCV_DESCRIPTORS
;
834 adapter
->max_rds_rings
= 3;
836 adapter
->num_lro_rxd
= 0;
837 adapter
->max_rds_rings
= 2;
842 netxen_start_firmware(struct netxen_adapter
*adapter
)
844 int val
, err
, first_boot
;
845 struct pci_dev
*pdev
= adapter
->pdev
;
847 /* required for NX2031 dummy dma */
848 err
= nx_set_dma_mask(adapter
);
852 if (!netxen_can_start_firmware(adapter
))
855 first_boot
= NXRD32(adapter
, NETXEN_CAM_RAM(0x1fc));
857 err
= netxen_check_hw_init(adapter
, first_boot
);
859 dev_err(&pdev
->dev
, "error in init HW init sequence\n");
863 netxen_request_firmware(adapter
);
865 err
= netxen_need_fw_reset(adapter
);
871 if (first_boot
!= 0x55555555) {
872 NXWR32(adapter
, CRB_CMDPEG_STATE
, 0);
873 netxen_pinit_from_rom(adapter
);
877 NXWR32(adapter
, CRB_DMA_SHIFT
, 0x55555555);
878 NXWR32(adapter
, NETXEN_PEG_HALT_STATUS1
, 0);
879 NXWR32(adapter
, NETXEN_PEG_HALT_STATUS2
, 0);
881 if (NX_IS_REVISION_P3(adapter
->ahw
.revision_id
))
882 netxen_set_port_mode(adapter
);
884 err
= netxen_load_firmware(adapter
);
888 netxen_release_firmware(adapter
);
890 if (NX_IS_REVISION_P2(adapter
->ahw
.revision_id
)) {
892 /* Initialize multicast addr pool owners */
894 if (adapter
->ahw
.port_type
== NETXEN_NIC_XGBE
)
896 NXWR32(adapter
, NETXEN_MAC_ADDR_CNTL_REG
, val
);
900 err
= netxen_init_dummy_dma(adapter
);
905 * Tell the hardware our version number.
907 val
= (_NETXEN_NIC_LINUX_MAJOR
<< 16)
908 | ((_NETXEN_NIC_LINUX_MINOR
<< 8))
909 | (_NETXEN_NIC_LINUX_SUBVERSION
);
910 NXWR32(adapter
, CRB_DRIVER_VERSION
, val
);
913 /* Handshake with the card before we register the devices. */
914 err
= netxen_phantom_init(adapter
, NETXEN_NIC_PEG_TUNE
);
916 netxen_free_dummy_dma(adapter
);
920 NXWR32(adapter
, NX_CRB_DEV_STATE
, NX_DEV_READY
);
922 nx_update_dma_mask(adapter
);
924 netxen_check_options(adapter
);
926 adapter
->need_fw_reset
= 0;
928 /* fall through and release firmware */
931 netxen_release_firmware(adapter
);
936 netxen_nic_request_irq(struct netxen_adapter
*adapter
)
938 irq_handler_t handler
;
939 struct nx_host_sds_ring
*sds_ring
;
942 unsigned long flags
= 0;
943 struct net_device
*netdev
= adapter
->netdev
;
944 struct netxen_recv_context
*recv_ctx
= &adapter
->recv_ctx
;
946 if (adapter
->flags
& NETXEN_NIC_MSIX_ENABLED
)
947 handler
= netxen_msix_intr
;
948 else if (adapter
->flags
& NETXEN_NIC_MSI_ENABLED
)
949 handler
= netxen_msi_intr
;
951 flags
|= IRQF_SHARED
;
952 handler
= netxen_intr
;
954 adapter
->irq
= netdev
->irq
;
956 for (ring
= 0; ring
< adapter
->max_sds_rings
; ring
++) {
957 sds_ring
= &recv_ctx
->sds_rings
[ring
];
958 sprintf(sds_ring
->name
, "%s[%d]", netdev
->name
, ring
);
959 err
= request_irq(sds_ring
->irq
, handler
,
960 flags
, sds_ring
->name
, sds_ring
);
969 netxen_nic_free_irq(struct netxen_adapter
*adapter
)
972 struct nx_host_sds_ring
*sds_ring
;
974 struct netxen_recv_context
*recv_ctx
= &adapter
->recv_ctx
;
976 for (ring
= 0; ring
< adapter
->max_sds_rings
; ring
++) {
977 sds_ring
= &recv_ctx
->sds_rings
[ring
];
978 free_irq(sds_ring
->irq
, sds_ring
);
983 netxen_nic_init_coalesce_defaults(struct netxen_adapter
*adapter
)
985 adapter
->coal
.flags
= NETXEN_NIC_INTR_DEFAULT
;
986 adapter
->coal
.normal
.data
.rx_time_us
=
987 NETXEN_DEFAULT_INTR_COALESCE_RX_TIME_US
;
988 adapter
->coal
.normal
.data
.rx_packets
=
989 NETXEN_DEFAULT_INTR_COALESCE_RX_PACKETS
;
990 adapter
->coal
.normal
.data
.tx_time_us
=
991 NETXEN_DEFAULT_INTR_COALESCE_TX_TIME_US
;
992 adapter
->coal
.normal
.data
.tx_packets
=
993 NETXEN_DEFAULT_INTR_COALESCE_TX_PACKETS
;
998 __netxen_nic_up(struct netxen_adapter
*adapter
, struct net_device
*netdev
)
1002 if (adapter
->is_up
!= NETXEN_ADAPTER_UP_MAGIC
)
1005 err
= adapter
->init_port(adapter
, adapter
->physical_port
);
1007 printk(KERN_ERR
"%s: Failed to initialize port %d\n",
1008 netxen_nic_driver_name
, adapter
->portnum
);
1011 if (NX_IS_REVISION_P2(adapter
->ahw
.revision_id
))
1012 adapter
->macaddr_set(adapter
, adapter
->mac_addr
);
1014 adapter
->set_multi(netdev
);
1015 adapter
->set_mtu(adapter
, netdev
->mtu
);
1017 adapter
->ahw
.linkup
= 0;
1019 if (adapter
->max_sds_rings
> 1)
1020 netxen_config_rss(adapter
, 1);
1022 if (NX_IS_REVISION_P3(adapter
->ahw
.revision_id
))
1023 netxen_config_intr_coalesce(adapter
);
1025 if (netdev
->features
& NETIF_F_LRO
)
1026 netxen_config_hw_lro(adapter
, NETXEN_NIC_LRO_ENABLED
);
1028 netxen_napi_enable(adapter
);
1030 if (adapter
->capabilities
& NX_FW_CAPABILITY_LINK_NOTIFICATION
)
1031 netxen_linkevent_request(adapter
, 1);
1033 netxen_nic_set_link_parameters(adapter
);
1035 set_bit(__NX_DEV_UP
, &adapter
->state
);
1039 /* Usage: During resume and firmware recovery module.*/
1042 netxen_nic_up(struct netxen_adapter
*adapter
, struct net_device
*netdev
)
1047 if (netif_running(netdev
))
1048 err
= __netxen_nic_up(adapter
, netdev
);
1054 /* with rtnl_lock */
1056 __netxen_nic_down(struct netxen_adapter
*adapter
, struct net_device
*netdev
)
1058 if (adapter
->is_up
!= NETXEN_ADAPTER_UP_MAGIC
)
1061 if (!test_and_clear_bit(__NX_DEV_UP
, &adapter
->state
))
1065 spin_lock(&adapter
->tx_clean_lock
);
1066 netif_carrier_off(netdev
);
1067 netif_tx_disable(netdev
);
1069 if (adapter
->capabilities
& NX_FW_CAPABILITY_LINK_NOTIFICATION
)
1070 netxen_linkevent_request(adapter
, 0);
1072 if (adapter
->stop_port
)
1073 adapter
->stop_port(adapter
);
1075 if (NX_IS_REVISION_P3(adapter
->ahw
.revision_id
))
1076 netxen_p3_free_mac_list(adapter
);
1078 adapter
->set_promisc(adapter
, NETXEN_NIU_NON_PROMISC_MODE
);
1080 netxen_napi_disable(adapter
);
1082 netxen_release_tx_buffers(adapter
);
1083 spin_unlock(&adapter
->tx_clean_lock
);
1086 /* Usage: During suspend and firmware recovery module */
1089 netxen_nic_down(struct netxen_adapter
*adapter
, struct net_device
*netdev
)
1092 if (netif_running(netdev
))
1093 __netxen_nic_down(adapter
, netdev
);
1099 netxen_nic_attach(struct netxen_adapter
*adapter
)
1101 struct net_device
*netdev
= adapter
->netdev
;
1102 struct pci_dev
*pdev
= adapter
->pdev
;
1104 struct nx_host_rds_ring
*rds_ring
;
1105 struct nx_host_tx_ring
*tx_ring
;
1107 if (adapter
->is_up
== NETXEN_ADAPTER_UP_MAGIC
)
1110 err
= netxen_init_firmware(adapter
);
1114 err
= netxen_napi_add(adapter
, netdev
);
1118 err
= netxen_alloc_sw_resources(adapter
);
1120 printk(KERN_ERR
"%s: Error in setting sw resources\n",
1125 err
= netxen_alloc_hw_resources(adapter
);
1127 printk(KERN_ERR
"%s: Error in setting hw resources\n",
1129 goto err_out_free_sw
;
1132 if (NX_IS_REVISION_P2(adapter
->ahw
.revision_id
)) {
1133 tx_ring
= adapter
->tx_ring
;
1134 tx_ring
->crb_cmd_producer
= netxen_get_ioaddr(adapter
,
1135 crb_cmd_producer
[adapter
->portnum
]);
1136 tx_ring
->crb_cmd_consumer
= netxen_get_ioaddr(adapter
,
1137 crb_cmd_consumer
[adapter
->portnum
]);
1139 tx_ring
->producer
= 0;
1140 tx_ring
->sw_consumer
= 0;
1142 netxen_nic_update_cmd_producer(adapter
, tx_ring
);
1143 netxen_nic_update_cmd_consumer(adapter
, tx_ring
);
1146 for (ring
= 0; ring
< adapter
->max_rds_rings
; ring
++) {
1147 rds_ring
= &adapter
->recv_ctx
.rds_rings
[ring
];
1148 netxen_post_rx_buffers(adapter
, ring
, rds_ring
);
1151 err
= netxen_nic_request_irq(adapter
);
1153 dev_err(&pdev
->dev
, "%s: failed to setup interrupt\n",
1155 goto err_out_free_rxbuf
;
1158 if (NX_IS_REVISION_P3(adapter
->ahw
.revision_id
))
1159 netxen_nic_init_coalesce_defaults(adapter
);
1161 netxen_create_sysfs_entries(adapter
);
1163 adapter
->is_up
= NETXEN_ADAPTER_UP_MAGIC
;
1167 netxen_release_rx_buffers(adapter
);
1168 netxen_free_hw_resources(adapter
);
1170 netxen_free_sw_resources(adapter
);
1175 netxen_nic_detach(struct netxen_adapter
*adapter
)
1177 if (adapter
->is_up
!= NETXEN_ADAPTER_UP_MAGIC
)
1180 netxen_remove_sysfs_entries(adapter
);
1182 netxen_free_hw_resources(adapter
);
1183 netxen_release_rx_buffers(adapter
);
1184 netxen_nic_free_irq(adapter
);
1185 netxen_napi_del(adapter
);
1186 netxen_free_sw_resources(adapter
);
1192 netxen_nic_reset_context(struct netxen_adapter
*adapter
)
1195 struct net_device
*netdev
= adapter
->netdev
;
1197 if (test_and_set_bit(__NX_RESETTING
, &adapter
->state
))
1200 if (adapter
->is_up
== NETXEN_ADAPTER_UP_MAGIC
) {
1202 netif_device_detach(netdev
);
1204 if (netif_running(netdev
))
1205 __netxen_nic_down(adapter
, netdev
);
1207 netxen_nic_detach(adapter
);
1209 if (netif_running(netdev
)) {
1210 err
= netxen_nic_attach(adapter
);
1212 err
= __netxen_nic_up(adapter
, netdev
);
1218 netif_device_attach(netdev
);
1222 clear_bit(__NX_RESETTING
, &adapter
->state
);
1227 netxen_setup_netdev(struct netxen_adapter
*adapter
,
1228 struct net_device
*netdev
)
1231 struct pci_dev
*pdev
= adapter
->pdev
;
1233 adapter
->mc_enabled
= 0;
1234 if (NX_IS_REVISION_P3(adapter
->ahw
.revision_id
))
1235 adapter
->max_mc_count
= 38;
1237 adapter
->max_mc_count
= 16;
1239 netdev
->netdev_ops
= &netxen_netdev_ops
;
1240 netdev
->watchdog_timeo
= 5*HZ
;
1242 netxen_nic_change_mtu(netdev
, netdev
->mtu
);
1244 SET_ETHTOOL_OPS(netdev
, &netxen_nic_ethtool_ops
);
1246 netdev
->hw_features
= NETIF_F_SG
| NETIF_F_IP_CSUM
| NETIF_F_TSO
|
1249 if (NX_IS_REVISION_P3(adapter
->ahw
.revision_id
))
1250 netdev
->hw_features
|= NETIF_F_IPV6_CSUM
| NETIF_F_TSO6
;
1252 netdev
->vlan_features
|= netdev
->hw_features
;
1254 if (adapter
->pci_using_dac
) {
1255 netdev
->features
|= NETIF_F_HIGHDMA
;
1256 netdev
->vlan_features
|= NETIF_F_HIGHDMA
;
1259 if (adapter
->capabilities
& NX_FW_CAPABILITY_FVLANTX
)
1260 netdev
->hw_features
|= NETIF_F_HW_VLAN_TX
;
1262 if (adapter
->capabilities
& NX_FW_CAPABILITY_HW_LRO
)
1263 netdev
->hw_features
|= NETIF_F_LRO
;
1265 netdev
->features
|= netdev
->hw_features
;
1267 netdev
->irq
= adapter
->msix_entries
[0].vector
;
1269 INIT_WORK(&adapter
->tx_timeout_task
, netxen_tx_timeout_task
);
1271 if (netxen_read_mac_addr(adapter
))
1272 dev_warn(&pdev
->dev
, "failed to read mac addr\n");
1274 netif_carrier_off(netdev
);
1276 err
= register_netdev(netdev
);
1278 dev_err(&pdev
->dev
, "failed to register net device\n");
1285 #ifdef CONFIG_PCIEAER
1286 static void netxen_mask_aer_correctable(struct netxen_adapter
*adapter
)
1288 struct pci_dev
*pdev
= adapter
->pdev
;
1289 struct pci_dev
*root
= pdev
->bus
->self
;
1292 if (adapter
->ahw
.board_type
!= NETXEN_BRDTYPE_P3_4_GB_MM
&&
1293 adapter
->ahw
.board_type
!= NETXEN_BRDTYPE_P3_10G_TP
)
1296 if (root
->pcie_type
!= PCI_EXP_TYPE_ROOT_PORT
)
1299 aer_pos
= pci_find_ext_capability(root
, PCI_EXT_CAP_ID_ERR
);
1303 pci_write_config_dword(root
, aer_pos
+ PCI_ERR_COR_MASK
, 0xffff);
1307 static int __devinit
1308 netxen_nic_probe(struct pci_dev
*pdev
, const struct pci_device_id
*ent
)
1310 struct net_device
*netdev
= NULL
;
1311 struct netxen_adapter
*adapter
= NULL
;
1313 int pci_func_id
= PCI_FUNC(pdev
->devfn
);
1314 uint8_t revision_id
;
1317 if (pdev
->revision
>= NX_P3_A0
&& pdev
->revision
<= NX_P3_B1
) {
1318 pr_warning("%s: chip revisions between 0x%x-0x%x "
1319 "will not be enabled.\n",
1320 module_name(THIS_MODULE
), NX_P3_A0
, NX_P3_B1
);
1324 if ((err
= pci_enable_device(pdev
)))
1327 if (!(pci_resource_flags(pdev
, 0) & IORESOURCE_MEM
)) {
1329 goto err_out_disable_pdev
;
1332 if ((err
= pci_request_regions(pdev
, netxen_nic_driver_name
)))
1333 goto err_out_disable_pdev
;
1335 if (NX_IS_REVISION_P3(pdev
->revision
))
1336 pci_enable_pcie_error_reporting(pdev
);
1338 pci_set_master(pdev
);
1340 netdev
= alloc_etherdev(sizeof(struct netxen_adapter
));
1342 dev_err(&pdev
->dev
, "failed to allocate net_device\n");
1344 goto err_out_free_res
;
1347 SET_NETDEV_DEV(netdev
, &pdev
->dev
);
1349 adapter
= netdev_priv(netdev
);
1350 adapter
->netdev
= netdev
;
1351 adapter
->pdev
= pdev
;
1352 adapter
->ahw
.pci_func
= pci_func_id
;
1354 revision_id
= pdev
->revision
;
1355 adapter
->ahw
.revision_id
= revision_id
;
1357 rwlock_init(&adapter
->ahw
.crb_lock
);
1358 spin_lock_init(&adapter
->ahw
.mem_lock
);
1360 spin_lock_init(&adapter
->tx_clean_lock
);
1361 INIT_LIST_HEAD(&adapter
->mac_list
);
1363 err
= netxen_setup_pci_map(adapter
);
1365 goto err_out_free_netdev
;
1367 /* This will be reset for mezz cards */
1368 adapter
->portnum
= pci_func_id
;
1370 err
= netxen_nic_get_board_info(adapter
);
1372 dev_err(&pdev
->dev
, "Error getting board config info.\n");
1373 goto err_out_iounmap
;
1376 #ifdef CONFIG_PCIEAER
1377 netxen_mask_aer_correctable(adapter
);
1380 /* Mezz cards have PCI function 0,2,3 enabled */
1381 switch (adapter
->ahw
.board_type
) {
1382 case NETXEN_BRDTYPE_P2_SB31_10G_IMEZ
:
1383 case NETXEN_BRDTYPE_P2_SB31_10G_HMEZ
:
1384 if (pci_func_id
>= 2)
1385 adapter
->portnum
= pci_func_id
- 2;
1391 err
= netxen_check_flash_fw_compatibility(adapter
);
1393 goto err_out_iounmap
;
1395 if (adapter
->portnum
== 0) {
1396 val
= NXRD32(adapter
, NX_CRB_DEV_REF_COUNT
);
1397 if (val
!= 0xffffffff && val
!= 0) {
1398 NXWR32(adapter
, NX_CRB_DEV_REF_COUNT
, 0);
1399 adapter
->need_fw_reset
= 1;
1403 err
= netxen_start_firmware(adapter
);
1405 goto err_out_decr_ref
;
1408 * See if the firmware gave us a virtual-physical port mapping.
1410 adapter
->physical_port
= adapter
->portnum
;
1411 if (NX_IS_REVISION_P2(adapter
->ahw
.revision_id
)) {
1412 i
= NXRD32(adapter
, CRB_V2P(adapter
->portnum
));
1413 if (i
!= 0x55555555)
1414 adapter
->physical_port
= i
;
1417 netxen_nic_clear_stats(adapter
);
1419 netxen_setup_intr(adapter
);
1421 err
= netxen_setup_netdev(adapter
, netdev
);
1423 goto err_out_disable_msi
;
1425 pci_set_drvdata(pdev
, adapter
);
1427 netxen_schedule_work(adapter
, netxen_fw_poll_work
, FW_POLL_DELAY
);
1429 switch (adapter
->ahw
.port_type
) {
1430 case NETXEN_NIC_GBE
:
1431 dev_info(&adapter
->pdev
->dev
, "%s: GbE port initialized\n",
1432 adapter
->netdev
->name
);
1434 case NETXEN_NIC_XGBE
:
1435 dev_info(&adapter
->pdev
->dev
, "%s: XGbE port initialized\n",
1436 adapter
->netdev
->name
);
1440 netxen_create_diag_entries(adapter
);
1444 err_out_disable_msi
:
1445 netxen_teardown_intr(adapter
);
1447 netxen_free_dummy_dma(adapter
);
1450 nx_decr_dev_ref_cnt(adapter
);
1453 netxen_cleanup_pci_map(adapter
);
1455 err_out_free_netdev
:
1456 free_netdev(netdev
);
1459 pci_release_regions(pdev
);
1461 err_out_disable_pdev
:
1462 pci_set_drvdata(pdev
, NULL
);
1463 pci_disable_device(pdev
);
1467 static void __devexit
netxen_nic_remove(struct pci_dev
*pdev
)
1469 struct netxen_adapter
*adapter
;
1470 struct net_device
*netdev
;
1472 adapter
= pci_get_drvdata(pdev
);
1473 if (adapter
== NULL
)
1476 netdev
= adapter
->netdev
;
1478 netxen_cancel_fw_work(adapter
);
1480 unregister_netdev(netdev
);
1482 cancel_work_sync(&adapter
->tx_timeout_task
);
1484 netxen_nic_detach(adapter
);
1486 nx_decr_dev_ref_cnt(adapter
);
1488 if (adapter
->portnum
== 0)
1489 netxen_free_dummy_dma(adapter
);
1491 clear_bit(__NX_RESETTING
, &adapter
->state
);
1493 netxen_teardown_intr(adapter
);
1495 netxen_remove_diag_entries(adapter
);
1497 netxen_cleanup_pci_map(adapter
);
1499 netxen_release_firmware(adapter
);
1501 if (NX_IS_REVISION_P3(pdev
->revision
))
1502 pci_disable_pcie_error_reporting(pdev
);
1504 pci_release_regions(pdev
);
1505 pci_disable_device(pdev
);
1506 pci_set_drvdata(pdev
, NULL
);
1508 free_netdev(netdev
);
1511 static void netxen_nic_detach_func(struct netxen_adapter
*adapter
)
1513 struct net_device
*netdev
= adapter
->netdev
;
1515 netif_device_detach(netdev
);
1517 netxen_cancel_fw_work(adapter
);
1519 if (netif_running(netdev
))
1520 netxen_nic_down(adapter
, netdev
);
1522 cancel_work_sync(&adapter
->tx_timeout_task
);
1524 netxen_nic_detach(adapter
);
1526 if (adapter
->portnum
== 0)
1527 netxen_free_dummy_dma(adapter
);
1529 nx_decr_dev_ref_cnt(adapter
);
1531 clear_bit(__NX_RESETTING
, &adapter
->state
);
1534 static int netxen_nic_attach_func(struct pci_dev
*pdev
)
1536 struct netxen_adapter
*adapter
= pci_get_drvdata(pdev
);
1537 struct net_device
*netdev
= adapter
->netdev
;
1540 err
= pci_enable_device(pdev
);
1544 pci_set_power_state(pdev
, PCI_D0
);
1545 pci_set_master(pdev
);
1546 pci_restore_state(pdev
);
1548 adapter
->ahw
.crb_win
= -1;
1549 adapter
->ahw
.ocm_win
= -1;
1551 err
= netxen_start_firmware(adapter
);
1553 dev_err(&pdev
->dev
, "failed to start firmware\n");
1557 if (netif_running(netdev
)) {
1558 err
= netxen_nic_attach(adapter
);
1562 err
= netxen_nic_up(adapter
, netdev
);
1564 goto err_out_detach
;
1566 netxen_config_indev_addr(netdev
, NETDEV_UP
);
1569 netif_device_attach(netdev
);
1570 netxen_schedule_work(adapter
, netxen_fw_poll_work
, FW_POLL_DELAY
);
1574 netxen_nic_detach(adapter
);
1576 nx_decr_dev_ref_cnt(adapter
);
1580 static pci_ers_result_t
netxen_io_error_detected(struct pci_dev
*pdev
,
1581 pci_channel_state_t state
)
1583 struct netxen_adapter
*adapter
= pci_get_drvdata(pdev
);
1585 if (state
== pci_channel_io_perm_failure
)
1586 return PCI_ERS_RESULT_DISCONNECT
;
1588 if (nx_dev_request_aer(adapter
))
1589 return PCI_ERS_RESULT_RECOVERED
;
1591 netxen_nic_detach_func(adapter
);
1593 pci_disable_device(pdev
);
1595 return PCI_ERS_RESULT_NEED_RESET
;
1598 static pci_ers_result_t
netxen_io_slot_reset(struct pci_dev
*pdev
)
1602 err
= netxen_nic_attach_func(pdev
);
1604 return err
? PCI_ERS_RESULT_DISCONNECT
: PCI_ERS_RESULT_RECOVERED
;
1607 static void netxen_io_resume(struct pci_dev
*pdev
)
1609 pci_cleanup_aer_uncorrect_error_status(pdev
);
1612 static void netxen_nic_shutdown(struct pci_dev
*pdev
)
1614 struct netxen_adapter
*adapter
= pci_get_drvdata(pdev
);
1616 netxen_nic_detach_func(adapter
);
1618 if (pci_save_state(pdev
))
1621 if (netxen_nic_wol_supported(adapter
)) {
1622 pci_enable_wake(pdev
, PCI_D3cold
, 1);
1623 pci_enable_wake(pdev
, PCI_D3hot
, 1);
1626 pci_disable_device(pdev
);
1631 netxen_nic_suspend(struct pci_dev
*pdev
, pm_message_t state
)
1633 struct netxen_adapter
*adapter
= pci_get_drvdata(pdev
);
1636 netxen_nic_detach_func(adapter
);
1638 retval
= pci_save_state(pdev
);
1642 if (netxen_nic_wol_supported(adapter
)) {
1643 pci_enable_wake(pdev
, PCI_D3cold
, 1);
1644 pci_enable_wake(pdev
, PCI_D3hot
, 1);
1647 pci_disable_device(pdev
);
1648 pci_set_power_state(pdev
, pci_choose_state(pdev
, state
));
1654 netxen_nic_resume(struct pci_dev
*pdev
)
1656 return netxen_nic_attach_func(pdev
);
1660 static int netxen_nic_open(struct net_device
*netdev
)
1662 struct netxen_adapter
*adapter
= netdev_priv(netdev
);
1665 if (adapter
->driver_mismatch
)
1668 err
= netxen_nic_attach(adapter
);
1672 err
= __netxen_nic_up(adapter
, netdev
);
1676 netif_start_queue(netdev
);
1681 netxen_nic_detach(adapter
);
1686 * netxen_nic_close - Disables a network interface entry point
1688 static int netxen_nic_close(struct net_device
*netdev
)
1690 struct netxen_adapter
*adapter
= netdev_priv(netdev
);
1692 __netxen_nic_down(adapter
, netdev
);
1697 netxen_tso_check(struct net_device
*netdev
,
1698 struct nx_host_tx_ring
*tx_ring
,
1699 struct cmd_desc_type0
*first_desc
,
1700 struct sk_buff
*skb
)
1702 u8 opcode
= TX_ETHER_PKT
;
1703 __be16 protocol
= skb
->protocol
;
1704 u16 flags
= 0, vid
= 0;
1706 int copied
, offset
, copy_len
, hdr_len
= 0, tso
= 0, vlan_oob
= 0;
1707 struct cmd_desc_type0
*hwdesc
;
1708 struct vlan_ethhdr
*vh
;
1710 if (protocol
== cpu_to_be16(ETH_P_8021Q
)) {
1712 vh
= (struct vlan_ethhdr
*)skb
->data
;
1713 protocol
= vh
->h_vlan_encapsulated_proto
;
1714 flags
= FLAGS_VLAN_TAGGED
;
1716 } else if (vlan_tx_tag_present(skb
)) {
1718 flags
= FLAGS_VLAN_OOB
;
1719 vid
= vlan_tx_tag_get(skb
);
1720 netxen_set_tx_vlan_tci(first_desc
, vid
);
1724 if ((netdev
->features
& (NETIF_F_TSO
| NETIF_F_TSO6
)) &&
1725 skb_shinfo(skb
)->gso_size
> 0) {
1727 hdr_len
= skb_transport_offset(skb
) + tcp_hdrlen(skb
);
1729 first_desc
->mss
= cpu_to_le16(skb_shinfo(skb
)->gso_size
);
1730 first_desc
->total_hdr_length
= hdr_len
;
1732 first_desc
->total_hdr_length
+= VLAN_HLEN
;
1733 first_desc
->tcp_hdr_offset
= VLAN_HLEN
;
1734 first_desc
->ip_hdr_offset
= VLAN_HLEN
;
1735 /* Only in case of TSO on vlan device */
1736 flags
|= FLAGS_VLAN_TAGGED
;
1739 opcode
= (protocol
== cpu_to_be16(ETH_P_IPV6
)) ?
1740 TX_TCP_LSO6
: TX_TCP_LSO
;
1743 } else if (skb
->ip_summed
== CHECKSUM_PARTIAL
) {
1746 if (protocol
== cpu_to_be16(ETH_P_IP
)) {
1747 l4proto
= ip_hdr(skb
)->protocol
;
1749 if (l4proto
== IPPROTO_TCP
)
1750 opcode
= TX_TCP_PKT
;
1751 else if(l4proto
== IPPROTO_UDP
)
1752 opcode
= TX_UDP_PKT
;
1753 } else if (protocol
== cpu_to_be16(ETH_P_IPV6
)) {
1754 l4proto
= ipv6_hdr(skb
)->nexthdr
;
1756 if (l4proto
== IPPROTO_TCP
)
1757 opcode
= TX_TCPV6_PKT
;
1758 else if(l4proto
== IPPROTO_UDP
)
1759 opcode
= TX_UDPV6_PKT
;
1763 first_desc
->tcp_hdr_offset
+= skb_transport_offset(skb
);
1764 first_desc
->ip_hdr_offset
+= skb_network_offset(skb
);
1765 netxen_set_tx_flags_opcode(first_desc
, flags
, opcode
);
1770 /* For LSO, we need to copy the MAC/IP/TCP headers into
1771 * the descriptor ring
1773 producer
= tx_ring
->producer
;
1778 /* Create a TSO vlan header template for firmware */
1780 hwdesc
= &tx_ring
->desc_head
[producer
];
1781 tx_ring
->cmd_buf_arr
[producer
].skb
= NULL
;
1783 copy_len
= min((int)sizeof(struct cmd_desc_type0
) - offset
,
1784 hdr_len
+ VLAN_HLEN
);
1786 vh
= (struct vlan_ethhdr
*)((char *)hwdesc
+ 2);
1787 skb_copy_from_linear_data(skb
, vh
, 12);
1788 vh
->h_vlan_proto
= htons(ETH_P_8021Q
);
1789 vh
->h_vlan_TCI
= htons(vid
);
1790 skb_copy_from_linear_data_offset(skb
, 12,
1791 (char *)vh
+ 16, copy_len
- 16);
1793 copied
= copy_len
- VLAN_HLEN
;
1796 producer
= get_next_index(producer
, tx_ring
->num_desc
);
1799 while (copied
< hdr_len
) {
1801 copy_len
= min((int)sizeof(struct cmd_desc_type0
) - offset
,
1802 (hdr_len
- copied
));
1804 hwdesc
= &tx_ring
->desc_head
[producer
];
1805 tx_ring
->cmd_buf_arr
[producer
].skb
= NULL
;
1807 skb_copy_from_linear_data_offset(skb
, copied
,
1808 (char *)hwdesc
+ offset
, copy_len
);
1813 producer
= get_next_index(producer
, tx_ring
->num_desc
);
1816 tx_ring
->producer
= producer
;
1821 netxen_map_tx_skb(struct pci_dev
*pdev
,
1822 struct sk_buff
*skb
, struct netxen_cmd_buffer
*pbuf
)
1824 struct netxen_skb_frag
*nf
;
1825 struct skb_frag_struct
*frag
;
1829 nr_frags
= skb_shinfo(skb
)->nr_frags
;
1830 nf
= &pbuf
->frag_array
[0];
1832 map
= pci_map_single(pdev
, skb
->data
,
1833 skb_headlen(skb
), PCI_DMA_TODEVICE
);
1834 if (pci_dma_mapping_error(pdev
, map
))
1838 nf
->length
= skb_headlen(skb
);
1840 for (i
= 0; i
< nr_frags
; i
++) {
1841 frag
= &skb_shinfo(skb
)->frags
[i
];
1842 nf
= &pbuf
->frag_array
[i
+1];
1844 map
= pci_map_page(pdev
, frag
->page
, frag
->page_offset
,
1845 frag
->size
, PCI_DMA_TODEVICE
);
1846 if (pci_dma_mapping_error(pdev
, map
))
1850 nf
->length
= frag
->size
;
1857 nf
= &pbuf
->frag_array
[i
+1];
1858 pci_unmap_page(pdev
, nf
->dma
, nf
->length
, PCI_DMA_TODEVICE
);
1861 nf
= &pbuf
->frag_array
[0];
1862 pci_unmap_single(pdev
, nf
->dma
, skb_headlen(skb
), PCI_DMA_TODEVICE
);
1869 netxen_clear_cmddesc(u64
*desc
)
1876 netxen_nic_xmit_frame(struct sk_buff
*skb
, struct net_device
*netdev
)
1878 struct netxen_adapter
*adapter
= netdev_priv(netdev
);
1879 struct nx_host_tx_ring
*tx_ring
= adapter
->tx_ring
;
1880 struct netxen_cmd_buffer
*pbuf
;
1881 struct netxen_skb_frag
*buffrag
;
1882 struct cmd_desc_type0
*hwdesc
, *first_desc
;
1883 struct pci_dev
*pdev
;
1886 struct skb_frag_struct
*frag
;
1889 int frag_count
, no_of_desc
;
1890 u32 num_txd
= tx_ring
->num_desc
;
1892 frag_count
= skb_shinfo(skb
)->nr_frags
+ 1;
1894 /* 14 frags supported for normal packet and
1895 * 32 frags supported for TSO packet
1897 if (!skb_is_gso(skb
) && frag_count
> NETXEN_MAX_FRAGS_PER_TX
) {
1899 for (i
= 0; i
< (frag_count
- NETXEN_MAX_FRAGS_PER_TX
); i
++) {
1900 frag
= &skb_shinfo(skb
)->frags
[i
];
1901 delta
+= frag
->size
;
1904 if (!__pskb_pull_tail(skb
, delta
))
1907 frag_count
= 1 + skb_shinfo(skb
)->nr_frags
;
1909 /* 4 fragments per cmd des */
1910 no_of_desc
= (frag_count
+ 3) >> 2;
1912 if (unlikely(netxen_tx_avail(tx_ring
) <= TX_STOP_THRESH
)) {
1913 netif_stop_queue(netdev
);
1915 if (netxen_tx_avail(tx_ring
) > TX_STOP_THRESH
)
1916 netif_start_queue(netdev
);
1918 return NETDEV_TX_BUSY
;
1921 producer
= tx_ring
->producer
;
1922 pbuf
= &tx_ring
->cmd_buf_arr
[producer
];
1924 pdev
= adapter
->pdev
;
1926 if (netxen_map_tx_skb(pdev
, skb
, pbuf
))
1930 pbuf
->frag_count
= frag_count
;
1932 first_desc
= hwdesc
= &tx_ring
->desc_head
[producer
];
1933 netxen_clear_cmddesc((u64
*)hwdesc
);
1935 netxen_set_tx_frags_len(first_desc
, frag_count
, skb
->len
);
1936 netxen_set_tx_port(first_desc
, adapter
->portnum
);
1938 for (i
= 0; i
< frag_count
; i
++) {
1942 if ((k
== 0) && (i
> 0)) {
1943 /* move to next desc.*/
1944 producer
= get_next_index(producer
, num_txd
);
1945 hwdesc
= &tx_ring
->desc_head
[producer
];
1946 netxen_clear_cmddesc((u64
*)hwdesc
);
1947 tx_ring
->cmd_buf_arr
[producer
].skb
= NULL
;
1950 buffrag
= &pbuf
->frag_array
[i
];
1952 hwdesc
->buffer_length
[k
] = cpu_to_le16(buffrag
->length
);
1955 hwdesc
->addr_buffer1
= cpu_to_le64(buffrag
->dma
);
1958 hwdesc
->addr_buffer2
= cpu_to_le64(buffrag
->dma
);
1961 hwdesc
->addr_buffer3
= cpu_to_le64(buffrag
->dma
);
1964 hwdesc
->addr_buffer4
= cpu_to_le64(buffrag
->dma
);
1969 tx_ring
->producer
= get_next_index(producer
, num_txd
);
1971 netxen_tso_check(netdev
, tx_ring
, first_desc
, skb
);
1973 adapter
->stats
.txbytes
+= skb
->len
;
1974 adapter
->stats
.xmitcalled
++;
1976 netxen_nic_update_cmd_producer(adapter
, tx_ring
);
1978 return NETDEV_TX_OK
;
1981 adapter
->stats
.txdropped
++;
1982 dev_kfree_skb_any(skb
);
1983 return NETDEV_TX_OK
;
1986 static int netxen_nic_check_temp(struct netxen_adapter
*adapter
)
1988 struct net_device
*netdev
= adapter
->netdev
;
1989 uint32_t temp
, temp_state
, temp_val
;
1992 temp
= NXRD32(adapter
, CRB_TEMP_STATE
);
1994 temp_state
= nx_get_temp_state(temp
);
1995 temp_val
= nx_get_temp_val(temp
);
1997 if (temp_state
== NX_TEMP_PANIC
) {
1999 "%s: Device temperature %d degrees C exceeds"
2000 " maximum allowed. Hardware has been shut down.\n",
2001 netdev
->name
, temp_val
);
2003 } else if (temp_state
== NX_TEMP_WARN
) {
2004 if (adapter
->temp
== NX_TEMP_NORMAL
) {
2006 "%s: Device temperature %d degrees C "
2007 "exceeds operating range."
2008 " Immediate action needed.\n",
2009 netdev
->name
, temp_val
);
2012 if (adapter
->temp
== NX_TEMP_WARN
) {
2014 "%s: Device temperature is now %d degrees C"
2015 " in normal range.\n", netdev
->name
,
2019 adapter
->temp
= temp_state
;
2023 void netxen_advert_link_change(struct netxen_adapter
*adapter
, int linkup
)
2025 struct net_device
*netdev
= adapter
->netdev
;
2027 if (adapter
->ahw
.linkup
&& !linkup
) {
2028 printk(KERN_INFO
"%s: %s NIC Link is down\n",
2029 netxen_nic_driver_name
, netdev
->name
);
2030 adapter
->ahw
.linkup
= 0;
2031 if (netif_running(netdev
)) {
2032 netif_carrier_off(netdev
);
2033 netif_stop_queue(netdev
);
2035 adapter
->link_changed
= !adapter
->has_link_events
;
2036 } else if (!adapter
->ahw
.linkup
&& linkup
) {
2037 printk(KERN_INFO
"%s: %s NIC Link is up\n",
2038 netxen_nic_driver_name
, netdev
->name
);
2039 adapter
->ahw
.linkup
= 1;
2040 if (netif_running(netdev
)) {
2041 netif_carrier_on(netdev
);
2042 netif_wake_queue(netdev
);
2044 adapter
->link_changed
= !adapter
->has_link_events
;
2048 static void netxen_nic_handle_phy_intr(struct netxen_adapter
*adapter
)
2050 u32 val
, port
, linkup
;
2052 port
= adapter
->physical_port
;
2054 if (NX_IS_REVISION_P3(adapter
->ahw
.revision_id
)) {
2055 val
= NXRD32(adapter
, CRB_XG_STATE_P3
);
2056 val
= XG_LINK_STATE_P3(adapter
->ahw
.pci_func
, val
);
2057 linkup
= (val
== XG_LINK_UP_P3
);
2059 val
= NXRD32(adapter
, CRB_XG_STATE
);
2060 val
= (val
>> port
*8) & 0xff;
2061 linkup
= (val
== XG_LINK_UP
);
2064 netxen_advert_link_change(adapter
, linkup
);
2067 static void netxen_tx_timeout(struct net_device
*netdev
)
2069 struct netxen_adapter
*adapter
= netdev_priv(netdev
);
2071 if (test_bit(__NX_RESETTING
, &adapter
->state
))
2074 dev_err(&netdev
->dev
, "transmit timeout, resetting.\n");
2075 schedule_work(&adapter
->tx_timeout_task
);
2078 static void netxen_tx_timeout_task(struct work_struct
*work
)
2080 struct netxen_adapter
*adapter
=
2081 container_of(work
, struct netxen_adapter
, tx_timeout_task
);
2083 if (!netif_running(adapter
->netdev
))
2086 if (test_and_set_bit(__NX_RESETTING
, &adapter
->state
))
2089 if (++adapter
->tx_timeo_cnt
>= NX_MAX_TX_TIMEOUTS
)
2093 if (NX_IS_REVISION_P2(adapter
->ahw
.revision_id
)) {
2094 /* try to scrub interrupt */
2095 netxen_napi_disable(adapter
);
2097 netxen_napi_enable(adapter
);
2099 netif_wake_queue(adapter
->netdev
);
2101 clear_bit(__NX_RESETTING
, &adapter
->state
);
2103 clear_bit(__NX_RESETTING
, &adapter
->state
);
2104 if (netxen_nic_reset_context(adapter
)) {
2109 adapter
->netdev
->trans_start
= jiffies
;
2114 adapter
->need_fw_reset
= 1;
2115 clear_bit(__NX_RESETTING
, &adapter
->state
);
2118 static struct rtnl_link_stats64
*netxen_nic_get_stats(struct net_device
*netdev
,
2119 struct rtnl_link_stats64
*stats
)
2121 struct netxen_adapter
*adapter
= netdev_priv(netdev
);
2123 stats
->rx_packets
= adapter
->stats
.rx_pkts
+ adapter
->stats
.lro_pkts
;
2124 stats
->tx_packets
= adapter
->stats
.xmitfinished
;
2125 stats
->rx_bytes
= adapter
->stats
.rxbytes
;
2126 stats
->tx_bytes
= adapter
->stats
.txbytes
;
2127 stats
->rx_dropped
= adapter
->stats
.rxdropped
;
2128 stats
->tx_dropped
= adapter
->stats
.txdropped
;
2133 static irqreturn_t
netxen_intr(int irq
, void *data
)
2135 struct nx_host_sds_ring
*sds_ring
= data
;
2136 struct netxen_adapter
*adapter
= sds_ring
->adapter
;
2139 status
= readl(adapter
->isr_int_vec
);
2141 if (!(status
& adapter
->int_vec_bit
))
2144 if (NX_IS_REVISION_P3(adapter
->ahw
.revision_id
)) {
2145 /* check interrupt state machine, to be sure */
2146 status
= readl(adapter
->crb_int_state_reg
);
2147 if (!ISR_LEGACY_INT_TRIGGERED(status
))
2151 unsigned long our_int
= 0;
2153 our_int
= readl(adapter
->crb_int_state_reg
);
2155 /* not our interrupt */
2156 if (!test_and_clear_bit((7 + adapter
->portnum
), &our_int
))
2159 /* claim interrupt */
2160 writel((our_int
& 0xffffffff), adapter
->crb_int_state_reg
);
2162 /* clear interrupt */
2163 netxen_nic_disable_int(sds_ring
);
2166 writel(0xffffffff, adapter
->tgt_status_reg
);
2167 /* read twice to ensure write is flushed */
2168 readl(adapter
->isr_int_vec
);
2169 readl(adapter
->isr_int_vec
);
2171 napi_schedule(&sds_ring
->napi
);
2176 static irqreturn_t
netxen_msi_intr(int irq
, void *data
)
2178 struct nx_host_sds_ring
*sds_ring
= data
;
2179 struct netxen_adapter
*adapter
= sds_ring
->adapter
;
2181 /* clear interrupt */
2182 writel(0xffffffff, adapter
->tgt_status_reg
);
2184 napi_schedule(&sds_ring
->napi
);
2188 static irqreturn_t
netxen_msix_intr(int irq
, void *data
)
2190 struct nx_host_sds_ring
*sds_ring
= data
;
2192 napi_schedule(&sds_ring
->napi
);
2196 static int netxen_nic_poll(struct napi_struct
*napi
, int budget
)
2198 struct nx_host_sds_ring
*sds_ring
=
2199 container_of(napi
, struct nx_host_sds_ring
, napi
);
2201 struct netxen_adapter
*adapter
= sds_ring
->adapter
;
2206 tx_complete
= netxen_process_cmd_ring(adapter
);
2208 work_done
= netxen_process_rcv_ring(sds_ring
, budget
);
2210 if ((work_done
< budget
) && tx_complete
) {
2211 napi_complete(&sds_ring
->napi
);
2212 if (test_bit(__NX_DEV_UP
, &adapter
->state
))
2213 netxen_nic_enable_int(sds_ring
);
2219 #ifdef CONFIG_NET_POLL_CONTROLLER
2220 static void netxen_nic_poll_controller(struct net_device
*netdev
)
2223 struct nx_host_sds_ring
*sds_ring
;
2224 struct netxen_adapter
*adapter
= netdev_priv(netdev
);
2225 struct netxen_recv_context
*recv_ctx
= &adapter
->recv_ctx
;
2227 disable_irq(adapter
->irq
);
2228 for (ring
= 0; ring
< adapter
->max_sds_rings
; ring
++) {
2229 sds_ring
= &recv_ctx
->sds_rings
[ring
];
2230 netxen_intr(adapter
->irq
, sds_ring
);
2232 enable_irq(adapter
->irq
);
2237 nx_incr_dev_ref_cnt(struct netxen_adapter
*adapter
)
2240 if (netxen_api_lock(adapter
))
2243 count
= NXRD32(adapter
, NX_CRB_DEV_REF_COUNT
);
2245 NXWR32(adapter
, NX_CRB_DEV_REF_COUNT
, ++count
);
2247 netxen_api_unlock(adapter
);
2252 nx_decr_dev_ref_cnt(struct netxen_adapter
*adapter
)
2255 if (netxen_api_lock(adapter
))
2258 count
= NXRD32(adapter
, NX_CRB_DEV_REF_COUNT
);
2259 WARN_ON(count
== 0);
2261 NXWR32(adapter
, NX_CRB_DEV_REF_COUNT
, --count
);
2264 NXWR32(adapter
, NX_CRB_DEV_STATE
, NX_DEV_COLD
);
2266 netxen_api_unlock(adapter
);
2271 nx_dev_request_aer(struct netxen_adapter
*adapter
)
2276 if (netxen_api_lock(adapter
))
2279 state
= NXRD32(adapter
, NX_CRB_DEV_STATE
);
2281 if (state
== NX_DEV_NEED_AER
)
2283 else if (state
== NX_DEV_READY
) {
2284 NXWR32(adapter
, NX_CRB_DEV_STATE
, NX_DEV_NEED_AER
);
2288 netxen_api_unlock(adapter
);
2293 nx_dev_request_reset(struct netxen_adapter
*adapter
)
2298 if (netxen_api_lock(adapter
))
2301 state
= NXRD32(adapter
, NX_CRB_DEV_STATE
);
2303 if (state
== NX_DEV_NEED_RESET
)
2305 else if (state
!= NX_DEV_INITALIZING
&& state
!= NX_DEV_NEED_AER
) {
2306 NXWR32(adapter
, NX_CRB_DEV_STATE
, NX_DEV_NEED_RESET
);
2310 netxen_api_unlock(adapter
);
2316 netxen_can_start_firmware(struct netxen_adapter
*adapter
)
2321 if (netxen_api_lock(adapter
))
2324 count
= NXRD32(adapter
, NX_CRB_DEV_REF_COUNT
);
2326 if ((count
< 0) || (count
>= NX_MAX_PCI_FUNC
))
2331 NXWR32(adapter
, NX_CRB_DEV_STATE
, NX_DEV_INITALIZING
);
2334 NXWR32(adapter
, NX_CRB_DEV_REF_COUNT
, ++count
);
2336 netxen_api_unlock(adapter
);
2342 netxen_schedule_work(struct netxen_adapter
*adapter
,
2343 work_func_t func
, int delay
)
2345 INIT_DELAYED_WORK(&adapter
->fw_work
, func
);
2346 schedule_delayed_work(&adapter
->fw_work
, delay
);
2350 netxen_cancel_fw_work(struct netxen_adapter
*adapter
)
2352 while (test_and_set_bit(__NX_RESETTING
, &adapter
->state
))
2355 cancel_delayed_work_sync(&adapter
->fw_work
);
2359 netxen_attach_work(struct work_struct
*work
)
2361 struct netxen_adapter
*adapter
= container_of(work
,
2362 struct netxen_adapter
, fw_work
.work
);
2363 struct net_device
*netdev
= adapter
->netdev
;
2366 if (netif_running(netdev
)) {
2367 err
= netxen_nic_attach(adapter
);
2371 err
= netxen_nic_up(adapter
, netdev
);
2373 netxen_nic_detach(adapter
);
2377 netxen_config_indev_addr(netdev
, NETDEV_UP
);
2380 netif_device_attach(netdev
);
2383 adapter
->fw_fail_cnt
= 0;
2384 clear_bit(__NX_RESETTING
, &adapter
->state
);
2385 netxen_schedule_work(adapter
, netxen_fw_poll_work
, FW_POLL_DELAY
);
2389 netxen_fwinit_work(struct work_struct
*work
)
2391 struct netxen_adapter
*adapter
= container_of(work
,
2392 struct netxen_adapter
, fw_work
.work
);
2395 dev_state
= NXRD32(adapter
, NX_CRB_DEV_STATE
);
2397 switch (dev_state
) {
2400 if (!netxen_start_firmware(adapter
)) {
2401 netxen_schedule_work(adapter
, netxen_attach_work
, 0);
2406 case NX_DEV_NEED_RESET
:
2407 case NX_DEV_INITALIZING
:
2408 if (++adapter
->fw_wait_cnt
< FW_POLL_THRESH
) {
2409 netxen_schedule_work(adapter
,
2410 netxen_fwinit_work
, 2 * FW_POLL_DELAY
);
2416 nx_incr_dev_ref_cnt(adapter
);
2420 clear_bit(__NX_RESETTING
, &adapter
->state
);
2424 netxen_detach_work(struct work_struct
*work
)
2426 struct netxen_adapter
*adapter
= container_of(work
,
2427 struct netxen_adapter
, fw_work
.work
);
2428 struct net_device
*netdev
= adapter
->netdev
;
2432 netif_device_detach(netdev
);
2434 netxen_nic_down(adapter
, netdev
);
2437 netxen_nic_detach(adapter
);
2440 status
= NXRD32(adapter
, NETXEN_PEG_HALT_STATUS1
);
2442 if (status
& NX_RCODE_FATAL_ERROR
)
2445 if (adapter
->temp
== NX_TEMP_PANIC
)
2448 ref_cnt
= nx_decr_dev_ref_cnt(adapter
);
2450 if (ref_cnt
== -EIO
)
2453 delay
= (ref_cnt
== 0) ? 0 : (2 * FW_POLL_DELAY
);
2455 adapter
->fw_wait_cnt
= 0;
2456 netxen_schedule_work(adapter
, netxen_fwinit_work
, delay
);
2461 clear_bit(__NX_RESETTING
, &adapter
->state
);
2465 netxen_check_health(struct netxen_adapter
*adapter
)
2467 u32 state
, heartbit
;
2468 struct net_device
*netdev
= adapter
->netdev
;
2470 state
= NXRD32(adapter
, NX_CRB_DEV_STATE
);
2471 if (state
== NX_DEV_NEED_AER
)
2474 if (netxen_nic_check_temp(adapter
))
2477 if (adapter
->need_fw_reset
) {
2478 if (nx_dev_request_reset(adapter
))
2483 /* NX_DEV_NEED_RESET, this state can be marked in two cases
2484 * 1. Tx timeout 2. Fw hang
2485 * Send request to destroy context in case of tx timeout only
2486 * and doesn't required in case of Fw hang
2488 if (state
== NX_DEV_NEED_RESET
) {
2489 adapter
->need_fw_reset
= 1;
2490 if (NX_IS_REVISION_P2(adapter
->ahw
.revision_id
))
2494 if (NX_IS_REVISION_P2(adapter
->ahw
.revision_id
))
2497 heartbit
= NXRD32(adapter
, NETXEN_PEG_ALIVE_COUNTER
);
2498 if (heartbit
!= adapter
->heartbit
) {
2499 adapter
->heartbit
= heartbit
;
2500 adapter
->fw_fail_cnt
= 0;
2501 if (adapter
->need_fw_reset
)
2506 if (++adapter
->fw_fail_cnt
< FW_FAIL_THRESH
)
2509 if (nx_dev_request_reset(adapter
))
2512 clear_bit(__NX_FW_ATTACHED
, &adapter
->state
);
2514 dev_info(&netdev
->dev
, "firmware hang detected\n");
2517 if ((auto_fw_reset
== AUTO_FW_RESET_ENABLED
) &&
2518 !test_and_set_bit(__NX_RESETTING
, &adapter
->state
))
2519 netxen_schedule_work(adapter
, netxen_detach_work
, 0);
2524 netxen_fw_poll_work(struct work_struct
*work
)
2526 struct netxen_adapter
*adapter
= container_of(work
,
2527 struct netxen_adapter
, fw_work
.work
);
2529 if (test_bit(__NX_RESETTING
, &adapter
->state
))
2532 if (test_bit(__NX_DEV_UP
, &adapter
->state
)) {
2533 if (!adapter
->has_link_events
) {
2535 netxen_nic_handle_phy_intr(adapter
);
2537 if (adapter
->link_changed
)
2538 netxen_nic_set_link_parameters(adapter
);
2542 if (netxen_check_health(adapter
))
2546 netxen_schedule_work(adapter
, netxen_fw_poll_work
, FW_POLL_DELAY
);
2550 netxen_store_bridged_mode(struct device
*dev
,
2551 struct device_attribute
*attr
, const char *buf
, size_t len
)
2553 struct net_device
*net
= to_net_dev(dev
);
2554 struct netxen_adapter
*adapter
= netdev_priv(net
);
2558 if (!(adapter
->capabilities
& NX_FW_CAPABILITY_BDG
))
2561 if (adapter
->is_up
!= NETXEN_ADAPTER_UP_MAGIC
)
2564 if (strict_strtoul(buf
, 2, &new))
2567 if (!netxen_config_bridged_mode(adapter
, !!new))
2575 netxen_show_bridged_mode(struct device
*dev
,
2576 struct device_attribute
*attr
, char *buf
)
2578 struct net_device
*net
= to_net_dev(dev
);
2579 struct netxen_adapter
*adapter
;
2580 int bridged_mode
= 0;
2582 adapter
= netdev_priv(net
);
2584 if (adapter
->capabilities
& NX_FW_CAPABILITY_BDG
)
2585 bridged_mode
= !!(adapter
->flags
& NETXEN_NIC_BRIDGE_ENABLED
);
2587 return sprintf(buf
, "%d\n", bridged_mode
);
2590 static struct device_attribute dev_attr_bridged_mode
= {
2591 .attr
= {.name
= "bridged_mode", .mode
= (S_IRUGO
| S_IWUSR
)},
2592 .show
= netxen_show_bridged_mode
,
2593 .store
= netxen_store_bridged_mode
,
2597 netxen_store_diag_mode(struct device
*dev
,
2598 struct device_attribute
*attr
, const char *buf
, size_t len
)
2600 struct netxen_adapter
*adapter
= dev_get_drvdata(dev
);
2603 if (strict_strtoul(buf
, 2, &new))
2606 if (!!new != !!(adapter
->flags
& NETXEN_NIC_DIAG_ENABLED
))
2607 adapter
->flags
^= NETXEN_NIC_DIAG_ENABLED
;
2613 netxen_show_diag_mode(struct device
*dev
,
2614 struct device_attribute
*attr
, char *buf
)
2616 struct netxen_adapter
*adapter
= dev_get_drvdata(dev
);
2618 return sprintf(buf
, "%d\n",
2619 !!(adapter
->flags
& NETXEN_NIC_DIAG_ENABLED
));
2622 static struct device_attribute dev_attr_diag_mode
= {
2623 .attr
= {.name
= "diag_mode", .mode
= (S_IRUGO
| S_IWUSR
)},
2624 .show
= netxen_show_diag_mode
,
2625 .store
= netxen_store_diag_mode
,
2629 netxen_sysfs_validate_crb(struct netxen_adapter
*adapter
,
2630 loff_t offset
, size_t size
)
2632 size_t crb_size
= 4;
2634 if (!(adapter
->flags
& NETXEN_NIC_DIAG_ENABLED
))
2637 if (offset
< NETXEN_PCI_CRBSPACE
) {
2638 if (NX_IS_REVISION_P2(adapter
->ahw
.revision_id
))
2641 if (ADDR_IN_RANGE(offset
, NETXEN_PCI_CAMQM
,
2642 NETXEN_PCI_CAMQM_2M_END
))
2648 if ((size
!= crb_size
) || (offset
& (crb_size
-1)))
2655 netxen_sysfs_read_crb(struct file
*filp
, struct kobject
*kobj
,
2656 struct bin_attribute
*attr
,
2657 char *buf
, loff_t offset
, size_t size
)
2659 struct device
*dev
= container_of(kobj
, struct device
, kobj
);
2660 struct netxen_adapter
*adapter
= dev_get_drvdata(dev
);
2665 ret
= netxen_sysfs_validate_crb(adapter
, offset
, size
);
2669 if (NX_IS_REVISION_P3(adapter
->ahw
.revision_id
) &&
2670 ADDR_IN_RANGE(offset
, NETXEN_PCI_CAMQM
,
2671 NETXEN_PCI_CAMQM_2M_END
)) {
2672 netxen_pci_camqm_read_2M(adapter
, offset
, &qmdata
);
2673 memcpy(buf
, &qmdata
, size
);
2675 data
= NXRD32(adapter
, offset
);
2676 memcpy(buf
, &data
, size
);
2683 netxen_sysfs_write_crb(struct file
*filp
, struct kobject
*kobj
,
2684 struct bin_attribute
*attr
,
2685 char *buf
, loff_t offset
, size_t size
)
2687 struct device
*dev
= container_of(kobj
, struct device
, kobj
);
2688 struct netxen_adapter
*adapter
= dev_get_drvdata(dev
);
2693 ret
= netxen_sysfs_validate_crb(adapter
, offset
, size
);
2697 if (NX_IS_REVISION_P3(adapter
->ahw
.revision_id
) &&
2698 ADDR_IN_RANGE(offset
, NETXEN_PCI_CAMQM
,
2699 NETXEN_PCI_CAMQM_2M_END
)) {
2700 memcpy(&qmdata
, buf
, size
);
2701 netxen_pci_camqm_write_2M(adapter
, offset
, qmdata
);
2703 memcpy(&data
, buf
, size
);
2704 NXWR32(adapter
, offset
, data
);
2711 netxen_sysfs_validate_mem(struct netxen_adapter
*adapter
,
2712 loff_t offset
, size_t size
)
2714 if (!(adapter
->flags
& NETXEN_NIC_DIAG_ENABLED
))
2717 if ((size
!= 8) || (offset
& 0x7))
2724 netxen_sysfs_read_mem(struct file
*filp
, struct kobject
*kobj
,
2725 struct bin_attribute
*attr
,
2726 char *buf
, loff_t offset
, size_t size
)
2728 struct device
*dev
= container_of(kobj
, struct device
, kobj
);
2729 struct netxen_adapter
*adapter
= dev_get_drvdata(dev
);
2733 ret
= netxen_sysfs_validate_mem(adapter
, offset
, size
);
2737 if (adapter
->pci_mem_read(adapter
, offset
, &data
))
2740 memcpy(buf
, &data
, size
);
2745 static ssize_t
netxen_sysfs_write_mem(struct file
*filp
, struct kobject
*kobj
,
2746 struct bin_attribute
*attr
, char *buf
,
2747 loff_t offset
, size_t size
)
2749 struct device
*dev
= container_of(kobj
, struct device
, kobj
);
2750 struct netxen_adapter
*adapter
= dev_get_drvdata(dev
);
2754 ret
= netxen_sysfs_validate_mem(adapter
, offset
, size
);
2758 memcpy(&data
, buf
, size
);
2760 if (adapter
->pci_mem_write(adapter
, offset
, data
))
2767 static struct bin_attribute bin_attr_crb
= {
2768 .attr
= {.name
= "crb", .mode
= (S_IRUGO
| S_IWUSR
)},
2770 .read
= netxen_sysfs_read_crb
,
2771 .write
= netxen_sysfs_write_crb
,
2774 static struct bin_attribute bin_attr_mem
= {
2775 .attr
= {.name
= "mem", .mode
= (S_IRUGO
| S_IWUSR
)},
2777 .read
= netxen_sysfs_read_mem
,
2778 .write
= netxen_sysfs_write_mem
,
2783 netxen_create_sysfs_entries(struct netxen_adapter
*adapter
)
2785 struct net_device
*netdev
= adapter
->netdev
;
2786 struct device
*dev
= &netdev
->dev
;
2788 if (adapter
->capabilities
& NX_FW_CAPABILITY_BDG
) {
2789 /* bridged_mode control */
2790 if (device_create_file(dev
, &dev_attr_bridged_mode
)) {
2791 dev_warn(&netdev
->dev
,
2792 "failed to create bridged_mode sysfs entry\n");
2798 netxen_remove_sysfs_entries(struct netxen_adapter
*adapter
)
2800 struct net_device
*netdev
= adapter
->netdev
;
2801 struct device
*dev
= &netdev
->dev
;
2803 if (adapter
->capabilities
& NX_FW_CAPABILITY_BDG
)
2804 device_remove_file(dev
, &dev_attr_bridged_mode
);
2808 netxen_create_diag_entries(struct netxen_adapter
*adapter
)
2810 struct pci_dev
*pdev
= adapter
->pdev
;
2814 if (device_create_file(dev
, &dev_attr_diag_mode
))
2815 dev_info(dev
, "failed to create diag_mode sysfs entry\n");
2816 if (device_create_bin_file(dev
, &bin_attr_crb
))
2817 dev_info(dev
, "failed to create crb sysfs entry\n");
2818 if (device_create_bin_file(dev
, &bin_attr_mem
))
2819 dev_info(dev
, "failed to create mem sysfs entry\n");
2824 netxen_remove_diag_entries(struct netxen_adapter
*adapter
)
2826 struct pci_dev
*pdev
= adapter
->pdev
;
2827 struct device
*dev
= &pdev
->dev
;
2829 device_remove_file(dev
, &dev_attr_diag_mode
);
2830 device_remove_bin_file(dev
, &bin_attr_crb
);
2831 device_remove_bin_file(dev
, &bin_attr_mem
);
2836 #define is_netxen_netdev(dev) (dev->netdev_ops == &netxen_netdev_ops)
2839 netxen_destip_supported(struct netxen_adapter
*adapter
)
2841 if (NX_IS_REVISION_P2(adapter
->ahw
.revision_id
))
2844 if (adapter
->ahw
.cut_through
)
2851 netxen_config_indev_addr(struct net_device
*dev
, unsigned long event
)
2853 struct in_device
*indev
;
2854 struct netxen_adapter
*adapter
= netdev_priv(dev
);
2856 if (!netxen_destip_supported(adapter
))
2859 indev
= in_dev_get(dev
);
2866 netxen_config_ipaddr(adapter
,
2867 ifa
->ifa_address
, NX_IP_UP
);
2870 netxen_config_ipaddr(adapter
,
2871 ifa
->ifa_address
, NX_IP_DOWN
);
2876 } endfor_ifa(indev
);
2881 static int netxen_netdev_event(struct notifier_block
*this,
2882 unsigned long event
, void *ptr
)
2884 struct netxen_adapter
*adapter
;
2885 struct net_device
*dev
= (struct net_device
*)ptr
;
2891 if (dev
->priv_flags
& IFF_802_1Q_VLAN
) {
2892 dev
= vlan_dev_real_dev(dev
);
2896 if (!is_netxen_netdev(dev
))
2899 adapter
= netdev_priv(dev
);
2904 if (adapter
->is_up
!= NETXEN_ADAPTER_UP_MAGIC
)
2907 netxen_config_indev_addr(dev
, event
);
2913 netxen_inetaddr_event(struct notifier_block
*this,
2914 unsigned long event
, void *ptr
)
2916 struct netxen_adapter
*adapter
;
2917 struct net_device
*dev
;
2919 struct in_ifaddr
*ifa
= (struct in_ifaddr
*)ptr
;
2921 dev
= ifa
->ifa_dev
? ifa
->ifa_dev
->dev
: NULL
;
2924 if (dev
== NULL
|| !netif_running(dev
))
2927 if (dev
->priv_flags
& IFF_802_1Q_VLAN
) {
2928 dev
= vlan_dev_real_dev(dev
);
2932 if (!is_netxen_netdev(dev
))
2935 adapter
= netdev_priv(dev
);
2937 if (!adapter
|| !netxen_destip_supported(adapter
))
2940 if (adapter
->is_up
!= NETXEN_ADAPTER_UP_MAGIC
)
2945 netxen_config_ipaddr(adapter
, ifa
->ifa_address
, NX_IP_UP
);
2948 netxen_config_ipaddr(adapter
, ifa
->ifa_address
, NX_IP_DOWN
);
2958 static struct notifier_block netxen_netdev_cb
= {
2959 .notifier_call
= netxen_netdev_event
,
2962 static struct notifier_block netxen_inetaddr_cb
= {
2963 .notifier_call
= netxen_inetaddr_event
,
2967 netxen_config_indev_addr(struct net_device
*dev
, unsigned long event
)
2971 static struct pci_error_handlers netxen_err_handler
= {
2972 .error_detected
= netxen_io_error_detected
,
2973 .slot_reset
= netxen_io_slot_reset
,
2974 .resume
= netxen_io_resume
,
2977 static struct pci_driver netxen_driver
= {
2978 .name
= netxen_nic_driver_name
,
2979 .id_table
= netxen_pci_tbl
,
2980 .probe
= netxen_nic_probe
,
2981 .remove
= __devexit_p(netxen_nic_remove
),
2983 .suspend
= netxen_nic_suspend
,
2984 .resume
= netxen_nic_resume
,
2986 .shutdown
= netxen_nic_shutdown
,
2987 .err_handler
= &netxen_err_handler
2990 static int __init
netxen_init_module(void)
2992 printk(KERN_INFO
"%s\n", netxen_nic_driver_string
);
2995 register_netdevice_notifier(&netxen_netdev_cb
);
2996 register_inetaddr_notifier(&netxen_inetaddr_cb
);
2998 return pci_register_driver(&netxen_driver
);
3001 module_init(netxen_init_module
);
3003 static void __exit
netxen_exit_module(void)
3005 pci_unregister_driver(&netxen_driver
);
3008 unregister_inetaddr_notifier(&netxen_inetaddr_cb
);
3009 unregister_netdevice_notifier(&netxen_netdev_cb
);
3013 module_exit(netxen_exit_module
);