diff options
author | Florin Coras <fcoras@cisco.com> | 2020-07-16 20:46:17 -0700 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2020-08-11 18:05:06 +0000 |
commit | 40c07ce7a78af69f7354222d4663a65cd5572049 (patch) | |
tree | 65666e13462253354216ce0565fffd2cb5e2d49f /src/vcl/vppcom.c | |
parent | 68ebcd50bfb9eee419b3efabfde3411550160d03 (diff) |
vcl: support inter worker rpc
Type: feature
Signed-off-by: Florin Coras <fcoras@cisco.com>
Change-Id: I664cd14c84fc5cf2ffe61efce99c95219b44fad7
Diffstat (limited to 'src/vcl/vppcom.c')
-rw-r--r-- | src/vcl/vppcom.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/vcl/vppcom.c b/src/vcl/vppcom.c index f1478f890c9..41d2f3170aa 100644 --- a/src/vcl/vppcom.c +++ b/src/vcl/vppcom.c @@ -351,6 +351,36 @@ vcl_send_session_worker_update (vcl_worker_t * wrk, vcl_session_t * s, app_send_ctrl_evt_to_vpp (mq, app_evt); } +void +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; + + if (data_len > sizeof (mp->data)) + goto done; + + clib_spinlock_lock (&vcm->workers_lock); + + dst_wrk = vcl_worker_get_if_valid (dst_wrk_index); + if (!dst_wrk) + goto done; + + wrk = vcl_worker_get_current (); + mq = vcl_worker_ctrl_mq (wrk); + app_alloc_ctrl_evt_to_vpp (mq, app_evt, SESSION_CTRL_EVT_APP_WRK_RPC); + mp = (session_app_wrk_rpc_msg_t *) app_evt->evt->data; + mp->client_index = wrk->my_client_index; + mp->wrk_index = dst_wrk->vpp_wrk_index; + clib_memcpy (mp->data, data, data_len); + app_send_ctrl_evt_to_vpp (mq, app_evt); + +done: + clib_spinlock_unlock (&vcm->workers_lock); +} + static u32 vcl_session_accepted_handler (vcl_worker_t * wrk, session_accepted_msg_t * mp, u32 ls_index) @@ -866,6 +896,15 @@ vcl_session_app_del_segment_handler (vcl_worker_t * wrk, void *data) VDBG (1, "Unmapped segment: %d", msg->segment_handle); } +static void +vcl_worker_rpc_handler (vcl_worker_t * wrk, void *data) +{ + if (!vcm->wrk_rpc_fn) + return; + + (vcm->wrk_rpc_fn) (data); +} + static int vcl_handle_mq_event (vcl_worker_t * wrk, session_event_t * e) { @@ -923,6 +962,9 @@ 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: + vcl_worker_rpc_handler (wrk, e->data); + break; default: clib_warning ("unhandled %u", e->event_type); } @@ -2259,6 +2301,9 @@ 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: + vcl_worker_rpc_handler (wrk, e->data); + break; default: clib_warning ("unhandled: %u", e->event_type); break; @@ -2875,6 +2920,9 @@ 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: + vcl_worker_rpc_handler (wrk, e->data); + break; default: VDBG (0, "unhandled: %u", e->event_type); break; |