From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by inbox.dpdk.org (Postfix) with ESMTP id B15A1A034F;
	Wed, 13 May 2020 15:22:44 +0200 (CEST)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id 0527B1D5AC;
	Wed, 13 May 2020 15:22:44 +0200 (CEST)
Received: from mga04.intel.com (mga04.intel.com [192.55.52.120])
 by dpdk.org (Postfix) with ESMTP id AD8E31D5A3
 for <dev@dpdk.org>; Wed, 13 May 2020 15:22:41 +0200 (CEST)
IronPort-SDR: phVOM4KbxKAgv3aSMxIts66a2pfxitV95pqvPY5OwEoXp8akyA0HYJA3DB0I5oJ+9ZidCHsRKP
 YPT9dtU1W4QA==
X-Amp-Result: SKIPPED(no attachment in message)
X-Amp-File-Uploaded: False
Received: from orsmga006.jf.intel.com ([10.7.209.51])
 by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 13 May 2020 06:22:40 -0700
IronPort-SDR: eXHecFNjIicGSeSP+iAjfLCX8wQV02lpDf9WRNSZMb12eQnHHi1J4fXAXZVwSZxDFr5ofGxh49
 ijAyCHNZq2RA==
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.73,387,1583222400"; d="scan'208";a="265870971"
Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206])
 by orsmga006.jf.intel.com with ESMTP; 13 May 2020 06:22:40 -0700
Received: from fmsmsx603.amr.corp.intel.com (10.18.126.83) by
 FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS)
 id 14.3.439.0; Wed, 13 May 2020 06:22:40 -0700
Received: from fmsmsx605.amr.corp.intel.com (10.18.126.85) by
 fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server
 (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id
 15.1.1713.5; Wed, 13 May 2020 06:22:39 -0700
Received: from FMSEDG001.ED.cps.intel.com (10.1.192.133) by
 fmsmsx605.amr.corp.intel.com (10.18.126.85) with Microsoft SMTP Server
 (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5
 via Frontend Transport; Wed, 13 May 2020 06:22:39 -0700
Received: from NAM02-CY1-obe.outbound.protection.outlook.com (104.47.37.55) by
 edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server
 (TLS) id 14.3.439.0; Wed, 13 May 2020 06:22:39 -0700
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
 b=cY/V/gxMFQJ9qw0o3qoWyqalpuRMTK7DJGzs+hfVCOrTDHRr3oJackdmGCsIOHvm2Upyc+qztUWV8Ry9QH8KUQN2usN376kjIbv06wPKjkLumB1ZzSzfUmG5/oRDsUPrF4Fr3BMJ+YlcmHKfeXv8sQHWhmgZco+ngA3XemxEQW6QhLL1WVuRnqd2NFDy5Wpv6w3qfIIJWoo4EWstowF+8gen200s3VEzOMXQ7ou7nT42E+NgFxVfCenzP1nzw+yN1fSBAxU4V/CLEUnhIk/ONLdIfH8okSQS8sr/H5GCNVPZiP7eXhyb/+Fb6yjve1hS7MP3x9HO2cgErGiVDGLn/w==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; 
 s=arcselector9901;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=y5gynHtlZfbzBPvGs+1wRPVaYRpLCPOKVkKXAQ31FH8=;
 b=BWo8MYj4XTUFZc8vbdtQxI+kuEzcqKfgToC79ct04prECI+EhhbgHLZK1j6grpsZ8lhSE+sTg6xhqddh5W3CVgzkShTwuvosNENlE42M2ce4xYIVOQHXN8ZvPdk51SGc48e9O9jeA923eYTpiScR+uvCpmj5hDPNyYIjAM757VP7RRPUJVzfPLsbjCMe2GLuEkayW52PSX+zAUpw4bba6r7ySGmNIu1n1RXZbRWn6qDyARyvGGPMmNa2YTnPuRcTUwMZgnKpG0kWFX/nHt7EpvJeHEnX0FjQ61ZTcPoj0dLndADIGvMiaRIOfkPovpnSYBuAQyfaL63NJYmjVpiSfQ==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass
 smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com;
 dkim=pass header.d=intel.com; arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; 
 s=selector2-intel-onmicrosoft-com;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=y5gynHtlZfbzBPvGs+1wRPVaYRpLCPOKVkKXAQ31FH8=;
 b=sJN/li/8LLAUCCZuh7iROYvaINqiNBZUKx5ol4Yn/0j38w4VIBAVuZ+mLLZXDfMK+OiAq92r5HW29lL2/E20xQYHfci46C11WkrYls+snHV02gDWZHwybsb1OAmn1mkfMW3u+lTfZIMuwH+y1EQHCoYdpyXvZDKyS5keAIDl664=
Received: from BYAPR11MB3301.namprd11.prod.outlook.com (2603:10b6:a03:7f::26)
 by BYAPR11MB3638.namprd11.prod.outlook.com (2603:10b6:a03:f8::24)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.34; Wed, 13 May
 2020 13:22:37 +0000
Received: from BYAPR11MB3301.namprd11.prod.outlook.com
 ([fe80::f8cb:58cd:e958:fff4]) by BYAPR11MB3301.namprd11.prod.outlook.com
 ([fe80::f8cb:58cd:e958:fff4%6]) with mapi id 15.20.2979.033; Wed, 13 May 2020
 13:22:37 +0000
From: "Ananyev, Konstantin" <konstantin.ananyev@intel.com>
To: Ruifeng Wang <Ruifeng.Wang@arm.com>, "pbhagavatula@marvell.com"
 <pbhagavatula@marvell.com>, "jerinj@marvell.com" <jerinj@marvell.com>, "Van
 Haaren, Harry" <harry.van.haaren@intel.com>, "Wang, Yipeng1"
 <yipeng1.wang@intel.com>, "Gobriel, Sameh" <sameh.gobriel@intel.com>,
 "Richardson, Bruce" <bruce.richardson@intel.com>
CC: "dev@dpdk.org" <dev@dpdk.org>, nd <nd@arm.com>
Thread-Topic: [dpdk-dev] [RFC v2] hash: unify crc32 API header for x86 and ARM
Thread-Index: AQHWKJ2/VNx4P2jQZUiXEsj59oKprqilVUUAgACsirA=
Date: Wed, 13 May 2020 13:22:37 +0000
Message-ID: <BYAPR11MB33017FE33A91A52C6E1E7BAC9ABF0@BYAPR11MB3301.namprd11.prod.outlook.com>
References: <20200429180515.5704-1-pbhagavatula@marvell.com>
 <20200512204015.1963-1-pbhagavatula@marvell.com>
 <HE1PR0801MB202562AEEC896C0845A7A7039EBF0@HE1PR0801MB2025.eurprd08.prod.outlook.com>
In-Reply-To: <HE1PR0801MB202562AEEC896C0845A7A7039EBF0@HE1PR0801MB2025.eurprd08.prod.outlook.com>
Accept-Language: en-GB, en-US
Content-Language: en-US
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
dlp-product: dlpe-windows
dlp-reaction: no-action
dlp-version: 11.2.0.6
authentication-results: arm.com; dkim=none (message not signed)
 header.d=none;arm.com; dmarc=none action=none header.from=intel.com;
x-originating-ip: [192.198.151.162]
x-ms-publictraffictype: Email
x-ms-office365-filtering-correlation-id: 5ab33e56-8310-4a08-bd64-08d7f740b4ad
x-ms-traffictypediagnostic: BYAPR11MB3638:
x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr
x-ms-exchange-transport-forked: True
x-microsoft-antispam-prvs: <BYAPR11MB3638895A42CB31564ABA409B9ABF0@BYAPR11MB3638.namprd11.prod.outlook.com>
x-ms-oob-tlc-oobclassifiers: OLM:2276;
x-forefront-prvs: 0402872DA1
x-ms-exchange-senderadcheck: 1
x-microsoft-antispam: BCL:0;
x-microsoft-antispam-message-info: 7/+SHr4z71NNB6i5As5oKCfrpa0BlXnyFF2iOclQ1YlwT9pGrsVdqvXHZv8R94AXKBfg4SgfG+AnkIt3lEnRUl8qHqXo5UxZOEw+soNdRWapueoESImwAO6oKm4vAcxudINIChvtNcV05MmhfygJnXHm4E3YS75XGc++T2cc+coOm+8ebYf/pKyr0Rc6JJhxNvfAaI5frxTzNqX6baUz9jAV9hbyiePeLSvgiz3ogLTbOh2sHQLrn/y6pAAhAUSH39t4P9XsUjNYA5U6PF7JBgGNdDm0BYnUXjP2EE3X1usLizKArtq5BKKoCTwL3/86AtyKxBbZgHUxVPqmcuGjktAVNBZMWpWFFX1IhsI4gdfXF+zQ5XLQohB6kGJcUW+plaMRd3iz/0gE44gsShgiyxwUW8i7njmaAlo0nmsSYB/3eNHzRGUYkRaKXamTdvC8xBqk23mBBosl6XwvQx4RdIVrMFnziVJIubARAo4TAUB2+YsOnIE7AbO84cCr2vGUyX2X89OG56NMtvdmy8VObJMYY+Ku33JNDSO2osvnuJo=
x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:;
 IPV:NLI; SFV:NSPM; H:BYAPR11MB3301.namprd11.prod.outlook.com; PTR:; CAT:NONE;
 SFTY:;
 SFS:(396003)(136003)(39860400002)(366004)(376002)(346002)(33430700001)(2906002)(30864003)(186003)(4326008)(54906003)(110136005)(26005)(33440700001)(478600001)(5660300002)(33656002)(66946007)(8936002)(66556008)(64756008)(86362001)(55016002)(66476007)(53546011)(9686003)(66446008)(316002)(6636002)(76116006)(71200400001)(52536014)(7696005)(8676002)(6506007)(921003);
 DIR:OUT; SFP:1102; 
x-ms-exchange-antispam-messagedata: do9G2IGdcly7qOnsi1Nta63BphIqZ0S4x639RmoQzCpOK050/Sl124T6Z3RZDfZ2v4Odd/8pYkl6PsZASGfsDzvE6CHr8QIcfwOt3lnKRugjdLcovyyHG3UI3SF7Evl1p3sMVW3XUSIvWsTITg3HEEeNbQ3uGGQ/rz6N/kNVZEEnVCrf6eNCfv2cnsHLDKdG0XnsW1Ad2V/kFQLZdQcTLQnrERzHZrT8bbBh1ghme2Fy35E3fX3+9EkO9NCHk45bPBincTdOO1mDOE4bMcvJqgUEovNgGQDuV19NqHQSSGyqQt0RsEfJurx6uikrfgSfdrnSJEGvdc7kHWeisxludEqS+89TJOI1E8DXPDBKcx0MejObef+jt9WgN4MGtvtdICZXtmsbVh9aL1KNwJ8OfvGkX/yZpekOSw07WrnDPdsiFidj2ipJDti9hz2nRrkbfQtp6qvtJP/ajuGVjJ2alo6BqmE9h0qWkXbEoCFMKcPTw6W6NggjNQXBeCXuVFHF
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-MS-Exchange-CrossTenant-Network-Message-Id: 5ab33e56-8310-4a08-bd64-08d7f740b4ad
X-MS-Exchange-CrossTenant-originalarrivaltime: 13 May 2020 13:22:37.4488 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-CrossTenant-userprincipalname: UkcvKQlB4eQRxiOUd7Bokx3ZT3vyflqmeQqXfKQkdEZtg+++NteZnVbVxwLT3O+xr5G1NeQEIQw1rcgmGhf/o1s3Dhf0ij2+R4A8d0Hysdg=
X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR11MB3638
X-OriginatorOrg: intel.com
Subject: Re: [dpdk-dev] [RFC v2] hash: unify crc32 API header for x86 and ARM
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

>=20
> > -----Original Message-----
> > From: pbhagavatula@marvell.com <pbhagavatula@marvell.com>
> > Sent: Wednesday, May 13, 2020 4:40 AM
> > To: jerinj@marvell.com; konstantin.ananyev@intel.com;
> > harry.van.haaren@intel.com; Yipeng Wang <yipeng1.wang@intel.com>;
> > Sameh Gobriel <sameh.gobriel@intel.com>; Bruce Richardson
> > <bruce.richardson@intel.com>; Ruifeng Wang <Ruifeng.Wang@arm.com>
> > Cc: dev@dpdk.org; Pavan Nikhilesh <pbhagavatula@marvell.com>
> > Subject: [dpdk-dev] [RFC v2] hash: unify crc32 API header for x86 and A=
RM
> >
> > From: Pavan Nikhilesh <pbhagavatula@marvell.com>
> >
> > Merge crc32 hash calculation public API headers for x86 and ARM.
> > Select the best available CRC32 algorithm when unsupported algorithm on=
 a
> > given CPU architecture is requested by an application.
> >
> > Previously, if an application directly includes `rte_crc_arm64.h` witho=
ut
> > including `rte_hash_crc.h` it will fail to compile.
> > Although, `rte_crc_arm64.h` is no longer needed make it a dummy file fo=
r
> > ABI purposes.
> >
> > Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
> > ---
> >  v2 Changes:
> >  - Don't remove `rte_crc_arm64.h` for ABI purposes.
> >  - Revert function pointer approach for performance reasons.
> >  - Select the best available algorithm based on the arch when user pass=
es an
> > unsupported crc32 algorithm.
> >
> Maybe split the patch? Changes to select the best available algorithm can=
 be a separate one.
>=20
> More ifdefs are added. Is it possible to have arch specific rte_hash_crc_=
xx implementations
> like what was done in rte_crc_arm64.h, and include specific headers accor=
ding to arch in rte_hash.crc.h?

Same thought.

> For ABI purpose, rte_crc_arm64.h can be kept and it only includes the new=
 arm64 specific header.
>=20
> >  app/test/test_hash.c            |   6 ++
> >  lib/librte_hash/meson.build     |   6 +-
> >  lib/librte_hash/rte_crc_arm64.h | 175 +-------------------------------
> > lib/librte_hash/rte_hash_crc.h  | 153 ++++++++++++++++++++--------
> >  4 files changed, 122 insertions(+), 218 deletions(-)
> >
> > diff --git a/app/test/test_hash.c b/app/test/test_hash.c index
> > afa3a1a3c..7bd457dac 100644
> > --- a/app/test/test_hash.c
> > +++ b/app/test/test_hash.c
> > @@ -195,7 +195,13 @@ test_crc32_hash_alg_equiv(void)
> >  	}
> >
> >  	/* Resetting to best available algorithm */
> > +#if defined RTE_ARCH_X86
> >  	rte_hash_crc_set_alg(CRC32_SSE42_x64);
> > +#elif defined RTE_ARCH_ARM64
> > +	rte_hash_crc_set_alg(CRC32_ARM64);
> > +#else
> > +	rte_hash_crc_set_alg(CRC32_SW);
> > +#endif
> >
> >  	if (i =3D=3D CRC32_ITERATIONS)
> >  		return 0;
> > diff --git a/lib/librte_hash/meson.build b/lib/librte_hash/meson.build =
index
> > 6ab46ae9d..8a3cf2f64 100644
> > --- a/lib/librte_hash/meson.build
> > +++ b/lib/librte_hash/meson.build
> > @@ -1,12 +1,14 @@
> >  # SPDX-License-Identifier: BSD-3-Clause  # Copyright(c) 2017 Intel
> > Corporation
> >
> > -headers =3D files('rte_crc_arm64.h',
> > -	'rte_fbk_hash.h',
> > +headers =3D files('rte_fbk_hash.h',
> >  	'rte_hash_crc.h',
> >  	'rte_hash.h',
> >  	'rte_jhash.h',
> >  	'rte_thash.h')
> > +if dpdk_conf.has('RTE_ARCH_ARM64')
> > +	headers +=3D files('rte_crc_arm64.h')
> > +endif
> >
> >  sources =3D files('rte_cuckoo_hash.c', 'rte_fbk_hash.c')  deps +=3D ['=
ring'] diff --
> > git a/lib/librte_hash/rte_crc_arm64.h b/lib/librte_hash/rte_crc_arm64.h
> > index b4628cfc0..adfcafc7d 100644
> > --- a/lib/librte_hash/rte_crc_arm64.h
> > +++ b/lib/librte_hash/rte_crc_arm64.h
> > @@ -5,179 +5,6 @@
> >  #ifndef _RTE_CRC_ARM64_H_
> >  #define _RTE_CRC_ARM64_H_
> >
> > -/**
> > - * @file
> > - *
> > - * RTE CRC arm64 Hash
> > - */
> > -
> > -#ifdef __cplusplus
> > -extern "C" {
> > -#endif
> > -
> > -#include <stdint.h>
> > -#include <rte_cpuflags.h>
> > -#include <rte_branch_prediction.h>
> > -#include <rte_common.h>
> > -
> > -static inline uint32_t
> > -crc32c_arm64_u8(uint8_t data, uint32_t init_val) -{
> > -	__asm__ volatile(
> > -			"crc32cb %w[crc], %w[crc], %w[value]"
> > -			: [crc] "+r" (init_val)
> > -			: [value] "r" (data));
> > -	return init_val;
> > -}
> > -
> > -static inline uint32_t
> > -crc32c_arm64_u16(uint16_t data, uint32_t init_val) -{
> > -	__asm__ volatile(
> > -			"crc32ch %w[crc], %w[crc], %w[value]"
> > -			: [crc] "+r" (init_val)
> > -			: [value] "r" (data));
> > -	return init_val;
> > -}
> > -
> > -static inline uint32_t
> > -crc32c_arm64_u32(uint32_t data, uint32_t init_val) -{
> > -	__asm__ volatile(
> > -			"crc32cw %w[crc], %w[crc], %w[value]"
> > -			: [crc] "+r" (init_val)
> > -			: [value] "r" (data));
> > -	return init_val;
> > -}
> > -
> > -static inline uint32_t
> > -crc32c_arm64_u64(uint64_t data, uint32_t init_val) -{
> > -	__asm__ volatile(
> > -			"crc32cx %w[crc], %w[crc], %x[value]"
> > -			: [crc] "+r" (init_val)
> > -			: [value] "r" (data));
> > -	return init_val;
> > -}
> > -
> > -/**
> > - * Allow or disallow use of arm64 SIMD instrinsics for CRC32 hash
> > - * calculation.
> > - *
> > - * @param alg
> > - *   An OR of following flags:
> > - *   - (CRC32_SW) Don't use arm64 crc intrinsics
> > - *   - (CRC32_ARM64) Use ARMv8 CRC intrinsic if available
> > - *
> > - */
> > -static inline void
> > -rte_hash_crc_set_alg(uint8_t alg)
> > -{
> > -	switch (alg) {
> > -	case CRC32_ARM64:
> > -		if (!rte_cpu_get_flag_enabled(RTE_CPUFLAG_CRC32))
> > -			alg =3D CRC32_SW;
> > -		/* fall-through */
> > -	case CRC32_SW:
> > -		crc32_alg =3D alg;
> > -		/* fall-through */
> > -	default:
> > -		break;
> > -	}
> > -}
> > -
> > -/* Setting the best available algorithm */
> > -RTE_INIT(rte_hash_crc_init_alg)
> > -{
> > -	rte_hash_crc_set_alg(CRC32_ARM64);
> > -}
> > -
> > -/**
> > - * Use single crc32 instruction to perform a hash on a 1 byte value.
> > - * Fall back to software crc32 implementation in case arm64 crc intrin=
sics is
> > - * not supported
> > - *
> > - * @param data
> > - *   Data to perform hash on.
> > - * @param init_val
> > - *   Value to initialise hash generator.
> > - * @return
> > - *   32bit calculated hash value.
> > - */
> > -static inline uint32_t
> > -rte_hash_crc_1byte(uint8_t data, uint32_t init_val) -{
> > -	if (likely(crc32_alg & CRC32_ARM64))
> > -		return crc32c_arm64_u8(data, init_val);
> > -
> > -	return crc32c_1byte(data, init_val);
> > -}
> > -
> > -/**
> > - * Use single crc32 instruction to perform a hash on a 2 bytes value.
> > - * Fall back to software crc32 implementation in case arm64 crc intrin=
sics is
> > - * not supported
> > - *
> > - * @param data
> > - *   Data to perform hash on.
> > - * @param init_val
> > - *   Value to initialise hash generator.
> > - * @return
> > - *   32bit calculated hash value.
> > - */
> > -static inline uint32_t
> > -rte_hash_crc_2byte(uint16_t data, uint32_t init_val) -{
> > -	if (likely(crc32_alg & CRC32_ARM64))
> > -		return crc32c_arm64_u16(data, init_val);
> > -
> > -	return crc32c_2bytes(data, init_val);
> > -}
> > -
> > -/**
> > - * Use single crc32 instruction to perform a hash on a 4 byte value.
> > - * Fall back to software crc32 implementation in case arm64 crc intrin=
sics is
> > - * not supported
> > - *
> > - * @param data
> > - *   Data to perform hash on.
> > - * @param init_val
> > - *   Value to initialise hash generator.
> > - * @return
> > - *   32bit calculated hash value.
> > - */
> > -static inline uint32_t
> > -rte_hash_crc_4byte(uint32_t data, uint32_t init_val) -{
> > -	if (likely(crc32_alg & CRC32_ARM64))
> > -		return crc32c_arm64_u32(data, init_val);
> > -
> > -	return crc32c_1word(data, init_val);
> > -}
> > -
> > -/**
> > - * Use single crc32 instruction to perform a hash on a 8 byte value.
> > - * Fall back to software crc32 implementation in case arm64 crc intrin=
sics is
> > - * not supported
> > - *
> > - * @param data
> > - *   Data to perform hash on.
> > - * @param init_val
> > - *   Value to initialise hash generator.
> > - * @return
> > - *   32bit calculated hash value.
> > - */
> > -static inline uint32_t
> > -rte_hash_crc_8byte(uint64_t data, uint32_t init_val) -{
> > -	if (likely(crc32_alg =3D=3D CRC32_ARM64))
> > -		return crc32c_arm64_u64(data, init_val);
> > -
> > -	return crc32c_2words(data, init_val);
> > -}
> > -
> > -#ifdef __cplusplus
> > -}
> > -#endif
> > +#include "rte_hash_crc.h"
> >
> >  #endif /* _RTE_CRC_ARM64_H_ */
> > diff --git a/lib/librte_hash/rte_hash_crc.h b/lib/librte_hash/rte_hash_=
crc.h
> > index cf28031b3..eaba70c12 100644
> > --- a/lib/librte_hash/rte_hash_crc.h
> > +++ b/lib/librte_hash/rte_hash_crc.h
> > @@ -16,10 +16,12 @@ extern "C" {
> >  #endif
> >
> >  #include <stdint.h>
> > -#include <rte_config.h>
> > -#include <rte_cpuflags.h>
> > +
> >  #include <rte_branch_prediction.h>
> >  #include <rte_common.h>
> > +#include <rte_config.h>
> > +#include <rte_cpuflags.h>
> > +#include <rte_log.h>
> >
> >  /* Lookup tables for software implementation of CRC32C */  static cons=
t
> > uint32_t crc32c_tables[8][256] =3D {{ @@ -322,7 +324,7 @@
> > crc32c_2bytes(uint16_t data, uint32_t init_val)  }
> >
> >  static inline uint32_t
> > -crc32c_1word(uint32_t data, uint32_t init_val)
> > +crc32c_4bytes(uint32_t data, uint32_t init_val)
> >  {
> >  	uint32_t crc, term1, term2;
> >  	crc =3D init_val;
> > @@ -336,7 +338,7 @@ crc32c_1word(uint32_t data, uint32_t init_val)  }
> >
> >  static inline uint32_t
> > -crc32c_2words(uint64_t data, uint32_t init_val)
> > +crc32c_8bytes(uint64_t data, uint32_t init_val)
> >  {
> >  	uint32_t crc, term1, term2;
> >  	union {
> > @@ -358,6 +360,48 @@ crc32c_2words(uint64_t data, uint32_t init_val)
> >  	return crc;
> >  }
> >
> > +#if defined(RTE_ARCH_ARM64) &&
> > defined(RTE_MACHINE_CPUFLAG_CRC32)
> > +static inline uint32_t
> > +crc32c_arm64_u8(uint8_t data, uint32_t init_val) {
> > +	__asm__ volatile(
> > +			"crc32cb %w[crc], %w[crc], %w[value]"
> > +			: [crc] "+r" (init_val)
> > +			: [value] "r" (data));
> > +	return init_val;
> > +}
> > +
> > +static inline uint32_t
> > +crc32c_arm64_u16(uint16_t data, uint32_t init_val) {
> > +	__asm__ volatile(
> > +			"crc32ch %w[crc], %w[crc], %w[value]"
> > +			: [crc] "+r" (init_val)
> > +			: [value] "r" (data));
> > +	return init_val;
> > +}
> > +
> > +static inline uint32_t
> > +crc32c_arm64_u32(uint32_t data, uint32_t init_val) {
> > +	__asm__ volatile(
> > +			"crc32cw %w[crc], %w[crc], %w[value]"
> > +			: [crc] "+r" (init_val)
> > +			: [value] "r" (data));
> > +	return init_val;
> > +}
> > +
> > +static inline uint32_t
> > +crc32c_arm64_u64(uint64_t data, uint32_t init_val) {
> > +	__asm__ volatile(
> > +			"crc32cx %w[crc], %w[crc], %x[value]"
> > +			: [crc] "+r" (init_val)
> > +			: [value] "r" (data));
> > +	return init_val;
> > +}
> > +#endif
> > +
> >  #if defined(RTE_ARCH_X86)
> >  static inline uint32_t
> >  crc32c_sse42_u8(uint8_t data, uint32_t init_val) @@ -424,42 +468,69 @@
> > crc32c_sse42_u64(uint64_t data, uint64_t init_val)
> >
> >  static uint8_t crc32_alg =3D CRC32_SW;
> >
> > -#if defined(RTE_ARCH_ARM64) &&
> > defined(RTE_MACHINE_CPUFLAG_CRC32)
> > -#include "rte_crc_arm64.h"
> > -#else
> > -
> >  /**
> > - * Allow or disallow use of SSE4.2 instrinsics for CRC32 hash
> > + * Allow or disallow use of SSE4.2/ARMv8 instrinsics for CRC32 hash
> >   * calculation.
> >   *
> >   * @param alg
> >   *   An OR of following flags:
> > - *   - (CRC32_SW) Don't use SSE4.2 intrinsics
> > + *   - (CRC32_SW) Don't use SSE4.2 intrinsics (default non-[x86/ARMv8]=
)
> >   *   - (CRC32_SSE42) Use SSE4.2 intrinsics if available
> > - *   - (CRC32_SSE42_x64) Use 64-bit SSE4.2 intrinsic if available (def=
ault)
> > - *
> > + *   - (CRC32_SSE42_x64) Use 64-bit SSE4.2 intrinsic if available (def=
ault x86)
> > + *   - (CRC32_ARM64) Use ARMv8 CRC intrinsic if available
> >   */
> >  static inline void
> >  rte_hash_crc_set_alg(uint8_t alg)
> >  {
> > -#if defined(RTE_ARCH_X86)
> > -	if (alg =3D=3D CRC32_SSE42_x64 &&
> > -			!rte_cpu_get_flag_enabled(RTE_CPUFLAG_EM64T))
> > -		alg =3D CRC32_SSE42;
> > +	switch (alg) {
> > +	case CRC32_SSE42_x64:
> > +	case CRC32_SSE42:
> > +#if defined RTE_ARCH_X86
> > +		if (!rte_cpu_get_flag_enabled(RTE_CPUFLAG_EM64T))
> > +			crc32_alg =3D CRC32_SSE42;
> > +		else
> > +			crc32_alg =3D alg;
> > +#endif
> > +#if defined RTE_ARCH_ARM64
> > +		RTE_LOG(WARNING, HASH,
> > +			"Incorrect CRC32 algorithm requested setting best"
> > +			"available algorithm on the architecture\n");
> > +		rte_hash_crc_set_alg(CRC32_ARM64);
> > +#endif
> > +		break;
> > +	case CRC32_ARM64:
> > +#if defined RTE_ARCH_ARM64
> > +		if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_CRC32))
> > +			crc32_alg =3D CRC32_ARM64;
> >  #endif
> > -	crc32_alg =3D alg;
> > +#if defined RTE_ARCH_X86
> > +		RTE_LOG(WARNING, HASH,
> > +			"Incorrect CRC32 algorithm requested setting best"
> > +			"available algorithm on the architecture\n");
> > +		rte_hash_crc_set_alg(CRC32_SSE42_x64);
> > +#endif
> > +		break;
> > +	case CRC32_SW:
> > +	default:
> > +		crc32_alg =3D CRC32_SW;
> > +	break;
> > +	}
> >  }
> >
> >  /* Setting the best available algorithm */
> >  RTE_INIT(rte_hash_crc_init_alg)
> >  {
> > +#if defined RTE_ARCH_X86
> >  	rte_hash_crc_set_alg(CRC32_SSE42_x64);
> > +#elif defined RTE_ARCH_ARM64
> > +	rte_hash_crc_set_alg(CRC32_ARM64);
> > +#else
> > +	rte_hash_crc_set_alg(CRC32_SW);
> > +#endif
> >  }
> >
> >  /**
> > - * Use single crc32 instruction to perform a hash on a byte value.
> > - * Fall back to software crc32 implementation in case SSE4.2 is
> > - * not supported
> > + * Calculate crc32 hash value of 1bytes.
> >   *
> >   * @param data
> >   *   Data to perform hash on.
> > @@ -474,15 +545,15 @@ rte_hash_crc_1byte(uint8_t data, uint32_t init_va=
l)
> > #if defined RTE_ARCH_X86
> >  	if (likely(crc32_alg & CRC32_SSE42))
> >  		return crc32c_sse42_u8(data, init_val);
> > +#elif defined RTE_ARCH_ARM64
> > +	if (likely(crc32_alg & CRC32_ARM64))
> > +		return crc32c_arm64_u8(data, init_val);
> >  #endif
> > -
> >  	return crc32c_1byte(data, init_val);
> >  }
> >
> >  /**
> > - * Use single crc32 instruction to perform a hash on a 2 bytes value.
> > - * Fall back to software crc32 implementation in case SSE4.2 is
> > - * not supported
> > + * Calculate crc32 hash value of 2bytes.
> >   *
> >   * @param data
> >   *   Data to perform hash on.
> > @@ -497,15 +568,15 @@ rte_hash_crc_2byte(uint16_t data, uint32_t init_v=
al)
> > #if defined RTE_ARCH_X86
> >  	if (likely(crc32_alg & CRC32_SSE42))
> >  		return crc32c_sse42_u16(data, init_val);
> > +#elif defined RTE_ARCH_ARM64
> > +	if (likely(crc32_alg & CRC32_ARM64))
> > +		return crc32c_arm64_u16(data, init_val);
> >  #endif
> > -
> >  	return crc32c_2bytes(data, init_val);
> >  }
> >
> >  /**
> > - * Use single crc32 instruction to perform a hash on a 4 byte value.
> > - * Fall back to software crc32 implementation in case SSE4.2 is
> > - * not supported
> > + * Calculate crc32 hash value of 4bytes.
> >   *
> >   * @param data
> >   *   Data to perform hash on.
> > @@ -520,15 +591,15 @@ rte_hash_crc_4byte(uint32_t data, uint32_t init_v=
al)
> > #if defined RTE_ARCH_X86
> >  	if (likely(crc32_alg & CRC32_SSE42))
> >  		return crc32c_sse42_u32(data, init_val);
> > +#elif defined RTE_ARCH_ARM64
> > +	if (likely(crc32_alg & CRC32_ARM64))
> > +		return crc32c_arm64_u32(data, init_val);
> >  #endif
> > -
> > -	return crc32c_1word(data, init_val);
> > +	return crc32c_4bytes(data, init_val);
> >  }
> >
> >  /**
> > - * Use single crc32 instruction to perform a hash on a 8 byte value.
> > - * Fall back to software crc32 implementation in case SSE4.2 is
> > - * not supported
> > + * Calculate crc32 hash value of 8bytes.
> >   *
> >   * @param data
> >   *   Data to perform hash on.
> > @@ -540,21 +611,19 @@ rte_hash_crc_4byte(uint32_t data, uint32_t init_v=
al)
> > static inline uint32_t  rte_hash_crc_8byte(uint64_t data, uint32_t init=
_val)  { -
> > #ifdef RTE_ARCH_X86_64
> > -	if (likely(crc32_alg =3D=3D CRC32_SSE42_x64))
> > +#if defined RTE_ARCH_X86_64
> > +	if (likely(crc32_alg & CRC32_SSE42_x64))
> >  		return crc32c_sse42_u64(data, init_val); -#endif
> > -
> > -#if defined RTE_ARCH_X86
> > +#elif defined RTE_ARCH_X86
> >  	if (likely(crc32_alg & CRC32_SSE42))
> >  		return crc32c_sse42_u64_mimic(data, init_val);
> > +#elif defined RTE_ARCH_ARM64
> > +	if (likely(crc32_alg & CRC32_ARM64))
> > +		return crc32c_arm64_u64(data, init_val);
> >  #endif
> > -
> > -	return crc32c_2words(data, init_val);
> > +	return crc32c_8bytes(data, init_val);
> >  }
> >
> > -#endif
> > -
> >  /**
> >   * Calculate CRC32 hash on user-supplied byte array.
> >   *
> > --
> > 2.17.1