5#ifndef __INCLUDE_RTE_TABLE_HASH_FUNC_H__
6#define __INCLUDE_RTE_TABLE_HASH_FUNC_H__
14#include <rte_compat.h>
19rte_crc32_u64_generic(uint64_t crc, uint64_t value)
23 crc = (crc & 0xFFFFFFFFLLU) ^ value;
24 for (i = 63; i >= 0; i--) {
28 crc = (crc >> 1LLU) ^ (0x82F63B78LLU & mask);
34#if defined(RTE_ARCH_X86_64)
39rte_crc32_u64(uint64_t crc, uint64_t v)
41 return _mm_crc32_u64(crc, v);
44#elif defined(RTE_ARCH_ARM64) && defined(__ARM_FEATURE_CRC32)
45#include "rte_table_hash_func_arm64.h"
49rte_crc32_u64(uint64_t crc, uint64_t v)
51 return rte_crc32_u64_generic(crc, v);
58rte_table_hash_crc_key8(
void *key,
void *mask,
__rte_unused uint32_t key_size,
61 uint64_t *k = (uint64_t *)key;
62 uint64_t *m = (uint64_t *)mask;
65 crc0 = rte_crc32_u64(seed, k[0] & m[0]);
72rte_table_hash_crc_key16(
void *key,
void *mask,
__rte_unused uint32_t key_size,
75 uint64_t *k = (uint64_t *)key;
76 uint64_t *m = (uint64_t *)mask;
77 uint64_t k0, crc0, crc1;
81 crc0 = rte_crc32_u64(k0, seed);
82 crc1 = rte_crc32_u64(k0 >> 32, k[1] & m[1]);
91rte_table_hash_crc_key24(
void *key,
void *mask,
__rte_unused uint32_t key_size,
94 uint64_t *k = (uint64_t *)key;
95 uint64_t *m = (uint64_t *)mask;
96 uint64_t k0, k2, crc0, crc1;
101 crc0 = rte_crc32_u64(k0, seed);
102 crc1 = rte_crc32_u64(k0 >> 32, k[1] & m[1]);
104 crc0 = rte_crc32_u64(crc0, k2);
112static inline uint64_t
113rte_table_hash_crc_key32(
void *key,
void *mask,
__rte_unused uint32_t key_size,
116 uint64_t *k = (uint64_t *)key;
117 uint64_t *m = (uint64_t *)mask;
118 uint64_t k0, k2, crc0, crc1, crc2, crc3;
123 crc0 = rte_crc32_u64(k0, seed);
124 crc1 = rte_crc32_u64(k0 >> 32, k[1] & m[1]);
126 crc2 = rte_crc32_u64(k2, k[3] & m[3]);
129 crc0 = rte_crc32_u64(crc0, crc1);
130 crc1 = rte_crc32_u64(crc2, crc3);
138static inline uint64_t
139rte_table_hash_crc_key40(
void *key,
void *mask,
__rte_unused uint32_t key_size,
142 uint64_t *k = (uint64_t *)key;
143 uint64_t *m = (uint64_t *)mask;
144 uint64_t k0, k2, crc0, crc1, crc2, crc3;
149 crc0 = rte_crc32_u64(k0, seed);
150 crc1 = rte_crc32_u64(k0 >> 32, k[1] & m[1]);
152 crc2 = rte_crc32_u64(k2, k[3] & m[3]);
153 crc3 = rte_crc32_u64(k2 >> 32, k[4] & m[4]);
155 crc0 = rte_crc32_u64(crc0, crc1);
156 crc1 = rte_crc32_u64(crc2, crc3);
164static inline uint64_t
165rte_table_hash_crc_key48(
void *key,
void *mask,
__rte_unused uint32_t key_size,
168 uint64_t *k = (uint64_t *)key;
169 uint64_t *m = (uint64_t *)mask;
170 uint64_t k0, k2, k5, crc0, crc1, crc2, crc3;
176 crc0 = rte_crc32_u64(k0, seed);
177 crc1 = rte_crc32_u64(k0 >> 32, k[1] & m[1]);
179 crc2 = rte_crc32_u64(k2, k[3] & m[3]);
180 crc3 = rte_crc32_u64(k2 >> 32, k[4] & m[4]);
182 crc0 = rte_crc32_u64(crc0, (crc1 << 32) ^ crc2);
183 crc1 = rte_crc32_u64(crc3, k5);
191static inline uint64_t
192rte_table_hash_crc_key56(
void *key,
void *mask,
__rte_unused uint32_t key_size,
195 uint64_t *k = (uint64_t *)key;
196 uint64_t *m = (uint64_t *)mask;
197 uint64_t k0, k2, k5, crc0, crc1, crc2, crc3, crc4, crc5;
203 crc0 = rte_crc32_u64(k0, seed);
204 crc1 = rte_crc32_u64(k0 >> 32, k[1] & m[1]);
206 crc2 = rte_crc32_u64(k2, k[3] & m[3]);
207 crc3 = rte_crc32_u64(k2 >> 32, k[4] & m[4]);
209 crc4 = rte_crc32_u64(k5, k[6] & m[6]);
212 crc0 = rte_crc32_u64(crc0, (crc1 << 32) ^ crc2);
213 crc1 = rte_crc32_u64(crc3, (crc4 << 32) ^ crc5);
221static inline uint64_t
222rte_table_hash_crc_key64(
void *key,
void *mask,
__rte_unused uint32_t key_size,
225 uint64_t *k = (uint64_t *)key;
226 uint64_t *m = (uint64_t *)mask;
227 uint64_t k0, k2, k5, crc0, crc1, crc2, crc3, crc4, crc5;
233 crc0 = rte_crc32_u64(k0, seed);
234 crc1 = rte_crc32_u64(k0 >> 32, k[1] & m[1]);
236 crc2 = rte_crc32_u64(k2, k[3] & m[3]);
237 crc3 = rte_crc32_u64(k2 >> 32, k[4] & m[4]);
239 crc4 = rte_crc32_u64(k5, k[6] & m[6]);
240 crc5 = rte_crc32_u64(k5 >> 32, k[7] & m[7]);
242 crc0 = rte_crc32_u64(crc0, (crc1 << 32) ^ crc2);
243 crc1 = rte_crc32_u64(crc3, (crc4 << 32) ^ crc5);