xref: /linux/drivers/vfio/pci/pds/lm.h (revision c02ce1735b150cf7c3b43790b48e23dcd17c0d46)
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 	bool disabled;
31 };
32 
33 struct pds_vfio_pci_device;
34 
35 struct file *
36 pds_vfio_step_device_state_locked(struct pds_vfio_pci_device *pds_vfio,
37 				  enum vfio_device_mig_state next);
38 
39 void pds_vfio_put_save_file(struct pds_vfio_pci_device *pds_vfio);
40 void pds_vfio_put_restore_file(struct pds_vfio_pci_device *pds_vfio);
41 
42 #endif /* _LM_H_ */
43