Merge tag 'pull-loongarch-20241016' of https://gitlab.com/gaosong/qemu into staging
[qemu/armbru.git] / include / hw / virtio / virtio-crypto.h
blob348749f5d5cdf99cfff10cd17d7c2251f5190ad1
1 /*
2 * Virtio crypto Support
4 * Copyright (c) 2016 HUAWEI TECHNOLOGIES CO., LTD.
6 * Authors:
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, ...) \
27 do { \
28 if (DEBUG_VIRTIO_CRYPTO) { \
29 fprintf(stderr, "virtio_crypto: " fmt, ##__VA_ARGS__); \
30 } \
31 } while (0)
34 #define TYPE_VIRTIO_CRYPTO "virtio-crypto-device"
35 OBJECT_DECLARE_SIMPLE_TYPE(VirtIOCrypto, 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;
49 uint32_t hash_algo;
50 uint32_t mac_algo_l;
51 uint32_t mac_algo_h;
52 uint32_t aead_algo;
53 uint32_t akcipher_algo;
55 /* Maximum length of cipher key */
56 uint32_t max_cipher_key_len;
57 /* Maximum length of authenticated key */
58 uint32_t max_auth_key_len;
59 /* Maximum size of each crypto request's content */
60 uint64_t max_size;
61 } VirtIOCryptoConf;
63 struct VirtIOCrypto;
65 typedef struct VirtIOCryptoReq {
66 VirtQueueElement elem;
67 /* flags of operation, such as type of algorithm */
68 uint32_t flags;
69 struct virtio_crypto_inhdr *in;
70 struct iovec *in_iov; /* Head address of dest iovec */
71 unsigned int in_num; /* Number of dest iovec */
72 size_t in_len;
73 VirtQueue *vq;
74 struct VirtIOCrypto *vcrypto;
75 CryptoDevBackendOpInfo op_info;
76 } VirtIOCryptoReq;
78 typedef struct VirtIOCryptoQueue {
79 VirtQueue *dataq;
80 QEMUBH *dataq_bh;
81 struct VirtIOCrypto *vcrypto;
82 } VirtIOCryptoQueue;
84 struct VirtIOCrypto {
85 VirtIODevice parent_obj;
87 VirtQueue *ctrl_vq;
88 VirtIOCryptoQueue *vqs;
89 VirtIOCryptoConf conf;
90 CryptoDevBackend *cryptodev;
92 uint32_t max_queues;
93 uint32_t status;
95 int multiqueue;
96 uint32_t curr_queues;
97 size_t config_size;
98 uint8_t vhost_started;
101 #endif /* QEMU_VIRTIO_CRYPTO_H */