From patchwork Fri Feb 13 09:22:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olivier Matz X-Patchwork-Id: 3290 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 49190B43E; Fri, 13 Feb 2015 10:23:30 +0100 (CET) Received: from mail-wi0-f170.google.com (mail-wi0-f170.google.com [209.85.212.170]) by dpdk.org (Postfix) with ESMTP id AB77BB3E2 for ; Fri, 13 Feb 2015 10:23:11 +0100 (CET) Received: by mail-wi0-f170.google.com with SMTP id hi2so10656296wib.1 for ; Fri, 13 Feb 2015 01:23:11 -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=COSR5YlFv3v3twjXDCKWLIPvsgr52Qg33F93mQ1INc4=; b=ky8xYUf7AAZRzRPYLXSgjJbaKlHgEQH9sndxCBFljDE69J930pvbJldTQW8g9/bPz+ UDY2K0p/gXgdfEFYyWiZfWU14eM9TE5gnGwAvFJua3hvrpM3YpCIy/N6KqvUXo+YLs0O w5yCpxfl9eOPS3PxwJhf8IOAQ1RvAIMpq8haC1+gotsMMJZsQbknFLHDq5/LWH2E0yqS DP1wosgIS7OnkUhoszGNqgA/gmzegP4W/fC4mDtBcrm2SV7K8grSBXF2/4GYlg8ZzBT1 YNBozDwsNQyCA8Akd4iGxw89YRozuVJIc3dMveoF2UBg73awZLeLW2vew3dwxS5zGSlM Ah+A== X-Gm-Message-State: ALoCoQme3HrMScLKbmD6v+gS2hZCEVRRx15fmuI9wNGEUaI7ktPpag8uIBIS204k4BflPQzN55Dd X-Received: by 10.180.100.202 with SMTP id fa10mr4895565wib.10.1423819391578; Fri, 13 Feb 2015 01:23:11 -0800 (PST) Received: from glumotte.dev.6wind.com (6wind.net2.nerim.net. [213.41.180.237]) by mx.google.com with ESMTPSA id a5sm2100153wib.20.2015.02.13.01.23.10 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 13 Feb 2015 01:23:11 -0800 (PST) From: Olivier Matz To: dev@dpdk.org Date: Fri, 13 Feb 2015 10:22:44 +0100 Message-Id: <1423819371-24222-14-git-send-email-olivier.matz@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1423819371-24222-1-git-send-email-olivier.matz@6wind.com> References: <1423041925-26956-1-git-send-email-olivier.matz@6wind.com> <1423819371-24222-1-git-send-email-olivier.matz@6wind.com> Subject: [dpdk-dev] [PATCH v3 13/20] testpmd: support gre tunnels in csum fwd 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Add support for Ethernet over GRE and IP over GRE tunnels. Signed-off-by: Olivier Matz --- app/test-pmd/cmdline.c | 6 ++-- app/test-pmd/csumonly.c | 91 +++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 87 insertions(+), 10 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 363da9a..b19869c 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -322,9 +322,9 @@ static void cmd_help_long_parsed(void *parsed_result, " checksum with when transmitting a packet using the" " csum forward engine.\n" " 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 vxlan packet by" - " the forward engine)\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" " Please check the NIC datasheet for HW limits.\n\n" "csum parse-tunnel (on|off) (tx_port_id)\n" diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index ba9049f..2582bf1 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -97,9 +97,16 @@ struct testpmd_offload_info { uint16_t outer_ethertype; uint16_t outer_l2_len; uint16_t outer_l3_len; + uint8_t outer_l4_proto; uint16_t tso_segsz; }; +/* simplified GRE header (flags must be 0) */ +struct simple_gre_hdr { + uint16_t flags; + uint16_t proto; +}; + static uint16_t get_psd_sum(void *l3_hdr, uint16_t ethertype, uint64_t ol_flags) { @@ -209,6 +216,7 @@ parse_vxlan(struct udp_hdr *udp_hdr, struct testpmd_offload_info *info, info->outer_ethertype = info->ethertype; info->outer_l2_len = info->l2_len; info->outer_l3_len = info->l3_len; + info->outer_l4_proto = info->l4_proto; eth_hdr = (struct ether_hdr *)((char *)udp_hdr + sizeof(struct udp_hdr) + @@ -218,6 +226,63 @@ parse_vxlan(struct udp_hdr *udp_hdr, struct testpmd_offload_info *info, info->l2_len += ETHER_VXLAN_HLEN; /* add udp + vxlan */ } +/* Parse a gre header */ +static void +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; + + /* if flags != 0; it's not supported */ + if (gre_hdr->flags != 0) + return; + + 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; + info->outer_l4_proto = info->l4_proto; + + ipv4_hdr = (struct ipv4_hdr *)((char *)gre_hdr + + sizeof(struct simple_gre_hdr)); + + parse_ipv4(ipv4_hdr, info); + info->ethertype = _htons(ETHER_TYPE_IPv4); + info->l2_len = 0; + + } else if (gre_hdr->proto == _htons(ETHER_TYPE_IPv6)) { + info->is_tunnel = 1; + info->outer_ethertype = info->ethertype; + info->outer_l2_len = info->l2_len; + info->outer_l3_len = info->l3_len; + info->outer_l4_proto = info->l4_proto; + + ipv6_hdr = (struct ipv6_hdr *)((char *)gre_hdr + + sizeof(struct simple_gre_hdr)); + + 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 */ + info->is_tunnel = 1; + info->outer_ethertype = info->ethertype; + info->outer_l2_len = info->l2_len; + info->outer_l3_len = info->l3_len; + info->outer_l4_proto = info->l4_proto; + + eth_hdr = (struct ether_hdr *)((char *)gre_hdr + + sizeof(struct simple_gre_hdr)); + + parse_ethernet(eth_hdr, info); + } else + return; + + info->l2_len += sizeof(struct simple_gre_hdr); +} + /* modify the IPv4 or IPv4 source address of a packet */ static void change_ip_addresses(void *l3_hdr, uint16_t ethertype) @@ -317,7 +382,7 @@ process_inner_cksums(void *l3_hdr, const struct testpmd_offload_info *info, * packet */ static uint64_t process_outer_cksums(void *outer_l3_hdr, struct testpmd_offload_info *info, -uint16_t testpmd_ol_flags) + uint16_t testpmd_ol_flags) { struct ipv4_hdr *ipv4_hdr = outer_l3_hdr; struct ipv6_hdr *ipv6_hdr = outer_l3_hdr; @@ -335,6 +400,9 @@ uint16_t testpmd_ol_flags) } else if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ol_flags |= PKT_TX_OUTER_IPV6; + if (info->outer_l4_proto != IPPROTO_UDP) + return ol_flags; + /* outer UDP checksum is always done in software as we have no * hardware supporting it today, and no API for it. */ @@ -368,6 +436,8 @@ uint16_t testpmd_ol_flags) * Ether / (vlan) / IP|IP6 / UDP|TCP|SCTP . * Ether / (vlan) / outer IP|IP6 / outer UDP / VxLAN / Ether / IP|IP6 / * 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 * * The testpmd command line for this forward engine sets the flags * TESTPMD_TX_OFFLOAD_* in ports[tx_port].tx_ol_flags. They control @@ -437,12 +507,19 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) parse_ethernet(eth_hdr, &info); l3_hdr = (char *)eth_hdr + info.l2_len; - /* check if it's a supported tunnel (only vxlan for now) */ - if ((testpmd_ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) && - info.l4_proto == IPPROTO_UDP) { - struct udp_hdr *udp_hdr; - udp_hdr = (struct udp_hdr *)((char *)l3_hdr + info.l3_len); - parse_vxlan(udp_hdr, &info, m->ol_flags); + /* check if it's a supported tunnel */ + if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) { + if (info.l4_proto == IPPROTO_UDP) { + struct udp_hdr *udp_hdr; + udp_hdr = (struct udp_hdr *)((char *)l3_hdr + + info.l3_len); + parse_vxlan(udp_hdr, &info, m->ol_flags); + } else if (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 */