summaryrefslogtreecommitdiffstats
path: root/src/vnet/util/throttle.c
diff options
context:
space:
mode:
authorMaxime Peim <mpeim@cisco.com>2023-02-06 10:14:20 +0000
committerBeno�t Ganne <bganne@cisco.com>2023-03-23 08:58:30 +0000
commitf6ba56296c4034d299784b828a8ac1661adc74da (patch)
treeb206a7b11c3624b7cf02aca5787c89c14f863106 /src/vnet/util/throttle.c
parentac3c8dcb076245544e61dabb984d057167572276 (diff)
vnet: throttling configuration improvement
To allow a more flexible throttling configuration, the number of bits used in the throttling bitmap can be chosen. Type: improvement Signed-off-by: Maxime Peim <mpeim@cisco.com> Change-Id: I7bfe391dd64729011b03f3e5b89408dfc340e036
Diffstat (limited to 'src/vnet/util/throttle.c')
-rw-r--r--src/vnet/util/throttle.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/vnet/util/throttle.c b/src/vnet/util/throttle.c
index 0985b4a81a3..8b8e030bf53 100644
--- a/src/vnet/util/throttle.c
+++ b/src/vnet/util/throttle.c
@@ -16,17 +16,18 @@
#include <vnet/util/throttle.h>
void
-throttle_init (throttle_t * t, u32 n_threads, f64 time)
+throttle_init (throttle_t *t, u32 n_threads, u32 buckets, f64 time)
{
u32 i;
t->time = time;
+ t->buckets = 1 << max_log2 (buckets);
vec_validate (t->bitmaps, n_threads);
vec_validate (t->seeds, n_threads);
vec_validate (t->last_seed_change_time, n_threads);
for (i = 0; i < n_threads; i++)
- vec_validate (t->bitmaps[i], (THROTTLE_BITS / BITS (uword)) - 1);
+ clib_bitmap_alloc (t->bitmaps[i], t->buckets);
}
/*