59 u64 handle, *handles = 0;
72 ls = listen_session_get_from_handle (handle);
73 al = app_listener_get (app, ls->al_index);
74 vec_add1 (handles, app_listener_handle (al));
75 sm = segment_manager_get (sm_index);
76 sm->app_wrk_index = SEGMENT_MANAGER_INVALID_APP_INDEX;
80 for (i = 0; i <
vec_len (handles); i++)
84 a->handle = handles[
i];
97 sm->first_is_protected = 0;
106 sm->first_is_protected = 0;
153 u32 fifo_segment_index;
157 &fifo_segment_index)))
200 return VNET_API_ERROR_ADDRESS_IN_USE;
297 return app->
cb_fns.session_accept_callback (s);
320 return app->
cb_fns.session_connected_callback (app_wrk->
wrk_index, opaque,
328 app->
cb_fns.session_disconnect_callback (s);
336 app->
cb_fns.session_reset_callback (s);
344 app->
cb_fns.builtin_app_rx_callback (s);
377 s->
rx_fifo->cursize = rxf->cursize;
385 s->
tx_fifo->cursize = txf->cursize;
462 listener = listen_session_get_from_handle (handle);
463 if (listener->session_type == sst
464 && !(listener->flags & SESSION_F_PROXY))
486 listener = listen_session_get_from_handle (handle);
487 if (listener->session_type == sst && (listener->flags & SESSION_F_PROXY))
550 session_event_t *evt;
580 evt->session_index = s->
rx_fifo->client_session_index;
594 session_event_t *evt;
617 evt->session_index = s->
tx_fifo->client_session_index;
662 u64 handle = va_arg (*args,
u64);
663 u32 sm_index = va_arg (*args,
u32);
664 int verbose = va_arg (*args,
int);
672 s =
format (s,
"%-40s%-25s%=10s%-15s%-15s%-10s",
"Connection",
"App",
673 "Wrk",
"API Client",
"ListenerID",
"SegManager");
675 s =
format (s,
"%-40s%-25s%=10s",
"Connection",
"App",
"Wrk");
688 s =
format (s,
"%-40s%-25s%=10s%-15u%-15u%-10u", str, app_name,
703 s =
format (s,
"%U wrk-index %u app-index %u map-index %u " 724 "API Client",
"SegManager");
746 u32 session_index, thread_index;
749 session_index = fifo->master_session_index;
750 thread_index = fifo->master_thread_index;
752 session =
session_get (session_index, thread_index);
756 s =
format (s,
"%-40s%-20s%-15u%-10u", str, app_name,
759 s =
format (s,
"%-40s%-20s", str, app_name);
int app_worker_init_accepted(session_t *s)
static u8 svm_msg_q_msg_is_invalid(svm_msg_q_msg_t *msg)
Check if message is invalid.
#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)
#define clib_memcpy_fast(a, b, c)
int app_worker_connect_notify(app_worker_t *app_wrk, session_t *s, u32 opaque)
static int app_enqueue_evt(svm_msg_q_t *mq, svm_msg_q_msg_t *msg, u8 lock)
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)
int app_worker_builtin_rx(app_worker_t *app_wrk, session_t *s)
u32 wrk_map_index
Worker index in app's map pool.
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.
#define segment_manager_foreach_segment_w_lock(VAR, SM, BODY)
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.
application_t * application_get_if_valid(u32 app_index)
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
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.
#define SESSION_INVALID_INDEX
static int svm_fifo_is_empty(svm_fifo_t *f)
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)
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)
static uword clib_bitmap_is_zero(uword *ai)
predicate function; is an entire bitmap empty?
int() app_send_evt_handler_fn(app_worker_t *app, session_t *s, u8 lock)
#define hash_foreach(key_var, value_var, h, body)
app_worker_t * app_worker_alloc(application_t *app)
segment_manager_t * segment_manager_new()
static const u8 * app_get_name(application_t *app)
int app_worker_del_segment_notify(app_worker_t *app_wrk, u64 segment_handle)
int segment_manager_alloc_session_fifos(segment_manager_t *sm, svm_fifo_t **rx_fifo, svm_fifo_t **tx_fifo, u32 *fifo_segment_index)
static svm_fifo_t * svm_fifo_segment_get_fifo_list(svm_fifo_segment_private_t *fifo_segment)
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.
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)
int app_worker_send_event(app_worker_t *app, session_t *s, u8 evt_type)
Send event to application.
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)
Sets fifo event flag.
session_t * app_worker_proxy_listener(app_worker_t *app_wrk, u8 fib_proto, u8 transport_proto)
static void svm_msg_q_unlock(svm_msg_q_t *mq)
Unlock message queue.
#define vec_free(V)
Free vector's memory (no header).
#define clib_warning(format, args...)
int svm_msg_q_add(svm_msg_q_t *mq, svm_msg_q_msg_t *msg, int nowait)
Producer enqueue one message to queue.
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.
blocking call - best used in combination with condvars, for eventfds we don't yield the cpu ...
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)
static u32 segment_manager_index(segment_manager_t *sm)
app_worker_t * app_worker_get_if_valid(u32 wrk_index)
void segment_manager_init_del(segment_manager_t *sm)
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 vlib_main_t * vlib_get_main(void)
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 segment_manager_del(segment_manager_t *sm)
Removes segment manager.
void svm_msg_q_free_msg(svm_msg_q_t *mq, svm_msg_q_msg_t *msg)
Free message buffer.
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)
static int app_send_io_evt_rx(app_worker_t *app_wrk, session_t *s, u8 lock)
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.
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)
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)
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.
static int app_send_io_evt_tx(app_worker_t *app_wrk, session_t *s, u8 lock)
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
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
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)
static segment_manager_t * segment_manager_get(u32 index)
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
u32 listener_index
Parent listener session index if the result of an accept.