From 64034367e32e3636cfb764a9140d28d5715799a2 Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Mon, 7 Nov 2016 22:19:55 +0100 Subject: pg: support for packet generator on different worker threads New Debug CLI: packet-generator new { worker X } Change-Id: I71499733a29b49cd36d753d54846d2553af6d024 Signed-off-by: Damjan Marion --- vlib/vlib/threads.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'vlib') diff --git a/vlib/vlib/threads.h b/vlib/vlib/threads.h index 2772fa86e0f..e30b9e35118 100644 --- a/vlib/vlib/threads.h +++ b/vlib/vlib/threads.h @@ -353,6 +353,29 @@ static void __vlib_add_thread_registration_##x (void) \ } \ __VA_ARGS__ vlib_thread_registration_t x +always_inline u32 +vlib_num_workers () +{ + return vlib_thread_main.n_vlib_mains - 1; +} + +always_inline u32 +vlib_get_worker_cpu_index (u32 worker_index) +{ + return worker_index + 1; +} + +always_inline vlib_main_t * +vlib_get_worker_vlib_main (u32 worker_index) +{ + vlib_main_t *vm; + vlib_thread_main_t *tm = &vlib_thread_main; + ASSERT (worker_index < tm->n_vlib_mains - 1); + vm = vlib_mains[worker_index + 1]; + ASSERT (vm); + return vm; +} + #endif /* included_vlib_threads_h */ /* -- cgit 1.2.3-korg