root / hw / virtio / virtio-pci.h @ 50787628
History | View | Annotate | Download (4.7 kB)
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/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" |
27 |
#ifdef CONFIG_VHOST_SCSI
|
28 |
#include "hw/virtio/vhost-scsi.h" |
29 |
#endif
|
30 |
|
31 |
typedef struct VirtIOPCIProxy VirtIOPCIProxy; |
32 |
typedef struct VirtIOBlkPCI VirtIOBlkPCI; |
33 |
typedef struct VirtIOSCSIPCI VirtIOSCSIPCI; |
34 |
typedef struct VirtIOBalloonPCI VirtIOBalloonPCI; |
35 |
typedef struct VirtIOSerialPCI VirtIOSerialPCI; |
36 |
typedef struct VirtIONetPCI VirtIONetPCI; |
37 |
typedef struct VHostSCSIPCI VHostSCSIPCI; |
38 |
|
39 |
/* virtio-pci-bus */
|
40 |
|
41 |
typedef struct VirtioBusState VirtioPCIBusState; |
42 |
typedef struct VirtioBusClass VirtioPCIBusClass; |
43 |
|
44 |
#define TYPE_VIRTIO_PCI_BUS "virtio-pci-bus" |
45 |
#define VIRTIO_PCI_BUS(obj) \
|
46 |
OBJECT_CHECK(VirtioPCIBusState, (obj), TYPE_VIRTIO_PCI_BUS) |
47 |
#define VIRTIO_PCI_BUS_GET_CLASS(obj) \
|
48 |
OBJECT_GET_CLASS(VirtioPCIBusClass, obj, TYPE_VIRTIO_PCI_BUS) |
49 |
#define VIRTIO_PCI_BUS_CLASS(klass) \
|
50 |
OBJECT_CLASS_CHECK(VirtioPCIBusClass, klass, TYPE_VIRTIO_PCI_BUS) |
51 |
|
52 |
/* Performance improves when virtqueue kick processing is decoupled from the
|
53 |
* vcpu thread using ioeventfd for some devices. */
|
54 |
#define VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT 1 |
55 |
#define VIRTIO_PCI_FLAG_USE_IOEVENTFD (1 << VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT) |
56 |
|
57 |
typedef struct { |
58 |
MSIMessage msg; |
59 |
int virq;
|
60 |
unsigned int users; |
61 |
} VirtIOIRQFD; |
62 |
|
63 |
/*
|
64 |
* virtio-pci: This is the PCIDevice which has a virtio-pci-bus.
|
65 |
*/
|
66 |
#define TYPE_VIRTIO_PCI "virtio-pci" |
67 |
#define VIRTIO_PCI_GET_CLASS(obj) \
|
68 |
OBJECT_GET_CLASS(VirtioPCIClass, obj, TYPE_VIRTIO_PCI) |
69 |
#define VIRTIO_PCI_CLASS(klass) \
|
70 |
OBJECT_CLASS_CHECK(VirtioPCIClass, klass, TYPE_VIRTIO_PCI) |
71 |
#define VIRTIO_PCI(obj) \
|
72 |
OBJECT_CHECK(VirtIOPCIProxy, (obj), TYPE_VIRTIO_PCI) |
73 |
|
74 |
typedef struct VirtioPCIClass { |
75 |
PCIDeviceClass parent_class; |
76 |
int (*init)(VirtIOPCIProxy *vpci_dev);
|
77 |
} VirtioPCIClass; |
78 |
|
79 |
struct VirtIOPCIProxy {
|
80 |
PCIDevice pci_dev; |
81 |
VirtIODevice *vdev; |
82 |
MemoryRegion bar; |
83 |
uint32_t flags; |
84 |
uint32_t class_code; |
85 |
uint32_t nvectors; |
86 |
uint32_t host_features; |
87 |
#ifdef CONFIG_VIRTFS
|
88 |
V9fsConf fsconf; |
89 |
#endif
|
90 |
VirtIORNGConf rng; |
91 |
bool ioeventfd_disabled;
|
92 |
bool ioeventfd_started;
|
93 |
VirtIOIRQFD *vector_irqfd; |
94 |
int nvqs_with_notifiers;
|
95 |
VirtioBusState bus; |
96 |
}; |
97 |
|
98 |
|
99 |
/*
|
100 |
* virtio-scsi-pci: This extends VirtioPCIProxy.
|
101 |
*/
|
102 |
#define TYPE_VIRTIO_SCSI_PCI "virtio-scsi-pci" |
103 |
#define VIRTIO_SCSI_PCI(obj) \
|
104 |
OBJECT_CHECK(VirtIOSCSIPCI, (obj), TYPE_VIRTIO_SCSI_PCI) |
105 |
|
106 |
struct VirtIOSCSIPCI {
|
107 |
VirtIOPCIProxy parent_obj; |
108 |
VirtIOSCSI vdev; |
109 |
}; |
110 |
|
111 |
#ifdef CONFIG_VHOST_SCSI
|
112 |
/*
|
113 |
* vhost-scsi-pci: This extends VirtioPCIProxy.
|
114 |
*/
|
115 |
#define TYPE_VHOST_SCSI_PCI "vhost-scsi-pci" |
116 |
#define VHOST_SCSI_PCI(obj) \
|
117 |
OBJECT_CHECK(VHostSCSIPCI, (obj), TYPE_VHOST_SCSI_PCI) |
118 |
|
119 |
struct VHostSCSIPCI {
|
120 |
VirtIOPCIProxy parent_obj; |
121 |
VHostSCSI vdev; |
122 |
}; |
123 |
#endif
|
124 |
|
125 |
/*
|
126 |
* virtio-blk-pci: This extends VirtioPCIProxy.
|
127 |
*/
|
128 |
#define TYPE_VIRTIO_BLK_PCI "virtio-blk-pci" |
129 |
#define VIRTIO_BLK_PCI(obj) \
|
130 |
OBJECT_CHECK(VirtIOBlkPCI, (obj), TYPE_VIRTIO_BLK_PCI) |
131 |
|
132 |
struct VirtIOBlkPCI {
|
133 |
VirtIOPCIProxy parent_obj; |
134 |
VirtIOBlock vdev; |
135 |
VirtIOBlkConf blk; |
136 |
}; |
137 |
|
138 |
/*
|
139 |
* virtio-balloon-pci: This extends VirtioPCIProxy.
|
140 |
*/
|
141 |
#define TYPE_VIRTIO_BALLOON_PCI "virtio-balloon-pci" |
142 |
#define VIRTIO_BALLOON_PCI(obj) \
|
143 |
OBJECT_CHECK(VirtIOBalloonPCI, (obj), TYPE_VIRTIO_BALLOON_PCI) |
144 |
|
145 |
struct VirtIOBalloonPCI {
|
146 |
VirtIOPCIProxy parent_obj; |
147 |
VirtIOBalloon vdev; |
148 |
}; |
149 |
|
150 |
/*
|
151 |
* virtio-serial-pci: This extends VirtioPCIProxy.
|
152 |
*/
|
153 |
#define TYPE_VIRTIO_SERIAL_PCI "virtio-serial-pci" |
154 |
#define VIRTIO_SERIAL_PCI(obj) \
|
155 |
OBJECT_CHECK(VirtIOSerialPCI, (obj), TYPE_VIRTIO_SERIAL_PCI) |
156 |
|
157 |
struct VirtIOSerialPCI {
|
158 |
VirtIOPCIProxy parent_obj; |
159 |
VirtIOSerial vdev; |
160 |
}; |
161 |
|
162 |
/*
|
163 |
* virtio-net-pci: This extends VirtioPCIProxy.
|
164 |
*/
|
165 |
#define TYPE_VIRTIO_NET_PCI "virtio-net-pci" |
166 |
#define VIRTIO_NET_PCI(obj) \
|
167 |
OBJECT_CHECK(VirtIONetPCI, (obj), TYPE_VIRTIO_NET_PCI) |
168 |
|
169 |
struct VirtIONetPCI {
|
170 |
VirtIOPCIProxy parent_obj; |
171 |
VirtIONet vdev; |
172 |
}; |
173 |
|
174 |
void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev);
|
175 |
void virtio_pci_bus_new(VirtioBusState *bus, VirtIOPCIProxy *dev);
|
176 |
|
177 |
/* Virtio ABI version, if we increment this, we break the guest driver. */
|
178 |
#define VIRTIO_PCI_ABI_VERSION 0 |
179 |
|
180 |
#endif
|