From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true 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; -- 2.44.0