fsl_dpbp.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Freescale Layerscape MC I/O wrapper
  4. *
  5. * Copyright 2013-2016 Freescale Semiconductor, Inc.
  6. * Copyright 2017 NXP
  7. */
  8. /*!
  9. * @file fsl_dpbp.h
  10. * @brief Data Path Buffer Pool API
  11. */
  12. #ifndef __FSL_DPBP_H
  13. #define __FSL_DPBP_H
  14. /* DPBP Version */
  15. #define DPBP_VER_MAJOR 3
  16. #define DPBP_VER_MINOR 3
  17. /* Command IDs */
  18. #define DPBP_CMDID_CLOSE 0x8001
  19. #define DPBP_CMDID_OPEN 0x8041
  20. #define DPBP_CMDID_CREATE 0x9041
  21. #define DPBP_CMDID_DESTROY 0x9841
  22. #define DPBP_CMDID_GET_API_VERSION 0xa041
  23. #define DPBP_CMDID_ENABLE 0x0021
  24. #define DPBP_CMDID_DISABLE 0x0031
  25. #define DPBP_CMDID_GET_ATTR 0x0041
  26. #define DPBP_CMDID_RESET 0x0051
  27. #define DPBP_CMDID_IS_ENABLED 0x0061
  28. /* cmd, param, offset, width, type, arg_name */
  29. #define DPBP_CMD_OPEN(cmd, dpbp_id) \
  30. MC_CMD_OP(cmd, 0, 0, 32, int, dpbp_id)
  31. /* cmd, param, offset, width, type, arg_name */
  32. #define DPBP_RSP_GET_ATTRIBUTES(cmd, attr) \
  33. do { \
  34. MC_RSP_OP(cmd, 0, 16, 16, uint16_t, attr->bpid); \
  35. MC_RSP_OP(cmd, 0, 32, 32, int, attr->id);\
  36. } while (0)
  37. /* Data Path Buffer Pool API
  38. * Contains initialization APIs and runtime control APIs for DPBP
  39. */
  40. struct fsl_mc_io;
  41. /**
  42. * dpbp_open() - Open a control session for the specified object.
  43. * @mc_io: Pointer to MC portal's I/O object
  44. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  45. * @dpbp_id: DPBP unique ID
  46. * @token: Returned token; use in subsequent API calls
  47. *
  48. * This function can be used to open a control session for an
  49. * already created object; an object may have been declared in
  50. * the DPL or by calling the dpbp_create function.
  51. * This function returns a unique authentication token,
  52. * associated with the specific object ID and the specific MC
  53. * portal; this token must be used in all subsequent commands for
  54. * this specific object
  55. *
  56. * Return: '0' on Success; Error code otherwise.
  57. */
  58. int dpbp_open(struct fsl_mc_io *mc_io,
  59. uint32_t cmd_flags,
  60. int dpbp_id,
  61. uint16_t *token);
  62. /**
  63. * dpbp_close() - Close the control session of the object
  64. * @mc_io: Pointer to MC portal's I/O object
  65. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  66. * @token: Token of DPBP object
  67. *
  68. * After this function is called, no further operations are
  69. * allowed on the object without opening a new control session.
  70. *
  71. * Return: '0' on Success; Error code otherwise.
  72. */
  73. int dpbp_close(struct fsl_mc_io *mc_io,
  74. uint32_t cmd_flags,
  75. uint16_t token);
  76. /**
  77. * struct dpbp_cfg - Structure representing DPBP configuration
  78. * @options: place holder
  79. */
  80. struct dpbp_cfg {
  81. uint32_t options;
  82. };
  83. /**
  84. * dpbp_create() - Create the DPBP object.
  85. * @mc_io: Pointer to MC portal's I/O object
  86. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  87. * @cfg: Configuration structure
  88. * @token: Returned token; use in subsequent API calls
  89. *
  90. * Create the DPBP object, allocate required resources and
  91. * perform required initialization.
  92. *
  93. * The object can be created either by declaring it in the
  94. * DPL file, or by calling this function.
  95. * This function returns a unique authentication token,
  96. * associated with the specific object ID and the specific MC
  97. * portal; this token must be used in all subsequent calls to
  98. * this specific object. For objects that are created using the
  99. * DPL file, call dpbp_open function to get an authentication
  100. * token first.
  101. *
  102. * Return: '0' on Success; Error code otherwise.
  103. */
  104. int dpbp_create(struct fsl_mc_io *mc_io,
  105. uint16_t dprc_token,
  106. uint32_t cmd_flags,
  107. const struct dpbp_cfg *cfg,
  108. uint32_t *obj_id);
  109. /**
  110. * dpbp_destroy() - Destroy the DPBP object and release all its resources.
  111. * @mc_io: Pointer to MC portal's I/O object
  112. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  113. * @token: Token of DPBP object
  114. *
  115. * Return: '0' on Success; error code otherwise.
  116. */
  117. int dpbp_destroy(struct fsl_mc_io *mc_io,
  118. uint16_t dprc_token,
  119. uint32_t cmd_flags,
  120. uint32_t obj_id);
  121. /**
  122. * dpbp_enable() - Enable the DPBP.
  123. * @mc_io: Pointer to MC portal's I/O object
  124. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  125. * @token: Token of DPBP object
  126. *
  127. * Return: '0' on Success; Error code otherwise.
  128. */
  129. int dpbp_enable(struct fsl_mc_io *mc_io,
  130. uint32_t cmd_flags,
  131. uint16_t token);
  132. /**
  133. * dpbp_disable() - Disable the DPBP.
  134. * @mc_io: Pointer to MC portal's I/O object
  135. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  136. * @token: Token of DPBP object
  137. *
  138. * Return: '0' on Success; Error code otherwise.
  139. */
  140. int dpbp_disable(struct fsl_mc_io *mc_io,
  141. uint32_t cmd_flags,
  142. uint16_t token);
  143. /**
  144. * dpbp_is_enabled() - Check if the DPBP is enabled.
  145. * @mc_io: Pointer to MC portal's I/O object
  146. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  147. * @token: Token of DPBP object
  148. * @en: Returns '1' if object is enabled; '0' otherwise
  149. *
  150. * Return: '0' on Success; Error code otherwise.
  151. */
  152. int dpbp_is_enabled(struct fsl_mc_io *mc_io,
  153. uint32_t cmd_flags,
  154. uint16_t token,
  155. int *en);
  156. /**
  157. * dpbp_reset() - Reset the DPBP, returns the object to initial state.
  158. * @mc_io: Pointer to MC portal's I/O object
  159. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  160. * @token: Token of DPBP object
  161. *
  162. * Return: '0' on Success; Error code otherwise.
  163. */
  164. int dpbp_reset(struct fsl_mc_io *mc_io,
  165. uint32_t cmd_flags,
  166. uint16_t token);
  167. /**
  168. * struct dpbp_attr - Structure representing DPBP attributes
  169. * @id: DPBP object ID
  170. * @version: DPBP version
  171. * @bpid: Hardware buffer pool ID; should be used as an argument in
  172. * acquire/release operations on buffers
  173. */
  174. struct dpbp_attr {
  175. uint32_t id;
  176. uint16_t bpid;
  177. };
  178. /**
  179. * dpbp_get_attributes - Retrieve DPBP attributes.
  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. * @token: Token of DPBP object
  184. * @attr: Returned object's attributes
  185. *
  186. * Return: '0' on Success; Error code otherwise.
  187. */
  188. int dpbp_get_attributes(struct fsl_mc_io *mc_io,
  189. uint32_t cmd_flags,
  190. uint16_t token,
  191. struct dpbp_attr *attr);
  192. /**
  193. * dpbp_get_api_version - Retrieve DPBP Major and Minor version info.
  194. *
  195. * @mc_io: Pointer to MC portal's I/O object
  196. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  197. * @major_ver: DPBP major version
  198. * @minor_ver: DPBP minor version
  199. *
  200. * Return: '0' on Success; Error code otherwise.
  201. */
  202. int dpbp_get_api_version(struct fsl_mc_io *mc_io,
  203. u32 cmd_flags,
  204. u16 *major_ver,
  205. u16 *minor_ver);
  206. /** @} */
  207. #endif /* __FSL_DPBP_H */