X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fplugins%2Flacp%2Flacp_api.c;h=dbeb14b3245e730b3693b7d12186387dc89ede34;hb=e5d34919b;hp=ed3ead626c94610ad984661002d2eae18d5d0dca;hpb=f78e87bf82868716ef77bc82d7cd5d60758ebbe6;p=vpp.git diff --git a/src/plugins/lacp/lacp_api.c b/src/plugins/lacp/lacp_api.c index ed3ead626c9..dbeb14b3245 100644 --- a/src/plugins/lacp/lacp_api.c +++ b/src/plugins/lacp/lacp_api.c @@ -27,26 +27,12 @@ /* define message IDs */ -#include +#include +#include +#include -/* define message structures */ -#define vl_typedefs -#include -#undef vl_typedefs - -/* define generated endian-swappers */ -#define vl_endianfun -#include -#undef vl_endianfun - -/* instantiate all the print functions we know about */ #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__) -/* Get the API version number */ -#define vl_api_version(n,v) static u32 api_version=(v); -#include -#undef vl_api_version - /* Macro to finish up custom dump fns */ #define FINISH \ vec_add1 (s, 0); \ @@ -57,9 +43,6 @@ #define REPLY_MSG_ID_BASE lm->msg_id_base #include -#define foreach_lacp_plugin_api_msg \ -_(SW_INTERFACE_LACP_DUMP, sw_interface_lacp_dump) - static void lacp_send_sw_interface_details (vl_api_registration_t * reg, lacp_interface_details_t * lacp_if, @@ -130,74 +113,21 @@ vl_api_sw_interface_lacp_dump_t_handler (vl_api_sw_interface_lacp_dump_t * mp) vec_free (lacpifs); } -static void * -vl_api_sw_interface_lacp_dump_t_print (vl_api_sw_interface_lacp_dump_t * mp, - void *handle) -{ - u8 *s; - - s = format (0, "SCRIPT: sw_interface_lacp_dump "); - - FINISH; -} - -#define vl_msg_name_crc_list -#include -#undef vl_msg_name_crc_list - -static void -setup_message_id_table (lacp_main_t * lm, api_main_t * am) -{ -#define _(id,n,crc) \ - vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id + lm->msg_id_base); - foreach_vl_msg_name_crc_lacp; -#undef _ -} - -static void -plugin_custom_dump_configure (lacp_main_t * lm) -{ -#define _(n,f) api_main.msg_print_handlers \ - [VL_API_##n + lm->msg_id_base] \ - = (void *) vl_api_##f##_t_print; - foreach_lacp_plugin_api_msg; -#undef _ -} - /* Set up the API message handling tables */ +#include clib_error_t * lacp_plugin_api_hookup (vlib_main_t * vm) { lacp_main_t *lm = &lacp_main; - api_main_t *am = &api_main; - u8 *name; - - /* Construct the API name */ - name = format (0, "lacp_%08x%c", api_version, 0); + api_main_t *am = vlibapi_get_main (); /* Ask for a correctly-sized block of API message decode slots */ - lm->msg_id_base = vl_msg_api_get_msg_ids - ((char *) name, VL_MSG_FIRST_AVAILABLE); - -#define _(N,n) \ - vl_msg_api_set_handlers((VL_API_##N + lm->msg_id_base), \ - #n, \ - vl_api_##n##_t_handler, \ - vl_noop_handler, \ - vl_api_##n##_t_endian, \ - vl_api_##n##_t_print, \ - sizeof(vl_api_##n##_t), 1); - foreach_lacp_plugin_api_msg; -#undef _ - - /* - * Set up the (msg_name, crc, message-id) table - */ - setup_message_id_table (lm, am); - - plugin_custom_dump_configure (lm); - - vec_free (name); + lm->msg_id_base = setup_message_id_table (); + + /* Mark these APIs as mp safe */ + am->is_mp_safe[VL_API_SW_INTERFACE_LACP_DUMP] = 1; + am->is_mp_safe[VL_API_SW_INTERFACE_LACP_DETAILS] = 1; + return 0; }