Commit ee4f9cf9 authored by Shay Drory's avatar Shay Drory Committed by Ma Wupeng
Browse files

net/mlx5: Enable 4 ports multiport E-switch

stable inclusion
from stable-v6.6.33
commit 66a5f6e09c63e28822c3fec579f059b4b196309a
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IAD6H2

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=66a5f6e09c63e28822c3fec579f059b4b196309a



--------------------------------

[ Upstream commit e738e355045237ee8802cb2b31a8ed6f4b7ac534 ]

enable_mpesw() assumed only 2 ports are available, fix this by removing
that assumption and looping through the existing lag ports to enable multi-port
E-switch for cards with more than 2 ports.

Signed-off-by: default avatarShay Drory <shayd@nvidia.com>
Reviewed-by: default avatarMark Bloch <mbloch@nvidia.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
Stable-dep-of: 0f06228d4a2d ("net/mlx5: Reload only IB representors upon lag disable/enable")
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarWang Hai <wanghai38@huawei.com>
parent c7a630d5
Loading
Loading
Loading
Loading
+9 −9
Original line number Diff line number Diff line
@@ -65,12 +65,12 @@ static int mlx5_mpesw_metadata_set(struct mlx5_lag *ldev)
	return err;
}

#define MLX5_LAG_MPESW_OFFLOADS_SUPPORTED_PORTS 2
#define MLX5_LAG_MPESW_OFFLOADS_SUPPORTED_PORTS 4
static int enable_mpesw(struct mlx5_lag *ldev)
{
	struct mlx5_core_dev *dev0 = ldev->pf[MLX5_LAG_P1].dev;
	struct mlx5_core_dev *dev1 = ldev->pf[MLX5_LAG_P2].dev;
	int err;
	int i;

	if (ldev->mode != MLX5_LAG_MODE_NONE)
		return -EINVAL;
@@ -98,11 +98,11 @@ static int enable_mpesw(struct mlx5_lag *ldev)

	dev0->priv.flags &= ~MLX5_PRIV_FLAGS_DISABLE_IB_ADEV;
	mlx5_rescan_drivers_locked(dev0);
	err = mlx5_eswitch_reload_reps(dev0->priv.eswitch);
	if (!err)
		err = mlx5_eswitch_reload_reps(dev1->priv.eswitch);
	for (i = 0; i < ldev->ports; i++) {
		err = mlx5_eswitch_reload_reps(ldev->pf[i].dev->priv.eswitch);
		if (err)
			goto err_rescan_drivers;
	}

	return 0;

@@ -112,8 +112,8 @@ static int enable_mpesw(struct mlx5_lag *ldev)
	mlx5_deactivate_lag(ldev);
err_add_devices:
	mlx5_lag_add_devices(ldev);
	mlx5_eswitch_reload_reps(dev0->priv.eswitch);
	mlx5_eswitch_reload_reps(dev1->priv.eswitch);
	for (i = 0; i < ldev->ports; i++)
		mlx5_eswitch_reload_reps(ldev->pf[i].dev->priv.eswitch);
	mlx5_mpesw_metadata_cleanup(ldev);
	return err;
}