blob: 81d9ffad41e4677d9abd4309bb2fd135eb1f3964 [file] [log] [blame]
Ed Warnickecb9cada2015-12-08 15:45:58 -07001/*
2 Copyright (c) 2014 Cisco and/or its affiliates.
3
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15*/
16
Chris Luke16bcf7d2016-09-01 14:31:46 -040017/** @cond DOCUMENTATION_IS_IN_BIHASH_DOC_H */
Dave Barachdd3a57f2016-07-27 16:58:51 -040018
Dave Barachc3799992016-08-15 11:12:27 -040019/*
Ed Warnickecb9cada2015-12-08 15:45:58 -070020 * Note: to instantiate the template multiple times in a single file,
21 * #undef __included_bihash_template_h__...
22 */
23#ifndef __included_bihash_template_h__
24#define __included_bihash_template_h__
25
26#include <vppinfra/heap.h>
27#include <vppinfra/format.h>
28#include <vppinfra/pool.h>
29
30#ifndef BIHASH_TYPE
31#error BIHASH_TYPE not defined
32#endif
33
34#define _bv(a,b) a##b
35#define __bv(a,b) _bv(a,b)
36#define BV(a) __bv(a,BIHASH_TYPE)
37
38#define _bvt(a,b) a##b##_t
39#define __bvt(a,b) _bvt(a,b)
40#define BVT(a) __bvt(a,BIHASH_TYPE)
41
Dave Barachc3799992016-08-15 11:12:27 -040042typedef struct BV (clib_bihash_value)
43{
44 union
45 {
46 BVT (clib_bihash_kv) kvp[BIHASH_KVP_PER_PAGE];
47 struct BV (clib_bihash_value) * next_free;
Ed Warnickecb9cada2015-12-08 15:45:58 -070048 };
Dave Barachc3799992016-08-15 11:12:27 -040049} BVT (clib_bihash_value);
Ed Warnickecb9cada2015-12-08 15:45:58 -070050
Dave Barach908a5ea2017-07-14 12:42:21 -040051#if BIHASH_KVP_CACHE_SIZE > 5
52#error Requested KVP cache LRU data exceeds 16 bits
53#endif
54
Dave Barachc3799992016-08-15 11:12:27 -040055typedef struct
56{
57 union
58 {
59 struct
60 {
Ed Warnickecb9cada2015-12-08 15:45:58 -070061 u32 offset;
Dave Barach5e6b9582016-12-12 15:37:29 -050062 u8 linear_search;
Ed Warnickecb9cada2015-12-08 15:45:58 -070063 u8 log2_pages;
Dave Barache7d212f2018-02-07 13:14:06 -050064 i16 refcnt;
Ed Warnickecb9cada2015-12-08 15:45:58 -070065 };
66 u64 as_u64;
67 };
Dave Barachc8ef08a2017-08-31 05:58:22 -040068#if BIHASH_KVP_CACHE_SIZE > 0
Dave Barache7d212f2018-02-07 13:14:06 -050069 u16 cache_lru;
Dave Barach908a5ea2017-07-14 12:42:21 -040070 BVT (clib_bihash_kv) cache[BIHASH_KVP_CACHE_SIZE];
Dave Barachc8ef08a2017-08-31 05:58:22 -040071#endif
Dave Barach908a5ea2017-07-14 12:42:21 -040072} BVT (clib_bihash_bucket);
Ed Warnickecb9cada2015-12-08 15:45:58 -070073
Dave Barachc3799992016-08-15 11:12:27 -040074typedef struct
75{
76 BVT (clib_bihash_value) * values;
Dave Barach908a5ea2017-07-14 12:42:21 -040077 BVT (clib_bihash_bucket) * buckets;
Dave Barachc3799992016-08-15 11:12:27 -040078 volatile u32 *writer_lock;
Ed Warnickecb9cada2015-12-08 15:45:58 -070079
Dave Barachc3799992016-08-15 11:12:27 -040080 BVT (clib_bihash_value) ** working_copies;
Dave Barachba7ddfe2017-05-17 20:20:50 -040081 int *working_copy_lengths;
Dave Barach908a5ea2017-07-14 12:42:21 -040082 BVT (clib_bihash_bucket) saved_bucket;
Ed Warnickecb9cada2015-12-08 15:45:58 -070083
84 u32 nbuckets;
85 u32 log2_nbuckets;
Dave Barachc3799992016-08-15 11:12:27 -040086 u8 *name;
Ed Warnickecb9cada2015-12-08 15:45:58 -070087
Dave Barach908a5ea2017-07-14 12:42:21 -040088 u64 cache_hits;
89 u64 cache_misses;
90
Dave Barachc3799992016-08-15 11:12:27 -040091 BVT (clib_bihash_value) ** freelists;
Dave Barach97f5af02018-02-22 09:48:45 -050092
93 /*
94 * Backing store allocation. Since bihash mananges its own
95 * freelists, we simple dole out memory at alloc_arena_next.
96 */
97 uword alloc_arena;
98 uword alloc_arena_next;
99 uword alloc_arena_size;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700100
Vijayabhaskar Katamreddyfb8e61c2017-12-14 13:20:50 -0800101 /**
102 * A custom format function to print the Key and Value of bihash_key instead of default hexdump
103 */
104 format_function_t *fmt_fn;
105
Dave Barachc3799992016-08-15 11:12:27 -0400106} BVT (clib_bihash);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700107
108
Dave Barach908a5ea2017-07-14 12:42:21 -0400109static inline void
110BV (clib_bihash_update_lru) (BVT (clib_bihash_bucket) * b, u8 slot)
111{
Dave Barache7d212f2018-02-07 13:14:06 -0500112#if BIHASH_KVP_CACHE_SIZE > 1
Dave Barach908a5ea2017-07-14 12:42:21 -0400113 u16 value, tmp, mask;
114 u8 found_lru_pos;
115 u16 save_hi;
116
Dave Barach908a5ea2017-07-14 12:42:21 -0400117 ASSERT (slot < BIHASH_KVP_CACHE_SIZE);
118
119 /* First, find the slot in cache_lru */
120 mask = slot;
121 if (BIHASH_KVP_CACHE_SIZE > 1)
122 mask |= slot << 3;
123 if (BIHASH_KVP_CACHE_SIZE > 2)
124 mask |= slot << 6;
125 if (BIHASH_KVP_CACHE_SIZE > 3)
126 mask |= slot << 9;
127 if (BIHASH_KVP_CACHE_SIZE > 4)
128 mask |= slot << 12;
129
130 value = b->cache_lru;
131 tmp = value ^ mask;
132
133 /* Already the most-recently used? */
134 if ((tmp & 7) == 0)
135 return;
136
137 found_lru_pos = ((tmp & (7 << 3)) == 0) ? 1 : 0;
138 if (BIHASH_KVP_CACHE_SIZE > 2)
139 found_lru_pos = ((tmp & (7 << 6)) == 0) ? 2 : found_lru_pos;
140 if (BIHASH_KVP_CACHE_SIZE > 3)
141 found_lru_pos = ((tmp & (7 << 9)) == 0) ? 3 : found_lru_pos;
142 if (BIHASH_KVP_CACHE_SIZE > 4)
143 found_lru_pos = ((tmp & (7 << 12)) == 0) ? 4 : found_lru_pos;
144
145 ASSERT (found_lru_pos);
146
147 /* create a mask to kill bits in or above slot */
148 mask = 0xFFFF << found_lru_pos;
149 mask <<= found_lru_pos;
150 mask <<= found_lru_pos;
151 mask ^= 0xFFFF;
152 tmp = value & mask;
153
154 /* Save bits above slot */
155 mask ^= 0xFFFF;
156 mask <<= 3;
157 save_hi = value & mask;
158
159 value = save_hi | (tmp << 3) | slot;
160
161 b->cache_lru = value;
Dave Barache7d212f2018-02-07 13:14:06 -0500162#endif
Dave Barach908a5ea2017-07-14 12:42:21 -0400163}
164
165void
166BV (clib_bihash_update_lru_not_inline) (BVT (clib_bihash_bucket) * b,
167 u8 slot);
168
169static inline u8 BV (clib_bihash_get_lru) (BVT (clib_bihash_bucket) * b)
170{
Dave Barachc8ef08a2017-08-31 05:58:22 -0400171#if BIHASH_KVP_CACHE_SIZE > 0
Dave Barach908a5ea2017-07-14 12:42:21 -0400172 return (b->cache_lru >> (3 * (BIHASH_KVP_CACHE_SIZE - 1))) & 7;
Dave Barachc8ef08a2017-08-31 05:58:22 -0400173#else
174 return 0;
175#endif
Dave Barach908a5ea2017-07-14 12:42:21 -0400176}
177
178static inline void BV (clib_bihash_reset_cache) (BVT (clib_bihash_bucket) * b)
179{
Dave Barachc8ef08a2017-08-31 05:58:22 -0400180#if BIHASH_KVP_CACHE_SIZE > 0
Dave Barach908a5ea2017-07-14 12:42:21 -0400181 u16 initial_lru_value;
182
183 memset (b->cache, 0xff, sizeof (b->cache));
184
185 /*
186 * We'll want the cache to be loaded from slot 0 -> slot N, so
187 * the initial LRU order is reverse index order.
188 */
189 if (BIHASH_KVP_CACHE_SIZE == 1)
190 initial_lru_value = 0;
191 else if (BIHASH_KVP_CACHE_SIZE == 2)
192 initial_lru_value = (0 << 3) | (1 << 0);
193 else if (BIHASH_KVP_CACHE_SIZE == 3)
194 initial_lru_value = (0 << 6) | (1 << 3) | (2 << 0);
195 else if (BIHASH_KVP_CACHE_SIZE == 4)
196 initial_lru_value = (0 << 9) | (1 << 6) | (2 << 3) | (3 << 0);
197 else if (BIHASH_KVP_CACHE_SIZE == 5)
198 initial_lru_value = (0 << 12) | (1 << 9) | (2 << 6) | (3 << 3) | (4 << 0);
199
200 b->cache_lru = initial_lru_value;
Dave Barachc8ef08a2017-08-31 05:58:22 -0400201#endif
Dave Barach908a5ea2017-07-14 12:42:21 -0400202}
203
Dave Barach858c06f2017-07-21 10:44:27 -0400204static inline int BV (clib_bihash_lock_bucket) (BVT (clib_bihash_bucket) * b)
Dave Barach908a5ea2017-07-14 12:42:21 -0400205{
Dave Barache7d212f2018-02-07 13:14:06 -0500206#if BIHASH_KVP_CACHE_SIZE > 0
207 u16 cache_lru_bit;
208 u16 rv;
Dave Barach858c06f2017-07-21 10:44:27 -0400209
Dave Barache7d212f2018-02-07 13:14:06 -0500210 cache_lru_bit = 1 << 15;
Dave Barach858c06f2017-07-21 10:44:27 -0400211
Dave Barache7d212f2018-02-07 13:14:06 -0500212 rv = __sync_fetch_and_or (&b->cache_lru, cache_lru_bit);
Dave Barach858c06f2017-07-21 10:44:27 -0400213 /* Was already locked? */
Dave Barache7d212f2018-02-07 13:14:06 -0500214 if (rv & (1 << 15))
Dave Barach858c06f2017-07-21 10:44:27 -0400215 return 0;
Dave Barache7d212f2018-02-07 13:14:06 -0500216#endif
Dave Barach858c06f2017-07-21 10:44:27 -0400217 return 1;
218}
219
220static inline void BV (clib_bihash_unlock_bucket)
221 (BVT (clib_bihash_bucket) * b)
222{
Dave Barache7d212f2018-02-07 13:14:06 -0500223#if BIHASH_KVP_CACHE_SIZE > 0
224 u16 cache_lru;
Dave Barach858c06f2017-07-21 10:44:27 -0400225
Dave Barache7d212f2018-02-07 13:14:06 -0500226 cache_lru = b->cache_lru & ~(1 << 15);
227 b->cache_lru = cache_lru;
228#endif
Dave Barach908a5ea2017-07-14 12:42:21 -0400229}
230
231static inline void *BV (clib_bihash_get_value) (BVT (clib_bihash) * h,
Dave Barachc3799992016-08-15 11:12:27 -0400232 uword offset)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700233{
Dave Barach97f5af02018-02-22 09:48:45 -0500234 u8 *hp = (u8 *) h->alloc_arena;
Dave Barachc3799992016-08-15 11:12:27 -0400235 u8 *vp = hp + offset;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700236
237 return (void *) vp;
238}
239
Dave Barach908a5ea2017-07-14 12:42:21 -0400240static inline uword BV (clib_bihash_get_offset) (BVT (clib_bihash) * h,
Dave Barachc3799992016-08-15 11:12:27 -0400241 void *v)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700242{
Dave Barachc3799992016-08-15 11:12:27 -0400243 u8 *hp, *vp;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700244
Dave Barach97f5af02018-02-22 09:48:45 -0500245 hp = (u8 *) h->alloc_arena;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700246 vp = (u8 *) v;
247
Ed Warnickecb9cada2015-12-08 15:45:58 -0700248 return vp - hp;
249}
250
Dave Barachc3799992016-08-15 11:12:27 -0400251void BV (clib_bihash_init)
252 (BVT (clib_bihash) * h, char *name, u32 nbuckets, uword memory_size);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700253
Vijayabhaskar Katamreddyfb8e61c2017-12-14 13:20:50 -0800254void BV (clib_bihash_set_kvp_format_fn) (BVT (clib_bihash) * h,
255 format_function_t * fmt_fn);
256
Dave Barachc3799992016-08-15 11:12:27 -0400257void BV (clib_bihash_free) (BVT (clib_bihash) * h);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700258
Dave Barachc3799992016-08-15 11:12:27 -0400259int BV (clib_bihash_add_del) (BVT (clib_bihash) * h,
260 BVT (clib_bihash_kv) * add_v, int is_add);
Dave Barach908a5ea2017-07-14 12:42:21 -0400261int BV (clib_bihash_search) (BVT (clib_bihash) * h,
Dave Barachc3799992016-08-15 11:12:27 -0400262 BVT (clib_bihash_kv) * search_v,
263 BVT (clib_bihash_kv) * return_v);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700264
Dave Barachc3799992016-08-15 11:12:27 -0400265void BV (clib_bihash_foreach_key_value_pair) (BVT (clib_bihash) * h,
266 void *callback, void *arg);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700267
Dave Barachc3799992016-08-15 11:12:27 -0400268format_function_t BV (format_bihash);
269format_function_t BV (format_bihash_kvp);
Dave Barach908a5ea2017-07-14 12:42:21 -0400270format_function_t BV (format_bihash_lru);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700271
Dave Barachc3799992016-08-15 11:12:27 -0400272static inline int BV (clib_bihash_search_inline)
Dave Barach908a5ea2017-07-14 12:42:21 -0400273 (BVT (clib_bihash) * h, BVT (clib_bihash_kv) * key_result)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700274{
275 u64 hash;
276 u32 bucket_index;
Dave Barachc3799992016-08-15 11:12:27 -0400277 BVT (clib_bihash_value) * v;
Dave Barach908a5ea2017-07-14 12:42:21 -0400278 BVT (clib_bihash_bucket) * b;
Dave Barachc8ef08a2017-08-31 05:58:22 -0400279#if BIHASH_KVP_CACHE_SIZE > 0
Dave Barach908a5ea2017-07-14 12:42:21 -0400280 BVT (clib_bihash_kv) * kvp;
Dave Barachc8ef08a2017-08-31 05:58:22 -0400281#endif
Dave Barach5e6b9582016-12-12 15:37:29 -0500282 int i, limit;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700283
Dave Barach908a5ea2017-07-14 12:42:21 -0400284 hash = BV (clib_bihash_hash) (key_result);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700285
Dave Barachc3799992016-08-15 11:12:27 -0400286 bucket_index = hash & (h->nbuckets - 1);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700287 b = &h->buckets[bucket_index];
288
289 if (b->offset == 0)
290 return -1;
291
Dave Barachc8ef08a2017-08-31 05:58:22 -0400292#if BIHASH_KVP_CACHE_SIZE > 0
Dave Barach858c06f2017-07-21 10:44:27 -0400293 /* Check the cache, if not currently locked */
294 if (PREDICT_TRUE ((b->cache_lru & (1 << 15)) == 0))
Dave Barach908a5ea2017-07-14 12:42:21 -0400295 {
296 limit = BIHASH_KVP_CACHE_SIZE;
297 kvp = b->cache;
298 for (i = 0; i < limit; i++)
299 {
300 if (BV (clib_bihash_key_compare) (kvp[i].key, key_result->key))
301 {
302 *key_result = kvp[i];
303 h->cache_hits++;
304 return 0;
305 }
306 }
307 }
Dave Barachc8ef08a2017-08-31 05:58:22 -0400308#endif
Dave Barach908a5ea2017-07-14 12:42:21 -0400309
Ed Warnickecb9cada2015-12-08 15:45:58 -0700310 hash >>= h->log2_nbuckets;
311
Dave Barachc3799992016-08-15 11:12:27 -0400312 v = BV (clib_bihash_get_value) (h, b->offset);
Dave Barachc3799992016-08-15 11:12:27 -0400313
Dave Barach5e6b9582016-12-12 15:37:29 -0500314 /* If the bucket has unresolvable collisions, use linear search */
315 limit = BIHASH_KVP_PER_PAGE;
316 v += (b->linear_search == 0) ? hash & ((1 << b->log2_pages) - 1) : 0;
317 if (PREDICT_FALSE (b->linear_search))
318 limit <<= b->log2_pages;
319
320 for (i = 0; i < limit; i++)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700321 {
Dave Barach908a5ea2017-07-14 12:42:21 -0400322 if (BV (clib_bihash_key_compare) (v->kvp[i].key, key_result->key))
Dave Barachc3799992016-08-15 11:12:27 -0400323 {
Dave Barach908a5ea2017-07-14 12:42:21 -0400324 *key_result = v->kvp[i];
325
Dave Barachc8ef08a2017-08-31 05:58:22 -0400326#if BIHASH_KVP_CACHE_SIZE > 0
327 u8 cache_slot;
Dave Barach858c06f2017-07-21 10:44:27 -0400328 /* Try to lock the bucket */
329 if (BV (clib_bihash_lock_bucket) (b))
330 {
331 cache_slot = BV (clib_bihash_get_lru) (b);
332 b->cache[cache_slot] = v->kvp[i];
333 BV (clib_bihash_update_lru) (b, cache_slot);
Dave Barach908a5ea2017-07-14 12:42:21 -0400334
Dave Barach858c06f2017-07-21 10:44:27 -0400335 /* Unlock the bucket */
336 BV (clib_bihash_unlock_bucket) (b);
337 h->cache_misses++;
338 }
Dave Barachc8ef08a2017-08-31 05:58:22 -0400339#endif
Dave Barachc3799992016-08-15 11:12:27 -0400340 return 0;
341 }
Ed Warnickecb9cada2015-12-08 15:45:58 -0700342 }
343 return -1;
344}
345
Dave Barachc3799992016-08-15 11:12:27 -0400346static inline int BV (clib_bihash_search_inline_2)
Dave Barach908a5ea2017-07-14 12:42:21 -0400347 (BVT (clib_bihash) * h,
Dave Barachc3799992016-08-15 11:12:27 -0400348 BVT (clib_bihash_kv) * search_key, BVT (clib_bihash_kv) * valuep)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700349{
350 u64 hash;
351 u32 bucket_index;
Dave Barachc3799992016-08-15 11:12:27 -0400352 BVT (clib_bihash_value) * v;
Dave Barach908a5ea2017-07-14 12:42:21 -0400353 BVT (clib_bihash_bucket) * b;
Dave Barachc8ef08a2017-08-31 05:58:22 -0400354#if BIHASH_KVP_CACHE_SIZE > 0
Dave Barach908a5ea2017-07-14 12:42:21 -0400355 BVT (clib_bihash_kv) * kvp;
Dave Barachc8ef08a2017-08-31 05:58:22 -0400356#endif
Dave Barach5e6b9582016-12-12 15:37:29 -0500357 int i, limit;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700358
Dave Barachc3799992016-08-15 11:12:27 -0400359 ASSERT (valuep);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700360
Dave Barachc3799992016-08-15 11:12:27 -0400361 hash = BV (clib_bihash_hash) (search_key);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700362
Dave Barachc3799992016-08-15 11:12:27 -0400363 bucket_index = hash & (h->nbuckets - 1);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700364 b = &h->buckets[bucket_index];
365
366 if (b->offset == 0)
367 return -1;
368
Dave Barach858c06f2017-07-21 10:44:27 -0400369 /* Check the cache, if currently unlocked */
Dave Barachc8ef08a2017-08-31 05:58:22 -0400370#if BIHASH_KVP_CACHE_SIZE > 0
Dave Barach858c06f2017-07-21 10:44:27 -0400371 if (PREDICT_TRUE ((b->cache_lru & (1 << 15)) == 0))
Dave Barach908a5ea2017-07-14 12:42:21 -0400372 {
373 limit = BIHASH_KVP_CACHE_SIZE;
374 kvp = b->cache;
375 for (i = 0; i < limit; i++)
376 {
377 if (BV (clib_bihash_key_compare) (kvp[i].key, search_key->key))
378 {
379 *valuep = kvp[i];
380 h->cache_hits++;
381 return 0;
382 }
383 }
384 }
Dave Barachc8ef08a2017-08-31 05:58:22 -0400385#endif
Dave Barach908a5ea2017-07-14 12:42:21 -0400386
Ed Warnickecb9cada2015-12-08 15:45:58 -0700387 hash >>= h->log2_nbuckets;
Dave Barachc3799992016-08-15 11:12:27 -0400388 v = BV (clib_bihash_get_value) (h, b->offset);
Dave Barachc3799992016-08-15 11:12:27 -0400389
Dave Barach5e6b9582016-12-12 15:37:29 -0500390 /* If the bucket has unresolvable collisions, use linear search */
391 limit = BIHASH_KVP_PER_PAGE;
392 v += (b->linear_search == 0) ? hash & ((1 << b->log2_pages) - 1) : 0;
393 if (PREDICT_FALSE (b->linear_search))
394 limit <<= b->log2_pages;
395
396 for (i = 0; i < limit; i++)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700397 {
Dave Barachc3799992016-08-15 11:12:27 -0400398 if (BV (clib_bihash_key_compare) (v->kvp[i].key, search_key->key))
399 {
400 *valuep = v->kvp[i];
Dave Barach908a5ea2017-07-14 12:42:21 -0400401
Dave Barachc8ef08a2017-08-31 05:58:22 -0400402#if BIHASH_KVP_CACHE_SIZE > 0
403 u8 cache_slot;
404
Dave Barach858c06f2017-07-21 10:44:27 -0400405 /* Try to lock the bucket */
406 if (BV (clib_bihash_lock_bucket) (b))
407 {
408 cache_slot = BV (clib_bihash_get_lru) (b);
409 b->cache[cache_slot] = v->kvp[i];
410 BV (clib_bihash_update_lru) (b, cache_slot);
Dave Barach908a5ea2017-07-14 12:42:21 -0400411
Dave Barach858c06f2017-07-21 10:44:27 -0400412 /* Reenable the cache */
413 BV (clib_bihash_unlock_bucket) (b);
414 h->cache_misses++;
415 }
Dave Barachc8ef08a2017-08-31 05:58:22 -0400416#endif
Dave Barachc3799992016-08-15 11:12:27 -0400417 return 0;
418 }
Ed Warnickecb9cada2015-12-08 15:45:58 -0700419 }
420 return -1;
421}
422
Ed Warnickecb9cada2015-12-08 15:45:58 -0700423#endif /* __included_bihash_template_h__ */
Dave Barachdd3a57f2016-07-27 16:58:51 -0400424
Chris Luke16bcf7d2016-09-01 14:31:46 -0400425/** @endcond */
Dave Barachc3799992016-08-15 11:12:27 -0400426
427/*
428 * fd.io coding-style-patch-verification: ON
429 *
430 * Local Variables:
431 * eval: (c-set-style "gnu")
432 * End:
433 */