mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-07-25 10:53:34 -04:00
net/mlx5: Lag: refactor representor reload handling
Representor reload during LAG/MPESW transitions has to be repeated in several flows, and each open-coded loop was easy to get out of sync when adding new flags or tweaking error handling. Move the sequencing into a single helper so that all call sites share the same ordering and checks. Signed-off-by: Mark Bloch <mbloch@nvidia.com> Reviewed-by: Shay Drori <shayd@nvidia.com> Signed-off-by: Tariq Toukan <tariqt@nvidia.com> Link: https://patch.msgid.link/20260503202726.266415-2-tariqt@nvidia.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
c978803c5d
commit
b501400fa6
@@ -1093,6 +1093,27 @@ void mlx5_lag_remove_devices(struct mlx5_lag *ldev)
|
||||
}
|
||||
}
|
||||
|
||||
int mlx5_lag_reload_ib_reps(struct mlx5_lag *ldev, u32 flags, bool cont_on_fail)
|
||||
{
|
||||
struct lag_func *pf;
|
||||
int ret;
|
||||
int i;
|
||||
|
||||
mlx5_ldev_for_each(i, 0, ldev) {
|
||||
pf = mlx5_lag_pf(ldev, i);
|
||||
if (!(pf->dev->priv.flags & flags)) {
|
||||
struct mlx5_eswitch *esw;
|
||||
|
||||
esw = pf->dev->priv.eswitch;
|
||||
ret = mlx5_eswitch_reload_ib_reps(esw);
|
||||
if (ret && !cont_on_fail)
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void mlx5_disable_lag(struct mlx5_lag *ldev)
|
||||
{
|
||||
bool shared_fdb = test_bit(MLX5_LAG_MODE_FLAG_SHARED_FDB, &ldev->mode_flags);
|
||||
@@ -1130,9 +1151,8 @@ void mlx5_disable_lag(struct mlx5_lag *ldev)
|
||||
mlx5_lag_add_devices(ldev);
|
||||
|
||||
if (shared_fdb)
|
||||
mlx5_ldev_for_each(i, 0, ldev)
|
||||
if (!(mlx5_lag_pf(ldev, i)->dev->priv.flags & MLX5_PRIV_FLAGS_DISABLE_ALL_ADEV))
|
||||
mlx5_eswitch_reload_ib_reps(mlx5_lag_pf(ldev, i)->dev->priv.eswitch);
|
||||
mlx5_lag_reload_ib_reps(ldev, MLX5_PRIV_FLAGS_DISABLE_ALL_ADEV,
|
||||
true);
|
||||
}
|
||||
|
||||
bool mlx5_lag_shared_fdb_supported(struct mlx5_lag *ldev)
|
||||
@@ -1388,10 +1408,8 @@ static void mlx5_do_bond(struct mlx5_lag *ldev)
|
||||
if (err) {
|
||||
if (shared_fdb || roce_lag)
|
||||
mlx5_lag_add_devices(ldev);
|
||||
if (shared_fdb) {
|
||||
mlx5_ldev_for_each(i, 0, ldev)
|
||||
mlx5_eswitch_reload_ib_reps(mlx5_lag_pf(ldev, i)->dev->priv.eswitch);
|
||||
}
|
||||
if (shared_fdb)
|
||||
mlx5_lag_reload_ib_reps(ldev, 0, true);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -1409,24 +1427,15 @@ static void mlx5_do_bond(struct mlx5_lag *ldev)
|
||||
mlx5_nic_vport_enable_roce(dev);
|
||||
}
|
||||
} else if (shared_fdb) {
|
||||
int i;
|
||||
|
||||
dev0->priv.flags &= ~MLX5_PRIV_FLAGS_DISABLE_IB_ADEV;
|
||||
mlx5_rescan_drivers_locked(dev0);
|
||||
|
||||
mlx5_ldev_for_each(i, 0, ldev) {
|
||||
err = mlx5_eswitch_reload_ib_reps(mlx5_lag_pf(ldev, i)->dev->priv.eswitch);
|
||||
if (err)
|
||||
break;
|
||||
}
|
||||
|
||||
err = mlx5_lag_reload_ib_reps(ldev, 0, false);
|
||||
if (err) {
|
||||
dev0->priv.flags |= MLX5_PRIV_FLAGS_DISABLE_IB_ADEV;
|
||||
mlx5_rescan_drivers_locked(dev0);
|
||||
mlx5_deactivate_lag(ldev);
|
||||
mlx5_lag_add_devices(ldev);
|
||||
mlx5_ldev_for_each(i, 0, ldev)
|
||||
mlx5_eswitch_reload_ib_reps(mlx5_lag_pf(ldev, i)->dev->priv.eswitch);
|
||||
mlx5_lag_reload_ib_reps(ldev, 0, true);
|
||||
mlx5_core_err(dev0, "Failed to enable lag\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -199,4 +199,6 @@ int mlx5_get_next_ldev_func(struct mlx5_lag *ldev, int start_idx);
|
||||
int mlx5_lag_get_dev_index_by_seq(struct mlx5_lag *ldev, int seq);
|
||||
int mlx5_lag_num_devs(struct mlx5_lag *ldev);
|
||||
int mlx5_lag_num_netdevs(struct mlx5_lag *ldev);
|
||||
int mlx5_lag_reload_ib_reps(struct mlx5_lag *ldev, u32 flags,
|
||||
bool cont_on_fail);
|
||||
#endif /* __MLX5_LAG_H__ */
|
||||
|
||||
@@ -70,7 +70,6 @@ static int mlx5_lag_enable_mpesw(struct mlx5_lag *ldev)
|
||||
int idx = mlx5_lag_get_dev_index_by_seq(ldev, MLX5_LAG_P1);
|
||||
struct mlx5_core_dev *dev0;
|
||||
int err;
|
||||
int i;
|
||||
|
||||
if (ldev->mode == MLX5_LAG_MODE_MPESW)
|
||||
return 0;
|
||||
@@ -103,11 +102,9 @@ static int mlx5_lag_enable_mpesw(struct mlx5_lag *ldev)
|
||||
|
||||
dev0->priv.flags &= ~MLX5_PRIV_FLAGS_DISABLE_IB_ADEV;
|
||||
mlx5_rescan_drivers_locked(dev0);
|
||||
mlx5_ldev_for_each(i, 0, ldev) {
|
||||
err = mlx5_eswitch_reload_ib_reps(mlx5_lag_pf(ldev, i)->dev->priv.eswitch);
|
||||
if (err)
|
||||
goto err_rescan_drivers;
|
||||
}
|
||||
err = mlx5_lag_reload_ib_reps(ldev, 0, false);
|
||||
if (err)
|
||||
goto err_rescan_drivers;
|
||||
|
||||
mlx5_lag_set_vports_agg_speed(ldev);
|
||||
|
||||
@@ -119,8 +116,7 @@ static int mlx5_lag_enable_mpesw(struct mlx5_lag *ldev)
|
||||
mlx5_deactivate_lag(ldev);
|
||||
err_add_devices:
|
||||
mlx5_lag_add_devices(ldev);
|
||||
mlx5_ldev_for_each(i, 0, ldev)
|
||||
mlx5_eswitch_reload_ib_reps(mlx5_lag_pf(ldev, i)->dev->priv.eswitch);
|
||||
mlx5_lag_reload_ib_reps(ldev, 0, true);
|
||||
mlx5_mpesw_metadata_cleanup(ldev);
|
||||
return err;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user