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 static inline void ixgb_irq_disable(struct ixgb_adapter *adapter);
59 static inline void ixgb_irq_enable(struct ixgb_adapter *adapter);
60 int ixgb_up(struct ixgb_adapter *adapter);
61 void ixgb_down(struct ixgb_adapter *adapter, boolean_t kill_watchdog);
62 void ixgb_reset(struct ixgb_adapter *adapter);
64 static int ixgb_init_module(void);
65 static void ixgb_exit_module(void);
66 static int ixgb_probe(struct pci_dev *pdev, const struct pci_device_id *ent);
67 static void __devexit ixgb_remove(struct pci_dev *pdev);
68 static int ixgb_sw_init(struct ixgb_adapter *adapter);
69 static int ixgb_open(struct net_device *netdev);
70 static int ixgb_close(struct net_device *netdev);
71 static int ixgb_setup_tx_resources(struct ixgb_adapter *adapter);
72 static int ixgb_setup_rx_resources(struct ixgb_adapter *adapter);
73 static void ixgb_configure_tx(struct ixgb_adapter *adapter);
74 static void ixgb_configure_rx(struct ixgb_adapter *adapter);
75 static void ixgb_setup_rctl(struct ixgb_adapter *adapter);
76 static void ixgb_clean_tx_ring(struct ixgb_adapter *adapter);
77 static void ixgb_clean_rx_ring(struct ixgb_adapter *adapter);
78 static void ixgb_free_tx_resources(struct ixgb_adapter *adapter);
79 static void ixgb_free_rx_resources(struct ixgb_adapter *adapter);
80 static void ixgb_set_multi(struct net_device *netdev);
81 static void ixgb_watchdog(unsigned long data);
82 static int ixgb_xmit_frame(struct sk_buff *skb, struct net_device *netdev);
83 static struct net_device_stats *ixgb_get_stats(struct net_device *netdev);
84 static int ixgb_change_mtu(struct net_device *netdev, int new_mtu);
85 static int ixgb_set_mac(struct net_device *netdev, void *p);
86 static void ixgb_update_stats(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 static inline void ixgb_rx_checksum(struct ixgb_adapter *adapter,
90 struct ixgb_rx_desc *rx_desc,
92 #ifdef CONFIG_IXGB_NAPI
93 static int ixgb_clean(struct net_device *netdev, int *budget);
94 static boolean_t ixgb_clean_rx_irq(struct ixgb_adapter *adapter,
95 int *work_done, int work_to_do);
97 static boolean_t ixgb_clean_rx_irq(struct ixgb_adapter *adapter);
99 static void ixgb_alloc_rx_buffers(struct ixgb_adapter *adapter);
100 static int ixgb_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd);
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);
189 * ixgb_irq_disable - Mask off interrupt generation on the NIC
190 * @adapter: board private structure
193 static inline void ixgb_irq_disable(struct ixgb_adapter *adapter)
195 atomic_inc(&adapter->irq_sem);
196 IXGB_WRITE_REG(&adapter->hw, IMC, ~0);
197 IXGB_WRITE_FLUSH(&adapter->hw);
198 synchronize_irq(adapter->pdev->irq);
202 * ixgb_irq_enable - Enable default interrupt generation settings
203 * @adapter: board private structure
206 static inline void ixgb_irq_enable(struct ixgb_adapter *adapter)
208 if (atomic_dec_and_test(&adapter->irq_sem)) {
209 IXGB_WRITE_REG(&adapter->hw, IMS,
210 IXGB_INT_RXT0 | IXGB_INT_RXDMT0 | IXGB_INT_TXDW |
211 IXGB_INT_RXO | IXGB_INT_LSC);
212 IXGB_WRITE_FLUSH(&adapter->hw);
216 int ixgb_up(struct ixgb_adapter *adapter)
218 struct net_device *netdev = adapter->netdev;
220 int max_frame = netdev->mtu + ENET_HEADER_SIZE + ENET_FCS_LENGTH;
221 struct ixgb_hw *hw = &adapter->hw;
223 /* hardware has been reset, we need to reload some things */
225 ixgb_set_multi(netdev);
227 ixgb_restore_vlan(adapter);
229 ixgb_configure_tx(adapter);
230 ixgb_setup_rctl(adapter);
231 ixgb_configure_rx(adapter);
232 ixgb_alloc_rx_buffers(adapter);
234 if ((err = request_irq(adapter->pdev->irq, &ixgb_intr,
235 SA_SHIRQ | SA_SAMPLE_RANDOM,
236 netdev->name, netdev)))
239 /* disable interrupts and get the hardware into a known state */
240 IXGB_WRITE_REG(&adapter->hw, IMC, 0xffffffff);
242 if ((hw->max_frame_size != max_frame) ||
243 (hw->max_frame_size !=
244 (IXGB_READ_REG(hw, MFS) >> IXGB_MFS_SHIFT))) {
246 hw->max_frame_size = max_frame;
248 IXGB_WRITE_REG(hw, MFS, hw->max_frame_size << IXGB_MFS_SHIFT);
250 if (hw->max_frame_size >
251 IXGB_MAX_ENET_FRAME_SIZE_WITHOUT_FCS + ENET_FCS_LENGTH) {
252 uint32_t ctrl0 = IXGB_READ_REG(hw, CTRL0);
254 if (!(ctrl0 & IXGB_CTRL0_JFE)) {
255 ctrl0 |= IXGB_CTRL0_JFE;
256 IXGB_WRITE_REG(hw, CTRL0, ctrl0);
261 mod_timer(&adapter->watchdog_timer, jiffies);
262 ixgb_irq_enable(adapter);
267 void ixgb_down(struct ixgb_adapter *adapter, boolean_t kill_watchdog)
269 struct net_device *netdev = adapter->netdev;
271 ixgb_irq_disable(adapter);
272 free_irq(adapter->pdev->irq, netdev);
274 del_timer_sync(&adapter->watchdog_timer);
275 adapter->link_speed = 0;
276 adapter->link_duplex = 0;
277 netif_carrier_off(netdev);
278 netif_stop_queue(netdev);
281 ixgb_clean_tx_ring(adapter);
282 ixgb_clean_rx_ring(adapter);
285 void ixgb_reset(struct ixgb_adapter *adapter)
288 ixgb_adapter_stop(&adapter->hw);
289 if (!ixgb_init_hw(&adapter->hw))
290 IXGB_DBG("ixgb_init_hw failed.\n");
294 * ixgb_probe - Device Initialization Routine
295 * @pdev: PCI device information struct
296 * @ent: entry in ixgb_pci_tbl
298 * Returns 0 on success, negative on failure
300 * ixgb_probe initializes an adapter identified by a pci_dev structure.
301 * The OS initialization, configuring of the adapter private structure,
302 * and a hardware reset occur.
306 ixgb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
308 struct net_device *netdev = NULL;
309 struct ixgb_adapter *adapter;
310 static int cards_found = 0;
311 unsigned long mmio_start;
317 if ((err = pci_enable_device(pdev)))
320 if (!(err = pci_set_dma_mask(pdev, DMA_64BIT_MASK))) {
323 if ((err = pci_set_dma_mask(pdev, DMA_32BIT_MASK))) {
324 IXGB_ERR("No usable DMA configuration, aborting\n");
330 if ((err = pci_request_regions(pdev, ixgb_driver_name)))
333 pci_set_master(pdev);
335 netdev = alloc_etherdev(sizeof(struct ixgb_adapter));
338 goto err_alloc_etherdev;
341 SET_MODULE_OWNER(netdev);
342 SET_NETDEV_DEV(netdev, &pdev->dev);
344 pci_set_drvdata(pdev, netdev);
345 adapter = netdev->priv;
346 adapter->netdev = netdev;
347 adapter->pdev = pdev;
348 adapter->hw.back = adapter;
350 mmio_start = pci_resource_start(pdev, BAR_0);
351 mmio_len = pci_resource_len(pdev, BAR_0);
353 adapter->hw.hw_addr = ioremap(mmio_start, mmio_len);
354 if (!adapter->hw.hw_addr) {
359 for (i = BAR_1; i <= BAR_5; i++) {
360 if (pci_resource_len(pdev, i) == 0)
362 if (pci_resource_flags(pdev, i) & IORESOURCE_IO) {
363 adapter->hw.io_base = pci_resource_start(pdev, i);
368 netdev->open = &ixgb_open;
369 netdev->stop = &ixgb_close;
370 netdev->hard_start_xmit = &ixgb_xmit_frame;
371 netdev->get_stats = &ixgb_get_stats;
372 netdev->set_multicast_list = &ixgb_set_multi;
373 netdev->set_mac_address = &ixgb_set_mac;
374 netdev->change_mtu = &ixgb_change_mtu;
375 netdev->do_ioctl = &ixgb_ioctl;
376 netdev->tx_timeout = &ixgb_tx_timeout;
377 netdev->watchdog_timeo = HZ;
378 #ifdef CONFIG_IXGB_NAPI
379 netdev->poll = &ixgb_clean;
382 netdev->vlan_rx_register = ixgb_vlan_rx_register;
383 netdev->vlan_rx_add_vid = ixgb_vlan_rx_add_vid;
384 netdev->vlan_rx_kill_vid = ixgb_vlan_rx_kill_vid;
385 #ifdef CONFIG_NET_POLL_CONTROLLER
386 netdev->poll_controller = ixgb_netpoll;
389 netdev->mem_start = mmio_start;
390 netdev->mem_end = mmio_start + mmio_len;
391 netdev->base_addr = adapter->hw.io_base;
393 adapter->bd_number = cards_found;
394 adapter->link_speed = 0;
395 adapter->link_duplex = 0;
397 /* setup the private structure */
399 if ((err = ixgb_sw_init(adapter)))
402 netdev->features = NETIF_F_SG |
404 NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX | NETIF_F_HW_VLAN_FILTER;
406 netdev->features |= NETIF_F_TSO;
410 netdev->features |= NETIF_F_HIGHDMA;
412 /* make sure the EEPROM is good */
414 if (!ixgb_validate_eeprom_checksum(&adapter->hw)) {
415 printk(KERN_ERR "The EEPROM Checksum Is Not Valid\n");
420 ixgb_get_ee_mac_addr(&adapter->hw, netdev->dev_addr);
422 if (!is_valid_ether_addr(netdev->dev_addr)) {
427 adapter->part_num = ixgb_get_ee_pba_number(&adapter->hw);
429 init_timer(&adapter->watchdog_timer);
430 adapter->watchdog_timer.function = &ixgb_watchdog;
431 adapter->watchdog_timer.data = (unsigned long)adapter;
433 INIT_WORK(&adapter->tx_timeout_task,
434 (void (*)(void *))ixgb_tx_timeout_task, netdev);
436 if ((err = register_netdev(netdev)))
439 /* we're going to reset, so assume we have no link for now */
441 netif_carrier_off(netdev);
442 netif_stop_queue(netdev);
444 printk(KERN_INFO "%s: Intel(R) PRO/10GbE Network Connection\n",
446 ixgb_check_options(adapter);
447 /* reset the hardware with the new settings */
457 iounmap(adapter->hw.hw_addr);
461 pci_release_regions(pdev);
466 * ixgb_remove - Device Removal Routine
467 * @pdev: PCI device information struct
469 * ixgb_remove is called by the PCI subsystem to alert the driver
470 * that it should release a PCI device. The could be caused by a
471 * Hot-Plug event, or because the driver is going to be removed from
475 static void __devexit ixgb_remove(struct pci_dev *pdev)
477 struct net_device *netdev = pci_get_drvdata(pdev);
478 struct ixgb_adapter *adapter = netdev->priv;
480 unregister_netdev(netdev);
482 iounmap(adapter->hw.hw_addr);
483 pci_release_regions(pdev);
489 * ixgb_sw_init - Initialize general software structures (struct ixgb_adapter)
490 * @adapter: board private structure to initialize
492 * ixgb_sw_init initializes the Adapter private data structure.
493 * Fields are initialized based on PCI device information and
494 * OS network device settings (MTU size).
497 static int __devinit ixgb_sw_init(struct ixgb_adapter *adapter)
499 struct ixgb_hw *hw = &adapter->hw;
500 struct net_device *netdev = adapter->netdev;
501 struct pci_dev *pdev = adapter->pdev;
503 /* PCI config space info */
505 hw->vendor_id = pdev->vendor;
506 hw->device_id = pdev->device;
507 hw->subsystem_vendor_id = pdev->subsystem_vendor;
508 hw->subsystem_id = pdev->subsystem_device;
510 adapter->rx_buffer_len = IXGB_RXBUFFER_2048;
512 hw->max_frame_size = netdev->mtu + ENET_HEADER_SIZE + ENET_FCS_LENGTH;
514 if ((hw->device_id == IXGB_DEVICE_ID_82597EX)
515 || (hw->device_id == IXGB_DEVICE_ID_82597EX_SR))
516 hw->mac_type = ixgb_82597;
518 /* should never have loaded on this device */
519 printk(KERN_ERR "ixgb: unsupported device id\n");
522 /* enable flow control to be programmed */
525 atomic_set(&adapter->irq_sem, 1);
526 spin_lock_init(&adapter->tx_lock);
532 * ixgb_open - Called when a network interface is made active
533 * @netdev: network interface device structure
535 * Returns 0 on success, negative value on failure
537 * The open entry point is called when a network interface is made
538 * active by the system (IFF_UP). At this point all resources needed
539 * for transmit and receive operations are allocated, the interrupt
540 * handler is registered with the OS, the watchdog timer is started,
541 * and the stack is notified that the interface is ready.
544 static int ixgb_open(struct net_device *netdev)
546 struct ixgb_adapter *adapter = netdev->priv;
549 /* allocate transmit descriptors */
551 if ((err = ixgb_setup_tx_resources(adapter)))
554 /* allocate receive descriptors */
556 if ((err = ixgb_setup_rx_resources(adapter)))
559 if ((err = ixgb_up(adapter)))
565 ixgb_free_rx_resources(adapter);
567 ixgb_free_tx_resources(adapter);
575 * ixgb_close - Disables a network interface
576 * @netdev: network interface device structure
578 * Returns 0, this is not allowed to fail
580 * The close entry point is called when an interface is de-activated
581 * by the OS. The hardware is still under the drivers control, but
582 * needs to be disabled. A global MAC reset is issued to stop the
583 * hardware, and all transmit and receive resources are freed.
586 static int ixgb_close(struct net_device *netdev)
588 struct ixgb_adapter *adapter = netdev->priv;
590 ixgb_down(adapter, TRUE);
592 ixgb_free_tx_resources(adapter);
593 ixgb_free_rx_resources(adapter);
599 * ixgb_setup_tx_resources - allocate Tx resources (Descriptors)
600 * @adapter: board private structure
602 * Return 0 on success, negative on failure
605 static int ixgb_setup_tx_resources(struct ixgb_adapter *adapter)
607 struct ixgb_desc_ring *txdr = &adapter->tx_ring;
608 struct pci_dev *pdev = adapter->pdev;
611 size = sizeof(struct ixgb_buffer) * txdr->count;
612 txdr->buffer_info = kmalloc(size, GFP_KERNEL);
613 if (!txdr->buffer_info) {
616 memset(txdr->buffer_info, 0, size);
618 /* round up to nearest 4K */
620 txdr->size = txdr->count * sizeof(struct ixgb_tx_desc);
621 IXGB_ROUNDUP(txdr->size, 4096);
623 txdr->desc = pci_alloc_consistent(pdev, txdr->size, &txdr->dma);
625 kfree(txdr->buffer_info);
628 memset(txdr->desc, 0, txdr->size);
630 txdr->next_to_use = 0;
631 txdr->next_to_clean = 0;
637 * ixgb_configure_tx - Configure 82597 Transmit Unit after Reset.
638 * @adapter: board private structure
640 * Configure the Tx unit of the MAC after a reset.
643 static void ixgb_configure_tx(struct ixgb_adapter *adapter)
645 uint64_t tdba = adapter->tx_ring.dma;
646 uint32_t tdlen = adapter->tx_ring.count * sizeof(struct ixgb_tx_desc);
648 struct ixgb_hw *hw = &adapter->hw;
650 /* Setup the Base and Length of the Tx Descriptor Ring
651 * tx_ring.dma can be either a 32 or 64 bit value
654 IXGB_WRITE_REG(hw, TDBAL, (tdba & 0x00000000ffffffffULL));
655 IXGB_WRITE_REG(hw, TDBAH, (tdba >> 32));
657 IXGB_WRITE_REG(hw, TDLEN, tdlen);
659 /* Setup the HW Tx Head and Tail descriptor pointers */
661 IXGB_WRITE_REG(hw, TDH, 0);
662 IXGB_WRITE_REG(hw, TDT, 0);
664 /* don't set up txdctl, it induces performance problems if
665 * configured incorrectly
666 txdctl = TXDCTL_PTHRESH_DEFAULT; // prefetch txds below this threshold
667 txdctl |= (TXDCTL_HTHRESH_DEFAULT // only prefetch if there are this many ready
668 << IXGB_TXDCTL_HTHRESH_SHIFT);
669 IXGB_WRITE_REG (hw, TXDCTL, txdctl);
672 /* Set the Tx Interrupt Delay register */
674 IXGB_WRITE_REG(hw, TIDV, adapter->tx_int_delay);
676 /* Program the Transmit Control Register */
678 tctl = IXGB_TCTL_TCE | IXGB_TCTL_TXEN | IXGB_TCTL_TPDE;
679 IXGB_WRITE_REG(hw, TCTL, tctl);
681 /* Setup Transmit Descriptor Settings for this adapter */
682 adapter->tx_cmd_type =
684 | (adapter->tx_int_delay_enable ? IXGB_TX_DESC_CMD_IDE : 0);
688 * ixgb_setup_rx_resources - allocate Rx resources (Descriptors)
689 * @adapter: board private structure
691 * Returns 0 on success, negative on failure
694 static int ixgb_setup_rx_resources(struct ixgb_adapter *adapter)
696 struct ixgb_desc_ring *rxdr = &adapter->rx_ring;
697 struct pci_dev *pdev = adapter->pdev;
700 size = sizeof(struct ixgb_buffer) * rxdr->count;
701 rxdr->buffer_info = kmalloc(size, GFP_KERNEL);
702 if (!rxdr->buffer_info) {
705 memset(rxdr->buffer_info, 0, size);
707 /* Round up to nearest 4K */
709 rxdr->size = rxdr->count * sizeof(struct ixgb_rx_desc);
710 IXGB_ROUNDUP(rxdr->size, 4096);
712 rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma);
715 kfree(rxdr->buffer_info);
718 memset(rxdr->desc, 0, rxdr->size);
720 rxdr->next_to_clean = 0;
721 rxdr->next_to_use = 0;
727 * ixgb_setup_rctl - configure the receive control register
728 * @adapter: Board private structure
731 static void ixgb_setup_rctl(struct ixgb_adapter *adapter)
735 rctl = IXGB_READ_REG(&adapter->hw, RCTL);
737 rctl &= ~(3 << IXGB_RCTL_MO_SHIFT);
740 IXGB_RCTL_BAM | IXGB_RCTL_RDMTS_1_2 |
741 IXGB_RCTL_RXEN | IXGB_RCTL_CFF |
742 (adapter->hw.mc_filter_type << IXGB_RCTL_MO_SHIFT);
744 rctl |= IXGB_RCTL_SECRC;
746 switch (adapter->rx_buffer_len) {
747 case IXGB_RXBUFFER_2048:
749 rctl |= IXGB_RCTL_BSIZE_2048;
751 case IXGB_RXBUFFER_4096:
752 rctl |= IXGB_RCTL_BSIZE_4096;
754 case IXGB_RXBUFFER_8192:
755 rctl |= IXGB_RCTL_BSIZE_8192;
757 case IXGB_RXBUFFER_16384:
758 rctl |= IXGB_RCTL_BSIZE_16384;
762 IXGB_WRITE_REG(&adapter->hw, RCTL, rctl);
766 * ixgb_configure_rx - Configure 82597 Receive Unit after Reset.
767 * @adapter: board private structure
769 * Configure the Rx unit of the MAC after a reset.
772 static void ixgb_configure_rx(struct ixgb_adapter *adapter)
774 uint64_t rdba = adapter->rx_ring.dma;
775 uint32_t rdlen = adapter->rx_ring.count * sizeof(struct ixgb_rx_desc);
776 struct ixgb_hw *hw = &adapter->hw;
781 /* make sure receives are disabled while setting up the descriptors */
783 rctl = IXGB_READ_REG(hw, RCTL);
784 IXGB_WRITE_REG(hw, RCTL, rctl & ~IXGB_RCTL_RXEN);
786 /* set the Receive Delay Timer Register */
788 IXGB_WRITE_REG(hw, RDTR, adapter->rx_int_delay);
790 /* Setup the Base and Length of the Rx Descriptor Ring */
792 IXGB_WRITE_REG(hw, RDBAL, (rdba & 0x00000000ffffffffULL));
793 IXGB_WRITE_REG(hw, RDBAH, (rdba >> 32));
795 IXGB_WRITE_REG(hw, RDLEN, rdlen);
797 /* Setup the HW Rx Head and Tail Descriptor Pointers */
798 IXGB_WRITE_REG(hw, RDH, 0);
799 IXGB_WRITE_REG(hw, RDT, 0);
801 /* burst 16 or burst when RXT0 */
802 rxdctl = RXDCTL_WTHRESH_DEFAULT << IXGB_RXDCTL_WTHRESH_SHIFT
803 | RXDCTL_HTHRESH_DEFAULT << IXGB_RXDCTL_HTHRESH_SHIFT
804 | RXDCTL_PTHRESH_DEFAULT << IXGB_RXDCTL_PTHRESH_SHIFT;
805 IXGB_WRITE_REG(hw, RXDCTL, rxdctl);
807 if (adapter->raidc) {
809 uint8_t poll_threshold;
811 /* Poll every rx_int_delay period, if RBD exists
812 * Receive Backlog Detection is set to <threshold>
814 * max is 0x3F == set to poll when 504 RxDesc left
817 /* polling times are 1 == 0.8192us
823 #define IXGB_RAIDC_POLL_DEFAULT 122 /* set to poll every ~100 us under load
824 also known as 10000 interrupts / sec */
826 /* divide this by 2^3 (8) to get a register size count */
827 poll_threshold = ((adapter->rx_ring.count - 1) >> 3);
828 /* poll at half of that size */
829 poll_threshold >>= 1;
830 /* make sure its not bigger than our max */
831 poll_threshold &= 0x3F;
833 raidc = IXGB_RAIDC_EN | /* turn on raidc style moderation */
834 IXGB_RAIDC_RXT_GATE | /* don't interrupt with rxt0 while
835 in RBD mode (polling) */
836 (IXGB_RAIDC_POLL_DEFAULT << IXGB_RAIDC_POLL_SHIFT) |
837 /* this sets the regular "min interrupt delay" */
838 (adapter->rx_int_delay << IXGB_RAIDC_DELAY_SHIFT) |
841 IXGB_WRITE_REG(hw, RAIDC, raidc);
844 /* Enable Receive Checksum Offload for TCP and UDP */
845 if (adapter->rx_csum == TRUE) {
846 rxcsum = IXGB_READ_REG(hw, RXCSUM);
847 rxcsum |= IXGB_RXCSUM_TUOFL;
848 IXGB_WRITE_REG(hw, RXCSUM, rxcsum);
851 /* Enable Receives */
853 IXGB_WRITE_REG(hw, RCTL, rctl);
857 * ixgb_free_tx_resources - Free Tx Resources
858 * @adapter: board private structure
860 * Free all transmit software resources
863 static void ixgb_free_tx_resources(struct ixgb_adapter *adapter)
865 struct pci_dev *pdev = adapter->pdev;
867 ixgb_clean_tx_ring(adapter);
869 kfree(adapter->tx_ring.buffer_info);
870 adapter->tx_ring.buffer_info = NULL;
872 pci_free_consistent(pdev, adapter->tx_ring.size,
873 adapter->tx_ring.desc, adapter->tx_ring.dma);
875 adapter->tx_ring.desc = NULL;
879 * ixgb_clean_tx_ring - Free Tx Buffers
880 * @adapter: board private structure
883 static void ixgb_clean_tx_ring(struct ixgb_adapter *adapter)
885 struct ixgb_desc_ring *tx_ring = &adapter->tx_ring;
886 struct ixgb_buffer *buffer_info;
887 struct pci_dev *pdev = adapter->pdev;
891 /* Free all the Tx ring sk_buffs */
893 for (i = 0; i < tx_ring->count; i++) {
894 buffer_info = &tx_ring->buffer_info[i];
895 if (buffer_info->skb) {
899 buffer_info->length, PCI_DMA_TODEVICE);
901 dev_kfree_skb(buffer_info->skb);
903 buffer_info->skb = NULL;
907 size = sizeof(struct ixgb_buffer) * tx_ring->count;
908 memset(tx_ring->buffer_info, 0, size);
910 /* Zero out the descriptor ring */
912 memset(tx_ring->desc, 0, tx_ring->size);
914 tx_ring->next_to_use = 0;
915 tx_ring->next_to_clean = 0;
917 IXGB_WRITE_REG(&adapter->hw, TDH, 0);
918 IXGB_WRITE_REG(&adapter->hw, TDT, 0);
922 * ixgb_free_rx_resources - Free Rx Resources
923 * @adapter: board private structure
925 * Free all receive software resources
928 static void ixgb_free_rx_resources(struct ixgb_adapter *adapter)
930 struct ixgb_desc_ring *rx_ring = &adapter->rx_ring;
931 struct pci_dev *pdev = adapter->pdev;
933 ixgb_clean_rx_ring(adapter);
935 kfree(rx_ring->buffer_info);
936 rx_ring->buffer_info = NULL;
938 pci_free_consistent(pdev, rx_ring->size, rx_ring->desc, rx_ring->dma);
940 rx_ring->desc = NULL;
944 * ixgb_clean_rx_ring - Free Rx Buffers
945 * @adapter: board private structure
948 static void ixgb_clean_rx_ring(struct ixgb_adapter *adapter)
950 struct ixgb_desc_ring *rx_ring = &adapter->rx_ring;
951 struct ixgb_buffer *buffer_info;
952 struct pci_dev *pdev = adapter->pdev;
956 /* Free all the Rx ring sk_buffs */
958 for (i = 0; i < rx_ring->count; i++) {
959 buffer_info = &rx_ring->buffer_info[i];
960 if (buffer_info->skb) {
962 pci_unmap_single(pdev,
967 dev_kfree_skb(buffer_info->skb);
969 buffer_info->skb = NULL;
973 size = sizeof(struct ixgb_buffer) * rx_ring->count;
974 memset(rx_ring->buffer_info, 0, size);
976 /* Zero out the descriptor ring */
978 memset(rx_ring->desc, 0, rx_ring->size);
980 rx_ring->next_to_clean = 0;
981 rx_ring->next_to_use = 0;
983 IXGB_WRITE_REG(&adapter->hw, RDH, 0);
984 IXGB_WRITE_REG(&adapter->hw, RDT, 0);
988 * ixgb_set_mac - Change the Ethernet Address of the NIC
989 * @netdev: network interface device structure
990 * @p: pointer to an address structure
992 * Returns 0 on success, negative on failure
995 static int ixgb_set_mac(struct net_device *netdev, void *p)
997 struct ixgb_adapter *adapter = netdev->priv;
998 struct sockaddr *addr = p;
1000 if (!is_valid_ether_addr(addr->sa_data))
1001 return -EADDRNOTAVAIL;
1003 memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
1005 ixgb_rar_set(&adapter->hw, addr->sa_data, 0);
1011 * ixgb_set_multi - Multicast and Promiscuous mode set
1012 * @netdev: network interface device structure
1014 * The set_multi entry point is called whenever the multicast address
1015 * list or the network interface flags are updated. This routine is
1016 * responsible for configuring the hardware for proper multicast,
1017 * promiscuous mode, and all-multi behavior.
1020 static void ixgb_set_multi(struct net_device *netdev)
1022 struct ixgb_adapter *adapter = netdev->priv;
1023 struct ixgb_hw *hw = &adapter->hw;
1024 struct dev_mc_list *mc_ptr;
1028 /* Check for Promiscuous and All Multicast modes */
1030 rctl = IXGB_READ_REG(hw, RCTL);
1032 if (netdev->flags & IFF_PROMISC) {
1033 rctl |= (IXGB_RCTL_UPE | IXGB_RCTL_MPE);
1034 } else if (netdev->flags & IFF_ALLMULTI) {
1035 rctl |= IXGB_RCTL_MPE;
1036 rctl &= ~IXGB_RCTL_UPE;
1038 rctl &= ~(IXGB_RCTL_UPE | IXGB_RCTL_MPE);
1041 if (netdev->mc_count > IXGB_MAX_NUM_MULTICAST_ADDRESSES) {
1042 rctl |= IXGB_RCTL_MPE;
1043 IXGB_WRITE_REG(hw, RCTL, rctl);
1045 uint8_t mta[netdev->mc_count * IXGB_ETH_LENGTH_OF_ADDRESS];
1047 IXGB_WRITE_REG(hw, RCTL, rctl);
1049 for (i = 0, mc_ptr = netdev->mc_list; mc_ptr;
1050 i++, mc_ptr = mc_ptr->next)
1051 memcpy(&mta[i * IXGB_ETH_LENGTH_OF_ADDRESS],
1052 mc_ptr->dmi_addr, IXGB_ETH_LENGTH_OF_ADDRESS);
1054 ixgb_mc_addr_list_update(hw, mta, netdev->mc_count, 0);
1059 * ixgb_watchdog - Timer Call-back
1060 * @data: pointer to netdev cast into an unsigned long
1063 static void ixgb_watchdog(unsigned long data)
1065 struct ixgb_adapter *adapter = (struct ixgb_adapter *)data;
1066 struct net_device *netdev = adapter->netdev;
1067 struct ixgb_desc_ring *txdr = &adapter->tx_ring;
1070 ixgb_check_for_link(&adapter->hw);
1072 if (ixgb_check_for_bad_link(&adapter->hw)) {
1073 /* force the reset path */
1074 netif_stop_queue(netdev);
1077 if (adapter->hw.link_up) {
1078 if (!netif_carrier_ok(netdev)) {
1079 printk(KERN_INFO "ixgb: %s NIC Link is Up %d Mbps %s\n",
1080 netdev->name, 10000, "Full Duplex");
1081 adapter->link_speed = 10000;
1082 adapter->link_duplex = FULL_DUPLEX;
1083 netif_carrier_on(netdev);
1084 netif_wake_queue(netdev);
1087 if (netif_carrier_ok(netdev)) {
1088 adapter->link_speed = 0;
1089 adapter->link_duplex = 0;
1091 "ixgb: %s NIC Link is Down\n", netdev->name);
1092 netif_carrier_off(netdev);
1093 netif_stop_queue(netdev);
1098 ixgb_update_stats(adapter);
1100 if (!netif_carrier_ok(netdev)) {
1101 if (IXGB_DESC_UNUSED(txdr) + 1 < txdr->count) {
1102 /* We've lost link, so the controller stops DMA,
1103 * but we've got queued Tx work that's never going
1104 * to get done, so reset controller to flush Tx.
1105 * (Do the reset outside of interrupt context). */
1106 schedule_work(&adapter->tx_timeout_task);
1110 /* Early detection of hung controller */
1111 i = txdr->next_to_clean;
1112 if (txdr->buffer_info[i].dma &&
1113 time_after(jiffies, txdr->buffer_info[i].time_stamp + HZ) &&
1114 !(IXGB_READ_REG(&adapter->hw, STATUS) & IXGB_STATUS_TXOFF))
1115 netif_stop_queue(netdev);
1117 /* generate an interrupt to force clean up of any stragglers */
1118 IXGB_WRITE_REG(&adapter->hw, ICS, IXGB_INT_TXDW);
1120 /* Reset the timer */
1121 mod_timer(&adapter->watchdog_timer, jiffies + 2 * HZ);
1124 #define IXGB_TX_FLAGS_CSUM 0x00000001
1125 #define IXGB_TX_FLAGS_VLAN 0x00000002
1126 #define IXGB_TX_FLAGS_TSO 0x00000004
1128 static inline boolean_t
1129 ixgb_tso(struct ixgb_adapter *adapter, struct sk_buff *skb)
1132 struct ixgb_context_desc *context_desc;
1134 uint8_t ipcss, ipcso, tucss, tucso, hdr_len;
1135 uint16_t ipcse, tucse, mss;
1137 if (likely(skb_shinfo(skb)->tso_size)) {
1138 hdr_len = ((skb->h.raw - skb->data) + (skb->h.th->doff << 2));
1139 mss = skb_shinfo(skb)->tso_size;
1140 skb->nh.iph->tot_len = 0;
1141 skb->nh.iph->check = 0;
1142 skb->h.th->check = ~csum_tcpudp_magic(skb->nh.iph->saddr,
1145 ipcss = skb->nh.raw - skb->data;
1146 ipcso = (void *)&(skb->nh.iph->check) - (void *)skb->data;
1147 ipcse = skb->h.raw - skb->data - 1;
1148 tucss = skb->h.raw - skb->data;
1149 tucso = (void *)&(skb->h.th->check) - (void *)skb->data;
1152 i = adapter->tx_ring.next_to_use;
1153 context_desc = IXGB_CONTEXT_DESC(adapter->tx_ring, i);
1155 context_desc->ipcss = ipcss;
1156 context_desc->ipcso = ipcso;
1157 context_desc->ipcse = cpu_to_le16(ipcse);
1158 context_desc->tucss = tucss;
1159 context_desc->tucso = tucso;
1160 context_desc->tucse = cpu_to_le16(tucse);
1161 context_desc->mss = cpu_to_le16(mss);
1162 context_desc->hdr_len = hdr_len;
1163 context_desc->status = 0;
1164 context_desc->cmd_type_len = cpu_to_le32(IXGB_CONTEXT_DESC_TYPE
1166 IXGB_CONTEXT_DESC_CMD_TSE
1168 IXGB_CONTEXT_DESC_CMD_IP
1170 IXGB_CONTEXT_DESC_CMD_TCP
1172 IXGB_CONTEXT_DESC_CMD_RS
1174 IXGB_CONTEXT_DESC_CMD_IDE
1178 if (++i == adapter->tx_ring.count)
1180 adapter->tx_ring.next_to_use = i;
1189 static inline boolean_t
1190 ixgb_tx_csum(struct ixgb_adapter *adapter, struct sk_buff *skb)
1192 struct ixgb_context_desc *context_desc;
1196 if (likely(skb->ip_summed == CHECKSUM_HW)) {
1197 css = skb->h.raw - skb->data;
1198 cso = (skb->h.raw + skb->csum) - skb->data;
1200 i = adapter->tx_ring.next_to_use;
1201 context_desc = IXGB_CONTEXT_DESC(adapter->tx_ring, i);
1203 context_desc->tucss = css;
1204 context_desc->tucso = cso;
1205 context_desc->tucse = 0;
1206 /* zero out any previously existing data in one instruction */
1207 *(uint32_t *) & (context_desc->ipcss) = 0;
1208 context_desc->status = 0;
1209 context_desc->hdr_len = 0;
1210 context_desc->mss = 0;
1211 context_desc->cmd_type_len =
1212 cpu_to_le32(IXGB_CONTEXT_DESC_TYPE
1213 | IXGB_TX_DESC_CMD_RS | IXGB_TX_DESC_CMD_IDE);
1215 if (++i == adapter->tx_ring.count)
1217 adapter->tx_ring.next_to_use = i;
1225 #define IXGB_MAX_TXD_PWR 14
1226 #define IXGB_MAX_DATA_PER_TXD (1<<IXGB_MAX_TXD_PWR)
1229 ixgb_tx_map(struct ixgb_adapter *adapter, struct sk_buff *skb,
1232 struct ixgb_desc_ring *tx_ring = &adapter->tx_ring;
1233 struct ixgb_buffer *buffer_info;
1235 unsigned int offset = 0, size, count = 0, i;
1237 unsigned int nr_frags = skb_shinfo(skb)->nr_frags;
1239 len -= skb->data_len;
1241 i = tx_ring->next_to_use;
1244 buffer_info = &tx_ring->buffer_info[i];
1245 size = min(len, IXGB_MAX_JUMBO_FRAME_SIZE);
1246 buffer_info->length = size;
1248 pci_map_single(adapter->pdev,
1249 skb->data + offset, size, PCI_DMA_TODEVICE);
1250 buffer_info->time_stamp = jiffies;
1255 if (++i == tx_ring->count)
1259 for (f = 0; f < nr_frags; f++) {
1260 struct skb_frag_struct *frag;
1262 frag = &skb_shinfo(skb)->frags[f];
1267 buffer_info = &tx_ring->buffer_info[i];
1268 size = min(len, IXGB_MAX_JUMBO_FRAME_SIZE);
1269 buffer_info->length = size;
1271 pci_map_page(adapter->pdev,
1273 frag->page_offset + offset,
1274 size, PCI_DMA_TODEVICE);
1275 buffer_info->time_stamp = jiffies;
1280 if (++i == tx_ring->count)
1284 i = (i == 0) ? tx_ring->count - 1 : i - 1;
1285 tx_ring->buffer_info[i].skb = skb;
1286 tx_ring->buffer_info[first].next_to_watch = i;
1292 ixgb_tx_queue(struct ixgb_adapter *adapter, int count, int vlan_id,
1295 struct ixgb_desc_ring *tx_ring = &adapter->tx_ring;
1296 struct ixgb_tx_desc *tx_desc = NULL;
1297 struct ixgb_buffer *buffer_info;
1298 uint32_t cmd_type_len = adapter->tx_cmd_type;
1303 if (tx_flags & IXGB_TX_FLAGS_TSO) {
1304 cmd_type_len |= IXGB_TX_DESC_CMD_TSE;
1305 popts |= (IXGB_TX_DESC_POPTS_IXSM | IXGB_TX_DESC_POPTS_TXSM);
1308 if (tx_flags & IXGB_TX_FLAGS_CSUM)
1309 popts |= IXGB_TX_DESC_POPTS_TXSM;
1311 if (tx_flags & IXGB_TX_FLAGS_VLAN) {
1312 cmd_type_len |= IXGB_TX_DESC_CMD_VLE;
1315 i = tx_ring->next_to_use;
1318 buffer_info = &tx_ring->buffer_info[i];
1319 tx_desc = IXGB_TX_DESC(*tx_ring, i);
1320 tx_desc->buff_addr = cpu_to_le64(buffer_info->dma);
1321 tx_desc->cmd_type_len =
1322 cpu_to_le32(cmd_type_len | buffer_info->length);
1323 tx_desc->status = status;
1324 tx_desc->popts = popts;
1325 tx_desc->vlan = cpu_to_le16(vlan_id);
1327 if (++i == tx_ring->count)
1331 tx_desc->cmd_type_len |= cpu_to_le32(IXGB_TX_DESC_CMD_EOP
1332 | IXGB_TX_DESC_CMD_RS);
1334 /* Force memory writes to complete before letting h/w
1335 * know there are new descriptors to fetch. (Only
1336 * applicable for weak-ordered memory model archs,
1337 * such as IA-64). */
1340 tx_ring->next_to_use = i;
1341 IXGB_WRITE_REG(&adapter->hw, TDT, i);
1344 /* Tx Descriptors needed, worst case */
1345 #define TXD_USE_COUNT(S) (((S) >> IXGB_MAX_TXD_PWR) + \
1346 (((S) & (IXGB_MAX_DATA_PER_TXD - 1)) ? 1 : 0))
1347 #define DESC_NEEDED TXD_USE_COUNT(IXGB_MAX_DATA_PER_TXD) + \
1348 MAX_SKB_FRAGS * TXD_USE_COUNT(PAGE_SIZE) + 1
1350 static int ixgb_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
1352 struct ixgb_adapter *adapter = netdev->priv;
1354 unsigned int tx_flags = 0;
1355 unsigned long flags;
1358 if (skb->len <= 0) {
1359 dev_kfree_skb_any(skb);
1363 spin_lock_irqsave(&adapter->tx_lock, flags);
1364 if (unlikely(IXGB_DESC_UNUSED(&adapter->tx_ring) < DESC_NEEDED)) {
1365 netif_stop_queue(netdev);
1366 spin_unlock_irqrestore(&adapter->tx_lock, flags);
1369 spin_unlock_irqrestore(&adapter->tx_lock, flags);
1371 if (adapter->vlgrp && vlan_tx_tag_present(skb)) {
1372 tx_flags |= IXGB_TX_FLAGS_VLAN;
1373 vlan_id = vlan_tx_tag_get(skb);
1376 first = adapter->tx_ring.next_to_use;
1378 if (ixgb_tso(adapter, skb))
1379 tx_flags |= IXGB_TX_FLAGS_TSO;
1380 else if (ixgb_tx_csum(adapter, skb))
1381 tx_flags |= IXGB_TX_FLAGS_CSUM;
1383 ixgb_tx_queue(adapter, ixgb_tx_map(adapter, skb, first), vlan_id,
1386 netdev->trans_start = jiffies;
1392 * ixgb_tx_timeout - Respond to a Tx Hang
1393 * @netdev: network interface device structure
1396 static void ixgb_tx_timeout(struct net_device *netdev)
1398 struct ixgb_adapter *adapter = netdev->priv;
1400 /* Do the reset outside of interrupt context */
1401 schedule_work(&adapter->tx_timeout_task);
1404 static void ixgb_tx_timeout_task(struct net_device *netdev)
1406 struct ixgb_adapter *adapter = netdev->priv;
1408 netif_device_detach(netdev);
1409 ixgb_down(adapter, TRUE);
1411 netif_device_attach(netdev);
1415 * ixgb_get_stats - Get System Network Statistics
1416 * @netdev: network interface device structure
1418 * Returns the address of the device statistics structure.
1419 * The statistics are actually updated from the timer callback.
1422 static struct net_device_stats *ixgb_get_stats(struct net_device *netdev)
1424 struct ixgb_adapter *adapter = netdev->priv;
1426 return &adapter->net_stats;
1430 * ixgb_change_mtu - Change the Maximum Transfer Unit
1431 * @netdev: network interface device structure
1432 * @new_mtu: new value for maximum frame size
1434 * Returns 0 on success, negative on failure
1437 static int ixgb_change_mtu(struct net_device *netdev, int new_mtu)
1439 struct ixgb_adapter *adapter = netdev->priv;
1440 uint32_t old_mtu = adapter->rx_buffer_len;
1441 int max_frame = new_mtu + ENET_HEADER_SIZE + ENET_FCS_LENGTH;
1443 if ((max_frame < IXGB_MIN_ENET_FRAME_SIZE_WITHOUT_FCS + ENET_FCS_LENGTH)
1444 || (max_frame > IXGB_MAX_JUMBO_FRAME_SIZE + ENET_FCS_LENGTH)) {
1445 IXGB_ERR("Invalid MTU setting\n");
1450 IXGB_MAX_ENET_FRAME_SIZE_WITHOUT_FCS + ENET_FCS_LENGTH)
1451 || (max_frame <= IXGB_RXBUFFER_2048)) {
1452 adapter->rx_buffer_len = IXGB_RXBUFFER_2048;
1454 } else if (max_frame <= IXGB_RXBUFFER_4096) {
1455 adapter->rx_buffer_len = IXGB_RXBUFFER_4096;
1457 } else if (max_frame <= IXGB_RXBUFFER_8192) {
1458 adapter->rx_buffer_len = IXGB_RXBUFFER_8192;
1461 adapter->rx_buffer_len = IXGB_RXBUFFER_16384;
1464 netdev->mtu = new_mtu;
1466 if (old_mtu != adapter->rx_buffer_len && netif_running(netdev)) {
1468 ixgb_down(adapter, TRUE);
1476 * ixgb_update_stats - Update the board statistics counters.
1477 * @adapter: board private structure
1480 static void ixgb_update_stats(struct ixgb_adapter *adapter)
1482 adapter->stats.tprl += IXGB_READ_REG(&adapter->hw, TPRL);
1483 adapter->stats.tprh += IXGB_READ_REG(&adapter->hw, TPRH);
1484 adapter->stats.gprcl += IXGB_READ_REG(&adapter->hw, GPRCL);
1485 adapter->stats.gprch += IXGB_READ_REG(&adapter->hw, GPRCH);
1486 adapter->stats.bprcl += IXGB_READ_REG(&adapter->hw, BPRCL);
1487 adapter->stats.bprch += IXGB_READ_REG(&adapter->hw, BPRCH);
1488 adapter->stats.mprcl += IXGB_READ_REG(&adapter->hw, MPRCL);
1489 adapter->stats.mprch += IXGB_READ_REG(&adapter->hw, MPRCH);
1490 adapter->stats.uprcl += IXGB_READ_REG(&adapter->hw, UPRCL);
1491 adapter->stats.uprch += IXGB_READ_REG(&adapter->hw, UPRCH);
1492 adapter->stats.vprcl += IXGB_READ_REG(&adapter->hw, VPRCL);
1493 adapter->stats.vprch += IXGB_READ_REG(&adapter->hw, VPRCH);
1494 adapter->stats.jprcl += IXGB_READ_REG(&adapter->hw, JPRCL);
1495 adapter->stats.jprch += IXGB_READ_REG(&adapter->hw, JPRCH);
1496 adapter->stats.gorcl += IXGB_READ_REG(&adapter->hw, GORCL);
1497 adapter->stats.gorch += IXGB_READ_REG(&adapter->hw, GORCH);
1498 adapter->stats.torl += IXGB_READ_REG(&adapter->hw, TORL);
1499 adapter->stats.torh += IXGB_READ_REG(&adapter->hw, TORH);
1500 adapter->stats.rnbc += IXGB_READ_REG(&adapter->hw, RNBC);
1501 adapter->stats.ruc += IXGB_READ_REG(&adapter->hw, RUC);
1502 adapter->stats.roc += IXGB_READ_REG(&adapter->hw, ROC);
1503 adapter->stats.rlec += IXGB_READ_REG(&adapter->hw, RLEC);
1504 adapter->stats.crcerrs += IXGB_READ_REG(&adapter->hw, CRCERRS);
1505 adapter->stats.icbc += IXGB_READ_REG(&adapter->hw, ICBC);
1506 adapter->stats.ecbc += IXGB_READ_REG(&adapter->hw, ECBC);
1507 adapter->stats.mpc += IXGB_READ_REG(&adapter->hw, MPC);
1508 adapter->stats.tptl += IXGB_READ_REG(&adapter->hw, TPTL);
1509 adapter->stats.tpth += IXGB_READ_REG(&adapter->hw, TPTH);
1510 adapter->stats.gptcl += IXGB_READ_REG(&adapter->hw, GPTCL);
1511 adapter->stats.gptch += IXGB_READ_REG(&adapter->hw, GPTCH);
1512 adapter->stats.bptcl += IXGB_READ_REG(&adapter->hw, BPTCL);
1513 adapter->stats.bptch += IXGB_READ_REG(&adapter->hw, BPTCH);
1514 adapter->stats.mptcl += IXGB_READ_REG(&adapter->hw, MPTCL);
1515 adapter->stats.mptch += IXGB_READ_REG(&adapter->hw, MPTCH);
1516 adapter->stats.uptcl += IXGB_READ_REG(&adapter->hw, UPTCL);
1517 adapter->stats.uptch += IXGB_READ_REG(&adapter->hw, UPTCH);
1518 adapter->stats.vptcl += IXGB_READ_REG(&adapter->hw, VPTCL);
1519 adapter->stats.vptch += IXGB_READ_REG(&adapter->hw, VPTCH);
1520 adapter->stats.jptcl += IXGB_READ_REG(&adapter->hw, JPTCL);
1521 adapter->stats.jptch += IXGB_READ_REG(&adapter->hw, JPTCH);
1522 adapter->stats.gotcl += IXGB_READ_REG(&adapter->hw, GOTCL);
1523 adapter->stats.gotch += IXGB_READ_REG(&adapter->hw, GOTCH);
1524 adapter->stats.totl += IXGB_READ_REG(&adapter->hw, TOTL);
1525 adapter->stats.toth += IXGB_READ_REG(&adapter->hw, TOTH);
1526 adapter->stats.dc += IXGB_READ_REG(&adapter->hw, DC);
1527 adapter->stats.plt64c += IXGB_READ_REG(&adapter->hw, PLT64C);
1528 adapter->stats.tsctc += IXGB_READ_REG(&adapter->hw, TSCTC);
1529 adapter->stats.tsctfc += IXGB_READ_REG(&adapter->hw, TSCTFC);
1530 adapter->stats.ibic += IXGB_READ_REG(&adapter->hw, IBIC);
1531 adapter->stats.rfc += IXGB_READ_REG(&adapter->hw, RFC);
1532 adapter->stats.lfc += IXGB_READ_REG(&adapter->hw, LFC);
1533 adapter->stats.pfrc += IXGB_READ_REG(&adapter->hw, PFRC);
1534 adapter->stats.pftc += IXGB_READ_REG(&adapter->hw, PFTC);
1535 adapter->stats.mcfrc += IXGB_READ_REG(&adapter->hw, MCFRC);
1536 adapter->stats.mcftc += IXGB_READ_REG(&adapter->hw, MCFTC);
1537 adapter->stats.xonrxc += IXGB_READ_REG(&adapter->hw, XONRXC);
1538 adapter->stats.xontxc += IXGB_READ_REG(&adapter->hw, XONTXC);
1539 adapter->stats.xoffrxc += IXGB_READ_REG(&adapter->hw, XOFFRXC);
1540 adapter->stats.xofftxc += IXGB_READ_REG(&adapter->hw, XOFFTXC);
1541 adapter->stats.rjc += IXGB_READ_REG(&adapter->hw, RJC);
1543 /* Fill out the OS statistics structure */
1545 adapter->net_stats.rx_packets = adapter->stats.gprcl;
1546 adapter->net_stats.tx_packets = adapter->stats.gptcl;
1547 adapter->net_stats.rx_bytes = adapter->stats.gorcl;
1548 adapter->net_stats.tx_bytes = adapter->stats.gotcl;
1549 adapter->net_stats.multicast = adapter->stats.mprcl;
1550 adapter->net_stats.collisions = 0;
1552 /* ignore RLEC as it reports errors for padded (<64bytes) frames
1553 * with a length in the type/len field */
1554 adapter->net_stats.rx_errors =
1555 /* adapter->stats.rnbc + */ adapter->stats.crcerrs +
1556 adapter->stats.ruc +
1557 adapter->stats.roc /*+ adapter->stats.rlec */ +
1558 adapter->stats.icbc +
1559 adapter->stats.ecbc + adapter->stats.mpc;
1561 adapter->net_stats.rx_dropped = adapter->stats.mpc;
1564 * adapter->net_stats.rx_length_errors = adapter->stats.rlec;
1567 adapter->net_stats.rx_crc_errors = adapter->stats.crcerrs;
1568 adapter->net_stats.rx_fifo_errors = adapter->stats.mpc;
1569 adapter->net_stats.rx_missed_errors = adapter->stats.mpc;
1570 adapter->net_stats.rx_over_errors = adapter->stats.mpc;
1572 adapter->net_stats.tx_errors = 0;
1573 adapter->net_stats.rx_frame_errors = 0;
1574 adapter->net_stats.tx_aborted_errors = 0;
1575 adapter->net_stats.tx_carrier_errors = 0;
1576 adapter->net_stats.tx_fifo_errors = 0;
1577 adapter->net_stats.tx_heartbeat_errors = 0;
1578 adapter->net_stats.tx_window_errors = 0;
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_rx_checksum - Receive Checksum Offload for 82597.
1734 * @adapter: board private structure
1735 * @rx_desc: receive descriptor
1736 * @sk_buff: socket buffer with received data
1740 ixgb_rx_checksum(struct ixgb_adapter *adapter,
1741 struct ixgb_rx_desc *rx_desc, struct sk_buff *skb)
1743 /* Ignore Checksum bit is set OR
1744 * TCP Checksum has not been calculated
1746 if ((rx_desc->status & IXGB_RX_DESC_STATUS_IXSM) ||
1747 (!(rx_desc->status & IXGB_RX_DESC_STATUS_TCPCS))) {
1748 skb->ip_summed = CHECKSUM_NONE;
1752 /* At this point we know the hardware did the TCP checksum */
1753 /* now look at the TCP checksum error bit */
1754 if (rx_desc->errors & IXGB_RX_DESC_ERRORS_TCPE) {
1755 /* let the stack verify checksum errors */
1756 skb->ip_summed = CHECKSUM_NONE;
1757 adapter->hw_csum_rx_error++;
1759 /* TCP checksum is good */
1760 skb->ip_summed = CHECKSUM_UNNECESSARY;
1761 adapter->hw_csum_rx_good++;
1766 * ixgb_clean_rx_irq - Send received data up the network stack,
1767 * @adapter: board private structure
1771 #ifdef CONFIG_IXGB_NAPI
1772 ixgb_clean_rx_irq(struct ixgb_adapter *adapter, int *work_done, int work_to_do)
1774 ixgb_clean_rx_irq(struct ixgb_adapter *adapter)
1777 struct ixgb_desc_ring *rx_ring = &adapter->rx_ring;
1778 struct net_device *netdev = adapter->netdev;
1779 struct pci_dev *pdev = adapter->pdev;
1780 struct ixgb_rx_desc *rx_desc, *next_rxd;
1781 struct ixgb_buffer *buffer_info, *next_buffer, *next2_buffer;
1782 struct sk_buff *skb, *next_skb;
1785 boolean_t cleaned = FALSE;
1787 i = rx_ring->next_to_clean;
1788 rx_desc = IXGB_RX_DESC(*rx_ring, i);
1789 buffer_info = &rx_ring->buffer_info[i];
1791 while (rx_desc->status & IXGB_RX_DESC_STATUS_DD) {
1793 skb = buffer_info->skb;
1794 prefetch(skb->data);
1796 if (++i == rx_ring->count)
1798 next_rxd = IXGB_RX_DESC(*rx_ring, i);
1801 if ((j = i + 1) == rx_ring->count)
1803 next2_buffer = &rx_ring->buffer_info[j];
1804 prefetch(next2_buffer);
1806 next_buffer = &rx_ring->buffer_info[i];
1807 next_skb = next_buffer->skb;
1810 #ifdef CONFIG_IXGB_NAPI
1811 if (*work_done >= work_to_do)
1819 pci_unmap_single(pdev,
1821 buffer_info->length, PCI_DMA_FROMDEVICE);
1823 length = le16_to_cpu(rx_desc->length);
1825 if (unlikely(!(rx_desc->status & IXGB_RX_DESC_STATUS_EOP))) {
1827 /* All receives must fit into a single buffer */
1829 IXGB_DBG("Receive packet consumed multiple buffers "
1830 "length<%x>\n", length);
1832 dev_kfree_skb_irq(skb);
1833 rx_desc->status = 0;
1834 buffer_info->skb = NULL;
1837 buffer_info = next_buffer;
1841 if (unlikely(rx_desc->errors
1842 & (IXGB_RX_DESC_ERRORS_CE | IXGB_RX_DESC_ERRORS_SE
1843 | IXGB_RX_DESC_ERRORS_P |
1844 IXGB_RX_DESC_ERRORS_RXE))) {
1846 dev_kfree_skb_irq(skb);
1847 rx_desc->status = 0;
1848 buffer_info->skb = NULL;
1851 buffer_info = next_buffer;
1856 skb_put(skb, length);
1858 /* Receive Checksum Offload */
1859 ixgb_rx_checksum(adapter, rx_desc, skb);
1861 skb->protocol = eth_type_trans(skb, netdev);
1862 #ifdef CONFIG_IXGB_NAPI
1864 && (rx_desc->status & IXGB_RX_DESC_STATUS_VP)) {
1865 vlan_hwaccel_receive_skb(skb, adapter->vlgrp,
1866 le16_to_cpu(rx_desc->
1868 IXGB_RX_DESC_SPECIAL_VLAN_MASK));
1870 netif_receive_skb(skb);
1872 #else /* CONFIG_IXGB_NAPI */
1874 && (rx_desc->status & IXGB_RX_DESC_STATUS_VP)) {
1875 vlan_hwaccel_rx(skb, adapter->vlgrp,
1876 le16_to_cpu(rx_desc->
1878 IXGB_RX_DESC_SPECIAL_VLAN_MASK));
1882 #endif /* CONFIG_IXGB_NAPI */
1883 netdev->last_rx = jiffies;
1885 rx_desc->status = 0;
1886 buffer_info->skb = NULL;
1889 buffer_info = next_buffer;
1892 rx_ring->next_to_clean = i;
1894 ixgb_alloc_rx_buffers(adapter);
1900 * ixgb_alloc_rx_buffers - Replace used receive buffers
1901 * @adapter: address of board private structure
1904 static void ixgb_alloc_rx_buffers(struct ixgb_adapter *adapter)
1906 struct ixgb_desc_ring *rx_ring = &adapter->rx_ring;
1907 struct net_device *netdev = adapter->netdev;
1908 struct pci_dev *pdev = adapter->pdev;
1909 struct ixgb_rx_desc *rx_desc;
1910 struct ixgb_buffer *buffer_info;
1911 struct sk_buff *skb;
1913 int num_group_tail_writes;
1916 i = rx_ring->next_to_use;
1917 buffer_info = &rx_ring->buffer_info[i];
1918 cleancount = IXGB_DESC_UNUSED(rx_ring);
1920 /* lessen this to 4 if we're
1921 * in the midst of raidc and rbd is occuring
1922 * because we don't want to delay returning buffers when low
1924 num_group_tail_writes = adapter->raidc ? 4 : IXGB_RX_BUFFER_WRITE;
1926 /* leave one descriptor unused */
1927 while (--cleancount > 0) {
1928 rx_desc = IXGB_RX_DESC(*rx_ring, i);
1930 skb = dev_alloc_skb(adapter->rx_buffer_len + NET_IP_ALIGN);
1932 if (unlikely(!skb)) {
1933 /* Better luck next round */
1937 /* Make buffer alignment 2 beyond a 16 byte boundary
1938 * this will result in a 16 byte aligned IP header after
1939 * the 14 byte MAC header is removed
1941 skb_reserve(skb, NET_IP_ALIGN);
1945 buffer_info->skb = skb;
1946 buffer_info->length = adapter->rx_buffer_len;
1948 pci_map_single(pdev,
1950 adapter->rx_buffer_len, PCI_DMA_FROMDEVICE);
1952 rx_desc->buff_addr = cpu_to_le64(buffer_info->dma);
1954 if ((i & ~(num_group_tail_writes - 1)) == i) {
1955 /* Force memory writes to complete before letting h/w
1956 * know there are new descriptors to fetch. (Only
1957 * applicable for weak-ordered memory model archs,
1958 * such as IA-64). */
1961 IXGB_WRITE_REG(&adapter->hw, RDT, i);
1964 if (++i == rx_ring->count)
1966 buffer_info = &rx_ring->buffer_info[i];
1969 rx_ring->next_to_use = i;
1973 * ixgb_ioctl - perform a command - e.g: ethtool:get_driver_info.
1974 * @param netdev network interface device structure
1975 * @param ifr data to be used/filled in by the ioctl command
1976 * @param cmd ioctl command to execute
1979 static int ixgb_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
1983 return ixgb_ethtool_ioctl(netdev, ifr);
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);