11 kni_fifo_init(
struct rte_kni_fifo *fifo,
unsigned size)
14 if (size & (size - 1))
15 rte_panic(
"KNI fifo size must be power of 2\n");
20 fifo->elem_size =
sizeof(
void *);
26 static inline unsigned
27 kni_fifo_put(
struct rte_kni_fifo *fifo,
void **data,
unsigned num)
30 unsigned fifo_write = fifo->write;
31 unsigned fifo_read = fifo->read;
32 unsigned new_write = fifo_write;
34 for (i = 0; i < num; i++) {
35 new_write = (new_write + 1) & (fifo->len - 1);
37 if (new_write == fifo_read)
39 fifo->buffer[fifo_write] = data[i];
40 fifo_write = new_write;
42 fifo->write = fifo_write;
49 static inline unsigned
50 kni_fifo_get(
struct rte_kni_fifo *fifo,
void **data,
unsigned num)
53 unsigned new_read = fifo->read;
54 unsigned fifo_write = fifo->write;
55 for (i = 0; i < num; i++) {
56 if (new_read == fifo_write)
59 data[i] = fifo->buffer[new_read];
60 new_read = (new_read + 1) & (fifo->len - 1);
62 fifo->read = new_read;
69 static inline uint32_t
70 kni_fifo_count(
struct rte_kni_fifo *fifo)
72 return (fifo->len + fifo->write - fifo->read) & (fifo->len - 1);