@@ -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,20 @@ 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 +176,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;
Adds stateless mode cipher support. Signed-off-by: Longpeng(Mike) <longpeng2@huawei.com> --- backends/cryptodev.c | 21 +++++++++++++++++++++ include/hw/virtio/virtio-crypto.h | 1 + include/sysemu/cryptodev.h | 18 ++++++++++++++++++ 3 files changed, 40 insertions(+)