xref: /qemu/hw/s390x/virtio-ccw-crypto.c (revision 7da50d64)
1a8e1b5ffSThomas Huth /*
2a8e1b5ffSThomas Huth  * virtio ccw crypto implementation
3a8e1b5ffSThomas Huth  *
4a8e1b5ffSThomas Huth  * Copyright 2012, 2015 IBM Corp.
5a8e1b5ffSThomas Huth  *
6a8e1b5ffSThomas Huth  * This work is licensed under the terms of the GNU GPL, version 2 or (at
7a8e1b5ffSThomas Huth  * your option) any later version. See the COPYING file in the top-level
8a8e1b5ffSThomas Huth  * directory.
9a8e1b5ffSThomas Huth  */
10a8e1b5ffSThomas Huth 
11a8e1b5ffSThomas Huth #include "qemu/osdep.h"
12a27bd6c7SMarkus Armbruster #include "hw/qdev-properties.h"
13a8e1b5ffSThomas Huth #include "hw/virtio/virtio.h"
14a8e1b5ffSThomas Huth #include "qapi/error.h"
150b8fa32fSMarkus Armbruster #include "qemu/module.h"
16a8e1b5ffSThomas Huth #include "virtio-ccw.h"
17*7da50d64SPaolo Bonzini #include "hw/virtio/virtio-crypto.h"
18*7da50d64SPaolo Bonzini 
19*7da50d64SPaolo Bonzini #define TYPE_VIRTIO_CRYPTO_CCW "virtio-crypto-ccw"
20*7da50d64SPaolo Bonzini OBJECT_DECLARE_SIMPLE_TYPE(VirtIOCryptoCcw, VIRTIO_CRYPTO_CCW)
21*7da50d64SPaolo Bonzini 
22*7da50d64SPaolo Bonzini struct VirtIOCryptoCcw {
23*7da50d64SPaolo Bonzini     VirtioCcwDevice parent_obj;
24*7da50d64SPaolo Bonzini     VirtIOCrypto vdev;
25*7da50d64SPaolo Bonzini };
26a8e1b5ffSThomas Huth 
virtio_ccw_crypto_realize(VirtioCcwDevice * ccw_dev,Error ** errp)27a8e1b5ffSThomas Huth static void virtio_ccw_crypto_realize(VirtioCcwDevice *ccw_dev, Error **errp)
28a8e1b5ffSThomas Huth {
29a8e1b5ffSThomas Huth     VirtIOCryptoCcw *dev = VIRTIO_CRYPTO_CCW(ccw_dev);
30a8e1b5ffSThomas Huth     DeviceState *vdev = DEVICE(&dev->vdev);
31a8e1b5ffSThomas Huth 
32668f62ecSMarkus Armbruster     if (!qdev_realize(vdev, BUS(&ccw_dev->bus), errp)) {
33a8e1b5ffSThomas Huth         return;
34a8e1b5ffSThomas Huth     }
35a8e1b5ffSThomas Huth }
36a8e1b5ffSThomas Huth 
virtio_ccw_crypto_instance_init(Object * obj)37a8e1b5ffSThomas Huth static void virtio_ccw_crypto_instance_init(Object *obj)
38a8e1b5ffSThomas Huth {
39a8e1b5ffSThomas Huth     VirtIOCryptoCcw *dev = VIRTIO_CRYPTO_CCW(obj);
40a8e1b5ffSThomas Huth     VirtioCcwDevice *ccw_dev = VIRTIO_CCW_DEVICE(obj);
41a8e1b5ffSThomas Huth 
42a8e1b5ffSThomas Huth     ccw_dev->force_revision_1 = true;
43a8e1b5ffSThomas Huth     virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
44a8e1b5ffSThomas Huth                                 TYPE_VIRTIO_CRYPTO);
45a8e1b5ffSThomas Huth }
46a8e1b5ffSThomas Huth 
47a8e1b5ffSThomas Huth static Property virtio_ccw_crypto_properties[] = {
48a8e1b5ffSThomas Huth     DEFINE_PROP_BIT("ioeventfd", VirtioCcwDevice, flags,
49a8e1b5ffSThomas Huth                     VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT, true),
50a8e1b5ffSThomas Huth     DEFINE_PROP_UINT32("max_revision", VirtioCcwDevice, max_rev,
51a8e1b5ffSThomas Huth                        VIRTIO_CCW_MAX_REV),
52a8e1b5ffSThomas Huth     DEFINE_PROP_END_OF_LIST(),
53a8e1b5ffSThomas Huth };
54a8e1b5ffSThomas Huth 
virtio_ccw_crypto_class_init(ObjectClass * klass,void * data)55a8e1b5ffSThomas Huth static void virtio_ccw_crypto_class_init(ObjectClass *klass, void *data)
56a8e1b5ffSThomas Huth {
57a8e1b5ffSThomas Huth     DeviceClass *dc = DEVICE_CLASS(klass);
58a8e1b5ffSThomas Huth     VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass);
59a8e1b5ffSThomas Huth 
60a8e1b5ffSThomas Huth     k->realize = virtio_ccw_crypto_realize;
614f67d30bSMarc-André Lureau     device_class_set_props(dc, virtio_ccw_crypto_properties);
62a8e1b5ffSThomas Huth     set_bit(DEVICE_CATEGORY_MISC, dc->categories);
63a8e1b5ffSThomas Huth }
64a8e1b5ffSThomas Huth 
65a8e1b5ffSThomas Huth static const TypeInfo virtio_ccw_crypto = {
66a8e1b5ffSThomas Huth     .name          = TYPE_VIRTIO_CRYPTO_CCW,
67a8e1b5ffSThomas Huth     .parent        = TYPE_VIRTIO_CCW_DEVICE,
68a8e1b5ffSThomas Huth     .instance_size = sizeof(VirtIOCryptoCcw),
69a8e1b5ffSThomas Huth     .instance_init = virtio_ccw_crypto_instance_init,
70a8e1b5ffSThomas Huth     .class_init    = virtio_ccw_crypto_class_init,
71a8e1b5ffSThomas Huth };
72a8e1b5ffSThomas Huth 
virtio_ccw_crypto_register(void)73a8e1b5ffSThomas Huth static void virtio_ccw_crypto_register(void)
74a8e1b5ffSThomas Huth {
75a8e1b5ffSThomas Huth     type_register_static(&virtio_ccw_crypto);
76a8e1b5ffSThomas Huth }
77a8e1b5ffSThomas Huth 
78a8e1b5ffSThomas Huth type_init(virtio_ccw_crypto_register)
79