]> git.proxmox.com Git - qemu.git/blob - hw/virtio-pci.h
virtio-blk: cleanup: init and exit functions.
[qemu.git] / hw / virtio-pci.h
1 /*
2 * Virtio PCI Bindings
3 *
4 * Copyright IBM, Corp. 2007
5 * Copyright (c) 2009 CodeSourcery
6 *
7 * Authors:
8 * Anthony Liguori <aliguori@us.ibm.com>
9 * Paul Brook <paul@codesourcery.com>
10 *
11 * This work is licensed under the terms of the GNU GPL, version 2. See
12 * the COPYING file in the top-level directory.
13 */
14
15 #ifndef QEMU_VIRTIO_PCI_H
16 #define QEMU_VIRTIO_PCI_H
17
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"
26
27 typedef struct VirtIOPCIProxy VirtIOPCIProxy;
28 typedef struct VirtIOBlkPCI VirtIOBlkPCI;
29
30 /* virtio-pci-bus */
31
32 typedef struct VirtioBusState VirtioPCIBusState;
33 typedef struct VirtioBusClass VirtioPCIBusClass;
34
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)
42
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)
47
48 typedef struct {
49 MSIMessage msg;
50 int virq;
51 unsigned int users;
52 } VirtIOIRQFD;
53
54 /*
55 * virtio-pci: This is the PCIDevice which has a virtio-pci-bus.
56 */
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)
64
65 typedef struct VirtioPCIClass {
66 PCIDeviceClass parent_class;
67 int (*init)(VirtIOPCIProxy *vpci_dev);
68 } VirtioPCIClass;
69
70 struct VirtIOPCIProxy {
71 PCIDevice pci_dev;
72 VirtIODevice *vdev;
73 MemoryRegion bar;
74 uint32_t flags;
75 uint32_t class_code;
76 uint32_t nvectors;
77 NICConf nic;
78 uint32_t host_features;
79 #ifdef CONFIG_VIRTFS
80 V9fsConf fsconf;
81 #endif
82 virtio_serial_conf serial;
83 virtio_net_conf net;
84 VirtIOSCSIConf scsi;
85 VirtIORNGConf rng;
86 bool ioeventfd_disabled;
87 bool ioeventfd_started;
88 VirtIOIRQFD *vector_irqfd;
89 int nvqs_with_notifiers;
90 VirtioBusState bus;
91 };
92
93 /*
94 * virtio-blk-pci: This extends VirtioPCIProxy.
95 */
96 #define TYPE_VIRTIO_BLK_PCI "virtio-blk-pci"
97 #define VIRTIO_BLK_PCI(obj) \
98 OBJECT_CHECK(VirtIOBlkPCI, (obj), TYPE_VIRTIO_BLK_PCI)
99
100 struct VirtIOBlkPCI {
101 VirtIOPCIProxy parent_obj;
102 VirtIOBlock vdev;
103 VirtIOBlkConf blk;
104 };
105
106 void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev);
107 void virtio_pci_bus_new(VirtioBusState *bus, VirtIOPCIProxy *dev);
108
109 /* Virtio ABI version, if we increment this, we break the guest driver. */
110 #define VIRTIO_PCI_ABI_VERSION 0
111
112 #endif