From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wi0-f178.google.com (mail-wi0-f178.google.com [209.85.212.178]) by dpdk.org (Postfix) with ESMTP id DE2F75AD1 for ; Thu, 22 Jan 2015 00:37:06 +0100 (CET) Received: by mail-wi0-f178.google.com with SMTP id em10so26336977wid.5 for ; Wed, 21 Jan 2015 15:37:06 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=bgaTq1gCAfnD26WXXDiXgCEz3hIZGmOZYt/zHQQ5TtQ=; b=AyuIaKakbXtD0JIIoFQsE7/eh9qnan+MgFpL1U9/2ugaaactLo/Gf3NIrdxpnAkP3H si1BDaZmrIBZQSnn5KYh5IXY/7SK4DLLgtUEYpZfV0ywE6mxHnnovfq8MQIXeGknWR8D gdiWqpi9RoqisZXZr3B1nvcED2r95dEdVgMdoqIEku2ZkU4d4yxuPyEw2y53iJmJW1Ig Q+HUft+FEz3DMjT+7Kgd12sUmAsRKnzcZkF3DdeiYbnrUxeNfoHFpTno3bkc5Fr6KyxG 3YbdJJEYjRAtyhPcMLz0GufA6XNzBXEIcpv+qKlQ8WZW3S5dBdJpYmhJ+NWFovLiBnSr 909Q== X-Gm-Message-State: ALoCoQk1mAp19AcbGDDsrUCiA4i2OSzLFX+sxb2exqh1xtyQIfN9wgs1A0WK9fAN6LDcKOT+IxPx X-Received: by 10.180.210.195 with SMTP id mw3mr62720970wic.79.1421883426787; Wed, 21 Jan 2015 15:37:06 -0800 (PST) Received: from glumotte.dev.6wind.com (guy78-3-82-239-227-177.fbx.proxad.net. [82.239.227.177]) by mx.google.com with ESMTPSA id wa5sm1710761wjc.8.2015.01.21.15.37.05 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 21 Jan 2015 15:37:05 -0800 (PST) From: Olivier Matz To: dev@dpdk.org Date: Thu, 22 Jan 2015 00:36:35 +0100 Message-Id: <1421883395-27235-17-git-send-email-olivier.matz@6wind.com> X-Mailer: git-send-email 2.1.3 In-Reply-To: <1421883395-27235-1-git-send-email-olivier.matz@6wind.com> References: <1421883395-27235-1-git-send-email-olivier.matz@6wind.com> Subject: [dpdk-dev] [RFC 16/16] testpmd: support ipip tunnel in csum forward engine 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: , X-List-Received-Date: Wed, 21 Jan 2015 23:37:08 -0000 Add support for IP over IP tunnels. Signed-off-by: Olivier Matz --- app/test-pmd/cmdline.c | 2 +- app/test-pmd/csumonly.c | 40 ++++++++++++++++++++++++++++++++++------ 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 9304207..b1832e3 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -323,7 +323,7 @@ static void cmd_help_long_parsed(void *parsed_result, " ip|udp|tcp|sctp always concern the inner layer.\n" " outer-ip concerns the outer IP layer in" " case the packet is recognized as a tunnel packet by" - " the forward engine (vxlan and gre are supported)\n" + " the forward engine (vxlan, gre and ipip are supported)\n" " Please check the NIC datasheet for HW limits.\n\n" "csum parse-tunnel (on|off) (port_id)\n" diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index 02c01f6..407e3b3 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -278,6 +278,35 @@ parse_gre(struct simple_gre_hdr *gre_hdr, struct testpmd_offload_info *info) info->l2_len += sizeof(struct simple_gre_hdr); } + +/* Parse an encapsulated ip or ipv6 header */ +static void +parse_encap_ip(void *encap_ip, struct testpmd_offload_info *info) +{ + struct ipv4_hdr *ipv4_hdr = encap_ip; + struct ipv6_hdr *ipv6_hdr = encap_ip; + uint8_t ip_version; + + ip_version = (ipv4_hdr->version_ihl & 0xf0) >> 4; + + if (ip_version != 4 && ip_version != 6) + return; + + info->is_tunnel = 1; + info->outer_ethertype = info->ethertype; + info->outer_l2_len = info->l2_len; + info->outer_l3_len = info->l3_len; + + if (ip_version == 4) { + parse_ipv4(ipv4_hdr, info); + info->ethertype = _htons(ETHER_TYPE_IPv4); + } else { + parse_ipv6(ipv6_hdr, info); + info->ethertype = _htons(ETHER_TYPE_IPv6); + } + info->l2_len = 0; +} + /* modify the IPv4 or IPv4 source address of a packet */ static void change_ip_addresses(void *l3_hdr, uint16_t ethertype) @@ -430,6 +459,7 @@ uint16_t testpmd_ol_flags) * UDP|TCP|SCTP * Ether / (vlan) / outer IP|IP6 / GRE / Ether / IP|IP6 / UDP|TCP|SCTP * Ether / (vlan) / outer IP|IP6 / GRE / IP|IP6 / UDP|TCP|SCTP + * Ether / (vlan) / outer IP|IP6 / IP|IP6 / UDP|TCP|SCTP * * The testpmd command line for this forward engine sets the flags * TESTPMD_TX_OFFLOAD_* in ports[tx_port].tx_ol_flags. They control @@ -511,14 +541,12 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) gre_hdr = (struct simple_gre_hdr *) ((char *)l3_hdr + info.l3_len); parse_gre(gre_hdr, &info); + } else if (info.l4_proto == IPPROTO_IPIP) { + void *encap_ip_hdr; + encap_ip_hdr = (char *)l3_hdr + info.l3_len; + parse_encap_ip(encap_ip_hdr, &info); } } - info.l4_proto == IPPROTO_GRE) { - struct simple_gre_hdr *gre_hdr; - gre_hdr = (struct simple_gre_hdr *)((char *)l3_hdr + - info.l3_len); - parse_gre(gre_hdr, &info); - } /* update l3_hdr and outer_l3_hdr if a tunnel was parsed */ if (info.is_tunnel) { -- 2.1.3