fw_cfg: amend callback behavior spec to once per select
[qemu/ar7.git] / hw / virtio / virtio-pci.h
bloba104ff20729b139e8dc3dc2dc0e6fb8b9ef67a9b
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-9p.h"
27 #include "hw/virtio/virtio-input.h"
28 #include "hw/virtio/virtio-gpu.h"
29 #ifdef CONFIG_VIRTFS
30 #include "hw/9pfs/virtio-9p.h"
31 #endif
32 #ifdef CONFIG_VHOST_SCSI
33 #include "hw/virtio/vhost-scsi.h"
34 #endif
36 typedef struct VirtIOPCIProxy VirtIOPCIProxy;
37 typedef struct VirtIOBlkPCI VirtIOBlkPCI;
38 typedef struct VirtIOSCSIPCI VirtIOSCSIPCI;
39 typedef struct VirtIOBalloonPCI VirtIOBalloonPCI;
40 typedef struct VirtIOSerialPCI VirtIOSerialPCI;
41 typedef struct VirtIONetPCI VirtIONetPCI;
42 typedef struct VHostSCSIPCI VHostSCSIPCI;
43 typedef struct VirtIORngPCI VirtIORngPCI;
44 typedef struct VirtIOInputPCI VirtIOInputPCI;
45 typedef struct VirtIOInputHIDPCI VirtIOInputHIDPCI;
46 typedef struct VirtIOInputHostPCI VirtIOInputHostPCI;
47 typedef struct VirtIOGPUPCI VirtIOGPUPCI;
49 /* virtio-pci-bus */
51 typedef struct VirtioBusState VirtioPCIBusState;
52 typedef struct VirtioBusClass VirtioPCIBusClass;
54 #define TYPE_VIRTIO_PCI_BUS "virtio-pci-bus"
55 #define VIRTIO_PCI_BUS(obj) \
56 OBJECT_CHECK(VirtioPCIBusState, (obj), TYPE_VIRTIO_PCI_BUS)
57 #define VIRTIO_PCI_BUS_GET_CLASS(obj) \
58 OBJECT_GET_CLASS(VirtioPCIBusClass, obj, TYPE_VIRTIO_PCI_BUS)
59 #define VIRTIO_PCI_BUS_CLASS(klass) \
60 OBJECT_CLASS_CHECK(VirtioPCIBusClass, klass, TYPE_VIRTIO_PCI_BUS)
62 /* Need to activate work-arounds for buggy guests at vmstate load. */
63 #define VIRTIO_PCI_FLAG_BUS_MASTER_BUG_MIGRATION_BIT 0
64 #define VIRTIO_PCI_FLAG_BUS_MASTER_BUG_MIGRATION \
65 (1 << VIRTIO_PCI_FLAG_BUS_MASTER_BUG_MIGRATION_BIT)
67 /* Performance improves when virtqueue kick processing is decoupled from the
68 * vcpu thread using ioeventfd for some devices. */
69 #define VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT 1
70 #define VIRTIO_PCI_FLAG_USE_IOEVENTFD (1 << VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT)
72 /* virtio version flags */
73 #define VIRTIO_PCI_FLAG_DISABLE_LEGACY_BIT 2
74 #define VIRTIO_PCI_FLAG_DISABLE_MODERN_BIT 3
75 #define VIRTIO_PCI_FLAG_DISABLE_PCIE_BIT 4
76 #define VIRTIO_PCI_FLAG_DISABLE_LEGACY (1 << VIRTIO_PCI_FLAG_DISABLE_LEGACY_BIT)
77 #define VIRTIO_PCI_FLAG_DISABLE_MODERN (1 << VIRTIO_PCI_FLAG_DISABLE_MODERN_BIT)
78 #define VIRTIO_PCI_FLAG_DISABLE_PCIE (1 << VIRTIO_PCI_FLAG_DISABLE_PCIE_BIT)
80 /* migrate extra state */
81 #define VIRTIO_PCI_FLAG_MIGRATE_EXTRA_BIT 4
82 #define VIRTIO_PCI_FLAG_MIGRATE_EXTRA (1 << VIRTIO_PCI_FLAG_MIGRATE_EXTRA_BIT)
84 /* have pio notification for modern device ? */
85 #define VIRTIO_PCI_FLAG_MODERN_PIO_NOTIFY_BIT 5
86 #define VIRTIO_PCI_FLAG_MODERN_PIO_NOTIFY \
87 (1 << VIRTIO_PCI_FLAG_MODERN_PIO_NOTIFY_BIT)
89 typedef struct {
90 MSIMessage msg;
91 int virq;
92 unsigned int users;
93 } VirtIOIRQFD;
96 * virtio-pci: This is the PCIDevice which has a virtio-pci-bus.
98 #define TYPE_VIRTIO_PCI "virtio-pci"
99 #define VIRTIO_PCI_GET_CLASS(obj) \
100 OBJECT_GET_CLASS(VirtioPCIClass, obj, TYPE_VIRTIO_PCI)
101 #define VIRTIO_PCI_CLASS(klass) \
102 OBJECT_CLASS_CHECK(VirtioPCIClass, klass, TYPE_VIRTIO_PCI)
103 #define VIRTIO_PCI(obj) \
104 OBJECT_CHECK(VirtIOPCIProxy, (obj), TYPE_VIRTIO_PCI)
106 typedef struct VirtioPCIClass {
107 PCIDeviceClass parent_class;
108 DeviceRealize parent_dc_realize;
109 void (*realize)(VirtIOPCIProxy *vpci_dev, Error **errp);
110 } VirtioPCIClass;
112 typedef struct VirtIOPCIRegion {
113 MemoryRegion mr;
114 uint32_t offset;
115 uint32_t size;
116 uint32_t type;
117 } VirtIOPCIRegion;
119 typedef struct VirtIOPCIQueue {
120 uint16_t num;
121 bool enabled;
122 uint32_t desc[2];
123 uint32_t avail[2];
124 uint32_t used[2];
125 } VirtIOPCIQueue;
127 struct VirtIOPCIProxy {
128 PCIDevice pci_dev;
129 MemoryRegion bar;
130 VirtIOPCIRegion common;
131 VirtIOPCIRegion isr;
132 VirtIOPCIRegion device;
133 VirtIOPCIRegion notify;
134 VirtIOPCIRegion notify_pio;
135 MemoryRegion modern_bar;
136 MemoryRegion io_bar;
137 MemoryRegion modern_cfg;
138 AddressSpace modern_as;
139 uint32_t legacy_io_bar;
140 uint32_t msix_bar;
141 uint32_t modern_io_bar;
142 uint32_t modern_mem_bar;
143 int config_cap;
144 uint32_t flags;
145 uint32_t class_code;
146 uint32_t nvectors;
147 uint32_t dfselect;
148 uint32_t gfselect;
149 uint32_t guest_features[2];
150 VirtIOPCIQueue vqs[VIRTIO_QUEUE_MAX];
152 bool ioeventfd_disabled;
153 bool ioeventfd_started;
154 VirtIOIRQFD *vector_irqfd;
155 int nvqs_with_notifiers;
156 VirtioBusState bus;
161 * virtio-scsi-pci: This extends VirtioPCIProxy.
163 #define TYPE_VIRTIO_SCSI_PCI "virtio-scsi-pci"
164 #define VIRTIO_SCSI_PCI(obj) \
165 OBJECT_CHECK(VirtIOSCSIPCI, (obj), TYPE_VIRTIO_SCSI_PCI)
167 struct VirtIOSCSIPCI {
168 VirtIOPCIProxy parent_obj;
169 VirtIOSCSI vdev;
172 #ifdef CONFIG_VHOST_SCSI
174 * vhost-scsi-pci: This extends VirtioPCIProxy.
176 #define TYPE_VHOST_SCSI_PCI "vhost-scsi-pci"
177 #define VHOST_SCSI_PCI(obj) \
178 OBJECT_CHECK(VHostSCSIPCI, (obj), TYPE_VHOST_SCSI_PCI)
180 struct VHostSCSIPCI {
181 VirtIOPCIProxy parent_obj;
182 VHostSCSI vdev;
184 #endif
187 * virtio-blk-pci: This extends VirtioPCIProxy.
189 #define TYPE_VIRTIO_BLK_PCI "virtio-blk-pci"
190 #define VIRTIO_BLK_PCI(obj) \
191 OBJECT_CHECK(VirtIOBlkPCI, (obj), TYPE_VIRTIO_BLK_PCI)
193 struct VirtIOBlkPCI {
194 VirtIOPCIProxy parent_obj;
195 VirtIOBlock vdev;
199 * virtio-balloon-pci: This extends VirtioPCIProxy.
201 #define TYPE_VIRTIO_BALLOON_PCI "virtio-balloon-pci"
202 #define VIRTIO_BALLOON_PCI(obj) \
203 OBJECT_CHECK(VirtIOBalloonPCI, (obj), TYPE_VIRTIO_BALLOON_PCI)
205 struct VirtIOBalloonPCI {
206 VirtIOPCIProxy parent_obj;
207 VirtIOBalloon vdev;
211 * virtio-serial-pci: This extends VirtioPCIProxy.
213 #define TYPE_VIRTIO_SERIAL_PCI "virtio-serial-pci"
214 #define VIRTIO_SERIAL_PCI(obj) \
215 OBJECT_CHECK(VirtIOSerialPCI, (obj), TYPE_VIRTIO_SERIAL_PCI)
217 struct VirtIOSerialPCI {
218 VirtIOPCIProxy parent_obj;
219 VirtIOSerial vdev;
223 * virtio-net-pci: This extends VirtioPCIProxy.
225 #define TYPE_VIRTIO_NET_PCI "virtio-net-pci"
226 #define VIRTIO_NET_PCI(obj) \
227 OBJECT_CHECK(VirtIONetPCI, (obj), TYPE_VIRTIO_NET_PCI)
229 struct VirtIONetPCI {
230 VirtIOPCIProxy parent_obj;
231 VirtIONet vdev;
235 * virtio-9p-pci: This extends VirtioPCIProxy.
238 #ifdef CONFIG_VIRTFS
240 #define TYPE_VIRTIO_9P_PCI "virtio-9p-pci"
241 #define VIRTIO_9P_PCI(obj) \
242 OBJECT_CHECK(V9fsPCIState, (obj), TYPE_VIRTIO_9P_PCI)
244 typedef struct V9fsPCIState {
245 VirtIOPCIProxy parent_obj;
246 V9fsState vdev;
247 } V9fsPCIState;
249 #endif
252 * virtio-rng-pci: This extends VirtioPCIProxy.
254 #define TYPE_VIRTIO_RNG_PCI "virtio-rng-pci"
255 #define VIRTIO_RNG_PCI(obj) \
256 OBJECT_CHECK(VirtIORngPCI, (obj), TYPE_VIRTIO_RNG_PCI)
258 struct VirtIORngPCI {
259 VirtIOPCIProxy parent_obj;
260 VirtIORNG vdev;
264 * virtio-input-pci: This extends VirtioPCIProxy.
266 #define TYPE_VIRTIO_INPUT_PCI "virtio-input-pci"
267 #define VIRTIO_INPUT_PCI(obj) \
268 OBJECT_CHECK(VirtIOInputPCI, (obj), TYPE_VIRTIO_INPUT_PCI)
270 struct VirtIOInputPCI {
271 VirtIOPCIProxy parent_obj;
272 VirtIOInput vdev;
275 #define TYPE_VIRTIO_INPUT_HID_PCI "virtio-input-hid-pci"
276 #define TYPE_VIRTIO_KEYBOARD_PCI "virtio-keyboard-pci"
277 #define TYPE_VIRTIO_MOUSE_PCI "virtio-mouse-pci"
278 #define TYPE_VIRTIO_TABLET_PCI "virtio-tablet-pci"
279 #define VIRTIO_INPUT_HID_PCI(obj) \
280 OBJECT_CHECK(VirtIOInputHIDPCI, (obj), TYPE_VIRTIO_INPUT_HID_PCI)
282 struct VirtIOInputHIDPCI {
283 VirtIOPCIProxy parent_obj;
284 VirtIOInputHID vdev;
287 #ifdef CONFIG_LINUX
289 #define TYPE_VIRTIO_INPUT_HOST_PCI "virtio-input-host-pci"
290 #define VIRTIO_INPUT_HOST_PCI(obj) \
291 OBJECT_CHECK(VirtIOInputHostPCI, (obj), TYPE_VIRTIO_INPUT_HOST_PCI)
293 struct VirtIOInputHostPCI {
294 VirtIOPCIProxy parent_obj;
295 VirtIOInputHost vdev;
298 #endif
301 * virtio-gpu-pci: This extends VirtioPCIProxy.
303 #define TYPE_VIRTIO_GPU_PCI "virtio-gpu-pci"
304 #define VIRTIO_GPU_PCI(obj) \
305 OBJECT_CHECK(VirtIOGPUPCI, (obj), TYPE_VIRTIO_GPU_PCI)
307 struct VirtIOGPUPCI {
308 VirtIOPCIProxy parent_obj;
309 VirtIOGPU vdev;
312 /* Virtio ABI version, if we increment this, we break the guest driver. */
313 #define VIRTIO_PCI_ABI_VERSION 0
315 #endif