40 kni_fifo_init(
struct rte_kni_fifo *fifo,
unsigned size)
43 if (size & (size - 1))
44 rte_panic(
"KNI fifo size must be power of 2\n");
49 fifo->elem_size =
sizeof(
void *);
55 static inline unsigned
56 kni_fifo_put(
struct rte_kni_fifo *fifo,
void **data,
unsigned num)
59 unsigned fifo_write = fifo->write;
60 unsigned fifo_read = fifo->read;
61 unsigned new_write = fifo_write;
63 for (i = 0; i < num; i++) {
64 new_write = (new_write + 1) & (fifo->len - 1);
66 if (new_write == fifo_read)
68 fifo->buffer[fifo_write] = data[i];
69 fifo_write = new_write;
71 fifo->write = fifo_write;
78 static inline unsigned
79 kni_fifo_get(
struct rte_kni_fifo *fifo,
void **data,
unsigned num)
82 unsigned new_read = fifo->read;
83 unsigned fifo_write = fifo->write;
84 for (i = 0; i < num; i++) {
85 if (new_read == fifo_write)
88 data[i] = fifo->buffer[new_read];
89 new_read = (new_read + 1) & (fifo->len - 1);
91 fifo->read = new_read;