{
unsigned i = 0;
unsigned fifo_write = fifo->write;
- unsigned fifo_read = fifo->read;
unsigned new_write = fifo_write;
+ rte_smp_rmb();
+ unsigned fifo_read = fifo->read;
for (i = 0; i < num; i++) {
new_write = (new_write + 1) & (fifo->len - 1);
fifo->buffer[fifo_write] = data[i];
fifo_write = new_write;
}
+ rte_smp_wmb();
fifo->write = fifo_write;
return i;
}
{
unsigned i = 0;
unsigned new_read = fifo->read;
+ rte_smp_rmb();
unsigned fifo_write = fifo->write;
+
for (i = 0; i < num; i++) {
if (new_read == fifo_write)
break;
data[i] = fifo->buffer[new_read];
new_read = (new_read + 1) & (fifo->len - 1);
}
+ rte_smp_rmb();
fifo->read = new_read;
return i;
}
static inline uint32_t
kni_fifo_count(struct rte_kni_fifo *fifo)
{
- return (fifo->len + fifo->write - fifo->read) & (fifo->len - 1);
+ unsigned fifo_write = fifo->write;
+ rte_smp_rmb();
+ unsigned fifo_read = fifo->read;
+ return (fifo->len + fifo_write - fifo_read) & (fifo->len - 1);
}