root / hw / s390x / virtio-ccw.c @ 80270a19
History | View | Annotate | Download (33.5 kB)
1 |
/*
|
---|---|
2 |
* virtio ccw target implementation
|
3 |
*
|
4 |
* Copyright 2012 IBM Corp.
|
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" |
18 |
#include "hw/virtio/virtio.h" |
19 |
#include "hw/virtio/virtio-serial.h" |
20 |
#include "hw/virtio/virtio-net.h" |
21 |
#include "hw/sysbus.h" |
22 |
#include "qemu/bitops.h" |
23 |
#include "hw/virtio/virtio-bus.h" |
24 |
|
25 |
#include "ioinst.h" |
26 |
#include "css.h" |
27 |
#include "virtio-ccw.h" |
28 |
#include "trace.h" |
29 |
|
30 |
static void virtio_ccw_bus_new(VirtioBusState *bus, VirtioCcwDevice *dev); |
31 |
|
32 |
static int virtual_css_bus_reset(BusState *qbus) |
33 |
{ |
34 |
/* This should actually be modelled via the generic css */
|
35 |
css_reset(); |
36 |
|
37 |
/* we dont traverse ourself, return 0 */
|
38 |
return 0; |
39 |
} |
40 |
|
41 |
|
42 |
static void virtual_css_bus_class_init(ObjectClass *klass, void *data) |
43 |
{ |
44 |
BusClass *k = BUS_CLASS(klass); |
45 |
|
46 |
k->reset = virtual_css_bus_reset; |
47 |
} |
48 |
|
49 |
static const TypeInfo virtual_css_bus_info = { |
50 |
.name = TYPE_VIRTUAL_CSS_BUS, |
51 |
.parent = TYPE_BUS, |
52 |
.instance_size = sizeof(VirtualCssBus),
|
53 |
.class_init = virtual_css_bus_class_init, |
54 |
}; |
55 |
|
56 |
VirtIODevice *virtio_ccw_get_vdev(SubchDev *sch) |
57 |
{ |
58 |
VirtIODevice *vdev = NULL;
|
59 |
|
60 |
if (sch->driver_data) {
|
61 |
vdev = ((VirtioCcwDevice *)sch->driver_data)->vdev; |
62 |
} |
63 |
return vdev;
|
64 |
} |
65 |
|
66 |
VirtualCssBus *virtual_css_bus_init(void)
|
67 |
{ |
68 |
VirtualCssBus *cbus; |
69 |
BusState *bus; |
70 |
DeviceState *dev; |
71 |
|
72 |
/* Create bridge device */
|
73 |
dev = qdev_create(NULL, "virtual-css-bridge"); |
74 |
qdev_init_nofail(dev); |
75 |
|
76 |
/* Create bus on bridge device */
|
77 |
bus = qbus_create(TYPE_VIRTUAL_CSS_BUS, dev, "virtual-css");
|
78 |
cbus = VIRTUAL_CSS_BUS(bus); |
79 |
|
80 |
/* Enable hotplugging */
|
81 |
bus->allow_hotplug = 1;
|
82 |
|
83 |
return cbus;
|
84 |
} |
85 |
|
86 |
/* Communication blocks used by several channel commands. */
|
87 |
typedef struct VqInfoBlock { |
88 |
uint64_t queue; |
89 |
uint32_t align; |
90 |
uint16_t index; |
91 |
uint16_t num; |
92 |
} QEMU_PACKED VqInfoBlock; |
93 |
|
94 |
typedef struct VqConfigBlock { |
95 |
uint16_t index; |
96 |
uint16_t num_max; |
97 |
} QEMU_PACKED VqConfigBlock; |
98 |
|
99 |
typedef struct VirtioFeatDesc { |
100 |
uint32_t features; |
101 |
uint8_t index; |
102 |
} QEMU_PACKED VirtioFeatDesc; |
103 |
|
104 |
/* Specify where the virtqueues for the subchannel are in guest memory. */
|
105 |
static int virtio_ccw_set_vqs(SubchDev *sch, uint64_t addr, uint32_t align, |
106 |
uint16_t index, uint16_t num) |
107 |
{ |
108 |
VirtioCcwDevice *dev = sch->driver_data; |
109 |
|
110 |
if (index > VIRTIO_PCI_QUEUE_MAX) {
|
111 |
return -EINVAL;
|
112 |
} |
113 |
|
114 |
/* Current code in virtio.c relies on 4K alignment. */
|
115 |
if (addr && (align != 4096)) { |
116 |
return -EINVAL;
|
117 |
} |
118 |
|
119 |
if (!dev) {
|
120 |
return -EINVAL;
|
121 |
} |
122 |
|
123 |
virtio_queue_set_addr(dev->vdev, index, addr); |
124 |
if (!addr) {
|
125 |
virtio_queue_set_vector(dev->vdev, index, 0);
|
126 |
} else {
|
127 |
/* Fail if we don't have a big enough queue. */
|
128 |
/* TODO: Add interface to handle vring.num changing */
|
129 |
if (virtio_queue_get_num(dev->vdev, index) > num) {
|
130 |
return -EINVAL;
|
131 |
} |
132 |
virtio_queue_set_vector(dev->vdev, index, index); |
133 |
} |
134 |
/* tell notify handler in case of config change */
|
135 |
dev->vdev->config_vector = VIRTIO_PCI_QUEUE_MAX; |
136 |
return 0; |
137 |
} |
138 |
|
139 |
static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw) |
140 |
{ |
141 |
int ret;
|
142 |
VqInfoBlock info; |
143 |
uint8_t status; |
144 |
VirtioFeatDesc features; |
145 |
void *config;
|
146 |
hwaddr indicators; |
147 |
VqConfigBlock vq_config; |
148 |
VirtioCcwDevice *dev = sch->driver_data; |
149 |
bool check_len;
|
150 |
int len;
|
151 |
hwaddr hw_len; |
152 |
|
153 |
if (!dev) {
|
154 |
return -EINVAL;
|
155 |
} |
156 |
|
157 |
trace_virtio_ccw_interpret_ccw(sch->cssid, sch->ssid, sch->schid, |
158 |
ccw.cmd_code); |
159 |
check_len = !((ccw.flags & CCW_FLAG_SLI) && !(ccw.flags & CCW_FLAG_DC)); |
160 |
|
161 |
/* Look at the command. */
|
162 |
switch (ccw.cmd_code) {
|
163 |
case CCW_CMD_SET_VQ:
|
164 |
if (check_len) {
|
165 |
if (ccw.count != sizeof(info)) { |
166 |
ret = -EINVAL; |
167 |
break;
|
168 |
} |
169 |
} else if (ccw.count < sizeof(info)) { |
170 |
/* Can't execute command. */
|
171 |
ret = -EINVAL; |
172 |
break;
|
173 |
} |
174 |
if (!ccw.cda) {
|
175 |
ret = -EFAULT; |
176 |
} else {
|
177 |
info.queue = ldq_phys(ccw.cda); |
178 |
info.align = ldl_phys(ccw.cda + sizeof(info.queue));
|
179 |
info.index = lduw_phys(ccw.cda + sizeof(info.queue)
|
180 |
+ sizeof(info.align));
|
181 |
info.num = lduw_phys(ccw.cda + sizeof(info.queue)
|
182 |
+ sizeof(info.align)
|
183 |
+ sizeof(info.index));
|
184 |
ret = virtio_ccw_set_vqs(sch, info.queue, info.align, info.index, |
185 |
info.num); |
186 |
sch->curr_status.scsw.count = 0;
|
187 |
} |
188 |
break;
|
189 |
case CCW_CMD_VDEV_RESET:
|
190 |
virtio_reset(dev->vdev); |
191 |
ret = 0;
|
192 |
break;
|
193 |
case CCW_CMD_READ_FEAT:
|
194 |
if (check_len) {
|
195 |
if (ccw.count != sizeof(features)) { |
196 |
ret = -EINVAL; |
197 |
break;
|
198 |
} |
199 |
} else if (ccw.count < sizeof(features)) { |
200 |
/* Can't execute command. */
|
201 |
ret = -EINVAL; |
202 |
break;
|
203 |
} |
204 |
if (!ccw.cda) {
|
205 |
ret = -EFAULT; |
206 |
} else {
|
207 |
features.index = ldub_phys(ccw.cda + sizeof(features.features));
|
208 |
if (features.index < ARRAY_SIZE(dev->host_features)) {
|
209 |
features.features = dev->host_features[features.index]; |
210 |
} else {
|
211 |
/* Return zeroes if the guest supports more feature bits. */
|
212 |
features.features = 0;
|
213 |
} |
214 |
stl_le_phys(ccw.cda, features.features); |
215 |
sch->curr_status.scsw.count = ccw.count - sizeof(features);
|
216 |
ret = 0;
|
217 |
} |
218 |
break;
|
219 |
case CCW_CMD_WRITE_FEAT:
|
220 |
if (check_len) {
|
221 |
if (ccw.count != sizeof(features)) { |
222 |
ret = -EINVAL; |
223 |
break;
|
224 |
} |
225 |
} else if (ccw.count < sizeof(features)) { |
226 |
/* Can't execute command. */
|
227 |
ret = -EINVAL; |
228 |
break;
|
229 |
} |
230 |
if (!ccw.cda) {
|
231 |
ret = -EFAULT; |
232 |
} else {
|
233 |
features.index = ldub_phys(ccw.cda + sizeof(features.features));
|
234 |
features.features = ldl_le_phys(ccw.cda); |
235 |
if (features.index < ARRAY_SIZE(dev->host_features)) {
|
236 |
virtio_bus_set_vdev_features(&dev->bus, features.features); |
237 |
dev->vdev->guest_features = features.features; |
238 |
} else {
|
239 |
/*
|
240 |
* If the guest supports more feature bits, assert that it
|
241 |
* passes us zeroes for those we don't support.
|
242 |
*/
|
243 |
if (features.features) {
|
244 |
fprintf(stderr, "Guest bug: features[%i]=%x (expected 0)\n",
|
245 |
features.index, features.features); |
246 |
/* XXX: do a unit check here? */
|
247 |
} |
248 |
} |
249 |
sch->curr_status.scsw.count = ccw.count - sizeof(features);
|
250 |
ret = 0;
|
251 |
} |
252 |
break;
|
253 |
case CCW_CMD_READ_CONF:
|
254 |
if (check_len) {
|
255 |
if (ccw.count > dev->vdev->config_len) {
|
256 |
ret = -EINVAL; |
257 |
break;
|
258 |
} |
259 |
} |
260 |
len = MIN(ccw.count, dev->vdev->config_len); |
261 |
if (!ccw.cda) {
|
262 |
ret = -EFAULT; |
263 |
} else {
|
264 |
virtio_bus_get_vdev_config(&dev->bus, dev->vdev->config); |
265 |
/* XXX config space endianness */
|
266 |
cpu_physical_memory_write(ccw.cda, dev->vdev->config, len); |
267 |
sch->curr_status.scsw.count = ccw.count - len; |
268 |
ret = 0;
|
269 |
} |
270 |
break;
|
271 |
case CCW_CMD_WRITE_CONF:
|
272 |
if (check_len) {
|
273 |
if (ccw.count > dev->vdev->config_len) {
|
274 |
ret = -EINVAL; |
275 |
break;
|
276 |
} |
277 |
} |
278 |
len = MIN(ccw.count, dev->vdev->config_len); |
279 |
hw_len = len; |
280 |
if (!ccw.cda) {
|
281 |
ret = -EFAULT; |
282 |
} else {
|
283 |
config = cpu_physical_memory_map(ccw.cda, &hw_len, 0);
|
284 |
if (!config) {
|
285 |
ret = -EFAULT; |
286 |
} else {
|
287 |
len = hw_len; |
288 |
/* XXX config space endianness */
|
289 |
memcpy(dev->vdev->config, config, len); |
290 |
cpu_physical_memory_unmap(config, hw_len, 0, hw_len);
|
291 |
virtio_bus_set_vdev_config(&dev->bus, dev->vdev->config); |
292 |
sch->curr_status.scsw.count = ccw.count - len; |
293 |
ret = 0;
|
294 |
} |
295 |
} |
296 |
break;
|
297 |
case CCW_CMD_WRITE_STATUS:
|
298 |
if (check_len) {
|
299 |
if (ccw.count != sizeof(status)) { |
300 |
ret = -EINVAL; |
301 |
break;
|
302 |
} |
303 |
} else if (ccw.count < sizeof(status)) { |
304 |
/* Can't execute command. */
|
305 |
ret = -EINVAL; |
306 |
break;
|
307 |
} |
308 |
if (!ccw.cda) {
|
309 |
ret = -EFAULT; |
310 |
} else {
|
311 |
status = ldub_phys(ccw.cda); |
312 |
virtio_set_status(dev->vdev, status); |
313 |
if (dev->vdev->status == 0) { |
314 |
virtio_reset(dev->vdev); |
315 |
} |
316 |
sch->curr_status.scsw.count = ccw.count - sizeof(status);
|
317 |
ret = 0;
|
318 |
} |
319 |
break;
|
320 |
case CCW_CMD_SET_IND:
|
321 |
if (check_len) {
|
322 |
if (ccw.count != sizeof(indicators)) { |
323 |
ret = -EINVAL; |
324 |
break;
|
325 |
} |
326 |
} else if (ccw.count < sizeof(indicators)) { |
327 |
/* Can't execute command. */
|
328 |
ret = -EINVAL; |
329 |
break;
|
330 |
} |
331 |
indicators = ldq_phys(ccw.cda); |
332 |
if (!indicators) {
|
333 |
ret = -EFAULT; |
334 |
} else {
|
335 |
dev->indicators = indicators; |
336 |
sch->curr_status.scsw.count = ccw.count - sizeof(indicators);
|
337 |
ret = 0;
|
338 |
} |
339 |
break;
|
340 |
case CCW_CMD_SET_CONF_IND:
|
341 |
if (check_len) {
|
342 |
if (ccw.count != sizeof(indicators)) { |
343 |
ret = -EINVAL; |
344 |
break;
|
345 |
} |
346 |
} else if (ccw.count < sizeof(indicators)) { |
347 |
/* Can't execute command. */
|
348 |
ret = -EINVAL; |
349 |
break;
|
350 |
} |
351 |
indicators = ldq_phys(ccw.cda); |
352 |
if (!indicators) {
|
353 |
ret = -EFAULT; |
354 |
} else {
|
355 |
dev->indicators2 = indicators; |
356 |
sch->curr_status.scsw.count = ccw.count - sizeof(indicators);
|
357 |
ret = 0;
|
358 |
} |
359 |
break;
|
360 |
case CCW_CMD_READ_VQ_CONF:
|
361 |
if (check_len) {
|
362 |
if (ccw.count != sizeof(vq_config)) { |
363 |
ret = -EINVAL; |
364 |
break;
|
365 |
} |
366 |
} else if (ccw.count < sizeof(vq_config)) { |
367 |
/* Can't execute command. */
|
368 |
ret = -EINVAL; |
369 |
break;
|
370 |
} |
371 |
if (!ccw.cda) {
|
372 |
ret = -EFAULT; |
373 |
} else {
|
374 |
vq_config.index = lduw_phys(ccw.cda); |
375 |
vq_config.num_max = virtio_queue_get_num(dev->vdev, |
376 |
vq_config.index); |
377 |
stw_phys(ccw.cda + sizeof(vq_config.index), vq_config.num_max);
|
378 |
sch->curr_status.scsw.count = ccw.count - sizeof(vq_config);
|
379 |
ret = 0;
|
380 |
} |
381 |
break;
|
382 |
default:
|
383 |
ret = -ENOSYS; |
384 |
break;
|
385 |
} |
386 |
return ret;
|
387 |
} |
388 |
|
389 |
static int virtio_ccw_device_init(VirtioCcwDevice *dev, VirtIODevice *vdev) |
390 |
{ |
391 |
unsigned int cssid = 0; |
392 |
unsigned int ssid = 0; |
393 |
unsigned int schid; |
394 |
unsigned int devno; |
395 |
bool have_devno = false; |
396 |
bool found = false; |
397 |
SubchDev *sch; |
398 |
int ret;
|
399 |
int num;
|
400 |
DeviceState *parent = DEVICE(dev); |
401 |
|
402 |
sch = g_malloc0(sizeof(SubchDev));
|
403 |
|
404 |
sch->driver_data = dev; |
405 |
dev->sch = sch; |
406 |
|
407 |
dev->vdev = vdev; |
408 |
dev->indicators = 0;
|
409 |
|
410 |
/* Initialize subchannel structure. */
|
411 |
sch->channel_prog = 0x0;
|
412 |
sch->last_cmd_valid = false;
|
413 |
sch->orb = NULL;
|
414 |
/*
|
415 |
* Use a device number if provided. Otherwise, fall back to subchannel
|
416 |
* number.
|
417 |
*/
|
418 |
if (dev->bus_id) {
|
419 |
num = sscanf(dev->bus_id, "%x.%x.%04x", &cssid, &ssid, &devno);
|
420 |
if (num == 3) { |
421 |
if ((cssid > MAX_CSSID) || (ssid > MAX_SSID)) {
|
422 |
ret = -EINVAL; |
423 |
error_report("Invalid cssid or ssid: cssid %x, ssid %x",
|
424 |
cssid, ssid); |
425 |
goto out_err;
|
426 |
} |
427 |
/* Enforce use of virtual cssid. */
|
428 |
if (cssid != VIRTUAL_CSSID) {
|
429 |
ret = -EINVAL; |
430 |
error_report("cssid %x not valid for virtio devices", cssid);
|
431 |
goto out_err;
|
432 |
} |
433 |
if (css_devno_used(cssid, ssid, devno)) {
|
434 |
ret = -EEXIST; |
435 |
error_report("Device %x.%x.%04x already exists", cssid, ssid,
|
436 |
devno); |
437 |
goto out_err;
|
438 |
} |
439 |
sch->cssid = cssid; |
440 |
sch->ssid = ssid; |
441 |
sch->devno = devno; |
442 |
have_devno = true;
|
443 |
} else {
|
444 |
ret = -EINVAL; |
445 |
error_report("Malformed devno parameter '%s'", dev->bus_id);
|
446 |
goto out_err;
|
447 |
} |
448 |
} |
449 |
|
450 |
/* Find the next free id. */
|
451 |
if (have_devno) {
|
452 |
for (schid = 0; schid <= MAX_SCHID; schid++) { |
453 |
if (!css_find_subch(1, cssid, ssid, schid)) { |
454 |
sch->schid = schid; |
455 |
css_subch_assign(cssid, ssid, schid, devno, sch); |
456 |
found = true;
|
457 |
break;
|
458 |
} |
459 |
} |
460 |
if (!found) {
|
461 |
ret = -ENODEV; |
462 |
error_report("No free subchannel found for %x.%x.%04x", cssid, ssid,
|
463 |
devno); |
464 |
goto out_err;
|
465 |
} |
466 |
trace_virtio_ccw_new_device(cssid, ssid, schid, devno, |
467 |
"user-configured");
|
468 |
} else {
|
469 |
cssid = VIRTUAL_CSSID; |
470 |
for (ssid = 0; ssid <= MAX_SSID; ssid++) { |
471 |
for (schid = 0; schid <= MAX_SCHID; schid++) { |
472 |
if (!css_find_subch(1, cssid, ssid, schid)) { |
473 |
sch->cssid = cssid; |
474 |
sch->ssid = ssid; |
475 |
sch->schid = schid; |
476 |
devno = schid; |
477 |
/*
|
478 |
* If the devno is already taken, look further in this
|
479 |
* subchannel set.
|
480 |
*/
|
481 |
while (css_devno_used(cssid, ssid, devno)) {
|
482 |
if (devno == MAX_SCHID) {
|
483 |
devno = 0;
|
484 |
} else if (devno == schid - 1) { |
485 |
ret = -ENODEV; |
486 |
error_report("No free devno found");
|
487 |
goto out_err;
|
488 |
} else {
|
489 |
devno++; |
490 |
} |
491 |
} |
492 |
sch->devno = devno; |
493 |
css_subch_assign(cssid, ssid, schid, devno, sch); |
494 |
found = true;
|
495 |
break;
|
496 |
} |
497 |
} |
498 |
if (found) {
|
499 |
break;
|
500 |
} |
501 |
} |
502 |
if (!found) {
|
503 |
ret = -ENODEV; |
504 |
error_report("Virtual channel subsystem is full!");
|
505 |
goto out_err;
|
506 |
} |
507 |
trace_virtio_ccw_new_device(cssid, ssid, schid, devno, |
508 |
"auto-configured");
|
509 |
} |
510 |
|
511 |
/* Build initial schib. */
|
512 |
css_sch_build_virtual_schib(sch, 0, VIRTIO_CCW_CHPID_TYPE);
|
513 |
|
514 |
sch->ccw_cb = virtio_ccw_cb; |
515 |
|
516 |
/* Build senseid data. */
|
517 |
memset(&sch->id, 0, sizeof(SenseId)); |
518 |
sch->id.reserved = 0xff;
|
519 |
sch->id.cu_type = VIRTIO_CCW_CU_TYPE; |
520 |
sch->id.cu_model = dev->vdev->device_id; |
521 |
|
522 |
/* Only the first 32 feature bits are used. */
|
523 |
dev->host_features[0] = virtio_bus_get_vdev_features(&dev->bus,
|
524 |
dev->host_features[0]);
|
525 |
|
526 |
dev->host_features[0] |= 0x1 << VIRTIO_F_NOTIFY_ON_EMPTY; |
527 |
dev->host_features[0] |= 0x1 << VIRTIO_F_BAD_FEATURE; |
528 |
|
529 |
css_generate_sch_crws(sch->cssid, sch->ssid, sch->schid, |
530 |
parent->hotplugged, 1);
|
531 |
return 0; |
532 |
|
533 |
out_err:
|
534 |
dev->sch = NULL;
|
535 |
g_free(sch); |
536 |
return ret;
|
537 |
} |
538 |
|
539 |
static int virtio_ccw_exit(VirtioCcwDevice *dev) |
540 |
{ |
541 |
SubchDev *sch = dev->sch; |
542 |
|
543 |
if (sch) {
|
544 |
css_subch_assign(sch->cssid, sch->ssid, sch->schid, sch->devno, NULL);
|
545 |
g_free(sch); |
546 |
} |
547 |
dev->indicators = 0;
|
548 |
return 0; |
549 |
} |
550 |
|
551 |
static int virtio_ccw_net_init(VirtioCcwDevice *ccw_dev) |
552 |
{ |
553 |
VirtIONetCcw *dev = VIRTIO_NET_CCW(ccw_dev); |
554 |
DeviceState *vdev = DEVICE(&dev->vdev); |
555 |
|
556 |
virtio_net_set_config_size(&dev->vdev, ccw_dev->host_features[0]);
|
557 |
qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus)); |
558 |
if (qdev_init(vdev) < 0) { |
559 |
return -1; |
560 |
} |
561 |
|
562 |
return virtio_ccw_device_init(ccw_dev, VIRTIO_DEVICE(vdev));
|
563 |
} |
564 |
|
565 |
static void virtio_ccw_net_instance_init(Object *obj) |
566 |
{ |
567 |
VirtIONetCcw *dev = VIRTIO_NET_CCW(obj); |
568 |
object_initialize(OBJECT(&dev->vdev), TYPE_VIRTIO_NET); |
569 |
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL); |
570 |
} |
571 |
|
572 |
static int virtio_ccw_blk_init(VirtioCcwDevice *ccw_dev) |
573 |
{ |
574 |
VirtIOBlkCcw *dev = VIRTIO_BLK_CCW(ccw_dev); |
575 |
DeviceState *vdev = DEVICE(&dev->vdev); |
576 |
virtio_blk_set_conf(vdev, &(dev->blk)); |
577 |
qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus)); |
578 |
if (qdev_init(vdev) < 0) { |
579 |
return -1; |
580 |
} |
581 |
|
582 |
return virtio_ccw_device_init(ccw_dev, VIRTIO_DEVICE(vdev));
|
583 |
} |
584 |
|
585 |
static void virtio_ccw_blk_instance_init(Object *obj) |
586 |
{ |
587 |
VirtIOBlkCcw *dev = VIRTIO_BLK_CCW(obj); |
588 |
object_initialize(OBJECT(&dev->vdev), TYPE_VIRTIO_BLK); |
589 |
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL); |
590 |
} |
591 |
|
592 |
static int virtio_ccw_serial_init(VirtioCcwDevice *ccw_dev) |
593 |
{ |
594 |
VirtioSerialCcw *dev = VIRTIO_SERIAL_CCW(ccw_dev); |
595 |
DeviceState *vdev = DEVICE(&dev->vdev); |
596 |
DeviceState *proxy = DEVICE(ccw_dev); |
597 |
char *bus_name;
|
598 |
|
599 |
/*
|
600 |
* For command line compatibility, this sets the virtio-serial-device bus
|
601 |
* name as before.
|
602 |
*/
|
603 |
if (proxy->id) {
|
604 |
bus_name = g_strdup_printf("%s.0", proxy->id);
|
605 |
virtio_device_set_child_bus_name(VIRTIO_DEVICE(vdev), bus_name); |
606 |
g_free(bus_name); |
607 |
} |
608 |
|
609 |
qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus)); |
610 |
if (qdev_init(vdev) < 0) { |
611 |
return -1; |
612 |
} |
613 |
|
614 |
return virtio_ccw_device_init(ccw_dev, VIRTIO_DEVICE(vdev));
|
615 |
} |
616 |
|
617 |
|
618 |
static void virtio_ccw_serial_instance_init(Object *obj) |
619 |
{ |
620 |
VirtioSerialCcw *dev = VIRTIO_SERIAL_CCW(obj); |
621 |
object_initialize(OBJECT(&dev->vdev), TYPE_VIRTIO_SERIAL); |
622 |
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL); |
623 |
} |
624 |
|
625 |
static int virtio_ccw_balloon_init(VirtioCcwDevice *ccw_dev) |
626 |
{ |
627 |
VirtIOBalloonCcw *dev = VIRTIO_BALLOON_CCW(ccw_dev); |
628 |
DeviceState *vdev = DEVICE(&dev->vdev); |
629 |
|
630 |
qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus)); |
631 |
if (qdev_init(vdev) < 0) { |
632 |
return -1; |
633 |
} |
634 |
|
635 |
return virtio_ccw_device_init(ccw_dev, VIRTIO_DEVICE(vdev));
|
636 |
} |
637 |
|
638 |
static void balloon_ccw_stats_get_all(Object *obj, struct Visitor *v, |
639 |
void *opaque, const char *name, |
640 |
Error **errp) |
641 |
{ |
642 |
VirtIOBalloonCcw *dev = opaque; |
643 |
object_property_get(OBJECT(&dev->vdev), v, "guest-stats", errp);
|
644 |
} |
645 |
|
646 |
static void balloon_ccw_stats_get_poll_interval(Object *obj, struct Visitor *v, |
647 |
void *opaque, const char *name, |
648 |
Error **errp) |
649 |
{ |
650 |
VirtIOBalloonCcw *dev = opaque; |
651 |
object_property_get(OBJECT(&dev->vdev), v, "guest-stats-polling-interval",
|
652 |
errp); |
653 |
} |
654 |
|
655 |
static void balloon_ccw_stats_set_poll_interval(Object *obj, struct Visitor *v, |
656 |
void *opaque, const char *name, |
657 |
Error **errp) |
658 |
{ |
659 |
VirtIOBalloonCcw *dev = opaque; |
660 |
object_property_set(OBJECT(&dev->vdev), v, "guest-stats-polling-interval",
|
661 |
errp); |
662 |
} |
663 |
|
664 |
static void virtio_ccw_balloon_instance_init(Object *obj) |
665 |
{ |
666 |
VirtIOBalloonCcw *dev = VIRTIO_BALLOON_CCW(obj); |
667 |
object_initialize(OBJECT(&dev->vdev), TYPE_VIRTIO_BALLOON); |
668 |
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL); |
669 |
|
670 |
object_property_add(obj, "guest-stats", "guest statistics", |
671 |
balloon_ccw_stats_get_all, NULL, NULL, dev, NULL); |
672 |
|
673 |
object_property_add(obj, "guest-stats-polling-interval", "int", |
674 |
balloon_ccw_stats_get_poll_interval, |
675 |
balloon_ccw_stats_set_poll_interval, |
676 |
NULL, dev, NULL); |
677 |
} |
678 |
|
679 |
static int virtio_ccw_scsi_init(VirtioCcwDevice *ccw_dev) |
680 |
{ |
681 |
VirtIOSCSICcw *dev = VIRTIO_SCSI_CCW(ccw_dev); |
682 |
DeviceState *vdev = DEVICE(&dev->vdev); |
683 |
|
684 |
qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus)); |
685 |
if (qdev_init(vdev) < 0) { |
686 |
return -1; |
687 |
} |
688 |
|
689 |
return virtio_ccw_device_init(ccw_dev, VIRTIO_DEVICE(vdev));
|
690 |
} |
691 |
|
692 |
static void virtio_ccw_scsi_instance_init(Object *obj) |
693 |
{ |
694 |
VirtIOSCSICcw *dev = VIRTIO_SCSI_CCW(obj); |
695 |
object_initialize(OBJECT(&dev->vdev), TYPE_VIRTIO_SCSI); |
696 |
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL); |
697 |
} |
698 |
|
699 |
#ifdef CONFIG_VHOST_SCSI
|
700 |
static int vhost_ccw_scsi_init(VirtioCcwDevice *ccw_dev) |
701 |
{ |
702 |
VHostSCSICcw *dev = VHOST_SCSI_CCW(ccw_dev); |
703 |
DeviceState *vdev = DEVICE(&dev->vdev); |
704 |
|
705 |
qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus)); |
706 |
if (qdev_init(vdev) < 0) { |
707 |
return -1; |
708 |
} |
709 |
|
710 |
return virtio_ccw_device_init(ccw_dev, VIRTIO_DEVICE(vdev));
|
711 |
} |
712 |
|
713 |
static void vhost_ccw_scsi_instance_init(Object *obj) |
714 |
{ |
715 |
VHostSCSICcw *dev = VHOST_SCSI_CCW(obj); |
716 |
object_initialize(OBJECT(&dev->vdev), TYPE_VHOST_SCSI); |
717 |
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL); |
718 |
} |
719 |
#endif
|
720 |
|
721 |
static int virtio_ccw_rng_init(VirtioCcwDevice *ccw_dev) |
722 |
{ |
723 |
VirtIORNGCcw *dev = VIRTIO_RNG_CCW(ccw_dev); |
724 |
DeviceState *vdev = DEVICE(&dev->vdev); |
725 |
|
726 |
qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus)); |
727 |
if (qdev_init(vdev) < 0) { |
728 |
return -1; |
729 |
} |
730 |
|
731 |
object_property_set_link(OBJECT(dev), |
732 |
OBJECT(dev->vdev.conf.default_backend), "rng",
|
733 |
NULL);
|
734 |
|
735 |
return virtio_ccw_device_init(ccw_dev, VIRTIO_DEVICE(vdev));
|
736 |
} |
737 |
|
738 |
/* DeviceState to VirtioCcwDevice. Note: used on datapath,
|
739 |
* be careful and test performance if you change this.
|
740 |
*/
|
741 |
static inline VirtioCcwDevice *to_virtio_ccw_dev_fast(DeviceState *d) |
742 |
{ |
743 |
return container_of(d, VirtioCcwDevice, parent_obj);
|
744 |
} |
745 |
|
746 |
static void virtio_ccw_notify(DeviceState *d, uint16_t vector) |
747 |
{ |
748 |
VirtioCcwDevice *dev = to_virtio_ccw_dev_fast(d); |
749 |
SubchDev *sch = dev->sch; |
750 |
uint64_t indicators; |
751 |
|
752 |
if (vector >= 128) { |
753 |
return;
|
754 |
} |
755 |
|
756 |
if (vector < VIRTIO_PCI_QUEUE_MAX) {
|
757 |
if (!dev->indicators) {
|
758 |
return;
|
759 |
} |
760 |
indicators = ldq_phys(dev->indicators); |
761 |
indicators |= 1ULL << vector;
|
762 |
stq_phys(dev->indicators, indicators); |
763 |
} else {
|
764 |
if (!dev->indicators2) {
|
765 |
return;
|
766 |
} |
767 |
vector = 0;
|
768 |
indicators = ldq_phys(dev->indicators2); |
769 |
indicators |= 1ULL << vector;
|
770 |
stq_phys(dev->indicators2, indicators); |
771 |
} |
772 |
|
773 |
css_conditional_io_interrupt(sch); |
774 |
|
775 |
} |
776 |
|
777 |
static unsigned virtio_ccw_get_features(DeviceState *d) |
778 |
{ |
779 |
VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d); |
780 |
|
781 |
/* Only the first 32 feature bits are used. */
|
782 |
return dev->host_features[0]; |
783 |
} |
784 |
|
785 |
static void virtio_ccw_reset(DeviceState *d) |
786 |
{ |
787 |
VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d); |
788 |
|
789 |
virtio_reset(dev->vdev); |
790 |
css_reset_sch(dev->sch); |
791 |
} |
792 |
|
793 |
/**************** Virtio-ccw Bus Device Descriptions *******************/
|
794 |
|
795 |
static Property virtio_ccw_net_properties[] = {
|
796 |
DEFINE_PROP_STRING("devno", VirtioCcwDevice, bus_id),
|
797 |
DEFINE_VIRTIO_NET_FEATURES(VirtioCcwDevice, host_features[0]),
|
798 |
DEFINE_VIRTIO_NET_PROPERTIES(VirtIONetCcw, vdev.net_conf), |
799 |
DEFINE_NIC_PROPERTIES(VirtIONetCcw, vdev.nic_conf), |
800 |
DEFINE_PROP_END_OF_LIST(), |
801 |
}; |
802 |
|
803 |
static void virtio_ccw_net_class_init(ObjectClass *klass, void *data) |
804 |
{ |
805 |
DeviceClass *dc = DEVICE_CLASS(klass); |
806 |
VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass); |
807 |
|
808 |
k->init = virtio_ccw_net_init; |
809 |
k->exit = virtio_ccw_exit; |
810 |
dc->reset = virtio_ccw_reset; |
811 |
dc->props = virtio_ccw_net_properties; |
812 |
} |
813 |
|
814 |
static const TypeInfo virtio_ccw_net = { |
815 |
.name = TYPE_VIRTIO_NET_CCW, |
816 |
.parent = TYPE_VIRTIO_CCW_DEVICE, |
817 |
.instance_size = sizeof(VirtIONetCcw),
|
818 |
.instance_init = virtio_ccw_net_instance_init, |
819 |
.class_init = virtio_ccw_net_class_init, |
820 |
}; |
821 |
|
822 |
static Property virtio_ccw_blk_properties[] = {
|
823 |
DEFINE_PROP_STRING("devno", VirtioCcwDevice, bus_id),
|
824 |
DEFINE_VIRTIO_BLK_FEATURES(VirtioCcwDevice, host_features[0]),
|
825 |
DEFINE_VIRTIO_BLK_PROPERTIES(VirtIOBlkCcw, blk), |
826 |
DEFINE_PROP_END_OF_LIST(), |
827 |
}; |
828 |
|
829 |
static void virtio_ccw_blk_class_init(ObjectClass *klass, void *data) |
830 |
{ |
831 |
DeviceClass *dc = DEVICE_CLASS(klass); |
832 |
VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass); |
833 |
|
834 |
k->init = virtio_ccw_blk_init; |
835 |
k->exit = virtio_ccw_exit; |
836 |
dc->reset = virtio_ccw_reset; |
837 |
dc->props = virtio_ccw_blk_properties; |
838 |
} |
839 |
|
840 |
static const TypeInfo virtio_ccw_blk = { |
841 |
.name = TYPE_VIRTIO_BLK_CCW, |
842 |
.parent = TYPE_VIRTIO_CCW_DEVICE, |
843 |
.instance_size = sizeof(VirtIOBlkCcw),
|
844 |
.instance_init = virtio_ccw_blk_instance_init, |
845 |
.class_init = virtio_ccw_blk_class_init, |
846 |
}; |
847 |
|
848 |
static Property virtio_ccw_serial_properties[] = {
|
849 |
DEFINE_PROP_STRING("devno", VirtioCcwDevice, bus_id),
|
850 |
DEFINE_VIRTIO_SERIAL_PROPERTIES(VirtioSerialCcw, vdev.serial), |
851 |
DEFINE_VIRTIO_COMMON_FEATURES(VirtioCcwDevice, host_features[0]),
|
852 |
DEFINE_PROP_END_OF_LIST(), |
853 |
}; |
854 |
|
855 |
static void virtio_ccw_serial_class_init(ObjectClass *klass, void *data) |
856 |
{ |
857 |
DeviceClass *dc = DEVICE_CLASS(klass); |
858 |
VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass); |
859 |
|
860 |
k->init = virtio_ccw_serial_init; |
861 |
k->exit = virtio_ccw_exit; |
862 |
dc->reset = virtio_ccw_reset; |
863 |
dc->props = virtio_ccw_serial_properties; |
864 |
} |
865 |
|
866 |
static const TypeInfo virtio_ccw_serial = { |
867 |
.name = TYPE_VIRTIO_SERIAL_CCW, |
868 |
.parent = TYPE_VIRTIO_CCW_DEVICE, |
869 |
.instance_size = sizeof(VirtioSerialCcw),
|
870 |
.instance_init = virtio_ccw_serial_instance_init, |
871 |
.class_init = virtio_ccw_serial_class_init, |
872 |
}; |
873 |
|
874 |
static Property virtio_ccw_balloon_properties[] = {
|
875 |
DEFINE_PROP_STRING("devno", VirtioCcwDevice, bus_id),
|
876 |
DEFINE_VIRTIO_COMMON_FEATURES(VirtioCcwDevice, host_features[0]),
|
877 |
DEFINE_PROP_END_OF_LIST(), |
878 |
}; |
879 |
|
880 |
static void virtio_ccw_balloon_class_init(ObjectClass *klass, void *data) |
881 |
{ |
882 |
DeviceClass *dc = DEVICE_CLASS(klass); |
883 |
VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass); |
884 |
|
885 |
k->init = virtio_ccw_balloon_init; |
886 |
k->exit = virtio_ccw_exit; |
887 |
dc->reset = virtio_ccw_reset; |
888 |
dc->props = virtio_ccw_balloon_properties; |
889 |
} |
890 |
|
891 |
static const TypeInfo virtio_ccw_balloon = { |
892 |
.name = TYPE_VIRTIO_BALLOON_CCW, |
893 |
.parent = TYPE_VIRTIO_CCW_DEVICE, |
894 |
.instance_size = sizeof(VirtIOBalloonCcw),
|
895 |
.instance_init = virtio_ccw_balloon_instance_init, |
896 |
.class_init = virtio_ccw_balloon_class_init, |
897 |
}; |
898 |
|
899 |
static Property virtio_ccw_scsi_properties[] = {
|
900 |
DEFINE_PROP_STRING("devno", VirtioCcwDevice, bus_id),
|
901 |
DEFINE_VIRTIO_SCSI_PROPERTIES(VirtIOSCSICcw, vdev.parent_obj.conf), |
902 |
DEFINE_VIRTIO_SCSI_FEATURES(VirtioCcwDevice, host_features[0]),
|
903 |
DEFINE_PROP_END_OF_LIST(), |
904 |
}; |
905 |
|
906 |
static void virtio_ccw_scsi_class_init(ObjectClass *klass, void *data) |
907 |
{ |
908 |
DeviceClass *dc = DEVICE_CLASS(klass); |
909 |
VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass); |
910 |
|
911 |
k->init = virtio_ccw_scsi_init; |
912 |
k->exit = virtio_ccw_exit; |
913 |
dc->reset = virtio_ccw_reset; |
914 |
dc->props = virtio_ccw_scsi_properties; |
915 |
} |
916 |
|
917 |
static const TypeInfo virtio_ccw_scsi = { |
918 |
.name = TYPE_VIRTIO_SCSI_CCW, |
919 |
.parent = TYPE_VIRTIO_CCW_DEVICE, |
920 |
.instance_size = sizeof(VirtIOSCSICcw),
|
921 |
.instance_init = virtio_ccw_scsi_instance_init, |
922 |
.class_init = virtio_ccw_scsi_class_init, |
923 |
}; |
924 |
|
925 |
#ifdef CONFIG_VHOST_SCSI
|
926 |
static Property vhost_ccw_scsi_properties[] = {
|
927 |
DEFINE_PROP_STRING("devno", VirtioCcwDevice, bus_id),
|
928 |
DEFINE_VHOST_SCSI_PROPERTIES(VirtIOSCSICcw, vdev.parent_obj.conf), |
929 |
DEFINE_VIRTIO_COMMON_FEATURES(VirtioCcwDevice, host_features[0]),
|
930 |
DEFINE_PROP_END_OF_LIST(), |
931 |
}; |
932 |
|
933 |
static void vhost_ccw_scsi_class_init(ObjectClass *klass, void *data) |
934 |
{ |
935 |
DeviceClass *dc = DEVICE_CLASS(klass); |
936 |
VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass); |
937 |
|
938 |
k->init = vhost_ccw_scsi_init; |
939 |
k->exit = virtio_ccw_exit; |
940 |
dc->reset = virtio_ccw_reset; |
941 |
dc->props = vhost_ccw_scsi_properties; |
942 |
} |
943 |
|
944 |
static const TypeInfo vhost_ccw_scsi = { |
945 |
.name = TYPE_VHOST_SCSI_CCW, |
946 |
.parent = TYPE_VIRTIO_CCW_DEVICE, |
947 |
.instance_size = sizeof(VirtIOSCSICcw),
|
948 |
.instance_init = vhost_ccw_scsi_instance_init, |
949 |
.class_init = vhost_ccw_scsi_class_init, |
950 |
}; |
951 |
#endif
|
952 |
|
953 |
static void virtio_ccw_rng_instance_init(Object *obj) |
954 |
{ |
955 |
VirtIORNGCcw *dev = VIRTIO_RNG_CCW(obj); |
956 |
object_initialize(OBJECT(&dev->vdev), TYPE_VIRTIO_RNG); |
957 |
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL); |
958 |
object_property_add_link(obj, "rng", TYPE_RNG_BACKEND,
|
959 |
(Object **)&dev->vdev.conf.rng, NULL);
|
960 |
} |
961 |
|
962 |
static Property virtio_ccw_rng_properties[] = {
|
963 |
DEFINE_PROP_STRING("devno", VirtioCcwDevice, bus_id),
|
964 |
DEFINE_VIRTIO_COMMON_FEATURES(VirtioCcwDevice, host_features[0]),
|
965 |
DEFINE_VIRTIO_RNG_PROPERTIES(VirtIORNGCcw, vdev.conf), |
966 |
DEFINE_PROP_END_OF_LIST(), |
967 |
}; |
968 |
|
969 |
static void virtio_ccw_rng_class_init(ObjectClass *klass, void *data) |
970 |
{ |
971 |
DeviceClass *dc = DEVICE_CLASS(klass); |
972 |
VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass); |
973 |
|
974 |
k->init = virtio_ccw_rng_init; |
975 |
k->exit = virtio_ccw_exit; |
976 |
dc->reset = virtio_ccw_reset; |
977 |
dc->props = virtio_ccw_rng_properties; |
978 |
} |
979 |
|
980 |
static const TypeInfo virtio_ccw_rng = { |
981 |
.name = TYPE_VIRTIO_RNG_CCW, |
982 |
.parent = TYPE_VIRTIO_CCW_DEVICE, |
983 |
.instance_size = sizeof(VirtIORNGCcw),
|
984 |
.instance_init = virtio_ccw_rng_instance_init, |
985 |
.class_init = virtio_ccw_rng_class_init, |
986 |
}; |
987 |
|
988 |
static int virtio_ccw_busdev_init(DeviceState *dev) |
989 |
{ |
990 |
VirtioCcwDevice *_dev = (VirtioCcwDevice *)dev; |
991 |
VirtIOCCWDeviceClass *_info = VIRTIO_CCW_DEVICE_GET_CLASS(dev); |
992 |
|
993 |
virtio_ccw_bus_new(&_dev->bus, _dev); |
994 |
|
995 |
return _info->init(_dev);
|
996 |
} |
997 |
|
998 |
static int virtio_ccw_busdev_exit(DeviceState *dev) |
999 |
{ |
1000 |
VirtioCcwDevice *_dev = (VirtioCcwDevice *)dev; |
1001 |
VirtIOCCWDeviceClass *_info = VIRTIO_CCW_DEVICE_GET_CLASS(dev); |
1002 |
|
1003 |
return _info->exit(_dev);
|
1004 |
} |
1005 |
|
1006 |
static int virtio_ccw_busdev_unplug(DeviceState *dev) |
1007 |
{ |
1008 |
VirtioCcwDevice *_dev = (VirtioCcwDevice *)dev; |
1009 |
SubchDev *sch = _dev->sch; |
1010 |
|
1011 |
/*
|
1012 |
* We should arrive here only for device_del, since we don't support
|
1013 |
* direct hot(un)plug of channels, but only through virtio.
|
1014 |
*/
|
1015 |
assert(sch != NULL);
|
1016 |
/* Subchannel is now disabled and no longer valid. */
|
1017 |
sch->curr_status.pmcw.flags &= ~(PMCW_FLAGS_MASK_ENA | |
1018 |
PMCW_FLAGS_MASK_DNV); |
1019 |
|
1020 |
css_generate_sch_crws(sch->cssid, sch->ssid, sch->schid, 1, 0); |
1021 |
|
1022 |
qdev_free(dev); |
1023 |
return 0; |
1024 |
} |
1025 |
|
1026 |
static void virtio_ccw_device_class_init(ObjectClass *klass, void *data) |
1027 |
{ |
1028 |
DeviceClass *dc = DEVICE_CLASS(klass); |
1029 |
|
1030 |
dc->init = virtio_ccw_busdev_init; |
1031 |
dc->exit = virtio_ccw_busdev_exit; |
1032 |
dc->unplug = virtio_ccw_busdev_unplug; |
1033 |
dc->bus_type = TYPE_VIRTUAL_CSS_BUS; |
1034 |
|
1035 |
} |
1036 |
|
1037 |
static const TypeInfo virtio_ccw_device_info = { |
1038 |
.name = TYPE_VIRTIO_CCW_DEVICE, |
1039 |
.parent = TYPE_DEVICE, |
1040 |
.instance_size = sizeof(VirtioCcwDevice),
|
1041 |
.class_init = virtio_ccw_device_class_init, |
1042 |
.class_size = sizeof(VirtIOCCWDeviceClass),
|
1043 |
.abstract = true,
|
1044 |
}; |
1045 |
|
1046 |
/***************** Virtual-css Bus Bridge Device ********************/
|
1047 |
/* Only required to have the virtio bus as child in the system bus */
|
1048 |
|
1049 |
static int virtual_css_bridge_init(SysBusDevice *dev) |
1050 |
{ |
1051 |
/* nothing */
|
1052 |
return 0; |
1053 |
} |
1054 |
|
1055 |
static void virtual_css_bridge_class_init(ObjectClass *klass, void *data) |
1056 |
{ |
1057 |
DeviceClass *dc = DEVICE_CLASS(klass); |
1058 |
SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); |
1059 |
|
1060 |
k->init = virtual_css_bridge_init; |
1061 |
dc->no_user = 1;
|
1062 |
} |
1063 |
|
1064 |
static const TypeInfo virtual_css_bridge_info = { |
1065 |
.name = "virtual-css-bridge",
|
1066 |
.parent = TYPE_SYS_BUS_DEVICE, |
1067 |
.instance_size = sizeof(SysBusDevice),
|
1068 |
.class_init = virtual_css_bridge_class_init, |
1069 |
}; |
1070 |
|
1071 |
/* virtio-ccw-bus */
|
1072 |
|
1073 |
static void virtio_ccw_bus_new(VirtioBusState *bus, VirtioCcwDevice *dev) |
1074 |
{ |
1075 |
DeviceState *qdev = DEVICE(dev); |
1076 |
BusState *qbus; |
1077 |
char virtio_bus_name[] = "virtio-bus"; |
1078 |
|
1079 |
qbus_create_inplace((BusState *)bus, TYPE_VIRTIO_CCW_BUS, qdev, |
1080 |
virtio_bus_name); |
1081 |
qbus = BUS(bus); |
1082 |
qbus->allow_hotplug = 1;
|
1083 |
} |
1084 |
|
1085 |
static void virtio_ccw_bus_class_init(ObjectClass *klass, void *data) |
1086 |
{ |
1087 |
VirtioBusClass *k = VIRTIO_BUS_CLASS(klass); |
1088 |
BusClass *bus_class = BUS_CLASS(klass); |
1089 |
|
1090 |
bus_class->max_dev = 1;
|
1091 |
k->notify = virtio_ccw_notify; |
1092 |
k->get_features = virtio_ccw_get_features; |
1093 |
} |
1094 |
|
1095 |
static const TypeInfo virtio_ccw_bus_info = { |
1096 |
.name = TYPE_VIRTIO_CCW_BUS, |
1097 |
.parent = TYPE_VIRTIO_BUS, |
1098 |
.instance_size = sizeof(VirtioCcwBusState),
|
1099 |
.class_init = virtio_ccw_bus_class_init, |
1100 |
}; |
1101 |
|
1102 |
static void virtio_ccw_register(void) |
1103 |
{ |
1104 |
type_register_static(&virtio_ccw_bus_info); |
1105 |
type_register_static(&virtual_css_bus_info); |
1106 |
type_register_static(&virtio_ccw_device_info); |
1107 |
type_register_static(&virtio_ccw_serial); |
1108 |
type_register_static(&virtio_ccw_blk); |
1109 |
type_register_static(&virtio_ccw_net); |
1110 |
type_register_static(&virtio_ccw_balloon); |
1111 |
type_register_static(&virtio_ccw_scsi); |
1112 |
#ifdef CONFIG_VHOST_SCSI
|
1113 |
type_register_static(&vhost_ccw_scsi); |
1114 |
#endif
|
1115 |
type_register_static(&virtio_ccw_rng); |
1116 |
type_register_static(&virtual_css_bridge_info); |
1117 |
} |
1118 |
|
1119 |
type_init(virtio_ccw_register) |