From patchwork Wed Mar 13 12:59:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Coquelin X-Patchwork-Id: 138329 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id DBA4F43C9F; Wed, 13 Mar 2024 13:59:45 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0993742DCD; Wed, 13 Mar 2024 13:59:45 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 98FB542DAC for ; Wed, 13 Mar 2024 13:59:42 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710334782; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XBpz86u4/Qd2RVER3fAMAMQwiBUeffSzo28O9gC8zM0=; b=Nn3HwcLjjV5se/02YGGuckhiBCFcLPj8qSt1XfIGyY5YhVCkJnFigVR5wkDbuPp71J6Fo8 icyCpUtaRmlywu8djN1Dj1HJO5Wv5bYFCpEFgzwWpoolKxIedDmmj5wSn343Th4i/XX6IO lHv2xL4DiIO1137lNw1FvZKvxVJVOe8= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-196-uoAS5PPIMGGi03oXnDGtmw-1; Wed, 13 Mar 2024 08:59:38 -0400 X-MC-Unique: uoAS5PPIMGGi03oXnDGtmw-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9B05F85A58B; Wed, 13 Mar 2024 12:59:38 +0000 (UTC) Received: from max-p1.redhat.com (unknown [10.39.208.24]) by smtp.corp.redhat.com (Postfix) with ESMTP id E04AF492BC7; Wed, 13 Mar 2024 12:59:36 +0000 (UTC) From: Maxime Coquelin To: dev@dpdk.org, david.marchand@redhat.com, chenbox@nvidia.com, schalla@marvell.com Cc: Maxime Coquelin , 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 Message-ID: <20240313125932.1878279-2-maxime.coquelin@redhat.com> In-Reply-To: <20240313125932.1878279-1-maxime.coquelin@redhat.com> References: <20240313125932.1878279-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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 Reviewed-by: David Marchand --- .../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; From patchwork Wed Mar 13 12:59:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Coquelin X-Patchwork-Id: 138330 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id F0EFB43C9F; Wed, 13 Mar 2024 13:59:55 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0120742DE0; Wed, 13 Mar 2024 13:59:49 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id A0FF542E00 for ; Wed, 13 Mar 2024 13:59:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710334786; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/i+SXtfYn1BVlI6ByuN7TaSfInHuKBUtcswulgk58eQ=; b=CUotLWz0/WZEonUk4NmuPbGIbA+9r0z9mehD4wYCBWOi42qrRr+CCAUJxvdO5tjcjO6xPK 3cMu3xRaL/ZDyQK2lOKpzUXeIHrwUu4GXXUsGIsiyvkHJEiVfgpdrTrHMO6KRb5tb1Rup4 Ad9CxmDPTJ5NFKtRpIUh6VMc5X8t/ys= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-511-vw0_-uMHPsyBT9l2zDoeTQ-1; Wed, 13 Mar 2024 08:59:41 -0400 X-MC-Unique: vw0_-uMHPsyBT9l2zDoeTQ-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7DBDA185A783; Wed, 13 Mar 2024 12:59:40 +0000 (UTC) Received: from max-p1.redhat.com (unknown [10.39.208.24]) by smtp.corp.redhat.com (Postfix) with ESMTP id E1F3B492BC6; Wed, 13 Mar 2024 12:59:38 +0000 (UTC) From: Maxime Coquelin To: dev@dpdk.org, david.marchand@redhat.com, chenbox@nvidia.com, schalla@marvell.com Cc: Maxime Coquelin Subject: [PATCH v2 2/2] net/virtio: fix notification area initialization Date: Wed, 13 Mar 2024 13:59:32 +0100 Message-ID: <20240313125932.1878279-3-maxime.coquelin@redhat.com> In-Reply-To: <20240313125932.1878279-1-maxime.coquelin@redhat.com> References: <20240313125932.1878279-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Notification area is a Virtio feature that requires to be negotiated because not all devices support it. Currently, it is tried to be initialized as soon as the backend implements the callback, so it assumes all Vhost-vDPA devices support it. This patch skips calling the notification area map callback if the device does not advertise its support. Fixes: 0fd2782660c8 ("net/virtio-user: support notification area mapping") Reviewed-by: David Marchand Signed-off-by: Maxime Coquelin --- drivers/net/virtio/virtio_user/virtio_user_dev.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c index 54187fedf5..4fdfe70e7c 100644 --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c @@ -445,8 +445,9 @@ virtio_user_dev_init_notify(struct virtio_user_dev *dev) dev->kickfds[i] = kickfd; } - if (dev->ops->map_notification_area) - if (dev->ops->map_notification_area(dev)) + if (dev->device_features & (1ULL << VIRTIO_F_NOTIFICATION_DATA)) + if (dev->ops->map_notification_area && + dev->ops->map_notification_area(dev)) goto err; return 0;