1 /*******************************************************************************
4 Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved.
6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 2 of the License, or (at your option)
11 This program is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 You should have received a copy of the GNU General Public License along with
17 this program; if not, write to the Free Software Foundation, Inc., 59
18 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 The full GNU General Public License is included in this distribution in the
24 Linux NICS <linux.nics@intel.com>
25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27 *******************************************************************************/
33 * - Make needlessly global code static -- bunk@stusta.de
34 * - ethtool cleanup -- shemminger@osdl.org
35 * - Support for MODULE_VERSION -- linville@tuxdriver.com
36 * - add skb_header_cloned check to the tso path -- herbert@apana.org.au
38 * - include fix to the condition that determines when to quit NAPI - Robert Olsson
39 * - use netif_poll_{disable/enable} to synchronize between NAPI and i/f up/down
41 * - reset buffer_info->dma in Tx resource cleanup logic
43 * - sparse cleanup - shemminger@osdl.org
44 * - fix tx resource cleanup logic
47 char ixgb_driver_name[] = "ixgb";
48 static char ixgb_driver_string[] = "Intel(R) PRO/10GbE Network Driver";
50 #ifndef CONFIG_IXGB_NAPI
53 #define DRIVERNAPI "-NAPI"
55 #define DRV_VERSION "1.0.100-k2"DRIVERNAPI
56 char ixgb_driver_version[] = DRV_VERSION;
57 static char ixgb_copyright[] = "Copyright (c) 1999-2005 Intel Corporation.";
59 /* ixgb_pci_tbl - PCI Device ID Table
61 * Wildcard entries (PCI_ANY_ID) should come last
62 * Last entry must be all 0s
64 * { Vendor ID, Device ID, SubVendor ID, SubDevice ID,
65 * Class, Class Mask, private data (not used) }
67 static struct pci_device_id ixgb_pci_tbl[] = {
68 {INTEL_VENDOR_ID, IXGB_DEVICE_ID_82597EX,
69 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
70 {INTEL_VENDOR_ID, IXGB_DEVICE_ID_82597EX_CX4,
71 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
72 {INTEL_VENDOR_ID, IXGB_DEVICE_ID_82597EX_SR,
73 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
74 {INTEL_VENDOR_ID, IXGB_DEVICE_ID_82597EX_LR,
75 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
77 /* required last entry */
81 MODULE_DEVICE_TABLE(pci, ixgb_pci_tbl);
83 /* Local Function Prototypes */
85 int ixgb_up(struct ixgb_adapter *adapter);
86 void ixgb_down(struct ixgb_adapter *adapter, boolean_t kill_watchdog);
87 void ixgb_reset(struct ixgb_adapter *adapter);
88 int ixgb_setup_tx_resources(struct ixgb_adapter *adapter);
89 int ixgb_setup_rx_resources(struct ixgb_adapter *adapter);
90 void ixgb_free_tx_resources(struct ixgb_adapter *adapter);
91 void ixgb_free_rx_resources(struct ixgb_adapter *adapter);
92 void ixgb_update_stats(struct ixgb_adapter *adapter);
94 static int ixgb_init_module(void);
95 static void ixgb_exit_module(void);
96 static int ixgb_probe(struct pci_dev *pdev, const struct pci_device_id *ent);
97 static void __devexit ixgb_remove(struct pci_dev *pdev);
98 static int ixgb_sw_init(struct ixgb_adapter *adapter);
99 static int ixgb_open(struct net_device *netdev);
100 static int ixgb_close(struct net_device *netdev);
101 static void ixgb_configure_tx(struct ixgb_adapter *adapter);
102 static void ixgb_configure_rx(struct ixgb_adapter *adapter);
103 static void ixgb_setup_rctl(struct ixgb_adapter *adapter);
104 static void ixgb_clean_tx_ring(struct ixgb_adapter *adapter);
105 static void ixgb_clean_rx_ring(struct ixgb_adapter *adapter);
106 static void ixgb_set_multi(struct net_device *netdev);
107 static void ixgb_watchdog(unsigned long data);
108 static int ixgb_xmit_frame(struct sk_buff *skb, struct net_device *netdev);
109 static struct net_device_stats *ixgb_get_stats(struct net_device *netdev);
110 static int ixgb_change_mtu(struct net_device *netdev, int new_mtu);
111 static int ixgb_set_mac(struct net_device *netdev, void *p);
112 static irqreturn_t ixgb_intr(int irq, void *data, struct pt_regs *regs);
113 static boolean_t ixgb_clean_tx_irq(struct ixgb_adapter *adapter);
115 #ifdef CONFIG_IXGB_NAPI
116 static int ixgb_clean(struct net_device *netdev, int *budget);
117 static boolean_t ixgb_clean_rx_irq(struct ixgb_adapter *adapter,
118 int *work_done, int work_to_do);
120 static boolean_t ixgb_clean_rx_irq(struct ixgb_adapter *adapter);
122 static void ixgb_alloc_rx_buffers(struct ixgb_adapter *adapter);
123 void ixgb_set_ethtool_ops(struct net_device *netdev);
124 static void ixgb_tx_timeout(struct net_device *dev);
125 static void ixgb_tx_timeout_task(struct net_device *dev);
126 static void ixgb_vlan_rx_register(struct net_device *netdev,
127 struct vlan_group *grp);
128 static void ixgb_vlan_rx_add_vid(struct net_device *netdev, uint16_t vid);
129 static void ixgb_vlan_rx_kill_vid(struct net_device *netdev, uint16_t vid);
130 static void ixgb_restore_vlan(struct ixgb_adapter *adapter);
132 #ifdef CONFIG_NET_POLL_CONTROLLER
133 /* for netdump / net console */
134 static void ixgb_netpoll(struct net_device *dev);
137 /* Exported from other modules */
139 extern void ixgb_check_options(struct ixgb_adapter *adapter);
141 static struct pci_driver ixgb_driver = {
142 .name = ixgb_driver_name,
143 .id_table = ixgb_pci_tbl,
145 .remove = __devexit_p(ixgb_remove),
148 MODULE_AUTHOR("Intel Corporation, <linux.nics@intel.com>");
149 MODULE_DESCRIPTION("Intel(R) PRO/10GbE Network Driver");
150 MODULE_LICENSE("GPL");
151 MODULE_VERSION(DRV_VERSION);
153 /* some defines for controlling descriptor fetches in h/w */
154 #define RXDCTL_WTHRESH_DEFAULT 16 /* chip writes back at this many or RXT0 */
155 #define RXDCTL_PTHRESH_DEFAULT 0 /* chip considers prefech below
157 #define RXDCTL_HTHRESH_DEFAULT 0 /* chip will only prefetch if tail
158 * is pushed this many descriptors
162 * ixgb_init_module - Driver Registration Routine
164 * ixgb_init_module is the first routine called when the driver is
165 * loaded. All it does is register with the PCI subsystem.
169 ixgb_init_module(void)
171 printk(KERN_INFO "%s - version %s\n",
172 ixgb_driver_string, ixgb_driver_version);
174 printk(KERN_INFO "%s\n", ixgb_copyright);
176 return pci_module_init(&ixgb_driver);
179 module_init(ixgb_init_module);
182 * ixgb_exit_module - Driver Exit Cleanup Routine
184 * ixgb_exit_module is called just before the driver is removed
189 ixgb_exit_module(void)
191 pci_unregister_driver(&ixgb_driver);
194 module_exit(ixgb_exit_module);
197 * ixgb_irq_disable - Mask off interrupt generation on the NIC
198 * @adapter: board private structure
202 ixgb_irq_disable(struct ixgb_adapter *adapter)
204 atomic_inc(&adapter->irq_sem);
205 IXGB_WRITE_REG(&adapter->hw, IMC, ~0);
206 IXGB_WRITE_FLUSH(&adapter->hw);
207 synchronize_irq(adapter->pdev->irq);
211 * ixgb_irq_enable - Enable default interrupt generation settings
212 * @adapter: board private structure
216 ixgb_irq_enable(struct ixgb_adapter *adapter)
218 if(atomic_dec_and_test(&adapter->irq_sem)) {
219 IXGB_WRITE_REG(&adapter->hw, IMS,
220 IXGB_INT_RXT0 | IXGB_INT_RXDMT0 | IXGB_INT_TXDW |
222 IXGB_WRITE_FLUSH(&adapter->hw);
227 ixgb_up(struct ixgb_adapter *adapter)
229 struct net_device *netdev = adapter->netdev;
231 int max_frame = netdev->mtu + ENET_HEADER_SIZE + ENET_FCS_LENGTH;
232 struct ixgb_hw *hw = &adapter->hw;
234 /* hardware has been reset, we need to reload some things */
236 ixgb_set_multi(netdev);
238 ixgb_restore_vlan(adapter);
240 ixgb_configure_tx(adapter);
241 ixgb_setup_rctl(adapter);
242 ixgb_configure_rx(adapter);
243 ixgb_alloc_rx_buffers(adapter);
245 #ifdef CONFIG_PCI_MSI
247 boolean_t pcix = (IXGB_READ_REG(&adapter->hw, STATUS) &
248 IXGB_STATUS_PCIX_MODE) ? TRUE : FALSE;
249 adapter->have_msi = TRUE;
252 adapter->have_msi = FALSE;
253 else if((err = pci_enable_msi(adapter->pdev))) {
255 "Unable to allocate MSI interrupt Error: %d\n", err);
256 adapter->have_msi = FALSE;
257 /* proceed to try to request regular interrupt */
262 if((err = request_irq(adapter->pdev->irq, &ixgb_intr,
263 SA_SHIRQ | SA_SAMPLE_RANDOM,
264 netdev->name, netdev)))
267 /* disable interrupts and get the hardware into a known state */
268 IXGB_WRITE_REG(&adapter->hw, IMC, 0xffffffff);
270 if((hw->max_frame_size != max_frame) ||
271 (hw->max_frame_size !=
272 (IXGB_READ_REG(hw, MFS) >> IXGB_MFS_SHIFT))) {
274 hw->max_frame_size = max_frame;
276 IXGB_WRITE_REG(hw, MFS, hw->max_frame_size << IXGB_MFS_SHIFT);
278 if(hw->max_frame_size >
279 IXGB_MAX_ENET_FRAME_SIZE_WITHOUT_FCS + ENET_FCS_LENGTH) {
280 uint32_t ctrl0 = IXGB_READ_REG(hw, CTRL0);
282 if(!(ctrl0 & IXGB_CTRL0_JFE)) {
283 ctrl0 |= IXGB_CTRL0_JFE;
284 IXGB_WRITE_REG(hw, CTRL0, ctrl0);
289 mod_timer(&adapter->watchdog_timer, jiffies);
290 ixgb_irq_enable(adapter);
292 #ifdef CONFIG_IXGB_NAPI
293 netif_poll_enable(netdev);
299 ixgb_down(struct ixgb_adapter *adapter, boolean_t kill_watchdog)
301 struct net_device *netdev = adapter->netdev;
303 ixgb_irq_disable(adapter);
304 free_irq(adapter->pdev->irq, netdev);
305 #ifdef CONFIG_PCI_MSI
306 if(adapter->have_msi == TRUE)
307 pci_disable_msi(adapter->pdev);
311 del_timer_sync(&adapter->watchdog_timer);
312 #ifdef CONFIG_IXGB_NAPI
313 netif_poll_disable(netdev);
315 adapter->link_speed = 0;
316 adapter->link_duplex = 0;
317 netif_carrier_off(netdev);
318 netif_stop_queue(netdev);
321 ixgb_clean_tx_ring(adapter);
322 ixgb_clean_rx_ring(adapter);
326 ixgb_reset(struct ixgb_adapter *adapter)
329 ixgb_adapter_stop(&adapter->hw);
330 if(!ixgb_init_hw(&adapter->hw))
331 IXGB_DBG("ixgb_init_hw failed.\n");
335 * ixgb_probe - Device Initialization Routine
336 * @pdev: PCI device information struct
337 * @ent: entry in ixgb_pci_tbl
339 * Returns 0 on success, negative on failure
341 * ixgb_probe initializes an adapter identified by a pci_dev structure.
342 * The OS initialization, configuring of the adapter private structure,
343 * and a hardware reset occur.
347 ixgb_probe(struct pci_dev *pdev,
348 const struct pci_device_id *ent)
350 struct net_device *netdev = NULL;
351 struct ixgb_adapter *adapter;
352 static int cards_found = 0;
353 unsigned long mmio_start;
359 if((err = pci_enable_device(pdev)))
362 if(!(err = pci_set_dma_mask(pdev, DMA_64BIT_MASK)) &&
363 !(err = pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK))) {
366 if((err = pci_set_dma_mask(pdev, DMA_32BIT_MASK)) ||
367 (err = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK))) {
368 IXGB_ERR("No usable DMA configuration, aborting\n");
374 if((err = pci_request_regions(pdev, ixgb_driver_name)))
375 goto err_request_regions;
377 pci_set_master(pdev);
379 netdev = alloc_etherdev(sizeof(struct ixgb_adapter));
382 goto err_alloc_etherdev;
385 SET_MODULE_OWNER(netdev);
386 SET_NETDEV_DEV(netdev, &pdev->dev);
388 pci_set_drvdata(pdev, netdev);
389 adapter = netdev_priv(netdev);
390 adapter->netdev = netdev;
391 adapter->pdev = pdev;
392 adapter->hw.back = adapter;
394 mmio_start = pci_resource_start(pdev, BAR_0);
395 mmio_len = pci_resource_len(pdev, BAR_0);
397 adapter->hw.hw_addr = ioremap(mmio_start, mmio_len);
398 if(!adapter->hw.hw_addr) {
403 for(i = BAR_1; i <= BAR_5; i++) {
404 if(pci_resource_len(pdev, i) == 0)
406 if(pci_resource_flags(pdev, i) & IORESOURCE_IO) {
407 adapter->hw.io_base = pci_resource_start(pdev, i);
412 netdev->open = &ixgb_open;
413 netdev->stop = &ixgb_close;
414 netdev->hard_start_xmit = &ixgb_xmit_frame;
415 netdev->get_stats = &ixgb_get_stats;
416 netdev->set_multicast_list = &ixgb_set_multi;
417 netdev->set_mac_address = &ixgb_set_mac;
418 netdev->change_mtu = &ixgb_change_mtu;
419 ixgb_set_ethtool_ops(netdev);
420 netdev->tx_timeout = &ixgb_tx_timeout;
421 netdev->watchdog_timeo = HZ;
422 #ifdef CONFIG_IXGB_NAPI
423 netdev->poll = &ixgb_clean;
426 netdev->vlan_rx_register = ixgb_vlan_rx_register;
427 netdev->vlan_rx_add_vid = ixgb_vlan_rx_add_vid;
428 netdev->vlan_rx_kill_vid = ixgb_vlan_rx_kill_vid;
429 #ifdef CONFIG_NET_POLL_CONTROLLER
430 netdev->poll_controller = ixgb_netpoll;
433 netdev->mem_start = mmio_start;
434 netdev->mem_end = mmio_start + mmio_len;
435 netdev->base_addr = adapter->hw.io_base;
437 adapter->bd_number = cards_found;
438 adapter->link_speed = 0;
439 adapter->link_duplex = 0;
441 /* setup the private structure */
443 if((err = ixgb_sw_init(adapter)))
446 netdev->features = NETIF_F_SG |
450 NETIF_F_HW_VLAN_FILTER;
452 netdev->features |= NETIF_F_TSO;
455 netdev->features |= NETIF_F_LLTX;
459 netdev->features |= NETIF_F_HIGHDMA;
461 /* make sure the EEPROM is good */
463 if(!ixgb_validate_eeprom_checksum(&adapter->hw)) {
464 printk(KERN_ERR "The EEPROM Checksum Is Not Valid\n");
469 ixgb_get_ee_mac_addr(&adapter->hw, netdev->dev_addr);
470 memcpy(netdev->perm_addr, netdev->dev_addr, netdev->addr_len);
472 if(!is_valid_ether_addr(netdev->perm_addr)) {
477 adapter->part_num = ixgb_get_ee_pba_number(&adapter->hw);
479 init_timer(&adapter->watchdog_timer);
480 adapter->watchdog_timer.function = &ixgb_watchdog;
481 adapter->watchdog_timer.data = (unsigned long)adapter;
483 INIT_WORK(&adapter->tx_timeout_task,
484 (void (*)(void *))ixgb_tx_timeout_task, netdev);
486 if((err = register_netdev(netdev)))
489 /* we're going to reset, so assume we have no link for now */
491 netif_carrier_off(netdev);
492 netif_stop_queue(netdev);
494 printk(KERN_INFO "%s: Intel(R) PRO/10GbE Network Connection\n",
496 ixgb_check_options(adapter);
497 /* reset the hardware with the new settings */
507 iounmap(adapter->hw.hw_addr);
511 pci_release_regions(pdev);
514 pci_disable_device(pdev);
519 * ixgb_remove - Device Removal Routine
520 * @pdev: PCI device information struct
522 * ixgb_remove is called by the PCI subsystem to alert the driver
523 * that it should release a PCI device. The could be caused by a
524 * Hot-Plug event, or because the driver is going to be removed from
528 static void __devexit
529 ixgb_remove(struct pci_dev *pdev)
531 struct net_device *netdev = pci_get_drvdata(pdev);
532 struct ixgb_adapter *adapter = netdev_priv(netdev);
534 unregister_netdev(netdev);
536 iounmap(adapter->hw.hw_addr);
537 pci_release_regions(pdev);
543 * ixgb_sw_init - Initialize general software structures (struct ixgb_adapter)
544 * @adapter: board private structure to initialize
546 * ixgb_sw_init initializes the Adapter private data structure.
547 * Fields are initialized based on PCI device information and
548 * OS network device settings (MTU size).
552 ixgb_sw_init(struct ixgb_adapter *adapter)
554 struct ixgb_hw *hw = &adapter->hw;
555 struct net_device *netdev = adapter->netdev;
556 struct pci_dev *pdev = adapter->pdev;
558 /* PCI config space info */
560 hw->vendor_id = pdev->vendor;
561 hw->device_id = pdev->device;
562 hw->subsystem_vendor_id = pdev->subsystem_vendor;
563 hw->subsystem_id = pdev->subsystem_device;
565 adapter->rx_buffer_len = IXGB_RXBUFFER_2048;
567 hw->max_frame_size = netdev->mtu + ENET_HEADER_SIZE + ENET_FCS_LENGTH;
569 if((hw->device_id == IXGB_DEVICE_ID_82597EX)
570 || (hw->device_id == IXGB_DEVICE_ID_82597EX_CX4)
571 || (hw->device_id == IXGB_DEVICE_ID_82597EX_LR)
572 || (hw->device_id == IXGB_DEVICE_ID_82597EX_SR))
573 hw->mac_type = ixgb_82597;
575 /* should never have loaded on this device */
576 printk(KERN_ERR "ixgb: unsupported device id\n");
579 /* enable flow control to be programmed */
582 atomic_set(&adapter->irq_sem, 1);
583 spin_lock_init(&adapter->tx_lock);
589 * ixgb_open - Called when a network interface is made active
590 * @netdev: network interface device structure
592 * Returns 0 on success, negative value on failure
594 * The open entry point is called when a network interface is made
595 * active by the system (IFF_UP). At this point all resources needed
596 * for transmit and receive operations are allocated, the interrupt
597 * handler is registered with the OS, the watchdog timer is started,
598 * and the stack is notified that the interface is ready.
602 ixgb_open(struct net_device *netdev)
604 struct ixgb_adapter *adapter = netdev_priv(netdev);
607 /* allocate transmit descriptors */
609 if((err = ixgb_setup_tx_resources(adapter)))
612 /* allocate receive descriptors */
614 if((err = ixgb_setup_rx_resources(adapter)))
617 if((err = ixgb_up(adapter)))
623 ixgb_free_rx_resources(adapter);
625 ixgb_free_tx_resources(adapter);
633 * ixgb_close - Disables a network interface
634 * @netdev: network interface device structure
636 * Returns 0, this is not allowed to fail
638 * The close entry point is called when an interface is de-activated
639 * by the OS. The hardware is still under the drivers control, but
640 * needs to be disabled. A global MAC reset is issued to stop the
641 * hardware, and all transmit and receive resources are freed.
645 ixgb_close(struct net_device *netdev)
647 struct ixgb_adapter *adapter = netdev_priv(netdev);
649 ixgb_down(adapter, TRUE);
651 ixgb_free_tx_resources(adapter);
652 ixgb_free_rx_resources(adapter);
658 * ixgb_setup_tx_resources - allocate Tx resources (Descriptors)
659 * @adapter: board private structure
661 * Return 0 on success, negative on failure
665 ixgb_setup_tx_resources(struct ixgb_adapter *adapter)
667 struct ixgb_desc_ring *txdr = &adapter->tx_ring;
668 struct pci_dev *pdev = adapter->pdev;
671 size = sizeof(struct ixgb_buffer) * txdr->count;
672 txdr->buffer_info = vmalloc(size);
673 if(!txdr->buffer_info) {
676 memset(txdr->buffer_info, 0, size);
678 /* round up to nearest 4K */
680 txdr->size = txdr->count * sizeof(struct ixgb_tx_desc);
681 IXGB_ROUNDUP(txdr->size, 4096);
683 txdr->desc = pci_alloc_consistent(pdev, txdr->size, &txdr->dma);
685 vfree(txdr->buffer_info);
688 memset(txdr->desc, 0, txdr->size);
690 txdr->next_to_use = 0;
691 txdr->next_to_clean = 0;
697 * ixgb_configure_tx - Configure 82597 Transmit Unit after Reset.
698 * @adapter: board private structure
700 * Configure the Tx unit of the MAC after a reset.
704 ixgb_configure_tx(struct ixgb_adapter *adapter)
706 uint64_t tdba = adapter->tx_ring.dma;
707 uint32_t tdlen = adapter->tx_ring.count * sizeof(struct ixgb_tx_desc);
709 struct ixgb_hw *hw = &adapter->hw;
711 /* Setup the Base and Length of the Tx Descriptor Ring
712 * tx_ring.dma can be either a 32 or 64 bit value
715 IXGB_WRITE_REG(hw, TDBAL, (tdba & 0x00000000ffffffffULL));
716 IXGB_WRITE_REG(hw, TDBAH, (tdba >> 32));
718 IXGB_WRITE_REG(hw, TDLEN, tdlen);
720 /* Setup the HW Tx Head and Tail descriptor pointers */
722 IXGB_WRITE_REG(hw, TDH, 0);
723 IXGB_WRITE_REG(hw, TDT, 0);
725 /* don't set up txdctl, it induces performance problems if configured
727 /* Set the Tx Interrupt Delay register */
729 IXGB_WRITE_REG(hw, TIDV, adapter->tx_int_delay);
731 /* Program the Transmit Control Register */
733 tctl = IXGB_TCTL_TCE | IXGB_TCTL_TXEN | IXGB_TCTL_TPDE;
734 IXGB_WRITE_REG(hw, TCTL, tctl);
736 /* Setup Transmit Descriptor Settings for this adapter */
737 adapter->tx_cmd_type =
739 | (adapter->tx_int_delay_enable ? IXGB_TX_DESC_CMD_IDE : 0);
743 * ixgb_setup_rx_resources - allocate Rx resources (Descriptors)
744 * @adapter: board private structure
746 * Returns 0 on success, negative on failure
750 ixgb_setup_rx_resources(struct ixgb_adapter *adapter)
752 struct ixgb_desc_ring *rxdr = &adapter->rx_ring;
753 struct pci_dev *pdev = adapter->pdev;
756 size = sizeof(struct ixgb_buffer) * rxdr->count;
757 rxdr->buffer_info = vmalloc(size);
758 if(!rxdr->buffer_info) {
761 memset(rxdr->buffer_info, 0, size);
763 /* Round up to nearest 4K */
765 rxdr->size = rxdr->count * sizeof(struct ixgb_rx_desc);
766 IXGB_ROUNDUP(rxdr->size, 4096);
768 rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma);
771 vfree(rxdr->buffer_info);
774 memset(rxdr->desc, 0, rxdr->size);
776 rxdr->next_to_clean = 0;
777 rxdr->next_to_use = 0;
783 * ixgb_setup_rctl - configure the receive control register
784 * @adapter: Board private structure
788 ixgb_setup_rctl(struct ixgb_adapter *adapter)
792 rctl = IXGB_READ_REG(&adapter->hw, RCTL);
794 rctl &= ~(3 << IXGB_RCTL_MO_SHIFT);
797 IXGB_RCTL_BAM | IXGB_RCTL_RDMTS_1_2 |
798 IXGB_RCTL_RXEN | IXGB_RCTL_CFF |
799 (adapter->hw.mc_filter_type << IXGB_RCTL_MO_SHIFT);
801 rctl |= IXGB_RCTL_SECRC;
803 switch (adapter->rx_buffer_len) {
804 case IXGB_RXBUFFER_2048:
806 rctl |= IXGB_RCTL_BSIZE_2048;
808 case IXGB_RXBUFFER_4096:
809 rctl |= IXGB_RCTL_BSIZE_4096;
811 case IXGB_RXBUFFER_8192:
812 rctl |= IXGB_RCTL_BSIZE_8192;
814 case IXGB_RXBUFFER_16384:
815 rctl |= IXGB_RCTL_BSIZE_16384;
819 IXGB_WRITE_REG(&adapter->hw, RCTL, rctl);
823 * ixgb_configure_rx - Configure 82597 Receive Unit after Reset.
824 * @adapter: board private structure
826 * Configure the Rx unit of the MAC after a reset.
830 ixgb_configure_rx(struct ixgb_adapter *adapter)
832 uint64_t rdba = adapter->rx_ring.dma;
833 uint32_t rdlen = adapter->rx_ring.count * sizeof(struct ixgb_rx_desc);
834 struct ixgb_hw *hw = &adapter->hw;
839 /* make sure receives are disabled while setting up the descriptors */
841 rctl = IXGB_READ_REG(hw, RCTL);
842 IXGB_WRITE_REG(hw, RCTL, rctl & ~IXGB_RCTL_RXEN);
844 /* set the Receive Delay Timer Register */
846 IXGB_WRITE_REG(hw, RDTR, adapter->rx_int_delay);
848 /* Setup the Base and Length of the Rx Descriptor Ring */
850 IXGB_WRITE_REG(hw, RDBAL, (rdba & 0x00000000ffffffffULL));
851 IXGB_WRITE_REG(hw, RDBAH, (rdba >> 32));
853 IXGB_WRITE_REG(hw, RDLEN, rdlen);
855 /* Setup the HW Rx Head and Tail Descriptor Pointers */
856 IXGB_WRITE_REG(hw, RDH, 0);
857 IXGB_WRITE_REG(hw, RDT, 0);
859 /* set up pre-fetching of receive buffers so we get some before we
860 * run out (default hardware behavior is to run out before fetching
861 * more). This sets up to fetch if HTHRESH rx descriptors are avail
862 * and the descriptors in hw cache are below PTHRESH. This avoids
863 * the hardware behavior of fetching <=512 descriptors in a single
864 * burst that pre-empts all other activity, usually causing fifo
866 /* use WTHRESH to burst write 16 descriptors or burst when RXT0 */
867 rxdctl = RXDCTL_WTHRESH_DEFAULT << IXGB_RXDCTL_WTHRESH_SHIFT |
868 RXDCTL_HTHRESH_DEFAULT << IXGB_RXDCTL_HTHRESH_SHIFT |
869 RXDCTL_PTHRESH_DEFAULT << IXGB_RXDCTL_PTHRESH_SHIFT;
870 IXGB_WRITE_REG(hw, RXDCTL, rxdctl);
872 /* Enable Receive Checksum Offload for TCP and UDP */
873 if(adapter->rx_csum == TRUE) {
874 rxcsum = IXGB_READ_REG(hw, RXCSUM);
875 rxcsum |= IXGB_RXCSUM_TUOFL;
876 IXGB_WRITE_REG(hw, RXCSUM, rxcsum);
879 /* Enable Receives */
881 IXGB_WRITE_REG(hw, RCTL, rctl);
885 * ixgb_free_tx_resources - Free Tx Resources
886 * @adapter: board private structure
888 * Free all transmit software resources
892 ixgb_free_tx_resources(struct ixgb_adapter *adapter)
894 struct pci_dev *pdev = adapter->pdev;
896 ixgb_clean_tx_ring(adapter);
898 vfree(adapter->tx_ring.buffer_info);
899 adapter->tx_ring.buffer_info = NULL;
901 pci_free_consistent(pdev, adapter->tx_ring.size,
902 adapter->tx_ring.desc, adapter->tx_ring.dma);
904 adapter->tx_ring.desc = NULL;
908 ixgb_unmap_and_free_tx_resource(struct ixgb_adapter *adapter,
909 struct ixgb_buffer *buffer_info)
911 struct pci_dev *pdev = adapter->pdev;
912 if(buffer_info->dma) {
917 buffer_info->dma = 0;
919 if(buffer_info->skb) {
920 dev_kfree_skb_any(buffer_info->skb);
921 buffer_info->skb = NULL;
926 * ixgb_clean_tx_ring - Free Tx Buffers
927 * @adapter: board private structure
931 ixgb_clean_tx_ring(struct ixgb_adapter *adapter)
933 struct ixgb_desc_ring *tx_ring = &adapter->tx_ring;
934 struct ixgb_buffer *buffer_info;
938 /* Free all the Tx ring sk_buffs */
940 for(i = 0; i < tx_ring->count; i++) {
941 buffer_info = &tx_ring->buffer_info[i];
942 ixgb_unmap_and_free_tx_resource(adapter, buffer_info);
945 size = sizeof(struct ixgb_buffer) * tx_ring->count;
946 memset(tx_ring->buffer_info, 0, size);
948 /* Zero out the descriptor ring */
950 memset(tx_ring->desc, 0, tx_ring->size);
952 tx_ring->next_to_use = 0;
953 tx_ring->next_to_clean = 0;
955 IXGB_WRITE_REG(&adapter->hw, TDH, 0);
956 IXGB_WRITE_REG(&adapter->hw, TDT, 0);
960 * ixgb_free_rx_resources - Free Rx Resources
961 * @adapter: board private structure
963 * Free all receive software resources
967 ixgb_free_rx_resources(struct ixgb_adapter *adapter)
969 struct ixgb_desc_ring *rx_ring = &adapter->rx_ring;
970 struct pci_dev *pdev = adapter->pdev;
972 ixgb_clean_rx_ring(adapter);
974 vfree(rx_ring->buffer_info);
975 rx_ring->buffer_info = NULL;
977 pci_free_consistent(pdev, rx_ring->size, rx_ring->desc, rx_ring->dma);
979 rx_ring->desc = NULL;
983 * ixgb_clean_rx_ring - Free Rx Buffers
984 * @adapter: board private structure
988 ixgb_clean_rx_ring(struct ixgb_adapter *adapter)
990 struct ixgb_desc_ring *rx_ring = &adapter->rx_ring;
991 struct ixgb_buffer *buffer_info;
992 struct pci_dev *pdev = adapter->pdev;
996 /* Free all the Rx ring sk_buffs */
998 for(i = 0; i < rx_ring->count; i++) {
999 buffer_info = &rx_ring->buffer_info[i];
1000 if(buffer_info->skb) {
1002 pci_unmap_single(pdev,
1004 buffer_info->length,
1005 PCI_DMA_FROMDEVICE);
1007 dev_kfree_skb(buffer_info->skb);
1009 buffer_info->skb = NULL;
1013 size = sizeof(struct ixgb_buffer) * rx_ring->count;
1014 memset(rx_ring->buffer_info, 0, size);
1016 /* Zero out the descriptor ring */
1018 memset(rx_ring->desc, 0, rx_ring->size);
1020 rx_ring->next_to_clean = 0;
1021 rx_ring->next_to_use = 0;
1023 IXGB_WRITE_REG(&adapter->hw, RDH, 0);
1024 IXGB_WRITE_REG(&adapter->hw, RDT, 0);
1028 * ixgb_set_mac - Change the Ethernet Address of the NIC
1029 * @netdev: network interface device structure
1030 * @p: pointer to an address structure
1032 * Returns 0 on success, negative on failure
1036 ixgb_set_mac(struct net_device *netdev, void *p)
1038 struct ixgb_adapter *adapter = netdev_priv(netdev);
1039 struct sockaddr *addr = p;
1041 if(!is_valid_ether_addr(addr->sa_data))
1042 return -EADDRNOTAVAIL;
1044 memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
1046 ixgb_rar_set(&adapter->hw, addr->sa_data, 0);
1052 * ixgb_set_multi - Multicast and Promiscuous mode set
1053 * @netdev: network interface device structure
1055 * The set_multi entry point is called whenever the multicast address
1056 * list or the network interface flags are updated. This routine is
1057 * responsible for configuring the hardware for proper multicast,
1058 * promiscuous mode, and all-multi behavior.
1062 ixgb_set_multi(struct net_device *netdev)
1064 struct ixgb_adapter *adapter = netdev_priv(netdev);
1065 struct ixgb_hw *hw = &adapter->hw;
1066 struct dev_mc_list *mc_ptr;
1070 /* Check for Promiscuous and All Multicast modes */
1072 rctl = IXGB_READ_REG(hw, RCTL);
1074 if(netdev->flags & IFF_PROMISC) {
1075 rctl |= (IXGB_RCTL_UPE | IXGB_RCTL_MPE);
1076 } else if(netdev->flags & IFF_ALLMULTI) {
1077 rctl |= IXGB_RCTL_MPE;
1078 rctl &= ~IXGB_RCTL_UPE;
1080 rctl &= ~(IXGB_RCTL_UPE | IXGB_RCTL_MPE);
1083 if(netdev->mc_count > IXGB_MAX_NUM_MULTICAST_ADDRESSES) {
1084 rctl |= IXGB_RCTL_MPE;
1085 IXGB_WRITE_REG(hw, RCTL, rctl);
1087 uint8_t mta[netdev->mc_count * IXGB_ETH_LENGTH_OF_ADDRESS];
1089 IXGB_WRITE_REG(hw, RCTL, rctl);
1091 for(i = 0, mc_ptr = netdev->mc_list; mc_ptr;
1092 i++, mc_ptr = mc_ptr->next)
1093 memcpy(&mta[i * IXGB_ETH_LENGTH_OF_ADDRESS],
1094 mc_ptr->dmi_addr, IXGB_ETH_LENGTH_OF_ADDRESS);
1096 ixgb_mc_addr_list_update(hw, mta, netdev->mc_count, 0);
1101 * ixgb_watchdog - Timer Call-back
1102 * @data: pointer to netdev cast into an unsigned long
1106 ixgb_watchdog(unsigned long data)
1108 struct ixgb_adapter *adapter = (struct ixgb_adapter *)data;
1109 struct net_device *netdev = adapter->netdev;
1110 struct ixgb_desc_ring *txdr = &adapter->tx_ring;
1112 ixgb_check_for_link(&adapter->hw);
1114 if (ixgb_check_for_bad_link(&adapter->hw)) {
1115 /* force the reset path */
1116 netif_stop_queue(netdev);
1119 if(adapter->hw.link_up) {
1120 if(!netif_carrier_ok(netdev)) {
1121 printk(KERN_INFO "ixgb: %s NIC Link is Up %d Mbps %s\n",
1122 netdev->name, 10000, "Full Duplex");
1123 adapter->link_speed = 10000;
1124 adapter->link_duplex = FULL_DUPLEX;
1125 netif_carrier_on(netdev);
1126 netif_wake_queue(netdev);
1129 if(netif_carrier_ok(netdev)) {
1130 adapter->link_speed = 0;
1131 adapter->link_duplex = 0;
1133 "ixgb: %s NIC Link is Down\n",
1135 netif_carrier_off(netdev);
1136 netif_stop_queue(netdev);
1141 ixgb_update_stats(adapter);
1143 if(!netif_carrier_ok(netdev)) {
1144 if(IXGB_DESC_UNUSED(txdr) + 1 < txdr->count) {
1145 /* We've lost link, so the controller stops DMA,
1146 * but we've got queued Tx work that's never going
1147 * to get done, so reset controller to flush Tx.
1148 * (Do the reset outside of interrupt context). */
1149 schedule_work(&adapter->tx_timeout_task);
1153 /* Force detection of hung controller every watchdog period */
1154 adapter->detect_tx_hung = TRUE;
1156 /* generate an interrupt to force clean up of any stragglers */
1157 IXGB_WRITE_REG(&adapter->hw, ICS, IXGB_INT_TXDW);
1159 /* Reset the timer */
1160 mod_timer(&adapter->watchdog_timer, jiffies + 2 * HZ);
1163 #define IXGB_TX_FLAGS_CSUM 0x00000001
1164 #define IXGB_TX_FLAGS_VLAN 0x00000002
1165 #define IXGB_TX_FLAGS_TSO 0x00000004
1168 ixgb_tso(struct ixgb_adapter *adapter, struct sk_buff *skb)
1171 struct ixgb_context_desc *context_desc;
1173 uint8_t ipcss, ipcso, tucss, tucso, hdr_len;
1174 uint16_t ipcse, tucse, mss;
1177 if(likely(skb_shinfo(skb)->tso_size)) {
1178 if (skb_header_cloned(skb)) {
1179 err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC);
1184 hdr_len = ((skb->h.raw - skb->data) + (skb->h.th->doff << 2));
1185 mss = skb_shinfo(skb)->tso_size;
1186 skb->nh.iph->tot_len = 0;
1187 skb->nh.iph->check = 0;
1188 skb->h.th->check = ~csum_tcpudp_magic(skb->nh.iph->saddr,
1191 ipcss = skb->nh.raw - skb->data;
1192 ipcso = (void *)&(skb->nh.iph->check) - (void *)skb->data;
1193 ipcse = skb->h.raw - skb->data - 1;
1194 tucss = skb->h.raw - skb->data;
1195 tucso = (void *)&(skb->h.th->check) - (void *)skb->data;
1198 i = adapter->tx_ring.next_to_use;
1199 context_desc = IXGB_CONTEXT_DESC(adapter->tx_ring, i);
1201 context_desc->ipcss = ipcss;
1202 context_desc->ipcso = ipcso;
1203 context_desc->ipcse = cpu_to_le16(ipcse);
1204 context_desc->tucss = tucss;
1205 context_desc->tucso = tucso;
1206 context_desc->tucse = cpu_to_le16(tucse);
1207 context_desc->mss = cpu_to_le16(mss);
1208 context_desc->hdr_len = hdr_len;
1209 context_desc->status = 0;
1210 context_desc->cmd_type_len = cpu_to_le32(
1211 IXGB_CONTEXT_DESC_TYPE
1212 | IXGB_CONTEXT_DESC_CMD_TSE
1213 | IXGB_CONTEXT_DESC_CMD_IP
1214 | IXGB_CONTEXT_DESC_CMD_TCP
1215 | IXGB_CONTEXT_DESC_CMD_IDE
1216 | (skb->len - (hdr_len)));
1219 if(++i == adapter->tx_ring.count) i = 0;
1220 adapter->tx_ring.next_to_use = i;
1229 static inline boolean_t
1230 ixgb_tx_csum(struct ixgb_adapter *adapter, struct sk_buff *skb)
1232 struct ixgb_context_desc *context_desc;
1236 if(likely(skb->ip_summed == CHECKSUM_HW)) {
1237 css = skb->h.raw - skb->data;
1238 cso = (skb->h.raw + skb->csum) - skb->data;
1240 i = adapter->tx_ring.next_to_use;
1241 context_desc = IXGB_CONTEXT_DESC(adapter->tx_ring, i);
1243 context_desc->tucss = css;
1244 context_desc->tucso = cso;
1245 context_desc->tucse = 0;
1246 /* zero out any previously existing data in one instruction */
1247 *(uint32_t *)&(context_desc->ipcss) = 0;
1248 context_desc->status = 0;
1249 context_desc->hdr_len = 0;
1250 context_desc->mss = 0;
1251 context_desc->cmd_type_len =
1252 cpu_to_le32(IXGB_CONTEXT_DESC_TYPE
1253 | IXGB_TX_DESC_CMD_IDE);
1255 if(++i == adapter->tx_ring.count) i = 0;
1256 adapter->tx_ring.next_to_use = i;
1264 #define IXGB_MAX_TXD_PWR 14
1265 #define IXGB_MAX_DATA_PER_TXD (1<<IXGB_MAX_TXD_PWR)
1268 ixgb_tx_map(struct ixgb_adapter *adapter, struct sk_buff *skb,
1271 struct ixgb_desc_ring *tx_ring = &adapter->tx_ring;
1272 struct ixgb_buffer *buffer_info;
1274 unsigned int offset = 0, size, count = 0, i;
1275 unsigned int mss = skb_shinfo(skb)->tso_size;
1277 unsigned int nr_frags = skb_shinfo(skb)->nr_frags;
1280 len -= skb->data_len;
1282 i = tx_ring->next_to_use;
1285 buffer_info = &tx_ring->buffer_info[i];
1286 size = min(len, IXGB_MAX_JUMBO_FRAME_SIZE);
1287 /* Workaround for premature desc write-backs
1288 * in TSO mode. Append 4-byte sentinel desc */
1289 if(unlikely(mss && !nr_frags && size == len && size > 8))
1292 buffer_info->length = size;
1294 pci_map_single(adapter->pdev,
1298 buffer_info->time_stamp = jiffies;
1303 if(++i == tx_ring->count) i = 0;
1306 for(f = 0; f < nr_frags; f++) {
1307 struct skb_frag_struct *frag;
1309 frag = &skb_shinfo(skb)->frags[f];
1314 buffer_info = &tx_ring->buffer_info[i];
1315 size = min(len, IXGB_MAX_JUMBO_FRAME_SIZE);
1316 /* Workaround for premature desc write-backs
1317 * in TSO mode. Append 4-byte sentinel desc */
1318 if(unlikely(mss && (f == (nr_frags-1)) && (size == len)
1322 buffer_info->length = size;
1324 pci_map_page(adapter->pdev,
1326 frag->page_offset + offset,
1329 buffer_info->time_stamp = jiffies;
1334 if(++i == tx_ring->count) i = 0;
1337 i = (i == 0) ? tx_ring->count - 1 : i - 1;
1338 tx_ring->buffer_info[i].skb = skb;
1339 tx_ring->buffer_info[first].next_to_watch = i;
1345 ixgb_tx_queue(struct ixgb_adapter *adapter, int count, int vlan_id,int tx_flags)
1347 struct ixgb_desc_ring *tx_ring = &adapter->tx_ring;
1348 struct ixgb_tx_desc *tx_desc = NULL;
1349 struct ixgb_buffer *buffer_info;
1350 uint32_t cmd_type_len = adapter->tx_cmd_type;
1355 if(tx_flags & IXGB_TX_FLAGS_TSO) {
1356 cmd_type_len |= IXGB_TX_DESC_CMD_TSE;
1357 popts |= (IXGB_TX_DESC_POPTS_IXSM | IXGB_TX_DESC_POPTS_TXSM);
1360 if(tx_flags & IXGB_TX_FLAGS_CSUM)
1361 popts |= IXGB_TX_DESC_POPTS_TXSM;
1363 if(tx_flags & IXGB_TX_FLAGS_VLAN) {
1364 cmd_type_len |= IXGB_TX_DESC_CMD_VLE;
1367 i = tx_ring->next_to_use;
1370 buffer_info = &tx_ring->buffer_info[i];
1371 tx_desc = IXGB_TX_DESC(*tx_ring, i);
1372 tx_desc->buff_addr = cpu_to_le64(buffer_info->dma);
1373 tx_desc->cmd_type_len =
1374 cpu_to_le32(cmd_type_len | buffer_info->length);
1375 tx_desc->status = status;
1376 tx_desc->popts = popts;
1377 tx_desc->vlan = cpu_to_le16(vlan_id);
1379 if(++i == tx_ring->count) i = 0;
1382 tx_desc->cmd_type_len |= cpu_to_le32(IXGB_TX_DESC_CMD_EOP
1383 | IXGB_TX_DESC_CMD_RS );
1385 /* Force memory writes to complete before letting h/w
1386 * know there are new descriptors to fetch. (Only
1387 * applicable for weak-ordered memory model archs,
1388 * such as IA-64). */
1391 tx_ring->next_to_use = i;
1392 IXGB_WRITE_REG(&adapter->hw, TDT, i);
1395 /* Tx Descriptors needed, worst case */
1396 #define TXD_USE_COUNT(S) (((S) >> IXGB_MAX_TXD_PWR) + \
1397 (((S) & (IXGB_MAX_DATA_PER_TXD - 1)) ? 1 : 0))
1398 #define DESC_NEEDED TXD_USE_COUNT(IXGB_MAX_DATA_PER_TXD) + \
1399 MAX_SKB_FRAGS * TXD_USE_COUNT(PAGE_SIZE) + 1 \
1400 /* one more for TSO workaround */ + 1
1403 ixgb_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
1405 struct ixgb_adapter *adapter = netdev_priv(netdev);
1407 unsigned int tx_flags = 0;
1408 unsigned long flags;
1413 dev_kfree_skb_any(skb);
1418 local_irq_save(flags);
1419 if (!spin_trylock(&adapter->tx_lock)) {
1420 /* Collision - tell upper layer to requeue */
1421 local_irq_restore(flags);
1422 return NETDEV_TX_LOCKED;
1425 spin_lock_irqsave(&adapter->tx_lock, flags);
1428 if(unlikely(IXGB_DESC_UNUSED(&adapter->tx_ring) < DESC_NEEDED)) {
1429 netif_stop_queue(netdev);
1430 spin_unlock_irqrestore(&adapter->tx_lock, flags);
1431 return NETDEV_TX_BUSY;
1434 #ifndef NETIF_F_LLTX
1435 spin_unlock_irqrestore(&adapter->tx_lock, flags);
1438 if(adapter->vlgrp && vlan_tx_tag_present(skb)) {
1439 tx_flags |= IXGB_TX_FLAGS_VLAN;
1440 vlan_id = vlan_tx_tag_get(skb);
1443 first = adapter->tx_ring.next_to_use;
1445 tso = ixgb_tso(adapter, skb);
1447 dev_kfree_skb_any(skb);
1449 spin_unlock_irqrestore(&adapter->tx_lock, flags);
1451 return NETDEV_TX_OK;
1455 tx_flags |= IXGB_TX_FLAGS_TSO;
1456 else if(ixgb_tx_csum(adapter, skb))
1457 tx_flags |= IXGB_TX_FLAGS_CSUM;
1459 ixgb_tx_queue(adapter, ixgb_tx_map(adapter, skb, first), vlan_id,
1462 netdev->trans_start = jiffies;
1465 /* Make sure there is space in the ring for the next send. */
1466 if(unlikely(IXGB_DESC_UNUSED(&adapter->tx_ring) < DESC_NEEDED))
1467 netif_stop_queue(netdev);
1469 spin_unlock_irqrestore(&adapter->tx_lock, flags);
1472 return NETDEV_TX_OK;
1476 * ixgb_tx_timeout - Respond to a Tx Hang
1477 * @netdev: network interface device structure
1481 ixgb_tx_timeout(struct net_device *netdev)
1483 struct ixgb_adapter *adapter = netdev_priv(netdev);
1485 /* Do the reset outside of interrupt context */
1486 schedule_work(&adapter->tx_timeout_task);
1490 ixgb_tx_timeout_task(struct net_device *netdev)
1492 struct ixgb_adapter *adapter = netdev_priv(netdev);
1494 ixgb_down(adapter, TRUE);
1499 * ixgb_get_stats - Get System Network Statistics
1500 * @netdev: network interface device structure
1502 * Returns the address of the device statistics structure.
1503 * The statistics are actually updated from the timer callback.
1506 static struct net_device_stats *
1507 ixgb_get_stats(struct net_device *netdev)
1509 struct ixgb_adapter *adapter = netdev_priv(netdev);
1511 return &adapter->net_stats;
1515 * ixgb_change_mtu - Change the Maximum Transfer Unit
1516 * @netdev: network interface device structure
1517 * @new_mtu: new value for maximum frame size
1519 * Returns 0 on success, negative on failure
1523 ixgb_change_mtu(struct net_device *netdev, int new_mtu)
1525 struct ixgb_adapter *adapter = netdev_priv(netdev);
1526 int max_frame = new_mtu + ENET_HEADER_SIZE + ENET_FCS_LENGTH;
1527 int old_max_frame = netdev->mtu + ENET_HEADER_SIZE + ENET_FCS_LENGTH;
1530 if((max_frame < IXGB_MIN_ENET_FRAME_SIZE_WITHOUT_FCS + ENET_FCS_LENGTH)
1531 || (max_frame > IXGB_MAX_JUMBO_FRAME_SIZE + ENET_FCS_LENGTH)) {
1532 IXGB_ERR("Invalid MTU setting\n");
1536 if((max_frame <= IXGB_MAX_ENET_FRAME_SIZE_WITHOUT_FCS + ENET_FCS_LENGTH)
1537 || (max_frame <= IXGB_RXBUFFER_2048)) {
1538 adapter->rx_buffer_len = IXGB_RXBUFFER_2048;
1540 } else if(max_frame <= IXGB_RXBUFFER_4096) {
1541 adapter->rx_buffer_len = IXGB_RXBUFFER_4096;
1543 } else if(max_frame <= IXGB_RXBUFFER_8192) {
1544 adapter->rx_buffer_len = IXGB_RXBUFFER_8192;
1547 adapter->rx_buffer_len = IXGB_RXBUFFER_16384;
1550 netdev->mtu = new_mtu;
1552 if(old_max_frame != max_frame && netif_running(netdev)) {
1554 ixgb_down(adapter, TRUE);
1562 * ixgb_update_stats - Update the board statistics counters.
1563 * @adapter: board private structure
1567 ixgb_update_stats(struct ixgb_adapter *adapter)
1569 struct net_device *netdev = adapter->netdev;
1571 if((netdev->flags & IFF_PROMISC) || (netdev->flags & IFF_ALLMULTI) ||
1572 (netdev->mc_count > IXGB_MAX_NUM_MULTICAST_ADDRESSES)) {
1573 u64 multi = IXGB_READ_REG(&adapter->hw, MPRCL);
1574 u32 bcast_l = IXGB_READ_REG(&adapter->hw, BPRCL);
1575 u32 bcast_h = IXGB_READ_REG(&adapter->hw, BPRCH);
1576 u64 bcast = ((u64)bcast_h << 32) | bcast_l;
1578 multi |= ((u64)IXGB_READ_REG(&adapter->hw, MPRCH) << 32);
1579 /* fix up multicast stats by removing broadcasts */
1583 adapter->stats.mprcl += (multi & 0xFFFFFFFF);
1584 adapter->stats.mprch += (multi >> 32);
1585 adapter->stats.bprcl += bcast_l;
1586 adapter->stats.bprch += bcast_h;
1588 adapter->stats.mprcl += IXGB_READ_REG(&adapter->hw, MPRCL);
1589 adapter->stats.mprch += IXGB_READ_REG(&adapter->hw, MPRCH);
1590 adapter->stats.bprcl += IXGB_READ_REG(&adapter->hw, BPRCL);
1591 adapter->stats.bprch += IXGB_READ_REG(&adapter->hw, BPRCH);
1593 adapter->stats.tprl += IXGB_READ_REG(&adapter->hw, TPRL);
1594 adapter->stats.tprh += IXGB_READ_REG(&adapter->hw, TPRH);
1595 adapter->stats.gprcl += IXGB_READ_REG(&adapter->hw, GPRCL);
1596 adapter->stats.gprch += IXGB_READ_REG(&adapter->hw, GPRCH);
1597 adapter->stats.uprcl += IXGB_READ_REG(&adapter->hw, UPRCL);
1598 adapter->stats.uprch += IXGB_READ_REG(&adapter->hw, UPRCH);
1599 adapter->stats.vprcl += IXGB_READ_REG(&adapter->hw, VPRCL);
1600 adapter->stats.vprch += IXGB_READ_REG(&adapter->hw, VPRCH);
1601 adapter->stats.jprcl += IXGB_READ_REG(&adapter->hw, JPRCL);
1602 adapter->stats.jprch += IXGB_READ_REG(&adapter->hw, JPRCH);
1603 adapter->stats.gorcl += IXGB_READ_REG(&adapter->hw, GORCL);
1604 adapter->stats.gorch += IXGB_READ_REG(&adapter->hw, GORCH);
1605 adapter->stats.torl += IXGB_READ_REG(&adapter->hw, TORL);
1606 adapter->stats.torh += IXGB_READ_REG(&adapter->hw, TORH);
1607 adapter->stats.rnbc += IXGB_READ_REG(&adapter->hw, RNBC);
1608 adapter->stats.ruc += IXGB_READ_REG(&adapter->hw, RUC);
1609 adapter->stats.roc += IXGB_READ_REG(&adapter->hw, ROC);
1610 adapter->stats.rlec += IXGB_READ_REG(&adapter->hw, RLEC);
1611 adapter->stats.crcerrs += IXGB_READ_REG(&adapter->hw, CRCERRS);
1612 adapter->stats.icbc += IXGB_READ_REG(&adapter->hw, ICBC);
1613 adapter->stats.ecbc += IXGB_READ_REG(&adapter->hw, ECBC);
1614 adapter->stats.mpc += IXGB_READ_REG(&adapter->hw, MPC);
1615 adapter->stats.tptl += IXGB_READ_REG(&adapter->hw, TPTL);
1616 adapter->stats.tpth += IXGB_READ_REG(&adapter->hw, TPTH);
1617 adapter->stats.gptcl += IXGB_READ_REG(&adapter->hw, GPTCL);
1618 adapter->stats.gptch += IXGB_READ_REG(&adapter->hw, GPTCH);
1619 adapter->stats.bptcl += IXGB_READ_REG(&adapter->hw, BPTCL);
1620 adapter->stats.bptch += IXGB_READ_REG(&adapter->hw, BPTCH);
1621 adapter->stats.mptcl += IXGB_READ_REG(&adapter->hw, MPTCL);
1622 adapter->stats.mptch += IXGB_READ_REG(&adapter->hw, MPTCH);
1623 adapter->stats.uptcl += IXGB_READ_REG(&adapter->hw, UPTCL);
1624 adapter->stats.uptch += IXGB_READ_REG(&adapter->hw, UPTCH);
1625 adapter->stats.vptcl += IXGB_READ_REG(&adapter->hw, VPTCL);
1626 adapter->stats.vptch += IXGB_READ_REG(&adapter->hw, VPTCH);
1627 adapter->stats.jptcl += IXGB_READ_REG(&adapter->hw, JPTCL);
1628 adapter->stats.jptch += IXGB_READ_REG(&adapter->hw, JPTCH);
1629 adapter->stats.gotcl += IXGB_READ_REG(&adapter->hw, GOTCL);
1630 adapter->stats.gotch += IXGB_READ_REG(&adapter->hw, GOTCH);
1631 adapter->stats.totl += IXGB_READ_REG(&adapter->hw, TOTL);
1632 adapter->stats.toth += IXGB_READ_REG(&adapter->hw, TOTH);
1633 adapter->stats.dc += IXGB_READ_REG(&adapter->hw, DC);
1634 adapter->stats.plt64c += IXGB_READ_REG(&adapter->hw, PLT64C);
1635 adapter->stats.tsctc += IXGB_READ_REG(&adapter->hw, TSCTC);
1636 adapter->stats.tsctfc += IXGB_READ_REG(&adapter->hw, TSCTFC);
1637 adapter->stats.ibic += IXGB_READ_REG(&adapter->hw, IBIC);
1638 adapter->stats.rfc += IXGB_READ_REG(&adapter->hw, RFC);
1639 adapter->stats.lfc += IXGB_READ_REG(&adapter->hw, LFC);
1640 adapter->stats.pfrc += IXGB_READ_REG(&adapter->hw, PFRC);
1641 adapter->stats.pftc += IXGB_READ_REG(&adapter->hw, PFTC);
1642 adapter->stats.mcfrc += IXGB_READ_REG(&adapter->hw, MCFRC);
1643 adapter->stats.mcftc += IXGB_READ_REG(&adapter->hw, MCFTC);
1644 adapter->stats.xonrxc += IXGB_READ_REG(&adapter->hw, XONRXC);
1645 adapter->stats.xontxc += IXGB_READ_REG(&adapter->hw, XONTXC);
1646 adapter->stats.xoffrxc += IXGB_READ_REG(&adapter->hw, XOFFRXC);
1647 adapter->stats.xofftxc += IXGB_READ_REG(&adapter->hw, XOFFTXC);
1648 adapter->stats.rjc += IXGB_READ_REG(&adapter->hw, RJC);
1650 /* Fill out the OS statistics structure */
1652 adapter->net_stats.rx_packets = adapter->stats.gprcl;
1653 adapter->net_stats.tx_packets = adapter->stats.gptcl;
1654 adapter->net_stats.rx_bytes = adapter->stats.gorcl;
1655 adapter->net_stats.tx_bytes = adapter->stats.gotcl;
1656 adapter->net_stats.multicast = adapter->stats.mprcl;
1657 adapter->net_stats.collisions = 0;
1659 /* ignore RLEC as it reports errors for padded (<64bytes) frames
1660 * with a length in the type/len field */
1661 adapter->net_stats.rx_errors =
1662 /* adapter->stats.rnbc + */ adapter->stats.crcerrs +
1663 adapter->stats.ruc +
1664 adapter->stats.roc /*+ adapter->stats.rlec */ +
1665 adapter->stats.icbc +
1666 adapter->stats.ecbc + adapter->stats.mpc;
1669 * adapter->net_stats.rx_length_errors = adapter->stats.rlec;
1672 adapter->net_stats.rx_crc_errors = adapter->stats.crcerrs;
1673 adapter->net_stats.rx_fifo_errors = adapter->stats.mpc;
1674 adapter->net_stats.rx_missed_errors = adapter->stats.mpc;
1675 adapter->net_stats.rx_over_errors = adapter->stats.mpc;
1677 adapter->net_stats.tx_errors = 0;
1678 adapter->net_stats.rx_frame_errors = 0;
1679 adapter->net_stats.tx_aborted_errors = 0;
1680 adapter->net_stats.tx_carrier_errors = 0;
1681 adapter->net_stats.tx_fifo_errors = 0;
1682 adapter->net_stats.tx_heartbeat_errors = 0;
1683 adapter->net_stats.tx_window_errors = 0;
1686 #define IXGB_MAX_INTR 10
1688 * ixgb_intr - Interrupt Handler
1689 * @irq: interrupt number
1690 * @data: pointer to a network interface device structure
1691 * @pt_regs: CPU registers structure
1695 ixgb_intr(int irq, void *data, struct pt_regs *regs)
1697 struct net_device *netdev = data;
1698 struct ixgb_adapter *adapter = netdev_priv(netdev);
1699 struct ixgb_hw *hw = &adapter->hw;
1700 uint32_t icr = IXGB_READ_REG(hw, ICR);
1701 #ifndef CONFIG_IXGB_NAPI
1706 return IRQ_NONE; /* Not our interrupt */
1708 if(unlikely(icr & (IXGB_INT_RXSEQ | IXGB_INT_LSC))) {
1709 mod_timer(&adapter->watchdog_timer, jiffies);
1712 #ifdef CONFIG_IXGB_NAPI
1713 if(netif_rx_schedule_prep(netdev)) {
1715 /* Disable interrupts and register for poll. The flush
1716 of the posted write is intentionally left out.
1719 atomic_inc(&adapter->irq_sem);
1720 IXGB_WRITE_REG(&adapter->hw, IMC, ~0);
1721 __netif_rx_schedule(netdev);
1724 /* yes, that is actually a & and it is meant to make sure that
1725 * every pass through this for loop checks both receive and
1726 * transmit queues for completed descriptors, intended to
1727 * avoid starvation issues and assist tx/rx fairness. */
1728 for(i = 0; i < IXGB_MAX_INTR; i++)
1729 if(!ixgb_clean_rx_irq(adapter) &
1730 !ixgb_clean_tx_irq(adapter))
1736 #ifdef CONFIG_IXGB_NAPI
1738 * ixgb_clean - NAPI Rx polling callback
1739 * @adapter: board private structure
1743 ixgb_clean(struct net_device *netdev, int *budget)
1745 struct ixgb_adapter *adapter = netdev_priv(netdev);
1746 int work_to_do = min(*budget, netdev->quota);
1750 tx_cleaned = ixgb_clean_tx_irq(adapter);
1751 ixgb_clean_rx_irq(adapter, &work_done, work_to_do);
1753 *budget -= work_done;
1754 netdev->quota -= work_done;
1756 /* if no Tx and not enough Rx work done, exit the polling mode */
1757 if((!tx_cleaned && (work_done == 0)) || !netif_running(netdev)) {
1758 netif_rx_complete(netdev);
1759 ixgb_irq_enable(adapter);
1768 * ixgb_clean_tx_irq - Reclaim resources after transmit completes
1769 * @adapter: board private structure
1773 ixgb_clean_tx_irq(struct ixgb_adapter *adapter)
1775 struct ixgb_desc_ring *tx_ring = &adapter->tx_ring;
1776 struct net_device *netdev = adapter->netdev;
1777 struct ixgb_tx_desc *tx_desc, *eop_desc;
1778 struct ixgb_buffer *buffer_info;
1779 unsigned int i, eop;
1780 boolean_t cleaned = FALSE;
1782 i = tx_ring->next_to_clean;
1783 eop = tx_ring->buffer_info[i].next_to_watch;
1784 eop_desc = IXGB_TX_DESC(*tx_ring, eop);
1786 while(eop_desc->status & IXGB_TX_DESC_STATUS_DD) {
1788 for(cleaned = FALSE; !cleaned; ) {
1789 tx_desc = IXGB_TX_DESC(*tx_ring, i);
1790 buffer_info = &tx_ring->buffer_info[i];
1793 & (IXGB_TX_DESC_POPTS_TXSM |
1794 IXGB_TX_DESC_POPTS_IXSM))
1795 adapter->hw_csum_tx_good++;
1797 ixgb_unmap_and_free_tx_resource(adapter, buffer_info);
1799 *(uint32_t *)&(tx_desc->status) = 0;
1801 cleaned = (i == eop);
1802 if(++i == tx_ring->count) i = 0;
1805 eop = tx_ring->buffer_info[i].next_to_watch;
1806 eop_desc = IXGB_TX_DESC(*tx_ring, eop);
1809 tx_ring->next_to_clean = i;
1811 spin_lock(&adapter->tx_lock);
1812 if(cleaned && netif_queue_stopped(netdev) && netif_carrier_ok(netdev) &&
1813 (IXGB_DESC_UNUSED(tx_ring) > IXGB_TX_QUEUE_WAKE)) {
1815 netif_wake_queue(netdev);
1817 spin_unlock(&adapter->tx_lock);
1819 if(adapter->detect_tx_hung) {
1820 /* detect a transmit hang in hardware, this serializes the
1821 * check with the clearing of time_stamp and movement of i */
1822 adapter->detect_tx_hung = FALSE;
1823 if(tx_ring->buffer_info[i].dma &&
1824 time_after(jiffies, tx_ring->buffer_info[i].time_stamp + HZ)
1825 && !(IXGB_READ_REG(&adapter->hw, STATUS) &
1827 netif_stop_queue(netdev);
1834 * ixgb_rx_checksum - Receive Checksum Offload for 82597.
1835 * @adapter: board private structure
1836 * @rx_desc: receive descriptor
1837 * @sk_buff: socket buffer with received data
1841 ixgb_rx_checksum(struct ixgb_adapter *adapter,
1842 struct ixgb_rx_desc *rx_desc,
1843 struct sk_buff *skb)
1845 /* Ignore Checksum bit is set OR
1846 * TCP Checksum has not been calculated
1848 if((rx_desc->status & IXGB_RX_DESC_STATUS_IXSM) ||
1849 (!(rx_desc->status & IXGB_RX_DESC_STATUS_TCPCS))) {
1850 skb->ip_summed = CHECKSUM_NONE;
1854 /* At this point we know the hardware did the TCP checksum */
1855 /* now look at the TCP checksum error bit */
1856 if(rx_desc->errors & IXGB_RX_DESC_ERRORS_TCPE) {
1857 /* let the stack verify checksum errors */
1858 skb->ip_summed = CHECKSUM_NONE;
1859 adapter->hw_csum_rx_error++;
1861 /* TCP checksum is good */
1862 skb->ip_summed = CHECKSUM_UNNECESSARY;
1863 adapter->hw_csum_rx_good++;
1868 * ixgb_clean_rx_irq - Send received data up the network stack,
1869 * @adapter: board private structure
1873 #ifdef CONFIG_IXGB_NAPI
1874 ixgb_clean_rx_irq(struct ixgb_adapter *adapter, int *work_done, int work_to_do)
1876 ixgb_clean_rx_irq(struct ixgb_adapter *adapter)
1879 struct ixgb_desc_ring *rx_ring = &adapter->rx_ring;
1880 struct net_device *netdev = adapter->netdev;
1881 struct pci_dev *pdev = adapter->pdev;
1882 struct ixgb_rx_desc *rx_desc, *next_rxd;
1883 struct ixgb_buffer *buffer_info, *next_buffer, *next2_buffer;
1886 boolean_t cleaned = FALSE;
1888 i = rx_ring->next_to_clean;
1889 rx_desc = IXGB_RX_DESC(*rx_ring, i);
1890 buffer_info = &rx_ring->buffer_info[i];
1892 while(rx_desc->status & IXGB_RX_DESC_STATUS_DD) {
1893 struct sk_buff *skb, *next_skb;
1896 #ifdef CONFIG_IXGB_NAPI
1897 if(*work_done >= work_to_do)
1902 status = rx_desc->status;
1903 skb = buffer_info->skb;
1905 prefetch(skb->data);
1907 if(++i == rx_ring->count) i = 0;
1908 next_rxd = IXGB_RX_DESC(*rx_ring, i);
1911 if((j = i + 1) == rx_ring->count) j = 0;
1912 next2_buffer = &rx_ring->buffer_info[j];
1913 prefetch(next2_buffer);
1915 next_buffer = &rx_ring->buffer_info[i];
1916 next_skb = next_buffer->skb;
1921 pci_unmap_single(pdev,
1923 buffer_info->length,
1924 PCI_DMA_FROMDEVICE);
1926 length = le16_to_cpu(rx_desc->length);
1928 if(unlikely(!(status & IXGB_RX_DESC_STATUS_EOP))) {
1930 /* All receives must fit into a single buffer */
1932 IXGB_DBG("Receive packet consumed multiple buffers "
1933 "length<%x>\n", length);
1935 dev_kfree_skb_irq(skb);
1939 if (unlikely(rx_desc->errors
1940 & (IXGB_RX_DESC_ERRORS_CE | IXGB_RX_DESC_ERRORS_SE
1941 | IXGB_RX_DESC_ERRORS_P |
1942 IXGB_RX_DESC_ERRORS_RXE))) {
1944 dev_kfree_skb_irq(skb);
1949 skb_put(skb, length);
1951 /* Receive Checksum Offload */
1952 ixgb_rx_checksum(adapter, rx_desc, skb);
1954 skb->protocol = eth_type_trans(skb, netdev);
1955 #ifdef CONFIG_IXGB_NAPI
1956 if(adapter->vlgrp && (status & IXGB_RX_DESC_STATUS_VP)) {
1957 vlan_hwaccel_receive_skb(skb, adapter->vlgrp,
1958 le16_to_cpu(rx_desc->special) &
1959 IXGB_RX_DESC_SPECIAL_VLAN_MASK);
1961 netif_receive_skb(skb);
1963 #else /* CONFIG_IXGB_NAPI */
1964 if(adapter->vlgrp && (status & IXGB_RX_DESC_STATUS_VP)) {
1965 vlan_hwaccel_rx(skb, adapter->vlgrp,
1966 le16_to_cpu(rx_desc->special) &
1967 IXGB_RX_DESC_SPECIAL_VLAN_MASK);
1971 #endif /* CONFIG_IXGB_NAPI */
1972 netdev->last_rx = jiffies;
1975 /* clean up descriptor, might be written over by hw */
1976 rx_desc->status = 0;
1977 buffer_info->skb = NULL;
1979 /* use prefetched values */
1981 buffer_info = next_buffer;
1984 rx_ring->next_to_clean = i;
1986 ixgb_alloc_rx_buffers(adapter);
1992 * ixgb_alloc_rx_buffers - Replace used receive buffers
1993 * @adapter: address of board private structure
1997 ixgb_alloc_rx_buffers(struct ixgb_adapter *adapter)
1999 struct ixgb_desc_ring *rx_ring = &adapter->rx_ring;
2000 struct net_device *netdev = adapter->netdev;
2001 struct pci_dev *pdev = adapter->pdev;
2002 struct ixgb_rx_desc *rx_desc;
2003 struct ixgb_buffer *buffer_info;
2004 struct sk_buff *skb;
2006 int num_group_tail_writes;
2009 i = rx_ring->next_to_use;
2010 buffer_info = &rx_ring->buffer_info[i];
2011 cleancount = IXGB_DESC_UNUSED(rx_ring);
2013 num_group_tail_writes = IXGB_RX_BUFFER_WRITE;
2015 /* leave three descriptors unused */
2016 while(--cleancount > 2) {
2017 rx_desc = IXGB_RX_DESC(*rx_ring, i);
2019 skb = dev_alloc_skb(adapter->rx_buffer_len + NET_IP_ALIGN);
2021 if(unlikely(!skb)) {
2022 /* Better luck next round */
2026 /* Make buffer alignment 2 beyond a 16 byte boundary
2027 * this will result in a 16 byte aligned IP header after
2028 * the 14 byte MAC header is removed
2030 skb_reserve(skb, NET_IP_ALIGN);
2034 buffer_info->skb = skb;
2035 buffer_info->length = adapter->rx_buffer_len;
2037 pci_map_single(pdev,
2039 adapter->rx_buffer_len,
2040 PCI_DMA_FROMDEVICE);
2042 rx_desc->buff_addr = cpu_to_le64(buffer_info->dma);
2043 /* guarantee DD bit not set now before h/w gets descriptor
2044 * this is the rest of the workaround for h/w double
2046 rx_desc->status = 0;
2048 if((i & ~(num_group_tail_writes- 1)) == i) {
2049 /* Force memory writes to complete before letting h/w
2050 * know there are new descriptors to fetch. (Only
2051 * applicable for weak-ordered memory model archs,
2052 * such as IA-64). */
2055 IXGB_WRITE_REG(&adapter->hw, RDT, i);
2058 if(++i == rx_ring->count) i = 0;
2059 buffer_info = &rx_ring->buffer_info[i];
2062 rx_ring->next_to_use = i;
2066 * ixgb_vlan_rx_register - enables or disables vlan tagging/stripping.
2068 * @param netdev network interface device structure
2069 * @param grp indicates to enable or disable tagging/stripping
2072 ixgb_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp)
2074 struct ixgb_adapter *adapter = netdev_priv(netdev);
2075 uint32_t ctrl, rctl;
2077 ixgb_irq_disable(adapter);
2078 adapter->vlgrp = grp;
2081 /* enable VLAN tag insert/strip */
2082 ctrl = IXGB_READ_REG(&adapter->hw, CTRL0);
2083 ctrl |= IXGB_CTRL0_VME;
2084 IXGB_WRITE_REG(&adapter->hw, CTRL0, ctrl);
2086 /* enable VLAN receive filtering */
2088 rctl = IXGB_READ_REG(&adapter->hw, RCTL);
2089 rctl |= IXGB_RCTL_VFE;
2090 rctl &= ~IXGB_RCTL_CFIEN;
2091 IXGB_WRITE_REG(&adapter->hw, RCTL, rctl);
2093 /* disable VLAN tag insert/strip */
2095 ctrl = IXGB_READ_REG(&adapter->hw, CTRL0);
2096 ctrl &= ~IXGB_CTRL0_VME;
2097 IXGB_WRITE_REG(&adapter->hw, CTRL0, ctrl);
2099 /* disable VLAN filtering */
2101 rctl = IXGB_READ_REG(&adapter->hw, RCTL);
2102 rctl &= ~IXGB_RCTL_VFE;
2103 IXGB_WRITE_REG(&adapter->hw, RCTL, rctl);
2106 ixgb_irq_enable(adapter);
2110 ixgb_vlan_rx_add_vid(struct net_device *netdev, uint16_t vid)
2112 struct ixgb_adapter *adapter = netdev_priv(netdev);
2113 uint32_t vfta, index;
2115 /* add VID to filter table */
2117 index = (vid >> 5) & 0x7F;
2118 vfta = IXGB_READ_REG_ARRAY(&adapter->hw, VFTA, index);
2119 vfta |= (1 << (vid & 0x1F));
2120 ixgb_write_vfta(&adapter->hw, index, vfta);
2124 ixgb_vlan_rx_kill_vid(struct net_device *netdev, uint16_t vid)
2126 struct ixgb_adapter *adapter = netdev_priv(netdev);
2127 uint32_t vfta, index;
2129 ixgb_irq_disable(adapter);
2132 adapter->vlgrp->vlan_devices[vid] = NULL;
2134 ixgb_irq_enable(adapter);
2136 /* remove VID from filter table*/
2138 index = (vid >> 5) & 0x7F;
2139 vfta = IXGB_READ_REG_ARRAY(&adapter->hw, VFTA, index);
2140 vfta &= ~(1 << (vid & 0x1F));
2141 ixgb_write_vfta(&adapter->hw, index, vfta);
2145 ixgb_restore_vlan(struct ixgb_adapter *adapter)
2147 ixgb_vlan_rx_register(adapter->netdev, adapter->vlgrp);
2149 if(adapter->vlgrp) {
2151 for(vid = 0; vid < VLAN_GROUP_ARRAY_LEN; vid++) {
2152 if(!adapter->vlgrp->vlan_devices[vid])
2154 ixgb_vlan_rx_add_vid(adapter->netdev, vid);
2159 #ifdef CONFIG_NET_POLL_CONTROLLER
2161 * Polling 'interrupt' - used by things like netconsole to send skbs
2162 * without having to re-enable interrupts. It's not called while
2163 * the interrupt routine is executing.
2166 static void ixgb_netpoll(struct net_device *dev)
2168 struct ixgb_adapter *adapter = dev->priv;
2170 disable_irq(adapter->pdev->irq);
2171 ixgb_intr(adapter->pdev->irq, dev, NULL);
2172 enable_irq(adapter->pdev->irq);