From: "Longpeng(Mike)" <longpeng2@huawei.com>
To: arei.gonglei@huawei.com, pasic@linux.vnet.ibm.com
Cc: weidong.huang@huawei.com, wangxinxin.wang@huawei.com,
jianjay.zhou@huawei.com, qemu-devel@nongnu.org,
"Longpeng(Mike)" <longpeng2@huawei.com>
Subject: [Qemu-devel] [RFC 02/10] virtio-crypto: add session creation logic for mux mode
Date: Mon, 6 Nov 2017 14:56:54 +0800 [thread overview]
Message-ID: <1509951422-20060-3-git-send-email-longpeng2@huawei.com> (raw)
In-Reply-To: <1509951422-20060-1-git-send-email-longpeng2@huawei.com>
Adds some macros about the features of multiplexing
mode and supports the session create for this mode.
Signed-off-by: Longpeng(Mike) <longpeng2@huawei.com>
---
hw/virtio/virtio-crypto.c | 13 +++++++++++--
include/standard-headers/linux/virtio_crypto.h | 7 +++++++
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c
index c7f6cc4..04c34d8 100644
--- a/hw/virtio/virtio-crypto.c
+++ b/hw/virtio/virtio-crypto.c
@@ -33,6 +33,11 @@ static inline int virtio_crypto_vq2q(int queue_index)
return queue_index;
}
+static inline bool virtio_crypto_in_mux_mode(VirtIODevice *vdev)
+{
+ return virtio_vdev_has_feature(vdev, VIRTIO_CRYPTO_F_MUX_MODE);
+}
+
static int
virtio_crypto_cipher_session_helper(VirtIODevice *vdev,
CryptoDevBackendSymSessionInfo *info,
@@ -223,6 +228,9 @@ static void virtio_crypto_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
uint8_t status;
size_t s;
+#define ctrl_req_payload_size(vdev, req) \
+ (virtio_crypto_in_mux_mode((vdev)) ? sizeof((req)) : \
+ VIRTIO_CRYPTO_CTRL_REQ_PAYLOAD_SIZE_NONMUX)
for (;;) {
elem = virtqueue_pop(vq, sizeof(VirtQueueElement));
if (!elem) {
@@ -259,7 +267,7 @@ static void virtio_crypto_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
iov_to_buf(out_iov, out_num, 0, &req, sizeof(req));
/* The unused part of the req will be ingored */
- s = VIRTIO_CRYPTO_CTRL_REQ_PAYLOAD_SIZE_NONMUX;
+ s = ctrl_req_payload_size(vdev, req);
if (unlikely(s != iov_discard_front(&out_iov, &out_num, s))) {
virtio_error(vdev, "virtio-crypto request additional "
"parameters too short");
@@ -304,7 +312,7 @@ static void virtio_crypto_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
iov_to_buf(out_iov, out_num, 0, &req, sizeof(req));
/* The unused part of the req will be ingored */
- s = VIRTIO_CRYPTO_CTRL_REQ_PAYLOAD_SIZE_NONMUX;
+ s = ctrl_req_payload_size(vdev, req);
if (unlikely(s != iov_discard_front(&out_iov, &out_num, s))) {
virtio_error(vdev, "virtio-crypto request additional "
"parameters too short");
@@ -346,6 +354,7 @@ static void virtio_crypto_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
g_free(elem);
} /* end for loop */
+#undef ctrl_req_payload_size
}
static void virtio_crypto_init_request(VirtIOCrypto *vcrypto, VirtQueue *vq,
diff --git a/include/standard-headers/linux/virtio_crypto.h b/include/standard-headers/linux/virtio_crypto.h
index 6677c82..8793be6 100644
--- a/include/standard-headers/linux/virtio_crypto.h
+++ b/include/standard-headers/linux/virtio_crypto.h
@@ -38,6 +38,13 @@
#define VIRTIO_CRYPTO_SERVICE_MAC 2
#define VIRTIO_CRYPTO_SERVICE_AEAD 3
+/* The features for virtio crypto device */
+#define VIRTIO_CRYPTO_F_MUX_MODE 0
+#define VIRTIO_CRYPTO_F_CIPHER_STATELESS_MODE 1
+#define VIRTIO_CRYPTO_F_HASH_STATELESS_MODE 2
+#define VIRTIO_CRYPTO_F_MAC_STATELESS_MODE 3
+#define VIRTIO_CRYPTO_F_AEAD_STATELESS_MODE 4
+
#define VIRTIO_CRYPTO_OPCODE(service, op) (((service) << 8) | (op))
struct virtio_crypto_ctrl_header {
--
1.8.3.1
next prev parent reply other threads:[~2017-11-06 7:43 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-06 6:56 [Qemu-devel] [RFC 00/10] virtio-crypto: add multiplexing mode support Longpeng(Mike)
2017-11-06 6:56 ` [Qemu-devel] [RFC 01/10] virtio-crypto: remove virtio_crypto_op_ctrl_req structure Longpeng(Mike)
2017-11-06 6:56 ` Longpeng(Mike) [this message]
2017-11-06 6:56 ` [Qemu-devel] [RFC 03/10] virtio-crypto: remove queue_id field in ctrl header Longpeng(Mike)
2017-11-06 6:56 ` [Qemu-devel] [RFC 04/10] virtio-crypto: remove virtio_crypto_op_data_req structure Longpeng(Mike)
2017-11-06 6:56 ` [Qemu-devel] [RFC 05/10] virtio-crypto: add dataq operation logic for mux mode Longpeng(Mike)
2017-11-06 6:56 ` [Qemu-devel] [RFC 06/10] cryptodev: add stateless mode cipher support Longpeng(Mike)
2017-11-06 6:56 ` [Qemu-devel] [RFC 07/10] virtio-crypto: add stateless crypto request handler Longpeng(Mike)
2017-11-06 6:57 ` [Qemu-devel] [RFC 08/10] cryptodev: extract one util function Longpeng(Mike)
2017-11-06 6:57 ` [Qemu-devel] [RFC 09/10] cryptodev-builtin: add stateless cipher support Longpeng(Mike)
2017-11-06 6:57 ` [Qemu-devel] [RFC 10/10] virtio-crypto: add host feature bits support Longpeng(Mike)
2017-11-06 7:57 ` [Qemu-devel] [RFC 00/10] virtio-crypto: add multiplexing mode support no-reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1509951422-20060-3-git-send-email-longpeng2@huawei.com \
--to=longpeng2@huawei.com \
--cc=arei.gonglei@huawei.com \
--cc=jianjay.zhou@huawei.com \
--cc=pasic@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=wangxinxin.wang@huawei.com \
--cc=weidong.huang@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).