45 #ifndef included_vlib_node_funcs_h 46 #define included_vlib_node_funcs_h 125 void *runtime_data,
u32 n_runtime_data_bytes)
178 n->
state = new_state;
179 r->
state = new_state;
230 #define VLIB_FRAME_VECTOR_ALIGN (1 << 4) 270 ASSERT (next_index < n->n_next_nodes);
313 u32 alloc_new_frame);
315 #define vlib_get_next_frame_macro(vm,node,next_index,vectors,n_vectors_left,alloc_new_frame) \ 318 = vlib_get_next_frame_internal ((vm), (node), (next_index), \ 319 (alloc_new_frame)); \ 320 u32 _n = _f->n_vectors; \ 321 (vectors) = vlib_frame_vector_args (_f) + _n * sizeof ((vectors)[0]); \ 322 (n_vectors_left) = VLIB_FRAME_SIZE - _n; \ 338 #define vlib_get_next_frame(vm,node,next_index,vectors,n_vectors_left) \ 339 vlib_get_next_frame_macro (vm, node, next_index, \ 340 vectors, n_vectors_left, \ 343 #define vlib_get_new_next_frame(vm,node,next_index,vectors,n_vectors_left) \ 344 vlib_get_next_frame_macro (vm, node, next_index, \ 345 vectors, n_vectors_left, \ 358 u32 next_index,
u32 n_packets_left);
361 #define vlib_set_next_frame(vm,node,next_index,v) \ 364 vlib_get_next_frame ((vm), (node), (next_index), (v), _n_left); \ 365 ASSERT (_n_left > 0); \ 366 vlib_put_next_frame ((vm), (node), (next_index), _n_left - 1); \ 373 u32 next_index,
u32 buffer_index)
445 uword is_one_time_event)
449 if (is_one_time_event)
464 uword * return_event_type_opaque)
470 void *event_data_vector;
490 *return_event_type_opaque = et->
opaque;
494 return event_data_vector;
551 uword ** data_vector)
572 uword with_type_opaque)
615 uword ** data_vector,
616 uword with_type_index)
639 uword ** data_vector,
640 uword with_type_opaque)
709 et->
opaque = with_type_opaque;
715 uword with_type_opaque)
749 uword p_flags, add_to_pending, delete_from_wheel;
750 void *data_to_be_written_by_caller;
766 _vec_len (data_vec) = 0;
771 data_vec = _vec_resize (data_vec,
774 (l + n_data_elts) * n_data_elt_bytes,
778 data_to_be_written_by_caller = data_vec + l * n_data_elt_bytes;
790 delete_from_wheel = 0;
799 delete_from_wheel = 1;
819 if (delete_from_wheel)
824 return data_to_be_written_by_caller;
924 uword n_data_elt_bytes)
965 .type_opaque = type_opaque,
969 (
u8 *) & args,
sizeof (args));
1047 vi0 = d == 0 ? vi0 : 0;
1048 vi1 = d <= 1 ? vi1 : 0;
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
static void vlib_node_set_runtime_data(vlib_main_t *vm, u32 node_index, void *runtime_data, u32 n_runtime_data_bytes)
Set node runtime private data.
volatile u32 main_loop_count
static void vlib_process_free_event_type(vlib_process_t *p, uword t, uword is_one_time_event)
u32 next_frame_index
Start of next frames for this node.
#define hash_set(h, key, value)
static void vlib_signal_one_time_waiting_process_vector(vlib_main_t *vm, vlib_one_time_waiting_process_t **wps)
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).
static void vlib_signal_one_time_waiting_process(vlib_main_t *vm, vlib_one_time_waiting_process_t *p)
vlib_process_t ** processes
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...
format_function_t format_vlib_node_name
static f64 vlib_node_vectors_per_main_loop_as_float(vlib_main_t *vm, u32 node_index)
vlib_node_runtime_t node_runtime
uword vlib_node_get_next(vlib_main_t *vm, uword node, uword next_node)
void vlib_put_frame_to_node(vlib_main_t *vm, u32 to_node_index, vlib_frame_t *f)
u8 runtime_data[0]
Function dependent node-runtime data.
static uword * vlib_process_wait_for_event(vlib_main_t *vm)
static void vlib_set_next_frame_buffer(vlib_main_t *vm, vlib_node_runtime_t *node, u32 next_index, u32 buffer_index)
static uword vlib_current_process(vlib_main_t *vm)
static void vlib_node_set_interrupt_pending(vlib_main_t *vm, u32 node_index)
#define clib_memcpy_fast(a, b, c)
static uword vlib_node_add_named_next(vlib_main_t *vm, uword node, char *name)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
static f64 vlib_time_now(vlib_main_t *vm)
vlib_node_t * vlib_get_node_by_name(vlib_main_t *vm, u8 *name)
u32 main_loop_vector_stats[2]
void ** pending_event_data_by_type_index
u32 current_process_index
static_always_inline void clib_spinlock_unlock_if_init(clib_spinlock_t *p)
static vlib_frame_t * vlib_get_frame(vlib_main_t *vm, vlib_frame_t *f)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
#define vlib_set_next_frame(vm, node, next_index, v)
void vlib_process_signal_event_mt_helper(vlib_process_signal_event_mt_args_t *args)
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
#define STRUCT_OFFSET_OF(t, f)
void clib_longjmp(clib_longjmp_t *save, uword return_value)
u8 * event_data_as_vector
format_function_t format_vlib_cpu_time
clib_spinlock_t pending_interrupt_lock
#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)
static uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
#define vec_pop(V)
Returns last element of a vector and decrements its length.
static uword vlib_process_suspend_time_is_zero(f64 dt)
Returns TRUE if a process suspend time is less than 10us.
static vlib_process_event_type_t * vlib_process_new_event_type(vlib_process_t *p, uword with_type_opaque)
#define vec_add(V, E, N)
Add N elements to end of vector V (no header, unspecified alignment)
u32 * pending_interrupt_node_runtime_indices
static uword vlib_process_suspend(vlib_main_t *vm, f64 dt)
Suspend a vlib cooperative multi-tasking thread for a period of time.
u32 main_loop_count_last_dispatch
Saved main loop counter of last dispatch of this node.
void vlib_node_rename(vlib_main_t *vm, u32 node_index, char *fmt,...)
#define VLIB_FRAME_NO_APPEND
void ** recycled_event_data_vectors
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...
format_function_t format_vlib_node_and_next
static uword clib_bitmap_is_zero(uword *ai)
predicate function; is an entire bitmap empty?
#define VLIB_LOG2_MAIN_LOOPS_PER_STATS_UPDATE
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
format_function_t format_vlib_next_node_name
#define VLIB_PROCESS_IS_SUSPENDED_WAITING_FOR_CLOCK
#define vec_resize(V, N)
Resize a vector (no header, unspecified alignment) Add N elements to end of given vector V...
void vlib_frame_free(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_frame_t *f)
u32 vlib_process_create(vlib_main_t *vm, char *name, vlib_node_function_t *f, u32 log2_n_stack_bytes)
Create a vlib process.
static void vlib_process_delete_one_time_event(vlib_main_t *vm, uword node_index, uword t)
vlib_node_runtime_t * nodes_by_type[VLIB_N_NODE_TYPE]
int TW() tw_timer_handle_is_free(TWT(tw_timer_wheel) *tw, u32 handle)
static vlib_next_frame_t * vlib_node_runtime_get_next_frame(vlib_main_t *vm, vlib_node_runtime_t *n, u32 next_index)
static vlib_node_state_t vlib_node_get_state(vlib_main_t *vm, u32 node_index)
Get node dispatch state.
clib_error_t * vlib_node_main_init(vlib_main_t *vm)
#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)
u16 state
Input node state.
u32 vlib_register_node(vlib_main_t *vm, vlib_node_registration_t *r)
static void vlib_process_signal_event(vlib_main_t *vm, uword node_index, uword type_opaque, uword data)
vlib_signal_timed_event_data_t * signal_timed_event_data_pool
static uword clib_bitmap_first_set(uword *ai)
Return the lowest numbered set bit in a bitmap.
vlib_error_main_t error_main
#define VLIB_FRAME_IS_ALLOCATED
static void vlib_process_maybe_free_event_type(vlib_process_t *p, uword t)
static void * vlib_process_signal_event_data(vlib_main_t *vm, uword node_index, uword type_opaque, uword n_data_elts, uword n_data_elt_bytes)
static void * vlib_node_get_runtime_data(vlib_main_t *vm, u32 node_index)
Get node runtime private data by node index.
static void vlib_process_signal_one_time_event(vlib_main_t *vm, uword node_index, uword type_index, uword data)
u32 node_index
Node index.
#define VLIB_PROCESS_RESUME_LONGJMP_RESUME
static u32 counter_index(vlib_main_t *vm, vlib_error_t e)
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
#define pool_get_aligned(P, E, A)
Allocate an object E from a pool P with alignment A.
static uword vlib_process_get_events_with_type(vlib_main_t *vm, uword **data_vector, uword with_type_opaque)
#define VLIB_FRAME_VECTOR_ALIGN
static u32 vlib_node_runtime_update_main_loop_vector_stats(vlib_main_t *vm, vlib_node_runtime_t *node, uword n_vectors)
static void vlib_process_signal_event_pointer(vlib_main_t *vm, uword node_index, uword type_opaque, void *data)
u8 inline_event_data[64 - 3 *sizeof(u32) - 2 *sizeof(u16)]
static void * vlib_process_signal_event_at_time(vlib_main_t *vm, f64 dt, uword node_index, uword type_opaque, uword n_data_elts, uword n_data_elt_bytes)
uword vlib_node_add_named_next_with_slot(vlib_main_t *vm, uword node, char *next_name, uword slot)
static_always_inline uword vlib_get_thread_index(void)
static vlib_process_t * vlib_get_current_process(vlib_main_t *vm)
#define VLIB_PROCESS_RESUME_LONGJMP_SUSPEND
static uword vlib_process_wait_for_one_time_event(vlib_main_t *vm, uword **data_vector, uword with_type_index)
sll srl srl sll sra u16x4 i
#define vec_free(V)
Free vector's memory (no header).
static void vlib_process_signal_event_mt(vlib_main_t *vm, uword node_index, uword type_opaque, uword data)
Signal event to process from any thread.
#define VLIB_PROCESS_RESUME_PENDING
static vlib_node_runtime_t * vlib_node_get_runtime(vlib_main_t *vm, u32 node_index)
Get node runtime by node index.
static uword vlib_process_create_one_time_event(vlib_main_t *vm, uword node_index, uword with_type_opaque)
uword vlib_node_add_next_with_slot(vlib_main_t *vm, uword node, uword next_node, uword slot)
static void * vlib_frame_scalar_args(vlib_frame_t *f)
Get pointer to frame scalar data.
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
static u32 vlib_frame_vector_byte_offset(u32 scalar_size)
static uword clib_bitmap_get(uword *ai, uword i)
Gets the ith bit value from a bitmap.
static uword round_pow2(uword x, uword pow2)
vlib_main_t vlib_node_runtime_t * node
uword * one_time_event_type_bitmap
static u32 vlib_node_vectors_per_main_loop_as_integer(vlib_main_t *vm, u32 node_index)
void vlib_start_process(vlib_main_t *vm, uword process_index)
#define pool_put_index(p, i)
Free pool element with given index.
static uword vlib_process_get_events_helper(vlib_process_t *p, uword t, uword **data_vector)
uword() vlib_node_function_t(struct vlib_main_t *vm, struct vlib_node_runtime_t *node, struct vlib_frame_t *frame)
static void vlib_node_set_state(vlib_main_t *vm, u32 node_index, vlib_node_state_t new_state)
Set node dispatch state.
vlib_frame_t * vlib_get_next_frame_internal(vlib_main_t *vm, vlib_node_runtime_t *node, u32 next_index, u32 alloc_new_frame)
static uword is_pow2(uword x)
static void vlib_current_process_wait_for_one_time_event_vector(vlib_main_t *vm, vlib_one_time_waiting_process_t **wps)
#define vec_elt(v, i)
Get vector value at index i.
struct _vlib_node_registration vlib_node_registration_t
void vlib_node_sync_stats(vlib_main_t *vm, vlib_node_t *n)
void vlib_put_next_frame(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, u32 n_packets_left)
Release pointer to next frame vector data.
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.
static void * vlib_process_get_event_data(vlib_main_t *vm, uword *return_event_type_opaque)
vlib_process_event_type_t * event_type_pool
u32 * data_from_advancing_timing_wheel
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
void vlib_rpc_call_main_thread(void *callback, u8 *args, u32 arg_size)
u32 input_node_counts_by_state[VLIB_N_NODE_STATE]
vlib_node_main_t node_main
static uword vlib_process_wait_for_event_with_type(vlib_main_t *vm, uword **data_vector, uword with_type_opaque)
format_function_t format_vlib_time
vlib_next_frame_t * next_frames
static u32 vlib_timing_wheel_data_set_timed_event(u32 i)
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
uword * event_type_index_by_type_opaque
unformat_function_t unformat_vlib_node
u64 resume_clock_interval
static uword vlib_in_process_context(vlib_main_t *vm)
static vlib_process_t * vlib_get_process_from_node(vlib_main_t *vm, vlib_node_t *node)
u32 TW() tw_timer_start(TWT(tw_timer_wheel) *tw, u32 user_id, u32 timer_id, u64 interval)
Start a Tw Timer.
static void vlib_process_put_event_data(vlib_main_t *vm, void *event_data)
void vlib_register_all_static_nodes(vlib_main_t *vm)
static vlib_node_t * vlib_get_node(vlib_main_t *vm, u32 i)
Get vlib node by index.
#define VLIB_PROCESS_IS_SUSPENDED_WAITING_FOR_EVENT
#define vec_foreach(var, vec)
Vector iterator.
clib_longjmp_t return_longjmp
static void vlib_frame_no_append(vlib_frame_t *f)
clib_longjmp_t resume_longjmp
static u32 vlib_timing_wheel_data_set_suspended_process(u32 i)
static_always_inline void clib_spinlock_lock_if_init(clib_spinlock_t *p)
vlib_frame_t * vlib_get_frame_to_node(vlib_main_t *vm, u32 to_node_index)
void TW() tw_timer_stop(TWT(tw_timer_wheel) *tw, u32 handle)
Stop a tw timer.
format_function_t format_vlib_node_graph
static void vlib_current_process_wait_for_one_time_event(vlib_main_t *vm, vlib_one_time_waiting_process_t *p)
uword * non_empty_event_type_bitmap
static void * vlib_process_signal_one_time_event_data(vlib_main_t *vm, uword node_index, uword type_index, uword n_data_elts, uword n_data_elt_bytes)
#define VLIB_PROCESS_RETURN_LONGJMP_SUSPEND
void vlib_node_get_nodes(vlib_main_t *vm, u32 max_threads, int include_stats, int barrier_sync, vlib_node_t ****node_dupsp, vlib_main_t ***stat_vmsp)
Get list of nodes.