From: "Cédric Le Goater" <clg@redhat.com>
To: "Duan, Zhenzhong" <zhenzhong.duan@intel.com>,
"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Cc: Eric Auger <eric.auger@redhat.com>,
Alex Williamson <alex.williamson@redhat.com>,
Nicholas Piggin <npiggin@gmail.com>,
Harsh Prateek Bora <harshpb@linux.ibm.com>
Subject: Re: [PATCH for-9.0 04/10] vfio/container: Introduce a VFIOIOMMU QOM interface
Date: Mon, 11 Dec 2023 14:58:55 +0100 [thread overview]
Message-ID: <f0dfddd3-b080-4f59-b92d-8e06c6f3f9cb@redhat.com> (raw)
In-Reply-To: <SJ0PR11MB67447A62DBC85853B6AB4652928FA@SJ0PR11MB6744.namprd11.prod.outlook.com>
On 12/11/23 07:08, Duan, Zhenzhong wrote:
>
>
>> -----Original Message-----
>> From: Cédric Le Goater <clg@redhat.com>
>> Sent: Friday, December 8, 2023 4:46 PM
>> Subject: [PATCH for-9.0 04/10] vfio/container: Introduce a VFIOIOMMU
>> QOM interface
>>
>> Simply transform the VFIOIOMMUOps struct in an InterfaceClass and do
>> some initial name replacements. Next changes will start converting
>> VFIOIOMMUOps.
>>
>> Signed-off-by: Cédric Le Goater <clg@redhat.com>
>> ---
>> include/hw/vfio/vfio-container-base.h | 18 ++++++++++++++----
>> hw/vfio/common.c | 2 +-
>> hw/vfio/container-base.c | 12 +++++++++++-
>> hw/vfio/pci.c | 2 +-
>> 4 files changed, 27 insertions(+), 7 deletions(-)
>>
>> diff --git a/include/hw/vfio/vfio-container-base.h b/include/hw/vfio/vfio-
>> container-base.h
>> index
>> 5c9594b6c77681e5593236e711e7e391e5f2bdff..81d49fe562d3840859096
>> dd8a62ac38d62314939 100644
>> --- a/include/hw/vfio/vfio-container-base.h
>> +++ b/include/hw/vfio/vfio-container-base.h
>> @@ -16,7 +16,8 @@
>> #include "exec/memory.h"
>>
>> typedef struct VFIODevice VFIODevice;
>> -typedef struct VFIOIOMMUOps VFIOIOMMUOps;
>> +typedef struct VFIOIOMMUClass VFIOIOMMUClass;
>> +#define VFIOIOMMUOps VFIOIOMMUClass /* To remove */
>>
>> typedef struct {
>> unsigned long *bitmap;
>> @@ -34,7 +35,7 @@ typedef struct VFIOAddressSpace {
>> * This is the base object for vfio container backends
>> */
>> typedef struct VFIOContainerBase {
>> - const VFIOIOMMUOps *ops;
>> + const VFIOIOMMUClass *ops;
>> VFIOAddressSpace *space;
>> MemoryListener listener;
>> Error *error;
>> @@ -88,10 +89,19 @@ int vfio_container_query_dirty_bitmap(const
>> VFIOContainerBase *bcontainer,
>>
>> void vfio_container_init(VFIOContainerBase *bcontainer,
>> VFIOAddressSpace *space,
>> - const VFIOIOMMUOps *ops);
>> + const VFIOIOMMUClass *ops);
>> void vfio_container_destroy(VFIOContainerBase *bcontainer);
>>
>> -struct VFIOIOMMUOps {
>> +typedef struct VFIOIOMMU VFIOIOMMU;
>> +
>> +#define TYPE_VFIO_IOMMU "vfio-iommu"
>> +
>> +#define VFIO_IOMMU(obj) INTERFACE_CHECK(VFIOIOMMU, (obj),
>> TYPE_VFIO_IOMMU)
>
> Maybe this #define can be removed or you have other plans?
yes, and we can remove 'struct VFIOIOMMU' also.
Thanks,
C.
> Otherwise, Reviewed-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
>
> Thanks
> Zhenzhong
>
>> +DECLARE_CLASS_CHECKERS(VFIOIOMMUClass, VFIO_IOMMU,
>> TYPE_VFIO_IOMMU)
>> +
>> +struct VFIOIOMMUClass {
>> + InterfaceClass parent_class;
>> +
>> /* basic feature */
>> int (*dma_map)(const VFIOContainerBase *bcontainer,
>> hwaddr iova, ram_addr_t size,
>> diff --git a/hw/vfio/common.c b/hw/vfio/common.c
>> index
>> 08a3e576725b1fc9f2f7e425375df3b827c4fe56..49dab41566f07ba7be1100f
>> ed1973e028d34467c 100644
>> --- a/hw/vfio/common.c
>> +++ b/hw/vfio/common.c
>> @@ -1503,7 +1503,7 @@ retry:
>> int vfio_attach_device(char *name, VFIODevice *vbasedev,
>> AddressSpace *as, Error **errp)
>> {
>> - const VFIOIOMMUOps *ops = &vfio_legacy_ops;
>> + const VFIOIOMMUClass *ops = &vfio_legacy_ops;
>>
>> #ifdef CONFIG_IOMMUFD
>> if (vbasedev->iommufd) {
>> diff --git a/hw/vfio/container-base.c b/hw/vfio/container-base.c
>> index
>> 1ffd25bbfa8bd3d404e43b96357273b95f5a0031..913ae49077c4f09b7b275
>> 17c1231cfbe4befb7fb 100644
>> --- a/hw/vfio/container-base.c
>> +++ b/hw/vfio/container-base.c
>> @@ -72,7 +72,7 @@ int vfio_container_query_dirty_bitmap(const
>> VFIOContainerBase *bcontainer,
>> }
>>
>> void vfio_container_init(VFIOContainerBase *bcontainer, VFIOAddressSpace
>> *space,
>> - const VFIOIOMMUOps *ops)
>> + const VFIOIOMMUClass *ops)
>> {
>> bcontainer->ops = ops;
>> bcontainer->space = space;
>> @@ -99,3 +99,13 @@ void vfio_container_destroy(VFIOContainerBase
>> *bcontainer)
>>
>> g_list_free_full(bcontainer->iova_ranges, g_free);
>> }
>> +
>> +static const TypeInfo types[] = {
>> + {
>> + .name = TYPE_VFIO_IOMMU,
>> + .parent = TYPE_INTERFACE,
>> + .class_size = sizeof(VFIOIOMMUClass),
>> + },
>> +};
>> +
>> +DEFINE_TYPES(types)
>> diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
>> index
>> 1874ec1aba987cac6cb83f86650e7a5e1968c327..d84a9e73a65de4e4c1cdaf
>> 65619a700bd8d6b802 100644
>> --- a/hw/vfio/pci.c
>> +++ b/hw/vfio/pci.c
>> @@ -2488,7 +2488,7 @@ int
>> vfio_pci_get_pci_hot_reset_info(VFIOPCIDevice *vdev,
>> static int vfio_pci_hot_reset(VFIOPCIDevice *vdev, bool single)
>> {
>> VFIODevice *vbasedev = &vdev->vbasedev;
>> - const VFIOIOMMUOps *ops = vbasedev->bcontainer->ops;
>> + const VFIOIOMMUClass *ops = vbasedev->bcontainer->ops;
>>
>> return ops->pci_hot_reset(vbasedev, single);
>> }
>> --
>> 2.43.0
>
next prev parent reply other threads:[~2023-12-11 13:59 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-08 8:45 [PATCH for-9.0 00/10] vfio: Introduce a VFIOIOMMUClass Cédric Le Goater
2023-12-08 8:45 ` [PATCH for-9.0 01/10] vfio/spapr: Extend VFIOIOMMUOps with a release handler Cédric Le Goater
2023-12-11 5:51 ` Duan, Zhenzhong
2023-12-08 8:45 ` [PATCH for-9.0 02/10] vfio/container: Introduce vfio_legacy_setup() for further cleanups Cédric Le Goater
2023-12-11 5:53 ` Duan, Zhenzhong
2023-12-08 8:45 ` [PATCH for-9.0 03/10] vfio/container: Initialize VFIOIOMMUOps under vfio_init_container() Cédric Le Goater
2023-12-11 5:59 ` Duan, Zhenzhong
2023-12-11 13:57 ` Cédric Le Goater
2023-12-12 4:15 ` Duan, Zhenzhong
2023-12-08 8:45 ` [PATCH for-9.0 04/10] vfio/container: Introduce a VFIOIOMMU QOM interface Cédric Le Goater
2023-12-11 6:08 ` Duan, Zhenzhong
2023-12-11 13:58 ` Cédric Le Goater [this message]
2023-12-08 8:45 ` [PATCH for-9.0 05/10] vfio/container: Introduce a VFIOIOMMU legacy " Cédric Le Goater
2023-12-11 6:14 ` Duan, Zhenzhong
2023-12-11 14:00 ` Cédric Le Goater
2023-12-08 8:45 ` [PATCH for-9.0 06/10] vfio/container: Intoduce a new VFIOIOMMUClass::setup handler Cédric Le Goater
2023-12-11 6:17 ` Duan, Zhenzhong
2023-12-08 8:45 ` [PATCH for-9.0 07/10] vfio/spapr: Introduce a sPAPR VFIOIOMMU QOM interface Cédric Le Goater
2023-12-11 6:25 ` Duan, Zhenzhong
2023-12-11 14:01 ` Cédric Le Goater
2023-12-08 8:45 ` [PATCH for-9.0 08/10] vfio/iommufd: Introduce a VFIOIOMMU iommufd " Cédric Le Goater
2023-12-11 6:32 ` Duan, Zhenzhong
2023-12-08 8:45 ` [PATCH for-9.0 09/10] vfio/spapr: Only compile sPAPR IOMMU support when needed Cédric Le Goater
2023-12-11 6:34 ` Duan, Zhenzhong
2023-12-08 8:46 ` [PATCH for-9.0 10/10] vfio/iommufd: Remove CONFIG_IOMMUFD usage Cédric Le Goater
2023-12-11 6:44 ` Duan, Zhenzhong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f0dfddd3-b080-4f59-b92d-8e06c6f3f9cb@redhat.com \
--to=clg@redhat.com \
--cc=alex.williamson@redhat.com \
--cc=eric.auger@redhat.com \
--cc=harshpb@linux.ibm.com \
--cc=npiggin@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=zhenzhong.duan@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).