15 #ifndef __included_session_h__ 16 #define __included_session_h__ 23 #define HALF_OPEN_LOOKUP_INVALID_VALUE ((u64)~0) 24 #define INVALID_INDEX ((u32)~0) 27 #define MAX_HDRS_LEN 100 39 #define foreach_session_input_error \ 40 _(NO_SESSION, "No session drops") \ 41 _(NO_LISTENER, "No listener for dst port drops") \ 42 _(ENQUEUED, "Packets pushed into rx fifo") \ 43 _(NOT_READY, "Session not ready packets") \ 44 _(FIFO_FULL, "Packets dropped for lack of rx fifo space") \ 45 _(EVENT_FIFO_FULL, "Events not sent for lack of event fifo space") \ 46 _(API_QUEUE_FULL, "Sessions not created for lack of API queue space") \ 47 _(NEW_SEG_NO_SPACE, "Created segment, couldn't allocate a fifo pair") \ 48 _(NO_SPACE, "Couldn't allocate a fifo pair") 52 #define _(sym,str) SESSION_ERROR_##sym, 69 #define foreach_session_type \ 77 #define _(A, a) SESSION_TYPE_##A, 111 }) session_fifo_event_t;
114 typedef struct _stream_session_t
135 u32 svm_segment_index;
141 u32 connection_index;
163 u32 thread_index,
int *n_tx_pkts);
168 struct _session_manager_main
171 clib_bihash_16_8_t v4_session_hash;
172 clib_bihash_48_8_t v6_session_hash;
175 clib_bihash_16_8_t v4_half_open_hash;
176 clib_bihash_48_8_t v6_half_open_hash;
188 u8 *current_enqueue_epoch;
191 u32 **session_indices_to_enqueue_by_thread;
197 session_fifo_event_t **free_event_vector;
200 session_fifo_event_t **pending_event_vector;
206 u32 configured_event_queue_length;
209 u32 unique_segment_name_counter;
225 f64 *last_event_poll_by_thread;
247 u16 lcl_port,
u8 proto);
250 u16 rmt_port,
u8 proto,
253 u16 lcl_port,
u8 proto);
256 u16 rmt_port,
u8,
u32 thread_index);
260 u16 rmt_port,
u8 proto,
265 u16 rmt_port,
u8 proto,
268 u16 lcl_port,
u8 proto);
275 ASSERT ((
u32) (ti_and_si >> 32) == thread_index);
277 ti_and_si & 0xFFFFFFFFULL);
289 if (thread_index >=
vec_len (session_manager_main.sessions))
301 return ((
u64) s->thread_index << 32) | (
u64) s->session_index;
307 return handle & 0xFFFFFFFF;
342 return s - session_manager_main.listen_sessions[s->session_type];
344 return s - session_manager_main.sessions[s->thread_index];
358 return s->server_rx_fifo->nitems;
365 u32 offset,
u8 queue_event,
u8 is_in_order);
368 u32 offset,
u32 max_bytes);
374 u32 rx_pointer,
u32 tx_pointer);
392 fifo_event_type_t evt_type,
408 return session_manager_main.vpp_event_queues[thread_index];
417 return ((
u64) s->session_type << 32) | s->session_index;
427 index = handle & 0xFFFFFFFF;
443 memset (s, 0,
sizeof (*s));
445 s->session_type = type;
447 s->session_index = s - session_manager_main.listen_sessions[type];
462 pool_put (session_manager_main.listen_sessions[s->session_type], s);
468 return session_manager_main.is_enabled == 1;
int send_session_connected_callback(u32 app_index, u32 api_context, stream_session_t *s, u8 is_fail)
static stream_session_t * listen_session_get_from_handle(u64 handle)
static u32 stream_session_index_from_handle(u64 handle)
void session_register_transport(u8 type, const transport_proto_vft_t *vft)
transport_proto_vft_t * session_get_transport_vft(u8 type)
struct _transport_connection transport_connection_t
struct _vlib_node_registration vlib_node_registration_t
static stream_session_t * listen_session_new(session_type_t type)
static u32 svm_fifo_max_enqueue(svm_fifo_t *f)
#define foreach_session_type
static u8 session_manager_is_enabled()
stream_session_t * stream_session_lookup_listener(ip46_address_t *lcl, u16 lcl_port, u8 proto)
static u32 stream_session_max_rx_enqueue(transport_connection_t *tc)
vlib_node_registration_t session_queue_node
(constructor) VLIB_REGISTER_NODE (session_queue_node)
session_fifo_rx_fn session_tx_fifo_peek_and_snd
struct _stream_session_t stream_session_t
struct _svm_fifo svm_fifo_t
stream_session_t * stream_session_lookup_listener6(ip6_address_t *lcl, u16 lcl_port, u8 proto)
int stream_session_connect_notify(transport_connection_t *tc, u8 sst, u8 is_fail)
void stream_session_accept_notify(transport_connection_t *tc)
typedef CLIB_PACKED(struct{union{svm_fifo_t *fifo;u64 session_handle;rpc_args_t rpc_args;};u8 event_type;u16 event_id;}) session_fifo_event_t
u32 stream_session_dequeue_drop(transport_connection_t *tc, u32 max_bytes)
stream_session_t * stream_session_lookup4(ip4_address_t *lcl, ip4_address_t *rmt, u16 lcl_port, u16 rmt_port, u8 proto, u32 thread_index)
Looks up a session based on the 5-tuple passed as argument.
struct _transport_proto_vft transport_proto_vft_t
void stream_session_table_add_for_tc(transport_connection_t *tc, u64 value)
static void listen_session_del(stream_session_t *s)
static session_manager_main_t * vnet_get_session_manager_main()
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
void stream_session_init_fifos_pointers(transport_connection_t *tc, u32 rx_pointer, u32 tx_pointer)
Init fifo tail and head pointers.
#define pool_put(P, E)
Free an object E in pool P.
int stream_session_table_del_for_tc(transport_connection_t *tc)
struct _session_manager_main session_manager_main_t
#define pool_get_aligned(P, E, A)
Allocate an object E from a pool P (general version).
static unix_shared_memory_queue_t * session_manager_get_vpp_event_queue(u32 thread_index)
session_fifo_rx_fn session_tx_fifo_dequeue_and_snd
static u32 stream_session_get_index(stream_session_t *s)
u8 * format_stream_session(u8 *s, va_list *args)
Format stream session as per the following format.
stream_session_t * stream_session_lookup_listener4(ip4_address_t *lcl, u16 lcl_port, u8 proto)
void stream_session_disconnect(stream_session_t *s)
Disconnect session and propagate to transport.
transport_connection_t * stream_session_lookup_transport4(ip4_address_t *lcl, ip4_address_t *rmt, u16 lcl_port, u16 rmt_port, u8 proto, u32 thread_index)
int stream_session_stop_listen(stream_session_t *s)
Ask transport to stop listening on local transport endpoint.
int stream_session_enqueue_data(transport_connection_t *tc, vlib_buffer_t *b, u32 offset, u8 queue_event, u8 is_in_order)
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
session_manager_main_t session_manager_main
static stream_session_t * stream_session_get_if_valid(u64 si, u32 thread_index)
clib_error_t * vnet_session_enable_disable(vlib_main_t *vm, u8 is_en)
int vlib_main(vlib_main_t *volatile vm, unformat_input_t *input)
void stream_session_delete_notify(transport_connection_t *tc)
Notification from transport that connection is being deleted.
static void stream_session_parse_handle(u64 handle, u32 *index, u32 *thread_index)
void stream_session_cleanup(stream_session_t *s)
Cleanup transport and session state.
static stream_session_t * stream_session_get_tsi(u64 ti_and_si, u32 thread_index)
void stream_session_reset_notify(transport_connection_t *tc)
Notify application that connection has been reset.
static u32 stream_session_thread_from_handle(u64 handle)
transport_connection_t * stream_session_lookup_transport6(ip6_address_t *lcl, ip6_address_t *rmt, u16 lcl_port, u16 rmt_port, u8 proto, u32 thread_index)
void session_send_session_evt_to_thread(u64 session_handle, fifo_event_type_t evt_type, u32 thread_index)
int stream_session_open(u32 app_index, session_type_t st, transport_endpoint_t *tep, transport_connection_t **tc)
Ask transport to open connection to remote transport endpoint.
static stream_session_t * stream_session_listener_get(u8 sst, u64 si)
u32 stream_session_tx_fifo_max_dequeue(transport_connection_t *tc)
int stream_session_listen(stream_session_t *s, transport_endpoint_t *tep)
Ask transport to listen on local transport endpoint.
stream_session_t * stream_session_lookup6(ip6_address_t *lcl, ip6_address_t *rmt, u16 lcl_port, u16 rmt_port, u8, u32 thread_index)
int stream_session_accept(transport_connection_t *tc, u32 listener_index, u8 sst, u8 notify)
Accept a stream session.
static u64 stream_session_handle(stream_session_t *s)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
static stream_session_t * listen_session_get(session_type_t type, u32 index)
struct _transport_endpoint transport_endpoint_t
#define foreach_session_input_error
static u32 stream_session_rx_fifo_size(transport_connection_t *tc)
int stream_session_peek_bytes(transport_connection_t *tc, u8 *buffer, u32 offset, u32 max_bytes)
int( session_fifo_rx_fn)(vlib_main_t *vm, vlib_node_runtime_t *node, session_manager_main_t *smm, session_fifo_event_t *e0, stream_session_t *s0, u32 thread_index, int *n_tx_pkts)
#define CLIB_CACHE_LINE_BYTES
static u64 listen_session_get_handle(stream_session_t *s)
void stream_session_disconnect_notify(transport_connection_t *tc)
Notification from transport that connection is being closed.
static stream_session_t * stream_session_get_from_handle(u64 handle)
int session_manager_flush_enqueue_events(u32 thread_index)
Flushes queue of sessions that are to be notified of new data enqueued events.
struct _unix_shared_memory_queue unix_shared_memory_queue_t
static stream_session_t * stream_session_get(u32 si, u32 thread_index)