qemu-devel
[Top][All Lists]
Advanced

[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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]