From patchwork Thu Sep 8 03:42:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gonglei (Arei)" X-Patchwork-Id: 9320365 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 09AFE6077F for ; Thu, 8 Sep 2016 03:53:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA85F29494 for ; Thu, 8 Sep 2016 03:53:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DE3F129556; Thu, 8 Sep 2016 03:53: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 5609229494 for ; Thu, 8 Sep 2016 03:53:02 +0000 (UTC) Received: from localhost ([::1]:44786 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhqOb-0002s4-Ej for patchwork-qemu-devel@patchwork.kernel.org; Wed, 07 Sep 2016 23:53:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56328) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhqIl-0004oN-Pw for qemu-devel@nongnu.org; Wed, 07 Sep 2016 23:47:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bhqIi-0006A3-9N for qemu-devel@nongnu.org; Wed, 07 Sep 2016 23:46:58 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:18965) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhqIh-00069W-K7 for qemu-devel@nongnu.org; Wed, 07 Sep 2016 23:46:56 -0400 Received: from 172.24.1.36 (EHLO szxeml427-hub.china.huawei.com) ([172.24.1.36]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id DMU12967; Thu, 08 Sep 2016 11:43:07 +0800 (CST) Received: from localhost (10.177.18.62) by szxeml427-hub.china.huawei.com (10.82.67.182) with Microsoft SMTP Server id 14.3.235.1; Thu, 8 Sep 2016 11:43:00 +0800 From: Gonglei To: , Date: Thu, 8 Sep 2016 11:42:32 +0800 Message-ID: <1473306156-176628-11-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.0A020201.57D0DE4B.0169, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: dc742b0b7d47138ee8d6e338a3300983 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 119.145.14.65 Subject: [Qemu-devel] [PATCH v1 10/14] virtio-crypto: set capacity of crypto legacy hardware 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 Set the crypto legacy hardware's capacity according to the backend peer cryptodev's capacity. We only support only one queue at present. Virtio crypto device is a kind of crypto legacy hardware. Signed-off-by: Gonglei --- crypto/crypto.c | 17 +++++++++++++++++ hw/virtio/virtio-crypto.c | 28 +++++++++++++++++++++++++++- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/crypto/crypto.c b/crypto/crypto.c index 184f837..ba99d7c 100644 --- a/crypto/crypto.c +++ b/crypto/crypto.c @@ -228,6 +228,7 @@ qemu_new_crypto_legacy_hw(CryptoClientInfo *info, CryptoLegacyHWState *crypto; CryptoClientState **peers = conf->peers.ccs; int i, queues = MAX(1, conf->peers.queues); + int has_set = 0; assert(info->type == CRYPTO_CLIENT_OPTIONS_KIND_LEGACY_HW); assert(info->size >= sizeof(CryptoLegacyHWState)); @@ -242,6 +243,22 @@ qemu_new_crypto_legacy_hw(CryptoClientInfo *info, NULL); crypto->ccs[i].queue_index = i; crypto->ccs[i].ready = true; + /* The mask bits of crypto_services and algos in + CryptoLegacyHWConf is set only once */ + if (has_set == 0 && peers[i]) { + conf->crypto_services = peers[i]->crypto_services; + conf->cipher_algo_l = peers[i]->cipher_algo_l; + conf->cipher_algo_h = peers[i]->cipher_algo_h; + conf->hash_algo = peers[i]->hash_algo; + conf->mac_algo_l = peers[i]->mac_algo_l; + conf->mac_algo_h = peers[i]->mac_algo_h; + conf->asym_algo = peers[i]->asym_algo; + conf->kdf_algo = peers[i]->kdf_algo; + conf->aead_algo = peers[i]->aead_algo; + conf->primitive_algo = peers[i]->primitive_algo; + + has_set = 1; + } } return crypto; diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c index 23c5041..b7a7b41 100644 --- a/hw/virtio/virtio-crypto.c +++ b/hw/virtio/virtio-crypto.c @@ -197,7 +197,33 @@ static Property virtio_crypto_properties[] = { static void virtio_crypto_get_config(VirtIODevice *vdev, uint8_t *config) { - + VirtIOCrypto *c = VIRTIO_CRYPTO(vdev); + struct virtio_crypto_config crypto_cfg; + + virtio_stl_p(vdev, &crypto_cfg.status, c->status); + virtio_stl_p(vdev, &crypto_cfg.max_dataqueues, c->max_queues); + virtio_stl_p(vdev, &crypto_cfg.crypto_services, + c->legacy_conf.crypto_services); + virtio_stl_p(vdev, &crypto_cfg.cipher_algo_l, + c->legacy_conf.cipher_algo_l); + virtio_stl_p(vdev, &crypto_cfg.cipher_algo_h, + c->legacy_conf.cipher_algo_h); + virtio_stl_p(vdev, &crypto_cfg.hash_algo, + c->legacy_conf.hash_algo); + virtio_stl_p(vdev, &crypto_cfg.mac_algo_l, + c->legacy_conf.mac_algo_l); + virtio_stl_p(vdev, &crypto_cfg.mac_algo_h, + c->legacy_conf.mac_algo_h); + virtio_stl_p(vdev, &crypto_cfg.asym_algo, + c->legacy_conf.asym_algo); + virtio_stl_p(vdev, &crypto_cfg.kdf_algo, + c->legacy_conf.kdf_algo); + virtio_stl_p(vdev, &crypto_cfg.aead_algo, + c->legacy_conf.aead_algo); + virtio_stl_p(vdev, &crypto_cfg.primitive_algo, + c->legacy_conf.primitive_algo); + + memcpy(config, &crypto_cfg, c->config_size); } static void virtio_crypto_set_config(VirtIODevice *vdev, const uint8_t *config)