igb: convert to net_device_ops
[deliverable/linux.git] / drivers / net / igb / igb_main.c
index 93d02efa9a0a614167d6dc533178aeaa02cf5556..1026ef402d47d562d5467e717c9325ff43e44996 100644 (file)
 #include <linux/ethtool.h>
 #include <linux/if_vlan.h>
 #include <linux/pci.h>
+#include <linux/pci-aspm.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 #include <linux/if_ether.h>
-#ifdef CONFIG_DCA
+#ifdef CONFIG_IGB_DCA
 #include <linux/dca.h>
 #endif
 #include "igb.h"
@@ -106,11 +107,11 @@ static irqreturn_t igb_msix_other(int irq, void *);
 static irqreturn_t igb_msix_rx(int irq, void *);
 static irqreturn_t igb_msix_tx(int irq, void *);
 static int igb_clean_rx_ring_msix(struct napi_struct *, int);
-#ifdef CONFIG_DCA
+#ifdef CONFIG_IGB_DCA
 static void igb_update_rx_dca(struct igb_ring *);
 static void igb_update_tx_dca(struct igb_ring *);
 static void igb_setup_dca(struct igb_adapter *);
-#endif /* CONFIG_DCA */
+#endif /* CONFIG_IGB_DCA */
 static bool igb_clean_tx_irq(struct igb_ring *);
 static int igb_poll(struct napi_struct *, int);
 static bool igb_clean_rx_irq_adv(struct igb_ring *, int *, int);
@@ -131,7 +132,7 @@ static int igb_suspend(struct pci_dev *, pm_message_t);
 static int igb_resume(struct pci_dev *);
 #endif
 static void igb_shutdown(struct pci_dev *);
-#ifdef CONFIG_DCA
+#ifdef CONFIG_IGB_DCA
 static int igb_notify_dca(struct notifier_block *, unsigned long, void *);
 static struct notifier_block dca_notifier = {
        .notifier_call  = igb_notify_dca,
@@ -207,7 +208,7 @@ static int __init igb_init_module(void)
        global_quad_port_a = 0;
 
        ret = pci_register_driver(&igb_driver);
-#ifdef CONFIG_DCA
+#ifdef CONFIG_IGB_DCA
        dca_register_notify(&dca_notifier);
 #endif
        return ret;
@@ -223,7 +224,7 @@ module_init(igb_init_module);
  **/
 static void __exit igb_exit_module(void)
 {
-#ifdef CONFIG_DCA
+#ifdef CONFIG_IGB_DCA
        dca_unregister_notify(&dca_notifier);
 #endif
        pci_unregister_driver(&igb_driver);
@@ -949,6 +950,24 @@ static int igb_is_need_ioport(struct pci_dev *pdev)
        }
 }
 
+static const struct net_device_ops igb_netdev_ops = {
+       .ndo_open               = igb_open,
+       .ndo_stop               = igb_close,
+       .ndo_get_stats          = igb_get_stats,
+       .ndo_set_multicast_list = igb_set_multi,
+       .ndo_set_mac_address    = igb_set_mac,
+       .ndo_change_mtu         = igb_change_mtu,
+       .ndo_do_ioctl           = igb_ioctl,
+       .ndo_tx_timeout         = igb_tx_timeout,
+       .ndo_validate_addr      = eth_validate_addr,
+       .ndo_vlan_rx_register   = igb_vlan_rx_register,
+       .ndo_vlan_rx_add_vid    = igb_vlan_rx_add_vid,
+       .ndo_vlan_rx_kill_vid   = igb_vlan_rx_kill_vid,
+#ifdef CONFIG_NET_POLL_CONTROLLER
+       .ndo_poll_controller    = igb_netpoll,
+#endif
+};
+
 /**
  * igb_probe - Device Initialization Routine
  * @pdev: PCI device information struct
@@ -966,10 +985,11 @@ static int __devinit igb_probe(struct pci_dev *pdev,
        struct net_device *netdev;
        struct igb_adapter *adapter;
        struct e1000_hw *hw;
+       struct pci_dev *us_dev;
        const struct e1000_info *ei = igb_info_tbl[ent->driver_data];
        unsigned long mmio_start, mmio_len;
-       int i, err, pci_using_dac;
-       u16 eeprom_data = 0;
+       int i, err, pci_using_dac, pos;
+       u16 eeprom_data = 0, state = 0;
        u16 eeprom_apme_mask = IGB_EEPROM_APME;
        u32 part_num;
        int bars, need_ioport;
@@ -1004,6 +1024,27 @@ static int __devinit igb_probe(struct pci_dev *pdev,
                }
        }
 
+       /* 82575 requires that the pci-e link partner disable the L0s state */
+       switch (pdev->device) {
+       case E1000_DEV_ID_82575EB_COPPER:
+       case E1000_DEV_ID_82575EB_FIBER_SERDES:
+       case E1000_DEV_ID_82575GB_QUAD_COPPER:
+               us_dev = pdev->bus->self;
+               pos = pci_find_capability(us_dev, PCI_CAP_ID_EXP);
+               if (pos) {
+                       pci_read_config_word(us_dev, pos + PCI_EXP_LNKCTL,
+                                            &state);
+                       state &= ~PCIE_LINK_STATE_L0S;
+                       pci_write_config_word(us_dev, pos + PCI_EXP_LNKCTL,
+                                             state);
+                       dev_info(&pdev->dev,
+                                "Disabling ASPM L0s upstream switch port %s\n",
+                                pci_name(us_dev));
+               }
+       default:
+               break;
+       }
+
        err = pci_request_selected_regions(pdev, bars, igb_driver_name);
        if (err)
                goto err_pci_reg;
@@ -1036,22 +1077,9 @@ static int __devinit igb_probe(struct pci_dev *pdev,
        if (!adapter->hw.hw_addr)
                goto err_ioremap;
 
-       netdev->open = &igb_open;
-       netdev->stop = &igb_close;
-       netdev->get_stats = &igb_get_stats;
-       netdev->set_multicast_list = &igb_set_multi;
-       netdev->set_mac_address = &igb_set_mac;
-       netdev->change_mtu = &igb_change_mtu;
-       netdev->do_ioctl = &igb_ioctl;
+       netdev->netdev_ops = &igb_netdev_ops;
        igb_set_ethtool_ops(netdev);
-       netdev->tx_timeout = &igb_tx_timeout;
        netdev->watchdog_timeo = 5 * HZ;
-       netdev->vlan_rx_register = igb_vlan_rx_register;
-       netdev->vlan_rx_add_vid = igb_vlan_rx_add_vid;
-       netdev->vlan_rx_kill_vid = igb_vlan_rx_kill_vid;
-#ifdef CONFIG_NET_POLL_CONTROLLER
-       netdev->poll_controller = igb_netpoll;
-#endif
        netdev->hard_start_xmit = &igb_xmit_frame_adv;
 
        strncpy(netdev->name, pci_name(pdev), sizeof(netdev->name) - 1);
@@ -1220,6 +1248,7 @@ static int __devinit igb_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);
 
        /* reset the hardware with the new settings */
        igb_reset(adapter);
@@ -1237,7 +1266,7 @@ static int __devinit igb_probe(struct pci_dev *pdev,
        if (err)
                goto err_register;
 
-#ifdef CONFIG_DCA
+#ifdef CONFIG_IGB_DCA
        if ((adapter->flags & IGB_FLAG_HAS_DCA) &&
            (dca_add_requester(&pdev->dev) == 0)) {
                adapter->flags |= IGB_FLAG_DCA_ENABLED;
@@ -1251,16 +1280,14 @@ static int __devinit igb_probe(struct pci_dev *pdev,
 
        dev_info(&pdev->dev, "Intel(R) Gigabit Ethernet Network Connection\n");
        /* print bus type/speed/width info */
-       dev_info(&pdev->dev,
-                "%s: (PCIe:%s:%s) %02x:%02x:%02x:%02x:%02x:%02x\n",
+       dev_info(&pdev->dev, "%s: (PCIe:%s:%s) %pM\n",
                 netdev->name,
                 ((hw->bus.speed == e1000_bus_speed_2500)
                  ? "2.5Gb/s" : "unknown"),
                 ((hw->bus.width == e1000_bus_width_pcie_x4)
                  ? "Width x4" : (hw->bus.width == e1000_bus_width_pcie_x1)
                  ? "Width x1" : "unknown"),
-                netdev->dev_addr[0], netdev->dev_addr[1], netdev->dev_addr[2],
-                netdev->dev_addr[3], netdev->dev_addr[4], netdev->dev_addr[5]);
+                netdev->dev_addr);
 
        igb_read_part_num(hw, &part_num);
        dev_info(&pdev->dev, "%s: PBA No: %06x-%03x\n", netdev->name,
@@ -1311,7 +1338,7 @@ static void __devexit igb_remove(struct pci_dev *pdev)
 {
        struct net_device *netdev = pci_get_drvdata(pdev);
        struct igb_adapter *adapter = netdev_priv(netdev);
-#ifdef CONFIG_DCA
+#ifdef CONFIG_IGB_DCA
        struct e1000_hw *hw = &adapter->hw;
 #endif
 
@@ -1323,7 +1350,7 @@ static void __devexit igb_remove(struct pci_dev *pdev)
 
        flush_scheduled_work();
 
-#ifdef CONFIG_DCA
+#ifdef CONFIG_IGB_DCA
        if (adapter->flags & IGB_FLAG_DCA_ENABLED) {
                dev_info(&pdev->dev, "DCA disabled\n");
                dca_remove_requester(&pdev->dev);
@@ -3271,7 +3298,7 @@ static irqreturn_t igb_msix_tx(int irq, void *data)
        struct igb_adapter *adapter = tx_ring->adapter;
        struct e1000_hw *hw = &adapter->hw;
 
-#ifdef CONFIG_DCA
+#ifdef CONFIG_IGB_DCA
        if (adapter->flags & IGB_FLAG_DCA_ENABLED)
                igb_update_tx_dca(tx_ring);
 #endif
@@ -3323,14 +3350,14 @@ static irqreturn_t igb_msix_rx(int irq, void *data)
        if (netif_rx_schedule_prep(adapter->netdev, &rx_ring->napi))
                __netif_rx_schedule(adapter->netdev, &rx_ring->napi);
 
-#ifdef CONFIG_DCA
+#ifdef CONFIG_IGB_DCA
        if (adapter->flags & IGB_FLAG_DCA_ENABLED)
                igb_update_rx_dca(rx_ring);
 #endif
                return IRQ_HANDLED;
 }
 
-#ifdef CONFIG_DCA
+#ifdef CONFIG_IGB_DCA
 static void igb_update_rx_dca(struct igb_ring *rx_ring)
 {
        u32 dca_rxctrl;
@@ -3450,7 +3477,7 @@ static int igb_notify_dca(struct notifier_block *nb, unsigned long event,
 
        return ret_val ? NOTIFY_BAD : NOTIFY_DONE;
 }
-#endif /* CONFIG_DCA */
+#endif /* CONFIG_IGB_DCA */
 
 /**
  * igb_intr_msi - Interrupt Handler
@@ -3529,13 +3556,13 @@ static int igb_poll(struct napi_struct *napi, int budget)
        int tx_clean_complete, work_done = 0;
 
        /* this poll routine only supports one tx and one rx queue */
-#ifdef CONFIG_DCA
+#ifdef CONFIG_IGB_DCA
        if (adapter->flags & IGB_FLAG_DCA_ENABLED)
                igb_update_tx_dca(&adapter->tx_ring[0]);
 #endif
        tx_clean_complete = igb_clean_tx_irq(&adapter->tx_ring[0]);
 
-#ifdef CONFIG_DCA
+#ifdef CONFIG_IGB_DCA
        if (adapter->flags & IGB_FLAG_DCA_ENABLED)
                igb_update_rx_dca(&adapter->rx_ring[0]);
 #endif
@@ -3563,7 +3590,7 @@ static int igb_clean_rx_ring_msix(struct napi_struct *napi, int budget)
        struct net_device *netdev = adapter->netdev;
        int work_done = 0;
 
-#ifdef CONFIG_DCA
+#ifdef CONFIG_IGB_DCA
        if (adapter->flags & IGB_FLAG_DCA_ENABLED)
                igb_update_rx_dca(rx_ring);
 #endif
@@ -3918,8 +3945,6 @@ send_up:
 
                igb_receive_skb(rx_ring, staterr, rx_desc, skb);
 
-               netdev->last_rx = jiffies;
-
 next_desc:
                rx_desc->wb.upper.status_error = 0;
 
This page took 0.032641 seconds and 5 git commands to generate.