5 #ifndef __INCLUDE_RTE_TABLE_HASH_FUNC_H__ 6 #define __INCLUDE_RTE_TABLE_HASH_FUNC_H__ 14 #include <rte_compat.h> 17 #if defined(RTE_ARCH_X86_64) 19 #include <x86intrin.h> 21 static inline uint64_t
22 rte_crc32_u64(uint64_t crc, uint64_t v)
24 return _mm_crc32_u64(crc, v);
27 #elif defined(RTE_ARCH_ARM64) && defined(__ARM_FEATURE_CRC32) 28 #include "rte_table_hash_func_arm64.h" 31 static inline uint64_t
32 rte_crc32_u64(uint64_t crc, uint64_t v)
36 crc = (crc & 0xFFFFFFFFLLU) ^ v;
37 for (i = 63; i >= 0; i--) {
41 crc = (crc >> 1LLU) ^ (0x82F63B78LLU & mask);
50 static inline uint64_t
51 rte_table_hash_crc_key8(
void *key,
void *mask,
__rte_unused uint32_t key_size,
54 uint64_t *k = (uint64_t *)key;
55 uint64_t *m = (uint64_t *)mask;
58 crc0 = rte_crc32_u64(seed, k[0] & m[0]);
64 static inline uint64_t
65 rte_table_hash_crc_key16(
void *key,
void *mask,
__rte_unused uint32_t key_size,
68 uint64_t *k = (uint64_t *)key;
69 uint64_t *m = (uint64_t *)mask;
70 uint64_t k0, crc0, crc1;
74 crc0 = rte_crc32_u64(k0, seed);
75 crc1 = rte_crc32_u64(k0 >> 32, k[1] & m[1]);
83 static inline uint64_t
84 rte_table_hash_crc_key24(
void *key,
void *mask,
__rte_unused uint32_t key_size,
87 uint64_t *k = (uint64_t *)key;
88 uint64_t *m = (uint64_t *)mask;
89 uint64_t k0, k2, crc0, crc1;
94 crc0 = rte_crc32_u64(k0, seed);
95 crc1 = rte_crc32_u64(k0 >> 32, k[1] & m[1]);
97 crc0 = rte_crc32_u64(crc0, k2);
105 static inline uint64_t
106 rte_table_hash_crc_key32(
void *key,
void *mask,
__rte_unused uint32_t key_size,
109 uint64_t *k = (uint64_t *)key;
110 uint64_t *m = (uint64_t *)mask;
111 uint64_t k0, k2, crc0, crc1, crc2, crc3;
116 crc0 = rte_crc32_u64(k0, seed);
117 crc1 = rte_crc32_u64(k0 >> 32, k[1] & m[1]);
119 crc2 = rte_crc32_u64(k2, k[3] & m[3]);
122 crc0 = rte_crc32_u64(crc0, crc1);
123 crc1 = rte_crc32_u64(crc2, crc3);
131 static inline uint64_t
132 rte_table_hash_crc_key40(
void *key,
void *mask,
__rte_unused uint32_t key_size,
135 uint64_t *k = (uint64_t *)key;
136 uint64_t *m = (uint64_t *)mask;
137 uint64_t k0, k2, crc0, crc1, crc2, crc3;
142 crc0 = rte_crc32_u64(k0, seed);
143 crc1 = rte_crc32_u64(k0 >> 32, k[1] & m[1]);
145 crc2 = rte_crc32_u64(k2, k[3] & m[3]);
146 crc3 = rte_crc32_u64(k2 >> 32, k[4] & m[4]);
148 crc0 = rte_crc32_u64(crc0, crc1);
149 crc1 = rte_crc32_u64(crc2, crc3);
157 static inline uint64_t
158 rte_table_hash_crc_key48(
void *key,
void *mask,
__rte_unused uint32_t key_size,
161 uint64_t *k = (uint64_t *)key;
162 uint64_t *m = (uint64_t *)mask;
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);
184 static inline uint64_t
185 rte_table_hash_crc_key56(
void *key,
void *mask,
__rte_unused uint32_t key_size,
188 uint64_t *k = (uint64_t *)key;
189 uint64_t *m = (uint64_t *)mask;
190 uint64_t k0, k2, k5, crc0, crc1, crc2, crc3, crc4, crc5;
196 crc0 = rte_crc32_u64(k0, seed);
197 crc1 = rte_crc32_u64(k0 >> 32, k[1] & m[1]);
199 crc2 = rte_crc32_u64(k2, k[3] & m[3]);
200 crc3 = rte_crc32_u64(k2 >> 32, k[4] & m[4]);
202 crc4 = rte_crc32_u64(k5, k[6] & m[6]);
205 crc0 = rte_crc32_u64(crc0, (crc1 << 32) ^ crc2);
206 crc1 = rte_crc32_u64(crc3, (crc4 << 32) ^ crc5);
214 static inline uint64_t
215 rte_table_hash_crc_key64(
void *key,
void *mask,
__rte_unused uint32_t key_size,
218 uint64_t *k = (uint64_t *)key;
219 uint64_t *m = (uint64_t *)mask;
220 uint64_t k0, k2, k5, crc0, crc1, crc2, crc3, crc4, crc5;
226 crc0 = rte_crc32_u64(k0, seed);
227 crc1 = rte_crc32_u64(k0 >> 32, k[1] & m[1]);
229 crc2 = rte_crc32_u64(k2, k[3] & m[3]);
230 crc3 = rte_crc32_u64(k2 >> 32, k[4] & m[4]);
232 crc4 = rte_crc32_u64(k5, k[6] & m[6]);
233 crc5 = rte_crc32_u64(k5 >> 32, k[7] & m[7]);
235 crc0 = rte_crc32_u64(crc0, (crc1 << 32) ^ crc2);
236 crc1 = rte_crc32_u64(crc3, (crc4 << 32) ^ crc5);