fsl_dpbp.h 6.2 KB

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