From 2a7ea2ee92d6dc4800ee21323d3324a9e8449dcf Mon Sep 17 00:00:00 2001 From: Florin Coras Date: Wed, 16 Oct 2019 22:06:08 -0700 Subject: session tcp: infra for transports to send buffers Type: feature Add infra that allows transpors to enqueue pending buffers without the need to build and manage their own pending frames. An important benefit is the fact that buffer wire/tx ordering is ensured by session layer. Change-Id: I764fd1693d610b321a1d0c84b648a314f14583db Signed-off-by: Florin Coras --- src/vnet/tcp/tcp_output.c | 63 ++++++----------------------------------------- 1 file changed, 7 insertions(+), 56 deletions(-) (limited to 'src/vnet/tcp/tcp_output.c') diff --git a/src/vnet/tcp/tcp_output.c b/src/vnet/tcp/tcp_output.c index 6ba0ee28f13..e3228c07fa1 100644 --- a/src/vnet/tcp/tcp_output.c +++ b/src/vnet/tcp/tcp_output.c @@ -674,51 +674,19 @@ tcp_enqueue_to_ip_lookup (tcp_worker_ctx_t * wrk, vlib_buffer_t * b, u32 bi, session_flush_frames_main_thread (wrk->vm); } -always_inline void -tcp_enqueue_to_output_i (tcp_worker_ctx_t * wrk, vlib_buffer_t * b, u32 bi, - u8 is_ip4, u8 flush) +static void +tcp_enqueue_to_output (tcp_worker_ctx_t * wrk, vlib_buffer_t * b, u32 bi, + u8 is_ip4) { - u32 *to_next, next_index; - vlib_frame_t *f; + session_type_t st; b->flags |= VNET_BUFFER_F_LOCALLY_ORIGINATED; b->error = 0; - /* Decide where to send the packet */ - next_index = is_ip4 ? tcp4_output_node.index : tcp6_output_node.index; - tcp_trajectory_add_start (b, 2); - - /* Get frame to v4/6 output node */ - f = wrk->tx_frames[!is_ip4]; - if (!f) - { - f = vlib_get_frame_to_node (wrk->vm, next_index); - ASSERT (f); - wrk->tx_frames[!is_ip4] = f; - } - to_next = vlib_frame_vector_args (f); - to_next[f->n_vectors] = bi; - f->n_vectors += 1; - if (flush || f->n_vectors == VLIB_FRAME_SIZE) - { - vlib_put_frame_to_node (wrk->vm, next_index, f); - wrk->tx_frames[!is_ip4] = 0; - } -} - -static void -tcp_enqueue_to_output (tcp_worker_ctx_t * wrk, vlib_buffer_t * b, u32 bi, - u8 is_ip4) -{ - tcp_enqueue_to_output_i (wrk, b, bi, is_ip4, 0); + st = session_type_from_proto_and_ip (TRANSPORT_PROTO_TCP, is_ip4); + session_add_pending_tx_buffer (st, wrk->vm->thread_index, bi); } -static void -tcp_enqueue_to_output_now (tcp_worker_ctx_t * wrk, vlib_buffer_t * b, u32 bi, - u8 is_ip4) -{ - tcp_enqueue_to_output_i (wrk, b, bi, is_ip4, 1); -} #endif /* CLIB_MARCH_VARIANT */ static int @@ -1014,21 +982,6 @@ tcp_send_synack (tcp_connection_t * tc) TCP_EVT (TCP_EVT_SYNACK_SENT, tc); } -/** - * Flush tx frame populated by retransmits and timer pops - */ -void -tcp_flush_frame_to_output (tcp_worker_ctx_t * wrk, u8 is_ip4) -{ - if (wrk->tx_frames[!is_ip4]) - { - u32 next_index; - next_index = is_ip4 ? tcp4_output_node.index : tcp6_output_node.index; - vlib_put_frame_to_node (wrk->vm, next_index, wrk->tx_frames[!is_ip4]); - wrk->tx_frames[!is_ip4] = 0; - } -} - /** * Flush ip lookup tx frames populated by timer pops */ @@ -1051,8 +1004,6 @@ tcp_flush_frame_to_ip_lookup (tcp_worker_ctx_t * wrk, u8 is_ip4) void tcp_flush_frames_to_output (tcp_worker_ctx_t * wrk) { - tcp_flush_frame_to_output (wrk, 1); - tcp_flush_frame_to_output (wrk, 0); tcp_flush_frame_to_ip_lookup (wrk, 1); tcp_flush_frame_to_ip_lookup (wrk, 0); } @@ -1093,7 +1044,7 @@ tcp_send_fin (tcp_connection_t * tc) b = vlib_get_buffer (vm, bi); tcp_init_buffer (vm, b); tcp_make_fin (tc, b); - tcp_enqueue_to_output_now (wrk, b, bi, tc->c_is_ip4); + tcp_enqueue_to_output (wrk, b, bi, tc->c_is_ip4); TCP_EVT (TCP_EVT_FIN_SENT, tc); /* Account for the FIN */ tc->snd_nxt += 1; -- cgit 1.2.3-korg