Commit 71b75f0e authored by Moshe Shemesh's avatar Moshe Shemesh Committed by Saeed Mahameed

net/mlx5: Unregister traps on driver unload flow

Before this patch, devlink traps are registered only on full driver
probe and unregistered on driver removal. As devlink traps are not
usable once driver functionality is unloaded, it should be unrgeistered
also on flows that unload the driver and then registered when loaded
back, e.g. devlink reload flow.
Signed-off-by: default avatarMoshe Shemesh <moshe@nvidia.com>
Reviewed-by: default avatarAya Levin <ayal@nvidia.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
parent d23b928b
...@@ -840,7 +840,7 @@ static const struct devlink_trap_group mlx5_trap_groups_arr[] = { ...@@ -840,7 +840,7 @@ static const struct devlink_trap_group mlx5_trap_groups_arr[] = {
DEVLINK_TRAP_GROUP_GENERIC(L2_DROPS, 0), DEVLINK_TRAP_GROUP_GENERIC(L2_DROPS, 0),
}; };
static int mlx5_devlink_traps_register(struct devlink *devlink) int mlx5_devlink_traps_register(struct devlink *devlink)
{ {
struct mlx5_core_dev *core_dev = devlink_priv(devlink); struct mlx5_core_dev *core_dev = devlink_priv(devlink);
int err; int err;
...@@ -862,7 +862,7 @@ static int mlx5_devlink_traps_register(struct devlink *devlink) ...@@ -862,7 +862,7 @@ static int mlx5_devlink_traps_register(struct devlink *devlink)
return err; return err;
} }
static void mlx5_devlink_traps_unregister(struct devlink *devlink) void mlx5_devlink_traps_unregister(struct devlink *devlink)
{ {
devl_traps_unregister(devlink, mlx5_traps_arr, ARRAY_SIZE(mlx5_traps_arr)); devl_traps_unregister(devlink, mlx5_traps_arr, ARRAY_SIZE(mlx5_traps_arr));
devl_trap_groups_unregister(devlink, mlx5_trap_groups_arr, devl_trap_groups_unregister(devlink, mlx5_trap_groups_arr,
...@@ -889,17 +889,11 @@ int mlx5_devlink_register(struct devlink *devlink) ...@@ -889,17 +889,11 @@ int mlx5_devlink_register(struct devlink *devlink)
if (err) if (err)
goto max_uc_list_err; goto max_uc_list_err;
err = mlx5_devlink_traps_register(devlink);
if (err)
goto traps_reg_err;
if (!mlx5_core_is_mp_slave(dev)) if (!mlx5_core_is_mp_slave(dev))
devlink_set_features(devlink, DEVLINK_F_RELOAD); devlink_set_features(devlink, DEVLINK_F_RELOAD);
return 0; return 0;
traps_reg_err:
mlx5_devlink_max_uc_list_param_unregister(devlink);
max_uc_list_err: max_uc_list_err:
mlx5_devlink_auxdev_params_unregister(devlink); mlx5_devlink_auxdev_params_unregister(devlink);
auxdev_reg_err: auxdev_reg_err:
...@@ -910,7 +904,6 @@ int mlx5_devlink_register(struct devlink *devlink) ...@@ -910,7 +904,6 @@ int mlx5_devlink_register(struct devlink *devlink)
void mlx5_devlink_unregister(struct devlink *devlink) void mlx5_devlink_unregister(struct devlink *devlink)
{ {
mlx5_devlink_traps_unregister(devlink);
mlx5_devlink_max_uc_list_param_unregister(devlink); mlx5_devlink_max_uc_list_param_unregister(devlink);
mlx5_devlink_auxdev_params_unregister(devlink); mlx5_devlink_auxdev_params_unregister(devlink);
devlink_params_unregister(devlink, mlx5_devlink_params, devlink_params_unregister(devlink, mlx5_devlink_params,
......
...@@ -30,6 +30,8 @@ void mlx5_devlink_trap_report(struct mlx5_core_dev *dev, int trap_id, struct sk_ ...@@ -30,6 +30,8 @@ void mlx5_devlink_trap_report(struct mlx5_core_dev *dev, int trap_id, struct sk_
int mlx5_devlink_trap_get_num_active(struct mlx5_core_dev *dev); int mlx5_devlink_trap_get_num_active(struct mlx5_core_dev *dev);
int mlx5_devlink_traps_get_action(struct mlx5_core_dev *dev, int trap_id, int mlx5_devlink_traps_get_action(struct mlx5_core_dev *dev, int trap_id,
enum devlink_trap_action *action); enum devlink_trap_action *action);
int mlx5_devlink_traps_register(struct devlink *devlink);
void mlx5_devlink_traps_unregister(struct devlink *devlink);
struct devlink *mlx5_devlink_alloc(struct device *dev); struct devlink *mlx5_devlink_alloc(struct device *dev);
void mlx5_devlink_free(struct devlink *devlink); void mlx5_devlink_free(struct devlink *devlink);
......
...@@ -1306,8 +1306,15 @@ static int mlx5_load(struct mlx5_core_dev *dev) ...@@ -1306,8 +1306,15 @@ static int mlx5_load(struct mlx5_core_dev *dev)
mlx5_sf_dev_table_create(dev); mlx5_sf_dev_table_create(dev);
err = mlx5_devlink_traps_register(priv_to_devlink(dev));
if (err)
goto err_traps_reg;
return 0; return 0;
err_traps_reg:
mlx5_sf_dev_table_destroy(dev);
mlx5_sriov_detach(dev);
err_sriov: err_sriov:
mlx5_lag_remove_mdev(dev); mlx5_lag_remove_mdev(dev);
mlx5_ec_cleanup(dev); mlx5_ec_cleanup(dev);
...@@ -1336,6 +1343,7 @@ static int mlx5_load(struct mlx5_core_dev *dev) ...@@ -1336,6 +1343,7 @@ static int mlx5_load(struct mlx5_core_dev *dev)
static void mlx5_unload(struct mlx5_core_dev *dev) static void mlx5_unload(struct mlx5_core_dev *dev)
{ {
mlx5_devlink_traps_unregister(priv_to_devlink(dev));
mlx5_sf_dev_table_destroy(dev); mlx5_sf_dev_table_destroy(dev);
mlx5_sriov_detach(dev); mlx5_sriov_detach(dev);
mlx5_eswitch_disable(dev->priv.eswitch); mlx5_eswitch_disable(dev->priv.eswitch);
......
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