From patchwork Tue Sep 13 03:52:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gonglei (Arei)" X-Patchwork-Id: 9328359 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 7968560839 for ; Tue, 13 Sep 2016 04:11:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 65C1229092 for ; Tue, 13 Sep 2016 04:11:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5A84129095; Tue, 13 Sep 2016 04:11:37 +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 EE8DF29092 for ; Tue, 13 Sep 2016 04:11:36 +0000 (UTC) Received: from localhost ([::1]:46397 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjf4K-0003H3-5t for patchwork-qemu-devel@patchwork.kernel.org; Tue, 13 Sep 2016 00:11:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38042) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjeq0-0000X0-Ke for qemu-devel@nongnu.org; Mon, 12 Sep 2016 23:56:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bjepu-00040q-TA for qemu-devel@nongnu.org; Mon, 12 Sep 2016 23:56:47 -0400 Received: from szxga01-in.huawei.com ([58.251.152.64]:52140) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjepu-00040I-9g for qemu-devel@nongnu.org; Mon, 12 Sep 2016 23:56:42 -0400 Received: from 172.24.1.36 (EHLO szxeml431-hub.china.huawei.com) ([172.24.1.36]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id DQY76485; Tue, 13 Sep 2016 11:53:00 +0800 (CST) Received: from localhost (10.177.18.62) by szxeml431-hub.china.huawei.com (10.82.67.208) with Microsoft SMTP Server id 14.3.235.1; Tue, 13 Sep 2016 11:52:50 +0800 From: Gonglei To: , Date: Tue, 13 Sep 2016 11:52:13 +0800 Message-ID: <1473738741-220600-8-git-send-email-arei.gonglei@huawei.com> X-Mailer: git-send-email 2.6.3.windows.1 In-Reply-To: <1473738741-220600-1-git-send-email-arei.gonglei@huawei.com> References: <1473738741-220600-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.0A020206.57D7781E.00AA, 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: db868a3b261c4b4308d0d81c23572a62 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 v2 07/15] virtio-crypto: introduce virtio-crypto.h 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: claudio.fontana@huawei.com, mst@redhat.com, xin.zeng@intel.com, luonengjun@huawei.com, peter.huangpeng@huawei.com, agraf@suse.de, nmorey@kalray.eu, mike.caraman@nxp.com, Gonglei , stefanha@redhat.com, pbonzini@redhat.com, vincent.jardin@6wind.com, weidong.huang@huawei.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 introduces the header of virtio crypto emulation. Signed-off-by: Gonglei --- include/hw/virtio/virtio-crypto.h | 84 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 include/hw/virtio/virtio-crypto.h diff --git a/include/hw/virtio/virtio-crypto.h b/include/hw/virtio/virtio-crypto.h new file mode 100644 index 0000000..243ed71 --- /dev/null +++ b/include/hw/virtio/virtio-crypto.h @@ -0,0 +1,84 @@ +/* + * Virtio crypto Support + * + * Copyright (c) 2016 HUAWEI TECHNOLOGIES CO., LTD. + * + * Authors: + * Gonglei + * + * This work is licensed under the terms of the GNU GPL, version 2 or + * (at your option) any later version. See the COPYING file in the + * top-level directory. + */ + +#ifndef _QEMU_VIRTIO_CRYPTO_H +#define _QEMU_VIRTIO_CRYPTO_H + +#include "standard-headers/linux/virtio_crypto.h" +#include "hw/virtio/virtio.h" +#include "sysemu/iothread.h" +#include "crypto/crypto.h" + +#define VIRTIO_ID_CRYPTO 20 + +/* #define DEBUG_VIRTIO_CRYPTO */ + +#ifdef DEBUG_VIRTIO_CRYPTO +#define DPRINTF(fmt, ...) \ +do { printf("virtio_crypto: " fmt , ## __VA_ARGS__); } while (0) +#else +#define DPRINTF(fmt, ...) do { } while (0) +#endif + +#define TYPE_VIRTIO_CRYPTO "virtio-crypto-device" +#define VIRTIO_CRYPTO(obj) \ + OBJECT_CHECK(VirtIOCrypto, (obj), TYPE_VIRTIO_CRYPTO) +#define VIRTIO_CRYPTO_GET_PARENT_CLASS(obj) \ + OBJECT_GET_PARENT_CLASS(obj, TYPE_VIRTIO_CRYPTO) + + +/* Limit the number of packets that can be sent via a single flush + * of the TX queue. This gives us a guaranteed exit condition and + * ensures fairness in the io path. 256 conveniently matches the + * length of the TX queue and shows a good balance of performance + * and latency. */ +#define VIRTIO_CRYPTO_TX_BURST 256 + +typedef struct VirtIOCryptoConf { + int32_t txburst; +} VirtIOCryptoConf; + +struct VirtIOCrypto; + +typedef struct VirtIOCryptoQueue { + VirtQueue *dataq; + QEMUBH *tx_bh; + int tx_waiting; + struct { + VirtQueueElement *elem; + uint32_t flags; + CryptoSymOpInfo *op_info; + void *idata_hva; + } async_tx; + struct VirtIOCrypto *vcrypto; +} VirtIOCryptoQueue; + +typedef struct VirtIOCrypto { + VirtIODevice parent_obj; + + VirtIOCryptoQueue *vqs; + VirtQueue *ctrl_vq; + CryptoLegacyHWState *crypto; + CryptoLegacyHWConf legacy_conf; + + VirtIOCryptoConf conf; + int32_t tx_burst; + uint32_t max_queues; + uint32_t status; + + int multiqueue; + uint32_t curr_queues; + size_t config_size; +} VirtIOCrypto; + +#endif /* _QEMU_VIRTIO_CRYPTO_H */