diff mbox series

[2/2] app/testpmd: support GTP-U extension packet checksum offload

Message ID 20201125093214.14504-3-murphyx.yang@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers show
Series support GTP-U Tx offload on FVL and CVL | expand

Checks

Context Check Description
ci/travis-robot success Travis build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/checkpatch success coding style OK

Commit Message

Murphy Yang Nov. 25, 2020, 9:32 a.m. UTC
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 mbox series

Patch

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 */