Commit 5853c418 authored by Jiri Pirko's avatar Jiri Pirko Committed by David S. Miller

mlxfw: Introduce status_notify op and call it to notify about the status

Add new op status_notify which is called to update the user about
flashing status.
Signed-off-by: default avatarJiri Pirko <jiri@mellanox.com>
Reviewed-by: default avatarIdo Schimmel <idosch@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 191ed202
...@@ -58,6 +58,10 @@ struct mlxfw_dev_ops { ...@@ -58,6 +58,10 @@ struct mlxfw_dev_ops {
void (*fsm_cancel)(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); void (*fsm_release)(struct mlxfw_dev *mlxfw_dev, u32 fwhandle);
void (*status_notify)(struct mlxfw_dev *mlxfw_dev,
const char *msg, const char *comp_name,
u32 done_bytes, u32 total_bytes);
}; };
struct mlxfw_dev { struct mlxfw_dev {
......
...@@ -39,6 +39,16 @@ static const char * const mlxfw_fsm_state_err_str[] = { ...@@ -39,6 +39,16 @@ static const char * const mlxfw_fsm_state_err_str[] = {
"unknown error" "unknown error"
}; };
static void mlxfw_status_notify(struct mlxfw_dev *mlxfw_dev,
const char *msg, const char *comp_name,
u32 done_bytes, u32 total_bytes)
{
if (!mlxfw_dev->ops->status_notify)
return;
mlxfw_dev->ops->status_notify(mlxfw_dev, msg, comp_name,
done_bytes, total_bytes);
}
static int mlxfw_fsm_state_wait(struct mlxfw_dev *mlxfw_dev, u32 fwhandle, static int mlxfw_fsm_state_wait(struct mlxfw_dev *mlxfw_dev, u32 fwhandle,
enum mlxfw_fsm_state fsm_state, enum mlxfw_fsm_state fsm_state,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
...@@ -85,11 +95,14 @@ static int mlxfw_flash_component(struct mlxfw_dev *mlxfw_dev, ...@@ -85,11 +95,14 @@ static int mlxfw_flash_component(struct mlxfw_dev *mlxfw_dev,
u16 comp_max_write_size; u16 comp_max_write_size;
u8 comp_align_bits; u8 comp_align_bits;
u32 comp_max_size; u32 comp_max_size;
char comp_name[8];
u16 block_size; u16 block_size;
u8 *block_ptr; u8 *block_ptr;
u32 offset; u32 offset;
int err; int err;
sprintf(comp_name, "%u", comp->index);
err = mlxfw_dev->ops->component_query(mlxfw_dev, comp->index, err = mlxfw_dev->ops->component_query(mlxfw_dev, comp->index,
&comp_max_size, &comp_align_bits, &comp_max_size, &comp_align_bits,
&comp_max_write_size); &comp_max_write_size);
...@@ -108,6 +121,7 @@ static int mlxfw_flash_component(struct mlxfw_dev *mlxfw_dev, ...@@ -108,6 +121,7 @@ static int mlxfw_flash_component(struct mlxfw_dev *mlxfw_dev,
comp_align_bits); comp_align_bits);
pr_debug("Component update\n"); pr_debug("Component update\n");
mlxfw_status_notify(mlxfw_dev, "Updating component", comp_name, 0, 0);
err = mlxfw_dev->ops->fsm_component_update(mlxfw_dev, fwhandle, err = mlxfw_dev->ops->fsm_component_update(mlxfw_dev, fwhandle,
comp->index, comp->index,
comp->data_size); comp->data_size);
...@@ -120,6 +134,8 @@ static int mlxfw_flash_component(struct mlxfw_dev *mlxfw_dev, ...@@ -120,6 +134,8 @@ static int mlxfw_flash_component(struct mlxfw_dev *mlxfw_dev,
goto err_out; goto err_out;
pr_debug("Component download\n"); pr_debug("Component download\n");
mlxfw_status_notify(mlxfw_dev, "Downloading component",
comp_name, 0, comp->data_size);
for (offset = 0; for (offset = 0;
offset < MLXFW_ALIGN_UP(comp->data_size, comp_align_bits); offset < MLXFW_ALIGN_UP(comp->data_size, comp_align_bits);
offset += comp_max_write_size) { offset += comp_max_write_size) {
...@@ -131,9 +147,13 @@ static int mlxfw_flash_component(struct mlxfw_dev *mlxfw_dev, ...@@ -131,9 +147,13 @@ static int mlxfw_flash_component(struct mlxfw_dev *mlxfw_dev,
offset); offset);
if (err) if (err)
goto err_out; goto err_out;
mlxfw_status_notify(mlxfw_dev, "Downloading component",
comp_name, offset + block_size,
comp->data_size);
} }
pr_debug("Component verify\n"); pr_debug("Component verify\n");
mlxfw_status_notify(mlxfw_dev, "Verifying component", comp_name, 0, 0);
err = mlxfw_dev->ops->fsm_component_verify(mlxfw_dev, fwhandle, err = mlxfw_dev->ops->fsm_component_verify(mlxfw_dev, fwhandle,
comp->index); comp->index);
if (err) if (err)
...@@ -203,6 +223,8 @@ int mlxfw_firmware_flash(struct mlxfw_dev *mlxfw_dev, ...@@ -203,6 +223,8 @@ int mlxfw_firmware_flash(struct mlxfw_dev *mlxfw_dev,
return PTR_ERR(mfa2_file); return PTR_ERR(mfa2_file);
pr_info("Initialize firmware flash process\n"); pr_info("Initialize firmware flash process\n");
mlxfw_status_notify(mlxfw_dev, "Initializing firmware flash process",
NULL, 0, 0);
err = mlxfw_dev->ops->fsm_lock(mlxfw_dev, &fwhandle); err = mlxfw_dev->ops->fsm_lock(mlxfw_dev, &fwhandle);
if (err) { if (err) {
pr_err("Could not lock the firmware FSM\n"); pr_err("Could not lock the firmware FSM\n");
...@@ -220,6 +242,7 @@ int mlxfw_firmware_flash(struct mlxfw_dev *mlxfw_dev, ...@@ -220,6 +242,7 @@ int mlxfw_firmware_flash(struct mlxfw_dev *mlxfw_dev,
goto err_flash_components; goto err_flash_components;
pr_debug("Activate image\n"); pr_debug("Activate image\n");
mlxfw_status_notify(mlxfw_dev, "Activating image", NULL, 0, 0);
err = mlxfw_dev->ops->fsm_activate(mlxfw_dev, fwhandle); err = mlxfw_dev->ops->fsm_activate(mlxfw_dev, fwhandle);
if (err) { if (err) {
pr_err("Could not activate the downloaded image\n"); pr_err("Could not activate the downloaded image\n");
...@@ -236,6 +259,7 @@ int mlxfw_firmware_flash(struct mlxfw_dev *mlxfw_dev, ...@@ -236,6 +259,7 @@ int mlxfw_firmware_flash(struct mlxfw_dev *mlxfw_dev,
mlxfw_dev->ops->fsm_release(mlxfw_dev, fwhandle); mlxfw_dev->ops->fsm_release(mlxfw_dev, fwhandle);
pr_info("Firmware flash done.\n"); pr_info("Firmware flash done.\n");
mlxfw_status_notify(mlxfw_dev, "Firmware flash done", NULL, 0, 0);
mlxfw_mfa2_file_fini(mfa2_file); mlxfw_mfa2_file_fini(mfa2_file);
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment