[dpdk-dev,dpdk-dev,PATCHv6,3/6] virtio: add support for eth_(rxq|txq)_info_get

Message ID 1445292384-19815-4-git-send-email-amine.kherbouche@6wind.com (mailing list archive)
State Changes Requested, archived
Headers

Commit Message

Aminek Kherbouche Oct. 19, 2015, 10:06 p.m. UTC
  In the case of virtio, there are many fields in rte_eth_(tx|rxq)_info
struct that aren't set in this function because those fields are
missed in virtqueue struct.

Signed-off-by: Amine Kherbouche <amine.kherbouche@6wind.com>
---
 drivers/net/virtio/virtio_ethdev.c |   28 ++++++++++++++++++++++++++++
 drivers/net/virtio/virtio_ethdev.h |    4 ++++
 2 files changed, 32 insertions(+)
  

Comments

Jianfeng Tan Oct. 20, 2015, 7:31 a.m. UTC | #1
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Amine Kherbouche
> Sent: Tuesday, October 20, 2015 6:06 AM
> To: dev@dpdk.org
> Cc: amine.kherbouche@6wind.com
> Subject: [dpdk-dev] [dpdk-dev, PATCHv6 3/6] virtio: add support for
> eth_(rxq|txq)_info_get
> 
> In the case of virtio, there are many fields in rte_eth_(tx|rxq)_info struct
> that aren't set in this function because those fields are missed in virtqueue
> struct.
> 
> Signed-off-by: Amine Kherbouche <amine.kherbouche@6wind.com>
> ---
>  drivers/net/virtio/virtio_ethdev.c |   28 ++++++++++++++++++++++++++++
>  drivers/net/virtio/virtio_ethdev.h |    4 ++++
>  2 files changed, 32 insertions(+)
> 
> diff --git a/drivers/net/virtio/virtio_ethdev.c
> b/drivers/net/virtio/virtio_ethdev.c
> index 465d3cd..6118913 100644
> --- a/drivers/net/virtio/virtio_ethdev.c
> +++ b/drivers/net/virtio/virtio_ethdev.c
> @@ -580,6 +580,8 @@ static const struct eth_dev_ops virtio_eth_dev_ops =
> {
>  	.mac_addr_add            = virtio_mac_addr_add,
>  	.mac_addr_remove         = virtio_mac_addr_remove,
>  	.mac_addr_set            = virtio_mac_addr_set,
> +	.rxq_info_get            = virtio_rxq_info_get,
> +	.txq_info_get            = virtio_txq_info_get,
>  };
> 
>  static inline int
> @@ -1574,4 +1576,30 @@ static struct rte_driver rte_virtio_driver = {
>  	.init = rte_virtio_pmd_init,
>  };
> 
> +void
> +virtio_rxq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
> +			struct rte_eth_rxq_info *qinfo)
> +{
> +	struct virtqueue *rxq;
> +
> +	rxq = dev->data->rx_queues[queue_id];
> +
> +	qinfo->nb_desc = rxq->vq_nentries;
> +	qinfo->used_desc = rxq->vq_nentries - rxq->vq_free_cnt;


rxq->vq_free_cnt needs to be masked by rx->vq_nentries here?

Thanks,
Jianfeng

> +	qinfo->free_desc= rxq->vq_free_cnt;
> +}
> +
> +void
> +virtio_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
> +			struct rte_eth_txq_info *qinfo)
> +{
> +	struct virtqueue *txq;
> +
> +	txq = dev->data->tx_queues[queue_id];
> +
> +	qinfo->nb_desc = txq->vq_nentries;
> +	qinfo->used_desc = txq->vq_nentries - txq->vq_free_cnt;
> +	qinfo->free_desc= txq->vq_free_cnt;
> +}
> +
>  PMD_REGISTER_DRIVER(rte_virtio_driver);
> diff --git a/drivers/net/virtio/virtio_ethdev.h
> b/drivers/net/virtio/virtio_ethdev.h
> index 9026d42..1bbe421 100644
> --- a/drivers/net/virtio/virtio_ethdev.h
> +++ b/drivers/net/virtio/virtio_ethdev.h
> @@ -107,7 +107,11 @@ uint16_t virtio_recv_mergeable_pkts(void
> *rx_queue, struct rte_mbuf **rx_pkts,
> 
>  uint16_t virtio_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
>  		uint16_t nb_pkts);
> +void virtio_rxq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
> +                        struct rte_eth_rxq_info *qinfo);
> 
> +void virtio_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
> +                        struct rte_eth_txq_info *qinfo);
> 
>  /*
>   * The VIRTIO_NET_F_GUEST_TSO[46] features permit the host to send us
> --
> 1.7.10.4
  

Patch

diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index 465d3cd..6118913 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -580,6 +580,8 @@  static const struct eth_dev_ops virtio_eth_dev_ops = {
 	.mac_addr_add            = virtio_mac_addr_add,
 	.mac_addr_remove         = virtio_mac_addr_remove,
 	.mac_addr_set            = virtio_mac_addr_set,
+	.rxq_info_get            = virtio_rxq_info_get,
+	.txq_info_get            = virtio_txq_info_get,
 };
 
 static inline int
@@ -1574,4 +1576,30 @@  static struct rte_driver rte_virtio_driver = {
 	.init = rte_virtio_pmd_init,
 };
 
+void
+virtio_rxq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
+			struct rte_eth_rxq_info *qinfo)
+{
+	struct virtqueue *rxq;
+
+	rxq = dev->data->rx_queues[queue_id];
+
+	qinfo->nb_desc = rxq->vq_nentries;
+	qinfo->used_desc = rxq->vq_nentries - rxq->vq_free_cnt;
+	qinfo->free_desc= rxq->vq_free_cnt;
+}
+
+void
+virtio_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
+			struct rte_eth_txq_info *qinfo)
+{
+	struct virtqueue *txq;
+
+	txq = dev->data->tx_queues[queue_id];
+
+	qinfo->nb_desc = txq->vq_nentries;
+	qinfo->used_desc = txq->vq_nentries - txq->vq_free_cnt;
+	qinfo->free_desc= txq->vq_free_cnt;
+}
+
 PMD_REGISTER_DRIVER(rte_virtio_driver);
diff --git a/drivers/net/virtio/virtio_ethdev.h b/drivers/net/virtio/virtio_ethdev.h
index 9026d42..1bbe421 100644
--- a/drivers/net/virtio/virtio_ethdev.h
+++ b/drivers/net/virtio/virtio_ethdev.h
@@ -107,7 +107,11 @@  uint16_t virtio_recv_mergeable_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 
 uint16_t virtio_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 		uint16_t nb_pkts);
+void virtio_rxq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
+                        struct rte_eth_rxq_info *qinfo);
 
+void virtio_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
+                        struct rte_eth_txq_info *qinfo);
 
 /*
  * The VIRTIO_NET_F_GUEST_TSO[46] features permit the host to send us