mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-28 13:22:57 +00:00
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
3 changed files with 19 additions and 5 deletions
|
@ -87,11 +87,11 @@ int mlx5_esw_offloads_devlink_port_register(struct mlx5_eswitch *esw, u16 vport_
|
||||||
|
|
||||||
devlink = priv_to_devlink(dev);
|
devlink = priv_to_devlink(dev);
|
||||||
dl_port_index = mlx5_esw_vport_to_devlink_port_index(dev, vport_num);
|
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)
|
if (err)
|
||||||
goto reg_err;
|
goto reg_err;
|
||||||
|
|
||||||
err = devlink_rate_leaf_create(dl_port, vport);
|
err = devl_rate_leaf_create(dl_port, vport);
|
||||||
if (err)
|
if (err)
|
||||||
goto rate_err;
|
goto rate_err;
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ int mlx5_esw_offloads_devlink_port_register(struct mlx5_eswitch *esw, u16 vport_
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
rate_err:
|
rate_err:
|
||||||
devlink_port_unregister(dl_port);
|
devl_port_unregister(dl_port);
|
||||||
reg_err:
|
reg_err:
|
||||||
mlx5_esw_dl_port_free(dl_port);
|
mlx5_esw_dl_port_free(dl_port);
|
||||||
return err;
|
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) {
|
if (vport->dl_port->devlink_rate) {
|
||||||
mlx5_esw_qos_vport_update_group(esw, vport, NULL, NULL);
|
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);
|
mlx5_esw_dl_port_free(vport->dl_port);
|
||||||
vport->dl_port = NULL;
|
vport->dl_port = NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1296,6 +1296,7 @@ int mlx5_eswitch_enable_locked(struct mlx5_eswitch *esw, int num_vfs)
|
||||||
*/
|
*/
|
||||||
int mlx5_eswitch_enable(struct mlx5_eswitch *esw, int num_vfs)
|
int mlx5_eswitch_enable(struct mlx5_eswitch *esw, int num_vfs)
|
||||||
{
|
{
|
||||||
|
struct devlink *devlink;
|
||||||
bool toggle_lag;
|
bool toggle_lag;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -1307,6 +1308,8 @@ int mlx5_eswitch_enable(struct mlx5_eswitch *esw, int num_vfs)
|
||||||
if (toggle_lag)
|
if (toggle_lag)
|
||||||
mlx5_lag_disable_change(esw->dev);
|
mlx5_lag_disable_change(esw->dev);
|
||||||
|
|
||||||
|
devlink = priv_to_devlink(esw->dev);
|
||||||
|
devl_lock(devlink);
|
||||||
down_write(&esw->mode_lock);
|
down_write(&esw->mode_lock);
|
||||||
if (!mlx5_esw_is_fdb_created(esw)) {
|
if (!mlx5_esw_is_fdb_created(esw)) {
|
||||||
ret = mlx5_eswitch_enable_locked(esw, num_vfs);
|
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;
|
esw->esw_funcs.num_vfs = num_vfs;
|
||||||
}
|
}
|
||||||
up_write(&esw->mode_lock);
|
up_write(&esw->mode_lock);
|
||||||
|
devl_unlock(devlink);
|
||||||
|
|
||||||
if (toggle_lag)
|
if (toggle_lag)
|
||||||
mlx5_lag_enable_change(esw->dev);
|
mlx5_lag_enable_change(esw->dev);
|
||||||
|
|
|
@ -2177,8 +2177,10 @@ static int esw_create_restore_table(struct mlx5_eswitch *esw)
|
||||||
static int esw_offloads_start(struct mlx5_eswitch *esw,
|
static int esw_offloads_start(struct mlx5_eswitch *esw,
|
||||||
struct netlink_ext_ack *extack)
|
struct netlink_ext_ack *extack)
|
||||||
{
|
{
|
||||||
|
struct devlink *devlink = priv_to_devlink(esw->dev);
|
||||||
int err, err1;
|
int err, err1;
|
||||||
|
|
||||||
|
devl_lock(devlink);
|
||||||
esw->mode = MLX5_ESWITCH_OFFLOADS;
|
esw->mode = MLX5_ESWITCH_OFFLOADS;
|
||||||
err = mlx5_eswitch_enable_locked(esw, esw->dev->priv.sriov.num_vfs);
|
err = mlx5_eswitch_enable_locked(esw, esw->dev->priv.sriov.num_vfs);
|
||||||
if (err) {
|
if (err) {
|
||||||
|
@ -2200,6 +2202,7 @@ static int esw_offloads_start(struct mlx5_eswitch *esw,
|
||||||
"Inline mode is different between vports");
|
"Inline mode is different between vports");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
devl_unlock(devlink);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3064,6 +3067,7 @@ static void esw_offloads_steering_cleanup(struct mlx5_eswitch *esw)
|
||||||
static void
|
static void
|
||||||
esw_vfs_changed_event_handler(struct mlx5_eswitch *esw, const u32 *out)
|
esw_vfs_changed_event_handler(struct mlx5_eswitch *esw, const u32 *out)
|
||||||
{
|
{
|
||||||
|
struct devlink *devlink;
|
||||||
bool host_pf_disabled;
|
bool host_pf_disabled;
|
||||||
u16 new_num_vfs;
|
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)
|
if (new_num_vfs == esw->esw_funcs.num_vfs || host_pf_disabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
devlink = priv_to_devlink(esw->dev);
|
||||||
|
devl_lock(devlink);
|
||||||
/* Number of VFs can only change from "0 to x" or "x to 0". */
|
/* Number of VFs can only change from "0 to x" or "x to 0". */
|
||||||
if (esw->esw_funcs.num_vfs > 0) {
|
if (esw->esw_funcs.num_vfs > 0) {
|
||||||
mlx5_eswitch_unload_vf_vports(esw, esw->esw_funcs.num_vfs);
|
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;
|
return;
|
||||||
}
|
}
|
||||||
esw->esw_funcs.num_vfs = new_num_vfs;
|
esw->esw_funcs.num_vfs = new_num_vfs;
|
||||||
|
devl_unlock(devlink);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void esw_functions_changed_event_handler(struct work_struct *work)
|
static void esw_functions_changed_event_handler(struct work_struct *work)
|
||||||
|
@ -3236,8 +3243,10 @@ int esw_offloads_enable(struct mlx5_eswitch *esw)
|
||||||
static int esw_offloads_stop(struct mlx5_eswitch *esw,
|
static int esw_offloads_stop(struct mlx5_eswitch *esw,
|
||||||
struct netlink_ext_ack *extack)
|
struct netlink_ext_ack *extack)
|
||||||
{
|
{
|
||||||
|
struct devlink *devlink = priv_to_devlink(esw->dev);
|
||||||
int err, err1;
|
int err, err1;
|
||||||
|
|
||||||
|
devl_lock(devlink);
|
||||||
esw->mode = MLX5_ESWITCH_LEGACY;
|
esw->mode = MLX5_ESWITCH_LEGACY;
|
||||||
err = mlx5_eswitch_enable_locked(esw, MLX5_ESWITCH_IGNORE_NUM_VFS);
|
err = mlx5_eswitch_enable_locked(esw, MLX5_ESWITCH_IGNORE_NUM_VFS);
|
||||||
if (err) {
|
if (err) {
|
||||||
|
@ -3249,6 +3258,7 @@ static int esw_offloads_stop(struct mlx5_eswitch *esw,
|
||||||
"Failed setting eswitch back to offloads");
|
"Failed setting eswitch back to offloads");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
devl_unlock(devlink);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue