diff options
author | Steven <sluong@cisco.com> | 2017-10-29 22:10:46 -0700 |
---|---|---|
committer | Steven <sluong@cisco.com> | 2017-10-29 22:15:29 -0700 |
commit | ad8015be47a8d7d4c1f94b51ad9c70e37cc29cbf (patch) | |
tree | 3575924050fbcbf1349f171befdc23159a92da25 /src/vat/api_format.c | |
parent | a2e244c92c13e931b9a11d2cb9c67bc5eebc5904 (diff) |
devices: Add binary API for set interface <interface> rx-mode
Also add vat test code to test the subject API. The format is
sw_interface_set_rx_mode sw_if_index <index> [queue <id>]
<polling|nterrupt|adaptive>
Change-Id: Ib810d85d430077865bead8cc08a070f8ae478225
Signed-off-by: Steven <sluong@cisco.com>
Diffstat (limited to 'src/vat/api_format.c')
-rw-r--r-- | src/vat/api_format.c | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/vat/api_format.c b/src/vat/api_format.c index c6b6317ef18..de63bc394a9 100644 --- a/src/vat/api_format.c +++ b/src/vat/api_format.c @@ -5044,6 +5044,7 @@ static void vl_api_flow_classify_details_t_handler_json #define foreach_standard_reply_retval_handler \ _(sw_interface_set_flags_reply) \ _(sw_interface_add_del_address_reply) \ +_(sw_interface_set_rx_mode_reply) \ _(sw_interface_set_table_reply) \ _(sw_interface_set_mpls_enable_reply) \ _(sw_interface_set_vpath_reply) \ @@ -5232,6 +5233,7 @@ _(CLI_REPLY, cli_reply) \ _(CLI_INBAND_REPLY, cli_inband_reply) \ _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \ sw_interface_add_del_address_reply) \ +_(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \ _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \ _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \ _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \ @@ -6233,6 +6235,64 @@ api_sw_interface_set_flags (vat_main_t * vam) } static int +api_sw_interface_set_rx_mode (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_sw_interface_set_rx_mode_t *mp; + u32 sw_if_index; + u8 sw_if_index_set = 0; + int ret; + u8 queue_id_valid = 0; + u32 queue_id; + vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN; + + /* Parse args required to build the message */ + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "queue %d", &queue_id)) + queue_id_valid = 1; + else if (unformat (i, "polling")) + mode = VNET_HW_INTERFACE_RX_MODE_POLLING; + else if (unformat (i, "interrupt")) + mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT; + else if (unformat (i, "adaptive")) + mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE; + else + 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 interface name or sw_if_index"); + return -99; + } + if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN) + { + errmsg ("missing rx-mode"); + return -99; + } + + /* Construct the API message */ + M (SW_INTERFACE_SET_RX_MODE, mp); + mp->sw_if_index = ntohl (sw_if_index); + mp->mode = mode; + mp->queue_id_valid = queue_id_valid; + mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0; + + /* send it... */ + S (mp); + + /* Wait for a reply, return the good/bad news... */ + W (ret); + return ret; +} + +static int api_sw_interface_clear_stats (vat_main_t * vam) { unformat_input_t *i = vam->input; @@ -21651,6 +21711,8 @@ _(sw_interface_set_flags, \ "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \ _(sw_interface_add_del_address, \ "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \ +_(sw_interface_set_rx_mode, \ + "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \ _(sw_interface_set_table, \ "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \ _(sw_interface_set_mpls_enable, \ |