Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2003 - 2006 NetXen, Inc. |
| 3 | * All rights reserved. |
Amit S. Kale | 80922fb | 2006-12-04 09:18:00 -0800 | [diff] [blame] | 4 | * |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 5 | * This program is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU General Public License |
| 7 | * as published by the Free Software Foundation; either version 2 |
| 8 | * of the License, or (at your option) any later version. |
Amit S. Kale | 80922fb | 2006-12-04 09:18:00 -0800 | [diff] [blame] | 9 | * |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 10 | * This program is distributed in the hope that it will be useful, but |
| 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
Amit S. Kale | 80922fb | 2006-12-04 09:18:00 -0800 | [diff] [blame] | 14 | * |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, |
| 18 | * MA 02111-1307, USA. |
Amit S. Kale | 80922fb | 2006-12-04 09:18:00 -0800 | [diff] [blame] | 19 | * |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 20 | * The full GNU General Public License is included in this distribution |
| 21 | * in the file called LICENSE. |
Amit S. Kale | 80922fb | 2006-12-04 09:18:00 -0800 | [diff] [blame] | 22 | * |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 23 | * 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. Kale | cb8011a | 2006-11-29 09:00:10 -0800 | [diff] [blame] | 34 | #include <linux/vmalloc.h> |
Amit S. Kale | ed25ffa | 2006-12-04 09:23:25 -0800 | [diff] [blame] | 35 | #include <linux/highmem.h> |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 36 | #include "netxen_nic_hw.h" |
| 37 | |
| 38 | #include "netxen_nic.h" |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 39 | #include "netxen_nic_phan_reg.h" |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 40 | |
Jeff Garzik | 1494a81 | 2006-11-07 05:12:16 -0500 | [diff] [blame] | 41 | #include <linux/dma-mapping.h> |
| 42 | #include <linux/vmalloc.h> |
Arnaldo Carvalho de Melo | c9bdd4b | 2007-03-12 20:09:15 -0300 | [diff] [blame] | 43 | #include <net/ip.h> |
Jeff Garzik | 1494a81 | 2006-11-07 05:12:16 -0500 | [diff] [blame] | 44 | |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 45 | MODULE_DESCRIPTION("NetXen Multi port (1/10) Gigabit Network Driver"); |
| 46 | MODULE_LICENSE("GPL"); |
| 47 | MODULE_VERSION(NETXEN_NIC_LINUX_VERSIONID); |
| 48 | |
Amit S. Kale | ed25ffa | 2006-12-04 09:23:25 -0800 | [diff] [blame] | 49 | char netxen_nic_driver_name[] = "netxen-nic"; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 50 | static char netxen_nic_driver_string[] = "NetXen Network Driver version " |
Amit S. Kale | cb8011a | 2006-11-29 09:00:10 -0800 | [diff] [blame] | 51 | NETXEN_NIC_LINUX_VERSIONID; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 52 | |
| 53 | #define NETXEN_NETDEV_WEIGHT 120 |
| 54 | #define NETXEN_ADAPTER_UP_MAGIC 777 |
Amit S. Kale | cb8011a | 2006-11-29 09:00:10 -0800 | [diff] [blame] | 55 | #define NETXEN_NIC_PEG_TUNE 0 |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 56 | |
Amit S. Kale | ed25ffa | 2006-12-04 09:23:25 -0800 | [diff] [blame] | 57 | u8 nx_p2_id = NX_P2_C0; |
| 58 | |
| 59 | #define DMA_32BIT_MASK 0x00000000ffffffffULL |
| 60 | #define DMA_35BIT_MASK 0x00000007ffffffffULL |
| 61 | |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 62 | /* Local functions to NetXen NIC driver */ |
| 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 int netxen_nic_xmit_frame(struct sk_buff *, struct net_device *); |
| 69 | static void netxen_tx_timeout(struct net_device *netdev); |
David Howells | 6d5aefb | 2006-12-05 19:36:26 +0000 | [diff] [blame] | 70 | static void netxen_tx_timeout_task(struct work_struct *work); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 71 | static void netxen_watchdog(unsigned long); |
| 72 | static int netxen_handle_int(struct netxen_adapter *, struct net_device *); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 73 | static int netxen_nic_poll(struct net_device *dev, int *budget); |
| 74 | #ifdef CONFIG_NET_POLL_CONTROLLER |
| 75 | static void netxen_nic_poll_controller(struct net_device *netdev); |
| 76 | #endif |
Jeff Garzik | 1494a81 | 2006-11-07 05:12:16 -0500 | [diff] [blame] | 77 | static irqreturn_t netxen_intr(int irq, void *data); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 78 | |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 79 | int physical_port[] = {0, 1, 2, 3}; |
| 80 | |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 81 | /* PCI Device ID Table */ |
| 82 | static struct pci_device_id netxen_pci_tbl[] __devinitdata = { |
| 83 | {PCI_DEVICE(0x4040, 0x0001)}, |
| 84 | {PCI_DEVICE(0x4040, 0x0002)}, |
| 85 | {PCI_DEVICE(0x4040, 0x0003)}, |
| 86 | {PCI_DEVICE(0x4040, 0x0004)}, |
| 87 | {PCI_DEVICE(0x4040, 0x0005)}, |
Amit S. Kale | 0d39073 | 2006-12-18 05:50:59 -0800 | [diff] [blame] | 88 | {PCI_DEVICE(0x4040, 0x0024)}, |
| 89 | {PCI_DEVICE(0x4040, 0x0025)}, |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 90 | {0,} |
| 91 | }; |
| 92 | |
| 93 | MODULE_DEVICE_TABLE(pci, netxen_pci_tbl); |
| 94 | |
Amit S. Kale | ed25ffa | 2006-12-04 09:23:25 -0800 | [diff] [blame] | 95 | struct workqueue_struct *netxen_workq; |
| 96 | static void netxen_watchdog(unsigned long); |
| 97 | |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 98 | static inline void netxen_nic_update_cmd_producer(struct netxen_adapter *adapter, |
| 99 | uint32_t crb_producer) |
| 100 | { |
| 101 | switch (adapter->portnum) { |
| 102 | case 0: |
| 103 | writel(crb_producer, NETXEN_CRB_NORMALIZE |
| 104 | (adapter, CRB_CMD_PRODUCER_OFFSET)); |
| 105 | return; |
| 106 | case 1: |
| 107 | writel(crb_producer, NETXEN_CRB_NORMALIZE |
| 108 | (adapter, CRB_CMD_PRODUCER_OFFSET_1)); |
| 109 | return; |
| 110 | case 2: |
| 111 | writel(crb_producer, NETXEN_CRB_NORMALIZE |
| 112 | (adapter, CRB_CMD_PRODUCER_OFFSET_2)); |
| 113 | return; |
| 114 | case 3: |
| 115 | writel(crb_producer, NETXEN_CRB_NORMALIZE |
| 116 | (adapter, CRB_CMD_PRODUCER_OFFSET_3)); |
| 117 | return; |
| 118 | default: |
| 119 | printk(KERN_WARNING "We tried to update " |
| 120 | "CRB_CMD_PRODUCER_OFFSET for invalid " |
| 121 | "PCI function id %d\n", |
| 122 | adapter->portnum); |
| 123 | return; |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | static inline void netxen_nic_update_cmd_consumer(struct netxen_adapter *adapter, |
| 128 | u32 crb_consumer) |
| 129 | { |
| 130 | switch (adapter->portnum) { |
| 131 | case 0: |
| 132 | writel(crb_consumer, NETXEN_CRB_NORMALIZE |
| 133 | (adapter, CRB_CMD_CONSUMER_OFFSET)); |
| 134 | return; |
| 135 | case 1: |
| 136 | writel(crb_consumer, NETXEN_CRB_NORMALIZE |
| 137 | (adapter, CRB_CMD_CONSUMER_OFFSET_1)); |
| 138 | return; |
| 139 | case 2: |
| 140 | writel(crb_consumer, NETXEN_CRB_NORMALIZE |
| 141 | (adapter, CRB_CMD_CONSUMER_OFFSET_2)); |
| 142 | return; |
| 143 | case 3: |
| 144 | writel(crb_consumer, NETXEN_CRB_NORMALIZE |
| 145 | (adapter, CRB_CMD_CONSUMER_OFFSET_3)); |
| 146 | return; |
| 147 | default: |
| 148 | printk(KERN_WARNING "We tried to update " |
| 149 | "CRB_CMD_PRODUCER_OFFSET for invalid " |
| 150 | "PCI function id %d\n", |
| 151 | adapter->portnum); |
| 152 | return; |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | #define ADAPTER_LIST_SIZE 12 |
| 157 | int netxen_cards_found; |
| 158 | |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 159 | /* |
| 160 | * netxen_nic_probe() |
| 161 | * |
| 162 | * The Linux system will invoke this after identifying the vendor ID and |
| 163 | * device Id in the pci_tbl supported by this module. |
| 164 | * |
| 165 | * A quad port card has one operational PCI config space, (function 0), |
| 166 | * which is used to access all four ports. |
| 167 | * |
| 168 | * This routine will initialize the adapter, and setup the global parameters |
| 169 | * along with the port's specific structure. |
| 170 | */ |
| 171 | static int __devinit |
| 172 | netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) |
| 173 | { |
| 174 | struct net_device *netdev = NULL; |
| 175 | struct netxen_adapter *adapter = NULL; |
Amit S. Kale | ed25ffa | 2006-12-04 09:23:25 -0800 | [diff] [blame] | 176 | void __iomem *mem_ptr0 = NULL; |
| 177 | void __iomem *mem_ptr1 = NULL; |
| 178 | void __iomem *mem_ptr2 = NULL; |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 179 | unsigned long first_page_group_end; |
| 180 | unsigned long first_page_group_start; |
| 181 | |
Amit S. Kale | cb8011a | 2006-11-29 09:00:10 -0800 | [diff] [blame] | 182 | |
Al Viro | a608ab9c | 2007-01-02 10:39:10 +0000 | [diff] [blame] | 183 | u8 __iomem *db_ptr = NULL; |
Amit S. Kale | ed25ffa | 2006-12-04 09:23:25 -0800 | [diff] [blame] | 184 | unsigned long mem_base, mem_len, db_base, db_len; |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 185 | int pci_using_dac, i = 0, err; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 186 | int ring; |
| 187 | struct netxen_recv_context *recv_ctx = NULL; |
| 188 | struct netxen_rcv_desc_ctx *rcv_desc = NULL; |
| 189 | struct netxen_cmd_buffer *cmd_buf_arr = NULL; |
| 190 | u64 mac_addr[FLASH_NUM_PORTS + 1]; |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 191 | int valid_mac = 0; |
| 192 | u32 val; |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 193 | int pci_func_id = PCI_FUNC(pdev->devfn); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 194 | |
Amit S. Kale | cb8011a | 2006-11-29 09:00:10 -0800 | [diff] [blame] | 195 | printk(KERN_INFO "%s \n", netxen_nic_driver_string); |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 196 | |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 197 | if (pdev->class != 0x020000) { |
| 198 | printk(KERN_ERR"NetXen function %d, class %x will not" |
| 199 | "be enabled.\n",pci_func_id, pdev->class); |
Amit S. Kale | ed25ffa | 2006-12-04 09:23:25 -0800 | [diff] [blame] | 200 | return -ENODEV; |
| 201 | } |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 202 | if ((err = pci_enable_device(pdev))) |
| 203 | return err; |
| 204 | if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) { |
| 205 | err = -ENODEV; |
| 206 | goto err_out_disable_pdev; |
| 207 | } |
| 208 | |
| 209 | if ((err = pci_request_regions(pdev, netxen_nic_driver_name))) |
| 210 | goto err_out_disable_pdev; |
| 211 | |
| 212 | pci_set_master(pdev); |
Amit S. Kale | ed25ffa | 2006-12-04 09:23:25 -0800 | [diff] [blame] | 213 | pci_read_config_byte(pdev, PCI_REVISION_ID, &nx_p2_id); |
| 214 | if (nx_p2_id == NX_P2_C1 && |
| 215 | (pci_set_dma_mask(pdev, DMA_35BIT_MASK) == 0) && |
| 216 | (pci_set_consistent_dma_mask(pdev, DMA_35BIT_MASK) == 0)) { |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 217 | pci_using_dac = 1; |
Amit S. Kale | ed25ffa | 2006-12-04 09:23:25 -0800 | [diff] [blame] | 218 | } else { |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 219 | if ((err = pci_set_dma_mask(pdev, DMA_32BIT_MASK)) || |
| 220 | (err = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK))) |
| 221 | goto err_out_free_res; |
| 222 | |
| 223 | pci_using_dac = 0; |
| 224 | } |
| 225 | |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 226 | |
| 227 | netdev = alloc_etherdev(sizeof(struct netxen_adapter)); |
| 228 | if(!netdev) { |
| 229 | printk(KERN_ERR"%s: Failed to allocate memory for the " |
| 230 | "device block.Check system memory resource" |
| 231 | " usage.\n", netxen_nic_driver_name); |
| 232 | goto err_out_free_res; |
| 233 | } |
| 234 | |
| 235 | SET_MODULE_OWNER(netdev); |
| 236 | SET_NETDEV_DEV(netdev, &pdev->dev); |
| 237 | |
| 238 | adapter = netdev->priv; |
| 239 | memset(adapter, 0 , sizeof(struct netxen_adapter)); |
| 240 | |
| 241 | adapter->ahw.pdev = pdev; |
Mithlesh Thukral | 13ba9c7 | 2007-04-20 07:53:05 -0700 | [diff] [blame] | 242 | adapter->ahw.pci_func = pci_func_id; |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 243 | spin_lock_init(&adapter->tx_lock); |
| 244 | spin_lock_init(&adapter->lock); |
Mithlesh Thukral | 13ba9c7 | 2007-04-20 07:53:05 -0700 | [diff] [blame] | 245 | |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 246 | /* remap phys address */ |
| 247 | mem_base = pci_resource_start(pdev, 0); /* 0 is for BAR 0 */ |
| 248 | mem_len = pci_resource_len(pdev, 0); |
| 249 | |
| 250 | /* 128 Meg of memory */ |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 251 | if (mem_len == NETXEN_PCI_128MB_SIZE) { |
| 252 | mem_ptr0 = ioremap(mem_base, FIRST_PAGE_GROUP_SIZE); |
| 253 | mem_ptr1 = ioremap(mem_base + SECOND_PAGE_GROUP_START, |
| 254 | SECOND_PAGE_GROUP_SIZE); |
| 255 | mem_ptr2 = ioremap(mem_base + THIRD_PAGE_GROUP_START, |
| 256 | THIRD_PAGE_GROUP_SIZE); |
| 257 | first_page_group_start = FIRST_PAGE_GROUP_START; |
| 258 | first_page_group_end = FIRST_PAGE_GROUP_END; |
| 259 | } else if (mem_len == NETXEN_PCI_32MB_SIZE) { |
| 260 | mem_ptr1 = ioremap(mem_base, SECOND_PAGE_GROUP_SIZE); |
| 261 | mem_ptr2 = ioremap(mem_base + THIRD_PAGE_GROUP_START - |
| 262 | SECOND_PAGE_GROUP_START, THIRD_PAGE_GROUP_SIZE); |
| 263 | first_page_group_start = 0; |
| 264 | first_page_group_end = 0; |
| 265 | } else { |
| 266 | err = -EIO; |
| 267 | goto err_out_free_netdev; |
| 268 | } |
Amit S. Kale | cb8011a | 2006-11-29 09:00:10 -0800 | [diff] [blame] | 269 | |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 270 | if (((mem_ptr0 == 0UL) && (mem_len == NETXEN_PCI_128MB_SIZE)) || |
| 271 | (mem_ptr1 == 0UL) || (mem_ptr2 == 0UL)) { |
Amit S. Kale | ed25ffa | 2006-12-04 09:23:25 -0800 | [diff] [blame] | 272 | DPRINTK(ERR, |
Amit S. Kale | cb8011a | 2006-11-29 09:00:10 -0800 | [diff] [blame] | 273 | "Cannot remap adapter memory aborting.:" |
| 274 | "0 -> %p, 1 -> %p, 2 -> %p\n", |
| 275 | mem_ptr0, mem_ptr1, mem_ptr2); |
| 276 | |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 277 | err = -EIO; |
Amit S. Kale | ed25ffa | 2006-12-04 09:23:25 -0800 | [diff] [blame] | 278 | goto err_out_iounmap; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 279 | } |
Amit S. Kale | ed25ffa | 2006-12-04 09:23:25 -0800 | [diff] [blame] | 280 | db_base = pci_resource_start(pdev, 4); /* doorbell is on bar 4 */ |
| 281 | db_len = pci_resource_len(pdev, 4); |
| 282 | |
| 283 | if (db_len == 0) { |
| 284 | printk(KERN_ERR "%s: doorbell is disabled\n", |
| 285 | netxen_nic_driver_name); |
| 286 | err = -EIO; |
| 287 | goto err_out_iounmap; |
| 288 | } |
| 289 | DPRINTK(INFO, "doorbell ioremap from %lx a size of %lx\n", db_base, |
| 290 | db_len); |
| 291 | |
| 292 | db_ptr = ioremap(db_base, NETXEN_DB_MAPSIZE_BYTES); |
Al Viro | a608ab9c | 2007-01-02 10:39:10 +0000 | [diff] [blame] | 293 | if (!db_ptr) { |
Amit S. Kale | ed25ffa | 2006-12-04 09:23:25 -0800 | [diff] [blame] | 294 | printk(KERN_ERR "%s: Failed to allocate doorbell map.", |
| 295 | netxen_nic_driver_name); |
| 296 | err = -EIO; |
| 297 | goto err_out_iounmap; |
| 298 | } |
| 299 | DPRINTK(INFO, "doorbell ioremaped at %p\n", db_ptr); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 300 | |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 301 | adapter->ahw.pci_base0 = mem_ptr0; |
| 302 | adapter->ahw.first_page_group_start = first_page_group_start; |
| 303 | adapter->ahw.first_page_group_end = first_page_group_end; |
| 304 | adapter->ahw.pci_base1 = mem_ptr1; |
| 305 | adapter->ahw.pci_base2 = mem_ptr2; |
| 306 | adapter->ahw.db_base = db_ptr; |
| 307 | adapter->ahw.db_len = db_len; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 308 | |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 309 | adapter->netdev = netdev; |
| 310 | adapter->pdev = pdev; |
| 311 | adapter->portnum = pci_func_id; |
| 312 | |
| 313 | netdev->open = netxen_nic_open; |
| 314 | netdev->stop = netxen_nic_close; |
| 315 | netdev->hard_start_xmit = netxen_nic_xmit_frame; |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 316 | netdev->get_stats = netxen_nic_get_stats; |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 317 | netdev->set_multicast_list = netxen_nic_set_multi; |
| 318 | netdev->set_mac_address = netxen_nic_set_mac; |
| 319 | netdev->change_mtu = netxen_nic_change_mtu; |
| 320 | netdev->tx_timeout = netxen_tx_timeout; |
| 321 | netdev->watchdog_timeo = HZ; |
| 322 | |
| 323 | netxen_nic_change_mtu(netdev, netdev->mtu); |
| 324 | |
| 325 | SET_ETHTOOL_OPS(netdev, &netxen_nic_ethtool_ops); |
| 326 | netdev->poll = netxen_nic_poll; |
| 327 | netdev->weight = NETXEN_NETDEV_WEIGHT; |
| 328 | #ifdef CONFIG_NET_POLL_CONTROLLER |
| 329 | netdev->poll_controller = netxen_nic_poll_controller; |
| 330 | #endif |
| 331 | /* ScatterGather support */ |
| 332 | netdev->features = NETIF_F_SG; |
| 333 | netdev->features |= NETIF_F_IP_CSUM; |
| 334 | netdev->features |= NETIF_F_TSO; |
| 335 | |
| 336 | if (pci_using_dac) |
| 337 | netdev->features |= NETIF_F_HIGHDMA; |
| 338 | |
dhananjay.phadke@gmail.com | 644caee | 2007-07-02 00:25:59 +0530 | [diff] [blame^] | 339 | if (pci_enable_msi(pdev)) |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 340 | adapter->flags &= ~NETXEN_NIC_MSI_ENABLED; |
dhananjay.phadke@gmail.com | 644caee | 2007-07-02 00:25:59 +0530 | [diff] [blame^] | 341 | else |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 342 | adapter->flags |= NETXEN_NIC_MSI_ENABLED; |
| 343 | |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 344 | netdev->irq = pdev->irq; |
| 345 | INIT_WORK(&adapter->tx_timeout_task, netxen_tx_timeout_task); |
| 346 | |
| 347 | /* |
| 348 | * Set the CRB window to invalid. If any register in window 0 is |
| 349 | * accessed it should set the window to 0 and then reset it to 1. |
| 350 | */ |
| 351 | adapter->curr_window = 255; |
| 352 | |
| 353 | /* initialize the adapter */ |
| 354 | netxen_initialize_adapter_hw(adapter); |
| 355 | |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 356 | /* |
| 357 | * Adapter in our case is quad port so initialize it before |
| 358 | * initializing the ports |
| 359 | */ |
| 360 | |
| 361 | netxen_initialize_adapter_ops(adapter); |
| 362 | |
| 363 | adapter->max_tx_desc_count = MAX_CMD_DESCRIPTORS_HOST; |
| 364 | if ((adapter->ahw.boardcfg.board_type == NETXEN_BRDTYPE_P2_SB35_4G) || |
| 365 | (adapter->ahw.boardcfg.board_type == |
| 366 | NETXEN_BRDTYPE_P2_SB31_2G)) |
| 367 | adapter->max_rx_desc_count = MAX_RCV_DESCRIPTORS_1G; |
| 368 | else |
| 369 | adapter->max_rx_desc_count = MAX_RCV_DESCRIPTORS; |
| 370 | adapter->max_jumbo_rx_desc_count = MAX_JUMBO_RCV_DESCRIPTORS; |
| 371 | adapter->max_lro_rx_desc_count = MAX_LRO_RCV_DESCRIPTORS; |
| 372 | |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 373 | cmd_buf_arr = (struct netxen_cmd_buffer *)vmalloc(TX_RINGSIZE); |
| 374 | if (cmd_buf_arr == NULL) { |
Amit S. Kale | ed25ffa | 2006-12-04 09:23:25 -0800 | [diff] [blame] | 375 | printk(KERN_ERR |
| 376 | "%s: Could not allocate cmd_buf_arr memory:%d\n", |
| 377 | netxen_nic_driver_name, (int)TX_RINGSIZE); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 378 | err = -ENOMEM; |
| 379 | goto err_out_free_adapter; |
| 380 | } |
| 381 | memset(cmd_buf_arr, 0, TX_RINGSIZE); |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 382 | adapter->cmd_buf_arr = cmd_buf_arr; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 383 | |
| 384 | for (i = 0; i < MAX_RCV_CTX; ++i) { |
| 385 | recv_ctx = &adapter->recv_ctx[i]; |
| 386 | for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) { |
| 387 | rcv_desc = &recv_ctx->rcv_desc[ring]; |
| 388 | switch (RCV_DESC_TYPE(ring)) { |
| 389 | case RCV_DESC_NORMAL: |
| 390 | rcv_desc->max_rx_desc_count = |
| 391 | adapter->max_rx_desc_count; |
| 392 | rcv_desc->flags = RCV_DESC_NORMAL; |
| 393 | rcv_desc->dma_size = RX_DMA_MAP_LEN; |
| 394 | rcv_desc->skb_size = MAX_RX_BUFFER_LENGTH; |
| 395 | break; |
| 396 | |
| 397 | case RCV_DESC_JUMBO: |
| 398 | rcv_desc->max_rx_desc_count = |
| 399 | adapter->max_jumbo_rx_desc_count; |
| 400 | rcv_desc->flags = RCV_DESC_JUMBO; |
| 401 | rcv_desc->dma_size = RX_JUMBO_DMA_MAP_LEN; |
| 402 | rcv_desc->skb_size = MAX_RX_JUMBO_BUFFER_LENGTH; |
| 403 | break; |
| 404 | |
Amit S. Kale | ed25ffa | 2006-12-04 09:23:25 -0800 | [diff] [blame] | 405 | case RCV_RING_LRO: |
| 406 | rcv_desc->max_rx_desc_count = |
| 407 | adapter->max_lro_rx_desc_count; |
| 408 | rcv_desc->flags = RCV_DESC_LRO; |
| 409 | rcv_desc->dma_size = RX_LRO_DMA_MAP_LEN; |
| 410 | rcv_desc->skb_size = MAX_RX_LRO_BUFFER_LENGTH; |
| 411 | break; |
| 412 | |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 413 | } |
| 414 | rcv_desc->rx_buf_arr = (struct netxen_rx_buffer *) |
| 415 | vmalloc(RCV_BUFFSIZE); |
| 416 | |
| 417 | if (rcv_desc->rx_buf_arr == NULL) { |
Amit S. Kale | ed25ffa | 2006-12-04 09:23:25 -0800 | [diff] [blame] | 418 | printk(KERN_ERR "%s: Could not allocate" |
| 419 | "rcv_desc->rx_buf_arr memory:%d\n", |
| 420 | netxen_nic_driver_name, |
| 421 | (int)RCV_BUFFSIZE); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 422 | err = -ENOMEM; |
| 423 | goto err_out_free_rx_buffer; |
| 424 | } |
| 425 | memset(rcv_desc->rx_buf_arr, 0, RCV_BUFFSIZE); |
| 426 | } |
| 427 | |
| 428 | } |
| 429 | |
Amit S. Kale | ed25ffa | 2006-12-04 09:23:25 -0800 | [diff] [blame] | 430 | netxen_initialize_adapter_sw(adapter); /* initialize the buffers in adapter */ |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 431 | |
Mithlesh Thukral | 13ba9c7 | 2007-04-20 07:53:05 -0700 | [diff] [blame] | 432 | /* Mezz cards have PCI function 0,2,3 enabled */ |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 433 | if ((adapter->ahw.boardcfg.board_type == NETXEN_BRDTYPE_P2_SB31_10G_IMEZ) |
| 434 | && (pci_func_id >= 2)) |
Mithlesh Thukral | 13ba9c7 | 2007-04-20 07:53:05 -0700 | [diff] [blame] | 435 | adapter->portnum = pci_func_id - 2; |
| 436 | |
Amit S. Kale | cb8011a | 2006-11-29 09:00:10 -0800 | [diff] [blame] | 437 | #ifdef CONFIG_IA64 |
Mithlesh Thukral | 13ba9c7 | 2007-04-20 07:53:05 -0700 | [diff] [blame] | 438 | if(adapter->portnum == 0) { |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 439 | netxen_pinit_from_rom(adapter, 0); |
| 440 | udelay(500); |
| 441 | netxen_load_firmware(adapter); |
| 442 | } |
Amit S. Kale | cb8011a | 2006-11-29 09:00:10 -0800 | [diff] [blame] | 443 | #endif |
| 444 | |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 445 | init_timer(&adapter->watchdog_timer); |
| 446 | adapter->ahw.xg_linkup = 0; |
| 447 | adapter->watchdog_timer.function = &netxen_watchdog; |
| 448 | adapter->watchdog_timer.data = (unsigned long)adapter; |
David Howells | 6d5aefb | 2006-12-05 19:36:26 +0000 | [diff] [blame] | 449 | INIT_WORK(&adapter->watchdog_task, netxen_watchdog_task); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 450 | adapter->ahw.pdev = pdev; |
| 451 | adapter->proc_cmd_buf_counter = 0; |
Amit S. Kale | ed25ffa | 2006-12-04 09:23:25 -0800 | [diff] [blame] | 452 | adapter->ahw.revision_id = nx_p2_id; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 453 | |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 454 | /* make sure Window == 1 */ |
| 455 | netxen_nic_pci_change_crbwindow(adapter, 1); |
| 456 | |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 457 | netxen_nic_update_cmd_producer(adapter, 0); |
| 458 | netxen_nic_update_cmd_consumer(adapter, 0); |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 459 | writel(0, NETXEN_CRB_NORMALIZE(adapter, CRB_HOST_CMD_ADDR_LO)); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 460 | |
| 461 | if (netxen_is_flash_supported(adapter) == 0 && |
| 462 | netxen_get_flash_mac_addr(adapter, mac_addr) == 0) |
| 463 | valid_mac = 1; |
| 464 | else |
| 465 | valid_mac = 0; |
| 466 | |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 467 | if (valid_mac) { |
Mithlesh Thukral | 13ba9c7 | 2007-04-20 07:53:05 -0700 | [diff] [blame] | 468 | unsigned char *p = (unsigned char *)&mac_addr[adapter->portnum]; |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 469 | netdev->dev_addr[0] = *(p + 5); |
| 470 | netdev->dev_addr[1] = *(p + 4); |
| 471 | netdev->dev_addr[2] = *(p + 3); |
| 472 | netdev->dev_addr[3] = *(p + 2); |
| 473 | netdev->dev_addr[4] = *(p + 1); |
| 474 | netdev->dev_addr[5] = *(p + 0); |
| 475 | |
| 476 | memcpy(netdev->perm_addr, netdev->dev_addr, |
| 477 | netdev->addr_len); |
| 478 | if (!is_valid_ether_addr(netdev->perm_addr)) { |
| 479 | printk(KERN_ERR "%s: Bad MAC address " |
| 480 | "%02x:%02x:%02x:%02x:%02x:%02x.\n", |
| 481 | netxen_nic_driver_name, |
| 482 | netdev->dev_addr[0], |
| 483 | netdev->dev_addr[1], |
| 484 | netdev->dev_addr[2], |
| 485 | netdev->dev_addr[3], |
| 486 | netdev->dev_addr[4], |
| 487 | netdev->dev_addr[5]); |
| 488 | } else { |
| 489 | if (adapter->macaddr_set) |
| 490 | adapter->macaddr_set(adapter, |
| 491 | netdev->dev_addr); |
| 492 | } |
| 493 | } |
| 494 | |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 495 | if (adapter->portnum == 0) { |
Mithlesh Thukral | 13ba9c7 | 2007-04-20 07:53:05 -0700 | [diff] [blame] | 496 | err = netxen_initialize_adapter_offload(adapter); |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 497 | if (err) |
| 498 | goto err_out_free_rx_buffer; |
| 499 | val = readl(NETXEN_CRB_NORMALIZE(adapter, |
| 500 | NETXEN_CAM_RAM(0x1fc))); |
| 501 | if (val == 0x55555555) { |
| 502 | /* This is the first boot after power up */ |
dhananjay.phadke@gmail.com | 644caee | 2007-07-02 00:25:59 +0530 | [diff] [blame^] | 503 | netxen_nic_read_w0(adapter, NETXEN_PCIE_REG(0x4), &val); |
| 504 | if (!(val & 0x4)) { |
| 505 | val |= 0x4; |
| 506 | netxen_nic_write_w0(adapter, NETXEN_PCIE_REG(0x4), val); |
| 507 | netxen_nic_read_w0(adapter, NETXEN_PCIE_REG(0x4), &val); |
| 508 | } |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 509 | val = readl(NETXEN_CRB_NORMALIZE(adapter, |
| 510 | NETXEN_ROMUSB_GLB_SW_RESET)); |
| 511 | printk(KERN_INFO"NetXen: read 0x%08x for reset reg.\n",val); |
| 512 | if (val != 0x80000f) { |
| 513 | /* clear the register for future unloads/loads */ |
dhananjay.phadke@gmail.com | 644caee | 2007-07-02 00:25:59 +0530 | [diff] [blame^] | 514 | writel(0, NETXEN_CRB_NORMALIZE(adapter, |
| 515 | NETXEN_CAM_RAM(0x1fc))); |
| 516 | printk(KERN_ERR "ERROR in NetXen HW init sequence.\n"); |
| 517 | err = -ENODEV; |
| 518 | goto err_out_free_dev; |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 519 | } |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 520 | |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 521 | /* clear the register for future unloads/loads */ |
| 522 | writel(0, NETXEN_CRB_NORMALIZE(adapter, |
| 523 | NETXEN_CAM_RAM(0x1fc))); |
| 524 | } |
| 525 | printk(KERN_INFO "State: 0x%0x\n", |
| 526 | readl(NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE))); |
| 527 | |
| 528 | /* |
| 529 | * Tell the hardware our version number. |
| 530 | */ |
| 531 | i = (_NETXEN_NIC_LINUX_MAJOR << 16) |
| 532 | | ((_NETXEN_NIC_LINUX_MINOR << 8)) |
| 533 | | (_NETXEN_NIC_LINUX_SUBVERSION); |
| 534 | writel(i, NETXEN_CRB_NORMALIZE(adapter, CRB_DRIVER_VERSION)); |
| 535 | |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 536 | /* Unlock the HW, prompting the boot sequence */ |
| 537 | writel(1, |
| 538 | NETXEN_CRB_NORMALIZE(adapter, |
| 539 | NETXEN_ROMUSB_GLB_PEGTUNE_DONE)); |
| 540 | /* Handshake with the card before we register the devices. */ |
| 541 | netxen_phantom_init(adapter, NETXEN_NIC_PEG_TUNE); |
Mithlesh Thukral | 3e2face | 2007-06-07 04:33:02 -0700 | [diff] [blame] | 542 | |
| 543 | /* leave the hw in the same state as reboot */ |
| 544 | writel(0, NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE)); |
| 545 | netxen_pinit_from_rom(adapter, 0); |
| 546 | udelay(500); |
| 547 | netxen_load_firmware(adapter); |
| 548 | netxen_phantom_init(adapter, NETXEN_NIC_PEG_TUNE); |
Amit S. Kale | ed25ffa | 2006-12-04 09:23:25 -0800 | [diff] [blame] | 549 | } |
| 550 | |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 551 | /* |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 552 | * See if the firmware gave us a virtual-physical port mapping. |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 553 | */ |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 554 | i = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_V2P(adapter->portnum))); |
| 555 | if (i != 0x55555555) |
| 556 | physical_port[adapter->portnum] = i; |
| 557 | |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 558 | netif_carrier_off(netdev); |
| 559 | netif_stop_queue(netdev); |
| 560 | |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 561 | if ((err = register_netdev(netdev))) { |
| 562 | printk(KERN_ERR "%s: register_netdev failed port #%d" |
| 563 | " aborting\n", netxen_nic_driver_name, |
| 564 | adapter->portnum); |
| 565 | err = -EIO; |
| 566 | goto err_out_free_dev; |
| 567 | } |
| 568 | |
| 569 | pci_set_drvdata(pdev, adapter); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 570 | |
| 571 | switch (adapter->ahw.board_type) { |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 572 | case NETXEN_NIC_GBE: |
| 573 | printk(KERN_INFO "%s: QUAD GbE board initialized\n", |
| 574 | netxen_nic_driver_name); |
| 575 | break; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 576 | |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 577 | case NETXEN_NIC_XGBE: |
| 578 | printk(KERN_INFO "%s: XGbE board initialized\n", |
| 579 | netxen_nic_driver_name); |
| 580 | break; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 581 | } |
| 582 | |
| 583 | adapter->driver_mismatch = 0; |
| 584 | |
| 585 | return 0; |
| 586 | |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 587 | err_out_free_dev: |
| 588 | if (adapter->portnum == 0) |
| 589 | netxen_free_adapter_offload(adapter); |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 590 | |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 591 | err_out_free_rx_buffer: |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 592 | for (i = 0; i < MAX_RCV_CTX; ++i) { |
| 593 | recv_ctx = &adapter->recv_ctx[i]; |
| 594 | for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) { |
| 595 | rcv_desc = &recv_ctx->rcv_desc[ring]; |
| 596 | if (rcv_desc->rx_buf_arr != NULL) { |
| 597 | vfree(rcv_desc->rx_buf_arr); |
| 598 | rcv_desc->rx_buf_arr = NULL; |
| 599 | } |
| 600 | } |
| 601 | } |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 602 | vfree(cmd_buf_arr); |
| 603 | |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 604 | err_out_free_adapter: |
| 605 | if (adapter->flags & NETXEN_NIC_MSI_ENABLED) |
| 606 | pci_disable_msi(pdev); |
| 607 | |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 608 | pci_set_drvdata(pdev, NULL); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 609 | |
Amit S. Kale | ed25ffa | 2006-12-04 09:23:25 -0800 | [diff] [blame] | 610 | if (db_ptr) |
| 611 | iounmap(db_ptr); |
| 612 | |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 613 | err_out_iounmap: |
Amit S. Kale | ed25ffa | 2006-12-04 09:23:25 -0800 | [diff] [blame] | 614 | if (mem_ptr0) |
| 615 | iounmap(mem_ptr0); |
| 616 | if (mem_ptr1) |
| 617 | iounmap(mem_ptr1); |
| 618 | if (mem_ptr2) |
| 619 | iounmap(mem_ptr2); |
Amit S. Kale | cb8011a | 2006-11-29 09:00:10 -0800 | [diff] [blame] | 620 | |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 621 | err_out_free_netdev: |
| 622 | free_netdev(netdev); |
| 623 | |
| 624 | err_out_free_res: |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 625 | pci_release_regions(pdev); |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 626 | |
| 627 | err_out_disable_pdev: |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 628 | pci_disable_device(pdev); |
| 629 | return err; |
| 630 | } |
| 631 | |
| 632 | static void __devexit netxen_nic_remove(struct pci_dev *pdev) |
| 633 | { |
| 634 | struct netxen_adapter *adapter; |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 635 | struct net_device *netdev; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 636 | struct netxen_rx_buffer *buffer; |
| 637 | struct netxen_recv_context *recv_ctx; |
| 638 | struct netxen_rcv_desc_ctx *rcv_desc; |
| 639 | int i; |
| 640 | int ctxid, ring; |
| 641 | |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 642 | adapter = pci_get_drvdata(pdev); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 643 | if (adapter == NULL) |
| 644 | return; |
| 645 | |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 646 | netdev = adapter->netdev; |
| 647 | |
| 648 | netxen_nic_disable_int(adapter); |
| 649 | if (adapter->irq) |
| 650 | free_irq(adapter->irq, adapter); |
| 651 | |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 652 | if (adapter->stop_port) |
| 653 | adapter->stop_port(adapter); |
| 654 | |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 655 | if ((adapter->flags & NETXEN_NIC_MSI_ENABLED)) |
| 656 | pci_disable_msi(pdev); |
| 657 | |
| 658 | if (adapter->portnum == 0) |
| 659 | netxen_free_adapter_offload(adapter); |
| 660 | |
Mithlesh Thukral | 595e3fb | 2007-04-20 07:53:52 -0700 | [diff] [blame] | 661 | if(adapter->portnum == 0) { |
| 662 | /* leave the hw in the same state as reboot */ |
| 663 | writel(0, NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE)); |
| 664 | netxen_pinit_from_rom(adapter, 0); |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 665 | udelay(500); |
Mithlesh Thukral | 595e3fb | 2007-04-20 07:53:52 -0700 | [diff] [blame] | 666 | netxen_load_firmware(adapter); |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 667 | netxen_phantom_init(adapter, NETXEN_NIC_PEG_TUNE); |
Mithlesh Thukral | 595e3fb | 2007-04-20 07:53:52 -0700 | [diff] [blame] | 668 | } |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 669 | |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 670 | if (adapter->is_up == NETXEN_ADAPTER_UP_MAGIC) |
| 671 | netxen_free_hw_resources(adapter); |
| 672 | |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 673 | for (ctxid = 0; ctxid < MAX_RCV_CTX; ++ctxid) { |
| 674 | recv_ctx = &adapter->recv_ctx[ctxid]; |
| 675 | for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) { |
| 676 | rcv_desc = &recv_ctx->rcv_desc[ring]; |
| 677 | for (i = 0; i < rcv_desc->max_rx_desc_count; ++i) { |
| 678 | buffer = &(rcv_desc->rx_buf_arr[i]); |
| 679 | if (buffer->state == NETXEN_BUFFER_FREE) |
| 680 | continue; |
| 681 | pci_unmap_single(pdev, buffer->dma, |
| 682 | rcv_desc->dma_size, |
| 683 | PCI_DMA_FROMDEVICE); |
| 684 | if (buffer->skb != NULL) |
| 685 | dev_kfree_skb_any(buffer->skb); |
| 686 | } |
| 687 | vfree(rcv_desc->rx_buf_arr); |
| 688 | } |
| 689 | } |
| 690 | |
Mithlesh Thukral | 595e3fb | 2007-04-20 07:53:52 -0700 | [diff] [blame] | 691 | unregister_netdev(netdev); |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 692 | |
| 693 | vfree(adapter->cmd_buf_arr); |
| 694 | |
| 695 | iounmap(adapter->ahw.db_base); |
| 696 | iounmap(adapter->ahw.pci_base0); |
| 697 | iounmap(adapter->ahw.pci_base1); |
| 698 | iounmap(adapter->ahw.pci_base2); |
Mithlesh Thukral | 595e3fb | 2007-04-20 07:53:52 -0700 | [diff] [blame] | 699 | |
| 700 | pci_release_regions(pdev); |
| 701 | pci_disable_device(pdev); |
| 702 | pci_set_drvdata(pdev, NULL); |
| 703 | |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 704 | free_netdev(netdev); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 705 | } |
| 706 | |
| 707 | /* |
| 708 | * Called when a network interface is made active |
| 709 | * @returns 0 on success, negative value on failure |
| 710 | */ |
| 711 | static int netxen_nic_open(struct net_device *netdev) |
| 712 | { |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 713 | struct netxen_adapter *adapter = (struct netxen_adapter *)netdev->priv; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 714 | int err = 0; |
| 715 | int ctx, ring; |
| 716 | |
| 717 | if (adapter->is_up != NETXEN_ADAPTER_UP_MAGIC) { |
| 718 | err = netxen_init_firmware(adapter); |
| 719 | if (err != 0) { |
| 720 | printk(KERN_ERR "Failed to init firmware\n"); |
| 721 | return -EIO; |
| 722 | } |
| 723 | netxen_nic_flash_print(adapter); |
| 724 | |
| 725 | /* setup all the resources for the Phantom... */ |
| 726 | /* this include the descriptors for rcv, tx, and status */ |
| 727 | netxen_nic_clear_stats(adapter); |
| 728 | err = netxen_nic_hw_resources(adapter); |
| 729 | if (err) { |
| 730 | printk(KERN_ERR "Error in setting hw resources:%d\n", |
| 731 | err); |
| 732 | return err; |
| 733 | } |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 734 | for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) { |
Amit S. Kale | cb8011a | 2006-11-29 09:00:10 -0800 | [diff] [blame] | 735 | for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 736 | netxen_post_rx_buffers(adapter, ctx, ring); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 737 | } |
Amit S. Kale | ed25ffa | 2006-12-04 09:23:25 -0800 | [diff] [blame] | 738 | adapter->irq = adapter->ahw.pdev->irq; |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 739 | err = request_irq(adapter->ahw.pdev->irq, netxen_intr, |
Andrew Morton | 1c8e039 | 2007-05-10 22:53:00 -0700 | [diff] [blame] | 740 | IRQF_SHARED|IRQF_SAMPLE_RANDOM, netdev->name, |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 741 | adapter); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 742 | if (err) { |
| 743 | printk(KERN_ERR "request_irq failed with: %d\n", err); |
Amit S. Kale | ed25ffa | 2006-12-04 09:23:25 -0800 | [diff] [blame] | 744 | netxen_free_hw_resources(adapter); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 745 | return err; |
| 746 | } |
Amit S. Kale | ed25ffa | 2006-12-04 09:23:25 -0800 | [diff] [blame] | 747 | |
| 748 | adapter->is_up = NETXEN_ADAPTER_UP_MAGIC; |
| 749 | } |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 750 | if (!adapter->driver_mismatch) |
| 751 | mod_timer(&adapter->watchdog_timer, jiffies); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 752 | |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 753 | netxen_nic_enable_int(adapter); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 754 | |
| 755 | /* Done here again so that even if phantom sw overwrote it, |
| 756 | * we set it */ |
Amit S. Kale | 80922fb | 2006-12-04 09:18:00 -0800 | [diff] [blame] | 757 | if (adapter->macaddr_set) |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 758 | adapter->macaddr_set(adapter, netdev->dev_addr); |
Mithlesh Thukral | 595e3fb | 2007-04-20 07:53:52 -0700 | [diff] [blame] | 759 | if (adapter->init_port |
| 760 | && adapter->init_port(adapter, adapter->portnum) != 0) { |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 761 | del_timer_sync(&adapter->watchdog_timer); |
Mithlesh Thukral | 595e3fb | 2007-04-20 07:53:52 -0700 | [diff] [blame] | 762 | printk(KERN_ERR "%s: Failed to initialize port %d\n", |
| 763 | netxen_nic_driver_name, adapter->portnum); |
Mithlesh Thukral | 595e3fb | 2007-04-20 07:53:52 -0700 | [diff] [blame] | 764 | return -EIO; |
| 765 | } |
| 766 | |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 767 | netxen_nic_set_link_parameters(adapter); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 768 | |
| 769 | netxen_nic_set_multi(netdev); |
Amit S. Kale | ed25ffa | 2006-12-04 09:23:25 -0800 | [diff] [blame] | 770 | if (adapter->set_mtu) |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 771 | adapter->set_mtu(adapter, netdev->mtu); |
Amit S. Kale | ed25ffa | 2006-12-04 09:23:25 -0800 | [diff] [blame] | 772 | |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 773 | if (!adapter->driver_mismatch) |
| 774 | netif_start_queue(netdev); |
| 775 | |
| 776 | return 0; |
| 777 | } |
| 778 | |
| 779 | /* |
| 780 | * netxen_nic_close - Disables a network interface entry point |
| 781 | */ |
| 782 | static int netxen_nic_close(struct net_device *netdev) |
| 783 | { |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 784 | struct netxen_adapter *adapter = netdev_priv(netdev); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 785 | int i, j; |
| 786 | struct netxen_cmd_buffer *cmd_buff; |
| 787 | struct netxen_skb_frag *buffrag; |
| 788 | |
| 789 | netif_carrier_off(netdev); |
| 790 | netif_stop_queue(netdev); |
| 791 | |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 792 | cmd_buff = adapter->cmd_buf_arr; |
| 793 | for (i = 0; i < adapter->max_tx_desc_count; i++) { |
| 794 | buffrag = cmd_buff->frag_array; |
| 795 | if (buffrag->dma) { |
| 796 | pci_unmap_single(adapter->pdev, buffrag->dma, |
| 797 | buffrag->length, PCI_DMA_TODEVICE); |
| 798 | buffrag->dma = (u64) NULL; |
| 799 | } |
| 800 | for (j = 0; j < cmd_buff->frag_count; j++) { |
| 801 | buffrag++; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 802 | if (buffrag->dma) { |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 803 | pci_unmap_page(adapter->pdev, buffrag->dma, |
| 804 | buffrag->length, |
| 805 | PCI_DMA_TODEVICE); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 806 | buffrag->dma = (u64) NULL; |
| 807 | } |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 808 | } |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 809 | /* Free the skb we received in netxen_nic_xmit_frame */ |
| 810 | if (cmd_buff->skb) { |
| 811 | dev_kfree_skb_any(cmd_buff->skb); |
| 812 | cmd_buff->skb = NULL; |
| 813 | } |
| 814 | cmd_buff++; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 815 | } |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 816 | FLUSH_SCHEDULED_WORK(); |
| 817 | del_timer_sync(&adapter->watchdog_timer); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 818 | |
| 819 | return 0; |
| 820 | } |
| 821 | |
| 822 | static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev) |
| 823 | { |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 824 | struct netxen_adapter *adapter = netdev_priv(netdev); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 825 | struct netxen_hardware_context *hw = &adapter->ahw; |
| 826 | unsigned int first_seg_len = skb->len - skb->data_len; |
| 827 | struct netxen_skb_frag *buffrag; |
| 828 | unsigned int i; |
| 829 | |
| 830 | u32 producer = 0; |
| 831 | u32 saved_producer = 0; |
| 832 | struct cmd_desc_type0 *hwdesc; |
| 833 | int k; |
| 834 | struct netxen_cmd_buffer *pbuf = NULL; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 835 | static int dropped_packet = 0; |
| 836 | int frag_count; |
| 837 | u32 local_producer = 0; |
| 838 | u32 max_tx_desc_count = 0; |
| 839 | u32 last_cmd_consumer = 0; |
| 840 | int no_of_desc; |
| 841 | |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 842 | adapter->stats.xmitcalled++; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 843 | frag_count = skb_shinfo(skb)->nr_frags + 1; |
| 844 | |
| 845 | if (unlikely(skb->len <= 0)) { |
| 846 | dev_kfree_skb_any(skb); |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 847 | adapter->stats.badskblen++; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 848 | return NETDEV_TX_OK; |
| 849 | } |
| 850 | |
| 851 | if (frag_count > MAX_BUFFERS_PER_CMD) { |
| 852 | printk("%s: %s netxen_nic_xmit_frame: frag_count (%d)" |
| 853 | "too large, can handle only %d frags\n", |
| 854 | netxen_nic_driver_name, netdev->name, |
| 855 | frag_count, MAX_BUFFERS_PER_CMD); |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 856 | adapter->stats.txdropped++; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 857 | if ((++dropped_packet & 0xff) == 0xff) |
| 858 | printk("%s: %s droppped packets = %d\n", |
| 859 | netxen_nic_driver_name, netdev->name, |
| 860 | dropped_packet); |
| 861 | |
| 862 | return NETDEV_TX_OK; |
| 863 | } |
| 864 | |
| 865 | /* |
| 866 | * Everything is set up. Now, we just need to transmit it out. |
| 867 | * Note that we have to copy the contents of buffer over to |
| 868 | * right place. Later on, this can be optimized out by de-coupling the |
| 869 | * producer index from the buffer index. |
| 870 | */ |
| 871 | retry_getting_window: |
| 872 | spin_lock_bh(&adapter->tx_lock); |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 873 | if (adapter->total_threads >= MAX_XMIT_PRODUCERS) { |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 874 | spin_unlock_bh(&adapter->tx_lock); |
| 875 | /* |
| 876 | * Yield CPU |
| 877 | */ |
| 878 | if (!in_atomic()) |
| 879 | schedule(); |
| 880 | else { |
| 881 | for (i = 0; i < 20; i++) |
| 882 | cpu_relax(); /*This a nop instr on i386 */ |
| 883 | } |
| 884 | goto retry_getting_window; |
| 885 | } |
| 886 | local_producer = adapter->cmd_producer; |
| 887 | /* There 4 fragments per descriptor */ |
| 888 | no_of_desc = (frag_count + 3) >> 2; |
Amit S. Kale | cb8011a | 2006-11-29 09:00:10 -0800 | [diff] [blame] | 889 | if (netdev->features & NETIF_F_TSO) { |
| 890 | if (skb_shinfo(skb)->gso_size > 0) { |
| 891 | |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 892 | no_of_desc++; |
Arnaldo Carvalho de Melo | ab6a5bb | 2007-03-18 17:43:48 -0700 | [diff] [blame] | 893 | if ((ip_hdrlen(skb) + tcp_hdrlen(skb) + |
Arnaldo Carvalho de Melo | c9bdd4b | 2007-03-12 20:09:15 -0300 | [diff] [blame] | 894 | sizeof(struct ethhdr)) > |
Amit S. Kale | ed25ffa | 2006-12-04 09:23:25 -0800 | [diff] [blame] | 895 | (sizeof(struct cmd_desc_type0) - 2)) { |
Amit S. Kale | cb8011a | 2006-11-29 09:00:10 -0800 | [diff] [blame] | 896 | no_of_desc++; |
| 897 | } |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 898 | } |
| 899 | } |
| 900 | k = adapter->cmd_producer; |
| 901 | max_tx_desc_count = adapter->max_tx_desc_count; |
| 902 | last_cmd_consumer = adapter->last_cmd_consumer; |
| 903 | if ((k + no_of_desc) >= |
| 904 | ((last_cmd_consumer <= k) ? last_cmd_consumer + max_tx_desc_count : |
| 905 | last_cmd_consumer)) { |
Amit S. Kale | ed25ffa | 2006-12-04 09:23:25 -0800 | [diff] [blame] | 906 | netif_stop_queue(netdev); |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 907 | adapter->flags |= NETXEN_NETDEV_STATUS; |
Amit S. Kale | ed25ffa | 2006-12-04 09:23:25 -0800 | [diff] [blame] | 908 | spin_unlock_bh(&adapter->tx_lock); |
| 909 | return NETDEV_TX_BUSY; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 910 | } |
| 911 | k = get_index_range(k, max_tx_desc_count, no_of_desc); |
| 912 | adapter->cmd_producer = k; |
| 913 | adapter->total_threads++; |
| 914 | adapter->num_threads++; |
| 915 | |
| 916 | spin_unlock_bh(&adapter->tx_lock); |
| 917 | /* Copy the descriptors into the hardware */ |
| 918 | producer = local_producer; |
| 919 | saved_producer = producer; |
| 920 | hwdesc = &hw->cmd_desc_head[producer]; |
| 921 | memset(hwdesc, 0, sizeof(struct cmd_desc_type0)); |
| 922 | /* Take skb->data itself */ |
| 923 | pbuf = &adapter->cmd_buf_arr[producer]; |
Amit S. Kale | cb8011a | 2006-11-29 09:00:10 -0800 | [diff] [blame] | 924 | if ((netdev->features & NETIF_F_TSO) && skb_shinfo(skb)->gso_size > 0) { |
Al Viro | a608ab9c | 2007-01-02 10:39:10 +0000 | [diff] [blame] | 925 | pbuf->mss = skb_shinfo(skb)->gso_size; |
Amit S. Kale | ed33ebe | 2006-12-18 05:53:59 -0800 | [diff] [blame] | 926 | hwdesc->mss = cpu_to_le16(skb_shinfo(skb)->gso_size); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 927 | } else { |
| 928 | pbuf->mss = 0; |
| 929 | hwdesc->mss = 0; |
| 930 | } |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 931 | pbuf->total_length = skb->len; |
| 932 | pbuf->skb = skb; |
| 933 | pbuf->cmd = TX_ETHER_PKT; |
| 934 | pbuf->frag_count = frag_count; |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 935 | pbuf->port = adapter->portnum; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 936 | buffrag = &pbuf->frag_array[0]; |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 937 | buffrag->dma = pci_map_single(adapter->pdev, skb->data, first_seg_len, |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 938 | PCI_DMA_TODEVICE); |
| 939 | buffrag->length = first_seg_len; |
Amit S. Kale | ed25ffa | 2006-12-04 09:23:25 -0800 | [diff] [blame] | 940 | netxen_set_cmd_desc_totallength(hwdesc, skb->len); |
| 941 | netxen_set_cmd_desc_num_of_buff(hwdesc, frag_count); |
| 942 | netxen_set_cmd_desc_opcode(hwdesc, TX_ETHER_PKT); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 943 | |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 944 | netxen_set_cmd_desc_port(hwdesc, adapter->portnum); |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 945 | netxen_set_cmd_desc_ctxid(hwdesc, adapter->portnum); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 946 | hwdesc->buffer1_length = cpu_to_le16(first_seg_len); |
| 947 | hwdesc->addr_buffer1 = cpu_to_le64(buffrag->dma); |
| 948 | |
| 949 | for (i = 1, k = 1; i < frag_count; i++, k++) { |
| 950 | struct skb_frag_struct *frag; |
| 951 | int len, temp_len; |
| 952 | unsigned long offset; |
| 953 | dma_addr_t temp_dma; |
| 954 | |
| 955 | /* move to next desc. if there is a need */ |
| 956 | if ((i & 0x3) == 0) { |
| 957 | k = 0; |
| 958 | producer = get_next_index(producer, |
| 959 | adapter->max_tx_desc_count); |
| 960 | hwdesc = &hw->cmd_desc_head[producer]; |
| 961 | memset(hwdesc, 0, sizeof(struct cmd_desc_type0)); |
| 962 | } |
| 963 | frag = &skb_shinfo(skb)->frags[i - 1]; |
| 964 | len = frag->size; |
| 965 | offset = frag->page_offset; |
| 966 | |
| 967 | temp_len = len; |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 968 | temp_dma = pci_map_page(adapter->pdev, frag->page, offset, |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 969 | len, PCI_DMA_TODEVICE); |
| 970 | |
| 971 | buffrag++; |
| 972 | buffrag->dma = temp_dma; |
| 973 | buffrag->length = temp_len; |
| 974 | |
| 975 | DPRINTK(INFO, "for loop. i=%d k=%d\n", i, k); |
| 976 | switch (k) { |
| 977 | case 0: |
| 978 | hwdesc->buffer1_length = cpu_to_le16(temp_len); |
| 979 | hwdesc->addr_buffer1 = cpu_to_le64(temp_dma); |
| 980 | break; |
| 981 | case 1: |
| 982 | hwdesc->buffer2_length = cpu_to_le16(temp_len); |
| 983 | hwdesc->addr_buffer2 = cpu_to_le64(temp_dma); |
| 984 | break; |
| 985 | case 2: |
| 986 | hwdesc->buffer3_length = cpu_to_le16(temp_len); |
| 987 | hwdesc->addr_buffer3 = cpu_to_le64(temp_dma); |
| 988 | break; |
| 989 | case 3: |
Al Viro | a608ab9c | 2007-01-02 10:39:10 +0000 | [diff] [blame] | 990 | hwdesc->buffer4_length = cpu_to_le16(temp_len); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 991 | hwdesc->addr_buffer4 = cpu_to_le64(temp_dma); |
| 992 | break; |
| 993 | } |
| 994 | frag++; |
| 995 | } |
| 996 | producer = get_next_index(producer, adapter->max_tx_desc_count); |
| 997 | |
| 998 | /* might change opcode to TX_TCP_LSO */ |
| 999 | netxen_tso_check(adapter, &hw->cmd_desc_head[saved_producer], skb); |
| 1000 | |
| 1001 | /* For LSO, we need to copy the MAC/IP/TCP headers into |
| 1002 | * the descriptor ring |
| 1003 | */ |
Amit S. Kale | ed25ffa | 2006-12-04 09:23:25 -0800 | [diff] [blame] | 1004 | if (netxen_get_cmd_desc_opcode(&hw->cmd_desc_head[saved_producer]) |
| 1005 | == TX_TCP_LSO) { |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1006 | int hdr_len, first_hdr_len, more_hdr; |
| 1007 | hdr_len = hw->cmd_desc_head[saved_producer].total_hdr_length; |
Amit S. Kale | ed25ffa | 2006-12-04 09:23:25 -0800 | [diff] [blame] | 1008 | if (hdr_len > (sizeof(struct cmd_desc_type0) - 2)) { |
| 1009 | first_hdr_len = sizeof(struct cmd_desc_type0) - 2; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1010 | more_hdr = 1; |
| 1011 | } else { |
| 1012 | first_hdr_len = hdr_len; |
| 1013 | more_hdr = 0; |
| 1014 | } |
| 1015 | /* copy the MAC/IP/TCP headers to the cmd descriptor list */ |
| 1016 | hwdesc = &hw->cmd_desc_head[producer]; |
| 1017 | |
| 1018 | /* copy the first 64 bytes */ |
Amit S. Kale | ed25ffa | 2006-12-04 09:23:25 -0800 | [diff] [blame] | 1019 | memcpy(((void *)hwdesc) + 2, |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1020 | (void *)(skb->data), first_hdr_len); |
| 1021 | producer = get_next_index(producer, max_tx_desc_count); |
| 1022 | |
| 1023 | if (more_hdr) { |
| 1024 | hwdesc = &hw->cmd_desc_head[producer]; |
| 1025 | /* copy the next 64 bytes - should be enough except |
| 1026 | * for pathological case |
| 1027 | */ |
Arnaldo Carvalho de Melo | d626f62 | 2007-03-27 18:55:52 -0300 | [diff] [blame] | 1028 | skb_copy_from_linear_data_offset(skb, first_hdr_len, |
| 1029 | hwdesc, |
| 1030 | (hdr_len - |
| 1031 | first_hdr_len)); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1032 | producer = get_next_index(producer, max_tx_desc_count); |
| 1033 | } |
| 1034 | } |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 1035 | |
| 1036 | i = netxen_get_cmd_desc_totallength(&hw->cmd_desc_head[saved_producer]); |
| 1037 | |
| 1038 | hw->cmd_desc_head[saved_producer].flags_opcode = |
| 1039 | cpu_to_le16(hw->cmd_desc_head[saved_producer].flags_opcode); |
| 1040 | hw->cmd_desc_head[saved_producer].num_of_buffers_total_length = |
| 1041 | cpu_to_le32(hw->cmd_desc_head[saved_producer]. |
| 1042 | num_of_buffers_total_length); |
| 1043 | |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1044 | spin_lock_bh(&adapter->tx_lock); |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 1045 | adapter->stats.txbytes += i; |
| 1046 | |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1047 | /* Code to update the adapter considering how many producer threads |
| 1048 | are currently working */ |
| 1049 | if ((--adapter->num_threads) == 0) { |
| 1050 | /* This is the last thread */ |
| 1051 | u32 crb_producer = adapter->cmd_producer; |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 1052 | netxen_nic_update_cmd_producer(adapter, crb_producer); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1053 | wmb(); |
| 1054 | adapter->total_threads = 0; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1055 | } |
| 1056 | |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 1057 | adapter->stats.xmitfinished++; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1058 | spin_unlock_bh(&adapter->tx_lock); |
| 1059 | |
| 1060 | netdev->trans_start = jiffies; |
| 1061 | |
| 1062 | DPRINTK(INFO, "wrote CMD producer %x to phantom\n", producer); |
| 1063 | |
| 1064 | DPRINTK(INFO, "Done. Send\n"); |
| 1065 | return NETDEV_TX_OK; |
| 1066 | } |
| 1067 | |
| 1068 | static void netxen_watchdog(unsigned long v) |
| 1069 | { |
| 1070 | struct netxen_adapter *adapter = (struct netxen_adapter *)v; |
Amit S. Kale | ed25ffa | 2006-12-04 09:23:25 -0800 | [diff] [blame] | 1071 | |
| 1072 | SCHEDULE_WORK(&adapter->watchdog_task); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1073 | } |
| 1074 | |
| 1075 | static void netxen_tx_timeout(struct net_device *netdev) |
| 1076 | { |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 1077 | struct netxen_adapter *adapter = (struct netxen_adapter *) |
| 1078 | netdev_priv(netdev); |
| 1079 | SCHEDULE_WORK(&adapter->tx_timeout_task); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1080 | } |
| 1081 | |
David Howells | 6d5aefb | 2006-12-05 19:36:26 +0000 | [diff] [blame] | 1082 | static void netxen_tx_timeout_task(struct work_struct *work) |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1083 | { |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 1084 | struct netxen_adapter *adapter = |
| 1085 | container_of(work, struct netxen_adapter, tx_timeout_task); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1086 | unsigned long flags; |
| 1087 | |
| 1088 | printk(KERN_ERR "%s %s: transmit timeout, resetting.\n", |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 1089 | netxen_nic_driver_name, adapter->netdev->name); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1090 | |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 1091 | spin_lock_irqsave(&adapter->lock, flags); |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 1092 | netxen_nic_close(adapter->netdev); |
| 1093 | netxen_nic_open(adapter->netdev); |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 1094 | spin_unlock_irqrestore(&adapter->lock, flags); |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 1095 | adapter->netdev->trans_start = jiffies; |
| 1096 | netif_wake_queue(adapter->netdev); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1097 | } |
| 1098 | |
| 1099 | static int |
| 1100 | netxen_handle_int(struct netxen_adapter *adapter, struct net_device *netdev) |
| 1101 | { |
| 1102 | u32 ret = 0; |
| 1103 | |
| 1104 | DPRINTK(INFO, "Entered handle ISR\n"); |
Mithlesh Thukral | 595e3fb | 2007-04-20 07:53:52 -0700 | [diff] [blame] | 1105 | adapter->stats.ints++; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1106 | |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1107 | if (!(adapter->flags & NETXEN_NIC_MSI_ENABLED)) { |
| 1108 | int count = 0; |
| 1109 | u32 mask; |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 1110 | u32 our_int = 0; |
| 1111 | our_int = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_INT_VECTOR)); |
| 1112 | /* not our interrupt */ |
| 1113 | if ((our_int & (0x80 << adapter->portnum)) == 0) |
Amit S. Kale | ed25ffa | 2006-12-04 09:23:25 -0800 | [diff] [blame] | 1114 | return ret; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1115 | netxen_nic_disable_int(adapter); |
| 1116 | /* Window = 0 or 1 */ |
| 1117 | do { |
Amit S. Kale | 71bd787 | 2006-12-01 05:36:22 -0800 | [diff] [blame] | 1118 | writel(0xffffffff, PCI_OFFSET_SECOND_RANGE(adapter, |
| 1119 | ISR_INT_TARGET_STATUS)); |
| 1120 | mask = readl(pci_base_offset(adapter, ISR_INT_VECTOR)); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1121 | } while (((mask & 0x80) != 0) && (++count < 32)); |
| 1122 | if ((mask & 0x80) != 0) |
| 1123 | printk("Could not disable interrupt completely\n"); |
| 1124 | |
| 1125 | } |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1126 | |
| 1127 | if (netxen_nic_rx_has_work(adapter) || netxen_nic_tx_has_work(adapter)) { |
| 1128 | if (netif_rx_schedule_prep(netdev)) { |
| 1129 | /* |
| 1130 | * Interrupts are already disabled. |
| 1131 | */ |
| 1132 | __netif_rx_schedule(netdev); |
| 1133 | } else { |
| 1134 | static unsigned int intcount = 0; |
| 1135 | if ((++intcount & 0xfff) == 0xfff) |
| 1136 | printk(KERN_ERR |
| 1137 | "%s: %s interrupt %d while in poll\n", |
| 1138 | netxen_nic_driver_name, netdev->name, |
| 1139 | intcount); |
| 1140 | } |
| 1141 | ret = 1; |
| 1142 | } |
| 1143 | |
| 1144 | if (ret == 0) { |
| 1145 | netxen_nic_enable_int(adapter); |
| 1146 | } |
| 1147 | |
| 1148 | return ret; |
| 1149 | } |
| 1150 | |
| 1151 | /* |
| 1152 | * netxen_intr - Interrupt Handler |
| 1153 | * @irq: interrupt number |
| 1154 | * data points to adapter stucture (which may be handling more than 1 port |
| 1155 | */ |
Jeff Garzik | 1494a81 | 2006-11-07 05:12:16 -0500 | [diff] [blame] | 1156 | irqreturn_t netxen_intr(int irq, void *data) |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1157 | { |
| 1158 | struct netxen_adapter *adapter; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1159 | struct net_device *netdev; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1160 | |
| 1161 | if (unlikely(!irq)) { |
| 1162 | return IRQ_NONE; /* Not our interrupt */ |
| 1163 | } |
| 1164 | |
| 1165 | adapter = (struct netxen_adapter *)data; |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 1166 | netdev = adapter->netdev; |
| 1167 | /* process our status queue (for all 4 ports) */ |
| 1168 | if (netif_running(netdev)) |
| 1169 | netxen_handle_int(adapter, netdev); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1170 | |
| 1171 | return IRQ_HANDLED; |
| 1172 | } |
| 1173 | |
| 1174 | static int netxen_nic_poll(struct net_device *netdev, int *budget) |
| 1175 | { |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 1176 | struct netxen_adapter *adapter = netdev_priv(netdev); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1177 | int work_to_do = min(*budget, netdev->quota); |
| 1178 | int done = 1; |
| 1179 | int ctx; |
| 1180 | int this_work_done; |
Amit S. Kale | 80922fb | 2006-12-04 09:18:00 -0800 | [diff] [blame] | 1181 | int work_done = 0; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1182 | |
| 1183 | DPRINTK(INFO, "polling for %d descriptors\n", *budget); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1184 | |
Amit S. Kale | 80922fb | 2006-12-04 09:18:00 -0800 | [diff] [blame] | 1185 | work_done = 0; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1186 | for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) { |
| 1187 | /* |
| 1188 | * Fairness issue. This will give undue weight to the |
| 1189 | * receive context 0. |
| 1190 | */ |
| 1191 | |
| 1192 | /* |
| 1193 | * To avoid starvation, we give each of our receivers, |
| 1194 | * a fraction of the quota. Sometimes, it might happen that we |
| 1195 | * have enough quota to process every packet, but since all the |
| 1196 | * packets are on one context, it gets only half of the quota, |
| 1197 | * and ends up not processing it. |
| 1198 | */ |
| 1199 | this_work_done = netxen_process_rcv_ring(adapter, ctx, |
| 1200 | work_to_do / |
| 1201 | MAX_RCV_CTX); |
Amit S. Kale | 80922fb | 2006-12-04 09:18:00 -0800 | [diff] [blame] | 1202 | work_done += this_work_done; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1203 | } |
| 1204 | |
Amit S. Kale | 80922fb | 2006-12-04 09:18:00 -0800 | [diff] [blame] | 1205 | netdev->quota -= work_done; |
| 1206 | *budget -= work_done; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1207 | |
Amit S. Kale | ed25ffa | 2006-12-04 09:23:25 -0800 | [diff] [blame] | 1208 | if (work_done >= work_to_do && netxen_nic_rx_has_work(adapter) != 0) |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1209 | done = 0; |
| 1210 | |
Amit S. Kale | ed25ffa | 2006-12-04 09:23:25 -0800 | [diff] [blame] | 1211 | if (netxen_process_cmd_ring((unsigned long)adapter) == 0) |
| 1212 | done = 0; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1213 | |
| 1214 | DPRINTK(INFO, "new work_done: %d work_to_do: %d\n", |
Amit S. Kale | 80922fb | 2006-12-04 09:18:00 -0800 | [diff] [blame] | 1215 | work_done, work_to_do); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1216 | if (done) { |
| 1217 | netif_rx_complete(netdev); |
| 1218 | netxen_nic_enable_int(adapter); |
| 1219 | } |
| 1220 | |
Amit S. Kale | edf9016 | 2006-11-29 08:58:11 -0800 | [diff] [blame] | 1221 | return !done; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1222 | } |
| 1223 | |
| 1224 | #ifdef CONFIG_NET_POLL_CONTROLLER |
| 1225 | static void netxen_nic_poll_controller(struct net_device *netdev) |
| 1226 | { |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 1227 | struct netxen_adapter *adapter = netdev_priv(netdev); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1228 | disable_irq(adapter->irq); |
Jeff Garzik | 1494a81 | 2006-11-07 05:12:16 -0500 | [diff] [blame] | 1229 | netxen_intr(adapter->irq, adapter); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1230 | enable_irq(adapter->irq); |
| 1231 | } |
| 1232 | #endif |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1233 | |
| 1234 | static struct pci_driver netxen_driver = { |
| 1235 | .name = netxen_nic_driver_name, |
| 1236 | .id_table = netxen_pci_tbl, |
| 1237 | .probe = netxen_nic_probe, |
| 1238 | .remove = __devexit_p(netxen_nic_remove) |
| 1239 | }; |
| 1240 | |
| 1241 | /* Driver Registration on NetXen card */ |
| 1242 | |
| 1243 | static int __init netxen_init_module(void) |
| 1244 | { |
Amit S. Kale | ed25ffa | 2006-12-04 09:23:25 -0800 | [diff] [blame] | 1245 | if ((netxen_workq = create_singlethread_workqueue("netxen")) == 0) |
| 1246 | return -ENOMEM; |
| 1247 | |
Amit S. Kale | 184231b | 2007-01-22 06:52:53 -0800 | [diff] [blame] | 1248 | return pci_register_driver(&netxen_driver); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1249 | } |
| 1250 | |
| 1251 | module_init(netxen_init_module); |
| 1252 | |
| 1253 | static void __exit netxen_exit_module(void) |
| 1254 | { |
| 1255 | /* |
| 1256 | * Wait for some time to allow the dma to drain, if any. |
| 1257 | */ |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1258 | pci_unregister_driver(&netxen_driver); |
Amit S. Kale | 9de0661 | 2007-02-21 06:37:06 -0800 | [diff] [blame] | 1259 | destroy_workqueue(netxen_workq); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1260 | } |
| 1261 | |
| 1262 | module_exit(netxen_exit_module); |