s390x/arch_dump: use proper note name and note size
[qemu.git] / hw / virtio / virtio-pci.h
blobd00064cc0c4664fe493f4d0acf6380e1b177f49a
1 /*
2 * Virtio PCI Bindings
4 * Copyright IBM, Corp. 2007
5 * Copyright (c) 2009 CodeSourcery
7 * Authors:
8 * Anthony Liguori <aliguori@us.ibm.com>
9 * Paul Brook <paul@codesourcery.com>
11 * This work is licensed under the terms of the GNU GPL, version 2. See
12 * the COPYING file in the top-level directory.
15 #ifndef QEMU_VIRTIO_PCI_H
16 #define QEMU_VIRTIO_PCI_H
18 #include "hw/pci/msi.h"
19 #include "hw/virtio/virtio-blk.h"
20 #include "hw/virtio/virtio-net.h"
21 #include "hw/virtio/virtio-rng.h"
22 #include "hw/virtio/virtio-serial.h"
23 #include "hw/virtio/virtio-scsi.h"
24 #include "hw/virtio/virtio-balloon.h"
25 #include "hw/virtio/virtio-bus.h"
26 #include "hw/virtio/virtio-input.h"
27 #include "hw/virtio/virtio-gpu.h"
28 #include "hw/virtio/virtio-crypto.h"
30 #ifdef CONFIG_VIRTFS
31 #include "hw/9pfs/virtio-9p.h"
32 #endif
33 #ifdef CONFIG_VHOST_SCSI
34 #include "hw/virtio/vhost-scsi.h"
35 #endif
36 #ifdef CONFIG_VHOST_VSOCK
37 #include "hw/virtio/vhost-vsock.h"
38 #endif
40 typedef struct VirtIOPCIProxy VirtIOPCIProxy;
41 typedef struct VirtIOBlkPCI VirtIOBlkPCI;
42 typedef struct VirtIOSCSIPCI VirtIOSCSIPCI;
43 typedef struct VirtIOBalloonPCI VirtIOBalloonPCI;
44 typedef struct VirtIOSerialPCI VirtIOSerialPCI;
45 typedef struct VirtIONetPCI VirtIONetPCI;
46 typedef struct VHostSCSIPCI VHostSCSIPCI;
47 typedef struct VirtIORngPCI VirtIORngPCI;
48 typedef struct VirtIOInputPCI VirtIOInputPCI;
49 typedef struct VirtIOInputHIDPCI VirtIOInputHIDPCI;
50 typedef struct VirtIOInputHostPCI VirtIOInputHostPCI;
51 typedef struct VirtIOGPUPCI VirtIOGPUPCI;
52 typedef struct VHostVSockPCI VHostVSockPCI;
53 typedef struct VirtIOCryptoPCI VirtIOCryptoPCI;
55 /* virtio-pci-bus */
57 typedef struct VirtioBusState VirtioPCIBusState;
58 typedef struct VirtioBusClass VirtioPCIBusClass;
60 #define TYPE_VIRTIO_PCI_BUS "virtio-pci-bus"
61 #define VIRTIO_PCI_BUS(obj) \
62 OBJECT_CHECK(VirtioPCIBusState, (obj), TYPE_VIRTIO_PCI_BUS)
63 #define VIRTIO_PCI_BUS_GET_CLASS(obj) \
64 OBJECT_GET_CLASS(VirtioPCIBusClass, obj, TYPE_VIRTIO_PCI_BUS)
65 #define VIRTIO_PCI_BUS_CLASS(klass) \
66 OBJECT_CLASS_CHECK(VirtioPCIBusClass, klass, TYPE_VIRTIO_PCI_BUS)
68 enum {
69 VIRTIO_PCI_FLAG_BUS_MASTER_BUG_MIGRATION_BIT,
70 VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT,
71 VIRTIO_PCI_FLAG_MIGRATE_EXTRA_BIT,
72 VIRTIO_PCI_FLAG_MODERN_PIO_NOTIFY_BIT,
73 VIRTIO_PCI_FLAG_DISABLE_PCIE_BIT,
74 VIRTIO_PCI_FLAG_PAGE_PER_VQ_BIT,
75 VIRTIO_PCI_FLAG_ATS_BIT,
78 /* Need to activate work-arounds for buggy guests at vmstate load. */
79 #define VIRTIO_PCI_FLAG_BUS_MASTER_BUG_MIGRATION \
80 (1 << VIRTIO_PCI_FLAG_BUS_MASTER_BUG_MIGRATION_BIT)
82 /* Performance improves when virtqueue kick processing is decoupled from the
83 * vcpu thread using ioeventfd for some devices. */
84 #define VIRTIO_PCI_FLAG_USE_IOEVENTFD (1 << VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT)
86 /* virtio version flags */
87 #define VIRTIO_PCI_FLAG_DISABLE_PCIE (1 << VIRTIO_PCI_FLAG_DISABLE_PCIE_BIT)
89 /* migrate extra state */
90 #define VIRTIO_PCI_FLAG_MIGRATE_EXTRA (1 << VIRTIO_PCI_FLAG_MIGRATE_EXTRA_BIT)
92 /* have pio notification for modern device ? */
93 #define VIRTIO_PCI_FLAG_MODERN_PIO_NOTIFY \
94 (1 << VIRTIO_PCI_FLAG_MODERN_PIO_NOTIFY_BIT)
96 /* page per vq flag to be used by split drivers within guests */
97 #define VIRTIO_PCI_FLAG_PAGE_PER_VQ \
98 (1 << VIRTIO_PCI_FLAG_PAGE_PER_VQ_BIT)
100 /* address space translation service */
101 #define VIRTIO_PCI_FLAG_ATS (1 << VIRTIO_PCI_FLAG_ATS_BIT)
103 typedef struct {
104 MSIMessage msg;
105 int virq;
106 unsigned int users;
107 } VirtIOIRQFD;
110 * virtio-pci: This is the PCIDevice which has a virtio-pci-bus.
112 #define TYPE_VIRTIO_PCI "virtio-pci"
113 #define VIRTIO_PCI_GET_CLASS(obj) \
114 OBJECT_GET_CLASS(VirtioPCIClass, obj, TYPE_VIRTIO_PCI)
115 #define VIRTIO_PCI_CLASS(klass) \
116 OBJECT_CLASS_CHECK(VirtioPCIClass, klass, TYPE_VIRTIO_PCI)
117 #define VIRTIO_PCI(obj) \
118 OBJECT_CHECK(VirtIOPCIProxy, (obj), TYPE_VIRTIO_PCI)
120 typedef struct VirtioPCIClass {
121 PCIDeviceClass parent_class;
122 DeviceRealize parent_dc_realize;
123 void (*realize)(VirtIOPCIProxy *vpci_dev, Error **errp);
124 } VirtioPCIClass;
126 typedef struct VirtIOPCIRegion {
127 MemoryRegion mr;
128 uint32_t offset;
129 uint32_t size;
130 uint32_t type;
131 } VirtIOPCIRegion;
133 typedef struct VirtIOPCIQueue {
134 uint16_t num;
135 bool enabled;
136 uint32_t desc[2];
137 uint32_t avail[2];
138 uint32_t used[2];
139 } VirtIOPCIQueue;
141 struct VirtIOPCIProxy {
142 PCIDevice pci_dev;
143 MemoryRegion bar;
144 VirtIOPCIRegion common;
145 VirtIOPCIRegion isr;
146 VirtIOPCIRegion device;
147 VirtIOPCIRegion notify;
148 VirtIOPCIRegion notify_pio;
149 MemoryRegion modern_bar;
150 MemoryRegion io_bar;
151 MemoryRegion modern_cfg;
152 AddressSpace modern_as;
153 uint32_t legacy_io_bar_idx;
154 uint32_t msix_bar_idx;
155 uint32_t modern_io_bar_idx;
156 uint32_t modern_mem_bar_idx;
157 int config_cap;
158 uint32_t flags;
159 bool disable_modern;
160 bool ignore_backend_features;
161 OnOffAuto disable_legacy;
162 uint32_t class_code;
163 uint32_t nvectors;
164 uint32_t dfselect;
165 uint32_t gfselect;
166 uint32_t guest_features[2];
167 VirtIOPCIQueue vqs[VIRTIO_QUEUE_MAX];
169 VirtIOIRQFD *vector_irqfd;
170 int nvqs_with_notifiers;
171 VirtioBusState bus;
174 static inline bool virtio_pci_modern(VirtIOPCIProxy *proxy)
176 return !proxy->disable_modern;
179 static inline bool virtio_pci_legacy(VirtIOPCIProxy *proxy)
181 return proxy->disable_legacy == ON_OFF_AUTO_OFF;
184 static inline void virtio_pci_force_virtio_1(VirtIOPCIProxy *proxy)
186 proxy->disable_modern = false;
187 proxy->disable_legacy = ON_OFF_AUTO_ON;
190 static inline void virtio_pci_disable_modern(VirtIOPCIProxy *proxy)
192 proxy->disable_modern = true;
196 * virtio-scsi-pci: This extends VirtioPCIProxy.
198 #define TYPE_VIRTIO_SCSI_PCI "virtio-scsi-pci"
199 #define VIRTIO_SCSI_PCI(obj) \
200 OBJECT_CHECK(VirtIOSCSIPCI, (obj), TYPE_VIRTIO_SCSI_PCI)
202 struct VirtIOSCSIPCI {
203 VirtIOPCIProxy parent_obj;
204 VirtIOSCSI vdev;
207 #ifdef CONFIG_VHOST_SCSI
209 * vhost-scsi-pci: This extends VirtioPCIProxy.
211 #define TYPE_VHOST_SCSI_PCI "vhost-scsi-pci"
212 #define VHOST_SCSI_PCI(obj) \
213 OBJECT_CHECK(VHostSCSIPCI, (obj), TYPE_VHOST_SCSI_PCI)
215 struct VHostSCSIPCI {
216 VirtIOPCIProxy parent_obj;
217 VHostSCSI vdev;
219 #endif
222 * virtio-blk-pci: This extends VirtioPCIProxy.
224 #define TYPE_VIRTIO_BLK_PCI "virtio-blk-pci"
225 #define VIRTIO_BLK_PCI(obj) \
226 OBJECT_CHECK(VirtIOBlkPCI, (obj), TYPE_VIRTIO_BLK_PCI)
228 struct VirtIOBlkPCI {
229 VirtIOPCIProxy parent_obj;
230 VirtIOBlock vdev;
234 * virtio-balloon-pci: This extends VirtioPCIProxy.
236 #define TYPE_VIRTIO_BALLOON_PCI "virtio-balloon-pci"
237 #define VIRTIO_BALLOON_PCI(obj) \
238 OBJECT_CHECK(VirtIOBalloonPCI, (obj), TYPE_VIRTIO_BALLOON_PCI)
240 struct VirtIOBalloonPCI {
241 VirtIOPCIProxy parent_obj;
242 VirtIOBalloon vdev;
246 * virtio-serial-pci: This extends VirtioPCIProxy.
248 #define TYPE_VIRTIO_SERIAL_PCI "virtio-serial-pci"
249 #define VIRTIO_SERIAL_PCI(obj) \
250 OBJECT_CHECK(VirtIOSerialPCI, (obj), TYPE_VIRTIO_SERIAL_PCI)
252 struct VirtIOSerialPCI {
253 VirtIOPCIProxy parent_obj;
254 VirtIOSerial vdev;
258 * virtio-net-pci: This extends VirtioPCIProxy.
260 #define TYPE_VIRTIO_NET_PCI "virtio-net-pci"
261 #define VIRTIO_NET_PCI(obj) \
262 OBJECT_CHECK(VirtIONetPCI, (obj), TYPE_VIRTIO_NET_PCI)
264 struct VirtIONetPCI {
265 VirtIOPCIProxy parent_obj;
266 VirtIONet vdev;
270 * virtio-9p-pci: This extends VirtioPCIProxy.
273 #ifdef CONFIG_VIRTFS
275 #define TYPE_VIRTIO_9P_PCI "virtio-9p-pci"
276 #define VIRTIO_9P_PCI(obj) \
277 OBJECT_CHECK(V9fsPCIState, (obj), TYPE_VIRTIO_9P_PCI)
279 typedef struct V9fsPCIState {
280 VirtIOPCIProxy parent_obj;
281 V9fsVirtioState vdev;
282 } V9fsPCIState;
284 #endif
287 * virtio-rng-pci: This extends VirtioPCIProxy.
289 #define TYPE_VIRTIO_RNG_PCI "virtio-rng-pci"
290 #define VIRTIO_RNG_PCI(obj) \
291 OBJECT_CHECK(VirtIORngPCI, (obj), TYPE_VIRTIO_RNG_PCI)
293 struct VirtIORngPCI {
294 VirtIOPCIProxy parent_obj;
295 VirtIORNG vdev;
299 * virtio-input-pci: This extends VirtioPCIProxy.
301 #define TYPE_VIRTIO_INPUT_PCI "virtio-input-pci"
302 #define VIRTIO_INPUT_PCI(obj) \
303 OBJECT_CHECK(VirtIOInputPCI, (obj), TYPE_VIRTIO_INPUT_PCI)
305 struct VirtIOInputPCI {
306 VirtIOPCIProxy parent_obj;
307 VirtIOInput vdev;
310 #define TYPE_VIRTIO_INPUT_HID_PCI "virtio-input-hid-pci"
311 #define TYPE_VIRTIO_KEYBOARD_PCI "virtio-keyboard-pci"
312 #define TYPE_VIRTIO_MOUSE_PCI "virtio-mouse-pci"
313 #define TYPE_VIRTIO_TABLET_PCI "virtio-tablet-pci"
314 #define VIRTIO_INPUT_HID_PCI(obj) \
315 OBJECT_CHECK(VirtIOInputHIDPCI, (obj), TYPE_VIRTIO_INPUT_HID_PCI)
317 struct VirtIOInputHIDPCI {
318 VirtIOPCIProxy parent_obj;
319 VirtIOInputHID vdev;
322 #ifdef CONFIG_LINUX
324 #define TYPE_VIRTIO_INPUT_HOST_PCI "virtio-input-host-pci"
325 #define VIRTIO_INPUT_HOST_PCI(obj) \
326 OBJECT_CHECK(VirtIOInputHostPCI, (obj), TYPE_VIRTIO_INPUT_HOST_PCI)
328 struct VirtIOInputHostPCI {
329 VirtIOPCIProxy parent_obj;
330 VirtIOInputHost vdev;
333 #endif
336 * virtio-gpu-pci: This extends VirtioPCIProxy.
338 #define TYPE_VIRTIO_GPU_PCI "virtio-gpu-pci"
339 #define VIRTIO_GPU_PCI(obj) \
340 OBJECT_CHECK(VirtIOGPUPCI, (obj), TYPE_VIRTIO_GPU_PCI)
342 struct VirtIOGPUPCI {
343 VirtIOPCIProxy parent_obj;
344 VirtIOGPU vdev;
347 #ifdef CONFIG_VHOST_VSOCK
349 * vhost-vsock-pci: This extends VirtioPCIProxy.
351 #define TYPE_VHOST_VSOCK_PCI "vhost-vsock-pci"
352 #define VHOST_VSOCK_PCI(obj) \
353 OBJECT_CHECK(VHostVSockPCI, (obj), TYPE_VHOST_VSOCK_PCI)
355 struct VHostVSockPCI {
356 VirtIOPCIProxy parent_obj;
357 VHostVSock vdev;
359 #endif
362 * virtio-crypto-pci: This extends VirtioPCIProxy.
364 #define TYPE_VIRTIO_CRYPTO_PCI "virtio-crypto-pci"
365 #define VIRTIO_CRYPTO_PCI(obj) \
366 OBJECT_CHECK(VirtIOCryptoPCI, (obj), TYPE_VIRTIO_CRYPTO_PCI)
368 struct VirtIOCryptoPCI {
369 VirtIOPCIProxy parent_obj;
370 VirtIOCrypto vdev;
373 /* Virtio ABI version, if we increment this, we break the guest driver. */
374 #define VIRTIO_PCI_ABI_VERSION 0
376 #endif