From patchwork Mon Apr 25 12:46:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 8927671 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id BD0F1BF29F for ; Mon, 25 Apr 2016 12:48:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CE23E20204 for ; Mon, 25 Apr 2016 12:48:47 +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 A892220120 for ; Mon, 25 Apr 2016 12:48:45 +0000 (UTC) Received: from localhost ([::1]:59707 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aufwS-0005WS-Sn for patchwork-qemu-devel@patchwork.kernel.org; Mon, 25 Apr 2016 08:48:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49241) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aufuD-0000kb-Vy for qemu-devel@nongnu.org; Mon, 25 Apr 2016 08:46:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aufuC-00059V-6G for qemu-devel@nongnu.org; Mon, 25 Apr 2016 08:46:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53694) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aufuB-00059P-Vb for qemu-devel@nongnu.org; Mon, 25 Apr 2016 08:46:24 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (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 936158AE73; Mon, 25 Apr 2016 12:46:23 +0000 (UTC) Received: from localhost (ovpn-112-54.ams2.redhat.com [10.36.112.54]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u3PCkMN8008244; Mon, 25 Apr 2016 08:46:22 -0400 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Date: Mon, 25 Apr 2016 13:46:09 +0100 Message-Id: <1461588373-26486-5-git-send-email-stefanha@redhat.com> In-Reply-To: <1461588373-26486-1-git-send-email-stefanha@redhat.com> References: <1461588373-26486-1-git-send-email-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 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 for-2.7 4/8] libqos: drop duplicated virtio_ring.h bit 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 , 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 Note that virtio_ring.h defines feature bits using their bit number: #define VIRTIO_RING_F_INDIRECT_DESC 28 On the other hand libqos virtio.h uses the bit mask: #define QVIRTIO_F_RING_INDIRECT_DESC 0x10000000 The patch makes the necessary adjustments. I have used "1 << BITMASK" instead of "1ULL << BITMASK" because the 64-bit feature fields are not implemented in libqos virtio. Signed-off-by: Stefan Hajnoczi --- tests/libqos/virtio-mmio.c | 5 +++-- tests/libqos/virtio-pci.c | 5 +++-- tests/libqos/virtio.c | 13 +++++++------ tests/libqos/virtio.h | 14 -------------- tests/virtio-blk-test.c | 21 +++++++++++++-------- tests/virtio-net-test.c | 5 +++-- 6 files changed, 29 insertions(+), 34 deletions(-) diff --git a/tests/libqos/virtio-mmio.c b/tests/libqos/virtio-mmio.c index a4382f3..7756b92 100644 --- a/tests/libqos/virtio-mmio.c +++ b/tests/libqos/virtio-mmio.c @@ -14,6 +14,7 @@ #include "libqos/virtio-mmio.h" #include "libqos/malloc.h" #include "libqos/malloc-generic.h" +#include "standard-headers/linux/virtio_ring.h" static uint8_t qvirtio_mmio_config_readb(QVirtioDevice *d, uint64_t addr) { @@ -136,8 +137,8 @@ static QVirtQueue *qvirtio_mmio_virtqueue_setup(QVirtioDevice *d, vq->free_head = 0; vq->num_free = vq->size; vq->align = dev->page_size; - vq->indirect = (dev->features & QVIRTIO_F_RING_INDIRECT_DESC) != 0; - vq->event = (dev->features & QVIRTIO_F_RING_EVENT_IDX) != 0; + vq->indirect = (dev->features & (1 << VIRTIO_RING_F_INDIRECT_DESC)) != 0; + vq->event = (dev->features & (1 << VIRTIO_RING_F_EVENT_IDX)) != 0; writel(dev->addr + QVIRTIO_MMIO_QUEUE_NUM, vq->size); diff --git a/tests/libqos/virtio-pci.c b/tests/libqos/virtio-pci.c index 275c14d..4a0bef8 100644 --- a/tests/libqos/virtio-pci.c +++ b/tests/libqos/virtio-pci.c @@ -16,6 +16,7 @@ #include "libqos/pci-pc.h" #include "libqos/malloc.h" #include "libqos/malloc-pc.h" +#include "standard-headers/linux/virtio_ring.h" #include "hw/pci/pci.h" #include "hw/pci/pci_regs.h" @@ -213,8 +214,8 @@ static QVirtQueue *qvirtio_pci_virtqueue_setup(QVirtioDevice *d, vqpci->vq.free_head = 0; vqpci->vq.num_free = vqpci->vq.size; vqpci->vq.align = QVIRTIO_PCI_ALIGN; - vqpci->vq.indirect = (feat & QVIRTIO_F_RING_INDIRECT_DESC) != 0; - vqpci->vq.event = (feat & QVIRTIO_F_RING_EVENT_IDX) != 0; + vqpci->vq.indirect = (feat & (1 << VIRTIO_RING_F_INDIRECT_DESC)) != 0; + vqpci->vq.event = (feat & (1 << VIRTIO_RING_F_EVENT_IDX)) != 0; vqpci->msix_entry = -1; vqpci->msix_addr = 0; diff --git a/tests/libqos/virtio.c b/tests/libqos/virtio.c index ee9e892..69b5426 100644 --- a/tests/libqos/virtio.c +++ b/tests/libqos/virtio.c @@ -12,6 +12,7 @@ #include "libqtest.h" #include "libqos/virtio.h" #include "standard-headers/linux/virtio_config.h" +#include "standard-headers/linux/virtio_ring.h" uint8_t qvirtio_config_readb(const QVirtioBus *bus, QVirtioDevice *d, uint64_t addr) @@ -173,7 +174,7 @@ QVRingIndirectDesc *qvring_indirect_desc_setup(QVirtioDevice *d, /* indirect->desc[i].addr */ writeq(indirect->desc + (16 * i), 0); /* indirect->desc[i].flags */ - writew(indirect->desc + (16 * i) + 12, QVRING_DESC_F_NEXT); + writew(indirect->desc + (16 * i) + 12, VRING_DESC_F_NEXT); /* indirect->desc[i].next */ writew(indirect->desc + (16 * i) + 14, i + 1); } @@ -191,7 +192,7 @@ void qvring_indirect_desc_add(QVRingIndirectDesc *indirect, uint64_t data, flags = readw(indirect->desc + (16 * indirect->index) + 12); if (write) { - flags |= QVRING_DESC_F_WRITE; + flags |= VRING_DESC_F_WRITE; } /* indirect->desc[indirect->index].addr */ @@ -211,11 +212,11 @@ uint32_t qvirtqueue_add(QVirtQueue *vq, uint64_t data, uint32_t len, bool write, vq->num_free--; if (write) { - flags |= QVRING_DESC_F_WRITE; + flags |= VRING_DESC_F_WRITE; } if (next) { - flags |= QVRING_DESC_F_NEXT; + flags |= VRING_DESC_F_NEXT; } /* vq->desc[vq->free_head].addr */ @@ -242,7 +243,7 @@ uint32_t qvirtqueue_add_indirect(QVirtQueue *vq, QVRingIndirectDesc *indirect) writel(vq->desc + (16 * vq->free_head) + 8, sizeof(QVRingDesc) * indirect->elem); /* vq->desc[vq->free_head].flags */ - writew(vq->desc + (16 * vq->free_head) + 12, QVRING_DESC_F_INDIRECT); + writew(vq->desc + (16 * vq->free_head) + 12, VRING_DESC_F_INDIRECT); return vq->free_head++; /* Return and increase, in this order */ } @@ -268,7 +269,7 @@ void qvirtqueue_kick(const QVirtioBus *bus, QVirtioDevice *d, QVirtQueue *vq, (sizeof(struct QVRingUsedElem) * vq->size)); /* < 1 because we add elements to avail queue one by one */ - if ((flags & QVRING_USED_F_NO_NOTIFY) == 0 && + if ((flags & VRING_USED_F_NO_NOTIFY) == 0 && (!vq->event || (uint16_t)(idx-avail_event) < 1)) { bus->virtqueue_kick(d, vq); } diff --git a/tests/libqos/virtio.h b/tests/libqos/virtio.h index 993ae0e..2af8036 100644 --- a/tests/libqos/virtio.h +++ b/tests/libqos/virtio.h @@ -12,22 +12,8 @@ #include "libqos/malloc.h" -#define QVIRTIO_F_RING_INDIRECT_DESC 0x10000000 -#define QVIRTIO_F_RING_EVENT_IDX 0x20000000 #define QVIRTIO_F_BAD_FEATURE 0x40000000 -#define QVRING_DESC_F_NEXT 0x1 -#define QVRING_DESC_F_WRITE 0x2 -#define QVRING_DESC_F_INDIRECT 0x4 - -#define QVIRTIO_F_RING_INDIRECT_DESC 0x10000000 -#define QVIRTIO_F_RING_EVENT_IDX 0x20000000 -#define QVIRTIO_F_BAD_FEATURE 0x40000000 - -#define QVRING_AVAIL_F_NO_INTERRUPT 1 - -#define QVRING_USED_F_NO_NOTIFY 1 - typedef struct QVirtioDevice { /* Device type */ uint16_t device_type; diff --git a/tests/virtio-blk-test.c b/tests/virtio-blk-test.c index bfeffc4..57a2635 100644 --- a/tests/virtio-blk-test.c +++ b/tests/virtio-blk-test.c @@ -21,6 +21,7 @@ #include "qemu/bswap.h" #include "standard-headers/linux/virtio_ids.h" #include "standard-headers/linux/virtio_config.h" +#include "standard-headers/linux/virtio_ring.h" #define QVIRTIO_BLK_F_BARRIER 0x00000001 #define QVIRTIO_BLK_F_SIZE_MAX 0x00000002 @@ -184,7 +185,8 @@ static void test_basic(const QVirtioBus *bus, QVirtioDevice *dev, features = qvirtio_get_features(bus, dev); features = features & ~(QVIRTIO_F_BAD_FEATURE | - QVIRTIO_F_RING_INDIRECT_DESC | QVIRTIO_F_RING_EVENT_IDX | + (1 << VIRTIO_RING_F_INDIRECT_DESC) | + (1 << VIRTIO_RING_F_EVENT_IDX) | QVIRTIO_BLK_F_SCSI); qvirtio_set_features(bus, dev, features); @@ -350,9 +352,10 @@ static void pci_indirect(void) g_assert_cmpint(capacity, ==, TEST_IMAGE_SIZE / 512); features = qvirtio_get_features(&qvirtio_pci, &dev->vdev); - g_assert_cmphex(features & QVIRTIO_F_RING_INDIRECT_DESC, !=, 0); - features = features & ~(QVIRTIO_F_BAD_FEATURE | QVIRTIO_F_RING_EVENT_IDX | - QVIRTIO_BLK_F_SCSI); + g_assert_cmphex(features & (1 << VIRTIO_RING_F_INDIRECT_DESC), !=, 0); + features = features & ~(QVIRTIO_F_BAD_FEATURE | + (1 << VIRTIO_RING_F_EVENT_IDX) | + QVIRTIO_BLK_F_SCSI); qvirtio_set_features(&qvirtio_pci, &dev->vdev, features); alloc = pc_alloc_init(); @@ -492,8 +495,9 @@ static void pci_msix(void) features = qvirtio_get_features(&qvirtio_pci, &dev->vdev); features = features & ~(QVIRTIO_F_BAD_FEATURE | - QVIRTIO_F_RING_INDIRECT_DESC | - QVIRTIO_F_RING_EVENT_IDX | QVIRTIO_BLK_F_SCSI); + (1 << VIRTIO_RING_F_INDIRECT_DESC) | + (1 << VIRTIO_RING_F_EVENT_IDX) | + QVIRTIO_BLK_F_SCSI); qvirtio_set_features(&qvirtio_pci, &dev->vdev, features); vqpci = (QVirtQueuePCI *)qvirtqueue_setup(&qvirtio_pci, &dev->vdev, @@ -607,8 +611,9 @@ static void pci_idx(void) features = qvirtio_get_features(&qvirtio_pci, &dev->vdev); features = features & ~(QVIRTIO_F_BAD_FEATURE | - QVIRTIO_F_RING_INDIRECT_DESC | - VIRTIO_F_NOTIFY_ON_EMPTY | QVIRTIO_BLK_F_SCSI); + (1 << VIRTIO_RING_F_INDIRECT_DESC) | + (1 << VIRTIO_F_NOTIFY_ON_EMPTY) | + QVIRTIO_BLK_F_SCSI); qvirtio_set_features(&qvirtio_pci, &dev->vdev, features); vqpci = (QVirtQueuePCI *)qvirtqueue_setup(&qvirtio_pci, &dev->vdev, diff --git a/tests/virtio-net-test.c b/tests/virtio-net-test.c index 7fd7a2f..9c8114d 100644 --- a/tests/virtio-net-test.c +++ b/tests/virtio-net-test.c @@ -22,6 +22,7 @@ #include "qemu/bswap.h" #include "hw/virtio/virtio-net.h" #include "standard-headers/linux/virtio_ids.h" +#include "standard-headers/linux/virtio_ring.h" #define PCI_SLOT_HP 0x06 #define PCI_SLOT 0x04 @@ -71,8 +72,8 @@ static void driver_init(const QVirtioBus *bus, QVirtioDevice *dev) features = qvirtio_get_features(bus, dev); features = features & ~(QVIRTIO_F_BAD_FEATURE | - QVIRTIO_F_RING_INDIRECT_DESC | - QVIRTIO_F_RING_EVENT_IDX); + (1 << VIRTIO_RING_F_INDIRECT_DESC) | + (1 << VIRTIO_RING_F_EVENT_IDX)); qvirtio_set_features(bus, dev, features); qvirtio_set_driver_ok(bus, dev);