- u64 hash;
- BVT (clib_bihash_value) * v;
- BVT (clib_bihash_bucket) * b;
- int i, limit;
-
- ASSERT (valuep);
-
-#if BIHASH_LAZY_INSTANTIATE
- if (PREDICT_FALSE (alloc_arena (h) == 0))
- return -1;
-#endif
-
- hash = BV (clib_bihash_hash) (search_key);
-
- b = BV (clib_bihash_get_bucket) (h, hash);
-
- if (BV (clib_bihash_bucket_is_empty) (b))
- return -1;
-
- if (PREDICT_FALSE (b->lock))
- {
- volatile BVT (clib_bihash_bucket) * bv = b;
- while (bv->lock)
- CLIB_PAUSE ();
- }
-
- hash >>= h->log2_nbuckets;
-
- v = BV (clib_bihash_get_value) (h, b->offset);
- limit = BIHASH_KVP_PER_PAGE;
- v += (b->linear_search == 0) ? hash & ((1 << b->log2_pages) - 1) : 0;
- if (PREDICT_FALSE (b->linear_search))
- limit <<= b->log2_pages;
-
- for (i = 0; i < limit; i++)
- {
- if (BV (clib_bihash_key_compare) (v->kvp[i].key, search_key->key))
- {
- *valuep = v->kvp[i];
- return 0;
- }
- }
- return -1;