From 36d5c97985237d4f509b07ad4e497bd0f1f6cd7e Mon Sep 17 00:00:00 2001 From: Filip Tehlar Date: Tue, 22 Jun 2021 11:28:25 +0000 Subject: devices: api cleanup Use autogenerated code. Does not change API definitions. Type: improvement Signed-off-by: Filip Tehlar Change-Id: I03f51393a92bae45608d9fc9f53164f3b0add3cd --- src/vnet/devices/pipe/pipe_api.c | 60 ++++++---------------------------------- 1 file changed, 8 insertions(+), 52 deletions(-) (limited to 'src/vnet/devices/pipe') diff --git a/src/vnet/devices/pipe/pipe_api.c b/src/vnet/devices/pipe/pipe_api.c index 35efb87a712..1f0faef7c1e 100644 --- a/src/vnet/devices/pipe/pipe_api.c +++ b/src/vnet/devices/pipe/pipe_api.c @@ -17,31 +17,17 @@ #include #include - #include -#include - -#define vl_typedefs /* define message structures */ -#include -#undef vl_typedefs - -#define vl_endianfun /* define message structures */ -#include -#undef vl_endianfun -/* instantiate all the print functions we know about */ -#define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__) -#define vl_printfun -#include -#undef vl_printfun +#include +#include +#include +#define REPLY_MSG_ID_BASE msg_id_base #include extern vpe_api_main_t vpe_api_main; -#define foreach_vpe_api_msg \ - _(PIPE_CREATE, pipe_create) \ - _(PIPE_DELETE, pipe_delete) \ - _(PIPE_DUMP, pipe_dump) +static u16 msg_id_base; static void vl_api_pipe_create_t_handler (vl_api_pipe_create_t * mp) @@ -94,7 +80,7 @@ pipe_send_details (u32 parent_sw_if_index, if (!mp) return (WALK_STOP); - mp->_vl_msg_id = ntohs (VL_API_PIPE_DETAILS); + mp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_PIPE_DETAILS); mp->context = ctx->context; mp->instance = ntohl (instance); @@ -124,44 +110,14 @@ vl_api_pipe_dump_t_handler (vl_api_pipe_dump_t * mp) pipe_walk (pipe_send_details, &ctx); } -/* - * vpe_api_hookup - * Add vpe's API message handlers to the table. - * vlib has already mapped shared memory and - * added the client registration handlers. - * See .../vlib-api/vlibmemory/memclnt_vlib.c:memclnt_process() - */ -#define vl_msg_name_crc_list -#include -#undef vl_msg_name_crc_list - -static void -setup_message_id_table (api_main_t * am) -{ -#define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id); - foreach_vl_msg_name_crc_pipe; -#undef _ -} - +#include static clib_error_t * pipe_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, \ - vl_noop_handler, \ - vl_api_##n##_t_endian, \ - vl_api_##n##_t_print, \ - sizeof(vl_api_##n##_t), 1); - foreach_vpe_api_msg; -#undef _ - /* * Set up the (msg_name, crc, message-id) table */ - setup_message_id_table (am); + REPLY_MSG_ID_BASE = setup_message_id_table (); return 0; } -- cgit 1.2.3-korg