Merge tag 'pull-loongarch-20241016' of https://gitlab.com/gaosong/qemu into staging
[qemu/armbru.git] / include / standard-headers / linux / virtio_iommu.h
blob366379c2f077047b34c11e473d54544466f729ad
1 /* SPDX-License-Identifier: BSD-3-Clause */
2 /*
3 * Virtio-iommu definition v0.12
5 * Copyright (C) 2019 Arm Ltd.
6 */
7 #ifndef _LINUX_VIRTIO_IOMMU_H
8 #define _LINUX_VIRTIO_IOMMU_H
10 #include "standard-headers/linux/types.h"
12 /* Feature bits */
13 #define VIRTIO_IOMMU_F_INPUT_RANGE 0
14 #define VIRTIO_IOMMU_F_DOMAIN_RANGE 1
15 #define VIRTIO_IOMMU_F_MAP_UNMAP 2
16 #define VIRTIO_IOMMU_F_BYPASS 3
17 #define VIRTIO_IOMMU_F_PROBE 4
18 #define VIRTIO_IOMMU_F_MMIO 5
19 #define VIRTIO_IOMMU_F_BYPASS_CONFIG 6
21 struct virtio_iommu_range_64 {
22 uint64_t start;
23 uint64_t end;
26 struct virtio_iommu_range_32 {
27 uint32_t start;
28 uint32_t end;
31 struct virtio_iommu_config {
32 /* Supported page sizes */
33 uint64_t page_size_mask;
34 /* Supported IOVA range */
35 struct virtio_iommu_range_64 input_range;
36 /* Max domain ID size */
37 struct virtio_iommu_range_32 domain_range;
38 /* Probe buffer size */
39 uint32_t probe_size;
40 uint8_t bypass;
41 uint8_t reserved[3];
44 /* Request types */
45 #define VIRTIO_IOMMU_T_ATTACH 0x01
46 #define VIRTIO_IOMMU_T_DETACH 0x02
47 #define VIRTIO_IOMMU_T_MAP 0x03
48 #define VIRTIO_IOMMU_T_UNMAP 0x04
49 #define VIRTIO_IOMMU_T_PROBE 0x05
51 /* Status types */
52 #define VIRTIO_IOMMU_S_OK 0x00
53 #define VIRTIO_IOMMU_S_IOERR 0x01
54 #define VIRTIO_IOMMU_S_UNSUPP 0x02
55 #define VIRTIO_IOMMU_S_DEVERR 0x03
56 #define VIRTIO_IOMMU_S_INVAL 0x04
57 #define VIRTIO_IOMMU_S_RANGE 0x05
58 #define VIRTIO_IOMMU_S_NOENT 0x06
59 #define VIRTIO_IOMMU_S_FAULT 0x07
60 #define VIRTIO_IOMMU_S_NOMEM 0x08
62 struct virtio_iommu_req_head {
63 uint8_t type;
64 uint8_t reserved[3];
67 struct virtio_iommu_req_tail {
68 uint8_t status;
69 uint8_t reserved[3];
72 #define VIRTIO_IOMMU_ATTACH_F_BYPASS (1 << 0)
74 struct virtio_iommu_req_attach {
75 struct virtio_iommu_req_head head;
76 uint32_t domain;
77 uint32_t endpoint;
78 uint32_t flags;
79 uint8_t reserved[4];
80 struct virtio_iommu_req_tail tail;
83 struct virtio_iommu_req_detach {
84 struct virtio_iommu_req_head head;
85 uint32_t domain;
86 uint32_t endpoint;
87 uint8_t reserved[8];
88 struct virtio_iommu_req_tail tail;
91 #define VIRTIO_IOMMU_MAP_F_READ (1 << 0)
92 #define VIRTIO_IOMMU_MAP_F_WRITE (1 << 1)
93 #define VIRTIO_IOMMU_MAP_F_MMIO (1 << 2)
95 #define VIRTIO_IOMMU_MAP_F_MASK (VIRTIO_IOMMU_MAP_F_READ | \
96 VIRTIO_IOMMU_MAP_F_WRITE | \
97 VIRTIO_IOMMU_MAP_F_MMIO)
99 struct virtio_iommu_req_map {
100 struct virtio_iommu_req_head head;
101 uint32_t domain;
102 uint64_t virt_start;
103 uint64_t virt_end;
104 uint64_t phys_start;
105 uint32_t flags;
106 struct virtio_iommu_req_tail tail;
109 struct virtio_iommu_req_unmap {
110 struct virtio_iommu_req_head head;
111 uint32_t domain;
112 uint64_t virt_start;
113 uint64_t virt_end;
114 uint8_t reserved[4];
115 struct virtio_iommu_req_tail tail;
118 #define VIRTIO_IOMMU_PROBE_T_NONE 0
119 #define VIRTIO_IOMMU_PROBE_T_RESV_MEM 1
121 #define VIRTIO_IOMMU_PROBE_T_MASK 0xfff
123 struct virtio_iommu_probe_property {
124 uint16_t type;
125 uint16_t length;
128 #define VIRTIO_IOMMU_RESV_MEM_T_RESERVED 0
129 #define VIRTIO_IOMMU_RESV_MEM_T_MSI 1
131 struct virtio_iommu_probe_resv_mem {
132 struct virtio_iommu_probe_property head;
133 uint8_t subtype;
134 uint8_t reserved[3];
135 uint64_t start;
136 uint64_t end;
139 struct virtio_iommu_req_probe {
140 struct virtio_iommu_req_head head;
141 uint32_t endpoint;
142 uint8_t reserved[64];
144 uint8_t properties[];
147 * Tail follows the variable-length properties array. No padding,
148 * property lengths are all aligned on 8 bytes.
152 /* Fault types */
153 #define VIRTIO_IOMMU_FAULT_R_UNKNOWN 0
154 #define VIRTIO_IOMMU_FAULT_R_DOMAIN 1
155 #define VIRTIO_IOMMU_FAULT_R_MAPPING 2
157 #define VIRTIO_IOMMU_FAULT_F_READ (1 << 0)
158 #define VIRTIO_IOMMU_FAULT_F_WRITE (1 << 1)
159 #define VIRTIO_IOMMU_FAULT_F_EXEC (1 << 2)
160 #define VIRTIO_IOMMU_FAULT_F_ADDRESS (1 << 8)
162 struct virtio_iommu_fault {
163 uint8_t reason;
164 uint8_t reserved[3];
165 uint32_t flags;
166 uint32_t endpoint;
167 uint8_t reserved2[4];
168 uint64_t address;
171 #endif