s390x: upgrade status of KVM cores to "supported"
[qemu/ar7.git] / include / sysemu / cryptodev-vhost.h
blobfb26b86977e4119786902baf47f337bd9a17bf89
1 /*
2 * QEMU Crypto Device Common Vhost Implement
4 * Copyright (c) 2016 HUAWEI TECHNOLOGIES CO., LTD.
6 * Authors:
7 * Gonglei <arei.gonglei@huawei.com>
8 * Jay Zhou <jianjay.zhou@huawei.com>
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2 of the License, or (at your option) any later version.
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
24 #ifndef CRYPTODEV_VHOST_H
25 #define CRYPTODEV_VHOST_H
27 #include "qemu-common.h"
28 #include "hw/virtio/vhost.h"
29 #include "hw/virtio/vhost-backend.h"
30 #include "chardev/char.h"
32 #include "sysemu/cryptodev.h"
35 typedef struct CryptoDevBackendVhostOptions {
36 VhostBackendType backend_type;
37 void *opaque;
38 int total_queues;
39 CryptoDevBackendClient *cc;
40 } CryptoDevBackendVhostOptions;
42 typedef struct CryptoDevBackendVhost {
43 struct vhost_dev dev;
44 struct vhost_virtqueue vqs[1];
45 int backend;
46 CryptoDevBackendClient *cc;
47 } CryptoDevBackendVhost;
49 /**
50 * cryptodev_vhost_get_max_queues:
51 * @crypto: the cryptodev backend common vhost object
53 * Get the maximum queue number of @crypto.
56 * Returns: the maximum queue number
58 uint64_t
59 cryptodev_vhost_get_max_queues(
60 CryptoDevBackendVhost *crypto);
63 /**
64 * cryptodev_vhost_init:
65 * @options: the common vhost object's option
67 * Creates a new cryptodev backend common vhost object
69 ** The returned object must be released with
70 * cryptodev_vhost_cleanup() when no
71 * longer required
73 * Returns: the cryptodev backend common vhost object
75 struct CryptoDevBackendVhost *
76 cryptodev_vhost_init(
77 CryptoDevBackendVhostOptions *options);
79 /**
80 * cryptodev_vhost_cleanup:
81 * @crypto: the cryptodev backend common vhost object
83 * Clean the resouce associated with @crypto that realizaed
84 * by cryptodev_vhost_init()
87 void cryptodev_vhost_cleanup(
88 CryptoDevBackendVhost *crypto);
90 /**
91 * cryptodev_get_vhost:
92 * @cc: the client object for each queue
93 * @b: the cryptodev backend common vhost object
94 * @queue: the cryptodev backend queue index
96 * Gets a new cryptodev backend common vhost object based on
97 * @b and @queue
99 * Returns: the cryptodev backend common vhost object
101 CryptoDevBackendVhost *
102 cryptodev_get_vhost(CryptoDevBackendClient *cc,
103 CryptoDevBackend *b,
104 uint16_t queue);
106 * cryptodev_vhost_start:
107 * @dev: the virtio crypto object
108 * @total_queues: the total count of queue
110 * Starts the vhost crypto logic
112 * Returns: 0 for success, negative for errors
114 int cryptodev_vhost_start(VirtIODevice *dev, int total_queues);
117 * cryptodev_vhost_stop:
118 * @dev: the virtio crypto object
119 * @total_queues: the total count of queue
121 * Stops the vhost crypto logic
124 void cryptodev_vhost_stop(VirtIODevice *dev, int total_queues);
127 * cryptodev_vhost_virtqueue_mask:
128 * @dev: the virtio crypto object
129 * @queue: the cryptodev backend queue index
130 * @idx: the virtqueue index
131 * @mask: mask or not (true or false)
133 * Mask/unmask events for @idx virtqueue on @dev device
136 void cryptodev_vhost_virtqueue_mask(VirtIODevice *dev,
137 int queue,
138 int idx, bool mask);
141 * cryptodev_vhost_virtqueue_pending:
142 * @dev: the virtio crypto object
143 * @queue: the cryptodev backend queue index
144 * @idx: the virtqueue index
146 * Test and clear event pending status for @idx virtqueue on @dev device.
147 * Should be called after unmask to avoid losing events.
149 * Returns: true for success, false for errors
151 bool cryptodev_vhost_virtqueue_pending(VirtIODevice *dev,
152 int queue, int idx);
154 #endif /* CRYPTODEV_VHOST_H */