1 /* SPDX-License-Identifier: Apache-2.0
2 * Copyright(c) 2021 Cisco Systems, Inc.
5 #undef BIHASH_KVP_PER_PAGE
6 #undef BIHASH_32_64_SVM
7 #undef BIHASH_ENABLE_STATS
8 #undef BIHASH_KVP_AT_BUCKET_LEVEL
9 #undef BIHASH_LAZY_INSTANTIATE
10 #undef BIHASH_BUCKET_PREFETCH_CACHE_LINES
11 #undef BIHASH_USE_HEAP
13 #define BIHASH_TYPE _12_4
14 #define BIHASH_KVP_PER_PAGE 4
15 #define BIHASH_KVP_AT_BUCKET_LEVEL 0
16 #define BIHASH_LAZY_INSTANTIATE 1
17 #define BIHASH_BUCKET_PREFETCH_CACHE_LINES 1
18 #define BIHASH_USE_HEAP 1
20 #ifndef __included_bihash_12_4_h__
21 #define __included_bihash_12_4_h__
23 #include <vppinfra/crc32.h>
24 #include <vppinfra/heap.h>
25 #include <vppinfra/format.h>
26 #include <vppinfra/pool.h>
27 #include <vppinfra/xxhash.h>
37 } clib_bihash_kv_12_4_t;
40 clib_bihash_mark_free_12_4 (clib_bihash_kv_12_4_t *v)
42 v->value = 0xFEEDFACE;
46 clib_bihash_is_free_12_4 (const clib_bihash_kv_12_4_t *v)
48 if (v->value == 0xFEEDFACE)
54 clib_bihash_hash_12_4 (const clib_bihash_kv_12_4_t *v)
56 #ifdef clib_crc32c_uses_intrinsics
57 return clib_crc32c ((u8 *) v->key, 12);
59 u64 tmp = v->as_u64[0] ^ v->key[2];
60 return clib_xxhash (tmp);
65 format_bihash_kvp_12_4 (u8 *s, va_list *args)
67 clib_bihash_kv_12_4_t *v = va_arg (*args, clib_bihash_kv_12_4_t *);
69 s = format (s, "key %u %u %u value %u", v->key[0], v->key[1], v->key[2],
75 clib_bihash_key_compare_12_4 (u32 *a, u32 *b)
77 #if defined(CLIB_HAVE_VEC128)
78 u32x4 v = (*(u32x4u *) a) ^ (*(u32x4u *) b);
80 return u32x4_is_all_zero (v);
82 return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2])) == 0;
86 #undef __included_bihash_template_h__
87 #include <vppinfra/bihash_template.h>
89 #endif /* __included_bihash_12_4_h__ */