From patchwork Thu Oct 6 11:36:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gonglei (Arei)" X-Patchwork-Id: 9364603 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2F5206075E for ; Thu, 6 Oct 2016 11:43:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1C6B628F51 for ; Thu, 6 Oct 2016 11:43:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0FF7128F58; Thu, 6 Oct 2016 11:43:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CB8FF28F5C for ; Thu, 6 Oct 2016 11:43:11 +0000 (UTC) Received: from localhost ([::1]:54984 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bs74x-0002yT-0O for patchwork-qemu-devel@patchwork.kernel.org; Thu, 06 Oct 2016 07:43:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41314) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bs721-0000XT-Bp for qemu-devel@nongnu.org; Thu, 06 Oct 2016 07:40:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bs71y-0001O4-04 for qemu-devel@nongnu.org; Thu, 06 Oct 2016 07:40:09 -0400 Received: from szxga01-in.huawei.com ([58.251.152.64]:27121) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bs71w-0001Na-Km for qemu-devel@nongnu.org; Thu, 06 Oct 2016 07:40:05 -0400 Received: from 172.24.1.36 (EHLO szxeml430-hub.china.huawei.com) ([172.24.1.36]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id DSC94031; Thu, 06 Oct 2016 19:37:44 +0800 (CST) Received: from localhost (10.177.18.62) by szxeml430-hub.china.huawei.com (10.82.67.185) with Microsoft SMTP Server id 14.3.235.1; Thu, 6 Oct 2016 19:37:37 +0800 From: Gonglei To: , Date: Thu, 6 Oct 2016 19:36:47 +0800 Message-ID: <1475753807-37624-15-git-send-email-arei.gonglei@huawei.com> X-Mailer: git-send-email 2.6.3.windows.1 In-Reply-To: <1475753807-37624-1-git-send-email-arei.gonglei@huawei.com> References: <1475753807-37624-1-git-send-email-arei.gonglei@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.18.62] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 58.251.152.64 Subject: [Qemu-devel] [PATCH v5 14/14] cryptodev: rename cryptodev stuff X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: weidong.huang@huawei.com, claudio.fontana@huawei.com, mst@redhat.com, xin.zeng@intel.com, hanweidong@huawei.com, luonengjun@huawei.com, agraf@suse.de, nmorey@kalray.eu, mike.caraman@nxp.com, Gonglei , stefanha@redhat.com, jianjay.zhou@huawei.com, pbonzini@redhat.com, peter.huangpeng@huawei.com, vincent.jardin@6wind.com, wu.wubin@huawei.com, arei.gonglei@hotmail.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Remove qcrypto and/or QCRYPTO prefix in order to make the name shorter because it doesn't repeat any information. Signed-off-by: Gonglei --- backends/cryptodev-builtin.c | 84 ++++++++++++------------ backends/cryptodev.c | 106 +++++++++++++++--------------- hw/virtio/virtio-crypto.c | 32 ++++----- include/hw/virtio/virtio-crypto.h | 6 +- include/sysemu/cryptodev.h | 132 +++++++++++++++++++------------------- 5 files changed, 180 insertions(+), 180 deletions(-) diff --git a/backends/cryptodev-builtin.c b/backends/cryptodev-builtin.c index 8b57e49..dc0a364 100644 --- a/backends/cryptodev-builtin.c +++ b/backends/cryptodev-builtin.c @@ -30,41 +30,41 @@ /** - * @TYPE_QCRYPTO_CRYPTODEV_BACKEND_BUILTIN: + * @TYPE_CRYPTODEV_BACKEND_BUILTIN: * name of backend that uses QEMU cipher API */ -#define TYPE_QCRYPTO_CRYPTODEV_BACKEND_BUILTIN "cryptodev-backend-builtin" +#define TYPE_CRYPTODEV_BACKEND_BUILTIN "cryptodev-backend-builtin" -#define QCRYPTO_CRYPTODEV_BACKEND_BUILTIN(obj) \ - OBJECT_CHECK(QCryptoCryptoDevBackendBuiltin, \ - (obj), TYPE_QCRYPTO_CRYPTODEV_BACKEND_BUILTIN) +#define CRYPTODEV_BACKEND_BUILTIN(obj) \ + OBJECT_CHECK(CryptoDevBackendBuiltin, \ + (obj), TYPE_CRYPTODEV_BACKEND_BUILTIN) -typedef struct QCryptoCryptoDevBackendBuiltin - QCryptoCryptoDevBackendBuiltin; +typedef struct CryptoDevBackendBuiltin + CryptoDevBackendBuiltin; -typedef struct QCryptoCryptoDevBackendBuiltinSession { +typedef struct CryptoDevBackendBuiltinSession { QCryptoCipher *cipher; uint8_t direction; /* encryption or decryption */ uint8_t type; /* cipher? hash? aead? */ - QTAILQ_ENTRY(QCryptoCryptoDevBackendBuiltinSession) next; -} QCryptoCryptoDevBackendBuiltinSession; + QTAILQ_ENTRY(CryptoDevBackendBuiltinSession) next; +} CryptoDevBackendBuiltinSession; /* Max number of symmetric sessions */ #define MAX_NUM_SESSIONS 256 -struct QCryptoCryptoDevBackendBuiltin { - QCryptoCryptoDevBackend parent_obj; +struct CryptoDevBackendBuiltin { + CryptoDevBackend parent_obj; - QCryptoCryptoDevBackendBuiltinSession *sessions[MAX_NUM_SESSIONS]; + CryptoDevBackendBuiltinSession *sessions[MAX_NUM_SESSIONS]; }; static void cryptodev_builtin_init( - QCryptoCryptoDevBackend *backend, Error **errp) + CryptoDevBackend *backend, Error **errp) { /* Only support one queue */ int queues = backend->conf.peers.queues; - QCryptoCryptoDevBackendClientState *cc; + CryptoDevBackendClient *cc; if (queues != 1) { error_setg(errp, @@ -72,7 +72,7 @@ static void cryptodev_builtin_init( return; } - cc = qcrypto_cryptodev_backend_new_client( + cc = cryptodev_backend_new_client( "cryptodev-builtin", NULL); cc->info_str = g_strdup_printf("cryptodev-builtin0"); cc->queue_index = 0; @@ -88,7 +88,7 @@ static void cryptodev_builtin_init( static int cryptodev_builtin_get_unused_session_index( - QCryptoCryptoDevBackendBuiltin *builtin) + CryptoDevBackendBuiltin *builtin) { size_t i; @@ -121,15 +121,15 @@ cryptodev_builtin_get_aes_algo(uint32_t key_len, Error **errp) } static int cryptodev_builtin_create_cipher_session( - QCryptoCryptoDevBackendBuiltin *builtin, - QCryptoCryptoDevBackendSymSessionInfo *sess_info, + CryptoDevBackendBuiltin *builtin, + CryptoDevBackendSymSessionInfo *sess_info, Error **errp) { int algo; int mode; QCryptoCipher *cipher; int index; - QCryptoCryptoDevBackendBuiltinSession *sess; + CryptoDevBackendBuiltinSession *sess; if (sess_info->op_type != VIRTIO_CRYPTO_SYM_OP_CIPHER) { error_setg(errp, "Unsupported optype :%u", sess_info->op_type); @@ -186,7 +186,7 @@ static int cryptodev_builtin_create_cipher_session( return -1; } - sess = g_new0(QCryptoCryptoDevBackendBuiltinSession, 1); + sess = g_new0(CryptoDevBackendBuiltinSession, 1); sess->cipher = cipher; sess->direction = sess_info->direction; sess->type = sess_info->op_type; @@ -197,12 +197,12 @@ static int cryptodev_builtin_create_cipher_session( } static int64_t cryptodev_builtin_sym_create_session( - QCryptoCryptoDevBackend *backend, - QCryptoCryptoDevBackendSymSessionInfo *sess_info, + CryptoDevBackend *backend, + CryptoDevBackendSymSessionInfo *sess_info, uint32_t queue_index, Error **errp) { - QCryptoCryptoDevBackendBuiltin *builtin = - QCRYPTO_CRYPTODEV_BACKEND_BUILTIN(backend); + CryptoDevBackendBuiltin *builtin = + CRYPTODEV_BACKEND_BUILTIN(backend); int64_t session_id = -1; int ret; @@ -228,12 +228,12 @@ static int64_t cryptodev_builtin_sym_create_session( } static int cryptodev_builtin_sym_close_session( - QCryptoCryptoDevBackend *backend, + CryptoDevBackend *backend, uint64_t session_id, uint32_t queue_index, Error **errp) { - QCryptoCryptoDevBackendBuiltin *builtin = - QCRYPTO_CRYPTODEV_BACKEND_BUILTIN(backend); + CryptoDevBackendBuiltin *builtin = + CRYPTODEV_BACKEND_BUILTIN(backend); if (session_id >= MAX_NUM_SESSIONS || builtin->sessions[session_id] == NULL) { @@ -249,13 +249,13 @@ static int cryptodev_builtin_sym_close_session( } static int cryptodev_builtin_sym_operation( - QCryptoCryptoDevBackend *backend, - QCryptoCryptoDevBackendSymOpInfo *op_info, + CryptoDevBackend *backend, + CryptoDevBackendSymOpInfo *op_info, uint32_t queue_index, Error **errp) { - QCryptoCryptoDevBackendBuiltin *builtin = - QCRYPTO_CRYPTODEV_BACKEND_BUILTIN(backend); - QCryptoCryptoDevBackendBuiltinSession *sess; + CryptoDevBackendBuiltin *builtin = + CRYPTODEV_BACKEND_BUILTIN(backend); + CryptoDevBackendBuiltinSession *sess; int ret; if (op_info->session_id >= MAX_NUM_SESSIONS || @@ -290,14 +290,14 @@ static int cryptodev_builtin_sym_operation( } static void cryptodev_builtin_cleanup( - QCryptoCryptoDevBackend *backend, + CryptoDevBackend *backend, Error **errp) { - QCryptoCryptoDevBackendBuiltin *builtin = - QCRYPTO_CRYPTODEV_BACKEND_BUILTIN(backend); + CryptoDevBackendBuiltin *builtin = + CRYPTODEV_BACKEND_BUILTIN(backend); size_t i; int queues = backend->conf.peers.queues; - QCryptoCryptoDevBackendClientState *cc; + CryptoDevBackendClient *cc; for (i = 0; i < MAX_NUM_SESSIONS; i++) { if (builtin->sessions[i] != NULL) { @@ -311,7 +311,7 @@ static void cryptodev_builtin_cleanup( for (i = 0; i < queues; i++) { cc = backend->conf.peers.ccs[i]; if (cc) { - qcrypto_cryptodev_backend_free_client(cc); + cryptodev_backend_free_client(cc); backend->conf.peers.ccs[i] = NULL; } } @@ -320,7 +320,7 @@ static void cryptodev_builtin_cleanup( static void cryptodev_builtin_class_init(ObjectClass *oc, void *data) { - QCryptoCryptoDevBackendClass *bc = QCRYPTO_CRYPTODEV_BACKEND_CLASS(oc); + CryptoDevBackendClass *bc = CRYPTODEV_BACKEND_CLASS(oc); bc->init = cryptodev_builtin_init; bc->cleanup = cryptodev_builtin_cleanup; @@ -330,10 +330,10 @@ cryptodev_builtin_class_init(ObjectClass *oc, void *data) } static const TypeInfo cryptodev_builtin_info = { - .name = TYPE_QCRYPTO_CRYPTODEV_BACKEND_BUILTIN, - .parent = TYPE_QCRYPTO_CRYPTODEV_BACKEND, + .name = TYPE_CRYPTODEV_BACKEND_BUILTIN, + .parent = TYPE_CRYPTODEV_BACKEND, .class_init = cryptodev_builtin_class_init, - .instance_size = sizeof(QCryptoCryptoDevBackendBuiltin), + .instance_size = sizeof(CryptoDevBackendBuiltin), }; static void diff --git a/backends/cryptodev.c b/backends/cryptodev.c index 744f12c..4a49f97 100644 --- a/backends/cryptodev.c +++ b/backends/cryptodev.c @@ -33,16 +33,16 @@ #include "hw/virtio/virtio-crypto.h" -static QTAILQ_HEAD(, QCryptoCryptoDevBackendClientState) crypto_clients; +static QTAILQ_HEAD(, CryptoDevBackendClient) crypto_clients; -QCryptoCryptoDevBackendClientState * -qcrypto_cryptodev_backend_new_client(const char *model, +CryptoDevBackendClient * +cryptodev_backend_new_client(const char *model, const char *name) { - QCryptoCryptoDevBackendClientState *cc; + CryptoDevBackendClient *cc; - cc = g_malloc0(sizeof(QCryptoCryptoDevBackendClientState)); + cc = g_malloc0(sizeof(CryptoDevBackendClient)); cc->model = g_strdup(model); if (name) { cc->name = g_strdup(name); @@ -53,8 +53,8 @@ qcrypto_cryptodev_backend_new_client(const char *model, return cc; } -void qcrypto_cryptodev_backend_free_client( - QCryptoCryptoDevBackendClientState *cc) +void cryptodev_backend_free_client( + CryptoDevBackendClient *cc) { QTAILQ_REMOVE(&crypto_clients, cc, next); g_free(cc->name); @@ -63,12 +63,12 @@ void qcrypto_cryptodev_backend_free_client( g_free(cc); } -void qcrypto_cryptodev_backend_cleanup( - QCryptoCryptoDevBackend *backend, +void cryptodev_backend_cleanup( + CryptoDevBackend *backend, Error **errp) { - QCryptoCryptoDevBackendClass *bc = - QCRYPTO_CRYPTODEV_BACKEND_GET_CLASS(backend); + CryptoDevBackendClass *bc = + CRYPTODEV_BACKEND_GET_CLASS(backend); if (bc->cleanup) { bc->cleanup(backend, errp); @@ -77,13 +77,13 @@ void qcrypto_cryptodev_backend_cleanup( backend->ready = false; } -int64_t qcrypto_cryptodev_backend_sym_create_session( - QCryptoCryptoDevBackend *backend, - QCryptoCryptoDevBackendSymSessionInfo *sess_info, +int64_t cryptodev_backend_sym_create_session( + CryptoDevBackend *backend, + CryptoDevBackendSymSessionInfo *sess_info, uint32_t queue_index, Error **errp) { - QCryptoCryptoDevBackendClass *bc = - QCRYPTO_CRYPTODEV_BACKEND_GET_CLASS(backend); + CryptoDevBackendClass *bc = + CRYPTODEV_BACKEND_GET_CLASS(backend); if (bc->create_session) { return bc->create_session(backend, sess_info, queue_index, errp); @@ -92,13 +92,13 @@ int64_t qcrypto_cryptodev_backend_sym_create_session( return -1; } -int qcrypto_cryptodev_backend_sym_close_session( - QCryptoCryptoDevBackend *backend, +int cryptodev_backend_sym_close_session( + CryptoDevBackend *backend, uint64_t session_id, uint32_t queue_index, Error **errp) { - QCryptoCryptoDevBackendClass *bc = - QCRYPTO_CRYPTODEV_BACKEND_GET_CLASS(backend); + CryptoDevBackendClass *bc = + CRYPTODEV_BACKEND_GET_CLASS(backend); if (bc->close_session) { return bc->close_session(backend, session_id, queue_index, errp); @@ -107,13 +107,13 @@ int qcrypto_cryptodev_backend_sym_close_session( return -1; } -static int qcrypto_cryptodev_backend_sym_operation( - QCryptoCryptoDevBackend *backend, - QCryptoCryptoDevBackendSymOpInfo *op_info, +static int cryptodev_backend_sym_operation( + CryptoDevBackend *backend, + CryptoDevBackendSymOpInfo *op_info, uint32_t queue_index, Error **errp) { - QCryptoCryptoDevBackendClass *bc = - QCRYPTO_CRYPTODEV_BACKEND_GET_CLASS(backend); + CryptoDevBackendClass *bc = + CRYPTODEV_BACKEND_GET_CLASS(backend); if (bc->do_sym_op) { return bc->do_sym_op(backend, op_info, queue_index, errp); @@ -122,18 +122,18 @@ static int qcrypto_cryptodev_backend_sym_operation( return -VIRTIO_CRYPTO_ERR; } -int qcrypto_cryptodev_backend_crypto_operation( - QCryptoCryptoDevBackend *backend, +int cryptodev_backend_crypto_operation( + CryptoDevBackend *backend, void *opaque, uint32_t queue_index, Error **errp) { VirtIOCryptoReq *req = opaque; - if (req->flags == QCRYPTO_CRYPTODEV_BACKEND_ALG_SYM) { - QCryptoCryptoDevBackendSymOpInfo *op_info; + if (req->flags == CRYPTODEV_BACKEND_ALG_SYM) { + CryptoDevBackendSymOpInfo *op_info; op_info = req->u.sym_op_info; - return qcrypto_cryptodev_backend_sym_operation(backend, + return cryptodev_backend_sym_operation(backend, op_info, queue_index, errp); } else { error_setg(errp, "Unsupported cryptodev alg type: %" PRIu32 "", @@ -145,20 +145,20 @@ int qcrypto_cryptodev_backend_crypto_operation( } static void -qcrypto_cryptodev_backend_get_queues(Object *obj, Visitor *v, const char *name, +cryptodev_backend_get_queues(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { - QCryptoCryptoDevBackend *backend = QCRYPTO_CRYPTODEV_BACKEND(obj); + CryptoDevBackend *backend = CRYPTODEV_BACKEND(obj); uint32_t value = backend->conf.peers.queues; visit_type_uint32(v, name, &value, errp); } static void -qcrypto_cryptodev_backend_set_queues(Object *obj, Visitor *v, const char *name, +cryptodev_backend_set_queues(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { - QCryptoCryptoDevBackend *backend = QCRYPTO_CRYPTODEV_BACKEND(obj); + CryptoDevBackend *backend = CRYPTODEV_BACKEND(obj); Error *local_err = NULL; uint32_t value; @@ -177,10 +177,10 @@ out: } static void -qcrypto_cryptodev_backend_complete(UserCreatable *uc, Error **errp) +cryptodev_backend_complete(UserCreatable *uc, Error **errp) { - QCryptoCryptoDevBackend *backend = QCRYPTO_CRYPTODEV_BACKEND(uc); - QCryptoCryptoDevBackendClass *bc = QCRYPTO_CRYPTODEV_BACKEND_GET_CLASS(uc); + CryptoDevBackend *backend = CRYPTODEV_BACKEND(uc); + CryptoDevBackendClass *bc = CRYPTODEV_BACKEND_GET_CLASS(uc); Error *local_err = NULL; if (bc->init) { @@ -197,39 +197,39 @@ out: error_propagate(errp, local_err); } -static void qcrypto_cryptodev_backend_instance_init(Object *obj) +static void cryptodev_backend_instance_init(Object *obj) { object_property_add(obj, "queues", "int", - qcrypto_cryptodev_backend_get_queues, - qcrypto_cryptodev_backend_set_queues, + cryptodev_backend_get_queues, + cryptodev_backend_set_queues, NULL, NULL, NULL); /* Initialize devices' queues property to 1 */ object_property_set_int(obj, 1, "queues", NULL); } -static void qcrypto_cryptodev_backend_finalize(Object *obj) +static void cryptodev_backend_finalize(Object *obj) { } static void -qcrypto_cryptodev_backend_class_init(ObjectClass *oc, void *data) +cryptodev_backend_class_init(ObjectClass *oc, void *data) { UserCreatableClass *ucc = USER_CREATABLE_CLASS(oc); - ucc->complete = qcrypto_cryptodev_backend_complete; + ucc->complete = cryptodev_backend_complete; QTAILQ_INIT(&crypto_clients); } -static const TypeInfo qcrypto_cryptodev_backend_info = { - .name = TYPE_QCRYPTO_CRYPTODEV_BACKEND, +static const TypeInfo cryptodev_backend_info = { + .name = TYPE_CRYPTODEV_BACKEND, .parent = TYPE_OBJECT, - .instance_size = sizeof(QCryptoCryptoDevBackend), - .instance_init = qcrypto_cryptodev_backend_instance_init, - .instance_finalize = qcrypto_cryptodev_backend_finalize, - .class_size = sizeof(QCryptoCryptoDevBackendClass), - .class_init = qcrypto_cryptodev_backend_class_init, + .instance_size = sizeof(CryptoDevBackend), + .instance_init = cryptodev_backend_instance_init, + .instance_finalize = cryptodev_backend_finalize, + .class_size = sizeof(CryptoDevBackendClass), + .class_init = cryptodev_backend_class_init, .interfaces = (InterfaceInfo[]) { { TYPE_USER_CREATABLE }, { } @@ -237,9 +237,9 @@ static const TypeInfo qcrypto_cryptodev_backend_info = { }; static void -qcrypto_cryptodev_backend_register_types(void) +cryptodev_backend_register_types(void) { - type_register_static(&qcrypto_cryptodev_backend_info); + type_register_static(&cryptodev_backend_info); } -type_init(qcrypto_cryptodev_backend_register_types); +type_init(cryptodev_backend_register_types); diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c index 53673f5..1e52bb5 100644 --- a/hw/virtio/virtio-crypto.c +++ b/hw/virtio/virtio-crypto.c @@ -35,7 +35,7 @@ static inline int virtio_crypto_vq2q(int queue_index) static int virtio_crypto_cipher_session_helper(VirtIODevice *vdev, - QCryptoCryptoDevBackendSymSessionInfo *info, + CryptoDevBackendSymSessionInfo *info, struct virtio_crypto_cipher_session_para *cipher_para, struct iovec *iov, unsigned int *out_num) { @@ -72,7 +72,7 @@ virtio_crypto_create_sym_session(VirtIOCrypto *vcrypto, struct iovec *iov, unsigned int out_num) { VirtIODevice *vdev = VIRTIO_DEVICE(vcrypto); - QCryptoCryptoDevBackendSymSessionInfo info; + CryptoDevBackendSymSessionInfo info; int64_t session_id; int queue_index; uint32_t op_type; @@ -142,7 +142,7 @@ virtio_crypto_create_sym_session(VirtIOCrypto *vcrypto, } queue_index = virtio_crypto_vq2q(queue_id); - session_id = qcrypto_cryptodev_backend_sym_create_session( + session_id = cryptodev_backend_sym_create_session( vcrypto->cryptodev, &info, queue_index, &local_err); if (session_id >= 0) { @@ -178,7 +178,7 @@ virtio_crypto_handle_close_session(VirtIOCrypto *vcrypto, session_id = virtio_ldq_p(vdev, &close_sess_req->session_id); DPRINTF("close session, id=%" PRIu64 "\n", session_id); - ret = qcrypto_cryptodev_backend_sym_close_session( + ret = cryptodev_backend_sym_close_session( vcrypto->cryptodev, session_id, queue_id, &local_err); if (ret == 0) { status = VIRTIO_CRYPTO_OK; @@ -309,7 +309,7 @@ static void virtio_crypto_init_request(VirtIOCrypto *vcrypto, VirtQueue *vq, static void virtio_crypto_free_request(VirtIOCryptoReq *req) { if (req) { - if (req->flags == QCRYPTO_CRYPTODEV_BACKEND_ALG_SYM) { + if (req->flags == CRYPTODEV_BACKEND_ALG_SYM) { g_free(req->u.sym_op_info); } g_free(req); @@ -320,7 +320,7 @@ static void virtio_crypto_sym_input_data_helper(VirtIODevice *vdev, VirtIOCryptoReq *req, uint32_t status, - QCryptoCryptoDevBackendSymOpInfo *sym_op_info) + CryptoDevBackendSymOpInfo *sym_op_info) { size_t s, len; @@ -355,7 +355,7 @@ static void virtio_crypto_req_complete(VirtIOCryptoReq *req, uint32_t status) VirtIOCrypto *vcrypto = req->vcrypto; VirtIODevice *vdev = VIRTIO_DEVICE(vcrypto); - if (req->flags == QCRYPTO_CRYPTODEV_BACKEND_ALG_SYM) { + if (req->flags == CRYPTODEV_BACKEND_ALG_SYM) { virtio_crypto_sym_input_data_helper(vdev, req, status, req->u.sym_op_info); } @@ -375,7 +375,7 @@ virtio_crypto_get_request(VirtIOCrypto *s, VirtQueue *vq) return req; } -static QCryptoCryptoDevBackendSymOpInfo * +static CryptoDevBackendSymOpInfo * virtio_crypto_sym_op_helper(VirtIODevice *vdev, struct virtio_crypto_cipher_para *para, uint32_t aad_len, @@ -383,7 +383,7 @@ virtio_crypto_sym_op_helper(VirtIODevice *vdev, uint32_t hash_result_len, uint32_t hash_start_src_offset) { - QCryptoCryptoDevBackendSymOpInfo *op_info; + CryptoDevBackendSymOpInfo *op_info; uint32_t src_len, dst_len; uint32_t iv_len; size_t max_len, curr_size = 0; @@ -394,7 +394,7 @@ virtio_crypto_sym_op_helper(VirtIODevice *vdev, dst_len = virtio_ldl_p(vdev, ¶->dst_data_len); max_len = iv_len + aad_len + src_len + dst_len + hash_result_len; - op_info = g_malloc0(sizeof(QCryptoCryptoDevBackendSymOpInfo) + max_len); + op_info = g_malloc0(sizeof(CryptoDevBackendSymOpInfo) + max_len); op_info->iv_len = iv_len; op_info->src_len = src_len; op_info->dst_len = dst_len; @@ -467,12 +467,12 @@ err: static int virtio_crypto_handle_sym_req(VirtIOCrypto *vcrypto, struct virtio_crypto_sym_data_req *req, - QCryptoCryptoDevBackendSymOpInfo **sym_op_info, + CryptoDevBackendSymOpInfo **sym_op_info, struct iovec *iov, unsigned int out_num) { VirtIODevice *vdev = VIRTIO_DEVICE(vcrypto); uint32_t op_type; - QCryptoCryptoDevBackendSymOpInfo *op_info; + CryptoDevBackendSymOpInfo *op_info; op_type = virtio_ldl_p(vdev, &req->op_type); @@ -527,7 +527,7 @@ virtio_crypto_handle_request(VirtIOCryptoReq *request) unsigned out_num; uint32_t opcode, status = VIRTIO_CRYPTO_ERR; uint64_t session_id; - QCryptoCryptoDevBackendSymOpInfo *sym_op_info = NULL; + CryptoDevBackendSymOpInfo *sym_op_info = NULL; Error *local_err = NULL; if (elem->out_num < 1 || elem->in_num < 1) { @@ -581,9 +581,9 @@ virtio_crypto_handle_request(VirtIOCryptoReq *request) sym_op_info->session_id = session_id; /* Set request's parameter */ - request->flags = QCRYPTO_CRYPTODEV_BACKEND_ALG_SYM; + request->flags = CRYPTODEV_BACKEND_ALG_SYM; request->u.sym_op_info = sym_op_info; - ret = qcrypto_cryptodev_backend_crypto_operation(vcrypto->cryptodev, + ret = cryptodev_backend_crypto_operation(vcrypto->cryptodev, request, queue_index, &local_err); if (ret < 0) { status = -ret; @@ -781,7 +781,7 @@ static void virtio_crypto_instance_init(Object *obj) vcrypto->config_size = sizeof(struct virtio_crypto_config); object_property_add_link(obj, "cryptodev", - TYPE_QCRYPTO_CRYPTODEV_BACKEND, + TYPE_CRYPTODEV_BACKEND, (Object **)&vcrypto->conf.cryptodev, qdev_prop_allow_set_link_before_realize, OBJ_PROP_LINK_UNREF_ON_RELEASE, NULL); diff --git a/include/hw/virtio/virtio-crypto.h b/include/hw/virtio/virtio-crypto.h index c46e9a9..ff3abfe 100644 --- a/include/hw/virtio/virtio-crypto.h +++ b/include/hw/virtio/virtio-crypto.h @@ -43,7 +43,7 @@ struct virtio_crypto_inhdr }; typedef struct VirtIOCryptoConf { - QCryptoCryptoDevBackend *cryptodev; + CryptoDevBackend *cryptodev; /* Supported service mask */ uint32_t crypto_services; @@ -73,7 +73,7 @@ typedef struct VirtIOCryptoReq { VirtQueue *vq; struct VirtIOCrypto *vcrypto; union { - QCryptoCryptoDevBackendSymOpInfo *sym_op_info; + CryptoDevBackendSymOpInfo *sym_op_info; } u; } VirtIOCryptoReq; @@ -83,7 +83,7 @@ typedef struct VirtIOCrypto { VirtQueue *ctrl_vq; VirtIOCryptoConf conf; - QCryptoCryptoDevBackend *cryptodev; + CryptoDevBackend *cryptodev; uint32_t max_queues; uint32_t status; diff --git a/include/sysemu/cryptodev.h b/include/sysemu/cryptodev.h index 6ba0f14..dc06d7e 100644 --- a/include/sysemu/cryptodev.h +++ b/include/sysemu/cryptodev.h @@ -27,42 +27,42 @@ #include "qemu-common.h" /** - * QCryptoCryptoDevBackend: + * CryptoDevBackend: * - * The QCryptoCryptoDevBackend object is an interface + * The CryptoDevBackend object is an interface * for different cryptodev backends, which provides crypto * operation wrapper. * */ -#define TYPE_QCRYPTO_CRYPTODEV_BACKEND "cryptodev-backend" +#define TYPE_CRYPTODEV_BACKEND "cryptodev-backend" -#define QCRYPTO_CRYPTODEV_BACKEND(obj) \ - OBJECT_CHECK(QCryptoCryptoDevBackend, \ - (obj), TYPE_QCRYPTO_CRYPTODEV_BACKEND) -#define QCRYPTO_CRYPTODEV_BACKEND_GET_CLASS(obj) \ - OBJECT_GET_CLASS(QCryptoCryptoDevBackendClass, \ - (obj), TYPE_QCRYPTO_CRYPTODEV_BACKEND) -#define QCRYPTO_CRYPTODEV_BACKEND_CLASS(klass) \ - OBJECT_CLASS_CHECK(QCryptoCryptoDevBackendClass, \ - (klass), TYPE_QCRYPTO_CRYPTODEV_BACKEND) +#define CRYPTODEV_BACKEND(obj) \ + OBJECT_CHECK(CryptoDevBackend, \ + (obj), TYPE_CRYPTODEV_BACKEND) +#define CRYPTODEV_BACKEND_GET_CLASS(obj) \ + OBJECT_GET_CLASS(CryptoDevBackendClass, \ + (obj), TYPE_CRYPTODEV_BACKEND) +#define CRYPTODEV_BACKEND_CLASS(klass) \ + OBJECT_CLASS_CHECK(CryptoDevBackendClass, \ + (klass), TYPE_CRYPTODEV_BACKEND) #define MAX_CRYPTO_QUEUE_NUM 64 -typedef struct QCryptoCryptoDevBackendConf QCryptoCryptoDevBackendConf; -typedef struct QCryptoCryptoDevBackendPeers QCryptoCryptoDevBackendPeers; -typedef struct QCryptoCryptoDevBackendClientState - QCryptoCryptoDevBackendClientState; -typedef struct QCryptoCryptoDevBackend QCryptoCryptoDevBackend; +typedef struct CryptoDevBackendConf CryptoDevBackendConf; +typedef struct CryptoDevBackendPeers CryptoDevBackendPeers; +typedef struct CryptoDevBackendClient + CryptoDevBackendClient; +typedef struct CryptoDevBackend CryptoDevBackend; -enum QCryptoCryptoDevBackendAlgType { - QCRYPTO_CRYPTODEV_BACKEND_ALG_SYM, - QCRYPTO_CRYPTODEV_BACKEND_ALG__MAX, +enum CryptoDevBackendAlgType { + CRYPTODEV_BACKEND_ALG_SYM, + CRYPTODEV_BACKEND_ALG__MAX, }; /** - * QCryptoCryptoDevBackendSymSessionInfo: + * CryptoDevBackendSymSessionInfo: * * @op_code: operation code (refer to virtio_crypto.h) * @cipher_alg: algorithm type of CIPHER @@ -80,7 +80,7 @@ enum QCryptoCryptoDevBackendAlgType { * @auth_key: point to an authenticated key of MAC * */ -typedef struct QCryptoCryptoDevBackendSymSessionInfo { +typedef struct CryptoDevBackendSymSessionInfo { /* corresponding with virtio crypto spec */ uint32_t op_code; uint32_t cipher_alg; @@ -95,13 +95,13 @@ typedef struct QCryptoCryptoDevBackendSymSessionInfo { uint8_t alg_chain_order; uint8_t *cipher_key; uint8_t *auth_key; -} QCryptoCryptoDevBackendSymSessionInfo; +} CryptoDevBackendSymSessionInfo; /** - * QCryptoCryptoDevBackendSymOpInfo: + * CryptoDevBackendSymOpInfo: * * @session_id: session index which was previously - * created by qcrypto_cryptodev_backend_sym_create_session() + * created by cryptodev_backend_sym_create_session() * @aad_len: byte length of additional authenticated data * @iv_len: byte length of initialization vector or counter * @src_len: byte length of source data @@ -118,7 +118,7 @@ typedef struct QCryptoCryptoDevBackendSymSessionInfo { * @data[0]: point to the extensional memory by one memory allocation * */ -typedef struct QCryptoCryptoDevBackendSymOpInfo { +typedef struct CryptoDevBackendSymOpInfo { uint64_t session_id; uint32_t aad_len; uint32_t iv_len; @@ -133,41 +133,41 @@ typedef struct QCryptoCryptoDevBackendSymOpInfo { uint8_t *aad_data; uint8_t *digest_result; uint8_t data[0]; -} QCryptoCryptoDevBackendSymOpInfo; +} CryptoDevBackendSymOpInfo; -typedef struct QCryptoCryptoDevBackendClass { +typedef struct CryptoDevBackendClass { ObjectClass parent_class; - void (*init)(QCryptoCryptoDevBackend *backend, Error **errp); - void (*cleanup)(QCryptoCryptoDevBackend *backend, Error **errp); + void (*init)(CryptoDevBackend *backend, Error **errp); + void (*cleanup)(CryptoDevBackend *backend, Error **errp); - int64_t (*create_session)(QCryptoCryptoDevBackend *backend, - QCryptoCryptoDevBackendSymSessionInfo *sess_info, + int64_t (*create_session)(CryptoDevBackend *backend, + CryptoDevBackendSymSessionInfo *sess_info, uint32_t queue_index, Error **errp); - int (*close_session)(QCryptoCryptoDevBackend *backend, + int (*close_session)(CryptoDevBackend *backend, uint64_t session_id, uint32_t queue_index, Error **errp); - int (*do_sym_op)(QCryptoCryptoDevBackend *backend, - QCryptoCryptoDevBackendSymOpInfo *op_info, + int (*do_sym_op)(CryptoDevBackend *backend, + CryptoDevBackendSymOpInfo *op_info, uint32_t queue_index, Error **errp); -} QCryptoCryptoDevBackendClass; +} CryptoDevBackendClass; -struct QCryptoCryptoDevBackendClientState { +struct CryptoDevBackendClient { char *model; char *name; char *info_str; unsigned int queue_index; - QTAILQ_ENTRY(QCryptoCryptoDevBackendClientState) next; + QTAILQ_ENTRY(CryptoDevBackendClient) next; }; -struct QCryptoCryptoDevBackendPeers { - QCryptoCryptoDevBackendClientState *ccs[MAX_CRYPTO_QUEUE_NUM]; +struct CryptoDevBackendPeers { + CryptoDevBackendClient *ccs[MAX_CRYPTO_QUEUE_NUM]; uint32_t queues; }; -struct QCryptoCryptoDevBackendConf { - QCryptoCryptoDevBackendPeers peers; +struct CryptoDevBackendConf { + CryptoDevBackendPeers peers; /* Supported service mask */ uint32_t crypto_services; @@ -184,15 +184,15 @@ struct QCryptoCryptoDevBackendConf { uint32_t primitive_algo; }; -struct QCryptoCryptoDevBackend { +struct CryptoDevBackend { Object parent_obj; bool ready; - QCryptoCryptoDevBackendConf conf; + CryptoDevBackendConf conf; }; /** - * qcrypto_cryptodev_backend_new_client: + * cryptodev_backend_new_client: * @model: the cryptodev backend model * @name: the cryptodev backend name, can be NULL * @@ -200,38 +200,38 @@ struct QCryptoCryptoDevBackend { * with the @name in the model @model. * * The returned object must be released with - * qcrypto_cryptodev_backend_free_client() when no + * cryptodev_backend_free_client() when no * longer required * * Returns: a new cryptodev backend client object */ -QCryptoCryptoDevBackendClientState * -qcrypto_cryptodev_backend_new_client(const char *model, +CryptoDevBackendClient * +cryptodev_backend_new_client(const char *model, const char *name); /** - * qcrypto_cryptodev_backend_free_client: + * cryptodev_backend_free_client: * @cc: the cryptodev backend client object * * Release the memory associated with @cc that - * was previously allocated by qcrypto_cryptodev_backend_new_client() + * was previously allocated by cryptodev_backend_new_client() */ -void qcrypto_cryptodev_backend_free_client( - QCryptoCryptoDevBackendClientState *cc); +void cryptodev_backend_free_client( + CryptoDevBackendClient *cc); /** - * qcrypto_cryptodev_backend_cleanup: + * cryptodev_backend_cleanup: * @backend: the cryptodev backend object * @errp: pointer to a NULL-initialized error object * * Clean the resouce associated with @backend that realizaed * by the specific backend's init() callback */ -void qcrypto_cryptodev_backend_cleanup( - QCryptoCryptoDevBackend *backend, +void cryptodev_backend_cleanup( + CryptoDevBackend *backend, Error **errp); /** - * qcrypto_cryptodev_backend_sym_create_session: + * cryptodev_backend_sym_create_session: * @backend: the cryptodev backend object * @sess_info: parameters needed by session creating * @queue_index: queue index of cryptodev backend client @@ -241,30 +241,30 @@ void qcrypto_cryptodev_backend_cleanup( * * Returns: session id on success, or -1 on error */ -int64_t qcrypto_cryptodev_backend_sym_create_session( - QCryptoCryptoDevBackend *backend, - QCryptoCryptoDevBackendSymSessionInfo *sess_info, +int64_t cryptodev_backend_sym_create_session( + CryptoDevBackend *backend, + CryptoDevBackendSymSessionInfo *sess_info, uint32_t queue_index, Error **errp); /** - * qcrypto_cryptodev_backend_sym_close_session: + * cryptodev_backend_sym_close_session: * @backend: the cryptodev backend object * @session_id: the session id * @queue_index: queue index of cryptodev backend client * @errp: pointer to a NULL-initialized error object * * Close a session for symmetric algorithms which was previously - * created by qcrypto_cryptodev_backend_sym_create_session() + * created by cryptodev_backend_sym_create_session() * * Returns: 0 on success, or Negative on error */ -int qcrypto_cryptodev_backend_sym_close_session( - QCryptoCryptoDevBackend *backend, +int cryptodev_backend_sym_close_session( + CryptoDevBackend *backend, uint64_t session_id, uint32_t queue_index, Error **errp); /** - * qcrypto_cryptodev_backend_crypto_operation: + * cryptodev_backend_crypto_operation: * @backend: the cryptodev backend object * @opaque: pointer to a VirtIOCryptoReq object * @queue_index: queue index of cryptodev backend client @@ -276,8 +276,8 @@ int qcrypto_cryptodev_backend_sym_close_session( * Returns: VIRTIO_CRYPTO_OK on success, * or -VIRTIO_CRYPTO_* on error */ -int qcrypto_cryptodev_backend_crypto_operation( - QCryptoCryptoDevBackend *backend, +int cryptodev_backend_crypto_operation( + CryptoDevBackend *backend, void *opaque, uint32_t queue_index, Error **errp);