Skip to contentSkip to conversation

net/mlx5: fix RSS selection flags settings

PATCH Superseded Lior Margalit 2 participants 6 messages Jul 13, 2021 – Jul 28, 2021 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/mlx5: fix RSS selection flags settings

The L3 protocol of the RSS type may be different than the one defined in the flow.
If the RSS type also includes L4 protocol type, the selection flags for the RX hash will be set with SPORT/DPORT without setting SRC/DST IP, but this combination is not supported by the rte API.

When using indirect RSS action, the flow creation fails, because it does not match any of the pre-created TIRs.

The fix is to prevent setting the hash flags with SPORT/DPORT without setting SRC/DST IP. The hash flags will remain 0, meaning non-RSS processing of the received packets.
In case of indirect rss action, it will match the MLX5_RSS_HASH_NONE pre-created TIR.
In addition, the queue_num is set to 1 when the hash flags are 0, but it was implemented only when creating a new TIR. Applied the same to the RSS desc before checking if it matches a cached TIR object.

Fixes b1d63d829378 ("net/mlx5: support RSS on src or dst fields only")
Fixes 5a959cbfa68c ("net/mlx5: share Rx hash queue code")
---
 drivers/net/mlx5/mlx5_flow_dv.c    | 14 +++++++++++---
 drivers/net/mlx5/mlx5_flow_verbs.c | 10 ++++++----
 2 files changed, 17 insertions(+), 7 deletions(-)
drivers/net/mlx5/mlx5_flow_dv.c +11 -3
index 2f4c0eeb5b..99836b1796 100644
@@ -10506,10 +10506,8 @@ flow_dv_hashfields_set(struct mlx5_flow *dev_flow,
 
 	dev_flow->hash_fields = 0;
 #ifdef HAVE_IBV_DEVICE_TUNNEL_SUPPORT
-	if (rss_desc->level >= 2) {
-		dev_flow->hash_fields |= IBV_RX_HASH_INNER;
+	if (rss_desc->level >= 2)
 		rss_inner = 1;
-	}
 #endif
 	if ((rss_inner && (items & MLX5_FLOW_LAYER_INNER_L3_IPV4)) ||
 	    (!rss_inner && (items & MLX5_FLOW_LAYER_OUTER_L3_IPV4))) {
@@ -10532,6 +10530,12 @@ flow_dv_hashfields_set(struct mlx5_flow *dev_flow,
 				dev_flow->hash_fields |= MLX5_IPV6_IBV_RX_HASH;
 		}
 	}
+	if (dev_flow->hash_fields == 0)
+		/*
+		 * There is no match between the rss types and the
+		 * l3 protocol (IPv4/IPv6) defined in the flow.
+		 */
+		return;
 	if ((rss_inner && (items & MLX5_FLOW_LAYER_INNER_L4_UDP)) ||
 	    (!rss_inner && (items & MLX5_FLOW_LAYER_OUTER_L4_UDP))) {
 		if (rss_types & ETH_RSS_UDP) {
@@ -10557,6 +10561,8 @@ flow_dv_hashfields_set(struct mlx5_flow *dev_flow,
 				dev_flow->hash_fields |= MLX5_TCP_IBV_RX_HASH;
 		}
 	}
+	if (rss_inner)
+		dev_flow->hash_fields |= IBV_RX_HASH_INNER;
 }
 
 /**
@@ -10589,6 +10595,8 @@ flow_dv_hrxq_prepare(struct rte_eth_dev *dev,
 	rss_desc->hash_fields = dev_flow->hash_fields;
 	rss_desc->tunnel = !!(dh->layers & MLX5_FLOW_LAYER_TUNNEL);
 	rss_desc->shared_rss = 0;
+	if (rss_desc->hash_fields == 0)
+		rss_desc->queue_num = 1;
 	*hrxq_idx = mlx5_hrxq_get(dev, rss_desc);
 	if (!*hrxq_idx)
 		return NULL;
drivers/net/mlx5/mlx5_flow_verbs.c +6 -4
index fe9673310a..527dcfbf26 100644
@@ -1820,8 +1820,9 @@ flow_verbs_translate(struct rte_eth_dev *dev,
 			flow_verbs_translate_item_tcp(dev_flow, items,
 						      item_flags);
 			subpriority = MLX5_PRIORITY_MAP_L4;
-			dev_flow->hash_fields |=
-				mlx5_flow_hashfields_adjust
+			if (dev_flow->hash_fields != 0)
+				dev_flow->hash_fields |=
+					mlx5_flow_hashfields_adjust
 					(rss_desc, tunnel, ETH_RSS_TCP,
 					 (IBV_RX_HASH_SRC_PORT_TCP |
 					  IBV_RX_HASH_DST_PORT_TCP));
@@ -1832,8 +1833,9 @@ flow_verbs_translate(struct rte_eth_dev *dev,
 			flow_verbs_translate_item_udp(dev_flow, items,
 						      item_flags);
 			subpriority = MLX5_PRIORITY_MAP_L4;
-			dev_flow->hash_fields |=
-				mlx5_flow_hashfields_adjust
+			if (dev_flow->hash_fields != 0)
+				dev_flow->hash_fields |=
+					mlx5_flow_hashfields_adjust
 					(rss_desc, tunnel, ETH_RSS_UDP,
 					 (IBV_RX_HASH_SRC_PORT_UDP |
 					  IBV_RX_HASH_DST_PORT_UDP));
Signature · 1 line
2.25.1
#1 lore raw

Hi,

Quoted 26 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Lior Margalit
Sent: Tuesday, July 13, 2021 3:55 PM
To: [email protected]; Matan Azrad <[email protected]>
Cc: Lior Margalit <[email protected]>; [email protected]
Subject: [dpdk-dev] [PATCH v1] net/mlx5: fix RSS selection flags settings

The L3 protocol of the RSS type may be different than the one defined in the flow.
If the RSS type also includes L4 protocol type, the selection flags for the RX hash will be set with SPORT/DPORT without setting SRC/DST IP, but this combination is not supported by the rte API.

When using indirect RSS action, the flow creation fails, because it does not match any of the pre-created TIRs.

The fix is to prevent setting the hash flags with SPORT/DPORT without setting SRC/DST IP. The hash flags will remain 0, meaning non-RSS processing of the received packets.
In case of indirect rss action, it will match the MLX5_RSS_HASH_NONE pre-created TIR.
In addition, the queue_num is set to 1 when the hash flags are 0, but it was implemented only when creating a new TIR. Applied the same to the RSS desc before checking if it matches a cached TIR object.

Quoted 6 lines
Fixes b1d63d829378 ("net/mlx5: support RSS on src or dst fields only")
Fixes 5a959cbfa68c ("net/mlx5: share Rx hash queue code")

Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh

#2 lore raw

v2 cover net/mlx5: prevent RSS distribution by L4 proto alone

In reply to Lior Margalit

Set proper selection flags for the RX hash and queue num in case of mismatch between the L3 proto of the RSS hash types and the flow rule pattern.

v2:
* Same code changes as v1, but separated into two commits.

Lior Margalit (2):
net/mlx5: fix RSS L4 proto selection flags settings net/mlx5: fix queue num in RSS desc

 drivers/net/mlx5/mlx5_flow_dv.c    | 14 +++++++++++---
 drivers/net/mlx5/mlx5_flow_verbs.c | 10 ++++++----
 2 files changed, 17 insertions(+), 7 deletions(-)
Signature · 1 line
2.25.1
#3 lore raw

PATCH v2 1/2 net/mlx5: fix RSS L4 proto selection flags settings

The RSS hash types defined in the API do not support setting the L4 proto type (TCP or UDP) without setting the L3 proto. For example, ETH_RSS_TCP is defined as
(ETH_RSS_NONFRAG_IPV4_TCP | \
ETH_RSS_NONFRAG_IPV6_TCP | \
ETH_RSS_IPV6_TCP_EX).

The L3 proto of the RSS hash type may be different than the one defined in the pattern, for example:
testpmd> flow create .../ ipv4 / tcp / end actions rss types ipv6-tcp-ex end / end

If the RSS hash type also includes L4 proto type as in the above example, the selection flags for the RX hash are currently set with SPORT/DPORT without setting SRC/DST IP. As this combination is not supported, it does not match any of the pre-created TIRs of the indirect RSS action and the flow creation fails.

The fix is to prevent setting the selection flags for the RX hash with SPORT/DPORT without setting SRC/DST IP. It applies non-RSS processing of the received packets. In case of indirect RSS action, it will match the MLX5_RSS_HASH_NONE pre-created TIR.

Fixes b1d63d829378 ("net/mlx5: support RSS on src or dst fields only")
Fixes 4a78c88e3bae ("net/mlx5: fix Verbs flow tunnel")
---
 drivers/net/mlx5/mlx5_flow_dv.c    | 12 +++++++++---
 drivers/net/mlx5/mlx5_flow_verbs.c | 10 ++++++----
 2 files changed, 15 insertions(+), 7 deletions(-)
drivers/net/mlx5/mlx5_flow_dv.c +9 -3
index 736227bc0c..fe922b6fbe 100644
@@ -10896,10 +10896,8 @@ flow_dv_hashfields_set(struct mlx5_flow *dev_flow,
 
 	dev_flow->hash_fields = 0;
 #ifdef HAVE_IBV_DEVICE_TUNNEL_SUPPORT
-	if (rss_desc->level >= 2) {
-		dev_flow->hash_fields |= IBV_RX_HASH_INNER;
+	if (rss_desc->level >= 2)
 		rss_inner = 1;
-	}
 #endif
 	if ((rss_inner && (items & MLX5_FLOW_LAYER_INNER_L3_IPV4)) ||
 	    (!rss_inner && (items & MLX5_FLOW_LAYER_OUTER_L3_IPV4))) {
@@ -10922,6 +10920,12 @@ flow_dv_hashfields_set(struct mlx5_flow *dev_flow,
 				dev_flow->hash_fields |= MLX5_IPV6_IBV_RX_HASH;
 		}
 	}
+	if (dev_flow->hash_fields == 0)
+		/*
+		 * There is no match between the rss types and the
+		 * l3 protocol (IPv4/IPv6) defined in the flow.
+		 */
+		return;
 	if ((rss_inner && (items & MLX5_FLOW_LAYER_INNER_L4_UDP)) ||
 	    (!rss_inner && (items & MLX5_FLOW_LAYER_OUTER_L4_UDP))) {
 		if (rss_types & ETH_RSS_UDP) {
@@ -10947,6 +10951,8 @@ flow_dv_hashfields_set(struct mlx5_flow *dev_flow,
 				dev_flow->hash_fields |= MLX5_TCP_IBV_RX_HASH;
 		}
 	}
+	if (rss_inner)
+		dev_flow->hash_fields |= IBV_RX_HASH_INNER;
 }
 
 /**
drivers/net/mlx5/mlx5_flow_verbs.c +6 -4
index 7b3d0b320d..a36b8adf6b 100644
@@ -1821,8 +1821,9 @@ flow_verbs_translate(struct rte_eth_dev *dev,
 			flow_verbs_translate_item_tcp(dev_flow, items,
 						      item_flags);
 			subpriority = MLX5_PRIORITY_MAP_L4;
-			dev_flow->hash_fields |=
-				mlx5_flow_hashfields_adjust
+			if (dev_flow->hash_fields != 0)
+				dev_flow->hash_fields |=
+					mlx5_flow_hashfields_adjust
 					(rss_desc, tunnel, ETH_RSS_TCP,
 					 (IBV_RX_HASH_SRC_PORT_TCP |
 					  IBV_RX_HASH_DST_PORT_TCP));
@@ -1833,8 +1834,9 @@ flow_verbs_translate(struct rte_eth_dev *dev,
 			flow_verbs_translate_item_udp(dev_flow, items,
 						      item_flags);
 			subpriority = MLX5_PRIORITY_MAP_L4;
-			dev_flow->hash_fields |=
-				mlx5_flow_hashfields_adjust
+			if (dev_flow->hash_fields != 0)
+				dev_flow->hash_fields |=
+					mlx5_flow_hashfields_adjust
 					(rss_desc, tunnel, ETH_RSS_UDP,
 					 (IBV_RX_HASH_SRC_PORT_UDP |
 					  IBV_RX_HASH_DST_PORT_UDP));
Signature · 1 line
2.25.1
#4 lore raw

PATCH v2 2/2 net/mlx5: fix queue num in RSS desc

In reply to Lior Margalit

The selection flags for the RX hash define how the received packets will be distributed between multiple queues.
When creating a new TIR, the queue_num is set to 1 if non of the selection flags is set.

Applied the same to the RSS desc before checking if it matches a cached TIR object to save creating a new object every time.

Fixes fabf8a37241c ("net/mlx5: fix shared RSS action release")
---
 drivers/net/mlx5/mlx5_flow_dv.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/mlx5/mlx5_flow_dv.c +2 -0
index fe922b6fbe..4aac69028f 100644
@@ -10985,6 +10985,8 @@ flow_dv_hrxq_prepare(struct rte_eth_dev *dev,
 	rss_desc->hash_fields = dev_flow->hash_fields;
 	rss_desc->tunnel = !!(dh->layers & MLX5_FLOW_LAYER_TUNNEL);
 	rss_desc->shared_rss = 0;
+	if (rss_desc->hash_fields == 0)
+		rss_desc->queue_num = 1;
 	*hrxq_idx = mlx5_hrxq_get(dev, rss_desc);
 	if (!*hrxq_idx)
 		return NULL;
Signature · 1 line
2.25.1
#5 lore raw

Re: [dpdk-dev] [PATCH v2 0/2] net/mlx5: prevent RSS distribution by L4 proto alone

In reply to Lior Margalit

Hi,

Quoted 19 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Lior Margalit
Sent: Tuesday, July 27, 2021 9:46 AM
To: Matan Azrad <[email protected]>
Cc: Lior Margalit <[email protected]>; [email protected]
Subject: [dpdk-dev] [PATCH v2 0/2] net/mlx5: prevent RSS distribution by L4 proto alone

Set proper selection flags for the RX hash and queue num in case of mismatch between the L3 proto of the RSS hash types and the flow rule pattern.

v2:
* Same code changes as v1, but separated into two commits.

Lior Margalit (2):
net/mlx5: fix RSS L4 proto selection flags settings net/mlx5: fix queue num in RSS desc

Quoted 6 lines
 drivers/net/mlx5/mlx5_flow_dv.c    | 14 +++++++++++---
 drivers/net/mlx5/mlx5_flow_verbs.c | 10 ++++++----
 2 files changed, 17 insertions(+), 7 deletions(-)

--
2.25.1

Series applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh