diff mbox series

[v3,04/19] vfio/iommufd: Introduce HostIOMMUDeviceIOMMUFDVFIO device

Message ID 20240429065046.3688701-5-zhenzhong.duan@intel.com
State New
Headers show
Series Add a host IOMMU device abstraction to check with vIOMMU | expand

Commit Message

Duan, Zhenzhong April 29, 2024, 6:50 a.m. UTC
HostIOMMUDeviceIOMMUFDVFIO represents a host IOMMU device under VFIO
iommufd backend. It will be created during VFIO device attaching and
passed to vIOMMU.

It includes a link to VFIODevice so that we can do VFIO device
specific operations, i.e., [at/de]taching hwpt, etc.

Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
---
 include/hw/vfio/vfio-common.h | 13 +++++++++++++
 hw/vfio/iommufd.c             |  6 +++++-
 2 files changed, 18 insertions(+), 1 deletion(-)

Comments

Cédric Le Goater April 30, 2024, 7:52 a.m. UTC | #1
On 4/29/24 08:50, Zhenzhong Duan wrote:
> HostIOMMUDeviceIOMMUFDVFIO represents a host IOMMU device under VFIO
> iommufd backend. It will be created during VFIO device attaching and
> passed to vIOMMU.
> 
> It includes a link to VFIODevice so that we can do VFIO device
> specific operations, i.e., [at/de]taching hwpt, etc.
> 
> Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
> ---
>   include/hw/vfio/vfio-common.h | 13 +++++++++++++
>   hw/vfio/iommufd.c             |  6 +++++-
>   2 files changed, 18 insertions(+), 1 deletion(-)
> 
> diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h
> index aa3abe0a18..0943add3bc 100644
> --- a/include/hw/vfio/vfio-common.h
> +++ b/include/hw/vfio/vfio-common.h
> @@ -32,6 +32,7 @@
>   #include "sysemu/sysemu.h"
>   #include "hw/vfio/vfio-container-base.h"
>   #include "sysemu/host_iommu_device.h"
> +#include "sysemu/iommufd.h"
>   
>   #define VFIO_MSG_PREFIX "vfio %s: "
>   
> @@ -159,6 +160,18 @@ struct HostIOMMUDeviceLegacyVFIO {
>       VFIODevice *vdev;
>   };
>   
> +#define TYPE_HOST_IOMMU_DEVICE_IOMMUFD_VFIO \
> +            TYPE_HOST_IOMMU_DEVICE_IOMMUFD "-vfio"
> +OBJECT_DECLARE_SIMPLE_TYPE(HostIOMMUDeviceIOMMUFDVFIO,
> +                           HOST_IOMMU_DEVICE_IOMMUFD_VFIO)
> +
> +/* Abstraction of host IOMMU device with VFIO IOMMUFD backend */
> +struct HostIOMMUDeviceIOMMUFDVFIO {
> +    HostIOMMUDeviceIOMMUFD parent;
> +
> +    VFIODevice *vdev;

Seems useless today.

Thanks,

C.



> +};
> +
>   typedef struct VFIODMABuf {
>       QemuDmaBuf buf;
>       uint32_t pos_x, pos_y, pos_updates;
> diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c
> index 8827ffe636..997f4ac43e 100644
> --- a/hw/vfio/iommufd.c
> +++ b/hw/vfio/iommufd.c
> @@ -639,7 +639,11 @@ static const TypeInfo types[] = {
>           .name = TYPE_VFIO_IOMMU_IOMMUFD,
>           .parent = TYPE_VFIO_IOMMU,
>           .class_init = vfio_iommu_iommufd_class_init,
> -    },
> +    }, {
> +        .name = TYPE_HOST_IOMMU_DEVICE_IOMMUFD_VFIO,
> +        .parent = TYPE_HOST_IOMMU_DEVICE_IOMMUFD,
> +        .instance_size = sizeof(HostIOMMUDeviceIOMMUFDVFIO),
> +    }
>   };
>   
>   DEFINE_TYPES(types)
Duan, Zhenzhong April 30, 2024, 9:25 a.m. UTC | #2
>-----Original Message-----
>From: Cédric Le Goater <clg@redhat.com>
>Subject: Re: [PATCH v3 04/19] vfio/iommufd: Introduce
>HostIOMMUDeviceIOMMUFDVFIO device
>
>On 4/29/24 08:50, Zhenzhong Duan wrote:
>> HostIOMMUDeviceIOMMUFDVFIO represents a host IOMMU device under
>VFIO
>> iommufd backend. It will be created during VFIO device attaching and
>> passed to vIOMMU.
>>
>> It includes a link to VFIODevice so that we can do VFIO device
>> specific operations, i.e., [at/de]taching hwpt, etc.
>>
>> Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
>> ---
>>   include/hw/vfio/vfio-common.h | 13 +++++++++++++
>>   hw/vfio/iommufd.c             |  6 +++++-
>>   2 files changed, 18 insertions(+), 1 deletion(-)
>>
>> diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-
>common.h
>> index aa3abe0a18..0943add3bc 100644
>> --- a/include/hw/vfio/vfio-common.h
>> +++ b/include/hw/vfio/vfio-common.h
>> @@ -32,6 +32,7 @@
>>   #include "sysemu/sysemu.h"
>>   #include "hw/vfio/vfio-container-base.h"
>>   #include "sysemu/host_iommu_device.h"
>> +#include "sysemu/iommufd.h"
>>
>>   #define VFIO_MSG_PREFIX "vfio %s: "
>>
>> @@ -159,6 +160,18 @@ struct HostIOMMUDeviceLegacyVFIO {
>>       VFIODevice *vdev;
>>   };
>>
>> +#define TYPE_HOST_IOMMU_DEVICE_IOMMUFD_VFIO \
>> +            TYPE_HOST_IOMMU_DEVICE_IOMMUFD "-vfio"
>> +OBJECT_DECLARE_SIMPLE_TYPE(HostIOMMUDeviceIOMMUFDVFIO,
>> +                           HOST_IOMMU_DEVICE_IOMMUFD_VFIO)
>> +
>> +/* Abstraction of host IOMMU device with VFIO IOMMUFD backend */
>> +struct HostIOMMUDeviceIOMMUFDVFIO {
>> +    HostIOMMUDeviceIOMMUFD parent;
>> +
>> +    VFIODevice *vdev;
>
>Seems useless today.

Yes, useless before nesting series, will add in nesting series.

Thanks
Zhenzhong

>
>Thanks,
>
>C.
>
>
>
>> +};
>> +
>>   typedef struct VFIODMABuf {
>>       QemuDmaBuf buf;
>>       uint32_t pos_x, pos_y, pos_updates;
>> diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c
>> index 8827ffe636..997f4ac43e 100644
>> --- a/hw/vfio/iommufd.c
>> +++ b/hw/vfio/iommufd.c
>> @@ -639,7 +639,11 @@ static const TypeInfo types[] = {
>>           .name = TYPE_VFIO_IOMMU_IOMMUFD,
>>           .parent = TYPE_VFIO_IOMMU,
>>           .class_init = vfio_iommu_iommufd_class_init,
>> -    },
>> +    }, {
>> +        .name = TYPE_HOST_IOMMU_DEVICE_IOMMUFD_VFIO,
>> +        .parent = TYPE_HOST_IOMMU_DEVICE_IOMMUFD,
>> +        .instance_size = sizeof(HostIOMMUDeviceIOMMUFDVFIO),
>> +    }
>>   };
>>
>>   DEFINE_TYPES(types)
diff mbox series

Patch

diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h
index aa3abe0a18..0943add3bc 100644
--- a/include/hw/vfio/vfio-common.h
+++ b/include/hw/vfio/vfio-common.h
@@ -32,6 +32,7 @@ 
 #include "sysemu/sysemu.h"
 #include "hw/vfio/vfio-container-base.h"
 #include "sysemu/host_iommu_device.h"
+#include "sysemu/iommufd.h"
 
 #define VFIO_MSG_PREFIX "vfio %s: "
 
@@ -159,6 +160,18 @@  struct HostIOMMUDeviceLegacyVFIO {
     VFIODevice *vdev;
 };
 
+#define TYPE_HOST_IOMMU_DEVICE_IOMMUFD_VFIO \
+            TYPE_HOST_IOMMU_DEVICE_IOMMUFD "-vfio"
+OBJECT_DECLARE_SIMPLE_TYPE(HostIOMMUDeviceIOMMUFDVFIO,
+                           HOST_IOMMU_DEVICE_IOMMUFD_VFIO)
+
+/* Abstraction of host IOMMU device with VFIO IOMMUFD backend */
+struct HostIOMMUDeviceIOMMUFDVFIO {
+    HostIOMMUDeviceIOMMUFD parent;
+
+    VFIODevice *vdev;
+};
+
 typedef struct VFIODMABuf {
     QemuDmaBuf buf;
     uint32_t pos_x, pos_y, pos_updates;
diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c
index 8827ffe636..997f4ac43e 100644
--- a/hw/vfio/iommufd.c
+++ b/hw/vfio/iommufd.c
@@ -639,7 +639,11 @@  static const TypeInfo types[] = {
         .name = TYPE_VFIO_IOMMU_IOMMUFD,
         .parent = TYPE_VFIO_IOMMU,
         .class_init = vfio_iommu_iommufd_class_init,
-    },
+    }, {
+        .name = TYPE_HOST_IOMMU_DEVICE_IOMMUFD_VFIO,
+        .parent = TYPE_HOST_IOMMU_DEVICE_IOMMUFD,
+        .instance_size = sizeof(HostIOMMUDeviceIOMMUFDVFIO),
+    }
 };
 
 DEFINE_TYPES(types)