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_is_free_12_4 (const clib_bihash_kv_12_4_t *v)
42 /* Free values are clib_memset to 0xff, check a bit... */
43 if (v->as_u64[0] == ~0ULL && v->value == ~0)
49 clib_bihash_hash_12_4 (const clib_bihash_kv_12_4_t *v)
51 #ifdef clib_crc32c_uses_intrinsics
52 return clib_crc32c ((u8 *) v->key, 12);
54 u64 tmp = v->as_u64[0] ^ v->key[2];
55 return clib_xxhash (tmp);
60 format_bihash_kvp_12_4 (u8 *s, va_list *args)
62 clib_bihash_kv_12_4_t *v = va_arg (*args, clib_bihash_kv_12_4_t *);
64 s = format (s, "key %u %u %u value %u", v->key[0], v->key[1], v->key[2],
70 clib_bihash_key_compare_12_4 (u32 *a, u32 *b)
72 #if defined(CLIB_HAVE_VEC128)
73 u32x4 v = (*(u32x4u *) a) ^ (*(u32x4u *) b);
75 return u32x4_is_all_zero (v);
77 return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2])) == 0;
81 #undef __included_bihash_template_h__
82 #include <vppinfra/bihash_template.h>
84 #endif /* __included_bihash_12_4_h__ */