From ea7178631ef292530993e0c91bf86f1ca9ae99d4 Mon Sep 17 00:00:00 2001 From: Steven Luong Date: Thu, 30 Jul 2020 07:31:40 -0700 Subject: bonding: add bond_create2 API to include gso option gso option is available for the debug CLI version of bond create. This patch is to create a new API to have the corresponding option in the binary API. The old binary API bond_create is marked deprecated. Type: improvement Signed-off-by: Steven Luong Change-Id: Id9501b8e6d267ae09e2b411957f181343da459c0 --- src/vat/api_format.c | 107 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) (limited to 'src/vat/api_format.c') diff --git a/src/vat/api_format.c b/src/vat/api_format.c index bbe5a04df33..f1935dee33a 100644 --- a/src/vat/api_format.c +++ b/src/vat/api_format.c @@ -1931,6 +1931,41 @@ static void vl_api_bond_create_reply_t_handler_json 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) { @@ -5281,6 +5316,7 @@ _(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) \ @@ -7769,6 +7805,73 @@ api_bond_create (vat_main_t * vam) 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) { @@ -20716,6 +20819,10 @@ _(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, \ -- cgit 1.2.3-korg