[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 06/15] crypto: add internal handle logic layer
From: |
Gonglei |
Subject: |
[Qemu-devel] [PATCH v2 06/15] crypto: add internal handle logic layer |
Date: |
Tue, 13 Sep 2016 11:52:12 +0800 |
This patch add some transfering layer or functions,
such as session creation, closing etc, which will be
used by subsequent virtio crypto device patches.
Signed-off-by: Gonglei <address@hidden>
---
crypto/crypto.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 68 insertions(+)
diff --git a/crypto/crypto.c b/crypto/crypto.c
index 1d3d1d3..184f837 100644
--- a/crypto/crypto.c
+++ b/crypto/crypto.c
@@ -291,3 +291,71 @@ void qemu_del_crypto_legacy_hw(CryptoLegacyHWState *crypto)
g_free(crypto);
}
+
+CryptoLegacyHWState *qemu_get_crypto_legacy_hw(CryptoClientState *cc)
+{
+ CryptoClientState *cc0 = cc - cc->queue_index;
+
+ return (CryptoLegacyHWState *)((void *)cc0 - cc->info->size);
+}
+
+void *qemu_get_crypto_legacy_hw_opaque(CryptoClientState *cc)
+{
+ CryptoLegacyHWState *crypto = qemu_get_crypto_legacy_hw(cc);
+
+ return crypto->opaque;
+}
+
+int qemu_find_crypto_clients_except(const char *id, CryptoClientState **ccs,
+ CryptoClientOptionsKind type, int max)
+{
+ CryptoClientState *cc;
+ int ret = 0;
+
+ QTAILQ_FOREACH(cc, &crypto_clients, next) {
+ if (cc->info->type == type) {
+ continue;
+ }
+ if (!id || !strcmp(cc->name, id)) {
+ if (ret < max) {
+ ccs[ret] = cc;
+ }
+ ret++;
+ }
+ }
+
+ return ret;
+}
+
+int qemu_crypto_create_session(CryptoClientState *cc,
+ CryptoSymSessionInfo *info,
+ uint64_t *session_id)
+{
+ int ret = -1;
+ CryptoClientState *peer = cc->peer;
+
+ if (!peer || !peer->ready) {
+ return ret;
+ }
+
+ if (peer->info->create_session) {
+ ret = peer->info->create_session(peer, info, session_id);
+ }
+ return ret;
+}
+
+int qemu_crypto_close_session(CryptoClientState *cc,
+ uint64_t session_id)
+{
+ int ret = -1;
+ CryptoClientState *peer = cc->peer;
+
+ if (!peer || !peer->ready) {
+ return ret;
+ }
+
+ if (peer->info->close_session) {
+ ret = peer->info->close_session(peer, session_id);
+ }
+ return ret;
+}
--
1.7.12.4
- [Qemu-devel] [PATCH v2 00/15] virtio-crypto: introduce framework and device emulation, Gonglei, 2016/09/12
- [Qemu-devel] [PATCH v2 10/15] virtio-crypto: set capacity of crypto legacy hardware, Gonglei, 2016/09/12
- [Qemu-devel] [PATCH v2 03/15] crypto: add cryptoLegacyHW stuff, Gonglei, 2016/09/12
- [Qemu-devel] [PATCH v2 02/15] crypto: introduce crypto queue handler, Gonglei, 2016/09/12
- [Qemu-devel] [PATCH v2 09/15] virtio-crypto: add virtio crypto realization, Gonglei, 2016/09/12
- [Qemu-devel] [PATCH v2 01/15] crypto: introduce cryptodev backend and crypto legacy hardware, Gonglei, 2016/09/12
- [Qemu-devel] [PATCH v2 15/15] virtio-crypto: support scatter gather list, Gonglei, 2016/09/12
- [Qemu-devel] [PATCH v2 06/15] crypto: add internal handle logic layer,
Gonglei <=
- [Qemu-devel] [PATCH v2 08/15] virtio-crypto-pci: add virtio crypto pci support, Gonglei, 2016/09/12
- [Qemu-devel] [PATCH v2 05/15] crypto: add cryptodev-linux as a cryptodev backend, Gonglei, 2016/09/12
- [Qemu-devel] [PATCH v2 04/15] crypto: add symetric algorithms support, Gonglei, 2016/09/12
- [Qemu-devel] [PATCH v2 12/15] virtio-crypto: add destroy session logic, Gonglei, 2016/09/12
- [Qemu-devel] [PATCH v2 07/15] virtio-crypto: introduce virtio-crypto.h, Gonglei, 2016/09/12
- [Qemu-devel] [PATCH v2 11/15] virtio-crypto: add control queue handler, Gonglei, 2016/09/12
- [Qemu-devel] [PATCH v2 13/15] virtio-crypto: get correct input data address for each request, Gonglei, 2016/09/12
- [Qemu-devel] [PATCH v2 14/15] virtio-crypto: add data virtqueue processing handler, Gonglei, 2016/09/12
- Re: [Qemu-devel] [PATCH v2 00/15] virtio-crypto: introduce framework and device emulation, Daniel P. Berrange, 2016/09/13