aboutsummaryrefslogtreecommitdiffstats
path: root/extras/libmemif/examples/icmp_responder-mt/main.c
diff options
context:
space:
mode:
authorJakub Grajciar <jgrajcia@cisco.com>2018-03-29 13:15:10 +0200
committerDamjan Marion <dmarion.lists@gmail.com>2018-03-30 20:48:36 +0000
commit3744fc7abce0cf8694d64b670589e35c6d7bf881 (patch)
tree04f5f42458a1ab4f3f4109f890e998221b22e622 /extras/libmemif/examples/icmp_responder-mt/main.c
parent17ddc0fee1bc20d0da84dd70bb579c8844a48ef4 (diff)
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>
Diffstat (limited to 'extras/libmemif/examples/icmp_responder-mt/main.c')
-rw-r--r--extras/libmemif/examples/icmp_responder-mt/main.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/extras/libmemif/examples/icmp_responder-mt/main.c b/extras/libmemif/examples/icmp_responder-mt/main.c
index 4f7733b8072..c4ac907cb53 100644
--- a/extras/libmemif/examples/icmp_responder-mt/main.c
+++ b/extras/libmemif/examples/icmp_responder-mt/main.c
@@ -299,10 +299,6 @@ memif_rx_poll (void *ptr)
data->rx_buf_num += rx;
if (rx == 0)
{
- /* if queue is in polling mode, it's not refilled */
- err = memif_refill_queue (c->conn, data->qid, -1);
- if (err != MEMIF_ERR_SUCCESS)
- INFO ("memif_buffer_free: %s", memif_strerror (err));
continue;
}
@@ -313,7 +309,7 @@ memif_rx_poll (void *ptr)
err =
memif_buffer_alloc (c->conn, data->qid, data->tx_bufs,
- data->rx_buf_num, &tx, 128);
+ data->rx_buf_num, &tx, 0);
if (err != MEMIF_ERR_SUCCESS)
{
INFO ("memif_buffer_alloc: %s", memif_strerror (err));
@@ -334,10 +330,10 @@ memif_rx_poll (void *ptr)
}
/* mark memif buffers and shared memory buffers as free */
- err = memif_refill_queue (c->conn, data->qid, -1);
+ err = memif_refill_queue (c->conn, data->qid, rx, 0);
if (err != MEMIF_ERR_SUCCESS)
INFO ("memif_buffer_free: %s", memif_strerror (err));
- data->rx_buf_num -= rx;
+ data->rx_buf_num -= fb;
DBG ("freed %d buffers. %u/%u alloc/free buffers",
fb, data->rx_buf_num, MAX_MEMIF_BUFS - data->rx_buf_num);
@@ -359,10 +355,10 @@ error:
goto close;
close:
- err = memif_refill_queue (c->conn, data->qid, -1);
+ err = memif_refill_queue (c->conn, data->qid, rx, 0);
if (err != MEMIF_ERR_SUCCESS)
INFO ("memif_buffer_free: %s", memif_strerror (err));
- data->rx_buf_num -= rx;
+ data->rx_buf_num -= fb;
DBG ("freed %d buffers. %u/%u alloc/free buffers",
fb, data->rx_buf_num, MAX_MEMIF_BUFS - data->rx_buf_num);
free (data->rx_bufs);
@@ -443,7 +439,7 @@ memif_rx_interrupt (void *ptr)
err =
memif_buffer_alloc (c->conn, data->qid, data->tx_bufs,
- data->rx_buf_num, &tx, 128);
+ data->rx_buf_num, &tx, 0);
if (err != MEMIF_ERR_SUCCESS)
{
INFO ("memif_buffer_alloc: %s", memif_strerror (err));
@@ -464,10 +460,10 @@ memif_rx_interrupt (void *ptr)
}
/* mark memif buffers and shared memory buffers as free */
- err = memif_refill_queue (c->conn, data->qid, rx);
+ err = memif_refill_queue (c->conn, data->qid, rx, 0);
if (err != MEMIF_ERR_SUCCESS)
INFO ("memif_buffer_free: %s", memif_strerror (err));
- data->rx_buf_num -= rx;
+ data->rx_buf_num -= fb;
DBG ("freed %d buffers. %u/%u alloc/free buffers",
fb, data->rx_buf_num, MAX_MEMIF_BUFS - data->rx_buf_num);
@@ -490,10 +486,10 @@ error:
goto close;
close:
- err = memif_refill_queue (c->conn, data->qid, rx);
+ err = memif_refill_queue (c->conn, data->qid, rx, 0);
if (err != MEMIF_ERR_SUCCESS)
INFO ("memif_buffer_free: %s", memif_strerror (err));
- data->rx_buf_num -= rx;
+ data->rx_buf_num -= fb;
DBG ("freed %d buffers. %u/%u alloc/free buffers",
fb, data->rx_buf_num, MAX_MEMIF_BUFS - data->rx_buf_num);
free (data->rx_bufs);