15 #ifndef __included_session_h__ 16 #define __included_session_h__ 24 #define foreach_session_input_error \ 25 _(NO_SESSION, "No session drops") \ 26 _(NO_LISTENER, "No listener for dst port drops") \ 27 _(ENQUEUED, "Packets pushed into rx fifo") \ 28 _(NOT_READY, "Session not ready packets") \ 29 _(FIFO_FULL, "Packets dropped for lack of rx fifo space") \ 30 _(EVENT_FIFO_FULL, "Events not sent for lack of event fifo space") \ 31 _(API_QUEUE_FULL, "Sessions not created for lack of API queue space") \ 32 _(NEW_SEG_NO_SPACE, "Created segment, couldn't allocate a fifo pair") \ 33 _(NO_SPACE, "Couldn't allocate a fifo pair") \ 34 _(SEG_CREATE, "Couldn't create a new segment") 38 #define _(sym,str) SESSION_ERROR_##sym, 111 session_event_t * e,
int *n_tx_pkts);
176 f64 *last_event_poll_by_thread;
186 #define SESSION_Q_PROCESS_FLUSH_FRAMES 1 187 #define SESSION_Q_PROCESS_STOP 2 216 if (thread_index >=
vec_len (session_main.
wrk))
230 u32 session_index, thread_index;
238 u32 session_index, thread_index;
316 old_s = session_main.
wrk[thread_index].
sessions + session_index;
354 u8 queue_event,
u8 is_in_order);
361 u32 old_thread_index,
501 return &session_main.
wrk[thread_index];
516 #define session_cli_return_if_not_enabled() \ 518 if (!session_main.is_enabled) \ 519 return clib_error_return(0, "session layer is not enabled"); \ transport_connection_t * session_get_transport(session_t *s)
static u8 session_is_valid(u32 si, u8 thread_index)
static void clib_rwlock_reader_lock(clib_rwlock_t *p)
u32 preallocated_sessions
Preallocate session config parameter.
int session_enqueue_dgram_connection(session_t *s, session_dgram_hdr_t *hdr, vlib_buffer_t *b, u8 proto, u8 queue_event)
uword evt_qs_segment_size
u32 session_tx_fifo_dequeue_drop(transport_connection_t *tc, u32 max_bytes)
int session_tx_fifo_peek_bytes(transport_connection_t *tc, u8 *buffer, u32 offset, u32 max_bytes)
int session_listen(session_t *s, session_endpoint_cfg_t *sep)
Ask transport to listen on session endpoint.
session_type_t session_type
Type built from transport and network protocol types.
static u32 transport_rx_fifo_size(transport_connection_t *tc)
int session_stream_accept_notify(transport_connection_t *tc)
svm_msg_q_t * vpp_event_queue
vpp event message queue for worker
transport_connection_t * listen_session_get_transport(session_t *s)
u8 * format_session(u8 *s, va_list *args)
Format stream session as per the following format.
static f64 transport_time_now(u32 thread_index)
uword unformat_transport_connection(unformat_input_t *input, va_list *args)
static u8 svm_fifo_has_ooo_data(svm_fifo_t *f)
u32 session_index
Index in thread pool where session was allocated.
struct session_tx_context_ session_tx_context_t
static svm_msg_q_t * session_main_get_vpp_event_queue(u32 thread_index)
u32 configured_v4_halfopen_table_buckets
#define clib_memcpy_fast(a, b, c)
svm_fifo_t * rx_fifo
Pointers to rx/tx buffers.
session_worker_t * wrk
Worker contexts.
static session_t * session_get_if_valid(u64 si, u32 thread_index)
static u32 session_get_index(session_t *s)
static session_t * listen_session_get_from_handle(session_handle_t handle)
int session_stop_listen(session_t *s)
Ask transport to stop listening on local transport endpoint.
static session_t * listen_session_alloc(u8 thread_index, session_type_t type)
int session_stream_connect_notify(transport_connection_t *tc, u8 is_fail)
static u32 svm_fifo_max_enqueue(svm_fifo_t *f)
static void session_pool_remove_peeker(u32 thread_index)
static session_t * session_get(u32 si, u32 thread_index)
u32 unique_segment_name_counter
Unique segment name counter.
static session_t * session_clone_safe(u32 session_index, u32 thread_index)
u32 local_endpoints_table_memory
Transport table (preallocation) size parameters.
uword unformat_session(unformat_input_t *input, va_list *args)
vlib_node_registration_t session_queue_node
(constructor) VLIB_REGISTER_NODE (session_queue_node)
static void session_parse_handle(session_handle_t handle, u32 *index, u32 *thread_index)
session_fifo_rx_fn session_tx_fifo_peek_and_snd
session_t * sessions
Worker session pool.
static session_handle_t session_handle(session_t *s)
struct _svm_fifo svm_fifo_t
CLIB_CACHE_LINE_ALIGN_MARK(cacheline0)
void session_transport_cleanup(session_t *s)
Cleanup transport and session state.
session_t * session_alloc(u32 thread_index)
u32 * tx_buffers
Vector of tx buffer free lists.
static session_worker_t * session_main_get_worker(u32 thread_index)
vlib_node_registration_t session_queue_pre_input_node
(constructor) VLIB_REGISTER_NODE (session_queue_pre_input_node)
void session_send_rpc_evt_to_thread(u32 thread_index, void *fp, void *rpc_args)
void session_transport_closed_notify(transport_connection_t *tc)
Notification from transport that session can be closed.
static u32 svm_fifo_max_dequeue(svm_fifo_t *f)
u32 * session_type_to_next
Per session type output nodes.
int session_open(u32 app_index, session_endpoint_t *tep, u32 opaque)
Ask transport to open connection to remote transport endpoint.
uword session_baseva
Session ssvm segment configs.
int session_dequeue_notify(session_t *s)
session_event_t * free_event_vector
Vector of partially read events.
u64 session_segment_handle(session_t *s)
struct _transport_proto_vft transport_proto_vft_t
struct _session_endpoint_cfg session_endpoint_cfg_t
u32 configured_v6_halfopen_table_memory
u32 configured_v6_session_table_buckets
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
uword session_va_space_size
u32 configured_v4_session_table_buckets
Session table size parameters.
static void clib_rwlock_reader_unlock(clib_rwlock_t *p)
static session_t * session_get_from_handle(session_handle_t handle)
transport_proto_vft_t * transport_vft
session_event_t * pending_disconnects
Vector of postponed disconnects.
void session_register_transport(transport_proto_t transport_proto, const transport_proto_vft_t *vft, u8 is_ip4, u32 output_node)
Initialize session layer for given transport proto and ip version.
u32 configured_v6_halfopen_table_buckets
u32 configured_event_queue_length
vpp fifo event queue configured length
void session_free(session_t *s)
u8 is_enabled
Session manager is enabled.
static u32 transport_max_rx_dequeue(transport_connection_t *tc)
static session_t * session_get_from_handle_safe(u64 handle)
Get session from handle and 'lock' pool resize if not in same thread.
session_fifo_rx_fn ** session_tx_fns
Per transport rx function that can either dequeue or peek.
static u64 listen_session_get_handle(session_t *s)
static void session_pool_add_peeker(u32 thread_index)
Acquires a lock that blocks a session pool from expanding.
int( session_fifo_rx_fn)(vlib_main_t *vm, vlib_node_runtime_t *node, session_worker_t *wrk, session_event_t *e, int *n_tx_pkts)
clib_rwlock_t peekers_rw_locks
Peekers rw lock.
static session_t * session_get_from_handle_if_valid(session_handle_t handle)
void session_node_enable_disable(u8 is_en)
f64 dispatch_period
Our approximation of a "complete" dispatch loop period.
session_fifo_rx_fn session_tx_fifo_dequeue_and_snd
ssvm_private_t evt_qs_segment
Event queues memfd segment initialized only if so configured.
int session_dgram_connect_notify(transport_connection_t *tc, u32 old_thread_index, session_t **new_session)
Move dgram session to the right thread.
static_always_inline uword vlib_get_thread_index(void)
Unidirectional shared-memory multi-ring message queue.
session_main_t session_main
static u8 transport_rx_fifo_has_ooo_data(transport_connection_t *tc)
void session_free_w_fifos(session_t *s)
struct _transport_connection transport_connection_t
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
void session_transport_delete_notify(transport_connection_t *tc)
Notification from transport that connection is being deleted.
session_event_t * pending_event_vector
Vector of active event vectors.
struct session_worker_ session_worker_t
struct session_main_ session_main_t
static u32 session_thread_from_handle(session_handle_t handle)
clib_error_t * vnet_session_enable_disable(vlib_main_t *vm, u8 is_en)
static u32 transport_max_tx_dequeue(transport_connection_t *tc)
static u32 session_index_from_handle(session_handle_t handle)
void session_transport_reset_notify(transport_connection_t *tc)
Notify application that connection has been reset.
int session_enqueue_notify(session_t *s)
void session_close(session_t *s)
Initialize session closing procedure.
int session_send_io_evt_to_thread(svm_fifo_t *f, session_evt_type_t evt_type)
session_tx_context_t ctx
Context for session tx.
static void transport_add_tx_event(transport_connection_t *tc)
int session_send_io_evt_to_thread_custom(void *data, u32 thread_index, session_evt_type_t evt_type)
enum _transport_proto transport_proto_t
int session_enqueue_stream_connection(transport_connection_t *tc, vlib_buffer_t *b, u32 offset, u8 queue_event, u8 is_in_order)
u32 configured_v4_halfopen_table_memory
u32 configured_v4_session_table_memory
void session_send_rpc_evt_to_thread_force(u32 thread_index, void *fp, void *rpc_args)
u8 thread_index
Index of the thread that allocated the session.
static void listen_session_free(session_t *s)
int session_stream_accept(transport_connection_t *tc, u32 listener_index, u8 notify)
Accept a stream session.
struct _vlib_node_registration vlib_node_registration_t
template key/value backing page structure
u32 local_endpoints_table_buckets
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
session_fifo_rx_fn session_tx_fifo_dequeue_internal
volatile u8 session_state
State in session layer state machine.
VLIB buffer representation.
int session_main_flush_all_enqueue_events(u8 transport_proto)
#define foreach_session_input_error
f64 last_vlib_time
vlib_time_now last time around the track
transport_connection_t * tc
u32 configured_v6_session_table_memory
vlib_node_registration_t session_queue_process_node
(constructor) VLIB_REGISTER_NODE (session_queue_process_node)
static int svm_fifo_has_event(svm_fifo_t *f)
session_event_t * postponed_event_vector
Vector of postponed events.
int session_main_flush_enqueue_events(u8 proto, u32 thread_index)
Flushes queue of sessions that are to be notified of new data enqueued events.
u8 session_node_lookup_fifo_event(svm_fifo_t *f, session_event_t *e)
static session_main_t * vnet_get_session_main()
static u32 transport_max_rx_enqueue(transport_connection_t *tc)
struct _session_endpoint session_endpoint_t
void session_transport_close(session_t *s)
Notify transport the session can be disconnected.
void session_transport_closing_notify(transport_connection_t *tc)
Notification from transport that connection is being closed.
ssvm_private_t * session_main_get_evt_q_segment(void)
static u32 transport_tx_fifo_size(transport_connection_t *tc)
static session_t * listen_session_get(u32 ls_index)
void session_flush_frames_main_thread(vlib_main_t *vm)
static f64 transport_dispatch_period(u32 thread_index)
static u8 session_main_is_enabled()
static void listen_session_parse_handle(session_handle_t handle, u32 *index, u32 *thread_index)