qapi/cryptodev: Rename QCryptodevBackendAlgType to *Algo, and drop prefix
QAPI's 'prefix' feature can make the connection between enumeration type and its constants less than obvious. It's best used with restraint. QCryptodevBackendAlgType has a 'prefix' that overrides the generated enumeration constants' prefix to QCRYPTODEV_BACKEND_ALG. We could simply drop 'prefix', but I think the abbreviation "alg" is less than clear. Additionally rename the type to QCryptodevBackendAlgoType. The prefix becomes QCRYPTODEV_BACKEND_ALGO_TYPE. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Message-ID: <20240904111836.3273842-19-armbru@redhat.com>
This commit is contained in:
parent
d0917d79fd
commit
b1019999e8
@ -549,7 +549,7 @@ static int cryptodev_builtin_operation(
|
|||||||
CryptoDevBackendBuiltinSession *sess;
|
CryptoDevBackendBuiltinSession *sess;
|
||||||
CryptoDevBackendSymOpInfo *sym_op_info;
|
CryptoDevBackendSymOpInfo *sym_op_info;
|
||||||
CryptoDevBackendAsymOpInfo *asym_op_info;
|
CryptoDevBackendAsymOpInfo *asym_op_info;
|
||||||
QCryptodevBackendAlgType algtype = op_info->algtype;
|
QCryptodevBackendAlgoType algtype = op_info->algtype;
|
||||||
int status = -VIRTIO_CRYPTO_ERR;
|
int status = -VIRTIO_CRYPTO_ERR;
|
||||||
Error *local_error = NULL;
|
Error *local_error = NULL;
|
||||||
|
|
||||||
@ -561,11 +561,11 @@ static int cryptodev_builtin_operation(
|
|||||||
}
|
}
|
||||||
|
|
||||||
sess = builtin->sessions[op_info->session_id];
|
sess = builtin->sessions[op_info->session_id];
|
||||||
if (algtype == QCRYPTODEV_BACKEND_ALG_SYM) {
|
if (algtype == QCRYPTODEV_BACKEND_ALGO_TYPE_SYM) {
|
||||||
sym_op_info = op_info->u.sym_op_info;
|
sym_op_info = op_info->u.sym_op_info;
|
||||||
status = cryptodev_builtin_sym_operation(sess, sym_op_info,
|
status = cryptodev_builtin_sym_operation(sess, sym_op_info,
|
||||||
&local_error);
|
&local_error);
|
||||||
} else if (algtype == QCRYPTODEV_BACKEND_ALG_ASYM) {
|
} else if (algtype == QCRYPTODEV_BACKEND_ALGO_TYPE_ASYM) {
|
||||||
asym_op_info = op_info->u.asym_op_info;
|
asym_op_info = op_info->u.asym_op_info;
|
||||||
status = cryptodev_builtin_asym_operation(sess, op_info->op_code,
|
status = cryptodev_builtin_asym_operation(sess, op_info->op_code,
|
||||||
asym_op_info, &local_error);
|
asym_op_info, &local_error);
|
||||||
|
@ -474,7 +474,7 @@ static int cryptodev_lkcf_operation(
|
|||||||
CryptoDevBackendLKCF *lkcf =
|
CryptoDevBackendLKCF *lkcf =
|
||||||
CRYPTODEV_BACKEND_LKCF(backend);
|
CRYPTODEV_BACKEND_LKCF(backend);
|
||||||
CryptoDevBackendLKCFSession *sess;
|
CryptoDevBackendLKCFSession *sess;
|
||||||
QCryptodevBackendAlgType algtype = op_info->algtype;
|
QCryptodevBackendAlgoType algtype = op_info->algtype;
|
||||||
CryptoDevLKCFTask *task;
|
CryptoDevLKCFTask *task;
|
||||||
|
|
||||||
if (op_info->session_id >= MAX_SESSIONS ||
|
if (op_info->session_id >= MAX_SESSIONS ||
|
||||||
@ -485,7 +485,7 @@ static int cryptodev_lkcf_operation(
|
|||||||
}
|
}
|
||||||
|
|
||||||
sess = lkcf->sess[op_info->session_id];
|
sess = lkcf->sess[op_info->session_id];
|
||||||
if (algtype != QCRYPTODEV_BACKEND_ALG_ASYM) {
|
if (algtype != QCRYPTODEV_BACKEND_ALGO_TYPE_ASYM) {
|
||||||
error_report("algtype not supported: %u", algtype);
|
error_report("algtype not supported: %u", algtype);
|
||||||
return -VIRTIO_CRYPTO_NOTSUPP;
|
return -VIRTIO_CRYPTO_NOTSUPP;
|
||||||
}
|
}
|
||||||
|
@ -185,10 +185,10 @@ static int cryptodev_backend_operation(
|
|||||||
static int cryptodev_backend_account(CryptoDevBackend *backend,
|
static int cryptodev_backend_account(CryptoDevBackend *backend,
|
||||||
CryptoDevBackendOpInfo *op_info)
|
CryptoDevBackendOpInfo *op_info)
|
||||||
{
|
{
|
||||||
enum QCryptodevBackendAlgType algtype = op_info->algtype;
|
enum QCryptodevBackendAlgoType algtype = op_info->algtype;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
if (algtype == QCRYPTODEV_BACKEND_ALG_ASYM) {
|
if (algtype == QCRYPTODEV_BACKEND_ALGO_TYPE_ASYM) {
|
||||||
CryptoDevBackendAsymOpInfo *asym_op_info = op_info->u.asym_op_info;
|
CryptoDevBackendAsymOpInfo *asym_op_info = op_info->u.asym_op_info;
|
||||||
len = asym_op_info->src_len;
|
len = asym_op_info->src_len;
|
||||||
|
|
||||||
@ -212,7 +212,7 @@ static int cryptodev_backend_account(CryptoDevBackend *backend,
|
|||||||
default:
|
default:
|
||||||
return -VIRTIO_CRYPTO_NOTSUPP;
|
return -VIRTIO_CRYPTO_NOTSUPP;
|
||||||
}
|
}
|
||||||
} else if (algtype == QCRYPTODEV_BACKEND_ALG_SYM) {
|
} else if (algtype == QCRYPTODEV_BACKEND_ALGO_TYPE_SYM) {
|
||||||
CryptoDevBackendSymOpInfo *sym_op_info = op_info->u.sym_op_info;
|
CryptoDevBackendSymOpInfo *sym_op_info = op_info->u.sym_op_info;
|
||||||
len = sym_op_info->src_len;
|
len = sym_op_info->src_len;
|
||||||
|
|
||||||
|
@ -461,7 +461,7 @@ static void virtio_crypto_init_request(VirtIOCrypto *vcrypto, VirtQueue *vq,
|
|||||||
req->in_iov = NULL;
|
req->in_iov = NULL;
|
||||||
req->in_num = 0;
|
req->in_num = 0;
|
||||||
req->in_len = 0;
|
req->in_len = 0;
|
||||||
req->flags = QCRYPTODEV_BACKEND_ALG__MAX;
|
req->flags = QCRYPTODEV_BACKEND_ALGO_TYPE__MAX;
|
||||||
memset(&req->op_info, 0x00, sizeof(req->op_info));
|
memset(&req->op_info, 0x00, sizeof(req->op_info));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -471,7 +471,7 @@ static void virtio_crypto_free_request(VirtIOCryptoReq *req)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (req->flags == QCRYPTODEV_BACKEND_ALG_SYM) {
|
if (req->flags == QCRYPTODEV_BACKEND_ALGO_TYPE_SYM) {
|
||||||
size_t max_len;
|
size_t max_len;
|
||||||
CryptoDevBackendSymOpInfo *op_info = req->op_info.u.sym_op_info;
|
CryptoDevBackendSymOpInfo *op_info = req->op_info.u.sym_op_info;
|
||||||
|
|
||||||
@ -486,7 +486,7 @@ static void virtio_crypto_free_request(VirtIOCryptoReq *req)
|
|||||||
memset(op_info, 0, sizeof(*op_info) + max_len);
|
memset(op_info, 0, sizeof(*op_info) + max_len);
|
||||||
g_free(op_info);
|
g_free(op_info);
|
||||||
}
|
}
|
||||||
} else if (req->flags == QCRYPTODEV_BACKEND_ALG_ASYM) {
|
} else if (req->flags == QCRYPTODEV_BACKEND_ALGO_TYPE_ASYM) {
|
||||||
CryptoDevBackendAsymOpInfo *op_info = req->op_info.u.asym_op_info;
|
CryptoDevBackendAsymOpInfo *op_info = req->op_info.u.asym_op_info;
|
||||||
if (op_info) {
|
if (op_info) {
|
||||||
g_free(op_info->src);
|
g_free(op_info->src);
|
||||||
@ -571,10 +571,10 @@ static void virtio_crypto_req_complete(void *opaque, int ret)
|
|||||||
VirtIODevice *vdev = VIRTIO_DEVICE(vcrypto);
|
VirtIODevice *vdev = VIRTIO_DEVICE(vcrypto);
|
||||||
uint8_t status = -ret;
|
uint8_t status = -ret;
|
||||||
|
|
||||||
if (req->flags == QCRYPTODEV_BACKEND_ALG_SYM) {
|
if (req->flags == QCRYPTODEV_BACKEND_ALGO_TYPE_SYM) {
|
||||||
virtio_crypto_sym_input_data_helper(vdev, req, status,
|
virtio_crypto_sym_input_data_helper(vdev, req, status,
|
||||||
req->op_info.u.sym_op_info);
|
req->op_info.u.sym_op_info);
|
||||||
} else if (req->flags == QCRYPTODEV_BACKEND_ALG_ASYM) {
|
} else if (req->flags == QCRYPTODEV_BACKEND_ALGO_TYPE_ASYM) {
|
||||||
virtio_crypto_akcipher_input_data_helper(vdev, req, status,
|
virtio_crypto_akcipher_input_data_helper(vdev, req, status,
|
||||||
req->op_info.u.asym_op_info);
|
req->op_info.u.asym_op_info);
|
||||||
}
|
}
|
||||||
@ -884,7 +884,7 @@ virtio_crypto_handle_request(VirtIOCryptoReq *request)
|
|||||||
switch (opcode) {
|
switch (opcode) {
|
||||||
case VIRTIO_CRYPTO_CIPHER_ENCRYPT:
|
case VIRTIO_CRYPTO_CIPHER_ENCRYPT:
|
||||||
case VIRTIO_CRYPTO_CIPHER_DECRYPT:
|
case VIRTIO_CRYPTO_CIPHER_DECRYPT:
|
||||||
op_info->algtype = request->flags = QCRYPTODEV_BACKEND_ALG_SYM;
|
op_info->algtype = request->flags = QCRYPTODEV_BACKEND_ALGO_TYPE_SYM;
|
||||||
ret = virtio_crypto_handle_sym_req(vcrypto,
|
ret = virtio_crypto_handle_sym_req(vcrypto,
|
||||||
&req.u.sym_req, op_info,
|
&req.u.sym_req, op_info,
|
||||||
out_iov, out_num);
|
out_iov, out_num);
|
||||||
@ -894,7 +894,7 @@ virtio_crypto_handle_request(VirtIOCryptoReq *request)
|
|||||||
case VIRTIO_CRYPTO_AKCIPHER_DECRYPT:
|
case VIRTIO_CRYPTO_AKCIPHER_DECRYPT:
|
||||||
case VIRTIO_CRYPTO_AKCIPHER_SIGN:
|
case VIRTIO_CRYPTO_AKCIPHER_SIGN:
|
||||||
case VIRTIO_CRYPTO_AKCIPHER_VERIFY:
|
case VIRTIO_CRYPTO_AKCIPHER_VERIFY:
|
||||||
op_info->algtype = request->flags = QCRYPTODEV_BACKEND_ALG_ASYM;
|
op_info->algtype = request->flags = QCRYPTODEV_BACKEND_ALGO_TYPE_ASYM;
|
||||||
ret = virtio_crypto_handle_asym_req(vcrypto,
|
ret = virtio_crypto_handle_asym_req(vcrypto,
|
||||||
&req.u.akcipher_req, op_info,
|
&req.u.akcipher_req, op_info,
|
||||||
out_iov, out_num);
|
out_iov, out_num);
|
||||||
|
@ -178,7 +178,7 @@ typedef struct CryptoDevBackendAsymOpInfo {
|
|||||||
typedef void (*CryptoDevCompletionFunc) (void *opaque, int ret);
|
typedef void (*CryptoDevCompletionFunc) (void *opaque, int ret);
|
||||||
|
|
||||||
typedef struct CryptoDevBackendOpInfo {
|
typedef struct CryptoDevBackendOpInfo {
|
||||||
QCryptodevBackendAlgType algtype;
|
QCryptodevBackendAlgoType algtype;
|
||||||
uint32_t op_code;
|
uint32_t op_code;
|
||||||
uint32_t queue_index;
|
uint32_t queue_index;
|
||||||
CryptoDevCompletionFunc cb;
|
CryptoDevCompletionFunc cb;
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
##
|
##
|
||||||
|
|
||||||
##
|
##
|
||||||
# @QCryptodevBackendAlgType:
|
# @QCryptodevBackendAlgoType:
|
||||||
#
|
#
|
||||||
# The supported algorithm types of a crypto device.
|
# The supported algorithm types of a crypto device.
|
||||||
#
|
#
|
||||||
@ -19,8 +19,7 @@
|
|||||||
#
|
#
|
||||||
# Since: 8.0
|
# Since: 8.0
|
||||||
##
|
##
|
||||||
{ 'enum': 'QCryptodevBackendAlgType',
|
{ 'enum': 'QCryptodevBackendAlgoType',
|
||||||
'prefix': 'QCRYPTODEV_BACKEND_ALG',
|
|
||||||
'data': ['sym', 'asym']}
|
'data': ['sym', 'asym']}
|
||||||
|
|
||||||
##
|
##
|
||||||
|
Loading…
Reference in New Issue
Block a user