libmemif: zero-copy-slave mode + header space

Slave is now able to dequeue buffers from rx queue and enqueue them to tx queue
(zero-copy operation). Slave can produce buffers with headroom, which will allow adding
 encap without copy.

Change-Id: Ia189f8de1a68be787545ed46cf78d36403e7e9bf
Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com>
diff --git a/extras/libmemif/examples/icmp_responder-epoll/main.c b/extras/libmemif/examples/icmp_responder-epoll/main.c
index 1dab51f..fd354a3 100644
--- a/extras/libmemif/examples/icmp_responder-epoll/main.c
+++ b/extras/libmemif/examples/icmp_responder-epoll/main.c
@@ -282,6 +282,7 @@
 on_connect (memif_conn_handle_t conn, void *private_ctx)
 {
   INFO ("memif connected!");
+  memif_refill_queue (conn, 0, -1, 0);
   enable_log = 1;
   return 0;
 }
@@ -384,6 +385,7 @@
 	}
 
       i = 0;
+      memset (c->tx_bufs, 0, sizeof (memif_buffer_t) * rx);
       err = memif_buffer_alloc (c->conn, qid, c->tx_bufs, rx, &tx, 128);
       if ((err != MEMIF_ERR_SUCCESS) && (err != MEMIF_ERR_NOBUF_RING))
 	{
@@ -404,7 +406,7 @@
 	  tx--;
 	}
 
-      err = memif_refill_queue (c->conn, qid, rx);
+      err = memif_refill_queue (c->conn, qid, rx, 0);
       if (err != MEMIF_ERR_SUCCESS)
 	INFO ("memif_buffer_free: %s", memif_strerror (err));
       rx -= rx;
@@ -426,7 +428,7 @@
   return 0;
 
 error:
-  err = memif_refill_queue (c->conn, qid, rx);
+  err = memif_refill_queue (c->conn, qid, rx, 0);
   if (err != MEMIF_ERR_SUCCESS)
     INFO ("memif_buffer_free: %s", memif_strerror (err));
   c->rx_buf_num -= rx;
@@ -512,7 +514,7 @@
 	    }
 	  /* mark memif buffers and shared memory buffers as free */
 	  /* free processed buffers */
-	  err = memif_refill_queue (c->conn, qid, j);
+	  err = memif_refill_queue (c->conn, qid, j, 0);
 	  if (err != MEMIF_ERR_SUCCESS)
 	    INFO ("memif_buffer_free: %s", memif_strerror (err));
 	  rx -= j;
@@ -538,7 +540,7 @@
   return 0;
 
 error:
-  err = memif_refill_queue (c->conn, qid, rx);
+  err = memif_refill_queue (c->conn, qid, rx, 0);
   if (err != MEMIF_ERR_SUCCESS)
     INFO ("memif_buffer_free: %s", memif_strerror (err));
   c->rx_buf_num -= rx;
@@ -595,7 +597,7 @@
 	    }
 	}
 
-      err = memif_refill_queue (c->conn, qid, rx);
+      err = memif_refill_queue (c->conn, qid, rx, 0);
       if (err != MEMIF_ERR_SUCCESS)
 	INFO ("memif_buffer_free: %s", memif_strerror (err));
       c->rx_buf_num -= rx;
@@ -607,7 +609,7 @@
   return 0;
 
 error:
-  err = memif_refill_queue (c->conn, qid, rx);
+  err = memif_refill_queue (c->conn, qid, rx, 0);
   if (err != MEMIF_ERR_SUCCESS)
     INFO ("memif_buffer_free: %s", memif_strerror (err));
   c->rx_buf_num -= rx;