diff options
author | Steven Luong <sluong@cisco.com> | 2020-10-21 16:55:49 -0700 |
---|---|---|
committer | Damjan Marion <dmarion@me.com> | 2020-10-24 08:56:59 +0000 |
commit | 490e077fb9a2295d704db3c1bee5901823d2441b (patch) | |
tree | 7ac87d956707a8700bc8c54f2fbedbf6923ab31c /src/plugins/vmxnet3/vmxnet3_test.c | |
parent | 94a92aaa4e3762e671b3a982e5ffc2795c09caa9 (diff) |
vmxnet3: add sw_if_index filter to vmxnet3 interface dump
Introduce a replacement API for vmxnet3_dump which supports interface
filter.
Type: improvement
Signed-off-by: Steven Luong <sluong@cisco.com>
Change-Id: I76074db2aa34b397ce570a2019c43e042a9c7838
Diffstat (limited to 'src/plugins/vmxnet3/vmxnet3_test.c')
-rw-r--r-- | src/plugins/vmxnet3/vmxnet3_test.c | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/src/plugins/vmxnet3/vmxnet3_test.c b/src/plugins/vmxnet3/vmxnet3_test.c index 259ccdb6828..fbd675da5de 100644 --- a/src/plugins/vmxnet3/vmxnet3_test.c +++ b/src/plugins/vmxnet3/vmxnet3_test.c @@ -186,6 +186,51 @@ api_vmxnet3_dump (vat_main_t * vam) return ret; } +static int +api_sw_vmxnet3_interface_dump (vat_main_t * vam) +{ + vmxnet3_test_main_t *vxm = &vmxnet3_test_main; + vl_api_sw_vmxnet3_interface_dump_t *mp; + vl_api_control_ping_t *mp_ping; + int ret; + u32 sw_if_index = ~0; + unformat_input_t *i = vam->input; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "sw_if_index %d", &sw_if_index)) + ; + else + break; + } + + if (vam->json_output) + { + clib_warning ("JSON output not supported for vmxnet3_dump"); + return -99; + } + + M (SW_VMXNET3_INTERFACE_DUMP, mp); + mp->sw_if_index = ntohl (sw_if_index); + S (mp); + + /* Use a control ping for synchronization */ + if (!vxm->ping_id) + vxm->ping_id = + vl_msg_api_get_msg_index ((u8 *) (VL_API_CONTROL_PING_CRC)); + mp_ping = vl_msg_api_alloc_as_if_client (sizeof (*mp_ping)); + mp_ping->_vl_msg_id = htons (vxm->ping_id); + mp_ping->client_index = vam->my_client_index; + + fformat (vam->ofp, "Sending ping id=%d\n", vxm->ping_id); + + vam->result_ready = 0; + S (mp_ping); + + W (ret); + return ret; +} + static u8 * format_pci_addr (u8 * s, va_list * va) { @@ -239,6 +284,51 @@ vl_api_vmxnet3_details_t_handler (vl_api_vmxnet3_details_t * mp) } } +static void vl_api_sw_vmxnet3_interface_details_t_handler + (vl_api_sw_vmxnet3_interface_details_t * mp) +{ + vat_main_t *vam = vmxnet3_test_main.vat_main; + u32 pci_addr = ntohl (mp->pci_addr); + u16 qid; + + fformat (vam->ofp, "%s: sw_if_index %u mac %U\n" + " version: %u\n" + " PCI Address: %U\n" + " state %s\n", + mp->if_name, ntohl (mp->sw_if_index), format_ethernet_address, + mp->hw_addr, mp->version, + format_pci_addr, &pci_addr, mp->admin_up_down ? "up" : "down"); + for (qid = 0; qid < mp->rx_count; qid++) + { + vl_api_vmxnet3_rx_list_t *rx_list = &mp->rx_list[qid]; + fformat (vam->ofp, + " RX Queue %u\n" + " RX completion next index %u\n" + " ring 0 size %u fill %u consume %u produce %u\n" + " ring 1 size %u fill %u consume %u produce %u\n", + qid, + ntohs (rx_list->rx_next), + ntohs (rx_list->rx_qsize), ntohs (rx_list->rx_fill[0]), + ntohs (rx_list->rx_consume[0]), + ntohs (rx_list->rx_produce[0]), + ntohs (rx_list->rx_qsize), ntohs (rx_list->rx_fill[1]), + ntohs (rx_list->rx_consume[1]), + ntohs (rx_list->rx_produce[1])); + } + for (qid = 0; qid < mp->tx_count; qid++) + { + vl_api_vmxnet3_tx_list_t *tx_list = &mp->tx_list[qid]; + fformat (vam->ofp, + " TX Queue %u\n" + " TX completion next index %u\n" + " size %u consume %u produce %u\n", + qid, + ntohs (tx_list->tx_next), + ntohs (tx_list->tx_qsize), ntohs (tx_list->tx_consume), + ntohs (tx_list->tx_produce)); + } +} + #include <vmxnet3/vmxnet3.api_test.c> /* |