15 #ifndef __included_session_h__ 16 #define __included_session_h__ 25 #define foreach_session_input_error \ 26 _(NO_SESSION, "No session drops") \ 27 _(NO_LISTENER, "No listener for dst port drops") \ 28 _(ENQUEUED, "Packets pushed into rx fifo") \ 29 _(NOT_READY, "Session not ready packets") \ 30 _(FIFO_FULL, "Packets dropped for lack of rx fifo space") \ 31 _(EVENT_FIFO_FULL, "Events not sent for lack of event fifo space") \ 32 _(API_QUEUE_FULL, "Sessions not created for lack of API queue space") \ 33 _(NEW_SEG_NO_SPACE, "Created segment, couldn't allocate a fifo pair") \ 34 _(NO_SPACE, "Couldn't allocate a fifo pair") \ 35 _(SEG_CREATE, "Couldn't create a new segment") 39 #define _(sym,str) SESSION_ERROR_##sym, 205 #define SESSION_Q_PROCESS_FLUSH_FRAMES 1 206 #define SESSION_Q_PROCESS_STOP 2 259 elt->
evt.ctrl_data_index));
304 if (thread_index >=
vec_len (session_main.
wrk))
318 u32 session_index, thread_index;
326 u32 session_index, thread_index;
404 old_s = session_main.
wrk[thread_index].
sessions + session_index;
447 u8 queue_event,
u8 is_in_order);
454 u32 old_thread_index,
462 u32 thread_index,
u8 notify);
595 return &session_main.
wrk[thread_index];
601 if (thread_index >
vec_len (session_main.
wrk))
603 return &session_main.
wrk[thread_index];
618 #define session_cli_return_if_not_enabled() \ 620 if (!session_main.is_enabled) \ 621 return clib_error_return (0, "session layer is not enabled"); \ transport_connection_t * session_get_transport(session_t *s)
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)
static clib_time_type_t transport_time_now(u32 thread_index)
svm_msg_q_t * vpp_event_queue
vpp event message queue for worker
static u32 svm_fifo_max_enqueue_prod(svm_fifo_t *f)
Maximum number of bytes that can be enqueued into fifo.
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 void session_add_pending_tx_buffer(session_type_t st, u32 thread_index, u32 bi)
uword unformat_transport_connection(unformat_input_t *input, va_list *args)
static u8 svm_fifo_has_ooo_data(svm_fifo_t *f)
Check if fifo has out-of-order data.
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
u8 session_enable_asap
Enable session manager at startup.
#define clib_llist_add_tail(LP, name, E, H)
Add entry after tail.
#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.
session_evt_ctrl_data_t * ctrl_evts_data
Pool of ctrl events data buffers.
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
static transport_proto_t session_get_transport_proto(session_t *s)
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)
void session_add_self_custom_tx_evt(transport_connection_t *tc, u8 has_prio)
static void session_pool_remove_peeker(u32 thread_index)
static session_t * session_get(u32 si, u32 thread_index)
session_evt_elt_t * event_elts
Pool of session event list elements.
static void * session_evt_ctrl_data(session_worker_t *wrk, session_evt_elt_t *elt)
u32 unique_segment_name_counter
Unique segment name counter.
static session_t * session_clone_safe(u32 session_index, u32 thread_index)
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
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
u16 * pending_tx_nexts
Vector of nexts for the pending tx buffers.
static u32 session_evt_ctrl_data_alloc(session_worker_t *wrk)
session_t * sessions
Worker session pool.
struct session_evt_elt session_evt_elt_t
static session_handle_t session_handle(session_t *s)
struct _svm_fifo svm_fifo_t
CLIB_CACHE_LINE_ALIGN_MARK(cacheline0)
static session_evt_elt_t * session_evt_elt_alloc(session_worker_t *wrk)
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.
#define clib_llist_add(LP, name, E, H)
Add entry after head.
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)
vlib_main_t * vm
Convenience pointer to this worker's vlib_main.
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 it is closed.
static u32 svm_fifo_max_dequeue(svm_fifo_t *f)
Fifo max bytes to dequeue.
clib_llist_index_t new_head
Head of list of elements.
static u32 svm_fifo_max_dequeue_cons(svm_fifo_t *f)
Fifo max bytes to dequeue optimized for consumer.
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)
u64 session_segment_handle(session_t *s)
struct _transport_proto_vft transport_proto_vft_t
struct _session_endpoint_cfg session_endpoint_cfg_t
vl_api_fib_path_type_t type
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.
int session_stream_accept(transport_connection_t *tc, u32 listener_index, u32 thread_index, u8 notify)
Accept a stream session.
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
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
static void session_evt_ctrl_data_free(session_worker_t *wrk, session_evt_elt_t *elt)
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)
#define SESSION_CTRL_MSG_MAX_SIZE
#define pool_put(P, E)
Free an object E in pool P.
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 session_evt_elt_t * session_evt_alloc_old(session_worker_t *wrk)
void session_reset(session_t *s)
Force a close without waiting for data to be flushed.
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.
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)
clib_llist_anchor_t evt_list
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.
static void session_evt_elt_free(session_worker_t *wrk, session_evt_elt_t *elt)
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.
static session_evt_elt_t * session_evt_alloc_new(session_worker_t *wrk)
void session_transport_delete_notify(transport_connection_t *tc)
Notification from transport that connection is being deleted.
struct session_worker_ session_worker_t
u32 * pending_tx_buffers
Vector of buffers to be sent.
struct session_main_ session_main_t
static u32 session_thread_from_handle(session_handle_t handle)
static clib_us_time_t transport_us_time_now(u32 thread_index)
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)
#define pool_put_index(p, i)
Free pool element with given index.
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.
struct session_ctrl_evt_data_ session_evt_ctrl_data_t
int session_send_io_evt_to_thread(svm_fifo_t *f, session_evt_type_t evt_type)
u8 session_is_valid(u32 si, u8 thread_index)
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)
void session_transport_reset(session_t *s)
Force transport close.
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)
clib_time_type_t last_vlib_time
vlib_time_now last time around the track
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)
int() session_fifo_rx_fn(session_worker_t *wrk, vlib_node_runtime_t *node, session_evt_elt_t *e, int *n_tx_packets)
u8 thread_index
Index of the thread that allocated the session.
void session_get_endpoint(session_t *s, transport_endpoint_t *tep, u8 is_lcl)
static void listen_session_free(session_t *s)
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
clib_llist_index_t old_head
Head of list of pending events.
volatile u8 session_state
State in session layer state machine.
VLIB buffer representation.
static void session_evt_add_old(session_worker_t *wrk, session_evt_elt_t *elt)
int session_main_flush_all_enqueue_events(u8 transport_proto)
static void session_evt_add_head_old(session_worker_t *wrk, session_evt_elt_t *elt)
#define foreach_session_input_error
static session_evt_elt_t * session_evt_alloc_ctrl(session_worker_t *wrk)
transport_connection_t * tc
u32 configured_v6_session_table_memory
clib_us_time_t last_vlib_us_time
vlib_time_now rounded to us precision and as u64
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)
Check if fifo has io event.
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)
clib_llist_index_t ctrl_head
Head of control events list.
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)
vl_api_fib_path_nh_proto_t proto
void session_flush_frames_main_thread(vlib_main_t *vm)
static session_worker_t * session_main_get_worker_if_valid(u32 thread_index)
static u8 session_main_is_enabled()
static void listen_session_parse_handle(session_handle_t handle, u32 *index, u32 *thread_index)