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"
21 #include "qom/object.h"
24 #define DEBUG_VIRTIO_CRYPTO 0
26 #define DPRINTF(fmt, ...) \
28 if (DEBUG_VIRTIO_CRYPTO) { \
29 fprintf(stderr, "virtio_crypto: " fmt, ##__VA_ARGS__); \
34 #define TYPE_VIRTIO_CRYPTO "virtio-crypto-device"
35 typedef struct VirtIOCrypto VirtIOCrypto
;
36 DECLARE_INSTANCE_CHECKER(VirtIOCrypto
, VIRTIO_CRYPTO
,
38 #define VIRTIO_CRYPTO_GET_PARENT_CLASS(obj) \
39 OBJECT_GET_PARENT_CLASS(obj, TYPE_VIRTIO_CRYPTO)
42 typedef struct VirtIOCryptoConf
{
43 CryptoDevBackend
*cryptodev
;
45 /* Supported service mask */
46 uint32_t crypto_services
;
48 /* Detailed algorithms mask */
49 uint32_t cipher_algo_l
;
50 uint32_t cipher_algo_h
;
56 /* Maximum length of cipher key */
57 uint32_t max_cipher_key_len
;
58 /* Maximum length of authenticated key */
59 uint32_t max_auth_key_len
;
60 /* Maximum size of each crypto request's content */
66 typedef struct VirtIOCryptoReq
{
67 VirtQueueElement elem
;
68 /* flags of operation, such as type of algorithm */
70 struct virtio_crypto_inhdr
*in
;
71 struct iovec
*in_iov
; /* Head address of dest iovec */
72 unsigned int in_num
; /* Number of dest iovec */
75 struct VirtIOCrypto
*vcrypto
;
77 CryptoDevBackendSymOpInfo
*sym_op_info
;
81 typedef struct VirtIOCryptoQueue
{
84 struct VirtIOCrypto
*vcrypto
;
88 VirtIODevice parent_obj
;
91 VirtIOCryptoQueue
*vqs
;
92 VirtIOCryptoConf conf
;
93 CryptoDevBackend
*cryptodev
;
101 uint8_t vhost_started
;
104 #endif /* QEMU_VIRTIO_CRYPTO_H */