DPDK patches and discussions
 help / color / mirror / Atom feed
From: Hengqi Chen <hengqi.chen@gmail.com>
To: dev@dpdk.org
Cc: Hengqi Chen <hengqi.chen@gmail.com>,
	Maxime Coquelin <maxime.coquelin@redhat.com>,
	Chenbo Xia <chenbox@nvidia.com>
Subject: [PATCH] net/virtio: Implement {rxq,txq}_info_get callbacks
Date: Thu, 19 Jun 2025 11:54:44 +0000	[thread overview]
Message-ID: <20250619115445.257679-1-hengqi.chen@gmail.com> (raw)

Currently, there are no ways to retrieve the queue size
set by vhost backend. Implement the {rxq,txq}_info_get
callbacks so that DPDK applications can use the queue
size to setup mempool properly.

Signed-off-by: Hengqi Chen <hengqi.chen@gmail.com>
---
 drivers/net/virtio/virtio_ethdev.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index 2d2635b669..b61d251814 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -616,6 +616,28 @@ virtio_dev_priv_dump(struct rte_eth_dev *dev, FILE *f)
 	return 0;
 }
 
+static void
+virtio_rxq_info_get(struct rte_eth_dev *dev, uint16_t rx_queue_id,
+		    struct rte_eth_rxq_info *qinfo)
+{
+	uint16_t vq_idx = 2 * rx_queue_id + VTNET_SQ_RQ_QUEUE_IDX;
+	struct virtio_hw *hw = dev->data->dev_private;
+	struct virtqueue *vq = hw->vqs[vq_idx];
+
+	qinfo->nb_desc = vq->vq_nentries;
+}
+
+static void
+virtio_txq_info_get(struct rte_eth_dev *dev, uint16_t tx_queue_id,
+		    struct rte_eth_txq_info *qinfo)
+{
+	uint16_t vq_idx = 2 * tx_queue_id + VTNET_SQ_TQ_QUEUE_IDX;
+	struct virtio_hw *hw = dev->data->dev_private;
+	struct virtqueue *vq = hw->vqs[vq_idx];
+
+	qinfo->nb_desc = vq->vq_nentries;
+}
+
 /*
  * dev_ops for virtio, bare necessities for basic operation
  */
@@ -630,6 +652,8 @@ static const struct eth_dev_ops virtio_eth_dev_ops = {
 	.allmulticast_disable    = virtio_dev_allmulticast_disable,
 	.mtu_set                 = virtio_mtu_set,
 	.dev_infos_get           = virtio_dev_info_get,
+	.rxq_info_get            = virtio_rxq_info_get,
+	.txq_info_get            = virtio_txq_info_get,
 	.stats_get               = virtio_dev_stats_get,
 	.xstats_get              = virtio_dev_xstats_get,
 	.xstats_get_names        = virtio_dev_xstats_get_names,
-- 
2.43.5


                 reply	other threads:[~2025-06-19 11:55 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250619115445.257679-1-hengqi.chen@gmail.com \
    --to=hengqi.chen@gmail.com \
    --cc=chenbox@nvidia.com \
    --cc=dev@dpdk.org \
    --cc=maxime.coquelin@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).