Skip to contentSkip to conversation

net/mlx5: fix flex tunnel validation

PATCH In review Dariusz Sosnowski 2 participants 2 messages Apr 30, 2025 – May 13, 2025 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/mlx5: fix flex tunnel validation

Pattern template validation did not take into account the configured tunnel mode of the flex item.
This caused validation failures for templates with flex item registered as tunnel headers.
Specifically, any item after such flex item was still considered as outer header, not an inner.

This patch fixes the flex item validation,
by correctly updating recognized items bitmask depending on flex item mode.

Fixes 80c676259a04 ("net/mlx5: validate HWS template items")
---
 drivers/net/mlx5/mlx5_flow_hw.c | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)
drivers/net/mlx5/mlx5_flow_hw.c +14 -5
index 20d38ce414..723652a6ec 100644
@@ -8867,12 +8867,21 @@ flow_hw_pattern_validate(struct rte_eth_dev *dev,
 				    MLX5_FLOW_ITEM_INNER_IPV6_ROUTING_EXT :
 				    MLX5_FLOW_ITEM_OUTER_IPV6_ROUTING_EXT;
 			break;
-		case RTE_FLOW_ITEM_TYPE_FLEX:
-			/* match mlx5dr_definer_conv_items_to_hl() */
-			last_item = tunnel ?
-				    MLX5_FLOW_ITEM_INNER_FLEX :
-				    MLX5_FLOW_ITEM_OUTER_FLEX;
+		case RTE_FLOW_ITEM_TYPE_FLEX: {
+			enum rte_flow_item_flex_tunnel_mode tunnel_mode = FLEX_TUNNEL_MODE_SINGLE;
+
+			ret = mlx5_flex_get_tunnel_mode(item, &tunnel_mode);
+			if (ret < 0)
+				return rte_flow_error_set(error, -ret, RTE_FLOW_ERROR_TYPE_ITEM,
+							  item, "Unable to get flex item mode");
+			if (tunnel_mode == FLEX_TUNNEL_MODE_TUNNEL)
+				last_item = MLX5_FLOW_ITEM_FLEX_TUNNEL;
+			else
+				last_item = tunnel ?
+					    MLX5_FLOW_ITEM_INNER_FLEX :
+					    MLX5_FLOW_ITEM_OUTER_FLEX;
 			break;
+		}
 		case RTE_FLOW_ITEM_TYPE_RANDOM:
 			last_item = MLX5_FLOW_ITEM_RANDOM;
 			break;
Signature · 1 line
2.39.5
#1 lore raw

Hi,

Quoted 11 lines · Dariusz Sosnowski

Pattern template validation did not take into account the configured tunnel mode of the flex item.
This caused validation failures for templates with flex item registered as tunnel headers.
Specifically, any item after such flex item was still considered as outer header, not an inner.

This patch fixes the flex item validation,
by correctly updating recognized items bitmask depending on flex item mode.

Quoted 7 lines
Fixes 80c676259a04 ("net/mlx5: validate HWS template items")

---

Patch applied to next-net-mlx,

Signature · 2 lines
Kindest regards
Raslan Darawsheh