From 3808ec06c4c6a860cab7c6293e8b1be93f002b21 Mon Sep 17 00:00:00 2001 From: Filip Tehlar Date: Tue, 22 Jun 2021 12:03:55 +0000 Subject: devices: tapv2 api cleanup Use autogenerated code. Does not change API definitions. Type: improvement Signed-off-by: Filip Tehlar Change-Id: I0a2c1cbbe798ddf9d08da78bf0b458a0f54fa13a --- src/vnet/devices/tap/tapv2_api.c | 61 ++++++++-------------------------------- 1 file changed, 12 insertions(+), 49 deletions(-) (limited to 'src/vnet/devices/tap/tapv2_api.c') diff --git a/src/vnet/devices/tap/tapv2_api.c b/src/vnet/devices/tap/tapv2_api.c index ac38128daf8..08dca0dc92b 100644 --- a/src/vnet/devices/tap/tapv2_api.c +++ b/src/vnet/devices/tap/tapv2_api.c @@ -24,33 +24,18 @@ #include #include #include - #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 -#include -#define foreach_tapv2_api_msg \ -_(TAP_CREATE_V2, tap_create_v2) \ -_(TAP_DELETE_V2, tap_delete_v2) \ -_(SW_INTERFACE_TAP_V2_DUMP, sw_interface_tap_v2_dump) +static u16 msg_id_base; static void vl_api_tap_create_v2_t_handler (vl_api_tap_create_v2_t * mp) @@ -158,7 +143,7 @@ vl_api_tap_create_v2_t_handler (vl_api_tap_create_v2_t * mp) } rmp = vl_msg_api_alloc (sizeof (*rmp)); - rmp->_vl_msg_id = ntohs (VL_API_TAP_CREATE_V2_REPLY); + rmp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_TAP_CREATE_V2_REPLY); rmp->context = mp->context; rmp->retval = ntohl (ap->rv); rmp->sw_if_index = ntohl (ap->sw_if_index); @@ -189,7 +174,7 @@ vl_api_tap_delete_v2_t_handler (vl_api_tap_delete_v2_t * mp) rv = tap_delete_if (vm, sw_if_index); rmp = vl_msg_api_alloc (sizeof (*rmp)); - rmp->_vl_msg_id = ntohs (VL_API_TAP_DELETE_V2_REPLY); + rmp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_TAP_DELETE_V2_REPLY); rmp->context = mp->context; rmp->retval = ntohl (rv); @@ -207,7 +192,8 @@ tap_send_sw_interface_details (vpe_api_main_t * am, vl_api_sw_interface_tap_v2_details_t *mp; mp = vl_msg_api_alloc (sizeof (*mp)); clib_memset (mp, 0, sizeof (*mp)); - mp->_vl_msg_id = htons (VL_API_SW_INTERFACE_TAP_V2_DETAILS); + mp->_vl_msg_id = + htons (REPLY_MSG_ID_BASE + VL_API_SW_INTERFACE_TAP_V2_DETAILS); mp->id = htonl (tap_if->id); mp->sw_if_index = htonl (tap_if->sw_if_index); mp->tap_flags = htonl (tap_if->tap_flags); @@ -273,37 +259,14 @@ vl_api_sw_interface_tap_v2_dump_t_handler (vl_api_sw_interface_tap_v2_dump_t * vec_free (tapifs); } -#define vl_msg_name_crc_list -#include -#undef vl_msg_name_crc_list - -static void -tap_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_tapv2; -#undef _ -} - +#include static clib_error_t * tapv2_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_tapv2_api_msg; -#undef _ - /* * Set up the (msg_name, crc, message-id) table */ - tap_setup_message_id_table (am); + REPLY_MSG_ID_BASE = setup_message_id_table (); return 0; } -- cgit 1.2.3-korg