44 #define DEBUG_MESSAGE_BUFFER_OVERRUN 0 59 #if DEBUG_MESSAGE_BUFFER_OVERRUN > 0 89 for (i = 0; i <
vec_len (ap); i++)
92 if (nbytes > ap[i].
size)
100 pthread_mutex_lock (&q->mutex);
102 rv = (
msgbuf_t *) (&q->data[0] + q->head * q->elsize);
118 u16 *msg_idp, msg_id;
120 (
"garbage collect pool %d ring %d index %d", pool, i,
123 msg_id = clib_net_to_host_u16 (*msg_idp);
137 pthread_mutex_unlock (&q->mutex);
151 if (q->head == q->maxsize)
155 pthread_mutex_unlock (&q->mutex);
165 pthread_mutex_lock (&am->vlib_rp->mutex);
173 pthread_mutex_unlock (&am->vlib_rp->mutex);
182 pthread_mutex_unlock (&am->vlib_rp->mutex);
185 #if DEBUG_MESSAGE_BUFFER_OVERRUN > 0 189 overrun = (
u32 *) (rv->data + nbytes - sizeof (
msgbuf_t));
190 *overrun = 0x1badbabe;
193 rv->data_len = htonl (nbytes -
sizeof (
msgbuf_t));
253 #if DEBUG_MESSAGE_BUFFER_OVERRUN > 0 257 ASSERT (*overrun == 0x1badbabe);
266 #if DEBUG_MESSAGE_BUFFER_OVERRUN > 0 270 ASSERT (*overrun == 0x1badbabe);
372 u32 vlib_input_queue_length;
384 vlib_input_queue_length = 1024;
396 _rp.rp = unix_shared_memory_queue_init ((n), (sz), 0, 0); \ 401 vec_add1(shmem_hdr->vl_rings, _rp); \ 410 _rp.rp = unix_shared_memory_queue_init ((n), (sz), 0, 0); \ 415 vec_add1(shmem_hdr->client_rings, _rp); \ 421 if (is_private_region == 0)
440 pthread_mutex_unlock (&vlib_rp->
mutex);
451 struct timespec ts, tsrem;
452 char *vpe_api_region_suffix =
"-vpe-api";
454 memset (a, 0,
sizeof (*a));
456 if (strstr (region_name, vpe_api_region_suffix))
458 u8 *root_path =
format (0,
"%s", region_name);
459 _vec_len (root_path) = (
vec_len (root_path) -
460 strlen (vpe_api_region_suffix));
463 am->
root_path = (
const char *) root_path;
475 a->
name =
"/vpe-api";
478 a->
name = region_name;
490 pthread_mutex_lock (&vlib_rp->
mutex);
513 for (i = 0; i < 10; i++)
515 if (pthread_mutex_trylock (&q->mutex) == 0)
517 pthread_mutex_unlock (&q->mutex);
521 ts.tv_nsec = 10000 * 1000;
522 while (nanosleep (&ts, &tsrem) < 0)
526 memset (&q->mutex, 0, sizeof (q->mutex));
527 clib_warning (
"forcibly release main input queue mutex");
539 pthread_mutex_unlock (&vlib_rp->
mutex);
543 pthread_mutex_lock (&root_rp->
mutex);
545 pthread_mutex_unlock (&root_rp->
mutex);
549 pthread_mutex_unlock (&vlib_rp->
mutex);
558 pthread_mutex_unlock (&vlib_rp->
mutex);
561 for (i = 0; i < 10000; i++)
564 ts.tv_nsec = 10000 * 1000;
565 while (nanosleep (&ts, &tsrem) < 0)
706 if (index == (
u32) ~ 0)
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
u64 api_pvt_heap_size
size of the api private mheap
svm_region_t * svm_get_root_rp(void)
sll srl srl sll sra u16x4 i
static void svm_pop_heap(void *oldheap)
struct msgbuf_ msgbuf_t
Message header structure.
void vl_set_global_memory_baseva(u64 baseva)
static vlib_cli_command_t trace
(constructor) VLIB_CLI_COMMAND (trace)
int vl_map_shmem(const char *region_name, int is_vlib)
u64 api_size
size of the API region
void vl_set_memory_uid(int uid)
unix_shared_memory_queue_t * vl_input_queue
void vl_set_global_pvt_heap_size(u64 size)
void vl_unmap_shmem(void)
u32 gc_mark_timestamp
message garbage collector mark TS
#define vec_terminate_c_string(V)
(If necessary) NULL terminate a vector containing a c-string.
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
int api_uid
uid for the api shared memory region
ring_alloc_t * client_rings
#define foreach_clnt_aring_size
u8 data[0]
actual message begins here
#define pool_is_free(P, E)
Use free bitmap to query whether given element is free.
static vl_api_registration_t * vl_api_client_index_to_registration_internal(u32 handle)
void * vl_msg_api_alloc(int nbytes)
int api_gid
gid for the api shared memory region
#define VL_API_EPOCH_MASK
void vl_set_global_memory_size(u64 size)
u32 vl_api_get_msg_index(u8 *name_and_crc)
int our_pid
Current process PID.
static void * svm_push_data_heap(svm_region_t *rp)
vl_api_registration_t ** vl_clients
vlib/vpp only: vector of client registrations
void * svm_region_find_or_create(svm_map_region_args_t *a)
const char * root_path
Chroot path to the shared memory API files.
svm_region_t * vlib_rp
Current binary api segment descriptor.
int unix_shared_memory_queue_add_nolock(unix_shared_memory_queue_t *q, u8 *elem)
struct vl_shmem_hdr_ * shmem_hdr
Binary API shared-memory segment header pointer.
vl_shmem_hdr_t * shmem_hdr
int unix_shared_memory_queue_add(unix_shared_memory_queue_t *q, u8 *elem, int nowait)
void vl_set_memory_root_path(const char *name)
void vl_register_mapped_shmem_region(svm_region_t *rp)
#define foreach_vl_aring_size
vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
void(** msg_print_handlers)(void *, void *)
Message print function vector.
void vl_msg_api_send_shmem_nolock(unix_shared_memory_queue_t *q, u8 *elem)
void vl_msg_api_send_shmem(unix_shared_memory_queue_t *q, u8 *elem)
static u32 vl_msg_api_handle_get_index(u32 index)
void vl_set_api_pvt_heap_size(u64 size)
API main structure, used by both vpp and binary API clients.
u64 global_size
size of the global VM region
u8 enabled
trace is enabled
An API client registration, only in vpp/vlib.
int unix_shared_memory_queue_sub(unix_shared_memory_queue_t *q, u8 *elem, int nowait)
void vl_init_shmem(svm_region_t *vlib_rp, int is_vlib, int is_private_region)
static_always_inline uword vlib_get_thread_index(void)
static void * clib_mem_alloc_or_null(uword size)
u64 global_baseva
base virtual address for global VM region
#define vec_free(V)
Free vector's memory (no header).
unix_shared_memory_queue_t * vl_input_queue
shared memory only: pointer to client input queue
unix_shared_memory_queue_t * q
message allocated in this shmem ring
#define clib_warning(format, args...)
void vl_msg_api_trace(api_main_t *am, vl_api_trace_t *tp, void *msg)
void vl_set_memory_gid(int gid)
static void vl_msg_api_free_nolock(void *a)
void vl_msg_api_free(void *a)
const char ** msg_names
Message name vector.
void vl_msg_api_increment_missing_client_counter(void)
vl_api_trace_t * tx_trace
Sent message trace configuration.
u32 data_len
message length not including header
Message header structure.
unix_shared_memory_queue_t * unix_shared_memory_queue_init(int nels, int elsize, int consumer_pid, int signal_when_queue_non_empty)
static void clib_mem_free(void *p)
socket_main_t socket_main
u64 global_pvt_heap_size
size of the global VM private mheap
static void * clib_mem_alloc(uword size)
vl_api_registration_t * current_rp
i32 vlib_signal
(Historical) signal-based queue non-empty signal, to be removed
void(** msg_endian_handlers)(void *)
Message endian handler vector.
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
void svm_region_unmap(void *rp_arg)
void svm_client_scan_this_region_nolock(svm_region_t *rp)
unix_shared_memory_queue_t * vl_api_client_index_to_input_queue(u32 index)
static void * vl_msg_api_alloc_internal(int nbytes, int pool, int may_return_null)
unix_shared_memory_queue_t * rp
void * vl_msg_api_alloc_as_if_client_or_null(int nbytes)
#define hash_get_mem(h, key)
void(** msg_handlers)(void *)
Message handler vector.
void vl_set_api_memory_size(u64 size)
void * vl_msg_api_alloc_as_if_client(int nbytes)
static u32 vl_msg_api_handle_get_epoch(u32 index)
void * vl_msg_api_alloc_or_null(int nbytes)
svm_region_t ** mapped_shmem_regions
uword * msg_index_by_name_and_crc
client message index hash table
u32 vlib_input_queue_length
vpp/vlib input queue length
struct _unix_shared_memory_queue unix_shared_memory_queue_t
static svm_region_t * root_rp
int svm_region_init_chroot(const char *root_path)