From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id DA7AC376C for ; Mon, 2 Feb 2015 02:49:12 +0100 (CET) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP; 01 Feb 2015 17:49:11 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,503,1418112000"; d="scan'208";a="671238294" Received: from pgsmsx105.gar.corp.intel.com ([10.221.44.96]) by fmsmga002.fm.intel.com with ESMTP; 01 Feb 2015 17:49:09 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by PGSMSX105.gar.corp.intel.com (10.221.44.96) with Microsoft SMTP Server (TLS) id 14.3.195.1; Mon, 2 Feb 2015 09:49:05 +0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.253]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.129]) with mapi id 14.03.0195.001; Mon, 2 Feb 2015 09:49:05 +0800 From: "Liu, Jijiang" To: Olivier Matz Thread-Topic: [PATCH 12/20] testpmd: introduce parse_vxlan in csum fwd engine Thread-Index: AQHQPI7+/I4L/TdvO0ieGk27wwG6eJzcmn7g Date: Mon, 2 Feb 2015 01:49:03 +0000 Message-ID: <1ED644BD7E0A5F4091CF203DAFB8E4CC01DC963B@SHSMSX101.ccr.corp.intel.com> References: <1421883395-27235-1-git-send-email-olivier.matz@6wind.com> <1422623775-8050-1-git-send-email-olivier.matz@6wind.com> <1422623775-8050-13-git-send-email-olivier.matz@6wind.com> In-Reply-To: <1422623775-8050-13-git-send-email-olivier.matz@6wind.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Cc: "dev@dpdk.org" Subject: Re: [dpdk-dev] [PATCH 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: , X-List-Received-Date: Mon, 02 Feb 2015 01:49:13 -0000 Hi, > -----Original Message----- > From: Olivier Matz [mailto:olivier.matz@6wind.com] > Sent: Friday, January 30, 2015 9:16 PM > To: dev@dpdk.org > Cc: Ananyev, Konstantin; Liu, Jijiang; Zhang, Helin; olivier.matz@6wind.c= om > Subject: [PATCH 12/20] testpmd: introduce parse_vxlan in csum fwd engine >=20 > Move code parsing vxlan into a function. It will ease the support of GRE > tunnels and IPIP tunnels in next commits. >=20 > Signed-off-by: Olivier Matz > --- > app/test-pmd/csumonly.c | 68 +++++++++++++++++++++++++++------------ > ---------- > 1 file changed, 37 insertions(+), 31 deletions(-) >=20 > diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index > 0b89d89..52af0e7 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) > } > } >=20 > +/* 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 !=3D _htons(4789) && > + (mbuf_olflags & (PKT_RX_TUNNEL_IPV4_HDR | > + PKT_RX_TUNNEL_IPV6_HDR)) !=3D 0) It seems that there is a bug, which is mbuf_olflags check. It should be=20 (mbuf_olflags & (PKT_RX_TUNNEL_IPV4_HDR | PKT_RX_TUNNEL_IPV6_HDR)) =3D=3D 0). > + return; > + > + info->is_tunnel =3D 1; > + info->outer_ethertype =3D info->ethertype; > + info->outer_l2_len =3D info->l2_len; > + info->outer_l3_len =3D info->l3_len; > + > + eth_hdr =3D (struct ether_hdr *)((char *)udp_hdr + > + sizeof(struct udp_hdr) + > + sizeof(struct vxlan_hdr)); > + > + parse_ethernet(eth_hdr, info); > + info->l2_len +=3D 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 =3D NULL, *outer_l3_hdr =3D 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 =3D=3D IPPROTO_UDP) { > + struct udp_hdr *udp_hdr; > udp_hdr =3D (struct udp_hdr *)((char *)l3_hdr + > info.l3_len); > + parse_vxlan(udp_hdr, &info, m->ol_flags); > + } >=20 > - /* check udp destination port, 4789 is the default > - * vxlan port (rfc7348) */ > - if (udp_hdr->dst_port =3D=3D _htons(4789)) { > - info.l4_tun_len =3D ETHER_VXLAN_HLEN; > - info.is_tunnel =3D 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 =3D 1; > - > - if (info.is_tunnel =3D=3D 1) { > - info.outer_ethertype =3D info.ethertype; > - info.outer_l2_len =3D info.l2_len; > - info.outer_l3_len =3D info.l3_len; > - outer_l3_hdr =3D l3_hdr; > - > - eth_hdr =3D (struct ether_hdr *)((char > *)udp_hdr + > - sizeof(struct udp_hdr) + > - sizeof(struct vxlan_hdr)); > - > - parse_ethernet(eth_hdr, &info); > - l3_hdr =3D (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 =3D l3_hdr; > + l3_hdr =3D (char *)l3_hdr + info.outer_l3_len + > info.l2_len; > } >=20 > /* 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 =3D info.outer_l2_len; > m->outer_l3_len =3D info.outer_l3_len; > - m->l2_len =3D info.l4_tun_len + info.l2_len; > + m->l2_len =3D info.l2_len; > m->l3_len =3D 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 =3D 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 =3D info.l3_len; > m->l4_len =3D info.l4_len; > } > -- > 2.1.4