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/block-backend.h" 17 #include "sysemu/blockdev.h" 18 #include "sysemu/sysemu.h" 19 #include "sysemu/kvm.h" 20 #include "net/net.h" 21 #include "hw/virtio/virtio.h" 22 #include "hw/virtio/virtio-serial.h" 23 #include "hw/virtio/virtio-net.h" 24 #include "hw/sysbus.h" 25 #include "qemu/bitops.h" 26 #include "qemu/error-report.h" 27 #include "hw/virtio/virtio-access.h" 28 #include "hw/virtio/virtio-bus.h" 29 #include "hw/s390x/adapter.h" 30 #include "hw/s390x/s390_flic.h" 31 32 #include "hw/s390x/ioinst.h" 33 #include "hw/s390x/css.h" 34 #include "virtio-ccw.h" 35 #include "trace.h" 36 37 static void virtio_ccw_bus_new(VirtioBusState *bus, size_t bus_size, 38 VirtioCcwDevice *dev); 39 40 static void virtual_css_bus_reset(BusState *qbus) 41 { 42 /* This should actually be modelled via the generic css */ 43 css_reset(); 44 } 45 46 47 static void virtual_css_bus_class_init(ObjectClass *klass, void *data) 48 { 49 BusClass *k = BUS_CLASS(klass); 50 51 k->reset = virtual_css_bus_reset; 52 } 53 54 static const TypeInfo virtual_css_bus_info = { 55 .name = TYPE_VIRTUAL_CSS_BUS, 56 .parent = TYPE_BUS, 57 .instance_size = sizeof(VirtualCssBus), 58 .class_init = virtual_css_bus_class_init, 59 }; 60 61 VirtIODevice *virtio_ccw_get_vdev(SubchDev *sch) 62 { 63 VirtIODevice *vdev = NULL; 64 VirtioCcwDevice *dev = sch->driver_data; 65 66 if (dev) { 67 vdev = virtio_bus_get_device(&dev->bus); 68 } 69 return vdev; 70 } 71 72 static void virtio_ccw_start_ioeventfd(VirtioCcwDevice *dev) 73 { 74 virtio_bus_start_ioeventfd(&dev->bus); 75 } 76 77 static void virtio_ccw_stop_ioeventfd(VirtioCcwDevice *dev) 78 { 79 virtio_bus_stop_ioeventfd(&dev->bus); 80 } 81 82 static bool virtio_ccw_ioeventfd_started(DeviceState *d) 83 { 84 VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d); 85 86 return dev->ioeventfd_started; 87 } 88 89 static void virtio_ccw_ioeventfd_set_started(DeviceState *d, bool started, 90 bool err) 91 { 92 VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d); 93 94 dev->ioeventfd_started = started; 95 if (err) { 96 /* Disable ioeventfd for this device. */ 97 dev->flags &= ~VIRTIO_CCW_FLAG_USE_IOEVENTFD; 98 } 99 } 100 101 static bool virtio_ccw_ioeventfd_disabled(DeviceState *d) 102 { 103 VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d); 104 105 return dev->ioeventfd_disabled || 106 !(dev->flags & VIRTIO_CCW_FLAG_USE_IOEVENTFD); 107 } 108 109 static void virtio_ccw_ioeventfd_set_disabled(DeviceState *d, bool disabled) 110 { 111 VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d); 112 113 dev->ioeventfd_disabled = disabled; 114 } 115 116 static int virtio_ccw_ioeventfd_assign(DeviceState *d, EventNotifier *notifier, 117 int n, bool assign) 118 { 119 VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d); 120 SubchDev *sch = dev->sch; 121 uint32_t sch_id = (css_build_subchannel_id(sch) << 16) | sch->schid; 122 123 return s390_assign_subch_ioeventfd(notifier, sch_id, n, assign); 124 } 125 126 VirtualCssBus *virtual_css_bus_init(void) 127 { 128 VirtualCssBus *cbus; 129 BusState *bus; 130 DeviceState *dev; 131 132 /* Create bridge device */ 133 dev = qdev_create(NULL, "virtual-css-bridge"); 134 qdev_init_nofail(dev); 135 136 /* Create bus on bridge device */ 137 bus = qbus_create(TYPE_VIRTUAL_CSS_BUS, dev, "virtual-css"); 138 cbus = VIRTUAL_CSS_BUS(bus); 139 140 /* Enable hotplugging */ 141 qbus_set_hotplug_handler(bus, dev, &error_abort); 142 143 return cbus; 144 } 145 146 /* Communication blocks used by several channel commands. */ 147 typedef struct VqInfoBlockLegacy { 148 uint64_t queue; 149 uint32_t align; 150 uint16_t index; 151 uint16_t num; 152 } QEMU_PACKED VqInfoBlockLegacy; 153 154 typedef struct VqInfoBlock { 155 uint64_t desc; 156 uint32_t res0; 157 uint16_t index; 158 uint16_t num; 159 uint64_t avail; 160 uint64_t used; 161 } QEMU_PACKED VqInfoBlock; 162 163 typedef struct VqConfigBlock { 164 uint16_t index; 165 uint16_t num_max; 166 } QEMU_PACKED VqConfigBlock; 167 168 typedef struct VirtioFeatDesc { 169 uint32_t features; 170 uint8_t index; 171 } QEMU_PACKED VirtioFeatDesc; 172 173 typedef struct VirtioThinintInfo { 174 hwaddr summary_indicator; 175 hwaddr device_indicator; 176 uint64_t ind_bit; 177 uint8_t isc; 178 } QEMU_PACKED VirtioThinintInfo; 179 180 typedef struct VirtioRevInfo { 181 uint16_t revision; 182 uint16_t length; 183 uint8_t data[0]; 184 } QEMU_PACKED VirtioRevInfo; 185 186 /* Specify where the virtqueues for the subchannel are in guest memory. */ 187 static int virtio_ccw_set_vqs(SubchDev *sch, VqInfoBlock *info, 188 VqInfoBlockLegacy *linfo) 189 { 190 VirtIODevice *vdev = virtio_ccw_get_vdev(sch); 191 uint16_t index = info ? info->index : linfo->index; 192 uint16_t num = info ? info->num : linfo->num; 193 uint64_t desc = info ? info->desc : linfo->queue; 194 195 if (index >= VIRTIO_CCW_QUEUE_MAX) { 196 return -EINVAL; 197 } 198 199 /* Current code in virtio.c relies on 4K alignment. */ 200 if (linfo && desc && (linfo->align != 4096)) { 201 return -EINVAL; 202 } 203 204 if (!vdev) { 205 return -EINVAL; 206 } 207 208 if (info) { 209 virtio_queue_set_rings(vdev, index, desc, info->avail, info->used); 210 } else { 211 virtio_queue_set_addr(vdev, index, desc); 212 } 213 if (!desc) { 214 virtio_queue_set_vector(vdev, index, VIRTIO_NO_VECTOR); 215 } else { 216 if (info) { 217 /* virtio-1 allows changing the ring size. */ 218 if (virtio_queue_get_num(vdev, index) < num) { 219 /* Fail if we exceed the maximum number. */ 220 return -EINVAL; 221 } 222 virtio_queue_set_num(vdev, index, num); 223 } else if (virtio_queue_get_num(vdev, index) > num) { 224 /* Fail if we don't have a big enough queue. */ 225 return -EINVAL; 226 } 227 /* We ignore possible increased num for legacy for compatibility. */ 228 virtio_queue_set_vector(vdev, index, index); 229 } 230 /* tell notify handler in case of config change */ 231 vdev->config_vector = VIRTIO_CCW_QUEUE_MAX; 232 return 0; 233 } 234 235 static void virtio_ccw_reset_virtio(VirtioCcwDevice *dev, VirtIODevice *vdev) 236 { 237 virtio_ccw_stop_ioeventfd(dev); 238 virtio_reset(vdev); 239 if (dev->indicators) { 240 release_indicator(&dev->routes.adapter, dev->indicators); 241 dev->indicators = NULL; 242 } 243 if (dev->indicators2) { 244 release_indicator(&dev->routes.adapter, dev->indicators2); 245 dev->indicators2 = NULL; 246 } 247 if (dev->summary_indicator) { 248 release_indicator(&dev->routes.adapter, dev->summary_indicator); 249 dev->summary_indicator = NULL; 250 } 251 dev->sch->thinint_active = false; 252 } 253 254 static int virtio_ccw_handle_set_vq(SubchDev *sch, CCW1 ccw, bool check_len, 255 bool is_legacy) 256 { 257 int ret; 258 VqInfoBlock info; 259 VqInfoBlockLegacy linfo; 260 size_t info_len = is_legacy ? sizeof(linfo) : sizeof(info); 261 262 if (check_len) { 263 if (ccw.count != info_len) { 264 return -EINVAL; 265 } 266 } else if (ccw.count < info_len) { 267 /* Can't execute command. */ 268 return -EINVAL; 269 } 270 if (!ccw.cda) { 271 return -EFAULT; 272 } 273 if (is_legacy) { 274 linfo.queue = address_space_ldq_be(&address_space_memory, ccw.cda, 275 MEMTXATTRS_UNSPECIFIED, NULL); 276 linfo.align = address_space_ldl_be(&address_space_memory, 277 ccw.cda + sizeof(linfo.queue), 278 MEMTXATTRS_UNSPECIFIED, 279 NULL); 280 linfo.index = address_space_lduw_be(&address_space_memory, 281 ccw.cda + sizeof(linfo.queue) 282 + sizeof(linfo.align), 283 MEMTXATTRS_UNSPECIFIED, 284 NULL); 285 linfo.num = address_space_lduw_be(&address_space_memory, 286 ccw.cda + sizeof(linfo.queue) 287 + sizeof(linfo.align) 288 + sizeof(linfo.index), 289 MEMTXATTRS_UNSPECIFIED, 290 NULL); 291 ret = virtio_ccw_set_vqs(sch, NULL, &linfo); 292 } else { 293 info.desc = address_space_ldq_be(&address_space_memory, ccw.cda, 294 MEMTXATTRS_UNSPECIFIED, NULL); 295 info.index = address_space_lduw_be(&address_space_memory, 296 ccw.cda + sizeof(info.desc) 297 + sizeof(info.res0), 298 MEMTXATTRS_UNSPECIFIED, NULL); 299 info.num = address_space_lduw_be(&address_space_memory, 300 ccw.cda + sizeof(info.desc) 301 + sizeof(info.res0) 302 + sizeof(info.index), 303 MEMTXATTRS_UNSPECIFIED, NULL); 304 info.avail = address_space_ldq_be(&address_space_memory, 305 ccw.cda + sizeof(info.desc) 306 + sizeof(info.res0) 307 + sizeof(info.index) 308 + sizeof(info.num), 309 MEMTXATTRS_UNSPECIFIED, NULL); 310 info.used = address_space_ldq_be(&address_space_memory, 311 ccw.cda + sizeof(info.desc) 312 + sizeof(info.res0) 313 + sizeof(info.index) 314 + sizeof(info.num) 315 + sizeof(info.avail), 316 MEMTXATTRS_UNSPECIFIED, NULL); 317 ret = virtio_ccw_set_vqs(sch, &info, NULL); 318 } 319 sch->curr_status.scsw.count = 0; 320 return ret; 321 } 322 323 static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw) 324 { 325 int ret; 326 VirtioRevInfo revinfo; 327 uint8_t status; 328 VirtioFeatDesc features; 329 void *config; 330 hwaddr indicators; 331 VqConfigBlock vq_config; 332 VirtioCcwDevice *dev = sch->driver_data; 333 VirtIODevice *vdev = virtio_ccw_get_vdev(sch); 334 bool check_len; 335 int len; 336 hwaddr hw_len; 337 VirtioThinintInfo *thinint; 338 339 if (!dev) { 340 return -EINVAL; 341 } 342 343 trace_virtio_ccw_interpret_ccw(sch->cssid, sch->ssid, sch->schid, 344 ccw.cmd_code); 345 check_len = !((ccw.flags & CCW_FLAG_SLI) && !(ccw.flags & CCW_FLAG_DC)); 346 347 /* Look at the command. */ 348 switch (ccw.cmd_code) { 349 case CCW_CMD_SET_VQ: 350 ret = virtio_ccw_handle_set_vq(sch, ccw, check_len, dev->revision < 1); 351 break; 352 case CCW_CMD_VDEV_RESET: 353 virtio_ccw_reset_virtio(dev, vdev); 354 ret = 0; 355 break; 356 case CCW_CMD_READ_FEAT: 357 if (check_len) { 358 if (ccw.count != sizeof(features)) { 359 ret = -EINVAL; 360 break; 361 } 362 } else if (ccw.count < sizeof(features)) { 363 /* Can't execute command. */ 364 ret = -EINVAL; 365 break; 366 } 367 if (!ccw.cda) { 368 ret = -EFAULT; 369 } else { 370 features.index = address_space_ldub(&address_space_memory, 371 ccw.cda 372 + sizeof(features.features), 373 MEMTXATTRS_UNSPECIFIED, 374 NULL); 375 if (features.index == 0) { 376 if (dev->revision >= 1) { 377 /* Don't offer legacy features for modern devices. */ 378 features.features = (uint32_t) 379 (vdev->host_features & ~VIRTIO_LEGACY_FEATURES); 380 } else { 381 features.features = (uint32_t)vdev->host_features; 382 } 383 } else if ((features.index == 1) && (dev->revision >= 1)) { 384 /* 385 * Only offer feature bits beyond 31 if the guest has 386 * negotiated at least revision 1. 387 */ 388 features.features = (uint32_t)(vdev->host_features >> 32); 389 } else { 390 /* Return zeroes if the guest supports more feature bits. */ 391 features.features = 0; 392 } 393 address_space_stl_le(&address_space_memory, ccw.cda, 394 features.features, MEMTXATTRS_UNSPECIFIED, 395 NULL); 396 sch->curr_status.scsw.count = ccw.count - sizeof(features); 397 ret = 0; 398 } 399 break; 400 case CCW_CMD_WRITE_FEAT: 401 if (check_len) { 402 if (ccw.count != sizeof(features)) { 403 ret = -EINVAL; 404 break; 405 } 406 } else if (ccw.count < sizeof(features)) { 407 /* Can't execute command. */ 408 ret = -EINVAL; 409 break; 410 } 411 if (!ccw.cda) { 412 ret = -EFAULT; 413 } else { 414 features.index = address_space_ldub(&address_space_memory, 415 ccw.cda 416 + sizeof(features.features), 417 MEMTXATTRS_UNSPECIFIED, 418 NULL); 419 features.features = address_space_ldl_le(&address_space_memory, 420 ccw.cda, 421 MEMTXATTRS_UNSPECIFIED, 422 NULL); 423 if (features.index == 0) { 424 virtio_set_features(vdev, 425 (vdev->guest_features & 0xffffffff00000000ULL) | 426 features.features); 427 } else if ((features.index == 1) && (dev->revision >= 1)) { 428 /* 429 * If the guest did not negotiate at least revision 1, 430 * we did not offer it any feature bits beyond 31. Such a 431 * guest passing us any bit here is therefore buggy. 432 */ 433 virtio_set_features(vdev, 434 (vdev->guest_features & 0x00000000ffffffffULL) | 435 ((uint64_t)features.features << 32)); 436 } else { 437 /* 438 * If the guest supports more feature bits, assert that it 439 * passes us zeroes for those we don't support. 440 */ 441 if (features.features) { 442 fprintf(stderr, "Guest bug: features[%i]=%x (expected 0)\n", 443 features.index, features.features); 444 /* XXX: do a unit check here? */ 445 } 446 } 447 sch->curr_status.scsw.count = ccw.count - sizeof(features); 448 ret = 0; 449 } 450 break; 451 case CCW_CMD_READ_CONF: 452 if (check_len) { 453 if (ccw.count > vdev->config_len) { 454 ret = -EINVAL; 455 break; 456 } 457 } 458 len = MIN(ccw.count, vdev->config_len); 459 if (!ccw.cda) { 460 ret = -EFAULT; 461 } else { 462 virtio_bus_get_vdev_config(&dev->bus, vdev->config); 463 /* XXX config space endianness */ 464 cpu_physical_memory_write(ccw.cda, vdev->config, len); 465 sch->curr_status.scsw.count = ccw.count - len; 466 ret = 0; 467 } 468 break; 469 case CCW_CMD_WRITE_CONF: 470 if (check_len) { 471 if (ccw.count > vdev->config_len) { 472 ret = -EINVAL; 473 break; 474 } 475 } 476 len = MIN(ccw.count, vdev->config_len); 477 hw_len = len; 478 if (!ccw.cda) { 479 ret = -EFAULT; 480 } else { 481 config = cpu_physical_memory_map(ccw.cda, &hw_len, 0); 482 if (!config) { 483 ret = -EFAULT; 484 } else { 485 len = hw_len; 486 /* XXX config space endianness */ 487 memcpy(vdev->config, config, len); 488 cpu_physical_memory_unmap(config, hw_len, 0, hw_len); 489 virtio_bus_set_vdev_config(&dev->bus, vdev->config); 490 sch->curr_status.scsw.count = ccw.count - len; 491 ret = 0; 492 } 493 } 494 break; 495 case CCW_CMD_WRITE_STATUS: 496 if (check_len) { 497 if (ccw.count != sizeof(status)) { 498 ret = -EINVAL; 499 break; 500 } 501 } else if (ccw.count < sizeof(status)) { 502 /* Can't execute command. */ 503 ret = -EINVAL; 504 break; 505 } 506 if (!ccw.cda) { 507 ret = -EFAULT; 508 } else { 509 status = address_space_ldub(&address_space_memory, ccw.cda, 510 MEMTXATTRS_UNSPECIFIED, NULL); 511 if (!(status & VIRTIO_CONFIG_S_DRIVER_OK)) { 512 virtio_ccw_stop_ioeventfd(dev); 513 } 514 if (virtio_set_status(vdev, status) == 0) { 515 if (vdev->status == 0) { 516 virtio_ccw_reset_virtio(dev, vdev); 517 } 518 if (status & VIRTIO_CONFIG_S_DRIVER_OK) { 519 virtio_ccw_start_ioeventfd(dev); 520 } 521 sch->curr_status.scsw.count = ccw.count - sizeof(status); 522 ret = 0; 523 } else { 524 /* Trigger a command reject. */ 525 ret = -ENOSYS; 526 } 527 } 528 break; 529 case CCW_CMD_SET_IND: 530 if (check_len) { 531 if (ccw.count != sizeof(indicators)) { 532 ret = -EINVAL; 533 break; 534 } 535 } else if (ccw.count < sizeof(indicators)) { 536 /* Can't execute command. */ 537 ret = -EINVAL; 538 break; 539 } 540 if (sch->thinint_active) { 541 /* Trigger a command reject. */ 542 ret = -ENOSYS; 543 break; 544 } 545 if (!ccw.cda) { 546 ret = -EFAULT; 547 } else { 548 indicators = address_space_ldq_be(&address_space_memory, ccw.cda, 549 MEMTXATTRS_UNSPECIFIED, NULL); 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 indicators = address_space_ldq_be(&address_space_memory, ccw.cda, 570 MEMTXATTRS_UNSPECIFIED, NULL); 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 vq_config.index = address_space_lduw_be(&address_space_memory, 591 ccw.cda, 592 MEMTXATTRS_UNSPECIFIED, 593 NULL); 594 if (vq_config.index >= VIRTIO_CCW_QUEUE_MAX) { 595 ret = -EINVAL; 596 break; 597 } 598 vq_config.num_max = virtio_queue_get_num(vdev, 599 vq_config.index); 600 address_space_stw_be(&address_space_memory, 601 ccw.cda + sizeof(vq_config.index), 602 vq_config.num_max, 603 MEMTXATTRS_UNSPECIFIED, 604 NULL); 605 sch->curr_status.scsw.count = ccw.count - sizeof(vq_config); 606 ret = 0; 607 } 608 break; 609 case CCW_CMD_SET_IND_ADAPTER: 610 if (check_len) { 611 if (ccw.count != sizeof(*thinint)) { 612 ret = -EINVAL; 613 break; 614 } 615 } else if (ccw.count < sizeof(*thinint)) { 616 /* Can't execute command. */ 617 ret = -EINVAL; 618 break; 619 } 620 len = sizeof(*thinint); 621 hw_len = len; 622 if (!ccw.cda) { 623 ret = -EFAULT; 624 } else if (dev->indicators && !sch->thinint_active) { 625 /* Trigger a command reject. */ 626 ret = -ENOSYS; 627 } else { 628 thinint = cpu_physical_memory_map(ccw.cda, &hw_len, 0); 629 if (!thinint) { 630 ret = -EFAULT; 631 } else { 632 uint64_t ind_bit = ldq_be_p(&thinint->ind_bit); 633 634 len = hw_len; 635 dev->summary_indicator = 636 get_indicator(ldq_be_p(&thinint->summary_indicator), 637 sizeof(uint8_t)); 638 dev->indicators = 639 get_indicator(ldq_be_p(&thinint->device_indicator), 640 ind_bit / 8 + 1); 641 dev->thinint_isc = thinint->isc; 642 dev->routes.adapter.ind_offset = ind_bit; 643 dev->routes.adapter.summary_offset = 7; 644 cpu_physical_memory_unmap(thinint, hw_len, 0, hw_len); 645 ret = css_register_io_adapter(CSS_IO_ADAPTER_VIRTIO, 646 dev->thinint_isc, true, false, 647 &dev->routes.adapter.adapter_id); 648 assert(ret == 0); 649 sch->thinint_active = ((dev->indicators != NULL) && 650 (dev->summary_indicator != NULL)); 651 sch->curr_status.scsw.count = ccw.count - len; 652 ret = 0; 653 } 654 } 655 break; 656 case CCW_CMD_SET_VIRTIO_REV: 657 len = sizeof(revinfo); 658 if (ccw.count < len) { 659 ret = -EINVAL; 660 break; 661 } 662 if (!ccw.cda) { 663 ret = -EFAULT; 664 break; 665 } 666 revinfo.revision = 667 address_space_lduw_be(&address_space_memory, ccw.cda, 668 MEMTXATTRS_UNSPECIFIED, NULL); 669 revinfo.length = 670 address_space_lduw_be(&address_space_memory, 671 ccw.cda + sizeof(revinfo.revision), 672 MEMTXATTRS_UNSPECIFIED, NULL); 673 if (ccw.count < len + revinfo.length || 674 (check_len && ccw.count > len + revinfo.length)) { 675 ret = -EINVAL; 676 break; 677 } 678 /* 679 * Once we start to support revisions with additional data, we'll 680 * need to fetch it here. Nothing to do for now, though. 681 */ 682 if (dev->revision >= 0 || 683 revinfo.revision > virtio_ccw_rev_max(dev)) { 684 ret = -ENOSYS; 685 break; 686 } 687 ret = 0; 688 dev->revision = revinfo.revision; 689 break; 690 default: 691 ret = -ENOSYS; 692 break; 693 } 694 return ret; 695 } 696 697 static void virtio_sch_disable_cb(SubchDev *sch) 698 { 699 VirtioCcwDevice *dev = sch->driver_data; 700 701 dev->revision = -1; 702 } 703 704 static void virtio_ccw_device_realize(VirtioCcwDevice *dev, Error **errp) 705 { 706 unsigned int schid; 707 bool found = false; 708 SubchDev *sch; 709 Error *err = NULL; 710 VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_GET_CLASS(dev); 711 712 sch = g_malloc0(sizeof(SubchDev)); 713 714 sch->driver_data = dev; 715 dev->sch = sch; 716 717 dev->indicators = NULL; 718 719 /* Initialize subchannel structure. */ 720 sch->channel_prog = 0x0; 721 sch->last_cmd_valid = false; 722 sch->thinint_active = false; 723 /* 724 * Use a device number if provided. Otherwise, fall back to subchannel 725 * number. 726 */ 727 if (dev->bus_id.valid) { 728 /* Enforce use of virtual cssid. */ 729 if (dev->bus_id.cssid != VIRTUAL_CSSID) { 730 error_setg(errp, "cssid %x not valid for virtio devices", 731 dev->bus_id.cssid); 732 goto out_err; 733 } 734 if (css_devno_used(dev->bus_id.cssid, dev->bus_id.ssid, 735 dev->bus_id.devid)) { 736 error_setg(errp, "Device %x.%x.%04x already exists", 737 dev->bus_id.cssid, dev->bus_id.ssid, 738 dev->bus_id.devid); 739 goto out_err; 740 } 741 sch->cssid = dev->bus_id.cssid; 742 sch->ssid = dev->bus_id.ssid; 743 sch->devno = dev->bus_id.devid; 744 745 /* Find the next free id. */ 746 for (schid = 0; schid <= MAX_SCHID; schid++) { 747 if (!css_find_subch(1, sch->cssid, sch->ssid, schid)) { 748 sch->schid = schid; 749 css_subch_assign(sch->cssid, sch->ssid, sch->schid, 750 sch->devno, sch); 751 found = true; 752 break; 753 } 754 } 755 if (!found) { 756 error_setg(errp, "No free subchannel found for %x.%x.%04x", 757 sch->cssid, sch->ssid, sch->devno); 758 goto out_err; 759 } 760 trace_virtio_ccw_new_device(sch->cssid, sch->ssid, sch->schid, 761 sch->devno, "user-configured"); 762 } else { 763 unsigned int cssid = VIRTUAL_CSSID, ssid, devno; 764 765 for (ssid = 0; ssid <= MAX_SSID; ssid++) { 766 for (schid = 0; schid <= MAX_SCHID; schid++) { 767 if (!css_find_subch(1, cssid, ssid, schid)) { 768 sch->cssid = cssid; 769 sch->ssid = ssid; 770 sch->schid = schid; 771 devno = schid; 772 /* 773 * If the devno is already taken, look further in this 774 * subchannel set. 775 */ 776 while (css_devno_used(cssid, ssid, devno)) { 777 if (devno == MAX_SCHID) { 778 devno = 0; 779 } else if (devno == schid - 1) { 780 error_setg(errp, "No free devno found"); 781 goto out_err; 782 } else { 783 devno++; 784 } 785 } 786 sch->devno = devno; 787 css_subch_assign(cssid, ssid, schid, devno, sch); 788 found = true; 789 break; 790 } 791 } 792 if (found) { 793 break; 794 } 795 } 796 if (!found) { 797 error_setg(errp, "Virtual channel subsystem is full!"); 798 goto out_err; 799 } 800 trace_virtio_ccw_new_device(cssid, ssid, schid, devno, 801 "auto-configured"); 802 } 803 804 /* Build initial schib. */ 805 css_sch_build_virtual_schib(sch, 0, VIRTIO_CCW_CHPID_TYPE); 806 807 sch->ccw_cb = virtio_ccw_cb; 808 sch->disable_cb = virtio_sch_disable_cb; 809 810 /* Build senseid data. */ 811 memset(&sch->id, 0, sizeof(SenseId)); 812 sch->id.reserved = 0xff; 813 sch->id.cu_type = VIRTIO_CCW_CU_TYPE; 814 815 dev->revision = -1; 816 817 if (k->realize) { 818 k->realize(dev, &err); 819 } 820 if (err) { 821 error_propagate(errp, err); 822 css_subch_assign(sch->cssid, sch->ssid, sch->schid, sch->devno, NULL); 823 goto out_err; 824 } 825 826 return; 827 828 out_err: 829 dev->sch = NULL; 830 g_free(sch); 831 } 832 833 static int virtio_ccw_exit(VirtioCcwDevice *dev) 834 { 835 SubchDev *sch = dev->sch; 836 837 if (sch) { 838 css_subch_assign(sch->cssid, sch->ssid, sch->schid, sch->devno, NULL); 839 g_free(sch); 840 } 841 if (dev->indicators) { 842 release_indicator(&dev->routes.adapter, dev->indicators); 843 dev->indicators = NULL; 844 } 845 return 0; 846 } 847 848 static void virtio_ccw_net_realize(VirtioCcwDevice *ccw_dev, Error **errp) 849 { 850 DeviceState *qdev = DEVICE(ccw_dev); 851 VirtIONetCcw *dev = VIRTIO_NET_CCW(ccw_dev); 852 DeviceState *vdev = DEVICE(&dev->vdev); 853 854 virtio_net_set_netclient_name(&dev->vdev, qdev->id, 855 object_get_typename(OBJECT(qdev))); 856 qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus)); 857 object_property_set_bool(OBJECT(vdev), true, "realized", errp); 858 } 859 860 static void virtio_ccw_net_instance_init(Object *obj) 861 { 862 VirtIONetCcw *dev = VIRTIO_NET_CCW(obj); 863 864 virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev), 865 TYPE_VIRTIO_NET); 866 object_property_add_alias(obj, "bootindex", OBJECT(&dev->vdev), 867 "bootindex", &error_abort); 868 } 869 870 static void virtio_ccw_blk_realize(VirtioCcwDevice *ccw_dev, Error **errp) 871 { 872 VirtIOBlkCcw *dev = VIRTIO_BLK_CCW(ccw_dev); 873 DeviceState *vdev = DEVICE(&dev->vdev); 874 875 qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus)); 876 object_property_set_bool(OBJECT(vdev), true, "realized", errp); 877 } 878 879 static void virtio_ccw_blk_instance_init(Object *obj) 880 { 881 VirtIOBlkCcw *dev = VIRTIO_BLK_CCW(obj); 882 883 virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev), 884 TYPE_VIRTIO_BLK); 885 object_property_add_alias(obj, "iothread", OBJECT(&dev->vdev),"iothread", 886 &error_abort); 887 object_property_add_alias(obj, "bootindex", OBJECT(&dev->vdev), 888 "bootindex", &error_abort); 889 } 890 891 static void virtio_ccw_serial_realize(VirtioCcwDevice *ccw_dev, Error **errp) 892 { 893 VirtioSerialCcw *dev = VIRTIO_SERIAL_CCW(ccw_dev); 894 DeviceState *vdev = DEVICE(&dev->vdev); 895 DeviceState *proxy = DEVICE(ccw_dev); 896 char *bus_name; 897 898 /* 899 * For command line compatibility, this sets the virtio-serial-device bus 900 * name as before. 901 */ 902 if (proxy->id) { 903 bus_name = g_strdup_printf("%s.0", proxy->id); 904 virtio_device_set_child_bus_name(VIRTIO_DEVICE(vdev), bus_name); 905 g_free(bus_name); 906 } 907 908 qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus)); 909 object_property_set_bool(OBJECT(vdev), true, "realized", errp); 910 } 911 912 913 static void virtio_ccw_serial_instance_init(Object *obj) 914 { 915 VirtioSerialCcw *dev = VIRTIO_SERIAL_CCW(obj); 916 917 virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev), 918 TYPE_VIRTIO_SERIAL); 919 } 920 921 static void virtio_ccw_balloon_realize(VirtioCcwDevice *ccw_dev, Error **errp) 922 { 923 VirtIOBalloonCcw *dev = VIRTIO_BALLOON_CCW(ccw_dev); 924 DeviceState *vdev = DEVICE(&dev->vdev); 925 926 qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus)); 927 object_property_set_bool(OBJECT(vdev), true, "realized", errp); 928 } 929 930 static void virtio_ccw_balloon_instance_init(Object *obj) 931 { 932 VirtIOBalloonCcw *dev = VIRTIO_BALLOON_CCW(obj); 933 934 virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev), 935 TYPE_VIRTIO_BALLOON); 936 object_property_add_alias(obj, "guest-stats", OBJECT(&dev->vdev), 937 "guest-stats", &error_abort); 938 object_property_add_alias(obj, "guest-stats-polling-interval", 939 OBJECT(&dev->vdev), 940 "guest-stats-polling-interval", &error_abort); 941 } 942 943 static void virtio_ccw_scsi_realize(VirtioCcwDevice *ccw_dev, Error **errp) 944 { 945 VirtIOSCSICcw *dev = VIRTIO_SCSI_CCW(ccw_dev); 946 DeviceState *vdev = DEVICE(&dev->vdev); 947 DeviceState *qdev = DEVICE(ccw_dev); 948 char *bus_name; 949 950 /* 951 * For command line compatibility, this sets the virtio-scsi-device bus 952 * name as before. 953 */ 954 if (qdev->id) { 955 bus_name = g_strdup_printf("%s.0", qdev->id); 956 virtio_device_set_child_bus_name(VIRTIO_DEVICE(vdev), bus_name); 957 g_free(bus_name); 958 } 959 960 qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus)); 961 object_property_set_bool(OBJECT(vdev), true, "realized", errp); 962 } 963 964 static void virtio_ccw_scsi_instance_init(Object *obj) 965 { 966 VirtIOSCSICcw *dev = VIRTIO_SCSI_CCW(obj); 967 968 virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev), 969 TYPE_VIRTIO_SCSI); 970 object_property_add_alias(obj, "iothread", OBJECT(&dev->vdev), "iothread", 971 &error_abort); 972 } 973 974 #ifdef CONFIG_VHOST_SCSI 975 static void vhost_ccw_scsi_realize(VirtioCcwDevice *ccw_dev, Error **errp) 976 { 977 VHostSCSICcw *dev = VHOST_SCSI_CCW(ccw_dev); 978 DeviceState *vdev = DEVICE(&dev->vdev); 979 980 qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus)); 981 object_property_set_bool(OBJECT(vdev), true, "realized", errp); 982 } 983 984 static void vhost_ccw_scsi_instance_init(Object *obj) 985 { 986 VHostSCSICcw *dev = VHOST_SCSI_CCW(obj); 987 988 virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev), 989 TYPE_VHOST_SCSI); 990 } 991 #endif 992 993 static void virtio_ccw_rng_realize(VirtioCcwDevice *ccw_dev, Error **errp) 994 { 995 VirtIORNGCcw *dev = VIRTIO_RNG_CCW(ccw_dev); 996 DeviceState *vdev = DEVICE(&dev->vdev); 997 Error *err = NULL; 998 999 qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus)); 1000 object_property_set_bool(OBJECT(vdev), true, "realized", &err); 1001 if (err) { 1002 error_propagate(errp, err); 1003 return; 1004 } 1005 1006 object_property_set_link(OBJECT(dev), 1007 OBJECT(dev->vdev.conf.rng), "rng", 1008 NULL); 1009 } 1010 1011 /* DeviceState to VirtioCcwDevice. Note: used on datapath, 1012 * be careful and test performance if you change this. 1013 */ 1014 static inline VirtioCcwDevice *to_virtio_ccw_dev_fast(DeviceState *d) 1015 { 1016 return container_of(d, VirtioCcwDevice, parent_obj); 1017 } 1018 1019 static uint8_t virtio_set_ind_atomic(SubchDev *sch, uint64_t ind_loc, 1020 uint8_t to_be_set) 1021 { 1022 uint8_t ind_old, ind_new; 1023 hwaddr len = 1; 1024 uint8_t *ind_addr; 1025 1026 ind_addr = cpu_physical_memory_map(ind_loc, &len, 1); 1027 if (!ind_addr) { 1028 error_report("%s(%x.%x.%04x): unable to access indicator", 1029 __func__, sch->cssid, sch->ssid, sch->schid); 1030 return -1; 1031 } 1032 do { 1033 ind_old = *ind_addr; 1034 ind_new = ind_old | to_be_set; 1035 } while (atomic_cmpxchg(ind_addr, ind_old, ind_new) != ind_old); 1036 trace_virtio_ccw_set_ind(ind_loc, ind_old, ind_new); 1037 cpu_physical_memory_unmap(ind_addr, len, 1, len); 1038 1039 return ind_old; 1040 } 1041 1042 static void virtio_ccw_notify(DeviceState *d, uint16_t vector) 1043 { 1044 VirtioCcwDevice *dev = to_virtio_ccw_dev_fast(d); 1045 SubchDev *sch = dev->sch; 1046 uint64_t indicators; 1047 1048 /* queue indicators + secondary indicators */ 1049 if (vector >= VIRTIO_CCW_QUEUE_MAX + 64) { 1050 return; 1051 } 1052 1053 if (vector < VIRTIO_CCW_QUEUE_MAX) { 1054 if (!dev->indicators) { 1055 return; 1056 } 1057 if (sch->thinint_active) { 1058 /* 1059 * In the adapter interrupt case, indicators points to a 1060 * memory area that may be (way) larger than 64 bit and 1061 * ind_bit indicates the start of the indicators in a big 1062 * endian notation. 1063 */ 1064 uint64_t ind_bit = dev->routes.adapter.ind_offset; 1065 1066 virtio_set_ind_atomic(sch, dev->indicators->addr + 1067 (ind_bit + vector) / 8, 1068 0x80 >> ((ind_bit + vector) % 8)); 1069 if (!virtio_set_ind_atomic(sch, dev->summary_indicator->addr, 1070 0x01)) { 1071 css_adapter_interrupt(dev->thinint_isc); 1072 } 1073 } else { 1074 indicators = address_space_ldq(&address_space_memory, 1075 dev->indicators->addr, 1076 MEMTXATTRS_UNSPECIFIED, 1077 NULL); 1078 indicators |= 1ULL << vector; 1079 address_space_stq(&address_space_memory, dev->indicators->addr, 1080 indicators, MEMTXATTRS_UNSPECIFIED, NULL); 1081 css_conditional_io_interrupt(sch); 1082 } 1083 } else { 1084 if (!dev->indicators2) { 1085 return; 1086 } 1087 vector = 0; 1088 indicators = address_space_ldq(&address_space_memory, 1089 dev->indicators2->addr, 1090 MEMTXATTRS_UNSPECIFIED, 1091 NULL); 1092 indicators |= 1ULL << vector; 1093 address_space_stq(&address_space_memory, dev->indicators2->addr, 1094 indicators, MEMTXATTRS_UNSPECIFIED, NULL); 1095 css_conditional_io_interrupt(sch); 1096 } 1097 } 1098 1099 static void virtio_ccw_reset(DeviceState *d) 1100 { 1101 VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d); 1102 VirtIODevice *vdev = virtio_bus_get_device(&dev->bus); 1103 1104 virtio_ccw_reset_virtio(dev, vdev); 1105 css_reset_sch(dev->sch); 1106 } 1107 1108 static void virtio_ccw_vmstate_change(DeviceState *d, bool running) 1109 { 1110 VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d); 1111 1112 if (running) { 1113 virtio_ccw_start_ioeventfd(dev); 1114 } else { 1115 virtio_ccw_stop_ioeventfd(dev); 1116 } 1117 } 1118 1119 static bool virtio_ccw_query_guest_notifiers(DeviceState *d) 1120 { 1121 VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d); 1122 1123 return !!(dev->sch->curr_status.pmcw.flags & PMCW_FLAGS_MASK_ENA); 1124 } 1125 1126 static 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 1148 static 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 1169 static 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 1177 static 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_gsi(kvm_state, notifier, NULL, 1184 dev->routes.gsi[n]); 1185 } 1186 1187 static 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_gsi(kvm_state, notifier, 1195 dev->routes.gsi[n]); 1196 assert(ret == 0); 1197 } 1198 1199 static int virtio_ccw_set_guest_notifier(VirtioCcwDevice *dev, int n, 1200 bool assign, bool with_irqfd) 1201 { 1202 VirtIODevice *vdev = virtio_bus_get_device(&dev->bus); 1203 VirtQueue *vq = virtio_get_queue(vdev, n); 1204 EventNotifier *notifier = virtio_queue_get_guest_notifier(vq); 1205 VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev); 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); 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. 1225 */ 1226 if (k->guest_notifier_mask) { 1227 k->guest_notifier_mask(vdev, n, false); 1228 } 1229 /* get lost events and re-inject */ 1230 if (k->guest_notifier_pending && 1231 k->guest_notifier_pending(vdev, n)) { 1232 event_notifier_set(notifier); 1233 } 1234 } else { 1235 if (k->guest_notifier_mask) { 1236 k->guest_notifier_mask(vdev, n, true); 1237 } 1238 if (with_irqfd) { 1239 virtio_ccw_remove_irqfd(dev, n); 1240 } 1241 virtio_queue_set_guest_notifier_fd_handler(vq, false, with_irqfd); 1242 event_notifier_cleanup(notifier); 1243 } 1244 return 0; 1245 } 1246 1247 static int virtio_ccw_set_guest_notifiers(DeviceState *d, int nvqs, 1248 bool assigned) 1249 { 1250 VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d); 1251 VirtIODevice *vdev = virtio_bus_get_device(&dev->bus); 1252 bool with_irqfd = dev->sch->thinint_active && kvm_irqfds_enabled(); 1253 int r, n; 1254 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 } 1262 for (n = 0; n < nvqs; n++) { 1263 if (!virtio_queue_get_num(vdev, n)) { 1264 break; 1265 } 1266 r = virtio_ccw_set_guest_notifier(dev, n, assigned, with_irqfd); 1267 if (r < 0) { 1268 goto assign_error; 1269 } 1270 } 1271 if (with_irqfd && !assigned) { 1272 /* release irq routes after irqfds have been released */ 1273 virtio_ccw_release_irqroutes(dev, nvqs); 1274 } 1275 return 0; 1276 1277 assign_error: 1278 while (--n >= 0) { 1279 virtio_ccw_set_guest_notifier(dev, n, !assigned, false); 1280 } 1281 irqroute_error: 1282 if (with_irqfd && assigned) { 1283 virtio_ccw_release_irqroutes(dev, nvqs); 1284 } 1285 return r; 1286 } 1287 1288 static 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 1296 static 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 1308 static void virtio_ccw_save_config(DeviceState *d, QEMUFile *f) 1309 { 1310 VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d); 1311 SubchDev *s = dev->sch; 1312 VirtIODevice *vdev = virtio_ccw_get_vdev(s); 1313 1314 subch_device_save(s, f); 1315 if (dev->indicators != NULL) { 1316 qemu_put_be32(f, dev->indicators->len); 1317 qemu_put_be64(f, dev->indicators->addr); 1318 } else { 1319 qemu_put_be32(f, 0); 1320 qemu_put_be64(f, 0UL); 1321 } 1322 if (dev->indicators2 != NULL) { 1323 qemu_put_be32(f, dev->indicators2->len); 1324 qemu_put_be64(f, dev->indicators2->addr); 1325 } else { 1326 qemu_put_be32(f, 0); 1327 qemu_put_be64(f, 0UL); 1328 } 1329 if (dev->summary_indicator != NULL) { 1330 qemu_put_be32(f, dev->summary_indicator->len); 1331 qemu_put_be64(f, dev->summary_indicator->addr); 1332 } else { 1333 qemu_put_be32(f, 0); 1334 qemu_put_be64(f, 0UL); 1335 } 1336 qemu_put_be16(f, vdev->config_vector); 1337 qemu_put_be64(f, dev->routes.adapter.ind_offset); 1338 qemu_put_byte(f, dev->thinint_isc); 1339 qemu_put_be32(f, dev->revision); 1340 } 1341 1342 static int virtio_ccw_load_config(DeviceState *d, QEMUFile *f) 1343 { 1344 VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d); 1345 SubchDev *s = dev->sch; 1346 VirtIODevice *vdev = virtio_ccw_get_vdev(s); 1347 int len; 1348 1349 s->driver_data = dev; 1350 subch_device_load(s, f); 1351 len = qemu_get_be32(f); 1352 if (len != 0) { 1353 dev->indicators = get_indicator(qemu_get_be64(f), len); 1354 } else { 1355 qemu_get_be64(f); 1356 dev->indicators = NULL; 1357 } 1358 len = qemu_get_be32(f); 1359 if (len != 0) { 1360 dev->indicators2 = get_indicator(qemu_get_be64(f), len); 1361 } else { 1362 qemu_get_be64(f); 1363 dev->indicators2 = NULL; 1364 } 1365 len = qemu_get_be32(f); 1366 if (len != 0) { 1367 dev->summary_indicator = get_indicator(qemu_get_be64(f), len); 1368 } else { 1369 qemu_get_be64(f); 1370 dev->summary_indicator = NULL; 1371 } 1372 qemu_get_be16s(f, &vdev->config_vector); 1373 dev->routes.adapter.ind_offset = qemu_get_be64(f); 1374 dev->thinint_isc = qemu_get_byte(f); 1375 dev->revision = qemu_get_be32(f); 1376 if (s->thinint_active) { 1377 return css_register_io_adapter(CSS_IO_ADAPTER_VIRTIO, 1378 dev->thinint_isc, true, false, 1379 &dev->routes.adapter.adapter_id); 1380 } 1381 1382 return 0; 1383 } 1384 1385 /* This is called by virtio-bus just after the device is plugged. */ 1386 static void virtio_ccw_device_plugged(DeviceState *d, Error **errp) 1387 { 1388 VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d); 1389 VirtIODevice *vdev = virtio_bus_get_device(&dev->bus); 1390 SubchDev *sch = dev->sch; 1391 int n = virtio_get_num_queues(vdev); 1392 1393 if (virtio_get_num_queues(vdev) > VIRTIO_CCW_QUEUE_MAX) { 1394 error_setg(errp, "The number of virtqueues %d " 1395 "exceeds ccw limit %d", n, 1396 VIRTIO_CCW_QUEUE_MAX); 1397 return; 1398 } 1399 1400 if (!kvm_eventfds_enabled()) { 1401 dev->flags &= ~VIRTIO_CCW_FLAG_USE_IOEVENTFD; 1402 } 1403 1404 sch->id.cu_model = virtio_bus_get_vdev_id(&dev->bus); 1405 1406 if (dev->max_rev >= 1) { 1407 virtio_add_feature(&vdev->host_features, VIRTIO_F_VERSION_1); 1408 } 1409 1410 css_generate_sch_crws(sch->cssid, sch->ssid, sch->schid, 1411 d->hotplugged, 1); 1412 } 1413 1414 static void virtio_ccw_post_plugged(DeviceState *d, Error **errp) 1415 { 1416 VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d); 1417 VirtIODevice *vdev = virtio_bus_get_device(&dev->bus); 1418 1419 if (!virtio_host_has_feature(vdev, VIRTIO_F_VERSION_1)) { 1420 /* A backend didn't support modern virtio. */ 1421 dev->max_rev = 0; 1422 } 1423 } 1424 1425 static void virtio_ccw_device_unplugged(DeviceState *d) 1426 { 1427 VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d); 1428 1429 virtio_ccw_stop_ioeventfd(dev); 1430 } 1431 /**************** Virtio-ccw Bus Device Descriptions *******************/ 1432 1433 static Property virtio_ccw_net_properties[] = { 1434 DEFINE_PROP_CSS_DEV_ID("devno", VirtioCcwDevice, bus_id), 1435 DEFINE_PROP_BIT("ioeventfd", VirtioCcwDevice, flags, 1436 VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT, true), 1437 DEFINE_PROP_UINT32("max_revision", VirtioCcwDevice, max_rev, 1438 VIRTIO_CCW_MAX_REV), 1439 DEFINE_PROP_END_OF_LIST(), 1440 }; 1441 1442 static void virtio_ccw_net_class_init(ObjectClass *klass, void *data) 1443 { 1444 DeviceClass *dc = DEVICE_CLASS(klass); 1445 VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass); 1446 1447 k->realize = virtio_ccw_net_realize; 1448 k->exit = virtio_ccw_exit; 1449 dc->reset = virtio_ccw_reset; 1450 dc->props = virtio_ccw_net_properties; 1451 set_bit(DEVICE_CATEGORY_NETWORK, dc->categories); 1452 } 1453 1454 static const TypeInfo virtio_ccw_net = { 1455 .name = TYPE_VIRTIO_NET_CCW, 1456 .parent = TYPE_VIRTIO_CCW_DEVICE, 1457 .instance_size = sizeof(VirtIONetCcw), 1458 .instance_init = virtio_ccw_net_instance_init, 1459 .class_init = virtio_ccw_net_class_init, 1460 }; 1461 1462 static Property virtio_ccw_blk_properties[] = { 1463 DEFINE_PROP_CSS_DEV_ID("devno", VirtioCcwDevice, bus_id), 1464 DEFINE_PROP_BIT("ioeventfd", VirtioCcwDevice, flags, 1465 VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT, true), 1466 DEFINE_PROP_UINT32("max_revision", VirtioCcwDevice, max_rev, 1467 VIRTIO_CCW_MAX_REV), 1468 DEFINE_PROP_END_OF_LIST(), 1469 }; 1470 1471 static void virtio_ccw_blk_class_init(ObjectClass *klass, void *data) 1472 { 1473 DeviceClass *dc = DEVICE_CLASS(klass); 1474 VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass); 1475 1476 k->realize = virtio_ccw_blk_realize; 1477 k->exit = virtio_ccw_exit; 1478 dc->reset = virtio_ccw_reset; 1479 dc->props = virtio_ccw_blk_properties; 1480 set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); 1481 } 1482 1483 static const TypeInfo virtio_ccw_blk = { 1484 .name = TYPE_VIRTIO_BLK_CCW, 1485 .parent = TYPE_VIRTIO_CCW_DEVICE, 1486 .instance_size = sizeof(VirtIOBlkCcw), 1487 .instance_init = virtio_ccw_blk_instance_init, 1488 .class_init = virtio_ccw_blk_class_init, 1489 }; 1490 1491 static Property virtio_ccw_serial_properties[] = { 1492 DEFINE_PROP_CSS_DEV_ID("devno", VirtioCcwDevice, bus_id), 1493 DEFINE_PROP_BIT("ioeventfd", VirtioCcwDevice, flags, 1494 VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT, true), 1495 DEFINE_PROP_UINT32("max_revision", VirtioCcwDevice, max_rev, 1496 VIRTIO_CCW_MAX_REV), 1497 DEFINE_PROP_END_OF_LIST(), 1498 }; 1499 1500 static void virtio_ccw_serial_class_init(ObjectClass *klass, void *data) 1501 { 1502 DeviceClass *dc = DEVICE_CLASS(klass); 1503 VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass); 1504 1505 k->realize = virtio_ccw_serial_realize; 1506 k->exit = virtio_ccw_exit; 1507 dc->reset = virtio_ccw_reset; 1508 dc->props = virtio_ccw_serial_properties; 1509 set_bit(DEVICE_CATEGORY_INPUT, dc->categories); 1510 } 1511 1512 static const TypeInfo virtio_ccw_serial = { 1513 .name = TYPE_VIRTIO_SERIAL_CCW, 1514 .parent = TYPE_VIRTIO_CCW_DEVICE, 1515 .instance_size = sizeof(VirtioSerialCcw), 1516 .instance_init = virtio_ccw_serial_instance_init, 1517 .class_init = virtio_ccw_serial_class_init, 1518 }; 1519 1520 static Property virtio_ccw_balloon_properties[] = { 1521 DEFINE_PROP_CSS_DEV_ID("devno", VirtioCcwDevice, bus_id), 1522 DEFINE_PROP_BIT("ioeventfd", VirtioCcwDevice, flags, 1523 VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT, true), 1524 DEFINE_PROP_UINT32("max_revision", VirtioCcwDevice, max_rev, 1525 VIRTIO_CCW_MAX_REV), 1526 DEFINE_PROP_END_OF_LIST(), 1527 }; 1528 1529 static void virtio_ccw_balloon_class_init(ObjectClass *klass, void *data) 1530 { 1531 DeviceClass *dc = DEVICE_CLASS(klass); 1532 VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass); 1533 1534 k->realize = virtio_ccw_balloon_realize; 1535 k->exit = virtio_ccw_exit; 1536 dc->reset = virtio_ccw_reset; 1537 dc->props = virtio_ccw_balloon_properties; 1538 set_bit(DEVICE_CATEGORY_MISC, dc->categories); 1539 } 1540 1541 static const TypeInfo virtio_ccw_balloon = { 1542 .name = TYPE_VIRTIO_BALLOON_CCW, 1543 .parent = TYPE_VIRTIO_CCW_DEVICE, 1544 .instance_size = sizeof(VirtIOBalloonCcw), 1545 .instance_init = virtio_ccw_balloon_instance_init, 1546 .class_init = virtio_ccw_balloon_class_init, 1547 }; 1548 1549 static Property virtio_ccw_scsi_properties[] = { 1550 DEFINE_PROP_CSS_DEV_ID("devno", VirtioCcwDevice, bus_id), 1551 DEFINE_PROP_BIT("ioeventfd", VirtioCcwDevice, flags, 1552 VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT, true), 1553 DEFINE_PROP_UINT32("max_revision", VirtioCcwDevice, max_rev, 1554 VIRTIO_CCW_MAX_REV), 1555 DEFINE_PROP_END_OF_LIST(), 1556 }; 1557 1558 static void virtio_ccw_scsi_class_init(ObjectClass *klass, void *data) 1559 { 1560 DeviceClass *dc = DEVICE_CLASS(klass); 1561 VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass); 1562 1563 k->realize = virtio_ccw_scsi_realize; 1564 k->exit = virtio_ccw_exit; 1565 dc->reset = virtio_ccw_reset; 1566 dc->props = virtio_ccw_scsi_properties; 1567 set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); 1568 } 1569 1570 static const TypeInfo virtio_ccw_scsi = { 1571 .name = TYPE_VIRTIO_SCSI_CCW, 1572 .parent = TYPE_VIRTIO_CCW_DEVICE, 1573 .instance_size = sizeof(VirtIOSCSICcw), 1574 .instance_init = virtio_ccw_scsi_instance_init, 1575 .class_init = virtio_ccw_scsi_class_init, 1576 }; 1577 1578 #ifdef CONFIG_VHOST_SCSI 1579 static Property vhost_ccw_scsi_properties[] = { 1580 DEFINE_PROP_CSS_DEV_ID("devno", VirtioCcwDevice, bus_id), 1581 DEFINE_PROP_UINT32("max_revision", VirtioCcwDevice, max_rev, 1582 VIRTIO_CCW_MAX_REV), 1583 DEFINE_PROP_END_OF_LIST(), 1584 }; 1585 1586 static void vhost_ccw_scsi_class_init(ObjectClass *klass, void *data) 1587 { 1588 DeviceClass *dc = DEVICE_CLASS(klass); 1589 VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass); 1590 1591 k->realize = vhost_ccw_scsi_realize; 1592 k->exit = virtio_ccw_exit; 1593 dc->reset = virtio_ccw_reset; 1594 dc->props = vhost_ccw_scsi_properties; 1595 set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); 1596 } 1597 1598 static const TypeInfo vhost_ccw_scsi = { 1599 .name = TYPE_VHOST_SCSI_CCW, 1600 .parent = TYPE_VIRTIO_CCW_DEVICE, 1601 .instance_size = sizeof(VHostSCSICcw), 1602 .instance_init = vhost_ccw_scsi_instance_init, 1603 .class_init = vhost_ccw_scsi_class_init, 1604 }; 1605 #endif 1606 1607 static void virtio_ccw_rng_instance_init(Object *obj) 1608 { 1609 VirtIORNGCcw *dev = VIRTIO_RNG_CCW(obj); 1610 1611 virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev), 1612 TYPE_VIRTIO_RNG); 1613 object_property_add_alias(obj, "rng", OBJECT(&dev->vdev), 1614 "rng", &error_abort); 1615 } 1616 1617 static Property virtio_ccw_rng_properties[] = { 1618 DEFINE_PROP_CSS_DEV_ID("devno", VirtioCcwDevice, bus_id), 1619 DEFINE_PROP_BIT("ioeventfd", VirtioCcwDevice, flags, 1620 VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT, true), 1621 DEFINE_PROP_UINT32("max_revision", VirtioCcwDevice, max_rev, 1622 VIRTIO_CCW_MAX_REV), 1623 DEFINE_PROP_END_OF_LIST(), 1624 }; 1625 1626 static void virtio_ccw_rng_class_init(ObjectClass *klass, void *data) 1627 { 1628 DeviceClass *dc = DEVICE_CLASS(klass); 1629 VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass); 1630 1631 k->realize = virtio_ccw_rng_realize; 1632 k->exit = virtio_ccw_exit; 1633 dc->reset = virtio_ccw_reset; 1634 dc->props = virtio_ccw_rng_properties; 1635 set_bit(DEVICE_CATEGORY_MISC, dc->categories); 1636 } 1637 1638 static const TypeInfo virtio_ccw_rng = { 1639 .name = TYPE_VIRTIO_RNG_CCW, 1640 .parent = TYPE_VIRTIO_CCW_DEVICE, 1641 .instance_size = sizeof(VirtIORNGCcw), 1642 .instance_init = virtio_ccw_rng_instance_init, 1643 .class_init = virtio_ccw_rng_class_init, 1644 }; 1645 1646 static void virtio_ccw_busdev_realize(DeviceState *dev, Error **errp) 1647 { 1648 VirtioCcwDevice *_dev = (VirtioCcwDevice *)dev; 1649 1650 virtio_ccw_bus_new(&_dev->bus, sizeof(_dev->bus), _dev); 1651 virtio_ccw_device_realize(_dev, errp); 1652 } 1653 1654 static int virtio_ccw_busdev_exit(DeviceState *dev) 1655 { 1656 VirtioCcwDevice *_dev = (VirtioCcwDevice *)dev; 1657 VirtIOCCWDeviceClass *_info = VIRTIO_CCW_DEVICE_GET_CLASS(dev); 1658 1659 return _info->exit(_dev); 1660 } 1661 1662 static void virtio_ccw_busdev_unplug(HotplugHandler *hotplug_dev, 1663 DeviceState *dev, Error **errp) 1664 { 1665 VirtioCcwDevice *_dev = (VirtioCcwDevice *)dev; 1666 SubchDev *sch = _dev->sch; 1667 1668 virtio_ccw_stop_ioeventfd(_dev); 1669 1670 /* 1671 * We should arrive here only for device_del, since we don't support 1672 * direct hot(un)plug of channels, but only through virtio. 1673 */ 1674 assert(sch != NULL); 1675 /* Subchannel is now disabled and no longer valid. */ 1676 sch->curr_status.pmcw.flags &= ~(PMCW_FLAGS_MASK_ENA | 1677 PMCW_FLAGS_MASK_DNV); 1678 1679 css_generate_sch_crws(sch->cssid, sch->ssid, sch->schid, 1, 0); 1680 1681 object_unparent(OBJECT(dev)); 1682 } 1683 1684 static void virtio_ccw_device_class_init(ObjectClass *klass, void *data) 1685 { 1686 DeviceClass *dc = DEVICE_CLASS(klass); 1687 1688 dc->realize = virtio_ccw_busdev_realize; 1689 dc->exit = virtio_ccw_busdev_exit; 1690 dc->bus_type = TYPE_VIRTUAL_CSS_BUS; 1691 } 1692 1693 static const TypeInfo virtio_ccw_device_info = { 1694 .name = TYPE_VIRTIO_CCW_DEVICE, 1695 .parent = TYPE_DEVICE, 1696 .instance_size = sizeof(VirtioCcwDevice), 1697 .class_init = virtio_ccw_device_class_init, 1698 .class_size = sizeof(VirtIOCCWDeviceClass), 1699 .abstract = true, 1700 }; 1701 1702 /***************** Virtual-css Bus Bridge Device ********************/ 1703 /* Only required to have the virtio bus as child in the system bus */ 1704 1705 static int virtual_css_bridge_init(SysBusDevice *dev) 1706 { 1707 /* nothing */ 1708 return 0; 1709 } 1710 1711 static void virtual_css_bridge_class_init(ObjectClass *klass, void *data) 1712 { 1713 SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); 1714 HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(klass); 1715 DeviceClass *dc = DEVICE_CLASS(klass); 1716 1717 k->init = virtual_css_bridge_init; 1718 hc->unplug = virtio_ccw_busdev_unplug; 1719 set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); 1720 } 1721 1722 static const TypeInfo virtual_css_bridge_info = { 1723 .name = "virtual-css-bridge", 1724 .parent = TYPE_SYS_BUS_DEVICE, 1725 .instance_size = sizeof(SysBusDevice), 1726 .class_init = virtual_css_bridge_class_init, 1727 .interfaces = (InterfaceInfo[]) { 1728 { TYPE_HOTPLUG_HANDLER }, 1729 { } 1730 } 1731 }; 1732 1733 /* virtio-ccw-bus */ 1734 1735 static void virtio_ccw_bus_new(VirtioBusState *bus, size_t bus_size, 1736 VirtioCcwDevice *dev) 1737 { 1738 DeviceState *qdev = DEVICE(dev); 1739 char virtio_bus_name[] = "virtio-bus"; 1740 1741 qbus_create_inplace(bus, bus_size, TYPE_VIRTIO_CCW_BUS, 1742 qdev, virtio_bus_name); 1743 } 1744 1745 static void virtio_ccw_bus_class_init(ObjectClass *klass, void *data) 1746 { 1747 VirtioBusClass *k = VIRTIO_BUS_CLASS(klass); 1748 BusClass *bus_class = BUS_CLASS(klass); 1749 1750 bus_class->max_dev = 1; 1751 k->notify = virtio_ccw_notify; 1752 k->vmstate_change = virtio_ccw_vmstate_change; 1753 k->query_guest_notifiers = virtio_ccw_query_guest_notifiers; 1754 k->set_guest_notifiers = virtio_ccw_set_guest_notifiers; 1755 k->save_queue = virtio_ccw_save_queue; 1756 k->load_queue = virtio_ccw_load_queue; 1757 k->save_config = virtio_ccw_save_config; 1758 k->load_config = virtio_ccw_load_config; 1759 k->device_plugged = virtio_ccw_device_plugged; 1760 k->post_plugged = virtio_ccw_post_plugged; 1761 k->device_unplugged = virtio_ccw_device_unplugged; 1762 k->ioeventfd_started = virtio_ccw_ioeventfd_started; 1763 k->ioeventfd_set_started = virtio_ccw_ioeventfd_set_started; 1764 k->ioeventfd_disabled = virtio_ccw_ioeventfd_disabled; 1765 k->ioeventfd_set_disabled = virtio_ccw_ioeventfd_set_disabled; 1766 k->ioeventfd_assign = virtio_ccw_ioeventfd_assign; 1767 } 1768 1769 static const TypeInfo virtio_ccw_bus_info = { 1770 .name = TYPE_VIRTIO_CCW_BUS, 1771 .parent = TYPE_VIRTIO_BUS, 1772 .instance_size = sizeof(VirtioCcwBusState), 1773 .class_init = virtio_ccw_bus_class_init, 1774 }; 1775 1776 #ifdef CONFIG_VIRTFS 1777 static Property virtio_ccw_9p_properties[] = { 1778 DEFINE_PROP_CSS_DEV_ID("devno", VirtioCcwDevice, bus_id), 1779 DEFINE_PROP_BIT("ioeventfd", VirtioCcwDevice, flags, 1780 VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT, true), 1781 DEFINE_PROP_UINT32("max_revision", VirtioCcwDevice, max_rev, 1782 VIRTIO_CCW_MAX_REV), 1783 DEFINE_PROP_END_OF_LIST(), 1784 }; 1785 1786 static void virtio_ccw_9p_realize(VirtioCcwDevice *ccw_dev, Error **errp) 1787 { 1788 V9fsCCWState *dev = VIRTIO_9P_CCW(ccw_dev); 1789 DeviceState *vdev = DEVICE(&dev->vdev); 1790 1791 qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus)); 1792 object_property_set_bool(OBJECT(vdev), true, "realized", errp); 1793 } 1794 1795 static void virtio_ccw_9p_class_init(ObjectClass *klass, void *data) 1796 { 1797 DeviceClass *dc = DEVICE_CLASS(klass); 1798 VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass); 1799 1800 k->exit = virtio_ccw_exit; 1801 k->realize = virtio_ccw_9p_realize; 1802 dc->reset = virtio_ccw_reset; 1803 dc->props = virtio_ccw_9p_properties; 1804 set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); 1805 } 1806 1807 static void virtio_ccw_9p_instance_init(Object *obj) 1808 { 1809 V9fsCCWState *dev = VIRTIO_9P_CCW(obj); 1810 1811 virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev), 1812 TYPE_VIRTIO_9P); 1813 } 1814 1815 static const TypeInfo virtio_ccw_9p_info = { 1816 .name = TYPE_VIRTIO_9P_CCW, 1817 .parent = TYPE_VIRTIO_CCW_DEVICE, 1818 .instance_size = sizeof(V9fsCCWState), 1819 .instance_init = virtio_ccw_9p_instance_init, 1820 .class_init = virtio_ccw_9p_class_init, 1821 }; 1822 #endif 1823 1824 static void virtio_ccw_register(void) 1825 { 1826 type_register_static(&virtio_ccw_bus_info); 1827 type_register_static(&virtual_css_bus_info); 1828 type_register_static(&virtio_ccw_device_info); 1829 type_register_static(&virtio_ccw_serial); 1830 type_register_static(&virtio_ccw_blk); 1831 type_register_static(&virtio_ccw_net); 1832 type_register_static(&virtio_ccw_balloon); 1833 type_register_static(&virtio_ccw_scsi); 1834 #ifdef CONFIG_VHOST_SCSI 1835 type_register_static(&vhost_ccw_scsi); 1836 #endif 1837 type_register_static(&virtio_ccw_rng); 1838 type_register_static(&virtual_css_bridge_info); 1839 #ifdef CONFIG_VIRTFS 1840 type_register_static(&virtio_ccw_9p_info); 1841 #endif 1842 } 1843 1844 type_init(virtio_ccw_register) 1845