session: cleanup io event functions 12/42212/3
authorFlorin Coras <fcoras@cisco.com>
Tue, 21 Jan 2025 21:07:28 +0000 (16:07 -0500)
committerDave Barach <vpp@barachs.net>
Wed, 22 Jan 2025 20:38:06 +0000 (20:38 +0000)
Program session events using session handles instead of fifos.

Type: improvement

Change-Id: I69063190598c2b4dc1104f2938f27c6cd057341a
Signed-off-by: Florin Coras <fcoras@cisco.com>
src/plugins/hs_apps/echo_client.c
src/plugins/hs_apps/echo_server.c
src/plugins/hs_apps/proxy.c
src/plugins/quic/quic.c
src/plugins/srtp/srtp.c
src/plugins/tlsopenssl/tls_bio.c
src/plugins/tlspicotls/tls_picotls.c
src/vnet/session/session.c
src/vnet/session/session.h
src/vnet/session/session_node.c
src/vnet/tls/tls.c

index d5edffb..ff5a3bd 100644 (file)
@@ -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;
 }
 
index b981e77..dc303e2 100644 (file)
@@ -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)
index f6b7f52..38d96bb 100644 (file)
@@ -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
     {
index 15a5263..10651f1 100644 (file)
@@ -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;
        }
index 6862301..5426b7a 100644 (file)
@@ -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,
index eead09a..422cee3 100644 (file)
@@ -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))
index 9459cb7..1153d39 100644 (file)
@@ -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;
index 1b6e8ce..2a6ac28 100644 (file)
@@ -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)
@@ -120,6 +122,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)
 {
index 823bdcb..daa3bf9 100644 (file)
@@ -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
index 1d4f45e..dd276cd 100644 (file)
@@ -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);
index b9ff30b..08809f7 100644 (file)
@@ -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