From patchwork Thu May 18 09:09:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jianbo Liu X-Patchwork-Id: 100061 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp622562qge; Thu, 18 May 2017 02:09:17 -0700 (PDT) X-Received: by 10.28.217.66 with SMTP id q63mr1863295wmg.10.1495098557565; Thu, 18 May 2017 02:09:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495098557; cv=none; d=google.com; s=arc-20160816; b=oGo1azrbXzJxWaEVwkN6FlJuj0Ko9Ote/jWM2f2NwrpVdz/s5Zmyfx0puHLrgPYzxY ZaUEFIqmZixqct/4KZnUFaRpwkeGS+Iz04gwn9n9G8AULp/SyqpfH+fghXsDXRczpnhx y9TZIsb2Kgv3vOKjVvpT3J4jhCFwLSJ8/ENyQc85k+ObYqipfhxTKoYCIeYlbLiYh90a 0mn7/+jJ/CgcTM4yuxsggGZxNDHjBhvp0Z+3esM59qZvywU5sRJzQqysPboaK3De8DqM pd2ZgvhNTHLt1s4zqaRmOWuIMgBe7r7LQuVl5OT+2B0vfSeTA1hwpnU6KhGOeoOSXjoD aJ5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:message-id:date:cc:to :from:arc-authentication-results; bh=O4qYJM26BrNNYW6mz3YbnCOH5X/JNgo+2rdGIS8fVYs=; b=P6G61ZXGwrd/iekbmCNIZlAZXziLCGXE5XCJ/HhBHxOlVazpFXYwhegoHwr4fMjuTC b99eSm0vwl4AKNjGweakuqUZj9F+oul0rqPvEY3eyknakyRJiEzrIS8dmNHOXtSpjS8w NW9MKgqeSGucSGR16d49e/kXHk2ceUfymXxNapgFlcHvDKLpAryIXPbOR13Z3qRn3KQr 6O5vY5mDA+pLVgCNF84ljn3cfm1wjAa+N5qjXrWU0ryQo/+D1PTXeW2j2g+Znm6WkXEW fX+fh+9ck+Ou9/0h1ALqgbnHlQf3LlKIq9lKfIR+vDLzu0LiN7sutYkpzIaoU0p8Q3Dw nt6w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 2001:4b98:dc0:41:216:3eff:fe72:dd13 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from dpdk.org ([2001:4b98:dc0:41:216:3eff:fe72:dd13]) by mx.google.com with ESMTP id b8si5702375wmi.104.2017.05.18.02.09.17; Thu, 18 May 2017 02:09:17 -0700 (PDT) Received-SPF: pass (google.com: domain of dev-bounces@dpdk.org designates 2001:4b98:dc0:41:216:3eff:fe72:dd13 as permitted sender) client-ip=2001:4b98:dc0:41:216:3eff:fe72:dd13; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 2001:4b98:dc0:41:216:3eff:fe72:dd13 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 4DD2E2C5; Thu, 18 May 2017 11:09:16 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.101.70]) by dpdk.org (Postfix) with ESMTP id F39A120F for ; Thu, 18 May 2017 11:09:14 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E0462344; Thu, 18 May 2017 02:09:13 -0700 (PDT) Received: from localhost.localdomain.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 14F0B3F23B; Thu, 18 May 2017 02:09:12 -0700 (PDT) From: Jianbo Liu To: dev@dpdk.org, cristian.dumitrescu@intel.com, jerin.jacob@caviumnetworks.com, ashwin.sekhar@caviumnetworks.com Cc: Jianbo Liu Date: Thu, 18 May 2017 17:09:00 +0800 Message-Id: <1495098540-8303-1-git-send-email-jianbo.liu@linaro.org> X-Mailer: git-send-email 1.8.3.1 Subject: [dpdk-dev] [PATCH] examples/ip_pipeline: use crc32 in hash functions for arm64 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Implement the same hash functions with crc32 on arm platform. Signed-off-by: Jianbo Liu --- examples/ip_pipeline/pipeline/hash_func.h | 2 + examples/ip_pipeline/pipeline/hash_func_arm64.h | 245 ++++++++++++++++++++++++ 2 files changed, 247 insertions(+) create mode 100644 examples/ip_pipeline/pipeline/hash_func_arm64.h -- 1.8.3.1 diff --git a/examples/ip_pipeline/pipeline/hash_func.h b/examples/ip_pipeline/pipeline/hash_func.h index 9db7173..990bbee 100644 --- a/examples/ip_pipeline/pipeline/hash_func.h +++ b/examples/ip_pipeline/pipeline/hash_func.h @@ -335,6 +335,8 @@ #define hash_default_key56 hash_crc_key56 #define hash_default_key64 hash_crc_key64 +#elif defined(RTE_ARCH_ARM64) +#include "hash_func_arm64.h" #else #define hash_default_key8 hash_xor_key8 diff --git a/examples/ip_pipeline/pipeline/hash_func_arm64.h b/examples/ip_pipeline/pipeline/hash_func_arm64.h new file mode 100644 index 0000000..f6a45d9 --- /dev/null +++ b/examples/ip_pipeline/pipeline/hash_func_arm64.h @@ -0,0 +1,245 @@ +/*- + * BSD LICENSE + * + * Copyright(c) 2017 Linaro Limited. All rights reserved. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef __HASH_FUNC_ARM64_H__ +#define __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 +hash_crc_key8(void *key, __rte_unused uint32_t key_size, uint64_t seed) +{ + uint64_t *k = key; + uint32_t crc0; + + crc0 = seed; + _CRC32CX(crc0, k[0]); + + return crc0; +} + +static inline uint64_t +hash_crc_key16(void *key, __rte_unused uint32_t key_size, uint64_t seed) +{ + uint64_t *k = key, k0; + uint32_t crc0, crc1; + + k0 = k[0]; + + crc0 = k0; + _CRC32CX(crc0, seed); + crc1 = k0 >> 32; + _CRC32CX(crc1, k[1]); + + crc0 ^= crc1; + + return crc0; +} + +static inline uint64_t +hash_crc_key24(void *key, __rte_unused uint32_t key_size, uint64_t seed) +{ + uint64_t *k = key, k0, k2; + uint32_t crc0, crc1; + + k0 = k[0]; + k2 = k[2]; + + crc0 = k0; + _CRC32CX(crc0, seed); + crc1 = k0 >> 32; + _CRC32CX(crc1, k[1]); + + _CRC32CX(crc0, k2); + + crc0 ^= crc1; + + return crc0; +} + +static inline uint64_t +hash_crc_key32(void *key, __rte_unused uint32_t key_size, uint64_t seed) +{ + uint64_t *k = key, k0, k2; + uint32_t crc0, crc1, crc2, crc3; + + k0 = k[0]; + k2 = k[2]; + + crc0 = k0; + _CRC32CX(crc0, seed); + crc1 = k0 >> 32; + _CRC32CX(crc1, k[1]); + + crc2 = k2; + _CRC32CX(crc2, k[3]); + crc3 = k2 >> 32; + + _CRC32CX(crc0, crc1); + _CRC32CX(crc2, crc3); + + crc0 ^= crc2; + + return crc0; +} + +static inline uint64_t +hash_crc_key40(void *key, __rte_unused uint32_t key_size, uint64_t seed) +{ + uint64_t *k = key, k0, k2; + uint32_t crc0, crc1, crc2, crc3; + + k0 = k[0]; + k2 = k[2]; + + crc0 = k0; + _CRC32CX(crc0, seed); + crc1 = k0 >> 32; + _CRC32CX(crc1, k[1]); + + crc2 = k2; + _CRC32CX(crc2, k[3]); + crc3 = k2 >> 32; + _CRC32CX(crc3, k[4]); + + _CRC32CX(crc0, crc1); + _CRC32CX(crc2, crc3); + + crc0 ^= crc2; + + return crc0; +} + +static inline uint64_t +hash_crc_key48(void *key, __rte_unused uint32_t key_size, uint64_t seed) +{ + uint64_t *k = key, k0, k2, k5; + uint32_t crc0, crc1, crc2, crc3; + + k0 = k[0]; + k2 = k[2]; + k5 = k[5]; + + crc0 = k0; + _CRC32CX(crc0, seed); + crc1 = k0 >> 32; + _CRC32CX(crc1, k[1]); + + crc2 = k2; + _CRC32CX(crc2, k[3]); + crc3 = k2 >> 32; + _CRC32CX(crc3, k[4]); + + _CRC32CX(crc0, ((uint64_t)crc1 << 32) ^ crc2); + _CRC32CX(crc3, k5); + + crc0 ^= crc3; + + return crc0; +} + +static inline uint64_t +hash_crc_key56(void *key, __rte_unused uint32_t key_size, uint64_t seed) +{ + uint64_t *k = key, k0, k2, k5; + uint32_t crc0, crc1, crc2, crc3, crc4, crc5; + + k0 = k[0]; + k2 = k[2]; + k5 = k[5]; + + crc0 = k0; + _CRC32CX(crc0, seed); + crc1 = k0 >> 32; + _CRC32CX(crc1, k[1]); + + crc2 = k2; + _CRC32CX(crc2, k[3]); + crc3 = k2 >> 32; + _CRC32CX(crc3, k[4]); + + crc4 = k5; + _CRC32CX(crc4, k[6]); + crc5 = k5 >> 32; + + _CRC32CX(crc0, ((uint64_t)crc1 << 32) ^ crc2); + _CRC32CX(crc3, ((uint64_t)crc4 << 32) ^ crc5); + + crc0 ^= crc3; + + return crc0; +} + +static inline uint64_t +hash_crc_key64(void *key, __rte_unused uint32_t key_size, uint64_t seed) +{ + uint64_t *k = key, k0, k2, k5; + uint32_t crc0, crc1, crc2, crc3, crc4, crc5; + + k0 = k[0]; + k2 = k[2]; + k5 = k[5]; + + crc0 = k0; + _CRC32CX(crc0, seed); + crc1 = k0 >> 32; + _CRC32CX(crc1, k[1]); + + crc2 = k2; + _CRC32CX(crc2, k[3]); + crc3 = k2 >> 32; + _CRC32CX(crc3, k[4]); + + crc4 = k5; + _CRC32CX(crc4, k[6]); + crc5 = k5 >> 32; + _CRC32CX(crc5, k[7]); + + _CRC32CX(crc0, ((uint64_t)crc1 << 32) ^ crc2); + _CRC32CX(crc3, ((uint64_t)crc4 << 32) ^ crc5); + + crc0 ^= crc3; + + return crc0; +} + +#define hash_default_key8 hash_crc_key8 +#define hash_default_key16 hash_crc_key16 +#define hash_default_key24 hash_crc_key24 +#define hash_default_key32 hash_crc_key32 +#define hash_default_key40 hash_crc_key40 +#define hash_default_key48 hash_crc_key48 +#define hash_default_key56 hash_crc_key56 +#define hash_default_key64 hash_crc_key64 + +#endif