2 * virtio ccw target definitions
4 * Copyright 2012,2015 IBM Corp.
5 * Author(s): Cornelia Huck <cornelia.huck@de.ibm.com>
6 * Pierre Morel <pmorel@linux.vnet.ibm.com>
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
13 #ifndef HW_S390X_VIRTIO_CCW_H
14 #define HW_S390X_VIRTIO_CCW_H
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"
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"
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"
38 #define VIRTIO_CCW_CU_TYPE 0x3832
39 #define VIRTIO_CCW_CHPID_TYPE 0x32
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
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)
63 typedef struct VirtioBusState VirtioCcwBusState
;
64 typedef struct VirtioBusClass VirtioCcwBusClass
;
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)
74 typedef struct VirtioCcwDevice VirtioCcwDevice
;
76 typedef struct VirtIOCCWDeviceClass
{
77 CCWDeviceClass parent_class
;
78 void (*realize
)(VirtioCcwDevice
*dev
, Error
**errp
);
79 void (*unrealize
)(VirtioCcwDevice
*dev
, Error
**errp
);
80 void (*parent_reset
)(DeviceState
*dev
);
81 } VirtIOCCWDeviceClass
;
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)
88 struct VirtioCcwDevice
{
96 /* Guest provided values: */
99 IndAddr
*summary_indicator
;
101 bool force_revision_1
;
104 /* The maximum virtio revision we support. */
105 #define VIRTIO_CCW_MAX_REV 2
106 static inline int virtio_ccw_rev_max(VirtioCcwDevice
*dev
)
111 /* virtio-scsi-ccw */
113 #define TYPE_VIRTIO_SCSI_CCW "virtio-scsi-ccw"
114 #define VIRTIO_SCSI_CCW(obj) \
115 OBJECT_CHECK(VirtIOSCSICcw, (obj), TYPE_VIRTIO_SCSI_CCW)
117 typedef struct VirtIOSCSICcw
{
118 VirtioCcwDevice parent_obj
;
122 #ifdef CONFIG_VHOST_SCSI
125 #define TYPE_VHOST_SCSI_CCW "vhost-scsi-ccw"
126 #define VHOST_SCSI_CCW(obj) \
127 OBJECT_CHECK(VHostSCSICcw, (obj), TYPE_VHOST_SCSI_CCW)
129 typedef struct VHostSCSICcw
{
130 VirtioCcwDevice parent_obj
;
137 #define TYPE_VIRTIO_BLK_CCW "virtio-blk-ccw"
138 #define VIRTIO_BLK_CCW(obj) \
139 OBJECT_CHECK(VirtIOBlkCcw, (obj), TYPE_VIRTIO_BLK_CCW)
141 typedef struct VirtIOBlkCcw
{
142 VirtioCcwDevice parent_obj
;
146 /* virtio-balloon-ccw */
148 #define TYPE_VIRTIO_BALLOON_CCW "virtio-balloon-ccw"
149 #define VIRTIO_BALLOON_CCW(obj) \
150 OBJECT_CHECK(VirtIOBalloonCcw, (obj), TYPE_VIRTIO_BALLOON_CCW)
152 typedef struct VirtIOBalloonCcw
{
153 VirtioCcwDevice parent_obj
;
157 /* virtio-serial-ccw */
159 #define TYPE_VIRTIO_SERIAL_CCW "virtio-serial-ccw"
160 #define VIRTIO_SERIAL_CCW(obj) \
161 OBJECT_CHECK(VirtioSerialCcw, (obj), TYPE_VIRTIO_SERIAL_CCW)
163 typedef struct VirtioSerialCcw
{
164 VirtioCcwDevice parent_obj
;
170 #define TYPE_VIRTIO_NET_CCW "virtio-net-ccw"
171 #define VIRTIO_NET_CCW(obj) \
172 OBJECT_CHECK(VirtIONetCcw, (obj), TYPE_VIRTIO_NET_CCW)
174 typedef struct VirtIONetCcw
{
175 VirtioCcwDevice parent_obj
;
181 #define TYPE_VIRTIO_RNG_CCW "virtio-rng-ccw"
182 #define VIRTIO_RNG_CCW(obj) \
183 OBJECT_CHECK(VirtIORNGCcw, (obj), TYPE_VIRTIO_RNG_CCW)
185 typedef struct VirtIORNGCcw
{
186 VirtioCcwDevice parent_obj
;
190 /* virtio-crypto-ccw */
192 #define TYPE_VIRTIO_CRYPTO_CCW "virtio-crypto-ccw"
193 #define VIRTIO_CRYPTO_CCW(obj) \
194 OBJECT_CHECK(VirtIOCryptoCcw, (obj), TYPE_VIRTIO_CRYPTO_CCW)
196 typedef struct VirtIOCryptoCcw
{
197 VirtioCcwDevice parent_obj
;
201 VirtIODevice
*virtio_ccw_get_vdev(SubchDev
*sch
);
204 #include "hw/9pfs/virtio-9p.h"
206 #define TYPE_VIRTIO_9P_CCW "virtio-9p-ccw"
207 #define VIRTIO_9P_CCW(obj) \
208 OBJECT_CHECK(V9fsCCWState, (obj), TYPE_VIRTIO_9P_CCW)
210 typedef struct V9fsCCWState
{
211 VirtioCcwDevice parent_obj
;
212 V9fsVirtioState vdev
;
215 #endif /* CONFIG_VIRTFS */
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)
222 typedef struct VHostVSockCCWState
{
223 VirtioCcwDevice parent_obj
;
225 } VHostVSockCCWState
;
227 #endif /* CONFIG_VHOST_VSOCK */
229 #define TYPE_VIRTIO_GPU_CCW "virtio-gpu-ccw"
230 #define VIRTIO_GPU_CCW(obj) \
231 OBJECT_CHECK(VirtIOGPUCcw, (obj), TYPE_VIRTIO_GPU_CCW)
233 typedef struct VirtIOGPUCcw
{
234 VirtioCcwDevice parent_obj
;
238 #define TYPE_VIRTIO_INPUT_CCW "virtio-input-ccw"
239 #define VIRTIO_INPUT_CCW(obj) \
240 OBJECT_CHECK(VirtIOInputCcw, (obj), TYPE_VIRTIO_INPUT_CCW)
242 typedef struct VirtIOInputCcw
{
243 VirtioCcwDevice parent_obj
;
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)
254 typedef struct VirtIOInputHIDCcw
{
255 VirtioCcwDevice parent_obj
;