fsl_dpni.h 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Copyright 2013-2016 Freescale Semiconductor, Inc.
  4. * Copyright 2017 NXP
  5. */
  6. #ifndef _FSL_DPNI_H
  7. #define _FSL_DPNI_H
  8. /* DPNI Version */
  9. #define DPNI_VER_MAJOR 7
  10. #define DPNI_VER_MINOR 3
  11. /* Command IDs */
  12. #define DPNI_CMDID_OPEN 0x8011
  13. #define DPNI_CMDID_CLOSE 0x8001
  14. #define DPNI_CMDID_CREATE 0x9011
  15. #define DPNI_CMDID_DESTROY 0x9811
  16. #define DPNI_CMDID_GET_API_VERSION 0xa011
  17. #define DPNI_CMDID_ENABLE 0x0021
  18. #define DPNI_CMDID_DISABLE 0x0031
  19. #define DPNI_CMDID_GET_ATTR 0x0041
  20. #define DPNI_CMDID_RESET 0x0051
  21. #define DPNI_CMDID_SET_POOLS 0x2002
  22. #define DPNI_CMDID_SET_BUFFER_LAYOUT 0x2651
  23. #define DPNI_CMDID_GET_BUFFER_LAYOUT 0x2641
  24. #define DPNI_CMDID_SET_ERRORS_BEHAVIOR 0x20B1
  25. #define DPNI_CMDID_GET_QDID 0x2101
  26. #define DPNI_CMDID_GET_TX_DATA_OFFSET 0x2121
  27. #define DPNI_CMDID_GET_LINK_STATE 0x2151
  28. #define DPNI_CMDID_SET_LINK_CFG 0x21A1
  29. #define DPNI_CMDID_SET_PRIM_MAC 0x2241
  30. #define DPNI_CMDID_GET_PRIM_MAC 0x2251
  31. #define DPNI_CMDID_ADD_MAC_ADDR 0x2261
  32. #define DPNI_CMDID_REMOVE_MAC_ADDR 0x2271
  33. #define DPNI_CMDID_GET_STATISTICS 0x25D1
  34. #define DPNI_CMDID_RESET_STATISTICS 0x25E1
  35. #define DPNI_CMDID_GET_QUEUE 0x25F1
  36. #define DPNI_CMDID_SET_QUEUE 0x2601
  37. #define DPNI_CMDID_SET_TX_CONFIRMATION_MODE 0x2661
  38. /* cmd, param, offset, width, type, arg_name */
  39. #define DPNI_CMD_OPEN(cmd, dpni_id) \
  40. MC_CMD_OP(cmd, 0, 0, 32, int, dpni_id)
  41. /* cmd, param, offset, width, type, arg_name */
  42. #define DPNI_PREP_CFG(param, cfg) \
  43. do { \
  44. MC_PREP_OP(param, 0, 0, 32, uint16_t, cfg->adv.options); \
  45. MC_PREP_OP(param, 0, 32, 8, uint16_t, cfg->adv.num_queues); \
  46. MC_PREP_OP(param, 0, 40, 8, uint16_t, cfg->adv.num_tcs); \
  47. MC_PREP_OP(param, 0, 48, 8, uint16_t, cfg->adv.mac_entries); \
  48. MC_PREP_OP(param, 1, 0, 8, uint16_t, cfg->adv.vlan_entries); \
  49. MC_PREP_OP(param, 1, 16, 8, uint16_t, cfg->adv.qos_entries); \
  50. MC_PREP_OP(param, 1, 32, 16, uint16_t, cfg->adv.fs_entries); \
  51. } while (0)
  52. /* cmd, param, offset, width, type, arg_name */
  53. #define DPNI_EXT_CFG(param, cfg) \
  54. do { \
  55. MC_EXT_OP(param, 0, 0, 32, uint16_t, cfg->adv.options); \
  56. MC_EXT_OP(param, 0, 32, 8, uint16_t, cfg->adv.num_queues); \
  57. MC_EXT_OP(param, 0, 40, 8, uint16_t, cfg->adv.num_tcs); \
  58. MC_EXT_OP(param, 0, 48, 8, uint16_t, cfg->adv.mac_entries); \
  59. MC_EXT_OP(param, 1, 0, 8, uint16_t, cfg->adv.vlan_entries); \
  60. MC_EXT_OP(param, 1, 16, 8, uint16_t, cfg->adv.qos_entries); \
  61. MC_EXT_OP(param, 1, 32, 16, uint16_t, cfg->adv.fs_entries); \
  62. } while (0)
  63. /* cmd, param, offset, width, type, arg_name */
  64. #define DPNI_CMD_CREATE(cmd, cfg) \
  65. do { \
  66. MC_CMD_OP(cmd, 0, 0, 32, uint32_t, cfg->adv.options); \
  67. MC_CMD_OP(cmd, 0, 32, 8, uint8_t, cfg->adv.num_queues); \
  68. MC_CMD_OP(cmd, 0, 40, 8, uint8_t, cfg->adv.num_tcs); \
  69. MC_CMD_OP(cmd, 0, 48, 8, uint8_t, cfg->adv.mac_entries); \
  70. MC_CMD_OP(cmd, 1, 0, 8, uint8_t, cfg->adv.vlan_entries); \
  71. MC_CMD_OP(cmd, 1, 16, 8, uint8_t, cfg->adv.qos_entries); \
  72. MC_CMD_OP(cmd, 1, 32, 16, uint8_t, cfg->adv.fs_entries); \
  73. } while (0)
  74. /* cmd, param, offset, width, type, arg_name */
  75. #define DPNI_CMD_SET_POOLS(cmd, cfg) \
  76. do { \
  77. MC_CMD_OP(cmd, 0, 0, 8, uint8_t, cfg->num_dpbp); \
  78. MC_CMD_OP(cmd, 0, 8, 1, int, cfg->pools[0].backup_pool); \
  79. MC_CMD_OP(cmd, 0, 9, 1, int, cfg->pools[1].backup_pool); \
  80. MC_CMD_OP(cmd, 0, 10, 1, int, cfg->pools[2].backup_pool); \
  81. MC_CMD_OP(cmd, 0, 11, 1, int, cfg->pools[3].backup_pool); \
  82. MC_CMD_OP(cmd, 0, 12, 1, int, cfg->pools[4].backup_pool); \
  83. MC_CMD_OP(cmd, 0, 13, 1, int, cfg->pools[5].backup_pool); \
  84. MC_CMD_OP(cmd, 0, 14, 1, int, cfg->pools[6].backup_pool); \
  85. MC_CMD_OP(cmd, 0, 15, 1, int, cfg->pools[7].backup_pool); \
  86. MC_CMD_OP(cmd, 0, 32, 32, int, cfg->pools[0].dpbp_id); \
  87. MC_CMD_OP(cmd, 4, 32, 16, uint16_t, cfg->pools[0].buffer_size);\
  88. MC_CMD_OP(cmd, 1, 0, 32, int, cfg->pools[1].dpbp_id); \
  89. MC_CMD_OP(cmd, 4, 48, 16, uint16_t, cfg->pools[1].buffer_size);\
  90. MC_CMD_OP(cmd, 1, 32, 32, int, cfg->pools[2].dpbp_id); \
  91. MC_CMD_OP(cmd, 5, 0, 16, uint16_t, cfg->pools[2].buffer_size);\
  92. MC_CMD_OP(cmd, 2, 0, 32, int, cfg->pools[3].dpbp_id); \
  93. MC_CMD_OP(cmd, 5, 16, 16, uint16_t, cfg->pools[3].buffer_size);\
  94. MC_CMD_OP(cmd, 2, 32, 32, int, cfg->pools[4].dpbp_id); \
  95. MC_CMD_OP(cmd, 5, 32, 16, uint16_t, cfg->pools[4].buffer_size);\
  96. MC_CMD_OP(cmd, 3, 0, 32, int, cfg->pools[5].dpbp_id); \
  97. MC_CMD_OP(cmd, 5, 48, 16, uint16_t, cfg->pools[5].buffer_size);\
  98. MC_CMD_OP(cmd, 3, 32, 32, int, cfg->pools[6].dpbp_id); \
  99. MC_CMD_OP(cmd, 6, 0, 16, uint16_t, cfg->pools[6].buffer_size);\
  100. MC_CMD_OP(cmd, 4, 0, 32, int, cfg->pools[7].dpbp_id); \
  101. MC_CMD_OP(cmd, 6, 16, 16, uint16_t, cfg->pools[7].buffer_size);\
  102. } while (0)
  103. /* cmd, param, offset, width, type, arg_name */
  104. #define DPNI_RSP_GET_ATTR(cmd, attr) \
  105. do { \
  106. MC_RSP_OP(cmd, 0, 0, 32, int, attr->options);\
  107. MC_RSP_OP(cmd, 0, 32, 8, uint8_t, attr->max_num_queues); \
  108. MC_RSP_OP(cmd, 0, 40, 8, uint8_t, attr->max_num_tcs); \
  109. MC_RSP_OP(cmd, 0, 48, 8, uint8_t, attr->max_mac_entries); \
  110. MC_RSP_OP(cmd, 1, 0, 8, uint8_t, attr->max_vlan_entries); \
  111. MC_RSP_OP(cmd, 1, 16, 8, uint8_t, attr->max_qos_entries); \
  112. MC_RSP_OP(cmd, 1, 32, 16, uint16_t, attr->max_fs_entries); \
  113. MC_RSP_OP(cmd, 2, 0, 8, uint8_t, attr->max_qos_key_size); \
  114. MC_RSP_OP(cmd, 2, 8, 8, uint8_t, attr->max_fs_key_size); \
  115. MC_RSP_OP(cmd, 2, 16, 16, uint16_t, attr->wriop_version); \
  116. } while (0)
  117. /* cmd, param, offset, width, type, arg_name */
  118. #define DPNI_CMD_SET_ERRORS_BEHAVIOR(cmd, cfg) \
  119. do { \
  120. MC_CMD_OP(cmd, 0, 0, 32, uint32_t, cfg->errors); \
  121. MC_CMD_OP(cmd, 0, 32, 4, enum dpni_error_action, cfg->error_action); \
  122. MC_CMD_OP(cmd, 0, 36, 1, int, cfg->set_frame_annotation); \
  123. } while (0)
  124. /* cmd, param, offset, width, type, arg_name */
  125. #define DPNI_CMD_SET_BUFFER_LAYOUT(cmd, layout, queue) \
  126. do { \
  127. MC_CMD_OP(cmd, 0, 0, 8, enum dpni_queue_type, queue); \
  128. MC_CMD_OP(cmd, 1, 0, 16, uint16_t, layout->private_data_size); \
  129. MC_CMD_OP(cmd, 1, 16, 16, uint16_t, layout->data_align); \
  130. MC_CMD_OP(cmd, 0, 32, 16, uint16_t, layout->options); \
  131. MC_CMD_OP(cmd, 0, 48, 1, int, layout->pass_timestamp); \
  132. MC_CMD_OP(cmd, 0, 49, 1, int, layout->pass_parser_result); \
  133. MC_CMD_OP(cmd, 0, 50, 1, int, layout->pass_frame_status); \
  134. MC_CMD_OP(cmd, 1, 32, 16, uint16_t, layout->data_head_room); \
  135. MC_CMD_OP(cmd, 1, 48, 16, uint16_t, layout->data_tail_room); \
  136. } while (0)
  137. /* cmd, param, offset, width, type, arg_name */
  138. #define DPNI_RSP_GET_QDID(cmd, qdid) \
  139. MC_RSP_OP(cmd, 0, 0, 16, uint16_t, qdid)
  140. /* cmd, param, offset, width, type, arg_name */
  141. #define DPNI_RSP_GET_TX_DATA_OFFSET(cmd, data_offset) \
  142. MC_RSP_OP(cmd, 0, 0, 16, uint16_t, data_offset)
  143. /* cmd, param, offset, width, type, arg_name */
  144. #define DPNI_CMD_SET_LINK_CFG(cmd, cfg) \
  145. do { \
  146. MC_CMD_OP(cmd, 1, 0, 32, uint32_t, cfg->rate);\
  147. MC_CMD_OP(cmd, 2, 0, 64, uint64_t, cfg->options);\
  148. } while (0)
  149. /* cmd, param, offset, width, type, arg_name */
  150. #define DPNI_RSP_GET_LINK_STATE(cmd, state) \
  151. do { \
  152. MC_RSP_OP(cmd, 0, 32, 1, int, state->up);\
  153. MC_RSP_OP(cmd, 1, 0, 32, uint32_t, state->rate);\
  154. MC_RSP_OP(cmd, 2, 0, 64, uint64_t, state->options);\
  155. } while (0)
  156. /* cmd, param, offset, width, type, arg_name */
  157. #define DPNI_CMD_SET_PRIMARY_MAC_ADDR(cmd, mac_addr) \
  158. do { \
  159. MC_CMD_OP(cmd, 0, 16, 8, uint8_t, mac_addr[5]); \
  160. MC_CMD_OP(cmd, 0, 24, 8, uint8_t, mac_addr[4]); \
  161. MC_CMD_OP(cmd, 0, 32, 8, uint8_t, mac_addr[3]); \
  162. MC_CMD_OP(cmd, 0, 40, 8, uint8_t, mac_addr[2]); \
  163. MC_CMD_OP(cmd, 0, 48, 8, uint8_t, mac_addr[1]); \
  164. MC_CMD_OP(cmd, 0, 56, 8, uint8_t, mac_addr[0]); \
  165. } while (0)
  166. /* cmd, param, offset, width, type, arg_name */
  167. #define DPNI_RSP_GET_PRIMARY_MAC_ADDR(cmd, mac_addr) \
  168. do { \
  169. MC_RSP_OP(cmd, 0, 16, 8, uint8_t, mac_addr[5]); \
  170. MC_RSP_OP(cmd, 0, 24, 8, uint8_t, mac_addr[4]); \
  171. MC_RSP_OP(cmd, 0, 32, 8, uint8_t, mac_addr[3]); \
  172. MC_RSP_OP(cmd, 0, 40, 8, uint8_t, mac_addr[2]); \
  173. MC_RSP_OP(cmd, 0, 48, 8, uint8_t, mac_addr[1]); \
  174. MC_RSP_OP(cmd, 0, 56, 8, uint8_t, mac_addr[0]); \
  175. } while (0)
  176. /* cmd, param, offset, width, type, arg_name */
  177. #define DPNI_CMD_ADD_MAC_ADDR(cmd, mac_addr) \
  178. do { \
  179. MC_CMD_OP(cmd, 0, 16, 8, uint8_t, mac_addr[5]); \
  180. MC_CMD_OP(cmd, 0, 24, 8, uint8_t, mac_addr[4]); \
  181. MC_CMD_OP(cmd, 0, 32, 8, uint8_t, mac_addr[3]); \
  182. MC_CMD_OP(cmd, 0, 40, 8, uint8_t, mac_addr[2]); \
  183. MC_CMD_OP(cmd, 0, 48, 8, uint8_t, mac_addr[1]); \
  184. MC_CMD_OP(cmd, 0, 56, 8, uint8_t, mac_addr[0]); \
  185. } while (0)
  186. /* cmd, param, offset, width, type, arg_name */
  187. #define DPNI_CMD_REMOVE_MAC_ADDR(cmd, mac_addr) \
  188. do { \
  189. MC_CMD_OP(cmd, 0, 16, 8, uint8_t, mac_addr[5]); \
  190. MC_CMD_OP(cmd, 0, 24, 8, uint8_t, mac_addr[4]); \
  191. MC_CMD_OP(cmd, 0, 32, 8, uint8_t, mac_addr[3]); \
  192. MC_CMD_OP(cmd, 0, 40, 8, uint8_t, mac_addr[2]); \
  193. MC_CMD_OP(cmd, 0, 48, 8, uint8_t, mac_addr[1]); \
  194. MC_CMD_OP(cmd, 0, 56, 8, uint8_t, mac_addr[0]); \
  195. } while (0)
  196. #define DPNI_CMD_GET_QUEUE(cmd, type, tc, index) \
  197. do { \
  198. MC_CMD_OP(cmd, 0, 0, 8, enum dpni_queue_type, type); \
  199. MC_CMD_OP(cmd, 0, 8, 8, uint8_t, tc); \
  200. MC_CMD_OP(cmd, 0, 16, 8, uint8_t, index); \
  201. } while (0)
  202. #define DPNI_RSP_GET_QUEUE(cmd, queue) \
  203. do { \
  204. MC_RSP_OP(cmd, 1, 0, 32, uint32_t, (queue)->destination.id); \
  205. MC_RSP_OP(cmd, 1, 56, 4, enum dpni_dest, (queue)->destination.type); \
  206. MC_RSP_OP(cmd, 1, 62, 1, char, (queue)->destination.stash_ctrl); \
  207. MC_RSP_OP(cmd, 1, 63, 1, char, (queue)->destination.hold_active); \
  208. MC_RSP_OP(cmd, 2, 0, 64, uint64_t, (queue)->flc); \
  209. MC_RSP_OP(cmd, 3, 0, 64, uint64_t, (queue)->user_context); \
  210. MC_RSP_OP(cmd, 4, 0, 32, uint32_t, (queue)->fqid); \
  211. MC_RSP_OP(cmd, 4, 32, 16, uint16_t, (queue)->qdbin); \
  212. } while (0)
  213. #define DPNI_CMD_SET_QUEUE(cmd, type, tc, index, queue) \
  214. do { \
  215. MC_CMD_OP(cmd, 0, 0, 8, enum dpni_queue_type, type); \
  216. MC_CMD_OP(cmd, 0, 8, 8, uint8_t, tc); \
  217. MC_CMD_OP(cmd, 0, 16, 8, uint8_t, index); \
  218. MC_CMD_OP(cmd, 0, 24, 8, uint8_t, (queue)->options); \
  219. MC_CMD_OP(cmd, 1, 0, 32, uint32_t, (queue)->destination.id); \
  220. MC_CMD_OP(cmd, 1, 56, 4, enum dpni_dest, (queue)->destination.type); \
  221. MC_CMD_OP(cmd, 1, 62, 1, char, (queue)->destination.stash_ctrl); \
  222. MC_CMD_OP(cmd, 1, 63, 1, char, (queue)->destination.hold_active); \
  223. MC_CMD_OP(cmd, 1, 0, 32, uint32_t, (queue)->destination.id); \
  224. MC_CMD_OP(cmd, 2, 0, 64, uint64_t, (queue)->flc); \
  225. MC_CMD_OP(cmd, 3, 0, 64, uint64_t, (queue)->user_context); \
  226. } while (0)
  227. /* cmd, param, offset, width, type, arg_name */
  228. #define DPNI_CMD_GET_STATISTICS(cmd, page) \
  229. MC_CMD_OP(cmd, 0, 0, 8, uint8_t, page)
  230. /* cmd, param, offset, width, type, arg_name */
  231. #define DPNI_RSP_GET_STATISTICS(cmd, stat) \
  232. do { \
  233. MC_RSP_OP(cmd, 0, 0, 64, uint64_t, (stat)->counter0); \
  234. MC_RSP_OP(cmd, 1, 0, 64, uint64_t, (stat)->counter1); \
  235. MC_RSP_OP(cmd, 2, 0, 64, uint64_t, (stat)->counter2); \
  236. MC_RSP_OP(cmd, 3, 0, 64, uint64_t, (stat)->counter3); \
  237. MC_RSP_OP(cmd, 4, 0, 64, uint64_t, (stat)->counter4); \
  238. MC_RSP_OP(cmd, 5, 0, 64, uint64_t, (stat)->counter5); \
  239. MC_RSP_OP(cmd, 6, 0, 64, uint64_t, (stat)->counter6); \
  240. } while (0)
  241. enum net_prot {
  242. NET_PROT_NONE = 0,
  243. NET_PROT_PAYLOAD,
  244. NET_PROT_ETH,
  245. NET_PROT_VLAN,
  246. NET_PROT_IPV4,
  247. NET_PROT_IPV6,
  248. NET_PROT_IP,
  249. NET_PROT_TCP,
  250. NET_PROT_UDP,
  251. NET_PROT_UDP_LITE,
  252. NET_PROT_IPHC,
  253. NET_PROT_SCTP,
  254. NET_PROT_SCTP_CHUNK_DATA,
  255. NET_PROT_PPPOE,
  256. NET_PROT_PPP,
  257. NET_PROT_PPPMUX,
  258. NET_PROT_PPPMUX_SUBFRM,
  259. NET_PROT_L2TPV2,
  260. NET_PROT_L2TPV3_CTRL,
  261. NET_PROT_L2TPV3_SESS,
  262. NET_PROT_LLC,
  263. NET_PROT_LLC_SNAP,
  264. NET_PROT_NLPID,
  265. NET_PROT_SNAP,
  266. NET_PROT_MPLS,
  267. NET_PROT_IPSEC_AH,
  268. NET_PROT_IPSEC_ESP,
  269. NET_PROT_UDP_ENC_ESP, /* RFC 3948 */
  270. NET_PROT_MACSEC,
  271. NET_PROT_GRE,
  272. NET_PROT_MINENCAP,
  273. NET_PROT_DCCP,
  274. NET_PROT_ICMP,
  275. NET_PROT_IGMP,
  276. NET_PROT_ARP,
  277. NET_PROT_CAPWAP_DATA,
  278. NET_PROT_CAPWAP_CTRL,
  279. NET_PROT_RFC2684,
  280. NET_PROT_ICMPV6,
  281. NET_PROT_FCOE,
  282. NET_PROT_FIP,
  283. NET_PROT_ISCSI,
  284. NET_PROT_GTP,
  285. NET_PROT_USER_DEFINED_L2,
  286. NET_PROT_USER_DEFINED_L3,
  287. NET_PROT_USER_DEFINED_L4,
  288. NET_PROT_USER_DEFINED_L5,
  289. NET_PROT_USER_DEFINED_SHIM1,
  290. NET_PROT_USER_DEFINED_SHIM2,
  291. NET_PROT_DUMMY_LAST
  292. };
  293. /**
  294. * Data Path Network Interface API
  295. * Contains initialization APIs and runtime control APIs for DPNI
  296. */
  297. struct fsl_mc_io;
  298. /* General DPNI macros */
  299. /* Maximum number of traffic classes */
  300. #define DPNI_MAX_TC 8
  301. /* Maximum number of buffer pools per DPNI */
  302. #define DPNI_MAX_DPBP 8
  303. /* All traffic classes considered; see dpni_set_rx_flow() */
  304. #define DPNI_ALL_TCS (uint8_t)(-1)
  305. /* All flows within traffic class considered; see dpni_set_rx_flow() */
  306. #define DPNI_ALL_TC_FLOWS (uint16_t)(-1)
  307. /* Generate new flow ID; see dpni_set_tx_flow() */
  308. #define DPNI_NEW_FLOW_ID (uint16_t)(-1)
  309. /* use for common tx-conf queue; see dpni_set_tx_conf_<x>() */
  310. #define DPNI_COMMON_TX_CONF (uint16_t)(-1)
  311. /**
  312. * dpni_open() - Open a control session for the specified object
  313. * @mc_io: Pointer to MC portal's I/O object
  314. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  315. * @dpni_id: DPNI unique ID
  316. * @token: Returned token; use in subsequent API calls
  317. *
  318. * This function can be used to open a control session for an
  319. * already created object; an object may have been declared in
  320. * the DPL or by calling the dpni_create() function.
  321. * This function returns a unique authentication token,
  322. * associated with the specific object ID and the specific MC
  323. * portal; this token must be used in all subsequent commands for
  324. * this specific object.
  325. *
  326. * Return: '0' on Success; Error code otherwise.
  327. */
  328. int dpni_open(struct fsl_mc_io *mc_io,
  329. uint32_t cmd_flags,
  330. int dpni_id,
  331. uint16_t *token);
  332. /**
  333. * dpni_close() - Close the control session of the object
  334. * @mc_io: Pointer to MC portal's I/O object
  335. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  336. * @token: Token of DPNI object
  337. *
  338. * After this function is called, no further operations are
  339. * allowed on the object without opening a new control session.
  340. *
  341. * Return: '0' on Success; Error code otherwise.
  342. */
  343. int dpni_close(struct fsl_mc_io *mc_io,
  344. uint32_t cmd_flags,
  345. uint16_t token);
  346. /* DPNI configuration options */
  347. /**
  348. * Allow different distribution key profiles for different traffic classes;
  349. * if not set, a single key profile is assumed
  350. */
  351. #define DPNI_OPT_ALLOW_DIST_KEY_PER_TC 0x00000001
  352. /**
  353. * Disable all non-error transmit confirmation; error frames are reported
  354. * back to a common Tx error queue
  355. */
  356. #define DPNI_OPT_TX_CONF_DISABLED 0x00000002
  357. /* Disable per-sender private Tx confirmation/error queue */
  358. #define DPNI_OPT_PRIVATE_TX_CONF_ERROR_DISABLED 0x00000004
  359. /**
  360. * Support distribution based on hashed key;
  361. * allows statistical distribution over receive queues in a traffic class
  362. */
  363. #define DPNI_OPT_DIST_HASH 0x00000010
  364. /**
  365. * Support distribution based on flow steering;
  366. * allows explicit control of distribution over receive queues in a traffic
  367. * class
  368. */
  369. #define DPNI_OPT_DIST_FS 0x00000020
  370. /* Unicast filtering support */
  371. #define DPNI_OPT_UNICAST_FILTER 0x00000080
  372. /* Multicast filtering support */
  373. #define DPNI_OPT_MULTICAST_FILTER 0x00000100
  374. /* VLAN filtering support */
  375. #define DPNI_OPT_VLAN_FILTER 0x00000200
  376. /* Support IP reassembly on received packets */
  377. #define DPNI_OPT_IPR 0x00000800
  378. /* Support IP fragmentation on transmitted packets */
  379. #define DPNI_OPT_IPF 0x00001000
  380. /* VLAN manipulation support */
  381. #define DPNI_OPT_VLAN_MANIPULATION 0x00010000
  382. /* Support masking of QoS lookup keys */
  383. #define DPNI_OPT_QOS_MASK_SUPPORT 0x00020000
  384. /* Support masking of Flow Steering lookup keys */
  385. #define DPNI_OPT_FS_MASK_SUPPORT 0x00040000
  386. /**
  387. * enum dpni_queue_type - Identifies a type of queue targeted by the command
  388. * @DPNI_QUEUE_RX: Rx queue
  389. * @DPNI_QUEUE_TX: Tx queue
  390. * @DPNI_QUEUE_TX_CONFIRM: Tx confirmation queue
  391. * @DPNI_QUEUE_RX_ERR: Rx error queue
  392. */
  393. enum dpni_queue_type {
  394. DPNI_QUEUE_RX,
  395. DPNI_QUEUE_TX,
  396. DPNI_QUEUE_TX_CONFIRM,
  397. DPNI_QUEUE_RX_ERR,
  398. };
  399. struct dpni_cfg {
  400. uint8_t mac_addr[6];
  401. struct {
  402. uint32_t options;
  403. uint16_t fs_entries;
  404. uint8_t num_queues;
  405. uint8_t num_tcs;
  406. uint8_t mac_entries;
  407. uint8_t vlan_entries;
  408. uint8_t qos_entries;
  409. } adv;
  410. };
  411. /**
  412. * struct dpni_extended_cfg - Structure representing extended DPNI configuration
  413. * @tc_cfg: TCs configuration
  414. * @ipr_cfg: IP reassembly configuration
  415. */
  416. struct dpni_extended_cfg {
  417. /**
  418. * struct tc_cfg - TC configuration
  419. * @max_dist: Maximum distribution size for Rx traffic class;
  420. * supported values: 1,2,3,4,6,7,8,12,14,16,24,28,32,48,56,64,96,
  421. * 112,128,192,224,256,384,448,512,768,896,1024;
  422. * value '0' will be treated as '1'.
  423. * other unsupported values will be round down to the nearest
  424. * supported value.
  425. * @max_fs_entries: Maximum FS entries for Rx traffic class;
  426. * '0' means no support for this TC;
  427. */
  428. struct {
  429. uint16_t max_dist;
  430. uint16_t max_fs_entries;
  431. } tc_cfg[DPNI_MAX_TC];
  432. /**
  433. * struct ipr_cfg - Structure representing IP reassembly configuration
  434. * @max_reass_frm_size: Maximum size of the reassembled frame
  435. * @min_frag_size_ipv4: Minimum fragment size of IPv4 fragments
  436. * @min_frag_size_ipv6: Minimum fragment size of IPv6 fragments
  437. * @max_open_frames_ipv4: Maximum concurrent IPv4 packets in reassembly
  438. * process
  439. * @max_open_frames_ipv6: Maximum concurrent IPv6 packets in reassembly
  440. * process
  441. */
  442. struct {
  443. uint16_t max_reass_frm_size;
  444. uint16_t min_frag_size_ipv4;
  445. uint16_t min_frag_size_ipv6;
  446. uint16_t max_open_frames_ipv4;
  447. uint16_t max_open_frames_ipv6;
  448. } ipr_cfg;
  449. };
  450. /**
  451. * dpni_prepare_cfg() - function prepare parameters
  452. * @cfg: cfg structure
  453. * @cfg_buf: Zeroed 256 bytes of memory before mapping it to DMA
  454. *
  455. * This function has to be called before dpni_create()
  456. */
  457. int dpni_prepare_cfg(const struct dpni_cfg *cfg,
  458. uint8_t *cfg_buf);
  459. /**
  460. * dpni_create() - Create the DPNI object
  461. * @mc_io: Pointer to MC portal's I/O object
  462. * @token: Authentication token.
  463. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  464. * @cfg: Configuration structure
  465. * @obj_id: Returned obj_id; use in subsequent API calls
  466. *
  467. * Create the DPNI object, allocate required resources and
  468. * perform required initialization.
  469. *
  470. * The object can be created either by declaring it in the
  471. * DPL file, or by calling this function.
  472. *
  473. * This function returns a unique authentication token,
  474. * associated with the specific object ID and the specific MC
  475. * portal; this token must be used in all subsequent calls to
  476. * this specific object. For objects that are created using the
  477. * DPL file, call dpni_open() function to get an authentication
  478. * token first.
  479. *
  480. * Return: '0' on Success; Error code otherwise.
  481. */
  482. int dpni_create(struct fsl_mc_io *mc_io,
  483. uint16_t token,
  484. uint32_t cmd_flags,
  485. const struct dpni_cfg *cfg,
  486. uint32_t *obj_id);
  487. /**
  488. * dpni_destroy() - Destroy the DPNI object and release all its resources.
  489. * @mc_io: Pointer to MC portal's I/O object
  490. * @token: Authentication token.
  491. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  492. * @obj_id: Returned obj_id; use in subsequent API calls
  493. *
  494. * Return: '0' on Success; error code otherwise.
  495. */
  496. int dpni_destroy(struct fsl_mc_io *mc_io,
  497. uint16_t token,
  498. uint32_t cmd_flags,
  499. uint32_t obj_id);
  500. /**
  501. * struct dpni_pools_cfg - Structure representing buffer pools configuration
  502. * @num_dpbp: Number of DPBPs
  503. * @pools: Array of buffer pools parameters; The number of valid entries
  504. * must match 'num_dpbp' value
  505. */
  506. struct dpni_pools_cfg {
  507. uint8_t num_dpbp;
  508. /**
  509. * struct pools - Buffer pools parameters
  510. * @dpbp_id: DPBP object ID
  511. * @buffer_size: Buffer size
  512. * @backup_pool: Backup pool
  513. */
  514. struct {
  515. int dpbp_id;
  516. uint16_t buffer_size;
  517. int backup_pool;
  518. } pools[DPNI_MAX_DPBP];
  519. };
  520. /**
  521. * dpni_set_pools() - Set buffer pools configuration
  522. * @mc_io: Pointer to MC portal's I/O object
  523. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  524. * @token: Token of DPNI object
  525. * @cfg: Buffer pools configuration
  526. *
  527. * mandatory for DPNI operation
  528. * warning:Allowed only when DPNI is disabled
  529. *
  530. * Return: '0' on Success; Error code otherwise.
  531. */
  532. int dpni_set_pools(struct fsl_mc_io *mc_io,
  533. uint32_t cmd_flags,
  534. uint16_t token,
  535. const struct dpni_pools_cfg *cfg);
  536. /**
  537. * dpni_enable() - Enable the DPNI, allow sending and receiving frames.
  538. * @mc_io: Pointer to MC portal's I/O object
  539. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  540. * @token: Token of DPNI object
  541. *
  542. * Return: '0' on Success; Error code otherwise.
  543. */
  544. int dpni_enable(struct fsl_mc_io *mc_io,
  545. uint32_t cmd_flags,
  546. uint16_t token);
  547. /**
  548. * dpni_disable() - Disable the DPNI, stop sending and receiving frames.
  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 DPNI object
  552. *
  553. * Return: '0' on Success; Error code otherwise.
  554. */
  555. int dpni_disable(struct fsl_mc_io *mc_io,
  556. uint32_t cmd_flags,
  557. uint16_t token);
  558. /**
  559. * dpni_reset() - Reset the DPNI, returns the object to initial state.
  560. * @mc_io: Pointer to MC portal's I/O object
  561. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  562. * @token: Token of DPNI object
  563. *
  564. * Return: '0' on Success; Error code otherwise.
  565. */
  566. int dpni_reset(struct fsl_mc_io *mc_io,
  567. uint32_t cmd_flags,
  568. uint16_t token);
  569. /**
  570. * struct dpni_attr - Structure representing DPNI attributes
  571. * @options: Mask of available options; reflects the value as was given in
  572. * object's creation
  573. * @max_num_queues: Number of queues available (for both Tx and Rx)
  574. * @max_num_tcs: Maximum number of traffic classes (for both Tx and Rx)
  575. * @max_mac_entries: Maximum number of traffic classes (for both Tx and Rx)
  576. * @max_unicast_filters: Maximum number of unicast filters
  577. * @max_multicast_filters: Maximum number of multicast filters
  578. * @max_vlan_entries: Maximum number of VLAN filters
  579. * @max_qos_entries: if 'max_tcs > 1', declares the maximum entries in QoS table
  580. * @max_fs_entries: declares the maximum entries in flow steering table
  581. * @max_qos_key_size: Maximum key size for the QoS look-up
  582. * @max_fs_key_size: Maximum key size for the flow steering
  583. * @wriop_version: Indicates revision of WRIOP hardware block
  584. */
  585. struct dpni_attr {
  586. uint32_t id;
  587. uint32_t options;
  588. uint8_t max_num_queues;
  589. uint8_t max_num_tcs;
  590. uint8_t max_mac_entries;
  591. uint8_t max_vlan_entries;
  592. uint8_t max_qos_entries;
  593. uint16_t max_fs_entries;
  594. uint8_t max_qos_key_size;
  595. uint8_t max_fs_key_size;
  596. uint16_t wriop_version;
  597. };
  598. /**
  599. * dpni_get_attributes() - Retrieve DPNI attributes.
  600. * @mc_io: Pointer to MC portal's I/O object
  601. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  602. * @token: Token of DPNI object
  603. * @attr: Object's attributes
  604. *
  605. * Return: '0' on Success; Error code otherwise.
  606. */
  607. int dpni_get_attributes(struct fsl_mc_io *mc_io,
  608. uint32_t cmd_flags,
  609. uint16_t token,
  610. struct dpni_attr *attr);
  611. /**
  612. * dpni_extract_cfg() - extract the parameters
  613. * @cfg: cfg structure
  614. * @cfg_buf: 256 bytes of DMA-able memory
  615. *
  616. * This function has to be called after dpni_get_attributes()
  617. */
  618. int dpni_extract_cfg(struct dpni_cfg *cfg,
  619. const uint8_t *cfg_buf);
  620. /**
  621. * DPNI errors
  622. */
  623. /**
  624. * Extract out of frame header error
  625. */
  626. #define DPNI_ERROR_EOFHE 0x00020000
  627. /**
  628. * Frame length error
  629. */
  630. #define DPNI_ERROR_FLE 0x00002000
  631. /**
  632. * Frame physical error
  633. */
  634. #define DPNI_ERROR_FPE 0x00001000
  635. /**
  636. * Parsing header error
  637. */
  638. #define DPNI_ERROR_PHE 0x00000020
  639. /**
  640. * Parser L3 checksum error
  641. */
  642. #define DPNI_ERROR_L3CE 0x00000004
  643. /**
  644. * Parser L3 checksum error
  645. */
  646. #define DPNI_ERROR_L4CE 0x00000001
  647. /**
  648. * enum dpni_error_action - Defines DPNI behavior for errors
  649. * @DPNI_ERROR_ACTION_DISCARD: Discard the frame
  650. * @DPNI_ERROR_ACTION_CONTINUE: Continue with the normal flow
  651. * @DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE: Send the frame to the error queue
  652. */
  653. enum dpni_error_action {
  654. DPNI_ERROR_ACTION_DISCARD = 0,
  655. DPNI_ERROR_ACTION_CONTINUE = 1,
  656. DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE = 2
  657. };
  658. /**
  659. * struct dpni_error_cfg - Structure representing DPNI errors treatment
  660. * @errors: Errors mask; use 'DPNI_ERROR__<X>
  661. * @error_action: The desired action for the errors mask
  662. * @set_frame_annotation: Set to '1' to mark the errors in frame annotation
  663. * status (FAS); relevant only for the non-discard action
  664. */
  665. struct dpni_error_cfg {
  666. uint32_t errors;
  667. enum dpni_error_action error_action;
  668. int set_frame_annotation;
  669. };
  670. /**
  671. * dpni_set_errors_behavior() - Set errors behavior
  672. * @mc_io: Pointer to MC portal's I/O object
  673. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  674. * @token: Token of DPNI object
  675. * @cfg: Errors configuration
  676. *
  677. * this function may be called numerous times with different
  678. * error masks
  679. *
  680. * Return: '0' on Success; Error code otherwise.
  681. */
  682. int dpni_set_errors_behavior(struct fsl_mc_io *mc_io,
  683. uint32_t cmd_flags,
  684. uint16_t token,
  685. struct dpni_error_cfg *cfg);
  686. /* DPNI buffer layout modification options */
  687. /* Select to modify the time-stamp setting */
  688. #define DPNI_BUF_LAYOUT_OPT_TIMESTAMP 0x00000001
  689. /* Select to modify the parser-result setting; not applicable for Tx */
  690. #define DPNI_BUF_LAYOUT_OPT_PARSER_RESULT 0x00000002
  691. /* Select to modify the frame-status setting */
  692. #define DPNI_BUF_LAYOUT_OPT_FRAME_STATUS 0x00000004
  693. /* Select to modify the private-data-size setting */
  694. #define DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE 0x00000008
  695. /* Select to modify the data-alignment setting */
  696. #define DPNI_BUF_LAYOUT_OPT_DATA_ALIGN 0x00000010
  697. /* Select to modify the data-head-room setting */
  698. #define DPNI_BUF_LAYOUT_OPT_DATA_HEAD_ROOM 0x00000020
  699. /*!< Select to modify the data-tail-room setting */
  700. #define DPNI_BUF_LAYOUT_OPT_DATA_TAIL_ROOM 0x00000040
  701. /**
  702. * struct dpni_buffer_layout - Structure representing DPNI buffer layout
  703. * @options: Flags representing the suggested modifications to the buffer
  704. * layout; Use any combination of 'DPNI_BUF_LAYOUT_OPT_<X>' flags
  705. * @pass_timestamp: Pass timestamp value
  706. * @pass_parser_result: Pass parser results
  707. * @pass_frame_status: Pass frame status
  708. * @private_data_size: Size kept for private data (in bytes)
  709. * @data_align: Data alignment
  710. * @data_head_room: Data head room
  711. * @data_tail_room: Data tail room
  712. */
  713. struct dpni_buffer_layout {
  714. uint16_t options;
  715. int pass_timestamp;
  716. int pass_parser_result;
  717. int pass_frame_status;
  718. uint16_t private_data_size;
  719. uint16_t data_align;
  720. uint16_t data_head_room;
  721. uint16_t data_tail_room;
  722. };
  723. /**
  724. * dpni_get_buffer_layout() - Retrieve buffer layout attributes.
  725. * @mc_io: Pointer to MC portal's I/O object
  726. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  727. * @token: Token of DPNI object
  728. * @layout: Returns buffer layout attributes
  729. * @type: DPNI queue type
  730. *
  731. * Return: '0' on Success; Error code otherwise.
  732. */
  733. int dpni_get_buffer_layout(struct fsl_mc_io *mc_io,
  734. uint32_t cmd_flags,
  735. uint16_t token,
  736. const struct dpni_buffer_layout *layout,
  737. enum dpni_queue_type type);
  738. /**
  739. * dpni_set_buffer_layout() - Set buffer layout configuration.
  740. * @mc_io: Pointer to MC portal's I/O object
  741. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  742. * @token: Token of DPNI object
  743. * @layout: Buffer layout configuration
  744. * @type: DPNI queue type
  745. *
  746. * Return: '0' on Success; Error code otherwise.
  747. *
  748. * @warning Allowed only when DPNI is disabled
  749. */
  750. int dpni_set_buffer_layout(struct fsl_mc_io *mc_io,
  751. uint32_t cmd_flags,
  752. uint16_t token,
  753. const struct dpni_buffer_layout *layout,
  754. enum dpni_queue_type type);
  755. /**
  756. * dpni_get_qdid() - Get the Queuing Destination ID (QDID) that should be used
  757. * for enqueue operations
  758. * @mc_io: Pointer to MC portal's I/O object
  759. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  760. * @token: Token of DPNI object
  761. * @qdid: Returned virtual QDID value that should be used as an argument
  762. * in all enqueue operations
  763. *
  764. * Return: '0' on Success; Error code otherwise.
  765. */
  766. int dpni_get_qdid(struct fsl_mc_io *mc_io,
  767. uint32_t cmd_flags,
  768. uint16_t token,
  769. uint16_t *qdid);
  770. /**
  771. * dpni_get_tx_data_offset() - Get the Tx data offset (from start of buffer)
  772. * @mc_io: Pointer to MC portal's I/O object
  773. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  774. * @token: Token of DPNI object
  775. * @data_offset: Tx data offset (from start of buffer)
  776. *
  777. * Return: '0' on Success; Error code otherwise.
  778. */
  779. int dpni_get_tx_data_offset(struct fsl_mc_io *mc_io,
  780. uint32_t cmd_flags,
  781. uint16_t token,
  782. uint16_t *data_offset);
  783. /* Enable auto-negotiation */
  784. #define DPNI_LINK_OPT_AUTONEG 0x0000000000000001ULL
  785. /* Enable half-duplex mode */
  786. #define DPNI_LINK_OPT_HALF_DUPLEX 0x0000000000000002ULL
  787. /* Enable pause frames */
  788. #define DPNI_LINK_OPT_PAUSE 0x0000000000000004ULL
  789. /* Enable a-symmetric pause frames */
  790. #define DPNI_LINK_OPT_ASYM_PAUSE 0x0000000000000008ULL
  791. /**
  792. * struct - Structure representing DPNI link configuration
  793. * @rate: Rate
  794. * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
  795. */
  796. struct dpni_link_cfg {
  797. uint32_t rate;
  798. uint64_t options;
  799. };
  800. /**
  801. * dpni_set_link_cfg() - set the link configuration.
  802. * @mc_io: Pointer to MC portal's I/O object
  803. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  804. * @token: Token of DPNI object
  805. * @cfg: Link configuration
  806. *
  807. * Return: '0' on Success; Error code otherwise.
  808. */
  809. int dpni_set_link_cfg(struct fsl_mc_io *mc_io,
  810. uint32_t cmd_flags,
  811. uint16_t token,
  812. const struct dpni_link_cfg *cfg);
  813. /**
  814. * struct dpni_link_state - Structure representing DPNI link state
  815. * @rate: Rate
  816. * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
  817. * @up: Link state; '0' for down, '1' for up
  818. */
  819. struct dpni_link_state {
  820. uint32_t rate;
  821. uint64_t options;
  822. int up;
  823. };
  824. /**
  825. * dpni_get_link_state() - Return the link state (either up or down)
  826. * @mc_io: Pointer to MC portal's I/O object
  827. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  828. * @token: Token of DPNI object
  829. * @state: Returned link state;
  830. *
  831. * Return: '0' on Success; Error code otherwise.
  832. */
  833. int dpni_get_link_state(struct fsl_mc_io *mc_io,
  834. uint32_t cmd_flags,
  835. uint16_t token,
  836. struct dpni_link_state *state);
  837. /**
  838. * dpni_set_primary_mac_addr() - Set the primary MAC address
  839. * @mc_io: Pointer to MC portal's I/O object
  840. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  841. * @token: Token of DPNI object
  842. * @mac_addr: MAC address to set as primary address
  843. *
  844. * Return: '0' on Success; Error code otherwise.
  845. */
  846. int dpni_set_primary_mac_addr(struct fsl_mc_io *mc_io,
  847. uint32_t cmd_flags,
  848. uint16_t token,
  849. const uint8_t mac_addr[6]);
  850. /**
  851. * dpni_get_primary_mac_addr() - Get the primary MAC address
  852. * @mc_io: Pointer to MC portal's I/O object
  853. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  854. * @token: Token of DPNI object
  855. * @mac_addr: Returned MAC address
  856. *
  857. * Return: '0' on Success; Error code otherwise.
  858. */
  859. int dpni_get_primary_mac_addr(struct fsl_mc_io *mc_io,
  860. uint32_t cmd_flags,
  861. uint16_t token,
  862. uint8_t mac_addr[6]);
  863. /**
  864. * dpni_add_mac_addr() - Add MAC address filter
  865. * @mc_io: Pointer to MC portal's I/O object
  866. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  867. * @token: Token of DPNI object
  868. * @mac_addr: MAC address to add
  869. *
  870. * Return: '0' on Success; Error code otherwise.
  871. */
  872. int dpni_add_mac_addr(struct fsl_mc_io *mc_io,
  873. uint32_t cmd_flags,
  874. uint16_t token,
  875. const uint8_t mac_addr[6]);
  876. /**
  877. * dpni_remove_mac_addr() - Remove MAC address filter
  878. * @mc_io: Pointer to MC portal's I/O object
  879. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  880. * @token: Token of DPNI object
  881. * @mac_addr: MAC address to remove
  882. *
  883. * Return: '0' on Success; Error code otherwise.
  884. */
  885. int dpni_remove_mac_addr(struct fsl_mc_io *mc_io,
  886. uint32_t cmd_flags,
  887. uint16_t token,
  888. const uint8_t mac_addr[6]);
  889. /**
  890. * enum dpni_dest - DPNI destination types
  891. * @DPNI_DEST_NONE: Unassigned destination; The queue is set in parked mode and
  892. * does not generate FQDAN notifications; user is expected to
  893. * dequeue from the queue based on polling or other user-defined
  894. * method
  895. * @DPNI_DEST_DPIO: The queue is set in schedule mode and generates FQDAN
  896. * notifications to the specified DPIO; user is expected to dequeue
  897. * from the queue only after notification is received
  898. * @DPNI_DEST_DPCON: The queue is set in schedule mode and does not generate
  899. * FQDAN notifications, but is connected to the specified DPCON
  900. * object; user is expected to dequeue from the DPCON channel
  901. */
  902. enum dpni_dest {
  903. DPNI_DEST_NONE = 0,
  904. DPNI_DEST_DPIO = 1,
  905. DPNI_DEST_DPCON = 2
  906. };
  907. /**
  908. * struct dpni_dest_cfg - Structure representing DPNI destination parameters
  909. * @dest_type: Destination type
  910. * @dest_id: Either DPIO ID or DPCON ID, depending on the destination type
  911. * @priority: Priority selection within the DPIO or DPCON channel; valid values
  912. * are 0-1 or 0-7, depending on the number of priorities in that
  913. * channel; not relevant for 'DPNI_DEST_NONE' option
  914. */
  915. struct dpni_dest_cfg {
  916. enum dpni_dest dest_type;
  917. int dest_id;
  918. uint8_t priority;
  919. };
  920. /**
  921. * enum dpni_flc_type - DPNI FLC types
  922. * @DPNI_FLC_USER_DEFINED: select the FLC to be used for user defined value
  923. * @DPNI_FLC_STASH: select the FLC to be used for stash control
  924. */
  925. enum dpni_flc_type {
  926. DPNI_FLC_USER_DEFINED = 0,
  927. DPNI_FLC_STASH = 1,
  928. };
  929. /**
  930. * enum dpni_stash_size - DPNI FLC stashing size
  931. * @DPNI_STASH_SIZE_0B: no stash
  932. * @DPNI_STASH_SIZE_64B: stashes 64 bytes
  933. * @DPNI_STASH_SIZE_128B: stashes 128 bytes
  934. * @DPNI_STASH_SIZE_192B: stashes 192 bytes
  935. */
  936. enum dpni_stash_size {
  937. DPNI_STASH_SIZE_0B = 0,
  938. DPNI_STASH_SIZE_64B = 1,
  939. DPNI_STASH_SIZE_128B = 2,
  940. DPNI_STASH_SIZE_192B = 3,
  941. };
  942. /* DPNI FLC stash options */
  943. /* stashes the whole annotation area (up to 192 bytes) */
  944. #define DPNI_FLC_STASH_FRAME_ANNOTATION 0x00000001
  945. /**
  946. * struct dpni_flc_cfg - Structure representing DPNI FLC configuration
  947. * @flc_type: FLC type
  948. * @options: Mask of available options;
  949. * use 'DPNI_FLC_STASH_<X>' values
  950. * @frame_data_size: Size of frame data to be stashed
  951. * @flow_context_size: Size of flow context to be stashed
  952. * @flow_context: 1. In case flc_type is 'DPNI_FLC_USER_DEFINED':
  953. * this value will be provided in the frame descriptor
  954. * (FD[FLC])
  955. * 2. In case flc_type is 'DPNI_FLC_STASH':
  956. * this value will be I/O virtual address of the
  957. * flow-context;
  958. * Must be cacheline-aligned and DMA-able memory
  959. */
  960. struct dpni_flc_cfg {
  961. enum dpni_flc_type flc_type;
  962. uint32_t options;
  963. enum dpni_stash_size frame_data_size;
  964. enum dpni_stash_size flow_context_size;
  965. uint64_t flow_context;
  966. };
  967. /* DPNI queue modification options */
  968. /* Select to modify the user's context associated with the queue */
  969. #define DPNI_QUEUE_OPT_USER_CTX 0x00000001
  970. /* Select to modify the queue's destination */
  971. #define DPNI_QUEUE_OPT_DEST 0x00000002
  972. /** Select to modify the flow-context parameters;
  973. * not applicable for Tx-conf/Err queues as the FD comes from the user
  974. */
  975. #define DPNI_QUEUE_OPT_FLC 0x00000004
  976. /* Select to modify the queue's order preservation */
  977. #define DPNI_QUEUE_OPT_ORDER_PRESERVATION 0x00000008
  978. /* Select to modify the queue's tail-drop threshold */
  979. #define DPNI_QUEUE_OPT_TAILDROP_THRESHOLD 0x00000010
  980. /**
  981. * struct dpni_queue_cfg - Structure representing queue configuration
  982. * @options: Flags representing the suggested modifications to the queue;
  983. * Use any combination of 'DPNI_QUEUE_OPT_<X>' flags
  984. * @user_ctx: User context value provided in the frame descriptor of each
  985. * dequeued frame; valid only if 'DPNI_QUEUE_OPT_USER_CTX'
  986. * is contained in 'options'
  987. * @dest_cfg: Queue destination parameters;
  988. * valid only if 'DPNI_QUEUE_OPT_DEST' is contained in 'options'
  989. * @flc_cfg: Flow context configuration; in case the TC's distribution
  990. * is either NONE or HASH the FLC's settings of flow#0 are used.
  991. * in the case of FS (flow-steering) the flow's FLC settings
  992. * are used.
  993. * valid only if 'DPNI_QUEUE_OPT_FLC' is contained in 'options'
  994. * @order_preservation_en: enable/disable order preservation;
  995. * valid only if 'DPNI_QUEUE_OPT_ORDER_PRESERVATION' is contained
  996. * in 'options'
  997. * @tail_drop_threshold: set the queue's tail drop threshold in bytes;
  998. * '0' value disable the threshold; maximum value is 0xE000000;
  999. * valid only if 'DPNI_QUEUE_OPT_TAILDROP_THRESHOLD' is contained
  1000. * in 'options'
  1001. */
  1002. struct dpni_queue_cfg {
  1003. uint32_t options;
  1004. uint64_t user_ctx;
  1005. struct dpni_dest_cfg dest_cfg;
  1006. struct dpni_flc_cfg flc_cfg;
  1007. int order_preservation_en;
  1008. uint32_t tail_drop_threshold;
  1009. };
  1010. /**
  1011. * struct dpni_queue_attr - Structure representing queue attributes
  1012. * @user_ctx: User context value provided in the frame descriptor of each
  1013. * dequeued frame
  1014. * @dest_cfg: Queue destination configuration
  1015. * @flc_cfg: Flow context configuration
  1016. * @order_preservation_en: enable/disable order preservation
  1017. * @tail_drop_threshold: queue's tail drop threshold in bytes;
  1018. * @fqid: Virtual fqid value to be used for dequeue operations
  1019. */
  1020. struct dpni_queue_attr {
  1021. uint64_t user_ctx;
  1022. struct dpni_dest_cfg dest_cfg;
  1023. struct dpni_flc_cfg flc_cfg;
  1024. int order_preservation_en;
  1025. uint32_t tail_drop_threshold;
  1026. uint32_t fqid;
  1027. };
  1028. /* DPNI Tx flow modification options */
  1029. /* Select to modify the settings for dedicate Tx confirmation/error */
  1030. #define DPNI_TX_FLOW_OPT_TX_CONF_ERROR 0x00000001
  1031. /*!< Select to modify the L3 checksum generation setting */
  1032. #define DPNI_TX_FLOW_OPT_L3_CHKSUM_GEN 0x00000010
  1033. /*!< Select to modify the L4 checksum generation setting */
  1034. #define DPNI_TX_FLOW_OPT_L4_CHKSUM_GEN 0x00000020
  1035. /**
  1036. * dpni_get_api_version - Retrieve DPNI Major and Minor version info.
  1037. *
  1038. * @mc_io: Pointer to MC portal's I/O object
  1039. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  1040. * @major_ver: DPNI major version
  1041. * @minor_ver: DPNI minor version
  1042. *
  1043. * Return: '0' on Success; Error code otherwise.
  1044. */
  1045. int dpni_get_api_version(struct fsl_mc_io *mc_io,
  1046. u32 cmd_flags,
  1047. u16 *major_ver,
  1048. u16 *minor_ver);
  1049. /**
  1050. * enum dpni_confirmation_mode - Defines DPNI options supported for Tx
  1051. * confirmation
  1052. * @DPNI_CONF_AFFINE: For each Tx queue set associated with a sender there is
  1053. * an affine Tx Confirmation queue
  1054. * @DPNI_CONF_SINGLE: All Tx queues are associated with a single Tx
  1055. * confirmation queue
  1056. * @DPNI_CONF_DISABLE: Tx frames are not confirmed. This must be associated
  1057. * with proper FD set-up to have buffers release to a Buffer Pool, otherwise
  1058. * buffers will be leaked.
  1059. */
  1060. enum dpni_confirmation_mode {
  1061. DPNI_CONF_AFFINE,
  1062. DPNI_CONF_SINGLE,
  1063. DPNI_CONF_DISABLE,
  1064. };
  1065. struct dpni_tx_confirmation_mode {
  1066. uint32_t pad;
  1067. uint8_t confirmation_mode;
  1068. };
  1069. /**
  1070. * struct dpni_queue - Queue structure
  1071. * @fqid: FQID used for enqueueing to and/or configuration of this specific FQ
  1072. * @qdbin: Queueing bin, used to enqueue using QDID, DQBIN, QPRI. Only relevant
  1073. * for Tx queues.
  1074. * @flc: FLC value for traffic dequeued from this queue.
  1075. * @user_context: User data, presented to the user along with any frames
  1076. * from this queue. Not relevant for Tx queues.
  1077. */
  1078. struct dpni_queue {
  1079. /**
  1080. * struct destination - Destination structure
  1081. * @id: ID of the destination, only relevant if DEST_TYPE is > 0.
  1082. * Identifies either a DPIO or a DPCON object. Not relevant for Tx
  1083. * queues.
  1084. * @type: May be one of the following:
  1085. * 0 - No destination, queue can be manually queried, but won't
  1086. * push traffic or notifications to a DPIO;
  1087. * 1 - The destination is DPIO. When traffic becomes available in
  1088. * the queue a FQDAN (FQ data available notification) will be
  1089. * generated to selected DPIO;
  1090. * 2 - The destination is a DPCON. The queue is associated with a
  1091. * DPCON object for purpose of scheduling between multiple
  1092. * queues. The DPCON may be independently configured to
  1093. * generate notifications. Not relevant for Tx queues.
  1094. * @hold_active: Hold active
  1095. */
  1096. struct {
  1097. uint32_t id;
  1098. enum dpni_dest type;
  1099. char hold_active;
  1100. char stash_ctrl;
  1101. } destination;
  1102. uint8_t options;
  1103. uint32_t fqid;
  1104. uint16_t qdbin;
  1105. uint64_t flc;
  1106. uint64_t user_context;
  1107. };
  1108. /**
  1109. * dpni_set_queue() - Set queue parameters
  1110. * @mc_io: Pointer to MC portal's I/O object
  1111. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  1112. * @token: Token of DPNI object
  1113. * @type: Type of queue
  1114. * @tc: Traffic class, in range 0 to NUM_TCS - 1
  1115. * @index: Selects the specific queue out of the set allocated for the same
  1116. * TC. Value must be in range 0 to NUM_QUEUES - 1
  1117. * @queue: Queue structure
  1118. *
  1119. * Return: '0' on Success; Error code otherwise.
  1120. */
  1121. int dpni_set_queue(struct fsl_mc_io *mc_io,
  1122. uint32_t cmd_flags,
  1123. uint16_t token,
  1124. enum dpni_queue_type type,
  1125. uint8_t tc,
  1126. uint8_t index,
  1127. const struct dpni_queue *queue);
  1128. /**
  1129. * dpni_get_queue() - Get queue parameters
  1130. * @mc_io: Pointer to MC portal's I/O object
  1131. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  1132. * @token: Token of DPNI object
  1133. * @type: Type of queue
  1134. * @tc: Traffic class, in range 0 to NUM_TCS - 1
  1135. * @index: Selects the specific queue out of the set allocated for the same
  1136. * TC. Value must be in range 0 to NUM_QUEUES - 1
  1137. * @queue: Queue structure
  1138. *
  1139. * Return: '0' on Success; Error code otherwise.
  1140. */
  1141. int dpni_get_queue(struct fsl_mc_io *mc_io,
  1142. uint32_t cmd_flags,
  1143. uint16_t token,
  1144. enum dpni_queue_type type,
  1145. uint8_t tc,
  1146. uint8_t index,
  1147. struct dpni_queue *queue);
  1148. /**
  1149. * dpni_set_tx_confirmation_mode() - Set TX conf mode
  1150. * @mc_io: Pointer to MC portal's I/O object
  1151. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  1152. * @token: Token of DPNI object
  1153. * @mode: DPNI confirmation mode type
  1154. *
  1155. * Return: '0' on Success; Error code otherwise.
  1156. */
  1157. int dpni_set_tx_confirmation_mode(struct fsl_mc_io *mc_io,
  1158. uint32_t cmd_flags,
  1159. uint16_t token,
  1160. enum dpni_confirmation_mode mode);
  1161. struct dpni_statistics {
  1162. /**
  1163. * Page_0 statistics structure
  1164. * @ingress_all_frames: Ingress frame count
  1165. * @ingress_all_bytes: Ingress byte count
  1166. * @ingress_multicast_frames: Ingress multicast frame count
  1167. * @ingress_multicast_bytes: Ingress multicast byte count
  1168. * @ingress_broadcast_frames: Ingress broadcast frame count
  1169. * @ingress_broadcast_bytes: Ingress broadcast byte count
  1170. *
  1171. * Page_1 statistics structure
  1172. * @egress_all_frames: Egress frame count
  1173. * @egress_all_bytes: Egress byte count
  1174. * @egress_multicast_frames: Egress multicast frame count
  1175. * @egress_multicast_bytes: Egress multicast byte count
  1176. * @egress_broadcast_frames: Egress broadcast frame count
  1177. * @egress_broadcast_bytes: Egress broadcast byte count
  1178. *
  1179. * Page_2 statistics structure
  1180. * @ingress_filtered_frames: Ingress filtered frame count
  1181. * @ingress_discarded_frames: Ingress discarded frame count
  1182. * @ingress_nobuffer_discards: Ingress discarded frame count due to
  1183. * lack of buffers.
  1184. * @egress_discarded_frames: Egress discarded frame count
  1185. * @egress_confirmed_frames: Egress confirmed frame count
  1186. */
  1187. uint64_t counter0;
  1188. uint64_t counter1;
  1189. uint64_t counter2;
  1190. uint64_t counter3;
  1191. uint64_t counter4;
  1192. uint64_t counter5;
  1193. uint64_t counter6;
  1194. };
  1195. /**
  1196. * dpni_get_statistics() - Get DPNI statistics
  1197. * @mc_io: Pointer to MC portal's I/O object
  1198. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  1199. * @token: Token of DPNI object
  1200. * @page: Selects the statistics page to retrieve, see DPNI_GET_STATISTICS
  1201. * output. Pages are numbered 0 to 2.
  1202. * @stat: Structure containing the statistics
  1203. *
  1204. * Return: '0' on Success; Error code otherwise.
  1205. */
  1206. int dpni_get_statistics(struct fsl_mc_io *mc_io,
  1207. uint32_t cmd_flags,
  1208. uint16_t token,
  1209. uint8_t page,
  1210. struct dpni_statistics *stat);
  1211. /**
  1212. * dpni_reset_statistics() - Clears DPNI statistics
  1213. * @mc_io: Pointer to MC portal's I/O object
  1214. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  1215. * @token: Token of DPNI object
  1216. *
  1217. * Return: '0' on Success; Error code otherwise.
  1218. */
  1219. int dpni_reset_statistics(struct fsl_mc_io *mc_io,
  1220. uint32_t cmd_flags,
  1221. uint16_t token);
  1222. #endif /* _FSL_DPNI_H */