From patchwork Mon May 9 12:08:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 9045891 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 00C609F1D3 for ; Mon, 9 May 2016 12:16:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0AA9B200ED for ; Mon, 9 May 2016 12:16:58 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CBB51200E6 for ; Mon, 9 May 2016 12:16:56 +0000 (UTC) Received: from localhost ([::1]:40914 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1azk7L-0002EX-W7 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 09 May 2016 08:16:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39370) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1azjzv-00041U-Pq for qemu-devel@nongnu.org; Mon, 09 May 2016 08:09:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1azjzn-0004hP-5e for qemu-devel@nongnu.org; Mon, 09 May 2016 08:09:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49237) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1azjzm-0004hG-U7 for qemu-devel@nongnu.org; Mon, 09 May 2016 08:09:07 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9EED281114; Mon, 9 May 2016 12:09:06 +0000 (UTC) Received: from localhost (ovpn-112-46.ams2.redhat.com [10.36.112.46]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u49C953q024038; Mon, 9 May 2016 08:09:06 -0400 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Date: Mon, 9 May 2016 13:08:07 +0100 Message-Id: <1462795687-25698-24-git-send-email-stefanha@redhat.com> In-Reply-To: <1462795687-25698-1-git-send-email-stefanha@redhat.com> References: <1462795687-25698-1-git-send-email-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 09 May 2016 12:09:06 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 23/23] libqos: drop duplicated virtio_pci.h definitions 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: marc.mari.barcelo@gmail.com, Paolo Bonzini , jsnow@redhat.com, Stefan Hajnoczi Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Stefan Hajnoczi --- tests/libqos/virtio-pci.c | 42 ++++++++++++++++++++++-------------------- tests/libqos/virtio-pci.h | 17 ----------------- tests/virtio-blk-test.c | 11 ++++++----- tests/virtio-scsi-test.c | 3 ++- 4 files changed, 30 insertions(+), 43 deletions(-) diff --git a/tests/libqos/virtio-pci.c b/tests/libqos/virtio-pci.c index 0b98ef2..cdde0b3 100644 --- a/tests/libqos/virtio-pci.c +++ b/tests/libqos/virtio-pci.c @@ -17,6 +17,7 @@ #include "libqos/malloc.h" #include "libqos/malloc-pc.h" #include "standard-headers/linux/virtio_ring.h" +#include "standard-headers/linux/virtio_pci.h" #include "hw/pci/pci.h" #include "hw/pci/pci_regs.h" @@ -104,31 +105,31 @@ static uint64_t qvirtio_pci_config_readq(QVirtioDevice *d, uint64_t addr) static uint32_t qvirtio_pci_get_features(QVirtioDevice *d) { QVirtioPCIDevice *dev = (QVirtioPCIDevice *)d; - return qpci_io_readl(dev->pdev, dev->addr + QVIRTIO_PCI_DEVICE_FEATURES); + return qpci_io_readl(dev->pdev, dev->addr + VIRTIO_PCI_HOST_FEATURES); } static void qvirtio_pci_set_features(QVirtioDevice *d, uint32_t features) { QVirtioPCIDevice *dev = (QVirtioPCIDevice *)d; - qpci_io_writel(dev->pdev, dev->addr + QVIRTIO_PCI_GUEST_FEATURES, features); + qpci_io_writel(dev->pdev, dev->addr + VIRTIO_PCI_GUEST_FEATURES, features); } static uint32_t qvirtio_pci_get_guest_features(QVirtioDevice *d) { QVirtioPCIDevice *dev = (QVirtioPCIDevice *)d; - return qpci_io_readl(dev->pdev, dev->addr + QVIRTIO_PCI_GUEST_FEATURES); + return qpci_io_readl(dev->pdev, dev->addr + VIRTIO_PCI_GUEST_FEATURES); } static uint8_t qvirtio_pci_get_status(QVirtioDevice *d) { QVirtioPCIDevice *dev = (QVirtioPCIDevice *)d; - return qpci_io_readb(dev->pdev, dev->addr + QVIRTIO_PCI_DEVICE_STATUS); + return qpci_io_readb(dev->pdev, dev->addr + VIRTIO_PCI_STATUS); } static void qvirtio_pci_set_status(QVirtioDevice *d, uint8_t status) { QVirtioPCIDevice *dev = (QVirtioPCIDevice *)d; - qpci_io_writeb(dev->pdev, dev->addr + QVIRTIO_PCI_DEVICE_STATUS, status); + qpci_io_writeb(dev->pdev, dev->addr + VIRTIO_PCI_STATUS, status); } static bool qvirtio_pci_get_queue_isr_status(QVirtioDevice *d, QVirtQueue *vq) @@ -152,7 +153,7 @@ static bool qvirtio_pci_get_queue_isr_status(QVirtioDevice *d, QVirtQueue *vq) } } } else { - return qpci_io_readb(dev->pdev, dev->addr + QVIRTIO_PCI_ISR_STATUS) & 1; + return qpci_io_readb(dev->pdev, dev->addr + VIRTIO_PCI_ISR) & 1; } } @@ -176,26 +177,26 @@ static bool qvirtio_pci_get_config_isr_status(QVirtioDevice *d) } } } else { - return qpci_io_readb(dev->pdev, dev->addr + QVIRTIO_PCI_ISR_STATUS) & 2; + return qpci_io_readb(dev->pdev, dev->addr + VIRTIO_PCI_ISR) & 2; } } static void qvirtio_pci_queue_select(QVirtioDevice *d, uint16_t index) { QVirtioPCIDevice *dev = (QVirtioPCIDevice *)d; - qpci_io_writeb(dev->pdev, dev->addr + QVIRTIO_PCI_QUEUE_SELECT, index); + qpci_io_writeb(dev->pdev, dev->addr + VIRTIO_PCI_QUEUE_SEL, index); } static uint16_t qvirtio_pci_get_queue_size(QVirtioDevice *d) { QVirtioPCIDevice *dev = (QVirtioPCIDevice *)d; - return qpci_io_readw(dev->pdev, dev->addr + QVIRTIO_PCI_QUEUE_SIZE); + return qpci_io_readw(dev->pdev, dev->addr + VIRTIO_PCI_QUEUE_NUM); } static void qvirtio_pci_set_queue_address(QVirtioDevice *d, uint32_t pfn) { QVirtioPCIDevice *dev = (QVirtioPCIDevice *)d; - qpci_io_writel(dev->pdev, dev->addr + QVIRTIO_PCI_QUEUE_ADDRESS, pfn); + qpci_io_writel(dev->pdev, dev->addr + VIRTIO_PCI_QUEUE_PFN, pfn); } static QVirtQueue *qvirtio_pci_virtqueue_setup(QVirtioDevice *d, @@ -213,7 +214,7 @@ static QVirtQueue *qvirtio_pci_virtqueue_setup(QVirtioDevice *d, vqpci->vq.size = qvirtio_pci_get_queue_size(d); vqpci->vq.free_head = 0; vqpci->vq.num_free = vqpci->vq.size; - vqpci->vq.align = QVIRTIO_PCI_ALIGN; + vqpci->vq.align = VIRTIO_PCI_VRING_ALIGN; vqpci->vq.indirect = (feat & (1u << VIRTIO_RING_F_INDIRECT_DESC)) != 0; vqpci->vq.event = (feat & (1u << VIRTIO_RING_F_EVENT_IDX)) != 0; @@ -227,9 +228,10 @@ static QVirtQueue *qvirtio_pci_virtqueue_setup(QVirtioDevice *d, /* Check power of 2 */ g_assert_cmpint(vqpci->vq.size & (vqpci->vq.size - 1), ==, 0); - addr = guest_alloc(alloc, qvring_size(vqpci->vq.size, QVIRTIO_PCI_ALIGN)); + addr = guest_alloc(alloc, qvring_size(vqpci->vq.size, + VIRTIO_PCI_VRING_ALIGN)); qvring_init(alloc, &vqpci->vq, addr); - qvirtio_pci_set_queue_address(d, vqpci->vq.desc / QVIRTIO_PCI_ALIGN); + qvirtio_pci_set_queue_address(d, vqpci->vq.desc / VIRTIO_PCI_VRING_ALIGN); return &vqpci->vq; } @@ -237,7 +239,7 @@ static QVirtQueue *qvirtio_pci_virtqueue_setup(QVirtioDevice *d, static void qvirtio_pci_virtqueue_kick(QVirtioDevice *d, QVirtQueue *vq) { QVirtioPCIDevice *dev = (QVirtioPCIDevice *)d; - qpci_io_writew(dev->pdev, dev->addr + QVIRTIO_PCI_QUEUE_NOTIFY, vq->index); + qpci_io_writew(dev->pdev, dev->addr + VIRTIO_PCI_QUEUE_NOTIFY, vq->index); } const QVirtioBus qvirtio_pci = { @@ -317,9 +319,9 @@ void qvirtqueue_pci_msix_setup(QVirtioPCIDevice *d, QVirtQueuePCI *vqpci, control & ~PCI_MSIX_ENTRY_CTRL_MASKBIT); qvirtio_pci_queue_select(&d->vdev, vqpci->vq.index); - qpci_io_writew(d->pdev, d->addr + QVIRTIO_PCI_MSIX_QUEUE_VECTOR, entry); - vector = qpci_io_readw(d->pdev, d->addr + QVIRTIO_PCI_MSIX_QUEUE_VECTOR); - g_assert_cmphex(vector, !=, QVIRTIO_MSI_NO_VECTOR); + qpci_io_writew(d->pdev, d->addr + VIRTIO_MSI_QUEUE_VECTOR, entry); + vector = qpci_io_readw(d->pdev, d->addr + VIRTIO_MSI_QUEUE_VECTOR); + g_assert_cmphex(vector, !=, VIRTIO_MSI_NO_VECTOR); } void qvirtio_pci_set_msix_configuration_vector(QVirtioPCIDevice *d, @@ -349,7 +351,7 @@ void qvirtio_pci_set_msix_configuration_vector(QVirtioPCIDevice *d, qpci_io_writel(d->pdev, addr + PCI_MSIX_ENTRY_VECTOR_CTRL, control & ~PCI_MSIX_ENTRY_CTRL_MASKBIT); - qpci_io_writew(d->pdev, d->addr + QVIRTIO_PCI_MSIX_CONF_VECTOR, entry); - vector = qpci_io_readw(d->pdev, d->addr + QVIRTIO_PCI_MSIX_CONF_VECTOR); - g_assert_cmphex(vector, !=, QVIRTIO_MSI_NO_VECTOR); + qpci_io_writew(d->pdev, d->addr + VIRTIO_MSI_CONFIG_VECTOR, entry); + vector = qpci_io_readw(d->pdev, d->addr + VIRTIO_MSI_CONFIG_VECTOR); + g_assert_cmphex(vector, !=, VIRTIO_MSI_NO_VECTOR); } diff --git a/tests/libqos/virtio-pci.h b/tests/libqos/virtio-pci.h index 8f0e52a..efcac2d 100644 --- a/tests/libqos/virtio-pci.h +++ b/tests/libqos/virtio-pci.h @@ -13,23 +13,6 @@ #include "libqos/virtio.h" #include "libqos/pci.h" -#define QVIRTIO_PCI_DEVICE_FEATURES 0x00 -#define QVIRTIO_PCI_GUEST_FEATURES 0x04 -#define QVIRTIO_PCI_QUEUE_ADDRESS 0x08 -#define QVIRTIO_PCI_QUEUE_SIZE 0x0C -#define QVIRTIO_PCI_QUEUE_SELECT 0x0E -#define QVIRTIO_PCI_QUEUE_NOTIFY 0x10 -#define QVIRTIO_PCI_DEVICE_STATUS 0x12 -#define QVIRTIO_PCI_ISR_STATUS 0x13 -#define QVIRTIO_PCI_MSIX_CONF_VECTOR 0x14 -#define QVIRTIO_PCI_MSIX_QUEUE_VECTOR 0x16 -#define QVIRTIO_PCI_DEVICE_SPECIFIC_MSIX 0x18 -#define QVIRTIO_PCI_DEVICE_SPECIFIC_NO_MSIX 0x14 - -#define QVIRTIO_PCI_ALIGN 4096 - -#define QVIRTIO_MSI_NO_VECTOR 0xFFFF - typedef struct QVirtioPCIDevice { QVirtioDevice vdev; QPCIDevice *pdev; diff --git a/tests/virtio-blk-test.c b/tests/virtio-blk-test.c index ff66d93..2c5d2db 100644 --- a/tests/virtio-blk-test.c +++ b/tests/virtio-blk-test.c @@ -23,6 +23,7 @@ #include "standard-headers/linux/virtio_config.h" #include "standard-headers/linux/virtio_ring.h" #include "standard-headers/linux/virtio_blk.h" +#include "standard-headers/linux/virtio_pci.h" #define TEST_IMAGE_SIZE (64 * 1024 * 1024) #define QVIRTIO_BLK_TIMEOUT_US (30 * 1000 * 1000) @@ -292,7 +293,7 @@ static void pci_basic(void) alloc, 0); /* MSI-X is not enabled */ - addr = dev->addr + QVIRTIO_PCI_DEVICE_SPECIFIC_NO_MSIX; + addr = dev->addr + VIRTIO_PCI_CONFIG_OFF(false); test_basic(&qvirtio_pci, &dev->vdev, alloc, &vqpci->vq, (uint64_t)(uintptr_t)addr); @@ -327,7 +328,7 @@ static void pci_indirect(void) dev = virtio_blk_pci_init(bus, PCI_SLOT); /* MSI-X is not enabled */ - addr = dev->addr + QVIRTIO_PCI_DEVICE_SPECIFIC_NO_MSIX; + addr = dev->addr + VIRTIO_PCI_CONFIG_OFF(false); capacity = qvirtio_config_readq(&qvirtio_pci, &dev->vdev, (uint64_t)(uintptr_t)addr); @@ -422,7 +423,7 @@ static void pci_config(void) dev = virtio_blk_pci_init(bus, PCI_SLOT); /* MSI-X is not enabled */ - addr = dev->addr + QVIRTIO_PCI_DEVICE_SPECIFIC_NO_MSIX; + addr = dev->addr + VIRTIO_PCI_CONFIG_OFF(false); capacity = qvirtio_config_readq(&qvirtio_pci, &dev->vdev, (uint64_t)(uintptr_t)addr); @@ -469,7 +470,7 @@ static void pci_msix(void) qvirtio_pci_set_msix_configuration_vector(dev, alloc, 0); /* MSI-X is enabled */ - addr = dev->addr + QVIRTIO_PCI_DEVICE_SPECIFIC_MSIX; + addr = dev->addr + VIRTIO_PCI_CONFIG_OFF(true); capacity = qvirtio_config_readq(&qvirtio_pci, &dev->vdev, (uint64_t)(uintptr_t)addr); @@ -585,7 +586,7 @@ static void pci_idx(void) qvirtio_pci_set_msix_configuration_vector(dev, alloc, 0); /* MSI-X is enabled */ - addr = dev->addr + QVIRTIO_PCI_DEVICE_SPECIFIC_MSIX; + addr = dev->addr + VIRTIO_PCI_CONFIG_OFF(true); capacity = qvirtio_config_readq(&qvirtio_pci, &dev->vdev, (uint64_t)(uintptr_t)addr); diff --git a/tests/virtio-scsi-test.c b/tests/virtio-scsi-test.c index 8b8f5f3..71f5aeb 100644 --- a/tests/virtio-scsi-test.c +++ b/tests/virtio-scsi-test.c @@ -19,6 +19,7 @@ #include "libqos/malloc-pc.h" #include "libqos/malloc-generic.h" #include "standard-headers/linux/virtio_ids.h" +#include "standard-headers/linux/virtio_pci.h" #include "standard-headers/linux/virtio_scsi.h" #define PCI_SLOT 0x02 @@ -158,7 +159,7 @@ static QVirtIOSCSI *qvirtio_scsi_pci_init(int slot) qvirtio_set_acknowledge(&qvirtio_pci, vs->dev); qvirtio_set_driver(&qvirtio_pci, vs->dev); - addr = dev->addr + QVIRTIO_PCI_DEVICE_SPECIFIC_NO_MSIX; + addr = dev->addr + VIRTIO_PCI_CONFIG_OFF(false); vs->num_queues = qvirtio_config_readl(&qvirtio_pci, vs->dev, (uint64_t)(uintptr_t)addr);