5 #ifndef __INCLUDE_RTE_TABLE_HASH_FUNC_H__
6 #define __INCLUDE_RTE_TABLE_HASH_FUNC_H__
14 #include <rte_compat.h>
17 static inline uint64_t __rte_experimental
18 rte_crc32_u64_generic(uint64_t crc, uint64_t value)
22 crc = (crc & 0xFFFFFFFFLLU) ^ value;
23 for (i = 63; i >= 0; i--) {
27 crc = (crc >> 1LLU) ^ (0x82F63B78LLU & mask);
33 #if defined(RTE_ARCH_X86_64)
35 #include <x86intrin.h>
37 static inline uint64_t
38 rte_crc32_u64(uint64_t crc, uint64_t v)
40 return _mm_crc32_u64(crc, v);
43 #elif defined(RTE_ARCH_ARM64) && defined(RTE_MACHINE_CPUFLAG_CRC32)
44 #include "rte_table_hash_func_arm64.h"
47 static inline uint64_t
48 rte_crc32_u64(uint64_t crc, uint64_t v)
50 return rte_crc32_u64_generic(crc, v);
55 static inline uint64_t __rte_experimental
56 rte_table_hash_crc_key8(
void *key,
void *mask,
__rte_unused uint32_t key_size,
63 crc0 = rte_crc32_u64(seed, k[0] & m[0]);
68 static inline uint64_t __rte_experimental
69 rte_table_hash_crc_key16(
void *key,
void *mask,
__rte_unused uint32_t key_size,
74 uint64_t k0, crc0, crc1;
78 crc0 = rte_crc32_u64(k0, seed);
79 crc1 = rte_crc32_u64(k0 >> 32, k[1] & m[1]);
86 static inline uint64_t __rte_experimental
87 rte_table_hash_crc_key24(
void *key,
void *mask,
__rte_unused uint32_t key_size,
92 uint64_t k0, k2, crc0, crc1;
97 crc0 = rte_crc32_u64(k0, seed);
98 crc1 = rte_crc32_u64(k0 >> 32, k[1] & m[1]);
100 crc0 = rte_crc32_u64(crc0, k2);
107 static inline uint64_t __rte_experimental
108 rte_table_hash_crc_key32(
void *key,
void *mask,
__rte_unused uint32_t key_size,
113 uint64_t k0, k2, crc0, crc1, crc2, crc3;
118 crc0 = rte_crc32_u64(k0, seed);
119 crc1 = rte_crc32_u64(k0 >> 32, k[1] & m[1]);
121 crc2 = rte_crc32_u64(k2, k[3] & m[3]);
124 crc0 = rte_crc32_u64(crc0, crc1);
125 crc1 = rte_crc32_u64(crc2, crc3);
132 static inline uint64_t __rte_experimental
133 rte_table_hash_crc_key40(
void *key,
void *mask,
__rte_unused uint32_t key_size,
138 uint64_t k0, k2, crc0, crc1, crc2, crc3;
143 crc0 = rte_crc32_u64(k0, seed);
144 crc1 = rte_crc32_u64(k0 >> 32, k[1] & m[1]);
146 crc2 = rte_crc32_u64(k2, k[3] & m[3]);
147 crc3 = rte_crc32_u64(k2 >> 32, k[4] & m[4]);
149 crc0 = rte_crc32_u64(crc0, crc1);
150 crc1 = rte_crc32_u64(crc2, crc3);
157 static inline uint64_t __rte_experimental
158 rte_table_hash_crc_key48(
void *key,
void *mask,
__rte_unused uint32_t key_size,
163 uint64_t k0, k2, k5, crc0, crc1, crc2, crc3;
169 crc0 = rte_crc32_u64(k0, seed);
170 crc1 = rte_crc32_u64(k0 >> 32, k[1] & m[1]);
172 crc2 = rte_crc32_u64(k2, k[3] & m[3]);
173 crc3 = rte_crc32_u64(k2 >> 32, k[4] & m[4]);
175 crc0 = rte_crc32_u64(crc0, (crc1 << 32) ^ crc2);
176 crc1 = rte_crc32_u64(crc3, k5);
183 static inline uint64_t __rte_experimental
184 rte_table_hash_crc_key56(
void *key,
void *mask,
__rte_unused uint32_t key_size,
189 uint64_t k0, k2, k5, crc0, crc1, crc2, crc3, crc4, crc5;
195 crc0 = rte_crc32_u64(k0, seed);
196 crc1 = rte_crc32_u64(k0 >> 32, k[1] & m[1]);
198 crc2 = rte_crc32_u64(k2, k[3] & m[3]);
199 crc3 = rte_crc32_u64(k2 >> 32, k[4] & m[4]);
201 crc4 = rte_crc32_u64(k5, k[6] & m[6]);
204 crc0 = rte_crc32_u64(crc0, (crc1 << 32) ^ crc2);
205 crc1 = rte_crc32_u64(crc3, (crc4 << 32) ^ crc5);
212 static inline uint64_t __rte_experimental
213 rte_table_hash_crc_key64(
void *key,
void *mask,
__rte_unused uint32_t key_size,
218 uint64_t k0, k2, k5, crc0, crc1, crc2, crc3, crc4, crc5;
224 crc0 = rte_crc32_u64(k0, seed);
225 crc1 = rte_crc32_u64(k0 >> 32, k[1] & m[1]);
227 crc2 = rte_crc32_u64(k2, k[3] & m[3]);
228 crc3 = rte_crc32_u64(k2 >> 32, k[4] & m[4]);
230 crc4 = rte_crc32_u64(k5, k[6] & m[6]);
231 crc5 = rte_crc32_u64(k5 >> 32, k[7] & m[7]);
233 crc0 = rte_crc32_u64(crc0, (crc1 << 32) ^ crc2);
234 crc1 = rte_crc32_u64(crc3, (crc4 << 32) ^ crc5);