]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - drivers/net/ixgbe/ixgbe_main.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6
[karo-tx-linux.git] / drivers / net / ixgbe / ixgbe_main.c
index e145f2c455cb4733976e6c2b83456dbfdde2c5a3..fa01b0b03b7740a8e746332eeb64f998444b7c5e 100644 (file)
 char ixgbe_driver_name[] = "ixgbe";
 static const char ixgbe_driver_string[] =
                              "Intel(R) 10 Gigabit PCI Express Network Driver";
-
-#define DRV_VERSION "3.2.9-k2"
+#define MAJ 3
+#define MIN 3
+#define BUILD 8
+#define KFIX 2
+#define DRV_VERSION __stringify(MAJ) "." __stringify(MIN) "." \
+       __stringify(BUILD) "-k" __stringify(KFIX)
 const char ixgbe_driver_version[] = DRV_VERSION;
 static const char ixgbe_copyright[] =
                                "Copyright (c) 1999-2011 Intel Corporation.";
@@ -120,6 +124,10 @@ static DEFINE_PCI_DEVICE_TABLE(ixgbe_pci_tbl) = {
         board_82599 },
        {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_X540T),
         board_X540 },
+       {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82599_SFP_SF2),
+        board_82599 },
+       {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82599_LS),
+        board_82599 },
 
        /* required last entry */
        {0, }
@@ -185,6 +193,22 @@ static inline void ixgbe_disable_sriov(struct ixgbe_adapter *adapter)
        adapter->flags &= ~IXGBE_FLAG_SRIOV_ENABLED;
 }
 
+static void ixgbe_service_event_schedule(struct ixgbe_adapter *adapter)
+{
+       if (!test_bit(__IXGBE_DOWN, &adapter->state) &&
+           !test_and_set_bit(__IXGBE_SERVICE_SCHED, &adapter->state))
+               schedule_work(&adapter->service_task);
+}
+
+static void ixgbe_service_event_complete(struct ixgbe_adapter *adapter)
+{
+       BUG_ON(!test_bit(__IXGBE_SERVICE_SCHED, &adapter->state));
+
+       /* flush memory to make sure state is correct before next watchog */
+       smp_mb__before_clear_bit();
+       clear_bit(__IXGBE_SERVICE_SCHED, &adapter->state);
+}
+
 struct ixgbe_reg_info {
        u32 ofs;
        char *name;
@@ -811,7 +835,19 @@ static inline bool ixgbe_check_tx_hang(struct ixgbe_ring *tx_ring)
 #define DESC_NEEDED (TXD_USE_COUNT(IXGBE_MAX_DATA_PER_TXD) /* skb->data */ + \
        MAX_SKB_FRAGS * TXD_USE_COUNT(PAGE_SIZE) + 1) /* for context */
 
-static void ixgbe_tx_timeout(struct net_device *netdev);
+/**
+ * ixgbe_tx_timeout_reset - initiate reset due to Tx timeout
+ * @adapter: driver private struct
+ **/
+static void ixgbe_tx_timeout_reset(struct ixgbe_adapter *adapter)
+{
+
+       /* Do the reset outside of interrupt context */
+       if (!test_bit(__IXGBE_DOWN, &adapter->state)) {
+               adapter->flags2 |= IXGBE_FLAG2_RESET_REQUESTED;
+               ixgbe_service_event_schedule(adapter);
+       }
+}
 
 /**
  * ixgbe_clean_tx_irq - Reclaim resources after transmit completes
@@ -893,7 +929,7 @@ static bool ixgbe_clean_tx_irq(struct ixgbe_q_vector *q_vector,
                        adapter->tx_timeout_count + 1, tx_ring->queue_index);
 
                /* schedule immediate reset if we believe we hung */
-               ixgbe_tx_timeout(adapter->netdev);
+               ixgbe_tx_timeout_reset(adapter);
 
                /* the adapter is about to reset, no point in enabling stuff */
                return true;
@@ -943,8 +979,6 @@ static void ixgbe_update_rx_dca(struct ixgbe_adapter *adapter,
        rxctrl |= IXGBE_DCA_RXCTRL_DESC_DCA_EN;
        rxctrl |= IXGBE_DCA_RXCTRL_HEAD_DCA_EN;
        rxctrl &= ~(IXGBE_DCA_RXCTRL_DESC_RRO_EN);
-       rxctrl &= ~(IXGBE_DCA_RXCTRL_DESC_WRO_EN |
-                   IXGBE_DCA_RXCTRL_DESC_HSRO_EN);
        IXGBE_WRITE_REG(hw, IXGBE_DCA_RXCTRL(reg_idx), rxctrl);
 }
 
@@ -962,7 +996,6 @@ static void ixgbe_update_tx_dca(struct ixgbe_adapter *adapter,
                txctrl &= ~IXGBE_DCA_TXCTRL_CPUID_MASK;
                txctrl |= dca3_get_tag(&adapter->pdev->dev, cpu);
                txctrl |= IXGBE_DCA_TXCTRL_DESC_DCA_EN;
-               txctrl &= ~IXGBE_DCA_TXCTRL_TX_WB_RO_EN;
                IXGBE_WRITE_REG(hw, IXGBE_DCA_TXCTRL(reg_idx), txctrl);
                break;
        case ixgbe_mac_82599EB:
@@ -972,7 +1005,6 @@ static void ixgbe_update_tx_dca(struct ixgbe_adapter *adapter,
                txctrl |= (dca3_get_tag(&adapter->pdev->dev, cpu) <<
                           IXGBE_DCA_TXCTRL_CPUID_SHIFT_82599);
                txctrl |= IXGBE_DCA_TXCTRL_DESC_DCA_EN;
-               txctrl &= ~IXGBE_DCA_TXCTRL_TX_WB_RO_EN;
                IXGBE_WRITE_REG(hw, IXGBE_DCA_TXCTRL_82599(reg_idx), txctrl);
                break;
        default:
@@ -1061,8 +1093,14 @@ static int __ixgbe_notify_dca(struct device *dev, void *data)
 
        return 0;
 }
-
 #endif /* CONFIG_IXGBE_DCA */
+
+static inline void ixgbe_rx_hash(union ixgbe_adv_rx_desc *rx_desc,
+                                struct sk_buff *skb)
+{
+       skb->rxhash = le32_to_cpu(rx_desc->wb.lower.hi_dword.rss);
+}
+
 /**
  * ixgbe_receive_skb - Send a completed packet up the stack
  * @adapter: board private structure
@@ -1454,6 +1492,8 @@ static void ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector,
                }
 
                ixgbe_rx_checksum(adapter, rx_desc, skb);
+               if (adapter->netdev->features & NETIF_F_RXHASH)
+                       ixgbe_rx_hash(rx_desc, skb);
 
                /* probably a little skewed due to removing CRC */
                total_rx_bytes += skb->len;
@@ -1787,35 +1827,51 @@ static void ixgbe_set_itr_msix(struct ixgbe_q_vector *q_vector)
 }
 
 /**
- * ixgbe_check_overtemp_task - worker thread to check over tempurature
- * @work: pointer to work_struct containing our data
+ * ixgbe_check_overtemp_subtask - check for over tempurature
+ * @adapter: pointer to adapter
  **/
-static void ixgbe_check_overtemp_task(struct work_struct *work)
+static void ixgbe_check_overtemp_subtask(struct ixgbe_adapter *adapter)
 {
-       struct ixgbe_adapter *adapter = container_of(work,
-                                                    struct ixgbe_adapter,
-                                                    check_overtemp_task);
        struct ixgbe_hw *hw = &adapter->hw;
        u32 eicr = adapter->interrupt_event;
 
-       if (!(adapter->flags2 & IXGBE_FLAG2_TEMP_SENSOR_CAPABLE))
+       if (test_bit(__IXGBE_DOWN, &adapter->state))
                return;
 
+       if (!(adapter->flags2 & IXGBE_FLAG2_TEMP_SENSOR_CAPABLE) &&
+           !(adapter->flags2 & IXGBE_FLAG2_TEMP_SENSOR_EVENT))
+               return;
+
+       adapter->flags2 &= ~IXGBE_FLAG2_TEMP_SENSOR_EVENT;
+
        switch (hw->device_id) {
-       case IXGBE_DEV_ID_82599_T3_LOM: {
-               u32 autoneg;
-               bool link_up = false;
+       case IXGBE_DEV_ID_82599_T3_LOM:
+               /*
+                * Since the warning interrupt is for both ports
+                * we don't have to check if:
+                *  - This interrupt wasn't for our port.
+                *  - We may have missed the interrupt so always have to
+                *    check if we  got a LSC
+                */
+               if (!(eicr & IXGBE_EICR_GPI_SDP0) &&
+                   !(eicr & IXGBE_EICR_LSC))
+                       return;
+
+               if (!(eicr & IXGBE_EICR_LSC) && hw->mac.ops.check_link) {
+                       u32 autoneg;
+                       bool link_up = false;
 
-               if (hw->mac.ops.check_link)
                        hw->mac.ops.check_link(hw, &autoneg, &link_up, false);
 
-               if (((eicr & IXGBE_EICR_GPI_SDP0) && (!link_up)) ||
-                   (eicr & IXGBE_EICR_LSC))
-                       /* Check if this is due to overtemp */
-                       if (hw->phy.ops.check_overtemp(hw) == IXGBE_ERR_OVERTEMP)
-                               break;
-               return;
-       }
+                       if (link_up)
+                               return;
+               }
+
+               /* Check if this is not due to overtemp */
+               if (hw->phy.ops.check_overtemp(hw) != IXGBE_ERR_OVERTEMP)
+                       return;
+
+               break;
        default:
                if (!(eicr & IXGBE_EICR_GPI_SDP0))
                        return;
@@ -1825,8 +1881,8 @@ static void ixgbe_check_overtemp_task(struct work_struct *work)
               "Network adapter has been stopped because it has over heated. "
               "Restart the computer. If the problem persists, "
               "power off the system and replace the adapter\n");
-       /* write to clear the interrupt */
-       IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_GPI_SDP0);
+
+       adapter->interrupt_event = 0;
 }
 
 static void ixgbe_check_fan_failure(struct ixgbe_adapter *adapter, u32 eicr)
@@ -1848,15 +1904,19 @@ static void ixgbe_check_sfp_event(struct ixgbe_adapter *adapter, u32 eicr)
        if (eicr & IXGBE_EICR_GPI_SDP2) {
                /* Clear the interrupt */
                IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_GPI_SDP2);
-               if (!test_bit(__IXGBE_DOWN, &adapter->state))
-                       schedule_work(&adapter->sfp_config_module_task);
+               if (!test_bit(__IXGBE_DOWN, &adapter->state)) {
+                       adapter->flags2 |= IXGBE_FLAG2_SFP_NEEDS_RESET;
+                       ixgbe_service_event_schedule(adapter);
+               }
        }
 
        if (eicr & IXGBE_EICR_GPI_SDP1) {
                /* Clear the interrupt */
                IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_GPI_SDP1);
-               if (!test_bit(__IXGBE_DOWN, &adapter->state))
-                       schedule_work(&adapter->multispeed_fiber_task);
+               if (!test_bit(__IXGBE_DOWN, &adapter->state)) {
+                       adapter->flags |= IXGBE_FLAG_NEED_LINK_CONFIG;
+                       ixgbe_service_event_schedule(adapter);
+               }
        }
 }
 
@@ -1870,7 +1930,7 @@ static void ixgbe_check_lsc(struct ixgbe_adapter *adapter)
        if (!test_bit(__IXGBE_DOWN, &adapter->state)) {
                IXGBE_WRITE_REG(hw, IXGBE_EIMC, IXGBE_EIMC_LSC);
                IXGBE_WRITE_FLUSH(hw);
-               schedule_work(&adapter->watchdog_task);
+               ixgbe_service_event_schedule(adapter);
        }
 }
 
@@ -1898,26 +1958,32 @@ static irqreturn_t ixgbe_msix_lsc(int irq, void *data)
 
        switch (hw->mac.type) {
        case ixgbe_mac_82599EB:
-               ixgbe_check_sfp_event(adapter, eicr);
-               if ((adapter->flags2 & IXGBE_FLAG2_TEMP_SENSOR_CAPABLE) &&
-                   ((eicr & IXGBE_EICR_GPI_SDP0) || (eicr & IXGBE_EICR_LSC))) {
-                       adapter->interrupt_event = eicr;
-                       schedule_work(&adapter->check_overtemp_task);
-               }
-               /* now fallthrough to handle Flow Director */
        case ixgbe_mac_X540:
                /* Handle Flow Director Full threshold interrupt */
                if (eicr & IXGBE_EICR_FLOW_DIR) {
+                       int reinit_count = 0;
                        int i;
-                       IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_FLOW_DIR);
-                       /* Disable transmits before FDIR Re-initialization */
-                       netif_tx_stop_all_queues(netdev);
                        for (i = 0; i < adapter->num_tx_queues; i++) {
-                               struct ixgbe_ring *tx_ring =
-                                                           adapter->tx_ring[i];
+                               struct ixgbe_ring *ring = adapter->tx_ring[i];
                                if (test_and_clear_bit(__IXGBE_TX_FDIR_INIT_DONE,
-                                                      &tx_ring->state))
-                                       schedule_work(&adapter->fdir_reinit_task);
+                                                      &ring->state))
+                                       reinit_count++;
+                       }
+                       if (reinit_count) {
+                               /* no more flow director interrupts until after init */
+                               IXGBE_WRITE_REG(hw, IXGBE_EIMC, IXGBE_EIMC_FLOW_DIR);
+                               eicr &= ~IXGBE_EICR_FLOW_DIR;
+                               adapter->flags2 |= IXGBE_FLAG2_FDIR_REQUIRES_REINIT;
+                               ixgbe_service_event_schedule(adapter);
+                       }
+               }
+               ixgbe_check_sfp_event(adapter, eicr);
+               if ((adapter->flags2 & IXGBE_FLAG2_TEMP_SENSOR_CAPABLE) &&
+                   ((eicr & IXGBE_EICR_GPI_SDP0) || (eicr & IXGBE_EICR_LSC))) {
+                       if (!test_bit(__IXGBE_DOWN, &adapter->state)) {
+                               adapter->interrupt_event = eicr;
+                               adapter->flags2 |= IXGBE_FLAG2_TEMP_SENSOR_EVENT;
+                               ixgbe_service_event_schedule(adapter);
                        }
                }
                break;
@@ -1927,8 +1993,10 @@ static irqreturn_t ixgbe_msix_lsc(int irq, void *data)
 
        ixgbe_check_fan_failure(adapter, eicr);
 
+       /* re-enable the original interrupt state, no lsc, no queues */
        if (!test_bit(__IXGBE_DOWN, &adapter->state))
-               IXGBE_WRITE_REG(hw, IXGBE_EIMS, IXGBE_EIMS_OTHER);
+               IXGBE_WRITE_REG(hw, IXGBE_EIMS, eicr &
+                               ~(IXGBE_EIMS_LSC | IXGBE_EIMS_RTX_QUEUE));
 
        return IRQ_HANDLED;
 }
@@ -2513,8 +2581,11 @@ static irqreturn_t ixgbe_intr(int irq, void *data)
                ixgbe_check_sfp_event(adapter, eicr);
                if ((adapter->flags2 & IXGBE_FLAG2_TEMP_SENSOR_CAPABLE) &&
                    ((eicr & IXGBE_EICR_GPI_SDP0) || (eicr & IXGBE_EICR_LSC))) {
-                       adapter->interrupt_event = eicr;
-                       schedule_work(&adapter->check_overtemp_task);
+                       if (!test_bit(__IXGBE_DOWN, &adapter->state)) {
+                               adapter->interrupt_event = eicr;
+                               adapter->flags2 |= IXGBE_FLAG2_TEMP_SENSOR_EVENT;
+                               ixgbe_service_event_schedule(adapter);
+                       }
                }
                break;
        default:
@@ -2731,7 +2802,7 @@ void ixgbe_configure_tx_ring(struct ixgbe_adapter *adapter,
 
        /* poll to verify queue is enabled */
        do {
-               msleep(1);
+               usleep_range(1000, 2000);
                txdctl = IXGBE_READ_REG(hw, IXGBE_TXDCTL(reg_idx));
        } while (--wait_loop && !(txdctl & IXGBE_TXDCTL_ENABLE));
        if (!wait_loop)
@@ -3023,7 +3094,7 @@ static void ixgbe_rx_desc_queue_enable(struct ixgbe_adapter *adapter,
                return;
 
        do {
-               msleep(1);
+               usleep_range(1000, 2000);
                rxdctl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(reg_idx));
        } while (--wait_loop && !(rxdctl & IXGBE_RXDCTL_ENABLE));
 
@@ -3178,7 +3249,9 @@ static void ixgbe_configure_virtualization(struct ixgbe_adapter *adapter)
        /* enable Tx loopback for VF/PF communication */
        IXGBE_WRITE_REG(hw, IXGBE_PFDTXGSWC, IXGBE_PFDTXGSWC_VT_LBEN);
        /* Enable MAC Anti-Spoofing */
-       hw->mac.ops.set_mac_anti_spoofing(hw, (adapter->num_vfs != 0),
+       hw->mac.ops.set_mac_anti_spoofing(hw,
+                                         (adapter->antispoofing_enabled =
+                                          (adapter->num_vfs != 0)),
                                          adapter->num_vfs);
 }
 
@@ -3487,7 +3560,7 @@ static int ixgbe_write_uc_addr_list(struct net_device *netdev)
        struct ixgbe_adapter *adapter = netdev_priv(netdev);
        struct ixgbe_hw *hw = &adapter->hw;
        unsigned int vfn = adapter->num_vfs;
-       unsigned int rar_entries = hw->mac.num_rar_entries - (vfn + 1);
+       unsigned int rar_entries = IXGBE_MAX_PF_MACVLANS;
        int count = 0;
 
        /* return ENOMEM indicating insufficient memory for addresses */
@@ -3760,31 +3833,16 @@ static inline bool ixgbe_is_sfp(struct ixgbe_hw *hw)
  **/
 static void ixgbe_sfp_link_config(struct ixgbe_adapter *adapter)
 {
-       struct ixgbe_hw *hw = &adapter->hw;
+       /*
+        * We are assuming the worst case scenerio here, and that
+        * is that an SFP was inserted/removed after the reset
+        * but before SFP detection was enabled.  As such the best
+        * solution is to just start searching as soon as we start
+        */
+       if (adapter->hw.mac.type == ixgbe_mac_82598EB)
+               adapter->flags2 |= IXGBE_FLAG2_SEARCH_FOR_SFP;
 
-               if (hw->phy.multispeed_fiber) {
-                       /*
-                        * In multispeed fiber setups, the device may not have
-                        * had a physical connection when the driver loaded.
-                        * If that's the case, the initial link configuration
-                        * couldn't get the MAC into 10G or 1G mode, so we'll
-                        * never have a link status change interrupt fire.
-                        * We need to try and force an autonegotiation
-                        * session, then bring up link.
-                        */
-                       if (hw->mac.ops.setup_sfp)
-                               hw->mac.ops.setup_sfp(hw);
-                       if (!(adapter->flags & IXGBE_FLAG_IN_SFP_LINK_TASK))
-                               schedule_work(&adapter->multispeed_fiber_task);
-               } else {
-                       /*
-                        * Direct Attach Cu and non-multispeed fiber modules
-                        * still need to be configured properly prior to
-                        * attempting link.
-                        */
-                       if (!(adapter->flags & IXGBE_FLAG_IN_SFP_MOD_TASK))
-                               schedule_work(&adapter->sfp_config_module_task);
-               }
+       adapter->flags2 |= IXGBE_FLAG2_SFP_NEEDS_RESET;
 }
 
 /**
@@ -3860,9 +3918,10 @@ static void ixgbe_setup_gpie(struct ixgbe_adapter *adapter)
        if (adapter->flags & IXGBE_FLAG_FAN_FAIL_CAPABLE)
                gpie |= IXGBE_SDP1_GPIEN;
 
-       if (hw->mac.type == ixgbe_mac_82599EB)
+       if (hw->mac.type == ixgbe_mac_82599EB) {
                gpie |= IXGBE_SDP1_GPIEN;
                gpie |= IXGBE_SDP2_GPIEN;
+       }
 
        IXGBE_WRITE_REG(hw, IXGBE_GPIE, gpie);
 }
@@ -3913,17 +3972,6 @@ static int ixgbe_up_complete(struct ixgbe_adapter *adapter)
                        e_crit(drv, "Fan has stopped, replace the adapter\n");
        }
 
-       /*
-        * For hot-pluggable SFP+ devices, a new SFP+ module may have
-        * arrived before interrupts were enabled but after probe.  Such
-        * devices wouldn't have their type identified yet. We need to
-        * kick off the SFP+ module setup first, then try to bring up link.
-        * If we're not hot-pluggable SFP+, we just need to configure link
-        * and bring it up.
-        */
-       if (hw->phy.type == ixgbe_phy_none)
-               schedule_work(&adapter->sfp_config_module_task);
-
        /* enable transmits */
        netif_tx_start_all_queues(adapter->netdev);
 
@@ -3931,7 +3979,7 @@ static int ixgbe_up_complete(struct ixgbe_adapter *adapter)
         * link up interrupt but shouldn't be a problem */
        adapter->flags |= IXGBE_FLAG_NEED_LINK_UPDATE;
        adapter->link_check_timeout = jiffies;
-       mod_timer(&adapter->watchdog_timer, jiffies);
+       mod_timer(&adapter->service_timer, jiffies);
 
        /* Set PF Reset Done bit so PF/VF Mail Ops can work */
        ctrl_ext = IXGBE_READ_REG(hw, IXGBE_CTRL_EXT);
@@ -3944,8 +3992,11 @@ static int ixgbe_up_complete(struct ixgbe_adapter *adapter)
 void ixgbe_reinit_locked(struct ixgbe_adapter *adapter)
 {
        WARN_ON(in_interrupt());
+       /* put off any impending NetWatchDogTimeout */
+       adapter->netdev->trans_start = jiffies;
+
        while (test_and_set_bit(__IXGBE_RESETTING, &adapter->state))
-               msleep(1);
+               usleep_range(1000, 2000);
        ixgbe_down(adapter);
        /*
         * If SR-IOV enabled then wait a bit before bringing the adapter
@@ -3972,10 +4023,20 @@ void ixgbe_reset(struct ixgbe_adapter *adapter)
        struct ixgbe_hw *hw = &adapter->hw;
        int err;
 
+       /* lock SFP init bit to prevent race conditions with the watchdog */
+       while (test_and_set_bit(__IXGBE_IN_SFP_INIT, &adapter->state))
+               usleep_range(1000, 2000);
+
+       /* clear all SFP and link config related flags while holding SFP_INIT */
+       adapter->flags2 &= ~(IXGBE_FLAG2_SEARCH_FOR_SFP |
+                            IXGBE_FLAG2_SFP_NEEDS_RESET);
+       adapter->flags &= ~IXGBE_FLAG_NEED_LINK_CONFIG;
+
        err = hw->mac.ops.init_hw(hw);
        switch (err) {
        case 0:
        case IXGBE_ERR_SFP_NOT_PRESENT:
+       case IXGBE_ERR_SFP_NOT_SUPPORTED:
                break;
        case IXGBE_ERR_MASTER_REQUESTS_PENDING:
                e_dev_err("master disable timed out\n");
@@ -3993,6 +4054,8 @@ void ixgbe_reset(struct ixgbe_adapter *adapter)
                e_dev_err("Hardware Error: %d\n", err);
        }
 
+       clear_bit(__IXGBE_IN_SFP_INIT, &adapter->state);
+
        /* reprogram the RAR[0] in case user changed it. */
        hw->mac.ops.set_rar(hw, 0, hw->mac.addr, adapter->num_vfs,
                            IXGBE_RAH_AV);
@@ -4121,26 +4184,12 @@ void ixgbe_down(struct ixgbe_adapter *adapter)
        struct net_device *netdev = adapter->netdev;
        struct ixgbe_hw *hw = &adapter->hw;
        u32 rxctrl;
-       u32 txdctl;
        int i;
        int num_q_vectors = adapter->num_msix_vectors - NON_Q_VECTORS;
 
        /* signal that we are down to the interrupt handler */
        set_bit(__IXGBE_DOWN, &adapter->state);
 
-       /* disable receive for all VFs and wait one second */
-       if (adapter->num_vfs) {
-               /* ping all the active vfs to let them know we are going down */
-               ixgbe_ping_all_vfs(adapter);
-
-               /* Disable all VFTE/VFRE TX/RX */
-               ixgbe_disable_tx_rx(adapter);
-
-               /* Mark all the VFs as inactive */
-               for (i = 0 ; i < adapter->num_vfs; i++)
-                       adapter->vfinfo[i].clear_to_send = 0;
-       }
-
        /* disable receives */
        rxctrl = IXGBE_READ_REG(hw, IXGBE_RXCTRL);
        IXGBE_WRITE_REG(hw, IXGBE_RXCTRL, rxctrl & ~IXGBE_RXCTRL_RXEN);
@@ -4150,15 +4199,11 @@ void ixgbe_down(struct ixgbe_adapter *adapter)
                /* this call also flushes the previous write */
                ixgbe_disable_rx_queue(adapter, adapter->rx_ring[i]);
 
-       msleep(10);
+       usleep_range(10000, 20000);
 
        netif_tx_stop_all_queues(netdev);
 
-       clear_bit(__IXGBE_SFP_MODULE_NOT_FOUND, &adapter->state);
-       del_timer_sync(&adapter->sfp_timer);
-       del_timer_sync(&adapter->watchdog_timer);
-       cancel_work_sync(&adapter->watchdog_task);
-
+       /* call carrier off first to avoid false dev_watchdog timeouts */
        netif_carrier_off(netdev);
        netif_tx_disable(netdev);
 
@@ -4166,6 +4211,25 @@ void ixgbe_down(struct ixgbe_adapter *adapter)
 
        ixgbe_napi_disable_all(adapter);
 
+       adapter->flags2 &= ~(IXGBE_FLAG2_FDIR_REQUIRES_REINIT |
+                            IXGBE_FLAG2_RESET_REQUESTED);
+       adapter->flags &= ~IXGBE_FLAG_NEED_LINK_UPDATE;
+
+       del_timer_sync(&adapter->service_timer);
+
+       /* disable receive for all VFs and wait one second */
+       if (adapter->num_vfs) {
+               /* ping all the active vfs to let them know we are going down */
+               ixgbe_ping_all_vfs(adapter);
+
+               /* Disable all VFTE/VFRE TX/RX */
+               ixgbe_disable_tx_rx(adapter);
+
+               /* Mark all the VFs as inactive */
+               for (i = 0 ; i < adapter->num_vfs; i++)
+                       adapter->vfinfo[i].clear_to_send = 0;
+       }
+
        /* Cleanup the affinity_hint CPU mask memory and callback */
        for (i = 0; i < num_q_vectors; i++) {
                struct ixgbe_q_vector *q_vector = adapter->q_vector[i];
@@ -4175,21 +4239,13 @@ void ixgbe_down(struct ixgbe_adapter *adapter)
                free_cpumask_var(q_vector->affinity_mask);
        }
 
-       if (adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE ||
-           adapter->flags & IXGBE_FLAG_FDIR_PERFECT_CAPABLE)
-               cancel_work_sync(&adapter->fdir_reinit_task);
-
-       if (adapter->flags2 & IXGBE_FLAG2_TEMP_SENSOR_CAPABLE)
-               cancel_work_sync(&adapter->check_overtemp_task);
-
        /* disable transmits in the hardware now that interrupts are off */
        for (i = 0; i < adapter->num_tx_queues; i++) {
                u8 reg_idx = adapter->tx_ring[i]->reg_idx;
-               txdctl = IXGBE_READ_REG(hw, IXGBE_TXDCTL(reg_idx));
-               IXGBE_WRITE_REG(hw, IXGBE_TXDCTL(reg_idx),
-                               (txdctl & ~IXGBE_TXDCTL_ENABLE));
+               IXGBE_WRITE_REG(hw, IXGBE_TXDCTL(reg_idx), IXGBE_TXDCTL_SWFLSH);
        }
-       /* Disable the Tx DMA engine on 82599 */
+
+       /* Disable the Tx DMA engine on 82599 and X540 */
        switch (hw->mac.type) {
        case ixgbe_mac_82599EB:
        case ixgbe_mac_X540:
@@ -4201,9 +4257,6 @@ void ixgbe_down(struct ixgbe_adapter *adapter)
                break;
        }
 
-       /* clear n-tuple filters that are cached */
-       ethtool_ntuple_flush(netdev);
-
        if (!pci_channel_offline(adapter->pdev))
                ixgbe_reset(adapter);
 
@@ -4267,25 +4320,8 @@ static void ixgbe_tx_timeout(struct net_device *netdev)
 {
        struct ixgbe_adapter *adapter = netdev_priv(netdev);
 
-       adapter->tx_timeout_count++;
-
        /* Do the reset outside of interrupt context */
-       schedule_work(&adapter->reset_task);
-}
-
-static void ixgbe_reset_task(struct work_struct *work)
-{
-       struct ixgbe_adapter *adapter;
-       adapter = container_of(work, struct ixgbe_adapter, reset_task);
-
-       /* If we're already down or resetting, just bail */
-       if (test_bit(__IXGBE_DOWN, &adapter->state) ||
-           test_bit(__IXGBE_RESETTING, &adapter->state))
-               return;
-
-       ixgbe_dump(adapter);
-       netdev_err(adapter->netdev, "Reset adapter\n");
-       ixgbe_reinit_locked(adapter);
+       ixgbe_tx_timeout_reset(adapter);
 }
 
 /**
@@ -4567,8 +4603,8 @@ static inline bool ixgbe_cache_ring_rss(struct ixgbe_adapter *adapter)
 #ifdef CONFIG_IXGBE_DCB
 
 /* ixgbe_get_first_reg_idx - Return first register index associated with ring */
-void ixgbe_get_first_reg_idx(struct ixgbe_adapter *adapter, u8 tc,
-                            unsigned int *tx, unsigned int *rx)
+static void ixgbe_get_first_reg_idx(struct ixgbe_adapter *adapter, u8 tc,
+                                   unsigned int *tx, unsigned int *rx)
 {
        struct net_device *dev = adapter->netdev;
        struct ixgbe_hw *hw = &adapter->hw;
@@ -5132,57 +5168,6 @@ void ixgbe_clear_interrupt_scheme(struct ixgbe_adapter *adapter)
        ixgbe_reset_interrupt_capability(adapter);
 }
 
-/**
- * ixgbe_sfp_timer - worker thread to find a missing module
- * @data: pointer to our adapter struct
- **/
-static void ixgbe_sfp_timer(unsigned long data)
-{
-       struct ixgbe_adapter *adapter = (struct ixgbe_adapter *)data;
-
-       /*
-        * Do the sfp_timer outside of interrupt context due to the
-        * delays that sfp+ detection requires
-        */
-       schedule_work(&adapter->sfp_task);
-}
-
-/**
- * ixgbe_sfp_task - worker thread to find a missing module
- * @work: pointer to work_struct containing our data
- **/
-static void ixgbe_sfp_task(struct work_struct *work)
-{
-       struct ixgbe_adapter *adapter = container_of(work,
-                                                    struct ixgbe_adapter,
-                                                    sfp_task);
-       struct ixgbe_hw *hw = &adapter->hw;
-
-       if ((hw->phy.type == ixgbe_phy_nl) &&
-           (hw->phy.sfp_type == ixgbe_sfp_type_not_present)) {
-               s32 ret = hw->phy.ops.identify_sfp(hw);
-               if (ret == IXGBE_ERR_SFP_NOT_PRESENT)
-                       goto reschedule;
-               ret = hw->phy.ops.reset(hw);
-               if (ret == IXGBE_ERR_SFP_NOT_SUPPORTED) {
-                       e_dev_err("failed to initialize because an unsupported "
-                                 "SFP+ module type was detected.\n");
-                       e_dev_err("Reload the driver after installing a "
-                                 "supported module.\n");
-                       unregister_netdev(adapter->netdev);
-               } else {
-                       e_info(probe, "detected SFP+: %d\n", hw->phy.sfp_type);
-               }
-               /* don't need this routine any more */
-               clear_bit(__IXGBE_SFP_MODULE_NOT_FOUND, &adapter->state);
-       }
-       return;
-reschedule:
-       if (test_bit(__IXGBE_SFP_MODULE_NOT_FOUND, &adapter->state))
-               mod_timer(&adapter->sfp_timer,
-                         round_jiffies(jiffies + (2 * HZ)));
-}
-
 /**
  * ixgbe_sw_init - Initialize general software structures (struct ixgbe_adapter)
  * @adapter: board private structure to initialize
@@ -5899,8 +5884,13 @@ void ixgbe_update_stats(struct ixgbe_adapter *adapter)
                hwstats->gotc += IXGBE_READ_REG(hw, IXGBE_GOTCH);
                hwstats->tor += IXGBE_READ_REG(hw, IXGBE_TORH);
                break;
-       case ixgbe_mac_82599EB:
        case ixgbe_mac_X540:
+               /* OS2BMC stats are X540 only*/
+               hwstats->o2bgptc += IXGBE_READ_REG(hw, IXGBE_O2BGPTC);
+               hwstats->o2bspc += IXGBE_READ_REG(hw, IXGBE_O2BSPC);
+               hwstats->b2ospc += IXGBE_READ_REG(hw, IXGBE_B2OSPC);
+               hwstats->b2ogprc += IXGBE_READ_REG(hw, IXGBE_B2OGPRC);
+       case ixgbe_mac_82599EB:
                hwstats->gorc += IXGBE_READ_REG(hw, IXGBE_GORCL);
                IXGBE_READ_REG(hw, IXGBE_GORCH); /* to clear */
                hwstats->gotc += IXGBE_READ_REG(hw, IXGBE_GOTCL);
@@ -5974,23 +5964,66 @@ void ixgbe_update_stats(struct ixgbe_adapter *adapter)
 }
 
 /**
- * ixgbe_watchdog - Timer Call-back
- * @data: pointer to adapter cast into an unsigned long
+ * ixgbe_fdir_reinit_subtask - worker thread to reinit FDIR filter table
+ * @adapter - pointer to the device adapter structure
  **/
-static void ixgbe_watchdog(unsigned long data)
+static void ixgbe_fdir_reinit_subtask(struct ixgbe_adapter *adapter)
 {
-       struct ixgbe_adapter *adapter = (struct ixgbe_adapter *)data;
        struct ixgbe_hw *hw = &adapter->hw;
-       u64 eics = 0;
        int i;
 
-       /*
-        *  Do the watchdog outside of interrupt context due to the lovely
-        * delays that some of the newer hardware requires
-        */
+       if (!(adapter->flags2 & IXGBE_FLAG2_FDIR_REQUIRES_REINIT))
+               return;
+
+       adapter->flags2 &= ~IXGBE_FLAG2_FDIR_REQUIRES_REINIT;
 
+       /* if interface is down do nothing */
        if (test_bit(__IXGBE_DOWN, &adapter->state))
-               goto watchdog_short_circuit;
+               return;
+
+       /* do nothing if we are not using signature filters */
+       if (!(adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE))
+               return;
+
+       adapter->fdir_overflow++;
+
+       if (ixgbe_reinit_fdir_tables_82599(hw) == 0) {
+               for (i = 0; i < adapter->num_tx_queues; i++)
+                       set_bit(__IXGBE_TX_FDIR_INIT_DONE,
+                               &(adapter->tx_ring[i]->state));
+               /* re-enable flow director interrupts */
+               IXGBE_WRITE_REG(hw, IXGBE_EIMS, IXGBE_EIMS_FLOW_DIR);
+       } else {
+               e_err(probe, "failed to finish FDIR re-initialization, "
+                     "ignored adding FDIR ATR filters\n");
+       }
+}
+
+/**
+ * ixgbe_check_hang_subtask - check for hung queues and dropped interrupts
+ * @adapter - pointer to the device adapter structure
+ *
+ * This function serves two purposes.  First it strobes the interrupt lines
+ * in order to make certain interrupts are occuring.  Secondly it sets the
+ * bits needed to check for TX hangs.  As a result we should immediately
+ * determine if a hang has occured.
+ */
+static void ixgbe_check_hang_subtask(struct ixgbe_adapter *adapter)
+{
+       struct ixgbe_hw *hw = &adapter->hw;
+       u64 eics = 0;
+       int i;
+
+       /* If we're down or resetting, just bail */
+       if (test_bit(__IXGBE_DOWN, &adapter->state) ||
+           test_bit(__IXGBE_RESETTING, &adapter->state))
+               return;
+
+       /* Force detection of hung controller */
+       if (netif_carrier_ok(adapter->netdev)) {
+               for (i = 0; i < adapter->num_tx_queues; i++)
+                       set_check_for_tx_hang(adapter->tx_ring[i]);
+       }
 
        if (!(adapter->flags & IXGBE_FLAG_MSIX_ENABLED)) {
                /*
@@ -6000,108 +6033,172 @@ static void ixgbe_watchdog(unsigned long data)
                 */
                IXGBE_WRITE_REG(hw, IXGBE_EICS,
                        (IXGBE_EICS_TCP_TIMER | IXGBE_EICS_OTHER));
-               goto watchdog_reschedule;
-       }
-
-       /* get one bit for every active tx/rx interrupt vector */
-       for (i = 0; i < adapter->num_msix_vectors - NON_Q_VECTORS; i++) {
-               struct ixgbe_q_vector *qv = adapter->q_vector[i];
-               if (qv->rxr_count || qv->txr_count)
-                       eics |= ((u64)1 << i);
+       } else {
+               /* get one bit for every active tx/rx interrupt vector */
+               for (i = 0; i < adapter->num_msix_vectors - NON_Q_VECTORS; i++) {
+                       struct ixgbe_q_vector *qv = adapter->q_vector[i];
+                       if (qv->rxr_count || qv->txr_count)
+                               eics |= ((u64)1 << i);
+               }
        }
 
-       /* Cause software interrupt to ensure rx rings are cleaned */
+       /* Cause software interrupt to ensure rings are cleaned */
        ixgbe_irq_rearm_queues(adapter, eics);
 
-watchdog_reschedule:
-       /* Reset the timer */
-       mod_timer(&adapter->watchdog_timer, round_jiffies(jiffies + 2 * HZ));
-
-watchdog_short_circuit:
-       schedule_work(&adapter->watchdog_task);
 }
 
 /**
- * ixgbe_multispeed_fiber_task - worker thread to configure multispeed fiber
- * @work: pointer to work_struct containing our data
+ * ixgbe_watchdog_update_link - update the link status
+ * @adapter - pointer to the device adapter structure
+ * @link_speed - pointer to a u32 to store the link_speed
  **/
-static void ixgbe_multispeed_fiber_task(struct work_struct *work)
+static void ixgbe_watchdog_update_link(struct ixgbe_adapter *adapter)
 {
-       struct ixgbe_adapter *adapter = container_of(work,
-                                                    struct ixgbe_adapter,
-                                                    multispeed_fiber_task);
        struct ixgbe_hw *hw = &adapter->hw;
-       u32 autoneg;
-       bool negotiation;
+       u32 link_speed = adapter->link_speed;
+       bool link_up = adapter->link_up;
+       int i;
 
-       adapter->flags |= IXGBE_FLAG_IN_SFP_LINK_TASK;
-       autoneg = hw->phy.autoneg_advertised;
-       if ((!autoneg) && (hw->mac.ops.get_link_capabilities))
-               hw->mac.ops.get_link_capabilities(hw, &autoneg, &negotiation);
-       hw->mac.autotry_restart = false;
-       if (hw->mac.ops.setup_link)
-               hw->mac.ops.setup_link(hw, autoneg, negotiation, true);
-       adapter->flags |= IXGBE_FLAG_NEED_LINK_UPDATE;
-       adapter->flags &= ~IXGBE_FLAG_IN_SFP_LINK_TASK;
+       if (!(adapter->flags & IXGBE_FLAG_NEED_LINK_UPDATE))
+               return;
+
+       if (hw->mac.ops.check_link) {
+               hw->mac.ops.check_link(hw, &link_speed, &link_up, false);
+       } else {
+               /* always assume link is up, if no check link function */
+               link_speed = IXGBE_LINK_SPEED_10GB_FULL;
+               link_up = true;
+       }
+       if (link_up) {
+               if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) {
+                       for (i = 0; i < MAX_TRAFFIC_CLASS; i++)
+                               hw->mac.ops.fc_enable(hw, i);
+               } else {
+                       hw->mac.ops.fc_enable(hw, 0);
+               }
+       }
+
+       if (link_up ||
+           time_after(jiffies, (adapter->link_check_timeout +
+                                IXGBE_TRY_LINK_TIMEOUT))) {
+               adapter->flags &= ~IXGBE_FLAG_NEED_LINK_UPDATE;
+               IXGBE_WRITE_REG(hw, IXGBE_EIMS, IXGBE_EIMC_LSC);
+               IXGBE_WRITE_FLUSH(hw);
+       }
+
+       adapter->link_up = link_up;
+       adapter->link_speed = link_speed;
 }
 
 /**
- * ixgbe_sfp_config_module_task - worker thread to configure a new SFP+ module
- * @work: pointer to work_struct containing our data
+ * ixgbe_watchdog_link_is_up - update netif_carrier status and
+ *                             print link up message
+ * @adapter - pointer to the device adapter structure
  **/
-static void ixgbe_sfp_config_module_task(struct work_struct *work)
+static void ixgbe_watchdog_link_is_up(struct ixgbe_adapter *adapter)
 {
-       struct ixgbe_adapter *adapter = container_of(work,
-                                                    struct ixgbe_adapter,
-                                                    sfp_config_module_task);
+       struct net_device *netdev = adapter->netdev;
        struct ixgbe_hw *hw = &adapter->hw;
-       u32 err;
+       u32 link_speed = adapter->link_speed;
+       bool flow_rx, flow_tx;
 
-       adapter->flags |= IXGBE_FLAG_IN_SFP_MOD_TASK;
+       /* only continue if link was previously down */
+       if (netif_carrier_ok(netdev))
+               return;
 
-       /* Time for electrical oscillations to settle down */
-       msleep(100);
-       err = hw->phy.ops.identify_sfp(hw);
+       adapter->flags2 &= ~IXGBE_FLAG2_SEARCH_FOR_SFP;
 
-       if (err == IXGBE_ERR_SFP_NOT_SUPPORTED) {
-               e_dev_err("failed to initialize because an unsupported SFP+ "
-                         "module type was detected.\n");
-               e_dev_err("Reload the driver after installing a supported "
-                         "module.\n");
-               unregister_netdev(adapter->netdev);
-               return;
+       switch (hw->mac.type) {
+       case ixgbe_mac_82598EB: {
+               u32 frctl = IXGBE_READ_REG(hw, IXGBE_FCTRL);
+               u32 rmcs = IXGBE_READ_REG(hw, IXGBE_RMCS);
+               flow_rx = !!(frctl & IXGBE_FCTRL_RFCE);
+               flow_tx = !!(rmcs & IXGBE_RMCS_TFCE_802_3X);
+       }
+               break;
+       case ixgbe_mac_X540:
+       case ixgbe_mac_82599EB: {
+               u32 mflcn = IXGBE_READ_REG(hw, IXGBE_MFLCN);
+               u32 fccfg = IXGBE_READ_REG(hw, IXGBE_FCCFG);
+               flow_rx = !!(mflcn & IXGBE_MFLCN_RFCE);
+               flow_tx = !!(fccfg & IXGBE_FCCFG_TFCE_802_3X);
+       }
+               break;
+       default:
+               flow_tx = false;
+               flow_rx = false;
+               break;
        }
-       if (hw->mac.ops.setup_sfp)
-               hw->mac.ops.setup_sfp(hw);
+       e_info(drv, "NIC Link is Up %s, Flow Control: %s\n",
+              (link_speed == IXGBE_LINK_SPEED_10GB_FULL ?
+              "10 Gbps" :
+              (link_speed == IXGBE_LINK_SPEED_1GB_FULL ?
+              "1 Gbps" :
+              (link_speed == IXGBE_LINK_SPEED_100_FULL ?
+              "100 Mbps" :
+              "unknown speed"))),
+              ((flow_rx && flow_tx) ? "RX/TX" :
+              (flow_rx ? "RX" :
+              (flow_tx ? "TX" : "None"))));
 
-       if (!(adapter->flags & IXGBE_FLAG_IN_SFP_LINK_TASK))
-               /* This will also work for DA Twinax connections */
-               schedule_work(&adapter->multispeed_fiber_task);
-       adapter->flags &= ~IXGBE_FLAG_IN_SFP_MOD_TASK;
+       netif_carrier_on(netdev);
+#ifdef HAVE_IPLINK_VF_CONFIG
+       ixgbe_check_vf_rate_limit(adapter);
+#endif /* HAVE_IPLINK_VF_CONFIG */
 }
 
 /**
- * ixgbe_fdir_reinit_task - worker thread to reinit FDIR filter table
- * @work: pointer to work_struct containing our data
+ * ixgbe_watchdog_link_is_down - update netif_carrier status and
+ *                               print link down message
+ * @adapter - pointer to the adapter structure
  **/
-static void ixgbe_fdir_reinit_task(struct work_struct *work)
+static void ixgbe_watchdog_link_is_down(struct ixgbe_adapter* adapter)
 {
-       struct ixgbe_adapter *adapter = container_of(work,
-                                                    struct ixgbe_adapter,
-                                                    fdir_reinit_task);
+       struct net_device *netdev = adapter->netdev;
        struct ixgbe_hw *hw = &adapter->hw;
+
+       adapter->link_up = false;
+       adapter->link_speed = 0;
+
+       /* only continue if link was up previously */
+       if (!netif_carrier_ok(netdev))
+               return;
+
+       /* poll for SFP+ cable when link is down */
+       if (ixgbe_is_sfp(hw) && hw->mac.type == ixgbe_mac_82598EB)
+               adapter->flags2 |= IXGBE_FLAG2_SEARCH_FOR_SFP;
+
+       e_info(drv, "NIC Link is Down\n");
+       netif_carrier_off(netdev);
+}
+
+/**
+ * ixgbe_watchdog_flush_tx - flush queues on link down
+ * @adapter - pointer to the device adapter structure
+ **/
+static void ixgbe_watchdog_flush_tx(struct ixgbe_adapter *adapter)
+{
        int i;
+       int some_tx_pending = 0;
 
-       if (ixgbe_reinit_fdir_tables_82599(hw) == 0) {
-               for (i = 0; i < adapter->num_tx_queues; i++)
-                       set_bit(__IXGBE_TX_FDIR_INIT_DONE,
-                               &(adapter->tx_ring[i]->state));
-       } else {
-               e_err(probe, "failed to finish FDIR re-initialization, "
-                     "ignored adding FDIR ATR filters\n");
+       if (!netif_carrier_ok(adapter->netdev)) {
+               for (i = 0; i < adapter->num_tx_queues; i++) {
+                       struct ixgbe_ring *tx_ring = adapter->tx_ring[i];
+                       if (tx_ring->next_to_use != tx_ring->next_to_clean) {
+                               some_tx_pending = 1;
+                               break;
+                       }
+               }
+
+               if (some_tx_pending) {
+                       /* We've lost link, so the controller stops DMA,
+                        * but we've got queued Tx work that's never going
+                        * to get done, so reset controller to flush Tx.
+                        * (Do the reset outside of interrupt context).
+                        */
+                       adapter->flags2 |= IXGBE_FLAG2_RESET_REQUESTED;
+               }
        }
-       /* Done FDIR Re-initialization, enable transmits */
-       netif_tx_start_all_queues(adapter->netdev);
 }
 
 static void ixgbe_spoof_check(struct ixgbe_adapter *adapter)
@@ -6124,133 +6221,186 @@ static void ixgbe_spoof_check(struct ixgbe_adapter *adapter)
        e_warn(drv, "%d Spoofed packets detected\n", ssvpc);
 }
 
-static DEFINE_MUTEX(ixgbe_watchdog_lock);
+/**
+ * ixgbe_watchdog_subtask - check and bring link up
+ * @adapter - pointer to the device adapter structure
+ **/
+static void ixgbe_watchdog_subtask(struct ixgbe_adapter *adapter)
+{
+       /* if interface is down do nothing */
+       if (test_bit(__IXGBE_DOWN, &adapter->state))
+               return;
+
+       ixgbe_watchdog_update_link(adapter);
+
+       if (adapter->link_up)
+               ixgbe_watchdog_link_is_up(adapter);
+       else
+               ixgbe_watchdog_link_is_down(adapter);
+
+       ixgbe_spoof_check(adapter);
+       ixgbe_update_stats(adapter);
+
+       ixgbe_watchdog_flush_tx(adapter);
+}
 
 /**
- * ixgbe_watchdog_task - worker thread to bring link up
- * @work: pointer to work_struct containing our data
+ * ixgbe_sfp_detection_subtask - poll for SFP+ cable
+ * @adapter - the ixgbe adapter structure
  **/
-static void ixgbe_watchdog_task(struct work_struct *work)
+static void ixgbe_sfp_detection_subtask(struct ixgbe_adapter *adapter)
 {
-       struct ixgbe_adapter *adapter = container_of(work,
-                                                    struct ixgbe_adapter,
-                                                    watchdog_task);
-       struct net_device *netdev = adapter->netdev;
        struct ixgbe_hw *hw = &adapter->hw;
-       u32 link_speed;
-       bool link_up;
-       int i;
-       struct ixgbe_ring *tx_ring;
-       int some_tx_pending = 0;
+       s32 err;
 
-       mutex_lock(&ixgbe_watchdog_lock);
+       /* not searching for SFP so there is nothing to do here */
+       if (!(adapter->flags2 & IXGBE_FLAG2_SEARCH_FOR_SFP) &&
+           !(adapter->flags2 & IXGBE_FLAG2_SFP_NEEDS_RESET))
+               return;
 
-       link_up = adapter->link_up;
-       link_speed = adapter->link_speed;
+       /* someone else is in init, wait until next service event */
+       if (test_and_set_bit(__IXGBE_IN_SFP_INIT, &adapter->state))
+               return;
 
-       if (adapter->flags & IXGBE_FLAG_NEED_LINK_UPDATE) {
-               hw->mac.ops.check_link(hw, &link_speed, &link_up, false);
-               if (link_up) {
-#ifdef CONFIG_DCB
-                       if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) {
-                               for (i = 0; i < MAX_TRAFFIC_CLASS; i++)
-                                       hw->mac.ops.fc_enable(hw, i);
-                       } else {
-                               hw->mac.ops.fc_enable(hw, 0);
-                       }
-#else
-                       hw->mac.ops.fc_enable(hw, 0);
-#endif
-               }
+       err = hw->phy.ops.identify_sfp(hw);
+       if (err == IXGBE_ERR_SFP_NOT_SUPPORTED)
+               goto sfp_out;
 
-               if (link_up ||
-                   time_after(jiffies, (adapter->link_check_timeout +
-                                        IXGBE_TRY_LINK_TIMEOUT))) {
-                       adapter->flags &= ~IXGBE_FLAG_NEED_LINK_UPDATE;
-                       IXGBE_WRITE_REG(hw, IXGBE_EIMS, IXGBE_EIMC_LSC);
-               }
-               adapter->link_up = link_up;
-               adapter->link_speed = link_speed;
+       if (err == IXGBE_ERR_SFP_NOT_PRESENT) {
+               /* If no cable is present, then we need to reset
+                * the next time we find a good cable. */
+               adapter->flags2 |= IXGBE_FLAG2_SFP_NEEDS_RESET;
        }
 
-       if (link_up) {
-               if (!netif_carrier_ok(netdev)) {
-                       bool flow_rx, flow_tx;
-
-                       switch (hw->mac.type) {
-                       case ixgbe_mac_82598EB: {
-                               u32 frctl = IXGBE_READ_REG(hw, IXGBE_FCTRL);
-                               u32 rmcs = IXGBE_READ_REG(hw, IXGBE_RMCS);
-                               flow_rx = !!(frctl & IXGBE_FCTRL_RFCE);
-                               flow_tx = !!(rmcs & IXGBE_RMCS_TFCE_802_3X);
-                       }
-                               break;
-                       case ixgbe_mac_82599EB:
-                       case ixgbe_mac_X540: {
-                               u32 mflcn = IXGBE_READ_REG(hw, IXGBE_MFLCN);
-                               u32 fccfg = IXGBE_READ_REG(hw, IXGBE_FCCFG);
-                               flow_rx = !!(mflcn & IXGBE_MFLCN_RFCE);
-                               flow_tx = !!(fccfg & IXGBE_FCCFG_TFCE_802_3X);
-                       }
-                               break;
-                       default:
-                               flow_tx = false;
-                               flow_rx = false;
-                               break;
-                       }
+       /* exit on error */
+       if (err)
+               goto sfp_out;
 
-                       e_info(drv, "NIC Link is Up %s, Flow Control: %s\n",
-                              (link_speed == IXGBE_LINK_SPEED_10GB_FULL ?
-                              "10 Gbps" :
-                              (link_speed == IXGBE_LINK_SPEED_1GB_FULL ?
-                              "1 Gbps" :
-                              (link_speed == IXGBE_LINK_SPEED_100_FULL ?
-                              "100 Mbps" :
-                              "unknown speed"))),
-                              ((flow_rx && flow_tx) ? "RX/TX" :
-                              (flow_rx ? "RX" :
-                              (flow_tx ? "TX" : "None"))));
-
-                       netif_carrier_on(netdev);
-                       ixgbe_check_vf_rate_limit(adapter);
-               } else {
-                       /* Force detection of hung controller */
-                       for (i = 0; i < adapter->num_tx_queues; i++) {
-                               tx_ring = adapter->tx_ring[i];
-                               set_check_for_tx_hang(tx_ring);
-                       }
-               }
-       } else {
-               adapter->link_up = false;
-               adapter->link_speed = 0;
-               if (netif_carrier_ok(netdev)) {
-                       e_info(drv, "NIC Link is Down\n");
-                       netif_carrier_off(netdev);
-               }
-       }
+       /* exit if reset not needed */
+       if (!(adapter->flags2 & IXGBE_FLAG2_SFP_NEEDS_RESET))
+               goto sfp_out;
 
-       if (!netif_carrier_ok(netdev)) {
-               for (i = 0; i < adapter->num_tx_queues; i++) {
-                       tx_ring = adapter->tx_ring[i];
-                       if (tx_ring->next_to_use != tx_ring->next_to_clean) {
-                               some_tx_pending = 1;
-                               break;
-                       }
-               }
+       adapter->flags2 &= ~IXGBE_FLAG2_SFP_NEEDS_RESET;
 
-               if (some_tx_pending) {
-                       /* We've lost link, so the controller stops DMA,
-                        * but we've got queued Tx work that's never going
-                        * to get done, so reset controller to flush Tx.
-                        * (Do the reset outside of interrupt context).
-                        */
-                        schedule_work(&adapter->reset_task);
-               }
+       /*
+        * A module may be identified correctly, but the EEPROM may not have
+        * support for that module.  setup_sfp() will fail in that case, so
+        * we should not allow that module to load.
+        */
+       if (hw->mac.type == ixgbe_mac_82598EB)
+               err = hw->phy.ops.reset(hw);
+       else
+               err = hw->mac.ops.setup_sfp(hw);
+
+       if (err == IXGBE_ERR_SFP_NOT_SUPPORTED)
+               goto sfp_out;
+
+       adapter->flags |= IXGBE_FLAG_NEED_LINK_CONFIG;
+       e_info(probe, "detected SFP+: %d\n", hw->phy.sfp_type);
+
+sfp_out:
+       clear_bit(__IXGBE_IN_SFP_INIT, &adapter->state);
+
+       if ((err == IXGBE_ERR_SFP_NOT_SUPPORTED) &&
+           (adapter->netdev->reg_state == NETREG_REGISTERED)) {
+               e_dev_err("failed to initialize because an unsupported "
+                         "SFP+ module type was detected.\n");
+               e_dev_err("Reload the driver after installing a "
+                         "supported module.\n");
+               unregister_netdev(adapter->netdev);
        }
+}
 
-       ixgbe_spoof_check(adapter);
-       ixgbe_update_stats(adapter);
-       mutex_unlock(&ixgbe_watchdog_lock);
+/**
+ * ixgbe_sfp_link_config_subtask - set up link SFP after module install
+ * @adapter - the ixgbe adapter structure
+ **/
+static void ixgbe_sfp_link_config_subtask(struct ixgbe_adapter *adapter)
+{
+       struct ixgbe_hw *hw = &adapter->hw;
+       u32 autoneg;
+       bool negotiation;
+
+       if (!(adapter->flags & IXGBE_FLAG_NEED_LINK_CONFIG))
+               return;
+
+       /* someone else is in init, wait until next service event */
+       if (test_and_set_bit(__IXGBE_IN_SFP_INIT, &adapter->state))
+               return;
+
+       adapter->flags &= ~IXGBE_FLAG_NEED_LINK_CONFIG;
+
+       autoneg = hw->phy.autoneg_advertised;
+       if ((!autoneg) && (hw->mac.ops.get_link_capabilities))
+               hw->mac.ops.get_link_capabilities(hw, &autoneg, &negotiation);
+       hw->mac.autotry_restart = false;
+       if (hw->mac.ops.setup_link)
+               hw->mac.ops.setup_link(hw, autoneg, negotiation, true);
+
+       adapter->flags |= IXGBE_FLAG_NEED_LINK_UPDATE;
+       adapter->link_check_timeout = jiffies;
+       clear_bit(__IXGBE_IN_SFP_INIT, &adapter->state);
+}
+
+/**
+ * ixgbe_service_timer - Timer Call-back
+ * @data: pointer to adapter cast into an unsigned long
+ **/
+static void ixgbe_service_timer(unsigned long data)
+{
+       struct ixgbe_adapter *adapter = (struct ixgbe_adapter *)data;
+       unsigned long next_event_offset;
+
+       /* poll faster when waiting for link */
+       if (adapter->flags & IXGBE_FLAG_NEED_LINK_UPDATE)
+               next_event_offset = HZ / 10;
+       else
+               next_event_offset = HZ * 2;
+
+       /* Reset the timer */
+       mod_timer(&adapter->service_timer, next_event_offset + jiffies);
+
+       ixgbe_service_event_schedule(adapter);
+}
+
+static void ixgbe_reset_subtask(struct ixgbe_adapter *adapter)
+{
+       if (!(adapter->flags2 & IXGBE_FLAG2_RESET_REQUESTED))
+               return;
+
+       adapter->flags2 &= ~IXGBE_FLAG2_RESET_REQUESTED;
+
+       /* If we're already down or resetting, just bail */
+       if (test_bit(__IXGBE_DOWN, &adapter->state) ||
+           test_bit(__IXGBE_RESETTING, &adapter->state))
+               return;
+
+       ixgbe_dump(adapter);
+       netdev_err(adapter->netdev, "Reset adapter\n");
+       adapter->tx_timeout_count++;
+
+       ixgbe_reinit_locked(adapter);
+}
+
+/**
+ * ixgbe_service_task - manages and runs subtasks
+ * @work: pointer to work_struct containing our data
+ **/
+static void ixgbe_service_task(struct work_struct *work)
+{
+       struct ixgbe_adapter *adapter = container_of(work,
+                                                    struct ixgbe_adapter,
+                                                    service_task);
+
+       ixgbe_reset_subtask(adapter);
+       ixgbe_sfp_detection_subtask(adapter);
+       ixgbe_sfp_link_config_subtask(adapter);
+       ixgbe_check_overtemp_subtask(adapter);
+       ixgbe_watchdog_subtask(adapter);
+       ixgbe_fdir_reinit_subtask(adapter);
+       ixgbe_check_hang_subtask(adapter);
+
+       ixgbe_service_event_complete(adapter);
 }
 
 static int ixgbe_tso(struct ixgbe_adapter *adapter,
@@ -7089,6 +7239,8 @@ static void __devinit ixgbe_probe_vf(struct ixgbe_adapter *adapter,
 #ifdef CONFIG_PCI_IOV
        struct ixgbe_hw *hw = &adapter->hw;
        int err;
+       int num_vf_macvlans, i;
+       struct vf_macvlans *mv_list;
 
        if (hw->mac.type == ixgbe_mac_82598EB || !max_vfs)
                return;
@@ -7105,6 +7257,26 @@ static void __devinit ixgbe_probe_vf(struct ixgbe_adapter *adapter,
                e_err(probe, "Failed to enable PCI sriov: %d\n", err);
                goto err_novfs;
        }
+
+       num_vf_macvlans = hw->mac.num_rar_entries -
+               (IXGBE_MAX_PF_MACVLANS + 1 + adapter->num_vfs);
+
+       adapter->mv_list = mv_list = kcalloc(num_vf_macvlans,
+                                            sizeof(struct vf_macvlans),
+                                            GFP_KERNEL);
+       if (mv_list) {
+               /* Initialize list of VF macvlans */
+               INIT_LIST_HEAD(&adapter->vf_mvs.l);
+               for (i = 0; i < num_vf_macvlans; i++) {
+                       mv_list->vf = -1;
+                       mv_list->free = true;
+                       mv_list->rar_entry = hw->mac.num_rar_entries -
+                               (i + adapter->num_vfs + 1);
+                       list_add(&mv_list->l, &adapter->vf_mvs.l);
+                       mv_list++;
+               }
+       }
+
        /* If call to enable VFs succeeded then allocate memory
         * for per VF control structures.
         */
@@ -7275,22 +7447,6 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev,
        hw->phy.mdio.mdio_read = ixgbe_mdio_read;
        hw->phy.mdio.mdio_write = ixgbe_mdio_write;
 
-       /* set up this timer and work struct before calling get_invariants
-        * which might start the timer
-        */
-       init_timer(&adapter->sfp_timer);
-       adapter->sfp_timer.function = ixgbe_sfp_timer;
-       adapter->sfp_timer.data = (unsigned long) adapter;
-
-       INIT_WORK(&adapter->sfp_task, ixgbe_sfp_task);
-
-       /* multispeed fiber has its own tasklet, called from GPI SDP1 context */
-       INIT_WORK(&adapter->multispeed_fiber_task, ixgbe_multispeed_fiber_task);
-
-       /* a new SFP+ module arrival, called from GPI SDP2 context */
-       INIT_WORK(&adapter->sfp_config_module_task,
-                 ixgbe_sfp_config_module_task);
-
        ii->get_invariants(hw);
 
        /* setup the private structure */
@@ -7324,17 +7480,9 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev,
        hw->phy.reset_if_overtemp = false;
        if (err == IXGBE_ERR_SFP_NOT_PRESENT &&
            hw->mac.type == ixgbe_mac_82598EB) {
-               /*
-                * Start a kernel thread to watch for a module to arrive.
-                * Only do this for 82598, since 82599 will generate
-                * interrupts on module arrival.
-                */
-               set_bit(__IXGBE_SFP_MODULE_NOT_FOUND, &adapter->state);
-               mod_timer(&adapter->sfp_timer,
-                         round_jiffies(jiffies + (2 * HZ)));
                err = 0;
        } else if (err == IXGBE_ERR_SFP_NOT_SUPPORTED) {
-               e_dev_err("failed to initialize because an unsupported SFP+ "
+               e_dev_err("failed to load because an unsupported SFP+ "
                          "module type was detected.\n");
                e_dev_err("Reload the driver after installing a supported "
                          "module.\n");
@@ -7356,9 +7504,16 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev,
        netdev->features |= NETIF_F_TSO;
        netdev->features |= NETIF_F_TSO6;
        netdev->features |= NETIF_F_GRO;
+       netdev->features |= NETIF_F_RXHASH;
 
-       if (adapter->hw.mac.type == ixgbe_mac_82599EB)
+       switch (adapter->hw.mac.type) {
+       case ixgbe_mac_82599EB:
+       case ixgbe_mac_X540:
                netdev->features |= NETIF_F_SCTP_CSUM;
+               break;
+       default:
+               break;
+       }
 
        netdev->vlan_features |= NETIF_F_TSO;
        netdev->vlan_features |= NETIF_F_TSO6;
@@ -7419,17 +7574,19 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev,
              (hw->mac.type == ixgbe_mac_82599EB))))
                hw->mac.ops.disable_tx_laser(hw);
 
-       init_timer(&adapter->watchdog_timer);
-       adapter->watchdog_timer.function = ixgbe_watchdog;
-       adapter->watchdog_timer.data = (unsigned long)adapter;
+       setup_timer(&adapter->service_timer, &ixgbe_service_timer,
+                   (unsigned long) adapter);
 
-       INIT_WORK(&adapter->reset_task, ixgbe_reset_task);
-       INIT_WORK(&adapter->watchdog_task, ixgbe_watchdog_task);
+       INIT_WORK(&adapter->service_task, ixgbe_service_task);
+       clear_bit(__IXGBE_SERVICE_SCHED, &adapter->state);
 
        err = ixgbe_init_interrupt_scheme(adapter);
        if (err)
                goto err_sw_init;
 
+       if (!(adapter->flags & IXGBE_FLAG_RSS_ENABLED))
+               netdev->features &= ~NETIF_F_RXHASH;
+
        switch (pdev->device) {
        case IXGBE_DEV_ID_82599_SFP:
                /* Only this subdevice supports WOL */
@@ -7458,8 +7615,8 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev,
 
        /* print bus type/speed/width info */
        e_dev_info("(PCI Express:%s:%s) %pM\n",
-                  (hw->bus.speed == ixgbe_bus_speed_5000 ? "5.0Gb/s" :
-                   hw->bus.speed == ixgbe_bus_speed_2500 ? "2.5Gb/s" :
+                  (hw->bus.speed == ixgbe_bus_speed_5000 ? "5.0GT/s" :
+                   hw->bus.speed == ixgbe_bus_speed_2500 ? "2.5GT/s" :
                    "Unknown"),
                   (hw->bus.width == ixgbe_bus_width_pcie_x8 ? "Width x8" :
                    hw->bus.width == ixgbe_bus_width_pcie_x4 ? "Width x4" :
@@ -7508,13 +7665,6 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev,
        /* carrier off reporting is important to ethtool even BEFORE open */
        netif_carrier_off(netdev);
 
-       if (adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE ||
-           adapter->flags & IXGBE_FLAG_FDIR_PERFECT_CAPABLE)
-               INIT_WORK(&adapter->fdir_reinit_task, ixgbe_fdir_reinit_task);
-
-       if (adapter->flags2 & IXGBE_FLAG2_TEMP_SENSOR_CAPABLE)
-               INIT_WORK(&adapter->check_overtemp_task,
-                         ixgbe_check_overtemp_task);
 #ifdef CONFIG_IXGBE_DCA
        if (dca_add_requester(&pdev->dev) == 0) {
                adapter->flags |= IXGBE_FLAG_DCA_ENABLED;
@@ -7541,11 +7691,7 @@ err_sw_init:
 err_eeprom:
        if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED)
                ixgbe_disable_sriov(adapter);
-       clear_bit(__IXGBE_SFP_MODULE_NOT_FOUND, &adapter->state);
-       del_timer_sync(&adapter->sfp_timer);
-       cancel_work_sync(&adapter->sfp_task);
-       cancel_work_sync(&adapter->multispeed_fiber_task);
-       cancel_work_sync(&adapter->sfp_config_module_task);
+       adapter->flags2 &= ~IXGBE_FLAG2_SEARCH_FOR_SFP;
        iounmap(hw->hw_addr);
 err_ioremap:
        free_netdev(netdev);
@@ -7573,24 +7719,7 @@ static void __devexit ixgbe_remove(struct pci_dev *pdev)
        struct net_device *netdev = adapter->netdev;
 
        set_bit(__IXGBE_DOWN, &adapter->state);
-
-       /*
-        * The timers may be rescheduled, so explicitly disable them
-        * from being rescheduled.
-        */
-       clear_bit(__IXGBE_SFP_MODULE_NOT_FOUND, &adapter->state);
-       del_timer_sync(&adapter->watchdog_timer);
-       del_timer_sync(&adapter->sfp_timer);
-
-       cancel_work_sync(&adapter->watchdog_task);
-       cancel_work_sync(&adapter->sfp_task);
-       cancel_work_sync(&adapter->multispeed_fiber_task);
-       cancel_work_sync(&adapter->sfp_config_module_task);
-       if (adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE ||
-           adapter->flags & IXGBE_FLAG_FDIR_PERFECT_CAPABLE)
-               cancel_work_sync(&adapter->fdir_reinit_task);
-       if (adapter->flags2 & IXGBE_FLAG2_TEMP_SENSOR_CAPABLE)
-               cancel_work_sync(&adapter->check_overtemp_task);
+       cancel_work_sync(&adapter->service_task);
 
 #ifdef CONFIG_IXGBE_DCA
        if (adapter->flags & IXGBE_FLAG_DCA_ENABLED) {