| 3558 | } |
| 3559 | |
| 3560 | uint16_t |
| 3561 | rte_vhost_dequeue_burst(int vid, uint16_t queue_id, |
| 3562 | struct rte_mempool *mbuf_pool, struct rte_mbuf **pkts, uint16_t count) |
| 3563 | { |
| 3564 | struct virtio_net *dev; |
| 3565 | struct rte_mbuf *rarp_mbuf = NULL; |
| 3566 | struct vhost_virtqueue *vq; |
| 3567 | int16_t success = 1; |
| 3568 | |
| 3569 | dev = get_device(vid); |
| 3570 | if (!dev) |
| 3571 | return 0; |
| 3572 | |
| 3573 | if (unlikely(!(dev->flags & VIRTIO_DEV_BUILTIN_VIRTIO_NET))) { |
| 3574 | VHOST_LOG_DATA(dev->ifname, ERR, |
| 3575 | "%s: built-in vhost net backend is disabled.\n", |
| 3576 | __func__); |
| 3577 | return 0; |
| 3578 | } |
| 3579 | |
| 3580 | if (unlikely(!is_valid_virt_queue_idx(queue_id, 1, dev->nr_vring))) { |
| 3581 | VHOST_LOG_DATA(dev->ifname, ERR, |
| 3582 | "%s: invalid virtqueue idx %d.\n", |
| 3583 | __func__, queue_id); |
| 3584 | return 0; |
| 3585 | } |
| 3586 | |
| 3587 | vq = dev->virtqueue[queue_id]; |
| 3588 | |
| 3589 | if (unlikely(rte_rwlock_read_trylock(&vq->access_lock) != 0)) |
| 3590 | return 0; |
| 3591 | |
| 3592 | if (unlikely(!vq->enabled)) { |
| 3593 | count = 0; |
| 3594 | goto out_access_unlock; |
| 3595 | } |
| 3596 | |
| 3597 | vhost_user_iotlb_rd_lock(vq); |
| 3598 | |
| 3599 | if (unlikely(!vq->access_ok)) { |
| 3600 | vhost_user_iotlb_rd_unlock(vq); |
| 3601 | rte_rwlock_read_unlock(&vq->access_lock); |
| 3602 | |
| 3603 | virtio_dev_vring_translate(dev, vq); |
| 3604 | |
| 3605 | count = 0; |
| 3606 | goto out_no_unlock; |
| 3607 | } |
| 3608 | |
| 3609 | /* |
| 3610 | * Construct a RARP broadcast packet, and inject it to the "pkts" |
| 3611 | * array, to looks like that guest actually send such packet. |
| 3612 | * |
| 3613 | * Check user_send_rarp() for more information. |
| 3614 | * |
| 3615 | * broadcast_rarp shares a cacheline in the virtio_net structure |
| 3616 | * with some fields that are accessed during enqueue and |
| 3617 | * rte_atomic_compare_exchange_strong_explicit causes a write if performed compare |
no test coverage detected