From 116a1e52772c3a2dba61f8f2ac9c919f0623153c Mon Sep 17 00:00:00 2001 From: Filip Tehlar Date: Tue, 22 Jun 2021 09:24:06 +0000 Subject: bonding: api cleanup Use autogenerated code. Does not change API definitions. Type: improvement Signed-off-by: Filip Tehlar Change-Id: I1de45c4db57444d2d2c9fb91b8a66a4f01be699b --- src/vnet/bonding/bond_api.c | 74 ++++++++++----------------------------------- src/vnet/vnet_all_api_h.h | 1 - 2 files changed, 16 insertions(+), 59 deletions(-) (limited to 'src/vnet') diff --git a/src/vnet/bonding/bond_api.c b/src/vnet/bonding/bond_api.c index 8b8385d8205..3fd73d7995f 100644 --- a/src/vnet/bonding/bond_api.c +++ b/src/vnet/bonding/bond_api.c @@ -24,39 +24,16 @@ #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_bond_api_msg \ -_(BOND_CREATE, bond_create) \ -_(BOND_CREATE2, bond_create2) \ -_(BOND_DELETE, bond_delete) \ -_(BOND_ENSLAVE, bond_enslave) \ -_(BOND_ADD_MEMBER, bond_add_member) \ -_(SW_INTERFACE_SET_BOND_WEIGHT, sw_interface_set_bond_weight) \ -_(BOND_DETACH_SLAVE, bond_detach_slave) \ -_(BOND_DETACH_MEMBER, bond_detach_member) \ -_(SW_INTERFACE_BOND_DUMP, sw_interface_bond_dump) \ -_(SW_BOND_INTERFACE_DUMP, sw_bond_interface_dump) \ -_(SW_INTERFACE_SLAVE_DUMP, sw_interface_slave_dump) \ -_(SW_MEMBER_INTERFACE_DUMP, sw_member_interface_dump) +static u16 msg_id_base; static void vl_api_bond_delete_t_handler (vl_api_bond_delete_t * mp) @@ -246,7 +223,8 @@ bond_send_sw_interface_details (vpe_api_main_t * am, mp = vl_msg_api_alloc (sizeof (*mp)); clib_memset (mp, 0, sizeof (*mp)); - mp->_vl_msg_id = htons (VL_API_SW_INTERFACE_BOND_DETAILS); + mp->_vl_msg_id = + htons (REPLY_MSG_ID_BASE + VL_API_SW_INTERFACE_BOND_DETAILS); mp->sw_if_index = htonl (bond_if->sw_if_index); mp->id = htonl (bond_if->id); clib_memcpy (mp->interface_name, bond_if->interface_name, @@ -297,7 +275,8 @@ bond_send_sw_bond_interface_details (vpe_api_main_t * am, mp = vl_msg_api_alloc (sizeof (*mp)); clib_memset (mp, 0, sizeof (*mp)); - mp->_vl_msg_id = htons (VL_API_SW_BOND_INTERFACE_DETAILS); + mp->_vl_msg_id = + htons (REPLY_MSG_ID_BASE + VL_API_SW_BOND_INTERFACE_DETAILS); mp->sw_if_index = htonl (bond_if->sw_if_index); mp->id = htonl (bond_if->id); clib_memcpy (mp->interface_name, bond_if->interface_name, @@ -356,7 +335,8 @@ bond_send_sw_member_interface_details (vpe_api_main_t * am, mp = vl_msg_api_alloc (sizeof (*mp)); clib_memset (mp, 0, sizeof (*mp)); - mp->_vl_msg_id = htons (VL_API_SW_INTERFACE_SLAVE_DETAILS); + mp->_vl_msg_id = + htons (REPLY_MSG_ID_BASE + VL_API_SW_INTERFACE_SLAVE_DETAILS); mp->sw_if_index = htonl (member_if->sw_if_index); clib_memcpy (mp->interface_name, member_if->interface_name, MIN (ARRAY_LEN (mp->interface_name) - 1, @@ -406,7 +386,8 @@ bond_send_member_interface_details (vpe_api_main_t * am, mp = vl_msg_api_alloc (sizeof (*mp)); clib_memset (mp, 0, sizeof (*mp)); - mp->_vl_msg_id = htons (VL_API_SW_MEMBER_INTERFACE_DETAILS); + mp->_vl_msg_id = + htons (REPLY_MSG_ID_BASE + VL_API_SW_MEMBER_INTERFACE_DETAILS); mp->sw_if_index = htonl (member_if->sw_if_index); clib_memcpy (mp->interface_name, member_if->interface_name, MIN (ARRAY_LEN (mp->interface_name) - 1, @@ -446,37 +427,14 @@ vl_api_sw_member_interface_dump_t_handler (vl_api_sw_member_interface_dump_t * vec_free (memberifs); } -#define vl_msg_name_crc_list -#include -#undef vl_msg_name_crc_list - -static void -bond_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_bond; -#undef _ -} - +#include static clib_error_t * bond_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_bond_api_msg; -#undef _ - /* * Set up the (msg_name, crc, message-id) table */ - bond_setup_message_id_table (am); + REPLY_MSG_ID_BASE = setup_message_id_table (); return 0; } diff --git a/src/vnet/vnet_all_api_h.h b/src/vnet/vnet_all_api_h.h index 5ae5e7ecf7f..fd9147b44d0 100644 --- a/src/vnet/vnet_all_api_h.h +++ b/src/vnet/vnet_all_api_h.h @@ -33,7 +33,6 @@ #include #endif -#include #include #include #include -- cgit 1.2.3-korg