[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v1 10/14] virtio-crypto: set capacity of crypto lega
From: |
Gonglei |
Subject: |
[Qemu-devel] [PATCH v1 10/14] virtio-crypto: set capacity of crypto legacy hardware |
Date: |
Thu, 8 Sep 2016 11:42:32 +0800 |
Set the crypto legacy hardware's capacity according to the
backend peer cryptodev's capacity. We only support only one
queue at present.
Virtio crypto device is a kind of crypto legacy hardware.
Signed-off-by: Gonglei <address@hidden>
---
crypto/crypto.c | 17 +++++++++++++++++
hw/virtio/virtio-crypto.c | 28 +++++++++++++++++++++++++++-
2 files changed, 44 insertions(+), 1 deletion(-)
diff --git a/crypto/crypto.c b/crypto/crypto.c
index 184f837..ba99d7c 100644
--- a/crypto/crypto.c
+++ b/crypto/crypto.c
@@ -228,6 +228,7 @@ qemu_new_crypto_legacy_hw(CryptoClientInfo *info,
CryptoLegacyHWState *crypto;
CryptoClientState **peers = conf->peers.ccs;
int i, queues = MAX(1, conf->peers.queues);
+ int has_set = 0;
assert(info->type == CRYPTO_CLIENT_OPTIONS_KIND_LEGACY_HW);
assert(info->size >= sizeof(CryptoLegacyHWState));
@@ -242,6 +243,22 @@ qemu_new_crypto_legacy_hw(CryptoClientInfo *info,
NULL);
crypto->ccs[i].queue_index = i;
crypto->ccs[i].ready = true;
+ /* The mask bits of crypto_services and algos in
+ CryptoLegacyHWConf is set only once */
+ if (has_set == 0 && peers[i]) {
+ conf->crypto_services = peers[i]->crypto_services;
+ conf->cipher_algo_l = peers[i]->cipher_algo_l;
+ conf->cipher_algo_h = peers[i]->cipher_algo_h;
+ conf->hash_algo = peers[i]->hash_algo;
+ conf->mac_algo_l = peers[i]->mac_algo_l;
+ conf->mac_algo_h = peers[i]->mac_algo_h;
+ conf->asym_algo = peers[i]->asym_algo;
+ conf->kdf_algo = peers[i]->kdf_algo;
+ conf->aead_algo = peers[i]->aead_algo;
+ conf->primitive_algo = peers[i]->primitive_algo;
+
+ has_set = 1;
+ }
}
return crypto;
diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c
index 23c5041..b7a7b41 100644
--- a/hw/virtio/virtio-crypto.c
+++ b/hw/virtio/virtio-crypto.c
@@ -197,7 +197,33 @@ 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;
+
+ virtio_stl_p(vdev, &crypto_cfg.status, c->status);
+ virtio_stl_p(vdev, &crypto_cfg.max_dataqueues, c->max_queues);
+ virtio_stl_p(vdev, &crypto_cfg.crypto_services,
+ c->legacy_conf.crypto_services);
+ virtio_stl_p(vdev, &crypto_cfg.cipher_algo_l,
+ c->legacy_conf.cipher_algo_l);
+ virtio_stl_p(vdev, &crypto_cfg.cipher_algo_h,
+ c->legacy_conf.cipher_algo_h);
+ virtio_stl_p(vdev, &crypto_cfg.hash_algo,
+ c->legacy_conf.hash_algo);
+ virtio_stl_p(vdev, &crypto_cfg.mac_algo_l,
+ c->legacy_conf.mac_algo_l);
+ virtio_stl_p(vdev, &crypto_cfg.mac_algo_h,
+ c->legacy_conf.mac_algo_h);
+ virtio_stl_p(vdev, &crypto_cfg.asym_algo,
+ c->legacy_conf.asym_algo);
+ virtio_stl_p(vdev, &crypto_cfg.kdf_algo,
+ c->legacy_conf.kdf_algo);
+ virtio_stl_p(vdev, &crypto_cfg.aead_algo,
+ c->legacy_conf.aead_algo);
+ virtio_stl_p(vdev, &crypto_cfg.primitive_algo,
+ c->legacy_conf.primitive_algo);
+
+ memcpy(config, &crypto_cfg, c->config_size);
}
static void virtio_crypto_set_config(VirtIODevice *vdev, const uint8_t *config)
--
1.7.12.4
- [Qemu-devel] [PATCH v1 00/14] virtio-crypto: introduce framework and device emulation, Gonglei, 2016/09/07
- [Qemu-devel] [PATCH v1 06/14] crypto: add internal handle logic layer, Gonglei, 2016/09/07
- [Qemu-devel] [PATCH v1 01/14] crypto: introduce cryptodev backend and crypto legacy hardware, Gonglei, 2016/09/07
- [Qemu-devel] [PATCH v1 03/14] crypto: add cryptoLegacyHW stuff, Gonglei, 2016/09/07
- [Qemu-devel] [PATCH v1 12/14] virtio-crypto: add destroy session logic, Gonglei, 2016/09/07
- [Qemu-devel] [PATCH v1 05/14] crypto: add cryptodev-linux as a cryptodev backend, Gonglei, 2016/09/07
- [Qemu-devel] [PATCH v1 07/14] virtio-crypto: introduce virtio-crypto.h, Gonglei, 2016/09/07
- [Qemu-devel] [PATCH v1 14/14] virtio-crypto: add data virtqueue processing handler, Gonglei, 2016/09/07
- [Qemu-devel] [PATCH v1 13/14] virtio-crypto: get correct input data address for each request, Gonglei, 2016/09/07
- [Qemu-devel] [PATCH v1 10/14] virtio-crypto: set capacity of crypto legacy hardware,
Gonglei <=
- [Qemu-devel] [PATCH v1 11/14] virtio-crypto: add control queue handler, Gonglei, 2016/09/07
- [Qemu-devel] [PATCH v1 09/14] virtio-crypto: add virtio crypto realization modle, Gonglei, 2016/09/07
- [Qemu-devel] [PATCH v1 08/14] virtio-crypto-pci: add virtio crypto pci support, Gonglei, 2016/09/07
- [Qemu-devel] [PATCH v1 02/14] crypto: introduce crypto queue handler, Gonglei, 2016/09/07
- [Qemu-devel] [PATCH v1 04/14] crypto: add symetric algorithms support, Gonglei, 2016/09/07
- Re: [Qemu-devel] [PATCH v1 00/14] virtio-crypto: introduce framework and device emulation, no-reply, 2016/09/08