1 /*******************************************************************************
4 Copyright(c) 1999 - 2004 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 *******************************************************************************/
31 char ixgb_driver_name[] = "ixgb";
32 char ixgb_driver_string[] = "Intel(R) PRO/10GbE Network Driver";
33 #define DRV_VERSION "1.0.66"
34 char ixgb_driver_version[] = DRV_VERSION;
35 char ixgb_copyright[] = "Copyright (c) 2001-2004 Intel Corporation.";
37 /* ixgb_pci_tbl - PCI Device ID Table
39 * Wildcard entries (PCI_ANY_ID) should come last
40 * Last entry must be all 0s
42 * { Vendor ID, Device ID, SubVendor ID, SubDevice ID,
43 * Class, Class Mask, private data (not used) }
45 static struct pci_device_id ixgb_pci_tbl[] = {
46 {INTEL_VENDOR_ID, IXGB_DEVICE_ID_82597EX,
47 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
48 {INTEL_VENDOR_ID, IXGB_DEVICE_ID_82597EX_SR,
49 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
51 /* required last entry */
55 MODULE_DEVICE_TABLE(pci, ixgb_pci_tbl);
57 /* Local Function Prototypes */
59 static inline void ixgb_irq_disable(struct ixgb_adapter *adapter);
60 static inline void ixgb_irq_enable(struct ixgb_adapter *adapter);
61 int ixgb_up(struct ixgb_adapter *adapter);
62 void ixgb_down(struct ixgb_adapter *adapter, boolean_t kill_watchdog);
63 void ixgb_reset(struct ixgb_adapter *adapter);
65 static int ixgb_init_module(void);
66 static void ixgb_exit_module(void);
67 static int ixgb_probe(struct pci_dev *pdev, const struct pci_device_id *ent);
68 static void __devexit ixgb_remove(struct pci_dev *pdev);
69 static int ixgb_sw_init(struct ixgb_adapter *adapter);
70 static int ixgb_open(struct net_device *netdev);
71 static int ixgb_close(struct net_device *netdev);
72 static int ixgb_setup_tx_resources(struct ixgb_adapter *adapter);
73 static int ixgb_setup_rx_resources(struct ixgb_adapter *adapter);
74 static void ixgb_configure_tx(struct ixgb_adapter *adapter);
75 static void ixgb_configure_rx(struct ixgb_adapter *adapter);
76 static void ixgb_setup_rctl(struct ixgb_adapter *adapter);
77 static void ixgb_clean_tx_ring(struct ixgb_adapter *adapter);
78 static void ixgb_clean_rx_ring(struct ixgb_adapter *adapter);
79 static void ixgb_free_tx_resources(struct ixgb_adapter *adapter);
80 static void ixgb_free_rx_resources(struct ixgb_adapter *adapter);
81 static void ixgb_set_multi(struct net_device *netdev);
82 static void ixgb_watchdog(unsigned long data);
83 static int ixgb_xmit_frame(struct sk_buff *skb, struct net_device *netdev);
84 static struct net_device_stats *ixgb_get_stats(struct net_device *netdev);
85 static int ixgb_change_mtu(struct net_device *netdev, int new_mtu);
86 static int ixgb_set_mac(struct net_device *netdev, void *p);
87 static void ixgb_update_stats(struct ixgb_adapter *adapter);
88 static irqreturn_t ixgb_intr(int irq, void *data, struct pt_regs *regs);
89 static boolean_t ixgb_clean_tx_irq(struct ixgb_adapter *adapter);
90 static inline void ixgb_rx_checksum(struct ixgb_adapter *adapter,
91 struct ixgb_rx_desc *rx_desc,
93 #ifdef CONFIG_IXGB_NAPI
94 static int ixgb_clean(struct net_device *netdev, int *budget);
95 static boolean_t ixgb_clean_rx_irq(struct ixgb_adapter *adapter,
96 int *work_done, int work_to_do);
98 static boolean_t ixgb_clean_rx_irq(struct ixgb_adapter *adapter);
100 static void ixgb_alloc_rx_buffers(struct ixgb_adapter *adapter);
101 static int ixgb_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd);
102 static void ixgb_tx_timeout(struct net_device *dev);
103 static void ixgb_tx_timeout_task(struct net_device *dev);
104 static void ixgb_vlan_rx_register(struct net_device *netdev,
105 struct vlan_group *grp);
106 static void ixgb_vlan_rx_add_vid(struct net_device *netdev, uint16_t vid);
107 static void ixgb_vlan_rx_kill_vid(struct net_device *netdev, uint16_t vid);
108 static void ixgb_restore_vlan(struct ixgb_adapter *adapter);
110 static int ixgb_notify_reboot(struct notifier_block *, unsigned long event,
112 static int ixgb_suspend(struct pci_dev *pdev, uint32_t state);
114 #ifdef CONFIG_NET_POLL_CONTROLLER
115 /* for netdump / net console */
116 static void ixgb_netpoll(struct net_device *dev);
119 struct notifier_block ixgb_notifier_reboot = {
120 .notifier_call = ixgb_notify_reboot,
125 /* Exported from other modules */
127 extern void ixgb_check_options(struct ixgb_adapter *adapter);
128 extern int ixgb_ethtool_ioctl(struct net_device *netdev, struct ifreq *ifr);
130 static struct pci_driver ixgb_driver = {
131 .name = ixgb_driver_name,
132 .id_table = ixgb_pci_tbl,
134 .remove = __devexit_p(ixgb_remove),
135 /* Power Managment Hooks */
140 MODULE_AUTHOR("Intel Corporation, <linux.nics@intel.com>");
141 MODULE_DESCRIPTION("Intel(R) PRO/10GbE Network Driver");
142 MODULE_LICENSE("GPL");
143 MODULE_VERSION(DRV_VERSION);
145 /* some defines for controlling descriptor fetches in h/w */
146 #define RXDCTL_PTHRESH_DEFAULT 128 /* chip considers prefech below this */
147 #define RXDCTL_HTHRESH_DEFAULT 16 /* chip will only prefetch if tail is
148 pushed this many descriptors from head */
149 #define RXDCTL_WTHRESH_DEFAULT 16 /* chip writes back at this many or RXT0 */
152 * ixgb_init_module - Driver Registration Routine
154 * ixgb_init_module is the first routine called when the driver is
155 * loaded. All it does is register with the PCI subsystem.
158 static int __init ixgb_init_module(void)
161 printk(KERN_INFO "%s - version %s\n",
162 ixgb_driver_string, ixgb_driver_version);
164 printk(KERN_INFO "%s\n", ixgb_copyright);
166 ret = pci_module_init(&ixgb_driver);
168 register_reboot_notifier(&ixgb_notifier_reboot);
173 module_init(ixgb_init_module);
176 * ixgb_exit_module - Driver Exit Cleanup Routine
178 * ixgb_exit_module is called just before the driver is removed
182 static void __exit ixgb_exit_module(void)
184 unregister_reboot_notifier(&ixgb_notifier_reboot);
185 pci_unregister_driver(&ixgb_driver);
188 module_exit(ixgb_exit_module);
191 * ixgb_irq_disable - Mask off interrupt generation on the NIC
192 * @adapter: board private structure
195 static inline void ixgb_irq_disable(struct ixgb_adapter *adapter)
197 atomic_inc(&adapter->irq_sem);
198 IXGB_WRITE_REG(&adapter->hw, IMC, ~0);
199 IXGB_WRITE_FLUSH(&adapter->hw);
200 synchronize_irq(adapter->pdev->irq);
204 * ixgb_irq_enable - Enable default interrupt generation settings
205 * @adapter: board private structure
208 static inline void ixgb_irq_enable(struct ixgb_adapter *adapter)
210 if (atomic_dec_and_test(&adapter->irq_sem)) {
211 IXGB_WRITE_REG(&adapter->hw, IMS,
212 IXGB_INT_RXT0 | IXGB_INT_RXDMT0 | IXGB_INT_TXDW |
213 IXGB_INT_RXO | IXGB_INT_LSC);
214 IXGB_WRITE_FLUSH(&adapter->hw);
218 int ixgb_up(struct ixgb_adapter *adapter)
220 struct net_device *netdev = adapter->netdev;
222 int max_frame = netdev->mtu + ENET_HEADER_SIZE + ENET_FCS_LENGTH;
223 struct ixgb_hw *hw = &adapter->hw;
225 /* hardware has been reset, we need to reload some things */
227 ixgb_set_multi(netdev);
229 ixgb_restore_vlan(adapter);
231 ixgb_configure_tx(adapter);
232 ixgb_setup_rctl(adapter);
233 ixgb_configure_rx(adapter);
234 ixgb_alloc_rx_buffers(adapter);
236 if ((err = request_irq(adapter->pdev->irq, &ixgb_intr,
237 SA_SHIRQ | SA_SAMPLE_RANDOM,
238 netdev->name, netdev)))
241 /* disable interrupts and get the hardware into a known state */
242 IXGB_WRITE_REG(&adapter->hw, IMC, 0xffffffff);
244 if ((hw->max_frame_size != max_frame) ||
245 (hw->max_frame_size !=
246 (IXGB_READ_REG(hw, MFS) >> IXGB_MFS_SHIFT))) {
248 hw->max_frame_size = max_frame;
250 IXGB_WRITE_REG(hw, MFS, hw->max_frame_size << IXGB_MFS_SHIFT);
252 if (hw->max_frame_size >
253 IXGB_MAX_ENET_FRAME_SIZE_WITHOUT_FCS + ENET_FCS_LENGTH) {
254 uint32_t ctrl0 = IXGB_READ_REG(hw, CTRL0);
256 if (!(ctrl0 & IXGB_CTRL0_JFE)) {
257 ctrl0 |= IXGB_CTRL0_JFE;
258 IXGB_WRITE_REG(hw, CTRL0, ctrl0);
263 mod_timer(&adapter->watchdog_timer, jiffies);
264 ixgb_irq_enable(adapter);
269 void ixgb_down(struct ixgb_adapter *adapter, boolean_t kill_watchdog)
271 struct net_device *netdev = adapter->netdev;
273 ixgb_irq_disable(adapter);
274 free_irq(adapter->pdev->irq, netdev);
276 del_timer_sync(&adapter->watchdog_timer);
277 adapter->link_speed = 0;
278 adapter->link_duplex = 0;
279 netif_carrier_off(netdev);
280 netif_stop_queue(netdev);
283 ixgb_clean_tx_ring(adapter);
284 ixgb_clean_rx_ring(adapter);
287 void ixgb_reset(struct ixgb_adapter *adapter)
290 ixgb_adapter_stop(&adapter->hw);
291 if (!ixgb_init_hw(&adapter->hw))
292 IXGB_DBG("ixgb_init_hw failed.\n");
296 * ixgb_probe - Device Initialization Routine
297 * @pdev: PCI device information struct
298 * @ent: entry in ixgb_pci_tbl
300 * Returns 0 on success, negative on failure
302 * ixgb_probe initializes an adapter identified by a pci_dev structure.
303 * The OS initialization, configuring of the adapter private structure,
304 * and a hardware reset occur.
308 ixgb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
310 struct net_device *netdev = NULL;
311 struct ixgb_adapter *adapter;
312 static int cards_found = 0;
313 unsigned long mmio_start;
319 if ((err = pci_enable_device(pdev)))
322 if (!(err = pci_set_dma_mask(pdev, DMA_64BIT_MASK))) {
325 if ((err = pci_set_dma_mask(pdev, DMA_32BIT_MASK))) {
326 IXGB_ERR("No usable DMA configuration, aborting\n");
332 if ((err = pci_request_regions(pdev, ixgb_driver_name)))
335 pci_set_master(pdev);
337 netdev = alloc_etherdev(sizeof(struct ixgb_adapter));
340 goto err_alloc_etherdev;
343 SET_MODULE_OWNER(netdev);
344 SET_NETDEV_DEV(netdev, &pdev->dev);
346 pci_set_drvdata(pdev, netdev);
347 adapter = netdev->priv;
348 adapter->netdev = netdev;
349 adapter->pdev = pdev;
350 adapter->hw.back = adapter;
352 mmio_start = pci_resource_start(pdev, BAR_0);
353 mmio_len = pci_resource_len(pdev, BAR_0);
355 adapter->hw.hw_addr = ioremap(mmio_start, mmio_len);
356 if (!adapter->hw.hw_addr) {
361 for (i = BAR_1; i <= BAR_5; i++) {
362 if (pci_resource_len(pdev, i) == 0)
364 if (pci_resource_flags(pdev, i) & IORESOURCE_IO) {
365 adapter->hw.io_base = pci_resource_start(pdev, i);
370 netdev->open = &ixgb_open;
371 netdev->stop = &ixgb_close;
372 netdev->hard_start_xmit = &ixgb_xmit_frame;
373 netdev->get_stats = &ixgb_get_stats;
374 netdev->set_multicast_list = &ixgb_set_multi;
375 netdev->set_mac_address = &ixgb_set_mac;
376 netdev->change_mtu = &ixgb_change_mtu;
377 netdev->do_ioctl = &ixgb_ioctl;
378 netdev->tx_timeout = &ixgb_tx_timeout;
379 netdev->watchdog_timeo = HZ;
380 #ifdef CONFIG_IXGB_NAPI
381 netdev->poll = &ixgb_clean;
384 netdev->vlan_rx_register = ixgb_vlan_rx_register;
385 netdev->vlan_rx_add_vid = ixgb_vlan_rx_add_vid;
386 netdev->vlan_rx_kill_vid = ixgb_vlan_rx_kill_vid;
387 #ifdef CONFIG_NET_POLL_CONTROLLER
388 netdev->poll_controller = ixgb_netpoll;
391 netdev->mem_start = mmio_start;
392 netdev->mem_end = mmio_start + mmio_len;
393 netdev->base_addr = adapter->hw.io_base;
395 adapter->bd_number = cards_found;
396 adapter->link_speed = 0;
397 adapter->link_duplex = 0;
399 /* setup the private structure */
401 if ((err = ixgb_sw_init(adapter)))
404 netdev->features = NETIF_F_SG |
406 NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX | NETIF_F_HW_VLAN_FILTER;
408 netdev->features |= NETIF_F_TSO;
412 netdev->features |= NETIF_F_HIGHDMA;
414 /* make sure the EEPROM is good */
416 if (!ixgb_validate_eeprom_checksum(&adapter->hw)) {
417 printk(KERN_ERR "The EEPROM Checksum Is Not Valid\n");
422 ixgb_get_ee_mac_addr(&adapter->hw, netdev->dev_addr);
424 if (!is_valid_ether_addr(netdev->dev_addr)) {
429 adapter->part_num = ixgb_get_ee_pba_number(&adapter->hw);
431 init_timer(&adapter->watchdog_timer);
432 adapter->watchdog_timer.function = &ixgb_watchdog;
433 adapter->watchdog_timer.data = (unsigned long)adapter;
435 INIT_WORK(&adapter->tx_timeout_task,
436 (void (*)(void *))ixgb_tx_timeout_task, netdev);
438 if ((err = register_netdev(netdev)))
441 /* we're going to reset, so assume we have no link for now */
443 netif_carrier_off(netdev);
444 netif_stop_queue(netdev);
446 printk(KERN_INFO "%s: Intel(R) PRO/10GbE Network Connection\n",
448 ixgb_check_options(adapter);
449 /* reset the hardware with the new settings */
459 iounmap(adapter->hw.hw_addr);
463 pci_release_regions(pdev);
468 * ixgb_remove - Device Removal Routine
469 * @pdev: PCI device information struct
471 * ixgb_remove is called by the PCI subsystem to alert the driver
472 * that it should release a PCI device. The could be caused by a
473 * Hot-Plug event, or because the driver is going to be removed from
477 static void __devexit ixgb_remove(struct pci_dev *pdev)
479 struct net_device *netdev = pci_get_drvdata(pdev);
480 struct ixgb_adapter *adapter = netdev->priv;
482 unregister_netdev(netdev);
484 iounmap(adapter->hw.hw_addr);
485 pci_release_regions(pdev);
491 * ixgb_sw_init - Initialize general software structures (struct ixgb_adapter)
492 * @adapter: board private structure to initialize
494 * ixgb_sw_init initializes the Adapter private data structure.
495 * Fields are initialized based on PCI device information and
496 * OS network device settings (MTU size).
499 static int __devinit ixgb_sw_init(struct ixgb_adapter *adapter)
501 struct ixgb_hw *hw = &adapter->hw;
502 struct net_device *netdev = adapter->netdev;
503 struct pci_dev *pdev = adapter->pdev;
505 /* PCI config space info */
507 hw->vendor_id = pdev->vendor;
508 hw->device_id = pdev->device;
509 hw->subsystem_vendor_id = pdev->subsystem_vendor;
510 hw->subsystem_id = pdev->subsystem_device;
512 adapter->rx_buffer_len = IXGB_RXBUFFER_2048;
514 hw->max_frame_size = netdev->mtu + ENET_HEADER_SIZE + ENET_FCS_LENGTH;
516 if ((hw->device_id == IXGB_DEVICE_ID_82597EX)
517 || (hw->device_id == IXGB_DEVICE_ID_82597EX_SR))
518 hw->mac_type = ixgb_82597;
520 /* should never have loaded on this device */
521 printk(KERN_ERR "ixgb: unsupported device id\n");
524 /* enable flow control to be programmed */
527 atomic_set(&adapter->irq_sem, 1);
528 spin_lock_init(&adapter->tx_lock);
534 * ixgb_open - Called when a network interface is made active
535 * @netdev: network interface device structure
537 * Returns 0 on success, negative value on failure
539 * The open entry point is called when a network interface is made
540 * active by the system (IFF_UP). At this point all resources needed
541 * for transmit and receive operations are allocated, the interrupt
542 * handler is registered with the OS, the watchdog timer is started,
543 * and the stack is notified that the interface is ready.
546 static int ixgb_open(struct net_device *netdev)
548 struct ixgb_adapter *adapter = netdev->priv;
551 /* allocate transmit descriptors */
553 if ((err = ixgb_setup_tx_resources(adapter)))
556 /* allocate receive descriptors */
558 if ((err = ixgb_setup_rx_resources(adapter)))
561 if ((err = ixgb_up(adapter)))
567 ixgb_free_rx_resources(adapter);
569 ixgb_free_tx_resources(adapter);
577 * ixgb_close - Disables a network interface
578 * @netdev: network interface device structure
580 * Returns 0, this is not allowed to fail
582 * The close entry point is called when an interface is de-activated
583 * by the OS. The hardware is still under the drivers control, but
584 * needs to be disabled. A global MAC reset is issued to stop the
585 * hardware, and all transmit and receive resources are freed.
588 static int ixgb_close(struct net_device *netdev)
590 struct ixgb_adapter *adapter = netdev->priv;
592 ixgb_down(adapter, TRUE);
594 ixgb_free_tx_resources(adapter);
595 ixgb_free_rx_resources(adapter);
601 * ixgb_setup_tx_resources - allocate Tx resources (Descriptors)
602 * @adapter: board private structure
604 * Return 0 on success, negative on failure
607 static int ixgb_setup_tx_resources(struct ixgb_adapter *adapter)
609 struct ixgb_desc_ring *txdr = &adapter->tx_ring;
610 struct pci_dev *pdev = adapter->pdev;
613 size = sizeof(struct ixgb_buffer) * txdr->count;
614 txdr->buffer_info = kmalloc(size, GFP_KERNEL);
615 if (!txdr->buffer_info) {
618 memset(txdr->buffer_info, 0, size);
620 /* round up to nearest 4K */
622 txdr->size = txdr->count * sizeof(struct ixgb_tx_desc);
623 IXGB_ROUNDUP(txdr->size, 4096);
625 txdr->desc = pci_alloc_consistent(pdev, txdr->size, &txdr->dma);
627 kfree(txdr->buffer_info);
630 memset(txdr->desc, 0, txdr->size);
632 txdr->next_to_use = 0;
633 txdr->next_to_clean = 0;
639 * ixgb_configure_tx - Configure 82597 Transmit Unit after Reset.
640 * @adapter: board private structure
642 * Configure the Tx unit of the MAC after a reset.
645 static void ixgb_configure_tx(struct ixgb_adapter *adapter)
647 uint64_t tdba = adapter->tx_ring.dma;
648 uint32_t tdlen = adapter->tx_ring.count * sizeof(struct ixgb_tx_desc);
650 struct ixgb_hw *hw = &adapter->hw;
652 /* Setup the Base and Length of the Tx Descriptor Ring
653 * tx_ring.dma can be either a 32 or 64 bit value
656 IXGB_WRITE_REG(hw, TDBAL, (tdba & 0x00000000ffffffffULL));
657 IXGB_WRITE_REG(hw, TDBAH, (tdba >> 32));
659 IXGB_WRITE_REG(hw, TDLEN, tdlen);
661 /* Setup the HW Tx Head and Tail descriptor pointers */
663 IXGB_WRITE_REG(hw, TDH, 0);
664 IXGB_WRITE_REG(hw, TDT, 0);
666 /* don't set up txdctl, it induces performance problems if
667 * configured incorrectly
668 txdctl = TXDCTL_PTHRESH_DEFAULT; // prefetch txds below this threshold
669 txdctl |= (TXDCTL_HTHRESH_DEFAULT // only prefetch if there are this many ready
670 << IXGB_TXDCTL_HTHRESH_SHIFT);
671 IXGB_WRITE_REG (hw, TXDCTL, txdctl);
674 /* Set the Tx Interrupt Delay register */
676 IXGB_WRITE_REG(hw, TIDV, adapter->tx_int_delay);
678 /* Program the Transmit Control Register */
680 tctl = IXGB_TCTL_TCE | IXGB_TCTL_TXEN | IXGB_TCTL_TPDE;
681 IXGB_WRITE_REG(hw, TCTL, tctl);
683 /* Setup Transmit Descriptor Settings for this adapter */
684 adapter->tx_cmd_type =
686 | (adapter->tx_int_delay_enable ? IXGB_TX_DESC_CMD_IDE : 0);
690 * ixgb_setup_rx_resources - allocate Rx resources (Descriptors)
691 * @adapter: board private structure
693 * Returns 0 on success, negative on failure
696 static int ixgb_setup_rx_resources(struct ixgb_adapter *adapter)
698 struct ixgb_desc_ring *rxdr = &adapter->rx_ring;
699 struct pci_dev *pdev = adapter->pdev;
702 size = sizeof(struct ixgb_buffer) * rxdr->count;
703 rxdr->buffer_info = kmalloc(size, GFP_KERNEL);
704 if (!rxdr->buffer_info) {
707 memset(rxdr->buffer_info, 0, size);
709 /* Round up to nearest 4K */
711 rxdr->size = rxdr->count * sizeof(struct ixgb_rx_desc);
712 IXGB_ROUNDUP(rxdr->size, 4096);
714 rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma);
717 kfree(rxdr->buffer_info);
720 memset(rxdr->desc, 0, rxdr->size);
722 rxdr->next_to_clean = 0;
723 rxdr->next_to_use = 0;
729 * ixgb_setup_rctl - configure the receive control register
730 * @adapter: Board private structure
733 static void ixgb_setup_rctl(struct ixgb_adapter *adapter)
737 rctl = IXGB_READ_REG(&adapter->hw, RCTL);
739 rctl &= ~(3 << IXGB_RCTL_MO_SHIFT);
742 IXGB_RCTL_BAM | IXGB_RCTL_RDMTS_1_2 |
743 IXGB_RCTL_RXEN | IXGB_RCTL_CFF |
744 (adapter->hw.mc_filter_type << IXGB_RCTL_MO_SHIFT);
746 rctl |= IXGB_RCTL_SECRC;
748 switch (adapter->rx_buffer_len) {
749 case IXGB_RXBUFFER_2048:
751 rctl |= IXGB_RCTL_BSIZE_2048;
753 case IXGB_RXBUFFER_4096:
754 rctl |= IXGB_RCTL_BSIZE_4096;
756 case IXGB_RXBUFFER_8192:
757 rctl |= IXGB_RCTL_BSIZE_8192;
759 case IXGB_RXBUFFER_16384:
760 rctl |= IXGB_RCTL_BSIZE_16384;
764 IXGB_WRITE_REG(&adapter->hw, RCTL, rctl);
768 * ixgb_configure_rx - Configure 82597 Receive Unit after Reset.
769 * @adapter: board private structure
771 * Configure the Rx unit of the MAC after a reset.
774 static void ixgb_configure_rx(struct ixgb_adapter *adapter)
776 uint64_t rdba = adapter->rx_ring.dma;
777 uint32_t rdlen = adapter->rx_ring.count * sizeof(struct ixgb_rx_desc);
778 struct ixgb_hw *hw = &adapter->hw;
783 /* make sure receives are disabled while setting up the descriptors */
785 rctl = IXGB_READ_REG(hw, RCTL);
786 IXGB_WRITE_REG(hw, RCTL, rctl & ~IXGB_RCTL_RXEN);
788 /* set the Receive Delay Timer Register */
790 IXGB_WRITE_REG(hw, RDTR, adapter->rx_int_delay);
792 /* Setup the Base and Length of the Rx Descriptor Ring */
794 IXGB_WRITE_REG(hw, RDBAL, (rdba & 0x00000000ffffffffULL));
795 IXGB_WRITE_REG(hw, RDBAH, (rdba >> 32));
797 IXGB_WRITE_REG(hw, RDLEN, rdlen);
799 /* Setup the HW Rx Head and Tail Descriptor Pointers */
800 IXGB_WRITE_REG(hw, RDH, 0);
801 IXGB_WRITE_REG(hw, RDT, 0);
803 /* burst 16 or burst when RXT0 */
804 rxdctl = RXDCTL_WTHRESH_DEFAULT << IXGB_RXDCTL_WTHRESH_SHIFT
805 | RXDCTL_HTHRESH_DEFAULT << IXGB_RXDCTL_HTHRESH_SHIFT
806 | RXDCTL_PTHRESH_DEFAULT << IXGB_RXDCTL_PTHRESH_SHIFT;
807 IXGB_WRITE_REG(hw, RXDCTL, rxdctl);
809 if (adapter->raidc) {
811 uint8_t poll_threshold;
813 /* Poll every rx_int_delay period, if RBD exists
814 * Receive Backlog Detection is set to <threshold>
816 * max is 0x3F == set to poll when 504 RxDesc left
819 /* polling times are 1 == 0.8192us
825 #define IXGB_RAIDC_POLL_DEFAULT 122 /* set to poll every ~100 us under load
826 also known as 10000 interrupts / sec */
828 /* divide this by 2^3 (8) to get a register size count */
829 poll_threshold = ((adapter->rx_ring.count - 1) >> 3);
830 /* poll at half of that size */
831 poll_threshold >>= 1;
832 /* make sure its not bigger than our max */
833 poll_threshold &= 0x3F;
835 raidc = IXGB_RAIDC_EN | /* turn on raidc style moderation */
836 IXGB_RAIDC_RXT_GATE | /* don't interrupt with rxt0 while
837 in RBD mode (polling) */
838 (IXGB_RAIDC_POLL_DEFAULT << IXGB_RAIDC_POLL_SHIFT) |
839 /* this sets the regular "min interrupt delay" */
840 (adapter->rx_int_delay << IXGB_RAIDC_DELAY_SHIFT) |
843 IXGB_WRITE_REG(hw, RAIDC, raidc);
846 /* Enable Receive Checksum Offload for TCP and UDP */
847 if (adapter->rx_csum == TRUE) {
848 rxcsum = IXGB_READ_REG(hw, RXCSUM);
849 rxcsum |= IXGB_RXCSUM_TUOFL;
850 IXGB_WRITE_REG(hw, RXCSUM, rxcsum);
853 /* Enable Receives */
855 IXGB_WRITE_REG(hw, RCTL, rctl);
859 * ixgb_free_tx_resources - Free Tx Resources
860 * @adapter: board private structure
862 * Free all transmit software resources
865 static void ixgb_free_tx_resources(struct ixgb_adapter *adapter)
867 struct pci_dev *pdev = adapter->pdev;
869 ixgb_clean_tx_ring(adapter);
871 kfree(adapter->tx_ring.buffer_info);
872 adapter->tx_ring.buffer_info = NULL;
874 pci_free_consistent(pdev, adapter->tx_ring.size,
875 adapter->tx_ring.desc, adapter->tx_ring.dma);
877 adapter->tx_ring.desc = NULL;
881 * ixgb_clean_tx_ring - Free Tx Buffers
882 * @adapter: board private structure
885 static void ixgb_clean_tx_ring(struct ixgb_adapter *adapter)
887 struct ixgb_desc_ring *tx_ring = &adapter->tx_ring;
888 struct ixgb_buffer *buffer_info;
889 struct pci_dev *pdev = adapter->pdev;
893 /* Free all the Tx ring sk_buffs */
895 for (i = 0; i < tx_ring->count; i++) {
896 buffer_info = &tx_ring->buffer_info[i];
897 if (buffer_info->skb) {
901 buffer_info->length, PCI_DMA_TODEVICE);
903 dev_kfree_skb(buffer_info->skb);
905 buffer_info->skb = NULL;
909 size = sizeof(struct ixgb_buffer) * tx_ring->count;
910 memset(tx_ring->buffer_info, 0, size);
912 /* Zero out the descriptor ring */
914 memset(tx_ring->desc, 0, tx_ring->size);
916 tx_ring->next_to_use = 0;
917 tx_ring->next_to_clean = 0;
919 IXGB_WRITE_REG(&adapter->hw, TDH, 0);
920 IXGB_WRITE_REG(&adapter->hw, TDT, 0);
924 * ixgb_free_rx_resources - Free Rx Resources
925 * @adapter: board private structure
927 * Free all receive software resources
930 static void ixgb_free_rx_resources(struct ixgb_adapter *adapter)
932 struct ixgb_desc_ring *rx_ring = &adapter->rx_ring;
933 struct pci_dev *pdev = adapter->pdev;
935 ixgb_clean_rx_ring(adapter);
937 kfree(rx_ring->buffer_info);
938 rx_ring->buffer_info = NULL;
940 pci_free_consistent(pdev, rx_ring->size, rx_ring->desc, rx_ring->dma);
942 rx_ring->desc = NULL;
946 * ixgb_clean_rx_ring - Free Rx Buffers
947 * @adapter: board private structure
950 static void ixgb_clean_rx_ring(struct ixgb_adapter *adapter)
952 struct ixgb_desc_ring *rx_ring = &adapter->rx_ring;
953 struct ixgb_buffer *buffer_info;
954 struct pci_dev *pdev = adapter->pdev;
958 /* Free all the Rx ring sk_buffs */
960 for (i = 0; i < rx_ring->count; i++) {
961 buffer_info = &rx_ring->buffer_info[i];
962 if (buffer_info->skb) {
964 pci_unmap_single(pdev,
969 dev_kfree_skb(buffer_info->skb);
971 buffer_info->skb = NULL;
975 size = sizeof(struct ixgb_buffer) * rx_ring->count;
976 memset(rx_ring->buffer_info, 0, size);
978 /* Zero out the descriptor ring */
980 memset(rx_ring->desc, 0, rx_ring->size);
982 rx_ring->next_to_clean = 0;
983 rx_ring->next_to_use = 0;
985 IXGB_WRITE_REG(&adapter->hw, RDH, 0);
986 IXGB_WRITE_REG(&adapter->hw, RDT, 0);
990 * ixgb_set_mac - Change the Ethernet Address of the NIC
991 * @netdev: network interface device structure
992 * @p: pointer to an address structure
994 * Returns 0 on success, negative on failure
997 static int ixgb_set_mac(struct net_device *netdev, void *p)
999 struct ixgb_adapter *adapter = netdev->priv;
1000 struct sockaddr *addr = p;
1002 if (!is_valid_ether_addr(addr->sa_data))
1003 return -EADDRNOTAVAIL;
1005 memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
1007 ixgb_rar_set(&adapter->hw, addr->sa_data, 0);
1013 * ixgb_set_multi - Multicast and Promiscuous mode set
1014 * @netdev: network interface device structure
1016 * The set_multi entry point is called whenever the multicast address
1017 * list or the network interface flags are updated. This routine is
1018 * responsible for configuring the hardware for proper multicast,
1019 * promiscuous mode, and all-multi behavior.
1022 static void ixgb_set_multi(struct net_device *netdev)
1024 struct ixgb_adapter *adapter = netdev->priv;
1025 struct ixgb_hw *hw = &adapter->hw;
1026 struct dev_mc_list *mc_ptr;
1030 /* Check for Promiscuous and All Multicast modes */
1032 rctl = IXGB_READ_REG(hw, RCTL);
1034 if (netdev->flags & IFF_PROMISC) {
1035 rctl |= (IXGB_RCTL_UPE | IXGB_RCTL_MPE);
1036 } else if (netdev->flags & IFF_ALLMULTI) {
1037 rctl |= IXGB_RCTL_MPE;
1038 rctl &= ~IXGB_RCTL_UPE;
1040 rctl &= ~(IXGB_RCTL_UPE | IXGB_RCTL_MPE);
1043 if (netdev->mc_count > IXGB_MAX_NUM_MULTICAST_ADDRESSES) {
1044 rctl |= IXGB_RCTL_MPE;
1045 IXGB_WRITE_REG(hw, RCTL, rctl);
1047 uint8_t mta[netdev->mc_count * IXGB_ETH_LENGTH_OF_ADDRESS];
1049 IXGB_WRITE_REG(hw, RCTL, rctl);
1051 for (i = 0, mc_ptr = netdev->mc_list; mc_ptr;
1052 i++, mc_ptr = mc_ptr->next)
1053 memcpy(&mta[i * IXGB_ETH_LENGTH_OF_ADDRESS],
1054 mc_ptr->dmi_addr, IXGB_ETH_LENGTH_OF_ADDRESS);
1056 ixgb_mc_addr_list_update(hw, mta, netdev->mc_count, 0);
1061 * ixgb_watchdog - Timer Call-back
1062 * @data: pointer to netdev cast into an unsigned long
1065 static void ixgb_watchdog(unsigned long data)
1067 struct ixgb_adapter *adapter = (struct ixgb_adapter *)data;
1068 struct net_device *netdev = adapter->netdev;
1069 struct ixgb_desc_ring *txdr = &adapter->tx_ring;
1072 ixgb_check_for_link(&adapter->hw);
1074 if (ixgb_check_for_bad_link(&adapter->hw)) {
1075 /* force the reset path */
1076 netif_stop_queue(netdev);
1079 if (adapter->hw.link_up) {
1080 if (!netif_carrier_ok(netdev)) {
1081 printk(KERN_INFO "ixgb: %s NIC Link is Up %d Mbps %s\n",
1082 netdev->name, 10000, "Full Duplex");
1083 adapter->link_speed = 10000;
1084 adapter->link_duplex = FULL_DUPLEX;
1085 netif_carrier_on(netdev);
1086 netif_wake_queue(netdev);
1089 if (netif_carrier_ok(netdev)) {
1090 adapter->link_speed = 0;
1091 adapter->link_duplex = 0;
1093 "ixgb: %s NIC Link is Down\n", netdev->name);
1094 netif_carrier_off(netdev);
1095 netif_stop_queue(netdev);
1100 ixgb_update_stats(adapter);
1102 if (!netif_carrier_ok(netdev)) {
1103 if (IXGB_DESC_UNUSED(txdr) + 1 < txdr->count) {
1104 /* We've lost link, so the controller stops DMA,
1105 * but we've got queued Tx work that's never going
1106 * to get done, so reset controller to flush Tx.
1107 * (Do the reset outside of interrupt context). */
1108 schedule_work(&adapter->tx_timeout_task);
1112 /* Early detection of hung controller */
1113 i = txdr->next_to_clean;
1114 if (txdr->buffer_info[i].dma &&
1115 time_after(jiffies, txdr->buffer_info[i].time_stamp + HZ) &&
1116 !(IXGB_READ_REG(&adapter->hw, STATUS) & IXGB_STATUS_TXOFF))
1117 netif_stop_queue(netdev);
1119 /* generate an interrupt to force clean up of any stragglers */
1120 IXGB_WRITE_REG(&adapter->hw, ICS, IXGB_INT_TXDW);
1122 /* Reset the timer */
1123 mod_timer(&adapter->watchdog_timer, jiffies + 2 * HZ);
1126 #define IXGB_TX_FLAGS_CSUM 0x00000001
1127 #define IXGB_TX_FLAGS_VLAN 0x00000002
1128 #define IXGB_TX_FLAGS_TSO 0x00000004
1130 static inline boolean_t
1131 ixgb_tso(struct ixgb_adapter *adapter, struct sk_buff *skb)
1134 struct ixgb_context_desc *context_desc;
1136 uint8_t ipcss, ipcso, tucss, tucso, hdr_len;
1137 uint16_t ipcse, tucse, mss;
1139 if (likely(skb_shinfo(skb)->tso_size)) {
1140 hdr_len = ((skb->h.raw - skb->data) + (skb->h.th->doff << 2));
1141 mss = skb_shinfo(skb)->tso_size;
1142 skb->nh.iph->tot_len = 0;
1143 skb->nh.iph->check = 0;
1144 skb->h.th->check = ~csum_tcpudp_magic(skb->nh.iph->saddr,
1147 ipcss = skb->nh.raw - skb->data;
1148 ipcso = (void *)&(skb->nh.iph->check) - (void *)skb->data;
1149 ipcse = skb->h.raw - skb->data - 1;
1150 tucss = skb->h.raw - skb->data;
1151 tucso = (void *)&(skb->h.th->check) - (void *)skb->data;
1154 i = adapter->tx_ring.next_to_use;
1155 context_desc = IXGB_CONTEXT_DESC(adapter->tx_ring, i);
1157 context_desc->ipcss = ipcss;
1158 context_desc->ipcso = ipcso;
1159 context_desc->ipcse = cpu_to_le16(ipcse);
1160 context_desc->tucss = tucss;
1161 context_desc->tucso = tucso;
1162 context_desc->tucse = cpu_to_le16(tucse);
1163 context_desc->mss = cpu_to_le16(mss);
1164 context_desc->hdr_len = hdr_len;
1165 context_desc->status = 0;
1166 context_desc->cmd_type_len = cpu_to_le32(IXGB_CONTEXT_DESC_TYPE
1168 IXGB_CONTEXT_DESC_CMD_TSE
1170 IXGB_CONTEXT_DESC_CMD_IP
1172 IXGB_CONTEXT_DESC_CMD_TCP
1174 IXGB_CONTEXT_DESC_CMD_RS
1176 IXGB_CONTEXT_DESC_CMD_IDE
1180 if (++i == adapter->tx_ring.count)
1182 adapter->tx_ring.next_to_use = i;
1191 static inline boolean_t
1192 ixgb_tx_csum(struct ixgb_adapter *adapter, struct sk_buff *skb)
1194 struct ixgb_context_desc *context_desc;
1198 if (likely(skb->ip_summed == CHECKSUM_HW)) {
1199 css = skb->h.raw - skb->data;
1200 cso = (skb->h.raw + skb->csum) - skb->data;
1202 i = adapter->tx_ring.next_to_use;
1203 context_desc = IXGB_CONTEXT_DESC(adapter->tx_ring, i);
1205 context_desc->tucss = css;
1206 context_desc->tucso = cso;
1207 context_desc->tucse = 0;
1208 /* zero out any previously existing data in one instruction */
1209 *(uint32_t *) & (context_desc->ipcss) = 0;
1210 context_desc->status = 0;
1211 context_desc->hdr_len = 0;
1212 context_desc->mss = 0;
1213 context_desc->cmd_type_len =
1214 cpu_to_le32(IXGB_CONTEXT_DESC_TYPE
1215 | IXGB_TX_DESC_CMD_RS | IXGB_TX_DESC_CMD_IDE);
1217 if (++i == adapter->tx_ring.count)
1219 adapter->tx_ring.next_to_use = i;
1227 #define IXGB_MAX_TXD_PWR 14
1228 #define IXGB_MAX_DATA_PER_TXD (1<<IXGB_MAX_TXD_PWR)
1231 ixgb_tx_map(struct ixgb_adapter *adapter, struct sk_buff *skb,
1234 struct ixgb_desc_ring *tx_ring = &adapter->tx_ring;
1235 struct ixgb_buffer *buffer_info;
1237 unsigned int offset = 0, size, count = 0, i;
1239 unsigned int nr_frags = skb_shinfo(skb)->nr_frags;
1241 len -= skb->data_len;
1243 i = tx_ring->next_to_use;
1246 buffer_info = &tx_ring->buffer_info[i];
1247 size = min(len, IXGB_MAX_JUMBO_FRAME_SIZE);
1248 buffer_info->length = size;
1250 pci_map_single(adapter->pdev,
1251 skb->data + offset, size, PCI_DMA_TODEVICE);
1252 buffer_info->time_stamp = jiffies;
1257 if (++i == tx_ring->count)
1261 for (f = 0; f < nr_frags; f++) {
1262 struct skb_frag_struct *frag;
1264 frag = &skb_shinfo(skb)->frags[f];
1269 buffer_info = &tx_ring->buffer_info[i];
1270 size = min(len, IXGB_MAX_JUMBO_FRAME_SIZE);
1271 buffer_info->length = size;
1273 pci_map_page(adapter->pdev,
1275 frag->page_offset + offset,
1276 size, PCI_DMA_TODEVICE);
1277 buffer_info->time_stamp = jiffies;
1282 if (++i == tx_ring->count)
1286 i = (i == 0) ? tx_ring->count - 1 : i - 1;
1287 tx_ring->buffer_info[i].skb = skb;
1288 tx_ring->buffer_info[first].next_to_watch = i;
1294 ixgb_tx_queue(struct ixgb_adapter *adapter, int count, int vlan_id,
1297 struct ixgb_desc_ring *tx_ring = &adapter->tx_ring;
1298 struct ixgb_tx_desc *tx_desc = NULL;
1299 struct ixgb_buffer *buffer_info;
1300 uint32_t cmd_type_len = adapter->tx_cmd_type;
1305 if (tx_flags & IXGB_TX_FLAGS_TSO) {
1306 cmd_type_len |= IXGB_TX_DESC_CMD_TSE;
1307 popts |= (IXGB_TX_DESC_POPTS_IXSM | IXGB_TX_DESC_POPTS_TXSM);
1310 if (tx_flags & IXGB_TX_FLAGS_CSUM)
1311 popts |= IXGB_TX_DESC_POPTS_TXSM;
1313 if (tx_flags & IXGB_TX_FLAGS_VLAN) {
1314 cmd_type_len |= IXGB_TX_DESC_CMD_VLE;
1317 i = tx_ring->next_to_use;
1320 buffer_info = &tx_ring->buffer_info[i];
1321 tx_desc = IXGB_TX_DESC(*tx_ring, i);
1322 tx_desc->buff_addr = cpu_to_le64(buffer_info->dma);
1323 tx_desc->cmd_type_len =
1324 cpu_to_le32(cmd_type_len | buffer_info->length);
1325 tx_desc->status = status;
1326 tx_desc->popts = popts;
1327 tx_desc->vlan = cpu_to_le16(vlan_id);
1329 if (++i == tx_ring->count)
1333 tx_desc->cmd_type_len |= cpu_to_le32(IXGB_TX_DESC_CMD_EOP
1334 | IXGB_TX_DESC_CMD_RS);
1336 /* Force memory writes to complete before letting h/w
1337 * know there are new descriptors to fetch. (Only
1338 * applicable for weak-ordered memory model archs,
1339 * such as IA-64). */
1342 tx_ring->next_to_use = i;
1343 IXGB_WRITE_REG(&adapter->hw, TDT, i);
1346 /* Tx Descriptors needed, worst case */
1347 #define TXD_USE_COUNT(S) (((S) >> IXGB_MAX_TXD_PWR) + \
1348 (((S) & (IXGB_MAX_DATA_PER_TXD - 1)) ? 1 : 0))
1349 #define DESC_NEEDED TXD_USE_COUNT(IXGB_MAX_DATA_PER_TXD) + \
1350 MAX_SKB_FRAGS * TXD_USE_COUNT(PAGE_SIZE) + 1
1352 static int ixgb_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
1354 struct ixgb_adapter *adapter = netdev->priv;
1356 unsigned int tx_flags = 0;
1357 unsigned long flags;
1360 if (skb->len <= 0) {
1361 dev_kfree_skb_any(skb);
1365 spin_lock_irqsave(&adapter->tx_lock, flags);
1366 if (unlikely(IXGB_DESC_UNUSED(&adapter->tx_ring) < DESC_NEEDED)) {
1367 netif_stop_queue(netdev);
1368 spin_unlock_irqrestore(&adapter->tx_lock, flags);
1371 spin_unlock_irqrestore(&adapter->tx_lock, flags);
1373 if (adapter->vlgrp && vlan_tx_tag_present(skb)) {
1374 tx_flags |= IXGB_TX_FLAGS_VLAN;
1375 vlan_id = vlan_tx_tag_get(skb);
1378 first = adapter->tx_ring.next_to_use;
1380 if (ixgb_tso(adapter, skb))
1381 tx_flags |= IXGB_TX_FLAGS_TSO;
1382 else if (ixgb_tx_csum(adapter, skb))
1383 tx_flags |= IXGB_TX_FLAGS_CSUM;
1385 ixgb_tx_queue(adapter, ixgb_tx_map(adapter, skb, first), vlan_id,
1388 netdev->trans_start = jiffies;
1394 * ixgb_tx_timeout - Respond to a Tx Hang
1395 * @netdev: network interface device structure
1398 static void ixgb_tx_timeout(struct net_device *netdev)
1400 struct ixgb_adapter *adapter = netdev->priv;
1402 /* Do the reset outside of interrupt context */
1403 schedule_work(&adapter->tx_timeout_task);
1406 static void ixgb_tx_timeout_task(struct net_device *netdev)
1408 struct ixgb_adapter *adapter = netdev->priv;
1410 netif_device_detach(netdev);
1411 ixgb_down(adapter, TRUE);
1413 netif_device_attach(netdev);
1417 * ixgb_get_stats - Get System Network Statistics
1418 * @netdev: network interface device structure
1420 * Returns the address of the device statistics structure.
1421 * The statistics are actually updated from the timer callback.
1424 static struct net_device_stats *ixgb_get_stats(struct net_device *netdev)
1426 struct ixgb_adapter *adapter = netdev->priv;
1428 return &adapter->net_stats;
1432 * ixgb_change_mtu - Change the Maximum Transfer Unit
1433 * @netdev: network interface device structure
1434 * @new_mtu: new value for maximum frame size
1436 * Returns 0 on success, negative on failure
1439 static int ixgb_change_mtu(struct net_device *netdev, int new_mtu)
1441 struct ixgb_adapter *adapter = netdev->priv;
1442 uint32_t old_mtu = adapter->rx_buffer_len;
1443 int max_frame = new_mtu + ENET_HEADER_SIZE + ENET_FCS_LENGTH;
1445 if ((max_frame < IXGB_MIN_ENET_FRAME_SIZE_WITHOUT_FCS + ENET_FCS_LENGTH)
1446 || (max_frame > IXGB_MAX_JUMBO_FRAME_SIZE + ENET_FCS_LENGTH)) {
1447 IXGB_ERR("Invalid MTU setting\n");
1452 IXGB_MAX_ENET_FRAME_SIZE_WITHOUT_FCS + ENET_FCS_LENGTH)
1453 || (max_frame <= IXGB_RXBUFFER_2048)) {
1454 adapter->rx_buffer_len = IXGB_RXBUFFER_2048;
1456 } else if (max_frame <= IXGB_RXBUFFER_4096) {
1457 adapter->rx_buffer_len = IXGB_RXBUFFER_4096;
1459 } else if (max_frame <= IXGB_RXBUFFER_8192) {
1460 adapter->rx_buffer_len = IXGB_RXBUFFER_8192;
1463 adapter->rx_buffer_len = IXGB_RXBUFFER_16384;
1466 netdev->mtu = new_mtu;
1468 if (old_mtu != adapter->rx_buffer_len && netif_running(netdev)) {
1470 ixgb_down(adapter, TRUE);
1478 * ixgb_update_stats - Update the board statistics counters.
1479 * @adapter: board private structure
1482 static void ixgb_update_stats(struct ixgb_adapter *adapter)
1484 adapter->stats.tprl += IXGB_READ_REG(&adapter->hw, TPRL);
1485 adapter->stats.tprh += IXGB_READ_REG(&adapter->hw, TPRH);
1486 adapter->stats.gprcl += IXGB_READ_REG(&adapter->hw, GPRCL);
1487 adapter->stats.gprch += IXGB_READ_REG(&adapter->hw, GPRCH);
1488 adapter->stats.bprcl += IXGB_READ_REG(&adapter->hw, BPRCL);
1489 adapter->stats.bprch += IXGB_READ_REG(&adapter->hw, BPRCH);
1490 adapter->stats.mprcl += IXGB_READ_REG(&adapter->hw, MPRCL);
1491 adapter->stats.mprch += IXGB_READ_REG(&adapter->hw, MPRCH);
1492 adapter->stats.uprcl += IXGB_READ_REG(&adapter->hw, UPRCL);
1493 adapter->stats.uprch += IXGB_READ_REG(&adapter->hw, UPRCH);
1494 adapter->stats.vprcl += IXGB_READ_REG(&adapter->hw, VPRCL);
1495 adapter->stats.vprch += IXGB_READ_REG(&adapter->hw, VPRCH);
1496 adapter->stats.jprcl += IXGB_READ_REG(&adapter->hw, JPRCL);
1497 adapter->stats.jprch += IXGB_READ_REG(&adapter->hw, JPRCH);
1498 adapter->stats.gorcl += IXGB_READ_REG(&adapter->hw, GORCL);
1499 adapter->stats.gorch += IXGB_READ_REG(&adapter->hw, GORCH);
1500 adapter->stats.torl += IXGB_READ_REG(&adapter->hw, TORL);
1501 adapter->stats.torh += IXGB_READ_REG(&adapter->hw, TORH);
1502 adapter->stats.rnbc += IXGB_READ_REG(&adapter->hw, RNBC);
1503 adapter->stats.ruc += IXGB_READ_REG(&adapter->hw, RUC);
1504 adapter->stats.roc += IXGB_READ_REG(&adapter->hw, ROC);
1505 adapter->stats.rlec += IXGB_READ_REG(&adapter->hw, RLEC);
1506 adapter->stats.crcerrs += IXGB_READ_REG(&adapter->hw, CRCERRS);
1507 adapter->stats.icbc += IXGB_READ_REG(&adapter->hw, ICBC);
1508 adapter->stats.ecbc += IXGB_READ_REG(&adapter->hw, ECBC);
1509 adapter->stats.mpc += IXGB_READ_REG(&adapter->hw, MPC);
1510 adapter->stats.tptl += IXGB_READ_REG(&adapter->hw, TPTL);
1511 adapter->stats.tpth += IXGB_READ_REG(&adapter->hw, TPTH);
1512 adapter->stats.gptcl += IXGB_READ_REG(&adapter->hw, GPTCL);
1513 adapter->stats.gptch += IXGB_READ_REG(&adapter->hw, GPTCH);
1514 adapter->stats.bptcl += IXGB_READ_REG(&adapter->hw, BPTCL);
1515 adapter->stats.bptch += IXGB_READ_REG(&adapter->hw, BPTCH);
1516 adapter->stats.mptcl += IXGB_READ_REG(&adapter->hw, MPTCL);
1517 adapter->stats.mptch += IXGB_READ_REG(&adapter->hw, MPTCH);
1518 adapter->stats.uptcl += IXGB_READ_REG(&adapter->hw, UPTCL);
1519 adapter->stats.uptch += IXGB_READ_REG(&adapter->hw, UPTCH);
1520 adapter->stats.vptcl += IXGB_READ_REG(&adapter->hw, VPTCL);
1521 adapter->stats.vptch += IXGB_READ_REG(&adapter->hw, VPTCH);
1522 adapter->stats.jptcl += IXGB_READ_REG(&adapter->hw, JPTCL);
1523 adapter->stats.jptch += IXGB_READ_REG(&adapter->hw, JPTCH);
1524 adapter->stats.gotcl += IXGB_READ_REG(&adapter->hw, GOTCL);
1525 adapter->stats.gotch += IXGB_READ_REG(&adapter->hw, GOTCH);
1526 adapter->stats.totl += IXGB_READ_REG(&adapter->hw, TOTL);
1527 adapter->stats.toth += IXGB_READ_REG(&adapter->hw, TOTH);
1528 adapter->stats.dc += IXGB_READ_REG(&adapter->hw, DC);
1529 adapter->stats.plt64c += IXGB_READ_REG(&adapter->hw, PLT64C);
1530 adapter->stats.tsctc += IXGB_READ_REG(&adapter->hw, TSCTC);
1531 adapter->stats.tsctfc += IXGB_READ_REG(&adapter->hw, TSCTFC);
1532 adapter->stats.ibic += IXGB_READ_REG(&adapter->hw, IBIC);
1533 adapter->stats.rfc += IXGB_READ_REG(&adapter->hw, RFC);
1534 adapter->stats.lfc += IXGB_READ_REG(&adapter->hw, LFC);
1535 adapter->stats.pfrc += IXGB_READ_REG(&adapter->hw, PFRC);
1536 adapter->stats.pftc += IXGB_READ_REG(&adapter->hw, PFTC);
1537 adapter->stats.mcfrc += IXGB_READ_REG(&adapter->hw, MCFRC);
1538 adapter->stats.mcftc += IXGB_READ_REG(&adapter->hw, MCFTC);
1539 adapter->stats.xonrxc += IXGB_READ_REG(&adapter->hw, XONRXC);
1540 adapter->stats.xontxc += IXGB_READ_REG(&adapter->hw, XONTXC);
1541 adapter->stats.xoffrxc += IXGB_READ_REG(&adapter->hw, XOFFRXC);
1542 adapter->stats.xofftxc += IXGB_READ_REG(&adapter->hw, XOFFTXC);
1543 adapter->stats.rjc += IXGB_READ_REG(&adapter->hw, RJC);
1545 /* Fill out the OS statistics structure */
1547 adapter->net_stats.rx_packets = adapter->stats.gprcl;
1548 adapter->net_stats.tx_packets = adapter->stats.gptcl;
1549 adapter->net_stats.rx_bytes = adapter->stats.gorcl;
1550 adapter->net_stats.tx_bytes = adapter->stats.gotcl;
1551 adapter->net_stats.multicast = adapter->stats.mprcl;
1552 adapter->net_stats.collisions = 0;
1554 /* ignore RLEC as it reports errors for padded (<64bytes) frames
1555 * with a length in the type/len field */
1556 adapter->net_stats.rx_errors =
1557 /* adapter->stats.rnbc + */ adapter->stats.crcerrs +
1558 adapter->stats.ruc +
1559 adapter->stats.roc /*+ adapter->stats.rlec */ +
1560 adapter->stats.icbc +
1561 adapter->stats.ecbc + adapter->stats.mpc;
1563 adapter->net_stats.rx_dropped = adapter->stats.mpc;
1566 * adapter->net_stats.rx_length_errors = adapter->stats.rlec;
1569 adapter->net_stats.rx_crc_errors = adapter->stats.crcerrs;
1570 adapter->net_stats.rx_fifo_errors = adapter->stats.mpc;
1571 adapter->net_stats.rx_missed_errors = adapter->stats.mpc;
1572 adapter->net_stats.rx_over_errors = adapter->stats.mpc;
1574 adapter->net_stats.tx_errors = 0;
1575 adapter->net_stats.rx_frame_errors = 0;
1576 adapter->net_stats.tx_aborted_errors = 0;
1577 adapter->net_stats.tx_carrier_errors = 0;
1578 adapter->net_stats.tx_fifo_errors = 0;
1579 adapter->net_stats.tx_heartbeat_errors = 0;
1580 adapter->net_stats.tx_window_errors = 0;
1583 #define IXGB_MAX_INTR 10
1585 * ixgb_intr - Interrupt Handler
1586 * @irq: interrupt number
1587 * @data: pointer to a network interface device structure
1588 * @pt_regs: CPU registers structure
1591 static irqreturn_t ixgb_intr(int irq, void *data, struct pt_regs *regs)
1593 struct net_device *netdev = data;
1594 struct ixgb_adapter *adapter = netdev->priv;
1595 struct ixgb_hw *hw = &adapter->hw;
1596 uint32_t icr = IXGB_READ_REG(&adapter->hw, ICR);
1597 #ifndef CONFIG_IXGB_NAPI
1602 return IRQ_NONE; /* Not our interrupt */
1604 if (unlikely(icr & (IXGB_INT_RXSEQ | IXGB_INT_LSC))) {
1605 mod_timer(&adapter->watchdog_timer, jiffies);
1607 #ifdef CONFIG_IXGB_NAPI
1608 if (netif_rx_schedule_prep(netdev)) {
1610 /* Disable interrupts and register for poll. The flush
1611 of the posted write is intentionally left out.
1614 atomic_inc(&adapter->irq_sem);
1615 IXGB_WRITE_REG(hw, IMC, ~0);
1616 __netif_rx_schedule(netdev);
1619 for (i = 0; i < IXGB_MAX_INTR; i++)
1620 if (!ixgb_clean_rx_irq(adapter) & !ixgb_clean_tx_irq(adapter))
1622 /* if RAIDC:EN == 1 and ICR:RXDMT0 == 1, we need to
1623 * set IMS:RXDMT0 to 1 to restart the RBD timer (POLL)
1625 if ((icr & IXGB_INT_RXDMT0) && adapter->raidc) {
1626 /* ready the timer by writing the clear reg */
1627 IXGB_WRITE_REG(hw, IMC, IXGB_INT_RXDMT0);
1628 /* now restart it, h/w will decide if its necessary */
1629 IXGB_WRITE_REG(hw, IMS, IXGB_INT_RXDMT0);
1635 #ifdef CONFIG_IXGB_NAPI
1637 * ixgb_clean - NAPI Rx polling callback
1638 * @adapter: board private structure
1641 static int ixgb_clean(struct net_device *netdev, int *budget)
1643 struct ixgb_adapter *adapter = netdev->priv;
1644 int work_to_do = min(*budget, netdev->quota);
1647 ixgb_clean_tx_irq(adapter);
1648 ixgb_clean_rx_irq(adapter, &work_done, work_to_do);
1650 *budget -= work_done;
1651 netdev->quota -= work_done;
1653 if (work_done < work_to_do || !netif_running(netdev)) {
1654 netif_rx_complete(netdev);
1655 /* RAIDC will be automatically restarted by irq_enable */
1656 ixgb_irq_enable(adapter);
1659 return (work_done >= work_to_do);
1664 * ixgb_clean_tx_irq - Reclaim resources after transmit completes
1665 * @adapter: board private structure
1668 static boolean_t ixgb_clean_tx_irq(struct ixgb_adapter *adapter)
1670 struct ixgb_desc_ring *tx_ring = &adapter->tx_ring;
1671 struct net_device *netdev = adapter->netdev;
1672 struct pci_dev *pdev = adapter->pdev;
1673 struct ixgb_tx_desc *tx_desc, *eop_desc;
1674 struct ixgb_buffer *buffer_info;
1675 unsigned int i, eop;
1676 boolean_t cleaned = FALSE;
1678 i = tx_ring->next_to_clean;
1679 eop = tx_ring->buffer_info[i].next_to_watch;
1680 eop_desc = IXGB_TX_DESC(*tx_ring, eop);
1682 while (eop_desc->status & cpu_to_le32(IXGB_TX_DESC_STATUS_DD)) {
1684 for (cleaned = FALSE; !cleaned;) {
1685 tx_desc = IXGB_TX_DESC(*tx_ring, i);
1686 buffer_info = &tx_ring->buffer_info[i];
1689 & (IXGB_TX_DESC_POPTS_TXSM |
1690 IXGB_TX_DESC_POPTS_IXSM))
1691 adapter->hw_csum_tx_good++;
1693 if (buffer_info->dma) {
1695 pci_unmap_page(pdev,
1697 buffer_info->length,
1700 buffer_info->dma = 0;
1703 if (buffer_info->skb) {
1705 dev_kfree_skb_any(buffer_info->skb);
1707 buffer_info->skb = NULL;
1710 *(uint32_t *) & (tx_desc->status) = 0;
1712 cleaned = (i == eop);
1713 if (++i == tx_ring->count)
1717 eop = tx_ring->buffer_info[i].next_to_watch;
1718 eop_desc = IXGB_TX_DESC(*tx_ring, eop);
1721 tx_ring->next_to_clean = i;
1723 spin_lock(&adapter->tx_lock);
1724 if (cleaned && netif_queue_stopped(netdev) && netif_carrier_ok(netdev)
1725 && (IXGB_DESC_UNUSED(tx_ring) > IXGB_TX_QUEUE_WAKE)) {
1727 netif_wake_queue(netdev);
1729 spin_unlock(&adapter->tx_lock);
1735 * ixgb_rx_checksum - Receive Checksum Offload for 82597.
1736 * @adapter: board private structure
1737 * @rx_desc: receive descriptor
1738 * @sk_buff: socket buffer with received data
1742 ixgb_rx_checksum(struct ixgb_adapter *adapter,
1743 struct ixgb_rx_desc *rx_desc, struct sk_buff *skb)
1745 /* Ignore Checksum bit is set OR
1746 * TCP Checksum has not been calculated
1748 if ((rx_desc->status & IXGB_RX_DESC_STATUS_IXSM) ||
1749 (!(rx_desc->status & IXGB_RX_DESC_STATUS_TCPCS))) {
1750 skb->ip_summed = CHECKSUM_NONE;
1754 /* At this point we know the hardware did the TCP checksum */
1755 /* now look at the TCP checksum error bit */
1756 if (rx_desc->errors & IXGB_RX_DESC_ERRORS_TCPE) {
1757 /* let the stack verify checksum errors */
1758 skb->ip_summed = CHECKSUM_NONE;
1759 adapter->hw_csum_rx_error++;
1761 /* TCP checksum is good */
1762 skb->ip_summed = CHECKSUM_UNNECESSARY;
1763 adapter->hw_csum_rx_good++;
1768 * ixgb_clean_rx_irq - Send received data up the network stack,
1769 * @adapter: board private structure
1773 #ifdef CONFIG_IXGB_NAPI
1774 ixgb_clean_rx_irq(struct ixgb_adapter *adapter, int *work_done, int work_to_do)
1776 ixgb_clean_rx_irq(struct ixgb_adapter *adapter)
1779 struct ixgb_desc_ring *rx_ring = &adapter->rx_ring;
1780 struct net_device *netdev = adapter->netdev;
1781 struct pci_dev *pdev = adapter->pdev;
1782 struct ixgb_rx_desc *rx_desc, *next_rxd;
1783 struct ixgb_buffer *buffer_info, *next_buffer, *next2_buffer;
1784 struct sk_buff *skb, *next_skb;
1787 boolean_t cleaned = FALSE;
1789 i = rx_ring->next_to_clean;
1790 rx_desc = IXGB_RX_DESC(*rx_ring, i);
1791 buffer_info = &rx_ring->buffer_info[i];
1793 while (rx_desc->status & IXGB_RX_DESC_STATUS_DD) {
1795 skb = buffer_info->skb;
1796 prefetch(skb->data);
1798 if (++i == rx_ring->count)
1800 next_rxd = IXGB_RX_DESC(*rx_ring, i);
1803 if ((j = i + 1) == rx_ring->count)
1805 next2_buffer = &rx_ring->buffer_info[j];
1806 prefetch(next2_buffer);
1808 next_buffer = &rx_ring->buffer_info[i];
1809 next_skb = next_buffer->skb;
1812 #ifdef CONFIG_IXGB_NAPI
1813 if (*work_done >= work_to_do)
1821 pci_unmap_single(pdev,
1823 buffer_info->length, PCI_DMA_FROMDEVICE);
1825 length = le16_to_cpu(rx_desc->length);
1827 if (unlikely(!(rx_desc->status & IXGB_RX_DESC_STATUS_EOP))) {
1829 /* All receives must fit into a single buffer */
1831 IXGB_DBG("Receive packet consumed multiple buffers "
1832 "length<%x>\n", length);
1834 dev_kfree_skb_irq(skb);
1835 rx_desc->status = 0;
1836 buffer_info->skb = NULL;
1839 buffer_info = next_buffer;
1843 if (unlikely(rx_desc->errors
1844 & (IXGB_RX_DESC_ERRORS_CE | IXGB_RX_DESC_ERRORS_SE
1845 | IXGB_RX_DESC_ERRORS_P |
1846 IXGB_RX_DESC_ERRORS_RXE))) {
1848 dev_kfree_skb_irq(skb);
1849 rx_desc->status = 0;
1850 buffer_info->skb = NULL;
1853 buffer_info = next_buffer;
1858 skb_put(skb, length);
1860 /* Receive Checksum Offload */
1861 ixgb_rx_checksum(adapter, rx_desc, skb);
1863 skb->protocol = eth_type_trans(skb, netdev);
1864 #ifdef CONFIG_IXGB_NAPI
1866 && (rx_desc->status & IXGB_RX_DESC_STATUS_VP)) {
1867 vlan_hwaccel_receive_skb(skb, adapter->vlgrp,
1868 le16_to_cpu(rx_desc->
1870 IXGB_RX_DESC_SPECIAL_VLAN_MASK));
1872 netif_receive_skb(skb);
1874 #else /* CONFIG_IXGB_NAPI */
1876 && (rx_desc->status & IXGB_RX_DESC_STATUS_VP)) {
1877 vlan_hwaccel_rx(skb, adapter->vlgrp,
1878 le16_to_cpu(rx_desc->
1880 IXGB_RX_DESC_SPECIAL_VLAN_MASK));
1884 #endif /* CONFIG_IXGB_NAPI */
1885 netdev->last_rx = jiffies;
1887 rx_desc->status = 0;
1888 buffer_info->skb = NULL;
1891 buffer_info = next_buffer;
1894 rx_ring->next_to_clean = i;
1896 ixgb_alloc_rx_buffers(adapter);
1902 * ixgb_alloc_rx_buffers - Replace used receive buffers
1903 * @adapter: address of board private structure
1906 static void ixgb_alloc_rx_buffers(struct ixgb_adapter *adapter)
1908 struct ixgb_desc_ring *rx_ring = &adapter->rx_ring;
1909 struct net_device *netdev = adapter->netdev;
1910 struct pci_dev *pdev = adapter->pdev;
1911 struct ixgb_rx_desc *rx_desc;
1912 struct ixgb_buffer *buffer_info;
1913 struct sk_buff *skb;
1915 int num_group_tail_writes;
1918 i = rx_ring->next_to_use;
1919 buffer_info = &rx_ring->buffer_info[i];
1920 cleancount = IXGB_DESC_UNUSED(rx_ring);
1922 /* lessen this to 4 if we're
1923 * in the midst of raidc and rbd is occuring
1924 * because we don't want to delay returning buffers when low
1926 num_group_tail_writes = adapter->raidc ? 4 : IXGB_RX_BUFFER_WRITE;
1928 /* leave one descriptor unused */
1929 while (--cleancount > 0) {
1930 rx_desc = IXGB_RX_DESC(*rx_ring, i);
1932 skb = dev_alloc_skb(adapter->rx_buffer_len + NET_IP_ALIGN);
1934 if (unlikely(!skb)) {
1935 /* Better luck next round */
1939 /* Make buffer alignment 2 beyond a 16 byte boundary
1940 * this will result in a 16 byte aligned IP header after
1941 * the 14 byte MAC header is removed
1943 skb_reserve(skb, NET_IP_ALIGN);
1947 buffer_info->skb = skb;
1948 buffer_info->length = adapter->rx_buffer_len;
1950 pci_map_single(pdev,
1952 adapter->rx_buffer_len, PCI_DMA_FROMDEVICE);
1954 rx_desc->buff_addr = cpu_to_le64(buffer_info->dma);
1956 if ((i & ~(num_group_tail_writes - 1)) == i) {
1957 /* Force memory writes to complete before letting h/w
1958 * know there are new descriptors to fetch. (Only
1959 * applicable for weak-ordered memory model archs,
1960 * such as IA-64). */
1963 IXGB_WRITE_REG(&adapter->hw, RDT, i);
1966 if (++i == rx_ring->count)
1968 buffer_info = &rx_ring->buffer_info[i];
1971 rx_ring->next_to_use = i;
1975 * ixgb_ioctl - perform a command - e.g: ethtool:get_driver_info.
1976 * @param netdev network interface device structure
1977 * @param ifr data to be used/filled in by the ioctl command
1978 * @param cmd ioctl command to execute
1981 static int ixgb_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
1985 return ixgb_ethtool_ioctl(netdev, ifr);
1994 * ixgb_vlan_rx_register - enables or disables vlan tagging/stripping.
1996 * @param netdev network interface device structure
1997 * @param grp indicates to enable or disable tagging/stripping
2000 ixgb_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp)
2002 struct ixgb_adapter *adapter = netdev->priv;
2003 uint32_t ctrl, rctl;
2005 ixgb_irq_disable(adapter);
2006 adapter->vlgrp = grp;
2009 /* enable VLAN tag insert/strip */
2010 ctrl = IXGB_READ_REG(&adapter->hw, CTRL0);
2011 ctrl |= IXGB_CTRL0_VME;
2012 IXGB_WRITE_REG(&adapter->hw, CTRL0, ctrl);
2014 /* enable VLAN receive filtering */
2016 rctl = IXGB_READ_REG(&adapter->hw, RCTL);
2017 rctl |= IXGB_RCTL_VFE;
2018 rctl &= ~IXGB_RCTL_CFIEN;
2019 IXGB_WRITE_REG(&adapter->hw, RCTL, rctl);
2021 /* disable VLAN tag insert/strip */
2023 ctrl = IXGB_READ_REG(&adapter->hw, CTRL0);
2024 ctrl &= ~IXGB_CTRL0_VME;
2025 IXGB_WRITE_REG(&adapter->hw, CTRL0, ctrl);
2027 /* disable VLAN filtering */
2029 rctl = IXGB_READ_REG(&adapter->hw, RCTL);
2030 rctl &= ~IXGB_RCTL_VFE;
2031 IXGB_WRITE_REG(&adapter->hw, RCTL, rctl);
2034 ixgb_irq_enable(adapter);
2037 static void ixgb_vlan_rx_add_vid(struct net_device *netdev, uint16_t vid)
2039 struct ixgb_adapter *adapter = netdev->priv;
2040 uint32_t vfta, index;
2042 /* add VID to filter table */
2044 index = (vid >> 5) & 0x7F;
2045 vfta = IXGB_READ_REG_ARRAY(&adapter->hw, VFTA, index);
2046 vfta |= (1 << (vid & 0x1F));
2047 ixgb_write_vfta(&adapter->hw, index, vfta);
2050 static void ixgb_vlan_rx_kill_vid(struct net_device *netdev, uint16_t vid)
2052 struct ixgb_adapter *adapter = netdev->priv;
2053 uint32_t vfta, index;
2055 ixgb_irq_disable(adapter);
2058 adapter->vlgrp->vlan_devices[vid] = NULL;
2060 ixgb_irq_enable(adapter);
2062 /* remove VID from filter table */
2064 index = (vid >> 5) & 0x7F;
2065 vfta = IXGB_READ_REG_ARRAY(&adapter->hw, VFTA, index);
2066 vfta &= ~(1 << (vid & 0x1F));
2067 ixgb_write_vfta(&adapter->hw, index, vfta);
2070 static void ixgb_restore_vlan(struct ixgb_adapter *adapter)
2072 ixgb_vlan_rx_register(adapter->netdev, adapter->vlgrp);
2074 if (adapter->vlgrp) {
2076 for (vid = 0; vid < VLAN_GROUP_ARRAY_LEN; vid++) {
2077 if (!adapter->vlgrp->vlan_devices[vid])
2079 ixgb_vlan_rx_add_vid(adapter->netdev, vid);
2085 * ixgb_notify_reboot - handles OS notification of reboot event.
2086 * @param nb notifier block, unused
2087 * @param event Event being passed to driver to act upon
2088 * @param p A pointer to our net device
2091 ixgb_notify_reboot(struct notifier_block *nb, unsigned long event, void *p)
2093 struct pci_dev *pdev = NULL;
2099 while ((pdev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pdev))) {
2100 if (pci_dev_driver(pdev) == &ixgb_driver)
2101 ixgb_suspend(pdev, 3);
2108 * ixgb_suspend - driver suspend function called from notify.
2109 * @param pdev pci driver structure used for passing to
2110 * @param state power state to enter
2112 static int ixgb_suspend(struct pci_dev *pdev, uint32_t state)
2114 struct net_device *netdev = pci_get_drvdata(pdev);
2115 struct ixgb_adapter *adapter = netdev->priv;
2117 netif_device_detach(netdev);
2119 if (netif_running(netdev))
2120 ixgb_down(adapter, TRUE);
2122 pci_save_state(pdev, adapter->pci_state);
2124 state = (state > 0) ? 3 : 0;
2125 pci_set_power_state(pdev, state);
2131 #ifdef CONFIG_NET_POLL_CONTROLLER
2133 * Polling 'interrupt' - used by things like netconsole to send skbs
2134 * without having to re-enable interrupts. It's not called while
2135 * the interrupt routine is executing.
2138 static void ixgb_netpoll(struct net_device *dev)
2140 struct ixgb_adapter *adapter = dev->priv;
2141 disable_irq(adapter->pdev->irq);
2142 ixgb_intr(adapter->pdev->irq, dev, NULL);
2143 enable_irq(adapter->pdev->irq);