From patchwork Mon Sep 11 01:10:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Longpeng(Mike)" X-Patchwork-Id: 9946439 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 077B9602C9 for ; Mon, 11 Sep 2017 01:13:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EF85F289ED for ; Mon, 11 Sep 2017 01:13:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E211F28A9E; Mon, 11 Sep 2017 01:13:02 +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 4D3EB28A99 for ; Mon, 11 Sep 2017 01:13:02 +0000 (UTC) Received: from localhost ([::1]:54823 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1drDHZ-0004Hj-DJ for patchwork-qemu-devel@patchwork.kernel.org; Sun, 10 Sep 2017 21:13:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35247) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1drDG5-0004HF-L6 for qemu-devel@nongnu.org; Sun, 10 Sep 2017 21:11:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1drDG0-00045W-Lf for qemu-devel@nongnu.org; Sun, 10 Sep 2017 21:11:29 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:2311) by eggs.gnu.org with esmtps (TLS1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.71) (envelope-from ) id 1drDG0-00042A-05 for qemu-devel@nongnu.org; Sun, 10 Sep 2017 21:11:24 -0400 Received: from 172.30.72.58 (EHLO DGGEMS407-HUB.china.huawei.com) ([172.30.72.58]) by dggrg04-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id DGZ05861; Mon, 11 Sep 2017 09:10:58 +0800 (CST) Received: from localhost (10.177.246.209) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.301.0; Mon, 11 Sep 2017 09:10:50 +0800 From: "Longpeng(Mike)" To: , Date: Mon, 11 Sep 2017 09:10:36 +0800 Message-ID: <1505092240-10864-5-git-send-email-longpeng2@huawei.com> X-Mailer: git-send-email 1.8.4.msysgit.0 In-Reply-To: <1505092240-10864-1-git-send-email-longpeng2@huawei.com> References: <1505092240-10864-1-git-send-email-longpeng2@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.246.209] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A0B0208.59B5E2A2.00B3, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 9f6fc4f4f0818c6979e99629858e8117 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] [fuzzy] X-Received-From: 45.249.212.190 Subject: [Qemu-devel] [RFC 4/8] cryptodev: add stateless mode cipher support 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, mst@redhat.com, jasowang@redhat.com, john.griffin@intel.com, Varun.Sethi@freescale.com, denglingli@chinamobile.com, arei.gonglei@hotmail.com, agraf@suse.de, arei.gonglei@huawei.com, "Longpeng\(Mike\)" , vincent.jardin@6wind.com, Ola.Liljedahl@arm.com, luonengjun@huawei.com, xin.zeng@intel.com, liang.j.ma@intel.com, stefanha@redhat.com, Jani.Kokkonen@huawei.com, pasic@linux.vnet.ibm.com, brian.a.keating@intel.com, wangxinxin.wang@huawei.com, cohuck@redhat.com, mike.caraman@nxp.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Adds stateless mode cipher support. Signed-off-by: Longpeng(Mike) --- backends/cryptodev.c | 21 +++++++++++++++++++++ include/hw/virtio/virtio-crypto.h | 1 + include/sysemu/cryptodev.h | 18 ++++++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/backends/cryptodev.c b/backends/cryptodev.c index 1764c17..a76a312 100755 --- a/backends/cryptodev.c +++ b/backends/cryptodev.c @@ -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); diff --git a/include/hw/virtio/virtio-crypto.h b/include/hw/virtio/virtio-crypto.h index a00a0bf..465ad20 100755 --- a/include/hw/virtio/virtio-crypto.h +++ b/include/hw/virtio/virtio-crypto.h @@ -73,6 +73,7 @@ typedef struct VirtIOCryptoReq { struct VirtIOCrypto *vcrypto; union { CryptoDevBackendSymOpInfo *sym_op_info; + CryptoDevBackendSymStatelessInfo *sym_stateless_info; } u; } VirtIOCryptoReq; diff --git a/include/sysemu/cryptodev.h b/include/sysemu/cryptodev.h index a9d0d1e..aa2fcd8 100755 --- a/include/sysemu/cryptodev.h +++ b/include/sysemu/cryptodev.h @@ -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;