-static __rte_always_inline int
-virtio_dev_rx_async_batch_check(struct virtio_net *dev,
- struct vhost_virtqueue *vq,
- struct rte_mbuf **pkts,
- uint64_t *desc_addrs,
- uint64_t *lens)
-{
- bool wrap_counter = vq->avail_wrap_counter;
- struct vring_packed_desc *descs = vq->desc_packed;
- uint16_t avail_idx = vq->last_avail_idx;
- uint16_t used_idx = vq->last_used_idx;
- uint32_t buf_offset = sizeof(struct virtio_net_hdr_mrg_rxbuf);
- uint32_t cpy_threshold = vq->async_threshold;
- uint16_t i;
-
- vhost_for_each_try_unroll(i, 0, PACKED_BATCH_SIZE) {
- if (unlikely(pkts[i]->data_len >= cpy_threshold))
- return -1;
- }
-
- if (unlikely(avail_idx & PACKED_BATCH_MASK))
- return -1;
-
- if (unlikely((avail_idx + PACKED_BATCH_SIZE) > vq->size))
- return -1;
-
- if (unlikely((used_idx + PACKED_BATCH_SIZE) > vq->size))
- return -1;
-
- vhost_for_each_try_unroll(i, 0, PACKED_BATCH_SIZE) {
- if (unlikely(pkts[i]->next != NULL))
- return -1;
- if (unlikely(!desc_is_avail(&descs[avail_idx + i],
- wrap_counter)))
- return -1;
- }
-
- vhost_for_each_try_unroll(i, 0, PACKED_BATCH_SIZE)
- lens[i] = descs[avail_idx + i].len;
-
- vhost_for_each_try_unroll(i, 0, PACKED_BATCH_SIZE) {
- if (unlikely(pkts[i]->pkt_len > (lens[i] - buf_offset)))
- return -1;
- }
-
- vhost_for_each_try_unroll(i, 0, PACKED_BATCH_SIZE)
- desc_addrs[i] = vhost_iova_to_vva(dev, vq,
- descs[avail_idx + i].addr,
- &lens[i],
- VHOST_ACCESS_RW);
-
- vhost_for_each_try_unroll(i, 0, PACKED_BATCH_SIZE) {
- if (unlikely(!desc_addrs[i]))
- return -1;
- if (unlikely(lens[i] != descs[avail_idx + i].len))
- return -1;
- }
-
- return 0;
-}
-