diff options
author | Jakub Grajciar <jgrajcia@cisco.com> | 2021-01-26 07:38:30 +0100 |
---|---|---|
committer | Damjan Marion <dmarion@me.com> | 2021-02-05 16:20:52 +0000 |
commit | 0dea94b45ad025da9289eff81e538480031d64c4 (patch) | |
tree | 45a54cffb20e552403eacc3129c168759308ef98 /extras | |
parent | 47e68de222f16b5b6738fcb235750ca9d8dc82a1 (diff) |
libmemif: fix memif_refill_queue
Fix arithmetic error in memif_refill_queue., where
some of the buffers didn't get properly refilled.
Type: fix
Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com>
Change-Id: I9815a8ac9b899216581452c352e75e2a0454cbce
Diffstat (limited to 'extras')
-rw-r--r-- | extras/libmemif/src/main.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/extras/libmemif/src/main.c b/extras/libmemif/src/main.c index 0644f948c31..0c52169a155 100644 --- a/extras/libmemif/src/main.c +++ b/extras/libmemif/src/main.c @@ -2436,7 +2436,7 @@ memif_refill_queue (memif_conn_handle_t conn, uint16_t qid, uint16_t count, 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; + uint16_t slot, counter = 0; if (c->args.is_master) { @@ -2448,12 +2448,12 @@ memif_refill_queue (memif_conn_handle_t conn, uint16_t qid, uint16_t count, } uint16_t head = ring->head; + slot = head; uint16_t ns = (1 << mq->log2_ring_size) - head + mq->last_tail; - head += (count < ns) ? count : ns; + count = (count < ns) ? count : ns; - slot = ring->head; memif_desc_t *d; - while (slot < head) + while (counter < count) { d = &ring->desc[slot & mask]; d->region = 1; @@ -2463,10 +2463,11 @@ memif_refill_queue (memif_conn_handle_t conn, uint16_t qid, uint16_t count, else d->offset = d->offset - (d->offset & offset_mask) + headroom; slot++; + counter++; } MEMIF_MEMORY_BARRIER (); - ring->head = head; + ring->head = slot; return MEMIF_ERR_SUCCESS; /* 0 */ } |