|
FD.io VPP
v21.06-3-gbb25fbf28
Vector Packet Processing
|
Go to the documentation of this file.
45 #ifndef included_vlib_node_funcs_h
46 #define included_vlib_node_funcs_h
52 #ifdef CLIB_SANITIZE_ADDR
53 #include <sanitizer/asan_interface.h>
59 #ifdef CLIB_SANITIZE_ADDR
62 __sanitizer_start_switch_fiber (&
vm->asan_stack_save, stack, stack_bytes);
69 #ifdef CLIB_SANITIZE_ADDR
70 const void *bottom_old;
73 __sanitizer_finish_switch_fiber (&
vm->asan_stack_save, &bottom_old,
140 return r->runtime_data;
152 void *runtime_data,
u32 n_runtime_data_bytes)
201 nm->input_node_counts_by_state[n->
state] -= 1;
202 nm->input_node_counts_by_state[new_state] += 1;
209 n->
state = new_state;
210 r->state = new_state;
261 __atomic_store_n (
nm->pending_interrupts, 1, __ATOMIC_RELEASE);
287 #define VLIB_FRAME_VECTOR_ALIGN (1 << 4)
327 ASSERT (next_index < n->n_next_nodes);
370 u32 alloc_new_frame);
372 #define vlib_get_next_frame_macro(vm,node,next_index,vectors,n_vectors_left,alloc_new_frame) \
375 = vlib_get_next_frame_internal ((vm), (node), (next_index), \
376 (alloc_new_frame)); \
377 u32 _n = _f->n_vectors; \
378 (vectors) = vlib_frame_vector_args (_f) + _n * sizeof ((vectors)[0]); \
379 (n_vectors_left) = VLIB_FRAME_SIZE - _n; \
395 #define vlib_get_next_frame(vm,node,next_index,vectors,n_vectors_left) \
396 vlib_get_next_frame_macro (vm, node, next_index, \
397 vectors, n_vectors_left, \
400 #define vlib_get_new_next_frame(vm,node,next_index,vectors,n_vectors_left) \
401 vlib_get_next_frame_macro (vm, node, next_index, \
402 vectors, n_vectors_left, \
418 #define vlib_set_next_frame(vm,node,next_index,v) \
421 vlib_get_next_frame ((vm), (node), (next_index), (v), _n_left); \
422 ASSERT (_n_left > 0); \
423 vlib_put_next_frame ((vm), (node), (next_index), _n_left - 1); \
452 return vec_elt (
nm->processes,
nm->current_process_index);
512 uword is_one_time_event)
516 if (is_one_time_event)
531 uword * return_event_type_opaque)
537 void *event_data_vector;
539 p =
vec_elt (
nm->processes,
nm->current_process_index);
557 *return_event_type_opaque = et->
opaque;
561 return event_data_vector;
570 vec_add1 (
nm->recycled_event_data_vectors, event_data);
590 p =
vec_elt (
nm->processes,
nm->current_process_index);
618 uword ** data_vector)
639 uword with_type_opaque)
645 p =
vec_elt (
nm->processes,
nm->current_process_index);
666 p =
vec_elt (
nm->processes,
nm->current_process_index);
687 uword ** data_vector,
688 uword with_type_index)
694 p =
vec_elt (
nm->processes,
nm->current_process_index);
716 uword ** data_vector,
717 uword with_type_opaque)
723 p =
vec_elt (
nm->processes,
nm->current_process_index);
762 p =
vec_elt (
nm->processes,
nm->current_process_index);
794 et->
opaque = with_type_opaque;
800 uword with_type_opaque)
834 uword p_flags, add_to_pending, delete_from_wheel;
835 void *data_to_be_written_by_caller;
848 if (!data_vec &&
vec_len (
nm->recycled_event_data_vectors))
850 data_vec =
vec_pop (
nm->recycled_event_data_vectors);
851 _vec_len (data_vec) = 0;
856 data_vec = _vec_resize (data_vec,
859 (l + n_data_elts) * n_data_elt_bytes,
863 data_to_be_written_by_caller = data_vec + l * n_data_elt_bytes;
875 delete_from_wheel = 0;
882 ((
TWT (tw_timer_wheel) *)
nm->timing_wheel,
884 delete_from_wheel = 1;
903 vec_add1 (
nm->data_from_advancing_timing_wheel, x);
904 if (delete_from_wheel)
909 return data_to_be_written_by_caller;
988 (te -
nm->signal_timed_event_data_pool),
1009 uword n_data_elt_bytes)
1023 1 ,
sizeof (
uword));
1050 .type_opaque = type_opaque,
1054 (
u8 *) & args,
sizeof (args));
1067 1 ,
sizeof (
uword));
1128 (
node->main_loop_count_last_dispatch >>
1130 vi0 =
node->main_loop_vector_stats[i0];
1131 vi1 =
node->main_loop_vector_stats[i1];
1132 vi0 = d == 0 ? vi0 : 0;
1133 vi1 = d <= 1 ? vi1 : 0;
1135 node->main_loop_vector_stats[i0] = vi0;
1136 node->main_loop_vector_stats[i1] = vi1;
1139 return node->main_loop_vector_stats[i1];
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_frame_t * vlib_get_frame(vlib_main_t *vm, vlib_frame_t *f)
format_function_t format_vlib_node_graph
u32 current_process_index
static uword vlib_in_process_context(vlib_main_t *vm)
void vlib_process_signal_event_mt_helper(vlib_process_signal_event_mt_args_t *args)
struct _vlib_node_fn_registration vlib_node_fn_registration_t
#define VLIB_PROCESS_RESUME_PENDING
void vlib_register_all_static_nodes(vlib_main_t *vm)
void vlib_put_frame_to_node(vlib_main_t *vm, u32 to_node_index, vlib_frame_t *f)
#define vec_add(V, E, N)
Add N elements to end of vector V (no header, unspecified alignment)
uword * non_empty_event_type_bitmap
static void * vlib_node_get_runtime_data(vlib_main_t *vm, u32 node_index)
Get node runtime private data by node index.
volatile u32 main_loop_count
static uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
void vlib_start_process(vlib_main_t *vm, uword process_index)
static vlib_process_event_type_t * vlib_process_new_event_type(vlib_process_t *p, uword with_type_opaque)
nat44_ei_hairpin_src_next_t next_index
__clib_export void TW() tw_timer_stop(TWT(tw_timer_wheel) *tw, u32 handle)
Stop a tw timer.
uword vlib_node_get_next(vlib_main_t *vm, uword node, uword next_node)
static_always_inline void vlib_process_finish_switch_stack(vlib_main_t *vm)
static uword * vlib_process_wait_for_event(vlib_main_t *vm)
static void vlib_node_set_state(vlib_main_t *vm, u32 node_index, vlib_node_state_t new_state)
Set node dispatch state.
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
static uword vlib_process_get_events_with_type(vlib_main_t *vm, uword **data_vector, uword with_type_opaque)
vlib_frame_t * vlib_get_next_frame_internal(vlib_main_t *vm, vlib_node_runtime_t *node, u32 next_index, u32 alloc_new_frame)
#define pool_get_aligned(P, E, A)
Allocate an object E from a pool P with alignment A.
int vlib_node_set_march_variant(vlib_main_t *vm, u32 node_index, clib_march_variant_type_t march_variant)
vlib_node_function_t * dispatch_wrapper_fn
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.
vlib_main_t vlib_node_runtime_t * node
static uword clib_bitmap_first_set(uword *ai)
Return the lowest numbered set bit in a bitmap.
format_function_t format_vlib_cpu_time
static u32 vlib_node_runtime_update_main_loop_vector_stats(vlib_main_t *vm, vlib_node_runtime_t *node, uword n_vectors)
void vlib_node_runtime_sync_stats_node(vlib_node_t *n, vlib_node_runtime_t *r, uword n_calls, uword n_vectors, uword n_clocks)
uword clib_setjmp(clib_longjmp_t *save, uword return_value_not_taken)
static uword vlib_process_create_one_time_event(vlib_main_t *vm, uword node_index, uword with_type_opaque)
#define VLIB_PROCESS_RESUME_LONGJMP_RESUME
vlib_error_main_t error_main
vlib_node_main_t node_main
static void vlib_signal_one_time_waiting_process(vlib_main_t *vm, vlib_one_time_waiting_process_t *p)
u32 next_frame_index
Start of next frames for this node.
static uword vlib_process_wait_for_event_with_type(vlib_main_t *vm, uword **data_vector, uword with_type_opaque)
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
static u32 counter_index(vlib_main_t *vm, vlib_error_t e)
vlib_node_runtime_t node_runtime
static u32 vlib_node_vectors_per_main_loop_as_integer(vlib_main_t *vm, u32 node_index)
static_always_inline void clib_interrupt_set_atomic(void *in, int int_num)
static uword vlib_current_process(vlib_main_t *vm)
clib_error_t * vlib_node_main_init(vlib_main_t *vm)
u8 inline_event_data[64 - 3 *sizeof(u32) - 2 *sizeof(u16)]
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)
uword() vlib_node_function_t(struct vlib_main_t *vm, struct vlib_node_runtime_t *node, struct vlib_frame_t *frame)
vnet_hw_if_output_node_runtime_t * r
@ VLIB_NODE_RUNTIME_PERF_RESET
u32 vlib_register_node(vlib_main_t *vm, vlib_node_registration_t *r)
#define VLIB_PROCESS_RETURN_LONGJMP_SUSPEND
static void vlib_process_signal_event(vlib_main_t *vm, uword node_index, uword type_opaque, uword data)
static_always_inline void * clib_memcpy_fast(void *restrict dst, const void *restrict src, size_t n)
#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_set_next_frame(vm, node, next_index, v)
static void vlib_frame_no_append(vlib_frame_t *f)
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
#define vec_elt(v, i)
Get vector value at index i.
#define hash_set(h, key, value)
void clib_longjmp(clib_longjmp_t *save, uword return_value)
static uword round_pow2(uword x, uword pow2)
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,...
#define STRUCT_OFFSET_OF(t, f)
static vnet_feature_upd_registration_t * regs
format_function_t format_vlib_node_and_next
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
static u32 vlib_get_current_process_node_index(vlib_main_t *vm)
#define VLIB_PROCESS_RESUME_LONGJMP_SUSPEND
static uword clib_bitmap_get(uword *ai, uword i)
Gets the ith bit value from a bitmap.
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
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 vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
static void * vlib_process_get_event_data(vlib_main_t *vm, uword *return_event_type_opaque)
static void vlib_process_signal_event_pointer(vlib_main_t *vm, uword node_index, uword type_opaque, void *data)
format_function_t format_vlib_time
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
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.
static void vlib_process_maybe_free_event_type(vlib_process_t *p, uword t)
static_always_inline uword vlib_get_thread_index(void)
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.
unformat_function_t unformat_vlib_node
static void vlib_signal_one_time_waiting_process_vector(vlib_main_t *vm, vlib_one_time_waiting_process_t **wps)
#define static_always_inline
static vlib_process_t * vlib_get_process_from_node(vlib_main_t *vm, vlib_node_t *node)
#define VLIB_FRAME_IS_ALLOCATED
static u32 vlib_timing_wheel_data_set_suspended_process(u32 i)
static u32 vlib_frame_vector_byte_offset(u32 scalar_size)
static_always_inline void clib_interrupt_set(void *in, int int_num)
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
static vlib_node_t * vlib_get_node(vlib_main_t *vm, u32 i)
Get vlib node by index.
sll srl srl sll sra u16x4 i
static void vlib_node_set_flag(vlib_main_t *vm, u32 node_index, u16 flag, u8 enable)
format_function_t format_vlib_next_node_name
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_always_inline void vlib_process_start_switch_stack(vlib_main_t *vm, vlib_process_t *p)
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment)
vlib_node_t * vlib_get_node_by_name(vlib_main_t *vm, u8 *name)
#define vec_pop(V)
Returns last element of a vector and decrements its length.
struct _vlib_node_registration vlib_node_registration_t
static void vlib_current_process_wait_for_one_time_event(vlib_main_t *vm, vlib_one_time_waiting_process_t *p)
static void * vlib_frame_scalar_args(vlib_frame_t *f)
Get pointer to frame scalar data.
static int vlib_node_set_dispatch_wrapper(vlib_main_t *vm, vlib_node_function_t *fn)
vlib_node_function_t * vlib_node_get_preferred_node_fn_variant(vlib_main_t *vm, vlib_node_fn_registration_t *regs)
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.
#define vec_free(V)
Free vector's memory (no header).
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.
__clib_export u32 TW() tw_timer_start(TWT(tw_timer_wheel) *tw, u32 user_id, u32 timer_id, u64 interval)
Start a Tw Timer.
format_function_t format_vlib_node_name
static f64 vlib_node_vectors_per_main_loop_as_float(vlib_main_t *vm, u32 node_index)
uword vlib_node_add_next_with_slot(vlib_main_t *vm, uword node, uword next_node, uword slot)
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).
clib_march_variant_type_t
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...
#define VLIB_PROCESS_IS_SUSPENDED_WAITING_FOR_EVENT
#define VLIB_THREAD_STACK_SIZE
static uword vlib_process_suspend(vlib_main_t *vm, f64 dt)
Suspend a vlib cooperative multi-tasking thread for a period of time.
static void vlib_set_next_frame_buffer(vlib_main_t *vm, vlib_node_runtime_t *node, u32 next_index, u32 buffer_index)
uword * one_time_event_type_bitmap
static void vlib_node_set_interrupt_pending(vlib_main_t *vm, u32 node_index)
#define VLIB_FRAME_NO_APPEND
static void vlib_process_put_event_data(vlib_main_t *vm, void *event_data)
static vlib_process_t * vlib_get_current_process(vlib_main_t *vm)
#define vec_foreach(var, vec)
Vector iterator.
u8 * event_data_as_vector
static uword vlib_node_add_named_next(vlib_main_t *vm, uword node, char *name)
static uword vlib_process_wait_for_one_time_event(vlib_main_t *vm, uword **data_vector, uword with_type_index)
#define VLIB_PROCESS_IS_SUSPENDED_WAITING_FOR_CLOCK
void vlib_rpc_call_main_thread(void *callback, u8 *args, u32 arg_size)
vlib_process_event_type_t * event_type_pool
__clib_export int TW() tw_timer_handle_is_free(TWT(tw_timer_wheel) *tw, u32 handle)
static vlib_node_runtime_t * vlib_node_get_runtime(vlib_main_t *vm, u32 node_index)
Get node runtime by node index.
#define vec_resize(V, N)
Resize a vector (no header, unspecified alignment) Add N elements to end of given vector V,...
static void vlib_process_delete_one_time_event(vlib_main_t *vm, uword node_index, uword t)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
static void vlib_current_process_wait_for_one_time_event_vector(vlib_main_t *vm, vlib_one_time_waiting_process_t **wps)
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 vlib_main_t * vlib_get_main(void)
vnet_interface_output_runtime_t * rt
u64 resume_clock_interval
static uword vlib_process_suspend_time_is_zero(f64 dt)
Returns TRUE if a process suspend time is less than 10us.
clib_longjmp_t resume_longjmp
static void vlib_process_free_event_type(vlib_process_t *p, uword t, uword is_one_time_event)
void vlib_node_rename(vlib_main_t *vm, u32 node_index, char *fmt,...)
static f64 vlib_time_now(vlib_main_t *vm)
uword * event_type_index_by_type_opaque
static uword is_pow2(uword x)
clib_longjmp_t return_longjmp
#define VLIB_LOG2_MAIN_LOOPS_PER_STATS_UPDATE
void vlib_register_all_node_march_variants(vlib_main_t *vm)
#define VLIB_FRAME_VECTOR_ALIGN
static uword clib_bitmap_is_zero(uword *ai)
predicate function; is an entire bitmap empty?
static vlib_next_frame_t * vlib_node_runtime_get_next_frame(vlib_main_t *vm, vlib_node_runtime_t *n, u32 next_index)
static void vlib_node_runtime_perf_counter(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, uword n, u64 t, vlib_node_runtime_perf_call_type_t call_type)
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.
void ** pending_event_data_by_type_index
static vlib_node_state_t vlib_node_get_state(vlib_main_t *vm, u32 node_index)
Get node dispatch state.
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)
vlib_frame_t * vlib_get_frame_to_node(vlib_main_t *vm, u32 to_node_index)