app/testpmd: optimized MAC swap by using neon intrinsics
PATCH 1/1 app/testpmd: optimized MAC swap by using neon intrinsics
Improved MAC swap performance for ARM platform. The improvement was achieved by using neon intrinsics to save CPU cycles and doing swap for four packets at a time.
The optimization had 15% - 20% throughput boost in testpmd MAC swap mode.
--- app/test-pmd/macswap.c | 4 +- app/test-pmd/macswap_neon.h | 93 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 app/test-pmd/macswap_neon.h
app/test-pmd/macswap.c +3 -1
@@ -66,8 +66,10 @@#include <rte_flow.h> #include "testpmd.h" -#ifdef RTE_ARCH_X86 +#if defined(RTE_ARCH_X86 )#include "macswap_sse.h" +#elif defined(RTE_MACHINE_CPUFLAG_NEON ) +#include "macswap_neon.h" #else #include "macswap.h" #endif
app/test-pmd/macswap_neon.h new file +93 -0
93 lines not on this page · raw message
Signature · 1 line
2.7.4
Quoted 28 lines · Ruifeng Wang
-------------------------------------------------------------------
---
Improved MAC swap performance for ARM platform. The improvement was achieved by using neon intrinsics to save CPU cycles and doing swap for four packets at a time.
The optimization had 15% - 20% throughput boost in testpmd MAC swap mode.Signed-off-by Ruifeng Wang <[email protected]>Reviewed-by Gavin Hu <[email protected]>Reviewed-by Phil Yang <[email protected]>--- app/test-pmd/macswap.c | 4 +- app/test-pmd/macswap_neon.h | 93 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 app/test-pmd/macswap_neon.happ/test-pmd/macswap.c +7
-0+static inline void +do_macswap (struct rte_mbuf *pkts[],uint16_t nb, +struct rte_port *txp) +{ +struct ether_hdr *eth_hdr[4 ]; +struct rte_mbuf *mb[4 ]; +uint64_t ol_flags;
app/test-pmd/macswap.c
Quoted 10 lines
app/test-pmd/macswap.c +10
-0+int i; +int r; +uint8x16_t v0, v1, v2, v3; +/** +* Index map be used to shuffle the 16 bytes. +* byte 0-5 will be swapped with byte 6-11. +* byte 12-15 will keep unchanged. +*/ +uint8x16_t idx_map = {6 ,7 ,8 ,9 ,10 ,11 ,0 ,1 ,2 ,3 ,4 ,5 , +12 ,13 ,14 ,15 };
Nit: I think, we can make it as "const uint8x16_t idx_map".
Other than that it looks good to me.
Regarding the performance, I have tested with two SoCs.
octeontx: +13% improvement
octeontx2: +46% improvement
Quoted 35 lines
Improved MAC swap performance for ARM platform.
The improvement was achieved by using neon intrinsics to save CPU cycles and doing swap for four packets at a time.
The optimization had 15% - 20% throughput boost in testpmd MAC swap mode.Signed-off-by Ruifeng Wang <[email protected]>Reviewed-by Gavin Hu <[email protected]>Reviewed-by Phil Yang <[email protected]>--- app/test-pmd/macswap.c | 4 +- app/test-pmd/macswap_neon.h | 93 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 app/test-
pmd/macswap_neon.happ/test-pmd/macswap.c index renamed from app/test-pmd/macswap.c +0
-0cbb41b7..71af916 100644
app/test-pmd/macswap.c +2
-1@@ -66,8 +66,10 @@#include <rte_flow.h> #include "testpmd.h" -#ifdef RTE_ARCH_X86 +#if defined(RTE_ARCH_X86 )#include "macswap_sse.h" +#elif defined(RTE_MACHINE_CPUFLAG_NEON) #include "macswap_neon.h"#else #include "macswap.h" #endif app/test-pmd/macswap_neon.h new file +0
-0
app/test-pmd/macswap_neon.h line 2
Quoted 2 lines
app/test-pmd/macswap_neon.h new file +2
-0@@ -0,0 +1,93 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2019 Arm Limited
This change is derived from Intel's work in macswap_sse.h. Can you please add a header similar to lib/librte_lpm/rte_lpm_neon.h?
Quoted 5 lines
app/test-pmd/macswap_neon.h new file +5
-0+*/ + +#ifndef _MACSWAP_NEON_H_ +#define _MACSWAP_NEON_H_ +
<snip>
Regards,
/Ruifeng
Quoted 52 lines
-----Original Message-----
From: Jerin Jacob Kollanukkaran <[email protected]>
Sent: 2019年3月11日 22:17
To: Ruifeng Wang (Arm Technology China) <[email protected]>; [email protected]; [email protected]; [email protected]
Cc: Honnappa Nagarahalli <[email protected]>; nd <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH v1] app/testpmd: optimized MAC swap by using neon intrinsicsQuoted 27 lines · Ruifeng Wang
-------------------------------------------------------------------
---
Improved MAC swap performance for ARM platform.
The improvement was achieved by using neon intrinsics to save CPU cycles and doing swap for four packets at a time.
The optimization had 15% - 20% throughput boost in testpmd MAC swap mode.Signed-off-by Ruifeng Wang <[email protected]>Reviewed-by Gavin Hu <[email protected]>Reviewed-by Phil Yang <[email protected]>--- app/test-pmd/macswap.c | 4 +- app/test-pmd/macswap_neon.h | 93 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+), 1 deletion(-) create mode 100644
app/test-pmd/macswap_neon.happ/test-pmd/macswap.c +7
-0+static inline void +do_macswap (struct rte_mbuf *pkts[],uint16_t nb, +struct rte_port *txp) +{ +struct ether_hdr *eth_hdr[4 ]; +struct rte_mbuf *mb[4 ]; +uint64_t ol_flags;app/test-pmd/macswap.c
Quoted 10 lines
app/test-pmd/macswap.c +10
-0+int i; +int r; +uint8x16_t v0, v1, v2, v3; +/** +* Index map be used to shuffle the 16 bytes. +* byte 0-5 will be swapped with byte 6-11. +* byte 12-15 will keep unchanged. +*/ +uint8x16_t idx_map = {6 ,7 ,8 ,9 ,10 ,11 ,0 ,1 ,2 ,3 ,4 ,5 , +12 ,13 ,14 ,15 };Nit: I think, we can make it as "const
uint8x16_tidx_map".
Quoted 9 lines
Other than that it looks good to me.
Regarding the performance, I have tested with two SoCs.octeontx: +13% improvement
octeontx2: +46% improvementAcked-by Jerin Jacob <[email protected]>
Thanks Jerin for your test and data.
The code change will be included in v2.
Regards,
/Ruifeng
Quoted 47 lines
-----Original Message-----
From: Honnappa Nagarahalli <[email protected]>
Sent: 2019年3月11日 23:33
To: Ruifeng Wang (Arm Technology China) <[email protected]>; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; nd <[email protected]>; Ruifeng Wang (Arm Technology China) <[email protected]>; Honnappa Nagarahalli <[email protected]>; nd <[email protected]>
Subject: RE: [PATCH v1] app/testpmd: optimized MAC swap by using neon intrinsicsQuoted 4 lines
Improved MAC swap performance for ARM platform.
The improvement was achieved by using neon intrinsics to save CPU cycles and doing swap for four packets at a time.
The optimization had 15% - 20% throughput boost in testpmd MAC swapmode.
Quoted 16 lines
Signed-off-by Ruifeng Wang <[email protected]>Reviewed-by Gavin Hu <[email protected]>Reviewed-by Phil Yang <[email protected]>--- app/test-pmd/macswap.c | 4 +- app/test-pmd/macswap_neon.h | 93 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+), 1 deletion(-) create mode 100644app/test-
pmd/macswap_neon.happ/test-pmd/macswap.c index renamed from app/test-pmd/macswap.c +0
-0cbb41b7..71af916 100644
app/test-pmd/macswap.c line 71
Quoted 7 lines
app/test-pmd/macswap.c +2
-1@@ -66,8 +66,10 @@#include <rte_flow.h> #include "testpmd.h" -#ifdef RTE_ARCH_X86 +#if defined(RTE_ARCH_X86 )#include "macswap_sse.h" +#elif defined(RTE_MACHINE_CPUFLAG_NEON) #include"
macswap_neon.h"app/test-
Quoted 4 lines
app/test-pmd/macswap.c +0
-0#else #include "macswap.h" #endif app/test- renamed from app/test-pmd/macswap_neon.h +0
-0
pmd/macswap_neon.h
Quoted 9 lines
app/test-pmd/macswap_neon.h line 2
Quoted 6 lines
new file mode 100644 index 0000000..bad1b9b
app/test-pmd/macswap_neon.h new file +2
-0@@ -0,0 +1,93 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2019 Arm Limited This change is derived from Intel's work in
macswap_sse.h. Can you please add a header similar tolib/librte_lpm/rte_lpm_neon.h?
Sure. Will update file header in v2.
Thanks for your suggestion.
Quoted 7 lines
Quoted 5 lines
app/test-pmd/macswap_neon.h new file +5
-0+*/ + +#ifndef _MACSWAP_NEON_H_ +#define _MACSWAP_NEON_H_ +<snip>