X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Futil%2Fthrottle.h;h=38ace2801316b2d66ef30ad381e0d3cdff7a1d6e;hb=2de9c0f92;hp=97ebb2597b3a1c71f2590da1965fb5c8e650ef70;hpb=bdc0e6b7204ea0211d4f7881497e4306586fb9ef;p=vpp.git diff --git a/src/vnet/util/throttle.h b/src/vnet/util/throttle.h index 97ebb2597b3..38ace280131 100644 --- a/src/vnet/util/throttle.h +++ b/src/vnet/util/throttle.h @@ -17,6 +17,7 @@ #define __THROTTLE_H__ #include +#include /** * @brief A throttle @@ -28,7 +29,7 @@ typedef struct throttle_t_ { f64 time; uword **bitmaps; - u32 *seeds; + u64 *seeds; f64 *last_seed_change_time; } throttle_t; @@ -36,13 +37,13 @@ typedef struct throttle_t_ extern void throttle_init (throttle_t * t, u32 n_threads, f64 time); -always_inline u32 +always_inline u64 throttle_seed (throttle_t * t, u32 thread_index, f64 time_now) { if (time_now - t->last_seed_change_time[thread_index] > t->time) { - (void) random_u32 (&t->seeds[thread_index]); - memset (t->bitmaps[thread_index], 0, THROTTLE_BITS / BITS (u8)); + (void) random_u64 (&t->seeds[thread_index]); + clib_memset (t->bitmaps[thread_index], 0, THROTTLE_BITS / BITS (u8)); t->last_seed_change_time[thread_index] = time_now; } @@ -50,13 +51,14 @@ throttle_seed (throttle_t * t, u32 thread_index, f64 time_now) } always_inline int -throttle_check (throttle_t * t, u32 thread_index, u32 hash, u32 seed) +throttle_check (throttle_t * t, u32 thread_index, u64 hash, u64 seed) { int drop; uword m; u32 w; - hash ^= seed; + hash = clib_xxhash (hash ^ seed); + /* Select bit number */ hash &= THROTTLE_BITS - 1; w = hash / BITS (uword);