From patchwork Sat Oct 26 21:52:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1184876 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 470vsL2mC6z9sPV for ; Sun, 27 Oct 2019 08:54:46 +1100 (AEDT) Received: from localhost ([::1]:42772 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iOU1D-0000Dh-Ll for incoming@patchwork.ozlabs.org; Sat, 26 Oct 2019 17:54:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34251) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iOTzX-0006zV-4S for qemu-devel@nongnu.org; Sat, 26 Oct 2019 17:53:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iOTzV-0003dh-Bo for qemu-devel@nongnu.org; Sat, 26 Oct 2019 17:52:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53924) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iOTzU-0003c6-In for qemu-devel@nongnu.org; Sat, 26 Oct 2019 17:52:57 -0400 Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A4BE3330276 for ; Sat, 26 Oct 2019 21:52:54 +0000 (UTC) Received: by mail-qk1-f199.google.com with SMTP id m189so6351898qkc.7 for ; Sat, 26 Oct 2019 14:52:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=tXGJp+rCCgyjcVmn+mwC2du6Xae9aaVCkOjM2+F9SkY=; b=oW1VgZux+OyEESxeUPFxI1oYv1JkFQXlaM1Cozof+aPEIU544/GOhKtChFO3uSI7Tz +24Hi0dZTOBskDkIXLn1X8jbndg9LNk3/aCJRs6AN49zf9g4h84xrK1qd1ox7wwyKlVi k8eVW2sSOzIwGj73k5y+QfQgkNjIT3PQvKSwWQkTj4Ycf+RMqkGtK1PtQNh5JLUS+pn4 51woZfPRb5CZUQPCRmj2vqARlDSR39l/taO9MgnengPy3LxU/b13M8pGhVkSa/jLhUhZ h66s4VeGvKF70K/Wda/ad/uozu3WI0cCi9KuZMnAkM4IhKj7VhfpocPeSlgl1cN4ttop t1sQ== X-Gm-Message-State: APjAAAUAfxOPOQs+iZ4/zUAKEL8u+3FkqHyXr1QeQcImd+KVChlANi4M iR+YWHSAwBJ+j04h8JhrqOIOP+74dxTlTmtLrXe4U14N9pjD3U4Xz1Ldw0phurgT7XnJ4swU7cG ziKlf0ISRZTzNt8g= X-Received: by 2002:ac8:45d0:: with SMTP id e16mr10270107qto.8.1572126773684; Sat, 26 Oct 2019 14:52:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqxk4z47Qvzp9Rif43s6sZchs1PBgqQ2EAPTZMq+aKGh3k4QsLKHOep/aHyJsKOlpeE/oOPUjQ== X-Received: by 2002:ac8:45d0:: with SMTP id e16mr10270095qto.8.1572126773485; Sat, 26 Oct 2019 14:52:53 -0700 (PDT) Received: from redhat.com (bzq-79-176-10-77.red.bezeqint.net. [79.176.10.77]) by smtp.gmail.com with ESMTPSA id j6sm3834148qkc.31.2019.10.26.14.52.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Oct 2019 14:52:52 -0700 (PDT) Date: Sat, 26 Oct 2019 17:52:48 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 19/25] libqos: pass full QVirtQueue to set_queue_address() Message-ID: <20191026193824.11926-20-mst@redhat.com> References: <20191026193824.11926-1-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20191026193824.11926-1-mst@redhat.com> X-Mailer: git-send-email 2.22.0.678.g13338e74b8 X-Mutt-Fcc: =sent X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Peter Maydell , Thomas Huth , Sergio Lopez , Stefan Hajnoczi , Paolo Bonzini , Philippe =?utf-8?q?Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Stefan Hajnoczi Instead of just passing the vring page frame number, pass the full QVirtQueue. This will allow the VIRTIO 1.0 transport to program the fine-grained vring address registers in the future. Signed-off-by: Stefan Hajnoczi Reviewed-by: Sergio Lopez Reviewed-by: Thomas Huth Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20191023100425.12168-12-stefanha@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/libqos/virtio-mmio.c | 6 ++++-- tests/libqos/virtio-pci.c | 6 ++++-- tests/libqos/virtio.h | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/libqos/virtio-mmio.c b/tests/libqos/virtio-mmio.c index 4db1f1b8bc..e0a2bd7bc6 100644 --- a/tests/libqos/virtio-mmio.c +++ b/tests/libqos/virtio-mmio.c @@ -143,9 +143,11 @@ static uint16_t qvirtio_mmio_get_queue_size(QVirtioDevice *d) return (uint16_t)qtest_readl(dev->qts, dev->addr + QVIRTIO_MMIO_QUEUE_NUM_MAX); } -static void qvirtio_mmio_set_queue_address(QVirtioDevice *d, uint32_t pfn) +static void qvirtio_mmio_set_queue_address(QVirtioDevice *d, QVirtQueue *vq) { QVirtioMMIODevice *dev = container_of(d, QVirtioMMIODevice, vdev); + uint64_t pfn = vq->desc / dev->page_size; + qtest_writel(dev->qts, dev->addr + QVIRTIO_MMIO_QUEUE_PFN, pfn); } @@ -179,7 +181,7 @@ static QVirtQueue *qvirtio_mmio_virtqueue_setup(QVirtioDevice *d, addr = guest_alloc(alloc, qvring_size(vq->size, dev->page_size)); qvring_init(dev->qts, alloc, vq, addr); - qvirtio_mmio_set_queue_address(d, vq->desc / dev->page_size); + qvirtio_mmio_set_queue_address(d, vq); return vq; } diff --git a/tests/libqos/virtio-pci.c b/tests/libqos/virtio-pci.c index 7ecf5d0a52..e4fa318dcc 100644 --- a/tests/libqos/virtio-pci.c +++ b/tests/libqos/virtio-pci.c @@ -199,9 +199,11 @@ static uint16_t qvirtio_pci_get_queue_size(QVirtioDevice *d) return qpci_io_readw(dev->pdev, dev->bar, VIRTIO_PCI_QUEUE_NUM); } -static void qvirtio_pci_set_queue_address(QVirtioDevice *d, uint32_t pfn) +static void qvirtio_pci_set_queue_address(QVirtioDevice *d, QVirtQueue *vq) { QVirtioPCIDevice *dev = container_of(d, QVirtioPCIDevice, vdev); + uint64_t pfn = vq->desc / VIRTIO_PCI_VRING_ALIGN; + qpci_io_writel(dev->pdev, dev->bar, VIRTIO_PCI_QUEUE_PFN, pfn); } @@ -239,7 +241,7 @@ static QVirtQueue *qvirtio_pci_virtqueue_setup(QVirtioDevice *d, addr = guest_alloc(alloc, qvring_size(vqpci->vq.size, VIRTIO_PCI_VRING_ALIGN)); qvring_init(qvpcidev->pdev->bus->qts, alloc, &vqpci->vq, addr); - qvirtio_pci_set_queue_address(d, vqpci->vq.desc / VIRTIO_PCI_VRING_ALIGN); + qvirtio_pci_set_queue_address(d, &vqpci->vq); return &vqpci->vq; } diff --git a/tests/libqos/virtio.h b/tests/libqos/virtio.h index ebbff5193b..529ef7555a 100644 --- a/tests/libqos/virtio.h +++ b/tests/libqos/virtio.h @@ -81,7 +81,7 @@ struct QVirtioBus { uint16_t (*get_queue_size)(QVirtioDevice *d); /* Set the address of the selected queue */ - void (*set_queue_address)(QVirtioDevice *d, uint32_t pfn); + void (*set_queue_address)(QVirtioDevice *d, QVirtQueue *vq); /* Setup the virtqueue specified by index */ QVirtQueue *(*virtqueue_setup)(QVirtioDevice *d, QGuestAllocator *alloc,