diff options
author | Damjan Marion <damarion@cisco.com> | 2020-09-30 14:15:24 +0200 |
---|---|---|
committer | Dave Barach <openvpp@barachs.net> | 2020-09-30 19:16:52 +0000 |
commit | f2b4a375d68b29130801c17f05ae66294d007d90 (patch) | |
tree | 48ddf4098368d93c70bc47b17a36ee2680b79691 /src/vppinfra | |
parent | 558607dc3a96232191f413b9bc894524ff85f2a1 (diff) |
vpp: update 'show bihash' command
Type: improvement
Change-Id: I6d00ba840d2168af0658f97c45a42d39be7cbbad
Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vppinfra')
-rw-r--r-- | src/vppinfra/bihash_template.c | 25 | ||||
-rw-r--r-- | src/vppinfra/bihash_template.h | 7 |
2 files changed, 18 insertions, 14 deletions
diff --git a/src/vppinfra/bihash_template.c b/src/vppinfra/bihash_template.c index e408d157da7..561855a5644 100644 --- 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->fmt_fn = a->fmt_fn; + h->fmt_fn = BV (format_bihash); + h->kvp_fmt_fn = a->kvp_fmt_fn; alloc_arena (h) = 0; @@ -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); - h->fmt_fn = NULL; + h->fmt_fn = BV (format_bihash); + h->kvp_fmt_fn = NULL; h->instantiated = 1; } @@ -377,14 +379,15 @@ 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->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, - format_function_t * fmt_fn) + format_function_t * kvp_fmt_fn) { - h->fmt_fn = fmt_fn; + h->kvp_fmt_fn = kvp_fmt_fn; } void BV (clib_bihash_free) (BVT (clib_bihash) * h) @@ -1009,11 +1012,11 @@ u8 *BV (format_bihash) (u8 * s, va_list * args) 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)) - return format (s, "[empty, uninitialized]"); + return format (s, " empty, uninitialized"); #endif for (i = 0; i < h->nbuckets; i++) @@ -1052,11 +1055,11 @@ u8 *BV (format_bihash) (u8 * s, va_list * args) } if (verbose) { - if (h->fmt_fn) + if (h->kvp_fmt_fn) { 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 { @@ -1106,8 +1109,8 @@ u8 *BV (format_bihash) (u8 * s, va_list * args) c = c->next; } s = format (s, - " heap: %u chunks 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); } diff --git a/src/vppinfra/bihash_template.h b/src/vppinfra/bihash_template.h index a6990ff5999..83c94279668 100644 --- a/src/vppinfra/bihash_template.h +++ b/src/vppinfra/bihash_template.h @@ -156,6 +156,7 @@ BVS (clib_bihash) u32 log2_nbuckets; u64 memory_size; u8 *name; + format_function_t *fmt_fn; void *heap; BVT (clib_bihash_alloc_chunk) * chunks; @@ -174,7 +175,7 @@ BVS (clib_bihash) /** * A custom format function to print the Key and Value of bihash_key instead of default hexdump */ - format_function_t *fmt_fn; + format_function_t *kvp_fmt_fn; /** Optional statistics-gathering callback */ #if BIHASH_ENABLE_STATS @@ -192,7 +193,7 @@ typedef struct char *name; u32 nbuckets; uword memory_size; - format_function_t *fmt_fn; + format_function_t *kvp_fmt_fn; u8 instantiate_immediately; u8 dont_add_to_all_bihash_list; } BVT (clib_bihash_init2_args); @@ -346,7 +347,7 @@ void BV (clib_bihash_responder_init_svm) #endif void BV (clib_bihash_set_kvp_format_fn) (BVT (clib_bihash) * h, - format_function_t * fmt_fn); + format_function_t * kvp_fmt_fn); void BV (clib_bihash_free) (BVT (clib_bihash) * h); |