Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
[sfrench/cifs-2.6.git] / tools / virtio / linux / virtio.h
1 #ifndef LINUX_VIRTIO_H
2 #define LINUX_VIRTIO_H
3 #include <linux/scatterlist.h>
4 #include <linux/kernel.h>
5
6 struct device {
7         void *parent;
8 };
9
10 struct virtio_device {
11         struct device dev;
12         u64 features;
13 };
14
15 struct virtqueue {
16         /* TODO: commented as list macros are empty stubs for now.
17          * Broken but enough for virtio_ring.c
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