2 * Virtio crypto Support
4 * Copyright (c) 2016 HUAWEI TECHNOLOGIES CO., LTD.
7 * Gonglei <arei.gonglei@huawei.com>
9 * This work is licensed under the terms of the GNU GPL, version 2 or
10 * (at your option) any later version. See the COPYING file in the
11 * top-level directory.
14 #ifndef QEMU_VIRTIO_CRYPTO_H
15 #define QEMU_VIRTIO_CRYPTO_H
17 #include "standard-headers/linux/virtio_crypto.h"
18 #include "hw/virtio/virtio.h"
19 #include "sysemu/iothread.h"
20 #include "sysemu/cryptodev.h"
23 #define DEBUG_VIRTIO_CRYPTO 0
25 #define DPRINTF(fmt, ...) \
27 if (DEBUG_VIRTIO_CRYPTO) { \
28 fprintf(stderr, "virtio_crypto: " fmt, ##__VA_ARGS__); \
33 #define TYPE_VIRTIO_CRYPTO "virtio-crypto-device"
34 #define VIRTIO_CRYPTO(obj) \
35 OBJECT_CHECK(VirtIOCrypto, (obj), TYPE_VIRTIO_CRYPTO)
36 #define VIRTIO_CRYPTO_GET_PARENT_CLASS(obj) \
37 OBJECT_GET_PARENT_CLASS(obj, TYPE_VIRTIO_CRYPTO)
40 typedef struct VirtIOCryptoConf
{
41 CryptoDevBackend
*cryptodev
;
43 /* Supported service mask */
44 uint32_t crypto_services
;
46 /* Detailed algorithms mask */
47 uint32_t cipher_algo_l
;
48 uint32_t cipher_algo_h
;
54 /* Maximum length of cipher key */
55 uint32_t max_cipher_key_len
;
56 /* Maximum length of authenticated key */
57 uint32_t max_auth_key_len
;
58 /* Maximum size of each crypto request's content */
64 typedef struct VirtIOCryptoReq
{
65 VirtQueueElement elem
;
66 /* flags of operation, such as type of algorithm */
68 struct virtio_crypto_inhdr
*in
;
69 struct iovec
*in_iov
; /* Head address of dest iovec */
70 unsigned int in_num
; /* Number of dest iovec */
73 struct VirtIOCrypto
*vcrypto
;
75 CryptoDevBackendSymOpInfo
*sym_op_info
;
79 typedef struct VirtIOCryptoQueue
{
82 struct VirtIOCrypto
*vcrypto
;
85 typedef struct VirtIOCrypto
{
86 VirtIODevice parent_obj
;
89 VirtIOCryptoQueue
*vqs
;
90 VirtIOCryptoConf conf
;
91 CryptoDevBackend
*cryptodev
;
99 uint8_t vhost_started
;
102 #endif /* QEMU_VIRTIO_CRYPTO_H */