From aeb7c1cb6e11dde259d954f7fabb95073a3b4c54 Mon Sep 17 00:00:00 2001 From: Florin Coras Date: Fri, 10 Mar 2023 10:22:21 -0800 Subject: session vcl: refactor builtin tx event for main tx Rename unused SESSION_IO_EVT_BUILTIN_TX to SESSION_IO_EVT_TX_MAIN and leverage it for non-connected udp tx. Non-connected udp sessions are listeners and are therefore allocated on main thread. Consequently, whenever session queue node is not polling main, tx events generated by external applications might be missed or processed with some delay. To solve this, request that apps use SESSION_IO_EVT_TX_MAIN tx events as opposed to SESSION_IO_EVT_TX and send that to first worker as opposed to main. Type: fix Signed-off-by: Florin Coras Change-Id: I5df5ac3dc80c0f192b2eefb1d465e9deefe8786b --- src/vnet/session/session.c | 2 +- src/vnet/session/session.h | 2 +- src/vnet/session/session_api.c | 2 ++ src/vnet/session/session_debug.c | 2 +- src/vnet/session/session_debug.h | 44 ++++++++++++++++++++-------------------- src/vnet/session/session_node.c | 8 +++++--- src/vnet/session/session_types.h | 3 +-- 7 files changed, 33 insertions(+), 30 deletions(-) (limited to 'src/vnet/session') diff --git a/src/vnet/session/session.c b/src/vnet/session/session.c index fe05dd21f68..93bdf6cba1f 100644 --- a/src/vnet/session/session.c +++ b/src/vnet/session/session.c @@ -59,7 +59,7 @@ session_send_evt_to_thread (void *data, void *args, u32 thread_index, evt = (session_event_t *) svm_msg_q_msg_data (mq, &msg); evt->session_index = *(u32 *) data; break; - case SESSION_IO_EVT_BUILTIN_TX: + case SESSION_IO_EVT_TX_MAIN: case SESSION_CTRL_EVT_CLOSE: case SESSION_CTRL_EVT_RESET: msg = svm_msg_q_alloc_msg_w_ring (mq, SESSION_MQ_IO_EVT_RING); diff --git a/src/vnet/session/session.h b/src/vnet/session/session.h index ab92295ea42..456718afb89 100644 --- a/src/vnet/session/session.h +++ b/src/vnet/session/session.h @@ -333,7 +333,7 @@ session_evt_ctrl_data (session_worker_t * wrk, session_evt_elt_t * elt) static inline void session_evt_ctrl_data_free (session_worker_t * wrk, session_evt_elt_t * elt) { - ASSERT (elt->evt.event_type > SESSION_IO_EVT_BUILTIN_TX); + ASSERT (elt->evt.event_type >= SESSION_CTRL_EVT_RPC); pool_put_index (wrk->ctrl_evts_data, elt->evt.ctrl_data_index); } diff --git a/src/vnet/session/session_api.c b/src/vnet/session/session_api.c index 2502ef6a70a..3481cdf8730 100644 --- a/src/vnet/session/session_api.c +++ b/src/vnet/session/session_api.c @@ -314,6 +314,8 @@ mq_send_session_bound_cb (u32 app_wrk_index, u32 api_context, if (session_transport_service_type (ls) == TRANSPORT_SERVICE_CL && ls->rx_fifo) { + m.mq_index = transport_cl_thread (); + m.vpp_evt_q = fifo_segment_msg_q_offset (eq_seg, m.mq_index); m.rx_fifo = fifo_segment_fifo_offset (ls->rx_fifo); m.tx_fifo = fifo_segment_fifo_offset (ls->tx_fifo); m.segment_handle = session_segment_handle (ls); diff --git a/src/vnet/session/session_debug.c b/src/vnet/session/session_debug.c index dba4ef36fb8..39d1752bdc6 100644 --- a/src/vnet/session/session_debug.c +++ b/src/vnet/session/session_debug.c @@ -280,7 +280,7 @@ session_node_cmp_event (session_event_t * e, svm_fifo_t * f) case SESSION_IO_EVT_RX: case SESSION_IO_EVT_TX: case SESSION_IO_EVT_BUILTIN_RX: - case SESSION_IO_EVT_BUILTIN_TX: + case SESSION_IO_EVT_TX_MAIN: case SESSION_IO_EVT_TX_FLUSH: if (e->session_index == f->shr->master_session_index) return 1; diff --git a/src/vnet/session/session_debug.h b/src/vnet/session/session_debug.h index 614ffc95a7b..45dd77c7e45 100644 --- a/src/vnet/session/session_debug.h +++ b/src/vnet/session/session_debug.h @@ -70,28 +70,28 @@ typedef enum session_evt_to_grp_ #undef _ } session_evt_to_grp_e; -#define foreach_session_events \ -_(CLK_UPDATE_TIME, 1, 1, "Time Update Time") \ -_(CLK_MQ_DEQ, 1, 1, "Time MQ Dequeue") \ -_(CLK_CTRL_EVTS, 1, 1, "Time Ctrl Events") \ -_(CLK_NEW_IO_EVTS, 1, 1, "Time New IO Events") \ -_(CLK_OLD_IO_EVTS, 1, 1, "Time Old IO Events") \ -_(CLK_TOTAL, 1, 1, "Time Total in Node") \ -_(CLK_START, 1, 1, "Time Since Last Reset") \ - \ -_(CNT_MQ_EVTS, 1, 0, "# of MQ Events Processed" ) \ -_(CNT_CTRL_EVTS, 1, 0, "# of Ctrl Events Processed" ) \ -_(CNT_NEW_EVTS, 1, 0, "# of New Events Processed" ) \ -_(CNT_OLD_EVTS, 1, 0, "# of Old Events Processed" ) \ -_(CNT_IO_EVTS, 1, 0, "# of Events Processed" ) \ -_(CNT_NODE_CALL, 1, 0, "# of Node Calls") \ - \ -_(BASE_OFFSET_IO_EVTS, 0, 0, "NULL") \ -_(SESSION_IO_EVT_RX, 1, 0, "# of IO Event RX") \ -_(SESSION_IO_EVT_TX, 1, 0, "# of IO Event TX") \ -_(SESSION_IO_EVT_TX_FLUSH, 1, 0, "# of IO Event TX Flush") \ -_(SESSION_IO_EVT_BUILTIN_RX, 1, 0, "# of IO Event BuiltIn RX") \ -_(SESSION_IO_EVT_BUILTIN_TX, 1, 0, "# of IO Event BuiltIn TX") \ +#define foreach_session_events \ + _ (CLK_UPDATE_TIME, 1, 1, "Time Update Time") \ + _ (CLK_MQ_DEQ, 1, 1, "Time MQ Dequeue") \ + _ (CLK_CTRL_EVTS, 1, 1, "Time Ctrl Events") \ + _ (CLK_NEW_IO_EVTS, 1, 1, "Time New IO Events") \ + _ (CLK_OLD_IO_EVTS, 1, 1, "Time Old IO Events") \ + _ (CLK_TOTAL, 1, 1, "Time Total in Node") \ + _ (CLK_START, 1, 1, "Time Since Last Reset") \ + \ + _ (CNT_MQ_EVTS, 1, 0, "# of MQ Events Processed") \ + _ (CNT_CTRL_EVTS, 1, 0, "# of Ctrl Events Processed") \ + _ (CNT_NEW_EVTS, 1, 0, "# of New Events Processed") \ + _ (CNT_OLD_EVTS, 1, 0, "# of Old Events Processed") \ + _ (CNT_IO_EVTS, 1, 0, "# of Events Processed") \ + _ (CNT_NODE_CALL, 1, 0, "# of Node Calls") \ + \ + _ (BASE_OFFSET_IO_EVTS, 0, 0, "NULL") \ + _ (SESSION_IO_EVT_RX, 1, 0, "# of IO Event RX") \ + _ (SESSION_IO_EVT_TX, 1, 0, "# of IO Event TX") \ + _ (SESSION_IO_EVT_TX_FLUSH, 1, 0, "# of IO Event TX Flush") \ + _ (SESSION_IO_EVT_BUILTIN_RX, 1, 0, "# of IO Event BuiltIn RX") \ + _ (SESSION_IO_EVT_TX_MAIN, 1, 0, "# of IO Event TX Main") typedef enum { diff --git a/src/vnet/session/session_node.c b/src/vnet/session/session_node.c index f1a006722fe..c61e89bf398 100644 --- a/src/vnet/session/session_node.c +++ b/src/vnet/session/session_node.c @@ -1776,11 +1776,13 @@ session_event_dispatch_io (session_worker_t * wrk, vlib_node_runtime_t * node, app_wrk = app_worker_get (s->app_wrk_index); app_worker_builtin_rx (app_wrk, s); break; - case SESSION_IO_EVT_BUILTIN_TX: - s = session_get_from_handle_if_valid (e->session_handle); + case SESSION_IO_EVT_TX_MAIN: + s = session_get_if_valid (e->session_index, 0 /* main thread */); + if (PREDICT_FALSE (!s)) + break; wrk->ctx.s = s; if (PREDICT_TRUE (s != 0)) - session_tx_fifo_dequeue_internal (wrk, node, elt, n_tx_packets); + (smm->session_tx_fns[s->session_type]) (wrk, node, elt, n_tx_packets); 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 513929a8354..9ad40fcca7f 100644 --- a/src/vnet/session/session_types.h +++ b/src/vnet/session/session_types.h @@ -348,7 +348,7 @@ typedef enum SESSION_IO_EVT_TX, SESSION_IO_EVT_TX_FLUSH, SESSION_IO_EVT_BUILTIN_RX, - SESSION_IO_EVT_BUILTIN_TX, + SESSION_IO_EVT_TX_MAIN, SESSION_CTRL_EVT_RPC, SESSION_CTRL_EVT_HALF_CLOSE, SESSION_CTRL_EVT_CLOSE, @@ -413,7 +413,6 @@ typedef enum #define FIFO_EVENT_APP_TX SESSION_IO_EVT_TX #define FIFO_EVENT_DISCONNECT SESSION_CTRL_EVT_CLOSE #define FIFO_EVENT_BUILTIN_RX SESSION_IO_EVT_BUILTIN_RX -#define FIFO_EVENT_BUILTIN_TX SESSION_IO_EVT_BUILTIN_TX typedef enum { -- cgit 1.2.3-korg