{
struct
{
- u32 offset;
- u8 linear_search;
- u8 log2_pages;
- i16 refcnt;
+ u64 offset:37;
+ u64 linear_search:1;
+ u64 log2_pages:8;
+ i64 refcnt:16;
};
u64 as_u64;
};
#endif
} BVT (clib_bihash_bucket);
+#if BIHASH_KVP_CACHE_SIZE == 0
+STATIC_ASSERT_SIZEOF (BVT (clib_bihash_bucket), sizeof (u64));
+#endif
+
typedef struct
{
BVT (clib_bihash_value) * values;
return (void *) vp;
}
+static inline int BV (clib_bihash_bucket_is_empty)
+ (BVT (clib_bihash_bucket) * b)
+{
+ return b->as_u64 == 0;
+}
+
static inline uword BV (clib_bihash_get_offset) (BVT (clib_bihash) * h,
void *v)
{
bucket_index = hash & (h->nbuckets - 1);
b = &h->buckets[bucket_index];
- if (b->offset == 0)
+ if (PREDICT_FALSE (BV (clib_bihash_bucket_is_empty) (b)))
return -1;
#if BIHASH_KVP_CACHE_SIZE > 0
bucket_index = hash & (h->nbuckets - 1);
b = &h->buckets[bucket_index];
- if (PREDICT_FALSE (b->offset == 0))
+ if (PREDICT_FALSE (BV (clib_bihash_bucket_is_empty) (b)))
return;
hash >>= h->log2_nbuckets;
CLIB_PREFETCH (v, CLIB_CACHE_LINE_BYTES, READ);
}
-static inline int BV (clib_bihash_search_inline_2)
+static inline int BV (clib_bihash_search_inline_2_with_hash)
(BVT (clib_bihash) * h,
- BVT (clib_bihash_kv) * search_key, BVT (clib_bihash_kv) * valuep)
+ u64 hash, BVT (clib_bihash_kv) * search_key, BVT (clib_bihash_kv) * valuep)
{
- u64 hash;
u32 bucket_index;
BVT (clib_bihash_value) * v;
BVT (clib_bihash_bucket) * b;
ASSERT (valuep);
- hash = BV (clib_bihash_hash) (search_key);
-
bucket_index = hash & (h->nbuckets - 1);
b = &h->buckets[bucket_index];
- if (b->offset == 0)
+ if (PREDICT_FALSE (BV (clib_bihash_bucket_is_empty) (b)))
return -1;
/* Check the cache, if currently unlocked */
return -1;
}
+static inline int BV (clib_bihash_search_inline_2)
+ (BVT (clib_bihash) * h,
+ BVT (clib_bihash_kv) * search_key, BVT (clib_bihash_kv) * valuep)
+{
+ u64 hash;
+
+ hash = BV (clib_bihash_hash) (search_key);
+
+ return BV (clib_bihash_search_inline_2_with_hash) (h, hash, search_key,
+ valuep);
+}
+
+
#endif /* __included_bihash_template_h__ */
/** @endcond */