dpseci.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. /* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
  2. /*
  3. * Copyright 2013-2016 Freescale Semiconductor Inc.
  4. * Copyright 2017-2018 NXP
  5. */
  6. #ifndef _DPSECI_H_
  7. #define _DPSECI_H_
  8. /*
  9. * Data Path SEC Interface API
  10. * Contains initialization APIs and runtime control APIs for DPSECI
  11. */
  12. struct fsl_mc_io;
  13. /**
  14. * General DPSECI macros
  15. */
  16. /**
  17. * Maximum number of Tx/Rx queues per DPSECI object
  18. */
  19. #define DPSECI_MAX_QUEUE_NUM 16
  20. /**
  21. * All queues considered; see dpseci_set_rx_queue()
  22. */
  23. #define DPSECI_ALL_QUEUES (u8)(-1)
  24. int dpseci_open(struct fsl_mc_io *mc_io, u32 cmd_flags, int dpseci_id,
  25. u16 *token);
  26. int dpseci_close(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
  27. /**
  28. * Enable the Congestion Group support
  29. */
  30. #define DPSECI_OPT_HAS_CG 0x000020
  31. /**
  32. * struct dpseci_cfg - Structure representing DPSECI configuration
  33. * @options: Any combination of the following flags:
  34. * DPSECI_OPT_HAS_CG
  35. * @num_tx_queues: num of queues towards the SEC
  36. * @num_rx_queues: num of queues back from the SEC
  37. * @priorities: Priorities for the SEC hardware processing;
  38. * each place in the array is the priority of the tx queue
  39. * towards the SEC;
  40. * valid priorities are configured with values 1-8;
  41. */
  42. struct dpseci_cfg {
  43. u32 options;
  44. u8 num_tx_queues;
  45. u8 num_rx_queues;
  46. u8 priorities[DPSECI_MAX_QUEUE_NUM];
  47. };
  48. int dpseci_enable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
  49. int dpseci_disable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
  50. int dpseci_is_enabled(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
  51. int *en);
  52. /**
  53. * struct dpseci_attr - Structure representing DPSECI attributes
  54. * @id: DPSECI object ID
  55. * @num_tx_queues: number of queues towards the SEC
  56. * @num_rx_queues: number of queues back from the SEC
  57. * @options: any combination of the following flags:
  58. * DPSECI_OPT_HAS_CG
  59. */
  60. struct dpseci_attr {
  61. int id;
  62. u8 num_tx_queues;
  63. u8 num_rx_queues;
  64. u32 options;
  65. };
  66. int dpseci_get_attributes(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
  67. struct dpseci_attr *attr);
  68. /**
  69. * enum dpseci_dest - DPSECI destination types
  70. * @DPSECI_DEST_NONE: Unassigned destination; The queue is set in parked mode
  71. * and does not generate FQDAN notifications; user is expected to dequeue
  72. * from the queue based on polling or other user-defined method
  73. * @DPSECI_DEST_DPIO: The queue is set in schedule mode and generates FQDAN
  74. * notifications to the specified DPIO; user is expected to dequeue from
  75. * the queue only after notification is received
  76. * @DPSECI_DEST_DPCON: The queue is set in schedule mode and does not generate
  77. * FQDAN notifications, but is connected to the specified DPCON object;
  78. * user is expected to dequeue from the DPCON channel
  79. */
  80. enum dpseci_dest {
  81. DPSECI_DEST_NONE = 0,
  82. DPSECI_DEST_DPIO,
  83. DPSECI_DEST_DPCON
  84. };
  85. /**
  86. * struct dpseci_dest_cfg - Structure representing DPSECI destination parameters
  87. * @dest_type: Destination type
  88. * @dest_id: Either DPIO ID or DPCON ID, depending on the destination type
  89. * @priority: Priority selection within the DPIO or DPCON channel; valid values
  90. * are 0-1 or 0-7, depending on the number of priorities in that channel;
  91. * not relevant for 'DPSECI_DEST_NONE' option
  92. */
  93. struct dpseci_dest_cfg {
  94. enum dpseci_dest dest_type;
  95. int dest_id;
  96. u8 priority;
  97. };
  98. /**
  99. * DPSECI queue modification options
  100. */
  101. /**
  102. * Select to modify the user's context associated with the queue
  103. */
  104. #define DPSECI_QUEUE_OPT_USER_CTX 0x00000001
  105. /**
  106. * Select to modify the queue's destination
  107. */
  108. #define DPSECI_QUEUE_OPT_DEST 0x00000002
  109. /**
  110. * Select to modify the queue's order preservation
  111. */
  112. #define DPSECI_QUEUE_OPT_ORDER_PRESERVATION 0x00000004
  113. /**
  114. * struct dpseci_rx_queue_cfg - DPSECI RX queue configuration
  115. * @options: Flags representing the suggested modifications to the queue;
  116. * Use any combination of 'DPSECI_QUEUE_OPT_<X>' flags
  117. * @order_preservation_en: order preservation configuration for the rx queue
  118. * valid only if 'DPSECI_QUEUE_OPT_ORDER_PRESERVATION' is contained in 'options'
  119. * @user_ctx: User context value provided in the frame descriptor of each
  120. * dequeued frame; valid only if 'DPSECI_QUEUE_OPT_USER_CTX' is contained
  121. * in 'options'
  122. * @dest_cfg: Queue destination parameters; valid only if
  123. * 'DPSECI_QUEUE_OPT_DEST' is contained in 'options'
  124. */
  125. struct dpseci_rx_queue_cfg {
  126. u32 options;
  127. int order_preservation_en;
  128. u64 user_ctx;
  129. struct dpseci_dest_cfg dest_cfg;
  130. };
  131. int dpseci_set_rx_queue(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
  132. u8 queue, const struct dpseci_rx_queue_cfg *cfg);
  133. /**
  134. * struct dpseci_rx_queue_attr - Structure representing attributes of Rx queues
  135. * @user_ctx: User context value provided in the frame descriptor of each
  136. * dequeued frame
  137. * @order_preservation_en: Status of the order preservation configuration on the
  138. * queue
  139. * @dest_cfg: Queue destination configuration
  140. * @fqid: Virtual FQID value to be used for dequeue operations
  141. */
  142. struct dpseci_rx_queue_attr {
  143. u64 user_ctx;
  144. int order_preservation_en;
  145. struct dpseci_dest_cfg dest_cfg;
  146. u32 fqid;
  147. };
  148. int dpseci_get_rx_queue(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
  149. u8 queue, struct dpseci_rx_queue_attr *attr);
  150. /**
  151. * struct dpseci_tx_queue_attr - Structure representing attributes of Tx queues
  152. * @fqid: Virtual FQID to be used for sending frames to SEC hardware
  153. * @priority: SEC hardware processing priority for the queue
  154. */
  155. struct dpseci_tx_queue_attr {
  156. u32 fqid;
  157. u8 priority;
  158. };
  159. int dpseci_get_tx_queue(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
  160. u8 queue, struct dpseci_tx_queue_attr *attr);
  161. /**
  162. * struct dpseci_sec_attr - Structure representing attributes of the SEC
  163. * hardware accelerator
  164. * @ip_id: ID for SEC
  165. * @major_rev: Major revision number for SEC
  166. * @minor_rev: Minor revision number for SEC
  167. * @era: SEC Era
  168. * @deco_num: The number of copies of the DECO that are implemented in this
  169. * version of SEC
  170. * @zuc_auth_acc_num: The number of copies of ZUCA that are implemented in this
  171. * version of SEC
  172. * @zuc_enc_acc_num: The number of copies of ZUCE that are implemented in this
  173. * version of SEC
  174. * @snow_f8_acc_num: The number of copies of the SNOW-f8 module that are
  175. * implemented in this version of SEC
  176. * @snow_f9_acc_num: The number of copies of the SNOW-f9 module that are
  177. * implemented in this version of SEC
  178. * @crc_acc_num: The number of copies of the CRC module that are implemented in
  179. * this version of SEC
  180. * @pk_acc_num: The number of copies of the Public Key module that are
  181. * implemented in this version of SEC
  182. * @kasumi_acc_num: The number of copies of the Kasumi module that are
  183. * implemented in this version of SEC
  184. * @rng_acc_num: The number of copies of the Random Number Generator that are
  185. * implemented in this version of SEC
  186. * @md_acc_num: The number of copies of the MDHA (Hashing module) that are
  187. * implemented in this version of SEC
  188. * @arc4_acc_num: The number of copies of the ARC4 module that are implemented
  189. * in this version of SEC
  190. * @des_acc_num: The number of copies of the DES module that are implemented in
  191. * this version of SEC
  192. * @aes_acc_num: The number of copies of the AES module that are implemented in
  193. * this version of SEC
  194. * @ccha_acc_num: The number of copies of the ChaCha20 module that are
  195. * implemented in this version of SEC.
  196. * @ptha_acc_num: The number of copies of the Poly1305 module that are
  197. * implemented in this version of SEC.
  198. **/
  199. struct dpseci_sec_attr {
  200. u16 ip_id;
  201. u8 major_rev;
  202. u8 minor_rev;
  203. u8 era;
  204. u8 deco_num;
  205. u8 zuc_auth_acc_num;
  206. u8 zuc_enc_acc_num;
  207. u8 snow_f8_acc_num;
  208. u8 snow_f9_acc_num;
  209. u8 crc_acc_num;
  210. u8 pk_acc_num;
  211. u8 kasumi_acc_num;
  212. u8 rng_acc_num;
  213. u8 md_acc_num;
  214. u8 arc4_acc_num;
  215. u8 des_acc_num;
  216. u8 aes_acc_num;
  217. u8 ccha_acc_num;
  218. u8 ptha_acc_num;
  219. };
  220. int dpseci_get_sec_attr(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
  221. struct dpseci_sec_attr *attr);
  222. int dpseci_get_api_version(struct fsl_mc_io *mc_io, u32 cmd_flags,
  223. u16 *major_ver, u16 *minor_ver);
  224. /**
  225. * enum dpseci_congestion_unit - DPSECI congestion units
  226. * @DPSECI_CONGESTION_UNIT_BYTES: bytes units
  227. * @DPSECI_CONGESTION_UNIT_FRAMES: frames units
  228. */
  229. enum dpseci_congestion_unit {
  230. DPSECI_CONGESTION_UNIT_BYTES = 0,
  231. DPSECI_CONGESTION_UNIT_FRAMES
  232. };
  233. /**
  234. * CSCN message is written to message_iova once entering a
  235. * congestion state (see 'threshold_entry')
  236. */
  237. #define DPSECI_CGN_MODE_WRITE_MEM_ON_ENTER 0x00000001
  238. /**
  239. * CSCN message is written to message_iova once exiting a
  240. * congestion state (see 'threshold_exit')
  241. */
  242. #define DPSECI_CGN_MODE_WRITE_MEM_ON_EXIT 0x00000002
  243. /**
  244. * CSCN write will attempt to allocate into a cache (coherent write);
  245. * valid only if 'DPSECI_CGN_MODE_WRITE_MEM_<X>' is selected
  246. */
  247. #define DPSECI_CGN_MODE_COHERENT_WRITE 0x00000004
  248. /**
  249. * if 'dpseci_dest_cfg.dest_type != DPSECI_DEST_NONE' CSCN message is sent to
  250. * DPIO/DPCON's WQ channel once entering a congestion state
  251. * (see 'threshold_entry')
  252. */
  253. #define DPSECI_CGN_MODE_NOTIFY_DEST_ON_ENTER 0x00000008
  254. /**
  255. * if 'dpseci_dest_cfg.dest_type != DPSECI_DEST_NONE' CSCN message is sent to
  256. * DPIO/DPCON's WQ channel once exiting a congestion state
  257. * (see 'threshold_exit')
  258. */
  259. #define DPSECI_CGN_MODE_NOTIFY_DEST_ON_EXIT 0x00000010
  260. /**
  261. * if 'dpseci_dest_cfg.dest_type != DPSECI_DEST_NONE' when the CSCN is written
  262. * to the sw-portal's DQRR, the DQRI interrupt is asserted immediately
  263. * (if enabled)
  264. */
  265. #define DPSECI_CGN_MODE_INTR_COALESCING_DISABLED 0x00000020
  266. /**
  267. * struct dpseci_congestion_notification_cfg - congestion notification
  268. * configuration
  269. * @units: units type
  270. * @threshold_entry: above this threshold we enter a congestion state.
  271. * set it to '0' to disable it
  272. * @threshold_exit: below this threshold we exit the congestion state.
  273. * @message_ctx: The context that will be part of the CSCN message
  274. * @message_iova: I/O virtual address (must be in DMA-able memory),
  275. * must be 16B aligned;
  276. * @dest_cfg: CSCN can be send to either DPIO or DPCON WQ channel
  277. * @notification_mode: Mask of available options; use 'DPSECI_CGN_MODE_<X>'
  278. * values
  279. */
  280. struct dpseci_congestion_notification_cfg {
  281. enum dpseci_congestion_unit units;
  282. u32 threshold_entry;
  283. u32 threshold_exit;
  284. u64 message_ctx;
  285. u64 message_iova;
  286. struct dpseci_dest_cfg dest_cfg;
  287. u16 notification_mode;
  288. };
  289. int dpseci_set_congestion_notification(struct fsl_mc_io *mc_io, u32 cmd_flags,
  290. u16 token, const struct dpseci_congestion_notification_cfg *cfg);
  291. int dpseci_get_congestion_notification(struct fsl_mc_io *mc_io, u32 cmd_flags,
  292. u16 token, struct dpseci_congestion_notification_cfg *cfg);
  293. #endif /* _DPSECI_H_ */