indirection_rqt[i] = i % num_channels;
  }
  
- static int mlx5e_get_pci_bw(struct mlx5_core_dev *mdev, u32 *pci_bw)
- {
-       enum pcie_link_width width;
-       enum pci_bus_speed speed;
-       int err = 0;
- 
-       err = pcie_get_minimum_link(mdev->pdev, &speed, &width);
-       if (err)
-               return err;
- 
-       if (speed == PCI_SPEED_UNKNOWN || width == PCIE_LNK_WIDTH_UNKNOWN)
-               return -EINVAL;
- 
-       switch (speed) {
-       case PCIE_SPEED_2_5GT:
-               *pci_bw = 2500 * width;
-               break;
-       case PCIE_SPEED_5_0GT:
-               *pci_bw = 5000 * width;
-               break;
-       case PCIE_SPEED_8_0GT:
-               *pci_bw = 8000 * width;
-               break;
-       default:
-               return -EINVAL;
-       }
- 
-       return 0;
- }
- 
 -static bool cqe_compress_heuristic(u32 link_speed, u32 pci_bw)
 +static bool slow_pci_heuristic(struct mlx5_core_dev *mdev)
  {
 -      return (link_speed && pci_bw &&
 -              (pci_bw < 40000) && (pci_bw < link_speed));
 -}
 +      u32 link_speed = 0;
 +      u32 pci_bw = 0;
  
 -static bool hw_lro_heuristic(u32 link_speed, u32 pci_bw)
 -{
 -      return !(link_speed && pci_bw &&
 -               (pci_bw <= 16000) && (pci_bw < link_speed));
 +      mlx5e_get_max_linkspeed(mdev, &link_speed);
-       mlx5e_get_pci_bw(mdev, &pci_bw);
++      pci_bw = pcie_bandwidth_available(mdev->pdev, NULL, NULL, NULL);
 +      mlx5_core_dbg_once(mdev, "Max link speed = %d, PCI BW = %d\n",
 +                         link_speed, pci_bw);
 +
 +#define MLX5E_SLOW_PCI_RATIO (2)
 +
 +      return link_speed && pci_bw &&
 +              link_speed > MLX5E_SLOW_PCI_RATIO * pci_bw;
  }
  
  void mlx5e_set_tx_cq_mode_params(struct mlx5e_params *params, u8 cq_period_mode)
 
        return -ENOENT;
  }
  EXPORT_SYMBOL_GPL(pci_vpd_find_info_keyword);
 -      pci_set_vpd_size(dev, 8192);
+ 
+ #ifdef CONFIG_PCI_QUIRKS
+ /*
+  * Quirk non-zero PCI functions to route VPD access through function 0 for
+  * devices that share VPD resources between functions.  The functions are
+  * expected to be identical devices.
+  */
+ static void quirk_f0_vpd_link(struct pci_dev *dev)
+ {
+       struct pci_dev *f0;
+ 
+       if (!PCI_FUNC(dev->devfn))
+               return;
+ 
+       f0 = pci_get_slot(dev->bus, PCI_DEVFN(PCI_SLOT(dev->devfn), 0));
+       if (!f0)
+               return;
+ 
+       if (f0->vpd && dev->class == f0->class &&
+           dev->vendor == f0->vendor && dev->device == f0->device)
+               dev->dev_flags |= PCI_DEV_FLAGS_VPD_REF_F0;
+ 
+       pci_dev_put(f0);
+ }
+ DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, PCI_ANY_ID,
+                             PCI_CLASS_NETWORK_ETHERNET, 8, quirk_f0_vpd_link);
+ 
+ /*
+  * If a device follows the VPD format spec, the PCI core will not read or
+  * write past the VPD End Tag.  But some vendors do not follow the VPD
+  * format spec, so we can't tell how much data is safe to access.  Devices
+  * may behave unpredictably if we access too much.  Blacklist these devices
+  * so we don't touch VPD at all.
+  */
+ static void quirk_blacklist_vpd(struct pci_dev *dev)
+ {
+       if (dev->vpd) {
+               dev->vpd->len = 0;
+               pci_warn(dev, FW_BUG "disabling VPD access (can't determine size of non-standard VPD format)\n");
+       }
+ }
+ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LSI_LOGIC, 0x0060, quirk_blacklist_vpd);
+ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LSI_LOGIC, 0x007c, quirk_blacklist_vpd);
+ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LSI_LOGIC, 0x0413, quirk_blacklist_vpd);
+ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LSI_LOGIC, 0x0078, quirk_blacklist_vpd);
+ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LSI_LOGIC, 0x0079, quirk_blacklist_vpd);
+ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LSI_LOGIC, 0x0073, quirk_blacklist_vpd);
+ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LSI_LOGIC, 0x0071, quirk_blacklist_vpd);
+ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LSI_LOGIC, 0x005b, quirk_blacklist_vpd);
+ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LSI_LOGIC, 0x002f, quirk_blacklist_vpd);
+ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LSI_LOGIC, 0x005d, quirk_blacklist_vpd);
+ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LSI_LOGIC, 0x005f, quirk_blacklist_vpd);
+ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATTANSIC, PCI_ANY_ID,
+               quirk_blacklist_vpd);
+ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_QLOGIC, 0x2261, quirk_blacklist_vpd);
+ 
+ /*
+  * For Broadcom 5706, 5708, 5709 rev. A nics, any read beyond the
+  * VPD end tag will hang the device.  This problem was initially
+  * observed when a vpd entry was created in sysfs
+  * ('/sys/bus/pci/devices/<id>/vpd').   A read to this sysfs entry
+  * will dump 32k of data.  Reading a full 32k will cause an access
+  * beyond the VPD end tag causing the device to hang.  Once the device
+  * is hung, the bnx2 driver will not be able to reset the device.
+  * We believe that it is legal to read beyond the end tag and
+  * therefore the solution is to limit the read/write length.
+  */
+ static void quirk_brcm_570x_limit_vpd(struct pci_dev *dev)
+ {
+       /*
+        * Only disable the VPD capability for 5706, 5706S, 5708,
+        * 5708S and 5709 rev. A
+        */
+       if ((dev->device == PCI_DEVICE_ID_NX2_5706) ||
+           (dev->device == PCI_DEVICE_ID_NX2_5706S) ||
+           (dev->device == PCI_DEVICE_ID_NX2_5708) ||
+           (dev->device == PCI_DEVICE_ID_NX2_5708S) ||
+           ((dev->device == PCI_DEVICE_ID_NX2_5709) &&
+            (dev->revision & 0xf0) == 0x0)) {
+               if (dev->vpd)
+                       dev->vpd->len = 0x80;
+       }
+ }
+ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_BROADCOM,
+                       PCI_DEVICE_ID_NX2_5706,
+                       quirk_brcm_570x_limit_vpd);
+ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_BROADCOM,
+                       PCI_DEVICE_ID_NX2_5706S,
+                       quirk_brcm_570x_limit_vpd);
+ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_BROADCOM,
+                       PCI_DEVICE_ID_NX2_5708,
+                       quirk_brcm_570x_limit_vpd);
+ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_BROADCOM,
+                       PCI_DEVICE_ID_NX2_5708S,
+                       quirk_brcm_570x_limit_vpd);
+ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_BROADCOM,
+                       PCI_DEVICE_ID_NX2_5709,
+                       quirk_brcm_570x_limit_vpd);
+ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_BROADCOM,
+                       PCI_DEVICE_ID_NX2_5709S,
+                       quirk_brcm_570x_limit_vpd);
+ 
+ static void quirk_chelsio_extend_vpd(struct pci_dev *dev)
+ {
 -DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x20, quirk_chelsio_extend_vpd);
 -DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x21, quirk_chelsio_extend_vpd);
 -DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x22, quirk_chelsio_extend_vpd);
 -DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x23, quirk_chelsio_extend_vpd);
 -DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x24, quirk_chelsio_extend_vpd);
 -DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x25, quirk_chelsio_extend_vpd);
 -DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x26, quirk_chelsio_extend_vpd);
 -DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x30, quirk_chelsio_extend_vpd);
 -DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x31, quirk_chelsio_extend_vpd);
 -DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x32, quirk_chelsio_extend_vpd);
 -DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x35, quirk_chelsio_extend_vpd);
 -DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x36, quirk_chelsio_extend_vpd);
 -DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x37, quirk_chelsio_extend_vpd);
++      int chip = (dev->device & 0xf000) >> 12;
++      int func = (dev->device & 0x0f00) >>  8;
++      int prod = (dev->device & 0x00ff) >>  0;
++
++      /*
++       * If this is a T3-based adapter, there's a 1KB VPD area at offset
++       * 0xc00 which contains the preferred VPD values.  If this is a T4 or
++       * later based adapter, the special VPD is at offset 0x400 for the
++       * Physical Functions (the SR-IOV Virtual Functions have no VPD
++       * Capabilities).  The PCI VPD Access core routines will normally
++       * compute the size of the VPD by parsing the VPD Data Structure at
++       * offset 0x000.  This will result in silent failures when attempting
++       * to accesses these other VPD areas which are beyond those computed
++       * limits.
++       */
++      if (chip == 0x0 && prod >= 0x20)
++              pci_set_vpd_size(dev, 8192);
++      else if (chip >= 0x4 && func < 0x8)
++              pci_set_vpd_size(dev, 2048);
+ }
++
++DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, PCI_ANY_ID,
++                      quirk_chelsio_extend_vpd);
++
+ #endif