Merge branch 'fix/usb-audio' into for-linus
[safe/jmp/linux-2.6] / drivers / net / e1000 / e1000_main.c
index 7dd4ded..6bd63cc 100644 (file)
@@ -31,7 +31,7 @@
 
 char e1000_driver_name[] = "e1000";
 static char e1000_driver_string[] = "Intel(R) PRO/1000 Network Driver";
-#define DRV_VERSION "7.3.20-k3-NAPI"
+#define DRV_VERSION "7.3.21-k3-NAPI"
 const char e1000_driver_version[] = DRV_VERSION;
 static const char e1000_copyright[] = "Copyright (c) 1999-2006 Intel Corporation.";
 
@@ -888,6 +888,26 @@ static int e1000_is_need_ioport(struct pci_dev *pdev)
        }
 }
 
+static const struct net_device_ops e1000_netdev_ops = {
+       .ndo_open               = e1000_open,
+       .ndo_stop               = e1000_close,
+       .ndo_start_xmit         = e1000_xmit_frame,
+       .ndo_get_stats          = e1000_get_stats,
+       .ndo_set_rx_mode        = e1000_set_rx_mode,
+       .ndo_set_mac_address    = e1000_set_mac,
+       .ndo_tx_timeout         = e1000_tx_timeout,
+       .ndo_change_mtu         = e1000_change_mtu,
+       .ndo_do_ioctl           = e1000_ioctl,
+       .ndo_validate_addr      = eth_validate_addr,
+
+       .ndo_vlan_rx_register   = e1000_vlan_rx_register,
+       .ndo_vlan_rx_add_vid    = e1000_vlan_rx_add_vid,
+       .ndo_vlan_rx_kill_vid   = e1000_vlan_rx_kill_vid,
+#ifdef CONFIG_NET_POLL_CONTROLLER
+       .ndo_poll_controller    = e1000_netpoll,
+#endif
+};
+
 /**
  * e1000_probe - Device Initialization Routine
  * @pdev: PCI device information struct
@@ -920,7 +940,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
                err = pci_enable_device(pdev);
        } else {
                bars = pci_select_bars(pdev, IORESOURCE_MEM);
-               err = pci_enable_device(pdev);
+               err = pci_enable_device_mem(pdev);
        }
        if (err)
                return err;
@@ -981,24 +1001,11 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
                }
        }
 
-       netdev->open = &e1000_open;
-       netdev->stop = &e1000_close;
-       netdev->hard_start_xmit = &e1000_xmit_frame;
-       netdev->get_stats = &e1000_get_stats;
-       netdev->set_rx_mode = &e1000_set_rx_mode;
-       netdev->set_mac_address = &e1000_set_mac;
-       netdev->change_mtu = &e1000_change_mtu;
-       netdev->do_ioctl = &e1000_ioctl;
+       netdev->netdev_ops = &e1000_netdev_ops;
        e1000_set_ethtool_ops(netdev);
-       netdev->tx_timeout = &e1000_tx_timeout;
        netdev->watchdog_timeo = 5 * HZ;
        netif_napi_add(netdev, &adapter->napi, e1000_clean, 64);
-       netdev->vlan_rx_register = e1000_vlan_rx_register;
-       netdev->vlan_rx_add_vid = e1000_vlan_rx_add_vid;
-       netdev->vlan_rx_kill_vid = e1000_vlan_rx_kill_vid;
-#ifdef CONFIG_NET_POLL_CONTROLLER
-       netdev->poll_controller = e1000_netpoll;
-#endif
+
        strncpy(netdev->name, pci_name(pdev), sizeof(netdev->name) - 1);
 
        adapter->bd_number = cards_found;
@@ -1175,6 +1182,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
 
        /* initialize the wol settings based on the eeprom settings */
        adapter->wol = adapter->eeprom_wol;
+       device_set_wakeup_enable(&adapter->pdev->dev, adapter->wol);
 
        /* print bus type/speed/width info */
        DPRINTK(PROBE, INFO, "(PCI%s:%s:%s) ",
@@ -1234,12 +1242,8 @@ err_eeprom:
        if (hw->flash_address)
                iounmap(hw->flash_address);
 err_flashmap:
-       for (i = 0; i < adapter->num_rx_queues; i++)
-               dev_put(&adapter->polling_netdev[i]);
-
        kfree(adapter->tx_ring);
        kfree(adapter->rx_ring);
-       kfree(adapter->polling_netdev);
 err_sw_init:
        iounmap(hw->hw_addr);
 err_ioremap:
@@ -1267,7 +1271,6 @@ static void __devexit e1000_remove(struct pci_dev *pdev)
        struct net_device *netdev = pci_get_drvdata(pdev);
        struct e1000_adapter *adapter = netdev_priv(netdev);
        struct e1000_hw *hw = &adapter->hw;
-       int i;
 
        cancel_work_sync(&adapter->reset_task);
 
@@ -1277,9 +1280,6 @@ static void __devexit e1000_remove(struct pci_dev *pdev)
         * would have already happened in close and is redundant. */
        e1000_release_hw_control(adapter);
 
-       for (i = 0; i < adapter->num_rx_queues; i++)
-               dev_put(&adapter->polling_netdev[i]);
-
        unregister_netdev(netdev);
 
        if (!e1000_check_phy_reset_block(hw))
@@ -1287,7 +1287,6 @@ static void __devexit e1000_remove(struct pci_dev *pdev)
 
        kfree(adapter->tx_ring);
        kfree(adapter->rx_ring);
-       kfree(adapter->polling_netdev);
 
        iounmap(hw->hw_addr);
        if (hw->flash_address)
@@ -1313,7 +1312,6 @@ static int __devinit e1000_sw_init(struct e1000_adapter *adapter)
        struct e1000_hw *hw = &adapter->hw;
        struct net_device *netdev = adapter->netdev;
        struct pci_dev *pdev = adapter->pdev;
-       int i;
 
        /* PCI config space info */
 
@@ -1370,11 +1368,6 @@ static int __devinit e1000_sw_init(struct e1000_adapter *adapter)
                return -ENOMEM;
        }
 
-       for (i = 0; i < adapter->num_rx_queues; i++) {
-               adapter->polling_netdev[i].priv = adapter;
-               dev_hold(&adapter->polling_netdev[i]);
-               set_bit(__LINK_STATE_START, &adapter->polling_netdev[i].state);
-       }
        spin_lock_init(&adapter->tx_queue_lock);
 
        /* Explicitly disable IRQ since the NIC can be in any state. */
@@ -1392,8 +1385,7 @@ static int __devinit e1000_sw_init(struct e1000_adapter *adapter)
  * @adapter: board private structure to initialize
  *
  * We allocate one ring per queue at run-time since we don't know the
- * number of queues at compile-time.  The polling_netdev array is
- * intended for Multiqueue, but should work fine with a single queue.
+ * number of queues at compile-time.
  **/
 
 static int __devinit e1000_alloc_queues(struct e1000_adapter *adapter)
@@ -1410,15 +1402,6 @@ static int __devinit e1000_alloc_queues(struct e1000_adapter *adapter)
                return -ENOMEM;
        }
 
-       adapter->polling_netdev = kcalloc(adapter->num_rx_queues,
-                                         sizeof(struct net_device),
-                                         GFP_KERNEL);
-       if (!adapter->polling_netdev) {
-               kfree(adapter->tx_ring);
-               kfree(adapter->rx_ring);
-               return -ENOMEM;
-       }
-
        return E1000_SUCCESS;
 }
 
@@ -2516,10 +2499,11 @@ static void e1000_watchdog(unsigned long data)
                                                   &adapter->link_duplex);
 
                        ctrl = er32(CTRL);
-                       DPRINTK(LINK, INFO, "NIC Link is Up %d Mbps %s, "
-                               "Flow Control: %s\n",
-                               adapter->link_speed,
-                               adapter->link_duplex == FULL_DUPLEX ?
+                       printk(KERN_INFO "e1000: %s NIC Link is Up %d Mbps %s, "
+                              "Flow Control: %s\n",
+                              netdev->name,
+                              adapter->link_speed,
+                              adapter->link_duplex == FULL_DUPLEX ?
                                "Full Duplex" : "Half Duplex",
                                ((ctrl & E1000_CTRL_TFCE) && (ctrl &
                                E1000_CTRL_RFCE)) ? "RX/TX" : ((ctrl &
@@ -2595,7 +2579,8 @@ static void e1000_watchdog(unsigned long data)
                if (netif_carrier_ok(netdev)) {
                        adapter->link_speed = 0;
                        adapter->link_duplex = 0;
-                       DPRINTK(LINK, INFO, "NIC Link is Down\n");
+                       printk(KERN_INFO "e1000: %s NIC Link is Down\n",
+                              netdev->name);
                        netif_carrier_off(netdev);
                        netif_stop_queue(netdev);
                        mod_timer(&adapter->phy_info_timer, round_jiffies(jiffies + 2 * HZ));
@@ -3702,12 +3687,12 @@ static irqreturn_t e1000_intr_msi(int irq, void *data)
                        mod_timer(&adapter->watchdog_timer, jiffies + 1);
        }
 
-       if (likely(netif_rx_schedule_prep(netdev, &adapter->napi))) {
+       if (likely(netif_rx_schedule_prep(&adapter->napi))) {
                adapter->total_tx_bytes = 0;
                adapter->total_tx_packets = 0;
                adapter->total_rx_bytes = 0;
                adapter->total_rx_packets = 0;
-               __netif_rx_schedule(netdev, &adapter->napi);
+               __netif_rx_schedule(&adapter->napi);
        } else
                e1000_irq_enable(adapter);
 
@@ -3727,7 +3712,7 @@ static irqreturn_t e1000_intr(int irq, void *data)
        struct e1000_hw *hw = &adapter->hw;
        u32 rctl, icr = er32(ICR);
 
-       if (unlikely(!icr))
+       if (unlikely((!icr) || test_bit(__E1000_RESETTING, &adapter->flags)))
                return IRQ_NONE;  /* Not our interrupt */
 
        /* IMS will not auto-mask if INT_ASSERTED is not set, and if it is
@@ -3762,12 +3747,12 @@ static irqreturn_t e1000_intr(int irq, void *data)
                ew32(IMC, ~0);
                E1000_WRITE_FLUSH();
        }
-       if (likely(netif_rx_schedule_prep(netdev, &adapter->napi))) {
+       if (likely(netif_rx_schedule_prep(&adapter->napi))) {
                adapter->total_tx_bytes = 0;
                adapter->total_tx_packets = 0;
                adapter->total_rx_bytes = 0;
                adapter->total_rx_packets = 0;
-               __netif_rx_schedule(netdev, &adapter->napi);
+               __netif_rx_schedule(&adapter->napi);
        } else
                /* this really should not happen! if it does it is basically a
                 * bug, but not a hard error, so enable ints and continue */
@@ -3808,7 +3793,7 @@ static int e1000_clean(struct napi_struct *napi, int budget)
        if (work_done < budget) {
                if (likely(adapter->itr_setting & 3))
                        e1000_set_itr(adapter);
-               netif_rx_complete(poll_dev, napi);
+               netif_rx_complete(napi);
                e1000_irq_enable(adapter);
        }