1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef LINUX_VIRTIO_H 3 #define LINUX_VIRTIO_H 4 #include <linux/scatterlist.h> 5 #include <linux/kernel.h> 6 7 struct device { 8 void *parent; 9 }; 10 11 struct virtio_device { 12 struct device dev; 13 u64 features; 14 struct list_head vqs; 15 }; 16 17 struct virtqueue { 18 struct list_head list; 19 void (*callback)(struct virtqueue *vq); 20 const char *name; 21 struct virtio_device *vdev; 22 unsigned int index; 23 unsigned int num_free; 24 void *priv; 25 }; 26 27 /* Interfaces exported by virtio_ring. */ 28 int virtqueue_add_sgs(struct virtqueue *vq, 29 struct scatterlist *sgs[], 30 unsigned int out_sgs, 31 unsigned int in_sgs, 32 void *data, 33 gfp_t gfp); 34 35 int virtqueue_add_outbuf(struct virtqueue *vq, 36 struct scatterlist sg[], unsigned int num, 37 void *data, 38 gfp_t gfp); 39 40 int virtqueue_add_inbuf(struct virtqueue *vq, 41 struct scatterlist sg[], unsigned int num, 42 void *data, 43 gfp_t gfp); 44 45 bool virtqueue_kick(struct virtqueue *vq); 46 47 void *virtqueue_get_buf(struct virtqueue *vq, unsigned int *len); 48 49 void virtqueue_disable_cb(struct virtqueue *vq); 50 51 bool virtqueue_enable_cb(struct virtqueue *vq); 52 bool virtqueue_enable_cb_delayed(struct virtqueue *vq); 53 54 void *virtqueue_detach_unused_buf(struct virtqueue *vq); 55 struct virtqueue *vring_new_virtqueue(unsigned int index, 56 unsigned int num, 57 unsigned int vring_align, 58 struct virtio_device *vdev, 59 bool weak_barriers, 60 bool ctx, 61 void *pages, 62 bool (*notify)(struct virtqueue *vq), 63 void (*callback)(struct virtqueue *vq), 64 const char *name); 65 void vring_del_virtqueue(struct virtqueue *vq); 66 67 #endif 68