From patchwork Wed Sep 28 08:25:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gonglei (Arei)" X-Patchwork-Id: 9353331 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 3D8E260756 for ; Wed, 28 Sep 2016 08:46:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2E55C2944E for ; Wed, 28 Sep 2016 08:46:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 22F3329451; Wed, 28 Sep 2016 08:46: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 91E672944E for ; Wed, 28 Sep 2016 08:46:13 +0000 (UTC) Received: from localhost ([::1]:56849 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpAVI-0001Dg-RZ for patchwork-qemu-devel@patchwork.kernel.org; Wed, 28 Sep 2016 04:46:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38312) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpAIu-0006Dx-4U for qemu-devel@nongnu.org; Wed, 28 Sep 2016 04:33:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bpAIp-0007KZ-Uh for qemu-devel@nongnu.org; Wed, 28 Sep 2016 04:33:23 -0400 Received: from szxga01-in.huawei.com ([58.251.152.64]:2121) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpAIo-0007JY-MR for qemu-devel@nongnu.org; Wed, 28 Sep 2016 04:33:19 -0400 Received: from 172.24.1.60 (EHLO szxeml432-hub.china.huawei.com) ([172.24.1.60]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id DRR27562; Wed, 28 Sep 2016 16:26:21 +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; Wed, 28 Sep 2016 16:26:10 +0800 From: Gonglei To: , Date: Wed, 28 Sep 2016 16:25:46 +0800 Message-ID: <1475051152-400276-8-git-send-email-arei.gonglei@huawei.com> X-Mailer: git-send-email 2.6.3.windows.1 In-Reply-To: <1475051152-400276-1-git-send-email-arei.gonglei@huawei.com> References: <1475051152-400276-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.57EB7EB1.0071, 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: 418398d8f8877826628ab08f987005cc 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 v4 07/13] virtio-crypto: set capacity of algorithms supported 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 Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Expose the capacity of algorithms supported by virtio crypto device to the frontend driver using pci configuration space. Signed-off-by: Gonglei --- hw/virtio/virtio-crypto.c | 32 +++++++++++++++++++++++++++++++- include/hw/virtio/virtio-crypto.h | 14 ++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c index e639fb3..e74a15f 100644 --- a/hw/virtio/virtio-crypto.c +++ b/hw/virtio/virtio-crypto.c @@ -89,6 +89,22 @@ static void virtio_crypto_reset(VirtIODevice *vdev) } } +static void virtio_crypto_init_config(VirtIODevice *vdev) +{ + VirtIOCrypto *vcrypto = VIRTIO_CRYPTO(vdev); + + vcrypto->conf.crypto_services = + vcrypto->conf.cryptodev->conf.crypto_services; + vcrypto->conf.cipher_algo_l = + vcrypto->conf.cryptodev->conf.cipher_algo_l; + vcrypto->conf.cipher_algo_h = + vcrypto->conf.cryptodev->conf.cipher_algo_h; + vcrypto->conf.hash_algo = vcrypto->conf.cryptodev->conf.hash_algo; + vcrypto->conf.mac_algo_l = vcrypto->conf.cryptodev->conf.mac_algo_l; + vcrypto->conf.mac_algo_h = vcrypto->conf.cryptodev->conf.mac_algo_h; + vcrypto->conf.aead_algo = vcrypto->conf.cryptodev->conf.aead_algo; +} + static void virtio_crypto_device_realize(DeviceState *dev, Error **errp) { VirtIODevice *vdev = VIRTIO_DEVICE(dev); @@ -122,6 +138,7 @@ static void virtio_crypto_device_realize(DeviceState *dev, Error **errp) } else { vcrypto->status |= VIRTIO_CRYPTO_S_HW_READY; } + virtio_crypto_init_config(vdev); register_savevm(dev, "virtio-crypto", -1, 1, virtio_crypto_save, virtio_crypto_load, vcrypto); } @@ -142,7 +159,20 @@ 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; + + crypto_cfg.status = c->status; + crypto_cfg.max_dataqueues = c->max_queues; + crypto_cfg.crypto_services = c->conf.crypto_services; + crypto_cfg.cipher_algo_l = c->conf.cipher_algo_l; + crypto_cfg.cipher_algo_h = c->conf.cipher_algo_h; + crypto_cfg.hash_algo = c->conf.hash_algo; + crypto_cfg.mac_algo_l = c->conf.mac_algo_l; + crypto_cfg.mac_algo_h = c->conf.mac_algo_h; + crypto_cfg.aead_algo = c->conf.aead_algo; + + memcpy(config, &crypto_cfg, c->config_size); } static void virtio_crypto_set_config(VirtIODevice *vdev, const uint8_t *config) diff --git a/include/hw/virtio/virtio-crypto.h b/include/hw/virtio/virtio-crypto.h index 484062c..8aa2fe9 100644 --- a/include/hw/virtio/virtio-crypto.h +++ b/include/hw/virtio/virtio-crypto.h @@ -38,6 +38,20 @@ do { printf("virtio_crypto: " fmt , ## __VA_ARGS__); } while (0) typedef struct VirtIOCryptoConf { QCryptoCryptoDevBackend *cryptodev; + + /* Supported service mask */ + uint32_t crypto_services; + + /* Detailed algorithms mask */ + uint32_t cipher_algo_l; + uint32_t cipher_algo_h; + uint32_t hash_algo; + uint32_t mac_algo_l; + uint32_t mac_algo_h; + uint32_t asym_algo; + uint32_t kdf_algo; + uint32_t aead_algo; + uint32_t primitive_algo; } VirtIOCryptoConf; struct VirtIOCrypto;