dpseci.h 10 KB

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