aboutsummaryrefslogtreecommitdiffstats
path: root/extras/libmemif/examples/icmp_responder/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/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/main.c')
-rw-r--r--extras/libmemif/examples/icmp_responder/main.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/extras/libmemif/examples/icmp_responder/main.c b/extras/libmemif/examples/icmp_responder/main.c
index b820ad3b12d..5e78acd3537 100644
--- a/extras/libmemif/examples/icmp_responder/main.c
+++ b/extras/libmemif/examples/icmp_responder/main.c
@@ -225,7 +225,7 @@ icmpr_buffer_alloc (long n, uint16_t qid)
int err;
uint16_t r;
/* set data pointer to shared memory and set buffer_len to shared mmeory buffer len */
- err = memif_buffer_alloc (c->conn, qid, c->tx_bufs, n, &r, 128);
+ err = memif_buffer_alloc (c->conn, qid, c->tx_bufs, n, &r, 0);
if (err != MEMIF_ERR_SUCCESS)
{
INFO ("memif_buffer_alloc: %s", memif_strerror (err));
@@ -311,24 +311,25 @@ on_interrupt (memif_conn_handle_t conn, void *private_ctx, uint16_t qid)
&(c->tx_bufs + i)->len, c->ip_addr);
}
+ uint16_t fb;
/* mark memif buffers and shared memory buffers as free */
- err = memif_refill_queue (c->conn, qid, rx);
- c->rx_buf_num -= rx;
+ err = memif_refill_queue (c->conn, qid, rx, 0);
+ c->rx_buf_num -= fb;
DBG ("freed %d buffers. %u/%u alloc/free buffers",
- rx, c->rx_buf_num, MAX_MEMIF_BUFS - c->rx_buf_num);
+ fb, c->rx_buf_num, MAX_MEMIF_BUFS - c->rx_buf_num);
icmpr_tx_burst (c->tx_qid);
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;
+ c->rx_buf_num -= fb;
DBG ("freed %d buffers. %u/%u alloc/free buffers",
- rx, c->rx_buf_num, MAX_MEMIF_BUFS - c->rx_buf_num);
+ fb, c->rx_buf_num, MAX_MEMIF_BUFS - c->rx_buf_num);
return 0;
}