session tls: improve app transports tx scheduling

Type: improvement

- allow apps to request rescheduling of tx events via
SESSION_F_CUSTOM_TX flag
- limit max burst per session custom tx dispatch

In tls
- use the new infra to reschedule tx events
- use max burst bytes as upper limit to number of bytes to be encrypted

Signed-off-by: Florin Coras <fcoras@cisco.com>
Change-Id: I544a5a3337af7ebdff3406b776adf30cf96ebf3c
This commit is contained in:
Florin Coras
2020-02-27 04:32:51 +00:00
committed by Dave Barach
parent 3e07a4a1e8
commit ed8db52539
7 changed files with 54 additions and 35 deletions

View File

@ -431,7 +431,7 @@ mbedtls_ctx_handshake_rx (tls_ctx_t * ctx)
}
static int
mbedtls_ctx_write (tls_ctx_t * ctx, session_t * app_session)
mbedtls_ctx_write (tls_ctx_t * ctx, session_t * app_session, u32 max_write)
{
mbedtls_ctx_t *mc = (mbedtls_ctx_t *) ctx;
u8 thread_index = ctx->c_thread_index;
@ -446,13 +446,14 @@ mbedtls_ctx_write (tls_ctx_t * ctx, session_t * app_session)
if (!deq_max)
return 0;
deq_max = clib_min (deq_max, max_write);
tls_session = session_get_from_handle (ctx->tls_session_handle);
enq_max = svm_fifo_max_enqueue_prod (tls_session->tx_fifo);
deq_now = clib_min (deq_max, TLS_CHUNK_SIZE);
if (PREDICT_FALSE (enq_max == 0))
{
tls_add_vpp_q_builtin_tx_evt (app_session);
app_session->flags |= SESSION_F_CUSTOM_TX;
return 0;
}
@ -462,7 +463,7 @@ mbedtls_ctx_write (tls_ctx_t * ctx, session_t * app_session)
wrote = mbedtls_ssl_write (&mc->ssl, mm->tx_bufs[thread_index], deq_now);
if (wrote <= 0)
{
tls_add_vpp_q_builtin_tx_evt (app_session);
app_session->flags |= SESSION_F_CUSTOM_TX;
return 0;
}
@ -471,7 +472,7 @@ mbedtls_ctx_write (tls_ctx_t * ctx, session_t * app_session)
tls_add_vpp_q_tx_evt (tls_session);
if (deq_now < deq_max)
tls_add_vpp_q_builtin_tx_evt (app_session);
app_session->flags |= SESSION_F_CUSTOM_TX;
return 0;
}