aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2020-03-23 15:34:22 +0000
committerDave Barach <openvpp@barachs.net>2020-04-04 17:34:13 +0000
commit9f86d225ab4f3dccbf61383a75d6af7d321a204e (patch)
tree28051dc383a6214a20854fd21a460281cd8c373c /src/vnet
parented8db52539a8d8239a9a43bea53328d25eb47f0d (diff)
session tls: support tls descheduling
Type: improvement Signed-off-by: Florin Coras <fcoras@cisco.com> Change-Id: Ieb8bb9c6deb92479fdd3e045778fe5ae4782d1ea
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/session/application_local.c2
-rw-r--r--src/vnet/session/session_node.c21
-rw-r--r--src/vnet/session/transport.h25
-rw-r--r--src/vnet/tcp/tcp.h2
-rw-r--r--src/vnet/tcp/tcp_output.c11
-rw-r--r--src/vnet/tls/tls.c27
-rw-r--r--src/vnet/tls/tls.h3
7 files changed, 58 insertions, 33 deletions
diff --git a/src/vnet/session/application_local.c b/src/vnet/session/application_local.c
index d54d1119ce6..0e1f6db19fb 100644
--- a/src/vnet/session/application_local.c
+++ b/src/vnet/session/application_local.c
@@ -470,7 +470,7 @@ format_ct_connection_id (u8 * s, va_list * args)
}
static int
-ct_custom_tx (void *session, u32 max_burst_size)
+ct_custom_tx (void *session, transport_send_params_t * sp)
{
session_t *s = (session_t *) session;
if (session_has_transport (s))
diff --git a/src/vnet/session/session_node.c b/src/vnet/session/session_node.c
index 30eca1e6577..f023a95c98c 100644
--- a/src/vnet/session/session_node.c
+++ b/src/vnet/session/session_node.c
@@ -872,7 +872,8 @@ session_tx_fifo_read_and_snd_i (session_worker_t * wrk,
{
u32 n_custom_tx;
ctx->s->flags &= ~SESSION_F_CUSTOM_TX;
- n_custom_tx = ctx->transport_vft->custom_tx (ctx->tc, max_burst);
+ ctx->sp.max_burst_size = max_burst;
+ n_custom_tx = ctx->transport_vft->custom_tx (ctx->tc, &ctx->sp);
*n_tx_packets += n_custom_tx;
if (PREDICT_FALSE
(ctx->s->session_state >= SESSION_STATE_TRANSPORT_CLOSED))
@@ -1068,8 +1069,9 @@ session_tx_fifo_dequeue_internal (session_worker_t * wrk,
vlib_node_runtime_t * node,
session_evt_elt_t * elt, int *n_tx_packets)
{
+ transport_send_params_t *sp = &wrk->ctx.sp;
session_t *s = wrk->ctx.s;
- u32 n_packets, max_pkts;
+ u32 n_packets;
if (PREDICT_FALSE (s->session_state >= SESSION_STATE_TRANSPORT_CLOSED))
return 0;
@@ -1077,18 +1079,17 @@ 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;
- max_pkts = clib_min (VLIB_FRAME_SIZE - *n_tx_packets,
- TRANSPORT_PACER_MAX_BURST_PKTS);
- n_packets = transport_custom_tx (session_get_transport_proto (s), s,
- max_pkts);
- *n_tx_packets -= n_packets;
+ sp->max_burst_size = clib_min (VLIB_FRAME_SIZE - *n_tx_packets,
+ TRANSPORT_PACER_MAX_BURST_PKTS);
- if (svm_fifo_max_dequeue_cons (s->tx_fifo)
- || (s->flags & SESSION_F_CUSTOM_TX))
+ n_packets = transport_custom_tx (session_get_transport_proto (s), s, sp);
+ *n_tx_packets += n_packets;
+
+ if (s->flags & SESSION_F_CUSTOM_TX)
{
session_evt_add_old (wrk, elt);
}
- else
+ else if (!(sp->flags & TRANSPORT_SND_F_DESCHED))
{
svm_fifo_unset_event (s->tx_fifo);
if (svm_fifo_max_dequeue_cons (s->tx_fifo))
diff --git a/src/vnet/session/transport.h b/src/vnet/session/transport.h
index 6dc6984cdf4..eb98032b1e4 100644
--- a/src/vnet/session/transport.h
+++ b/src/vnet/session/transport.h
@@ -44,9 +44,21 @@ typedef enum transport_snd_flags_
typedef struct transport_send_params_
{
- u32 snd_space;
- u32 tx_offset;
- u16 snd_mss;
+ union
+ {
+ /* Used to retrieve snd params from transports */
+ struct
+ {
+ u32 snd_space;
+ u32 tx_offset;
+ u16 snd_mss;
+ };
+ /* Used by custom tx functions */
+ struct
+ {
+ u32 max_burst_size;
+ };
+ };
transport_snd_flags_t flags;
} transport_send_params_t;
@@ -76,7 +88,7 @@ typedef struct _transport_proto_vft
transport_send_params_t *sp);
void (*update_time) (f64 time_now, u8 thread_index);
void (*flush_data) (transport_connection_t *tconn);
- int (*custom_tx) (void *session, u32 max_burst_size);
+ int (*custom_tx) (void *session, transport_send_params_t *sp);
int (*app_rx_evt) (transport_connection_t *tconn);
/*
@@ -152,9 +164,10 @@ transport_get_half_open (transport_proto_t tp, u32 conn_index)
}
static inline int
-transport_custom_tx (transport_proto_t tp, void *s, u32 max_burst_size)
+transport_custom_tx (transport_proto_t tp, void *s,
+ transport_send_params_t * sp)
{
- return tp_vfts[tp].custom_tx (s, max_burst_size);
+ return tp_vfts[tp].custom_tx (s, sp);
}
static inline int
diff --git a/src/vnet/tcp/tcp.h b/src/vnet/tcp/tcp.h
index f8c8cb342fe..f4cc2c88e62 100644
--- a/src/vnet/tcp/tcp.h
+++ b/src/vnet/tcp/tcp.h
@@ -325,7 +325,7 @@ void tcp_reschedule (tcp_connection_t * tc);
fib_node_index_t tcp_lookup_rmt_in_fib (tcp_connection_t * tc);
u32 tcp_session_push_header (transport_connection_t * tconn,
vlib_buffer_t * b);
-int tcp_session_custom_tx (void *conn, u32 max_burst_size);
+int tcp_session_custom_tx (void *conn, transport_send_params_t * sp);
void tcp_connection_timers_init (tcp_connection_t * tc);
void tcp_connection_timers_reset (tcp_connection_t * tc);
diff --git a/src/vnet/tcp/tcp_output.c b/src/vnet/tcp/tcp_output.c
index 095f3602557..b1af535eea7 100644
--- a/src/vnet/tcp/tcp_output.c
+++ b/src/vnet/tcp/tcp_output.c
@@ -2010,7 +2010,7 @@ tcp_do_retransmit (tcp_connection_t * tc, u32 max_burst_size)
}
int
-tcp_session_custom_tx (void *conn, u32 max_burst_size)
+tcp_session_custom_tx (void *conn, transport_send_params_t * sp)
{
tcp_connection_t *tc = (tcp_connection_t *) conn;
u32 n_segs = 0;
@@ -2018,8 +2018,7 @@ tcp_session_custom_tx (void *conn, u32 max_burst_size)
if (tcp_in_cong_recovery (tc) && (tc->flags & TCP_CONN_RXT_PENDING))
{
tc->flags &= ~TCP_CONN_RXT_PENDING;
- n_segs = tcp_do_retransmit (tc, max_burst_size);
- max_burst_size -= n_segs;
+ n_segs = tcp_do_retransmit (tc, sp->max_burst_size);
}
if (!(tc->flags & TCP_CONN_SNDACK))
@@ -2031,13 +2030,13 @@ tcp_session_custom_tx (void *conn, u32 max_burst_size)
if (n_segs && !tc->pending_dupacks)
return n_segs;
- if (!max_burst_size)
+ if (sp->max_burst_size <= n_segs)
{
tcp_program_ack (tc);
- return max_burst_size;
+ return n_segs;
}
- n_segs += tcp_send_acks (tc, max_burst_size);
+ n_segs += tcp_send_acks (tc, sp->max_burst_size - n_segs);
return n_segs;
}
diff --git a/src/vnet/tls/tls.c b/src/vnet/tls/tls.c
index d0552dc6f3b..89dbd36bc44 100644
--- a/src/vnet/tls/tls.c
+++ b/src/vnet/tls/tls.c
@@ -307,13 +307,13 @@ tls_ctx_init_client (tls_ctx_t * ctx)
}
static inline int
-tls_ctx_write (tls_ctx_t * ctx, session_t * app_session, u32 max_burst_size)
+tls_ctx_write (tls_ctx_t * ctx, session_t * app_session,
+ transport_send_params_t * sp)
{
- u32 max_write, n_wrote;
+ u32 n_wrote;
- max_write = max_burst_size * TRANSPORT_PACER_MIN_MSS;
- n_wrote = tls_vfts[ctx->tls_ctx_engine].ctx_write (ctx, app_session,
- max_write);
+ 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);
return n_wrote > 0 ? clib_max (n_wrote / TRANSPORT_PACER_MIN_MSS, 1) : 0;
}
@@ -448,6 +448,17 @@ tls_app_rx_callback (session_t * tls_session)
}
int
+tls_app_tx_callback (session_t * tls_session)
+{
+ tls_ctx_t *ctx;
+
+ ctx = tls_ctx_get (tls_session->opaque);
+ transport_connection_reschedule (&ctx->connection);
+
+ return 0;
+}
+
+int
tls_session_connected_callback (u32 tls_app_index, u32 ho_ctx_index,
session_t * tls_session, session_error_t err)
{
@@ -524,6 +535,7 @@ static session_cb_vft_t tls_app_cb_vft = {
.add_segment_callback = tls_add_segment_callback,
.del_segment_callback = tls_del_segment_callback,
.builtin_app_rx_callback = tls_app_rx_callback,
+ .builtin_app_tx_callback = tls_app_tx_callback,
.session_cleanup_callback = tls_app_session_cleanup,
};
/* *INDENT-ON* */
@@ -712,7 +724,7 @@ tls_listener_get (u32 listener_index)
}
int
-tls_custom_tx_callback (void *session, u32 max_burst_size)
+tls_custom_tx_callback (void *session, transport_send_params_t * sp)
{
session_t *app_session = (session_t *) session;
tls_ctx_t *ctx;
@@ -722,8 +734,7 @@ tls_custom_tx_callback (void *session, u32 max_burst_size)
return 0;
ctx = tls_ctx_get (app_session->connection_index);
- tls_ctx_write (ctx, app_session, max_burst_size);
- return 0;
+ return tls_ctx_write (ctx, app_session, sp);
}
u8 *
diff --git a/src/vnet/tls/tls.h b/src/vnet/tls/tls.h
index 2d09b291aa7..d950fe82629 100644
--- a/src/vnet/tls/tls.h
+++ b/src/vnet/tls/tls.h
@@ -110,7 +110,8 @@ typedef struct tls_engine_vft_
int (*ctx_init_client) (tls_ctx_t * ctx);
int (*ctx_init_server) (tls_ctx_t * ctx);
int (*ctx_read) (tls_ctx_t * ctx, session_t * tls_session);
- int (*ctx_write) (tls_ctx_t * ctx, session_t * app_session, u32 max_write);
+ int (*ctx_write) (tls_ctx_t * ctx, session_t * app_session,
+ transport_send_params_t * sp);
u8 (*ctx_handshake_is_over) (tls_ctx_t * ctx);
int (*ctx_start_listen) (tls_ctx_t * ctx);
int (*ctx_stop_listen) (tls_ctx_t * ctx);