ixgbe: Check config reads for removal
[linux.git] / drivers / net / ethernet / intel / ixgbe / ixgbe_main.c
index 6d4ada72dfd0a79f1111ff5c48f91ba3e2c862f1..72807431c88a1c144c6e016adb00c3a6fe0ba9ad 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************************
 
   Intel 10 Gigabit PCI Express Linux driver
-  Copyright(c) 1999 - 2013 Intel Corporation.
+  Copyright(c) 1999 - 2014 Intel Corporation.
 
   This program is free software; you can redistribute it and/or modify it
   under the terms and conditions of the GNU General Public License,
@@ -67,7 +67,7 @@ static char ixgbe_default_device_descr[] =
 #define DRV_VERSION "3.19.1-k"
 const char ixgbe_driver_version[] = DRV_VERSION;
 static const char ixgbe_copyright[] =
-                               "Copyright (c) 1999-2013 Intel Corporation.";
+                               "Copyright (c) 1999-2014 Intel Corporation.";
 
 static const struct ixgbe_info *ixgbe_info_tbl[] = {
        [board_82598] = &ixgbe_82598_info,
@@ -151,6 +151,8 @@ MODULE_DESCRIPTION("Intel(R) 10 Gigabit PCI Express Network Driver");
 MODULE_LICENSE("GPL");
 MODULE_VERSION(DRV_VERSION);
 
+static bool ixgbe_check_cfg_remove(struct ixgbe_hw *hw, struct pci_dev *pdev);
+
 static int ixgbe_read_pci_cfg_word_parent(struct ixgbe_adapter *adapter,
                                          u32 reg, u16 *value)
 {
@@ -169,6 +171,9 @@ static int ixgbe_read_pci_cfg_word_parent(struct ixgbe_adapter *adapter,
                return -1;
 
        pcie_capability_read_word(parent_dev, reg, value);
+       if (*value == IXGBE_FAILED_READ_CFG_WORD &&
+           ixgbe_check_cfg_remove(&adapter->hw, parent_dev))
+               return -1;
        return 0;
 }
 
@@ -313,6 +318,48 @@ void ixgbe_check_remove(struct ixgbe_hw *hw, u32 reg)
                ixgbe_remove_adapter(hw);
 }
 
+static bool ixgbe_check_cfg_remove(struct ixgbe_hw *hw, struct pci_dev *pdev)
+{
+       u16 value;
+
+       pci_read_config_word(pdev, PCI_VENDOR_ID, &value);
+       if (value == IXGBE_FAILED_READ_CFG_WORD) {
+               ixgbe_remove_adapter(hw);
+               return true;
+       }
+       return false;
+}
+
+u16 ixgbe_read_pci_cfg_word(struct ixgbe_hw *hw, u32 reg)
+{
+       struct ixgbe_adapter *adapter = hw->back;
+       u16 value;
+
+       if (ixgbe_removed(hw->hw_addr))
+               return IXGBE_FAILED_READ_CFG_WORD;
+       pci_read_config_word(adapter->pdev, reg, &value);
+       if (value == IXGBE_FAILED_READ_CFG_WORD &&
+           ixgbe_check_cfg_remove(hw, adapter->pdev))
+               return IXGBE_FAILED_READ_CFG_WORD;
+       return value;
+}
+
+#ifdef CONFIG_PCI_IOV
+static u32 ixgbe_read_pci_cfg_dword(struct ixgbe_hw *hw, u32 reg)
+{
+       struct ixgbe_adapter *adapter = hw->back;
+       u32 value;
+
+       if (ixgbe_removed(hw->hw_addr))
+               return IXGBE_FAILED_READ_CFG_DWORD;
+       pci_read_config_dword(adapter->pdev, reg, &value);
+       if (value == IXGBE_FAILED_READ_CFG_DWORD &&
+           ixgbe_check_cfg_remove(hw, adapter->pdev))
+               return IXGBE_FAILED_READ_CFG_DWORD;
+       return value;
+}
+#endif /* CONFIG_PCI_IOV */
+
 static void ixgbe_service_event_complete(struct ixgbe_adapter *adapter)
 {
        BUG_ON(!test_bit(__IXGBE_SERVICE_SCHED, &adapter->state));
@@ -2630,9 +2677,12 @@ static irqreturn_t ixgbe_msix_other(int irq, void *data)
        switch (hw->mac.type) {
        case ixgbe_mac_82599EB:
        case ixgbe_mac_X540:
-               if (eicr & IXGBE_EICR_ECC)
-                       e_info(link, "Received unrecoverable ECC Err, please "
-                              "reboot\n");
+               if (eicr & IXGBE_EICR_ECC) {
+                       e_info(link, "Received ECC Err, initiating reset\n");
+                       adapter->flags2 |= IXGBE_FLAG2_RESET_REQUESTED;
+                       ixgbe_service_event_schedule(adapter);
+                       IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_ECC);
+               }
                /* Handle Flow Director Full threshold interrupt */
                if (eicr & IXGBE_EICR_FLOW_DIR) {
                        int reinit_count = 0;
@@ -2846,9 +2896,12 @@ static irqreturn_t ixgbe_intr(int irq, void *data)
                ixgbe_check_sfp_event(adapter, eicr);
                /* Fall through */
        case ixgbe_mac_X540:
-               if (eicr & IXGBE_EICR_ECC)
-                       e_info(link, "Received unrecoverable ECC err, please "
-                                    "reboot\n");
+               if (eicr & IXGBE_EICR_ECC) {
+                       e_info(link, "Received ECC Err, initiating reset\n");
+                       adapter->flags2 |= IXGBE_FLAG2_RESET_REQUESTED;
+                       ixgbe_service_event_schedule(adapter);
+                       IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_ECC);
+               }
                ixgbe_check_overtemp_event(adapter, eicr);
                break;
        default:
@@ -5502,6 +5555,7 @@ static int ixgbe_resume(struct pci_dev *pdev)
        struct net_device *netdev = adapter->netdev;
        u32 err;
 
+       adapter->hw.hw_addr = adapter->io_addr;
        pci_set_power_state(pdev, PCI_D0);
        pci_restore_state(pdev);
        /*
@@ -6881,7 +6935,7 @@ static inline int ixgbe_maybe_stop_tx(struct ixgbe_ring *tx_ring, u16 size)
 }
 
 static u16 ixgbe_select_queue(struct net_device *dev, struct sk_buff *skb,
-                             void *accel_priv)
+                             void *accel_priv, select_queue_fallback_t fallback)
 {
        struct ixgbe_fwd_adapter *fwd_adapter = accel_priv;
 #ifdef IXGBE_FCOE
@@ -6907,7 +6961,7 @@ static u16 ixgbe_select_queue(struct net_device *dev, struct sk_buff *skb,
                if (adapter->flags & IXGBE_FLAG_FCOE_ENABLED)
                        break;
        default:
-               return __netdev_pick_tx(dev, skb);
+               return fallback(dev, skb);
        }
 
        f = &adapter->ring_feature[RING_F_FCOE];
@@ -6920,7 +6974,7 @@ static u16 ixgbe_select_queue(struct net_device *dev, struct sk_buff *skb,
 
        return txq + f->offset;
 #else
-       return __netdev_pick_tx(dev, skb);
+       return fallback(dev, skb);
 #endif
 }
 
@@ -7792,6 +7846,7 @@ int ixgbe_wol_supported(struct ixgbe_adapter *adapter, u16 device_id,
        case IXGBE_DEV_ID_82599_SFP:
                /* Only these subdevices could supports WOL */
                switch (subdevice_id) {
+               case IXGBE_SUBDEV_ID_82599_SFP_WOL0:
                case IXGBE_SUBDEV_ID_82599_560FLR:
                        /* only support first port */
                        if (hw->bus.func != 0)
@@ -8331,6 +8386,7 @@ static pci_ers_result_t ixgbe_io_error_detected(struct pci_dev *pdev,
        struct net_device *netdev = adapter->netdev;
 
 #ifdef CONFIG_PCI_IOV
+       struct ixgbe_hw *hw = &adapter->hw;
        struct pci_dev *bdev, *vfdev;
        u32 dw0, dw1, dw2, dw3;
        int vf, pos;
@@ -8351,10 +8407,12 @@ static pci_ers_result_t ixgbe_io_error_detected(struct pci_dev *pdev,
        if (!pos)
                goto skip_bad_vf_detection;
 
-       pci_read_config_dword(bdev, pos + PCI_ERR_HEADER_LOG, &dw0);
-       pci_read_config_dword(bdev, pos + PCI_ERR_HEADER_LOG + 4, &dw1);
-       pci_read_config_dword(bdev, pos + PCI_ERR_HEADER_LOG + 8, &dw2);
-       pci_read_config_dword(bdev, pos + PCI_ERR_HEADER_LOG + 12, &dw3);
+       dw0 = ixgbe_read_pci_cfg_dword(hw, pos + PCI_ERR_HEADER_LOG);
+       dw1 = ixgbe_read_pci_cfg_dword(hw, pos + PCI_ERR_HEADER_LOG + 4);
+       dw2 = ixgbe_read_pci_cfg_dword(hw, pos + PCI_ERR_HEADER_LOG + 8);
+       dw3 = ixgbe_read_pci_cfg_dword(hw, pos + PCI_ERR_HEADER_LOG + 12);
+       if (ixgbe_removed(hw->hw_addr))
+               goto skip_bad_vf_detection;
 
        req_id = dw1 >> 16;
        /* On the 82599 if bit 7 of the requestor ID is set then it's a VF */
@@ -8446,6 +8504,7 @@ static pci_ers_result_t ixgbe_io_slot_reset(struct pci_dev *pdev)
                e_err(probe, "Cannot re-enable PCI device after reset.\n");
                result = PCI_ERS_RESULT_DISCONNECT;
        } else {
+               adapter->hw.hw_addr = adapter->io_addr;
                pci_set_master(pdev);
                pci_restore_state(pdev);
                pci_save_state(pdev);