Merge branch '100GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/net...
authorJakub Kicinski <kuba@kernel.org>
Thu, 14 Jul 2022 03:16:03 +0000 (20:16 -0700)
committerJakub Kicinski <kuba@kernel.org>
Thu, 14 Jul 2022 03:16:04 +0000 (20:16 -0700)
Tony Nguyen says:

====================
Intel Wired LAN Driver Updates 2022-07-12

This series contains updates to ice driver only.

Paul fixes detection of E822 devices for firmware update and changes NVM
read for snapshot creation to be done in chunks as some systems cannot
read the entire NVM in the allotted time.
====================

Link: https://lore.kernel.org/r/20220712164829.7275-1-anthony.l.nguyen@intel.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/intel/ice/ice_devids.h
drivers/net/ethernet/intel/ice/ice_devlink.c
drivers/net/ethernet/intel/ice/ice_fw_update.c
drivers/net/ethernet/intel/ice/ice_main.c

index 61dd2f1..b41bc3d 100644 (file)
@@ -5,6 +5,7 @@
 #define _ICE_DEVIDS_H_
 
 /* Device IDs */
+#define ICE_DEV_ID_E822_SI_DFLT         0x1888
 /* Intel(R) Ethernet Connection E823-L for backplane */
 #define ICE_DEV_ID_E823L_BACKPLANE     0x124C
 /* Intel(R) Ethernet Connection E823-L for SFP */
index 3991d62..3337314 100644 (file)
@@ -814,6 +814,8 @@ void ice_devlink_destroy_vf_port(struct ice_vf *vf)
        devlink_port_unregister(devlink_port);
 }
 
+#define ICE_DEVLINK_READ_BLK_SIZE (1024 * 1024)
+
 /**
  * ice_devlink_nvm_snapshot - Capture a snapshot of the NVM flash contents
  * @devlink: the devlink instance
@@ -840,8 +842,9 @@ static int ice_devlink_nvm_snapshot(struct devlink *devlink,
        struct ice_pf *pf = devlink_priv(devlink);
        struct device *dev = ice_pf_to_dev(pf);
        struct ice_hw *hw = &pf->hw;
-       void *nvm_data;
-       u32 nvm_size;
+       u8 *nvm_data, *tmp, i;
+       u32 nvm_size, left;
+       s8 num_blks;
        int status;
 
        nvm_size = hw->flash.flash_size;
@@ -849,26 +852,44 @@ static int ice_devlink_nvm_snapshot(struct devlink *devlink,
        if (!nvm_data)
                return -ENOMEM;
 
-       status = ice_acquire_nvm(hw, ICE_RES_READ);
-       if (status) {
-               dev_dbg(dev, "ice_acquire_nvm failed, err %d aq_err %d\n",
-                       status, hw->adminq.sq_last_status);
-               NL_SET_ERR_MSG_MOD(extack, "Failed to acquire NVM semaphore");
-               vfree(nvm_data);
-               return status;
-       }
 
-       status = ice_read_flat_nvm(hw, 0, &nvm_size, nvm_data, false);
-       if (status) {
-               dev_dbg(dev, "ice_read_flat_nvm failed after reading %u bytes, err %d aq_err %d\n",
-                       nvm_size, status, hw->adminq.sq_last_status);
-               NL_SET_ERR_MSG_MOD(extack, "Failed to read NVM contents");
+       num_blks = DIV_ROUND_UP(nvm_size, ICE_DEVLINK_READ_BLK_SIZE);
+       tmp = nvm_data;
+       left = nvm_size;
+
+       /* Some systems take longer to read the NVM than others which causes the
+        * FW to reclaim the NVM lock before the entire NVM has been read. Fix
+        * this by breaking the reads of the NVM into smaller chunks that will
+        * probably not take as long. This has some overhead since we are
+        * increasing the number of AQ commands, but it should always work
+        */
+       for (i = 0; i < num_blks; i++) {
+               u32 read_sz = min_t(u32, ICE_DEVLINK_READ_BLK_SIZE, left);
+
+               status = ice_acquire_nvm(hw, ICE_RES_READ);
+               if (status) {
+                       dev_dbg(dev, "ice_acquire_nvm failed, err %d aq_err %d\n",
+                               status, hw->adminq.sq_last_status);
+                       NL_SET_ERR_MSG_MOD(extack, "Failed to acquire NVM semaphore");
+                       vfree(nvm_data);
+                       return -EIO;
+               }
+
+               status = ice_read_flat_nvm(hw, i * ICE_DEVLINK_READ_BLK_SIZE,
+                                          &read_sz, tmp, false);
+               if (status) {
+                       dev_dbg(dev, "ice_read_flat_nvm failed after reading %u bytes, err %d aq_err %d\n",
+                               read_sz, status, hw->adminq.sq_last_status);
+                       NL_SET_ERR_MSG_MOD(extack, "Failed to read NVM contents");
+                       ice_release_nvm(hw);
+                       vfree(nvm_data);
+                       return -EIO;
+               }
                ice_release_nvm(hw);
-               vfree(nvm_data);
-               return status;
-       }
 
-       ice_release_nvm(hw);
+               tmp += read_sz;
+               left -= read_sz;
+       }
 
        *data = nvm_data;
 
index 665a344..3dc5662 100644 (file)
@@ -736,7 +736,87 @@ static int ice_finalize_update(struct pldmfw *context)
        return 0;
 }
 
-static const struct pldmfw_ops ice_fwu_ops = {
+struct ice_pldm_pci_record_id {
+       u32 vendor;
+       u32 device;
+       u32 subsystem_vendor;
+       u32 subsystem_device;
+};
+
+/**
+ * ice_op_pci_match_record - Check if a PCI device matches the record
+ * @context: PLDM fw update structure
+ * @record: list of records extracted from the PLDM image
+ *
+ * Determine if the PCI device associated with this device matches the record
+ * data provided.
+ *
+ * Searches the descriptor TLVs and extracts the relevant descriptor data into
+ * a pldm_pci_record_id. This is then compared against the PCI device ID
+ * information.
+ *
+ * Returns: true if the device matches the record, false otherwise.
+ */
+static bool
+ice_op_pci_match_record(struct pldmfw *context, struct pldmfw_record *record)
+{
+       struct pci_dev *pdev = to_pci_dev(context->dev);
+       struct ice_pldm_pci_record_id id = {
+               .vendor = PCI_ANY_ID,
+               .device = PCI_ANY_ID,
+               .subsystem_vendor = PCI_ANY_ID,
+               .subsystem_device = PCI_ANY_ID,
+       };
+       struct pldmfw_desc_tlv *desc;
+
+       list_for_each_entry(desc, &record->descs, entry) {
+               u16 value;
+               int *ptr;
+
+               switch (desc->type) {
+               case PLDM_DESC_ID_PCI_VENDOR_ID:
+                       ptr = &id.vendor;
+                       break;
+               case PLDM_DESC_ID_PCI_DEVICE_ID:
+                       ptr = &id.device;
+                       break;
+               case PLDM_DESC_ID_PCI_SUBVENDOR_ID:
+                       ptr = &id.subsystem_vendor;
+                       break;
+               case PLDM_DESC_ID_PCI_SUBDEV_ID:
+                       ptr = &id.subsystem_device;
+                       break;
+               default:
+                       /* Skip unrelated TLVs */
+                       continue;
+               }
+
+               value = get_unaligned_le16(desc->data);
+               /* A value of zero for one of the descriptors is sometimes
+                * used when the record should ignore this field when matching
+                * device. For example if the record applies to any subsystem
+                * device or vendor.
+                */
+               if (value)
+                       *ptr = value;
+               else
+                       *ptr = PCI_ANY_ID;
+       }
+
+       /* the E822 device can have a generic device ID so check for that */
+       if ((id.vendor == PCI_ANY_ID || id.vendor == pdev->vendor) &&
+           (id.device == PCI_ANY_ID || id.device == pdev->device ||
+           id.device == ICE_DEV_ID_E822_SI_DFLT) &&
+           (id.subsystem_vendor == PCI_ANY_ID ||
+           id.subsystem_vendor == pdev->subsystem_vendor) &&
+           (id.subsystem_device == PCI_ANY_ID ||
+           id.subsystem_device == pdev->subsystem_device))
+               return true;
+
+       return false;
+}
+
+static const struct pldmfw_ops ice_fwu_ops_e810 = {
        .match_record = &pldmfw_op_pci_match_record,
        .send_package_data = &ice_send_package_data,
        .send_component_table = &ice_send_component_table,
@@ -744,6 +824,14 @@ static const struct pldmfw_ops ice_fwu_ops = {
        .finalize_update = &ice_finalize_update,
 };
 
+static const struct pldmfw_ops ice_fwu_ops_e822 = {
+       .match_record = &ice_op_pci_match_record,
+       .send_package_data = &ice_send_package_data,
+       .send_component_table = &ice_send_component_table,
+       .flash_component = &ice_flash_component,
+       .finalize_update = &ice_finalize_update,
+};
+
 /**
  * ice_get_pending_updates - Check if the component has a pending update
  * @pf: the PF driver structure
@@ -921,7 +1009,11 @@ int ice_devlink_flash_update(struct devlink *devlink,
 
        memset(&priv, 0, sizeof(priv));
 
-       priv.context.ops = &ice_fwu_ops;
+       /* the E822 device needs a slightly different ops */
+       if (hw->mac_type == ICE_MAC_GENERIC)
+               priv.context.ops = &ice_fwu_ops_e822;
+       else
+               priv.context.ops = &ice_fwu_ops_e810;
        priv.context.dev = dev;
        priv.extack = extack;
        priv.pf = pf;
index c1ac2f7..ff2eac2 100644 (file)
@@ -5413,6 +5413,7 @@ static const struct pci_device_id ice_pci_tbl[] = {
        { PCI_VDEVICE(INTEL, ICE_DEV_ID_E823L_10G_BASE_T), 0 },
        { PCI_VDEVICE(INTEL, ICE_DEV_ID_E823L_1GBE), 0 },
        { PCI_VDEVICE(INTEL, ICE_DEV_ID_E823L_QSFP), 0 },
+       { PCI_VDEVICE(INTEL, ICE_DEV_ID_E822_SI_DFLT), 0 },
        /* required last entry */
        { 0, }
 };