Commit | Line | Data |
---|---|---|
4e53f78e MT |
1 | #ifndef LINUX_VIRTIO_H |
2 | #define LINUX_VIRTIO_H | |
61d0b5a4 RR |
3 | #include <linux/scatterlist.h> |
4 | #include <linux/kernel.h> | |
4e53f78e MT |
5 | |
6 | /* TODO: empty stubs for now. Broken but enough for virtio_ring.c */ | |
7 | #define list_add_tail(a, b) do {} while (0) | |
8 | #define list_del(a) do {} while (0) | |
2d7ce0e8 | 9 | #define list_for_each_entry(a, b, c) while (0) |
4e53f78e MT |
10 | /* end of stubs */ |
11 | ||
12 | struct virtio_device { | |
13 | void *dev; | |
d0254773 | 14 | u64 features; |
4e53f78e MT |
15 | }; |
16 | ||
17 | struct virtqueue { | |
18 | /* TODO: commented as list macros are empty stubs for now. | |
19 | * Broken but enough for virtio_ring.c | |
20 | * struct list_head list; */ | |
21 | void (*callback)(struct virtqueue *vq); | |
22 | const char *name; | |
23 | struct virtio_device *vdev; | |
73640c99 MT |
24 | unsigned int index; |
25 | unsigned int num_free; | |
4e53f78e MT |
26 | void *priv; |
27 | }; | |
28 | ||
4e53f78e | 29 | /* Interfaces exported by virtio_ring. */ |
13816c76 RR |
30 | int virtqueue_add_sgs(struct virtqueue *vq, |
31 | struct scatterlist *sgs[], | |
32 | unsigned int out_sgs, | |
33 | unsigned int in_sgs, | |
34 | void *data, | |
35 | gfp_t gfp); | |
36 | ||
e538ebaf RR |
37 | int virtqueue_add_outbuf(struct virtqueue *vq, |
38 | struct scatterlist sg[], unsigned int num, | |
39 | void *data, | |
40 | gfp_t gfp); | |
41 | ||
42 | int virtqueue_add_inbuf(struct virtqueue *vq, | |
43 | struct scatterlist sg[], unsigned int num, | |
44 | void *data, | |
45 | gfp_t gfp); | |
46 | ||
d1b8c4c2 | 47 | bool virtqueue_kick(struct virtqueue *vq); |
4e53f78e MT |
48 | |
49 | void *virtqueue_get_buf(struct virtqueue *vq, unsigned int *len); | |
50 | ||
51 | void virtqueue_disable_cb(struct virtqueue *vq); | |
52 | ||
53 | bool virtqueue_enable_cb(struct virtqueue *vq); | |
64d09888 | 54 | bool virtqueue_enable_cb_delayed(struct virtqueue *vq); |
4e53f78e MT |
55 | |
56 | void *virtqueue_detach_unused_buf(struct virtqueue *vq); | |
73640c99 MT |
57 | struct virtqueue *vring_new_virtqueue(unsigned int index, |
58 | unsigned int num, | |
4e53f78e MT |
59 | unsigned int vring_align, |
60 | struct virtio_device *vdev, | |
7b21e34f | 61 | bool weak_barriers, |
4e53f78e | 62 | void *pages, |
d1b8c4c2 | 63 | bool (*notify)(struct virtqueue *vq), |
4e53f78e MT |
64 | void (*callback)(struct virtqueue *vq), |
65 | const char *name); | |
66 | void vring_del_virtqueue(struct virtqueue *vq); | |
67 | ||
68 | #endif |