Skip to content

Commit c356eaa

Browse files
jacob-kelleranguy11
authored andcommitted
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. Signed-off-by: Jacob Keller <[email protected]> Tested-by: Gurucharan G <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent 78ad87d commit c356eaa

File tree

3 files changed

+77
-77
lines changed

3 files changed

+77
-77
lines changed

drivers/net/ethernet/intel/ice/ice_devlink.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ ice_devlink_flash_update(struct devlink *devlink,
411411
return -EOPNOTSUPP;
412412
}
413413

414-
err = ice_check_for_pending_update(pf, NULL, extack);
414+
err = ice_cancel_pending_update(pf, NULL, extack);
415415
if (err)
416416
return err;
417417

drivers/net/ethernet/intel/ice/ice_fw_update.c

Lines changed: 74 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -642,87 +642,18 @@ static const struct pldmfw_ops ice_fwu_ops = {
642642
};
643643

644644
/**
645-
* ice_flash_pldm_image - Write a PLDM-formatted firmware image to the device
646-
* @pf: private device driver structure
647-
* @fw: firmware object pointing to the relevant firmware file
648-
* @preservation: preservation level to request from firmware
649-
* @extack: netlink extended ACK structure
650-
*
651-
* Parse the data for a given firmware file, verifying that it is a valid PLDM
652-
* formatted image that matches this device.
653-
*
654-
* Extract the device record Package Data and Component Tables and send them
655-
* to the firmware. Extract and write the flash data for each of the three
656-
* main flash components, "fw.mgmt", "fw.undi", and "fw.netlist". Notify
657-
* firmware once the data is written to the inactive banks.
658-
*
659-
* Returns: zero on success or a negative error code on failure.
660-
*/
661-
int ice_flash_pldm_image(struct ice_pf *pf, const struct firmware *fw,
662-
u8 preservation, struct netlink_ext_ack *extack)
663-
{
664-
struct device *dev = ice_pf_to_dev(pf);
665-
struct ice_hw *hw = &pf->hw;
666-
struct ice_fwu_priv priv;
667-
int err;
668-
669-
switch (preservation) {
670-
case ICE_AQC_NVM_PRESERVE_ALL:
671-
case ICE_AQC_NVM_PRESERVE_SELECTED:
672-
case ICE_AQC_NVM_NO_PRESERVATION:
673-
case ICE_AQC_NVM_FACTORY_DEFAULT:
674-
break;
675-
default:
676-
WARN(1, "Unexpected preservation level request %u", preservation);
677-
return -EINVAL;
678-
}
679-
680-
memset(&priv, 0, sizeof(priv));
681-
682-
priv.context.ops = &ice_fwu_ops;
683-
priv.context.dev = dev;
684-
priv.extack = extack;
685-
priv.pf = pf;
686-
priv.activate_flags = preservation;
687-
688-
err = ice_acquire_nvm(hw, ICE_RES_WRITE);
689-
if (err) {
690-
dev_err(dev, "Failed to acquire device flash lock, err %d aq_err %s\n",
691-
err, ice_aq_str(hw->adminq.sq_last_status));
692-
NL_SET_ERR_MSG_MOD(extack, "Failed to acquire device flash lock");
693-
return err;
694-
}
695-
696-
err = pldmfw_flash_image(&priv.context, fw);
697-
if (err == -ENOENT) {
698-
dev_err(dev, "Firmware image has no record matching this device\n");
699-
NL_SET_ERR_MSG_MOD(extack, "Firmware image has no record matching this device");
700-
} else if (err) {
701-
/* Do not set a generic extended ACK message here. A more
702-
* specific message may already have been set by one of our
703-
* ops.
704-
*/
705-
dev_err(dev, "Failed to flash PLDM image, err %d", err);
706-
}
707-
708-
ice_release_nvm(hw);
709-
710-
return err;
711-
}
712-
713-
/**
714-
* ice_check_for_pending_update - Check for a pending flash update
645+
* ice_cancel_pending_update - Cancel any pending update for a component
715646
* @pf: the PF driver structure
716647
* @component: if not NULL, the name of the component being updated
717648
* @extack: Netlink extended ACK structure
718649
*
719-
* Check whether the device already has a pending flash update. If such an
720-
* update is found, cancel it so that the requested update may proceed.
650+
* Cancel any pending update for the specified component. If component is
651+
* NULL, all device updates will be canceled.
721652
*
722653
* Returns: zero on success, or a negative error code on failure.
723654
*/
724-
int ice_check_for_pending_update(struct ice_pf *pf, const char *component,
725-
struct netlink_ext_ack *extack)
655+
int ice_cancel_pending_update(struct ice_pf *pf, const char *component,
656+
struct netlink_ext_ack *extack)
726657
{
727658
struct devlink *devlink = priv_to_devlink(pf);
728659
struct device *dev = ice_pf_to_dev(pf);
@@ -804,3 +735,72 @@ int ice_check_for_pending_update(struct ice_pf *pf, const char *component,
804735

805736
return err;
806737
}
738+
739+
/**
740+
* ice_flash_pldm_image - Write a PLDM-formatted firmware image to the device
741+
* @pf: private device driver structure
742+
* @fw: firmware object pointing to the relevant firmware file
743+
* @preservation: preservation level to request from firmware
744+
* @extack: netlink extended ACK structure
745+
*
746+
* Parse the data for a given firmware file, verifying that it is a valid PLDM
747+
* formatted image that matches this device.
748+
*
749+
* Extract the device record Package Data and Component Tables and send them
750+
* to the firmware. Extract and write the flash data for each of the three
751+
* main flash components, "fw.mgmt", "fw.undi", and "fw.netlist". Notify
752+
* firmware once the data is written to the inactive banks.
753+
*
754+
* Returns: zero on success or a negative error code on failure.
755+
*/
756+
int ice_flash_pldm_image(struct ice_pf *pf, const struct firmware *fw,
757+
u8 preservation, struct netlink_ext_ack *extack)
758+
{
759+
struct device *dev = ice_pf_to_dev(pf);
760+
struct ice_hw *hw = &pf->hw;
761+
struct ice_fwu_priv priv;
762+
int err;
763+
764+
switch (preservation) {
765+
case ICE_AQC_NVM_PRESERVE_ALL:
766+
case ICE_AQC_NVM_PRESERVE_SELECTED:
767+
case ICE_AQC_NVM_NO_PRESERVATION:
768+
case ICE_AQC_NVM_FACTORY_DEFAULT:
769+
break;
770+
default:
771+
WARN(1, "Unexpected preservation level request %u", preservation);
772+
return -EINVAL;
773+
}
774+
775+
memset(&priv, 0, sizeof(priv));
776+
777+
priv.context.ops = &ice_fwu_ops;
778+
priv.context.dev = dev;
779+
priv.extack = extack;
780+
priv.pf = pf;
781+
priv.activate_flags = preservation;
782+
783+
err = ice_acquire_nvm(hw, ICE_RES_WRITE);
784+
if (err) {
785+
dev_err(dev, "Failed to acquire device flash lock, err %d aq_err %s\n",
786+
err, ice_aq_str(hw->adminq.sq_last_status));
787+
NL_SET_ERR_MSG_MOD(extack, "Failed to acquire device flash lock");
788+
return err;
789+
}
790+
791+
err = pldmfw_flash_image(&priv.context, fw);
792+
if (err == -ENOENT) {
793+
dev_err(dev, "Firmware image has no record matching this device\n");
794+
NL_SET_ERR_MSG_MOD(extack, "Firmware image has no record matching this device");
795+
} else if (err) {
796+
/* Do not set a generic extended ACK message here. A more
797+
* specific message may already have been set by one of our
798+
* ops.
799+
*/
800+
dev_err(dev, "Failed to flash PLDM image, err %d", err);
801+
}
802+
803+
ice_release_nvm(hw);
804+
805+
return err;
806+
}

drivers/net/ethernet/intel/ice/ice_fw_update.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
int ice_flash_pldm_image(struct ice_pf *pf, const struct firmware *fw,
88
u8 preservation, struct netlink_ext_ack *extack);
9-
int ice_check_for_pending_update(struct ice_pf *pf, const char *component,
10-
struct netlink_ext_ack *extack);
9+
int ice_cancel_pending_update(struct ice_pf *pf, const char *component,
10+
struct netlink_ext_ack *extack);
1111

1212
#endif

0 commit comments

Comments
 (0)