]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net/mlx5: E-switch, Set to legacy mode if failed to change switchdev mode
authorChris Mi <cmi@nvidia.com>
Thu, 3 Nov 2022 06:55:39 +0000 (23:55 -0700)
committerSaeed Mahameed <saeedm@nvidia.com>
Wed, 9 Nov 2022 18:30:42 +0000 (10:30 -0800)
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: f019679ea5f2 ("net/mlx5: E-switch, Remove dependency between sriov and eswitch mode")
Signed-off-by: Chris Mi <cmi@nvidia.com>
Reviewed-by: Roi Dayan <roid@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c

index c59107fa9e6d2d8f87031ea12ef2d345461c2d7d..2169486c4bfb3812d19330984e37c8abc545faca 100644 (file)
@@ -1387,12 +1387,14 @@ void mlx5_eswitch_disable_locked(struct mlx5_eswitch *esw)
                 esw->mode == MLX5_ESWITCH_LEGACY ? "LEGACY" : "OFFLOADS",
                 esw->esw_funcs.num_vfs, esw->enabled_vports);
 
-       esw->fdb_table.flags &= ~MLX5_ESW_FDB_CREATED;
-       if (esw->mode == MLX5_ESWITCH_OFFLOADS)
-               esw_offloads_disable(esw);
-       else if (esw->mode == MLX5_ESWITCH_LEGACY)
-               esw_legacy_disable(esw);
-       mlx5_esw_acls_ns_cleanup(esw);
+       if (esw->fdb_table.flags & MLX5_ESW_FDB_CREATED) {
+               esw->fdb_table.flags &= ~MLX5_ESW_FDB_CREATED;
+               if (esw->mode == MLX5_ESWITCH_OFFLOADS)
+                       esw_offloads_disable(esw);
+               else if (esw->mode == MLX5_ESWITCH_LEGACY)
+                       esw_legacy_disable(esw);
+               mlx5_esw_acls_ns_cleanup(esw);
+       }
 
        if (esw->mode == MLX5_ESWITCH_OFFLOADS)
                devl_rate_nodes_destroy(devlink);
index 4e50df3139c68e7b02f5dc88f2b5506d4b022745..728ca9f2bb9d60b86b6cf8ee3b110d36308d7ea8 100644 (file)
@@ -2310,7 +2310,7 @@ out_free:
 static int esw_offloads_start(struct mlx5_eswitch *esw,
                              struct netlink_ext_ack *extack)
 {
-       int err, err1;
+       int err;
 
        esw->mode = MLX5_ESWITCH_OFFLOADS;
        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,
                NL_SET_ERR_MSG_MOD(extack,
                                   "Failed setting eswitch to offloads");
                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);
        }
        if (esw->offloads.inline_mode == MLX5_INLINE_MODE_NONE) {
@@ -3389,19 +3384,12 @@ err_metadata:
 static int esw_offloads_stop(struct mlx5_eswitch *esw,
                             struct netlink_ext_ack *extack)
 {
-       int err, err1;
+       int err;
 
        esw->mode = MLX5_ESWITCH_LEGACY;
        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");
-               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;
 }