1*1f94b218SZhenzhong Duan /*
2*1f94b218SZhenzhong Duan  * Host IOMMU device abstract declaration
3*1f94b218SZhenzhong Duan  *
4*1f94b218SZhenzhong Duan  * Copyright (C) 2024 Intel Corporation.
5*1f94b218SZhenzhong Duan  *
6*1f94b218SZhenzhong Duan  * Authors: Zhenzhong Duan <zhenzhong.duan@intel.com>
7*1f94b218SZhenzhong Duan  *
8*1f94b218SZhenzhong Duan  * This work is licensed under the terms of the GNU GPL, version 2.  See
9*1f94b218SZhenzhong Duan  * the COPYING file in the top-level directory.
10*1f94b218SZhenzhong Duan  */
11*1f94b218SZhenzhong Duan 
12*1f94b218SZhenzhong Duan #ifndef HOST_IOMMU_DEVICE_H
13*1f94b218SZhenzhong Duan #define HOST_IOMMU_DEVICE_H
14*1f94b218SZhenzhong Duan 
15*1f94b218SZhenzhong Duan #include "qom/object.h"
16*1f94b218SZhenzhong Duan #include "qapi/error.h"
17*1f94b218SZhenzhong Duan 
18*1f94b218SZhenzhong Duan #define TYPE_HOST_IOMMU_DEVICE "host-iommu-device"
19*1f94b218SZhenzhong Duan OBJECT_DECLARE_TYPE(HostIOMMUDevice, HostIOMMUDeviceClass, HOST_IOMMU_DEVICE)
20*1f94b218SZhenzhong Duan 
21*1f94b218SZhenzhong Duan struct HostIOMMUDevice {
22*1f94b218SZhenzhong Duan     Object parent_obj;
23*1f94b218SZhenzhong Duan 
24*1f94b218SZhenzhong Duan     char *name;
25*1f94b218SZhenzhong Duan };
26*1f94b218SZhenzhong Duan 
27*1f94b218SZhenzhong Duan /**
28*1f94b218SZhenzhong Duan  * struct HostIOMMUDeviceClass - The base class for all host IOMMU devices.
29*1f94b218SZhenzhong Duan  *
30*1f94b218SZhenzhong Duan  * Different types of host devices (e.g., VFIO or VDPA device) or devices
31*1f94b218SZhenzhong Duan  * with different backend (e.g., VFIO legacy container or IOMMUFD backend)
32*1f94b218SZhenzhong Duan  * will have different implementations of the HostIOMMUDeviceClass.
33*1f94b218SZhenzhong Duan  */
34*1f94b218SZhenzhong Duan struct HostIOMMUDeviceClass {
35*1f94b218SZhenzhong Duan     ObjectClass parent_class;
36*1f94b218SZhenzhong Duan 
37*1f94b218SZhenzhong Duan     /**
38*1f94b218SZhenzhong Duan      * @realize: initialize host IOMMU device instance further.
39*1f94b218SZhenzhong Duan      *
40*1f94b218SZhenzhong Duan      * Mandatory callback.
41*1f94b218SZhenzhong Duan      *
42*1f94b218SZhenzhong Duan      * @hiod: pointer to a host IOMMU device instance.
43*1f94b218SZhenzhong Duan      *
44*1f94b218SZhenzhong Duan      * @opaque: pointer to agent device of this host IOMMU device,
45*1f94b218SZhenzhong Duan      *          e.g., VFIO base device or VDPA device.
46*1f94b218SZhenzhong Duan      *
47*1f94b218SZhenzhong Duan      * @errp: pass an Error out when realize fails.
48*1f94b218SZhenzhong Duan      *
49*1f94b218SZhenzhong Duan      * Returns: true on success, false on failure.
50*1f94b218SZhenzhong Duan      */
51*1f94b218SZhenzhong Duan     bool (*realize)(HostIOMMUDevice *hiod, void *opaque, Error **errp);
52*1f94b218SZhenzhong Duan };
53*1f94b218SZhenzhong Duan #endif
54