blob: c2b551fd711f494f796c7ac3a58408a88df2c898 [file] [log] [blame]
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001/*
2 * Copyright (C) 2003 - 2006 NetXen, Inc.
3 * All rights reserved.
Amit S. Kale80922fb2006-12-04 09:18:00 -08004 *
Amit S. Kale3d396eb2006-10-21 15:33:03 -04005 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
Amit S. Kale80922fb2006-12-04 09:18:00 -08009 *
Amit S. Kale3d396eb2006-10-21 15:33:03 -040010 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
Amit S. Kale80922fb2006-12-04 09:18:00 -080014 *
Amit S. Kale3d396eb2006-10-21 15:33:03 -040015 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18 * MA 02111-1307, USA.
Amit S. Kale80922fb2006-12-04 09:18:00 -080019 *
Amit S. Kale3d396eb2006-10-21 15:33:03 -040020 * The full GNU General Public License is included in this distribution
21 * in the file called LICENSE.
Amit S. Kale80922fb2006-12-04 09:18:00 -080022 *
Amit S. Kale3d396eb2006-10-21 15:33:03 -040023 * Contact Information:
24 * info@netxen.com
25 * NetXen,
26 * 3965 Freedom Circle, Fourth floor,
27 * Santa Clara, CA 95054
28 *
29 *
30 * Main source file for NetXen NIC Driver on Linux
31 *
32 */
33
Amit S. Kalecb8011a2006-11-29 09:00:10 -080034#include <linux/vmalloc.h>
Amit S. Kaleed25ffa2006-12-04 09:23:25 -080035#include <linux/highmem.h>
Amit S. Kale3d396eb2006-10-21 15:33:03 -040036#include "netxen_nic_hw.h"
37
38#include "netxen_nic.h"
Amit S. Kale3d396eb2006-10-21 15:33:03 -040039#include "netxen_nic_phan_reg.h"
Amit S. Kale3d396eb2006-10-21 15:33:03 -040040
Jeff Garzik1494a812006-11-07 05:12:16 -050041#include <linux/dma-mapping.h>
Dhananjay Phadke391587c2009-01-14 20:48:11 -080042#include <linux/if_vlan.h>
Arnaldo Carvalho de Meloc9bdd4b2007-03-12 20:09:15 -030043#include <net/ip.h>
Dhananjay Phadke00977782009-01-16 11:03:25 -080044#include <linux/ipv6.h>
Jeff Garzik1494a812006-11-07 05:12:16 -050045
Amit S. Kale3d396eb2006-10-21 15:33:03 -040046MODULE_DESCRIPTION("NetXen Multi port (1/10) Gigabit Network Driver");
47MODULE_LICENSE("GPL");
48MODULE_VERSION(NETXEN_NIC_LINUX_VERSIONID);
49
dhananjay@netxen.comceded322007-07-19 14:41:09 +053050char netxen_nic_driver_name[] = "netxen_nic";
Amit S. Kale3d396eb2006-10-21 15:33:03 -040051static char netxen_nic_driver_string[] = "NetXen Network Driver version "
Amit S. Kalecb8011a2006-11-29 09:00:10 -080052 NETXEN_NIC_LINUX_VERSIONID;
Amit S. Kale3d396eb2006-10-21 15:33:03 -040053
Dhananjay Phadke29566402008-07-21 19:44:04 -070054static int port_mode = NETXEN_PORT_MODE_AUTO_NEG;
55
56/* Default to restricted 1G auto-neg mode */
57static int wol_port_mode = 5;
58
59static int use_msi = 1;
60
61static int use_msi_x = 1;
62
Amit S. Kale3d396eb2006-10-21 15:33:03 -040063/* Local functions to NetXen NIC driver */
64static int __devinit netxen_nic_probe(struct pci_dev *pdev,
Dhananjay Phadke29566402008-07-21 19:44:04 -070065 const struct pci_device_id *ent);
Amit S. Kale3d396eb2006-10-21 15:33:03 -040066static void __devexit netxen_nic_remove(struct pci_dev *pdev);
67static int netxen_nic_open(struct net_device *netdev);
68static int netxen_nic_close(struct net_device *netdev);
69static int netxen_nic_xmit_frame(struct sk_buff *, struct net_device *);
70static void netxen_tx_timeout(struct net_device *netdev);
David Howells6d5aefb2006-12-05 19:36:26 +000071static void netxen_tx_timeout_task(struct work_struct *work);
Amit S. Kale3d396eb2006-10-21 15:33:03 -040072static void netxen_watchdog(unsigned long);
Stephen Hemmingerbea33482007-10-03 16:41:36 -070073static int netxen_nic_poll(struct napi_struct *napi, int budget);
Amit S. Kale3d396eb2006-10-21 15:33:03 -040074#ifdef CONFIG_NET_POLL_CONTROLLER
75static void netxen_nic_poll_controller(struct net_device *netdev);
76#endif
Jeff Garzik1494a812006-11-07 05:12:16 -050077static irqreturn_t netxen_intr(int irq, void *data);
Dhananjay Phadke05aaa022008-03-17 19:59:49 -070078static irqreturn_t netxen_msi_intr(int irq, void *data);
Dhananjay Phadkeb3df68f2009-02-08 19:20:19 -080079static irqreturn_t netxen_msix_intr(int irq, void *data);
Amit S. Kale3d396eb2006-10-21 15:33:03 -040080
81/* PCI Device ID Table */
Al Viro70081ac2008-06-23 02:04:50 +010082#define ENTRY(device) \
Dhananjay Phadke040dec32008-09-12 06:55:14 -070083 {PCI_DEVICE(PCI_VENDOR_ID_NETXEN, (device)), \
Al Viro70081ac2008-06-23 02:04:50 +010084 .class = PCI_CLASS_NETWORK_ETHERNET << 8, .class_mask = ~0}
85
Amit S. Kale3d396eb2006-10-21 15:33:03 -040086static struct pci_device_id netxen_pci_tbl[] __devinitdata = {
Dhananjay Phadke040dec32008-09-12 06:55:14 -070087 ENTRY(PCI_DEVICE_ID_NX2031_10GXSR),
88 ENTRY(PCI_DEVICE_ID_NX2031_10GCX4),
89 ENTRY(PCI_DEVICE_ID_NX2031_4GCU),
90 ENTRY(PCI_DEVICE_ID_NX2031_IMEZ),
91 ENTRY(PCI_DEVICE_ID_NX2031_HMEZ),
92 ENTRY(PCI_DEVICE_ID_NX2031_XG_MGMT),
93 ENTRY(PCI_DEVICE_ID_NX2031_XG_MGMT2),
94 ENTRY(PCI_DEVICE_ID_NX3031),
Amit S. Kale3d396eb2006-10-21 15:33:03 -040095 {0,}
96};
97
98MODULE_DEVICE_TABLE(pci, netxen_pci_tbl);
99
Adrian Bunkb15551302008-03-31 02:22:18 +0300100/*
101 * In netxen_nic_down(), we must wait for any pending callback requests into
102 * netxen_watchdog_task() to complete; eg otherwise the watchdog_timer could be
103 * reenabled right after it is deleted in netxen_nic_down().
104 * FLUSH_SCHEDULED_WORK() does this synchronization.
105 *
106 * Normally, schedule_work()/flush_scheduled_work() could have worked, but
107 * netxen_nic_close() is invoked with kernel rtnl lock held. netif_carrier_off()
108 * call in netxen_nic_close() triggers a schedule_work(&linkwatch_work), and a
109 * subsequent call to flush_scheduled_work() in netxen_nic_down() would cause
110 * linkwatch_event() to be executed which also attempts to acquire the rtnl
111 * lock thus causing a deadlock.
112 */
113
114static struct workqueue_struct *netxen_workq;
115#define SCHEDULE_WORK(tp) queue_work(netxen_workq, tp)
116#define FLUSH_SCHEDULED_WORK() flush_workqueue(netxen_workq)
117
Amit S. Kaleed25ffa2006-12-04 09:23:25 -0800118static void netxen_watchdog(unsigned long);
119
Dhananjay Phadke7830b222008-07-21 19:44:00 -0700120static uint32_t crb_cmd_producer[4] = {
121 CRB_CMD_PRODUCER_OFFSET, CRB_CMD_PRODUCER_OFFSET_1,
122 CRB_CMD_PRODUCER_OFFSET_2, CRB_CMD_PRODUCER_OFFSET_3
123};
124
Dhananjay Phadkec9fc8912008-07-21 19:44:07 -0700125void
Dhananjay Phadke3ce06a32008-07-21 19:44:03 -0700126netxen_nic_update_cmd_producer(struct netxen_adapter *adapter,
127 uint32_t crb_producer)
Mithlesh Thukral3176ff32007-04-20 07:52:37 -0700128{
Dhananjay Phadke3ce06a32008-07-21 19:44:03 -0700129 adapter->pci_write_normalize(adapter,
130 adapter->crb_addr_cmd_producer, crb_producer);
Mithlesh Thukral3176ff32007-04-20 07:52:37 -0700131}
132
Dhananjay Phadke7830b222008-07-21 19:44:00 -0700133static uint32_t crb_cmd_consumer[4] = {
134 CRB_CMD_CONSUMER_OFFSET, CRB_CMD_CONSUMER_OFFSET_1,
135 CRB_CMD_CONSUMER_OFFSET_2, CRB_CMD_CONSUMER_OFFSET_3
136};
137
Dhananjay Phadke3ce06a32008-07-21 19:44:03 -0700138static inline void
139netxen_nic_update_cmd_consumer(struct netxen_adapter *adapter,
140 u32 crb_consumer)
Mithlesh Thukral3176ff32007-04-20 07:52:37 -0700141{
Dhananjay Phadke3ce06a32008-07-21 19:44:03 -0700142 adapter->pci_write_normalize(adapter,
143 adapter->crb_addr_cmd_consumer, crb_consumer);
Mithlesh Thukral3176ff32007-04-20 07:52:37 -0700144}
145
Dhananjay Phadke29566402008-07-21 19:44:04 -0700146static uint32_t msi_tgt_status[8] = {
Dhananjay Phadke443be792008-03-17 19:59:48 -0700147 ISR_INT_TARGET_STATUS, ISR_INT_TARGET_STATUS_F1,
Dhananjay Phadke29566402008-07-21 19:44:04 -0700148 ISR_INT_TARGET_STATUS_F2, ISR_INT_TARGET_STATUS_F3,
149 ISR_INT_TARGET_STATUS_F4, ISR_INT_TARGET_STATUS_F5,
150 ISR_INT_TARGET_STATUS_F6, ISR_INT_TARGET_STATUS_F7
Dhananjay Phadke443be792008-03-17 19:59:48 -0700151};
152
Dhananjay Phadke29566402008-07-21 19:44:04 -0700153static struct netxen_legacy_intr_set legacy_intr[] = NX_LEGACY_INTR_CONFIG;
154
Dhananjay Phadke092bc572008-08-08 00:08:43 -0700155static inline void netxen_nic_disable_int(struct netxen_adapter *adapter)
Stephen Hemminger4638aef12007-07-05 16:13:55 -0700156{
Dhananjay Phadke092bc572008-08-08 00:08:43 -0700157 adapter->pci_write_normalize(adapter, adapter->crb_intr_mask, 0);
Stephen Hemminger4638aef12007-07-05 16:13:55 -0700158}
159
Dhananjay Phadke092bc572008-08-08 00:08:43 -0700160static inline void netxen_nic_enable_int(struct netxen_adapter *adapter)
Stephen Hemminger4638aef12007-07-05 16:13:55 -0700161{
Dhananjay Phadke48bfd1e2008-07-21 19:44:06 -0700162 adapter->pci_write_normalize(adapter, adapter->crb_intr_mask, 0x1);
Stephen Hemminger4638aef12007-07-05 16:13:55 -0700163
Dhananjay Phadke092bc572008-08-08 00:08:43 -0700164 if (!NETXEN_IS_MSI_FAMILY(adapter))
165 adapter->pci_write_immediate(adapter,
166 adapter->legacy_intr.tgt_mask_reg, 0xfbff);
Stephen Hemminger4638aef12007-07-05 16:13:55 -0700167}
168
Dhananjay Phadke29566402008-07-21 19:44:04 -0700169static int nx_set_dma_mask(struct netxen_adapter *adapter, uint8_t revision_id)
170{
171 struct pci_dev *pdev = adapter->pdev;
172 int err;
173 uint64_t mask;
174
175#ifdef CONFIG_IA64
176 adapter->dma_mask = DMA_32BIT_MASK;
177#else
178 if (revision_id >= NX_P3_B0) {
179 /* should go to DMA_64BIT_MASK */
180 adapter->dma_mask = DMA_39BIT_MASK;
181 mask = DMA_39BIT_MASK;
182 } else if (revision_id == NX_P3_A2) {
183 adapter->dma_mask = DMA_39BIT_MASK;
184 mask = DMA_39BIT_MASK;
185 } else if (revision_id == NX_P2_C1) {
186 adapter->dma_mask = DMA_35BIT_MASK;
187 mask = DMA_35BIT_MASK;
188 } else {
189 adapter->dma_mask = DMA_32BIT_MASK;
190 mask = DMA_32BIT_MASK;
191 goto set_32_bit_mask;
192 }
193
194 /*
195 * Consistent DMA mask is set to 32 bit because it cannot be set to
196 * 35 bits. For P3 also leave it at 32 bits for now. Only the rings
197 * come off this pool.
198 */
199 if (pci_set_dma_mask(pdev, mask) == 0 &&
200 pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK) == 0) {
201 adapter->pci_using_dac = 1;
202 return 0;
203 }
Yang Hongyang354b45f2009-02-12 16:57:12 -0800204set_32_bit_mask:
Dhananjay Phadke29566402008-07-21 19:44:04 -0700205#endif /* CONFIG_IA64 */
206
Dhananjay Phadke29566402008-07-21 19:44:04 -0700207 err = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
208 if (!err)
209 err = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
210 if (err) {
211 DPRINTK(ERR, "No usable DMA configuration, aborting:%d\n", err);
212 return err;
213 }
214
215 adapter->pci_using_dac = 0;
216 return 0;
217}
218
219static void netxen_check_options(struct netxen_adapter *adapter)
220{
221 switch (adapter->ahw.boardcfg.board_type) {
222 case NETXEN_BRDTYPE_P3_HMEZ:
223 case NETXEN_BRDTYPE_P3_XG_LOM:
224 case NETXEN_BRDTYPE_P3_10G_CX4:
225 case NETXEN_BRDTYPE_P3_10G_CX4_LP:
226 case NETXEN_BRDTYPE_P3_IMEZ:
227 case NETXEN_BRDTYPE_P3_10G_SFP_PLUS:
Dhananjay Phadkea70f9392008-08-01 03:14:56 -0700228 case NETXEN_BRDTYPE_P3_10G_SFP_QT:
229 case NETXEN_BRDTYPE_P3_10G_SFP_CT:
Dhananjay Phadke29566402008-07-21 19:44:04 -0700230 case NETXEN_BRDTYPE_P3_10G_XFP:
231 case NETXEN_BRDTYPE_P3_10000_BASE_T:
232 adapter->msix_supported = !!use_msi_x;
233 adapter->max_rx_desc_count = MAX_RCV_DESCRIPTORS_10G;
234 break;
235
236 case NETXEN_BRDTYPE_P2_SB31_10G:
237 case NETXEN_BRDTYPE_P2_SB31_10G_CX4:
238 case NETXEN_BRDTYPE_P2_SB31_10G_IMEZ:
239 case NETXEN_BRDTYPE_P2_SB31_10G_HMEZ:
240 adapter->msix_supported = 0;
241 adapter->max_rx_desc_count = MAX_RCV_DESCRIPTORS_10G;
242 break;
243
244 case NETXEN_BRDTYPE_P3_REF_QG:
245 case NETXEN_BRDTYPE_P3_4_GB:
246 case NETXEN_BRDTYPE_P3_4_GB_MM:
Dhananjay Phadkeec68db62008-08-20 13:52:48 -0700247 adapter->msix_supported = !!use_msi_x;
Dhananjay Phadkec7860a22009-01-14 20:48:32 -0800248 adapter->max_rx_desc_count = MAX_RCV_DESCRIPTORS_1G;
Dhananjay Phadkea70f9392008-08-01 03:14:56 -0700249 break;
250
Dhananjay Phadke29566402008-07-21 19:44:04 -0700251 case NETXEN_BRDTYPE_P2_SB35_4G:
252 case NETXEN_BRDTYPE_P2_SB31_2G:
253 adapter->msix_supported = 0;
254 adapter->max_rx_desc_count = MAX_RCV_DESCRIPTORS_1G;
255 break;
256
Dhananjay Phadkec7860a22009-01-14 20:48:32 -0800257 case NETXEN_BRDTYPE_P3_10G_TP:
258 adapter->msix_supported = !!use_msi_x;
259 if (adapter->ahw.board_type == NETXEN_NIC_XGBE)
260 adapter->max_rx_desc_count = MAX_RCV_DESCRIPTORS_10G;
261 else
262 adapter->max_rx_desc_count = MAX_RCV_DESCRIPTORS_1G;
263 break;
264
Dhananjay Phadke29566402008-07-21 19:44:04 -0700265 default:
266 adapter->msix_supported = 0;
267 adapter->max_rx_desc_count = MAX_RCV_DESCRIPTORS_1G;
268
269 printk(KERN_WARNING "Unknown board type(0x%x)\n",
270 adapter->ahw.boardcfg.board_type);
271 break;
272 }
273
274 adapter->max_tx_desc_count = MAX_CMD_DESCRIPTORS_HOST;
275 adapter->max_jumbo_rx_desc_count = MAX_JUMBO_RCV_DESCRIPTORS;
276 adapter->max_lro_rx_desc_count = MAX_LRO_RCV_DESCRIPTORS;
277
278 adapter->max_possible_rss_rings = 1;
279 return;
280}
281
282static int
283netxen_check_hw_init(struct netxen_adapter *adapter, int first_boot)
284{
Dhananjay Phadke27c915a2009-01-14 20:49:00 -0800285 u32 val, timeout;
Dhananjay Phadke29566402008-07-21 19:44:04 -0700286
287 if (first_boot == 0x55555555) {
288 /* This is the first boot after power up */
Dhananjay Phadke27c915a2009-01-14 20:49:00 -0800289 adapter->pci_write_normalize(adapter,
290 NETXEN_CAM_RAM(0x1fc), NETXEN_BDINFO_MAGIC);
291
292 if (!NX_IS_REVISION_P2(adapter->ahw.revision_id))
293 return 0;
Dhananjay Phadke29566402008-07-21 19:44:04 -0700294
295 /* PCI bus master workaround */
296 adapter->hw_read_wx(adapter,
297 NETXEN_PCIE_REG(0x4), &first_boot, 4);
298 if (!(first_boot & 0x4)) {
299 first_boot |= 0x4;
300 adapter->hw_write_wx(adapter,
301 NETXEN_PCIE_REG(0x4), &first_boot, 4);
302 adapter->hw_read_wx(adapter,
303 NETXEN_PCIE_REG(0x4), &first_boot, 4);
304 }
305
306 /* This is the first boot after power up */
307 adapter->hw_read_wx(adapter,
308 NETXEN_ROMUSB_GLB_SW_RESET, &first_boot, 4);
309 if (first_boot != 0x80000f) {
310 /* clear the register for future unloads/loads */
311 adapter->pci_write_normalize(adapter,
312 NETXEN_CAM_RAM(0x1fc), 0);
Dhananjay Phadke27c915a2009-01-14 20:49:00 -0800313 return -EIO;
Dhananjay Phadke29566402008-07-21 19:44:04 -0700314 }
315
Dhananjay Phadke27c915a2009-01-14 20:49:00 -0800316 /* Start P2 boot loader */
317 val = adapter->pci_read_normalize(adapter,
318 NETXEN_ROMUSB_GLB_PEGTUNE_DONE);
319 adapter->pci_write_normalize(adapter,
320 NETXEN_ROMUSB_GLB_PEGTUNE_DONE, val | 0x1);
321 timeout = 0;
322 do {
323 msleep(1);
324 val = adapter->pci_read_normalize(adapter,
325 NETXEN_CAM_RAM(0x1fc));
326
327 if (++timeout > 5000)
328 return -EIO;
329
330 } while (val == NETXEN_BDINFO_MAGIC);
Dhananjay Phadke29566402008-07-21 19:44:04 -0700331 }
Dhananjay Phadke27c915a2009-01-14 20:49:00 -0800332 return 0;
Dhananjay Phadke29566402008-07-21 19:44:04 -0700333}
334
335static void netxen_set_port_mode(struct netxen_adapter *adapter)
336{
337 u32 val, data;
338
339 val = adapter->ahw.boardcfg.board_type;
340 if ((val == NETXEN_BRDTYPE_P3_HMEZ) ||
341 (val == NETXEN_BRDTYPE_P3_XG_LOM)) {
342 if (port_mode == NETXEN_PORT_MODE_802_3_AP) {
343 data = NETXEN_PORT_MODE_802_3_AP;
344 adapter->hw_write_wx(adapter,
345 NETXEN_PORT_MODE_ADDR, &data, 4);
346 } else if (port_mode == NETXEN_PORT_MODE_XG) {
347 data = NETXEN_PORT_MODE_XG;
348 adapter->hw_write_wx(adapter,
349 NETXEN_PORT_MODE_ADDR, &data, 4);
350 } else if (port_mode == NETXEN_PORT_MODE_AUTO_NEG_1G) {
351 data = NETXEN_PORT_MODE_AUTO_NEG_1G;
352 adapter->hw_write_wx(adapter,
353 NETXEN_PORT_MODE_ADDR, &data, 4);
354 } else if (port_mode == NETXEN_PORT_MODE_AUTO_NEG_XG) {
355 data = NETXEN_PORT_MODE_AUTO_NEG_XG;
356 adapter->hw_write_wx(adapter,
357 NETXEN_PORT_MODE_ADDR, &data, 4);
358 } else {
359 data = NETXEN_PORT_MODE_AUTO_NEG;
360 adapter->hw_write_wx(adapter,
361 NETXEN_PORT_MODE_ADDR, &data, 4);
362 }
363
364 if ((wol_port_mode != NETXEN_PORT_MODE_802_3_AP) &&
365 (wol_port_mode != NETXEN_PORT_MODE_XG) &&
366 (wol_port_mode != NETXEN_PORT_MODE_AUTO_NEG_1G) &&
367 (wol_port_mode != NETXEN_PORT_MODE_AUTO_NEG_XG)) {
368 wol_port_mode = NETXEN_PORT_MODE_AUTO_NEG;
369 }
370 adapter->hw_write_wx(adapter, NETXEN_WOL_PORT_MODE,
371 &wol_port_mode, 4);
372 }
373}
374
Dhananjay Phadke29566402008-07-21 19:44:04 -0700375static void netxen_set_msix_bit(struct pci_dev *pdev, int enable)
376{
377 u32 control;
378 int pos;
379
380 pos = pci_find_capability(pdev, PCI_CAP_ID_MSIX);
381 if (pos) {
382 pci_read_config_dword(pdev, pos, &control);
383 if (enable)
384 control |= PCI_MSIX_FLAGS_ENABLE;
385 else
386 control = 0;
387 pci_write_config_dword(pdev, pos, control);
388 }
389}
390
391static void netxen_init_msix_entries(struct netxen_adapter *adapter)
392{
393 int i;
394
395 for (i = 0; i < MSIX_ENTRIES_PER_ADAPTER; i++)
396 adapter->msix_entries[i].entry = i;
397}
398
Dhananjay Phadke9dc28ef2008-08-08 00:08:39 -0700399static int
400netxen_read_mac_addr(struct netxen_adapter *adapter)
401{
402 int i;
403 unsigned char *p;
404 __le64 mac_addr;
Dhananjay Phadke9dc28ef2008-08-08 00:08:39 -0700405 struct net_device *netdev = adapter->netdev;
406 struct pci_dev *pdev = adapter->pdev;
407
408 if (netxen_is_flash_supported(adapter) != 0)
409 return -EIO;
410
411 if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) {
412 if (netxen_p3_get_mac_addr(adapter, &mac_addr) != 0)
413 return -EIO;
414 } else {
415 if (netxen_get_flash_mac_addr(adapter, &mac_addr) != 0)
416 return -EIO;
417 }
418
419 p = (unsigned char *)&mac_addr;
420 for (i = 0; i < 6; i++)
421 netdev->dev_addr[i] = *(p + 5 - i);
422
423 memcpy(netdev->perm_addr, netdev->dev_addr, netdev->addr_len);
424
425 /* set station address */
426
Johannes Berge1749612008-10-27 15:59:26 -0700427 if (!is_valid_ether_addr(netdev->perm_addr))
428 dev_warn(&pdev->dev, "Bad MAC address %pM.\n", netdev->dev_addr);
429 else
Dhananjay Phadke9dc28ef2008-08-08 00:08:39 -0700430 adapter->macaddr_set(adapter, netdev->dev_addr);
431
432 return 0;
433}
434
Stephen Hemminger1abd2662008-11-21 17:32:15 -0800435static void netxen_set_multicast_list(struct net_device *dev)
436{
437 struct netxen_adapter *adapter = netdev_priv(dev);
438
439 if (NX_IS_REVISION_P3(adapter->ahw.revision_id))
440 netxen_p3_nic_set_multi(dev);
441 else
442 netxen_p2_nic_set_multi(dev);
443}
444
445static const struct net_device_ops netxen_netdev_ops = {
446 .ndo_open = netxen_nic_open,
447 .ndo_stop = netxen_nic_close,
448 .ndo_start_xmit = netxen_nic_xmit_frame,
449 .ndo_get_stats = netxen_nic_get_stats,
450 .ndo_validate_addr = eth_validate_addr,
451 .ndo_set_multicast_list = netxen_set_multicast_list,
452 .ndo_set_mac_address = netxen_nic_set_mac,
453 .ndo_change_mtu = netxen_nic_change_mtu,
454 .ndo_tx_timeout = netxen_tx_timeout,
455#ifdef CONFIG_NET_POLL_CONTROLLER
456 .ndo_poll_controller = netxen_nic_poll_controller,
457#endif
458};
459
Dhananjay Phadke97daee82009-02-24 16:39:21 -0800460static void
461netxen_setup_intr(struct netxen_adapter *adapter)
462{
463 struct netxen_legacy_intr_set *legacy_intrp;
464 struct pci_dev *pdev = adapter->pdev;
465
466 adapter->flags &= ~(NETXEN_NIC_MSI_ENABLED | NETXEN_NIC_MSIX_ENABLED);
467 adapter->intr_scheme = -1;
468 adapter->msi_mode = -1;
469
470 if (adapter->ahw.revision_id >= NX_P3_B0)
471 legacy_intrp = &legacy_intr[adapter->ahw.pci_func];
472 else
473 legacy_intrp = &legacy_intr[0];
474 adapter->legacy_intr.int_vec_bit = legacy_intrp->int_vec_bit;
475 adapter->legacy_intr.tgt_status_reg = legacy_intrp->tgt_status_reg;
476 adapter->legacy_intr.tgt_mask_reg = legacy_intrp->tgt_mask_reg;
477 adapter->legacy_intr.pci_int_reg = legacy_intrp->pci_int_reg;
478
479 netxen_set_msix_bit(pdev, 0);
480
481 if (adapter->msix_supported) {
482
483 netxen_init_msix_entries(adapter);
484 if (pci_enable_msix(pdev, adapter->msix_entries,
485 MSIX_ENTRIES_PER_ADAPTER))
486 goto request_msi;
487
488 adapter->flags |= NETXEN_NIC_MSIX_ENABLED;
489 netxen_set_msix_bit(pdev, 1);
490 dev_info(&pdev->dev, "using msi-x interrupts\n");
491
492 } else {
493request_msi:
494 if (use_msi && !pci_enable_msi(pdev)) {
495 adapter->flags |= NETXEN_NIC_MSI_ENABLED;
496 dev_info(&pdev->dev, "using msi interrupts\n");
497 } else
498 dev_info(&pdev->dev, "using legacy interrupts\n");
499 }
500}
501
502static void
503netxen_teardown_intr(struct netxen_adapter *adapter)
504{
505 if (adapter->flags & NETXEN_NIC_MSIX_ENABLED)
506 pci_disable_msix(adapter->pdev);
507 if (adapter->flags & NETXEN_NIC_MSI_ENABLED)
508 pci_disable_msi(adapter->pdev);
509}
510
511static void
512netxen_cleanup_pci_map(struct netxen_adapter *adapter)
513{
514 if (adapter->ahw.db_base != NULL)
515 iounmap(adapter->ahw.db_base);
516 if (adapter->ahw.pci_base0 != NULL)
517 iounmap(adapter->ahw.pci_base0);
518 if (adapter->ahw.pci_base1 != NULL)
519 iounmap(adapter->ahw.pci_base1);
520 if (adapter->ahw.pci_base2 != NULL)
521 iounmap(adapter->ahw.pci_base2);
522}
523
524static int
525netxen_setup_pci_map(struct netxen_adapter *adapter)
526{
527 void __iomem *mem_ptr0 = NULL;
528 void __iomem *mem_ptr1 = NULL;
529 void __iomem *mem_ptr2 = NULL;
530 void __iomem *db_ptr = NULL;
531
532 unsigned long first_page_group_end;
533 unsigned long first_page_group_start;
534 unsigned long mem_base, mem_len, db_base, db_len = 0, pci_len0 = 0;
535
536 struct pci_dev *pdev = adapter->pdev;
537 int pci_func = adapter->ahw.pci_func;
538
539 int err = 0;
540
541 /*
542 * Set the CRB window to invalid. If any register in window 0 is
543 * accessed it should set the window to 0 and then reset it to 1.
544 */
545 adapter->curr_window = 255;
546 adapter->ahw.qdr_sn_window = -1;
547 adapter->ahw.ddr_mn_window = -1;
548
549 /* remap phys address */
550 mem_base = pci_resource_start(pdev, 0); /* 0 is for BAR 0 */
551 mem_len = pci_resource_len(pdev, 0);
552 pci_len0 = 0;
553
554 adapter->hw_write_wx = netxen_nic_hw_write_wx_128M;
555 adapter->hw_read_wx = netxen_nic_hw_read_wx_128M;
556 adapter->pci_read_immediate = netxen_nic_pci_read_immediate_128M;
557 adapter->pci_write_immediate = netxen_nic_pci_write_immediate_128M;
558 adapter->pci_read_normalize = netxen_nic_pci_read_normalize_128M;
559 adapter->pci_write_normalize = netxen_nic_pci_write_normalize_128M;
560 adapter->pci_set_window = netxen_nic_pci_set_window_128M;
561 adapter->pci_mem_read = netxen_nic_pci_mem_read_128M;
562 adapter->pci_mem_write = netxen_nic_pci_mem_write_128M;
563
564 /* 128 Meg of memory */
565 if (mem_len == NETXEN_PCI_128MB_SIZE) {
566 mem_ptr0 = ioremap(mem_base, FIRST_PAGE_GROUP_SIZE);
567 mem_ptr1 = ioremap(mem_base + SECOND_PAGE_GROUP_START,
568 SECOND_PAGE_GROUP_SIZE);
569 mem_ptr2 = ioremap(mem_base + THIRD_PAGE_GROUP_START,
570 THIRD_PAGE_GROUP_SIZE);
571 first_page_group_start = FIRST_PAGE_GROUP_START;
572 first_page_group_end = FIRST_PAGE_GROUP_END;
573 } else if (mem_len == NETXEN_PCI_32MB_SIZE) {
574 mem_ptr1 = ioremap(mem_base, SECOND_PAGE_GROUP_SIZE);
575 mem_ptr2 = ioremap(mem_base + THIRD_PAGE_GROUP_START -
576 SECOND_PAGE_GROUP_START, THIRD_PAGE_GROUP_SIZE);
577 first_page_group_start = 0;
578 first_page_group_end = 0;
579 } else if (mem_len == NETXEN_PCI_2MB_SIZE) {
580 adapter->hw_write_wx = netxen_nic_hw_write_wx_2M;
581 adapter->hw_read_wx = netxen_nic_hw_read_wx_2M;
582 adapter->pci_read_immediate = netxen_nic_pci_read_immediate_2M;
583 adapter->pci_write_immediate =
584 netxen_nic_pci_write_immediate_2M;
585 adapter->pci_read_normalize = netxen_nic_pci_read_normalize_2M;
586 adapter->pci_write_normalize =
587 netxen_nic_pci_write_normalize_2M;
588 adapter->pci_set_window = netxen_nic_pci_set_window_2M;
589 adapter->pci_mem_read = netxen_nic_pci_mem_read_2M;
590 adapter->pci_mem_write = netxen_nic_pci_mem_write_2M;
591
592 mem_ptr0 = pci_ioremap_bar(pdev, 0);
593 if (mem_ptr0 == NULL) {
594 dev_err(&pdev->dev, "failed to map PCI bar 0\n");
595 return -EIO;
596 }
597 pci_len0 = mem_len;
598 first_page_group_start = 0;
599 first_page_group_end = 0;
600
601 adapter->ahw.ddr_mn_window = 0;
602 adapter->ahw.qdr_sn_window = 0;
603
604 adapter->ahw.mn_win_crb = 0x100000 + PCIX_MN_WINDOW +
605 (pci_func * 0x20);
606 adapter->ahw.ms_win_crb = 0x100000 + PCIX_SN_WINDOW;
607 if (pci_func < 4)
608 adapter->ahw.ms_win_crb += (pci_func * 0x20);
609 else
610 adapter->ahw.ms_win_crb +=
611 0xA0 + ((pci_func - 4) * 0x10);
612 } else {
613 return -EIO;
614 }
615
616 dev_info(&pdev->dev, "%dMB memory map\n", (int)(mem_len>>20));
617
618 adapter->ahw.pci_base0 = mem_ptr0;
619 adapter->ahw.pci_len0 = pci_len0;
620 adapter->ahw.first_page_group_start = first_page_group_start;
621 adapter->ahw.first_page_group_end = first_page_group_end;
622 adapter->ahw.pci_base1 = mem_ptr1;
623 adapter->ahw.pci_base2 = mem_ptr2;
624
625 if (NX_IS_REVISION_P3(adapter->ahw.revision_id))
626 goto skip_doorbell;
627
628 db_base = pci_resource_start(pdev, 4); /* doorbell is on bar 4 */
629 db_len = pci_resource_len(pdev, 4);
630
631 if (db_len == 0) {
632 printk(KERN_ERR "%s: doorbell is disabled\n",
633 netxen_nic_driver_name);
634 err = -EIO;
635 goto err_out;
636 }
637
638 db_ptr = ioremap(db_base, NETXEN_DB_MAPSIZE_BYTES);
639 if (!db_ptr) {
640 printk(KERN_ERR "%s: Failed to allocate doorbell map.",
641 netxen_nic_driver_name);
642 err = -EIO;
643 goto err_out;
644 }
645
646skip_doorbell:
647 adapter->ahw.db_base = db_ptr;
648 adapter->ahw.db_len = db_len;
649 return 0;
650
651err_out:
652 netxen_cleanup_pci_map(adapter);
653 return err;
654}
655
Dhananjay Phadkeba599d42009-02-24 16:38:22 -0800656static int
657netxen_start_firmware(struct netxen_adapter *adapter)
658{
659 int val, err, first_boot;
660 struct pci_dev *pdev = adapter->pdev;
661
662 first_boot = adapter->pci_read_normalize(adapter,
663 NETXEN_CAM_RAM(0x1fc));
664
665 err = netxen_check_hw_init(adapter, first_boot);
666 if (err) {
667 dev_err(&pdev->dev, "error in init HW init sequence\n");
668 return err;
669 }
670
671 if (NX_IS_REVISION_P3(adapter->ahw.revision_id))
672 netxen_set_port_mode(adapter);
673
674 if (first_boot != 0x55555555) {
675 adapter->pci_write_normalize(adapter,
676 CRB_CMDPEG_STATE, 0);
677 netxen_pinit_from_rom(adapter, 0);
678 msleep(1);
679 }
680 netxen_load_firmware(adapter);
681
682 if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) {
683
684 /* Initialize multicast addr pool owners */
685 val = 0x7654;
686 if (adapter->ahw.board_type == NETXEN_NIC_XGBE)
687 val |= 0x0f000000;
688 netxen_crb_writelit_adapter(adapter,
689 NETXEN_MAC_ADDR_CNTL_REG, val);
690
691 }
692
693 err = netxen_initialize_adapter_offload(adapter);
694 if (err)
695 return err;
696
697 /*
698 * Tell the hardware our version number.
699 */
700 val = (_NETXEN_NIC_LINUX_MAJOR << 16)
701 | ((_NETXEN_NIC_LINUX_MINOR << 8))
702 | (_NETXEN_NIC_LINUX_SUBVERSION);
703 adapter->pci_write_normalize(adapter, CRB_DRIVER_VERSION, val);
704
705 /* Handshake with the card before we register the devices. */
706 err = netxen_phantom_init(adapter, NETXEN_NIC_PEG_TUNE);
707 if (err) {
708 netxen_free_adapter_offload(adapter);
709 return err;
710 }
711
712 return 0;
713}
714
Amit S. Kale3d396eb2006-10-21 15:33:03 -0400715static int __devinit
716netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
717{
718 struct net_device *netdev = NULL;
719 struct netxen_adapter *adapter = NULL;
Dhananjay Phadke29566402008-07-21 19:44:04 -0700720 int i = 0, err;
Dhananjay Phadkeba599d42009-02-24 16:38:22 -0800721 int first_driver;
Mithlesh Thukral6c80b182007-04-20 07:55:26 -0700722 u32 val;
Mithlesh Thukral3176ff32007-04-20 07:52:37 -0700723 int pci_func_id = PCI_FUNC(pdev->devfn);
Dhananjay Phadke29566402008-07-21 19:44:04 -0700724 uint8_t revision_id;
Amit S. Kale3d396eb2006-10-21 15:33:03 -0400725
Dhananjay Phadkedcd56fd2008-06-15 22:59:45 -0700726 if (pci_func_id == 0)
Dhananjay Phadke29566402008-07-21 19:44:04 -0700727 printk(KERN_INFO "%s\n", netxen_nic_driver_string);
Mithlesh Thukral6c80b182007-04-20 07:55:26 -0700728
Mithlesh Thukral3176ff32007-04-20 07:52:37 -0700729 if (pdev->class != 0x020000) {
Dhananjay Phadkedcd56fd2008-06-15 22:59:45 -0700730 printk(KERN_DEBUG "NetXen function %d, class %x will not "
Mithlesh Thukral3176ff32007-04-20 07:52:37 -0700731 "be enabled.\n",pci_func_id, pdev->class);
Amit S. Kaleed25ffa2006-12-04 09:23:25 -0800732 return -ENODEV;
733 }
Dhananjay Phadke29566402008-07-21 19:44:04 -0700734
Dhananjay Phadke11d89d62008-08-08 00:08:45 -0700735 if (pdev->revision >= NX_P3_A0 && pdev->revision < NX_P3_B1) {
736 printk(KERN_WARNING "NetXen chip revisions between 0x%x-0x%x"
737 "will not be enabled.\n",
738 NX_P3_A0, NX_P3_B1);
739 return -ENODEV;
740 }
741
Amit S. Kale3d396eb2006-10-21 15:33:03 -0400742 if ((err = pci_enable_device(pdev)))
743 return err;
Dhananjay Phadke29566402008-07-21 19:44:04 -0700744
Amit S. Kale3d396eb2006-10-21 15:33:03 -0400745 if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) {
746 err = -ENODEV;
747 goto err_out_disable_pdev;
748 }
749
750 if ((err = pci_request_regions(pdev, netxen_nic_driver_name)))
751 goto err_out_disable_pdev;
752
753 pci_set_master(pdev);
Mithlesh Thukral3176ff32007-04-20 07:52:37 -0700754
755 netdev = alloc_etherdev(sizeof(struct netxen_adapter));
756 if(!netdev) {
757 printk(KERN_ERR"%s: Failed to allocate memory for the "
758 "device block.Check system memory resource"
759 " usage.\n", netxen_nic_driver_name);
760 goto err_out_free_res;
761 }
762
Mithlesh Thukral3176ff32007-04-20 07:52:37 -0700763 SET_NETDEV_DEV(netdev, &pdev->dev);
764
Wang Chen4cf16532008-11-12 23:38:14 -0800765 adapter = netdev_priv(netdev);
Dhananjay Phadke29566402008-07-21 19:44:04 -0700766 adapter->netdev = netdev;
767 adapter->pdev = pdev;
Mithlesh Thukral13ba9c72007-04-20 07:53:05 -0700768 adapter->ahw.pci_func = pci_func_id;
Dhananjay Phadke29566402008-07-21 19:44:04 -0700769
770 revision_id = pdev->revision;
771 adapter->ahw.revision_id = revision_id;
772
773 err = nx_set_dma_mask(adapter, revision_id);
774 if (err)
775 goto err_out_free_netdev;
776
Dhananjay Phadke3ce06a32008-07-21 19:44:03 -0700777 rwlock_init(&adapter->adapter_lock);
Mithlesh Thukral13ba9c72007-04-20 07:53:05 -0700778
Dhananjay Phadke97daee82009-02-24 16:39:21 -0800779 err = netxen_setup_pci_map(adapter);
780 if (err)
Mithlesh Thukral6c80b182007-04-20 07:55:26 -0700781 goto err_out_free_netdev;
Amit S. Kale3d396eb2006-10-21 15:33:03 -0400782
Stephen Hemmingerbea33482007-10-03 16:41:36 -0700783 netif_napi_add(netdev, &adapter->napi,
Dhananjay Phadke29566402008-07-21 19:44:04 -0700784 netxen_nic_poll, NETXEN_NETDEV_WEIGHT);
785
dhananjay.phadke@gmail.com2d1a3bb2007-07-02 00:26:00 +0530786 /* This will be reset for mezz cards */
Mithlesh Thukral3176ff32007-04-20 07:52:37 -0700787 adapter->portnum = pci_func_id;
dhananjay.phadke@gmail.com2d1a3bb2007-07-02 00:26:00 +0530788 adapter->status &= ~NETXEN_NETDEV_STATUS;
Dhananjay Phadke200eef22007-09-03 10:33:35 +0530789 adapter->rx_csum = 1;
Dhananjay Phadke623621b2008-07-21 19:44:01 -0700790 adapter->mc_enabled = 0;
Dhananjay Phadke83821a02008-08-01 03:14:58 -0700791 if (NX_IS_REVISION_P3(revision_id))
Dhananjay Phadke29566402008-07-21 19:44:04 -0700792 adapter->max_mc_count = 38;
Dhananjay Phadke83821a02008-08-01 03:14:58 -0700793 else
Dhananjay Phadke29566402008-07-21 19:44:04 -0700794 adapter->max_mc_count = 16;
Mithlesh Thukral3176ff32007-04-20 07:52:37 -0700795
Stephen Hemminger1abd2662008-11-21 17:32:15 -0800796 netdev->netdev_ops = &netxen_netdev_ops;
Dhananjay Phadke05aaa022008-03-17 19:59:49 -0700797 netdev->watchdog_timeo = 2*HZ;
Mithlesh Thukral3176ff32007-04-20 07:52:37 -0700798
799 netxen_nic_change_mtu(netdev, netdev->mtu);
800
801 SET_ETHTOOL_OPS(netdev, &netxen_nic_ethtool_ops);
Stephen Hemminger1abd2662008-11-21 17:32:15 -0800802
Dhananjay Phadkecdff1032009-01-26 12:34:57 -0800803 netdev->features |= (NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO);
804 netdev->vlan_features |= (NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO);
805
Dhananjay Phadkecd1f8162008-07-21 19:44:09 -0700806 if (NX_IS_REVISION_P3(revision_id)) {
Dhananjay Phadkecdff1032009-01-26 12:34:57 -0800807 netdev->features |= (NETIF_F_IPV6_CSUM | NETIF_F_TSO6);
808 netdev->vlan_features |= (NETIF_F_IPV6_CSUM | NETIF_F_TSO6);
Dhananjay Phadkecd1f8162008-07-21 19:44:09 -0700809 }
Mithlesh Thukral3176ff32007-04-20 07:52:37 -0700810
Dhananjay Phadkecdff1032009-01-26 12:34:57 -0800811 if (adapter->pci_using_dac) {
Mithlesh Thukral3176ff32007-04-20 07:52:37 -0700812 netdev->features |= NETIF_F_HIGHDMA;
Dhananjay Phadkecdff1032009-01-26 12:34:57 -0800813 netdev->vlan_features |= NETIF_F_HIGHDMA;
814 }
Mithlesh Thukral3176ff32007-04-20 07:52:37 -0700815
Dhananjay Phadkedcd56fd2008-06-15 22:59:45 -0700816 if (netxen_nic_get_board_info(adapter) != 0) {
817 printk("%s: Error getting board config info.\n",
Dhananjay Phadke29566402008-07-21 19:44:04 -0700818 netxen_nic_driver_name);
Dhananjay Phadkedcd56fd2008-06-15 22:59:45 -0700819 err = -EIO;
820 goto err_out_iounmap;
821 }
Mithlesh Thukral6c80b182007-04-20 07:55:26 -0700822
Mithlesh Thukral6c80b182007-04-20 07:55:26 -0700823 netxen_initialize_adapter_ops(adapter);
824
Mithlesh Thukral13ba9c72007-04-20 07:53:05 -0700825 /* Mezz cards have PCI function 0,2,3 enabled */
Dhananjay Phadkedc515f22008-06-15 22:59:43 -0700826 switch (adapter->ahw.boardcfg.board_type) {
827 case NETXEN_BRDTYPE_P2_SB31_10G_IMEZ:
828 case NETXEN_BRDTYPE_P2_SB31_10G_HMEZ:
829 if (pci_func_id >= 2)
Mithlesh Thukral13ba9c72007-04-20 07:53:05 -0700830 adapter->portnum = pci_func_id - 2;
Dhananjay Phadkedc515f22008-06-15 22:59:43 -0700831 break;
832 default:
833 break;
834 }
Mithlesh Thukral13ba9c72007-04-20 07:53:05 -0700835
Dhananjay Phadke29566402008-07-21 19:44:04 -0700836 /*
837 * This call will setup various max rx/tx counts.
838 * It must be done before any buffer/ring allocations.
839 */
840 netxen_check_options(adapter);
Amit S. Kale3d396eb2006-10-21 15:33:03 -0400841
Dhananjay Phadke29566402008-07-21 19:44:04 -0700842 first_driver = 0;
843 if (NX_IS_REVISION_P3(revision_id)) {
844 if (adapter->ahw.pci_func == 0)
845 first_driver = 1;
846 } else {
847 if (adapter->portnum == 0)
848 first_driver = 1;
849 }
Amit S. Kale3d396eb2006-10-21 15:33:03 -0400850
Dhananjay Phadke29566402008-07-21 19:44:04 -0700851 if (first_driver) {
Dhananjay Phadkeba599d42009-02-24 16:38:22 -0800852 err = netxen_start_firmware(adapter);
Dhananjay Phadke29566402008-07-21 19:44:04 -0700853 if (err)
854 goto err_out_iounmap;
Dhananjay Phadkeba599d42009-02-24 16:38:22 -0800855 }
Dhananjay Phadke29566402008-07-21 19:44:04 -0700856
857 netxen_nic_flash_print(adapter);
858
Dhananjay Phadked9e651b2008-07-21 19:44:08 -0700859 if (NX_IS_REVISION_P3(revision_id)) {
860 adapter->hw_read_wx(adapter,
861 NETXEN_MIU_MN_CONTROL, &val, 4);
862 adapter->ahw.cut_through = (val & 0x4) ? 1 : 0;
863 dev_info(&pdev->dev, "firmware running in %s mode\n",
864 adapter->ahw.cut_through ? "cut through" : "legacy");
865 }
866
Dhananjay Phadke29566402008-07-21 19:44:04 -0700867 /*
868 * See if the firmware gave us a virtual-physical port mapping.
869 */
870 adapter->physical_port = adapter->portnum;
Dhananjay Phadke044fad02009-02-24 03:42:59 -0800871 if (adapter->fw_major < 4) {
872 i = adapter->pci_read_normalize(adapter,
873 CRB_V2P(adapter->portnum));
874 if (i != 0x55555555)
875 adapter->physical_port = i;
876 }
Dhananjay Phadke29566402008-07-21 19:44:04 -0700877
878 adapter->flags &= ~(NETXEN_NIC_MSI_ENABLED | NETXEN_NIC_MSIX_ENABLED);
879
880 netxen_set_msix_bit(pdev, 0);
881
Dhananjay Phadke97daee82009-02-24 16:39:21 -0800882 netxen_setup_intr(adapter);
Dhananjay Phadke29566402008-07-21 19:44:04 -0700883
884 if (adapter->flags & NETXEN_NIC_MSIX_ENABLED)
885 netdev->irq = adapter->msix_entries[0].vector;
886 else
887 netdev->irq = pdev->irq;
888
889 err = netxen_receive_peg_ready(adapter);
890 if (err)
891 goto err_out_disable_msi;
892
893 init_timer(&adapter->watchdog_timer);
Dhananjay Phadke29566402008-07-21 19:44:04 -0700894 adapter->watchdog_timer.function = &netxen_watchdog;
895 adapter->watchdog_timer.data = (unsigned long)adapter;
896 INIT_WORK(&adapter->watchdog_task, netxen_watchdog_task);
897 INIT_WORK(&adapter->tx_timeout_task, netxen_tx_timeout_task);
898
Dhananjay Phadke9dc28ef2008-08-08 00:08:39 -0700899 err = netxen_read_mac_addr(adapter);
900 if (err)
901 dev_warn(&pdev->dev, "failed to read mac addr\n");
Mithlesh Thukral3176ff32007-04-20 07:52:37 -0700902
Mithlesh Thukral3176ff32007-04-20 07:52:37 -0700903 netif_carrier_off(netdev);
904 netif_stop_queue(netdev);
905
Mithlesh Thukral6c80b182007-04-20 07:55:26 -0700906 if ((err = register_netdev(netdev))) {
907 printk(KERN_ERR "%s: register_netdev failed port #%d"
908 " aborting\n", netxen_nic_driver_name,
909 adapter->portnum);
910 err = -EIO;
Dhananjay Phadke29566402008-07-21 19:44:04 -0700911 goto err_out_disable_msi;
Mithlesh Thukral6c80b182007-04-20 07:55:26 -0700912 }
913
914 pci_set_drvdata(pdev, adapter);
Amit S. Kale3d396eb2006-10-21 15:33:03 -0400915
Dhananjay Phadke29566402008-07-21 19:44:04 -0700916 switch (adapter->ahw.board_type) {
917 case NETXEN_NIC_GBE:
918 dev_info(&adapter->pdev->dev, "%s: GbE port initialized\n",
919 adapter->netdev->name);
920 break;
921 case NETXEN_NIC_XGBE:
922 dev_info(&adapter->pdev->dev, "%s: XGbE port initialized\n",
923 adapter->netdev->name);
924 break;
925 }
926
Amit S. Kale3d396eb2006-10-21 15:33:03 -0400927 return 0;
928
Dhananjay Phadke29566402008-07-21 19:44:04 -0700929err_out_disable_msi:
Dhananjay Phadke97daee82009-02-24 16:39:21 -0800930 netxen_teardown_intr(adapter);
Mithlesh Thukral6c80b182007-04-20 07:55:26 -0700931
Dhananjay Phadke29566402008-07-21 19:44:04 -0700932 if (first_driver)
933 netxen_free_adapter_offload(adapter);
Amit S. Kale3d396eb2006-10-21 15:33:03 -0400934
Dhananjay Phadke29566402008-07-21 19:44:04 -0700935err_out_iounmap:
Dhananjay Phadke97daee82009-02-24 16:39:21 -0800936 netxen_cleanup_pci_map(adapter);
Amit S. Kalecb8011a2006-11-29 09:00:10 -0800937
Mithlesh Thukral6c80b182007-04-20 07:55:26 -0700938err_out_free_netdev:
939 free_netdev(netdev);
940
941err_out_free_res:
Amit S. Kale3d396eb2006-10-21 15:33:03 -0400942 pci_release_regions(pdev);
Mithlesh Thukral6c80b182007-04-20 07:55:26 -0700943
944err_out_disable_pdev:
Dhananjay Phadke29566402008-07-21 19:44:04 -0700945 pci_set_drvdata(pdev, NULL);
Amit S. Kale3d396eb2006-10-21 15:33:03 -0400946 pci_disable_device(pdev);
947 return err;
948}
949
950static void __devexit netxen_nic_remove(struct pci_dev *pdev)
951{
952 struct netxen_adapter *adapter;
Mithlesh Thukral3176ff32007-04-20 07:52:37 -0700953 struct net_device *netdev;
Amit S. Kale3d396eb2006-10-21 15:33:03 -0400954
Mithlesh Thukral6c80b182007-04-20 07:55:26 -0700955 adapter = pci_get_drvdata(pdev);
Amit S. Kale3d396eb2006-10-21 15:33:03 -0400956 if (adapter == NULL)
957 return;
958
Mithlesh Thukral6c80b182007-04-20 07:55:26 -0700959 netdev = adapter->netdev;
960
Dhananjay Phadke96acb6e2007-07-02 09:37:57 +0530961 unregister_netdev(netdev);
962
Dhananjay Phadke96acb6e2007-07-02 09:37:57 +0530963 if (adapter->is_up == NETXEN_ADAPTER_UP_MAGIC) {
Amit S. Kale3d396eb2006-10-21 15:33:03 -0400964 netxen_free_hw_resources(adapter);
Dhananjay Phadke9e410772008-08-08 00:08:40 -0700965 netxen_release_rx_buffers(adapter);
Dhananjay Phadke29566402008-07-21 19:44:04 -0700966 netxen_free_sw_resources(adapter);
Dhananjay Phadke06e9d9f2009-01-14 20:49:22 -0800967
968 if (NX_IS_REVISION_P3(adapter->ahw.revision_id))
969 netxen_p3_free_mac_list(adapter);
Dhananjay Phadke96acb6e2007-07-02 09:37:57 +0530970 }
Amit S. Kale3d396eb2006-10-21 15:33:03 -0400971
Dhananjay Phadke439b4542008-06-15 22:59:46 -0700972 if (adapter->portnum == 0)
973 netxen_free_adapter_offload(adapter);
Dhananjay Phadke96acb6e2007-07-02 09:37:57 +0530974
dhananjay@netxen.com30522462007-08-28 17:23:26 +0530975 if (adapter->irq)
976 free_irq(adapter->irq, adapter);
977
Dhananjay Phadke97daee82009-02-24 16:39:21 -0800978 netxen_teardown_intr(adapter);
dhananjay@netxen.com30522462007-08-28 17:23:26 +0530979
Dhananjay Phadke97daee82009-02-24 16:39:21 -0800980 netxen_cleanup_pci_map(adapter);
Mithlesh Thukral595e3fb2007-04-20 07:53:52 -0700981
982 pci_release_regions(pdev);
dhananjay@netxen.com30522462007-08-28 17:23:26 +0530983 pci_disable_device(pdev);
Mithlesh Thukral595e3fb2007-04-20 07:53:52 -0700984 pci_set_drvdata(pdev, NULL);
985
Mithlesh Thukral6c80b182007-04-20 07:55:26 -0700986 free_netdev(netdev);
Amit S. Kale3d396eb2006-10-21 15:33:03 -0400987}
988
989/*
990 * Called when a network interface is made active
991 * @returns 0 on success, negative value on failure
992 */
993static int netxen_nic_open(struct net_device *netdev)
994{
Wang Chen4cf16532008-11-12 23:38:14 -0800995 struct netxen_adapter *adapter = netdev_priv(netdev);
Amit S. Kale3d396eb2006-10-21 15:33:03 -0400996 int err = 0;
997 int ctx, ring;
Dhananjay Phadke05aaa022008-03-17 19:59:49 -0700998 irq_handler_t handler;
999 unsigned long flags = IRQF_SAMPLE_RANDOM;
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001000
Dhananjay Phadkedcd56fd2008-06-15 22:59:45 -07001001 if (adapter->driver_mismatch)
1002 return -EIO;
1003
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001004 if (adapter->is_up != NETXEN_ADAPTER_UP_MAGIC) {
1005 err = netxen_init_firmware(adapter);
1006 if (err != 0) {
1007 printk(KERN_ERR "Failed to init firmware\n");
1008 return -EIO;
1009 }
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001010
Dhananjay Phadke83821a02008-08-01 03:14:58 -07001011 if (adapter->fw_major < 4)
1012 adapter->max_rds_rings = 3;
1013 else
1014 adapter->max_rds_rings = 2;
1015
Dhananjay Phadke29566402008-07-21 19:44:04 -07001016 err = netxen_alloc_sw_resources(adapter);
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001017 if (err) {
Dhananjay Phadke29566402008-07-21 19:44:04 -07001018 printk(KERN_ERR "%s: Error in setting sw resources\n",
1019 netdev->name);
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001020 return err;
1021 }
Dhananjay Phadke29566402008-07-21 19:44:04 -07001022
1023 netxen_nic_clear_stats(adapter);
1024
1025 err = netxen_alloc_hw_resources(adapter);
1026 if (err) {
1027 printk(KERN_ERR "%s: Error in setting hw resources\n",
1028 netdev->name);
1029 goto err_out_free_sw;
1030 }
1031
Dhananjay Phadke092bc572008-08-08 00:08:43 -07001032 if ((adapter->msi_mode != MSI_MODE_MULTIFUNC) ||
1033 (adapter->intr_scheme != INTR_SCHEME_PERPORT)) {
1034 printk(KERN_ERR "%s: Firmware interrupt scheme is "
1035 "incompatible with driver\n",
1036 netdev->name);
1037 adapter->driver_mismatch = 1;
1038 goto err_out_free_hw;
1039 }
1040
Dhananjay Phadke29566402008-07-21 19:44:04 -07001041 if (adapter->fw_major < 4) {
1042 adapter->crb_addr_cmd_producer =
1043 crb_cmd_producer[adapter->portnum];
1044 adapter->crb_addr_cmd_consumer =
1045 crb_cmd_consumer[adapter->portnum];
Dhananjay Phadke29566402008-07-21 19:44:04 -07001046
Dhananjay Phadke83821a02008-08-01 03:14:58 -07001047 netxen_nic_update_cmd_producer(adapter, 0);
1048 netxen_nic_update_cmd_consumer(adapter, 0);
1049 }
Dhananjay Phadke29566402008-07-21 19:44:04 -07001050
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001051 for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) {
Dhananjay Phadke48bfd1e2008-07-21 19:44:06 -07001052 for (ring = 0; ring < adapter->max_rds_rings; ring++)
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001053 netxen_post_rx_buffers(adapter, ctx, ring);
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001054 }
Dhananjay Phadkeb3df68f2009-02-08 19:20:19 -08001055 if (adapter->flags & NETXEN_NIC_MSIX_ENABLED)
1056 handler = netxen_msix_intr;
1057 else if (adapter->flags & NETXEN_NIC_MSI_ENABLED)
Dhananjay Phadke05aaa022008-03-17 19:59:49 -07001058 handler = netxen_msi_intr;
1059 else {
1060 flags |= IRQF_SHARED;
1061 handler = netxen_intr;
1062 }
Dhananjay Phadke29566402008-07-21 19:44:04 -07001063 adapter->irq = netdev->irq;
Dhananjay Phadke05aaa022008-03-17 19:59:49 -07001064 err = request_irq(adapter->irq, handler,
1065 flags, netdev->name, adapter);
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001066 if (err) {
1067 printk(KERN_ERR "request_irq failed with: %d\n", err);
Dhananjay Phadke9e410772008-08-08 00:08:40 -07001068 goto err_out_free_rxbuf;
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001069 }
Amit S. Kaleed25ffa2006-12-04 09:23:25 -08001070
1071 adapter->is_up = NETXEN_ADAPTER_UP_MAGIC;
1072 }
Dhananjay Phadke29566402008-07-21 19:44:04 -07001073
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001074 /* Done here again so that even if phantom sw overwrote it,
1075 * we set it */
Dhananjay Phadkec9fc8912008-07-21 19:44:07 -07001076 err = adapter->init_port(adapter, adapter->physical_port);
Dhananjay Phadke29566402008-07-21 19:44:04 -07001077 if (err) {
Mithlesh Thukral595e3fb2007-04-20 07:53:52 -07001078 printk(KERN_ERR "%s: Failed to initialize port %d\n",
1079 netxen_nic_driver_name, adapter->portnum);
Dhananjay Phadke29566402008-07-21 19:44:04 -07001080 goto err_out_free_irq;
Mithlesh Thukral595e3fb2007-04-20 07:53:52 -07001081 }
Dhananjay Phadke29566402008-07-21 19:44:04 -07001082 adapter->macaddr_set(adapter, netdev->dev_addr);
Mithlesh Thukral595e3fb2007-04-20 07:53:52 -07001083
Mithlesh Thukral3176ff32007-04-20 07:52:37 -07001084 netxen_nic_set_link_parameters(adapter);
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001085
Stephen Hemminger1abd2662008-11-21 17:32:15 -08001086 netxen_set_multicast_list(netdev);
Dhananjay Phadke9ad27642008-08-01 03:14:59 -07001087 if (adapter->set_mtu)
Dhananjay Phadkec9fc8912008-07-21 19:44:07 -07001088 adapter->set_mtu(adapter, netdev->mtu);
Amit S. Kaleed25ffa2006-12-04 09:23:25 -08001089
Dhananjay Phadke922c4f22008-08-08 00:08:41 -07001090 adapter->ahw.linkup = 0;
Dhananjay Phadkedcd56fd2008-06-15 22:59:45 -07001091 mod_timer(&adapter->watchdog_timer, jiffies);
Dhananjay Phadke05aaa022008-03-17 19:59:49 -07001092
1093 napi_enable(&adapter->napi);
1094 netxen_nic_enable_int(adapter);
1095
Dhananjay Phadkedcd56fd2008-06-15 22:59:45 -07001096 netif_start_queue(netdev);
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001097
1098 return 0;
Dhananjay Phadke29566402008-07-21 19:44:04 -07001099
1100err_out_free_irq:
1101 free_irq(adapter->irq, adapter);
Dhananjay Phadke9e410772008-08-08 00:08:40 -07001102err_out_free_rxbuf:
1103 netxen_release_rx_buffers(adapter);
Dhananjay Phadke092bc572008-08-08 00:08:43 -07001104err_out_free_hw:
Dhananjay Phadke29566402008-07-21 19:44:04 -07001105 netxen_free_hw_resources(adapter);
1106err_out_free_sw:
1107 netxen_free_sw_resources(adapter);
1108 return err;
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001109}
1110
1111/*
1112 * netxen_nic_close - Disables a network interface entry point
1113 */
1114static int netxen_nic_close(struct net_device *netdev)
1115{
Mithlesh Thukral3176ff32007-04-20 07:52:37 -07001116 struct netxen_adapter *adapter = netdev_priv(netdev);
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001117
1118 netif_carrier_off(netdev);
1119 netif_stop_queue(netdev);
Stephen Hemmingerbea33482007-10-03 16:41:36 -07001120 napi_disable(&adapter->napi);
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001121
dhananjay@netxen.com72b0a7a2007-12-26 10:23:56 -08001122 if (adapter->stop_port)
1123 adapter->stop_port(adapter);
1124
dhananjay@netxen.come01872af2007-07-25 20:13:12 +05301125 netxen_nic_disable_int(adapter);
1126
Dhananjay Phadke29566402008-07-21 19:44:04 -07001127 netxen_release_tx_buffers(adapter);
1128
Dhananjay Phadke922c4f22008-08-08 00:08:41 -07001129 FLUSH_SCHEDULED_WORK();
1130 del_timer_sync(&adapter->watchdog_timer);
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001131
1132 return 0;
1133}
1134
Dhananjay Phadke391587c2009-01-14 20:48:11 -08001135static bool netxen_tso_check(struct net_device *netdev,
Dhananjay Phadkecd1f8162008-07-21 19:44:09 -07001136 struct cmd_desc_type0 *desc, struct sk_buff *skb)
1137{
Dhananjay Phadke391587c2009-01-14 20:48:11 -08001138 bool tso = false;
1139 u8 opcode = TX_ETHER_PKT;
Dhananjay Phadkecdff1032009-01-26 12:34:57 -08001140 __be16 protocol = skb->protocol;
1141 u16 flags = 0;
1142
Harvey Harrison09640e62009-02-01 00:45:17 -08001143 if (protocol == cpu_to_be16(ETH_P_8021Q)) {
Dhananjay Phadkecdff1032009-01-26 12:34:57 -08001144 struct vlan_ethhdr *vh = (struct vlan_ethhdr *)skb->data;
1145 protocol = vh->h_vlan_encapsulated_proto;
1146 flags = FLAGS_VLAN_TAGGED;
1147 }
Dhananjay Phadkecd1f8162008-07-21 19:44:09 -07001148
Dhananjay Phadke391587c2009-01-14 20:48:11 -08001149 if ((netdev->features & (NETIF_F_TSO | NETIF_F_TSO6)) &&
1150 skb_shinfo(skb)->gso_size > 0) {
1151
1152 desc->mss = cpu_to_le16(skb_shinfo(skb)->gso_size);
1153 desc->total_hdr_length =
1154 skb_transport_offset(skb) + tcp_hdrlen(skb);
1155
Harvey Harrison09640e62009-02-01 00:45:17 -08001156 opcode = (protocol == cpu_to_be16(ETH_P_IPV6)) ?
Dhananjay Phadke391587c2009-01-14 20:48:11 -08001157 TX_TCP_LSO6 : TX_TCP_LSO;
1158 tso = true;
Dhananjay Phadkecd1f8162008-07-21 19:44:09 -07001159
1160 } else if (skb->ip_summed == CHECKSUM_PARTIAL) {
Dhananjay Phadke391587c2009-01-14 20:48:11 -08001161 u8 l4proto;
1162
Harvey Harrison09640e62009-02-01 00:45:17 -08001163 if (protocol == cpu_to_be16(ETH_P_IP)) {
Dhananjay Phadke391587c2009-01-14 20:48:11 -08001164 l4proto = ip_hdr(skb)->protocol;
1165
1166 if (l4proto == IPPROTO_TCP)
1167 opcode = TX_TCP_PKT;
1168 else if(l4proto == IPPROTO_UDP)
1169 opcode = TX_UDP_PKT;
Harvey Harrison09640e62009-02-01 00:45:17 -08001170 } else if (protocol == cpu_to_be16(ETH_P_IPV6)) {
Dhananjay Phadke391587c2009-01-14 20:48:11 -08001171 l4proto = ipv6_hdr(skb)->nexthdr;
1172
1173 if (l4proto == IPPROTO_TCP)
1174 opcode = TX_TCPV6_PKT;
1175 else if(l4proto == IPPROTO_UDP)
1176 opcode = TX_UDPV6_PKT;
1177 }
Dhananjay Phadkecd1f8162008-07-21 19:44:09 -07001178 }
1179 desc->tcp_hdr_offset = skb_transport_offset(skb);
1180 desc->ip_hdr_offset = skb_network_offset(skb);
Dhananjay Phadkecdff1032009-01-26 12:34:57 -08001181 netxen_set_tx_flags_opcode(desc, flags, opcode);
Dhananjay Phadke391587c2009-01-14 20:48:11 -08001182 return tso;
Dhananjay Phadkecd1f8162008-07-21 19:44:09 -07001183}
1184
Dhananjay Phadke6f703402009-01-14 20:50:00 -08001185static void
1186netxen_clean_tx_dma_mapping(struct pci_dev *pdev,
1187 struct netxen_cmd_buffer *pbuf, int last)
1188{
1189 int k;
1190 struct netxen_skb_frag *buffrag;
1191
1192 buffrag = &pbuf->frag_array[0];
1193 pci_unmap_single(pdev, buffrag->dma,
1194 buffrag->length, PCI_DMA_TODEVICE);
1195
1196 for (k = 1; k < last; k++) {
1197 buffrag = &pbuf->frag_array[k];
1198 pci_unmap_page(pdev, buffrag->dma,
1199 buffrag->length, PCI_DMA_TODEVICE);
1200 }
1201}
1202
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001203static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
1204{
Mithlesh Thukral3176ff32007-04-20 07:52:37 -07001205 struct netxen_adapter *adapter = netdev_priv(netdev);
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001206 struct netxen_hardware_context *hw = &adapter->ahw;
1207 unsigned int first_seg_len = skb->len - skb->data_len;
Dhananjay Phadke391587c2009-01-14 20:48:11 -08001208 struct netxen_cmd_buffer *pbuf;
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001209 struct netxen_skb_frag *buffrag;
Dhananjay Phadke391587c2009-01-14 20:48:11 -08001210 struct cmd_desc_type0 *hwdesc;
Dhananjay Phadke6f703402009-01-14 20:50:00 -08001211 struct pci_dev *pdev = adapter->pdev;
1212 dma_addr_t temp_dma;
Dhananjay Phadke391587c2009-01-14 20:48:11 -08001213 int i, k;
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001214
Dhananjay Phadkeba53e6b2008-03-17 19:59:50 -07001215 u32 producer, consumer;
Dhananjay Phadke391587c2009-01-14 20:48:11 -08001216 int frag_count, no_of_desc;
Dhananjay Phadkeba53e6b2008-03-17 19:59:50 -07001217 u32 num_txd = adapter->max_tx_desc_count;
Dhananjay Phadke391587c2009-01-14 20:48:11 -08001218 bool is_tso = false;
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001219
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001220 frag_count = skb_shinfo(skb)->nr_frags + 1;
1221
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001222 /* There 4 fragments per descriptor */
1223 no_of_desc = (frag_count + 3) >> 2;
dhananjay@netxen.com53a01e02007-12-26 10:23:58 -08001224
Dhananjay Phadkeba53e6b2008-03-17 19:59:50 -07001225 producer = adapter->cmd_producer;
1226 smp_mb();
1227 consumer = adapter->last_cmd_consumer;
1228 if ((no_of_desc+2) > find_diff_among(producer, consumer, num_txd)) {
1229 netif_stop_queue(netdev);
1230 smp_mb();
1231 return NETDEV_TX_BUSY;
dhananjay@netxen.com53a01e02007-12-26 10:23:58 -08001232 }
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001233
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001234 /* Copy the descriptors into the hardware */
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001235 hwdesc = &hw->cmd_desc_head[producer];
1236 memset(hwdesc, 0, sizeof(struct cmd_desc_type0));
1237 /* Take skb->data itself */
1238 pbuf = &adapter->cmd_buf_arr[producer];
Dhananjay Phadke391587c2009-01-14 20:48:11 -08001239
1240 is_tso = netxen_tso_check(netdev, hwdesc, skb);
1241
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001242 pbuf->skb = skb;
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001243 pbuf->frag_count = frag_count;
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001244 buffrag = &pbuf->frag_array[0];
Dhananjay Phadke6f703402009-01-14 20:50:00 -08001245 temp_dma = pci_map_single(pdev, skb->data, first_seg_len,
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001246 PCI_DMA_TODEVICE);
Dhananjay Phadke6f703402009-01-14 20:50:00 -08001247 if (pci_dma_mapping_error(pdev, temp_dma))
1248 goto drop_packet;
1249
1250 buffrag->dma = temp_dma;
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001251 buffrag->length = first_seg_len;
Dhananjay Phadke391587c2009-01-14 20:48:11 -08001252 netxen_set_tx_frags_len(hwdesc, frag_count, skb->len);
1253 netxen_set_tx_port(hwdesc, adapter->portnum);
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001254
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001255 hwdesc->buffer1_length = cpu_to_le16(first_seg_len);
1256 hwdesc->addr_buffer1 = cpu_to_le64(buffrag->dma);
1257
1258 for (i = 1, k = 1; i < frag_count; i++, k++) {
1259 struct skb_frag_struct *frag;
1260 int len, temp_len;
1261 unsigned long offset;
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001262
1263 /* move to next desc. if there is a need */
1264 if ((i & 0x3) == 0) {
1265 k = 0;
Dhananjay Phadkeba53e6b2008-03-17 19:59:50 -07001266 producer = get_next_index(producer, num_txd);
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001267 hwdesc = &hw->cmd_desc_head[producer];
1268 memset(hwdesc, 0, sizeof(struct cmd_desc_type0));
dhananjay@netxen.com53a01e02007-12-26 10:23:58 -08001269 pbuf = &adapter->cmd_buf_arr[producer];
1270 pbuf->skb = NULL;
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001271 }
1272 frag = &skb_shinfo(skb)->frags[i - 1];
1273 len = frag->size;
1274 offset = frag->page_offset;
1275
1276 temp_len = len;
Dhananjay Phadke6f703402009-01-14 20:50:00 -08001277 temp_dma = pci_map_page(pdev, frag->page, offset,
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001278 len, PCI_DMA_TODEVICE);
Dhananjay Phadke6f703402009-01-14 20:50:00 -08001279 if (pci_dma_mapping_error(pdev, temp_dma)) {
1280 netxen_clean_tx_dma_mapping(pdev, pbuf, i);
1281 goto drop_packet;
1282 }
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001283
1284 buffrag++;
1285 buffrag->dma = temp_dma;
1286 buffrag->length = temp_len;
1287
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001288 switch (k) {
1289 case 0:
1290 hwdesc->buffer1_length = cpu_to_le16(temp_len);
1291 hwdesc->addr_buffer1 = cpu_to_le64(temp_dma);
1292 break;
1293 case 1:
1294 hwdesc->buffer2_length = cpu_to_le16(temp_len);
1295 hwdesc->addr_buffer2 = cpu_to_le64(temp_dma);
1296 break;
1297 case 2:
1298 hwdesc->buffer3_length = cpu_to_le16(temp_len);
1299 hwdesc->addr_buffer3 = cpu_to_le64(temp_dma);
1300 break;
1301 case 3:
Al Viroa608ab9c2007-01-02 10:39:10 +00001302 hwdesc->buffer4_length = cpu_to_le16(temp_len);
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001303 hwdesc->addr_buffer4 = cpu_to_le64(temp_dma);
1304 break;
1305 }
1306 frag++;
1307 }
Dhananjay Phadkeba53e6b2008-03-17 19:59:50 -07001308 producer = get_next_index(producer, num_txd);
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001309
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001310 /* For LSO, we need to copy the MAC/IP/TCP headers into
1311 * the descriptor ring
1312 */
Dhananjay Phadke391587c2009-01-14 20:48:11 -08001313 if (is_tso) {
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001314 int hdr_len, first_hdr_len, more_hdr;
Dhananjay Phadke391587c2009-01-14 20:48:11 -08001315 hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
Amit S. Kaleed25ffa2006-12-04 09:23:25 -08001316 if (hdr_len > (sizeof(struct cmd_desc_type0) - 2)) {
1317 first_hdr_len = sizeof(struct cmd_desc_type0) - 2;
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001318 more_hdr = 1;
1319 } else {
1320 first_hdr_len = hdr_len;
1321 more_hdr = 0;
1322 }
1323 /* copy the MAC/IP/TCP headers to the cmd descriptor list */
1324 hwdesc = &hw->cmd_desc_head[producer];
dhananjay@netxen.com53a01e02007-12-26 10:23:58 -08001325 pbuf = &adapter->cmd_buf_arr[producer];
1326 pbuf->skb = NULL;
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001327
1328 /* copy the first 64 bytes */
Amit S. Kaleed25ffa2006-12-04 09:23:25 -08001329 memcpy(((void *)hwdesc) + 2,
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001330 (void *)(skb->data), first_hdr_len);
Dhananjay Phadkeba53e6b2008-03-17 19:59:50 -07001331 producer = get_next_index(producer, num_txd);
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001332
1333 if (more_hdr) {
1334 hwdesc = &hw->cmd_desc_head[producer];
dhananjay@netxen.com53a01e02007-12-26 10:23:58 -08001335 pbuf = &adapter->cmd_buf_arr[producer];
1336 pbuf->skb = NULL;
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001337 /* copy the next 64 bytes - should be enough except
1338 * for pathological case
1339 */
Arnaldo Carvalho de Melod626f622007-03-27 18:55:52 -03001340 skb_copy_from_linear_data_offset(skb, first_hdr_len,
1341 hwdesc,
1342 (hdr_len -
1343 first_hdr_len));
Dhananjay Phadkeba53e6b2008-03-17 19:59:50 -07001344 producer = get_next_index(producer, num_txd);
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001345 }
1346 }
Mithlesh Thukral6c80b182007-04-20 07:55:26 -07001347
Dhananjay Phadkeba53e6b2008-03-17 19:59:50 -07001348 adapter->cmd_producer = producer;
Dhananjay Phadke5dc16262007-12-31 10:08:57 -08001349 adapter->stats.txbytes += skb->len;
Mithlesh Thukral6c80b182007-04-20 07:55:26 -07001350
Dhananjay Phadkeba53e6b2008-03-17 19:59:50 -07001351 netxen_nic_update_cmd_producer(adapter, adapter->cmd_producer);
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001352
Dhananjay Phadkeba53e6b2008-03-17 19:59:50 -07001353 adapter->stats.xmitcalled++;
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001354 netdev->trans_start = jiffies;
1355
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001356 return NETDEV_TX_OK;
Dhananjay Phadke6f703402009-01-14 20:50:00 -08001357
1358drop_packet:
1359 adapter->stats.txdropped++;
1360 dev_kfree_skb_any(skb);
1361 return NETDEV_TX_OK;
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001362}
1363
Dhananjay Phadkea97342f2008-07-21 19:44:05 -07001364static int netxen_nic_check_temp(struct netxen_adapter *adapter)
1365{
1366 struct net_device *netdev = adapter->netdev;
1367 uint32_t temp, temp_state, temp_val;
1368 int rv = 0;
1369
1370 temp = adapter->pci_read_normalize(adapter, CRB_TEMP_STATE);
1371
1372 temp_state = nx_get_temp_state(temp);
1373 temp_val = nx_get_temp_val(temp);
1374
1375 if (temp_state == NX_TEMP_PANIC) {
1376 printk(KERN_ALERT
1377 "%s: Device temperature %d degrees C exceeds"
1378 " maximum allowed. Hardware has been shut down.\n",
1379 netxen_nic_driver_name, temp_val);
1380
1381 netif_carrier_off(netdev);
1382 netif_stop_queue(netdev);
1383 rv = 1;
1384 } else if (temp_state == NX_TEMP_WARN) {
1385 if (adapter->temp == NX_TEMP_NORMAL) {
1386 printk(KERN_ALERT
1387 "%s: Device temperature %d degrees C "
1388 "exceeds operating range."
1389 " Immediate action needed.\n",
1390 netxen_nic_driver_name, temp_val);
1391 }
1392 } else {
1393 if (adapter->temp == NX_TEMP_WARN) {
1394 printk(KERN_INFO
1395 "%s: Device temperature is now %d degrees C"
1396 " in normal range.\n", netxen_nic_driver_name,
1397 temp_val);
1398 }
1399 }
1400 adapter->temp = temp_state;
1401 return rv;
1402}
1403
1404static void netxen_nic_handle_phy_intr(struct netxen_adapter *adapter)
1405{
1406 struct net_device *netdev = adapter->netdev;
1407 u32 val, port, linkup;
1408
1409 port = adapter->physical_port;
1410
Dhananjay Phadke24a7a452008-08-01 03:14:55 -07001411 if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) {
1412 val = adapter->pci_read_normalize(adapter, CRB_XG_STATE_P3);
1413 val = XG_LINK_STATE_P3(adapter->ahw.pci_func, val);
1414 linkup = (val == XG_LINK_UP_P3);
Dhananjay Phadkec9fc8912008-07-21 19:44:07 -07001415 } else {
Dhananjay Phadke24a7a452008-08-01 03:14:55 -07001416 val = adapter->pci_read_normalize(adapter, CRB_XG_STATE);
1417 if (adapter->ahw.board_type == NETXEN_NIC_GBE)
1418 linkup = (val >> port) & 1;
1419 else {
Dhananjay Phadkec9fc8912008-07-21 19:44:07 -07001420 val = (val >> port*8) & 0xff;
1421 linkup = (val == XG_LINK_UP);
Dhananjay Phadkec9fc8912008-07-21 19:44:07 -07001422 }
Dhananjay Phadkea97342f2008-07-21 19:44:05 -07001423 }
1424
1425 if (adapter->ahw.linkup && !linkup) {
1426 printk(KERN_INFO "%s: %s NIC Link is down\n",
1427 netxen_nic_driver_name, netdev->name);
1428 adapter->ahw.linkup = 0;
1429 if (netif_running(netdev)) {
1430 netif_carrier_off(netdev);
1431 netif_stop_queue(netdev);
1432 }
Dhananjay Phadkec7860a22009-01-14 20:48:32 -08001433
1434 netxen_nic_set_link_parameters(adapter);
Dhananjay Phadkea97342f2008-07-21 19:44:05 -07001435 } else if (!adapter->ahw.linkup && linkup) {
1436 printk(KERN_INFO "%s: %s NIC Link is up\n",
1437 netxen_nic_driver_name, netdev->name);
1438 adapter->ahw.linkup = 1;
1439 if (netif_running(netdev)) {
1440 netif_carrier_on(netdev);
1441 netif_wake_queue(netdev);
1442 }
Dhananjay Phadkec7860a22009-01-14 20:48:32 -08001443
1444 netxen_nic_set_link_parameters(adapter);
Dhananjay Phadkea97342f2008-07-21 19:44:05 -07001445 }
1446}
1447
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001448static void netxen_watchdog(unsigned long v)
1449{
1450 struct netxen_adapter *adapter = (struct netxen_adapter *)v;
Amit S. Kaleed25ffa2006-12-04 09:23:25 -08001451
1452 SCHEDULE_WORK(&adapter->watchdog_task);
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001453}
1454
Dhananjay Phadkea97342f2008-07-21 19:44:05 -07001455void netxen_watchdog_task(struct work_struct *work)
1456{
1457 struct netxen_adapter *adapter =
1458 container_of(work, struct netxen_adapter, watchdog_task);
1459
1460 if ((adapter->portnum == 0) && netxen_nic_check_temp(adapter))
1461 return;
1462
1463 netxen_nic_handle_phy_intr(adapter);
1464
Dhananjay Phadke922c4f22008-08-08 00:08:41 -07001465 if (netif_running(adapter->netdev))
1466 mod_timer(&adapter->watchdog_timer, jiffies + 2 * HZ);
Dhananjay Phadkea97342f2008-07-21 19:44:05 -07001467}
1468
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001469static void netxen_tx_timeout(struct net_device *netdev)
1470{
Mithlesh Thukral3176ff32007-04-20 07:52:37 -07001471 struct netxen_adapter *adapter = (struct netxen_adapter *)
1472 netdev_priv(netdev);
1473 SCHEDULE_WORK(&adapter->tx_timeout_task);
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001474}
1475
David Howells6d5aefb2006-12-05 19:36:26 +00001476static void netxen_tx_timeout_task(struct work_struct *work)
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001477{
Jeff Garzik47906542007-11-23 21:23:36 -05001478 struct netxen_adapter *adapter =
Mithlesh Thukral3176ff32007-04-20 07:52:37 -07001479 container_of(work, struct netxen_adapter, tx_timeout_task);
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001480
1481 printk(KERN_ERR "%s %s: transmit timeout, resetting.\n",
Mithlesh Thukral6c80b182007-04-20 07:55:26 -07001482 netxen_nic_driver_name, adapter->netdev->name);
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001483
Dhananjay Phadkeba53e6b2008-03-17 19:59:50 -07001484 netxen_nic_disable_int(adapter);
1485 napi_disable(&adapter->napi);
1486
Mithlesh Thukral6c80b182007-04-20 07:55:26 -07001487 adapter->netdev->trans_start = jiffies;
Dhananjay Phadkeba53e6b2008-03-17 19:59:50 -07001488
1489 napi_enable(&adapter->napi);
1490 netxen_nic_enable_int(adapter);
Mithlesh Thukral6c80b182007-04-20 07:55:26 -07001491 netif_wake_queue(adapter->netdev);
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001492}
1493
Dhananjay Phadkea97342f2008-07-21 19:44:05 -07001494/*
1495 * netxen_nic_get_stats - Get System Network Statistics
1496 * @netdev: network interface device structure
1497 */
1498struct net_device_stats *netxen_nic_get_stats(struct net_device *netdev)
1499{
1500 struct netxen_adapter *adapter = netdev_priv(netdev);
1501 struct net_device_stats *stats = &adapter->net_stats;
1502
1503 memset(stats, 0, sizeof(*stats));
1504
1505 /* total packets received */
1506 stats->rx_packets = adapter->stats.no_rcv;
1507 /* total packets transmitted */
1508 stats->tx_packets = adapter->stats.xmitedframes +
1509 adapter->stats.xmitfinished;
1510 /* total bytes received */
1511 stats->rx_bytes = adapter->stats.rxbytes;
1512 /* total bytes transmitted */
1513 stats->tx_bytes = adapter->stats.txbytes;
1514 /* bad packets received */
1515 stats->rx_errors = adapter->stats.rcvdbadskb;
1516 /* packet transmit problems */
1517 stats->tx_errors = adapter->stats.nocmddescriptor;
1518 /* no space in linux buffers */
1519 stats->rx_dropped = adapter->stats.rxdropped;
1520 /* no space available in linux */
1521 stats->tx_dropped = adapter->stats.txdropped;
1522
1523 return stats;
1524}
1525
Dhananjay Phadkee4c93c82008-07-21 19:44:02 -07001526static irqreturn_t netxen_intr(int irq, void *data)
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001527{
Jeff Garzik1daec862007-10-19 03:14:03 -04001528 struct netxen_adapter *adapter = data;
Dhananjay Phadked71e1be2008-08-01 03:14:57 -07001529 u32 status = 0;
1530
1531 status = adapter->pci_read_immediate(adapter, ISR_INT_VECTOR);
1532
1533 if (!(status & adapter->legacy_intr.int_vec_bit))
Dhananjay Phadke05aaa022008-03-17 19:59:49 -07001534 return IRQ_NONE;
dhananjay@netxen.come01872af2007-07-25 20:13:12 +05301535
Dhananjay Phadked71e1be2008-08-01 03:14:57 -07001536 if (adapter->ahw.revision_id >= NX_P3_B1) {
1537 /* check interrupt state machine, to be sure */
1538 status = adapter->pci_read_immediate(adapter,
1539 ISR_INT_STATE_REG);
1540 if (!ISR_LEGACY_INT_TRIGGERED(status))
1541 return IRQ_NONE;
1542
Dhananjay Phadke092bc572008-08-08 00:08:43 -07001543 } else {
1544 unsigned long our_int = 0;
Dhananjay Phadked71e1be2008-08-01 03:14:57 -07001545
1546 our_int = adapter->pci_read_normalize(adapter, CRB_INT_VECTOR);
Dhananjay Phadke092bc572008-08-08 00:08:43 -07001547
Dhananjay Phadked71e1be2008-08-01 03:14:57 -07001548 /* not our interrupt */
Dhananjay Phadke092bc572008-08-08 00:08:43 -07001549 if (!test_and_clear_bit((7 + adapter->portnum), &our_int))
Dhananjay Phadked71e1be2008-08-01 03:14:57 -07001550 return IRQ_NONE;
1551
Dhananjay Phadke092bc572008-08-08 00:08:43 -07001552 /* claim interrupt */
1553 adapter->pci_write_normalize(adapter,
1554 CRB_INT_VECTOR, (our_int & 0xffffffff));
dhananjay@netxen.come01872af2007-07-25 20:13:12 +05301555 }
1556
Dhananjay Phadke092bc572008-08-08 00:08:43 -07001557 /* clear interrupt */
1558 if (adapter->fw_major < 4)
1559 netxen_nic_disable_int(adapter);
1560
1561 adapter->pci_write_immediate(adapter,
1562 adapter->legacy_intr.tgt_status_reg,
1563 0xffffffff);
1564 /* read twice to ensure write is flushed */
1565 adapter->pci_read_immediate(adapter, ISR_INT_VECTOR);
1566 adapter->pci_read_immediate(adapter, ISR_INT_VECTOR);
1567
1568 napi_schedule(&adapter->napi);
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001569
1570 return IRQ_HANDLED;
1571}
1572
Dhananjay Phadkee4c93c82008-07-21 19:44:02 -07001573static irqreturn_t netxen_msi_intr(int irq, void *data)
Dhananjay Phadke05aaa022008-03-17 19:59:49 -07001574{
1575 struct netxen_adapter *adapter = data;
1576
Dhananjay Phadke092bc572008-08-08 00:08:43 -07001577 /* clear interrupt */
1578 adapter->pci_write_immediate(adapter,
1579 msi_tgt_status[adapter->ahw.pci_func], 0xffffffff);
1580
1581 napi_schedule(&adapter->napi);
Dhananjay Phadke05aaa022008-03-17 19:59:49 -07001582 return IRQ_HANDLED;
1583}
1584
Dhananjay Phadkeb3df68f2009-02-08 19:20:19 -08001585static irqreturn_t netxen_msix_intr(int irq, void *data)
1586{
1587 struct netxen_adapter *adapter = data;
1588
1589 napi_schedule(&adapter->napi);
1590 return IRQ_HANDLED;
1591}
1592
Stephen Hemmingerbea33482007-10-03 16:41:36 -07001593static int netxen_nic_poll(struct napi_struct *napi, int budget)
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001594{
Stephen Hemmingerbea33482007-10-03 16:41:36 -07001595 struct netxen_adapter *adapter = container_of(napi, struct netxen_adapter, napi);
Dhananjay Phadke05aaa022008-03-17 19:59:49 -07001596 int tx_complete;
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001597 int ctx;
Stephen Hemmingerbea33482007-10-03 16:41:36 -07001598 int work_done;
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001599
Dhananjay Phadke05aaa022008-03-17 19:59:49 -07001600 tx_complete = netxen_process_cmd_ring(adapter);
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001601
Amit S. Kale80922fb2006-12-04 09:18:00 -08001602 work_done = 0;
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001603 for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) {
1604 /*
1605 * Fairness issue. This will give undue weight to the
1606 * receive context 0.
1607 */
1608
1609 /*
1610 * To avoid starvation, we give each of our receivers,
1611 * a fraction of the quota. Sometimes, it might happen that we
1612 * have enough quota to process every packet, but since all the
1613 * packets are on one context, it gets only half of the quota,
1614 * and ends up not processing it.
1615 */
Stephen Hemmingerbea33482007-10-03 16:41:36 -07001616 work_done += netxen_process_rcv_ring(adapter, ctx,
1617 budget / MAX_RCV_CTX);
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001618 }
1619
Dhananjay Phadke05aaa022008-03-17 19:59:49 -07001620 if ((work_done < budget) && tx_complete) {
Ben Hutchings288379f2009-01-19 16:43:59 -08001621 napi_complete(&adapter->napi);
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001622 netxen_nic_enable_int(adapter);
1623 }
1624
Stephen Hemmingerbea33482007-10-03 16:41:36 -07001625 return work_done;
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001626}
1627
1628#ifdef CONFIG_NET_POLL_CONTROLLER
1629static void netxen_nic_poll_controller(struct net_device *netdev)
1630{
Mithlesh Thukral3176ff32007-04-20 07:52:37 -07001631 struct netxen_adapter *adapter = netdev_priv(netdev);
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001632 disable_irq(adapter->irq);
Jeff Garzik1494a812006-11-07 05:12:16 -05001633 netxen_intr(adapter->irq, adapter);
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001634 enable_irq(adapter->irq);
1635}
1636#endif
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001637
1638static struct pci_driver netxen_driver = {
1639 .name = netxen_nic_driver_name,
1640 .id_table = netxen_pci_tbl,
1641 .probe = netxen_nic_probe,
1642 .remove = __devexit_p(netxen_nic_remove)
1643};
1644
1645/* Driver Registration on NetXen card */
1646
1647static int __init netxen_init_module(void)
1648{
Al Viro79ea13c2008-01-24 02:06:46 -08001649 if ((netxen_workq = create_singlethread_workqueue("netxen")) == NULL)
Amit S. Kaleed25ffa2006-12-04 09:23:25 -08001650 return -ENOMEM;
1651
Amit S. Kale184231b2007-01-22 06:52:53 -08001652 return pci_register_driver(&netxen_driver);
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001653}
1654
1655module_init(netxen_init_module);
1656
1657static void __exit netxen_exit_module(void)
1658{
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001659 pci_unregister_driver(&netxen_driver);
Amit S. Kale9de06612007-02-21 06:37:06 -08001660 destroy_workqueue(netxen_workq);
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001661}
1662
1663module_exit(netxen_exit_module);