diff options
author | Jan Kiszka <jan.kiszka@siemens.com> | 2010-11-16 16:30:07 -0500 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2011-01-12 04:29:25 -0500 |
commit | 49f481720438bbd0138218b0bcb494c3512a454f (patch) | |
tree | 9b080ee6a011f42a441033cdebde5c9f2049bfac | |
parent | 51de271d441c01e7a0cf39f128827e0b4dc56409 (diff) |
KVM: Document device assigment API
Adds API documentation for KVM_[DE]ASSIGN_PCI_DEVICE,
KVM_[DE]ASSIGN_DEV_IRQ, KVM_SET_GSI_ROUTING, KVM_ASSIGN_SET_MSIX_NR, and
KVM_ASSIGN_SET_MSIX_ENTRY.
Acked-by: Alex Williamson <alex.williamson@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
-rw-r--r-- | Documentation/kvm/api.txt | 178 |
1 files changed, 178 insertions, 0 deletions
diff --git a/Documentation/kvm/api.txt b/Documentation/kvm/api.txt index b336266bea5e..e1a92977833e 100644 --- a/Documentation/kvm/api.txt +++ b/Documentation/kvm/api.txt | |||
@@ -1085,6 +1085,184 @@ of 4 instructions that make up a hypercall. | |||
1085 | If any additional field gets added to this structure later on, a bit for that | 1085 | If any additional field gets added to this structure later on, a bit for that |
1086 | additional piece of information will be set in the flags bitmap. | 1086 | additional piece of information will be set in the flags bitmap. |
1087 | 1087 | ||
1088 | 4.47 KVM_ASSIGN_PCI_DEVICE | ||
1089 | |||
1090 | Capability: KVM_CAP_DEVICE_ASSIGNMENT | ||
1091 | Architectures: x86 ia64 | ||
1092 | Type: vm ioctl | ||
1093 | Parameters: struct kvm_assigned_pci_dev (in) | ||
1094 | Returns: 0 on success, -1 on error | ||
1095 | |||
1096 | Assigns a host PCI device to the VM. | ||
1097 | |||
1098 | struct kvm_assigned_pci_dev { | ||
1099 | __u32 assigned_dev_id; | ||
1100 | __u32 busnr; | ||
1101 | __u32 devfn; | ||
1102 | __u32 flags; | ||
1103 | __u32 segnr; | ||
1104 | union { | ||
1105 | __u32 reserved[11]; | ||
1106 | }; | ||
1107 | }; | ||
1108 | |||
1109 | The PCI device is specified by the triple segnr, busnr, and devfn. | ||
1110 | Identification in succeeding service requests is done via assigned_dev_id. The | ||
1111 | following flags are specified: | ||
1112 | |||
1113 | /* Depends on KVM_CAP_IOMMU */ | ||
1114 | #define KVM_DEV_ASSIGN_ENABLE_IOMMU (1 << 0) | ||
1115 | |||
1116 | 4.48 KVM_DEASSIGN_PCI_DEVICE | ||
1117 | |||
1118 | Capability: KVM_CAP_DEVICE_DEASSIGNMENT | ||
1119 | Architectures: x86 ia64 | ||
1120 | Type: vm ioctl | ||
1121 | Parameters: struct kvm_assigned_pci_dev (in) | ||
1122 | Returns: 0 on success, -1 on error | ||
1123 | |||
1124 | Ends PCI device assignment, releasing all associated resources. | ||
1125 | |||
1126 | See KVM_CAP_DEVICE_ASSIGNMENT for the data structure. Only assigned_dev_id is | ||
1127 | used in kvm_assigned_pci_dev to identify the device. | ||
1128 | |||
1129 | 4.49 KVM_ASSIGN_DEV_IRQ | ||
1130 | |||
1131 | Capability: KVM_CAP_ASSIGN_DEV_IRQ | ||
1132 | Architectures: x86 ia64 | ||
1133 | Type: vm ioctl | ||
1134 | Parameters: struct kvm_assigned_irq (in) | ||
1135 | Returns: 0 on success, -1 on error | ||
1136 | |||
1137 | Assigns an IRQ to a passed-through device. | ||
1138 | |||
1139 | struct kvm_assigned_irq { | ||
1140 | __u32 assigned_dev_id; | ||
1141 | __u32 host_irq; | ||
1142 | __u32 guest_irq; | ||
1143 | __u32 flags; | ||
1144 | union { | ||
1145 | struct { | ||
1146 | __u32 addr_lo; | ||
1147 | __u32 addr_hi; | ||
1148 | __u32 data; | ||
1149 | } guest_msi; | ||
1150 | __u32 reserved[12]; | ||
1151 | }; | ||
1152 | }; | ||
1153 | |||
1154 | The following flags are defined: | ||
1155 | |||
1156 | #define KVM_DEV_IRQ_HOST_INTX (1 << 0) | ||
1157 | #define KVM_DEV_IRQ_HOST_MSI (1 << 1) | ||
1158 | #define KVM_DEV_IRQ_HOST_MSIX (1 << 2) | ||
1159 | |||
1160 | #define KVM_DEV_IRQ_GUEST_INTX (1 << 8) | ||
1161 | #define KVM_DEV_IRQ_GUEST_MSI (1 << 9) | ||
1162 | #define KVM_DEV_IRQ_GUEST_MSIX (1 << 10) | ||
1163 | |||
1164 | It is not valid to specify multiple types per host or guest IRQ. However, the | ||
1165 | IRQ type of host and guest can differ or can even be null. | ||
1166 | |||
1167 | 4.50 KVM_DEASSIGN_DEV_IRQ | ||
1168 | |||
1169 | Capability: KVM_CAP_ASSIGN_DEV_IRQ | ||
1170 | Architectures: x86 ia64 | ||
1171 | Type: vm ioctl | ||
1172 | Parameters: struct kvm_assigned_irq (in) | ||
1173 | Returns: 0 on success, -1 on error | ||
1174 | |||
1175 | Ends an IRQ assignment to a passed-through device. | ||
1176 | |||
1177 | See KVM_ASSIGN_DEV_IRQ for the data structure. The target device is specified | ||
1178 | by assigned_dev_id, flags must correspond to the IRQ type specified on | ||
1179 | KVM_ASSIGN_DEV_IRQ. Partial deassignment of host or guest IRQ is allowed. | ||
1180 | |||
1181 | 4.51 KVM_SET_GSI_ROUTING | ||
1182 | |||
1183 | Capability: KVM_CAP_IRQ_ROUTING | ||
1184 | Architectures: x86 ia64 | ||
1185 | Type: vm ioctl | ||
1186 | Parameters: struct kvm_irq_routing (in) | ||
1187 | Returns: 0 on success, -1 on error | ||
1188 | |||
1189 | Sets the GSI routing table entries, overwriting any previously set entries. | ||
1190 | |||
1191 | struct kvm_irq_routing { | ||
1192 | __u32 nr; | ||
1193 | __u32 flags; | ||
1194 | struct kvm_irq_routing_entry entries[0]; | ||
1195 | }; | ||
1196 | |||
1197 | No flags are specified so far, the corresponding field must be set to zero. | ||
1198 | |||
1199 | struct kvm_irq_routing_entry { | ||
1200 | __u32 gsi; | ||
1201 | __u32 type; | ||
1202 | __u32 flags; | ||
1203 | __u32 pad; | ||
1204 | union { | ||
1205 | struct kvm_irq_routing_irqchip irqchip; | ||
1206 | struct kvm_irq_routing_msi msi; | ||
1207 | __u32 pad[8]; | ||
1208 | } u; | ||
1209 | }; | ||
1210 | |||
1211 | /* gsi routing entry types */ | ||
1212 | #define KVM_IRQ_ROUTING_IRQCHIP 1 | ||
1213 | #define KVM_IRQ_ROUTING_MSI 2 | ||
1214 | |||
1215 | No flags are specified so far, the corresponding field must be set to zero. | ||
1216 | |||
1217 | struct kvm_irq_routing_irqchip { | ||
1218 | __u32 irqchip; | ||
1219 | __u32 pin; | ||
1220 | }; | ||
1221 | |||
1222 | struct kvm_irq_routing_msi { | ||
1223 | __u32 address_lo; | ||
1224 | __u32 address_hi; | ||
1225 | __u32 data; | ||
1226 | __u32 pad; | ||
1227 | }; | ||
1228 | |||
1229 | 4.52 KVM_ASSIGN_SET_MSIX_NR | ||
1230 | |||
1231 | Capability: KVM_CAP_DEVICE_MSIX | ||
1232 | Architectures: x86 ia64 | ||
1233 | Type: vm ioctl | ||
1234 | Parameters: struct kvm_assigned_msix_nr (in) | ||
1235 | Returns: 0 on success, -1 on error | ||
1236 | |||
1237 | Set the number of MSI-X interrupts for an assigned device. This service can | ||
1238 | only be called once in the lifetime of an assigned device. | ||
1239 | |||
1240 | struct kvm_assigned_msix_nr { | ||
1241 | __u32 assigned_dev_id; | ||
1242 | __u16 entry_nr; | ||
1243 | __u16 padding; | ||
1244 | }; | ||
1245 | |||
1246 | #define KVM_MAX_MSIX_PER_DEV 256 | ||
1247 | |||
1248 | 4.53 KVM_ASSIGN_SET_MSIX_ENTRY | ||
1249 | |||
1250 | Capability: KVM_CAP_DEVICE_MSIX | ||
1251 | Architectures: x86 ia64 | ||
1252 | Type: vm ioctl | ||
1253 | Parameters: struct kvm_assigned_msix_entry (in) | ||
1254 | Returns: 0 on success, -1 on error | ||
1255 | |||
1256 | Specifies the routing of an MSI-X assigned device interrupt to a GSI. Setting | ||
1257 | the GSI vector to zero means disabling the interrupt. | ||
1258 | |||
1259 | struct kvm_assigned_msix_entry { | ||
1260 | __u32 assigned_dev_id; | ||
1261 | __u32 gsi; | ||
1262 | __u16 entry; /* The index of entry in the MSI-X table */ | ||
1263 | __u16 padding[3]; | ||
1264 | }; | ||
1265 | |||
1088 | 5. The kvm_run structure | 1266 | 5. The kvm_run structure |
1089 | 1267 | ||
1090 | Application code obtains a pointer to the kvm_run structure by | 1268 | Application code obtains a pointer to the kvm_run structure by |