diff mbox series

[v4,21/41] vfio/spapr: Introduce spapr backend and target interface

Message ID 20231102071302.1818071-22-zhenzhong.duan@intel.com
State Handled Elsewhere
Headers show
Series [v4,01/41] vfio/container: Move IBM EEH related functions into spapr_pci_vfio.c | expand

Commit Message

Duan, Zhenzhong Nov. 2, 2023, 7:12 a.m. UTC
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>
---
v4: remove VFIOIOMMUSpaprOps

 include/hw/vfio/vfio-container-base.h |  6 ++++++
 hw/vfio/spapr.c                       | 14 ++++++++++++++
 2 files changed, 20 insertions(+)

Comments

Cédric Le Goater Nov. 6, 2023, 5:30 p.m. UTC | #1
On 11/2/23 08:12, Zhenzhong Duan wrote:
> 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>

Thanks,

C.


> ---
> v4: remove VFIOIOMMUSpaprOps
> 
>   include/hw/vfio/vfio-container-base.h |  6 ++++++
>   hw/vfio/spapr.c                       | 14 ++++++++++++++
>   2 files changed, 20 insertions(+)
> 
> diff --git a/include/hw/vfio/vfio-container-base.h b/include/hw/vfio/vfio-container-base.h
> index 9658ffb526..f62a14ac73 100644
> --- a/include/hw/vfio/vfio-container-base.h
> +++ b/include/hw/vfio/vfio-container-base.h
> @@ -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 */
> diff --git a/hw/vfio/spapr.c b/hw/vfio/spapr.c
> index 7a50975f25..e1a6b35563 100644
> --- a/hw/vfio/spapr.c
> +++ b/hw/vfio/spapr.c
> @@ -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)) {
> @@ -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;
> @@ -486,6 +498,8 @@ int vfio_spapr_container_init(VFIOContainer *container, Error **errp)
>                             0x1000);
>       }
>   
> +    setup_spapr_ops(bcontainer);
> +
>       return 0;
>   
>   listener_unregister_exit:
diff mbox series

Patch

diff --git a/include/hw/vfio/vfio-container-base.h b/include/hw/vfio/vfio-container-base.h
index 9658ffb526..f62a14ac73 100644
--- a/include/hw/vfio/vfio-container-base.h
+++ b/include/hw/vfio/vfio-container-base.h
@@ -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 */
diff --git a/hw/vfio/spapr.c b/hw/vfio/spapr.c
index 7a50975f25..e1a6b35563 100644
--- a/hw/vfio/spapr.c
+++ b/hw/vfio/spapr.c
@@ -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)) {
@@ -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;
@@ -486,6 +498,8 @@  int vfio_spapr_container_init(VFIOContainer *container, Error **errp)
                           0x1000);
     }
 
+    setup_spapr_ops(bcontainer);
+
     return 0;
 
 listener_unregister_exit: