RDMA/mlx5: Don't set tx affinity when lag is in hash mode
authorLiu, Changcheng <jerrliu@nvidia.com>
Wed, 7 Sep 2022 23:36:26 +0000 (16:36 -0700)
committerSaeed Mahameed <saeedm@nvidia.com>
Tue, 27 Sep 2022 19:50:27 +0000 (12:50 -0700)
In hash mode, without setting tx affinity explicitly, the port select
flow table decides which port is used for the traffic.
If port_select_flow_table_bypass capability is supported and tx affinity
is set explicitly for QP/TIS, they will be added into the explicit affinity
table in FW to check which port is used for the traffic.
1. The overloaded explicit affinity table may affect performance.
   To avoid this, do not set tx affinity explicitly by default.
2. The packets of the same flow need to be transmitted on the same port.
   Because the packets of the same flow use different QPs in slow & fast
   path, it shouldn't set tx affinity explicitly for these QPs.

Signed-off-by: Liu, Changcheng <jerrliu@nvidia.com>
Reviewed-by: Mark Bloch <mbloch@nvidia.com>
Reviewed-by: Vlad Buslov <vladbu@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
drivers/infiniband/hw/mlx5/mlx5_ib.h
drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c
include/linux/mlx5/driver.h

index 2e2ad3918385832c62b38775b2dcc3c3b9005a80..c3e014283c410b5833ef15dfad990c48a242d931 100644 (file)
@@ -1540,6 +1540,18 @@ int mlx5_ib_test_wc(struct mlx5_ib_dev *dev);
 
 static inline bool mlx5_ib_lag_should_assign_affinity(struct mlx5_ib_dev *dev)
 {
+       /*
+        * If the driver is in hash mode and the port_select_flow_table_bypass cap
+        * is supported, it means that the driver no longer needs to assign the port
+        * affinity by default. If a user wants to set the port affinity explicitly,
+        * the user has a dedicated API to do that, so there is no need to assign
+        * the port affinity by default.
+        */
+       if (dev->lag_active &&
+           mlx5_lag_mode_is_hash(dev->mdev) &&
+           MLX5_CAP_PORT_SELECTION(dev->mdev, port_select_flow_table_bypass))
+               return 0;
+
        return dev->lag_active ||
                (MLX5_CAP_GEN(dev->mdev, num_lag_ports) > 1 &&
                 MLX5_CAP_GEN(dev->mdev, lag_tx_port_affinity));
index 065102278cb8080a8059a930d34dd77aa0582e4f..4cc5fc37a8315e38f4a8643d7c50408147aa2e4e 100644 (file)
@@ -1275,6 +1275,22 @@ bool mlx5_lag_is_active(struct mlx5_core_dev *dev)
 }
 EXPORT_SYMBOL(mlx5_lag_is_active);
 
+bool mlx5_lag_mode_is_hash(struct mlx5_core_dev *dev)
+{
+       struct mlx5_lag *ldev;
+       unsigned long flags;
+       bool res = 0;
+
+       spin_lock_irqsave(&lag_lock, flags);
+       ldev = mlx5_lag_dev(dev);
+       if (ldev)
+               res = test_bit(MLX5_LAG_MODE_FLAG_HASH_BASED, &ldev->mode_flags);
+       spin_unlock_irqrestore(&lag_lock, flags);
+
+       return res;
+}
+EXPORT_SYMBOL(mlx5_lag_mode_is_hash);
+
 bool mlx5_lag_is_master(struct mlx5_core_dev *dev)
 {
        struct mlx5_lag *ldev;
index 4815063763442f0c2e8b833d39134b07e712cd60..9114caceb2b5ede55386fbf46ec637f5dc52ade8 100644 (file)
@@ -1153,6 +1153,7 @@ int mlx5_cmd_destroy_vport_lag(struct mlx5_core_dev *dev);
 bool mlx5_lag_is_roce(struct mlx5_core_dev *dev);
 bool mlx5_lag_is_sriov(struct mlx5_core_dev *dev);
 bool mlx5_lag_is_active(struct mlx5_core_dev *dev);
+bool mlx5_lag_mode_is_hash(struct mlx5_core_dev *dev);
 bool mlx5_lag_is_master(struct mlx5_core_dev *dev);
 bool mlx5_lag_is_shared_fdb(struct mlx5_core_dev *dev);
 struct net_device *mlx5_lag_get_roce_netdev(struct mlx5_core_dev *dev);