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