DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH v1] net/iavf: fix FDIR configure
@ 2021-03-11  8:45 Jeff Guo
  2021-03-17  2:31 ` [dpdk-dev] [PATCH v2] " Jeff Guo
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jeff Guo @ 2021-03-11  8:45 UTC (permalink / raw)
  To: qi.z.zhang, beilei.xing, jingjing.wu; +Cc: yuying.zhang, dev, jia.guo

The refine configure of TCP/UDP flow item should not affact other flow
configure which not include L4 layer. Fix and clean the refinement
function.

Fixes: 61abc5f611a0 ("net/iavf: support TCP/UDP flow item without input set")

Signed-off-by: Jeff Guo <jia.guo@intel.com>
---
 drivers/net/iavf/iavf_fdir.c | 54 +++++++++++++-----------------------
 1 file changed, 20 insertions(+), 34 deletions(-)

diff --git a/drivers/net/iavf/iavf_fdir.c b/drivers/net/iavf/iavf_fdir.c
index 4e864b4b9c..d057fc515d 100644
--- a/drivers/net/iavf/iavf_fdir.c
+++ b/drivers/net/iavf/iavf_fdir.c
@@ -456,35 +456,16 @@ iavf_fdir_parse_action(struct iavf_adapter *ad,
 	return 0;
 }
 
-static bool
-iavf_fdir_refine_input_set(const uint64_t input_set,
-			   const uint64_t input_set_mask,
-			   struct iavf_fdir_conf *filter)
+#define	IAVF_IPPROTO_TCP 6
+#define	IAVF_IPPROTO_UDP 17
+
+static void
+iavf_fdir_refine_proto_hdr(struct virtchnl_proto_hdr *hdr,
+			   uint8_t proto_id)
 {
-	struct virtchnl_proto_hdr *hdr, *hdr_last;
 	struct rte_flow_item_ipv4 ipv4_spec;
 	struct rte_flow_item_ipv6 ipv6_spec;
-	int last_layer;
-	uint8_t proto_id;
-
-	if (input_set & ~input_set_mask)
-		return false;
-	else if (input_set)
-		return true;
-
-	last_layer = filter->add_fltr.rule_cfg.proto_hdrs.count - 1;
-	/* Last layer of TCP/UDP pattern isn't less than 2. */
-	if (last_layer < 2)
-		return false;
-	hdr_last = &filter->add_fltr.rule_cfg.proto_hdrs.proto_hdr[last_layer];
-	if (hdr_last->type == VIRTCHNL_PROTO_HDR_TCP)
-		proto_id = 6;
-	else if (hdr_last->type == VIRTCHNL_PROTO_HDR_UDP)
-		proto_id = 17;
-	else
-		return false;
 
-	hdr = &filter->add_fltr.rule_cfg.proto_hdrs.proto_hdr[last_layer - 1];
 	switch (hdr->type) {
 	case VIRTCHNL_PROTO_HDR_IPV4:
 		VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, IPV4, PROT);
@@ -492,17 +473,19 @@ iavf_fdir_refine_input_set(const uint64_t input_set,
 		ipv4_spec.hdr.next_proto_id = proto_id;
 		rte_memcpy(hdr->buffer, &ipv4_spec.hdr,
 			   sizeof(ipv4_spec.hdr));
-		return true;
+		break;
 	case VIRTCHNL_PROTO_HDR_IPV6:
 		VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, IPV6, PROT);
 		memset(&ipv6_spec, 0, sizeof(ipv6_spec));
 		ipv6_spec.hdr.proto = proto_id;
 		rte_memcpy(hdr->buffer, &ipv6_spec.hdr,
 			   sizeof(ipv6_spec.hdr));
-		return true;
+		break;
 	default:
-		return false;
+		break;
 	}
+
+	return;
 }
 
 static int
@@ -530,6 +513,7 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 	const struct rte_flow_item_ecpri *ecpri_spec, *ecpri_mask;
 	struct rte_ecpri_common_hdr ecpri_common;
 	uint64_t input_set = IAVF_INSET_NONE;
+	uint8_t proto_id;
 
 	enum rte_flow_item_type next_type;
 	uint16_t ether_type;
@@ -746,6 +730,9 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 						sizeof(udp_spec->hdr));
 			}
 
+			proto_id = IAVF_IPPROTO_UDP;
+			iavf_fdir_refine_proto_hdr(&filter->add_fltr.rule_cfg.proto_hdrs.proto_hdr[layer - 1], proto_id);
+
 			filter->add_fltr.rule_cfg.proto_hdrs.count = ++layer;
 			break;
 
@@ -790,6 +777,9 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 						sizeof(tcp_spec->hdr));
 			}
 
+			proto_id = IAVF_IPPROTO_TCP;
+			iavf_fdir_refine_proto_hdr(&filter->add_fltr.rule_cfg.proto_hdrs.proto_hdr[layer - 1], proto_id);
+
 			filter->add_fltr.rule_cfg.proto_hdrs.count = ++layer;
 			break;
 
@@ -1016,12 +1006,8 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 		return -rte_errno;
 	}
 
-	if (!iavf_fdir_refine_input_set(input_set, input_set_mask, filter)) {
-		rte_flow_error_set(error, EINVAL,
-				   RTE_FLOW_ERROR_TYPE_ITEM_SPEC, pattern,
-				   "Invalid input set");
-		return -rte_errno;
-	}
+	if (input_set & ~input_set_mask)
+		return -EINVAL;
 
 	filter->input_set = input_set;
 
-- 
2.20.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [dpdk-dev] [PATCH v2] net/iavf: fix FDIR configure
  2021-03-11  8:45 [dpdk-dev] [PATCH v1] net/iavf: fix FDIR configure Jeff Guo
@ 2021-03-17  2:31 ` Jeff Guo
  2021-03-24 13:24 ` [dpdk-dev] [PATCH v3] " Jeff Guo
  2021-03-24 13:40 ` Jeff Guo
  2 siblings, 0 replies; 4+ messages in thread
From: Jeff Guo @ 2021-03-17  2:31 UTC (permalink / raw)
  To: qi.z.zhang, beilei.xing, jingjing.wu; +Cc: yuying.zhang, dev, jia.guo

The configure of TCP/UDP flow item should not affact other flow
configure which not include L4 layer. Fix and clean the protocol header
refinement function.

Fixes: 61abc5f611a0 ("net/iavf: support TCP/UDP flow item without input set")

Signed-off-by: Jeff Guo <jia.guo@intel.com>
---
v2:
fix coding style issue
---
 drivers/net/iavf/iavf_fdir.c | 109 ++++++++++++++++-------------------
 1 file changed, 49 insertions(+), 60 deletions(-)

diff --git a/drivers/net/iavf/iavf_fdir.c b/drivers/net/iavf/iavf_fdir.c
index 4e864b4b9c..e3f3b5f22a 100644
--- a/drivers/net/iavf/iavf_fdir.c
+++ b/drivers/net/iavf/iavf_fdir.c
@@ -456,35 +456,16 @@ iavf_fdir_parse_action(struct iavf_adapter *ad,
 	return 0;
 }
 
-static bool
-iavf_fdir_refine_input_set(const uint64_t input_set,
-			   const uint64_t input_set_mask,
-			   struct iavf_fdir_conf *filter)
+#define	IAVF_IPPROTO_TCP 6
+#define	IAVF_IPPROTO_UDP 17
+
+static void
+iavf_fdir_refine_proto_hdr(struct virtchnl_proto_hdr *hdr,
+			   uint8_t proto_id)
 {
-	struct virtchnl_proto_hdr *hdr, *hdr_last;
 	struct rte_flow_item_ipv4 ipv4_spec;
 	struct rte_flow_item_ipv6 ipv6_spec;
-	int last_layer;
-	uint8_t proto_id;
-
-	if (input_set & ~input_set_mask)
-		return false;
-	else if (input_set)
-		return true;
-
-	last_layer = filter->add_fltr.rule_cfg.proto_hdrs.count - 1;
-	/* Last layer of TCP/UDP pattern isn't less than 2. */
-	if (last_layer < 2)
-		return false;
-	hdr_last = &filter->add_fltr.rule_cfg.proto_hdrs.proto_hdr[last_layer];
-	if (hdr_last->type == VIRTCHNL_PROTO_HDR_TCP)
-		proto_id = 6;
-	else if (hdr_last->type == VIRTCHNL_PROTO_HDR_UDP)
-		proto_id = 17;
-	else
-		return false;
 
-	hdr = &filter->add_fltr.rule_cfg.proto_hdrs.proto_hdr[last_layer - 1];
 	switch (hdr->type) {
 	case VIRTCHNL_PROTO_HDR_IPV4:
 		VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, IPV4, PROT);
@@ -492,17 +473,19 @@ iavf_fdir_refine_input_set(const uint64_t input_set,
 		ipv4_spec.hdr.next_proto_id = proto_id;
 		rte_memcpy(hdr->buffer, &ipv4_spec.hdr,
 			   sizeof(ipv4_spec.hdr));
-		return true;
+		break;
 	case VIRTCHNL_PROTO_HDR_IPV6:
 		VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, IPV6, PROT);
 		memset(&ipv6_spec, 0, sizeof(ipv6_spec));
 		ipv6_spec.hdr.proto = proto_id;
 		rte_memcpy(hdr->buffer, &ipv6_spec.hdr,
 			   sizeof(ipv6_spec.hdr));
-		return true;
+		break;
 	default:
-		return false;
+		break;
 	}
+
+	return;
 }
 
 static int
@@ -512,6 +495,7 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 			struct rte_flow_error *error,
 			struct iavf_fdir_conf *filter)
 {
+	struct virtchnl_proto_hdrs hdrs = filter->add_fltr.rule_cfg.proto_hdrs;
 	const struct rte_flow_item *item = pattern;
 	enum rte_flow_item_type item_type;
 	enum rte_flow_item_type l3 = RTE_FLOW_ITEM_TYPE_END;
@@ -530,6 +514,7 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 	const struct rte_flow_item_ecpri *ecpri_spec, *ecpri_mask;
 	struct rte_ecpri_common_hdr ecpri_common;
 	uint64_t input_set = IAVF_INSET_NONE;
+	uint8_t proto_id;
 
 	enum rte_flow_item_type next_type;
 	uint16_t ether_type;
@@ -557,7 +542,7 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 			eth_mask = item->mask;
 			next_type = (item + 1)->type;
 
-			hdr = &filter->add_fltr.rule_cfg.proto_hdrs.proto_hdr[layer];
+			hdr = &hdrs.proto_hdr[layer];
 
 			VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, ETH);
 
@@ -604,7 +589,7 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 					eth_spec, sizeof(struct rte_ether_hdr));
 			}
 
-			filter->add_fltr.rule_cfg.proto_hdrs.count = ++layer;
+			hdrs.count = ++layer;
 			break;
 
 		case RTE_FLOW_ITEM_TYPE_IPV4:
@@ -612,7 +597,7 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 			ipv4_spec = item->spec;
 			ipv4_mask = item->mask;
 
-			hdr = &filter->add_fltr.rule_cfg.proto_hdrs.proto_hdr[layer];
+			hdr = &hdrs.proto_hdr[layer];
 
 			VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, IPV4);
 
@@ -655,7 +640,7 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 					sizeof(ipv4_spec->hdr));
 			}
 
-			filter->add_fltr.rule_cfg.proto_hdrs.count = ++layer;
+			hdrs.count = ++layer;
 			break;
 
 		case RTE_FLOW_ITEM_TYPE_IPV6:
@@ -663,7 +648,7 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 			ipv6_spec = item->spec;
 			ipv6_mask = item->mask;
 
-			hdr = &filter->add_fltr.rule_cfg.proto_hdrs.proto_hdr[layer];
+			hdr = &hdrs.proto_hdr[layer];
 
 			VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, IPV6);
 
@@ -707,14 +692,14 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 					sizeof(ipv6_spec->hdr));
 			}
 
-			filter->add_fltr.rule_cfg.proto_hdrs.count = ++layer;
+			hdrs.count = ++layer;
 			break;
 
 		case RTE_FLOW_ITEM_TYPE_UDP:
 			udp_spec = item->spec;
 			udp_mask = item->mask;
 
-			hdr = &filter->add_fltr.rule_cfg.proto_hdrs.proto_hdr[layer];
+			hdr = &hdrs.proto_hdr[layer];
 
 			VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, UDP);
 
@@ -746,14 +731,18 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 						sizeof(udp_spec->hdr));
 			}
 
-			filter->add_fltr.rule_cfg.proto_hdrs.count = ++layer;
+			proto_id = IAVF_IPPROTO_UDP;
+			iavf_fdir_refine_proto_hdr(&hdrs.proto_hdr[layer - 1],
+						   proto_id);
+
+			hdrs.count = ++layer;
 			break;
 
 		case RTE_FLOW_ITEM_TYPE_TCP:
 			tcp_spec = item->spec;
 			tcp_mask = item->mask;
 
-			hdr = &filter->add_fltr.rule_cfg.proto_hdrs.proto_hdr[layer];
+			hdr = &hdrs.proto_hdr[layer];
 
 			VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, TCP);
 
@@ -790,14 +779,18 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 						sizeof(tcp_spec->hdr));
 			}
 
-			filter->add_fltr.rule_cfg.proto_hdrs.count = ++layer;
+			proto_id = IAVF_IPPROTO_TCP;
+			iavf_fdir_refine_proto_hdr(&hdrs.proto_hdr[layer - 1],
+						   proto_id);
+
+			hdrs.count = ++layer;
 			break;
 
 		case RTE_FLOW_ITEM_TYPE_SCTP:
 			sctp_spec = item->spec;
 			sctp_mask = item->mask;
 
-			hdr = &filter->add_fltr.rule_cfg.proto_hdrs.proto_hdr[layer];
+			hdr = &hdrs.proto_hdr[layer];
 
 			VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, SCTP);
 
@@ -828,14 +821,14 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 						sizeof(sctp_spec->hdr));
 			}
 
-			filter->add_fltr.rule_cfg.proto_hdrs.count = ++layer;
+			hdrs.count = ++layer;
 			break;
 
 		case RTE_FLOW_ITEM_TYPE_GTPU:
 			gtp_spec = item->spec;
 			gtp_mask = item->mask;
 
-			hdr = &filter->add_fltr.rule_cfg.proto_hdrs.proto_hdr[layer];
+			hdr = &hdrs.proto_hdr[layer];
 
 			VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, GTPU_IP);
 
@@ -858,14 +851,14 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 					gtp_spec, sizeof(*gtp_spec));
 			}
 
-			filter->add_fltr.rule_cfg.proto_hdrs.count = ++layer;
+			hdrs.count = ++layer;
 			break;
 
 		case RTE_FLOW_ITEM_TYPE_GTP_PSC:
 			gtp_psc_spec = item->spec;
 			gtp_psc_mask = item->mask;
 
-			hdr = &filter->add_fltr.rule_cfg.proto_hdrs.proto_hdr[layer];
+			hdr = &hdrs.proto_hdr[layer];
 
 			if (!gtp_psc_spec)
 				VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, GTPU_EH);
@@ -886,14 +879,14 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 					sizeof(*gtp_psc_spec));
 			}
 
-			filter->add_fltr.rule_cfg.proto_hdrs.count = ++layer;
+			hdrs.count = ++layer;
 			break;
 
 		case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
 			l2tpv3oip_spec = item->spec;
 			l2tpv3oip_mask = item->mask;
 
-			hdr = &filter->add_fltr.rule_cfg.proto_hdrs.proto_hdr[layer];
+			hdr = &hdrs.proto_hdr[layer];
 
 			VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, L2TPV3);
 
@@ -907,14 +900,14 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 					sizeof(*l2tpv3oip_spec));
 			}
 
-			filter->add_fltr.rule_cfg.proto_hdrs.count = ++layer;
+			hdrs.count = ++layer;
 			break;
 
 		case RTE_FLOW_ITEM_TYPE_ESP:
 			esp_spec = item->spec;
 			esp_mask = item->mask;
 
-			hdr = &filter->add_fltr.rule_cfg.proto_hdrs.proto_hdr[layer];
+			hdr = &hdrs.proto_hdr[layer];
 
 			VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, ESP);
 
@@ -928,14 +921,14 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 					sizeof(esp_spec->hdr));
 			}
 
-			filter->add_fltr.rule_cfg.proto_hdrs.count = ++layer;
+			hdrs.count = ++layer;
 			break;
 
 		case RTE_FLOW_ITEM_TYPE_AH:
 			ah_spec = item->spec;
 			ah_mask = item->mask;
 
-			hdr = &filter->add_fltr.rule_cfg.proto_hdrs.proto_hdr[layer];
+			hdr = &hdrs.proto_hdr[layer];
 
 			VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, AH);
 
@@ -949,14 +942,14 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 					sizeof(*ah_spec));
 			}
 
-			filter->add_fltr.rule_cfg.proto_hdrs.count = ++layer;
+			hdrs.count = ++layer;
 			break;
 
 		case RTE_FLOW_ITEM_TYPE_PFCP:
 			pfcp_spec = item->spec;
 			pfcp_mask = item->mask;
 
-			hdr = &filter->add_fltr.rule_cfg.proto_hdrs.proto_hdr[layer];
+			hdr = &hdrs.proto_hdr[layer];
 
 			VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, PFCP);
 
@@ -970,7 +963,7 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 					sizeof(*pfcp_spec));
 			}
 
-			filter->add_fltr.rule_cfg.proto_hdrs.count = ++layer;
+			hdrs.count = ++layer;
 			break;
 
 		case RTE_FLOW_ITEM_TYPE_ECPRI:
@@ -979,7 +972,7 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 
 			ecpri_common.u32 = rte_be_to_cpu_32(ecpri_spec->hdr.common.u32);
 
-			hdr = &filter->add_fltr.rule_cfg.proto_hdrs.proto_hdr[layer];
+			hdr = &hdrs.proto_hdr[layer];
 
 			VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, ECPRI);
 
@@ -995,7 +988,7 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 					sizeof(*ecpri_spec));
 			}
 
-			filter->add_fltr.rule_cfg.proto_hdrs.count = ++layer;
+			hdrs.count = ++layer;
 			break;
 
 		case RTE_FLOW_ITEM_TYPE_VOID:
@@ -1016,12 +1009,8 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 		return -rte_errno;
 	}
 
-	if (!iavf_fdir_refine_input_set(input_set, input_set_mask, filter)) {
-		rte_flow_error_set(error, EINVAL,
-				   RTE_FLOW_ERROR_TYPE_ITEM_SPEC, pattern,
-				   "Invalid input set");
-		return -rte_errno;
-	}
+	if (input_set & ~input_set_mask)
+		return -EINVAL;
 
 	filter->input_set = input_set;
 
-- 
2.20.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [dpdk-dev] [PATCH v3] net/iavf: fix FDIR configure
  2021-03-11  8:45 [dpdk-dev] [PATCH v1] net/iavf: fix FDIR configure Jeff Guo
  2021-03-17  2:31 ` [dpdk-dev] [PATCH v2] " Jeff Guo
@ 2021-03-24 13:24 ` Jeff Guo
  2021-03-24 13:40 ` Jeff Guo
  2 siblings, 0 replies; 4+ messages in thread
From: Jeff Guo @ 2021-03-24 13:24 UTC (permalink / raw)
  To: qi.z.zhang, beilei.xing, jingjing.wu; +Cc: yuying.zhang, dev, jia.guo

The configure of TCP/UDP flow item should not affact other flow
configure which not include L4 layer. Fix and clean the protocol header
refinement function.

Fixes: 61abc5f611a0 ("net/iavf: support TCP/UDP flow item without input set")

Signed-off-by: Jeff Guo <jia.guo@intel.com>
---
v3:
fix some coding error
---
 drivers/net/iavf/iavf_fdir.c | 110 ++++++++++++++++-------------------
 1 file changed, 50 insertions(+), 60 deletions(-)

diff --git a/drivers/net/iavf/iavf_fdir.c b/drivers/net/iavf/iavf_fdir.c
index 4e864b4b9c..459c09f6fb 100644
--- a/drivers/net/iavf/iavf_fdir.c
+++ b/drivers/net/iavf/iavf_fdir.c
@@ -456,35 +456,16 @@ iavf_fdir_parse_action(struct iavf_adapter *ad,
 	return 0;
 }
 
-static bool
-iavf_fdir_refine_input_set(const uint64_t input_set,
-			   const uint64_t input_set_mask,
-			   struct iavf_fdir_conf *filter)
+#define	IAVF_IPPROTO_TCP 6
+#define	IAVF_IPPROTO_UDP 17
+
+static void
+iavf_fdir_refine_proto_hdr(struct virtchnl_proto_hdr *hdr,
+			   uint8_t proto_id)
 {
-	struct virtchnl_proto_hdr *hdr, *hdr_last;
 	struct rte_flow_item_ipv4 ipv4_spec;
 	struct rte_flow_item_ipv6 ipv6_spec;
-	int last_layer;
-	uint8_t proto_id;
-
-	if (input_set & ~input_set_mask)
-		return false;
-	else if (input_set)
-		return true;
-
-	last_layer = filter->add_fltr.rule_cfg.proto_hdrs.count - 1;
-	/* Last layer of TCP/UDP pattern isn't less than 2. */
-	if (last_layer < 2)
-		return false;
-	hdr_last = &filter->add_fltr.rule_cfg.proto_hdrs.proto_hdr[last_layer];
-	if (hdr_last->type == VIRTCHNL_PROTO_HDR_TCP)
-		proto_id = 6;
-	else if (hdr_last->type == VIRTCHNL_PROTO_HDR_UDP)
-		proto_id = 17;
-	else
-		return false;
 
-	hdr = &filter->add_fltr.rule_cfg.proto_hdrs.proto_hdr[last_layer - 1];
 	switch (hdr->type) {
 	case VIRTCHNL_PROTO_HDR_IPV4:
 		VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, IPV4, PROT);
@@ -492,17 +473,19 @@ iavf_fdir_refine_input_set(const uint64_t input_set,
 		ipv4_spec.hdr.next_proto_id = proto_id;
 		rte_memcpy(hdr->buffer, &ipv4_spec.hdr,
 			   sizeof(ipv4_spec.hdr));
-		return true;
+		break;
 	case VIRTCHNL_PROTO_HDR_IPV6:
 		VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, IPV6, PROT);
 		memset(&ipv6_spec, 0, sizeof(ipv6_spec));
 		ipv6_spec.hdr.proto = proto_id;
 		rte_memcpy(hdr->buffer, &ipv6_spec.hdr,
 			   sizeof(ipv6_spec.hdr));
-		return true;
+		break;
 	default:
-		return false;
+		break;
 	}
+
+	return;
 }
 
 static int
@@ -512,6 +495,8 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 			struct rte_flow_error *error,
 			struct iavf_fdir_conf *filter)
 {
+	struct virtchnl_proto_hdrs *hdrs =
+			&filter->add_fltr.rule_cfg.proto_hdrs;
 	const struct rte_flow_item *item = pattern;
 	enum rte_flow_item_type item_type;
 	enum rte_flow_item_type l3 = RTE_FLOW_ITEM_TYPE_END;
@@ -530,6 +515,7 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 	const struct rte_flow_item_ecpri *ecpri_spec, *ecpri_mask;
 	struct rte_ecpri_common_hdr ecpri_common;
 	uint64_t input_set = IAVF_INSET_NONE;
+	uint8_t proto_id;
 
 	enum rte_flow_item_type next_type;
 	uint16_t ether_type;
@@ -557,7 +543,7 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 			eth_mask = item->mask;
 			next_type = (item + 1)->type;
 
-			hdr = &filter->add_fltr.rule_cfg.proto_hdrs.proto_hdr[layer];
+			hdr = &hdrs->proto_hdr[layer];
 
 			VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, ETH);
 
@@ -604,7 +590,7 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 					eth_spec, sizeof(struct rte_ether_hdr));
 			}
 
-			filter->add_fltr.rule_cfg.proto_hdrs.count = ++layer;
+			hdrs->count = ++layer;
 			break;
 
 		case RTE_FLOW_ITEM_TYPE_IPV4:
@@ -612,7 +598,7 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 			ipv4_spec = item->spec;
 			ipv4_mask = item->mask;
 
-			hdr = &filter->add_fltr.rule_cfg.proto_hdrs.proto_hdr[layer];
+			hdr = &hdrs->proto_hdr[layer];
 
 			VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, IPV4);
 
@@ -655,7 +641,7 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 					sizeof(ipv4_spec->hdr));
 			}
 
-			filter->add_fltr.rule_cfg.proto_hdrs.count = ++layer;
+			hdrs->count = ++layer;
 			break;
 
 		case RTE_FLOW_ITEM_TYPE_IPV6:
@@ -663,7 +649,7 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 			ipv6_spec = item->spec;
 			ipv6_mask = item->mask;
 
-			hdr = &filter->add_fltr.rule_cfg.proto_hdrs.proto_hdr[layer];
+			hdr = &hdrs->proto_hdr[layer];
 
 			VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, IPV6);
 
@@ -707,14 +693,14 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 					sizeof(ipv6_spec->hdr));
 			}
 
-			filter->add_fltr.rule_cfg.proto_hdrs.count = ++layer;
+			hdrs->count = ++layer;
 			break;
 
 		case RTE_FLOW_ITEM_TYPE_UDP:
 			udp_spec = item->spec;
 			udp_mask = item->mask;
 
-			hdr = &filter->add_fltr.rule_cfg.proto_hdrs.proto_hdr[layer];
+			hdr = &hdrs->proto_hdr[layer];
 
 			VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, UDP);
 
@@ -746,14 +732,18 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 						sizeof(udp_spec->hdr));
 			}
 
-			filter->add_fltr.rule_cfg.proto_hdrs.count = ++layer;
+			proto_id = IAVF_IPPROTO_UDP;
+			iavf_fdir_refine_proto_hdr(&hdrs->proto_hdr[layer - 1],
+						   proto_id);
+
+			hdrs->count = ++layer;
 			break;
 
 		case RTE_FLOW_ITEM_TYPE_TCP:
 			tcp_spec = item->spec;
 			tcp_mask = item->mask;
 
-			hdr = &filter->add_fltr.rule_cfg.proto_hdrs.proto_hdr[layer];
+			hdr = &hdrs->proto_hdr[layer];
 
 			VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, TCP);
 
@@ -790,14 +780,18 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 						sizeof(tcp_spec->hdr));
 			}
 
-			filter->add_fltr.rule_cfg.proto_hdrs.count = ++layer;
+			proto_id = IAVF_IPPROTO_TCP;
+			iavf_fdir_refine_proto_hdr(&hdrs->proto_hdr[layer - 1],
+						   proto_id);
+
+			hdrs->count = ++layer;
 			break;
 
 		case RTE_FLOW_ITEM_TYPE_SCTP:
 			sctp_spec = item->spec;
 			sctp_mask = item->mask;
 
-			hdr = &filter->add_fltr.rule_cfg.proto_hdrs.proto_hdr[layer];
+			hdr = &hdrs->proto_hdr[layer];
 
 			VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, SCTP);
 
@@ -828,14 +822,14 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 						sizeof(sctp_spec->hdr));
 			}
 
-			filter->add_fltr.rule_cfg.proto_hdrs.count = ++layer;
+			hdrs->count = ++layer;
 			break;
 
 		case RTE_FLOW_ITEM_TYPE_GTPU:
 			gtp_spec = item->spec;
 			gtp_mask = item->mask;
 
-			hdr = &filter->add_fltr.rule_cfg.proto_hdrs.proto_hdr[layer];
+			hdr = &hdrs->proto_hdr[layer];
 
 			VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, GTPU_IP);
 
@@ -858,14 +852,14 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 					gtp_spec, sizeof(*gtp_spec));
 			}
 
-			filter->add_fltr.rule_cfg.proto_hdrs.count = ++layer;
+			hdrs->count = ++layer;
 			break;
 
 		case RTE_FLOW_ITEM_TYPE_GTP_PSC:
 			gtp_psc_spec = item->spec;
 			gtp_psc_mask = item->mask;
 
-			hdr = &filter->add_fltr.rule_cfg.proto_hdrs.proto_hdr[layer];
+			hdr = &hdrs->proto_hdr[layer];
 
 			if (!gtp_psc_spec)
 				VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, GTPU_EH);
@@ -886,14 +880,14 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 					sizeof(*gtp_psc_spec));
 			}
 
-			filter->add_fltr.rule_cfg.proto_hdrs.count = ++layer;
+			hdrs->count = ++layer;
 			break;
 
 		case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
 			l2tpv3oip_spec = item->spec;
 			l2tpv3oip_mask = item->mask;
 
-			hdr = &filter->add_fltr.rule_cfg.proto_hdrs.proto_hdr[layer];
+			hdr = &hdrs->proto_hdr[layer];
 
 			VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, L2TPV3);
 
@@ -907,14 +901,14 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 					sizeof(*l2tpv3oip_spec));
 			}
 
-			filter->add_fltr.rule_cfg.proto_hdrs.count = ++layer;
+			hdrs->count = ++layer;
 			break;
 
 		case RTE_FLOW_ITEM_TYPE_ESP:
 			esp_spec = item->spec;
 			esp_mask = item->mask;
 
-			hdr = &filter->add_fltr.rule_cfg.proto_hdrs.proto_hdr[layer];
+			hdr = &hdrs->proto_hdr[layer];
 
 			VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, ESP);
 
@@ -928,14 +922,14 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 					sizeof(esp_spec->hdr));
 			}
 
-			filter->add_fltr.rule_cfg.proto_hdrs.count = ++layer;
+			hdrs->count = ++layer;
 			break;
 
 		case RTE_FLOW_ITEM_TYPE_AH:
 			ah_spec = item->spec;
 			ah_mask = item->mask;
 
-			hdr = &filter->add_fltr.rule_cfg.proto_hdrs.proto_hdr[layer];
+			hdr = &hdrs->proto_hdr[layer];
 
 			VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, AH);
 
@@ -949,14 +943,14 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 					sizeof(*ah_spec));
 			}
 
-			filter->add_fltr.rule_cfg.proto_hdrs.count = ++layer;
+			hdrs->count = ++layer;
 			break;
 
 		case RTE_FLOW_ITEM_TYPE_PFCP:
 			pfcp_spec = item->spec;
 			pfcp_mask = item->mask;
 
-			hdr = &filter->add_fltr.rule_cfg.proto_hdrs.proto_hdr[layer];
+			hdr = &hdrs->proto_hdr[layer];
 
 			VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, PFCP);
 
@@ -970,7 +964,7 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 					sizeof(*pfcp_spec));
 			}
 
-			filter->add_fltr.rule_cfg.proto_hdrs.count = ++layer;
+			hdrs->count = ++layer;
 			break;
 
 		case RTE_FLOW_ITEM_TYPE_ECPRI:
@@ -979,7 +973,7 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 
 			ecpri_common.u32 = rte_be_to_cpu_32(ecpri_spec->hdr.common.u32);
 
-			hdr = &filter->add_fltr.rule_cfg.proto_hdrs.proto_hdr[layer];
+			hdr = &hdrs->proto_hdr[layer];
 
 			VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, ECPRI);
 
@@ -995,7 +989,7 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 					sizeof(*ecpri_spec));
 			}
 
-			filter->add_fltr.rule_cfg.proto_hdrs.count = ++layer;
+			hdrs->count = ++layer;
 			break;
 
 		case RTE_FLOW_ITEM_TYPE_VOID:
@@ -1016,12 +1010,8 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 		return -rte_errno;
 	}
 
-	if (!iavf_fdir_refine_input_set(input_set, input_set_mask, filter)) {
-		rte_flow_error_set(error, EINVAL,
-				   RTE_FLOW_ERROR_TYPE_ITEM_SPEC, pattern,
-				   "Invalid input set");
-		return -rte_errno;
-	}
+	if (input_set & ~input_set_mask)
+		return -EINVAL;
 
 	filter->input_set = input_set;
 
-- 
2.20.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [dpdk-dev] [PATCH v3] net/iavf: fix FDIR configure
  2021-03-11  8:45 [dpdk-dev] [PATCH v1] net/iavf: fix FDIR configure Jeff Guo
  2021-03-17  2:31 ` [dpdk-dev] [PATCH v2] " Jeff Guo
  2021-03-24 13:24 ` [dpdk-dev] [PATCH v3] " Jeff Guo
@ 2021-03-24 13:40 ` Jeff Guo
  2 siblings, 0 replies; 4+ messages in thread
From: Jeff Guo @ 2021-03-24 13:40 UTC (permalink / raw)
  To: qi.z.zhang, beilei.xing, jingjing.wu; +Cc: yuying.zhang, dev, jia.guo

The configure of TCP/UDP flow item should not affect other flow
configure which not include L4 layer. Fix and clean the protocol header
refinement function.

Fixes: 61abc5f611a0 ("net/iavf: support TCP/UDP flow item without input set")

Signed-off-by: Jeff Guo <jia.guo@intel.com>
---
v3:
fix some coding error
---
 drivers/net/iavf/iavf_fdir.c | 110 ++++++++++++++++-------------------
 1 file changed, 50 insertions(+), 60 deletions(-)

diff --git a/drivers/net/iavf/iavf_fdir.c b/drivers/net/iavf/iavf_fdir.c
index 4e864b4b9c..459c09f6fb 100644
--- a/drivers/net/iavf/iavf_fdir.c
+++ b/drivers/net/iavf/iavf_fdir.c
@@ -456,35 +456,16 @@ iavf_fdir_parse_action(struct iavf_adapter *ad,
 	return 0;
 }
 
-static bool
-iavf_fdir_refine_input_set(const uint64_t input_set,
-			   const uint64_t input_set_mask,
-			   struct iavf_fdir_conf *filter)
+#define	IAVF_IPPROTO_TCP 6
+#define	IAVF_IPPROTO_UDP 17
+
+static void
+iavf_fdir_refine_proto_hdr(struct virtchnl_proto_hdr *hdr,
+			   uint8_t proto_id)
 {
-	struct virtchnl_proto_hdr *hdr, *hdr_last;
 	struct rte_flow_item_ipv4 ipv4_spec;
 	struct rte_flow_item_ipv6 ipv6_spec;
-	int last_layer;
-	uint8_t proto_id;
-
-	if (input_set & ~input_set_mask)
-		return false;
-	else if (input_set)
-		return true;
-
-	last_layer = filter->add_fltr.rule_cfg.proto_hdrs.count - 1;
-	/* Last layer of TCP/UDP pattern isn't less than 2. */
-	if (last_layer < 2)
-		return false;
-	hdr_last = &filter->add_fltr.rule_cfg.proto_hdrs.proto_hdr[last_layer];
-	if (hdr_last->type == VIRTCHNL_PROTO_HDR_TCP)
-		proto_id = 6;
-	else if (hdr_last->type == VIRTCHNL_PROTO_HDR_UDP)
-		proto_id = 17;
-	else
-		return false;
 
-	hdr = &filter->add_fltr.rule_cfg.proto_hdrs.proto_hdr[last_layer - 1];
 	switch (hdr->type) {
 	case VIRTCHNL_PROTO_HDR_IPV4:
 		VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, IPV4, PROT);
@@ -492,17 +473,19 @@ iavf_fdir_refine_input_set(const uint64_t input_set,
 		ipv4_spec.hdr.next_proto_id = proto_id;
 		rte_memcpy(hdr->buffer, &ipv4_spec.hdr,
 			   sizeof(ipv4_spec.hdr));
-		return true;
+		break;
 	case VIRTCHNL_PROTO_HDR_IPV6:
 		VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, IPV6, PROT);
 		memset(&ipv6_spec, 0, sizeof(ipv6_spec));
 		ipv6_spec.hdr.proto = proto_id;
 		rte_memcpy(hdr->buffer, &ipv6_spec.hdr,
 			   sizeof(ipv6_spec.hdr));
-		return true;
+		break;
 	default:
-		return false;
+		break;
 	}
+
+	return;
 }
 
 static int
@@ -512,6 +495,8 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 			struct rte_flow_error *error,
 			struct iavf_fdir_conf *filter)
 {
+	struct virtchnl_proto_hdrs *hdrs =
+			&filter->add_fltr.rule_cfg.proto_hdrs;
 	const struct rte_flow_item *item = pattern;
 	enum rte_flow_item_type item_type;
 	enum rte_flow_item_type l3 = RTE_FLOW_ITEM_TYPE_END;
@@ -530,6 +515,7 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 	const struct rte_flow_item_ecpri *ecpri_spec, *ecpri_mask;
 	struct rte_ecpri_common_hdr ecpri_common;
 	uint64_t input_set = IAVF_INSET_NONE;
+	uint8_t proto_id;
 
 	enum rte_flow_item_type next_type;
 	uint16_t ether_type;
@@ -557,7 +543,7 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 			eth_mask = item->mask;
 			next_type = (item + 1)->type;
 
-			hdr = &filter->add_fltr.rule_cfg.proto_hdrs.proto_hdr[layer];
+			hdr = &hdrs->proto_hdr[layer];
 
 			VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, ETH);
 
@@ -604,7 +590,7 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 					eth_spec, sizeof(struct rte_ether_hdr));
 			}
 
-			filter->add_fltr.rule_cfg.proto_hdrs.count = ++layer;
+			hdrs->count = ++layer;
 			break;
 
 		case RTE_FLOW_ITEM_TYPE_IPV4:
@@ -612,7 +598,7 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 			ipv4_spec = item->spec;
 			ipv4_mask = item->mask;
 
-			hdr = &filter->add_fltr.rule_cfg.proto_hdrs.proto_hdr[layer];
+			hdr = &hdrs->proto_hdr[layer];
 
 			VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, IPV4);
 
@@ -655,7 +641,7 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 					sizeof(ipv4_spec->hdr));
 			}
 
-			filter->add_fltr.rule_cfg.proto_hdrs.count = ++layer;
+			hdrs->count = ++layer;
 			break;
 
 		case RTE_FLOW_ITEM_TYPE_IPV6:
@@ -663,7 +649,7 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 			ipv6_spec = item->spec;
 			ipv6_mask = item->mask;
 
-			hdr = &filter->add_fltr.rule_cfg.proto_hdrs.proto_hdr[layer];
+			hdr = &hdrs->proto_hdr[layer];
 
 			VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, IPV6);
 
@@ -707,14 +693,14 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 					sizeof(ipv6_spec->hdr));
 			}
 
-			filter->add_fltr.rule_cfg.proto_hdrs.count = ++layer;
+			hdrs->count = ++layer;
 			break;
 
 		case RTE_FLOW_ITEM_TYPE_UDP:
 			udp_spec = item->spec;
 			udp_mask = item->mask;
 
-			hdr = &filter->add_fltr.rule_cfg.proto_hdrs.proto_hdr[layer];
+			hdr = &hdrs->proto_hdr[layer];
 
 			VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, UDP);
 
@@ -746,14 +732,18 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 						sizeof(udp_spec->hdr));
 			}
 
-			filter->add_fltr.rule_cfg.proto_hdrs.count = ++layer;
+			proto_id = IAVF_IPPROTO_UDP;
+			iavf_fdir_refine_proto_hdr(&hdrs->proto_hdr[layer - 1],
+						   proto_id);
+
+			hdrs->count = ++layer;
 			break;
 
 		case RTE_FLOW_ITEM_TYPE_TCP:
 			tcp_spec = item->spec;
 			tcp_mask = item->mask;
 
-			hdr = &filter->add_fltr.rule_cfg.proto_hdrs.proto_hdr[layer];
+			hdr = &hdrs->proto_hdr[layer];
 
 			VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, TCP);
 
@@ -790,14 +780,18 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 						sizeof(tcp_spec->hdr));
 			}
 
-			filter->add_fltr.rule_cfg.proto_hdrs.count = ++layer;
+			proto_id = IAVF_IPPROTO_TCP;
+			iavf_fdir_refine_proto_hdr(&hdrs->proto_hdr[layer - 1],
+						   proto_id);
+
+			hdrs->count = ++layer;
 			break;
 
 		case RTE_FLOW_ITEM_TYPE_SCTP:
 			sctp_spec = item->spec;
 			sctp_mask = item->mask;
 
-			hdr = &filter->add_fltr.rule_cfg.proto_hdrs.proto_hdr[layer];
+			hdr = &hdrs->proto_hdr[layer];
 
 			VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, SCTP);
 
@@ -828,14 +822,14 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 						sizeof(sctp_spec->hdr));
 			}
 
-			filter->add_fltr.rule_cfg.proto_hdrs.count = ++layer;
+			hdrs->count = ++layer;
 			break;
 
 		case RTE_FLOW_ITEM_TYPE_GTPU:
 			gtp_spec = item->spec;
 			gtp_mask = item->mask;
 
-			hdr = &filter->add_fltr.rule_cfg.proto_hdrs.proto_hdr[layer];
+			hdr = &hdrs->proto_hdr[layer];
 
 			VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, GTPU_IP);
 
@@ -858,14 +852,14 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 					gtp_spec, sizeof(*gtp_spec));
 			}
 
-			filter->add_fltr.rule_cfg.proto_hdrs.count = ++layer;
+			hdrs->count = ++layer;
 			break;
 
 		case RTE_FLOW_ITEM_TYPE_GTP_PSC:
 			gtp_psc_spec = item->spec;
 			gtp_psc_mask = item->mask;
 
-			hdr = &filter->add_fltr.rule_cfg.proto_hdrs.proto_hdr[layer];
+			hdr = &hdrs->proto_hdr[layer];
 
 			if (!gtp_psc_spec)
 				VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, GTPU_EH);
@@ -886,14 +880,14 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 					sizeof(*gtp_psc_spec));
 			}
 
-			filter->add_fltr.rule_cfg.proto_hdrs.count = ++layer;
+			hdrs->count = ++layer;
 			break;
 
 		case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
 			l2tpv3oip_spec = item->spec;
 			l2tpv3oip_mask = item->mask;
 
-			hdr = &filter->add_fltr.rule_cfg.proto_hdrs.proto_hdr[layer];
+			hdr = &hdrs->proto_hdr[layer];
 
 			VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, L2TPV3);
 
@@ -907,14 +901,14 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 					sizeof(*l2tpv3oip_spec));
 			}
 
-			filter->add_fltr.rule_cfg.proto_hdrs.count = ++layer;
+			hdrs->count = ++layer;
 			break;
 
 		case RTE_FLOW_ITEM_TYPE_ESP:
 			esp_spec = item->spec;
 			esp_mask = item->mask;
 
-			hdr = &filter->add_fltr.rule_cfg.proto_hdrs.proto_hdr[layer];
+			hdr = &hdrs->proto_hdr[layer];
 
 			VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, ESP);
 
@@ -928,14 +922,14 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 					sizeof(esp_spec->hdr));
 			}
 
-			filter->add_fltr.rule_cfg.proto_hdrs.count = ++layer;
+			hdrs->count = ++layer;
 			break;
 
 		case RTE_FLOW_ITEM_TYPE_AH:
 			ah_spec = item->spec;
 			ah_mask = item->mask;
 
-			hdr = &filter->add_fltr.rule_cfg.proto_hdrs.proto_hdr[layer];
+			hdr = &hdrs->proto_hdr[layer];
 
 			VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, AH);
 
@@ -949,14 +943,14 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 					sizeof(*ah_spec));
 			}
 
-			filter->add_fltr.rule_cfg.proto_hdrs.count = ++layer;
+			hdrs->count = ++layer;
 			break;
 
 		case RTE_FLOW_ITEM_TYPE_PFCP:
 			pfcp_spec = item->spec;
 			pfcp_mask = item->mask;
 
-			hdr = &filter->add_fltr.rule_cfg.proto_hdrs.proto_hdr[layer];
+			hdr = &hdrs->proto_hdr[layer];
 
 			VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, PFCP);
 
@@ -970,7 +964,7 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 					sizeof(*pfcp_spec));
 			}
 
-			filter->add_fltr.rule_cfg.proto_hdrs.count = ++layer;
+			hdrs->count = ++layer;
 			break;
 
 		case RTE_FLOW_ITEM_TYPE_ECPRI:
@@ -979,7 +973,7 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 
 			ecpri_common.u32 = rte_be_to_cpu_32(ecpri_spec->hdr.common.u32);
 
-			hdr = &filter->add_fltr.rule_cfg.proto_hdrs.proto_hdr[layer];
+			hdr = &hdrs->proto_hdr[layer];
 
 			VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, ECPRI);
 
@@ -995,7 +989,7 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 					sizeof(*ecpri_spec));
 			}
 
-			filter->add_fltr.rule_cfg.proto_hdrs.count = ++layer;
+			hdrs->count = ++layer;
 			break;
 
 		case RTE_FLOW_ITEM_TYPE_VOID:
@@ -1016,12 +1010,8 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 		return -rte_errno;
 	}
 
-	if (!iavf_fdir_refine_input_set(input_set, input_set_mask, filter)) {
-		rte_flow_error_set(error, EINVAL,
-				   RTE_FLOW_ERROR_TYPE_ITEM_SPEC, pattern,
-				   "Invalid input set");
-		return -rte_errno;
-	}
+	if (input_set & ~input_set_mask)
+		return -EINVAL;
 
 	filter->input_set = input_set;
 
-- 
2.20.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-03-24 13:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-11  8:45 [dpdk-dev] [PATCH v1] net/iavf: fix FDIR configure Jeff Guo
2021-03-17  2:31 ` [dpdk-dev] [PATCH v2] " Jeff Guo
2021-03-24 13:24 ` [dpdk-dev] [PATCH v3] " Jeff Guo
2021-03-24 13:40 ` Jeff Guo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).