/include/hw/virtio/virtio-crypto.h

https://github.com/mstsirkin/qemu · C Header · 102 lines · 64 code · 20 blank · 18 comment · 2 complexity · aca690432cc00166d3eac1ac0ea82128 MD5 · raw file

  1. /*
  2. * Virtio crypto Support
  3. *
  4. * Copyright (c) 2016 HUAWEI TECHNOLOGIES CO., LTD.
  5. *
  6. * Authors:
  7. * Gonglei <arei.gonglei@huawei.com>
  8. *
  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.
  12. */
  13. #ifndef _QEMU_VIRTIO_CRYPTO_H
  14. #define _QEMU_VIRTIO_CRYPTO_H
  15. #include "standard-headers/linux/virtio_crypto.h"
  16. #include "hw/virtio/virtio.h"
  17. #include "sysemu/iothread.h"
  18. #include "sysemu/cryptodev.h"
  19. #define DEBUG_VIRTIO_CRYPTO 0
  20. #define DPRINTF(fmt, ...) \
  21. do { \
  22. if (DEBUG_VIRTIO_CRYPTO) { \
  23. fprintf(stderr, "virtio_crypto: " fmt, ##__VA_ARGS__); \
  24. } \
  25. } while (0)
  26. #define TYPE_VIRTIO_CRYPTO "virtio-crypto-device"
  27. #define VIRTIO_CRYPTO(obj) \
  28. OBJECT_CHECK(VirtIOCrypto, (obj), TYPE_VIRTIO_CRYPTO)
  29. #define VIRTIO_CRYPTO_GET_PARENT_CLASS(obj) \
  30. OBJECT_GET_PARENT_CLASS(obj, TYPE_VIRTIO_CRYPTO)
  31. typedef struct VirtIOCryptoConf {
  32. CryptoDevBackend *cryptodev;
  33. /* Supported service mask */
  34. uint32_t crypto_services;
  35. /* Detailed algorithms mask */
  36. uint32_t cipher_algo_l;
  37. uint32_t cipher_algo_h;
  38. uint32_t hash_algo;
  39. uint32_t mac_algo_l;
  40. uint32_t mac_algo_h;
  41. uint32_t aead_algo;
  42. /* Maximum length of cipher key */
  43. uint32_t max_cipher_key_len;
  44. /* Maximum length of authenticated key */
  45. uint32_t max_auth_key_len;
  46. /* Maximum size of each crypto request's content */
  47. uint64_t max_size;
  48. } VirtIOCryptoConf;
  49. struct VirtIOCrypto;
  50. typedef struct VirtIOCryptoReq {
  51. VirtQueueElement elem;
  52. /* flags of operation, such as type of algorithm */
  53. uint32_t flags;
  54. struct virtio_crypto_inhdr *in;
  55. struct iovec *in_iov; /* Head address of dest iovec */
  56. unsigned int in_num; /* Number of dest iovec */
  57. size_t in_len;
  58. VirtQueue *vq;
  59. struct VirtIOCrypto *vcrypto;
  60. union {
  61. CryptoDevBackendSymOpInfo *sym_op_info;
  62. } u;
  63. } VirtIOCryptoReq;
  64. typedef struct VirtIOCryptoQueue {
  65. VirtQueue *dataq;
  66. QEMUBH *dataq_bh;
  67. struct VirtIOCrypto *vcrypto;
  68. } VirtIOCryptoQueue;
  69. typedef struct VirtIOCrypto {
  70. VirtIODevice parent_obj;
  71. VirtQueue *ctrl_vq;
  72. VirtIOCryptoQueue *vqs;
  73. VirtIOCryptoConf conf;
  74. CryptoDevBackend *cryptodev;
  75. uint32_t max_queues;
  76. uint32_t status;
  77. int multiqueue;
  78. uint32_t curr_queues;
  79. size_t config_size;
  80. uint8_t vhost_started;
  81. } VirtIOCrypto;
  82. #endif /* _QEMU_VIRTIO_CRYPTO_H */