diff options
author | Alexey Kardashevskiy <aik@ozlabs.ru> | 2019-12-04 13:06:27 +1100 |
---|---|---|
committer | Alexey Kardashevskiy <aik@ozlabs.ru> | 2019-12-05 15:18:54 +1100 |
commit | 7477a174abc03d3e6f508412f69ea0bbd63b93ac (patch) | |
tree | c31c82b4c3f17888379468185d5229e1a5201aed /lib/libvirtio/virtio-net.c | |
parent | 48b86c575ff730f6d8ca5071fffdf7c0f4706695 (diff) | |
download | SLOF-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-net.c')
-rw-r--r-- | lib/libvirtio/virtio-net.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/libvirtio/virtio-net.c b/lib/libvirtio/virtio-net.c index ae67883..5a0d190 100644 --- a/lib/libvirtio/virtio-net.c +++ b/lib/libvirtio/virtio-net.c @@ -255,6 +255,9 @@ static int virtionet_xmit(struct virtio_net *vnet, char *buf, int len) idx = virtio_modern16_to_cpu(vdev, vq_tx->avail->idx); id = (idx * 2) % vq_tx->size; + virtio_free_desc(vq_tx, id, vdev->features); + virtio_free_desc(vq_tx, id + 1, vdev->features); + /* Set up virtqueue descriptor for header */ virtio_fill_desc(vq_tx, id, vdev->features, (uint64_t)nethdr, net_hdr_size, VRING_DESC_F_NEXT, id + 1); @@ -317,7 +320,7 @@ static int virtionet_receive(struct virtio_net *vnet, char *buf, int maxlen) #endif /* Copy data to destination buffer */ - memcpy(buf, (void *)virtio_modern64_to_cpu(vdev, vq_rx->desc[id].addr), len); + memcpy(buf, virtio_desc_addr(vdev, VQ_RX, id), len); /* Move indices to next entries */ last_rx_idx = last_rx_idx + 1; |