31 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__) 44 vl_print (handle,
"vl_api_memclnt_create_t:\n");
55 vl_print (handle,
"vl_api_memclnt_delete_t:\n");
88 shmem_hdr = (
void *) vlib_rp->
user_ctx;
222 rp->_vl_msg_id = ntohs (VL_API_MEMCLNT_CREATE_REPLY);
238 _vl_msg_api_function_list_elt_t *
i;
243 error = i->f (client_index);
246 i = i->next_init_function;
262 u32 handle, client_index, epoch;
275 (
"Stale clnt delete index %d old epoch %d cur epoch %d",
287 int private_registration = 0;
297 rp->_vl_msg_id = ntohs (VL_API_MEMCLNT_DELETE_REPLY);
334 if (munmap ((
void *) virtual_base, virtual_size) < 0)
338 private_registration = 1;
343 if (private_registration == 0)
375 (vl_api_memclnt_keepalive_reply_t * mp)
387 clib_warning (
"BUG: anonymous memclnt_keepalive_reply");
397 vl_api_memclnt_keepalive_reply_t *rmp;
406 rmp->_vl_msg_id = ntohs (VL_API_MEMCLNT_KEEPALIVE_REPLY);
416 #define foreach_vlib_api_msg \ 417 _(MEMCLNT_CREATE, memclnt_create, 1) \ 418 _(MEMCLNT_DELETE, memclnt_delete, 1) \ 419 _(MEMCLNT_KEEPALIVE, memclnt_keepalive, 0) \ 420 _(MEMCLNT_KEEPALIVE_REPLY, memclnt_keepalive_reply, 0) 440 #define _(N,n,t) do { \ 441 c->id = VL_API_##N; \ 443 c->handler = vl_api_##n##_t_handler; \ 444 c->cleanup = vl_noop_handler; \ 445 c->endian = vl_api_##n##_t_endian; \ 446 c->print = vl_api_##n##_t_print; \ 447 c->size = sizeof(vl_api_##n##_t); \ 450 c->message_bounce = 0; \ 451 vl_msg_api_config(c);} while (0); 461 am->
is_mp_safe[VL_API_MEMCLNT_KEEPALIVE_REPLY] = 1;
520 mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_MEMCLNT_KEEPALIVE);
537 u32 ** confused_indices)
549 if (kill (q->consumer_pid, 0) >= 0)
581 static u32 *dead_indices;
582 static u32 *confused_indices;
589 vl_mem_send_client_keepalive_w_reg (am, now, regpp, &dead_indices,
598 for (i = 0; i <
vec_len (confused_indices); i++)
610 for (i = 0; i <
vec_len (dead_indices); i++)
625 for (i = 0; i <
vec_len (dead_indices); i++)
631 if ((*regpp)->vlib_rp != am->
vlib_rp)
653 if (munmap ((
void *) virtual_base, virtual_size) < 0)
680 for (i = 0; i <
vec_len (dead_indices); i++)
802 if (index == (
u32) ~ 0)
825 int main_segment = va_arg (*args,
int);
830 return format (s,
"%8s %8s %8s %8s %8s\n",
831 "Owner",
"Size",
"Nitems",
"Hits",
"Misses");
837 s =
format (s,
"%8s %8d %8d %8d %8d\n",
846 s =
format (s,
"%8s %8d %8d %8d %8d\n",
856 "%d application restarts, %d reclaimed msgs, %d garbage collects\n",
892 shmem_hdr = (
void *) vlib_rp->
user_ctx;
901 if (regp && regp->vlib_rp == vlib_rp)
926 .path =
"show api ring-stats",
927 .short_help =
"Message ring statistics",
937 u8 *remove_path1, *remove_path2;
948 remove_path1 =
format (0,
"/dev/shm/global_vm%c", 0);
949 remove_path2 =
format (0,
"/dev/shm/vpe-api%c", 0);
953 remove_path1 =
format (0,
"/dev/shm/%s-global_vm%c", am->
root_path, 0);
957 (void) unlink ((
char *) remove_path1);
958 (void) unlink ((
char *) remove_path2);
int vl_mem_api_handle_msg_private(vlib_main_t *vm, vlib_node_runtime_t *node, u32 reg_index)
int vl_mem_api_handle_msg_main(vlib_main_t *vm, vlib_node_runtime_t *node)
void vlibsocket_reference()
uword * pending_rpc_requests
static u32 vl_msg_api_handle_get_index(u32 index)
void vl_api_memclnt_create_t_handler(vl_api_memclnt_create_t *mp)
#define SVM_GLOBAL_REGION_NAME
static void * vl_api_memclnt_create_t_print(vl_api_memclnt_create_t *a, void *handle)
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 void svm_pop_heap(void *oldheap)
clib_spinlock_t pending_rpc_lock
#define vl_print(handle,...)
int svm_queue_add(svm_queue_t *q, u8 *elem, int nowait)
u32 vl_api_memclnt_create_internal(char *name, svm_queue_t *q)
static void send_memclnt_keepalive(vl_api_registration_t *regp, f64 now)
int vl_map_shmem(const char *region_name, int is_vlib)
uword * processing_rpc_requests
volatile int ** vl_api_queue_cursizes
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
static f64 vlib_time_now(vlib_main_t *vm)
void vl_unmap_shmem(void)
int svm_queue_sub2(svm_queue_t *q, u8 *elem)
u8 * message_bounce
Don't automatically free message buffer vetor.
static_always_inline void clib_spinlock_unlock_if_init(clib_spinlock_t *p)
Message configuration definition.
svm_region_t * vlib_primary_rp
Primary api segment descriptor.
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
#define SVM_PVT_MHEAP_SIZE
int api_uid
uid for the api shared memory region
ring_alloc_t * client_rings
#define pool_is_free(P, E)
Use free bitmap to query whether given element is free.
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
void * vl_msg_api_alloc(int nbytes)
int api_gid
gid for the api shared memory region
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
_vl_msg_api_function_list_elt_t * reaper_function_registrations
List of API client reaper functions.
u8 * format_api_message_rings(u8 *s, va_list *args)
u32 clib_file_index
Socket only: file index.
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
void vl_msg_api_barrier_sync(void)
#define VLIB_INIT_FUNCTION(x)
u32 ring_misses
Number of times that the ring allocator failed.
static void * svm_push_data_heap(svm_region_t *rp)
vl_api_registration_t ** vl_clients
vlib/vpp only: vector of client registrations
vl_api_registration_t * vl_mem_api_client_index_to_registration(u32 handle)
static clib_error_t * vl_api_ring_command(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cli_cmd)
static u32 vl_msg_api_handle_from_index_and_epoch(u32 index, u32 epoch)
void vl_api_memclnt_keepalive_reply_t_handler(vl_api_memclnt_keepalive_reply_t *mp)
client answered a ping, stave off the grim reaper...
void vl_mem_api_dead_client_scan(api_main_t *am, vl_shmem_hdr_t *shm, f64 now)
vlib_node_registration_t vl_api_clnt_node
(constructor) VLIB_REGISTER_NODE (vl_api_clnt_node)
const char * root_path
Chroot path to the shared memory API files.
#define clib_error_return(e, args...)
svm_region_t * vlib_rp
Current binary api segment descriptor.
struct vl_shmem_hdr_ * shmem_hdr
Binary API shared-memory segment header pointer.
void vl_msg_api_send_shmem(svm_queue_t *q, u8 *elem)
static void vlib_set_queue_signal_callback(vlib_main_t *vm, void(*fp)(vlib_main_t *))
vl_registration_type_t registration_type
type
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
#define foreach_vlib_api_msg
static void vlib_process_signal_event(vlib_main_t *vm, uword node_index, uword type_opaque, uword data)
void vl_msg_pop_heap(void *oldheap)
svm_queue_t * vl_input_queue
shared memory only: pointer to client input queue
svm_region_t ** vlib_private_rps
Vector of all mapped shared-VM segments.
void svm_region_init_args(svm_map_region_args_t *a)
#define SVM_GLOBAL_REGION_SIZE
clib_error_t * vlibmemory_init(vlib_main_t *vm)
volatile u32 queue_signal_pending
int vl_mem_api_handle_rpc(vlib_main_t *vm, vlib_node_runtime_t *node)
clib_error_t * map_api_segment_init(vlib_main_t *vm)
API main structure, used by both vpp and binary API clients.
u64 global_size
size of the global VM region
An API client registration, only in vpp/vlib.
Shared memory connection.
void vl_msg_api_free_w_region(svm_region_t *vlib_rp, void *a)
static_always_inline uword vlib_get_thread_index(void)
svm_queue_t * vl_api_client_index_to_input_queue(u32 index)
u64 global_baseva
base virtual address for global VM region
static clib_error_t * setup_memclnt_exit(vlib_main_t *vm)
#define vec_free(V)
Free vector's memory (no header).
#define clib_warning(format, args...)
static void * vl_api_memclnt_delete_t_print(vl_api_memclnt_delete_t *a, void *handle)
static vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
svm_queue_t * vl_input_queue
vlib_main_t vlib_node_runtime_t * node
static CLIB_NOSANITIZE_ADDR void VL_MSG_API_SVM_QUEUE_UNPOISON(const svm_queue_t *q)
void svm_queue_free(svm_queue_t *q)
#define VLIB_CLI_COMMAND(x,...)
static u32 vl_msg_api_handle_get_epoch(u32 index)
#define pool_put_index(p, i)
Free pool element with given index.
int vl_mem_api_init(const char *region_name)
#define vec_delete(V, N, M)
Delete N elements starting at element M.
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)
static u8 vl_msg_api_handle_is_valid(u32 handle, u32 restarts)
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)
static void clib_mem_free(void *p)
void vl_set_memory_region_name(const char *name)
u64 svm_get_global_region_base_va()
u8 * serialized_message_table_in_shmem
vlib/vpp only: serialized (message, name, crc) table
u8 * vl_api_serialize_message_table(api_main_t *am, u8 *vector)
#define clib_error_report(e)
u64 global_pvt_heap_size
size of the global VM private mheap
void vl_api_memclnt_delete_t_handler(vl_api_memclnt_delete_t *mp)
static void * clib_mem_alloc(uword size)
static uword pointer_to_uword(const void *p)
static vlib_main_t * vlib_get_main(void)
void vl_msg_api_free(void *)
#define VL_API_EPOCH_MASK
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)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
static void memclnt_queue_callback(vlib_main_t *vm)
#define clib_unix_warning(format, args...)
u32 vl_api_registration_pool_index
Index in VLIB's brain (not shared memory).
void svm_client_scan_this_region_nolock(svm_region_t *rp)
volatile u32 api_queue_nonempty
struct _svm_queue svm_queue_t
void * vl_mem_api_alloc_as_if_client_w_reg(vl_api_registration_t *reg, int nbytes)
static api_main_t * vlibapi_get_main(void)
u8 * is_mp_safe
Message is mp safe vector.
void vl_msg_api_increment_missing_client_counter(void)
void * vl_msg_push_heap(void)
int vl_api_call_reaper_functions(u32 client_index)
void * vl_msg_api_alloc_as_if_client(int nbytes)
const char * region_name
Shared VM binary API region name.
void vl_msg_api_barrier_release(void)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
static_always_inline void clib_spinlock_lock_if_init(clib_spinlock_t *p)
static CLIB_NOSANITIZE_ADDR void VL_MSG_API_UNPOISON(const void *a)