62 lines
1.8 KiB
Diff
62 lines
1.8 KiB
Diff
|
|
From 2f1a2f4b320e70a85cef8392cd5f4b1e54afb9c9 Mon Sep 17 00:00:00 2001
|
||
|
|
From: Zhenzhong Duan <zhenzhong.duan@intel.com>
|
||
|
|
Date: Wed, 5 Jun 2024 16:30:36 +0800
|
||
|
|
Subject: [PATCH] backends/iommufd: Implement HostIOMMUDeviceClass::get_cap()
|
||
|
|
handler
|
||
|
|
MIME-Version: 1.0
|
||
|
|
Content-Type: text/plain; charset=UTF-8
|
||
|
|
Content-Transfer-Encoding: 8bit
|
||
|
|
|
||
|
|
Suggested-by: Cédric Le Goater <clg@redhat.com>
|
||
|
|
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
|
||
|
|
Reviewed-by: Eric Auger <eric.auger@redhat.com>
|
||
|
|
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
||
|
|
---
|
||
|
|
backends/iommufd.c | 23 +++++++++++++++++++++++
|
||
|
|
1 file changed, 23 insertions(+)
|
||
|
|
|
||
|
|
diff --git a/backends/iommufd.c b/backends/iommufd.c
|
||
|
|
index 604a8f4e7d..7e805bd664 100644
|
||
|
|
--- a/backends/iommufd.c
|
||
|
|
+++ b/backends/iommufd.c
|
||
|
|
@@ -245,6 +245,28 @@ bool iommufd_backend_get_device_info(IOMMUFDBackend *be, uint32_t devid,
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
|
||
|
|
+static int hiod_iommufd_get_cap(HostIOMMUDevice *hiod, int cap, Error **errp)
|
||
|
|
+{
|
||
|
|
+ HostIOMMUDeviceCaps *caps = &hiod->caps;
|
||
|
|
+
|
||
|
|
+ switch (cap) {
|
||
|
|
+ case HOST_IOMMU_DEVICE_CAP_IOMMU_TYPE:
|
||
|
|
+ return caps->type;
|
||
|
|
+ case HOST_IOMMU_DEVICE_CAP_AW_BITS:
|
||
|
|
+ return caps->aw_bits;
|
||
|
|
+ default:
|
||
|
|
+ error_setg(errp, "%s: unsupported capability %x", hiod->name, cap);
|
||
|
|
+ return -EINVAL;
|
||
|
|
+ }
|
||
|
|
+}
|
||
|
|
+
|
||
|
|
+static void hiod_iommufd_class_init(ObjectClass *oc, void *data)
|
||
|
|
+{
|
||
|
|
+ HostIOMMUDeviceClass *hioc = HOST_IOMMU_DEVICE_CLASS(oc);
|
||
|
|
+
|
||
|
|
+ hioc->get_cap = hiod_iommufd_get_cap;
|
||
|
|
+};
|
||
|
|
+
|
||
|
|
static const TypeInfo types[] = {
|
||
|
|
{
|
||
|
|
.name = TYPE_IOMMUFD_BACKEND,
|
||
|
|
@@ -261,6 +283,7 @@ static const TypeInfo types[] = {
|
||
|
|
}, {
|
||
|
|
.name = TYPE_HOST_IOMMU_DEVICE_IOMMUFD,
|
||
|
|
.parent = TYPE_HOST_IOMMU_DEVICE,
|
||
|
|
+ .class_init = hiod_iommufd_class_init,
|
||
|
|
.abstract = true,
|
||
|
|
}
|
||
|
|
};
|
||
|
|
--
|
||
|
|
2.41.0.windows.1
|
||
|
|
|