aboutsummaryrefslogtreecommitdiff
path: root/lib/libvirtio/virtio.h
diff options
context:
space:
mode:
authorAlexey Kardashevskiy <aik@ozlabs.ru>2019-12-04 13:06:27 +1100
committerAlexey Kardashevskiy <aik@ozlabs.ru>2019-12-05 15:18:54 +1100
commit7477a174abc03d3e6f508412f69ea0bbd63b93ac (patch)
treec31c82b4c3f17888379468185d5229e1a5201aed /lib/libvirtio/virtio.h
parent48b86c575ff730f6d8ca5071fffdf7c0f4706695 (diff)
downloadSLOF-7477a174abc03d3e6f508412f69ea0bbd63b93ac.zip
SLOF-7477a174abc03d3e6f508412f69ea0bbd63b93ac.tar.gz
SLOF-7477a174abc03d3e6f508412f69ea0bbd63b93ac.tar.bz2
virtio: Enable IOMMU
When QEMU is started with iommu_platform=on, the guest driver must accept it or the device will fail. This enables IOMMU support for virtio-net, -scsi, -block, -serial, -9p devices. -serial and -9p are only compile tested though. For virtio-net we map all RX buffers once and TX when xmit() is called and unmap older pages when we are about to reuse the VQ descriptor. As all other devices are synchronous, we unmap IOMMU pages right after completion of a transaction. This depends on QEMU's: https://patchwork.ozlabs.org/patch/1194067/ Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru> Tested-by: Michael Roth <mdroth@linux.vnet.ibm.com> --- Changes: v5: * fixed queue size calculation * reworked virtio_free_desc() to only unmap what is has mapped v4: * ditched vqs->id in virtio_queue_init_vq v2: * added Mike's fs/dma-instance-function.fs * total rework
Diffstat (limited to 'lib/libvirtio/virtio.h')
-rw-r--r--lib/libvirtio/virtio.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/libvirtio/virtio.h b/lib/libvirtio/virtio.h
index 7efc1e5..c4eafe4 100644
--- a/lib/libvirtio/virtio.h
+++ b/lib/libvirtio/virtio.h
@@ -29,6 +29,7 @@
#define VIRTIO_F_RING_INDIRECT_DESC BIT(28)
#define VIRTIO_F_RING_EVENT_IDX BIT(29)
#define VIRTIO_F_VERSION_1 BIT(32)
+#define VIRTIO_F_IOMMU_PLATFORM BIT(33)
#define VIRTIO_TIMEOUT 5000 /* 5 sec timeout */
@@ -83,6 +84,8 @@ struct vqs {
struct vring_desc *desc;
struct vring_avail *avail;
struct vring_used *used;
+ void **desc_gpas; /* to get gpa from desc->addr (which is ioba) */
+ uint64_t bus_desc;
};
struct virtio_device {
@@ -108,6 +111,8 @@ extern struct vring_used *virtio_get_vring_used(struct virtio_device *dev, int q
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 void virtio_free_desc(struct vqs *vq, int id, uint64_t features);
+void *virtio_desc_addr(struct virtio_device *vdev, int queue, 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);