mlxfw_dev
struct mlxfw_dev mlxfw_dev;
static int mlx5_component_query(struct mlxfw_dev *mlxfw_dev,
container_of(mlxfw_dev, struct mlx5_mlxfw_dev, mlxfw_dev);
static int mlx5_fsm_lock(struct mlxfw_dev *mlxfw_dev, u32 *fwhandle)
container_of(mlxfw_dev, struct mlx5_mlxfw_dev, mlxfw_dev);
static int mlx5_fsm_component_update(struct mlxfw_dev *mlxfw_dev, u32 fwhandle,
container_of(mlxfw_dev, struct mlx5_mlxfw_dev, mlxfw_dev);
static int mlx5_fsm_block_download(struct mlxfw_dev *mlxfw_dev, u32 fwhandle,
container_of(mlxfw_dev, struct mlx5_mlxfw_dev, mlxfw_dev);
static int mlx5_fsm_component_verify(struct mlxfw_dev *mlxfw_dev, u32 fwhandle,
container_of(mlxfw_dev, struct mlx5_mlxfw_dev, mlxfw_dev);
static int mlx5_fsm_activate(struct mlxfw_dev *mlxfw_dev, u32 fwhandle)
container_of(mlxfw_dev, struct mlx5_mlxfw_dev, mlxfw_dev);
static int mlx5_fsm_query_state(struct mlxfw_dev *mlxfw_dev, u32 fwhandle,
container_of(mlxfw_dev, struct mlx5_mlxfw_dev, mlxfw_dev);
static void mlx5_fsm_cancel(struct mlxfw_dev *mlxfw_dev, u32 fwhandle)
container_of(mlxfw_dev, struct mlx5_mlxfw_dev, mlxfw_dev);
static void mlx5_fsm_release(struct mlxfw_dev *mlxfw_dev, u32 fwhandle)
container_of(mlxfw_dev, struct mlx5_mlxfw_dev, mlxfw_dev);
static int mlx5_fsm_reactivate(struct mlxfw_dev *mlxfw_dev, u8 *status)
container_of(mlxfw_dev, struct mlx5_mlxfw_dev, mlxfw_dev);
.mlxfw_dev = {
return mlxfw_firmware_flash(&mlx5_mlxfw_dev.mlxfw_dev,
int mlxfw_firmware_flash(struct mlxfw_dev *mlxfw_dev,
int mlxfw_firmware_flash(struct mlxfw_dev *mlxfw_dev,
struct device *mlxfw_dev_dev(struct mlxfw_dev *mlxfw_dev)
return devlink_to_dev(mlxfw_dev->devlink);
#define mlxfw_info(mlxfw_dev, fmt, ...) \
dev_info(mlxfw_dev_dev(mlxfw_dev), MLXFW_PRFX fmt, ## __VA_ARGS__)
#define mlxfw_err(mlxfw_dev, fmt, ...) \
dev_err(mlxfw_dev_dev(mlxfw_dev), MLXFW_PRFX fmt, ## __VA_ARGS__)
#define mlxfw_dbg(mlxfw_dev, fmt, ...) \
dev_dbg(mlxfw_dev_dev(mlxfw_dev), MLXFW_PRFX fmt, ## __VA_ARGS__)
int (*component_query)(struct mlxfw_dev *mlxfw_dev, u16 component_index,
int (*fsm_lock)(struct mlxfw_dev *mlxfw_dev, u32 *fwhandle);
int (*fsm_component_update)(struct mlxfw_dev *mlxfw_dev, u32 fwhandle,
int (*fsm_block_download)(struct mlxfw_dev *mlxfw_dev, u32 fwhandle,
int (*fsm_component_verify)(struct mlxfw_dev *mlxfw_dev, u32 fwhandle,
int (*fsm_activate)(struct mlxfw_dev *mlxfw_dev, u32 fwhandle);
int (*fsm_reactivate)(struct mlxfw_dev *mlxfw_dev, u8 *status);
int (*fsm_query_state)(struct mlxfw_dev *mlxfw_dev, u32 fwhandle,
void (*fsm_cancel)(struct mlxfw_dev *mlxfw_dev, u32 fwhandle);
void (*fsm_release)(struct mlxfw_dev *mlxfw_dev, u32 fwhandle);
return mlxfw_fsm_state_err(mlxfw_dev, extack, fsm_state_err);
MLXFW_ERR_MSG(mlxfw_dev, extack,
mlxfw_fsm_reactivate_err(struct mlxfw_dev *mlxfw_dev,
MLXFW_ERR_MSG(mlxfw_dev, extack, MXFW_REACT_PRFX msg, err)
static int mlxfw_fsm_reactivate(struct mlxfw_dev *mlxfw_dev,
if (!mlxfw_dev->ops->fsm_reactivate)
err = mlxfw_dev->ops->fsm_reactivate(mlxfw_dev, &status);
MLXFW_ERR_MSG(mlxfw_dev, extack,
return mlxfw_fsm_reactivate_err(mlxfw_dev, extack, status);
static void mlxfw_status_notify(struct mlxfw_dev *mlxfw_dev,
devlink_flash_update_status_notify(mlxfw_dev->devlink, msg, comp_name,
static int mlxfw_flash_component(struct mlxfw_dev *mlxfw_dev,
err = mlxfw_dev->ops->component_query(mlxfw_dev, comp->index,
MLXFW_ERR_MSG(mlxfw_dev, extack, "FSM component query failed", err);
MLXFW_ERR_MSG(mlxfw_dev, extack,
mlxfw_dbg(mlxfw_dev, "Component update\n");
mlxfw_status_notify(mlxfw_dev, "Updating component", comp_name, 0, 0);
err = mlxfw_dev->ops->fsm_component_update(mlxfw_dev, fwhandle,
MLXFW_ERR_MSG(mlxfw_dev, extack,
MLXFW_ERR_MSG(mlxfw_dev, extack,
err = mlxfw_fsm_state_wait(mlxfw_dev, fwhandle,
mlxfw_dbg(mlxfw_dev, "Component download\n");
mlxfw_status_notify(mlxfw_dev, "Downloading component",
err = mlxfw_dev->ops->fsm_block_download(mlxfw_dev, fwhandle,
MLXFW_ERR_MSG(mlxfw_dev, extack,
mlxfw_status_notify(mlxfw_dev, "Downloading component",
mlxfw_dbg(mlxfw_dev, "Component verify\n");
mlxfw_status_notify(mlxfw_dev, "Verifying component", comp_name, 0, 0);
err = mlxfw_dev->ops->fsm_component_verify(mlxfw_dev, fwhandle,
MLXFW_ERR_MSG(mlxfw_dev, extack,
err = mlxfw_fsm_state_wait(mlxfw_dev, fwhandle,
mlxfw_dev->ops->fsm_cancel(mlxfw_dev, fwhandle);
static int mlxfw_flash_components(struct mlxfw_dev *mlxfw_dev, u32 fwhandle,
err = mlxfw_mfa2_file_component_count(mfa2_file, mlxfw_dev->psid,
mlxfw_dev->psid_size,
MLXFW_ERR_MSG(mlxfw_dev, extack,
comp = mlxfw_mfa2_file_component_get(mfa2_file, mlxfw_dev->psid,
mlxfw_dev->psid_size, i);
MLXFW_ERR_MSG(mlxfw_dev, extack,
mlxfw_info(mlxfw_dev, "Flashing component type %d\n",
err = mlxfw_flash_component(mlxfw_dev, fwhandle, comp,
int mlxfw_firmware_flash(struct mlxfw_dev *mlxfw_dev,
MLXFW_ERR_MSG(mlxfw_dev, extack,
MLXFW_ERR_MSG(mlxfw_dev, extack,
mlxfw_info(mlxfw_dev, "Initialize firmware flash process\n");
mlxfw_status_notify(mlxfw_dev, "Initializing firmware flash process",
static int mlxfw_fsm_state_err(struct mlxfw_dev *mlxfw_dev,
err = mlxfw_dev->ops->fsm_lock(mlxfw_dev, &fwhandle);
MLXFW_ERR_MSG(mlxfw_dev, extack,
err = mlxfw_fsm_state_wait(mlxfw_dev, fwhandle,
err = mlxfw_fsm_reactivate(mlxfw_dev, extack, &reactivate_supp);
err = mlxfw_fsm_state_wait(mlxfw_dev, fwhandle,
err = mlxfw_flash_components(mlxfw_dev, fwhandle, mfa2_file,
mlxfw_dbg(mlxfw_dev, "Activate image\n");
mlxfw_status_notify(mlxfw_dev, "Activating image", NULL, 0, 0);
err = mlxfw_dev->ops->fsm_activate(mlxfw_dev, fwhandle);
MLXFW_ERR_MSG(mlxfw_dev, extack,
err = mlxfw_fsm_state_wait(mlxfw_dev, fwhandle,
mlxfw_dbg(mlxfw_dev, "Handle release\n");
mlxfw_dev->ops->fsm_release(mlxfw_dev, fwhandle);
mlxfw_info(mlxfw_dev, "Firmware flash done\n");
mlxfw_status_notify(mlxfw_dev, "Firmware flash done", NULL, 0, 0);
mlxfw_dev->ops->fsm_release(mlxfw_dev, fwhandle);
MLXFW_ERR_MSG(mlxfw_dev, extack, "general error", err);
MLXFW_ERR_MSG(mlxfw_dev, extack, "component hash mismatch", err);
MLXFW_ERR_MSG(mlxfw_dev, extack, "component not applicable", err);
MLXFW_ERR_MSG(mlxfw_dev, extack, "unknown key", err);
MLXFW_ERR_MSG(mlxfw_dev, extack, "authentication failed", err);
MLXFW_ERR_MSG(mlxfw_dev, extack, "component was not signed", err);
MLXFW_ERR_MSG(mlxfw_dev, extack, "key not applicable", err);
MLXFW_ERR_MSG(mlxfw_dev, extack, "bad format", err);
MLXFW_ERR_MSG(mlxfw_dev, extack, "pending reset", err);
MLXFW_ERR_MSG(mlxfw_dev, extack, "unknown error", err);
static int mlxfw_fsm_state_wait(struct mlxfw_dev *mlxfw_dev, u32 fwhandle,
err = mlxfw_dev->ops->fsm_query_state(mlxfw_dev, fwhandle,
MLXFW_ERR_MSG(mlxfw_dev, extack, "FSM state query failed", err);
struct mlxfw_dev *mlxfw_dev,
err = mlxfw_firmware_flash(mlxfw_dev, firmware, extack);
struct mlxfw_dev mlxfw_dev;
static int mlxsw_core_fw_component_query(struct mlxfw_dev *mlxfw_dev,
container_of(mlxfw_dev, struct mlxsw_core_fw_info, mlxfw_dev);
static int mlxsw_core_fw_fsm_lock(struct mlxfw_dev *mlxfw_dev, u32 *fwhandle)
container_of(mlxfw_dev, struct mlxsw_core_fw_info, mlxfw_dev);
static int mlxsw_core_fw_fsm_component_update(struct mlxfw_dev *mlxfw_dev, u32 fwhandle,
container_of(mlxfw_dev, struct mlxsw_core_fw_info, mlxfw_dev);
static int mlxsw_core_fw_fsm_block_download(struct mlxfw_dev *mlxfw_dev, u32 fwhandle,
container_of(mlxfw_dev, struct mlxsw_core_fw_info, mlxfw_dev);
static int mlxsw_core_fw_fsm_component_verify(struct mlxfw_dev *mlxfw_dev, u32 fwhandle,
container_of(mlxfw_dev, struct mlxsw_core_fw_info, mlxfw_dev);
static int mlxsw_core_fw_fsm_activate(struct mlxfw_dev *mlxfw_dev, u32 fwhandle)
container_of(mlxfw_dev, struct mlxsw_core_fw_info, mlxfw_dev);
static int mlxsw_core_fw_fsm_query_state(struct mlxfw_dev *mlxfw_dev, u32 fwhandle,
container_of(mlxfw_dev, struct mlxsw_core_fw_info, mlxfw_dev);
static void mlxsw_core_fw_fsm_cancel(struct mlxfw_dev *mlxfw_dev, u32 fwhandle)
container_of(mlxfw_dev, struct mlxsw_core_fw_info, mlxfw_dev);
static void mlxsw_core_fw_fsm_release(struct mlxfw_dev *mlxfw_dev, u32 fwhandle)
container_of(mlxfw_dev, struct mlxsw_core_fw_info, mlxfw_dev);
.mlxfw_dev = {
return mlxsw_core_fw_flash(mlxsw_core, &mlxsw_core_fw_info.mlxfw_dev,
struct mlxfw_dev *mlxfw_dev,
container_of(mlxfw_dev, struct mlxsw_linecard_device_fw_info,
mlxfw_dev);
static int mlxsw_linecard_device_fw_fsm_lock(struct mlxfw_dev *mlxfw_dev,
container_of(mlxfw_dev, struct mlxsw_linecard_device_fw_info,
mlxfw_dev);
mlxsw_linecard_device_fw_fsm_component_update(struct mlxfw_dev *mlxfw_dev,
container_of(mlxfw_dev, struct mlxsw_linecard_device_fw_info,
mlxfw_dev);
mlxsw_linecard_device_fw_fsm_block_download(struct mlxfw_dev *mlxfw_dev,
container_of(mlxfw_dev, struct mlxsw_linecard_device_fw_info,
mlxfw_dev);
mlxsw_linecard_device_fw_fsm_component_verify(struct mlxfw_dev *mlxfw_dev,
container_of(mlxfw_dev, struct mlxsw_linecard_device_fw_info,
mlxfw_dev);
static int mlxsw_linecard_device_fw_fsm_activate(struct mlxfw_dev *mlxfw_dev,
container_of(mlxfw_dev, struct mlxsw_linecard_device_fw_info,
mlxfw_dev);
mlxsw_linecard_device_fw_fsm_query_state(struct mlxfw_dev *mlxfw_dev,
container_of(mlxfw_dev, struct mlxsw_linecard_device_fw_info,
mlxfw_dev);
static void mlxsw_linecard_device_fw_fsm_cancel(struct mlxfw_dev *mlxfw_dev,
container_of(mlxfw_dev, struct mlxsw_linecard_device_fw_info,
mlxfw_dev);
static void mlxsw_linecard_device_fw_fsm_release(struct mlxfw_dev *mlxfw_dev,
container_of(mlxfw_dev, struct mlxsw_linecard_device_fw_info,
mlxfw_dev);
.mlxfw_dev = {
err = mlxsw_core_fw_flash(mlxsw_core, &info.mlxfw_dev,
struct mlxfw_dev mlxfw_dev;
static int mlxsw_linecard_device_fw_component_query(struct mlxfw_dev *mlxfw_dev,