diff options
author | 2025-04-19 18:51:06 +0200 | |
---|---|---|
committer | 2025-04-24 13:27:22 +0000 | |
commit | fc7b794758fbdd9bcae337e90255c1fc1e548808 (patch) | |
tree | 35ebef921658c028aa9d6c439677a7ffd21d6399 /src/vnet/util | |
parent | ae87469885b30ba68fd4457f75fc2613d908e451 (diff) |
vppinfra: unify thread_index handling
use typedef for thread_index instead if u16, u32, uword....
Type: improvement
Change-Id: Ib31a0f918035e07d8f53c46a3d80b9ad8b3df129
Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vnet/util')
-rw-r--r-- | src/vnet/util/refcount.c | 2 | ||||
-rw-r--r-- | src/vnet/util/refcount.h | 7 | ||||
-rw-r--r-- | src/vnet/util/throttle.h | 5 |
3 files changed, 8 insertions, 6 deletions
diff --git a/src/vnet/util/refcount.c b/src/vnet/util/refcount.c index a7b525d67be..dcb29841262 100644 --- a/src/vnet/util/refcount.c +++ b/src/vnet/util/refcount.c @@ -32,7 +32,7 @@ u64 vlib_refcount_get(vlib_refcount_t *r, u32 index) { u64 count = 0; vlib_thread_main_t *tm = vlib_get_thread_main (); - u32 thread_index; + clib_thread_index_t thread_index; for (thread_index = 0; thread_index < tm->n_vlib_mains; thread_index++) { vlib_refcount_lock(r->per_cpu[thread_index].counter_lock); if (index < vec_len(r->per_cpu[thread_index].counters)) diff --git a/src/vnet/util/refcount.h b/src/vnet/util/refcount.h index 4c7d7bdbdd5..63bc80d72be 100644 --- a/src/vnet/util/refcount.h +++ b/src/vnet/util/refcount.h @@ -64,8 +64,9 @@ void vlib_refcount_unlock (clib_spinlock_t counter_lock) void __vlib_refcount_resize(vlib_refcount_per_cpu_t *per_cpu, u32 size); -static_always_inline -void vlib_refcount_add(vlib_refcount_t *r, u32 thread_index, u32 counter_index, i32 v) +static_always_inline void +vlib_refcount_add (vlib_refcount_t *r, clib_thread_index_t thread_index, + u32 counter_index, i32 v) { vlib_refcount_per_cpu_t *per_cpu = &r->per_cpu[thread_index]; if (PREDICT_FALSE(counter_index >= vec_len(per_cpu->counters))) @@ -80,7 +81,7 @@ static_always_inline void vlib_refcount_init(vlib_refcount_t *r) { vlib_thread_main_t *tm = vlib_get_thread_main (); - u32 thread_index; + clib_thread_index_t thread_index; r->per_cpu = 0; vec_validate (r->per_cpu, tm->n_vlib_mains - 1); diff --git a/src/vnet/util/throttle.h b/src/vnet/util/throttle.h index 53435c4a359..4fd1619935e 100644 --- a/src/vnet/util/throttle.h +++ b/src/vnet/util/throttle.h @@ -40,7 +40,7 @@ extern void throttle_init (throttle_t *t, u32 n_threads, u32 buckets, f64 time); always_inline u64 -throttle_seed (throttle_t * t, u32 thread_index, f64 time_now) +throttle_seed (throttle_t *t, clib_thread_index_t thread_index, f64 time_now) { if (time_now - t->last_seed_change_time[thread_index] > t->time) { @@ -53,7 +53,8 @@ throttle_seed (throttle_t * t, u32 thread_index, f64 time_now) } always_inline int -throttle_check (throttle_t * t, u32 thread_index, u64 hash, u64 seed) +throttle_check (throttle_t *t, clib_thread_index_t thread_index, u64 hash, + u64 seed) { ASSERT (is_pow2 (t->buckets)); |