From patchwork Tue Nov 20 04:45:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zhang X-Patchwork-Id: 48195 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 85C9C326C; Tue, 20 Nov 2018 05:44:27 +0100 (CET) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 1A22B2BD5; Tue, 20 Nov 2018 05:44:25 +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 fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Nov 2018 20:44:24 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,255,1539673200"; d="scan'208";a="107717763" Received: from dpdk51.sh.intel.com ([10.67.110.190]) by fmsmga004.fm.intel.com with ESMTP; 19 Nov 2018 20:44:22 -0800 From: Qi Zhang To: bruce.richardson@intel.com, keith.wiles@intel.com Cc: dev@dpdk.org, wenzhuo.lu@intel.com, bernard.iremonger@intel.com, Qi Zhang , stable@dpdk.org Date: Tue, 20 Nov 2018 12:45:37 +0800 Message-Id: <20181120044537.9495-1-qi.z.zhang@intel.com> X-Mailer: git-send-email 2.13.6 Subject: [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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 = rte_rdtsc(); #endif +#ifdef RTE_ARCH_X86 + __m128i addr; + __m128i shfl_msk = _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 /* * Receive a burst of packets and forward them. */ @@ -123,9 +131,15 @@ pkt_burst_mac_swap(struct fwd_stream *fs) eth_hdr = rte_pktmbuf_mtod(mb, struct ether_hdr *); /* Swap dest and src mac addresses. */ +#ifdef RTE_ARCH_X86 + addr = _mm_loadu_si128((__m128i *)eth_hdr); + addr = _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 &= IND_ATTACHED_MBUF | EXT_ATTACHED_MBUF; mb->ol_flags |= ol_flags;