From: Jianfeng Tan Date: Tue, 17 Jan 2017 07:10:23 +0000 (+0000) Subject: net/virtio: add Rx descriptor check X-Git-Tag: spdx-start~5154 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=b0caba1a1378fe95cf8c221850cc5556539f9d6b;p=dpdk.git net/virtio: add Rx descriptor check Under interrupt mode, rx_descriptor_done is used as an indicator for applications to check if some number of packets are ready to be received. This patch enables this by checking used ring's local consumed idx with shared (with backend) idx. Signed-off-by: Jianfeng Tan Tested-by: Lei Yao Acked-by: Yuanhan Liu --- diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index 6e6eaca50a..05cbd1d6c3 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -739,6 +739,7 @@ static const struct eth_dev_ops virtio_eth_dev_ops = { .link_update = virtio_dev_link_update, .rx_queue_setup = virtio_dev_rx_queue_setup, .rx_queue_release = virtio_dev_queue_release, + .rx_descriptor_done = virtio_dev_rx_queue_done, .tx_queue_setup = virtio_dev_tx_queue_setup, .tx_queue_release = virtio_dev_queue_release, /* collect stats per queue */ diff --git a/drivers/net/virtio/virtio_ethdev.h b/drivers/net/virtio/virtio_ethdev.h index 4feccf939b..777a14be0b 100644 --- a/drivers/net/virtio/virtio_ethdev.h +++ b/drivers/net/virtio/virtio_ethdev.h @@ -83,6 +83,9 @@ void virtio_dev_cq_start(struct rte_eth_dev *dev); /* * RX/TX function prototypes */ + +int virtio_dev_rx_queue_done(void *rxq, uint16_t offset); + int virtio_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id, uint16_t nb_rx_desc, unsigned int socket_id, const struct rte_eth_rxconf *rx_conf, diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c index 1e5a6b932d..b29565e590 100644 --- a/drivers/net/virtio/virtio_rxtx.c +++ b/drivers/net/virtio/virtio_rxtx.c @@ -72,6 +72,15 @@ #define VIRTIO_SIMPLE_FLAGS ((uint32_t)ETH_TXQ_FLAGS_NOMULTSEGS | \ ETH_TXQ_FLAGS_NOOFFLOADS) +int +virtio_dev_rx_queue_done(void *rxq, uint16_t offset) +{ + struct virtnet_rx *rxvq = rxq; + struct virtqueue *vq = rxvq->vq; + + return VIRTQUEUE_NUSED(vq) >= offset; +} + static void vq_ring_free_chain(struct virtqueue *vq, uint16_t desc_idx) {