diff options
author | hanlin <hanlin_wang@163.com> | 2020-07-13 11:09:15 +0800 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2020-08-12 01:57:18 +0000 |
commit | a3a489691d7f2813702fae2d915120743b860d62 (patch) | |
tree | 23a22a25ebe051be37244c45fc3a0732cc296e0d /src/vcl/vppcom.c | |
parent | 40c07ce7a78af69f7354222d4663a65cd5572049 (diff) |
vcl: support multi-threads with session migration
Currently, mutlti-threads only support one dispatch thread and multiple
worker threads, eventually only dispatch thread is a vcl worker and can
interact with epoll.
This patch will register all threads as vcl worker, and then each
thread can interact with epoll now. Moreover, session migration also
supported, such as socket created in thread A and used (bind, connect
and etc.) in thread B.
Type: feature
Signed-off-by: hanlin <hanlin_wang@163.com>
Change-Id: Iab0b43a33466968c1423d7d20faf1460c8589d91
Diffstat (limited to 'src/vcl/vppcom.c')
-rw-r--r-- | src/vcl/vppcom.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/vcl/vppcom.c b/src/vcl/vppcom.c index 41d2f3170aa..d73c73be383 100644 --- a/src/vcl/vppcom.c +++ b/src/vcl/vppcom.c @@ -351,13 +351,14 @@ vcl_send_session_worker_update (vcl_worker_t * wrk, vcl_session_t * s, app_send_ctrl_evt_to_vpp (mq, app_evt); } -void +int vcl_send_worker_rpc (u32 dst_wrk_index, void *data, u32 data_len) { app_session_evt_t _app_evt, *app_evt = &_app_evt; session_app_wrk_rpc_msg_t *mp; vcl_worker_t *dst_wrk, *wrk; svm_msg_q_t *mq; + int ret = -1; if (data_len > sizeof (mp->data)) goto done; @@ -376,9 +377,11 @@ vcl_send_worker_rpc (u32 dst_wrk_index, void *data, u32 data_len) mp->wrk_index = dst_wrk->vpp_wrk_index; clib_memcpy (mp->data, data, data_len); app_send_ctrl_evt_to_vpp (mq, app_evt); + ret = 0; done: clib_spinlock_unlock (&vcm->workers_lock); + return ret; } static u32 @@ -902,7 +905,7 @@ vcl_worker_rpc_handler (vcl_worker_t * wrk, void *data) if (!vcm->wrk_rpc_fn) return; - (vcm->wrk_rpc_fn) (data); + (vcm->wrk_rpc_fn) (((session_app_wrk_rpc_msg_t *) data)->data); } static int @@ -962,7 +965,7 @@ vcl_handle_mq_event (vcl_worker_t * wrk, session_event_t * e) case SESSION_CTRL_EVT_APP_DEL_SEGMENT: vcl_session_app_del_segment_handler (wrk, e->data); break; - case SESSION_CTRL_EVT_RPC: + case SESSION_CTRL_EVT_APP_WRK_RPC: vcl_worker_rpc_handler (wrk, e->data); break; default: @@ -2301,7 +2304,7 @@ vcl_select_handle_mq_event (vcl_worker_t * wrk, session_event_t * e, case SESSION_CTRL_EVT_APP_DEL_SEGMENT: vcl_session_app_del_segment_handler (wrk, e->data); break; - case SESSION_CTRL_EVT_RPC: + case SESSION_CTRL_EVT_APP_WRK_RPC: vcl_worker_rpc_handler (wrk, e->data); break; default: @@ -2920,7 +2923,7 @@ vcl_epoll_wait_handle_mq_event (vcl_worker_t * wrk, session_event_t * e, case SESSION_CTRL_EVT_APP_DEL_SEGMENT: vcl_session_app_del_segment_handler (wrk, e->data); break; - case SESSION_CTRL_EVT_RPC: + case SESSION_CTRL_EVT_APP_WRK_RPC: vcl_worker_rpc_handler (wrk, e->data); break; default: |