xref: /openbmc/qemu/include/hw/vfio/vfio-cpr.h (revision 924c3ccb310e615bd350d4c77b269b19d95bf5e4)
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 
19 typedef int (*dma_map_fn)(const struct VFIOContainerBase *bcontainer,
20                           hwaddr iova, ram_addr_t size, void *vaddr,
21                           bool readonly, MemoryRegion *mr);
22 
23 typedef struct VFIOContainerCPR {
24     Error *blocker;
25     bool vaddr_unmapped;
26     NotifierWithReturn transfer_notifier;
27     MemoryListener remap_listener;
28 } VFIOContainerCPR;
29 
30 typedef struct VFIODeviceCPR {
31     Error *mdev_blocker;
32 } VFIODeviceCPR;
33 
34 bool vfio_legacy_cpr_register_container(struct VFIOContainer *container,
35                                         Error **errp);
36 void vfio_legacy_cpr_unregister_container(struct VFIOContainer *container);
37 
38 int vfio_cpr_reboot_notifier(NotifierWithReturn *notifier, MigrationEvent *e,
39                              Error **errp);
40 
41 bool vfio_cpr_register_container(struct VFIOContainerBase *bcontainer,
42                                  Error **errp);
43 void vfio_cpr_unregister_container(struct VFIOContainerBase *bcontainer);
44 
45 int vfio_cpr_group_get_device_fd(int d, const char *name);
46 
47 bool vfio_cpr_container_match(struct VFIOContainer *container,
48                               struct VFIOGroup *group, int fd);
49 
50 void vfio_cpr_giommu_remap(struct VFIOContainerBase *bcontainer,
51                            MemoryRegionSection *section);
52 
53 bool vfio_cpr_ram_discard_register_listener(
54     struct VFIOContainerBase *bcontainer, MemoryRegionSection *section);
55 
56 extern const VMStateDescription vfio_cpr_pci_vmstate;
57 
58 #endif /* HW_VFIO_VFIO_CPR_H */
59