+u8 *
+format_bihash_stats (u8 * s, va_list * args)
+{
+ BVT (clib_bihash) * h = va_arg (*args, BVT (clib_bihash) *);
+ int verbose = va_arg (*args, int);
+ int i;
+ bihash_stats_t *sp = h->inc_stats_context;
+
+#define _(a) s = format (s, "%20s: %lld\n", #a, sp->a);
+ foreach_bihash_stat;
+#undef _
+ for (i = 0; i < vec_len (sp->splits); i++)
+ {
+ if (sp->splits[i] > 0 || verbose)
+ s = format (s, " splits[%d]: %lld\n", 1 << i, sp->splits[i]);
+ }
+ return s;
+}
+
+
+static void
+inc_stats_callback (BVT (clib_bihash) * h, int stat_id, u64 count)
+{
+ uword *statp = h->inc_stats_context;
+ bihash_stats_t *for_splits;
+
+ if (PREDICT_TRUE (stat_id * sizeof (u64)
+ < STRUCT_OFFSET_OF (bihash_stats_t, splits)))
+ {
+ statp[stat_id] += count;
+ return;
+ }
+
+ for_splits = h->inc_stats_context;
+ vec_validate (for_splits->splits, count);
+ for_splits->splits[count] += 1;
+}
+
+