fsl_dpsparser.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Data Path Soft Parser API
  4. *
  5. * Copyright 2018 NXP
  6. */
  7. #ifndef _FSL_DPSPARSER_H
  8. #define _FSL_DPSPARSER_H
  9. /* DPSPARSER last supported API version */
  10. #define DPSPARSER_VER_MAJOR 1
  11. #define DPSPARSER_VER_MINOR 0
  12. /* Command IDs */
  13. #define DPSPARSER_CMDID_CLOSE 0x8001
  14. #define DPSPARSER_CMDID_OPEN 0x8111
  15. #define DPSPARSER_CMDID_CREATE 0x9111
  16. #define DPSPARSER_CMDID_DESTROY 0x9911
  17. #define DPSPARSER_CMDID_GET_API_VERSION 0xa111
  18. #define DPSPARSER_CMDID_APPLY_SPB 0x1181
  19. /* cmd, param, offset, width, type, arg_name */
  20. #define DPSPARSER_CMD_BLOB_SET_ADDR(cmd, addr) \
  21. MC_CMD_OP(cmd, 0, 0, 64, u64, addr)
  22. /* cmd, param, offset, width, type, arg_name */
  23. #define DPSPARSER_CMD_BLOB_REPORT_ERROR(cmd, err) \
  24. MC_RSP_OP(cmd, 0, 0, 16, u16, err)
  25. /* Data Path Soft Parser API
  26. * Contains initialization APIs and runtime control APIs for DPSPARSER
  27. */
  28. struct fsl_mc_io;
  29. /* MC Unknown error: */
  30. #define MC_ERROR_MSG_SPB_UNKNOWN "Unknown MC error\n"
  31. /* MC Error messages (in order for each error code defined above): */
  32. #define MC_ERROR_MSG_APPLY_SPB \
  33. { \
  34. "OK\n", \
  35. "BLOB : Magic number does not match\n", \
  36. "BLOB : Version does not match MC API version\n", \
  37. "BLOB : IP revision does not match HW revision\n", \
  38. "BLOB : Blob length is not a multiple of 4\n", \
  39. "BLOB : Invalid length detected\n", \
  40. "BLOB : Name length < 0 in 'blob-name'\n", \
  41. "BLOB : Name length not a 4 multiple in 'blob-name'\n", \
  42. "BLOB : No target HW parser selected\n", \
  43. "BLOB : SP size is negative\n", \
  44. "BLOB : Size is zero\n", \
  45. "BLOB : Number of protocols is negative\n", \
  46. "BLOB : Zero protocols\n", \
  47. "BLOB : Protocol name is null\n", \
  48. "BLOB : SP 'seq-start' is not in [0x40, 0xffc0) range\n", \
  49. "BLOB : Invalid base protocol\n", \
  50. "BLOB : Invalid parameters section\n", \
  51. "BLOB : Invalid parameter\n", \
  52. "BLOB : Invalid parameter configuration\n", \
  53. "BLOB : Not aligned value\n", \
  54. "BLOB : Invalid section TAG detected\n", \
  55. "BLOB : Section size is zero\n", \
  56. "BLOB : Section size not a 4 multiple\n", \
  57. "BLOB : Section size is too big\n", \
  58. "BLOB : No 'bytecode' section before\n", \
  59. "BLOB : No 'sp-protocols' section before\n", \
  60. "BLOB : No 'bytecode' section defined\n", \
  61. "BLOB : No 'sp-protocols' section defined\n", \
  62. "BLOB : Soft Parser BLOB parsing : Error detected\n", \
  63. "apply spb : Soft Parser BLOB is already applied\n", \
  64. "apply spb : BLOB address is not set\n", \
  65. "BLOB : SP parameter offset is not a 4 multiple\n", \
  66. "BLOB : SP parameter offset can't be less than 0x40\n", \
  67. "BLOB : Bytecode size is not a 4 multiple\n", \
  68. "BLOB : Bytecode size cannot be zero\n", \
  69. "BLOB : Bytecode can't overwrite the 0xFFE address\n", \
  70. "BLOB : No hardware parser selected as target\n", \
  71. "BLOB : Bytecode overlap detected\n", \
  72. "BLOB : No parser support\n", \
  73. "BLOB : Too many bytecode sections on WRIOP ingress\n", \
  74. "BLOB : Too many bytecode sections on WRIOP egress\n", \
  75. "BLOB : Too many bytecode sections on AIOP\n", \
  76. "BLOB : Duplicated protocol is already registered\n", \
  77. "BLOB : Maximum number of allowed protocols was exceeded\n", \
  78. "BLOB : Protocols limit exceeded\n", \
  79. "BLOB : Protocol is linked twice\n", \
  80. "BLOB : Soft parser is linked twice\n", \
  81. "BLOB : Parameter offset exceeds the maximum parameters limit\n", \
  82. "BLOB : Parameter size can't be 0 or greater than 64\n", \
  83. "BLOB : Parameter offset plus size exceeds the maximum limit\n", \
  84. "BLOB : Parameters number exceeds the maximum limit\n", \
  85. "BLOB : Duplicated parameter name\n", \
  86. "BLOB : Parameters overlapped detected\n", \
  87. "apply spb : No dpsparser handle.\n", \
  88. \
  89. MC_ERROR_MSG_SPB_UNKNOWN, \
  90. NULL, \
  91. }
  92. /**
  93. * dpsparser_open() - Open a control session for the specified object.
  94. * @mc_io: Pointer to MC portal's I/O object
  95. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  96. * @token: Returned token; use in subsequent API calls
  97. *
  98. * This function can be used to open a control session for an
  99. * already created object; an object may have been declared in
  100. * the DPL or by calling the dpsparser_create function.
  101. * This function returns a unique authentication token,
  102. * associated with the specific object ID and the specific MC
  103. * portal; this token must be used in all subsequent commands for
  104. * this specific object
  105. *
  106. * Return: '0' on Success; Error code otherwise.
  107. */
  108. int dpsparser_open(struct fsl_mc_io *mc_io,
  109. u32 cmd_flags,
  110. u16 *token);
  111. /**
  112. * dpsparser_close() - Close the control session of the object
  113. * @mc_io: Pointer to MC portal's I/O object
  114. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  115. * @token: Token of DPSPARSER object
  116. *
  117. * After this function is called, no further operations are
  118. * allowed on the object without opening a new control session.
  119. *
  120. * Return: '0' on Success; Error code otherwise.
  121. */
  122. int dpsparser_close(struct fsl_mc_io *mc_io,
  123. u32 cmd_flags,
  124. u16 token);
  125. /**
  126. * dpsparser_create() - Create the DPSPARSER object.
  127. * @mc_io: Pointer to MC portal's I/O object
  128. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  129. * @token: Returned token; use in subsequent API calls
  130. *
  131. * Create the DPSPARSER object, allocate required resources and
  132. * perform required initialization.
  133. *
  134. * The object can be created either by declaring it in the
  135. * DPL file, or by calling this function.
  136. * This function returns a unique authentication token,
  137. * associated with the specific object ID and the specific MC
  138. * portal; this token must be used in all subsequent calls to
  139. * this specific object. For objects that are created using the
  140. * DPL file, call dpsparser_open function to get an authentication
  141. * token first.
  142. *
  143. * Return: '0' on Success; Error code otherwise.
  144. */
  145. int dpsparser_create(struct fsl_mc_io *mc_io,
  146. u16 token,
  147. u32 cmd_flags,
  148. u32 *obj_id);
  149. /**
  150. * dpsparser_destroy() - Destroy the DPSPARSER object and release all its
  151. * resources.
  152. * @mc_io: Pointer to MC portal's I/O object
  153. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  154. * @token: Token of DPSPARSER object
  155. *
  156. * Return: '0' on Success; error code otherwise.
  157. */
  158. int dpsparser_destroy(struct fsl_mc_io *mc_io,
  159. u16 token,
  160. u32 cmd_flags,
  161. u32 obj_id);
  162. /**
  163. * dpsparser_apply_spb() - Applies the Soft Parser Blob loaded at specified
  164. * address.
  165. * @mc_io: Pointer to MC portal's I/O object
  166. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  167. * @token: Token of DPSPARSER object
  168. * @blob_addr: Blob loading address
  169. * @error: Error reported by MC related to SP Blob parsing and apply
  170. *
  171. * Return: '0' on Success; error code otherwise.
  172. */
  173. int dpsparser_apply_spb(struct fsl_mc_io *mc_io,
  174. u32 cmd_flags,
  175. u16 token,
  176. u64 blob_addr,
  177. u16 *error);
  178. /**
  179. * dpsparser_get_api_version - Retrieve DPSPARSER Major and Minor version info.
  180. *
  181. * @mc_io: Pointer to MC portal's I/O object
  182. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  183. * @major_ver: DPSPARSER major version
  184. * @minor_ver: DPSPARSER minor version
  185. *
  186. * Return: '0' on Success; Error code otherwise.
  187. */
  188. int dpsparser_get_api_version(struct fsl_mc_io *mc_io,
  189. u32 cmd_flags,
  190. u16 *major_ver,
  191. u16 *minor_ver);
  192. #endif /* _FSL_DPSPARSER_H */