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;
113 strncpy ((
char *) name, (
char *) mp->
name,
ARRAY_LEN (name) - 1);
125 rmp->_vl_msg_id = ntohs (VL_API_GET_FIRST_MSG_ID_REPLY);
139 int msg_size =
sizeof (*rmp) +
sizeof (rmp->
api_versions[0]) * nmsg;
147 memset (rmp, 0, msg_size);
148 rmp->_vl_msg_id = ntohs (VL_API_API_VERSIONS_REPLY);
152 rmp->
count = htonl (nmsg);
154 for (i = 0; i < nmsg; ++
i)
166 #define foreach_vlib_api_msg \ 167 _(GET_FIRST_MSG_ID, get_first_msg_id) \ 168 _(API_VERSIONS, api_versions) 179 memset (c, 0,
sizeof (*c));
181 #define _(N,n) do { \ 182 c->id = VL_API_##N; \ 184 c->handler = vl_api_##n##_t_handler; \ 185 c->cleanup = vl_noop_handler; \ 186 c->endian = vl_api_##n##_t_endian; \ 187 c->print = vl_api_##n##_t_print; \ 188 c->size = sizeof(vl_api_##n##_t); \ 191 c->message_bounce = 0; \ 192 vl_msg_api_config(c);} while (0); 214 memset (mp, 0,
sizeof (*mp));
216 mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_TRACE_PLUGIN_MSG_IDS);
220 mp->
last_msg_id = clib_host_to_net_u16 (last_msg_id);
230 u8 *serialized_message_table;
241 clib_warning (
"illegal save-message-table filename '%s'",
248 fd = creat ((
char *) chroot_file, 0644);
258 rv = write (fd, serialized_message_table,
259 vec_len (serialized_message_table));
261 if (rv !=
vec_len (serialized_message_table))
269 vec_free (serialized_message_table);
276 int private_segment_rotor = 0,
i, rv;
282 f64 dead_client_scan_time;
283 f64 sleep_time, start_time;
287 uword *event_data = 0;
299 clib_warning (
"vlib_api_init returned %d, quitting...", rv);
358 int index = SLEEP_400_US;
359 if (vector_rate > 40.0)
361 else if (vector_rate > 20.0)
363 index = SLEEP_200_US;
366 else if (vector_rate >= 1.0)
368 index = SLEEP_100_US;
390 private_segment_rotor = 0;
425 if (now > dead_client_scan_time)
439 .name =
"api-rx-from-ring",
440 .state = VLIB_NODE_STATE_DISABLED,
449 ? VLIB_NODE_STATE_POLLING
450 : VLIB_NODE_STATE_DISABLED));
466 while (n_left_from > 0)
480 if (b0->
flags & VLIB_BUFFER_NEXT_PRESENT)
483 _vec_len (long_msg) = 0;
484 vec_add (long_msg, msg, msg_len);
485 while (b0->
flags & VLIB_BUFFER_NEXT_PRESENT)
490 vec_add (long_msg, msg, msg_len);
508 .name =
"api-rx-from-node",
515 vl_api_rpc_call_reply_t *rmp;
544 rmp->_vl_msg_id = ntohs (VL_API_RPC_CALL_REPLY);
579 while (pthread_mutex_trylock (&q->mutex))
584 pthread_mutex_unlock (&q->mutex);
586 while (pthread_mutex_trylock (&q->mutex))
592 pthread_mutex_unlock (&q->mutex);
607 void (*call_fp) (
void *);
621 memset (mp, 0,
sizeof (*mp));
623 mp->_vl_msg_id = ntohs (VL_API_RPC_CALL);
667 clib_warning (
"WARNING: traced plugin '%s' not in current image",
675 clib_warning (
"WARNING: traced plugin '%s' first message id %d not %d",
682 clib_warning (
"WARNING: traced plugin '%s' last message id %d not %d",
688 #define foreach_rpc_api_msg \ 689 _(RPC_CALL,rpc_call) \ 690 _(RPC_CALL_REPLY,rpc_call_reply) 692 #define foreach_plugin_trace_msg \ 693 _(TRACE_PLUGIN_MSG_IDS,trace_plugin_msg_ids) 711 vl_msg_api_set_handlers(VL_API_##N, #n, \ 712 vl_api_##n##_t_handler, \ 715 vl_api_##n##_t_print, \ 716 sizeof(vl_api_##n##_t), 0 ); 721 vl_msg_api_set_handlers(VL_API_##N, #n, \ 722 vl_api_##n##_t_handler, \ 725 vl_api_##n##_t_print, \ 726 sizeof(vl_api_##n##_t), 1 ); 731 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".