Skip to contentSkip to conversation

net/mlx5: fix the NIC egress flow mismatch in switchdev mode

PATCH Superseded Jiawei Wang 3 participants 9 messages Nov 5, 2021 – Mar 7, 2022 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/mlx5: fix the NIC egress flow mismatch in switchdev mode

When E-Switch mode is enabled, the NIC egress flows always added the source vport in the matcher item, then cause the flows cannot be hit. This commit fixes the issue that removes the souce port as matcher for NIC egress flow.
Also adding the validation that rejects the NIC egress flows on the representors ports.

Fixes ce777b147bf8 ("net/mlx5: fix E-Switch flow without port item")
---
 doc/guides/nics/mlx5.rst        |  2 ++
 drivers/net/mlx5/mlx5_flow_dv.c | 14 +++++++++++---
 2 files changed, 13 insertions(+), 3 deletions(-)
doc/guides/nics/mlx5.rst +2 -0
index 006896375f..0099128c98 100644
@@ -479,6 +479,8 @@ Limitations
 
   - Needs OFED 5.4+.
 
+- The NIC Egress flow on representor port is not supported.
+
 Statistics
 ----------
 
drivers/net/mlx5/mlx5_flow_dv.c +11 -3
index 842ada2ea9..58eb39d45f 100644
@@ -7992,6 +7992,12 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
 		return rte_flow_error_set(error, EINVAL,
 				RTE_FLOW_ERROR_TYPE_ACTION, NULL,
 				"sample before modify action is not supported");
+	if ((!attr->transfer && attr->egress) && priv->representor)
+		return rte_flow_error_set(error, EINVAL,
+					  RTE_FLOW_ERROR_TYPE_ITEM,
+					  NULL,
+					  "NIC egress rules on representors"
+					  " is not supported");
 	return 0;
 }
 
@@ -13556,11 +13562,13 @@ flow_dv_translate(struct rte_eth_dev *dev,
 	/*
 	 * When E-Switch mode is enabled, we have two cases where we need to
 	 * set the source port manually.
-	 * The first one, is in case of Nic steering rule, and the second is
-	 * E-Switch rule where no port_id item was found. In both cases
-	 * the source port is set according the current port in use.
+	 * The first one, is in case of NIC ingress steering rule, and the
+	 * second is E-Switch rule where no port_id item was found.
+	 * In both cases the source port is set according the current port
+	 * in use.
 	 */
 	if (!(item_flags & MLX5_FLOW_ITEM_PORT_ID) &&
+	    !(attr->egress && !attr->transfer) &&
 	    (priv->representor || priv->master)) {
 		if (flow_dv_translate_item_port_id(dev, match_mask,
 						   match_value, NULL, attr))
Signature · 1 line
2.18.1
#1 lore raw

PATCH v2 1/1 net/mlx5: fix the NIC egress flow mismatch in switchdev mode

When E-Switch mode was enabled, the NIC egress flows always added the source vport in the matcher item, then cause the flows cannot be hit. This commit fixes the issue that removes the source vport as matcher for NIC egress flow.
Also adding the validation that rejects the NIC egress flows on the representor ports.

Fixes ce777b147bf8 ("net/mlx5: fix E-Switch flow without port item")

---
v2: fix one typo

---
 doc/guides/nics/mlx5.rst        |  2 ++
 drivers/net/mlx5/mlx5_flow_dv.c | 14 +++++++++++---
 2 files changed, 13 insertions(+), 3 deletions(-)
doc/guides/nics/mlx5.rst +2 -0
index 006896375f..0099128c98 100644
@@ -479,6 +479,8 @@ Limitations
 
   - Needs OFED 5.4+.
 
+- The NIC Egress flow on representor port is not supported.
+
 Statistics
 ----------
 
drivers/net/mlx5/mlx5_flow_dv.c +11 -3
index 842ada2ea9..58eb39d45f 100644
@@ -7992,6 +7992,12 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
 		return rte_flow_error_set(error, EINVAL,
 				RTE_FLOW_ERROR_TYPE_ACTION, NULL,
 				"sample before modify action is not supported");
+	if ((!attr->transfer && attr->egress) && priv->representor)
+		return rte_flow_error_set(error, EINVAL,
+					  RTE_FLOW_ERROR_TYPE_ITEM,
+					  NULL,
+					  "NIC egress rules on representors"
+					  " is not supported");
 	return 0;
 }
 
@@ -13556,11 +13562,13 @@ flow_dv_translate(struct rte_eth_dev *dev,
 	/*
 	 * When E-Switch mode is enabled, we have two cases where we need to
 	 * set the source port manually.
-	 * The first one, is in case of Nic steering rule, and the second is
-	 * E-Switch rule where no port_id item was found. In both cases
-	 * the source port is set according the current port in use.
+	 * The first one, is in case of NIC ingress steering rule, and the
+	 * second is E-Switch rule where no port_id item was found.
+	 * In both cases the source port is set according the current port
+	 * in use.
 	 */
 	if (!(item_flags & MLX5_FLOW_ITEM_PORT_ID) &&
+	    !(attr->egress && !attr->transfer) &&
 	    (priv->representor || priv->master)) {
 		if (flow_dv_translate_item_port_id(dev, match_mask,
 						   match_value, NULL, attr))
Signature · 1 line
2.18.1
#2 lore raw

Hi,

Quoted 18 lines

-----Original Message-----
From: Jiawei(Jonny) Wang <[email protected]>
Sent: Friday, November 5, 2021 10:59 AM
To: Slava Ovsiienko <[email protected]>; Matan Azrad <[email protected]>; Ori Kam <[email protected]>; Ori Kam <[email protected]>; Yongseok Koh <[email protected]>
Cc: [email protected]; Raslan Darawsheh <[email protected]>; [email protected]
Subject: [PATCH v2] net/mlx5: fix the NIC egress flow mismatch in switchdev mode

When E-Switch mode was enabled, the NIC egress flows always added the source vport in the matcher item, then cause the flows cannot be hit. This commit fixes the issue that removes the source vport as matcher for NIC egress flow.
Also adding the validation that rejects the NIC egress flows on the representor ports.

Quoted 2 lines
Fixes ce777b147bf8 ("net/mlx5: fix E-Switch flow without port item")

Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh

#3 lore raw

Hello Raslan,

I need send the new V3 patch for this change, Sorry for the late update.

Thanks.
B.R.
Jonny

Quoted 38 lines

-----Original Message-----
From: Raslan Darawsheh <[email protected]>
Sent: Thursday, November 11, 2021 9:00 PM
To: Jiawei(Jonny) Wang <[email protected]>; Slava Ovsiienko <[email protected]>; Matan Azrad <[email protected]>; Ori Kam <[email protected]>; Ori Kam <[email protected]>; Yongseok Koh <[email protected]>
Cc: [email protected]; [email protected]
Subject: RE: [PATCH v2] net/mlx5: fix the NIC egress flow mismatch in switchdev mode

Hi,

Quoted 18 lines

-----Original Message-----
From: Jiawei(Jonny) Wang <[email protected]>
Sent: Friday, November 5, 2021 10:59 AM
To: Slava Ovsiienko <[email protected]>; Matan Azrad <[email protected]>; Ori Kam <[email protected]>; Ori Kam <[email protected]>; Yongseok Koh <[email protected]>
Cc: [email protected]; Raslan Darawsheh <[email protected]>; [email protected]
Subject: [PATCH v2] net/mlx5: fix the NIC egress flow mismatch in switchdev mode

When E-Switch mode was enabled, the NIC egress flows always added the source vport in the matcher item, then cause the flows cannot be hit. This commit fixes the issue that removes the source vport as matcher for NIC egress flow.
Also adding the validation that rejects the NIC egress flows on the representor ports.

Quoted 2 lines
Fixes ce777b147bf8 ("net/mlx5: fix E-Switch flow without port item")

Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh

#4 lore raw
Quoted 12 lines

-----Original Message-----
From: Jiawei(Jonny) Wang <[email protected]>
Sent: Thursday, November 11, 2021 3:18 PM
To: Raslan Darawsheh <[email protected]>; Slava Ovsiienko <[email protected]>; Matan Azrad <[email protected]>; Ori Kam <[email protected]>; Ori Kam <[email protected]>; Yongseok Koh <[email protected]>
Cc: [email protected]; [email protected]
Subject: RE: [PATCH v2] net/mlx5: fix the NIC egress flow mismatch in switchdev mode

Quoted 4 lines

Hello Raslan,

I need send the new V3 patch for this change, Sorry for the late update.

Sure, dropping this version for now, waiting for the updated version.

Kindest regards,
Raslan Darawsheh

Quoted 43 lines

Thanks.
B.R.
Jonny

Quoted 39 lines

-----Original Message-----
From: Raslan Darawsheh <[email protected]>
Sent: Thursday, November 11, 2021 9:00 PM
To: Jiawei(Jonny) Wang <[email protected]>; Slava Ovsiienko <[email protected]>; Matan Azrad <[email protected]>; Ori Kam <[email protected]>; Ori Kam <[email protected]>; Yongseok Koh <[email protected]>
Cc: [email protected]; [email protected]
Subject: RE: [PATCH v2] net/mlx5: fix the NIC egress flow mismatch in switchdev mode

Hi,

Quoted 18 lines

-----Original Message-----
From: Jiawei(Jonny) Wang <[email protected]>
Sent: Friday, November 5, 2021 10:59 AM
To: Slava Ovsiienko <[email protected]>; Matan Azrad <[email protected]>; Ori Kam <[email protected]>; Ori Kam <[email protected]>; Yongseok Koh <[email protected]>
Cc: [email protected]; Raslan Darawsheh <[email protected]>; [email protected]
Subject: [PATCH v2] net/mlx5: fix the NIC egress flow mismatch in switchdev mode

When E-Switch mode was enabled, the NIC egress flows always added the source vport in the matcher item, then cause the flows cannot be hit. This commit fixes the issue that removes the source vport as matcher for NIC egress flow.
Also adding the validation that rejects the NIC egress flows on the representor ports.

Quoted 3 lines
Fixes ce777b147bf8 ("net/mlx5: fix E-Switch flow without port

item")
Cc: [email protected]

Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh

#5 lore raw

PATCH v3 1/1 net/mlx5: fix the NIC egress flow mismatch in switchdev mode

In reply to Jiawei Wang

When E-Switch mode was enabled, the NIC egress flows was implicitly appended with source vport to match on. If the metadata register C0 was used to maintain the source vport, it was initialized to zero on packet steering engine entry, the flow could be hit only if source vport was zero, the register C0 of the packet was not correct to match in the TX side, this caused egress flow misses.

This patch:
- removes the implicit source vport match for NIC egress flow.
- rejects the NIC egress flows on the representor ports at validation.
- allows the internal NIC egress flows containing the TX_QUEUE items in order to not impact hairpins.

Fixes ce777b147bf8 ("net/mlx5: fix E-Switch flow without port item")

---
v3: update the tx_item checking
v2: fix one typo

---
 doc/guides/nics/mlx5.rst        |  2 ++
 drivers/net/mlx5/mlx5_flow_dv.c | 24 ++++++++++++++++++++----
 2 files changed, 22 insertions(+), 4 deletions(-)
doc/guides/nics/mlx5.rst +2 -0
index 043d006a2b..267d25ebb8 100644
@@ -493,6 +493,8 @@ Limitations
     completions, the scheduled send timestamps should not be specified
     with non-zero msb
 
+- The NIC Egress flow on representor port is not supported.
+
 Statistics
 ----------
 
drivers/net/mlx5/mlx5_flow_dv.c +20 -4
index 28911d6f0f..201f04ca84 100644
@@ -7164,8 +7164,10 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
 				return ret;
 			last_item = MLX5_FLOW_ITEM_TAG;
 			break;
-		case MLX5_RTE_FLOW_ITEM_TYPE_TAG:
 		case MLX5_RTE_FLOW_ITEM_TYPE_TX_QUEUE:
+			last_item = MLX5_FLOW_ITEM_TX_QUEUE;
+			break;
+		case MLX5_RTE_FLOW_ITEM_TYPE_TAG:
 			break;
 		case RTE_FLOW_ITEM_TYPE_GTP:
 			ret = flow_dv_validate_item_gtp(dev, items, item_flags,
@@ -7999,6 +8001,18 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
 		return rte_flow_error_set(error, EINVAL,
 				RTE_FLOW_ERROR_TYPE_ACTION, NULL,
 				"sample before modify action is not supported");
+	/*
+	 * Validation the NIC Egress flow on representor, except implicit
+	 * hairpin default egress flow with TX_QUEUE item, other flows not
+	 * work due to metadata regC0 mismatch.
+	 */
+	if ((!attr->transfer && attr->egress) && priv->representor &&
+	    !(item_flags & MLX5_FLOW_ITEM_TX_QUEUE))
+		return rte_flow_error_set(error, EINVAL,
+					  RTE_FLOW_ERROR_TYPE_ITEM,
+					  NULL,
+					  "NIC egress rules on representors"
+					  " is not supported");
 	return 0;
 }
 
@@ -13563,11 +13577,13 @@ flow_dv_translate(struct rte_eth_dev *dev,
 	/*
 	 * When E-Switch mode is enabled, we have two cases where we need to
 	 * set the source port manually.
-	 * The first one, is in case of Nic steering rule, and the second is
-	 * E-Switch rule where no port_id item was found. In both cases
-	 * the source port is set according the current port in use.
+	 * The first one, is in case of NIC ingress steering rule, and the
+	 * second is E-Switch rule where no port_id item was found.
+	 * In both cases the source port is set according the current port
+	 * in use.
 	 */
 	if (!(item_flags & MLX5_FLOW_ITEM_PORT_ID) &&
+	    !(attr->egress && !attr->transfer) &&
 	    (priv->representor || priv->master)) {
 		if (flow_dv_translate_item_port_id(dev, match_mask,
 						   match_value, NULL, attr))
Signature · 1 line
2.18.1
Acked-by on v3 1/1
#6 lore raw

Hi Jiawei,

Quoted 99 lines

-----Original Message-----
From: Jiawei(Jonny) Wang <[email protected]>
Sent: Friday, November 12, 2021 2:43 PM
Subject: [PATCH v3] net/mlx5: fix the NIC egress flow mismatch in switchdev mode

When E-Switch mode was enabled, the NIC egress flows was implicitly appended with source vport to match on. If the metadata register C0 was used to maintain the source vport, it was initialized to zero on packet steering engine entry, the flow could be hit only if source vport was zero, the register C0 of the packet was not correct to match in the TX side, this caused egress flow misses.

This patch:
- removes the implicit source vport match for NIC egress flow.
- rejects the NIC egress flows on the representor ports at validation.
- allows the internal NIC egress flows containing the TX_QUEUE items in order to not impact hairpins.

Fixes ce777b147bf8 ("net/mlx5: fix E-Switch flow without port item")

---
v3: update the tx_item checking
v2: fix one typo

---
 doc/guides/nics/mlx5.rst        |  2 ++
 drivers/net/mlx5/mlx5_flow_dv.c | 24 ++++++++++++++++++++----
 2 files changed, 22 insertions(+), 4 deletions(-)
doc/guides/nics/mlx5.rst +2 -0
index 043d006a2b..267d25ebb8 100644
@@ -493,6 +493,8 @@ Limitations
     completions, the scheduled send timestamps should not be specified
     with non-zero msb
 
+- The NIC Egress flow on representor port is not supported.
+
 Statistics
 ----------
 
drivers/net/mlx5/mlx5_flow_dv.c +3 -1
index 28911d6f0f..201f04ca84 100644
@@ -7164,8 +7164,10 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr
 *attr,
 				return ret;
 			last_item = MLX5_FLOW_ITEM_TAG;
 			break;
-		case MLX5_RTE_FLOW_ITEM_TYPE_TAG:
 		case MLX5_RTE_FLOW_ITEM_TYPE_TX_QUEUE:
+			last_item = MLX5_FLOW_ITEM_TX_QUEUE;
+			break;
+		case MLX5_RTE_FLOW_ITEM_TYPE_TAG:
 			break;
 		case RTE_FLOW_ITEM_TYPE_GTP:
drivers/net/mlx5/mlx5_flow_dv.c +17 -4
 			ret = flow_dv_validate_item_gtp(dev, items, item_flags,
@@ -7999,6 +8001,18 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr
 *attr,
 		return rte_flow_error_set(error, EINVAL,
 				RTE_FLOW_ERROR_TYPE_ACTION, NULL,
 				"sample before modify action is not supported");
+	/*
+	 * Validation the NIC Egress flow on representor, except implicit
+	 * hairpin default egress flow with TX_QUEUE item, other flows not
+	 * work due to metadata regC0 mismatch.
+	 */
+	if ((!attr->transfer && attr->egress) && priv->representor &&
+	    !(item_flags & MLX5_FLOW_ITEM_TX_QUEUE))
+		return rte_flow_error_set(error, EINVAL,
+					  RTE_FLOW_ERROR_TYPE_ITEM,
+					  NULL,
+					  "NIC egress rules on representors"
+					  " is not supported");
 	return 0;
 }
@@ -13563,11 +13577,13 @@ flow_dv_translate(struct rte_eth_dev *dev,
 	/*
 	 * When E-Switch mode is enabled, we have two cases where we need to
 	 * set the source port manually.
-	 * The first one, is in case of Nic steering rule, and the second is
-	 * E-Switch rule where no port_id item was found. In both cases
-	 * the source port is set according the current port in use.
+	 * The first one, is in case of NIC ingress steering rule, and the
+	 * second is E-Switch rule where no port_id item was found.
+	 * In both cases the source port is set according the current port
+	 * in use.
 	 */
 	if (!(item_flags & MLX5_FLOW_ITEM_PORT_ID) &&
+	    !(attr->egress && !attr->transfer) &&
 	    (priv->representor || priv->master)) {
 		if (flow_dv_translate_item_port_id(dev, match_mask,
 						   match_value, NULL, attr))
--
Quoted 1 line

2.18.1

Best,
Ori

#7 lore raw

PATCH v4 1/1 net/mlx5: fix the NIC egress flow mismatch in switchdev mode

In reply to Jiawei Wang

When E-Switch mode was enabled, the NIC egress flows was implicitly appended with source vport to match on. If the metadata register C0 was used to maintain the source vport, it was initialized to zero on packet steering engine entry, the flow could be hit only if source vport was zero, the register C0 of the packet was not correct to match in the TX side, this caused egress flow misses.

This patch:
- removes the implicit source vport match for NIC egress flow.
- rejects the NIC egress flows on the representor ports at validation.
- allows the internal NIC egress flows containing the TX_QUEUE items in order to not impact hairpins.

Fixes ce777b147bf8 ("net/mlx5: fix E-Switch flow without port item")

---
v4: rebase
v3: update the tx_item checking
v2: fix one typo

---
 doc/guides/nics/mlx5.rst        |  1 +
 drivers/net/mlx5/mlx5_flow_dv.c | 26 +++++++++++++++++++++-----
 2 files changed, 22 insertions(+), 5 deletions(-)
doc/guides/nics/mlx5.rst +1 -0
index c31a154181..acf37bd862 100644
@@ -504,6 +504,7 @@ Limitations
 
   Matching on checksum and sequence needs OFED 5.6+.
 
+- The NIC Egress flow on representor port is not supported.
 
 Statistics
 ----------
drivers/net/mlx5/mlx5_flow_dv.c +21 -5
index ae88a1cc29..b596144159 100644
@@ -7212,8 +7212,10 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
 				return ret;
 			last_item = MLX5_FLOW_ITEM_TAG;
 			break;
-		case MLX5_RTE_FLOW_ITEM_TYPE_TAG:
 		case MLX5_RTE_FLOW_ITEM_TYPE_TX_QUEUE:
+			last_item = MLX5_FLOW_ITEM_TX_QUEUE;
+			break;
+		case MLX5_RTE_FLOW_ITEM_TYPE_TAG:
 			break;
 		case RTE_FLOW_ITEM_TYPE_GTP:
 			ret = flow_dv_validate_item_gtp(dev, items, item_flags,
@@ -8047,6 +8049,18 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
 		return rte_flow_error_set(error, EINVAL,
 				RTE_FLOW_ERROR_TYPE_ACTION, NULL,
 				"sample before modify action is not supported");
+	/*
+	 * Validation the NIC Egress flow on representor, except implicit
+	 * hairpin default egress flow with TX_QUEUE item, other flows not
+	 * work due to metadata regC0 mismatch.
+	 */
+	if ((!attr->transfer && attr->egress) && priv->representor &&
+	    !(item_flags & MLX5_FLOW_ITEM_TX_QUEUE))
+		return rte_flow_error_set(error, EINVAL,
+					  RTE_FLOW_ERROR_TYPE_ITEM,
+					  NULL,
+					  "NIC egress rules on representors"
+					  " is not supported");
 	return 0;
 }
 
@@ -13732,11 +13746,13 @@ flow_dv_translate(struct rte_eth_dev *dev,
 	/*
 	 * When E-Switch mode is enabled, we have two cases where we need to
 	 * set the source port manually.
-	 * The first one, is in case of Nic steering rule, and the second is
-	 * E-Switch rule where no port_id item was found. In both cases
-	 * the source port is set according the current port in use.
+	 * The first one, is in case of NIC ingress steering rule, and the
+	 * second is E-Switch rule where no port_id item was found.
+	 * In both cases the source port is set according the current port
+	 * in use.
 	 */
-	if (!(item_flags & MLX5_FLOW_ITEM_PORT_ID) && priv->sh->esw_mode) {
+	if (!(item_flags & MLX5_FLOW_ITEM_PORT_ID) && priv->sh->esw_mode &&
+	    !(attr->egress && !attr->transfer)) {
 		if (flow_dv_translate_item_port_id(dev, match_mask,
 						   match_value, NULL, attr))
 			return -rte_errno;
Signature · 1 line
2.18.1
#8 lore raw

Hi,

Quoted 27 lines

-----Original Message-----
From: Jiawei(Jonny) Wang <[email protected]>
Sent: Wednesday, March 2, 2022 5:31 PM
To: Slava Ovsiienko <[email protected]>; Matan Azrad <[email protected]>; Ori Kam <[email protected]>; Yongseok Koh <[email protected]>; Ori Kam <[email protected]>
Cc: [email protected]; Raslan Darawsheh <[email protected]>; [email protected]
Subject: [PATCH v4] net/mlx5: fix the NIC egress flow mismatch in switchdev mode

When E-Switch mode was enabled, the NIC egress flows was implicitly appended with source vport to match on. If the metadata register C0 was used to maintain the source vport, it was initialized to zero on packet steering engine entry, the flow could be hit only if source vport was zero, the register C0 of the packet was not correct to match in the TX side, this caused egress flow misses.

This patch:
- removes the implicit source vport match for NIC egress flow.
- rejects the NIC egress flows on the representor ports at validation.
- allows the internal NIC egress flows containing the TX_QUEUE items in order to not impact hairpins.

Fixes ce777b147bf8 ("net/mlx5: fix E-Switch flow without port item")
Quoted 7 lines

---
v4: rebase
v3: update the tx_item checking
v2: fix one typo

Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh