Skip to contentSkip to conversation

ice: support immediate firmware activation via devlink reload

PATCH Superseded Jacob Keller 2 participants 2 messages Oct 19, 2021 – Oct 26, 2021 3 messages not in the archive

Subsystems (2)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 ice: support immediate firmware activation via devlink reload

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 synchronous 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, add a status notification to inform the user of the required reset needed to switch the running firmware.

Also track whether or not the EMP reset is available for use during reload. If firmware reported that it is available, an EMP reset can be requested using the appropriate firmware command.

Add support for devlink reload, and allow the user to request a reload to the new firmware using the FW_ACTIVIATE flag. If an EMP reset is available from firmware, we will attempt to load the newly activated firmware.

In some cases, such as older firmware versions which do not check or report whether EMP reset is suitable, the driver may not be able to determine when an EMP reset is available. In this case, whether an EMP reset is sufficient or not. In this case, we will always attempt the EMP reset.

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.

---

Changes since v3
* correctly read response of NVM write activate from synchronous reply value instead of from the ARQ event. This fixes a bug where we never reported that EMP reset is available.

Changes since v2
* ensure DEVLINK_F_RELOAD gets set
* rebase to avoid conflicts

 drivers/net/ethernet/intel/ice/ice.h          |   1 +
 .../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  |  91 ++++++++++
 .../net/ethernet/intel/ice/ice_fw_update.c    | 168 +++++++++++++++---
 .../net/ethernet/intel/ice/ice_fw_update.h    |   2 +
 drivers/net/ethernet/intel/ice/ice_nvm.c      |  19 +-
 drivers/net/ethernet/intel/ice/ice_nvm.h      |   2 +-
 drivers/net/ethernet/intel/ice/ice_type.h     |   4 +
 9 files changed, 279 insertions(+), 27 deletions(-)
drivers/net/ethernet/intel/ice/ice.h +1 -0
index ed85442551ca..0d4af0d84711 100644
@@ -551,6 +551,7 @@ struct ice_pf {
 	spinlock_t aq_wait_lock;
 	struct hlist_head aq_wait_list;
 	wait_queue_head_t aq_wait_queue;
+	bool fw_empr_disabled;
 
 	wait_queue_head_t reset_wait_queue;
 
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +7 -0
index a5425f0dce3f..88fc7aac915b 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;
@@ -1406,6 +1408,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 da9a3dbd13f6..f78b16be56a5 100644
@@ -2067,6 +2067,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 +91 -0

105 lines not on this page · raw message

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

316 lines not on this page · raw message

drivers/net/ethernet/intel/ice/ice_fw_update.h +2 -0
index be6d222124f2..750574885716 100644
@@ -7,5 +7,7 @@
 int ice_devlink_flash_update(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_nvm.c +16 -3
index 941bfce97bf4..192e9825be21 100644
@@ -1088,22 +1088,35 @@ int ice_nvm_validate_checksum(struct ice_hw *hw)
 /**
  * ice_nvm_write_activate
  * @hw: pointer to the HW struct
- * @cmd_flags: NVM activate admin command bits (banks to be validated)
+ * @cmd_flags: flags for write activate command
+ * @response_flags: response indicators from firmware
  *
  * Update the control word with the required banks' validity bits
  * and dumps the Shadow RAM to flash (0x0707)
+ *
+ * cmd_flags controls which banks to activate, and the preservation level to
+ * use when activating the NVM bank.
+ *
+ * On successful return of the firmware command, the response_flags variable
+ * is updated with the flags reported by firmware indicating certain status,
+ * such as whether EMP reset is enabled.
  */
-int ice_nvm_write_activate(struct ice_hw *hw, u8 cmd_flags)
+int ice_nvm_write_activate(struct ice_hw *hw, u8 cmd_flags, u8 *response_flags)
 {
 	struct ice_aqc_nvm *cmd;
 	struct ice_aq_desc desc;
+	int err;
 
 	cmd = &desc.params.nvm;
 	ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_nvm_write_activate);
 
 	cmd->cmd_flags = cmd_flags;
 
-	return ice_aq_send_cmd(hw, &desc, NULL, 0, NULL);
+	err = ice_aq_send_cmd(hw, &desc, NULL, 0, NULL);
+	if (!err && response_flags)
+		*response_flags = cmd->cmd_flags;
+
+	return err;
 }
 
 /**
drivers/net/ethernet/intel/ice/ice_nvm.h +1 -1
index ed5165d24cb1..738546ca09d2 100644
@@ -38,7 +38,7 @@ ice_aq_update_nvm(struct ice_hw *hw, u16 module_typeid, u32 offset,
 int
 ice_aq_erase_nvm(struct ice_hw *hw, u16 module_typeid, struct ice_sq_cd *cd);
 int ice_nvm_validate_checksum(struct ice_hw *hw);
-int ice_nvm_write_activate(struct ice_hw *hw, u8 cmd_flags);
+int ice_nvm_write_activate(struct ice_hw *hw, u8 cmd_flags, u8 *response_flags);
 int ice_aq_nvm_update_empr(struct ice_hw *hw);
 int
 ice_nvm_set_pkg_data(struct ice_hw *hw, bool del_pkg_data_flag, u8 *data,
drivers/net/ethernet/intel/ice/ice_type.h +4 -0
index b8644adfba78..669702b16ef5 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

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): PH0PR11MB5095792EF885D0C6C4EE853FD6BF9@PH0PR11MB5095.namprd11.prod.outlook.com

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw

PATCH v4 1/1 ice: support immediate firmware activation via devlink reload

Quoted 5 lines · Paul Menzel

Dear Jacob,

Thank you for your reply.

I sent a v5 with several changes and improvements including your suggestions. I significantly re-wrote the commit message for clarity.

I appreciate your careful review! Thank you for your time.

Thanks,
Jake