1 /* 2 * VFIO CPR 3 * 4 * Copyright (c) 2025 Oracle and/or its affiliates. 5 * 6 * SPDX-License-Identifier: GPL-2.0-or-later 7 */ 8 9 #ifndef HW_VFIO_VFIO_CPR_H 10 #define HW_VFIO_VFIO_CPR_H 11 12 #include "migration/misc.h" 13 #include "system/memory.h" 14 15 struct VFIOContainer; 16 struct VFIOContainerBase; 17 struct VFIOGroup; 18 struct VFIOPCIDevice; 19 20 typedef int (*dma_map_fn)(const struct VFIOContainerBase *bcontainer, 21 hwaddr iova, ram_addr_t size, void *vaddr, 22 bool readonly, MemoryRegion *mr); 23 24 typedef struct VFIOContainerCPR { 25 Error *blocker; 26 bool vaddr_unmapped; 27 NotifierWithReturn transfer_notifier; 28 MemoryListener remap_listener; 29 } VFIOContainerCPR; 30 31 typedef struct VFIODeviceCPR { 32 Error *mdev_blocker; 33 } VFIODeviceCPR; 34 35 bool vfio_legacy_cpr_register_container(struct VFIOContainer *container, 36 Error **errp); 37 void vfio_legacy_cpr_unregister_container(struct VFIOContainer *container); 38 39 int vfio_cpr_reboot_notifier(NotifierWithReturn *notifier, MigrationEvent *e, 40 Error **errp); 41 42 bool vfio_cpr_register_container(struct VFIOContainerBase *bcontainer, 43 Error **errp); 44 void vfio_cpr_unregister_container(struct VFIOContainerBase *bcontainer); 45 46 int vfio_cpr_group_get_device_fd(int d, const char *name); 47 48 bool vfio_cpr_container_match(struct VFIOContainer *container, 49 struct VFIOGroup *group, int fd); 50 51 void vfio_cpr_giommu_remap(struct VFIOContainerBase *bcontainer, 52 MemoryRegionSection *section); 53 54 bool vfio_cpr_ram_discard_register_listener( 55 struct VFIOContainerBase *bcontainer, MemoryRegionSection *section); 56 57 void vfio_cpr_save_vector_fd(struct VFIOPCIDevice *vdev, const char *name, 58 int nr, int fd); 59 int vfio_cpr_load_vector_fd(struct VFIOPCIDevice *vdev, const char *name, 60 int nr); 61 void vfio_cpr_delete_vector_fd(struct VFIOPCIDevice *vdev, const char *name, 62 int nr); 63 64 extern const VMStateDescription vfio_cpr_pci_vmstate; 65 66 #endif /* HW_VFIO_VFIO_CPR_H */ 67