73 for (i = 0; i <
vec_len (ap); i++) {
75 if (nbytes > ap[i].
size) {
81 pthread_mutex_lock(&q->mutex);
83 rv = (
msgbuf_t *) (&q->data[0] + q->head*q->elsize);
91 pthread_mutex_unlock(&q->mutex);
102 if (q->head == q->maxsize)
106 pthread_mutex_unlock(&q->mutex);
222 struct timespec ts, tsrem;
227 memset (a, 0,
sizeof (*a));
229 a->
name = region_name;
240 pthread_mutex_lock (&vlib_rp->
mutex);
261 for (i = 0; i < 10; i++) {
262 if (pthread_mutex_trylock (&q->mutex) == 0) {
263 pthread_mutex_unlock (&q->mutex);
267 ts.tv_nsec = 10000*1000;
268 while (nanosleep(&ts, &tsrem) < 0)
272 memset (&q->mutex, 0, sizeof (q->mutex));
273 clib_warning (
"forcibly release main input queue mutex");
284 pthread_mutex_unlock (&vlib_rp->
mutex);
288 pthread_mutex_lock (&root_rp->
mutex);
290 pthread_mutex_unlock (&root_rp->
mutex);
292 pthread_mutex_unlock (&vlib_rp->
mutex);
299 pthread_mutex_unlock (&vlib_rp->
mutex);
302 for (i = 0; i < 10000; i++) {
304 ts.tv_nsec = 10000*1000;
305 while (nanosleep(&ts, &tsrem) < 0)
339 _rp.rp = unix_shared_memory_queue_init ((n), (sz), 0, 0); \ 344 vec_add1(shmem_hdr->vl_rings, _rp); \ 353 _rp.rp = unix_shared_memory_queue_init ((n), (sz), 0, 0); \ 358 vec_add1(shmem_hdr->client_rings, _rp); \ 378 pthread_mutex_unlock (&vlib_rp->
mutex);
453 __attribute__((weak));
492 pthread_mutex_lock (&svm->
mutex);
497 pthread_mutex_unlock(&svm->
mutex);
505 memset(mp, 0,
sizeof (*mp));
506 mp->_vl_msg_id = ntohs(VL_API_MEMCLNT_CREATE);
509 strncpy ((
char *) mp->
name, name,
sizeof(mp->
name)-1);
517 struct timespec ts, tsrem;
521 for (i = 0; i < 1000; i++) {
527 ts.tv_nsec = 10000*1000;
528 while (nanosleep(&ts, &tsrem) < 0)
536 if (ntohs(rp->_vl_msg_id) != VL_API_MEMCLNT_CREATE_REPLY) {
537 clib_warning (
"unexpected reply: id %d", ntohs(rp->_vl_msg_id));
540 rv = clib_net_to_host_u32(rp->
response);
581 memset(mp, 0,
sizeof (*mp));
582 mp->_vl_msg_id = ntohs(VL_API_MEMCLNT_DELETE);
599 if (now >= (begin + 2)) {
610 if (ntohs(rp->_vl_msg_id) != VL_API_MEMCLNT_DELETE_REPLY) {
659 #define foreach_api_client_msg \ 660 _(MEMCLNT_CREATE_REPLY, memclnt_create_reply) \ 661 _(MEMCLNT_DELETE_REPLY, memclnt_delete_reply) 672 vl_msg_api_set_handlers(VL_API_##N, 0 , \ 673 vl_api_##n##_t_handler, \ 675 sizeof(vl_api_##n##_t), 1); #define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
static void * vl_msg_api_alloc_internal(int nbytes, int pool)
void vl_client_api_unmap(void)
svm_region_t * svm_get_root_rp(void)
sll srl srl sll sra u16x4 i
int vl_client_api_map(char *region_name)
static void svm_pop_heap(void *oldheap)
vlib_cli_command_t trace
(constructor) VLIB_CLI_COMMAND (trace)
static void(BVT(clib_bihash)*h, BVT(clib_bihash_value)*v)
#define foreach_clnt_aring_size
void vl_set_memory_uid(int uid)
always_inline void clib_mem_free(void *p)
unix_shared_memory_queue_t * vl_input_queue
void unix_shared_memory_queue_free(unix_shared_memory_queue_t *q)
void vl_unmap_shmem(void)
int vl_client_connect(char *name, int ctx_quota, int input_queue_size)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
ring_alloc_t * client_rings
#define pool_is_free(P, E)
static vl_api_registration_t * vl_api_client_index_to_registration_internal(u32 handle)
void * vl_msg_api_alloc(int nbytes)
void vl_set_memory_root_path(char *name)
unix_shared_memory_queue_t * vl_input_queue
vl_api_registration_t * my_registration
static void * svm_push_data_heap(svm_region_t *rp)
vl_api_registration_t ** vl_clients
void * svm_region_find_or_create(svm_map_region_args_t *a)
int vl_map_shmem(char *region_name, int is_vlib)
int unix_shared_memory_queue_add_nolock(unix_shared_memory_queue_t *q, u8 *elem)
#define clib_warning(format, args...)
struct vl_shmem_hdr_ * shmem_hdr
vl_shmem_hdr_t * shmem_hdr
int unix_shared_memory_queue_add(unix_shared_memory_queue_t *q, u8 *elem, int nowait)
void vl_register_mapped_shmem_region(svm_region_t *rp)
vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
void(** msg_print_handlers)(void *, void *)
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)
int unix_shared_memory_queue_sub(unix_shared_memory_queue_t *q, u8 *elem, int nowait)
always_inline void * clib_mem_alloc(uword size)
#define vec_free(V)
Free vector's memory (no header).
unix_shared_memory_queue_t * vl_input_queue
unix_shared_memory_queue_t * q
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)
#define foreach_vl_aring_size
vl_api_trace_t * tx_trace
#define VL_API_EPOCH_MASK
void svm_region_init_chroot(char *root_path)
static void vl_api_memclnt_create_reply_t_handler(vl_api_memclnt_create_reply_t *mp)
unix_shared_memory_queue_t * unix_shared_memory_queue_init(int nels, int elsize, int consumer_pid, int signal_when_queue_non_empty)
#define foreach_api_client_msg
void(** msg_endian_handlers)(void *)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
void vl_msg_api_handler(void *the_msg)
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_api_memclnt_delete_reply_t_handler(vl_api_memclnt_delete_reply_t *mp)
void vl_client_add_api_signatures(vl_api_memclnt_create_t *mp)
unix_shared_memory_queue_t * rp
void vl_msg_api_increment_missing_client_counter(void)
void(** msg_handlers)(void *)
void * vl_msg_api_alloc_as_if_client(int nbytes)
static u32 vl_msg_api_handle_get_epoch(u32 index)
svm_region_t ** mapped_shmem_regions
void vl_client_disconnect(void)
struct _unix_shared_memory_queue unix_shared_memory_queue_t
static svm_region_t * root_rp