int head;
struct vring_packed_desc *desc = vq->ring_packed.desc_packed;
struct virtio_pmd_ctrl *result;
- int wrap_counter;
+ bool avail_wrap_counter, used_wrap_counter;
uint16_t flags;
int sum = 0;
int k;
* One RX packet for ACK.
*/
head = vq->vq_avail_idx;
- wrap_counter = vq->avail_wrap_counter;
+ avail_wrap_counter = vq->avail_wrap_counter;
+ used_wrap_counter = vq->used_wrap_counter;
desc[head].flags = VRING_DESC_F_NEXT;
desc[head].addr = cvq->virtio_net_hdr_mem;
desc[head].len = sizeof(struct virtio_net_ctrl_hdr);
VRING_DESC_F_USED(!vq->avail_wrap_counter);
desc[vq->vq_avail_idx].flags = flags;
flags = VRING_DESC_F_NEXT;
- flags |= VRING_DESC_F_AVAIL(wrap_counter) |
- VRING_DESC_F_USED(!wrap_counter);
+ flags |= VRING_DESC_F_AVAIL(avail_wrap_counter) |
+ VRING_DESC_F_USED(!avail_wrap_counter);
desc[head].flags = flags;
rte_smp_wmb();
do {
rte_rmb();
usleep(100);
- } while (!desc_is_used(&desc[head], vq));
+ } while (!__desc_is_used(&desc[head], used_wrap_counter));
/* now get used descriptors */
while (desc_is_used(&desc[vq->vq_used_cons_idx], vq)) {
};
static inline int
-desc_is_used(struct vring_packed_desc *desc, struct virtqueue *vq)
+__desc_is_used(struct vring_packed_desc *desc, bool wrap_counter)
{
uint16_t used, avail, flags;
used = !!(flags & VRING_DESC_F_USED(1));
avail = !!(flags & VRING_DESC_F_AVAIL(1));
- return avail == used && used == vq->used_wrap_counter;
+ return avail == used && used == wrap_counter;
+}
+
+static inline int
+desc_is_used(struct vring_packed_desc *desc, struct virtqueue *vq)
+{
+ return __desc_is_used(desc, vq->used_wrap_counter);
}