summaryrefslogtreecommitdiffstats
path: root/extras/libmemif/examples/icmp_responder-epoll
diff options
context:
space:
mode:
authorJakub Grajciar <jgrajcia@cisco.com>2018-08-20 14:26:32 +0200
committerDamjan Marion <dmarion@me.com>2018-08-30 12:35:46 +0000
commit93a5dd17232e42bea2fc9dcf59c652a9da31b2b3 (patch)
tree9f3c1b69bb96cc65353b468f8264204ca493913f /extras/libmemif/examples/icmp_responder-epoll
parent43b06063015abfa42bc9c5ab925cd6b7ea3cbf42 (diff)
libmemif: external region support
region 0: descriptors region 1: buffers (external) Change-Id: Ia728967817b4c78bc00f8eed44606d0c5bc386b0 Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com>
Diffstat (limited to 'extras/libmemif/examples/icmp_responder-epoll')
-rw-r--r--extras/libmemif/examples/icmp_responder-epoll/main.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/extras/libmemif/examples/icmp_responder-epoll/main.c b/extras/libmemif/examples/icmp_responder-epoll/main.c
index fd354a38aaf..70095ddfed5 100644
--- a/extras/libmemif/examples/icmp_responder-epoll/main.c
+++ b/extras/libmemif/examples/icmp_responder-epoll/main.c
@@ -86,6 +86,8 @@
#define MAX_MEMIF_BUFS 256
#define MAX_CONNS 50
+#define ICMPR_HEADROOM 64
+
int epfd;
int out_fd;
uint8_t enable_log;
@@ -282,7 +284,7 @@ int
on_connect (memif_conn_handle_t conn, void *private_ctx)
{
INFO ("memif connected!");
- memif_refill_queue (conn, 0, -1, 0);
+ memif_refill_queue (conn, 0, -1, ICMPR_HEADROOM);
enable_log = 1;
return 0;
}
@@ -406,13 +408,12 @@ on_interrupt (memif_conn_handle_t conn, void *private_ctx, uint16_t qid)
tx--;
}
- err = memif_refill_queue (c->conn, qid, rx, 0);
+ err = memif_refill_queue (c->conn, qid, rx, ICMPR_HEADROOM);
if (err != MEMIF_ERR_SUCCESS)
INFO ("memif_buffer_free: %s", memif_strerror (err));
rx -= rx;
- DBG ("freed %d buffers. %u/%u alloc/free buffers",
- rx, rx, MAX_MEMIF_BUFS - rx);
+ DBG ("%u/%u alloc/free buffers", rx, MAX_MEMIF_BUFS - rx);
err = memif_tx_burst (c->conn, qid, c->tx_bufs, j, &tx);
if (err != MEMIF_ERR_SUCCESS)
@@ -428,7 +429,7 @@ on_interrupt (memif_conn_handle_t conn, void *private_ctx, uint16_t qid)
return 0;
error:
- err = memif_refill_queue (c->conn, qid, rx, 0);
+ err = memif_refill_queue (c->conn, qid, rx, ICMPR_HEADROOM);
if (err != MEMIF_ERR_SUCCESS)
INFO ("memif_buffer_free: %s", memif_strerror (err));
c->rx_buf_num -= rx;
@@ -514,7 +515,7 @@ on_interrupt0 (memif_conn_handle_t conn, void *private_ctx, uint16_t qid)
}
/* mark memif buffers and shared memory buffers as free */
/* free processed buffers */
- err = memif_refill_queue (c->conn, qid, j, 0);
+ err = memif_refill_queue (c->conn, qid, j, ICMPR_HEADROOM);
if (err != MEMIF_ERR_SUCCESS)
INFO ("memif_buffer_free: %s", memif_strerror (err));
rx -= j;
@@ -540,7 +541,7 @@ on_interrupt0 (memif_conn_handle_t conn, void *private_ctx, uint16_t qid)
return 0;
error:
- err = memif_refill_queue (c->conn, qid, rx, 0);
+ err = memif_refill_queue (c->conn, qid, rx, ICMPR_HEADROOM);
if (err != MEMIF_ERR_SUCCESS)
INFO ("memif_buffer_free: %s", memif_strerror (err));
c->rx_buf_num -= rx;
@@ -597,7 +598,7 @@ on_interrupt1 (memif_conn_handle_t conn, void *private_ctx, uint16_t qid)
}
}
- err = memif_refill_queue (c->conn, qid, rx, 0);
+ err = memif_refill_queue (c->conn, qid, rx, ICMPR_HEADROOM);
if (err != MEMIF_ERR_SUCCESS)
INFO ("memif_buffer_free: %s", memif_strerror (err));
c->rx_buf_num -= rx;
@@ -609,7 +610,7 @@ on_interrupt1 (memif_conn_handle_t conn, void *private_ctx, uint16_t qid)
return 0;
error:
- err = memif_refill_queue (c->conn, qid, rx, 0);
+ err = memif_refill_queue (c->conn, qid, rx, ICMPR_HEADROOM);
if (err != MEMIF_ERR_SUCCESS)
INFO ("memif_buffer_free: %s", memif_strerror (err));
c->rx_buf_num -= rx;
@@ -992,6 +993,7 @@ icmpr_send_proc (void *data)
count -= tx;
}
timespec_get (&end, TIME_UTC);
+ printf ("\n\n");
INFO ("Pakcet sequence finished!");
INFO ("Seq len: %u", seq);
uint64_t t1 = end.tv_sec - start.tv_sec;
@@ -1297,7 +1299,7 @@ main ()
/* if valid callback is passed as argument, fd event polling will be done by user
all file descriptors and events will be passed to user in this callback */
/* if callback is set to NULL libmemif will handle fd event polling */
- err = memif_init (control_fd_update, APP_NAME, NULL, NULL);
+ err = memif_init (control_fd_update, APP_NAME, NULL, NULL, NULL);
if (err != MEMIF_ERR_SUCCESS)
{
INFO ("memif_init: %s", memif_strerror (err));