xref: /openbmc/qemu/hw/s390x/virtio-ccw.h (revision b4b9a0e3)
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 #include "qom/object.h"
21 #ifdef CONFIG_VHOST_SCSI
22 #include "hw/virtio/vhost-scsi.h"
23 #endif
24 #include "hw/virtio/virtio-balloon.h"
25 #include "hw/virtio/virtio-rng.h"
26 #include "hw/virtio/virtio-crypto.h"
27 #include "hw/virtio/virtio-bus.h"
28 #ifdef CONFIG_VHOST_VSOCK
29 #include "hw/virtio/vhost-vsock.h"
30 #endif /* CONFIG_VHOST_VSOCK */
31 #include "hw/virtio/virtio-gpu.h"
32 #include "hw/virtio/virtio-input.h"
33 
34 #include "hw/s390x/s390_flic.h"
35 #include "hw/s390x/css.h"
36 #include "ccw-device.h"
37 #include "hw/s390x/css-bridge.h"
38 
39 #define VIRTIO_CCW_CU_TYPE 0x3832
40 #define VIRTIO_CCW_CHPID_TYPE 0x32
41 
42 #define CCW_CMD_SET_VQ       0x13
43 #define CCW_CMD_VDEV_RESET   0x33
44 #define CCW_CMD_READ_FEAT    0x12
45 #define CCW_CMD_WRITE_FEAT   0x11
46 #define CCW_CMD_READ_CONF    0x22
47 #define CCW_CMD_WRITE_CONF   0x21
48 #define CCW_CMD_WRITE_STATUS 0x31
49 #define CCW_CMD_SET_IND      0x43
50 #define CCW_CMD_SET_CONF_IND 0x53
51 #define CCW_CMD_READ_VQ_CONF 0x32
52 #define CCW_CMD_READ_STATUS  0x72
53 #define CCW_CMD_SET_IND_ADAPTER 0x73
54 #define CCW_CMD_SET_VIRTIO_REV 0x83
55 
56 #define TYPE_VIRTIO_CCW_DEVICE "virtio-ccw-device"
57 OBJECT_DECLARE_TYPE(VirtioCcwDevice, VirtIOCCWDeviceClass, VIRTIO_CCW_DEVICE)
58 
59 typedef struct VirtioBusState VirtioCcwBusState;
60 typedef struct VirtioBusClass VirtioCcwBusClass;
61 
62 #define TYPE_VIRTIO_CCW_BUS "virtio-ccw-bus"
63 DECLARE_OBJ_CHECKERS(VirtioCcwBusState, VirtioCcwBusClass,
64                      VIRTIO_CCW_BUS, TYPE_VIRTIO_CCW_BUS)
65 
66 /*
67  * modules can reference this symbol to avoid being loaded
68  * into system emulators without ccw support
69  */
70 extern bool have_virtio_ccw;
71 
72 struct VirtIOCCWDeviceClass {
73     CCWDeviceClass parent_class;
74     void (*realize)(VirtioCcwDevice *dev, Error **errp);
75     void (*unrealize)(VirtioCcwDevice *dev);
76     void (*parent_reset)(DeviceState *dev);
77 };
78 
79 /* Performance improves when virtqueue kick processing is decoupled from the
80  * vcpu thread using ioeventfd for some devices. */
81 #define VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT 1
82 #define VIRTIO_CCW_FLAG_USE_IOEVENTFD   (1 << VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT)
83 
84 struct VirtioCcwDevice {
85     CcwDevice parent_obj;
86     int revision;
87     uint32_t max_rev;
88     VirtioBusState bus;
89     uint32_t flags;
90     uint8_t thinint_isc;
91     AdapterRoutes routes;
92     /* Guest provided values: */
93     IndAddr *indicators;
94     IndAddr *indicators2;
95     IndAddr *summary_indicator;
96     uint64_t ind_bit;
97     bool force_revision_1;
98 };
99 
100 /* The maximum virtio revision we support. */
101 #define VIRTIO_CCW_MAX_REV 2
102 static inline int virtio_ccw_rev_max(VirtioCcwDevice *dev)
103 {
104     return dev->max_rev;
105 }
106 
107 /* virtio-scsi-ccw */
108 
109 #define TYPE_VIRTIO_SCSI_CCW "virtio-scsi-ccw"
110 OBJECT_DECLARE_SIMPLE_TYPE(VirtIOSCSICcw, VIRTIO_SCSI_CCW)
111 
112 struct VirtIOSCSICcw {
113     VirtioCcwDevice parent_obj;
114     VirtIOSCSI vdev;
115 };
116 
117 #ifdef CONFIG_VHOST_SCSI
118 /* vhost-scsi-ccw */
119 
120 #define TYPE_VHOST_SCSI_CCW "vhost-scsi-ccw"
121 OBJECT_DECLARE_SIMPLE_TYPE(VHostSCSICcw, VHOST_SCSI_CCW)
122 
123 struct VHostSCSICcw {
124     VirtioCcwDevice parent_obj;
125     VHostSCSI vdev;
126 };
127 #endif
128 
129 /* virtio-blk-ccw */
130 
131 #define TYPE_VIRTIO_BLK_CCW "virtio-blk-ccw"
132 OBJECT_DECLARE_SIMPLE_TYPE(VirtIOBlkCcw, VIRTIO_BLK_CCW)
133 
134 struct VirtIOBlkCcw {
135     VirtioCcwDevice parent_obj;
136     VirtIOBlock vdev;
137 };
138 
139 /* virtio-balloon-ccw */
140 
141 #define TYPE_VIRTIO_BALLOON_CCW "virtio-balloon-ccw"
142 OBJECT_DECLARE_SIMPLE_TYPE(VirtIOBalloonCcw, VIRTIO_BALLOON_CCW)
143 
144 struct VirtIOBalloonCcw {
145     VirtioCcwDevice parent_obj;
146     VirtIOBalloon vdev;
147 };
148 
149 /* virtio-serial-ccw */
150 
151 #define TYPE_VIRTIO_SERIAL_CCW "virtio-serial-ccw"
152 OBJECT_DECLARE_SIMPLE_TYPE(VirtioSerialCcw, VIRTIO_SERIAL_CCW)
153 
154 struct VirtioSerialCcw {
155     VirtioCcwDevice parent_obj;
156     VirtIOSerial vdev;
157 };
158 
159 /* virtio-net-ccw */
160 
161 #define TYPE_VIRTIO_NET_CCW "virtio-net-ccw"
162 OBJECT_DECLARE_SIMPLE_TYPE(VirtIONetCcw, VIRTIO_NET_CCW)
163 
164 struct VirtIONetCcw {
165     VirtioCcwDevice parent_obj;
166     VirtIONet vdev;
167 };
168 
169 /* virtio-rng-ccw */
170 
171 #define TYPE_VIRTIO_RNG_CCW "virtio-rng-ccw"
172 OBJECT_DECLARE_SIMPLE_TYPE(VirtIORNGCcw, VIRTIO_RNG_CCW)
173 
174 struct VirtIORNGCcw {
175     VirtioCcwDevice parent_obj;
176     VirtIORNG vdev;
177 };
178 
179 /* virtio-crypto-ccw */
180 
181 #define TYPE_VIRTIO_CRYPTO_CCW "virtio-crypto-ccw"
182 OBJECT_DECLARE_SIMPLE_TYPE(VirtIOCryptoCcw, VIRTIO_CRYPTO_CCW)
183 
184 struct VirtIOCryptoCcw {
185     VirtioCcwDevice parent_obj;
186     VirtIOCrypto vdev;
187 };
188 
189 VirtIODevice *virtio_ccw_get_vdev(SubchDev *sch);
190 
191 #ifdef CONFIG_VIRTFS
192 #include "hw/9pfs/virtio-9p.h"
193 
194 #define TYPE_VIRTIO_9P_CCW "virtio-9p-ccw"
195 OBJECT_DECLARE_SIMPLE_TYPE(V9fsCCWState, VIRTIO_9P_CCW)
196 
197 struct V9fsCCWState {
198     VirtioCcwDevice parent_obj;
199     V9fsVirtioState vdev;
200 };
201 
202 #endif /* CONFIG_VIRTFS */
203 
204 #ifdef CONFIG_VHOST_VSOCK
205 #define TYPE_VHOST_VSOCK_CCW "vhost-vsock-ccw"
206 OBJECT_DECLARE_SIMPLE_TYPE(VHostVSockCCWState, VHOST_VSOCK_CCW)
207 
208 struct VHostVSockCCWState {
209     VirtioCcwDevice parent_obj;
210     VHostVSock vdev;
211 };
212 
213 #endif /* CONFIG_VHOST_VSOCK */
214 
215 #define TYPE_VIRTIO_GPU_CCW "virtio-gpu-ccw"
216 OBJECT_DECLARE_SIMPLE_TYPE(VirtIOGPUCcw, VIRTIO_GPU_CCW)
217 
218 struct VirtIOGPUCcw {
219     VirtioCcwDevice parent_obj;
220     VirtIOGPU vdev;
221 };
222 
223 #define TYPE_VIRTIO_INPUT_CCW "virtio-input-ccw"
224 OBJECT_DECLARE_SIMPLE_TYPE(VirtIOInputCcw, VIRTIO_INPUT_CCW)
225 
226 struct VirtIOInputCcw {
227     VirtioCcwDevice parent_obj;
228     VirtIOInput vdev;
229 };
230 
231 #define TYPE_VIRTIO_INPUT_HID_CCW "virtio-input-hid-ccw"
232 #define TYPE_VIRTIO_KEYBOARD_CCW "virtio-keyboard-ccw"
233 #define TYPE_VIRTIO_MOUSE_CCW "virtio-mouse-ccw"
234 #define TYPE_VIRTIO_TABLET_CCW "virtio-tablet-ccw"
235 OBJECT_DECLARE_SIMPLE_TYPE(VirtIOInputHIDCcw, VIRTIO_INPUT_HID_CCW)
236 
237 struct VirtIOInputHIDCcw {
238     VirtioCcwDevice parent_obj;
239     VirtIOInputHID vdev;
240 };
241 
242 #endif
243