From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-eopbgr20064.outbound.protection.outlook.com [40.107.2.64]) by dpdk.org (Postfix) with ESMTP id 0E6162AA0 for ; Fri, 7 Sep 2018 11:18:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector1-arm-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nycGSv12Jn4yujecPjy9dyuCvo9PhXZkZepihhlWLoI=; b=TxqWEXFZdGHoGBVKAde++GOFNH+FxgRWh4TUh/2Qy1q5NixlgWfv5wrsOu1odOp2UctIy4EiK6Ej/zjDzG1pYwKFv32dFe6gF0f+He+Don+3E7NoGZzKVNLcuwKu/jVadoTkdT7ryZ21N2j1TW25PnaN8gjkVvShYe2HZ/zKPek= Received: from VI1PR08MB3167.eurprd08.prod.outlook.com (52.133.15.142) by VI1PR08MB3662.eurprd08.prod.outlook.com (20.177.61.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1101.17; Fri, 7 Sep 2018 09:18:18 +0000 Received: from VI1PR08MB3167.eurprd08.prod.outlook.com ([fe80::b91d:e285:4647:f3e8]) by VI1PR08MB3167.eurprd08.prod.outlook.com ([fe80::b91d:e285:4647:f3e8%2]) with mapi id 15.20.1101.019; Fri, 7 Sep 2018 09:18:18 +0000 From: "Gavin Hu (Arm Technology China)" To: Kevin Laatz , "dev@dpdk.org" CC: "cristian.dumitrescu@intel.com" , Jianbo Liu , "jerin.jacob@caviumnetworks.com" Thread-Topic: [PATCH v2 1/3] lib/librte_table: add hash_func header files Thread-Index: AQHURoF+oPZy1KFJtkGL3bsbszmUBKTkiBJg Date: Fri, 7 Sep 2018 09:18:18 +0000 Message-ID: References: <20180907080510.87617-1-kevin.laatz@intel.com> In-Reply-To: <20180907080510.87617-1-kevin.laatz@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Gavin.Hu@arm.com; x-originating-ip: [113.29.88.7] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VI1PR08MB3662; 6:1hJkR9gUlUTCA8/cDHxm3R0QJoZkM1C3218YfsjXZtAJkD3iDuN3Z8Eb5K9dPAPWIecgTKZ9BEUXrKjhwJfrKhGWdwakzHK8hM/Uywaifa/NJKYRyVEe5olISAzMV1cBfaGsfDa89Nh5j6TSqicnpgKhJ8K4xWYQqTmehC67+U2DEcYXW6vd9VumciIuISijRhpBzTPZ6Uzb/s8T/MPM6yrJ8zvbDSO7olILZrEsazmdIac3INgEwJY8l7Jg2TAVMEUL5DEyfbzREMDuwGpcBAa2ylKp87tQONhBYlZtAfsdt5SwC0hYfBfswvCgUepcIkCZEoFkbzsnN0ZsGZTubEbt93iYqbVl7rxm8UyTmQGEnRRxxOKAU4v2RbqZrZGtn/bsHkZhtW4hM7kkbD8Bb6E+PvhCvMdve/+CAVWhp1YcqxIb/36cGAejN8YOan2QDkkd9XBE2UhH1TyWH+aEPQ==; 5:KX5HuZ36x1ZSsmMTniNFrI25YFGgsCawAthlJxHSn9DVllMn9Wf0bU+hBNK+WF7BKu7Nfc2hfZuSvzwbpvXVdl+xUlJb7UVcqBXpVCk2fQlAAAUMvFN/0wJA6MhIO39l8EBOJ+9nzPy3oBoqpwOUyGU++iq9/AKn7VlUqb7ewrA=; 7:TdRW5l1d62X7cV4pGvzAm9f8xKVmnmmIND94q5iCuflaPXD1qQSRRgm8XUAC1C81UTN6IswyfcnncpZpFnVsgtPCfRqFgNhZJInG7+KGivAKcJXNSydE9aiz1kDuznjJpC05IueRpb4rx9xoGfxlTMKmQPyYdUlyDZ6VQadZkR0uNAflu+ep6nOyXhca4qLrs5SR/By7D90XB2QfqSsGAYEcZkwc/mwMCXpxjWal+XyN+izZJONzePSuR4PkiFII x-ms-exchange-antispam-srfa-diagnostics: SOS;SOR; x-ms-office365-filtering-correlation-id: 8da9860a-3f42-424f-3db3-08d614a2d95c x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:VI1PR08MB3662; x-ms-traffictypediagnostic: VI1PR08MB3662: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(180628864354917)(103651359005742)(788757137089)(228905959029699); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(10201501046)(3231311)(944501410)(52105095)(3002001)(93006095)(93001095)(6055026)(149027)(150027)(6041310)(20161123564045)(20161123560045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(201708071742011)(7699050); SRVR:VI1PR08MB3662; BCL:0; PCL:0; RULEID:; SRVR:VI1PR08MB3662; x-forefront-prvs: 07880C4932 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(346002)(366004)(136003)(39860400002)(396003)(376002)(189003)(199004)(40434004)(13464003)(68736007)(54906003)(14454004)(110136005)(81156014)(81166006)(6436002)(316002)(8676002)(25786009)(8936002)(53936002)(14444005)(2906002)(478600001)(6246003)(186003)(5660300001)(33656002)(5024004)(6506007)(7736002)(7696005)(102836004)(76176011)(4326008)(229853002)(105586002)(256004)(11346002)(53546011)(74316002)(86362001)(2900100001)(66066001)(446003)(6116002)(97736004)(9686003)(72206003)(26005)(55016002)(3846002)(5250100002)(486006)(99286004)(2501003)(106356001)(476003)(305945005); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR08MB3662; H:VI1PR08MB3167.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: HlJEQ8az8Uud/LU4safeWfNirw5aYPIOcxx8nhts2tEJT2TvLdl2msibuEefs6zGy6Ssgg+HaSuztY8ZlyWwyAgOuEg5zYkKaGra0h/rr+7CDsL5E7c1PpQvE4RvsrMmdfe/PLJkLhunbtzMk8303capCOy2RhmEUw0YZkf9wd2ynuvzgGRbC3HaY8n/V4VHwzP45Ze2+zq+ruEHFUmuL1ePiGfwEmvCht00cPhJckDA+2zTvgUcCt4c5pIJG1bKkGgTpmVpFlLIXgq4kJAp7ggY8M28joYqrRsJePWcrSg2bjiu7DH55KakxSRtJ5XeMA3u5UGSDISHqDymTRv8dqafzCYuVMsCrXjYReQdh1k= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8da9860a-3f42-424f-3db3-08d614a2d95c X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Sep 2018 09:18:18.2056 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB3662 Subject: Re: [dpdk-dev] [PATCH v2 1/3] lib/librte_table: add hash_func header files 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, 07 Sep 2018 09:18:21 -0000 The code looks good, some comments to the commit message. > -----Original Message----- > From: Kevin Laatz > Sent: Friday, September 7, 2018 4:05 PM > To: dev@dpdk.org > Cc: cristian.dumitrescu@intel.com; Jianbo Liu ; Gavin > Hu (Arm Technology China) ; > jerin.jacob@caviumnetworks.com; Kevin Laatz > Subject: [PATCH v2 1/3] lib/librte_table: add hash_func header files > > This commit adds rte_table_hash_func.h and rte_table_hash_func_arm64.h > to librte_table. This will replace hash_func.h and hash_func_arm64.h in t= he > IP Pipeline application and in SoftNIC. This also adds a scalar implement= ation > of the x86_64 intrinsic for crc32 as a generic fallback. It is better to mention this patch reduces code duplication by removing dup= licate headers files Within two folders and consolidating them into a single one. > > Signed-off-by: Cristian Dumitrescu > Signed-off-by: Kevin Laatz Acked-by: Gavin Hu > --- > v2: > - Fixed typo in commit message > - Fixed typo in arm header that caused some compilations to fail for t= he > entire patchset > --- > lib/librte_table/Makefile | 2 + > lib/librte_table/meson.build | 2 + > lib/librte_table/rte_table_hash_func.h | 244 > +++++++++++++++++++++++++++ > lib/librte_table/rte_table_hash_func_arm64.h | 21 +++ > lib/librte_table/rte_table_version.map | 14 ++ > 5 files changed, 283 insertions(+) > create mode 100644 lib/librte_table/rte_table_hash_func.h > create mode 100644 lib/librte_table/rte_table_hash_func_arm64.h > > diff --git a/lib/librte_table/Makefile b/lib/librte_table/Makefile index > 276d476..f935678 100644 > --- a/lib/librte_table/Makefile > +++ b/lib/librte_table/Makefile > @@ -46,6 +46,8 @@ SYMLINK-$(CONFIG_RTE_LIBRTE_TABLE)-include +=3D > rte_table_acl.h endif SYMLINK-$(CONFIG_RTE_LIBRTE_TABLE)-include +=3D > rte_table_hash.h SYMLINK-$(CONFIG_RTE_LIBRTE_TABLE)-include +=3D > rte_table_hash_cuckoo.h > +SYMLINK-$(CONFIG_RTE_LIBRTE_TABLE)-include +=3D rte_table_hash_func.h > +SYMLINK-$(CONFIG_RTE_LIBRTE_TABLE)-include +=3D > +rte_table_hash_func_arm64.h > SYMLINK-$(CONFIG_RTE_LIBRTE_TABLE)-include +=3D rte_lru.h ifeq > ($(CONFIG_RTE_ARCH_X86),y) SYMLINK-$(CONFIG_RTE_LIBRTE_TABLE)- > include +=3D rte_lru_x86.h diff --git a/lib/librte_table/meson.build > b/lib/librte_table/meson.build index 8b2f841..6ae3cd6 100644 > --- a/lib/librte_table/meson.build > +++ b/lib/librte_table/meson.build > @@ -19,6 +19,8 @@ headers =3D files('rte_table.h', > 'rte_table_lpm_ipv6.h', > 'rte_table_hash.h', > 'rte_table_hash_cuckoo.h', > +'rte_table_hash_func.h', > +'rte_table_hash_func_arm64.h', > 'rte_lru.h', > 'rte_table_array.h', > 'rte_table_stub.h') > diff --git a/lib/librte_table/rte_table_hash_func.h > b/lib/librte_table/rte_table_hash_func.h > new file mode 100644 > index 0000000..4eadbfb > --- /dev/null > +++ b/lib/librte_table/rte_table_hash_func.h > @@ -0,0 +1,244 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright(c) 2010-2018 Intel Corporation */ > + > +#ifndef __INCLUDE_RTE_TABLE_HASH_FUNC_H__ #define > +__INCLUDE_RTE_TABLE_HASH_FUNC_H__ > + > +#ifdef __cplusplus > +extern "C" { > +#endif > + > +#include > + > +#include > + > +static inline uint64_t > +rte_crc32_u64_generic(uint64_t crc, uint64_t value) { > +int i; > + > +crc =3D (crc & 0xFFFFFFFFLLU) ^ value; > +for (i =3D 63; i >=3D 0; i--) { > +uint64_t mask; > + > +mask =3D -(crc & 1LLU); > +crc =3D (crc >> 1LLU) ^ (0x82F63B78LLU & mask); > +} > + > +return crc; > +} > + > +#if defined(RTE_ARCH_X86_64) > + > +#include > + > +static inline uint64_t > +rte_crc32_u64(uint64_t crc, uint64_t v) { > +return _mm_crc32_u64(crc, v); > +} > + > +#elif defined(RTE_ARCH_ARM64) > +#include "rte_table_hash_func_arm64.h" > +#else > + > +static inline uin64_t > +rte_crc32_u64(uint64_t crc, uint64_t v) { > +return rte_crc32_u64_generic(crc, v); > +} > + > +#endif > + > +static inline uint64_t > +rte_table_hash_crc_key8(void *key, void *mask, __rte_unused uint32_t > key_size, > +uint64_t seed) > +{ > +uint64_t *k =3D key; > +uint64_t *m =3D mask; > +uint64_t crc0; > + > +crc0 =3D rte_crc32_u64(seed, k[0] & m[0]); > + > +return crc0; > +} > + > +static inline uint64_t > +rte_table_hash_crc_key16(void *key, void *mask, __rte_unused uint32_t > key_size, > +uint64_t seed) > +{ > +uint64_t *k =3D key; > +uint64_t *m =3D mask; > +uint64_t k0, crc0, crc1; > + > +k0 =3D k[0] & m[0]; > + > +crc0 =3D rte_crc32_u64(k0, seed); > +crc1 =3D rte_crc32_u64(k0 >> 32, k[1] & m[1]); > + > +crc0 ^=3D crc1; > + > +return crc0; > +} > + > +static inline uint64_t > +rte_table_hash_crc_key24(void *key, void *mask, __rte_unused uint32_t > key_size, > +uint64_t seed) > +{ > +uint64_t *k =3D key; > +uint64_t *m =3D mask; > +uint64_t k0, k2, crc0, crc1; > + > +k0 =3D k[0] & m[0]; > +k2 =3D k[2] & m[2]; > + > +crc0 =3D rte_crc32_u64(k0, seed); > +crc1 =3D rte_crc32_u64(k0 >> 32, k[1] & m[1]); > + > +crc0 =3D rte_crc32_u64(crc0, k2); > + > +crc0 ^=3D crc1; > + > +return crc0; > +} > + > +static inline uint64_t > +rte_table_hash_crc_key32(void *key, void *mask, __rte_unused uint32_t > key_size, > +uint64_t seed) > +{ > +uint64_t *k =3D key; > +uint64_t *m =3D mask; > +uint64_t k0, k2, crc0, crc1, crc2, crc3; > + > +k0 =3D k[0] & m[0]; > +k2 =3D k[2] & m[2]; > + > +crc0 =3D rte_crc32_u64(k0, seed); > +crc1 =3D rte_crc32_u64(k0 >> 32, k[1] & m[1]); > + > +crc2 =3D rte_crc32_u64(k2, k[3] & m[3]); > +crc3 =3D k2 >> 32; > + > +crc0 =3D rte_crc32_u64(crc0, crc1); > +crc1 =3D rte_crc32_u64(crc2, crc3); > + > +crc0 ^=3D crc1; > + > +return crc0; > +} > + > +static inline uint64_t > +rte_table_hash_crc_key40(void *key, void *mask, __rte_unused uint32_t > key_size, > +uint64_t seed) > +{ > +uint64_t *k =3D key; > +uint64_t *m =3D mask; > +uint64_t k0, k2, crc0, crc1, crc2, crc3; > + > +k0 =3D k[0] & m[0]; > +k2 =3D k[2] & m[2]; > + > +crc0 =3D rte_crc32_u64(k0, seed); > +crc1 =3D rte_crc32_u64(k0 >> 32, k[1] & m[1]); > + > +crc2 =3D rte_crc32_u64(k2, k[3] & m[3]); > +crc3 =3D rte_crc32_u64(k2 >> 32, k[4] & m[4]); > + > +crc0 =3D rte_crc32_u64(crc0, crc1); > +crc1 =3D rte_crc32_u64(crc2, crc3); > + > +crc0 ^=3D crc1; > + > +return crc0; > +} > + > +static inline uint64_t > +rte_table_hash_crc_key48(void *key, void *mask, __rte_unused uint32_t > key_size, > +uint64_t seed) > +{ > +uint64_t *k =3D key; > +uint64_t *m =3D mask; > +uint64_t k0, k2, k5, crc0, crc1, crc2, crc3; > + > +k0 =3D k[0] & m[0]; > +k2 =3D k[2] & m[2]; > +k5 =3D k[5] & m[5]; > + > +crc0 =3D rte_crc32_u64(k0, seed); > +crc1 =3D rte_crc32_u64(k0 >> 32, k[1] & m[1]); > + > +crc2 =3D rte_crc32_u64(k2, k[3] & m[3]); > +crc3 =3D rte_crc32_u64(k2 >> 32, k[4] & m[4]); > + > +crc0 =3D rte_crc32_u64(crc0, (crc1 << 32) ^ crc2); > +crc1 =3D rte_crc32_u64(crc3, k5); > + > +crc0 ^=3D crc1; > + > +return crc0; > +} > + > +static inline uint64_t > +rte_table_hash_crc_key56(void *key, void *mask, __rte_unused uint32_t > key_size, > +uint64_t seed) > +{ > +uint64_t *k =3D key; > +uint64_t *m =3D mask; > +uint64_t k0, k2, k5, crc0, crc1, crc2, crc3, crc4, crc5; > + > +k0 =3D k[0] & m[0]; > +k2 =3D k[2] & m[2]; > +k5 =3D k[5] & m[5]; > + > +crc0 =3D rte_crc32_u64(k0, seed); > +crc1 =3D rte_crc32_u64(k0 >> 32, k[1] & m[1]); > + > +crc2 =3D rte_crc32_u64(k2, k[3] & m[3]); > +crc3 =3D rte_crc32_u64(k2 >> 32, k[4] & m[4]); > + > +crc4 =3D rte_crc32_u64(k5, k[6] & m[6]); > +crc5 =3D k5 >> 32; > + > +crc0 =3D rte_crc32_u64(crc0, (crc1 << 32) ^ crc2); > +crc1 =3D rte_crc32_u64(crc3, (crc4 << 32) ^ crc5); > + > +crc0 ^=3D crc1; > + > +return crc0; > +} > + > +static inline uint64_t > +rte_table_hash_crc_key64(void *key, void *mask, __rte_unused uint32_t > key_size, > +uint64_t seed) > +{ > +uint64_t *k =3D key; > +uint64_t *m =3D mask; > +uint64_t k0, k2, k5, crc0, crc1, crc2, crc3, crc4, crc5; > + > +k0 =3D k[0] & m[0]; > +k2 =3D k[2] & m[2]; > +k5 =3D k[5] & m[5]; > + > +crc0 =3D rte_crc32_u64(k0, seed); > +crc1 =3D rte_crc32_u64(k0 >> 32, k[1] & m[1]); > + > +crc2 =3D rte_crc32_u64(k2, k[3] & m[3]); > +crc3 =3D rte_crc32_u64(k2 >> 32, k[4] & m[4]); > + > +crc4 =3D rte_crc32_u64(k5, k[6] & m[6]); > +crc5 =3D rte_crc32_u64(k5 >> 32, k[7] & m[7]); > + > +crc0 =3D rte_crc32_u64(crc0, (crc1 << 32) ^ crc2); > +crc1 =3D rte_crc32_u64(crc3, (crc4 << 32) ^ crc5); > + > +crc0 ^=3D crc1; > + > +return crc0; > +} > + > +#ifdef __cplusplus > +} > +#endif > + > +#endif > diff --git a/lib/librte_table/rte_table_hash_func_arm64.h > b/lib/librte_table/rte_table_hash_func_arm64.h > new file mode 100644 > index 0000000..eb04c1f > --- /dev/null > +++ b/lib/librte_table/rte_table_hash_func_arm64.h > @@ -0,0 +1,21 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright(c) 2017-2018 Linaro Limited */ > + > +#ifndef __INCLUDE_RTE_TABLE_HASH_FUNC_ARM64_H__ > +#define __INCLUDE_RTE_TABLE_HASH_FUNC_ARM64_H__ > + > +#define _CRC32CX(crc, val)\ > +__asm__("crc32cx %w[c], %w[c], %x[v]":[c] "+r" (crc):[v] "r" (val)) > + > +static inline uint64_t > +rte_crc32_u64(uint64_t crc, uint64_t v) { > +uint32_t crc32 =3D crc; > + > +_CRC32CX(crc32, v); > + > +return crc32; > +} > + > +#endif > diff --git a/lib/librte_table/rte_table_version.map > b/lib/librte_table/rte_table_version.map > index 6237252..dab339e 100644 > --- a/lib/librte_table/rte_table_version.map > +++ b/lib/librte_table/rte_table_version.map > @@ -18,3 +18,17 @@ DPDK_17.11 { > > local: *; > }; > + > +DPDK_18.11 { > +global: > + > +rte_crc32_u64_generic; > +rte_table_hash_crc_key8; > +rte_table_hash_crc_key16; > +rte_table_hash_crc_key24; > +rte_table_hash_crc_key32; > +rte_table_hash_crc_key40; > +rte_table_hash_crc_key48; > +rte_table_hash_crc_key56; > +rte_table_hash_crc_key64; > +} DPDK_17.11; > -- > 2.9.5 IMPORTANT NOTICE: The contents of this email and any attachments are confid= ential and may also be privileged. If you are not the intended recipient, p= lease notify the sender immediately and do not disclose the contents to any= other person, use it for any purpose, or store or copy the information in = any medium. Thank you.