]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net/mlx5: SD, keep netdev resources on same PF in switchdev mode
authorShay Drory <shayd@nvidia.com>
Sun, 31 May 2026 11:39:50 +0000 (14:39 +0300)
committerJakub Kicinski <kuba@kernel.org>
Thu, 4 Jun 2026 00:42:21 +0000 (17:42 -0700)
In SD switchdev mode, network device resources such as channels and
completion vectors must remain on the same PF rather than being
distributed across SD group members.

Modify mlx5_sd_ch_ix_get_dev_ix() to return 0 and
mlx5_sd_ch_ix_get_vec_ix() to return the channel index directly when
in switchdev mode, keeping resources local to the requesting PF.

Signed-off-by: Shay Drory <shayd@nvidia.com>
Reviewed-by: Mark Bloch <mbloch@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Link: https://patch.msgid.link/20260531113954.395443-11-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/mellanox/mlx5/core/lib/sd.c

index 8991db3a19cf343ec3c47dca72faeae487c706b1..ec606851feb86a3405073f4782cd2da3948c6906 100644 (file)
@@ -6,6 +6,7 @@
 #include "mlx5_core.h"
 #include "lib/mlx5.h"
 #include "fs_cmd.h"
+#include <linux/mlx5/eswitch.h>
 #include <linux/mlx5/vport.h>
 #include <linux/debugfs.h>
 
@@ -85,11 +86,17 @@ mlx5_sd_primary_get_peer(struct mlx5_core_dev *primary, int idx)
 
 int mlx5_sd_ch_ix_get_dev_ix(struct mlx5_core_dev *dev, int ch_ix)
 {
+       if (is_mdev_switchdev_mode(dev))
+               return 0;
+
        return ch_ix % mlx5_sd_get_host_buses(dev);
 }
 
 int mlx5_sd_ch_ix_get_vec_ix(struct mlx5_core_dev *dev, int ch_ix)
 {
+       if (is_mdev_switchdev_mode(dev))
+               return ch_ix;
+
        return ch_ix / mlx5_sd_get_host_buses(dev);
 }