mlxsw: Implement flash update status notifications
authorJiri Pirko <jiri@mellanox.com>
Tue, 4 Jun 2019 13:40:42 +0000 (15:40 +0200)
committerDavid S. Miller <davem@davemloft.net>
Tue, 4 Jun 2019 21:21:40 +0000 (14:21 -0700)
Implement mlxfw status_notify op by passing notification down to
devlink. Also notify about flash update begin and end.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Reviewed-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/spectrum.c

index 2cba678863bd857f66f49e944453c91f12e6496e..417e7c9273ef8e7ca6e9dcc1432124a5c157cecb 100644 (file)
@@ -294,6 +294,19 @@ static void mlxsw_sp_fsm_release(struct mlxfw_dev *mlxfw_dev, u32 fwhandle)
        mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(mcc), mcc_pl);
 }
 
+static void mlxsw_sp_status_notify(struct mlxfw_dev *mlxfw_dev,
+                                  const char *msg, const char *comp_name,
+                                  u32 done_bytes, u32 total_bytes)
+{
+       struct mlxsw_sp_mlxfw_dev *mlxsw_sp_mlxfw_dev =
+               container_of(mlxfw_dev, struct mlxsw_sp_mlxfw_dev, mlxfw_dev);
+       struct mlxsw_sp *mlxsw_sp = mlxsw_sp_mlxfw_dev->mlxsw_sp;
+
+       devlink_flash_update_status_notify(priv_to_devlink(mlxsw_sp->core),
+                                          msg, comp_name,
+                                          done_bytes, total_bytes);
+}
+
 static const struct mlxfw_dev_ops mlxsw_sp_mlxfw_dev_ops = {
        .component_query        = mlxsw_sp_component_query,
        .fsm_lock               = mlxsw_sp_fsm_lock,
@@ -303,7 +316,8 @@ static const struct mlxfw_dev_ops mlxsw_sp_mlxfw_dev_ops = {
        .fsm_activate           = mlxsw_sp_fsm_activate,
        .fsm_query_state        = mlxsw_sp_fsm_query_state,
        .fsm_cancel             = mlxsw_sp_fsm_cancel,
-       .fsm_release            = mlxsw_sp_fsm_release
+       .fsm_release            = mlxsw_sp_fsm_release,
+       .status_notify          = mlxsw_sp_status_notify,
 };
 
 static int mlxsw_sp_firmware_flash(struct mlxsw_sp *mlxsw_sp,
@@ -321,8 +335,10 @@ static int mlxsw_sp_firmware_flash(struct mlxsw_sp *mlxsw_sp,
        int err;
 
        mlxsw_core_fw_flash_start(mlxsw_sp->core);
+       devlink_flash_update_begin_notify(priv_to_devlink(mlxsw_sp->core));
        err = mlxfw_firmware_flash(&mlxsw_sp_mlxfw_dev.mlxfw_dev,
                                   firmware, extack);
+       devlink_flash_update_end_notify(priv_to_devlink(mlxsw_sp->core));
        mlxsw_core_fw_flash_end(mlxsw_sp->core);
 
        return err;