aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/session/session.h
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2018-10-30 12:01:48 -0700
committerMarco Varlese <marco.varlese@suse.de>2018-10-31 08:17:33 +0000
commit5a7ca7bde104b12f8dc4a751fd911819d4bd6c8e (patch)
treec554ef8c3e544cb7c4a9134b4ac27da02c1f15a9 /src/vnet/session/session.h
parent1bce5a92087fc0caffe7723d2f2de7f1bf296046 (diff)
session: add wrk context
Change-Id: I66ca0ddea872948507d078e405eb90f9f3a0e897 Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/vnet/session/session.h')
-rw-r--r--src/vnet/session/session.h113
1 files changed, 66 insertions, 47 deletions
diff --git a/src/vnet/session/session.h b/src/vnet/session/session.h
index 4d46596813f..a98986124d7 100644
--- a/src/vnet/session/session.h
+++ b/src/vnet/session/session.h
@@ -186,43 +186,52 @@ extern session_fifo_rx_fn session_tx_fifo_dequeue_internal;
u8 session_node_lookup_fifo_event (svm_fifo_t * f, session_event_t * e);
-struct _session_manager_main
+typedef struct session_manager_worker_
{
- /** Per worker thread session pools */
- stream_session_t **sessions;
+ CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
- /** Per worker-thread session pool peekers rw locks */
- clib_rwlock_t *peekers_rw_locks;
+ /** Worker session pool */
+ stream_session_t *sessions;
- /** Per-proto, per-worker enqueue epoch counters */
- u64 *current_enqueue_epoch[TRANSPORT_N_PROTO];
+ /** vpp event message queue for worker */
+ svm_msg_q_t *vpp_event_queue;
- /** Per-proto, per-worker thread vector of sessions to enqueue */
- u32 **session_to_enqueue[TRANSPORT_N_PROTO];
+ /** Our approximation of a "complete" dispatch loop period */
+ f64 dispatch_period;
- /** per-worker tx buffer free lists */
- u32 **tx_buffers;
+ /** vlib_time_now last time around the track */
+ f64 last_vlib_time;
- /** Per worker-thread vector of partially read events */
- session_event_t **free_event_vector;
+ /** Per-proto enqueue epoch counters */
+ u64 current_enqueue_epoch[TRANSPORT_N_PROTO];
- /** per-worker active event vectors */
- session_event_t **pending_event_vector;
+ /** Per-proto vector of sessions to enqueue */
+ u32 *session_to_enqueue[TRANSPORT_N_PROTO];
- /** per-worker postponed disconnects */
- session_event_t **pending_disconnects;
+ /** Context for session tx */
+ session_tx_context_t ctx;
- /** per-worker session context */
- session_tx_context_t *ctx;
+ /** Vector of tx buffer free lists */
+ u32 *tx_buffers;
- /** Our approximation of a "complete" dispatch loop period */
- f64 *dispatch_period;
+ /** Vector of partially read events */
+ session_event_t *free_event_vector;
- /** vlib_time_now last time around the track */
- f64 *last_vlib_time;
+ /** Vector of active event vectors */
+ session_event_t *pending_event_vector;
+
+ /** Vector of postponed disconnects */
+ session_event_t *pending_disconnects;
- /** vpp fifo event queue */
- svm_msg_q_t **vpp_event_queues;
+ /** Peekers rw lock */
+ clib_rwlock_t peekers_rw_locks;
+
+} session_manager_worker_t;
+
+struct _session_manager_main
+{
+ /** Worker contexts */
+ session_manager_worker_t *wrk;
/** Event queues memfd segment initialized only if so configured */
ssvm_private_t evt_qs_segment;
@@ -238,16 +247,16 @@ struct _session_manager_main
* Trade memory for speed, for now */
u32 *session_type_to_next;
+ /*
+ * Config parameters
+ */
+
/** Session manager is enabled */
u8 is_enabled;
/** vpp fifo event queue configured length */
u32 configured_event_queue_length;
- /*
- * Config parameters
- */
-
/** Session ssvm segment configs*/
uword session_baseva;
uword session_va_space_size;
@@ -297,11 +306,17 @@ vnet_get_session_manager_main ()
return &session_manager_main;
}
+always_inline session_manager_worker_t *
+session_manager_get_worker (u32 thread_index)
+{
+ return &session_manager_main.wrk[thread_index];
+}
+
always_inline u8
stream_session_is_valid (u32 si, u8 thread_index)
{
stream_session_t *s;
- s = pool_elt_at_index (session_manager_main.sessions[thread_index], si);
+ s = pool_elt_at_index (session_manager_main.wrk[thread_index].sessions, si);
if (s->thread_index != thread_index || s->session_index != si
/* || s->server_rx_fifo->master_session_index != si
|| s->server_tx_fifo->master_session_index != si
@@ -320,20 +335,23 @@ always_inline stream_session_t *
session_get (u32 si, u32 thread_index)
{
ASSERT (stream_session_is_valid (si, thread_index));
- return pool_elt_at_index (session_manager_main.sessions[thread_index], si);
+ return pool_elt_at_index (session_manager_main.wrk[thread_index].sessions,
+ si);
}
always_inline stream_session_t *
session_get_if_valid (u64 si, u32 thread_index)
{
- if (thread_index >= vec_len (session_manager_main.sessions))
+ if (thread_index >= vec_len (session_manager_main.wrk))
return 0;
- if (pool_is_free_index (session_manager_main.sessions[thread_index], si))
+ if (pool_is_free_index (session_manager_main.wrk[thread_index].sessions,
+ si))
return 0;
ASSERT (stream_session_is_valid (si, thread_index));
- return pool_elt_at_index (session_manager_main.sessions[thread_index], si);
+ return pool_elt_at_index (session_manager_main.wrk[thread_index].sessions,
+ si);
}
always_inline session_handle_t
@@ -368,7 +386,7 @@ session_get_from_handle (session_handle_t handle)
session_manager_main_t *smm = &session_manager_main;
u32 session_index, thread_index;
session_parse_handle (handle, &session_index, &thread_index);
- return pool_elt_at_index (smm->sessions[thread_index], session_index);
+ return pool_elt_at_index (smm->wrk[thread_index].sessions, session_index);
}
always_inline stream_session_t *
@@ -441,19 +459,19 @@ u8 session_tx_is_dgram (stream_session_t * s);
always_inline void
session_pool_add_peeker (u32 thread_index)
{
- session_manager_main_t *smm = &session_manager_main;
+ session_manager_worker_t *wrk = &session_manager_main.wrk[thread_index];
if (thread_index == vlib_get_thread_index ())
return;
- clib_rwlock_reader_lock (&smm->peekers_rw_locks[thread_index]);
+ clib_rwlock_reader_lock (&wrk->peekers_rw_locks);
}
always_inline void
session_pool_remove_peeker (u32 thread_index)
{
- session_manager_main_t *smm = &session_manager_main;
+ session_manager_worker_t *wrk = &session_manager_main.wrk[thread_index];
if (thread_index == vlib_get_thread_index ())
return;
- clib_rwlock_reader_unlock (&smm->peekers_rw_locks[thread_index]);
+ clib_rwlock_reader_unlock (&wrk->peekers_rw_locks);
}
/**
@@ -464,18 +482,19 @@ session_pool_remove_peeker (u32 thread_index)
always_inline stream_session_t *
session_get_from_handle_safe (u64 handle)
{
- session_manager_main_t *smm = &session_manager_main;
u32 thread_index = session_thread_from_handle (handle);
+ session_manager_worker_t *wrk = &session_manager_main.wrk[thread_index];
+
if (thread_index == vlib_get_thread_index ())
{
- return pool_elt_at_index (smm->sessions[thread_index],
+ return pool_elt_at_index (wrk->sessions,
session_index_from_handle (handle));
}
else
{
session_pool_add_peeker (thread_index);
/* Don't use pool_elt_at index. See @ref session_pool_add_peeker */
- return smm->sessions[thread_index] + session_index_from_handle (handle);
+ return wrk->sessions + session_index_from_handle (handle);
}
}
@@ -503,19 +522,19 @@ transport_tx_fifo_size (transport_connection_t * tc)
always_inline f64
transport_dispatch_period (u32 thread_index)
{
- return session_manager_main.dispatch_period[thread_index];
+ return session_manager_main.wrk[thread_index].dispatch_period;
}
always_inline f64
transport_time_now (u32 thread_index)
{
- return session_manager_main.last_vlib_time[thread_index];
+ return session_manager_main.wrk[thread_index].last_vlib_time;
}
always_inline u32
session_get_index (stream_session_t * s)
{
- return (s - session_manager_main.sessions[s->thread_index]);
+ return (s - session_manager_main.wrk[s->thread_index].sessions);
}
always_inline stream_session_t *
@@ -531,7 +550,7 @@ session_clone_safe (u32 session_index, u32 thread_index)
*/
session_pool_add_peeker (thread_index);
new_s = session_alloc (current_thread_index);
- old_s = session_manager_main.sessions[thread_index] + session_index;
+ old_s = session_manager_main.wrk[thread_index].sessions + session_index;
clib_memcpy (new_s, old_s, sizeof (*new_s));
session_pool_remove_peeker (thread_index);
new_s->thread_index = current_thread_index;
@@ -607,7 +626,7 @@ clib_error_t *vnet_session_enable_disable (vlib_main_t * vm, u8 is_en);
always_inline svm_msg_q_t *
session_manager_get_vpp_event_queue (u32 thread_index)
{
- return session_manager_main.vpp_event_queues[thread_index];
+ return session_manager_main.wrk[thread_index].vpp_event_queue;
}
int session_manager_flush_enqueue_events (u8 proto, u32 thread_index);