meson: convert hw/vfio
[qemu.git] / hw / s390x / virtio-ccw.h
1 /*
2 * virtio ccw target definitions
3 *
4 * Copyright 2012,2015 IBM Corp.
5 * Author(s): Cornelia Huck <cornelia.huck@de.ibm.com>
6 * Pierre Morel <pmorel@linux.vnet.ibm.com>
7 *
8 * This work is licensed under the terms of the GNU GPL, version 2 or (at
9 * your option) any later version. See the COPYING file in the top-level
10 * directory.
11 */
12
13 #ifndef HW_S390X_VIRTIO_CCW_H
14 #define HW_S390X_VIRTIO_CCW_H
15
16 #include "hw/virtio/virtio-blk.h"
17 #include "hw/virtio/virtio-net.h"
18 #include "hw/virtio/virtio-serial.h"
19 #include "hw/virtio/virtio-scsi.h"
20 #ifdef CONFIG_VHOST_SCSI
21 #include "hw/virtio/vhost-scsi.h"
22 #endif
23 #include "hw/virtio/virtio-balloon.h"
24 #include "hw/virtio/virtio-rng.h"
25 #include "hw/virtio/virtio-crypto.h"
26 #include "hw/virtio/virtio-bus.h"
27 #ifdef CONFIG_VHOST_VSOCK
28 #include "hw/virtio/vhost-vsock.h"
29 #endif /* CONFIG_VHOST_VSOCK */
30 #include "hw/virtio/virtio-gpu.h"
31 #include "hw/virtio/virtio-input.h"
32
33 #include "hw/s390x/s390_flic.h"
34 #include "hw/s390x/css.h"
35 #include "ccw-device.h"
36 #include "hw/s390x/css-bridge.h"
37
38 #define VIRTIO_CCW_CU_TYPE 0x3832
39 #define VIRTIO_CCW_CHPID_TYPE 0x32
40
41 #define CCW_CMD_SET_VQ 0x13
42 #define CCW_CMD_VDEV_RESET 0x33
43 #define CCW_CMD_READ_FEAT 0x12
44 #define CCW_CMD_WRITE_FEAT 0x11
45 #define CCW_CMD_READ_CONF 0x22
46 #define CCW_CMD_WRITE_CONF 0x21
47 #define CCW_CMD_WRITE_STATUS 0x31
48 #define CCW_CMD_SET_IND 0x43
49 #define CCW_CMD_SET_CONF_IND 0x53
50 #define CCW_CMD_READ_VQ_CONF 0x32
51 #define CCW_CMD_READ_STATUS 0x72
52 #define CCW_CMD_SET_IND_ADAPTER 0x73
53 #define CCW_CMD_SET_VIRTIO_REV 0x83
54
55 #define TYPE_VIRTIO_CCW_DEVICE "virtio-ccw-device"
56 #define VIRTIO_CCW_DEVICE(obj) \
57 OBJECT_CHECK(VirtioCcwDevice, (obj), TYPE_VIRTIO_CCW_DEVICE)
58 #define VIRTIO_CCW_DEVICE_CLASS(klass) \
59 OBJECT_CLASS_CHECK(VirtIOCCWDeviceClass, (klass), TYPE_VIRTIO_CCW_DEVICE)
60 #define VIRTIO_CCW_DEVICE_GET_CLASS(obj) \
61 OBJECT_GET_CLASS(VirtIOCCWDeviceClass, (obj), TYPE_VIRTIO_CCW_DEVICE)
62
63 typedef struct VirtioBusState VirtioCcwBusState;
64 typedef struct VirtioBusClass VirtioCcwBusClass;
65
66 #define TYPE_VIRTIO_CCW_BUS "virtio-ccw-bus"
67 #define VIRTIO_CCW_BUS(obj) \
68 OBJECT_CHECK(VirtioCcwBus, (obj), TYPE_VIRTIO_CCW_BUS)
69 #define VIRTIO_CCW_BUS_GET_CLASS(obj) \
70 OBJECT_CHECK(VirtioCcwBusState, (obj), TYPE_VIRTIO_CCW_BUS)
71 #define VIRTIO_CCW_BUS_CLASS(klass) \
72 OBJECT_CLASS_CHECK(VirtioCcwBusClass, klass, TYPE_VIRTIO_CCW_BUS)
73
74 typedef struct VirtioCcwDevice VirtioCcwDevice;
75
76 typedef struct VirtIOCCWDeviceClass {
77 CCWDeviceClass parent_class;
78 void (*realize)(VirtioCcwDevice *dev, Error **errp);
79 void (*unrealize)(VirtioCcwDevice *dev);
80 void (*parent_reset)(DeviceState *dev);
81 } VirtIOCCWDeviceClass;
82
83 /* Performance improves when virtqueue kick processing is decoupled from the
84 * vcpu thread using ioeventfd for some devices. */
85 #define VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT 1
86 #define VIRTIO_CCW_FLAG_USE_IOEVENTFD (1 << VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT)
87
88 struct VirtioCcwDevice {
89 CcwDevice parent_obj;
90 int revision;
91 uint32_t max_rev;
92 VirtioBusState bus;
93 uint32_t flags;
94 uint8_t thinint_isc;
95 AdapterRoutes routes;
96 /* Guest provided values: */
97 IndAddr *indicators;
98 IndAddr *indicators2;
99 IndAddr *summary_indicator;
100 uint64_t ind_bit;
101 bool force_revision_1;
102 };
103
104 /* The maximum virtio revision we support. */
105 #define VIRTIO_CCW_MAX_REV 2
106 static inline int virtio_ccw_rev_max(VirtioCcwDevice *dev)
107 {
108 return dev->max_rev;
109 }
110
111 /* virtio-scsi-ccw */
112
113 #define TYPE_VIRTIO_SCSI_CCW "virtio-scsi-ccw"
114 #define VIRTIO_SCSI_CCW(obj) \
115 OBJECT_CHECK(VirtIOSCSICcw, (obj), TYPE_VIRTIO_SCSI_CCW)
116
117 typedef struct VirtIOSCSICcw {
118 VirtioCcwDevice parent_obj;
119 VirtIOSCSI vdev;
120 } VirtIOSCSICcw;
121
122 #ifdef CONFIG_VHOST_SCSI
123 /* vhost-scsi-ccw */
124
125 #define TYPE_VHOST_SCSI_CCW "vhost-scsi-ccw"
126 #define VHOST_SCSI_CCW(obj) \
127 OBJECT_CHECK(VHostSCSICcw, (obj), TYPE_VHOST_SCSI_CCW)
128
129 typedef struct VHostSCSICcw {
130 VirtioCcwDevice parent_obj;
131 VHostSCSI vdev;
132 } VHostSCSICcw;
133 #endif
134
135 /* virtio-blk-ccw */
136
137 #define TYPE_VIRTIO_BLK_CCW "virtio-blk-ccw"
138 #define VIRTIO_BLK_CCW(obj) \
139 OBJECT_CHECK(VirtIOBlkCcw, (obj), TYPE_VIRTIO_BLK_CCW)
140
141 typedef struct VirtIOBlkCcw {
142 VirtioCcwDevice parent_obj;
143 VirtIOBlock vdev;
144 } VirtIOBlkCcw;
145
146 /* virtio-balloon-ccw */
147
148 #define TYPE_VIRTIO_BALLOON_CCW "virtio-balloon-ccw"
149 #define VIRTIO_BALLOON_CCW(obj) \
150 OBJECT_CHECK(VirtIOBalloonCcw, (obj), TYPE_VIRTIO_BALLOON_CCW)
151
152 typedef struct VirtIOBalloonCcw {
153 VirtioCcwDevice parent_obj;
154 VirtIOBalloon vdev;
155 } VirtIOBalloonCcw;
156
157 /* virtio-serial-ccw */
158
159 #define TYPE_VIRTIO_SERIAL_CCW "virtio-serial-ccw"
160 #define VIRTIO_SERIAL_CCW(obj) \
161 OBJECT_CHECK(VirtioSerialCcw, (obj), TYPE_VIRTIO_SERIAL_CCW)
162
163 typedef struct VirtioSerialCcw {
164 VirtioCcwDevice parent_obj;
165 VirtIOSerial vdev;
166 } VirtioSerialCcw;
167
168 /* virtio-net-ccw */
169
170 #define TYPE_VIRTIO_NET_CCW "virtio-net-ccw"
171 #define VIRTIO_NET_CCW(obj) \
172 OBJECT_CHECK(VirtIONetCcw, (obj), TYPE_VIRTIO_NET_CCW)
173
174 typedef struct VirtIONetCcw {
175 VirtioCcwDevice parent_obj;
176 VirtIONet vdev;
177 } VirtIONetCcw;
178
179 /* virtio-rng-ccw */
180
181 #define TYPE_VIRTIO_RNG_CCW "virtio-rng-ccw"
182 #define VIRTIO_RNG_CCW(obj) \
183 OBJECT_CHECK(VirtIORNGCcw, (obj), TYPE_VIRTIO_RNG_CCW)
184
185 typedef struct VirtIORNGCcw {
186 VirtioCcwDevice parent_obj;
187 VirtIORNG vdev;
188 } VirtIORNGCcw;
189
190 /* virtio-crypto-ccw */
191
192 #define TYPE_VIRTIO_CRYPTO_CCW "virtio-crypto-ccw"
193 #define VIRTIO_CRYPTO_CCW(obj) \
194 OBJECT_CHECK(VirtIOCryptoCcw, (obj), TYPE_VIRTIO_CRYPTO_CCW)
195
196 typedef struct VirtIOCryptoCcw {
197 VirtioCcwDevice parent_obj;
198 VirtIOCrypto vdev;
199 } VirtIOCryptoCcw;
200
201 VirtIODevice *virtio_ccw_get_vdev(SubchDev *sch);
202
203 #ifdef CONFIG_VIRTFS
204 #include "hw/9pfs/virtio-9p.h"
205
206 #define TYPE_VIRTIO_9P_CCW "virtio-9p-ccw"
207 #define VIRTIO_9P_CCW(obj) \
208 OBJECT_CHECK(V9fsCCWState, (obj), TYPE_VIRTIO_9P_CCW)
209
210 typedef struct V9fsCCWState {
211 VirtioCcwDevice parent_obj;
212 V9fsVirtioState vdev;
213 } V9fsCCWState;
214
215 #endif /* CONFIG_VIRTFS */
216
217 #ifdef CONFIG_VHOST_VSOCK
218 #define TYPE_VHOST_VSOCK_CCW "vhost-vsock-ccw"
219 #define VHOST_VSOCK_CCW(obj) \
220 OBJECT_CHECK(VHostVSockCCWState, (obj), TYPE_VHOST_VSOCK_CCW)
221
222 typedef struct VHostVSockCCWState {
223 VirtioCcwDevice parent_obj;
224 VHostVSock vdev;
225 } VHostVSockCCWState;
226
227 #endif /* CONFIG_VHOST_VSOCK */
228
229 #define TYPE_VIRTIO_GPU_CCW "virtio-gpu-ccw"
230 #define VIRTIO_GPU_CCW(obj) \
231 OBJECT_CHECK(VirtIOGPUCcw, (obj), TYPE_VIRTIO_GPU_CCW)
232
233 typedef struct VirtIOGPUCcw {
234 VirtioCcwDevice parent_obj;
235 VirtIOGPU vdev;
236 } VirtIOGPUCcw;
237
238 #define TYPE_VIRTIO_INPUT_CCW "virtio-input-ccw"
239 #define VIRTIO_INPUT_CCW(obj) \
240 OBJECT_CHECK(VirtIOInputCcw, (obj), TYPE_VIRTIO_INPUT_CCW)
241
242 typedef struct VirtIOInputCcw {
243 VirtioCcwDevice parent_obj;
244 VirtIOInput vdev;
245 } VirtIOInputCcw;
246
247 #define TYPE_VIRTIO_INPUT_HID_CCW "virtio-input-hid-ccw"
248 #define TYPE_VIRTIO_KEYBOARD_CCW "virtio-keyboard-ccw"
249 #define TYPE_VIRTIO_MOUSE_CCW "virtio-mouse-ccw"
250 #define TYPE_VIRTIO_TABLET_CCW "virtio-tablet-ccw"
251 #define VIRTIO_INPUT_HID_CCW(obj) \
252 OBJECT_CHECK(VirtIOInputHIDCcw, (obj), TYPE_VIRTIO_INPUT_HID_CCW)
253
254 typedef struct VirtIOInputHIDCcw {
255 VirtioCcwDevice parent_obj;
256 VirtIOInputHID vdev;
257 } VirtIOInputHIDCcw;
258
259 #endif