Skip to contentSkip to conversation

support AVF RSS and FDIR for GRE tunnel packet

PATCH Superseded Wenjun Wu 1 participant 7 messages May 27, 2021 Network drivers

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Wenjun Wu

author
#0 lore raw

cover support AVF RSS and FDIR for GRE tunnel packet

[PATCH v1 1/6] support flow pattern for GRE [PATCH v1 2/6] add header types for GRE [PATCH v1 3/6] add GRE RSS offload type [PATCH v1 4/6] support AVF RSS for GRE tunnel packet [PATCH v1 5/6] support AVF FDIR for GRE tunnel packet [PATCH v1 6/6] support FDIR for GRE tunnel packet

Wenjun Wu (6):
net/iavf: support flow pattern for GRE common/iavf: add header types for GRE
ethdev: add GRE RSS offload type net/iavf: support AVF RSS for GRE tunnel packet net/iavf: support AVF FDIR for GRE tunnel packet net/ice/base: support FDIR for GRE tunnel packet

 drivers/common/iavf/virtchnl.h       |   1 +
 drivers/net/iavf/iavf_fdir.c         |  55 +++++
 drivers/net/iavf/iavf_generic_flow.c | 105 ++++++++
 drivers/net/iavf/iavf_generic_flow.h |  14 ++
 drivers/net/iavf/iavf_hash.c         |  37 ++-
 drivers/net/ice/base/ice_fdir.c      | 352 +++++++++++++++++++++++++++
 drivers/net/ice/base/ice_fdir.h      |   2 +
 drivers/net/ice/base/ice_flow.c      |  16 +-
 drivers/net/ice/base/ice_type.h      |  14 ++
 lib/ethdev/rte_ethdev.h              |   1 +
 10 files changed, 582 insertions(+), 15 deletions(-)
Signature · 1 line
2.25.1
author
#1 lore raw

PATCH 1/6 net/iavf: support flow pattern for GRE

Add GRE pattern support for AVF FDIR and RSS.

Patterns are listed below:
1. eth/ipv4/gre/ipv4
2. eth/ipv4/gre/ipv6
3. eth/ipv6/gre/ipv4
4. eth/ipv6/gre/ipv6
5. eth/ipv4/gre/ipv4/tcp
6. eth/ipv4/gre/ipv6/tcp
7. eth/ipv4/gre/ipv4/udp
8. eth/ipv4/gre/ipv6/udp
9. eth/ipv6/gre/ipv4/tcp
10. eth/ipv6/gre/ipv6/tcp
11. eth/ipv6/gre/ipv4/udp
12. eth/ipv6/gre/ipv6/udp

---
 drivers/net/iavf/iavf_generic_flow.c | 105 +++++++++++++++++++++++++++
 drivers/net/iavf/iavf_generic_flow.h |  14 ++++
 2 files changed, 119 insertions(+)
drivers/net/iavf/iavf_generic_flow.c +105 -0
index 242bb4abc5..d9ba5735b2 100644
@@ -822,6 +822,111 @@ enum rte_flow_item_type iavf_pattern_eth_ipv4_ecpri[] = {
 	RTE_FLOW_ITEM_TYPE_END,
 };
 
+/* GRE */
+enum rte_flow_item_type iavf_pattern_eth_ipv4_gre_ipv4[] = {
+	RTE_FLOW_ITEM_TYPE_ETH,
+	RTE_FLOW_ITEM_TYPE_IPV4,
+	RTE_FLOW_ITEM_TYPE_GRE,
+	RTE_FLOW_ITEM_TYPE_IPV4,
+	RTE_FLOW_ITEM_TYPE_END,
+};
+
+enum rte_flow_item_type iavf_pattern_eth_ipv4_gre_ipv6[] = {
+	RTE_FLOW_ITEM_TYPE_ETH,
+	RTE_FLOW_ITEM_TYPE_IPV4,
+	RTE_FLOW_ITEM_TYPE_GRE,
+	RTE_FLOW_ITEM_TYPE_IPV6,
+	RTE_FLOW_ITEM_TYPE_END,
+};
+
+enum rte_flow_item_type iavf_pattern_eth_ipv6_gre_ipv4[] = {
+	RTE_FLOW_ITEM_TYPE_ETH,
+	RTE_FLOW_ITEM_TYPE_IPV6,
+	RTE_FLOW_ITEM_TYPE_GRE,
+	RTE_FLOW_ITEM_TYPE_IPV4,
+	RTE_FLOW_ITEM_TYPE_END,
+};
+
+enum rte_flow_item_type iavf_pattern_eth_ipv6_gre_ipv6[] = {
+	RTE_FLOW_ITEM_TYPE_ETH,
+	RTE_FLOW_ITEM_TYPE_IPV6,
+	RTE_FLOW_ITEM_TYPE_GRE,
+	RTE_FLOW_ITEM_TYPE_IPV6,
+	RTE_FLOW_ITEM_TYPE_END,
+};
+
+enum rte_flow_item_type iavf_pattern_eth_ipv4_gre_ipv4_tcp[] = {
+	RTE_FLOW_ITEM_TYPE_ETH,
+	RTE_FLOW_ITEM_TYPE_IPV4,
+	RTE_FLOW_ITEM_TYPE_GRE,
+	RTE_FLOW_ITEM_TYPE_IPV4,
+	RTE_FLOW_ITEM_TYPE_TCP,
+	RTE_FLOW_ITEM_TYPE_END,
+};
+
+enum rte_flow_item_type iavf_pattern_eth_ipv4_gre_ipv4_udp[] = {
+	RTE_FLOW_ITEM_TYPE_ETH,
+	RTE_FLOW_ITEM_TYPE_IPV4,
+	RTE_FLOW_ITEM_TYPE_GRE,
+	RTE_FLOW_ITEM_TYPE_IPV4,
+	RTE_FLOW_ITEM_TYPE_UDP,
+	RTE_FLOW_ITEM_TYPE_END,
+};
+
+enum rte_flow_item_type iavf_pattern_eth_ipv4_gre_ipv6_tcp[] = {
+	RTE_FLOW_ITEM_TYPE_ETH,
+	RTE_FLOW_ITEM_TYPE_IPV4,
+	RTE_FLOW_ITEM_TYPE_GRE,
+	RTE_FLOW_ITEM_TYPE_IPV6,
+	RTE_FLOW_ITEM_TYPE_TCP,
+	RTE_FLOW_ITEM_TYPE_END,
+};
+
+enum rte_flow_item_type iavf_pattern_eth_ipv4_gre_ipv6_udp[] = {
+	RTE_FLOW_ITEM_TYPE_ETH,
+	RTE_FLOW_ITEM_TYPE_IPV4,
+	RTE_FLOW_ITEM_TYPE_GRE,
+	RTE_FLOW_ITEM_TYPE_IPV6,
+	RTE_FLOW_ITEM_TYPE_UDP,
+	RTE_FLOW_ITEM_TYPE_END,
+};
+
+enum rte_flow_item_type iavf_pattern_eth_ipv6_gre_ipv4_tcp[] = {
+	RTE_FLOW_ITEM_TYPE_ETH,
+	RTE_FLOW_ITEM_TYPE_IPV6,
+	RTE_FLOW_ITEM_TYPE_GRE,
+	RTE_FLOW_ITEM_TYPE_IPV4,
+	RTE_FLOW_ITEM_TYPE_TCP,
+	RTE_FLOW_ITEM_TYPE_END,
+};
+
+enum rte_flow_item_type iavf_pattern_eth_ipv6_gre_ipv4_udp[] = {
+	RTE_FLOW_ITEM_TYPE_ETH,
+	RTE_FLOW_ITEM_TYPE_IPV6,
+	RTE_FLOW_ITEM_TYPE_GRE,
+	RTE_FLOW_ITEM_TYPE_IPV4,
+	RTE_FLOW_ITEM_TYPE_UDP,
+	RTE_FLOW_ITEM_TYPE_END,
+};
+
+enum rte_flow_item_type iavf_pattern_eth_ipv6_gre_ipv6_tcp[] = {
+	RTE_FLOW_ITEM_TYPE_ETH,
+	RTE_FLOW_ITEM_TYPE_IPV6,
+	RTE_FLOW_ITEM_TYPE_GRE,
+	RTE_FLOW_ITEM_TYPE_IPV6,
+	RTE_FLOW_ITEM_TYPE_TCP,
+	RTE_FLOW_ITEM_TYPE_END,
+};
+
+enum rte_flow_item_type iavf_pattern_eth_ipv6_gre_ipv6_udp[] = {
+	RTE_FLOW_ITEM_TYPE_ETH,
+	RTE_FLOW_ITEM_TYPE_IPV6,
+	RTE_FLOW_ITEM_TYPE_GRE,
+	RTE_FLOW_ITEM_TYPE_IPV6,
+	RTE_FLOW_ITEM_TYPE_UDP,
+	RTE_FLOW_ITEM_TYPE_END,
+};
+
 typedef struct iavf_flow_engine * (*parse_engine_t)(struct iavf_adapter *ad,
 		struct rte_flow *flow,
 		struct iavf_parser_list *parser_list,
drivers/net/iavf/iavf_generic_flow.h +14 -0
index e19da15518..48fd03a973 100644
@@ -308,6 +308,20 @@ extern enum rte_flow_item_type iavf_pattern_eth_ipv6_pfcp[];
 extern enum rte_flow_item_type iavf_pattern_eth_ecpri[];
 extern enum rte_flow_item_type iavf_pattern_eth_ipv4_ecpri[];
 
+/* GRE */
+extern enum rte_flow_item_type iavf_pattern_eth_ipv4_gre_ipv4[];
+extern enum rte_flow_item_type iavf_pattern_eth_ipv4_gre_ipv6[];
+extern enum rte_flow_item_type iavf_pattern_eth_ipv6_gre_ipv4[];
+extern enum rte_flow_item_type iavf_pattern_eth_ipv6_gre_ipv6[];
+extern enum rte_flow_item_type iavf_pattern_eth_ipv4_gre_ipv4_tcp[];
+extern enum rte_flow_item_type iavf_pattern_eth_ipv4_gre_ipv6_tcp[];
+extern enum rte_flow_item_type iavf_pattern_eth_ipv4_gre_ipv4_udp[];
+extern enum rte_flow_item_type iavf_pattern_eth_ipv4_gre_ipv6_udp[];
+extern enum rte_flow_item_type iavf_pattern_eth_ipv6_gre_ipv4_tcp[];
+extern enum rte_flow_item_type iavf_pattern_eth_ipv6_gre_ipv6_tcp[];
+extern enum rte_flow_item_type iavf_pattern_eth_ipv6_gre_ipv4_udp[];
+extern enum rte_flow_item_type iavf_pattern_eth_ipv6_gre_ipv6_udp[];
+
 extern const struct rte_flow_ops iavf_flow_ops;
 
 /* pattern structure */
Signature · 1 line
2.25.1
author
#2 lore raw

PATCH 2/6 common/iavf: add header types for GRE

In reply to Wenjun Wu

Add a virtchnl protocol header type to support AVF FDIR and RSS for GRE.

---
 drivers/common/iavf/virtchnl.h | 1 +
 1 file changed, 1 insertion(+)
drivers/common/iavf/virtchnl.h +1 -0
index 3a60faff93..197edce8a1 100644
@@ -1504,6 +1504,7 @@ enum virtchnl_proto_hdr_type {
 	 */
 	VIRTCHNL_PROTO_HDR_IPV4_FRAG,
 	VIRTCHNL_PROTO_HDR_IPV6_EH_FRAG,
+	VIRTCHNL_PROTO_HDR_GRE,
 };
 
 /* Protocol header field within a protocol header. */
Signature · 1 line
2.25.1
author
#3 lore raw

PATCH 3/6 ethdev: add GRE RSS offload type

In reply to Wenjun Wu

Define new RSS offload type for GRE.

---
 lib/ethdev/rte_ethdev.h | 1 +
 1 file changed, 1 insertion(+)
lib/ethdev/rte_ethdev.h +1 -0
index faf3bd901d..be83456257 100644
@@ -537,6 +537,7 @@ struct rte_eth_rss_conf {
 #define ETH_RSS_PPPOE		   (1ULL << 31)
 #define ETH_RSS_ECPRI		   (1ULL << 32)
 #define ETH_RSS_MPLS		   (1ULL << 33)
+#define ETH_RSS_GRE			   (1ULL << 34)
 
 /*
  * We use the following macros to combine with above ETH_RSS_* for
Signature · 1 line
2.25.1
author
#4 lore raw

PATCH 4/6 net/iavf: support AVF RSS for GRE tunnel packet

In reply to Wenjun Wu

Support AVF RSS for inner header of GRE tunnel packet. It supports RSS based on fields inner IP src + dst address and TCP/UDP src + dst port.

---
 drivers/net/iavf/iavf_hash.c | 37 ++++++++++++++++++++++++++++++------
 1 file changed, 31 insertions(+), 6 deletions(-)
drivers/net/iavf/iavf_hash.c +31 -6
index 5d3d62839b..973591100f 100644
@@ -30,6 +30,7 @@
 #define	IAVF_PHINT_GTPU_EH_UP			BIT_ULL(3)
 #define IAVF_PHINT_OUTER_IPV4			BIT_ULL(4)
 #define IAVF_PHINT_OUTER_IPV6			BIT_ULL(5)
+#define IAVF_PHINT_GRE				BIT_ULL(6)
 
 #define IAVF_PHINT_GTPU_MSK	(IAVF_PHINT_GTPU	| \
 				 IAVF_PHINT_GTPU_EH	| \
@@ -390,6 +391,14 @@ struct virtchnl_proto_hdrs ipv4_ecpri_tmplt = {
 #define IAVF_RSS_TYPE_IPV6_L2TPV3	(ETH_RSS_L2TPV3 | ETH_RSS_IPV6)
 #define IAVF_RSS_TYPE_IPV4_PFCP		(ETH_RSS_PFCP | ETH_RSS_IPV4)
 #define IAVF_RSS_TYPE_IPV6_PFCP		(ETH_RSS_PFCP | ETH_RSS_IPV6)
+/* GRE IPv4 */
+#define IAVF_RSS_TYPE_GRE_IPV4	(ETH_RSS_GRE | IAVF_RSS_TYPE_INNER_IPV4)
+#define IAVF_RSS_TYPE_GRE_IPV4_TCP	(ETH_RSS_GRE | IAVF_RSS_TYPE_INNER_IPV4_TCP)
+#define IAVF_RSS_TYPE_GRE_IPV4_UDP	(ETH_RSS_GRE | IAVF_RSS_TYPE_INNER_IPV4_UDP)
+/* GRE IPv6 */
+#define IAVF_RSS_TYPE_GRE_IPV6	(ETH_RSS_GRE | IAVF_RSS_TYPE_INNER_IPV6)
+#define IAVF_RSS_TYPE_GRE_IPV6_TCP	(ETH_RSS_GRE | IAVF_RSS_TYPE_INNER_IPV6_TCP)
+#define IAVF_RSS_TYPE_GRE_IPV6_UDP	(ETH_RSS_GRE | IAVF_RSS_TYPE_INNER_IPV6_UDP)
 
 /**
  * Supported pattern for hash.
@@ -428,6 +437,12 @@ static struct iavf_pattern_match_item iavf_hash_pattern_list[] = {
 	{iavf_pattern_eth_ipv4_gtpc,			ETH_RSS_IPV4,			&ipv4_udp_gtpc_tmplt},
 	{iavf_pattern_eth_ecpri,			ETH_RSS_ECPRI,			&eth_ecpri_tmplt},
 	{iavf_pattern_eth_ipv4_ecpri,			ETH_RSS_ECPRI,			&ipv4_ecpri_tmplt},
+	{iavf_pattern_eth_ipv4_gre_ipv4,		IAVF_RSS_TYPE_GRE_IPV4,	&inner_ipv4_tmplt},
+	{iavf_pattern_eth_ipv6_gre_ipv4,		IAVF_RSS_TYPE_GRE_IPV4, &inner_ipv4_tmplt},
+	{iavf_pattern_eth_ipv4_gre_ipv4_tcp,	IAVF_RSS_TYPE_GRE_IPV4_TCP, &inner_ipv4_tcp_tmplt},
+	{iavf_pattern_eth_ipv6_gre_ipv4_tcp,	IAVF_RSS_TYPE_GRE_IPV4_TCP, &inner_ipv4_tcp_tmplt},
+	{iavf_pattern_eth_ipv4_gre_ipv4_udp,	IAVF_RSS_TYPE_GRE_IPV4_UDP, &inner_ipv4_udp_tmplt},
+	{iavf_pattern_eth_ipv6_gre_ipv4_udp,	IAVF_RSS_TYPE_GRE_IPV4_UDP, &inner_ipv4_udp_tmplt},
 	/* IPv6 */
 	{iavf_pattern_eth_ipv6,				IAVF_RSS_TYPE_OUTER_IPV6,	&outer_ipv6_tmplt},
 	{iavf_pattern_eth_ipv6_frag_ext,		IAVF_RSS_TYPE_OUTER_IPV6_FRAG,	&outer_ipv6_frag_tmplt},
@@ -458,6 +473,12 @@ static struct iavf_pattern_match_item iavf_hash_pattern_list[] = {
 	{iavf_pattern_eth_ipv6_l2tpv3,			IAVF_RSS_TYPE_IPV6_L2TPV3,	&ipv6_l2tpv3_tmplt},
 	{iavf_pattern_eth_ipv6_pfcp,			IAVF_RSS_TYPE_IPV6_PFCP,	&ipv6_pfcp_tmplt},
 	{iavf_pattern_eth_ipv6_gtpc,			ETH_RSS_IPV6,			&ipv6_udp_gtpc_tmplt},
+	{iavf_pattern_eth_ipv4_gre_ipv6,		IAVF_RSS_TYPE_GRE_IPV6,	&inner_ipv6_tmplt},
+	{iavf_pattern_eth_ipv6_gre_ipv6,		IAVF_RSS_TYPE_GRE_IPV6, &inner_ipv6_tmplt},
+	{iavf_pattern_eth_ipv4_gre_ipv6_tcp,	IAVF_RSS_TYPE_GRE_IPV6_TCP, &inner_ipv6_tcp_tmplt},
+	{iavf_pattern_eth_ipv6_gre_ipv6_tcp,	IAVF_RSS_TYPE_GRE_IPV6_TCP, &inner_ipv6_tcp_tmplt},
+	{iavf_pattern_eth_ipv4_gre_ipv6_udp,	IAVF_RSS_TYPE_GRE_IPV6_UDP, &inner_ipv6_udp_tmplt},
+	{iavf_pattern_eth_ipv6_gre_ipv6_udp,	IAVF_RSS_TYPE_GRE_IPV6_UDP, &inner_ipv6_udp_tmplt},
 };
 
 static struct iavf_flow_engine iavf_hash_engine = {
@@ -592,11 +613,11 @@ iavf_hash_parse_pattern(const struct rte_flow_item pattern[], uint64_t *phint,
 
 		switch (item->type) {
 		case RTE_FLOW_ITEM_TYPE_IPV4:
-			if (!(*phint & IAVF_PHINT_GTPU_MSK))
+			if (!(*phint & IAVF_PHINT_GTPU_MSK) && !(*phint & IAVF_PHINT_GRE))
 				*phint |= IAVF_PHINT_OUTER_IPV4;
 			break;
 		case RTE_FLOW_ITEM_TYPE_IPV6:
-			if (!(*phint & IAVF_PHINT_GTPU_MSK))
+			if (!(*phint & IAVF_PHINT_GTPU_MSK) && !(*phint & IAVF_PHINT_GRE))
 				*phint |= IAVF_PHINT_OUTER_IPV6;
 			break;
 		case RTE_FLOW_ITEM_TYPE_GTPU:
@@ -627,6 +648,8 @@ iavf_hash_parse_pattern(const struct rte_flow_item pattern[], uint64_t *phint,
 				return -rte_errno;
 			}
 			break;
+		case RTE_FLOW_ITEM_TYPE_GRE:
+			*phint |= IAVF_PHINT_GRE;
 		default:
 			break;
 		}
@@ -867,7 +890,7 @@ iavf_refine_proto_hdrs_by_pattern(struct virtchnl_proto_hdrs *proto_hdrs,
 	struct virtchnl_proto_hdr *hdr2;
 	int i, shift_count = 1;
 
-	if (!(phint & IAVF_PHINT_GTPU_MSK))
+	if (!(phint & IAVF_PHINT_GTPU_MSK) && !(phint & IAVF_PHINT_GRE))
 		return;
 
 	if (phint & IAVF_PHINT_LAYERS_MSK)
@@ -883,10 +906,10 @@ iavf_refine_proto_hdrs_by_pattern(struct virtchnl_proto_hdrs *proto_hdrs,
 		}
 
 		if (shift_count == 1) {
-			/* adding gtpu header at layer 0 */
+			/* adding tunnel header at layer 0 */
 			hdr1 = &proto_hdrs->proto_hdr[0];
 		} else {
-			/* adding gtpu header and outer ip header */
+			/* adding tunnel header and outer ip header */
 			hdr1 = &proto_hdrs->proto_hdr[1];
 			hdr2 = &proto_hdrs->proto_hdr[0];
 			hdr2->field_selector = 0;
@@ -913,6 +936,8 @@ iavf_refine_proto_hdrs_by_pattern(struct virtchnl_proto_hdrs *proto_hdrs,
 		VIRTCHNL_SET_PROTO_HDR_TYPE(hdr1, GTPU_EH);
 	else if (phint & IAVF_PHINT_GTPU)
 		VIRTCHNL_SET_PROTO_HDR_TYPE(hdr1, GTPU_IP);
+	else if (phint & IAVF_PHINT_GRE)
+		VIRTCHNL_SET_PROTO_HDR_TYPE(hdr1, GRE);
 }
 
 static void iavf_refine_proto_hdrs(struct virtchnl_proto_hdrs *proto_hdrs,
@@ -1172,8 +1197,8 @@ iavf_hash_create(__rte_unused struct iavf_adapter *ad,
 
 	rss_cfg->proto_hdrs = rss_meta->proto_hdrs;
 	rss_cfg->rss_algorithm = rss_meta->rss_algorithm;
-
 	ret = iavf_add_del_rss_cfg(ad, rss_cfg, true);
+
 	if (!ret) {
 		flow->rule = rss_cfg;
 	} else {
Signature · 1 line
2.25.1
author
#5 lore raw

PATCH 5/6 net/iavf: support AVF FDIR for GRE tunnel packet

In reply to Wenjun Wu

Support AVF FDIR for inner header of GRE tunnel packet.

+------------------------------+---------------------------------------+
|           Pattern            |            Input Set                  |
+------------------------------+---------------------------------------+
| eth/ipv4/gre/ipv4            | inner: src/dst ip, dscp               |
| eth/ipv4/gre/ipv4/udp        | inner: src/dst ip, dscp, src/dst port |
| eth/ipv4/gre/ipv4/tcp        | inner: src/dst ip, dscp, src/dst port |
| eth/ipv4/gre/eh/ipv6         | inner: src/dst ip, tc                 |
| eth/ipv4/gre/eh/ipv6/udp     | inner: src/dst ip, tc, src/dst port   |
| eth/ipv4/gre/eh/ipv6/tcp     | inner: src/dst ip, tc, src/dst port   |
| eth/ipv6/gre/ipv4            | inner: src/dst ip, dscp               |
| eth/ipv6/gre/ipv4/udp        | inner: src/dst ip, dscp, src/dst port |
| eth/ipv6/gre/ipv4/tcp        | inner: src/dst ip, dscp, src/dst port |
| eth/ipv6/gre/ipv6            | inner: src/dst ip, tc                 |
| eth/ipv6/gre/ipv6/udp        | inner: src/dst ip, tc, src/dst port   |
| eth/ipv6/gre/ipv6/tcp        | inner: src/dst ip, tc, src/dst port   |
+------------------------------+---------------------------------------+
---
 drivers/net/iavf/iavf_fdir.c | 55 ++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)
drivers/net/iavf/iavf_fdir.c +55 -0
index f238a83c84..c0b748caca 100644
@@ -139,6 +139,30 @@
 #define IAVF_FDIR_INSET_ECPRI (\
 	IAVF_INSET_ECPRI)
 
+#define IAVF_FDIR_INSET_GRE_IPV4 (\
+	IAVF_INSET_TUN_IPV4_SRC | IAVF_INSET_TUN_IPV4_DST | \
+	IAVF_INSET_TUN_IPV4_TOS | IAVF_INSET_TUN_IPV4_PROTO)
+
+#define IAVF_FDIR_INSET_GRE_IPV4_TCP (\
+	IAVF_FDIR_INSET_GRE_IPV4 | IAVF_INSET_TUN_TCP_SRC_PORT | \
+	IAVF_INSET_TUN_TCP_DST_PORT)
+
+#define IAVF_FDIR_INSET_GRE_IPV4_UDP (\
+	IAVF_FDIR_INSET_GRE_IPV4 | IAVF_INSET_TUN_UDP_SRC_PORT | \
+	IAVF_INSET_TUN_UDP_DST_PORT)
+
+#define IAVF_FDIR_INSET_GRE_IPV6 (\
+	IAVF_INSET_TUN_IPV6_SRC | IAVF_INSET_TUN_IPV6_DST | \
+	IAVF_INSET_TUN_IPV6_TC | IAVF_INSET_TUN_IPV6_NEXT_HDR)
+
+#define IAVF_FDIR_INSET_GRE_IPV6_TCP (\
+	IAVF_FDIR_INSET_GRE_IPV6 | IAVF_INSET_TUN_TCP_SRC_PORT | \
+	IAVF_INSET_TUN_TCP_DST_PORT)
+
+#define IAVF_FDIR_INSET_GRE_IPV6_UDP (\
+	IAVF_FDIR_INSET_GRE_IPV6 | IAVF_INSET_TUN_UDP_SRC_PORT | \
+	IAVF_INSET_TUN_UDP_DST_PORT)
+
 static struct iavf_pattern_match_item iavf_fdir_pattern[] = {
 	{iavf_pattern_ethertype,		 IAVF_FDIR_INSET_ETH,		IAVF_INSET_NONE},
 	{iavf_pattern_eth_ipv4,			 IAVF_FDIR_INSET_ETH_IPV4,	IAVF_INSET_NONE},
@@ -178,6 +202,18 @@ static struct iavf_pattern_match_item iavf_fdir_pattern[] = {
 	{iavf_pattern_eth_ipv6_pfcp,		 IAVF_FDIR_INSET_PFCP,		IAVF_INSET_NONE},
 	{iavf_pattern_eth_ecpri,		 IAVF_FDIR_INSET_ECPRI,		IAVF_INSET_NONE},
 	{iavf_pattern_eth_ipv4_ecpri,		 IAVF_FDIR_INSET_ECPRI,		IAVF_INSET_NONE},
+	{iavf_pattern_eth_ipv4_gre_ipv4,	IAVF_FDIR_INSET_GRE_IPV4,	IAVF_INSET_NONE},
+	{iavf_pattern_eth_ipv4_gre_ipv4_tcp,	IAVF_FDIR_INSET_GRE_IPV4_TCP,	IAVF_INSET_NONE},
+	{iavf_pattern_eth_ipv4_gre_ipv4_udp,	IAVF_FDIR_INSET_GRE_IPV4_UDP,	IAVF_INSET_NONE},
+	{iavf_pattern_eth_ipv4_gre_ipv6,	IAVF_FDIR_INSET_GRE_IPV6,	IAVF_INSET_NONE},
+	{iavf_pattern_eth_ipv4_gre_ipv6_tcp,	IAVF_FDIR_INSET_GRE_IPV6_TCP,	IAVF_INSET_NONE},
+	{iavf_pattern_eth_ipv4_gre_ipv6_udp,	IAVF_FDIR_INSET_GRE_IPV6_UDP,	IAVF_INSET_NONE},
+	{iavf_pattern_eth_ipv6_gre_ipv4,	IAVF_FDIR_INSET_GRE_IPV4,	IAVF_INSET_NONE},
+	{iavf_pattern_eth_ipv6_gre_ipv4_tcp,	IAVF_FDIR_INSET_GRE_IPV4_TCP,	IAVF_INSET_NONE},
+	{iavf_pattern_eth_ipv6_gre_ipv4_udp,	IAVF_FDIR_INSET_GRE_IPV4_UDP,	IAVF_INSET_NONE},
+	{iavf_pattern_eth_ipv6_gre_ipv6,	IAVF_FDIR_INSET_GRE_IPV6,	IAVF_INSET_NONE},
+	{iavf_pattern_eth_ipv6_gre_ipv6_tcp,	IAVF_FDIR_INSET_GRE_IPV6_TCP,	IAVF_INSET_NONE},
+	{iavf_pattern_eth_ipv6_gre_ipv6_udp,	IAVF_FDIR_INSET_GRE_IPV6_UDP,	IAVF_INSET_NONE},
 };
 
 static struct iavf_flow_parser iavf_fdir_parser;
@@ -596,6 +632,7 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 	const struct rte_flow_item_ah *ah_spec, *ah_mask;
 	const struct rte_flow_item_pfcp *pfcp_spec, *pfcp_mask;
 	const struct rte_flow_item_ecpri *ecpri_spec, *ecpri_mask;
+	const struct rte_flow_item_gre *gre_spec, *gre_mask;
 	const struct rte_flow_item *item = pattern;
 	struct virtchnl_proto_hdr *hdr, *hdr1 = NULL;
 	struct rte_ecpri_common_hdr ecpri_common;
@@ -1195,6 +1232,24 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 			hdrs->count = ++layer;
 			break;
 
+		case RTE_FLOW_ITEM_TYPE_GRE:
+			gre_spec = item->spec;
+			gre_mask = item->mask;
+
+			hdr = &hdrs->proto_hdr[layer];
+
+			VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, GRE);
+
+			if (gre_spec && gre_mask) {
+				rte_memcpy(hdr->buffer, gre_spec,
+					   sizeof(*gre_spec));
+			}
+
+			tun_inner = 1;
+
+			hdrs->count = ++layer;
+			break;
+
 		case RTE_FLOW_ITEM_TYPE_VOID:
 			break;
 
Signature · 1 line
2.25.1
author
#6 lore raw

PATCH 6/6 net/ice/base: support FDIR for GRE tunnel packet

In reply to Wenjun Wu

Add support for FDIR of inner header of GRE tunnel packet.

---
 drivers/net/ice/base/ice_fdir.c | 352 ++++++++++++++++++++++++++++++++
 drivers/net/ice/base/ice_fdir.h |   2 +
 drivers/net/ice/base/ice_flow.c |  16 +-
 drivers/net/ice/base/ice_type.h |  14 ++
 4 files changed, 375 insertions(+), 9 deletions(-)
drivers/net/ice/base/ice_fdir.c +352 -0
index 180508243d..b9fd98d562 100644
@@ -518,6 +518,180 @@ static const u8 ice_fdir_ipv4_udp_ecpri_tp0_pkt[] = {
 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 };
 
+/* IPV4 GRE INNER IPV4 */
+static const u8 ice_fdir_ipv4_gre4_pkt[] = {
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x45, 0x00,
+	0x00, 0x2e, 0x00, 0x01, 0x00, 0x00, 0x40, 0x2f,
+	0x7c, 0x9e, 0x7f, 0x00, 0x00, 0x01, 0x7f, 0x00,
+	0x00, 0x01, 0x00, 0x00, 0x08, 0x00, 0x45, 0x00,
+	0x00, 0x16, 0x00, 0x01, 0x00, 0x00, 0x40, 0x00,
+	0x7c, 0xe5, 0x7f, 0x00, 0x00, 0x01, 0x7f, 0x00,
+	0x00, 0x01, 0x00, 0x00,
+};
+
+static const u8 ice_fdir_udp4_gre4_pkt[] = {
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x45, 0x00,
+	0x00, 0x36, 0x00, 0x01, 0x00, 0x00, 0x40, 0x2f,
+	0x7c, 0x96, 0x7f, 0x00, 0x00, 0x01, 0x7f, 0x00,
+	0x00, 0x01, 0x00, 0x00, 0x08, 0x00, 0x45, 0x00,
+	0x00, 0x1e, 0x00, 0x01, 0x00, 0x00, 0x40, 0x11,
+	0x7c, 0xcc, 0x7f, 0x00, 0x00, 0x01, 0x7f, 0x00,
+	0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a,
+	0x01, 0xd8, 0x00, 0x00,
+};
+
+static const u8 ice_fdir_tcp4_gre4_pkt[] = {
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x45, 0x00,
+	0x00, 0x42, 0x00, 0x01, 0x00, 0x00, 0x40, 0x2f,
+	0x7c, 0x8a, 0x7f, 0x00, 0x00, 0x01, 0x7f, 0x00,
+	0x00, 0x01, 0x00, 0x00, 0x08, 0x00, 0x45, 0x00,
+	0x00, 0x2a, 0x00, 0x01, 0x00, 0x00, 0x40, 0x06,
+	0x7c, 0xcb, 0x7f, 0x00, 0x00, 0x01, 0x7f, 0x00,
+	0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x02,
+	0x20, 0x00, 0x91, 0xde, 0x00, 0x00, 0x00, 0x00,
+};
+
+/* IPV4 GRE INNER IPV6 */
+static const u8 ice_fdir_ipv6_gre4_pkt[] = {
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x45, 0x00,
+	0x00, 0x42, 0x00, 0x01, 0x00, 0x00, 0x40, 0x2f,
+	0x7c, 0x8a, 0x7f, 0x00, 0x00, 0x01, 0x7f, 0x00,
+	0x00, 0x01, 0x00, 0x00, 0x86, 0xdd, 0x60, 0x00,
+	0x00, 0x00, 0x00, 0x02, 0x3b, 0x40, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
+};
+
+static const u8 ice_fdir_udp6_gre4_pkt[] = {
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x45, 0x00,
+	0x00, 0x4a, 0x00, 0x01, 0x00, 0x00, 0x40, 0x2f,
+	0x7c, 0x82, 0x7f, 0x00, 0x00, 0x01, 0x7f, 0x00,
+	0x00, 0x01, 0x00, 0x00, 0x86, 0xdd, 0x60, 0x00,
+	0x00, 0x00, 0x00, 0x0a, 0x11, 0x40, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x0a, 0xff, 0xd8, 0x00, 0x00,
+};
+
+static const u8 ice_fdir_tcp6_gre4_pkt[] = {
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x45, 0x00,
+	0x00, 0x56, 0x00, 0x01, 0x00, 0x00, 0x40, 0x2f,
+	0x7c, 0x76, 0x7f, 0x00, 0x00, 0x01, 0x7f, 0x00,
+	0x00, 0x01, 0x00, 0x00, 0x86, 0xdd, 0x60, 0x00,
+	0x00, 0x00, 0x00, 0x16, 0x06, 0x40, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x50, 0x02, 0x20, 0x00, 0x8f, 0xdf,
+	0x00, 0x00, 0x00, 0x00,
+};
+
+/* IPV6 GRE INNER IPV4 */
+static const u8 ice_fdir_ipv4_gre6_pkt[] = {
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x86, 0xDD, 0x60, 0x00,
+	0x00, 0x00, 0x00, 0x18, 0x2F, 0x40, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
+	0x08, 0x00, 0x45, 0x00, 0x00, 0x14, 0x00, 0x01,
+	0x00, 0x00, 0x40, 0x00, 0x7A, 0xEA, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+
+static const u8 ice_fdir_udp4_gre6_pkt[] = {
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x86, 0xDD, 0x60, 0x00,
+	0x00, 0x00, 0x00, 0x20, 0x2F, 0x40, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
+	0x08, 0x00, 0x45, 0x00, 0x00, 0x1C, 0x00, 0x01,
+	0x00, 0x00, 0x40, 0x11, 0x7A, 0xD1, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x08, 0xFF, 0xDE, 0x00, 0x00,
+};
+
+static const u8 ice_fdir_tcp4_gre6_pkt[] = {
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x86, 0xDD, 0x60, 0x00,
+	0x00, 0x00, 0x00, 0x2C, 0x2F, 0x40, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
+	0x08, 0x00, 0x45, 0x00, 0x00, 0x28, 0x00, 0x01,
+	0x00, 0x00, 0x40, 0x06, 0x7A, 0xD0, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x50, 0x02, 0x20, 0x00, 0x8F, 0xE3,
+	0x00, 0x00, 0x00, 0x00,
+};
+
+/* IPV6 GRE INNER IPV6 */
+static const u8 ice_fdir_ipv6_gre6_pkt[] = {
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x86, 0xDD, 0x60, 0x00,
+	0x00, 0x00, 0x00, 0x2C, 0x2F, 0x40, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
+	0x86, 0xDD, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x3B, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x01, 0x00, 0x00,
+};
+
+static const u8 ice_fdir_udp6_gre6_pkt[] = {
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x86, 0xDD, 0x60, 0x00,
+	0x00, 0x00, 0x00, 0x34, 0x2F, 0x40, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
+	0x08, 0x00, 0x45, 0x00, 0x00, 0x1C, 0x00, 0x01,
+	0x00, 0x00, 0x40, 0x11, 0x7A, 0xD1, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x08, 0xFF, 0xDE, 0x00, 0x00,
+};
+
+static const u8 ice_fdir_tcp6_gre6_pkt[] = {
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x86, 0xDD, 0x60, 0x00,
+	0x00, 0x00, 0x00, 0x40, 0x2F, 0x40, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
+	0x86, 0xDD, 0x60, 0x00, 0x00, 0x00, 0x00, 0x14,
+	0x06, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x02,
+	0x20, 0x00, 0x8F, 0xE1, 0x00, 0x00, 0x00, 0x00,
+};
+
 static const u8 ice_fdir_ipv6_frag_pkt[] = {
 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 	0x00, 0x00, 0x00, 0x00, 0x86, 0xDD, 0x60, 0x00,
@@ -1035,6 +1209,94 @@ static const struct ice_fdir_base_pkt ice_fdir_pkt[] = {
 		sizeof(ice_fdir_ipv4_udp_ecpri_tp0_pkt),
 		ice_fdir_ipv4_udp_ecpri_tp0_pkt,
 	},
+	/* IPV4 GRE INNER IPV4 */
+	{
+		ICE_FLTR_PTYPE_NONF_IPV4_GRE_IPV4,
+		sizeof(ice_fdir_ipv4_gre4_pkt),
+		ice_fdir_ipv4_gre4_pkt,
+		sizeof(ice_fdir_ipv4_gre4_pkt),
+		ice_fdir_ipv4_gre4_pkt,
+	},
+	{
+		ICE_FLTR_PTYPE_NONF_IPV4_GRE_IPV4_UDP,
+		sizeof(ice_fdir_udp4_gre4_pkt),
+		ice_fdir_udp4_gre4_pkt,
+		sizeof(ice_fdir_udp4_gre4_pkt),
+		ice_fdir_udp4_gre4_pkt,
+	},
+	{
+		ICE_FLTR_PTYPE_NONF_IPV4_GRE_IPV4_TCP,
+		sizeof(ice_fdir_tcp4_gre4_pkt),
+		ice_fdir_tcp4_gre4_pkt,
+		sizeof(ice_fdir_tcp4_gre4_pkt),
+		ice_fdir_tcp4_gre4_pkt,
+	},
+	/* IPV4 GRE INNER IPV6 */
+	{
+		ICE_FLTR_PTYPE_NONF_IPV4_GRE_IPV6,
+		sizeof(ice_fdir_ipv6_gre4_pkt),
+		ice_fdir_ipv6_gre4_pkt,
+		sizeof(ice_fdir_ipv6_gre4_pkt),
+		ice_fdir_ipv6_gre4_pkt,
+	},
+	{
+		ICE_FLTR_PTYPE_NONF_IPV4_GRE_IPV6_UDP,
+		sizeof(ice_fdir_udp6_gre4_pkt),
+		ice_fdir_udp6_gre4_pkt,
+		sizeof(ice_fdir_udp6_gre4_pkt),
+		ice_fdir_udp6_gre4_pkt,
+	},
+	{
+		ICE_FLTR_PTYPE_NONF_IPV4_GRE_IPV6_TCP,
+		sizeof(ice_fdir_tcp6_gre4_pkt),
+		ice_fdir_tcp6_gre4_pkt,
+		sizeof(ice_fdir_tcp6_gre4_pkt),
+		ice_fdir_tcp6_gre4_pkt,
+	},
+	/* IPV6 GRE INNER IPV4 */
+	{
+		ICE_FLTR_PTYPE_NONF_IPV6_GRE_IPV4,
+		sizeof(ice_fdir_ipv4_gre6_pkt),
+		ice_fdir_ipv4_gre6_pkt,
+		sizeof(ice_fdir_ipv4_gre6_pkt),
+		ice_fdir_ipv4_gre6_pkt,
+	},
+	{
+		ICE_FLTR_PTYPE_NONF_IPV6_GRE_IPV4_UDP,
+		sizeof(ice_fdir_udp4_gre6_pkt),
+		ice_fdir_udp4_gre6_pkt,
+		sizeof(ice_fdir_udp4_gre6_pkt),
+		ice_fdir_udp4_gre6_pkt,
+	},
+	{
+		ICE_FLTR_PTYPE_NONF_IPV6_GRE_IPV4_TCP,
+		sizeof(ice_fdir_tcp4_gre6_pkt),
+		ice_fdir_tcp4_gre6_pkt,
+		sizeof(ice_fdir_tcp4_gre6_pkt),
+		ice_fdir_tcp4_gre6_pkt,
+	},
+	/* IPV4 GRE INNER IPV6 */
+	{
+		ICE_FLTR_PTYPE_NONF_IPV6_GRE_IPV6,
+		sizeof(ice_fdir_ipv6_gre6_pkt),
+		ice_fdir_ipv6_gre6_pkt,
+		sizeof(ice_fdir_ipv6_gre6_pkt),
+		ice_fdir_ipv6_gre6_pkt,
+	},
+	{
+		ICE_FLTR_PTYPE_NONF_IPV6_GRE_IPV6_UDP,
+		sizeof(ice_fdir_udp6_gre6_pkt),
+		ice_fdir_udp6_gre6_pkt,
+		sizeof(ice_fdir_udp6_gre6_pkt),
+		ice_fdir_udp6_gre6_pkt,
+	},
+	{
+		ICE_FLTR_PTYPE_NONF_IPV6_GRE_IPV6_TCP,
+		sizeof(ice_fdir_tcp6_gre6_pkt),
+		ice_fdir_tcp6_gre6_pkt,
+		sizeof(ice_fdir_tcp6_gre6_pkt),
+		ice_fdir_tcp6_gre6_pkt,
+	},
 	{
 		ICE_FLTR_PTYPE_NONF_IPV6_TCP,
 		sizeof(ice_fdir_tcpv6_pkt), ice_fdir_tcpv6_pkt,
@@ -1503,6 +1765,28 @@ ice_fdir_get_gen_prgm_pkt(struct ice_hw *hw, struct ice_fdir_fltr *input,
 				   ICE_NONDMA_TO_NONDMA);
 			loc = &pkt[ICE_FDIR_GTPU_EH_INNER_PKT_OFF];
 			break;
+		case ICE_FLTR_PTYPE_NONF_IPV4_GRE_IPV4:
+		case ICE_FLTR_PTYPE_NONF_IPV4_GRE_IPV4_UDP:
+		case ICE_FLTR_PTYPE_NONF_IPV4_GRE_IPV4_TCP:
+		case ICE_FLTR_PTYPE_NONF_IPV4_GRE_IPV6:
+		case ICE_FLTR_PTYPE_NONF_IPV4_GRE_IPV6_UDP:
+		case ICE_FLTR_PTYPE_NONF_IPV4_GRE_IPV6_TCP:
+			ice_memcpy(pkt, ice_fdir_pkt[idx].tun_pkt,
+				   ice_fdir_pkt[idx].tun_pkt_len,
+				   ICE_NONDMA_TO_NONDMA);
+			loc = &pkt[ICE_FDIR_IPV4_GRE_INNER_PKT_OFF];
+			break;
+		case ICE_FLTR_PTYPE_NONF_IPV6_GRE_IPV4:
+		case ICE_FLTR_PTYPE_NONF_IPV6_GRE_IPV4_UDP:
+		case ICE_FLTR_PTYPE_NONF_IPV6_GRE_IPV4_TCP:
+		case ICE_FLTR_PTYPE_NONF_IPV6_GRE_IPV6:
+		case ICE_FLTR_PTYPE_NONF_IPV6_GRE_IPV6_UDP:
+		case ICE_FLTR_PTYPE_NONF_IPV6_GRE_IPV6_TCP:
+			ice_memcpy(pkt, ice_fdir_pkt[idx].tun_pkt,
+				   ice_fdir_pkt[idx].tun_pkt_len,
+				   ICE_NONDMA_TO_NONDMA);
+			loc = &pkt[ICE_FDIR_IPV6_GRE_INNER_PKT_OFF];
+			break;
 		default:
 			if (ice_fdir_get_open_tunnel_port(hw, flow, &tnl_port))
 				return ICE_ERR_DOES_NOT_EXIST;
@@ -1787,6 +2071,74 @@ ice_fdir_get_gen_prgm_pkt(struct ice_hw *hw, struct ice_fdir_fltr *input,
 		ice_pkt_insert_u16(pkt, ICE_IPV4_UDP_ECPRI_TP0_PC_ID_OFFSET,
 				   input->ecpri_data.pc_id);
 		break;
+	case ICE_FLTR_PTYPE_NONF_IPV4_GRE_IPV4:
+	case ICE_FLTR_PTYPE_NONF_IPV6_GRE_IPV4:
+		ice_pkt_insert_u32(loc, ICE_IPV4_NO_MAC_DST_ADDR_OFFSET,
+				   input->ip.v4.src_ip);
+		ice_pkt_insert_u32(loc, ICE_IPV4_NO_MAC_SRC_ADDR_OFFSET,
+				   input->ip.v4.dst_ip);
+		ice_pkt_insert_u8(loc, ICE_IPV4_NO_MAC_TOS_OFFSET, input->ip.v4.tos);
+		ice_pkt_insert_u8(loc, ICE_IPV4_NO_MAC_PROTO_OFFSET,
+				  input->ip.v4.proto);
+		break;
+	case ICE_FLTR_PTYPE_NONF_IPV4_GRE_IPV4_TCP:
+	case ICE_FLTR_PTYPE_NONF_IPV6_GRE_IPV4_TCP:
+		ice_pkt_insert_u32(loc, ICE_IPV4_NO_MAC_DST_ADDR_OFFSET,
+				   input->ip.v4.src_ip);
+		ice_pkt_insert_u16(loc, ICE_TCP4_NO_MAC_DST_PORT_OFFSET,
+				   input->ip.v4.src_port);
+		ice_pkt_insert_u32(loc, ICE_IPV4_NO_MAC_SRC_ADDR_OFFSET,
+				   input->ip.v4.dst_ip);
+		ice_pkt_insert_u16(loc, ICE_TCP4_NO_MAC_SRC_PORT_OFFSET,
+				   input->ip.v4.dst_port);
+		ice_pkt_insert_u8(loc, ICE_IPV4_NO_MAC_TOS_OFFSET, input->ip.v4.tos);
+		break;
+	case ICE_FLTR_PTYPE_NONF_IPV4_GRE_IPV4_UDP:
+	case ICE_FLTR_PTYPE_NONF_IPV6_GRE_IPV4_UDP:
+		ice_pkt_insert_u32(loc, ICE_IPV4_NO_MAC_DST_ADDR_OFFSET,
+				   input->ip.v4.src_ip);
+		ice_pkt_insert_u16(loc, ICE_UDP4_NO_MAC_DST_PORT_OFFSET,
+				   input->ip.v4.src_port);
+		ice_pkt_insert_u32(loc, ICE_IPV4_NO_MAC_SRC_ADDR_OFFSET,
+				   input->ip.v4.dst_ip);
+		ice_pkt_insert_u16(loc, ICE_UDP4_NO_MAC_SRC_PORT_OFFSET,
+				   input->ip.v4.dst_port);
+		ice_pkt_insert_u8(loc, ICE_IPV4_NO_MAC_TOS_OFFSET, input->ip.v4.tos);
+		break;
+	case ICE_FLTR_PTYPE_NONF_IPV4_GRE_IPV6:
+	case ICE_FLTR_PTYPE_NONF_IPV6_GRE_IPV6:
+		ice_pkt_insert_ipv6_addr(loc, ICE_IPV6_NO_MAC_DST_ADDR_OFFSET,
+					 input->ip.v6.src_ip);
+		ice_pkt_insert_ipv6_addr(loc, ICE_IPV6_NO_MAC_SRC_ADDR_OFFSET,
+					 input->ip.v6.dst_ip);
+		ice_pkt_insert_u8_tc(loc, ICE_IPV6_NO_MAC_TC_OFFSET, input->ip.v6.tc);
+		ice_pkt_insert_u8(loc, ICE_IPV6_NO_MAC_PROTO_OFFSET,
+				  input->ip.v6.proto);
+		break;
+	case ICE_FLTR_PTYPE_NONF_IPV4_GRE_IPV6_TCP:
+	case ICE_FLTR_PTYPE_NONF_IPV6_GRE_IPV6_TCP:
+		ice_pkt_insert_ipv6_addr(loc, ICE_IPV6_NO_MAC_DST_ADDR_OFFSET,
+					 input->ip.v6.src_ip);
+		ice_pkt_insert_ipv6_addr(loc, ICE_IPV6_NO_MAC_SRC_ADDR_OFFSET,
+					 input->ip.v6.dst_ip);
+		ice_pkt_insert_u16(loc, ICE_TCP6_NO_MAC_DST_PORT_OFFSET,
+				   input->ip.v6.src_port);
+		ice_pkt_insert_u16(loc, ICE_TCP6_NO_MAC_SRC_PORT_OFFSET,
+				   input->ip.v6.dst_port);
+		ice_pkt_insert_u8_tc(loc, ICE_IPV6_NO_MAC_TC_OFFSET, input->ip.v6.tc);
+		break;
+	case ICE_FLTR_PTYPE_NONF_IPV4_GRE_IPV6_UDP:
+	case ICE_FLTR_PTYPE_NONF_IPV6_GRE_IPV6_UDP:
+		ice_pkt_insert_ipv6_addr(loc, ICE_IPV6_NO_MAC_DST_ADDR_OFFSET,
+					 input->ip.v6.src_ip);
+		ice_pkt_insert_ipv6_addr(loc, ICE_IPV6_NO_MAC_SRC_ADDR_OFFSET,
+					 input->ip.v6.dst_ip);
+		ice_pkt_insert_u16(loc, ICE_UDP6_NO_MAC_DST_PORT_OFFSET,
+				   input->ip.v6.src_port);
+		ice_pkt_insert_u16(loc, ICE_UDP6_NO_MAC_SRC_PORT_OFFSET,
+				   input->ip.v6.dst_port);
+		ice_pkt_insert_u8_tc(loc, ICE_IPV6_NO_MAC_TC_OFFSET, input->ip.v6.tc);
+		break;
 	case ICE_FLTR_PTYPE_NONF_IPV6_TCP:
 		ice_pkt_insert_ipv6_addr(loc, ICE_IPV6_DST_ADDR_OFFSET,
 					 input->ip.v6.src_ip);
drivers/net/ice/base/ice_fdir.h +2 -0
index 0ebf7f326c..771ac3af16 100644
@@ -16,6 +16,8 @@
 
 #define ICE_FDIR_GTPU_IP_INNER_PKT_OFF 50
 #define ICE_FDIR_GTPU_EH_INNER_PKT_OFF 58
+#define ICE_FDIR_IPV4_GRE_INNER_PKT_OFF 38
+#define ICE_FDIR_IPV6_GRE_INNER_PKT_OFF 58
 
 #define ICE_FDIR_TUN_PKT_OFF		50
 #define ICE_FDIR_MAX_RAW_PKT_SIZE	(512 + ICE_FDIR_TUN_PKT_OFF)
drivers/net/ice/base/ice_flow.c +7 -9
index d6242744cd..dfadb321c3 100644
@@ -257,7 +257,7 @@ static const u32 ice_ptypes_ipv4_ofos[] = {
  * IPV4 other PTYPEs
  */
 static const u32 ice_ptypes_ipv4_ofos_all[] = {
-	0x1DC00000, 0x24000800, 0x00000000, 0x00000000,
+	0x1DC00000, 0x27BF7800, 0x00000000, 0x00000000,
 	0x00000000, 0x00000155, 0x00000000, 0x00000000,
 	0x00000000, 0x000FC000, 0x83E0FAA0, 0x00000101,
 	0x03FFD500, 0x00000000, 0x00000000, 0x00000000,
@@ -297,7 +297,7 @@ static const u32 ice_ptypes_ipv6_ofos[] = {
  * IPV6 other PTYPEs
  */
 static const u32 ice_ptypes_ipv6_ofos_all[] = {
-	0x00000000, 0x00000000, 0x77000000, 0x10002000,
+	0x00000000, 0x00000000, 0x77000000, 0x1EFDE000,
 	0x00000000, 0x000002AA, 0x00000000, 0x00000000,
 	0x00000000, 0x03F00000, 0x7C1F0540, 0x00000206,
 	0xFC002A00, 0x0000003F, 0x00000000, 0x00000000,
@@ -444,7 +444,7 @@ static const u32 ice_ptypes_icmp_il[] = {
 /* Packet types for packets with an Outermost/First GRE header */
 static const u32 ice_ptypes_gre_of[] = {
 	0x00000000, 0xBFBF7800, 0x000001DF, 0xFEFDE000,
-	0x0000017E, 0x00000000, 0x00000000, 0x00000000,
+	0x0000077E, 0x00000000, 0x00000000, 0x00000000,
 	0x00000000, 0x00000000, 0x00000000, 0x00000000,
 	0x00000000, 0x00000000, 0x00000000, 0x00000000,
 	0x00000000, 0x00000000, 0x00000000, 0x00000000,
@@ -803,7 +803,7 @@ struct ice_flow_prof_params {
 	ICE_FLOW_SEG_HDR_ESP | ICE_FLOW_SEG_HDR_AH | \
 	ICE_FLOW_SEG_HDR_NAT_T_ESP | ICE_FLOW_SEG_HDR_GTPU_NON_IP | \
 	ICE_FLOW_SEG_HDR_ECPRI_TP0 | ICE_FLOW_SEG_HDR_UDP_ECPRI_TP0 | \
-	ICE_FLOW_SEG_HDR_L2TPV2 | ICE_FLOW_SEG_HDR_PPP)
+	ICE_FLOW_SEG_HDR_L2TPV2 | ICE_FLOW_SEG_HDR_PPP | ICE_FLOW_SEG_HDR_GRE)
 
 #define ICE_FLOW_SEG_HDRS_L2_MASK	\
 	(ICE_FLOW_SEG_HDR_ETH | ICE_FLOW_SEG_HDR_VLAN)
@@ -1020,11 +1020,9 @@ ice_flow_proc_seg_hdrs(struct ice_flow_prof_params *params)
 			ice_and_bitmap(params->ptypes, params->ptypes, src,
 				       ICE_FLOW_PTYPE_MAX);
 		} else if (hdrs & ICE_FLOW_SEG_HDR_GRE) {
-			if (!i) {
-				src = (const ice_bitmap_t *)ice_ptypes_gre_of;
-				ice_and_bitmap(params->ptypes, params->ptypes,
-					       src, ICE_FLOW_PTYPE_MAX);
-			}
+			src = (const ice_bitmap_t *)ice_ptypes_gre_of;
+			ice_and_bitmap(params->ptypes, params->ptypes,
+				       src, ICE_FLOW_PTYPE_MAX);
 		} else if (hdrs & ICE_FLOW_SEG_HDR_GTPC) {
 			src = (const ice_bitmap_t *)ice_ptypes_gtpc;
 			ice_and_bitmap(params->ptypes, params->ptypes,
drivers/net/ice/base/ice_type.h +14 -0
index ce508a02e5..8dba531e1a 100644
@@ -348,6 +348,20 @@ enum ice_fltr_ptype {
 	ICE_FLTR_PTYPE_NONF_IPV4_UDP_ECPRI_TP0,
 	ICE_FLTR_PTYPE_FRAG_IPV4,
 	ICE_FLTR_PTYPE_FRAG_IPV6,
+	ICE_FLTR_PTYPE_NONF_IPV4_GRE,
+	ICE_FLTR_PTYPE_NONF_IPV4_GRE_IPV4,
+	ICE_FLTR_PTYPE_NONF_IPV4_GRE_IPV4_UDP,
+	ICE_FLTR_PTYPE_NONF_IPV4_GRE_IPV4_TCP,
+	ICE_FLTR_PTYPE_NONF_IPV4_GRE_IPV6,
+	ICE_FLTR_PTYPE_NONF_IPV4_GRE_IPV6_UDP,
+	ICE_FLTR_PTYPE_NONF_IPV4_GRE_IPV6_TCP,
+	ICE_FLTR_PTYPE_NONF_IPV6_GRE,
+	ICE_FLTR_PTYPE_NONF_IPV6_GRE_IPV4,
+	ICE_FLTR_PTYPE_NONF_IPV6_GRE_IPV4_UDP,
+	ICE_FLTR_PTYPE_NONF_IPV6_GRE_IPV4_TCP,
+	ICE_FLTR_PTYPE_NONF_IPV6_GRE_IPV6,
+	ICE_FLTR_PTYPE_NONF_IPV6_GRE_IPV6_UDP,
+	ICE_FLTR_PTYPE_NONF_IPV6_GRE_IPV6_TCP,
 	ICE_FLTR_PTYPE_NONF_IPV6_UDP,
 	ICE_FLTR_PTYPE_NONF_IPV6_TCP,
 	ICE_FLTR_PTYPE_NONF_IPV6_SCTP,
Signature · 1 line
2.25.1