|
FD.io VPP
v21.06-3-gbb25fbf28
Vector Packet Processing
|
Go to the documentation of this file.
44 return ((
u32 *) d)[0];
46 return ((
u16 *) d)[0] | (((
u8 *) d)[2] << 16);
48 return ((
u16 *) d)[0];
93 #define foreach_mhash_key_size \
94 _ (2) _ (3) _ (4) _ (5) _ (6) _ (7) \
95 _ (8) _ (12) _ (16) _ (20) \
96 _ (24) _ (28) _ (32) _ (36) \
97 _ (40) _ (44) _ (48) _ (52) \
100 #define _(N_KEY_BYTES) \
102 mhash_key_sum_##N_KEY_BYTES (hash_t * h, uword key) \
104 mhash_t * hv = uword_to_pointer (h->user, mhash_t *); \
105 return mhash_key_sum_inline (mhash_key_to_mem (hv, key), \
111 mhash_key_equal_##N_KEY_BYTES (hash_t * h, uword key1, uword key2) \
113 mhash_t * hv = uword_to_pointer (h->user, mhash_t *); \
114 void * k1 = mhash_key_to_mem (hv, key1); \
115 void * k2 = mhash_key_to_mem (hv, key2); \
116 return ! memcmp (k1, k2, (N_KEY_BYTES)); \
135 return strcmp (k1, k2) == 0;
176 #define _(N_KEY_BYTES) \
178 .key_sum = mhash_key_sum_##N_KEY_BYTES, \
179 .key_equal = mhash_key_equal_##N_KEY_BYTES, \
206 h->n_key_bytes = n_key_bytes;
225 key_tmp =
h->key_tmps[my_cpu];
241 h->key_tmps[my_cpu] = key_tmp;
267 uword ikey,
i, l = 0, n_key_bytes, old_n_elts, key_alloc_from_free_list = 0;
277 n_key_bytes = is_c_string ? (strlen (
key) + 1) :
vec_len (
key);
279 heap_alloc (
h->key_vector_or_heap, n_key_bytes + sizeof (sk[0]),
282 sk = (
void *) (
h->key_vector_or_heap +
i);
284 sk->
vec.
len = n_key_bytes;
292 key_alloc_from_free_list = (l =
293 vec_len (
h->key_vector_free_indices)) > 0;
294 if (key_alloc_from_free_list)
296 i =
h->key_vector_free_indices[l - 1];
298 _vec_len (
h->key_vector_free_indices) = l - 1;
302 vec_add2 (
h->key_vector_or_heap, k,
h->n_key_bytes);
303 i = k -
h->key_vector_or_heap;
306 n_key_bytes =
h->n_key_bytes;
312 h->hash = _hash_set3 (
h->hash, ikey, new_value, old_value);
327 sk = (
void *) (
h->key_vector_or_heap +
i - sizeof (sk[0]));
332 if (key_alloc_from_free_list)
334 h->key_vector_free_indices[l] =
i;
335 _vec_len (
h->key_vector_free_indices) = l + 1;
338 _vec_len (
h->key_vector_or_heap) -=
h->n_key_bytes;
364 sk = (
void *) (
h->key_vector_or_heap +
i) -
sizeof (sk[0]);
378 u32 ki = va_arg (*va,
u32);
384 u32 l = is_c_string ? strlen (k) :
vec_len (k);
387 else if (
h->format_key)
388 s =
format (s,
"%U",
h->format_key, k);
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
#define vec_add(V, E, N)
Add N elements to end of vector V (no header, unspecified alignment)
__clib_export hash_pair_t * mhash_get_pair(mhash_t *h, const void *key)
static uword pointer_to_uword(const void *p)
static void * mhash_key_to_mem(mhash_t *h, uword key)
static hash_t * hash_header(void *v)
u8 * format_mhash_key(u8 *s, va_list *va)
#define hash_get_pair(h, key)
uword() hash_key_equal_function_t(struct hash_header *, uword key1, uword key2)
__clib_export void mhash_init(mhash_t *h, uword n_value_bytes, uword n_key_bytes)
static_always_inline void * clib_memcpy_fast(void *restrict dst, const void *restrict src, size_t n)
static u32 load_partial_u32(void *d, uword n)
#define MHASH_VEC_STRING_KEY
uword() hash_key_sum_function_t(struct hash_header *, uword key)
#define hash_unset3(h, key, old_value)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define MHASH_C_STRING_KEY
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
uword os_get_nthreads(void)
static foreach_mhash_key_size uword mhash_key_sum_c_string(hash_t *h, uword key)
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
#define foreach_mhash_key_size
#define hash_create2(_elts, _user, _value_bytes, _key_sum, _key_equal, _format_pair, _format_pair_arg)
static uword mhash_key_equal_c_string(hash_t *h, uword key1, uword key2)
static uword mhash_key_sum_vec_string(hash_t *h, uword key)
sll srl srl sll sra u16x4 i
static uword mhash_key_vector_is_heap(mhash_t *h)
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment)
#define hash_v3_finalize32(a, b, c)
static_always_inline uword os_get_thread_index(void)
static uword mhash_set_tmp_key(mhash_t *h, const void *key)
__clib_export void heap_dealloc(void *v, uword handle)
static uword hash_elts(void *v)
#define vec_free(V)
Free vector's memory (no header).
description fragment has unexpected format
static u32 mhash_key_sum_inline(void *data, uword n_data_bytes, u32 seed)
static uword key_equal(hash_t *h, uword key1, uword key2)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
#define heap_alloc(v, size, handle)
static uword mhash_key_equal_vec_string(hash_t *h, uword key1, uword key2)
#define uword_to_pointer(u, type)
static void mhash_sanitize_hash_user(mhash_t *mh)
#define hash_v3_mix32(a, b, c)
__clib_export uword mhash_set_mem(mhash_t *h, void *key, uword *new_value, uword *old_value)
__clib_export uword mhash_unset(mhash_t *h, void *key, uword *old_value)
static uword key_sum(hash_t *h, uword key)