virtio: add packet buffering on tx

Type: feature

This patch adds packet buffering on tx for
slow backend which have some jitter/delays
in freeing the vrings.

There are some limitations to the current design:
1) It only works in poll mode.
2) Atleast 1 rx queue of an interface (with buffering
   enabled) should be placed on each worker and main thread.

Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com>
Change-Id: Ib93c350298b228e80426e58ac77f3bbc93b8be27
diff --git a/src/vnet/devices/virtio/cli.c b/src/vnet/devices/virtio/cli.c
index 6d47bad..8a9c97b 100644
--- a/src/vnet/devices/virtio/cli.c
+++ b/src/vnet/devices/virtio/cli.c
@@ -30,6 +30,7 @@
   unformat_input_t _line_input, *line_input = &_line_input;
   virtio_pci_create_if_args_t args;
   u64 feature_mask = (u64) ~ (0ULL);
+  u32 buffering_size = 0;
 
   /* Get a line of input. */
   if (!unformat_user (input, unformat_line_input, line_input))
@@ -46,6 +47,12 @@
 	args.gso_enabled = 1;
       else if (unformat (line_input, "csum-enabled"))
 	args.checksum_offload_enabled = 1;
+      else if (unformat (line_input, "buffering"))
+	{
+	  args.virtio_flags = VIRTIO_FLAG_BUFFERING;
+	  if (unformat (line_input, "size %u", &buffering_size))
+	    args.buffering_size = buffering_size;
+	}
       else
 	return clib_error_return (0, "unknown input `%U'",
 				  format_unformat_error, input);
@@ -61,7 +68,8 @@
 VLIB_CLI_COMMAND (virtio_pci_create_command, static) = {
   .path = "create interface virtio",
   .short_help = "create interface virtio <pci-address> "
-                "[feature-mask <hex-mask>] [gso-enabled] [csum-enabled]",
+                "[feature-mask <hex-mask>] [gso-enabled] [csum-enabled] "
+		"[buffering [size <buffering-szie>]]",
   .function = virtio_pci_create_command_fn,
 };
 /* *INDENT-ON* */