Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
vfio/spapr: Introduce spapr backend and target interface
Introduce an empty spapr backend which will hold spapr specific
content, currently only prereg_listener and hostwin_list.

Also introduce two spapr specific callbacks add/del_window into
VFIOIOMMUOps. Instantiate a spapr ops with a helper setup_spapr_ops
and assign it to bcontainer->ops.

Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Cédric Le Goater <clg@redhat.com>
  • Loading branch information
duanzhenzhong authored and legoater committed Dec 19, 2023
1 parent 1eb31f1 commit 9b7d38b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
14 changes: 14 additions & 0 deletions hw/vfio/spapr.c
Expand Up @@ -24,6 +24,10 @@
#include "qapi/error.h"
#include "trace.h"

typedef struct VFIOSpaprContainer {
VFIOContainer container;
} VFIOSpaprContainer;

static bool vfio_prereg_listener_skipped_section(MemoryRegionSection *section)
{
if (memory_region_is_iommu(section->mr)) {
Expand Down Expand Up @@ -421,6 +425,14 @@ void vfio_container_del_section_window(VFIOContainer *container,
}
}

static VFIOIOMMUOps vfio_iommu_spapr_ops;

static void setup_spapr_ops(VFIOContainerBase *bcontainer)
{
vfio_iommu_spapr_ops = *bcontainer->ops;
bcontainer->ops = &vfio_iommu_spapr_ops;
}

int vfio_spapr_container_init(VFIOContainer *container, Error **errp)
{
VFIOContainerBase *bcontainer = &container->bcontainer;
Expand Down Expand Up @@ -486,6 +498,8 @@ int vfio_spapr_container_init(VFIOContainer *container, Error **errp)
0x1000);
}

setup_spapr_ops(bcontainer);

return 0;

listener_unregister_exit:
Expand Down
6 changes: 6 additions & 0 deletions include/hw/vfio/vfio-container-base.h
Expand Up @@ -101,5 +101,11 @@ struct VFIOIOMMUOps {
int (*set_dirty_page_tracking)(VFIOContainerBase *bcontainer, bool start);
int (*query_dirty_bitmap)(VFIOContainerBase *bcontainer, VFIOBitmap *vbmap,
hwaddr iova, hwaddr size);
/* SPAPR specific */
int (*add_window)(VFIOContainerBase *bcontainer,
MemoryRegionSection *section,
Error **errp);
void (*del_window)(VFIOContainerBase *bcontainer,
MemoryRegionSection *section);
};
#endif /* HW_VFIO_VFIO_CONTAINER_BASE_H */

0 comments on commit 9b7d38b

Please sign in to comment.