http: estimate tx packets for scheduler 20/35220/4
authorFlorin Coras <fcoras@cisco.com>
Fri, 4 Feb 2022 22:37:04 +0000 (14:37 -0800)
committerDave Barach <openvpp@barachs.net>
Sat, 5 Feb 2022 21:19:53 +0000 (21:19 +0000)
Type: improvement

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

src/plugins/http/http.c

index 574c341..657a0b5 100644 (file)
@@ -498,6 +498,9 @@ state_wait_app (http_conn_t *hc, transport_send_params_t *sp)
   /* Start sending the actual data */
   hc->req_state = HTTP_REQ_STATE_SEND_MORE_DATA;
 
+  ASSERT (sp->max_burst_size >= offset);
+  sp->max_burst_size -= offset;
+
   return 1;
 
 error:
@@ -520,6 +523,7 @@ state_send_more_data (http_conn_t *hc, transport_send_params_t *sp)
   session_t *ts;
   int sent = 0;
 
+  max_send = clib_min (max_send, sp->max_burst_size);
   ts = session_get_from_handle (hc->h_tc_session_handle);
   if ((seg = http_buffer_get_segs (hb, max_send, &n_segs)))
     sent = svm_fifo_enqueue_segments (ts->tx_fifo, seg, n_segs,
@@ -529,6 +533,7 @@ state_send_more_data (http_conn_t *hc, transport_send_params_t *sp)
     {
       /* Ask scheduler to notify app of deq event if needed */
       sp->bytes_dequeued += http_buffer_drain (hb, sent);
+      sp->max_burst_size -= sent;
     }
 
   /* Not finished sending all data */
@@ -816,6 +821,7 @@ static int
 http_app_tx_callback (void *session, transport_send_params_t *sp)
 {
   session_t *as = (session_t *) session;
+  u32 max_burst_sz, sent;
   http_conn_t *hc;
 
   hc = http_conn_get_w_thread (as->connection_index, as->thread_index);
@@ -825,6 +831,9 @@ http_app_tx_callback (void *session, transport_send_params_t *sp)
       return 0;
     }
 
+  max_burst_sz = sp->max_burst_size * TRANSPORT_PACER_MIN_MSS;
+  sp->max_burst_size = max_burst_sz;
+
   http_req_run_state_machine (hc, sp);
 
   if (hc->state == HTTP_CONN_STATE_CLOSED)
@@ -832,7 +841,10 @@ http_app_tx_callback (void *session, transport_send_params_t *sp)
       if (!svm_fifo_max_dequeue_cons (as->rx_fifo))
        http_disconnect_transport (hc);
     }
-  return 0;
+
+  sent = max_burst_sz - sp->max_burst_size;
+
+  return sent > 0 ? clib_max (sent / TRANSPORT_PACER_MIN_MSS, 1) : 0;
 }
 
 static void