fsl_dprc.h 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957
  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. #ifndef _FSL_DPRC_H
  9. #define _FSL_DPRC_H
  10. /* DPRC Version */
  11. #define DPRC_VER_MAJOR 6
  12. #define DPRC_VER_MINOR 1
  13. /* Command IDs */
  14. #define DPRC_CMDID_CLOSE 0x8001
  15. #define DPRC_CMDID_OPEN 0x8051
  16. #define DPRC_CMDID_CREATE 0x9051
  17. #define DPRC_CMDID_GET_ATTR 0x0041
  18. #define DPRC_CMDID_RESET_CONT 0x0051
  19. #define DPRC_CMDID_GET_API_VERSION 0xa051
  20. #define DPRC_CMDID_CREATE_CONT 0x1511
  21. #define DPRC_CMDID_DESTROY_CONT 0x1521
  22. #define DPRC_CMDID_GET_CONT_ID 0x8301
  23. #define DPRC_CMDID_GET_OBJ_COUNT 0x1591
  24. #define DPRC_CMDID_GET_OBJ 0x15A1
  25. #define DPRC_CMDID_GET_RES_COUNT 0x15B1
  26. #define DPRC_CMDID_GET_RES_IDS 0x15C1
  27. #define DPRC_CMDID_GET_OBJ_REG 0x15E1
  28. #define DPRC_CMDID_CONNECT 0x1671
  29. #define DPRC_CMDID_DISCONNECT 0x1681
  30. #define DPRC_CMDID_GET_CONNECTION 0x16C1
  31. /* cmd, param, offset, width, type, arg_name */
  32. #define DPRC_RSP_GET_CONTAINER_ID(cmd, container_id) \
  33. MC_RSP_OP(cmd, 0, 0, 32, int, container_id)
  34. /* cmd, param, offset, width, type, arg_name */
  35. #define DPRC_CMD_OPEN(cmd, container_id) \
  36. MC_CMD_OP(cmd, 0, 0, 32, int, container_id)
  37. /* cmd, param, offset, width, type, arg_name */
  38. #define DPRC_CMD_CREATE_CONTAINER(cmd, cfg) \
  39. do { \
  40. MC_CMD_OP(cmd, 0, 32, 16, uint16_t, cfg->icid); \
  41. MC_CMD_OP(cmd, 0, 0, 32, uint32_t, cfg->options); \
  42. MC_CMD_OP(cmd, 1, 32, 32, int, cfg->portal_id); \
  43. MC_CMD_OP(cmd, 2, 0, 8, char, cfg->label[0]);\
  44. MC_CMD_OP(cmd, 2, 8, 8, char, cfg->label[1]);\
  45. MC_CMD_OP(cmd, 2, 16, 8, char, cfg->label[2]);\
  46. MC_CMD_OP(cmd, 2, 24, 8, char, cfg->label[3]);\
  47. MC_CMD_OP(cmd, 2, 32, 8, char, cfg->label[4]);\
  48. MC_CMD_OP(cmd, 2, 40, 8, char, cfg->label[5]);\
  49. MC_CMD_OP(cmd, 2, 48, 8, char, cfg->label[6]);\
  50. MC_CMD_OP(cmd, 2, 56, 8, char, cfg->label[7]);\
  51. MC_CMD_OP(cmd, 3, 0, 8, char, cfg->label[8]);\
  52. MC_CMD_OP(cmd, 3, 8, 8, char, cfg->label[9]);\
  53. MC_CMD_OP(cmd, 3, 16, 8, char, cfg->label[10]);\
  54. MC_CMD_OP(cmd, 3, 24, 8, char, cfg->label[11]);\
  55. MC_CMD_OP(cmd, 3, 32, 8, char, cfg->label[12]);\
  56. MC_CMD_OP(cmd, 3, 40, 8, char, cfg->label[13]);\
  57. MC_CMD_OP(cmd, 3, 48, 8, char, cfg->label[14]);\
  58. MC_CMD_OP(cmd, 3, 56, 8, char, cfg->label[15]);\
  59. } while (0)
  60. /* cmd, param, offset, width, type, arg_name */
  61. #define DPRC_RSP_CREATE_CONTAINER(cmd, child_container_id, child_portal_offset)\
  62. do { \
  63. MC_RSP_OP(cmd, 1, 0, 32, int, child_container_id); \
  64. MC_RSP_OP(cmd, 2, 0, 64, uint64_t, child_portal_offset);\
  65. } while (0)
  66. /* cmd, param, offset, width, type, arg_name */
  67. #define DPRC_CMD_DESTROY_CONTAINER(cmd, child_container_id) \
  68. MC_CMD_OP(cmd, 0, 0, 32, int, child_container_id)
  69. /* cmd, param, offset, width, type, arg_name */
  70. #define DPRC_CMD_RESET_CONTAINER(cmd, child_container_id) \
  71. MC_CMD_OP(cmd, 0, 0, 32, int, child_container_id)
  72. /* cmd, param, offset, width, type, arg_name */
  73. #define DPRC_RSP_GET_ATTRIBUTES(cmd, attr) \
  74. do { \
  75. MC_RSP_OP(cmd, 0, 0, 32, int, attr->container_id); \
  76. MC_RSP_OP(cmd, 0, 32, 16, uint16_t, attr->icid); \
  77. MC_RSP_OP(cmd, 1, 0, 32, uint32_t, attr->options);\
  78. MC_RSP_OP(cmd, 1, 32, 32, int, attr->portal_id); \
  79. } while (0)
  80. /* cmd, param, offset, width, type, arg_name */
  81. #define DPRC_RSP_GET_OBJ_COUNT(cmd, obj_count) \
  82. MC_RSP_OP(cmd, 0, 32, 32, int, obj_count)
  83. /* cmd, param, offset, width, type, arg_name */
  84. #define DPRC_CMD_GET_OBJ(cmd, obj_index) \
  85. MC_CMD_OP(cmd, 0, 0, 32, int, obj_index)
  86. /* cmd, param, offset, width, type, arg_name */
  87. #define DPRC_RSP_GET_OBJ(cmd, obj_desc) \
  88. do { \
  89. MC_RSP_OP(cmd, 0, 32, 32, int, obj_desc->id); \
  90. MC_RSP_OP(cmd, 1, 0, 16, uint16_t, obj_desc->vendor); \
  91. MC_RSP_OP(cmd, 1, 16, 8, uint8_t, obj_desc->irq_count); \
  92. MC_RSP_OP(cmd, 1, 24, 8, uint8_t, obj_desc->region_count); \
  93. MC_RSP_OP(cmd, 1, 32, 32, uint32_t, obj_desc->state);\
  94. MC_RSP_OP(cmd, 2, 0, 16, uint16_t, obj_desc->ver_major);\
  95. MC_RSP_OP(cmd, 2, 16, 16, uint16_t, obj_desc->ver_minor);\
  96. MC_RSP_OP(cmd, 2, 32, 16, uint16_t, obj_desc->flags); \
  97. MC_RSP_OP(cmd, 3, 0, 8, char, obj_desc->type[0]);\
  98. MC_RSP_OP(cmd, 3, 8, 8, char, obj_desc->type[1]);\
  99. MC_RSP_OP(cmd, 3, 16, 8, char, obj_desc->type[2]);\
  100. MC_RSP_OP(cmd, 3, 24, 8, char, obj_desc->type[3]);\
  101. MC_RSP_OP(cmd, 3, 32, 8, char, obj_desc->type[4]);\
  102. MC_RSP_OP(cmd, 3, 40, 8, char, obj_desc->type[5]);\
  103. MC_RSP_OP(cmd, 3, 48, 8, char, obj_desc->type[6]);\
  104. MC_RSP_OP(cmd, 3, 56, 8, char, obj_desc->type[7]);\
  105. MC_RSP_OP(cmd, 4, 0, 8, char, obj_desc->type[8]);\
  106. MC_RSP_OP(cmd, 4, 8, 8, char, obj_desc->type[9]);\
  107. MC_RSP_OP(cmd, 4, 16, 8, char, obj_desc->type[10]);\
  108. MC_RSP_OP(cmd, 4, 24, 8, char, obj_desc->type[11]);\
  109. MC_RSP_OP(cmd, 4, 32, 8, char, obj_desc->type[12]);\
  110. MC_RSP_OP(cmd, 4, 40, 8, char, obj_desc->type[13]);\
  111. MC_RSP_OP(cmd, 4, 48, 8, char, obj_desc->type[14]);\
  112. MC_RSP_OP(cmd, 4, 56, 8, char, obj_desc->type[15]);\
  113. MC_RSP_OP(cmd, 5, 0, 8, char, obj_desc->label[0]);\
  114. MC_RSP_OP(cmd, 5, 8, 8, char, obj_desc->label[1]);\
  115. MC_RSP_OP(cmd, 5, 16, 8, char, obj_desc->label[2]);\
  116. MC_RSP_OP(cmd, 5, 24, 8, char, obj_desc->label[3]);\
  117. MC_RSP_OP(cmd, 5, 32, 8, char, obj_desc->label[4]);\
  118. MC_RSP_OP(cmd, 5, 40, 8, char, obj_desc->label[5]);\
  119. MC_RSP_OP(cmd, 5, 48, 8, char, obj_desc->label[6]);\
  120. MC_RSP_OP(cmd, 5, 56, 8, char, obj_desc->label[7]);\
  121. MC_RSP_OP(cmd, 6, 0, 8, char, obj_desc->label[8]);\
  122. MC_RSP_OP(cmd, 6, 8, 8, char, obj_desc->label[9]);\
  123. MC_RSP_OP(cmd, 6, 16, 8, char, obj_desc->label[10]);\
  124. MC_RSP_OP(cmd, 6, 24, 8, char, obj_desc->label[11]);\
  125. MC_RSP_OP(cmd, 6, 32, 8, char, obj_desc->label[12]);\
  126. MC_RSP_OP(cmd, 6, 40, 8, char, obj_desc->label[13]);\
  127. MC_RSP_OP(cmd, 6, 48, 8, char, obj_desc->label[14]);\
  128. MC_RSP_OP(cmd, 6, 56, 8, char, obj_desc->label[15]);\
  129. } while (0)
  130. /* cmd, param, offset, width, type, arg_name */
  131. #define DPRC_CMD_GET_OBJ_DESC(cmd, obj_type, obj_id) \
  132. do { \
  133. MC_CMD_OP(cmd, 0, 0, 32, int, obj_id);\
  134. MC_CMD_OP(cmd, 1, 0, 8, char, obj_type[0]);\
  135. MC_CMD_OP(cmd, 1, 8, 8, char, obj_type[1]);\
  136. MC_CMD_OP(cmd, 1, 16, 8, char, obj_type[2]);\
  137. MC_CMD_OP(cmd, 1, 24, 8, char, obj_type[3]);\
  138. MC_CMD_OP(cmd, 1, 32, 8, char, obj_type[4]);\
  139. MC_CMD_OP(cmd, 1, 40, 8, char, obj_type[5]);\
  140. MC_CMD_OP(cmd, 1, 48, 8, char, obj_type[6]);\
  141. MC_CMD_OP(cmd, 1, 56, 8, char, obj_type[7]);\
  142. MC_CMD_OP(cmd, 2, 0, 8, char, obj_type[8]);\
  143. MC_CMD_OP(cmd, 2, 8, 8, char, obj_type[9]);\
  144. MC_CMD_OP(cmd, 2, 16, 8, char, obj_type[10]);\
  145. MC_CMD_OP(cmd, 2, 24, 8, char, obj_type[11]);\
  146. MC_CMD_OP(cmd, 2, 32, 8, char, obj_type[12]);\
  147. MC_CMD_OP(cmd, 2, 40, 8, char, obj_type[13]);\
  148. MC_CMD_OP(cmd, 2, 48, 8, char, obj_type[14]);\
  149. MC_CMD_OP(cmd, 2, 56, 8, char, obj_type[15]);\
  150. } while (0)
  151. /* cmd, param, offset, width, type, arg_name */
  152. #define DPRC_RSP_GET_OBJ_DESC(cmd, obj_desc) \
  153. do { \
  154. MC_RSP_OP(cmd, 0, 32, 32, int, obj_desc->id); \
  155. MC_RSP_OP(cmd, 1, 0, 16, uint16_t, obj_desc->vendor); \
  156. MC_RSP_OP(cmd, 1, 16, 8, uint8_t, obj_desc->irq_count); \
  157. MC_RSP_OP(cmd, 1, 24, 8, uint8_t, obj_desc->region_count); \
  158. MC_RSP_OP(cmd, 1, 32, 32, uint32_t, obj_desc->state);\
  159. MC_RSP_OP(cmd, 2, 0, 16, uint16_t, obj_desc->ver_major);\
  160. MC_RSP_OP(cmd, 2, 16, 16, uint16_t, obj_desc->ver_minor);\
  161. MC_RSP_OP(cmd, 2, 32, 16, uint16_t, obj_desc->flags); \
  162. MC_RSP_OP(cmd, 3, 0, 8, char, obj_desc->type[0]);\
  163. MC_RSP_OP(cmd, 3, 8, 8, char, obj_desc->type[1]);\
  164. MC_RSP_OP(cmd, 3, 16, 8, char, obj_desc->type[2]);\
  165. MC_RSP_OP(cmd, 3, 24, 8, char, obj_desc->type[3]);\
  166. MC_RSP_OP(cmd, 3, 32, 8, char, obj_desc->type[4]);\
  167. MC_RSP_OP(cmd, 3, 40, 8, char, obj_desc->type[5]);\
  168. MC_RSP_OP(cmd, 3, 48, 8, char, obj_desc->type[6]);\
  169. MC_RSP_OP(cmd, 3, 56, 8, char, obj_desc->type[7]);\
  170. MC_RSP_OP(cmd, 4, 0, 8, char, obj_desc->type[8]);\
  171. MC_RSP_OP(cmd, 4, 8, 8, char, obj_desc->type[9]);\
  172. MC_RSP_OP(cmd, 4, 16, 8, char, obj_desc->type[10]);\
  173. MC_RSP_OP(cmd, 4, 24, 8, char, obj_desc->type[11]);\
  174. MC_RSP_OP(cmd, 4, 32, 8, char, obj_desc->type[12]);\
  175. MC_RSP_OP(cmd, 4, 40, 8, char, obj_desc->type[13]);\
  176. MC_RSP_OP(cmd, 4, 48, 8, char, obj_desc->type[14]);\
  177. MC_RSP_OP(cmd, 4, 56, 8, char, obj_desc->type[15]);\
  178. MC_RSP_OP(cmd, 5, 0, 8, char, obj_desc->label[0]);\
  179. MC_RSP_OP(cmd, 5, 8, 8, char, obj_desc->label[1]);\
  180. MC_RSP_OP(cmd, 5, 16, 8, char, obj_desc->label[2]);\
  181. MC_RSP_OP(cmd, 5, 24, 8, char, obj_desc->label[3]);\
  182. MC_RSP_OP(cmd, 5, 32, 8, char, obj_desc->label[4]);\
  183. MC_RSP_OP(cmd, 5, 40, 8, char, obj_desc->label[5]);\
  184. MC_RSP_OP(cmd, 5, 48, 8, char, obj_desc->label[6]);\
  185. MC_RSP_OP(cmd, 5, 56, 8, char, obj_desc->label[7]);\
  186. MC_RSP_OP(cmd, 6, 0, 8, char, obj_desc->label[8]);\
  187. MC_RSP_OP(cmd, 6, 8, 8, char, obj_desc->label[9]);\
  188. MC_RSP_OP(cmd, 6, 16, 8, char, obj_desc->label[10]);\
  189. MC_RSP_OP(cmd, 6, 24, 8, char, obj_desc->label[11]);\
  190. MC_RSP_OP(cmd, 6, 32, 8, char, obj_desc->label[12]);\
  191. MC_RSP_OP(cmd, 6, 40, 8, char, obj_desc->label[13]);\
  192. MC_RSP_OP(cmd, 6, 48, 8, char, obj_desc->label[14]);\
  193. MC_RSP_OP(cmd, 6, 56, 8, char, obj_desc->label[15]);\
  194. } while (0)
  195. /* cmd, param, offset, width, type, arg_name */
  196. #define DPRC_CMD_GET_RES_COUNT(cmd, type) \
  197. do { \
  198. MC_CMD_OP(cmd, 1, 0, 8, char, type[0]);\
  199. MC_CMD_OP(cmd, 1, 8, 8, char, type[1]);\
  200. MC_CMD_OP(cmd, 1, 16, 8, char, type[2]);\
  201. MC_CMD_OP(cmd, 1, 24, 8, char, type[3]);\
  202. MC_CMD_OP(cmd, 1, 32, 8, char, type[4]);\
  203. MC_CMD_OP(cmd, 1, 40, 8, char, type[5]);\
  204. MC_CMD_OP(cmd, 1, 48, 8, char, type[6]);\
  205. MC_CMD_OP(cmd, 1, 56, 8, char, type[7]);\
  206. MC_CMD_OP(cmd, 2, 0, 8, char, type[8]);\
  207. MC_CMD_OP(cmd, 2, 8, 8, char, type[9]);\
  208. MC_CMD_OP(cmd, 2, 16, 8, char, type[10]);\
  209. MC_CMD_OP(cmd, 2, 24, 8, char, type[11]);\
  210. MC_CMD_OP(cmd, 2, 32, 8, char, type[12]);\
  211. MC_CMD_OP(cmd, 2, 40, 8, char, type[13]);\
  212. MC_CMD_OP(cmd, 2, 48, 8, char, type[14]);\
  213. MC_CMD_OP(cmd, 2, 56, 8, char, type[15]);\
  214. } while (0)
  215. /* cmd, param, offset, width, type, arg_name */
  216. #define DPRC_RSP_GET_RES_COUNT(cmd, res_count) \
  217. MC_RSP_OP(cmd, 0, 0, 32, int, res_count)
  218. /* cmd, param, offset, width, type, arg_name */
  219. #define DPRC_CMD_GET_RES_IDS(cmd, range_desc, type) \
  220. do { \
  221. MC_CMD_OP(cmd, 0, 42, 7, enum dprc_iter_status, \
  222. range_desc->iter_status); \
  223. MC_CMD_OP(cmd, 1, 0, 32, int, range_desc->base_id); \
  224. MC_CMD_OP(cmd, 1, 32, 32, int, range_desc->last_id);\
  225. MC_CMD_OP(cmd, 2, 0, 8, char, type[0]);\
  226. MC_CMD_OP(cmd, 2, 8, 8, char, type[1]);\
  227. MC_CMD_OP(cmd, 2, 16, 8, char, type[2]);\
  228. MC_CMD_OP(cmd, 2, 24, 8, char, type[3]);\
  229. MC_CMD_OP(cmd, 2, 32, 8, char, type[4]);\
  230. MC_CMD_OP(cmd, 2, 40, 8, char, type[5]);\
  231. MC_CMD_OP(cmd, 2, 48, 8, char, type[6]);\
  232. MC_CMD_OP(cmd, 2, 56, 8, char, type[7]);\
  233. MC_CMD_OP(cmd, 3, 0, 8, char, type[8]);\
  234. MC_CMD_OP(cmd, 3, 8, 8, char, type[9]);\
  235. MC_CMD_OP(cmd, 3, 16, 8, char, type[10]);\
  236. MC_CMD_OP(cmd, 3, 24, 8, char, type[11]);\
  237. MC_CMD_OP(cmd, 3, 32, 8, char, type[12]);\
  238. MC_CMD_OP(cmd, 3, 40, 8, char, type[13]);\
  239. MC_CMD_OP(cmd, 3, 48, 8, char, type[14]);\
  240. MC_CMD_OP(cmd, 3, 56, 8, char, type[15]);\
  241. } while (0)
  242. /* cmd, param, offset, width, type, arg_name */
  243. #define DPRC_RSP_GET_RES_IDS(cmd, range_desc) \
  244. do { \
  245. MC_RSP_OP(cmd, 0, 42, 7, enum dprc_iter_status, \
  246. range_desc->iter_status);\
  247. MC_RSP_OP(cmd, 1, 0, 32, int, range_desc->base_id); \
  248. MC_RSP_OP(cmd, 1, 32, 32, int, range_desc->last_id);\
  249. } while (0)
  250. /* cmd, param, offset, width, type, arg_name */
  251. #define DPRC_CMD_GET_OBJ_REGION(cmd, obj_type, obj_id, region_index) \
  252. do { \
  253. MC_CMD_OP(cmd, 0, 0, 32, int, obj_id); \
  254. MC_CMD_OP(cmd, 0, 48, 8, uint8_t, region_index);\
  255. MC_CMD_OP(cmd, 3, 0, 8, char, obj_type[0]);\
  256. MC_CMD_OP(cmd, 3, 8, 8, char, obj_type[1]);\
  257. MC_CMD_OP(cmd, 3, 16, 8, char, obj_type[2]);\
  258. MC_CMD_OP(cmd, 3, 24, 8, char, obj_type[3]);\
  259. MC_CMD_OP(cmd, 3, 32, 8, char, obj_type[4]);\
  260. MC_CMD_OP(cmd, 3, 40, 8, char, obj_type[5]);\
  261. MC_CMD_OP(cmd, 3, 48, 8, char, obj_type[6]);\
  262. MC_CMD_OP(cmd, 3, 56, 8, char, obj_type[7]);\
  263. MC_CMD_OP(cmd, 4, 0, 8, char, obj_type[8]);\
  264. MC_CMD_OP(cmd, 4, 8, 8, char, obj_type[9]);\
  265. MC_CMD_OP(cmd, 4, 16, 8, char, obj_type[10]);\
  266. MC_CMD_OP(cmd, 4, 24, 8, char, obj_type[11]);\
  267. MC_CMD_OP(cmd, 4, 32, 8, char, obj_type[12]);\
  268. MC_CMD_OP(cmd, 4, 40, 8, char, obj_type[13]);\
  269. MC_CMD_OP(cmd, 4, 48, 8, char, obj_type[14]);\
  270. MC_CMD_OP(cmd, 4, 56, 8, char, obj_type[15]);\
  271. } while (0)
  272. /* param, offset, width, type, arg_name */
  273. #define DPRC_RSP_GET_OBJ_REGION(cmd, region_desc) \
  274. do { \
  275. MC_RSP_OP(cmd, 1, 0, 32, uint32_t, region_desc->base_offset);\
  276. MC_RSP_OP(cmd, 2, 0, 32, uint32_t, region_desc->size); \
  277. MC_RSP_OP(cmd, 2, 32, 4, enum dprc_region_type, region_desc->type);\
  278. MC_RSP_OP(cmd, 3, 0, 32, uint32_t, region_desc->flags);\
  279. } while (0)
  280. /* cmd, param, offset, width, type, arg_name */
  281. #define DPRC_CMD_SET_OBJ_LABEL(cmd, obj_type, obj_id, label) \
  282. do { \
  283. MC_CMD_OP(cmd, 0, 0, 32, int, obj_id); \
  284. MC_CMD_OP(cmd, 1, 0, 8, char, label[0]);\
  285. MC_CMD_OP(cmd, 1, 8, 8, char, label[1]);\
  286. MC_CMD_OP(cmd, 1, 16, 8, char, label[2]);\
  287. MC_CMD_OP(cmd, 1, 24, 8, char, label[3]);\
  288. MC_CMD_OP(cmd, 1, 32, 8, char, label[4]);\
  289. MC_CMD_OP(cmd, 1, 40, 8, char, label[5]);\
  290. MC_CMD_OP(cmd, 1, 48, 8, char, label[6]);\
  291. MC_CMD_OP(cmd, 1, 56, 8, char, label[7]);\
  292. MC_CMD_OP(cmd, 2, 0, 8, char, label[8]);\
  293. MC_CMD_OP(cmd, 2, 8, 8, char, label[9]);\
  294. MC_CMD_OP(cmd, 2, 16, 8, char, label[10]);\
  295. MC_CMD_OP(cmd, 2, 24, 8, char, label[11]);\
  296. MC_CMD_OP(cmd, 2, 32, 8, char, label[12]);\
  297. MC_CMD_OP(cmd, 2, 40, 8, char, label[13]);\
  298. MC_CMD_OP(cmd, 2, 48, 8, char, label[14]);\
  299. MC_CMD_OP(cmd, 2, 56, 8, char, label[15]);\
  300. MC_CMD_OP(cmd, 3, 0, 8, char, obj_type[0]);\
  301. MC_CMD_OP(cmd, 3, 8, 8, char, obj_type[1]);\
  302. MC_CMD_OP(cmd, 3, 16, 8, char, obj_type[2]);\
  303. MC_CMD_OP(cmd, 3, 24, 8, char, obj_type[3]);\
  304. MC_CMD_OP(cmd, 3, 32, 8, char, obj_type[4]);\
  305. MC_CMD_OP(cmd, 3, 40, 8, char, obj_type[5]);\
  306. MC_CMD_OP(cmd, 3, 48, 8, char, obj_type[6]);\
  307. MC_CMD_OP(cmd, 3, 56, 8, char, obj_type[7]);\
  308. MC_CMD_OP(cmd, 4, 0, 8, char, obj_type[8]);\
  309. MC_CMD_OP(cmd, 4, 8, 8, char, obj_type[9]);\
  310. MC_CMD_OP(cmd, 4, 16, 8, char, obj_type[10]);\
  311. MC_CMD_OP(cmd, 4, 24, 8, char, obj_type[11]);\
  312. MC_CMD_OP(cmd, 4, 32, 8, char, obj_type[12]);\
  313. MC_CMD_OP(cmd, 4, 40, 8, char, obj_type[13]);\
  314. MC_CMD_OP(cmd, 4, 48, 8, char, obj_type[14]);\
  315. MC_CMD_OP(cmd, 4, 56, 8, char, obj_type[15]);\
  316. } while (0)
  317. /* cmd, param, offset, width, type, arg_name */
  318. #define DPRC_CMD_CONNECT(cmd, endpoint1, endpoint2, cfg) \
  319. do { \
  320. MC_CMD_OP(cmd, 0, 0, 32, int, endpoint1->id); \
  321. MC_CMD_OP(cmd, 0, 32, 32, int, endpoint1->if_id); \
  322. MC_CMD_OP(cmd, 1, 0, 32, int, endpoint2->id); \
  323. MC_CMD_OP(cmd, 1, 32, 32, int, endpoint2->if_id); \
  324. MC_CMD_OP(cmd, 2, 0, 8, char, endpoint1->type[0]); \
  325. MC_CMD_OP(cmd, 2, 8, 8, char, endpoint1->type[1]); \
  326. MC_CMD_OP(cmd, 2, 16, 8, char, endpoint1->type[2]); \
  327. MC_CMD_OP(cmd, 2, 24, 8, char, endpoint1->type[3]); \
  328. MC_CMD_OP(cmd, 2, 32, 8, char, endpoint1->type[4]); \
  329. MC_CMD_OP(cmd, 2, 40, 8, char, endpoint1->type[5]); \
  330. MC_CMD_OP(cmd, 2, 48, 8, char, endpoint1->type[6]); \
  331. MC_CMD_OP(cmd, 2, 56, 8, char, endpoint1->type[7]); \
  332. MC_CMD_OP(cmd, 3, 0, 8, char, endpoint1->type[8]); \
  333. MC_CMD_OP(cmd, 3, 8, 8, char, endpoint1->type[9]); \
  334. MC_CMD_OP(cmd, 3, 16, 8, char, endpoint1->type[10]); \
  335. MC_CMD_OP(cmd, 3, 24, 8, char, endpoint1->type[11]); \
  336. MC_CMD_OP(cmd, 3, 32, 8, char, endpoint1->type[12]); \
  337. MC_CMD_OP(cmd, 3, 40, 8, char, endpoint1->type[13]); \
  338. MC_CMD_OP(cmd, 3, 48, 8, char, endpoint1->type[14]); \
  339. MC_CMD_OP(cmd, 3, 56, 8, char, endpoint1->type[15]); \
  340. MC_CMD_OP(cmd, 4, 0, 32, uint32_t, cfg->max_rate); \
  341. MC_CMD_OP(cmd, 4, 32, 32, uint32_t, cfg->committed_rate); \
  342. MC_CMD_OP(cmd, 5, 0, 8, char, endpoint2->type[0]); \
  343. MC_CMD_OP(cmd, 5, 8, 8, char, endpoint2->type[1]); \
  344. MC_CMD_OP(cmd, 5, 16, 8, char, endpoint2->type[2]); \
  345. MC_CMD_OP(cmd, 5, 24, 8, char, endpoint2->type[3]); \
  346. MC_CMD_OP(cmd, 5, 32, 8, char, endpoint2->type[4]); \
  347. MC_CMD_OP(cmd, 5, 40, 8, char, endpoint2->type[5]); \
  348. MC_CMD_OP(cmd, 5, 48, 8, char, endpoint2->type[6]); \
  349. MC_CMD_OP(cmd, 5, 56, 8, char, endpoint2->type[7]); \
  350. MC_CMD_OP(cmd, 6, 0, 8, char, endpoint2->type[8]); \
  351. MC_CMD_OP(cmd, 6, 8, 8, char, endpoint2->type[9]); \
  352. MC_CMD_OP(cmd, 6, 16, 8, char, endpoint2->type[10]); \
  353. MC_CMD_OP(cmd, 6, 24, 8, char, endpoint2->type[11]); \
  354. MC_CMD_OP(cmd, 6, 32, 8, char, endpoint2->type[12]); \
  355. MC_CMD_OP(cmd, 6, 40, 8, char, endpoint2->type[13]); \
  356. MC_CMD_OP(cmd, 6, 48, 8, char, endpoint2->type[14]); \
  357. MC_CMD_OP(cmd, 6, 56, 8, char, endpoint2->type[15]); \
  358. } while (0)
  359. /* cmd, param, offset, width, type, arg_name */
  360. #define DPRC_CMD_DISCONNECT(cmd, endpoint) \
  361. do { \
  362. MC_CMD_OP(cmd, 0, 0, 32, int, endpoint->id); \
  363. MC_CMD_OP(cmd, 0, 32, 16, uint16_t, endpoint->if_id); \
  364. MC_CMD_OP(cmd, 1, 0, 8, char, endpoint->type[0]); \
  365. MC_CMD_OP(cmd, 1, 8, 8, char, endpoint->type[1]); \
  366. MC_CMD_OP(cmd, 1, 16, 8, char, endpoint->type[2]); \
  367. MC_CMD_OP(cmd, 1, 24, 8, char, endpoint->type[3]); \
  368. MC_CMD_OP(cmd, 1, 32, 8, char, endpoint->type[4]); \
  369. MC_CMD_OP(cmd, 1, 40, 8, char, endpoint->type[5]); \
  370. MC_CMD_OP(cmd, 1, 48, 8, char, endpoint->type[6]); \
  371. MC_CMD_OP(cmd, 1, 56, 8, char, endpoint->type[7]); \
  372. MC_CMD_OP(cmd, 2, 0, 8, char, endpoint->type[8]); \
  373. MC_CMD_OP(cmd, 2, 8, 8, char, endpoint->type[9]); \
  374. MC_CMD_OP(cmd, 2, 16, 8, char, endpoint->type[10]); \
  375. MC_CMD_OP(cmd, 2, 24, 8, char, endpoint->type[11]); \
  376. MC_CMD_OP(cmd, 2, 32, 8, char, endpoint->type[12]); \
  377. MC_CMD_OP(cmd, 2, 40, 8, char, endpoint->type[13]); \
  378. MC_CMD_OP(cmd, 2, 48, 8, char, endpoint->type[14]); \
  379. MC_CMD_OP(cmd, 2, 56, 8, char, endpoint->type[15]); \
  380. } while (0)
  381. /* cmd, param, offset, width, type, arg_name */
  382. #define DPRC_CMD_GET_CONNECTION(cmd, endpoint1) \
  383. do { \
  384. MC_CMD_OP(cmd, 0, 0, 32, int, endpoint1->id); \
  385. MC_CMD_OP(cmd, 0, 32, 32, int, endpoint1->if_id); \
  386. MC_CMD_OP(cmd, 1, 0, 8, char, endpoint1->type[0]); \
  387. MC_CMD_OP(cmd, 1, 8, 8, char, endpoint1->type[1]); \
  388. MC_CMD_OP(cmd, 1, 16, 8, char, endpoint1->type[2]); \
  389. MC_CMD_OP(cmd, 1, 24, 8, char, endpoint1->type[3]); \
  390. MC_CMD_OP(cmd, 1, 32, 8, char, endpoint1->type[4]); \
  391. MC_CMD_OP(cmd, 1, 40, 8, char, endpoint1->type[5]); \
  392. MC_CMD_OP(cmd, 1, 48, 8, char, endpoint1->type[6]); \
  393. MC_CMD_OP(cmd, 1, 56, 8, char, endpoint1->type[7]); \
  394. MC_CMD_OP(cmd, 2, 0, 8, char, endpoint1->type[8]); \
  395. MC_CMD_OP(cmd, 2, 8, 8, char, endpoint1->type[9]); \
  396. MC_CMD_OP(cmd, 2, 16, 8, char, endpoint1->type[10]); \
  397. MC_CMD_OP(cmd, 2, 24, 8, char, endpoint1->type[11]); \
  398. MC_CMD_OP(cmd, 2, 32, 8, char, endpoint1->type[12]); \
  399. MC_CMD_OP(cmd, 2, 40, 8, char, endpoint1->type[13]); \
  400. MC_CMD_OP(cmd, 2, 48, 8, char, endpoint1->type[14]); \
  401. MC_CMD_OP(cmd, 2, 56, 8, char, endpoint1->type[15]); \
  402. } while (0)
  403. /* cmd, param, offset, width, type, arg_name */
  404. #define DPRC_RSP_GET_CONNECTION(cmd, endpoint2, state) \
  405. do { \
  406. MC_RSP_OP(cmd, 3, 0, 32, int, endpoint2->id); \
  407. MC_RSP_OP(cmd, 3, 32, 16, uint16_t, endpoint2->if_id); \
  408. MC_RSP_OP(cmd, 4, 0, 8, char, endpoint2->type[0]); \
  409. MC_RSP_OP(cmd, 4, 8, 8, char, endpoint2->type[1]); \
  410. MC_RSP_OP(cmd, 4, 16, 8, char, endpoint2->type[2]); \
  411. MC_RSP_OP(cmd, 4, 24, 8, char, endpoint2->type[3]); \
  412. MC_RSP_OP(cmd, 4, 32, 8, char, endpoint2->type[4]); \
  413. MC_RSP_OP(cmd, 4, 40, 8, char, endpoint2->type[5]); \
  414. MC_RSP_OP(cmd, 4, 48, 8, char, endpoint2->type[6]); \
  415. MC_RSP_OP(cmd, 4, 56, 8, char, endpoint2->type[7]); \
  416. MC_RSP_OP(cmd, 5, 0, 8, char, endpoint2->type[8]); \
  417. MC_RSP_OP(cmd, 5, 8, 8, char, endpoint2->type[9]); \
  418. MC_RSP_OP(cmd, 5, 16, 8, char, endpoint2->type[10]); \
  419. MC_RSP_OP(cmd, 5, 24, 8, char, endpoint2->type[11]); \
  420. MC_RSP_OP(cmd, 5, 32, 8, char, endpoint2->type[12]); \
  421. MC_RSP_OP(cmd, 5, 40, 8, char, endpoint2->type[13]); \
  422. MC_RSP_OP(cmd, 5, 48, 8, char, endpoint2->type[14]); \
  423. MC_RSP_OP(cmd, 5, 56, 8, char, endpoint2->type[15]); \
  424. MC_RSP_OP(cmd, 6, 0, 32, int, state); \
  425. } while (0)
  426. /* Data Path Resource Container API
  427. * Contains DPRC API for managing and querying DPAA resources
  428. */
  429. struct fsl_mc_io;
  430. /**
  431. * Set this value as the icid value in dprc_cfg structure when creating a
  432. * container, in case the ICID is not selected by the user and should be
  433. * allocated by the DPRC from the pool of ICIDs.
  434. */
  435. #define DPRC_GET_ICID_FROM_POOL (uint16_t)(~(0))
  436. /**
  437. * Set this value as the portal_id value in dprc_cfg structure when creating a
  438. * container, in case the portal ID is not specifically selected by the
  439. * user and should be allocated by the DPRC from the pool of portal ids.
  440. */
  441. #define DPRC_GET_PORTAL_ID_FROM_POOL (int)(~(0))
  442. /**
  443. * dprc_get_container_id() - Get container ID associated with a given portal.
  444. * @mc_io: Pointer to MC portal's I/O object
  445. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  446. * @container_id: Requested container ID
  447. *
  448. * Return: '0' on Success; Error code otherwise.
  449. */
  450. int dprc_get_container_id(struct fsl_mc_io *mc_io,
  451. uint32_t cmd_flags,
  452. int *container_id);
  453. /**
  454. * dprc_open() - Open DPRC object for use
  455. * @mc_io: Pointer to MC portal's I/O object
  456. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  457. * @container_id: Container ID to open
  458. * @token: Returned token of DPRC object
  459. *
  460. * Return: '0' on Success; Error code otherwise.
  461. *
  462. * @warning Required before any operation on the object.
  463. */
  464. int dprc_open(struct fsl_mc_io *mc_io,
  465. uint32_t cmd_flags,
  466. int container_id,
  467. uint16_t *token);
  468. /**
  469. * dprc_close() - Close the control session of the object
  470. * @mc_io: Pointer to MC portal's I/O object
  471. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  472. * @token: Token of DPRC object
  473. *
  474. * After this function is called, no further operations are
  475. * allowed on the object without opening a new control session.
  476. *
  477. * Return: '0' on Success; Error code otherwise.
  478. */
  479. int dprc_close(struct fsl_mc_io *mc_io,
  480. uint32_t cmd_flags,
  481. uint16_t token);
  482. /**
  483. * Container general options
  484. *
  485. * These options may be selected at container creation by the container creator
  486. * and can be retrieved using dprc_get_attributes()
  487. */
  488. /* Spawn Policy Option allowed - Indicates that the new container is allowed
  489. * to spawn and have its own child containers.
  490. */
  491. #define DPRC_CFG_OPT_SPAWN_ALLOWED 0x00000001
  492. /* General Container allocation policy - Indicates that the new container is
  493. * allowed to allocate requested resources from its parent container; if not
  494. * set, the container is only allowed to use resources in its own pools; Note
  495. * that this is a container's global policy, but the parent container may
  496. * override it and set specific quota per resource type.
  497. */
  498. #define DPRC_CFG_OPT_ALLOC_ALLOWED 0x00000002
  499. /* Object initialization allowed - software context associated with this
  500. * container is allowed to invoke object initialization operations.
  501. */
  502. #define DPRC_CFG_OPT_OBJ_CREATE_ALLOWED 0x00000004
  503. /* Topology change allowed - software context associated with this
  504. * container is allowed to invoke topology operations, such as attach/detach
  505. * of network objects.
  506. */
  507. #define DPRC_CFG_OPT_TOPOLOGY_CHANGES_ALLOWED 0x00000008
  508. /* AIOP - Indicates that container belongs to AIOP. */
  509. #define DPRC_CFG_OPT_AIOP 0x00000020
  510. /* IRQ Config - Indicates that the container allowed to configure its IRQs.*/
  511. #define DPRC_CFG_OPT_IRQ_CFG_ALLOWED 0x00000040
  512. /**
  513. * struct dprc_cfg - Container configuration options
  514. * @icid: Container's ICID; if set to 'DPRC_GET_ICID_FROM_POOL', a free
  515. * ICID value is allocated by the DPRC
  516. * @portal_id: Portal ID; if set to 'DPRC_GET_PORTAL_ID_FROM_POOL', a free
  517. * portal ID is allocated by the DPRC
  518. * @options: Combination of 'DPRC_CFG_OPT_<X>' options
  519. * @label: Object's label
  520. */
  521. struct dprc_cfg {
  522. uint16_t icid;
  523. int portal_id;
  524. uint64_t options;
  525. char label[16];
  526. };
  527. /**
  528. * dprc_create_container() - Create child container
  529. * @mc_io: Pointer to MC portal's I/O object
  530. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  531. * @token: Token of DPRC object
  532. * @cfg: Child container configuration
  533. * @child_container_id: Returned child container ID
  534. * @child_portal_offset: Returned child portal offset from MC portal base
  535. *
  536. *
  537. * Return: '0' on Success; Error code otherwise.
  538. */
  539. int dprc_create_container(struct fsl_mc_io *mc_io,
  540. uint32_t cmd_flags,
  541. uint16_t token,
  542. struct dprc_cfg *cfg,
  543. int *child_container_id,
  544. uint64_t *child_portal_offset);
  545. /**
  546. * dprc_destroy_container() - Destroy child container.
  547. * @mc_io: Pointer to MC portal's I/O object
  548. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  549. * @token: Token of DPRC object
  550. * @child_container_id: ID of the container to destroy
  551. *
  552. * This function terminates the child container, so following this call the
  553. * child container ID becomes invalid.
  554. *
  555. * Notes:
  556. * - All resources and objects of the destroyed container are returned to the
  557. * parent container or destroyed if were created be the destroyed container.
  558. * - This function destroy all the child containers of the specified
  559. * container prior to destroying the container itself.
  560. *
  561. * warning: Only the parent container is allowed to destroy a child policy
  562. * Container 0 can't be destroyed
  563. *
  564. * Return: '0' on Success; Error code otherwise.
  565. *
  566. */
  567. int dprc_destroy_container(struct fsl_mc_io *mc_io,
  568. uint32_t cmd_flags,
  569. uint16_t token,
  570. int child_container_id);
  571. /**
  572. * dprc_reset_container - Reset child container.
  573. * @mc_io: Pointer to MC portal's I/O object
  574. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  575. * @token: Token of DPRC object
  576. * @child_container_id: ID of the container to reset
  577. *
  578. * In case a software context crashes or becomes non-responsive, the parent
  579. * may wish to reset its resources container before the software context is
  580. * restarted.
  581. *
  582. * This routine informs all objects assigned to the child container that the
  583. * container is being reset, so they may perform any cleanup operations that are
  584. * needed. All objects handles that were owned by the child container shall be
  585. * closed.
  586. *
  587. * Note that such request may be submitted even if the child software context
  588. * has not crashed, but the resulting object cleanup operations will not be
  589. * aware of that.
  590. *
  591. * Return: '0' on Success; Error code otherwise.
  592. */
  593. int dprc_reset_container(struct fsl_mc_io *mc_io,
  594. uint32_t cmd_flags,
  595. uint16_t token,
  596. int child_container_id);
  597. /**
  598. * struct dprc_attributes - Container attributes
  599. * @container_id: Container's ID
  600. * @icid: Container's ICID
  601. * @portal_id: Container's portal ID
  602. * @options: Container's options as set at container's creation
  603. * @version: DPRC version
  604. */
  605. struct dprc_attributes {
  606. int container_id;
  607. uint16_t icid;
  608. int portal_id;
  609. uint64_t options;
  610. };
  611. /**
  612. * dprc_get_attributes() - Obtains container attributes
  613. * @mc_io: Pointer to MC portal's I/O object
  614. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  615. * @token: Token of DPRC object
  616. * @attributes: Returned container attributes
  617. *
  618. * Return: '0' on Success; Error code otherwise.
  619. */
  620. int dprc_get_attributes(struct fsl_mc_io *mc_io,
  621. uint32_t cmd_flags,
  622. uint16_t token,
  623. struct dprc_attributes *attributes);
  624. /**
  625. * dprc_get_obj_count() - Obtains the number of objects in the DPRC
  626. * @mc_io: Pointer to MC portal's I/O object
  627. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  628. * @token: Token of DPRC object
  629. * @obj_count: Number of objects assigned to the DPRC
  630. *
  631. * Return: '0' on Success; Error code otherwise.
  632. */
  633. int dprc_get_obj_count(struct fsl_mc_io *mc_io,
  634. uint32_t cmd_flags,
  635. uint16_t token,
  636. int *obj_count);
  637. /* Objects Attributes Flags */
  638. /* Opened state - Indicates that an object is open by at least one owner */
  639. #define DPRC_OBJ_STATE_OPEN 0x00000001
  640. /* Plugged state - Indicates that the object is plugged */
  641. #define DPRC_OBJ_STATE_PLUGGED 0x00000002
  642. /**
  643. * Shareability flag - Object flag indicating no memory shareability.
  644. * the object generates memory accesses that are non coherent with other
  645. * masters;
  646. * user is responsible for proper memory handling through IOMMU configuration.
  647. */
  648. #define DPRC_OBJ_FLAG_NO_MEM_SHAREABILITY 0x0001
  649. /**
  650. * struct dprc_obj_desc - Object descriptor, returned from dprc_get_obj()
  651. * @type: Type of object: NULL terminated string
  652. * @id: ID of logical object resource
  653. * @vendor: Object vendor identifier
  654. * @ver_major: Major version number
  655. * @ver_minor: Minor version number
  656. * @irq_count: Number of interrupts supported by the object
  657. * @region_count: Number of mappable regions supported by the object
  658. * @state: Object state: combination of DPRC_OBJ_STATE_ states
  659. * @label: Object label
  660. * @flags: Object's flags
  661. */
  662. struct dprc_obj_desc {
  663. char type[16];
  664. int id;
  665. uint16_t vendor;
  666. uint16_t ver_major;
  667. uint16_t ver_minor;
  668. uint8_t irq_count;
  669. uint8_t region_count;
  670. uint32_t state;
  671. char label[16];
  672. uint16_t flags;
  673. };
  674. /**
  675. * dprc_get_obj() - Get general information on an object
  676. * @mc_io: Pointer to MC portal's I/O object
  677. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  678. * @token: Token of DPRC object
  679. * @obj_index: Index of the object to be queried (< obj_count)
  680. * @obj_desc: Returns the requested object descriptor
  681. *
  682. * The object descriptors are retrieved one by one by incrementing
  683. * obj_index up to (not including) the value of obj_count returned
  684. * from dprc_get_obj_count(). dprc_get_obj_count() must
  685. * be called prior to dprc_get_obj().
  686. *
  687. * Return: '0' on Success; Error code otherwise.
  688. */
  689. int dprc_get_obj(struct fsl_mc_io *mc_io,
  690. uint32_t cmd_flags,
  691. uint16_t token,
  692. int obj_index,
  693. struct dprc_obj_desc *obj_desc);
  694. /**
  695. * dprc_get_res_count() - Obtains the number of free resources that are
  696. * assigned to this container, by pool type
  697. * @mc_io: Pointer to MC portal's I/O object
  698. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  699. * @token: Token of DPRC object
  700. * @type: pool type
  701. * @res_count: Returned number of free resources of the given
  702. * resource type that are assigned to this DPRC
  703. *
  704. * Return: '0' on Success; Error code otherwise.
  705. */
  706. int dprc_get_res_count(struct fsl_mc_io *mc_io,
  707. uint32_t cmd_flags,
  708. uint16_t token,
  709. char *type,
  710. int *res_count);
  711. /**
  712. * enum dprc_iter_status - Iteration status
  713. * @DPRC_ITER_STATUS_FIRST: Perform first iteration
  714. * @DPRC_ITER_STATUS_MORE: Indicates more/next iteration is needed
  715. * @DPRC_ITER_STATUS_LAST: Indicates last iteration
  716. */
  717. enum dprc_iter_status {
  718. DPRC_ITER_STATUS_FIRST = 0,
  719. DPRC_ITER_STATUS_MORE = 1,
  720. DPRC_ITER_STATUS_LAST = 2
  721. };
  722. /**
  723. * struct dprc_res_ids_range_desc - Resource ID range descriptor
  724. * @base_id: Base resource ID of this range
  725. * @last_id: Last resource ID of this range
  726. * @iter_status: Iteration status - should be set to DPRC_ITER_STATUS_FIRST at
  727. * first iteration; while the returned marker is DPRC_ITER_STATUS_MORE,
  728. * additional iterations are needed, until the returned marker is
  729. * DPRC_ITER_STATUS_LAST
  730. */
  731. struct dprc_res_ids_range_desc {
  732. int base_id;
  733. int last_id;
  734. enum dprc_iter_status iter_status;
  735. };
  736. /**
  737. * dprc_get_res_ids() - Obtains IDs of free resources in the container
  738. * @mc_io: Pointer to MC portal's I/O object
  739. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  740. * @token: Token of DPRC object
  741. * @type: pool type
  742. * @range_desc: range descriptor
  743. *
  744. * Return: '0' on Success; Error code otherwise.
  745. */
  746. int dprc_get_res_ids(struct fsl_mc_io *mc_io,
  747. uint32_t cmd_flags,
  748. uint16_t token,
  749. char *type,
  750. struct dprc_res_ids_range_desc *range_desc);
  751. /* Region flags */
  752. /* Cacheable - Indicates that region should be mapped as cacheable */
  753. #define DPRC_REGION_CACHEABLE 0x00000001
  754. /**
  755. * enum dprc_region_type - Region type
  756. * @DPRC_REGION_TYPE_MC_PORTAL: MC portal region
  757. * @DPRC_REGION_TYPE_QBMAN_PORTAL: Qbman portal region
  758. */
  759. enum dprc_region_type {
  760. DPRC_REGION_TYPE_MC_PORTAL,
  761. DPRC_REGION_TYPE_QBMAN_PORTAL
  762. };
  763. /**
  764. * struct dprc_region_desc - Mappable region descriptor
  765. * @base_offset: Region offset from region's base address.
  766. * For DPMCP and DPRC objects, region base is offset from SoC MC portals
  767. * base address; For DPIO, region base is offset from SoC QMan portals
  768. * base address
  769. * @size: Region size (in bytes)
  770. * @flags: Region attributes
  771. * @type: Portal region type
  772. */
  773. struct dprc_region_desc {
  774. uint32_t base_offset;
  775. uint32_t size;
  776. uint32_t flags;
  777. enum dprc_region_type type;
  778. };
  779. /**
  780. * dprc_get_obj_region() - Get region information for a specified object.
  781. * @mc_io: Pointer to MC portal's I/O object
  782. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  783. * @token: Token of DPRC object
  784. * @obj_type: Object type as returned in dprc_get_obj()
  785. * @obj_id: Unique object instance as returned in dprc_get_obj()
  786. * @region_index: The specific region to query
  787. * @region_desc: Returns the requested region descriptor
  788. *
  789. * Return: '0' on Success; Error code otherwise.
  790. */
  791. int dprc_get_obj_region(struct fsl_mc_io *mc_io,
  792. uint32_t cmd_flags,
  793. uint16_t token,
  794. char *obj_type,
  795. int obj_id,
  796. uint8_t region_index,
  797. struct dprc_region_desc *region_desc);
  798. /**
  799. * struct dprc_endpoint - Endpoint description for link connect/disconnect
  800. * operations
  801. * @type: Endpoint object type: NULL terminated string
  802. * @id: Endpoint object ID
  803. * @if_id: Interface ID; should be set for endpoints with multiple
  804. * interfaces ("dpsw", "dpdmux"); for others, always set to 0
  805. */
  806. struct dprc_endpoint {
  807. char type[16];
  808. int id;
  809. uint16_t if_id;
  810. };
  811. /**
  812. * struct dprc_connection_cfg - Connection configuration.
  813. * Used for virtual connections only
  814. * @committed_rate: Committed rate (Mbits/s)
  815. * @max_rate: Maximum rate (Mbits/s)
  816. */
  817. struct dprc_connection_cfg {
  818. uint32_t committed_rate;
  819. uint32_t max_rate;
  820. };
  821. /**
  822. * dprc_connect() - Connect two endpoints to create a network link between them
  823. * @mc_io: Pointer to MC portal's I/O object
  824. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  825. * @token: Token of DPRC object
  826. * @endpoint1: Endpoint 1 configuration parameters
  827. * @endpoint2: Endpoint 2 configuration parameters
  828. * @cfg: Connection configuration. The connection configuration is ignored for
  829. * connections made to DPMAC objects, where rate is retrieved from the
  830. * MAC configuration.
  831. *
  832. * Return: '0' on Success; Error code otherwise.
  833. */
  834. int dprc_connect(struct fsl_mc_io *mc_io,
  835. uint32_t cmd_flags,
  836. uint16_t token,
  837. const struct dprc_endpoint *endpoint1,
  838. const struct dprc_endpoint *endpoint2,
  839. const struct dprc_connection_cfg *cfg);
  840. /**
  841. * dprc_disconnect() - Disconnect one endpoint to remove its network connection
  842. * @mc_io: Pointer to MC portal's I/O object
  843. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  844. * @token: Token of DPRC object
  845. * @endpoint: Endpoint configuration parameters
  846. *
  847. * Return: '0' on Success; Error code otherwise.
  848. */
  849. int dprc_disconnect(struct fsl_mc_io *mc_io,
  850. uint32_t cmd_flags,
  851. uint16_t token,
  852. const struct dprc_endpoint *endpoint);
  853. /**
  854. * dprc_get_connection() - Get connected endpoint and link status if connection
  855. * exists.
  856. * @mc_io: Pointer to MC portal's I/O object
  857. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  858. * @token: Token of DPRC object
  859. * @endpoint1: Endpoint 1 configuration parameters
  860. * @endpoint2: Returned endpoint 2 configuration parameters
  861. * @state: Returned link state:
  862. * 1 - link is up;
  863. * 0 - link is down;
  864. * -1 - no connection (endpoint2 information is irrelevant)
  865. *
  866. * Return: '0' on Success; -ENAVAIL if connection does not exist.
  867. */
  868. int dprc_get_connection(struct fsl_mc_io *mc_io,
  869. uint32_t cmd_flags,
  870. uint16_t token,
  871. const struct dprc_endpoint *endpoint1,
  872. struct dprc_endpoint *endpoint2,
  873. int *state);
  874. /**
  875. * dprc_get_api_version - Retrieve DPRC Major and Minor version info.
  876. *
  877. * @mc_io: Pointer to MC portal's I/O object
  878. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  879. * @major_ver: DPRC major version
  880. * @minor_ver: DPRC minor version
  881. *
  882. * Return: '0' on Success; Error code otherwise.
  883. */
  884. int dprc_get_api_version(struct fsl_mc_io *mc_io,
  885. u32 cmd_flags,
  886. u16 *major_ver,
  887. u16 *minor_ver);
  888. #endif /* _FSL_DPRC_H */