X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvlibapi%2Fapi.h;h=a62fa64493ef56e9b6915e9283b4f63fbfa406f1;hb=b64e4e2af314e1b2bc074b12ede50ad6d96c37c0;hp=970a0ee01573c869bfa26cb30c56b3fe1eada770;hpb=7cd468a3d7dee7d6c92f69a0bb7061ae208ec727;p=vpp.git diff --git a/src/vlibapi/api.h b/src/vlibapi/api.h index 970a0ee0157..a62fa64493e 100644 --- a/src/vlibapi/api.h +++ b/src/vlibapi/api.h @@ -112,6 +112,14 @@ typedef struct u16 last_msg_id; } vl_api_msg_range_t; +typedef clib_error_t *(vl_msg_api_init_function_t) (u32 client_index); + +typedef struct _vl_msg_api_init_function_list_elt +{ + struct _vl_msg_api_init_function_list_elt *next_init_function; + vl_msg_api_init_function_t *f; +} _vl_msg_api_function_list_elt_t; + typedef struct { void (**msg_handlers) (void *); @@ -124,6 +132,7 @@ typedef struct u8 *is_mp_safe; struct ring_alloc_ *arings; u32 ring_misses; + u32 garbage_collects; u32 missing_clients; vl_api_trace_t *rx_trace; vl_api_trace_t *tx_trace; @@ -188,6 +197,13 @@ typedef struct char *region_name; char *root_path; + + /* Replay in progress? */ + int replay_in_progress; + + /* List of API client reaper functions */ + _vl_msg_api_function_list_elt_t *reaper_function_registrations; + } api_main_t; extern api_main_t api_main; @@ -212,7 +228,7 @@ typedef struct msgbuf_ { unix_shared_memory_queue_t *q; u32 data_len; - u32 pad; + u32 gc_mark_timestamp; u8 data[0]; } msgbuf_t; @@ -248,11 +264,13 @@ void vl_msg_api_queue_handler (unix_shared_memory_queue_t * q); vl_api_trace_t *vl_msg_api_trace_get (api_main_t * am, vl_api_trace_which_t which); +void vl_msg_api_barrier_sync (void) __attribute__ ((weak)); +void vl_msg_api_barrier_release (void) __attribute__ ((weak)); void vl_msg_api_free (void *); void vl_noop_handler (void *mp); -clib_error_t *vl_api_init (vlib_main_t * vm); void vl_msg_api_increment_missing_client_counter (void); void vl_msg_api_post_mortem_dump (void); +void vl_msg_api_post_mortem_dump_enable_disable (int enable); void vl_msg_api_register_pd_handler (void *handler, u16 msg_id_host_byte_order); int vl_msg_api_pd_handler (void *mp, int rv); @@ -270,6 +288,53 @@ vlib_node_t **vlib_node_unserialize (u8 * vector); #define VLIB_API_INIT_FUNCTION(x) VLIB_DECLARE_INIT_FUNCTION(x,api_init) +/* Call given init function: used for init function dependencies. */ +#define vlib_call_api_init_function(vm, x) \ + ({ \ + extern vlib_init_function_t * _VLIB_INIT_FUNCTION_SYMBOL (x,api_init); \ + vlib_init_function_t * _f = _VLIB_INIT_FUNCTION_SYMBOL (x,api_init); \ + clib_error_t * _error = 0; \ + if (! hash_get (vm->init_functions_called, _f)) \ + { \ + hash_set1 (vm->init_functions_called, _f); \ + _error = _f (vm); \ + } \ + _error; \ + }) + + +#define _VL_MSG_API_FUNCTION_SYMBOL(x, type) \ + _vl_msg_api_##type##_function_##x + +#define VL_MSG_API_FUNCTION_SYMBOL(x) \ + _VL_MSG_API_FUNCTION_SYMBOL(x, reaper) + +#define VLIB_DECLARE_REAPER_FUNCTION(x, tag) \ +vl_msg_api_init_function_t * _VL_MSG_API_FUNCTION_SYMBOL (x, tag) = x; \ +static void __vl_msg_api_add_##tag##_function_##x (void) \ + __attribute__((__constructor__)) ; \ + \ +static void __vl_msg_api_add_##tag##_function_##x (void) \ +{ \ + api_main_t * am = &api_main; \ + static _vl_msg_api_function_list_elt_t _vl_msg_api_function; \ + _vl_msg_api_function.next_init_function \ + = am->tag##_function_registrations; \ + am->tag##_function_registrations = &_vl_msg_api_function; \ + _vl_msg_api_function.f = &x; \ +} + +#define VL_MSG_API_REAPER_FUNCTION(x) VLIB_DECLARE_REAPER_FUNCTION(x,reaper) + +/* Call reaper function with client index */ +#define vl_msg_api_call_reaper_function(ci) \ + ({ \ + extern vlib_init_function_t * VLIB_INIT_FUNCTION_SYMBOL (reaper); \ + vlib_init_function_t * _f = VLIB_INIT_FUNCTION_SYMBOL (reaper); \ + clib_error_t * _error = 0; \ + _error = _f (ci); \ + }) + #endif /* included_api_h */ /*