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 net_device_stats
*netxen_nic_get_stats(struct net_device
*netdev
);
96 static int netxen_nic_set_mac(struct net_device
*netdev
, void *p
);
98 /* PCI Device ID Table */
99 #define ENTRY(device) \
100 {PCI_DEVICE(PCI_VENDOR_ID_NETXEN, (device)), \
101 .class = PCI_CLASS_NETWORK_ETHERNET << 8, .class_mask = ~0}
103 static DEFINE_PCI_DEVICE_TABLE(netxen_pci_tbl
) = {
104 ENTRY(PCI_DEVICE_ID_NX2031_10GXSR
),
105 ENTRY(PCI_DEVICE_ID_NX2031_10GCX4
),
106 ENTRY(PCI_DEVICE_ID_NX2031_4GCU
),
107 ENTRY(PCI_DEVICE_ID_NX2031_IMEZ
),
108 ENTRY(PCI_DEVICE_ID_NX2031_HMEZ
),
109 ENTRY(PCI_DEVICE_ID_NX2031_XG_MGMT
),
110 ENTRY(PCI_DEVICE_ID_NX2031_XG_MGMT2
),
111 ENTRY(PCI_DEVICE_ID_NX3031
),
115 MODULE_DEVICE_TABLE(pci
, netxen_pci_tbl
);
117 static uint32_t crb_cmd_producer
[4] = {
118 CRB_CMD_PRODUCER_OFFSET
, CRB_CMD_PRODUCER_OFFSET_1
,
119 CRB_CMD_PRODUCER_OFFSET_2
, CRB_CMD_PRODUCER_OFFSET_3
123 netxen_nic_update_cmd_producer(struct netxen_adapter
*adapter
,
124 struct nx_host_tx_ring
*tx_ring
)
126 NXWRIO(adapter
, tx_ring
->crb_cmd_producer
, tx_ring
->producer
);
129 static uint32_t crb_cmd_consumer
[4] = {
130 CRB_CMD_CONSUMER_OFFSET
, CRB_CMD_CONSUMER_OFFSET_1
,
131 CRB_CMD_CONSUMER_OFFSET_2
, CRB_CMD_CONSUMER_OFFSET_3
135 netxen_nic_update_cmd_consumer(struct netxen_adapter
*adapter
,
136 struct nx_host_tx_ring
*tx_ring
)
138 NXWRIO(adapter
, tx_ring
->crb_cmd_consumer
, tx_ring
->sw_consumer
);
141 static uint32_t msi_tgt_status
[8] = {
142 ISR_INT_TARGET_STATUS
, ISR_INT_TARGET_STATUS_F1
,
143 ISR_INT_TARGET_STATUS_F2
, ISR_INT_TARGET_STATUS_F3
,
144 ISR_INT_TARGET_STATUS_F4
, ISR_INT_TARGET_STATUS_F5
,
145 ISR_INT_TARGET_STATUS_F6
, ISR_INT_TARGET_STATUS_F7
148 static struct netxen_legacy_intr_set legacy_intr
[] = NX_LEGACY_INTR_CONFIG
;
150 static inline void netxen_nic_disable_int(struct nx_host_sds_ring
*sds_ring
)
152 struct netxen_adapter
*adapter
= sds_ring
->adapter
;
154 NXWRIO(adapter
, sds_ring
->crb_intr_mask
, 0);
157 static inline void netxen_nic_enable_int(struct nx_host_sds_ring
*sds_ring
)
159 struct netxen_adapter
*adapter
= sds_ring
->adapter
;
161 NXWRIO(adapter
, sds_ring
->crb_intr_mask
, 0x1);
163 if (!NETXEN_IS_MSI_FAMILY(adapter
))
164 NXWRIO(adapter
, adapter
->tgt_mask_reg
, 0xfbff);
168 netxen_alloc_sds_rings(struct netxen_recv_context
*recv_ctx
, int count
)
170 int size
= sizeof(struct nx_host_sds_ring
) * count
;
172 recv_ctx
->sds_rings
= kzalloc(size
, GFP_KERNEL
);
174 return recv_ctx
->sds_rings
== NULL
;
178 netxen_free_sds_rings(struct netxen_recv_context
*recv_ctx
)
180 if (recv_ctx
->sds_rings
!= NULL
)
181 kfree(recv_ctx
->sds_rings
);
183 recv_ctx
->sds_rings
= NULL
;
187 netxen_napi_add(struct netxen_adapter
*adapter
, struct net_device
*netdev
)
190 struct nx_host_sds_ring
*sds_ring
;
191 struct netxen_recv_context
*recv_ctx
= &adapter
->recv_ctx
;
193 if (netxen_alloc_sds_rings(recv_ctx
, adapter
->max_sds_rings
))
196 for (ring
= 0; ring
< adapter
->max_sds_rings
; ring
++) {
197 sds_ring
= &recv_ctx
->sds_rings
[ring
];
198 netif_napi_add(netdev
, &sds_ring
->napi
,
199 netxen_nic_poll
, NETXEN_NETDEV_WEIGHT
);
206 netxen_napi_del(struct netxen_adapter
*adapter
)
209 struct nx_host_sds_ring
*sds_ring
;
210 struct netxen_recv_context
*recv_ctx
= &adapter
->recv_ctx
;
212 for (ring
= 0; ring
< adapter
->max_sds_rings
; ring
++) {
213 sds_ring
= &recv_ctx
->sds_rings
[ring
];
214 netif_napi_del(&sds_ring
->napi
);
217 netxen_free_sds_rings(&adapter
->recv_ctx
);
221 netxen_napi_enable(struct netxen_adapter
*adapter
)
224 struct nx_host_sds_ring
*sds_ring
;
225 struct netxen_recv_context
*recv_ctx
= &adapter
->recv_ctx
;
227 for (ring
= 0; ring
< adapter
->max_sds_rings
; ring
++) {
228 sds_ring
= &recv_ctx
->sds_rings
[ring
];
229 napi_enable(&sds_ring
->napi
);
230 netxen_nic_enable_int(sds_ring
);
235 netxen_napi_disable(struct netxen_adapter
*adapter
)
238 struct nx_host_sds_ring
*sds_ring
;
239 struct netxen_recv_context
*recv_ctx
= &adapter
->recv_ctx
;
241 for (ring
= 0; ring
< adapter
->max_sds_rings
; ring
++) {
242 sds_ring
= &recv_ctx
->sds_rings
[ring
];
243 netxen_nic_disable_int(sds_ring
);
244 napi_synchronize(&sds_ring
->napi
);
245 napi_disable(&sds_ring
->napi
);
249 static int nx_set_dma_mask(struct netxen_adapter
*adapter
)
251 struct pci_dev
*pdev
= adapter
->pdev
;
252 uint64_t mask
, cmask
;
254 adapter
->pci_using_dac
= 0;
256 mask
= DMA_BIT_MASK(32);
257 cmask
= DMA_BIT_MASK(32);
259 if (NX_IS_REVISION_P2(adapter
->ahw
.revision_id
)) {
261 mask
= DMA_BIT_MASK(35);
264 mask
= DMA_BIT_MASK(39);
268 if (pci_set_dma_mask(pdev
, mask
) == 0 &&
269 pci_set_consistent_dma_mask(pdev
, cmask
) == 0) {
270 adapter
->pci_using_dac
= 1;
277 /* Update addressable range if firmware supports it */
279 nx_update_dma_mask(struct netxen_adapter
*adapter
)
281 int change
, shift
, err
;
282 uint64_t mask
, old_mask
, old_cmask
;
283 struct pci_dev
*pdev
= adapter
->pdev
;
287 shift
= NXRD32(adapter
, CRB_DMA_SHIFT
);
291 if (NX_IS_REVISION_P3(adapter
->ahw
.revision_id
) && (shift
> 9))
293 else if ((adapter
->ahw
.revision_id
== NX_P2_C1
) && (shift
<= 4))
297 old_mask
= pdev
->dma_mask
;
298 old_cmask
= pdev
->dev
.coherent_dma_mask
;
300 mask
= DMA_BIT_MASK(32+shift
);
302 err
= pci_set_dma_mask(pdev
, mask
);
306 if (NX_IS_REVISION_P3(adapter
->ahw
.revision_id
)) {
308 err
= pci_set_consistent_dma_mask(pdev
, mask
);
312 dev_info(&pdev
->dev
, "using %d-bit dma mask\n", 32+shift
);
318 pci_set_dma_mask(pdev
, old_mask
);
319 pci_set_consistent_dma_mask(pdev
, old_cmask
);
324 netxen_check_hw_init(struct netxen_adapter
*adapter
, int first_boot
)
328 if (first_boot
== 0x55555555) {
329 /* This is the first boot after power up */
330 NXWR32(adapter
, NETXEN_CAM_RAM(0x1fc), NETXEN_BDINFO_MAGIC
);
332 if (!NX_IS_REVISION_P2(adapter
->ahw
.revision_id
))
335 /* PCI bus master workaround */
336 first_boot
= NXRD32(adapter
, NETXEN_PCIE_REG(0x4));
337 if (!(first_boot
& 0x4)) {
339 NXWR32(adapter
, NETXEN_PCIE_REG(0x4), first_boot
);
340 NXRD32(adapter
, NETXEN_PCIE_REG(0x4));
343 /* This is the first boot after power up */
344 first_boot
= NXRD32(adapter
, NETXEN_ROMUSB_GLB_SW_RESET
);
345 if (first_boot
!= 0x80000f) {
346 /* clear the register for future unloads/loads */
347 NXWR32(adapter
, NETXEN_CAM_RAM(0x1fc), 0);
351 /* Start P2 boot loader */
352 val
= NXRD32(adapter
, NETXEN_ROMUSB_GLB_PEGTUNE_DONE
);
353 NXWR32(adapter
, NETXEN_ROMUSB_GLB_PEGTUNE_DONE
, val
| 0x1);
357 val
= NXRD32(adapter
, NETXEN_CAM_RAM(0x1fc));
359 if (++timeout
> 5000)
362 } while (val
== NETXEN_BDINFO_MAGIC
);
367 static void netxen_set_port_mode(struct netxen_adapter
*adapter
)
371 val
= adapter
->ahw
.board_type
;
372 if ((val
== NETXEN_BRDTYPE_P3_HMEZ
) ||
373 (val
== NETXEN_BRDTYPE_P3_XG_LOM
)) {
374 if (port_mode
== NETXEN_PORT_MODE_802_3_AP
) {
375 data
= NETXEN_PORT_MODE_802_3_AP
;
376 NXWR32(adapter
, NETXEN_PORT_MODE_ADDR
, data
);
377 } else if (port_mode
== NETXEN_PORT_MODE_XG
) {
378 data
= NETXEN_PORT_MODE_XG
;
379 NXWR32(adapter
, NETXEN_PORT_MODE_ADDR
, data
);
380 } else if (port_mode
== NETXEN_PORT_MODE_AUTO_NEG_1G
) {
381 data
= NETXEN_PORT_MODE_AUTO_NEG_1G
;
382 NXWR32(adapter
, NETXEN_PORT_MODE_ADDR
, data
);
383 } else if (port_mode
== NETXEN_PORT_MODE_AUTO_NEG_XG
) {
384 data
= NETXEN_PORT_MODE_AUTO_NEG_XG
;
385 NXWR32(adapter
, NETXEN_PORT_MODE_ADDR
, data
);
387 data
= NETXEN_PORT_MODE_AUTO_NEG
;
388 NXWR32(adapter
, NETXEN_PORT_MODE_ADDR
, data
);
391 if ((wol_port_mode
!= NETXEN_PORT_MODE_802_3_AP
) &&
392 (wol_port_mode
!= NETXEN_PORT_MODE_XG
) &&
393 (wol_port_mode
!= NETXEN_PORT_MODE_AUTO_NEG_1G
) &&
394 (wol_port_mode
!= NETXEN_PORT_MODE_AUTO_NEG_XG
)) {
395 wol_port_mode
= NETXEN_PORT_MODE_AUTO_NEG
;
397 NXWR32(adapter
, NETXEN_WOL_PORT_MODE
, wol_port_mode
);
401 static void netxen_set_msix_bit(struct pci_dev
*pdev
, int enable
)
406 pos
= pci_find_capability(pdev
, PCI_CAP_ID_MSIX
);
408 pci_read_config_dword(pdev
, pos
, &control
);
410 control
|= PCI_MSIX_FLAGS_ENABLE
;
413 pci_write_config_dword(pdev
, pos
, control
);
417 static void netxen_init_msix_entries(struct netxen_adapter
*adapter
, int count
)
421 for (i
= 0; i
< count
; i
++)
422 adapter
->msix_entries
[i
].entry
= i
;
426 netxen_read_mac_addr(struct netxen_adapter
*adapter
)
431 struct net_device
*netdev
= adapter
->netdev
;
432 struct pci_dev
*pdev
= adapter
->pdev
;
434 if (NX_IS_REVISION_P3(adapter
->ahw
.revision_id
)) {
435 if (netxen_p3_get_mac_addr(adapter
, &mac_addr
) != 0)
438 if (netxen_get_flash_mac_addr(adapter
, &mac_addr
) != 0)
442 p
= (unsigned char *)&mac_addr
;
443 for (i
= 0; i
< 6; i
++)
444 netdev
->dev_addr
[i
] = *(p
+ 5 - i
);
446 memcpy(netdev
->perm_addr
, netdev
->dev_addr
, netdev
->addr_len
);
447 memcpy(adapter
->mac_addr
, netdev
->dev_addr
, netdev
->addr_len
);
449 /* set station address */
451 if (!is_valid_ether_addr(netdev
->perm_addr
))
452 dev_warn(&pdev
->dev
, "Bad MAC address %pM.\n", netdev
->dev_addr
);
457 static int netxen_nic_set_mac(struct net_device
*netdev
, void *p
)
459 struct netxen_adapter
*adapter
= netdev_priv(netdev
);
460 struct sockaddr
*addr
= p
;
462 if (!is_valid_ether_addr(addr
->sa_data
))
465 if (netif_running(netdev
)) {
466 netif_device_detach(netdev
);
467 netxen_napi_disable(adapter
);
470 memcpy(adapter
->mac_addr
, addr
->sa_data
, netdev
->addr_len
);
471 memcpy(netdev
->dev_addr
, addr
->sa_data
, netdev
->addr_len
);
472 adapter
->macaddr_set(adapter
, addr
->sa_data
);
474 if (netif_running(netdev
)) {
475 netif_device_attach(netdev
);
476 netxen_napi_enable(adapter
);
481 static void netxen_set_multicast_list(struct net_device
*dev
)
483 struct netxen_adapter
*adapter
= netdev_priv(dev
);
485 adapter
->set_multi(dev
);
488 static u32
netxen_fix_features(struct net_device
*dev
, u32 features
)
490 if (!(features
& NETIF_F_RXCSUM
)) {
491 netdev_info(dev
, "disabling LRO as RXCSUM is off\n");
493 features
&= ~NETIF_F_LRO
;
499 static int netxen_set_features(struct net_device
*dev
, u32 features
)
501 struct netxen_adapter
*adapter
= netdev_priv(dev
);
504 if (!((dev
->features
^ features
) & NETIF_F_LRO
))
507 hw_lro
= (features
& NETIF_F_LRO
) ? NETXEN_NIC_LRO_ENABLED
508 : NETXEN_NIC_LRO_DISABLED
;
510 if (netxen_config_hw_lro(adapter
, hw_lro
))
513 if (!(features
& NETIF_F_LRO
) && netxen_send_lro_cleanup(adapter
))
519 static const struct net_device_ops netxen_netdev_ops
= {
520 .ndo_open
= netxen_nic_open
,
521 .ndo_stop
= netxen_nic_close
,
522 .ndo_start_xmit
= netxen_nic_xmit_frame
,
523 .ndo_get_stats
= netxen_nic_get_stats
,
524 .ndo_validate_addr
= eth_validate_addr
,
525 .ndo_set_multicast_list
= netxen_set_multicast_list
,
526 .ndo_set_mac_address
= netxen_nic_set_mac
,
527 .ndo_change_mtu
= netxen_nic_change_mtu
,
528 .ndo_tx_timeout
= netxen_tx_timeout
,
529 .ndo_fix_features
= netxen_fix_features
,
530 .ndo_set_features
= netxen_set_features
,
531 #ifdef CONFIG_NET_POLL_CONTROLLER
532 .ndo_poll_controller
= netxen_nic_poll_controller
,
537 netxen_setup_intr(struct netxen_adapter
*adapter
)
539 struct netxen_legacy_intr_set
*legacy_intrp
;
540 struct pci_dev
*pdev
= adapter
->pdev
;
543 if (adapter
->rss_supported
) {
544 num_msix
= (num_online_cpus() >= MSIX_ENTRIES_PER_ADAPTER
) ?
545 MSIX_ENTRIES_PER_ADAPTER
: 2;
549 adapter
->max_sds_rings
= 1;
551 adapter
->flags
&= ~(NETXEN_NIC_MSI_ENABLED
| NETXEN_NIC_MSIX_ENABLED
);
553 if (adapter
->ahw
.revision_id
>= NX_P3_B0
)
554 legacy_intrp
= &legacy_intr
[adapter
->ahw
.pci_func
];
556 legacy_intrp
= &legacy_intr
[0];
558 adapter
->int_vec_bit
= legacy_intrp
->int_vec_bit
;
559 adapter
->tgt_status_reg
= netxen_get_ioaddr(adapter
,
560 legacy_intrp
->tgt_status_reg
);
561 adapter
->tgt_mask_reg
= netxen_get_ioaddr(adapter
,
562 legacy_intrp
->tgt_mask_reg
);
563 adapter
->pci_int_reg
= netxen_get_ioaddr(adapter
,
564 legacy_intrp
->pci_int_reg
);
565 adapter
->isr_int_vec
= netxen_get_ioaddr(adapter
, ISR_INT_VECTOR
);
567 if (adapter
->ahw
.revision_id
>= NX_P3_B1
)
568 adapter
->crb_int_state_reg
= netxen_get_ioaddr(adapter
,
571 adapter
->crb_int_state_reg
= netxen_get_ioaddr(adapter
,
574 netxen_set_msix_bit(pdev
, 0);
576 if (adapter
->msix_supported
) {
578 netxen_init_msix_entries(adapter
, num_msix
);
579 err
= pci_enable_msix(pdev
, adapter
->msix_entries
, num_msix
);
581 adapter
->flags
|= NETXEN_NIC_MSIX_ENABLED
;
582 netxen_set_msix_bit(pdev
, 1);
584 if (adapter
->rss_supported
)
585 adapter
->max_sds_rings
= num_msix
;
587 dev_info(&pdev
->dev
, "using msi-x interrupts\n");
592 pci_disable_msix(pdev
);
594 /* fall through for msi */
597 if (use_msi
&& !pci_enable_msi(pdev
)) {
598 adapter
->flags
|= NETXEN_NIC_MSI_ENABLED
;
599 adapter
->tgt_status_reg
= netxen_get_ioaddr(adapter
,
600 msi_tgt_status
[adapter
->ahw
.pci_func
]);
601 dev_info(&pdev
->dev
, "using msi interrupts\n");
602 adapter
->msix_entries
[0].vector
= pdev
->irq
;
606 dev_info(&pdev
->dev
, "using legacy interrupts\n");
607 adapter
->msix_entries
[0].vector
= pdev
->irq
;
611 netxen_teardown_intr(struct netxen_adapter
*adapter
)
613 if (adapter
->flags
& NETXEN_NIC_MSIX_ENABLED
)
614 pci_disable_msix(adapter
->pdev
);
615 if (adapter
->flags
& NETXEN_NIC_MSI_ENABLED
)
616 pci_disable_msi(adapter
->pdev
);
620 netxen_cleanup_pci_map(struct netxen_adapter
*adapter
)
622 if (adapter
->ahw
.db_base
!= NULL
)
623 iounmap(adapter
->ahw
.db_base
);
624 if (adapter
->ahw
.pci_base0
!= NULL
)
625 iounmap(adapter
->ahw
.pci_base0
);
626 if (adapter
->ahw
.pci_base1
!= NULL
)
627 iounmap(adapter
->ahw
.pci_base1
);
628 if (adapter
->ahw
.pci_base2
!= NULL
)
629 iounmap(adapter
->ahw
.pci_base2
);
633 netxen_setup_pci_map(struct netxen_adapter
*adapter
)
635 void __iomem
*db_ptr
= NULL
;
637 resource_size_t mem_base
, db_base
;
638 unsigned long mem_len
, db_len
= 0;
640 struct pci_dev
*pdev
= adapter
->pdev
;
641 int pci_func
= adapter
->ahw
.pci_func
;
642 struct netxen_hardware_context
*ahw
= &adapter
->ahw
;
647 * Set the CRB window to invalid. If any register in window 0 is
648 * accessed it should set the window to 0 and then reset it to 1.
650 adapter
->ahw
.crb_win
= -1;
651 adapter
->ahw
.ocm_win
= -1;
653 /* remap phys address */
654 mem_base
= pci_resource_start(pdev
, 0); /* 0 is for BAR 0 */
655 mem_len
= pci_resource_len(pdev
, 0);
657 /* 128 Meg of memory */
658 if (mem_len
== NETXEN_PCI_128MB_SIZE
) {
660 ahw
->pci_base0
= ioremap(mem_base
, FIRST_PAGE_GROUP_SIZE
);
661 ahw
->pci_base1
= ioremap(mem_base
+ SECOND_PAGE_GROUP_START
,
662 SECOND_PAGE_GROUP_SIZE
);
663 ahw
->pci_base2
= ioremap(mem_base
+ THIRD_PAGE_GROUP_START
,
664 THIRD_PAGE_GROUP_SIZE
);
665 if (ahw
->pci_base0
== NULL
|| ahw
->pci_base1
== NULL
||
666 ahw
->pci_base2
== NULL
) {
667 dev_err(&pdev
->dev
, "failed to map PCI bar 0\n");
672 ahw
->pci_len0
= FIRST_PAGE_GROUP_SIZE
;
674 } else if (mem_len
== NETXEN_PCI_32MB_SIZE
) {
676 ahw
->pci_base1
= ioremap(mem_base
, SECOND_PAGE_GROUP_SIZE
);
677 ahw
->pci_base2
= ioremap(mem_base
+ THIRD_PAGE_GROUP_START
-
678 SECOND_PAGE_GROUP_START
, THIRD_PAGE_GROUP_SIZE
);
679 if (ahw
->pci_base1
== NULL
|| ahw
->pci_base2
== NULL
) {
680 dev_err(&pdev
->dev
, "failed to map PCI bar 0\n");
685 } else if (mem_len
== NETXEN_PCI_2MB_SIZE
) {
687 ahw
->pci_base0
= pci_ioremap_bar(pdev
, 0);
688 if (ahw
->pci_base0
== NULL
) {
689 dev_err(&pdev
->dev
, "failed to map PCI bar 0\n");
692 ahw
->pci_len0
= mem_len
;
697 netxen_setup_hwops(adapter
);
699 dev_info(&pdev
->dev
, "%dMB memory map\n", (int)(mem_len
>>20));
701 if (NX_IS_REVISION_P3P(adapter
->ahw
.revision_id
)) {
702 adapter
->ahw
.ocm_win_crb
= netxen_get_ioaddr(adapter
,
703 NETXEN_PCIX_PS_REG(PCIX_OCM_WINDOW_REG(pci_func
)));
705 } else if (NX_IS_REVISION_P3(adapter
->ahw
.revision_id
)) {
706 adapter
->ahw
.ocm_win_crb
= netxen_get_ioaddr(adapter
,
707 NETXEN_PCIX_PS_REG(PCIE_MN_WINDOW_REG(pci_func
)));
710 if (NX_IS_REVISION_P3(adapter
->ahw
.revision_id
))
713 db_base
= pci_resource_start(pdev
, 4); /* doorbell is on bar 4 */
714 db_len
= pci_resource_len(pdev
, 4);
717 printk(KERN_ERR
"%s: doorbell is disabled\n",
718 netxen_nic_driver_name
);
723 db_ptr
= ioremap(db_base
, NETXEN_DB_MAPSIZE_BYTES
);
725 printk(KERN_ERR
"%s: Failed to allocate doorbell map.",
726 netxen_nic_driver_name
);
732 adapter
->ahw
.db_base
= db_ptr
;
733 adapter
->ahw
.db_len
= db_len
;
737 netxen_cleanup_pci_map(adapter
);
742 netxen_check_options(struct netxen_adapter
*adapter
)
744 u32 fw_major
, fw_minor
, fw_build
;
745 char brd_name
[NETXEN_MAX_SHORT_NAME
];
749 struct pci_dev
*pdev
= adapter
->pdev
;
751 adapter
->driver_mismatch
= 0;
753 ptr32
= (int *)&serial_num
;
754 offset
= NX_FW_SERIAL_NUM_OFFSET
;
755 for (i
= 0; i
< 8; i
++) {
756 if (netxen_rom_fast_read(adapter
, offset
, &val
) == -1) {
757 dev_err(&pdev
->dev
, "error reading board info\n");
758 adapter
->driver_mismatch
= 1;
761 ptr32
[i
] = cpu_to_le32(val
);
762 offset
+= sizeof(u32
);
765 fw_major
= NXRD32(adapter
, NETXEN_FW_VERSION_MAJOR
);
766 fw_minor
= NXRD32(adapter
, NETXEN_FW_VERSION_MINOR
);
767 fw_build
= NXRD32(adapter
, NETXEN_FW_VERSION_SUB
);
769 adapter
->fw_version
= NETXEN_VERSION_CODE(fw_major
, fw_minor
, fw_build
);
771 if (adapter
->portnum
== 0) {
772 get_brd_name_by_type(adapter
->ahw
.board_type
, brd_name
);
774 pr_info("%s: %s Board S/N %s Chip rev 0x%x\n",
775 module_name(THIS_MODULE
),
776 brd_name
, serial_num
, adapter
->ahw
.revision_id
);
779 if (adapter
->fw_version
< NETXEN_VERSION_CODE(3, 4, 216)) {
780 adapter
->driver_mismatch
= 1;
781 dev_warn(&pdev
->dev
, "firmware version %d.%d.%d unsupported\n",
782 fw_major
, fw_minor
, fw_build
);
786 if (NX_IS_REVISION_P3(adapter
->ahw
.revision_id
)) {
787 i
= NXRD32(adapter
, NETXEN_SRE_MISC
);
788 adapter
->ahw
.cut_through
= (i
& 0x8000) ? 1 : 0;
791 dev_info(&pdev
->dev
, "firmware v%d.%d.%d [%s]\n",
792 fw_major
, fw_minor
, fw_build
,
793 adapter
->ahw
.cut_through
? "cut-through" : "legacy");
795 if (adapter
->fw_version
>= NETXEN_VERSION_CODE(4, 0, 222))
796 adapter
->capabilities
= NXRD32(adapter
, CRB_FW_CAPABILITIES_1
);
798 if (adapter
->ahw
.port_type
== NETXEN_NIC_XGBE
) {
799 adapter
->num_rxd
= DEFAULT_RCV_DESCRIPTORS_10G
;
800 adapter
->num_jumbo_rxd
= MAX_JUMBO_RCV_DESCRIPTORS_10G
;
801 } else if (adapter
->ahw
.port_type
== NETXEN_NIC_GBE
) {
802 adapter
->num_rxd
= DEFAULT_RCV_DESCRIPTORS_1G
;
803 adapter
->num_jumbo_rxd
= MAX_JUMBO_RCV_DESCRIPTORS_1G
;
806 adapter
->msix_supported
= 0;
807 if (NX_IS_REVISION_P3(adapter
->ahw
.revision_id
)) {
808 adapter
->msix_supported
= !!use_msi_x
;
809 adapter
->rss_supported
= !!use_msi_x
;
812 netxen_rom_fast_read(adapter
,
813 NX_FW_VERSION_OFFSET
, (int *)&flashed_ver
);
814 flashed_ver
= NETXEN_DECODE_VERSION(flashed_ver
);
816 if (flashed_ver
>= NETXEN_VERSION_CODE(3, 4, 336)) {
817 switch (adapter
->ahw
.board_type
) {
818 case NETXEN_BRDTYPE_P2_SB31_10G
:
819 case NETXEN_BRDTYPE_P2_SB31_10G_CX4
:
820 adapter
->msix_supported
= !!use_msi_x
;
821 adapter
->rss_supported
= !!use_msi_x
;
829 adapter
->num_txd
= MAX_CMD_DESCRIPTORS
;
831 if (NX_IS_REVISION_P2(adapter
->ahw
.revision_id
)) {
832 adapter
->num_lro_rxd
= MAX_LRO_RCV_DESCRIPTORS
;
833 adapter
->max_rds_rings
= 3;
835 adapter
->num_lro_rxd
= 0;
836 adapter
->max_rds_rings
= 2;
841 netxen_start_firmware(struct netxen_adapter
*adapter
)
843 int val
, err
, first_boot
;
844 struct pci_dev
*pdev
= adapter
->pdev
;
846 /* required for NX2031 dummy dma */
847 err
= nx_set_dma_mask(adapter
);
851 if (!netxen_can_start_firmware(adapter
))
854 first_boot
= NXRD32(adapter
, NETXEN_CAM_RAM(0x1fc));
856 err
= netxen_check_hw_init(adapter
, first_boot
);
858 dev_err(&pdev
->dev
, "error in init HW init sequence\n");
862 netxen_request_firmware(adapter
);
864 err
= netxen_need_fw_reset(adapter
);
870 if (first_boot
!= 0x55555555) {
871 NXWR32(adapter
, CRB_CMDPEG_STATE
, 0);
872 netxen_pinit_from_rom(adapter
);
876 NXWR32(adapter
, CRB_DMA_SHIFT
, 0x55555555);
877 NXWR32(adapter
, NETXEN_PEG_HALT_STATUS1
, 0);
878 NXWR32(adapter
, NETXEN_PEG_HALT_STATUS2
, 0);
880 if (NX_IS_REVISION_P3(adapter
->ahw
.revision_id
))
881 netxen_set_port_mode(adapter
);
883 err
= netxen_load_firmware(adapter
);
887 netxen_release_firmware(adapter
);
889 if (NX_IS_REVISION_P2(adapter
->ahw
.revision_id
)) {
891 /* Initialize multicast addr pool owners */
893 if (adapter
->ahw
.port_type
== NETXEN_NIC_XGBE
)
895 NXWR32(adapter
, NETXEN_MAC_ADDR_CNTL_REG
, val
);
899 err
= netxen_init_dummy_dma(adapter
);
904 * Tell the hardware our version number.
906 val
= (_NETXEN_NIC_LINUX_MAJOR
<< 16)
907 | ((_NETXEN_NIC_LINUX_MINOR
<< 8))
908 | (_NETXEN_NIC_LINUX_SUBVERSION
);
909 NXWR32(adapter
, CRB_DRIVER_VERSION
, val
);
912 /* Handshake with the card before we register the devices. */
913 err
= netxen_phantom_init(adapter
, NETXEN_NIC_PEG_TUNE
);
915 netxen_free_dummy_dma(adapter
);
919 NXWR32(adapter
, NX_CRB_DEV_STATE
, NX_DEV_READY
);
921 nx_update_dma_mask(adapter
);
923 netxen_check_options(adapter
);
925 adapter
->need_fw_reset
= 0;
927 /* fall through and release firmware */
930 netxen_release_firmware(adapter
);
935 netxen_nic_request_irq(struct netxen_adapter
*adapter
)
937 irq_handler_t handler
;
938 struct nx_host_sds_ring
*sds_ring
;
941 unsigned long flags
= 0;
942 struct net_device
*netdev
= adapter
->netdev
;
943 struct netxen_recv_context
*recv_ctx
= &adapter
->recv_ctx
;
945 if (adapter
->flags
& NETXEN_NIC_MSIX_ENABLED
)
946 handler
= netxen_msix_intr
;
947 else if (adapter
->flags
& NETXEN_NIC_MSI_ENABLED
)
948 handler
= netxen_msi_intr
;
950 flags
|= IRQF_SHARED
;
951 handler
= netxen_intr
;
953 adapter
->irq
= netdev
->irq
;
955 for (ring
= 0; ring
< adapter
->max_sds_rings
; ring
++) {
956 sds_ring
= &recv_ctx
->sds_rings
[ring
];
957 sprintf(sds_ring
->name
, "%s[%d]", netdev
->name
, ring
);
958 err
= request_irq(sds_ring
->irq
, handler
,
959 flags
, sds_ring
->name
, sds_ring
);
968 netxen_nic_free_irq(struct netxen_adapter
*adapter
)
971 struct nx_host_sds_ring
*sds_ring
;
973 struct netxen_recv_context
*recv_ctx
= &adapter
->recv_ctx
;
975 for (ring
= 0; ring
< adapter
->max_sds_rings
; ring
++) {
976 sds_ring
= &recv_ctx
->sds_rings
[ring
];
977 free_irq(sds_ring
->irq
, sds_ring
);
982 netxen_nic_init_coalesce_defaults(struct netxen_adapter
*adapter
)
984 adapter
->coal
.flags
= NETXEN_NIC_INTR_DEFAULT
;
985 adapter
->coal
.normal
.data
.rx_time_us
=
986 NETXEN_DEFAULT_INTR_COALESCE_RX_TIME_US
;
987 adapter
->coal
.normal
.data
.rx_packets
=
988 NETXEN_DEFAULT_INTR_COALESCE_RX_PACKETS
;
989 adapter
->coal
.normal
.data
.tx_time_us
=
990 NETXEN_DEFAULT_INTR_COALESCE_TX_TIME_US
;
991 adapter
->coal
.normal
.data
.tx_packets
=
992 NETXEN_DEFAULT_INTR_COALESCE_TX_PACKETS
;
997 __netxen_nic_up(struct netxen_adapter
*adapter
, struct net_device
*netdev
)
1001 if (adapter
->is_up
!= NETXEN_ADAPTER_UP_MAGIC
)
1004 err
= adapter
->init_port(adapter
, adapter
->physical_port
);
1006 printk(KERN_ERR
"%s: Failed to initialize port %d\n",
1007 netxen_nic_driver_name
, adapter
->portnum
);
1010 if (NX_IS_REVISION_P2(adapter
->ahw
.revision_id
))
1011 adapter
->macaddr_set(adapter
, adapter
->mac_addr
);
1013 adapter
->set_multi(netdev
);
1014 adapter
->set_mtu(adapter
, netdev
->mtu
);
1016 adapter
->ahw
.linkup
= 0;
1018 if (adapter
->max_sds_rings
> 1)
1019 netxen_config_rss(adapter
, 1);
1021 if (NX_IS_REVISION_P3(adapter
->ahw
.revision_id
))
1022 netxen_config_intr_coalesce(adapter
);
1024 if (netdev
->features
& NETIF_F_LRO
)
1025 netxen_config_hw_lro(adapter
, NETXEN_NIC_LRO_ENABLED
);
1027 netxen_napi_enable(adapter
);
1029 if (adapter
->capabilities
& NX_FW_CAPABILITY_LINK_NOTIFICATION
)
1030 netxen_linkevent_request(adapter
, 1);
1032 netxen_nic_set_link_parameters(adapter
);
1034 set_bit(__NX_DEV_UP
, &adapter
->state
);
1038 /* Usage: During resume and firmware recovery module.*/
1041 netxen_nic_up(struct netxen_adapter
*adapter
, struct net_device
*netdev
)
1046 if (netif_running(netdev
))
1047 err
= __netxen_nic_up(adapter
, netdev
);
1053 /* with rtnl_lock */
1055 __netxen_nic_down(struct netxen_adapter
*adapter
, struct net_device
*netdev
)
1057 if (adapter
->is_up
!= NETXEN_ADAPTER_UP_MAGIC
)
1060 if (!test_and_clear_bit(__NX_DEV_UP
, &adapter
->state
))
1064 spin_lock(&adapter
->tx_clean_lock
);
1065 netif_carrier_off(netdev
);
1066 netif_tx_disable(netdev
);
1068 if (adapter
->capabilities
& NX_FW_CAPABILITY_LINK_NOTIFICATION
)
1069 netxen_linkevent_request(adapter
, 0);
1071 if (adapter
->stop_port
)
1072 adapter
->stop_port(adapter
);
1074 if (NX_IS_REVISION_P3(adapter
->ahw
.revision_id
))
1075 netxen_p3_free_mac_list(adapter
);
1077 adapter
->set_promisc(adapter
, NETXEN_NIU_NON_PROMISC_MODE
);
1079 netxen_napi_disable(adapter
);
1081 netxen_release_tx_buffers(adapter
);
1082 spin_unlock(&adapter
->tx_clean_lock
);
1085 /* Usage: During suspend and firmware recovery module */
1088 netxen_nic_down(struct netxen_adapter
*adapter
, struct net_device
*netdev
)
1091 if (netif_running(netdev
))
1092 __netxen_nic_down(adapter
, netdev
);
1098 netxen_nic_attach(struct netxen_adapter
*adapter
)
1100 struct net_device
*netdev
= adapter
->netdev
;
1101 struct pci_dev
*pdev
= adapter
->pdev
;
1103 struct nx_host_rds_ring
*rds_ring
;
1104 struct nx_host_tx_ring
*tx_ring
;
1106 if (adapter
->is_up
== NETXEN_ADAPTER_UP_MAGIC
)
1109 err
= netxen_init_firmware(adapter
);
1113 err
= netxen_napi_add(adapter
, netdev
);
1117 err
= netxen_alloc_sw_resources(adapter
);
1119 printk(KERN_ERR
"%s: Error in setting sw resources\n",
1124 err
= netxen_alloc_hw_resources(adapter
);
1126 printk(KERN_ERR
"%s: Error in setting hw resources\n",
1128 goto err_out_free_sw
;
1131 if (NX_IS_REVISION_P2(adapter
->ahw
.revision_id
)) {
1132 tx_ring
= adapter
->tx_ring
;
1133 tx_ring
->crb_cmd_producer
= netxen_get_ioaddr(adapter
,
1134 crb_cmd_producer
[adapter
->portnum
]);
1135 tx_ring
->crb_cmd_consumer
= netxen_get_ioaddr(adapter
,
1136 crb_cmd_consumer
[adapter
->portnum
]);
1138 tx_ring
->producer
= 0;
1139 tx_ring
->sw_consumer
= 0;
1141 netxen_nic_update_cmd_producer(adapter
, tx_ring
);
1142 netxen_nic_update_cmd_consumer(adapter
, tx_ring
);
1145 for (ring
= 0; ring
< adapter
->max_rds_rings
; ring
++) {
1146 rds_ring
= &adapter
->recv_ctx
.rds_rings
[ring
];
1147 netxen_post_rx_buffers(adapter
, ring
, rds_ring
);
1150 err
= netxen_nic_request_irq(adapter
);
1152 dev_err(&pdev
->dev
, "%s: failed to setup interrupt\n",
1154 goto err_out_free_rxbuf
;
1157 if (NX_IS_REVISION_P3(adapter
->ahw
.revision_id
))
1158 netxen_nic_init_coalesce_defaults(adapter
);
1160 netxen_create_sysfs_entries(adapter
);
1162 adapter
->is_up
= NETXEN_ADAPTER_UP_MAGIC
;
1166 netxen_release_rx_buffers(adapter
);
1167 netxen_free_hw_resources(adapter
);
1169 netxen_free_sw_resources(adapter
);
1174 netxen_nic_detach(struct netxen_adapter
*adapter
)
1176 if (adapter
->is_up
!= NETXEN_ADAPTER_UP_MAGIC
)
1179 netxen_remove_sysfs_entries(adapter
);
1181 netxen_free_hw_resources(adapter
);
1182 netxen_release_rx_buffers(adapter
);
1183 netxen_nic_free_irq(adapter
);
1184 netxen_napi_del(adapter
);
1185 netxen_free_sw_resources(adapter
);
1191 netxen_nic_reset_context(struct netxen_adapter
*adapter
)
1194 struct net_device
*netdev
= adapter
->netdev
;
1196 if (test_and_set_bit(__NX_RESETTING
, &adapter
->state
))
1199 if (adapter
->is_up
== NETXEN_ADAPTER_UP_MAGIC
) {
1201 netif_device_detach(netdev
);
1203 if (netif_running(netdev
))
1204 __netxen_nic_down(adapter
, netdev
);
1206 netxen_nic_detach(adapter
);
1208 if (netif_running(netdev
)) {
1209 err
= netxen_nic_attach(adapter
);
1211 err
= __netxen_nic_up(adapter
, netdev
);
1217 netif_device_attach(netdev
);
1221 clear_bit(__NX_RESETTING
, &adapter
->state
);
1226 netxen_setup_netdev(struct netxen_adapter
*adapter
,
1227 struct net_device
*netdev
)
1230 struct pci_dev
*pdev
= adapter
->pdev
;
1232 adapter
->mc_enabled
= 0;
1233 if (NX_IS_REVISION_P3(adapter
->ahw
.revision_id
))
1234 adapter
->max_mc_count
= 38;
1236 adapter
->max_mc_count
= 16;
1238 netdev
->netdev_ops
= &netxen_netdev_ops
;
1239 netdev
->watchdog_timeo
= 5*HZ
;
1241 netxen_nic_change_mtu(netdev
, netdev
->mtu
);
1243 SET_ETHTOOL_OPS(netdev
, &netxen_nic_ethtool_ops
);
1245 netdev
->hw_features
= NETIF_F_SG
| NETIF_F_IP_CSUM
| NETIF_F_TSO
|
1248 if (NX_IS_REVISION_P3(adapter
->ahw
.revision_id
))
1249 netdev
->hw_features
|= NETIF_F_IPV6_CSUM
| NETIF_F_TSO6
;
1251 netdev
->vlan_features
|= netdev
->hw_features
;
1253 if (adapter
->pci_using_dac
) {
1254 netdev
->features
|= NETIF_F_HIGHDMA
;
1255 netdev
->vlan_features
|= NETIF_F_HIGHDMA
;
1258 if (adapter
->capabilities
& NX_FW_CAPABILITY_FVLANTX
)
1259 netdev
->hw_features
|= NETIF_F_HW_VLAN_TX
;
1261 if (adapter
->capabilities
& NX_FW_CAPABILITY_HW_LRO
)
1262 netdev
->hw_features
|= NETIF_F_LRO
;
1264 netdev
->features
|= netdev
->hw_features
;
1266 netdev
->irq
= adapter
->msix_entries
[0].vector
;
1268 INIT_WORK(&adapter
->tx_timeout_task
, netxen_tx_timeout_task
);
1270 if (netxen_read_mac_addr(adapter
))
1271 dev_warn(&pdev
->dev
, "failed to read mac addr\n");
1273 netif_carrier_off(netdev
);
1275 err
= register_netdev(netdev
);
1277 dev_err(&pdev
->dev
, "failed to register net device\n");
1284 #ifdef CONFIG_PCIEAER
1285 static void netxen_mask_aer_correctable(struct netxen_adapter
*adapter
)
1287 struct pci_dev
*pdev
= adapter
->pdev
;
1288 struct pci_dev
*root
= pdev
->bus
->self
;
1291 if (adapter
->ahw
.board_type
!= NETXEN_BRDTYPE_P3_4_GB_MM
&&
1292 adapter
->ahw
.board_type
!= NETXEN_BRDTYPE_P3_10G_TP
)
1295 if (root
->pcie_type
!= PCI_EXP_TYPE_ROOT_PORT
)
1298 aer_pos
= pci_find_ext_capability(root
, PCI_EXT_CAP_ID_ERR
);
1302 pci_write_config_dword(root
, aer_pos
+ PCI_ERR_COR_MASK
, 0xffff);
1306 static int __devinit
1307 netxen_nic_probe(struct pci_dev
*pdev
, const struct pci_device_id
*ent
)
1309 struct net_device
*netdev
= NULL
;
1310 struct netxen_adapter
*adapter
= NULL
;
1312 int pci_func_id
= PCI_FUNC(pdev
->devfn
);
1313 uint8_t revision_id
;
1316 if (pdev
->revision
>= NX_P3_A0
&& pdev
->revision
<= NX_P3_B1
) {
1317 pr_warning("%s: chip revisions between 0x%x-0x%x "
1318 "will not be enabled.\n",
1319 module_name(THIS_MODULE
), NX_P3_A0
, NX_P3_B1
);
1323 if ((err
= pci_enable_device(pdev
)))
1326 if (!(pci_resource_flags(pdev
, 0) & IORESOURCE_MEM
)) {
1328 goto err_out_disable_pdev
;
1331 if ((err
= pci_request_regions(pdev
, netxen_nic_driver_name
)))
1332 goto err_out_disable_pdev
;
1334 if (NX_IS_REVISION_P3(pdev
->revision
))
1335 pci_enable_pcie_error_reporting(pdev
);
1337 pci_set_master(pdev
);
1339 netdev
= alloc_etherdev(sizeof(struct netxen_adapter
));
1341 dev_err(&pdev
->dev
, "failed to allocate net_device\n");
1343 goto err_out_free_res
;
1346 SET_NETDEV_DEV(netdev
, &pdev
->dev
);
1348 adapter
= netdev_priv(netdev
);
1349 adapter
->netdev
= netdev
;
1350 adapter
->pdev
= pdev
;
1351 adapter
->ahw
.pci_func
= pci_func_id
;
1353 revision_id
= pdev
->revision
;
1354 adapter
->ahw
.revision_id
= revision_id
;
1356 rwlock_init(&adapter
->ahw
.crb_lock
);
1357 spin_lock_init(&adapter
->ahw
.mem_lock
);
1359 spin_lock_init(&adapter
->tx_clean_lock
);
1360 INIT_LIST_HEAD(&adapter
->mac_list
);
1362 err
= netxen_setup_pci_map(adapter
);
1364 goto err_out_free_netdev
;
1366 /* This will be reset for mezz cards */
1367 adapter
->portnum
= pci_func_id
;
1369 err
= netxen_nic_get_board_info(adapter
);
1371 dev_err(&pdev
->dev
, "Error getting board config info.\n");
1372 goto err_out_iounmap
;
1375 #ifdef CONFIG_PCIEAER
1376 netxen_mask_aer_correctable(adapter
);
1379 /* Mezz cards have PCI function 0,2,3 enabled */
1380 switch (adapter
->ahw
.board_type
) {
1381 case NETXEN_BRDTYPE_P2_SB31_10G_IMEZ
:
1382 case NETXEN_BRDTYPE_P2_SB31_10G_HMEZ
:
1383 if (pci_func_id
>= 2)
1384 adapter
->portnum
= pci_func_id
- 2;
1390 if (adapter
->portnum
== 0) {
1391 val
= NXRD32(adapter
, NX_CRB_DEV_REF_COUNT
);
1392 if (val
!= 0xffffffff && val
!= 0) {
1393 NXWR32(adapter
, NX_CRB_DEV_REF_COUNT
, 0);
1394 adapter
->need_fw_reset
= 1;
1398 err
= netxen_start_firmware(adapter
);
1400 goto err_out_decr_ref
;
1403 * See if the firmware gave us a virtual-physical port mapping.
1405 adapter
->physical_port
= adapter
->portnum
;
1406 if (NX_IS_REVISION_P2(adapter
->ahw
.revision_id
)) {
1407 i
= NXRD32(adapter
, CRB_V2P(adapter
->portnum
));
1408 if (i
!= 0x55555555)
1409 adapter
->physical_port
= i
;
1412 netxen_nic_clear_stats(adapter
);
1414 netxen_setup_intr(adapter
);
1416 err
= netxen_setup_netdev(adapter
, netdev
);
1418 goto err_out_disable_msi
;
1420 pci_set_drvdata(pdev
, adapter
);
1422 netxen_schedule_work(adapter
, netxen_fw_poll_work
, FW_POLL_DELAY
);
1424 switch (adapter
->ahw
.port_type
) {
1425 case NETXEN_NIC_GBE
:
1426 dev_info(&adapter
->pdev
->dev
, "%s: GbE port initialized\n",
1427 adapter
->netdev
->name
);
1429 case NETXEN_NIC_XGBE
:
1430 dev_info(&adapter
->pdev
->dev
, "%s: XGbE port initialized\n",
1431 adapter
->netdev
->name
);
1435 netxen_create_diag_entries(adapter
);
1439 err_out_disable_msi
:
1440 netxen_teardown_intr(adapter
);
1442 netxen_free_dummy_dma(adapter
);
1445 nx_decr_dev_ref_cnt(adapter
);
1448 netxen_cleanup_pci_map(adapter
);
1450 err_out_free_netdev
:
1451 free_netdev(netdev
);
1454 pci_release_regions(pdev
);
1456 err_out_disable_pdev
:
1457 pci_set_drvdata(pdev
, NULL
);
1458 pci_disable_device(pdev
);
1462 static void __devexit
netxen_nic_remove(struct pci_dev
*pdev
)
1464 struct netxen_adapter
*adapter
;
1465 struct net_device
*netdev
;
1467 adapter
= pci_get_drvdata(pdev
);
1468 if (adapter
== NULL
)
1471 netdev
= adapter
->netdev
;
1473 netxen_cancel_fw_work(adapter
);
1475 unregister_netdev(netdev
);
1477 cancel_work_sync(&adapter
->tx_timeout_task
);
1479 netxen_nic_detach(adapter
);
1481 nx_decr_dev_ref_cnt(adapter
);
1483 if (adapter
->portnum
== 0)
1484 netxen_free_dummy_dma(adapter
);
1486 clear_bit(__NX_RESETTING
, &adapter
->state
);
1488 netxen_teardown_intr(adapter
);
1490 netxen_remove_diag_entries(adapter
);
1492 netxen_cleanup_pci_map(adapter
);
1494 netxen_release_firmware(adapter
);
1496 if (NX_IS_REVISION_P3(pdev
->revision
))
1497 pci_disable_pcie_error_reporting(pdev
);
1499 pci_release_regions(pdev
);
1500 pci_disable_device(pdev
);
1501 pci_set_drvdata(pdev
, NULL
);
1503 free_netdev(netdev
);
1506 static void netxen_nic_detach_func(struct netxen_adapter
*adapter
)
1508 struct net_device
*netdev
= adapter
->netdev
;
1510 netif_device_detach(netdev
);
1512 netxen_cancel_fw_work(adapter
);
1514 if (netif_running(netdev
))
1515 netxen_nic_down(adapter
, netdev
);
1517 cancel_work_sync(&adapter
->tx_timeout_task
);
1519 netxen_nic_detach(adapter
);
1521 if (adapter
->portnum
== 0)
1522 netxen_free_dummy_dma(adapter
);
1524 nx_decr_dev_ref_cnt(adapter
);
1526 clear_bit(__NX_RESETTING
, &adapter
->state
);
1529 static int netxen_nic_attach_func(struct pci_dev
*pdev
)
1531 struct netxen_adapter
*adapter
= pci_get_drvdata(pdev
);
1532 struct net_device
*netdev
= adapter
->netdev
;
1535 err
= pci_enable_device(pdev
);
1539 pci_set_power_state(pdev
, PCI_D0
);
1540 pci_set_master(pdev
);
1541 pci_restore_state(pdev
);
1543 adapter
->ahw
.crb_win
= -1;
1544 adapter
->ahw
.ocm_win
= -1;
1546 err
= netxen_start_firmware(adapter
);
1548 dev_err(&pdev
->dev
, "failed to start firmware\n");
1552 if (netif_running(netdev
)) {
1553 err
= netxen_nic_attach(adapter
);
1557 err
= netxen_nic_up(adapter
, netdev
);
1559 goto err_out_detach
;
1561 netxen_config_indev_addr(netdev
, NETDEV_UP
);
1564 netif_device_attach(netdev
);
1565 netxen_schedule_work(adapter
, netxen_fw_poll_work
, FW_POLL_DELAY
);
1569 netxen_nic_detach(adapter
);
1571 nx_decr_dev_ref_cnt(adapter
);
1575 static pci_ers_result_t
netxen_io_error_detected(struct pci_dev
*pdev
,
1576 pci_channel_state_t state
)
1578 struct netxen_adapter
*adapter
= pci_get_drvdata(pdev
);
1580 if (state
== pci_channel_io_perm_failure
)
1581 return PCI_ERS_RESULT_DISCONNECT
;
1583 if (nx_dev_request_aer(adapter
))
1584 return PCI_ERS_RESULT_RECOVERED
;
1586 netxen_nic_detach_func(adapter
);
1588 pci_disable_device(pdev
);
1590 return PCI_ERS_RESULT_NEED_RESET
;
1593 static pci_ers_result_t
netxen_io_slot_reset(struct pci_dev
*pdev
)
1597 err
= netxen_nic_attach_func(pdev
);
1599 return err
? PCI_ERS_RESULT_DISCONNECT
: PCI_ERS_RESULT_RECOVERED
;
1602 static void netxen_io_resume(struct pci_dev
*pdev
)
1604 pci_cleanup_aer_uncorrect_error_status(pdev
);
1607 static void netxen_nic_shutdown(struct pci_dev
*pdev
)
1609 struct netxen_adapter
*adapter
= pci_get_drvdata(pdev
);
1611 netxen_nic_detach_func(adapter
);
1613 if (pci_save_state(pdev
))
1616 if (netxen_nic_wol_supported(adapter
)) {
1617 pci_enable_wake(pdev
, PCI_D3cold
, 1);
1618 pci_enable_wake(pdev
, PCI_D3hot
, 1);
1621 pci_disable_device(pdev
);
1626 netxen_nic_suspend(struct pci_dev
*pdev
, pm_message_t state
)
1628 struct netxen_adapter
*adapter
= pci_get_drvdata(pdev
);
1631 netxen_nic_detach_func(adapter
);
1633 retval
= pci_save_state(pdev
);
1637 if (netxen_nic_wol_supported(adapter
)) {
1638 pci_enable_wake(pdev
, PCI_D3cold
, 1);
1639 pci_enable_wake(pdev
, PCI_D3hot
, 1);
1642 pci_disable_device(pdev
);
1643 pci_set_power_state(pdev
, pci_choose_state(pdev
, state
));
1649 netxen_nic_resume(struct pci_dev
*pdev
)
1651 return netxen_nic_attach_func(pdev
);
1655 static int netxen_nic_open(struct net_device
*netdev
)
1657 struct netxen_adapter
*adapter
= netdev_priv(netdev
);
1660 if (adapter
->driver_mismatch
)
1663 err
= netxen_nic_attach(adapter
);
1667 err
= __netxen_nic_up(adapter
, netdev
);
1671 netif_start_queue(netdev
);
1676 netxen_nic_detach(adapter
);
1681 * netxen_nic_close - Disables a network interface entry point
1683 static int netxen_nic_close(struct net_device
*netdev
)
1685 struct netxen_adapter
*adapter
= netdev_priv(netdev
);
1687 __netxen_nic_down(adapter
, netdev
);
1692 netxen_tso_check(struct net_device
*netdev
,
1693 struct nx_host_tx_ring
*tx_ring
,
1694 struct cmd_desc_type0
*first_desc
,
1695 struct sk_buff
*skb
)
1697 u8 opcode
= TX_ETHER_PKT
;
1698 __be16 protocol
= skb
->protocol
;
1699 u16 flags
= 0, vid
= 0;
1701 int copied
, offset
, copy_len
, hdr_len
= 0, tso
= 0, vlan_oob
= 0;
1702 struct cmd_desc_type0
*hwdesc
;
1703 struct vlan_ethhdr
*vh
;
1705 if (protocol
== cpu_to_be16(ETH_P_8021Q
)) {
1707 vh
= (struct vlan_ethhdr
*)skb
->data
;
1708 protocol
= vh
->h_vlan_encapsulated_proto
;
1709 flags
= FLAGS_VLAN_TAGGED
;
1711 } else if (vlan_tx_tag_present(skb
)) {
1713 flags
= FLAGS_VLAN_OOB
;
1714 vid
= vlan_tx_tag_get(skb
);
1715 netxen_set_tx_vlan_tci(first_desc
, vid
);
1719 if ((netdev
->features
& (NETIF_F_TSO
| NETIF_F_TSO6
)) &&
1720 skb_shinfo(skb
)->gso_size
> 0) {
1722 hdr_len
= skb_transport_offset(skb
) + tcp_hdrlen(skb
);
1724 first_desc
->mss
= cpu_to_le16(skb_shinfo(skb
)->gso_size
);
1725 first_desc
->total_hdr_length
= hdr_len
;
1727 first_desc
->total_hdr_length
+= VLAN_HLEN
;
1728 first_desc
->tcp_hdr_offset
= VLAN_HLEN
;
1729 first_desc
->ip_hdr_offset
= VLAN_HLEN
;
1730 /* Only in case of TSO on vlan device */
1731 flags
|= FLAGS_VLAN_TAGGED
;
1734 opcode
= (protocol
== cpu_to_be16(ETH_P_IPV6
)) ?
1735 TX_TCP_LSO6
: TX_TCP_LSO
;
1738 } else if (skb
->ip_summed
== CHECKSUM_PARTIAL
) {
1741 if (protocol
== cpu_to_be16(ETH_P_IP
)) {
1742 l4proto
= ip_hdr(skb
)->protocol
;
1744 if (l4proto
== IPPROTO_TCP
)
1745 opcode
= TX_TCP_PKT
;
1746 else if(l4proto
== IPPROTO_UDP
)
1747 opcode
= TX_UDP_PKT
;
1748 } else if (protocol
== cpu_to_be16(ETH_P_IPV6
)) {
1749 l4proto
= ipv6_hdr(skb
)->nexthdr
;
1751 if (l4proto
== IPPROTO_TCP
)
1752 opcode
= TX_TCPV6_PKT
;
1753 else if(l4proto
== IPPROTO_UDP
)
1754 opcode
= TX_UDPV6_PKT
;
1758 first_desc
->tcp_hdr_offset
+= skb_transport_offset(skb
);
1759 first_desc
->ip_hdr_offset
+= skb_network_offset(skb
);
1760 netxen_set_tx_flags_opcode(first_desc
, flags
, opcode
);
1765 /* For LSO, we need to copy the MAC/IP/TCP headers into
1766 * the descriptor ring
1768 producer
= tx_ring
->producer
;
1773 /* Create a TSO vlan header template for firmware */
1775 hwdesc
= &tx_ring
->desc_head
[producer
];
1776 tx_ring
->cmd_buf_arr
[producer
].skb
= NULL
;
1778 copy_len
= min((int)sizeof(struct cmd_desc_type0
) - offset
,
1779 hdr_len
+ VLAN_HLEN
);
1781 vh
= (struct vlan_ethhdr
*)((char *)hwdesc
+ 2);
1782 skb_copy_from_linear_data(skb
, vh
, 12);
1783 vh
->h_vlan_proto
= htons(ETH_P_8021Q
);
1784 vh
->h_vlan_TCI
= htons(vid
);
1785 skb_copy_from_linear_data_offset(skb
, 12,
1786 (char *)vh
+ 16, copy_len
- 16);
1788 copied
= copy_len
- VLAN_HLEN
;
1791 producer
= get_next_index(producer
, tx_ring
->num_desc
);
1794 while (copied
< hdr_len
) {
1796 copy_len
= min((int)sizeof(struct cmd_desc_type0
) - offset
,
1797 (hdr_len
- copied
));
1799 hwdesc
= &tx_ring
->desc_head
[producer
];
1800 tx_ring
->cmd_buf_arr
[producer
].skb
= NULL
;
1802 skb_copy_from_linear_data_offset(skb
, copied
,
1803 (char *)hwdesc
+ offset
, copy_len
);
1808 producer
= get_next_index(producer
, tx_ring
->num_desc
);
1811 tx_ring
->producer
= producer
;
1816 netxen_map_tx_skb(struct pci_dev
*pdev
,
1817 struct sk_buff
*skb
, struct netxen_cmd_buffer
*pbuf
)
1819 struct netxen_skb_frag
*nf
;
1820 struct skb_frag_struct
*frag
;
1824 nr_frags
= skb_shinfo(skb
)->nr_frags
;
1825 nf
= &pbuf
->frag_array
[0];
1827 map
= pci_map_single(pdev
, skb
->data
,
1828 skb_headlen(skb
), PCI_DMA_TODEVICE
);
1829 if (pci_dma_mapping_error(pdev
, map
))
1833 nf
->length
= skb_headlen(skb
);
1835 for (i
= 0; i
< nr_frags
; i
++) {
1836 frag
= &skb_shinfo(skb
)->frags
[i
];
1837 nf
= &pbuf
->frag_array
[i
+1];
1839 map
= pci_map_page(pdev
, frag
->page
, frag
->page_offset
,
1840 frag
->size
, PCI_DMA_TODEVICE
);
1841 if (pci_dma_mapping_error(pdev
, map
))
1845 nf
->length
= frag
->size
;
1852 nf
= &pbuf
->frag_array
[i
+1];
1853 pci_unmap_page(pdev
, nf
->dma
, nf
->length
, PCI_DMA_TODEVICE
);
1856 nf
= &pbuf
->frag_array
[0];
1857 pci_unmap_single(pdev
, nf
->dma
, skb_headlen(skb
), PCI_DMA_TODEVICE
);
1864 netxen_clear_cmddesc(u64
*desc
)
1871 netxen_nic_xmit_frame(struct sk_buff
*skb
, struct net_device
*netdev
)
1873 struct netxen_adapter
*adapter
= netdev_priv(netdev
);
1874 struct nx_host_tx_ring
*tx_ring
= adapter
->tx_ring
;
1875 struct netxen_cmd_buffer
*pbuf
;
1876 struct netxen_skb_frag
*buffrag
;
1877 struct cmd_desc_type0
*hwdesc
, *first_desc
;
1878 struct pci_dev
*pdev
;
1881 struct skb_frag_struct
*frag
;
1884 int frag_count
, no_of_desc
;
1885 u32 num_txd
= tx_ring
->num_desc
;
1887 frag_count
= skb_shinfo(skb
)->nr_frags
+ 1;
1889 /* 14 frags supported for normal packet and
1890 * 32 frags supported for TSO packet
1892 if (!skb_is_gso(skb
) && frag_count
> NETXEN_MAX_FRAGS_PER_TX
) {
1894 for (i
= 0; i
< (frag_count
- NETXEN_MAX_FRAGS_PER_TX
); i
++) {
1895 frag
= &skb_shinfo(skb
)->frags
[i
];
1896 delta
+= frag
->size
;
1899 if (!__pskb_pull_tail(skb
, delta
))
1902 frag_count
= 1 + skb_shinfo(skb
)->nr_frags
;
1904 /* 4 fragments per cmd des */
1905 no_of_desc
= (frag_count
+ 3) >> 2;
1907 if (unlikely(netxen_tx_avail(tx_ring
) <= TX_STOP_THRESH
)) {
1908 netif_stop_queue(netdev
);
1910 if (netxen_tx_avail(tx_ring
) > TX_STOP_THRESH
)
1911 netif_start_queue(netdev
);
1913 return NETDEV_TX_BUSY
;
1916 producer
= tx_ring
->producer
;
1917 pbuf
= &tx_ring
->cmd_buf_arr
[producer
];
1919 pdev
= adapter
->pdev
;
1921 if (netxen_map_tx_skb(pdev
, skb
, pbuf
))
1925 pbuf
->frag_count
= frag_count
;
1927 first_desc
= hwdesc
= &tx_ring
->desc_head
[producer
];
1928 netxen_clear_cmddesc((u64
*)hwdesc
);
1930 netxen_set_tx_frags_len(first_desc
, frag_count
, skb
->len
);
1931 netxen_set_tx_port(first_desc
, adapter
->portnum
);
1933 for (i
= 0; i
< frag_count
; i
++) {
1937 if ((k
== 0) && (i
> 0)) {
1938 /* move to next desc.*/
1939 producer
= get_next_index(producer
, num_txd
);
1940 hwdesc
= &tx_ring
->desc_head
[producer
];
1941 netxen_clear_cmddesc((u64
*)hwdesc
);
1942 tx_ring
->cmd_buf_arr
[producer
].skb
= NULL
;
1945 buffrag
= &pbuf
->frag_array
[i
];
1947 hwdesc
->buffer_length
[k
] = cpu_to_le16(buffrag
->length
);
1950 hwdesc
->addr_buffer1
= cpu_to_le64(buffrag
->dma
);
1953 hwdesc
->addr_buffer2
= cpu_to_le64(buffrag
->dma
);
1956 hwdesc
->addr_buffer3
= cpu_to_le64(buffrag
->dma
);
1959 hwdesc
->addr_buffer4
= cpu_to_le64(buffrag
->dma
);
1964 tx_ring
->producer
= get_next_index(producer
, num_txd
);
1966 netxen_tso_check(netdev
, tx_ring
, first_desc
, skb
);
1968 adapter
->stats
.txbytes
+= skb
->len
;
1969 adapter
->stats
.xmitcalled
++;
1971 netxen_nic_update_cmd_producer(adapter
, tx_ring
);
1973 return NETDEV_TX_OK
;
1976 adapter
->stats
.txdropped
++;
1977 dev_kfree_skb_any(skb
);
1978 return NETDEV_TX_OK
;
1981 static int netxen_nic_check_temp(struct netxen_adapter
*adapter
)
1983 struct net_device
*netdev
= adapter
->netdev
;
1984 uint32_t temp
, temp_state
, temp_val
;
1987 temp
= NXRD32(adapter
, CRB_TEMP_STATE
);
1989 temp_state
= nx_get_temp_state(temp
);
1990 temp_val
= nx_get_temp_val(temp
);
1992 if (temp_state
== NX_TEMP_PANIC
) {
1994 "%s: Device temperature %d degrees C exceeds"
1995 " maximum allowed. Hardware has been shut down.\n",
1996 netdev
->name
, temp_val
);
1998 } else if (temp_state
== NX_TEMP_WARN
) {
1999 if (adapter
->temp
== NX_TEMP_NORMAL
) {
2001 "%s: Device temperature %d degrees C "
2002 "exceeds operating range."
2003 " Immediate action needed.\n",
2004 netdev
->name
, temp_val
);
2007 if (adapter
->temp
== NX_TEMP_WARN
) {
2009 "%s: Device temperature is now %d degrees C"
2010 " in normal range.\n", netdev
->name
,
2014 adapter
->temp
= temp_state
;
2018 void netxen_advert_link_change(struct netxen_adapter
*adapter
, int linkup
)
2020 struct net_device
*netdev
= adapter
->netdev
;
2022 if (adapter
->ahw
.linkup
&& !linkup
) {
2023 printk(KERN_INFO
"%s: %s NIC Link is down\n",
2024 netxen_nic_driver_name
, netdev
->name
);
2025 adapter
->ahw
.linkup
= 0;
2026 if (netif_running(netdev
)) {
2027 netif_carrier_off(netdev
);
2028 netif_stop_queue(netdev
);
2030 adapter
->link_changed
= !adapter
->has_link_events
;
2031 } else if (!adapter
->ahw
.linkup
&& linkup
) {
2032 printk(KERN_INFO
"%s: %s NIC Link is up\n",
2033 netxen_nic_driver_name
, netdev
->name
);
2034 adapter
->ahw
.linkup
= 1;
2035 if (netif_running(netdev
)) {
2036 netif_carrier_on(netdev
);
2037 netif_wake_queue(netdev
);
2039 adapter
->link_changed
= !adapter
->has_link_events
;
2043 static void netxen_nic_handle_phy_intr(struct netxen_adapter
*adapter
)
2045 u32 val
, port
, linkup
;
2047 port
= adapter
->physical_port
;
2049 if (NX_IS_REVISION_P3(adapter
->ahw
.revision_id
)) {
2050 val
= NXRD32(adapter
, CRB_XG_STATE_P3
);
2051 val
= XG_LINK_STATE_P3(adapter
->ahw
.pci_func
, val
);
2052 linkup
= (val
== XG_LINK_UP_P3
);
2054 val
= NXRD32(adapter
, CRB_XG_STATE
);
2055 val
= (val
>> port
*8) & 0xff;
2056 linkup
= (val
== XG_LINK_UP
);
2059 netxen_advert_link_change(adapter
, linkup
);
2062 static void netxen_tx_timeout(struct net_device
*netdev
)
2064 struct netxen_adapter
*adapter
= netdev_priv(netdev
);
2066 if (test_bit(__NX_RESETTING
, &adapter
->state
))
2069 dev_err(&netdev
->dev
, "transmit timeout, resetting.\n");
2070 schedule_work(&adapter
->tx_timeout_task
);
2073 static void netxen_tx_timeout_task(struct work_struct
*work
)
2075 struct netxen_adapter
*adapter
=
2076 container_of(work
, struct netxen_adapter
, tx_timeout_task
);
2078 if (!netif_running(adapter
->netdev
))
2081 if (test_and_set_bit(__NX_RESETTING
, &adapter
->state
))
2084 if (++adapter
->tx_timeo_cnt
>= NX_MAX_TX_TIMEOUTS
)
2088 if (NX_IS_REVISION_P2(adapter
->ahw
.revision_id
)) {
2089 /* try to scrub interrupt */
2090 netxen_napi_disable(adapter
);
2092 netxen_napi_enable(adapter
);
2094 netif_wake_queue(adapter
->netdev
);
2096 clear_bit(__NX_RESETTING
, &adapter
->state
);
2098 clear_bit(__NX_RESETTING
, &adapter
->state
);
2099 if (netxen_nic_reset_context(adapter
)) {
2104 adapter
->netdev
->trans_start
= jiffies
;
2109 adapter
->need_fw_reset
= 1;
2110 clear_bit(__NX_RESETTING
, &adapter
->state
);
2113 static struct net_device_stats
*netxen_nic_get_stats(struct net_device
*netdev
)
2115 struct netxen_adapter
*adapter
= netdev_priv(netdev
);
2116 struct net_device_stats
*stats
= &netdev
->stats
;
2118 stats
->rx_packets
= adapter
->stats
.rx_pkts
+ adapter
->stats
.lro_pkts
;
2119 stats
->tx_packets
= adapter
->stats
.xmitfinished
;
2120 stats
->rx_bytes
= adapter
->stats
.rxbytes
;
2121 stats
->tx_bytes
= adapter
->stats
.txbytes
;
2122 stats
->rx_dropped
= adapter
->stats
.rxdropped
;
2123 stats
->tx_dropped
= adapter
->stats
.txdropped
;
2128 static irqreturn_t
netxen_intr(int irq
, void *data
)
2130 struct nx_host_sds_ring
*sds_ring
= data
;
2131 struct netxen_adapter
*adapter
= sds_ring
->adapter
;
2134 status
= readl(adapter
->isr_int_vec
);
2136 if (!(status
& adapter
->int_vec_bit
))
2139 if (NX_IS_REVISION_P3(adapter
->ahw
.revision_id
)) {
2140 /* check interrupt state machine, to be sure */
2141 status
= readl(adapter
->crb_int_state_reg
);
2142 if (!ISR_LEGACY_INT_TRIGGERED(status
))
2146 unsigned long our_int
= 0;
2148 our_int
= readl(adapter
->crb_int_state_reg
);
2150 /* not our interrupt */
2151 if (!test_and_clear_bit((7 + adapter
->portnum
), &our_int
))
2154 /* claim interrupt */
2155 writel((our_int
& 0xffffffff), adapter
->crb_int_state_reg
);
2157 /* clear interrupt */
2158 netxen_nic_disable_int(sds_ring
);
2161 writel(0xffffffff, adapter
->tgt_status_reg
);
2162 /* read twice to ensure write is flushed */
2163 readl(adapter
->isr_int_vec
);
2164 readl(adapter
->isr_int_vec
);
2166 napi_schedule(&sds_ring
->napi
);
2171 static irqreturn_t
netxen_msi_intr(int irq
, void *data
)
2173 struct nx_host_sds_ring
*sds_ring
= data
;
2174 struct netxen_adapter
*adapter
= sds_ring
->adapter
;
2176 /* clear interrupt */
2177 writel(0xffffffff, adapter
->tgt_status_reg
);
2179 napi_schedule(&sds_ring
->napi
);
2183 static irqreturn_t
netxen_msix_intr(int irq
, void *data
)
2185 struct nx_host_sds_ring
*sds_ring
= data
;
2187 napi_schedule(&sds_ring
->napi
);
2191 static int netxen_nic_poll(struct napi_struct
*napi
, int budget
)
2193 struct nx_host_sds_ring
*sds_ring
=
2194 container_of(napi
, struct nx_host_sds_ring
, napi
);
2196 struct netxen_adapter
*adapter
= sds_ring
->adapter
;
2201 tx_complete
= netxen_process_cmd_ring(adapter
);
2203 work_done
= netxen_process_rcv_ring(sds_ring
, budget
);
2205 if ((work_done
< budget
) && tx_complete
) {
2206 napi_complete(&sds_ring
->napi
);
2207 if (test_bit(__NX_DEV_UP
, &adapter
->state
))
2208 netxen_nic_enable_int(sds_ring
);
2214 #ifdef CONFIG_NET_POLL_CONTROLLER
2215 static void netxen_nic_poll_controller(struct net_device
*netdev
)
2218 struct nx_host_sds_ring
*sds_ring
;
2219 struct netxen_adapter
*adapter
= netdev_priv(netdev
);
2220 struct netxen_recv_context
*recv_ctx
= &adapter
->recv_ctx
;
2222 disable_irq(adapter
->irq
);
2223 for (ring
= 0; ring
< adapter
->max_sds_rings
; ring
++) {
2224 sds_ring
= &recv_ctx
->sds_rings
[ring
];
2225 netxen_intr(adapter
->irq
, sds_ring
);
2227 enable_irq(adapter
->irq
);
2232 nx_incr_dev_ref_cnt(struct netxen_adapter
*adapter
)
2235 if (netxen_api_lock(adapter
))
2238 count
= NXRD32(adapter
, NX_CRB_DEV_REF_COUNT
);
2240 NXWR32(adapter
, NX_CRB_DEV_REF_COUNT
, ++count
);
2242 netxen_api_unlock(adapter
);
2247 nx_decr_dev_ref_cnt(struct netxen_adapter
*adapter
)
2250 if (netxen_api_lock(adapter
))
2253 count
= NXRD32(adapter
, NX_CRB_DEV_REF_COUNT
);
2254 WARN_ON(count
== 0);
2256 NXWR32(adapter
, NX_CRB_DEV_REF_COUNT
, --count
);
2259 NXWR32(adapter
, NX_CRB_DEV_STATE
, NX_DEV_COLD
);
2261 netxen_api_unlock(adapter
);
2266 nx_dev_request_aer(struct netxen_adapter
*adapter
)
2271 if (netxen_api_lock(adapter
))
2274 state
= NXRD32(adapter
, NX_CRB_DEV_STATE
);
2276 if (state
== NX_DEV_NEED_AER
)
2278 else if (state
== NX_DEV_READY
) {
2279 NXWR32(adapter
, NX_CRB_DEV_STATE
, NX_DEV_NEED_AER
);
2283 netxen_api_unlock(adapter
);
2288 nx_dev_request_reset(struct netxen_adapter
*adapter
)
2293 if (netxen_api_lock(adapter
))
2296 state
= NXRD32(adapter
, NX_CRB_DEV_STATE
);
2298 if (state
== NX_DEV_NEED_RESET
)
2300 else if (state
!= NX_DEV_INITALIZING
&& state
!= NX_DEV_NEED_AER
) {
2301 NXWR32(adapter
, NX_CRB_DEV_STATE
, NX_DEV_NEED_RESET
);
2305 netxen_api_unlock(adapter
);
2311 netxen_can_start_firmware(struct netxen_adapter
*adapter
)
2316 if (netxen_api_lock(adapter
))
2319 count
= NXRD32(adapter
, NX_CRB_DEV_REF_COUNT
);
2321 if ((count
< 0) || (count
>= NX_MAX_PCI_FUNC
))
2326 NXWR32(adapter
, NX_CRB_DEV_STATE
, NX_DEV_INITALIZING
);
2329 NXWR32(adapter
, NX_CRB_DEV_REF_COUNT
, ++count
);
2331 netxen_api_unlock(adapter
);
2337 netxen_schedule_work(struct netxen_adapter
*adapter
,
2338 work_func_t func
, int delay
)
2340 INIT_DELAYED_WORK(&adapter
->fw_work
, func
);
2341 schedule_delayed_work(&adapter
->fw_work
, delay
);
2345 netxen_cancel_fw_work(struct netxen_adapter
*adapter
)
2347 while (test_and_set_bit(__NX_RESETTING
, &adapter
->state
))
2350 cancel_delayed_work_sync(&adapter
->fw_work
);
2354 netxen_attach_work(struct work_struct
*work
)
2356 struct netxen_adapter
*adapter
= container_of(work
,
2357 struct netxen_adapter
, fw_work
.work
);
2358 struct net_device
*netdev
= adapter
->netdev
;
2361 if (netif_running(netdev
)) {
2362 err
= netxen_nic_attach(adapter
);
2366 err
= netxen_nic_up(adapter
, netdev
);
2368 netxen_nic_detach(adapter
);
2372 netxen_config_indev_addr(netdev
, NETDEV_UP
);
2375 netif_device_attach(netdev
);
2378 adapter
->fw_fail_cnt
= 0;
2379 clear_bit(__NX_RESETTING
, &adapter
->state
);
2380 netxen_schedule_work(adapter
, netxen_fw_poll_work
, FW_POLL_DELAY
);
2384 netxen_fwinit_work(struct work_struct
*work
)
2386 struct netxen_adapter
*adapter
= container_of(work
,
2387 struct netxen_adapter
, fw_work
.work
);
2390 dev_state
= NXRD32(adapter
, NX_CRB_DEV_STATE
);
2392 switch (dev_state
) {
2395 if (!netxen_start_firmware(adapter
)) {
2396 netxen_schedule_work(adapter
, netxen_attach_work
, 0);
2401 case NX_DEV_NEED_RESET
:
2402 case NX_DEV_INITALIZING
:
2403 if (++adapter
->fw_wait_cnt
< FW_POLL_THRESH
) {
2404 netxen_schedule_work(adapter
,
2405 netxen_fwinit_work
, 2 * FW_POLL_DELAY
);
2411 nx_incr_dev_ref_cnt(adapter
);
2415 clear_bit(__NX_RESETTING
, &adapter
->state
);
2419 netxen_detach_work(struct work_struct
*work
)
2421 struct netxen_adapter
*adapter
= container_of(work
,
2422 struct netxen_adapter
, fw_work
.work
);
2423 struct net_device
*netdev
= adapter
->netdev
;
2427 netif_device_detach(netdev
);
2429 netxen_nic_down(adapter
, netdev
);
2432 netxen_nic_detach(adapter
);
2435 status
= NXRD32(adapter
, NETXEN_PEG_HALT_STATUS1
);
2437 if (status
& NX_RCODE_FATAL_ERROR
)
2440 if (adapter
->temp
== NX_TEMP_PANIC
)
2443 ref_cnt
= nx_decr_dev_ref_cnt(adapter
);
2445 if (ref_cnt
== -EIO
)
2448 delay
= (ref_cnt
== 0) ? 0 : (2 * FW_POLL_DELAY
);
2450 adapter
->fw_wait_cnt
= 0;
2451 netxen_schedule_work(adapter
, netxen_fwinit_work
, delay
);
2456 clear_bit(__NX_RESETTING
, &adapter
->state
);
2460 netxen_check_health(struct netxen_adapter
*adapter
)
2462 u32 state
, heartbit
;
2463 struct net_device
*netdev
= adapter
->netdev
;
2465 state
= NXRD32(adapter
, NX_CRB_DEV_STATE
);
2466 if (state
== NX_DEV_NEED_AER
)
2469 if (netxen_nic_check_temp(adapter
))
2472 if (adapter
->need_fw_reset
) {
2473 if (nx_dev_request_reset(adapter
))
2478 /* NX_DEV_NEED_RESET, this state can be marked in two cases
2479 * 1. Tx timeout 2. Fw hang
2480 * Send request to destroy context in case of tx timeout only
2481 * and doesn't required in case of Fw hang
2483 if (state
== NX_DEV_NEED_RESET
) {
2484 adapter
->need_fw_reset
= 1;
2485 if (NX_IS_REVISION_P2(adapter
->ahw
.revision_id
))
2489 if (NX_IS_REVISION_P2(adapter
->ahw
.revision_id
))
2492 heartbit
= NXRD32(adapter
, NETXEN_PEG_ALIVE_COUNTER
);
2493 if (heartbit
!= adapter
->heartbit
) {
2494 adapter
->heartbit
= heartbit
;
2495 adapter
->fw_fail_cnt
= 0;
2496 if (adapter
->need_fw_reset
)
2501 if (++adapter
->fw_fail_cnt
< FW_FAIL_THRESH
)
2504 if (nx_dev_request_reset(adapter
))
2507 clear_bit(__NX_FW_ATTACHED
, &adapter
->state
);
2509 dev_info(&netdev
->dev
, "firmware hang detected\n");
2512 if ((auto_fw_reset
== AUTO_FW_RESET_ENABLED
) &&
2513 !test_and_set_bit(__NX_RESETTING
, &adapter
->state
))
2514 netxen_schedule_work(adapter
, netxen_detach_work
, 0);
2519 netxen_fw_poll_work(struct work_struct
*work
)
2521 struct netxen_adapter
*adapter
= container_of(work
,
2522 struct netxen_adapter
, fw_work
.work
);
2524 if (test_bit(__NX_RESETTING
, &adapter
->state
))
2527 if (test_bit(__NX_DEV_UP
, &adapter
->state
)) {
2528 if (!adapter
->has_link_events
) {
2530 netxen_nic_handle_phy_intr(adapter
);
2532 if (adapter
->link_changed
)
2533 netxen_nic_set_link_parameters(adapter
);
2537 if (netxen_check_health(adapter
))
2541 netxen_schedule_work(adapter
, netxen_fw_poll_work
, FW_POLL_DELAY
);
2545 netxen_store_bridged_mode(struct device
*dev
,
2546 struct device_attribute
*attr
, const char *buf
, size_t len
)
2548 struct net_device
*net
= to_net_dev(dev
);
2549 struct netxen_adapter
*adapter
= netdev_priv(net
);
2553 if (!(adapter
->capabilities
& NX_FW_CAPABILITY_BDG
))
2556 if (adapter
->is_up
!= NETXEN_ADAPTER_UP_MAGIC
)
2559 if (strict_strtoul(buf
, 2, &new))
2562 if (!netxen_config_bridged_mode(adapter
, !!new))
2570 netxen_show_bridged_mode(struct device
*dev
,
2571 struct device_attribute
*attr
, char *buf
)
2573 struct net_device
*net
= to_net_dev(dev
);
2574 struct netxen_adapter
*adapter
;
2575 int bridged_mode
= 0;
2577 adapter
= netdev_priv(net
);
2579 if (adapter
->capabilities
& NX_FW_CAPABILITY_BDG
)
2580 bridged_mode
= !!(adapter
->flags
& NETXEN_NIC_BRIDGE_ENABLED
);
2582 return sprintf(buf
, "%d\n", bridged_mode
);
2585 static struct device_attribute dev_attr_bridged_mode
= {
2586 .attr
= {.name
= "bridged_mode", .mode
= (S_IRUGO
| S_IWUSR
)},
2587 .show
= netxen_show_bridged_mode
,
2588 .store
= netxen_store_bridged_mode
,
2592 netxen_store_diag_mode(struct device
*dev
,
2593 struct device_attribute
*attr
, const char *buf
, size_t len
)
2595 struct netxen_adapter
*adapter
= dev_get_drvdata(dev
);
2598 if (strict_strtoul(buf
, 2, &new))
2601 if (!!new != !!(adapter
->flags
& NETXEN_NIC_DIAG_ENABLED
))
2602 adapter
->flags
^= NETXEN_NIC_DIAG_ENABLED
;
2608 netxen_show_diag_mode(struct device
*dev
,
2609 struct device_attribute
*attr
, char *buf
)
2611 struct netxen_adapter
*adapter
= dev_get_drvdata(dev
);
2613 return sprintf(buf
, "%d\n",
2614 !!(adapter
->flags
& NETXEN_NIC_DIAG_ENABLED
));
2617 static struct device_attribute dev_attr_diag_mode
= {
2618 .attr
= {.name
= "diag_mode", .mode
= (S_IRUGO
| S_IWUSR
)},
2619 .show
= netxen_show_diag_mode
,
2620 .store
= netxen_store_diag_mode
,
2624 netxen_sysfs_validate_crb(struct netxen_adapter
*adapter
,
2625 loff_t offset
, size_t size
)
2627 size_t crb_size
= 4;
2629 if (!(adapter
->flags
& NETXEN_NIC_DIAG_ENABLED
))
2632 if (offset
< NETXEN_PCI_CRBSPACE
) {
2633 if (NX_IS_REVISION_P2(adapter
->ahw
.revision_id
))
2636 if (ADDR_IN_RANGE(offset
, NETXEN_PCI_CAMQM
,
2637 NETXEN_PCI_CAMQM_2M_END
))
2643 if ((size
!= crb_size
) || (offset
& (crb_size
-1)))
2650 netxen_sysfs_read_crb(struct file
*filp
, struct kobject
*kobj
,
2651 struct bin_attribute
*attr
,
2652 char *buf
, loff_t offset
, size_t size
)
2654 struct device
*dev
= container_of(kobj
, struct device
, kobj
);
2655 struct netxen_adapter
*adapter
= dev_get_drvdata(dev
);
2660 ret
= netxen_sysfs_validate_crb(adapter
, offset
, size
);
2664 if (NX_IS_REVISION_P3(adapter
->ahw
.revision_id
) &&
2665 ADDR_IN_RANGE(offset
, NETXEN_PCI_CAMQM
,
2666 NETXEN_PCI_CAMQM_2M_END
)) {
2667 netxen_pci_camqm_read_2M(adapter
, offset
, &qmdata
);
2668 memcpy(buf
, &qmdata
, size
);
2670 data
= NXRD32(adapter
, offset
);
2671 memcpy(buf
, &data
, size
);
2678 netxen_sysfs_write_crb(struct file
*filp
, struct kobject
*kobj
,
2679 struct bin_attribute
*attr
,
2680 char *buf
, loff_t offset
, size_t size
)
2682 struct device
*dev
= container_of(kobj
, struct device
, kobj
);
2683 struct netxen_adapter
*adapter
= dev_get_drvdata(dev
);
2688 ret
= netxen_sysfs_validate_crb(adapter
, offset
, size
);
2692 if (NX_IS_REVISION_P3(adapter
->ahw
.revision_id
) &&
2693 ADDR_IN_RANGE(offset
, NETXEN_PCI_CAMQM
,
2694 NETXEN_PCI_CAMQM_2M_END
)) {
2695 memcpy(&qmdata
, buf
, size
);
2696 netxen_pci_camqm_write_2M(adapter
, offset
, qmdata
);
2698 memcpy(&data
, buf
, size
);
2699 NXWR32(adapter
, offset
, data
);
2706 netxen_sysfs_validate_mem(struct netxen_adapter
*adapter
,
2707 loff_t offset
, size_t size
)
2709 if (!(adapter
->flags
& NETXEN_NIC_DIAG_ENABLED
))
2712 if ((size
!= 8) || (offset
& 0x7))
2719 netxen_sysfs_read_mem(struct file
*filp
, struct kobject
*kobj
,
2720 struct bin_attribute
*attr
,
2721 char *buf
, loff_t offset
, size_t size
)
2723 struct device
*dev
= container_of(kobj
, struct device
, kobj
);
2724 struct netxen_adapter
*adapter
= dev_get_drvdata(dev
);
2728 ret
= netxen_sysfs_validate_mem(adapter
, offset
, size
);
2732 if (adapter
->pci_mem_read(adapter
, offset
, &data
))
2735 memcpy(buf
, &data
, size
);
2740 static ssize_t
netxen_sysfs_write_mem(struct file
*filp
, struct kobject
*kobj
,
2741 struct bin_attribute
*attr
, char *buf
,
2742 loff_t offset
, size_t size
)
2744 struct device
*dev
= container_of(kobj
, struct device
, kobj
);
2745 struct netxen_adapter
*adapter
= dev_get_drvdata(dev
);
2749 ret
= netxen_sysfs_validate_mem(adapter
, offset
, size
);
2753 memcpy(&data
, buf
, size
);
2755 if (adapter
->pci_mem_write(adapter
, offset
, data
))
2762 static struct bin_attribute bin_attr_crb
= {
2763 .attr
= {.name
= "crb", .mode
= (S_IRUGO
| S_IWUSR
)},
2765 .read
= netxen_sysfs_read_crb
,
2766 .write
= netxen_sysfs_write_crb
,
2769 static struct bin_attribute bin_attr_mem
= {
2770 .attr
= {.name
= "mem", .mode
= (S_IRUGO
| S_IWUSR
)},
2772 .read
= netxen_sysfs_read_mem
,
2773 .write
= netxen_sysfs_write_mem
,
2778 netxen_create_sysfs_entries(struct netxen_adapter
*adapter
)
2780 struct net_device
*netdev
= adapter
->netdev
;
2781 struct device
*dev
= &netdev
->dev
;
2783 if (adapter
->capabilities
& NX_FW_CAPABILITY_BDG
) {
2784 /* bridged_mode control */
2785 if (device_create_file(dev
, &dev_attr_bridged_mode
)) {
2786 dev_warn(&netdev
->dev
,
2787 "failed to create bridged_mode sysfs entry\n");
2793 netxen_remove_sysfs_entries(struct netxen_adapter
*adapter
)
2795 struct net_device
*netdev
= adapter
->netdev
;
2796 struct device
*dev
= &netdev
->dev
;
2798 if (adapter
->capabilities
& NX_FW_CAPABILITY_BDG
)
2799 device_remove_file(dev
, &dev_attr_bridged_mode
);
2803 netxen_create_diag_entries(struct netxen_adapter
*adapter
)
2805 struct pci_dev
*pdev
= adapter
->pdev
;
2809 if (device_create_file(dev
, &dev_attr_diag_mode
))
2810 dev_info(dev
, "failed to create diag_mode sysfs entry\n");
2811 if (device_create_bin_file(dev
, &bin_attr_crb
))
2812 dev_info(dev
, "failed to create crb sysfs entry\n");
2813 if (device_create_bin_file(dev
, &bin_attr_mem
))
2814 dev_info(dev
, "failed to create mem sysfs entry\n");
2819 netxen_remove_diag_entries(struct netxen_adapter
*adapter
)
2821 struct pci_dev
*pdev
= adapter
->pdev
;
2822 struct device
*dev
= &pdev
->dev
;
2824 device_remove_file(dev
, &dev_attr_diag_mode
);
2825 device_remove_bin_file(dev
, &bin_attr_crb
);
2826 device_remove_bin_file(dev
, &bin_attr_mem
);
2831 #define is_netxen_netdev(dev) (dev->netdev_ops == &netxen_netdev_ops)
2834 netxen_destip_supported(struct netxen_adapter
*adapter
)
2836 if (NX_IS_REVISION_P2(adapter
->ahw
.revision_id
))
2839 if (adapter
->ahw
.cut_through
)
2846 netxen_config_indev_addr(struct net_device
*dev
, unsigned long event
)
2848 struct in_device
*indev
;
2849 struct netxen_adapter
*adapter
= netdev_priv(dev
);
2851 if (!netxen_destip_supported(adapter
))
2854 indev
= in_dev_get(dev
);
2861 netxen_config_ipaddr(adapter
,
2862 ifa
->ifa_address
, NX_IP_UP
);
2865 netxen_config_ipaddr(adapter
,
2866 ifa
->ifa_address
, NX_IP_DOWN
);
2871 } endfor_ifa(indev
);
2876 static int netxen_netdev_event(struct notifier_block
*this,
2877 unsigned long event
, void *ptr
)
2879 struct netxen_adapter
*adapter
;
2880 struct net_device
*dev
= (struct net_device
*)ptr
;
2886 if (dev
->priv_flags
& IFF_802_1Q_VLAN
) {
2887 dev
= vlan_dev_real_dev(dev
);
2891 if (!is_netxen_netdev(dev
))
2894 adapter
= netdev_priv(dev
);
2899 if (adapter
->is_up
!= NETXEN_ADAPTER_UP_MAGIC
)
2902 netxen_config_indev_addr(dev
, event
);
2908 netxen_inetaddr_event(struct notifier_block
*this,
2909 unsigned long event
, void *ptr
)
2911 struct netxen_adapter
*adapter
;
2912 struct net_device
*dev
;
2914 struct in_ifaddr
*ifa
= (struct in_ifaddr
*)ptr
;
2916 dev
= ifa
->ifa_dev
? ifa
->ifa_dev
->dev
: NULL
;
2919 if (dev
== NULL
|| !netif_running(dev
))
2922 if (dev
->priv_flags
& IFF_802_1Q_VLAN
) {
2923 dev
= vlan_dev_real_dev(dev
);
2927 if (!is_netxen_netdev(dev
))
2930 adapter
= netdev_priv(dev
);
2932 if (!adapter
|| !netxen_destip_supported(adapter
))
2935 if (adapter
->is_up
!= NETXEN_ADAPTER_UP_MAGIC
)
2940 netxen_config_ipaddr(adapter
, ifa
->ifa_address
, NX_IP_UP
);
2943 netxen_config_ipaddr(adapter
, ifa
->ifa_address
, NX_IP_DOWN
);
2953 static struct notifier_block netxen_netdev_cb
= {
2954 .notifier_call
= netxen_netdev_event
,
2957 static struct notifier_block netxen_inetaddr_cb
= {
2958 .notifier_call
= netxen_inetaddr_event
,
2962 netxen_config_indev_addr(struct net_device
*dev
, unsigned long event
)
2966 static struct pci_error_handlers netxen_err_handler
= {
2967 .error_detected
= netxen_io_error_detected
,
2968 .slot_reset
= netxen_io_slot_reset
,
2969 .resume
= netxen_io_resume
,
2972 static struct pci_driver netxen_driver
= {
2973 .name
= netxen_nic_driver_name
,
2974 .id_table
= netxen_pci_tbl
,
2975 .probe
= netxen_nic_probe
,
2976 .remove
= __devexit_p(netxen_nic_remove
),
2978 .suspend
= netxen_nic_suspend
,
2979 .resume
= netxen_nic_resume
,
2981 .shutdown
= netxen_nic_shutdown
,
2982 .err_handler
= &netxen_err_handler
2985 static int __init
netxen_init_module(void)
2987 printk(KERN_INFO
"%s\n", netxen_nic_driver_string
);
2990 register_netdevice_notifier(&netxen_netdev_cb
);
2991 register_inetaddr_notifier(&netxen_inetaddr_cb
);
2993 return pci_register_driver(&netxen_driver
);
2996 module_init(netxen_init_module
);
2998 static void __exit
netxen_exit_module(void)
3000 pci_unregister_driver(&netxen_driver
);
3003 unregister_inetaddr_notifier(&netxen_inetaddr_cb
);
3004 unregister_netdevice_notifier(&netxen_netdev_cb
);
3008 module_exit(netxen_exit_module
);