@@ -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,
@@ -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 {
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(-)