ice: move ice_devlink_flash_update and merge with ice_flash_pldm_image
The ice_devlink_flash_update function performs a few upfront checks and then calls ice_flash_pldm_image. Most if these checks make more sense in the context of code within ice_flash_pldm_image. Merge ice_devlink_flash_update and ice_flash_pldm_image into one function, placing it in ice_fw_update.c Since this is still the entry point for devlink, call the function ice_devlink_flash_update instead of ice_flash_pldm_image. This leaves a single function which handles the devlink parameters and then initiates a PLDM update. With this change, the ice_devlink_flash_update function in ice_fw_update.c becomes the main entry point for flash update. It elimintes some unnecessary boiler plate code between the two previous functions. The ultimate motivation for this is that it eases supporting a dry run with the PLDM library in a future change. Signed-off-by: Jacob Keller <jacob.e.keller@intel.com> Tested-by: Gurucharan G <gurucharanx.g@intel.com> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
This commit is contained in:
parent
c356eaa824
commit
c9f7a483e4
@ -370,56 +370,6 @@ out_free_ctx:
|
|||||||
return err;
|
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 = {
|
static const struct devlink_ops ice_devlink_ops = {
|
||||||
.supported_flash_update_params = DEVLINK_SUPPORT_FLASH_UPDATE_OVERWRITE_MASK,
|
.supported_flash_update_params = DEVLINK_SUPPORT_FLASH_UPDATE_OVERWRITE_MASK,
|
||||||
.eswitch_mode_get = ice_eswitch_mode_get,
|
.eswitch_mode_get = ice_eswitch_mode_get,
|
||||||
|
@ -652,8 +652,9 @@ static const struct pldmfw_ops ice_fwu_ops = {
|
|||||||
*
|
*
|
||||||
* Returns: zero on success, or a negative error code on failure.
|
* Returns: zero on success, or a negative error code on failure.
|
||||||
*/
|
*/
|
||||||
int ice_cancel_pending_update(struct ice_pf *pf, const char *component,
|
static int
|
||||||
struct netlink_ext_ack *extack)
|
ice_cancel_pending_update(struct ice_pf *pf, const char *component,
|
||||||
|
struct netlink_ext_ack *extack)
|
||||||
{
|
{
|
||||||
struct devlink *devlink = priv_to_devlink(pf);
|
struct devlink *devlink = priv_to_devlink(pf);
|
||||||
struct device *dev = ice_pf_to_dev(pf);
|
struct device *dev = ice_pf_to_dev(pf);
|
||||||
@ -737,10 +738,9 @@ int ice_cancel_pending_update(struct ice_pf *pf, const char *component,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ice_flash_pldm_image - Write a PLDM-formatted firmware image to the device
|
* ice_devlink_flash_update - Write a firmware image to the device
|
||||||
* @pf: private device driver structure
|
* @devlink: pointer to devlink associated with the device to update
|
||||||
* @fw: firmware object pointing to the relevant firmware file
|
* @params: devlink flash update parameters
|
||||||
* @preservation: preservation level to request from firmware
|
|
||||||
* @extack: netlink extended ACK structure
|
* @extack: netlink extended ACK structure
|
||||||
*
|
*
|
||||||
* Parse the data for a given firmware file, verifying that it is a valid PLDM
|
* Parse the data for a given firmware file, verifying that it is a valid PLDM
|
||||||
@ -753,23 +753,35 @@ int ice_cancel_pending_update(struct ice_pf *pf, const char *component,
|
|||||||
*
|
*
|
||||||
* Returns: zero on success or a negative error code on failure.
|
* Returns: zero on success or a negative error code on failure.
|
||||||
*/
|
*/
|
||||||
int ice_flash_pldm_image(struct ice_pf *pf, const struct firmware *fw,
|
int ice_devlink_flash_update(struct devlink *devlink,
|
||||||
u8 preservation, struct netlink_ext_ack *extack)
|
struct devlink_flash_update_params *params,
|
||||||
|
struct netlink_ext_ack *extack)
|
||||||
{
|
{
|
||||||
|
struct ice_pf *pf = devlink_priv(devlink);
|
||||||
struct device *dev = ice_pf_to_dev(pf);
|
struct device *dev = ice_pf_to_dev(pf);
|
||||||
struct ice_hw *hw = &pf->hw;
|
struct ice_hw *hw = &pf->hw;
|
||||||
struct ice_fwu_priv priv;
|
struct ice_fwu_priv priv;
|
||||||
|
u8 preservation;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
switch (preservation) {
|
if (!params->overwrite_mask) {
|
||||||
case ICE_AQC_NVM_PRESERVE_ALL:
|
/* preserve all settings and identifiers */
|
||||||
case ICE_AQC_NVM_PRESERVE_SELECTED:
|
preservation = ICE_AQC_NVM_PRESERVE_ALL;
|
||||||
case ICE_AQC_NVM_NO_PRESERVATION:
|
} else if (params->overwrite_mask == DEVLINK_FLASH_OVERWRITE_SETTINGS) {
|
||||||
case ICE_AQC_NVM_FACTORY_DEFAULT:
|
/* overwrite settings, but preserve the vital device identifiers */
|
||||||
break;
|
preservation = ICE_AQC_NVM_PRESERVE_SELECTED;
|
||||||
default:
|
} else if (params->overwrite_mask == (DEVLINK_FLASH_OVERWRITE_SETTINGS |
|
||||||
WARN(1, "Unexpected preservation level request %u", preservation);
|
DEVLINK_FLASH_OVERWRITE_IDENTIFIERS)) {
|
||||||
return -EINVAL;
|
/* 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(&priv, 0, sizeof(priv));
|
memset(&priv, 0, sizeof(priv));
|
||||||
@ -780,6 +792,12 @@ int ice_flash_pldm_image(struct ice_pf *pf, const struct firmware *fw,
|
|||||||
priv.pf = pf;
|
priv.pf = pf;
|
||||||
priv.activate_flags = preservation;
|
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);
|
err = ice_acquire_nvm(hw, ICE_RES_WRITE);
|
||||||
if (err) {
|
if (err) {
|
||||||
dev_err(dev, "Failed to acquire device flash lock, err %d aq_err %s\n",
|
dev_err(dev, "Failed to acquire device flash lock, err %d aq_err %s\n",
|
||||||
@ -788,7 +806,7 @@ int ice_flash_pldm_image(struct ice_pf *pf, const struct firmware *fw,
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = pldmfw_flash_image(&priv.context, fw);
|
err = pldmfw_flash_image(&priv.context, params->fw);
|
||||||
if (err == -ENOENT) {
|
if (err == -ENOENT) {
|
||||||
dev_err(dev, "Firmware image has no record matching this device\n");
|
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");
|
NL_SET_ERR_MSG_MOD(extack, "Firmware image has no record matching this device");
|
||||||
|
@ -4,9 +4,8 @@
|
|||||||
#ifndef _ICE_FW_UPDATE_H_
|
#ifndef _ICE_FW_UPDATE_H_
|
||||||
#define _ICE_FW_UPDATE_H_
|
#define _ICE_FW_UPDATE_H_
|
||||||
|
|
||||||
int ice_flash_pldm_image(struct ice_pf *pf, const struct firmware *fw,
|
int ice_devlink_flash_update(struct devlink *devlink,
|
||||||
u8 preservation, struct netlink_ext_ack *extack);
|
struct devlink_flash_update_params *params,
|
||||||
int ice_cancel_pending_update(struct ice_pf *pf, const char *component,
|
struct netlink_ext_ack *extack);
|
||||||
struct netlink_ext_ack *extack);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user