virtio.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #ifndef LINUX_VIRTIO_H
  2. #define LINUX_VIRTIO_H
  3. #include <linux/scatterlist.h>
  4. #include <linux/kernel.h>
  5. struct device {
  6. void *parent;
  7. };
  8. struct virtio_device {
  9. struct device dev;
  10. u64 features;
  11. };
  12. struct virtqueue {
  13. /* TODO: commented as list macros are empty stubs for now.
  14. * Broken but enough for virtio_ring.c
  15. * struct list_head list; */
  16. void (*callback)(struct virtqueue *vq);
  17. const char *name;
  18. struct virtio_device *vdev;
  19. unsigned int index;
  20. unsigned int num_free;
  21. void *priv;
  22. };
  23. /* Interfaces exported by virtio_ring. */
  24. int virtqueue_add_sgs(struct virtqueue *vq,
  25. struct scatterlist *sgs[],
  26. unsigned int out_sgs,
  27. unsigned int in_sgs,
  28. void *data,
  29. gfp_t gfp);
  30. int virtqueue_add_outbuf(struct virtqueue *vq,
  31. struct scatterlist sg[], unsigned int num,
  32. void *data,
  33. gfp_t gfp);
  34. int virtqueue_add_inbuf(struct virtqueue *vq,
  35. struct scatterlist sg[], unsigned int num,
  36. void *data,
  37. gfp_t gfp);
  38. bool virtqueue_kick(struct virtqueue *vq);
  39. void *virtqueue_get_buf(struct virtqueue *vq, unsigned int *len);
  40. void virtqueue_disable_cb(struct virtqueue *vq);
  41. bool virtqueue_enable_cb(struct virtqueue *vq);
  42. bool virtqueue_enable_cb_delayed(struct virtqueue *vq);
  43. void *virtqueue_detach_unused_buf(struct virtqueue *vq);
  44. struct virtqueue *vring_new_virtqueue(unsigned int index,
  45. unsigned int num,
  46. unsigned int vring_align,
  47. struct virtio_device *vdev,
  48. bool weak_barriers,
  49. void *pages,
  50. bool (*notify)(struct virtqueue *vq),
  51. void (*callback)(struct virtqueue *vq),
  52. const char *name);
  53. void vring_del_virtqueue(struct virtqueue *vq);
  54. #endif