qtest/ahci: remove guest_malloc global
[qemu/ar7.git] / hw / virtio / virtio-pci.h
blob8873b6d138e9de9d3ebf62b492ca801d52992a03
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 #ifdef CONFIG_VIRTFS
28 #include "hw/9pfs/virtio-9p.h"
29 #endif
30 #ifdef CONFIG_VHOST_SCSI
31 #include "hw/virtio/vhost-scsi.h"
32 #endif
34 typedef struct VirtIOPCIProxy VirtIOPCIProxy;
35 typedef struct VirtIOBlkPCI VirtIOBlkPCI;
36 typedef struct VirtIOSCSIPCI VirtIOSCSIPCI;
37 typedef struct VirtIOBalloonPCI VirtIOBalloonPCI;
38 typedef struct VirtIOSerialPCI VirtIOSerialPCI;
39 typedef struct VirtIONetPCI VirtIONetPCI;
40 typedef struct VHostSCSIPCI VHostSCSIPCI;
41 typedef struct VirtIORngPCI VirtIORngPCI;
43 /* virtio-pci-bus */
45 typedef struct VirtioBusState VirtioPCIBusState;
46 typedef struct VirtioBusClass VirtioPCIBusClass;
48 #define TYPE_VIRTIO_PCI_BUS "virtio-pci-bus"
49 #define VIRTIO_PCI_BUS(obj) \
50 OBJECT_CHECK(VirtioPCIBusState, (obj), TYPE_VIRTIO_PCI_BUS)
51 #define VIRTIO_PCI_BUS_GET_CLASS(obj) \
52 OBJECT_GET_CLASS(VirtioPCIBusClass, obj, TYPE_VIRTIO_PCI_BUS)
53 #define VIRTIO_PCI_BUS_CLASS(klass) \
54 OBJECT_CLASS_CHECK(VirtioPCIBusClass, klass, TYPE_VIRTIO_PCI_BUS)
56 /* Need to activate work-arounds for buggy guests at vmstate load. */
57 #define VIRTIO_PCI_FLAG_BUS_MASTER_BUG_MIGRATION_BIT 0
58 #define VIRTIO_PCI_FLAG_BUS_MASTER_BUG_MIGRATION \
59 (1 << VIRTIO_PCI_FLAG_BUS_MASTER_BUG_MIGRATION_BIT)
61 /* Performance improves when virtqueue kick processing is decoupled from the
62 * vcpu thread using ioeventfd for some devices. */
63 #define VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT 1
64 #define VIRTIO_PCI_FLAG_USE_IOEVENTFD (1 << VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT)
66 typedef struct {
67 MSIMessage msg;
68 int virq;
69 unsigned int users;
70 } VirtIOIRQFD;
73 * virtio-pci: This is the PCIDevice which has a virtio-pci-bus.
75 #define TYPE_VIRTIO_PCI "virtio-pci"
76 #define VIRTIO_PCI_GET_CLASS(obj) \
77 OBJECT_GET_CLASS(VirtioPCIClass, obj, TYPE_VIRTIO_PCI)
78 #define VIRTIO_PCI_CLASS(klass) \
79 OBJECT_CLASS_CHECK(VirtioPCIClass, klass, TYPE_VIRTIO_PCI)
80 #define VIRTIO_PCI(obj) \
81 OBJECT_CHECK(VirtIOPCIProxy, (obj), TYPE_VIRTIO_PCI)
83 typedef struct VirtioPCIClass {
84 PCIDeviceClass parent_class;
85 int (*init)(VirtIOPCIProxy *vpci_dev);
86 } VirtioPCIClass;
88 struct VirtIOPCIProxy {
89 PCIDevice pci_dev;
90 MemoryRegion bar;
91 uint32_t flags;
92 uint32_t class_code;
93 uint32_t nvectors;
94 uint32_t host_features;
95 bool ioeventfd_disabled;
96 bool ioeventfd_started;
97 VirtIOIRQFD *vector_irqfd;
98 int nvqs_with_notifiers;
99 VirtioBusState bus;
104 * virtio-scsi-pci: This extends VirtioPCIProxy.
106 #define TYPE_VIRTIO_SCSI_PCI "virtio-scsi-pci"
107 #define VIRTIO_SCSI_PCI(obj) \
108 OBJECT_CHECK(VirtIOSCSIPCI, (obj), TYPE_VIRTIO_SCSI_PCI)
110 struct VirtIOSCSIPCI {
111 VirtIOPCIProxy parent_obj;
112 VirtIOSCSI vdev;
115 #ifdef CONFIG_VHOST_SCSI
117 * vhost-scsi-pci: This extends VirtioPCIProxy.
119 #define TYPE_VHOST_SCSI_PCI "vhost-scsi-pci"
120 #define VHOST_SCSI_PCI(obj) \
121 OBJECT_CHECK(VHostSCSIPCI, (obj), TYPE_VHOST_SCSI_PCI)
123 struct VHostSCSIPCI {
124 VirtIOPCIProxy parent_obj;
125 VHostSCSI vdev;
127 #endif
130 * virtio-blk-pci: This extends VirtioPCIProxy.
132 #define TYPE_VIRTIO_BLK_PCI "virtio-blk-pci"
133 #define VIRTIO_BLK_PCI(obj) \
134 OBJECT_CHECK(VirtIOBlkPCI, (obj), TYPE_VIRTIO_BLK_PCI)
136 struct VirtIOBlkPCI {
137 VirtIOPCIProxy parent_obj;
138 VirtIOBlock vdev;
142 * virtio-balloon-pci: This extends VirtioPCIProxy.
144 #define TYPE_VIRTIO_BALLOON_PCI "virtio-balloon-pci"
145 #define VIRTIO_BALLOON_PCI(obj) \
146 OBJECT_CHECK(VirtIOBalloonPCI, (obj), TYPE_VIRTIO_BALLOON_PCI)
148 struct VirtIOBalloonPCI {
149 VirtIOPCIProxy parent_obj;
150 VirtIOBalloon vdev;
154 * virtio-serial-pci: This extends VirtioPCIProxy.
156 #define TYPE_VIRTIO_SERIAL_PCI "virtio-serial-pci"
157 #define VIRTIO_SERIAL_PCI(obj) \
158 OBJECT_CHECK(VirtIOSerialPCI, (obj), TYPE_VIRTIO_SERIAL_PCI)
160 struct VirtIOSerialPCI {
161 VirtIOPCIProxy parent_obj;
162 VirtIOSerial vdev;
166 * virtio-net-pci: This extends VirtioPCIProxy.
168 #define TYPE_VIRTIO_NET_PCI "virtio-net-pci"
169 #define VIRTIO_NET_PCI(obj) \
170 OBJECT_CHECK(VirtIONetPCI, (obj), TYPE_VIRTIO_NET_PCI)
172 struct VirtIONetPCI {
173 VirtIOPCIProxy parent_obj;
174 VirtIONet vdev;
178 * virtio-9p-pci: This extends VirtioPCIProxy.
181 #ifdef CONFIG_VIRTFS
183 #define TYPE_VIRTIO_9P_PCI "virtio-9p-pci"
184 #define VIRTIO_9P_PCI(obj) \
185 OBJECT_CHECK(V9fsPCIState, (obj), TYPE_VIRTIO_9P_PCI)
187 typedef struct V9fsPCIState {
188 VirtIOPCIProxy parent_obj;
189 V9fsState vdev;
190 } V9fsPCIState;
192 #endif
195 * virtio-rng-pci: This extends VirtioPCIProxy.
197 #define TYPE_VIRTIO_RNG_PCI "virtio-rng-pci"
198 #define VIRTIO_RNG_PCI(obj) \
199 OBJECT_CHECK(VirtIORngPCI, (obj), TYPE_VIRTIO_RNG_PCI)
201 struct VirtIORngPCI {
202 VirtIOPCIProxy parent_obj;
203 VirtIORNG vdev;
206 /* Virtio ABI version, if we increment this, we break the guest driver. */
207 #define VIRTIO_PCI_ABI_VERSION 0
209 #endif