17 #ifndef included_clib_pfhash_h 18 #define included_clib_pfhash_h 25 #if defined(CLIB_HAVE_VEC128) && ! defined (__ALTIVEC__) 82 pfhash_kv_8v8_t kv8v8;
90 #define PFHASH_BUCKET_OVERFLOW (u32)~0 106 u32 nitems_in_overflow;
109 void pfhash_init (pfhash_t * p,
char *name,
u32 key_size,
u32 value_size,
111 void pfhash_free (pfhash_t * p);
112 u64 pfhash_get (pfhash_t * p,
u32 bucket,
void *key);
113 void pfhash_set (pfhash_t * p,
u32 bucket,
void *key,
void *value);
114 void pfhash_unset (pfhash_t * p,
u32 bucket,
void *key);
119 pfhash_prefetch_bucket (pfhash_t * p,
u32 bucket)
125 pfhash_read_bucket_prefetch_kv (pfhash_t * p,
u32 bucket)
127 u32 bucket_contents = p->buckets[bucket];
128 if (
PREDICT_TRUE ((bucket_contents & PFHASH_BUCKET_OVERFLOW) == 0))
130 return bucket_contents;
143 pfhash_search_kv_16 (pfhash_t * p,
u32 bucket_contents,
u32x4 * key)
145 u32x4 diff0, diff1, diff2;
146 u32 is_equal0, is_equal1, is_equal2;
151 if (
PREDICT_FALSE (bucket_contents == PFHASH_BUCKET_OVERFLOW))
160 kv = &p->kvp[bucket_contents].kv16;
162 diff0 = u32x4_sub (kv->kb.k_u32x4[0], key[0]);
163 diff1 = u32x4_sub (kv->kb.k_u32x4[1], key[0]);
164 diff2 = u32x4_sub (kv->kb.k_u32x4[2], key[0]);
168 no_match |= is_equal1;
170 no_match |= is_equal2;
172 no_match = ~no_match;
174 rv = (is_equal0 & kv->values[0])
175 | (is_equal1 & kv->values[1]) | (is_equal2 & kv->values[2]) | no_match;
181 pfhash_search_kv_8 (pfhash_t * p,
u32 bucket_contents,
u64 * key)
186 if (
PREDICT_FALSE (bucket_contents == PFHASH_BUCKET_OVERFLOW))
195 kv = &p->kvp[bucket_contents].kv8;
197 rv = (kv->kb.k_u64[0] == key[0]) ? kv->values[0] : rv;
198 rv = (kv->kb.k_u64[1] == key[0]) ? kv->values[1] : rv;
199 rv = (kv->kb.k_u64[2] == key[0]) ? kv->values[2] : rv;
200 rv = (kv->kb.k_u64[3] == key[0]) ? kv->values[3] : rv;
201 rv = (kv->kb.k_u64[4] == key[0]) ? kv->values[4] : rv;
207 pfhash_search_kv_8v8 (pfhash_t * p,
u32 bucket_contents,
u64 * key)
212 if (
PREDICT_FALSE (bucket_contents == PFHASH_BUCKET_OVERFLOW))
221 kv = &p->kvp[bucket_contents].kv8v8;
223 rv = (kv->kb.k_u64[0] == key[0]) ? kv->values[0] : rv;
224 rv = (kv->kb.k_u64[1] == key[0]) ? kv->values[1] : rv;
225 rv = (kv->kb.k_u64[2] == key[0]) ? kv->values[2] : rv;
226 rv = (kv->kb.k_u64[3] == key[0]) ? kv->values[3] : rv;
232 pfhash_search_kv_4 (pfhash_t * p,
u32 bucket_contents,
u32 * key)
236 u32 zbm[2], winner_index;
239 if (
PREDICT_FALSE (bucket_contents == PFHASH_BUCKET_OVERFLOW))
248 kv = &p->kvp[bucket_contents].kv4;
260 winner_index =
min_log2 (zbm[0]) >> 2;
261 winner_index = zbm[1] ? (4 + (
min_log2 (zbm[1]) >> 2)) : winner_index;
263 return kv->values[winner_index];
static u32x4 u32x4_is_equal(u32x4 x, u32x4 y)
u8 pad[3]
log2 (size of the packing page block)
Fixed length block allocator.
static uword min_log2(uword x)
#define CLIB_PREFETCH(addr, size, type)
#define hash_get_mem(h, key)
#define CLIB_CACHE_LINE_BYTES
static u32 u32x4_zero_byte_mask(u32x4 x)