1efbc1783SThomas Huth /* 2efbc1783SThomas Huth * virtio ccw net implementation 3efbc1783SThomas Huth * 4efbc1783SThomas Huth * Copyright 2012, 2015 IBM Corp. 5efbc1783SThomas Huth * Author(s): Cornelia Huck <cornelia.huck@de.ibm.com> 6efbc1783SThomas Huth * 7efbc1783SThomas Huth * This work is licensed under the terms of the GNU GPL, version 2 or (at 8efbc1783SThomas Huth * your option) any later version. See the COPYING file in the top-level 9efbc1783SThomas Huth * directory. 10efbc1783SThomas Huth */ 11efbc1783SThomas Huth 12efbc1783SThomas Huth #include "qemu/osdep.h" 13a27bd6c7SMarkus Armbruster #include "hw/qdev-properties.h" 14efbc1783SThomas Huth #include "hw/virtio/virtio.h" 15efbc1783SThomas Huth #include "qapi/error.h" 160b8fa32fSMarkus Armbruster #include "qemu/module.h" 17efbc1783SThomas Huth #include "virtio-ccw.h" 18efbc1783SThomas Huth 19efbc1783SThomas Huth static void virtio_ccw_net_realize(VirtioCcwDevice *ccw_dev, Error **errp) 20efbc1783SThomas Huth { 21efbc1783SThomas Huth DeviceState *qdev = DEVICE(ccw_dev); 22efbc1783SThomas Huth VirtIONetCcw *dev = VIRTIO_NET_CCW(ccw_dev); 23efbc1783SThomas Huth DeviceState *vdev = DEVICE(&dev->vdev); 24efbc1783SThomas Huth 25efbc1783SThomas Huth virtio_net_set_netclient_name(&dev->vdev, qdev->id, 26efbc1783SThomas Huth object_get_typename(OBJECT(qdev))); 27*99ba777eSMarkus Armbruster qdev_realize(vdev, BUS(&ccw_dev->bus), errp); 28efbc1783SThomas Huth } 29efbc1783SThomas Huth 30efbc1783SThomas Huth static void virtio_ccw_net_instance_init(Object *obj) 31efbc1783SThomas Huth { 32efbc1783SThomas Huth VirtIONetCcw *dev = VIRTIO_NET_CCW(obj); 33efbc1783SThomas Huth 34efbc1783SThomas Huth virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev), 35efbc1783SThomas Huth TYPE_VIRTIO_NET); 36efbc1783SThomas Huth object_property_add_alias(obj, "bootindex", OBJECT(&dev->vdev), 37d2623129SMarkus Armbruster "bootindex"); 38efbc1783SThomas Huth } 39efbc1783SThomas Huth 40efbc1783SThomas Huth static Property virtio_ccw_net_properties[] = { 41efbc1783SThomas Huth DEFINE_PROP_BIT("ioeventfd", VirtioCcwDevice, flags, 42efbc1783SThomas Huth VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT, true), 43efbc1783SThomas Huth DEFINE_PROP_UINT32("max_revision", VirtioCcwDevice, max_rev, 44efbc1783SThomas Huth VIRTIO_CCW_MAX_REV), 45efbc1783SThomas Huth DEFINE_PROP_END_OF_LIST(), 46efbc1783SThomas Huth }; 47efbc1783SThomas Huth 48efbc1783SThomas Huth static void virtio_ccw_net_class_init(ObjectClass *klass, void *data) 49efbc1783SThomas Huth { 50efbc1783SThomas Huth DeviceClass *dc = DEVICE_CLASS(klass); 51efbc1783SThomas Huth VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass); 52efbc1783SThomas Huth 53efbc1783SThomas Huth k->realize = virtio_ccw_net_realize; 544f67d30bSMarc-André Lureau device_class_set_props(dc, virtio_ccw_net_properties); 55efbc1783SThomas Huth set_bit(DEVICE_CATEGORY_NETWORK, dc->categories); 56efbc1783SThomas Huth } 57efbc1783SThomas Huth 58efbc1783SThomas Huth static const TypeInfo virtio_ccw_net = { 59efbc1783SThomas Huth .name = TYPE_VIRTIO_NET_CCW, 60efbc1783SThomas Huth .parent = TYPE_VIRTIO_CCW_DEVICE, 61efbc1783SThomas Huth .instance_size = sizeof(VirtIONetCcw), 62efbc1783SThomas Huth .instance_init = virtio_ccw_net_instance_init, 63efbc1783SThomas Huth .class_init = virtio_ccw_net_class_init, 64efbc1783SThomas Huth }; 65efbc1783SThomas Huth 66efbc1783SThomas Huth static void virtio_ccw_net_register(void) 67efbc1783SThomas Huth { 68efbc1783SThomas Huth type_register_static(&virtio_ccw_net); 69efbc1783SThomas Huth } 70efbc1783SThomas Huth 71efbc1783SThomas Huth type_init(virtio_ccw_net_register) 72