[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 07/10] virtio-crypto: set capacity of algorithms
From: |
Gonglei |
Subject: |
[Qemu-devel] [PATCH v3 07/10] virtio-crypto: set capacity of algorithms supported |
Date: |
Mon, 19 Sep 2016 16:16:19 +0800 |
Expose the capacity of algorithms supported by
virtio crypto device to the frontend driver using
pci configuration space.
Signed-off-by: Gonglei <address@hidden>
---
hw/virtio/virtio-crypto.c | 39 ++++++++++++++++++++++++++++++++++++++-
include/hw/virtio/virtio-crypto.h | 14 ++++++++++++++
2 files changed, 52 insertions(+), 1 deletion(-)
diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c
index b1c10b2..e78656c 100644
--- a/hw/virtio/virtio-crypto.c
+++ b/hw/virtio/virtio-crypto.c
@@ -87,6 +87,26 @@ static void virtio_crypto_reset(VirtIODevice *vdev)
}
}
+static void virtio_crypto_init_config(VirtIODevice *vdev)
+{
+ VirtIOCrypto *vcrypto = VIRTIO_CRYPTO(vdev);
+
+ vcrypto->conf.crypto_services =
+ vcrypto->conf.cryptodev->conf.crypto_services;
+ vcrypto->conf.cipher_algo_l =
+ vcrypto->conf.cryptodev->conf.cipher_algo_l;
+ vcrypto->conf.cipher_algo_h =
+ vcrypto->conf.cryptodev->conf.cipher_algo_h;
+ vcrypto->conf.hash_algo = vcrypto->conf.cryptodev->conf.hash_algo;
+ vcrypto->conf.mac_algo_l = vcrypto->conf.cryptodev->conf.mac_algo_l;
+ vcrypto->conf.mac_algo_h = vcrypto->conf.cryptodev->conf.mac_algo_h;
+ vcrypto->conf.asym_algo = vcrypto->conf.cryptodev->conf.asym_algo;
+ vcrypto->conf.kdf_algo = vcrypto->conf.cryptodev->conf.kdf_algo;
+ vcrypto->conf.aead_algo = vcrypto->conf.cryptodev->conf.aead_algo;
+ vcrypto->conf.primitive_algo =
+ vcrypto->conf.cryptodev->conf.primitive_algo;
+}
+
static void virtio_crypto_device_realize(DeviceState *dev, Error **errp)
{
VirtIODevice *vdev = VIRTIO_DEVICE(dev);
@@ -120,6 +140,7 @@ static void virtio_crypto_device_realize(DeviceState *dev,
Error **errp)
} else {
vcrypto->status |= VIRTIO_CRYPTO_S_HW_READY;
}
+ virtio_crypto_init_config(vdev);
register_savevm(dev, "virtio-crypto", -1, 1, virtio_crypto_save,
virtio_crypto_load, vcrypto);
}
@@ -140,7 +161,23 @@ static Property virtio_crypto_properties[] = {
static void virtio_crypto_get_config(VirtIODevice *vdev, uint8_t *config)
{
-
+ VirtIOCrypto *c = VIRTIO_CRYPTO(vdev);
+ struct virtio_crypto_config crypto_cfg;
+
+ crypto_cfg.status = c->status;
+ crypto_cfg.max_dataqueues = c->max_queues;
+ crypto_cfg.crypto_services = c->conf.crypto_services;
+ crypto_cfg.cipher_algo_l = c->conf.cipher_algo_l;
+ crypto_cfg.cipher_algo_h = c->conf.cipher_algo_h;
+ crypto_cfg.hash_algo = c->conf.hash_algo;
+ crypto_cfg.mac_algo_l = c->conf.mac_algo_l;
+ crypto_cfg.mac_algo_h = c->conf.mac_algo_h;
+ crypto_cfg.asym_algo = c->conf.asym_algo;
+ crypto_cfg.kdf_algo = c->conf.kdf_algo;
+ crypto_cfg.aead_algo = c->conf.aead_algo;
+ crypto_cfg.primitive_algo = c->conf.primitive_algo;
+
+ memcpy(config, &crypto_cfg, c->config_size);
}
static void virtio_crypto_set_config(VirtIODevice *vdev, const uint8_t *config)
diff --git a/include/hw/virtio/virtio-crypto.h
b/include/hw/virtio/virtio-crypto.h
index 2fe2499..f6fe2d8 100644
--- a/include/hw/virtio/virtio-crypto.h
+++ b/include/hw/virtio/virtio-crypto.h
@@ -39,6 +39,20 @@ do { printf("virtio_crypto: " fmt , ## __VA_ARGS__); } while
(0)
typedef struct VirtIOCryptoConf {
QCryptoCryptoDevBackend *cryptodev;
+
+ /* Supported service mask */
+ uint32_t crypto_services;
+
+ /* Detailed algorithms mask */
+ uint32_t cipher_algo_l;
+ uint32_t cipher_algo_h;
+ uint32_t hash_algo;
+ uint32_t mac_algo_l;
+ uint32_t mac_algo_h;
+ uint32_t asym_algo;
+ uint32_t kdf_algo;
+ uint32_t aead_algo;
+ uint32_t primitive_algo;
} VirtIOCryptoConf;
struct VirtIOCrypto;
--
1.7.12.4
- [Qemu-devel] [PATCH v3 00/10] virtio-crypto: introduce framework and device emulation, Gonglei, 2016/09/19
- [Qemu-devel] [PATCH v3 02/10] cryptodev: add symmetric algorithm operation stuff, Gonglei, 2016/09/19
- [Qemu-devel] [PATCH v3 05/10] virtio-crypto: add virtio crypto device emulation, Gonglei, 2016/09/19
- [Qemu-devel] [PATCH v3 01/10] cryptodev: introduce cryptodev backend interface, Gonglei, 2016/09/19
- [Qemu-devel] [PATCH v3 07/10] virtio-crypto: set capacity of algorithms supported,
Gonglei <=
- [Qemu-devel] [PATCH v3 09/10] virtio-crypto: add data queue processing handler, Gonglei, 2016/09/19
- [Qemu-devel] [PATCH v3 10/10] cryptodev: introduce an unified wrapper for crypto operation, Gonglei, 2016/09/19
- [Qemu-devel] [PATCH v3 06/10] virtio-crypto-pci: add virtio crypto pci support, Gonglei, 2016/09/19
- [Qemu-devel] [PATCH v3 04/10] cryptodev: introduce gcrypt lib as a new cryptodev backend, Gonglei, 2016/09/19
- [Qemu-devel] [PATCH v3 03/10] virtio-crypto: introduce virtio_crypto.h, Gonglei, 2016/09/19
- [Qemu-devel] [PATCH v3 08/10] virtio-crypto: add control queue handler, Gonglei, 2016/09/19