| .. | .. |
|---|
| 1 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
|---|
| 2 | | -/* Copyright (C) 2012-2018 ARM Limited or its affiliates. */ |
|---|
| 2 | +/* Copyright (C) 2012-2019 ARM Limited (or its affiliates). */ |
|---|
| 3 | 3 | |
|---|
| 4 | 4 | #ifndef __CC_HW_QUEUE_DEFS_H__ |
|---|
| 5 | 5 | #define __CC_HW_QUEUE_DEFS_H__ |
|---|
| .. | .. |
|---|
| 17 | 17 | /* Define max. available slots in HW queue */ |
|---|
| 18 | 18 | #define HW_QUEUE_SLOTS_MAX 15 |
|---|
| 19 | 19 | |
|---|
| 20 | | -#define CC_REG_LOW(word, name) \ |
|---|
| 21 | | - (CC_DSCRPTR_QUEUE_WORD ## word ## _ ## name ## _BIT_SHIFT) |
|---|
| 20 | +#define CC_REG_LOW(name) (name ## _BIT_SHIFT) |
|---|
| 21 | +#define CC_REG_HIGH(name) (CC_REG_LOW(name) + name ## _BIT_SIZE - 1) |
|---|
| 22 | +#define CC_GENMASK(name) GENMASK(CC_REG_HIGH(name), CC_REG_LOW(name)) |
|---|
| 22 | 23 | |
|---|
| 23 | | -#define CC_REG_HIGH(word, name) \ |
|---|
| 24 | | - (CC_REG_LOW(word, name) + \ |
|---|
| 25 | | - CC_DSCRPTR_QUEUE_WORD ## word ## _ ## name ## _BIT_SIZE - 1) |
|---|
| 24 | +#define CC_HWQ_GENMASK(word, field) \ |
|---|
| 25 | + CC_GENMASK(CC_DSCRPTR_QUEUE_WORD ## word ## _ ## field) |
|---|
| 26 | 26 | |
|---|
| 27 | | -#define CC_GENMASK(word, name) \ |
|---|
| 28 | | - GENMASK(CC_REG_HIGH(word, name), CC_REG_LOW(word, name)) |
|---|
| 29 | | - |
|---|
| 30 | | -#define WORD0_VALUE CC_GENMASK(0, VALUE) |
|---|
| 31 | | -#define WORD1_DIN_CONST_VALUE CC_GENMASK(1, DIN_CONST_VALUE) |
|---|
| 32 | | -#define WORD1_DIN_DMA_MODE CC_GENMASK(1, DIN_DMA_MODE) |
|---|
| 33 | | -#define WORD1_DIN_SIZE CC_GENMASK(1, DIN_SIZE) |
|---|
| 34 | | -#define WORD1_NOT_LAST CC_GENMASK(1, NOT_LAST) |
|---|
| 35 | | -#define WORD1_NS_BIT CC_GENMASK(1, NS_BIT) |
|---|
| 36 | | -#define WORD2_VALUE CC_GENMASK(2, VALUE) |
|---|
| 37 | | -#define WORD3_DOUT_DMA_MODE CC_GENMASK(3, DOUT_DMA_MODE) |
|---|
| 38 | | -#define WORD3_DOUT_LAST_IND CC_GENMASK(3, DOUT_LAST_IND) |
|---|
| 39 | | -#define WORD3_DOUT_SIZE CC_GENMASK(3, DOUT_SIZE) |
|---|
| 40 | | -#define WORD3_HASH_XOR_BIT CC_GENMASK(3, HASH_XOR_BIT) |
|---|
| 41 | | -#define WORD3_NS_BIT CC_GENMASK(3, NS_BIT) |
|---|
| 42 | | -#define WORD3_QUEUE_LAST_IND CC_GENMASK(3, QUEUE_LAST_IND) |
|---|
| 43 | | -#define WORD4_ACK_NEEDED CC_GENMASK(4, ACK_NEEDED) |
|---|
| 44 | | -#define WORD4_AES_SEL_N_HASH CC_GENMASK(4, AES_SEL_N_HASH) |
|---|
| 45 | | -#define WORD4_BYTES_SWAP CC_GENMASK(4, BYTES_SWAP) |
|---|
| 46 | | -#define WORD4_CIPHER_CONF0 CC_GENMASK(4, CIPHER_CONF0) |
|---|
| 47 | | -#define WORD4_CIPHER_CONF1 CC_GENMASK(4, CIPHER_CONF1) |
|---|
| 48 | | -#define WORD4_CIPHER_CONF2 CC_GENMASK(4, CIPHER_CONF2) |
|---|
| 49 | | -#define WORD4_CIPHER_DO CC_GENMASK(4, CIPHER_DO) |
|---|
| 50 | | -#define WORD4_CIPHER_MODE CC_GENMASK(4, CIPHER_MODE) |
|---|
| 51 | | -#define WORD4_CMAC_SIZE0 CC_GENMASK(4, CMAC_SIZE0) |
|---|
| 52 | | -#define WORD4_DATA_FLOW_MODE CC_GENMASK(4, DATA_FLOW_MODE) |
|---|
| 53 | | -#define WORD4_KEY_SIZE CC_GENMASK(4, KEY_SIZE) |
|---|
| 54 | | -#define WORD4_SETUP_OPERATION CC_GENMASK(4, SETUP_OPERATION) |
|---|
| 55 | | -#define WORD5_DIN_ADDR_HIGH CC_GENMASK(5, DIN_ADDR_HIGH) |
|---|
| 56 | | -#define WORD5_DOUT_ADDR_HIGH CC_GENMASK(5, DOUT_ADDR_HIGH) |
|---|
| 27 | +#define WORD0_VALUE CC_HWQ_GENMASK(0, VALUE) |
|---|
| 28 | +#define WORD0_CPP_CIPHER_MODE CC_HWQ_GENMASK(0, CPP_CIPHER_MODE) |
|---|
| 29 | +#define WORD1_DIN_CONST_VALUE CC_HWQ_GENMASK(1, DIN_CONST_VALUE) |
|---|
| 30 | +#define WORD1_DIN_DMA_MODE CC_HWQ_GENMASK(1, DIN_DMA_MODE) |
|---|
| 31 | +#define WORD1_DIN_SIZE CC_HWQ_GENMASK(1, DIN_SIZE) |
|---|
| 32 | +#define WORD1_NOT_LAST CC_HWQ_GENMASK(1, NOT_LAST) |
|---|
| 33 | +#define WORD1_NS_BIT CC_HWQ_GENMASK(1, NS_BIT) |
|---|
| 34 | +#define WORD1_LOCK_QUEUE CC_HWQ_GENMASK(1, LOCK_QUEUE) |
|---|
| 35 | +#define WORD2_VALUE CC_HWQ_GENMASK(2, VALUE) |
|---|
| 36 | +#define WORD3_DOUT_DMA_MODE CC_HWQ_GENMASK(3, DOUT_DMA_MODE) |
|---|
| 37 | +#define WORD3_DOUT_LAST_IND CC_HWQ_GENMASK(3, DOUT_LAST_IND) |
|---|
| 38 | +#define WORD3_DOUT_SIZE CC_HWQ_GENMASK(3, DOUT_SIZE) |
|---|
| 39 | +#define WORD3_HASH_XOR_BIT CC_HWQ_GENMASK(3, HASH_XOR_BIT) |
|---|
| 40 | +#define WORD3_NS_BIT CC_HWQ_GENMASK(3, NS_BIT) |
|---|
| 41 | +#define WORD3_QUEUE_LAST_IND CC_HWQ_GENMASK(3, QUEUE_LAST_IND) |
|---|
| 42 | +#define WORD4_ACK_NEEDED CC_HWQ_GENMASK(4, ACK_NEEDED) |
|---|
| 43 | +#define WORD4_AES_SEL_N_HASH CC_HWQ_GENMASK(4, AES_SEL_N_HASH) |
|---|
| 44 | +#define WORD4_AES_XOR_CRYPTO_KEY CC_HWQ_GENMASK(4, AES_XOR_CRYPTO_KEY) |
|---|
| 45 | +#define WORD4_BYTES_SWAP CC_HWQ_GENMASK(4, BYTES_SWAP) |
|---|
| 46 | +#define WORD4_CIPHER_CONF0 CC_HWQ_GENMASK(4, CIPHER_CONF0) |
|---|
| 47 | +#define WORD4_CIPHER_CONF1 CC_HWQ_GENMASK(4, CIPHER_CONF1) |
|---|
| 48 | +#define WORD4_CIPHER_CONF2 CC_HWQ_GENMASK(4, CIPHER_CONF2) |
|---|
| 49 | +#define WORD4_CIPHER_DO CC_HWQ_GENMASK(4, CIPHER_DO) |
|---|
| 50 | +#define WORD4_CIPHER_MODE CC_HWQ_GENMASK(4, CIPHER_MODE) |
|---|
| 51 | +#define WORD4_CMAC_SIZE0 CC_HWQ_GENMASK(4, CMAC_SIZE0) |
|---|
| 52 | +#define WORD4_DATA_FLOW_MODE CC_HWQ_GENMASK(4, DATA_FLOW_MODE) |
|---|
| 53 | +#define WORD4_KEY_SIZE CC_HWQ_GENMASK(4, KEY_SIZE) |
|---|
| 54 | +#define WORD4_SETUP_OPERATION CC_HWQ_GENMASK(4, SETUP_OPERATION) |
|---|
| 55 | +#define WORD5_DIN_ADDR_HIGH CC_HWQ_GENMASK(5, DIN_ADDR_HIGH) |
|---|
| 56 | +#define WORD5_DOUT_ADDR_HIGH CC_HWQ_GENMASK(5, DOUT_ADDR_HIGH) |
|---|
| 57 | 57 | |
|---|
| 58 | 58 | /****************************************************************************** |
|---|
| 59 | 59 | * TYPE DEFINITIONS |
|---|
| .. | .. |
|---|
| 107 | 107 | AES_to_AES_to_HASH_and_DOUT = 13, |
|---|
| 108 | 108 | AES_to_AES_to_HASH = 14, |
|---|
| 109 | 109 | AES_to_HASH_and_AES = 15, |
|---|
| 110 | + DIN_SM4_DOUT = 16, |
|---|
| 110 | 111 | DIN_AES_AESMAC = 17, |
|---|
| 111 | 112 | HASH_to_DOUT = 18, |
|---|
| 112 | 113 | /* setup flows */ |
|---|
| .. | .. |
|---|
| 114 | 115 | S_DIN_to_AES2 = 33, |
|---|
| 115 | 116 | S_DIN_to_DES = 34, |
|---|
| 116 | 117 | S_DIN_to_RC4 = 35, |
|---|
| 118 | + S_DIN_to_SM4 = 36, |
|---|
| 117 | 119 | S_DIN_to_HASH = 37, |
|---|
| 118 | 120 | S_AES_to_DOUT = 38, |
|---|
| 119 | 121 | S_AES2_to_DOUT = 39, |
|---|
| 122 | + S_SM4_to_DOUT = 40, |
|---|
| 120 | 123 | S_RC4_to_DOUT = 41, |
|---|
| 121 | 124 | S_DES_to_DOUT = 42, |
|---|
| 122 | 125 | S_HASH_to_DOUT = 43, |
|---|
| .. | .. |
|---|
| 172 | 175 | END_OF_KEYS = S32_MAX, |
|---|
| 173 | 176 | }; |
|---|
| 174 | 177 | |
|---|
| 178 | +#define CC_NUM_HW_KEY_SLOTS 4 |
|---|
| 179 | +#define CC_FIRST_HW_KEY_SLOT 0 |
|---|
| 180 | +#define CC_LAST_HW_KEY_SLOT (CC_FIRST_HW_KEY_SLOT + CC_NUM_HW_KEY_SLOTS - 1) |
|---|
| 181 | + |
|---|
| 182 | +#define CC_NUM_CPP_KEY_SLOTS 8 |
|---|
| 183 | +#define CC_FIRST_CPP_KEY_SLOT 16 |
|---|
| 184 | +#define CC_LAST_CPP_KEY_SLOT (CC_FIRST_CPP_KEY_SLOT + \ |
|---|
| 185 | + CC_NUM_CPP_KEY_SLOTS - 1) |
|---|
| 186 | + |
|---|
| 175 | 187 | enum cc_hw_aes_key_size { |
|---|
| 176 | 188 | AES_128_KEY = 0, |
|---|
| 177 | 189 | AES_192_KEY = 1, |
|---|
| .. | .. |
|---|
| 185 | 197 | HASH_CIPHER_DO_PADDING_RESERVE32 = S32_MAX, |
|---|
| 186 | 198 | }; |
|---|
| 187 | 199 | |
|---|
| 200 | +#define CC_CPP_DIN_ADDR 0xFF00FF00UL |
|---|
| 201 | +#define CC_CPP_DIN_SIZE 0xFF00FFUL |
|---|
| 202 | + |
|---|
| 188 | 203 | /*****************************/ |
|---|
| 189 | 204 | /* Descriptor packing macros */ |
|---|
| 190 | 205 | /*****************************/ |
|---|
| 191 | 206 | |
|---|
| 192 | | -/* |
|---|
| 193 | | - * Init a HW descriptor struct |
|---|
| 194 | | - * @pdesc: pointer HW descriptor struct |
|---|
| 207 | +/** |
|---|
| 208 | + * hw_desc_init() - Init a HW descriptor struct |
|---|
| 209 | + * @pdesc: pointer to HW descriptor struct |
|---|
| 195 | 210 | */ |
|---|
| 196 | 211 | static inline void hw_desc_init(struct cc_hw_desc *pdesc) |
|---|
| 197 | 212 | { |
|---|
| 198 | 213 | memset(pdesc, 0, sizeof(struct cc_hw_desc)); |
|---|
| 199 | 214 | } |
|---|
| 200 | 215 | |
|---|
| 201 | | -/* |
|---|
| 202 | | - * Indicates the end of current HW descriptors flow and release the HW engines. |
|---|
| 216 | +/** |
|---|
| 217 | + * set_queue_last_ind_bit() - Indicate the end of current HW descriptors flow |
|---|
| 218 | + * and release the HW engines. |
|---|
| 203 | 219 | * |
|---|
| 204 | | - * @pdesc: pointer HW descriptor struct |
|---|
| 220 | + * @pdesc: Pointer to HW descriptor struct |
|---|
| 205 | 221 | */ |
|---|
| 206 | 222 | static inline void set_queue_last_ind_bit(struct cc_hw_desc *pdesc) |
|---|
| 207 | 223 | { |
|---|
| 208 | 224 | pdesc->word[3] |= FIELD_PREP(WORD3_QUEUE_LAST_IND, 1); |
|---|
| 209 | 225 | } |
|---|
| 210 | 226 | |
|---|
| 211 | | -/* |
|---|
| 212 | | - * Set the DIN field of a HW descriptors |
|---|
| 227 | +/** |
|---|
| 228 | + * set_din_type() - Set the DIN field of a HW descriptor |
|---|
| 213 | 229 | * |
|---|
| 214 | | - * @pdesc: pointer HW descriptor struct |
|---|
| 215 | | - * @dma_mode: dmaMode The DMA mode: NO_DMA, SRAM, DLLI, MLLI, CONSTANT |
|---|
| 216 | | - * @addr: dinAdr DIN address |
|---|
| 230 | + * @pdesc: Pointer to HW descriptor struct |
|---|
| 231 | + * @dma_mode: The DMA mode: NO_DMA, SRAM, DLLI, MLLI, CONSTANT |
|---|
| 232 | + * @addr: DIN address |
|---|
| 217 | 233 | * @size: Data size in bytes |
|---|
| 218 | 234 | * @axi_sec: AXI secure bit |
|---|
| 219 | 235 | */ |
|---|
| .. | .. |
|---|
| 221 | 237 | enum cc_dma_mode dma_mode, dma_addr_t addr, |
|---|
| 222 | 238 | u32 size, enum cc_axi_sec axi_sec) |
|---|
| 223 | 239 | { |
|---|
| 224 | | - pdesc->word[0] = (u32)addr; |
|---|
| 240 | + pdesc->word[0] = lower_32_bits(addr); |
|---|
| 225 | 241 | #ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT |
|---|
| 226 | | - pdesc->word[5] |= FIELD_PREP(WORD5_DIN_ADDR_HIGH, ((u16)(addr >> 32))); |
|---|
| 242 | + pdesc->word[5] |= FIELD_PREP(WORD5_DIN_ADDR_HIGH, upper_32_bits(addr)); |
|---|
| 227 | 243 | #endif |
|---|
| 228 | 244 | pdesc->word[1] |= FIELD_PREP(WORD1_DIN_DMA_MODE, dma_mode) | |
|---|
| 229 | 245 | FIELD_PREP(WORD1_DIN_SIZE, size) | |
|---|
| 230 | 246 | FIELD_PREP(WORD1_NS_BIT, axi_sec); |
|---|
| 231 | 247 | } |
|---|
| 232 | 248 | |
|---|
| 233 | | -/* |
|---|
| 234 | | - * Set the DIN field of a HW descriptors to NO DMA mode. |
|---|
| 249 | +/** |
|---|
| 250 | + * set_din_no_dma() - Set the DIN field of a HW descriptor to NO DMA mode. |
|---|
| 235 | 251 | * Used for NOP descriptor, register patches and other special modes. |
|---|
| 236 | 252 | * |
|---|
| 237 | | - * @pdesc: pointer HW descriptor struct |
|---|
| 253 | + * @pdesc: Pointer to HW descriptor struct |
|---|
| 238 | 254 | * @addr: DIN address |
|---|
| 239 | 255 | * @size: Data size in bytes |
|---|
| 240 | 256 | */ |
|---|
| .. | .. |
|---|
| 244 | 260 | pdesc->word[1] |= FIELD_PREP(WORD1_DIN_SIZE, size); |
|---|
| 245 | 261 | } |
|---|
| 246 | 262 | |
|---|
| 247 | | -/* |
|---|
| 248 | | - * Set the DIN field of a HW descriptors to SRAM mode. |
|---|
| 249 | | - * Note: No need to check SRAM alignment since host requests do not use SRAM and |
|---|
| 250 | | - * adaptor will enforce alignment check. |
|---|
| 263 | +/** |
|---|
| 264 | + * set_cpp_crypto_key() - Setup the special CPP descriptor |
|---|
| 251 | 265 | * |
|---|
| 252 | | - * @pdesc: pointer HW descriptor struct |
|---|
| 253 | | - * @addr: DIN address |
|---|
| 254 | | - * @size Data size in bytes |
|---|
| 266 | + * @pdesc: Pointer to HW descriptor struct |
|---|
| 267 | + * @slot: Slot number |
|---|
| 255 | 268 | */ |
|---|
| 256 | | -static inline void set_din_sram(struct cc_hw_desc *pdesc, dma_addr_t addr, |
|---|
| 257 | | - u32 size) |
|---|
| 269 | +static inline void set_cpp_crypto_key(struct cc_hw_desc *pdesc, u8 slot) |
|---|
| 258 | 270 | { |
|---|
| 259 | | - pdesc->word[0] = (u32)addr; |
|---|
| 271 | + pdesc->word[0] |= CC_CPP_DIN_ADDR; |
|---|
| 272 | + |
|---|
| 273 | + pdesc->word[1] |= FIELD_PREP(WORD1_DIN_SIZE, CC_CPP_DIN_SIZE); |
|---|
| 274 | + pdesc->word[1] |= FIELD_PREP(WORD1_LOCK_QUEUE, 1); |
|---|
| 275 | + |
|---|
| 276 | + pdesc->word[4] |= FIELD_PREP(WORD4_SETUP_OPERATION, slot); |
|---|
| 277 | +} |
|---|
| 278 | + |
|---|
| 279 | +/** |
|---|
| 280 | + * set_din_sram() - Set the DIN field of a HW descriptor to SRAM mode. |
|---|
| 281 | + * Note: No need to check SRAM alignment since host requests do not use SRAM and |
|---|
| 282 | + * the adaptor will enforce alignment checks. |
|---|
| 283 | + * |
|---|
| 284 | + * @pdesc: Pointer to HW descriptor struct |
|---|
| 285 | + * @addr: DIN address |
|---|
| 286 | + * @size: Data size in bytes |
|---|
| 287 | + */ |
|---|
| 288 | +static inline void set_din_sram(struct cc_hw_desc *pdesc, u32 addr, u32 size) |
|---|
| 289 | +{ |
|---|
| 290 | + pdesc->word[0] = addr; |
|---|
| 260 | 291 | pdesc->word[1] |= FIELD_PREP(WORD1_DIN_SIZE, size) | |
|---|
| 261 | 292 | FIELD_PREP(WORD1_DIN_DMA_MODE, DMA_SRAM); |
|---|
| 262 | 293 | } |
|---|
| 263 | 294 | |
|---|
| 264 | | -/* |
|---|
| 265 | | - * Set the DIN field of a HW descriptors to CONST mode |
|---|
| 295 | +/** |
|---|
| 296 | + * set_din_const() - Set the DIN field of a HW descriptor to CONST mode |
|---|
| 266 | 297 | * |
|---|
| 267 | | - * @pdesc: pointer HW descriptor struct |
|---|
| 298 | + * @pdesc: Pointer to HW descriptor struct |
|---|
| 268 | 299 | * @val: DIN const value |
|---|
| 269 | 300 | * @size: Data size in bytes |
|---|
| 270 | 301 | */ |
|---|
| .. | .. |
|---|
| 276 | 307 | FIELD_PREP(WORD1_DIN_SIZE, size); |
|---|
| 277 | 308 | } |
|---|
| 278 | 309 | |
|---|
| 279 | | -/* |
|---|
| 280 | | - * Set the DIN not last input data indicator |
|---|
| 310 | +/** |
|---|
| 311 | + * set_din_not_last_indication() - Set the DIN not last input data indicator |
|---|
| 281 | 312 | * |
|---|
| 282 | | - * @pdesc: pointer HW descriptor struct |
|---|
| 313 | + * @pdesc: Pointer to HW descriptor struct |
|---|
| 283 | 314 | */ |
|---|
| 284 | 315 | static inline void set_din_not_last_indication(struct cc_hw_desc *pdesc) |
|---|
| 285 | 316 | { |
|---|
| 286 | 317 | pdesc->word[1] |= FIELD_PREP(WORD1_NOT_LAST, 1); |
|---|
| 287 | 318 | } |
|---|
| 288 | 319 | |
|---|
| 289 | | -/* |
|---|
| 290 | | - * Set the DOUT field of a HW descriptors |
|---|
| 320 | +/** |
|---|
| 321 | + * set_dout_type() - Set the DOUT field of a HW descriptor |
|---|
| 291 | 322 | * |
|---|
| 292 | | - * @pdesc: pointer HW descriptor struct |
|---|
| 323 | + * @pdesc: Pointer to HW descriptor struct |
|---|
| 293 | 324 | * @dma_mode: The DMA mode: NO_DMA, SRAM, DLLI, MLLI, CONSTANT |
|---|
| 294 | 325 | * @addr: DOUT address |
|---|
| 295 | 326 | * @size: Data size in bytes |
|---|
| .. | .. |
|---|
| 299 | 330 | enum cc_dma_mode dma_mode, dma_addr_t addr, |
|---|
| 300 | 331 | u32 size, enum cc_axi_sec axi_sec) |
|---|
| 301 | 332 | { |
|---|
| 302 | | - pdesc->word[2] = (u32)addr; |
|---|
| 333 | + pdesc->word[2] = lower_32_bits(addr); |
|---|
| 303 | 334 | #ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT |
|---|
| 304 | | - pdesc->word[5] |= FIELD_PREP(WORD5_DOUT_ADDR_HIGH, ((u16)(addr >> 32))); |
|---|
| 335 | + pdesc->word[5] |= FIELD_PREP(WORD5_DOUT_ADDR_HIGH, upper_32_bits(addr)); |
|---|
| 305 | 336 | #endif |
|---|
| 306 | 337 | pdesc->word[3] |= FIELD_PREP(WORD3_DOUT_DMA_MODE, dma_mode) | |
|---|
| 307 | 338 | FIELD_PREP(WORD3_DOUT_SIZE, size) | |
|---|
| 308 | 339 | FIELD_PREP(WORD3_NS_BIT, axi_sec); |
|---|
| 309 | 340 | } |
|---|
| 310 | 341 | |
|---|
| 311 | | -/* |
|---|
| 312 | | - * Set the DOUT field of a HW descriptors to DLLI type |
|---|
| 342 | +/** |
|---|
| 343 | + * set_dout_dlli() - Set the DOUT field of a HW descriptor to DLLI type |
|---|
| 313 | 344 | * The LAST INDICATION is provided by the user |
|---|
| 314 | 345 | * |
|---|
| 315 | | - * @pdesc pointer HW descriptor struct |
|---|
| 346 | + * @pdesc: Pointer to HW descriptor struct |
|---|
| 316 | 347 | * @addr: DOUT address |
|---|
| 317 | 348 | * @size: Data size in bytes |
|---|
| 318 | | - * @last_ind: The last indication bit |
|---|
| 319 | 349 | * @axi_sec: AXI secure bit |
|---|
| 350 | + * @last_ind: The last indication bit |
|---|
| 320 | 351 | */ |
|---|
| 321 | 352 | static inline void set_dout_dlli(struct cc_hw_desc *pdesc, dma_addr_t addr, |
|---|
| 322 | 353 | u32 size, enum cc_axi_sec axi_sec, |
|---|
| .. | .. |
|---|
| 326 | 357 | pdesc->word[3] |= FIELD_PREP(WORD3_DOUT_LAST_IND, last_ind); |
|---|
| 327 | 358 | } |
|---|
| 328 | 359 | |
|---|
| 329 | | -/* |
|---|
| 330 | | - * Set the DOUT field of a HW descriptors to DLLI type |
|---|
| 360 | +/** |
|---|
| 361 | + * set_dout_mlli() - Set the DOUT field of a HW descriptor to MLLI type |
|---|
| 331 | 362 | * The LAST INDICATION is provided by the user |
|---|
| 332 | 363 | * |
|---|
| 333 | | - * @pdesc: pointer HW descriptor struct |
|---|
| 364 | + * @pdesc: Pointer to HW descriptor struct |
|---|
| 334 | 365 | * @addr: DOUT address |
|---|
| 335 | 366 | * @size: Data size in bytes |
|---|
| 336 | | - * @last_ind: The last indication bit |
|---|
| 337 | 367 | * @axi_sec: AXI secure bit |
|---|
| 368 | + * @last_ind: The last indication bit |
|---|
| 338 | 369 | */ |
|---|
| 339 | | -static inline void set_dout_mlli(struct cc_hw_desc *pdesc, dma_addr_t addr, |
|---|
| 340 | | - u32 size, enum cc_axi_sec axi_sec, |
|---|
| 341 | | - bool last_ind) |
|---|
| 370 | +static inline void set_dout_mlli(struct cc_hw_desc *pdesc, u32 addr, u32 size, |
|---|
| 371 | + enum cc_axi_sec axi_sec, bool last_ind) |
|---|
| 342 | 372 | { |
|---|
| 343 | 373 | set_dout_type(pdesc, DMA_MLLI, addr, size, axi_sec); |
|---|
| 344 | 374 | pdesc->word[3] |= FIELD_PREP(WORD3_DOUT_LAST_IND, last_ind); |
|---|
| 345 | 375 | } |
|---|
| 346 | 376 | |
|---|
| 347 | | -/* |
|---|
| 348 | | - * Set the DOUT field of a HW descriptors to NO DMA mode. |
|---|
| 377 | +/** |
|---|
| 378 | + * set_dout_no_dma() - Set the DOUT field of a HW descriptor to NO DMA mode. |
|---|
| 349 | 379 | * Used for NOP descriptor, register patches and other special modes. |
|---|
| 350 | 380 | * |
|---|
| 351 | | - * @pdesc: pointer HW descriptor struct |
|---|
| 381 | + * @pdesc: pointer to HW descriptor struct |
|---|
| 352 | 382 | * @addr: DOUT address |
|---|
| 353 | 383 | * @size: Data size in bytes |
|---|
| 354 | 384 | * @write_enable: Enables a write operation to a register |
|---|
| .. | .. |
|---|
| 361 | 391 | FIELD_PREP(WORD3_DOUT_LAST_IND, write_enable); |
|---|
| 362 | 392 | } |
|---|
| 363 | 393 | |
|---|
| 364 | | -/* |
|---|
| 365 | | - * Set the word for the XOR operation. |
|---|
| 394 | +/** |
|---|
| 395 | + * set_xor_val() - Set the word for the XOR operation. |
|---|
| 366 | 396 | * |
|---|
| 367 | | - * @pdesc: pointer HW descriptor struct |
|---|
| 368 | | - * @val: xor data value |
|---|
| 397 | + * @pdesc: Pointer to HW descriptor struct |
|---|
| 398 | + * @val: XOR data value |
|---|
| 369 | 399 | */ |
|---|
| 370 | 400 | static inline void set_xor_val(struct cc_hw_desc *pdesc, u32 val) |
|---|
| 371 | 401 | { |
|---|
| 372 | 402 | pdesc->word[2] = val; |
|---|
| 373 | 403 | } |
|---|
| 374 | 404 | |
|---|
| 375 | | -/* |
|---|
| 376 | | - * Sets the XOR indicator bit in the descriptor |
|---|
| 405 | +/** |
|---|
| 406 | + * set_xor_active() - Set the XOR indicator bit in the descriptor |
|---|
| 377 | 407 | * |
|---|
| 378 | | - * @pdesc: pointer HW descriptor struct |
|---|
| 408 | + * @pdesc: Pointer to HW descriptor struct |
|---|
| 379 | 409 | */ |
|---|
| 380 | 410 | static inline void set_xor_active(struct cc_hw_desc *pdesc) |
|---|
| 381 | 411 | { |
|---|
| 382 | 412 | pdesc->word[3] |= FIELD_PREP(WORD3_HASH_XOR_BIT, 1); |
|---|
| 383 | 413 | } |
|---|
| 384 | 414 | |
|---|
| 385 | | -/* |
|---|
| 386 | | - * Select the AES engine instead of HASH engine when setting up combined mode |
|---|
| 387 | | - * with AES XCBC MAC |
|---|
| 415 | +/** |
|---|
| 416 | + * set_aes_not_hash_mode() - Select the AES engine instead of HASH engine when |
|---|
| 417 | + * setting up combined mode with AES XCBC MAC |
|---|
| 388 | 418 | * |
|---|
| 389 | | - * @pdesc: pointer HW descriptor struct |
|---|
| 419 | + * @pdesc: Pointer to HW descriptor struct |
|---|
| 390 | 420 | */ |
|---|
| 391 | 421 | static inline void set_aes_not_hash_mode(struct cc_hw_desc *pdesc) |
|---|
| 392 | 422 | { |
|---|
| 393 | 423 | pdesc->word[4] |= FIELD_PREP(WORD4_AES_SEL_N_HASH, 1); |
|---|
| 394 | 424 | } |
|---|
| 395 | 425 | |
|---|
| 396 | | -/* |
|---|
| 397 | | - * Set the DOUT field of a HW descriptors to SRAM mode |
|---|
| 398 | | - * Note: No need to check SRAM alignment since host requests do not use SRAM and |
|---|
| 399 | | - * adaptor will enforce alignment check. |
|---|
| 426 | +/** |
|---|
| 427 | + * set_aes_xor_crypto_key() - Set aes xor crypto key, which in some scenarios |
|---|
| 428 | + * selects the SM3 engine |
|---|
| 400 | 429 | * |
|---|
| 401 | | - * @pdesc: pointer HW descriptor struct |
|---|
| 430 | + * @pdesc: Pointer to HW descriptor struct |
|---|
| 431 | + */ |
|---|
| 432 | +static inline void set_aes_xor_crypto_key(struct cc_hw_desc *pdesc) |
|---|
| 433 | +{ |
|---|
| 434 | + pdesc->word[4] |= FIELD_PREP(WORD4_AES_XOR_CRYPTO_KEY, 1); |
|---|
| 435 | +} |
|---|
| 436 | + |
|---|
| 437 | +/** |
|---|
| 438 | + * set_dout_sram() - Set the DOUT field of a HW descriptor to SRAM mode |
|---|
| 439 | + * Note: No need to check SRAM alignment since host requests do not use SRAM and |
|---|
| 440 | + * the adaptor will enforce alignment checks. |
|---|
| 441 | + * |
|---|
| 442 | + * @pdesc: Pointer to HW descriptor struct |
|---|
| 402 | 443 | * @addr: DOUT address |
|---|
| 403 | 444 | * @size: Data size in bytes |
|---|
| 404 | 445 | */ |
|---|
| .. | .. |
|---|
| 409 | 450 | FIELD_PREP(WORD3_DOUT_SIZE, size); |
|---|
| 410 | 451 | } |
|---|
| 411 | 452 | |
|---|
| 412 | | -/* |
|---|
| 413 | | - * Sets the data unit size for XEX mode in data_out_addr[15:0] |
|---|
| 453 | +/** |
|---|
| 454 | + * set_xex_data_unit_size() - Set the data unit size for XEX mode in |
|---|
| 455 | + * data_out_addr[15:0] |
|---|
| 414 | 456 | * |
|---|
| 415 | | - * @pdesc: pDesc pointer HW descriptor struct |
|---|
| 416 | | - * @size: data unit size for XEX mode |
|---|
| 457 | + * @pdesc: Pointer to HW descriptor struct |
|---|
| 458 | + * @size: Data unit size for XEX mode |
|---|
| 417 | 459 | */ |
|---|
| 418 | 460 | static inline void set_xex_data_unit_size(struct cc_hw_desc *pdesc, u32 size) |
|---|
| 419 | 461 | { |
|---|
| 420 | 462 | pdesc->word[2] = size; |
|---|
| 421 | 463 | } |
|---|
| 422 | 464 | |
|---|
| 423 | | -/* |
|---|
| 424 | | - * Set the number of rounds for Multi2 in data_out_addr[15:0] |
|---|
| 465 | +/** |
|---|
| 466 | + * set_multi2_num_rounds() - Set the number of rounds for Multi2 in |
|---|
| 467 | + * data_out_addr[15:0] |
|---|
| 425 | 468 | * |
|---|
| 426 | | - * @pdesc: pointer HW descriptor struct |
|---|
| 427 | | - * @num: number of rounds for Multi2 |
|---|
| 469 | + * @pdesc: Pointer to HW descriptor struct |
|---|
| 470 | + * @num: Number of rounds for Multi2 |
|---|
| 428 | 471 | */ |
|---|
| 429 | 472 | static inline void set_multi2_num_rounds(struct cc_hw_desc *pdesc, u32 num) |
|---|
| 430 | 473 | { |
|---|
| 431 | 474 | pdesc->word[2] = num; |
|---|
| 432 | 475 | } |
|---|
| 433 | 476 | |
|---|
| 434 | | -/* |
|---|
| 435 | | - * Set the flow mode. |
|---|
| 477 | +/** |
|---|
| 478 | + * set_flow_mode() - Set the flow mode. |
|---|
| 436 | 479 | * |
|---|
| 437 | | - * @pdesc: pointer HW descriptor struct |
|---|
| 480 | + * @pdesc: Pointer to HW descriptor struct |
|---|
| 438 | 481 | * @mode: Any one of the modes defined in [CC7x-DESC] |
|---|
| 439 | 482 | */ |
|---|
| 440 | 483 | static inline void set_flow_mode(struct cc_hw_desc *pdesc, |
|---|
| .. | .. |
|---|
| 443 | 486 | pdesc->word[4] |= FIELD_PREP(WORD4_DATA_FLOW_MODE, mode); |
|---|
| 444 | 487 | } |
|---|
| 445 | 488 | |
|---|
| 446 | | -/* |
|---|
| 447 | | - * Set the cipher mode. |
|---|
| 489 | +/** |
|---|
| 490 | + * set_cipher_mode() - Set the cipher mode. |
|---|
| 448 | 491 | * |
|---|
| 449 | | - * @pdesc: pointer HW descriptor struct |
|---|
| 450 | | - * @mode: Any one of the modes defined in [CC7x-DESC] |
|---|
| 492 | + * @pdesc: Pointer to HW descriptor struct |
|---|
| 493 | + * @mode: Any one of the modes defined in [CC7x-DESC] |
|---|
| 451 | 494 | */ |
|---|
| 452 | 495 | static inline void set_cipher_mode(struct cc_hw_desc *pdesc, int mode) |
|---|
| 453 | 496 | { |
|---|
| 454 | 497 | pdesc->word[4] |= FIELD_PREP(WORD4_CIPHER_MODE, mode); |
|---|
| 455 | 498 | } |
|---|
| 456 | 499 | |
|---|
| 457 | | -/* |
|---|
| 458 | | - * Set the cipher configuration fields. |
|---|
| 500 | +/** |
|---|
| 501 | + * set_hash_cipher_mode() - Set the cipher mode for hash algorithms. |
|---|
| 459 | 502 | * |
|---|
| 460 | | - * @pdesc: pointer HW descriptor struct |
|---|
| 503 | + * @pdesc: Pointer to HW descriptor struct |
|---|
| 504 | + * @cipher_mode: Any one of the modes defined in [CC7x-DESC] |
|---|
| 505 | + * @hash_mode: specifies which hash is being handled |
|---|
| 506 | + */ |
|---|
| 507 | +static inline void set_hash_cipher_mode(struct cc_hw_desc *pdesc, |
|---|
| 508 | + enum drv_cipher_mode cipher_mode, |
|---|
| 509 | + enum drv_hash_mode hash_mode) |
|---|
| 510 | +{ |
|---|
| 511 | + set_cipher_mode(pdesc, cipher_mode); |
|---|
| 512 | + if (hash_mode == DRV_HASH_SM3) |
|---|
| 513 | + set_aes_xor_crypto_key(pdesc); |
|---|
| 514 | +} |
|---|
| 515 | + |
|---|
| 516 | +/** |
|---|
| 517 | + * set_cipher_config0() - Set the cipher configuration fields. |
|---|
| 518 | + * |
|---|
| 519 | + * @pdesc: Pointer to HW descriptor struct |
|---|
| 461 | 520 | * @mode: Any one of the modes defined in [CC7x-DESC] |
|---|
| 462 | 521 | */ |
|---|
| 463 | 522 | static inline void set_cipher_config0(struct cc_hw_desc *pdesc, int mode) |
|---|
| .. | .. |
|---|
| 465 | 524 | pdesc->word[4] |= FIELD_PREP(WORD4_CIPHER_CONF0, mode); |
|---|
| 466 | 525 | } |
|---|
| 467 | 526 | |
|---|
| 468 | | -/* |
|---|
| 469 | | - * Set the cipher configuration fields. |
|---|
| 527 | +/** |
|---|
| 528 | + * set_cipher_config1() - Set the cipher configuration fields. |
|---|
| 470 | 529 | * |
|---|
| 471 | | - * @pdesc: pointer HW descriptor struct |
|---|
| 472 | | - * @config: Any one of the modes defined in [CC7x-DESC] |
|---|
| 530 | + * @pdesc: Pointer to HW descriptor struct |
|---|
| 531 | + * @config: Padding mode |
|---|
| 473 | 532 | */ |
|---|
| 474 | 533 | static inline void set_cipher_config1(struct cc_hw_desc *pdesc, |
|---|
| 475 | 534 | enum cc_hash_conf_pad config) |
|---|
| .. | .. |
|---|
| 477 | 536 | pdesc->word[4] |= FIELD_PREP(WORD4_CIPHER_CONF1, config); |
|---|
| 478 | 537 | } |
|---|
| 479 | 538 | |
|---|
| 480 | | -/* |
|---|
| 481 | | - * Set HW key configuration fields. |
|---|
| 539 | +/** |
|---|
| 540 | + * set_hw_crypto_key() - Set HW key configuration fields. |
|---|
| 482 | 541 | * |
|---|
| 483 | | - * @pdesc: pointer HW descriptor struct |
|---|
| 542 | + * @pdesc: Pointer to HW descriptor struct |
|---|
| 484 | 543 | * @hw_key: The HW key slot asdefined in enum cc_hw_crypto_key |
|---|
| 485 | 544 | */ |
|---|
| 486 | 545 | static inline void set_hw_crypto_key(struct cc_hw_desc *pdesc, |
|---|
| .. | .. |
|---|
| 492 | 551 | (hw_key >> HW_KEY_SHIFT_CIPHER_CFG2)); |
|---|
| 493 | 552 | } |
|---|
| 494 | 553 | |
|---|
| 495 | | -/* |
|---|
| 496 | | - * Set byte order of all setup-finalize descriptors. |
|---|
| 554 | +/** |
|---|
| 555 | + * set_bytes_swap() - Set byte order of all setup-finalize descriptors. |
|---|
| 497 | 556 | * |
|---|
| 498 | | - * @pdesc: pointer HW descriptor struct |
|---|
| 499 | | - * @config: Any one of the modes defined in [CC7x-DESC] |
|---|
| 557 | + * @pdesc: Pointer to HW descriptor struct |
|---|
| 558 | + * @config: True to enable byte swapping |
|---|
| 500 | 559 | */ |
|---|
| 501 | 560 | static inline void set_bytes_swap(struct cc_hw_desc *pdesc, bool config) |
|---|
| 502 | 561 | { |
|---|
| 503 | 562 | pdesc->word[4] |= FIELD_PREP(WORD4_BYTES_SWAP, config); |
|---|
| 504 | 563 | } |
|---|
| 505 | 564 | |
|---|
| 506 | | -/* |
|---|
| 507 | | - * Set CMAC_SIZE0 mode. |
|---|
| 565 | +/** |
|---|
| 566 | + * set_cmac_size0_mode() - Set CMAC_SIZE0 mode. |
|---|
| 508 | 567 | * |
|---|
| 509 | | - * @pdesc: pointer HW descriptor struct |
|---|
| 568 | + * @pdesc: Pointer to HW descriptor struct |
|---|
| 510 | 569 | */ |
|---|
| 511 | 570 | static inline void set_cmac_size0_mode(struct cc_hw_desc *pdesc) |
|---|
| 512 | 571 | { |
|---|
| 513 | 572 | pdesc->word[4] |= FIELD_PREP(WORD4_CMAC_SIZE0, 1); |
|---|
| 514 | 573 | } |
|---|
| 515 | 574 | |
|---|
| 516 | | -/* |
|---|
| 517 | | - * Set key size descriptor field. |
|---|
| 575 | +/** |
|---|
| 576 | + * set_key_size() - Set key size descriptor field. |
|---|
| 518 | 577 | * |
|---|
| 519 | | - * @pdesc: pointer HW descriptor struct |
|---|
| 520 | | - * @size: key size in bytes (NOT size code) |
|---|
| 578 | + * @pdesc: Pointer to HW descriptor struct |
|---|
| 579 | + * @size: Key size in bytes (NOT size code) |
|---|
| 521 | 580 | */ |
|---|
| 522 | 581 | static inline void set_key_size(struct cc_hw_desc *pdesc, u32 size) |
|---|
| 523 | 582 | { |
|---|
| 524 | 583 | pdesc->word[4] |= FIELD_PREP(WORD4_KEY_SIZE, size); |
|---|
| 525 | 584 | } |
|---|
| 526 | 585 | |
|---|
| 527 | | -/* |
|---|
| 528 | | - * Set AES key size. |
|---|
| 586 | +/** |
|---|
| 587 | + * set_key_size_aes() - Set AES key size. |
|---|
| 529 | 588 | * |
|---|
| 530 | | - * @pdesc: pointer HW descriptor struct |
|---|
| 531 | | - * @size: key size in bytes (NOT size code) |
|---|
| 589 | + * @pdesc: Pointer to HW descriptor struct |
|---|
| 590 | + * @size: Key size in bytes (NOT size code) |
|---|
| 532 | 591 | */ |
|---|
| 533 | 592 | static inline void set_key_size_aes(struct cc_hw_desc *pdesc, u32 size) |
|---|
| 534 | 593 | { |
|---|
| 535 | 594 | set_key_size(pdesc, ((size >> 3) - 2)); |
|---|
| 536 | 595 | } |
|---|
| 537 | 596 | |
|---|
| 538 | | -/* |
|---|
| 539 | | - * Set DES key size. |
|---|
| 597 | +/** |
|---|
| 598 | + * set_key_size_des() - Set DES key size. |
|---|
| 540 | 599 | * |
|---|
| 541 | | - * @pdesc: pointer HW descriptor struct |
|---|
| 542 | | - * @size: key size in bytes (NOT size code) |
|---|
| 600 | + * @pdesc: Pointer to HW descriptor struct |
|---|
| 601 | + * @size: Key size in bytes (NOT size code) |
|---|
| 543 | 602 | */ |
|---|
| 544 | 603 | static inline void set_key_size_des(struct cc_hw_desc *pdesc, u32 size) |
|---|
| 545 | 604 | { |
|---|
| 546 | 605 | set_key_size(pdesc, ((size >> 3) - 1)); |
|---|
| 547 | 606 | } |
|---|
| 548 | 607 | |
|---|
| 549 | | -/* |
|---|
| 550 | | - * Set the descriptor setup mode |
|---|
| 608 | +/** |
|---|
| 609 | + * set_setup_mode() - Set the descriptor setup mode |
|---|
| 551 | 610 | * |
|---|
| 552 | | - * @pdesc: pointer HW descriptor struct |
|---|
| 611 | + * @pdesc: Pointer to HW descriptor struct |
|---|
| 553 | 612 | * @mode: Any one of the setup modes defined in [CC7x-DESC] |
|---|
| 554 | 613 | */ |
|---|
| 555 | 614 | static inline void set_setup_mode(struct cc_hw_desc *pdesc, |
|---|
| .. | .. |
|---|
| 558 | 617 | pdesc->word[4] |= FIELD_PREP(WORD4_SETUP_OPERATION, mode); |
|---|
| 559 | 618 | } |
|---|
| 560 | 619 | |
|---|
| 561 | | -/* |
|---|
| 562 | | - * Set the descriptor cipher DO |
|---|
| 620 | +/** |
|---|
| 621 | + * set_cipher_do() - Set the descriptor cipher DO |
|---|
| 563 | 622 | * |
|---|
| 564 | | - * @pdesc: pointer HW descriptor struct |
|---|
| 623 | + * @pdesc: Pointer to HW descriptor struct |
|---|
| 565 | 624 | * @config: Any one of the cipher do defined in [CC7x-DESC] |
|---|
| 566 | 625 | */ |
|---|
| 567 | 626 | static inline void set_cipher_do(struct cc_hw_desc *pdesc, |
|---|