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 char ixgb_driver_version[] = "1.0.66";
34 char ixgb_copyright[] = "Copyright (c) 2001-2004 Intel Corporation.";
36 /* ixgb_pci_tbl - PCI Device ID Table
38 * Wildcard entries (PCI_ANY_ID) should come last
39 * Last entry must be all 0s
41 * { Vendor ID, Device ID, SubVendor ID, SubDevice ID,
42 * Class, Class Mask, private data (not used) }
44 static struct pci_device_id ixgb_pci_tbl[] = {
45 {INTEL_VENDOR_ID, IXGB_DEVICE_ID_82597EX,
46 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
47 {INTEL_VENDOR_ID, IXGB_DEVICE_ID_82597EX_SR,
48 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
50 /* required last entry */
54 MODULE_DEVICE_TABLE(pci, ixgb_pci_tbl);
56 /* Local Function Prototypes */
58 int ixgb_up(struct ixgb_adapter *adapter);
59 void ixgb_down(struct ixgb_adapter *adapter, boolean_t kill_watchdog);
60 void ixgb_reset(struct ixgb_adapter *adapter);
62 static int ixgb_init_module(void);
63 static void ixgb_exit_module(void);
64 static int ixgb_probe(struct pci_dev *pdev, const struct pci_device_id *ent);
65 static void __devexit ixgb_remove(struct pci_dev *pdev);
66 static int ixgb_sw_init(struct ixgb_adapter *adapter);
67 static int ixgb_open(struct net_device *netdev);
68 static int ixgb_close(struct net_device *netdev);
69 static int ixgb_setup_tx_resources(struct ixgb_adapter *adapter);
70 static int ixgb_setup_rx_resources(struct ixgb_adapter *adapter);
71 static void ixgb_configure_tx(struct ixgb_adapter *adapter);
72 static void ixgb_configure_rx(struct ixgb_adapter *adapter);
73 static void ixgb_setup_rctl(struct ixgb_adapter *adapter);
74 static void ixgb_clean_tx_ring(struct ixgb_adapter *adapter);
75 static void ixgb_clean_rx_ring(struct ixgb_adapter *adapter);
76 static void ixgb_free_tx_resources(struct ixgb_adapter *adapter);
77 static void ixgb_free_rx_resources(struct ixgb_adapter *adapter);
78 static void ixgb_set_multi(struct net_device *netdev);
79 static void ixgb_watchdog(unsigned long data);
80 static int ixgb_xmit_frame(struct sk_buff *skb, struct net_device *netdev);
81 static struct net_device_stats *ixgb_get_stats(struct net_device *netdev);
82 static int ixgb_change_mtu(struct net_device *netdev, int new_mtu);
83 static int ixgb_set_mac(struct net_device *netdev, void *p);
84 static void ixgb_update_stats(struct ixgb_adapter *adapter);
85 static inline void ixgb_irq_disable(struct ixgb_adapter *adapter);
86 static inline void ixgb_irq_enable(struct ixgb_adapter *adapter);
87 static irqreturn_t ixgb_intr(int irq, void *data, struct pt_regs *regs);
88 static boolean_t ixgb_clean_tx_irq(struct ixgb_adapter *adapter);
89 #ifdef CONFIG_IXGB_NAPI
90 static int ixgb_clean(struct net_device *netdev, int *budget);
91 static boolean_t ixgb_clean_rx_irq(struct ixgb_adapter *adapter,
92 int *work_done, int work_to_do);
94 static boolean_t ixgb_clean_rx_irq(struct ixgb_adapter *adapter);
96 static void ixgb_alloc_rx_buffers(struct ixgb_adapter *adapter);
97 static int ixgb_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd);
98 static inline void ixgb_rx_checksum(struct ixgb_adapter *adapter,
99 struct ixgb_rx_desc *rx_desc,
100 struct sk_buff *skb);
101 static void ixgb_tx_timeout(struct net_device *dev);
102 static void ixgb_tx_timeout_task(struct net_device *dev);
103 static void ixgb_vlan_rx_register(struct net_device *netdev,
104 struct vlan_group *grp);
105 static void ixgb_vlan_rx_add_vid(struct net_device *netdev, uint16_t vid);
106 static void ixgb_vlan_rx_kill_vid(struct net_device *netdev, uint16_t vid);
107 static void ixgb_restore_vlan(struct ixgb_adapter *adapter);
109 static int ixgb_notify_reboot(struct notifier_block *, unsigned long event,
111 static int ixgb_suspend(struct pci_dev *pdev, uint32_t state);
113 #ifdef CONFIG_NET_POLL_CONTROLLER
114 /* for netdump / net console */
115 static void ixgb_netpoll(struct net_device *dev);
118 struct notifier_block ixgb_notifier_reboot = {
119 .notifier_call = ixgb_notify_reboot,
124 /* Exported from other modules */
126 extern void ixgb_check_options(struct ixgb_adapter *adapter);
127 extern int ixgb_ethtool_ioctl(struct net_device *netdev, struct ifreq *ifr);
129 static struct pci_driver ixgb_driver = {
130 .name = ixgb_driver_name,
131 .id_table = ixgb_pci_tbl,
133 .remove = __devexit_p(ixgb_remove),
134 /* Power Managment Hooks */
139 MODULE_AUTHOR("Intel Corporation, <linux.nics@intel.com>");
140 MODULE_DESCRIPTION("Intel(R) PRO/10GbE Network Driver");
141 MODULE_LICENSE("GPL");
143 /* some defines for controlling descriptor fetches in h/w */
144 #define RXDCTL_PTHRESH_DEFAULT 128 /* chip considers prefech below this */
145 #define RXDCTL_HTHRESH_DEFAULT 16 /* chip will only prefetch if tail is
146 pushed this many descriptors from head */
147 #define RXDCTL_WTHRESH_DEFAULT 16 /* chip writes back at this many or RXT0 */
150 * ixgb_init_module - Driver Registration Routine
152 * ixgb_init_module is the first routine called when the driver is
153 * loaded. All it does is register with the PCI subsystem.
156 static int __init ixgb_init_module(void)
159 printk(KERN_INFO "%s - version %s\n",
160 ixgb_driver_string, ixgb_driver_version);
162 printk(KERN_INFO "%s\n", ixgb_copyright);
164 ret = pci_module_init(&ixgb_driver);
166 register_reboot_notifier(&ixgb_notifier_reboot);
171 module_init(ixgb_init_module);
174 * ixgb_exit_module - Driver Exit Cleanup Routine
176 * ixgb_exit_module is called just before the driver is removed
180 static void __exit ixgb_exit_module(void)
182 unregister_reboot_notifier(&ixgb_notifier_reboot);
183 pci_unregister_driver(&ixgb_driver);
186 module_exit(ixgb_exit_module);
188 int ixgb_up(struct ixgb_adapter *adapter)
190 struct net_device *netdev = adapter->netdev;
192 int max_frame = netdev->mtu + ENET_HEADER_SIZE + ENET_FCS_LENGTH;
193 struct ixgb_hw *hw = &adapter->hw;
195 /* hardware has been reset, we need to reload some things */
197 ixgb_set_multi(netdev);
199 ixgb_restore_vlan(adapter);
201 ixgb_configure_tx(adapter);
202 ixgb_setup_rctl(adapter);
203 ixgb_configure_rx(adapter);
204 ixgb_alloc_rx_buffers(adapter);
206 if ((err = request_irq(adapter->pdev->irq, &ixgb_intr,
207 SA_SHIRQ | SA_SAMPLE_RANDOM,
208 netdev->name, netdev)))
211 /* disable interrupts and get the hardware into a known state */
212 IXGB_WRITE_REG(&adapter->hw, IMC, 0xffffffff);
214 if ((hw->max_frame_size != max_frame) ||
215 (hw->max_frame_size !=
216 (IXGB_READ_REG(hw, MFS) >> IXGB_MFS_SHIFT))) {
218 hw->max_frame_size = max_frame;
220 IXGB_WRITE_REG(hw, MFS, hw->max_frame_size << IXGB_MFS_SHIFT);
222 if (hw->max_frame_size >
223 IXGB_MAX_ENET_FRAME_SIZE_WITHOUT_FCS + ENET_FCS_LENGTH) {
224 uint32_t ctrl0 = IXGB_READ_REG(hw, CTRL0);
226 if (!(ctrl0 & IXGB_CTRL0_JFE)) {
227 ctrl0 |= IXGB_CTRL0_JFE;
228 IXGB_WRITE_REG(hw, CTRL0, ctrl0);
233 mod_timer(&adapter->watchdog_timer, jiffies);
234 ixgb_irq_enable(adapter);
239 void ixgb_down(struct ixgb_adapter *adapter, boolean_t kill_watchdog)
241 struct net_device *netdev = adapter->netdev;
243 ixgb_irq_disable(adapter);
244 free_irq(adapter->pdev->irq, netdev);
246 del_timer_sync(&adapter->watchdog_timer);
247 adapter->link_speed = 0;
248 adapter->link_duplex = 0;
249 netif_carrier_off(netdev);
250 netif_stop_queue(netdev);
253 ixgb_clean_tx_ring(adapter);
254 ixgb_clean_rx_ring(adapter);
257 void ixgb_reset(struct ixgb_adapter *adapter)
260 ixgb_adapter_stop(&adapter->hw);
261 if (!ixgb_init_hw(&adapter->hw))
262 IXGB_DBG("ixgb_init_hw failed.\n");
266 * ixgb_probe - Device Initialization Routine
267 * @pdev: PCI device information struct
268 * @ent: entry in ixgb_pci_tbl
270 * Returns 0 on success, negative on failure
272 * ixgb_probe initializes an adapter identified by a pci_dev structure.
273 * The OS initialization, configuring of the adapter private structure,
274 * and a hardware reset occur.
278 ixgb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
280 struct net_device *netdev = NULL;
281 struct ixgb_adapter *adapter;
282 static int cards_found = 0;
283 unsigned long mmio_start;
289 if ((err = pci_enable_device(pdev)))
292 if (!(err = pci_set_dma_mask(pdev, DMA_64BIT_MASK))) {
295 if ((err = pci_set_dma_mask(pdev, DMA_32BIT_MASK))) {
296 IXGB_ERR("No usable DMA configuration, aborting\n");
302 if ((err = pci_request_regions(pdev, ixgb_driver_name)))
305 pci_set_master(pdev);
307 netdev = alloc_etherdev(sizeof(struct ixgb_adapter));
310 goto err_alloc_etherdev;
313 SET_MODULE_OWNER(netdev);
314 SET_NETDEV_DEV(netdev, &pdev->dev);
316 pci_set_drvdata(pdev, netdev);
317 adapter = netdev->priv;
318 adapter->netdev = netdev;
319 adapter->pdev = pdev;
320 adapter->hw.back = adapter;
322 mmio_start = pci_resource_start(pdev, BAR_0);
323 mmio_len = pci_resource_len(pdev, BAR_0);
325 adapter->hw.hw_addr = ioremap(mmio_start, mmio_len);
326 if (!adapter->hw.hw_addr) {
331 for (i = BAR_1; i <= BAR_5; i++) {
332 if (pci_resource_len(pdev, i) == 0)
334 if (pci_resource_flags(pdev, i) & IORESOURCE_IO) {
335 adapter->hw.io_base = pci_resource_start(pdev, i);
340 netdev->open = &ixgb_open;
341 netdev->stop = &ixgb_close;
342 netdev->hard_start_xmit = &ixgb_xmit_frame;
343 netdev->get_stats = &ixgb_get_stats;
344 netdev->set_multicast_list = &ixgb_set_multi;
345 netdev->set_mac_address = &ixgb_set_mac;
346 netdev->change_mtu = &ixgb_change_mtu;
347 netdev->do_ioctl = &ixgb_ioctl;
348 netdev->tx_timeout = &ixgb_tx_timeout;
349 netdev->watchdog_timeo = HZ;
350 #ifdef CONFIG_IXGB_NAPI
351 netdev->poll = &ixgb_clean;
354 netdev->vlan_rx_register = ixgb_vlan_rx_register;
355 netdev->vlan_rx_add_vid = ixgb_vlan_rx_add_vid;
356 netdev->vlan_rx_kill_vid = ixgb_vlan_rx_kill_vid;
357 #ifdef CONFIG_NET_POLL_CONTROLLER
358 netdev->poll_controller = ixgb_netpoll;
361 netdev->mem_start = mmio_start;
362 netdev->mem_end = mmio_start + mmio_len;
363 netdev->base_addr = adapter->hw.io_base;
365 adapter->bd_number = cards_found;
366 adapter->link_speed = 0;
367 adapter->link_duplex = 0;
369 /* setup the private structure */
371 if ((err = ixgb_sw_init(adapter)))
374 netdev->features = NETIF_F_SG |
376 NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX | NETIF_F_HW_VLAN_FILTER;
378 netdev->features |= NETIF_F_TSO;
382 netdev->features |= NETIF_F_HIGHDMA;
384 /* make sure the EEPROM is good */
386 if (!ixgb_validate_eeprom_checksum(&adapter->hw)) {
387 printk(KERN_ERR "The EEPROM Checksum Is Not Valid\n");
392 ixgb_get_ee_mac_addr(&adapter->hw, netdev->dev_addr);
394 if (!is_valid_ether_addr(netdev->dev_addr)) {
399 adapter->part_num = ixgb_get_ee_pba_number(&adapter->hw);
401 init_timer(&adapter->watchdog_timer);
402 adapter->watchdog_timer.function = &ixgb_watchdog;
403 adapter->watchdog_timer.data = (unsigned long)adapter;
405 INIT_WORK(&adapter->tx_timeout_task,
406 (void (*)(void *))ixgb_tx_timeout_task, netdev);
408 if ((err = register_netdev(netdev)))
411 /* we're going to reset, so assume we have no link for now */
413 netif_carrier_off(netdev);
414 netif_stop_queue(netdev);
416 printk(KERN_INFO "%s: Intel(R) PRO/10GbE Network Connection\n",
418 ixgb_check_options(adapter);
419 /* reset the hardware with the new settings */
429 iounmap(adapter->hw.hw_addr);
433 pci_release_regions(pdev);
438 * ixgb_remove - Device Removal Routine
439 * @pdev: PCI device information struct
441 * ixgb_remove is called by the PCI subsystem to alert the driver
442 * that it should release a PCI device. The could be caused by a
443 * Hot-Plug event, or because the driver is going to be removed from
447 static void __devexit ixgb_remove(struct pci_dev *pdev)
449 struct net_device *netdev = pci_get_drvdata(pdev);
450 struct ixgb_adapter *adapter = netdev->priv;
452 unregister_netdev(netdev);
454 iounmap(adapter->hw.hw_addr);
455 pci_release_regions(pdev);
461 * ixgb_sw_init - Initialize general software structures (struct ixgb_adapter)
462 * @adapter: board private structure to initialize
464 * ixgb_sw_init initializes the Adapter private data structure.
465 * Fields are initialized based on PCI device information and
466 * OS network device settings (MTU size).
469 static int __devinit ixgb_sw_init(struct ixgb_adapter *adapter)
471 struct ixgb_hw *hw = &adapter->hw;
472 struct net_device *netdev = adapter->netdev;
473 struct pci_dev *pdev = adapter->pdev;
475 /* PCI config space info */
477 hw->vendor_id = pdev->vendor;
478 hw->device_id = pdev->device;
479 hw->subsystem_vendor_id = pdev->subsystem_vendor;
480 hw->subsystem_id = pdev->subsystem_device;
482 adapter->rx_buffer_len = IXGB_RXBUFFER_2048;
484 hw->max_frame_size = netdev->mtu + ENET_HEADER_SIZE + ENET_FCS_LENGTH;
486 if ((hw->device_id == IXGB_DEVICE_ID_82597EX)
487 || (hw->device_id == IXGB_DEVICE_ID_82597EX_SR))
488 hw->mac_type = ixgb_82597;
490 /* should never have loaded on this device */
491 printk(KERN_ERR "ixgb: unsupported device id\n");
494 /* enable flow control to be programmed */
497 atomic_set(&adapter->irq_sem, 1);
498 spin_lock_init(&adapter->tx_lock);
504 * ixgb_open - Called when a network interface is made active
505 * @netdev: network interface device structure
507 * Returns 0 on success, negative value on failure
509 * The open entry point is called when a network interface is made
510 * active by the system (IFF_UP). At this point all resources needed
511 * for transmit and receive operations are allocated, the interrupt
512 * handler is registered with the OS, the watchdog timer is started,
513 * and the stack is notified that the interface is ready.
516 static int ixgb_open(struct net_device *netdev)
518 struct ixgb_adapter *adapter = netdev->priv;
521 /* allocate transmit descriptors */
523 if ((err = ixgb_setup_tx_resources(adapter)))
526 /* allocate receive descriptors */
528 if ((err = ixgb_setup_rx_resources(adapter)))
531 if ((err = ixgb_up(adapter)))
537 ixgb_free_rx_resources(adapter);
539 ixgb_free_tx_resources(adapter);
547 * ixgb_close - Disables a network interface
548 * @netdev: network interface device structure
550 * Returns 0, this is not allowed to fail
552 * The close entry point is called when an interface is de-activated
553 * by the OS. The hardware is still under the drivers control, but
554 * needs to be disabled. A global MAC reset is issued to stop the
555 * hardware, and all transmit and receive resources are freed.
558 static int ixgb_close(struct net_device *netdev)
560 struct ixgb_adapter *adapter = netdev->priv;
562 ixgb_down(adapter, TRUE);
564 ixgb_free_tx_resources(adapter);
565 ixgb_free_rx_resources(adapter);
571 * ixgb_setup_tx_resources - allocate Tx resources (Descriptors)
572 * @adapter: board private structure
574 * Return 0 on success, negative on failure
577 static int ixgb_setup_tx_resources(struct ixgb_adapter *adapter)
579 struct ixgb_desc_ring *txdr = &adapter->tx_ring;
580 struct pci_dev *pdev = adapter->pdev;
583 size = sizeof(struct ixgb_buffer) * txdr->count;
584 txdr->buffer_info = kmalloc(size, GFP_KERNEL);
585 if (!txdr->buffer_info) {
588 memset(txdr->buffer_info, 0, size);
590 /* round up to nearest 4K */
592 txdr->size = txdr->count * sizeof(struct ixgb_tx_desc);
593 IXGB_ROUNDUP(txdr->size, 4096);
595 txdr->desc = pci_alloc_consistent(pdev, txdr->size, &txdr->dma);
597 kfree(txdr->buffer_info);
600 memset(txdr->desc, 0, txdr->size);
602 txdr->next_to_use = 0;
603 txdr->next_to_clean = 0;
609 * ixgb_configure_tx - Configure 82597 Transmit Unit after Reset.
610 * @adapter: board private structure
612 * Configure the Tx unit of the MAC after a reset.
615 static void ixgb_configure_tx(struct ixgb_adapter *adapter)
617 uint64_t tdba = adapter->tx_ring.dma;
618 uint32_t tdlen = adapter->tx_ring.count * sizeof(struct ixgb_tx_desc);
620 struct ixgb_hw *hw = &adapter->hw;
622 /* Setup the Base and Length of the Tx Descriptor Ring
623 * tx_ring.dma can be either a 32 or 64 bit value
626 IXGB_WRITE_REG(hw, TDBAL, (tdba & 0x00000000ffffffffULL));
627 IXGB_WRITE_REG(hw, TDBAH, (tdba >> 32));
629 IXGB_WRITE_REG(hw, TDLEN, tdlen);
631 /* Setup the HW Tx Head and Tail descriptor pointers */
633 IXGB_WRITE_REG(hw, TDH, 0);
634 IXGB_WRITE_REG(hw, TDT, 0);
636 /* don't set up txdctl, it induces performance problems if
637 * configured incorrectly
638 txdctl = TXDCTL_PTHRESH_DEFAULT; // prefetch txds below this threshold
639 txdctl |= (TXDCTL_HTHRESH_DEFAULT // only prefetch if there are this many ready
640 << IXGB_TXDCTL_HTHRESH_SHIFT);
641 IXGB_WRITE_REG (hw, TXDCTL, txdctl);
644 /* Set the Tx Interrupt Delay register */
646 IXGB_WRITE_REG(hw, TIDV, adapter->tx_int_delay);
648 /* Program the Transmit Control Register */
650 tctl = IXGB_TCTL_TCE | IXGB_TCTL_TXEN | IXGB_TCTL_TPDE;
651 IXGB_WRITE_REG(hw, TCTL, tctl);
653 /* Setup Transmit Descriptor Settings for this adapter */
654 adapter->tx_cmd_type =
656 | (adapter->tx_int_delay_enable ? IXGB_TX_DESC_CMD_IDE : 0);
660 * ixgb_setup_rx_resources - allocate Rx resources (Descriptors)
661 * @adapter: board private structure
663 * Returns 0 on success, negative on failure
666 static int ixgb_setup_rx_resources(struct ixgb_adapter *adapter)
668 struct ixgb_desc_ring *rxdr = &adapter->rx_ring;
669 struct pci_dev *pdev = adapter->pdev;
672 size = sizeof(struct ixgb_buffer) * rxdr->count;
673 rxdr->buffer_info = kmalloc(size, GFP_KERNEL);
674 if (!rxdr->buffer_info) {
677 memset(rxdr->buffer_info, 0, size);
679 /* Round up to nearest 4K */
681 rxdr->size = rxdr->count * sizeof(struct ixgb_rx_desc);
682 IXGB_ROUNDUP(rxdr->size, 4096);
684 rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma);
687 kfree(rxdr->buffer_info);
690 memset(rxdr->desc, 0, rxdr->size);
692 rxdr->next_to_clean = 0;
693 rxdr->next_to_use = 0;
699 * ixgb_setup_rctl - configure the receive control register
700 * @adapter: Board private structure
703 static void ixgb_setup_rctl(struct ixgb_adapter *adapter)
707 rctl = IXGB_READ_REG(&adapter->hw, RCTL);
709 rctl &= ~(3 << IXGB_RCTL_MO_SHIFT);
712 IXGB_RCTL_BAM | IXGB_RCTL_RDMTS_1_2 |
713 IXGB_RCTL_RXEN | IXGB_RCTL_CFF |
714 (adapter->hw.mc_filter_type << IXGB_RCTL_MO_SHIFT);
716 rctl |= IXGB_RCTL_SECRC;
718 switch (adapter->rx_buffer_len) {
719 case IXGB_RXBUFFER_2048:
721 rctl |= IXGB_RCTL_BSIZE_2048;
723 case IXGB_RXBUFFER_4096:
724 rctl |= IXGB_RCTL_BSIZE_4096;
726 case IXGB_RXBUFFER_8192:
727 rctl |= IXGB_RCTL_BSIZE_8192;
729 case IXGB_RXBUFFER_16384:
730 rctl |= IXGB_RCTL_BSIZE_16384;
734 IXGB_WRITE_REG(&adapter->hw, RCTL, rctl);
738 * ixgb_configure_rx - Configure 82597 Receive Unit after Reset.
739 * @adapter: board private structure
741 * Configure the Rx unit of the MAC after a reset.
744 static void ixgb_configure_rx(struct ixgb_adapter *adapter)
746 uint64_t rdba = adapter->rx_ring.dma;
747 uint32_t rdlen = adapter->rx_ring.count * sizeof(struct ixgb_rx_desc);
748 struct ixgb_hw *hw = &adapter->hw;
753 /* make sure receives are disabled while setting up the descriptors */
755 rctl = IXGB_READ_REG(hw, RCTL);
756 IXGB_WRITE_REG(hw, RCTL, rctl & ~IXGB_RCTL_RXEN);
758 /* set the Receive Delay Timer Register */
760 IXGB_WRITE_REG(hw, RDTR, adapter->rx_int_delay);
762 /* Setup the Base and Length of the Rx Descriptor Ring */
764 IXGB_WRITE_REG(hw, RDBAL, (rdba & 0x00000000ffffffffULL));
765 IXGB_WRITE_REG(hw, RDBAH, (rdba >> 32));
767 IXGB_WRITE_REG(hw, RDLEN, rdlen);
769 /* Setup the HW Rx Head and Tail Descriptor Pointers */
770 IXGB_WRITE_REG(hw, RDH, 0);
771 IXGB_WRITE_REG(hw, RDT, 0);
773 /* burst 16 or burst when RXT0 */
774 rxdctl = RXDCTL_WTHRESH_DEFAULT << IXGB_RXDCTL_WTHRESH_SHIFT
775 | RXDCTL_HTHRESH_DEFAULT << IXGB_RXDCTL_HTHRESH_SHIFT
776 | RXDCTL_PTHRESH_DEFAULT << IXGB_RXDCTL_PTHRESH_SHIFT;
777 IXGB_WRITE_REG(hw, RXDCTL, rxdctl);
779 if (adapter->raidc) {
781 uint8_t poll_threshold;
783 /* Poll every rx_int_delay period, if RBD exists
784 * Receive Backlog Detection is set to <threshold>
786 * max is 0x3F == set to poll when 504 RxDesc left
789 /* polling times are 1 == 0.8192us
795 #define IXGB_RAIDC_POLL_DEFAULT 122 /* set to poll every ~100 us under load
796 also known as 10000 interrupts / sec */
798 /* divide this by 2^3 (8) to get a register size count */
799 poll_threshold = ((adapter->rx_ring.count - 1) >> 3);
800 /* poll at half of that size */
801 poll_threshold >>= 1;
802 /* make sure its not bigger than our max */
803 poll_threshold &= 0x3F;
805 raidc = IXGB_RAIDC_EN | /* turn on raidc style moderation */
806 IXGB_RAIDC_RXT_GATE | /* don't interrupt with rxt0 while
807 in RBD mode (polling) */
808 (IXGB_RAIDC_POLL_DEFAULT << IXGB_RAIDC_POLL_SHIFT) |
809 /* this sets the regular "min interrupt delay" */
810 (adapter->rx_int_delay << IXGB_RAIDC_DELAY_SHIFT) |
813 IXGB_WRITE_REG(hw, RAIDC, raidc);
816 /* Enable Receive Checksum Offload for TCP and UDP */
817 if (adapter->rx_csum == TRUE) {
818 rxcsum = IXGB_READ_REG(hw, RXCSUM);
819 rxcsum |= IXGB_RXCSUM_TUOFL;
820 IXGB_WRITE_REG(hw, RXCSUM, rxcsum);
823 /* Enable Receives */
825 IXGB_WRITE_REG(hw, RCTL, rctl);
829 * ixgb_free_tx_resources - Free Tx Resources
830 * @adapter: board private structure
832 * Free all transmit software resources
835 static void ixgb_free_tx_resources(struct ixgb_adapter *adapter)
837 struct pci_dev *pdev = adapter->pdev;
839 ixgb_clean_tx_ring(adapter);
841 kfree(adapter->tx_ring.buffer_info);
842 adapter->tx_ring.buffer_info = NULL;
844 pci_free_consistent(pdev, adapter->tx_ring.size,
845 adapter->tx_ring.desc, adapter->tx_ring.dma);
847 adapter->tx_ring.desc = NULL;
851 * ixgb_clean_tx_ring - Free Tx Buffers
852 * @adapter: board private structure
855 static void ixgb_clean_tx_ring(struct ixgb_adapter *adapter)
857 struct ixgb_desc_ring *tx_ring = &adapter->tx_ring;
858 struct ixgb_buffer *buffer_info;
859 struct pci_dev *pdev = adapter->pdev;
863 /* Free all the Tx ring sk_buffs */
865 for (i = 0; i < tx_ring->count; i++) {
866 buffer_info = &tx_ring->buffer_info[i];
867 if (buffer_info->skb) {
871 buffer_info->length, PCI_DMA_TODEVICE);
873 dev_kfree_skb(buffer_info->skb);
875 buffer_info->skb = NULL;
879 size = sizeof(struct ixgb_buffer) * tx_ring->count;
880 memset(tx_ring->buffer_info, 0, size);
882 /* Zero out the descriptor ring */
884 memset(tx_ring->desc, 0, tx_ring->size);
886 tx_ring->next_to_use = 0;
887 tx_ring->next_to_clean = 0;
889 IXGB_WRITE_REG(&adapter->hw, TDH, 0);
890 IXGB_WRITE_REG(&adapter->hw, TDT, 0);
894 * ixgb_free_rx_resources - Free Rx Resources
895 * @adapter: board private structure
897 * Free all receive software resources
900 static void ixgb_free_rx_resources(struct ixgb_adapter *adapter)
902 struct ixgb_desc_ring *rx_ring = &adapter->rx_ring;
903 struct pci_dev *pdev = adapter->pdev;
905 ixgb_clean_rx_ring(adapter);
907 kfree(rx_ring->buffer_info);
908 rx_ring->buffer_info = NULL;
910 pci_free_consistent(pdev, rx_ring->size, rx_ring->desc, rx_ring->dma);
912 rx_ring->desc = NULL;
916 * ixgb_clean_rx_ring - Free Rx Buffers
917 * @adapter: board private structure
920 static void ixgb_clean_rx_ring(struct ixgb_adapter *adapter)
922 struct ixgb_desc_ring *rx_ring = &adapter->rx_ring;
923 struct ixgb_buffer *buffer_info;
924 struct pci_dev *pdev = adapter->pdev;
928 /* Free all the Rx ring sk_buffs */
930 for (i = 0; i < rx_ring->count; i++) {
931 buffer_info = &rx_ring->buffer_info[i];
932 if (buffer_info->skb) {
934 pci_unmap_single(pdev,
939 dev_kfree_skb(buffer_info->skb);
941 buffer_info->skb = NULL;
945 size = sizeof(struct ixgb_buffer) * rx_ring->count;
946 memset(rx_ring->buffer_info, 0, size);
948 /* Zero out the descriptor ring */
950 memset(rx_ring->desc, 0, rx_ring->size);
952 rx_ring->next_to_clean = 0;
953 rx_ring->next_to_use = 0;
955 IXGB_WRITE_REG(&adapter->hw, RDH, 0);
956 IXGB_WRITE_REG(&adapter->hw, RDT, 0);
960 * ixgb_set_mac - Change the Ethernet Address of the NIC
961 * @netdev: network interface device structure
962 * @p: pointer to an address structure
964 * Returns 0 on success, negative on failure
967 static int ixgb_set_mac(struct net_device *netdev, void *p)
969 struct ixgb_adapter *adapter = netdev->priv;
970 struct sockaddr *addr = p;
972 if (!is_valid_ether_addr(addr->sa_data))
973 return -EADDRNOTAVAIL;
975 memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
977 ixgb_rar_set(&adapter->hw, addr->sa_data, 0);
983 * ixgb_set_multi - Multicast and Promiscuous mode set
984 * @netdev: network interface device structure
986 * The set_multi entry point is called whenever the multicast address
987 * list or the network interface flags are updated. This routine is
988 * responsible for configuring the hardware for proper multicast,
989 * promiscuous mode, and all-multi behavior.
992 static void ixgb_set_multi(struct net_device *netdev)
994 struct ixgb_adapter *adapter = netdev->priv;
995 struct ixgb_hw *hw = &adapter->hw;
996 struct dev_mc_list *mc_ptr;
1000 /* Check for Promiscuous and All Multicast modes */
1002 rctl = IXGB_READ_REG(hw, RCTL);
1004 if (netdev->flags & IFF_PROMISC) {
1005 rctl |= (IXGB_RCTL_UPE | IXGB_RCTL_MPE);
1006 } else if (netdev->flags & IFF_ALLMULTI) {
1007 rctl |= IXGB_RCTL_MPE;
1008 rctl &= ~IXGB_RCTL_UPE;
1010 rctl &= ~(IXGB_RCTL_UPE | IXGB_RCTL_MPE);
1013 if (netdev->mc_count > IXGB_MAX_NUM_MULTICAST_ADDRESSES) {
1014 rctl |= IXGB_RCTL_MPE;
1015 IXGB_WRITE_REG(hw, RCTL, rctl);
1017 uint8_t mta[netdev->mc_count * IXGB_ETH_LENGTH_OF_ADDRESS];
1019 IXGB_WRITE_REG(hw, RCTL, rctl);
1021 for (i = 0, mc_ptr = netdev->mc_list; mc_ptr;
1022 i++, mc_ptr = mc_ptr->next)
1023 memcpy(&mta[i * IXGB_ETH_LENGTH_OF_ADDRESS],
1024 mc_ptr->dmi_addr, IXGB_ETH_LENGTH_OF_ADDRESS);
1026 ixgb_mc_addr_list_update(hw, mta, netdev->mc_count, 0);
1031 * ixgb_watchdog - Timer Call-back
1032 * @data: pointer to netdev cast into an unsigned long
1035 static void ixgb_watchdog(unsigned long data)
1037 struct ixgb_adapter *adapter = (struct ixgb_adapter *)data;
1038 struct net_device *netdev = adapter->netdev;
1039 struct ixgb_desc_ring *txdr = &adapter->tx_ring;
1042 ixgb_check_for_link(&adapter->hw);
1044 if (ixgb_check_for_bad_link(&adapter->hw)) {
1045 /* force the reset path */
1046 netif_stop_queue(netdev);
1049 if (adapter->hw.link_up) {
1050 if (!netif_carrier_ok(netdev)) {
1051 printk(KERN_INFO "ixgb: %s NIC Link is Up %d Mbps %s\n",
1052 netdev->name, 10000, "Full Duplex");
1053 adapter->link_speed = 10000;
1054 adapter->link_duplex = FULL_DUPLEX;
1055 netif_carrier_on(netdev);
1056 netif_wake_queue(netdev);
1059 if (netif_carrier_ok(netdev)) {
1060 adapter->link_speed = 0;
1061 adapter->link_duplex = 0;
1063 "ixgb: %s NIC Link is Down\n", netdev->name);
1064 netif_carrier_off(netdev);
1065 netif_stop_queue(netdev);
1070 ixgb_update_stats(adapter);
1072 if (!netif_carrier_ok(netdev)) {
1073 if (IXGB_DESC_UNUSED(txdr) + 1 < txdr->count) {
1074 /* We've lost link, so the controller stops DMA,
1075 * but we've got queued Tx work that's never going
1076 * to get done, so reset controller to flush Tx.
1077 * (Do the reset outside of interrupt context). */
1078 schedule_work(&adapter->tx_timeout_task);
1082 /* Early detection of hung controller */
1083 i = txdr->next_to_clean;
1084 if (txdr->buffer_info[i].dma &&
1085 time_after(jiffies, txdr->buffer_info[i].time_stamp + HZ) &&
1086 !(IXGB_READ_REG(&adapter->hw, STATUS) & IXGB_STATUS_TXOFF))
1087 netif_stop_queue(netdev);
1089 /* generate an interrupt to force clean up of any stragglers */
1090 IXGB_WRITE_REG(&adapter->hw, ICS, IXGB_INT_TXDW);
1092 /* Reset the timer */
1093 mod_timer(&adapter->watchdog_timer, jiffies + 2 * HZ);
1096 #define IXGB_TX_FLAGS_CSUM 0x00000001
1097 #define IXGB_TX_FLAGS_VLAN 0x00000002
1098 #define IXGB_TX_FLAGS_TSO 0x00000004
1100 static inline boolean_t
1101 ixgb_tso(struct ixgb_adapter *adapter, struct sk_buff *skb)
1104 struct ixgb_context_desc *context_desc;
1106 uint8_t ipcss, ipcso, tucss, tucso, hdr_len;
1107 uint16_t ipcse, tucse, mss;
1109 if (likely(skb_shinfo(skb)->tso_size)) {
1110 hdr_len = ((skb->h.raw - skb->data) + (skb->h.th->doff << 2));
1111 mss = skb_shinfo(skb)->tso_size;
1112 skb->nh.iph->tot_len = 0;
1113 skb->nh.iph->check = 0;
1114 skb->h.th->check = ~csum_tcpudp_magic(skb->nh.iph->saddr,
1117 ipcss = skb->nh.raw - skb->data;
1118 ipcso = (void *)&(skb->nh.iph->check) - (void *)skb->data;
1119 ipcse = skb->h.raw - skb->data - 1;
1120 tucss = skb->h.raw - skb->data;
1121 tucso = (void *)&(skb->h.th->check) - (void *)skb->data;
1124 i = adapter->tx_ring.next_to_use;
1125 context_desc = IXGB_CONTEXT_DESC(adapter->tx_ring, i);
1127 context_desc->ipcss = ipcss;
1128 context_desc->ipcso = ipcso;
1129 context_desc->ipcse = cpu_to_le16(ipcse);
1130 context_desc->tucss = tucss;
1131 context_desc->tucso = tucso;
1132 context_desc->tucse = cpu_to_le16(tucse);
1133 context_desc->mss = cpu_to_le16(mss);
1134 context_desc->hdr_len = hdr_len;
1135 context_desc->status = 0;
1136 context_desc->cmd_type_len = cpu_to_le32(IXGB_CONTEXT_DESC_TYPE
1138 IXGB_CONTEXT_DESC_CMD_TSE
1140 IXGB_CONTEXT_DESC_CMD_IP
1142 IXGB_CONTEXT_DESC_CMD_TCP
1144 IXGB_CONTEXT_DESC_CMD_RS
1146 IXGB_CONTEXT_DESC_CMD_IDE
1150 if (++i == adapter->tx_ring.count)
1152 adapter->tx_ring.next_to_use = i;
1161 static inline boolean_t
1162 ixgb_tx_csum(struct ixgb_adapter *adapter, struct sk_buff *skb)
1164 struct ixgb_context_desc *context_desc;
1168 if (likely(skb->ip_summed == CHECKSUM_HW)) {
1169 css = skb->h.raw - skb->data;
1170 cso = (skb->h.raw + skb->csum) - skb->data;
1172 i = adapter->tx_ring.next_to_use;
1173 context_desc = IXGB_CONTEXT_DESC(adapter->tx_ring, i);
1175 context_desc->tucss = css;
1176 context_desc->tucso = cso;
1177 context_desc->tucse = 0;
1178 /* zero out any previously existing data in one instruction */
1179 *(uint32_t *) & (context_desc->ipcss) = 0;
1180 context_desc->status = 0;
1181 context_desc->hdr_len = 0;
1182 context_desc->mss = 0;
1183 context_desc->cmd_type_len =
1184 cpu_to_le32(IXGB_CONTEXT_DESC_TYPE
1185 | IXGB_TX_DESC_CMD_RS | IXGB_TX_DESC_CMD_IDE);
1187 if (++i == adapter->tx_ring.count)
1189 adapter->tx_ring.next_to_use = i;
1197 #define IXGB_MAX_TXD_PWR 14
1198 #define IXGB_MAX_DATA_PER_TXD (1<<IXGB_MAX_TXD_PWR)
1201 ixgb_tx_map(struct ixgb_adapter *adapter, struct sk_buff *skb,
1204 struct ixgb_desc_ring *tx_ring = &adapter->tx_ring;
1205 struct ixgb_buffer *buffer_info;
1207 unsigned int offset = 0, size, count = 0, i;
1209 unsigned int nr_frags = skb_shinfo(skb)->nr_frags;
1211 len -= skb->data_len;
1213 i = tx_ring->next_to_use;
1216 buffer_info = &tx_ring->buffer_info[i];
1217 size = min(len, IXGB_MAX_JUMBO_FRAME_SIZE);
1218 buffer_info->length = size;
1220 pci_map_single(adapter->pdev,
1221 skb->data + offset, size, PCI_DMA_TODEVICE);
1222 buffer_info->time_stamp = jiffies;
1227 if (++i == tx_ring->count)
1231 for (f = 0; f < nr_frags; f++) {
1232 struct skb_frag_struct *frag;
1234 frag = &skb_shinfo(skb)->frags[f];
1239 buffer_info = &tx_ring->buffer_info[i];
1240 size = min(len, IXGB_MAX_JUMBO_FRAME_SIZE);
1241 buffer_info->length = size;
1243 pci_map_page(adapter->pdev,
1245 frag->page_offset + offset,
1246 size, PCI_DMA_TODEVICE);
1247 buffer_info->time_stamp = jiffies;
1252 if (++i == tx_ring->count)
1256 i = (i == 0) ? tx_ring->count - 1 : i - 1;
1257 tx_ring->buffer_info[i].skb = skb;
1258 tx_ring->buffer_info[first].next_to_watch = i;
1264 ixgb_tx_queue(struct ixgb_adapter *adapter, int count, int vlan_id,
1267 struct ixgb_desc_ring *tx_ring = &adapter->tx_ring;
1268 struct ixgb_tx_desc *tx_desc = NULL;
1269 struct ixgb_buffer *buffer_info;
1270 uint32_t cmd_type_len = adapter->tx_cmd_type;
1275 if (tx_flags & IXGB_TX_FLAGS_TSO) {
1276 cmd_type_len |= IXGB_TX_DESC_CMD_TSE;
1277 popts |= (IXGB_TX_DESC_POPTS_IXSM | IXGB_TX_DESC_POPTS_TXSM);
1280 if (tx_flags & IXGB_TX_FLAGS_CSUM)
1281 popts |= IXGB_TX_DESC_POPTS_TXSM;
1283 if (tx_flags & IXGB_TX_FLAGS_VLAN) {
1284 cmd_type_len |= IXGB_TX_DESC_CMD_VLE;
1287 i = tx_ring->next_to_use;
1290 buffer_info = &tx_ring->buffer_info[i];
1291 tx_desc = IXGB_TX_DESC(*tx_ring, i);
1292 tx_desc->buff_addr = cpu_to_le64(buffer_info->dma);
1293 tx_desc->cmd_type_len =
1294 cpu_to_le32(cmd_type_len | buffer_info->length);
1295 tx_desc->status = status;
1296 tx_desc->popts = popts;
1297 tx_desc->vlan = cpu_to_le16(vlan_id);
1299 if (++i == tx_ring->count)
1303 tx_desc->cmd_type_len |= cpu_to_le32(IXGB_TX_DESC_CMD_EOP
1304 | IXGB_TX_DESC_CMD_RS);
1306 /* Force memory writes to complete before letting h/w
1307 * know there are new descriptors to fetch. (Only
1308 * applicable for weak-ordered memory model archs,
1309 * such as IA-64). */
1312 tx_ring->next_to_use = i;
1313 IXGB_WRITE_REG(&adapter->hw, TDT, i);
1316 /* Tx Descriptors needed, worst case */
1317 #define TXD_USE_COUNT(S) (((S) >> IXGB_MAX_TXD_PWR) + \
1318 (((S) & (IXGB_MAX_DATA_PER_TXD - 1)) ? 1 : 0))
1319 #define DESC_NEEDED TXD_USE_COUNT(IXGB_MAX_DATA_PER_TXD) + \
1320 MAX_SKB_FRAGS * TXD_USE_COUNT(PAGE_SIZE) + 1
1322 static int ixgb_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
1324 struct ixgb_adapter *adapter = netdev->priv;
1326 unsigned int tx_flags = 0;
1327 unsigned long flags;
1330 if (skb->len <= 0) {
1331 dev_kfree_skb_any(skb);
1335 spin_lock_irqsave(&adapter->tx_lock, flags);
1336 if (unlikely(IXGB_DESC_UNUSED(&adapter->tx_ring) < DESC_NEEDED)) {
1337 netif_stop_queue(netdev);
1338 spin_unlock_irqrestore(&adapter->tx_lock, flags);
1341 spin_unlock_irqrestore(&adapter->tx_lock, flags);
1343 if (adapter->vlgrp && vlan_tx_tag_present(skb)) {
1344 tx_flags |= IXGB_TX_FLAGS_VLAN;
1345 vlan_id = vlan_tx_tag_get(skb);
1348 first = adapter->tx_ring.next_to_use;
1350 if (ixgb_tso(adapter, skb))
1351 tx_flags |= IXGB_TX_FLAGS_TSO;
1352 else if (ixgb_tx_csum(adapter, skb))
1353 tx_flags |= IXGB_TX_FLAGS_CSUM;
1355 ixgb_tx_queue(adapter, ixgb_tx_map(adapter, skb, first), vlan_id,
1358 netdev->trans_start = jiffies;
1364 * ixgb_tx_timeout - Respond to a Tx Hang
1365 * @netdev: network interface device structure
1368 static void ixgb_tx_timeout(struct net_device *netdev)
1370 struct ixgb_adapter *adapter = netdev->priv;
1372 /* Do the reset outside of interrupt context */
1373 schedule_work(&adapter->tx_timeout_task);
1376 static void ixgb_tx_timeout_task(struct net_device *netdev)
1378 struct ixgb_adapter *adapter = netdev->priv;
1380 netif_device_detach(netdev);
1381 ixgb_down(adapter, TRUE);
1383 netif_device_attach(netdev);
1387 * ixgb_get_stats - Get System Network Statistics
1388 * @netdev: network interface device structure
1390 * Returns the address of the device statistics structure.
1391 * The statistics are actually updated from the timer callback.
1394 static struct net_device_stats *ixgb_get_stats(struct net_device *netdev)
1396 struct ixgb_adapter *adapter = netdev->priv;
1398 return &adapter->net_stats;
1402 * ixgb_change_mtu - Change the Maximum Transfer Unit
1403 * @netdev: network interface device structure
1404 * @new_mtu: new value for maximum frame size
1406 * Returns 0 on success, negative on failure
1409 static int ixgb_change_mtu(struct net_device *netdev, int new_mtu)
1411 struct ixgb_adapter *adapter = netdev->priv;
1412 uint32_t old_mtu = adapter->rx_buffer_len;
1413 int max_frame = new_mtu + ENET_HEADER_SIZE + ENET_FCS_LENGTH;
1415 if ((max_frame < IXGB_MIN_ENET_FRAME_SIZE_WITHOUT_FCS + ENET_FCS_LENGTH)
1416 || (max_frame > IXGB_MAX_JUMBO_FRAME_SIZE + ENET_FCS_LENGTH)) {
1417 IXGB_ERR("Invalid MTU setting\n");
1422 IXGB_MAX_ENET_FRAME_SIZE_WITHOUT_FCS + ENET_FCS_LENGTH)
1423 || (max_frame <= IXGB_RXBUFFER_2048)) {
1424 adapter->rx_buffer_len = IXGB_RXBUFFER_2048;
1426 } else if (max_frame <= IXGB_RXBUFFER_4096) {
1427 adapter->rx_buffer_len = IXGB_RXBUFFER_4096;
1429 } else if (max_frame <= IXGB_RXBUFFER_8192) {
1430 adapter->rx_buffer_len = IXGB_RXBUFFER_8192;
1433 adapter->rx_buffer_len = IXGB_RXBUFFER_16384;
1436 netdev->mtu = new_mtu;
1438 if (old_mtu != adapter->rx_buffer_len && netif_running(netdev)) {
1440 ixgb_down(adapter, TRUE);
1448 * ixgb_update_stats - Update the board statistics counters.
1449 * @adapter: board private structure
1452 static void ixgb_update_stats(struct ixgb_adapter *adapter)
1454 adapter->stats.tprl += IXGB_READ_REG(&adapter->hw, TPRL);
1455 adapter->stats.tprh += IXGB_READ_REG(&adapter->hw, TPRH);
1456 adapter->stats.gprcl += IXGB_READ_REG(&adapter->hw, GPRCL);
1457 adapter->stats.gprch += IXGB_READ_REG(&adapter->hw, GPRCH);
1458 adapter->stats.bprcl += IXGB_READ_REG(&adapter->hw, BPRCL);
1459 adapter->stats.bprch += IXGB_READ_REG(&adapter->hw, BPRCH);
1460 adapter->stats.mprcl += IXGB_READ_REG(&adapter->hw, MPRCL);
1461 adapter->stats.mprch += IXGB_READ_REG(&adapter->hw, MPRCH);
1462 adapter->stats.uprcl += IXGB_READ_REG(&adapter->hw, UPRCL);
1463 adapter->stats.uprch += IXGB_READ_REG(&adapter->hw, UPRCH);
1464 adapter->stats.vprcl += IXGB_READ_REG(&adapter->hw, VPRCL);
1465 adapter->stats.vprch += IXGB_READ_REG(&adapter->hw, VPRCH);
1466 adapter->stats.jprcl += IXGB_READ_REG(&adapter->hw, JPRCL);
1467 adapter->stats.jprch += IXGB_READ_REG(&adapter->hw, JPRCH);
1468 adapter->stats.gorcl += IXGB_READ_REG(&adapter->hw, GORCL);
1469 adapter->stats.gorch += IXGB_READ_REG(&adapter->hw, GORCH);
1470 adapter->stats.torl += IXGB_READ_REG(&adapter->hw, TORL);
1471 adapter->stats.torh += IXGB_READ_REG(&adapter->hw, TORH);
1472 adapter->stats.rnbc += IXGB_READ_REG(&adapter->hw, RNBC);
1473 adapter->stats.ruc += IXGB_READ_REG(&adapter->hw, RUC);
1474 adapter->stats.roc += IXGB_READ_REG(&adapter->hw, ROC);
1475 adapter->stats.rlec += IXGB_READ_REG(&adapter->hw, RLEC);
1476 adapter->stats.crcerrs += IXGB_READ_REG(&adapter->hw, CRCERRS);
1477 adapter->stats.icbc += IXGB_READ_REG(&adapter->hw, ICBC);
1478 adapter->stats.ecbc += IXGB_READ_REG(&adapter->hw, ECBC);
1479 adapter->stats.mpc += IXGB_READ_REG(&adapter->hw, MPC);
1480 adapter->stats.tptl += IXGB_READ_REG(&adapter->hw, TPTL);
1481 adapter->stats.tpth += IXGB_READ_REG(&adapter->hw, TPTH);
1482 adapter->stats.gptcl += IXGB_READ_REG(&adapter->hw, GPTCL);
1483 adapter->stats.gptch += IXGB_READ_REG(&adapter->hw, GPTCH);
1484 adapter->stats.bptcl += IXGB_READ_REG(&adapter->hw, BPTCL);
1485 adapter->stats.bptch += IXGB_READ_REG(&adapter->hw, BPTCH);
1486 adapter->stats.mptcl += IXGB_READ_REG(&adapter->hw, MPTCL);
1487 adapter->stats.mptch += IXGB_READ_REG(&adapter->hw, MPTCH);
1488 adapter->stats.uptcl += IXGB_READ_REG(&adapter->hw, UPTCL);
1489 adapter->stats.uptch += IXGB_READ_REG(&adapter->hw, UPTCH);
1490 adapter->stats.vptcl += IXGB_READ_REG(&adapter->hw, VPTCL);
1491 adapter->stats.vptch += IXGB_READ_REG(&adapter->hw, VPTCH);
1492 adapter->stats.jptcl += IXGB_READ_REG(&adapter->hw, JPTCL);
1493 adapter->stats.jptch += IXGB_READ_REG(&adapter->hw, JPTCH);
1494 adapter->stats.gotcl += IXGB_READ_REG(&adapter->hw, GOTCL);
1495 adapter->stats.gotch += IXGB_READ_REG(&adapter->hw, GOTCH);
1496 adapter->stats.totl += IXGB_READ_REG(&adapter->hw, TOTL);
1497 adapter->stats.toth += IXGB_READ_REG(&adapter->hw, TOTH);
1498 adapter->stats.dc += IXGB_READ_REG(&adapter->hw, DC);
1499 adapter->stats.plt64c += IXGB_READ_REG(&adapter->hw, PLT64C);
1500 adapter->stats.tsctc += IXGB_READ_REG(&adapter->hw, TSCTC);
1501 adapter->stats.tsctfc += IXGB_READ_REG(&adapter->hw, TSCTFC);
1502 adapter->stats.ibic += IXGB_READ_REG(&adapter->hw, IBIC);
1503 adapter->stats.rfc += IXGB_READ_REG(&adapter->hw, RFC);
1504 adapter->stats.lfc += IXGB_READ_REG(&adapter->hw, LFC);
1505 adapter->stats.pfrc += IXGB_READ_REG(&adapter->hw, PFRC);
1506 adapter->stats.pftc += IXGB_READ_REG(&adapter->hw, PFTC);
1507 adapter->stats.mcfrc += IXGB_READ_REG(&adapter->hw, MCFRC);
1508 adapter->stats.mcftc += IXGB_READ_REG(&adapter->hw, MCFTC);
1509 adapter->stats.xonrxc += IXGB_READ_REG(&adapter->hw, XONRXC);
1510 adapter->stats.xontxc += IXGB_READ_REG(&adapter->hw, XONTXC);
1511 adapter->stats.xoffrxc += IXGB_READ_REG(&adapter->hw, XOFFRXC);
1512 adapter->stats.xofftxc += IXGB_READ_REG(&adapter->hw, XOFFTXC);
1513 adapter->stats.rjc += IXGB_READ_REG(&adapter->hw, RJC);
1515 /* Fill out the OS statistics structure */
1517 adapter->net_stats.rx_packets = adapter->stats.gprcl;
1518 adapter->net_stats.tx_packets = adapter->stats.gptcl;
1519 adapter->net_stats.rx_bytes = adapter->stats.gorcl;
1520 adapter->net_stats.tx_bytes = adapter->stats.gotcl;
1521 adapter->net_stats.multicast = adapter->stats.mprcl;
1522 adapter->net_stats.collisions = 0;
1524 /* ignore RLEC as it reports errors for padded (<64bytes) frames
1525 * with a length in the type/len field */
1526 adapter->net_stats.rx_errors =
1527 /* adapter->stats.rnbc + */ adapter->stats.crcerrs +
1528 adapter->stats.ruc +
1529 adapter->stats.roc /*+ adapter->stats.rlec */ +
1530 adapter->stats.icbc +
1531 adapter->stats.ecbc + adapter->stats.mpc;
1533 adapter->net_stats.rx_dropped = adapter->stats.mpc;
1536 * adapter->net_stats.rx_length_errors = adapter->stats.rlec;
1539 adapter->net_stats.rx_crc_errors = adapter->stats.crcerrs;
1540 adapter->net_stats.rx_fifo_errors = adapter->stats.mpc;
1541 adapter->net_stats.rx_missed_errors = adapter->stats.mpc;
1542 adapter->net_stats.rx_over_errors = adapter->stats.mpc;
1544 adapter->net_stats.tx_errors = 0;
1545 adapter->net_stats.rx_frame_errors = 0;
1546 adapter->net_stats.tx_aborted_errors = 0;
1547 adapter->net_stats.tx_carrier_errors = 0;
1548 adapter->net_stats.tx_fifo_errors = 0;
1549 adapter->net_stats.tx_heartbeat_errors = 0;
1550 adapter->net_stats.tx_window_errors = 0;
1554 * ixgb_irq_disable - Mask off interrupt generation on the NIC
1555 * @adapter: board private structure
1558 static inline void ixgb_irq_disable(struct ixgb_adapter *adapter)
1560 atomic_inc(&adapter->irq_sem);
1561 IXGB_WRITE_REG(&adapter->hw, IMC, ~0);
1562 IXGB_WRITE_FLUSH(&adapter->hw);
1563 synchronize_irq(adapter->pdev->irq);
1567 * ixgb_irq_enable - Enable default interrupt generation settings
1568 * @adapter: board private structure
1571 static inline void ixgb_irq_enable(struct ixgb_adapter *adapter)
1573 if (atomic_dec_and_test(&adapter->irq_sem)) {
1574 IXGB_WRITE_REG(&adapter->hw, IMS,
1575 IXGB_INT_RXT0 | IXGB_INT_RXDMT0 | IXGB_INT_TXDW |
1576 IXGB_INT_RXO | IXGB_INT_LSC);
1577 IXGB_WRITE_FLUSH(&adapter->hw);
1581 #define IXGB_MAX_INTR 10
1583 * ixgb_intr - Interrupt Handler
1584 * @irq: interrupt number
1585 * @data: pointer to a network interface device structure
1586 * @pt_regs: CPU registers structure
1589 static irqreturn_t ixgb_intr(int irq, void *data, struct pt_regs *regs)
1591 struct net_device *netdev = data;
1592 struct ixgb_adapter *adapter = netdev->priv;
1593 struct ixgb_hw *hw = &adapter->hw;
1594 uint32_t icr = IXGB_READ_REG(&adapter->hw, ICR);
1595 #ifndef CONFIG_IXGB_NAPI
1600 return IRQ_NONE; /* Not our interrupt */
1602 if (unlikely(icr & (IXGB_INT_RXSEQ | IXGB_INT_LSC))) {
1603 mod_timer(&adapter->watchdog_timer, jiffies);
1605 #ifdef CONFIG_IXGB_NAPI
1606 if (netif_rx_schedule_prep(netdev)) {
1608 /* Disable interrupts and register for poll. The flush
1609 of the posted write is intentionally left out.
1612 atomic_inc(&adapter->irq_sem);
1613 IXGB_WRITE_REG(hw, IMC, ~0);
1614 __netif_rx_schedule(netdev);
1617 for (i = 0; i < IXGB_MAX_INTR; i++)
1618 if (!ixgb_clean_rx_irq(adapter) & !ixgb_clean_tx_irq(adapter))
1620 /* if RAIDC:EN == 1 and ICR:RXDMT0 == 1, we need to
1621 * set IMS:RXDMT0 to 1 to restart the RBD timer (POLL)
1623 if ((icr & IXGB_INT_RXDMT0) && adapter->raidc) {
1624 /* ready the timer by writing the clear reg */
1625 IXGB_WRITE_REG(hw, IMC, IXGB_INT_RXDMT0);
1626 /* now restart it, h/w will decide if its necessary */
1627 IXGB_WRITE_REG(hw, IMS, IXGB_INT_RXDMT0);
1633 #ifdef CONFIG_IXGB_NAPI
1635 * ixgb_clean - NAPI Rx polling callback
1636 * @adapter: board private structure
1639 static int ixgb_clean(struct net_device *netdev, int *budget)
1641 struct ixgb_adapter *adapter = netdev->priv;
1642 int work_to_do = min(*budget, netdev->quota);
1645 ixgb_clean_tx_irq(adapter);
1646 ixgb_clean_rx_irq(adapter, &work_done, work_to_do);
1648 *budget -= work_done;
1649 netdev->quota -= work_done;
1651 if (work_done < work_to_do || !netif_running(netdev)) {
1652 netif_rx_complete(netdev);
1653 /* RAIDC will be automatically restarted by irq_enable */
1654 ixgb_irq_enable(adapter);
1657 return (work_done >= work_to_do);
1662 * ixgb_clean_tx_irq - Reclaim resources after transmit completes
1663 * @adapter: board private structure
1666 static boolean_t ixgb_clean_tx_irq(struct ixgb_adapter *adapter)
1668 struct ixgb_desc_ring *tx_ring = &adapter->tx_ring;
1669 struct net_device *netdev = adapter->netdev;
1670 struct pci_dev *pdev = adapter->pdev;
1671 struct ixgb_tx_desc *tx_desc, *eop_desc;
1672 struct ixgb_buffer *buffer_info;
1673 unsigned int i, eop;
1674 boolean_t cleaned = FALSE;
1676 i = tx_ring->next_to_clean;
1677 eop = tx_ring->buffer_info[i].next_to_watch;
1678 eop_desc = IXGB_TX_DESC(*tx_ring, eop);
1680 while (eop_desc->status & cpu_to_le32(IXGB_TX_DESC_STATUS_DD)) {
1682 for (cleaned = FALSE; !cleaned;) {
1683 tx_desc = IXGB_TX_DESC(*tx_ring, i);
1684 buffer_info = &tx_ring->buffer_info[i];
1687 & (IXGB_TX_DESC_POPTS_TXSM |
1688 IXGB_TX_DESC_POPTS_IXSM))
1689 adapter->hw_csum_tx_good++;
1691 if (buffer_info->dma) {
1693 pci_unmap_page(pdev,
1695 buffer_info->length,
1698 buffer_info->dma = 0;
1701 if (buffer_info->skb) {
1703 dev_kfree_skb_any(buffer_info->skb);
1705 buffer_info->skb = NULL;
1708 *(uint32_t *) & (tx_desc->status) = 0;
1710 cleaned = (i == eop);
1711 if (++i == tx_ring->count)
1715 eop = tx_ring->buffer_info[i].next_to_watch;
1716 eop_desc = IXGB_TX_DESC(*tx_ring, eop);
1719 tx_ring->next_to_clean = i;
1721 spin_lock(&adapter->tx_lock);
1722 if (cleaned && netif_queue_stopped(netdev) && netif_carrier_ok(netdev)
1723 && (IXGB_DESC_UNUSED(tx_ring) > IXGB_TX_QUEUE_WAKE)) {
1725 netif_wake_queue(netdev);
1727 spin_unlock(&adapter->tx_lock);
1733 * ixgb_clean_rx_irq - Send received data up the network stack,
1734 * @adapter: board private structure
1738 #ifdef CONFIG_IXGB_NAPI
1739 ixgb_clean_rx_irq(struct ixgb_adapter *adapter, int *work_done, int work_to_do)
1741 ixgb_clean_rx_irq(struct ixgb_adapter *adapter)
1744 struct ixgb_desc_ring *rx_ring = &adapter->rx_ring;
1745 struct net_device *netdev = adapter->netdev;
1746 struct pci_dev *pdev = adapter->pdev;
1747 struct ixgb_rx_desc *rx_desc, *next_rxd;
1748 struct ixgb_buffer *buffer_info, *next_buffer, *next2_buffer;
1749 struct sk_buff *skb, *next_skb;
1752 boolean_t cleaned = FALSE;
1754 i = rx_ring->next_to_clean;
1755 rx_desc = IXGB_RX_DESC(*rx_ring, i);
1756 buffer_info = &rx_ring->buffer_info[i];
1758 while (rx_desc->status & IXGB_RX_DESC_STATUS_DD) {
1760 skb = buffer_info->skb;
1761 prefetch(skb->data);
1763 if (++i == rx_ring->count)
1765 next_rxd = IXGB_RX_DESC(*rx_ring, i);
1768 if ((j = i + 1) == rx_ring->count)
1770 next2_buffer = &rx_ring->buffer_info[j];
1771 prefetch(next2_buffer);
1773 next_buffer = &rx_ring->buffer_info[i];
1774 next_skb = next_buffer->skb;
1777 #ifdef CONFIG_IXGB_NAPI
1778 if (*work_done >= work_to_do)
1786 pci_unmap_single(pdev,
1788 buffer_info->length, PCI_DMA_FROMDEVICE);
1790 length = le16_to_cpu(rx_desc->length);
1792 if (unlikely(!(rx_desc->status & IXGB_RX_DESC_STATUS_EOP))) {
1794 /* All receives must fit into a single buffer */
1796 IXGB_DBG("Receive packet consumed multiple buffers "
1797 "length<%x>\n", length);
1799 dev_kfree_skb_irq(skb);
1800 rx_desc->status = 0;
1801 buffer_info->skb = NULL;
1804 buffer_info = next_buffer;
1808 if (unlikely(rx_desc->errors
1809 & (IXGB_RX_DESC_ERRORS_CE | IXGB_RX_DESC_ERRORS_SE
1810 | IXGB_RX_DESC_ERRORS_P |
1811 IXGB_RX_DESC_ERRORS_RXE))) {
1813 dev_kfree_skb_irq(skb);
1814 rx_desc->status = 0;
1815 buffer_info->skb = NULL;
1818 buffer_info = next_buffer;
1823 skb_put(skb, length);
1825 /* Receive Checksum Offload */
1826 ixgb_rx_checksum(adapter, rx_desc, skb);
1828 skb->protocol = eth_type_trans(skb, netdev);
1829 #ifdef CONFIG_IXGB_NAPI
1831 && (rx_desc->status & IXGB_RX_DESC_STATUS_VP)) {
1832 vlan_hwaccel_receive_skb(skb, adapter->vlgrp,
1833 le16_to_cpu(rx_desc->
1835 IXGB_RX_DESC_SPECIAL_VLAN_MASK));
1837 netif_receive_skb(skb);
1839 #else /* CONFIG_IXGB_NAPI */
1841 && (rx_desc->status & IXGB_RX_DESC_STATUS_VP)) {
1842 vlan_hwaccel_rx(skb, adapter->vlgrp,
1843 le16_to_cpu(rx_desc->
1845 IXGB_RX_DESC_SPECIAL_VLAN_MASK));
1849 #endif /* CONFIG_IXGB_NAPI */
1850 netdev->last_rx = jiffies;
1852 rx_desc->status = 0;
1853 buffer_info->skb = NULL;
1856 buffer_info = next_buffer;
1859 rx_ring->next_to_clean = i;
1861 ixgb_alloc_rx_buffers(adapter);
1867 * ixgb_alloc_rx_buffers - Replace used receive buffers
1868 * @adapter: address of board private structure
1871 static void ixgb_alloc_rx_buffers(struct ixgb_adapter *adapter)
1873 struct ixgb_desc_ring *rx_ring = &adapter->rx_ring;
1874 struct net_device *netdev = adapter->netdev;
1875 struct pci_dev *pdev = adapter->pdev;
1876 struct ixgb_rx_desc *rx_desc;
1877 struct ixgb_buffer *buffer_info;
1878 struct sk_buff *skb;
1880 int num_group_tail_writes;
1883 i = rx_ring->next_to_use;
1884 buffer_info = &rx_ring->buffer_info[i];
1885 cleancount = IXGB_DESC_UNUSED(rx_ring);
1887 /* lessen this to 4 if we're
1888 * in the midst of raidc and rbd is occuring
1889 * because we don't want to delay returning buffers when low
1891 num_group_tail_writes = adapter->raidc ? 4 : IXGB_RX_BUFFER_WRITE;
1893 /* leave one descriptor unused */
1894 while (--cleancount > 0) {
1895 rx_desc = IXGB_RX_DESC(*rx_ring, i);
1897 skb = dev_alloc_skb(adapter->rx_buffer_len + NET_IP_ALIGN);
1899 if (unlikely(!skb)) {
1900 /* Better luck next round */
1904 /* Make buffer alignment 2 beyond a 16 byte boundary
1905 * this will result in a 16 byte aligned IP header after
1906 * the 14 byte MAC header is removed
1908 skb_reserve(skb, NET_IP_ALIGN);
1912 buffer_info->skb = skb;
1913 buffer_info->length = adapter->rx_buffer_len;
1915 pci_map_single(pdev,
1917 adapter->rx_buffer_len, PCI_DMA_FROMDEVICE);
1919 rx_desc->buff_addr = cpu_to_le64(buffer_info->dma);
1921 if ((i & ~(num_group_tail_writes - 1)) == i) {
1922 /* Force memory writes to complete before letting h/w
1923 * know there are new descriptors to fetch. (Only
1924 * applicable for weak-ordered memory model archs,
1925 * such as IA-64). */
1928 IXGB_WRITE_REG(&adapter->hw, RDT, i);
1931 if (++i == rx_ring->count)
1933 buffer_info = &rx_ring->buffer_info[i];
1936 rx_ring->next_to_use = i;
1940 * ixgb_ioctl - perform a command - e.g: ethtool:get_driver_info.
1941 * @param netdev network interface device structure
1942 * @param ifr data to be used/filled in by the ioctl command
1943 * @param cmd ioctl command to execute
1946 static int ixgb_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
1950 return ixgb_ethtool_ioctl(netdev, ifr);
1959 * ixgb_rx_checksum - Receive Checksum Offload for 82597.
1960 * @adapter: board private structure
1961 * @rx_desc: receive descriptor
1962 * @sk_buff: socket buffer with received data
1966 ixgb_rx_checksum(struct ixgb_adapter *adapter,
1967 struct ixgb_rx_desc *rx_desc, struct sk_buff *skb)
1969 /* Ignore Checksum bit is set OR
1970 * TCP Checksum has not been calculated
1972 if ((rx_desc->status & IXGB_RX_DESC_STATUS_IXSM) ||
1973 (!(rx_desc->status & IXGB_RX_DESC_STATUS_TCPCS))) {
1974 skb->ip_summed = CHECKSUM_NONE;
1978 /* At this point we know the hardware did the TCP checksum */
1979 /* now look at the TCP checksum error bit */
1980 if (rx_desc->errors & IXGB_RX_DESC_ERRORS_TCPE) {
1981 /* let the stack verify checksum errors */
1982 skb->ip_summed = CHECKSUM_NONE;
1983 adapter->hw_csum_rx_error++;
1985 /* TCP checksum is good */
1986 skb->ip_summed = CHECKSUM_UNNECESSARY;
1987 adapter->hw_csum_rx_good++;
1992 * ixgb_vlan_rx_register - enables or disables vlan tagging/stripping.
1994 * @param netdev network interface device structure
1995 * @param grp indicates to enable or disable tagging/stripping
1998 ixgb_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp)
2000 struct ixgb_adapter *adapter = netdev->priv;
2001 uint32_t ctrl, rctl;
2003 ixgb_irq_disable(adapter);
2004 adapter->vlgrp = grp;
2007 /* enable VLAN tag insert/strip */
2008 ctrl = IXGB_READ_REG(&adapter->hw, CTRL0);
2009 ctrl |= IXGB_CTRL0_VME;
2010 IXGB_WRITE_REG(&adapter->hw, CTRL0, ctrl);
2012 /* enable VLAN receive filtering */
2014 rctl = IXGB_READ_REG(&adapter->hw, RCTL);
2015 rctl |= IXGB_RCTL_VFE;
2016 rctl &= ~IXGB_RCTL_CFIEN;
2017 IXGB_WRITE_REG(&adapter->hw, RCTL, rctl);
2019 /* disable VLAN tag insert/strip */
2021 ctrl = IXGB_READ_REG(&adapter->hw, CTRL0);
2022 ctrl &= ~IXGB_CTRL0_VME;
2023 IXGB_WRITE_REG(&adapter->hw, CTRL0, ctrl);
2025 /* disable VLAN filtering */
2027 rctl = IXGB_READ_REG(&adapter->hw, RCTL);
2028 rctl &= ~IXGB_RCTL_VFE;
2029 IXGB_WRITE_REG(&adapter->hw, RCTL, rctl);
2032 ixgb_irq_enable(adapter);
2035 static void ixgb_vlan_rx_add_vid(struct net_device *netdev, uint16_t vid)
2037 struct ixgb_adapter *adapter = netdev->priv;
2038 uint32_t vfta, index;
2040 /* add VID to filter table */
2042 index = (vid >> 5) & 0x7F;
2043 vfta = IXGB_READ_REG_ARRAY(&adapter->hw, VFTA, index);
2044 vfta |= (1 << (vid & 0x1F));
2045 ixgb_write_vfta(&adapter->hw, index, vfta);
2048 static void ixgb_vlan_rx_kill_vid(struct net_device *netdev, uint16_t vid)
2050 struct ixgb_adapter *adapter = netdev->priv;
2051 uint32_t vfta, index;
2053 ixgb_irq_disable(adapter);
2056 adapter->vlgrp->vlan_devices[vid] = NULL;
2058 ixgb_irq_enable(adapter);
2060 /* remove VID from filter table */
2062 index = (vid >> 5) & 0x7F;
2063 vfta = IXGB_READ_REG_ARRAY(&adapter->hw, VFTA, index);
2064 vfta &= ~(1 << (vid & 0x1F));
2065 ixgb_write_vfta(&adapter->hw, index, vfta);
2068 static void ixgb_restore_vlan(struct ixgb_adapter *adapter)
2070 ixgb_vlan_rx_register(adapter->netdev, adapter->vlgrp);
2072 if (adapter->vlgrp) {
2074 for (vid = 0; vid < VLAN_GROUP_ARRAY_LEN; vid++) {
2075 if (!adapter->vlgrp->vlan_devices[vid])
2077 ixgb_vlan_rx_add_vid(adapter->netdev, vid);
2083 * ixgb_notify_reboot - handles OS notification of reboot event.
2084 * @param nb notifier block, unused
2085 * @param event Event being passed to driver to act upon
2086 * @param p A pointer to our net device
2089 ixgb_notify_reboot(struct notifier_block *nb, unsigned long event, void *p)
2091 struct pci_dev *pdev = NULL;
2097 while ((pdev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pdev))) {
2098 if (pci_dev_driver(pdev) == &ixgb_driver)
2099 ixgb_suspend(pdev, 3);
2106 * ixgb_suspend - driver suspend function called from notify.
2107 * @param pdev pci driver structure used for passing to
2108 * @param state power state to enter
2110 static int ixgb_suspend(struct pci_dev *pdev, uint32_t state)
2112 struct net_device *netdev = pci_get_drvdata(pdev);
2113 struct ixgb_adapter *adapter = netdev->priv;
2115 netif_device_detach(netdev);
2117 if (netif_running(netdev))
2118 ixgb_down(adapter, TRUE);
2120 pci_save_state(pdev, adapter->pci_state);
2122 state = (state > 0) ? 3 : 0;
2123 pci_set_power_state(pdev, state);
2129 #ifdef CONFIG_NET_POLL_CONTROLLER
2131 * Polling 'interrupt' - used by things like netconsole to send skbs
2132 * without having to re-enable interrupts. It's not called while
2133 * the interrupt routine is executing.
2136 static void ixgb_netpoll(struct net_device *dev)
2138 struct ixgb_adapter *adapter = dev->priv;
2139 disable_irq(adapter->pdev->irq);
2140 ixgb_intr(adapter->pdev->irq, dev, NULL);
2141 enable_irq(adapter->pdev->irq);