PageRenderTime 63ms CodeModel.GetById 25ms RepoModel.GetById 1ms app.codeStats 0ms

/drivers/crypto/msm/qce50.h

https://gitlab.com/webhaikal/SenseiOneplus3
C Header | 240 lines | 193 code | 31 blank | 16 comment | 0 complexity | b2ff7a1ec7f6d8d7e802e41215e796bd MD5 | raw file
  1. /* Copyright (c) 2013-2015, 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 <linux/msm-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. ((uintptr_t)pce_dev->coh_vmem + \
  20. ((uintptr_t)x - (uintptr_t)pce_dev->coh_pmem))
  21. #define GET_PHYS_ADDR(x) \
  22. (phys_addr_t)(((uintptr_t)pce_dev->coh_pmem + \
  23. ((uintptr_t)x - (uintptr_t)pce_dev->coh_vmem)))
  24. #define CRYPTO_REG_SIZE 4
  25. #define NUM_OF_CRYPTO_AUTH_IV_REG 16
  26. #define NUM_OF_CRYPTO_CNTR_IV_REG 4
  27. #define NUM_OF_CRYPTO_AUTH_BYTE_COUNT_REG 4
  28. #define CRYPTO_TOTAL_REGISTERS_DUMPED 26
  29. #define CRYPTO_RESULT_DUMP_SIZE \
  30. ALIGN((CRYPTO_TOTAL_REGISTERS_DUMPED * CRYPTO_REG_SIZE), \
  31. QCEBAM_BURST_SIZE)
  32. /* QCE max number of descriptor in a descriptor list */
  33. #define QCE_MAX_NUM_DESC 128
  34. #define SPS_MAX_PKT_SIZE (32 * 1024 - 64)
  35. /* State of consumer/producer Pipe */
  36. enum qce_pipe_st_enum {
  37. QCE_PIPE_STATE_IDLE = 0,
  38. QCE_PIPE_STATE_IN_PROG = 1,
  39. QCE_PIPE_STATE_COMP = 2,
  40. QCE_PIPE_STATE_LAST
  41. };
  42. enum qce_xfer_type_enum {
  43. QCE_XFER_HASHING,
  44. QCE_XFER_CIPHERING,
  45. QCE_XFER_AEAD,
  46. QCE_XFER_F8,
  47. QCE_XFER_F9,
  48. QCE_XFER_TYPE_LAST
  49. };
  50. struct qce_sps_ep_conn_data {
  51. struct sps_pipe *pipe;
  52. struct sps_connect connect;
  53. struct sps_register_event event;
  54. };
  55. /* CE Result DUMP format*/
  56. struct ce_result_dump_format {
  57. uint32_t auth_iv[NUM_OF_CRYPTO_AUTH_IV_REG];
  58. uint32_t auth_byte_count[NUM_OF_CRYPTO_AUTH_BYTE_COUNT_REG];
  59. uint32_t encr_cntr_iv[NUM_OF_CRYPTO_CNTR_IV_REG];
  60. uint32_t status;
  61. uint32_t status2;
  62. };
  63. struct qce_cmdlist_info {
  64. unsigned long cmdlist;
  65. struct sps_command_element *crypto_cfg;
  66. struct sps_command_element *encr_seg_cfg;
  67. struct sps_command_element *encr_seg_size;
  68. struct sps_command_element *encr_seg_start;
  69. struct sps_command_element *encr_key;
  70. struct sps_command_element *encr_xts_key;
  71. struct sps_command_element *encr_cntr_iv;
  72. struct sps_command_element *encr_ccm_cntr_iv;
  73. struct sps_command_element *encr_mask;
  74. struct sps_command_element *encr_xts_du_size;
  75. struct sps_command_element *auth_seg_cfg;
  76. struct sps_command_element *auth_seg_size;
  77. struct sps_command_element *auth_seg_start;
  78. struct sps_command_element *auth_key;
  79. struct sps_command_element *auth_iv;
  80. struct sps_command_element *auth_nonce_info;
  81. struct sps_command_element *auth_bytecount;
  82. struct sps_command_element *seg_size;
  83. struct sps_command_element *go_proc;
  84. ptrdiff_t size;
  85. };
  86. struct qce_cmdlistptr_ops {
  87. struct qce_cmdlist_info cipher_aes_128_cbc_ctr;
  88. struct qce_cmdlist_info cipher_aes_256_cbc_ctr;
  89. struct qce_cmdlist_info cipher_aes_128_ecb;
  90. struct qce_cmdlist_info cipher_aes_256_ecb;
  91. struct qce_cmdlist_info cipher_aes_128_xts;
  92. struct qce_cmdlist_info cipher_aes_256_xts;
  93. struct qce_cmdlist_info cipher_des_cbc;
  94. struct qce_cmdlist_info cipher_des_ecb;
  95. struct qce_cmdlist_info cipher_3des_cbc;
  96. struct qce_cmdlist_info cipher_3des_ecb;
  97. struct qce_cmdlist_info auth_sha1;
  98. struct qce_cmdlist_info auth_sha256;
  99. struct qce_cmdlist_info auth_sha1_hmac;
  100. struct qce_cmdlist_info auth_sha256_hmac;
  101. struct qce_cmdlist_info auth_aes_128_cmac;
  102. struct qce_cmdlist_info auth_aes_256_cmac;
  103. struct qce_cmdlist_info aead_hmac_sha1_cbc_aes_128;
  104. struct qce_cmdlist_info aead_hmac_sha1_cbc_aes_256;
  105. struct qce_cmdlist_info aead_hmac_sha1_cbc_des;
  106. struct qce_cmdlist_info aead_hmac_sha1_cbc_3des;
  107. struct qce_cmdlist_info aead_hmac_sha256_cbc_aes_128;
  108. struct qce_cmdlist_info aead_hmac_sha256_cbc_aes_256;
  109. struct qce_cmdlist_info aead_hmac_sha256_cbc_des;
  110. struct qce_cmdlist_info aead_hmac_sha256_cbc_3des;
  111. struct qce_cmdlist_info aead_aes_128_ccm;
  112. struct qce_cmdlist_info aead_aes_256_ccm;
  113. struct qce_cmdlist_info cipher_null;
  114. struct qce_cmdlist_info f8_kasumi;
  115. struct qce_cmdlist_info f8_snow3g;
  116. struct qce_cmdlist_info f9_kasumi;
  117. struct qce_cmdlist_info f9_snow3g;
  118. struct qce_cmdlist_info unlock_all_pipes;
  119. };
  120. struct qce_ce_cfg_reg_setting {
  121. uint32_t crypto_cfg_be;
  122. uint32_t crypto_cfg_le;
  123. uint32_t encr_cfg_aes_cbc_128;
  124. uint32_t encr_cfg_aes_cbc_256;
  125. uint32_t encr_cfg_aes_ecb_128;
  126. uint32_t encr_cfg_aes_ecb_256;
  127. uint32_t encr_cfg_aes_xts_128;
  128. uint32_t encr_cfg_aes_xts_256;
  129. uint32_t encr_cfg_aes_ctr_128;
  130. uint32_t encr_cfg_aes_ctr_256;
  131. uint32_t encr_cfg_aes_ccm_128;
  132. uint32_t encr_cfg_aes_ccm_256;
  133. uint32_t encr_cfg_des_cbc;
  134. uint32_t encr_cfg_des_ecb;
  135. uint32_t encr_cfg_3des_cbc;
  136. uint32_t encr_cfg_3des_ecb;
  137. uint32_t encr_cfg_kasumi;
  138. uint32_t encr_cfg_snow3g;
  139. uint32_t auth_cfg_cmac_128;
  140. uint32_t auth_cfg_cmac_256;
  141. uint32_t auth_cfg_sha1;
  142. uint32_t auth_cfg_sha256;
  143. uint32_t auth_cfg_hmac_sha1;
  144. uint32_t auth_cfg_hmac_sha256;
  145. uint32_t auth_cfg_aes_ccm_128;
  146. uint32_t auth_cfg_aes_ccm_256;
  147. uint32_t auth_cfg_aead_sha1_hmac;
  148. uint32_t auth_cfg_aead_sha256_hmac;
  149. uint32_t auth_cfg_kasumi;
  150. uint32_t auth_cfg_snow3g;
  151. };
  152. struct ce_bam_info {
  153. uint32_t bam_irq;
  154. uint32_t bam_mem;
  155. void __iomem *bam_iobase;
  156. uint32_t ce_device;
  157. uint32_t ce_hw_instance;
  158. uint32_t bam_ee;
  159. unsigned int pipe_pair_index;
  160. unsigned int src_pipe_index;
  161. unsigned int dest_pipe_index;
  162. unsigned long bam_handle;
  163. int ce_burst_size;
  164. uint32_t minor_version;
  165. struct qce_sps_ep_conn_data producer;
  166. struct qce_sps_ep_conn_data consumer;
  167. };
  168. /* SPS data structure with buffers, commandlists & commmand pointer lists */
  169. struct ce_sps_data {
  170. enum qce_pipe_st_enum producer_state; /* Producer pipe state */
  171. int consumer_status; /* consumer pipe status */
  172. int producer_status; /* producer pipe status */
  173. struct sps_transfer in_transfer;
  174. struct sps_transfer out_transfer;
  175. struct qce_cmdlistptr_ops cmdlistptr;
  176. uint32_t result_dump; /* reuslt dump virtual address */
  177. uint32_t result_dump_null;
  178. uint32_t result_dump_phy; /* result dump physical address (32 bits) */
  179. uint32_t result_dump_null_phy;
  180. uint32_t ignore_buffer; /* ignore buffer virtual address */
  181. struct ce_result_dump_format *result; /* ponter to result dump */
  182. struct ce_result_dump_format *result_null;
  183. };
  184. struct ce_request_info {
  185. bool in_use;
  186. bool in_prog;
  187. enum qce_xfer_type_enum xfer_type;
  188. struct ce_sps_data ce_sps;
  189. qce_comp_func_ptr_t qce_cb; /* qce callback function pointer */
  190. void *user;
  191. void *areq;
  192. int assoc_nents;
  193. int src_nents;
  194. int dst_nents;
  195. dma_addr_t phy_iv_in;
  196. unsigned char dec_iv[16];
  197. int dir;
  198. enum qce_cipher_mode_enum mode;
  199. dma_addr_t phy_ota_src;
  200. dma_addr_t phy_ota_dst;
  201. unsigned int ota_size;
  202. };
  203. struct qce_driver_stats {
  204. int no_of_timeouts;
  205. int no_of_dummy_reqs;
  206. int current_mode;
  207. int outstanding_reqs;
  208. };
  209. #endif /* _DRIVERS_CRYPTO_MSM_QCE50_H */