vlib: epoll on worker threads

This patch teaches worer threads to sleep and to be waken up by
kernel if there is activity on file desctiptors assigned to that thread.

It also adds counters to epoll file descriptors and new
debug cli 'show unix file'.

Change-Id: Iaf67869f4aa88ff5b0a08982e1c08474013107c4
Signed-off-by: Damjan Marion <damarion@cisco.com>
diff --git a/src/vnet/devices/af_packet/af_packet.c b/src/vnet/devices/af_packet/af_packet.c
index c51fded..2a13510 100644
--- a/src/vnet/devices/af_packet/af_packet.c
+++ b/src/vnet/devices/af_packet/af_packet.c
@@ -288,6 +288,8 @@
     template.file_descriptor = fd;
     template.private_data = if_index;
     template.flags = UNIX_FILE_EVENT_EDGE_TRIGGERED;
+    template.description = format (0, "%U", format_af_packet_device_name,
+				   if_index);
     apif->clib_file_index = clib_file_add (&file_main, &template);
   }
 
diff --git a/src/vnet/devices/af_packet/af_packet.h b/src/vnet/devices/af_packet/af_packet.h
index b095e7f..18822f8 100644
--- a/src/vnet/devices/af_packet/af_packet.h
+++ b/src/vnet/devices/af_packet/af_packet.h
@@ -66,6 +66,8 @@
 int af_packet_set_l4_cksum_offload (vlib_main_t * vm, u32 sw_if_index,
 				    u8 set);
 
+format_function_t format_af_packet_device_name;
+
 /*
  * fd.io coding-style-patch-verification: ON
  *
diff --git a/src/vnet/devices/af_packet/device.c b/src/vnet/devices/af_packet/device.c
index b9492b3..2c2489b 100644
--- a/src/vnet/devices/af_packet/device.c
+++ b/src/vnet/devices/af_packet/device.c
@@ -51,7 +51,7 @@
 };
 
 
-static u8 *
+u8 *
 format_af_packet_device_name (u8 * s, va_list * args)
 {
   u32 i = va_arg (*args, u32);
diff --git a/src/vnet/devices/virtio/virtio.c b/src/vnet/devices/virtio/virtio.c
index 02ded3f..aa9db3a 100644
--- a/src/vnet/devices/virtio/virtio.c
+++ b/src/vnet/devices/virtio/virtio.c
@@ -109,6 +109,8 @@
   t.read_function = call_read_ready;
   t.file_descriptor = vring->call_fd;
   t.private_data = vif->dev_instance << 16 | idx;
+  t.description = format (0, "%U vring %u", format_virtio_device_name,
+			  vif->dev_instance, idx);
   vring->call_file_index = clib_file_add (&file_main, &t);
 
   state.index = idx;
diff --git a/src/vnet/devices/virtio/virtio.h b/src/vnet/devices/virtio/virtio.h
index 90eeb53..7ffb2ea 100644
--- a/src/vnet/devices/virtio/virtio.h
+++ b/src/vnet/devices/virtio/virtio.h
@@ -132,6 +132,8 @@
 				 u32 idx);
 extern void virtio_free_used_desc (vlib_main_t * vm, virtio_vring_t * vring);
 
+format_function_t format_virtio_device_name;
+
 #endif /* _VNET_DEVICES_VIRTIO_VIRTIO_H_ */
 
 /*