From nobody Sun Nov 9 22:27:05 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1551982128398112.3173108674381; Thu, 7 Mar 2019 10:08:48 -0800 (PST) Received: from localhost ([127.0.0.1]:56625 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1xRl-0000qg-9P for importer@patchew.org; Thu, 07 Mar 2019 13:08:45 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39858) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1wr9-0003cz-KE for qemu-devel@nongnu.org; Thu, 07 Mar 2019 12:30:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h1wr4-0008ND-PZ for qemu-devel@nongnu.org; Thu, 07 Mar 2019 12:30:55 -0500 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]:36302) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h1wr4-0008MD-Gr for qemu-devel@nongnu.org; Thu, 07 Mar 2019 12:30:50 -0500 Received: by mail-wm1-x331.google.com with SMTP id j125so10119108wmj.1 for ; Thu, 07 Mar 2019 09:30:50 -0800 (PST) Received: from 640k.localdomain ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id d206sm9979753wmc.11.2019.03.07.09.30.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Mar 2019 09:30:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=23R2ZOIWRhFaRuPewX+YO6zA6oQ9cyGwQdrmIwSfmo4=; b=ushVm55nBtEZ4IWTGfFHZRt2wcATx/DBpdFuAsKQultG2f0ySxYfoUhhwtgWqLeulT VU/a3GbZwiyuLUHoaqBY+atmsKRIuaR7OlSeAvKFOJ1P82wppTa64lfSdqt2cD3KwHsy OTA+Q9ORODiwsQ+7NafXJIKe5c3JWxuRAR5/fwJj8wzvLfTUcg4JRUi4CoD2G1wiJ9ZO u1Itf88Snn8UqB/aykyKxVdBbG8pnKvScrfBJV7nMaetLamMqnlp1o//TGeOp2wHrwzr bj9xlv+vgJm5qXyoSLS1oVo7tAYP3Zy+iOZ+XbQhGD6K2SMR9Cxryla8a0V1ZF7Y9Vtr ubGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=23R2ZOIWRhFaRuPewX+YO6zA6oQ9cyGwQdrmIwSfmo4=; b=MFY+KPy5fEqTacnDDOAki7cacHwRrn8m9KkmdepJksjDBxFH0WeIcVnt542Gmt5oJB /N4w0BNca2lLgViao1cd9M7c3vW9fXtCIOqpNK4XMEvTzbfKjk99uE2mPmoMhvg5MFp2 1RgCUBLp5Z7/5Qzg/tpxJpcD2eadxt8xgYVnBijCnl0W4J8ADK6FPzBgapV1cyArEeTI 5aWWI4n4IVh82JYer8mL5lXbKoGRDvjaqWhoOB/I6VjZLRk/SznKdcsv3CRqmAgKXf1X KPSxEDb8v/3L2HKL97FlR7Sq6KFWmnldT7J+9liph5pqP62+CrlNQSsIfvlkQYrrVi6/ oW0Q== X-Gm-Message-State: APjAAAV93+vaZlCYx2AayT/YHcGJficzgAtCQsgvzJWBMLPF12zGnAz+ 4i8+ibM7ZymxkuRMHe0eXpKFXmmu X-Google-Smtp-Source: APXvYqw5goHX9FDgbg6XxQLyNEHHhnHOIQU0wFlg/3fxstmvHrBKQSiHNZR/WT7cNyNEWI5s0dZZ/Q== X-Received: by 2002:a1c:2947:: with SMTP id p68mr6474560wmp.104.1551979849094; Thu, 07 Mar 2019 09:30:49 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 7 Mar 2019 18:29:45 +0100 Message-Id: <1551979804-6060-39-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1551979804-6060-1-git-send-email-pbonzini@redhat.com> References: <1551979804-6060-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::331 Subject: [Qemu-devel] [PULL 38/57] tests/libqos: support multiqueue for virtio-net X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thuth@redhat.com, lviver@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Initialize the additional virtqueues if they are supported. This is needed to switch vhost-user-test's multiqueue test to the virtio-net qgraph. Signed-off-by: Paolo Bonzini --- tests/libqos/virtio-net.c | 21 +++++++++++++++++---- tests/libqos/virtio-net.h | 4 ++-- tests/virtio-net-test.c | 6 +++--- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/tests/libqos/virtio-net.c b/tests/libqos/virtio-net.c index 3ddfbdc..61c5617 100644 --- a/tests/libqos/virtio-net.c +++ b/tests/libqos/virtio-net.c @@ -27,14 +27,19 @@ static QGuestAllocator *alloc; =20 static void virtio_net_cleanup(QVirtioNet *interface) { - qvirtqueue_cleanup(interface->vdev->bus, interface->rx, alloc); - qvirtqueue_cleanup(interface->vdev->bus, interface->tx, alloc); + int i; + + for (i =3D 0; i < interface->n_queues; i++) { + qvirtqueue_cleanup(interface->vdev->bus, interface->queues[i], all= oc); + } + g_free(interface->queues); } =20 static void virtio_net_setup(QVirtioNet *interface) { QVirtioDevice *vdev =3D interface->vdev; uint64_t features; + int i; =20 features =3D qvirtio_get_features(vdev); features &=3D ~(QVIRTIO_F_BAD_FEATURE | @@ -42,8 +47,16 @@ static void virtio_net_setup(QVirtioNet *interface) (1u << VIRTIO_RING_F_EVENT_IDX)); qvirtio_set_features(vdev, features); =20 - interface->rx =3D qvirtqueue_setup(vdev, alloc, 0); - interface->tx =3D qvirtqueue_setup(vdev, alloc, 1); + if (features & (1u << VIRTIO_NET_F_MQ)) { + interface->n_queues =3D qvirtio_config_readw(vdev, 8) * 2; + } else { + interface->n_queues =3D 2; + } + + interface->queues =3D g_new(QVirtQueue *, interface->n_queues); + for (i =3D 0; i < interface->n_queues; i++) { + interface->queues[i] =3D qvirtqueue_setup(vdev, alloc, i); + } qvirtio_set_driver_ok(vdev); } =20 diff --git a/tests/libqos/virtio-net.h b/tests/libqos/virtio-net.h index e6905cd..28238a1 100644 --- a/tests/libqos/virtio-net.h +++ b/tests/libqos/virtio-net.h @@ -26,8 +26,8 @@ typedef struct QVirtioNetDevice QVirtioNetDevice; =20 struct QVirtioNet { QVirtioDevice *vdev; - QVirtQueue *rx; - QVirtQueue *tx; + int n_queues; + QVirtQueue **queues; }; =20 struct QVirtioNetPCI { diff --git a/tests/virtio-net-test.c b/tests/virtio-net-test.c index 2d3630c..c58e670 100644 --- a/tests/virtio-net-test.c +++ b/tests/virtio-net-test.c @@ -136,8 +136,8 @@ static void send_recv_test(void *obj, void *data, QGues= tAllocator *t_alloc) { QVirtioNet *net_if =3D obj; QVirtioDevice *dev =3D net_if->vdev; - QVirtQueue *rx =3D net_if->rx; - QVirtQueue *tx =3D net_if->tx; + QVirtQueue *rx =3D net_if->queues[0]; + QVirtQueue *tx =3D net_if->queues[1]; int *sv =3D data; =20 rx_test(dev, t_alloc, rx, sv[0]); @@ -148,7 +148,7 @@ static void stop_cont_test(void *obj, void *data, QGues= tAllocator *t_alloc) { QVirtioNet *net_if =3D obj; QVirtioDevice *dev =3D net_if->vdev; - QVirtQueue *rx =3D net_if->rx; + QVirtQueue *rx =3D net_if->queues[0]; int *sv =3D data; =20 rx_stop_cont_test(dev, t_alloc, rx, sv[0]); --=20 1.8.3.1