From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 1805B1B57B; Tue, 27 Nov 2018 02:06:20 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Nov 2018 17:06:19 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,284,1539673200"; d="scan'208";a="103581561" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by orsmga003.jf.intel.com with ESMTP; 26 Nov 2018 17:06:19 -0800 Received: from fmsmsx158.amr.corp.intel.com (10.18.116.75) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.408.0; Mon, 26 Nov 2018 17:06:19 -0800 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by fmsmsx158.amr.corp.intel.com (10.18.116.75) with Microsoft SMTP Server (TLS) id 14.3.408.0; Mon, 26 Nov 2018 17:06:19 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.161]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.102]) with mapi id 14.03.0415.000; Tue, 27 Nov 2018 09:06:16 +0800 From: "Zhang, Qi Z" To: "Wiles, Keith" CC: "Richardson, Bruce" , dev , "Lu, Wenzhuo" , "Iremonger, Bernard" , "stable@dpdk.org" Thread-Topic: [PATCH] app/testpmd: improve MAC swap performance Thread-Index: AQHUgIu32aOj5rhZkEe0SJUqUpTu76VddLUAgAEocICABDxMQA== Date: Tue, 27 Nov 2018 01:06:15 +0000 Message-ID: <039ED4275CED7440929022BC67E70611532EB088@SHSMSX103.ccr.corp.intel.com> References: <20181120044537.9495-1-qi.z.zhang@intel.com> <21DA84FC-B5A5-4987-868F-C6AA85724D5F@intel.com> In-Reply-To: <21DA84FC-B5A5-4987-868F-C6AA85724D5F@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMmM3OGRlZjktYjkwNC00MmEwLWFlY2ItNWQ5OTdlOWY4MDQzIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiM2FsaGJpdmJpZ1VcL0Qrak9vS05xN3pveVdPTFg3bUNoeHBsUDhxdHJaNklIRGxOXC9MdmVWaGxTTTgrRWhMeVFhIn0= x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action 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] 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: Tue, 27 Nov 2018 01:06:21 -0000 > -----Original Message----- > From: Wiles, Keith > Sent: Saturday, November 24, 2018 8:24 AM > To: Zhang, Qi Z > Cc: Richardson, Bruce ; dev ; L= u, > Wenzhuo ; Iremonger, Bernard > ; stable@dpdk.org > Subject: Re: [PATCH] app/testpmd: improve MAC swap performance >=20 >=20 >=20 > > On Nov 23, 2018, at 4:43 PM, Wiles, Keith wrote= : > > > > > > > >> On Nov 19, 2018, at 10:45 PM, Zhang, Qi Z wrote= : > >> > >> The patch optimizes the mac swap operation by taking advantage of SSE > >> instructions, it only impacts x86 platform. > >> > >> Cc: stable@dpdk.org > >> > >> Signed-off-by: Qi Zhang > >> --- > >> app/test-pmd/macswap.c | 16 +++++++++++++++- > >> 1 file changed, 15 insertions(+), 1 deletion(-) > >> > >> 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 > >> > >> +#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); > > > > 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. > > > > _mm_set_epi8(15, 14, 13, 12, 5, 4, 3, 2, 1, 0, 11, 10, 9, 8, 7, 6); > > > > After dumping the memory for a large number of tests this one seems cor= rect, > can you verify your mask is correct? >=20 > Sorry, I do not know why I thought the code was not the same, but your > example is correct my mistake. Thanks for review and verify this! Regards Qi > > > >> +#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 *); > >> > >> /* 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 > >> > >> mb->ol_flags &=3D IND_ATTACHED_MBUF | EXT_ATTACHED_MBUF; > >> mb->ol_flags |=3D ol_flags; > >> -- > >> 2.13.6 > >> > > > > Regards, > > Keith >=20 > Regards, > Keith