5#ifndef __INCLUDE_RTE_TABLE_HASH_FUNC_H__
6#define __INCLUDE_RTE_TABLE_HASH_FUNC_H__
10#include <rte_compat.h>
13#if defined(RTE_ARCH_X86_64)
22rte_crc32_u64(uint64_t crc, uint64_t v)
24 return _mm_crc32_u64(crc, v);
31#elif defined(RTE_ARCH_ARM64) && defined(__ARM_FEATURE_CRC32)
32#include "rte_table_hash_func_arm64.h"
40rte_crc32_u64(uint64_t crc, uint64_t v)
44 crc = (crc & 0xFFFFFFFFLLU) ^ v;
45 for (i = 63; i >= 0; i--) {
49 crc = (crc >> 1LLU) ^ (0x82F63B78LLU & mask);
67rte_table_hash_crc_key8(
void *key,
void *mask,
__rte_unused uint32_t key_size,
70 uint64_t *k = (uint64_t *)key;
71 uint64_t *m = (uint64_t *)mask;
74 crc0 = rte_crc32_u64(seed, k[0] & m[0]);
81rte_table_hash_crc_key16(
void *key,
void *mask,
__rte_unused uint32_t key_size,
84 uint64_t *k = (uint64_t *)key;
85 uint64_t *m = (uint64_t *)mask;
86 uint64_t k0, crc0, crc1;
90 crc0 = rte_crc32_u64(k0, seed);
91 crc1 = rte_crc32_u64(k0 >> 32, k[1] & m[1]);
100rte_table_hash_crc_key24(
void *key,
void *mask,
__rte_unused uint32_t key_size,
103 uint64_t *k = (uint64_t *)key;
104 uint64_t *m = (uint64_t *)mask;
105 uint64_t k0, k2, crc0, crc1;
110 crc0 = rte_crc32_u64(k0, seed);
111 crc1 = rte_crc32_u64(k0 >> 32, k[1] & m[1]);
113 crc0 = rte_crc32_u64(crc0, k2);
121static inline uint64_t
122rte_table_hash_crc_key32(
void *key,
void *mask,
__rte_unused uint32_t key_size,
125 uint64_t *k = (uint64_t *)key;
126 uint64_t *m = (uint64_t *)mask;
127 uint64_t k0, k2, crc0, crc1, crc2, crc3;
132 crc0 = rte_crc32_u64(k0, seed);
133 crc1 = rte_crc32_u64(k0 >> 32, k[1] & m[1]);
135 crc2 = rte_crc32_u64(k2, k[3] & m[3]);
138 crc0 = rte_crc32_u64(crc0, crc1);
139 crc1 = rte_crc32_u64(crc2, crc3);
147static inline uint64_t
148rte_table_hash_crc_key40(
void *key,
void *mask,
__rte_unused uint32_t key_size,
151 uint64_t *k = (uint64_t *)key;
152 uint64_t *m = (uint64_t *)mask;
153 uint64_t k0, k2, crc0, crc1, crc2, crc3;
158 crc0 = rte_crc32_u64(k0, seed);
159 crc1 = rte_crc32_u64(k0 >> 32, k[1] & m[1]);
161 crc2 = rte_crc32_u64(k2, k[3] & m[3]);
162 crc3 = rte_crc32_u64(k2 >> 32, k[4] & m[4]);
164 crc0 = rte_crc32_u64(crc0, crc1);
165 crc1 = rte_crc32_u64(crc2, crc3);
173static inline uint64_t
174rte_table_hash_crc_key48(
void *key,
void *mask,
__rte_unused uint32_t key_size,
177 uint64_t *k = (uint64_t *)key;
178 uint64_t *m = (uint64_t *)mask;
179 uint64_t k0, k2, k5, crc0, crc1, crc2, crc3;
185 crc0 = rte_crc32_u64(k0, seed);
186 crc1 = rte_crc32_u64(k0 >> 32, k[1] & m[1]);
188 crc2 = rte_crc32_u64(k2, k[3] & m[3]);
189 crc3 = rte_crc32_u64(k2 >> 32, k[4] & m[4]);
191 crc0 = rte_crc32_u64(crc0, (crc1 << 32) ^ crc2);
192 crc1 = rte_crc32_u64(crc3, k5);
200static inline uint64_t
201rte_table_hash_crc_key56(
void *key,
void *mask,
__rte_unused uint32_t key_size,
204 uint64_t *k = (uint64_t *)key;
205 uint64_t *m = (uint64_t *)mask;
206 uint64_t k0, k2, k5, crc0, crc1, crc2, crc3, crc4, crc5;
212 crc0 = rte_crc32_u64(k0, seed);
213 crc1 = rte_crc32_u64(k0 >> 32, k[1] & m[1]);
215 crc2 = rte_crc32_u64(k2, k[3] & m[3]);
216 crc3 = rte_crc32_u64(k2 >> 32, k[4] & m[4]);
218 crc4 = rte_crc32_u64(k5, k[6] & m[6]);
221 crc0 = rte_crc32_u64(crc0, (crc1 << 32) ^ crc2);
222 crc1 = rte_crc32_u64(crc3, (crc4 << 32) ^ crc5);
230static inline uint64_t
231rte_table_hash_crc_key64(
void *key,
void *mask,
__rte_unused uint32_t key_size,
234 uint64_t *k = (uint64_t *)key;
235 uint64_t *m = (uint64_t *)mask;
236 uint64_t k0, k2, k5, crc0, crc1, crc2, crc3, crc4, crc5;
242 crc0 = rte_crc32_u64(k0, seed);
243 crc1 = rte_crc32_u64(k0 >> 32, k[1] & m[1]);
245 crc2 = rte_crc32_u64(k2, k[3] & m[3]);
246 crc3 = rte_crc32_u64(k2 >> 32, k[4] & m[4]);
248 crc4 = rte_crc32_u64(k5, k[6] & m[6]);
249 crc5 = rte_crc32_u64(k5 >> 32, k[7] & m[7]);
251 crc0 = rte_crc32_u64(crc0, (crc1 << 32) ^ crc2);
252 crc1 = rte_crc32_u64(crc3, (crc4 << 32) ^ crc5);