41 if (app->api_client_index == ~0)
48 if (q->cursize == q->maxsize)
81 memset (app, 0,
sizeof (*app));
86 clib_warning (
"[%d] New app (%d)", getpid (), app->index);
95 u32 index, *handles = 0;
104 clib_warning (
"[%d] Delete app (%d)", getpid (), app->index);
113 vec_add1 (handles, handle);
114 sm = segment_manager_get (index);
115 sm->app_index = SEGMENT_MANAGER_INVALID_APP_INDEX;
119 for (i = 0; i <
vec_len (handles); i++)
121 a->app_index = app->index;
122 a->handle = handles[
i];
141 && app->first_segment_manager != app->connects_seg_manager)
160 if (cb_fns->session_accept_callback == 0)
162 if (cb_fns->session_connected_callback == 0)
163 clib_warning (
"No session connected callback function provided");
164 if (cb_fns->session_disconnect_callback == 0)
165 clib_warning (
"No session disconnect callback function provided");
166 if (cb_fns->session_reset_callback == 0)
167 clib_warning (
"No session reset callback function provided");
176 u32 app_evt_queue_size, first_seg_size;
177 u32 default_rx_fifo_size = 16 << 10, default_tx_fifo_size = 16 << 10;
185 sm->app_index = app->index;
186 props = &app->sm_properties;
189 props->rx_fifo_size =
190 props->rx_fifo_size ? props->rx_fifo_size : default_rx_fifo_size;
192 props->tx_fifo_size =
193 props->tx_fifo_size ? props->tx_fifo_size : default_tx_fifo_size;
194 props->add_segment = props->add_segment_size != 0;
197 & APP_OPTIONS_FLAGS_BUILTIN_APP;
204 sm->first_is_protected = 1;
207 app->api_client_index = api_client_index;
209 app->cb_fns = *cb_fns;
251 && app->first_segment_manager_in_use == 0)
254 app->first_segment_manager_in_use = 1;
259 sm->properties = &app->sm_properties;
280 s->app_index = srv->index;
314 if (srv &&
hash_get (srv->listeners_table, handle) == 0)
323 indexp =
hash_get (srv->listeners_table, handle);
327 if (srv->first_segment_manager == *indexp)
330 srv->first_segment_manager_in_use = 0;
352 if (app->connects_seg_manager == (
u32) ~ 0)
365 tc->s_index = api_context;
373 ASSERT (app->connects_seg_manager != (
u32) ~ 0);
395 app_name =
format (0,
"builtin-%d%c", app->index, 0);
405 return !(app->flags & APP_OPTIONS_FLAGS_IS_PROXY);
416 ASSERT (app->cb_fns.add_segment_callback);
419 return app->cb_fns.add_segment_callback (app->api_client_index, seg_name,
427 u64 handle = va_arg (*args,
u64);
428 u32 index = va_arg (*args,
u32);
429 int verbose = va_arg (*args,
int);
436 s =
format (s,
"%-40s%-20s%-15s%-15s%-10s",
"Connection",
"App",
437 "API Client",
"ListenerID",
"SegManager");
439 s =
format (s,
"%-40s%-20s",
"Connection",
"App");
450 s =
format (s,
"%-40s%-20s%-15u%-15u%-10u", str, app_name,
451 app->api_client_index, handle, index);
454 s =
format (s,
"%-40s%-20s", str, app_name);
465 u8 *app_name, *s = 0;
473 "API Client",
"SegManager");
480 if (app->connects_seg_manager == (
u32) ~ 0)
487 for (j = 0; j <
vec_len (sm->segment_indices); j++)
497 u32 session_index, thread_index;
500 session_index = fifo->master_session_index;
501 thread_index = fifo->master_thread_index;
507 s =
format (s,
"%-40s%-20s%-15u%-10u", str, app_name,
508 app->api_client_index, app->connects_seg_manager);
510 s =
format (s,
"%-40s%-20s", str, app_name);
534 s =
format (s,
"%-10s%-20s%-15s%-15s%-15s%-15s",
"Index",
"Name",
535 "API Client",
"Add seg size",
"Rx fifo size",
538 s =
format (s,
"%-10s%-20s%-20s",
"Index",
"Name",
"API Client");
544 s =
format (s,
"%-10d%-20s%-15d%-15d%-15d%-15d", app->index, app_name,
545 app->api_client_index, app->sm_properties.add_segment_size,
546 app->sm_properties.rx_fifo_size,
547 app->sm_properties.tx_fifo_size);
549 s =
format (s,
"%-10d%-20s%-20d", app->index, app_name,
550 app->api_client_index);
572 else if (
unformat (input,
"client"))
574 else if (
unformat (input,
"verbose"))
593 if (
hash_elts (app->listeners_table) == 0)
597 vlib_cli_output (vm,
"%U", format_application_listener, app,
598 handle, index, verbose);
616 if (app->connects_seg_manager == (
u32)~0)
627 if (!do_server && !do_client)
646 .short_help =
"show app [server|client] [verbose]",
static void application_table_add(application_t *app)
int application_stop_listen(application_t *srv, u64 handle)
Stop listening on session associated to handle.
#define hash_set(h, key, value)
static u32 default_app_evt_queue_size
Default application event queue size.
sll srl srl sll sra u16x4 i
static stream_session_t * listen_session_get_from_handle(u64 handle)
int application_add_segment_notify(u32 app_index, u32 fifo_segment_index)
#define hash_unset(h, key)
struct _transport_connection transport_connection_t
struct _segment_manager_properties segment_manager_properties_t
static clib_error_t * show_app_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
application_t * application_new()
application_t * application_lookup(u32 api_client_index)
static stream_session_t * listen_session_new(session_type_t type)
static u8 session_manager_is_enabled()
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
struct _svm_fifo svm_fifo_t
void segment_manager_get_segment_info(u32 index, u8 **name, u32 *size)
segment_manager_t * application_get_listen_segment_manager(application_t *app, stream_session_t *s)
int application_is_proxy(application_t *app)
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
static void application_table_del(application_t *app)
struct _stream_session_cb_vft session_cb_vft_t
struct _vnet_unbind_args_t vnet_unbind_args_t
#define hash_foreach(key_var, value_var, h, body)
#define clib_error_return(e, args...)
unix_shared_memory_queue_t * segment_manager_alloc_queue(segment_manager_t *sm, u32 queue_size)
Allocates shm queue in the first segment.
static u8 * app_get_name_from_reg_index(application_t *app)
int stream_session_open(u32 app_index, session_type_t st, transport_endpoint_t *rmt, transport_connection_t **res)
Ask transport to open connection to remote transport endpoint.
struct _stream_session_t stream_session_t
segment_manager_t * segment_manager_new()
static void application_verify_cb_fns(session_cb_vft_t *cb_fns)
static void listen_session_del(stream_session_t *s)
static svm_fifo_t * svm_fifo_segment_get_fifo_list(svm_fifo_segment_private_t *fifo_segment)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
static application_t * app_pool
Pool from which we allocate all applications.
#define pool_put(P, E)
Free an object E in pool P.
u8 segment_manager_has_fifos(segment_manager_t *sm)
#define SEGMENT_MANAGER_INVALID_APP_INDEX
An API client registration, only in vpp/vlib.
u8 * format_stream_session(u8 *s, va_list *args)
Format stream session as per the following format.
#define vec_free(V)
Free vector's memory (no header).
segment_manager_t * application_get_connect_segment_manager(application_t *app)
#define clib_warning(format, args...)
unix_shared_memory_queue_t * vl_api_client_index_to_input_queue(u32 index)
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
struct _application application_t
static uword * app_by_api_client_index
Hash table of apps by api client index.
static svm_fifo_segment_private_t * svm_fifo_segment_get_segment(u32 segment_index)
static u32 segment_manager_index(segment_manager_t *sm)
static segment_manager_t * application_alloc_segment_manager(application_t *app)
#define VLIB_CLI_COMMAND(x,...)
void segment_manager_init_del(segment_manager_t *sm)
static uword hash_elts(void *v)
int application_init(application_t *app, u32 api_client_index, u64 *options, session_cb_vft_t *cb_fns)
void application_del(application_t *app)
u32 application_get_index(application_t *app)
int application_start_listen(application_t *srv, session_type_t session_type, transport_endpoint_t *tep, u64 *res)
Start listening local transport endpoint for requested transport.
int stream_session_stop_listen(stream_session_t *s)
Ask transport to stop listening on local transport endpoint.
static vlib_main_t * vlib_get_main(void)
void segment_manager_del(segment_manager_t *sm)
Removes segment manager.
int segment_manager_init(segment_manager_t *sm, segment_manager_properties_t *properties, u32 first_seg_size)
Initializes segment manager based on options provided.
u8 * format_application_listener(u8 *s, va_list *args)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
u8 * format_application(u8 *s, va_list *args)
application_t * application_get(u32 index)
struct _transport_endpoint transport_endpoint_t
void segment_manager_del_sessions(segment_manager_t *sm)
Initiate disconnects for all sessions 'owned' by a segment manager.
int vnet_unbind(vnet_unbind_args_t *a)
struct _segment_manager segment_manager_t
int stream_session_listen(stream_session_t *s, transport_endpoint_t *tep)
Ask transport to listen on local transport endpoint.
vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
int application_api_queue_is_full(application_t *app)
#define APP_INVALID_SEGMENT_MANAGER_INDEX
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
static segment_manager_t * segment_manager_get(u32 index)
static u64 listen_session_get_handle(stream_session_t *s)
int application_open_session(application_t *app, session_type_t sst, transport_endpoint_t *tep, u32 api_context)
application_t * application_get_if_valid(u32 index)
void application_format_connects(application_t *app, int verbose)
struct _unix_shared_memory_queue unix_shared_memory_queue_t
static stream_session_t * stream_session_get(u32 si, u32 thread_index)
static uword pool_elts(void *v)
Number of active elements in a pool.