cc_hw_queue_defs.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* Copyright (C) 2012-2018 ARM Limited or its affiliates. */
  3. #ifndef __CC_HW_QUEUE_DEFS_H__
  4. #define __CC_HW_QUEUE_DEFS_H__
  5. #include <linux/types.h>
  6. #include "cc_kernel_regs.h"
  7. #include <linux/bitfield.h>
  8. /******************************************************************************
  9. * DEFINITIONS
  10. ******************************************************************************/
  11. #define HW_DESC_SIZE_WORDS 6
  12. /* Define max. available slots in HW queue */
  13. #define HW_QUEUE_SLOTS_MAX 15
  14. #define CC_REG_LOW(word, name) \
  15. (CC_DSCRPTR_QUEUE_WORD ## word ## _ ## name ## _BIT_SHIFT)
  16. #define CC_REG_HIGH(word, name) \
  17. (CC_REG_LOW(word, name) + \
  18. CC_DSCRPTR_QUEUE_WORD ## word ## _ ## name ## _BIT_SIZE - 1)
  19. #define CC_GENMASK(word, name) \
  20. GENMASK(CC_REG_HIGH(word, name), CC_REG_LOW(word, name))
  21. #define WORD0_VALUE CC_GENMASK(0, VALUE)
  22. #define WORD1_DIN_CONST_VALUE CC_GENMASK(1, DIN_CONST_VALUE)
  23. #define WORD1_DIN_DMA_MODE CC_GENMASK(1, DIN_DMA_MODE)
  24. #define WORD1_DIN_SIZE CC_GENMASK(1, DIN_SIZE)
  25. #define WORD1_NOT_LAST CC_GENMASK(1, NOT_LAST)
  26. #define WORD1_NS_BIT CC_GENMASK(1, NS_BIT)
  27. #define WORD2_VALUE CC_GENMASK(2, VALUE)
  28. #define WORD3_DOUT_DMA_MODE CC_GENMASK(3, DOUT_DMA_MODE)
  29. #define WORD3_DOUT_LAST_IND CC_GENMASK(3, DOUT_LAST_IND)
  30. #define WORD3_DOUT_SIZE CC_GENMASK(3, DOUT_SIZE)
  31. #define WORD3_HASH_XOR_BIT CC_GENMASK(3, HASH_XOR_BIT)
  32. #define WORD3_NS_BIT CC_GENMASK(3, NS_BIT)
  33. #define WORD3_QUEUE_LAST_IND CC_GENMASK(3, QUEUE_LAST_IND)
  34. #define WORD4_ACK_NEEDED CC_GENMASK(4, ACK_NEEDED)
  35. #define WORD4_AES_SEL_N_HASH CC_GENMASK(4, AES_SEL_N_HASH)
  36. #define WORD4_BYTES_SWAP CC_GENMASK(4, BYTES_SWAP)
  37. #define WORD4_CIPHER_CONF0 CC_GENMASK(4, CIPHER_CONF0)
  38. #define WORD4_CIPHER_CONF1 CC_GENMASK(4, CIPHER_CONF1)
  39. #define WORD4_CIPHER_CONF2 CC_GENMASK(4, CIPHER_CONF2)
  40. #define WORD4_CIPHER_DO CC_GENMASK(4, CIPHER_DO)
  41. #define WORD4_CIPHER_MODE CC_GENMASK(4, CIPHER_MODE)
  42. #define WORD4_CMAC_SIZE0 CC_GENMASK(4, CMAC_SIZE0)
  43. #define WORD4_DATA_FLOW_MODE CC_GENMASK(4, DATA_FLOW_MODE)
  44. #define WORD4_KEY_SIZE CC_GENMASK(4, KEY_SIZE)
  45. #define WORD4_SETUP_OPERATION CC_GENMASK(4, SETUP_OPERATION)
  46. #define WORD5_DIN_ADDR_HIGH CC_GENMASK(5, DIN_ADDR_HIGH)
  47. #define WORD5_DOUT_ADDR_HIGH CC_GENMASK(5, DOUT_ADDR_HIGH)
  48. /******************************************************************************
  49. * TYPE DEFINITIONS
  50. ******************************************************************************/
  51. struct cc_hw_desc {
  52. union {
  53. u32 word[HW_DESC_SIZE_WORDS];
  54. u16 hword[HW_DESC_SIZE_WORDS * 2];
  55. };
  56. };
  57. enum cc_axi_sec {
  58. AXI_SECURE = 0,
  59. AXI_NOT_SECURE = 1
  60. };
  61. enum cc_desc_direction {
  62. DESC_DIRECTION_ILLEGAL = -1,
  63. DESC_DIRECTION_ENCRYPT_ENCRYPT = 0,
  64. DESC_DIRECTION_DECRYPT_DECRYPT = 1,
  65. DESC_DIRECTION_DECRYPT_ENCRYPT = 3,
  66. DESC_DIRECTION_END = S32_MAX,
  67. };
  68. enum cc_dma_mode {
  69. DMA_MODE_NULL = -1,
  70. NO_DMA = 0,
  71. DMA_SRAM = 1,
  72. DMA_DLLI = 2,
  73. DMA_MLLI = 3,
  74. DMA_MODE_END = S32_MAX,
  75. };
  76. enum cc_flow_mode {
  77. FLOW_MODE_NULL = -1,
  78. /* data flows */
  79. BYPASS = 0,
  80. DIN_AES_DOUT = 1,
  81. AES_to_HASH = 2,
  82. AES_and_HASH = 3,
  83. DIN_DES_DOUT = 4,
  84. DES_to_HASH = 5,
  85. DES_and_HASH = 6,
  86. DIN_HASH = 7,
  87. DIN_HASH_and_BYPASS = 8,
  88. AESMAC_and_BYPASS = 9,
  89. AES_to_HASH_and_DOUT = 10,
  90. DIN_RC4_DOUT = 11,
  91. DES_to_HASH_and_DOUT = 12,
  92. AES_to_AES_to_HASH_and_DOUT = 13,
  93. AES_to_AES_to_HASH = 14,
  94. AES_to_HASH_and_AES = 15,
  95. DIN_AES_AESMAC = 17,
  96. HASH_to_DOUT = 18,
  97. /* setup flows */
  98. S_DIN_to_AES = 32,
  99. S_DIN_to_AES2 = 33,
  100. S_DIN_to_DES = 34,
  101. S_DIN_to_RC4 = 35,
  102. S_DIN_to_HASH = 37,
  103. S_AES_to_DOUT = 38,
  104. S_AES2_to_DOUT = 39,
  105. S_RC4_to_DOUT = 41,
  106. S_DES_to_DOUT = 42,
  107. S_HASH_to_DOUT = 43,
  108. SET_FLOW_ID = 44,
  109. FLOW_MODE_END = S32_MAX,
  110. };
  111. enum cc_setup_op {
  112. SETUP_LOAD_NOP = 0,
  113. SETUP_LOAD_STATE0 = 1,
  114. SETUP_LOAD_STATE1 = 2,
  115. SETUP_LOAD_STATE2 = 3,
  116. SETUP_LOAD_KEY0 = 4,
  117. SETUP_LOAD_XEX_KEY = 5,
  118. SETUP_WRITE_STATE0 = 8,
  119. SETUP_WRITE_STATE1 = 9,
  120. SETUP_WRITE_STATE2 = 10,
  121. SETUP_WRITE_STATE3 = 11,
  122. SETUP_OP_END = S32_MAX,
  123. };
  124. enum cc_hash_conf_pad {
  125. HASH_PADDING_DISABLED = 0,
  126. HASH_PADDING_ENABLED = 1,
  127. HASH_DIGEST_RESULT_LITTLE_ENDIAN = 2,
  128. HASH_CONFIG1_PADDING_RESERVE32 = S32_MAX,
  129. };
  130. enum cc_aes_mac_selector {
  131. AES_SK = 1,
  132. AES_CMAC_INIT = 2,
  133. AES_CMAC_SIZE0 = 3,
  134. AES_MAC_END = S32_MAX,
  135. };
  136. #define HW_KEY_MASK_CIPHER_DO 0x3
  137. #define HW_KEY_SHIFT_CIPHER_CFG2 2
  138. /* HwCryptoKey[1:0] is mapped to cipher_do[1:0] */
  139. /* HwCryptoKey[2:3] is mapped to cipher_config2[1:0] */
  140. enum cc_hw_crypto_key {
  141. USER_KEY = 0, /* 0x0000 */
  142. ROOT_KEY = 1, /* 0x0001 */
  143. PROVISIONING_KEY = 2, /* 0x0010 */ /* ==KCP */
  144. SESSION_KEY = 3, /* 0x0011 */
  145. RESERVED_KEY = 4, /* NA */
  146. PLATFORM_KEY = 5, /* 0x0101 */
  147. CUSTOMER_KEY = 6, /* 0x0110 */
  148. KFDE0_KEY = 7, /* 0x0111 */
  149. KFDE1_KEY = 9, /* 0x1001 */
  150. KFDE2_KEY = 10, /* 0x1010 */
  151. KFDE3_KEY = 11, /* 0x1011 */
  152. END_OF_KEYS = S32_MAX,
  153. };
  154. enum cc_hw_aes_key_size {
  155. AES_128_KEY = 0,
  156. AES_192_KEY = 1,
  157. AES_256_KEY = 2,
  158. END_OF_AES_KEYS = S32_MAX,
  159. };
  160. enum cc_hash_cipher_pad {
  161. DO_NOT_PAD = 0,
  162. DO_PAD = 1,
  163. HASH_CIPHER_DO_PADDING_RESERVE32 = S32_MAX,
  164. };
  165. /*****************************/
  166. /* Descriptor packing macros */
  167. /*****************************/
  168. /*
  169. * Init a HW descriptor struct
  170. * @pdesc: pointer HW descriptor struct
  171. */
  172. static inline void hw_desc_init(struct cc_hw_desc *pdesc)
  173. {
  174. memset(pdesc, 0, sizeof(struct cc_hw_desc));
  175. }
  176. /*
  177. * Indicates the end of current HW descriptors flow and release the HW engines.
  178. *
  179. * @pdesc: pointer HW descriptor struct
  180. */
  181. static inline void set_queue_last_ind_bit(struct cc_hw_desc *pdesc)
  182. {
  183. pdesc->word[3] |= FIELD_PREP(WORD3_QUEUE_LAST_IND, 1);
  184. }
  185. /*
  186. * Set the DIN field of a HW descriptors
  187. *
  188. * @pdesc: pointer HW descriptor struct
  189. * @dma_mode: dmaMode The DMA mode: NO_DMA, SRAM, DLLI, MLLI, CONSTANT
  190. * @addr: dinAdr DIN address
  191. * @size: Data size in bytes
  192. * @axi_sec: AXI secure bit
  193. */
  194. static inline void set_din_type(struct cc_hw_desc *pdesc,
  195. enum cc_dma_mode dma_mode, dma_addr_t addr,
  196. u32 size, enum cc_axi_sec axi_sec)
  197. {
  198. pdesc->word[0] = (u32)addr;
  199. #ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT
  200. pdesc->word[5] |= FIELD_PREP(WORD5_DIN_ADDR_HIGH, ((u16)(addr >> 32)));
  201. #endif
  202. pdesc->word[1] |= FIELD_PREP(WORD1_DIN_DMA_MODE, dma_mode) |
  203. FIELD_PREP(WORD1_DIN_SIZE, size) |
  204. FIELD_PREP(WORD1_NS_BIT, axi_sec);
  205. }
  206. /*
  207. * Set the DIN field of a HW descriptors to NO DMA mode.
  208. * Used for NOP descriptor, register patches and other special modes.
  209. *
  210. * @pdesc: pointer HW descriptor struct
  211. * @addr: DIN address
  212. * @size: Data size in bytes
  213. */
  214. static inline void set_din_no_dma(struct cc_hw_desc *pdesc, u32 addr, u32 size)
  215. {
  216. pdesc->word[0] = addr;
  217. pdesc->word[1] |= FIELD_PREP(WORD1_DIN_SIZE, size);
  218. }
  219. /*
  220. * Set the DIN field of a HW descriptors to SRAM mode.
  221. * Note: No need to check SRAM alignment since host requests do not use SRAM and
  222. * adaptor will enforce alignment check.
  223. *
  224. * @pdesc: pointer HW descriptor struct
  225. * @addr: DIN address
  226. * @size Data size in bytes
  227. */
  228. static inline void set_din_sram(struct cc_hw_desc *pdesc, dma_addr_t addr,
  229. u32 size)
  230. {
  231. pdesc->word[0] = (u32)addr;
  232. pdesc->word[1] |= FIELD_PREP(WORD1_DIN_SIZE, size) |
  233. FIELD_PREP(WORD1_DIN_DMA_MODE, DMA_SRAM);
  234. }
  235. /*
  236. * Set the DIN field of a HW descriptors to CONST mode
  237. *
  238. * @pdesc: pointer HW descriptor struct
  239. * @val: DIN const value
  240. * @size: Data size in bytes
  241. */
  242. static inline void set_din_const(struct cc_hw_desc *pdesc, u32 val, u32 size)
  243. {
  244. pdesc->word[0] = val;
  245. pdesc->word[1] |= FIELD_PREP(WORD1_DIN_CONST_VALUE, 1) |
  246. FIELD_PREP(WORD1_DIN_DMA_MODE, DMA_SRAM) |
  247. FIELD_PREP(WORD1_DIN_SIZE, size);
  248. }
  249. /*
  250. * Set the DIN not last input data indicator
  251. *
  252. * @pdesc: pointer HW descriptor struct
  253. */
  254. static inline void set_din_not_last_indication(struct cc_hw_desc *pdesc)
  255. {
  256. pdesc->word[1] |= FIELD_PREP(WORD1_NOT_LAST, 1);
  257. }
  258. /*
  259. * Set the DOUT field of a HW descriptors
  260. *
  261. * @pdesc: pointer HW descriptor struct
  262. * @dma_mode: The DMA mode: NO_DMA, SRAM, DLLI, MLLI, CONSTANT
  263. * @addr: DOUT address
  264. * @size: Data size in bytes
  265. * @axi_sec: AXI secure bit
  266. */
  267. static inline void set_dout_type(struct cc_hw_desc *pdesc,
  268. enum cc_dma_mode dma_mode, dma_addr_t addr,
  269. u32 size, enum cc_axi_sec axi_sec)
  270. {
  271. pdesc->word[2] = (u32)addr;
  272. #ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT
  273. pdesc->word[5] |= FIELD_PREP(WORD5_DOUT_ADDR_HIGH, ((u16)(addr >> 32)));
  274. #endif
  275. pdesc->word[3] |= FIELD_PREP(WORD3_DOUT_DMA_MODE, dma_mode) |
  276. FIELD_PREP(WORD3_DOUT_SIZE, size) |
  277. FIELD_PREP(WORD3_NS_BIT, axi_sec);
  278. }
  279. /*
  280. * Set the DOUT field of a HW descriptors to DLLI type
  281. * The LAST INDICATION is provided by the user
  282. *
  283. * @pdesc pointer HW descriptor struct
  284. * @addr: DOUT address
  285. * @size: Data size in bytes
  286. * @last_ind: The last indication bit
  287. * @axi_sec: AXI secure bit
  288. */
  289. static inline void set_dout_dlli(struct cc_hw_desc *pdesc, dma_addr_t addr,
  290. u32 size, enum cc_axi_sec axi_sec,
  291. u32 last_ind)
  292. {
  293. set_dout_type(pdesc, DMA_DLLI, addr, size, axi_sec);
  294. pdesc->word[3] |= FIELD_PREP(WORD3_DOUT_LAST_IND, last_ind);
  295. }
  296. /*
  297. * Set the DOUT field of a HW descriptors to DLLI type
  298. * The LAST INDICATION is provided by the user
  299. *
  300. * @pdesc: pointer HW descriptor struct
  301. * @addr: DOUT address
  302. * @size: Data size in bytes
  303. * @last_ind: The last indication bit
  304. * @axi_sec: AXI secure bit
  305. */
  306. static inline void set_dout_mlli(struct cc_hw_desc *pdesc, dma_addr_t addr,
  307. u32 size, enum cc_axi_sec axi_sec,
  308. bool last_ind)
  309. {
  310. set_dout_type(pdesc, DMA_MLLI, addr, size, axi_sec);
  311. pdesc->word[3] |= FIELD_PREP(WORD3_DOUT_LAST_IND, last_ind);
  312. }
  313. /*
  314. * Set the DOUT field of a HW descriptors to NO DMA mode.
  315. * Used for NOP descriptor, register patches and other special modes.
  316. *
  317. * @pdesc: pointer HW descriptor struct
  318. * @addr: DOUT address
  319. * @size: Data size in bytes
  320. * @write_enable: Enables a write operation to a register
  321. */
  322. static inline void set_dout_no_dma(struct cc_hw_desc *pdesc, u32 addr,
  323. u32 size, bool write_enable)
  324. {
  325. pdesc->word[2] = addr;
  326. pdesc->word[3] |= FIELD_PREP(WORD3_DOUT_SIZE, size) |
  327. FIELD_PREP(WORD3_DOUT_LAST_IND, write_enable);
  328. }
  329. /*
  330. * Set the word for the XOR operation.
  331. *
  332. * @pdesc: pointer HW descriptor struct
  333. * @val: xor data value
  334. */
  335. static inline void set_xor_val(struct cc_hw_desc *pdesc, u32 val)
  336. {
  337. pdesc->word[2] = val;
  338. }
  339. /*
  340. * Sets the XOR indicator bit in the descriptor
  341. *
  342. * @pdesc: pointer HW descriptor struct
  343. */
  344. static inline void set_xor_active(struct cc_hw_desc *pdesc)
  345. {
  346. pdesc->word[3] |= FIELD_PREP(WORD3_HASH_XOR_BIT, 1);
  347. }
  348. /*
  349. * Select the AES engine instead of HASH engine when setting up combined mode
  350. * with AES XCBC MAC
  351. *
  352. * @pdesc: pointer HW descriptor struct
  353. */
  354. static inline void set_aes_not_hash_mode(struct cc_hw_desc *pdesc)
  355. {
  356. pdesc->word[4] |= FIELD_PREP(WORD4_AES_SEL_N_HASH, 1);
  357. }
  358. /*
  359. * Set the DOUT field of a HW descriptors to SRAM mode
  360. * Note: No need to check SRAM alignment since host requests do not use SRAM and
  361. * adaptor will enforce alignment check.
  362. *
  363. * @pdesc: pointer HW descriptor struct
  364. * @addr: DOUT address
  365. * @size: Data size in bytes
  366. */
  367. static inline void set_dout_sram(struct cc_hw_desc *pdesc, u32 addr, u32 size)
  368. {
  369. pdesc->word[2] = addr;
  370. pdesc->word[3] |= FIELD_PREP(WORD3_DOUT_DMA_MODE, DMA_SRAM) |
  371. FIELD_PREP(WORD3_DOUT_SIZE, size);
  372. }
  373. /*
  374. * Sets the data unit size for XEX mode in data_out_addr[15:0]
  375. *
  376. * @pdesc: pDesc pointer HW descriptor struct
  377. * @size: data unit size for XEX mode
  378. */
  379. static inline void set_xex_data_unit_size(struct cc_hw_desc *pdesc, u32 size)
  380. {
  381. pdesc->word[2] = size;
  382. }
  383. /*
  384. * Set the number of rounds for Multi2 in data_out_addr[15:0]
  385. *
  386. * @pdesc: pointer HW descriptor struct
  387. * @num: number of rounds for Multi2
  388. */
  389. static inline void set_multi2_num_rounds(struct cc_hw_desc *pdesc, u32 num)
  390. {
  391. pdesc->word[2] = num;
  392. }
  393. /*
  394. * Set the flow mode.
  395. *
  396. * @pdesc: pointer HW descriptor struct
  397. * @mode: Any one of the modes defined in [CC7x-DESC]
  398. */
  399. static inline void set_flow_mode(struct cc_hw_desc *pdesc,
  400. enum cc_flow_mode mode)
  401. {
  402. pdesc->word[4] |= FIELD_PREP(WORD4_DATA_FLOW_MODE, mode);
  403. }
  404. /*
  405. * Set the cipher mode.
  406. *
  407. * @pdesc: pointer HW descriptor struct
  408. * @mode: Any one of the modes defined in [CC7x-DESC]
  409. */
  410. static inline void set_cipher_mode(struct cc_hw_desc *pdesc, int mode)
  411. {
  412. pdesc->word[4] |= FIELD_PREP(WORD4_CIPHER_MODE, mode);
  413. }
  414. /*
  415. * Set the cipher configuration fields.
  416. *
  417. * @pdesc: pointer HW descriptor struct
  418. * @mode: Any one of the modes defined in [CC7x-DESC]
  419. */
  420. static inline void set_cipher_config0(struct cc_hw_desc *pdesc, int mode)
  421. {
  422. pdesc->word[4] |= FIELD_PREP(WORD4_CIPHER_CONF0, mode);
  423. }
  424. /*
  425. * Set the cipher configuration fields.
  426. *
  427. * @pdesc: pointer HW descriptor struct
  428. * @config: Any one of the modes defined in [CC7x-DESC]
  429. */
  430. static inline void set_cipher_config1(struct cc_hw_desc *pdesc,
  431. enum cc_hash_conf_pad config)
  432. {
  433. pdesc->word[4] |= FIELD_PREP(WORD4_CIPHER_CONF1, config);
  434. }
  435. /*
  436. * Set HW key configuration fields.
  437. *
  438. * @pdesc: pointer HW descriptor struct
  439. * @hw_key: The HW key slot asdefined in enum cc_hw_crypto_key
  440. */
  441. static inline void set_hw_crypto_key(struct cc_hw_desc *pdesc,
  442. enum cc_hw_crypto_key hw_key)
  443. {
  444. pdesc->word[4] |= FIELD_PREP(WORD4_CIPHER_DO,
  445. (hw_key & HW_KEY_MASK_CIPHER_DO)) |
  446. FIELD_PREP(WORD4_CIPHER_CONF2,
  447. (hw_key >> HW_KEY_SHIFT_CIPHER_CFG2));
  448. }
  449. /*
  450. * Set byte order of all setup-finalize descriptors.
  451. *
  452. * @pdesc: pointer HW descriptor struct
  453. * @config: Any one of the modes defined in [CC7x-DESC]
  454. */
  455. static inline void set_bytes_swap(struct cc_hw_desc *pdesc, bool config)
  456. {
  457. pdesc->word[4] |= FIELD_PREP(WORD4_BYTES_SWAP, config);
  458. }
  459. /*
  460. * Set CMAC_SIZE0 mode.
  461. *
  462. * @pdesc: pointer HW descriptor struct
  463. */
  464. static inline void set_cmac_size0_mode(struct cc_hw_desc *pdesc)
  465. {
  466. pdesc->word[4] |= FIELD_PREP(WORD4_CMAC_SIZE0, 1);
  467. }
  468. /*
  469. * Set key size descriptor field.
  470. *
  471. * @pdesc: pointer HW descriptor struct
  472. * @size: key size in bytes (NOT size code)
  473. */
  474. static inline void set_key_size(struct cc_hw_desc *pdesc, u32 size)
  475. {
  476. pdesc->word[4] |= FIELD_PREP(WORD4_KEY_SIZE, size);
  477. }
  478. /*
  479. * Set AES key size.
  480. *
  481. * @pdesc: pointer HW descriptor struct
  482. * @size: key size in bytes (NOT size code)
  483. */
  484. static inline void set_key_size_aes(struct cc_hw_desc *pdesc, u32 size)
  485. {
  486. set_key_size(pdesc, ((size >> 3) - 2));
  487. }
  488. /*
  489. * Set DES key size.
  490. *
  491. * @pdesc: pointer HW descriptor struct
  492. * @size: key size in bytes (NOT size code)
  493. */
  494. static inline void set_key_size_des(struct cc_hw_desc *pdesc, u32 size)
  495. {
  496. set_key_size(pdesc, ((size >> 3) - 1));
  497. }
  498. /*
  499. * Set the descriptor setup mode
  500. *
  501. * @pdesc: pointer HW descriptor struct
  502. * @mode: Any one of the setup modes defined in [CC7x-DESC]
  503. */
  504. static inline void set_setup_mode(struct cc_hw_desc *pdesc,
  505. enum cc_setup_op mode)
  506. {
  507. pdesc->word[4] |= FIELD_PREP(WORD4_SETUP_OPERATION, mode);
  508. }
  509. /*
  510. * Set the descriptor cipher DO
  511. *
  512. * @pdesc: pointer HW descriptor struct
  513. * @config: Any one of the cipher do defined in [CC7x-DESC]
  514. */
  515. static inline void set_cipher_do(struct cc_hw_desc *pdesc,
  516. enum cc_hash_cipher_pad config)
  517. {
  518. pdesc->word[4] |= FIELD_PREP(WORD4_CIPHER_DO,
  519. (config & HW_KEY_MASK_CIPHER_DO));
  520. }
  521. #endif /*__CC_HW_QUEUE_DEFS_H__*/