From patchwork Fri Feb 13 09:22:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olivier Matz X-Patchwork-Id: 3289 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 47FC9B438; Fri, 13 Feb 2015 10:23:29 +0100 (CET) Received: from mail-we0-f179.google.com (mail-we0-f179.google.com [74.125.82.179]) by dpdk.org (Postfix) with ESMTP id 00EB9B3DC for ; Fri, 13 Feb 2015 10:23:11 +0100 (CET) Received: by mail-we0-f179.google.com with SMTP id u56so15306497wes.10 for ; Fri, 13 Feb 2015 01:23:10 -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=HtJiiC/BWyvgu1skTtCwMjCuScAVNyAws26KqzYLMSE=; b=HT79bC1bq5wTmvqaE4XIJ9msdPXA7oqVzYgtnIKlJCmI49rZdbw9p7ZddrLfmRRCKd pXXqCmauR8iIiuDx4nsGbMEXYEx30R8jPb4YnLnY3cRTuPd5fH/98CSpugqrUqwNUeaN QtMbe4kN4PfNbOMwo5gBFYd2WRm8OiEqOJT31kHz2PcG6w4kGYxhDgixKO2uNsviJVJ9 IEpspHKN3SsRDqpPDs4Q4C2ANkzHcgnlGMfIxUxscIrgANIivnJZI93BPaPfiBjhYV6x CtzihZKnsjxn07e4IwQ1tusRrPjMjbCcmlldVf6slEohNYCyt5i4JzRjy/xMDCoXKVhz /UaQ== X-Gm-Message-State: ALoCoQk5lmIRgNRZR1/zZDN2NAfhVAeAiUEozzDls+JoRYM0oYfThOFtfckBaxmGNu80v3FnocKI X-Received: by 10.194.63.206 with SMTP id i14mr16288214wjs.107.1423819390873; Fri, 13 Feb 2015 01:23:10 -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:10 -0800 (PST) From: Olivier Matz To: dev@dpdk.org Date: Fri, 13 Feb 2015 10:22:43 +0100 Message-Id: <1423819371-24222-13-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 12/20] testpmd: introduce parse_vxlan 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" Move code parsing vxlan into a function. It will ease the support of GRE tunnels and IPIP tunnels in next commits. Signed-off-by: Olivier Matz --- app/test-pmd/csumonly.c | 68 +++++++++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 31 deletions(-) diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index 0b89d89..ba9049f 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -93,7 +93,6 @@ struct testpmd_offload_info { uint16_t l3_len; uint16_t l4_len; uint8_t l4_proto; - uint8_t l4_tun_len; uint8_t is_tunnel; uint16_t outer_ethertype; uint16_t outer_l2_len; @@ -191,6 +190,34 @@ parse_ethernet(struct ether_hdr *eth_hdr, struct testpmd_offload_info *info) } } +/* Parse a vxlan header */ +static void +parse_vxlan(struct udp_hdr *udp_hdr, struct testpmd_offload_info *info, + uint64_t mbuf_olflags) +{ + struct ether_hdr *eth_hdr; + + /* check udp destination port, 4789 is the default vxlan port + * (rfc7348) or that the rx offload flag is set (i40e only + * currently) */ + if (udp_hdr->dst_port != _htons(4789) && + (mbuf_olflags & (PKT_RX_TUNNEL_IPV4_HDR | + PKT_RX_TUNNEL_IPV6_HDR)) == 0) + return; + + 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 *)udp_hdr + + sizeof(struct udp_hdr) + + sizeof(struct vxlan_hdr)); + + parse_ethernet(eth_hdr, info); + info->l2_len += ETHER_VXLAN_HLEN; /* add udp + vxlan */ +} + /* modify the IPv4 or IPv4 source address of a packet */ static void change_ip_addresses(void *l3_hdr, uint16_t ethertype) @@ -356,7 +383,6 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) struct rte_mbuf *m; struct ether_hdr *eth_hdr; void *l3_hdr = NULL, *outer_l3_hdr = NULL; /* can be IPv4 or IPv6 */ - struct udp_hdr *udp_hdr; uint16_t nb_rx; uint16_t nb_tx; uint16_t i; @@ -414,33 +440,15 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) /* 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 udp destination port, 4789 is the default - * vxlan port (rfc7348) */ - if (udp_hdr->dst_port == _htons(4789)) { - info.l4_tun_len = ETHER_VXLAN_HLEN; - info.is_tunnel = 1; - - /* currently, this flag is set by i40e only if the - * packet is vxlan */ - } else if (m->ol_flags & (PKT_RX_TUNNEL_IPV4_HDR | - PKT_RX_TUNNEL_IPV6_HDR)) - info.is_tunnel = 1; - - if (info.is_tunnel == 1) { - info.outer_ethertype = info.ethertype; - info.outer_l2_len = info.l2_len; - info.outer_l3_len = info.l3_len; - outer_l3_hdr = l3_hdr; - - eth_hdr = (struct ether_hdr *)((char *)udp_hdr + - sizeof(struct udp_hdr) + - sizeof(struct vxlan_hdr)); - - parse_ethernet(eth_hdr, &info); - l3_hdr = (char *)eth_hdr + info.l2_len; - } + /* update l3_hdr and outer_l3_hdr if a tunnel was parsed */ + if (info.is_tunnel) { + outer_l3_hdr = l3_hdr; + l3_hdr = (char *)l3_hdr + info.outer_l3_len + info.l2_len; } /* step 2: change all source IPs (v4 or v6) so we need @@ -472,7 +480,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) { m->outer_l2_len = info.outer_l2_len; m->outer_l3_len = info.outer_l3_len; - m->l2_len = info.l4_tun_len + info.l2_len; + m->l2_len = info.l2_len; m->l3_len = info.l3_len; } else { @@ -482,9 +490,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) the payload will be modified by the hardware */ m->l2_len = info.outer_l2_len + - info.outer_l3_len + - sizeof(struct udp_hdr) + - sizeof(struct vxlan_hdr) + info.l2_len; + info.outer_l3_len + info.l2_len; m->l3_len = info.l3_len; m->l4_len = info.l4_len; }