From patchwork Mon Oct 10 08:55:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gonglei (Arei)" X-Patchwork-Id: 680294 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3ssvbN0j5xz9ry7 for ; Mon, 10 Oct 2016 20:14:56 +1100 (AEDT) Received: from localhost ([::1]:48269 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1btWfc-0003ii-2r for incoming@patchwork.ozlabs.org; Mon, 10 Oct 2016 05:14:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48382) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1btWQV-0007yG-1D for qemu-devel@nongnu.org; Mon, 10 Oct 2016 04:59:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1btWQT-0005v6-S1 for qemu-devel@nongnu.org; Mon, 10 Oct 2016 04:59:15 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:7161) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1btWQT-0005nz-6z for qemu-devel@nongnu.org; Mon, 10 Oct 2016 04:59:13 -0400 Received: from 172.24.1.60 (EHLO szxeml425-hub.china.huawei.com) ([172.24.1.60]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id DOJ73453; Mon, 10 Oct 2016 16:55:49 +0800 (CST) Received: from localhost (10.177.18.62) by szxeml425-hub.china.huawei.com (10.82.67.180) with Microsoft SMTP Server id 14.3.235.1; Mon, 10 Oct 2016 16:55:42 +0800 From: Gonglei To: , Date: Mon, 10 Oct 2016 16:55:25 +0800 Message-ID: <1476089730-65776-8-git-send-email-arei.gonglei@huawei.com> X-Mailer: git-send-email 2.6.3.windows.1 In-Reply-To: <1476089730-65776-1-git-send-email-arei.gonglei@huawei.com> References: <1476089730-65776-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: 119.145.14.65 Subject: [Qemu-devel] [PATCH RESEND v6 07/12] 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, arei.gonglei@hotmail.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 | 40 ++++++++++++++++++++++++++++++++++++++- include/hw/virtio/virtio-crypto.h | 14 ++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c index 58cb3a9..e2bc90e 100644 --- a/hw/virtio/virtio-crypto.c +++ b/hw/virtio/virtio-crypto.c @@ -42,6 +42,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); @@ -75,6 +91,8 @@ static void virtio_crypto_device_realize(DeviceState *dev, Error **errp) } else { vcrypto->status |= VIRTIO_CRYPTO_S_HW_READY; } + + virtio_crypto_init_config(vdev); } static void virtio_crypto_device_unrealize(DeviceState *dev, Error **errp) @@ -100,7 +118,27 @@ 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->conf.crypto_services); + virtio_stl_p(vdev, &crypto_cfg.cipher_algo_l, + c->conf.cipher_algo_l); + virtio_stl_p(vdev, &crypto_cfg.cipher_algo_h, + c->conf.cipher_algo_h); + virtio_stl_p(vdev, &crypto_cfg.hash_algo, + c->conf.hash_algo); + virtio_stl_p(vdev, &crypto_cfg.mac_algo_l, + c->conf.mac_algo_l); + virtio_stl_p(vdev, &crypto_cfg.mac_algo_h, + c->conf.mac_algo_h); + virtio_stl_p(vdev, &crypto_cfg.aead_algo, + c->conf.aead_algo); + + memcpy(config, &crypto_cfg, c->config_size); } static void virtio_crypto_class_init(ObjectClass *klass, void *data) diff --git a/include/hw/virtio/virtio-crypto.h b/include/hw/virtio/virtio-crypto.h index 9bf2b74..a5e826c 100644 --- a/include/hw/virtio/virtio-crypto.h +++ b/include/hw/virtio/virtio-crypto.h @@ -39,6 +39,20 @@ do { \ typedef struct VirtIOCryptoConf { CryptoDevBackend *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;