cryptodev: Introduce cryptodev.json
Introduce QCryptodevBackendType in cryptodev.json, also apply this to related codes. Then we can drop 'enum CryptoDevBackendOptionsType'. Note that `CRYPTODEV_BACKEND_TYPE_NONE` is *NOT* used by anywhere, so drop it(no 'none' enum in QCryptodevBackendType). Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: zhenwei pi <pizhenwei@bytedance.com> Message-Id: <20230301105847.253084-2-pizhenwei@bytedance.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
9832009d9d
commit
14c9fd1673
@ -2879,6 +2879,7 @@ M: Gonglei <arei.gonglei@huawei.com>
|
|||||||
S: Maintained
|
S: Maintained
|
||||||
F: include/sysemu/cryptodev*.h
|
F: include/sysemu/cryptodev*.h
|
||||||
F: backends/cryptodev*.c
|
F: backends/cryptodev*.c
|
||||||
|
F: qapi/cryptodev.json
|
||||||
|
|
||||||
Python library
|
Python library
|
||||||
M: John Snow <jsnow@redhat.com>
|
M: John Snow <jsnow@redhat.com>
|
||||||
|
@ -76,7 +76,7 @@ static void cryptodev_builtin_init(
|
|||||||
"cryptodev-builtin", NULL);
|
"cryptodev-builtin", NULL);
|
||||||
cc->info_str = g_strdup_printf("cryptodev-builtin0");
|
cc->info_str = g_strdup_printf("cryptodev-builtin0");
|
||||||
cc->queue_index = 0;
|
cc->queue_index = 0;
|
||||||
cc->type = CRYPTODEV_BACKEND_TYPE_BUILTIN;
|
cc->type = QCRYPTODEV_BACKEND_TYPE_BUILTIN;
|
||||||
backend->conf.peers.ccs[0] = cc;
|
backend->conf.peers.ccs[0] = cc;
|
||||||
|
|
||||||
backend->conf.crypto_services =
|
backend->conf.crypto_services =
|
||||||
|
@ -226,7 +226,7 @@ static void cryptodev_lkcf_init(CryptoDevBackend *backend, Error **errp)
|
|||||||
cc = cryptodev_backend_new_client("cryptodev-lkcf", NULL);
|
cc = cryptodev_backend_new_client("cryptodev-lkcf", NULL);
|
||||||
cc->info_str = g_strdup_printf("cryptodev-lkcf0");
|
cc->info_str = g_strdup_printf("cryptodev-lkcf0");
|
||||||
cc->queue_index = 0;
|
cc->queue_index = 0;
|
||||||
cc->type = CRYPTODEV_BACKEND_TYPE_LKCF;
|
cc->type = QCRYPTODEV_BACKEND_TYPE_LKCF;
|
||||||
backend->conf.peers.ccs[0] = cc;
|
backend->conf.peers.ccs[0] = cc;
|
||||||
|
|
||||||
backend->conf.crypto_services =
|
backend->conf.crypto_services =
|
||||||
|
@ -67,7 +67,7 @@ cryptodev_vhost_user_get_vhost(
|
|||||||
{
|
{
|
||||||
CryptoDevBackendVhostUser *s =
|
CryptoDevBackendVhostUser *s =
|
||||||
CRYPTODEV_BACKEND_VHOST_USER(b);
|
CRYPTODEV_BACKEND_VHOST_USER(b);
|
||||||
assert(cc->type == CRYPTODEV_BACKEND_TYPE_VHOST_USER);
|
assert(cc->type == QCRYPTODEV_BACKEND_TYPE_VHOST_USER);
|
||||||
assert(queue < MAX_CRYPTO_QUEUE_NUM);
|
assert(queue < MAX_CRYPTO_QUEUE_NUM);
|
||||||
|
|
||||||
return s->vhost_crypto[queue];
|
return s->vhost_crypto[queue];
|
||||||
@ -203,7 +203,7 @@ static void cryptodev_vhost_user_init(
|
|||||||
cc->info_str = g_strdup_printf("cryptodev-vhost-user%zu to %s ",
|
cc->info_str = g_strdup_printf("cryptodev-vhost-user%zu to %s ",
|
||||||
i, chr->label);
|
i, chr->label);
|
||||||
cc->queue_index = i;
|
cc->queue_index = i;
|
||||||
cc->type = CRYPTODEV_BACKEND_TYPE_VHOST_USER;
|
cc->type = QCRYPTODEV_BACKEND_TYPE_VHOST_USER;
|
||||||
|
|
||||||
backend->conf.peers.ccs[i] = cc;
|
backend->conf.peers.ccs[i] = cc;
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ cryptodev_get_vhost(CryptoDevBackendClient *cc,
|
|||||||
|
|
||||||
switch (cc->type) {
|
switch (cc->type) {
|
||||||
#if defined(CONFIG_VHOST_USER) && defined(CONFIG_LINUX)
|
#if defined(CONFIG_VHOST_USER) && defined(CONFIG_LINUX)
|
||||||
case CRYPTODEV_BACKEND_TYPE_VHOST_USER:
|
case QCRYPTODEV_BACKEND_TYPE_VHOST_USER:
|
||||||
vhost_crypto = cryptodev_vhost_user_get_vhost(cc, b, queue);
|
vhost_crypto = cryptodev_vhost_user_get_vhost(cc, b, queue);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
@ -195,7 +195,7 @@ int cryptodev_vhost_start(VirtIODevice *dev, int total_queues)
|
|||||||
* because vhost user doesn't interrupt masking/unmasking
|
* because vhost user doesn't interrupt masking/unmasking
|
||||||
* properly.
|
* properly.
|
||||||
*/
|
*/
|
||||||
if (cc->type == CRYPTODEV_BACKEND_TYPE_VHOST_USER) {
|
if (cc->type == QCRYPTODEV_BACKEND_TYPE_VHOST_USER) {
|
||||||
dev->use_guest_notifier_mask = false;
|
dev->use_guest_notifier_mask = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
#include "qemu/queue.h"
|
#include "qemu/queue.h"
|
||||||
#include "qom/object.h"
|
#include "qom/object.h"
|
||||||
|
#include "qapi/qapi-types-cryptodev.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CryptoDevBackend:
|
* CryptoDevBackend:
|
||||||
@ -215,16 +216,8 @@ struct CryptoDevBackendClass {
|
|||||||
void *opaque);
|
void *opaque);
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef enum CryptoDevBackendOptionsType {
|
|
||||||
CRYPTODEV_BACKEND_TYPE_NONE = 0,
|
|
||||||
CRYPTODEV_BACKEND_TYPE_BUILTIN = 1,
|
|
||||||
CRYPTODEV_BACKEND_TYPE_VHOST_USER = 2,
|
|
||||||
CRYPTODEV_BACKEND_TYPE_LKCF = 3,
|
|
||||||
CRYPTODEV_BACKEND_TYPE__MAX,
|
|
||||||
} CryptoDevBackendOptionsType;
|
|
||||||
|
|
||||||
struct CryptoDevBackendClient {
|
struct CryptoDevBackendClient {
|
||||||
CryptoDevBackendOptionsType type;
|
QCryptodevBackendType type;
|
||||||
char *model;
|
char *model;
|
||||||
char *name;
|
char *name;
|
||||||
char *info_str;
|
char *info_str;
|
||||||
|
20
qapi/cryptodev.json
Normal file
20
qapi/cryptodev.json
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
# -*- Mode: Python -*-
|
||||||
|
# vim: filetype=python
|
||||||
|
#
|
||||||
|
# This work is licensed under the terms of the GNU GPL, version 2 or later.
|
||||||
|
# See the COPYING file in the top-level directory.
|
||||||
|
|
||||||
|
##
|
||||||
|
# @QCryptodevBackendType:
|
||||||
|
#
|
||||||
|
# The crypto device backend type
|
||||||
|
#
|
||||||
|
# @builtin: the QEMU builtin support
|
||||||
|
# @vhost-user: vhost-user
|
||||||
|
# @lkcf: Linux kernel cryptographic framework
|
||||||
|
#
|
||||||
|
# Since: 8.0
|
||||||
|
##
|
||||||
|
{ 'enum': 'QCryptodevBackendType',
|
||||||
|
'prefix': 'QCRYPTODEV_BACKEND_TYPE',
|
||||||
|
'data': ['builtin', 'vhost-user', 'lkcf']}
|
@ -56,6 +56,7 @@ if have_system
|
|||||||
qapi_all_modules += [
|
qapi_all_modules += [
|
||||||
'acpi',
|
'acpi',
|
||||||
'audio',
|
'audio',
|
||||||
|
'cryptodev',
|
||||||
'qdev',
|
'qdev',
|
||||||
'pci',
|
'pci',
|
||||||
'rdma',
|
'rdma',
|
||||||
|
@ -95,3 +95,4 @@
|
|||||||
{ 'include': 'pci.json' }
|
{ 'include': 'pci.json' }
|
||||||
{ 'include': 'stats.json' }
|
{ 'include': 'stats.json' }
|
||||||
{ 'include': 'virtio.json' }
|
{ 'include': 'virtio.json' }
|
||||||
|
{ 'include': 'cryptodev.json' }
|
||||||
|
Loading…
Reference in New Issue
Block a user