diff options
-rw-r--r-- | src/plugins/hs_apps/sapi/vpp_echo_bapi.c | 17 | ||||
-rw-r--r-- | src/plugins/tracedump/tracedump_test.c | 18 | ||||
-rw-r--r-- | src/tools/vppapigen/vppapigen_c.py | 46 | ||||
-rw-r--r-- | src/vat/api_format.c | 16 | ||||
-rw-r--r-- | src/vcl/vcl_bapi.c | 17 | ||||
-rw-r--r-- | src/vlibapi/api_common.h | 4 | ||||
-rw-r--r-- | src/vlibapi/api_shared.c | 30 | ||||
-rw-r--r-- | src/vlibmemory/memclnt_api.c | 34 | ||||
-rw-r--r-- | src/vlibmemory/memory_client.c | 16 | ||||
-rw-r--r-- | src/vlibmemory/socket_api.c | 16 | ||||
-rw-r--r-- | src/vlibmemory/socket_client.c | 16 | ||||
-rw-r--r-- | src/vnet/srmpls/sr_mpls_api.c | 54 |
12 files changed, 168 insertions, 116 deletions
diff --git a/src/plugins/hs_apps/sapi/vpp_echo_bapi.c b/src/plugins/hs_apps/sapi/vpp_echo_bapi.c index 0652b864b1d..868cc3a0591 100644 --- a/src/plugins/hs_apps/sapi/vpp_echo_bapi.c +++ b/src/plugins/hs_apps/sapi/vpp_echo_bapi.c @@ -585,11 +585,18 @@ echo_api_hookup (echo_main_t * em) return; #define _(N, n) \ - vl_msg_api_set_handlers (REPLY_MSG_ID_BASE + VL_API_##N, #n, \ - vl_api_##n##_t_handler, vl_api_##n##_t_endian, \ - vl_api_##n##_t_format, sizeof (vl_api_##n##_t), 1, \ - vl_api_##n##_t_tojson, vl_api_##n##_t_fromjson, \ - vl_api_##n##_t_calc_size); + vl_msg_api_config (&(vl_msg_api_msg_config_t){ \ + .id = REPLY_MSG_ID_BASE + VL_API_##N, \ + .name = #n, \ + .handler = vl_api_##n##_t_handler, \ + .endian = vl_api_##n##_t_endian, \ + .format_fn = vl_api_##n##_t_format, \ + .size = sizeof (vl_api_##n##_t), \ + .traced = 1, \ + .tojson = vl_api_##n##_t_tojson, \ + .fromjson = vl_api_##n##_t_fromjson, \ + .calc_size = vl_api_##n##_t_calc_size, \ + }); foreach_quic_echo_msg; #undef _ } diff --git a/src/plugins/tracedump/tracedump_test.c b/src/plugins/tracedump/tracedump_test.c index f2bb63ec85d..1a2c8185fe2 100644 --- a/src/plugins/tracedump/tracedump_test.c +++ b/src/plugins/tracedump/tracedump_test.c @@ -248,12 +248,18 @@ api_trace_clear_capture (vat_main_t * vam) void manual_setup_message_id_table (vat_main_t * vam) { - vl_msg_api_set_handlers ( - VL_API_TRACE_DETAILS + tracedump_test_main.msg_id_base, "trace_details", - vl_api_trace_details_t_handler, vl_api_trace_details_t_endian, - vl_api_trace_details_t_format, sizeof (vl_api_trace_details_t), 1, - vl_api_trace_details_t_tojson, vl_api_trace_details_t_fromjson, - vl_api_trace_details_t_calc_size); + vl_msg_api_config (&(vl_msg_api_msg_config_t){ + .id = VL_API_TRACE_DETAILS + tracedump_test_main.msg_id_base, + .name = "trace_details", + .handler = vl_api_trace_details_t_handler, + .endian = vl_api_trace_details_t_endian, + .format_fn = vl_api_trace_details_t_format, + .size = sizeof (vl_api_trace_details_t), + .traced = 1, + .tojson = vl_api_trace_details_t_tojson, + .fromjson = vl_api_trace_details_t_fromjson, + .calc_size = vl_api_trace_details_t_calc_size, + }); } #define VL_API_LOCAL_SETUP_MESSAGE_ID_TABLE manual_setup_message_id_table diff --git a/src/tools/vppapigen/vppapigen_c.py b/src/tools/vppapigen/vppapigen_c.py index b9f9e070e4a..5ca2ed51ff6 100644 --- a/src/tools/vppapigen/vppapigen_c.py +++ b/src/tools/vppapigen/vppapigen_c.py @@ -1669,17 +1669,18 @@ def generate_c_test_boilerplate(services, defines, file_crc, module, plugin, str write("setup_message_id_table (vat_main_t * vam, u16 msg_id_base) {\n") for s in services: write( - " vl_msg_api_set_handlers(VL_API_{ID} + msg_id_base, " - ' "{n}",\n' - " vl_api_{n}_t_handler, " - " vl_api_{n}_t_endian, " - " vl_api_{n}_t_format,\n" - " sizeof(vl_api_{n}_t), 1,\n" - " vl_api_{n}_t_tojson,\n" - " vl_api_{n}_t_fromjson,\n" - " vl_api_{n}_t_calc_size);\n".format( - n=s.reply, ID=s.reply.upper() - ) + " vl_msg_api_config (&(vl_msg_api_msg_config_t){{\n" + " .id = VL_API_{ID} + msg_id_base,\n" + ' .name = "{n}",\n' + " .handler = vl_api_{n}_t_handler,\n" + " .endian = vl_api_{n}_t_endian,\n" + " .format_fn = vl_api_{n}_t_format,\n" + " .size = sizeof(vl_api_{n}_t),\n" + " .traced = 1,\n" + " .tojson = vl_api_{n}_t_tojson,\n" + " .fromjson = vl_api_{n}_t_fromjson,\n" + " .calc_size = vl_api_{n}_t_calc_size,\n" + " }});".format(n=s.reply, ID=s.reply.upper()) ) write( ' hash_set_mem (vam->function_by_name, "{n}", api_{n});\n'.format( @@ -1698,17 +1699,18 @@ def generate_c_test_boilerplate(services, defines, file_crc, module, plugin, str # Events for e in s.events: write( - " vl_msg_api_set_handlers(VL_API_{ID} + msg_id_base, " - ' "{n}",\n' - " vl_api_{n}_t_handler, " - " vl_api_{n}_t_endian, " - " vl_api_{n}_t_format,\n" - " sizeof(vl_api_{n}_t), 1,\n" - " vl_api_{n}_t_tojson,\n" - " vl_api_{n}_t_fromjson,\n" - " vl_api_{n}_t_calc_size);\n".format( - n=e, ID=e.upper() - ) + " vl_msg_api_config (&(vl_msg_api_msg_config_t){{\n" + " .id = VL_API_{ID} + msg_id_base,\n" + ' .name = "{n}",\n' + " .handler = vl_api_{n}_t_handler,\n" + " .endian = vl_api_{n}_t_endian,\n" + " .format_fn = vl_api_{n}_t_format,\n" + " .size = sizeof(vl_api_{n}_t),\n" + " .traced = 1,\n" + " .tojson = vl_api_{n}_t_tojson,\n" + " .fromjson = vl_api_{n}_t_fromjson,\n" + " .calc_size = vl_api_{n}_t_calc_size,\n" + " }});".format(n=e, ID=e.upper()) ) write("}\n") diff --git a/src/vat/api_format.c b/src/vat/api_format.c index 72ce34fdf6a..45ba025f191 100644 --- a/src/vat/api_format.c +++ b/src/vat/api_format.c @@ -2733,10 +2733,18 @@ void vat_api_hookup (vat_main_t * vam) { #define _(N, n) \ - vl_msg_api_set_handlers ( \ - VL_API_##N + 1, #n, vl_api_##n##_t_handler_uni, vl_api_##n##_t_endian, \ - vl_api_##n##_t_format, sizeof (vl_api_##n##_t), 1, vl_api_##n##_t_tojson, \ - vl_api_##n##_t_fromjson, vl_api_##n##_t_calc_size); + vl_msg_api_config (&(vl_msg_api_msg_config_t){ \ + .id = VL_API_##N + 1, \ + .name = #n, \ + .handler = vl_api_##n##_t_handler_uni, \ + .endian = vl_api_##n##_t_endian, \ + .format_fn = vl_api_##n##_t_format, \ + .size = sizeof (vl_api_##n##_t), \ + .traced = 1, \ + .tojson = vl_api_##n##_t_tojson, \ + .fromjson = vl_api_##n##_t_fromjson, \ + .calc_size = vl_api_##n##_t_calc_size, \ + }); foreach_vpe_api_reply_msg; #if VPP_API_TEST_BUILTIN == 0 foreach_standalone_reply_msg; diff --git a/src/vcl/vcl_bapi.c b/src/vcl/vcl_bapi.c index 7e5203dcfe6..afe8824812f 100644 --- a/src/vcl/vcl_bapi.c +++ b/src/vcl/vcl_bapi.c @@ -302,11 +302,18 @@ vcl_bapi_hookup (void) return; #define _(N, n) \ - vl_msg_api_set_handlers (REPLY_MSG_ID_BASE + VL_API_##N, #n, \ - vl_api_##n##_t_handler, vl_api_##n##_t_endian, \ - vl_api_##n##_t_format, sizeof (vl_api_##n##_t), 1, \ - vl_api_##n##_t_tojson, vl_api_##n##_t_fromjson, \ - vl_api_##n##_t_calc_size); + vl_msg_api_config (&(vl_msg_api_msg_config_t){ \ + .id = REPLY_MSG_ID_BASE + VL_API_##N, \ + .name = #n, \ + .handler = vl_api_##n##_t_handler, \ + .endian = vl_api_##n##_t_endian, \ + .format_fn = vl_api_##n##_t_format, \ + .size = sizeof (vl_api_##n##_t), \ + .traced = 1, \ + .tojson = vl_api_##n##_t_tojson, \ + .fromjson = vl_api_##n##_t_fromjson, \ + .calc_size = vl_api_##n##_t_calc_size, \ + }); foreach_sock_msg; #undef _ } diff --git a/src/vlibapi/api_common.h b/src/vlibapi/api_common.h index 37ffb587732..d644d939ad3 100644 --- a/src/vlibapi/api_common.h +++ b/src/vlibapi/api_common.h @@ -171,10 +171,6 @@ void vl_msg_api_trace_only (void *the_msg, uword msg_len); void vl_msg_api_cleanup_handler (void *the_msg); void vl_msg_api_replay_handler (void *the_msg); void vl_msg_api_socket_handler (void *the_msg, uword msg_len); -void vl_msg_api_set_handlers (int msg_id, char *msg_name, void *handler, - void *endian, format_function_t *format, - int msg_size, int traced, void *tojson, - void *fromjson, void *validate_size); void vl_msg_api_clean_handlers (int msg_id); void vl_msg_api_config (vl_msg_api_msg_config_t *); void vl_msg_api_set_cleanup_handler (int msg_id, void *fp); diff --git a/src/vlibapi/api_shared.c b/src/vlibapi/api_shared.c index 0a983488bec..bf037518418 100644 --- a/src/vlibapi/api_shared.c +++ b/src/vlibapi/api_shared.c @@ -784,36 +784,6 @@ vl_msg_api_config (vl_msg_api_msg_config_t * c) hash_set_mem (am->msg_id_by_name, c->name, c->id); } -/* - * vl_msg_api_set_handlers - * preserve the old API for a while - */ -void -vl_msg_api_set_handlers (int id, char *name, void *handler, void *endian, - format_function_t *format, int size, int traced, - void *tojson, void *fromjson, void *calc_size) -{ - vl_msg_api_msg_config_t cfg; - vl_msg_api_msg_config_t *c = &cfg; - - clib_memset (c, 0, sizeof (*c)); - - c->id = id; - c->name = name; - c->handler = handler; - c->endian = endian; - c->format_fn = format; - c->traced = traced; - c->replay = 1; - c->message_bounce = 0; - c->is_mp_safe = 0; - c->is_autoendian = 0; - c->tojson = tojson; - c->fromjson = fromjson; - c->calc_size = calc_size; - vl_msg_api_config (c); -} - void vl_msg_api_clean_handlers (int msg_id) { diff --git a/src/vlibmemory/memclnt_api.c b/src/vlibmemory/memclnt_api.c index 0717d81c199..29858dd8497 100644 --- a/src/vlibmemory/memclnt_api.c +++ b/src/vlibmemory/memclnt_api.c @@ -707,22 +707,36 @@ rpc_api_hookup (vlib_main_t *vm) { api_main_t *am = vlibapi_get_main (); #define _(N, n) \ - vl_msg_api_set_handlers ( \ - VL_API_##N, #n, vl_api_##n##_t_handler, 0, vl_api_##n##_t_format, \ - sizeof (vl_api_##n##_t), 0 /* do not trace */, vl_api_##n##_t_tojson, \ - vl_api_##n##_t_fromjson, vl_api_##n##_t_calc_size); + vl_msg_api_config (&(vl_msg_api_msg_config_t){ \ + .id = VL_API_##N, \ + .name = #n, \ + .handler = vl_api_##n##_t_handler, \ + .format_fn = vl_api_##n##_t_format, \ + .size = sizeof (vl_api_##n##_t), \ + .traced = 0, \ + .tojson = vl_api_##n##_t_tojson, \ + .fromjson = vl_api_##n##_t_fromjson, \ + .calc_size = vl_api_##n##_t_calc_size, \ + }); foreach_rpc_api_msg; #undef _ #define _(N, n) \ - vl_msg_api_set_handlers ( \ - VL_API_##N, #n, vl_api_##n##_t_handler, 0, vl_api_##n##_t_format, \ - sizeof (vl_api_##n##_t), 1 /* do trace */, vl_api_##n##_t_tojson, \ - vl_api_##n##_t_fromjson, vl_api_##n##_t_calc_size); - foreach_plugin_trace_msg; + vl_msg_api_config (&(vl_msg_api_msg_config_t){ \ + .id = VL_API_##N, \ + .name = #n, \ + .handler = vl_api_##n##_t_handler, \ + .format_fn = vl_api_##n##_t_format, \ + .size = sizeof (vl_api_##n##_t), \ + .traced = 1, \ + .tojson = vl_api_##n##_t_tojson, \ + .fromjson = vl_api_##n##_t_fromjson, \ + .calc_size = vl_api_##n##_t_calc_size, \ + }); + foreach_plugin_trace_msg #undef _ - vl_api_allow_msg_replay (am, VL_API_TRACE_PLUGIN_MSG_IDS, 0); + vl_api_allow_msg_replay (am, VL_API_TRACE_PLUGIN_MSG_IDS, 0); /* No reason to halt the parade to create a trace record... */ vl_api_set_msg_thread_safe (am, VL_API_TRACE_PLUGIN_MSG_IDS, 1); diff --git a/src/vlibmemory/memory_client.c b/src/vlibmemory/memory_client.c index 738c4e50cb9..d2323de0034 100644 --- a/src/vlibmemory/memory_client.c +++ b/src/vlibmemory/memory_client.c @@ -366,10 +366,18 @@ vl_client_install_client_message_handlers (void) { api_main_t *am = vlibapi_get_main (); #define _(N, n) \ - vl_msg_api_set_handlers ( \ - VL_API_##N, #n, vl_api_##n##_t_handler, vl_api_##n##_t_endian, \ - vl_api_##n##_t_format, sizeof (vl_api_##n##_t), 0, vl_api_##n##_t_tojson, \ - vl_api_##n##_t_fromjson, vl_api_##n##_t_calc_size); \ + vl_msg_api_config (&(vl_msg_api_msg_config_t){ \ + .id = VL_API_##N, \ + .name = #n, \ + .handler = vl_api_##n##_t_handler, \ + .endian = vl_api_##n##_t_endian, \ + .format_fn = vl_api_##n##_t_format, \ + .size = sizeof (vl_api_##n##_t), \ + .traced = 0, \ + .tojson = vl_api_##n##_t_tojson, \ + .fromjson = vl_api_##n##_t_fromjson, \ + .calc_size = vl_api_##n##_t_calc_size, \ + }); \ am->msg_data[VL_API_##N].replay_allowed = 0; foreach_api_msg; #undef _ diff --git a/src/vlibmemory/socket_api.c b/src/vlibmemory/socket_api.c index 106fcb2f2b9..6559f733393 100644 --- a/src/vlibmemory/socket_api.c +++ b/src/vlibmemory/socket_api.c @@ -796,10 +796,18 @@ vl_sock_api_init (vlib_main_t * vm) return 0; #define _(N, n, t) \ - vl_msg_api_set_handlers ( \ - VL_API_##N, #n, vl_api_##n##_t_handler, vl_api_##n##_t_endian, \ - vl_api_##n##_t_format, sizeof (vl_api_##n##_t), t, vl_api_##n##_t_tojson, \ - vl_api_##n##_t_fromjson, vl_api_##n##_t_calc_size); \ + vl_msg_api_config (&(vl_msg_api_msg_config_t){ \ + .id = VL_API_##N, \ + .name = #n, \ + .handler = vl_api_##n##_t_handler, \ + .endian = vl_api_##n##_t_endian, \ + .format_fn = vl_api_##n##_t_format, \ + .size = sizeof (vl_api_##n##_t), \ + .traced = t, \ + .tojson = vl_api_##n##_t_tojson, \ + .fromjson = vl_api_##n##_t_fromjson, \ + .calc_size = vl_api_##n##_t_calc_size, \ + }); \ am->msg_data[VL_API_##N].replay_allowed = 0; foreach_vlib_api_msg; #undef _ diff --git a/src/vlibmemory/socket_client.c b/src/vlibmemory/socket_client.c index 1eccb737282..82c6bfe7bee 100644 --- a/src/vlibmemory/socket_client.c +++ b/src/vlibmemory/socket_client.c @@ -431,10 +431,18 @@ vl_sock_client_install_message_handlers (void) { #define _(N, n) \ - vl_msg_api_set_handlers ( \ - VL_API_##N, #n, vl_api_##n##_t_handler, vl_api_##n##_t_endian, \ - vl_api_##n##_t_format, sizeof (vl_api_##n##_t), 0, vl_api_##n##_t_tojson, \ - vl_api_##n##_t_fromjson, vl_api_##n##_t_calc_size); + vl_msg_api_config (&(vl_msg_api_msg_config_t){ \ + .id = VL_API_##N, \ + .name = #n, \ + .handler = vl_api_##n##_t_handler, \ + .endian = vl_api_##n##_t_endian, \ + .format_fn = vl_api_##n##_t_format, \ + .size = sizeof (vl_api_##n##_t), \ + .traced = 0, \ + .tojson = vl_api_##n##_t_tojson, \ + .fromjson = vl_api_##n##_t_fromjson, \ + .calc_size = vl_api_##n##_t_calc_size, \ + }); foreach_sock_client_api_msg; #undef _ } diff --git a/src/vnet/srmpls/sr_mpls_api.c b/src/vnet/srmpls/sr_mpls_api.c index 8642db9e6e3..920856acff6 100644 --- a/src/vnet/srmpls/sr_mpls_api.c +++ b/src/vnet/srmpls/sr_mpls_api.c @@ -193,11 +193,18 @@ sr_mpls_api_hookup (vlib_main_t * vm) vec_free (name); #define _(N, n) \ - vl_msg_api_set_handlers (REPLY_MSG_ID_BASE + VL_API_##N, #n, \ - vl_api_##n##_t_handler, vl_api_##n##_t_endian, \ - vl_api_##n##_t_format, sizeof (vl_api_##n##_t), 1, \ - vl_api_##n##_t_tojson, vl_api_##n##_t_fromjson, \ - vl_api_##n##_t_calc_size); + vl_msg_api_config (&(vl_msg_api_msg_config_t){ \ + .id = REPLY_MSG_ID_BASE + VL_API_##N, \ + .name = #n, \ + .handler = vl_api_##n##_t_handler, \ + .endian = vl_api_##n##_t_endian, \ + .format_fn = vl_api_##n##_t_format, \ + .size = sizeof (vl_api_##n##_t), \ + .traced = 1, \ + .tojson = vl_api_##n##_t_tojson, \ + .fromjson = vl_api_##n##_t_fromjson, \ + .calc_size = vl_api_##n##_t_calc_size, \ + }); foreach_vpe_api_msg; #undef _ @@ -205,23 +212,34 @@ sr_mpls_api_hookup (vlib_main_t * vm) * Manually register the sr policy add msg, so we trace enough bytes * to capture a typical segment list */ - vl_msg_api_set_handlers ( - REPLY_MSG_ID_BASE + VL_API_SR_MPLS_POLICY_ADD, "sr_mpls_policy_add", - vl_api_sr_mpls_policy_add_t_handler, vl_api_sr_mpls_policy_add_t_endian, - vl_api_sr_mpls_policy_add_t_format, 256, 1, - vl_api_sr_mpls_policy_add_t_tojson, vl_api_sr_mpls_policy_add_t_fromjson, - vl_api_sr_mpls_policy_add_t_calc_size); - + vl_msg_api_config (&(vl_msg_api_msg_config_t){ + .id = REPLY_MSG_ID_BASE + VL_API_SR_MPLS_POLICY_ADD, + .name = "sr_mpls_policy_add", + .handler = vl_api_sr_mpls_policy_add_t_handler, + .endian = vl_api_sr_mpls_policy_add_t_endian, + .format_fn = vl_api_sr_mpls_policy_add_t_format, + .size = 256, + .traced = 1, + .tojson = vl_api_sr_mpls_policy_add_t_tojson, + .fromjson = vl_api_sr_mpls_policy_add_t_fromjson, + .calc_size = vl_api_sr_mpls_policy_add_t_calc_size, + }); /* * Manually register the sr policy mod msg, so we trace enough bytes * to capture a typical segment list */ - vl_msg_api_set_handlers ( - REPLY_MSG_ID_BASE + VL_API_SR_MPLS_POLICY_MOD, "sr_mpls_policy_mod", - vl_api_sr_mpls_policy_mod_t_handler, vl_api_sr_mpls_policy_mod_t_endian, - vl_api_sr_mpls_policy_mod_t_format, 256, 1, - vl_api_sr_mpls_policy_mod_t_tojson, vl_api_sr_mpls_policy_mod_t_fromjson, - vl_api_sr_mpls_policy_mod_t_calc_size); + vl_msg_api_config (&(vl_msg_api_msg_config_t){ + .id = REPLY_MSG_ID_BASE + VL_API_SR_MPLS_POLICY_MOD, + .name = "sr_mpls_policy_mod", + .handler = vl_api_sr_mpls_policy_mod_t_handler, + .endian = vl_api_sr_mpls_policy_mod_t_endian, + .format_fn = vl_api_sr_mpls_policy_mod_t_format, + .size = 256, + .traced = 1, + .tojson = vl_api_sr_mpls_policy_mod_t_tojson, + .fromjson = vl_api_sr_mpls_policy_mod_t_fromjson, + .calc_size = vl_api_sr_mpls_policy_mod_t_calc_size, + }); /* * Set up the (msg_name, crc, message-id) table |