41 #define TRACE_VLIB_MEMORY_QUEUE 0 50 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__) 59 vl_print (handle,
"vl_api_trace_plugin_msg_ids: %s first %u last %u\n",
86 serialize_likely_small_unsigned_integer (sm, hp->value[0]);
87 serialize_cstring (sm, (char *) hp->key);
103 u16 first_msg_id = ~0;
112 strncpy ((
char *) name, (
char *) mp->
name,
ARRAY_LEN (name));
124 rmp->_vl_msg_id = ntohs (VL_API_GET_FIRST_MSG_ID_REPLY);
138 int msg_size =
sizeof (*rmp) +
sizeof (rmp->
api_versions[0]) * nmsg;
146 memset (rmp, 0, msg_size);
147 rmp->_vl_msg_id = ntohs (VL_API_API_VERSIONS_REPLY);
151 rmp->
count = htonl (nmsg);
153 for (i = 0; i < nmsg; ++
i)
168 #define foreach_vlib_api_msg \ 169 _(GET_FIRST_MSG_ID, get_first_msg_id) \ 170 _(API_VERSIONS, api_versions) 181 memset (c, 0,
sizeof (*c));
183 #define _(N,n) do { \ 184 c->id = VL_API_##N; \ 186 c->handler = vl_api_##n##_t_handler; \ 187 c->cleanup = vl_noop_handler; \ 188 c->endian = vl_api_##n##_t_endian; \ 189 c->print = vl_api_##n##_t_print; \ 190 c->size = sizeof(vl_api_##n##_t); \ 193 c->message_bounce = 0; \ 194 vl_msg_api_config(c);} while (0); 216 memset (mp, 0,
sizeof (*mp));
218 mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_TRACE_PLUGIN_MSG_IDS);
222 mp->
last_msg_id = clib_host_to_net_u16 (last_msg_id);
232 u8 *serialized_message_table;
243 clib_warning (
"illegal save-message-table filename '%s'",
250 fd = creat ((
char *) chroot_file, 0644);
260 rv = write (fd, serialized_message_table,
261 vec_len (serialized_message_table));
263 if (rv !=
vec_len (serialized_message_table))
271 vec_free (serialized_message_table);
278 int private_segment_rotor = 0,
i, rv;
284 f64 dead_client_scan_time;
285 f64 sleep_time, start_time;
289 uword *event_data = 0;
301 clib_warning (
"vlib_api_init returned %d, quitting...", rv);
360 int index = SLEEP_400_US;
361 if (vector_rate > 40.0)
363 else if (vector_rate > 20.0)
365 index = SLEEP_200_US;
368 else if (vector_rate >= 1.0)
370 index = SLEEP_100_US;
392 private_segment_rotor = 0;
427 if (now > dead_client_scan_time)
441 .name =
"api-rx-from-ring",
442 .state = VLIB_NODE_STATE_DISABLED,
451 ? VLIB_NODE_STATE_POLLING
452 : VLIB_NODE_STATE_DISABLED));
468 while (n_left_from > 0)
482 if (b0->
flags & VLIB_BUFFER_NEXT_PRESENT)
485 _vec_len (long_msg) = 0;
486 vec_add (long_msg, msg, msg_len);
487 while (b0->
flags & VLIB_BUFFER_NEXT_PRESENT)
492 vec_add (long_msg, msg, msg_len);
510 .name =
"api-rx-from-node",
517 vl_api_rpc_call_reply_t *rmp;
546 rmp->_vl_msg_id = ntohs (VL_API_RPC_CALL_REPLY);
581 while (pthread_mutex_trylock (&q->mutex))
586 pthread_mutex_unlock (&q->mutex);
588 while (pthread_mutex_trylock (&q->mutex))
594 pthread_mutex_unlock (&q->mutex);
609 void (*call_fp) (
void *);
623 memset (mp, 0,
sizeof (*mp));
625 mp->_vl_msg_id = ntohs (VL_API_RPC_CALL);
669 clib_warning (
"WARNING: traced plugin '%s' not in current image",
677 clib_warning (
"WARNING: traced plugin '%s' first message id %d not %d",
684 clib_warning (
"WARNING: traced plugin '%s' last message id %d not %d",
690 #define foreach_rpc_api_msg \ 691 _(RPC_CALL,rpc_call) \ 692 _(RPC_CALL_REPLY,rpc_call_reply) 694 #define foreach_plugin_trace_msg \ 695 _(TRACE_PLUGIN_MSG_IDS,trace_plugin_msg_ids) 713 vl_msg_api_set_handlers(VL_API_##N, #n, \ 714 vl_api_##n##_t_handler, \ 717 vl_api_##n##_t_print, \ 718 sizeof(vl_api_##n##_t), 0 ); 723 vl_msg_api_set_handlers(VL_API_##N, #n, \ 724 vl_api_##n##_t_handler, \ 727 vl_api_##n##_t_print, \ 728 sizeof(vl_api_##n##_t), 1 ); 733 am->
is_mp_safe[VL_API_TRACE_PLUGIN_MSG_IDS] = 1;
#define foreach_vlib_api_msg
int vl_mem_api_handle_msg_private(vlib_main_t *vm, vlib_node_runtime_t *node, u32 reg_index)
#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
int vl_mem_api_handle_msg_main(vlib_main_t *vm, vlib_node_runtime_t *node)
uword * pending_rpc_requests
static void send_one_plugin_msg_ids_msg(u8 *name, u16 first_msg_id, u16 last_msg_id)
VLIB_API_INIT_FUNCTION(rpc_api_hookup)
clib_error_t * vl_sock_api_init(vlib_main_t *vm)
void vl_msg_api_handler_no_trace_no_free(void *the_msg)
static void vl_api_rpc_call_main_thread_inline(void *fp, u8 *data, u32 data_length, u8 force_rpc)
void vl_api_save_msg_table(void)
u8 * name
name of the plugin
int svm_queue_is_full(svm_queue_t *q)
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...
static void vl_api_get_first_msg_id_t_handler(vl_api_get_first_msg_id_t *mp)
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 void * vl_api_trace_plugin_msg_ids_t_print(vl_api_trace_plugin_msg_ids_t *a, void *handle)
Fixed length block allocator.
static f64 vlib_time_now(vlib_main_t *vm)
static void vl_api_send_msg(vl_api_registration_t *rp, u8 *elem)
vl_socket_args_for_process_t * process_args
Message configuration definition.
socket_main_t socket_main
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
api_version_t * api_version_list
api version list
void vl_socket_process_api_msg(clib_file_t *uf, vl_api_registration_t *rp, i8 *input_v)
void * vl_msg_api_alloc(int nbytes)
#define VL_MEM_API_LOG_Q_LEN(fmt, qlen)
vlib_node_registration_t vl_api_clnt_node
(constructor) VLIB_REGISTER_NODE (vl_api_clnt_node)
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
#define vlib_worker_thread_barrier_sync(X)
#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)
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
_vlib_init_function_list_elt_t * api_init_function_registrations
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...
static clib_error_t * rpc_api_hookup(vlib_main_t *vm)
void vl_mem_api_dead_client_scan(api_main_t *am, vl_shmem_hdr_t *shm, f64 now)
#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?
clib_error_t * vlib_call_init_exit_functions(vlib_main_t *vm, _vlib_init_function_list_elt_t *head, int call_once)
void vl_api_send_pending_rpc_requests(vlib_main_t *vm)
struct vl_shmem_hdr_ * shmem_hdr
Binary API shared-memory segment header pointer.
static uword vl_api_clnt_process(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *f)
vl_shmem_hdr_t * shmem_hdr
u16 last_msg_id
last assigned message ID
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
u16 current_length
Nbytes between current data and the end of this buffer.
void * rpc_call_main_thread_cb_fn
#define pool_put(P, E)
Free an object E in pool P.
svm_region_t ** vlib_private_rps
Vector of all mapped shared-VM segments.
volatile u32 queue_signal_pending
vl_api_module_version_t api_versions[count]
API main structure, used by both vpp and binary API clients.
static void vl_api_rpc_call_reply_t_handler(vl_api_rpc_call_reply_t *mp)
An API client registration, only in vpp/vlib.
The fine-grained event logger allows lightweight, thread-safe event logging at minimum cost...
void vl_msg_api_send_shmem(svm_queue_t *q, u8 *elem)
#define VLIB_REGISTER_NODE(x,...)
static_always_inline uword vlib_get_thread_index(void)
static vlib_node_registration_t api_rx_from_node_node
(constructor) VLIB_REGISTER_NODE (api_rx_from_node_node)
void serialize_open_vector(serialize_main_t *m, u8 *vector)
svm_queue_t * vl_api_client_index_to_input_queue(u32 index)
#define vec_free(V)
Free vector's memory (no header).
u8 * vl_api_serialize_message_table(api_main_t *am, u8 *vector)
vl_api_msg_range_t * msg_ranges
vector of message ranges
#define clib_warning(format, args...)
#define vl_print(handle,...)
#define clib_memcpy(a, b, c)
u64 vector_rate_histogram[SLEEP_N_BUCKETS]
static void vl_api_rpc_call_t_handler(vl_api_rpc_call_t *mp)
static void serialize_integer(serialize_main_t *m, u64 x, u32 n_bytes)
static vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
svm_queue_t * vl_input_queue
u8 * save_msg_table_filename
Dump (msg-name, crc) snapshot here at startup.
#define uword_to_pointer(u, type)
#define foreach_rpc_api_msg
static uword hash_elts(void *v)
u32 next_buffer
Next buffer for this linked-list of buffers.
#define clib_error_report(e)
static void * vlib_frame_args(vlib_frame_t *f)
Get pointer to frame scalar data.
void vl_api_api_versions_t_handler(vl_api_api_versions_t *mp)
static void vlib_node_set_state(vlib_main_t *vm, u32 node_index, vlib_node_state_t new_state)
Set node dispatch state.
static uword pointer_to_uword(const void *p)
static vlib_main_t * vlib_get_main(void)
#define foreach_plugin_trace_msg
u16 first_msg_id
first assigned message ID
void vl_api_rpc_call_main_thread(void *fp, u8 *data, u32 data_length)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define hash_foreach_pair(p, v, body)
Iterate over hash pairs.
#define clib_unix_warning(format, args...)
volatile u32 api_queue_nonempty
struct _svm_queue svm_queue_t
static int vlib_api_init(void)
#define hash_get_mem(h, key)
void vlib_worker_thread_barrier_release(vlib_main_t *vm)
u8 * is_mp_safe
Message is mp safe vector.
void vl_api_force_rpc_call_main_thread(void *fp, u8 *data, u32 data_length)
static void vl_api_trace_plugin_msg_ids_t_handler(vl_api_trace_plugin_msg_ids_t *mp)
static uword api_rx_from_node(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
void * vl_msg_api_alloc_as_if_client(int nbytes)
void * serialize_close_vector(serialize_main_t *m)
uword * msg_index_by_name_and_crc
client message index hash table
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.
void vl_mem_api_enable_disable(vlib_main_t *vm, int enable)
void vl_msg_api_send_shmem_nolock(svm_queue_t *q, u8 *elem)
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
CLIB vectors are ubiquitous dynamically resized arrays with by user defined "headers".