21 #ifndef __included_bihash_template_h__ 22 #define __included_bihash_template_h__ 29 #error BIHASH_TYPE not defined 33 #define __bv(a,b) _bv(a,b) 34 #define BV(a) __bv(a,BIHASH_TYPE) 36 #define _bvt(a,b) a##b##_t 37 #define __bvt(a,b) _bvt(a,b) 38 #define BVT(a) __bvt(a,BIHASH_TYPE) 40 typedef struct BV(clib_bihash_value) {
43 struct BV(clib_bihash_value) * next_free;
45 }
BVT(clib_bihash_value);
51 #ifndef __defined_clib_bihash_bucket_t__ 52 #define __defined_clib_bihash_bucket_t__ 66 BVT(clib_bihash_value) * values;
70 BVT(clib_bihash_value) ** working_copies;
77 BVT(clib_bihash_value) **freelists;
87 u8 * vp = hp + offset;
99 ASSERT((vp - hp) < 0x100000000ULL);
104 (
BVT(clib_bihash) * h,
char * name,
u32 nbuckets,
uword memory_size);
107 (
BVT(clib_bihash) * h);
110 BVT(clib_bihash_kv) * add_v,
113 BVT(clib_bihash_kv) * search_v,
114 BVT(clib_bihash_kv) * return_v);
125 (
BVT(clib_bihash) * h,
BVT(clib_bihash_kv) * kvp)
130 BVT(clib_bihash_value) * v;
134 hash =
BV(clib_bihash_hash) (kvp);
136 bucket_index = hash & (h->nbuckets-1);
137 b = &h->buckets[bucket_index];
142 hash >>= h->log2_nbuckets;
145 value_index = hash & ((1<<b->log2_pages)-1);
150 if (
BV(clib_bihash_key_compare)(v->kvp[i].key, kvp->key))
161 BVT(clib_bihash_kv) *search_key,
162 BVT(clib_bihash_kv) *valuep)
167 BVT(clib_bihash_value) * v;
173 hash =
BV(clib_bihash_hash) (search_key);
175 bucket_index = hash & (h->nbuckets-1);
176 b = &h->buckets[bucket_index];
181 hash >>= h->log2_nbuckets;
184 value_index = hash & ((1<<b->log2_pages)-1);
189 if (
BV(clib_bihash_key_compare)(v->kvp[i].key, search_key->key))
sll srl srl sll sra u16x4 i
clib_bihash_bucket_t saved_bucket
clib_bihash_bucket_t * buckets
int BV() clib_bihash_add_del(BVT(clib_bihash)*h, BVT(clib_bihash_kv)*add_v, int is_add)
int BV() clib_bihash_search(BVT(clib_bihash)*h, BVT(clib_bihash_kv)*search_v, BVT(clib_bihash_kv)*return_v)
#define BIHASH_KVP_PER_PAGE
static uword BV() clib_bihash_get_offset(BVT(clib_bihash)*h, void *v)
u8 *BV() format_bihash(u8 *s, va_list *args)
static int BV() clib_bihash_search_inline_2(BVT(clib_bihash)*h, BVT(clib_bihash_kv)*search_key, BVT(clib_bihash_kv)*valuep)
void BV() clib_bihash_foreach_key_value_pair(BVT(clib_bihash)*h, void *callback, void *arg)
static void *BV() clib_bihash_get_value(BVT(clib_bihash)*h, uword offset)
void BV() clib_bihash_init(BVT(clib_bihash)*h, char *name, u32 nbuckets, uword memory_size)
void BV() clib_bihash_free(BVT(clib_bihash)*h)
static int BV() clib_bihash_search_inline(BVT(clib_bihash)*h, BVT(clib_bihash_kv)*kvp)
volatile u32 * writer_lock