net/mlx5: Use devl_ API in mlx5_esw_offloads_devlink_port_register
The function mlx5_esw_offloads_devlink_port_register() calls devlink_port_register() and devlink_rate_leaf_create(). Use devl_ API to call devl_port_register() and devl_rate_leaf_create() accordingly and add devlink instance lock in driver paths to this function. Similarly, use devl_ API to call devl_port_unregister() and devl_rate_leaf_destroy() in mlx5_esw_offloads_devlink_port_unregister() and ensure locking devlink instance lock on the paths to this function too. This will be used by the downstream patch to invoke mlx5_devlink_eswitch_mode_set() with devlink lock held. Signed-off-by: Moshe Shemesh <moshe@nvidia.com> Reviewed-by: Leon Romanovsky <leonro@nvidia.com> Signed-off-by: Saeed Mahameed <saeedm@nvidia.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
parent
868232f5cd
commit
f1bc646c9a
@ -87,11 +87,11 @@ int mlx5_esw_offloads_devlink_port_register(struct mlx5_eswitch *esw, u16 vport_
|
||||
|
||||
devlink = priv_to_devlink(dev);
|
||||
dl_port_index = mlx5_esw_vport_to_devlink_port_index(dev, vport_num);
|
||||
err = devlink_port_register(devlink, dl_port, dl_port_index);
|
||||
err = devl_port_register(devlink, dl_port, dl_port_index);
|
||||
if (err)
|
||||
goto reg_err;
|
||||
|
||||
err = devlink_rate_leaf_create(dl_port, vport);
|
||||
err = devl_rate_leaf_create(dl_port, vport);
|
||||
if (err)
|
||||
goto rate_err;
|
||||
|
||||
@ -99,7 +99,7 @@ int mlx5_esw_offloads_devlink_port_register(struct mlx5_eswitch *esw, u16 vport_
|
||||
return 0;
|
||||
|
||||
rate_err:
|
||||
devlink_port_unregister(dl_port);
|
||||
devl_port_unregister(dl_port);
|
||||
reg_err:
|
||||
mlx5_esw_dl_port_free(dl_port);
|
||||
return err;
|
||||
@ -118,10 +118,10 @@ void mlx5_esw_offloads_devlink_port_unregister(struct mlx5_eswitch *esw, u16 vpo
|
||||
|
||||
if (vport->dl_port->devlink_rate) {
|
||||
mlx5_esw_qos_vport_update_group(esw, vport, NULL, NULL);
|
||||
devlink_rate_leaf_destroy(vport->dl_port);
|
||||
devl_rate_leaf_destroy(vport->dl_port);
|
||||
}
|
||||
|
||||
devlink_port_unregister(vport->dl_port);
|
||||
devl_port_unregister(vport->dl_port);
|
||||
mlx5_esw_dl_port_free(vport->dl_port);
|
||||
vport->dl_port = NULL;
|
||||
}
|
||||
|
@ -1296,6 +1296,7 @@ abort:
|
||||
*/
|
||||
int mlx5_eswitch_enable(struct mlx5_eswitch *esw, int num_vfs)
|
||||
{
|
||||
struct devlink *devlink;
|
||||
bool toggle_lag;
|
||||
int ret;
|
||||
|
||||
@ -1307,6 +1308,8 @@ int mlx5_eswitch_enable(struct mlx5_eswitch *esw, int num_vfs)
|
||||
if (toggle_lag)
|
||||
mlx5_lag_disable_change(esw->dev);
|
||||
|
||||
devlink = priv_to_devlink(esw->dev);
|
||||
devl_lock(devlink);
|
||||
down_write(&esw->mode_lock);
|
||||
if (!mlx5_esw_is_fdb_created(esw)) {
|
||||
ret = mlx5_eswitch_enable_locked(esw, num_vfs);
|
||||
@ -1320,6 +1323,7 @@ int mlx5_eswitch_enable(struct mlx5_eswitch *esw, int num_vfs)
|
||||
esw->esw_funcs.num_vfs = num_vfs;
|
||||
}
|
||||
up_write(&esw->mode_lock);
|
||||
devl_unlock(devlink);
|
||||
|
||||
if (toggle_lag)
|
||||
mlx5_lag_enable_change(esw->dev);
|
||||
|
@ -2177,8 +2177,10 @@ out_free:
|
||||
static int esw_offloads_start(struct mlx5_eswitch *esw,
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
struct devlink *devlink = priv_to_devlink(esw->dev);
|
||||
int err, err1;
|
||||
|
||||
devl_lock(devlink);
|
||||
esw->mode = MLX5_ESWITCH_OFFLOADS;
|
||||
err = mlx5_eswitch_enable_locked(esw, esw->dev->priv.sriov.num_vfs);
|
||||
if (err) {
|
||||
@ -2200,6 +2202,7 @@ static int esw_offloads_start(struct mlx5_eswitch *esw,
|
||||
"Inline mode is different between vports");
|
||||
}
|
||||
}
|
||||
devl_unlock(devlink);
|
||||
return err;
|
||||
}
|
||||
|
||||
@ -3064,6 +3067,7 @@ static void esw_offloads_steering_cleanup(struct mlx5_eswitch *esw)
|
||||
static void
|
||||
esw_vfs_changed_event_handler(struct mlx5_eswitch *esw, const u32 *out)
|
||||
{
|
||||
struct devlink *devlink;
|
||||
bool host_pf_disabled;
|
||||
u16 new_num_vfs;
|
||||
|
||||
@ -3075,6 +3079,8 @@ esw_vfs_changed_event_handler(struct mlx5_eswitch *esw, const u32 *out)
|
||||
if (new_num_vfs == esw->esw_funcs.num_vfs || host_pf_disabled)
|
||||
return;
|
||||
|
||||
devlink = priv_to_devlink(esw->dev);
|
||||
devl_lock(devlink);
|
||||
/* Number of VFs can only change from "0 to x" or "x to 0". */
|
||||
if (esw->esw_funcs.num_vfs > 0) {
|
||||
mlx5_eswitch_unload_vf_vports(esw, esw->esw_funcs.num_vfs);
|
||||
@ -3087,6 +3093,7 @@ esw_vfs_changed_event_handler(struct mlx5_eswitch *esw, const u32 *out)
|
||||
return;
|
||||
}
|
||||
esw->esw_funcs.num_vfs = new_num_vfs;
|
||||
devl_unlock(devlink);
|
||||
}
|
||||
|
||||
static void esw_functions_changed_event_handler(struct work_struct *work)
|
||||
@ -3236,8 +3243,10 @@ err_metadata:
|
||||
static int esw_offloads_stop(struct mlx5_eswitch *esw,
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
struct devlink *devlink = priv_to_devlink(esw->dev);
|
||||
int err, err1;
|
||||
|
||||
devl_lock(devlink);
|
||||
esw->mode = MLX5_ESWITCH_LEGACY;
|
||||
err = mlx5_eswitch_enable_locked(esw, MLX5_ESWITCH_IGNORE_NUM_VFS);
|
||||
if (err) {
|
||||
@ -3249,6 +3258,7 @@ static int esw_offloads_stop(struct mlx5_eswitch *esw,
|
||||
"Failed setting eswitch back to offloads");
|
||||
}
|
||||
}
|
||||
devl_unlock(devlink);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user