aboutsummaryrefslogtreecommitdiffstats
path: root/extras
diff options
context:
space:
mode:
authorMohsin Kazmi <sykazmi@cisco.com>2022-07-27 13:43:07 +0000
committerBeno�t Ganne <bganne@cisco.com>2022-08-29 07:07:07 +0000
commit8a34484057895cb583f46915274de71550ac0f2d (patch)
tree22f667548e9feef49543dde83be542b71b37594e /extras
parent6e284ef6ce66d3fa2fdd562dfe7e6ba65bd5a508 (diff)
libmemif: fix the buffer size
Type: fix Previously, libmemif can only use buffer size which have to be power of 2. memif protocol does not enforce this. This patch fixes this issue. Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com> Change-Id: Ic71e6a51685e2c2228c744920797064d4c7c65c9
Diffstat (limited to 'extras')
-rw-r--r--extras/libmemif/src/main.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/extras/libmemif/src/main.c b/extras/libmemif/src/main.c
index 2a4cd817a65..e735ee35fb1 100644
--- a/extras/libmemif/src/main.c
+++ b/extras/libmemif/src/main.c
@@ -1545,7 +1545,6 @@ memif_buffer_alloc (memif_conn_handle_t conn, uint16_t qid,
memif_ring_t *ring = mq->ring;
memif_buffer_t *b0;
uint16_t mask = (1 << mq->log2_ring_size) - 1;
- uint32_t offset_mask = c->run_args.buffer_size - 1;
uint16_t ring_size;
uint16_t ns;
int err = MEMIF_ERR_SUCCESS; /* 0 */
@@ -1620,7 +1619,7 @@ memif_buffer_alloc (memif_conn_handle_t conn, uint16_t qid,
if (ms->get_external_buffer_offset)
d->offset = ms->get_external_buffer_offset (c->private_ctx);
else
- d->offset = d->offset - (d->offset & offset_mask);
+ d->offset = d->offset - (d->offset % c->run_args.buffer_size);
}
b0->data = memif_get_buffer (c, ring, mq->next_buf & mask);
@@ -1666,7 +1665,6 @@ memif_refill_queue (memif_conn_handle_t conn, uint16_t qid, uint16_t count,
memif_queue_t *mq = &c->rx_queues[qid];
memif_ring_t *ring = mq->ring;
uint16_t mask = (1 << mq->log2_ring_size) - 1;
- uint32_t offset_mask = c->run_args.buffer_size - 1;
uint16_t slot, counter = 0;
if (c->args.is_master)
@@ -1692,7 +1690,8 @@ memif_refill_queue (memif_conn_handle_t conn, uint16_t qid, uint16_t count,
if (ms->get_external_buffer_offset)
d->offset = ms->get_external_buffer_offset (c->private_ctx);
else
- d->offset = d->offset - (d->offset & offset_mask) + headroom;
+ d->offset =
+ d->offset - (d->offset % c->run_args.buffer_size) + headroom;
slot++;
counter++;
}
@@ -1723,7 +1722,6 @@ memif_tx_burst (memif_conn_handle_t conn, uint16_t qid,
memif_queue_t *mq = &c->tx_queues[qid];
memif_ring_t *ring = mq->ring;
uint16_t mask = (1 << mq->log2_ring_size) - 1;
- uint32_t offset_mask = c->run_args.buffer_size - 1;
memif_buffer_t *b0;
memif_desc_t *d;
int64_t data_offset;
@@ -1756,7 +1754,7 @@ memif_tx_burst (memif_conn_handle_t conn, uint16_t qid,
if (!c->args.is_master)
{
// reset headroom
- d->offset = d->offset - (d->offset & offset_mask);
+ d->offset = d->offset - (d->offset % c->run_args.buffer_size);
// calculate offset from user data
data_offset = b0->data - (d->offset + c->regions[d->region].addr);
if (data_offset != 0)