virtio.h 1.7 KB

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