|
FD.io VPP
v21.06-3-gbb25fbf28
Vector Packet Processing
|
Go to the documentation of this file.
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") \
36 #define _(sym,str) SESSION_ERROR_##sym,
257 #define TRANSPORT_PROTO_INVALID (session_main.last_transport_proto_type + 1)
258 #define TRANSPORT_N_PROTOS (session_main.last_transport_proto_type + 1)
297 elt->evt.ctrl_data_index));
493 u8 queue_event,
u8 is_in_order);
501 u32 old_thread_index,
672 s->
flags |= SESSION_F_HALF_OPEN;
727 #define session_cli_return_if_not_enabled() \
729 if (!session_main.is_enabled) \
730 return clib_error_return (0, "session layer is not enabled"); \
uword timerfd_file
Clib file for timerfd.
static clib_time_type_t transport_seconds_per_loop(u32 thread_index)
enum session_wrk_flags_ session_wrk_flag_t
u32 configured_v6_session_table_memory
session_fifo_rx_fn session_tx_fifo_dequeue_and_snd
enum session_error_ session_error_t
static u32 svm_fifo_size(svm_fifo_t *f)
session_tx_context_t ctx
Context for session tx.
u8 session_enable_asap
Enable session manager at startup.
#define SESSION_CTRL_MSG_MAX_SIZE
int session_send_io_evt_to_thread(svm_fifo_t *f, session_evt_type_t evt_type)
u32 session_index
Index in thread pool where session was allocated.
void session_get_endpoint(session_t *s, transport_endpoint_t *tep, u8 is_lcl)
int() session_fifo_rx_fn(session_worker_t *wrk, vlib_node_runtime_t *node, session_evt_elt_t *e, int *n_tx_packets)
void session_send_rpc_evt_to_thread(u32 thread_index, void *fp, void *rpc_args)
CLIB_CACHE_LINE_ALIGN_MARK(cacheline0)
transport_send_params_t sp
u8 data[SESSION_CTRL_MSG_MAX_SIZE]
static session_t * session_clone_safe(u32 session_index, u32 thread_index)
static void session_parse_handle(session_handle_t handle, u32 *index, u32 *thread_index)
int session_stream_accept_notify(transport_connection_t *tc)
int session_stream_connect_notify(transport_connection_t *tc, session_error_t err)
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.
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
int timerfd
Timerfd used to periodically signal wrk session queue node.
#define CLIB_US_TIME_FREQ
static void session_wrk_update_time(session_worker_t *wrk, f64 now)
static u64 listen_session_get_handle(session_t *s)
void session_transport_reset_notify(transport_connection_t *tc)
Notify application that connection has been reset.
int session_wrk_handle_mq(session_worker_t *wrk, svm_msg_q_t *mq)
#define clib_llist_add(LP, name, E, H)
Add entry after head.
u32 local_endpoints_table_memory
Transport table (preallocation) size parameters.
vlib_main_t vlib_node_runtime_t * node
void session_half_open_delete_notify(transport_connection_t *tc)
u32 preallocated_sessions
Preallocate session config parameter.
struct _session_endpoint_cfg session_endpoint_cfg_t
static session_worker_t * session_main_get_worker_if_valid(u32 thread_index)
#define foreach_session_input_error
static void session_add_pending_tx_buffer(u32 thread_index, u32 bi, u32 next_node)
Add session node pending buffer with custom node.
void session_transport_closed_notify(transport_connection_t *tc)
Notification from transport that it is closed.
struct _transport_proto_vft transport_proto_vft_t
static session_t * listen_session_get(u32 ls_index)
void session_add_self_custom_tx_evt(transport_connection_t *tc, u8 has_prio)
u8 thread_index
Index of the thread that allocated the session.
session_type_t session_type
Type built from transport and network protocol types.
Unidirectional shared-memory multi-ring message queue.
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
@ SESSION_Q_PROCESS_RUN_ON_MAIN
@ SESSION_IO_EVT_BUILTIN_TX
void session_close(session_t *s)
Initialize session closing procedure.
u8 session_node_lookup_fifo_event(svm_fifo_t *f, session_event_t *e)
static u32 session_thread_from_handle(session_handle_t handle)
u32 * session_type_to_next
Per session type output nodes.
struct _transport_connection transport_connection_t
static void clib_rwlock_reader_lock(clib_rwlock_t *p)
static void listen_session_parse_handle(session_handle_t handle, u32 *index, u32 *thread_index)
static u32 transport_rx_fifo_size(transport_connection_t *tc)
session_t * session_alloc_for_connection(transport_connection_t *tc)
u32 transport_cl_thread
Thread for cl and ho that rely on cl allocs.
static void ho_session_free(session_t *s)
static_always_inline void * clib_memcpy_fast(void *restrict dst, const void *restrict src, size_t n)
static void clib_rwlock_reader_unlock(clib_rwlock_t *p)
u32 * tx_buffers
Vector of tx buffer free lists.
#define pool_put_index(p, i)
Free pool element with given index.
void session_free_w_fifos(session_t *s)
#define clib_llist_add_tail(LP, name, E, H)
Add entry after tail.
clib_llist_index_t new_head
Head of list of elements.
u32 configured_v6_halfopen_table_buckets
static session_evt_elt_t * session_evt_alloc_new(session_worker_t *wrk)
transport_proto_vft_t * transport_vft
static void session_evt_add_old(session_worker_t *wrk, session_evt_elt_t *elt)
u64 session_segment_handle(session_t *s)
session_worker_t * wrk
Worker contexts.
static void * session_evt_ctrl_data(session_worker_t *wrk, session_evt_elt_t *elt)
clib_time_type_t last_vlib_time
vlib_time_now last time around the track
int session_listen(session_t *s, session_endpoint_cfg_t *sep)
Ask transport to listen on session endpoint.
struct _svm_fifo svm_fifo_t
int session_main_flush_all_enqueue_events(u8 transport_proto)
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
static u8 svm_fifo_has_ooo_data(svm_fifo_t *f)
Check if fifo has out-of-order data.
int session_half_open_migrated_notify(transport_connection_t *tc)
static void session_pool_add_peeker(u32 thread_index)
Acquires a lock that blocks a session pool from expanding.
u32 * pending_tx_buffers
Vector of buffers to be sent.
void session_transport_cleanup(session_t *s)
Cleanup transport and session state.
u32 no_connect_loops
Main thread loops in poll mode without a connect.
void session_transport_reset(session_t *s)
Force transport close.
@ SVM_FIFO_WANT_DEQ_NOTIF
Notify on dequeue.
svm_fifo_t * rx_fifo
Pointers to rx/tx buffers.
u8 session_is_valid(u32 si, u8 thread_index)
uword session_va_space_size
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
u32 unique_segment_name_counter
Unique segment name counter.
void session_queue_run_on_main_thread(vlib_main_t *vm)
static session_main_t * vnet_get_session_main()
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
static void listen_session_free(session_t *s)
struct session_tx_context_ session_tx_context_t
void session_send_rpc_evt_to_thread_force(u32 thread_index, void *fp, void *rpc_args)
u32 configured_event_queue_length
vpp fifo event queue configured length
int session_open(session_endpoint_cfg_t *sep, session_handle_t *rsh)
Ask transport to open connection to remote transport endpoint.
enum session_q_process_evt_ session_q_process_evt_t
u32 ** session_to_enqueue
Per-proto vector of sessions to enqueue.
uword session_baseva
Session ssvm segment configs.
static u8 transport_rx_fifo_has_ooo_data(transport_connection_t *tc)
transport_proto_t session_add_transport_proto(void)
void session_free(session_t *s)
static svm_msg_q_t * session_main_get_vpp_event_queue(u32 thread_index)
void session_reset(session_t *s)
Force a close without waiting for data to be flushed.
session_fifo_rx_fn session_tx_fifo_peek_and_snd
static_always_inline uword vlib_get_thread_index(void)
int session_enqueue_stream_connection(transport_connection_t *tc, vlib_buffer_t *b, u32 offset, u8 queue_event, u8 is_in_order)
int session_tx_fifo_peek_bytes(transport_connection_t *tc, u8 *buffer, u32 offset, u32 max_bytes)
session_fifo_rx_fn ** session_tx_fns
Per transport rx function that can either dequeue or peek.
uword unformat_session(unformat_input_t *input, va_list *args)
static u32 transport_max_rx_dequeue(transport_connection_t *tc)
int session_enqueue_notify(session_t *s)
clib_rwlock_t peekers_rw_locks
Peekers rw lock.
static session_t * session_get_from_handle_safe(u64 handle)
Get session from handle and 'lock' pool resize if not in same thread.
u32 configured_v6_halfopen_table_memory
struct session_ctrl_evt_data_ session_evt_ctrl_data_t
static u32 transport_max_tx_dequeue(transport_connection_t *tc)
vlib_node_registration_t session_queue_pre_input_node
(constructor) VLIB_REGISTER_NODE (session_queue_pre_input_node)
static session_evt_elt_t * session_evt_alloc_ctrl(session_worker_t *wrk)
static u32 session_get_index(session_t *s)
static u32 transport_cl_thread(void)
static u32 session_evt_ctrl_data_alloc(session_worker_t *wrk)
static u32 session_index_from_handle(session_handle_t handle)
void session_transport_half_close(session_t *s)
Notify transport the session can be half-disconnected.
u32 configured_v4_session_table_buckets
Session table size parameters.
static session_handle_t session_handle(session_t *s)
session_t * session_alloc_for_half_open(transport_connection_t *tc)
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
static session_t * session_get_from_handle(session_handle_t handle)
static session_t * session_get_from_handle_if_valid(session_handle_t handle)
session_wrk_flag_t flags
Worker flags.
u32 session_tx_fifo_dequeue_drop(transport_connection_t *tc, u32 max_bytes)
void session_node_enable_disable(u8 is_en)
u8 is_enabled
Session manager is enabled.
transport_connection_t * session_get_transport(session_t *s)
u8 use_private_rx_mqs
Allocate private rx mqs for external apps.
CLIB_CACHE_LINE_ALIGN_MARK(cacheline0)
clib_llist_anchor_t evt_list
static void session_evt_add_head_old(session_worker_t *wrk, session_evt_elt_t *elt)
struct session_main_ session_main_t
u8 is_initialized
Session manager initialized (not necessarily enabled)
void session_half_open_migrate_notify(transport_connection_t *tc)
clib_error_t * vnet_session_enable_disable(vlib_main_t *vm, u8 is_en)
void session_transport_close(session_t *s)
Notify transport the session can be disconnected.
fifo_segment_t evt_qs_segment
Event queues memfd segment.
struct _vlib_node_registration vlib_node_registration_t
static session_t * session_get(u32 si, u32 thread_index)
u32 configured_v6_session_table_buckets
u8 * format_session(u8 *s, va_list *args)
Format stream session as per the following format.
int session_stream_accept(transport_connection_t *tc, u32 listener_index, u32 thread_index, u8 notify)
Accept a stream session.
static clib_time_type_t transport_time_now(u32 thread_index)
clib_us_time_t last_vlib_us_time
vlib_time_now rounded to us precision and as u64
svm_msg_q_t * vpp_event_queue
vpp event message queue for worker
uword unformat_transport_connection(unformat_input_t *input, va_list *args)
void session_half_close(session_t *s)
Initialize session half-closing procedure.
int session_dgram_accept(transport_connection_t *tc, u32 listener_index, u32 thread_index)
fifo_segment_t * session_main_get_evt_q_segment(void)
static void transport_rx_fifo_req_deq_ntf(transport_connection_t *tc)
transport_proto_t last_transport_proto_type
session_evt_elt_t * event_elts
Pool of session event list elements.
vlib_node_registration_t session_queue_process_node
(constructor) VLIB_REGISTER_NODE (session_queue_process_node)
enum session_wrk_state_ session_wrk_state_t
template key/value backing page structure
static void session_evt_ctrl_data_free(session_worker_t *wrk, session_evt_elt_t *elt)
static u32 svm_fifo_max_enqueue_prod(svm_fifo_t *f)
Maximum number of bytes that can be enqueued into fifo.
static u8 session_main_is_enabled()
u32 configured_v4_halfopen_table_memory
static u32 transport_tx_fifo_size(transport_connection_t *tc)
int session_stop_listen(session_t *s)
Ask transport to stop listening on local transport endpoint.
static session_t * session_get_if_valid(u64 si, u32 thread_index)
int session_enqueue_dgram_connection(session_t *s, session_dgram_hdr_t *hdr, vlib_buffer_t *b, u8 proto, u8 queue_event)
static void vlib_node_set_interrupt_pending(vlib_main_t *vm, u32 node_index)
static session_t * ho_session_alloc(void)
enum _transport_proto transport_proto_t
vlib_main_t * vm
Convenience pointer to this worker's vlib_main.
session_main_t session_main
static session_t * listen_session_alloc(u8 thread_index, session_type_t type)
transport_connection_t * listen_session_get_transport(session_t *s)
session_fifo_rx_fn session_tx_fifo_dequeue_internal
struct session_evt_elt session_evt_elt_t
#define clib_llist_get(LP, E)
Alloc new element.
u16 * pending_tx_nexts
Vector of nexts for the pending tx buffers.
clib_llist_index_t pending_connects
List of pending connects for first worker.
session_t * sessions
Worker session pool.
clib_llist_index_t old_head
Head of list of pending events.
u8 no_adaptive
Do not enable session queue node adaptive mode.
static transport_proto_t session_get_transport_proto(session_t *s)
int session_transport_attribute(session_t *s, u8 is_get, transport_endpt_attr_t *attr)
void session_transport_delete_notify(transport_connection_t *tc)
Notification from transport that connection is being deleted.
static u32 transport_max_rx_enqueue(transport_connection_t *tc)
transport_connection_t * tc
session_evt_ctrl_data_t * ctrl_evts_data
Pool of ctrl events data buffers.
u32 n_pending_connects
Flag that is set if main thread signaled to handle connects.
static session_t * ho_session_get(u32 ho_index)
int session_send_io_evt_to_thread_custom(void *data, u32 thread_index, session_evt_type_t evt_type)
int session_dequeue_notify(session_t *s)
u32 local_endpoints_table_buckets
static void session_pool_remove_peeker(u32 thread_index)
static void transport_add_tx_event(transport_connection_t *tc)
struct session_worker_ session_worker_t
u8 poll_main
Poll session node in main thread.
session_wrk_state_t state
Worker state.
int session_dgram_connect_notify(transport_connection_t *tc, u32 old_thread_index, session_t **new_session)
Move dgram session to the right thread.
vlib_node_registration_t session_queue_node
(constructor) VLIB_REGISTER_NODE (session_queue_node)
u32 configured_v4_session_table_memory
static u32 svm_fifo_max_dequeue_cons(svm_fifo_t *f)
Fifo max bytes to dequeue optimized for consumer.
void session_cleanup_half_open(session_handle_t ho_handle)
static void svm_fifo_add_want_deq_ntf(svm_fifo_t *f, u8 ntf_type)
Set specific want notification flag.
static clib_us_time_t transport_us_time_now(u32 thread_index)
volatile u8 session_state
State in session layer state machine.
static session_worker_t * session_main_get_worker(u32 thread_index)
static int svm_fifo_has_event(svm_fifo_t *f)
Check if fifo has io event.
void session_wrk_enable_adaptive_mode(session_worker_t *wrk)
vl_api_fib_path_type_t type
static session_t * listen_session_get_from_handle(session_handle_t handle)
u32 configured_v4_halfopen_table_buckets
uword evt_qs_segment_size
void session_transport_closing_notify(transport_connection_t *tc)
Notification from transport that connection is being closed.
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.
static u32 svm_fifo_max_dequeue(svm_fifo_t *f)
Fifo max bytes to dequeue.
session_t * session_alloc(u32 thread_index)
VLIB buffer representation.
clib_llist_index_t ctrl_head
Head of control events list.
#define clib_llist_elt(LP, EI)
Get list elt at index.
void sesssion_reschedule_tx(transport_connection_t *tc)
static session_evt_elt_t * session_evt_alloc_old(session_worker_t *wrk)