Code Review
/
vpp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
crypto crypto-openssl: support hashing operations
[vpp.git]
/
src
/
vppinfra
/
bihash_template.c
diff --git
a/src/vppinfra/bihash_template.c
b/src/vppinfra/bihash_template.c
index
e408d15
..
0c6aa2a
100644
(file)
--- a/
src/vppinfra/bihash_template.c
+++ b/
src/vppinfra/bihash_template.c
@@
-197,7
+197,8
@@
void BV (clib_bihash_init2) (BVT (clib_bihash_init2_args) * a)
h->log2_nbuckets = max_log2 (a->nbuckets);
h->memory_size = BIHASH_USE_HEAP ? 0 : a->memory_size;
h->instantiated = 0;
h->log2_nbuckets = max_log2 (a->nbuckets);
h->memory_size = BIHASH_USE_HEAP ? 0 : a->memory_size;
h->instantiated = 0;
- h->fmt_fn = a->fmt_fn;
+ h->fmt_fn = BV (format_bihash);
+ h->kvp_fmt_fn = a->kvp_fmt_fn;
alloc_arena (h) = 0;
alloc_arena (h) = 0;
@@
-271,7
+272,7
@@
void BV (clib_bihash_initiator_init_svm)
ASSERT (memory_size < (1ULL << 32));
/* Set up for memfd sharing */
ASSERT (memory_size < (1ULL << 32));
/* Set up for memfd sharing */
- if ((fd =
memfd_create (name, MFD_ALLOW_SEALING)
) == -1)
+ if ((fd =
clib_mem_vm_create_fd (CLIB_MEM_PAGE_SZ_DEFAULT, name
) == -1)
{
clib_unix_warning ("memfd_create");
return;
{
clib_unix_warning ("memfd_create");
return;
@@
-327,7
+328,8
@@
void BV (clib_bihash_initiator_init_svm)
(u64) BV (clib_bihash_get_offset) (h, freelist_vh->vector_data);
h->freelists = (void *) (freelist_vh->vector_data);
(u64) BV (clib_bihash_get_offset) (h, freelist_vh->vector_data);
h->freelists = (void *) (freelist_vh->vector_data);
- h->fmt_fn = NULL;
+ h->fmt_fn = BV (format_bihash);
+ h->kvp_fmt_fn = NULL;
h->instantiated = 1;
}
h->instantiated = 1;
}
@@
-377,14
+379,20
@@
void BV (clib_bihash_responder_init_svm)
h->alloc_lock = BV (clib_bihash_get_value) (h, h->sh->alloc_lock_as_u64);
h->freelists = BV (clib_bihash_get_value) (h, h->sh->freelists_as_u64);
h->alloc_lock = BV (clib_bihash_get_value) (h, h->sh->alloc_lock_as_u64);
h->freelists = BV (clib_bihash_get_value) (h, h->sh->freelists_as_u64);
- h->fmt_fn = NULL;
+ h->fmt_fn = BV (format_bihash);
+ h->kvp_fmt_fn = NULL;
}
#endif /* BIHASH_32_64_SVM */
void BV (clib_bihash_set_kvp_format_fn) (BVT (clib_bihash) * h,
}
#endif /* BIHASH_32_64_SVM */
void BV (clib_bihash_set_kvp_format_fn) (BVT (clib_bihash) * h,
- format_function_t * fmt_fn)
+ format_function_t *
kvp_
fmt_fn)
{
{
- h->fmt_fn = fmt_fn;
+ h->kvp_fmt_fn = kvp_fmt_fn;
+}
+
+int BV (clib_bihash_is_initialised) (const BVT (clib_bihash) * h)
+{
+ return (h->instantiated != 0);
}
void BV (clib_bihash_free) (BVT (clib_bihash) * h)
}
void BV (clib_bihash_free) (BVT (clib_bihash) * h)
@@
-1009,11
+1017,11
@@
u8 *BV (format_bihash) (u8 * s, va_list * args)
u64 active_buckets = 0;
u64 linear_buckets = 0;
u64 active_buckets = 0;
u64 linear_buckets = 0;
- s = format (s, "Hash table
%s
\n", h->name ? h->name : (u8 *) "(unnamed)");
+ s = format (s, "Hash table
'%s'
\n", h->name ? h->name : (u8 *) "(unnamed)");
#if BIHASH_LAZY_INSTANTIATE
if (PREDICT_FALSE (h->instantiated == 0))
#if BIHASH_LAZY_INSTANTIATE
if (PREDICT_FALSE (h->instantiated == 0))
- return format (s, "
[empty, uninitialized]
");
+ return format (s, "
empty, uninitialized
");
#endif
for (i = 0; i < h->nbuckets; i++)
#endif
for (i = 0; i < h->nbuckets; i++)
@@
-1052,11
+1060,11
@@
u8 *BV (format_bihash) (u8 * s, va_list * args)
}
if (verbose)
{
}
if (verbose)
{
- if (h->fmt_fn)
+ if (h->
kvp_
fmt_fn)
{
s = format (s, " %d: %U\n",
j * BIHASH_KVP_PER_PAGE + k,
{
s = format (s, " %d: %U\n",
j * BIHASH_KVP_PER_PAGE + k,
- h->fmt_fn, &(v->kvp[k]), verbose);
+ h->
kvp_
fmt_fn, &(v->kvp[k]), verbose);
}
else
{
}
else
{
@@
-1106,8
+1114,8
@@
u8 *BV (format_bihash) (u8 * s, va_list * args)
c = c->next;
}
s = format (s,
c = c->next;
}
s = format (s,
- " heap: %u chunk
s
allocated\n"
- "
used %UB, scrap %UB
\n", n_chunks,
+ " heap: %u chunk
(s)
allocated\n"
+ "
bytes: used %U, scrap %U
\n", n_chunks,
format_memory_size, total_size,
format_memory_size, bytes_left);
}
format_memory_size, total_size,
format_memory_size, bytes_left);
}