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
This commit is contained in:

committed by
Damjan Marion

parent
47e68de222
commit
0dea94b45a
@ -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 */
|
||||
}
|
||||
|
Reference in New Issue
Block a user