DPDK patches and discussions
 help / color / mirror / Atom feed
From: Chaoyong He <chaoyong.he@corigine.com>
To: dev@dpdk.org
Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com,
	Chaoyong He <chaoyong.he@corigine.com>
Subject: [PATCH v3 20/26] net/nfp: prepare for IPv4 GRE tunnel decap flow action
Date: Tue, 25 Oct 2022 15:59:12 +0800	[thread overview]
Message-ID: <20221025075918.7778-21-chaoyong.he@corigine.com> (raw)
In-Reply-To: <20221025075918.7778-1-chaoyong.he@corigine.com>

Add the related data structure and logics, prepare for
the decap action of IPv4 GRE tunnel.

Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
---
 drivers/net/nfp/flower/nfp_flower_cmsg.h | 29 +++++++++++++++++
 drivers/net/nfp/nfp_flow.c               | 40 ++++++++++++++++++------
 drivers/net/nfp/nfp_flow.h               |  3 ++
 3 files changed, 63 insertions(+), 9 deletions(-)

diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.h b/drivers/net/nfp/flower/nfp_flower_cmsg.h
index 61f2f83fc9..8bca7c2fa2 100644
--- a/drivers/net/nfp/flower/nfp_flower_cmsg.h
+++ b/drivers/net/nfp/flower/nfp_flower_cmsg.h
@@ -575,6 +575,35 @@ struct nfp_flower_ipv6_udp_tun {
 	rte_be32_t tun_id;
 };
 
+/*
+ * Flow Frame GRE TUNNEL --> Tunnel details (6W/24B)
+ * -----------------------------------------------------------------
+ *    3                   2                   1
+ *  1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |                         ipv4_addr_src                         |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |                         ipv4_addr_dst                         |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |           tun_flags           |       tos     |       ttl     |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |            Reserved           |           Ethertype           |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |                              Key                              |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |                           Reserved                            |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+struct nfp_flower_ipv4_gre_tun {
+	struct nfp_flower_tun_ipv4 ipv4;
+	rte_be16_t tun_flags;
+	struct nfp_flower_tun_ip_ext ip_ext;
+	rte_be16_t reserved1;
+	rte_be16_t ethertype;
+	rte_be32_t tun_key;
+	rte_be32_t reserved2;
+};
+
 struct nfp_fl_act_head {
 	uint8_t jump_id;
 	uint8_t len_lw;
diff --git a/drivers/net/nfp/nfp_flow.c b/drivers/net/nfp/nfp_flow.c
index 06115cc954..115b9cbb92 100644
--- a/drivers/net/nfp/nfp_flow.c
+++ b/drivers/net/nfp/nfp_flow.c
@@ -564,6 +564,7 @@ nfp_tun_check_ip_off_del(struct nfp_flower_representor *repr,
 	uint32_t key_layer2 = 0;
 	struct nfp_flower_ipv4_udp_tun *udp4;
 	struct nfp_flower_ipv6_udp_tun *udp6;
+	struct nfp_flower_ipv4_gre_tun *gre4;
 	struct nfp_flower_meta_tci *meta_tci;
 	struct nfp_flower_ext_meta *ext_meta = NULL;
 
@@ -579,9 +580,15 @@ nfp_tun_check_ip_off_del(struct nfp_flower_representor *repr,
 				sizeof(struct nfp_flower_ipv6_udp_tun));
 		ret = nfp_tun_del_ipv6_off(repr->app_fw_flower, udp6->ipv6.ipv6_dst);
 	} else {
-		udp4 = (struct nfp_flower_ipv4_udp_tun *)(nfp_flow->payload.mask_data -
-				sizeof(struct nfp_flower_ipv4_udp_tun));
-		ret = nfp_tun_del_ipv4_off(repr->app_fw_flower, udp4->ipv4.dst);
+		if (key_layer2 & NFP_FLOWER_LAYER2_GRE) {
+			gre4 = (struct nfp_flower_ipv4_gre_tun *)(nfp_flow->payload.mask_data -
+					sizeof(struct nfp_flower_ipv4_gre_tun));
+			ret = nfp_tun_del_ipv4_off(repr->app_fw_flower, gre4->ipv4.dst);
+		} else {
+			udp4 = (struct nfp_flower_ipv4_udp_tun *)(nfp_flow->payload.mask_data -
+					sizeof(struct nfp_flower_ipv4_udp_tun));
+			ret = nfp_tun_del_ipv4_off(repr->app_fw_flower, udp4->ipv4.dst);
+		}
 	}
 
 	return ret;
@@ -1013,7 +1020,7 @@ nfp_flow_is_tunnel(struct rte_flow *nfp_flow)
 
 	ext_meta = (struct nfp_flower_ext_meta *)(meta_tci + 1);
 	key_layer2 = rte_be_to_cpu_32(ext_meta->nfp_flow_key_layer2);
-	if (key_layer2 & NFP_FLOWER_LAYER2_GENEVE)
+	if (key_layer2 & (NFP_FLOWER_LAYER2_GENEVE | NFP_FLOWER_LAYER2_GRE))
 		return true;
 
 	return false;
@@ -1102,11 +1109,15 @@ nfp_flow_merge_ipv4(__rte_unused struct nfp_app_fw_flower *app_fw_flower,
 	struct nfp_flower_meta_tci *meta_tci;
 	const struct rte_flow_item_ipv4 *spec;
 	const struct rte_flow_item_ipv4 *mask;
+	struct nfp_flower_ext_meta *ext_meta = NULL;
 	struct nfp_flower_ipv4_udp_tun *ipv4_udp_tun;
+	struct nfp_flower_ipv4_gre_tun *ipv4_gre_tun;
 
 	spec = item->spec;
 	mask = item->mask ? item->mask : proc->mask_default;
 	meta_tci = (struct nfp_flower_meta_tci *)nfp_flow->payload.unmasked_data;
+	if (meta_tci->nfp_flow_key_layer & NFP_FLOWER_LAYER_EXT_META)
+		ext_meta = (struct nfp_flower_ext_meta *)(meta_tci + 1);
 
 	if (is_outer_layer && nfp_flow_is_tunnel(nfp_flow)) {
 		if (spec == NULL) {
@@ -1115,12 +1126,23 @@ nfp_flow_merge_ipv4(__rte_unused struct nfp_app_fw_flower *app_fw_flower,
 		}
 
 		hdr = is_mask ? &mask->hdr : &spec->hdr;
-		ipv4_udp_tun = (struct nfp_flower_ipv4_udp_tun *)*mbuf_off;
 
-		ipv4_udp_tun->ip_ext.tos = hdr->type_of_service;
-		ipv4_udp_tun->ip_ext.ttl = hdr->time_to_live;
-		ipv4_udp_tun->ipv4.src   = hdr->src_addr;
-		ipv4_udp_tun->ipv4.dst   = hdr->dst_addr;
+		if (ext_meta && (rte_be_to_cpu_32(ext_meta->nfp_flow_key_layer2) &
+				NFP_FLOWER_LAYER2_GRE)) {
+			ipv4_gre_tun = (struct nfp_flower_ipv4_gre_tun *)*mbuf_off;
+
+			ipv4_gre_tun->ip_ext.tos = hdr->type_of_service;
+			ipv4_gre_tun->ip_ext.ttl = hdr->time_to_live;
+			ipv4_gre_tun->ipv4.src   = hdr->src_addr;
+			ipv4_gre_tun->ipv4.dst   = hdr->dst_addr;
+		} else {
+			ipv4_udp_tun = (struct nfp_flower_ipv4_udp_tun *)*mbuf_off;
+
+			ipv4_udp_tun->ip_ext.tos = hdr->type_of_service;
+			ipv4_udp_tun->ip_ext.ttl = hdr->time_to_live;
+			ipv4_udp_tun->ipv4.src   = hdr->src_addr;
+			ipv4_udp_tun->ipv4.dst   = hdr->dst_addr;
+		}
 	} else {
 		if (spec == NULL) {
 			PMD_DRV_LOG(DEBUG, "nfp flow merge ipv4: no item->spec!");
diff --git a/drivers/net/nfp/nfp_flow.h b/drivers/net/nfp/nfp_flow.h
index a6994e08ee..b0c2aaf6d8 100644
--- a/drivers/net/nfp/nfp_flow.h
+++ b/drivers/net/nfp/nfp_flow.h
@@ -49,6 +49,9 @@
 #define NFP_FL_SC_ACT_POPV      0x6A000000
 #define NFP_FL_SC_ACT_NULL      0x00000000
 
+/* GRE Tunnel flags */
+#define NFP_FL_GRE_FLAG_KEY         (1 << 2)
+
 /* Action opcodes */
 #define NFP_FL_ACTION_OPCODE_OUTPUT             0
 #define NFP_FL_ACTION_OPCODE_PUSH_VLAN          1
-- 
2.29.3


  parent reply	other threads:[~2022-10-25  8:02 UTC|newest]

Thread overview: 88+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-18  3:22 [PATCH 00/25] add the extend rte_flow offload support of nfp PMD Chaoyong He
2022-10-18  3:22 ` [PATCH 01/25] net/nfp: add the offload support of IPv4 VXLAN item Chaoyong He
2022-10-18  3:22 ` [PATCH 02/25] net/nfp: add the offload support of IPv6 " Chaoyong He
2022-10-18  3:22 ` [PATCH 03/25] net/nfp: prepare for the encap action of IPv4 tunnel Chaoyong He
2022-10-18  3:22 ` [PATCH 04/25] net/nfp: prepare for the encap action of IPv6 tunnel Chaoyong He
2022-10-18  3:22 ` [PATCH 05/25] net/nfp: add the offload support of IPv4 VXLAN encap action Chaoyong He
2022-10-18  3:22 ` [PATCH 06/25] net/nfp: add the offload support of IPv6 " Chaoyong He
2022-10-18  3:22 ` [PATCH 07/25] net/nfp: prepare for the decap action of IPv4 UDP tunnel Chaoyong He
2022-10-18  3:22 ` [PATCH 08/25] net/nfp: prepare for the decap action of IPv6 " Chaoyong He
2022-10-18  3:22 ` [PATCH 09/25] net/nfp: add the offload support of IPv4 VXLAN decap action Chaoyong He
2022-10-18  3:22 ` [PATCH 10/25] net/nfp: add the offload support of IPv6 " Chaoyong He
2022-10-18  3:22 ` [PATCH 11/25] net/nfp: add the offload support of IPv4 GENEVE encap action Chaoyong He
2022-10-18  3:22 ` [PATCH 12/25] net/nfp: add the offload support of IPv6 " Chaoyong He
2022-10-18  3:22 ` [PATCH 13/25] net/nfp: add the offload support of IPv4 GENEVE item Chaoyong He
2022-10-18  3:22 ` [PATCH 14/25] net/nfp: add the offload support of IPv6 " Chaoyong He
2022-10-18  3:22 ` [PATCH 15/25] net/nfp: add the offload support of IPv4 GENEVE decap action Chaoyong He
2022-10-18  3:22 ` [PATCH 16/25] net/nfp: add the offload support of IPv6 " Chaoyong He
2022-10-18  3:22 ` [PATCH 17/25] net/nfp: add the offload support of IPv4 NVGRE encap action Chaoyong He
2022-10-18  3:22 ` [PATCH 18/25] net/nfp: add the offload support of IPv6 " Chaoyong He
2022-10-18  3:22 ` [PATCH 19/25] net/nfp: prepare for the decap action of IPv4 GRE tunnel Chaoyong He
2022-10-18  3:22 ` [PATCH 20/25] net/nfp: prepare for the decap action of IPv6 " Chaoyong He
2022-10-18  3:22 ` [PATCH 21/25] net/nfp: add the offload support of IPv4 NVGRE item Chaoyong He
2022-10-18  3:22 ` [PATCH 22/25] net/nfp: add the offload support of IPv6 " Chaoyong He
2022-10-18  3:22 ` [PATCH 23/25] net/nfp: add the offload support of IPv4 NVGRE decap action Chaoyong He
2022-10-18  3:22 ` [PATCH 24/25] net/nfp: add the offload support of IPv6 " Chaoyong He
2022-10-18  3:22 ` [PATCH 25/25] net/nfp: add the support of new tunnel solution Chaoyong He
2022-10-21 13:37 ` [PATCH 00/25] add the extend rte_flow offload support of nfp PMD Ferruh Yigit
2022-10-21 13:39   ` Ferruh Yigit
2022-10-22  8:24 ` [PATCH v2 " Chaoyong He
2022-10-22  8:24   ` [PATCH v2 01/25] net/nfp: support IPv4 VXLAN flow item Chaoyong He
2022-10-22  8:24   ` [PATCH v2 02/25] net/nfp: support IPv6 " Chaoyong He
2022-10-22  8:24   ` [PATCH v2 03/25] net/nfp: prepare for IPv4 tunnel encap flow action Chaoyong He
2022-10-22  8:24   ` [PATCH v2 04/25] net/nfp: prepare for IPv6 " Chaoyong He
2022-10-22  8:24   ` [PATCH v2 05/25] net/nfp: support IPv4 VXLAN " Chaoyong He
2022-10-22  8:24   ` [PATCH v2 06/25] net/nfp: support IPv6 " Chaoyong He
2022-10-22  8:24   ` [PATCH v2 07/25] net/nfp: prepare for IPv4 UDP tunnel decap " Chaoyong He
2022-10-22  8:24   ` [PATCH v2 08/25] net/nfp: prepare for IPv6 " Chaoyong He
2022-10-22  8:24   ` [PATCH v2 09/25] net/nfp: support IPv4 VXLAN " Chaoyong He
2022-10-22  8:24   ` [PATCH v2 10/25] net/nfp: support IPv6 " Chaoyong He
2022-10-22  8:24   ` [PATCH v2 11/25] net/nfp: support IPv4 GENEVE encap " Chaoyong He
2022-10-22  8:24   ` [PATCH v2 12/25] net/nfp: support IPv6 " Chaoyong He
2022-10-22  8:24   ` [PATCH v2 13/25] net/nfp: support IPv4 GENEVE flow item Chaoyong He
2022-10-22  8:24   ` [PATCH v2 14/25] net/nfp: support IPv6 " Chaoyong He
2022-10-22  8:24   ` [PATCH v2 15/25] net/nfp: support IPv4 GENEVE decap flow action Chaoyong He
2022-10-22  8:24   ` [PATCH v2 16/25] net/nfp: support IPv6 " Chaoyong He
2022-10-22  8:24   ` [PATCH v2 17/25] net/nfp: support IPv4 NVGRE encap " Chaoyong He
2022-10-22  8:24   ` [PATCH v2 18/25] net/nfp: support IPv6 " Chaoyong He
2022-10-22  8:24   ` [PATCH v2 19/25] net/nfp: prepare for IPv4 GRE tunnel decap " Chaoyong He
2022-10-22  8:24   ` [PATCH v2 20/25] net/nfp: prepare for IPv6 " Chaoyong He
2022-10-22  8:24   ` [PATCH v2 21/25] net/nfp: support IPv4 NVGRE flow item Chaoyong He
2022-10-22  8:24   ` [PATCH v2 22/25] net/nfp: support IPv6 " Chaoyong He
2022-10-22  8:24   ` [PATCH v2 23/25] net/nfp: support IPv4 NVGRE decap flow action Chaoyong He
2022-10-22  8:24   ` [PATCH v2 24/25] net/nfp: support IPv6 " Chaoyong He
2022-10-22  8:24   ` [PATCH v2 25/25] net/nfp: support new tunnel solution Chaoyong He
2022-10-24 15:09     ` Ferruh Yigit
2022-10-25  1:44       ` Chaoyong He
2022-10-25  8:18         ` Ferruh Yigit
2022-10-24 15:07   ` [PATCH v2 00/25] add the extend rte_flow offload support of nfp PMD Ferruh Yigit
2022-10-25  3:17     ` Chaoyong He
2022-10-25  3:29       ` Chaoyong He
2022-10-25  7:58   ` [PATCH v3 00/26] " Chaoyong He
2022-10-25  7:58     ` [PATCH v3 01/26] net/nfp: fix the app stuck by CPP bridge service Chaoyong He
2022-10-25  7:58     ` [PATCH v3 02/26] net/nfp: support IPv4 VXLAN flow item Chaoyong He
2022-10-25  7:58     ` [PATCH v3 03/26] net/nfp: support IPv6 " Chaoyong He
2022-10-25  7:58     ` [PATCH v3 04/26] net/nfp: prepare for IPv4 tunnel encap flow action Chaoyong He
2022-10-25  7:58     ` [PATCH v3 05/26] net/nfp: prepare for IPv6 " Chaoyong He
2022-10-25  7:58     ` [PATCH v3 06/26] net/nfp: support IPv4 VXLAN " Chaoyong He
2022-10-25  7:58     ` [PATCH v3 07/26] net/nfp: support IPv6 " Chaoyong He
2022-10-25  7:59     ` [PATCH v3 08/26] net/nfp: prepare for IPv4 UDP tunnel decap " Chaoyong He
2022-10-25  7:59     ` [PATCH v3 09/26] net/nfp: prepare for IPv6 " Chaoyong He
2022-10-25  7:59     ` [PATCH v3 10/26] net/nfp: support IPv4 VXLAN " Chaoyong He
2022-10-25  7:59     ` [PATCH v3 11/26] net/nfp: support IPv6 " Chaoyong He
2022-10-25  7:59     ` [PATCH v3 12/26] net/nfp: support IPv4 GENEVE encap " Chaoyong He
2022-10-25  7:59     ` [PATCH v3 13/26] net/nfp: support IPv6 " Chaoyong He
2022-10-25  7:59     ` [PATCH v3 14/26] net/nfp: support IPv4 GENEVE flow item Chaoyong He
2022-10-25  7:59     ` [PATCH v3 15/26] net/nfp: support IPv6 " Chaoyong He
2022-10-25  7:59     ` [PATCH v3 16/26] net/nfp: support IPv4 GENEVE decap flow action Chaoyong He
2022-10-25  7:59     ` [PATCH v3 17/26] net/nfp: support IPv6 " Chaoyong He
2022-10-25  7:59     ` [PATCH v3 18/26] net/nfp: support IPv4 NVGRE encap " Chaoyong He
2022-10-25  7:59     ` [PATCH v3 19/26] net/nfp: support IPv6 " Chaoyong He
2022-10-25  7:59     ` Chaoyong He [this message]
2022-10-25  7:59     ` [PATCH v3 21/26] net/nfp: prepare for IPv6 GRE tunnel decap " Chaoyong He
2022-10-25  7:59     ` [PATCH v3 22/26] net/nfp: support IPv4 NVGRE flow item Chaoyong He
2022-10-25  7:59     ` [PATCH v3 23/26] net/nfp: support IPv6 " Chaoyong He
2022-10-25  7:59     ` [PATCH v3 24/26] net/nfp: support IPv4 NVGRE decap flow action Chaoyong He
2022-10-25  7:59     ` [PATCH v3 25/26] net/nfp: support IPv6 " Chaoyong He
2022-10-25  7:59     ` [PATCH v3 26/26] net/nfp: support new solution for tunnel decap action Chaoyong He
2022-10-25 11:42     ` [PATCH v3 00/26] add the extend rte_flow offload support of nfp PMD Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221025075918.7778-21-chaoyong.he@corigine.com \
    --to=chaoyong.he@corigine.com \
    --cc=dev@dpdk.org \
    --cc=niklas.soderlund@corigine.com \
    --cc=oss-drivers@corigine.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).