4 * Copyright IBM, Corp. 2007
5 * Copyright (c) 2009 CodeSourcery
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"
28 #include "hw/9pfs/virtio-9p.h"
30 #ifdef CONFIG_VHOST_SCSI
31 #include "hw/virtio/vhost-scsi.h"
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
;
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)
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 void (*realize
)(VirtIOPCIProxy
*vpci_dev
, Error
**errp
);
88 struct VirtIOPCIProxy
{
94 bool ioeventfd_disabled
;
95 bool ioeventfd_started
;
96 VirtIOIRQFD
*vector_irqfd
;
97 int nvqs_with_notifiers
;
103 * virtio-scsi-pci: This extends VirtioPCIProxy.
105 #define TYPE_VIRTIO_SCSI_PCI "virtio-scsi-pci"
106 #define VIRTIO_SCSI_PCI(obj) \
107 OBJECT_CHECK(VirtIOSCSIPCI, (obj), TYPE_VIRTIO_SCSI_PCI)
109 struct VirtIOSCSIPCI
{
110 VirtIOPCIProxy parent_obj
;
114 #ifdef CONFIG_VHOST_SCSI
116 * vhost-scsi-pci: This extends VirtioPCIProxy.
118 #define TYPE_VHOST_SCSI_PCI "vhost-scsi-pci"
119 #define VHOST_SCSI_PCI(obj) \
120 OBJECT_CHECK(VHostSCSIPCI, (obj), TYPE_VHOST_SCSI_PCI)
122 struct VHostSCSIPCI
{
123 VirtIOPCIProxy parent_obj
;
129 * virtio-blk-pci: This extends VirtioPCIProxy.
131 #define TYPE_VIRTIO_BLK_PCI "virtio-blk-pci"
132 #define VIRTIO_BLK_PCI(obj) \
133 OBJECT_CHECK(VirtIOBlkPCI, (obj), TYPE_VIRTIO_BLK_PCI)
135 struct VirtIOBlkPCI
{
136 VirtIOPCIProxy parent_obj
;
141 * virtio-balloon-pci: This extends VirtioPCIProxy.
143 #define TYPE_VIRTIO_BALLOON_PCI "virtio-balloon-pci"
144 #define VIRTIO_BALLOON_PCI(obj) \
145 OBJECT_CHECK(VirtIOBalloonPCI, (obj), TYPE_VIRTIO_BALLOON_PCI)
147 struct VirtIOBalloonPCI
{
148 VirtIOPCIProxy parent_obj
;
153 * virtio-serial-pci: This extends VirtioPCIProxy.
155 #define TYPE_VIRTIO_SERIAL_PCI "virtio-serial-pci"
156 #define VIRTIO_SERIAL_PCI(obj) \
157 OBJECT_CHECK(VirtIOSerialPCI, (obj), TYPE_VIRTIO_SERIAL_PCI)
159 struct VirtIOSerialPCI
{
160 VirtIOPCIProxy parent_obj
;
165 * virtio-net-pci: This extends VirtioPCIProxy.
167 #define TYPE_VIRTIO_NET_PCI "virtio-net-pci"
168 #define VIRTIO_NET_PCI(obj) \
169 OBJECT_CHECK(VirtIONetPCI, (obj), TYPE_VIRTIO_NET_PCI)
171 struct VirtIONetPCI
{
172 VirtIOPCIProxy parent_obj
;
177 * virtio-9p-pci: This extends VirtioPCIProxy.
182 #define TYPE_VIRTIO_9P_PCI "virtio-9p-pci"
183 #define VIRTIO_9P_PCI(obj) \
184 OBJECT_CHECK(V9fsPCIState, (obj), TYPE_VIRTIO_9P_PCI)
186 typedef struct V9fsPCIState
{
187 VirtIOPCIProxy parent_obj
;
194 * virtio-rng-pci: This extends VirtioPCIProxy.
196 #define TYPE_VIRTIO_RNG_PCI "virtio-rng-pci"
197 #define VIRTIO_RNG_PCI(obj) \
198 OBJECT_CHECK(VirtIORngPCI, (obj), TYPE_VIRTIO_RNG_PCI)
200 struct VirtIORngPCI
{
201 VirtIOPCIProxy parent_obj
;
205 /* Virtio ABI version, if we increment this, we break the guest driver. */
206 #define VIRTIO_PCI_ABI_VERSION 0