session: track bytes dequeued in snd params 19/35219/7
authorFlorin Coras <fcoras@cisco.com>
Fri, 4 Feb 2022 21:31:25 +0000 (13:31 -0800)
committerDave Barach <openvpp@barachs.net>
Sat, 5 Feb 2022 21:19:53 +0000 (21:19 +0000)
Also reset send params flags before calling transports to avoid explicit
resets in all transports.

Type: improvement

Signed-off-by: Florin Coras <fcoras@cisco.com>
Change-Id: I1da7b3fab009728e7fee4199425ced933fa8a122

src/plugins/http/http.c
src/plugins/srtp/srtp.c
src/vnet/session/session_node.c
src/vnet/session/transport.h
src/vnet/tls/tls.c

index a6a6af1..574c341 100644 (file)
@@ -528,11 +528,7 @@ state_send_more_data (http_conn_t *hc, transport_send_params_t *sp)
   if (sent > 0)
     {
       /* Ask scheduler to notify app of deq event if needed */
-      sp->max_burst_size = http_buffer_drain (hb, sent);
-    }
-  else
-    {
-      sp->max_burst_size = 0;
+      sp->bytes_dequeued += http_buffer_drain (hb, sent);
     }
 
   /* Not finished sending all data */
@@ -822,8 +818,6 @@ http_app_tx_callback (void *session, transport_send_params_t *sp)
   session_t *as = (session_t *) session;
   http_conn_t *hc;
 
-  sp->flags = 0;
-
   hc = http_conn_get_w_thread (as->connection_index, as->thread_index);
   if (hc->req_state < HTTP_REQ_STATE_WAIT_APP)
     {
index 62274ba..cc4b59d 100644 (file)
@@ -238,6 +238,7 @@ srtp_ctx_write (srtp_tc_t *ctx, session_t *app_session,
   us = session_get_from_handle (ctx->srtp_session_handle);
   to_deq = svm_fifo_max_dequeue_cons (app_session->tx_fifo);
   mq = session_main_get_vpp_event_queue (us->thread_index);
+  sp->bytes_dequeued = to_deq;
 
   while (to_deq > 0)
     {
@@ -296,6 +297,9 @@ done:
       session_transport_closed_notify (&ctx->connection);
     }
 
+  ASSERT (sp->bytes_dequeued >= to_deq);
+  sp->bytes_dequeued -= to_deq;
+
   return n_wrote > 0 ? clib_max (n_wrote / TRANSPORT_PACER_MIN_MSS, 1) : 0;
 }
 
@@ -812,7 +816,6 @@ srtp_custom_tx_callback (void *session, transport_send_params_t *sp)
                     SESSION_STATE_TRANSPORT_CLOSED))
     return 0;
 
-  sp->flags = 0;
   ctx = srtp_ctx_get_w_thread (app_session->connection_index,
                               app_session->thread_index);
   if (PREDICT_FALSE (ctx->is_migrated))
index 162d54e..35ce091 100644 (file)
@@ -1441,6 +1441,8 @@ session_tx_fifo_dequeue_internal (session_worker_t * wrk,
   /* Clear custom-tx flag used to request reschedule for tx */
   s->flags &= ~SESSION_F_CUSTOM_TX;
 
+  sp->flags = 0;
+  sp->bytes_dequeued = 0;
   sp->max_burst_size = clib_min (SESSION_NODE_FRAME_SIZE - *n_tx_packets,
                                 TRANSPORT_PACER_MAX_BURST_PKTS);
 
@@ -1459,8 +1461,8 @@ session_tx_fifo_dequeue_internal (session_worker_t * wrk,
          session_evt_add_head_old (wrk, elt);
     }
 
-  if (sp->max_burst_size &&
-      svm_fifo_needs_deq_ntf (s->tx_fifo, sp->max_burst_size))
+  if (sp->bytes_dequeued &&
+      svm_fifo_needs_deq_ntf (s->tx_fifo, sp->bytes_dequeued))
     session_dequeue_notify (s);
 
   return n_packets;
index 4edc281..02ab540 100644 (file)
@@ -57,6 +57,7 @@ typedef struct transport_send_params_
     struct
     {
       u32 max_burst_size;
+      u32 bytes_dequeued;
     };
   };
   transport_snd_flags_t flags;
index 9cf1008..0184917 100644 (file)
@@ -365,7 +365,7 @@ tls_ctx_write (tls_ctx_t * ctx, session_t * app_session,
 
   sp->max_burst_size = sp->max_burst_size * TRANSPORT_PACER_MIN_MSS;
   n_wrote = tls_vfts[ctx->tls_ctx_engine].ctx_write (ctx, app_session, sp);
-  sp->max_burst_size = n_wrote;
+  sp->bytes_dequeued = n_wrote;
   return n_wrote > 0 ? clib_max (n_wrote / TRANSPORT_PACER_MIN_MSS, 1) : 0;
 }
 
@@ -942,7 +942,6 @@ tls_custom_tx_callback (void *session, transport_send_params_t * sp)
                     >= SESSION_STATE_TRANSPORT_CLOSED))
     return 0;
 
-  sp->flags = 0;
   ctx = tls_ctx_get (app_session->connection_index);
   return tls_ctx_write (ctx, app_session, sp);
 }