xref: /linux/drivers/vfio/pci/pds/vfio_dev.h (revision 993498e537af9260e697219ce41b41b22b6199cc)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright(c) 2023 Advanced Micro Devices, Inc. */
3 
4 #ifndef _VFIO_DEV_H_
5 #define _VFIO_DEV_H_
6 
7 #include <linux/pci.h>
8 #include <linux/vfio_pci_core.h>
9 
10 #include "dirty.h"
11 #include "lm.h"
12 
13 struct pds_vfio_pci_device {
14 	struct vfio_pci_core_device vfio_coredev;
15 
16 	struct pds_vfio_lm_file *save_file;
17 	struct pds_vfio_lm_file *restore_file;
18 	struct pds_vfio_dirty dirty;
19 	struct mutex state_mutex; /* protect migration state */
20 	enum vfio_device_mig_state state;
21 	struct mutex reset_mutex; /* protect reset_done flow */
22 	u8 deferred_reset;
23 	enum vfio_device_mig_state deferred_reset_state;
24 	struct notifier_block nb;
25 
26 	int vf_id;
27 	u16 client_id;
28 };
29 
30 void pds_vfio_state_mutex_unlock(struct pds_vfio_pci_device *pds_vfio);
31 
32 const struct vfio_device_ops *pds_vfio_ops_info(void);
33 struct pds_vfio_pci_device *pds_vfio_pci_drvdata(struct pci_dev *pdev);
34 void pds_vfio_reset(struct pds_vfio_pci_device *pds_vfio);
35 
36 struct pci_dev *pds_vfio_to_pci_dev(struct pds_vfio_pci_device *pds_vfio);
37 struct device *pds_vfio_to_dev(struct pds_vfio_pci_device *pds_vfio);
38 
39 #endif /* _VFIO_DEV_H_ */
40