Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 079adf05 authored by Eran Ben Elisha's avatar Eran Ben Elisha Committed by Saeed Mahameed
Browse files

net/mlx5: Clean SRIOV eswitch resources upon VF creation failure



Upon sriov enable, eswitch is always enabled.
Currently, if enable hca failed over all VFs, we would skip eswitch
disable as part of sriov disable, which will lead to resources leak.

Fix it by disabling eswitch if it was enabled (use indication from
eswitch mode).

Fixes: 6b6adee3 ('net/mlx5: SRIOV core code refactoring')
Signed-off-by: default avatarEran Ben Elisha <eranbe@mellanox.com>
Signed-off-by: default avatarNoa Osherovich <noaos@mellanox.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
parent 6b84202c
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -1668,7 +1668,8 @@ void mlx5_eswitch_disable_sriov(struct mlx5_eswitch *esw)
	int i;
	int i;


	if (!esw || !MLX5_CAP_GEN(esw->dev, vport_group_manager) ||
	if (!esw || !MLX5_CAP_GEN(esw->dev, vport_group_manager) ||
	    MLX5_CAP_GEN(esw->dev, port_type) != MLX5_CAP_PORT_TYPE_ETH)
	    MLX5_CAP_GEN(esw->dev, port_type) != MLX5_CAP_PORT_TYPE_ETH ||
	    esw->mode == SRIOV_NONE)
		return;
		return;


	esw_info(esw->dev, "disable SRIOV: active vports(%d) mode(%d)\n",
	esw_info(esw->dev, "disable SRIOV: active vports(%d) mode(%d)\n",
+5 −0
Original line number Original line Diff line number Diff line
@@ -88,7 +88,11 @@ static void mlx5_device_disable_sriov(struct mlx5_core_dev *dev)
	int vf;
	int vf;


	if (!sriov->enabled_vfs)
	if (!sriov->enabled_vfs)
#ifdef CONFIG_MLX5_CORE_EN
		goto disable_sriov_resources;
#else
		return;
		return;
#endif


	for (vf = 0; vf < sriov->num_vfs; vf++) {
	for (vf = 0; vf < sriov->num_vfs; vf++) {
		if (!sriov->vfs_ctx[vf].enabled)
		if (!sriov->vfs_ctx[vf].enabled)
@@ -103,6 +107,7 @@ static void mlx5_device_disable_sriov(struct mlx5_core_dev *dev)
	}
	}


#ifdef CONFIG_MLX5_CORE_EN
#ifdef CONFIG_MLX5_CORE_EN
disable_sriov_resources:
	mlx5_eswitch_disable_sriov(dev->priv.eswitch);
	mlx5_eswitch_disable_sriov(dev->priv.eswitch);
#endif
#endif