e1000: Prevent reset task killing itself.
[linux-flexiantxendom0-3.2.10.git] / drivers / net / ethernet / intel / e1000 / e1000_main.c
index 4bbc05a..8d8908d 100644 (file)
 #include <linux/bitops.h>
 #include <linux/if_vlan.h>
 
-/* Intel Media SOC GbE MDIO physical base address */
-static unsigned long ce4100_gbe_mdio_base_phy;
-/* Intel Media SOC GbE MDIO virtual base address */
-void __iomem *ce4100_gbe_mdio_base_virt;
-
 char e1000_driver_name[] = "e1000";
 static char e1000_driver_string[] = "Intel(R) PRO/1000 Network Driver";
 #define DRV_VERSION "7.3.21-k8-NAPI"
@@ -131,10 +126,8 @@ static void e1000_clean_tx_ring(struct e1000_adapter *adapter,
 static void e1000_clean_rx_ring(struct e1000_adapter *adapter,
                                 struct e1000_rx_ring *rx_ring);
 static void e1000_set_rx_mode(struct net_device *netdev);
-static void e1000_update_phy_info(unsigned long data);
 static void e1000_update_phy_info_task(struct work_struct *work);
-static void e1000_watchdog(unsigned long data);
-static void e1000_82547_tx_fifo_stall(unsigned long data);
+static void e1000_watchdog(struct work_struct *work);
 static void e1000_82547_tx_fifo_stall_task(struct work_struct *work);
 static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb,
                                    struct net_device *netdev);
@@ -169,9 +162,12 @@ static int e1000_82547_fifo_workaround(struct e1000_adapter *adapter,
                                        struct sk_buff *skb);
 
 static bool e1000_vlan_used(struct e1000_adapter *adapter);
-static void e1000_vlan_mode(struct net_device *netdev, u32 features);
-static void e1000_vlan_rx_add_vid(struct net_device *netdev, u16 vid);
-static void e1000_vlan_rx_kill_vid(struct net_device *netdev, u16 vid);
+static void e1000_vlan_mode(struct net_device *netdev,
+                           netdev_features_t features);
+static void e1000_vlan_filter_on_off(struct e1000_adapter *adapter,
+                                    bool filter_on);
+static int e1000_vlan_rx_add_vid(struct net_device *netdev, u16 vid);
+static int e1000_vlan_rx_kill_vid(struct net_device *netdev, u16 vid);
 static void e1000_restore_vlan(struct e1000_adapter *adapter);
 
 #ifdef CONFIG_PM
@@ -221,7 +217,8 @@ MODULE_DESCRIPTION("Intel(R) PRO/1000 Network Driver");
 MODULE_LICENSE("GPL");
 MODULE_VERSION(DRV_VERSION);
 
-static int debug = NETIF_MSG_DRV | NETIF_MSG_PROBE;
+#define DEFAULT_MSG_ENABLE (NETIF_MSG_DRV|NETIF_MSG_PROBE|NETIF_MSG_LINK)
+static int debug = -1;
 module_param(debug, int, 0);
 MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)");
 
@@ -487,12 +484,25 @@ static void e1000_power_down_phy(struct e1000_adapter *adapter)
                e1000_read_phy_reg(hw, PHY_CTRL, &mii_reg);
                mii_reg |= MII_CR_POWER_DOWN;
                e1000_write_phy_reg(hw, PHY_CTRL, mii_reg);
-               mdelay(1);
+               msleep(1);
        }
 out:
        return;
 }
 
+static void e1000_down_and_stop(struct e1000_adapter *adapter)
+{
+       set_bit(__E1000_DOWN, &adapter->flags);
+
+       /* Only kill reset task if adapter is not resetting */
+       if (!test_bit(__E1000_RESETTING, &adapter->flags))
+               cancel_work_sync(&adapter->reset_task);
+
+       cancel_delayed_work_sync(&adapter->watchdog_task);
+       cancel_delayed_work_sync(&adapter->phy_info_task);
+       cancel_delayed_work_sync(&adapter->fifo_stall_task);
+}
+
 void e1000_down(struct e1000_adapter *adapter)
 {
        struct e1000_hw *hw = &adapter->hw;
@@ -522,13 +532,9 @@ void e1000_down(struct e1000_adapter *adapter)
        /*
         * Setting DOWN must be after irq_disable to prevent
         * a screaming interrupt.  Setting DOWN also prevents
-        * timers and tasks from rescheduling.
+        * tasks from rescheduling.
         */
-       set_bit(__E1000_DOWN, &adapter->flags);
-
-       del_timer_sync(&adapter->tx_fifo_stall_timer);
-       del_timer_sync(&adapter->watchdog_timer);
-       del_timer_sync(&adapter->phy_info_timer);
+       e1000_down_and_stop(adapter);
 
        adapter->link_speed = 0;
        adapter->link_duplex = 0;
@@ -543,10 +549,10 @@ static void e1000_reinit_safe(struct e1000_adapter *adapter)
 {
        while (test_and_set_bit(__E1000_RESETTING, &adapter->flags))
                msleep(1);
-       rtnl_lock();
+       mutex_lock(&adapter->mutex);
        e1000_down(adapter);
        e1000_up(adapter);
-       rtnl_unlock();
+       mutex_unlock(&adapter->mutex);
        clear_bit(__E1000_RESETTING, &adapter->flags);
 }
 
@@ -731,10 +737,8 @@ static void e1000_dump_eeprom(struct e1000_adapter *adapter)
        eeprom.offset = 0;
 
        data = kmalloc(eeprom.len, GFP_KERNEL);
-       if (!data) {
-               pr_err("Unable to allocate memory to dump EEPROM data\n");
+       if (!data)
                return;
-       }
 
        ops->get_eeprom(netdev, &eeprom, data);
 
@@ -803,7 +807,8 @@ static int e1000_is_need_ioport(struct pci_dev *pdev)
        }
 }
 
-static u32 e1000_fix_features(struct net_device *netdev, u32 features)
+static netdev_features_t e1000_fix_features(struct net_device *netdev,
+       netdev_features_t features)
 {
        /*
         * Since there is no support for separate rx/tx vlan accel
@@ -817,10 +822,11 @@ static u32 e1000_fix_features(struct net_device *netdev, u32 features)
        return features;
 }
 
-static int e1000_set_features(struct net_device *netdev, u32 features)
+static int e1000_set_features(struct net_device *netdev,
+       netdev_features_t features)
 {
        struct e1000_adapter *adapter = netdev_priv(netdev);
-       u32 changed = features ^ netdev->features;
+       netdev_features_t changed = features ^ netdev->features;
 
        if (changed & NETIF_F_HW_VLAN_RX)
                e1000_vlan_mode(netdev, features);
@@ -980,7 +986,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
        adapter = netdev_priv(netdev);
        adapter->netdev = netdev;
        adapter->pdev = pdev;
-       adapter->msg_enable = (1 << debug) - 1;
+       adapter->msg_enable = netif_msg_init(debug, DEFAULT_MSG_ENABLE);
        adapter->bars = bars;
        adapter->need_ioport = need_ioport;
 
@@ -1048,11 +1054,11 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
 
        err = -EIO;
        if (hw->mac_type == e1000_ce4100) {
-               ce4100_gbe_mdio_base_phy = pci_resource_start(pdev, BAR_1);
-               ce4100_gbe_mdio_base_virt = ioremap(ce4100_gbe_mdio_base_phy,
+               hw->ce4100_gbe_mdio_base_virt =
+                                       ioremap(pci_resource_start(pdev, BAR_1),
                                                pci_resource_len(pdev, BAR_1));
 
-               if (!ce4100_gbe_mdio_base_virt)
+               if (!hw->ce4100_gbe_mdio_base_virt)
                        goto err_mdio_ioremap;
        }
 
@@ -1068,8 +1074,11 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
           (hw->mac_type != e1000_82547))
                netdev->hw_features |= NETIF_F_TSO;
 
+       netdev->priv_flags |= IFF_SUPP_NOFCS;
+
        netdev->features |= netdev->hw_features;
        netdev->hw_features |= NETIF_F_RXCSUM;
+       netdev->hw_features |= NETIF_F_RXFCS;
 
        if (pci_using_dac) {
                netdev->features |= NETIF_F_HIGHDMA;
@@ -1120,21 +1129,12 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
        if (!is_valid_ether_addr(netdev->perm_addr))
                e_err(probe, "Invalid MAC Address\n");
 
-       init_timer(&adapter->tx_fifo_stall_timer);
-       adapter->tx_fifo_stall_timer.function = e1000_82547_tx_fifo_stall;
-       adapter->tx_fifo_stall_timer.data = (unsigned long)adapter;
-
-       init_timer(&adapter->watchdog_timer);
-       adapter->watchdog_timer.function = e1000_watchdog;
-       adapter->watchdog_timer.data = (unsigned long) adapter;
 
-       init_timer(&adapter->phy_info_timer);
-       adapter->phy_info_timer.function = e1000_update_phy_info;
-       adapter->phy_info_timer.data = (unsigned long)adapter;
-
-       INIT_WORK(&adapter->fifo_stall_task, e1000_82547_tx_fifo_stall_task);
+       INIT_DELAYED_WORK(&adapter->watchdog_task, e1000_watchdog);
+       INIT_DELAYED_WORK(&adapter->fifo_stall_task,
+                         e1000_82547_tx_fifo_stall_task);
+       INIT_DELAYED_WORK(&adapter->phy_info_task, e1000_update_phy_info_task);
        INIT_WORK(&adapter->reset_task, e1000_reset_task);
-       INIT_WORK(&adapter->phy_info_task, e1000_update_phy_info_task);
 
        e1000_check_options(adapter);
 
@@ -1188,7 +1188,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
                if (global_quad_port_a != 0)
                        adapter->eeprom_wol = 0;
                else
-                       adapter->quad_port_a = 1;
+                       adapter->quad_port_a = true;
                /* Reset for multiple quad port adapters */
                if (++global_quad_port_a == 4)
                        global_quad_port_a = 0;
@@ -1221,7 +1221,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
        if (err)
                goto err_register;
 
-       e1000_vlan_mode(netdev, netdev->features);
+       e1000_vlan_filter_on_off(adapter, false);
 
        /* print bus type/speed/width info */
        e_info(probe, "(PCI%s:%dMHz:%d-bit) %pM\n",
@@ -1252,7 +1252,7 @@ err_eeprom:
 err_dma:
 err_sw_init:
 err_mdio_ioremap:
-       iounmap(ce4100_gbe_mdio_base_virt);
+       iounmap(hw->ce4100_gbe_mdio_base_virt);
        iounmap(hw->hw_addr);
 err_ioremap:
        free_netdev(netdev);
@@ -1279,13 +1279,7 @@ static void __devexit e1000_remove(struct pci_dev *pdev)
        struct e1000_adapter *adapter = netdev_priv(netdev);
        struct e1000_hw *hw = &adapter->hw;
 
-       set_bit(__E1000_DOWN, &adapter->flags);
-       del_timer_sync(&adapter->tx_fifo_stall_timer);
-       del_timer_sync(&adapter->watchdog_timer);
-       del_timer_sync(&adapter->phy_info_timer);
-
-       cancel_work_sync(&adapter->reset_task);
-
+       e1000_down_and_stop(adapter);
        e1000_release_manageability(adapter);
 
        unregister_netdev(netdev);
@@ -1295,6 +1289,8 @@ static void __devexit e1000_remove(struct pci_dev *pdev)
        kfree(adapter->tx_ring);
        kfree(adapter->rx_ring);
 
+       if (hw->mac_type == e1000_ce4100)
+               iounmap(hw->ce4100_gbe_mdio_base_virt);
        iounmap(hw->hw_addr);
        if (hw->flash_address)
                iounmap(hw->flash_address);
@@ -1329,6 +1325,7 @@ static int __devinit e1000_sw_init(struct e1000_adapter *adapter)
        e1000_irq_disable(adapter);
 
        spin_lock_init(&adapter->stats_lock);
+       mutex_init(&adapter->mutex);
 
        set_bit(__E1000_DOWN, &adapter->flags);
 
@@ -1369,7 +1366,7 @@ static int __devinit e1000_alloc_queues(struct e1000_adapter *adapter)
  * The open entry point is called when a network interface is made
  * active by the system (IFF_UP).  At this point all resources needed
  * for transmit and receive operations are allocated, the interrupt
- * handler is registered with the OS, the watchdog timer is started,
+ * handler is registered with the OS, the watchdog task is started,
  * and the stack is notified that the interface is ready.
  **/
 
@@ -1687,7 +1684,7 @@ static void e1000_configure_tx(struct e1000_adapter *adapter)
         * need this to apply a workaround later in the send path. */
        if (hw->mac_type == e1000_82544 &&
            hw->bus_type == e1000_bus_type_pcix)
-               adapter->pcix_82544 = 1;
+               adapter->pcix_82544 = true;
 
        ew32(TCTL, tctl);
 
@@ -2010,7 +2007,7 @@ static void e1000_clean_tx_ring(struct e1000_adapter *adapter,
 
        tx_ring->next_to_use = 0;
        tx_ring->next_to_clean = 0;
-       tx_ring->last_tx_tso = 0;
+       tx_ring->last_tx_tso = false;
 
        writel(0, hw->hw_addr + tx_ring->tdh);
        writel(0, hw->hw_addr + tx_ring->tdt);
@@ -2331,35 +2328,23 @@ static void e1000_set_rx_mode(struct net_device *netdev)
        kfree(mcarray);
 }
 
-/* Need to wait a few seconds after link up to get diagnostic information from
- * the phy */
-
-static void e1000_update_phy_info(unsigned long data)
-{
-       struct e1000_adapter *adapter = (struct e1000_adapter *)data;
-       schedule_work(&adapter->phy_info_task);
-}
-
+/**
+ * e1000_update_phy_info_task - get phy info
+ * @work: work struct contained inside adapter struct
+ *
+ * Need to wait a few seconds after link up to get diagnostic information from
+ * the phy
+ */
 static void e1000_update_phy_info_task(struct work_struct *work)
 {
        struct e1000_adapter *adapter = container_of(work,
-                                                    struct e1000_adapter,
-                                                    phy_info_task);
-       struct e1000_hw *hw = &adapter->hw;
-
-       rtnl_lock();
-       e1000_phy_get_info(hw, &adapter->phy_info);
-       rtnl_unlock();
-}
-
-/**
- * e1000_82547_tx_fifo_stall - Timer Call-back
- * @data: pointer to adapter cast into an unsigned long
- **/
-static void e1000_82547_tx_fifo_stall(unsigned long data)
-{
-       struct e1000_adapter *adapter = (struct e1000_adapter *)data;
-       schedule_work(&adapter->fifo_stall_task);
+                                                    struct e1000_adapter,
+                                                    phy_info_task.work);
+       if (test_bit(__E1000_DOWN, &adapter->flags))
+               return;
+       mutex_lock(&adapter->mutex);
+       e1000_phy_get_info(&adapter->hw, &adapter->phy_info);
+       mutex_unlock(&adapter->mutex);
 }
 
 /**
@@ -2369,13 +2354,15 @@ static void e1000_82547_tx_fifo_stall(unsigned long data)
 static void e1000_82547_tx_fifo_stall_task(struct work_struct *work)
 {
        struct e1000_adapter *adapter = container_of(work,
-                                                    struct e1000_adapter,
-                                                    fifo_stall_task);
+                                                    struct e1000_adapter,
+                                                    fifo_stall_task.work);
        struct e1000_hw *hw = &adapter->hw;
        struct net_device *netdev = adapter->netdev;
        u32 tctl;
 
-       rtnl_lock();
+       if (test_bit(__E1000_DOWN, &adapter->flags))
+               return;
+       mutex_lock(&adapter->mutex);
        if (atomic_read(&adapter->tx_fifo_stall)) {
                if ((er32(TDT) == er32(TDH)) &&
                   (er32(TDFT) == er32(TDFH)) &&
@@ -2393,10 +2380,10 @@ static void e1000_82547_tx_fifo_stall_task(struct work_struct *work)
                        atomic_set(&adapter->tx_fifo_stall, 0);
                        netif_wake_queue(netdev);
                } else if (!test_bit(__E1000_DOWN, &adapter->flags)) {
-                       mod_timer(&adapter->tx_fifo_stall_timer, jiffies + 1);
+                       schedule_delayed_work(&adapter->fifo_stall_task, 1);
                }
        }
-       rtnl_unlock();
+       mutex_unlock(&adapter->mutex);
 }
 
 bool e1000_has_link(struct e1000_adapter *adapter)
@@ -2437,17 +2424,23 @@ bool e1000_has_link(struct e1000_adapter *adapter)
 }
 
 /**
- * e1000_watchdog - Timer Call-back
- * @data: pointer to adapter cast into an unsigned long
+ * e1000_watchdog - work function
+ * @work: work struct contained inside adapter struct
  **/
-static void e1000_watchdog(unsigned long data)
+static void e1000_watchdog(struct work_struct *work)
 {
-       struct e1000_adapter *adapter = (struct e1000_adapter *)data;
+       struct e1000_adapter *adapter = container_of(work,
+                                                    struct e1000_adapter,
+                                                    watchdog_task.work);
        struct e1000_hw *hw = &adapter->hw;
        struct net_device *netdev = adapter->netdev;
        struct e1000_tx_ring *txdr = adapter->tx_ring;
        u32 link, tctl;
 
+       if (test_bit(__E1000_DOWN, &adapter->flags))
+               return;
+
+       mutex_lock(&adapter->mutex);
        link = e1000_has_link(adapter);
        if ((netif_carrier_ok(netdev)) && link)
                goto link_up;
@@ -2493,8 +2486,8 @@ static void e1000_watchdog(unsigned long data)
 
                        netif_carrier_on(netdev);
                        if (!test_bit(__E1000_DOWN, &adapter->flags))
-                               mod_timer(&adapter->phy_info_timer,
-                                         round_jiffies(jiffies + 2 * HZ));
+                               schedule_delayed_work(&adapter->phy_info_task,
+                                                     2 * HZ);
                        adapter->smartspeed = 0;
                }
        } else {
@@ -2506,8 +2499,8 @@ static void e1000_watchdog(unsigned long data)
                        netif_carrier_off(netdev);
 
                        if (!test_bit(__E1000_DOWN, &adapter->flags))
-                               mod_timer(&adapter->phy_info_timer,
-                                         round_jiffies(jiffies + 2 * HZ));
+                               schedule_delayed_work(&adapter->phy_info_task,
+                                                     2 * HZ);
                }
 
                e1000_smartspeed(adapter);
@@ -2536,8 +2529,8 @@ link_up:
                         * (Do the reset outside of interrupt context). */
                        adapter->tx_timeout_count++;
                        schedule_work(&adapter->reset_task);
-                       /* return immediately since reset is imminent */
-                       return;
+                       /* exit immediately since reset is imminent */
+                       goto unlock;
                }
        }
 
@@ -2563,10 +2556,12 @@ link_up:
        /* Force detection of hung controller every watchdog period */
        adapter->detect_tx_hung = true;
 
-       /* Reset the timer */
+       /* Reschedule the task */
        if (!test_bit(__E1000_DOWN, &adapter->flags))
-               mod_timer(&adapter->watchdog_timer,
-                         round_jiffies(jiffies + 2 * HZ));
+               schedule_delayed_work(&adapter->watchdog_task, 2 * HZ);
+
+unlock:
+       mutex_unlock(&adapter->mutex);
 }
 
 enum latency_range {
@@ -2707,6 +2702,7 @@ set_itr_now:
 #define E1000_TX_FLAGS_VLAN            0x00000002
 #define E1000_TX_FLAGS_TSO             0x00000004
 #define E1000_TX_FLAGS_IPV4            0x00000008
+#define E1000_TX_FLAGS_NO_FCS          0x00000010
 #define E1000_TX_FLAGS_VLAN_MASK       0xffff0000
 #define E1000_TX_FLAGS_VLAN_SHIFT      16
 
@@ -2861,7 +2857,7 @@ static int e1000_tx_map(struct e1000_adapter *adapter,
                 * DMA'd to the controller */
                if (!skb->data_len && tx_ring->last_tx_tso &&
                    !skb_is_gso(skb)) {
-                       tx_ring->last_tx_tso = 0;
+                       tx_ring->last_tx_tso = false;
                        size -= 4;
                }
 
@@ -2907,10 +2903,10 @@ static int e1000_tx_map(struct e1000_adapter *adapter,
        }
 
        for (f = 0; f < nr_frags; f++) {
-               struct skb_frag_struct *frag;
+               const struct skb_frag_struct *frag;
 
                frag = &skb_shinfo(skb)->frags[f];
-               len = frag->size;
+               len = skb_frag_size(frag);
                offset = 0;
 
                while (len) {
@@ -3008,6 +3004,9 @@ static void e1000_tx_queue(struct e1000_adapter *adapter,
                txd_upper |= (tx_flags & E1000_TX_FLAGS_VLAN_MASK);
        }
 
+       if (unlikely(tx_flags & E1000_TX_FLAGS_NO_FCS))
+               txd_lower &= ~(E1000_TXD_CMD_IFCS);
+
        i = tx_ring->next_to_use;
 
        while (count--) {
@@ -3022,6 +3021,10 @@ static void e1000_tx_queue(struct e1000_adapter *adapter,
 
        tx_desc->lower.data |= cpu_to_le32(adapter->txd_cmd);
 
+       /* txd_cmd re-enables FCS, so we'll re-disable it here as desired. */
+       if (unlikely(tx_flags & E1000_TX_FLAGS_NO_FCS))
+               tx_desc->lower.data &= ~(cpu_to_le32(E1000_TXD_CMD_IFCS));
+
        /* Force memory writes to complete before letting h/w
         * know there are new descriptors to fetch.  (Only
         * applicable for weak-ordered memory model archs,
@@ -3196,7 +3199,7 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb,
 
        nr_frags = skb_shinfo(skb)->nr_frags;
        for (f = 0; f < nr_frags; f++)
-               count += TXD_USE_COUNT(skb_shinfo(skb)->frags[f].size,
+               count += TXD_USE_COUNT(skb_frag_size(&skb_shinfo(skb)->frags[f]),
                                       max_txd_pwr);
        if (adapter->pcix_82544)
                count += nr_frags;
@@ -3206,14 +3209,12 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb,
        if (unlikely(e1000_maybe_stop_tx(netdev, tx_ring, count + 2)))
                return NETDEV_TX_BUSY;
 
-       if (unlikely(hw->mac_type == e1000_82547)) {
-               if (unlikely(e1000_82547_fifo_workaround(adapter, skb))) {
-                       netif_stop_queue(netdev);
-                       if (!test_bit(__E1000_DOWN, &adapter->flags))
-                               mod_timer(&adapter->tx_fifo_stall_timer,
-                                         jiffies + 1);
-                       return NETDEV_TX_BUSY;
-               }
+       if (unlikely((hw->mac_type == e1000_82547) &&
+                    (e1000_82547_fifo_workaround(adapter, skb)))) {
+               netif_stop_queue(netdev);
+               if (!test_bit(__E1000_DOWN, &adapter->flags))
+                       schedule_delayed_work(&adapter->fifo_stall_task, 1);
+               return NETDEV_TX_BUSY;
        }
 
        if (vlan_tx_tag_present(skb)) {
@@ -3231,7 +3232,7 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb,
 
        if (likely(tso)) {
                if (likely(hw->mac_type != e1000_82544))
-                       tx_ring->last_tx_tso = 1;
+                       tx_ring->last_tx_tso = true;
                tx_flags |= E1000_TX_FLAGS_TSO;
        } else if (likely(e1000_tx_csum(adapter, tx_ring, skb)))
                tx_flags |= E1000_TX_FLAGS_CSUM;
@@ -3239,6 +3240,9 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb,
        if (likely(skb->protocol == htons(ETH_P_IP)))
                tx_flags |= E1000_TX_FLAGS_IPV4;
 
+       if (unlikely(skb->no_fcs))
+               tx_flags |= E1000_TX_FLAGS_NO_FCS;
+
        count = e1000_tx_map(adapter, tx_ring, skb, first, max_per_txd,
                             nr_frags, mss);
 
@@ -3256,6 +3260,215 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb,
        return NETDEV_TX_OK;
 }
 
+#define NUM_REGS 38 /* 1 based count */
+static void e1000_regdump(struct e1000_adapter *adapter)
+{
+       struct e1000_hw *hw = &adapter->hw;
+       u32 regs[NUM_REGS];
+       u32 *regs_buff = regs;
+       int i = 0;
+
+       static const char * const reg_name[] = {
+               "CTRL",  "STATUS",
+               "RCTL", "RDLEN", "RDH", "RDT", "RDTR",
+               "TCTL", "TDBAL", "TDBAH", "TDLEN", "TDH", "TDT",
+               "TIDV", "TXDCTL", "TADV", "TARC0",
+               "TDBAL1", "TDBAH1", "TDLEN1", "TDH1", "TDT1",
+               "TXDCTL1", "TARC1",
+               "CTRL_EXT", "ERT", "RDBAL", "RDBAH",
+               "TDFH", "TDFT", "TDFHS", "TDFTS", "TDFPC",
+               "RDFH", "RDFT", "RDFHS", "RDFTS", "RDFPC"
+       };
+
+       regs_buff[0]  = er32(CTRL);
+       regs_buff[1]  = er32(STATUS);
+
+       regs_buff[2]  = er32(RCTL);
+       regs_buff[3]  = er32(RDLEN);
+       regs_buff[4]  = er32(RDH);
+       regs_buff[5]  = er32(RDT);
+       regs_buff[6]  = er32(RDTR);
+
+       regs_buff[7]  = er32(TCTL);
+       regs_buff[8]  = er32(TDBAL);
+       regs_buff[9]  = er32(TDBAH);
+       regs_buff[10] = er32(TDLEN);
+       regs_buff[11] = er32(TDH);
+       regs_buff[12] = er32(TDT);
+       regs_buff[13] = er32(TIDV);
+       regs_buff[14] = er32(TXDCTL);
+       regs_buff[15] = er32(TADV);
+       regs_buff[16] = er32(TARC0);
+
+       regs_buff[17] = er32(TDBAL1);
+       regs_buff[18] = er32(TDBAH1);
+       regs_buff[19] = er32(TDLEN1);
+       regs_buff[20] = er32(TDH1);
+       regs_buff[21] = er32(TDT1);
+       regs_buff[22] = er32(TXDCTL1);
+       regs_buff[23] = er32(TARC1);
+       regs_buff[24] = er32(CTRL_EXT);
+       regs_buff[25] = er32(ERT);
+       regs_buff[26] = er32(RDBAL0);
+       regs_buff[27] = er32(RDBAH0);
+       regs_buff[28] = er32(TDFH);
+       regs_buff[29] = er32(TDFT);
+       regs_buff[30] = er32(TDFHS);
+       regs_buff[31] = er32(TDFTS);
+       regs_buff[32] = er32(TDFPC);
+       regs_buff[33] = er32(RDFH);
+       regs_buff[34] = er32(RDFT);
+       regs_buff[35] = er32(RDFHS);
+       regs_buff[36] = er32(RDFTS);
+       regs_buff[37] = er32(RDFPC);
+
+       pr_info("Register dump\n");
+       for (i = 0; i < NUM_REGS; i++)
+               pr_info("%-15s  %08x\n", reg_name[i], regs_buff[i]);
+}
+
+/*
+ * e1000_dump: Print registers, tx ring and rx ring
+ */
+static void e1000_dump(struct e1000_adapter *adapter)
+{
+       /* this code doesn't handle multiple rings */
+       struct e1000_tx_ring *tx_ring = adapter->tx_ring;
+       struct e1000_rx_ring *rx_ring = adapter->rx_ring;
+       int i;
+
+       if (!netif_msg_hw(adapter))
+               return;
+
+       /* Print Registers */
+       e1000_regdump(adapter);
+
+       /*
+        * transmit dump
+        */
+       pr_info("TX Desc ring0 dump\n");
+
+       /* Transmit Descriptor Formats - DEXT[29] is 0 (Legacy) or 1 (Extended)
+        *
+        * Legacy Transmit Descriptor
+        *   +--------------------------------------------------------------+
+        * 0 |         Buffer Address [63:0] (Reserved on Write Back)       |
+        *   +--------------------------------------------------------------+
+        * 8 | Special  |    CSS     | Status |  CMD    |  CSO   |  Length  |
+        *   +--------------------------------------------------------------+
+        *   63       48 47        36 35    32 31     24 23    16 15        0
+        *
+        * Extended Context Descriptor (DTYP=0x0) for TSO or checksum offload
+        *   63      48 47    40 39       32 31             16 15    8 7      0
+        *   +----------------------------------------------------------------+
+        * 0 |  TUCSE  | TUCS0  |   TUCSS   |     IPCSE       | IPCS0 | IPCSS |
+        *   +----------------------------------------------------------------+
+        * 8 |   MSS   | HDRLEN | RSV | STA | TUCMD | DTYP |      PAYLEN      |
+        *   +----------------------------------------------------------------+
+        *   63      48 47    40 39 36 35 32 31   24 23  20 19                0
+        *
+        * Extended Data Descriptor (DTYP=0x1)
+        *   +----------------------------------------------------------------+
+        * 0 |                     Buffer Address [63:0]                      |
+        *   +----------------------------------------------------------------+
+        * 8 | VLAN tag |  POPTS  | Rsvd | Status | Command | DTYP |  DTALEN  |
+        *   +----------------------------------------------------------------+
+        *   63       48 47     40 39  36 35    32 31     24 23  20 19        0
+        */
+       pr_info("Tc[desc]     [Ce CoCsIpceCoS] [MssHlRSCm0Plen] [bi->dma       ] leng  ntw timestmp         bi->skb\n");
+       pr_info("Td[desc]     [address 63:0  ] [VlaPoRSCm1Dlen] [bi->dma       ] leng  ntw timestmp         bi->skb\n");
+
+       if (!netif_msg_tx_done(adapter))
+               goto rx_ring_summary;
+
+       for (i = 0; tx_ring->desc && (i < tx_ring->count); i++) {
+               struct e1000_tx_desc *tx_desc = E1000_TX_DESC(*tx_ring, i);
+               struct e1000_buffer *buffer_info = &tx_ring->buffer_info[i];
+               struct my_u { __le64 a; __le64 b; };
+               struct my_u *u = (struct my_u *)tx_desc;
+               const char *type;
+
+               if (i == tx_ring->next_to_use && i == tx_ring->next_to_clean)
+                       type = "NTC/U";
+               else if (i == tx_ring->next_to_use)
+                       type = "NTU";
+               else if (i == tx_ring->next_to_clean)
+                       type = "NTC";
+               else
+                       type = "";
+
+               pr_info("T%c[0x%03X]    %016llX %016llX %016llX %04X  %3X %016llX %p %s\n",
+                       ((le64_to_cpu(u->b) & (1<<20)) ? 'd' : 'c'), i,
+                       le64_to_cpu(u->a), le64_to_cpu(u->b),
+                       (u64)buffer_info->dma, buffer_info->length,
+                       buffer_info->next_to_watch,
+                       (u64)buffer_info->time_stamp, buffer_info->skb, type);
+       }
+
+rx_ring_summary:
+       /*
+        * receive dump
+        */
+       pr_info("\nRX Desc ring dump\n");
+
+       /* Legacy Receive Descriptor Format
+        *
+        * +-----------------------------------------------------+
+        * |                Buffer Address [63:0]                |
+        * +-----------------------------------------------------+
+        * | VLAN Tag | Errors | Status 0 | Packet csum | Length |
+        * +-----------------------------------------------------+
+        * 63       48 47    40 39      32 31         16 15      0
+        */
+       pr_info("R[desc]      [address 63:0  ] [vl er S cks ln] [bi->dma       ] [bi->skb]\n");
+
+       if (!netif_msg_rx_status(adapter))
+               goto exit;
+
+       for (i = 0; rx_ring->desc && (i < rx_ring->count); i++) {
+               struct e1000_rx_desc *rx_desc = E1000_RX_DESC(*rx_ring, i);
+               struct e1000_buffer *buffer_info = &rx_ring->buffer_info[i];
+               struct my_u { __le64 a; __le64 b; };
+               struct my_u *u = (struct my_u *)rx_desc;
+               const char *type;
+
+               if (i == rx_ring->next_to_use)
+                       type = "NTU";
+               else if (i == rx_ring->next_to_clean)
+                       type = "NTC";
+               else
+                       type = "";
+
+               pr_info("R[0x%03X]     %016llX %016llX %016llX %p %s\n",
+                       i, le64_to_cpu(u->a), le64_to_cpu(u->b),
+                       (u64)buffer_info->dma, buffer_info->skb, type);
+       } /* for */
+
+       /* dump the descriptor caches */
+       /* rx */
+       pr_info("Rx descriptor cache in 64bit format\n");
+       for (i = 0x6000; i <= 0x63FF ; i += 0x10) {
+               pr_info("R%04X: %08X|%08X %08X|%08X\n",
+                       i,
+                       readl(adapter->hw.hw_addr + i+4),
+                       readl(adapter->hw.hw_addr + i),
+                       readl(adapter->hw.hw_addr + i+12),
+                       readl(adapter->hw.hw_addr + i+8));
+       }
+       /* tx */
+       pr_info("Tx descriptor cache in 64bit format\n");
+       for (i = 0x7000; i <= 0x73FF ; i += 0x10) {
+               pr_info("T%04X: %08X|%08X %08X|%08X\n",
+                       i,
+                       readl(adapter->hw.hw_addr + i+4),
+                       readl(adapter->hw.hw_addr + i),
+                       readl(adapter->hw.hw_addr + i+12),
+                       readl(adapter->hw.hw_addr + i+8));
+       }
+exit:
+       return;
+}
+
 /**
  * e1000_tx_timeout - Respond to a Tx Hang
  * @netdev: network interface device structure
@@ -3275,6 +3488,9 @@ static void e1000_reset_task(struct work_struct *work)
        struct e1000_adapter *adapter =
                container_of(work, struct e1000_adapter, reset_task);
 
+       if (test_bit(__E1000_DOWN, &adapter->flags))
+               return;
+       e_err(drv, "Reset adapter\n");
        e1000_reinit_safe(adapter);
 }
 
@@ -3283,7 +3499,7 @@ static void e1000_reset_task(struct work_struct *work)
  * @netdev: network interface device structure
  *
  * Returns the address of the device statistics structure.
- * The statistics are actually updated from the timer callback.
+ * The statistics are actually updated from the watchdog.
  **/
 
 static struct net_device_stats *e1000_get_stats(struct net_device *netdev)
@@ -3551,7 +3767,7 @@ static irqreturn_t e1000_intr(int irq, void *data)
                hw->get_link_status = 1;
                /* guard against interrupt when we're going down */
                if (!test_bit(__E1000_DOWN, &adapter->flags))
-                       mod_timer(&adapter->watchdog_timer, jiffies + 1);
+                       schedule_delayed_work(&adapter->watchdog_task, 1);
        }
 
        /* disable interrupts, without the synchronize_irq bit */
@@ -3692,6 +3908,7 @@ static bool e1000_clean_tx_irq(struct e1000_adapter *adapter,
                                eop,
                                jiffies,
                                eop_desc->upper.fields.status);
+                       e1000_dump(adapter);
                        netif_stop_queue(netdev);
                }
        }
@@ -3750,7 +3967,7 @@ static void e1000_consume_page(struct e1000_buffer *bi, struct sk_buff *skb,
        bi->page = NULL;
        skb->len += length;
        skb->data_len += length;
-       skb->truesize += length;
+       skb->truesize += PAGE_SIZE;
 }
 
 /**
@@ -3891,11 +4108,9 @@ static bool e1000_clean_jumbo_rx_irq(struct e1000_adapter *adapter,
                                if (length <= copybreak &&
                                    skb_tailroom(skb) >= length) {
                                        u8 *vaddr;
-                                       vaddr = kmap_atomic(buffer_info->page,
-                                                           KM_SKB_DATA_SOFTIRQ);
+                                       vaddr = kmap_atomic(buffer_info->page);
                                        memcpy(skb_tail_pointer(skb), vaddr, length);
-                                       kunmap_atomic(vaddr,
-                                                     KM_SKB_DATA_SOFTIRQ);
+                                       kunmap_atomic(vaddr);
                                        /* re-use the page, so don't erase
                                         * buffer_info->page */
                                        skb_put(skb, length);
@@ -3915,10 +4130,9 @@ static bool e1000_clean_jumbo_rx_irq(struct e1000_adapter *adapter,
                                  ((u32)(rx_desc->errors) << 24),
                                  le16_to_cpu(rx_desc->csum), skb);
 
-               pskb_trim(skb, skb->len - 4);
-
-               /* probably a little skewed due to removing CRC */
-               total_rx_bytes += skb->len;
+               total_rx_bytes += (skb->len - 4); /* don't count FCS */
+               if (likely(!(netdev->features & NETIF_F_RXFCS)))
+                       pskb_trim(skb, skb->len - 4);
                total_rx_packets++;
 
                /* eth type trans needs skb->data to point to something */
@@ -4072,14 +4286,15 @@ static bool e1000_clean_rx_irq(struct e1000_adapter *adapter,
                        }
                }
 
-               /* adjust length to remove Ethernet CRC, this must be
-                * done after the TBI_ACCEPT workaround above */
-               length -= 4;
-
-               /* probably a little skewed due to removing CRC */
-               total_rx_bytes += length;
+               total_rx_bytes += (length - 4); /* don't count FCS */
                total_rx_packets++;
 
+               if (likely(!(netdev->features & NETIF_F_RXFCS)))
+                       /* adjust length to remove Ethernet CRC, this must be
+                        * done after the TBI_ACCEPT workaround above
+                        */
+                       length -= 4;
+
                e1000_check_copybreak(netdev, buffer_info, length, &skb);
 
                skb_put(skb, length);
@@ -4562,6 +4777,22 @@ static bool e1000_vlan_used(struct e1000_adapter *adapter)
        return false;
 }
 
+static void __e1000_vlan_mode(struct e1000_adapter *adapter,
+                             netdev_features_t features)
+{
+       struct e1000_hw *hw = &adapter->hw;
+       u32 ctrl;
+
+       ctrl = er32(CTRL);
+       if (features & NETIF_F_HW_VLAN_RX) {
+               /* enable VLAN tag insert/strip */
+               ctrl |= E1000_CTRL_VME;
+       } else {
+               /* disable VLAN tag insert/strip */
+               ctrl &= ~E1000_CTRL_VME;
+       }
+       ew32(CTRL, ctrl);
+}
 static void e1000_vlan_filter_on_off(struct e1000_adapter *adapter,
                                     bool filter_on)
 {
@@ -4571,6 +4802,7 @@ static void e1000_vlan_filter_on_off(struct e1000_adapter *adapter,
        if (!test_bit(__E1000_DOWN, &adapter->flags))
                e1000_irq_disable(adapter);
 
+       __e1000_vlan_mode(adapter, adapter->netdev->features);
        if (filter_on) {
                /* enable VLAN receive filtering */
                rctl = er32(RCTL);
@@ -4590,30 +4822,21 @@ static void e1000_vlan_filter_on_off(struct e1000_adapter *adapter,
                e1000_irq_enable(adapter);
 }
 
-static void e1000_vlan_mode(struct net_device *netdev, u32 features)
+static void e1000_vlan_mode(struct net_device *netdev,
+                           netdev_features_t features)
 {
        struct e1000_adapter *adapter = netdev_priv(netdev);
-       struct e1000_hw *hw = &adapter->hw;
-       u32 ctrl;
 
        if (!test_bit(__E1000_DOWN, &adapter->flags))
                e1000_irq_disable(adapter);
 
-       ctrl = er32(CTRL);
-       if (features & NETIF_F_HW_VLAN_RX) {
-               /* enable VLAN tag insert/strip */
-               ctrl |= E1000_CTRL_VME;
-       } else {
-               /* disable VLAN tag insert/strip */
-               ctrl &= ~E1000_CTRL_VME;
-       }
-       ew32(CTRL, ctrl);
+       __e1000_vlan_mode(adapter, features);
 
        if (!test_bit(__E1000_DOWN, &adapter->flags))
                e1000_irq_enable(adapter);
 }
 
-static void e1000_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
+static int e1000_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
 {
        struct e1000_adapter *adapter = netdev_priv(netdev);
        struct e1000_hw *hw = &adapter->hw;
@@ -4622,7 +4845,7 @@ static void e1000_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
        if ((hw->mng_cookie.status &
             E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) &&
            (vid == adapter->mng_vlan_id))
-               return;
+               return 0;
 
        if (!e1000_vlan_used(adapter))
                e1000_vlan_filter_on_off(adapter, true);
@@ -4634,9 +4857,11 @@ static void e1000_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
        e1000_write_vfta(hw, index, vfta);
 
        set_bit(vid, adapter->active_vlans);
+
+       return 0;
 }
 
-static void e1000_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
+static int e1000_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
 {
        struct e1000_adapter *adapter = netdev_priv(netdev);
        struct e1000_hw *hw = &adapter->hw;
@@ -4657,6 +4882,8 @@ static void e1000_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
 
        if (!e1000_vlan_used(adapter))
                e1000_vlan_filter_on_off(adapter, false);
+
+       return 0;
 }
 
 static void e1000_restore_vlan(struct e1000_adapter *adapter)
@@ -4748,12 +4975,14 @@ static int __e1000_shutdown(struct pci_dev *pdev, bool *enable_wake)
                e1000_setup_rctl(adapter);
                e1000_set_rx_mode(netdev);
 
+               rctl = er32(RCTL);
+
                /* turn on all-multi mode if wake on multicast is enabled */
-               if (wufc & E1000_WUFC_MC) {
-                       rctl = er32(RCTL);
+               if (wufc & E1000_WUFC_MC)
                        rctl |= E1000_RCTL_MPE;
-                       ew32(RCTL, rctl);
-               }
+
+               /* enable receives in the hardware */
+               ew32(RCTL, rctl | E1000_RCTL_EN);
 
                if (hw->mac_type >= e1000_82540) {
                        ctrl = er32(CTRL);