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 /* Performance improves when virtqueue kick processing is decoupled from the
57 * vcpu thread using ioeventfd for some devices. */
58 #define VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT 1
59 #define VIRTIO_PCI_FLAG_USE_IOEVENTFD (1 << VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT)
68 * virtio-pci: This is the PCIDevice which has a virtio-pci-bus.
70 #define TYPE_VIRTIO_PCI "virtio-pci"
71 #define VIRTIO_PCI_GET_CLASS(obj) \
72 OBJECT_GET_CLASS(VirtioPCIClass, obj, TYPE_VIRTIO_PCI)
73 #define VIRTIO_PCI_CLASS(klass) \
74 OBJECT_CLASS_CHECK(VirtioPCIClass, klass, TYPE_VIRTIO_PCI)
75 #define VIRTIO_PCI(obj) \
76 OBJECT_CHECK(VirtIOPCIProxy, (obj), TYPE_VIRTIO_PCI)
78 typedef struct VirtioPCIClass
{
79 PCIDeviceClass parent_class
;
80 int (*init
)(VirtIOPCIProxy
*vpci_dev
);
83 struct VirtIOPCIProxy
{
89 uint32_t host_features
;
90 bool ioeventfd_disabled
;
91 bool ioeventfd_started
;
92 VirtIOIRQFD
*vector_irqfd
;
93 int nvqs_with_notifiers
;
99 * virtio-scsi-pci: This extends VirtioPCIProxy.
101 #define TYPE_VIRTIO_SCSI_PCI "virtio-scsi-pci"
102 #define VIRTIO_SCSI_PCI(obj) \
103 OBJECT_CHECK(VirtIOSCSIPCI, (obj), TYPE_VIRTIO_SCSI_PCI)
105 struct VirtIOSCSIPCI
{
106 VirtIOPCIProxy parent_obj
;
110 #ifdef CONFIG_VHOST_SCSI
112 * vhost-scsi-pci: This extends VirtioPCIProxy.
114 #define TYPE_VHOST_SCSI_PCI "vhost-scsi-pci"
115 #define VHOST_SCSI_PCI(obj) \
116 OBJECT_CHECK(VHostSCSIPCI, (obj), TYPE_VHOST_SCSI_PCI)
118 struct VHostSCSIPCI
{
119 VirtIOPCIProxy parent_obj
;
125 * virtio-blk-pci: This extends VirtioPCIProxy.
127 #define TYPE_VIRTIO_BLK_PCI "virtio-blk-pci"
128 #define VIRTIO_BLK_PCI(obj) \
129 OBJECT_CHECK(VirtIOBlkPCI, (obj), TYPE_VIRTIO_BLK_PCI)
131 struct VirtIOBlkPCI
{
132 VirtIOPCIProxy parent_obj
;
138 * virtio-balloon-pci: This extends VirtioPCIProxy.
140 #define TYPE_VIRTIO_BALLOON_PCI "virtio-balloon-pci"
141 #define VIRTIO_BALLOON_PCI(obj) \
142 OBJECT_CHECK(VirtIOBalloonPCI, (obj), TYPE_VIRTIO_BALLOON_PCI)
144 struct VirtIOBalloonPCI
{
145 VirtIOPCIProxy parent_obj
;
150 * virtio-serial-pci: This extends VirtioPCIProxy.
152 #define TYPE_VIRTIO_SERIAL_PCI "virtio-serial-pci"
153 #define VIRTIO_SERIAL_PCI(obj) \
154 OBJECT_CHECK(VirtIOSerialPCI, (obj), TYPE_VIRTIO_SERIAL_PCI)
156 struct VirtIOSerialPCI
{
157 VirtIOPCIProxy parent_obj
;
162 * virtio-net-pci: This extends VirtioPCIProxy.
164 #define TYPE_VIRTIO_NET_PCI "virtio-net-pci"
165 #define VIRTIO_NET_PCI(obj) \
166 OBJECT_CHECK(VirtIONetPCI, (obj), TYPE_VIRTIO_NET_PCI)
168 struct VirtIONetPCI
{
169 VirtIOPCIProxy parent_obj
;
174 * virtio-9p-pci: This extends VirtioPCIProxy.
179 #define TYPE_VIRTIO_9P_PCI "virtio-9p-pci"
180 #define VIRTIO_9P_PCI(obj) \
181 OBJECT_CHECK(V9fsPCIState, (obj), TYPE_VIRTIO_9P_PCI)
183 typedef struct V9fsPCIState
{
184 VirtIOPCIProxy parent_obj
;
191 * virtio-rng-pci: This extends VirtioPCIProxy.
193 #define TYPE_VIRTIO_RNG_PCI "virtio-rng-pci"
194 #define VIRTIO_RNG_PCI(obj) \
195 OBJECT_CHECK(VirtIORngPCI, (obj), TYPE_VIRTIO_RNG_PCI)
197 struct VirtIORngPCI
{
198 VirtIOPCIProxy parent_obj
;
202 /* Virtio ABI version, if we increment this, we break the guest driver. */
203 #define VIRTIO_PCI_ABI_VERSION 0