From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id E6C6442D83;
	Wed, 28 Jun 2023 21:20:24 +0200 (CEST)
Received: from mails.dpdk.org (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id C922D406B3;
	Wed, 28 Jun 2023 21:20:24 +0200 (CEST)
Received: from mga11.intel.com (mga11.intel.com [192.55.52.93])
 by mails.dpdk.org (Postfix) with ESMTP id 4BAFB40151
 for <dev@dpdk.org>; Wed, 28 Jun 2023 21:20:23 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple;
 d=intel.com; i=@intel.com; q=dns/txt; s=Intel;
 t=1687980023; x=1719516023;
 h=message-id:date:subject:to:cc:references:from:
 in-reply-to:content-transfer-encoding:mime-version;
 bh=NN+tvcc7ITwImcbgEOaCDdde6athvro2o8CFMaw9v/c=;
 b=OcLMIQ9u1BezLE6StoF/Ws4jktCb6zHbYLZSgqe//f5zyT2NVwzHQfpp
 XeiBCeg7fUS9RiT1Expk8MnMFbRMty7i+PTWQNXqlr6OCnd59/cb01Ni5
 DUfLF/WT/seA/bDx+4Wjc1uwv1IAQaSp91KeWHYBM3JPtxhYz3qjdW1e7
 LDWqbTT0q3mcUctAJwZClb59akMUhKdm8ZPDwqaLy5IIX/0e/2q0kjXZu
 eWLuTY270wlTgPMd/35M4DpcaAWmDbsEYZs/TbGXkvSDBVBaluRHYzuou
 AhsbzwdT+37KLvNAdgtM9vkpMpXyr4Xe4XJR19Lj6bAPhpWke8paj9Irj g==;
X-IronPort-AV: E=McAfee;i="6600,9927,10755"; a="359429583"
X-IronPort-AV: E=Sophos;i="6.01,166,1684825200"; d="scan'208";a="359429583"
Received: from orsmga003.jf.intel.com ([10.7.209.27])
 by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 28 Jun 2023 12:20:22 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=McAfee;i="6600,9927,10755"; a="667236123"
X-IronPort-AV: E=Sophos;i="6.01,166,1684825200"; d="scan'208";a="667236123"
Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16])
 by orsmga003.jf.intel.com with ESMTP; 28 Jun 2023 12:20:16 -0700
Received: from orsmsx601.amr.corp.intel.com (10.22.229.14) by
 ORSMSX603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server
 (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id
 15.1.2507.27; Wed, 28 Jun 2023 12:20:07 -0700
Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by
 orsmsx601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server
 (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id
 15.1.2507.27 via Frontend Transport; Wed, 28 Jun 2023 12:20:07 -0700
Received: from NAM11-CO1-obe.outbound.protection.outlook.com (104.47.56.173)
 by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server
 (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
 15.1.2507.27; Wed, 28 Jun 2023 12:20:06 -0700
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
 b=UYJqVZMsoil40Q7fddiEGZESwQOIjHdW1Hm0IXrlg5jR841o4aXZ+wQoqS7npnmOC7aLmBJPHmRrphVlZv4sxBT2/dmrAJu24YBsxwLgh9UUfMxnga0NXhgKmQE348eON1xCF4Sclicu9U6FPbewHhqx7B96F4+/W4r5q5D6VkWLVPXiOaxPMg7E4VqF/+gGUh7PIf+SJvXC4SsWNHF5l8kfAX4maTSxVHD81aRxas6xrTtrfx+VmujSoZUeBm7xImFLl0aLnPhSzqaEsaZ67ZA53fOAl5dquEvfZGia7Ylrv6oyWOF3VIFfnK5QfH+9FnZ9MkkXmBJPCmE9ffkxhw==
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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;
 bh=/7rmjcDGohtyzfKz5msx3RPJaR/6yuHfBjpwDLAhSWk=;
 b=mZ4/1vfjYtsl6E0I7w8NsXBBolJoJPr/pl9GBeYU0gB4Ncr2lV34cgdiqohcPMUv/exb2B5FeIYTG1RTXSLSRUzPJMvglNUqGLEkRP0uIca4/mTRAbFvS8RTgGhWfZVcIavidfJKeXDovuvdp0JT3THK+jGJAiUArd4LiySfWSoAmbvSlbWij98Myi7yqHs7zmLGJcFXmT24E3ioLjqn6l+J0ynMThSPg5ZVATZO0TiBcRcxmcx6088K3q0R7ak35CnLtzMySMG4bBT7fVK+A+hQnBEKZOTYVntNXZbrQxLCIFMwCQJJIX2dexIlJ42SZZvGZuBgDnHh11K13YDluw==
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
Authentication-Results: dkim=none (message not signed)
 header.d=none;dmarc=none action=none header.from=intel.com;
Received: from SJ0PR11MB5772.namprd11.prod.outlook.com (2603:10b6:a03:422::8)
 by CY8PR11MB7748.namprd11.prod.outlook.com (2603:10b6:930:87::20)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.24; Wed, 28 Jun
 2023 19:20:05 +0000
Received: from SJ0PR11MB5772.namprd11.prod.outlook.com
 ([fe80::4215:1bb5:eb92:5e9b]) by SJ0PR11MB5772.namprd11.prod.outlook.com
 ([fe80::4215:1bb5:eb92:5e9b%4]) with mapi id 15.20.6521.024; Wed, 28 Jun 2023
 19:20:05 +0000
Message-ID: <12205df1-1868-6dec-0901-3d4b2310da3b@intel.com>
Date: Wed, 28 Jun 2023 20:19:59 +0100
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
 Thunderbird/102.10.0
Subject: Re: [PATCH v7 1/1] hash: add XOR32 hash function
To: Bili Dong <qobilidop@gmail.com>, <dev@dpdk.org>
CC: <cristian.dumitrescu@intel.com>, <yipeng1.wang@intel.com>,
 <sameh.gobriel@intel.com>, <bruce.richardson@intel.com>,
 <medvedkinv@gmail.com>, <hofors@lysator.liu.se>, <stephen@networkplumber.org>
References: <20230221193710.717280-1-qobilidop@gmail.com>
 <20230620191253.3218830-1-qobilidop@gmail.com>
Content-Language: en-US
From: "Medvedkin, Vladimir" <vladimir.medvedkin@intel.com>
In-Reply-To: <20230620191253.3218830-1-qobilidop@gmail.com>
Content-Type: text/plain; charset="UTF-8"; format=flowed
Content-Transfer-Encoding: 8bit
X-ClientProxiedBy: DU2P250CA0007.EURP250.PROD.OUTLOOK.COM
 (2603:10a6:10:231::12) To SJ0PR11MB5772.namprd11.prod.outlook.com
 (2603:10b6:a03:422::8)
MIME-Version: 1.0
X-MS-PublicTrafficType: Email
X-MS-TrafficTypeDiagnostic: SJ0PR11MB5772:EE_|CY8PR11MB7748:EE_
X-MS-Office365-Filtering-Correlation-Id: 8202a1b8-b114-444f-39d3-08db780cad7e
X-MS-Exchange-SenderADCheck: 1
X-MS-Exchange-AntiSpam-Relay: 0
X-Microsoft-Antispam: BCL:0;
X-Microsoft-Antispam-Message-Info: Ib/CoSqsReexJJ6p3t7g0Ioj8akPlRgluSdGSKoz99M7v7Uvx1V94vTNLo0ZOMnOrNb75Cy7UC4NRgTG40XuYwnya22WoLLO1C/9pnPKZN1xA5uK7DhsBsPIu9TbL3vGo+lBx499tG2Y0VM+Dhz4+chgkYSlp75vLrmJArQx1uTjacPC1QwcgdMsEREL2qvamXlyO11NJ4Ci4uFaFU4F5OYNbia2CRpdujkwXotJEIFYH7azsbB3bO2hGAcry6Aiqi9SZWTK0Ca0oAFpQmHNMloQV2cI9edgR4Q1uBmO5QB69T5DKarqMJff6DpcJyXY7pUbd2W4Hf+eFKNqaSIfHRYjmPw5DCO2mhnxrHU2wNUzZsNOKYdDC03C+4Ec7VlBPAFN4W/fndmbm+M8qW8RnlKceweXpiNXgDStjvJT3+3nclYbaWqB0zyB+dZKdBze8kczI10yQVtlhEjIeFg/zRqyWTxoxygZo1K07aPjaUn8at3TFf/EXADpDihx+UUwdqgXsZw5xgEMEd3ALfynKXvsGNpX2KAMX0GdY907Cv6desKNF4Tgym/pZsaGkKXCPr07QaboQAhdPQGDNMppbNWbhLZ3blMIsT7STiPzXCT39PehwsVxJLai1EkE26SFEZ16B23gH5U243K+BKSV8Q==
X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:;
 IPV:NLI; SFV:NSPM; H:SJ0PR11MB5772.namprd11.prod.outlook.com; PTR:; CAT:NONE;
 SFS:(13230028)(396003)(346002)(376002)(366004)(136003)(39860400002)(451199021)(82960400001)(38100700002)(36756003)(66574015)(83380400001)(31696002)(86362001)(31686004)(2616005)(8936002)(6486002)(66556008)(41300700001)(6666004)(66946007)(66476007)(8676002)(316002)(53546011)(26005)(6512007)(4326008)(186003)(6506007)(66899021)(478600001)(2906002)(5660300002)(43740500002)(45980500001);
 DIR:OUT; SFP:1102; 
X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1
X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?ZWt2YmdVcUVMTW5ocHFLR3JkMmZMTVZuNTVBZVM5QUcxVkU4ZVlwZTRvZzlE?=
 =?utf-8?B?V2VueUFKWndFK1dacXQxc3pUQWp1TEJFVjdLbmw2Ty8zU2p6Mmg2RnJqek5a?=
 =?utf-8?B?NXpIellKN3B5SXN4OEw4QVlRMSsxVDlpQWFKY3RPN09lNm1mVnU5V0cvcVJi?=
 =?utf-8?B?REZHZlh6VTRXTnFNdkE1N2UyQnh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Kythc2Z5WEF1UjhMSGc4eDJTazlDbkVRZGhxK3pPRUF4Z0N0KzJW?=
 =?utf-8?B?RU5tZVJSMlpCVWlRcjYzYlhBR1hKU003V0dkUzg4SmdVZjJLSGJwNkI2NE5P?=
 =?utf-8?B?ZktUWTFReGlYdEtGMFRBakYybFlEcm55OGJ1eGZPZWZlaTFaMzlndG1IbXFC?=
 =?utf-8?B?RkZnbzJuZCtXU1pPci95RG9JbHFicE5FNkt2bVNHL2NhUUV0aS9ZeWMybnJ2?=
 =?utf-8?B?b2c9PQ==?=
X-MS-Exchange-CrossTenant-Network-Message-Id: 8202a1b8-b114-444f-39d3-08db780cad7e
X-MS-Exchange-CrossTenant-AuthSource: SJ0PR11MB5772.namprd11.prod.outlook.com
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jun 2023 19:20:05.1403 (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: bYX83dctLqmgArHyh8IjRQYVd6lLTQJF7Tr6n/EreMXB51J4B9oLTzq7OdS5WmWymVsEAXE20W7HJmPp2tPsfpXrGlgfq4iVoA5XaHYpWaQ=
X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR11MB7748
X-OriginatorOrg: intel.com
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
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

Hi Bili,

Please find just one nit below inlined

Apart from it LGTM

Acked-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>

On 20/06/2023 20:12, Bili Dong wrote:
> An XOR32 hash is needed in the Software Switch (SWX) Pipeline for its
> use case in P4. We implement it in this patch so it could be easily
> registered in the pipeline later.
>
> Signed-off-by: Bili Dong <qobilidop@gmail.com>
> ---
> v7:
> * Simplified byte ordering conversion logic. (re Vladimir Medvedkin <medvedkinv@gmail.com>)
> * Added test cases with hash key length = 3 (mod 4). (re Vladimir Medvedkin <medvedkinv@gmail.com>)
> * Adopted a better way to access bytes. (re Mattias Rönnblom <hofors@lysator.liu.se>)
> * Adopted RTE_PTR_ADD for pointer arithmetic. (re Mattias Rönnblom <hofors@lysator.liu.se>)
>
>   .mailmap                       |   1 +
>   app/test/test_hash_functions.c |  47 +++++++++++---
>   lib/hash/rte_hash_xor.h        | 109 +++++++++++++++++++++++++++++++++
>   3 files changed, 147 insertions(+), 10 deletions(-)
>   create mode 100644 lib/hash/rte_hash_xor.h
>
> diff --git a/.mailmap b/.mailmap
> index 8e3940a253..997d89388f 100644
> --- a/.mailmap
> +++ b/.mailmap
> @@ -164,6 +164,7 @@ Bernard Iremonger <bernard.iremonger@intel.com>
>   Bert van Leeuwen <bert.vanleeuwen@netronome.com>
>   Bhagyada Modali <bhagyada.modali@amd.com>
>   Bharat Mota <bmota@vmware.com>
> +Bili Dong <qobilidop@gmail.com>
>   Bill Hong <bhong@brocade.com>
>   Billy McFall <bmcfall@redhat.com>
>   Billy O'Mahony <billy.o.mahony@intel.com>
> diff --git a/app/test/test_hash_functions.c b/app/test/test_hash_functions.c
> index 76d51b6e71..61f1341cbc 100644
> --- a/app/test/test_hash_functions.c
> +++ b/app/test/test_hash_functions.c
> @@ -15,6 +15,7 @@
>   #include <rte_hash.h>
>   #include <rte_jhash.h>
>   #include <rte_hash_crc.h>
> +#include <rte_hash_xor.h>
>
>   #include "test.h"
>
> @@ -22,35 +23,48 @@
>    * Hash values calculated for key sizes from array "hashtest_key_lens"
>    * and for initial values from array "hashtest_initvals.
>    * Each key will be formed by increasing each byte by 1:
> - * e.g.: key size = 4, key = 0x03020100
> - *       key size = 8, key = 0x0706050403020100
> + * e.g.: key size = 4, key = 0x00010203
> + *       key size = 8, key = 0x0001020304050607
>    */
> -static uint32_t hash_values_jhash[2][12] = {{
> -	0x8ba9414b, 0xdf0d39c9,
> +static uint32_t hash_values_jhash[2][14] = {{
> +	0x8ba9414b, 0xdf0d39c9, 0x6b12f277, 0x589511d8,
>   	0xe4cf1d42, 0xd4ccb93c, 0x5e84eafc, 0x21362cfe,
>   	0x2f4775ab, 0x9ff036cc, 0xeca51474, 0xbc9d6816,
>   	0x12926a31, 0x1c9fa888
>   },
>   {
> -	0x5c62c303, 0x1b8cf784,
> +	0x5c62c303, 0x1b8cf784, 0x455e19f7, 0x785de928,
>   	0x8270ac65, 0x05fa6668, 0x762df861, 0xda088f2f,
>   	0x59614cd4, 0x7a94f690, 0xdc1e4993, 0x30825494,
>   	0x91d0e462, 0x768087fc
>   }
>   };
> -static uint32_t hash_values_crc[2][12] = {{
> -	0x00000000, 0xf26b8303,
> +static uint32_t hash_values_crc[2][14] = {{
> +	0x00000000, 0xf26b8303, 0xf299e880, 0x18678721,
>   	0x91545164, 0x06040eb1, 0x9bb99201, 0xcc4c4fe4,
>   	0x14a90993, 0xf8a5dd8c, 0xcaa1ad0b, 0x7ac1e03e,
>   	0x43f44466, 0x4a11475e
>   },
>   {
> -	0xbdfd3980, 0x70204542,
> +	0xbdfd3980, 0x70204542, 0x410b3df9, 0xe3f8b2f1,
>   	0x98cd4c70, 0xd52c702f, 0x41fc0e1c, 0x3905f65c,
>   	0x94bff47f, 0x1bab102d, 0xf4a2c645, 0xbf441539,
>   	0x789c104f, 0x53028d3e
>   }
>   };
> +static uint32_t hash_values_xor32[2][14] = {{
> +	0x00000000, 0x00010000, 0x00010200, 0x4040403,
> +	0x00010203, 0x04040404, 0x00000000, 0x00000000,
> +	0x00000000, 0x00000000, 0x0c040404, 0x000d0e0f,
> +	0x04212223, 0x04040404
> +},
> +{
> +	0xdeadbeef, 0xdeacbeef, 0xdeacbcef, 0xdaa9baec,
> +	0xdeacbcec, 0xdaa9baeb, 0xdeadbeef, 0xdeadbeef,
> +	0xdeadbeef, 0xdeadbeef, 0xd2a9baeb, 0xdea0b0e0,
> +	0xda8c9ccc, 0xdaa9baeb
> +}
> +};
>
>   /*******************************************************************************
>    * Hash function performance test configuration section. Each performance test
> @@ -61,10 +75,10 @@ static uint32_t hash_values_crc[2][12] = {{
>    */
>   #define HASHTEST_ITERATIONS 1000000
>   #define MAX_KEYSIZE 64
> -static rte_hash_function hashtest_funcs[] = {rte_jhash, rte_hash_crc};
> +static rte_hash_function hashtest_funcs[] = {rte_jhash, rte_hash_crc, rte_hash_xor32};
>   static uint32_t hashtest_initvals[] = {0, 0xdeadbeef};
>   static uint32_t hashtest_key_lens[] = {
> -	1, 2,                 /* Unusual key sizes */
> +	1, 2, 3, 7,           /* Unusual key sizes */
>   	4, 8, 16, 32, 48, 64, /* standard key sizes */
>   	9,                    /* IPv4 SRC + DST + protocol, unpadded */
>   	13,                   /* IPv4 5-tuple, unpadded */
> @@ -85,6 +99,9 @@ get_hash_name(rte_hash_function f)
>   	if (f == rte_hash_crc)
>   		return "rte_hash_crc";
>
> +	if (f == rte_hash_xor32)
> +		return "rte_hash_xor32";
> +
>   	return "UnknownHash";
>   }
>
> @@ -173,6 +190,16 @@ verify_precalculated_hash_func_tests(void)
>   				       hash_values_crc[j][i], hash);
>   				return -1;
>   			}
> +
> +			hash = rte_hash_xor32(key, hashtest_key_lens[i],
> +					hashtest_initvals[j]);
> +			if (hash != hash_values_xor32[j][i]) {
> +				printf("XOR32 for %u bytes with initial value 0x%x."
> +				       " Expected 0x%x, but got 0x%x\n",
> +				       hashtest_key_lens[i], hashtest_initvals[j],
> +				       hash_values_xor32[j][i], hash);
> +				return -1;
> +			}
>   		}
>   	}
>
> diff --git a/lib/hash/rte_hash_xor.h b/lib/hash/rte_hash_xor.h
> new file mode 100644
> index 0000000000..7bc0953716
> --- /dev/null
> +++ b/lib/hash/rte_hash_xor.h
> @@ -0,0 +1,109 @@
> +/* SPDX-License-Identifier: BSD-3-Clause
> + * Copyright(c) 2023 Intel Corporation
> + */
> +
> +#ifndef _RTE_HASH_XOR_H_
> +#define _RTE_HASH_XOR_H_
> +
> +/**
> + * @file
> + *
> + * RTE XOR Hash
> + */
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
> +#include <stdint.h>
> +
> +#include <rte_byteorder.h>
> +#include <rte_common.h>
> +
> +/**
> + * The following bytes access helper functions are expected to work
> + * without any particular input buffer alignment requirements.
> + */
> +
> +static inline uint64_t
> +rte_hash_access64(const void *data)
> +{
> +	uint64_t v;
> +	memcpy(&v, data, sizeof(v));
> +	return v;
> +}
> +
> +static inline uint32_t
> +rte_hash_access32(const void *data)
> +{
> +	uint32_t v;
> +	memcpy(&v, data, sizeof(v));
> +	return v;
> +}
> +
> +static inline uint16_t
> +rte_hash_access16(const void *data)
> +{
> +	uint16_t v;
> +	memcpy(&v, data, sizeof(v));
> +	return v;
> +}
> +
> +static inline uint8_t
> +rte_hash_access8(const void *data)
> +{
> +	uint8_t v;
> +	memcpy(&v, data, sizeof(v));
> +	return v;
> +}

I don't think this function is necessary.


> +
> +/**
> + * Calculate XOR32 hash on user-supplied byte array.
> + *
> + * @param data
> + *   Data to perform hash on.
> + * @param data_len
> + *   How many bytes to use to calculate hash value.
> + * @param init_val
> + *   Value to initialise hash generator.
> + * @return
> + *   32bit calculated hash value.
> + */
> +static inline uint32_t
> +rte_hash_xor32(const void *data, uint32_t data_len, uint32_t init_val)
> +{
> +	uint32_t hash32 = init_val;
> +	uint64_t hash64 = 0;
> +
> +	/* Batch process in 8 bytes for better performance. */
> +	uint32_t i;
> +	for (i = 0; i < data_len / 8; i++) {
> +		hash64 ^= rte_hash_access64(data);
> +		data = RTE_PTR_ADD(data, 8);
> +	}
> +
> +	if (data_len & 0x4) {
> +		hash64 ^= rte_hash_access32(data);
> +		data = RTE_PTR_ADD(data, 4);
> +	}
> +
> +	/* Deal with remaining (< 4) bytes. */
> +	uint8_t bit_offset = 0;
> +	if (data_len & 0x2) {
> +		hash64 ^= rte_hash_access16(data);
> +		data = RTE_PTR_ADD(data, 2);
> +		bit_offset += 16;
> +
> +	}
> +	if (data_len & 0x1)
> +		hash64 ^= rte_hash_access8(data) << bit_offset;
> +
> +	hash32 ^= rte_be_to_cpu_32((uint32_t)hash64 ^ (hash64 >> 32));
> +	return hash32;
> +}
> +
> +#ifdef __cplusplus
> +}
> +#endif
> +
> +#endif /* _RTE_HASH_XOR_H_ */
> --
> 2.41.0.162.gfafddb0af9-goog
>
-- 
Regards,
Vladimir