From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id D80B41B47E; Sat, 24 Nov 2018 17:24:32 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Nov 2018 08:24:31 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,273,1539673200"; d="scan'208";a="108938137" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by fmsmga004.fm.intel.com with ESMTP; 24 Nov 2018 08:24:31 -0800 Received: from FMSMSX110.amr.corp.intel.com (10.18.116.10) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.408.0; Sat, 24 Nov 2018 08:24:31 -0800 Received: from fmsmsx118.amr.corp.intel.com ([169.254.1.160]) by FMSMSX110.amr.corp.intel.com ([169.254.14.33]) with mapi id 14.03.0415.000; Sat, 24 Nov 2018 08:24:30 -0800 From: "Wiles, Keith" To: "Zhang, Qi Z" CC: "Richardson, Bruce" , dev , "Lu, Wenzhuo" , "Iremonger, Bernard" , "stable@dpdk.org" Thread-Topic: [PATCH] app/testpmd: improve MAC swap performance Thread-Index: AQHUgIu2WDX9Iwc3dkmCSNxM+XXwtKVegO4AgAEobgA= Date: Sat, 24 Nov 2018 16:24:29 +0000 Message-ID: <21DA84FC-B5A5-4987-868F-C6AA85724D5F@intel.com> References: <20181120044537.9495-1-qi.z.zhang@intel.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.254.184.30] Content-Type: text/plain; charset="us-ascii" Content-ID: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] app/testpmd: improve MAC swap performance 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: Sat, 24 Nov 2018 16:24:33 -0000 > On Nov 23, 2018, at 4:43 PM, Wiles, Keith wrote: >=20 >=20 >=20 >> On Nov 19, 2018, at 10:45 PM, Zhang, Qi Z wrote: >>=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); >=20 > I was playing around with these mask values and I was not able to make it= work as I expected. > I ended up with different values in the mask. >=20 > _mm_set_epi8(15, 14, 13, 12, 5, 4, 3, 2, 1, 0, 11, 10, 9, 8, 7, 6); >=20 > After dumping the memory for a large number of tests this one seems corre= ct, can you verify your mask is correct? Sorry, I do not know why I thought the code was not the same, but your exam= ple is correct my mistake. >=20 >> +#else >> + struct ether_addr addr; >> +#endif >> /* >> * 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; >> --=20 >> 2.13.6 >>=20 >=20 > Regards, > Keith Regards, Keith