]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net/mlx5: Prevent flow steering mode changes in switchdev mode
authorMoshe Shemesh <moshe@nvidia.com>
Mon, 25 Aug 2025 14:34:31 +0000 (17:34 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 4 Sep 2025 14:55:41 +0000 (16:55 +0200)
[ Upstream commit cf9a8627b9a369ba01d37be6f71b297beb688faa ]

Changing flow steering modes is not allowed when eswitch is in switchdev
mode. This fix ensures that any steering mode change, including to
firmware steering, is correctly blocked while eswitch mode is switchdev.

Fixes: e890acd5ff18 ("net/mlx5: Add devlink flow_steering_mode parameter")
Signed-off-by: Moshe Shemesh <moshe@nvidia.com>
Signed-off-by: Mark Bloch <mbloch@nvidia.com>
Link: https://patch.msgid.link/20250825143435.598584-9-mbloch@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/mellanox/mlx5/core/fs_core.c

index 3dd9a6f407092f736a9a6c061bb5d0036e872545..29ce09af59aef0cf7a01e5c69a52b57c2873880a 100644 (file)
@@ -3706,6 +3706,13 @@ static int mlx5_fs_mode_validate(struct devlink *devlink, u32 id,
        char *value = val.vstr;
        u8 eswitch_mode;
 
+       eswitch_mode = mlx5_eswitch_mode(dev);
+       if (eswitch_mode == MLX5_ESWITCH_OFFLOADS) {
+               NL_SET_ERR_MSG_FMT_MOD(extack,
+                                      "Changing fs mode is not supported when eswitch offloads enabled.");
+               return -EOPNOTSUPP;
+       }
+
        if (!strcmp(value, "dmfs"))
                return 0;
 
@@ -3731,14 +3738,6 @@ static int mlx5_fs_mode_validate(struct devlink *devlink, u32 id,
                return -EINVAL;
        }
 
-       eswitch_mode = mlx5_eswitch_mode(dev);
-       if (eswitch_mode == MLX5_ESWITCH_OFFLOADS) {
-               NL_SET_ERR_MSG_FMT_MOD(extack,
-                                      "Moving to %s is not supported when eswitch offloads enabled.",
-                                      value);
-               return -EOPNOTSUPP;
-       }
-
        return 0;
 }