From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from na01-bn1-obe.outbound.protection.outlook.com (mail-bn1on0087.outbound.protection.outlook.com [157.56.110.87]) by dpdk.org (Postfix) with ESMTP id 2B31128BF for ; Thu, 10 Mar 2016 17:06:48 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-caviumnetworks-com; h=From:To:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=feKEQh9RpCwSSp2KmH5ijldMFGHUc0PXEetJyzeqm00=; b=Q8zvP4/3ebCVDzMbNBPkqKmED6ZLGdwJTx8GAHBxqkyW9NObUWf/ta1dmCFw3kySeH8Kb6DW6l3lDH513mLOPtFmIsaf6x0n7KvHbfslqiT6LDJ245fm55SO8qXWeSIqvq8brqaasxjRJH4zTzi0fbnpVkMC1tJHjSEYFMyjmo8= Authentication-Results: dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=none action=none header.from=caviumnetworks.com; Received: from hp-mjc.semihalf.local (80.82.22.190) by BLUPR0701MB1025.namprd07.prod.outlook.com (10.160.35.17) with Microsoft SMTP Server (TLS) id 15.1.434.16; Thu, 10 Mar 2016 16:06:46 +0000 From: To: Date: Thu, 10 Mar 2016 17:06:22 +0100 Message-ID: <1457625982-24066-2-git-send-email-Maciej.Czekaj@caviumnetworks.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1457625982-24066-1-git-send-email-Maciej.Czekaj@caviumnetworks.com> References: <1457625982-24066-1-git-send-email-Maciej.Czekaj@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [80.82.22.190] X-ClientProxiedBy: DB5PR09CA0051.eurprd09.prod.outlook.com (25.162.34.19) To BLUPR0701MB1025.namprd07.prod.outlook.com (25.160.35.17) X-MS-Office365-Filtering-Correlation-Id: d51a955b-a857-4649-e7eb-08d348fdfb43 X-Microsoft-Exchange-Diagnostics: 1; BLUPR0701MB1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A/kM3zwB2GmnntfS2xF3LS2VIUOebujy14fnZd9Xp3ypIe8YHzXWUUCJfCOzrpgG+ZDsoW6pnBv2otrtV7hVdEc9Gysu0DyDrIHtlRTdcVn3GEQg6MKn2o0ng3+VU4afIMXj1EtiyUPXn/bfkNqkHsSeJFUS6OupMIFy9KiUl22xqYkwB62tU3So6TrPKiUp3YaLOt33IJRCXKUDDZg3X1KZLAzSEhnBODuBZOcCBbiV7zgAbNfZ+IOAaNRCrx81mquFAtz27XOvUC5sBUXMwEg9+YsW+rHqZHkCg8wcspD92jtjEs/TTXhki7bHw= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001); SRVR:BLUPR0701MB1025; BCL:0; PCL:0; RULEID:; SRVR:BLUPR0701MB1025; X-Microsoft-Exchange-Diagnostics: 1; BLUPR0701MB1025; 4:wGkgJ2t/eV/fWHC/GI4aapVJ3ho9GocGyOuAWbb7vBW7lBdPBktU7HQICmoC5bJNF2wio14HdAm11uGm958/G+HSsovtif+Z0YXgFPs1CTJjSEeO8mlEFHTbYqyyYCp1vC4Dn4mkzhePRgUYRPHVOb8KkHUePFb9sM6hBxPGUw/tCFtAKm69YMvVXMkMvfmCfspjNfx1mcU3ibv+PgK0SVCd/kMmt5pagsTGTG32a+LUt1glakoeoI8py3jRuItvFxMVmulnyLLpPIhPT+UYxtR4avcmKisnBwre5pU3eZn4dMolSRlfUYUl6v/v60gSL2V/U6ehDNa0wKAKaU2dqTkiGp3ezkrGjMsjobn2uQSCYF4vUr44J1EvMCKLHxk8 X-Forefront-PRVS: 08770259B4 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(189998001)(5004730100002)(19580395003)(77096005)(5008740100001)(2876002)(19580405001)(50986999)(76176999)(50466002)(86152002)(3846002)(2351001)(6116002)(229853001)(86362001)(4326007)(36756003)(5003940100001)(92566002)(42186005)(47776003)(81166005)(50226001)(2950100001)(4001430100002)(66066001)(2906002)(110136002)(107886002)(1096002)(48376002)(586003)(7099028)(32563001); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR0701MB1025; H:hp-mjc.semihalf.local; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BLUPR0701MB1025; 23:vTDIaDRg3kbpr4CJsf8AwWcjJHbNFtnjdMCAEKj?= =?us-ascii?Q?KNP3GeBZw3TTIhZ81qOX4TTeXAwhmjc1XSl1JIiVq0Z+3etjaMPGXzyxtiLk?= =?us-ascii?Q?mbNegqlYnCMChqMpdcP9GEIj2UY1DxUI2w9RCeNglLnqJEJDVGx9HslPxvX3?= =?us-ascii?Q?ULkMCuLaU08YSvw6ysYA8AghpWTsGv7JXhS+W6TpDcN7xl75toud/coxZ1c6?= =?us-ascii?Q?Z2B+IocEkyFupMgsBvvmsML3QfYvUwQebSndigoQLK0PcG23GXDa9WASHOFs?= =?us-ascii?Q?C3EYv64uHtKxOefanCRD3YIsDkZI8QnQMMaDFOjGRCAwF64/EwPdygvrb81C?= =?us-ascii?Q?yULMXqfasd583qgJhlFcfjF+49RaZ06najPw4m/iYHc3p8K+SvodPA95lG/q?= =?us-ascii?Q?GiEtJKnGfQLgNy7P/QzVCnong8ksqqYEwkZwR1LYhDu9oLvGcAleIdMi4U+j?= =?us-ascii?Q?1jDR37kyMK/QClzHLgxhvlhmsAGDcq2Agu4nEnaPgmddHEIb0K5/2Fwu3uqS?= =?us-ascii?Q?LrSC6CHz1RavJ+aJbw1/qyWr4C2B28xhuBKLLVkUkzM3mHZIJNJITGF+BBgU?= =?us-ascii?Q?709UfG0iKYx3B285Y5v1PT56jCzxUEKHuNg601nf59EGWA1nAtUk/fv2l1p1?= =?us-ascii?Q?Pyh7Xi+lqJNknWOA8oPNi5Pu26Th9d6PWkUCNGI5TT+qUokrPoFUcAhuNiHP?= =?us-ascii?Q?1XiABHZBD4xsXWgsAuzgWzYnGehYAMqDpDedGFOItRHUln/CTv86jn+fPtR6?= =?us-ascii?Q?UZOTfQt1sg2w1mHKnPni4/RaM11GiAj8dftjysCccbhKmuRz2f+TrrIicYSh?= =?us-ascii?Q?0agK86Zsx/Eq4twohMNVfMvOIjhCvuPeWGV/fmRKenY6q58GzR4TYPvwhCoo?= =?us-ascii?Q?ybXstQoaTjBfOuxKC+y0eWcCRNOp3WuZTBB01Y6wVY1qLwsl2hbgjmC+Z/7y?= =?us-ascii?Q?8C19tPEBuO4qOVEEksUMBcysyeZcJ9YkDf6SkpGxDXpI1v8vpj37+woz4Plt?= =?us-ascii?Q?AT8Wj1cSOUUxjO4CU39qQCA8Z?= X-Microsoft-Exchange-Diagnostics: 1; BLUPR0701MB1025; 5:KWAUy4URxiJ6aFkUAz1pkbMO7Y5wwOdZjq80gfVKf/Y5/Nh/Cc18DLBYmdFU/9CGYYLenLqqWMVCYJtaPZx5nB8HkQuEtBdoAgNxLMxHtuk8Yk5owkas2soxleZwWRKM4UZUgCOVnQva3vZ8SwFlag==; 24:wCSfyMDumPl5Y4m4s+/TfxO2bqTkKqs4AsZ3BeZyg9+3QAcHmZIbu0cyVvUmZnW/vsfmZv5QdP2kXsLs9IAMiW6l+QQ3gWR7QKUqCSKQFe8= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Mar 2016 16:06:46.0547 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR0701MB1025 Subject: [dpdk-dev] [PATCH] l3fwd: Fix compilation & enable exact match mode on ARM. X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Mar 2016 16:06:48 -0000 From: Maciej Czekaj Enable NEON support in exact match mode. l3fwd example did not compile on ARM due to SSE2 instrincics used in generic part. Some instrinsins were used to initialize data structures and those were replaced by ordinary structure initalization. All SSE2 intrinsics used in forwarding, i.e. masking the IP/TCP header are moved to single inline function and made arch-specific. Signed-off-by: Maciej Czekaj --- examples/l3fwd/l3fwd.h | 4 ++- examples/l3fwd/l3fwd_em.c | 72 +++++++++++++++++++++++++++++------------------ examples/l3fwd/main.c | 2 +- 3 files changed, 48 insertions(+), 30 deletions(-) diff --git a/examples/l3fwd/l3fwd.h b/examples/l3fwd/l3fwd.h index da6d369..7dcc7e5 100644 --- a/examples/l3fwd/l3fwd.h +++ b/examples/l3fwd/l3fwd.h @@ -34,6 +34,8 @@ #ifndef __L3_FWD_H__ #define __L3_FWD_H__ +#include + #define DO_RFC_1812_CHECKS #define RTE_LOGTYPE_L3FWD RTE_LOGTYPE_USER1 @@ -103,7 +105,7 @@ extern uint32_t enabled_port_mask; extern int ipv6; /**< ipv6 is false by default. */ extern uint32_t hash_entry_number; -extern __m128i val_eth[RTE_MAX_ETHPORTS]; +extern xmm_t val_eth[RTE_MAX_ETHPORTS]; extern struct lcore_conf lcore_conf[RTE_MAX_LCORE]; diff --git a/examples/l3fwd/l3fwd_em.c b/examples/l3fwd/l3fwd_em.c index f6a65d8..0adf8f4 100644 --- a/examples/l3fwd/l3fwd_em.c +++ b/examples/l3fwd/l3fwd_em.c @@ -85,7 +85,7 @@ union ipv4_5tuple_host { uint16_t port_src; uint16_t port_dst; }; - __m128i xmm; + xmm_t xmm; }; #define XMM_NUM_IN_IPV6_5TUPLE 3 @@ -109,9 +109,11 @@ union ipv6_5tuple_host { uint16_t port_dst; uint64_t reserve; }; - __m128i xmm[XMM_NUM_IN_IPV6_5TUPLE]; + xmm_t xmm[XMM_NUM_IN_IPV6_5TUPLE]; }; + + struct ipv4_l3fwd_em_route { struct ipv4_5tuple key; uint8_t if_out; @@ -236,9 +238,27 @@ ipv6_hash_crc(const void *data, __rte_unused uint32_t data_len, static uint8_t ipv4_l3fwd_out_if[L3FWD_HASH_ENTRIES] __rte_cache_aligned; static uint8_t ipv6_l3fwd_out_if[L3FWD_HASH_ENTRIES] __rte_cache_aligned; -static __m128i mask0; -static __m128i mask1; -static __m128i mask2; +static rte_xmm_t mask0; +static rte_xmm_t mask1; +static rte_xmm_t mask2; + +#if defined(__SSE2__) +static inline xmm_t +em_mask_key(void *key, xmm_t mask) +{ + __m128i data = _mm_loadu_si128((__m128i *)(key)); + + return _mm_and_si128(data, mask); +} +#elif defined(__ARM_NEON) +static inline xmm_t +em_mask_key(void *key, xmm_t mask) +{ + int32x4_t data = vld1q_s32((int32_t *)key); + + return vandq_s32(data, mask); +} +#endif static inline uint8_t em_get_ipv4_dst_port(void *ipv4_hdr, uint8_t portid, void *lookup_struct) @@ -249,13 +269,12 @@ em_get_ipv4_dst_port(void *ipv4_hdr, uint8_t portid, void *lookup_struct) (struct rte_hash *)lookup_struct; ipv4_hdr = (uint8_t *)ipv4_hdr + offsetof(struct ipv4_hdr, time_to_live); - __m128i data = _mm_loadu_si128((__m128i *)(ipv4_hdr)); /* * Get 5 tuple: dst port, src port, dst IP address, * src IP address and protocol. */ - key.xmm = _mm_and_si128(data, mask0); + key.xmm = em_mask_key(ipv4_hdr, mask0.x); /* Find destination port */ ret = rte_hash_lookup(ipv4_l3fwd_lookup_struct, (const void *)&key); @@ -271,35 +290,31 @@ em_get_ipv6_dst_port(void *ipv6_hdr, uint8_t portid, void *lookup_struct) (struct rte_hash *)lookup_struct; ipv6_hdr = (uint8_t *)ipv6_hdr + offsetof(struct ipv6_hdr, payload_len); - __m128i data0 = - _mm_loadu_si128((__m128i *)(ipv6_hdr)); - __m128i data1 = - _mm_loadu_si128((__m128i *)(((uint8_t *)ipv6_hdr)+ - sizeof(__m128i))); - __m128i data2 = - _mm_loadu_si128((__m128i *)(((uint8_t *)ipv6_hdr)+ - sizeof(__m128i)+sizeof(__m128i))); + void *data0 = ipv6_hdr; + void *data1 = ((uint8_t *)ipv6_hdr) + sizeof(xmm_t); + void *data2 = ((uint8_t *)ipv6_hdr) + sizeof(xmm_t) + sizeof(xmm_t); /* Get part of 5 tuple: src IP address lower 96 bits and protocol */ - key.xmm[0] = _mm_and_si128(data0, mask1); + key.xmm[0] = em_mask_key(data0, mask1.x); /* * Get part of 5 tuple: dst IP address lower 96 bits * and src IP address higher 32 bits. */ - key.xmm[1] = data1; + key.xmm[1] = *(xmm_t *)data1; /* * Get part of 5 tuple: dst port and src port * and dst IP address higher 32 bits. */ - key.xmm[2] = _mm_and_si128(data2, mask2); + key.xmm[2] = em_mask_key(data2, mask2.x); /* Find destination port */ ret = rte_hash_lookup(ipv6_l3fwd_lookup_struct, (const void *)&key); return (uint8_t)((ret < 0) ? portid : ipv6_l3fwd_out_if[ret]); } + /* * Include header file if SSE4_1 is enabled for * buffer optimization i.e. ENABLE_MULTI_BUFFER_OPTIMIZE=1. @@ -348,14 +363,15 @@ convert_ipv6_5tuple(struct ipv6_5tuple *key1, #define BYTE_VALUE_MAX 256 #define ALL_32_BITS 0xffffffff #define BIT_8_TO_15 0x0000ff00 + static inline void populate_ipv4_few_flow_into_table(const struct rte_hash *h) { uint32_t i; int32_t ret; - mask0 = _mm_set_epi32(ALL_32_BITS, ALL_32_BITS, - ALL_32_BITS, BIT_8_TO_15); + mask0 = (rte_xmm_t){.u32 = {BIT_8_TO_15, ALL_32_BITS, + ALL_32_BITS, ALL_32_BITS} }; for (i = 0; i < IPV4_L3FWD_EM_NUM_ROUTES; i++) { struct ipv4_l3fwd_em_route entry; @@ -381,10 +397,10 @@ populate_ipv6_few_flow_into_table(const struct rte_hash *h) uint32_t i; int32_t ret; - mask1 = _mm_set_epi32(ALL_32_BITS, ALL_32_BITS, - ALL_32_BITS, BIT_16_TO_23); + mask1 = (rte_xmm_t){.u32 = {BIT_16_TO_23, ALL_32_BITS, + ALL_32_BITS, ALL_32_BITS} }; - mask2 = _mm_set_epi32(0, 0, ALL_32_BITS, ALL_32_BITS); + mask2 = (rte_xmm_t){.u32 = {ALL_32_BITS, ALL_32_BITS, 0, 0} }; for (i = 0; i < IPV6_L3FWD_EM_NUM_ROUTES; i++) { struct ipv6_l3fwd_em_route entry; @@ -410,8 +426,8 @@ populate_ipv4_many_flow_into_table(const struct rte_hash *h, { unsigned i; - mask0 = _mm_set_epi32(ALL_32_BITS, ALL_32_BITS, - ALL_32_BITS, BIT_8_TO_15); + mask0 = (rte_xmm_t){.u32 = {BIT_8_TO_15, ALL_32_BITS, + ALL_32_BITS, ALL_32_BITS} }; for (i = 0; i < nr_flow; i++) { struct ipv4_l3fwd_em_route entry; @@ -462,9 +478,9 @@ populate_ipv6_many_flow_into_table(const struct rte_hash *h, { unsigned i; - mask1 = _mm_set_epi32(ALL_32_BITS, ALL_32_BITS, - ALL_32_BITS, BIT_16_TO_23); - mask2 = _mm_set_epi32(0, 0, ALL_32_BITS, ALL_32_BITS); + mask1 = (rte_xmm_t){.u32 = {BIT_16_TO_23, ALL_32_BITS, + ALL_32_BITS, ALL_32_BITS} }; + mask2 = (rte_xmm_t){.u32 = {ALL_32_BITS, ALL_32_BITS, 0, 0} }; for (i = 0; i < nr_flow; i++) { struct ipv6_l3fwd_em_route entry; diff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c index 0e33039..8520f71 100644 --- a/examples/l3fwd/main.c +++ b/examples/l3fwd/main.c @@ -112,7 +112,7 @@ volatile bool force_quit; uint64_t dest_eth_addr[RTE_MAX_ETHPORTS]; struct ether_addr ports_eth_addr[RTE_MAX_ETHPORTS]; -__m128i val_eth[RTE_MAX_ETHPORTS]; +xmm_t val_eth[RTE_MAX_ETHPORTS]; /* mask of enabled ports */ uint32_t enabled_port_mask; -- 1.9.1