Skip to contentSkip to conversation

net/i40e: fix FDIR issue for ETH + VLAN pattern

PATCH In review [email protected] 3 participants 5 messages Oct 22, 2020 – Oct 27, 2020 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/i40e: fix FDIR issue for ETH + VLAN pattern

From: Beilei Xing <[email protected]>

Currently, can't create more than one following flow for ETH + VLAN pattern:

Quoted 1 line

flow create 0 ingress pattern eth / vlan vid is 350 / end

actions queue index 2 / end

The root cause is the keys of all such flows are the same.

Fixes 42044b69c67d ("net/i40e: support input set selection for FDIR")
---
 drivers/net/i40e/i40e_flow.c | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)
drivers/net/i40e/i40e_flow.c +18 -5
index adc5da1c53..60043322a1 100644
@@ -28,6 +28,9 @@
 #define I40E_IPV6_FRAG_HEADER	44
 #define I40E_TENANT_ARRAY_NUM	3
 #define I40E_TCI_MASK		0xFFFF
+#define I40E_PRI_MASK		0xE000
+#define I40E_CFI_MASK		0x1000
+#define I40E_VID_MASK		0x0FFF
 
 static int i40e_flow_validate(struct rte_eth_dev *dev,
 			      const struct rte_flow_attr *attr,
@@ -2705,12 +2708,22 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev,
 
 			RTE_ASSERT(!(input_set & I40E_INSET_LAST_ETHER_TYPE));
 			if (vlan_spec && vlan_mask) {
-				if (vlan_mask->tci ==
-				    rte_cpu_to_be_16(I40E_TCI_MASK)) {
-					input_set |= I40E_INSET_VLAN_INNER;
-					filter->input.flow_ext.vlan_tci =
-						vlan_spec->tci;
+				if (vlan_mask->tci !=
+				    rte_cpu_to_be_16(I40E_TCI_MASK) &&
+				    vlan_mask->tci !=
+				    rte_cpu_to_be_16(I40E_PRI_MASK) &&
+				    vlan_mask->tci !=
+				    rte_cpu_to_be_16(I40E_CFI_MASK) &&
+				    vlan_mask->tci !=
+				    rte_cpu_to_be_16(I40E_VID_MASK)) {
+					rte_flow_error_set(error, EINVAL,
+						   RTE_FLOW_ERROR_TYPE_ITEM,
+						   item,
+						   "Unsupported TCI mask.");
 				}
+				input_set |= I40E_INSET_VLAN_INNER;
+				filter->input.flow_ext.vlan_tci =
+					vlan_spec->tci;
 			}
 			if (vlan_spec && vlan_mask && vlan_mask->inner_type) {
 				if (vlan_mask->inner_type != RTE_BE16(0xffff)) {
Signature · 1 line
2.26.2
#1 lore raw
Quoted 9 lines

-----Original Message-----
From: Xing, Beilei <[email protected]>
Sent: Friday, October 23, 2020 4:15 PM
To: [email protected]
Cc: Guo, Jia <[email protected]>; Xing, Beilei <[email protected]>; [email protected]
Subject: [PATCH] net/i40e: fix FDIR issue for ETH + VLAN pattern

Quoted 9 lines

From: Beilei Xing <[email protected]>

Currently, can't create more than one following flow for ETH + VLAN pattern:

Quoted 1 line

flow create 0 ingress pattern eth / vlan vid is 350 / end

actions queue index 2 / end

The root cause is the keys of all such flows are the same.

Create more same flow or different flow? Why the same key relate with below code change. Suggest better to make it more clear for readable. Thanks.

Quoted 13 lines
Fixes 42044b69c67d ("net/i40e: support input set selection for FDIR")
---
 drivers/net/i40e/i40e_flow.c | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)
drivers/net/i40e/i40e_flow.c +0 -0
index adc5da1c53..60043322a1 100644

drivers/net/i40e/i40e_flow.c line 34

Quoted 7 lines
drivers/net/i40e/i40e_flow.c +3 -0
@@ -28,6 +28,9 @@
 #define I40E_IPV6_FRAG_HEADER	44
 #define I40E_TENANT_ARRAY_NUM	3
 #define I40E_TCI_MASK		0xFFFF
+#define I40E_PRI_MASK		0xE000
+#define I40E_CFI_MASK		0x1000
+#define I40E_VID_MASK		0x0FFF
 

Should below are better to show that tci involve the others when use these mask?

+#define I40E_TCI_PRI_MASK 0xE000
+#define I40E_TCI_CFI_MASK 0x1000
+#define I40E_TCI_VID_MASK 0x0FFF

Quoted 37 lines
drivers/net/i40e/i40e_flow.c +1 -0
 static int i40e_flow_validate(struct rte_eth_dev *dev,
 			      const struct rte_flow_attr *attr, @@ -2705,12
+2708,22 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev,
 
 			RTE_ASSERT(!(input_set &

I40E_INSET_LAST_ETHER_TYPE));

drivers/net/i40e/i40e_flow.c +0 -3
 			if (vlan_spec && vlan_mask) {
-				if (vlan_mask->tci ==
-				    rte_cpu_to_be_16(I40E_TCI_MASK)) {
-					input_set |=

I40E_INSET_VLAN_INNER;

drivers/net/i40e/i40e_flow.c +10 -2
-					filter->input.flow_ext.vlan_tci =
-						vlan_spec->tci;
+				if (vlan_mask->tci !=
+				    rte_cpu_to_be_16(I40E_TCI_MASK) &&
+				    vlan_mask->tci !=
+				    rte_cpu_to_be_16(I40E_PRI_MASK) &&
+				    vlan_mask->tci !=
+				    rte_cpu_to_be_16(I40E_CFI_MASK) &&
+				    vlan_mask->tci !=
+				    rte_cpu_to_be_16(I40E_VID_MASK)) {
+					rte_flow_error_set(error, EINVAL,
+

RTE_FLOW_ERROR_TYPE_ITEM,

drivers/net/i40e/i40e_flow.c +5 -0
+						   item,
+						   "Unsupported TCI mask.");
 				}
+				input_set |= I40E_INSET_VLAN_INNER;
+				filter->input.flow_ext.vlan_tci =
+					vlan_spec->tci;
 			}
 			if (vlan_spec && vlan_mask && vlan_mask-
Quoted 1 line

inner_type) {

if (vlan_mask->inner_type !=
RTE_BE16(0xffff)) {
--
2.26.2

#2 lore raw

PATCH 1/1 net/i40e: fix FDIR issue for ETH + VLAN pattern

In reply to [email protected]

From: Beilei Xing <[email protected]>

Currently, can't create more than one following flow for ETH + VLAN pattern.

1. flow create 0 ingress pattern eth / vlan vid is 350 / end actions queue index 2 / end
2. flow create 0 ingress pattern eth / vlan vid is 351 / end actions queue index 3 / end

The root cause is the vlan_tci is not set correctly, it will cause the keys of both of the two flows are the same.

Fixes 42044b69c67d ("net/i40e: support input set selection for FDIR")
---
 drivers/net/i40e/i40e_flow.c | 35 ++++++++++++++++++++++++-----------
 1 file changed, 24 insertions(+), 11 deletions(-)
drivers/net/i40e/i40e_flow.c +24 -11
index 8e7a9989b3..5bec0c7a84 100644
@@ -27,7 +27,10 @@
 #define I40E_IPV6_TC_MASK	(0xFF << I40E_FDIR_IPv6_TC_OFFSET)
 #define I40E_IPV6_FRAG_HEADER	44
 #define I40E_TENANT_ARRAY_NUM	3
-#define I40E_TCI_MASK		0xFFFF
+#define I40E_VLAN_TCI_MASK	0xFFFF
+#define I40E_VLAN_PRI_MASK	0xE000
+#define I40E_VLAN_CFI_MASK	0x1000
+#define I40E_VLAN_VID_MASK	0x0FFF
 
 static int i40e_flow_validate(struct rte_eth_dev *dev,
 			      const struct rte_flow_attr *attr,
@@ -2705,12 +2708,22 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev,
 
 			RTE_ASSERT(!(input_set & I40E_INSET_LAST_ETHER_TYPE));
 			if (vlan_spec && vlan_mask) {
-				if (vlan_mask->tci ==
-				    rte_cpu_to_be_16(I40E_TCI_MASK)) {
-					input_set |= I40E_INSET_VLAN_INNER;
-					filter->input.flow_ext.vlan_tci =
-						vlan_spec->tci;
+				if (vlan_mask->tci !=
+				    rte_cpu_to_be_16(I40E_VLAN_TCI_MASK) &&
+				    vlan_mask->tci !=
+				    rte_cpu_to_be_16(I40E_VLAN_PRI_MASK) &&
+				    vlan_mask->tci !=
+				    rte_cpu_to_be_16(I40E_VLAN_CFI_MASK) &&
+				    vlan_mask->tci !=
+				    rte_cpu_to_be_16(I40E_VLAN_VID_MASK)) {
+					rte_flow_error_set(error, EINVAL,
+						   RTE_FLOW_ERROR_TYPE_ITEM,
+						   item,
+						   "Unsupported TCI mask.");
 				}
+				input_set |= I40E_INSET_VLAN_INNER;
+				filter->input.flow_ext.vlan_tci =
+					vlan_spec->tci;
 			}
 			if (vlan_spec && vlan_mask && vlan_mask->inner_type) {
 				if (vlan_mask->inner_type != RTE_BE16(0xffff)) {
@@ -3894,10 +3907,10 @@ i40e_flow_parse_vxlan_pattern(__rte_unused struct rte_eth_dev *dev,
 
 			if (vlan_spec && vlan_mask) {
 				if (vlan_mask->tci ==
-				    rte_cpu_to_be_16(I40E_TCI_MASK))
+				    rte_cpu_to_be_16(I40E_VLAN_TCI_MASK))
 					filter->inner_vlan =
 					      rte_be_to_cpu_16(vlan_spec->tci) &
-					      I40E_TCI_MASK;
+					      I40E_VLAN_TCI_MASK;
 				filter_type |= ETH_TUNNEL_FILTER_IVLAN;
 			}
 			break;
@@ -4125,10 +4138,10 @@ i40e_flow_parse_nvgre_pattern(__rte_unused struct rte_eth_dev *dev,
 
 			if (vlan_spec && vlan_mask) {
 				if (vlan_mask->tci ==
-				    rte_cpu_to_be_16(I40E_TCI_MASK))
+				    rte_cpu_to_be_16(I40E_VLAN_TCI_MASK))
 					filter->inner_vlan =
 					      rte_be_to_cpu_16(vlan_spec->tci) &
-					      I40E_TCI_MASK;
+					      I40E_VLAN_TCI_MASK;
 				filter_type |= ETH_TUNNEL_FILTER_IVLAN;
 			}
 			break;
@@ -4800,7 +4813,7 @@ i40e_flow_parse_rss_pattern(__rte_unused struct rte_eth_dev *dev,
 			vlan_mask = item->mask;
 			if (vlan_spec && vlan_mask) {
 				if (vlan_mask->tci ==
-					rte_cpu_to_be_16(I40E_TCI_MASK)) {
+					rte_cpu_to_be_16(I40E_VLAN_TCI_MASK)) {
 					info->region[0].user_priority[0] =
 						(rte_be_to_cpu_16(
 						vlan_spec->tci) >> 13) & 0x7;
Signature · 1 line
2.26.2
Acked-by on v1 1/1
#3 lore raw
Quoted 124 lines

-----Original Message-----
From: Xing, Beilei <[email protected]>
Sent: Tuesday, October 27, 2020 2:22 PM
To: [email protected]
Cc: Guo, Jia <[email protected]>; Xing, Beilei <[email protected]>; [email protected]
Subject: [PATCH] net/i40e: fix FDIR issue for ETH + VLAN pattern

From: Beilei Xing <[email protected]>

Currently, can't create more than one following flow for ETH + VLAN pattern.

1. flow create 0 ingress pattern eth / vlan vid is 350 / end actions queue index 2 / end
2. flow create 0 ingress pattern eth / vlan vid is 351 / end actions queue index 3 / end

The root cause is the vlan_tci is not set correctly, it will cause the keys of both of the two flows are the same.

Fixes 42044b69c67d ("net/i40e: support input set selection for FDIR")
---
 drivers/net/i40e/i40e_flow.c | 35 ++++++++++++++++++++++++-----------
 1 file changed, 24 insertions(+), 11 deletions(-)
drivers/net/i40e/i40e_flow.c +5 -1
index 8e7a9989b3..5bec0c7a84 100644
@@ -27,7 +27,10 @@
 #define I40E_IPV6_TC_MASK	(0xFF << I40E_FDIR_IPv6_TC_OFFSET)
 #define I40E_IPV6_FRAG_HEADER	44
 #define I40E_TENANT_ARRAY_NUM	3
-#define I40E_TCI_MASK		0xFFFF
+#define I40E_VLAN_TCI_MASK	0xFFFF
+#define I40E_VLAN_PRI_MASK	0xE000
+#define I40E_VLAN_CFI_MASK	0x1000
+#define I40E_VLAN_VID_MASK	0x0FFF
 
 static int i40e_flow_validate(struct rte_eth_dev *dev,
 			      const struct rte_flow_attr *attr, @@ -2705,12
+2708,22 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev,
 
 			RTE_ASSERT(!(input_set &

I40E_INSET_LAST_ETHER_TYPE));

drivers/net/i40e/i40e_flow.c +0 -3
 			if (vlan_spec && vlan_mask) {
-				if (vlan_mask->tci ==
-				    rte_cpu_to_be_16(I40E_TCI_MASK)) {
-					input_set |=

I40E_INSET_VLAN_INNER;

drivers/net/i40e/i40e_flow.c +2 -2
-					filter->input.flow_ext.vlan_tci =
-						vlan_spec->tci;
+				if (vlan_mask->tci !=
+				    rte_cpu_to_be_16(I40E_VLAN_TCI_MASK)

&&

drivers/net/i40e/i40e_flow.c +2 -0
+				    vlan_mask->tci !=
+				    rte_cpu_to_be_16(I40E_VLAN_PRI_MASK)

&&

drivers/net/i40e/i40e_flow.c +2 -0
+				    vlan_mask->tci !=
+				    rte_cpu_to_be_16(I40E_VLAN_CFI_MASK)

&&

drivers/net/i40e/i40e_flow.c +2 -0
+				    vlan_mask->tci !=
+

rte_cpu_to_be_16(I40E_VLAN_VID_MASK)) {

drivers/net/i40e/i40e_flow.c +2 -0
+					rte_flow_error_set(error, EINVAL,
+

RTE_FLOW_ERROR_TYPE_ITEM,

drivers/net/i40e/i40e_flow.c +5 -0
+						   item,
+						   "Unsupported TCI mask.");
 				}
+				input_set |= I40E_INSET_VLAN_INNER;
+				filter->input.flow_ext.vlan_tci =
+					vlan_spec->tci;
 			}
 			if (vlan_spec && vlan_mask && vlan_mask-
Quoted 1 line

inner_type) {

if (vlan_mask->inner_type !=
RTE_BE16(0xffff)) { @@ -3894,10 +3907,10 @@ i40e_flow_parse_vxlan_pattern(__rte_unused struct rte_eth_dev *dev,

drivers/net/i40e/i40e_flow.c +1 -1
 			if (vlan_spec && vlan_mask) {
 				if (vlan_mask->tci ==
-				    rte_cpu_to_be_16(I40E_TCI_MASK))
+				    rte_cpu_to_be_16(I40E_VLAN_TCI_MASK))
 					filter->inner_vlan =
 					      rte_be_to_cpu_16(vlan_spec->tci)

&

drivers/net/i40e/i40e_flow.c +2 -2
-					      I40E_TCI_MASK;
+					      I40E_VLAN_TCI_MASK;
 				filter_type |= ETH_TUNNEL_FILTER_IVLAN;
 			}
 			break;
@@ -4125,10 +4138,10 @@ i40e_flow_parse_nvgre_pattern(__rte_unused
 struct rte_eth_dev *dev,
 
 			if (vlan_spec && vlan_mask) {
 				if (vlan_mask->tci ==
-				    rte_cpu_to_be_16(I40E_TCI_MASK))
+				    rte_cpu_to_be_16(I40E_VLAN_TCI_MASK))
 					filter->inner_vlan =
 					      rte_be_to_cpu_16(vlan_spec->tci)

&

drivers/net/i40e/i40e_flow.c +2 -2
-					      I40E_TCI_MASK;
+					      I40E_VLAN_TCI_MASK;
 				filter_type |= ETH_TUNNEL_FILTER_IVLAN;
 			}
 			break;
@@ -4800,7 +4813,7 @@ i40e_flow_parse_rss_pattern(__rte_unused struct
 rte_eth_dev *dev,
 			vlan_mask = item->mask;
 			if (vlan_spec && vlan_mask) {
 				if (vlan_mask->tci ==
-					rte_cpu_to_be_16(I40E_TCI_MASK))
 {
+
 	rte_cpu_to_be_16(I40E_VLAN_TCI_MASK)) {
drivers/net/i40e/i40e_flow.c +0 -1
 					info->region[0].user_priority[0] =
 						(rte_be_to_cpu_16(
 						vlan_spec->tci) >> 13) & 0x7;
--

2.26.2

Applied
#4 lore raw
Quoted 36 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Guo, Jia
Sent: Monday, October 26, 2020 3:15 PM
To: Xing, Beilei <[email protected]>; [email protected]
Cc: [email protected]
Subject: Re: [dpdk-dev] [PATCH] net/i40e: fix FDIR issue for ETH + VLAN pattern

Quoted 25 lines

-----Original Message-----
From: Xing, Beilei <[email protected]>
Sent: Tuesday, October 27, 2020 2:22 PM
To: [email protected]
Cc: Guo, Jia <[email protected]>; Xing, Beilei <[email protected]>; [email protected]
Subject: [PATCH] net/i40e: fix FDIR issue for ETH + VLAN pattern

From: Beilei Xing <[email protected]>

Currently, can't create more than one following flow for ETH + VLAN pattern.

1. flow create 0 ingress pattern eth / vlan vid is 350 / end actions queue index 2 / end
2. flow create 0 ingress pattern eth / vlan vid is 351 / end actions queue index 3 / end

The root cause is the vlan_tci is not set correctly, it will cause the keys of both of the two flows are the same.

Fixes 42044b69c67d ("net/i40e: support input set selection for FDIR")

---

Applied to dpdk-next-net-intel.

Thanks
Qi