]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net/mlx5: LAG, replace peer count check with direct peer lookup
authorShay Drory <shayd@nvidia.com>
Sun, 31 May 2026 11:39:44 +0000 (14:39 +0300)
committerJakub Kicinski <kuba@kernel.org>
Thu, 4 Jun 2026 00:42:20 +0000 (17:42 -0700)
Replace mlx5_eswitch_get_npeers() count-based check with a new
mlx5_eswitch_is_peer() function that directly verifies the peer
relationship between two eswitches.

This change prepares for SD LAG support, which is a virtual LAG that
does not have num_lag_ports capability and cannot use the count-based
peer validation.

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-5-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
drivers/net/ethernet/mellanox/mlx5/core/lag/shared_fdb.c

index 8a94c38f8566d83053e64bb0a5fb7269b7d0286f..94a530d19828b66de2bb026e51a34581c066eece 100644 (file)
@@ -955,6 +955,8 @@ int mlx5_eswitch_offloads_single_fdb_add_one(struct mlx5_eswitch *master_esw,
 void mlx5_eswitch_offloads_single_fdb_del_one(struct mlx5_eswitch *master_esw,
                                              struct mlx5_eswitch *slave_esw);
 int mlx5_eswitch_reload_ib_reps(struct mlx5_eswitch *esw);
+bool mlx5_eswitch_is_peer(struct mlx5_eswitch *esw,
+                         struct mlx5_eswitch *peer_esw);
 
 bool mlx5_eswitch_block_encap(struct mlx5_core_dev *dev, bool from_fdb);
 void mlx5_eswitch_unblock_encap(struct mlx5_core_dev *dev);
@@ -970,13 +972,6 @@ static inline int mlx5_eswitch_num_vfs(struct mlx5_eswitch *esw)
        return 0;
 }
 
-static inline int mlx5_eswitch_get_npeers(struct mlx5_eswitch *esw)
-{
-       if (mlx5_esw_allowed(esw))
-               return esw->num_peers;
-       return 0;
-}
-
 static inline struct mlx5_flow_table *
 mlx5_eswitch_get_slow_fdb(struct mlx5_eswitch *esw)
 {
@@ -1058,8 +1053,6 @@ static inline void
 mlx5_eswitch_offloads_single_fdb_del_one(struct mlx5_eswitch *master_esw,
                                         struct mlx5_eswitch *slave_esw) {}
 
-static inline int mlx5_eswitch_get_npeers(struct mlx5_eswitch *esw) { return 0; }
-
 static inline int
 mlx5_eswitch_reload_ib_reps(struct mlx5_eswitch *esw)
 {
index d9683d3ea0e7a461f86c2970cb0ba97e76915462..d65f30bb2f80a3580664adb6854fd9650af8f437 100644 (file)
@@ -3296,6 +3296,18 @@ static int mlx5_esw_offloads_set_ns_peer(struct mlx5_eswitch *esw,
        return 0;
 }
 
+bool mlx5_eswitch_is_peer(struct mlx5_eswitch *esw,
+                         struct mlx5_eswitch *peer_esw)
+{
+       u16 peer_esw_i;
+
+       if (!mlx5_esw_allowed(esw) || !mlx5_esw_allowed(peer_esw))
+               return false;
+
+       peer_esw_i = MLX5_CAP_GEN(peer_esw->dev, vhca_id);
+       return !!xa_load(&esw->paired, peer_esw_i);
+}
+
 static int mlx5_esw_offloads_devcom_event(int event,
                                          void *my_data,
                                          void *event_data)
index e5b8e9f1e6fde28807b4bdcef9180cc25d585c24..b5cbe34097203669282ac96d2bd1d9a97ae7a23a 100644 (file)
@@ -10,7 +10,7 @@
 
 bool mlx5_lag_shared_fdb_supported(struct mlx5_lag *ldev)
 {
-       struct mlx5_core_dev *dev;
+       struct mlx5_core_dev *dev0, *dev;
        bool ret = false;
        int idx;
        int i;
@@ -19,6 +19,7 @@ bool mlx5_lag_shared_fdb_supported(struct mlx5_lag *ldev)
        if (idx < 0)
                return false;
 
+       dev0 = mlx5_lag_pf(ldev, idx)->dev;
        mlx5_ldev_for_each(i, 0, ldev) {
                if (i == idx)
                        continue;
@@ -27,19 +28,15 @@ bool mlx5_lag_shared_fdb_supported(struct mlx5_lag *ldev)
                    mlx5_eswitch_vport_match_metadata_enabled(dev->priv.eswitch) &&
                    MLX5_CAP_GEN(dev, lag_native_fdb_selection) &&
                    MLX5_CAP_ESW(dev, root_ft_on_other_esw) &&
-                   mlx5_eswitch_get_npeers(dev->priv.eswitch) ==
-                   MLX5_CAP_GEN(dev, num_lag_ports) - 1)
+                   mlx5_eswitch_is_peer(dev0->priv.eswitch, dev->priv.eswitch))
                        continue;
                return false;
        }
 
-       dev = mlx5_lag_pf(ldev, idx)->dev;
-       if (is_mdev_switchdev_mode(dev) &&
-           mlx5_eswitch_vport_match_metadata_enabled(dev->priv.eswitch) &&
-           mlx5_esw_offloads_devcom_is_ready(dev->priv.eswitch) &&
-           MLX5_CAP_ESW(dev, esw_shared_ingress_acl) &&
-           mlx5_eswitch_get_npeers(dev->priv.eswitch) ==
-           MLX5_CAP_GEN(dev, num_lag_ports) - 1)
+       if (is_mdev_switchdev_mode(dev0) &&
+           mlx5_eswitch_vport_match_metadata_enabled(dev0->priv.eswitch) &&
+           mlx5_esw_offloads_devcom_is_ready(dev0->priv.eswitch) &&
+           MLX5_CAP_ESW(dev0, esw_shared_ingress_acl))
                ret = true;
 
        return ret;