Skip to contentSkip to conversation

lib/librte_table: add hash_func header files

PATCH Superseded Kevin Laatz 4 participants 14 messages Sep 7, 2018 – Sep 28, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v3 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 reduces code duplication by removing duplicate header files within two folders and consolidating them into a single one. This also adds a scalar implementation of the x86_64 intrinsic for crc32 as a generic fallback.

---
v2:
- Fixed typo in commit message
- Fixed typo in arm header that caused some compilations to fail for the entire patchset
v3:
- Improved commit message

---
 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
lib/librte_table/Makefile +2 -0
index 276d476..f935678 100644
@@ -46,6 +46,8 @@ SYMLINK-$(CONFIG_RTE_LIBRTE_TABLE)-include += rte_table_acl.h
 endif
 SYMLINK-$(CONFIG_RTE_LIBRTE_TABLE)-include += rte_table_hash.h
 SYMLINK-$(CONFIG_RTE_LIBRTE_TABLE)-include += rte_table_hash_cuckoo.h
+SYMLINK-$(CONFIG_RTE_LIBRTE_TABLE)-include += rte_table_hash_func.h
+SYMLINK-$(CONFIG_RTE_LIBRTE_TABLE)-include += rte_table_hash_func_arm64.h
 SYMLINK-$(CONFIG_RTE_LIBRTE_TABLE)-include += rte_lru.h
 ifeq ($(CONFIG_RTE_ARCH_X86),y)
 SYMLINK-$(CONFIG_RTE_LIBRTE_TABLE)-include += rte_lru_x86.h
lib/librte_table/meson.build +2 -0
index 8b2f841..6ae3cd6 100644
@@ -19,6 +19,8 @@ headers = 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')
lib/librte_table/rte_table_hash_func.h new file +244 -0

244 lines not on this page · raw message

lib/librte_table/rte_table_hash_func_arm64.h new file +21 -0
new file mode 100644
index 0000000..eb04c1f
@@ -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 = crc;
+
+	_CRC32CX(crc32, v);
+
+	return crc32;
+}
+
+#endif
lib/librte_table/rte_table_version.map +14 -0
index 6237252..dab339e 100644
@@ -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;
Signature · 1 line
2.9.5
#1 lore raw

PATCH v3 2/3 examples/ip_pipeline: modify application to use librte_table headers

This commit modifies the IP Pipeline application to use the new header files in librte_table.

As we are now using the new header files, we can remove the old ones from the application directory.

---
 examples/ip_pipeline/action.c          |  34 ++--
 examples/ip_pipeline/hash_func.h       | 357 ---------------------------------
 examples/ip_pipeline/hash_func_arm64.h | 232 ---------------------
 examples/ip_pipeline/pipeline.c        |  19 +-
 4 files changed, 26 insertions(+), 616 deletions(-)
 delete mode 100644 examples/ip_pipeline/hash_func.h
 delete mode 100644 examples/ip_pipeline/hash_func_arm64.h
examples/ip_pipeline/action.c +17 -17
index a29c2b3..20497c3 100644
@@ -7,9 +7,9 @@
 #include <string.h>
 
 #include <rte_string_fns.h>
+#include <rte_table_hash_func.h>
 
 #include "action.h"
-#include "hash_func.h"
 
 /**
  * Input port
@@ -57,35 +57,35 @@ port_in_action_profile_create(const char *name,
 		(params->lb.f_hash == NULL)) {
 		switch (params->lb.key_size) {
 		case  8:
-			params->lb.f_hash = hash_default_key8;
+			params->lb.f_hash = rte_table_hash_crc_key8;
 			break;
 
 		case 16:
-			params->lb.f_hash = hash_default_key16;
+			params->lb.f_hash = rte_table_hash_crc_key16;
 			break;
 
 		case 24:
-			params->lb.f_hash = hash_default_key24;
+			params->lb.f_hash = rte_table_hash_crc_key24;
 			break;
 
 		case 32:
-			params->lb.f_hash = hash_default_key32;
+			params->lb.f_hash = rte_table_hash_crc_key32;
 			break;
 
 		case 40:
-			params->lb.f_hash = hash_default_key40;
+			params->lb.f_hash = rte_table_hash_crc_key40;
 			break;
 
 		case 48:
-			params->lb.f_hash = hash_default_key48;
+			params->lb.f_hash = rte_table_hash_crc_key48;
 			break;
 
 		case 56:
-			params->lb.f_hash = hash_default_key56;
+			params->lb.f_hash = rte_table_hash_crc_key56;
 			break;
 
 		case 64:
-			params->lb.f_hash = hash_default_key64;
+			params->lb.f_hash = rte_table_hash_crc_key64;
 			break;
 
 		default:
@@ -192,35 +192,35 @@ table_action_profile_create(const char *name,
 		(params->lb.f_hash == NULL)) {
 		switch (params->lb.key_size) {
 		case 8:
-			params->lb.f_hash = hash_default_key8;
+			params->lb.f_hash = rte_table_hash_crc_key8;
 			break;
 
 		case 16:
-			params->lb.f_hash = hash_default_key16;
+			params->lb.f_hash = rte_table_hash_crc_key16;
 			break;
 
 		case 24:
-			params->lb.f_hash = hash_default_key24;
+			params->lb.f_hash = rte_table_hash_crc_key24;
 			break;
 
 		case 32:
-			params->lb.f_hash = hash_default_key32;
+			params->lb.f_hash = rte_table_hash_crc_key32;
 			break;
 
 		case 40:
-			params->lb.f_hash = hash_default_key40;
+			params->lb.f_hash = rte_table_hash_crc_key40;
 			break;
 
 		case 48:
-			params->lb.f_hash = hash_default_key48;
+			params->lb.f_hash = rte_table_hash_crc_key48;
 			break;
 
 		case 56:
-			params->lb.f_hash = hash_default_key56;
+			params->lb.f_hash = rte_table_hash_crc_key56;
 			break;
 
 		case 64:
-			params->lb.f_hash = hash_default_key64;
+			params->lb.f_hash = rte_table_hash_crc_key64;
 			break;
 
 		default:
examples/ip_pipeline/hash_func.h deleted +0 -357

357 lines not on this page · raw message

examples/ip_pipeline/hash_func_arm64.h deleted +0 -232

232 lines not on this page · raw message

examples/ip_pipeline/pipeline.c +9 -10
index 43fe867..b2fd215 100644
@@ -22,6 +22,7 @@
 #include <rte_table_acl.h>
 #include <rte_table_array.h>
 #include <rte_table_hash.h>
+#include <rte_table_hash_func.h>
 #include <rte_table_lpm.h>
 #include <rte_table_lpm_ipv6.h>
 #include <rte_table_stub.h>
@@ -36,8 +37,6 @@
 #include "tmgr.h"
 #include "swq.h"
 
-#include "hash_func.h"
-
 #ifndef PIPELINE_MSGQ_SIZE
 #define PIPELINE_MSGQ_SIZE                                 64
 #endif
@@ -818,28 +817,28 @@ pipeline_table_create(const char *pipeline_name,
 
 		switch (params->match.hash.key_size) {
 		case  8:
-			f_hash = hash_default_key8;
+			f_hash = rte_table_hash_crc_key8;
 			break;
 		case 16:
-			f_hash = hash_default_key16;
+			f_hash = rte_table_hash_crc_key16;
 			break;
 		case 24:
-			f_hash = hash_default_key24;
+			f_hash = rte_table_hash_crc_key24;
 			break;
 		case 32:
-			f_hash = hash_default_key32;
+			f_hash = rte_table_hash_crc_key32;
 			break;
 		case 40:
-			f_hash = hash_default_key40;
+			f_hash = rte_table_hash_crc_key40;
 			break;
 		case 48:
-			f_hash = hash_default_key48;
+			f_hash = rte_table_hash_crc_key48;
 			break;
 		case 56:
-			f_hash = hash_default_key56;
+			f_hash = rte_table_hash_crc_key56;
 			break;
 		case 64:
-			f_hash = hash_default_key64;
+			f_hash = rte_table_hash_crc_key64;
 			break;
 		default:
 			return -1;
Signature · 1 line
2.9.5
#2 lore raw

Re: [PATCH v3 2/3] examples/ip_pipeline: modify application to use librte_table headers

Quoted 12 lines

-----Original Message-----
From: Kevin Laatz <[email protected]>
Sent: Friday, September 7, 2018 6:06 PM
To: [email protected]
Cc: [email protected]; Jianbo Liu <[email protected]>; Gavin Hu (Arm Technology China) <[email protected]>; [email protected]; Kevin Laatz <[email protected]>
Subject: [PATCH v3 2/3] examples/ip_pipeline: modify application to use librte_table headers

Quoted 8 lines

This commit modifies the IP Pipeline application to use the new header files in librte_table.

As we are now using the new header files, we can remove the old ones from the application directory.

Quoted 774 lines
---
 examples/ip_pipeline/action.c          |  34 ++--
 examples/ip_pipeline/hash_func.h       | 357 ---------------------------------
 examples/ip_pipeline/hash_func_arm64.h | 232 ---------------------
 examples/ip_pipeline/pipeline.c        |  19 +-
 4 files changed, 26 insertions(+), 616 deletions(-)  delete mode 100644

examples/ip_pipeline/hash_func.h delete mode 100644 examples/ip_pipeline/hash_func_arm64.h

examples/ip_pipeline/action.c +17 -17
index a29c2b3..20497c3 100644
@@ -7,9 +7,9 @@
 #include <string.h>
 
 #include <rte_string_fns.h>
+#include <rte_table_hash_func.h>
 
 #include "action.h"
-#include "hash_func.h"
 
 /**
  * Input port
@@ -57,35 +57,35 @@ port_in_action_profile_create(const char *name,
 (params->lb.f_hash == NULL)) {
 switch (params->lb.key_size) {
 case  8:
-params->lb.f_hash = hash_default_key8;
+params->lb.f_hash = rte_table_hash_crc_key8;
 break;
 
 case 16:
-params->lb.f_hash = hash_default_key16;
+params->lb.f_hash = rte_table_hash_crc_key16;
 break;
 
 case 24:
-params->lb.f_hash = hash_default_key24;
+params->lb.f_hash = rte_table_hash_crc_key24;
 break;
 
 case 32:
-params->lb.f_hash = hash_default_key32;
+params->lb.f_hash = rte_table_hash_crc_key32;
 break;
 
 case 40:
-params->lb.f_hash = hash_default_key40;
+params->lb.f_hash = rte_table_hash_crc_key40;
 break;
 
 case 48:
-params->lb.f_hash = hash_default_key48;
+params->lb.f_hash = rte_table_hash_crc_key48;
 break;
 
 case 56:
-params->lb.f_hash = hash_default_key56;
+params->lb.f_hash = rte_table_hash_crc_key56;
 break;
 
 case 64:
-params->lb.f_hash = hash_default_key64;
+params->lb.f_hash = rte_table_hash_crc_key64;
 break;
 
 default:
@@ -192,35 +192,35 @@ table_action_profile_create(const char *name,
 (params->lb.f_hash == NULL)) {
 switch (params->lb.key_size) {
 case 8:
-params->lb.f_hash = hash_default_key8;
+params->lb.f_hash = rte_table_hash_crc_key8;
 break;
 
 case 16:
-params->lb.f_hash = hash_default_key16;
+params->lb.f_hash = rte_table_hash_crc_key16;
 break;
 
 case 24:
-params->lb.f_hash = hash_default_key24;
+params->lb.f_hash = rte_table_hash_crc_key24;
 break;
 
 case 32:
-params->lb.f_hash = hash_default_key32;
+params->lb.f_hash = rte_table_hash_crc_key32;
 break;
 
 case 40:
-params->lb.f_hash = hash_default_key40;
+params->lb.f_hash = rte_table_hash_crc_key40;
 break;
 
 case 48:
-params->lb.f_hash = hash_default_key48;
+params->lb.f_hash = rte_table_hash_crc_key48;
 break;
 
 case 56:
-params->lb.f_hash = hash_default_key56;
+params->lb.f_hash = rte_table_hash_crc_key56;
 break;
 
 case 64:
-params->lb.f_hash = hash_default_key64;
+params->lb.f_hash = rte_table_hash_crc_key64;
 break;
 
 default:
examples/ip_pipeline/hash_func.h deleted +0 -357
deleted file mode 100644
index f1b9d94..0000000
@@ -1,357 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2010-2018 Intel Corporation
- */
-
-#ifndef __INCLUDE_HASH_FUNC_H__
-#define __INCLUDE_HASH_FUNC_H__
-
-static inline uint64_t
-hash_xor_key8(void *key, void *mask, __rte_unused uint32_t key_size,
-uint64_t seed)
-{
-uint64_t *k = key;
-uint64_t *m = mask;
-uint64_t xor0;
-
-xor0 = seed ^ (k[0] & m[0]);
-
-return (xor0 >> 32) ^ xor0;
-}
-
-static inline uint64_t
-hash_xor_key16(void *key, void *mask, __rte_unused uint32_t key_size,
-uint64_t seed)
-{
-uint64_t *k = key;
-uint64_t *m = mask;
-uint64_t xor0;
-
-xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
-
-return (xor0 >> 32) ^ xor0;
-}
-
-static inline uint64_t
-hash_xor_key24(void *key, void *mask, __rte_unused uint32_t key_size,
-uint64_t seed)
-{
-uint64_t *k = key;
-uint64_t *m = mask;
-uint64_t xor0;
-
-xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
-
-xor0 ^= k[2] & m[2];
-
-return (xor0 >> 32) ^ xor0;
-}
-
-static inline uint64_t
-hash_xor_key32(void *key, void *mask, __rte_unused uint32_t key_size,
-uint64_t seed)
-{
-uint64_t *k = key;
-uint64_t *m = mask;
-uint64_t xor0, xor1;
-
-xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
-xor1 = (k[2] & m[2]) ^ (k[3] & m[3]);
-
-xor0 ^= xor1;
-
-return (xor0 >> 32) ^ xor0;
-}
-
-static inline uint64_t
-hash_xor_key40(void *key, void *mask, __rte_unused uint32_t key_size,
-uint64_t seed)
-{
-uint64_t *k = key;
-uint64_t *m = mask;
-uint64_t xor0, xor1;
-
-xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
-xor1 = (k[2] & m[2]) ^ (k[3] & m[3]);
-
-xor0 ^= xor1;
-
-xor0 ^= k[4] & m[4];
-
-return (xor0 >> 32) ^ xor0;
-}
-
-static inline uint64_t
-hash_xor_key48(void *key, void *mask, __rte_unused uint32_t key_size,
-uint64_t seed)
-{
-uint64_t *k = key;
-uint64_t *m = mask;
-uint64_t xor0, xor1, xor2;
-
-xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
-xor1 = (k[2] & m[2]) ^ (k[3] & m[3]);
-xor2 = (k[4] & m[4]) ^ (k[5] & m[5]);
-
-xor0 ^= xor1;
-
-xor0 ^= xor2;
-
-return (xor0 >> 32) ^ xor0;
-}
-
-static inline uint64_t
-hash_xor_key56(void *key, void *mask, __rte_unused uint32_t key_size,
-uint64_t seed)
-{
-uint64_t *k = key;
-uint64_t *m = mask;
-uint64_t xor0, xor1, xor2;
-
-xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
-xor1 = (k[2] & m[2]) ^ (k[3] & m[3]);
-xor2 = (k[4] & m[4]) ^ (k[5] & m[5]);
-
-xor0 ^= xor1;
-xor2 ^= k[6] & m[6];
-
-xor0 ^= xor2;
-
-return (xor0 >> 32) ^ xor0;
-}
-
-static inline uint64_t
-hash_xor_key64(void *key, void *mask, __rte_unused uint32_t key_size,
-uint64_t seed)
-{
-uint64_t *k = key;
-uint64_t *m = mask;
-uint64_t xor0, xor1, xor2, xor3;
-
-xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
-xor1 = (k[2] & m[2]) ^ (k[3] & m[3]);
-xor2 = (k[4] & m[4]) ^ (k[5] & m[5]);
-xor3 = (k[6] & m[6]) ^ (k[7] & m[7]);
-
-xor0 ^= xor1;
-xor2 ^= xor3;
-
-xor0 ^= xor2;
-
-return (xor0 >> 32) ^ xor0;
-}
-
-#if defined(RTE_ARCH_X86_64)
-
-#include <x86intrin.h>
-
-static inline uint64_t
-hash_crc_key8(void *key, void *mask, __rte_unused uint32_t key_size,
-uint64_t seed)
-{
-uint64_t *k = key;
-uint64_t *m = mask;
-uint64_t crc0;
-
-crc0 = _mm_crc32_u64(seed, k[0] & m[0]);
-
-return crc0;
-}
-
-static inline uint64_t
-hash_crc_key16(void *key, void *mask, __rte_unused uint32_t key_size,
-uint64_t seed)
-{
-uint64_t *k = key;
-uint64_t *m = mask;
-uint64_t k0, crc0, crc1;
-
-k0 = k[0] & m[0];
-
-crc0 = _mm_crc32_u64(k0, seed);
-crc1 = _mm_crc32_u64(k0 >> 32, k[1] & m[1]);
-
-crc0 ^= crc1;
-
-return crc0;
-}
-
-static inline uint64_t
-hash_crc_key24(void *key, void *mask, __rte_unused uint32_t key_size,
-uint64_t seed)
-{
-uint64_t *k = key;
-uint64_t *m = mask;
-uint64_t k0, k2, crc0, crc1;
-
-k0 = k[0] & m[0];
-k2 = k[2] & m[2];
-
-crc0 = _mm_crc32_u64(k0, seed);
-crc1 = _mm_crc32_u64(k0 >> 32, k[1] & m[1]);
-
-crc0 = _mm_crc32_u64(crc0, k2);
-
-crc0 ^= crc1;
-
-return crc0;
-}
-
-static inline uint64_t
-hash_crc_key32(void *key, void *mask, __rte_unused uint32_t key_size,
-uint64_t seed)
-{
-uint64_t *k = key;
-uint64_t *m = mask;
-uint64_t k0, k2, crc0, crc1, crc2, crc3;
-
-k0 = k[0] & m[0];
-k2 = k[2] & m[2];
-
-crc0 = _mm_crc32_u64(k0, seed);
-crc1 = _mm_crc32_u64(k0 >> 32, k[1] & m[1]);
-
-crc2 = _mm_crc32_u64(k2, k[3] & m[3]);
-crc3 = k2 >> 32;
-
-crc0 = _mm_crc32_u64(crc0, crc1);
-crc1 = _mm_crc32_u64(crc2, crc3);
-
-crc0 ^= crc1;
-
-return crc0;
-}
-
-static inline uint64_t
-hash_crc_key40(void *key, void *mask, __rte_unused uint32_t key_size,
-uint64_t seed)
-{
-uint64_t *k = key;
-uint64_t *m = mask;
-uint64_t k0, k2, crc0, crc1, crc2, crc3;
-
-k0 = k[0] & m[0];
-k2 = k[2] & m[2];
-
-crc0 = _mm_crc32_u64(k0, seed);
-crc1 = _mm_crc32_u64(k0 >> 32, k[1] & m[1]);
-
-crc2 = _mm_crc32_u64(k2, k[3] & m[3]);
-crc3 = _mm_crc32_u64(k2 >> 32, k[4] & m[4]);
-
-crc0 = _mm_crc32_u64(crc0, crc1);
-crc1 = _mm_crc32_u64(crc2, crc3);
-
-crc0 ^= crc1;
-
-return crc0;
-}
-
-static inline uint64_t
-hash_crc_key48(void *key, void *mask, __rte_unused uint32_t key_size,
-uint64_t seed)
-{
-uint64_t *k = key;
-uint64_t *m = mask;
-uint64_t k0, k2, k5, crc0, crc1, crc2, crc3;
-
-k0 = k[0] & m[0];
-k2 = k[2] & m[2];
-k5 = k[5] & m[5];
-
-crc0 = _mm_crc32_u64(k0, seed);
-crc1 = _mm_crc32_u64(k0 >> 32, k[1] & m[1]);
-
-crc2 = _mm_crc32_u64(k2, k[3] & m[3]);
-crc3 = _mm_crc32_u64(k2 >> 32, k[4] & m[4]);
-
-crc0 = _mm_crc32_u64(crc0, (crc1 << 32) ^ crc2);
-crc1 = _mm_crc32_u64(crc3, k5);
-
-crc0 ^= crc1;
-
-return crc0;
-}
-
-static inline uint64_t
-hash_crc_key56(void *key, void *mask, __rte_unused uint32_t key_size,
-uint64_t seed)
-{
-uint64_t *k = key;
-uint64_t *m = mask;
-uint64_t k0, k2, k5, crc0, crc1, crc2, crc3, crc4, crc5;
-
-k0 = k[0] & m[0];
-k2 = k[2] & m[2];
-k5 = k[5] & m[5];
-
-crc0 = _mm_crc32_u64(k0, seed);
-crc1 = _mm_crc32_u64(k0 >> 32, k[1] & m[1]);
-
-crc2 = _mm_crc32_u64(k2, k[3] & m[3]);
-crc3 = _mm_crc32_u64(k2 >> 32, k[4] & m[4]);
-
-crc4 = _mm_crc32_u64(k5, k[6] & m[6]);
-crc5 = k5 >> 32;
-
-crc0 = _mm_crc32_u64(crc0, (crc1 << 32) ^ crc2);
-crc1 = _mm_crc32_u64(crc3, (crc4 << 32) ^ crc5);
-
-crc0 ^= crc1;
-
-return crc0;
-}
-
-static inline uint64_t
-hash_crc_key64(void *key, void *mask, __rte_unused uint32_t key_size,
-uint64_t seed)
-{
-uint64_t *k = key;
-uint64_t *m = mask;
-uint64_t k0, k2, k5, crc0, crc1, crc2, crc3, crc4, crc5;
-
-k0 = k[0] & m[0];
-k2 = k[2] & m[2];
-k5 = k[5] & m[5];
-
-crc0 = _mm_crc32_u64(k0, seed);
-crc1 = _mm_crc32_u64(k0 >> 32, k[1] & m[1]);
-
-crc2 = _mm_crc32_u64(k2, k[3] & m[3]);
-crc3 = _mm_crc32_u64(k2 >> 32, k[4] & m[4]);
-
-crc4 = _mm_crc32_u64(k5, k[6] & m[6]);
-crc5 = _mm_crc32_u64(k5 >> 32, k[7] & m[7]);
-
-crc0 = _mm_crc32_u64(crc0, (crc1 << 32) ^ crc2);
-crc1 = _mm_crc32_u64(crc3, (crc4 << 32) ^ crc5);
-
-crc0 ^= crc1;
-
-return crc0;
-}
-
-#define hash_default_key8hash_crc_key8
-#define hash_default_key16hash_crc_key16
-#define hash_default_key24hash_crc_key24
-#define hash_default_key32hash_crc_key32
-#define hash_default_key40hash_crc_key40
-#define hash_default_key48hash_crc_key48
-#define hash_default_key56hash_crc_key56
-#define hash_default_key64hash_crc_key64
-
-#elif defined(RTE_ARCH_ARM64)
-#include "hash_func_arm64.h"
-#else
-
-#define hash_default_key8hash_xor_key8
-#define hash_default_key16hash_xor_key16
-#define hash_default_key24hash_xor_key24
-#define hash_default_key32hash_xor_key32
-#define hash_default_key40hash_xor_key40
-#define hash_default_key48hash_xor_key48
-#define hash_default_key56hash_xor_key56
-#define hash_default_key64hash_xor_key64
-
-#endif
-
-#endif
examples/ip_pipeline/hash_func_arm64.h deleted +0 -232
deleted file mode 100644
index 50df816..0000000
@@ -1,232 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2017-2018 Linaro Limited.
- */
-#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, void *mask, __rte_unused uint32_t key_size,
-uint64_t seed)
-{
-uint64_t *k = key;
-uint64_t *m = mask;
-uint32_t crc0;
-
-crc0 = seed;
-_CRC32CX(crc0, k[0] & m[0]);
-
-return crc0;
-}
-
-static inline uint64_t
-hash_crc_key16(void *key, void *mask, __rte_unused uint32_t key_size,
-uint64_t seed)
-{
-uint64_t *k = key, k0;
-uint64_t *m = mask;
-uint32_t crc0, crc1;
-
-k0 = k[0] & m[0];
-
-crc0 = k0;
-_CRC32CX(crc0, seed);
-crc1 = k0 >> 32;
-_CRC32CX(crc1, k[1] & m[1]);
-
-crc0 ^= crc1;
-
-return crc0;
-}
-
-static inline uint64_t
-hash_crc_key24(void *key, void *mask, __rte_unused uint32_t key_size,
-uint64_t seed)
-{
-uint64_t *k = key, k0, k2;
-uint64_t *m = mask;
-uint32_t crc0, crc1;
-
-k0 = k[0] & m[0];
-k2 = k[2] & m[2];
-
-crc0 = k0;
-_CRC32CX(crc0, seed);
-crc1 = k0 >> 32;
-_CRC32CX(crc1, k[1] & m[1]);
-
-_CRC32CX(crc0, k2);
-
-crc0 ^= crc1;
-
-return crc0;
-}
-
-static inline uint64_t
-hash_crc_key32(void *key, void *mask, __rte_unused uint32_t key_size,
-uint64_t seed)
-{
-uint64_t *k = key, k0, k2;
-uint64_t *m = mask;
-uint32_t crc0, crc1, crc2, crc3;
-
-k0 = k[0] & m[0];
-k2 = k[2] & m[2];
-
-crc0 = k0;
-_CRC32CX(crc0, seed);
-crc1 = k0 >> 32;
-_CRC32CX(crc1, k[1] & m[1]);
-
-crc2 = k2;
-_CRC32CX(crc2, k[3] & m[3]);
-crc3 = k2 >> 32;
-
-_CRC32CX(crc0, crc1);
-_CRC32CX(crc2, crc3);
-
-crc0 ^= crc2;
-
-return crc0;
-}
-
-static inline uint64_t
-hash_crc_key40(void *key, void *mask, __rte_unused uint32_t key_size,
-uint64_t seed)
-{
-uint64_t *k = key, k0, k2;
-uint64_t *m = mask;
-uint32_t crc0, crc1, crc2, crc3;
-
-k0 = k[0] & m[0];
-k2 = k[2] & m[2];
-
-crc0 = k0;
-_CRC32CX(crc0, seed);
-crc1 = k0 >> 32;
-_CRC32CX(crc1, k[1] & m[1]);
-
-crc2 = k2;
-_CRC32CX(crc2, k[3] & m[3]);
-crc3 = k2 >> 32;
-_CRC32CX(crc3, k[4] & m[4]);
-
-_CRC32CX(crc0, crc1);
-_CRC32CX(crc2, crc3);
-
-crc0 ^= crc2;
-
-return crc0;
-}
-
-static inline uint64_t
-hash_crc_key48(void *key, void *mask, __rte_unused uint32_t key_size,
-uint64_t seed)
-{
-uint64_t *k = key, k0, k2, k5;
-uint64_t *m = mask;
-uint32_t crc0, crc1, crc2, crc3;
-
-k0 = k[0] & m[0];
-k2 = k[2] & m[2];
-k5 = k[5] & m[5];
-
-crc0 = k0;
-_CRC32CX(crc0, seed);
-crc1 = k0 >> 32;
-_CRC32CX(crc1, k[1] & m[1]);
-
-crc2 = k2;
-_CRC32CX(crc2, k[3] & m[3]);
-crc3 = k2 >> 32;
-_CRC32CX(crc3, k[4] & m[4]);
-
-_CRC32CX(crc0, ((uint64_t)crc1 << 32) ^ crc2);
-_CRC32CX(crc3, k5);
-
-crc0 ^= crc3;
-
-return crc0;
-}
-
-static inline uint64_t
-hash_crc_key56(void *key, void *mask, __rte_unused uint32_t key_size,
-uint64_t seed)
-{
-uint64_t *k = key, k0, k2, k5;
-uint64_t *m = mask;
-uint32_t crc0, crc1, crc2, crc3, crc4, crc5;
-
-k0 = k[0] & m[0];
-k2 = k[2] & m[2];
-k5 = k[5] & m[5];
-
-crc0 = k0;
-_CRC32CX(crc0, seed);
-crc1 = k0 >> 32;
-_CRC32CX(crc1, k[1] & m[1]);
-
-crc2 = k2;
-_CRC32CX(crc2, k[3] & m[3]);
-crc3 = k2 >> 32;
-_CRC32CX(crc3, k[4] & m[4]);
-
-crc4 = k5;
- _CRC32CX(crc4, k[6] & m[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, void *mask, __rte_unused uint32_t key_size,
-uint64_t seed)
-{
-uint64_t *k = key, k0, k2, k5;
-uint64_t *m = mask;
-uint32_t crc0, crc1, crc2, crc3, crc4, crc5;
-
-k0 = k[0] & m[0];
-k2 = k[2] & m[2];
-k5 = k[5] & m[5];
-
-crc0 = k0;
-_CRC32CX(crc0, seed);
-crc1 = k0 >> 32;
-_CRC32CX(crc1, k[1] & m[1]);
-
-crc2 = k2;
-_CRC32CX(crc2, k[3] & m[3]);
-crc3 = k2 >> 32;
-_CRC32CX(crc3, k[4] & m[4]);
-
-crc4 = k5;
- _CRC32CX(crc4, k[6] & m[6]);
-crc5 = k5 >> 32;
-_CRC32CX(crc5, k[7] & m[7]);
-
-_CRC32CX(crc0, ((uint64_t)crc1 << 32) ^ crc2);
-_CRC32CX(crc3, ((uint64_t)crc4 << 32) ^ crc5);
-
-crc0 ^= crc3;
-
-return crc0;
-}
-
-#define hash_default_key8hash_crc_key8
-#define hash_default_key16hash_crc_key16
-#define hash_default_key24hash_crc_key24
-#define hash_default_key32hash_crc_key32
-#define hash_default_key40hash_crc_key40
-#define hash_default_key48hash_crc_key48
-#define hash_default_key56hash_crc_key56
-#define hash_default_key64hash_crc_key64
-
-#endif
(quoted diff) +0 -0

b/examples/ip_pipeline/pipeline.c index 43fe867..b2fd215 100644

examples/ip_pipeline/pipeline.c +9 -11
@@ -22,6 +22,7 @@
 #include <rte_table_acl.h>
 #include <rte_table_array.h>
 #include <rte_table_hash.h>
+#include <rte_table_hash_func.h>
 #include <rte_table_lpm.h>
 #include <rte_table_lpm_ipv6.h>
 #include <rte_table_stub.h>
@@ -36,8 +37,6 @@
 #include "tmgr.h"
 #include "swq.h"
 
-#include "hash_func.h"
-
 #ifndef PIPELINE_MSGQ_SIZE
 #define PIPELINE_MSGQ_SIZE                                 64
 #endif
@@ -818,28 +817,28 @@ pipeline_table_create(const char *pipeline_name,
 
 switch (params->match.hash.key_size) {
 case  8:
-f_hash = hash_default_key8;
+f_hash = rte_table_hash_crc_key8;
 break;
 case 16:
-f_hash = hash_default_key16;
+f_hash = rte_table_hash_crc_key16;
 break;
 case 24:
-f_hash = hash_default_key24;
+f_hash = rte_table_hash_crc_key24;
 break;
 case 32:
-f_hash = hash_default_key32;
+f_hash = rte_table_hash_crc_key32;
 break;
 case 40:
-f_hash = hash_default_key40;
+f_hash = rte_table_hash_crc_key40;
 break;
 case 48:
-f_hash = hash_default_key48;
+f_hash = rte_table_hash_crc_key48;
 break;
 case 56:
-f_hash = hash_default_key56;
+f_hash = rte_table_hash_crc_key56;
 break;
 case 64:
-f_hash = hash_default_key64;
+f_hash = rte_table_hash_crc_key64;
 break;
 default:
 return -1;
--
Quoted 1 line

2.9.5

IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please 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.

#3 lore raw

PATCH v3 3/3 net/softnic: modify softnic to use librte_table headers

In reply to Kevin Laatz

This commit modifies SoftNIC to make use of the new header files in librte_table.

As we are now using the new header files in librte_table in SoftNIC, we no longer need the old header files so they can be removed.

---
 drivers/net/softnic/hash_func.h                | 359 -------------------------
 drivers/net/softnic/hash_func_arm64.h          | 261 ------------------
 drivers/net/softnic/rte_eth_softnic_action.c   |  34 +--
 drivers/net/softnic/rte_eth_softnic_pipeline.c |  19 +-
 4 files changed, 26 insertions(+), 647 deletions(-)
 delete mode 100644 drivers/net/softnic/hash_func.h
 delete mode 100644 drivers/net/softnic/hash_func_arm64.h
drivers/net/softnic/hash_func.h deleted +0 -359
deleted file mode 100644
index 198d2b2..0000000
@@ -1,359 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2010-2018 Intel Corporation
- */
-
-#ifndef __INCLUDE_HASH_FUNC_H__
-#define __INCLUDE_HASH_FUNC_H__
-
-#include <rte_common.h>
-
-static inline uint64_t
-hash_xor_key8(void *key, void *mask, __rte_unused uint32_t key_size,
-	uint64_t seed)
-{
-	uint64_t *k = key;
-	uint64_t *m = mask;
-	uint64_t xor0;
-
-	xor0 = seed ^ (k[0] & m[0]);
-
-	return (xor0 >> 32) ^ xor0;
-}
-
-static inline uint64_t
-hash_xor_key16(void *key, void *mask, __rte_unused uint32_t key_size,
-	uint64_t seed)
-{
-	uint64_t *k = key;
-	uint64_t *m = mask;
-	uint64_t xor0;
-
-	xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
-
-	return (xor0 >> 32) ^ xor0;
-}
-
-static inline uint64_t
-hash_xor_key24(void *key, void *mask, __rte_unused uint32_t key_size,
-	uint64_t seed)
-{
-	uint64_t *k = key;
-	uint64_t *m = mask;
-	uint64_t xor0;
-
-	xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
-
-	xor0 ^= k[2] & m[2];
-
-	return (xor0 >> 32) ^ xor0;
-}
-
-static inline uint64_t
-hash_xor_key32(void *key, void *mask, __rte_unused uint32_t key_size,
-	uint64_t seed)
-{
-	uint64_t *k = key;
-	uint64_t *m = mask;
-	uint64_t xor0, xor1;
-
-	xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
-	xor1 = (k[2] & m[2]) ^ (k[3] & m[3]);
-
-	xor0 ^= xor1;
-
-	return (xor0 >> 32) ^ xor0;
-}
-
-static inline uint64_t
-hash_xor_key40(void *key, void *mask, __rte_unused uint32_t key_size,
-	uint64_t seed)
-{
-	uint64_t *k = key;
-	uint64_t *m = mask;
-	uint64_t xor0, xor1;
-
-	xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
-	xor1 = (k[2] & m[2]) ^ (k[3] & m[3]);
-
-	xor0 ^= xor1;
-
-	xor0 ^= k[4] & m[4];
-
-	return (xor0 >> 32) ^ xor0;
-}
-
-static inline uint64_t
-hash_xor_key48(void *key, void *mask, __rte_unused uint32_t key_size,
-	uint64_t seed)
-{
-	uint64_t *k = key;
-	uint64_t *m = mask;
-	uint64_t xor0, xor1, xor2;
-
-	xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
-	xor1 = (k[2] & m[2]) ^ (k[3] & m[3]);
-	xor2 = (k[4] & m[4]) ^ (k[5] & m[5]);
-
-	xor0 ^= xor1;
-
-	xor0 ^= xor2;
-
-	return (xor0 >> 32) ^ xor0;
-}
-
-static inline uint64_t
-hash_xor_key56(void *key, void *mask, __rte_unused uint32_t key_size,
-	uint64_t seed)
-{
-	uint64_t *k = key;
-	uint64_t *m = mask;
-	uint64_t xor0, xor1, xor2;
-
-	xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
-	xor1 = (k[2] & m[2]) ^ (k[3] & m[3]);
-	xor2 = (k[4] & m[4]) ^ (k[5] & m[5]);
-
-	xor0 ^= xor1;
-	xor2 ^= k[6] & m[6];
-
-	xor0 ^= xor2;
-
-	return (xor0 >> 32) ^ xor0;
-}
-
-static inline uint64_t
-hash_xor_key64(void *key, void *mask, __rte_unused uint32_t key_size,
-	uint64_t seed)
-{
-	uint64_t *k = key;
-	uint64_t *m = mask;
-	uint64_t xor0, xor1, xor2, xor3;
-
-	xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
-	xor1 = (k[2] & m[2]) ^ (k[3] & m[3]);
-	xor2 = (k[4] & m[4]) ^ (k[5] & m[5]);
-	xor3 = (k[6] & m[6]) ^ (k[7] & m[7]);
-
-	xor0 ^= xor1;
-	xor2 ^= xor3;
-
-	xor0 ^= xor2;
-
-	return (xor0 >> 32) ^ xor0;
-}
-
-#if defined(RTE_ARCH_X86_64)
-
-#include <x86intrin.h>
-
-static inline uint64_t
-hash_crc_key8(void *key, void *mask, __rte_unused uint32_t key_size,
-	uint64_t seed)
-{
-	uint64_t *k = key;
-	uint64_t *m = mask;
-	uint64_t crc0;
-
-	crc0 = _mm_crc32_u64(seed, k[0] & m[0]);
-
-	return crc0;
-}
-
-static inline uint64_t
-hash_crc_key16(void *key, void *mask, __rte_unused uint32_t key_size,
-	uint64_t seed)
-{
-	uint64_t *k = key;
-	uint64_t *m = mask;
-	uint64_t k0, crc0, crc1;
-
-	k0 = k[0] & m[0];
-
-	crc0 = _mm_crc32_u64(k0, seed);
-	crc1 = _mm_crc32_u64(k0 >> 32, k[1] & m[1]);
-
-	crc0 ^= crc1;
-
-	return crc0;
-}
-
-static inline uint64_t
-hash_crc_key24(void *key, void *mask, __rte_unused uint32_t key_size,
-	uint64_t seed)
-{
-	uint64_t *k = key;
-	uint64_t *m = mask;
-	uint64_t k0, k2, crc0, crc1;
-
-	k0 = k[0] & m[0];
-	k2 = k[2] & m[2];
-
-	crc0 = _mm_crc32_u64(k0, seed);
-	crc1 = _mm_crc32_u64(k0 >> 32, k[1] & m[1]);
-
-	crc0 = _mm_crc32_u64(crc0, k2);
-
-	crc0 ^= crc1;
-
-	return crc0;
-}
-
-static inline uint64_t
-hash_crc_key32(void *key, void *mask, __rte_unused uint32_t key_size,
-	uint64_t seed)
-{
-	uint64_t *k = key;
-	uint64_t *m = mask;
-	uint64_t k0, k2, crc0, crc1, crc2, crc3;
-
-	k0 = k[0] & m[0];
-	k2 = k[2] & m[2];
-
-	crc0 = _mm_crc32_u64(k0, seed);
-	crc1 = _mm_crc32_u64(k0 >> 32, k[1] & m[1]);
-
-	crc2 = _mm_crc32_u64(k2, k[3] & m[3]);
-	crc3 = k2 >> 32;
-
-	crc0 = _mm_crc32_u64(crc0, crc1);
-	crc1 = _mm_crc32_u64(crc2, crc3);
-
-	crc0 ^= crc1;
-
-	return crc0;
-}
-
-static inline uint64_t
-hash_crc_key40(void *key, void *mask, __rte_unused uint32_t key_size,
-	uint64_t seed)
-{
-	uint64_t *k = key;
-	uint64_t *m = mask;
-	uint64_t k0, k2, crc0, crc1, crc2, crc3;
-
-	k0 = k[0] & m[0];
-	k2 = k[2] & m[2];
-
-	crc0 = _mm_crc32_u64(k0, seed);
-	crc1 = _mm_crc32_u64(k0 >> 32, k[1] & m[1]);
-
-	crc2 = _mm_crc32_u64(k2, k[3] & m[3]);
-	crc3 = _mm_crc32_u64(k2 >> 32, k[4] & m[4]);
-
-	crc0 = _mm_crc32_u64(crc0, crc1);
-	crc1 = _mm_crc32_u64(crc2, crc3);
-
-	crc0 ^= crc1;
-
-	return crc0;
-}
-
-static inline uint64_t
-hash_crc_key48(void *key, void *mask, __rte_unused uint32_t key_size,
-	uint64_t seed)
-{
-	uint64_t *k = key;
-	uint64_t *m = mask;
-	uint64_t k0, k2, k5, crc0, crc1, crc2, crc3;
-
-	k0 = k[0] & m[0];
-	k2 = k[2] & m[2];
-	k5 = k[5] & m[5];
-
-	crc0 = _mm_crc32_u64(k0, seed);
-	crc1 = _mm_crc32_u64(k0 >> 32, k[1] & m[1]);
-
-	crc2 = _mm_crc32_u64(k2, k[3] & m[3]);
-	crc3 = _mm_crc32_u64(k2 >> 32, k[4] & m[4]);
-
-	crc0 = _mm_crc32_u64(crc0, (crc1 << 32) ^ crc2);
-	crc1 = _mm_crc32_u64(crc3, k5);
-
-	crc0 ^= crc1;
-
-	return crc0;
-}
-
-static inline uint64_t
-hash_crc_key56(void *key, void *mask, __rte_unused uint32_t key_size,
-	uint64_t seed)
-{
-	uint64_t *k = key;
-	uint64_t *m = mask;
-	uint64_t k0, k2, k5, crc0, crc1, crc2, crc3, crc4, crc5;
-
-	k0 = k[0] & m[0];
-	k2 = k[2] & m[2];
-	k5 = k[5] & m[5];
-
-	crc0 = _mm_crc32_u64(k0, seed);
-	crc1 = _mm_crc32_u64(k0 >> 32, k[1] & m[1]);
-
-	crc2 = _mm_crc32_u64(k2, k[3] & m[3]);
-	crc3 = _mm_crc32_u64(k2 >> 32, k[4] & m[4]);
-
-	crc4 = _mm_crc32_u64(k5, k[6] & m[6]);
-	crc5 = k5 >> 32;
-
-	crc0 = _mm_crc32_u64(crc0, (crc1 << 32) ^ crc2);
-	crc1 = _mm_crc32_u64(crc3, (crc4 << 32) ^ crc5);
-
-	crc0 ^= crc1;
-
-	return crc0;
-}
-
-static inline uint64_t
-hash_crc_key64(void *key, void *mask, __rte_unused uint32_t key_size,
-	uint64_t seed)
-{
-	uint64_t *k = key;
-	uint64_t *m = mask;
-	uint64_t k0, k2, k5, crc0, crc1, crc2, crc3, crc4, crc5;
-
-	k0 = k[0] & m[0];
-	k2 = k[2] & m[2];
-	k5 = k[5] & m[5];
-
-	crc0 = _mm_crc32_u64(k0, seed);
-	crc1 = _mm_crc32_u64(k0 >> 32, k[1] & m[1]);
-
-	crc2 = _mm_crc32_u64(k2, k[3] & m[3]);
-	crc3 = _mm_crc32_u64(k2 >> 32, k[4] & m[4]);
-
-	crc4 = _mm_crc32_u64(k5, k[6] & m[6]);
-	crc5 = _mm_crc32_u64(k5 >> 32, k[7] & m[7]);
-
-	crc0 = _mm_crc32_u64(crc0, (crc1 << 32) ^ crc2);
-	crc1 = _mm_crc32_u64(crc3, (crc4 << 32) ^ crc5);
-
-	crc0 ^= crc1;
-
-	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
-
-#elif defined(RTE_ARCH_ARM64)
-#include "hash_func_arm64.h"
-#else
-
-#define hash_default_key8			hash_xor_key8
-#define hash_default_key16			hash_xor_key16
-#define hash_default_key24			hash_xor_key24
-#define hash_default_key32			hash_xor_key32
-#define hash_default_key40			hash_xor_key40
-#define hash_default_key48			hash_xor_key48
-#define hash_default_key56			hash_xor_key56
-#define hash_default_key64			hash_xor_key64
-
-#endif
-
-#endif
drivers/net/softnic/hash_func_arm64.h deleted +0 -261

261 lines not on this page · raw message

drivers/net/softnic/rte_eth_softnic_action.c +17 -17
index c25f4dd..c542688 100644
@@ -7,8 +7,8 @@
 #include <string.h>
 
 #include <rte_string_fns.h>
+#include <rte_table_hash_func.h>
 
-#include "hash_func.h"
 #include "rte_eth_softnic_internals.h"
 
 /**
@@ -72,35 +72,35 @@ softnic_port_in_action_profile_create(struct pmd_internals *p,
 		params->lb.f_hash == NULL) {
 		switch (params->lb.key_size) {
 		case  8:
-			params->lb.f_hash = hash_default_key8;
+			params->lb.f_hash = rte_table_hash_crc_key8;
 			break;
 
 		case 16:
-			params->lb.f_hash = hash_default_key16;
+			params->lb.f_hash = rte_table_hash_crc_key16;
 			break;
 
 		case 24:
-			params->lb.f_hash = hash_default_key24;
+			params->lb.f_hash = rte_table_hash_crc_key24;
 			break;
 
 		case 32:
-			params->lb.f_hash = hash_default_key32;
+			params->lb.f_hash = rte_table_hash_crc_key32;
 			break;
 
 		case 40:
-			params->lb.f_hash = hash_default_key40;
+			params->lb.f_hash = rte_table_hash_crc_key40;
 			break;
 
 		case 48:
-			params->lb.f_hash = hash_default_key48;
+			params->lb.f_hash = rte_table_hash_crc_key48;
 			break;
 
 		case 56:
-			params->lb.f_hash = hash_default_key56;
+			params->lb.f_hash = rte_table_hash_crc_key56;
 			break;
 
 		case 64:
-			params->lb.f_hash = hash_default_key64;
+			params->lb.f_hash = rte_table_hash_crc_key64;
 			break;
 
 		default:
@@ -223,35 +223,35 @@ softnic_table_action_profile_create(struct pmd_internals *p,
 		params->lb.f_hash == NULL) {
 		switch (params->lb.key_size) {
 		case 8:
-			params->lb.f_hash = hash_default_key8;
+			params->lb.f_hash = rte_table_hash_crc_key8;
 			break;
 
 		case 16:
-			params->lb.f_hash = hash_default_key16;
+			params->lb.f_hash = rte_table_hash_crc_key16;
 			break;
 
 		case 24:
-			params->lb.f_hash = hash_default_key24;
+			params->lb.f_hash = rte_table_hash_crc_key24;
 			break;
 
 		case 32:
-			params->lb.f_hash = hash_default_key32;
+			params->lb.f_hash = rte_table_hash_crc_key32;
 			break;
 
 		case 40:
-			params->lb.f_hash = hash_default_key40;
+			params->lb.f_hash = rte_table_hash_crc_key40;
 			break;
 
 		case 48:
-			params->lb.f_hash = hash_default_key48;
+			params->lb.f_hash = rte_table_hash_crc_key48;
 			break;
 
 		case 56:
-			params->lb.f_hash = hash_default_key56;
+			params->lb.f_hash = rte_table_hash_crc_key56;
 			break;
 
 		case 64:
-			params->lb.f_hash = hash_default_key64;
+			params->lb.f_hash = rte_table_hash_crc_key64;
 			break;
 
 		default:
drivers/net/softnic/rte_eth_softnic_pipeline.c +9 -10
index 45136a4..0aababe 100644
@@ -19,14 +19,13 @@
 #include <rte_table_acl.h>
 #include <rte_table_array.h>
 #include <rte_table_hash.h>
+#include <rte_table_hash_func.h>
 #include <rte_table_lpm.h>
 #include <rte_table_lpm_ipv6.h>
 #include <rte_table_stub.h>
 
 #include "rte_eth_softnic_internals.h"
 
-#include "hash_func.h"
-
 #ifndef PIPELINE_MSGQ_SIZE
 #define PIPELINE_MSGQ_SIZE                                 64
 #endif
@@ -797,28 +796,28 @@ softnic_pipeline_table_create(struct pmd_internals *softnic,
 
 		switch (params->match.hash.key_size) {
 		case  8:
-			f_hash = hash_default_key8;
+			f_hash = rte_table_hash_crc_key8;
 			break;
 		case 16:
-			f_hash = hash_default_key16;
+			f_hash = rte_table_hash_crc_key16;
 			break;
 		case 24:
-			f_hash = hash_default_key24;
+			f_hash = rte_table_hash_crc_key24;
 			break;
 		case 32:
-			f_hash = hash_default_key32;
+			f_hash = rte_table_hash_crc_key32;
 			break;
 		case 40:
-			f_hash = hash_default_key40;
+			f_hash = rte_table_hash_crc_key40;
 			break;
 		case 48:
-			f_hash = hash_default_key48;
+			f_hash = rte_table_hash_crc_key48;
 			break;
 		case 56:
-			f_hash = hash_default_key56;
+			f_hash = rte_table_hash_crc_key56;
 			break;
 		case 64:
-			f_hash = hash_default_key64;
+			f_hash = rte_table_hash_crc_key64;
 			break;
 		default:
 			return -1;
Signature · 1 line
2.9.5
#4 lore raw

Re: [PATCH v3 3/3] net/softnic: modify softnic to use librte_table headers

Quoted 12 lines

-----Original Message-----
From: Kevin Laatz <[email protected]>
Sent: Friday, September 7, 2018 6:06 PM
To: [email protected]
Cc: [email protected]; Jianbo Liu <[email protected]>; Gavin Hu (Arm Technology China) <[email protected]>; [email protected]; Kevin Laatz <[email protected]>
Subject: [PATCH v3 3/3] net/softnic: modify softnic to use librte_table headers

Quoted 8 lines

This commit modifies SoftNIC to make use of the new header files in librte_table.

As we are now using the new header files in librte_table in SoftNIC, we no longer need the old header files so they can be removed.

Quoted 816 lines
---
 drivers/net/softnic/hash_func.h                | 359 -------------------------
 drivers/net/softnic/hash_func_arm64.h          | 261 ------------------
 drivers/net/softnic/rte_eth_softnic_action.c   |  34 +--
 drivers/net/softnic/rte_eth_softnic_pipeline.c |  19 +-
 4 files changed, 26 insertions(+), 647 deletions(-)  delete mode 100644

drivers/net/softnic/hash_func.h delete mode 100644 drivers/net/softnic/hash_func_arm64.h

(quoted diff) +0 -0

b/drivers/net/softnic/hash_func.h deleted file mode 100644 index 198d2b2..0000000

drivers/net/softnic/hash_func.h deleted +0 -359
@@ -1,359 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2010-2018 Intel Corporation
- */
-
-#ifndef __INCLUDE_HASH_FUNC_H__
-#define __INCLUDE_HASH_FUNC_H__
-
-#include <rte_common.h>
-
-static inline uint64_t
-hash_xor_key8(void *key, void *mask, __rte_unused uint32_t key_size,
-uint64_t seed)
-{
-uint64_t *k = key;
-uint64_t *m = mask;
-uint64_t xor0;
-
-xor0 = seed ^ (k[0] & m[0]);
-
-return (xor0 >> 32) ^ xor0;
-}
-
-static inline uint64_t
-hash_xor_key16(void *key, void *mask, __rte_unused uint32_t key_size,
-uint64_t seed)
-{
-uint64_t *k = key;
-uint64_t *m = mask;
-uint64_t xor0;
-
-xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
-
-return (xor0 >> 32) ^ xor0;
-}
-
-static inline uint64_t
-hash_xor_key24(void *key, void *mask, __rte_unused uint32_t key_size,
-uint64_t seed)
-{
-uint64_t *k = key;
-uint64_t *m = mask;
-uint64_t xor0;
-
-xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
-
-xor0 ^= k[2] & m[2];
-
-return (xor0 >> 32) ^ xor0;
-}
-
-static inline uint64_t
-hash_xor_key32(void *key, void *mask, __rte_unused uint32_t key_size,
-uint64_t seed)
-{
-uint64_t *k = key;
-uint64_t *m = mask;
-uint64_t xor0, xor1;
-
-xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
-xor1 = (k[2] & m[2]) ^ (k[3] & m[3]);
-
-xor0 ^= xor1;
-
-return (xor0 >> 32) ^ xor0;
-}
-
-static inline uint64_t
-hash_xor_key40(void *key, void *mask, __rte_unused uint32_t key_size,
-uint64_t seed)
-{
-uint64_t *k = key;
-uint64_t *m = mask;
-uint64_t xor0, xor1;
-
-xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
-xor1 = (k[2] & m[2]) ^ (k[3] & m[3]);
-
-xor0 ^= xor1;
-
-xor0 ^= k[4] & m[4];
-
-return (xor0 >> 32) ^ xor0;
-}
-
-static inline uint64_t
-hash_xor_key48(void *key, void *mask, __rte_unused uint32_t key_size,
-uint64_t seed)
-{
-uint64_t *k = key;
-uint64_t *m = mask;
-uint64_t xor0, xor1, xor2;
-
-xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
-xor1 = (k[2] & m[2]) ^ (k[3] & m[3]);
-xor2 = (k[4] & m[4]) ^ (k[5] & m[5]);
-
-xor0 ^= xor1;
-
-xor0 ^= xor2;
-
-return (xor0 >> 32) ^ xor0;
-}
-
-static inline uint64_t
-hash_xor_key56(void *key, void *mask, __rte_unused uint32_t key_size,
-uint64_t seed)
-{
-uint64_t *k = key;
-uint64_t *m = mask;
-uint64_t xor0, xor1, xor2;
-
-xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
-xor1 = (k[2] & m[2]) ^ (k[3] & m[3]);
-xor2 = (k[4] & m[4]) ^ (k[5] & m[5]);
-
-xor0 ^= xor1;
-xor2 ^= k[6] & m[6];
-
-xor0 ^= xor2;
-
-return (xor0 >> 32) ^ xor0;
-}
-
-static inline uint64_t
-hash_xor_key64(void *key, void *mask, __rte_unused uint32_t key_size,
-uint64_t seed)
-{
-uint64_t *k = key;
-uint64_t *m = mask;
-uint64_t xor0, xor1, xor2, xor3;
-
-xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
-xor1 = (k[2] & m[2]) ^ (k[3] & m[3]);
-xor2 = (k[4] & m[4]) ^ (k[5] & m[5]);
-xor3 = (k[6] & m[6]) ^ (k[7] & m[7]);
-
-xor0 ^= xor1;
-xor2 ^= xor3;
-
-xor0 ^= xor2;
-
-return (xor0 >> 32) ^ xor0;
-}
-
-#if defined(RTE_ARCH_X86_64)
-
-#include <x86intrin.h>
-
-static inline uint64_t
-hash_crc_key8(void *key, void *mask, __rte_unused uint32_t key_size,
-uint64_t seed)
-{
-uint64_t *k = key;
-uint64_t *m = mask;
-uint64_t crc0;
-
-crc0 = _mm_crc32_u64(seed, k[0] & m[0]);
-
-return crc0;
-}
-
-static inline uint64_t
-hash_crc_key16(void *key, void *mask, __rte_unused uint32_t key_size,
-uint64_t seed)
-{
-uint64_t *k = key;
-uint64_t *m = mask;
-uint64_t k0, crc0, crc1;
-
-k0 = k[0] & m[0];
-
-crc0 = _mm_crc32_u64(k0, seed);
-crc1 = _mm_crc32_u64(k0 >> 32, k[1] & m[1]);
-
-crc0 ^= crc1;
-
-return crc0;
-}
-
-static inline uint64_t
-hash_crc_key24(void *key, void *mask, __rte_unused uint32_t key_size,
-uint64_t seed)
-{
-uint64_t *k = key;
-uint64_t *m = mask;
-uint64_t k0, k2, crc0, crc1;
-
-k0 = k[0] & m[0];
-k2 = k[2] & m[2];
-
-crc0 = _mm_crc32_u64(k0, seed);
-crc1 = _mm_crc32_u64(k0 >> 32, k[1] & m[1]);
-
-crc0 = _mm_crc32_u64(crc0, k2);
-
-crc0 ^= crc1;
-
-return crc0;
-}
-
-static inline uint64_t
-hash_crc_key32(void *key, void *mask, __rte_unused uint32_t key_size,
-uint64_t seed)
-{
-uint64_t *k = key;
-uint64_t *m = mask;
-uint64_t k0, k2, crc0, crc1, crc2, crc3;
-
-k0 = k[0] & m[0];
-k2 = k[2] & m[2];
-
-crc0 = _mm_crc32_u64(k0, seed);
-crc1 = _mm_crc32_u64(k0 >> 32, k[1] & m[1]);
-
-crc2 = _mm_crc32_u64(k2, k[3] & m[3]);
-crc3 = k2 >> 32;
-
-crc0 = _mm_crc32_u64(crc0, crc1);
-crc1 = _mm_crc32_u64(crc2, crc3);
-
-crc0 ^= crc1;
-
-return crc0;
-}
-
-static inline uint64_t
-hash_crc_key40(void *key, void *mask, __rte_unused uint32_t key_size,
-uint64_t seed)
-{
-uint64_t *k = key;
-uint64_t *m = mask;
-uint64_t k0, k2, crc0, crc1, crc2, crc3;
-
-k0 = k[0] & m[0];
-k2 = k[2] & m[2];
-
-crc0 = _mm_crc32_u64(k0, seed);
-crc1 = _mm_crc32_u64(k0 >> 32, k[1] & m[1]);
-
-crc2 = _mm_crc32_u64(k2, k[3] & m[3]);
-crc3 = _mm_crc32_u64(k2 >> 32, k[4] & m[4]);
-
-crc0 = _mm_crc32_u64(crc0, crc1);
-crc1 = _mm_crc32_u64(crc2, crc3);
-
-crc0 ^= crc1;
-
-return crc0;
-}
-
-static inline uint64_t
-hash_crc_key48(void *key, void *mask, __rte_unused uint32_t key_size,
-uint64_t seed)
-{
-uint64_t *k = key;
-uint64_t *m = mask;
-uint64_t k0, k2, k5, crc0, crc1, crc2, crc3;
-
-k0 = k[0] & m[0];
-k2 = k[2] & m[2];
-k5 = k[5] & m[5];
-
-crc0 = _mm_crc32_u64(k0, seed);
-crc1 = _mm_crc32_u64(k0 >> 32, k[1] & m[1]);
-
-crc2 = _mm_crc32_u64(k2, k[3] & m[3]);
-crc3 = _mm_crc32_u64(k2 >> 32, k[4] & m[4]);
-
-crc0 = _mm_crc32_u64(crc0, (crc1 << 32) ^ crc2);
-crc1 = _mm_crc32_u64(crc3, k5);
-
-crc0 ^= crc1;
-
-return crc0;
-}
-
-static inline uint64_t
-hash_crc_key56(void *key, void *mask, __rte_unused uint32_t key_size,
-uint64_t seed)
-{
-uint64_t *k = key;
-uint64_t *m = mask;
-uint64_t k0, k2, k5, crc0, crc1, crc2, crc3, crc4, crc5;
-
-k0 = k[0] & m[0];
-k2 = k[2] & m[2];
-k5 = k[5] & m[5];
-
-crc0 = _mm_crc32_u64(k0, seed);
-crc1 = _mm_crc32_u64(k0 >> 32, k[1] & m[1]);
-
-crc2 = _mm_crc32_u64(k2, k[3] & m[3]);
-crc3 = _mm_crc32_u64(k2 >> 32, k[4] & m[4]);
-
-crc4 = _mm_crc32_u64(k5, k[6] & m[6]);
-crc5 = k5 >> 32;
-
-crc0 = _mm_crc32_u64(crc0, (crc1 << 32) ^ crc2);
-crc1 = _mm_crc32_u64(crc3, (crc4 << 32) ^ crc5);
-
-crc0 ^= crc1;
-
-return crc0;
-}
-
-static inline uint64_t
-hash_crc_key64(void *key, void *mask, __rte_unused uint32_t key_size,
-uint64_t seed)
-{
-uint64_t *k = key;
-uint64_t *m = mask;
-uint64_t k0, k2, k5, crc0, crc1, crc2, crc3, crc4, crc5;
-
-k0 = k[0] & m[0];
-k2 = k[2] & m[2];
-k5 = k[5] & m[5];
-
-crc0 = _mm_crc32_u64(k0, seed);
-crc1 = _mm_crc32_u64(k0 >> 32, k[1] & m[1]);
-
-crc2 = _mm_crc32_u64(k2, k[3] & m[3]);
-crc3 = _mm_crc32_u64(k2 >> 32, k[4] & m[4]);
-
-crc4 = _mm_crc32_u64(k5, k[6] & m[6]);
-crc5 = _mm_crc32_u64(k5 >> 32, k[7] & m[7]);
-
-crc0 = _mm_crc32_u64(crc0, (crc1 << 32) ^ crc2);
-crc1 = _mm_crc32_u64(crc3, (crc4 << 32) ^ crc5);
-
-crc0 ^= crc1;
-
-return crc0;
-}
-
-#define hash_default_key8hash_crc_key8
-#define hash_default_key16hash_crc_key16
-#define hash_default_key24hash_crc_key24
-#define hash_default_key32hash_crc_key32
-#define hash_default_key40hash_crc_key40
-#define hash_default_key48hash_crc_key48
-#define hash_default_key56hash_crc_key56
-#define hash_default_key64hash_crc_key64
-
-#elif defined(RTE_ARCH_ARM64)
-#include "hash_func_arm64.h"
-#else
-
-#define hash_default_key8hash_xor_key8
-#define hash_default_key16hash_xor_key16
-#define hash_default_key24hash_xor_key24
-#define hash_default_key32hash_xor_key32
-#define hash_default_key40hash_xor_key40
-#define hash_default_key48hash_xor_key48
-#define hash_default_key56hash_xor_key56
-#define hash_default_key64hash_xor_key64
-
-#endif
-
-#endif
drivers/net/softnic/hash_func_arm64.h deleted +0 -21
deleted file mode 100644
index ae6c0f4..0000000
@@ -1,261 +0,0 @@
-/*-
- *   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.
- */

drivers/net/softnic/hash_func_arm64.h deleted +0 -229
-#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, void *mask, __rte_unused uint32_t key_size,
-uint64_t seed)
-{
-uint64_t *k = key;
-uint64_t *m = mask;
-uint32_t crc0;
-
-crc0 = seed;
-_CRC32CX(crc0, k[0] & m[0]);
-
-return crc0;
-}
-
-static inline uint64_t
-hash_crc_key16(void *key, void *mask, __rte_unused uint32_t key_size,
-uint64_t seed)
-{
-uint64_t *k = key, k0;
-uint64_t *m = mask;
-uint32_t crc0, crc1;
-
-k0 = k[0] & m[0];
-
-crc0 = k0;
-_CRC32CX(crc0, seed);
-crc1 = k0 >> 32;
-_CRC32CX(crc1, k[1] & m[1]);
-
-crc0 ^= crc1;
-
-return crc0;
-}
-
-static inline uint64_t
-hash_crc_key24(void *key, void *mask, __rte_unused uint32_t key_size,
-uint64_t seed)
-{
-uint64_t *k = key, k0, k2;
-uint64_t *m = mask;
-uint32_t crc0, crc1;
-
-k0 = k[0] & m[0];
-k2 = k[2] & m[2];
-
-crc0 = k0;
-_CRC32CX(crc0, seed);
-crc1 = k0 >> 32;
-_CRC32CX(crc1, k[1] & m[1]);
-
-_CRC32CX(crc0, k2);
-
-crc0 ^= crc1;
-
-return crc0;
-}
-
-static inline uint64_t
-hash_crc_key32(void *key, void *mask, __rte_unused uint32_t key_size,
-uint64_t seed)
-{
-uint64_t *k = key, k0, k2;
-uint64_t *m = mask;
-uint32_t crc0, crc1, crc2, crc3;
-
-k0 = k[0] & m[0];
-k2 = k[2] & m[2];
-
-crc0 = k0;
-_CRC32CX(crc0, seed);
-crc1 = k0 >> 32;
-_CRC32CX(crc1, k[1] & m[1]);
-
-crc2 = k2;
-_CRC32CX(crc2, k[3] & m[3]);
-crc3 = k2 >> 32;
-
-_CRC32CX(crc0, crc1);
-_CRC32CX(crc2, crc3);
-
-crc0 ^= crc2;
-
-return crc0;
-}
-
-static inline uint64_t
-hash_crc_key40(void *key, void *mask, __rte_unused uint32_t key_size,
-uint64_t seed)
-{
-uint64_t *k = key, k0, k2;
-uint64_t *m = mask;
-uint32_t crc0, crc1, crc2, crc3;
-
-k0 = k[0] & m[0];
-k2 = k[2] & m[2];
-
-crc0 = k0;
-_CRC32CX(crc0, seed);
-crc1 = k0 >> 32;
-_CRC32CX(crc1, k[1] & m[1]);
-
-crc2 = k2;
-_CRC32CX(crc2, k[3] & m[3]);
-crc3 = k2 >> 32;
-_CRC32CX(crc3, k[4] & m[4]);
-
-_CRC32CX(crc0, crc1);
-_CRC32CX(crc2, crc3);
-
-crc0 ^= crc2;
-
-return crc0;
-}
-
-static inline uint64_t
-hash_crc_key48(void *key, void *mask, __rte_unused uint32_t key_size,
-uint64_t seed)
-{
-uint64_t *k = key, k0, k2, k5;
-uint64_t *m = mask;
-uint32_t crc0, crc1, crc2, crc3;
-
-k0 = k[0] & m[0];
-k2 = k[2] & m[2];
-k5 = k[5] & m[5];
-
-crc0 = k0;
-_CRC32CX(crc0, seed);
-crc1 = k0 >> 32;
-_CRC32CX(crc1, k[1] & m[1]);
-
-crc2 = k2;
-_CRC32CX(crc2, k[3] & m[3]);
-crc3 = k2 >> 32;
-_CRC32CX(crc3, k[4] & m[4]);
-
-_CRC32CX(crc0, ((uint64_t)crc1 << 32) ^ crc2);
-_CRC32CX(crc3, k5);
-
-crc0 ^= crc3;
-
-return crc0;
-}
-
-static inline uint64_t
-hash_crc_key56(void *key, void *mask, __rte_unused uint32_t key_size,
-uint64_t seed)
-{
-uint64_t *k = key, k0, k2, k5;
-uint64_t *m = mask;
-uint32_t crc0, crc1, crc2, crc3, crc4, crc5;
-
-k0 = k[0] & m[0];
-k2 = k[2] & m[2];
-k5 = k[5] & m[5];
-
-crc0 = k0;
-_CRC32CX(crc0, seed);
-crc1 = k0 >> 32;
-_CRC32CX(crc1, k[1] & m[1]);
-
-crc2 = k2;
-_CRC32CX(crc2, k[3] & m[3]);
-crc3 = k2 >> 32;
-_CRC32CX(crc3, k[4] & m[4]);
-
-crc4 = k5;
- _CRC32CX(crc4, k[6] & m[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, void *mask, __rte_unused uint32_t key_size,
-uint64_t seed)
-{
-uint64_t *k = key, k0, k2, k5;
-uint64_t *m = mask;
-uint32_t crc0, crc1, crc2, crc3, crc4, crc5;
-
-k0 = k[0] & m[0];
-k2 = k[2] & m[2];
-k5 = k[5] & m[5];
-
-crc0 = k0;
-_CRC32CX(crc0, seed);
-crc1 = k0 >> 32;
-_CRC32CX(crc1, k[1] & m[1]);
-
-crc2 = k2;
-_CRC32CX(crc2, k[3] & m[3]);
-crc3 = k2 >> 32;
-_CRC32CX(crc3, k[4] & m[4]);
-
-crc4 = k5;
- _CRC32CX(crc4, k[6] & m[6]);
-crc5 = k5 >> 32;
-_CRC32CX(crc5, k[7] & m[7]);
-
-_CRC32CX(crc0, ((uint64_t)crc1 << 32) ^ crc2);
-_CRC32CX(crc3, ((uint64_t)crc4 << 32) ^ crc5);
-
-crc0 ^= crc3;
-
-return crc0;
-}
-
-#define hash_default_key8hash_crc_key8
-#define hash_default_key16hash_crc_key16
-#define hash_default_key24hash_crc_key24
-#define hash_default_key32hash_crc_key32
-#define hash_default_key40hash_crc_key40
-#define hash_default_key48hash_crc_key48
-#define hash_default_key56hash_crc_key56
-#define hash_default_key64hash_crc_key64
-
-#endif
drivers/net/softnic/rte_eth_softnic_action.c +9 -9
index c25f4dd..c542688 100644
@@ -7,8 +7,8 @@
 #include <string.h>
 
 #include <rte_string_fns.h>
+#include <rte_table_hash_func.h>
 
-#include "hash_func.h"
 #include "rte_eth_softnic_internals.h"
 
 /**
@@ -72,35 +72,35 @@ softnic_port_in_action_profile_create(struct
 pmd_internals *p,
 params->lb.f_hash == NULL) {
 switch (params->lb.key_size) {
 case  8:
-params->lb.f_hash = hash_default_key8;
+params->lb.f_hash = rte_table_hash_crc_key8;
 break;
 
 case 16:
-params->lb.f_hash = hash_default_key16;
+params->lb.f_hash = rte_table_hash_crc_key16;
 break;
 
 case 24:
-params->lb.f_hash = hash_default_key24;
+params->lb.f_hash = rte_table_hash_crc_key24;
 break;
 
 case 32:
-params->lb.f_hash = hash_default_key32;
+params->lb.f_hash = rte_table_hash_crc_key32;
 break;
 
 case 40:
-params->lb.f_hash = hash_default_key40;
+params->lb.f_hash = rte_table_hash_crc_key40;
 break;
 
 case 48:
-params->lb.f_hash = hash_default_key48;
+params->lb.f_hash = rte_table_hash_crc_key48;
 break;
 
 case 56:
-params->lb.f_hash = hash_default_key56;
+params->lb.f_hash = rte_table_hash_crc_key56;
 break;
 
 case 64:
-params->lb.f_hash = hash_default_key64;
+params->lb.f_hash = rte_table_hash_crc_key64;
 break;
 

default:

drivers/net/softnic/rte_eth_softnic_action.c +8 -8
@@ -223,35 +223,35 @@ softnic_table_action_profile_create(struct
 pmd_internals *p,
 params->lb.f_hash == NULL) {
 switch (params->lb.key_size) {
 case 8:
-params->lb.f_hash = hash_default_key8;
+params->lb.f_hash = rte_table_hash_crc_key8;
 break;
 
 case 16:
-params->lb.f_hash = hash_default_key16;
+params->lb.f_hash = rte_table_hash_crc_key16;
 break;
 
 case 24:
-params->lb.f_hash = hash_default_key24;
+params->lb.f_hash = rte_table_hash_crc_key24;
 break;
 
 case 32:
-params->lb.f_hash = hash_default_key32;
+params->lb.f_hash = rte_table_hash_crc_key32;
 break;
 
 case 40:
-params->lb.f_hash = hash_default_key40;
+params->lb.f_hash = rte_table_hash_crc_key40;
 break;
 
 case 48:
-params->lb.f_hash = hash_default_key48;
+params->lb.f_hash = rte_table_hash_crc_key48;
 break;
 
 case 56:
-params->lb.f_hash = hash_default_key56;
+params->lb.f_hash = rte_table_hash_crc_key56;
 break;
 
 case 64:
-params->lb.f_hash = hash_default_key64;
+params->lb.f_hash = rte_table_hash_crc_key64;
 break;
 

default:

drivers/net/softnic/rte_eth_softnic_pipeline.c +9 -10
index 45136a4..0aababe 100644
@@ -19,14 +19,13 @@
 #include <rte_table_acl.h>
 #include <rte_table_array.h>
 #include <rte_table_hash.h>
+#include <rte_table_hash_func.h>
 #include <rte_table_lpm.h>
 #include <rte_table_lpm_ipv6.h>
 #include <rte_table_stub.h>
 
 #include "rte_eth_softnic_internals.h"
 
-#include "hash_func.h"
-
 #ifndef PIPELINE_MSGQ_SIZE
 #define PIPELINE_MSGQ_SIZE                                 64
 #endif
@@ -797,28 +796,28 @@ softnic_pipeline_table_create(struct
 pmd_internals *softnic,
 
 switch (params->match.hash.key_size) {
 case  8:
-f_hash = hash_default_key8;
+f_hash = rte_table_hash_crc_key8;
 break;
 case 16:
-f_hash = hash_default_key16;
+f_hash = rte_table_hash_crc_key16;
 break;
 case 24:
-f_hash = hash_default_key24;
+f_hash = rte_table_hash_crc_key24;
 break;
 case 32:
-f_hash = hash_default_key32;
+f_hash = rte_table_hash_crc_key32;
 break;
 case 40:
-f_hash = hash_default_key40;
+f_hash = rte_table_hash_crc_key40;
 break;
 case 48:
-f_hash = hash_default_key48;
+f_hash = rte_table_hash_crc_key48;
 break;
 case 56:
-f_hash = hash_default_key56;
+f_hash = rte_table_hash_crc_key56;
 break;
 case 64:
-f_hash = hash_default_key64;
+f_hash = rte_table_hash_crc_key64;
 break;
 default:
Quoted 3 lines

return -1;
--
2.9.5

IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please 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.

#5 lore raw
In reply to Kevin Laatz

-----Original Message-----

Quoted 16 lines

Date: Fri, 7 Sep 2018 11:06:24 +0100
From: Kevin Laatz <[email protected]>
To: [email protected]
CC: [email protected], [email protected], [email protected],
[email protected], Kevin Laatz <[email protected]>
Subject: [PATCH v3 1/3] lib/librte_table: add hash_func header files
X-Mailer: git-send-email 2.9.5

This commit adds rte_table_hash_func.h and rte_table_hash_func_arm64.h to librte_table. This reduces code duplication by removing duplicate header files within two folders and consolidating them into a single one. This also adds a scalar implementation of the x86_64 intrinsic for crc32 as a generic fallback.

Quoted 7 lines

---
v2:
- Fixed typo in commit message
- Fixed typo in arm header that caused some compilations to fail for the entire patchset
v3:
- Improved commit message

ARM specific change and this patchset looks good. But, It has following checkpatches.sh and check-git-log.sh errors.

➜ [master][dpdk.org] $ ./devtools/checkpatches.sh

### lib/librte_table: add hash_func header files

WARNING:COMMIT_LOG_LONG_LINE: Possible unwrapped commit description (prefer a maximum 75 chars per line)
#7:
librte_table. This reduces code duplication by removing duplicate header files

total: 0 errors, 1 warnings, 298 lines checked
ERROR: symbol rte_crc32_u64_generic is added in a section other than the EXPERIMENTAL section of the version map
ERROR: symbol rte_table_hash_crc_key16 is added in a section other than the EXPERIMENTAL section of the version map
ERROR: symbol rte_table_hash_crc_key24 is added in a section other than the EXPERIMENTAL section of the version map
ERROR: symbol rte_table_hash_crc_key32 is added in a section other than the EXPERIMENTAL section of the version map
ERROR: symbol rte_table_hash_crc_key40 is added in a section other than the EXPERIMENTAL section of the version map
ERROR: symbol rte_table_hash_crc_key48 is added in a section other than the EXPERIMENTAL section of the version map
ERROR: symbol rte_table_hash_crc_key56 is added in a section other than the EXPERIMENTAL section of the version map
ERROR: symbol rte_table_hash_crc_key64 is added in a section other than the EXPERIMENTAL section of the version map
ERROR: symbol rte_table_hash_crc_key8 is added in a section other than the EXPERIMENTAL section of the version map

2/3 valid patches
➜ [master][dpdk.org] $ ./devtools/check-git-log.sh
Wrong headline format:
lib/librte_table: add hash_func header files examples/ip_pipeline: modify application to use librte_table
headers
net/softnic: modify softnic to use librte_table headers
Headline too long:
examples/ip_pipeline: modify application to use librte_table
headers
Line too long:
librte_table. This reduces code duplication by removing
duplicate header files
within two folders and consolidating them into a single one.
This also adds a
scalar implementation of the x86_64 intrinsic for crc32 as a
generic fallback.

#6 lore raw
Quoted 3 lines

ARM specific change and this patchset looks good. But, It has following checkpatches.sh and check-git-log.sh errors.

Thanks, Jerin, this looks like a map file issue, we'll work to fix it.

Regards,
Cristian

#7 lore raw

PATCH v4 1/3 lib/librte_table: add hash func header files

In reply to Kevin Laatz

This commit adds rte_table_hash_func.h and rte_table_hash_func_arm64.h to librte_table. This reduces code duplication by removing duplicate header files within two folders and consolidating them into a single one. This also adds a scalar implementation of the x86_64 intrinsic for crc32 as a generic fallback.

---
v2:
- Fixed typo in commit message
- Fixed typo in arm header that caused some compilations to fail for the entire patchset
v3:
- Improved commit message

v4:
- Fixed checkpatch.sh and check-git-log.sh errors

---
 lib/librte_table/Makefile                    |   2 +
 lib/librte_table/meson.build                 |   2 +
 lib/librte_table/rte_table_hash_func.h       | 245 +++++++++++++++++++++++++++
 lib/librte_table/rte_table_hash_func_arm64.h |  21 +++
 4 files changed, 270 insertions(+)
 create mode 100644 lib/librte_table/rte_table_hash_func.h
 create mode 100644 lib/librte_table/rte_table_hash_func_arm64.h
lib/librte_table/Makefile +2 -0
index 276d476..f935678 100644
@@ -46,6 +46,8 @@ SYMLINK-$(CONFIG_RTE_LIBRTE_TABLE)-include += rte_table_acl.h
 endif
 SYMLINK-$(CONFIG_RTE_LIBRTE_TABLE)-include += rte_table_hash.h
 SYMLINK-$(CONFIG_RTE_LIBRTE_TABLE)-include += rte_table_hash_cuckoo.h
+SYMLINK-$(CONFIG_RTE_LIBRTE_TABLE)-include += rte_table_hash_func.h
+SYMLINK-$(CONFIG_RTE_LIBRTE_TABLE)-include += rte_table_hash_func_arm64.h
 SYMLINK-$(CONFIG_RTE_LIBRTE_TABLE)-include += rte_lru.h
 ifeq ($(CONFIG_RTE_ARCH_X86),y)
 SYMLINK-$(CONFIG_RTE_LIBRTE_TABLE)-include += rte_lru_x86.h
lib/librte_table/meson.build +2 -0
index 8b2f841..6ae3cd6 100644
@@ -19,6 +19,8 @@ headers = 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')
lib/librte_table/rte_table_hash_func.h new file +245 -0

245 lines not on this page · raw message

lib/librte_table/rte_table_hash_func_arm64.h new file +21 -0
new file mode 100644
index 0000000..eb04c1f
@@ -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 = crc;
+
+	_CRC32CX(crc32, v);
+
+	return crc32;
+}
+
+#endif
Signature · 1 line
2.9.5
#8 lore raw

PATCH v4 2/3 examples/ip_pipeline: modify to use new table lib headers

This commit modifies the IP Pipeline application to use the new header files in librte_table.

As we are now using the new header files, we can remove the old ones from the application directory.

---
 examples/ip_pipeline/action.c          |  34 ++--
 examples/ip_pipeline/hash_func.h       | 357 ---------------------------------
 examples/ip_pipeline/hash_func_arm64.h | 232 ---------------------
 examples/ip_pipeline/pipeline.c        |  19 +-
 4 files changed, 26 insertions(+), 616 deletions(-)
 delete mode 100644 examples/ip_pipeline/hash_func.h
 delete mode 100644 examples/ip_pipeline/hash_func_arm64.h
examples/ip_pipeline/action.c +17 -17
index a29c2b3..20497c3 100644
@@ -7,9 +7,9 @@
 #include <string.h>
 
 #include <rte_string_fns.h>
+#include <rte_table_hash_func.h>
 
 #include "action.h"
-#include "hash_func.h"
 
 /**
  * Input port
@@ -57,35 +57,35 @@ port_in_action_profile_create(const char *name,
 		(params->lb.f_hash == NULL)) {
 		switch (params->lb.key_size) {
 		case  8:
-			params->lb.f_hash = hash_default_key8;
+			params->lb.f_hash = rte_table_hash_crc_key8;
 			break;
 
 		case 16:
-			params->lb.f_hash = hash_default_key16;
+			params->lb.f_hash = rte_table_hash_crc_key16;
 			break;
 
 		case 24:
-			params->lb.f_hash = hash_default_key24;
+			params->lb.f_hash = rte_table_hash_crc_key24;
 			break;
 
 		case 32:
-			params->lb.f_hash = hash_default_key32;
+			params->lb.f_hash = rte_table_hash_crc_key32;
 			break;
 
 		case 40:
-			params->lb.f_hash = hash_default_key40;
+			params->lb.f_hash = rte_table_hash_crc_key40;
 			break;
 
 		case 48:
-			params->lb.f_hash = hash_default_key48;
+			params->lb.f_hash = rte_table_hash_crc_key48;
 			break;
 
 		case 56:
-			params->lb.f_hash = hash_default_key56;
+			params->lb.f_hash = rte_table_hash_crc_key56;
 			break;
 
 		case 64:
-			params->lb.f_hash = hash_default_key64;
+			params->lb.f_hash = rte_table_hash_crc_key64;
 			break;
 
 		default:
@@ -192,35 +192,35 @@ table_action_profile_create(const char *name,
 		(params->lb.f_hash == NULL)) {
 		switch (params->lb.key_size) {
 		case 8:
-			params->lb.f_hash = hash_default_key8;
+			params->lb.f_hash = rte_table_hash_crc_key8;
 			break;
 
 		case 16:
-			params->lb.f_hash = hash_default_key16;
+			params->lb.f_hash = rte_table_hash_crc_key16;
 			break;
 
 		case 24:
-			params->lb.f_hash = hash_default_key24;
+			params->lb.f_hash = rte_table_hash_crc_key24;
 			break;
 
 		case 32:
-			params->lb.f_hash = hash_default_key32;
+			params->lb.f_hash = rte_table_hash_crc_key32;
 			break;
 
 		case 40:
-			params->lb.f_hash = hash_default_key40;
+			params->lb.f_hash = rte_table_hash_crc_key40;
 			break;
 
 		case 48:
-			params->lb.f_hash = hash_default_key48;
+			params->lb.f_hash = rte_table_hash_crc_key48;
 			break;
 
 		case 56:
-			params->lb.f_hash = hash_default_key56;
+			params->lb.f_hash = rte_table_hash_crc_key56;
 			break;
 
 		case 64:
-			params->lb.f_hash = hash_default_key64;
+			params->lb.f_hash = rte_table_hash_crc_key64;
 			break;
 
 		default:
examples/ip_pipeline/hash_func.h deleted +0 -357

357 lines not on this page · raw message

examples/ip_pipeline/hash_func_arm64.h deleted +0 -232

232 lines not on this page · raw message

examples/ip_pipeline/pipeline.c +9 -10
index 43fe867..b2fd215 100644
@@ -22,6 +22,7 @@
 #include <rte_table_acl.h>
 #include <rte_table_array.h>
 #include <rte_table_hash.h>
+#include <rte_table_hash_func.h>
 #include <rte_table_lpm.h>
 #include <rte_table_lpm_ipv6.h>
 #include <rte_table_stub.h>
@@ -36,8 +37,6 @@
 #include "tmgr.h"
 #include "swq.h"
 
-#include "hash_func.h"
-
 #ifndef PIPELINE_MSGQ_SIZE
 #define PIPELINE_MSGQ_SIZE                                 64
 #endif
@@ -818,28 +817,28 @@ pipeline_table_create(const char *pipeline_name,
 
 		switch (params->match.hash.key_size) {
 		case  8:
-			f_hash = hash_default_key8;
+			f_hash = rte_table_hash_crc_key8;
 			break;
 		case 16:
-			f_hash = hash_default_key16;
+			f_hash = rte_table_hash_crc_key16;
 			break;
 		case 24:
-			f_hash = hash_default_key24;
+			f_hash = rte_table_hash_crc_key24;
 			break;
 		case 32:
-			f_hash = hash_default_key32;
+			f_hash = rte_table_hash_crc_key32;
 			break;
 		case 40:
-			f_hash = hash_default_key40;
+			f_hash = rte_table_hash_crc_key40;
 			break;
 		case 48:
-			f_hash = hash_default_key48;
+			f_hash = rte_table_hash_crc_key48;
 			break;
 		case 56:
-			f_hash = hash_default_key56;
+			f_hash = rte_table_hash_crc_key56;
 			break;
 		case 64:
-			f_hash = hash_default_key64;
+			f_hash = rte_table_hash_crc_key64;
 			break;
 		default:
 			return -1;
Signature · 1 line
2.9.5
Acked-by on v4 2/3
#9 lore raw

Re: [PATCH v4 2/3] examples/ip_pipeline: modify to use new table lib headers

-----Original Message-----

Quoted 12 lines

Date: Tue, 25 Sep 2018 16:32:29 +0100
From: Kevin Laatz <[email protected]>
To: [email protected]
CC: [email protected], [email protected], [email protected],
[email protected], Kevin Laatz <[email protected]>
Subject: [PATCH v4 2/3] examples/ip_pipeline: modify to use new table lib
headers
X-Mailer: git-send-email 2.9.5

This commit modifies the IP Pipeline application to use the new header files in librte_table.

Quoted 6 lines

As we are now using the new header files, we can remove the old ones from the application directory.

#10 lore raw

PATCH v4 3/3 net/softnic: modify to use new table lib headers

In reply to Kevin Laatz

This commit modifies SoftNIC to make use of the new header files in librte_table.

As we are now using the new header files in librte_table in SoftNIC, we no longer need the old header files so they can be removed.

---
 drivers/net/softnic/hash_func.h                | 359 -------------------------
 drivers/net/softnic/hash_func_arm64.h          | 261 ------------------
 drivers/net/softnic/rte_eth_softnic_action.c   |  34 +--
 drivers/net/softnic/rte_eth_softnic_pipeline.c |  19 +-
 4 files changed, 26 insertions(+), 647 deletions(-)
 delete mode 100644 drivers/net/softnic/hash_func.h
 delete mode 100644 drivers/net/softnic/hash_func_arm64.h
drivers/net/softnic/hash_func.h deleted +0 -359
deleted file mode 100644
index 198d2b2..0000000
@@ -1,359 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2010-2018 Intel Corporation
- */
-
-#ifndef __INCLUDE_HASH_FUNC_H__
-#define __INCLUDE_HASH_FUNC_H__
-
-#include <rte_common.h>
-
-static inline uint64_t
-hash_xor_key8(void *key, void *mask, __rte_unused uint32_t key_size,
-	uint64_t seed)
-{
-	uint64_t *k = key;
-	uint64_t *m = mask;
-	uint64_t xor0;
-
-	xor0 = seed ^ (k[0] & m[0]);
-
-	return (xor0 >> 32) ^ xor0;
-}
-
-static inline uint64_t
-hash_xor_key16(void *key, void *mask, __rte_unused uint32_t key_size,
-	uint64_t seed)
-{
-	uint64_t *k = key;
-	uint64_t *m = mask;
-	uint64_t xor0;
-
-	xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
-
-	return (xor0 >> 32) ^ xor0;
-}
-
-static inline uint64_t
-hash_xor_key24(void *key, void *mask, __rte_unused uint32_t key_size,
-	uint64_t seed)
-{
-	uint64_t *k = key;
-	uint64_t *m = mask;
-	uint64_t xor0;
-
-	xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
-
-	xor0 ^= k[2] & m[2];
-
-	return (xor0 >> 32) ^ xor0;
-}
-
-static inline uint64_t
-hash_xor_key32(void *key, void *mask, __rte_unused uint32_t key_size,
-	uint64_t seed)
-{
-	uint64_t *k = key;
-	uint64_t *m = mask;
-	uint64_t xor0, xor1;
-
-	xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
-	xor1 = (k[2] & m[2]) ^ (k[3] & m[3]);
-
-	xor0 ^= xor1;
-
-	return (xor0 >> 32) ^ xor0;
-}
-
-static inline uint64_t
-hash_xor_key40(void *key, void *mask, __rte_unused uint32_t key_size,
-	uint64_t seed)
-{
-	uint64_t *k = key;
-	uint64_t *m = mask;
-	uint64_t xor0, xor1;
-
-	xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
-	xor1 = (k[2] & m[2]) ^ (k[3] & m[3]);
-
-	xor0 ^= xor1;
-
-	xor0 ^= k[4] & m[4];
-
-	return (xor0 >> 32) ^ xor0;
-}
-
-static inline uint64_t
-hash_xor_key48(void *key, void *mask, __rte_unused uint32_t key_size,
-	uint64_t seed)
-{
-	uint64_t *k = key;
-	uint64_t *m = mask;
-	uint64_t xor0, xor1, xor2;
-
-	xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
-	xor1 = (k[2] & m[2]) ^ (k[3] & m[3]);
-	xor2 = (k[4] & m[4]) ^ (k[5] & m[5]);
-
-	xor0 ^= xor1;
-
-	xor0 ^= xor2;
-
-	return (xor0 >> 32) ^ xor0;
-}
-
-static inline uint64_t
-hash_xor_key56(void *key, void *mask, __rte_unused uint32_t key_size,
-	uint64_t seed)
-{
-	uint64_t *k = key;
-	uint64_t *m = mask;
-	uint64_t xor0, xor1, xor2;
-
-	xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
-	xor1 = (k[2] & m[2]) ^ (k[3] & m[3]);
-	xor2 = (k[4] & m[4]) ^ (k[5] & m[5]);
-
-	xor0 ^= xor1;
-	xor2 ^= k[6] & m[6];
-
-	xor0 ^= xor2;
-
-	return (xor0 >> 32) ^ xor0;
-}
-
-static inline uint64_t
-hash_xor_key64(void *key, void *mask, __rte_unused uint32_t key_size,
-	uint64_t seed)
-{
-	uint64_t *k = key;
-	uint64_t *m = mask;
-	uint64_t xor0, xor1, xor2, xor3;
-
-	xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
-	xor1 = (k[2] & m[2]) ^ (k[3] & m[3]);
-	xor2 = (k[4] & m[4]) ^ (k[5] & m[5]);
-	xor3 = (k[6] & m[6]) ^ (k[7] & m[7]);
-
-	xor0 ^= xor1;
-	xor2 ^= xor3;
-
-	xor0 ^= xor2;
-
-	return (xor0 >> 32) ^ xor0;
-}
-
-#if defined(RTE_ARCH_X86_64)
-
-#include <x86intrin.h>
-
-static inline uint64_t
-hash_crc_key8(void *key, void *mask, __rte_unused uint32_t key_size,
-	uint64_t seed)
-{
-	uint64_t *k = key;
-	uint64_t *m = mask;
-	uint64_t crc0;
-
-	crc0 = _mm_crc32_u64(seed, k[0] & m[0]);
-
-	return crc0;
-}
-
-static inline uint64_t
-hash_crc_key16(void *key, void *mask, __rte_unused uint32_t key_size,
-	uint64_t seed)
-{
-	uint64_t *k = key;
-	uint64_t *m = mask;
-	uint64_t k0, crc0, crc1;
-
-	k0 = k[0] & m[0];
-
-	crc0 = _mm_crc32_u64(k0, seed);
-	crc1 = _mm_crc32_u64(k0 >> 32, k[1] & m[1]);
-
-	crc0 ^= crc1;
-
-	return crc0;
-}
-
-static inline uint64_t
-hash_crc_key24(void *key, void *mask, __rte_unused uint32_t key_size,
-	uint64_t seed)
-{
-	uint64_t *k = key;
-	uint64_t *m = mask;
-	uint64_t k0, k2, crc0, crc1;
-
-	k0 = k[0] & m[0];
-	k2 = k[2] & m[2];
-
-	crc0 = _mm_crc32_u64(k0, seed);
-	crc1 = _mm_crc32_u64(k0 >> 32, k[1] & m[1]);
-
-	crc0 = _mm_crc32_u64(crc0, k2);
-
-	crc0 ^= crc1;
-
-	return crc0;
-}
-
-static inline uint64_t
-hash_crc_key32(void *key, void *mask, __rte_unused uint32_t key_size,
-	uint64_t seed)
-{
-	uint64_t *k = key;
-	uint64_t *m = mask;
-	uint64_t k0, k2, crc0, crc1, crc2, crc3;
-
-	k0 = k[0] & m[0];
-	k2 = k[2] & m[2];
-
-	crc0 = _mm_crc32_u64(k0, seed);
-	crc1 = _mm_crc32_u64(k0 >> 32, k[1] & m[1]);
-
-	crc2 = _mm_crc32_u64(k2, k[3] & m[3]);
-	crc3 = k2 >> 32;
-
-	crc0 = _mm_crc32_u64(crc0, crc1);
-	crc1 = _mm_crc32_u64(crc2, crc3);
-
-	crc0 ^= crc1;
-
-	return crc0;
-}
-
-static inline uint64_t
-hash_crc_key40(void *key, void *mask, __rte_unused uint32_t key_size,
-	uint64_t seed)
-{
-	uint64_t *k = key;
-	uint64_t *m = mask;
-	uint64_t k0, k2, crc0, crc1, crc2, crc3;
-
-	k0 = k[0] & m[0];
-	k2 = k[2] & m[2];
-
-	crc0 = _mm_crc32_u64(k0, seed);
-	crc1 = _mm_crc32_u64(k0 >> 32, k[1] & m[1]);
-
-	crc2 = _mm_crc32_u64(k2, k[3] & m[3]);
-	crc3 = _mm_crc32_u64(k2 >> 32, k[4] & m[4]);
-
-	crc0 = _mm_crc32_u64(crc0, crc1);
-	crc1 = _mm_crc32_u64(crc2, crc3);
-
-	crc0 ^= crc1;
-
-	return crc0;
-}
-
-static inline uint64_t
-hash_crc_key48(void *key, void *mask, __rte_unused uint32_t key_size,
-	uint64_t seed)
-{
-	uint64_t *k = key;
-	uint64_t *m = mask;
-	uint64_t k0, k2, k5, crc0, crc1, crc2, crc3;
-
-	k0 = k[0] & m[0];
-	k2 = k[2] & m[2];
-	k5 = k[5] & m[5];
-
-	crc0 = _mm_crc32_u64(k0, seed);
-	crc1 = _mm_crc32_u64(k0 >> 32, k[1] & m[1]);
-
-	crc2 = _mm_crc32_u64(k2, k[3] & m[3]);
-	crc3 = _mm_crc32_u64(k2 >> 32, k[4] & m[4]);
-
-	crc0 = _mm_crc32_u64(crc0, (crc1 << 32) ^ crc2);
-	crc1 = _mm_crc32_u64(crc3, k5);
-
-	crc0 ^= crc1;
-
-	return crc0;
-}
-
-static inline uint64_t
-hash_crc_key56(void *key, void *mask, __rte_unused uint32_t key_size,
-	uint64_t seed)
-{
-	uint64_t *k = key;
-	uint64_t *m = mask;
-	uint64_t k0, k2, k5, crc0, crc1, crc2, crc3, crc4, crc5;
-
-	k0 = k[0] & m[0];
-	k2 = k[2] & m[2];
-	k5 = k[5] & m[5];
-
-	crc0 = _mm_crc32_u64(k0, seed);
-	crc1 = _mm_crc32_u64(k0 >> 32, k[1] & m[1]);
-
-	crc2 = _mm_crc32_u64(k2, k[3] & m[3]);
-	crc3 = _mm_crc32_u64(k2 >> 32, k[4] & m[4]);
-
-	crc4 = _mm_crc32_u64(k5, k[6] & m[6]);
-	crc5 = k5 >> 32;
-
-	crc0 = _mm_crc32_u64(crc0, (crc1 << 32) ^ crc2);
-	crc1 = _mm_crc32_u64(crc3, (crc4 << 32) ^ crc5);
-
-	crc0 ^= crc1;
-
-	return crc0;
-}
-
-static inline uint64_t
-hash_crc_key64(void *key, void *mask, __rte_unused uint32_t key_size,
-	uint64_t seed)
-{
-	uint64_t *k = key;
-	uint64_t *m = mask;
-	uint64_t k0, k2, k5, crc0, crc1, crc2, crc3, crc4, crc5;
-
-	k0 = k[0] & m[0];
-	k2 = k[2] & m[2];
-	k5 = k[5] & m[5];
-
-	crc0 = _mm_crc32_u64(k0, seed);
-	crc1 = _mm_crc32_u64(k0 >> 32, k[1] & m[1]);
-
-	crc2 = _mm_crc32_u64(k2, k[3] & m[3]);
-	crc3 = _mm_crc32_u64(k2 >> 32, k[4] & m[4]);
-
-	crc4 = _mm_crc32_u64(k5, k[6] & m[6]);
-	crc5 = _mm_crc32_u64(k5 >> 32, k[7] & m[7]);
-
-	crc0 = _mm_crc32_u64(crc0, (crc1 << 32) ^ crc2);
-	crc1 = _mm_crc32_u64(crc3, (crc4 << 32) ^ crc5);
-
-	crc0 ^= crc1;
-
-	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
-
-#elif defined(RTE_ARCH_ARM64)
-#include "hash_func_arm64.h"
-#else
-
-#define hash_default_key8			hash_xor_key8
-#define hash_default_key16			hash_xor_key16
-#define hash_default_key24			hash_xor_key24
-#define hash_default_key32			hash_xor_key32
-#define hash_default_key40			hash_xor_key40
-#define hash_default_key48			hash_xor_key48
-#define hash_default_key56			hash_xor_key56
-#define hash_default_key64			hash_xor_key64
-
-#endif
-
-#endif
drivers/net/softnic/hash_func_arm64.h deleted +0 -261

261 lines not on this page · raw message

drivers/net/softnic/rte_eth_softnic_action.c +17 -17
index c25f4dd..c542688 100644
@@ -7,8 +7,8 @@
 #include <string.h>
 
 #include <rte_string_fns.h>
+#include <rte_table_hash_func.h>
 
-#include "hash_func.h"
 #include "rte_eth_softnic_internals.h"
 
 /**
@@ -72,35 +72,35 @@ softnic_port_in_action_profile_create(struct pmd_internals *p,
 		params->lb.f_hash == NULL) {
 		switch (params->lb.key_size) {
 		case  8:
-			params->lb.f_hash = hash_default_key8;
+			params->lb.f_hash = rte_table_hash_crc_key8;
 			break;
 
 		case 16:
-			params->lb.f_hash = hash_default_key16;
+			params->lb.f_hash = rte_table_hash_crc_key16;
 			break;
 
 		case 24:
-			params->lb.f_hash = hash_default_key24;
+			params->lb.f_hash = rte_table_hash_crc_key24;
 			break;
 
 		case 32:
-			params->lb.f_hash = hash_default_key32;
+			params->lb.f_hash = rte_table_hash_crc_key32;
 			break;
 
 		case 40:
-			params->lb.f_hash = hash_default_key40;
+			params->lb.f_hash = rte_table_hash_crc_key40;
 			break;
 
 		case 48:
-			params->lb.f_hash = hash_default_key48;
+			params->lb.f_hash = rte_table_hash_crc_key48;
 			break;
 
 		case 56:
-			params->lb.f_hash = hash_default_key56;
+			params->lb.f_hash = rte_table_hash_crc_key56;
 			break;
 
 		case 64:
-			params->lb.f_hash = hash_default_key64;
+			params->lb.f_hash = rte_table_hash_crc_key64;
 			break;
 
 		default:
@@ -223,35 +223,35 @@ softnic_table_action_profile_create(struct pmd_internals *p,
 		params->lb.f_hash == NULL) {
 		switch (params->lb.key_size) {
 		case 8:
-			params->lb.f_hash = hash_default_key8;
+			params->lb.f_hash = rte_table_hash_crc_key8;
 			break;
 
 		case 16:
-			params->lb.f_hash = hash_default_key16;
+			params->lb.f_hash = rte_table_hash_crc_key16;
 			break;
 
 		case 24:
-			params->lb.f_hash = hash_default_key24;
+			params->lb.f_hash = rte_table_hash_crc_key24;
 			break;
 
 		case 32:
-			params->lb.f_hash = hash_default_key32;
+			params->lb.f_hash = rte_table_hash_crc_key32;
 			break;
 
 		case 40:
-			params->lb.f_hash = hash_default_key40;
+			params->lb.f_hash = rte_table_hash_crc_key40;
 			break;
 
 		case 48:
-			params->lb.f_hash = hash_default_key48;
+			params->lb.f_hash = rte_table_hash_crc_key48;
 			break;
 
 		case 56:
-			params->lb.f_hash = hash_default_key56;
+			params->lb.f_hash = rte_table_hash_crc_key56;
 			break;
 
 		case 64:
-			params->lb.f_hash = hash_default_key64;
+			params->lb.f_hash = rte_table_hash_crc_key64;
 			break;
 
 		default:
drivers/net/softnic/rte_eth_softnic_pipeline.c +9 -10
index 45136a4..0aababe 100644
@@ -19,14 +19,13 @@
 #include <rte_table_acl.h>
 #include <rte_table_array.h>
 #include <rte_table_hash.h>
+#include <rte_table_hash_func.h>
 #include <rte_table_lpm.h>
 #include <rte_table_lpm_ipv6.h>
 #include <rte_table_stub.h>
 
 #include "rte_eth_softnic_internals.h"
 
-#include "hash_func.h"
-
 #ifndef PIPELINE_MSGQ_SIZE
 #define PIPELINE_MSGQ_SIZE                                 64
 #endif
@@ -797,28 +796,28 @@ softnic_pipeline_table_create(struct pmd_internals *softnic,
 
 		switch (params->match.hash.key_size) {
 		case  8:
-			f_hash = hash_default_key8;
+			f_hash = rte_table_hash_crc_key8;
 			break;
 		case 16:
-			f_hash = hash_default_key16;
+			f_hash = rte_table_hash_crc_key16;
 			break;
 		case 24:
-			f_hash = hash_default_key24;
+			f_hash = rte_table_hash_crc_key24;
 			break;
 		case 32:
-			f_hash = hash_default_key32;
+			f_hash = rte_table_hash_crc_key32;
 			break;
 		case 40:
-			f_hash = hash_default_key40;
+			f_hash = rte_table_hash_crc_key40;
 			break;
 		case 48:
-			f_hash = hash_default_key48;
+			f_hash = rte_table_hash_crc_key48;
 			break;
 		case 56:
-			f_hash = hash_default_key56;
+			f_hash = rte_table_hash_crc_key56;
 			break;
 		case 64:
-			f_hash = hash_default_key64;
+			f_hash = rte_table_hash_crc_key64;
 			break;
 		default:
 			return -1;
Signature · 1 line
2.9.5
Acked-by on v4 3/3
#11 lore raw

Re: [PATCH v4 3/3] net/softnic: modify to use new table lib headers

-----Original Message-----

Quoted 12 lines

Date: Tue, 25 Sep 2018 16:32:30 +0100
From: Kevin Laatz <[email protected]>
To: [email protected]
CC: [email protected], [email protected], [email protected],
[email protected], Kevin Laatz <[email protected]>
Subject: [PATCH v4 3/3] net/softnic: modify to use new table lib headers
X-Mailer: git-send-email 2.9.5

This commit modifies SoftNIC to make use of the new header files in librte_table.

Quoted 6 lines

As we are now using the new header files in librte_table in SoftNIC, we no longer need the old header files so they can be removed.

Acked-by on v4 1/3
#12 lore raw

Re: [PATCH v4 1/3] lib/librte_table: add hash func header files

In reply to Kevin Laatz

-----Original Message-----

Quoted 27 lines

Date: Tue, 25 Sep 2018 16:32:28 +0100
From: Kevin Laatz <[email protected]>
To: [email protected]
CC: [email protected], [email protected], [email protected],
[email protected], Kevin Laatz <[email protected]>
Subject: [PATCH v4 1/3] lib/librte_table: add hash func header files
X-Mailer: git-send-email 2.9.5

External Email

This commit adds rte_table_hash_func.h and rte_table_hash_func_arm64.h to librte_table. This reduces code duplication by removing duplicate header files within two folders and consolidating them into a single one. This also adds a scalar implementation of the x86_64 intrinsic for crc32 as a generic fallback.

---
v2:
- Fixed typo in commit message
- Fixed typo in arm header that caused some compilations to fail for the entire patchset
v3:
- Improved commit message

Quoted 2 lines

v4:
- Fixed checkpatch.sh and check-git-log.sh errors

#13 lore raw

Re: [PATCH v4 1/3] lib/librte_table: add hash func header files

In reply to Kevin Laatz
Quoted 18 lines

-----Original Message-----
From: Laatz, Kevin
Sent: Tuesday, September 25, 2018 4:32 PM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; Dumitrescu, Cristian <[email protected]>; Laatz, Kevin <[email protected]>
Subject: [PATCH v4 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 reduces code duplication by removing duplicate header files within two folders and consolidating them into a single one. This also adds a scalar implementation of the x86_64 intrinsic for crc32 as a generic fallback.

Quoted 4 lines

---

Patchset applied to next-pipeline tree, thanks!