Skip to content

Commit 3b5ff59

Browse files
Rabie LoulouSaeed Mahameed
authored andcommitted
net/mlx5: Adjustments for the activate LAG logic to run under sriov
When HW lag is set/unset, roce must not be enabled on the port, as such we wrap such changes with roce enable/disable either directly or through re-creation of IB device. Currently, lag and sriov are mutually exclusive, so by definition this code doesn't run under sriov. Towards changing this exclusion, we need to make sure that roce will not be enabled on the eswitch manager port under sriov since this is requirement of the switchdev mode. We are going strict here and avoiding this all together under sriov. Signed-off-by: Rabie Loulou <[email protected]> Reviewed-by: Or Gerlitz <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 1418ddd commit 3b5ff59

File tree

1 file changed

+21
-12
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core

1 file changed

+21
-12
lines changed

drivers/net/ethernet/mellanox/mlx5/core/lag.c

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include <linux/mlx5/driver.h>
3535
#include <linux/mlx5/vport.h>
3636
#include "mlx5_core.h"
37+
#include "eswitch.h"
3738

3839
enum {
3940
MLX5_LAG_FLAG_BONDED = 1 << 0,
@@ -257,40 +258,48 @@ static void mlx5_do_bond(struct mlx5_lag *ldev)
257258
{
258259
struct mlx5_core_dev *dev0 = ldev->pf[0].dev;
259260
struct mlx5_core_dev *dev1 = ldev->pf[1].dev;
261+
bool do_bond, sriov_enabled;
260262
struct lag_tracker tracker;
261263
int i;
262-
bool do_bond;
263264

264265
if (!dev0 || !dev1)
265266
return;
266267

268+
sriov_enabled = mlx5_sriov_is_enabled(dev0) || mlx5_sriov_is_enabled(dev1);
269+
267270
mutex_lock(&lag_mutex);
268271
tracker = ldev->tracker;
269272
mutex_unlock(&lag_mutex);
270273

271274
do_bond = tracker.is_bonded && ldev->allowed;
272275

273276
if (do_bond && !mlx5_lag_is_bonded(ldev)) {
274-
for (i = 0; i < MLX5_MAX_PORTS; i++)
275-
mlx5_remove_dev_by_protocol(ldev->pf[i].dev,
276-
MLX5_INTERFACE_PROTOCOL_IB);
277+
if (!sriov_enabled)
278+
for (i = 0; i < MLX5_MAX_PORTS; i++)
279+
mlx5_remove_dev_by_protocol(ldev->pf[i].dev,
280+
MLX5_INTERFACE_PROTOCOL_IB);
277281

278282
mlx5_activate_lag(ldev, &tracker);
279283

280-
mlx5_add_dev_by_protocol(dev0, MLX5_INTERFACE_PROTOCOL_IB);
281-
mlx5_nic_vport_enable_roce(dev1);
284+
if (!sriov_enabled) {
285+
mlx5_add_dev_by_protocol(dev0, MLX5_INTERFACE_PROTOCOL_IB);
286+
mlx5_nic_vport_enable_roce(dev1);
287+
}
282288
} else if (do_bond && mlx5_lag_is_bonded(ldev)) {
283289
mlx5_modify_lag(ldev, &tracker);
284290
} else if (!do_bond && mlx5_lag_is_bonded(ldev)) {
285-
mlx5_remove_dev_by_protocol(dev0, MLX5_INTERFACE_PROTOCOL_IB);
286-
mlx5_nic_vport_disable_roce(dev1);
291+
if (!sriov_enabled) {
292+
mlx5_remove_dev_by_protocol(dev0, MLX5_INTERFACE_PROTOCOL_IB);
293+
mlx5_nic_vport_disable_roce(dev1);
294+
}
287295

288296
mlx5_deactivate_lag(ldev);
289297

290-
for (i = 0; i < MLX5_MAX_PORTS; i++)
291-
if (ldev->pf[i].dev)
292-
mlx5_add_dev_by_protocol(ldev->pf[i].dev,
293-
MLX5_INTERFACE_PROTOCOL_IB);
298+
if (!sriov_enabled)
299+
for (i = 0; i < MLX5_MAX_PORTS; i++)
300+
if (ldev->pf[i].dev)
301+
mlx5_add_dev_by_protocol(ldev->pf[i].dev,
302+
MLX5_INTERFACE_PROTOCOL_IB);
294303
}
295304
}
296305

0 commit comments

Comments
 (0)