diff options
author | Andrei Varvara <andrei.varvara@freescale.com> | 2013-05-28 03:37:07 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2013-05-28 03:37:07 -0400 |
commit | 3ebfa92f49a61a00e967112632ad10e92998bb75 (patch) | |
tree | 75f4184d51d5c6e038441c7e972dc94f80d19e97 /drivers/crypto/caam/desc_constr.h | |
parent | d179333b0c6298291c384a0b0ba51ee67d983758 (diff) |
crypto: caam - Add new macros for building extended SEC descriptors (> 64 words)
added all supported math funtion on 8 byte boundary with
immediate flag bit set automatically
added MATH_SRC0_DPOVRD & MATH_SRC1_DPOVRD
The function/defines above are needed for creating descriptors
longer than 64 words
Signed-off-by: Andrei Varvara <andrei.varvara@freescale.com>
Reviewed-by: Phillips Kim-R1AAHA <Kim.Phillips@freescale.com>
Reviewed-by: Fleming Andrew-AFLEMING <AFLEMING@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.h | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/drivers/crypto/caam/desc_constr.h b/drivers/crypto/caam/desc_constr.h index 08c95a192234..fe3bfd1b08ca 100644 --- a/drivers/crypto/caam/desc_constr.h +++ b/drivers/crypto/caam/desc_constr.h | |||
@@ -110,6 +110,26 @@ static inline void append_cmd(u32 *desc, u32 command) | |||
110 | (*desc)++; | 110 | (*desc)++; |
111 | } | 111 | } |
112 | 112 | ||
113 | #define append_u32 append_cmd | ||
114 | |||
115 | static inline void append_u64(u32 *desc, u64 data) | ||
116 | { | ||
117 | u32 *offset = desc_end(desc); | ||
118 | |||
119 | *offset = upper_32_bits(data); | ||
120 | *(++offset) = lower_32_bits(data); | ||
121 | |||
122 | (*desc) += 2; | ||
123 | } | ||
124 | |||
125 | /* Write command without affecting header, and return pointer to next word */ | ||
126 | static inline u32 *write_cmd(u32 *desc, u32 command) | ||
127 | { | ||
128 | *desc = command; | ||
129 | |||
130 | return desc + 1; | ||
131 | } | ||
132 | |||
113 | static inline void append_cmd_ptr(u32 *desc, dma_addr_t ptr, int len, | 133 | static inline void append_cmd_ptr(u32 *desc, dma_addr_t ptr, int len, |
114 | u32 command) | 134 | u32 command) |
115 | { | 135 | { |
@@ -279,7 +299,7 @@ APPEND_CMD_RAW_IMM(load, LOAD, u32); | |||
279 | */ | 299 | */ |
280 | #define APPEND_MATH(op, desc, dest, src_0, src_1, len) \ | 300 | #define APPEND_MATH(op, desc, dest, src_0, src_1, len) \ |
281 | append_cmd(desc, CMD_MATH | MATH_FUN_##op | MATH_DEST_##dest | \ | 301 | append_cmd(desc, CMD_MATH | MATH_FUN_##op | MATH_DEST_##dest | \ |
282 | MATH_SRC0_##src_0 | MATH_SRC1_##src_1 | (u32) (len & MATH_LEN_MASK)); | 302 | MATH_SRC0_##src_0 | MATH_SRC1_##src_1 | (u32)len); |
283 | 303 | ||
284 | #define append_math_add(desc, dest, src0, src1, len) \ | 304 | #define append_math_add(desc, dest, src0, src1, len) \ |
285 | APPEND_MATH(ADD, desc, dest, src0, src1, len) | 305 | APPEND_MATH(ADD, desc, dest, src0, src1, len) |
@@ -327,3 +347,34 @@ do { \ | |||
327 | APPEND_MATH_IMM_u32(LSHIFT, desc, dest, src0, src1, data) | 347 | APPEND_MATH_IMM_u32(LSHIFT, desc, dest, src0, src1, data) |
328 | #define append_math_rshift_imm_u32(desc, dest, src0, src1, data) \ | 348 | #define append_math_rshift_imm_u32(desc, dest, src0, src1, data) \ |
329 | APPEND_MATH_IMM_u32(RSHIFT, desc, dest, src0, src1, data) | 349 | APPEND_MATH_IMM_u32(RSHIFT, desc, dest, src0, src1, data) |
350 | |||
351 | /* Exactly one source is IMM. Data is passed in as u64 value */ | ||
352 | #define APPEND_MATH_IMM_u64(op, desc, dest, src_0, src_1, data) \ | ||
353 | do { \ | ||
354 | u32 upper = (data >> 16) >> 16; \ | ||
355 | APPEND_MATH(op, desc, dest, src_0, src_1, CAAM_CMD_SZ * 2 | \ | ||
356 | (upper ? 0 : MATH_IFB)); \ | ||
357 | if (upper) \ | ||
358 | append_u64(desc, data); \ | ||
359 | else \ | ||
360 | append_u32(desc, data); \ | ||
361 | } while (0) | ||
362 | |||
363 | #define append_math_add_imm_u64(desc, dest, src0, src1, data) \ | ||
364 | APPEND_MATH_IMM_u64(ADD, desc, dest, src0, src1, data) | ||
365 | #define append_math_sub_imm_u64(desc, dest, src0, src1, data) \ | ||
366 | APPEND_MATH_IMM_u64(SUB, desc, dest, src0, src1, data) | ||
367 | #define append_math_add_c_imm_u64(desc, dest, src0, src1, data) \ | ||
368 | APPEND_MATH_IMM_u64(ADDC, desc, dest, src0, src1, data) | ||
369 | #define append_math_sub_b_imm_u64(desc, dest, src0, src1, data) \ | ||
370 | APPEND_MATH_IMM_u64(SUBB, desc, dest, src0, src1, data) | ||
371 | #define append_math_and_imm_u64(desc, dest, src0, src1, data) \ | ||
372 | APPEND_MATH_IMM_u64(AND, desc, dest, src0, src1, data) | ||
373 | #define append_math_or_imm_u64(desc, dest, src0, src1, data) \ | ||
374 | APPEND_MATH_IMM_u64(OR, desc, dest, src0, src1, data) | ||
375 | #define append_math_xor_imm_u64(desc, dest, src0, src1, data) \ | ||
376 | APPEND_MATH_IMM_u64(XOR, desc, dest, src0, src1, data) | ||
377 | #define append_math_lshift_imm_u64(desc, dest, src0, src1, data) \ | ||
378 | APPEND_MATH_IMM_u64(LSHIFT, desc, dest, src0, src1, data) | ||
379 | #define append_math_rshift_imm_u64(desc, dest, src0, src1, data) \ | ||
380 | APPEND_MATH_IMM_u64(RSHIFT, desc, dest, src0, src1, data) | ||