|
4 | 4 | #include "ice.h"
|
5 | 5 | #include "ice_lib.h"
|
6 | 6 | #include "ice_devlink.h"
|
| 7 | +#include "ice_fw_update.h" |
7 | 8 |
|
8 | 9 | static int ice_info_get_dsn(struct ice_pf *pf, char *buf, size_t len)
|
9 | 10 | {
|
@@ -229,8 +230,61 @@ static int ice_devlink_info_get(struct devlink *devlink,
|
229 | 230 | return 0;
|
230 | 231 | }
|
231 | 232 |
|
| 233 | +/** |
| 234 | + * ice_devlink_flash_update - Update firmware stored in flash on the device |
| 235 | + * @devlink: pointer to devlink associated with device to update |
| 236 | + * @path: the path of the firmware file to use via request_firmware |
| 237 | + * @component: name of the component to update, or NULL |
| 238 | + * @extack: netlink extended ACK structure |
| 239 | + * |
| 240 | + * Perform a device flash update. The bulk of the update logic is contained |
| 241 | + * within the ice_flash_pldm_image function. |
| 242 | + * |
| 243 | + * Returns: zero on success, or an error code on failure. |
| 244 | + */ |
| 245 | +static int |
| 246 | +ice_devlink_flash_update(struct devlink *devlink, const char *path, |
| 247 | + const char *component, struct netlink_ext_ack *extack) |
| 248 | +{ |
| 249 | + struct ice_pf *pf = devlink_priv(devlink); |
| 250 | + struct device *dev = &pf->pdev->dev; |
| 251 | + struct ice_hw *hw = &pf->hw; |
| 252 | + const struct firmware *fw; |
| 253 | + int err; |
| 254 | + |
| 255 | + /* individual component update is not yet supported */ |
| 256 | + if (component) |
| 257 | + return -EOPNOTSUPP; |
| 258 | + |
| 259 | + if (!hw->dev_caps.common_cap.nvm_unified_update) { |
| 260 | + NL_SET_ERR_MSG_MOD(extack, "Current firmware does not support unified update"); |
| 261 | + return -EOPNOTSUPP; |
| 262 | + } |
| 263 | + |
| 264 | + err = ice_check_for_pending_update(pf, component, extack); |
| 265 | + if (err) |
| 266 | + return err; |
| 267 | + |
| 268 | + err = request_firmware(&fw, path, dev); |
| 269 | + if (err) { |
| 270 | + NL_SET_ERR_MSG_MOD(extack, "Unable to read file from disk"); |
| 271 | + return err; |
| 272 | + } |
| 273 | + |
| 274 | + devlink_flash_update_begin_notify(devlink); |
| 275 | + devlink_flash_update_status_notify(devlink, "Preparing to flash", |
| 276 | + component, 0, 0); |
| 277 | + err = ice_flash_pldm_image(pf, fw, extack); |
| 278 | + devlink_flash_update_end_notify(devlink); |
| 279 | + |
| 280 | + release_firmware(fw); |
| 281 | + |
| 282 | + return err; |
| 283 | +} |
| 284 | + |
232 | 285 | static const struct devlink_ops ice_devlink_ops = {
|
233 | 286 | .info_get = ice_devlink_info_get,
|
| 287 | + .flash_update = ice_devlink_flash_update, |
234 | 288 | };
|
235 | 289 |
|
236 | 290 | static void ice_devlink_free(void *devlink_ptr)
|
|
0 commit comments