virtio_pmem.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * virtio_pmem.h: virtio pmem Driver
  4. *
  5. * Discovers persistent memory range information
  6. * from host and provides a virtio based flushing
  7. * interface.
  8. **/
  9. #ifndef _LINUX_VIRTIO_PMEM_H
  10. #define _LINUX_VIRTIO_PMEM_H
  11. #include <linux/module.h>
  12. #include <uapi/linux/virtio_pmem.h>
  13. #include <linux/libnvdimm.h>
  14. #include <linux/spinlock.h>
  15. struct virtio_pmem_request {
  16. struct virtio_pmem_req req;
  17. struct virtio_pmem_resp resp;
  18. /* Wait queue to process deferred work after ack from host */
  19. wait_queue_head_t host_acked;
  20. bool done;
  21. /* Wait queue to process deferred work after virt queue buffer avail */
  22. wait_queue_head_t wq_buf;
  23. bool wq_buf_avail;
  24. struct list_head list;
  25. };
  26. struct virtio_pmem {
  27. struct virtio_device *vdev;
  28. /* Virtio pmem request queue */
  29. struct virtqueue *req_vq;
  30. /* nvdimm bus registers virtio pmem device */
  31. struct nvdimm_bus *nvdimm_bus;
  32. struct nvdimm_bus_descriptor nd_desc;
  33. /* List to store deferred work if virtqueue is full */
  34. struct list_head req_list;
  35. /* Synchronize virtqueue data */
  36. spinlock_t pmem_lock;
  37. /* Memory region information */
  38. __u64 start;
  39. __u64 size;
  40. };
  41. void virtio_pmem_host_ack(struct virtqueue *vq);
  42. int async_pmem_flush(struct nd_region *nd_region, struct bio *bio);
  43. #endif