From patchwork Wed Mar 27 09:40:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Coquelin X-Patchwork-Id: 138851 X-Patchwork-Delegate: maxime.coquelin@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 598C743D66; Wed, 27 Mar 2024 10:40:50 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 267D340E6E; Wed, 27 Mar 2024 10:40:48 +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 A23164029F for ; Wed, 27 Mar 2024 10:40:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711532444; 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=pCNI8mll5OoEItNXoreyyTyewsh9Xw84tzRnAJwAIRk=; b=F9VYoHzHgTghLWtKH0NvEjrWaWpAyANR3ukplm+XAeNcVa+665IGAWzvmFZyZuNIsGZUM+ f3KW4xVIhu5S9Jo/deEA6abwWNUuw5O8xYn5xL88us2tJjcZZqUazioBVGkeVuPLsnkh4H dqE1jSW9YHjUMTRshQqdlpzTPQy7Iq8= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-350-MA9G2RnoOEWC2Y93g59xxA-1; Wed, 27 Mar 2024 05:40:42 -0400 X-MC-Unique: MA9G2RnoOEWC2Y93g59xxA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (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 7E80738157A8; Wed, 27 Mar 2024 09:40:42 +0000 (UTC) Received: from max-p1.redhat.com (unknown [10.39.208.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 15BBD1074E; Wed, 27 Mar 2024 09:40:40 +0000 (UTC) From: Maxime Coquelin To: dev@dpdk.org, david.marchand@redhat.com, chenbox@nvidia.com Cc: Maxime Coquelin Subject: [PATCH 1/4] net/virtio: rename Virtio-user queue iterator Date: Wed, 27 Mar 2024 10:40:29 +0100 Message-ID: <20240327094032.2400951-2-maxime.coquelin@redhat.com> In-Reply-To: <20240327094032.2400951-1-maxime.coquelin@redhat.com> References: <20240327094032.2400951-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 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 This is a preliminary rework to prepare for iterating over queues for non-setup operations. Also, remove the error log that does not provide much information given the callbacks already provide one. Signed-off-by: Maxime Coquelin --- drivers/net/virtio/virtio_user/virtio_user_dev.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c index 4fdfe70e7c..c3d44880f5 100644 --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c @@ -129,7 +129,7 @@ virtio_user_kick_queue(struct virtio_user_dev *dev, uint32_t queue_sel) } static int -virtio_user_queue_setup(struct virtio_user_dev *dev, +virtio_user_foreach_queue(struct virtio_user_dev *dev, int (*fn)(struct virtio_user_dev *, uint32_t)) { uint32_t i, nr_vq; @@ -138,12 +138,9 @@ virtio_user_queue_setup(struct virtio_user_dev *dev, if (dev->hw_cvq) nr_vq++; - for (i = 0; i < nr_vq; i++) { - if (fn(dev, i) < 0) { - PMD_DRV_LOG(ERR, "(%s) setup VQ %u failed", dev->path, i); + for (i = 0; i < nr_vq; i++) + if (fn(dev, i) < 0) return -1; - } - } return 0; } @@ -157,7 +154,7 @@ virtio_user_dev_set_features(struct virtio_user_dev *dev) pthread_mutex_lock(&dev->mutex); /* Step 0: tell vhost to create queues */ - if (virtio_user_queue_setup(dev, virtio_user_create_queue) < 0) + if (virtio_user_foreach_queue(dev, virtio_user_create_queue) < 0) goto error; features = dev->features; @@ -205,7 +202,7 @@ virtio_user_start_device(struct virtio_user_dev *dev) goto error; /* Step 3: kick queues */ - ret = virtio_user_queue_setup(dev, virtio_user_kick_queue); + ret = virtio_user_foreach_queue(dev, virtio_user_kick_queue); if (ret < 0) goto error; From patchwork Wed Mar 27 09:40:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Coquelin X-Patchwork-Id: 138852 X-Patchwork-Delegate: maxime.coquelin@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 67A3A43D66; Wed, 27 Mar 2024 10:40:57 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B6411410F9; Wed, 27 Mar 2024 10:40:50 +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 5E087410D5 for ; Wed, 27 Mar 2024 10:40:48 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711532448; 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=5gTbHs4gsMOKc1yXz/6xudqUPBKnwP2wsGSU3rmvYTk=; b=BH1ml/u5E5EvKOzILcP5PlWPnRTxF9iCMdSTkUx2/CJFVIYW9BJ/Hktf8VCVFKCYagcgBT XoWl4Cu/tbCpZwag6qFzbqQKKyfYi782ej9RIxf4oYjCdQeA7acPLoHRUx7DTtx4WVzZzh 8qdVkyjHAtvMDBQRZKrBSdzeqdvEMUc= 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-299-g1n3Z7-LOnisXDonsV6M1A-1; Wed, 27 Mar 2024 05:40:44 -0400 X-MC-Unique: g1n3Z7-LOnisXDonsV6M1A-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (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 4A1A18007A4; Wed, 27 Mar 2024 09:40:44 +0000 (UTC) Received: from max-p1.redhat.com (unknown [10.39.208.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id C325A107A8; Wed, 27 Mar 2024 09:40:42 +0000 (UTC) From: Maxime Coquelin To: dev@dpdk.org, david.marchand@redhat.com, chenbox@nvidia.com Cc: Maxime Coquelin , stable@dpdk.org Subject: [PATCH 2/4] net/virtio: use iterator to destroy Virtio-user queues Date: Wed, 27 Mar 2024 10:40:30 +0100 Message-ID: <20240327094032.2400951-3-maxime.coquelin@redhat.com> In-Reply-To: <20240327094032.2400951-1-maxime.coquelin@redhat.com> References: <20240327094032.2400951-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 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 This patch uses the freshly renamed iterator to destroy queues at stop time. Doing this, we fix the missing control queue destroy. Fixes: 90966e8e5b67 ("net/virtio-user: send shadow virtqueue info to the backend") Cc: stable@dpdk.org Signed-off-by: Maxime Coquelin --- .../net/virtio/virtio_user/virtio_user_dev.c | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c index c3d44880f5..0776c54deb 100644 --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c @@ -33,6 +33,22 @@ const char * const virtio_user_backend_strings[] = { [VIRTIO_USER_BACKEND_VHOST_VDPA] = "VHOST_VDPA", }; +static int +virtio_user_destroy_queue(struct virtio_user_dev *dev, uint32_t queue_sel) +{ + struct vhost_vring_state state; + int ret; + + state.index = queue_sel; + ret = dev->ops->get_vring_base(dev, &state); + if (ret < 0) { + PMD_DRV_LOG(ERR, "(%s) Failed to destroy queue %u", dev->path, queue_sel); + return -1; + } + + return 0; +} + static int virtio_user_create_queue(struct virtio_user_dev *dev, uint32_t queue_sel) { @@ -237,7 +253,6 @@ virtio_user_start_device(struct virtio_user_dev *dev) int virtio_user_stop_device(struct virtio_user_dev *dev) { - struct vhost_vring_state state; uint32_t i; int ret; @@ -258,14 +273,8 @@ int virtio_user_stop_device(struct virtio_user_dev *dev) } /* Stop the backend. */ - for (i = 0; i < dev->max_queue_pairs * 2; ++i) { - state.index = i; - ret = dev->ops->get_vring_base(dev, &state); - if (ret < 0) { - PMD_DRV_LOG(ERR, "(%s) get_vring_base failed, index=%u", dev->path, i); - goto err; - } - } + if (virtio_user_foreach_queue(dev, virtio_user_destroy_queue) < 0) + goto err; dev->started = false; From patchwork Wed Mar 27 09:40: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: 138853 X-Patchwork-Delegate: maxime.coquelin@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 3611743D66; Wed, 27 Mar 2024 10:41:05 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4F44D410E3; Wed, 27 Mar 2024 10:40:53 +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 6B488410FD for ; Wed, 27 Mar 2024 10:40:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711532451; 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=bVZF1IU6Ercp5siyFWlnTTxA3Okd6U+HQWLvxm7v4aQ=; b=E+UVXDFV4sYcKc0XCgK26W5ZGvSVIVU3MYoKRqyy6FHHUvYJfndmGyq11wb3LbZI4V/3r+ WrPwv5DPL80kXqGaO2cuYziLX2x9/97capTXXTWwgJLMTfbBnGTXMd62XE5gu5i+E09bMx LsPBWiRuyzmBqDcBcJbW0ugcV4+aKPU= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-532-YhnQKF1TN2aY9nGVbYEPdg-1; Wed, 27 Mar 2024 05:40:46 -0400 X-MC-Unique: YhnQKF1TN2aY9nGVbYEPdg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (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 04F841C05149; Wed, 27 Mar 2024 09:40:46 +0000 (UTC) Received: from max-p1.redhat.com (unknown [10.39.208.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9249C1074E; Wed, 27 Mar 2024 09:40:44 +0000 (UTC) From: Maxime Coquelin To: dev@dpdk.org, david.marchand@redhat.com, chenbox@nvidia.com Cc: Maxime Coquelin , stable@dpdk.org Subject: [PATCH 3/4] net/virtio: fix shadow control queue notification init Date: Wed, 27 Mar 2024 10:40:31 +0100 Message-ID: <20240327094032.2400951-4-maxime.coquelin@redhat.com> In-Reply-To: <20240327094032.2400951-1-maxime.coquelin@redhat.com> References: <20240327094032.2400951-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 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 The Virtio-user control queue kick and call FDs were not uninitialized at device stop time. This patch fixes this using the queues iterator helper for both initialization and uninitialization. Fixes: 90966e8e5b67 ("net/virtio-user: send shadow virtqueue info to the backend") Cc: stable@dpdk.org Signed-off-by: Maxime Coquelin --- .../net/virtio/virtio_user/virtio_user_dev.c | 90 +++++++++---------- 1 file changed, 43 insertions(+), 47 deletions(-) diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c index 0776c54deb..912e87fecf 100644 --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c @@ -33,6 +33,45 @@ const char * const virtio_user_backend_strings[] = { [VIRTIO_USER_BACKEND_VHOST_VDPA] = "VHOST_VDPA", }; +static int +virtio_user_uninit_notify_queue(struct virtio_user_dev *dev, uint32_t queue_sel) +{ + if (dev->kickfds[queue_sel] >= 0) { + close(dev->kickfds[queue_sel]); + dev->kickfds[queue_sel] = -1; + } + + if (dev->callfds[queue_sel] >= 0) { + close(dev->callfds[queue_sel]); + dev->callfds[queue_sel] = -1; + } + + return 0; +} + +static int +virtio_user_init_notify_queue(struct virtio_user_dev *dev, uint32_t queue_sel) +{ + /* May use invalid flag, but some backend uses kickfd and + * callfd as criteria to judge if dev is alive. so finally we + * use real event_fd. + */ + dev->callfds[queue_sel] = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK); + if (dev->callfds[queue_sel] < 0) { + PMD_DRV_LOG(ERR, "(%s) Failed to setup callfd for queue %u: %s", + dev->path, queue_sel, strerror(errno)); + return -1; + } + dev->kickfds[queue_sel] = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK); + if (dev->kickfds[queue_sel] < 0) { + PMD_DRV_LOG(ERR, "(%s) Failed to setup kickfd for queue %u: %s", + dev->path, queue_sel, strerror(errno)); + return -1; + } + + return 0; +} + static int virtio_user_destroy_queue(struct virtio_user_dev *dev, uint32_t queue_sel) { @@ -423,33 +462,9 @@ virtio_user_dev_init_mac(struct virtio_user_dev *dev, const char *mac) static int virtio_user_dev_init_notify(struct virtio_user_dev *dev) { - uint32_t i, j, nr_vq; - int callfd; - int kickfd; - - nr_vq = dev->max_queue_pairs * 2; - if (dev->hw_cvq) - nr_vq++; - for (i = 0; i < nr_vq; i++) { - /* May use invalid flag, but some backend uses kickfd and - * callfd as criteria to judge if dev is alive. so finally we - * use real event_fd. - */ - callfd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK); - if (callfd < 0) { - PMD_DRV_LOG(ERR, "(%s) callfd error, %s", dev->path, strerror(errno)); - goto err; - } - kickfd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK); - if (kickfd < 0) { - close(callfd); - PMD_DRV_LOG(ERR, "(%s) kickfd error, %s", dev->path, strerror(errno)); - goto err; - } - dev->callfds[i] = callfd; - dev->kickfds[i] = kickfd; - } + if (virtio_user_foreach_queue(dev, virtio_user_init_notify_queue) < 0) + goto err; if (dev->device_features & (1ULL << VIRTIO_F_NOTIFICATION_DATA)) if (dev->ops->map_notification_area && @@ -458,16 +473,7 @@ virtio_user_dev_init_notify(struct virtio_user_dev *dev) return 0; err: - for (j = 0; j < i; j++) { - if (dev->kickfds[j] >= 0) { - close(dev->kickfds[j]); - dev->kickfds[j] = -1; - } - if (dev->callfds[j] >= 0) { - close(dev->callfds[j]); - dev->callfds[j] = -1; - } - } + virtio_user_foreach_queue(dev, virtio_user_uninit_notify_queue); return -1; } @@ -475,18 +481,8 @@ virtio_user_dev_init_notify(struct virtio_user_dev *dev) static void virtio_user_dev_uninit_notify(struct virtio_user_dev *dev) { - uint32_t i; + virtio_user_foreach_queue(dev, virtio_user_uninit_notify_queue); - for (i = 0; i < dev->max_queue_pairs * 2; ++i) { - if (dev->kickfds[i] >= 0) { - close(dev->kickfds[i]); - dev->kickfds[i] = -1; - } - if (dev->callfds[i] >= 0) { - close(dev->callfds[i]); - dev->callfds[i] = -1; - } - } if (dev->ops->unmap_notification_area && dev->notify_area) dev->ops->unmap_notification_area(dev); } From patchwork Wed Mar 27 09:40: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: 138854 X-Patchwork-Delegate: maxime.coquelin@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 CF57A43D66; Wed, 27 Mar 2024 10:41:11 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7C1A6427D7; Wed, 27 Mar 2024 10:40:54 +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 0073041141 for ; Wed, 27 Mar 2024 10:40:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711532451; 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=okZ70ZLBNcS+dj1RGHXS/tI+BD0sFihnN5Z9BdLiCYQ=; b=Y3rdYioLlZZ4KKNtFNP1faaFL/L6uzEPfIq8TFf6JCaXMtJ90NgsIXI9Hu4xQOn7+7PpBf KceQfcCwjouC2cblWc0W2a6zFhoIsa2wvFwLbsW4yZK+6Dc3tGsIvZsdETODG0kFU6J+Br Suzw+dr2/lNH9T+NB1yw7H76b3u9H4I= 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-540-Tt8ds663PEiOycw5rSe7-g-1; Wed, 27 Mar 2024 05:40:48 -0400 X-MC-Unique: Tt8ds663PEiOycw5rSe7-g-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (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 E96AF811E81; Wed, 27 Mar 2024 09:40:47 +0000 (UTC) Received: from max-p1.redhat.com (unknown [10.39.208.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 52AD4107A8; Wed, 27 Mar 2024 09:40:46 +0000 (UTC) From: Maxime Coquelin To: dev@dpdk.org, david.marchand@redhat.com, chenbox@nvidia.com Cc: Maxime Coquelin , stable@dpdk.org Subject: [PATCH 4/4] net/virtio: fix shadow control queue allocation Date: Wed, 27 Mar 2024 10:40:32 +0100 Message-ID: <20240327094032.2400951-5-maxime.coquelin@redhat.com> In-Reply-To: <20240327094032.2400951-1-maxime.coquelin@redhat.com> References: <20240327094032.2400951-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 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 It is possible to have the control queue without the vDPA device advertising VIRTIO_NET_F_MQ. Let's just rely on hw_cvq flag as in other places. Fixes: 6fdf32d1e318 ("net/virtio-user: remove max queues limitation") Cc: stable@dpdk.org Signed-off-by: Maxime Coquelin --- drivers/net/virtio/virtio_user/virtio_user_dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c index 912e87fecf..5240b44481 100644 --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c @@ -615,7 +615,7 @@ virtio_user_alloc_vrings(struct virtio_user_dev *dev) bool packed_ring = !!(dev->device_features & (1ull << VIRTIO_F_RING_PACKED)); nr_vrings = dev->max_queue_pairs * 2; - if (dev->device_features & (1ull << VIRTIO_NET_F_MQ)) + if (dev->hw_cvq) nr_vrings++; dev->callfds = rte_zmalloc("virtio_user_dev", nr_vrings * sizeof(*dev->callfds), 0);