]> git.proxmox.com Git - mirror_qemu.git/blob - hw/s390x/virtio-ccw.c
hw/s390x: Move virtio-ccw-balloon code to a separate file
[mirror_qemu.git] / hw / s390x / virtio-ccw.c
1 /*
2 * virtio ccw target implementation
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 #include "qemu/osdep.h"
14 #include "qapi/error.h"
15 #include "hw/hw.h"
16 #include "sysemu/sysemu.h"
17 #include "sysemu/kvm.h"
18 #include "net/net.h"
19 #include "hw/virtio/virtio.h"
20 #include "hw/virtio/virtio-net.h"
21 #include "hw/sysbus.h"
22 #include "qemu/bitops.h"
23 #include "qemu/error-report.h"
24 #include "hw/virtio/virtio-access.h"
25 #include "hw/virtio/virtio-bus.h"
26 #include "hw/s390x/adapter.h"
27 #include "hw/s390x/s390_flic.h"
28
29 #include "hw/s390x/ioinst.h"
30 #include "hw/s390x/css.h"
31 #include "virtio-ccw.h"
32 #include "trace.h"
33 #include "hw/s390x/css-bridge.h"
34 #include "hw/s390x/s390-virtio-ccw.h"
35
36 #define NR_CLASSIC_INDICATOR_BITS 64
37
38 static int virtio_ccw_dev_post_load(void *opaque, int version_id)
39 {
40 VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(opaque);
41 CcwDevice *ccw_dev = CCW_DEVICE(dev);
42 CCWDeviceClass *ck = CCW_DEVICE_GET_CLASS(ccw_dev);
43
44 ccw_dev->sch->driver_data = dev;
45 if (ccw_dev->sch->thinint_active) {
46 dev->routes.adapter.adapter_id = css_get_adapter_id(
47 CSS_IO_ADAPTER_VIRTIO,
48 dev->thinint_isc);
49 }
50 /* Re-fill subch_id after loading the subchannel states.*/
51 if (ck->refill_ids) {
52 ck->refill_ids(ccw_dev);
53 }
54 return 0;
55 }
56
57 typedef struct VirtioCcwDeviceTmp {
58 VirtioCcwDevice *parent;
59 uint16_t config_vector;
60 } VirtioCcwDeviceTmp;
61
62 static int virtio_ccw_dev_tmp_pre_save(void *opaque)
63 {
64 VirtioCcwDeviceTmp *tmp = opaque;
65 VirtioCcwDevice *dev = tmp->parent;
66 VirtIODevice *vdev = virtio_bus_get_device(&dev->bus);
67
68 tmp->config_vector = vdev->config_vector;
69
70 return 0;
71 }
72
73 static int virtio_ccw_dev_tmp_post_load(void *opaque, int version_id)
74 {
75 VirtioCcwDeviceTmp *tmp = opaque;
76 VirtioCcwDevice *dev = tmp->parent;
77 VirtIODevice *vdev = virtio_bus_get_device(&dev->bus);
78
79 vdev->config_vector = tmp->config_vector;
80 return 0;
81 }
82
83 const VMStateDescription vmstate_virtio_ccw_dev_tmp = {
84 .name = "s390_virtio_ccw_dev_tmp",
85 .pre_save = virtio_ccw_dev_tmp_pre_save,
86 .post_load = virtio_ccw_dev_tmp_post_load,
87 .fields = (VMStateField[]) {
88 VMSTATE_UINT16(config_vector, VirtioCcwDeviceTmp),
89 VMSTATE_END_OF_LIST()
90 }
91 };
92
93 const VMStateDescription vmstate_virtio_ccw_dev = {
94 .name = "s390_virtio_ccw_dev",
95 .version_id = 1,
96 .minimum_version_id = 1,
97 .post_load = virtio_ccw_dev_post_load,
98 .fields = (VMStateField[]) {
99 VMSTATE_CCW_DEVICE(parent_obj, VirtioCcwDevice),
100 VMSTATE_PTR_TO_IND_ADDR(indicators, VirtioCcwDevice),
101 VMSTATE_PTR_TO_IND_ADDR(indicators2, VirtioCcwDevice),
102 VMSTATE_PTR_TO_IND_ADDR(summary_indicator, VirtioCcwDevice),
103 /*
104 * Ugly hack because VirtIODevice does not migrate itself.
105 * This also makes legacy via vmstate_save_state possible.
106 */
107 VMSTATE_WITH_TMP(VirtioCcwDevice, VirtioCcwDeviceTmp,
108 vmstate_virtio_ccw_dev_tmp),
109 VMSTATE_STRUCT(routes, VirtioCcwDevice, 1, vmstate_adapter_routes,
110 AdapterRoutes),
111 VMSTATE_UINT8(thinint_isc, VirtioCcwDevice),
112 VMSTATE_INT32(revision, VirtioCcwDevice),
113 VMSTATE_END_OF_LIST()
114 }
115 };
116
117 static void virtio_ccw_bus_new(VirtioBusState *bus, size_t bus_size,
118 VirtioCcwDevice *dev);
119
120 VirtIODevice *virtio_ccw_get_vdev(SubchDev *sch)
121 {
122 VirtIODevice *vdev = NULL;
123 VirtioCcwDevice *dev = sch->driver_data;
124
125 if (dev) {
126 vdev = virtio_bus_get_device(&dev->bus);
127 }
128 return vdev;
129 }
130
131 static void virtio_ccw_start_ioeventfd(VirtioCcwDevice *dev)
132 {
133 virtio_bus_start_ioeventfd(&dev->bus);
134 }
135
136 static void virtio_ccw_stop_ioeventfd(VirtioCcwDevice *dev)
137 {
138 virtio_bus_stop_ioeventfd(&dev->bus);
139 }
140
141 static bool virtio_ccw_ioeventfd_enabled(DeviceState *d)
142 {
143 VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d);
144
145 return (dev->flags & VIRTIO_CCW_FLAG_USE_IOEVENTFD) != 0;
146 }
147
148 static int virtio_ccw_ioeventfd_assign(DeviceState *d, EventNotifier *notifier,
149 int n, bool assign)
150 {
151 VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d);
152 CcwDevice *ccw_dev = CCW_DEVICE(dev);
153 SubchDev *sch = ccw_dev->sch;
154 uint32_t sch_id = (css_build_subchannel_id(sch) << 16) | sch->schid;
155
156 return s390_assign_subch_ioeventfd(notifier, sch_id, n, assign);
157 }
158
159 /* Communication blocks used by several channel commands. */
160 typedef struct VqInfoBlockLegacy {
161 uint64_t queue;
162 uint32_t align;
163 uint16_t index;
164 uint16_t num;
165 } QEMU_PACKED VqInfoBlockLegacy;
166
167 typedef struct VqInfoBlock {
168 uint64_t desc;
169 uint32_t res0;
170 uint16_t index;
171 uint16_t num;
172 uint64_t avail;
173 uint64_t used;
174 } QEMU_PACKED VqInfoBlock;
175
176 typedef struct VqConfigBlock {
177 uint16_t index;
178 uint16_t num_max;
179 } QEMU_PACKED VqConfigBlock;
180
181 typedef struct VirtioFeatDesc {
182 uint32_t features;
183 uint8_t index;
184 } QEMU_PACKED VirtioFeatDesc;
185
186 typedef struct VirtioThinintInfo {
187 hwaddr summary_indicator;
188 hwaddr device_indicator;
189 uint64_t ind_bit;
190 uint8_t isc;
191 } QEMU_PACKED VirtioThinintInfo;
192
193 typedef struct VirtioRevInfo {
194 uint16_t revision;
195 uint16_t length;
196 uint8_t data[0];
197 } QEMU_PACKED VirtioRevInfo;
198
199 /* Specify where the virtqueues for the subchannel are in guest memory. */
200 static int virtio_ccw_set_vqs(SubchDev *sch, VqInfoBlock *info,
201 VqInfoBlockLegacy *linfo)
202 {
203 VirtIODevice *vdev = virtio_ccw_get_vdev(sch);
204 uint16_t index = info ? info->index : linfo->index;
205 uint16_t num = info ? info->num : linfo->num;
206 uint64_t desc = info ? info->desc : linfo->queue;
207
208 if (index >= VIRTIO_QUEUE_MAX) {
209 return -EINVAL;
210 }
211
212 /* Current code in virtio.c relies on 4K alignment. */
213 if (linfo && desc && (linfo->align != 4096)) {
214 return -EINVAL;
215 }
216
217 if (!vdev) {
218 return -EINVAL;
219 }
220
221 if (info) {
222 virtio_queue_set_rings(vdev, index, desc, info->avail, info->used);
223 } else {
224 virtio_queue_set_addr(vdev, index, desc);
225 }
226 if (!desc) {
227 virtio_queue_set_vector(vdev, index, VIRTIO_NO_VECTOR);
228 } else {
229 if (info) {
230 /* virtio-1 allows changing the ring size. */
231 if (virtio_queue_get_max_num(vdev, index) < num) {
232 /* Fail if we exceed the maximum number. */
233 return -EINVAL;
234 }
235 virtio_queue_set_num(vdev, index, num);
236 } else if (virtio_queue_get_num(vdev, index) > num) {
237 /* Fail if we don't have a big enough queue. */
238 return -EINVAL;
239 }
240 /* We ignore possible increased num for legacy for compatibility. */
241 virtio_queue_set_vector(vdev, index, index);
242 }
243 /* tell notify handler in case of config change */
244 vdev->config_vector = VIRTIO_QUEUE_MAX;
245 return 0;
246 }
247
248 static void virtio_ccw_reset_virtio(VirtioCcwDevice *dev, VirtIODevice *vdev)
249 {
250 CcwDevice *ccw_dev = CCW_DEVICE(dev);
251
252 virtio_ccw_stop_ioeventfd(dev);
253 virtio_reset(vdev);
254 if (dev->indicators) {
255 release_indicator(&dev->routes.adapter, dev->indicators);
256 dev->indicators = NULL;
257 }
258 if (dev->indicators2) {
259 release_indicator(&dev->routes.adapter, dev->indicators2);
260 dev->indicators2 = NULL;
261 }
262 if (dev->summary_indicator) {
263 release_indicator(&dev->routes.adapter, dev->summary_indicator);
264 dev->summary_indicator = NULL;
265 }
266 ccw_dev->sch->thinint_active = false;
267 }
268
269 static int virtio_ccw_handle_set_vq(SubchDev *sch, CCW1 ccw, bool check_len,
270 bool is_legacy)
271 {
272 int ret;
273 VqInfoBlock info;
274 VqInfoBlockLegacy linfo;
275 size_t info_len = is_legacy ? sizeof(linfo) : sizeof(info);
276
277 if (check_len) {
278 if (ccw.count != info_len) {
279 return -EINVAL;
280 }
281 } else if (ccw.count < info_len) {
282 /* Can't execute command. */
283 return -EINVAL;
284 }
285 if (!ccw.cda) {
286 return -EFAULT;
287 }
288 if (is_legacy) {
289 ccw_dstream_read(&sch->cds, linfo);
290 be64_to_cpus(&linfo.queue);
291 be32_to_cpus(&linfo.align);
292 be16_to_cpus(&linfo.index);
293 be16_to_cpus(&linfo.num);
294 ret = virtio_ccw_set_vqs(sch, NULL, &linfo);
295 } else {
296 ccw_dstream_read(&sch->cds, info);
297 be64_to_cpus(&info.desc);
298 be16_to_cpus(&info.index);
299 be16_to_cpus(&info.num);
300 be64_to_cpus(&info.avail);
301 be64_to_cpus(&info.used);
302 ret = virtio_ccw_set_vqs(sch, &info, NULL);
303 }
304 sch->curr_status.scsw.count = 0;
305 return ret;
306 }
307
308 static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw)
309 {
310 int ret;
311 VirtioRevInfo revinfo;
312 uint8_t status;
313 VirtioFeatDesc features;
314 hwaddr indicators;
315 VqConfigBlock vq_config;
316 VirtioCcwDevice *dev = sch->driver_data;
317 VirtIODevice *vdev = virtio_ccw_get_vdev(sch);
318 bool check_len;
319 int len;
320 VirtioThinintInfo thinint;
321
322 if (!dev) {
323 return -EINVAL;
324 }
325
326 trace_virtio_ccw_interpret_ccw(sch->cssid, sch->ssid, sch->schid,
327 ccw.cmd_code);
328 check_len = !((ccw.flags & CCW_FLAG_SLI) && !(ccw.flags & CCW_FLAG_DC));
329
330 if (dev->force_revision_1 && dev->revision < 0 &&
331 ccw.cmd_code != CCW_CMD_SET_VIRTIO_REV) {
332 /*
333 * virtio-1 drivers must start with negotiating to a revision >= 1,
334 * so post a command reject for all other commands
335 */
336 return -ENOSYS;
337 }
338
339 /* Look at the command. */
340 switch (ccw.cmd_code) {
341 case CCW_CMD_SET_VQ:
342 ret = virtio_ccw_handle_set_vq(sch, ccw, check_len, dev->revision < 1);
343 break;
344 case CCW_CMD_VDEV_RESET:
345 virtio_ccw_reset_virtio(dev, vdev);
346 ret = 0;
347 break;
348 case CCW_CMD_READ_FEAT:
349 if (check_len) {
350 if (ccw.count != sizeof(features)) {
351 ret = -EINVAL;
352 break;
353 }
354 } else if (ccw.count < sizeof(features)) {
355 /* Can't execute command. */
356 ret = -EINVAL;
357 break;
358 }
359 if (!ccw.cda) {
360 ret = -EFAULT;
361 } else {
362 VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(vdev);
363
364 ccw_dstream_advance(&sch->cds, sizeof(features.features));
365 ccw_dstream_read(&sch->cds, features.index);
366 if (features.index == 0) {
367 if (dev->revision >= 1) {
368 /* Don't offer legacy features for modern devices. */
369 features.features = (uint32_t)
370 (vdev->host_features & ~vdc->legacy_features);
371 } else {
372 features.features = (uint32_t)vdev->host_features;
373 }
374 } else if ((features.index == 1) && (dev->revision >= 1)) {
375 /*
376 * Only offer feature bits beyond 31 if the guest has
377 * negotiated at least revision 1.
378 */
379 features.features = (uint32_t)(vdev->host_features >> 32);
380 } else {
381 /* Return zeroes if the guest supports more feature bits. */
382 features.features = 0;
383 }
384 ccw_dstream_rewind(&sch->cds);
385 cpu_to_le32s(&features.features);
386 ccw_dstream_write(&sch->cds, features.features);
387 sch->curr_status.scsw.count = ccw.count - sizeof(features);
388 ret = 0;
389 }
390 break;
391 case CCW_CMD_WRITE_FEAT:
392 if (check_len) {
393 if (ccw.count != sizeof(features)) {
394 ret = -EINVAL;
395 break;
396 }
397 } else if (ccw.count < sizeof(features)) {
398 /* Can't execute command. */
399 ret = -EINVAL;
400 break;
401 }
402 if (!ccw.cda) {
403 ret = -EFAULT;
404 } else {
405 ccw_dstream_read(&sch->cds, features);
406 le32_to_cpus(&features.features);
407 if (features.index == 0) {
408 virtio_set_features(vdev,
409 (vdev->guest_features & 0xffffffff00000000ULL) |
410 features.features);
411 } else if ((features.index == 1) && (dev->revision >= 1)) {
412 /*
413 * If the guest did not negotiate at least revision 1,
414 * we did not offer it any feature bits beyond 31. Such a
415 * guest passing us any bit here is therefore buggy.
416 */
417 virtio_set_features(vdev,
418 (vdev->guest_features & 0x00000000ffffffffULL) |
419 ((uint64_t)features.features << 32));
420 } else {
421 /*
422 * If the guest supports more feature bits, assert that it
423 * passes us zeroes for those we don't support.
424 */
425 if (features.features) {
426 qemu_log_mask(LOG_GUEST_ERROR,
427 "Guest bug: features[%i]=%x (expected 0)",
428 features.index, features.features);
429 /* XXX: do a unit check here? */
430 }
431 }
432 sch->curr_status.scsw.count = ccw.count - sizeof(features);
433 ret = 0;
434 }
435 break;
436 case CCW_CMD_READ_CONF:
437 if (check_len) {
438 if (ccw.count > vdev->config_len) {
439 ret = -EINVAL;
440 break;
441 }
442 }
443 len = MIN(ccw.count, vdev->config_len);
444 if (!ccw.cda) {
445 ret = -EFAULT;
446 } else {
447 virtio_bus_get_vdev_config(&dev->bus, vdev->config);
448 ccw_dstream_write_buf(&sch->cds, vdev->config, len);
449 sch->curr_status.scsw.count = ccw.count - len;
450 ret = 0;
451 }
452 break;
453 case CCW_CMD_WRITE_CONF:
454 if (check_len) {
455 if (ccw.count > vdev->config_len) {
456 ret = -EINVAL;
457 break;
458 }
459 }
460 len = MIN(ccw.count, vdev->config_len);
461 if (!ccw.cda) {
462 ret = -EFAULT;
463 } else {
464 ret = ccw_dstream_read_buf(&sch->cds, vdev->config, len);
465 if (!ret) {
466 virtio_bus_set_vdev_config(&dev->bus, vdev->config);
467 sch->curr_status.scsw.count = ccw.count - len;
468 }
469 }
470 break;
471 case CCW_CMD_READ_STATUS:
472 if (check_len) {
473 if (ccw.count != sizeof(status)) {
474 ret = -EINVAL;
475 break;
476 }
477 } else if (ccw.count < sizeof(status)) {
478 /* Can't execute command. */
479 ret = -EINVAL;
480 break;
481 }
482 if (!ccw.cda) {
483 ret = -EFAULT;
484 } else {
485 address_space_stb(&address_space_memory, ccw.cda, vdev->status,
486 MEMTXATTRS_UNSPECIFIED, NULL);
487 sch->curr_status.scsw.count = ccw.count - sizeof(vdev->status);
488 ret = 0;
489 }
490 break;
491 case CCW_CMD_WRITE_STATUS:
492 if (check_len) {
493 if (ccw.count != sizeof(status)) {
494 ret = -EINVAL;
495 break;
496 }
497 } else if (ccw.count < sizeof(status)) {
498 /* Can't execute command. */
499 ret = -EINVAL;
500 break;
501 }
502 if (!ccw.cda) {
503 ret = -EFAULT;
504 } else {
505 ccw_dstream_read(&sch->cds, status);
506 if (!(status & VIRTIO_CONFIG_S_DRIVER_OK)) {
507 virtio_ccw_stop_ioeventfd(dev);
508 }
509 if (virtio_set_status(vdev, status) == 0) {
510 if (vdev->status == 0) {
511 virtio_ccw_reset_virtio(dev, vdev);
512 }
513 if (status & VIRTIO_CONFIG_S_DRIVER_OK) {
514 virtio_ccw_start_ioeventfd(dev);
515 }
516 sch->curr_status.scsw.count = ccw.count - sizeof(status);
517 ret = 0;
518 } else {
519 /* Trigger a command reject. */
520 ret = -ENOSYS;
521 }
522 }
523 break;
524 case CCW_CMD_SET_IND:
525 if (check_len) {
526 if (ccw.count != sizeof(indicators)) {
527 ret = -EINVAL;
528 break;
529 }
530 } else if (ccw.count < sizeof(indicators)) {
531 /* Can't execute command. */
532 ret = -EINVAL;
533 break;
534 }
535 if (sch->thinint_active) {
536 /* Trigger a command reject. */
537 ret = -ENOSYS;
538 break;
539 }
540 if (virtio_get_num_queues(vdev) > NR_CLASSIC_INDICATOR_BITS) {
541 /* More queues than indicator bits --> trigger a reject */
542 ret = -ENOSYS;
543 break;
544 }
545 if (!ccw.cda) {
546 ret = -EFAULT;
547 } else {
548 ccw_dstream_read(&sch->cds, indicators);
549 be64_to_cpus(&indicators);
550 dev->indicators = get_indicator(indicators, sizeof(uint64_t));
551 sch->curr_status.scsw.count = ccw.count - sizeof(indicators);
552 ret = 0;
553 }
554 break;
555 case CCW_CMD_SET_CONF_IND:
556 if (check_len) {
557 if (ccw.count != sizeof(indicators)) {
558 ret = -EINVAL;
559 break;
560 }
561 } else if (ccw.count < sizeof(indicators)) {
562 /* Can't execute command. */
563 ret = -EINVAL;
564 break;
565 }
566 if (!ccw.cda) {
567 ret = -EFAULT;
568 } else {
569 ccw_dstream_read(&sch->cds, indicators);
570 be64_to_cpus(&indicators);
571 dev->indicators2 = get_indicator(indicators, sizeof(uint64_t));
572 sch->curr_status.scsw.count = ccw.count - sizeof(indicators);
573 ret = 0;
574 }
575 break;
576 case CCW_CMD_READ_VQ_CONF:
577 if (check_len) {
578 if (ccw.count != sizeof(vq_config)) {
579 ret = -EINVAL;
580 break;
581 }
582 } else if (ccw.count < sizeof(vq_config)) {
583 /* Can't execute command. */
584 ret = -EINVAL;
585 break;
586 }
587 if (!ccw.cda) {
588 ret = -EFAULT;
589 } else {
590 ccw_dstream_read(&sch->cds, vq_config.index);
591 be16_to_cpus(&vq_config.index);
592 if (vq_config.index >= VIRTIO_QUEUE_MAX) {
593 ret = -EINVAL;
594 break;
595 }
596 vq_config.num_max = virtio_queue_get_num(vdev,
597 vq_config.index);
598 cpu_to_be16s(&vq_config.num_max);
599 ccw_dstream_write(&sch->cds, vq_config.num_max);
600 sch->curr_status.scsw.count = ccw.count - sizeof(vq_config);
601 ret = 0;
602 }
603 break;
604 case CCW_CMD_SET_IND_ADAPTER:
605 if (check_len) {
606 if (ccw.count != sizeof(thinint)) {
607 ret = -EINVAL;
608 break;
609 }
610 } else if (ccw.count < sizeof(thinint)) {
611 /* Can't execute command. */
612 ret = -EINVAL;
613 break;
614 }
615 if (!ccw.cda) {
616 ret = -EFAULT;
617 } else if (dev->indicators && !sch->thinint_active) {
618 /* Trigger a command reject. */
619 ret = -ENOSYS;
620 } else {
621 if (ccw_dstream_read(&sch->cds, thinint)) {
622 ret = -EFAULT;
623 } else {
624 be64_to_cpus(&thinint.ind_bit);
625 be64_to_cpus(&thinint.summary_indicator);
626 be64_to_cpus(&thinint.device_indicator);
627
628 dev->summary_indicator =
629 get_indicator(thinint.summary_indicator, sizeof(uint8_t));
630 dev->indicators =
631 get_indicator(thinint.device_indicator,
632 thinint.ind_bit / 8 + 1);
633 dev->thinint_isc = thinint.isc;
634 dev->routes.adapter.ind_offset = thinint.ind_bit;
635 dev->routes.adapter.summary_offset = 7;
636 dev->routes.adapter.adapter_id = css_get_adapter_id(
637 CSS_IO_ADAPTER_VIRTIO,
638 dev->thinint_isc);
639 sch->thinint_active = ((dev->indicators != NULL) &&
640 (dev->summary_indicator != NULL));
641 sch->curr_status.scsw.count = ccw.count - sizeof(thinint);
642 ret = 0;
643 }
644 }
645 break;
646 case CCW_CMD_SET_VIRTIO_REV:
647 len = sizeof(revinfo);
648 if (ccw.count < len) {
649 ret = -EINVAL;
650 break;
651 }
652 if (!ccw.cda) {
653 ret = -EFAULT;
654 break;
655 }
656 ccw_dstream_read_buf(&sch->cds, &revinfo, 4);
657 be16_to_cpus(&revinfo.revision);
658 be16_to_cpus(&revinfo.length);
659 if (ccw.count < len + revinfo.length ||
660 (check_len && ccw.count > len + revinfo.length)) {
661 ret = -EINVAL;
662 break;
663 }
664 /*
665 * Once we start to support revisions with additional data, we'll
666 * need to fetch it here. Nothing to do for now, though.
667 */
668 if (dev->revision >= 0 ||
669 revinfo.revision > virtio_ccw_rev_max(dev) ||
670 (dev->force_revision_1 && !revinfo.revision)) {
671 ret = -ENOSYS;
672 break;
673 }
674 ret = 0;
675 dev->revision = revinfo.revision;
676 break;
677 default:
678 ret = -ENOSYS;
679 break;
680 }
681 return ret;
682 }
683
684 static void virtio_sch_disable_cb(SubchDev *sch)
685 {
686 VirtioCcwDevice *dev = sch->driver_data;
687
688 dev->revision = -1;
689 }
690
691 static void virtio_ccw_device_realize(VirtioCcwDevice *dev, Error **errp)
692 {
693 VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_GET_CLASS(dev);
694 CcwDevice *ccw_dev = CCW_DEVICE(dev);
695 CCWDeviceClass *ck = CCW_DEVICE_GET_CLASS(ccw_dev);
696 SubchDev *sch;
697 Error *err = NULL;
698
699 sch = css_create_sch(ccw_dev->devno, errp);
700 if (!sch) {
701 return;
702 }
703 if (!virtio_ccw_rev_max(dev) && dev->force_revision_1) {
704 error_setg(&err, "Invalid value of property max_rev "
705 "(is %d expected >= 1)", virtio_ccw_rev_max(dev));
706 goto out_err;
707 }
708
709 sch->driver_data = dev;
710 sch->ccw_cb = virtio_ccw_cb;
711 sch->disable_cb = virtio_sch_disable_cb;
712 sch->id.reserved = 0xff;
713 sch->id.cu_type = VIRTIO_CCW_CU_TYPE;
714 sch->do_subchannel_work = do_subchannel_work_virtual;
715 ccw_dev->sch = sch;
716 dev->indicators = NULL;
717 dev->revision = -1;
718 css_sch_build_virtual_schib(sch, 0, VIRTIO_CCW_CHPID_TYPE);
719
720 trace_virtio_ccw_new_device(
721 sch->cssid, sch->ssid, sch->schid, sch->devno,
722 ccw_dev->devno.valid ? "user-configured" : "auto-configured");
723
724 if (kvm_enabled() && !kvm_eventfds_enabled()) {
725 dev->flags &= ~VIRTIO_CCW_FLAG_USE_IOEVENTFD;
726 }
727
728 if (k->realize) {
729 k->realize(dev, &err);
730 if (err) {
731 goto out_err;
732 }
733 }
734
735 ck->realize(ccw_dev, &err);
736 if (err) {
737 goto out_err;
738 }
739
740 return;
741
742 out_err:
743 error_propagate(errp, err);
744 css_subch_assign(sch->cssid, sch->ssid, sch->schid, sch->devno, NULL);
745 ccw_dev->sch = NULL;
746 g_free(sch);
747 }
748
749 static void virtio_ccw_device_unrealize(VirtioCcwDevice *dev, Error **errp)
750 {
751 VirtIOCCWDeviceClass *dc = VIRTIO_CCW_DEVICE_GET_CLASS(dev);
752 CcwDevice *ccw_dev = CCW_DEVICE(dev);
753 SubchDev *sch = ccw_dev->sch;
754
755 if (dc->unrealize) {
756 dc->unrealize(dev, errp);
757 }
758
759 if (sch) {
760 css_subch_assign(sch->cssid, sch->ssid, sch->schid, sch->devno, NULL);
761 g_free(sch);
762 ccw_dev->sch = NULL;
763 }
764 if (dev->indicators) {
765 release_indicator(&dev->routes.adapter, dev->indicators);
766 dev->indicators = NULL;
767 }
768 }
769
770 static void virtio_ccw_net_realize(VirtioCcwDevice *ccw_dev, Error **errp)
771 {
772 DeviceState *qdev = DEVICE(ccw_dev);
773 VirtIONetCcw *dev = VIRTIO_NET_CCW(ccw_dev);
774 DeviceState *vdev = DEVICE(&dev->vdev);
775
776 virtio_net_set_netclient_name(&dev->vdev, qdev->id,
777 object_get_typename(OBJECT(qdev)));
778 qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus));
779 object_property_set_bool(OBJECT(vdev), true, "realized", errp);
780 }
781
782 static void virtio_ccw_net_instance_init(Object *obj)
783 {
784 VirtIONetCcw *dev = VIRTIO_NET_CCW(obj);
785
786 virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
787 TYPE_VIRTIO_NET);
788 object_property_add_alias(obj, "bootindex", OBJECT(&dev->vdev),
789 "bootindex", &error_abort);
790 }
791
792 static void virtio_ccw_blk_realize(VirtioCcwDevice *ccw_dev, Error **errp)
793 {
794 VirtIOBlkCcw *dev = VIRTIO_BLK_CCW(ccw_dev);
795 DeviceState *vdev = DEVICE(&dev->vdev);
796
797 qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus));
798 object_property_set_bool(OBJECT(vdev), true, "realized", errp);
799 }
800
801 static void virtio_ccw_blk_instance_init(Object *obj)
802 {
803 VirtIOBlkCcw *dev = VIRTIO_BLK_CCW(obj);
804
805 virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
806 TYPE_VIRTIO_BLK);
807 object_property_add_alias(obj, "bootindex", OBJECT(&dev->vdev),
808 "bootindex", &error_abort);
809 }
810
811 static void virtio_ccw_scsi_realize(VirtioCcwDevice *ccw_dev, Error **errp)
812 {
813 VirtIOSCSICcw *dev = VIRTIO_SCSI_CCW(ccw_dev);
814 DeviceState *vdev = DEVICE(&dev->vdev);
815 DeviceState *qdev = DEVICE(ccw_dev);
816 char *bus_name;
817
818 /*
819 * For command line compatibility, this sets the virtio-scsi-device bus
820 * name as before.
821 */
822 if (qdev->id) {
823 bus_name = g_strdup_printf("%s.0", qdev->id);
824 virtio_device_set_child_bus_name(VIRTIO_DEVICE(vdev), bus_name);
825 g_free(bus_name);
826 }
827
828 qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus));
829 object_property_set_bool(OBJECT(vdev), true, "realized", errp);
830 }
831
832 static void virtio_ccw_scsi_instance_init(Object *obj)
833 {
834 VirtIOSCSICcw *dev = VIRTIO_SCSI_CCW(obj);
835
836 virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
837 TYPE_VIRTIO_SCSI);
838 }
839
840 #ifdef CONFIG_VHOST_SCSI
841 static void vhost_ccw_scsi_realize(VirtioCcwDevice *ccw_dev, Error **errp)
842 {
843 VHostSCSICcw *dev = VHOST_SCSI_CCW(ccw_dev);
844 DeviceState *vdev = DEVICE(&dev->vdev);
845
846 qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus));
847 object_property_set_bool(OBJECT(vdev), true, "realized", errp);
848 }
849
850 static void vhost_ccw_scsi_instance_init(Object *obj)
851 {
852 VHostSCSICcw *dev = VHOST_SCSI_CCW(obj);
853
854 virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
855 TYPE_VHOST_SCSI);
856 }
857 #endif
858
859 static void virtio_ccw_rng_realize(VirtioCcwDevice *ccw_dev, Error **errp)
860 {
861 VirtIORNGCcw *dev = VIRTIO_RNG_CCW(ccw_dev);
862 DeviceState *vdev = DEVICE(&dev->vdev);
863 Error *err = NULL;
864
865 qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus));
866 object_property_set_bool(OBJECT(vdev), true, "realized", &err);
867 if (err) {
868 error_propagate(errp, err);
869 return;
870 }
871
872 object_property_set_link(OBJECT(dev),
873 OBJECT(dev->vdev.conf.rng), "rng",
874 NULL);
875 }
876
877 static void virtio_ccw_crypto_realize(VirtioCcwDevice *ccw_dev, Error **errp)
878 {
879 VirtIOCryptoCcw *dev = VIRTIO_CRYPTO_CCW(ccw_dev);
880 DeviceState *vdev = DEVICE(&dev->vdev);
881 Error *err = NULL;
882
883 qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus));
884 object_property_set_bool(OBJECT(vdev), true, "realized", &err);
885 if (err) {
886 error_propagate(errp, err);
887 return;
888 }
889
890 object_property_set_link(OBJECT(vdev),
891 OBJECT(dev->vdev.conf.cryptodev), "cryptodev",
892 NULL);
893 }
894
895 static void virtio_ccw_gpu_realize(VirtioCcwDevice *ccw_dev, Error **errp)
896 {
897 VirtIOGPUCcw *dev = VIRTIO_GPU_CCW(ccw_dev);
898 DeviceState *vdev = DEVICE(&dev->vdev);
899
900 qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus));
901 object_property_set_bool(OBJECT(vdev), true, "realized", errp);
902 }
903
904 static void virtio_ccw_input_realize(VirtioCcwDevice *ccw_dev, Error **errp)
905 {
906 VirtIOInputCcw *dev = VIRTIO_INPUT_CCW(ccw_dev);
907 DeviceState *vdev = DEVICE(&dev->vdev);
908
909 qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus));
910 object_property_set_bool(OBJECT(vdev), true, "realized", errp);
911 }
912
913 /* DeviceState to VirtioCcwDevice. Note: used on datapath,
914 * be careful and test performance if you change this.
915 */
916 static inline VirtioCcwDevice *to_virtio_ccw_dev_fast(DeviceState *d)
917 {
918 CcwDevice *ccw_dev = to_ccw_dev_fast(d);
919
920 return container_of(ccw_dev, VirtioCcwDevice, parent_obj);
921 }
922
923 static uint8_t virtio_set_ind_atomic(SubchDev *sch, uint64_t ind_loc,
924 uint8_t to_be_set)
925 {
926 uint8_t ind_old, ind_new;
927 hwaddr len = 1;
928 uint8_t *ind_addr;
929
930 ind_addr = cpu_physical_memory_map(ind_loc, &len, 1);
931 if (!ind_addr) {
932 error_report("%s(%x.%x.%04x): unable to access indicator",
933 __func__, sch->cssid, sch->ssid, sch->schid);
934 return -1;
935 }
936 do {
937 ind_old = *ind_addr;
938 ind_new = ind_old | to_be_set;
939 } while (atomic_cmpxchg(ind_addr, ind_old, ind_new) != ind_old);
940 trace_virtio_ccw_set_ind(ind_loc, ind_old, ind_new);
941 cpu_physical_memory_unmap(ind_addr, len, 1, len);
942
943 return ind_old;
944 }
945
946 static void virtio_ccw_notify(DeviceState *d, uint16_t vector)
947 {
948 VirtioCcwDevice *dev = to_virtio_ccw_dev_fast(d);
949 CcwDevice *ccw_dev = to_ccw_dev_fast(d);
950 SubchDev *sch = ccw_dev->sch;
951 uint64_t indicators;
952
953 if (vector == VIRTIO_NO_VECTOR) {
954 return;
955 }
956 /*
957 * vector < VIRTIO_QUEUE_MAX: notification for a virtqueue
958 * vector == VIRTIO_QUEUE_MAX: configuration change notification
959 * bits beyond that are unused and should never be notified for
960 */
961 assert(vector <= VIRTIO_QUEUE_MAX);
962
963 if (vector < VIRTIO_QUEUE_MAX) {
964 if (!dev->indicators) {
965 return;
966 }
967 if (sch->thinint_active) {
968 /*
969 * In the adapter interrupt case, indicators points to a
970 * memory area that may be (way) larger than 64 bit and
971 * ind_bit indicates the start of the indicators in a big
972 * endian notation.
973 */
974 uint64_t ind_bit = dev->routes.adapter.ind_offset;
975
976 virtio_set_ind_atomic(sch, dev->indicators->addr +
977 (ind_bit + vector) / 8,
978 0x80 >> ((ind_bit + vector) % 8));
979 if (!virtio_set_ind_atomic(sch, dev->summary_indicator->addr,
980 0x01)) {
981 css_adapter_interrupt(CSS_IO_ADAPTER_VIRTIO, dev->thinint_isc);
982 }
983 } else {
984 assert(vector < NR_CLASSIC_INDICATOR_BITS);
985 indicators = address_space_ldq(&address_space_memory,
986 dev->indicators->addr,
987 MEMTXATTRS_UNSPECIFIED,
988 NULL);
989 indicators |= 1ULL << vector;
990 address_space_stq(&address_space_memory, dev->indicators->addr,
991 indicators, MEMTXATTRS_UNSPECIFIED, NULL);
992 css_conditional_io_interrupt(sch);
993 }
994 } else {
995 if (!dev->indicators2) {
996 return;
997 }
998 indicators = address_space_ldq(&address_space_memory,
999 dev->indicators2->addr,
1000 MEMTXATTRS_UNSPECIFIED,
1001 NULL);
1002 indicators |= 1ULL;
1003 address_space_stq(&address_space_memory, dev->indicators2->addr,
1004 indicators, MEMTXATTRS_UNSPECIFIED, NULL);
1005 css_conditional_io_interrupt(sch);
1006 }
1007 }
1008
1009 static void virtio_ccw_reset(DeviceState *d)
1010 {
1011 VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d);
1012 VirtIODevice *vdev = virtio_bus_get_device(&dev->bus);
1013 VirtIOCCWDeviceClass *vdc = VIRTIO_CCW_DEVICE_GET_CLASS(dev);
1014
1015 virtio_ccw_reset_virtio(dev, vdev);
1016 if (vdc->parent_reset) {
1017 vdc->parent_reset(d);
1018 }
1019 }
1020
1021 static void virtio_ccw_vmstate_change(DeviceState *d, bool running)
1022 {
1023 VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d);
1024
1025 if (running) {
1026 virtio_ccw_start_ioeventfd(dev);
1027 } else {
1028 virtio_ccw_stop_ioeventfd(dev);
1029 }
1030 }
1031
1032 static bool virtio_ccw_query_guest_notifiers(DeviceState *d)
1033 {
1034 CcwDevice *dev = CCW_DEVICE(d);
1035
1036 return !!(dev->sch->curr_status.pmcw.flags & PMCW_FLAGS_MASK_ENA);
1037 }
1038
1039 static int virtio_ccw_get_mappings(VirtioCcwDevice *dev)
1040 {
1041 int r;
1042 CcwDevice *ccw_dev = CCW_DEVICE(dev);
1043
1044 if (!ccw_dev->sch->thinint_active) {
1045 return -EINVAL;
1046 }
1047
1048 r = map_indicator(&dev->routes.adapter, dev->summary_indicator);
1049 if (r) {
1050 return r;
1051 }
1052 r = map_indicator(&dev->routes.adapter, dev->indicators);
1053 if (r) {
1054 return r;
1055 }
1056 dev->routes.adapter.summary_addr = dev->summary_indicator->map;
1057 dev->routes.adapter.ind_addr = dev->indicators->map;
1058
1059 return 0;
1060 }
1061
1062 static int virtio_ccw_setup_irqroutes(VirtioCcwDevice *dev, int nvqs)
1063 {
1064 int i;
1065 VirtIODevice *vdev = virtio_bus_get_device(&dev->bus);
1066 int ret;
1067 S390FLICState *fs = s390_get_flic();
1068 S390FLICStateClass *fsc = s390_get_flic_class(fs);
1069
1070 ret = virtio_ccw_get_mappings(dev);
1071 if (ret) {
1072 return ret;
1073 }
1074 for (i = 0; i < nvqs; i++) {
1075 if (!virtio_queue_get_num(vdev, i)) {
1076 break;
1077 }
1078 }
1079 dev->routes.num_routes = i;
1080 return fsc->add_adapter_routes(fs, &dev->routes);
1081 }
1082
1083 static void virtio_ccw_release_irqroutes(VirtioCcwDevice *dev, int nvqs)
1084 {
1085 S390FLICState *fs = s390_get_flic();
1086 S390FLICStateClass *fsc = s390_get_flic_class(fs);
1087
1088 fsc->release_adapter_routes(fs, &dev->routes);
1089 }
1090
1091 static int virtio_ccw_add_irqfd(VirtioCcwDevice *dev, int n)
1092 {
1093 VirtIODevice *vdev = virtio_bus_get_device(&dev->bus);
1094 VirtQueue *vq = virtio_get_queue(vdev, n);
1095 EventNotifier *notifier = virtio_queue_get_guest_notifier(vq);
1096
1097 return kvm_irqchip_add_irqfd_notifier_gsi(kvm_state, notifier, NULL,
1098 dev->routes.gsi[n]);
1099 }
1100
1101 static void virtio_ccw_remove_irqfd(VirtioCcwDevice *dev, int n)
1102 {
1103 VirtIODevice *vdev = virtio_bus_get_device(&dev->bus);
1104 VirtQueue *vq = virtio_get_queue(vdev, n);
1105 EventNotifier *notifier = virtio_queue_get_guest_notifier(vq);
1106 int ret;
1107
1108 ret = kvm_irqchip_remove_irqfd_notifier_gsi(kvm_state, notifier,
1109 dev->routes.gsi[n]);
1110 assert(ret == 0);
1111 }
1112
1113 static int virtio_ccw_set_guest_notifier(VirtioCcwDevice *dev, int n,
1114 bool assign, bool with_irqfd)
1115 {
1116 VirtIODevice *vdev = virtio_bus_get_device(&dev->bus);
1117 VirtQueue *vq = virtio_get_queue(vdev, n);
1118 EventNotifier *notifier = virtio_queue_get_guest_notifier(vq);
1119 VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
1120
1121 if (assign) {
1122 int r = event_notifier_init(notifier, 0);
1123
1124 if (r < 0) {
1125 return r;
1126 }
1127 virtio_queue_set_guest_notifier_fd_handler(vq, true, with_irqfd);
1128 if (with_irqfd) {
1129 r = virtio_ccw_add_irqfd(dev, n);
1130 if (r) {
1131 virtio_queue_set_guest_notifier_fd_handler(vq, false,
1132 with_irqfd);
1133 return r;
1134 }
1135 }
1136 /*
1137 * We do not support individual masking for channel devices, so we
1138 * need to manually trigger any guest masking callbacks here.
1139 */
1140 if (k->guest_notifier_mask && vdev->use_guest_notifier_mask) {
1141 k->guest_notifier_mask(vdev, n, false);
1142 }
1143 /* get lost events and re-inject */
1144 if (k->guest_notifier_pending &&
1145 k->guest_notifier_pending(vdev, n)) {
1146 event_notifier_set(notifier);
1147 }
1148 } else {
1149 if (k->guest_notifier_mask && vdev->use_guest_notifier_mask) {
1150 k->guest_notifier_mask(vdev, n, true);
1151 }
1152 if (with_irqfd) {
1153 virtio_ccw_remove_irqfd(dev, n);
1154 }
1155 virtio_queue_set_guest_notifier_fd_handler(vq, false, with_irqfd);
1156 event_notifier_cleanup(notifier);
1157 }
1158 return 0;
1159 }
1160
1161 static int virtio_ccw_set_guest_notifiers(DeviceState *d, int nvqs,
1162 bool assigned)
1163 {
1164 VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d);
1165 VirtIODevice *vdev = virtio_bus_get_device(&dev->bus);
1166 CcwDevice *ccw_dev = CCW_DEVICE(d);
1167 bool with_irqfd = ccw_dev->sch->thinint_active && kvm_irqfds_enabled();
1168 int r, n;
1169
1170 if (with_irqfd && assigned) {
1171 /* irq routes need to be set up before assigning irqfds */
1172 r = virtio_ccw_setup_irqroutes(dev, nvqs);
1173 if (r < 0) {
1174 goto irqroute_error;
1175 }
1176 }
1177 for (n = 0; n < nvqs; n++) {
1178 if (!virtio_queue_get_num(vdev, n)) {
1179 break;
1180 }
1181 r = virtio_ccw_set_guest_notifier(dev, n, assigned, with_irqfd);
1182 if (r < 0) {
1183 goto assign_error;
1184 }
1185 }
1186 if (with_irqfd && !assigned) {
1187 /* release irq routes after irqfds have been released */
1188 virtio_ccw_release_irqroutes(dev, nvqs);
1189 }
1190 return 0;
1191
1192 assign_error:
1193 while (--n >= 0) {
1194 virtio_ccw_set_guest_notifier(dev, n, !assigned, false);
1195 }
1196 irqroute_error:
1197 if (with_irqfd && assigned) {
1198 virtio_ccw_release_irqroutes(dev, nvqs);
1199 }
1200 return r;
1201 }
1202
1203 static void virtio_ccw_save_queue(DeviceState *d, int n, QEMUFile *f)
1204 {
1205 VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d);
1206 VirtIODevice *vdev = virtio_bus_get_device(&dev->bus);
1207
1208 qemu_put_be16(f, virtio_queue_vector(vdev, n));
1209 }
1210
1211 static int virtio_ccw_load_queue(DeviceState *d, int n, QEMUFile *f)
1212 {
1213 VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d);
1214 VirtIODevice *vdev = virtio_bus_get_device(&dev->bus);
1215 uint16_t vector;
1216
1217 qemu_get_be16s(f, &vector);
1218 virtio_queue_set_vector(vdev, n , vector);
1219
1220 return 0;
1221 }
1222
1223 static void virtio_ccw_save_config(DeviceState *d, QEMUFile *f)
1224 {
1225 VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d);
1226 vmstate_save_state(f, &vmstate_virtio_ccw_dev, dev, NULL);
1227 }
1228
1229 static int virtio_ccw_load_config(DeviceState *d, QEMUFile *f)
1230 {
1231 VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d);
1232 return vmstate_load_state(f, &vmstate_virtio_ccw_dev, dev, 1);
1233 }
1234
1235 static void virtio_ccw_pre_plugged(DeviceState *d, Error **errp)
1236 {
1237 VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d);
1238 VirtIODevice *vdev = virtio_bus_get_device(&dev->bus);
1239
1240 if (dev->max_rev >= 1) {
1241 virtio_add_feature(&vdev->host_features, VIRTIO_F_VERSION_1);
1242 }
1243 }
1244
1245 /* This is called by virtio-bus just after the device is plugged. */
1246 static void virtio_ccw_device_plugged(DeviceState *d, Error **errp)
1247 {
1248 VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d);
1249 VirtIODevice *vdev = virtio_bus_get_device(&dev->bus);
1250 CcwDevice *ccw_dev = CCW_DEVICE(d);
1251 SubchDev *sch = ccw_dev->sch;
1252 int n = virtio_get_num_queues(vdev);
1253 S390FLICState *flic = s390_get_flic();
1254
1255 if (!virtio_has_feature(vdev->host_features, VIRTIO_F_VERSION_1)) {
1256 dev->max_rev = 0;
1257 }
1258
1259 if (virtio_get_num_queues(vdev) > VIRTIO_QUEUE_MAX) {
1260 error_setg(errp, "The number of virtqueues %d "
1261 "exceeds virtio limit %d", n,
1262 VIRTIO_QUEUE_MAX);
1263 return;
1264 }
1265 if (virtio_get_num_queues(vdev) > flic->adapter_routes_max_batch) {
1266 error_setg(errp, "The number of virtqueues %d "
1267 "exceeds flic adapter route limit %d", n,
1268 flic->adapter_routes_max_batch);
1269 return;
1270 }
1271
1272 sch->id.cu_model = virtio_bus_get_vdev_id(&dev->bus);
1273
1274
1275 css_generate_sch_crws(sch->cssid, sch->ssid, sch->schid,
1276 d->hotplugged, 1);
1277 }
1278
1279 static void virtio_ccw_device_unplugged(DeviceState *d)
1280 {
1281 VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d);
1282
1283 virtio_ccw_stop_ioeventfd(dev);
1284 }
1285 /**************** Virtio-ccw Bus Device Descriptions *******************/
1286
1287 static Property virtio_ccw_net_properties[] = {
1288 DEFINE_PROP_BIT("ioeventfd", VirtioCcwDevice, flags,
1289 VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT, true),
1290 DEFINE_PROP_UINT32("max_revision", VirtioCcwDevice, max_rev,
1291 VIRTIO_CCW_MAX_REV),
1292 DEFINE_PROP_END_OF_LIST(),
1293 };
1294
1295 static void virtio_ccw_net_class_init(ObjectClass *klass, void *data)
1296 {
1297 DeviceClass *dc = DEVICE_CLASS(klass);
1298 VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass);
1299
1300 k->realize = virtio_ccw_net_realize;
1301 dc->props = virtio_ccw_net_properties;
1302 set_bit(DEVICE_CATEGORY_NETWORK, dc->categories);
1303 }
1304
1305 static const TypeInfo virtio_ccw_net = {
1306 .name = TYPE_VIRTIO_NET_CCW,
1307 .parent = TYPE_VIRTIO_CCW_DEVICE,
1308 .instance_size = sizeof(VirtIONetCcw),
1309 .instance_init = virtio_ccw_net_instance_init,
1310 .class_init = virtio_ccw_net_class_init,
1311 };
1312
1313 static Property virtio_ccw_blk_properties[] = {
1314 DEFINE_PROP_BIT("ioeventfd", VirtioCcwDevice, flags,
1315 VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT, true),
1316 DEFINE_PROP_UINT32("max_revision", VirtioCcwDevice, max_rev,
1317 VIRTIO_CCW_MAX_REV),
1318 DEFINE_PROP_END_OF_LIST(),
1319 };
1320
1321 static void virtio_ccw_blk_class_init(ObjectClass *klass, void *data)
1322 {
1323 DeviceClass *dc = DEVICE_CLASS(klass);
1324 VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass);
1325
1326 k->realize = virtio_ccw_blk_realize;
1327 dc->props = virtio_ccw_blk_properties;
1328 set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
1329 }
1330
1331 static const TypeInfo virtio_ccw_blk = {
1332 .name = TYPE_VIRTIO_BLK_CCW,
1333 .parent = TYPE_VIRTIO_CCW_DEVICE,
1334 .instance_size = sizeof(VirtIOBlkCcw),
1335 .instance_init = virtio_ccw_blk_instance_init,
1336 .class_init = virtio_ccw_blk_class_init,
1337 };
1338
1339 static Property virtio_ccw_scsi_properties[] = {
1340 DEFINE_PROP_BIT("ioeventfd", VirtioCcwDevice, flags,
1341 VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT, true),
1342 DEFINE_PROP_UINT32("max_revision", VirtioCcwDevice, max_rev,
1343 VIRTIO_CCW_MAX_REV),
1344 DEFINE_PROP_END_OF_LIST(),
1345 };
1346
1347 static void virtio_ccw_scsi_class_init(ObjectClass *klass, void *data)
1348 {
1349 DeviceClass *dc = DEVICE_CLASS(klass);
1350 VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass);
1351
1352 k->realize = virtio_ccw_scsi_realize;
1353 dc->props = virtio_ccw_scsi_properties;
1354 set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
1355 }
1356
1357 static const TypeInfo virtio_ccw_scsi = {
1358 .name = TYPE_VIRTIO_SCSI_CCW,
1359 .parent = TYPE_VIRTIO_CCW_DEVICE,
1360 .instance_size = sizeof(VirtIOSCSICcw),
1361 .instance_init = virtio_ccw_scsi_instance_init,
1362 .class_init = virtio_ccw_scsi_class_init,
1363 };
1364
1365 #ifdef CONFIG_VHOST_SCSI
1366 static Property vhost_ccw_scsi_properties[] = {
1367 DEFINE_PROP_UINT32("max_revision", VirtioCcwDevice, max_rev,
1368 VIRTIO_CCW_MAX_REV),
1369 DEFINE_PROP_END_OF_LIST(),
1370 };
1371
1372 static void vhost_ccw_scsi_class_init(ObjectClass *klass, void *data)
1373 {
1374 DeviceClass *dc = DEVICE_CLASS(klass);
1375 VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass);
1376
1377 k->realize = vhost_ccw_scsi_realize;
1378 dc->props = vhost_ccw_scsi_properties;
1379 set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
1380 }
1381
1382 static const TypeInfo vhost_ccw_scsi = {
1383 .name = TYPE_VHOST_SCSI_CCW,
1384 .parent = TYPE_VIRTIO_CCW_DEVICE,
1385 .instance_size = sizeof(VHostSCSICcw),
1386 .instance_init = vhost_ccw_scsi_instance_init,
1387 .class_init = vhost_ccw_scsi_class_init,
1388 };
1389 #endif
1390
1391 static void virtio_ccw_rng_instance_init(Object *obj)
1392 {
1393 VirtIORNGCcw *dev = VIRTIO_RNG_CCW(obj);
1394
1395 virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
1396 TYPE_VIRTIO_RNG);
1397 }
1398
1399 static Property virtio_ccw_rng_properties[] = {
1400 DEFINE_PROP_BIT("ioeventfd", VirtioCcwDevice, flags,
1401 VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT, true),
1402 DEFINE_PROP_UINT32("max_revision", VirtioCcwDevice, max_rev,
1403 VIRTIO_CCW_MAX_REV),
1404 DEFINE_PROP_END_OF_LIST(),
1405 };
1406
1407 static void virtio_ccw_rng_class_init(ObjectClass *klass, void *data)
1408 {
1409 DeviceClass *dc = DEVICE_CLASS(klass);
1410 VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass);
1411
1412 k->realize = virtio_ccw_rng_realize;
1413 dc->props = virtio_ccw_rng_properties;
1414 set_bit(DEVICE_CATEGORY_MISC, dc->categories);
1415 }
1416
1417 static const TypeInfo virtio_ccw_rng = {
1418 .name = TYPE_VIRTIO_RNG_CCW,
1419 .parent = TYPE_VIRTIO_CCW_DEVICE,
1420 .instance_size = sizeof(VirtIORNGCcw),
1421 .instance_init = virtio_ccw_rng_instance_init,
1422 .class_init = virtio_ccw_rng_class_init,
1423 };
1424
1425 static Property virtio_ccw_crypto_properties[] = {
1426 DEFINE_PROP_BIT("ioeventfd", VirtioCcwDevice, flags,
1427 VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT, true),
1428 DEFINE_PROP_UINT32("max_revision", VirtioCcwDevice, max_rev,
1429 VIRTIO_CCW_MAX_REV),
1430 DEFINE_PROP_END_OF_LIST(),
1431 };
1432
1433 static void virtio_ccw_crypto_instance_init(Object *obj)
1434 {
1435 VirtIOCryptoCcw *dev = VIRTIO_CRYPTO_CCW(obj);
1436 VirtioCcwDevice *ccw_dev = VIRTIO_CCW_DEVICE(obj);
1437
1438 ccw_dev->force_revision_1 = true;
1439 virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
1440 TYPE_VIRTIO_CRYPTO);
1441 }
1442
1443 static void virtio_ccw_crypto_class_init(ObjectClass *klass, void *data)
1444 {
1445 DeviceClass *dc = DEVICE_CLASS(klass);
1446 VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass);
1447
1448 k->realize = virtio_ccw_crypto_realize;
1449 dc->props = virtio_ccw_crypto_properties;
1450 set_bit(DEVICE_CATEGORY_MISC, dc->categories);
1451 }
1452
1453 static const TypeInfo virtio_ccw_crypto = {
1454 .name = TYPE_VIRTIO_CRYPTO_CCW,
1455 .parent = TYPE_VIRTIO_CCW_DEVICE,
1456 .instance_size = sizeof(VirtIOCryptoCcw),
1457 .instance_init = virtio_ccw_crypto_instance_init,
1458 .class_init = virtio_ccw_crypto_class_init,
1459 };
1460
1461 static Property virtio_ccw_gpu_properties[] = {
1462 DEFINE_PROP_BIT("ioeventfd", VirtioCcwDevice, flags,
1463 VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT, true),
1464 DEFINE_PROP_UINT32("max_revision", VirtioCcwDevice, max_rev,
1465 VIRTIO_CCW_MAX_REV),
1466 DEFINE_PROP_END_OF_LIST(),
1467 };
1468
1469 static void virtio_ccw_gpu_instance_init(Object *obj)
1470 {
1471 VirtIOGPUCcw *dev = VIRTIO_GPU_CCW(obj);
1472 VirtioCcwDevice *ccw_dev = VIRTIO_CCW_DEVICE(obj);
1473
1474 ccw_dev->force_revision_1 = true;
1475 virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
1476 TYPE_VIRTIO_GPU);
1477 }
1478
1479 static void virtio_ccw_gpu_class_init(ObjectClass *klass, void *data)
1480 {
1481 DeviceClass *dc = DEVICE_CLASS(klass);
1482 VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass);
1483
1484 k->realize = virtio_ccw_gpu_realize;
1485 dc->props = virtio_ccw_gpu_properties;
1486 dc->hotpluggable = false;
1487 set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories);
1488 }
1489
1490 static const TypeInfo virtio_ccw_gpu = {
1491 .name = TYPE_VIRTIO_GPU_CCW,
1492 .parent = TYPE_VIRTIO_CCW_DEVICE,
1493 .instance_size = sizeof(VirtIOGPUCcw),
1494 .instance_init = virtio_ccw_gpu_instance_init,
1495 .class_init = virtio_ccw_gpu_class_init,
1496 };
1497
1498 static Property virtio_ccw_input_properties[] = {
1499 DEFINE_PROP_BIT("ioeventfd", VirtioCcwDevice, flags,
1500 VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT, true),
1501 DEFINE_PROP_UINT32("max_revision", VirtioCcwDevice, max_rev,
1502 VIRTIO_CCW_MAX_REV),
1503 DEFINE_PROP_END_OF_LIST(),
1504 };
1505
1506 static void virtio_ccw_input_class_init(ObjectClass *klass, void *data)
1507 {
1508 DeviceClass *dc = DEVICE_CLASS(klass);
1509 VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass);
1510
1511 k->realize = virtio_ccw_input_realize;
1512 dc->props = virtio_ccw_input_properties;
1513 set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
1514 }
1515
1516 static void virtio_ccw_keyboard_instance_init(Object *obj)
1517 {
1518 VirtIOInputHIDCcw *dev = VIRTIO_INPUT_HID_CCW(obj);
1519 VirtioCcwDevice *ccw_dev = VIRTIO_CCW_DEVICE(obj);
1520
1521 ccw_dev->force_revision_1 = true;
1522 virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
1523 TYPE_VIRTIO_KEYBOARD);
1524 }
1525
1526 static void virtio_ccw_mouse_instance_init(Object *obj)
1527 {
1528 VirtIOInputHIDCcw *dev = VIRTIO_INPUT_HID_CCW(obj);
1529 VirtioCcwDevice *ccw_dev = VIRTIO_CCW_DEVICE(obj);
1530
1531 ccw_dev->force_revision_1 = true;
1532 virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
1533 TYPE_VIRTIO_MOUSE);
1534 }
1535
1536 static void virtio_ccw_tablet_instance_init(Object *obj)
1537 {
1538 VirtIOInputHIDCcw *dev = VIRTIO_INPUT_HID_CCW(obj);
1539 VirtioCcwDevice *ccw_dev = VIRTIO_CCW_DEVICE(obj);
1540
1541 ccw_dev->force_revision_1 = true;
1542 virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
1543 TYPE_VIRTIO_TABLET);
1544 }
1545
1546 static const TypeInfo virtio_ccw_input = {
1547 .name = TYPE_VIRTIO_INPUT_CCW,
1548 .parent = TYPE_VIRTIO_CCW_DEVICE,
1549 .instance_size = sizeof(VirtIOInputCcw),
1550 .class_init = virtio_ccw_input_class_init,
1551 .abstract = true,
1552 };
1553
1554 static const TypeInfo virtio_ccw_input_hid = {
1555 .name = TYPE_VIRTIO_INPUT_HID_CCW,
1556 .parent = TYPE_VIRTIO_INPUT_CCW,
1557 .instance_size = sizeof(VirtIOInputHIDCcw),
1558 .abstract = true,
1559 };
1560
1561 static const TypeInfo virtio_ccw_keyboard = {
1562 .name = TYPE_VIRTIO_KEYBOARD_CCW,
1563 .parent = TYPE_VIRTIO_INPUT_HID_CCW,
1564 .instance_size = sizeof(VirtIOInputHIDCcw),
1565 .instance_init = virtio_ccw_keyboard_instance_init,
1566 };
1567
1568 static const TypeInfo virtio_ccw_mouse = {
1569 .name = TYPE_VIRTIO_MOUSE_CCW,
1570 .parent = TYPE_VIRTIO_INPUT_HID_CCW,
1571 .instance_size = sizeof(VirtIOInputHIDCcw),
1572 .instance_init = virtio_ccw_mouse_instance_init,
1573 };
1574
1575 static const TypeInfo virtio_ccw_tablet = {
1576 .name = TYPE_VIRTIO_TABLET_CCW,
1577 .parent = TYPE_VIRTIO_INPUT_HID_CCW,
1578 .instance_size = sizeof(VirtIOInputHIDCcw),
1579 .instance_init = virtio_ccw_tablet_instance_init,
1580 };
1581
1582 static void virtio_ccw_busdev_realize(DeviceState *dev, Error **errp)
1583 {
1584 VirtioCcwDevice *_dev = (VirtioCcwDevice *)dev;
1585
1586 virtio_ccw_bus_new(&_dev->bus, sizeof(_dev->bus), _dev);
1587 virtio_ccw_device_realize(_dev, errp);
1588 }
1589
1590 static void virtio_ccw_busdev_unrealize(DeviceState *dev, Error **errp)
1591 {
1592 VirtioCcwDevice *_dev = (VirtioCcwDevice *)dev;
1593
1594 virtio_ccw_device_unrealize(_dev, errp);
1595 }
1596
1597 static void virtio_ccw_busdev_unplug(HotplugHandler *hotplug_dev,
1598 DeviceState *dev, Error **errp)
1599 {
1600 VirtioCcwDevice *_dev = to_virtio_ccw_dev_fast(dev);
1601
1602 virtio_ccw_stop_ioeventfd(_dev);
1603 }
1604
1605 static void virtio_ccw_device_class_init(ObjectClass *klass, void *data)
1606 {
1607 DeviceClass *dc = DEVICE_CLASS(klass);
1608 CCWDeviceClass *k = CCW_DEVICE_CLASS(dc);
1609 VirtIOCCWDeviceClass *vdc = VIRTIO_CCW_DEVICE_CLASS(klass);
1610
1611 k->unplug = virtio_ccw_busdev_unplug;
1612 dc->realize = virtio_ccw_busdev_realize;
1613 dc->unrealize = virtio_ccw_busdev_unrealize;
1614 dc->bus_type = TYPE_VIRTUAL_CSS_BUS;
1615 device_class_set_parent_reset(dc, virtio_ccw_reset, &vdc->parent_reset);
1616 }
1617
1618 static const TypeInfo virtio_ccw_device_info = {
1619 .name = TYPE_VIRTIO_CCW_DEVICE,
1620 .parent = TYPE_CCW_DEVICE,
1621 .instance_size = sizeof(VirtioCcwDevice),
1622 .class_init = virtio_ccw_device_class_init,
1623 .class_size = sizeof(VirtIOCCWDeviceClass),
1624 .abstract = true,
1625 };
1626
1627 /* virtio-ccw-bus */
1628
1629 static void virtio_ccw_bus_new(VirtioBusState *bus, size_t bus_size,
1630 VirtioCcwDevice *dev)
1631 {
1632 DeviceState *qdev = DEVICE(dev);
1633 char virtio_bus_name[] = "virtio-bus";
1634
1635 qbus_create_inplace(bus, bus_size, TYPE_VIRTIO_CCW_BUS,
1636 qdev, virtio_bus_name);
1637 }
1638
1639 static void virtio_ccw_bus_class_init(ObjectClass *klass, void *data)
1640 {
1641 VirtioBusClass *k = VIRTIO_BUS_CLASS(klass);
1642 BusClass *bus_class = BUS_CLASS(klass);
1643
1644 bus_class->max_dev = 1;
1645 k->notify = virtio_ccw_notify;
1646 k->vmstate_change = virtio_ccw_vmstate_change;
1647 k->query_guest_notifiers = virtio_ccw_query_guest_notifiers;
1648 k->set_guest_notifiers = virtio_ccw_set_guest_notifiers;
1649 k->save_queue = virtio_ccw_save_queue;
1650 k->load_queue = virtio_ccw_load_queue;
1651 k->save_config = virtio_ccw_save_config;
1652 k->load_config = virtio_ccw_load_config;
1653 k->pre_plugged = virtio_ccw_pre_plugged;
1654 k->device_plugged = virtio_ccw_device_plugged;
1655 k->device_unplugged = virtio_ccw_device_unplugged;
1656 k->ioeventfd_enabled = virtio_ccw_ioeventfd_enabled;
1657 k->ioeventfd_assign = virtio_ccw_ioeventfd_assign;
1658 }
1659
1660 static const TypeInfo virtio_ccw_bus_info = {
1661 .name = TYPE_VIRTIO_CCW_BUS,
1662 .parent = TYPE_VIRTIO_BUS,
1663 .instance_size = sizeof(VirtioCcwBusState),
1664 .class_init = virtio_ccw_bus_class_init,
1665 };
1666
1667 #ifdef CONFIG_VIRTFS
1668 static Property virtio_ccw_9p_properties[] = {
1669 DEFINE_PROP_BIT("ioeventfd", VirtioCcwDevice, flags,
1670 VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT, true),
1671 DEFINE_PROP_UINT32("max_revision", VirtioCcwDevice, max_rev,
1672 VIRTIO_CCW_MAX_REV),
1673 DEFINE_PROP_END_OF_LIST(),
1674 };
1675
1676 static void virtio_ccw_9p_realize(VirtioCcwDevice *ccw_dev, Error **errp)
1677 {
1678 V9fsCCWState *dev = VIRTIO_9P_CCW(ccw_dev);
1679 DeviceState *vdev = DEVICE(&dev->vdev);
1680
1681 qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus));
1682 object_property_set_bool(OBJECT(vdev), true, "realized", errp);
1683 }
1684
1685 static void virtio_ccw_9p_class_init(ObjectClass *klass, void *data)
1686 {
1687 DeviceClass *dc = DEVICE_CLASS(klass);
1688 VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass);
1689
1690 k->realize = virtio_ccw_9p_realize;
1691 dc->props = virtio_ccw_9p_properties;
1692 set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
1693 }
1694
1695 static void virtio_ccw_9p_instance_init(Object *obj)
1696 {
1697 V9fsCCWState *dev = VIRTIO_9P_CCW(obj);
1698
1699 virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
1700 TYPE_VIRTIO_9P);
1701 }
1702
1703 static const TypeInfo virtio_ccw_9p_info = {
1704 .name = TYPE_VIRTIO_9P_CCW,
1705 .parent = TYPE_VIRTIO_CCW_DEVICE,
1706 .instance_size = sizeof(V9fsCCWState),
1707 .instance_init = virtio_ccw_9p_instance_init,
1708 .class_init = virtio_ccw_9p_class_init,
1709 };
1710 #endif
1711
1712 #ifdef CONFIG_VHOST_VSOCK
1713
1714 static Property vhost_vsock_ccw_properties[] = {
1715 DEFINE_PROP_UINT32("max_revision", VirtioCcwDevice, max_rev,
1716 VIRTIO_CCW_MAX_REV),
1717 DEFINE_PROP_END_OF_LIST(),
1718 };
1719
1720 static void vhost_vsock_ccw_realize(VirtioCcwDevice *ccw_dev, Error **errp)
1721 {
1722 VHostVSockCCWState *dev = VHOST_VSOCK_CCW(ccw_dev);
1723 DeviceState *vdev = DEVICE(&dev->vdev);
1724
1725 qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus));
1726 object_property_set_bool(OBJECT(vdev), true, "realized", errp);
1727 }
1728
1729 static void vhost_vsock_ccw_class_init(ObjectClass *klass, void *data)
1730 {
1731 DeviceClass *dc = DEVICE_CLASS(klass);
1732 VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass);
1733
1734 k->realize = vhost_vsock_ccw_realize;
1735 set_bit(DEVICE_CATEGORY_MISC, dc->categories);
1736 dc->props = vhost_vsock_ccw_properties;
1737 }
1738
1739 static void vhost_vsock_ccw_instance_init(Object *obj)
1740 {
1741 VHostVSockCCWState *dev = VHOST_VSOCK_CCW(obj);
1742
1743 virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
1744 TYPE_VHOST_VSOCK);
1745 }
1746
1747 static const TypeInfo vhost_vsock_ccw_info = {
1748 .name = TYPE_VHOST_VSOCK_CCW,
1749 .parent = TYPE_VIRTIO_CCW_DEVICE,
1750 .instance_size = sizeof(VHostVSockCCWState),
1751 .instance_init = vhost_vsock_ccw_instance_init,
1752 .class_init = vhost_vsock_ccw_class_init,
1753 };
1754 #endif
1755
1756 static void virtio_ccw_register(void)
1757 {
1758 type_register_static(&virtio_ccw_bus_info);
1759 type_register_static(&virtio_ccw_device_info);
1760 type_register_static(&virtio_ccw_blk);
1761 type_register_static(&virtio_ccw_net);
1762 type_register_static(&virtio_ccw_scsi);
1763 #ifdef CONFIG_VHOST_SCSI
1764 type_register_static(&vhost_ccw_scsi);
1765 #endif
1766 type_register_static(&virtio_ccw_rng);
1767 #ifdef CONFIG_VIRTFS
1768 type_register_static(&virtio_ccw_9p_info);
1769 #endif
1770 #ifdef CONFIG_VHOST_VSOCK
1771 type_register_static(&vhost_vsock_ccw_info);
1772 #endif
1773 type_register_static(&virtio_ccw_crypto);
1774 type_register_static(&virtio_ccw_gpu);
1775 type_register_static(&virtio_ccw_input);
1776 type_register_static(&virtio_ccw_input_hid);
1777 type_register_static(&virtio_ccw_keyboard);
1778 type_register_static(&virtio_ccw_mouse);
1779 type_register_static(&virtio_ccw_tablet);
1780 }
1781
1782 type_init(virtio_ccw_register)