|
FD.io VPP
v21.10.1-2-g0a485f517
Vector Packet Processing
|
Go to the documentation of this file.
31 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
44 vl_print (handle,
"vl_api_memclnt_create_t:\n");
46 vl_print (handle,
"input_queue: 0x%wx\n",
a->input_queue);
47 vl_print (handle,
"context: %u\n", (
unsigned)
a->context);
48 vl_print (handle,
"ctx_quota: %ld\n", (
long)
a->ctx_quota);
55 vl_print (handle,
"vl_api_memclnt_delete_t:\n");
56 vl_print (handle,
"index: %u\n", (
unsigned)
a->index);
57 vl_print (handle,
"handle: 0x%wx\n",
a->handle);
68 int have_pending_rpcs;
89 shmem_hdr = (
void *) vlib_rp->
user_ctx;
112 if (have_pending_rpcs)
153 am->shmem_hdr->application_restarts);
216 if (
am->serialized_message_table_in_shmem == 0)
217 am->serialized_message_table_in_shmem =
220 if (
am->vlib_rp !=
am->vlib_primary_rp)
223 msg_table =
am->serialized_message_table_in_shmem;
228 rp->_vl_msg_id =
ntohs (VL_API_MEMCLNT_CREATE_REPLY);
232 am->shmem_hdr->application_restarts);
244 _vl_msg_api_function_list_elt_t *
i;
249 error =
i->f (client_index);
252 i =
i->next_init_function;
267 u32 handle, client_index, epoch;
279 (
"Stale clnt delete index %d old epoch %d cur epoch %d",
291 int private_registration = 0;
301 rp->_vl_msg_id =
ntohs (VL_API_MEMCLNT_DELETE_REPLY);
323 if (
am->vlib_private_rps[
i] ==
am->vlib_rp)
338 if (munmap ((
void *) virtual_base, virtual_size) < 0)
342 private_registration = 1;
347 if (private_registration == 0)
379 (vl_api_memclnt_keepalive_reply_t * mp)
391 clib_warning (
"BUG: anonymous memclnt_keepalive_reply");
401 vl_api_memclnt_keepalive_reply_t *rmp;
406 shmem_hdr =
am->shmem_hdr;
410 rmp->_vl_msg_id =
ntohs (VL_API_MEMCLNT_KEEPALIVE_REPLY);
420 #define foreach_vlib_api_msg \
421 _(MEMCLNT_CREATE, memclnt_create, 1) \
422 _(MEMCLNT_DELETE, memclnt_delete, 1) \
423 _(MEMCLNT_KEEPALIVE, memclnt_keepalive, 0) \
424 _(MEMCLNT_KEEPALIVE_REPLY, memclnt_keepalive_reply, 0)
444 #define _(N,n,t) do { \
445 c->id = VL_API_##N; \
447 c->handler = vl_api_##n##_t_handler; \
448 c->cleanup = vl_noop_handler; \
449 c->endian = vl_api_##n##_t_endian; \
450 c->print = vl_api_##n##_t_print; \
451 c->size = sizeof(vl_api_##n##_t); \
454 c->message_bounce = 0; \
455 vl_msg_api_config(c);} while (0);
464 am->message_bounce[VL_API_MEMCLNT_DELETE] = 1;
465 am->is_mp_safe[VL_API_MEMCLNT_KEEPALIVE_REPLY] = 1;
466 am->is_mp_safe[VL_API_MEMCLNT_KEEPALIVE] = 1;
474 am->vlib_primary_rp =
am->vlib_rp;
524 mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_MEMCLNT_KEEPALIVE);
528 am->shmem_hdr->application_restarts);
541 u32 ** confused_indices)
553 if (kill (q->consumer_pid, 0) >= 0)
564 vec_add1 (*dead_indices, regpp -
am->vl_clients);
576 regpp -
am->vl_clients);
577 vec_add1 (*confused_indices, regpp -
am->vl_clients);
585 static u32 *dead_indices;
586 static u32 *confused_indices;
602 for (
i = 0;
i <
vec_len (confused_indices);
i++)
635 if ((*regpp)->vlib_rp !=
am->vlib_rp)
645 if (
am->vlib_private_rps[
i] == dead_rp)
657 if (munmap ((
void *) virtual_base, virtual_size) < 0)
676 regpp -
am->vl_clients);
780 regpp =
am->vl_clients +
index;
807 return (
am->shmem_hdr->vl_input_queue);
829 int main_segment = va_arg (*args,
int);
834 return format (s,
"%8s %8s %8s %8s %8s\n",
835 "Owner",
"Size",
"Nitems",
"Hits",
"Misses");
841 s =
format (s,
"%8s %8d %8d %8d %8d\n",
850 s =
format (s,
"%8s %8d %8d %8d %8d\n",
857 s =
format (s,
"%d ring miss fallback allocations\n",
am->ring_misses);
860 "%d application restarts, %d reclaimed msgs, %d garbage collects\n",
877 if (
am->vlib_primary_rp == 0 ||
am->vlib_primary_rp->user_ctx == 0)
883 shmem_hdr = (
void *)
am->vlib_primary_rp->user_ctx;
896 shmem_hdr = (
void *) vlib_rp->
user_ctx;
905 if (regp && regp->vlib_rp == vlib_rp)
930 .path =
"show api ring-stats",
931 .short_help =
"Message ring statistics",
941 u8 *remove_path1, *remove_path2;
950 if (
am->root_path == 0)
952 remove_path1 =
format (0,
"/dev/shm/global_vm%c", 0);
953 remove_path2 =
format (0,
"/dev/shm/vpe-api%c", 0);
957 remove_path1 =
format (0,
"/dev/shm/%s-global_vm%c",
am->root_path, 0);
958 remove_path2 =
format (0,
"/dev/shm/%s-vpe-api%c",
am->root_path, 0);
961 (void) unlink ((
char *) remove_path1);
962 (void) unlink ((
char *) remove_path2);
968 a->root_path =
am->root_path;
970 a->baseva = (
am->global_baseva != 0) ?
974 a->uid =
am->api_uid;
975 a->gid =
am->api_gid;
977 (
am->global_pvt_heap_size !=
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
void vl_msg_api_barrier_release(void)
static u32 vl_msg_api_handle_get_index(u32 index)
#define SVM_GLOBAL_REGION_SIZE
#define vl_print(handle,...)
static vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
void * vl_mem_api_alloc_as_if_client_w_reg(vl_api_registration_t *reg, int nbytes)
static_always_inline void clib_spinlock_lock_if_init(clib_spinlock_t *p)
int vl_mem_api_handle_msg_private(vlib_main_t *vm, vlib_node_runtime_t *node, u32 reg_index)
int vl_map_shmem(const char *region_name, int is_vlib)
static uword pointer_to_uword(const void *p)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
void vl_api_memclnt_keepalive_reply_t_handler(vl_api_memclnt_keepalive_reply_t *mp)
client answered a ping, stave off the grim reaper...
static u32 vl_msg_api_handle_from_index_and_epoch(u32 index, u32 epoch)
clib_spinlock_t pending_rpc_lock
static void clib_mem_free(void *p)
vlib_main_t vlib_node_runtime_t * node
#define clib_error_return(e, args...)
struct _svm_queue svm_queue_t
_vl_msg_api_function_list_elt_t * reaper_function_registrations
List of API client reaper functions.
Message configuration definition.
vl_registration_type_t registration_type
type
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
svm_queue_t * vl_input_queue
shared memory only: pointer to client input queue
#define vec_delete(V, N, M)
Delete N elements starting at element M.
static clib_error_t * vl_api_ring_command(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cli_cmd)
static u8 vl_msg_api_handle_is_valid(u32 handle, u32 restarts)
#define clib_error_report(e)
static void vlib_process_signal_event(vlib_main_t *vm, uword node_index, uword type_opaque, uword data)
#define pool_put_index(p, i)
Free pool element with given index.
volatile u32 queue_signal_pending
void * vl_msg_api_alloc_as_if_client(int nbytes)
#define clib_unix_warning(format, args...)
void svm_region_init_args(svm_map_region_args_t *a)
static CLIB_NOSANITIZE_ADDR void VL_MSG_API_UNPOISON(const void *a)
uword * processing_rpc_requests
ring_alloc_t * client_rings
u8 * format_api_message_rings(u8 *s, va_list *args)
#define pool_foreach(VAR, POOL)
Iterate through pool.
void svm_queue_free(svm_queue_t *q)
void vl_set_memory_region_name(const char *name)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
svm_queue_t * vl_api_client_index_to_input_queue(u32 index)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
int vl_mem_api_handle_rpc(vlib_main_t *vm, vlib_node_runtime_t *node)
int vl_mem_api_handle_msg_main(vlib_main_t *vm, vlib_node_runtime_t *node)
static void vl_api_memclnt_keepalive_t_handler(vl_api_memclnt_keepalive_t *mp)
We can send ourselves these messages if someone uses the builtin binary api test tool....
static_always_inline uword vlib_get_thread_index(void)
An API client registration, only in vpp/vlib.
clib_error_t * map_api_segment_init(vlib_main_t *vm)
#define pool_is_free(P, E)
Use free bitmap to query whether given element is free.
svm_queue_t * vl_input_queue
static void memclnt_queue_callback(vlib_main_t *vm)
if(node->flags &VLIB_NODE_FLAG_TRACE) vnet_interface_output_trace(vm
static void svm_pop_heap(void *oldheap)
u32 clib_file_index
Socket only: file index.
void vlibsocket_reference()
static api_main_t * vlibapi_get_main(void)
static void vl_mem_send_client_keepalive_w_reg(api_main_t *am, f64 now, vl_api_registration_t **regpp, u32 **dead_indices, u32 **confused_indices)
u8 * vl_api_serialize_message_table(api_main_t *am, u8 *vector)
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
#define VLIB_CLI_COMMAND(x,...)
uword * pending_rpc_requests
void vl_unmap_shmem(void)
volatile u32 api_queue_nonempty
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
static int void_mem_api_handle_msg_i(api_main_t *am, svm_region_t *vlib_rp, vlib_main_t *vm, vlib_node_runtime_t *node, u8 is_private)
API main structure, used by both vpp and binary API clients.
static clib_error_t * setup_memclnt_exit(vlib_main_t *vm)
int svm_queue_sub2(svm_queue_t *q, u8 *elem)
#define vec_free(V)
Free vector's memory (no header).
#define VL_API_EPOCH_MASK
void vl_msg_api_free_w_region(svm_region_t *vlib_rp, void *a)
#define foreach_vlib_api_msg
int svm_queue_add(svm_queue_t *q, u8 *elem, int nowait)
void vl_msg_api_free(void *)
u64 svm_get_global_region_base_va()
description fragment has unexpected format
int vl_mem_api_init(const char *region_name)
void svm_client_scan_this_region_nolock(svm_region_t *rp)
static u32 vl_msg_api_handle_get_epoch(u32 index)
void vl_mem_api_dead_client_scan(api_main_t *am, vl_shmem_hdr_t *shm, f64 now)
void vl_msg_api_increment_missing_client_counter(void)
static void * vl_api_memclnt_create_t_print(vl_api_memclnt_create_t *a, void *handle)
void * vl_msg_push_heap(void)
#define VLIB_INIT_FUNCTION(x)
static vlib_cli_command_t cli_show_api_ring_command
(constructor) VLIB_CLI_COMMAND (cli_show_api_ring_command)
clib_error_t * vlibmemory_init(vlib_main_t *vm)
static void vlib_set_queue_signal_callback(vlib_main_t *vm, void(*fp)(vlib_main_t *))
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
static vlib_main_t * vlib_get_main(void)
#define SVM_GLOBAL_REGION_NAME
void vl_api_call_reaper_functions(u32 client_index)
void vl_msg_api_send_shmem(svm_queue_t *q, u8 *elem)
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
static void * vl_api_memclnt_delete_t_print(vl_api_memclnt_delete_t *a, void *handle)
static CLIB_NOSANITIZE_ADDR void VL_MSG_API_SVM_QUEUE_UNPOISON(const svm_queue_t *q)
#define SVM_PVT_MHEAP_SIZE
#define clib_warning(format, args...)
static void send_memclnt_keepalive(vl_api_registration_t *regp, f64 now)
@ REGISTRATION_TYPE_SHMEM
Shared memory connection.
static f64 vlib_time_now(vlib_main_t *vm)
static_always_inline void clib_spinlock_unlock_if_init(clib_spinlock_t *p)
void vl_msg_pop_heap(void *oldheap)
vl_api_registration_t * vl_mem_api_client_index_to_registration(u32 handle)
vlib_node_registration_t vl_api_clnt_node
(constructor) VLIB_REGISTER_NODE (vl_api_clnt_node)
static void * svm_push_data_heap(svm_region_t *rp)
void vl_api_memclnt_create_t_handler(vl_api_memclnt_create_t *mp)
void vl_msg_api_barrier_sync(void)
static void * clib_mem_alloc(uword size)
void vl_msg_api_handler_with_vm_node(api_main_t *am, svm_region_t *vlib_rp, void *the_msg, vlib_main_t *vm, vlib_node_runtime_t *node, u8 is_private)
void vl_api_memclnt_delete_t_handler(vl_api_memclnt_delete_t *mp)
volatile int ** vl_api_queue_cursizes
u32 vl_api_memclnt_create_internal(char *name, svm_queue_t *q)
u32 vl_api_registration_pool_index
Index in VLIB's brain (not shared memory).
void * vl_msg_api_alloc(int nbytes)