DPDK patches and discussions
 help / color / mirror / Atom feed
From: Murphy Yang <murphyx.yang@intel.com>
To: dev@dpdk.org
Cc: qiming.yang@intel.com, stevex.yang@intel.com,
	beilei.xing@intel.com, jia.guo@intel.com, wenzhuo.lu@intel.com,
	Murphy Yang <murphyx.yang@intel.com>
Subject: [dpdk-dev] [PATCH 2/2] app/testpmd: support GTP-U extension packet checksum offload
Date: Wed, 25 Nov 2020 09:32:14 +0000	[thread overview]
Message-ID: <20201125093214.14504-3-murphyx.yang@intel.com> (raw)
In-Reply-To: <20201125093214.14504-1-murphyx.yang@intel.com>

To enable Tx side offload on GTP-U packets that contain extension header,
testpmd should set 'info->l2_len' correctly, this value should contain UDP
header length, GTP-U header length and GTP-U extension header length.

Signed-off-by: Murphy Yang <murphyx.yang@intel.com>
---
 app/test-pmd/csumonly.c | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index d813d4fae0..1faeacd809 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -218,14 +218,32 @@ parse_gtp(struct rte_udp_hdr *udp_hdr,
 	gtp_hdr = (struct rte_gtp_hdr *)((char *)udp_hdr +
 		  sizeof(struct rte_udp_hdr));
 
+	/* Calculate the gtp_len*/
+	if (gtp_hdr->gtp_hdr_info & 0x7)
+		gtp_len = gtp_len + 4;
+
+	if (gtp_hdr->gtp_hdr_info & 0x4) {
+		/*Assuming one extension gtp header*/
+		uint16_t gtp_extension_len = 0;
+		uint8_t *gtp_extension_hdr = NULL;
+		uint8_t gtp_NEHT = 0;
+		do {
+			gtp_extension_hdr = (uint8_t *)((uint8_t *)gtp_hdr +
+					     gtp_len);
+			gtp_extension_len = *gtp_extension_hdr * 4;
+			gtp_len = gtp_len + gtp_extension_len;
+			gtp_NEHT = *(gtp_extension_hdr +
+				      gtp_extension_len - 1);
+		} while (gtp_NEHT);
+	}
+
 	/*
 	 * Check message type. If message type is 0xff, it is
 	 * a GTP data packet. If not, it is a GTP control packet
 	 */
 	if (gtp_hdr->msg_type == 0xff) {
 		ip_ver = *(uint8_t *)((char *)udp_hdr +
-			 sizeof(struct rte_udp_hdr) +
-			 sizeof(struct rte_gtp_hdr));
+			 sizeof(struct rte_udp_hdr) +  gtp_len);
 		ip_ver = (ip_ver) & 0xf0;
 
 		if (ip_ver == RTE_GTP_TYPE_IPV4) {
@@ -233,20 +251,22 @@ parse_gtp(struct rte_udp_hdr *udp_hdr,
 				   gtp_len);
 			info->ethertype = _htons(RTE_ETHER_TYPE_IPV4);
 			parse_ipv4(ipv4_hdr, info);
+			info->l2_len = (uint8_t *)ipv4_hdr - (uint8_t *)udp_hdr;
 		} else if (ip_ver == RTE_GTP_TYPE_IPV6) {
 			ipv6_hdr = (struct rte_ipv6_hdr *)((char *)gtp_hdr +
 				   gtp_len);
 			info->ethertype = _htons(RTE_ETHER_TYPE_IPV6);
 			parse_ipv6(ipv6_hdr, info);
+			info->l2_len = (uint8_t *)ipv6_hdr - (uint8_t *)udp_hdr;
 		}
 	} else {
 		info->ethertype = 0;
 		info->l4_len = 0;
 		info->l3_len = 0;
 		info->l4_proto = 0;
+		info->l2_len += RTE_ETHER_GTP_HLEN;
 	}
 
-	info->l2_len += RTE_ETHER_GTP_HLEN;
 }
 
 /* Parse a vxlan header */
-- 
2.17.1


  parent reply	other threads:[~2020-11-25  9:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-25  9:32 [dpdk-dev] [PATCH 0/2] support GTP-U Tx offload on FVL and CVL Murphy Yang
2020-11-25  9:32 ` [dpdk-dev] [PATCH 1/2] net/i40e: support GTP checksum offload Murphy Yang
2020-12-02  8:06   ` Guo, Jia
2020-11-25  9:32 ` Murphy Yang [this message]
2020-12-02  7:58 ` [dpdk-dev] [PATCH 0/2] support GTP-U Tx offload on FVL and CVL Guo, Jia

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=20201125093214.14504-3-murphyx.yang@intel.com \
    --to=murphyx.yang@intel.com \
    --cc=beilei.xing@intel.com \
    --cc=dev@dpdk.org \
    --cc=jia.guo@intel.com \
    --cc=qiming.yang@intel.com \
    --cc=stevex.yang@intel.com \
    --cc=wenzhuo.lu@intel.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).