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/vnet | |
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/vnet')
-rw-r--r-- | src/vnet/session/application_interface.h | 7 | ||||
-rw-r--r-- | src/vnet/session/session_node.c | 30 | ||||
-rw-r--r-- | src/vnet/session/session_types.h | 1 |
3 files changed, 38 insertions, 0 deletions
diff --git a/src/vnet/session/application_interface.h b/src/vnet/session/application_interface.h index 7a3eeeb34c4..d1897934d61 100644 --- a/src/vnet/session/application_interface.h +++ b/src/vnet/session/application_interface.h @@ -527,6 +527,13 @@ typedef struct session_cleanup_msg_ u8 type; } __clib_packed session_cleanup_msg_t; +typedef struct session_app_wrk_rpc_msg_ +{ + u32 client_index; /**< app client index */ + u32 wrk_index; /**< dst worker index */ + u8 data[252]; /**< rpc data */ +} __clib_packed session_app_wrk_rpc_msg_t; + typedef struct app_session_event_ { svm_msg_q_msg_t msg; diff --git a/src/vnet/session/session_node.c b/src/vnet/session/session_node.c index 738f0b90124..763b789eef2 100644 --- a/src/vnet/session/session_node.c +++ b/src/vnet/session/session_node.c @@ -490,6 +490,33 @@ session_mq_worker_update_handler (void *data) app_worker_close_notify (app_wrk, s); } +static void +session_mq_app_wrk_rpc_handler (void *data) +{ + session_app_wrk_rpc_msg_t *mp = (session_app_wrk_rpc_msg_t *) data; + svm_msg_q_msg_t _msg, *msg = &_msg; + session_app_wrk_rpc_msg_t *rmp; + app_worker_t *app_wrk; + session_event_t *evt; + application_t *app; + + app = application_lookup (mp->client_index); + if (!app) + return; + + app_wrk = application_get_worker (app, mp->wrk_index); + + svm_msg_q_lock_and_alloc_msg_w_ring (app_wrk->event_queue, + SESSION_MQ_CTRL_EVT_RING, SVM_Q_WAIT, + msg); + evt = svm_msg_q_msg_data (app_wrk->event_queue, msg); + clib_memset (evt, 0, sizeof (*evt)); + evt->event_type = SESSION_CTRL_EVT_APP_WRK_RPC; + rmp = (session_app_wrk_rpc_msg_t *) evt->data; + clib_memcpy (rmp->data, mp->data, sizeof (mp->data)); + svm_msg_q_add_and_unlock (app_wrk->event_queue, msg); +} + vlib_node_registration_t session_queue_node; typedef struct @@ -1226,6 +1253,9 @@ session_event_dispatch_ctrl (session_worker_t * wrk, session_evt_elt_t * elt) case SESSION_CTRL_EVT_APP_DETACH: app_mq_detach_handler (session_evt_ctrl_data (wrk, elt)); break; + case SESSION_CTRL_EVT_APP_WRK_RPC: + session_mq_app_wrk_rpc_handler (session_evt_ctrl_data (wrk, elt)); + break; default: clib_warning ("unhandled event type %d", e->event_type); } diff --git a/src/vnet/session/session_types.h b/src/vnet/session/session_types.h index 784312d9182..b3a7eb2bb60 100644 --- a/src/vnet/session/session_types.h +++ b/src/vnet/session/session_types.h @@ -358,6 +358,7 @@ typedef enum SESSION_CTRL_EVT_APP_DEL_SEGMENT, SESSION_CTRL_EVT_MIGRATED, SESSION_CTRL_EVT_CLEANUP, + SESSION_CTRL_EVT_APP_WRK_RPC, } session_evt_type_t; #define foreach_session_ctrl_evt \ |