diff options
author | 2025-01-21 16:07:28 -0500 | |
---|---|---|
committer | 2025-01-22 20:38:06 +0000 | |
commit | 96b568a495114baccc391ca5030ad159cd082b74 (patch) | |
tree | 4e0c4826e3cadc83f3eb50a71e1cff8b42025089 /src | |
parent | b0761fd464936870a65f8d49eca8daa8215efdf2 (diff) |
session: cleanup io event functions
Program session events using session handles instead of fifos.
Type: improvement
Change-Id: I69063190598c2b4dc1104f2938f27c6cd057341a
Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/hs_apps/echo_client.c | 8 | ||||
-rw-r--r-- | src/plugins/hs_apps/echo_server.c | 7 | ||||
-rw-r--r-- | src/plugins/hs_apps/proxy.c | 12 | ||||
-rw-r--r-- | src/plugins/quic/quic.c | 11 | ||||
-rw-r--r-- | src/plugins/srtp/srtp.c | 4 | ||||
-rw-r--r-- | src/plugins/tlsopenssl/tls_bio.c | 2 | ||||
-rw-r--r-- | src/plugins/tlspicotls/tls_picotls.c | 5 | ||||
-rw-r--r-- | src/vnet/session/session.c | 10 | ||||
-rw-r--r-- | src/vnet/session/session.h | 6 | ||||
-rw-r--r-- | src/vnet/session/session_node.c | 2 | ||||
-rw-r--r-- | src/vnet/tls/tls.c | 6 |
11 files changed, 38 insertions, 35 deletions
diff --git a/src/plugins/hs_apps/echo_client.c b/src/plugins/hs_apps/echo_client.c index d5edffbd02e..ff5a3bd6b3c 100644 --- a/src/plugins/hs_apps/echo_client.c +++ b/src/plugins/hs_apps/echo_client.c @@ -96,8 +96,7 @@ send_data_chunk (ec_main_t *ecm, ec_session_t *es) svm_fifo_t *f = es->tx_fifo; rv = clib_min (svm_fifo_max_enqueue_prod (f), bytes_this_chunk); svm_fifo_enqueue_nocopy (f, rv); - session_send_io_evt_to_thread_custom ( - &es->vpp_session_index, es->thread_index, SESSION_IO_EVT_TX); + session_program_tx_io_evt (es->tx_fifo->vpp_sh, SESSION_IO_EVT_TX); } else rv = @@ -132,8 +131,7 @@ send_data_chunk (ec_main_t *ecm, ec_session_t *es) hdr.lcl_port = at->lcl_port; svm_fifo_enqueue (f, sizeof (hdr), (u8 *) & hdr); svm_fifo_enqueue_nocopy (f, rv); - session_send_io_evt_to_thread_custom ( - &es->vpp_session_index, es->thread_index, SESSION_IO_EVT_TX); + session_program_tx_io_evt (es->tx_fifo->vpp_sh, SESSION_IO_EVT_TX); } else { @@ -543,7 +541,7 @@ ec_ctrl_send (hs_test_cmd_t cmd) rv = svm_fifo_enqueue (s->tx_fifo, sizeof (ecm->cfg), (u8 *) &ecm->cfg); ASSERT (rv == sizeof (ecm->cfg)); - session_send_io_evt_to_thread (s->tx_fifo, SESSION_IO_EVT_TX); + session_program_tx_io_evt (s->handle, SESSION_IO_EVT_TX); return 0; } diff --git a/src/plugins/hs_apps/echo_server.c b/src/plugins/hs_apps/echo_server.c index b981e775b57..dc303e2f83a 100644 --- a/src/plugins/hs_apps/echo_server.c +++ b/src/plugins/hs_apps/echo_server.c @@ -256,8 +256,7 @@ echo_server_ctrl_reply (session_t *s) rv = svm_fifo_enqueue (s->tx_fifo, sizeof (esm->cfg), (u8 *) &esm->cfg); ASSERT (rv == sizeof (esm->cfg)); - session_send_io_evt_to_thread_custom (&s->session_index, s->thread_index, - SESSION_IO_EVT_TX); + session_program_tx_io_evt (s->handle, SESSION_IO_EVT_TX); } static int @@ -423,8 +422,8 @@ echo_server_rx_callback (session_t * s) { /* TODO should be session_enqueue_notify(s) but quic tests seem * to fail if that's the case */ - if (session_send_io_evt_to_thread (rx_fifo, - SESSION_IO_EVT_BUILTIN_RX)) + if (session_program_transport_io_evt (s->handle, + SESSION_IO_EVT_BUILTIN_RX)) es_err ("failed to enqueue self-tap"); if (es->rx_retries == 500000) diff --git a/src/plugins/hs_apps/proxy.c b/src/plugins/hs_apps/proxy.c index f6b7f52d80c..38d96bbf5ac 100644 --- a/src/plugins/hs_apps/proxy.c +++ b/src/plugins/hs_apps/proxy.c @@ -1099,13 +1099,7 @@ active_open_rx_callback (session_t * s) * Send event for server tx fifo */ if (svm_fifo_set_event (proxy_tx_fifo)) - { - u8 thread_index = proxy_tx_fifo->master_thread_index; - u32 session_index = proxy_tx_fifo->vpp_session_index; - return session_send_io_evt_to_thread_custom (&session_index, - thread_index, - SESSION_IO_EVT_TX); - } + session_program_tx_io_evt (proxy_tx_fifo->vpp_sh, SESSION_IO_EVT_TX); if (svm_fifo_max_enqueue (proxy_tx_fifo) <= TCP_MSS) svm_fifo_add_want_deq_ntf (proxy_tx_fifo, SVM_FIFO_WANT_DEQ_NOTIF); @@ -1136,9 +1130,7 @@ active_open_tx_callback (session_t * ao_s) if (sc->pair.is_http) { /* notify HTTP transport */ - session_t *po = session_get_from_handle (sc->pair.session_handle); - session_send_io_evt_to_thread_custom ( - &po->session_index, po->thread_index, SESSION_IO_EVT_RX); + session_program_rx_io_evt (sc->pair.session_handle); } else { diff --git a/src/plugins/quic/quic.c b/src/plugins/quic/quic.c index 15a5263284a..10651f10e7e 100644 --- a/src/plugins/quic/quic.c +++ b/src/plugins/quic/quic.c @@ -507,8 +507,7 @@ quic_set_udp_tx_evt (session_t * udp_session) { int rv = 0; if (svm_fifo_set_event (udp_session->tx_fifo)) - rv = session_send_io_evt_to_thread (udp_session->tx_fifo, - SESSION_IO_EVT_TX); + rv = session_program_tx_io_evt (udp_session->handle, SESSION_IO_EVT_TX); if (PREDICT_FALSE (rv)) clib_warning ("Event enqueue errored %d", rv); } @@ -1154,10 +1153,10 @@ quic_update_timer (quic_ctx_t * ctx) quic_session = session_get (ctx->c_s_index, ctx->c_thread_index); if (svm_fifo_set_event (quic_session->tx_fifo)) { - rv = session_send_io_evt_to_thread_custom ( - quic_session, quic_session->thread_index, SESSION_IO_EVT_TX); - if (PREDICT_FALSE (rv)) - QUIC_ERR ("Failed to enqueue builtin_tx %d", rv); + rv = session_program_tx_io_evt (quic_session->handle, + SESSION_IO_EVT_TX); + if (PREDICT_FALSE (rv)) + QUIC_ERR ("Failed to enqueue builtin_tx %d", rv); } return; } diff --git a/src/plugins/srtp/srtp.c b/src/plugins/srtp/srtp.c index 6862301d2d2..5426b7aa03f 100644 --- a/src/plugins/srtp/srtp.c +++ b/src/plugins/srtp/srtp.c @@ -291,7 +291,7 @@ done: if (n_wrote) { if (svm_fifo_set_event (us->tx_fifo)) - session_send_io_evt_to_thread (us->tx_fifo, SESSION_IO_EVT_TX); + session_program_tx_io_evt (us->handle, SESSION_IO_EVT_TX); } if (PREDICT_FALSE (ctx->app_closed && @@ -538,7 +538,7 @@ srtp_migrate_ctx (void *arg) us->opaque = ctx_handle; us->flags &= ~SESSION_F_IS_MIGRATING; if (svm_fifo_max_dequeue (us->tx_fifo)) - session_send_io_evt_to_thread (us->tx_fifo, SESSION_IO_EVT_TX); + session_program_tx_io_evt (us->handle, SESSION_IO_EVT_TX); /* Migrate app session as well */ session_dgram_connect_notify (&ctx->connection, old_thread_index, diff --git a/src/plugins/tlsopenssl/tls_bio.c b/src/plugins/tlsopenssl/tls_bio.c index eead09a9635..422cee399f6 100644 --- a/src/plugins/tlsopenssl/tls_bio.c +++ b/src/plugins/tlsopenssl/tls_bio.c @@ -80,7 +80,7 @@ bio_tls_read (BIO * b, char *out, int outl) if (svm_fifo_needs_deq_ntf (s->rx_fifo, rv)) { svm_fifo_clear_deq_ntf (s->rx_fifo); - session_send_io_evt_to_thread (s->rx_fifo, SESSION_IO_EVT_RX); + session_program_transport_io_evt (s->handle, SESSION_IO_EVT_RX); } if (svm_fifo_is_empty_cons (s->rx_fifo)) diff --git a/src/plugins/tlspicotls/tls_picotls.c b/src/plugins/tlspicotls/tls_picotls.c index 9459cb776b5..1153d39b6fe 100644 --- a/src/plugins/tlspicotls/tls_picotls.c +++ b/src/plugins/tlspicotls/tls_picotls.c @@ -406,7 +406,8 @@ do_checks: if (svm_fifo_needs_deq_ntf (tcp_rx_fifo, read)) { svm_fifo_clear_deq_ntf (tcp_rx_fifo); - session_send_io_evt_to_thread (tcp_rx_fifo, SESSION_IO_EVT_RX); + session_program_transport_io_evt (tcp_rx_fifo->vpp_sh, + SESSION_IO_EVT_RX); } } @@ -601,7 +602,7 @@ ptls_app_to_tcp_write (picotls_ctx_t *ptls_ctx, session_t *app_session, { svm_fifo_enqueue_nocopy (tcp_tx_fifo, wrote); if (svm_fifo_set_event (tcp_tx_fifo)) - session_send_io_evt_to_thread (tcp_tx_fifo, SESSION_IO_EVT_TX); + session_program_tx_io_evt (tcp_tx_fifo->vpp_sh, SESSION_IO_EVT_TX); } return wrote; diff --git a/src/vnet/session/session.c b/src/vnet/session/session.c index 1b6e8ce6c6e..2a6ac283fb9 100644 --- a/src/vnet/session/session.c +++ b/src/vnet/session/session.c @@ -83,6 +83,7 @@ session_send_evt_to_thread (void *data, void *args, u32 thread_index, return 0; } +/* Deprecated, use session_program_* functions */ int session_send_io_evt_to_thread (svm_fifo_t * f, session_evt_type_t evt_type) { @@ -90,6 +91,7 @@ session_send_io_evt_to_thread (svm_fifo_t * f, session_evt_type_t evt_type) f->master_thread_index, evt_type); } +/* Deprecated, use session_program_* functions */ int session_send_io_evt_to_thread_custom (void *data, u32 thread_index, session_evt_type_t evt_type) @@ -121,6 +123,14 @@ session_program_rx_io_evt (session_handle_tu_t sh) } int +session_program_transport_io_evt (session_handle_tu_t sh, + session_evt_type_t evt_type) +{ + return session_send_evt_to_thread ((void *) &sh.session_index, 0, + (u32) sh.thread_index, evt_type); +} + +int session_send_ctrl_evt_to_thread (session_t * s, session_evt_type_t evt_type) { /* only events supported are disconnect, shutdown and reset */ diff --git a/src/vnet/session/session.h b/src/vnet/session/session.h index 823bdcb02af..daa3bf97f56 100644 --- a/src/vnet/session/session.h +++ b/src/vnet/session/session.h @@ -484,12 +484,16 @@ void session_transport_cleanup (session_t * s); int session_enqueue_notify (session_t *s); int session_dequeue_notify (session_t * s); int session_enqueue_notify_cl (session_t *s); +/* Deprecated, use session_program_* functions */ int session_send_io_evt_to_thread (svm_fifo_t *f, session_evt_type_t evt_type); +/* Deprecated, use session_program_* functions */ int session_send_io_evt_to_thread_custom (void *data, u32 thread_index, session_evt_type_t evt_type); int session_program_tx_io_evt (session_handle_tu_t sh, session_evt_type_t evt_type); int session_program_rx_io_evt (session_handle_tu_t sh); +int session_program_transport_io_evt (session_handle_tu_t sh, + session_evt_type_t evt_type); void session_send_rpc_evt_to_thread (u32 thread_index, void *fp, void *rpc_args); void session_send_rpc_evt_to_thread_force (u32 thread_index, void *fp, @@ -659,7 +663,7 @@ transport_add_tx_event (transport_connection_t * tc) session_t *s = session_get (tc->s_index, tc->thread_index); if (svm_fifo_has_event (s->tx_fifo)) return; - session_send_io_evt_to_thread (s->tx_fifo, SESSION_IO_EVT_TX); + session_program_tx_io_evt (s->handle, SESSION_IO_EVT_TX); } always_inline u32 diff --git a/src/vnet/session/session_node.c b/src/vnet/session/session_node.c index 1d4f45e073b..dd276cd7854 100644 --- a/src/vnet/session/session_node.c +++ b/src/vnet/session/session_node.c @@ -688,7 +688,7 @@ session_mq_worker_update_handler (void *data) * Retransmit messages that may have been lost */ if (s->tx_fifo && !svm_fifo_is_empty (s->tx_fifo)) - session_send_io_evt_to_thread (s->tx_fifo, SESSION_IO_EVT_TX); + session_program_tx_io_evt (s->handle, SESSION_IO_EVT_TX); if (s->rx_fifo && !svm_fifo_is_empty (s->rx_fifo)) app_worker_rx_notify (app_wrk, s); diff --git a/src/vnet/tls/tls.c b/src/vnet/tls/tls.c index b9ff30ba6a6..08809f70070 100644 --- a/src/vnet/tls/tls.c +++ b/src/vnet/tls/tls.c @@ -66,7 +66,7 @@ int tls_add_vpp_q_rx_evt (session_t * s) { if (svm_fifo_set_event (s->rx_fifo)) - session_send_io_evt_to_thread (s->rx_fifo, SESSION_IO_EVT_RX); + session_enqueue_notify (s); return 0; } @@ -81,7 +81,7 @@ int tls_add_vpp_q_tx_evt (session_t * s) { if (svm_fifo_set_event (s->tx_fifo)) - session_send_io_evt_to_thread (s->tx_fifo, SESSION_IO_EVT_TX); + session_program_tx_io_evt (s->handle, SESSION_IO_EVT_TX); return 0; } @@ -569,7 +569,7 @@ dtls_migrate_ctx (void *arg) } if (svm_fifo_max_dequeue (us->tx_fifo)) - session_send_io_evt_to_thread (us->tx_fifo, SESSION_IO_EVT_TX); + session_program_tx_io_evt (us->handle, SESSION_IO_EVT_TX); } static void |