]> git.proxmox.com Git - mirror_qemu.git/blame - hw/s390x/virtio-ccw.c
block: remove bootindex property from qdev to qom
[mirror_qemu.git] / hw / s390x / virtio-ccw.c
CommitLineData
a5cf2bb4
CH
1/*
2 * virtio ccw target implementation
3 *
7e749462 4 * Copyright 2012,2014 IBM Corp.
a5cf2bb4
CH
5 * Author(s): Cornelia Huck <cornelia.huck@de.ibm.com>
6 *
7 * This work is licensed under the terms of the GNU GPL, version 2 or (at
8 * your option) any later version. See the COPYING file in the top-level
9 * directory.
10 */
11
12#include "hw/hw.h"
13#include "block/block.h"
14#include "sysemu/blockdev.h"
15#include "sysemu/sysemu.h"
16#include "net/net.h"
17#include "monitor/monitor.h"
0d09e41a
PB
18#include "hw/virtio/virtio.h"
19#include "hw/virtio/virtio-serial.h"
20#include "hw/virtio/virtio-net.h"
a5cf2bb4
CH
21#include "hw/sysbus.h"
22#include "qemu/bitops.h"
0d09e41a 23#include "hw/virtio/virtio-bus.h"
d426d9fb
CH
24#include "hw/s390x/adapter.h"
25#include "hw/s390x/s390_flic.h"
a5cf2bb4
CH
26
27#include "ioinst.h"
28#include "css.h"
29#include "virtio-ccw.h"
30#include "trace.h"
31
7bca3892
CH
32static QTAILQ_HEAD(, IndAddr) indicator_addresses =
33 QTAILQ_HEAD_INITIALIZER(indicator_addresses);
34
35static IndAddr *get_indicator(hwaddr ind_addr, int len)
36{
37 IndAddr *indicator;
38
39 QTAILQ_FOREACH(indicator, &indicator_addresses, sibling) {
40 if (indicator->addr == ind_addr) {
41 indicator->refcnt++;
42 return indicator;
43 }
44 }
45 indicator = g_new0(IndAddr, 1);
46 indicator->addr = ind_addr;
47 indicator->len = len;
48 indicator->refcnt = 1;
49 QTAILQ_INSERT_TAIL(&indicator_addresses, indicator, sibling);
50 return indicator;
51}
52
d426d9fb
CH
53static int s390_io_adapter_map(AdapterInfo *adapter, uint64_t map_addr,
54 bool do_map)
55{
56 S390FLICState *fs = s390_get_flic();
57 S390FLICStateClass *fsc = S390_FLIC_COMMON_GET_CLASS(fs);
58
59 return fsc->io_adapter_map(fs, adapter->adapter_id, map_addr, do_map);
60}
61
62static void release_indicator(AdapterInfo *adapter, IndAddr *indicator)
7bca3892
CH
63{
64 assert(indicator->refcnt > 0);
65 indicator->refcnt--;
66 if (indicator->refcnt > 0) {
67 return;
68 }
69 QTAILQ_REMOVE(&indicator_addresses, indicator, sibling);
d426d9fb
CH
70 if (indicator->map) {
71 s390_io_adapter_map(adapter, indicator->map, false);
72 }
7bca3892
CH
73 g_free(indicator);
74}
75
d426d9fb
CH
76static int map_indicator(AdapterInfo *adapter, IndAddr *indicator)
77{
78 int ret;
79
80 if (indicator->map) {
81 return 0; /* already mapped is not an error */
82 }
83 indicator->map = indicator->addr;
84 ret = s390_io_adapter_map(adapter, indicator->map, true);
85 if ((ret != 0) && (ret != -ENOSYS)) {
86 goto out_err;
87 }
88 return 0;
89
90out_err:
91 indicator->map = 0;
92 return ret;
93}
94
1bf4d7aa
AF
95static void virtio_ccw_bus_new(VirtioBusState *bus, size_t bus_size,
96 VirtioCcwDevice *dev);
d51fcfac 97
dcc20931 98static void virtual_css_bus_reset(BusState *qbus)
a5cf2bb4
CH
99{
100 /* This should actually be modelled via the generic css */
101 css_reset();
a5cf2bb4
CH
102}
103
104
105static void virtual_css_bus_class_init(ObjectClass *klass, void *data)
106{
107 BusClass *k = BUS_CLASS(klass);
108
109 k->reset = virtual_css_bus_reset;
110}
111
112static const TypeInfo virtual_css_bus_info = {
113 .name = TYPE_VIRTUAL_CSS_BUS,
114 .parent = TYPE_BUS,
115 .instance_size = sizeof(VirtualCssBus),
116 .class_init = virtual_css_bus_class_init,
117};
118
a5cf2bb4
CH
119VirtIODevice *virtio_ccw_get_vdev(SubchDev *sch)
120{
121 VirtIODevice *vdev = NULL;
f24a6840 122 VirtioCcwDevice *dev = sch->driver_data;
a5cf2bb4 123
f24a6840
PB
124 if (dev) {
125 vdev = virtio_bus_get_device(&dev->bus);
a5cf2bb4
CH
126 }
127 return vdev;
128}
129
b4436a0b
CH
130static int virtio_ccw_set_guest2host_notifier(VirtioCcwDevice *dev, int n,
131 bool assign, bool set_handler)
132{
f24a6840
PB
133 VirtIODevice *vdev = virtio_bus_get_device(&dev->bus);
134 VirtQueue *vq = virtio_get_queue(vdev, n);
b4436a0b
CH
135 EventNotifier *notifier = virtio_queue_get_host_notifier(vq);
136 int r = 0;
137 SubchDev *sch = dev->sch;
138 uint32_t sch_id = (css_build_subchannel_id(sch) << 16) | sch->schid;
139
140 if (assign) {
141 r = event_notifier_init(notifier, 1);
142 if (r < 0) {
143 error_report("%s: unable to init event notifier: %d", __func__, r);
144 return r;
145 }
146 virtio_queue_set_host_notifier_fd_handler(vq, true, set_handler);
cc3ac9c4 147 r = s390_assign_subch_ioeventfd(notifier, sch_id, n, assign);
b4436a0b
CH
148 if (r < 0) {
149 error_report("%s: unable to assign ioeventfd: %d", __func__, r);
150 virtio_queue_set_host_notifier_fd_handler(vq, false, false);
151 event_notifier_cleanup(notifier);
152 return r;
153 }
154 } else {
155 virtio_queue_set_host_notifier_fd_handler(vq, false, false);
cc3ac9c4 156 s390_assign_subch_ioeventfd(notifier, sch_id, n, assign);
b4436a0b
CH
157 event_notifier_cleanup(notifier);
158 }
159 return r;
160}
161
162static void virtio_ccw_start_ioeventfd(VirtioCcwDevice *dev)
163{
f24a6840 164 VirtIODevice *vdev;
b4436a0b
CH
165 int n, r;
166
167 if (!(dev->flags & VIRTIO_CCW_FLAG_USE_IOEVENTFD) ||
320ce850 168 dev->ioeventfd_disabled ||
b4436a0b
CH
169 dev->ioeventfd_started) {
170 return;
171 }
f24a6840 172 vdev = virtio_bus_get_device(&dev->bus);
b4436a0b 173 for (n = 0; n < VIRTIO_PCI_QUEUE_MAX; n++) {
f24a6840 174 if (!virtio_queue_get_num(vdev, n)) {
b4436a0b
CH
175 continue;
176 }
177 r = virtio_ccw_set_guest2host_notifier(dev, n, true, true);
178 if (r < 0) {
179 goto assign_error;
180 }
181 }
182 dev->ioeventfd_started = true;
183 return;
184
185 assign_error:
186 while (--n >= 0) {
f24a6840 187 if (!virtio_queue_get_num(vdev, n)) {
b4436a0b
CH
188 continue;
189 }
190 r = virtio_ccw_set_guest2host_notifier(dev, n, false, false);
191 assert(r >= 0);
192 }
193 dev->ioeventfd_started = false;
194 /* Disable ioeventfd for this device. */
195 dev->flags &= ~VIRTIO_CCW_FLAG_USE_IOEVENTFD;
196 error_report("%s: failed. Fallback to userspace (slower).", __func__);
197}
198
199static void virtio_ccw_stop_ioeventfd(VirtioCcwDevice *dev)
200{
f24a6840 201 VirtIODevice *vdev;
b4436a0b
CH
202 int n, r;
203
204 if (!dev->ioeventfd_started) {
205 return;
206 }
f24a6840 207 vdev = virtio_bus_get_device(&dev->bus);
b4436a0b 208 for (n = 0; n < VIRTIO_PCI_QUEUE_MAX; n++) {
f24a6840 209 if (!virtio_queue_get_num(vdev, n)) {
b4436a0b
CH
210 continue;
211 }
212 r = virtio_ccw_set_guest2host_notifier(dev, n, false, false);
213 assert(r >= 0);
214 }
215 dev->ioeventfd_started = false;
216}
217
a5cf2bb4
CH
218VirtualCssBus *virtual_css_bus_init(void)
219{
220 VirtualCssBus *cbus;
221 BusState *bus;
222 DeviceState *dev;
223
224 /* Create bridge device */
225 dev = qdev_create(NULL, "virtual-css-bridge");
226 qdev_init_nofail(dev);
227
228 /* Create bus on bridge device */
229 bus = qbus_create(TYPE_VIRTUAL_CSS_BUS, dev, "virtual-css");
230 cbus = VIRTUAL_CSS_BUS(bus);
231
232 /* Enable hotplugging */
233 bus->allow_hotplug = 1;
234
235 return cbus;
236}
237
238/* Communication blocks used by several channel commands. */
239typedef struct VqInfoBlock {
240 uint64_t queue;
241 uint32_t align;
242 uint16_t index;
243 uint16_t num;
244} QEMU_PACKED VqInfoBlock;
245
246typedef struct VqConfigBlock {
247 uint16_t index;
248 uint16_t num_max;
249} QEMU_PACKED VqConfigBlock;
250
251typedef struct VirtioFeatDesc {
252 uint32_t features;
253 uint8_t index;
254} QEMU_PACKED VirtioFeatDesc;
255
7e749462
CH
256typedef struct VirtioThinintInfo {
257 hwaddr summary_indicator;
258 hwaddr device_indicator;
259 uint64_t ind_bit;
260 uint8_t isc;
261} QEMU_PACKED VirtioThinintInfo;
262
a5cf2bb4
CH
263/* Specify where the virtqueues for the subchannel are in guest memory. */
264static int virtio_ccw_set_vqs(SubchDev *sch, uint64_t addr, uint32_t align,
265 uint16_t index, uint16_t num)
266{
f24a6840 267 VirtIODevice *vdev = virtio_ccw_get_vdev(sch);
a5cf2bb4
CH
268
269 if (index > VIRTIO_PCI_QUEUE_MAX) {
270 return -EINVAL;
271 }
272
273 /* Current code in virtio.c relies on 4K alignment. */
274 if (addr && (align != 4096)) {
275 return -EINVAL;
276 }
277
f24a6840 278 if (!vdev) {
a5cf2bb4
CH
279 return -EINVAL;
280 }
281
f24a6840 282 virtio_queue_set_addr(vdev, index, addr);
a5cf2bb4 283 if (!addr) {
f24a6840 284 virtio_queue_set_vector(vdev, index, 0);
a5cf2bb4
CH
285 } else {
286 /* Fail if we don't have a big enough queue. */
287 /* TODO: Add interface to handle vring.num changing */
f24a6840 288 if (virtio_queue_get_num(vdev, index) > num) {
a5cf2bb4
CH
289 return -EINVAL;
290 }
f24a6840 291 virtio_queue_set_vector(vdev, index, index);
a5cf2bb4
CH
292 }
293 /* tell notify handler in case of config change */
f24a6840 294 vdev->config_vector = VIRTIO_PCI_QUEUE_MAX;
a5cf2bb4
CH
295 return 0;
296}
297
298static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw)
299{
300 int ret;
301 VqInfoBlock info;
302 uint8_t status;
303 VirtioFeatDesc features;
304 void *config;
305 hwaddr indicators;
306 VqConfigBlock vq_config;
307 VirtioCcwDevice *dev = sch->driver_data;
f24a6840 308 VirtIODevice *vdev = virtio_ccw_get_vdev(sch);
a5cf2bb4
CH
309 bool check_len;
310 int len;
311 hwaddr hw_len;
7e749462 312 VirtioThinintInfo *thinint;
a5cf2bb4
CH
313
314 if (!dev) {
315 return -EINVAL;
316 }
317
318 trace_virtio_ccw_interpret_ccw(sch->cssid, sch->ssid, sch->schid,
319 ccw.cmd_code);
320 check_len = !((ccw.flags & CCW_FLAG_SLI) && !(ccw.flags & CCW_FLAG_DC));
321
322 /* Look at the command. */
323 switch (ccw.cmd_code) {
324 case CCW_CMD_SET_VQ:
325 if (check_len) {
326 if (ccw.count != sizeof(info)) {
327 ret = -EINVAL;
328 break;
329 }
330 } else if (ccw.count < sizeof(info)) {
331 /* Can't execute command. */
332 ret = -EINVAL;
333 break;
334 }
335 if (!ccw.cda) {
336 ret = -EFAULT;
337 } else {
2c17449b 338 info.queue = ldq_phys(&address_space_memory, ccw.cda);
fdfba1a2
EI
339 info.align = ldl_phys(&address_space_memory,
340 ccw.cda + sizeof(info.queue));
41701aa4
EI
341 info.index = lduw_phys(&address_space_memory,
342 ccw.cda + sizeof(info.queue)
a5cf2bb4 343 + sizeof(info.align));
41701aa4
EI
344 info.num = lduw_phys(&address_space_memory,
345 ccw.cda + sizeof(info.queue)
a5cf2bb4
CH
346 + sizeof(info.align)
347 + sizeof(info.index));
348 ret = virtio_ccw_set_vqs(sch, info.queue, info.align, info.index,
349 info.num);
350 sch->curr_status.scsw.count = 0;
351 }
352 break;
353 case CCW_CMD_VDEV_RESET:
b4436a0b 354 virtio_ccw_stop_ioeventfd(dev);
f24a6840 355 virtio_reset(vdev);
a5cf2bb4
CH
356 ret = 0;
357 break;
358 case CCW_CMD_READ_FEAT:
359 if (check_len) {
360 if (ccw.count != sizeof(features)) {
361 ret = -EINVAL;
362 break;
363 }
364 } else if (ccw.count < sizeof(features)) {
365 /* Can't execute command. */
366 ret = -EINVAL;
367 break;
368 }
369 if (!ccw.cda) {
370 ret = -EFAULT;
371 } else {
2c17449b
EI
372 features.index = ldub_phys(&address_space_memory,
373 ccw.cda + sizeof(features.features));
a5cf2bb4
CH
374 if (features.index < ARRAY_SIZE(dev->host_features)) {
375 features.features = dev->host_features[features.index];
376 } else {
377 /* Return zeroes if the guest supports more feature bits. */
378 features.features = 0;
379 }
ab1da857 380 stl_le_phys(&address_space_memory, ccw.cda, features.features);
a5cf2bb4
CH
381 sch->curr_status.scsw.count = ccw.count - sizeof(features);
382 ret = 0;
383 }
384 break;
385 case CCW_CMD_WRITE_FEAT:
386 if (check_len) {
387 if (ccw.count != sizeof(features)) {
388 ret = -EINVAL;
389 break;
390 }
391 } else if (ccw.count < sizeof(features)) {
392 /* Can't execute command. */
393 ret = -EINVAL;
394 break;
395 }
396 if (!ccw.cda) {
397 ret = -EFAULT;
398 } else {
2c17449b
EI
399 features.index = ldub_phys(&address_space_memory,
400 ccw.cda + sizeof(features.features));
fdfba1a2 401 features.features = ldl_le_phys(&address_space_memory, ccw.cda);
a5cf2bb4 402 if (features.index < ARRAY_SIZE(dev->host_features)) {
181103cd 403 virtio_bus_set_vdev_features(&dev->bus, features.features);
f24a6840 404 vdev->guest_features = features.features;
a5cf2bb4
CH
405 } else {
406 /*
407 * If the guest supports more feature bits, assert that it
408 * passes us zeroes for those we don't support.
409 */
410 if (features.features) {
411 fprintf(stderr, "Guest bug: features[%i]=%x (expected 0)\n",
412 features.index, features.features);
413 /* XXX: do a unit check here? */
414 }
415 }
416 sch->curr_status.scsw.count = ccw.count - sizeof(features);
417 ret = 0;
418 }
419 break;
420 case CCW_CMD_READ_CONF:
421 if (check_len) {
f24a6840 422 if (ccw.count > vdev->config_len) {
a5cf2bb4
CH
423 ret = -EINVAL;
424 break;
425 }
426 }
f24a6840 427 len = MIN(ccw.count, vdev->config_len);
a5cf2bb4
CH
428 if (!ccw.cda) {
429 ret = -EFAULT;
430 } else {
f24a6840 431 virtio_bus_get_vdev_config(&dev->bus, vdev->config);
a5cf2bb4 432 /* XXX config space endianness */
f24a6840 433 cpu_physical_memory_write(ccw.cda, vdev->config, len);
a5cf2bb4
CH
434 sch->curr_status.scsw.count = ccw.count - len;
435 ret = 0;
436 }
437 break;
438 case CCW_CMD_WRITE_CONF:
439 if (check_len) {
f24a6840 440 if (ccw.count > vdev->config_len) {
a5cf2bb4
CH
441 ret = -EINVAL;
442 break;
443 }
444 }
f24a6840 445 len = MIN(ccw.count, vdev->config_len);
a5cf2bb4
CH
446 hw_len = len;
447 if (!ccw.cda) {
448 ret = -EFAULT;
449 } else {
450 config = cpu_physical_memory_map(ccw.cda, &hw_len, 0);
451 if (!config) {
452 ret = -EFAULT;
453 } else {
454 len = hw_len;
455 /* XXX config space endianness */
f24a6840 456 memcpy(vdev->config, config, len);
a5cf2bb4 457 cpu_physical_memory_unmap(config, hw_len, 0, hw_len);
f24a6840 458 virtio_bus_set_vdev_config(&dev->bus, vdev->config);
a5cf2bb4
CH
459 sch->curr_status.scsw.count = ccw.count - len;
460 ret = 0;
461 }
462 }
463 break;
464 case CCW_CMD_WRITE_STATUS:
465 if (check_len) {
466 if (ccw.count != sizeof(status)) {
467 ret = -EINVAL;
468 break;
469 }
470 } else if (ccw.count < sizeof(status)) {
471 /* Can't execute command. */
472 ret = -EINVAL;
473 break;
474 }
475 if (!ccw.cda) {
476 ret = -EFAULT;
477 } else {
2c17449b 478 status = ldub_phys(&address_space_memory, ccw.cda);
b4436a0b
CH
479 if (!(status & VIRTIO_CONFIG_S_DRIVER_OK)) {
480 virtio_ccw_stop_ioeventfd(dev);
481 }
f24a6840
PB
482 virtio_set_status(vdev, status);
483 if (vdev->status == 0) {
484 virtio_reset(vdev);
a5cf2bb4 485 }
b4436a0b
CH
486 if (status & VIRTIO_CONFIG_S_DRIVER_OK) {
487 virtio_ccw_start_ioeventfd(dev);
488 }
a5cf2bb4
CH
489 sch->curr_status.scsw.count = ccw.count - sizeof(status);
490 ret = 0;
491 }
492 break;
493 case CCW_CMD_SET_IND:
494 if (check_len) {
495 if (ccw.count != sizeof(indicators)) {
496 ret = -EINVAL;
497 break;
498 }
499 } else if (ccw.count < sizeof(indicators)) {
500 /* Can't execute command. */
501 ret = -EINVAL;
502 break;
503 }
7e749462
CH
504 if (sch->thinint_active) {
505 /* Trigger a command reject. */
506 ret = -ENOSYS;
507 break;
508 }
d1db1fa8 509 if (!ccw.cda) {
a5cf2bb4
CH
510 ret = -EFAULT;
511 } else {
2c17449b 512 indicators = ldq_phys(&address_space_memory, ccw.cda);
7bca3892 513 dev->indicators = get_indicator(indicators, sizeof(uint64_t));
a5cf2bb4
CH
514 sch->curr_status.scsw.count = ccw.count - sizeof(indicators);
515 ret = 0;
516 }
517 break;
518 case CCW_CMD_SET_CONF_IND:
519 if (check_len) {
520 if (ccw.count != sizeof(indicators)) {
521 ret = -EINVAL;
522 break;
523 }
524 } else if (ccw.count < sizeof(indicators)) {
525 /* Can't execute command. */
526 ret = -EINVAL;
527 break;
528 }
d1db1fa8 529 if (!ccw.cda) {
a5cf2bb4
CH
530 ret = -EFAULT;
531 } else {
2c17449b 532 indicators = ldq_phys(&address_space_memory, ccw.cda);
7bca3892 533 dev->indicators2 = get_indicator(indicators, sizeof(uint64_t));
a5cf2bb4
CH
534 sch->curr_status.scsw.count = ccw.count - sizeof(indicators);
535 ret = 0;
536 }
537 break;
538 case CCW_CMD_READ_VQ_CONF:
539 if (check_len) {
540 if (ccw.count != sizeof(vq_config)) {
541 ret = -EINVAL;
542 break;
543 }
544 } else if (ccw.count < sizeof(vq_config)) {
545 /* Can't execute command. */
546 ret = -EINVAL;
547 break;
548 }
549 if (!ccw.cda) {
550 ret = -EFAULT;
551 } else {
41701aa4 552 vq_config.index = lduw_phys(&address_space_memory, ccw.cda);
f24a6840 553 vq_config.num_max = virtio_queue_get_num(vdev,
a5cf2bb4 554 vq_config.index);
5ce5944d
EI
555 stw_phys(&address_space_memory,
556 ccw.cda + sizeof(vq_config.index), vq_config.num_max);
a5cf2bb4
CH
557 sch->curr_status.scsw.count = ccw.count - sizeof(vq_config);
558 ret = 0;
559 }
560 break;
7e749462
CH
561 case CCW_CMD_SET_IND_ADAPTER:
562 if (check_len) {
563 if (ccw.count != sizeof(*thinint)) {
564 ret = -EINVAL;
565 break;
566 }
567 } else if (ccw.count < sizeof(*thinint)) {
568 /* Can't execute command. */
569 ret = -EINVAL;
570 break;
571 }
572 len = sizeof(*thinint);
573 hw_len = len;
574 if (!ccw.cda) {
575 ret = -EFAULT;
576 } else if (dev->indicators && !sch->thinint_active) {
577 /* Trigger a command reject. */
578 ret = -ENOSYS;
579 } else {
580 thinint = cpu_physical_memory_map(ccw.cda, &hw_len, 0);
581 if (!thinint) {
582 ret = -EFAULT;
583 } else {
584 len = hw_len;
7bca3892
CH
585 dev->summary_indicator =
586 get_indicator(thinint->summary_indicator, sizeof(uint8_t));
587 dev->indicators = get_indicator(thinint->device_indicator,
588 thinint->ind_bit / 8 + 1);
7e749462 589 dev->thinint_isc = thinint->isc;
d426d9fb
CH
590 dev->routes.adapter.ind_offset = thinint->ind_bit;
591 dev->routes.adapter.summary_offset = 7;
7e749462 592 cpu_physical_memory_unmap(thinint, hw_len, 0, hw_len);
03cf077a
CH
593 ret = css_register_io_adapter(CSS_IO_ADAPTER_VIRTIO,
594 dev->thinint_isc, true, false,
d426d9fb 595 &dev->routes.adapter.adapter_id);
03cf077a 596 assert(ret == 0);
7bca3892
CH
597 sch->thinint_active = ((dev->indicators != NULL) &&
598 (dev->summary_indicator != NULL));
7e749462
CH
599 sch->curr_status.scsw.count = ccw.count - len;
600 ret = 0;
601 }
602 }
603 break;
a5cf2bb4 604 default:
8d034a6f 605 ret = -ENOSYS;
a5cf2bb4
CH
606 break;
607 }
608 return ret;
609}
610
611static int virtio_ccw_device_init(VirtioCcwDevice *dev, VirtIODevice *vdev)
612{
613 unsigned int cssid = 0;
614 unsigned int ssid = 0;
615 unsigned int schid;
616 unsigned int devno;
617 bool have_devno = false;
618 bool found = false;
619 SubchDev *sch;
620 int ret;
621 int num;
622 DeviceState *parent = DEVICE(dev);
623
624 sch = g_malloc0(sizeof(SubchDev));
625
626 sch->driver_data = dev;
627 dev->sch = sch;
628
7bca3892 629 dev->indicators = NULL;
a5cf2bb4
CH
630
631 /* Initialize subchannel structure. */
632 sch->channel_prog = 0x0;
633 sch->last_cmd_valid = false;
7e749462 634 sch->thinint_active = false;
a5cf2bb4
CH
635 /*
636 * Use a device number if provided. Otherwise, fall back to subchannel
637 * number.
638 */
639 if (dev->bus_id) {
640 num = sscanf(dev->bus_id, "%x.%x.%04x", &cssid, &ssid, &devno);
641 if (num == 3) {
642 if ((cssid > MAX_CSSID) || (ssid > MAX_SSID)) {
643 ret = -EINVAL;
644 error_report("Invalid cssid or ssid: cssid %x, ssid %x",
645 cssid, ssid);
646 goto out_err;
647 }
648 /* Enforce use of virtual cssid. */
649 if (cssid != VIRTUAL_CSSID) {
650 ret = -EINVAL;
651 error_report("cssid %x not valid for virtio devices", cssid);
652 goto out_err;
653 }
654 if (css_devno_used(cssid, ssid, devno)) {
655 ret = -EEXIST;
656 error_report("Device %x.%x.%04x already exists", cssid, ssid,
657 devno);
658 goto out_err;
659 }
660 sch->cssid = cssid;
661 sch->ssid = ssid;
662 sch->devno = devno;
663 have_devno = true;
664 } else {
665 ret = -EINVAL;
666 error_report("Malformed devno parameter '%s'", dev->bus_id);
667 goto out_err;
668 }
669 }
670
671 /* Find the next free id. */
672 if (have_devno) {
673 for (schid = 0; schid <= MAX_SCHID; schid++) {
674 if (!css_find_subch(1, cssid, ssid, schid)) {
675 sch->schid = schid;
676 css_subch_assign(cssid, ssid, schid, devno, sch);
677 found = true;
678 break;
679 }
680 }
681 if (!found) {
682 ret = -ENODEV;
683 error_report("No free subchannel found for %x.%x.%04x", cssid, ssid,
684 devno);
685 goto out_err;
686 }
687 trace_virtio_ccw_new_device(cssid, ssid, schid, devno,
688 "user-configured");
689 } else {
690 cssid = VIRTUAL_CSSID;
691 for (ssid = 0; ssid <= MAX_SSID; ssid++) {
692 for (schid = 0; schid <= MAX_SCHID; schid++) {
693 if (!css_find_subch(1, cssid, ssid, schid)) {
694 sch->cssid = cssid;
695 sch->ssid = ssid;
696 sch->schid = schid;
697 devno = schid;
698 /*
699 * If the devno is already taken, look further in this
700 * subchannel set.
701 */
702 while (css_devno_used(cssid, ssid, devno)) {
703 if (devno == MAX_SCHID) {
704 devno = 0;
705 } else if (devno == schid - 1) {
706 ret = -ENODEV;
707 error_report("No free devno found");
708 goto out_err;
709 } else {
710 devno++;
711 }
712 }
713 sch->devno = devno;
714 css_subch_assign(cssid, ssid, schid, devno, sch);
715 found = true;
716 break;
717 }
718 }
719 if (found) {
720 break;
721 }
722 }
723 if (!found) {
724 ret = -ENODEV;
725 error_report("Virtual channel subsystem is full!");
726 goto out_err;
727 }
728 trace_virtio_ccw_new_device(cssid, ssid, schid, devno,
729 "auto-configured");
730 }
731
732 /* Build initial schib. */
733 css_sch_build_virtual_schib(sch, 0, VIRTIO_CCW_CHPID_TYPE);
734
735 sch->ccw_cb = virtio_ccw_cb;
736
737 /* Build senseid data. */
738 memset(&sch->id, 0, sizeof(SenseId));
739 sch->id.reserved = 0xff;
740 sch->id.cu_type = VIRTIO_CCW_CU_TYPE;
f24a6840 741 sch->id.cu_model = vdev->device_id;
a5cf2bb4 742
a5cf2bb4 743 /* Only the first 32 feature bits are used. */
181103cd
FK
744 dev->host_features[0] = virtio_bus_get_vdev_features(&dev->bus,
745 dev->host_features[0]);
746
a5cf2bb4
CH
747 dev->host_features[0] |= 0x1 << VIRTIO_F_NOTIFY_ON_EMPTY;
748 dev->host_features[0] |= 0x1 << VIRTIO_F_BAD_FEATURE;
749
750 css_generate_sch_crws(sch->cssid, sch->ssid, sch->schid,
751 parent->hotplugged, 1);
752 return 0;
753
754out_err:
755 dev->sch = NULL;
756 g_free(sch);
757 return ret;
758}
759
760static int virtio_ccw_exit(VirtioCcwDevice *dev)
761{
762 SubchDev *sch = dev->sch;
763
764 if (sch) {
765 css_subch_assign(sch->cssid, sch->ssid, sch->schid, sch->devno, NULL);
766 g_free(sch);
767 }
7bca3892 768 if (dev->indicators) {
d426d9fb 769 release_indicator(&dev->routes.adapter, dev->indicators);
7bca3892
CH
770 dev->indicators = NULL;
771 }
a5cf2bb4
CH
772 return 0;
773}
774
89334c8b 775static int virtio_ccw_net_init(VirtioCcwDevice *ccw_dev)
a5cf2bb4 776{
800ced8c 777 DeviceState *qdev = DEVICE(ccw_dev);
89334c8b
FK
778 VirtIONetCcw *dev = VIRTIO_NET_CCW(ccw_dev);
779 DeviceState *vdev = DEVICE(&dev->vdev);
a5cf2bb4 780
89334c8b 781 virtio_net_set_config_size(&dev->vdev, ccw_dev->host_features[0]);
800ced8c
FK
782 virtio_net_set_netclient_name(&dev->vdev, qdev->id,
783 object_get_typename(OBJECT(qdev)));
89334c8b
FK
784 qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus));
785 if (qdev_init(vdev) < 0) {
a5cf2bb4
CH
786 return -1;
787 }
788
89334c8b 789 return virtio_ccw_device_init(ccw_dev, VIRTIO_DEVICE(vdev));
a5cf2bb4
CH
790}
791
89334c8b 792static void virtio_ccw_net_instance_init(Object *obj)
a5cf2bb4 793{
89334c8b 794 VirtIONetCcw *dev = VIRTIO_NET_CCW(obj);
c8075caf
GA
795
796 virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
797 TYPE_VIRTIO_NET);
0cf63c3e
GA
798 object_property_add_alias(obj, "bootindex", OBJECT(&dev->vdev),
799 "bootindex", &error_abort);
a5cf2bb4
CH
800}
801
3400c455 802static int virtio_ccw_blk_init(VirtioCcwDevice *ccw_dev)
a5cf2bb4 803{
3400c455
FK
804 VirtIOBlkCcw *dev = VIRTIO_BLK_CCW(ccw_dev);
805 DeviceState *vdev = DEVICE(&dev->vdev);
3400c455
FK
806 qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus));
807 if (qdev_init(vdev) < 0) {
a5cf2bb4
CH
808 return -1;
809 }
810
3400c455 811 return virtio_ccw_device_init(ccw_dev, VIRTIO_DEVICE(vdev));
a5cf2bb4
CH
812}
813
3400c455 814static void virtio_ccw_blk_instance_init(Object *obj)
a5cf2bb4 815{
3400c455 816 VirtIOBlkCcw *dev = VIRTIO_BLK_CCW(obj);
c8075caf
GA
817
818 virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
819 TYPE_VIRTIO_BLK);
467b3f33
SH
820 object_property_add_alias(obj, "iothread", OBJECT(&dev->vdev),"iothread",
821 &error_abort);
a5cf2bb4
CH
822}
823
6acf69cd 824static int virtio_ccw_serial_init(VirtioCcwDevice *ccw_dev)
a5cf2bb4 825{
6acf69cd
FK
826 VirtioSerialCcw *dev = VIRTIO_SERIAL_CCW(ccw_dev);
827 DeviceState *vdev = DEVICE(&dev->vdev);
80270a19
FK
828 DeviceState *proxy = DEVICE(ccw_dev);
829 char *bus_name;
830
831 /*
832 * For command line compatibility, this sets the virtio-serial-device bus
833 * name as before.
834 */
835 if (proxy->id) {
836 bus_name = g_strdup_printf("%s.0", proxy->id);
837 virtio_device_set_child_bus_name(VIRTIO_DEVICE(vdev), bus_name);
838 g_free(bus_name);
839 }
a5cf2bb4 840
6acf69cd
FK
841 qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus));
842 if (qdev_init(vdev) < 0) {
a5cf2bb4
CH
843 return -1;
844 }
845
6acf69cd 846 return virtio_ccw_device_init(ccw_dev, VIRTIO_DEVICE(vdev));
a5cf2bb4
CH
847}
848
6acf69cd
FK
849
850static void virtio_ccw_serial_instance_init(Object *obj)
a5cf2bb4 851{
6acf69cd 852 VirtioSerialCcw *dev = VIRTIO_SERIAL_CCW(obj);
c8075caf
GA
853
854 virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
855 TYPE_VIRTIO_SERIAL);
a5cf2bb4
CH
856}
857
30bff6a0 858static int virtio_ccw_balloon_init(VirtioCcwDevice *ccw_dev)
a5cf2bb4 859{
30bff6a0
FK
860 VirtIOBalloonCcw *dev = VIRTIO_BALLOON_CCW(ccw_dev);
861 DeviceState *vdev = DEVICE(&dev->vdev);
a5cf2bb4 862
30bff6a0
FK
863 qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus));
864 if (qdev_init(vdev) < 0) {
a5cf2bb4
CH
865 return -1;
866 }
867
30bff6a0 868 return virtio_ccw_device_init(ccw_dev, VIRTIO_DEVICE(vdev));
a5cf2bb4
CH
869}
870
24a6e7f4
FK
871static void balloon_ccw_stats_get_all(Object *obj, struct Visitor *v,
872 void *opaque, const char *name,
873 Error **errp)
874{
875 VirtIOBalloonCcw *dev = opaque;
876 object_property_get(OBJECT(&dev->vdev), v, "guest-stats", errp);
877}
878
879static void balloon_ccw_stats_get_poll_interval(Object *obj, struct Visitor *v,
880 void *opaque, const char *name,
881 Error **errp)
882{
883 VirtIOBalloonCcw *dev = opaque;
884 object_property_get(OBJECT(&dev->vdev), v, "guest-stats-polling-interval",
885 errp);
886}
887
888static void balloon_ccw_stats_set_poll_interval(Object *obj, struct Visitor *v,
889 void *opaque, const char *name,
890 Error **errp)
891{
892 VirtIOBalloonCcw *dev = opaque;
893 object_property_set(OBJECT(&dev->vdev), v, "guest-stats-polling-interval",
894 errp);
895}
896
30bff6a0 897static void virtio_ccw_balloon_instance_init(Object *obj)
a5cf2bb4 898{
30bff6a0 899 VirtIOBalloonCcw *dev = VIRTIO_BALLOON_CCW(obj);
213f0c4f 900 object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_BALLOON);
30bff6a0 901 object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
91ba2120 902 object_unref(OBJECT(&dev->vdev));
24a6e7f4
FK
903 object_property_add(obj, "guest-stats", "guest statistics",
904 balloon_ccw_stats_get_all, NULL, NULL, dev, NULL);
905
906 object_property_add(obj, "guest-stats-polling-interval", "int",
907 balloon_ccw_stats_get_poll_interval,
908 balloon_ccw_stats_set_poll_interval,
909 NULL, dev, NULL);
a5cf2bb4
CH
910}
911
c908ea10 912static int virtio_ccw_scsi_init(VirtioCcwDevice *ccw_dev)
a5cf2bb4 913{
c908ea10
FK
914 VirtIOSCSICcw *dev = VIRTIO_SCSI_CCW(ccw_dev);
915 DeviceState *vdev = DEVICE(&dev->vdev);
6f32a6b4
FK
916 DeviceState *qdev = DEVICE(ccw_dev);
917 char *bus_name;
918
919 /*
920 * For command line compatibility, this sets the virtio-scsi-device bus
921 * name as before.
922 */
923 if (qdev->id) {
924 bus_name = g_strdup_printf("%s.0", qdev->id);
925 virtio_device_set_child_bus_name(VIRTIO_DEVICE(vdev), bus_name);
926 g_free(bus_name);
927 }
a5cf2bb4 928
c908ea10
FK
929 qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus));
930 if (qdev_init(vdev) < 0) {
a5cf2bb4
CH
931 return -1;
932 }
933
c908ea10 934 return virtio_ccw_device_init(ccw_dev, VIRTIO_DEVICE(vdev));
a5cf2bb4
CH
935}
936
c908ea10 937static void virtio_ccw_scsi_instance_init(Object *obj)
a5cf2bb4 938{
c908ea10 939 VirtIOSCSICcw *dev = VIRTIO_SCSI_CCW(obj);
c8075caf
GA
940
941 virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
942 TYPE_VIRTIO_SCSI);
19d339f1
FZ
943 object_property_add_alias(obj, "iothread", OBJECT(&dev->vdev), "iothread",
944 &error_abort);
a5cf2bb4
CH
945}
946
ccf6916c
PB
947#ifdef CONFIG_VHOST_SCSI
948static int vhost_ccw_scsi_init(VirtioCcwDevice *ccw_dev)
949{
950 VHostSCSICcw *dev = VHOST_SCSI_CCW(ccw_dev);
951 DeviceState *vdev = DEVICE(&dev->vdev);
952
953 qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus));
954 if (qdev_init(vdev) < 0) {
955 return -1;
956 }
957
958 return virtio_ccw_device_init(ccw_dev, VIRTIO_DEVICE(vdev));
959}
960
961static void vhost_ccw_scsi_instance_init(Object *obj)
962{
963 VHostSCSICcw *dev = VHOST_SCSI_CCW(obj);
c8075caf
GA
964
965 virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
966 TYPE_VHOST_SCSI);
ccf6916c
PB
967}
968#endif
969
2db26d4c 970static int virtio_ccw_rng_init(VirtioCcwDevice *ccw_dev)
2362ecc5 971{
2db26d4c
FK
972 VirtIORNGCcw *dev = VIRTIO_RNG_CCW(ccw_dev);
973 DeviceState *vdev = DEVICE(&dev->vdev);
2362ecc5 974
2db26d4c
FK
975 qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus));
976 if (qdev_init(vdev) < 0) {
2362ecc5
CH
977 return -1;
978 }
2362ecc5 979
2db26d4c 980 object_property_set_link(OBJECT(dev),
5b456438 981 OBJECT(dev->vdev.conf.rng), "rng",
2db26d4c
FK
982 NULL);
983
984 return virtio_ccw_device_init(ccw_dev, VIRTIO_DEVICE(vdev));
2362ecc5
CH
985}
986
a5cf2bb4
CH
987/* DeviceState to VirtioCcwDevice. Note: used on datapath,
988 * be careful and test performance if you change this.
989 */
990static inline VirtioCcwDevice *to_virtio_ccw_dev_fast(DeviceState *d)
991{
992 return container_of(d, VirtioCcwDevice, parent_obj);
993}
994
7e749462
CH
995static uint8_t virtio_set_ind_atomic(SubchDev *sch, uint64_t ind_loc,
996 uint8_t to_be_set)
997{
998 uint8_t ind_old, ind_new;
999 hwaddr len = 1;
1000 uint8_t *ind_addr;
1001
1002 ind_addr = cpu_physical_memory_map(ind_loc, &len, 1);
1003 if (!ind_addr) {
1004 error_report("%s(%x.%x.%04x): unable to access indicator",
1005 __func__, sch->cssid, sch->ssid, sch->schid);
1006 return -1;
1007 }
1008 do {
1009 ind_old = *ind_addr;
1010 ind_new = ind_old | to_be_set;
1011 } while (atomic_cmpxchg(ind_addr, ind_old, ind_new) != ind_old);
1012 cpu_physical_memory_unmap(ind_addr, len, 1, len);
1013
1014 return ind_old;
1015}
1016
a5cf2bb4
CH
1017static void virtio_ccw_notify(DeviceState *d, uint16_t vector)
1018{
1019 VirtioCcwDevice *dev = to_virtio_ccw_dev_fast(d);
1020 SubchDev *sch = dev->sch;
1021 uint64_t indicators;
1022
1023 if (vector >= 128) {
1024 return;
1025 }
1026
1027 if (vector < VIRTIO_PCI_QUEUE_MAX) {
7c486976
CH
1028 if (!dev->indicators) {
1029 return;
1030 }
7e749462
CH
1031 if (sch->thinint_active) {
1032 /*
1033 * In the adapter interrupt case, indicators points to a
1034 * memory area that may be (way) larger than 64 bit and
1035 * ind_bit indicates the start of the indicators in a big
1036 * endian notation.
1037 */
d426d9fb
CH
1038 uint64_t ind_bit = dev->routes.adapter.ind_offset;
1039
7bca3892 1040 virtio_set_ind_atomic(sch, dev->indicators->addr +
d426d9fb
CH
1041 (ind_bit + vector) / 8,
1042 0x80 >> ((ind_bit + vector) % 8));
7bca3892 1043 if (!virtio_set_ind_atomic(sch, dev->summary_indicator->addr,
7e749462
CH
1044 0x01)) {
1045 css_adapter_interrupt(dev->thinint_isc);
1046 }
1047 } else {
7bca3892 1048 indicators = ldq_phys(&address_space_memory, dev->indicators->addr);
7e749462 1049 indicators |= 1ULL << vector;
7bca3892 1050 stq_phys(&address_space_memory, dev->indicators->addr, indicators);
7e749462
CH
1051 css_conditional_io_interrupt(sch);
1052 }
a5cf2bb4 1053 } else {
7c486976
CH
1054 if (!dev->indicators2) {
1055 return;
1056 }
a5cf2bb4 1057 vector = 0;
7bca3892 1058 indicators = ldq_phys(&address_space_memory, dev->indicators2->addr);
19380b1b 1059 indicators |= 1ULL << vector;
7bca3892 1060 stq_phys(&address_space_memory, dev->indicators2->addr, indicators);
7e749462 1061 css_conditional_io_interrupt(sch);
a5cf2bb4 1062 }
a5cf2bb4
CH
1063}
1064
1065static unsigned virtio_ccw_get_features(DeviceState *d)
1066{
1067 VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d);
1068
1069 /* Only the first 32 feature bits are used. */
1070 return dev->host_features[0];
1071}
1072
1073static void virtio_ccw_reset(DeviceState *d)
1074{
1075 VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d);
f24a6840 1076 VirtIODevice *vdev = virtio_bus_get_device(&dev->bus);
a5cf2bb4 1077
b4436a0b 1078 virtio_ccw_stop_ioeventfd(dev);
f24a6840 1079 virtio_reset(vdev);
a5cf2bb4 1080 css_reset_sch(dev->sch);
7bca3892 1081 if (dev->indicators) {
d426d9fb 1082 release_indicator(&dev->routes.adapter, dev->indicators);
7bca3892
CH
1083 dev->indicators = NULL;
1084 }
1085 if (dev->indicators2) {
d426d9fb 1086 release_indicator(&dev->routes.adapter, dev->indicators2);
7bca3892
CH
1087 dev->indicators2 = NULL;
1088 }
1089 if (dev->summary_indicator) {
d426d9fb 1090 release_indicator(&dev->routes.adapter, dev->summary_indicator);
7bca3892
CH
1091 dev->summary_indicator = NULL;
1092 }
a5cf2bb4
CH
1093}
1094
b4436a0b
CH
1095static void virtio_ccw_vmstate_change(DeviceState *d, bool running)
1096{
1097 VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d);
1098
1099 if (running) {
1100 virtio_ccw_start_ioeventfd(dev);
1101 } else {
1102 virtio_ccw_stop_ioeventfd(dev);
1103 }
1104}
1105
320ce850
CH
1106static bool virtio_ccw_query_guest_notifiers(DeviceState *d)
1107{
1108 VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d);
1109
1110 return !!(dev->sch->curr_status.pmcw.flags & PMCW_FLAGS_MASK_ENA);
1111}
1112
1113static int virtio_ccw_set_host_notifier(DeviceState *d, int n, bool assign)
1114{
1115 VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d);
1116
1117 /* Stop using the generic ioeventfd, we are doing eventfd handling
1118 * ourselves below */
1119 dev->ioeventfd_disabled = assign;
1120 if (assign) {
1121 virtio_ccw_stop_ioeventfd(dev);
1122 }
1123 return virtio_ccw_set_guest2host_notifier(dev, n, assign, false);
1124}
1125
d426d9fb
CH
1126static int virtio_ccw_get_mappings(VirtioCcwDevice *dev)
1127{
1128 int r;
1129
1130 if (!dev->sch->thinint_active) {
1131 return -EINVAL;
1132 }
1133
1134 r = map_indicator(&dev->routes.adapter, dev->summary_indicator);
1135 if (r) {
1136 return r;
1137 }
1138 r = map_indicator(&dev->routes.adapter, dev->indicators);
1139 if (r) {
1140 return r;
1141 }
1142 dev->routes.adapter.summary_addr = dev->summary_indicator->map;
1143 dev->routes.adapter.ind_addr = dev->indicators->map;
1144
1145 return 0;
1146}
1147
1148static int virtio_ccw_setup_irqroutes(VirtioCcwDevice *dev, int nvqs)
1149{
1150 int i;
1151 VirtIODevice *vdev = virtio_bus_get_device(&dev->bus);
1152 int ret;
1153 S390FLICState *fs = s390_get_flic();
1154 S390FLICStateClass *fsc = S390_FLIC_COMMON_GET_CLASS(fs);
1155
1156 ret = virtio_ccw_get_mappings(dev);
1157 if (ret) {
1158 return ret;
1159 }
1160 for (i = 0; i < nvqs; i++) {
1161 if (!virtio_queue_get_num(vdev, i)) {
1162 break;
1163 }
1164 }
1165 dev->routes.num_routes = i;
1166 return fsc->add_adapter_routes(fs, &dev->routes);
1167}
1168
1169static void virtio_ccw_release_irqroutes(VirtioCcwDevice *dev, int nvqs)
1170{
1171 S390FLICState *fs = s390_get_flic();
1172 S390FLICStateClass *fsc = S390_FLIC_COMMON_GET_CLASS(fs);
1173
1174 fsc->release_adapter_routes(fs, &dev->routes);
1175}
1176
1177static int virtio_ccw_add_irqfd(VirtioCcwDevice *dev, int n)
1178{
1179 VirtIODevice *vdev = virtio_bus_get_device(&dev->bus);
1180 VirtQueue *vq = virtio_get_queue(vdev, n);
1181 EventNotifier *notifier = virtio_queue_get_guest_notifier(vq);
1182
1183 return kvm_irqchip_add_irqfd_notifier(kvm_state, notifier, NULL,
1184 dev->routes.gsi[n]);
1185}
1186
1187static void virtio_ccw_remove_irqfd(VirtioCcwDevice *dev, int n)
1188{
1189 VirtIODevice *vdev = virtio_bus_get_device(&dev->bus);
1190 VirtQueue *vq = virtio_get_queue(vdev, n);
1191 EventNotifier *notifier = virtio_queue_get_guest_notifier(vq);
1192 int ret;
1193
1194 ret = kvm_irqchip_remove_irqfd_notifier(kvm_state, notifier,
1195 dev->routes.gsi[n]);
1196 assert(ret == 0);
1197}
1198
320ce850
CH
1199static int virtio_ccw_set_guest_notifier(VirtioCcwDevice *dev, int n,
1200 bool assign, bool with_irqfd)
1201{
f24a6840
PB
1202 VirtIODevice *vdev = virtio_bus_get_device(&dev->bus);
1203 VirtQueue *vq = virtio_get_queue(vdev, n);
320ce850 1204 EventNotifier *notifier = virtio_queue_get_guest_notifier(vq);
f24a6840 1205 VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
320ce850
CH
1206
1207 if (assign) {
1208 int r = event_notifier_init(notifier, 0);
1209
1210 if (r < 0) {
1211 return r;
1212 }
1213 virtio_queue_set_guest_notifier_fd_handler(vq, true, with_irqfd);
d426d9fb
CH
1214 if (with_irqfd) {
1215 r = virtio_ccw_add_irqfd(dev, n);
1216 if (r) {
1217 virtio_queue_set_guest_notifier_fd_handler(vq, false,
1218 with_irqfd);
1219 return r;
1220 }
1221 }
1222 /*
1223 * We do not support individual masking for channel devices, so we
1224 * need to manually trigger any guest masking callbacks here.
320ce850
CH
1225 */
1226 if (k->guest_notifier_mask) {
f24a6840 1227 k->guest_notifier_mask(vdev, n, false);
320ce850
CH
1228 }
1229 /* get lost events and re-inject */
1230 if (k->guest_notifier_pending &&
f24a6840 1231 k->guest_notifier_pending(vdev, n)) {
320ce850
CH
1232 event_notifier_set(notifier);
1233 }
1234 } else {
1235 if (k->guest_notifier_mask) {
f24a6840 1236 k->guest_notifier_mask(vdev, n, true);
320ce850 1237 }
d426d9fb
CH
1238 if (with_irqfd) {
1239 virtio_ccw_remove_irqfd(dev, n);
1240 }
320ce850
CH
1241 virtio_queue_set_guest_notifier_fd_handler(vq, false, with_irqfd);
1242 event_notifier_cleanup(notifier);
1243 }
1244 return 0;
1245}
1246
1247static int virtio_ccw_set_guest_notifiers(DeviceState *d, int nvqs,
1248 bool assigned)
1249{
1250 VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d);
f24a6840 1251 VirtIODevice *vdev = virtio_bus_get_device(&dev->bus);
d426d9fb 1252 bool with_irqfd = dev->sch->thinint_active && kvm_irqfds_enabled();
320ce850
CH
1253 int r, n;
1254
d426d9fb
CH
1255 if (with_irqfd && assigned) {
1256 /* irq routes need to be set up before assigning irqfds */
1257 r = virtio_ccw_setup_irqroutes(dev, nvqs);
1258 if (r < 0) {
1259 goto irqroute_error;
1260 }
1261 }
320ce850
CH
1262 for (n = 0; n < nvqs; n++) {
1263 if (!virtio_queue_get_num(vdev, n)) {
1264 break;
1265 }
d426d9fb 1266 r = virtio_ccw_set_guest_notifier(dev, n, assigned, with_irqfd);
320ce850
CH
1267 if (r < 0) {
1268 goto assign_error;
1269 }
1270 }
d426d9fb
CH
1271 if (with_irqfd && !assigned) {
1272 /* release irq routes after irqfds have been released */
1273 virtio_ccw_release_irqroutes(dev, nvqs);
1274 }
320ce850
CH
1275 return 0;
1276
1277assign_error:
1278 while (--n >= 0) {
1279 virtio_ccw_set_guest_notifier(dev, n, !assigned, false);
1280 }
d426d9fb
CH
1281irqroute_error:
1282 if (with_irqfd && assigned) {
1283 virtio_ccw_release_irqroutes(dev, nvqs);
1284 }
320ce850
CH
1285 return r;
1286}
1287
bcb2b582
JF
1288static void virtio_ccw_save_queue(DeviceState *d, int n, QEMUFile *f)
1289{
1290 VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d);
1291 VirtIODevice *vdev = virtio_bus_get_device(&dev->bus);
1292
1293 qemu_put_be16(f, virtio_queue_vector(vdev, n));
1294}
1295
1296static int virtio_ccw_load_queue(DeviceState *d, int n, QEMUFile *f)
1297{
1298 VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d);
1299 VirtIODevice *vdev = virtio_bus_get_device(&dev->bus);
1300 uint16_t vector;
1301
1302 qemu_get_be16s(f, &vector);
1303 virtio_queue_set_vector(vdev, n , vector);
1304
1305 return 0;
1306}
1307
1308static void virtio_ccw_save_config(DeviceState *d, QEMUFile *f)
1309{
1310 VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d);
1311 SubchDev *s = dev->sch;
1312
1313 subch_device_save(s, f);
1314 if (dev->indicators != NULL) {
1315 qemu_put_be32(f, dev->indicators->len);
1316 qemu_put_be64(f, dev->indicators->addr);
1317 } else {
1318 qemu_put_be32(f, 0);
1319 qemu_put_be64(f, 0UL);
1320 }
1321 if (dev->indicators2 != NULL) {
1322 qemu_put_be32(f, dev->indicators2->len);
1323 qemu_put_be64(f, dev->indicators2->addr);
1324 } else {
1325 qemu_put_be32(f, 0);
1326 qemu_put_be64(f, 0UL);
1327 }
1328 if (dev->summary_indicator != NULL) {
1329 qemu_put_be32(f, dev->summary_indicator->len);
1330 qemu_put_be64(f, dev->summary_indicator->addr);
1331 } else {
1332 qemu_put_be32(f, 0);
1333 qemu_put_be64(f, 0UL);
1334 }
1335 qemu_put_be64(f, dev->routes.adapter.ind_offset);
1336 qemu_put_byte(f, dev->thinint_isc);
1337}
1338
1339static int virtio_ccw_load_config(DeviceState *d, QEMUFile *f)
1340{
1341 VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d);
1342 SubchDev *s = dev->sch;
1343 int len;
1344
1345 s->driver_data = dev;
1346 subch_device_load(s, f);
1347 len = qemu_get_be32(f);
1348 if (len != 0) {
1349 dev->indicators = get_indicator(qemu_get_be64(f), len);
1350 } else {
1351 qemu_get_be64(f);
1352 dev->indicators = NULL;
1353 }
1354 len = qemu_get_be32(f);
1355 if (len != 0) {
1356 dev->indicators2 = get_indicator(qemu_get_be64(f), len);
1357 } else {
1358 qemu_get_be64(f);
1359 dev->indicators2 = NULL;
1360 }
1361 len = qemu_get_be32(f);
1362 if (len != 0) {
1363 dev->summary_indicator = get_indicator(qemu_get_be64(f), len);
1364 } else {
1365 qemu_get_be64(f);
1366 dev->summary_indicator = NULL;
1367 }
1368 dev->routes.adapter.ind_offset = qemu_get_be64(f);
1369 dev->thinint_isc = qemu_get_byte(f);
1370 if (s->thinint_active) {
1371 return css_register_io_adapter(CSS_IO_ADAPTER_VIRTIO,
1372 dev->thinint_isc, true, false,
1373 &dev->routes.adapter.adapter_id);
1374 }
1375
1376 return 0;
1377}
1378
a5cf2bb4
CH
1379/**************** Virtio-ccw Bus Device Descriptions *******************/
1380
a5cf2bb4
CH
1381static Property virtio_ccw_net_properties[] = {
1382 DEFINE_PROP_STRING("devno", VirtioCcwDevice, bus_id),
1383 DEFINE_VIRTIO_NET_FEATURES(VirtioCcwDevice, host_features[0]),
b4436a0b
CH
1384 DEFINE_PROP_BIT("ioeventfd", VirtioCcwDevice, flags,
1385 VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT, true),
a5cf2bb4
CH
1386 DEFINE_PROP_END_OF_LIST(),
1387};
1388
1389static void virtio_ccw_net_class_init(ObjectClass *klass, void *data)
1390{
1391 DeviceClass *dc = DEVICE_CLASS(klass);
1392 VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass);
1393
1394 k->init = virtio_ccw_net_init;
89334c8b 1395 k->exit = virtio_ccw_exit;
a5cf2bb4
CH
1396 dc->reset = virtio_ccw_reset;
1397 dc->props = virtio_ccw_net_properties;
1398}
1399
1400static const TypeInfo virtio_ccw_net = {
89334c8b 1401 .name = TYPE_VIRTIO_NET_CCW,
a5cf2bb4 1402 .parent = TYPE_VIRTIO_CCW_DEVICE,
89334c8b
FK
1403 .instance_size = sizeof(VirtIONetCcw),
1404 .instance_init = virtio_ccw_net_instance_init,
a5cf2bb4
CH
1405 .class_init = virtio_ccw_net_class_init,
1406};
1407
1408static Property virtio_ccw_blk_properties[] = {
1409 DEFINE_PROP_STRING("devno", VirtioCcwDevice, bus_id),
b4436a0b
CH
1410 DEFINE_PROP_BIT("ioeventfd", VirtioCcwDevice, flags,
1411 VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT, true),
a5cf2bb4
CH
1412 DEFINE_PROP_END_OF_LIST(),
1413};
1414
1415static void virtio_ccw_blk_class_init(ObjectClass *klass, void *data)
1416{
1417 DeviceClass *dc = DEVICE_CLASS(klass);
1418 VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass);
1419
1420 k->init = virtio_ccw_blk_init;
3400c455 1421 k->exit = virtio_ccw_exit;
a5cf2bb4
CH
1422 dc->reset = virtio_ccw_reset;
1423 dc->props = virtio_ccw_blk_properties;
1424}
1425
1426static const TypeInfo virtio_ccw_blk = {
3400c455 1427 .name = TYPE_VIRTIO_BLK_CCW,
a5cf2bb4 1428 .parent = TYPE_VIRTIO_CCW_DEVICE,
3400c455
FK
1429 .instance_size = sizeof(VirtIOBlkCcw),
1430 .instance_init = virtio_ccw_blk_instance_init,
a5cf2bb4
CH
1431 .class_init = virtio_ccw_blk_class_init,
1432};
1433
1434static Property virtio_ccw_serial_properties[] = {
1435 DEFINE_PROP_STRING("devno", VirtioCcwDevice, bus_id),
b4436a0b
CH
1436 DEFINE_PROP_BIT("ioeventfd", VirtioCcwDevice, flags,
1437 VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT, true),
a5cf2bb4
CH
1438 DEFINE_PROP_END_OF_LIST(),
1439};
1440
1441static void virtio_ccw_serial_class_init(ObjectClass *klass, void *data)
1442{
1443 DeviceClass *dc = DEVICE_CLASS(klass);
1444 VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass);
1445
1446 k->init = virtio_ccw_serial_init;
6acf69cd 1447 k->exit = virtio_ccw_exit;
a5cf2bb4
CH
1448 dc->reset = virtio_ccw_reset;
1449 dc->props = virtio_ccw_serial_properties;
1450}
1451
1452static const TypeInfo virtio_ccw_serial = {
6acf69cd 1453 .name = TYPE_VIRTIO_SERIAL_CCW,
a5cf2bb4 1454 .parent = TYPE_VIRTIO_CCW_DEVICE,
6acf69cd
FK
1455 .instance_size = sizeof(VirtioSerialCcw),
1456 .instance_init = virtio_ccw_serial_instance_init,
a5cf2bb4
CH
1457 .class_init = virtio_ccw_serial_class_init,
1458};
1459
1460static Property virtio_ccw_balloon_properties[] = {
1461 DEFINE_PROP_STRING("devno", VirtioCcwDevice, bus_id),
b4436a0b
CH
1462 DEFINE_PROP_BIT("ioeventfd", VirtioCcwDevice, flags,
1463 VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT, true),
a5cf2bb4
CH
1464 DEFINE_PROP_END_OF_LIST(),
1465};
1466
1467static void virtio_ccw_balloon_class_init(ObjectClass *klass, void *data)
1468{
1469 DeviceClass *dc = DEVICE_CLASS(klass);
1470 VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass);
1471
1472 k->init = virtio_ccw_balloon_init;
30bff6a0 1473 k->exit = virtio_ccw_exit;
a5cf2bb4
CH
1474 dc->reset = virtio_ccw_reset;
1475 dc->props = virtio_ccw_balloon_properties;
1476}
1477
1478static const TypeInfo virtio_ccw_balloon = {
30bff6a0 1479 .name = TYPE_VIRTIO_BALLOON_CCW,
a5cf2bb4 1480 .parent = TYPE_VIRTIO_CCW_DEVICE,
30bff6a0
FK
1481 .instance_size = sizeof(VirtIOBalloonCcw),
1482 .instance_init = virtio_ccw_balloon_instance_init,
a5cf2bb4
CH
1483 .class_init = virtio_ccw_balloon_class_init,
1484};
1485
1486static Property virtio_ccw_scsi_properties[] = {
1487 DEFINE_PROP_STRING("devno", VirtioCcwDevice, bus_id),
4bfeb18a 1488 DEFINE_VIRTIO_SCSI_FEATURES(VirtioCcwDevice, host_features[0]),
b4436a0b
CH
1489 DEFINE_PROP_BIT("ioeventfd", VirtioCcwDevice, flags,
1490 VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT, true),
a5cf2bb4
CH
1491 DEFINE_PROP_END_OF_LIST(),
1492};
1493
1494static void virtio_ccw_scsi_class_init(ObjectClass *klass, void *data)
1495{
1496 DeviceClass *dc = DEVICE_CLASS(klass);
1497 VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass);
1498
1499 k->init = virtio_ccw_scsi_init;
c908ea10 1500 k->exit = virtio_ccw_exit;
a5cf2bb4
CH
1501 dc->reset = virtio_ccw_reset;
1502 dc->props = virtio_ccw_scsi_properties;
1503}
1504
1505static const TypeInfo virtio_ccw_scsi = {
c908ea10 1506 .name = TYPE_VIRTIO_SCSI_CCW,
a5cf2bb4 1507 .parent = TYPE_VIRTIO_CCW_DEVICE,
c908ea10
FK
1508 .instance_size = sizeof(VirtIOSCSICcw),
1509 .instance_init = virtio_ccw_scsi_instance_init,
a5cf2bb4
CH
1510 .class_init = virtio_ccw_scsi_class_init,
1511};
1512
ccf6916c
PB
1513#ifdef CONFIG_VHOST_SCSI
1514static Property vhost_ccw_scsi_properties[] = {
1515 DEFINE_PROP_STRING("devno", VirtioCcwDevice, bus_id),
ccf6916c
PB
1516 DEFINE_PROP_END_OF_LIST(),
1517};
1518
1519static void vhost_ccw_scsi_class_init(ObjectClass *klass, void *data)
1520{
1521 DeviceClass *dc = DEVICE_CLASS(klass);
1522 VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass);
1523
1524 k->init = vhost_ccw_scsi_init;
1525 k->exit = virtio_ccw_exit;
1526 dc->reset = virtio_ccw_reset;
1527 dc->props = vhost_ccw_scsi_properties;
1528}
1529
1530static const TypeInfo vhost_ccw_scsi = {
1531 .name = TYPE_VHOST_SCSI_CCW,
1532 .parent = TYPE_VIRTIO_CCW_DEVICE,
4b7757ba 1533 .instance_size = sizeof(VHostSCSICcw),
ccf6916c
PB
1534 .instance_init = vhost_ccw_scsi_instance_init,
1535 .class_init = vhost_ccw_scsi_class_init,
1536};
1537#endif
1538
2db26d4c 1539static void virtio_ccw_rng_instance_init(Object *obj)
2362ecc5 1540{
2db26d4c 1541 VirtIORNGCcw *dev = VIRTIO_RNG_CCW(obj);
c8075caf
GA
1542
1543 virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
1544 TYPE_VIRTIO_RNG);
2362ecc5 1545 object_property_add_link(obj, "rng", TYPE_RNG_BACKEND,
9561fda8 1546 (Object **)&dev->vdev.conf.rng,
39f72ef9 1547 qdev_prop_allow_set_link_before_realize,
9561fda8 1548 OBJ_PROP_LINK_UNREF_ON_RELEASE, NULL);
2362ecc5
CH
1549}
1550
1551static Property virtio_ccw_rng_properties[] = {
1552 DEFINE_PROP_STRING("devno", VirtioCcwDevice, bus_id),
b4436a0b
CH
1553 DEFINE_PROP_BIT("ioeventfd", VirtioCcwDevice, flags,
1554 VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT, true),
2362ecc5
CH
1555 DEFINE_PROP_END_OF_LIST(),
1556};
1557
1558static void virtio_ccw_rng_class_init(ObjectClass *klass, void *data)
1559{
1560 DeviceClass *dc = DEVICE_CLASS(klass);
1561 VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass);
1562
1563 k->init = virtio_ccw_rng_init;
2db26d4c 1564 k->exit = virtio_ccw_exit;
2362ecc5
CH
1565 dc->reset = virtio_ccw_reset;
1566 dc->props = virtio_ccw_rng_properties;
1567}
1568
1569static const TypeInfo virtio_ccw_rng = {
2db26d4c 1570 .name = TYPE_VIRTIO_RNG_CCW,
2362ecc5 1571 .parent = TYPE_VIRTIO_CCW_DEVICE,
2db26d4c
FK
1572 .instance_size = sizeof(VirtIORNGCcw),
1573 .instance_init = virtio_ccw_rng_instance_init,
2362ecc5
CH
1574 .class_init = virtio_ccw_rng_class_init,
1575};
1576
a5cf2bb4
CH
1577static int virtio_ccw_busdev_init(DeviceState *dev)
1578{
1579 VirtioCcwDevice *_dev = (VirtioCcwDevice *)dev;
1580 VirtIOCCWDeviceClass *_info = VIRTIO_CCW_DEVICE_GET_CLASS(dev);
1581
1bf4d7aa 1582 virtio_ccw_bus_new(&_dev->bus, sizeof(_dev->bus), _dev);
a5cf2bb4
CH
1583
1584 return _info->init(_dev);
1585}
1586
1587static int virtio_ccw_busdev_exit(DeviceState *dev)
1588{
1589 VirtioCcwDevice *_dev = (VirtioCcwDevice *)dev;
1590 VirtIOCCWDeviceClass *_info = VIRTIO_CCW_DEVICE_GET_CLASS(dev);
1591
1592 return _info->exit(_dev);
1593}
1594
1595static int virtio_ccw_busdev_unplug(DeviceState *dev)
1596{
1597 VirtioCcwDevice *_dev = (VirtioCcwDevice *)dev;
1598 SubchDev *sch = _dev->sch;
1599
0b81c1ef
PB
1600 virtio_ccw_stop_ioeventfd(_dev);
1601
a5cf2bb4
CH
1602 /*
1603 * We should arrive here only for device_del, since we don't support
1604 * direct hot(un)plug of channels, but only through virtio.
1605 */
1606 assert(sch != NULL);
1607 /* Subchannel is now disabled and no longer valid. */
1608 sch->curr_status.pmcw.flags &= ~(PMCW_FLAGS_MASK_ENA |
1609 PMCW_FLAGS_MASK_DNV);
1610
1611 css_generate_sch_crws(sch->cssid, sch->ssid, sch->schid, 1, 0);
1612
02a5c4c9 1613 object_unparent(OBJECT(dev));
a5cf2bb4
CH
1614 return 0;
1615}
1616
85d1277e
ML
1617static Property virtio_ccw_properties[] = {
1618 DEFINE_VIRTIO_COMMON_FEATURES(VirtioCcwDevice, host_features[0]),
1619 DEFINE_PROP_END_OF_LIST(),
1620};
1621
a5cf2bb4
CH
1622static void virtio_ccw_device_class_init(ObjectClass *klass, void *data)
1623{
1624 DeviceClass *dc = DEVICE_CLASS(klass);
1625
85d1277e 1626 dc->props = virtio_ccw_properties;
a5cf2bb4
CH
1627 dc->init = virtio_ccw_busdev_init;
1628 dc->exit = virtio_ccw_busdev_exit;
1629 dc->unplug = virtio_ccw_busdev_unplug;
1630 dc->bus_type = TYPE_VIRTUAL_CSS_BUS;
1631
1632}
1633
1634static const TypeInfo virtio_ccw_device_info = {
1635 .name = TYPE_VIRTIO_CCW_DEVICE,
1636 .parent = TYPE_DEVICE,
1637 .instance_size = sizeof(VirtioCcwDevice),
1638 .class_init = virtio_ccw_device_class_init,
1639 .class_size = sizeof(VirtIOCCWDeviceClass),
1640 .abstract = true,
1641};
1642
1643/***************** Virtual-css Bus Bridge Device ********************/
1644/* Only required to have the virtio bus as child in the system bus */
1645
1646static int virtual_css_bridge_init(SysBusDevice *dev)
1647{
1648 /* nothing */
1649 return 0;
1650}
1651
1652static void virtual_css_bridge_class_init(ObjectClass *klass, void *data)
1653{
a5cf2bb4
CH
1654 SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
1655
1656 k->init = virtual_css_bridge_init;
a5cf2bb4
CH
1657}
1658
1659static const TypeInfo virtual_css_bridge_info = {
1660 .name = "virtual-css-bridge",
1661 .parent = TYPE_SYS_BUS_DEVICE,
1662 .instance_size = sizeof(SysBusDevice),
1663 .class_init = virtual_css_bridge_class_init,
1664};
1665
1666/* virtio-ccw-bus */
1667
1bf4d7aa
AF
1668static void virtio_ccw_bus_new(VirtioBusState *bus, size_t bus_size,
1669 VirtioCcwDevice *dev)
a5cf2bb4
CH
1670{
1671 DeviceState *qdev = DEVICE(dev);
1672 BusState *qbus;
f4dd69aa 1673 char virtio_bus_name[] = "virtio-bus";
a5cf2bb4 1674
fb17dfe0
AF
1675 qbus_create_inplace(bus, bus_size, TYPE_VIRTIO_CCW_BUS,
1676 qdev, virtio_bus_name);
a5cf2bb4 1677 qbus = BUS(bus);
cbd19063 1678 qbus->allow_hotplug = 1;
a5cf2bb4
CH
1679}
1680
1681static void virtio_ccw_bus_class_init(ObjectClass *klass, void *data)
1682{
1683 VirtioBusClass *k = VIRTIO_BUS_CLASS(klass);
1684 BusClass *bus_class = BUS_CLASS(klass);
1685
1686 bus_class->max_dev = 1;
1687 k->notify = virtio_ccw_notify;
1688 k->get_features = virtio_ccw_get_features;
b4436a0b 1689 k->vmstate_change = virtio_ccw_vmstate_change;
320ce850
CH
1690 k->query_guest_notifiers = virtio_ccw_query_guest_notifiers;
1691 k->set_host_notifier = virtio_ccw_set_host_notifier;
1692 k->set_guest_notifiers = virtio_ccw_set_guest_notifiers;
bcb2b582
JF
1693 k->save_queue = virtio_ccw_save_queue;
1694 k->load_queue = virtio_ccw_load_queue;
1695 k->save_config = virtio_ccw_save_config;
1696 k->load_config = virtio_ccw_load_config;
a5cf2bb4
CH
1697}
1698
1699static const TypeInfo virtio_ccw_bus_info = {
1700 .name = TYPE_VIRTIO_CCW_BUS,
1701 .parent = TYPE_VIRTIO_BUS,
1702 .instance_size = sizeof(VirtioCcwBusState),
1703 .class_init = virtio_ccw_bus_class_init,
1704};
1705
1706static void virtio_ccw_register(void)
1707{
1708 type_register_static(&virtio_ccw_bus_info);
1709 type_register_static(&virtual_css_bus_info);
1710 type_register_static(&virtio_ccw_device_info);
1711 type_register_static(&virtio_ccw_serial);
1712 type_register_static(&virtio_ccw_blk);
1713 type_register_static(&virtio_ccw_net);
1714 type_register_static(&virtio_ccw_balloon);
1715 type_register_static(&virtio_ccw_scsi);
b702d2ae 1716#ifdef CONFIG_VHOST_SCSI
ccf6916c 1717 type_register_static(&vhost_ccw_scsi);
b702d2ae 1718#endif
2362ecc5 1719 type_register_static(&virtio_ccw_rng);
a5cf2bb4
CH
1720 type_register_static(&virtual_css_bridge_info);
1721}
1722
1723type_init(virtio_ccw_register)