From patchwork Thu Feb 12 00:45:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jijiang Liu X-Patchwork-Id: 3154 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id B9D285A97; Thu, 12 Feb 2015 01:46:09 +0100 (CET) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 5608A5A55 for ; Thu, 12 Feb 2015 01:46:07 +0100 (CET) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP; 11 Feb 2015 16:41:03 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,562,1418112000"; d="scan'208";a="676659163" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by fmsmga002.fm.intel.com with ESMTP; 11 Feb 2015 16:46:04 -0800 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id t1C0k17l003514; Thu, 12 Feb 2015 08:46:01 +0800 Received: from shecgisg004.sh.intel.com (localhost [127.0.0.1]) by shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id t1C0jvIu018059; Thu, 12 Feb 2015 08:45:59 +0800 Received: (from jijiangl@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id t1C0jvHG018055; Thu, 12 Feb 2015 08:45:57 +0800 From: Jijiang Liu To: dev@dpdk.org Date: Thu, 12 Feb 2015 08:45:47 +0800 Message-Id: <1423701947-17996-5-git-send-email-jijiang.liu@intel.com> X-Mailer: git-send-email 1.7.12.2 In-Reply-To: <1423701947-17996-1-git-send-email-jijiang.liu@intel.com> References: <1423701947-17996-1-git-send-email-jijiang.liu@intel.com> Subject: [dpdk-dev] [PATCH v2 4/4] app/testpmd:test NVGRE Tx checksum offload X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 --- 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)