diff options
author | Alexey Kardashevskiy <aik@ozlabs.ru> | 2019-11-07 17:47:13 +1100 |
---|---|---|
committer | Alexey Kardashevskiy <aik@ozlabs.ru> | 2019-12-05 14:41:07 +1100 |
commit | 300384f3dc68588a051f5737aee3b5eab4dd19e4 (patch) | |
tree | 5b96c2de68d164ffd4c385ed8255449e596f0f89 /lib/libvirtio/virtio.h | |
parent | ac4c07a9a416f72cd0df0af1778693a5a5060523 (diff) | |
download | SLOF-300384f3dc68588a051f5737aee3b5eab4dd19e4.zip SLOF-300384f3dc68588a051f5737aee3b5eab4dd19e4.tar.gz SLOF-300384f3dc68588a051f5737aee3b5eab4dd19e4.tar.bz2 |
virtio: Store queue descriptors in virtio_device
At the moment desc/avail/used pointers are read from the device every
time we need them. This works for now unless iommu_platform=on is used,
desc/avail/used stored in the config space are bus addresses while
SLOF should keep using the guest physical addresses.
virtio-net stores queue descriptors already, virtio-serial does it in
global statics, move them into virtio_device.
The next patch will use this to allow IOMMU.
While at this, move repeating avail->flags/idx setup into
virtio_queue_init_vq() except virtio-serial which vq_rx->avail->idx is
setup differently.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
Changes:
v4:
* removed vqs::id as it is not really used
* replaced vq_size with vq->size in virtio-serial.c
Diffstat (limited to 'lib/libvirtio/virtio.h')
-rw-r--r-- | lib/libvirtio/virtio.h | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/lib/libvirtio/virtio.h b/lib/libvirtio/virtio.h index b65c716..7efc1e5 100644 --- a/lib/libvirtio/virtio.h +++ b/lib/libvirtio/virtio.h @@ -14,7 +14,6 @@ #define _LIBVIRTIO_H #include <stdint.h> -#include <stdbool.h> /* Device status bits */ #define VIRTIO_STAT_ACKNOWLEDGE 1 @@ -78,8 +77,16 @@ struct virtio_cap { uint8_t cap_id; }; +struct vqs { + uint32_t size; + void *buf_mem; + struct vring_desc *desc; + struct vring_avail *avail; + struct vring_used *used; +}; + struct virtio_device { - uint32_t is_modern; /* Indicates whether to use virtio 1.0 */ + uint64_t features; struct virtio_cap legacy; struct virtio_cap common; struct virtio_cap notify; @@ -87,15 +94,7 @@ struct virtio_device { struct virtio_cap device; struct virtio_cap pci; uint32_t notify_off_mul; -}; - -struct vqs { - uint64_t id; /* Queue ID */ - uint32_t size; - void *buf_mem; - struct vring_desc *desc; - struct vring_avail *avail; - struct vring_used *used; + struct vqs vq[3]; }; /* Parts of the virtqueue are aligned on a 4096 byte page boundary */ @@ -106,10 +105,10 @@ extern unsigned int virtio_get_qsize(struct virtio_device *dev, int queue); extern struct vring_desc *virtio_get_vring_desc(struct virtio_device *dev, int queue); extern struct vring_avail *virtio_get_vring_avail(struct virtio_device *dev, int queue); extern struct vring_used *virtio_get_vring_used(struct virtio_device *dev, int queue); -extern void virtio_fill_desc(struct vring_desc *desc, bool is_modern, +extern void virtio_fill_desc(struct vqs *vq, int id, uint64_t features, uint64_t addr, uint32_t len, uint16_t flags, uint16_t next); -extern int virtio_queue_init_vq(struct virtio_device *dev, struct vqs *vq, unsigned int id); +extern struct vqs *virtio_queue_init_vq(struct virtio_device *dev, unsigned int id); extern void virtio_queue_term_vq(struct virtio_device *dev, struct vqs *vq, unsigned int id); extern struct virtio_device *virtio_setup_vd(void); |