Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Yuan Kang and committed by
Herbert Xu
6ec47334 a23d80e0

+50 -4
+3 -2
drivers/crypto/caam/caamalg.c
··· 37 37 * | ShareDesc Pointer | 38 38 * | SEQ_OUT_PTR | 39 39 * | (output buffer) | 40 + * | (output length) | 40 41 * | SEQ_IN_PTR | 41 42 * | (input buffer) | 42 - * | LOAD (to DECO) | 43 + * | (input length) | 43 44 * --------------------- 44 45 */ 45 46 ··· 63 62 #define CAAM_MAX_IV_LENGTH 16 64 63 65 64 /* length of descriptors text */ 66 - #define DESC_JOB_IO_LEN (CAAM_CMD_SZ * 3 + CAAM_PTR_SZ * 3) 65 + #define DESC_JOB_IO_LEN (CAAM_CMD_SZ * 5 + CAAM_PTR_SZ * 3) 67 66 68 67 #define DESC_AEAD_BASE (4 * CAAM_CMD_SZ) 69 68 #define DESC_AEAD_ENC_LEN (DESC_AEAD_BASE + 16 * CAAM_CMD_SZ)
+47 -2
drivers/crypto/caam/desc_constr.h
··· 117 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 129 static inline void append_cmd_data(u32 *desc, void *data, int len, 121 130 u32 command) 122 131 { ··· 175 166 append_cmd_ptr(desc, ptr, len, CMD_##op | options); \ 176 167 } 177 168 APPEND_CMD_PTR(key, KEY) 178 - APPEND_CMD_PTR(seq_in_ptr, SEQ_IN_PTR) 179 - APPEND_CMD_PTR(seq_out_ptr, SEQ_OUT_PTR) 180 169 APPEND_CMD_PTR(load, LOAD) 181 170 APPEND_CMD_PTR(store, STORE) 182 171 APPEND_CMD_PTR(fifo_load, FIFO_LOAD) 183 172 APPEND_CMD_PTR(fifo_store, FIFO_STORE) 173 + 174 + #define APPEND_SEQ_PTR_INTLEN(cmd, op) \ 175 + static inline void append_seq_##cmd##_ptr_intlen(u32 *desc, dma_addr_t ptr, \ 176 + unsigned int len, \ 177 + u32 options) \ 178 + { \ 179 + PRINT_POS; \ 180 + append_cmd_ptr(desc, ptr, len, CMD_SEQ_##op##_PTR | options); \ 181 + } 182 + APPEND_SEQ_PTR_INTLEN(in, IN) 183 + APPEND_SEQ_PTR_INTLEN(out, OUT) 184 184 185 185 #define APPEND_CMD_PTR_TO_IMM(cmd, op) \ 186 186 static inline void append_##cmd##_as_imm(u32 *desc, void *data, \ ··· 200 182 } 201 183 APPEND_CMD_PTR_TO_IMM(load, LOAD); 202 184 APPEND_CMD_PTR_TO_IMM(fifo_load, FIFO_LOAD); 185 + 186 + #define APPEND_CMD_PTR_EXTLEN(cmd, op) \ 187 + static inline void append_##cmd##_extlen(u32 *desc, dma_addr_t ptr, \ 188 + unsigned int len, u32 options) \ 189 + { \ 190 + PRINT_POS; \ 191 + append_cmd_ptr_extlen(desc, ptr, len, CMD_##op | SQIN_EXT | options); \ 192 + } 193 + APPEND_CMD_PTR_EXTLEN(seq_in_ptr, SEQ_IN_PTR) 194 + APPEND_CMD_PTR_EXTLEN(seq_out_ptr, SEQ_OUT_PTR) 195 + 196 + /* 197 + * Determine whether to store length internally or externally depending on 198 + * the size of its type 199 + */ 200 + #define APPEND_CMD_PTR_LEN(cmd, op, type) \ 201 + static inline void append_##cmd(u32 *desc, dma_addr_t ptr, \ 202 + type len, u32 options) \ 203 + { \ 204 + PRINT_POS; \ 205 + if (sizeof(type) > sizeof(u16)) \ 206 + append_##cmd##_extlen(desc, ptr, len, options); \ 207 + else \ 208 + append_##cmd##_intlen(desc, ptr, len, options); \ 209 + } 210 + APPEND_CMD_PTR_LEN(seq_in_ptr, SEQ_IN_PTR, u32) 211 + APPEND_CMD_PTR_LEN(seq_out_ptr, SEQ_OUT_PTR, u32) 203 212 204 213 /* 205 214 * 2nd variant for commands whose specified immediate length differs