aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/tcp
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2020-03-27 23:55:06 +0000
committerDave Barach <openvpp@barachs.net>2020-03-30 20:34:48 +0000
commit5484daa001ccbbbf8773b273f428dbcddc4750cc (patch)
tree711404688109b8ec3cd8e6a58b236d9c85d23e27 /src/vnet/tcp
parent87b7e3df2b6f0335424c338ee7d61d426ef45904 (diff)
tcp: reuse session infra for syns and resets
Type: improvement Signed-off-by: Florin Coras <fcoras@cisco.com> Change-Id: I71df27049ef0193578f0c42f8f8bbd5c54e4d53e
Diffstat (limited to 'src/vnet/tcp')
-rw-r--r--src/vnet/tcp/tcp.c44
-rw-r--r--src/vnet/tcp/tcp.h13
-rw-r--r--src/vnet/tcp/tcp_output.c54
3 files changed, 38 insertions, 73 deletions
diff --git a/src/vnet/tcp/tcp.c b/src/vnet/tcp/tcp.c
index 25a3a446463..a1d774dc89b 100644
--- a/src/vnet/tcp/tcp.c
+++ b/src/vnet/tcp/tcp.c
@@ -1460,28 +1460,7 @@ tcp_dispatch_pending_timers (tcp_worker_ctx_t * wrk)
}
if (thread_index == 0 && clib_fifo_elts (wrk->pending_timers))
- vlib_process_signal_event_mt (wrk->vm, session_queue_process_node.index,
- SESSION_Q_PROCESS_FLUSH_FRAMES, 0);
-}
-
-/**
- * Flush ip lookup tx frames populated by timer pops
- */
-static void
-tcp_flush_frames_to_output (tcp_worker_ctx_t * wrk)
-{
- if (wrk->ip_lookup_tx_frames[0])
- {
- vlib_put_frame_to_node (wrk->vm, ip4_lookup_node.index,
- wrk->ip_lookup_tx_frames[0]);
- wrk->ip_lookup_tx_frames[0] = 0;
- }
- if (wrk->ip_lookup_tx_frames[1])
- {
- vlib_put_frame_to_node (wrk->vm, ip6_lookup_node.index,
- wrk->ip_lookup_tx_frames[1]);
- wrk->ip_lookup_tx_frames[1] = 0;
- }
+ session_queue_run_on_main_thread (wrk->vm);
}
static void
@@ -1514,7 +1493,6 @@ tcp_update_time (f64 now, u8 thread_index)
tcp_handle_cleanups (wrk, now);
tw_timer_expire_timers_16t_2w_512sl (&wrk->timer_wheel, now);
tcp_dispatch_pending_timers (wrk);
- tcp_flush_frames_to_output (wrk);
}
static void
@@ -1629,8 +1607,7 @@ tcp_expired_timers_dispatch (u32 * expired_timers)
max_per_loop);
if (thread_index == 0)
- vlib_process_signal_event_mt (wrk->vm, session_queue_process_node.index,
- SESSION_Q_PROCESS_FLUSH_FRAMES, 0);
+ session_queue_run_on_main_thread (wrk->vm);
}
static void
@@ -1691,6 +1668,12 @@ tcp_main_enable (vlib_main_t * vm)
n_workers = num_threads == 1 ? 1 : vtm->n_threads;
prealloc_conn_per_wrk = tcp_cfg.preallocated_connections / n_workers;
+ wrk = &tm->wrk_ctx[0];
+ wrk->tco_next_node[0] = vlib_node_get_next (vm, session_queue_node.index,
+ tcp4_output_node.index);
+ wrk->tco_next_node[1] = vlib_node_get_next (vm, session_queue_node.index,
+ tcp6_output_node.index);
+
for (thread = 0; thread < num_threads; thread++)
{
wrk = &tm->wrk_ctx[thread];
@@ -1704,6 +1687,12 @@ tcp_main_enable (vlib_main_t * vm)
wrk->vm = vlib_mains[thread];
wrk->max_timers_per_loop = 10;
+ if (thread > 0)
+ {
+ wrk->tco_next_node[0] = tm->wrk_ctx[0].tco_next_node[0];
+ wrk->tco_next_node[1] = tm->wrk_ctx[0].tco_next_node[1];
+ }
+
/*
* Preallocate connections. Assume that thread 0 won't
* use preallocated threads when running multi-core
@@ -1734,6 +1723,11 @@ tcp_main_enable (vlib_main_t * vm)
tm->bytes_per_buffer = vlib_buffer_get_default_data_size (vm);
tm->cc_last_type = TCP_CC_LAST;
+
+ tm->ipl_next_node[0] = vlib_node_get_next (vm, session_queue_node.index,
+ ip4_lookup_node.index);
+ tm->ipl_next_node[1] = vlib_node_get_next (vm, session_queue_node.index,
+ ip6_lookup_node.index);
return error;
}
diff --git a/src/vnet/tcp/tcp.h b/src/vnet/tcp/tcp.h
index 361abe25729..30c95a48ffa 100644
--- a/src/vnet/tcp/tcp.h
+++ b/src/vnet/tcp/tcp.h
@@ -559,8 +559,11 @@ typedef struct tcp_worker_ctx_
/* Max timers to be handled per dispatch loop */
u32 max_timers_per_loop;
- /** tx frames for ip 4/6 lookup nodes */
- vlib_frame_t *ip_lookup_tx_frames[2];
+ /** Session layer edge indices to tcp output */
+ u32 tco_next_node[2];
+
+ /* Fifo of pending timer expirations */
+ u32 *pending_timers;
CLIB_CACHE_LINE_ALIGN_MARK (cacheline1);
@@ -570,9 +573,6 @@ typedef struct tcp_worker_ctx_
/** tx buffer free list */
u32 *tx_buffers;
- /* Fifo of pending timer expirations */
- u32 *pending_timers;
-
/* fifo of pending free requests */
tcp_cleanup_req_t *pending_cleanups;
@@ -679,6 +679,9 @@ typedef struct _tcp_main
/** vlib buffer size */
u32 bytes_per_buffer;
+ /** Session layer edge indices to ip lookup (syns, rst) */
+ u32 ipl_next_node[2];
+
/** Dispatch table by state and flags */
tcp_lookup_dispatch_t dispatch_table[TCP_N_STATES][64];
diff --git a/src/vnet/tcp/tcp_output.c b/src/vnet/tcp/tcp_output.c
index aff2d932331..d07fb2ec26e 100644
--- a/src/vnet/tcp/tcp_output.c
+++ b/src/vnet/tcp/tcp_output.c
@@ -620,13 +620,12 @@ tcp_make_synack (tcp_connection_t * tc, vlib_buffer_t * b)
th->checksum = tcp_compute_checksum (tc, b);
}
-always_inline void
-tcp_enqueue_to_ip_lookup_i (tcp_worker_ctx_t * wrk, vlib_buffer_t * b, u32 bi,
- u8 is_ip4, u32 fib_index, u8 flush)
+static void
+tcp_enqueue_to_ip_lookup (tcp_worker_ctx_t * wrk, vlib_buffer_t * b, u32 bi,
+ u8 is_ip4, u32 fib_index)
{
+ tcp_main_t *tm = &tcp_main;
vlib_main_t *vm = wrk->vm;
- u32 *to_next, next_index;
- vlib_frame_t *f;
b->flags |= VNET_BUFFER_F_LOCALLY_ORIGINATED;
b->error = 0;
@@ -634,55 +633,24 @@ tcp_enqueue_to_ip_lookup_i (tcp_worker_ctx_t * wrk, vlib_buffer_t * b, u32 bi,
vnet_buffer (b)->sw_if_index[VLIB_TX] = fib_index;
vnet_buffer (b)->sw_if_index[VLIB_RX] = 0;
- /* Send to IP lookup */
- next_index = is_ip4 ? ip4_lookup_node.index : ip6_lookup_node.index;
tcp_trajectory_add_start (b, 1);
- f = wrk->ip_lookup_tx_frames[!is_ip4];
- if (!f)
- {
- f = vlib_get_frame_to_node (vm, next_index);
- ASSERT (f);
- wrk->ip_lookup_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 (vm, next_index, f);
- wrk->ip_lookup_tx_frames[!is_ip4] = 0;
- }
-}
-
-static void
-tcp_enqueue_to_ip_lookup_now (tcp_worker_ctx_t * wrk, vlib_buffer_t * b,
- u32 bi, u8 is_ip4, u32 fib_index)
-{
- tcp_enqueue_to_ip_lookup_i (wrk, b, bi, is_ip4, fib_index, 1);
-}
+ session_add_pending_tx_buffer (vm->thread_index, bi,
+ tm->ipl_next_node[!is_ip4]);
-static void
-tcp_enqueue_to_ip_lookup (tcp_worker_ctx_t * wrk, vlib_buffer_t * b, u32 bi,
- u8 is_ip4, u32 fib_index)
-{
- tcp_enqueue_to_ip_lookup_i (wrk, b, bi, is_ip4, fib_index, 0);
- if (wrk->vm->thread_index == 0 && vlib_num_workers ())
- session_flush_frames_main_thread (wrk->vm);
+ if (vm->thread_index == 0 && vlib_num_workers ())
+ session_queue_run_on_main_thread (wrk->vm);
}
static void
tcp_enqueue_to_output (tcp_worker_ctx_t * wrk, vlib_buffer_t * b, u32 bi,
u8 is_ip4)
{
- session_type_t st;
-
b->flags |= VNET_BUFFER_F_LOCALLY_ORIGINATED;
b->error = 0;
- st = session_type_from_proto_and_ip (TRANSPORT_PROTO_TCP, is_ip4);
- session_add_pending_tx_buffer (st, wrk->vm->thread_index, bi);
+ session_add_pending_tx_buffer (wrk->vm->thread_index, bi,
+ wrk->tco_next_node[!is_ip4]);
}
#endif /* CLIB_MARCH_VARIANT */
@@ -846,7 +814,7 @@ tcp_send_reset_w_pkt (tcp_connection_t * tc, vlib_buffer_t * pkt,
ASSERT (!bogus);
}
- tcp_enqueue_to_ip_lookup_now (wrk, b, bi, is_ip4, fib_index);
+ tcp_enqueue_to_ip_lookup (wrk, b, bi, is_ip4, fib_index);
TCP_EVT (TCP_EVT_RST_SENT, tc);
vlib_node_increment_counter (vm, tcp_node_index (output, tc->c_is_ip4),
TCP_ERROR_RST_SENT, 1);