aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrew Yourtchenko <ayourtch@gmail.com>2018-05-27 20:56:26 +0200
committerDave Barach <openvpp@barachs.net>2018-06-14 17:38:53 +0000
commitabcddcbcabb180595ec8041ac7cf07249d896dc4 (patch)
tree5256d26eab3ced56a5a084356bf9bf638a9a3bf6 /src
parent8637634d4dbc3e8cc90f78307d2069524b8f8f5e (diff)
Add clib_bihash_search_inline_2_with_hash to bihash template
Use similar approach as in the clib_bihash_search_inline_with_hash to be able to do the hash calculation and lookup separately. Change-Id: Ief79aa0f9f1e42b0af88be4807ca01fac30a80d7 Signed-off-by: Andrew Yourtchenko <ayourtch@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/vppinfra/bihash_template.h20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/vppinfra/bihash_template.h b/src/vppinfra/bihash_template.h
index 2101d44defe..8398c38f577 100644
--- a/src/vppinfra/bihash_template.h
+++ b/src/vppinfra/bihash_template.h
@@ -384,11 +384,10 @@ static inline void BV (clib_bihash_prefetch_data)
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;
@@ -399,8 +398,6 @@ static inline int BV (clib_bihash_search_inline_2)
ASSERT (valuep);
- hash = BV (clib_bihash_hash) (search_key);
-
bucket_index = hash & (h->nbuckets - 1);
b = &h->buckets[bucket_index];
@@ -461,6 +458,19 @@ static inline int BV (clib_bihash_search_inline_2)
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 */