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-blk.h"
20 #include "hw/virtio-net.h"
21 #include "hw/virtio-rng.h"
22 #include "hw/virtio-serial.h"
23 #include "hw/virtio-scsi.h"
24 #include "hw/virtio-bus.h"
25 #include "hw/9pfs/virtio-9p-device.h"
27 typedef struct VirtIOPCIProxy VirtIOPCIProxy;
28 typedef struct VirtIOBlkPCI VirtIOBlkPCI;
32 typedef struct VirtioBusState VirtioPCIBusState;
33 typedef struct VirtioBusClass VirtioPCIBusClass;
35 #define TYPE_VIRTIO_PCI_BUS "virtio-pci-bus"
36 #define VIRTIO_PCI_BUS(obj) \
37 OBJECT_CHECK(VirtioPCIBusState, (obj), TYPE_VIRTIO_PCI_BUS)
38 #define VIRTIO_PCI_BUS_GET_CLASS(obj) \
39 OBJECT_GET_CLASS(VirtioPCIBusClass, obj, TYPE_VIRTIO_PCI_BUS)
40 #define VIRTIO_PCI_BUS_CLASS(klass) \
41 OBJECT_CLASS_CHECK(VirtioPCIBusClass, klass, TYPE_VIRTIO_PCI_BUS)
43 /* Performance improves when virtqueue kick processing is decoupled from the
44 * vcpu thread using ioeventfd for some devices. */
45 #define VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT 1
46 #define VIRTIO_PCI_FLAG_USE_IOEVENTFD (1 << VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT)
55 * virtio-pci: This is the PCIDevice which has a virtio-pci-bus.
57 #define TYPE_VIRTIO_PCI "virtio-pci"
58 #define VIRTIO_PCI_GET_CLASS(obj) \
59 OBJECT_GET_CLASS(VirtioPCIClass, obj, TYPE_VIRTIO_PCI)
60 #define VIRTIO_PCI_CLASS(klass) \
61 OBJECT_CLASS_CHECK(VirtioPCIClass, klass, TYPE_VIRTIO_PCI)
62 #define VIRTIO_PCI(obj) \
63 OBJECT_CHECK(VirtIOPCIProxy, (obj), TYPE_VIRTIO_PCI)
65 typedef struct VirtioPCIClass {
66 PCIDeviceClass parent_class;
67 int (*init)(VirtIOPCIProxy *vpci_dev);
70 struct VirtIOPCIProxy {
78 uint32_t host_features;
82 virtio_serial_conf serial;
86 bool ioeventfd_disabled;
87 bool ioeventfd_started;
88 VirtIOIRQFD *vector_irqfd;
89 int nvqs_with_notifiers;
94 * virtio-blk-pci: This extends VirtioPCIProxy.
96 #define TYPE_VIRTIO_BLK_PCI "virtio-blk-pci"
97 #define VIRTIO_BLK_PCI(obj) \
98 OBJECT_CHECK(VirtIOBlkPCI, (obj), TYPE_VIRTIO_BLK_PCI)
100 struct VirtIOBlkPCI {
101 VirtIOPCIProxy parent_obj;
106 void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev);
107 void virtio_pci_bus_new(VirtioBusState *bus, VirtIOPCIProxy *dev);
109 /* Virtio ABI version, if we increment this, we break the guest driver. */
110 #define VIRTIO_PCI_ABI_VERSION 0