Skip to contentSkip to conversation

ice: miscellaneous firmware features

PATCH Superseded Jacob Keller 2 participants 8 messages Sep 8, 2021 – Sep 30, 2021

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover ice: miscellaneous firmware features

This series contains a few miscellaneous left over pieces of work related to flash update that I've been meaning to submit for a while.

This includes the following:

* a new shadow-ram region similar to NVM region but for the device shadow RAM contents. This is distinct from NVM region because shadow RAM is built up during device init and may be different from the raw NVM flash data. (As I found out while debugging some issues with flash update).
* refactoring of the ice_flash_pldm_image to become the main flash update entry point. This is simpler than having both a ice_devlink_flash_update and an ice_flash_pldm_image. It will make additions like dry-run easier in the future
* support for firmware activation via devlink reload, when possible.

The major new work is the reload support, which allows activating firmware immediately without a reboot when possible.

As a note, I want to call out that the reload support here only supports firmware activation. I really did try to see what it would take to get proper driver reload support working. Unfortunately this task requires a large amount of rewrite to the entire flow that the driver uses for both probe/remove, as well as driver reset.

Jacob Keller (4):
ice: devlink: add shadow-ram region to snapshot Shadow RAM
ice: move and rename ice_check_for_pending_update
ice: refactor ice_flash_pldm_image and combine with
ice_devlink_flash_update
ice: support immediate firmware activation via devlink reload

 drivers/net/ethernet/intel/ice/ice.h          |   9 +
 .../net/ethernet/intel/ice/ice_adminq_cmd.h   |   7 +
 drivers/net/ethernet/intel/ice/ice_common.c   |  12 +
 drivers/net/ethernet/intel/ice/ice_devlink.c  | 218 ++++++++++---
 .../net/ethernet/intel/ice/ice_fw_update.c    | 291 ++++++++++++------
 .../net/ethernet/intel/ice/ice_fw_update.h    |   9 +-
 drivers/net/ethernet/intel/ice/ice_type.h     |   4 +
 7 files changed, 412 insertions(+), 138 deletions(-)

base-commit: 8945c4bc5e8e03b2358974e602dcf8137b448ed9

Signature · 1 line
2.31.1.331.gb0c09ab8796f
#1 lore raw

PATCH 1/4 ice: devlink: add shadow-ram region to snapshot Shadow RAM

We have a region for reading the contents of the NVM flash as a snapshot. This region does not allow reading the Shadow RAM, as it always passes the FLASH_ONLY bit to the low level firmware interface.

Add a separate shadow-ram region which will allow snapshot of the current contents of the Shadow RAM. This data is built from the NVM contents but is distinct as the device builds up the Shadow RAM during initialization, so being able to snapshot its contents can be useful when attempting to debug flash related issues.

Fix the comment description of the nvm-flash region which incorrectly stated that it filled the shadow-ram region, and add a comment explaining that the nvm-flash region does not actually read the Shadow RAM.

---
 drivers/net/ethernet/intel/ice/ice.h         |  1 +
 drivers/net/ethernet/intel/ice/ice_devlink.c | 93 ++++++++++++++++++--
 2 files changed, 89 insertions(+), 5 deletions(-)
drivers/net/ethernet/intel/ice/ice.h +1 -0
index 62d00c82cf2d..4be0828b4972 100644
@@ -436,6 +436,7 @@ struct ice_pf {
 	struct pci_dev *pdev;
 
 	struct devlink_region *nvm_region;
+	struct devlink_region *sram_region;
 	struct devlink_region *devcaps_region;
 
 	/* devlink port data */
drivers/net/ethernet/intel/ice/ice_devlink.c +88 -5

135 lines not on this page · raw message

Signature · 1 line
2.31.1.331.gb0c09ab8796f
#2 lore raw

PATCH 1/4 ice: devlink: add shadow-ram region to snapshot Shadow RAM

Quoted 24 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jacob Keller
Sent: Thursday, September 9, 2021 5:19 AM
To: Intel Wired LAN <[email protected]>
Subject: [Intel-wired-lan] [net-next 1/4] ice: devlink: add shadow-ram region to snapshot Shadow RAM

We have a region for reading the contents of the NVM flash as a snapshot. This region does not allow reading the Shadow RAM, as it always passes the FLASH_ONLY bit to the low level firmware interface.

Add a separate shadow-ram region which will allow snapshot of the current contents of the Shadow RAM. This data is built from the NVM contents but is distinct as the device builds up the Shadow RAM during initialization, so being able to snapshot its contents can be useful when attempting to debug flash related issues.

Fix the comment description of the nvm-flash region which incorrectly stated that it filled the shadow-ram region, and add a comment explaining that the nvm-flash region does not actually read the Shadow RAM.

Quoted 6 lines
---
 drivers/net/ethernet/intel/ice/ice.h         |  1 +
 drivers/net/ethernet/intel/ice/ice_devlink.c | 93 ++++++++++++++++++--
 2 files changed, 89 insertions(+), 5 deletions(-)
#3 lore raw

PATCH 2/4 ice: move and rename ice_check_for_pending_update

In reply to Jacob Keller

The ice_devlink_flash_update function performs a few checks and then calls ice_flash_pldm_image. One of these checks is to call ice_check_for_pending_update. This function checks if the device has a pending update, and cancels it if so. This is necessary to allow a new flash update to proceed.

We want to refactor the ice code to eliminate ice_devlink_flash_update, moving its checks into ice_flash_pldm_image.

To do this, ice_check_for_pending_update will become static, and only called by ice_flash_pldm_image. To make this change easier to review, first just move the function up within the ice_fw_update.c file.

While at it, note that the function has a misleading name. Its primary action is to cancel a pending update. Using the verb "check" does not imply this. Rename it to ice_cancel_pending_update.

---
 drivers/net/ethernet/intel/ice/ice_devlink.c  |   2 +-
 .../net/ethernet/intel/ice/ice_fw_update.c    | 152 +++++++++---------
 .../net/ethernet/intel/ice/ice_fw_update.h    |   4 +-
 3 files changed, 79 insertions(+), 79 deletions(-)
drivers/net/ethernet/intel/ice/ice_devlink.c +1 -1
index 66a11ec941a3..dbf54fb5c9ee 100644
@@ -413,7 +413,7 @@ ice_devlink_flash_update(struct devlink *devlink,
 		return -EOPNOTSUPP;
 	}
 
-	err = ice_check_for_pending_update(pf, NULL, extack);
+	err = ice_cancel_pending_update(pf, NULL, extack);
 	if (err)
 		return err;
 
drivers/net/ethernet/intel/ice/ice_fw_update.c +76 -76

168 lines not on this page · raw message

drivers/net/ethernet/intel/ice/ice_fw_update.h +2 -2
index c6390f6851ff..1f84ef18bfd1 100644
@@ -6,7 +6,7 @@
 
 int ice_flash_pldm_image(struct ice_pf *pf, const struct firmware *fw,
 			 u8 preservation, struct netlink_ext_ack *extack);
-int ice_check_for_pending_update(struct ice_pf *pf, const char *component,
-				 struct netlink_ext_ack *extack);
+int ice_cancel_pending_update(struct ice_pf *pf, const char *component,
+			      struct netlink_ext_ack *extack);
 
 #endif
Signature · 1 line
2.31.1.331.gb0c09ab8796f
#4 lore raw

PATCH 2/4 ice: move and rename ice_check_for_pending_update

Quoted 27 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jacob Keller
Sent: Thursday, September 9, 2021 5:19 AM
To: Intel Wired LAN <[email protected]>
Subject: [Intel-wired-lan] [net-next 2/4] ice: move and rename ice_check_for_pending_update

The ice_devlink_flash_update function performs a few checks and then calls ice_flash_pldm_image. One of these checks is to call ice_check_for_pending_update. This function checks if the device has a pending update, and cancels it if so. This is necessary to allow a new flash update to proceed.

We want to refactor the ice code to eliminate ice_devlink_flash_update, moving its checks into ice_flash_pldm_image.

To do this, ice_check_for_pending_update will become static, and only called by ice_flash_pldm_image. To make this change easier to review, first just move the function up within the ice_fw_update.c file.

While at it, note that the function has a misleading name. Its primary action is to cancel a pending update. Using the verb "check" does not imply this. Rename it to ice_cancel_pending_update.

Quoted 7 lines
---
 drivers/net/ethernet/intel/ice/ice_devlink.c  |   2 +-
 .../net/ethernet/intel/ice/ice_fw_update.c    | 152 +++++++++---------
 .../net/ethernet/intel/ice/ice_fw_update.h    |   4 +-
 3 files changed, 79 insertions(+), 79 deletions(-)
#5 lore raw

PATCH 3/4 ice: refactor ice_flash_pldm_image and combine with ice_devlink_flash_update

In reply to Jacob Keller

The ice_devlink_flash_update function performs a few upfront checks and then calls ice_flash_pldm_image.

Most of these checks actually make more sense within the context of ice_flash_pldm_image. Refactor this function to fit the argument format of the .flash_update devlink handler, and merge the checks from ice_devlink_flash_update.

Note that the check for overwrite mask was converted to a switch because it made the check easier to read by avoiding the massively long line or weird line breaks that were hard for my eyes to follow.

When moving the ice_cancel_pending_update function, notice that it also takes the NVM semaphore. The main flash update process also requires the NVM hardware semaphore. We can eliminate the call to get the semaphore from ice_cancel_pending_update by placing the check after we acquire the semaphore during ice_flash_pldm_image.

With this change, the ice_flash_pldm_image becomes the main entry point for the devlink flash update, eliminating some unnecessary boiler plate code. This also eases supporting a dry run with the PLDM library in a future change.

---
 drivers/net/ethernet/intel/ice/ice_devlink.c  | 52 +-------------
 .../net/ethernet/intel/ice/ice_fw_update.c    | 70 +++++++++++--------
 .../net/ethernet/intel/ice/ice_fw_update.h    |  7 +-
 3 files changed, 45 insertions(+), 84 deletions(-)
drivers/net/ethernet/intel/ice/ice_devlink.c +1 -51
index dbf54fb5c9ee..40d1d113c1ad 100644
@@ -372,62 +372,12 @@ static int ice_devlink_info_get(struct devlink *devlink,
 	return err;
 }
 
-/**
- * ice_devlink_flash_update - Update firmware stored in flash on the device
- * @devlink: pointer to devlink associated with device to update
- * @params: flash update parameters
- * @extack: netlink extended ACK structure
- *
- * Perform a device flash update. The bulk of the update logic is contained
- * within the ice_flash_pldm_image function.
- *
- * Returns: zero on success, or an error code on failure.
- */
-static int
-ice_devlink_flash_update(struct devlink *devlink,
-			 struct devlink_flash_update_params *params,
-			 struct netlink_ext_ack *extack)
-{
-	struct ice_pf *pf = devlink_priv(devlink);
-	struct ice_hw *hw = &pf->hw;
-	u8 preservation;
-	int err;
-
-	if (!params->overwrite_mask) {
-		/* preserve all settings and identifiers */
-		preservation = ICE_AQC_NVM_PRESERVE_ALL;
-	} else if (params->overwrite_mask == DEVLINK_FLASH_OVERWRITE_SETTINGS) {
-		/* overwrite settings, but preserve the vital device identifiers */
-		preservation = ICE_AQC_NVM_PRESERVE_SELECTED;
-	} else if (params->overwrite_mask == (DEVLINK_FLASH_OVERWRITE_SETTINGS |
-					      DEVLINK_FLASH_OVERWRITE_IDENTIFIERS)) {
-		/* overwrite both settings and identifiers, preserve nothing */
-		preservation = ICE_AQC_NVM_NO_PRESERVATION;
-	} else {
-		NL_SET_ERR_MSG_MOD(extack, "Requested overwrite mask is not supported");
-		return -EOPNOTSUPP;
-	}
-
-	if (!hw->dev_caps.common_cap.nvm_unified_update) {
-		NL_SET_ERR_MSG_MOD(extack, "Current firmware does not support unified update");
-		return -EOPNOTSUPP;
-	}
-
-	err = ice_cancel_pending_update(pf, NULL, extack);
-	if (err)
-		return err;
-
-	devlink_flash_update_status_notify(devlink, "Preparing to flash", NULL, 0, 0);
-
-	return ice_flash_pldm_image(pf, params->fw, preservation, extack);
-}
-
 static const struct devlink_ops ice_devlink_ops = {
 	.supported_flash_update_params = DEVLINK_SUPPORT_FLASH_UPDATE_OVERWRITE_MASK,
 	.eswitch_mode_get = ice_eswitch_mode_get,
 	.eswitch_mode_set = ice_eswitch_mode_set,
 	.info_get = ice_devlink_info_get,
-	.flash_update = ice_devlink_flash_update,
+	.flash_update = ice_flash_pldm_image,
 };
 
 static void ice_devlink_free(void *devlink_ptr)
drivers/net/ethernet/intel/ice/ice_fw_update.c +41 -29

120 lines not on this page · raw message

drivers/net/ethernet/intel/ice/ice_fw_update.h +3 -4
index 1f84ef18bfd1..d12e81a00f11 100644
@@ -4,9 +4,8 @@
 #ifndef _ICE_FW_UPDATE_H_
 #define _ICE_FW_UPDATE_H_
 
-int ice_flash_pldm_image(struct ice_pf *pf, const struct firmware *fw,
-			 u8 preservation, struct netlink_ext_ack *extack);
-int ice_cancel_pending_update(struct ice_pf *pf, const char *component,
-			      struct netlink_ext_ack *extack);
+int ice_flash_pldm_image(struct devlink *devlink,
+			 struct devlink_flash_update_params *params,
+			 struct netlink_ext_ack *extack);
 
 #endif
Signature · 1 line
2.31.1.331.gb0c09ab8796f
#6 lore raw

PATCH 3/4 ice: refactor ice_flash_pldm_image and combine with ice_devlink_flash_update

Quoted 32 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jacob Keller
Sent: Thursday, September 9, 2021 5:19 AM
To: Intel Wired LAN <[email protected]>
Subject: [Intel-wired-lan] [net-next 3/4] ice: refactor ice_flash_pldm_image and combine with ice_devlink_flash_update

The ice_devlink_flash_update function performs a few upfront checks and then calls ice_flash_pldm_image.

Most of these checks actually make more sense within the context of ice_flash_pldm_image. Refactor this function to fit the argument format of the .flash_update devlink handler, and merge the checks from ice_devlink_flash_update.

Note that the check for overwrite mask was converted to a switch because it made the check easier to read by avoiding the massively long line or weird line breaks that were hard for my eyes to follow.

When moving the ice_cancel_pending_update function, notice that it also takes the NVM semaphore. The main flash update process also requires the NVM hardware semaphore. We can eliminate the call to get the semaphore from ice_cancel_pending_update by placing the check after we acquire the semaphore during ice_flash_pldm_image.

With this change, the ice_flash_pldm_image becomes the main entry point for the devlink flash update, eliminating some unnecessary boiler plate code. This also eases supporting a dry run with the PLDM library in a future change.

Quoted 7 lines
---
 drivers/net/ethernet/intel/ice/ice_devlink.c  | 52 +-------------
 .../net/ethernet/intel/ice/ice_fw_update.c    | 70 +++++++++++--------
 .../net/ethernet/intel/ice/ice_fw_update.h    |  7 +-
 3 files changed, 45 insertions(+), 84 deletions(-)
#7 lore raw

PATCH 4/4 ice: support immediate firmware activation via devlink reload

In reply to Jacob Keller

In order to complete a device flash update for the ice device, the system administrator currently must perform a system reboot. This is not ideal, as rebooting the entire system can cause unwanted downtime.

In many cases, it is possible to update the device firmware immediately using what is known as an EMP reset. This can be used to complete a device firmware update without the undesired effects caused by a full platform reboot.

We can implement support for this in userspace using the devlink reload command. Implement this command for the ice driver so that a devlink reload with the FW_ACTIVATE reload action. This enables the administrator to request a firmware activation after performing a flash update.

Unfortunately, it is not always possible to complete an update with a simple EMP reset. In some cases, the update cannot be completed without performing either a full power on or a cold PCIe reset. In these cases a system reboot is the only known way to complete the update.

When actually writing the flash device, newer versions of firmware can inform the driver about whether an EMP reset is sufficient. It does this using two mechanisms, which are detected via firmware capability bits.

The first is known as PCIe reset avoidance, and the second is known as indication of reset restriction.

If the firmware supports these capabilities, it will be able to indicate to the driver when an EMP reset is sufficient to complete an update.

The minimum required reset level is provided as part of the response to the final NVM module block write. This reset level indicates what reset is required in order to properly initialize the firmware given the contents that were updated in the NVM.

The availability of EMP reset is indicated as part of the response to asking firmware to switch flash backs for the next load.

Track these responses in the private structure when performing a flash update. After finalizing the update, determine the required reset by checking the two responses. If both the minimum required reset is an EMP reset and the EMP reset is available, we will be able to reload immediately.

Use these values within the devlink reload implementation. First, check if there even is a pending flash update. Then, check the required reset level. In the event that we know an EMP reset is not sufficient, issue an appropriate extended ACK message to inform the user.

Otherwise, attempt to issue an EMP reset. This will cause the standard driver reset handling to run, so the reload up implementation simply uses the wait_for_reset function to wait until the driver reset has completed.

In some cases, such as older firmware versions, the driver may not be able to determine whether an EMP reset is sufficient or not. In this case, we will always attempt the EMP reset as it may be sufficient.

Finally, this change does *not* implement basic driver-only reload support. I did look into trying to do this. However, it requires significant refactor of how the ice driver probes and loads everything. The ice driver probe and allocation flows were not designed with such a reload in mind.

---
 drivers/net/ethernet/intel/ice/ice.h          |   8 +
 .../net/ethernet/intel/ice/ice_adminq_cmd.h   |   7 +
 drivers/net/ethernet/intel/ice/ice_common.c   |  12 ++
 drivers/net/ethernet/intel/ice/ice_devlink.c  | 105 ++++++++++++++
 .../net/ethernet/intel/ice/ice_fw_update.c    | 137 +++++++++++++++---
 .../net/ethernet/intel/ice/ice_fw_update.h    |   2 +
 drivers/net/ethernet/intel/ice/ice_type.h     |   4 +
 7 files changed, 252 insertions(+), 23 deletions(-)
drivers/net/ethernet/intel/ice/ice.h +8 -0
index 4be0828b4972..62e93f9b11de 100644
@@ -432,6 +432,13 @@ struct ice_agg_node {
 	u8 valid;
 };
 
+enum ice_fw_activate {
+	ICE_FW_ACTIVATE_UNKNOWN = 0, /* Unknown activation requirement */
+	ICE_FW_ACTIVATE_ON_POR, /* Activate by power on */
+	ICE_FW_ACTIVATE_ON_PCIR, /* Activate by PCI reset */
+	ICE_FW_ACTIVATE_ON_EMPR, /* Activate by EMP reset */
+};
+
 struct ice_pf {
 	struct pci_dev *pdev;
 
@@ -486,6 +493,7 @@ struct ice_pf {
 	spinlock_t aq_wait_lock;
 	struct hlist_head aq_wait_list;
 	wait_queue_head_t aq_wait_queue;
+	enum ice_fw_activate fw_reset_req;
 
 	wait_queue_head_t reset_wait_queue;
 
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +7 -0
index b1072a47e1b5..0f64fbc9d3e8 100644
@@ -117,6 +117,8 @@ struct ice_aqc_list_caps_elem {
 #define ICE_AQC_CAPS_NET_VER				0x004C
 #define ICE_AQC_CAPS_PENDING_NET_VER			0x004D
 #define ICE_AQC_CAPS_RDMA				0x0051
+#define ICE_AQC_CAPS_PCIE_RESET_AVOIDANCE		0x0076
+#define ICE_AQC_CAPS_POST_UPDATE_RESET_RESTRICT		0x0077
 #define ICE_AQC_CAPS_NVM_MGMT				0x0080
 
 	u8 major_ver;
@@ -1410,6 +1412,11 @@ struct ice_aqc_nvm {
 #define ICE_AQC_NVM_REVERT_LAST_ACTIV	BIT(6) /* Write Activate only */
 #define ICE_AQC_NVM_ACTIV_SEL_MASK	ICE_M(0x7, 3)
 #define ICE_AQC_NVM_FLASH_ONLY		BIT(7)
+#define ICE_AQC_NVM_RESET_LVL_M		ICE_M(0x3, 0) /* Write reply only */
+#define ICE_AQC_NVM_POR_FLAG		0
+#define ICE_AQC_NVM_PERST_FLAG		1
+#define ICE_AQC_NVM_EMPR_FLAG		2
+#define ICE_AQC_NVM_EMPR_ENA		BIT(0) /* Write Activate reply only */
 	__le16 module_typeid;
 	__le16 length;
 #define ICE_AQC_NVM_ERASE_LEN	0xFFFF
drivers/net/ethernet/intel/ice/ice_common.c +12 -0
index aee4bbd55e4f..93df36ccde51 100644
@@ -2069,6 +2069,18 @@ ice_parse_common_caps(struct ice_hw *hw, struct ice_hw_common_caps *caps,
 		ice_debug(hw, ICE_DBG_INIT, "%s: max_mtu = %d\n",
 			  prefix, caps->max_mtu);
 		break;
+	case ICE_AQC_CAPS_PCIE_RESET_AVOIDANCE:
+		caps->pcie_reset_avoidance = (number > 0);
+		ice_debug(hw, ICE_DBG_INIT,
+			  "%s: pcie_reset_avoidance = %d\n", prefix,
+			  caps->pcie_reset_avoidance);
+		break;
+	case ICE_AQC_CAPS_POST_UPDATE_RESET_RESTRICT:
+		caps->reset_restrict_support = (number == 1);
+		ice_debug(hw, ICE_DBG_INIT,
+			  "%s: reset_restrict_support = %d\n", prefix,
+			  caps->reset_restrict_support);
+		break;
 	default:
 		/* Not one of the recognized common capabilities */
 		found = false;
drivers/net/ethernet/intel/ice/ice_devlink.c +105 -0

125 lines not on this page · raw message

drivers/net/ethernet/intel/ice/ice_fw_update.c +114 -23

274 lines not on this page · raw message

drivers/net/ethernet/intel/ice/ice_fw_update.h +2 -0
index d12e81a00f11..52e5e085bb5c 100644
@@ -7,5 +7,7 @@
 int ice_flash_pldm_image(struct devlink *devlink,
 			 struct devlink_flash_update_params *params,
 			 struct netlink_ext_ack *extack);
+int ice_get_pending_updates(struct ice_pf *pf, u8 *pending,
+			    struct netlink_ext_ack *extack);
 
 #endif
drivers/net/ethernet/intel/ice/ice_type.h +4 -0
index 4249dec389bf..4a3187c3abff 100644
@@ -278,6 +278,10 @@ struct ice_hw_common_caps {
 #define ICE_NVM_PENDING_NETLIST			BIT(2)
 	bool nvm_unified_update;
 #define ICE_NVM_MGMT_UNIFIED_UPD_SUPPORT	BIT(3)
+	/* PCIe reset avoidance */
+	bool pcie_reset_avoidance; /* false: not supported, true: supported */
+	/* Post update reset restriction */
+	bool reset_restrict_support; /* false: not supported, true: supported */
 };
 
 /* IEEE 1588 TIME_SYNC specific info */
Signature · 1 line
2.31.1.331.gb0c09ab8796f