aboutsummaryrefslogtreecommitdiff
path: root/include/hw/virtio/virtio-crypto.h
blob: 4652c21b206884db4c9cbd53f8299ed1b40c1b79 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
 * Virtio crypto Support
 *
 * Copyright (c) 2016 HUAWEI TECHNOLOGIES CO., LTD.
 *
 * Authors:
 *    Gonglei <arei.gonglei@huawei.com>
 *
 * This work is licensed under the terms of the GNU GPL, version 2 or
 * (at your option) any later version.  See the COPYING file in the
 * top-level directory.
 */

#ifndef _QEMU_VIRTIO_CRYPTO_H
#define _QEMU_VIRTIO_CRYPTO_H

#include "standard-headers/linux/virtio_crypto.h"
#include "hw/virtio/virtio.h"
#include "sysemu/iothread.h"
#include "sysemu/cryptodev.h"


#define DEBUG_VIRTIO_CRYPTO 0

#define DPRINTF(fmt, ...) \
do { \
    if (DEBUG_VIRTIO_CRYPTO) { \
        fprintf(stderr, "virtio_crypto: " fmt, ##__VA_ARGS__); \
    } \
} while (0)


#define TYPE_VIRTIO_CRYPTO "virtio-crypto-device"
#define VIRTIO_CRYPTO(obj) \
        OBJECT_CHECK(VirtIOCrypto, (obj), TYPE_VIRTIO_CRYPTO)
#define VIRTIO_CRYPTO_GET_PARENT_CLASS(obj) \
        OBJECT_GET_PARENT_CLASS(obj, TYPE_VIRTIO_CRYPTO)


typedef struct VirtIOCryptoConf {
    CryptoDevBackend *cryptodev;
} VirtIOCryptoConf;

struct VirtIOCrypto;

typedef struct VirtIOCryptoReq {
    VirtQueueElement elem;
    /* flags of operation, such as type of algorithm */
    uint32_t flags;
    VirtQueue *vq;
    struct VirtIOCrypto *vcrypto;
    union {
        CryptoDevBackendSymOpInfo *sym_op_info;
    } u;
} VirtIOCryptoReq;

typedef struct VirtIOCrypto {
    VirtIODevice parent_obj;

    VirtQueue *ctrl_vq;

    VirtIOCryptoConf conf;
    CryptoDevBackend *cryptodev;

    uint32_t max_queues;
    uint32_t status;

    int multiqueue;
    uint32_t curr_queues;
    size_t config_size;
} VirtIOCrypto;

#endif /* _QEMU_VIRTIO_CRYPTO_H */