fsl_dpio.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. /*
  2. * Copyright (C) 2013-2015 Freescale Semiconductor
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #ifndef _FSL_DPIO_H
  7. #define _FSL_DPIO_H
  8. /* DPIO Version */
  9. #define DPIO_VER_MAJOR 3
  10. #define DPIO_VER_MINOR 2
  11. /* Command IDs */
  12. #define DPIO_CMDID_CLOSE 0x800
  13. #define DPIO_CMDID_OPEN 0x803
  14. #define DPIO_CMDID_CREATE 0x903
  15. #define DPIO_CMDID_DESTROY 0x900
  16. #define DPIO_CMDID_ENABLE 0x002
  17. #define DPIO_CMDID_DISABLE 0x003
  18. #define DPIO_CMDID_GET_ATTR 0x004
  19. #define DPIO_CMDID_RESET 0x005
  20. /* cmd, param, offset, width, type, arg_name */
  21. #define DPIO_CMD_OPEN(cmd, dpio_id) \
  22. MC_CMD_OP(cmd, 0, 0, 32, int, dpio_id)
  23. /* cmd, param, offset, width, type, arg_name */
  24. #define DPIO_CMD_CREATE(cmd, cfg) \
  25. do { \
  26. MC_CMD_OP(cmd, 0, 16, 2, enum dpio_channel_mode, \
  27. cfg->channel_mode);\
  28. MC_CMD_OP(cmd, 0, 32, 8, uint8_t, cfg->num_priorities);\
  29. } while (0)
  30. /* cmd, param, offset, width, type, arg_name */
  31. #define DPIO_RSP_GET_ATTR(cmd, attr) \
  32. do { \
  33. MC_RSP_OP(cmd, 0, 0, 32, int, attr->id);\
  34. MC_RSP_OP(cmd, 0, 32, 16, uint16_t, attr->qbman_portal_id);\
  35. MC_RSP_OP(cmd, 0, 48, 8, uint8_t, attr->num_priorities);\
  36. MC_RSP_OP(cmd, 0, 56, 4, enum dpio_channel_mode, attr->channel_mode);\
  37. MC_RSP_OP(cmd, 1, 0, 64, uint64_t, attr->qbman_portal_ce_offset);\
  38. MC_RSP_OP(cmd, 2, 0, 64, uint64_t, attr->qbman_portal_ci_offset);\
  39. MC_RSP_OP(cmd, 3, 0, 16, uint16_t, attr->version.major);\
  40. MC_RSP_OP(cmd, 3, 16, 16, uint16_t, attr->version.minor);\
  41. MC_RSP_OP(cmd, 3, 32, 32, uint32_t, attr->qbman_version);\
  42. } while (0)
  43. /* Data Path I/O Portal API
  44. * Contains initialization APIs and runtime control APIs for DPIO
  45. */
  46. struct fsl_mc_io;
  47. /**
  48. * dpio_open() - Open a control session for the specified object
  49. * @mc_io: Pointer to MC portal's I/O object
  50. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  51. * @dpio_id: DPIO unique ID
  52. * @token: Returned token; use in subsequent API calls
  53. *
  54. * This function can be used to open a control session for an
  55. * already created object; an object may have been declared in
  56. * the DPL or by calling the dpio_create() function.
  57. * This function returns a unique authentication token,
  58. * associated with the specific object ID and the specific MC
  59. * portal; this token must be used in all subsequent commands for
  60. * this specific object.
  61. *
  62. * Return: '0' on Success; Error code otherwise.
  63. */
  64. int dpio_open(struct fsl_mc_io *mc_io,
  65. uint32_t cmd_flags,
  66. int dpio_id,
  67. uint16_t *token);
  68. /**
  69. * dpio_close() - Close the control session of the object
  70. * @mc_io: Pointer to MC portal's I/O object
  71. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  72. * @token: Token of DPIO object
  73. *
  74. * Return: '0' on Success; Error code otherwise.
  75. */
  76. int dpio_close(struct fsl_mc_io *mc_io,
  77. uint32_t cmd_flags,
  78. uint16_t token);
  79. /**
  80. * enum dpio_channel_mode - DPIO notification channel mode
  81. * @DPIO_NO_CHANNEL: No support for notification channel
  82. * @DPIO_LOCAL_CHANNEL: Notifications on data availability can be received by a
  83. * dedicated channel in the DPIO; user should point the queue's
  84. * destination in the relevant interface to this DPIO
  85. */
  86. enum dpio_channel_mode {
  87. DPIO_NO_CHANNEL = 0,
  88. DPIO_LOCAL_CHANNEL = 1,
  89. };
  90. /**
  91. * struct dpio_cfg - Structure representing DPIO configuration
  92. * @channel_mode: Notification channel mode
  93. * @num_priorities: Number of priorities for the notification channel (1-8);
  94. * relevant only if 'channel_mode = DPIO_LOCAL_CHANNEL'
  95. */
  96. struct dpio_cfg {
  97. enum dpio_channel_mode channel_mode;
  98. uint8_t num_priorities;
  99. };
  100. /**
  101. * dpio_create() - Create the DPIO object.
  102. * @mc_io: Pointer to MC portal's I/O object
  103. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  104. * @cfg: Configuration structure
  105. * @token: Returned token; use in subsequent API calls
  106. *
  107. * Create the DPIO object, allocate required resources and
  108. * perform required initialization.
  109. *
  110. * The object can be created either by declaring it in the
  111. * DPL file, or by calling this function.
  112. *
  113. * This function returns a unique authentication token,
  114. * associated with the specific object ID and the specific MC
  115. * portal; this token must be used in all subsequent calls to
  116. * this specific object. For objects that are created using the
  117. * DPL file, call dpio_open() function to get an authentication
  118. * token first.
  119. *
  120. * Return: '0' on Success; Error code otherwise.
  121. */
  122. int dpio_create(struct fsl_mc_io *mc_io,
  123. uint32_t cmd_flags,
  124. const struct dpio_cfg *cfg,
  125. uint16_t *token);
  126. /**
  127. * dpio_destroy() - Destroy the DPIO object and release all its resources.
  128. * @mc_io: Pointer to MC portal's I/O object
  129. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  130. * @token: Token of DPIO object
  131. *
  132. * Return: '0' on Success; Error code otherwise
  133. */
  134. int dpio_destroy(struct fsl_mc_io *mc_io,
  135. uint32_t cmd_flags,
  136. uint16_t token);
  137. /**
  138. * dpio_enable() - Enable the DPIO, allow I/O portal operations.
  139. * @mc_io: Pointer to MC portal's I/O object
  140. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  141. * @token: Token of DPIO object
  142. *
  143. * Return: '0' on Success; Error code otherwise
  144. */
  145. int dpio_enable(struct fsl_mc_io *mc_io,
  146. uint32_t cmd_flags,
  147. uint16_t token);
  148. /**
  149. * dpio_disable() - Disable the DPIO, stop any I/O portal operation.
  150. * @mc_io: Pointer to MC portal's I/O object
  151. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  152. * @token: Token of DPIO object
  153. *
  154. * Return: '0' on Success; Error code otherwise
  155. */
  156. int dpio_disable(struct fsl_mc_io *mc_io,
  157. uint32_t cmd_flags,
  158. uint16_t token);
  159. /**
  160. * dpio_reset() - Reset the DPIO, returns the object to initial state.
  161. * @mc_io: Pointer to MC portal's I/O object
  162. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  163. * @token: Token of DPIO object
  164. *
  165. * Return: '0' on Success; Error code otherwise.
  166. */
  167. int dpio_reset(struct fsl_mc_io *mc_io,
  168. uint32_t cmd_flags,
  169. uint16_t token);
  170. /**
  171. * struct dpio_attr - Structure representing DPIO attributes
  172. * @id: DPIO object ID
  173. * @version: DPIO version
  174. * @qbman_portal_ce_offset: offset of the software portal cache-enabled area
  175. * @qbman_portal_ci_offset: offset of the software portal cache-inhibited area
  176. * @qbman_portal_id: Software portal ID
  177. * @channel_mode: Notification channel mode
  178. * @num_priorities: Number of priorities for the notification channel (1-8);
  179. * relevant only if 'channel_mode = DPIO_LOCAL_CHANNEL'
  180. * @qbman_version: QBMAN version
  181. */
  182. struct dpio_attr {
  183. int id;
  184. /**
  185. * struct version - DPIO version
  186. * @major: DPIO major version
  187. * @minor: DPIO minor version
  188. */
  189. struct {
  190. uint16_t major;
  191. uint16_t minor;
  192. } version;
  193. uint64_t qbman_portal_ce_offset;
  194. uint64_t qbman_portal_ci_offset;
  195. uint16_t qbman_portal_id;
  196. enum dpio_channel_mode channel_mode;
  197. uint8_t num_priorities;
  198. uint32_t qbman_version;
  199. };
  200. /**
  201. * dpio_get_attributes() - Retrieve DPIO attributes
  202. * @mc_io: Pointer to MC portal's I/O object
  203. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  204. * @token: Token of DPIO object
  205. * @attr: Returned object's attributes
  206. *
  207. * Return: '0' on Success; Error code otherwise
  208. */
  209. int dpio_get_attributes(struct fsl_mc_io *mc_io,
  210. uint32_t cmd_flags,
  211. uint16_t token,
  212. struct dpio_attr *attr);
  213. #endif /* _FSL_DPIO_H */