Commit e12de39c authored by Chris Mi's avatar Chris Mi Committed by Saeed Mahameed

net/mlx5: E-switch, Set to legacy mode if failed to change switchdev mode

No need to rollback to the other mode because probably will fail
again. Just set to legacy mode and clear fdb table created flag.
So that fdb table will not be cleared again.

Fixes: f019679e ("net/mlx5: E-switch, Remove dependency between sriov and eswitch mode")
Signed-off-by: default avatarChris Mi <cmi@nvidia.com>
Reviewed-by: default avatarRoi Dayan <roid@nvidia.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
parent 2808b37b
...@@ -1387,12 +1387,14 @@ void mlx5_eswitch_disable_locked(struct mlx5_eswitch *esw) ...@@ -1387,12 +1387,14 @@ void mlx5_eswitch_disable_locked(struct mlx5_eswitch *esw)
esw->mode == MLX5_ESWITCH_LEGACY ? "LEGACY" : "OFFLOADS", esw->mode == MLX5_ESWITCH_LEGACY ? "LEGACY" : "OFFLOADS",
esw->esw_funcs.num_vfs, esw->enabled_vports); esw->esw_funcs.num_vfs, esw->enabled_vports);
esw->fdb_table.flags &= ~MLX5_ESW_FDB_CREATED; if (esw->fdb_table.flags & MLX5_ESW_FDB_CREATED) {
if (esw->mode == MLX5_ESWITCH_OFFLOADS) esw->fdb_table.flags &= ~MLX5_ESW_FDB_CREATED;
esw_offloads_disable(esw); if (esw->mode == MLX5_ESWITCH_OFFLOADS)
else if (esw->mode == MLX5_ESWITCH_LEGACY) esw_offloads_disable(esw);
esw_legacy_disable(esw); else if (esw->mode == MLX5_ESWITCH_LEGACY)
mlx5_esw_acls_ns_cleanup(esw); esw_legacy_disable(esw);
mlx5_esw_acls_ns_cleanup(esw);
}
if (esw->mode == MLX5_ESWITCH_OFFLOADS) if (esw->mode == MLX5_ESWITCH_OFFLOADS)
devl_rate_nodes_destroy(devlink); devl_rate_nodes_destroy(devlink);
......
...@@ -2310,7 +2310,7 @@ static int esw_create_restore_table(struct mlx5_eswitch *esw) ...@@ -2310,7 +2310,7 @@ 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)
{ {
int err, err1; int err;
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);
...@@ -2318,11 +2318,6 @@ static int esw_offloads_start(struct mlx5_eswitch *esw, ...@@ -2318,11 +2318,6 @@ static int esw_offloads_start(struct mlx5_eswitch *esw,
NL_SET_ERR_MSG_MOD(extack, NL_SET_ERR_MSG_MOD(extack,
"Failed setting eswitch to offloads"); "Failed setting eswitch to offloads");
esw->mode = MLX5_ESWITCH_LEGACY; esw->mode = MLX5_ESWITCH_LEGACY;
err1 = mlx5_eswitch_enable_locked(esw, MLX5_ESWITCH_IGNORE_NUM_VFS);
if (err1) {
NL_SET_ERR_MSG_MOD(extack,
"Failed setting eswitch back to legacy");
}
mlx5_rescan_drivers(esw->dev); mlx5_rescan_drivers(esw->dev);
} }
if (esw->offloads.inline_mode == MLX5_INLINE_MODE_NONE) { if (esw->offloads.inline_mode == MLX5_INLINE_MODE_NONE) {
...@@ -3389,19 +3384,12 @@ int esw_offloads_enable(struct mlx5_eswitch *esw) ...@@ -3389,19 +3384,12 @@ 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)
{ {
int err, err1; int err;
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)
NL_SET_ERR_MSG_MOD(extack, "Failed setting eswitch to legacy"); NL_SET_ERR_MSG_MOD(extack, "Failed setting eswitch to legacy");
esw->mode = MLX5_ESWITCH_OFFLOADS;
err1 = mlx5_eswitch_enable_locked(esw, MLX5_ESWITCH_IGNORE_NUM_VFS);
if (err1) {
NL_SET_ERR_MSG_MOD(extack,
"Failed setting eswitch back to offloads");
}
}
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment