OSDN Git Service

virtio-serial-pci: switch to the new API.
[qmiga/qemu.git] / hw / virtio / 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/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
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;
33
34 /* virtio-pci-bus */
35
36 typedef struct VirtioBusState VirtioPCIBusState;
37 typedef struct VirtioBusClass VirtioPCIBusClass;
38
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)
46
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)
51
52 typedef struct {
53     MSIMessage msg;
54     int virq;
55     unsigned int users;
56 } VirtIOIRQFD;
57
58 /*
59  * virtio-pci: This is the PCIDevice which has a virtio-pci-bus.
60  */
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)
68
69 typedef struct VirtioPCIClass {
70     PCIDeviceClass parent_class;
71     int (*init)(VirtIOPCIProxy *vpci_dev);
72 } VirtioPCIClass;
73
74 struct VirtIOPCIProxy {
75     PCIDevice pci_dev;
76     VirtIODevice *vdev;
77     MemoryRegion bar;
78     uint32_t flags;
79     uint32_t class_code;
80     uint32_t nvectors;
81     NICConf nic;
82     uint32_t host_features;
83 #ifdef CONFIG_VIRTFS
84     V9fsConf fsconf;
85 #endif
86     virtio_net_conf net;
87     VirtIORNGConf rng;
88     bool ioeventfd_disabled;
89     bool ioeventfd_started;
90     VirtIOIRQFD *vector_irqfd;
91     int nvqs_with_notifiers;
92     VirtioBusState bus;
93 };
94
95
96 /*
97  * virtio-scsi-pci: This extends VirtioPCIProxy.
98  */
99 #define TYPE_VIRTIO_SCSI_PCI "virtio-scsi-pci"
100 #define VIRTIO_SCSI_PCI(obj) \
101         OBJECT_CHECK(VirtIOSCSIPCI, (obj), TYPE_VIRTIO_SCSI_PCI)
102
103 struct VirtIOSCSIPCI {
104     VirtIOPCIProxy parent_obj;
105     VirtIOSCSI vdev;
106 };
107
108 /*
109  * virtio-blk-pci: This extends VirtioPCIProxy.
110  */
111 #define TYPE_VIRTIO_BLK_PCI "virtio-blk-pci"
112 #define VIRTIO_BLK_PCI(obj) \
113         OBJECT_CHECK(VirtIOBlkPCI, (obj), TYPE_VIRTIO_BLK_PCI)
114
115 struct VirtIOBlkPCI {
116     VirtIOPCIProxy parent_obj;
117     VirtIOBlock vdev;
118     VirtIOBlkConf blk;
119 };
120
121 /*
122  * virtio-balloon-pci: This extends VirtioPCIProxy.
123  */
124 #define TYPE_VIRTIO_BALLOON_PCI "virtio-balloon-pci"
125 #define VIRTIO_BALLOON_PCI(obj) \
126         OBJECT_CHECK(VirtIOBalloonPCI, (obj), TYPE_VIRTIO_BALLOON_PCI)
127
128 struct VirtIOBalloonPCI {
129     VirtIOPCIProxy parent_obj;
130     VirtIOBalloon vdev;
131 };
132
133 /*
134  * virtio-serial-pci: This extends VirtioPCIProxy.
135  */
136 #define TYPE_VIRTIO_SERIAL_PCI "virtio-serial-pci"
137 #define VIRTIO_SERIAL_PCI(obj) \
138         OBJECT_CHECK(VirtIOSerialPCI, (obj), TYPE_VIRTIO_SERIAL_PCI)
139
140 struct VirtIOSerialPCI {
141     VirtIOPCIProxy parent_obj;
142     VirtIOSerial vdev;
143 };
144
145 void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev);
146 void virtio_pci_bus_new(VirtioBusState *bus, VirtIOPCIProxy *dev);
147
148 /* Virtio ABI version, if we increment this, we break the guest driver. */
149 #define VIRTIO_PCI_ABI_VERSION          0
150
151 #endif