4 * Copyright IBM, Corp. 2007
5 * Copyright (c) 2009 CodeSourcery
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 typedef struct VirtIOPCIProxy VirtIOPCIProxy;
29 typedef struct VirtIOBlkPCI VirtIOBlkPCI;
30 typedef struct VirtIOSCSIPCI VirtIOSCSIPCI;
31 typedef struct VirtIOBalloonPCI VirtIOBalloonPCI;
35 typedef struct VirtioBusState VirtioPCIBusState;
36 typedef struct VirtioBusClass VirtioPCIBusClass;
38 #define TYPE_VIRTIO_PCI_BUS "virtio-pci-bus"
39 #define VIRTIO_PCI_BUS(obj) \
40 OBJECT_CHECK(VirtioPCIBusState, (obj), TYPE_VIRTIO_PCI_BUS)
41 #define VIRTIO_PCI_BUS_GET_CLASS(obj) \
42 OBJECT_GET_CLASS(VirtioPCIBusClass, obj, TYPE_VIRTIO_PCI_BUS)
43 #define VIRTIO_PCI_BUS_CLASS(klass) \
44 OBJECT_CLASS_CHECK(VirtioPCIBusClass, klass, TYPE_VIRTIO_PCI_BUS)
46 /* Performance improves when virtqueue kick processing is decoupled from the
47 * vcpu thread using ioeventfd for some devices. */
48 #define VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT 1
49 #define VIRTIO_PCI_FLAG_USE_IOEVENTFD (1 << VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT)
58 * virtio-pci: This is the PCIDevice which has a virtio-pci-bus.
60 #define TYPE_VIRTIO_PCI "virtio-pci"
61 #define VIRTIO_PCI_GET_CLASS(obj) \
62 OBJECT_GET_CLASS(VirtioPCIClass, obj, TYPE_VIRTIO_PCI)
63 #define VIRTIO_PCI_CLASS(klass) \
64 OBJECT_CLASS_CHECK(VirtioPCIClass, klass, TYPE_VIRTIO_PCI)
65 #define VIRTIO_PCI(obj) \
66 OBJECT_CHECK(VirtIOPCIProxy, (obj), TYPE_VIRTIO_PCI)
68 typedef struct VirtioPCIClass {
69 PCIDeviceClass parent_class;
70 int (*init)(VirtIOPCIProxy *vpci_dev);
73 struct VirtIOPCIProxy {
81 uint32_t host_features;
85 virtio_serial_conf serial;
88 bool ioeventfd_disabled;
89 bool ioeventfd_started;
90 VirtIOIRQFD *vector_irqfd;
91 int nvqs_with_notifiers;
97 * virtio-scsi-pci: This extends VirtioPCIProxy.
99 #define TYPE_VIRTIO_SCSI_PCI "virtio-scsi-pci"
100 #define VIRTIO_SCSI_PCI(obj) \
101 OBJECT_CHECK(VirtIOSCSIPCI, (obj), TYPE_VIRTIO_SCSI_PCI)
103 struct VirtIOSCSIPCI {
104 VirtIOPCIProxy parent_obj;
109 * virtio-blk-pci: This extends VirtioPCIProxy.
111 #define TYPE_VIRTIO_BLK_PCI "virtio-blk-pci"
112 #define VIRTIO_BLK_PCI(obj) \
113 OBJECT_CHECK(VirtIOBlkPCI, (obj), TYPE_VIRTIO_BLK_PCI)
115 struct VirtIOBlkPCI {
116 VirtIOPCIProxy parent_obj;
122 * virtio-balloon-pci: This extends VirtioPCIProxy.
124 #define TYPE_VIRTIO_BALLOON_PCI "virtio-balloon-pci"
125 #define VIRTIO_BALLOON_PCI(obj) \
126 OBJECT_CHECK(VirtIOBalloonPCI, (obj), TYPE_VIRTIO_BALLOON_PCI)
128 struct VirtIOBalloonPCI {
129 VirtIOPCIProxy parent_obj;
133 void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev);
134 void virtio_pci_bus_new(VirtioBusState *bus, VirtIOPCIProxy *dev);
136 /* Virtio ABI version, if we increment this, we break the guest driver. */
137 #define VIRTIO_PCI_ABI_VERSION 0