]>
Commit | Line | Data |
---|---|---|
9fe1ebeb AK |
1 | /* |
2 | * Virtio PCI Bindings | |
3 | * | |
4 | * Copyright IBM, Corp. 2007 | |
5 | * Copyright (c) 2009 CodeSourcery | |
6 | * | |
7 | * Authors: | |
8 | * Anthony Liguori <[email protected]> | |
9 | * Paul Brook <[email protected]> | |
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 | ||
cf7c3f0c | 18 | #include "hw/pci/msi.h" |
83c9f4ca PB |
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" | |
e378e88d | 24 | #include "hw/virtio-balloon.h" |
83c9f4ca PB |
25 | #include "hw/virtio-bus.h" |
26 | #include "hw/9pfs/virtio-9p-device.h" | |
0a2acf5e | 27 | |
085bccb7 | 28 | typedef struct VirtIOPCIProxy VirtIOPCIProxy; |
653ced07 | 29 | typedef struct VirtIOBlkPCI VirtIOBlkPCI; |
bc7b90a0 | 30 | typedef struct VirtIOSCSIPCI VirtIOSCSIPCI; |
e378e88d | 31 | typedef struct VirtIOBalloonPCI VirtIOBalloonPCI; |
085bccb7 | 32 | |
0a2acf5e FK |
33 | /* virtio-pci-bus */ |
34 | ||
35 | typedef struct VirtioBusState VirtioPCIBusState; | |
36 | typedef struct VirtioBusClass VirtioPCIBusClass; | |
37 | ||
38 | #define TYPE_VIRTIO_PCI_BUS "virtio-pci-bus" | |
39 | #define VIRTIO_PCI_BUS(obj) \ | |
40 | OBJECT_CHECK(VirtioPCIBusState, (obj), TYPE_VIRTIO_PCI_BUS) | |
41 | #define VIRTIO_PCI_BUS_GET_CLASS(obj) \ | |
42 | OBJECT_GET_CLASS(VirtioPCIBusClass, obj, TYPE_VIRTIO_PCI_BUS) | |
43 | #define VIRTIO_PCI_BUS_CLASS(klass) \ | |
44 | OBJECT_CLASS_CHECK(VirtioPCIBusClass, klass, TYPE_VIRTIO_PCI_BUS) | |
9fe1ebeb | 45 | |
5745e38a AK |
46 | /* Performance improves when virtqueue kick processing is decoupled from the |
47 | * vcpu thread using ioeventfd for some devices. */ | |
48 | #define VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT 1 | |
49 | #define VIRTIO_PCI_FLAG_USE_IOEVENTFD (1 << VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT) | |
50 | ||
7d37d351 | 51 | typedef struct { |
774345f9 | 52 | MSIMessage msg; |
7d37d351 JK |
53 | int virq; |
54 | unsigned int users; | |
55 | } VirtIOIRQFD; | |
56 | ||
085bccb7 FK |
57 | /* |
58 | * virtio-pci: This is the PCIDevice which has a virtio-pci-bus. | |
59 | */ | |
60 | #define TYPE_VIRTIO_PCI "virtio-pci" | |
61 | #define VIRTIO_PCI_GET_CLASS(obj) \ | |
62 | OBJECT_GET_CLASS(VirtioPCIClass, obj, TYPE_VIRTIO_PCI) | |
63 | #define VIRTIO_PCI_CLASS(klass) \ | |
64 | OBJECT_CLASS_CHECK(VirtioPCIClass, klass, TYPE_VIRTIO_PCI) | |
65 | #define VIRTIO_PCI(obj) \ | |
66 | OBJECT_CHECK(VirtIOPCIProxy, (obj), TYPE_VIRTIO_PCI) | |
67 | ||
68 | typedef struct VirtioPCIClass { | |
69 | PCIDeviceClass parent_class; | |
70 | int (*init)(VirtIOPCIProxy *vpci_dev); | |
71 | } VirtioPCIClass; | |
72 | ||
73 | struct VirtIOPCIProxy { | |
9fe1ebeb AK |
74 | PCIDevice pci_dev; |
75 | VirtIODevice *vdev; | |
da146d0a | 76 | MemoryRegion bar; |
9fe1ebeb | 77 | uint32_t flags; |
9fe1ebeb AK |
78 | uint32_t class_code; |
79 | uint32_t nvectors; | |
9fe1ebeb AK |
80 | NICConf nic; |
81 | uint32_t host_features; | |
7e6b14df | 82 | #ifdef CONFIG_VIRTFS |
9fe1ebeb AK |
83 | V9fsConf fsconf; |
84 | #endif | |
85 | virtio_serial_conf serial; | |
86 | virtio_net_conf net; | |
16c915ba | 87 | VirtIORNGConf rng; |
9fe1ebeb AK |
88 | bool ioeventfd_disabled; |
89 | bool ioeventfd_started; | |
7d37d351 | 90 | VirtIOIRQFD *vector_irqfd; |
2d620f59 | 91 | int nvqs_with_notifiers; |
085bccb7 FK |
92 | VirtioBusState bus; |
93 | }; | |
9fe1ebeb | 94 | |
bc7b90a0 FK |
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 | ||
653ced07 FK |
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 | ||
e378e88d FK |
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 | ||
befeac45 | 133 | void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev); |
0a2acf5e | 134 | void virtio_pci_bus_new(VirtioBusState *bus, VirtIOPCIProxy *dev); |
befeac45 MT |
135 | |
136 | /* Virtio ABI version, if we increment this, we break the guest driver. */ | |
137 | #define VIRTIO_PCI_ABI_VERSION 0 | |
138 | ||
9fe1ebeb | 139 | #endif |