[1/2] net/virtio: fix vDPA device init advertising control queue

Message ID 20240312104849.667036-2-maxime.coquelin@redhat.com (mailing list archive)
State Superseded, archived
Delegated to: Maxime Coquelin
Headers
Series net/virtio: vhost-vdpa fixes |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Maxime Coquelin March 12, 2024, 10:48 a.m. UTC
  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.

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

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

Comments

David Marchand March 12, 2024, 2:10 p.m. UTC | #1
On Tue, Mar 12, 2024 at 11:48 AM Maxime Coquelin
<maxime.coquelin@redhat.com> wrote:
>
> 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.
>
> Fixes: b277308e8868 ("net/virtio-user: advertise control VQ support with vDPA")
> Cc: stable@dpdk.org
>
> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Reviewed-by: David Marchand <david.marchand@redhat.com>
  

Patch

diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c
index d395fc1676..0b5db12886 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
@@ -752,7 +752,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 +770,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 {