DPDK patches and discussions
 help / color / mirror / Atom feed
From: Maxime Coquelin <maxime.coquelin@redhat.com>
To: dev@dpdk.org, david.marchand@redhat.com, chenbox@nvidia.com,
	schalla@marvell.com
Cc: Maxime Coquelin <maxime.coquelin@redhat.com>, stable@dpdk.org
Subject: [PATCH v2 1/2] net/virtio: fix vDPA device init advertising control queue
Date: Wed, 13 Mar 2024 13:59:31 +0100	[thread overview]
Message-ID: <20240313125932.1878279-2-maxime.coquelin@redhat.com> (raw)
In-Reply-To: <20240313125932.1878279-1-maxime.coquelin@redhat.com>

If the vDPA device advertises control queue support, but
the user neither passes "cq=1" as devarg nor requests
multiple queues, the initialization fails because the
driver tries to setup the control queue without negotiating
related feature.

This patch enables the control queue at driver level as
soon as the device claims to support it, and not only when
multiple queue pairs are requested. Also, enable the
control queue event if multiqueue feature has not been
negotiated and device start time, and disable it at device
stop time.

Fixes: b277308e8868 ("net/virtio-user: advertise control VQ support with vDPA")
Cc: stable@dpdk.org

Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
 .../net/virtio/virtio_user/virtio_user_dev.c  | 22 ++++++++++++++-----
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c
index d395fc1676..54187fedf5 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
@@ -216,6 +216,12 @@ virtio_user_start_device(struct virtio_user_dev *dev)
 	if (ret < 0)
 		goto error;
 
+	if (dev->scvq) {
+		ret = dev->ops->cvq_enable(dev, 1);
+		if (ret < 0)
+			goto error;
+	}
+
 	dev->started = true;
 
 	pthread_mutex_unlock(&dev->mutex);
@@ -248,6 +254,12 @@ int virtio_user_stop_device(struct virtio_user_dev *dev)
 			goto err;
 	}
 
+	if (dev->scvq) {
+		ret = dev->ops->cvq_enable(dev, 0);
+		if (ret < 0)
+			goto err;
+	}
+
 	/* Stop the backend. */
 	for (i = 0; i < dev->max_queue_pairs * 2; ++i) {
 		state.index = i;
@@ -752,7 +764,7 @@ virtio_user_dev_init(struct virtio_user_dev *dev, char *path, uint16_t queues,
 	if (virtio_user_dev_init_max_queue_pairs(dev, queues))
 		dev->unsupported_features |= (1ull << VIRTIO_NET_F_MQ);
 
-	if (dev->max_queue_pairs > 1)
+	if (dev->max_queue_pairs > 1 || dev->hw_cvq)
 		cq = 1;
 
 	if (!mrg_rxbuf)
@@ -770,8 +782,9 @@ virtio_user_dev_init(struct virtio_user_dev *dev, char *path, uint16_t queues,
 		dev->unsupported_features |= (1ull << VIRTIO_NET_F_MAC);
 
 	if (cq) {
-		/* device does not really need to know anything about CQ,
-		 * so if necessary, we just claim to support CQ
+		/* Except for vDPA, the device does not really need to know
+		 * anything about CQ, so if necessary, we just claim to support
+		 * control queue.
 		 */
 		dev->frontend_features |= (1ull << VIRTIO_NET_F_CTRL_VQ);
 	} else {
@@ -871,9 +884,6 @@ virtio_user_handle_mq(struct virtio_user_dev *dev, uint16_t q_pairs)
 	for (i = q_pairs; i < dev->max_queue_pairs; ++i)
 		ret |= dev->ops->enable_qp(dev, i, 0);
 
-	if (dev->scvq)
-		ret |= dev->ops->cvq_enable(dev, 1);
-
 	dev->queue_pairs = q_pairs;
 
 	return ret;
-- 
2.44.0


  reply	other threads:[~2024-03-13 12:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-13 12:59 [PATCH v2 0/2] net/virtio: vhost-vdpa fixes Maxime Coquelin
2024-03-13 12:59 ` Maxime Coquelin [this message]
2024-03-13 14:12   ` [PATCH v2 1/2] net/virtio: fix vDPA device init advertising control queue David Marchand
2024-03-13 12:59 ` [PATCH v2 2/2] net/virtio: fix notification area initialization Maxime Coquelin
2024-03-13 14:48 ` [PATCH v2 0/2] net/virtio: vhost-vdpa fixes David Marchand

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=20240313125932.1878279-2-maxime.coquelin@redhat.com \
    --to=maxime.coquelin@redhat.com \
    --cc=chenbox@nvidia.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=schalla@marvell.com \
    --cc=stable@dpdk.org \
    /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).