aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/crypto
diff options
context:
space:
mode:
authorYuan Kang <Yuan.Kang@freescale.com>2012-06-22 20:48:43 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2012-06-27 02:42:04 -0400
commit6ec47334935ffbc3eccc227ed22ab716be9942f1 (patch)
treefe882ecd0a2d53b48a20ab1ec16f170049f7319c /drivers/crypto
parenta23d80e0b77314cc863a075796bc2b6d5245ba60 (diff)
crypto: caam - support external seq in/out lengths
functions for external storage of seq in/out lengths, i.e., for 32-bit lengths. These type-dependent functions automatically determine whether to store the length internally (embedded in the command header word) or externally (after the address pointer), based on size of the type given. Signed-off-by: Yuan Kang <Yuan.Kang@freescale.com> Signed-off-by: Kim Phillips <kim.phillips@freescale.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto')
-rw-r--r--drivers/crypto/caam/caamalg.c5
-rw-r--r--drivers/crypto/caam/desc_constr.h49
2 files changed, 50 insertions, 4 deletions
diff --git a/drivers/crypto/caam/caamalg.c b/drivers/crypto/caam/caamalg.c
index 5c10dc5c0c51..d0f8df1dcec3 100644
--- a/drivers/crypto/caam/caamalg.c
+++ b/drivers/crypto/caam/caamalg.c
@@ -37,9 +37,10 @@
37 * | ShareDesc Pointer | 37 * | ShareDesc Pointer |
38 * | SEQ_OUT_PTR | 38 * | SEQ_OUT_PTR |
39 * | (output buffer) | 39 * | (output buffer) |
40 * | (output length) |
40 * | SEQ_IN_PTR | 41 * | SEQ_IN_PTR |
41 * | (input buffer) | 42 * | (input buffer) |
42 * | LOAD (to DECO) | 43 * | (input length) |
43 * --------------------- 44 * ---------------------
44 */ 45 */
45 46
@@ -62,7 +63,7 @@
62#define CAAM_MAX_IV_LENGTH 16 63#define CAAM_MAX_IV_LENGTH 16
63 64
64/* length of descriptors text */ 65/* length of descriptors text */
65#define DESC_JOB_IO_LEN (CAAM_CMD_SZ * 3 + CAAM_PTR_SZ * 3) 66#define DESC_JOB_IO_LEN (CAAM_CMD_SZ * 5 + CAAM_PTR_SZ * 3)
66 67
67#define DESC_AEAD_BASE (4 * CAAM_CMD_SZ) 68#define DESC_AEAD_BASE (4 * CAAM_CMD_SZ)
68#define DESC_AEAD_ENC_LEN (DESC_AEAD_BASE + 16 * CAAM_CMD_SZ) 69#define DESC_AEAD_ENC_LEN (DESC_AEAD_BASE + 16 * CAAM_CMD_SZ)
diff --git a/drivers/crypto/caam/desc_constr.h b/drivers/crypto/caam/desc_constr.h
index 8e1056fac681..c85c1f058401 100644
--- a/drivers/crypto/caam/desc_constr.h
+++ b/drivers/crypto/caam/desc_constr.h
@@ -117,6 +117,15 @@ static inline void append_cmd_ptr(u32 *desc, dma_addr_t ptr, int len,
117 append_ptr(desc, ptr); 117 append_ptr(desc, ptr);
118} 118}
119 119
120/* Write length after pointer, rather than inside command */
121static inline void append_cmd_ptr_extlen(u32 *desc, dma_addr_t ptr,
122 unsigned int len, u32 command)
123{
124 append_cmd(desc, command);
125 append_ptr(desc, ptr);
126 append_cmd(desc, len);
127}
128
120static inline void append_cmd_data(u32 *desc, void *data, int len, 129static inline void append_cmd_data(u32 *desc, void *data, int len,
121 u32 command) 130 u32 command)
122{ 131{
@@ -166,13 +175,22 @@ static inline void append_##cmd(u32 *desc, dma_addr_t ptr, unsigned int len, \
166 append_cmd_ptr(desc, ptr, len, CMD_##op | options); \ 175 append_cmd_ptr(desc, ptr, len, CMD_##op | options); \
167} 176}
168APPEND_CMD_PTR(key, KEY) 177APPEND_CMD_PTR(key, KEY)
169APPEND_CMD_PTR(seq_in_ptr, SEQ_IN_PTR)
170APPEND_CMD_PTR(seq_out_ptr, SEQ_OUT_PTR)
171APPEND_CMD_PTR(load, LOAD) 178APPEND_CMD_PTR(load, LOAD)
172APPEND_CMD_PTR(store, STORE) 179APPEND_CMD_PTR(store, STORE)
173APPEND_CMD_PTR(fifo_load, FIFO_LOAD) 180APPEND_CMD_PTR(fifo_load, FIFO_LOAD)
174APPEND_CMD_PTR(fifo_store, FIFO_STORE) 181APPEND_CMD_PTR(fifo_store, FIFO_STORE)
175 182
183#define APPEND_SEQ_PTR_INTLEN(cmd, op) \
184static inline void append_seq_##cmd##_ptr_intlen(u32 *desc, dma_addr_t ptr, \
185 unsigned int len, \
186 u32 options) \
187{ \
188 PRINT_POS; \
189 append_cmd_ptr(desc, ptr, len, CMD_SEQ_##op##_PTR | options); \
190}
191APPEND_SEQ_PTR_INTLEN(in, IN)
192APPEND_SEQ_PTR_INTLEN(out, OUT)
193
176#define APPEND_CMD_PTR_TO_IMM(cmd, op) \ 194#define APPEND_CMD_PTR_TO_IMM(cmd, op) \
177static inline void append_##cmd##_as_imm(u32 *desc, void *data, \ 195static inline void append_##cmd##_as_imm(u32 *desc, void *data, \
178 unsigned int len, u32 options) \ 196 unsigned int len, u32 options) \
@@ -183,6 +201,33 @@ static inline void append_##cmd##_as_imm(u32 *desc, void *data, \
183APPEND_CMD_PTR_TO_IMM(load, LOAD); 201APPEND_CMD_PTR_TO_IMM(load, LOAD);
184APPEND_CMD_PTR_TO_IMM(fifo_load, FIFO_LOAD); 202APPEND_CMD_PTR_TO_IMM(fifo_load, FIFO_LOAD);
185 203
204#define APPEND_CMD_PTR_EXTLEN(cmd, op) \
205static inline void append_##cmd##_extlen(u32 *desc, dma_addr_t ptr, \
206 unsigned int len, u32 options) \
207{ \
208 PRINT_POS; \
209 append_cmd_ptr_extlen(desc, ptr, len, CMD_##op | SQIN_EXT | options); \
210}
211APPEND_CMD_PTR_EXTLEN(seq_in_ptr, SEQ_IN_PTR)
212APPEND_CMD_PTR_EXTLEN(seq_out_ptr, SEQ_OUT_PTR)
213
214/*
215 * Determine whether to store length internally or externally depending on
216 * the size of its type
217 */
218#define APPEND_CMD_PTR_LEN(cmd, op, type) \
219static inline void append_##cmd(u32 *desc, dma_addr_t ptr, \
220 type len, u32 options) \
221{ \
222 PRINT_POS; \
223 if (sizeof(type) > sizeof(u16)) \
224 append_##cmd##_extlen(desc, ptr, len, options); \
225 else \
226 append_##cmd##_intlen(desc, ptr, len, options); \
227}
228APPEND_CMD_PTR_LEN(seq_in_ptr, SEQ_IN_PTR, u32)
229APPEND_CMD_PTR_LEN(seq_out_ptr, SEQ_OUT_PTR, u32)
230
186/* 231/*
187 * 2nd variant for commands whose specified immediate length differs 232 * 2nd variant for commands whose specified immediate length differs
188 * from length of immediate data provided, e.g., split keys 233 * from length of immediate data provided, e.g., split keys