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 typedef struct VirtIOPCIProxy VirtIOPCIProxy;
29 typedef struct VirtIOBlkPCI VirtIOBlkPCI;
30 typedef struct VirtIOSCSIPCI VirtIOSCSIPCI;
31 typedef struct VirtIOBalloonPCI VirtIOBalloonPCI;
32 typedef struct VirtIOSerialPCI VirtIOSerialPCI;
36 typedef struct VirtioBusState VirtioPCIBusState;
37 typedef struct VirtioBusClass VirtioPCIBusClass;
39 #define TYPE_VIRTIO_PCI_BUS "virtio-pci-bus"
40 #define VIRTIO_PCI_BUS(obj) \
41 OBJECT_CHECK(VirtioPCIBusState, (obj), TYPE_VIRTIO_PCI_BUS)
42 #define VIRTIO_PCI_BUS_GET_CLASS(obj) \
43 OBJECT_GET_CLASS(VirtioPCIBusClass, obj, TYPE_VIRTIO_PCI_BUS)
44 #define VIRTIO_PCI_BUS_CLASS(klass) \
45 OBJECT_CLASS_CHECK(VirtioPCIBusClass, klass, TYPE_VIRTIO_PCI_BUS)
47 /* Performance improves when virtqueue kick processing is decoupled from the
48 * vcpu thread using ioeventfd for some devices. */
49 #define VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT 1
50 #define VIRTIO_PCI_FLAG_USE_IOEVENTFD (1 << VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT)
59 * virtio-pci: This is the PCIDevice which has a virtio-pci-bus.
61 #define TYPE_VIRTIO_PCI "virtio-pci"
62 #define VIRTIO_PCI_GET_CLASS(obj) \
63 OBJECT_GET_CLASS(VirtioPCIClass, obj, TYPE_VIRTIO_PCI)
64 #define VIRTIO_PCI_CLASS(klass) \
65 OBJECT_CLASS_CHECK(VirtioPCIClass, klass, TYPE_VIRTIO_PCI)
66 #define VIRTIO_PCI(obj) \
67 OBJECT_CHECK(VirtIOPCIProxy, (obj), TYPE_VIRTIO_PCI)
69 typedef struct VirtioPCIClass {
70 PCIDeviceClass parent_class;
71 int (*init)(VirtIOPCIProxy *vpci_dev);
74 struct VirtIOPCIProxy {
82 uint32_t host_features;
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;
134 * virtio-serial-pci: This extends VirtioPCIProxy.
136 #define TYPE_VIRTIO_SERIAL_PCI "virtio-serial-pci"
137 #define VIRTIO_SERIAL_PCI(obj) \
138 OBJECT_CHECK(VirtIOSerialPCI, (obj), TYPE_VIRTIO_SERIAL_PCI)
140 struct VirtIOSerialPCI {
141 VirtIOPCIProxy parent_obj;
145 void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev);
146 void virtio_pci_bus_new(VirtioBusState *bus, VirtIOPCIProxy *dev);
148 /* Virtio ABI version, if we increment this, we break the guest driver. */
149 #define VIRTIO_PCI_ABI_VERSION 0