| 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 |
|
| 10 |
#ifndef _LINUX_VIRTIO_PMEM_H |
| 11 |
#define _LINUX_VIRTIO_PMEM_H |
| 12 |
|
| 13 |
#include <linux/module.h> |
| 14 |
#include <uapi/linux/virtio_pmem.h> |
| 15 |
#include <linux/libnvdimm.h> |
| 16 |
#include <linux/mutex.h> |
| 17 |
#include <linux/spinlock.h> |
| 18 |
|
| 19 |
struct virtio_pmem_request { |
| 20 |
struct virtio_pmem_req req; |
| 21 |
struct virtio_pmem_resp resp; |
| 22 |
|
| 23 |
/* Wait queue to process deferred work after ack from host */ |
| 24 |
wait_queue_head_t host_acked; |
| 25 |
bool done; |
| 26 |
|
| 27 |
/* Wait queue to process deferred work after virt queue buffer avail */ |
| 28 |
wait_queue_head_t wq_buf; |
| 29 |
bool wq_buf_avail; |
| 30 |
struct list_head list; |
| 31 |
}; |
| 32 |
|
| 33 |
struct virtio_pmem { |
| 34 |
struct virtio_device *vdev; |
| 35 |
|
| 36 |
/* Virtio pmem request queue */ |
| 37 |
struct virtqueue *req_vq; |
| 38 |
|
| 39 |
/* Serialize flush requests to the device. */ |
| 40 |
struct mutex flush_lock; |
| 41 |
|
| 42 |
/* nvdimm bus registers virtio pmem device */ |
| 43 |
struct nvdimm_bus *nvdimm_bus; |
| 44 |
struct nvdimm_bus_descriptor nd_desc; |
| 45 |
|
| 46 |
/* List to store deferred work if virtqueue is full */ |
| 47 |
struct list_head req_list; |
| 48 |
|
| 49 |
/* Synchronize virtqueue data */ |
| 50 |
spinlock_t pmem_lock; |
| 51 |
|
| 52 |
/* Memory region information */ |
| 53 |
__u64 start; |
| 54 |
__u64 size; |
| 55 |
}; |
| 56 |
|
| 57 |
void virtio_pmem_host_ack(struct virtqueue *vq); |
| 58 |
int async_pmem_flush(struct nd_region *nd_region, struct bio *bio); |
| 59 |
#endif |