60 u64 handle, *handles = 0, *sm_indices = 0;
72 ls = listen_session_get_from_handle (handle);
73 vec_add1 (handles, app_listen_session_handle (ls));
74 vec_add1 (sm_indices, sm_index);
75 sm = segment_manager_get (sm_index);
79 for (i = 0; i <
vec_len (handles); i++)
84 a->handle = handles[
i];
90 sm->first_is_protected = 0;
106 sm->first_is_protected = 0;
121 vec_add1 (handles, handle);
125 for (j = 0; j <
vec_len (handles); j++)
152 sm->first_is_protected = 0;
199 &rx_fifo, &tx_fifo)))
221 return SESSION_E_ALLOC;
230 return SESSION_E_NOSUPPORT;
244 return SESSION_E_ALREADY_LISTENING;
368 s->
flags |= SESSION_F_CUSTOM_FIFO_TUNING;
398 s->
flags |= SESSION_F_CUSTOM_FIFO_TUNING;
443 return *ho_wrk_handlep;
553 return SESSION_E_ALLOC;
624 listener = listen_session_get_from_handle (handle);
625 if (listener->session_type == sst
626 && !(listener->flags & SESSION_F_PROXY))
648 listener = listen_session_get_from_handle (handle);
649 if (listener->session_type == sst && (listener->flags & SESSION_F_PROXY))
686 session_event_t *evt;
715 evt->session_index = s->
rx_fifo->client_session_index;
728 session_event_t *evt;
754 evt->session_index = s->
tx_fifo->client_session_index;
786 u64 handle = va_arg (*args,
u64);
787 u32 sm_index = va_arg (*args,
u32);
788 int verbose = va_arg (*args,
int);
796 s =
format (s,
"%-40s%-25s%=10s%-15s%-15s%-10s",
"Connection",
"App",
797 "Wrk",
"API Client",
"ListenerID",
"SegManager");
799 s =
format (s,
"%-40s%-25s%=10s",
"Connection",
"App",
"Wrk");
812 s =
format (s,
"%-40s%-25s%=10v%-15u%-15u%-10u", str, app_name,
828 s =
format (s,
"%U wrk-index %u app-index %u map-index %u " u32 segment_manager_index(segment_manager_t *sm)
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
int app_worker_init_accepted(session_t *s)
#define hash_set(h, key, value)
void * svm_msg_q_msg_data(svm_msg_q_t *mq, svm_msg_q_msg_t *msg)
Get data for message in queue.
static u8 svm_msg_q_ring_is_full(svm_msg_q_t *mq, u32 ring_index)
static_always_inline void clib_spinlock_unlock(clib_spinlock_t *p)
int session_open(u32 app_wrk_index, session_endpoint_t *rmt, u32 opaque)
Ask transport to open connection to remote transport endpoint.
static_always_inline void clib_spinlock_lock(clib_spinlock_t *p)
int app_worker_init_connected(app_worker_t *app_wrk, session_t *s)
#define hash_unset(h, key)
u8 * format_session(u8 *s, va_list *args)
Format stream session as per the following format.
u32 * detached_seg_managers
Vector of detached listener segment managers.
struct _vnet_unlisten_args_t vnet_unlisten_args_t
int application_change_listener_owner(session_t *s, app_worker_t *app_wrk)
u32 session_index
Index in thread pool where session was allocated.
static segment_manager_t * app_worker_alloc_segment_manager(app_worker_t *app_wrk)
session_t * app_worker_first_listener(app_worker_t *app_wrk, u8 fib_proto, u8 transport_proto)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
transport_connection_t * session_get_transport(session_t *s)
svm_fifo_t * rx_fifo
Pointers to rx/tx buffers.
static session_t * listen_session_get_from_handle(session_handle_t handle)
static void app_worker_add_detached_sm(app_worker_t *app_wrk, u32 sm_index)
void segment_manager_format_sessions(segment_manager_t *sm, int verbose)
int app_worker_builtin_tx(app_worker_t *app_wrk, session_t *s)
u64 app_worker_lookup_half_open(app_worker_t *app_wrk, transport_proto_t tp, session_handle_t ho_handle)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
void app_worker_del_detached_sm(app_worker_t *app_wrk, u32 sm_index)
static int svm_fifo_is_empty_cons(svm_fifo_t *f)
Check if fifo is empty optimized for consumer.
int app_worker_builtin_rx(app_worker_t *app_wrk, session_t *s)
u32 wrk_map_index
Worker index in app's map pool.
void segment_manager_free(segment_manager_t *sm)
Cleanup segment manager.
static uword * clib_bitmap_set(uword *ai, uword i, uword value)
Sets the ith bit of a bitmap to new_value Removes trailing zeros from the bitmap. ...
static session_t * session_get(u32 si, u32 thread_index)
int vnet_unlisten(vnet_unlisten_args_t *a)
int app_worker_reset_notify(app_worker_t *app_wrk, session_t *s)
void(* session_reset_callback)(session_t *s)
Notify app that session was reset.
uword * listeners_table
Lookup tables for listeners.
static u8 app_worker_application_is_builtin(app_worker_t *app_wrk)
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
u32 connects_seg_manager
Segment manager used for outgoing connects issued by the app.
static int app_send_io_evt_tx(app_worker_t *app_wrk, session_t *s)
application_t * application_get_if_valid(u32 app_index)
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
static void clib_spinlock_free(clib_spinlock_t *p)
static uword clib_bitmap_set_no_check(uword *a, uword i, uword new_value)
Sets the ith bit of a bitmap to new_value.
static int app_send_io_evt_rx(app_worker_t *app_wrk, session_t *s)
int app_worker_connect_session(app_worker_t *app_wrk, session_endpoint_t *sep, u32 api_context)
void(* session_migrate_callback)(session_t *s, session_handle_t new_sh)
Notify app that session pool migration happened.
enum session_ft_action_ session_ft_action_t
application_t * app_worker_get_app(u32 wrk_index)
int(* builtin_app_rx_callback)(session_t *session)
Direct RX callback for built-in application.
void svm_fifo_clone(svm_fifo_t *df, svm_fifo_t *sf)
Clones fifo.
u32 first_segment_manager
First segment manager has in the the first segment the application's event fifo.
static int app_worker_alloc_session_fifos(segment_manager_t *sm, session_t *s)
void segment_manager_dealloc_fifos(svm_fifo_t *rx_fifo, svm_fifo_t *tx_fifo)
u32 local_index
local listening session index
static uword clib_bitmap_is_zero(uword *ai)
predicate function; is an entire bitmap empty?
int app_worker_cleanup_notify(app_worker_t *app_wrk, session_t *s, session_cleanup_ntf_t ntf)
u32 session_index
global listening session index
void session_cleanup_half_open(transport_proto_t tp, session_handle_t ho_handle)
#define hash_foreach(key_var, value_var, h, body)
#define ALWAYS_ASSERT(truth)
app_worker_t * app_worker_alloc(application_t *app)
#define SESSION_INVALID_HANDLE
int app_worker_transport_closed_notify(app_worker_t *app_wrk, session_t *s)
int app_worker_connect_notify(app_worker_t *app_wrk, session_t *s, session_error_t err, u32 opaque)
static void clib_spinlock_init(clib_spinlock_t *p)
int app_worker_del_segment_notify(app_worker_t *app_wrk, u64 segment_handle)
static session_type_t session_type_from_proto_and_ip(transport_proto_t proto, u8 is_ip4)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
void app_worker_free(app_worker_t *app_wrk)
u8 * format_app_worker_listener(u8 *s, va_list *args)
void segment_manager_app_detach(segment_manager_t *sm)
int app_worker_stop_listen(app_worker_t *app_wrk, app_listener_t *al)
const u8 * application_name_from_index(u32 app_index)
Returns app name for app-index.
#define pool_put(P, E)
Free an object E in pool P.
void segment_manager_init_free(segment_manager_t *sm)
Initiate segment manager cleanup.
u8 segment_manager_has_fifos(segment_manager_t *sm)
#define vec_del1(v, i)
Delete the element at index I.
int(* add_segment_callback)(u32 app_wrk_index, u64 segment_handle)
Notify server of new segment.
u32 wrk_index
Worker index in global worker pool.
segment_manager_t * app_worker_get_or_alloc_connect_segment_manager(app_worker_t *app_wrk)
#define SESSION_INVALID_INDEX
int() app_send_evt_handler_fn(app_worker_t *app, session_t *s)
static void app_worker_stop_listen_session(app_worker_t *app_wrk, session_t *ls)
static u64 listen_session_get_handle(session_t *s)
int(* del_segment_callback)(u32 app_wrk_index, u64 segment_handle)
Notify server of new segment.
int app_worker_accept_notify(app_worker_t *app_wrk, session_t *s)
#define SEGMENT_MANAGER_INVALID_APP_INDEX
static u8 svm_fifo_set_event(svm_fifo_t *f)
Set fifo event flag.
session_t * app_worker_proxy_listener(app_worker_t *app_wrk, u8 fib_proto, u8 transport_proto)
int(* session_connected_callback)(u32 app_wrk_index, u32 opaque, session_t *s, session_error_t code)
Connection request callback.
session_handle_t listener_handle
Parent listener session index if the result of an accept.
int app_worker_migrate_notify(app_worker_t *app_wrk, session_t *s, session_handle_t new_sh)
static_always_inline uword vlib_get_thread_index(void)
static void svm_msg_q_unlock(svm_msg_q_t *mq)
Unlock message queue.
segment_manager_t * segment_manager_alloc(void)
void(* session_cleanup_callback)(session_t *s, session_cleanup_ntf_t ntf)
Notify app that session or transport are about to be removed.
int app_worker_del_half_open(app_worker_t *app_wrk, transport_proto_t tp, session_handle_t ho_handle)
sll srl srl sll sra u16x4 i
#define vec_free(V)
Free vector's memory (no header).
#define clib_warning(format, args...)
u8 segment_manager_app_detached(segment_manager_t *sm)
clib_bitmap_t * workers
workers accepting connections
clib_spinlock_t detached_seg_managers_lock
Protects detached seg managers.
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
static uword clib_bitmap_get(uword *ai, uword i)
Gets the ith bit value from a bitmap.
int app_worker_close_notify(app_worker_t *app_wrk, session_t *s)
static u8 transport_connection_is_cless(transport_connection_t *tc)
int(* builtin_app_tx_callback)(session_t *session)
Direct TX callback for built-in application.
int app_worker_own_session(app_worker_t *app_wrk, session_t *s)
int segment_manager_alloc_session_fifos(segment_manager_t *sm, u32 thread_index, svm_fifo_t **rx_fifo, svm_fifo_t **tx_fifo)
application_t * application_get(u32 app_index)
int app_worker_add_half_open(app_worker_t *app_wrk, transport_proto_t tp, session_handle_t ho_handle, session_handle_t wrk_handle)
app_worker_t * app_worker_get_if_valid(u32 wrk_index)
void svm_msg_q_add_and_unlock(svm_msg_q_t *mq, svm_msg_q_msg_t *msg)
Producer enqueue one message to queue with mutex held.
app_worker_t * application_listener_select_worker(session_t *ls)
uword ** half_open_table
Per transport proto hash tables of half-open connection handles.
session_cb_vft_t cb_fns
Callbacks: shoulder-taps for the server/client.
enum _transport_proto transport_proto_t
static app_send_evt_handler_fn *const app_send_evt_handler_fns[2]
u8 thread_index
Index of the thread that allocated the session.
app_worker_t * app_worker_get(u32 wrk_index)
u32 app_index
App index in app pool.
void app_worker_format_connects(app_worker_t *app_wrk, int verbose)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
void(* session_disconnect_callback)(session_t *s)
Notify app that session is closing.
volatile u8 session_state
State in session layer state machine.
segment_manager_t * app_worker_get_listen_segment_manager(app_worker_t *app, session_t *listener)
int app_worker_add_segment_notify(app_worker_t *app_wrk, u64 segment_handle)
Send an API message to the external app, to map new segment.
u8 * name
Name registered by builtin apps.
struct _segment_manager segment_manager_t
int app_worker_start_listen(app_worker_t *app_wrk, app_listener_t *app_listener)
segment_manager_t * segment_manager_get(u32 index)
void app_listener_cleanup(app_listener_t *al)
void(* session_transport_closed_callback)(session_t *s)
Notify app that transport is closed.
u32 app_index
Index of owning app.
u8 * format_app_worker(u8 *s, va_list *args)
int app_worker_session_fifo_tuning(app_worker_t *app_wrk, session_t *s, svm_fifo_t *f, session_ft_action_t act, u32 len)
int app_worker_lock_and_send_event(app_worker_t *app, session_t *s, u8 evt_type)
Send event to application.
int(* fifo_tuning_callback)(session_t *s, svm_fifo_t *f, session_ft_action_t act, u32 bytes)
Delegate fifo-tuning-logic to application.
enum session_error_ session_error_t
u32 app_wrk_index
Index of the app worker that owns the session.
static int svm_fifo_has_event(svm_fifo_t *f)
Check if fifo has io event.
int(* session_accept_callback)(session_t *new_session)
Notify server of newly accepted session.
int app_worker_init_listener(app_worker_t *app_wrk, session_t *ls)
static app_worker_t * app_workers
Pool of workers associated to apps.
int application_is_builtin_proxy(application_t *app)
u32 api_client_index
API index for the worker.
struct _session_endpoint session_endpoint_t
static int svm_msg_q_lock(svm_msg_q_t *mq)
Lock, or block trying, the message queue.
svm_msg_q_t * event_queue
Application listens for events on this svm queue.
struct _svm_fifo svm_fifo_t
#define APP_INVALID_SEGMENT_MANAGER_INDEX
static u8 svm_msg_q_is_full(svm_msg_q_t *mq)
Check if message queue is full.
#define APP_DBG(_fmt, _args...)
segment_manager_t * app_worker_get_connect_segment_manager(app_worker_t *app)
svm_msg_q_msg_t svm_msg_q_alloc_msg_w_ring(svm_msg_q_t *mq, u32 ring_index)
Allocate message buffer on ring.
int app_worker_alloc_connects_segment_manager(app_worker_t *app_wrk)
static session_t * listen_session_get(u32 ls_index)
u8 first_segment_manager_in_use
segment_manager_t * segment_manager_get_if_valid(u32 index)