From 84c13e6b0246ca037183d3f8f3916777bc22ed56 Mon Sep 17 00:00:00 2001 From: IJsbrand Wijnands Date: Mon, 4 May 2020 17:57:33 +0200 Subject: vcl: allow vcl worker index to be set by applications When using vppcom_session* apis to setup TCP sessions in applications build outside of the VPP repository, it is necessary to set the worker_index explicitly when these apis are called from the none-VCL worker threads. An example is when data is to be sent to the TCP session that is originated from a different thread, like the main program thread or from the bin api thread. This change allows the application to set it. Type: fix Signed-off-by: IJsbrand Wijnands Change-Id: I37f3654a49ea9a8cf3a0d3d0e672583018c12299 (cherry picked from commit 6017ff0dd7a27c062d0ad4687bfc70a69747ac55) --- src/vcl/vppcom.c | 6 ++++++ src/vcl/vppcom.h | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/src/vcl/vppcom.c b/src/vcl/vppcom.c index a50d0abf2f4..0b61c5eb304 100644 --- a/src/vcl/vppcom.c +++ b/src/vcl/vppcom.c @@ -3635,6 +3635,12 @@ vppcom_worker_unregister (void) vcl_set_worker_index (~0); } +void +vppcom_worker_index_set (int index) +{ + vcl_set_worker_index (index); +} + int vppcom_worker_index (void) { diff --git a/src/vcl/vppcom.h b/src/vcl/vppcom.h index 62613037575..771443021b3 100644 --- a/src/vcl/vppcom.h +++ b/src/vcl/vppcom.h @@ -333,6 +333,11 @@ extern void vppcom_worker_unregister (void); */ extern int vppcom_worker_index (void); +/** + * Set current worker index + */ +extern void vppcom_worker_index_set (int); + /** * Returns the current worker's message queues epoll fd * -- cgit 1.2.3-korg