| Duy Truong | e833aca | 2013-02-12 13:35:08 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2012, The Linux Foundation. All rights reserved. |
| Mona Hossain | b43e94b | 2012-05-07 08:52:06 -0700 | [diff] [blame] | 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 | |
| 15 | #include <mach/sps.h> |
| 16 | |
| 17 | /* MAX Data xfer block size between BAM and CE */ |
| 18 | #define MAX_CE_BAM_BURST_SIZE 0x40 |
| 19 | #define QCEBAM_BURST_SIZE MAX_CE_BAM_BURST_SIZE |
| 20 | #define MAX_BAM_DESCRIPTORS (0x40 - 1) |
| 21 | |
| 22 | #define GET_VIRT_ADDR(x) \ |
| 23 | ((uint32_t)pce_dev->coh_vmem + \ |
| 24 | ((uint32_t)x - pce_dev->coh_pmem)) |
| 25 | #define GET_PHYS_ADDR(x) \ |
| 26 | (pce_dev->coh_pmem + (x - (uint32_t)pce_dev->coh_vmem)) |
| 27 | |
| 28 | #define CRYPTO_REG_SIZE 4 |
| 29 | #define NUM_OF_CRYPTO_AUTH_IV_REG 16 |
| 30 | #define NUM_OF_CRYPTO_CNTR_IV_REG 4 |
| 31 | #define NUM_OF_CRYPTO_AUTH_BYTE_COUNT_REG 4 |
| 32 | #define CRYPTO_TOTAL_REGISTERS_DUMPED 26 |
| 33 | #define CRYPTO_RESULT_DUMP_SIZE \ |
| 34 | ALIGN((CRYPTO_TOTAL_REGISTERS_DUMPED * CRYPTO_REG_SIZE), \ |
| 35 | QCEBAM_BURST_SIZE) |
| 36 | |
| 37 | /* QCE max number of descriptor in a descriptor list */ |
| 38 | #define QCE_MAX_NUM_DESC 128 |
| 39 | #define SPS_MAX_PKT_SIZE (64 * 1024 - 1) |
| 40 | |
| 41 | /* State of consumer/producer Pipe */ |
| 42 | enum qce_pipe_st_enum { |
| 43 | QCE_PIPE_STATE_IDLE = 0, |
| 44 | QCE_PIPE_STATE_IN_PROG = 1, |
| 45 | QCE_PIPE_STATE_COMP = 2, |
| 46 | QCE_PIPE_STATE_LAST |
| 47 | }; |
| 48 | |
| 49 | struct qce_sps_ep_conn_data { |
| 50 | struct sps_pipe *pipe; |
| 51 | struct sps_connect connect; |
| 52 | struct sps_register_event event; |
| 53 | }; |
| 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 | |
| 64 | struct qce_cmdlist_info { |
| 65 | |
| 66 | uint32_t cmdlist; |
| 67 | struct sps_command_element *crypto_cfg; |
| 68 | struct sps_command_element *encr_seg_cfg; |
| 69 | struct sps_command_element *encr_seg_size; |
| 70 | struct sps_command_element *encr_seg_start; |
| 71 | struct sps_command_element *encr_key; |
| 72 | struct sps_command_element *encr_xts_key; |
| 73 | struct sps_command_element *encr_cntr_iv; |
| 74 | struct sps_command_element *encr_ccm_cntr_iv; |
| 75 | struct sps_command_element *encr_mask; |
| 76 | struct sps_command_element *encr_xts_du_size; |
| 77 | |
| 78 | struct sps_command_element *auth_seg_cfg; |
| 79 | struct sps_command_element *auth_seg_size; |
| 80 | struct sps_command_element *auth_seg_start; |
| 81 | struct sps_command_element *auth_key; |
| 82 | struct sps_command_element *auth_iv; |
| 83 | struct sps_command_element *auth_nonce_info; |
| 84 | struct sps_command_element *auth_bytecount; |
| 85 | struct sps_command_element *seg_size; |
| 86 | struct sps_command_element *go_proc; |
| 87 | uint32_t size; |
| 88 | }; |
| 89 | |
| 90 | struct qce_cmdlistptr_ops { |
| 91 | struct qce_cmdlist_info cipher_aes_128_cbc_ctr; |
| 92 | struct qce_cmdlist_info cipher_aes_256_cbc_ctr; |
| 93 | struct qce_cmdlist_info cipher_aes_128_ecb; |
| 94 | struct qce_cmdlist_info cipher_aes_256_ecb; |
| 95 | struct qce_cmdlist_info cipher_aes_128_xts; |
| 96 | struct qce_cmdlist_info cipher_aes_256_xts; |
| 97 | struct qce_cmdlist_info cipher_des_cbc; |
| 98 | struct qce_cmdlist_info cipher_des_ecb; |
| 99 | struct qce_cmdlist_info cipher_3des_cbc; |
| 100 | struct qce_cmdlist_info cipher_3des_ecb; |
| 101 | struct qce_cmdlist_info auth_sha1; |
| 102 | struct qce_cmdlist_info auth_sha256; |
| 103 | struct qce_cmdlist_info auth_sha1_hmac; |
| 104 | struct qce_cmdlist_info auth_sha256_hmac; |
| 105 | struct qce_cmdlist_info auth_aes_128_cmac; |
| 106 | struct qce_cmdlist_info auth_aes_256_cmac; |
| 107 | struct qce_cmdlist_info aead_sha1_hmac; |
| 108 | struct qce_cmdlist_info aead_aes_128_ccm; |
| 109 | struct qce_cmdlist_info aead_aes_256_ccm; |
| 110 | struct qce_cmdlist_info unlock_all_pipes; |
| 111 | }; |
| 112 | |
| 113 | |
| 114 | /* DM data structure with buffers, commandlists & commmand pointer lists */ |
| 115 | struct ce_sps_data { |
| 116 | |
| 117 | uint32_t bam_irq; |
| 118 | uint32_t bam_mem; |
| 119 | void __iomem *bam_iobase; |
| 120 | |
| 121 | struct qce_sps_ep_conn_data producer; |
| 122 | struct qce_sps_ep_conn_data consumer; |
| 123 | struct sps_event_notify notify; |
| 124 | struct scatterlist *src; |
| 125 | struct scatterlist *dst; |
| 126 | unsigned int pipe_pair_index; |
| 127 | unsigned int src_pipe_index; |
| 128 | unsigned int dest_pipe_index; |
| 129 | uint32_t bam_handle; |
| 130 | |
| 131 | enum qce_pipe_st_enum consumer_state; /* Consumer pipe state */ |
| 132 | enum qce_pipe_st_enum producer_state; /* Producer pipe state */ |
| 133 | |
| 134 | int consumer_status; /* consumer pipe status */ |
| 135 | int producer_status; /* producer pipe status */ |
| 136 | |
| 137 | struct sps_transfer in_transfer; |
| 138 | struct sps_transfer out_transfer; |
| 139 | |
| 140 | int ce_burst_size; |
| 141 | |
| 142 | struct qce_cmdlistptr_ops cmdlistptr; |
| 143 | uint32_t result_dump; |
| 144 | uint32_t ignore_buffer; |
| 145 | struct ce_result_dump_format *result; |
| 146 | uint32_t minor_version; |
| 147 | }; |
| 148 | #endif /* _DRIVERS_CRYPTO_MSM_QCE50_H */ |