From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 3016F29C6; Tue, 20 Nov 2018 10:16:58 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Nov 2018 01:16:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,256,1539673200"; d="scan'208";a="87812535" Received: from irsmsx101.ger.corp.intel.com ([163.33.3.153]) by fmsmga008.fm.intel.com with ESMTP; 20 Nov 2018 01:16:57 -0800 Received: from irsmsx106.ger.corp.intel.com ([169.254.8.8]) by IRSMSX101.ger.corp.intel.com ([169.254.1.134]) with mapi id 14.03.0415.000; Tue, 20 Nov 2018 09:16:56 +0000 From: "Ananyev, Konstantin" To: "Zhang, Qi Z" , "Richardson, Bruce" , "Wiles, Keith" CC: "dev@dpdk.org" , "Lu, Wenzhuo" , "Iremonger, Bernard" , "Zhang, Qi Z" , "stable@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH] app/testpmd: improve MAC swap performance Thread-Index: AQHUgIvCSKoZvPnjN0eggi2tlA1D3KVYYfvg Date: Tue, 20 Nov 2018 09:16:55 +0000 Message-ID: <2601191342CEEE43887BDE71AB977258010CEBA106@IRSMSX106.ger.corp.intel.com> References: <20181120044537.9495-1-qi.z.zhang@intel.com> In-Reply-To: <20181120044537.9495-1-qi.z.zhang@intel.com> Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiY2MwZjc1NGMtYjNjNi00MzU5LTk0MGUtZmZiN2VmZDc2ZThhIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoianFTVTFzNWJtaTNmTlpoNlhCTEtIUzFpcXJyd29CMDhsOFdQbmo2V1wvM0RqZ3RQMjFCcFVHQkM0djRSR29EU2gifQ== x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [163.33.239.182] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-stable] [dpdk-dev] [PATCH] app/testpmd: improve MAC swap performance X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Nov 2018 09:17:00 -0000 Hi Qi, > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Qi Zhang > Sent: Tuesday, November 20, 2018 4:46 AM > To: Richardson, Bruce ; Wiles, Keith > Cc: dev@dpdk.org; Lu, Wenzhuo ; Iremonger, Bernard = ; Zhang, Qi Z > ; stable@dpdk.org > Subject: [dpdk-dev] [PATCH] app/testpmd: improve MAC swap performance >=20 > The patch optimizes the mac swap operation by taking advantage > of SSE instructions, it only impacts x86 platform. >=20 > Cc: stable@dpdk.org >=20 > Signed-off-by: Qi Zhang > --- > app/test-pmd/macswap.c | 16 +++++++++++++++- > 1 file changed, 15 insertions(+), 1 deletion(-) >=20 > diff --git a/app/test-pmd/macswap.c b/app/test-pmd/macswap.c > index a8384d5b8..0722782b0 100644 > --- a/app/test-pmd/macswap.c > +++ b/app/test-pmd/macswap.c > @@ -78,7 +78,6 @@ pkt_burst_mac_swap(struct fwd_stream *fs) > struct rte_port *txp; > struct rte_mbuf *mb; > struct ether_hdr *eth_hdr; > - struct ether_addr addr; > uint16_t nb_rx; > uint16_t nb_tx; > uint16_t i; > @@ -95,6 +94,15 @@ pkt_burst_mac_swap(struct fwd_stream *fs) > start_tsc =3D rte_rdtsc(); > #endif >=20 > +#ifdef RTE_ARCH_X86 > + __m128i addr; > + __m128i shfl_msk =3D _mm_set_epi8(15, 14, 13, 12, > + 5, 4, 3, 2, > + 1, 0, 11, 10, > + 9, 8, 7, 6); > +#else > + struct ether_addr addr; > +#endif I think it would better to place IA specific code into a separate fnction (and probably into a separate .h file). BTW, just curious what % of improvement it gives? Konstantin > /* > * Receive a burst of packets and forward them. > */ > @@ -123,9 +131,15 @@ pkt_burst_mac_swap(struct fwd_stream *fs) > eth_hdr =3D rte_pktmbuf_mtod(mb, struct ether_hdr *); >=20 > /* Swap dest and src mac addresses. */ > +#ifdef RTE_ARCH_X86 > + addr =3D _mm_loadu_si128((__m128i *)eth_hdr); > + addr =3D _mm_shuffle_epi8(addr, shfl_msk); > + _mm_storeu_si128((__m128i *)eth_hdr, addr); > +#else > ether_addr_copy(ð_hdr->d_addr, &addr); > ether_addr_copy(ð_hdr->s_addr, ð_hdr->d_addr); > ether_addr_copy(&addr, ð_hdr->s_addr); > +#endif >=20 > mb->ol_flags &=3D IND_ATTACHED_MBUF | EXT_ATTACHED_MBUF; > mb->ol_flags |=3D ol_flags; > -- > 2.13.6