[dpdk-dev] [PATCH 08/17] net/virtio: implement receive path for packed queues
Tiwei Bie
tiwei.bie at intel.com
Mon Mar 19 11:15:49 CET 2018
On Fri, Mar 16, 2018 at 04:21:11PM +0100, Jens Freimann wrote:
[...]
> diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
> index 722a2cd..888cc49 100644
> --- a/drivers/net/virtio/virtio_ethdev.c
> +++ b/drivers/net/virtio/virtio_ethdev.c
> @@ -1352,6 +1352,8 @@ static int virtio_dev_xstats_get_names(struct rte_eth_dev *dev,
> PMD_INIT_LOG(INFO, "virtio: using simple Rx path on port %u",
> eth_dev->data->port_id);
> eth_dev->rx_pkt_burst = virtio_recv_pkts_vec;
> + } else if (vtpci_packed_queue(hw)) {
> + eth_dev->rx_pkt_burst = &virtio_recv_pkts_packed;
If MRG_RXBUF isn't supported at this point, then we will
need to make sure that RING_PACKED and MRG_RXBUF won't be
negotiated at the same time. Otherwise this commit will
break the driver.
> } else if (vtpci_with_feature(hw, VIRTIO_NET_F_MRG_RXBUF)) {
> PMD_INIT_LOG(INFO,
> "virtio: using mergeable buffer Rx path on port %u",
> @@ -1507,7 +1509,8 @@ static int virtio_dev_xstats_get_names(struct rte_eth_dev *dev,
>
> /* Setting up rx_header size for the device */
> if (vtpci_with_feature(hw, VIRTIO_NET_F_MRG_RXBUF) ||
> - vtpci_with_feature(hw, VIRTIO_F_VERSION_1))
> + vtpci_with_feature(hw, VIRTIO_F_VERSION_1) ||
> + vtpci_with_feature(hw, VIRTIO_F_RING_PACKED))
> hw->vtnet_hdr_size = sizeof(struct virtio_net_hdr_mrg_rxbuf);
> else
> hw->vtnet_hdr_size = sizeof(struct virtio_net_hdr);
[...]
> #ifdef RTE_LIBRTE_VIRTIO_DEBUG_DUMP
> #define VIRTIO_DUMP_PACKET(m, len) rte_pktmbuf_dump(stdout, m, len)
> @@ -428,6 +429,34 @@
>
> PMD_INIT_FUNC_TRACE();
>
> + if (vtpci_packed_queue(hw)) {
> + struct vring_desc_packed *desc;
> + struct vq_desc_extra *dxp;
> +
> + for (desc_idx = 0; desc_idx < vq->vq_nentries;
> + desc_idx++) {
> + m = rte_mbuf_raw_alloc(rxvq->mpool);
> + if (unlikely(m == NULL))
> + return -ENOMEM;
> +
> + dxp = &vq->vq_descx[desc_idx];
> + dxp->cookie = m;
> + dxp->ndescs = 1;
> +
> + desc = &vq->vq_ring.desc_packed[desc_idx];
> + desc->addr = VIRTIO_MBUF_ADDR(m, vq) +
> + RTE_PKTMBUF_HEADROOM - hw->vtnet_hdr_size;
> + desc->len = m->buf_len - RTE_PKTMBUF_HEADROOM +
> + hw->vtnet_hdr_size;
> + desc->flags |= VRING_DESC_F_WRITE;
> + rte_smp_wmb();
> + set_desc_avail(&vq->vq_ring, desc);
> + }
> + toggle_wrap_counter(&vq->vq_ring);
> +
> + return 0;
Maybe it's better to give the debug code (which is at the
end of this function) a chance to run.
Thanks
More information about the dev
mailing list