aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/include/linux/virtio.h
diff options
context:
space:
mode:
authorAndy Lutomirski <luto@kernel.org>2016-02-02 21:46:37 -0800
committerMichael S. Tsirkin <mst@redhat.com>2016-03-02 17:01:57 +0200
commit2a2d1382fe9dccfce6f9c60a9c9fd2f0fe5bcf2b (patch)
treeab3783be11369f689e3e7aebe0c438ab6746375f /include/linux/virtio.h
parentvirtio_ring: Support DMA APIs (diff)
downloadwireguard-linux-2a2d1382fe9dccfce6f9c60a9c9fd2f0fe5bcf2b.tar.xz
wireguard-linux-2a2d1382fe9dccfce6f9c60a9c9fd2f0fe5bcf2b.zip
virtio: Add improved queue allocation API
This leaves vring_new_virtqueue alone for compatbility, but it adds two new improved APIs: vring_create_virtqueue: Creates a virtqueue backed by automatically allocated coherent memory. (Some day it this could be extended to support non-coherent memory, too, if there ends up being a platform on which it's worthwhile.) __vring_new_virtqueue: Creates a virtqueue with a manually-specified layout. This should allow mic_virtio to work much more cleanly. Signed-off-by: Andy Lutomirski <luto@kernel.org> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'include/linux/virtio.h')
-rw-r--r--include/linux/virtio.h23
1 files changed, 21 insertions, 2 deletions
diff --git a/include/linux/virtio.h b/include/linux/virtio.h
index 8f4d4bfa6d46..d5eb5479a425 100644
--- a/include/linux/virtio.h
+++ b/include/linux/virtio.h
@@ -75,8 +75,27 @@ unsigned int virtqueue_get_vring_size(struct virtqueue *vq);
bool virtqueue_is_broken(struct virtqueue *vq);
-void *virtqueue_get_avail(struct virtqueue *vq);
-void *virtqueue_get_used(struct virtqueue *vq);
+const struct vring *virtqueue_get_vring(struct virtqueue *vq);
+dma_addr_t virtqueue_get_desc_addr(struct virtqueue *vq);
+dma_addr_t virtqueue_get_avail_addr(struct virtqueue *vq);
+dma_addr_t virtqueue_get_used_addr(struct virtqueue *vq);
+
+/*
+ * Legacy accessors -- in almost all cases, these are the wrong functions
+ * to use.
+ */
+static inline void *virtqueue_get_desc(struct virtqueue *vq)
+{
+ return virtqueue_get_vring(vq)->desc;
+}
+static inline void *virtqueue_get_avail(struct virtqueue *vq)
+{
+ return virtqueue_get_vring(vq)->avail;
+}
+static inline void *virtqueue_get_used(struct virtqueue *vq)
+{
+ return virtqueue_get_vring(vq)->used;
+}
/**
* virtio_device - representation of a device using virtio