fsl_dprc.h 37 KB

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