@@ -372,6 +372,15 @@ static void cryptodev_builtin_cleanup(
cryptodev_backend_set_ready(backend, false);
}
+static int
+cryptodev_builtin_sym_stateless_operation(
+ CryptoDevBackend *backend,
+ CryptoDevBackendSymStatelessInfo *op_info,
+ uint32_t queue_index, Error **errp)
+{
+ return -VIRTIO_CRYPTO_ERR;
+}
+
static void
cryptodev_builtin_class_init(ObjectClass *oc, void *data)
{
@@ -382,6 +391,7 @@ cryptodev_builtin_class_init(ObjectClass *oc, void *data)
bc->create_session = cryptodev_builtin_sym_create_session;
bc->close_session = cryptodev_builtin_sym_close_session;
bc->do_sym_op = cryptodev_builtin_sym_operation;
+ bc->do_sym_stateless_op = cryptodev_builtin_sym_stateless_operation;
}
static const TypeInfo cryptodev_builtin_info = {
@@ -120,6 +120,21 @@ static int cryptodev_backend_sym_operation(
return -VIRTIO_CRYPTO_ERR;
}
+static int cryptodev_backend_sym_stateless_operation(
+ CryptoDevBackend *backend,
+ CryptoDevBackendSymStatelessInfo *op_info,
+ uint32_t queue_index, Error **errp)
+{
+ CryptoDevBackendClass *bc =
+ CRYPTODEV_BACKEND_GET_CLASS(backend);
+
+ if (bc->do_sym_stateless_op) {
+ return bc->do_sym_stateless_op(backend, op_info, queue_index, errp);
+ }
+
+ return -VIRTIO_CRYPTO_ERR;
+}
+
int cryptodev_backend_crypto_operation(
CryptoDevBackend *backend,
void *opaque,
@@ -133,6 +148,12 @@ int cryptodev_backend_crypto_operation(
return cryptodev_backend_sym_operation(backend,
op_info, queue_index, errp);
+ } else if (req->flags == CRYPTODEV_BACKEND_ALG_SYM_STATELESS) {
+ CryptoDevBackendSymStatelessInfo *op_info;
+ op_info = req->u.sym_stateless_info;
+
+ return cryptodev_backend_sym_stateless_operation(backend,
+ op_info, queue_index, errp);
} else {
error_setg(errp, "Unsupported cryptodev alg type: %" PRIu32 "",
req->flags);
@@ -73,6 +73,7 @@ typedef struct VirtIOCryptoReq {
struct VirtIOCrypto *vcrypto;
union {
CryptoDevBackendSymOpInfo *sym_op_info;
+ CryptoDevBackendSymStatelessInfo *sym_stateless_info;
} u;
} VirtIOCryptoReq;
@@ -58,6 +58,7 @@ typedef struct CryptoDevBackend CryptoDevBackend;
enum CryptoDevBackendAlgType {
CRYPTODEV_BACKEND_ALG_SYM,
+ CRYPTODEV_BACKEND_ALG_SYM_STATELESS,
CRYPTODEV_BACKEND_ALG__MAX,
};
@@ -146,6 +147,21 @@ typedef struct CryptoDevBackendSymOpInfo {
uint8_t data[0];
} CryptoDevBackendSymOpInfo;
+/**
+ * CryptoDevBackendSymStatelessInfo:
+ *
+ * @session_info: session information, see above
+ * CryptoDevBackendSymSessionInfo
+ * @op_info: crypto operation information, see above
+ * CryptoDevBackendSymOpInfo, @session_id is ignored
+ *
+ */
+typedef struct CryptoDevBackendSymStatelessInfo {
+ CryptoDevBackendSymSessionInfo session_info;
+ CryptoDevBackendSymOpInfo op_info;
+} CryptoDevBackendSymStatelessInfo;
+
+
typedef struct CryptoDevBackendClass {
ObjectClass parent_class;
@@ -161,6 +177,9 @@ typedef struct CryptoDevBackendClass {
int (*do_sym_op)(CryptoDevBackend *backend,
CryptoDevBackendSymOpInfo *op_info,
uint32_t queue_index, Error **errp);
+ int (*do_sym_stateless_op)(CryptoDevBackend *backend,
+ CryptoDevBackendSymStatelessInfo *op_info,
+ uint32_t queue_index, Error **errp);
} CryptoDevBackendClass;
Because a stateless crypto request include all information about one crypto operation, we should introduce a wrapper for it, and add a new crypto operation callback to do statless crypto operation. Signed-off-by: Gonglei <arei.gonglei@huawei.com> --- backends/cryptodev-builtin.c | 10 ++++++++++ backends/cryptodev.c | 21 +++++++++++++++++++++ include/hw/virtio/virtio-crypto.h | 1 + include/sysemu/cryptodev.h | 19 +++++++++++++++++++ 4 files changed, 51 insertions(+)