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