Lines Matching +full:- +full:- +full:cc

27 #include "qemu/error-report.h"
28 #include "hw/virtio/vhost-user.h"
29 #include "standard-headers/linux/virtio_crypto.h"
30 #include "system/cryptodev-vhost.h"
31 #include "chardev/char-fe.h"
32 #include "system/cryptodev-vhost-user.h"
40 #define TYPE_CRYPTODEV_BACKEND_VHOST_USER "cryptodev-vhost-user"
64 CryptoDevBackendClient *cc, in cryptodev_vhost_user_get_vhost() argument
70 assert(cc->type == QCRYPTODEV_BACKEND_TYPE_VHOST_USER); in cryptodev_vhost_user_get_vhost()
73 return s->vhost_crypto[queue]; in cryptodev_vhost_user_get_vhost()
82 if (!cryptodev_vhost_user_running(s->vhost_crypto[i])) { in cryptodev_vhost_user_stop()
86 cryptodev_vhost_cleanup(s->vhost_crypto[i]); in cryptodev_vhost_user_stop()
87 s->vhost_crypto[i] = NULL; in cryptodev_vhost_user_stop()
101 if (cryptodev_vhost_user_running(s->vhost_crypto[i])) { in cryptodev_vhost_user_start()
105 options.opaque = &s->vhost_user; in cryptodev_vhost_user_start()
107 options.cc = b->conf.peers.ccs[i]; in cryptodev_vhost_user_start()
108 s->vhost_crypto[i] = cryptodev_vhost_init(&options); in cryptodev_vhost_user_start()
109 if (!s->vhost_crypto[i]) { in cryptodev_vhost_user_start()
116 cryptodev_vhost_get_max_queues(s->vhost_crypto[i]); in cryptodev_vhost_user_start()
129 return -1; in cryptodev_vhost_user_start()
138 if (s->chr_name == NULL) { in cryptodev_vhost_claim_chardev()
144 chr = qemu_chr_find(s->chr_name); in cryptodev_vhost_claim_chardev()
147 "Device '%s' not found", s->chr_name); in cryptodev_vhost_claim_chardev()
158 int queues = b->conf.peers.queues; in cryptodev_vhost_user_event()
167 b->ready = true; in cryptodev_vhost_user_event()
170 b->ready = false; in cryptodev_vhost_user_event()
184 int queues = backend->conf.peers.queues; in cryptodev_vhost_user_init()
188 CryptoDevBackendClient *cc; in cryptodev_vhost_user_init() local
198 s->opened = true; in cryptodev_vhost_user_init()
201 cc = cryptodev_backend_new_client(); in cryptodev_vhost_user_init()
202 cc->info_str = g_strdup_printf("cryptodev-vhost-user%zu to %s ", in cryptodev_vhost_user_init()
203 i, chr->label); in cryptodev_vhost_user_init()
204 cc->queue_index = i; in cryptodev_vhost_user_init()
205 cc->type = QCRYPTODEV_BACKEND_TYPE_VHOST_USER; in cryptodev_vhost_user_init()
207 backend->conf.peers.ccs[i] = cc; in cryptodev_vhost_user_init()
210 if (!qemu_chr_fe_init(&s->chr, chr, errp)) { in cryptodev_vhost_user_init()
216 if (!vhost_user_init(&s->vhost_user, &s->chr, errp)) { in cryptodev_vhost_user_init()
220 qemu_chr_fe_set_handlers(&s->chr, NULL, NULL, in cryptodev_vhost_user_init()
223 backend->conf.crypto_services = in cryptodev_vhost_user_init()
227 backend->conf.cipher_algo_l = 1u << VIRTIO_CRYPTO_CIPHER_AES_CBC; in cryptodev_vhost_user_init()
228 backend->conf.hash_algo = 1u << VIRTIO_CRYPTO_HASH_SHA1; in cryptodev_vhost_user_init()
230 backend->conf.max_size = UINT64_MAX; in cryptodev_vhost_user_init()
231 backend->conf.max_cipher_key_len = VHOST_USER_MAX_CIPHER_KEY_LEN; in cryptodev_vhost_user_init()
232 backend->conf.max_auth_key_len = VHOST_USER_MAX_AUTH_KEY_LEN; in cryptodev_vhost_user_init()
240 CryptoDevBackendClient *cc = in cryptodev_vhost_user_crypto_create_session() local
241 backend->conf.peers.ccs[queue_index]; in cryptodev_vhost_user_crypto_create_session()
246 vhost_crypto = cryptodev_vhost_user_get_vhost(cc, backend, queue_index); in cryptodev_vhost_user_crypto_create_session()
248 struct vhost_dev *dev = &(vhost_crypto->dev); in cryptodev_vhost_user_crypto_create_session()
249 ret = dev->vhost_ops->vhost_crypto_create_session(dev, in cryptodev_vhost_user_crypto_create_session()
253 return -1; in cryptodev_vhost_user_crypto_create_session()
258 return -1; in cryptodev_vhost_user_crypto_create_session()
268 uint32_t op_code = sess_info->op_code; in cryptodev_vhost_user_create_session()
284 error_report("Unsupported opcode :%" PRIu32 "", sess_info->op_code); in cryptodev_vhost_user_create_session()
285 return -VIRTIO_CRYPTO_NOTSUPP; in cryptodev_vhost_user_create_session()
292 status = -VIRTIO_CRYPTO_ERR; in cryptodev_vhost_user_create_session()
294 sess_info->session_id = ret; in cryptodev_vhost_user_create_session()
310 CryptoDevBackendClient *cc = in cryptodev_vhost_user_close_session() local
311 backend->conf.peers.ccs[queue_index]; in cryptodev_vhost_user_close_session()
313 int ret = -1, status; in cryptodev_vhost_user_close_session()
315 vhost_crypto = cryptodev_vhost_user_get_vhost(cc, backend, queue_index); in cryptodev_vhost_user_close_session()
317 struct vhost_dev *dev = &(vhost_crypto->dev); in cryptodev_vhost_user_close_session()
318 ret = dev->vhost_ops->vhost_crypto_close_session(dev, in cryptodev_vhost_user_close_session()
321 status = -VIRTIO_CRYPTO_ERR; in cryptodev_vhost_user_close_session()
326 status = -VIRTIO_CRYPTO_NOTSUPP; in cryptodev_vhost_user_close_session()
341 int queues = backend->conf.peers.queues; in cryptodev_vhost_user_cleanup()
342 CryptoDevBackendClient *cc; in cryptodev_vhost_user_cleanup() local
347 cc = backend->conf.peers.ccs[i]; in cryptodev_vhost_user_cleanup()
348 if (cc) { in cryptodev_vhost_user_cleanup()
349 cryptodev_backend_free_client(cc); in cryptodev_vhost_user_cleanup()
350 backend->conf.peers.ccs[i] = NULL; in cryptodev_vhost_user_cleanup()
354 vhost_user_cleanup(&s->vhost_user); in cryptodev_vhost_user_cleanup()
363 if (s->opened) { in cryptodev_vhost_user_set_chardev()
366 g_free(s->chr_name); in cryptodev_vhost_user_set_chardev()
367 s->chr_name = g_strdup(value); in cryptodev_vhost_user_set_chardev()
376 Chardev *chr = qemu_chr_fe_get_driver(&s->chr); in cryptodev_vhost_user_get_chardev()
378 if (chr && chr->label) { in cryptodev_vhost_user_get_chardev()
379 return g_strdup(chr->label); in cryptodev_vhost_user_get_chardev()
390 qemu_chr_fe_deinit(&s->chr, false); in cryptodev_vhost_user_finalize()
392 g_free(s->chr_name); in cryptodev_vhost_user_finalize()
400 bc->init = cryptodev_vhost_user_init; in cryptodev_vhost_user_class_init()
401 bc->cleanup = cryptodev_vhost_user_cleanup; in cryptodev_vhost_user_class_init()
402 bc->create_session = cryptodev_vhost_user_create_session; in cryptodev_vhost_user_class_init()
403 bc->close_session = cryptodev_vhost_user_close_session; in cryptodev_vhost_user_class_init()
404 bc->do_op = NULL; in cryptodev_vhost_user_class_init()