/* Track which NVM banks to activate at the end of the update */
u8 activate_flags;
/* Track the firmware response of the required reset to complete the *flashupdate. * *0-ICE_AQC_NVM_POR_FLAG-Afullpoweronisrequired *1-ICE_AQC_NVM_PERST_FLAG-AcoldPCIeresetisrequired *2-ICE_AQC_NVM_EMPR_FLAG-AnEMPresetisrequired
*/
u8 reset_level;
/* Track if EMP reset is available */
u8 emp_reset_available;
};
dev_dbg(dev, "Sending PLDM record package data to firmware\n");
package_data = kmemdup(data, length, GFP_KERNEL); if (!package_data) return -ENOMEM;
status = ice_nvm_set_pkg_data(hw, false, package_data, length, NULL);
kfree(package_data);
if (status) {
dev_err(dev, "Failed to send record package data to firmware, err %d aq_err %s\n",
status, libie_aq_str(hw->adminq.sq_last_status));
NL_SET_ERR_MSG_MOD(extack, "Failed to record package data to firmware"); return -EIO;
}
switch (response) { case ICE_AQ_NVM_PASS_COMP_CAN_BE_UPDATED: /* firmware indicated this update is good to proceed */ return0; case ICE_AQ_NVM_PASS_COMP_CAN_MAY_BE_UPDATEABLE:
dev_warn(dev, "firmware recommends not updating %s, as it may result in a downgrade. continuing anyways\n", component); return0; case ICE_AQ_NVM_PASS_COMP_CAN_NOT_BE_UPDATED:
dev_info(dev, "firmware has rejected updating %s\n", component); break; case ICE_AQ_NVM_PASS_COMP_PARTIAL_CHECK: if (ice_is_recovery_mode(&pf->hw)) return0; break;
}
switch (code) { case ICE_AQ_NVM_PASS_COMP_STAMP_IDENTICAL_CODE:
dev_err(dev, "Component comparison stamp for %s is identical to the running image\n",
component);
NL_SET_ERR_MSG_MOD(extack, "Component comparison stamp is identical to running image"); break; case ICE_AQ_NVM_PASS_COMP_STAMP_LOWER:
dev_err(dev, "Component comparison stamp for %s is lower than the running image\n",
component);
NL_SET_ERR_MSG_MOD(extack, "Component comparison stamp is lower than running image"); break; case ICE_AQ_NVM_PASS_COMP_INVALID_STAMP_CODE:
dev_err(dev, "Component comparison stamp for %s is invalid\n",
component);
NL_SET_ERR_MSG_MOD(extack, "Component comparison stamp is invalid"); break; case ICE_AQ_NVM_PASS_COMP_CONFLICT_CODE:
dev_err(dev, "%s conflicts with a previous component table\n",
component);
NL_SET_ERR_MSG_MOD(extack, "Component table conflict occurred"); break; case ICE_AQ_NVM_PASS_COMP_PRE_REQ_NOT_MET_CODE:
dev_err(dev, "Pre-requisites for component %s have not been met\n",
component);
NL_SET_ERR_MSG_MOD(extack, "Component pre-requisites not met"); break; case ICE_AQ_NVM_PASS_COMP_NOT_SUPPORTED_CODE:
dev_err(dev, "%s is not a supported component\n",
component);
NL_SET_ERR_MSG_MOD(extack, "Component not supported"); break; case ICE_AQ_NVM_PASS_COMP_CANNOT_DOWNGRADE_CODE:
dev_err(dev, "Security restrictions prevent %s from being downgraded\n",
component);
NL_SET_ERR_MSG_MOD(extack, "Component cannot be downgraded"); break; case ICE_AQ_NVM_PASS_COMP_INCOMPLETE_IMAGE_CODE:
dev_err(dev, "Received an incomplete component image for %s\n",
component);
NL_SET_ERR_MSG_MOD(extack, "Incomplete component image"); break; case ICE_AQ_NVM_PASS_COMP_VER_STR_IDENTICAL_CODE:
dev_err(dev, "Component version for %s is identical to the running image\n",
component);
NL_SET_ERR_MSG_MOD(extack, "Component version is identical to running image"); break; case ICE_AQ_NVM_PASS_COMP_VER_STR_LOWER_CODE:
dev_err(dev, "Component version for %s is lower than the running image\n",
component);
NL_SET_ERR_MSG_MOD(extack, "Component version is lower than the running image"); break; default:
dev_err(dev, "Unexpected response code 0x02%x for %s\n",
code, component);
NL_SET_ERR_MSG_MOD(extack, "Received unexpected response code from firmware"); break;
}
switch (component->identifier) { case NVM_COMP_ID_OROM: case NVM_COMP_ID_NVM: case NVM_COMP_ID_NETLIST: break; default:
dev_err(dev, "Unable to update due to a firmware component with unknown ID %u\n",
component->identifier);
NL_SET_ERR_MSG_MOD(extack, "Unable to update due to unknown firmware component"); return -EOPNOTSUPP;
}
dev_dbg(dev, "Sending component table to firmware:\n");
status = ice_nvm_pass_component_tbl(hw, (u8 *)comp_tbl, length,
transfer_flag, &comp_response,
&comp_response_code, NULL);
kfree(comp_tbl);
if (status) {
dev_err(dev, "Failed to transfer component table to firmware, err %d aq_err %s\n",
status, libie_aq_str(hw->adminq.sq_last_status));
NL_SET_ERR_MSG_MOD(extack, "Failed to transfer component table to firmware"); return -EIO;
}
err = ice_aq_update_nvm(hw, module, offset, block_size, block,
last_cmd, 0, NULL); if (err) {
dev_err(dev, "Failed to flash module 0x%02x with block of size %u at offset %u, err %d aq_err %s\n",
module, block_size, offset, err,
libie_aq_str(hw->adminq.sq_last_status));
NL_SET_ERR_MSG_MOD(extack, "Failed to program flash module"); return -EIO;
}
/* In most cases, firmware reports a write completion within a few *milliseconds.However,ithasbeenobservedthatacompletionmight *takemorethanasecondtocompleteinsomecases.Thetimeouthere *isconservativeandisintendedtopreventfailuretoupdatewhen *firmwareisslowtorespond.
*/
err = ice_aq_wait_for_event(pf, &task, 15 * HZ); if (err) {
dev_err(dev, "Timed out while trying to flash module 0x%02x with block of size %u at offset %u, err %d\n",
module, block_size, offset, err);
NL_SET_ERR_MSG_MOD(extack, "Timed out waiting for firmware"); return -EIO;
}
if (completion_retval) {
dev_err(dev, "Firmware failed to flash module 0x%02x with block of size %u at offset %u, err %s\n",
module, block_size, offset,
libie_aq_str((enum libie_aq_err)completion_retval));
NL_SET_ERR_MSG_MOD(extack, "Firmware failed to program flash module"); return -EIO;
}
/* For the last command to write the NVM bank, newer versions of *firmwareindicatetherequiredlevelofresettocomplete *activationoffirmware.Ifthefirmwaresupportsthis,cachethe *responseforindicatingtotheuserlater.Otherwise,assumethat *afullpowercycleisrequired.
*/ if (reset_level && last_cmd && module == ICE_SR_1ST_NVM_BANK_PTR) { if (hw->dev_caps.common_cap.pcie_reset_avoidance) {
*reset_level = cmd->cmd_flags &
ICE_AQC_NVM_RESET_LVL_M;
dev_dbg(dev, "Firmware reported required reset level as %u\n",
*reset_level);
} else {
*reset_level = ICE_AQC_NVM_POR_FLAG;
dev_dbg(dev, "Firmware doesn't support indicating required reset level. Assuming a power cycle is required\n");
}
}
/* ice_aq_update_nvm may copy the firmware response into the *buffer,sowemustmakeacopysincethesourcedatais *constant.
*/
memcpy(block, image + offset, block_size);
/* Length in seconds to wait before timing out when erasing a flash module. *Yes,erasingreallycantakeminutestocomplete.
*/ #define ICE_FW_ERASE_TIMEOUT 300
err = ice_aq_wait_for_event(pf, &task, ICE_FW_ERASE_TIMEOUT * HZ); if (err) {
dev_err(dev, "Timed out waiting for firmware to respond with erase completion for %s (module 0x%02x), err %d\n",
component, module, err);
NL_SET_ERR_MSG_MOD(extack, "Timed out waiting for firmware"); goto out_notify_devlink;
}
err = ice_nvm_write_activate(hw, activate_flags, &response_flags); if (err) {
dev_err(dev, "Failed to switch active flash banks, err %d aq_err %s\n",
err, libie_aq_str(hw->adminq.sq_last_status));
NL_SET_ERR_MSG_MOD(extack, "Failed to switch active flash banks"); return -EIO;
}
/* Newer versions of firmware have support to indicate whether an EMP *resettoreloadfirmwareisavailable.Forolderfirmware,EMP *resetisalwaysavailable.
*/ if (emp_reset_available) { if (hw->dev_caps.common_cap.reset_restrict_support) {
*emp_reset_available = response_flags & ICE_AQC_NVM_EMPR_ENA;
dev_dbg(dev, "Firmware indicated that EMP reset is %s\n",
*emp_reset_available ? "available" : "not available");
} else {
*emp_reset_available = ICE_AQC_NVM_EMPR_ENA;
dev_dbg(dev, "Firmware does not support restricting EMP reset availability\n");
}
}
err = ice_aq_wait_for_event(pf, &task, 30 * HZ); if (err) {
dev_err(dev, "Timed out waiting for firmware to switch active flash banks, err %d\n",
err);
NL_SET_ERR_MSG_MOD(extack, "Timed out waiting for firmware"); return err;
}
completion_retval = le16_to_cpu(task.event.desc.retval); if (completion_retval) {
dev_err(dev, "Firmware failed to switch active flash banks aq_err %s\n",
libie_aq_str((enum libie_aq_err)completion_retval));
NL_SET_ERR_MSG_MOD(extack, "Firmware failed to switch active flash banks"); return -EIO;
}
switch (component->identifier) { case NVM_COMP_ID_OROM:
module = ICE_SR_1ST_OROM_BANK_PTR;
flag = ICE_AQC_NVM_ACTIV_SEL_OROM;
reset_level = NULL;
name = "fw.undi"; break; case NVM_COMP_ID_NVM:
module = ICE_SR_1ST_NVM_BANK_PTR;
flag = ICE_AQC_NVM_ACTIV_SEL_NVM;
reset_level = &priv->reset_level;
name = "fw.mgmt"; break; case NVM_COMP_ID_NETLIST:
module = ICE_SR_NETLIST_BANK_PTR;
flag = ICE_AQC_NVM_ACTIV_SEL_NETLIST;
reset_level = NULL;
name = "fw.netlist"; break; default: /* This should not trigger, since we check the id before *sendingthecomponenttabletofirmware.
*/
WARN(1, "Unexpected unknown component identifier 0x%02x",
component->identifier); return -EINVAL;
}
/* Mark this component for activating at the end */
priv->activate_flags |= flag;
err = ice_erase_nvm_module(pf, module, name, extack); if (err) return err;
/* Finally, notify firmware to activate the written NVM banks */
err = ice_switch_flash_banks(pf, priv->activate_flags,
&priv->emp_reset_available, extack); if (err) return err;
devlink = priv_to_devlink(pf);
/* If the required reset is EMPR, but EMPR is disabled, report that *arebootisrequiredinstead.
*/ if (priv->reset_level == ICE_AQC_NVM_EMPR_FLAG &&
!priv->emp_reset_available) {
dev_dbg(ice_pf_to_dev(pf), "Firmware indicated EMP reset as sufficient, but EMP reset is disabled\n");
priv->reset_level = ICE_AQC_NVM_PERST_FLAG;
}
switch (priv->reset_level) { case ICE_AQC_NVM_EMPR_FLAG:
devlink_flash_update_status_notify(devlink, "Activate new firmware by devlink reload",
NULL, 0, 0); break; case ICE_AQC_NVM_PERST_FLAG:
devlink_flash_update_status_notify(devlink, "Activate new firmware by rebooting the system",
NULL, 0, 0); break; case ICE_AQC_NVM_POR_FLAG: default:
devlink_flash_update_status_notify(devlink, "Activate new firmware by power cycling the system",
NULL, 0, 0); break;
}
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 *usedwhentherecordshouldignorethisfieldwhenmatching *device.Forexampleiftherecordappliestoanysubsystem *deviceorvendor.
*/ 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)) returntrue;
dev_caps = kzalloc(sizeof(*dev_caps), GFP_KERNEL); if (!dev_caps) return -ENOMEM;
/* Read the most recent device capabilities from firmware. Do not use *thecachedvaluesinhw->dev_caps,becausethependingupdateflag *mayhavechanged,e.g.ifanupdatewaspreviouslycompletedand *thesystemhasnotyetrebooted.
*/
err = ice_discover_dev_caps(hw, dev_caps); if (err) {
NL_SET_ERR_MSG_MOD(extack, "Unable to read device capabilities");
kfree(dev_caps); return err;
}
*pending = 0;
if (dev_caps->common_cap.nvm_update_pending_nvm) {
dev_info(dev, "The fw.mgmt flash component has a pending update\n");
*pending |= ICE_AQC_NVM_ACTIV_SEL_NVM;
}
if (dev_caps->common_cap.nvm_update_pending_orom) {
dev_info(dev, "The fw.undi flash component has a pending update\n");
*pending |= ICE_AQC_NVM_ACTIV_SEL_OROM;
}
if (dev_caps->common_cap.nvm_update_pending_netlist) {
dev_info(dev, "The fw.netlist flash component has a pending update\n");
*pending |= ICE_AQC_NVM_ACTIV_SEL_NETLIST;
}
if (!params->overwrite_mask) { /* preserve all settings and identifiers */
preservation = ICE_AQC_NVM_PRESERVE_ALL;
} elseif (params->overwrite_mask == DEVLINK_FLASH_OVERWRITE_SETTINGS) { /* overwrite settings, but preserve the vital device identifiers */
preservation = ICE_AQC_NVM_PRESERVE_SELECTED;
} elseif (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 && !ice_is_recovery_mode(hw)) {
NL_SET_ERR_MSG_MOD(extack, "Current firmware does not support unified update"); return -EOPNOTSUPP;
}
/* 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;
priv.activate_flags = preservation;
devlink_flash_update_status_notify(devlink, "Preparing to flash", NULL, 0, 0);
err = ice_cancel_pending_update(pf, NULL, extack); if (err) return err;
err = ice_acquire_nvm(hw, ICE_RES_WRITE); if (err) {
dev_err(dev, "Failed to acquire device flash lock, err %d aq_err %s\n",
err, libie_aq_str(hw->adminq.sq_last_status));
NL_SET_ERR_MSG_MOD(extack, "Failed to acquire device flash lock"); return err;
}
err = pldmfw_flash_image(&priv.context, params->fw); if (err == -ENOENT) {
dev_err(dev, "Firmware image has no record matching this device\n");
NL_SET_ERR_MSG_MOD(extack, "Firmware image has no record matching this device");
} elseif (err) { /* Do not set a generic extended ACK message here. A more *specificmessagemayalreadyhavebeensetbyoneofour *ops.
*/
dev_err(dev, "Failed to flash PLDM image, err %d", err);
}
ice_release_nvm(hw);
return err;
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.23 Sekunden
(vorverarbeitet am 2026-10-03)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.