Signed-off-by: Tiwei Bie <tiwei....@intel.com> --- drivers/net/virtio/virtio_rxtx.c | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-)
diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c index 93d564f..3dc5eaf 100644 --- a/drivers/net/virtio/virtio_rxtx.c +++ b/drivers/net/virtio/virtio_rxtx.c @@ -299,9 +299,6 @@ virtqueue_enqueue_recv_refill_1_1(struct virtqueue *vq, struct rte_mbuf *cookie) vq->vq_free_cnt -= needed; - rte_smp_wmb(); - desc[idx].flags |= DESC_HW; - return 0; } @@ -381,6 +378,7 @@ virtio_dev_rx_queue_setup(struct rte_eth_dev *dev, int error, nbufs; struct rte_mbuf *m; uint16_t desc_idx; + uint16_t head_idx; PMD_INIT_FUNC_TRACE(); @@ -418,6 +416,8 @@ virtio_dev_rx_queue_setup(struct rte_eth_dev *dev, &rxvq->fake_mbuf; } + head_idx = vq->vq_desc_head_idx; + while (!virtqueue_full(vq)) { m = rte_mbuf_raw_alloc(rxvq->mpool); if (m == NULL) @@ -438,6 +438,14 @@ virtio_dev_rx_queue_setup(struct rte_eth_dev *dev, if (!vtpci_version_1_1(hw)) vq_update_avail_idx(vq); + else { + struct vring_desc_1_1 *desc = vq->vq_ring.desc_1_1; + int i; + for (i = 0; i < nbufs; i++) { + desc[head_idx & (vq->vq_nentries - 1)].flags |= DESC_HW; + head_idx++; + } + } PMD_INIT_LOG(DEBUG, "Allocated %d bufs", nbufs); @@ -701,6 +709,7 @@ virtio_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) uint32_t hdr_size; int offload; struct virtio_net_hdr *hdr; + uint16_t head_idx, idx; nb_rx = 0; if (unlikely(hw->started == 0)) @@ -774,8 +783,11 @@ virtio_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) rxvq->stats.packets += nb_rx; + head_idx = vq->vq_desc_head_idx; + /* Allocate new mbuf for the used descriptor */ error = ENOSPC; + int count = 0; while (likely(!virtqueue_full(vq))) { new_mbuf = rte_mbuf_raw_alloc(rxvq->mpool); if (unlikely(new_mbuf == NULL)) { @@ -790,9 +802,21 @@ virtio_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) break; } nb_enqueued++; + count++; } - if (likely(nb_enqueued) && !vtpci_version_1_1(hw)) { + if (vtpci_version_1_1(hw)) { + struct vring_desc_1_1 *desc = vq->vq_ring.desc_1_1; + if (count > 0) { + rte_smp_wmb(); + idx = head_idx + 1; + while (--count) { + desc[idx & (vq->vq_nentries - 1)].flags |= DESC_HW; + idx++; + } + desc[head_idx & (vq->vq_nentries - 1)].flags |= DESC_HW; + } + } else if (likely(nb_enqueued)) { vq_update_avail_idx(vq); if (unlikely(virtqueue_kick_prepare(vq))) { -- 2.7.4