summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Luong <sluong@cisco.com>2020-05-18 17:12:56 -0700
committerPaul Vinciguerra <pvinci@vinciconsulting.com>2020-06-16 01:37:56 +0000
commita0e8d9669e980c673f5302e7bff0c06b31d46b56 (patch)
tree93a12a433ff07eb91f9393b2c654984522d68a1d
parent0cf528233ab9272d7153f7323bacae2d50313b1a (diff)
virtio: add vhost sw_if_index filter for sw_interface_vhost_user_dump
The filter sw_if_index was in the API sw_interface_vhost_user_dump. But it was never implemented in the backend. This patch is to add the backend, vat, and custom dump support for the filter. Type: feature Signed-off-by: Steven Luong <sluong@cisco.com> Change-Id: Iaa41a7e11bfbcbb4c60092375e4b0dcf0950077b
-rw-r--r--src/vat/api_format.c17
-rw-r--r--src/vnet/devices/virtio/vhost_user.api2
-rw-r--r--src/vnet/devices/virtio/vhost_user_api.c7
-rw-r--r--src/vpp/api/custom_dump.c3
4 files changed, 23 insertions, 6 deletions
diff --git a/src/vat/api_format.c b/src/vat/api_format.c
index 60cfa504480..a3a67c1eb57 100644
--- a/src/vat/api_format.c
+++ b/src/vat/api_format.c
@@ -12675,15 +12675,28 @@ static void vl_api_sw_interface_vhost_user_details_t_handler_json
static int
api_sw_interface_vhost_user_dump (vat_main_t * vam)
{
+ unformat_input_t *i = vam->input;
vl_api_sw_interface_vhost_user_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,
"Interface name idx hdr_sz features server regions filename");
/* Get list of vhost-user interfaces */
M (SW_INTERFACE_VHOST_USER_DUMP, mp);
- mp->sw_if_index = ntohl (~0);
+ mp->sw_if_index = ntohl (sw_if_index);
S (mp);
/* Use a control ping for synchronization */
@@ -20729,7 +20742,7 @@ _(modify_vhost_user_if, \
"<intfc> | sw_if_index <nn> socket <filename>\n" \
"[server] [renumber <dev_instance>] [gso] [packed]") \
_(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
-_(sw_interface_vhost_user_dump, "") \
+_(sw_interface_vhost_user_dump, "<intfc> | sw_if_index <nn>") \
_(show_version, "") \
_(show_threads, "") \
_(vxlan_gpe_add_del_tunnel, \
diff --git a/src/vnet/devices/virtio/vhost_user.api b/src/vnet/devices/virtio/vhost_user.api
index 127b0a27fc7..338fd710bc0 100644
--- a/src/vnet/devices/virtio/vhost_user.api
+++ b/src/vnet/devices/virtio/vhost_user.api
@@ -115,7 +115,7 @@ define sw_interface_vhost_user_details
};
/** \brief Vhost-user interface dump request
- @param sw_if_index - filter by sw_if_index UNIMPLEMENTED
+ @param sw_if_index - filter by sw_if_index
*/
define sw_interface_vhost_user_dump
{
diff --git a/src/vnet/devices/virtio/vhost_user_api.c b/src/vnet/devices/virtio/vhost_user_api.c
index 67365334d95..80fe5548efd 100644
--- a/src/vnet/devices/virtio/vhost_user_api.c
+++ b/src/vnet/devices/virtio/vhost_user_api.c
@@ -211,7 +211,7 @@ static void
filter_sw_if_index = htonl (mp->sw_if_index);
if (filter_sw_if_index != ~0)
- return; /* UNIMPLEMENTED */
+ VALIDATE_SW_IF_INDEX (mp);
rv = vhost_user_dump_ifs (vnm, vm, &ifaces);
if (rv)
@@ -219,8 +219,11 @@ static void
vec_foreach (vuid, ifaces)
{
- send_sw_interface_vhost_user_details (am, reg, vuid, mp->context);
+ if ((filter_sw_if_index == ~0) ||
+ (vuid->sw_if_index == filter_sw_if_index))
+ send_sw_interface_vhost_user_details (am, reg, vuid, mp->context);
}
+ BAD_SW_IF_INDEX_LABEL;
vec_free (ifaces);
}
diff --git a/src/vpp/api/custom_dump.c b/src/vpp/api/custom_dump.c
index f1798de16c0..be6b094913b 100644
--- a/src/vpp/api/custom_dump.c
+++ b/src/vpp/api/custom_dump.c
@@ -1785,7 +1785,8 @@ static void *vl_api_sw_interface_vhost_user_dump_t_print
u8 *s;
s = format (0, "SCRIPT: sw_interface_vhost_user_dump ");
- s = format (s, "sw_if_index %d ", (mp->sw_if_index));
+ if (mp->sw_if_index != ~0)
+ s = format (s, "sw_if_index %d ", (mp->sw_if_index));
FINISH;
}