From patchwork Thu Sep 8 03:42:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gonglei (Arei)" X-Patchwork-Id: 9320335 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 D01A460231 for ; Thu, 8 Sep 2016 03:44:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B21F829552 for ; Thu, 8 Sep 2016 03:44:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A6C1D29554; Thu, 8 Sep 2016 03:44:10 +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 0869529552 for ; Thu, 8 Sep 2016 03:44:09 +0000 (UTC) Received: from localhost ([::1]:44738 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhqG0-0001zO-6K for patchwork-qemu-devel@patchwork.kernel.org; Wed, 07 Sep 2016 23:44:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55888) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhqFU-0001yF-OP for qemu-devel@nongnu.org; Wed, 07 Sep 2016 23:43:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bhqFQ-0005Qh-JQ for qemu-devel@nongnu.org; Wed, 07 Sep 2016 23:43:35 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:5469) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhqFP-0005OX-Ux for qemu-devel@nongnu.org; Wed, 07 Sep 2016 23:43:32 -0400 Received: from 172.24.1.60 (EHLO szxeml432-hub.china.huawei.com) ([172.24.1.60]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id CHM27369; Thu, 08 Sep 2016 11:43:04 +0800 (CST) Received: from localhost (10.177.18.62) by szxeml432-hub.china.huawei.com (10.82.67.209) with Microsoft SMTP Server id 14.3.235.1; Thu, 8 Sep 2016 11:42:56 +0800 From: Gonglei To: , Date: Thu, 8 Sep 2016 11:42:28 +0800 Message-ID: <1473306156-176628-7-git-send-email-arei.gonglei@huawei.com> X-Mailer: git-send-email 2.6.3.windows.1 In-Reply-To: <1473306156-176628-1-git-send-email-arei.gonglei@huawei.com> References: <1473306156-176628-1-git-send-email-arei.gonglei@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.18.62] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020204.57D0DE49.0018, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 6e6fbdfb06e4c9c34d2c0c4b1f0b3e35 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 119.145.14.66 Subject: [Qemu-devel] [PATCH v1 06/14] crypto: add internal handle logic layer 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, john.griffin@intel.com, jianjay.zhou@huawei.com, Varun.Sethi@freescale.com, denglingli@chinamobile.com, hanweidong@huawei.com, agraf@suse.de, Gonglei , nmorey@kalray.eu, vincent.jardin@6wind.com, Ola.Liljedahl@arm.com, luonengjun@huawei.com, xin.zeng@intel.com, peter.huangpeng@huawei.com, liang.j.ma@intel.com, stefanha@redhat.com, cornelia.huck@de.ibm.com, Jani.Kokkonen@huawei.com, brian.a.keating@intel.com, claudio.fontana@huawei.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 This patch add some transfering layer or functions, such as session creation, closing etc, which will be used by subsequent virtio crypto device patches. Signed-off-by: Gonglei --- crypto/crypto.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/crypto/crypto.c b/crypto/crypto.c index 1d3d1d3..184f837 100644 --- a/crypto/crypto.c +++ b/crypto/crypto.c @@ -291,3 +291,71 @@ void qemu_del_crypto_legacy_hw(CryptoLegacyHWState *crypto) g_free(crypto); } + +CryptoLegacyHWState *qemu_get_crypto_legacy_hw(CryptoClientState *cc) +{ + CryptoClientState *cc0 = cc - cc->queue_index; + + return (CryptoLegacyHWState *)((void *)cc0 - cc->info->size); +} + +void *qemu_get_crypto_legacy_hw_opaque(CryptoClientState *cc) +{ + CryptoLegacyHWState *crypto = qemu_get_crypto_legacy_hw(cc); + + return crypto->opaque; +} + +int qemu_find_crypto_clients_except(const char *id, CryptoClientState **ccs, + CryptoClientOptionsKind type, int max) +{ + CryptoClientState *cc; + int ret = 0; + + QTAILQ_FOREACH(cc, &crypto_clients, next) { + if (cc->info->type == type) { + continue; + } + if (!id || !strcmp(cc->name, id)) { + if (ret < max) { + ccs[ret] = cc; + } + ret++; + } + } + + return ret; +} + +int qemu_crypto_create_session(CryptoClientState *cc, + CryptoSymSessionInfo *info, + uint64_t *session_id) +{ + int ret = -1; + CryptoClientState *peer = cc->peer; + + if (!peer || !peer->ready) { + return ret; + } + + if (peer->info->create_session) { + ret = peer->info->create_session(peer, info, session_id); + } + return ret; +} + +int qemu_crypto_close_session(CryptoClientState *cc, + uint64_t session_id) +{ + int ret = -1; + CryptoClientState *peer = cc->peer; + + if (!peer || !peer->ready) { + return ret; + } + + if (peer->info->close_session) { + ret = peer->info->close_session(peer, session_id); + } + return ret; +}