From patchwork Tue Feb 7 15:17:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Coquelin X-Patchwork-Id: 123281 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 F09CE41C30; Tue, 7 Feb 2023 16:19:17 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 30DDC42D75; Tue, 7 Feb 2023 16:18:46 +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 4B70242D50 for ; Tue, 7 Feb 2023 16:18:42 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675783121; 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=XRzO1sP/xKX6o51dUvHYVrP72YhPWdZ2KR0+uHLXGAI=; b=IG3S2cPcxQnq29F4OzY5xyqY7IENQxw6n1BPcKNtjKxHIF+aiCT5U0TqjXL1jBJdID3qpQ qMZxFeQL3yIduYdqR4Uwp7FO8vQJ8mA7O2EKgkADGMo9tNbwZBoQBLYUxuP1Xm7vteEsep GSo92DM2/7smLjjv3u5rkRw6TVOgG9Q= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-135-gq-mh04lPxe3Qu_zIl5aRw-1; Tue, 07 Feb 2023 10:18:38 -0500 X-MC-Unique: gq-mh04lPxe3Qu_zIl5aRw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6F0CD8A4EFB; Tue, 7 Feb 2023 15:18:15 +0000 (UTC) Received: from max-t490s.redhat.com (unknown [10.39.208.26]) by smtp.corp.redhat.com (Postfix) with ESMTP id 22F62140EBF4; Tue, 7 Feb 2023 15:18:13 +0000 (UTC) From: Maxime Coquelin To: dev@dpdk.org, chenbo.xia@intel.com, david.marchand@redhat.com, eperezma@redhat.com, stephen@networkplumber.org Cc: Maxime Coquelin Subject: [PATCH v2 13/21] net/virtio-user: simplify queues setup Date: Tue, 7 Feb 2023 16:17:39 +0100 Message-Id: <20230207151747.245808-14-maxime.coquelin@redhat.com> In-Reply-To: <20230207151747.245808-1-maxime.coquelin@redhat.com> References: <20230207151747.245808-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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 only reason two loops were needed to iterate over queues at setup time was to be able to print whether it was a Tx or Rx queue. This patch changes queues iteration to a single loop. Signed-off-by: Maxime Coquelin Reviewed-by: Chenbo Xia --- drivers/net/virtio/virtio_user/virtio_user_dev.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c index 19599aa3f6..873c6aa036 100644 --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c @@ -118,19 +118,11 @@ static int virtio_user_queue_setup(struct virtio_user_dev *dev, int (*fn)(struct virtio_user_dev *, uint32_t)) { - uint32_t i, queue_sel; + uint32_t i; - for (i = 0; i < dev->max_queue_pairs; ++i) { - queue_sel = 2 * i + VTNET_SQ_RQ_QUEUE_IDX; - if (fn(dev, queue_sel) < 0) { - PMD_DRV_LOG(ERR, "(%s) setup rx vq %u failed", dev->path, i); - return -1; - } - } - for (i = 0; i < dev->max_queue_pairs; ++i) { - queue_sel = 2 * i + VTNET_SQ_TQ_QUEUE_IDX; - if (fn(dev, queue_sel) < 0) { - PMD_DRV_LOG(INFO, "(%s) setup tx vq %u failed", dev->path, i); + for (i = 0; i < dev->max_queue_pairs * 2; ++i) { + if (fn(dev, i) < 0) { + PMD_DRV_LOG(ERR, "(%s) setup VQ %u failed", dev->path, i); return -1; } }