51 #define VLIB_FRAME_SIZE_ALLOC (VLIB_FRAME_SIZE + 4) 66 #define VLIB_FRAME_SIZE_EXTRA 4 71 #define VLIB_FRAME_MAGIC (0xabadc0ed) 72 n_bytes +=
sizeof (
u32);
94 u32 n_scalar_bytes,
u32 n_vector_bytes)
96 uword key = (n_scalar_bytes << 16) | n_vector_bytes;
120 u32 fi, l, n, scalar_size, vector_size;
260 if (n_alloc + n_free > 0)
270 .path =
"show vlib frame-allocation",
271 .short_help =
"Show node dispatch frame statistics",
311 tmp = owner_next_frame[0];
312 owner_next_frame[0] = next_frame[0];
363 u32 next_index,
u32 allocate_new_next_frame)
394 if (n_used >=
VLIB_FRAME_SIZE || (allocate_new_next_frame && n_used > 0))
425 u32 next_index,
u32 n_vectors_left)
432 u32 n_before, n_after;
441 ASSERT (n_after >= n_before);
461 u32 next_index,
u32 n_vectors_left)
466 u32 n_vectors_in_frame;
533 v1 = v0 + n_vectors_in_frame;
582 if (vm != &vlib_global_main)
617 u32 ca0, ca1, v0, v1, cl0, cl1, r;
625 cl1 = cl0 + n_clocks;
653 n_calls, n_vectors, n_clocks);
666 .path =
"event-logger clear",
667 .short_help =
"Clear the event log",
678 char *file, *chroot_file;
689 if (strstr (file,
"..") || index (file,
'/'))
695 chroot_file = (
char *)
format (0,
"/tmp/%s%c", file, 0);
721 filename =
format (0,
"/tmp/elog_post_mortem.%d%c", getpid (), 0);
730 .path =
"event-logger save",
731 .short_help =
"event-logger save <filename> (saves log in /tmp/<filename>)",
750 .path =
"event-logger stop",
751 .short_help =
"Stop the event-logger",
770 .path =
"event-logger restart",
771 .short_help =
"Restart the event-logger",
794 vlib_cli_output (vm,
"Resized ring and restarted the event logger...");
800 .path =
"event-logger resize",
801 .short_help =
"event-logger resize <nnn>",
823 "running" :
"stopped");
829 if (n_events_to_show == 0)
840 u32 n_events_to_show;
843 n_events_to_show = 250;
846 if (
unformat (input,
"%d", &n_events_to_show))
849 n_events_to_show = ~0;
859 .path =
"show event-logger",
860 .short_help =
"Show event logger info",
904 fformat (stderr,
"Context trace for bi %d b 0x%llx, visited %d\n",
907 if (n == 0 || n > 20)
909 fformat (stderr,
"n is unreasonable\n");
914 for (i = 0; i < n; i++)
922 fformat (stderr,
"Skip bogus node index %d\n", node_index);
933 "in vlib/buffers.h, #define VLIB_BUFFER_TRACE_TRAJECTORY 1\n");
960 return last_time_stamp;
964 && dispatch_state != VLIB_NODE_STATE_INTERRUPT)
971 return last_time_stamp;
1013 n = node->
function (vm, node, frame);
1016 n = node->
function (vm, node, frame);
1029 t - last_time_stamp);
1033 if ((dispatch_state == VLIB_NODE_STATE_INTERRUPT)
1034 || (dispatch_state == VLIB_NODE_STATE_POLLING
1038 #ifdef DISPATCH_NODE_ELOG_REQUIRED 1041 .function = (
char *) __FUNCTION__,.
format =
1042 "%s vector length %d, switching to %s",.format_args =
1043 "T4i4t4",.n_enum_strings = 2,.enum_strings =
1045 "interrupt",
"polling",},};
1048 u32 node_name, vector_length, is_polling;
1053 if ((dispatch_state == VLIB_NODE_STATE_INTERRUPT
1059 n->
state = VLIB_NODE_STATE_POLLING;
1060 node->
state = VLIB_NODE_STATE_POLLING;
1068 #ifdef DISPATCH_NODE_ELOG_REQUIRED 1072 ed->vector_length =
v;
1076 else if (dispatch_state == VLIB_NODE_STATE_POLLING
1077 && v <= nm->interrupt_threshold_vector_length)
1085 n->
state = VLIB_NODE_STATE_INTERRUPT;
1086 node->
state = VLIB_NODE_STATE_INTERRUPT;
1099 #ifdef DISPATCH_NODE_ELOG_REQUIRED 1103 ed->vector_length =
v;
1116 u64 last_time_stamp)
1122 u32 restore_frame_index;
1146 restore_frame_index = ~0;
1168 VLIB_NODE_STATE_POLLING,
1169 f, last_time_stamp);
1174 if (restore_frame_index != ~0)
1225 return last_time_stamp;
1308 uword n_vectors, is_suspend;
1310 if (node->
state != VLIB_NODE_STATE_POLLING
1313 return last_time_stamp;
1317 t = last_time_stamp;
1359 t - last_time_stamp);
1374 uword process_index,
u64 last_time_stamp)
1382 u64 t, n_vectors, is_suspend;
1384 t = last_time_stamp;
1388 return last_time_stamp;
1437 t - last_time_stamp);
1450 u32 *last_node_runtime_indices = 0;
1481 vec_alloc (last_node_runtime_indices, 32);
1517 VLIB_NODE_STATE_POLLING,
1525 VLIB_NODE_STATE_POLLING,
1543 last_node_runtime_indices;
1544 last_node_runtime_indices = tmp;
1545 _vec_len (last_node_runtime_indices) = 0;
1548 for (i = 0; i < l; i++)
1551 last_node_runtime_indices[i]);
1554 VLIB_NODE_STATE_INTERRUPT,
1575 processes_timing_wheel_data:
1631 goto processes_timing_wheel_data;
1658 int turn_on_mem_trace = 0;
1662 if (
unformat (input,
"memory-trace"))
1663 turn_on_mem_trace = 1;
1665 else if (
unformat (input,
"elog-events %d",
1668 else if (
unformat (input,
"elog-post-mortem-dump"))
1677 if (turn_on_mem_trace)
static u32 * vlib_frame_find_magic(vlib_frame_t *f, vlib_node_t *node)
static void elog_enable_disable(elog_main_t *em, int is_enabled)
Enable or disable event logging.
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
static void elog_show_buffer_internal(vlib_main_t *vm, u32 n_events_to_show)
clib_error_t * vlib_call_all_main_loop_exit_functions(vlib_main_t *vm)
vlib_frame_t * vlib_get_frame_to_node(vlib_main_t *vm, u32 to_node_index)
f64 time
Absolute time as floating point number in seconds.
u32 max_clock
Maximum clock cycle for an invocation.
u32 next_frame_index
Start of next frames for this node.
#define hash_set(h, key, value)
sll srl srl sll sra u16x4 i
clib_error_t * vlib_call_all_main_loop_enter_functions(vlib_main_t *vm)
static_always_inline void clib_spinlock_unlock(clib_spinlock_t *p)
static_always_inline void clib_spinlock_lock(clib_spinlock_t *p)
static vlib_next_frame_t * vlib_node_get_next_frame(vlib_main_t *vm, u32 node_index, u32 next_index)
Get pointer to frame by (node_index, next_index).
u32 interrupt_threshold_vector_length
u32 vlib_buffer_get_or_create_free_list(vlib_main_t *vm, u32 n_data_bytes, char *fmt,...)
vlib_process_t ** processes
vlib_node_runtime_t node_runtime
static void vlib_main_loop(vlib_main_t *vm)
static void vlib_elog_main_loop_event(vlib_main_t *vm, u32 node_index, u64 time, u32 n_vectors, u32 is_return)
void vlib_gdb_show_event_log(void)
static void dummy_queue_signal_callback(vlib_main_t *vm)
int elog_post_mortem_dump
#define VLIB_FRAME_IS_ALLOCATED
void timing_wheel_init(timing_wheel_t *w, u64 current_cpu_time, f64 cpu_clocks_per_second)
static void vlib_increment_main_loop_counter(vlib_main_t *vm)
elog_time_stamp_t init_time
Timestamps.
void clib_random_buffer_init(clib_random_buffer_t *b, uword seed)
void vlib_put_next_frame(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, u32 n_vectors_left)
Release pointer to next frame vector data.
u32 current_process_index
u64 cpu_time_next_process_ready
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
static u64 clib_cpu_time_now(void)
static u64 dispatch_process(vlib_main_t *vm, vlib_process_t *p, vlib_frame_t *f, u64 last_time_stamp)
static_always_inline uword vlib_process_startup(vlib_main_t *vm, vlib_process_t *p, vlib_frame_t *f)
#define VLIB_FRAME_NO_FREE_AFTER_DISPATCH
u32 clocks_since_last_overflow
Number of clock cycles.
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
vlib_buffer_main_t * buffer_main
#define VLIB_MAIN_LOOP_EXIT_CLI
static void vlib_process_update_stats(vlib_main_t *vm, vlib_process_t *p, uword n_calls, uword n_vectors, uword n_clocks)
void clib_longjmp(clib_longjmp_t *save, uword return_value)
u8 * event_data_as_vector
u8 * format_elog_event(u8 *s, va_list *va)
vlib_frame_t * vlib_get_next_frame_internal(vlib_main_t *vm, vlib_node_runtime_t *node, u32 next_index, u32 allocate_new_next_frame)
static void validate_frame_magic(vlib_main_t *vm, vlib_frame_t *f, vlib_node_t *n, uword next_index)
static clib_error_t * elog_resize(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
clib_spinlock_t pending_interrupt_lock
static clib_error_t * elog_save_buffer(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
void timing_wheel_insert(timing_wheel_t *w, u64 insert_cpu_time, u32 user_data)
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
uword clib_setjmp(clib_longjmp_t *save, uword return_value_not_taken)
#define vec_alloc(V, N)
Allocate space for N more elements (no header, unspecified alignment)
#define VLIB_FRAME_SIZE_EXTRA
#define VLIB_PROCESS_RESUME_PENDING
static vlib_frame_t * vlib_get_frame_no_check(vlib_main_t *vm, uword frame_index)
void vlib_frame_free(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_frame_t *f)
u16 thread_index
thread this node runs on
static void vlib_worker_thread_barrier_check(void)
u32 * pending_interrupt_node_runtime_indices
u32 input_main_loops_per_call
For input nodes: decremented on each main loop interation until it reaches zero and function is calle...
#define static_always_inline
static_always_inline u64 dispatch_node(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_node_type_t type, vlib_node_state_t dispatch_state, vlib_frame_t *frame, u64 last_time_stamp)
vlib_node_function_t * function
Node function to call.
void elog_init(elog_main_t *em, u32 n_events)
never_inline void vlib_node_runtime_sync_stats(vlib_main_t *vm, vlib_node_runtime_t *r, uword n_calls, uword n_vectors, uword n_clocks)
static void vlib_put_next_frame_validate(vlib_main_t *vm, vlib_node_runtime_t *rt, u32 next_index, u32 n_vectors_left)
u32 main_loop_vectors_processed
static clib_error_t * elog_stop(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
void vlib_dump_context_trace(vlib_main_t *vm, u32 bi)
u32 vectors_since_last_overflow
Number of vector elements processed by this node.
static clib_error_t * vlib_cli_elog_clear(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
#define clib_error_return(e, args...)
static uword vlib_process_stack_is_valid(vlib_process_t *p)
u8 pre_data[VLIB_BUFFER_PRE_DATA_SIZE]
Space for inserting data before buffer start.
#define VLIB_BUFFER_DEFAULT_FREE_LIST_BYTES
#define vec_resize(V, N)
Resize a vector (no header, unspecified alignment) Add N elements to end of given vector V...
u64 cpu_time_main_loop_start
vlib_node_runtime_t * nodes_by_type[VLIB_N_NODE_TYPE]
#define VLIB_MAIN_LOOP_EXIT_NONE
clib_error_t * vlib_node_main_init(vlib_main_t *vm)
static vlib_next_frame_t * vlib_node_runtime_get_next_frame(vlib_main_t *vm, vlib_node_runtime_t *n, u32 next_index)
static uword pointer_to_uword(const void *p)
static void clib_spinlock_init(clib_spinlock_t *p)
u32 calls_since_last_overflow
Number of calls.
vlib_worker_thread_t * vlib_worker_threads
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
static void * vlib_process_signal_event_helper(vlib_node_main_t *nm, vlib_node_t *n, vlib_process_t *p, uword t, uword n_data_elts, uword n_data_elt_bytes)
vlib_node_stats_t stats_total
static clib_error_t * elog_restart(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
u16 state
Input node state.
void vlib_node_sync_stats(vlib_main_t *vm, vlib_node_t *n)
vlib_signal_timed_event_data_t * signal_timed_event_data_pool
vlib_main_t vlib_global_main
static u32 vlib_frame_index(vlib_main_t *vm, vlib_frame_t *f)
static vlib_frame_size_t * get_frame_size_info(vlib_node_main_t *nm, u32 n_scalar_bytes, u32 n_vector_bytes)
static clib_error_t * vlib_main_configure(vlib_main_t *vm, unformat_input_t *input)
static clib_error_t * elog_write_file(elog_main_t *em, char *unix_file, int flush_ring)
u8 inline_event_data[64-3 *sizeof(u32)-2 *sizeof(u16)]
#define pool_put(P, E)
Free an object E in pool P.
elog_event_type_t * node_return_elog_event_types
u32 polling_threshold_vector_length
u64 * n_vectors_by_next_node
#define VLIB_FRAME_PENDING
static u32 vlib_timing_wheel_data_set_suspended_process(u32 i)
static_always_inline uword vlib_process_resume(vlib_process_t *p)
static u64 dispatch_pending_node(vlib_main_t *vm, uword pending_frame_index, u64 last_time_stamp)
static vlib_frame_t * vlib_get_frame(vlib_main_t *vm, uword frame_index)
u32 node_index
Node index.
uword * init_functions_called
#define VLIB_FRAME_FREE_AFTER_DISPATCH
#define VLIB_ELOG_MAIN_LOOP
void clib_time_init(clib_time_t *c)
void elog_alloc(elog_main_t *em, u32 n_events)
volatile u32 queue_signal_pending
static u64 dispatch_suspended_process(vlib_main_t *vm, uword process_index, u64 last_time_stamp)
#define VLIB_PROCESS_RETURN_LONGJMP_SUSPEND
#define uword_to_pointer(u, type)
timing_wheel_t timing_wheel
static u32 vlib_frame_index_no_check(vlib_main_t *vm, vlib_frame_t *f)
static u32 vlib_frame_alloc_to_node(vlib_main_t *vm, u32 to_node_index, u32 frame_flags)
void vlib_register_all_static_nodes(vlib_main_t *vm)
#define VLIB_EARLY_CONFIG_FUNCTION(x, n,...)
static u32 vlib_node_runtime_update_main_loop_vector_stats(vlib_main_t *vm, vlib_node_runtime_t *node, uword n_vectors)
#define CLIB_PREFETCH(addr, size, type)
static uword elog_n_events_in_buffer(elog_main_t *em)
Return number of events in the event-log buffer.
vlib_pending_frame_t * pending_frames
int vlib_frame_queue_dequeue(vlib_main_t *vm, vlib_frame_queue_main_t *fqm)
#define vec_free(V)
Free vector's memory (no header).
void elog_post_mortem_dump(void)
#define clib_warning(format, args...)
static vlib_node_runtime_t * vlib_node_get_runtime(vlib_main_t *vm, u32 node_index)
Get node runtime by node index.
#define clib_memcpy(a, b, c)
u32 * timing_wheel_advance(timing_wheel_t *w, u64 advance_cpu_time, u32 *expired_user_data, u64 *next_expiring_element_cpu_time)
void vlib_worker_loop(vlib_main_t *vm)
#define VLIB_BUFFER_TRACE_TRAJECTORY
Compile time buffer trajectory tracing option Turn this on if you run into "bad monkey" contexts...
static clib_error_t * elog_show_buffer(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define VLIB_PROCESS_RETURN_LONGJMP_RETURN
static u32 vlib_frame_vector_byte_offset(u32 scalar_size)
void vlib_worker_thread_barrier_sync(vlib_main_t *vm)
#define ELOG_TYPE_DECLARE(f)
static uword round_pow2(uword x, uword pow2)
u32 n_total_events_disable_limit
When count reaches limit logging is disabled.
void vlib_start_process(vlib_main_t *vm, uword process_index)
#define VLIB_CLI_COMMAND(x,...)
#define hash_create(elts, value_bytes)
#define VLIB_PROCESS_IS_SUSPENDED_WAITING_FOR_EVENT
static uword vlib_timing_wheel_data_is_timed_event(u32 d)
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
int vlib_main(vlib_main_t *volatile vm, unformat_input_t *input)
static clib_error_t * show_frame_stats(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static void elog_reset_buffer(elog_main_t *em)
Reset the event buffer.
vlib_frame_queue_main_t * frame_queue_mains
#define ELOG_TRACK_DATA(em, f, track)
uword event_ring_size
Power of 2 number of elements in ring.
#define VLIB_PROCESS_STACK_MAGIC
u32 main_loop_nodes_processed
u64 cpu
CPU cycle counter.
#define VLIB_PROCESS_RESUME_LONGJMP_RESUME
#define clib_error_report(e)
#define VLIB_NODE_FLAG_TRACE
static_always_inline void vlib_main_or_worker_loop(vlib_main_t *vm, int is_main)
void(* queue_signal_callback)(struct vlib_main_t *)
static vlib_main_t * vlib_get_main(void)
static u32 vlib_node_runtime_update_stats(vlib_main_t *vm, vlib_node_runtime_t *node, uword n_calls, uword n_vectors, uword n_clocks)
#define vec_elt(v, i)
Get vector value at index i.
static u32 vlib_frame_bytes(u32 n_scalar_bytes, u32 n_vector_bytes)
static vlib_node_t * vlib_get_next_node(vlib_main_t *vm, u32 node_index, u32 next_index)
Get vlib node by graph arc (next) index.
#define clib_mem_alloc_aligned_no_fail(size, align)
u32 * data_from_advancing_timing_wheel
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
u32 input_node_counts_by_state[VLIB_N_NODE_STATE]
#define VLIB_PENDING_FRAME_NO_NEXT_FRAME
vlib_pending_frame_t * suspended_process_frames
void vlib_buffer_cb_init(struct vlib_main_t *vm)
vlib_node_main_t node_main
vlib_next_frame_t * next_frames
clib_error_t * vlib_call_all_config_functions(vlib_main_t *vm, unformat_input_t *input, int is_early)
#define VLIB_NODE_FLAG_SWITCH_FROM_POLLING_TO_INTERRUPT_MODE
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
clib_error_t * vlib_call_all_init_functions(vlib_main_t *vm)
#define VLIB_PROCESS_IS_SUSPENDED_WAITING_FOR_CLOCK
static void vlib_next_frame_change_ownership(vlib_main_t *vm, vlib_node_runtime_t *node_runtime, u32 next_index)
static void elog_track(elog_main_t *em, elog_event_type_t *type, elog_track_t *track, u32 data)
Log a single-datum event to a specific track, non-inline version.
vlib_frame_size_t * frame_sizes
elog_event_type_t * node_call_elog_event_types
static vlib_process_t * vlib_get_process_from_node(vlib_main_t *vm, vlib_node_t *node)
uword clib_calljmp(uword(*func)(uword func_arg), uword func_arg, void *stack)
void vlib_worker_thread_barrier_release(vlib_main_t *vm)
static void vlib_process_sync_stats(vlib_main_t *vm, vlib_process_t *p, uword n_calls, uword n_vectors, uword n_clocks)
#define VLIB_INVALID_NODE_INDEX
u32 suspended_process_frame_index
static vlib_thread_main_t * vlib_get_thread_main()
#define VLIB_NODE_FLAG_SWITCH_FROM_INTERRUPT_TO_POLLING_MODE
static vlib_node_t * vlib_get_node(vlib_main_t *vm, u32 i)
Get vlib node by index.
static uword vlib_timing_wheel_data_get_index(u32 d)
#define vec_foreach(var, vec)
Vector iterator.
elog_track_t default_track
Default track.
clib_longjmp_t return_longjmp
u16 flags
Copy of main node flags.
u32 n_total_events
Total number of events in buffer.
void vlib_put_frame_to_node(vlib_main_t *vm, u32 to_node_index, vlib_frame_t *f)
clib_longjmp_t main_loop_exit
clib_longjmp_t resume_longjmp
void clib_mem_trace(int enable)
#define CLIB_CACHE_LINE_BYTES
#define VLIB_NODE_FLAG_FRAME_NO_FREE_AFTER_DISPATCH
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
static uword vlib_process_bootstrap(uword _a)
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
clib_random_buffer_t random_buffer
static u32 vlib_frame_alloc(vlib_main_t *vm, vlib_node_runtime_t *from_node_runtime, u32 to_next_index)
u8 *(* validate_frame)(struct vlib_main_t *vm, struct vlib_node_runtime_t *, struct vlib_frame_t *f)
clib_error_t * main_loop_error
elog_event_t * elog_peek_events(elog_main_t *em)
convert event ring events to events, and return them as a vector.
static uword elog_buffer_capacity(elog_main_t *em)
Return number of events which can fit in the event buffer.
u64 cpu_time_last_node_dispatch
clib_error_t * vlib_thread_init(vlib_main_t *vm)
u32 vectors_since_last_overflow
#define VLIB_PROCESS_IS_RUNNING
u32 max_clock_n
Number of vectors in the recorded max_clock.