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 71CA61B1FF for ; Fri, 14 Dec 2018 12:36:53 +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 orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Dec 2018 03:36:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,352,1539673200"; d="scan'208";a="110364925" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by orsmga003.jf.intel.com with ESMTP; 14 Dec 2018 03:36:52 -0800 Received: from fmsmsx122.amr.corp.intel.com (10.18.125.37) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.408.0; Fri, 14 Dec 2018 03:36:51 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by fmsmsx122.amr.corp.intel.com (10.18.125.37) with Microsoft SMTP Server (TLS) id 14.3.408.0; Fri, 14 Dec 2018 03:36:51 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.59]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.222]) with mapi id 14.03.0415.000; Fri, 14 Dec 2018 19:36:48 +0800 From: "Zhang, Qi Z" To: "Iremonger, Bernard" , "Yigit, Ferruh" , "Richardson, Bruce" , "Wiles, Keith" , "Ananyev, Konstantin" CC: "dev@dpdk.org" , "Lu, Wenzhuo" Thread-Topic: [PATCH v2 2/3] app/testpmd: improve MAC swap performance for x86 Thread-Index: AQHUkRXuWfhehYFq6UKnuYl2ZbJkIaV9liOAgACJ0mA= Date: Fri, 14 Dec 2018 11:36:48 +0000 Message-ID: <039ED4275CED7440929022BC67E70611532FEF20@SHSMSX103.ccr.corp.intel.com> References: <20181122172632.6229-1-qi.z.zhang@intel.com> <20181211055511.32284-1-qi.z.zhang@intel.com> <20181211055511.32284-3-qi.z.zhang@intel.com> <8CEF83825BEC744B83065625E567D7C260D3D6D0@IRSMSX108.ger.corp.intel.com> In-Reply-To: <8CEF83825BEC744B83065625E567D7C260D3D6D0@IRSMSX108.ger.corp.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYjBlNzg4NmItZjc5YS00N2IyLWFlZDktNjYxOGVkZTFjMmMyIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiT3N3emwwdXhyaEVxRFdNSUI5NExqUEZ2VW9vZnlMMHpocnBEMldGQ1wvZHJpNzFnanhmT1dcL0xsVkRETXpcL0ptayJ9 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 v2 2/3] app/testpmd: improve MAC swap performance for x86 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: Fri, 14 Dec 2018 11:36:54 -0000 > -----Original Message----- > From: Iremonger, Bernard > Sent: Friday, December 14, 2018 7:22 PM > To: Zhang, Qi Z ; Yigit, Ferruh ; > Richardson, Bruce ; Wiles, Keith > ; Ananyev, Konstantin > Cc: dev@dpdk.org; Lu, Wenzhuo > Subject: RE: [PATCH v2 2/3] app/testpmd: improve MAC swap performance for > x86 >=20 > Hi Qi, >=20 > > -----Original Message----- > > From: Zhang, Qi Z > > Sent: Tuesday, December 11, 2018 5:55 AM > > To: Yigit, Ferruh ; Richardson, Bruce > > ; Wiles, Keith ; > > Ananyev, Konstantin > > Cc: dev@dpdk.org; Lu, Wenzhuo ; Iremonger, > > Bernard ; Zhang, Qi Z > > > > Subject: [PATCH v2 2/3] app/testpmd: improve MAC swap performance for > > x86 > > > > The patch optimizes the mac swap operation by taking advantage of SSE > > instructions, it only impacts x86 platform. > > > > Signed-off-by: Qi Zhang > > --- > > app/test-pmd/macswap.c | 4 ++++ > > app/test-pmd/macswap_common.h | 1 - > > app/test-pmd/macswap_sse.h | 45 > > +++++++++++++++++++++++++++++++++++++++++++ > > 3 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 > > app/test- pmd/macswap_sse.h > > > > diff --git a/app/test-pmd/macswap.c b/app/test-pmd/macswap.c index > > 849194fe2..cbb41b728 100644 > > --- a/app/test-pmd/macswap.c > > +++ b/app/test-pmd/macswap.c > > @@ -66,7 +66,11 @@ > > #include > > > > #include "testpmd.h" > > +#ifdef RTE_ARCH_X86 > > +#include "macswap_sse.h" > > +#else > > #include "macswap.h" > > +#endif > > > > /* > > * MAC swap forwarding mode: Swap the source and the destination > > Ethernet diff --git a/app/test-pmd/macswap_common.h b/app/test- > > pmd/macswap_common.h index ab0a5b5ef..8c5518596 100644 > > --- a/app/test-pmd/macswap_common.h > > +++ b/app/test-pmd/macswap_common.h > > @@ -44,4 +44,3 @@ mbuf_field_set(struct rte_mbuf *mb, uint64_t > > ol_flags) } > > > > #endif /* _BPF_CMD_H_ */ > > - > > diff --git a/app/test-pmd/macswap_sse.h b/app/test-pmd/macswap_sse.h > > new file mode 100644 index 000000000..79f4f9a7c > > --- /dev/null > > +++ b/app/test-pmd/macswap_sse.h > > @@ -0,0 +1,45 @@ > > +/* SPDX-License-Identifier: BSD-3-Clause > > + * Copyright(c) 2018 Intel Corporation */ > > + > > +#ifndef _L2FWD_SSE_H_ > > +#define _L2FWD_SSE_H_ >=20 > _L2FWD_SSE_H_ should be replaced by _MACSWAP_SSE_H_ in the lines > above. Yes, during re-work, I saw this and EOF issue also, will fix >=20 > > + > > +#include "macswap_common.h" > > + > > +static inline void > > +do_macswap(struct rte_mbuf *pkts[], uint16_t nb, > > + struct rte_port *txp) > > +{ > > + struct ether_hdr *eth_hdr; > > + struct rte_mbuf *mb; > > + uint64_t ol_flags; > > + int i; > > + __m128i addr; >=20 > Some comments explaining the parameters to _mm_set_epi8() would be useful= . OK, will add. Thanks Qi >=20 > > + __m128i shfl_msk =3D _mm_set_epi8(15, 14, 13, 12, > > + 5, 4, 3, 2, > > + 1, 0, 11, 10, > > + 9, 8, 7, 6); > > + > > + ol_flags =3D ol_flags_init(txp->dev_conf.txmode.offloads); > > + vlan_qinq_set(pkts, nb, ol_flags, > > + txp->tx_vlan_id, txp->tx_vlan_id_outer); > > + > > + for (i =3D 0; i < nb; i++) { > > + if (likely(i < nb - 1)) > > + rte_prefetch0(rte_pktmbuf_mtod(pkts[i+1], void > > *)); > > + mb =3D pkts[i]; > > + > > + eth_hdr =3D rte_pktmbuf_mtod(mb, struct ether_hdr *); > > + > > + /* Swap dest and src mac addresses. */ > > + addr =3D _mm_loadu_si128((__m128i *)eth_hdr); > > + addr =3D _mm_shuffle_epi8(addr, shfl_msk); > > + _mm_storeu_si128((__m128i *)eth_hdr, addr); > > + > > + mbuf_field_set(mb, ol_flags); > > + } > > +} > > + > > +#endif /* _BPF_CMD_H_ */ >=20 > _BPF_CMD_H should be replaced by _MACSWAP_SSE_H_ in the line above. >=20 > > + > > -- > > 2.13.6 >=20 > A white space error is reported when applying this patch >=20 > Applying: app/testpmd: improve MAC swap performance for x86 > .git/rebase-apply/patch:83: new blank line at EOF. >=20 > Regards, >=20 > Bernard. >=20