aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAndrei Varvara <andrei.varvara@freescale.com>2013-05-28 03:37:07 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2013-05-28 03:37:07 -0400
commit3ebfa92f49a61a00e967112632ad10e92998bb75 (patch)
tree75f4184d51d5c6e038441c7e972dc94f80d19e97 /drivers
parentd179333b0c6298291c384a0b0ba51ee67d983758 (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')
-rw-r--r--drivers/crypto/caam/desc.h4
-rw-r--r--drivers/crypto/caam/desc_constr.h53
2 files changed, 56 insertions, 1 deletions
diff --git a/drivers/crypto/caam/desc.h b/drivers/crypto/caam/desc.h
index 89fa3d045612..7d8b14723465 100644
--- a/drivers/crypto/caam/desc.h
+++ b/drivers/crypto/caam/desc.h
@@ -366,6 +366,7 @@ struct sec4_sg_entry {
366#define FIFOLD_TYPE_LAST2FLUSH1 (0x05 << FIFOLD_TYPE_SHIFT) 366#define FIFOLD_TYPE_LAST2FLUSH1 (0x05 << FIFOLD_TYPE_SHIFT)
367#define FIFOLD_TYPE_LASTBOTH (0x06 << FIFOLD_TYPE_SHIFT) 367#define FIFOLD_TYPE_LASTBOTH (0x06 << FIFOLD_TYPE_SHIFT)
368#define FIFOLD_TYPE_LASTBOTHFL (0x07 << FIFOLD_TYPE_SHIFT) 368#define FIFOLD_TYPE_LASTBOTHFL (0x07 << FIFOLD_TYPE_SHIFT)
369#define FIFOLD_TYPE_NOINFOFIFO (0x0F << FIFOLD_TYPE_SHIFT)
369 370
370#define FIFOLDST_LEN_MASK 0xffff 371#define FIFOLDST_LEN_MASK 0xffff
371#define FIFOLDST_EXT_LEN_MASK 0xffffffff 372#define FIFOLDST_EXT_LEN_MASK 0xffffffff
@@ -1359,6 +1360,7 @@ struct sec4_sg_entry {
1359#define MOVE_DEST_MATH3 (0x07 << MOVE_DEST_SHIFT) 1360#define MOVE_DEST_MATH3 (0x07 << MOVE_DEST_SHIFT)
1360#define MOVE_DEST_CLASS1INFIFO (0x08 << MOVE_DEST_SHIFT) 1361#define MOVE_DEST_CLASS1INFIFO (0x08 << MOVE_DEST_SHIFT)
1361#define MOVE_DEST_CLASS2INFIFO (0x09 << MOVE_DEST_SHIFT) 1362#define MOVE_DEST_CLASS2INFIFO (0x09 << MOVE_DEST_SHIFT)
1363#define MOVE_DEST_INFIFO_NOINFO (0x0a << MOVE_DEST_SHIFT)
1362#define MOVE_DEST_PK_A (0x0c << MOVE_DEST_SHIFT) 1364#define MOVE_DEST_PK_A (0x0c << MOVE_DEST_SHIFT)
1363#define MOVE_DEST_CLASS1KEY (0x0d << MOVE_DEST_SHIFT) 1365#define MOVE_DEST_CLASS1KEY (0x0d << MOVE_DEST_SHIFT)
1364#define MOVE_DEST_CLASS2KEY (0x0e << MOVE_DEST_SHIFT) 1366#define MOVE_DEST_CLASS2KEY (0x0e << MOVE_DEST_SHIFT)
@@ -1411,6 +1413,7 @@ struct sec4_sg_entry {
1411#define MATH_SRC0_REG2 (0x02 << MATH_SRC0_SHIFT) 1413#define MATH_SRC0_REG2 (0x02 << MATH_SRC0_SHIFT)
1412#define MATH_SRC0_REG3 (0x03 << MATH_SRC0_SHIFT) 1414#define MATH_SRC0_REG3 (0x03 << MATH_SRC0_SHIFT)
1413#define MATH_SRC0_IMM (0x04 << MATH_SRC0_SHIFT) 1415#define MATH_SRC0_IMM (0x04 << MATH_SRC0_SHIFT)
1416#define MATH_SRC0_DPOVRD (0x07 << MATH_SRC0_SHIFT)
1414#define MATH_SRC0_SEQINLEN (0x08 << MATH_SRC0_SHIFT) 1417#define MATH_SRC0_SEQINLEN (0x08 << MATH_SRC0_SHIFT)
1415#define MATH_SRC0_SEQOUTLEN (0x09 << MATH_SRC0_SHIFT) 1418#define MATH_SRC0_SEQOUTLEN (0x09 << MATH_SRC0_SHIFT)
1416#define MATH_SRC0_VARSEQINLEN (0x0a << MATH_SRC0_SHIFT) 1419#define MATH_SRC0_VARSEQINLEN (0x0a << MATH_SRC0_SHIFT)
@@ -1425,6 +1428,7 @@ struct sec4_sg_entry {
1425#define MATH_SRC1_REG2 (0x02 << MATH_SRC1_SHIFT) 1428#define MATH_SRC1_REG2 (0x02 << MATH_SRC1_SHIFT)
1426#define MATH_SRC1_REG3 (0x03 << MATH_SRC1_SHIFT) 1429#define MATH_SRC1_REG3 (0x03 << MATH_SRC1_SHIFT)
1427#define MATH_SRC1_IMM (0x04 << MATH_SRC1_SHIFT) 1430#define MATH_SRC1_IMM (0x04 << MATH_SRC1_SHIFT)
1431#define MATH_SRC1_DPOVRD (0x07 << MATH_SRC0_SHIFT)
1428#define MATH_SRC1_INFIFO (0x0a << MATH_SRC1_SHIFT) 1432#define MATH_SRC1_INFIFO (0x0a << MATH_SRC1_SHIFT)
1429#define MATH_SRC1_OUTFIFO (0x0b << MATH_SRC1_SHIFT) 1433#define MATH_SRC1_OUTFIFO (0x0b << MATH_SRC1_SHIFT)
1430#define MATH_SRC1_ONE (0x0c << MATH_SRC1_SHIFT) 1434#define MATH_SRC1_ONE (0x0c << MATH_SRC1_SHIFT)
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
115static 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 */
126static inline u32 *write_cmd(u32 *desc, u32 command)
127{
128 *desc = command;
129
130 return desc + 1;
131}
132
113static inline void append_cmd_ptr(u32 *desc, dma_addr_t ptr, int len, 133static 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) \
281append_cmd(desc, CMD_MATH | MATH_FUN_##op | MATH_DEST_##dest | \ 301append_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) \
353do { \
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)