59 u64 handle, *handles = 0;
71 ls = listen_session_get_from_handle (handle);
72 vec_add1 (handles, app_listen_session_handle (ls));
73 sm = segment_manager_get (sm_index);
74 sm->app_wrk_index = SEGMENT_MANAGER_INVALID_APP_INDEX;
78 for (i = 0; i <
vec_len (handles); i++)
82 a->handle = handles[
i];
95 sm->first_is_protected = 0;
104 sm->first_is_protected = 0;
196 return VNET_API_ERROR_ADDRESS_IN_USE;
293 return app->
cb_fns.session_accept_callback (s);
316 return app->
cb_fns.session_connected_callback (app_wrk->
wrk_index, opaque,
324 app->
cb_fns.session_disconnect_callback (s);
332 if (app->
cb_fns.session_transport_closed_callback)
333 app->
cb_fns.session_transport_closed_callback (s);
341 app->
cb_fns.session_reset_callback (s);
350 if (app->
cb_fns.session_cleanup_callback)
351 app->
cb_fns.session_cleanup_callback (s, ntf);
359 app->
cb_fns.builtin_app_rx_callback (s);
368 if (!app->
cb_fns.builtin_app_tx_callback)
371 app->
cb_fns.builtin_app_tx_callback (s);
380 app->
cb_fns.session_migrate_callback (s, new_sh);
488 listener = listen_session_get_from_handle (handle);
489 if (listener->session_type == sst
490 && !(listener->flags & SESSION_F_PROXY))
512 listener = listen_session_get_from_handle (handle);
513 if (listener->session_type == sst && (listener->flags & SESSION_F_PROXY))
549 session_event_t *evt;
584 evt->session_index = s->
rx_fifo->client_session_index;
597 session_event_t *evt;
623 evt->session_index = s->
tx_fifo->client_session_index;
655 u64 handle = va_arg (*args,
u64);
656 u32 sm_index = va_arg (*args,
u32);
657 int verbose = va_arg (*args,
int);
665 s =
format (s,
"%-40s%-25s%=10s%-15s%-15s%-10s",
"Connection",
"App",
666 "Wrk",
"API Client",
"ListenerID",
"SegManager");
668 s =
format (s,
"%-40s%-25s%=10s",
"Connection",
"App",
"Wrk");
681 s =
format (s,
"%-40s%-25s%=10v%-15u%-15u%-10u", str, app_name,
697 s =
format (s,
"%U wrk-index %u app-index %u map-index %u " u32 segment_manager_index(segment_manager_t *sm)
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)
int session_open(u32 app_wrk_index, session_endpoint_t *rmt, u32 opaque)
Ask transport to open connection to remote transport endpoint.
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.
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)
int app_worker_connect_notify(app_worker_t *app_wrk, session_t *s, u32 opaque)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
svm_fifo_t * rx_fifo
Pointers to rx/tx buffers.
static session_t * listen_session_get_from_handle(session_handle_t handle)
void segment_manager_format_sessions(segment_manager_t *sm, int verbose)
int app_worker_builtin_tx(app_worker_t *app_wrk, session_t *s)
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)
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)
struct _svm_fifo svm_fifo_t
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, session_endpoint_t *sep, u32 api_context)
application_t * app_worker_get_app(u32 wrk_index)
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.
int segment_manager_alloc_session_fifos(segment_manager_t *sm, svm_fifo_t **rx_fifo, svm_fifo_t **tx_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
#define hash_foreach(key_var, value_var, h, body)
#define ALWAYS_ASSERT(truth)
app_worker_t * app_worker_alloc(application_t *app)
int app_worker_transport_closed_notify(app_worker_t *app_wrk, session_t *s)
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)
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)
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 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)
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 void svm_msg_q_unlock(svm_msg_q_t *mq)
Unlock message queue.
segment_manager_t * segment_manager_alloc(void)
#define vec_free(V)
Free vector's memory (no header).
#define clib_warning(format, args...)
clib_bitmap_t * workers
workers accepting connections
#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)
int app_worker_own_session(app_worker_t *app_wrk, session_t *s)
application_t * application_get(u32 app_index)
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)
session_cb_vft_t cb_fns
Callbacks: shoulder-taps for the server/client.
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)
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.
void segment_manager_del_sessions(segment_manager_t *sm)
Initiate disconnects for all sessions 'owned' by a segment manager.
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)
u32 app_index
Index of owning app.
u8 * format_app_worker(u8 *s, va_list *args)
int app_worker_lock_and_send_event(app_worker_t *app, session_t *s, u8 evt_type)
Send event to application.
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 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.
static transport_service_type_t session_transport_service_type(session_t *s)
#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