fsl_dpni.h 60 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688
  1. /*
  2. * Copyright (C) 2013-2015 Freescale Semiconductor
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #ifndef _FSL_DPNI_H
  7. #define _FSL_DPNI_H
  8. /* DPNI Version */
  9. #define DPNI_VER_MAJOR 6
  10. #define DPNI_VER_MINOR 0
  11. /* Command IDs */
  12. #define DPNI_CMDID_OPEN 0x801
  13. #define DPNI_CMDID_CLOSE 0x800
  14. #define DPNI_CMDID_CREATE 0x901
  15. #define DPNI_CMDID_DESTROY 0x900
  16. #define DPNI_CMDID_ENABLE 0x002
  17. #define DPNI_CMDID_DISABLE 0x003
  18. #define DPNI_CMDID_GET_ATTR 0x004
  19. #define DPNI_CMDID_RESET 0x005
  20. #define DPNI_CMDID_SET_POOLS 0x200
  21. #define DPNI_CMDID_GET_RX_BUFFER_LAYOUT 0x201
  22. #define DPNI_CMDID_SET_RX_BUFFER_LAYOUT 0x202
  23. #define DPNI_CMDID_GET_TX_BUFFER_LAYOUT 0x203
  24. #define DPNI_CMDID_SET_TX_BUFFER_LAYOUT 0x204
  25. #define DPNI_CMDID_SET_TX_CONF_BUFFER_LAYOUT 0x205
  26. #define DPNI_CMDID_GET_TX_CONF_BUFFER_LAYOUT 0x206
  27. #define DPNI_CMDID_SET_ERRORS_BEHAVIOR 0x20B
  28. #define DPNI_CMDID_GET_QDID 0x210
  29. #define DPNI_CMDID_GET_TX_DATA_OFFSET 0x212
  30. #define DPNI_CMDID_GET_COUNTER 0x213
  31. #define DPNI_CMDID_SET_COUNTER 0x214
  32. #define DPNI_CMDID_GET_LINK_STATE 0x215
  33. #define DPNI_CMDID_SET_LINK_CFG 0x21A
  34. #define DPNI_CMDID_SET_PRIM_MAC 0x224
  35. #define DPNI_CMDID_GET_PRIM_MAC 0x225
  36. #define DPNI_CMDID_ADD_MAC_ADDR 0x226
  37. #define DPNI_CMDID_REMOVE_MAC_ADDR 0x227
  38. #define DPNI_CMDID_SET_TX_FLOW 0x236
  39. #define DPNI_CMDID_GET_TX_FLOW 0x237
  40. #define DPNI_CMDID_SET_RX_FLOW 0x238
  41. #define DPNI_CMDID_GET_RX_FLOW 0x239
  42. #define DPNI_CMDID_SET_TX_CONF 0x257
  43. #define DPNI_CMDID_GET_TX_CONF 0x258
  44. /* cmd, param, offset, width, type, arg_name */
  45. #define DPNI_CMD_OPEN(cmd, dpni_id) \
  46. MC_CMD_OP(cmd, 0, 0, 32, int, dpni_id)
  47. #define DPNI_PREP_EXTENDED_CFG(ext, cfg) \
  48. do { \
  49. MC_PREP_OP(ext, 0, 0, 16, uint16_t, cfg->tc_cfg[0].max_dist); \
  50. MC_PREP_OP(ext, 0, 16, 16, uint16_t, cfg->tc_cfg[0].max_fs_entries); \
  51. MC_PREP_OP(ext, 0, 32, 16, uint16_t, cfg->tc_cfg[1].max_dist); \
  52. MC_PREP_OP(ext, 0, 48, 16, uint16_t, cfg->tc_cfg[1].max_fs_entries); \
  53. MC_PREP_OP(ext, 1, 0, 16, uint16_t, cfg->tc_cfg[2].max_dist); \
  54. MC_PREP_OP(ext, 1, 16, 16, uint16_t, cfg->tc_cfg[2].max_fs_entries); \
  55. MC_PREP_OP(ext, 1, 32, 16, uint16_t, cfg->tc_cfg[3].max_dist); \
  56. MC_PREP_OP(ext, 1, 48, 16, uint16_t, cfg->tc_cfg[3].max_fs_entries); \
  57. MC_PREP_OP(ext, 2, 0, 16, uint16_t, cfg->tc_cfg[4].max_dist); \
  58. MC_PREP_OP(ext, 2, 16, 16, uint16_t, cfg->tc_cfg[4].max_fs_entries); \
  59. MC_PREP_OP(ext, 2, 32, 16, uint16_t, cfg->tc_cfg[5].max_dist); \
  60. MC_PREP_OP(ext, 2, 48, 16, uint16_t, cfg->tc_cfg[5].max_fs_entries); \
  61. MC_PREP_OP(ext, 3, 0, 16, uint16_t, cfg->tc_cfg[6].max_dist); \
  62. MC_PREP_OP(ext, 3, 16, 16, uint16_t, cfg->tc_cfg[6].max_fs_entries); \
  63. MC_PREP_OP(ext, 3, 32, 16, uint16_t, cfg->tc_cfg[7].max_dist); \
  64. MC_PREP_OP(ext, 3, 48, 16, uint16_t, cfg->tc_cfg[7].max_fs_entries); \
  65. MC_PREP_OP(ext, 4, 0, 16, uint16_t, \
  66. cfg->ipr_cfg.max_open_frames_ipv4); \
  67. MC_PREP_OP(ext, 4, 16, 16, uint16_t, \
  68. cfg->ipr_cfg.max_open_frames_ipv6); \
  69. MC_PREP_OP(ext, 4, 32, 16, uint16_t, \
  70. cfg->ipr_cfg.max_reass_frm_size); \
  71. MC_PREP_OP(ext, 5, 0, 16, uint16_t, \
  72. cfg->ipr_cfg.min_frag_size_ipv4); \
  73. MC_PREP_OP(ext, 5, 16, 16, uint16_t, \
  74. cfg->ipr_cfg.min_frag_size_ipv6); \
  75. } while (0)
  76. #define DPNI_EXT_EXTENDED_CFG(ext, cfg) \
  77. do { \
  78. MC_EXT_OP(ext, 0, 0, 16, uint16_t, cfg->tc_cfg[0].max_dist); \
  79. MC_EXT_OP(ext, 0, 16, 16, uint16_t, cfg->tc_cfg[0].max_fs_entries); \
  80. MC_EXT_OP(ext, 0, 32, 16, uint16_t, cfg->tc_cfg[1].max_dist); \
  81. MC_EXT_OP(ext, 0, 48, 16, uint16_t, cfg->tc_cfg[1].max_fs_entries); \
  82. MC_EXT_OP(ext, 1, 0, 16, uint16_t, cfg->tc_cfg[2].max_dist); \
  83. MC_EXT_OP(ext, 1, 16, 16, uint16_t, cfg->tc_cfg[2].max_fs_entries); \
  84. MC_EXT_OP(ext, 1, 32, 16, uint16_t, cfg->tc_cfg[3].max_dist); \
  85. MC_EXT_OP(ext, 1, 48, 16, uint16_t, cfg->tc_cfg[3].max_fs_entries); \
  86. MC_EXT_OP(ext, 2, 0, 16, uint16_t, cfg->tc_cfg[4].max_dist); \
  87. MC_EXT_OP(ext, 2, 16, 16, uint16_t, cfg->tc_cfg[4].max_fs_entries); \
  88. MC_EXT_OP(ext, 2, 32, 16, uint16_t, cfg->tc_cfg[5].max_dist); \
  89. MC_EXT_OP(ext, 2, 48, 16, uint16_t, cfg->tc_cfg[5].max_fs_entries); \
  90. MC_EXT_OP(ext, 3, 0, 16, uint16_t, cfg->tc_cfg[6].max_dist); \
  91. MC_EXT_OP(ext, 3, 16, 16, uint16_t, cfg->tc_cfg[6].max_fs_entries); \
  92. MC_EXT_OP(ext, 3, 32, 16, uint16_t, cfg->tc_cfg[7].max_dist); \
  93. MC_EXT_OP(ext, 3, 48, 16, uint16_t, cfg->tc_cfg[7].max_fs_entries); \
  94. MC_EXT_OP(ext, 4, 0, 16, uint16_t, \
  95. cfg->ipr_cfg.max_open_frames_ipv4); \
  96. MC_EXT_OP(ext, 4, 16, 16, uint16_t, \
  97. cfg->ipr_cfg.max_open_frames_ipv6); \
  98. MC_EXT_OP(ext, 4, 32, 16, uint16_t, \
  99. cfg->ipr_cfg.max_reass_frm_size); \
  100. MC_EXT_OP(ext, 5, 0, 16, uint16_t, \
  101. cfg->ipr_cfg.min_frag_size_ipv4); \
  102. MC_EXT_OP(ext, 5, 16, 16, uint16_t, \
  103. cfg->ipr_cfg.min_frag_size_ipv6); \
  104. } while (0)
  105. /* cmd, param, offset, width, type, arg_name */
  106. #define DPNI_CMD_CREATE(cmd, cfg) \
  107. do { \
  108. MC_CMD_OP(cmd, 0, 0, 8, uint8_t, cfg->adv.max_tcs); \
  109. MC_CMD_OP(cmd, 0, 8, 8, uint8_t, cfg->adv.max_senders); \
  110. MC_CMD_OP(cmd, 0, 16, 8, uint8_t, cfg->mac_addr[5]); \
  111. MC_CMD_OP(cmd, 0, 24, 8, uint8_t, cfg->mac_addr[4]); \
  112. MC_CMD_OP(cmd, 0, 32, 8, uint8_t, cfg->mac_addr[3]); \
  113. MC_CMD_OP(cmd, 0, 40, 8, uint8_t, cfg->mac_addr[2]); \
  114. MC_CMD_OP(cmd, 0, 48, 8, uint8_t, cfg->mac_addr[1]); \
  115. MC_CMD_OP(cmd, 0, 56, 8, uint8_t, cfg->mac_addr[0]); \
  116. MC_CMD_OP(cmd, 1, 0, 32, uint32_t, cfg->adv.options); \
  117. MC_CMD_OP(cmd, 2, 0, 8, uint8_t, cfg->adv.max_unicast_filters); \
  118. MC_CMD_OP(cmd, 2, 8, 8, uint8_t, cfg->adv.max_multicast_filters); \
  119. MC_CMD_OP(cmd, 2, 16, 8, uint8_t, cfg->adv.max_vlan_filters); \
  120. MC_CMD_OP(cmd, 2, 24, 8, uint8_t, cfg->adv.max_qos_entries); \
  121. MC_CMD_OP(cmd, 2, 32, 8, uint8_t, cfg->adv.max_qos_key_size); \
  122. MC_CMD_OP(cmd, 2, 48, 8, uint8_t, cfg->adv.max_dist_key_size); \
  123. MC_CMD_OP(cmd, 2, 56, 8, enum net_prot, cfg->adv.start_hdr); \
  124. MC_CMD_OP(cmd, 4, 48, 8, uint8_t, cfg->adv.max_policers); \
  125. MC_CMD_OP(cmd, 4, 56, 8, uint8_t, cfg->adv.max_congestion_ctrl); \
  126. MC_CMD_OP(cmd, 5, 0, 64, uint64_t, cfg->adv.ext_cfg_iova); \
  127. } while (0)
  128. /* cmd, param, offset, width, type, arg_name */
  129. #define DPNI_CMD_SET_POOLS(cmd, cfg) \
  130. do { \
  131. MC_CMD_OP(cmd, 0, 0, 8, uint8_t, cfg->num_dpbp); \
  132. MC_CMD_OP(cmd, 0, 8, 1, int, cfg->pools[0].backup_pool); \
  133. MC_CMD_OP(cmd, 0, 9, 1, int, cfg->pools[1].backup_pool); \
  134. MC_CMD_OP(cmd, 0, 10, 1, int, cfg->pools[2].backup_pool); \
  135. MC_CMD_OP(cmd, 0, 11, 1, int, cfg->pools[3].backup_pool); \
  136. MC_CMD_OP(cmd, 0, 12, 1, int, cfg->pools[4].backup_pool); \
  137. MC_CMD_OP(cmd, 0, 13, 1, int, cfg->pools[5].backup_pool); \
  138. MC_CMD_OP(cmd, 0, 14, 1, int, cfg->pools[6].backup_pool); \
  139. MC_CMD_OP(cmd, 0, 15, 1, int, cfg->pools[7].backup_pool); \
  140. MC_CMD_OP(cmd, 0, 32, 32, int, cfg->pools[0].dpbp_id); \
  141. MC_CMD_OP(cmd, 4, 32, 16, uint16_t, cfg->pools[0].buffer_size);\
  142. MC_CMD_OP(cmd, 1, 0, 32, int, cfg->pools[1].dpbp_id); \
  143. MC_CMD_OP(cmd, 4, 48, 16, uint16_t, cfg->pools[1].buffer_size);\
  144. MC_CMD_OP(cmd, 1, 32, 32, int, cfg->pools[2].dpbp_id); \
  145. MC_CMD_OP(cmd, 5, 0, 16, uint16_t, cfg->pools[2].buffer_size);\
  146. MC_CMD_OP(cmd, 2, 0, 32, int, cfg->pools[3].dpbp_id); \
  147. MC_CMD_OP(cmd, 5, 16, 16, uint16_t, cfg->pools[3].buffer_size);\
  148. MC_CMD_OP(cmd, 2, 32, 32, int, cfg->pools[4].dpbp_id); \
  149. MC_CMD_OP(cmd, 5, 32, 16, uint16_t, cfg->pools[4].buffer_size);\
  150. MC_CMD_OP(cmd, 3, 0, 32, int, cfg->pools[5].dpbp_id); \
  151. MC_CMD_OP(cmd, 5, 48, 16, uint16_t, cfg->pools[5].buffer_size);\
  152. MC_CMD_OP(cmd, 3, 32, 32, int, cfg->pools[6].dpbp_id); \
  153. MC_CMD_OP(cmd, 6, 0, 16, uint16_t, cfg->pools[6].buffer_size);\
  154. MC_CMD_OP(cmd, 4, 0, 32, int, cfg->pools[7].dpbp_id); \
  155. MC_CMD_OP(cmd, 6, 16, 16, uint16_t, cfg->pools[7].buffer_size);\
  156. } while (0)
  157. /* cmd, param, offset, width, type, arg_name */
  158. #define DPNI_CMD_GET_ATTR(cmd, attr) \
  159. MC_CMD_OP(cmd, 6, 0, 64, uint64_t, attr->ext_cfg_iova)
  160. /* cmd, param, offset, width, type, arg_name */
  161. #define DPNI_RSP_GET_ATTR(cmd, attr) \
  162. do { \
  163. MC_RSP_OP(cmd, 0, 0, 32, int, attr->id);\
  164. MC_RSP_OP(cmd, 0, 32, 8, uint8_t, attr->max_tcs); \
  165. MC_RSP_OP(cmd, 0, 40, 8, uint8_t, attr->max_senders); \
  166. MC_RSP_OP(cmd, 0, 48, 8, enum net_prot, attr->start_hdr); \
  167. MC_RSP_OP(cmd, 1, 0, 32, uint32_t, attr->options); \
  168. MC_RSP_OP(cmd, 2, 0, 8, uint8_t, attr->max_unicast_filters); \
  169. MC_RSP_OP(cmd, 2, 8, 8, uint8_t, attr->max_multicast_filters);\
  170. MC_RSP_OP(cmd, 2, 16, 8, uint8_t, attr->max_vlan_filters); \
  171. MC_RSP_OP(cmd, 2, 24, 8, uint8_t, attr->max_qos_entries); \
  172. MC_RSP_OP(cmd, 2, 32, 8, uint8_t, attr->max_qos_key_size); \
  173. MC_RSP_OP(cmd, 2, 40, 8, uint8_t, attr->max_dist_key_size); \
  174. MC_RSP_OP(cmd, 4, 48, 8, uint8_t, attr->max_policers); \
  175. MC_RSP_OP(cmd, 4, 56, 8, uint8_t, attr->max_congestion_ctrl); \
  176. MC_RSP_OP(cmd, 5, 32, 16, uint16_t, attr->version.major);\
  177. MC_RSP_OP(cmd, 5, 48, 16, uint16_t, attr->version.minor);\
  178. } while (0)
  179. /* cmd, param, offset, width, type, arg_name */
  180. #define DPNI_CMD_SET_ERRORS_BEHAVIOR(cmd, cfg) \
  181. do { \
  182. MC_CMD_OP(cmd, 0, 0, 32, uint32_t, cfg->errors); \
  183. MC_CMD_OP(cmd, 0, 32, 4, enum dpni_error_action, cfg->error_action); \
  184. MC_CMD_OP(cmd, 0, 36, 1, int, cfg->set_frame_annotation); \
  185. } while (0)
  186. /* cmd, param, offset, width, type, arg_name */
  187. #define DPNI_RSP_GET_RX_BUFFER_LAYOUT(cmd, layout) \
  188. do { \
  189. MC_RSP_OP(cmd, 0, 0, 16, uint16_t, layout->private_data_size); \
  190. MC_RSP_OP(cmd, 0, 16, 16, uint16_t, layout->data_align); \
  191. MC_RSP_OP(cmd, 1, 0, 1, int, layout->pass_timestamp); \
  192. MC_RSP_OP(cmd, 1, 1, 1, int, layout->pass_parser_result); \
  193. MC_RSP_OP(cmd, 1, 2, 1, int, layout->pass_frame_status); \
  194. MC_RSP_OP(cmd, 1, 16, 16, uint16_t, layout->data_head_room); \
  195. MC_RSP_OP(cmd, 1, 32, 16, uint16_t, layout->data_tail_room); \
  196. } while (0)
  197. /* cmd, param, offset, width, type, arg_name */
  198. #define DPNI_CMD_SET_RX_BUFFER_LAYOUT(cmd, layout) \
  199. do { \
  200. MC_CMD_OP(cmd, 0, 0, 16, uint16_t, layout->private_data_size); \
  201. MC_CMD_OP(cmd, 0, 16, 16, uint16_t, layout->data_align); \
  202. MC_CMD_OP(cmd, 0, 32, 32, uint32_t, layout->options); \
  203. MC_CMD_OP(cmd, 1, 0, 1, int, layout->pass_timestamp); \
  204. MC_CMD_OP(cmd, 1, 1, 1, int, layout->pass_parser_result); \
  205. MC_CMD_OP(cmd, 1, 2, 1, int, layout->pass_frame_status); \
  206. MC_CMD_OP(cmd, 1, 16, 16, uint16_t, layout->data_head_room); \
  207. MC_CMD_OP(cmd, 1, 32, 16, uint16_t, layout->data_tail_room); \
  208. } while (0)
  209. /* cmd, param, offset, width, type, arg_name */
  210. #define DPNI_RSP_GET_TX_BUFFER_LAYOUT(cmd, layout) \
  211. do { \
  212. MC_RSP_OP(cmd, 0, 0, 16, uint16_t, layout->private_data_size); \
  213. MC_RSP_OP(cmd, 0, 16, 16, uint16_t, layout->data_align); \
  214. MC_RSP_OP(cmd, 1, 0, 1, int, layout->pass_timestamp); \
  215. MC_RSP_OP(cmd, 1, 1, 1, int, layout->pass_parser_result); \
  216. MC_RSP_OP(cmd, 1, 2, 1, int, layout->pass_frame_status); \
  217. MC_RSP_OP(cmd, 1, 16, 16, uint16_t, layout->data_head_room); \
  218. MC_RSP_OP(cmd, 1, 32, 16, uint16_t, layout->data_tail_room); \
  219. } while (0)
  220. /* cmd, param, offset, width, type, arg_name */
  221. #define DPNI_CMD_SET_TX_BUFFER_LAYOUT(cmd, layout) \
  222. do { \
  223. MC_CMD_OP(cmd, 0, 0, 16, uint16_t, layout->private_data_size); \
  224. MC_CMD_OP(cmd, 0, 16, 16, uint16_t, layout->data_align); \
  225. MC_CMD_OP(cmd, 0, 32, 32, uint32_t, layout->options); \
  226. MC_CMD_OP(cmd, 1, 0, 1, int, layout->pass_timestamp); \
  227. MC_CMD_OP(cmd, 1, 1, 1, int, layout->pass_parser_result); \
  228. MC_CMD_OP(cmd, 1, 2, 1, int, layout->pass_frame_status); \
  229. MC_CMD_OP(cmd, 1, 16, 16, uint16_t, layout->data_head_room); \
  230. MC_CMD_OP(cmd, 1, 32, 16, uint16_t, layout->data_tail_room); \
  231. } while (0)
  232. /* cmd, param, offset, width, type, arg_name */
  233. #define DPNI_RSP_GET_TX_CONF_BUFFER_LAYOUT(cmd, layout) \
  234. do { \
  235. MC_RSP_OP(cmd, 0, 0, 16, uint16_t, layout->private_data_size); \
  236. MC_RSP_OP(cmd, 0, 16, 16, uint16_t, layout->data_align); \
  237. MC_RSP_OP(cmd, 1, 0, 1, int, layout->pass_timestamp); \
  238. MC_RSP_OP(cmd, 1, 1, 1, int, layout->pass_parser_result); \
  239. MC_RSP_OP(cmd, 1, 2, 1, int, layout->pass_frame_status); \
  240. MC_RSP_OP(cmd, 1, 16, 16, uint16_t, layout->data_head_room); \
  241. MC_RSP_OP(cmd, 1, 32, 16, uint16_t, layout->data_tail_room); \
  242. } while (0)
  243. /* cmd, param, offset, width, type, arg_name */
  244. #define DPNI_CMD_SET_TX_CONF_BUFFER_LAYOUT(cmd, layout) \
  245. do { \
  246. MC_CMD_OP(cmd, 0, 0, 16, uint16_t, layout->private_data_size); \
  247. MC_CMD_OP(cmd, 0, 16, 16, uint16_t, layout->data_align); \
  248. MC_CMD_OP(cmd, 0, 32, 32, uint32_t, layout->options); \
  249. MC_CMD_OP(cmd, 1, 0, 1, int, layout->pass_timestamp); \
  250. MC_CMD_OP(cmd, 1, 1, 1, int, layout->pass_parser_result); \
  251. MC_CMD_OP(cmd, 1, 2, 1, int, layout->pass_frame_status); \
  252. MC_CMD_OP(cmd, 1, 16, 16, uint16_t, layout->data_head_room); \
  253. MC_CMD_OP(cmd, 1, 32, 16, uint16_t, layout->data_tail_room); \
  254. } while (0)
  255. /* cmd, param, offset, width, type, arg_name */
  256. #define DPNI_RSP_GET_QDID(cmd, qdid) \
  257. MC_RSP_OP(cmd, 0, 0, 16, uint16_t, qdid)
  258. /* cmd, param, offset, width, type, arg_name */
  259. #define DPNI_RSP_GET_TX_DATA_OFFSET(cmd, data_offset) \
  260. MC_RSP_OP(cmd, 0, 0, 16, uint16_t, data_offset)
  261. /* cmd, param, offset, width, type, arg_name */
  262. #define DPNI_CMD_GET_COUNTER(cmd, counter) \
  263. MC_CMD_OP(cmd, 0, 0, 16, enum dpni_counter, counter)
  264. /* cmd, param, offset, width, type, arg_name */
  265. #define DPNI_RSP_GET_COUNTER(cmd, value) \
  266. MC_RSP_OP(cmd, 1, 0, 64, uint64_t, value)
  267. /* cmd, param, offset, width, type, arg_name */
  268. #define DPNI_CMD_SET_COUNTER(cmd, counter, value) \
  269. do { \
  270. MC_CMD_OP(cmd, 0, 0, 16, enum dpni_counter, counter); \
  271. MC_CMD_OP(cmd, 1, 0, 64, uint64_t, value); \
  272. } while (0)
  273. /* cmd, param, offset, width, type, arg_name */
  274. #define DPNI_CMD_SET_LINK_CFG(cmd, cfg) \
  275. do { \
  276. MC_CMD_OP(cmd, 1, 0, 32, uint32_t, cfg->rate);\
  277. MC_CMD_OP(cmd, 2, 0, 64, uint64_t, cfg->options);\
  278. } while (0)
  279. /* cmd, param, offset, width, type, arg_name */
  280. #define DPNI_RSP_GET_LINK_STATE(cmd, state) \
  281. do { \
  282. MC_RSP_OP(cmd, 0, 32, 1, int, state->up);\
  283. MC_RSP_OP(cmd, 1, 0, 32, uint32_t, state->rate);\
  284. MC_RSP_OP(cmd, 2, 0, 64, uint64_t, state->options);\
  285. } while (0)
  286. /* cmd, param, offset, width, type, arg_name */
  287. #define DPNI_CMD_SET_PRIMARY_MAC_ADDR(cmd, mac_addr) \
  288. do { \
  289. MC_CMD_OP(cmd, 0, 16, 8, uint8_t, mac_addr[5]); \
  290. MC_CMD_OP(cmd, 0, 24, 8, uint8_t, mac_addr[4]); \
  291. MC_CMD_OP(cmd, 0, 32, 8, uint8_t, mac_addr[3]); \
  292. MC_CMD_OP(cmd, 0, 40, 8, uint8_t, mac_addr[2]); \
  293. MC_CMD_OP(cmd, 0, 48, 8, uint8_t, mac_addr[1]); \
  294. MC_CMD_OP(cmd, 0, 56, 8, uint8_t, mac_addr[0]); \
  295. } while (0)
  296. /* cmd, param, offset, width, type, arg_name */
  297. #define DPNI_RSP_GET_PRIMARY_MAC_ADDR(cmd, mac_addr) \
  298. do { \
  299. MC_RSP_OP(cmd, 0, 16, 8, uint8_t, mac_addr[5]); \
  300. MC_RSP_OP(cmd, 0, 24, 8, uint8_t, mac_addr[4]); \
  301. MC_RSP_OP(cmd, 0, 32, 8, uint8_t, mac_addr[3]); \
  302. MC_RSP_OP(cmd, 0, 40, 8, uint8_t, mac_addr[2]); \
  303. MC_RSP_OP(cmd, 0, 48, 8, uint8_t, mac_addr[1]); \
  304. MC_RSP_OP(cmd, 0, 56, 8, uint8_t, mac_addr[0]); \
  305. } while (0)
  306. /* cmd, param, offset, width, type, arg_name */
  307. #define DPNI_CMD_ADD_MAC_ADDR(cmd, mac_addr) \
  308. do { \
  309. MC_CMD_OP(cmd, 0, 16, 8, uint8_t, mac_addr[5]); \
  310. MC_CMD_OP(cmd, 0, 24, 8, uint8_t, mac_addr[4]); \
  311. MC_CMD_OP(cmd, 0, 32, 8, uint8_t, mac_addr[3]); \
  312. MC_CMD_OP(cmd, 0, 40, 8, uint8_t, mac_addr[2]); \
  313. MC_CMD_OP(cmd, 0, 48, 8, uint8_t, mac_addr[1]); \
  314. MC_CMD_OP(cmd, 0, 56, 8, uint8_t, mac_addr[0]); \
  315. } while (0)
  316. /* cmd, param, offset, width, type, arg_name */
  317. #define DPNI_CMD_REMOVE_MAC_ADDR(cmd, mac_addr) \
  318. do { \
  319. MC_CMD_OP(cmd, 0, 16, 8, uint8_t, mac_addr[5]); \
  320. MC_CMD_OP(cmd, 0, 24, 8, uint8_t, mac_addr[4]); \
  321. MC_CMD_OP(cmd, 0, 32, 8, uint8_t, mac_addr[3]); \
  322. MC_CMD_OP(cmd, 0, 40, 8, uint8_t, mac_addr[2]); \
  323. MC_CMD_OP(cmd, 0, 48, 8, uint8_t, mac_addr[1]); \
  324. MC_CMD_OP(cmd, 0, 56, 8, uint8_t, mac_addr[0]); \
  325. } while (0)
  326. /* cmd, param, offset, width, type, arg_name */
  327. #define DPNI_CMD_SET_TX_FLOW(cmd, flow_id, cfg) \
  328. do { \
  329. MC_CMD_OP(cmd, 0, 43, 1, int, cfg->l3_chksum_gen);\
  330. MC_CMD_OP(cmd, 0, 44, 1, int, cfg->l4_chksum_gen);\
  331. MC_CMD_OP(cmd, 0, 45, 1, int, cfg->use_common_tx_conf_queue);\
  332. MC_CMD_OP(cmd, 0, 48, 16, uint16_t, flow_id);\
  333. MC_CMD_OP(cmd, 2, 0, 32, uint32_t, cfg->options);\
  334. } while (0)
  335. /* cmd, param, offset, width, type, arg_name */
  336. #define DPNI_RSP_SET_TX_FLOW(cmd, flow_id) \
  337. MC_RSP_OP(cmd, 0, 48, 16, uint16_t, flow_id)
  338. /* cmd, param, offset, width, type, arg_name */
  339. #define DPNI_CMD_GET_TX_FLOW(cmd, flow_id) \
  340. MC_CMD_OP(cmd, 0, 48, 16, uint16_t, flow_id)
  341. /* cmd, param, offset, width, type, arg_name */
  342. #define DPNI_RSP_GET_TX_FLOW(cmd, attr) \
  343. do { \
  344. MC_RSP_OP(cmd, 0, 43, 1, int, attr->l3_chksum_gen);\
  345. MC_RSP_OP(cmd, 0, 44, 1, int, attr->l4_chksum_gen);\
  346. MC_RSP_OP(cmd, 0, 45, 1, int, attr->use_common_tx_conf_queue);\
  347. } while (0)
  348. /* cmd, param, offset, width, type, arg_name */
  349. #define DPNI_CMD_SET_RX_FLOW(cmd, tc_id, flow_id, cfg) \
  350. do { \
  351. MC_CMD_OP(cmd, 0, 0, 32, int, cfg->dest_cfg.dest_id); \
  352. MC_CMD_OP(cmd, 0, 32, 8, uint8_t, cfg->dest_cfg.priority);\
  353. MC_CMD_OP(cmd, 0, 40, 2, enum dpni_dest, cfg->dest_cfg.dest_type);\
  354. MC_CMD_OP(cmd, 0, 42, 1, int, cfg->order_preservation_en);\
  355. MC_CMD_OP(cmd, 0, 48, 16, uint16_t, flow_id); \
  356. MC_CMD_OP(cmd, 1, 0, 64, uint64_t, cfg->user_ctx); \
  357. MC_CMD_OP(cmd, 2, 16, 8, uint8_t, tc_id); \
  358. MC_CMD_OP(cmd, 2, 32, 32, uint32_t, cfg->options); \
  359. MC_CMD_OP(cmd, 3, 0, 4, enum dpni_flc_type, cfg->flc_cfg.flc_type); \
  360. MC_CMD_OP(cmd, 3, 4, 4, enum dpni_stash_size, \
  361. cfg->flc_cfg.frame_data_size);\
  362. MC_CMD_OP(cmd, 3, 8, 4, enum dpni_stash_size, \
  363. cfg->flc_cfg.flow_context_size);\
  364. MC_CMD_OP(cmd, 3, 32, 32, uint32_t, cfg->flc_cfg.options);\
  365. MC_CMD_OP(cmd, 4, 0, 64, uint64_t, cfg->flc_cfg.flow_context);\
  366. MC_CMD_OP(cmd, 5, 0, 32, uint32_t, cfg->tail_drop_threshold); \
  367. } while (0)
  368. /* cmd, param, offset, width, type, arg_name */
  369. #define DPNI_CMD_GET_RX_FLOW(cmd, tc_id, flow_id) \
  370. do { \
  371. MC_CMD_OP(cmd, 0, 16, 8, uint8_t, tc_id); \
  372. MC_CMD_OP(cmd, 0, 48, 16, uint16_t, flow_id); \
  373. } while (0)
  374. /* cmd, param, offset, width, type, arg_name */
  375. #define DPNI_RSP_GET_RX_FLOW(cmd, attr) \
  376. do { \
  377. MC_RSP_OP(cmd, 0, 0, 32, int, attr->dest_cfg.dest_id); \
  378. MC_RSP_OP(cmd, 0, 32, 8, uint8_t, attr->dest_cfg.priority);\
  379. MC_RSP_OP(cmd, 0, 40, 2, enum dpni_dest, attr->dest_cfg.dest_type); \
  380. MC_RSP_OP(cmd, 0, 42, 1, int, attr->order_preservation_en);\
  381. MC_RSP_OP(cmd, 1, 0, 64, uint64_t, attr->user_ctx); \
  382. MC_RSP_OP(cmd, 2, 0, 32, uint32_t, attr->tail_drop_threshold); \
  383. MC_RSP_OP(cmd, 2, 32, 32, uint32_t, attr->fqid); \
  384. MC_RSP_OP(cmd, 3, 0, 4, enum dpni_flc_type, attr->flc_cfg.flc_type); \
  385. MC_RSP_OP(cmd, 3, 4, 4, enum dpni_stash_size, \
  386. attr->flc_cfg.frame_data_size);\
  387. MC_RSP_OP(cmd, 3, 8, 4, enum dpni_stash_size, \
  388. attr->flc_cfg.flow_context_size);\
  389. MC_RSP_OP(cmd, 3, 32, 32, uint32_t, attr->flc_cfg.options);\
  390. MC_RSP_OP(cmd, 4, 0, 64, uint64_t, attr->flc_cfg.flow_context);\
  391. } while (0)
  392. #define DPNI_CMD_SET_TX_CONF(cmd, flow_id, cfg) \
  393. do { \
  394. MC_CMD_OP(cmd, 0, 32, 8, uint8_t, cfg->queue_cfg.dest_cfg.priority); \
  395. MC_CMD_OP(cmd, 0, 40, 2, enum dpni_dest, \
  396. cfg->queue_cfg.dest_cfg.dest_type); \
  397. MC_CMD_OP(cmd, 0, 42, 1, int, cfg->errors_only); \
  398. MC_CMD_OP(cmd, 0, 46, 1, int, cfg->queue_cfg.order_preservation_en); \
  399. MC_CMD_OP(cmd, 0, 48, 16, uint16_t, flow_id); \
  400. MC_CMD_OP(cmd, 1, 0, 64, uint64_t, cfg->queue_cfg.user_ctx); \
  401. MC_CMD_OP(cmd, 2, 0, 32, uint32_t, cfg->queue_cfg.options); \
  402. MC_CMD_OP(cmd, 2, 32, 32, int, cfg->queue_cfg.dest_cfg.dest_id); \
  403. MC_CMD_OP(cmd, 3, 0, 32, uint32_t, \
  404. cfg->queue_cfg.tail_drop_threshold); \
  405. MC_CMD_OP(cmd, 4, 0, 4, enum dpni_flc_type, \
  406. cfg->queue_cfg.flc_cfg.flc_type); \
  407. MC_CMD_OP(cmd, 4, 4, 4, enum dpni_stash_size, \
  408. cfg->queue_cfg.flc_cfg.frame_data_size); \
  409. MC_CMD_OP(cmd, 4, 8, 4, enum dpni_stash_size, \
  410. cfg->queue_cfg.flc_cfg.flow_context_size); \
  411. MC_CMD_OP(cmd, 4, 32, 32, uint32_t, cfg->queue_cfg.flc_cfg.options); \
  412. MC_CMD_OP(cmd, 5, 0, 64, uint64_t, \
  413. cfg->queue_cfg.flc_cfg.flow_context); \
  414. } while (0)
  415. #define DPNI_CMD_GET_TX_CONF(cmd, flow_id) \
  416. MC_CMD_OP(cmd, 0, 48, 16, uint16_t, flow_id)
  417. #define DPNI_RSP_GET_TX_CONF(cmd, attr) \
  418. do { \
  419. MC_RSP_OP(cmd, 0, 32, 8, uint8_t, \
  420. attr->queue_attr.dest_cfg.priority); \
  421. MC_RSP_OP(cmd, 0, 40, 2, enum dpni_dest, \
  422. attr->queue_attr.dest_cfg.dest_type); \
  423. MC_RSP_OP(cmd, 0, 42, 1, int, attr->errors_only); \
  424. MC_RSP_OP(cmd, 0, 46, 1, int, \
  425. attr->queue_attr.order_preservation_en); \
  426. MC_RSP_OP(cmd, 1, 0, 64, uint64_t, attr->queue_attr.user_ctx); \
  427. MC_RSP_OP(cmd, 2, 32, 32, int, attr->queue_attr.dest_cfg.dest_id); \
  428. MC_RSP_OP(cmd, 3, 0, 32, uint32_t, \
  429. attr->queue_attr.tail_drop_threshold); \
  430. MC_RSP_OP(cmd, 3, 32, 32, uint32_t, attr->queue_attr.fqid); \
  431. MC_RSP_OP(cmd, 4, 0, 4, enum dpni_flc_type, \
  432. attr->queue_attr.flc_cfg.flc_type); \
  433. MC_RSP_OP(cmd, 4, 4, 4, enum dpni_stash_size, \
  434. attr->queue_attr.flc_cfg.frame_data_size); \
  435. MC_RSP_OP(cmd, 4, 8, 4, enum dpni_stash_size, \
  436. attr->queue_attr.flc_cfg.flow_context_size); \
  437. MC_RSP_OP(cmd, 4, 32, 32, uint32_t, attr->queue_attr.flc_cfg.options); \
  438. MC_RSP_OP(cmd, 5, 0, 64, uint64_t, \
  439. attr->queue_attr.flc_cfg.flow_context); \
  440. } while (0)
  441. enum net_prot {
  442. NET_PROT_NONE = 0,
  443. NET_PROT_PAYLOAD,
  444. NET_PROT_ETH,
  445. NET_PROT_VLAN,
  446. NET_PROT_IPV4,
  447. NET_PROT_IPV6,
  448. NET_PROT_IP,
  449. NET_PROT_TCP,
  450. NET_PROT_UDP,
  451. NET_PROT_UDP_LITE,
  452. NET_PROT_IPHC,
  453. NET_PROT_SCTP,
  454. NET_PROT_SCTP_CHUNK_DATA,
  455. NET_PROT_PPPOE,
  456. NET_PROT_PPP,
  457. NET_PROT_PPPMUX,
  458. NET_PROT_PPPMUX_SUBFRM,
  459. NET_PROT_L2TPV2,
  460. NET_PROT_L2TPV3_CTRL,
  461. NET_PROT_L2TPV3_SESS,
  462. NET_PROT_LLC,
  463. NET_PROT_LLC_SNAP,
  464. NET_PROT_NLPID,
  465. NET_PROT_SNAP,
  466. NET_PROT_MPLS,
  467. NET_PROT_IPSEC_AH,
  468. NET_PROT_IPSEC_ESP,
  469. NET_PROT_UDP_ENC_ESP, /* RFC 3948 */
  470. NET_PROT_MACSEC,
  471. NET_PROT_GRE,
  472. NET_PROT_MINENCAP,
  473. NET_PROT_DCCP,
  474. NET_PROT_ICMP,
  475. NET_PROT_IGMP,
  476. NET_PROT_ARP,
  477. NET_PROT_CAPWAP_DATA,
  478. NET_PROT_CAPWAP_CTRL,
  479. NET_PROT_RFC2684,
  480. NET_PROT_ICMPV6,
  481. NET_PROT_FCOE,
  482. NET_PROT_FIP,
  483. NET_PROT_ISCSI,
  484. NET_PROT_GTP,
  485. NET_PROT_USER_DEFINED_L2,
  486. NET_PROT_USER_DEFINED_L3,
  487. NET_PROT_USER_DEFINED_L4,
  488. NET_PROT_USER_DEFINED_L5,
  489. NET_PROT_USER_DEFINED_SHIM1,
  490. NET_PROT_USER_DEFINED_SHIM2,
  491. NET_PROT_DUMMY_LAST
  492. };
  493. /**
  494. * Data Path Network Interface API
  495. * Contains initialization APIs and runtime control APIs for DPNI
  496. */
  497. struct fsl_mc_io;
  498. /* General DPNI macros */
  499. /* Maximum number of traffic classes */
  500. #define DPNI_MAX_TC 8
  501. /* Maximum number of buffer pools per DPNI */
  502. #define DPNI_MAX_DPBP 8
  503. /* All traffic classes considered; see dpni_set_rx_flow() */
  504. #define DPNI_ALL_TCS (uint8_t)(-1)
  505. /* All flows within traffic class considered; see dpni_set_rx_flow() */
  506. #define DPNI_ALL_TC_FLOWS (uint16_t)(-1)
  507. /* Generate new flow ID; see dpni_set_tx_flow() */
  508. #define DPNI_NEW_FLOW_ID (uint16_t)(-1)
  509. /* use for common tx-conf queue; see dpni_set_tx_conf_<x>() */
  510. #define DPNI_COMMON_TX_CONF (uint16_t)(-1)
  511. /**
  512. * dpni_open() - Open a control session for the specified object
  513. * @mc_io: Pointer to MC portal's I/O object
  514. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  515. * @dpni_id: DPNI unique ID
  516. * @token: Returned token; use in subsequent API calls
  517. *
  518. * This function can be used to open a control session for an
  519. * already created object; an object may have been declared in
  520. * the DPL or by calling the dpni_create() function.
  521. * This function returns a unique authentication token,
  522. * associated with the specific object ID and the specific MC
  523. * portal; this token must be used in all subsequent commands for
  524. * this specific object.
  525. *
  526. * Return: '0' on Success; Error code otherwise.
  527. */
  528. int dpni_open(struct fsl_mc_io *mc_io,
  529. uint32_t cmd_flags,
  530. int dpni_id,
  531. uint16_t *token);
  532. /**
  533. * dpni_close() - Close the control session of the object
  534. * @mc_io: Pointer to MC portal's I/O object
  535. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  536. * @token: Token of DPNI object
  537. *
  538. * After this function is called, no further operations are
  539. * allowed on the object without opening a new control session.
  540. *
  541. * Return: '0' on Success; Error code otherwise.
  542. */
  543. int dpni_close(struct fsl_mc_io *mc_io,
  544. uint32_t cmd_flags,
  545. uint16_t token);
  546. /* DPNI configuration options */
  547. /**
  548. * Allow different distribution key profiles for different traffic classes;
  549. * if not set, a single key profile is assumed
  550. */
  551. #define DPNI_OPT_ALLOW_DIST_KEY_PER_TC 0x00000001
  552. /**
  553. * Disable all non-error transmit confirmation; error frames are reported
  554. * back to a common Tx error queue
  555. */
  556. #define DPNI_OPT_TX_CONF_DISABLED 0x00000002
  557. /* Disable per-sender private Tx confirmation/error queue */
  558. #define DPNI_OPT_PRIVATE_TX_CONF_ERROR_DISABLED 0x00000004
  559. /**
  560. * Support distribution based on hashed key;
  561. * allows statistical distribution over receive queues in a traffic class
  562. */
  563. #define DPNI_OPT_DIST_HASH 0x00000010
  564. /**
  565. * Support distribution based on flow steering;
  566. * allows explicit control of distribution over receive queues in a traffic
  567. * class
  568. */
  569. #define DPNI_OPT_DIST_FS 0x00000020
  570. /* Unicast filtering support */
  571. #define DPNI_OPT_UNICAST_FILTER 0x00000080
  572. /* Multicast filtering support */
  573. #define DPNI_OPT_MULTICAST_FILTER 0x00000100
  574. /* VLAN filtering support */
  575. #define DPNI_OPT_VLAN_FILTER 0x00000200
  576. /* Support IP reassembly on received packets */
  577. #define DPNI_OPT_IPR 0x00000800
  578. /* Support IP fragmentation on transmitted packets */
  579. #define DPNI_OPT_IPF 0x00001000
  580. /* VLAN manipulation support */
  581. #define DPNI_OPT_VLAN_MANIPULATION 0x00010000
  582. /* Support masking of QoS lookup keys */
  583. #define DPNI_OPT_QOS_MASK_SUPPORT 0x00020000
  584. /* Support masking of Flow Steering lookup keys */
  585. #define DPNI_OPT_FS_MASK_SUPPORT 0x00040000
  586. /**
  587. * struct dpni_extended_cfg - Structure representing extended DPNI configuration
  588. * @tc_cfg: TCs configuration
  589. * @ipr_cfg: IP reassembly configuration
  590. */
  591. struct dpni_extended_cfg {
  592. /**
  593. * struct tc_cfg - TC configuration
  594. * @max_dist: Maximum distribution size for Rx traffic class;
  595. * supported values: 1,2,3,4,6,7,8,12,14,16,24,28,32,48,56,64,96,
  596. * 112,128,192,224,256,384,448,512,768,896,1024;
  597. * value '0' will be treated as '1'.
  598. * other unsupported values will be round down to the nearest
  599. * supported value.
  600. * @max_fs_entries: Maximum FS entries for Rx traffic class;
  601. * '0' means no support for this TC;
  602. */
  603. struct {
  604. uint16_t max_dist;
  605. uint16_t max_fs_entries;
  606. } tc_cfg[DPNI_MAX_TC];
  607. /**
  608. * struct ipr_cfg - Structure representing IP reassembly configuration
  609. * @max_reass_frm_size: Maximum size of the reassembled frame
  610. * @min_frag_size_ipv4: Minimum fragment size of IPv4 fragments
  611. * @min_frag_size_ipv6: Minimum fragment size of IPv6 fragments
  612. * @max_open_frames_ipv4: Maximum concurrent IPv4 packets in reassembly
  613. * process
  614. * @max_open_frames_ipv6: Maximum concurrent IPv6 packets in reassembly
  615. * process
  616. */
  617. struct {
  618. uint16_t max_reass_frm_size;
  619. uint16_t min_frag_size_ipv4;
  620. uint16_t min_frag_size_ipv6;
  621. uint16_t max_open_frames_ipv4;
  622. uint16_t max_open_frames_ipv6;
  623. } ipr_cfg;
  624. };
  625. /**
  626. * dpni_prepare_extended_cfg() - function prepare extended parameters
  627. * @cfg: extended structure
  628. * @ext_cfg_buf: Zeroed 256 bytes of memory before mapping it to DMA
  629. *
  630. * This function has to be called before dpni_create()
  631. */
  632. int dpni_prepare_extended_cfg(const struct dpni_extended_cfg *cfg,
  633. uint8_t *ext_cfg_buf);
  634. /**
  635. * struct dpni_cfg - Structure representing DPNI configuration
  636. * @mac_addr: Primary MAC address
  637. * @adv: Advanced parameters; default is all zeros;
  638. * use this structure to change default settings
  639. */
  640. struct dpni_cfg {
  641. uint8_t mac_addr[6];
  642. /**
  643. * struct adv - Advanced parameters
  644. * @options: Mask of available options; use 'DPNI_OPT_<X>' values
  645. * @start_hdr: Selects the packet starting header for parsing;
  646. * 'NET_PROT_NONE' is treated as default: 'NET_PROT_ETH'
  647. * @max_senders: Maximum number of different senders; used as the number
  648. * of dedicated Tx flows; Non-power-of-2 values are rounded
  649. * up to the next power-of-2 value as hardware demands it;
  650. * '0' will be treated as '1'
  651. * @max_tcs: Maximum number of traffic classes (for both Tx and Rx);
  652. * '0' will e treated as '1'
  653. * @max_unicast_filters: Maximum number of unicast filters;
  654. * '0' is treated as '16'
  655. * @max_multicast_filters: Maximum number of multicast filters;
  656. * '0' is treated as '64'
  657. * @max_qos_entries: if 'max_tcs > 1', declares the maximum entries in
  658. * the QoS table; '0' is treated as '64'
  659. * @max_qos_key_size: Maximum key size for the QoS look-up;
  660. * '0' is treated as '24' which is enough for IPv4
  661. * 5-tuple
  662. * @max_dist_key_size: Maximum key size for the distribution;
  663. * '0' is treated as '24' which is enough for IPv4 5-tuple
  664. * @max_policers: Maximum number of policers;
  665. * should be between '0' and max_tcs
  666. * @max_congestion_ctrl: Maximum number of congestion control groups
  667. * (CGs); covers early drop and congestion notification
  668. * requirements;
  669. * should be between '0' and ('max_tcs' + 'max_senders')
  670. * @ext_cfg_iova: I/O virtual address of 256 bytes DMA-able memory
  671. * filled with the extended configuration by calling
  672. * dpni_prepare_extended_cfg()
  673. */
  674. struct {
  675. uint32_t options;
  676. enum net_prot start_hdr;
  677. uint8_t max_senders;
  678. uint8_t max_tcs;
  679. uint8_t max_unicast_filters;
  680. uint8_t max_multicast_filters;
  681. uint8_t max_vlan_filters;
  682. uint8_t max_qos_entries;
  683. uint8_t max_qos_key_size;
  684. uint8_t max_dist_key_size;
  685. uint8_t max_policers;
  686. uint8_t max_congestion_ctrl;
  687. uint64_t ext_cfg_iova;
  688. } adv;
  689. };
  690. /**
  691. * dpni_create() - Create the DPNI object
  692. * @mc_io: Pointer to MC portal's I/O object
  693. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  694. * @cfg: Configuration structure
  695. * @token: Returned token; use in subsequent API calls
  696. *
  697. * Create the DPNI object, allocate required resources and
  698. * perform required initialization.
  699. *
  700. * The object can be created either by declaring it in the
  701. * DPL file, or by calling this function.
  702. *
  703. * This function returns a unique authentication token,
  704. * associated with the specific object ID and the specific MC
  705. * portal; this token must be used in all subsequent calls to
  706. * this specific object. For objects that are created using the
  707. * DPL file, call dpni_open() function to get an authentication
  708. * token first.
  709. *
  710. * Return: '0' on Success; Error code otherwise.
  711. */
  712. int dpni_create(struct fsl_mc_io *mc_io,
  713. uint32_t cmd_flags,
  714. const struct dpni_cfg *cfg,
  715. uint16_t *token);
  716. /**
  717. * dpni_destroy() - Destroy the DPNI object and release all its resources.
  718. * @mc_io: Pointer to MC portal's I/O object
  719. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  720. * @token: Token of DPNI object
  721. *
  722. * Return: '0' on Success; error code otherwise.
  723. */
  724. int dpni_destroy(struct fsl_mc_io *mc_io,
  725. uint32_t cmd_flags,
  726. uint16_t token);
  727. /**
  728. * struct dpni_pools_cfg - Structure representing buffer pools configuration
  729. * @num_dpbp: Number of DPBPs
  730. * @pools: Array of buffer pools parameters; The number of valid entries
  731. * must match 'num_dpbp' value
  732. */
  733. struct dpni_pools_cfg {
  734. uint8_t num_dpbp;
  735. /**
  736. * struct pools - Buffer pools parameters
  737. * @dpbp_id: DPBP object ID
  738. * @buffer_size: Buffer size
  739. * @backup_pool: Backup pool
  740. */
  741. struct {
  742. int dpbp_id;
  743. uint16_t buffer_size;
  744. int backup_pool;
  745. } pools[DPNI_MAX_DPBP];
  746. };
  747. /**
  748. * dpni_set_pools() - Set buffer pools configuration
  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 DPNI object
  752. * @cfg: Buffer pools configuration
  753. *
  754. * mandatory for DPNI operation
  755. * warning:Allowed only when DPNI is disabled
  756. *
  757. * Return: '0' on Success; Error code otherwise.
  758. */
  759. int dpni_set_pools(struct fsl_mc_io *mc_io,
  760. uint32_t cmd_flags,
  761. uint16_t token,
  762. const struct dpni_pools_cfg *cfg);
  763. /**
  764. * dpni_enable() - Enable the DPNI, allow sending and receiving frames.
  765. * @mc_io: Pointer to MC portal's I/O object
  766. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  767. * @token: Token of DPNI object
  768. *
  769. * Return: '0' on Success; Error code otherwise.
  770. */
  771. int dpni_enable(struct fsl_mc_io *mc_io,
  772. uint32_t cmd_flags,
  773. uint16_t token);
  774. /**
  775. * dpni_disable() - Disable the DPNI, stop sending and receiving frames.
  776. * @mc_io: Pointer to MC portal's I/O object
  777. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  778. * @token: Token of DPNI object
  779. *
  780. * Return: '0' on Success; Error code otherwise.
  781. */
  782. int dpni_disable(struct fsl_mc_io *mc_io,
  783. uint32_t cmd_flags,
  784. uint16_t token);
  785. /**
  786. * dpni_reset() - Reset the DPNI, returns the object to initial state.
  787. * @mc_io: Pointer to MC portal's I/O object
  788. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  789. * @token: Token of DPNI object
  790. *
  791. * Return: '0' on Success; Error code otherwise.
  792. */
  793. int dpni_reset(struct fsl_mc_io *mc_io,
  794. uint32_t cmd_flags,
  795. uint16_t token);
  796. /**
  797. * struct dpni_attr - Structure representing DPNI attributes
  798. * @id: DPNI object ID
  799. * @version: DPNI version
  800. * @start_hdr: Indicates the packet starting header for parsing
  801. * @options: Mask of available options; reflects the value as was given in
  802. * object's creation
  803. * @max_senders: Maximum number of different senders; used as the number
  804. * of dedicated Tx flows;
  805. * @max_tcs: Maximum number of traffic classes (for both Tx and Rx)
  806. * @max_unicast_filters: Maximum number of unicast filters
  807. * @max_multicast_filters: Maximum number of multicast filters
  808. * @max_vlan_filters: Maximum number of VLAN filters
  809. * @max_qos_entries: if 'max_tcs > 1', declares the maximum entries in QoS table
  810. * @max_qos_key_size: Maximum key size for the QoS look-up
  811. * @max_dist_key_size: Maximum key size for the distribution look-up
  812. * @max_policers: Maximum number of policers;
  813. * @max_congestion_ctrl: Maximum number of congestion control groups (CGs);
  814. * @ext_cfg_iova: I/O virtual address of 256 bytes DMA-able memory;
  815. * call dpni_extract_extended_cfg() to extract the extended configuration
  816. */
  817. struct dpni_attr {
  818. int id;
  819. /**
  820. * struct version - DPNI version
  821. * @major: DPNI major version
  822. * @minor: DPNI minor version
  823. */
  824. struct {
  825. uint16_t major;
  826. uint16_t minor;
  827. } version;
  828. enum net_prot start_hdr;
  829. uint32_t options;
  830. uint8_t max_senders;
  831. uint8_t max_tcs;
  832. uint8_t max_unicast_filters;
  833. uint8_t max_multicast_filters;
  834. uint8_t max_vlan_filters;
  835. uint8_t max_qos_entries;
  836. uint8_t max_qos_key_size;
  837. uint8_t max_dist_key_size;
  838. uint8_t max_policers;
  839. uint8_t max_congestion_ctrl;
  840. uint64_t ext_cfg_iova;
  841. };
  842. /**
  843. * dpni_get_attributes() - Retrieve DPNI attributes.
  844. * @mc_io: Pointer to MC portal's I/O object
  845. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  846. * @token: Token of DPNI object
  847. * @attr: Object's attributes
  848. *
  849. * Return: '0' on Success; Error code otherwise.
  850. */
  851. int dpni_get_attributes(struct fsl_mc_io *mc_io,
  852. uint32_t cmd_flags,
  853. uint16_t token,
  854. struct dpni_attr *attr);
  855. /**
  856. * dpni_extract_extended_cfg() - extract the extended parameters
  857. * @cfg: extended structure
  858. * @ext_cfg_buf: 256 bytes of DMA-able memory
  859. *
  860. * This function has to be called after dpni_get_attributes()
  861. */
  862. int dpni_extract_extended_cfg(struct dpni_extended_cfg *cfg,
  863. const uint8_t *ext_cfg_buf);
  864. /**
  865. * DPNI errors
  866. */
  867. /**
  868. * Extract out of frame header error
  869. */
  870. #define DPNI_ERROR_EOFHE 0x00020000
  871. /**
  872. * Frame length error
  873. */
  874. #define DPNI_ERROR_FLE 0x00002000
  875. /**
  876. * Frame physical error
  877. */
  878. #define DPNI_ERROR_FPE 0x00001000
  879. /**
  880. * Parsing header error
  881. */
  882. #define DPNI_ERROR_PHE 0x00000020
  883. /**
  884. * Parser L3 checksum error
  885. */
  886. #define DPNI_ERROR_L3CE 0x00000004
  887. /**
  888. * Parser L3 checksum error
  889. */
  890. #define DPNI_ERROR_L4CE 0x00000001
  891. /**
  892. * enum dpni_error_action - Defines DPNI behavior for errors
  893. * @DPNI_ERROR_ACTION_DISCARD: Discard the frame
  894. * @DPNI_ERROR_ACTION_CONTINUE: Continue with the normal flow
  895. * @DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE: Send the frame to the error queue
  896. */
  897. enum dpni_error_action {
  898. DPNI_ERROR_ACTION_DISCARD = 0,
  899. DPNI_ERROR_ACTION_CONTINUE = 1,
  900. DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE = 2
  901. };
  902. /**
  903. * struct dpni_error_cfg - Structure representing DPNI errors treatment
  904. * @errors: Errors mask; use 'DPNI_ERROR__<X>
  905. * @error_action: The desired action for the errors mask
  906. * @set_frame_annotation: Set to '1' to mark the errors in frame annotation
  907. * status (FAS); relevant only for the non-discard action
  908. */
  909. struct dpni_error_cfg {
  910. uint32_t errors;
  911. enum dpni_error_action error_action;
  912. int set_frame_annotation;
  913. };
  914. /**
  915. * dpni_set_errors_behavior() - Set errors behavior
  916. * @mc_io: Pointer to MC portal's I/O object
  917. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  918. * @token: Token of DPNI object
  919. * @cfg: Errors configuration
  920. *
  921. * this function may be called numerous times with different
  922. * error masks
  923. *
  924. * Return: '0' on Success; Error code otherwise.
  925. */
  926. int dpni_set_errors_behavior(struct fsl_mc_io *mc_io,
  927. uint32_t cmd_flags,
  928. uint16_t token,
  929. struct dpni_error_cfg *cfg);
  930. /* DPNI buffer layout modification options */
  931. /* Select to modify the time-stamp setting */
  932. #define DPNI_BUF_LAYOUT_OPT_TIMESTAMP 0x00000001
  933. /* Select to modify the parser-result setting; not applicable for Tx */
  934. #define DPNI_BUF_LAYOUT_OPT_PARSER_RESULT 0x00000002
  935. /* Select to modify the frame-status setting */
  936. #define DPNI_BUF_LAYOUT_OPT_FRAME_STATUS 0x00000004
  937. /* Select to modify the private-data-size setting */
  938. #define DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE 0x00000008
  939. /* Select to modify the data-alignment setting */
  940. #define DPNI_BUF_LAYOUT_OPT_DATA_ALIGN 0x00000010
  941. /* Select to modify the data-head-room setting */
  942. #define DPNI_BUF_LAYOUT_OPT_DATA_HEAD_ROOM 0x00000020
  943. /*!< Select to modify the data-tail-room setting */
  944. #define DPNI_BUF_LAYOUT_OPT_DATA_TAIL_ROOM 0x00000040
  945. /**
  946. * struct dpni_buffer_layout - Structure representing DPNI buffer layout
  947. * @options: Flags representing the suggested modifications to the buffer
  948. * layout; Use any combination of 'DPNI_BUF_LAYOUT_OPT_<X>' flags
  949. * @pass_timestamp: Pass timestamp value
  950. * @pass_parser_result: Pass parser results
  951. * @pass_frame_status: Pass frame status
  952. * @private_data_size: Size kept for private data (in bytes)
  953. * @data_align: Data alignment
  954. * @data_head_room: Data head room
  955. * @data_tail_room: Data tail room
  956. */
  957. struct dpni_buffer_layout {
  958. uint32_t options;
  959. int pass_timestamp;
  960. int pass_parser_result;
  961. int pass_frame_status;
  962. uint16_t private_data_size;
  963. uint16_t data_align;
  964. uint16_t data_head_room;
  965. uint16_t data_tail_room;
  966. };
  967. /**
  968. * dpni_get_rx_buffer_layout() - Retrieve Rx buffer layout attributes.
  969. * @mc_io: Pointer to MC portal's I/O object
  970. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  971. * @token: Token of DPNI object
  972. * @layout: Returns buffer layout attributes
  973. *
  974. * Return: '0' on Success; Error code otherwise.
  975. */
  976. int dpni_get_rx_buffer_layout(struct fsl_mc_io *mc_io,
  977. uint32_t cmd_flags,
  978. uint16_t token,
  979. struct dpni_buffer_layout *layout);
  980. /**
  981. * dpni_set_rx_buffer_layout() - Set Rx buffer layout configuration.
  982. * @mc_io: Pointer to MC portal's I/O object
  983. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  984. * @token: Token of DPNI object
  985. * @layout: Buffer layout configuration
  986. *
  987. * Return: '0' on Success; Error code otherwise.
  988. *
  989. * @warning Allowed only when DPNI is disabled
  990. */
  991. int dpni_set_rx_buffer_layout(struct fsl_mc_io *mc_io,
  992. uint32_t cmd_flags,
  993. uint16_t token,
  994. const struct dpni_buffer_layout *layout);
  995. /**
  996. * dpni_get_tx_buffer_layout() - Retrieve Tx buffer layout attributes.
  997. * @mc_io: Pointer to MC portal's I/O object
  998. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  999. * @token: Token of DPNI object
  1000. * @layout: Returns buffer layout attributes
  1001. *
  1002. * Return: '0' on Success; Error code otherwise.
  1003. */
  1004. int dpni_get_tx_buffer_layout(struct fsl_mc_io *mc_io,
  1005. uint32_t cmd_flags,
  1006. uint16_t token,
  1007. struct dpni_buffer_layout *layout);
  1008. /**
  1009. * dpni_set_tx_buffer_layout() - Set Tx buffer layout configuration.
  1010. * @mc_io: Pointer to MC portal's I/O object
  1011. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  1012. * @token: Token of DPNI object
  1013. * @layout: Buffer layout configuration
  1014. *
  1015. * Return: '0' on Success; Error code otherwise.
  1016. *
  1017. * @warning Allowed only when DPNI is disabled
  1018. */
  1019. int dpni_set_tx_buffer_layout(struct fsl_mc_io *mc_io,
  1020. uint32_t cmd_flags,
  1021. uint16_t token,
  1022. const struct dpni_buffer_layout *layout);
  1023. /**
  1024. * dpni_get_tx_conf_buffer_layout() - Retrieve Tx confirmation buffer layout
  1025. * attributes.
  1026. * @mc_io: Pointer to MC portal's I/O object
  1027. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  1028. * @token: Token of DPNI object
  1029. * @layout: Returns buffer layout attributes
  1030. *
  1031. * Return: '0' on Success; Error code otherwise.
  1032. */
  1033. int dpni_get_tx_conf_buffer_layout(struct fsl_mc_io *mc_io,
  1034. uint32_t cmd_flags,
  1035. uint16_t token,
  1036. struct dpni_buffer_layout *layout);
  1037. /**
  1038. * dpni_set_tx_conf_buffer_layout() - Set Tx confirmation buffer layout
  1039. * configuration.
  1040. * @mc_io: Pointer to MC portal's I/O object
  1041. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  1042. * @token: Token of DPNI object
  1043. * @layout: Buffer layout configuration
  1044. *
  1045. * Return: '0' on Success; Error code otherwise.
  1046. *
  1047. * @warning Allowed only when DPNI is disabled
  1048. */
  1049. int dpni_set_tx_conf_buffer_layout(struct fsl_mc_io *mc_io,
  1050. uint32_t cmd_flags,
  1051. uint16_t token,
  1052. const struct dpni_buffer_layout *layout);
  1053. /**
  1054. * dpni_get_qdid() - Get the Queuing Destination ID (QDID) that should be used
  1055. * for enqueue operations
  1056. * @mc_io: Pointer to MC portal's I/O object
  1057. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  1058. * @token: Token of DPNI object
  1059. * @qdid: Returned virtual QDID value that should be used as an argument
  1060. * in all enqueue operations
  1061. *
  1062. * Return: '0' on Success; Error code otherwise.
  1063. */
  1064. int dpni_get_qdid(struct fsl_mc_io *mc_io,
  1065. uint32_t cmd_flags,
  1066. uint16_t token,
  1067. uint16_t *qdid);
  1068. /**
  1069. * dpni_get_tx_data_offset() - Get the Tx data offset (from start of buffer)
  1070. * @mc_io: Pointer to MC portal's I/O object
  1071. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  1072. * @token: Token of DPNI object
  1073. * @data_offset: Tx data offset (from start of buffer)
  1074. *
  1075. * Return: '0' on Success; Error code otherwise.
  1076. */
  1077. int dpni_get_tx_data_offset(struct fsl_mc_io *mc_io,
  1078. uint32_t cmd_flags,
  1079. uint16_t token,
  1080. uint16_t *data_offset);
  1081. /**
  1082. * enum dpni_counter - DPNI counter types
  1083. * @DPNI_CNT_ING_FRAME: Counts ingress frames
  1084. * @DPNI_CNT_ING_BYTE: Counts ingress bytes
  1085. * @DPNI_CNT_ING_FRAME_DROP: Counts ingress frames dropped due to explicit
  1086. * 'drop' setting
  1087. * @DPNI_CNT_ING_FRAME_DISCARD: Counts ingress frames discarded due to errors
  1088. * @DPNI_CNT_ING_MCAST_FRAME: Counts ingress multicast frames
  1089. * @DPNI_CNT_ING_MCAST_BYTE: Counts ingress multicast bytes
  1090. * @DPNI_CNT_ING_BCAST_FRAME: Counts ingress broadcast frames
  1091. * @DPNI_CNT_ING_BCAST_BYTES: Counts ingress broadcast bytes
  1092. * @DPNI_CNT_EGR_FRAME: Counts egress frames
  1093. * @DPNI_CNT_EGR_BYTE: Counts egress bytes
  1094. * @DPNI_CNT_EGR_FRAME_DISCARD: Counts egress frames discarded due to errors
  1095. */
  1096. enum dpni_counter {
  1097. DPNI_CNT_ING_FRAME = 0x0,
  1098. DPNI_CNT_ING_BYTE = 0x1,
  1099. DPNI_CNT_ING_FRAME_DROP = 0x2,
  1100. DPNI_CNT_ING_FRAME_DISCARD = 0x3,
  1101. DPNI_CNT_ING_MCAST_FRAME = 0x4,
  1102. DPNI_CNT_ING_MCAST_BYTE = 0x5,
  1103. DPNI_CNT_ING_BCAST_FRAME = 0x6,
  1104. DPNI_CNT_ING_BCAST_BYTES = 0x7,
  1105. DPNI_CNT_EGR_FRAME = 0x8,
  1106. DPNI_CNT_EGR_BYTE = 0x9,
  1107. DPNI_CNT_EGR_FRAME_DISCARD = 0xa
  1108. };
  1109. /**
  1110. * dpni_get_counter() - Read a specific DPNI counter
  1111. * @mc_io: Pointer to MC portal's I/O object
  1112. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  1113. * @token: Token of DPNI object
  1114. * @counter: The requested counter
  1115. * @value: Returned counter's current value
  1116. *
  1117. * Return: '0' on Success; Error code otherwise.
  1118. */
  1119. int dpni_get_counter(struct fsl_mc_io *mc_io,
  1120. uint32_t cmd_flags,
  1121. uint16_t token,
  1122. enum dpni_counter counter,
  1123. uint64_t *value);
  1124. /**
  1125. * dpni_set_counter() - Set (or clear) a specific DPNI counter
  1126. * @mc_io: Pointer to MC portal's I/O object
  1127. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  1128. * @token: Token of DPNI object
  1129. * @counter: The requested counter
  1130. * @value: New counter value; typically pass '0' for resetting
  1131. * the counter.
  1132. *
  1133. * Return: '0' on Success; Error code otherwise.
  1134. */
  1135. int dpni_set_counter(struct fsl_mc_io *mc_io,
  1136. uint32_t cmd_flags,
  1137. uint16_t token,
  1138. enum dpni_counter counter,
  1139. uint64_t value);
  1140. /* Enable auto-negotiation */
  1141. #define DPNI_LINK_OPT_AUTONEG 0x0000000000000001ULL
  1142. /* Enable half-duplex mode */
  1143. #define DPNI_LINK_OPT_HALF_DUPLEX 0x0000000000000002ULL
  1144. /* Enable pause frames */
  1145. #define DPNI_LINK_OPT_PAUSE 0x0000000000000004ULL
  1146. /* Enable a-symmetric pause frames */
  1147. #define DPNI_LINK_OPT_ASYM_PAUSE 0x0000000000000008ULL
  1148. /**
  1149. * struct - Structure representing DPNI link configuration
  1150. * @rate: Rate
  1151. * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
  1152. */
  1153. struct dpni_link_cfg {
  1154. uint32_t rate;
  1155. uint64_t options;
  1156. };
  1157. /**
  1158. * dpni_set_link_cfg() - set the link configuration.
  1159. * @mc_io: Pointer to MC portal's I/O object
  1160. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  1161. * @token: Token of DPNI object
  1162. * @cfg: Link configuration
  1163. *
  1164. * Return: '0' on Success; Error code otherwise.
  1165. */
  1166. int dpni_set_link_cfg(struct fsl_mc_io *mc_io,
  1167. uint32_t cmd_flags,
  1168. uint16_t token,
  1169. const struct dpni_link_cfg *cfg);
  1170. /**
  1171. * struct dpni_link_state - Structure representing DPNI link state
  1172. * @rate: Rate
  1173. * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
  1174. * @up: Link state; '0' for down, '1' for up
  1175. */
  1176. struct dpni_link_state {
  1177. uint32_t rate;
  1178. uint64_t options;
  1179. int up;
  1180. };
  1181. /**
  1182. * dpni_get_link_state() - Return the link state (either up or down)
  1183. * @mc_io: Pointer to MC portal's I/O object
  1184. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  1185. * @token: Token of DPNI object
  1186. * @state: Returned link state;
  1187. *
  1188. * Return: '0' on Success; Error code otherwise.
  1189. */
  1190. int dpni_get_link_state(struct fsl_mc_io *mc_io,
  1191. uint32_t cmd_flags,
  1192. uint16_t token,
  1193. struct dpni_link_state *state);
  1194. /**
  1195. * dpni_set_primary_mac_addr() - Set the primary MAC address
  1196. * @mc_io: Pointer to MC portal's I/O object
  1197. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  1198. * @token: Token of DPNI object
  1199. * @mac_addr: MAC address to set as primary address
  1200. *
  1201. * Return: '0' on Success; Error code otherwise.
  1202. */
  1203. int dpni_set_primary_mac_addr(struct fsl_mc_io *mc_io,
  1204. uint32_t cmd_flags,
  1205. uint16_t token,
  1206. const uint8_t mac_addr[6]);
  1207. /**
  1208. * dpni_get_primary_mac_addr() - Get the primary MAC address
  1209. * @mc_io: Pointer to MC portal's I/O object
  1210. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  1211. * @token: Token of DPNI object
  1212. * @mac_addr: Returned MAC address
  1213. *
  1214. * Return: '0' on Success; Error code otherwise.
  1215. */
  1216. int dpni_get_primary_mac_addr(struct fsl_mc_io *mc_io,
  1217. uint32_t cmd_flags,
  1218. uint16_t token,
  1219. uint8_t mac_addr[6]);
  1220. /**
  1221. * dpni_add_mac_addr() - Add MAC address filter
  1222. * @mc_io: Pointer to MC portal's I/O object
  1223. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  1224. * @token: Token of DPNI object
  1225. * @mac_addr: MAC address to add
  1226. *
  1227. * Return: '0' on Success; Error code otherwise.
  1228. */
  1229. int dpni_add_mac_addr(struct fsl_mc_io *mc_io,
  1230. uint32_t cmd_flags,
  1231. uint16_t token,
  1232. const uint8_t mac_addr[6]);
  1233. /**
  1234. * dpni_remove_mac_addr() - Remove MAC address filter
  1235. * @mc_io: Pointer to MC portal's I/O object
  1236. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  1237. * @token: Token of DPNI object
  1238. * @mac_addr: MAC address to remove
  1239. *
  1240. * Return: '0' on Success; Error code otherwise.
  1241. */
  1242. int dpni_remove_mac_addr(struct fsl_mc_io *mc_io,
  1243. uint32_t cmd_flags,
  1244. uint16_t token,
  1245. const uint8_t mac_addr[6]);
  1246. /**
  1247. * enum dpni_dest - DPNI destination types
  1248. * @DPNI_DEST_NONE: Unassigned destination; The queue is set in parked mode and
  1249. * does not generate FQDAN notifications; user is expected to
  1250. * dequeue from the queue based on polling or other user-defined
  1251. * method
  1252. * @DPNI_DEST_DPIO: The queue is set in schedule mode and generates FQDAN
  1253. * notifications to the specified DPIO; user is expected to dequeue
  1254. * from the queue only after notification is received
  1255. * @DPNI_DEST_DPCON: The queue is set in schedule mode and does not generate
  1256. * FQDAN notifications, but is connected to the specified DPCON
  1257. * object; user is expected to dequeue from the DPCON channel
  1258. */
  1259. enum dpni_dest {
  1260. DPNI_DEST_NONE = 0,
  1261. DPNI_DEST_DPIO = 1,
  1262. DPNI_DEST_DPCON = 2
  1263. };
  1264. /**
  1265. * struct dpni_dest_cfg - Structure representing DPNI destination parameters
  1266. * @dest_type: Destination type
  1267. * @dest_id: Either DPIO ID or DPCON ID, depending on the destination type
  1268. * @priority: Priority selection within the DPIO or DPCON channel; valid values
  1269. * are 0-1 or 0-7, depending on the number of priorities in that
  1270. * channel; not relevant for 'DPNI_DEST_NONE' option
  1271. */
  1272. struct dpni_dest_cfg {
  1273. enum dpni_dest dest_type;
  1274. int dest_id;
  1275. uint8_t priority;
  1276. };
  1277. /**
  1278. * enum dpni_flc_type - DPNI FLC types
  1279. * @DPNI_FLC_USER_DEFINED: select the FLC to be used for user defined value
  1280. * @DPNI_FLC_STASH: select the FLC to be used for stash control
  1281. */
  1282. enum dpni_flc_type {
  1283. DPNI_FLC_USER_DEFINED = 0,
  1284. DPNI_FLC_STASH = 1,
  1285. };
  1286. /**
  1287. * enum dpni_stash_size - DPNI FLC stashing size
  1288. * @DPNI_STASH_SIZE_0B: no stash
  1289. * @DPNI_STASH_SIZE_64B: stashes 64 bytes
  1290. * @DPNI_STASH_SIZE_128B: stashes 128 bytes
  1291. * @DPNI_STASH_SIZE_192B: stashes 192 bytes
  1292. */
  1293. enum dpni_stash_size {
  1294. DPNI_STASH_SIZE_0B = 0,
  1295. DPNI_STASH_SIZE_64B = 1,
  1296. DPNI_STASH_SIZE_128B = 2,
  1297. DPNI_STASH_SIZE_192B = 3,
  1298. };
  1299. /* DPNI FLC stash options */
  1300. /* stashes the whole annotation area (up to 192 bytes) */
  1301. #define DPNI_FLC_STASH_FRAME_ANNOTATION 0x00000001
  1302. /**
  1303. * struct dpni_flc_cfg - Structure representing DPNI FLC configuration
  1304. * @flc_type: FLC type
  1305. * @options: Mask of available options;
  1306. * use 'DPNI_FLC_STASH_<X>' values
  1307. * @frame_data_size: Size of frame data to be stashed
  1308. * @flow_context_size: Size of flow context to be stashed
  1309. * @flow_context: 1. In case flc_type is 'DPNI_FLC_USER_DEFINED':
  1310. * this value will be provided in the frame descriptor
  1311. * (FD[FLC])
  1312. * 2. In case flc_type is 'DPNI_FLC_STASH':
  1313. * this value will be I/O virtual address of the
  1314. * flow-context;
  1315. * Must be cacheline-aligned and DMA-able memory
  1316. */
  1317. struct dpni_flc_cfg {
  1318. enum dpni_flc_type flc_type;
  1319. uint32_t options;
  1320. enum dpni_stash_size frame_data_size;
  1321. enum dpni_stash_size flow_context_size;
  1322. uint64_t flow_context;
  1323. };
  1324. /* DPNI queue modification options */
  1325. /* Select to modify the user's context associated with the queue */
  1326. #define DPNI_QUEUE_OPT_USER_CTX 0x00000001
  1327. /* Select to modify the queue's destination */
  1328. #define DPNI_QUEUE_OPT_DEST 0x00000002
  1329. /** Select to modify the flow-context parameters;
  1330. * not applicable for Tx-conf/Err queues as the FD comes from the user
  1331. */
  1332. #define DPNI_QUEUE_OPT_FLC 0x00000004
  1333. /* Select to modify the queue's order preservation */
  1334. #define DPNI_QUEUE_OPT_ORDER_PRESERVATION 0x00000008
  1335. /* Select to modify the queue's tail-drop threshold */
  1336. #define DPNI_QUEUE_OPT_TAILDROP_THRESHOLD 0x00000010
  1337. /**
  1338. * struct dpni_queue_cfg - Structure representing queue configuration
  1339. * @options: Flags representing the suggested modifications to the queue;
  1340. * Use any combination of 'DPNI_QUEUE_OPT_<X>' flags
  1341. * @user_ctx: User context value provided in the frame descriptor of each
  1342. * dequeued frame; valid only if 'DPNI_QUEUE_OPT_USER_CTX'
  1343. * is contained in 'options'
  1344. * @dest_cfg: Queue destination parameters;
  1345. * valid only if 'DPNI_QUEUE_OPT_DEST' is contained in 'options'
  1346. * @flc_cfg: Flow context configuration; in case the TC's distribution
  1347. * is either NONE or HASH the FLC's settings of flow#0 are used.
  1348. * in the case of FS (flow-steering) the flow's FLC settings
  1349. * are used.
  1350. * valid only if 'DPNI_QUEUE_OPT_FLC' is contained in 'options'
  1351. * @order_preservation_en: enable/disable order preservation;
  1352. * valid only if 'DPNI_QUEUE_OPT_ORDER_PRESERVATION' is contained
  1353. * in 'options'
  1354. * @tail_drop_threshold: set the queue's tail drop threshold in bytes;
  1355. * '0' value disable the threshold; maximum value is 0xE000000;
  1356. * valid only if 'DPNI_QUEUE_OPT_TAILDROP_THRESHOLD' is contained
  1357. * in 'options'
  1358. */
  1359. struct dpni_queue_cfg {
  1360. uint32_t options;
  1361. uint64_t user_ctx;
  1362. struct dpni_dest_cfg dest_cfg;
  1363. struct dpni_flc_cfg flc_cfg;
  1364. int order_preservation_en;
  1365. uint32_t tail_drop_threshold;
  1366. };
  1367. /**
  1368. * struct dpni_queue_attr - Structure representing queue attributes
  1369. * @user_ctx: User context value provided in the frame descriptor of each
  1370. * dequeued frame
  1371. * @dest_cfg: Queue destination configuration
  1372. * @flc_cfg: Flow context configuration
  1373. * @order_preservation_en: enable/disable order preservation
  1374. * @tail_drop_threshold: queue's tail drop threshold in bytes;
  1375. * @fqid: Virtual fqid value to be used for dequeue operations
  1376. */
  1377. struct dpni_queue_attr {
  1378. uint64_t user_ctx;
  1379. struct dpni_dest_cfg dest_cfg;
  1380. struct dpni_flc_cfg flc_cfg;
  1381. int order_preservation_en;
  1382. uint32_t tail_drop_threshold;
  1383. uint32_t fqid;
  1384. };
  1385. /* DPNI Tx flow modification options */
  1386. /* Select to modify the settings for dedicate Tx confirmation/error */
  1387. #define DPNI_TX_FLOW_OPT_TX_CONF_ERROR 0x00000001
  1388. /*!< Select to modify the L3 checksum generation setting */
  1389. #define DPNI_TX_FLOW_OPT_L3_CHKSUM_GEN 0x00000010
  1390. /*!< Select to modify the L4 checksum generation setting */
  1391. #define DPNI_TX_FLOW_OPT_L4_CHKSUM_GEN 0x00000020
  1392. /**
  1393. * struct dpni_tx_flow_cfg - Structure representing Tx flow configuration
  1394. * @options: Flags representing the suggested modifications to the Tx flow;
  1395. * Use any combination 'DPNI_TX_FLOW_OPT_<X>' flags
  1396. * @use_common_tx_conf_queue: Set to '1' to use the common (default) Tx
  1397. * confirmation and error queue; Set to '0' to use the private
  1398. * Tx confirmation and error queue; valid only if
  1399. * 'DPNI_OPT_PRIVATE_TX_CONF_ERROR_DISABLED' wasn't set at DPNI creation
  1400. * and 'DPNI_TX_FLOW_OPT_TX_CONF_ERROR' is contained in 'options'
  1401. * @l3_chksum_gen: Set to '1' to enable L3 checksum generation; '0' to disable;
  1402. * valid only if 'DPNI_TX_FLOW_OPT_L3_CHKSUM_GEN' is contained in 'options'
  1403. * @l4_chksum_gen: Set to '1' to enable L4 checksum generation; '0' to disable;
  1404. * valid only if 'DPNI_TX_FLOW_OPT_L4_CHKSUM_GEN' is contained in 'options'
  1405. */
  1406. struct dpni_tx_flow_cfg {
  1407. uint32_t options;
  1408. int use_common_tx_conf_queue;
  1409. int l3_chksum_gen;
  1410. int l4_chksum_gen;
  1411. };
  1412. /**
  1413. * dpni_set_tx_flow() - Set Tx flow configuration
  1414. * @mc_io: Pointer to MC portal's I/O object
  1415. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  1416. * @token: Token of DPNI object
  1417. * @flow_id: Provides (or returns) the sender's flow ID;
  1418. * for each new sender set (*flow_id) to 'DPNI_NEW_FLOW_ID' to generate
  1419. * a new flow_id; this ID should be used as the QDBIN argument
  1420. * in enqueue operations
  1421. * @cfg: Tx flow configuration
  1422. *
  1423. * Return: '0' on Success; Error code otherwise.
  1424. */
  1425. int dpni_set_tx_flow(struct fsl_mc_io *mc_io,
  1426. uint32_t cmd_flags,
  1427. uint16_t token,
  1428. uint16_t *flow_id,
  1429. const struct dpni_tx_flow_cfg *cfg);
  1430. /**
  1431. * struct dpni_tx_flow_attr - Structure representing Tx flow attributes
  1432. * @use_common_tx_conf_queue: '1' if using common (default) Tx confirmation and
  1433. * error queue; '0' if using private Tx confirmation and error queue
  1434. * @l3_chksum_gen: '1' if L3 checksum generation is enabled; '0' if disabled
  1435. * @l4_chksum_gen: '1' if L4 checksum generation is enabled; '0' if disabled
  1436. */
  1437. struct dpni_tx_flow_attr {
  1438. int use_common_tx_conf_queue;
  1439. int l3_chksum_gen;
  1440. int l4_chksum_gen;
  1441. };
  1442. /**
  1443. * dpni_get_tx_flow() - Get Tx flow attributes
  1444. * @mc_io: Pointer to MC portal's I/O object
  1445. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  1446. * @token: Token of DPNI object
  1447. * @flow_id: The sender's flow ID, as returned by the
  1448. * dpni_set_tx_flow() function
  1449. * @attr: Returned Tx flow attributes
  1450. *
  1451. * Return: '0' on Success; Error code otherwise.
  1452. */
  1453. int dpni_get_tx_flow(struct fsl_mc_io *mc_io,
  1454. uint32_t cmd_flags,
  1455. uint16_t token,
  1456. uint16_t flow_id,
  1457. struct dpni_tx_flow_attr *attr);
  1458. /**
  1459. * struct dpni_tx_conf_cfg - Structure representing Tx conf configuration
  1460. * @errors_only: Set to '1' to report back only error frames;
  1461. * Set to '0' to confirm transmission/error for all transmitted frames;
  1462. * @queue_cfg: Queue configuration
  1463. */
  1464. struct dpni_tx_conf_cfg {
  1465. int errors_only;
  1466. struct dpni_queue_cfg queue_cfg;
  1467. };
  1468. /**
  1469. * dpni_set_tx_conf() - Set Tx confirmation and error queue configuration
  1470. * @mc_io: Pointer to MC portal's I/O object
  1471. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  1472. * @token: Token of DPNI object
  1473. * @flow_id: The sender's flow ID, as returned by the
  1474. * dpni_set_tx_flow() function;
  1475. * use 'DPNI_COMMON_TX_CONF' for common tx-conf
  1476. * @cfg: Queue configuration
  1477. *
  1478. * If either 'DPNI_OPT_TX_CONF_DISABLED' or
  1479. * 'DPNI_OPT_PRIVATE_TX_CONF_ERROR_DISABLED' were selected at DPNI creation,
  1480. * this function can ONLY be used with 'flow_id == DPNI_COMMON_TX_CONF';
  1481. * i.e. only serve the common tx-conf-err queue;
  1482. * if 'DPNI_OPT_TX_CONF_DISABLED' was selected, only error frames are reported
  1483. * back - successfully transmitted frames are not confirmed. Otherwise, all
  1484. * transmitted frames are sent for confirmation.
  1485. *
  1486. * Return: '0' on Success; Error code otherwise.
  1487. */
  1488. int dpni_set_tx_conf(struct fsl_mc_io *mc_io,
  1489. uint32_t cmd_flags,
  1490. uint16_t token,
  1491. uint16_t flow_id,
  1492. const struct dpni_tx_conf_cfg *cfg);
  1493. /**
  1494. * struct dpni_tx_conf_attr - Structure representing Tx conf attributes
  1495. * @errors_only: '1' if only error frames are reported back; '0' if all
  1496. * transmitted frames are confirmed
  1497. * @queue_attr: Queue attributes
  1498. */
  1499. struct dpni_tx_conf_attr {
  1500. int errors_only;
  1501. struct dpni_queue_attr queue_attr;
  1502. };
  1503. /**
  1504. * dpni_get_tx_conf() - Get Tx confirmation and error queue attributes
  1505. * @mc_io: Pointer to MC portal's I/O object
  1506. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  1507. * @token: Token of DPNI object
  1508. * @flow_id: The sender's flow ID, as returned by the
  1509. * dpni_set_tx_flow() function;
  1510. * use 'DPNI_COMMON_TX_CONF' for common tx-conf
  1511. * @attr: Returned tx-conf attributes
  1512. *
  1513. * If either 'DPNI_OPT_TX_CONF_DISABLED' or
  1514. * 'DPNI_OPT_PRIVATE_TX_CONF_ERROR_DISABLED' were selected at DPNI creation,
  1515. * this function can ONLY be used with 'flow_id == DPNI_COMMON_TX_CONF';
  1516. * i.e. only serve the common tx-conf-err queue;
  1517. *
  1518. * Return: '0' on Success; Error code otherwise.
  1519. */
  1520. int dpni_get_tx_conf(struct fsl_mc_io *mc_io,
  1521. uint32_t cmd_flags,
  1522. uint16_t token,
  1523. uint16_t flow_id,
  1524. struct dpni_tx_conf_attr *attr);
  1525. /**
  1526. * dpni_set_rx_flow() - Set Rx flow configuration
  1527. * @mc_io: Pointer to MC portal's I/O object
  1528. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  1529. * @token: Token of DPNI object
  1530. * @tc_id: Traffic class selection (0-7);
  1531. * use 'DPNI_ALL_TCS' to set all TCs and all flows
  1532. * @flow_id: Rx flow id within the traffic class; use
  1533. * 'DPNI_ALL_TC_FLOWS' to set all flows within
  1534. * this tc_id; ignored if tc_id is set to
  1535. * 'DPNI_ALL_TCS';
  1536. * @cfg: Rx flow configuration
  1537. *
  1538. * Return: '0' on Success; Error code otherwise.
  1539. */
  1540. int dpni_set_rx_flow(struct fsl_mc_io *mc_io,
  1541. uint32_t cmd_flags,
  1542. uint16_t token,
  1543. uint8_t tc_id,
  1544. uint16_t flow_id,
  1545. const struct dpni_queue_cfg *cfg);
  1546. /**
  1547. * dpni_get_rx_flow() - Get Rx flow attributes
  1548. * @mc_io: Pointer to MC portal's I/O object
  1549. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  1550. * @token: Token of DPNI object
  1551. * @tc_id: Traffic class selection (0-7)
  1552. * @flow_id: Rx flow id within the traffic class
  1553. * @attr: Returned Rx flow attributes
  1554. *
  1555. * Return: '0' on Success; Error code otherwise.
  1556. */
  1557. int dpni_get_rx_flow(struct fsl_mc_io *mc_io,
  1558. uint32_t cmd_flags,
  1559. uint16_t token,
  1560. uint8_t tc_id,
  1561. uint16_t flow_id,
  1562. struct dpni_queue_attr *attr);
  1563. #endif /* _FSL_DPNI_H */