Skip to contentSkip to conversation

net/mlx5: fix indirect RSS action hash fields calculation

PATCH In review Dariusz Sosnowski 2 participants 2 messages Oct 30, 2025 – Nov 2, 2025 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/mlx5: fix indirect RSS action hash fields calculation

Whenever indirect RSS flow action is created,
mlx5 PMD creates an hrxq object (abstraction over HW object used to configure RSS hashing),
for all possible and supported protocols combinations. For each combination, the hrxq configuration is adjusted based on RSS hash types provided by the user
(e.g. hash on source L3 address is removed if user passed RTE_ETH_RSS_L3_SRC_ONLY in hash types).

Function used for adjustment, flow_dv_action_rss_l34_hash_adjust(), had a bug. If user requested, for example, hashing over both UDP ports and only IPv6 source address, then RSS hashing was configured to hash both IPv6 addresses. Adjustment for RTE_ETH_RSS_L3_SRC_ONLY was skipped.

In HW Steering mode, this resulted in failures to use such indirect RSS flow action in flow rules created through template flow API. In this mode, only a single hrxq object is selected during flow rule creation, based on actual configuration of RSS hash types
in flow action.
Since hrxq was created without applying RTE_ETH_RSS_L3_SRC_ONLY adjustment and RSS hash types contained RTE_ETH_RSS_L3_SRC_ONLY, then no matching hrxq could be found, resulting in rule creation failure.

This issue is addressed by the following:

- Missing adjustments are added to flow_dv_action_rss_l34_hash_adjust() function.
This function is reworked to check each protocol type separately, instead of using switch case over all combinations.
- Code for setting/looking up hrxq objects based on RSS hash types is reworked. Separate switch cases for possible combinations in each function are replaced with a single one.
Additional logging and assertions are added to flag any invalid or missing combinations.

Beside that, the existing set of protocols combinations set did not cover RSS hashing only over UDP or TCP ports, which is a valid configuration.
These combinations are added in this patch
(new elements in mlx5_rss_hash_fields array).

Fixes 212d17b6a650 ("net/mlx5: fix missing shared RSS hash types")
---
 drivers/net/mlx5/mlx5.h         |   2 -
 drivers/net/mlx5/mlx5_flow.c    |  15 ++
 drivers/net/mlx5/mlx5_flow.h    |  38 +--
 drivers/net/mlx5/mlx5_flow_dv.c | 410 +++++++++++++++++++-------------
 4 files changed, 287 insertions(+), 178 deletions(-)
drivers/net/mlx5/mlx5.h +0 -2
index 07418b0922..11fc904619 100644
@@ -1845,8 +1845,6 @@ struct mlx5_obj_ops {
 	void (*lb_dummy_queue_release)(struct rte_eth_dev *dev);
 };
 
-#define MLX5_RSS_HASH_FIELDS_LEN RTE_DIM(mlx5_rss_hash_fields)
-
 enum mlx5_ctrl_flow_type {
 	MLX5_CTRL_FLOW_TYPE_GENERAL,
 	MLX5_CTRL_FLOW_TYPE_SQ_MISS_ROOT,
drivers/net/mlx5/mlx5_flow.c +15 -0
index 1de398982a..43595836cf 100644
@@ -34,6 +34,21 @@
 #include "mlx5_common_os.h"
 #include "rte_pmd_mlx5.h"
 
+const uint64_t mlx5_rss_hash_fields[] = {
+	[MLX5_RSS_HASH_IDX_IPV4]     = MLX5_RSS_HASH_IPV4,
+	[MLX5_RSS_HASH_IDX_IPV4_TCP] = MLX5_RSS_HASH_IPV4_TCP,
+	[MLX5_RSS_HASH_IDX_IPV4_UDP] = MLX5_RSS_HASH_IPV4_UDP,
+	[MLX5_RSS_HASH_IDX_IPV4_ESP] = MLX5_RSS_HASH_IPV4_ESP,
+	[MLX5_RSS_HASH_IDX_IPV6]     = MLX5_RSS_HASH_IPV6,
+	[MLX5_RSS_HASH_IDX_IPV6_TCP] = MLX5_RSS_HASH_IPV6_TCP,
+	[MLX5_RSS_HASH_IDX_IPV6_UDP] = MLX5_RSS_HASH_IPV6_UDP,
+	[MLX5_RSS_HASH_IDX_IPV6_ESP] = MLX5_RSS_HASH_IPV6_ESP,
+	[MLX5_RSS_HASH_IDX_TCP]      = MLX5_TCP_IBV_RX_HASH,
+	[MLX5_RSS_HASH_IDX_UDP]      = MLX5_UDP_IBV_RX_HASH,
+	[MLX5_RSS_HASH_IDX_ESP_SPI]  = MLX5_RSS_HASH_ESP_SPI,
+	[MLX5_RSS_HASH_IDX_NONE]     = MLX5_RSS_HASH_NONE,
+};
+
 /*
  * Shared array for quick translation between port_id and vport mask/values
  * used for HWS rules.
drivers/net/mlx5/mlx5_flow.h +24 -14
index ff61706054..29a40bde2d 100644
@@ -1905,19 +1905,29 @@ flow_hw_get_reg_id_from_ctx(void *dr_ctx, enum rte_flow_item_type type,
 	(_prt) = rte_be_to_cpu_16((_prt));                    \
 } while (0)
 
-/* array of valid combinations of RX Hash fields for RSS */
-static const uint64_t mlx5_rss_hash_fields[] = {
-	MLX5_RSS_HASH_IPV4,
-	MLX5_RSS_HASH_IPV4_TCP,
-	MLX5_RSS_HASH_IPV4_UDP,
-	MLX5_RSS_HASH_IPV4_ESP,
-	MLX5_RSS_HASH_IPV6,
-	MLX5_RSS_HASH_IPV6_TCP,
-	MLX5_RSS_HASH_IPV6_UDP,
-	MLX5_RSS_HASH_IPV6_ESP,
-	MLX5_RSS_HASH_ESP_SPI,
-	MLX5_RSS_HASH_NONE,
-};
+/**
+ * Each enum variant corresponds to a single valid protocols combination for hrxq configuration
+ * Each variant serves as an index into #mlx5_rss_hash_fields array containing default
+ * bitmaps of ibv_rx_hash_fields flags for given protocols combination.
+ */
+enum {
+	MLX5_RSS_HASH_IDX_IPV4,
+	MLX5_RSS_HASH_IDX_IPV4_TCP,
+	MLX5_RSS_HASH_IDX_IPV4_UDP,
+	MLX5_RSS_HASH_IDX_IPV4_ESP,
+	MLX5_RSS_HASH_IDX_IPV6,
+	MLX5_RSS_HASH_IDX_IPV6_TCP,
+	MLX5_RSS_HASH_IDX_IPV6_UDP,
+	MLX5_RSS_HASH_IDX_IPV6_ESP,
+	MLX5_RSS_HASH_IDX_TCP,
+	MLX5_RSS_HASH_IDX_UDP,
+	MLX5_RSS_HASH_IDX_ESP_SPI,
+	MLX5_RSS_HASH_IDX_NONE,
+	MLX5_RSS_HASH_IDX_MAX,
+};
+
+/** Array of valid combinations of RX Hash fields for RSS. */
+extern const uint64_t mlx5_rss_hash_fields[];
 
 /* Shared RSS action structure */
 struct mlx5_shared_action_rss {
@@ -1927,7 +1937,7 @@ struct mlx5_shared_action_rss {
 	uint8_t key[MLX5_RSS_HASH_KEY_LEN]; /**< RSS hash key. */
 	struct mlx5_ind_table_obj *ind_tbl;
 	/**< Hash RX queues (hrxq, hrxq_tunnel fields) indirection table. */
-	uint32_t hrxq[MLX5_RSS_HASH_FIELDS_LEN];
+	uint32_t hrxq[MLX5_RSS_HASH_IDX_MAX];
 	/**< Hash RX queue indexes mapped to mlx5_rss_hash_fields */
 	rte_spinlock_t action_rss_sl; /**< Shared RSS action spinlock. */
 };
drivers/net/mlx5/mlx5_flow_dv.c +248 -162

478 lines not on this page · raw message

--
2.39.5

#1 lore raw

Hi,

Quoted 42 lines · Dariusz Sosnowski

Whenever indirect RSS flow action is created,
mlx5 PMD creates an hrxq object (abstraction over HW object used to configure RSS hashing),
for all possible and supported protocols combinations. For each combination, the hrxq configuration is adjusted based on RSS hash types provided by the user
(e.g. hash on source L3 address is removed if user passed RTE_ETH_RSS_L3_SRC_ONLY in hash types).

Function used for adjustment, flow_dv_action_rss_l34_hash_adjust(), had a bug. If user requested, for example, hashing over both UDP ports and only IPv6 source address, then RSS hashing was configured to hash both IPv6 addresses. Adjustment for RTE_ETH_RSS_L3_SRC_ONLY was skipped.

In HW Steering mode, this resulted in failures to use such indirect RSS flow action in flow rules created through template flow API. In this mode, only a single hrxq object is selected during flow rule creation, based on actual configuration of RSS hash types
in flow action.
Since hrxq was created without applying RTE_ETH_RSS_L3_SRC_ONLY adjustment and RSS hash types contained RTE_ETH_RSS_L3_SRC_ONLY, then no matching hrxq could be found, resulting in rule creation failure.

This issue is addressed by the following:

- Missing adjustments are added to flow_dv_action_rss_l34_hash_adjust() function.
This function is reworked to check each protocol type separately, instead of using switch case over all combinations.
- Code for setting/looking up hrxq objects based on RSS hash types is reworked. Separate switch cases for possible combinations in each function are replaced with a single one.
Additional logging and assertions are added to flag any invalid or missing combinations.

Beside that, the existing set of protocols combinations set did not cover RSS hashing only over UDP or TCP ports, which is a valid configuration.
These combinations are added in this patch
(new elements in mlx5_rss_hash_fields array).

Quoted 6 lines
Fixes 212d17b6a650 ("net/mlx5: fix missing shared RSS hash types")

Patch applied to next-net-mlx,

Kindest regards
Raslan Darawsheh