aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/crypto/caam/desc_constr.h
diff options
context:
space:
mode:
authorYuan Kang <Yuan.Kang@freescale.com>2011-07-14 23:21:42 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2011-07-14 23:21:42 -0400
commit1acebad3d8db8d5220b3010c2eb160c625434cf2 (patch)
tree29f21d77d77e06b5f0cc6bb8fa05c848dfd3676f /drivers/crypto/caam/desc_constr.h
parent885e9e2fd3f009de56dd265f4ecd8740e9ad5aaa (diff)
crypto: caam - faster aead implementation
Job descriptors only contain header and seq pointers. Other commands are stored in separate shared descriptors for encrypt, decrypt and givencrypt, stored as arrays in caam_ctx. This requires additional macros to create math commands to calculate assoclen and cryptlen. 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/caam/desc_constr.h')
-rw-r--r--drivers/crypto/caam/desc_constr.h58
1 files changed, 57 insertions, 1 deletions
diff --git a/drivers/crypto/caam/desc_constr.h b/drivers/crypto/caam/desc_constr.h
index 46915800c26f..0991323cf3fd 100644
--- a/drivers/crypto/caam/desc_constr.h
+++ b/drivers/crypto/caam/desc_constr.h
@@ -9,7 +9,7 @@
9#define IMMEDIATE (1 << 23) 9#define IMMEDIATE (1 << 23)
10#define CAAM_CMD_SZ sizeof(u32) 10#define CAAM_CMD_SZ sizeof(u32)
11#define CAAM_PTR_SZ sizeof(dma_addr_t) 11#define CAAM_PTR_SZ sizeof(dma_addr_t)
12#define CAAM_DESC_BYTES_MAX (CAAM_CMD_SZ * 64) 12#define CAAM_DESC_BYTES_MAX (CAAM_CMD_SZ * MAX_CAAM_DESCSIZE)
13 13
14#ifdef DEBUG 14#ifdef DEBUG
15#define PRINT_POS do { printk(KERN_DEBUG "%02d: %s\n", desc_len(desc),\ 15#define PRINT_POS do { printk(KERN_DEBUG "%02d: %s\n", desc_len(desc),\
@@ -18,6 +18,9 @@
18#define PRINT_POS 18#define PRINT_POS
19#endif 19#endif
20 20
21#define SET_OK_PROP_ERRORS (IMMEDIATE | LDST_CLASS_DECO | \
22 LDST_SRCDST_WORD_DECOCTRL | \
23 (LDOFF_CHG_SHARE_OK_PROP << LDST_OFFSET_SHIFT))
21#define DISABLE_AUTO_INFO_FIFO (IMMEDIATE | LDST_CLASS_DECO | \ 24#define DISABLE_AUTO_INFO_FIFO (IMMEDIATE | LDST_CLASS_DECO | \
22 LDST_SRCDST_WORD_DECOCTRL | \ 25 LDST_SRCDST_WORD_DECOCTRL | \
23 (LDOFF_DISABLE_AUTO_NFIFO << LDST_OFFSET_SHIFT)) 26 (LDOFF_DISABLE_AUTO_NFIFO << LDST_OFFSET_SHIFT))
@@ -203,3 +206,56 @@ static inline void append_##cmd##_imm_##type(u32 *desc, type immediate, \
203 append_cmd(desc, immediate); \ 206 append_cmd(desc, immediate); \
204} 207}
205APPEND_CMD_RAW_IMM(load, LOAD, u32); 208APPEND_CMD_RAW_IMM(load, LOAD, u32);
209
210/*
211 * Append math command. Only the last part of destination and source need to
212 * be specified
213 */
214#define APPEND_MATH(op, desc, dest, src_0, src_1, len) \
215append_cmd(desc, CMD_MATH | MATH_FUN_##op | MATH_DEST_##dest | \
216 MATH_SRC0_##src_0 | MATH_SRC1_##src_1 | (u32) (len & MATH_LEN_MASK));
217
218#define append_math_add(desc, dest, src0, src1, len) \
219 APPEND_MATH(ADD, desc, dest, src0, src1, len)
220#define append_math_sub(desc, dest, src0, src1, len) \
221 APPEND_MATH(SUB, desc, dest, src0, src1, len)
222#define append_math_add_c(desc, dest, src0, src1, len) \
223 APPEND_MATH(ADDC, desc, dest, src0, src1, len)
224#define append_math_sub_b(desc, dest, src0, src1, len) \
225 APPEND_MATH(SUBB, desc, dest, src0, src1, len)
226#define append_math_and(desc, dest, src0, src1, len) \
227 APPEND_MATH(AND, desc, dest, src0, src1, len)
228#define append_math_or(desc, dest, src0, src1, len) \
229 APPEND_MATH(OR, desc, dest, src0, src1, len)
230#define append_math_xor(desc, dest, src0, src1, len) \
231 APPEND_MATH(XOR, desc, dest, src0, src1, len)
232#define append_math_lshift(desc, dest, src0, src1, len) \
233 APPEND_MATH(LSHIFT, desc, dest, src0, src1, len)
234#define append_math_rshift(desc, dest, src0, src1, len) \
235 APPEND_MATH(RSHIFT, desc, dest, src0, src1, len)
236
237/* Exactly one source is IMM. Data is passed in as u32 value */
238#define APPEND_MATH_IMM_u32(op, desc, dest, src_0, src_1, data) \
239do { \
240 APPEND_MATH(op, desc, dest, src_0, src_1, CAAM_CMD_SZ); \
241 append_cmd(desc, data); \
242} while (0);
243
244#define append_math_add_imm_u32(desc, dest, src0, src1, data) \
245 APPEND_MATH_IMM_u32(ADD, desc, dest, src0, src1, data)
246#define append_math_sub_imm_u32(desc, dest, src0, src1, data) \
247 APPEND_MATH_IMM_u32(SUB, desc, dest, src0, src1, data)
248#define append_math_add_c_imm_u32(desc, dest, src0, src1, data) \
249 APPEND_MATH_IMM_u32(ADDC, desc, dest, src0, src1, data)
250#define append_math_sub_b_imm_u32(desc, dest, src0, src1, data) \
251 APPEND_MATH_IMM_u32(SUBB, desc, dest, src0, src1, data)
252#define append_math_and_imm_u32(desc, dest, src0, src1, data) \
253 APPEND_MATH_IMM_u32(AND, desc, dest, src0, src1, data)
254#define append_math_or_imm_u32(desc, dest, src0, src1, data) \
255 APPEND_MATH_IMM_u32(OR, desc, dest, src0, src1, data)
256#define append_math_xor_imm_u32(desc, dest, src0, src1, data) \
257 APPEND_MATH_IMM_u32(XOR, desc, dest, src0, src1, data)
258#define append_math_lshift_imm_u32(desc, dest, src0, src1, data) \
259 APPEND_MATH_IMM_u32(LSHIFT, desc, dest, src0, src1, data)
260#define append_math_rshift_imm_u32(desc, dest, src0, src1, data) \
261 APPEND_MATH_IMM_u32(RSHIFT, desc, dest, src0, src1, data)