net/virtio: Implement {rxq,txq}_info_get callbacks

Message ID 20250619115445.257679-1-hengqi.chen@gmail.com (mailing list archive)
State New
Delegated to: Maxime Coquelin
Headers
Series net/virtio: Implement {rxq,txq}_info_get callbacks |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/github-robot: build success github build: passed
ci/iol-marvell-Functional success Functional Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/aws-unit-testing success Unit Testing PASS
ci/iol-compile-amd64-testing fail Testing issues
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/iol-unit-amd64-testing fail Testing issues

Commit Message

Hengqi Chen June 19, 2025, 11:54 a.m. UTC
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(+)
  

Comments

Hengqi Chen July 2, 2025, 12:17 p.m. UTC | #1
Hi Maxime, Chenbo,

Gentle ping on this. Does this change make sense ?

On Thu, Jun 19, 2025 at 7:55 PM Hengqi Chen <hengqi.chen@gmail.com> wrote:
>
> 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
>
  

Patch

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,