summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorSteven Luong <sluong@cisco.com>2020-10-21 16:55:49 -0700
committerDamjan Marion <dmarion@me.com>2020-10-24 08:56:59 +0000
commit490e077fb9a2295d704db3c1bee5901823d2441b (patch)
tree7ac87d956707a8700bc8c54f2fbedbf6923ab31c /src/plugins
parent94a92aaa4e3762e671b3a982e5ffc2795c09caa9 (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')
-rw-r--r--src/plugins/vmxnet3/vmxnet3.api46
-rw-r--r--src/plugins/vmxnet3/vmxnet3_api.c43
-rw-r--r--src/plugins/vmxnet3/vmxnet3_test.c90
3 files changed, 178 insertions, 1 deletions
diff --git a/src/plugins/vmxnet3/vmxnet3.api b/src/plugins/vmxnet3/vmxnet3.api
index ff4bdf88f5c..bcea9683f08 100644
--- a/src/plugins/vmxnet3/vmxnet3.api
+++ b/src/plugins/vmxnet3/vmxnet3.api
@@ -15,7 +15,7 @@
*------------------------------------------------------------------
*/
-option version = "1.1.0";
+option version = "1.2.0";
import "vnet/interface_types.api";
import "vnet/ethernet/ethernet_types.api";
@@ -148,10 +148,54 @@ define vmxnet3_details
*/
define vmxnet3_dump
{
+ option deprecated;
u32 client_index;
u32 context;
};
+/** \brief Dump vmxnet3 interfaces
+ @param client_index - opaque cookie to identify the sender
+ @param context - sender context, to match reply w/ request
+ @param vl_api_interface_index_t sw_if_index [default=0xffffffff];
+*/
+define sw_vmxnet3_interface_dump
+{
+ u32 client_index;
+ u32 context;
+ vl_api_interface_index_t sw_if_index [default=0xffffffff];
+};
+
+/** \brief Reply for vmxnet3_interface_dump
+ @param context - sender context, to match reply w/ request (memif_dump)
+ @param sw_if_index - index of the interface
+ @param if_name - name of the interface
+ @param hw_addr - interface MAC address
+ @param pci_addr - pci address of the interface
+ @param version - vmxnet3 hardware version
+ @param admin_up_down - interface administrative status
+ @param rx_count - number of elements in rx_list
+ @param rx_list - list of vmxnet3_rx_list
+ @param tx_count - number of elements in tx_list
+ @param tx_list - list of vmnxnet3_tx_list
+*/
+define sw_vmxnet3_interface_details
+{
+ u32 context;
+
+ vl_api_interface_index_t sw_if_index;
+ string if_name[64];
+ vl_api_mac_address_t hw_addr;
+ u32 pci_addr;
+ u8 version;
+ bool admin_up_down;
+
+ u8 rx_count;
+ vl_api_vmxnet3_rx_list_t rx_list[16];
+
+ u8 tx_count;
+ vl_api_vmxnet3_tx_list_t tx_list[8];
+};
+
/*
* Local Variables:
* eval: (c-set-style "gnu")
diff --git a/src/plugins/vmxnet3/vmxnet3_api.c b/src/plugins/vmxnet3/vmxnet3_api.c
index cdb68708f57..decb7b64c61 100644
--- a/src/plugins/vmxnet3/vmxnet3_api.c
+++ b/src/plugins/vmxnet3/vmxnet3_api.c
@@ -187,6 +187,49 @@ vl_api_vmxnet3_dump_t_handler (vl_api_vmxnet3_dump_t * mp)
vec_free (if_name);
}
+/**
+ * @brief Message handler for vmxnet3_dump API.
+ * @param mp vl_api_vmxnet3_dump_t * mp the api message
+ */
+static void vl_api_sw_vmxnet3_interface_dump_t_handler
+ (vl_api_sw_vmxnet3_interface_dump_t * mp)
+{
+ vmxnet3_main_t *vmxm = &vmxnet3_main;
+ vnet_main_t *vnm = vnet_get_main ();
+ vnet_sw_interface_t *swif;
+ vmxnet3_device_t *vd;
+ u8 *if_name = 0;
+ vl_api_registration_t *reg;
+ u32 filter_sw_if_index;
+
+ reg = vl_api_client_index_to_registration (mp->client_index);
+ if (!reg)
+ return;
+
+ filter_sw_if_index = htonl (mp->sw_if_index);
+ if ((filter_sw_if_index != ~0) &&
+ (vnet_sw_interface_is_api_valid (vnm, filter_sw_if_index) == 0))
+ goto bad_sw_if_index;
+
+ /* *INDENT-OFF* */
+ pool_foreach (vd, vmxm->devices,
+ ({
+ if ((filter_sw_if_index == ~0) ||
+ (vd->sw_if_index == filter_sw_if_index))
+ {
+ swif = vnet_get_sw_interface (vnm, vd->sw_if_index);
+ if_name = format (if_name, "%U%c", format_vnet_sw_interface_name, vnm,
+ swif, 0);
+ send_vmxnet3_details (reg, vd, swif, if_name, mp->context);
+ _vec_len (if_name) = 0;
+ }
+ }));
+ /* *INDENT-ON* */
+
+ BAD_SW_IF_INDEX_LABEL;
+ vec_free (if_name);
+}
+
/* set tup the API message handling tables */
#include <vmxnet3/vmxnet3.api.c>
clib_error_t *
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>
/*