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