24 #include <sys/types.h> 49 #define TRACE_VLIB_MEMORY_QUEUE 0 58 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__) 66 vl_print (handle,
"vl_api_memclnt_create_t:\n");
77 vl_print (handle,
"vl_api_memclnt_delete_t:\n");
87 vl_print (handle,
"vl_api_trace_plugin_msg_ids: %s first %u last %u\n",
129 serialize_likely_small_unsigned_integer (sm, hp->value[0]);
130 serialize_cstring (sm, (char *) hp->key);
155 pthread_mutex_lock (&svm->
mutex);
160 memset (regp, 0,
sizeof (*regp));
169 pthread_mutex_unlock (&svm->
mutex);
222 pthread_mutex_lock (&svm->
mutex);
227 memset (regp, 0,
sizeof (*regp));
243 pthread_mutex_unlock (&svm->
mutex);
247 rp->_vl_msg_id = ntohs (VL_API_MEMCLNT_CREATE_REPLY);
264 _vl_msg_api_function_list_elt_t *
i;
269 error = i->f (client_index);
272 i = i->next_init_function;
289 u32 handle, client_index, epoch;
302 (
"Stale clnt delete index %d old epoch %d cur epoch %d",
315 int private_registration = 0;
322 rp->_vl_msg_id = ntohs (VL_API_MEMCLNT_DELETE_REPLY);
355 if (munmap ((
void *) virtual_base, virtual_size) < 0)
359 private_registration = 1;
367 if (private_registration == 0)
371 pthread_mutex_lock (&svm->
mutex);
374 memset (regp, 0xF1,
sizeof (*regp));
376 pthread_mutex_unlock (&svm->
mutex);
402 u16 first_msg_id = ~0;
412 strncpy ((
char *) name, (
char *) mp->
name,
ARRAY_LEN (name) - 1);
426 rmp->_vl_msg_id = ntohs (VL_API_GET_FIRST_MSG_ID_REPLY);
439 (vl_api_memclnt_keepalive_reply_t * mp)
451 clib_warning (
"BUG: anonymous memclnt_keepalive_reply");
461 vl_api_memclnt_keepalive_reply_t *rmp;
469 memset (rmp, 0,
sizeof (*rmp));
470 rmp->_vl_msg_id = ntohs (VL_API_MEMCLNT_KEEPALIVE_REPLY);
482 int msg_size =
sizeof (*rmp) +
sizeof (rmp->
api_versions[0]) * nmsg;
490 memset (rmp, 0, msg_size);
491 rmp->_vl_msg_id = ntohs (VL_API_API_VERSIONS_REPLY);
495 rmp->
count = htonl (nmsg);
497 for (i = 0; i < nmsg; ++
i)
510 #define foreach_vlib_api_msg \ 511 _(MEMCLNT_CREATE, memclnt_create) \ 512 _(MEMCLNT_DELETE, memclnt_delete) \ 513 _(GET_FIRST_MSG_ID, get_first_msg_id) \ 514 _(MEMCLNT_KEEPALIVE, memclnt_keepalive) \ 515 _(MEMCLNT_KEEPALIVE_REPLY, memclnt_keepalive_reply) \ 516 _(API_VERSIONS, api_versions) 529 memset (c, 0,
sizeof (*c));
534 #define _(N,n) do { \ 535 c->id = VL_API_##N; \ 537 c->handler = vl_api_##n##_t_handler; \ 538 c->cleanup = vl_noop_handler; \ 539 c->endian = vl_api_##n##_t_endian; \ 540 c->print = vl_api_##n##_t_print; \ 541 c->size = sizeof(vl_api_##n##_t); \ 544 c->message_bounce = 0; \ 545 vl_msg_api_config(c);} while (0); 555 am->
is_mp_safe[VL_API_MEMCLNT_KEEPALIVE_REPLY] = 1;
560 #define foreach_histogram_bucket \ 568 #define _(n) SLEEP_##n##_US, 590 memset (mp, 0,
sizeof (*mp));
592 mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_TRACE_PLUGIN_MSG_IDS);
596 mp->
last_msg_id = clib_host_to_net_u16 (last_msg_id);
638 memset (mp, 0,
sizeof (*mp));
639 mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_MEMCLNT_KEEPALIVE);
661 static u32 *dead_indices;
662 static u32 *confused_indices;
674 if (regp->last_heard < (now - 10.0))
676 if (regp->unanswered_pings == 2)
678 unix_shared_memory_queue_t *q;
679 q = regp->vl_input_queue;
680 if (kill (q->consumer_pid, 0) >=0)
682 clib_warning (
"REAPER: lazy binary API client '%s'",
684 regp->unanswered_pings = 0;
685 regp->last_heard = now;
689 clib_warning (
"REAPER: binary API client '%s' died",
691 vec_add1(dead_indices, regpp - am->vl_clients);
695 send_memclnt_keepalive (regp, now);
698 regp->unanswered_pings = 0;
702 clib_warning (
"NULL client registration index %d",
703 regpp - am->vl_clients);
704 vec_add1 (confused_indices, regpp - am->vl_clients);
712 for (i = 0; i <
vec_len (confused_indices); i++)
725 for (i = 0; i <
vec_len (dead_indices); i++)
733 (dead_indices[i], shm->application_restarts);
739 pthread_mutex_lock (&svm->
mutex);
742 for (i = 0; i <
vec_len (dead_indices); i++)
748 if ((*regpp)->vlib_rp != svm)
767 if (munmap ((
void *) virtual_base, virtual_size) < 0)
775 memset (*regpp, 0xF3,
sizeof (**regpp));
792 pthread_mutex_unlock (&svm->
mutex);
794 for (i = 0; i <
vec_len (dead_indices); i++)
810 f64 dead_client_scan_time;
811 f64 sleep_time, start_time;
818 uword *event_data = 0;
819 int private_segment_rotor = 0;
827 clib_warning (
"memory_api_init returned %d, quitting...", rv);
831 if ((error = socksvr_api_init (vm)))
870 u8 *serialized_message_table;
878 clib_warning (
"illegal save-message-table filename '%s'",
885 fd = creat ((
char *) chroot_file, 0644);
895 rv = write (fd, serialized_message_table,
896 vec_len (serialized_message_table));
898 if (rv != vec_len (serialized_message_table))
906 vec_free (serialized_message_table);
931 pthread_mutex_lock (&q->mutex);
935 pthread_mutex_unlock (&q->mutex);
942 .format =
"q-underflow: len %d",
957 headp = (
i8 *) (q->data + sizeof (
uword) * q->head);
961 need_broadcast = (q->cursize == q->maxsize / 2);
966 pthread_mutex_unlock (&q->mutex);
968 (void) pthread_cond_broadcast (&q->condvar);
975 int index = SLEEP_400_US;
976 if (vector_rate > 40.0)
978 else if (vector_rate > 20.0)
980 index = SLEEP_200_US;
983 else if (vector_rate >= 1.0)
985 index = SLEEP_100_US;
1014 pthread_mutex_lock (&q->mutex);
1017 headp = (
i8 *) (q->data + sizeof (
uword) * q->head);
1021 need_broadcast = (q->cursize == q->maxsize / 2);
1026 pthread_mutex_unlock (&q->mutex);
1029 (void) pthread_cond_broadcast (&q->condvar);
1034 pthread_mutex_unlock (&q->mutex);
1036 q = save_vlib_input_queue;
1040 private_segment_rotor++;
1042 private_segment_rotor = 0;
1057 for (i = 0; i <
vec_len (event_data); i++)
1076 if (now > dead_client_scan_time)
1086 .format =
"q-awake: len %d",
1087 .format_args =
"i4",
1095 ed->len = q->cursize;
1106 .name =
"api-rx-from-ring",
1107 .state = VLIB_NODE_STATE_DISABLED,
1117 u64 total_counts = 0;
1125 if (total_counts == 0)
1134 percent = ((f64) vector_rate_histogram[SLEEP_##n##_US]) \ 1135 / (f64) total_counts; \ 1137 vlib_cli_output (vm, "Sleep %3d us: %llu, %.2f%%",n, \ 1138 vector_rate_histogram[SLEEP_##n##_US], \ 1153 .path =
"show api histogram",
1154 .short_help =
"show api histogram",
1177 .path =
"clear api histogram",
1178 .short_help =
"clear api histogram",
1204 vec_add1 (vl_api_queue_cursizes, &q->cursize);
1210 shmem_hdr = (
void *) vlib_rp->
user_ctx;
1212 vec_add1 (vl_api_queue_cursizes, &q->cursize);
1216 for (i = 0; i <
vec_len (vl_api_queue_cursizes); i++)
1218 if (*vl_api_queue_cursizes[i])
1235 ? VLIB_NODE_STATE_POLLING
1236 : VLIB_NODE_STATE_DISABLED));
1246 static u8 *long_msg;
1252 while (n_left_from > 0)
1269 _vec_len (long_msg) = 0;
1270 vec_add (long_msg, msg, msg_len);
1276 vec_add (long_msg, msg, msg_len);
1294 .name =
"api-rx-from-node",
1312 int main_segment = va_arg (*args,
int);
1317 return format (s,
"%8s %8s %8s %8s %8s\n",
1318 "Owner",
"Size",
"Nitems",
"Hits",
"Misses");
1324 s =
format (s,
"%8s %8d %8d %8d %8d\n",
1333 s =
format (s,
"%8s %8d %8d %8d %8d\n",
1343 "%d application restarts, %d reclaimed msgs, %d garbage collects\n",
1380 shmem_hdr = (
void *) vlib_rp->
user_ctx;
1389 if (regp && regp->vlib_rp == vlib_rp)
1409 __attribute__ ((weak));
1424 u32 *confused_indices = 0;
1427 goto socket_clients;
1430 "Name",
"PID",
"Queue Length",
"Queue VA",
"Health");
1439 if (regp->unanswered_pings > 0)
1440 health =
"questionable";
1444 q = regp->vl_input_queue;
1446 vlib_cli_output (vm,
"%16s %8d %14d 0x%016llx %s\n",
1447 regp->name, q->consumer_pid, q->cursize,
1452 clib_warning (
"NULL client registration index %d",
1453 regpp - am->vl_clients);
1454 vec_add1 (confused_indices, regpp - am->vl_clients);
1463 for (i = 0; i <
vec_len (confused_indices); i++)
1518 .short_help =
"Show API information",
1528 .path =
"show api ring-stats",
1529 .short_help =
"Message ring statistics",
1540 .path =
"show api clients",
1541 .short_help =
"Client information",
1552 .path =
"show api trace-status",
1553 .short_help =
"Display API trace status",
1603 .path =
"show api message-table",
1604 .short_help =
"Message Table",
1621 else if (
unformat (input,
"tx nitems %u", &nitems)
1627 else if (
unformat (input,
"on rx"))
1631 else if (
unformat (input,
"on tx"))
1651 else if (
unformat (input,
"debug on"))
1655 else if (
unformat (input,
"debug off"))
1681 .path =
"set api-trace [on][on tx][on rx][off][free][debug on][debug off]",
1682 .short_help =
"API trace",
1694 memset (a, 0,
sizeof (*a));
1727 int len0, len1, clen;
1731 clen = len0 < len1 ? len0 : len1;
1732 return (strncmp ((
char *) a0->
name, (
char *) a1->
name, clen));
1741 s =
format (s,
"%-50s%9s%9s",
"Name",
"First-ID",
"Last-ID");
1771 for (i = 0; i <
vec_len (rp); i++)
1785 .path =
"show api plugin",
1786 .short_help =
"show api plugin",
1794 vl_api_rpc_call_reply_t *rmp;
1824 rmp->_vl_msg_id = ntohs (VL_API_RPC_CALL_REPLY);
1859 while (pthread_mutex_trylock (&q->mutex))
1864 pthread_mutex_unlock (&q->mutex);
1866 while (pthread_mutex_trylock (&q->mutex))
1872 pthread_mutex_unlock (&q->mutex);
1887 void (*call_fp) (
void *);
1901 memset (mp, 0,
sizeof (*mp));
1903 mp->_vl_msg_id = ntohs (VL_API_RPC_CALL);
1947 clib_warning (
"WARNING: traced plugin '%s' not in current image",
1955 clib_warning (
"WARNING: traced plugin '%s' first message id %d not %d",
1962 clib_warning (
"WARNING: traced plugin '%s' last message id %d not %d",
1968 #define foreach_rpc_api_msg \ 1969 _(RPC_CALL,rpc_call) \ 1970 _(RPC_CALL_REPLY,rpc_call_reply) 1972 #define foreach_plugin_trace_msg \ 1973 _(TRACE_PLUGIN_MSG_IDS,trace_plugin_msg_ids) 1991 vl_msg_api_set_handlers(VL_API_##N, #n, \ 1992 vl_api_##n##_t_handler, \ 1995 vl_api_##n##_t_print, \ 1996 sizeof(vl_api_##n##_t), 0 ); 2001 vl_msg_api_set_handlers(VL_API_##N, #n, \ 2002 vl_api_##n##_t_handler, \ 2005 vl_api_##n##_t_print, \ 2006 sizeof(vl_api_##n##_t), 1 ); 2011 am->
is_mp_safe[VL_API_TRACE_PLUGIN_MSG_IDS] = 1;
2038 trace_name =
"TX trace";
2043 trace_name =
"RX trace";
2052 s =
format (s,
"%s: not yet configured.\n", trace_name);
2056 s =
format (s,
"%s: used %d of %d items, %s enabled, %s wrapped\n",
2063 __attribute__ ((weak));
2071 u32 first_index,
u32 last_index,
2072 vl_api_replay_t which)
2074 vl_api_trace_file_header_t *hp;
2079 u8 endian_swap_needed = 0;
2083 void **saved_print_handlers = 0;
2085 fd = open ((
char *) filename, O_RDONLY);
2093 if (fstat (fd, &statb) < 0)
2100 if (!(statb.st_mode & S_IFREG) || (statb.st_size < sizeof (*hp)))
2107 file_size = statb.st_size;
2108 file_size = (file_size + 4095) & ~(4096);
2110 hp = mmap (0, file_size, PROT_READ, MAP_PRIVATE, fd, 0);
2112 if (hp == (vl_api_trace_file_header_t *) MAP_FAILED)
2122 endian_swap_needed = 1;
2124 if (endian_swap_needed)
2125 nitems = ntohl (hp->nitems);
2127 nitems = hp->nitems;
2129 if (last_index == (
u32) ~ 0)
2131 last_index = nitems - 1;
2134 if (first_index >= nitems || last_index >= nitems)
2137 first_index, last_index, nitems - 1);
2138 munmap (hp, file_size);
2143 "Note: wrapped/incomplete trace, results may vary\n");
2152 msg = (
u8 *) (hp + 1);
2154 for (i = 0; i < first_index; i++)
2160 size = clib_host_to_net_u32 (*(
u32 *) msg);
2161 msg +=
sizeof (
u32);
2164 msg_id = ntohs (*((
u16 *) msg));
2166 msg_id = *((
u16 *) msg);
2172 munmap (hp, file_size);
2181 for (; i <= last_index; i++)
2191 size = clib_host_to_net_u32 (*(
u32 *) msg);
2192 msg +=
sizeof (
u32);
2195 msg_id = ntohs (*((
u16 *) msg));
2197 msg_id = *((
u16 *) msg);
2203 munmap (hp, file_size);
2212 memset (tmpbuf, 0xf,
sizeof (
uword));
2222 void (*endian_fp) (
void *);
2227 munmap (hp, file_size);
2233 (*endian_fp) (tmpbuf +
sizeof (
uword));
2239 msg_idp = (
u16 *) (tmpbuf +
sizeof (
uword));
2250 u8 *(*print_fp) (
void *,
void *);
2253 (*print_fp) (tmpbuf +
sizeof (
uword), vm);
2269 u8 *(*print_fp) (
void *,
void *);
2275 (*print_fp) (tmpbuf +
sizeof (
uword), vm);
2278 s =
format (0,
"static u8 * vl_api_%s_%d[%d] = {",
2286 s =
format (s,
"0x%02x,", tmpbuf[
sizeof (
uword) + j]);
2288 s =
format (s,
"\n};\n%c", 0);
2298 void (*handler) (
void *);
2304 (*handler) (tmpbuf +
sizeof (
uword));
2318 _vec_len (tmpbuf) = 0;
2322 if (saved_print_handlers)
2329 munmap (hp, file_size);
2338 u32 nitems = 256 << 10;
2351 if (
unformat (input,
"nitems %d", &nitems))
2360 else if (
unformat (input,
"save %s", &filename))
2362 u8 *chroot_filename;
2363 if (strstr ((
char *) filename,
"..")
2364 || index ((
char *) filename,
'/'))
2371 chroot_filename =
format (0,
"/tmp/%s%c", filename, 0);
2375 fp = fopen ((
char *) chroot_filename,
"w");
2393 "Error while writing end of buffer trace to file\n");
2396 "Error while writing start of buffer trace to file\n");
2403 else if (
unformat (input,
"dump %s", &filename))
2407 else if (
unformat (input,
"custom-dump %s", &filename))
2411 else if (
unformat (input,
"replay %s", &filename))
2415 else if (
unformat (input,
"initializers %s", &filename))
2423 else if (
unformat (input,
"first %d", &first))
2427 else if (
unformat (input,
"last %d", &last))
2431 else if (
unformat (input,
"status"))
2441 else if (
unformat (input,
"post-mortem-on"))
2443 else if (
unformat (input,
"post-mortem-off"))
2459 .path =
"api trace",
2461 "api trace [on|off][dump|save|replay <file>][status][free][post-mortem-on]",
2469 u32 nitems = 256 << 10;
2477 if (
unformat (input,
"nitems %d", &nitems))
2483 else if (
unformat (input,
"save-api-table %s",
2509 if (
unformat (input,
"length %d", &nitems) ||
2510 (
unformat (input,
"len %d", &nitems)))
2515 clib_warning (
"vlib input queue length %d too small, ignored",
2550 for (i =
vec_len (rv) - 1; i >= 0; i--)
2600 int compare_current = 0;
2601 int numeric_sort = 0;
2604 u32 ndifferences = 0;
2608 if (
unformat (input,
"file %s", &filename))
2610 else if (
unformat (input,
"compare-current")
2612 compare_current = 1;
2613 else if (
unformat (input,
"numeric"))
2620 if (numeric_sort && compare_current)
2622 (0,
"Comparison and numeric sorting are incompatible");
2636 for (i = 0; i < nmsgs; i++)
2641 item->msg_index = msg_index;
2642 item->name_and_crc = name_and_crc;
2650 if (compare_current)
2658 for (i = 0; i < nmsgs; i++)
2664 item->msg_index = msg_index;
2665 item->name_and_crc = name_and_crc;
2679 if (compare_current)
2691 for (i = 0; i <
vec_len (table);)
2694 if (i == vec_len (table) - 1)
2702 ((
char *) table[i].name_and_crc,
2703 (
char *) table[i + 1].name_and_crc,
2704 vec_len (table[i].name_and_crc)))
2713 if (strncmp ((
char *) table[i].name, (
char *) table[i + 1].name,
2714 vec_len (table[i].name)))
2718 table[i].name, table[i].which ?
2727 if (ndifferences == 0)
2736 vlib_cli_output (vm,
"%=60s %=8s %=10s",
"Message name",
"MsgID",
"CRC");
2738 for (i = 0; i <
vec_len (table); i++)
2742 item->msg_index, item->crc);
2746 for (i = 0; i <
vec_len (table); i++)
2793 .path =
"show api dump",
2794 .short_help =
"show api dump file <filename> [numeric | compare-current]",
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Message range (belonging to a plugin)
vl_api_registration_t * regp
void vl_set_memory_region_name(const char *name)
u8 * format_api_message_rings(u8 *s, va_list *args)
static int table_id_cmp(void *a1, void *a2)
void * vl_msg_api_alloc_as_if_client(int nbytes)
#define TRACE_VLIB_MEMORY_QUEUE
uword * pending_rpc_requests
#define vl_print(handle,...)
static int memory_api_init(const char *region_name)
#define SVM_GLOBAL_REGION_NAME
sll srl srl sll sra u16x4 i
void vl_api_memclnt_delete_t_handler(vl_api_memclnt_delete_t *mp)
u8 * name
name of the plugin
static void svm_pop_heap(void *oldheap)
static u64 unserialize_likely_small_unsigned_integer(serialize_main_t *m)
static f64 vlib_process_wait_for_event_or_clock(vlib_main_t *vm, f64 dt)
Suspend a cooperative multi-tasking thread Waits for an event, or for the indicated number of seconds...
int unix_shared_memory_queue_is_full(unix_shared_memory_queue_t *q)
static void vlib_buffer_free(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Free buffers Frees the entire buffer chain for each buffer.
static clib_error_t * api_queue_config_fn(vlib_main_t *vm, unformat_input_t *input)
static clib_error_t * setup_memclnt_exit(vlib_main_t *vm)
u8 wrapped
trace has wrapped
int size
for sanity checking
Fixed length block allocator.
unix_shared_memory_queue_t * vl_input_queue
static vlib_node_registration_t api_rx_from_node_node
(constructor) VLIB_REGISTER_NODE (api_rx_from_node_node)
static f64 vlib_time_now(vlib_main_t *vm)
static clib_error_t * vl_api_client_command(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cli_cmd)
u8 * message_bounce
Don't automatically free message buffer vetor.
vl_socket_args_for_process_t * process_args
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).
static void vl_api_trace_plugin_msg_ids_t_handler(vl_api_trace_plugin_msg_ids_t *mp)
static clib_error_t * vl_api_message_table_command(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cli_cmd)
static clib_error_t * vl_api_show_plugin_command(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cli_cmd)
static heap_elt_t * last(heap_header_t *h)
#define SVM_PVT_MHEAP_SIZE
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
api_version_t * api_version_list
api version list
int api_uid
uid for the api shared memory region
static clib_error_t * api_config_fn(vlib_main_t *vm, unformat_input_t *input)
ring_alloc_t * client_rings
static clib_error_t * vl_api_clear_histogram_command(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cli_cmd)
void vl_msg_api_send(vl_api_registration_t *rp, u8 *elem)
#define pool_is_free(P, E)
Use free bitmap to query whether given element is free.
static void vl_api_rpc_call_reply_t_handler(vl_api_rpc_call_reply_t *mp)
void vl_api_get_first_msg_id_t_handler(vl_api_get_first_msg_id_t *mp)
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
int api_gid
gid for the api shared memory region
static clib_error_t * dump_api_table_file_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
void vl_enable_disable_memory_api(vlib_main_t *vm, int enable)
#define VL_API_EPOCH_MASK
trace_cfg_t * api_trace_cfg
Current trace configuration.
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
#define vlib_worker_thread_barrier_sync(X)
_vl_msg_api_function_list_elt_t * reaper_function_registrations
List of API client reaper functions.
void vl_msg_api_custom_dump_configure(api_main_t *am)
#define vec_add(V, E, N)
Add N elements to end of vector V (no header, unspecified alignment)
static f64 vlib_last_vector_length_per_node(vlib_main_t *vm)
static void vlib_worker_thread_barrier_check(void)
#define VLIB_BUFFER_NEXT_PRESENT
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
_vlib_init_function_list_elt_t * api_init_function_registrations
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
static int range_compare(vl_api_msg_range_t *a0, vl_api_msg_range_t *a1)
vl_api_trace_t * rx_trace
Received message trace configuration.
void vl_api_api_versions_t_handler(vl_api_api_versions_t *mp)
#define VLIB_INIT_FUNCTION(x)
static uword vlib_process_get_events(vlib_main_t *vm, uword **data_vector)
Return the first event type which has occurred and a vector of per-event data of that type...
void vl_msg_api_handler_no_trace_no_free(void *the_msg)
u32 ring_misses
Number of times that the ring allocator failed.
static void * svm_push_data_heap(svm_region_t *rp)
void vl_api_socket_process_msg(clib_file_t *uf, vl_api_registration_t *rp, i8 *input_v)
vl_api_registration_t ** vl_clients
vlib/vpp only: vector of client registrations
#define clib_arch_is_little_endian
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
int replay_in_progress
Replay in progress?
static void send_one_plugin_msg_ids_msg(u8 *name, u16 first_msg_id, u16 last_msg_id)
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.
clib_error_t * vlib_call_init_exit_functions(vlib_main_t *vm, _vlib_init_function_list_elt_t *head, int call_once)
static clib_error_t * api_trace_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define SVM_GLOBAL_REGION_BASEVA
struct vl_shmem_hdr_ * shmem_hdr
Binary API shared-memory segment header pointer.
static void * vl_api_memclnt_create_t_print(vl_api_memclnt_create_t *a, void *handle)
void vl_socket_api_send(vl_api_registration_t *rp, u8 *elem)
#define foreach_plugin_trace_msg
#define vlib_call_init_function(vm, x)
#define SOCKET_READ_EVENT
static uword pointer_to_uword(const void *p)
void * vl_msg_api_alloc(int nbytes)
static void memclnt_queue_callback(vlib_main_t *vm)
static void vlib_set_queue_signal_callback(vlib_main_t *vm, void(*fp)(vlib_main_t *))
static vlib_cli_command_t cli_show_api_histogram_command
(constructor) VLIB_CLI_COMMAND (cli_show_api_histogram_command)
vl_shmem_hdr_t * shmem_hdr
static heap_elt_t * first(heap_header_t *h)
void * rpc_call_main_thread_cb_fn
int vl_msg_api_trace_free(api_main_t *am, vl_api_trace_which_t which)
vl_registration_type_t registration_type
type
int unix_shared_memory_queue_add(unix_shared_memory_queue_t *q, u8 *elem, int nowait)
u16 last_msg_id
last assigned message ID
static void * vl_api_trace_plugin_msg_ids_t_print(vl_api_trace_plugin_msg_ids_t *a, void *handle)
static void dead_client_scan(api_main_t *am, vl_shmem_hdr_t *shm, f64 now)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
#define foreach_rpc_api_msg
vlib_node_registration_t memclnt_node
(constructor) VLIB_REGISTER_NODE (memclnt_node)
static clib_error_t * vl_api_ring_command(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cli_cmd)
u16 current_length
Nbytes between current data and the end of this buffer.
static void vlib_process_signal_event(vlib_main_t *vm, uword node_index, uword type_opaque, uword data)
static int call_reaper_functions(u32 client_index)
void(** msg_print_handlers)(void *, void *)
Message print function vector.
void vl_api_memclnt_keepalive_reply_t_handler(vl_api_memclnt_keepalive_reply_t *mp)
client answered a ping, stave off the grim reaper...
int replay_enable
This message can be replayed.
volatile int ** vl_api_queue_cursizes
void vl_msg_api_free(void *)
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...
#define pool_put(P, E)
Free an object E in pool P.
#define vec_dup(V)
Return copy of vector (no header, no alignment)
static void cleanup(void)
svm_region_t ** vlib_private_rps
Vector of all mapped shared-VM segments.
#define VLIB_CONFIG_FUNCTION(x, n,...)
void svm_region_init_args(svm_map_region_args_t *a)
void vl_msg_api_barrier_sync(void)
static void vl_api_rpc_call_t_handler(vl_api_rpc_call_t *mp)
#define SVM_GLOBAL_REGION_SIZE
static u32 vl_msg_api_handle_get_index(u32 index)
#define foreach_vlib_api_msg
void vl_msg_api_handler_with_vm_node(api_main_t *am, void *the_msg, vlib_main_t *vm, vlib_node_runtime_t *node)
volatile u32 queue_signal_pending
#define QUEUE_SIGNAL_EVENT
void unserialize_cstring(serialize_main_t *m, char **s)
vl_api_module_version_t api_versions[count]
#define uword_to_pointer(u, type)
API main structure, used by both vpp and binary API clients.
socket_main_t socket_main
int vl_msg_api_trace_save(api_main_t *am, vl_api_trace_which_t which, FILE *fp)
u64 global_size
size of the global VM region
void vl_api_force_rpc_call_main_thread(void *fp, u8 *data, u32 data_length)
u8 enabled
trace is enabled
An API client registration, only in vpp/vlib.
The fine-grained event logger allows lightweight, thread-safe event logging at minimum cost...
#define clib_arch_is_big_endian
int vl_msg_api_trace_onoff(api_main_t *am, vl_api_trace_which_t which, int onoff)
static void vl_api_rpc_call_main_thread_inline(void *fp, u8 *data, u32 data_length, u8 force_rpc)
static_always_inline uword vlib_get_thread_index(void)
void vl_api_rpc_call_main_thread(void *fp, u8 *data, u32 data_length)
void serialize_open_vector(serialize_main_t *m, u8 *vector)
void vl_unmap_shmem(void)
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
vl_api_msg_range_t * msg_ranges
vector of message ranges
clib_error_t * unserialize_open_clib_file(serialize_main_t *m, char *file)
#define clib_warning(format, args...)
clib_error_t * vlibsocket_init(vlib_main_t *vm)
#define clib_memcpy(a, b, c)
#define foreach_histogram_bucket
unix_shared_memory_queue_t * vl_api_client_index_to_input_queue(u32 index)
static void unserialize_integer(serialize_main_t *m, void *x, u32 n_bytes)
static void serialize_integer(serialize_main_t *m, u64 x, u32 n_bytes)
#define ELOG_TYPE_DECLARE(f)
const char ** msg_names
Message name vector.
void vl_msg_api_barrier_release(void)
static clib_error_t * vl_api_trace_command(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cli_cmd)
static void vl_msg_api_process_file(vlib_main_t *vm, u8 *filename, u32 first_index, u32 last_index, vl_api_replay_t which)
#define VLIB_CLI_COMMAND(x,...)
u8 * save_msg_table_filename
Dump (msg-name, crc) snapshot here at startup.
#define VL_API_BIG_ENDIAN
void vl_msg_api_send_shmem(unix_shared_memory_queue_t *q, u8 *elem)
vl_api_trace_t * tx_trace
Sent message trace configuration.
static uword api_rx_from_node(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
#define pool_put_index(p, i)
Free pool element with given index.
static uword hash_elts(void *v)
clib_error_t * vlibmemory_init(vlib_main_t *vm)
#define VL_API_LITTLE_ENDIAN
#define vec_delete(V, N, M)
Delete N elements starting at element M.
static u64 vector_rate_histogram[SLEEP_N_BUCKETS]
static uword memclnt_process(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *f)
void serialize_close(serialize_main_t *m)
VLIB_API_INIT_FUNCTION(rpc_api_hookup)
u8 * vl_api_serialize_message_table(api_main_t *am, u8 *vector)
u32 next_buffer
Next buffer for this linked-list of buffers.
static void clib_mem_free(void *p)
static u8 * extract_name(u8 *s)
static vlib_cli_command_t cli_clear_api_histogram_command
(constructor) VLIB_CLI_COMMAND (cli_clear_api_histogram_command)
u8 * serialized_message_table_in_shmem
vlib/vpp only: serialized (message, name, crc) table
#define clib_error_report(e)
static void * vlib_frame_args(vlib_frame_t *f)
Get pointer to frame scalar data.
void dump_socket_clients(vlib_main_t *vm, api_main_t *am)
u64 global_pvt_heap_size
size of the global VM private mheap
static void vlib_node_set_state(vlib_main_t *vm, u32 node_index, vlib_node_state_t new_state)
Set node dispatch state.
static void * clib_mem_alloc(uword size)
static u8 * format_api_msg_range(u8 *s, va_list *args)
static vlib_main_t * vlib_get_main(void)
static clib_error_t * rpc_api_hookup(vlib_main_t *vm)
static clib_error_t * vl_api_status_command(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cli_cmd)
u32 missing_clients
Number of missing clients / failed message sends.
void vl_msg_api_post_mortem_dump_enable_disable(int enable)
static void send_memclnt_keepalive(vl_api_registration_t *regp, f64 now)
u16 first_msg_id
first assigned message ID
void vl_msg_api_send_shmem_nolock(unix_shared_memory_queue_t *q, u8 *elem)
void vl_api_memclnt_create_t_handler(vl_api_memclnt_create_t *mp)
void(** msg_endian_handlers)(void *)
Message endian handler vector.
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define hash_foreach_pair(p, v, body)
Iterate over hash pairs.
static u8 * extract_crc(u8 *s)
#define vec_sort_with_function(vec, f)
Sort a vector using the supplied element comparison function.
#define clib_unix_warning(format, args...)
void vl_api_send_pending_rpc_requests(vlib_main_t *vm)
u8 * format_vl_msg_api_trace_status(u8 *s, va_list *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)
static clib_error_t * vl_api_show_histogram_command(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cli_cmd)
volatile u32 api_queue_nonempty
#define hash_get_mem(h, key)
void(** msg_handlers)(void *)
Message handler vector.
clib_error_t * socksvr_api_init(vlib_main_t *vm)
void vlib_worker_thread_barrier_release(vlib_main_t *vm)
u8 * is_mp_safe
Message is mp safe vector.
#define VLIB_REGISTER_NODE(x,...)
static int table_name_and_crc_cmp(void *a1, void *a2)
int msg_print_flag
Print every received message.
vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
void * serialize_close_vector(serialize_main_t *m)
static void * vl_api_memclnt_delete_t_print(vl_api_memclnt_delete_t *a, void *handle)
vl_api_trace_which_t
Trace RX / TX enum.
const char * region_name
Shared VM binary API region name.
Trace configuration for a single message.
static u32 vl_msg_api_handle_get_epoch(u32 index)
int vl_map_shmem(const char *region_name, int is_vlib)
u32 vl_api_memclnt_create_internal(char *name, unix_shared_memory_queue_t *q)
uword * msg_index_by_name_and_crc
client message index hash table
int vl_msg_api_trace_configure(api_main_t *am, vl_api_trace_which_t which, u32 nitems)
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
uword * msg_range_by_name
Message range by name hash.
Shared memory connection.
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
u32 nitems
Number of trace records.
u32 vlib_input_queue_length
vpp/vlib input queue length
static u32 vl_msg_api_handle_from_index_and_epoch(u32 index, u32 epoch)
CLIB vectors are ubiquitous dynamically resized arrays with by user defined "headers".
struct _unix_shared_memory_queue unix_shared_memory_queue_t
static uword pool_elts(void *v)
Number of active elements in a pool.