X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Fbonding%2Fbond_api.c;h=3fd73d7995f416a426bdcf1fabe230a244a270ab;hb=cfd8e4ec8;hp=4306e3cba9f78eba5033818f05c936e00aa9d6c4;hpb=3f54d96dac7eda66096ad7068a86fdf4b86cea67;p=vpp.git diff --git a/src/vnet/bonding/bond_api.c b/src/vnet/bonding/bond_api.c index 4306e3cba9f..3fd73d7995f 100644 --- a/src/vnet/bonding/bond_api.c +++ b/src/vnet/bonding/bond_api.c @@ -24,38 +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_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) @@ -102,6 +80,39 @@ vl_api_bond_create_t_handler (vl_api_bond_create_t * mp) /* *INDENT-ON* */ } +static void +vl_api_bond_create2_t_handler (vl_api_bond_create2_t * mp) +{ + vlib_main_t *vm = vlib_get_main (); + vl_api_bond_create2_reply_t *rmp; + bond_create_if_args_t _a, *ap = &_a; + + clib_memset (ap, 0, sizeof (*ap)); + + ap->id = ntohl (mp->id); + + if (mp->use_custom_mac) + { + mac_address_decode (mp->mac_address, (mac_address_t *) ap->hw_addr); + ap->hw_addr_set = 1; + } + + ap->mode = ntohl (mp->mode); + ap->lb = ntohl (mp->lb); + ap->numa_only = mp->numa_only; + ap->gso = mp->enable_gso; + bond_create_if (vm, ap); + + int rv = ap->rv; + + /* *INDENT-OFF* */ + REPLY_MACRO2(VL_API_BOND_CREATE2_REPLY, + ({ + rmp->sw_if_index = ntohl (ap->sw_if_index); + })); + /* *INDENT-ON* */ +} + static void vl_api_bond_add_member_t_handler (vl_api_bond_add_member_t * mp) { @@ -212,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, @@ -263,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, @@ -322,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, @@ -372,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, @@ -412,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; }