session: send tx events when data is dequeued 28/19428/5
authorFlorin Coras <fcoras@cisco.com>
Tue, 7 May 2019 23:28:16 +0000 (16:28 -0700)
committerDave Barach <openvpp@barachs.net>
Wed, 8 May 2019 21:15:38 +0000 (21:15 +0000)
Change-Id: Ib8cb19361c42e38e3f68d7147358378fff161eb1
Signed-off-by: Florin Coras <fcoras@cisco.com>
src/plugins/tlsopenssl/tls_openssl.c
src/vnet/session/application.h
src/vnet/session/application_worker.c
src/vnet/session/session.c
src/vnet/session/session_node.c

index 903398a..f6de0e0 100644 (file)
@@ -333,6 +333,9 @@ openssl_ctx_write (tls_ctx_t * ctx, session_t * app_session)
        }
     }
 
+  if (svm_fifo_needs_tx_ntf (app_session->tx_fifo, wrote))
+    session_dequeue_notify (app_session);
+
   if (wrote < deq_max)
     tls_add_vpp_q_builtin_tx_evt (app_session);
 
index 4485b74..cb83f65 100644 (file)
@@ -227,6 +227,7 @@ int app_worker_connect_notify (app_worker_t * app_wrk, session_t * s,
 int app_worker_close_notify (app_worker_t * app_wrk, session_t * s);
 int app_worker_reset_notify (app_worker_t * app_wrk, session_t * s);
 int app_worker_builtin_rx (app_worker_t * app_wrk, session_t * s);
+int app_worker_builtin_tx (app_worker_t * app_wrk, session_t * s);
 segment_manager_t *app_worker_get_listen_segment_manager (app_worker_t *,
                                                          session_t *);
 segment_manager_t *app_worker_get_connect_segment_manager (app_worker_t *);
index d98c437..081dbbe 100644 (file)
@@ -343,6 +343,18 @@ app_worker_builtin_rx (app_worker_t * app_wrk, session_t * s)
   return 0;
 }
 
+int
+app_worker_builtin_tx (app_worker_t * app_wrk, session_t * s)
+{
+  application_t *app = application_get (app_wrk->app_index);
+
+  if (!app->cb_fns.builtin_app_tx_callback)
+    return 0;
+
+  app->cb_fns.builtin_app_tx_callback (s);
+  return 0;
+}
+
 int
 app_worker_own_session (app_worker_t * app_wrk, session_t * s)
 {
@@ -583,7 +595,7 @@ app_send_io_evt_tx (app_worker_t * app_wrk, session_t * s, u8 lock)
   svm_msg_q_msg_t msg;
 
   if (app_worker_application_is_builtin (app_wrk))
-    return 0;
+    return app_worker_builtin_tx (app_wrk, s);
 
   mq = app_wrk->event_queue;
   if (lock)
index 75f7baf..1a304a6 100644 (file)
@@ -452,6 +452,10 @@ u32
 session_tx_fifo_dequeue_drop (transport_connection_t * tc, u32 max_bytes)
 {
   session_t *s = session_get (tc->s_index, tc->thread_index);
+
+  if (svm_fifo_needs_tx_ntf (s->tx_fifo, max_bytes))
+    session_dequeue_notify (s);
+
   return svm_fifo_dequeue_drop (s->tx_fifo, max_bytes);
 }
 
index 1a04658..067ab58 100644 (file)
@@ -792,6 +792,9 @@ session_tx_fifo_read_and_snd_i (vlib_main_t * vm, vlib_node_runtime_t * node,
       else if (svm_fifo_max_dequeue_cons (ctx->s->tx_fifo) > 0)
        if (svm_fifo_set_event (ctx->s->tx_fifo))
          vec_add1 (wrk->pending_event_vector, *e);
+
+      if (svm_fifo_needs_tx_ntf (ctx->s->tx_fifo, ctx->max_len_to_snd))
+       session_dequeue_notify (ctx->s);
     }
   return SESSION_TX_OK;
 }
@@ -905,9 +908,8 @@ session_queue_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
 
   for (i = 0; i < n_events; i++)
     {
-      session_t *s;            /* $$$ prefetch 1 ahead maybe */
       session_event_t *e;
-      u8 need_tx_ntf;
+      session_t *s;
 
       e = &fifo_events[i];
       switch (e->event_type)
@@ -933,14 +935,7 @@ session_queue_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
           * different nodes */
          rv = (smm->session_tx_fns[s->session_type]) (vm, node, wrk, e,
                                                       &n_tx_packets);
-         if (PREDICT_TRUE (rv == SESSION_TX_OK))
-           {
-             need_tx_ntf = svm_fifo_needs_tx_ntf (s->tx_fifo,
-                                                  wrk->ctx.max_len_to_snd);
-             if (PREDICT_FALSE (need_tx_ntf))
-               session_dequeue_notify (s);
-           }
-         else if (PREDICT_FALSE (rv == SESSION_TX_NO_BUFFERS))
+         if (PREDICT_FALSE (rv == SESSION_TX_NO_BUFFERS))
            {
              vlib_node_increment_counter (vm, node->node_index,
                                           SESSION_QUEUE_ERROR_NO_BUFFER, 1);