Merge tag 'pull-loongarch-20241016' of https://gitlab.com/gaosong/qemu into staging
[qemu/armbru.git] / include / sysemu / iommufd.h
blob4c4886c7787b23ee6abdbfd117ae1b628ae41cdd
1 /*
2 * iommufd container backend declaration
4 * Copyright (C) 2024 Intel Corporation.
5 * Copyright Red Hat, Inc. 2024
7 * Authors: Yi Liu <yi.l.liu@intel.com>
8 * Eric Auger <eric.auger@redhat.com>
9 * Zhenzhong Duan <zhenzhong.duan@intel.com>
11 * SPDX-License-Identifier: GPL-2.0-or-later
14 #ifndef SYSEMU_IOMMUFD_H
15 #define SYSEMU_IOMMUFD_H
17 #include "qom/object.h"
18 #include "exec/hwaddr.h"
19 #include "exec/cpu-common.h"
20 #include "sysemu/host_iommu_device.h"
22 #define TYPE_IOMMUFD_BACKEND "iommufd"
23 OBJECT_DECLARE_TYPE(IOMMUFDBackend, IOMMUFDBackendClass, IOMMUFD_BACKEND)
25 struct IOMMUFDBackendClass {
26 ObjectClass parent_class;
29 struct IOMMUFDBackend {
30 Object parent;
32 /*< protected >*/
33 int fd; /* /dev/iommu file descriptor */
34 bool owned; /* is the /dev/iommu opened internally */
35 uint32_t users;
37 /*< public >*/
40 bool iommufd_backend_connect(IOMMUFDBackend *be, Error **errp);
41 void iommufd_backend_disconnect(IOMMUFDBackend *be);
43 bool iommufd_backend_alloc_ioas(IOMMUFDBackend *be, uint32_t *ioas_id,
44 Error **errp);
45 void iommufd_backend_free_id(IOMMUFDBackend *be, uint32_t id);
46 int iommufd_backend_map_dma(IOMMUFDBackend *be, uint32_t ioas_id, hwaddr iova,
47 ram_addr_t size, void *vaddr, bool readonly);
48 int iommufd_backend_unmap_dma(IOMMUFDBackend *be, uint32_t ioas_id,
49 hwaddr iova, ram_addr_t size);
50 bool iommufd_backend_get_device_info(IOMMUFDBackend *be, uint32_t devid,
51 uint32_t *type, void *data, uint32_t len,
52 uint64_t *caps, Error **errp);
53 bool iommufd_backend_alloc_hwpt(IOMMUFDBackend *be, uint32_t dev_id,
54 uint32_t pt_id, uint32_t flags,
55 uint32_t data_type, uint32_t data_len,
56 void *data_ptr, uint32_t *out_hwpt,
57 Error **errp);
58 bool iommufd_backend_set_dirty_tracking(IOMMUFDBackend *be, uint32_t hwpt_id,
59 bool start, Error **errp);
60 bool iommufd_backend_get_dirty_bitmap(IOMMUFDBackend *be, uint32_t hwpt_id,
61 uint64_t iova, ram_addr_t size,
62 uint64_t page_size, uint64_t *data,
63 Error **errp);
65 #define TYPE_HOST_IOMMU_DEVICE_IOMMUFD TYPE_HOST_IOMMU_DEVICE "-iommufd"
66 #endif