45 #ifndef included_vlib_node_funcs_h 46 #define included_vlib_node_funcs_h 125 void *runtime_data,
u32 n_runtime_data_bytes)
177 n->
state = new_state;
178 r->
state = new_state;
253 #define VLIB_FRAME_VECTOR_ALIGN (1 << 4) 296 ASSERT (next_index < n->n_next_nodes);
339 u32 alloc_new_frame);
341 #define vlib_get_next_frame_macro(vm,node,next_index,vectors,n_vectors_left,alloc_new_frame) \ 344 = vlib_get_next_frame_internal ((vm), (node), (next_index), \ 345 (alloc_new_frame)); \ 346 u32 _n = _f->n_vectors; \ 347 (vectors) = vlib_frame_vector_args (_f) + _n * sizeof ((vectors)[0]); \ 348 (n_vectors_left) = VLIB_FRAME_SIZE - _n; \ 364 #define vlib_get_next_frame(vm,node,next_index,vectors,n_vectors_left) \ 365 vlib_get_next_frame_macro (vm, node, next_index, \ 366 vectors, n_vectors_left, \ 369 #define vlib_get_new_next_frame(vm,node,next_index,vectors,n_vectors_left) \ 370 vlib_get_next_frame_macro (vm, node, next_index, \ 371 vectors, n_vectors_left, \ 384 u32 next_index,
u32 n_packets_left);
387 #define vlib_set_next_frame(vm,node,next_index,v) \ 390 vlib_get_next_frame ((vm), (node), (next_index), (v), _n_left); \ 391 ASSERT (_n_left > 0); \ 392 vlib_put_next_frame ((vm), (node), (next_index), _n_left - 1); \ 399 u32 next_index,
u32 buffer_index)
471 uword is_one_time_event)
475 if (is_one_time_event)
490 uword * return_event_type_opaque)
496 void *event_data_vector;
516 *return_event_type_opaque = et->
opaque;
520 return event_data_vector;
577 uword ** data_vector)
598 uword with_type_opaque)
641 uword ** data_vector,
642 uword with_type_index)
665 uword ** data_vector,
666 uword with_type_opaque)
735 et->
opaque = with_type_opaque;
741 uword with_type_opaque)
775 uword p_flags, add_to_pending, delete_from_wheel;
776 void *data_to_be_written_by_caller;
790 _vec_len (data_vec) = 0;
795 data_vec = _vec_resize (data_vec,
798 (l + n_data_elts) * n_data_elt_bytes,
802 data_to_be_written_by_caller = data_vec + l * n_data_elt_bytes;
814 delete_from_wheel = 0;
819 delete_from_wheel = 1;
835 if (delete_from_wheel)
840 return data_to_be_written_by_caller;
940 uword n_data_elt_bytes)
961 uword type_opaque,
void *data)
981 .type_opaque = type_opaque,
985 (
u8 *) & args,
sizeof (args));
1008 memset (p, ~0,
sizeof (p[0]));
1063 vi0 = d == 0 ? vi0 : 0;
1064 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.
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)
sll srl srl sll sra u16x4 i
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)
#define VLIB_FRAME_IS_ALLOCATED
static void vlib_node_set_interrupt_pending(vlib_main_t *vm, u32 node_index)
static u32 vlib_timing_wheel_data_set_timed_event(u32 i)
static uword vlib_node_add_named_next(vlib_main_t *vm, uword node, char *name)
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)
#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)
struct _vlib_node_registration vlib_node_registration_t
#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 VLIB_PROCESS_RESUME_PENDING
#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_frame_t * vlib_get_frame_no_check(vlib_main_t *vm, uword frame_index)
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,...)
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?
static u32 counter_index(vlib_main_t *vm, vlib_error_t e)
#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 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 TW() tw_timer_start(TWT(tw_timer_wheel)*tw, u32 pool_index, u32 timer_id, u64 interval)
Start a Tw Timer.
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]
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
static u32 vlib_frame_index(vlib_main_t *vm, vlib_frame_t *f)
static void vlib_process_maybe_free_event_type(vlib_process_t *p, uword t)
u8 inline_event_data[64-3 *sizeof(u32)-2 *sizeof(u16)]
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)
#define VLIB_PROCESS_RESUME_LONGJMP_SUSPEND
static u32 vlib_timing_wheel_data_set_suspended_process(u32 i)
static vlib_frame_t * vlib_get_frame(vlib_main_t *vm, uword frame_index)
u32 node_index
Node index.
#define VLIB_PROCESS_RETURN_LONGJMP_SUSPEND
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 (general version).
static uword vlib_process_get_events_with_type(vlib_main_t *vm, uword **data_vector, uword with_type_opaque)
static u32 vlib_frame_index_no_check(vlib_main_t *vm, vlib_frame_t *f)
#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)
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)
static uword vlib_process_wait_for_one_time_event(vlib_main_t *vm, uword **data_vector, uword with_type_index)
#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.
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)
static uword vlib_process_create_one_time_event(vlib_main_t *vm, uword node_index, uword with_type_opaque)
void TW() tw_timer_stop(TWT(tw_timer_wheel)*tw, u32 handle)
Stop a tw timer.
uword vlib_node_add_next_with_slot(vlib_main_t *vm, uword node, uword next_node, uword slot)
#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)
uword * one_time_event_type_bitmap
static u32 vlib_node_vectors_per_main_loop_as_integer(vlib_main_t *vm, u32 node_index)
#define VLIB_PROCESS_IS_SUSPENDED_WAITING_FOR_EVENT
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)
#define VLIB_PROCESS_RESUME_LONGJMP_RESUME
static void * vlib_frame_args(vlib_frame_t *f)
Get pointer to frame scalar data.
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.
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 void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
uword * event_type_index_by_type_opaque
#define VLIB_PROCESS_IS_SUSPENDED_WAITING_FOR_CLOCK
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)
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 vec_foreach(var, vec)
Vector iterator.
clib_longjmp_t return_longjmp
clib_longjmp_t resume_longjmp
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)
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)