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 9B1F216E for ; Wed, 20 Sep 2017 05:17:31 +0200 (CEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Sep 2017 20:17:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,420,1500966000"; d="scan'208";a="902067965" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by FMSMGA003.fm.intel.com with ESMTP; 19 Sep 2017 20:17:28 -0700 Received: from fmsmsx122.amr.corp.intel.com (10.18.125.37) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 19 Sep 2017 20:17:22 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by fmsmsx122.amr.corp.intel.com (10.18.125.37) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 19 Sep 2017 20:17:22 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.175]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.98]) with mapi id 14.03.0319.002; Wed, 20 Sep 2017 11:17:20 +0800 From: "Hu, Jiayu" To: "Tan, Jianfeng" , "dev@dpdk.org" CC: "Ananyev, Konstantin" , "Kavanagh, Mark B" , "Yigit, Ferruh" , "thomas@monjalon.net" Thread-Topic: [PATCH v4 3/5] gso: add VxLAN GSO support Thread-Index: AQHTMRkv6UWHBrgOQUK7p/yxtCihs6K8k/YAgACGnkA= Date: Wed, 20 Sep 2017 03:17:18 +0000 Message-ID: References: <1505184211-36728-1-git-send-email-jiayu.hu@intel.com> <1505806379-71355-1-git-send-email-jiayu.hu@intel.com> <1505806379-71355-4-git-send-email-jiayu.hu@intel.com> <2296585c-ca59-6148-7a9b-edde83d25ef5@intel.com> In-Reply-To: <2296585c-ca59-6148-7a9b-edde83d25ef5@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYTU5MDdmNTUtOTg4OS00YmVhLTgxYmItNzkwYTMyYzgzZjA2IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE2LjUuOS4zIiwiVHJ1c3RlZExhYmVsSGFzaCI6IlJGQUsyXC9RYWdZVzZJdUdFVE1lOEVlMmExSjNcLzFtUTcwTFNtQ2JidDVpWT0ifQ== x-ctpclassification: CTP_IC x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v4 3/5] gso: add VxLAN GSO support X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Sep 2017 03:17:32 -0000 Hi Jianfeng, > -----Original Message----- > From: Tan, Jianfeng > Sent: Wednesday, September 20, 2017 11:11 AM > To: Hu, Jiayu ; dev@dpdk.org > Cc: Ananyev, Konstantin ; Kavanagh, Mark > B ; Yigit, Ferruh ; > thomas@monjalon.net > Subject: Re: [PATCH v4 3/5] gso: add VxLAN GSO support >=20 >=20 > On 9/19/2017 3:32 PM, Jiayu Hu wrote: > > From: Mark Kavanagh > > > > This patch adds GSO support for VxLAN-encapsulated packets. Supported > > VxLAN packets must have an outer IPv4 header (prepended by an optional > > VLAN tag), and contain an inner TCP/IPv4 packet (with an optional inner > > VLAN tag). >=20 > This patch not only adds support for VxLAN, but also support for tunnel > framework. Better to mention it in the first place. >=20 > > VxLAN GSO doesn't check if all input packets have correct checksums and > > doesn't update checksums for output packets. Additionally, it doesn't > > process IP fragmented packets. > > > > As with TCP/IPv4 GSO, VxLAN GSO uses a two-segment MBUF to organize > each > > output packet, which mandates support for multi-segment mbufs in the TX > > functions of the NIC driver. Also, if a packet is GSOed, VxLAN GSO > > reduces its MBUF refcnt by 1. As a result, when all of its GSOed segmen= ts > > are freed, the packet is freed automatically. > > > > VxLAN GSO clears the PKT_TX_TCP_SEG flag for the input packet and GSO > > segments on the event of success. >=20 > This flag is not cleared here, it's cleared in the gso interface. So > remove above sentence? Make sense. I will remove the above sentence. >=20 > > > > Signed-off-by: Mark Kavanagh > > Signed-off-by: Jiayu Hu > > --- > > doc/guides/rel_notes/release_17_11.rst | 3 ++ > > lib/librte_gso/Makefile | 1 + > > lib/librte_gso/gso_common.c | 58 +++++++++++++++++++++++ > > lib/librte_gso/gso_common.h | 25 ++++++++++ > > lib/librte_gso/gso_tunnel_tcp4.c | 87 > ++++++++++++++++++++++++++++++++++ > > lib/librte_gso/gso_tunnel_tcp4.h | 76 > +++++++++++++++++++++++++++++ > > lib/librte_gso/rte_gso.c | 13 +++-- > > 7 files changed, 260 insertions(+), 3 deletions(-) > > create mode 100644 lib/librte_gso/gso_tunnel_tcp4.c > > create mode 100644 lib/librte_gso/gso_tunnel_tcp4.h > > > > diff --git a/doc/guides/rel_notes/release_17_11.rst > b/doc/guides/rel_notes/release_17_11.rst > > index 7453bb0..2dc6b89 100644 > > --- a/doc/guides/rel_notes/release_17_11.rst > > +++ b/doc/guides/rel_notes/release_17_11.rst > > @@ -48,6 +48,9 @@ New Features > > ones (e.g. MTU is 1500B). Supported packet types are: > > > > * TCP/IPv4 packets, which may include a single VLAN tag. > > + * VxLAN packets, which must have an outer IPv4 header (prepended by > > + an optional VLAN tag), and contain an inner TCP/IPv4 packet (with > > + an optional VLAN tag). > > > > The GSO library doesn't check if the input packets have correct > > checksums, and doesn't update checksums for output packets. > > diff --git a/lib/librte_gso/Makefile b/lib/librte_gso/Makefile > > index 2be64d1..e6d41df 100644 > > --- a/lib/librte_gso/Makefile > > +++ b/lib/librte_gso/Makefile > > @@ -44,6 +44,7 @@ LIBABIVER :=3D 1 > > SRCS-$(CONFIG_RTE_LIBRTE_GSO) +=3D rte_gso.c > > SRCS-$(CONFIG_RTE_LIBRTE_GSO) +=3D gso_common.c > > SRCS-$(CONFIG_RTE_LIBRTE_GSO) +=3D gso_tcp4.c > > +SRCS-$(CONFIG_RTE_LIBRTE_GSO) +=3D gso_tunnel_tcp4.c > > > > # install this header file > > SYMLINK-$(CONFIG_RTE_LIBRTE_GSO)-include +=3D rte_gso.h > > diff --git a/lib/librte_gso/gso_common.c b/lib/librte_gso/gso_common.c > > index b2c84f6..90fcb2a 100644 > > --- a/lib/librte_gso/gso_common.c > > +++ b/lib/librte_gso/gso_common.c > > @@ -39,6 +39,7 @@ > > #include > > #include > > #include > > +#include > > > > #include "gso_common.h" > > > > @@ -200,3 +201,60 @@ update_tcp4_header(struct rte_mbuf *pkt, > uint8_t ipid_delta, > > sent_seq +=3D (segs[i]->pkt_len - segs[i]->data_len); > > } > > } > > + > > +static inline void > > +__update_outer_ipv4_header(struct rte_mbuf *pkt, uint16_t id) > > +{ > > + struct ipv4_hdr *ipv4_hdr; > > + > > + ipv4_hdr =3D (struct ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) + > > + pkt->outer_l2_len); > > + ipv4_hdr->total_length =3D rte_cpu_to_be_16(pkt->pkt_len - > > + pkt->outer_l2_len); > > + ipv4_hdr->packet_id =3D rte_cpu_to_be_16(id); > > +} > > + > > +static inline void > > +__update_outer_udp_header(struct rte_mbuf *pkt) > > +{ > > + struct udp_hdr *udp_hdr; > > + uint16_t length; > > + > > + length =3D pkt->outer_l2_len + pkt->outer_l3_len; > > + udp_hdr =3D (struct udp_hdr *)(rte_pktmbuf_mtod(pkt, char *) + > > + length); > > + udp_hdr->dgram_len =3D rte_cpu_to_be_16(pkt->pkt_len - length); > > +} > > + > > +void > > +update_ipv4_vxlan_tcp4_header(struct rte_mbuf *pkt, uint8_t ipid_delta= , > > + struct rte_mbuf **segs, uint16_t nb_segs) >=20 > This function is specific to tunnel, better move to gso_tunnel_tcp4.c Make sense. I will remove GRE header update function too. >=20 > > +{ > > + struct ipv4_hdr *ipv4_hdr; > > + struct tcp_hdr *tcp_hdr; > > + uint32_t sent_seq; > > + uint16_t l2_len, outer_id, inner_id, tail_idx, i; > > + > > + ipv4_hdr =3D (struct ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) + > > + pkt->outer_l2_len); > > + outer_id =3D rte_be_to_cpu_16(ipv4_hdr->packet_id); > > + > > + l2_len =3D pkt->outer_l2_len + pkt->outer_l3_len + pkt->l2_len; > > + ipv4_hdr =3D (struct ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) + > > + l2_len); > > + inner_id =3D rte_be_to_cpu_16(ipv4_hdr->packet_id); > > + tcp_hdr =3D (struct tcp_hdr *)((char *)ipv4_hdr + pkt->l3_len); > > + sent_seq =3D rte_be_to_cpu_32(tcp_hdr->sent_seq); > > + tail_idx =3D nb_segs - 1; > > + > > + for (i =3D 0; i < nb_segs; i++) { > > + __update_outer_ipv4_header(segs[i], outer_id); > > + outer_id +=3D ipid_delta; > > + __update_outer_udp_header(segs[i]); > > + > > + __update_ipv4_tcp_header(segs[i], l2_len, inner_id, > sent_seq, > > + i < tail_idx); > > + inner_id +=3D ipid_delta; > > + sent_seq +=3D (segs[i]->pkt_len - segs[i]->data_len); > > + } > > +} > > diff --git a/lib/librte_gso/gso_common.h b/lib/librte_gso/gso_common.h > > index 2a01cd0..0b0d8ed 100644 > > --- a/lib/librte_gso/gso_common.h > > +++ b/lib/librte_gso/gso_common.h > > @@ -48,6 +48,11 @@ > > #define IS_IPV4_TCP(flag) (((flag) & (PKT_TX_TCP_SEG | PKT_TX_IPV4)) = =3D=3D > \ > > (PKT_TX_TCP_SEG | PKT_TX_IPV4)) > > > > +#define IS_IPV4_VXLAN_TCP4(flag) (((flag) & (PKT_TX_TCP_SEG | > PKT_TX_IPV4 | \ > > + PKT_TX_OUTER_IPV4 | > PKT_TX_TUNNEL_VXLAN)) =3D=3D \ > > + (PKT_TX_TCP_SEG | PKT_TX_IPV4 | PKT_TX_OUTER_IPV4 | \ > > + PKT_TX_TUNNEL_VXLAN)) > > + > > /** > > * Internal function which updates relevant packet headers for TCP/IP= v4 > > * packets, following segmentation. This is required to update, for > > @@ -69,6 +74,26 @@ void update_tcp4_header(struct rte_mbuf *pkt, > > uint16_t nb_segs); > > > > /** > > + * Internal function which updates relevant packet headers for VxLAN > > + * packets, following segmentation. This is required to update, for > > + * example, the IPv4 'total_length' field, to reflect the reduced leng= th > > + * of the now-segmented packet. > > + * > > + * @param pkt > > + * The original packet. > > + * @param ipid_delta > > + * The increasing uint of IP ids. > > + * @param segs > > + * Pointer array used for storing mbuf addresses for GSO segments. > > + * @param nb_segs > > + * The number of GSO segments placed in segs. > > + */ > > +void update_ipv4_vxlan_tcp4_header(struct rte_mbuf *pkt, > > + uint8_t ipid_delta, > > + struct rte_mbuf **segs, > > + uint16_t nb_segs); > > + > > +/** > > * Internal function which divides the input packet into small segmen= ts. > > * Each of the newly-created segments is organized as a two-segment > MBUF, > > * where the first segment is a standard mbuf, which stores a copy of > > diff --git a/lib/librte_gso/gso_tunnel_tcp4.c > b/lib/librte_gso/gso_tunnel_tcp4.c > > new file mode 100644 > > index 0000000..cc017bd > > --- /dev/null > > +++ b/lib/librte_gso/gso_tunnel_tcp4.c > > @@ -0,0 +1,87 @@ > > +/*- > > + * BSD LICENSE > > + * > > + * Copyright(c) 2017 Intel Corporation. All rights reserved. > > + * All rights reserved. > > + * > > + * Redistribution and use in source and binary forms, with or withou= t > > + * modification, are permitted provided that the following condition= s > > + * are met: > > + * > > + * * Redistributions of source code must retain the above copyrigh= t > > + * notice, this list of conditions and the following disclaimer. > > + * * Redistributions in binary form must reproduce the above copyr= ight > > + * notice, this list of conditions and the following disclaimer = in > > + * the documentation and/or other materials provided with the > > + * distribution. > > + * * Neither the name of Intel Corporation nor the names of its > > + * contributors may be used to endorse or promote products deriv= ed > > + * from this software without specific prior written permission. > > + * > > + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND > CONTRIBUTORS > > + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT > NOT > > + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND > FITNESS FOR > > + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE > COPYRIGHT > > + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, > INCIDENTAL, > > + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, > BUT NOT > > + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; > LOSS OF USE, > > + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED > AND ON ANY > > + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR > TORT > > + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT > OF THE USE > > + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH > DAMAGE. > > + */ > > + > > +#include > > +#include > > + > > +#include "gso_common.h" > > +#include "gso_tunnel_tcp4.h" > > + > > +int > > +gso_tunnel_tcp4_segment(struct rte_mbuf *pkt, > > + uint16_t gso_size, > > + uint8_t ipid_delta, > > + struct rte_mempool *direct_pool, > > + struct rte_mempool *indirect_pool, > > + struct rte_mbuf **pkts_out, > > + uint16_t nb_pkts_out) > > +{ > > + struct ipv4_hdr *inner_ipv4_hdr; > > + uint16_t pyld_unit_size, hdr_offset; > > + uint16_t tcp_dl, frag_off; > > + int ret =3D 1; > > + > > + hdr_offset =3D pkt->outer_l2_len + pkt->outer_l3_len + pkt->l2_len; > > + inner_ipv4_hdr =3D (struct ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) = + > > + hdr_offset); > > + /* > > + * Don't process the packet whose MF bit and offset in the inner > > + * IPv4 header are non-zero. > > + */ > > + frag_off =3D rte_be_to_cpu_16(inner_ipv4_hdr->fragment_offset); > > + if (unlikely(IS_FRAGMENTED(frag_off))) { > > + pkts_out[0] =3D pkt; > > + return ret; >=20 > Please use "return 1;" for readability. OK. >=20 > > + } > > + > > + /* Don't process the packet without data */ > > + tcp_dl =3D pkt->pkt_len - pkt->l2_len - pkt->l3_len - pkt->l4_len; > > + if (unlikely(tcp_dl =3D=3D 0)) { > > + pkts_out[0] =3D pkt; > > + return ret; >=20 > Ditto. >=20 > > + } > > + > > + hdr_offset +=3D pkt->l3_len + pkt->l4_len; > > + pyld_unit_size =3D gso_size - hdr_offset; > > + > > + /* Segment the payload */ > > + ret =3D gso_do_segment(pkt, hdr_offset, pyld_unit_size, direct_pool, > > + indirect_pool, pkts_out, nb_pkts_out); > > + if (ret <=3D 1) > > + return ret; > > + > > + if (pkt->ol_flags & PKT_TX_TUNNEL_VXLAN) > > + update_ipv4_vxlan_tcp4_header(pkt, ipid_delta, pkts_out, > ret); > > + > > + return ret; > > +} > > diff --git a/lib/librte_gso/gso_tunnel_tcp4.h > b/lib/librte_gso/gso_tunnel_tcp4.h > > new file mode 100644 > > index 0000000..a848a2e > > --- /dev/null > > +++ b/lib/librte_gso/gso_tunnel_tcp4.h > > @@ -0,0 +1,76 @@ > > +/*- > > + * BSD LICENSE > > + * > > + * Copyright(c) 2017 Intel Corporation. All rights reserved. > > + * All rights reserved. > > + * > > + * Redistribution and use in source and binary forms, with or withou= t > > + * modification, are permitted provided that the following condition= s > > + * are met: > > + * > > + * * Redistributions of source code must retain the above copyrigh= t > > + * notice, this list of conditions and the following disclaimer. > > + * * Redistributions in binary form must reproduce the above copyr= ight > > + * notice, this list of conditions and the following disclaimer = in > > + * the documentation and/or other materials provided with the > > + * distribution. > > + * * Neither the name of Intel Corporation nor the names of its > > + * contributors may be used to endorse or promote products deriv= ed > > + * from this software without specific prior written permission. > > + * > > + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND > CONTRIBUTORS > > + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT > NOT > > + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND > FITNESS FOR > > + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE > COPYRIGHT > > + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, > INCIDENTAL, > > + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, > BUT NOT > > + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; > LOSS OF USE, > > + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED > AND ON ANY > > + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR > TORT > > + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT > OF THE USE > > + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH > DAMAGE. > > + */ > > + > > +#ifndef _GSO_TUNNEL_TCP4_H_ > > +#define _GSO_TUNNEL_TCP4_H_ > > + > > +#include > > +#include > > + > > +/** > > + * Segment an tunneling packet with inner TCP/IPv4 headers. This funct= ion > > + * doesn't check if the input packet has correct checksums, and doesn'= t > > + * update checksums for output GSO segments. Furthermore, it doesn't > > + * process IP fragment packets. > > + * > > + * @param pkt > > + * The packet mbuf to segment. > > + * @param gso_size > > + * The max length of a GSO segment, measured in bytes. > > + * @param ipid_delta > > + * The increasing uint of IP ids. > > + * @param direct_pool > > + * MBUF pool used for allocating direct buffers for output segments. > > + * @param indirect_pool > > + * MBUF pool used for allocating indirect buffers for output segments= . > > + * @param pkts_out > > + * Pointer array used to store the MBUF addresses of output GSO > > + * segments, when gso_tunnel_tcp4_segment() successes. If the memory > > + * space in pkts_out is insufficient, gso_tcp4_segment() fails and >=20 > "gso_tcp4_segment()" -> "it". Yes, a typo here. Thanks. Thanks, Jiayu >=20 > Thanks, > Jianfeng