diff options
author | Yuan Kang <Yuan.Kang@freescale.com> | 2012-06-22 20:48:43 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2012-06-27 02:42:04 -0400 |
commit | 6ec47334935ffbc3eccc227ed22ab716be9942f1 (patch) | |
tree | fe882ecd0a2d53b48a20ab1ec16f170049f7319c /drivers/crypto | |
parent | a23d80e0b77314cc863a075796bc2b6d5245ba60 (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.c | 5 | ||||
-rw-r--r-- | drivers/crypto/caam/desc_constr.h | 49 |
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 */ | ||
121 | static 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 | |||
120 | static inline void append_cmd_data(u32 *desc, void *data, int len, | 129 | static 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 | } |
168 | APPEND_CMD_PTR(key, KEY) | 177 | APPEND_CMD_PTR(key, KEY) |
169 | APPEND_CMD_PTR(seq_in_ptr, SEQ_IN_PTR) | ||
170 | APPEND_CMD_PTR(seq_out_ptr, SEQ_OUT_PTR) | ||
171 | APPEND_CMD_PTR(load, LOAD) | 178 | APPEND_CMD_PTR(load, LOAD) |
172 | APPEND_CMD_PTR(store, STORE) | 179 | APPEND_CMD_PTR(store, STORE) |
173 | APPEND_CMD_PTR(fifo_load, FIFO_LOAD) | 180 | APPEND_CMD_PTR(fifo_load, FIFO_LOAD) |
174 | APPEND_CMD_PTR(fifo_store, FIFO_STORE) | 181 | APPEND_CMD_PTR(fifo_store, FIFO_STORE) |
175 | 182 | ||
183 | #define APPEND_SEQ_PTR_INTLEN(cmd, op) \ | ||
184 | static 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 | } | ||
191 | APPEND_SEQ_PTR_INTLEN(in, IN) | ||
192 | APPEND_SEQ_PTR_INTLEN(out, OUT) | ||
193 | |||
176 | #define APPEND_CMD_PTR_TO_IMM(cmd, op) \ | 194 | #define APPEND_CMD_PTR_TO_IMM(cmd, op) \ |
177 | static inline void append_##cmd##_as_imm(u32 *desc, void *data, \ | 195 | static 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, \ | |||
183 | APPEND_CMD_PTR_TO_IMM(load, LOAD); | 201 | APPEND_CMD_PTR_TO_IMM(load, LOAD); |
184 | APPEND_CMD_PTR_TO_IMM(fifo_load, FIFO_LOAD); | 202 | APPEND_CMD_PTR_TO_IMM(fifo_load, FIFO_LOAD); |
185 | 203 | ||
204 | #define APPEND_CMD_PTR_EXTLEN(cmd, op) \ | ||
205 | static 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 | } | ||
211 | APPEND_CMD_PTR_EXTLEN(seq_in_ptr, SEQ_IN_PTR) | ||
212 | APPEND_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) \ | ||
219 | static 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 | } | ||
228 | APPEND_CMD_PTR_LEN(seq_in_ptr, SEQ_IN_PTR, u32) | ||
229 | APPEND_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 |