diff options
Diffstat (limited to 'tests/libqos')
-rw-r--r-- | tests/libqos/virtio-mmio.c | 5 | ||||
-rw-r--r-- | tests/libqos/virtio-pci.c | 5 | ||||
-rw-r--r-- | tests/libqos/virtio.c | 13 | ||||
-rw-r--r-- | tests/libqos/virtio.h | 14 |
4 files changed, 13 insertions, 24 deletions
diff --git a/tests/libqos/virtio-mmio.c b/tests/libqos/virtio-mmio.c index e15b480..ccb92d9 100644 --- a/tests/libqos/virtio-mmio.c +++ b/tests/libqos/virtio-mmio.c @@ -13,6 +13,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) { @@ -135,8 +136,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 & (1u << VIRTIO_RING_F_INDIRECT_DESC)) != 0; + vq->event = (dev->features & (1u << 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 dc867d7..2418b7d 100644 --- a/tests/libqos/virtio-pci.c +++ b/tests/libqos/virtio-pci.c @@ -15,6 +15,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" @@ -212,8 +213,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 & (1u << VIRTIO_RING_F_INDIRECT_DESC)) != 0; + vqpci->vq.event = (feat & (1u << 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 e3f6194..0a3e05b 100644 --- a/tests/libqos/virtio.c +++ b/tests/libqos/virtio.c @@ -11,6 +11,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) @@ -172,7 +173,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); } @@ -190,7 +191,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 */ @@ -210,11 +211,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 */ @@ -241,7 +242,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 */ } @@ -267,7 +268,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; |