xref: /linux/drivers/vfio/pci/pds/lm.h (revision 409c38d4f156740bf3165fd6ceae4fa6425eebf4)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright(c) 2023 Advanced Micro Devices, Inc. */
3 
4 #ifndef _LM_H_
5 #define _LM_H_
6 
7 #include <linux/fs.h>
8 #include <linux/mutex.h>
9 #include <linux/scatterlist.h>
10 #include <linux/types.h>
11 
12 #include <linux/pds/pds_common.h>
13 #include <linux/pds/pds_adminq.h>
14 
15 struct pds_vfio_lm_file {
16 	struct file *filep;
17 	struct mutex lock;	/* protect live migration data file */
18 	u64 size;		/* Size with valid data */
19 	u64 alloc_size;		/* Total allocated size. Always >= len */
20 	void *page_mem;		/* memory allocated for pages */
21 	struct page **pages;	/* Backing pages for file */
22 	unsigned long long npages;
23 	struct sg_table sg_table;	/* SG table for backing pages */
24 	struct pds_lm_sg_elem *sgl;	/* DMA mapping */
25 	dma_addr_t sgl_addr;
26 	u16 num_sge;
27 	struct scatterlist *last_offset_sg;	/* Iterator */
28 	unsigned int sg_last_entry;
29 	unsigned long last_offset;
30 };
31 
32 struct pds_vfio_pci_device;
33 
34 struct file *
35 pds_vfio_step_device_state_locked(struct pds_vfio_pci_device *pds_vfio,
36 				  enum vfio_device_mig_state next);
37 
38 void pds_vfio_put_save_file(struct pds_vfio_pci_device *pds_vfio);
39 void pds_vfio_put_restore_file(struct pds_vfio_pci_device *pds_vfio);
40 
41 #endif /* _LM_H_ */
42