summaryrefslogtreecommitdiffstats
path: root/vlib
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2016-11-07 22:19:55 +0100
committerDamjan Marion <damarion@cisco.com>2016-11-08 12:01:00 +0100
commit64034367e32e3636cfb764a9140d28d5715799a2 (patch)
tree603199935161b41dceed17be8c1c32c7c597f91f /vlib
parent80e8816b41282ad705aa64790f1e9652f8f36f14 (diff)
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 <damarion@cisco.com>
Diffstat (limited to 'vlib')
-rw-r--r--vlib/vlib/threads.h23
1 files changed, 23 insertions, 0 deletions
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 */
/*