virtio-ccw: add virtio-crypto-ccw device

Wire up virtio-crypto for the CCW based VIRTIO.

Signed-off-by: Halil Pasic <pasic@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
This commit is contained in:
Halil Pasic 2016-11-03 13:39:15 +01:00 committed by Cornelia Huck
parent 47e13dfd86
commit d2256070d2
2 changed files with 73 additions and 0 deletions

View File

@ -894,6 +894,24 @@ static void virtio_ccw_rng_realize(VirtioCcwDevice *ccw_dev, Error **errp)
NULL);
}
static void virtio_ccw_crypto_realize(VirtioCcwDevice *ccw_dev, Error **errp)
{
VirtIOCryptoCcw *dev = VIRTIO_CRYPTO_CCW(ccw_dev);
DeviceState *vdev = DEVICE(&dev->vdev);
Error *err = NULL;
qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus));
object_property_set_bool(OBJECT(vdev), true, "realized", &err);
if (err) {
error_propagate(errp, err);
return;
}
object_property_set_link(OBJECT(vdev),
OBJECT(dev->vdev.conf.cryptodev), "cryptodev",
NULL);
}
/* DeviceState to VirtioCcwDevice. Note: used on datapath,
* be careful and test performance if you change this.
*/
@ -1534,6 +1552,48 @@ static const TypeInfo virtio_ccw_rng = {
.class_init = virtio_ccw_rng_class_init,
};
static Property virtio_ccw_crypto_properties[] = {
DEFINE_PROP_CSS_DEV_ID("devno", VirtioCcwDevice, parent_obj.bus_id),
DEFINE_PROP_BIT("ioeventfd", VirtioCcwDevice, flags,
VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT, true),
DEFINE_PROP_UINT32("max_revision", VirtioCcwDevice, max_rev,
VIRTIO_CCW_MAX_REV),
DEFINE_PROP_END_OF_LIST(),
};
static void virtio_ccw_crypto_instance_init(Object *obj)
{
VirtIOCryptoCcw *dev = VIRTIO_CRYPTO_CCW(obj);
VirtioCcwDevice *ccw_dev = VIRTIO_CCW_DEVICE(obj);
ccw_dev->force_revision_1 = true;
virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
TYPE_VIRTIO_CRYPTO);
object_property_add_alias(obj, "cryptodev", OBJECT(&dev->vdev),
"cryptodev", &error_abort);
}
static void virtio_ccw_crypto_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass);
k->realize = virtio_ccw_crypto_realize;
k->exit = virtio_ccw_exit;
dc->reset = virtio_ccw_reset;
dc->props = virtio_ccw_crypto_properties;
set_bit(DEVICE_CATEGORY_MISC, dc->categories);
}
static const TypeInfo virtio_ccw_crypto = {
.name = TYPE_VIRTIO_CRYPTO_CCW,
.parent = TYPE_VIRTIO_CCW_DEVICE,
.instance_size = sizeof(VirtIOCryptoCcw),
.instance_init = virtio_ccw_crypto_instance_init,
.class_init = virtio_ccw_crypto_class_init,
};
static void virtio_ccw_busdev_realize(DeviceState *dev, Error **errp)
{
VirtioCcwDevice *_dev = (VirtioCcwDevice *)dev;
@ -1736,6 +1796,7 @@ static void virtio_ccw_register(void)
#ifdef CONFIG_VHOST_VSOCK
type_register_static(&vhost_vsock_ccw_info);
#endif
type_register_static(&virtio_ccw_crypto);
}
type_init(virtio_ccw_register)

View File

@ -22,6 +22,7 @@
#endif
#include "hw/virtio/virtio-balloon.h"
#include "hw/virtio/virtio-rng.h"
#include "hw/virtio/virtio-crypto.h"
#include "hw/virtio/virtio-bus.h"
#ifdef CONFIG_VHOST_VSOCK
#include "hw/virtio/vhost-vsock.h"
@ -183,6 +184,17 @@ typedef struct VirtIORNGCcw {
VirtIORNG vdev;
} VirtIORNGCcw;
/* virtio-crypto-ccw */
#define TYPE_VIRTIO_CRYPTO_CCW "virtio-crypto-ccw"
#define VIRTIO_CRYPTO_CCW(obj) \
OBJECT_CHECK(VirtIOCryptoCcw, (obj), TYPE_VIRTIO_CRYPTO_CCW)
typedef struct VirtIOCryptoCcw {
VirtioCcwDevice parent_obj;
VirtIOCrypto vdev;
} VirtIOCryptoCcw;
VirtIODevice *virtio_ccw_get_vdev(SubchDev *sch);
#ifdef CONFIG_VIRTFS