tap: implement sw_interface_tap_v2_dump filtering by sw_if_index

Type: feature

Change-Id: I6f607f383dc77a71e8712124f7613b38b4ac065a
Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
diff --git a/src/vnet/devices/tap/FEATURE.yaml b/src/vnet/devices/tap/FEATURE.yaml
index a143d33..5d1726d 100644
--- a/src/vnet/devices/tap/FEATURE.yaml
+++ b/src/vnet/devices/tap/FEATURE.yaml
@@ -7,8 +7,5 @@
   - attach to existing tap at host
 description: "Create a tap v2 device interface, which connects to a
               tap interface on the host system."
-missing:
-
-  - API dump filtering by sw_if_index
 state: production
 properties: [API, CLI, STATS, MULTITHREAD]
diff --git a/src/vnet/devices/tap/tapv2.api b/src/vnet/devices/tap/tapv2.api
index 9113458..61b6720 100644
--- a/src/vnet/devices/tap/tapv2.api
+++ b/src/vnet/devices/tap/tapv2.api
@@ -40,8 +40,8 @@
     @param use_random_mac - let the system generate a unique mac address
     @param mac_address - mac addr to assign to the interface if use_random not set
     @param num_rx_queues - number of rx queues
-    @param tx_ring_sz - the number of entries of TX ring
-    @param rx_ring_sz - the number of entries of RX ring
+    @param tx_ring_sz - the number of entries of TX ring, optional, default is 256 entries, must be power of 2
+    @param rx_ring_sz - the number of entries of RX ring, optional, default is 256 entries, must be power of 2
     @param host_mtu_set - host MTU should be set
     @param host_mtu_size - host MTU size
     @param host_mac_addr_set - host side interface mac address should be set
@@ -57,7 +57,7 @@
     @param tap_flags - flags for the TAP interface creation
     @param host_if_name_set - host side interface name should be set
     @param host_if_name - host side interface name
-    @param host_namespace_set - host namespece should be set
+    @param host_namespace_set - host namespace should be set
     @param host_namespace - host namespace to attach interface to
     @param host_bridge_set - host bridge should be set
     @param host_bridge - host bridge to attach interface to
@@ -71,8 +71,8 @@
   bool use_random_mac [default=true];
   vl_api_mac_address_t mac_address;
   u8 num_rx_queues [default=1];
-  u16 tx_ring_sz; /* optional, default is 256 entries, must be power of 2 */
-  u16 rx_ring_sz; /* optional, default is 256 entries, must be power of 2 */
+  u16 tx_ring_sz [default=256];
+  u16 rx_ring_sz [default=256];
   bool host_mtu_set;
   u32 host_mtu_size;
   bool host_mac_addr_set;
@@ -120,7 +120,7 @@
 };
 
 /** \brief Dump tap interfaces request
-    @param sw_if_index - filter by sw_if_index UNIMPLEMENTED
+    @param sw_if_index - filter by sw_if_index
 */
 define sw_interface_tap_v2_dump
 {
diff --git a/src/vnet/devices/tap/tapv2_api.c b/src/vnet/devices/tap/tapv2_api.c
index 9e09459..0567937 100644
--- a/src/vnet/devices/tap/tapv2_api.c
+++ b/src/vnet/devices/tap/tapv2_api.c
@@ -232,8 +232,8 @@
     return;
 
   filter_sw_if_index = htonl (mp->sw_if_index);
-  if (filter_sw_if_index != ~0)
-    return;			/* UNIMPLEMENTED */
+  if (mp->sw_if_index != ~0)
+    VALIDATE_SW_IF_INDEX (mp);
 
   rv = tap_dump_ifs (&tapifs);
   if (rv)
@@ -241,9 +241,11 @@
 
   vec_foreach (tap_if, tapifs)
   {
-    tap_send_sw_interface_details (am, reg, tap_if, mp->context);
+    if ((filter_sw_if_index == ~0)
+	|| (tap_if->sw_if_index == filter_sw_if_index))
+      tap_send_sw_interface_details (am, reg, tap_if, mp->context);
   }
-
+  BAD_SW_IF_INDEX_LABEL;
   vec_free (tapifs);
 }