diff options
author | Mohsin Kazmi <sykazmi@cisco.com> | 2022-07-27 15:04:01 +0000 |
---|---|---|
committer | Beno�t Ganne <bganne@cisco.com> | 2022-08-29 07:05:23 +0000 |
commit | 6e284ef6ce66d3fa2fdd562dfe7e6ba65bd5a508 (patch) | |
tree | a6e647ffb5e6763746d1dfbd398d1285eb887ae1 /extras/libmemif/examples/common | |
parent | a01be735f25a9a4596d3f67ef71a094e601e8b65 (diff) |
libmemif: add support for custom buffer-size and headroom in icmp example app
Type: improvement
Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com>
Change-Id: I2bdaee7938a3747e3217d6901ec3c66f1ee3da61
Diffstat (limited to 'extras/libmemif/examples/common')
-rw-r--r-- | extras/libmemif/examples/common/common.h | 6 | ||||
-rw-r--r-- | extras/libmemif/examples/common/responder.c | 12 |
2 files changed, 11 insertions, 7 deletions
diff --git a/extras/libmemif/examples/common/common.h b/extras/libmemif/examples/common/common.h index ce4ead2d253..3538e39e23b 100644 --- a/extras/libmemif/examples/common/common.h +++ b/extras/libmemif/examples/common/common.h @@ -78,6 +78,10 @@ typedef struct memif_connection uint8_t ip_addr[4]; /* interface hw address */ uint8_t hw_addr[6]; + /* buffer size */ + uint16_t buffer_size; + /* headroom size */ + uint16_t headroom_size; } memif_connection_t; void print_version (); @@ -113,4 +117,4 @@ int basic_packet_handler (memif_connection_t *conn); /* ICMPv4 and ARP handler */ int icmp_packet_handler (memif_connection_t *conn); -#endif /* COMMON_H */
\ No newline at end of file +#endif /* COMMON_H */ diff --git a/extras/libmemif/examples/common/responder.c b/extras/libmemif/examples/common/responder.c index e0fa9e35b08..3edf91125dd 100644 --- a/extras/libmemif/examples/common/responder.c +++ b/extras/libmemif/examples/common/responder.c @@ -19,7 +19,7 @@ responder (memif_conn_handle_t conn, void *private_ctx, uint16_t qid) { /* allocate tx buffers */ err = memif_buffer_alloc (conn, qid, c->tx_bufs, c->rx_buf_num, - &c->tx_buf_num, 2048); + &c->tx_buf_num, c->buffer_size); /* suppress full ring error MEMIF_ERR_NOBUF_RING */ if (err != MEMIF_ERR_SUCCESS && err != MEMIF_ERR_NOBUF_RING) { @@ -42,7 +42,7 @@ responder (memif_conn_handle_t conn, void *private_ctx, uint16_t qid) /* Done processing packets */ /* refill the queue */ - err = memif_refill_queue (conn, qid, c->tx_buf_num, 0); + err = memif_refill_queue (conn, qid, c->tx_buf_num, c->headroom_size); if (err != MEMIF_ERR_SUCCESS) { INFO ("memif_refill_queue: %s", memif_strerror (err)); @@ -70,7 +70,7 @@ responder (memif_conn_handle_t conn, void *private_ctx, uint16_t qid) return 0; error: - err = memif_refill_queue (conn, qid, c->rx_buf_num, 0); + err = memif_refill_queue (conn, qid, c->rx_buf_num, c->headroom_size); if (err != MEMIF_ERR_SUCCESS) { INFO ("memif_refill_queue: %s", memif_strerror (err)); @@ -130,7 +130,7 @@ responder_zero_copy (memif_conn_handle_t conn, void *private_ctx, uint16_t qid) } /* refill the queue */ - err = memif_refill_queue (conn, qid, tx, 0); + err = memif_refill_queue (conn, qid, tx, c->headroom_size); if (err != MEMIF_ERR_SUCCESS) { INFO ("memif_refill_queue: %s", memif_strerror (err)); @@ -160,7 +160,7 @@ responder_zero_copy (memif_conn_handle_t conn, void *private_ctx, uint16_t qid) return 0; error: - err = memif_refill_queue (conn, qid, c->rx_buf_num, 0); + err = memif_refill_queue (conn, qid, c->rx_buf_num, c->headroom_size); if (err != MEMIF_ERR_SUCCESS) { INFO ("memif_refill_queue: %s", memif_strerror (err)); @@ -169,4 +169,4 @@ error: c->rx_buf_num = 0; return -1; -}
\ No newline at end of file +} |