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"
187da50d64SPaolo Bonzini #include "hw/virtio/virtio-net.h"
197da50d64SPaolo Bonzini
207da50d64SPaolo Bonzini #define TYPE_VIRTIO_NET_CCW "virtio-net-ccw"
217da50d64SPaolo Bonzini OBJECT_DECLARE_SIMPLE_TYPE(VirtIONetCcw, VIRTIO_NET_CCW)
227da50d64SPaolo Bonzini
237da50d64SPaolo Bonzini struct VirtIONetCcw {
247da50d64SPaolo Bonzini VirtioCcwDevice parent_obj;
257da50d64SPaolo Bonzini VirtIONet vdev;
267da50d64SPaolo Bonzini };
27efbc1783SThomas Huth
virtio_ccw_net_realize(VirtioCcwDevice * ccw_dev,Error ** errp)28efbc1783SThomas Huth static void virtio_ccw_net_realize(VirtioCcwDevice *ccw_dev, Error **errp)
29efbc1783SThomas Huth {
30efbc1783SThomas Huth DeviceState *qdev = DEVICE(ccw_dev);
31efbc1783SThomas Huth VirtIONetCcw *dev = VIRTIO_NET_CCW(ccw_dev);
32efbc1783SThomas Huth DeviceState *vdev = DEVICE(&dev->vdev);
33efbc1783SThomas Huth
34efbc1783SThomas Huth virtio_net_set_netclient_name(&dev->vdev, qdev->id,
35efbc1783SThomas Huth object_get_typename(OBJECT(qdev)));
3699ba777eSMarkus Armbruster qdev_realize(vdev, BUS(&ccw_dev->bus), errp);
37efbc1783SThomas Huth }
38efbc1783SThomas Huth
virtio_ccw_net_instance_init(Object * obj)39efbc1783SThomas Huth static void virtio_ccw_net_instance_init(Object *obj)
40efbc1783SThomas Huth {
41efbc1783SThomas Huth VirtIONetCcw *dev = VIRTIO_NET_CCW(obj);
42efbc1783SThomas Huth
43efbc1783SThomas Huth virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
44efbc1783SThomas Huth TYPE_VIRTIO_NET);
45efbc1783SThomas Huth object_property_add_alias(obj, "bootindex", OBJECT(&dev->vdev),
46d2623129SMarkus Armbruster "bootindex");
47efbc1783SThomas Huth }
48efbc1783SThomas Huth
49efbc1783SThomas Huth static Property virtio_ccw_net_properties[] = {
50efbc1783SThomas Huth DEFINE_PROP_BIT("ioeventfd", VirtioCcwDevice, flags,
51efbc1783SThomas Huth VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT, true),
52efbc1783SThomas Huth DEFINE_PROP_UINT32("max_revision", VirtioCcwDevice, max_rev,
53efbc1783SThomas Huth VIRTIO_CCW_MAX_REV),
54*6e7c96aeSThomas Huth DEFINE_PROP_CCW_LOADPARM("loadparm", CcwDevice, loadparm),
55efbc1783SThomas Huth DEFINE_PROP_END_OF_LIST(),
56efbc1783SThomas Huth };
57efbc1783SThomas Huth
virtio_ccw_net_class_init(ObjectClass * klass,void * data)58efbc1783SThomas Huth static void virtio_ccw_net_class_init(ObjectClass *klass, void *data)
59efbc1783SThomas Huth {
60efbc1783SThomas Huth DeviceClass *dc = DEVICE_CLASS(klass);
61efbc1783SThomas Huth VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass);
62efbc1783SThomas Huth
63efbc1783SThomas Huth k->realize = virtio_ccw_net_realize;
644f67d30bSMarc-André Lureau device_class_set_props(dc, virtio_ccw_net_properties);
65efbc1783SThomas Huth set_bit(DEVICE_CATEGORY_NETWORK, dc->categories);
66efbc1783SThomas Huth }
67efbc1783SThomas Huth
68efbc1783SThomas Huth static const TypeInfo virtio_ccw_net = {
69efbc1783SThomas Huth .name = TYPE_VIRTIO_NET_CCW,
70efbc1783SThomas Huth .parent = TYPE_VIRTIO_CCW_DEVICE,
71efbc1783SThomas Huth .instance_size = sizeof(VirtIONetCcw),
72efbc1783SThomas Huth .instance_init = virtio_ccw_net_instance_init,
73efbc1783SThomas Huth .class_init = virtio_ccw_net_class_init,
74efbc1783SThomas Huth };
75efbc1783SThomas Huth
virtio_ccw_net_register(void)76efbc1783SThomas Huth static void virtio_ccw_net_register(void)
77efbc1783SThomas Huth {
78efbc1783SThomas Huth type_register_static(&virtio_ccw_net);
79efbc1783SThomas Huth }
80efbc1783SThomas Huth
81efbc1783SThomas Huth type_init(virtio_ccw_net_register)
82