|
FD.io VPP
v21.10.1-2-g0a485f517
Vector Packet Processing
|
Go to the documentation of this file.
40 #ifndef included_vlib_init_h
41 #define included_vlib_init_h
53 typedef struct _vlib_init_function_list_elt
55 struct _vlib_init_function_list_elt *next_init_function;
61 } _vlib_init_function_list_elt_t;
86 #define VLIB_REMOVE_FROM_LINKED_LIST(first,p,next) \
93 __typeof__ (p) current = first; \
94 while (current->next) \
96 if (current->next == p) \
98 current->next = current->next->next; \
101 current = current->next; \
107 #define _VLIB_INIT_FUNCTION_SYMBOL(x, type) \
108 _vlib_##type##_function_##x
110 #define VLIB_INIT_FUNCTION_SYMBOL(x) \
111 _VLIB_INIT_FUNCTION_SYMBOL(x, init)
112 #define VLIB_MAIN_LOOP_ENTER_FUNCTION_SYMBOL(x) \
113 _VLIB_INIT_FUNCTION_SYMBOL(x, main_loop_enter)
114 #define VLIB_MAIN_LOOP_EXIT_FUNCTION_SYMBOL(x) \
115 _VLIB_INIT_FUNCTION_SYMBOL(x, main_loop_exit)
116 #define VLIB_CONFIG_FUNCTION_SYMBOL(x) \
117 _VLIB_INIT_FUNCTION_SYMBOL(x, config)
122 #ifndef CLIB_MARCH_VARIANT
123 #define VLIB_DECLARE_INIT_FUNCTION(x, tag) \
124 vlib_init_function_t *_VLIB_INIT_FUNCTION_SYMBOL (x, tag) = x; \
125 static void __vlib_add_##tag##_function_##x (void) \
126 __attribute__ ((__constructor__)); \
127 static _vlib_init_function_list_elt_t _vlib_init_function_##tag##_##x; \
128 static void __vlib_add_##tag##_function_##x (void) \
130 vlib_global_main_t *vgm = vlib_get_global_main (); \
131 _vlib_init_function_##tag##_##x.next_init_function = \
132 vgm->tag##_function_registrations; \
133 vgm->tag##_function_registrations = &_vlib_init_function_##tag##_##x; \
134 _vlib_init_function_##tag##_##x.f = &x; \
135 _vlib_init_function_##tag##_##x.name = #x; \
137 static void __vlib_rm_##tag##_function_##x (void) \
138 __attribute__ ((__destructor__)); \
139 static void __vlib_rm_##tag##_function_##x (void) \
141 vlib_global_main_t *vgm = vlib_get_global_main (); \
142 _vlib_init_function_list_elt_t *this, *prev; \
143 this = vgm->tag##_function_registrations; \
148 vgm->tag##_function_registrations = this->next_init_function; \
152 this = this->next_init_function; \
157 prev->next_init_function = this->next_init_function; \
161 this = this->next_init_function; \
164 static _vlib_init_function_list_elt_t _vlib_init_function_##tag##_##x
168 #define VLIB_DECLARE_INIT_FUNCTION(x, tag) \
169 static __clib_unused void * __clib_unused_##tag##_##x = x
172 #define VLIB_INIT_FUNCTION(x) VLIB_DECLARE_INIT_FUNCTION(x,init)
173 #define VLIB_WORKER_INIT_FUNCTION(x) VLIB_DECLARE_INIT_FUNCTION(x,worker_init)
175 #define VLIB_MAIN_LOOP_ENTER_FUNCTION(x) \
176 VLIB_DECLARE_INIT_FUNCTION(x,main_loop_enter)
177 #define VLIB_MAIN_LOOP_EXIT_FUNCTION(x) \
178 VLIB_DECLARE_INIT_FUNCTION(x,main_loop_exit)
180 #ifndef CLIB_MARCH_VARIANT
181 #define VLIB_CONFIG_FUNCTION(x, n, ...) \
182 __VA_ARGS__ vlib_config_function_runtime_t VLIB_CONFIG_FUNCTION_SYMBOL (x); \
183 static void __vlib_add_config_function_##x (void) \
184 __attribute__ ((__constructor__)); \
185 static void __vlib_add_config_function_##x (void) \
187 vlib_global_main_t *vgm = vlib_get_global_main (); \
188 VLIB_CONFIG_FUNCTION_SYMBOL (x).next_registration = \
189 vgm->config_function_registrations; \
190 vgm->config_function_registrations = &VLIB_CONFIG_FUNCTION_SYMBOL (x); \
192 static void __vlib_rm_config_function_##x (void) \
193 __attribute__ ((__destructor__)); \
194 static void __vlib_rm_config_function_##x (void) \
196 vlib_global_main_t *vgm = vlib_get_global_main (); \
197 vlib_config_function_runtime_t *p = &VLIB_CONFIG_FUNCTION_SYMBOL (x); \
198 VLIB_REMOVE_FROM_LINKED_LIST (vgm->config_function_registrations, p, \
199 next_registration); \
201 vlib_config_function_runtime_t VLIB_CONFIG_FUNCTION_SYMBOL (x) = { \
209 #define VLIB_CONFIG_FUNCTION(x,n,...) \
210 static __clib_unused vlib_config_function_runtime_t \
211 VLIB_CONFIG_FUNCTION_SYMBOL (__clib_unused_##x) \
219 #ifndef CLIB_MARCH_VARIANT
220 #define VLIB_EARLY_CONFIG_FUNCTION(x, n, ...) \
221 __VA_ARGS__ vlib_config_function_runtime_t VLIB_CONFIG_FUNCTION_SYMBOL (x); \
222 static void __vlib_add_config_function_##x (void) \
223 __attribute__ ((__constructor__)); \
224 static void __vlib_add_config_function_##x (void) \
226 vlib_global_main_t *vgm = vlib_get_global_main (); \
227 VLIB_CONFIG_FUNCTION_SYMBOL (x).next_registration = \
228 vgm->config_function_registrations; \
229 vgm->config_function_registrations = &VLIB_CONFIG_FUNCTION_SYMBOL (x); \
231 static void __vlib_rm_config_function_##x (void) \
232 __attribute__ ((__destructor__)); \
233 static void __vlib_rm_config_function_##x (void) \
235 vlib_global_main_t *vgm = vlib_get_global_main (); \
236 vlib_config_function_runtime_t *p = &VLIB_CONFIG_FUNCTION_SYMBOL (x); \
237 VLIB_REMOVE_FROM_LINKED_LIST (vgm->config_function_registrations, p, \
238 next_registration); \
240 vlib_config_function_runtime_t VLIB_CONFIG_FUNCTION_SYMBOL (x) = { \
248 #define VLIB_EARLY_CONFIG_FUNCTION(x,n,...) \
249 static __clib_unused vlib_config_function_runtime_t \
250 VLIB_CONFIG_FUNCTION_SYMBOL (__clib_unused_##x) \
259 #define vlib_call_init_function(vm, x) \
261 vlib_global_main_t *vgm = &vlib_global_main; \
262 extern vlib_init_function_t *VLIB_INIT_FUNCTION_SYMBOL (x); \
263 vlib_init_function_t *_f = VLIB_INIT_FUNCTION_SYMBOL (x); \
264 clib_error_t *_error = 0; \
265 if (!hash_get (vgm->init_functions_called, _f)) \
267 hash_set1 (vgm->init_functions_called, _f); \
274 #define vlib_mark_init_function_complete(vm, x) \
276 vlib_global_main_t *vgm = &vlib_global_main; \
277 extern vlib_init_function_t *VLIB_INIT_FUNCTION_SYMBOL (x); \
278 vlib_init_function_t *_f = VLIB_INIT_FUNCTION_SYMBOL (x); \
279 hash_set1 (vgm->init_functions_called, _f); \
282 #define vlib_call_post_graph_init_function(vm, x) \
284 vlib_global_main_t *vgm = &vlib_global_main; \
285 extern vlib_init_function_t *VLIB_POST_GRAPH_INIT_FUNCTION_SYMBOL (x); \
286 vlib_init_function_t *_f = VLIB_POST_GRAPH_INIT_FUNCTION_SYMBOL (x); \
287 clib_error_t *_error = 0; \
288 if (!hash_get (vgm->init_functions_called, _f)) \
290 hash_set1 (vgm->init_functions_called, _f); \
296 #define vlib_call_config_function(vm, x) \
298 vlib_global_main_t *vgm = &vlib_global_main; \
299 vlib_config_function_runtime_t *_r; \
300 clib_error_t *_error = 0; \
301 extern vlib_config_function_runtime_t VLIB_CONFIG_FUNCTION_SYMBOL (x); \
303 _r = &VLIB_CONFIG_FUNCTION_SYMBOL (x); \
304 if (!hash_get (vgm->init_functions_called, _r->function)) \
306 hash_set1 (vgm->init_functions_called, _r->function); \
307 _error = _r->function (vm, &_r->input); \
312 #define vlib_call_main_loop_enter_function(vm, x) \
314 vlib_global_main_t *vgm = &vlib_global_main; \
315 extern vlib_init_function_t *VLIB_MAIN_LOOP_ENTER_FUNCTION_SYMBOL (x); \
316 vlib_init_function_t *_f = VLIB_MAIN_LOOP_ENTER_FUNCTION_SYMBOL (x); \
317 clib_error_t *_error = 0; \
318 if (!hash_get (vgm->init_functions_called, _f)) \
320 hash_set1 (vgm->init_functions_called, _f); \
336 _vlib_init_function_list_elt_t **headp,
340 _vlib_init_function_list_elt_t **headp,
344 #define foreach_vlib_module_reference \
349 #define _(x) void vlib_##x##_reference (void);
352 #define VLIB_INITS(...) (char*[]) { __VA_ARGS__, 0}
clib_error_t * vlib_call_all_main_loop_enter_functions(struct vlib_main_t *vm)
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)
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
#define foreach_vlib_module_reference
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)
clib_error_t * vlib_sort_init_exit_functions(_vlib_init_function_list_elt_t **)
Topological sorter for init function chains.
clib_error_t *() vlib_config_function_t(struct vlib_main_t *vm, unformat_input_t *input)
clib_error_t * vlib_call_all_main_loop_exit_functions(struct vlib_main_t *vm)
struct vlib_config_function_runtime_t vlib_config_function_runtime_t
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
clib_error_t * vlib_call_all_config_functions(struct vlib_main_t *vm, unformat_input_t *input, int is_early)
struct vlib_config_function_runtime_t * next_registration
clib_error_t * vlib_call_all_init_functions(struct vlib_main_t *vm)