FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
init.h File Reference
+ Include dependency graph for init.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  vlib_config_function_runtime_t
 

Macros

#define VLIB_REMOVE_FROM_LINKED_LIST(first, p, next)
 
#define VLIB_INIT_FUNCTION_SYMBOL(x)   _VLIB_INIT_FUNCTION_SYMBOL(x, init)
 
#define VLIB_MAIN_LOOP_ENTER_FUNCTION_SYMBOL(x)   _VLIB_INIT_FUNCTION_SYMBOL(x, main_loop_enter)
 
#define VLIB_MAIN_LOOP_EXIT_FUNCTION_SYMBOL(x)   _VLIB_INIT_FUNCTION_SYMBOL(x, main_loop_exit)
 
#define VLIB_CONFIG_FUNCTION_SYMBOL(x)   _VLIB_INIT_FUNCTION_SYMBOL(x, config)
 
#define VLIB_DECLARE_INIT_FUNCTION(x, tag)
 
#define VLIB_INIT_FUNCTION(x)   VLIB_DECLARE_INIT_FUNCTION(x,init)
 
#define VLIB_WORKER_INIT_FUNCTION(x)   VLIB_DECLARE_INIT_FUNCTION(x,worker_init)
 
#define VLIB_MAIN_LOOP_ENTER_FUNCTION(x)   VLIB_DECLARE_INIT_FUNCTION(x,main_loop_enter)
 
#define VLIB_MAIN_LOOP_EXIT_FUNCTION(x)   VLIB_DECLARE_INIT_FUNCTION(x,main_loop_exit)
 
#define VLIB_CONFIG_FUNCTION(x, n, ...)
 
#define VLIB_EARLY_CONFIG_FUNCTION(x, n, ...)
 
#define vlib_call_init_function(vm, x)
 
#define vlib_mark_init_function_complete(vm, x)
 
#define vlib_call_post_graph_init_function(vm, x)
 
#define vlib_call_config_function(vm, x)
 
#define vlib_call_main_loop_enter_function(vm, x)
 
#define foreach_vlib_module_reference
 
#define VLIB_INITS(...)   (char*[]) { __VA_ARGS__, 0}
 

Typedefs

typedef clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
 
typedef clib_error_t *() vlib_config_function_t(struct vlib_main_t *vm, unformat_input_t *input)
 
typedef struct vlib_config_function_runtime_t vlib_config_function_runtime_t
 

Functions

clib_error_tvlib_call_all_init_functions (struct vlib_main_t *vm)
 
clib_error_tvlib_call_all_config_functions (struct vlib_main_t *vm, unformat_input_t *input, int is_early)
 
clib_error_tvlib_call_all_main_loop_enter_functions (struct vlib_main_t *vm)
 
clib_error_tvlib_call_all_main_loop_exit_functions (struct vlib_main_t *vm)
 
clib_error_tvlib_call_init_exit_functions (struct vlib_main_t *vm, _vlib_init_function_list_elt_t **headp, int call_once, int is_global)
 
clib_error_tvlib_call_init_exit_functions_no_sort (struct vlib_main_t *vm, _vlib_init_function_list_elt_t **headp, int call_once, int is_global)
 
clib_error_tvlib_sort_init_exit_functions (_vlib_init_function_list_elt_t **)
 Topological sorter for init function chains. More...
 

Macro Definition Documentation

◆ foreach_vlib_module_reference

#define foreach_vlib_module_reference
Value:
_ (node_cli) \
_ (trace_cli)

Definition at line 344 of file init.h.

◆ vlib_call_config_function

#define vlib_call_config_function (   vm,
 
)
Value:
({ \
vlib_global_main_t *vgm = &vlib_global_main; \
vlib_config_function_runtime_t *_r; \
clib_error_t *_error = 0; \
\
if (!hash_get (vgm->init_functions_called, _r->function)) \
{ \
hash_set1 (vgm->init_functions_called, _r->function); \
_error = _r->function (vm, &_r->input); \
} \
_error; \
})

Definition at line 296 of file init.h.

◆ vlib_call_init_function

#define vlib_call_init_function (   vm,
 
)
Value:
({ \
vlib_global_main_t *vgm = &vlib_global_main; \
vlib_init_function_t *_f = VLIB_INIT_FUNCTION_SYMBOL (x); \
clib_error_t *_error = 0; \
if (!hash_get (vgm->init_functions_called, _f)) \
{ \
hash_set1 (vgm->init_functions_called, _f); \
_error = _f (vm); \
} \
_error; \
})

Definition at line 259 of file init.h.

◆ vlib_call_main_loop_enter_function

#define vlib_call_main_loop_enter_function (   vm,
 
)
Value:
({ \
vlib_global_main_t *vgm = &vlib_global_main; \
vlib_init_function_t *_f = VLIB_MAIN_LOOP_ENTER_FUNCTION_SYMBOL (x); \
clib_error_t *_error = 0; \
if (!hash_get (vgm->init_functions_called, _f)) \
{ \
hash_set1 (vgm->init_functions_called, _f); \
_error = _f (vm); \
} \
_error; \
})

Definition at line 312 of file init.h.

◆ vlib_call_post_graph_init_function

#define vlib_call_post_graph_init_function (   vm,
 
)
Value:
({ \
vlib_global_main_t *vgm = &vlib_global_main; \
extern vlib_init_function_t *VLIB_POST_GRAPH_INIT_FUNCTION_SYMBOL (x); \
vlib_init_function_t *_f = VLIB_POST_GRAPH_INIT_FUNCTION_SYMBOL (x); \
clib_error_t *_error = 0; \
if (!hash_get (vgm->init_functions_called, _f)) \
{ \
hash_set1 (vgm->init_functions_called, _f); \
_error = _f (vm); \
} \
_error; \
})

Definition at line 282 of file init.h.

◆ VLIB_CONFIG_FUNCTION

#define VLIB_CONFIG_FUNCTION (   x,
  n,
  ... 
)
Value:
static void __vlib_add_config_function_##x (void) \
__attribute__ ((__constructor__)); \
static void __vlib_add_config_function_##x (void) \
{ \
vlib_global_main_t *vgm = vlib_get_global_main (); \
VLIB_CONFIG_FUNCTION_SYMBOL (x).next_registration = \
vgm->config_function_registrations; \
vgm->config_function_registrations = &VLIB_CONFIG_FUNCTION_SYMBOL (x); \
} \
static void __vlib_rm_config_function_##x (void) \
__attribute__ ((__destructor__)); \
static void __vlib_rm_config_function_##x (void) \
{ \
vlib_global_main_t *vgm = vlib_get_global_main (); \
vlib_config_function_runtime_t *p = &VLIB_CONFIG_FUNCTION_SYMBOL (x); \
VLIB_REMOVE_FROM_LINKED_LIST (vgm->config_function_registrations, p, \
next_registration); \
} \
vlib_config_function_runtime_t VLIB_CONFIG_FUNCTION_SYMBOL (x) = { \
.name = n, \
.function = x, \
.is_early = 0, \
}

Definition at line 181 of file init.h.

◆ VLIB_CONFIG_FUNCTION_SYMBOL

#define VLIB_CONFIG_FUNCTION_SYMBOL (   x)    _VLIB_INIT_FUNCTION_SYMBOL(x, config)

Definition at line 116 of file init.h.

◆ VLIB_DECLARE_INIT_FUNCTION

#define VLIB_DECLARE_INIT_FUNCTION (   x,
  tag 
)
Value:
vlib_init_function_t *_VLIB_INIT_FUNCTION_SYMBOL (x, tag) = x; \
static void __vlib_add_##tag##_function_##x (void) \
__attribute__ ((__constructor__)); \
static _vlib_init_function_list_elt_t _vlib_init_function_##tag##_##x; \
static void __vlib_add_##tag##_function_##x (void) \
{ \
vlib_global_main_t *vgm = vlib_get_global_main (); \
_vlib_init_function_##tag##_##x.next_init_function = \
vgm->tag##_function_registrations; \
vgm->tag##_function_registrations = &_vlib_init_function_##tag##_##x; \
_vlib_init_function_##tag##_##x.f = &x; \
_vlib_init_function_##tag##_##x.name = #x; \
} \
static void __vlib_rm_##tag##_function_##x (void) \
__attribute__ ((__destructor__)); \
static void __vlib_rm_##tag##_function_##x (void) \
{ \
vlib_global_main_t *vgm = vlib_get_global_main (); \
_vlib_init_function_list_elt_t *this, *prev; \
this = vgm->tag##_function_registrations; \
if (this == 0) \
return; \
if (this->f == &x) \
{ \
vgm->tag##_function_registrations = this->next_init_function; \
return; \
} \
prev = this; \
this = this->next_init_function; \
while (this) \
{ \
if (this->f == &x) \
{ \
prev->next_init_function = this->next_init_function; \
return; \
} \
prev = this; \
this = this->next_init_function; \
} \
} \
static _vlib_init_function_list_elt_t _vlib_init_function_##tag##_##x

Definition at line 123 of file init.h.

◆ VLIB_EARLY_CONFIG_FUNCTION

#define VLIB_EARLY_CONFIG_FUNCTION (   x,
  n,
  ... 
)
Value:
static void __vlib_add_config_function_##x (void) \
__attribute__ ((__constructor__)); \
static void __vlib_add_config_function_##x (void) \
{ \
vlib_global_main_t *vgm = vlib_get_global_main (); \
VLIB_CONFIG_FUNCTION_SYMBOL (x).next_registration = \
vgm->config_function_registrations; \
vgm->config_function_registrations = &VLIB_CONFIG_FUNCTION_SYMBOL (x); \
} \
static void __vlib_rm_config_function_##x (void) \
__attribute__ ((__destructor__)); \
static void __vlib_rm_config_function_##x (void) \
{ \
vlib_global_main_t *vgm = vlib_get_global_main (); \
vlib_config_function_runtime_t *p = &VLIB_CONFIG_FUNCTION_SYMBOL (x); \
VLIB_REMOVE_FROM_LINKED_LIST (vgm->config_function_registrations, p, \
next_registration); \
} \
vlib_config_function_runtime_t VLIB_CONFIG_FUNCTION_SYMBOL (x) = { \
.name = n, \
.function = x, \
.is_early = 1, \
}

Definition at line 220 of file init.h.

◆ VLIB_INIT_FUNCTION

#define VLIB_INIT_FUNCTION (   x)    VLIB_DECLARE_INIT_FUNCTION(x,init)

Definition at line 172 of file init.h.

◆ VLIB_INIT_FUNCTION_SYMBOL

#define VLIB_INIT_FUNCTION_SYMBOL (   x)    _VLIB_INIT_FUNCTION_SYMBOL(x, init)

Definition at line 110 of file init.h.

◆ VLIB_INITS

#define VLIB_INITS (   ...)    (char*[]) { __VA_ARGS__, 0}

Definition at line 352 of file init.h.

◆ VLIB_MAIN_LOOP_ENTER_FUNCTION

#define VLIB_MAIN_LOOP_ENTER_FUNCTION (   x)    VLIB_DECLARE_INIT_FUNCTION(x,main_loop_enter)

Definition at line 175 of file init.h.

◆ VLIB_MAIN_LOOP_ENTER_FUNCTION_SYMBOL

#define VLIB_MAIN_LOOP_ENTER_FUNCTION_SYMBOL (   x)    _VLIB_INIT_FUNCTION_SYMBOL(x, main_loop_enter)

Definition at line 112 of file init.h.

◆ VLIB_MAIN_LOOP_EXIT_FUNCTION

#define VLIB_MAIN_LOOP_EXIT_FUNCTION (   x)    VLIB_DECLARE_INIT_FUNCTION(x,main_loop_exit)

Definition at line 177 of file init.h.

◆ VLIB_MAIN_LOOP_EXIT_FUNCTION_SYMBOL

#define VLIB_MAIN_LOOP_EXIT_FUNCTION_SYMBOL (   x)    _VLIB_INIT_FUNCTION_SYMBOL(x, main_loop_exit)

Definition at line 114 of file init.h.

◆ vlib_mark_init_function_complete

#define vlib_mark_init_function_complete (   vm,
 
)
Value:
({ \
vlib_global_main_t *vgm = &vlib_global_main; \
vlib_init_function_t *_f = VLIB_INIT_FUNCTION_SYMBOL (x); \
hash_set1 (vgm->init_functions_called, _f); \
})

Definition at line 274 of file init.h.

◆ VLIB_REMOVE_FROM_LINKED_LIST

#define VLIB_REMOVE_FROM_LINKED_LIST (   first,
  p,
  next 
)
Value:
{ \
ASSERT (first); \
if (first == p) \
first = (p)->next; \
else \
{ \
__typeof__ (p) current = first; \
while (current->next) \
{ \
if (current->next == p) \
{ \
current->next = current->next->next; \
break; \
} \
current = current->next; \
} \
ASSERT (current); \
} \
}

Definition at line 86 of file init.h.

◆ VLIB_WORKER_INIT_FUNCTION

#define VLIB_WORKER_INIT_FUNCTION (   x)    VLIB_DECLARE_INIT_FUNCTION(x,worker_init)

Definition at line 173 of file init.h.

Typedef Documentation

◆ vlib_config_function_runtime_t

◆ vlib_config_function_t

typedef clib_error_t*() vlib_config_function_t(struct vlib_main_t *vm, unformat_input_t *input)

Definition at line 65 of file init.h.

◆ vlib_init_function_t

typedef clib_error_t*() vlib_init_function_t(struct vlib_main_t *vm)

Definition at line 51 of file init.h.

Function Documentation

◆ vlib_call_all_config_functions()

clib_error_t* vlib_call_all_config_functions ( struct vlib_main_t vm,
unformat_input_t input,
int  is_early 
)

Definition at line 423 of file init.c.

+ Here is the caller graph for this function:

◆ vlib_call_all_init_functions()

clib_error_t* vlib_call_all_init_functions ( struct vlib_main_t vm)

Definition at line 391 of file init.c.

+ Here is the caller graph for this function:

◆ vlib_call_all_main_loop_enter_functions()

clib_error_t* vlib_call_all_main_loop_enter_functions ( struct vlib_main_t vm)

Definition at line 405 of file init.c.

◆ vlib_call_all_main_loop_exit_functions()

clib_error_t* vlib_call_all_main_loop_exit_functions ( struct vlib_main_t vm)

Definition at line 414 of file init.c.

◆ vlib_call_init_exit_functions()

clib_error_t* vlib_call_init_exit_functions ( struct vlib_main_t vm,
_vlib_init_function_list_elt_t **  headp,
int  call_once,
int  is_global 
)

Definition at line 373 of file init.c.

+ Here is the caller graph for this function:

◆ vlib_call_init_exit_functions_no_sort()

clib_error_t* vlib_call_init_exit_functions_no_sort ( struct vlib_main_t vm,
_vlib_init_function_list_elt_t **  headp,
int  call_once,
int  is_global 
)

Definition at line 382 of file init.c.

+ Here is the caller graph for this function:

◆ vlib_sort_init_exit_functions()

clib_error_t* vlib_sort_init_exit_functions ( _vlib_init_function_list_elt_t **  head)

Topological sorter for init function chains.

Parameters
head[in/out] address of the listhead to be sorted
Returns
0 on success, otherwise a clib_error_t *.

Definition at line 76 of file init.c.

+ Here is the call graph for this function:
VLIB_MAIN_LOOP_ENTER_FUNCTION_SYMBOL
#define VLIB_MAIN_LOOP_ENTER_FUNCTION_SYMBOL(x)
Definition: init.h:112
VLIB_INIT_FUNCTION_SYMBOL
#define VLIB_INIT_FUNCTION_SYMBOL(x)
Definition: init.h:110
f
vlib_frame_t * f
Definition: interface_output.c:1098
next
u16 * next
Definition: nat44_ei_out2in.c:718
first
static heap_elt_t * first(heap_header_t *h)
Definition: heap.c:59
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
vlib_get_global_main
static vlib_global_main_t * vlib_get_global_main(void)
Definition: global_funcs.h:50
VLIB_CONFIG_FUNCTION_SYMBOL
#define VLIB_CONFIG_FUNCTION_SYMBOL(x)
Definition: init.h:116
hash_get
#define hash_get(h, key)
Definition: hash.h:249
vlib_config_function_runtime_t
Definition: init.h:68
vlib_global_main
vlib_global_main_t vlib_global_main
Definition: main.c:1786
heap_elt_t::next
i32 next
Definition: heap.h:78
vlib_init_function_t
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
Definition: init.h:51