public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Laurent Vivier <lvivier@redhat.com>
Cc: passt-dev@passt.top
Subject: Re: [PATCH 1/3] vhost-user: Fix VHOST_USER_GET_QUEUE_NUM to return number of queues
Date: Mon, 8 Sep 2025 11:58:42 +1000	[thread overview]
Message-ID: <aL44UqJ_KMzlXm6h@zatzit> (raw)
In-Reply-To: <20250905154935.389634-2-lvivier@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 4001 bytes --]

On Fri, Sep 05, 2025 at 05:49:33PM +0200, Laurent Vivier wrote:
> The vhost-user specification states that VHOST_USER_GET_QUEUE_NUM should
> return the maximum number of queues supported by the back-end, not the
> number of virtqueues. Since each queue pair consists of RX and TX
> virtqueues, we need to divide VHOST_USER_MAX_QUEUES by 2 to get the
> correct queue count.
> 
> Also rename VHOST_USER_MAX_QUEUES to VHOST_USER_MAX_VQS throughout the
> codebase to better reflect that it represents the maximum number of
> virtqueues, not queue pairs.
> 
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

> ---
>  vhost_user.c | 16 +++++++++-------
>  virtio.h     |  4 ++--
>  2 files changed, 11 insertions(+), 9 deletions(-)
> 
> diff --git a/vhost_user.c b/vhost_user.c
> index f97ec6064cac..fa343a86fac2 100644
> --- a/vhost_user.c
> +++ b/vhost_user.c
> @@ -345,7 +345,7 @@ static void vu_set_enable_all_rings(struct vu_dev *vdev, bool enable)
>  {
>  	uint16_t i;
>  
> -	for (i = 0; i < VHOST_USER_MAX_QUEUES; i++)
> +	for (i = 0; i < VHOST_USER_MAX_VQS; i++)
>  		vdev->vq[i].enable = enable;
>  }
>  
> @@ -477,7 +477,7 @@ static bool vu_set_mem_table_exec(struct vu_dev *vdev,
>  		close(vmsg->fds[i]);
>  	}
>  
> -	for (i = 0; i < VHOST_USER_MAX_QUEUES; i++) {
> +	for (i = 0; i < VHOST_USER_MAX_VQS; i++) {
>  		if (vdev->vq[i].vring.desc) {
>  			if (map_ring(vdev, &vdev->vq[i]))
>  				die("remapping queue %d during setmemtable", i);
> @@ -770,7 +770,7 @@ static void vu_check_queue_msg_file(struct vhost_user_msg *vmsg)
>  	bool nofd = vmsg->payload.u64 & VHOST_USER_VRING_NOFD_MASK;
>  	int idx = vmsg->payload.u64 & VHOST_USER_VRING_IDX_MASK;
>  
> -	if (idx >= VHOST_USER_MAX_QUEUES)
> +	if (idx >= VHOST_USER_MAX_VQS)
>  		die("Invalid vhost-user queue index: %u", idx);
>  
>  	if (nofd) {
> @@ -939,7 +939,9 @@ static bool vu_get_queue_num_exec(struct vu_dev *vdev,
>  {
>  	(void)vdev;
>  
> -	vmsg_set_reply_u64(vmsg, VHOST_USER_MAX_QUEUES);
> +	vmsg_set_reply_u64(vmsg, VHOST_USER_MAX_VQS / 2);
> +
> +	debug("VHOST_USER_MAX_VQS  %u", VHOST_USER_MAX_VQS / 2);
>  
>  	return true;
>  }
> @@ -960,7 +962,7 @@ static bool vu_set_vring_enable_exec(struct vu_dev *vdev,
>  	debug("State.index:  %u", idx);
>  	debug("State.enable: %u", enable);
>  
> -	if (idx >= VHOST_USER_MAX_QUEUES)
> +	if (idx >= VHOST_USER_MAX_VQS)
>  		die("Invalid vring_enable index: %u", idx);
>  
>  	vdev->vq[idx].enable = enable;
> @@ -1052,7 +1054,7 @@ void vu_init(struct ctx *c)
>  
>  	c->vdev = &vdev_storage;
>  	c->vdev->context = c;
> -	for (i = 0; i < VHOST_USER_MAX_QUEUES; i++) {
> +	for (i = 0; i < VHOST_USER_MAX_VQS; i++) {
>  		c->vdev->vq[i] = (struct vu_virtq){
>  			.call_fd = -1,
>  			.kick_fd = -1,
> @@ -1075,7 +1077,7 @@ void vu_cleanup(struct vu_dev *vdev)
>  {
>  	unsigned int i;
>  
> -	for (i = 0; i < VHOST_USER_MAX_QUEUES; i++) {
> +	for (i = 0; i < VHOST_USER_MAX_VQS; i++) {
>  		struct vu_virtq *vq = &vdev->vq[i];
>  
>  		vq->started = false;
> diff --git a/virtio.h b/virtio.h
> index b55cc4042521..12caaa0b6def 100644
> --- a/virtio.h
> +++ b/virtio.h
> @@ -88,7 +88,7 @@ struct vu_dev_region {
>  	uint64_t mmap_addr;
>  };
>  
> -#define VHOST_USER_MAX_QUEUES 2
> +#define VHOST_USER_MAX_VQS 2
>  
>  /*
>   * Set a reasonable maximum number of ram slots, which will be supported by
> @@ -121,7 +121,7 @@ struct vdev_memory {
>  struct vu_dev {
>  	struct ctx *context;
>  	struct vdev_memory memory;
> -	struct vu_virtq vq[VHOST_USER_MAX_QUEUES];
> +	struct vu_virtq vq[VHOST_USER_MAX_VQS];
>  	uint64_t features;
>  	uint64_t protocol_features;
>  	int log_call_fd;
> -- 
> 2.50.1
> 

-- 
David Gibson (he or they)	| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you, not the other way
				| around.
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2025-09-08  2:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-05 15:49 [PATCH 0/3] This series contains fixes and improvements to the vhost-user implementation Laurent Vivier
2025-09-05 15:49 ` [PATCH 1/3] vhost-user: Fix VHOST_USER_GET_QUEUE_NUM to return number of queues Laurent Vivier
2025-09-08  1:58   ` David Gibson [this message]
2025-09-05 15:49 ` [PATCH 2/3] udp_vu: Pass virtqueue pointer to udp_vu_sock_recv() Laurent Vivier
2025-09-08  1:59   ` David Gibson
2025-09-05 15:49 ` [PATCH 3/3] tcp_vu: Pass virtqueue pointer to tcp_vu_sock_recv() Laurent Vivier
2025-09-08  2:00   ` David Gibson
2025-09-09 20:24 ` [PATCH 0/3] This series contains fixes and improvements to the vhost-user implementation Stefano Brivio

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=aL44UqJ_KMzlXm6h@zatzit \
    --to=david@gibson.dropbear.id.au \
    --cc=lvivier@redhat.com \
    --cc=passt-dev@passt.top \
    /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.
Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

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 IMAP folder(s).