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/vat/api_format.c | 655 --------------------------------------------------- 1 file changed, 655 deletions(-) (limited to 'src/vat') diff --git a/src/vat/api_format.c b/src/vat/api_format.c index 3a93bdfa790..0457a3cac7a 100644 --- a/src/vat/api_format.c +++ b/src/vat/api_format.c @@ -1679,371 +1679,6 @@ static void vl_api_virtio_pci_delete_reply_t_handler_json vam->result_ready = 1; } -static void -vl_api_bond_create_reply_t_handler (vl_api_bond_create_reply_t * mp) -{ - vat_main_t *vam = &vat_main; - i32 retval = ntohl (mp->retval); - - if (vam->async_mode) - { - vam->async_errors += (retval < 0); - } - else - { - vam->retval = retval; - vam->sw_if_index = ntohl (mp->sw_if_index); - vam->result_ready = 1; - } -} - -static void vl_api_bond_create_reply_t_handler_json - (vl_api_bond_create_reply_t * mp) -{ - vat_main_t *vam = &vat_main; - vat_json_node_t node; - - vat_json_init_object (&node); - vat_json_object_add_int (&node, "retval", ntohl (mp->retval)); - vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index)); - - vat_json_print (vam->ofp, &node); - vat_json_free (&node); - - vam->retval = ntohl (mp->retval); - vam->result_ready = 1; -} - -static void -vl_api_bond_create2_reply_t_handler (vl_api_bond_create2_reply_t * mp) -{ - vat_main_t *vam = &vat_main; - i32 retval = ntohl (mp->retval); - - if (vam->async_mode) - { - vam->async_errors += (retval < 0); - } - else - { - vam->retval = retval; - vam->sw_if_index = ntohl (mp->sw_if_index); - vam->result_ready = 1; - } -} - -static void vl_api_bond_create2_reply_t_handler_json - (vl_api_bond_create2_reply_t * mp) -{ - vat_main_t *vam = &vat_main; - vat_json_node_t node; - - vat_json_init_object (&node); - vat_json_object_add_int (&node, "retval", ntohl (mp->retval)); - vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index)); - - vat_json_print (vam->ofp, &node); - vat_json_free (&node); - - vam->retval = ntohl (mp->retval); - vam->result_ready = 1; -} - -static void -vl_api_bond_delete_reply_t_handler (vl_api_bond_delete_reply_t * mp) -{ - vat_main_t *vam = &vat_main; - i32 retval = ntohl (mp->retval); - - if (vam->async_mode) - { - vam->async_errors += (retval < 0); - } - else - { - vam->retval = retval; - vam->result_ready = 1; - } -} - -static void vl_api_bond_delete_reply_t_handler_json - (vl_api_bond_delete_reply_t * mp) -{ - vat_main_t *vam = &vat_main; - vat_json_node_t node; - - vat_json_init_object (&node); - vat_json_object_add_int (&node, "retval", ntohl (mp->retval)); - - vat_json_print (vam->ofp, &node); - vat_json_free (&node); - - vam->retval = ntohl (mp->retval); - vam->result_ready = 1; -} - -static void -vl_api_bond_add_member_reply_t_handler (vl_api_bond_add_member_reply_t * mp) -{ - vat_main_t *vam = &vat_main; - i32 retval = ntohl (mp->retval); - - if (vam->async_mode) - { - vam->async_errors += (retval < 0); - } - else - { - vam->retval = retval; - vam->result_ready = 1; - } -} - -static void vl_api_bond_add_member_reply_t_handler_json - (vl_api_bond_add_member_reply_t * mp) -{ - vat_main_t *vam = &vat_main; - vat_json_node_t node; - - vat_json_init_object (&node); - vat_json_object_add_int (&node, "retval", ntohl (mp->retval)); - - vat_json_print (vam->ofp, &node); - vat_json_free (&node); - - vam->retval = ntohl (mp->retval); - vam->result_ready = 1; -} - -static void -vl_api_bond_detach_member_reply_t_handler (vl_api_bond_detach_member_reply_t * - mp) -{ - vat_main_t *vam = &vat_main; - i32 retval = ntohl (mp->retval); - - if (vam->async_mode) - { - vam->async_errors += (retval < 0); - } - else - { - vam->retval = retval; - vam->result_ready = 1; - } -} - -static void vl_api_bond_detach_member_reply_t_handler_json - (vl_api_bond_detach_member_reply_t * mp) -{ - vat_main_t *vam = &vat_main; - vat_json_node_t node; - - vat_json_init_object (&node); - vat_json_object_add_int (&node, "retval", ntohl (mp->retval)); - - vat_json_print (vam->ofp, &node); - vat_json_free (&node); - - vam->retval = ntohl (mp->retval); - vam->result_ready = 1; -} - -static int -api_sw_interface_set_bond_weight (vat_main_t * vam) -{ - unformat_input_t *i = vam->input; - vl_api_sw_interface_set_bond_weight_t *mp; - u32 sw_if_index = ~0; - u32 weight = 0; - u8 weight_enter = 0; - int ret; - - while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) - { - if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) - ; - else if (unformat (i, "sw_if_index %d", &sw_if_index)) - ; - else if (unformat (i, "weight %u", &weight)) - weight_enter = 1; - else - break; - } - - if (sw_if_index == ~0) - { - errmsg ("missing interface name or sw_if_index"); - return -99; - } - if (weight_enter == 0) - { - errmsg ("missing valid weight"); - return -99; - } - - /* Construct the API message */ - M (SW_INTERFACE_SET_BOND_WEIGHT, mp); - mp->sw_if_index = ntohl (sw_if_index); - mp->weight = ntohl (weight); - - S (mp); - W (ret); - return ret; -} - -static void vl_api_sw_bond_interface_details_t_handler - (vl_api_sw_bond_interface_details_t * mp) -{ - vat_main_t *vam = &vat_main; - - print (vam->ofp, - "%-16s %-12d %-12U %-13U %-14u %-14u", - mp->interface_name, ntohl (mp->sw_if_index), - format_bond_mode, ntohl (mp->mode), format_bond_load_balance, - ntohl (mp->lb), ntohl (mp->active_members), ntohl (mp->members)); -} - -static void vl_api_sw_bond_interface_details_t_handler_json - (vl_api_sw_bond_interface_details_t * mp) -{ - vat_main_t *vam = &vat_main; - vat_json_node_t *node = NULL; - - if (VAT_JSON_ARRAY != vam->json_tree.type) - { - ASSERT (VAT_JSON_NONE == vam->json_tree.type); - vat_json_init_array (&vam->json_tree); - } - node = vat_json_array_add (&vam->json_tree); - - vat_json_init_object (node); - vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index)); - vat_json_object_add_string_copy (node, "interface_name", - mp->interface_name); - vat_json_object_add_uint (node, "mode", ntohl (mp->mode)); - vat_json_object_add_uint (node, "load_balance", ntohl (mp->lb)); - vat_json_object_add_uint (node, "active_members", - ntohl (mp->active_members)); - vat_json_object_add_uint (node, "members", ntohl (mp->members)); -} - -static int -api_sw_bond_interface_dump (vat_main_t * vam) -{ - unformat_input_t *i = vam->input; - vl_api_sw_bond_interface_dump_t *mp; - vl_api_control_ping_t *mp_ping; - int ret; - u32 sw_if_index = ~0; - - while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) - { - if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) - ; - else if (unformat (i, "sw_if_index %d", &sw_if_index)) - ; - else - break; - } - - print (vam->ofp, - "\n%-16s %-12s %-12s %-13s %-14s %-14s", - "interface name", "sw_if_index", "mode", "load balance", - "active members", "members"); - - /* Get list of bond interfaces */ - M (SW_BOND_INTERFACE_DUMP, mp); - mp->sw_if_index = ntohl (sw_if_index); - S (mp); - - /* Use a control ping for synchronization */ - MPING (CONTROL_PING, mp_ping); - S (mp_ping); - - W (ret); - return ret; -} - -static void vl_api_sw_member_interface_details_t_handler - (vl_api_sw_member_interface_details_t * mp) -{ - vat_main_t *vam = &vat_main; - - print (vam->ofp, - "%-25s %-12d %-7d %-12d %-10d %-10d", mp->interface_name, - ntohl (mp->sw_if_index), mp->is_passive, mp->is_long_timeout, - ntohl (mp->weight), mp->is_local_numa); -} - -static void vl_api_sw_member_interface_details_t_handler_json - (vl_api_sw_member_interface_details_t * mp) -{ - vat_main_t *vam = &vat_main; - vat_json_node_t *node = NULL; - - if (VAT_JSON_ARRAY != vam->json_tree.type) - { - ASSERT (VAT_JSON_NONE == vam->json_tree.type); - vat_json_init_array (&vam->json_tree); - } - node = vat_json_array_add (&vam->json_tree); - - vat_json_init_object (node); - vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index)); - vat_json_object_add_string_copy (node, "interface_name", - mp->interface_name); - vat_json_object_add_uint (node, "passive", mp->is_passive); - vat_json_object_add_uint (node, "long_timeout", mp->is_long_timeout); - vat_json_object_add_uint (node, "weight", ntohl (mp->weight)); - vat_json_object_add_uint (node, "is_local_numa", mp->is_local_numa); -} - -static int -api_sw_member_interface_dump (vat_main_t * vam) -{ - unformat_input_t *i = vam->input; - vl_api_sw_member_interface_dump_t *mp; - vl_api_control_ping_t *mp_ping; - u32 sw_if_index = ~0; - u8 sw_if_index_set = 0; - int ret; - - /* Parse args required to build the message */ - while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) - { - if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) - sw_if_index_set = 1; - else if (unformat (i, "sw_if_index %d", &sw_if_index)) - sw_if_index_set = 1; - else - break; - } - - if (sw_if_index_set == 0) - { - errmsg ("missing vpp interface name. "); - return -99; - } - - print (vam->ofp, - "\n%-25s %-12s %-7s %-12s %-10s %-10s", - "member interface name", "sw_if_index", "passive", "long_timeout", - "weight", "local numa"); - - /* Get list of bond interfaces */ - M (SW_MEMBER_INTERFACE_DUMP, mp); - mp->sw_if_index = ntohl (sw_if_index); - S (mp); - - /* Use a control ping for synchronization */ - MPING (CONTROL_PING, mp_ping); - S (mp_ping); - - W (ret); - return ret; -} - static void vl_api_mpls_tunnel_add_del_reply_t_handler (vl_api_mpls_tunnel_add_del_reply_t * mp) { @@ -2406,7 +2041,6 @@ _(sw_interface_set_table_reply) \ _(sw_interface_set_mpls_enable_reply) \ _(sw_interface_set_vpath_reply) \ _(sw_interface_set_l2_bridge_reply) \ -_(sw_interface_set_bond_weight_reply) \ _(bridge_domain_add_del_reply) \ _(sw_interface_set_l2_xconnect_reply) \ _(l2fib_add_del_reply) \ @@ -2533,14 +2167,6 @@ _(VIRTIO_PCI_CREATE_REPLY, virtio_pci_create_reply) \ _(VIRTIO_PCI_CREATE_V2_REPLY, virtio_pci_create_v2_reply) \ _(VIRTIO_PCI_DELETE_REPLY, virtio_pci_delete_reply) \ _(SW_INTERFACE_VIRTIO_PCI_DETAILS, sw_interface_virtio_pci_details) \ -_(BOND_CREATE_REPLY, bond_create_reply) \ -_(BOND_CREATE2_REPLY, bond_create2_reply) \ -_(BOND_DELETE_REPLY, bond_delete_reply) \ -_(BOND_ADD_MEMBER_REPLY, bond_add_member_reply) \ -_(BOND_DETACH_MEMBER_REPLY, bond_detach_member_reply) \ -_(SW_INTERFACE_SET_BOND_WEIGHT_REPLY, sw_interface_set_bond_weight_reply) \ -_(SW_BOND_INTERFACE_DETAILS, sw_bond_interface_details) \ -_(SW_MEMBER_INTERFACE_DETAILS, sw_member_interface_details) \ _(IP_ROUTE_ADD_DEL_REPLY, ip_route_add_del_reply) \ _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \ _(IP_TABLE_REPLACE_BEGIN_REPLY, ip_table_replace_begin_reply) \ @@ -4726,269 +4352,6 @@ api_virtio_pci_delete (vat_main_t * vam) return ret; } -static int -api_bond_create (vat_main_t * vam) -{ - unformat_input_t *i = vam->input; - vl_api_bond_create_t *mp; - u8 mac_address[6]; - u8 custom_mac = 0; - int ret; - u8 mode; - u8 lb; - u8 mode_is_set = 0; - u32 id = ~0; - u8 numa_only = 0; - - clib_memset (mac_address, 0, sizeof (mac_address)); - lb = BOND_LB_L2; - - /* Parse args required to build the message */ - while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) - { - if (unformat (i, "mode %U", unformat_bond_mode, &mode)) - mode_is_set = 1; - else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR)) - && unformat (i, "lb %U", unformat_bond_load_balance, &lb)) - ; - else if (unformat (i, "hw-addr %U", unformat_ethernet_address, - mac_address)) - custom_mac = 1; - else if (unformat (i, "numa-only")) - numa_only = 1; - else if (unformat (i, "id %u", &id)) - ; - else - break; - } - - if (mode_is_set == 0) - { - errmsg ("Missing bond mode. "); - return -99; - } - - /* Construct the API message */ - M (BOND_CREATE, mp); - - mp->use_custom_mac = custom_mac; - - mp->mode = htonl (mode); - mp->lb = htonl (lb); - mp->id = htonl (id); - mp->numa_only = numa_only; - - if (custom_mac) - clib_memcpy (mp->mac_address, mac_address, 6); - - /* send it... */ - S (mp); - - /* Wait for a reply... */ - W (ret); - return ret; -} - -static int -api_bond_create2 (vat_main_t * vam) -{ - unformat_input_t *i = vam->input; - vl_api_bond_create2_t *mp; - u8 mac_address[6]; - u8 custom_mac = 0; - int ret; - u8 mode; - u8 lb; - u8 mode_is_set = 0; - u32 id = ~0; - u8 numa_only = 0; - u8 gso = 0; - - clib_memset (mac_address, 0, sizeof (mac_address)); - lb = BOND_LB_L2; - - /* Parse args required to build the message */ - while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) - { - if (unformat (i, "mode %U", unformat_bond_mode, &mode)) - mode_is_set = 1; - else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR)) - && unformat (i, "lb %U", unformat_bond_load_balance, &lb)) - ; - else if (unformat (i, "hw-addr %U", unformat_ethernet_address, - mac_address)) - custom_mac = 1; - else if (unformat (i, "numa-only")) - numa_only = 1; - else if (unformat (i, "gso")) - gso = 1; - else if (unformat (i, "id %u", &id)) - ; - else - break; - } - - if (mode_is_set == 0) - { - errmsg ("Missing bond mode. "); - return -99; - } - - /* Construct the API message */ - M (BOND_CREATE2, mp); - - mp->use_custom_mac = custom_mac; - - mp->mode = htonl (mode); - mp->lb = htonl (lb); - mp->id = htonl (id); - mp->numa_only = numa_only; - mp->enable_gso = gso; - - if (custom_mac) - clib_memcpy (mp->mac_address, mac_address, 6); - - /* send it... */ - S (mp); - - /* Wait for a reply... */ - W (ret); - return ret; -} - -static int -api_bond_delete (vat_main_t * vam) -{ - unformat_input_t *i = vam->input; - vl_api_bond_delete_t *mp; - u32 sw_if_index = ~0; - u8 sw_if_index_set = 0; - int ret; - - /* Parse args required to build the message */ - while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) - { - if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) - sw_if_index_set = 1; - else if (unformat (i, "sw_if_index %d", &sw_if_index)) - sw_if_index_set = 1; - else - break; - } - - if (sw_if_index_set == 0) - { - errmsg ("missing vpp interface name. "); - return -99; - } - - /* Construct the API message */ - M (BOND_DELETE, mp); - - mp->sw_if_index = ntohl (sw_if_index); - - /* send it... */ - S (mp); - - /* Wait for a reply... */ - W (ret); - return ret; -} - -static int -api_bond_add_member (vat_main_t * vam) -{ - unformat_input_t *i = vam->input; - vl_api_bond_add_member_t *mp; - u32 bond_sw_if_index; - int ret; - u8 is_passive; - u8 is_long_timeout; - u32 bond_sw_if_index_is_set = 0; - u32 sw_if_index; - u8 sw_if_index_is_set = 0; - - /* Parse args required to build the message */ - while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) - { - if (unformat (i, "sw_if_index %d", &sw_if_index)) - sw_if_index_is_set = 1; - else if (unformat (i, "bond %u", &bond_sw_if_index)) - bond_sw_if_index_is_set = 1; - else if (unformat (i, "passive %d", &is_passive)) - ; - else if (unformat (i, "long-timeout %d", &is_long_timeout)) - ; - else - break; - } - - if (bond_sw_if_index_is_set == 0) - { - errmsg ("Missing bond sw_if_index. "); - return -99; - } - if (sw_if_index_is_set == 0) - { - errmsg ("Missing member sw_if_index. "); - return -99; - } - - /* Construct the API message */ - M (BOND_ADD_MEMBER, mp); - - mp->bond_sw_if_index = ntohl (bond_sw_if_index); - mp->sw_if_index = ntohl (sw_if_index); - mp->is_long_timeout = is_long_timeout; - mp->is_passive = is_passive; - - /* send it... */ - S (mp); - - /* Wait for a reply... */ - W (ret); - return ret; -} - -static int -api_bond_detach_member (vat_main_t * vam) -{ - unformat_input_t *i = vam->input; - vl_api_bond_detach_member_t *mp; - u32 sw_if_index = ~0; - u8 sw_if_index_set = 0; - int ret; - - /* Parse args required to build the message */ - while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) - { - if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) - sw_if_index_set = 1; - else if (unformat (i, "sw_if_index %d", &sw_if_index)) - sw_if_index_set = 1; - else - break; - } - - if (sw_if_index_set == 0) - { - errmsg ("missing vpp interface name. "); - return -99; - } - - /* Construct the API message */ - M (BOND_DETACH_MEMBER, mp); - - mp->sw_if_index = ntohl (sw_if_index); - - /* send it... */ - S (mp); - - /* Wait for a reply... */ - W (ret); - return ret; -} - static int api_ip_table_add_del (vat_main_t * vam) { @@ -11142,24 +10505,6 @@ _(virtio_pci_create_v2, \ _(virtio_pci_delete, \ " | sw_if_index ") \ _(sw_interface_virtio_pci_dump, "") \ -_(bond_create, \ - "[hw-addr ] {round-robin | active-backup | " \ - "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]} " \ - "[id ]") \ -_(bond_create2, \ - "[hw-addr ] {mode round-robin | active-backup | " \ - "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]} " \ - "[id ] [gso]") \ -_(bond_delete, \ - " | sw_if_index ") \ -_(bond_add_member, \ - "sw_if_index bond [is_passive] [is_long_timeout]") \ -_(bond_detach_member, \ - "sw_if_index ") \ - _(sw_interface_set_bond_weight, " | sw_if_index weight ") \ - _(sw_bond_interface_dump, " | sw_if_index ") \ - _(sw_member_interface_dump, \ - " | sw_if_index ") \ _(ip_table_add_del, \ "table [ipv6] [add | del]\n") \ _(ip_route_add_del, \ -- cgit 1.2.3-korg