DPDK patches and discussions
 help / color / mirror / Atom feed
From: Jijiang Liu <jijiang.liu@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH v2 4/4] app/testpmd:test NVGRE Tx checksum offload
Date: Thu, 12 Feb 2015 08:45:47 +0800	[thread overview]
Message-ID: <1423701947-17996-5-git-send-email-jijiang.liu@intel.com> (raw)
In-Reply-To: <1423701947-17996-1-git-send-email-jijiang.liu@intel.com>

Enhance csum fwd engine based on current TX checksum framework in order to test TX Checksum offload for NVGRE packet.

It includes:
 - IPv4 and IPv6 packet
 - outer L3, inner L3 and L4 checksum offload for Tx side.

Signed-off-by: Jijiang Liu <jijiang.liu@intel.com>
---
 app/test-pmd/csumonly.c |   32 +++++++++++++++++++-------------
 1 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index 5ddbaf5..58b82e7 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -79,6 +79,10 @@
 #define IP_HDRLEN  0x05 /* default IP header length == five 32-bits words. */
 #define IP_VHL_DEF (IP_VERSION | IP_HDRLEN)
 
+#define GRE_KEY_PRESENT 0x2000
+#define GRE_KEY_LEN     4
+#define GRE_SUPPORTED_FIELDS GRE_KEY_PRESENT
+
 /* We cannot use rte_cpu_to_be_16() on a constant in a switch/case */
 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
 #define _htons(x) ((uint16_t)((((x) & 0x00ffU) << 8) | (((x) & 0xff00U) >> 8)))
@@ -100,7 +104,7 @@ struct testpmd_offload_info {
 	uint16_t tso_segsz;
 };
 
-/* simplified GRE header (flags must be 0) */
+/* simplified GRE header */
 struct simple_gre_hdr {
 	uint16_t flags;
 	uint16_t proto;
@@ -231,20 +235,25 @@ parse_gre(struct simple_gre_hdr *gre_hdr, struct testpmd_offload_info *info)
 	struct ether_hdr *eth_hdr;
 	struct ipv4_hdr *ipv4_hdr;
 	struct ipv6_hdr *ipv6_hdr;
+	uint8_t gre_len = 0;
 
-	/* if flags != 0; it's not supported */
-	if (gre_hdr->flags != 0)
+	/* check which fields are supported */
+	if (gre_hdr->flags != 0 &&
+		(gre_hdr->flags & _htons(GRE_SUPPORTED_FIELDS)) == 0)
 		return;
 
+	gre_len += sizeof(struct simple_gre_hdr);
+
+	if (gre_hdr->flags & _htons(GRE_KEY_PRESENT))
+		gre_len += GRE_KEY_LEN;
+
 	if (gre_hdr->proto == _htons(ETHER_TYPE_IPv4)) {
 		info->is_tunnel = 1;
 		info->outer_ethertype = info->ethertype;
 		info->outer_l2_len = info->l2_len;
 		info->outer_l3_len = info->l3_len;
 
-		ipv4_hdr = (struct ipv4_hdr *)((char *)gre_hdr +
-			sizeof(struct simple_gre_hdr));
-
+		ipv4_hdr = (struct ipv4_hdr *)((char *)gre_hdr + gre_len);
 		parse_ipv4(ipv4_hdr, info);
 		info->ethertype = _htons(ETHER_TYPE_IPv4);
 		info->l2_len = 0;
@@ -255,30 +264,27 @@ parse_gre(struct simple_gre_hdr *gre_hdr, struct testpmd_offload_info *info)
 		info->outer_l2_len = info->l2_len;
 		info->outer_l3_len = info->l3_len;
 
-		ipv6_hdr = (struct ipv6_hdr *)((char *)gre_hdr +
-			sizeof(struct simple_gre_hdr));
+		ipv6_hdr = (struct ipv6_hdr *)((char *)gre_hdr + gre_len);
 
 		info->ethertype = _htons(ETHER_TYPE_IPv6);
 		parse_ipv6(ipv6_hdr, info);
 		info->l2_len = 0;
 
-	} else if (gre_hdr->proto == _htons(0x6558)) { /* ETH_P_TEB in linux */
+	} else if (gre_hdr->proto == _htons(ETHER_TYPE_TEB)) {
 		info->is_tunnel = 1;
 		info->outer_ethertype = info->ethertype;
 		info->outer_l2_len = info->l2_len;
 		info->outer_l3_len = info->l3_len;
 
-		eth_hdr = (struct ether_hdr *)((char *)gre_hdr +
-			sizeof(struct simple_gre_hdr));
+		eth_hdr = (struct ether_hdr *)((char *)gre_hdr + gre_len);
 
 		parse_ethernet(eth_hdr, info);
 	} else
 		return;
 
-	info->l2_len += sizeof(struct simple_gre_hdr);
+	info->l2_len += gre_len;
 }
 
-
 /* Parse an encapsulated ip or ipv6 header */
 static void
 parse_encap_ip(void *encap_ip, struct testpmd_offload_info *info)
-- 
1.7.7.6

  parent reply	other threads:[~2015-02-12  0:46 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-12  0:45 [dpdk-dev] [PATCH v2 0/4] Support NVGRE on i40e Jijiang Liu
2015-02-12  0:45 ` [dpdk-dev] [PATCH v2 1/4] librte_ether:add an ETHER_TYPE_TEB macro Jijiang Liu
2015-02-12  0:45 ` [dpdk-dev] [PATCH v2 2/4] i40e:support RX tunnel filter for NVGRE packet Jijiang Liu
2015-02-12  0:45 ` [dpdk-dev] [PATCH v2 3/4] app/testpmd:test " Jijiang Liu
2015-02-13  1:23   ` Wu, Jingjing
2015-02-13  1:27     ` Liu, Jijiang
2015-02-12  0:45 ` Jijiang Liu [this message]
2015-02-13  9:52   ` [dpdk-dev] [PATCH v2 4/4] app/testpmd:test NVGRE Tx checksum offload Olivier MATZ
2015-02-15  1:13     ` Liu, Jijiang
2015-02-20 17:01 ` [dpdk-dev] [PATCH v3 0/4] Support NVGRE on i40e Declan Doherty
2015-02-20 17:01   ` [dpdk-dev] [PATCH v3 1/4] librte_ether:add an ETHER_TYPE_TEB macro Declan Doherty
2015-02-20 17:01     ` [dpdk-dev] [PATCH v3 2/4] i40e:support RX tunnel filter for NVGRE packet Declan Doherty
2015-02-20 17:01       ` [dpdk-dev] [PATCH v3 3/4] app/testpmd:test " Declan Doherty
2015-02-20 17:01         ` [dpdk-dev] [PATCH v3 4/4] app/testpmd:test NVGRE Tx checksum offload Declan Doherty
2015-02-23 15:42   ` [dpdk-dev] [PATCH v3 0/4] Support NVGRE on i40e Thomas Monjalon

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=1423701947-17996-5-git-send-email-jijiang.liu@intel.com \
    --to=jijiang.liu@intel.com \
    --cc=dev@dpdk.org \
    /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).