/drivers/crypto/msm/qce50.h

https://gitlab.com/culot/kernel_lge_madai · C Header · 201 lines · 153 code · 32 blank · 16 comment · 0 complexity · d3e3e489fee2248e75618105588cdf6c MD5 · raw file

  1. /* Copyright (c) 2013, The Linux Foundation. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. */
  12. #ifndef _DRIVERS_CRYPTO_MSM_QCE50_H_
  13. #define _DRIVERS_CRYPTO_MSM_QCE50_H_
  14. #include <mach/sps.h>
  15. /* MAX Data xfer block size between BAM and CE */
  16. #define MAX_CE_BAM_BURST_SIZE 0x40
  17. #define QCEBAM_BURST_SIZE MAX_CE_BAM_BURST_SIZE
  18. #define GET_VIRT_ADDR(x) \
  19. ((uint32_t)pce_dev->coh_vmem + \
  20. ((uint32_t)x - pce_dev->coh_pmem))
  21. #define GET_PHYS_ADDR(x) \
  22. (pce_dev->coh_pmem + (x - (uint32_t)pce_dev->coh_vmem))
  23. #define CRYPTO_REG_SIZE 4
  24. #define NUM_OF_CRYPTO_AUTH_IV_REG 16
  25. #define NUM_OF_CRYPTO_CNTR_IV_REG 4
  26. #define NUM_OF_CRYPTO_AUTH_BYTE_COUNT_REG 4
  27. #define CRYPTO_TOTAL_REGISTERS_DUMPED 26
  28. #define CRYPTO_RESULT_DUMP_SIZE \
  29. ALIGN((CRYPTO_TOTAL_REGISTERS_DUMPED * CRYPTO_REG_SIZE), \
  30. QCEBAM_BURST_SIZE)
  31. /* QCE max number of descriptor in a descriptor list */
  32. #define QCE_MAX_NUM_DESC 128
  33. #define SPS_MAX_PKT_SIZE (32 * 1024 - 64)
  34. /* State of consumer/producer Pipe */
  35. enum qce_pipe_st_enum {
  36. QCE_PIPE_STATE_IDLE = 0,
  37. QCE_PIPE_STATE_IN_PROG = 1,
  38. QCE_PIPE_STATE_COMP = 2,
  39. QCE_PIPE_STATE_LAST
  40. };
  41. struct qce_sps_ep_conn_data {
  42. struct sps_pipe *pipe;
  43. struct sps_connect connect;
  44. struct sps_register_event event;
  45. };
  46. /* CE Result DUMP format*/
  47. struct ce_result_dump_format {
  48. uint32_t auth_iv[NUM_OF_CRYPTO_AUTH_IV_REG];
  49. uint32_t auth_byte_count[NUM_OF_CRYPTO_AUTH_BYTE_COUNT_REG];
  50. uint32_t encr_cntr_iv[NUM_OF_CRYPTO_CNTR_IV_REG];
  51. uint32_t status;
  52. uint32_t status2;
  53. };
  54. struct qce_cmdlist_info {
  55. uint32_t cmdlist;
  56. struct sps_command_element *crypto_cfg;
  57. struct sps_command_element *encr_seg_cfg;
  58. struct sps_command_element *encr_seg_size;
  59. struct sps_command_element *encr_seg_start;
  60. struct sps_command_element *encr_key;
  61. struct sps_command_element *encr_xts_key;
  62. struct sps_command_element *encr_cntr_iv;
  63. struct sps_command_element *encr_ccm_cntr_iv;
  64. struct sps_command_element *encr_mask;
  65. struct sps_command_element *encr_xts_du_size;
  66. struct sps_command_element *auth_seg_cfg;
  67. struct sps_command_element *auth_seg_size;
  68. struct sps_command_element *auth_seg_start;
  69. struct sps_command_element *auth_key;
  70. struct sps_command_element *auth_iv;
  71. struct sps_command_element *auth_nonce_info;
  72. struct sps_command_element *auth_bytecount;
  73. struct sps_command_element *seg_size;
  74. struct sps_command_element *go_proc;
  75. uint32_t size;
  76. };
  77. struct qce_cmdlistptr_ops {
  78. struct qce_cmdlist_info cipher_aes_128_cbc_ctr;
  79. struct qce_cmdlist_info cipher_aes_256_cbc_ctr;
  80. struct qce_cmdlist_info cipher_aes_128_ecb;
  81. struct qce_cmdlist_info cipher_aes_256_ecb;
  82. struct qce_cmdlist_info cipher_aes_128_xts;
  83. struct qce_cmdlist_info cipher_aes_256_xts;
  84. struct qce_cmdlist_info cipher_des_cbc;
  85. struct qce_cmdlist_info cipher_des_ecb;
  86. struct qce_cmdlist_info cipher_3des_cbc;
  87. struct qce_cmdlist_info cipher_3des_ecb;
  88. struct qce_cmdlist_info auth_sha1;
  89. struct qce_cmdlist_info auth_sha256;
  90. struct qce_cmdlist_info auth_sha1_hmac;
  91. struct qce_cmdlist_info auth_sha256_hmac;
  92. struct qce_cmdlist_info auth_aes_128_cmac;
  93. struct qce_cmdlist_info auth_aes_256_cmac;
  94. struct qce_cmdlist_info aead_hmac_sha1_cbc_aes_128;
  95. struct qce_cmdlist_info aead_hmac_sha1_cbc_aes_256;
  96. struct qce_cmdlist_info aead_hmac_sha1_cbc_des;
  97. struct qce_cmdlist_info aead_hmac_sha1_cbc_3des;
  98. struct qce_cmdlist_info aead_hmac_sha1_ecb_aes_128;
  99. struct qce_cmdlist_info aead_hmac_sha1_ecb_aes_256;
  100. struct qce_cmdlist_info aead_hmac_sha1_ecb_des;
  101. struct qce_cmdlist_info aead_hmac_sha1_ecb_3des;
  102. struct qce_cmdlist_info aead_aes_128_ccm;
  103. struct qce_cmdlist_info aead_aes_256_ccm;
  104. struct qce_cmdlist_info f8_kasumi;
  105. struct qce_cmdlist_info f8_snow3g;
  106. struct qce_cmdlist_info f9_kasumi;
  107. struct qce_cmdlist_info f9_snow3g;
  108. struct qce_cmdlist_info unlock_all_pipes;
  109. };
  110. struct qce_ce_cfg_reg_setting {
  111. uint32_t crypto_cfg_be;
  112. uint32_t crypto_cfg_le;
  113. uint32_t encr_cfg_aes_cbc_128;
  114. uint32_t encr_cfg_aes_cbc_256;
  115. uint32_t encr_cfg_aes_ecb_128;
  116. uint32_t encr_cfg_aes_ecb_256;
  117. uint32_t encr_cfg_aes_xts_128;
  118. uint32_t encr_cfg_aes_xts_256;
  119. uint32_t encr_cfg_aes_ctr_128;
  120. uint32_t encr_cfg_aes_ctr_256;
  121. uint32_t encr_cfg_aes_ccm_128;
  122. uint32_t encr_cfg_aes_ccm_256;
  123. uint32_t encr_cfg_des_cbc;
  124. uint32_t encr_cfg_des_ecb;
  125. uint32_t encr_cfg_3des_cbc;
  126. uint32_t encr_cfg_3des_ecb;
  127. uint32_t encr_cfg_kasumi;
  128. uint32_t encr_cfg_snow3g;
  129. uint32_t auth_cfg_cmac_128;
  130. uint32_t auth_cfg_cmac_256;
  131. uint32_t auth_cfg_sha1;
  132. uint32_t auth_cfg_sha256;
  133. uint32_t auth_cfg_hmac_sha1;
  134. uint32_t auth_cfg_hmac_sha256;
  135. uint32_t auth_cfg_aes_ccm_128;
  136. uint32_t auth_cfg_aes_ccm_256;
  137. uint32_t auth_cfg_aead_sha1_hmac;
  138. uint32_t auth_cfg_aead_sha256_hmac;
  139. uint32_t auth_cfg_kasumi;
  140. uint32_t auth_cfg_snow3g;
  141. };
  142. /* DM data structure with buffers, commandlists & commmand pointer lists */
  143. struct ce_sps_data {
  144. uint32_t bam_irq;
  145. uint32_t bam_mem;
  146. void __iomem *bam_iobase;
  147. struct qce_sps_ep_conn_data producer;
  148. struct qce_sps_ep_conn_data consumer;
  149. struct sps_event_notify notify;
  150. struct scatterlist *src;
  151. struct scatterlist *dst;
  152. unsigned int pipe_pair_index;
  153. unsigned int src_pipe_index;
  154. unsigned int dest_pipe_index;
  155. uint32_t bam_handle;
  156. enum qce_pipe_st_enum consumer_state; /* Consumer pipe state */
  157. enum qce_pipe_st_enum producer_state; /* Producer pipe state */
  158. int consumer_status; /* consumer pipe status */
  159. int producer_status; /* producer pipe status */
  160. struct sps_transfer in_transfer;
  161. struct sps_transfer out_transfer;
  162. int ce_burst_size;
  163. struct qce_cmdlistptr_ops cmdlistptr;
  164. uint32_t result_dump;
  165. uint32_t ignore_buffer;
  166. struct ce_result_dump_format *result;
  167. uint32_t minor_version;
  168. };
  169. #endif /* _DRIVERS_CRYPTO_MSM_QCE50_H */