habanalabs.h 71 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153
  1. /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note
  2. *
  3. * Copyright 2016-2022 HabanaLabs, Ltd.
  4. * All Rights Reserved.
  5. *
  6. */
  7. #ifndef HABANALABS_H_
  8. #define HABANALABS_H_
  9. #include <linux/types.h>
  10. #include <linux/ioctl.h>
  11. /*
  12. * Defines that are asic-specific but constitutes as ABI between kernel driver
  13. * and userspace
  14. */
  15. #define GOYA_KMD_SRAM_RESERVED_SIZE_FROM_START 0x8000 /* 32KB */
  16. #define GAUDI_DRIVER_SRAM_RESERVED_SIZE_FROM_START 0x80 /* 128 bytes */
  17. /*
  18. * 128 SOBs reserved for collective wait
  19. * 16 SOBs reserved for sync stream
  20. */
  21. #define GAUDI_FIRST_AVAILABLE_W_S_SYNC_OBJECT 144
  22. /*
  23. * 64 monitors reserved for collective wait
  24. * 8 monitors reserved for sync stream
  25. */
  26. #define GAUDI_FIRST_AVAILABLE_W_S_MONITOR 72
  27. /* Max number of elements in timestamps registration buffers */
  28. #define TS_MAX_ELEMENTS_NUM (1 << 20) /* 1MB */
  29. /*
  30. * Goya queue Numbering
  31. *
  32. * The external queues (PCI DMA channels) MUST be before the internal queues
  33. * and each group (PCI DMA channels and internal) must be contiguous inside
  34. * itself but there can be a gap between the two groups (although not
  35. * recommended)
  36. */
  37. enum goya_queue_id {
  38. GOYA_QUEUE_ID_DMA_0 = 0,
  39. GOYA_QUEUE_ID_DMA_1 = 1,
  40. GOYA_QUEUE_ID_DMA_2 = 2,
  41. GOYA_QUEUE_ID_DMA_3 = 3,
  42. GOYA_QUEUE_ID_DMA_4 = 4,
  43. GOYA_QUEUE_ID_CPU_PQ = 5,
  44. GOYA_QUEUE_ID_MME = 6, /* Internal queues start here */
  45. GOYA_QUEUE_ID_TPC0 = 7,
  46. GOYA_QUEUE_ID_TPC1 = 8,
  47. GOYA_QUEUE_ID_TPC2 = 9,
  48. GOYA_QUEUE_ID_TPC3 = 10,
  49. GOYA_QUEUE_ID_TPC4 = 11,
  50. GOYA_QUEUE_ID_TPC5 = 12,
  51. GOYA_QUEUE_ID_TPC6 = 13,
  52. GOYA_QUEUE_ID_TPC7 = 14,
  53. GOYA_QUEUE_ID_SIZE
  54. };
  55. /*
  56. * Gaudi queue Numbering
  57. * External queues (PCI DMA channels) are DMA_0_*, DMA_1_* and DMA_5_*.
  58. * Except one CPU queue, all the rest are internal queues.
  59. */
  60. enum gaudi_queue_id {
  61. GAUDI_QUEUE_ID_DMA_0_0 = 0, /* external */
  62. GAUDI_QUEUE_ID_DMA_0_1 = 1, /* external */
  63. GAUDI_QUEUE_ID_DMA_0_2 = 2, /* external */
  64. GAUDI_QUEUE_ID_DMA_0_3 = 3, /* external */
  65. GAUDI_QUEUE_ID_DMA_1_0 = 4, /* external */
  66. GAUDI_QUEUE_ID_DMA_1_1 = 5, /* external */
  67. GAUDI_QUEUE_ID_DMA_1_2 = 6, /* external */
  68. GAUDI_QUEUE_ID_DMA_1_3 = 7, /* external */
  69. GAUDI_QUEUE_ID_CPU_PQ = 8, /* CPU */
  70. GAUDI_QUEUE_ID_DMA_2_0 = 9, /* internal */
  71. GAUDI_QUEUE_ID_DMA_2_1 = 10, /* internal */
  72. GAUDI_QUEUE_ID_DMA_2_2 = 11, /* internal */
  73. GAUDI_QUEUE_ID_DMA_2_3 = 12, /* internal */
  74. GAUDI_QUEUE_ID_DMA_3_0 = 13, /* internal */
  75. GAUDI_QUEUE_ID_DMA_3_1 = 14, /* internal */
  76. GAUDI_QUEUE_ID_DMA_3_2 = 15, /* internal */
  77. GAUDI_QUEUE_ID_DMA_3_3 = 16, /* internal */
  78. GAUDI_QUEUE_ID_DMA_4_0 = 17, /* internal */
  79. GAUDI_QUEUE_ID_DMA_4_1 = 18, /* internal */
  80. GAUDI_QUEUE_ID_DMA_4_2 = 19, /* internal */
  81. GAUDI_QUEUE_ID_DMA_4_3 = 20, /* internal */
  82. GAUDI_QUEUE_ID_DMA_5_0 = 21, /* internal */
  83. GAUDI_QUEUE_ID_DMA_5_1 = 22, /* internal */
  84. GAUDI_QUEUE_ID_DMA_5_2 = 23, /* internal */
  85. GAUDI_QUEUE_ID_DMA_5_3 = 24, /* internal */
  86. GAUDI_QUEUE_ID_DMA_6_0 = 25, /* internal */
  87. GAUDI_QUEUE_ID_DMA_6_1 = 26, /* internal */
  88. GAUDI_QUEUE_ID_DMA_6_2 = 27, /* internal */
  89. GAUDI_QUEUE_ID_DMA_6_3 = 28, /* internal */
  90. GAUDI_QUEUE_ID_DMA_7_0 = 29, /* internal */
  91. GAUDI_QUEUE_ID_DMA_7_1 = 30, /* internal */
  92. GAUDI_QUEUE_ID_DMA_7_2 = 31, /* internal */
  93. GAUDI_QUEUE_ID_DMA_7_3 = 32, /* internal */
  94. GAUDI_QUEUE_ID_MME_0_0 = 33, /* internal */
  95. GAUDI_QUEUE_ID_MME_0_1 = 34, /* internal */
  96. GAUDI_QUEUE_ID_MME_0_2 = 35, /* internal */
  97. GAUDI_QUEUE_ID_MME_0_3 = 36, /* internal */
  98. GAUDI_QUEUE_ID_MME_1_0 = 37, /* internal */
  99. GAUDI_QUEUE_ID_MME_1_1 = 38, /* internal */
  100. GAUDI_QUEUE_ID_MME_1_2 = 39, /* internal */
  101. GAUDI_QUEUE_ID_MME_1_3 = 40, /* internal */
  102. GAUDI_QUEUE_ID_TPC_0_0 = 41, /* internal */
  103. GAUDI_QUEUE_ID_TPC_0_1 = 42, /* internal */
  104. GAUDI_QUEUE_ID_TPC_0_2 = 43, /* internal */
  105. GAUDI_QUEUE_ID_TPC_0_3 = 44, /* internal */
  106. GAUDI_QUEUE_ID_TPC_1_0 = 45, /* internal */
  107. GAUDI_QUEUE_ID_TPC_1_1 = 46, /* internal */
  108. GAUDI_QUEUE_ID_TPC_1_2 = 47, /* internal */
  109. GAUDI_QUEUE_ID_TPC_1_3 = 48, /* internal */
  110. GAUDI_QUEUE_ID_TPC_2_0 = 49, /* internal */
  111. GAUDI_QUEUE_ID_TPC_2_1 = 50, /* internal */
  112. GAUDI_QUEUE_ID_TPC_2_2 = 51, /* internal */
  113. GAUDI_QUEUE_ID_TPC_2_3 = 52, /* internal */
  114. GAUDI_QUEUE_ID_TPC_3_0 = 53, /* internal */
  115. GAUDI_QUEUE_ID_TPC_3_1 = 54, /* internal */
  116. GAUDI_QUEUE_ID_TPC_3_2 = 55, /* internal */
  117. GAUDI_QUEUE_ID_TPC_3_3 = 56, /* internal */
  118. GAUDI_QUEUE_ID_TPC_4_0 = 57, /* internal */
  119. GAUDI_QUEUE_ID_TPC_4_1 = 58, /* internal */
  120. GAUDI_QUEUE_ID_TPC_4_2 = 59, /* internal */
  121. GAUDI_QUEUE_ID_TPC_4_3 = 60, /* internal */
  122. GAUDI_QUEUE_ID_TPC_5_0 = 61, /* internal */
  123. GAUDI_QUEUE_ID_TPC_5_1 = 62, /* internal */
  124. GAUDI_QUEUE_ID_TPC_5_2 = 63, /* internal */
  125. GAUDI_QUEUE_ID_TPC_5_3 = 64, /* internal */
  126. GAUDI_QUEUE_ID_TPC_6_0 = 65, /* internal */
  127. GAUDI_QUEUE_ID_TPC_6_1 = 66, /* internal */
  128. GAUDI_QUEUE_ID_TPC_6_2 = 67, /* internal */
  129. GAUDI_QUEUE_ID_TPC_6_3 = 68, /* internal */
  130. GAUDI_QUEUE_ID_TPC_7_0 = 69, /* internal */
  131. GAUDI_QUEUE_ID_TPC_7_1 = 70, /* internal */
  132. GAUDI_QUEUE_ID_TPC_7_2 = 71, /* internal */
  133. GAUDI_QUEUE_ID_TPC_7_3 = 72, /* internal */
  134. GAUDI_QUEUE_ID_NIC_0_0 = 73, /* internal */
  135. GAUDI_QUEUE_ID_NIC_0_1 = 74, /* internal */
  136. GAUDI_QUEUE_ID_NIC_0_2 = 75, /* internal */
  137. GAUDI_QUEUE_ID_NIC_0_3 = 76, /* internal */
  138. GAUDI_QUEUE_ID_NIC_1_0 = 77, /* internal */
  139. GAUDI_QUEUE_ID_NIC_1_1 = 78, /* internal */
  140. GAUDI_QUEUE_ID_NIC_1_2 = 79, /* internal */
  141. GAUDI_QUEUE_ID_NIC_1_3 = 80, /* internal */
  142. GAUDI_QUEUE_ID_NIC_2_0 = 81, /* internal */
  143. GAUDI_QUEUE_ID_NIC_2_1 = 82, /* internal */
  144. GAUDI_QUEUE_ID_NIC_2_2 = 83, /* internal */
  145. GAUDI_QUEUE_ID_NIC_2_3 = 84, /* internal */
  146. GAUDI_QUEUE_ID_NIC_3_0 = 85, /* internal */
  147. GAUDI_QUEUE_ID_NIC_3_1 = 86, /* internal */
  148. GAUDI_QUEUE_ID_NIC_3_2 = 87, /* internal */
  149. GAUDI_QUEUE_ID_NIC_3_3 = 88, /* internal */
  150. GAUDI_QUEUE_ID_NIC_4_0 = 89, /* internal */
  151. GAUDI_QUEUE_ID_NIC_4_1 = 90, /* internal */
  152. GAUDI_QUEUE_ID_NIC_4_2 = 91, /* internal */
  153. GAUDI_QUEUE_ID_NIC_4_3 = 92, /* internal */
  154. GAUDI_QUEUE_ID_NIC_5_0 = 93, /* internal */
  155. GAUDI_QUEUE_ID_NIC_5_1 = 94, /* internal */
  156. GAUDI_QUEUE_ID_NIC_5_2 = 95, /* internal */
  157. GAUDI_QUEUE_ID_NIC_5_3 = 96, /* internal */
  158. GAUDI_QUEUE_ID_NIC_6_0 = 97, /* internal */
  159. GAUDI_QUEUE_ID_NIC_6_1 = 98, /* internal */
  160. GAUDI_QUEUE_ID_NIC_6_2 = 99, /* internal */
  161. GAUDI_QUEUE_ID_NIC_6_3 = 100, /* internal */
  162. GAUDI_QUEUE_ID_NIC_7_0 = 101, /* internal */
  163. GAUDI_QUEUE_ID_NIC_7_1 = 102, /* internal */
  164. GAUDI_QUEUE_ID_NIC_7_2 = 103, /* internal */
  165. GAUDI_QUEUE_ID_NIC_7_3 = 104, /* internal */
  166. GAUDI_QUEUE_ID_NIC_8_0 = 105, /* internal */
  167. GAUDI_QUEUE_ID_NIC_8_1 = 106, /* internal */
  168. GAUDI_QUEUE_ID_NIC_8_2 = 107, /* internal */
  169. GAUDI_QUEUE_ID_NIC_8_3 = 108, /* internal */
  170. GAUDI_QUEUE_ID_NIC_9_0 = 109, /* internal */
  171. GAUDI_QUEUE_ID_NIC_9_1 = 110, /* internal */
  172. GAUDI_QUEUE_ID_NIC_9_2 = 111, /* internal */
  173. GAUDI_QUEUE_ID_NIC_9_3 = 112, /* internal */
  174. GAUDI_QUEUE_ID_SIZE
  175. };
  176. /*
  177. * In GAUDI2 we have two modes of operation in regard to queues:
  178. * 1. Legacy mode, where each QMAN exposes 4 streams to the user
  179. * 2. F/W mode, where we use F/W to schedule the JOBS to the different queues.
  180. *
  181. * When in legacy mode, the user sends the queue id per JOB according to
  182. * enum gaudi2_queue_id below.
  183. *
  184. * When in F/W mode, the user sends a stream id per Command Submission. The
  185. * stream id is a running number from 0 up to (N-1), where N is the number
  186. * of streams the F/W exposes and is passed to the user in
  187. * struct hl_info_hw_ip_info
  188. */
  189. enum gaudi2_queue_id {
  190. GAUDI2_QUEUE_ID_PDMA_0_0 = 0,
  191. GAUDI2_QUEUE_ID_PDMA_0_1 = 1,
  192. GAUDI2_QUEUE_ID_PDMA_0_2 = 2,
  193. GAUDI2_QUEUE_ID_PDMA_0_3 = 3,
  194. GAUDI2_QUEUE_ID_PDMA_1_0 = 4,
  195. GAUDI2_QUEUE_ID_PDMA_1_1 = 5,
  196. GAUDI2_QUEUE_ID_PDMA_1_2 = 6,
  197. GAUDI2_QUEUE_ID_PDMA_1_3 = 7,
  198. GAUDI2_QUEUE_ID_DCORE0_EDMA_0_0 = 8,
  199. GAUDI2_QUEUE_ID_DCORE0_EDMA_0_1 = 9,
  200. GAUDI2_QUEUE_ID_DCORE0_EDMA_0_2 = 10,
  201. GAUDI2_QUEUE_ID_DCORE0_EDMA_0_3 = 11,
  202. GAUDI2_QUEUE_ID_DCORE0_EDMA_1_0 = 12,
  203. GAUDI2_QUEUE_ID_DCORE0_EDMA_1_1 = 13,
  204. GAUDI2_QUEUE_ID_DCORE0_EDMA_1_2 = 14,
  205. GAUDI2_QUEUE_ID_DCORE0_EDMA_1_3 = 15,
  206. GAUDI2_QUEUE_ID_DCORE0_MME_0_0 = 16,
  207. GAUDI2_QUEUE_ID_DCORE0_MME_0_1 = 17,
  208. GAUDI2_QUEUE_ID_DCORE0_MME_0_2 = 18,
  209. GAUDI2_QUEUE_ID_DCORE0_MME_0_3 = 19,
  210. GAUDI2_QUEUE_ID_DCORE0_TPC_0_0 = 20,
  211. GAUDI2_QUEUE_ID_DCORE0_TPC_0_1 = 21,
  212. GAUDI2_QUEUE_ID_DCORE0_TPC_0_2 = 22,
  213. GAUDI2_QUEUE_ID_DCORE0_TPC_0_3 = 23,
  214. GAUDI2_QUEUE_ID_DCORE0_TPC_1_0 = 24,
  215. GAUDI2_QUEUE_ID_DCORE0_TPC_1_1 = 25,
  216. GAUDI2_QUEUE_ID_DCORE0_TPC_1_2 = 26,
  217. GAUDI2_QUEUE_ID_DCORE0_TPC_1_3 = 27,
  218. GAUDI2_QUEUE_ID_DCORE0_TPC_2_0 = 28,
  219. GAUDI2_QUEUE_ID_DCORE0_TPC_2_1 = 29,
  220. GAUDI2_QUEUE_ID_DCORE0_TPC_2_2 = 30,
  221. GAUDI2_QUEUE_ID_DCORE0_TPC_2_3 = 31,
  222. GAUDI2_QUEUE_ID_DCORE0_TPC_3_0 = 32,
  223. GAUDI2_QUEUE_ID_DCORE0_TPC_3_1 = 33,
  224. GAUDI2_QUEUE_ID_DCORE0_TPC_3_2 = 34,
  225. GAUDI2_QUEUE_ID_DCORE0_TPC_3_3 = 35,
  226. GAUDI2_QUEUE_ID_DCORE0_TPC_4_0 = 36,
  227. GAUDI2_QUEUE_ID_DCORE0_TPC_4_1 = 37,
  228. GAUDI2_QUEUE_ID_DCORE0_TPC_4_2 = 38,
  229. GAUDI2_QUEUE_ID_DCORE0_TPC_4_3 = 39,
  230. GAUDI2_QUEUE_ID_DCORE0_TPC_5_0 = 40,
  231. GAUDI2_QUEUE_ID_DCORE0_TPC_5_1 = 41,
  232. GAUDI2_QUEUE_ID_DCORE0_TPC_5_2 = 42,
  233. GAUDI2_QUEUE_ID_DCORE0_TPC_5_3 = 43,
  234. GAUDI2_QUEUE_ID_DCORE0_TPC_6_0 = 44,
  235. GAUDI2_QUEUE_ID_DCORE0_TPC_6_1 = 45,
  236. GAUDI2_QUEUE_ID_DCORE0_TPC_6_2 = 46,
  237. GAUDI2_QUEUE_ID_DCORE0_TPC_6_3 = 47,
  238. GAUDI2_QUEUE_ID_DCORE1_EDMA_0_0 = 48,
  239. GAUDI2_QUEUE_ID_DCORE1_EDMA_0_1 = 49,
  240. GAUDI2_QUEUE_ID_DCORE1_EDMA_0_2 = 50,
  241. GAUDI2_QUEUE_ID_DCORE1_EDMA_0_3 = 51,
  242. GAUDI2_QUEUE_ID_DCORE1_EDMA_1_0 = 52,
  243. GAUDI2_QUEUE_ID_DCORE1_EDMA_1_1 = 53,
  244. GAUDI2_QUEUE_ID_DCORE1_EDMA_1_2 = 54,
  245. GAUDI2_QUEUE_ID_DCORE1_EDMA_1_3 = 55,
  246. GAUDI2_QUEUE_ID_DCORE1_MME_0_0 = 56,
  247. GAUDI2_QUEUE_ID_DCORE1_MME_0_1 = 57,
  248. GAUDI2_QUEUE_ID_DCORE1_MME_0_2 = 58,
  249. GAUDI2_QUEUE_ID_DCORE1_MME_0_3 = 59,
  250. GAUDI2_QUEUE_ID_DCORE1_TPC_0_0 = 60,
  251. GAUDI2_QUEUE_ID_DCORE1_TPC_0_1 = 61,
  252. GAUDI2_QUEUE_ID_DCORE1_TPC_0_2 = 62,
  253. GAUDI2_QUEUE_ID_DCORE1_TPC_0_3 = 63,
  254. GAUDI2_QUEUE_ID_DCORE1_TPC_1_0 = 64,
  255. GAUDI2_QUEUE_ID_DCORE1_TPC_1_1 = 65,
  256. GAUDI2_QUEUE_ID_DCORE1_TPC_1_2 = 66,
  257. GAUDI2_QUEUE_ID_DCORE1_TPC_1_3 = 67,
  258. GAUDI2_QUEUE_ID_DCORE1_TPC_2_0 = 68,
  259. GAUDI2_QUEUE_ID_DCORE1_TPC_2_1 = 69,
  260. GAUDI2_QUEUE_ID_DCORE1_TPC_2_2 = 70,
  261. GAUDI2_QUEUE_ID_DCORE1_TPC_2_3 = 71,
  262. GAUDI2_QUEUE_ID_DCORE1_TPC_3_0 = 72,
  263. GAUDI2_QUEUE_ID_DCORE1_TPC_3_1 = 73,
  264. GAUDI2_QUEUE_ID_DCORE1_TPC_3_2 = 74,
  265. GAUDI2_QUEUE_ID_DCORE1_TPC_3_3 = 75,
  266. GAUDI2_QUEUE_ID_DCORE1_TPC_4_0 = 76,
  267. GAUDI2_QUEUE_ID_DCORE1_TPC_4_1 = 77,
  268. GAUDI2_QUEUE_ID_DCORE1_TPC_4_2 = 78,
  269. GAUDI2_QUEUE_ID_DCORE1_TPC_4_3 = 79,
  270. GAUDI2_QUEUE_ID_DCORE1_TPC_5_0 = 80,
  271. GAUDI2_QUEUE_ID_DCORE1_TPC_5_1 = 81,
  272. GAUDI2_QUEUE_ID_DCORE1_TPC_5_2 = 82,
  273. GAUDI2_QUEUE_ID_DCORE1_TPC_5_3 = 83,
  274. GAUDI2_QUEUE_ID_DCORE2_EDMA_0_0 = 84,
  275. GAUDI2_QUEUE_ID_DCORE2_EDMA_0_1 = 85,
  276. GAUDI2_QUEUE_ID_DCORE2_EDMA_0_2 = 86,
  277. GAUDI2_QUEUE_ID_DCORE2_EDMA_0_3 = 87,
  278. GAUDI2_QUEUE_ID_DCORE2_EDMA_1_0 = 88,
  279. GAUDI2_QUEUE_ID_DCORE2_EDMA_1_1 = 89,
  280. GAUDI2_QUEUE_ID_DCORE2_EDMA_1_2 = 90,
  281. GAUDI2_QUEUE_ID_DCORE2_EDMA_1_3 = 91,
  282. GAUDI2_QUEUE_ID_DCORE2_MME_0_0 = 92,
  283. GAUDI2_QUEUE_ID_DCORE2_MME_0_1 = 93,
  284. GAUDI2_QUEUE_ID_DCORE2_MME_0_2 = 94,
  285. GAUDI2_QUEUE_ID_DCORE2_MME_0_3 = 95,
  286. GAUDI2_QUEUE_ID_DCORE2_TPC_0_0 = 96,
  287. GAUDI2_QUEUE_ID_DCORE2_TPC_0_1 = 97,
  288. GAUDI2_QUEUE_ID_DCORE2_TPC_0_2 = 98,
  289. GAUDI2_QUEUE_ID_DCORE2_TPC_0_3 = 99,
  290. GAUDI2_QUEUE_ID_DCORE2_TPC_1_0 = 100,
  291. GAUDI2_QUEUE_ID_DCORE2_TPC_1_1 = 101,
  292. GAUDI2_QUEUE_ID_DCORE2_TPC_1_2 = 102,
  293. GAUDI2_QUEUE_ID_DCORE2_TPC_1_3 = 103,
  294. GAUDI2_QUEUE_ID_DCORE2_TPC_2_0 = 104,
  295. GAUDI2_QUEUE_ID_DCORE2_TPC_2_1 = 105,
  296. GAUDI2_QUEUE_ID_DCORE2_TPC_2_2 = 106,
  297. GAUDI2_QUEUE_ID_DCORE2_TPC_2_3 = 107,
  298. GAUDI2_QUEUE_ID_DCORE2_TPC_3_0 = 108,
  299. GAUDI2_QUEUE_ID_DCORE2_TPC_3_1 = 109,
  300. GAUDI2_QUEUE_ID_DCORE2_TPC_3_2 = 110,
  301. GAUDI2_QUEUE_ID_DCORE2_TPC_3_3 = 111,
  302. GAUDI2_QUEUE_ID_DCORE2_TPC_4_0 = 112,
  303. GAUDI2_QUEUE_ID_DCORE2_TPC_4_1 = 113,
  304. GAUDI2_QUEUE_ID_DCORE2_TPC_4_2 = 114,
  305. GAUDI2_QUEUE_ID_DCORE2_TPC_4_3 = 115,
  306. GAUDI2_QUEUE_ID_DCORE2_TPC_5_0 = 116,
  307. GAUDI2_QUEUE_ID_DCORE2_TPC_5_1 = 117,
  308. GAUDI2_QUEUE_ID_DCORE2_TPC_5_2 = 118,
  309. GAUDI2_QUEUE_ID_DCORE2_TPC_5_3 = 119,
  310. GAUDI2_QUEUE_ID_DCORE3_EDMA_0_0 = 120,
  311. GAUDI2_QUEUE_ID_DCORE3_EDMA_0_1 = 121,
  312. GAUDI2_QUEUE_ID_DCORE3_EDMA_0_2 = 122,
  313. GAUDI2_QUEUE_ID_DCORE3_EDMA_0_3 = 123,
  314. GAUDI2_QUEUE_ID_DCORE3_EDMA_1_0 = 124,
  315. GAUDI2_QUEUE_ID_DCORE3_EDMA_1_1 = 125,
  316. GAUDI2_QUEUE_ID_DCORE3_EDMA_1_2 = 126,
  317. GAUDI2_QUEUE_ID_DCORE3_EDMA_1_3 = 127,
  318. GAUDI2_QUEUE_ID_DCORE3_MME_0_0 = 128,
  319. GAUDI2_QUEUE_ID_DCORE3_MME_0_1 = 129,
  320. GAUDI2_QUEUE_ID_DCORE3_MME_0_2 = 130,
  321. GAUDI2_QUEUE_ID_DCORE3_MME_0_3 = 131,
  322. GAUDI2_QUEUE_ID_DCORE3_TPC_0_0 = 132,
  323. GAUDI2_QUEUE_ID_DCORE3_TPC_0_1 = 133,
  324. GAUDI2_QUEUE_ID_DCORE3_TPC_0_2 = 134,
  325. GAUDI2_QUEUE_ID_DCORE3_TPC_0_3 = 135,
  326. GAUDI2_QUEUE_ID_DCORE3_TPC_1_0 = 136,
  327. GAUDI2_QUEUE_ID_DCORE3_TPC_1_1 = 137,
  328. GAUDI2_QUEUE_ID_DCORE3_TPC_1_2 = 138,
  329. GAUDI2_QUEUE_ID_DCORE3_TPC_1_3 = 139,
  330. GAUDI2_QUEUE_ID_DCORE3_TPC_2_0 = 140,
  331. GAUDI2_QUEUE_ID_DCORE3_TPC_2_1 = 141,
  332. GAUDI2_QUEUE_ID_DCORE3_TPC_2_2 = 142,
  333. GAUDI2_QUEUE_ID_DCORE3_TPC_2_3 = 143,
  334. GAUDI2_QUEUE_ID_DCORE3_TPC_3_0 = 144,
  335. GAUDI2_QUEUE_ID_DCORE3_TPC_3_1 = 145,
  336. GAUDI2_QUEUE_ID_DCORE3_TPC_3_2 = 146,
  337. GAUDI2_QUEUE_ID_DCORE3_TPC_3_3 = 147,
  338. GAUDI2_QUEUE_ID_DCORE3_TPC_4_0 = 148,
  339. GAUDI2_QUEUE_ID_DCORE3_TPC_4_1 = 149,
  340. GAUDI2_QUEUE_ID_DCORE3_TPC_4_2 = 150,
  341. GAUDI2_QUEUE_ID_DCORE3_TPC_4_3 = 151,
  342. GAUDI2_QUEUE_ID_DCORE3_TPC_5_0 = 152,
  343. GAUDI2_QUEUE_ID_DCORE3_TPC_5_1 = 153,
  344. GAUDI2_QUEUE_ID_DCORE3_TPC_5_2 = 154,
  345. GAUDI2_QUEUE_ID_DCORE3_TPC_5_3 = 155,
  346. GAUDI2_QUEUE_ID_NIC_0_0 = 156,
  347. GAUDI2_QUEUE_ID_NIC_0_1 = 157,
  348. GAUDI2_QUEUE_ID_NIC_0_2 = 158,
  349. GAUDI2_QUEUE_ID_NIC_0_3 = 159,
  350. GAUDI2_QUEUE_ID_NIC_1_0 = 160,
  351. GAUDI2_QUEUE_ID_NIC_1_1 = 161,
  352. GAUDI2_QUEUE_ID_NIC_1_2 = 162,
  353. GAUDI2_QUEUE_ID_NIC_1_3 = 163,
  354. GAUDI2_QUEUE_ID_NIC_2_0 = 164,
  355. GAUDI2_QUEUE_ID_NIC_2_1 = 165,
  356. GAUDI2_QUEUE_ID_NIC_2_2 = 166,
  357. GAUDI2_QUEUE_ID_NIC_2_3 = 167,
  358. GAUDI2_QUEUE_ID_NIC_3_0 = 168,
  359. GAUDI2_QUEUE_ID_NIC_3_1 = 169,
  360. GAUDI2_QUEUE_ID_NIC_3_2 = 170,
  361. GAUDI2_QUEUE_ID_NIC_3_3 = 171,
  362. GAUDI2_QUEUE_ID_NIC_4_0 = 172,
  363. GAUDI2_QUEUE_ID_NIC_4_1 = 173,
  364. GAUDI2_QUEUE_ID_NIC_4_2 = 174,
  365. GAUDI2_QUEUE_ID_NIC_4_3 = 175,
  366. GAUDI2_QUEUE_ID_NIC_5_0 = 176,
  367. GAUDI2_QUEUE_ID_NIC_5_1 = 177,
  368. GAUDI2_QUEUE_ID_NIC_5_2 = 178,
  369. GAUDI2_QUEUE_ID_NIC_5_3 = 179,
  370. GAUDI2_QUEUE_ID_NIC_6_0 = 180,
  371. GAUDI2_QUEUE_ID_NIC_6_1 = 181,
  372. GAUDI2_QUEUE_ID_NIC_6_2 = 182,
  373. GAUDI2_QUEUE_ID_NIC_6_3 = 183,
  374. GAUDI2_QUEUE_ID_NIC_7_0 = 184,
  375. GAUDI2_QUEUE_ID_NIC_7_1 = 185,
  376. GAUDI2_QUEUE_ID_NIC_7_2 = 186,
  377. GAUDI2_QUEUE_ID_NIC_7_3 = 187,
  378. GAUDI2_QUEUE_ID_NIC_8_0 = 188,
  379. GAUDI2_QUEUE_ID_NIC_8_1 = 189,
  380. GAUDI2_QUEUE_ID_NIC_8_2 = 190,
  381. GAUDI2_QUEUE_ID_NIC_8_3 = 191,
  382. GAUDI2_QUEUE_ID_NIC_9_0 = 192,
  383. GAUDI2_QUEUE_ID_NIC_9_1 = 193,
  384. GAUDI2_QUEUE_ID_NIC_9_2 = 194,
  385. GAUDI2_QUEUE_ID_NIC_9_3 = 195,
  386. GAUDI2_QUEUE_ID_NIC_10_0 = 196,
  387. GAUDI2_QUEUE_ID_NIC_10_1 = 197,
  388. GAUDI2_QUEUE_ID_NIC_10_2 = 198,
  389. GAUDI2_QUEUE_ID_NIC_10_3 = 199,
  390. GAUDI2_QUEUE_ID_NIC_11_0 = 200,
  391. GAUDI2_QUEUE_ID_NIC_11_1 = 201,
  392. GAUDI2_QUEUE_ID_NIC_11_2 = 202,
  393. GAUDI2_QUEUE_ID_NIC_11_3 = 203,
  394. GAUDI2_QUEUE_ID_NIC_12_0 = 204,
  395. GAUDI2_QUEUE_ID_NIC_12_1 = 205,
  396. GAUDI2_QUEUE_ID_NIC_12_2 = 206,
  397. GAUDI2_QUEUE_ID_NIC_12_3 = 207,
  398. GAUDI2_QUEUE_ID_NIC_13_0 = 208,
  399. GAUDI2_QUEUE_ID_NIC_13_1 = 209,
  400. GAUDI2_QUEUE_ID_NIC_13_2 = 210,
  401. GAUDI2_QUEUE_ID_NIC_13_3 = 211,
  402. GAUDI2_QUEUE_ID_NIC_14_0 = 212,
  403. GAUDI2_QUEUE_ID_NIC_14_1 = 213,
  404. GAUDI2_QUEUE_ID_NIC_14_2 = 214,
  405. GAUDI2_QUEUE_ID_NIC_14_3 = 215,
  406. GAUDI2_QUEUE_ID_NIC_15_0 = 216,
  407. GAUDI2_QUEUE_ID_NIC_15_1 = 217,
  408. GAUDI2_QUEUE_ID_NIC_15_2 = 218,
  409. GAUDI2_QUEUE_ID_NIC_15_3 = 219,
  410. GAUDI2_QUEUE_ID_NIC_16_0 = 220,
  411. GAUDI2_QUEUE_ID_NIC_16_1 = 221,
  412. GAUDI2_QUEUE_ID_NIC_16_2 = 222,
  413. GAUDI2_QUEUE_ID_NIC_16_3 = 223,
  414. GAUDI2_QUEUE_ID_NIC_17_0 = 224,
  415. GAUDI2_QUEUE_ID_NIC_17_1 = 225,
  416. GAUDI2_QUEUE_ID_NIC_17_2 = 226,
  417. GAUDI2_QUEUE_ID_NIC_17_3 = 227,
  418. GAUDI2_QUEUE_ID_NIC_18_0 = 228,
  419. GAUDI2_QUEUE_ID_NIC_18_1 = 229,
  420. GAUDI2_QUEUE_ID_NIC_18_2 = 230,
  421. GAUDI2_QUEUE_ID_NIC_18_3 = 231,
  422. GAUDI2_QUEUE_ID_NIC_19_0 = 232,
  423. GAUDI2_QUEUE_ID_NIC_19_1 = 233,
  424. GAUDI2_QUEUE_ID_NIC_19_2 = 234,
  425. GAUDI2_QUEUE_ID_NIC_19_3 = 235,
  426. GAUDI2_QUEUE_ID_NIC_20_0 = 236,
  427. GAUDI2_QUEUE_ID_NIC_20_1 = 237,
  428. GAUDI2_QUEUE_ID_NIC_20_2 = 238,
  429. GAUDI2_QUEUE_ID_NIC_20_3 = 239,
  430. GAUDI2_QUEUE_ID_NIC_21_0 = 240,
  431. GAUDI2_QUEUE_ID_NIC_21_1 = 241,
  432. GAUDI2_QUEUE_ID_NIC_21_2 = 242,
  433. GAUDI2_QUEUE_ID_NIC_21_3 = 243,
  434. GAUDI2_QUEUE_ID_NIC_22_0 = 244,
  435. GAUDI2_QUEUE_ID_NIC_22_1 = 245,
  436. GAUDI2_QUEUE_ID_NIC_22_2 = 246,
  437. GAUDI2_QUEUE_ID_NIC_22_3 = 247,
  438. GAUDI2_QUEUE_ID_NIC_23_0 = 248,
  439. GAUDI2_QUEUE_ID_NIC_23_1 = 249,
  440. GAUDI2_QUEUE_ID_NIC_23_2 = 250,
  441. GAUDI2_QUEUE_ID_NIC_23_3 = 251,
  442. GAUDI2_QUEUE_ID_ROT_0_0 = 252,
  443. GAUDI2_QUEUE_ID_ROT_0_1 = 253,
  444. GAUDI2_QUEUE_ID_ROT_0_2 = 254,
  445. GAUDI2_QUEUE_ID_ROT_0_3 = 255,
  446. GAUDI2_QUEUE_ID_ROT_1_0 = 256,
  447. GAUDI2_QUEUE_ID_ROT_1_1 = 257,
  448. GAUDI2_QUEUE_ID_ROT_1_2 = 258,
  449. GAUDI2_QUEUE_ID_ROT_1_3 = 259,
  450. GAUDI2_QUEUE_ID_CPU_PQ = 260,
  451. GAUDI2_QUEUE_ID_SIZE
  452. };
  453. /*
  454. * Engine Numbering
  455. *
  456. * Used in the "busy_engines_mask" field in `struct hl_info_hw_idle'
  457. */
  458. enum goya_engine_id {
  459. GOYA_ENGINE_ID_DMA_0 = 0,
  460. GOYA_ENGINE_ID_DMA_1,
  461. GOYA_ENGINE_ID_DMA_2,
  462. GOYA_ENGINE_ID_DMA_3,
  463. GOYA_ENGINE_ID_DMA_4,
  464. GOYA_ENGINE_ID_MME_0,
  465. GOYA_ENGINE_ID_TPC_0,
  466. GOYA_ENGINE_ID_TPC_1,
  467. GOYA_ENGINE_ID_TPC_2,
  468. GOYA_ENGINE_ID_TPC_3,
  469. GOYA_ENGINE_ID_TPC_4,
  470. GOYA_ENGINE_ID_TPC_5,
  471. GOYA_ENGINE_ID_TPC_6,
  472. GOYA_ENGINE_ID_TPC_7,
  473. GOYA_ENGINE_ID_SIZE
  474. };
  475. enum gaudi_engine_id {
  476. GAUDI_ENGINE_ID_DMA_0 = 0,
  477. GAUDI_ENGINE_ID_DMA_1,
  478. GAUDI_ENGINE_ID_DMA_2,
  479. GAUDI_ENGINE_ID_DMA_3,
  480. GAUDI_ENGINE_ID_DMA_4,
  481. GAUDI_ENGINE_ID_DMA_5,
  482. GAUDI_ENGINE_ID_DMA_6,
  483. GAUDI_ENGINE_ID_DMA_7,
  484. GAUDI_ENGINE_ID_MME_0,
  485. GAUDI_ENGINE_ID_MME_1,
  486. GAUDI_ENGINE_ID_MME_2,
  487. GAUDI_ENGINE_ID_MME_3,
  488. GAUDI_ENGINE_ID_TPC_0,
  489. GAUDI_ENGINE_ID_TPC_1,
  490. GAUDI_ENGINE_ID_TPC_2,
  491. GAUDI_ENGINE_ID_TPC_3,
  492. GAUDI_ENGINE_ID_TPC_4,
  493. GAUDI_ENGINE_ID_TPC_5,
  494. GAUDI_ENGINE_ID_TPC_6,
  495. GAUDI_ENGINE_ID_TPC_7,
  496. GAUDI_ENGINE_ID_NIC_0,
  497. GAUDI_ENGINE_ID_NIC_1,
  498. GAUDI_ENGINE_ID_NIC_2,
  499. GAUDI_ENGINE_ID_NIC_3,
  500. GAUDI_ENGINE_ID_NIC_4,
  501. GAUDI_ENGINE_ID_NIC_5,
  502. GAUDI_ENGINE_ID_NIC_6,
  503. GAUDI_ENGINE_ID_NIC_7,
  504. GAUDI_ENGINE_ID_NIC_8,
  505. GAUDI_ENGINE_ID_NIC_9,
  506. GAUDI_ENGINE_ID_SIZE
  507. };
  508. enum gaudi2_engine_id {
  509. GAUDI2_DCORE0_ENGINE_ID_EDMA_0 = 0,
  510. GAUDI2_DCORE0_ENGINE_ID_EDMA_1,
  511. GAUDI2_DCORE0_ENGINE_ID_MME,
  512. GAUDI2_DCORE0_ENGINE_ID_TPC_0,
  513. GAUDI2_DCORE0_ENGINE_ID_TPC_1,
  514. GAUDI2_DCORE0_ENGINE_ID_TPC_2,
  515. GAUDI2_DCORE0_ENGINE_ID_TPC_3,
  516. GAUDI2_DCORE0_ENGINE_ID_TPC_4,
  517. GAUDI2_DCORE0_ENGINE_ID_TPC_5,
  518. GAUDI2_DCORE0_ENGINE_ID_DEC_0,
  519. GAUDI2_DCORE0_ENGINE_ID_DEC_1,
  520. GAUDI2_DCORE1_ENGINE_ID_EDMA_0,
  521. GAUDI2_DCORE1_ENGINE_ID_EDMA_1,
  522. GAUDI2_DCORE1_ENGINE_ID_MME,
  523. GAUDI2_DCORE1_ENGINE_ID_TPC_0,
  524. GAUDI2_DCORE1_ENGINE_ID_TPC_1,
  525. GAUDI2_DCORE1_ENGINE_ID_TPC_2,
  526. GAUDI2_DCORE1_ENGINE_ID_TPC_3,
  527. GAUDI2_DCORE1_ENGINE_ID_TPC_4,
  528. GAUDI2_DCORE1_ENGINE_ID_TPC_5,
  529. GAUDI2_DCORE1_ENGINE_ID_DEC_0,
  530. GAUDI2_DCORE1_ENGINE_ID_DEC_1,
  531. GAUDI2_DCORE2_ENGINE_ID_EDMA_0,
  532. GAUDI2_DCORE2_ENGINE_ID_EDMA_1,
  533. GAUDI2_DCORE2_ENGINE_ID_MME,
  534. GAUDI2_DCORE2_ENGINE_ID_TPC_0,
  535. GAUDI2_DCORE2_ENGINE_ID_TPC_1,
  536. GAUDI2_DCORE2_ENGINE_ID_TPC_2,
  537. GAUDI2_DCORE2_ENGINE_ID_TPC_3,
  538. GAUDI2_DCORE2_ENGINE_ID_TPC_4,
  539. GAUDI2_DCORE2_ENGINE_ID_TPC_5,
  540. GAUDI2_DCORE2_ENGINE_ID_DEC_0,
  541. GAUDI2_DCORE2_ENGINE_ID_DEC_1,
  542. GAUDI2_DCORE3_ENGINE_ID_EDMA_0,
  543. GAUDI2_DCORE3_ENGINE_ID_EDMA_1,
  544. GAUDI2_DCORE3_ENGINE_ID_MME,
  545. GAUDI2_DCORE3_ENGINE_ID_TPC_0,
  546. GAUDI2_DCORE3_ENGINE_ID_TPC_1,
  547. GAUDI2_DCORE3_ENGINE_ID_TPC_2,
  548. GAUDI2_DCORE3_ENGINE_ID_TPC_3,
  549. GAUDI2_DCORE3_ENGINE_ID_TPC_4,
  550. GAUDI2_DCORE3_ENGINE_ID_TPC_5,
  551. GAUDI2_DCORE3_ENGINE_ID_DEC_0,
  552. GAUDI2_DCORE3_ENGINE_ID_DEC_1,
  553. GAUDI2_DCORE0_ENGINE_ID_TPC_6,
  554. GAUDI2_ENGINE_ID_PDMA_0,
  555. GAUDI2_ENGINE_ID_PDMA_1,
  556. GAUDI2_ENGINE_ID_ROT_0,
  557. GAUDI2_ENGINE_ID_ROT_1,
  558. GAUDI2_PCIE_ENGINE_ID_DEC_0,
  559. GAUDI2_PCIE_ENGINE_ID_DEC_1,
  560. GAUDI2_ENGINE_ID_NIC0_0,
  561. GAUDI2_ENGINE_ID_NIC0_1,
  562. GAUDI2_ENGINE_ID_NIC1_0,
  563. GAUDI2_ENGINE_ID_NIC1_1,
  564. GAUDI2_ENGINE_ID_NIC2_0,
  565. GAUDI2_ENGINE_ID_NIC2_1,
  566. GAUDI2_ENGINE_ID_NIC3_0,
  567. GAUDI2_ENGINE_ID_NIC3_1,
  568. GAUDI2_ENGINE_ID_NIC4_0,
  569. GAUDI2_ENGINE_ID_NIC4_1,
  570. GAUDI2_ENGINE_ID_NIC5_0,
  571. GAUDI2_ENGINE_ID_NIC5_1,
  572. GAUDI2_ENGINE_ID_NIC6_0,
  573. GAUDI2_ENGINE_ID_NIC6_1,
  574. GAUDI2_ENGINE_ID_NIC7_0,
  575. GAUDI2_ENGINE_ID_NIC7_1,
  576. GAUDI2_ENGINE_ID_NIC8_0,
  577. GAUDI2_ENGINE_ID_NIC8_1,
  578. GAUDI2_ENGINE_ID_NIC9_0,
  579. GAUDI2_ENGINE_ID_NIC9_1,
  580. GAUDI2_ENGINE_ID_NIC10_0,
  581. GAUDI2_ENGINE_ID_NIC10_1,
  582. GAUDI2_ENGINE_ID_NIC11_0,
  583. GAUDI2_ENGINE_ID_NIC11_1,
  584. GAUDI2_ENGINE_ID_SIZE
  585. };
  586. /*
  587. * ASIC specific PLL index
  588. *
  589. * Used to retrieve in frequency info of different IPs via
  590. * HL_INFO_PLL_FREQUENCY under HL_IOCTL_INFO IOCTL. The enums need to be
  591. * used as an index in struct hl_pll_frequency_info
  592. */
  593. enum hl_goya_pll_index {
  594. HL_GOYA_CPU_PLL = 0,
  595. HL_GOYA_IC_PLL,
  596. HL_GOYA_MC_PLL,
  597. HL_GOYA_MME_PLL,
  598. HL_GOYA_PCI_PLL,
  599. HL_GOYA_EMMC_PLL,
  600. HL_GOYA_TPC_PLL,
  601. HL_GOYA_PLL_MAX
  602. };
  603. enum hl_gaudi_pll_index {
  604. HL_GAUDI_CPU_PLL = 0,
  605. HL_GAUDI_PCI_PLL,
  606. HL_GAUDI_SRAM_PLL,
  607. HL_GAUDI_HBM_PLL,
  608. HL_GAUDI_NIC_PLL,
  609. HL_GAUDI_DMA_PLL,
  610. HL_GAUDI_MESH_PLL,
  611. HL_GAUDI_MME_PLL,
  612. HL_GAUDI_TPC_PLL,
  613. HL_GAUDI_IF_PLL,
  614. HL_GAUDI_PLL_MAX
  615. };
  616. enum hl_gaudi2_pll_index {
  617. HL_GAUDI2_CPU_PLL = 0,
  618. HL_GAUDI2_PCI_PLL,
  619. HL_GAUDI2_SRAM_PLL,
  620. HL_GAUDI2_HBM_PLL,
  621. HL_GAUDI2_NIC_PLL,
  622. HL_GAUDI2_DMA_PLL,
  623. HL_GAUDI2_MESH_PLL,
  624. HL_GAUDI2_MME_PLL,
  625. HL_GAUDI2_TPC_PLL,
  626. HL_GAUDI2_IF_PLL,
  627. HL_GAUDI2_VID_PLL,
  628. HL_GAUDI2_MSS_PLL,
  629. HL_GAUDI2_PLL_MAX
  630. };
  631. /**
  632. * enum hl_goya_dma_direction - Direction of DMA operation inside a LIN_DMA packet that is
  633. * submitted to the GOYA's DMA QMAN. This attribute is not relevant
  634. * to the H/W but the kernel driver use it to parse the packet's
  635. * addresses and patch/validate them.
  636. * @HL_DMA_HOST_TO_DRAM: DMA operation from Host memory to GOYA's DDR.
  637. * @HL_DMA_HOST_TO_SRAM: DMA operation from Host memory to GOYA's SRAM.
  638. * @HL_DMA_DRAM_TO_SRAM: DMA operation from GOYA's DDR to GOYA's SRAM.
  639. * @HL_DMA_SRAM_TO_DRAM: DMA operation from GOYA's SRAM to GOYA's DDR.
  640. * @HL_DMA_SRAM_TO_HOST: DMA operation from GOYA's SRAM to Host memory.
  641. * @HL_DMA_DRAM_TO_HOST: DMA operation from GOYA's DDR to Host memory.
  642. * @HL_DMA_DRAM_TO_DRAM: DMA operation from GOYA's DDR to GOYA's DDR.
  643. * @HL_DMA_SRAM_TO_SRAM: DMA operation from GOYA's SRAM to GOYA's SRAM.
  644. * @HL_DMA_ENUM_MAX: number of values in enum
  645. */
  646. enum hl_goya_dma_direction {
  647. HL_DMA_HOST_TO_DRAM,
  648. HL_DMA_HOST_TO_SRAM,
  649. HL_DMA_DRAM_TO_SRAM,
  650. HL_DMA_SRAM_TO_DRAM,
  651. HL_DMA_SRAM_TO_HOST,
  652. HL_DMA_DRAM_TO_HOST,
  653. HL_DMA_DRAM_TO_DRAM,
  654. HL_DMA_SRAM_TO_SRAM,
  655. HL_DMA_ENUM_MAX
  656. };
  657. /**
  658. * enum hl_device_status - Device status information.
  659. * @HL_DEVICE_STATUS_OPERATIONAL: Device is operational.
  660. * @HL_DEVICE_STATUS_IN_RESET: Device is currently during reset.
  661. * @HL_DEVICE_STATUS_MALFUNCTION: Device is unusable.
  662. * @HL_DEVICE_STATUS_NEEDS_RESET: Device needs reset because auto reset was disabled.
  663. * @HL_DEVICE_STATUS_IN_DEVICE_CREATION: Device is operational but its creation is still in
  664. * progress.
  665. * @HL_DEVICE_STATUS_IN_RESET_AFTER_DEVICE_RELEASE: Device is currently during reset that was
  666. * triggered because the user released the device
  667. * @HL_DEVICE_STATUS_LAST: Last status.
  668. */
  669. enum hl_device_status {
  670. HL_DEVICE_STATUS_OPERATIONAL,
  671. HL_DEVICE_STATUS_IN_RESET,
  672. HL_DEVICE_STATUS_MALFUNCTION,
  673. HL_DEVICE_STATUS_NEEDS_RESET,
  674. HL_DEVICE_STATUS_IN_DEVICE_CREATION,
  675. HL_DEVICE_STATUS_IN_RESET_AFTER_DEVICE_RELEASE,
  676. HL_DEVICE_STATUS_LAST = HL_DEVICE_STATUS_IN_RESET_AFTER_DEVICE_RELEASE
  677. };
  678. enum hl_server_type {
  679. HL_SERVER_TYPE_UNKNOWN = 0,
  680. HL_SERVER_GAUDI_HLS1 = 1,
  681. HL_SERVER_GAUDI_HLS1H = 2,
  682. HL_SERVER_GAUDI_TYPE1 = 3,
  683. HL_SERVER_GAUDI_TYPE2 = 4,
  684. HL_SERVER_GAUDI2_HLS2 = 5
  685. };
  686. /*
  687. * Notifier event values - for the notification mechanism and the HL_INFO_GET_EVENTS command
  688. *
  689. * HL_NOTIFIER_EVENT_TPC_ASSERT - Indicates TPC assert event
  690. * HL_NOTIFIER_EVENT_UNDEFINED_OPCODE - Indicates undefined operation code
  691. * HL_NOTIFIER_EVENT_DEVICE_RESET - Indicates device requires a reset
  692. * HL_NOTIFIER_EVENT_CS_TIMEOUT - Indicates CS timeout error
  693. * HL_NOTIFIER_EVENT_DEVICE_UNAVAILABLE - Indicates device is unavailable
  694. * HL_NOTIFIER_EVENT_USER_ENGINE_ERR - Indicates device engine in error state
  695. * HL_NOTIFIER_EVENT_GENERAL_HW_ERR - Indicates device HW error
  696. */
  697. #define HL_NOTIFIER_EVENT_TPC_ASSERT (1ULL << 0)
  698. #define HL_NOTIFIER_EVENT_UNDEFINED_OPCODE (1ULL << 1)
  699. #define HL_NOTIFIER_EVENT_DEVICE_RESET (1ULL << 2)
  700. #define HL_NOTIFIER_EVENT_CS_TIMEOUT (1ULL << 3)
  701. #define HL_NOTIFIER_EVENT_DEVICE_UNAVAILABLE (1ULL << 4)
  702. #define HL_NOTIFIER_EVENT_USER_ENGINE_ERR (1ULL << 5)
  703. #define HL_NOTIFIER_EVENT_GENERAL_HW_ERR (1ULL << 6)
  704. /* Opcode for management ioctl
  705. *
  706. * HW_IP_INFO - Receive information about different IP blocks in the
  707. * device.
  708. * HL_INFO_HW_EVENTS - Receive an array describing how many times each event
  709. * occurred since the last hard reset.
  710. * HL_INFO_DRAM_USAGE - Retrieve the dram usage inside the device and of the
  711. * specific context. This is relevant only for devices
  712. * where the dram is managed by the kernel driver
  713. * HL_INFO_HW_IDLE - Retrieve information about the idle status of each
  714. * internal engine.
  715. * HL_INFO_DEVICE_STATUS - Retrieve the device's status. This opcode doesn't
  716. * require an open context.
  717. * HL_INFO_DEVICE_UTILIZATION - Retrieve the total utilization of the device
  718. * over the last period specified by the user.
  719. * The period can be between 100ms to 1s, in
  720. * resolution of 100ms. The return value is a
  721. * percentage of the utilization rate.
  722. * HL_INFO_HW_EVENTS_AGGREGATE - Receive an array describing how many times each
  723. * event occurred since the driver was loaded.
  724. * HL_INFO_CLK_RATE - Retrieve the current and maximum clock rate
  725. * of the device in MHz. The maximum clock rate is
  726. * configurable via sysfs parameter
  727. * HL_INFO_RESET_COUNT - Retrieve the counts of the soft and hard reset
  728. * operations performed on the device since the last
  729. * time the driver was loaded.
  730. * HL_INFO_TIME_SYNC - Retrieve the device's time alongside the host's time
  731. * for synchronization.
  732. * HL_INFO_CS_COUNTERS - Retrieve command submission counters
  733. * HL_INFO_PCI_COUNTERS - Retrieve PCI counters
  734. * HL_INFO_CLK_THROTTLE_REASON - Retrieve clock throttling reason
  735. * HL_INFO_SYNC_MANAGER - Retrieve sync manager info per dcore
  736. * HL_INFO_TOTAL_ENERGY - Retrieve total energy consumption
  737. * HL_INFO_PLL_FREQUENCY - Retrieve PLL frequency
  738. * HL_INFO_POWER - Retrieve power information
  739. * HL_INFO_OPEN_STATS - Retrieve info regarding recent device open calls
  740. * HL_INFO_DRAM_REPLACED_ROWS - Retrieve DRAM replaced rows info
  741. * HL_INFO_DRAM_PENDING_ROWS - Retrieve DRAM pending rows num
  742. * HL_INFO_LAST_ERR_OPEN_DEV_TIME - Retrieve timestamp of the last time the device was opened
  743. * and CS timeout or razwi error occurred.
  744. * HL_INFO_CS_TIMEOUT_EVENT - Retrieve CS timeout timestamp and its related CS sequence number.
  745. * HL_INFO_RAZWI_EVENT - Retrieve parameters of razwi:
  746. * Timestamp of razwi.
  747. * The address which accessing it caused the razwi.
  748. * Razwi initiator.
  749. * Razwi cause, was it a page fault or MMU access error.
  750. * HL_INFO_DEV_MEM_ALLOC_PAGE_SIZES - Retrieve valid page sizes for device memory allocation
  751. * HL_INFO_SECURED_ATTESTATION - Retrieve attestation report of the boot.
  752. * HL_INFO_REGISTER_EVENTFD - Register eventfd for event notifications.
  753. * HL_INFO_UNREGISTER_EVENTFD - Unregister eventfd
  754. * HL_INFO_GET_EVENTS - Retrieve the last occurred events
  755. * HL_INFO_UNDEFINED_OPCODE_EVENT - Retrieve last undefined opcode error information.
  756. */
  757. #define HL_INFO_HW_IP_INFO 0
  758. #define HL_INFO_HW_EVENTS 1
  759. #define HL_INFO_DRAM_USAGE 2
  760. #define HL_INFO_HW_IDLE 3
  761. #define HL_INFO_DEVICE_STATUS 4
  762. #define HL_INFO_DEVICE_UTILIZATION 6
  763. #define HL_INFO_HW_EVENTS_AGGREGATE 7
  764. #define HL_INFO_CLK_RATE 8
  765. #define HL_INFO_RESET_COUNT 9
  766. #define HL_INFO_TIME_SYNC 10
  767. #define HL_INFO_CS_COUNTERS 11
  768. #define HL_INFO_PCI_COUNTERS 12
  769. #define HL_INFO_CLK_THROTTLE_REASON 13
  770. #define HL_INFO_SYNC_MANAGER 14
  771. #define HL_INFO_TOTAL_ENERGY 15
  772. #define HL_INFO_PLL_FREQUENCY 16
  773. #define HL_INFO_POWER 17
  774. #define HL_INFO_OPEN_STATS 18
  775. #define HL_INFO_DRAM_REPLACED_ROWS 21
  776. #define HL_INFO_DRAM_PENDING_ROWS 22
  777. #define HL_INFO_LAST_ERR_OPEN_DEV_TIME 23
  778. #define HL_INFO_CS_TIMEOUT_EVENT 24
  779. #define HL_INFO_RAZWI_EVENT 25
  780. #define HL_INFO_DEV_MEM_ALLOC_PAGE_SIZES 26
  781. #define HL_INFO_SECURED_ATTESTATION 27
  782. #define HL_INFO_REGISTER_EVENTFD 28
  783. #define HL_INFO_UNREGISTER_EVENTFD 29
  784. #define HL_INFO_GET_EVENTS 30
  785. #define HL_INFO_UNDEFINED_OPCODE_EVENT 31
  786. #define HL_INFO_ENGINE_STATUS 32
  787. #define HL_INFO_VERSION_MAX_LEN 128
  788. #define HL_INFO_CARD_NAME_MAX_LEN 16
  789. /* Maximum buffer size for retrieving engines status */
  790. #define HL_ENGINES_DATA_MAX_SIZE SZ_1M
  791. /**
  792. * struct hl_info_hw_ip_info - hardware information on various IPs in the ASIC
  793. * @sram_base_address: The first SRAM physical base address that is free to be
  794. * used by the user.
  795. * @dram_base_address: The first DRAM virtual or physical base address that is
  796. * free to be used by the user.
  797. * @dram_size: The DRAM size that is available to the user.
  798. * @sram_size: The SRAM size that is available to the user.
  799. * @num_of_events: The number of events that can be received from the f/w. This
  800. * is needed so the user can what is the size of the h/w events
  801. * array he needs to pass to the kernel when he wants to fetch
  802. * the event counters.
  803. * @device_id: PCI device ID of the ASIC.
  804. * @module_id: Module ID of the ASIC for mezzanine cards in servers
  805. * (From OCP spec).
  806. * @decoder_enabled_mask: Bit-mask that represents which decoders are enabled.
  807. * @first_available_interrupt_id: The first available interrupt ID for the user
  808. * to be used when it works with user interrupts.
  809. * Relevant for Gaudi2 and later.
  810. * @server_type: Server type that the Gaudi ASIC is currently installed in.
  811. * The value is according to enum hl_server_type
  812. * @cpld_version: CPLD version on the board.
  813. * @psoc_pci_pll_nr: PCI PLL NR value. Needed by the profiler in some ASICs.
  814. * @psoc_pci_pll_nf: PCI PLL NF value. Needed by the profiler in some ASICs.
  815. * @psoc_pci_pll_od: PCI PLL OD value. Needed by the profiler in some ASICs.
  816. * @psoc_pci_pll_div_factor: PCI PLL DIV factor value. Needed by the profiler
  817. * in some ASICs.
  818. * @tpc_enabled_mask: Bit-mask that represents which TPCs are enabled. Relevant
  819. * for Goya/Gaudi only.
  820. * @dram_enabled: Whether the DRAM is enabled.
  821. * @security_enabled: Whether security is enabled on device.
  822. * @mme_master_slave_mode: Indicate whether the MME is working in master/slave
  823. * configuration. Relevant for Greco and later.
  824. * @cpucp_version: The CPUCP f/w version.
  825. * @card_name: The card name as passed by the f/w.
  826. * @tpc_enabled_mask_ext: Bit-mask that represents which TPCs are enabled.
  827. * Relevant for Greco and later.
  828. * @dram_page_size: The DRAM physical page size.
  829. * @edma_enabled_mask: Bit-mask that represents which EDMAs are enabled.
  830. * Relevant for Gaudi2 and later.
  831. * @number_of_user_interrupts: The number of interrupts that are available to the userspace
  832. * application to use. Relevant for Gaudi2 and later.
  833. * @device_mem_alloc_default_page_size: default page size used in device memory allocation.
  834. */
  835. struct hl_info_hw_ip_info {
  836. __u64 sram_base_address;
  837. __u64 dram_base_address;
  838. __u64 dram_size;
  839. __u32 sram_size;
  840. __u32 num_of_events;
  841. __u32 device_id;
  842. __u32 module_id;
  843. __u32 decoder_enabled_mask;
  844. __u16 first_available_interrupt_id;
  845. __u16 server_type;
  846. __u32 cpld_version;
  847. __u32 psoc_pci_pll_nr;
  848. __u32 psoc_pci_pll_nf;
  849. __u32 psoc_pci_pll_od;
  850. __u32 psoc_pci_pll_div_factor;
  851. __u8 tpc_enabled_mask;
  852. __u8 dram_enabled;
  853. __u8 security_enabled;
  854. __u8 mme_master_slave_mode;
  855. __u8 cpucp_version[HL_INFO_VERSION_MAX_LEN];
  856. __u8 card_name[HL_INFO_CARD_NAME_MAX_LEN];
  857. __u64 tpc_enabled_mask_ext;
  858. __u64 dram_page_size;
  859. __u32 edma_enabled_mask;
  860. __u16 number_of_user_interrupts;
  861. __u16 pad2;
  862. __u64 reserved4;
  863. __u64 device_mem_alloc_default_page_size;
  864. };
  865. struct hl_info_dram_usage {
  866. __u64 dram_free_mem;
  867. __u64 ctx_dram_mem;
  868. };
  869. #define HL_BUSY_ENGINES_MASK_EXT_SIZE 2
  870. struct hl_info_hw_idle {
  871. __u32 is_idle;
  872. /*
  873. * Bitmask of busy engines.
  874. * Bits definition is according to `enum <chip>_engine_id'.
  875. */
  876. __u32 busy_engines_mask;
  877. /*
  878. * Extended Bitmask of busy engines.
  879. * Bits definition is according to `enum <chip>_engine_id'.
  880. */
  881. __u64 busy_engines_mask_ext[HL_BUSY_ENGINES_MASK_EXT_SIZE];
  882. };
  883. struct hl_info_device_status {
  884. __u32 status;
  885. __u32 pad;
  886. };
  887. struct hl_info_device_utilization {
  888. __u32 utilization;
  889. __u32 pad;
  890. };
  891. struct hl_info_clk_rate {
  892. __u32 cur_clk_rate_mhz;
  893. __u32 max_clk_rate_mhz;
  894. };
  895. struct hl_info_reset_count {
  896. __u32 hard_reset_cnt;
  897. __u32 soft_reset_cnt;
  898. };
  899. struct hl_info_time_sync {
  900. __u64 device_time;
  901. __u64 host_time;
  902. };
  903. /**
  904. * struct hl_info_pci_counters - pci counters
  905. * @rx_throughput: PCI rx throughput KBps
  906. * @tx_throughput: PCI tx throughput KBps
  907. * @replay_cnt: PCI replay counter
  908. */
  909. struct hl_info_pci_counters {
  910. __u64 rx_throughput;
  911. __u64 tx_throughput;
  912. __u64 replay_cnt;
  913. };
  914. enum hl_clk_throttling_type {
  915. HL_CLK_THROTTLE_TYPE_POWER,
  916. HL_CLK_THROTTLE_TYPE_THERMAL,
  917. HL_CLK_THROTTLE_TYPE_MAX
  918. };
  919. /* clk_throttling_reason masks */
  920. #define HL_CLK_THROTTLE_POWER (1 << HL_CLK_THROTTLE_TYPE_POWER)
  921. #define HL_CLK_THROTTLE_THERMAL (1 << HL_CLK_THROTTLE_TYPE_THERMAL)
  922. /**
  923. * struct hl_info_clk_throttle - clock throttling reason
  924. * @clk_throttling_reason: each bit represents a clk throttling reason
  925. * @clk_throttling_timestamp_us: represents CPU timestamp in microseconds of the start-event
  926. * @clk_throttling_duration_ns: the clock throttle time in nanosec
  927. */
  928. struct hl_info_clk_throttle {
  929. __u32 clk_throttling_reason;
  930. __u32 pad;
  931. __u64 clk_throttling_timestamp_us[HL_CLK_THROTTLE_TYPE_MAX];
  932. __u64 clk_throttling_duration_ns[HL_CLK_THROTTLE_TYPE_MAX];
  933. };
  934. /**
  935. * struct hl_info_energy - device energy information
  936. * @total_energy_consumption: total device energy consumption
  937. */
  938. struct hl_info_energy {
  939. __u64 total_energy_consumption;
  940. };
  941. #define HL_PLL_NUM_OUTPUTS 4
  942. struct hl_pll_frequency_info {
  943. __u16 output[HL_PLL_NUM_OUTPUTS];
  944. };
  945. /**
  946. * struct hl_open_stats_info - device open statistics information
  947. * @open_counter: ever growing counter, increased on each successful dev open
  948. * @last_open_period_ms: duration (ms) device was open last time
  949. * @is_compute_ctx_active: Whether there is an active compute context executing
  950. * @compute_ctx_in_release: true if the current compute context is being released
  951. */
  952. struct hl_open_stats_info {
  953. __u64 open_counter;
  954. __u64 last_open_period_ms;
  955. __u8 is_compute_ctx_active;
  956. __u8 compute_ctx_in_release;
  957. __u8 pad[6];
  958. };
  959. /**
  960. * struct hl_power_info - power information
  961. * @power: power consumption
  962. */
  963. struct hl_power_info {
  964. __u64 power;
  965. };
  966. /**
  967. * struct hl_info_sync_manager - sync manager information
  968. * @first_available_sync_object: first available sob
  969. * @first_available_monitor: first available monitor
  970. * @first_available_cq: first available cq
  971. */
  972. struct hl_info_sync_manager {
  973. __u32 first_available_sync_object;
  974. __u32 first_available_monitor;
  975. __u32 first_available_cq;
  976. __u32 reserved;
  977. };
  978. /**
  979. * struct hl_info_cs_counters - command submission counters
  980. * @total_out_of_mem_drop_cnt: total dropped due to memory allocation issue
  981. * @ctx_out_of_mem_drop_cnt: context dropped due to memory allocation issue
  982. * @total_parsing_drop_cnt: total dropped due to error in packet parsing
  983. * @ctx_parsing_drop_cnt: context dropped due to error in packet parsing
  984. * @total_queue_full_drop_cnt: total dropped due to queue full
  985. * @ctx_queue_full_drop_cnt: context dropped due to queue full
  986. * @total_device_in_reset_drop_cnt: total dropped due to device in reset
  987. * @ctx_device_in_reset_drop_cnt: context dropped due to device in reset
  988. * @total_max_cs_in_flight_drop_cnt: total dropped due to maximum CS in-flight
  989. * @ctx_max_cs_in_flight_drop_cnt: context dropped due to maximum CS in-flight
  990. * @total_validation_drop_cnt: total dropped due to validation error
  991. * @ctx_validation_drop_cnt: context dropped due to validation error
  992. */
  993. struct hl_info_cs_counters {
  994. __u64 total_out_of_mem_drop_cnt;
  995. __u64 ctx_out_of_mem_drop_cnt;
  996. __u64 total_parsing_drop_cnt;
  997. __u64 ctx_parsing_drop_cnt;
  998. __u64 total_queue_full_drop_cnt;
  999. __u64 ctx_queue_full_drop_cnt;
  1000. __u64 total_device_in_reset_drop_cnt;
  1001. __u64 ctx_device_in_reset_drop_cnt;
  1002. __u64 total_max_cs_in_flight_drop_cnt;
  1003. __u64 ctx_max_cs_in_flight_drop_cnt;
  1004. __u64 total_validation_drop_cnt;
  1005. __u64 ctx_validation_drop_cnt;
  1006. };
  1007. /**
  1008. * struct hl_info_last_err_open_dev_time - last error boot information.
  1009. * @timestamp: timestamp of last time the device was opened and error occurred.
  1010. */
  1011. struct hl_info_last_err_open_dev_time {
  1012. __s64 timestamp;
  1013. };
  1014. /**
  1015. * struct hl_info_cs_timeout_event - last CS timeout information.
  1016. * @timestamp: timestamp when last CS timeout event occurred.
  1017. * @seq: sequence number of last CS timeout event.
  1018. */
  1019. struct hl_info_cs_timeout_event {
  1020. __s64 timestamp;
  1021. __u64 seq;
  1022. };
  1023. #define HL_RAZWI_PAGE_FAULT 0
  1024. #define HL_RAZWI_MMU_ACCESS_ERROR 1
  1025. /**
  1026. * struct hl_info_razwi_event - razwi information.
  1027. * @timestamp: timestamp of razwi.
  1028. * @addr: address which accessing it caused razwi.
  1029. * @engine_id_1: engine id of the razwi initiator, if it was initiated by engine that does not
  1030. * have engine id it will be set to U16_MAX.
  1031. * @engine_id_2: second engine id of razwi initiator. Might happen that razwi have 2 possible
  1032. * engines which one them caused the razwi. In that case, it will contain the
  1033. * second possible engine id, otherwise it will be set to U16_MAX.
  1034. * @no_engine_id: if razwi initiator does not have engine id, this field will be set to 1,
  1035. * otherwise 0.
  1036. * @error_type: cause of razwi, page fault or access error, otherwise it will be set to U8_MAX.
  1037. * @pad: padding to 64 bit.
  1038. */
  1039. struct hl_info_razwi_event {
  1040. __s64 timestamp;
  1041. __u64 addr;
  1042. __u16 engine_id_1;
  1043. __u16 engine_id_2;
  1044. __u8 no_engine_id;
  1045. __u8 error_type;
  1046. __u8 pad[2];
  1047. };
  1048. #define MAX_QMAN_STREAMS_INFO 4
  1049. #define OPCODE_INFO_MAX_ADDR_SIZE 8
  1050. /**
  1051. * struct hl_info_undefined_opcode_event - info about last undefined opcode error
  1052. * @timestamp: timestamp of the undefined opcode error
  1053. * @cb_addr_streams: CB addresses (per stream) that are currently exists in the PQ
  1054. * entries. In case all streams array entries are
  1055. * filled with values, it means the execution was in Lower-CP.
  1056. * @cq_addr: the address of the current handled command buffer
  1057. * @cq_size: the size of the current handled command buffer
  1058. * @cb_addr_streams_len: num of streams - actual len of cb_addr_streams array.
  1059. * should be equal to 1 in case of undefined opcode
  1060. * in Upper-CP (specific stream) and equal to 4 incase
  1061. * of undefined opcode in Lower-CP.
  1062. * @engine_id: engine-id that the error occurred on
  1063. * @stream_id: the stream id the error occurred on. In case the stream equals to
  1064. * MAX_QMAN_STREAMS_INFO it means the error occurred on a Lower-CP.
  1065. */
  1066. struct hl_info_undefined_opcode_event {
  1067. __s64 timestamp;
  1068. __u64 cb_addr_streams[MAX_QMAN_STREAMS_INFO][OPCODE_INFO_MAX_ADDR_SIZE];
  1069. __u64 cq_addr;
  1070. __u32 cq_size;
  1071. __u32 cb_addr_streams_len;
  1072. __u32 engine_id;
  1073. __u32 stream_id;
  1074. };
  1075. /**
  1076. * struct hl_info_dev_memalloc_page_sizes - valid page sizes in device mem alloc information.
  1077. * @page_order_bitmask: bitmap in which a set bit represents the order of the supported page size
  1078. * (e.g. 0x2100000 means that 1MB and 32MB pages are supported).
  1079. */
  1080. struct hl_info_dev_memalloc_page_sizes {
  1081. __u64 page_order_bitmask;
  1082. };
  1083. #define SEC_PCR_DATA_BUF_SZ 256
  1084. #define SEC_PCR_QUOTE_BUF_SZ 510 /* (512 - 2) 2 bytes used for size */
  1085. #define SEC_SIGNATURE_BUF_SZ 255 /* (256 - 1) 1 byte used for size */
  1086. #define SEC_PUB_DATA_BUF_SZ 510 /* (512 - 2) 2 bytes used for size */
  1087. #define SEC_CERTIFICATE_BUF_SZ 2046 /* (2048 - 2) 2 bytes used for size */
  1088. /*
  1089. * struct hl_info_sec_attest - attestation report of the boot
  1090. * @nonce: number only used once. random number provided by host. this also passed to the quote
  1091. * command as a qualifying data.
  1092. * @pcr_quote_len: length of the attestation quote data (bytes)
  1093. * @pub_data_len: length of the public data (bytes)
  1094. * @certificate_len: length of the certificate (bytes)
  1095. * @pcr_num_reg: number of PCR registers in the pcr_data array
  1096. * @pcr_reg_len: length of each PCR register in the pcr_data array (bytes)
  1097. * @quote_sig_len: length of the attestation report signature (bytes)
  1098. * @pcr_data: raw values of the PCR registers
  1099. * @pcr_quote: attestation report data structure
  1100. * @quote_sig: signature structure of the attestation report
  1101. * @public_data: public key for the signed attestation
  1102. * (outPublic + name + qualifiedName)
  1103. * @certificate: certificate for the attestation signing key
  1104. */
  1105. struct hl_info_sec_attest {
  1106. __u32 nonce;
  1107. __u16 pcr_quote_len;
  1108. __u16 pub_data_len;
  1109. __u16 certificate_len;
  1110. __u8 pcr_num_reg;
  1111. __u8 pcr_reg_len;
  1112. __u8 quote_sig_len;
  1113. __u8 pcr_data[SEC_PCR_DATA_BUF_SZ];
  1114. __u8 pcr_quote[SEC_PCR_QUOTE_BUF_SZ];
  1115. __u8 quote_sig[SEC_SIGNATURE_BUF_SZ];
  1116. __u8 public_data[SEC_PUB_DATA_BUF_SZ];
  1117. __u8 certificate[SEC_CERTIFICATE_BUF_SZ];
  1118. __u8 pad0[2];
  1119. };
  1120. enum gaudi_dcores {
  1121. HL_GAUDI_WS_DCORE,
  1122. HL_GAUDI_WN_DCORE,
  1123. HL_GAUDI_EN_DCORE,
  1124. HL_GAUDI_ES_DCORE
  1125. };
  1126. /**
  1127. * struct hl_info_args - Main structure to retrieve device related information.
  1128. * @return_pointer: User space address of the relevant structure related to HL_INFO_* operation
  1129. * mentioned in @op.
  1130. * @return_size: Size of the structure used in @return_pointer, just like "size" in "snprintf", it
  1131. * limits how many bytes the kernel can write. For hw_events array, the size should be
  1132. * hl_info_hw_ip_info.num_of_events * sizeof(__u32).
  1133. * @op: Defines which type of information to be retrieved. Refer HL_INFO_* for details.
  1134. * @dcore_id: DCORE id for which the information is relevant (for Gaudi refer to enum gaudi_dcores).
  1135. * @ctx_id: Context ID of the user. Currently not in use.
  1136. * @period_ms: Period value, in milliseconds, for utilization rate in range 100ms - 1000ms in 100 ms
  1137. * resolution. Currently not in use.
  1138. * @pll_index: Index as defined in hl_<asic type>_pll_index enumeration.
  1139. * @eventfd: event file descriptor for event notifications.
  1140. * @user_buffer_actual_size: Actual data size which was copied to user allocated buffer by the
  1141. * driver. It is possible for the user to allocate buffer larger than
  1142. * needed, hence updating this variable so user will know the exact amount
  1143. * of bytes copied by the kernel to the buffer.
  1144. * @sec_attest_nonce: Nonce number used for attestation report.
  1145. * @pad: Padding to 64 bit.
  1146. */
  1147. struct hl_info_args {
  1148. __u64 return_pointer;
  1149. __u32 return_size;
  1150. __u32 op;
  1151. union {
  1152. __u32 dcore_id;
  1153. __u32 ctx_id;
  1154. __u32 period_ms;
  1155. __u32 pll_index;
  1156. __u32 eventfd;
  1157. __u32 user_buffer_actual_size;
  1158. __u32 sec_attest_nonce;
  1159. };
  1160. __u32 pad;
  1161. };
  1162. /* Opcode to create a new command buffer */
  1163. #define HL_CB_OP_CREATE 0
  1164. /* Opcode to destroy previously created command buffer */
  1165. #define HL_CB_OP_DESTROY 1
  1166. /* Opcode to retrieve information about a command buffer */
  1167. #define HL_CB_OP_INFO 2
  1168. /* 2MB minus 32 bytes for 2xMSG_PROT */
  1169. #define HL_MAX_CB_SIZE (0x200000 - 32)
  1170. /* Indicates whether the command buffer should be mapped to the device's MMU */
  1171. #define HL_CB_FLAGS_MAP 0x1
  1172. /* Used with HL_CB_OP_INFO opcode to get the device va address for kernel mapped CB */
  1173. #define HL_CB_FLAGS_GET_DEVICE_VA 0x2
  1174. struct hl_cb_in {
  1175. /* Handle of CB or 0 if we want to create one */
  1176. __u64 cb_handle;
  1177. /* HL_CB_OP_* */
  1178. __u32 op;
  1179. /* Size of CB. Maximum size is HL_MAX_CB_SIZE. The minimum size that
  1180. * will be allocated, regardless of this parameter's value, is PAGE_SIZE
  1181. */
  1182. __u32 cb_size;
  1183. /* Context ID - Currently not in use */
  1184. __u32 ctx_id;
  1185. /* HL_CB_FLAGS_* */
  1186. __u32 flags;
  1187. };
  1188. struct hl_cb_out {
  1189. union {
  1190. /* Handle of CB */
  1191. __u64 cb_handle;
  1192. union {
  1193. /* Information about CB */
  1194. struct {
  1195. /* Usage count of CB */
  1196. __u32 usage_cnt;
  1197. __u32 pad;
  1198. };
  1199. /* CB mapped address to device MMU */
  1200. __u64 device_va;
  1201. };
  1202. };
  1203. };
  1204. union hl_cb_args {
  1205. struct hl_cb_in in;
  1206. struct hl_cb_out out;
  1207. };
  1208. /* HL_CS_CHUNK_FLAGS_ values
  1209. *
  1210. * HL_CS_CHUNK_FLAGS_USER_ALLOC_CB:
  1211. * Indicates if the CB was allocated and mapped by userspace
  1212. * (relevant to greco and above). User allocated CB is a command buffer,
  1213. * allocated by the user, via malloc (or similar). After allocating the
  1214. * CB, the user invokes - “memory ioctl” to map the user memory into a
  1215. * device virtual address. The user provides this address via the
  1216. * cb_handle field. The interface provides the ability to create a
  1217. * large CBs, Which aren’t limited to “HL_MAX_CB_SIZE”. Therefore, it
  1218. * increases the PCI-DMA queues throughput. This CB allocation method
  1219. * also reduces the use of Linux DMA-able memory pool. Which are limited
  1220. * and used by other Linux sub-systems.
  1221. */
  1222. #define HL_CS_CHUNK_FLAGS_USER_ALLOC_CB 0x1
  1223. /*
  1224. * This structure size must always be fixed to 64-bytes for backward
  1225. * compatibility
  1226. */
  1227. struct hl_cs_chunk {
  1228. union {
  1229. /* Goya/Gaudi:
  1230. * For external queue, this represents a Handle of CB on the
  1231. * Host.
  1232. * For internal queue in Goya, this represents an SRAM or
  1233. * a DRAM address of the internal CB. In Gaudi, this might also
  1234. * represent a mapped host address of the CB.
  1235. *
  1236. * Greco onwards:
  1237. * For H/W queue, this represents either a Handle of CB on the
  1238. * Host, or an SRAM, a DRAM, or a mapped host address of the CB.
  1239. *
  1240. * A mapped host address is in the device address space, after
  1241. * a host address was mapped by the device MMU.
  1242. */
  1243. __u64 cb_handle;
  1244. /* Relevant only when HL_CS_FLAGS_WAIT or
  1245. * HL_CS_FLAGS_COLLECTIVE_WAIT is set
  1246. * This holds address of array of u64 values that contain
  1247. * signal CS sequence numbers. The wait described by
  1248. * this job will listen on all those signals
  1249. * (wait event per signal)
  1250. */
  1251. __u64 signal_seq_arr;
  1252. /*
  1253. * Relevant only when HL_CS_FLAGS_WAIT or
  1254. * HL_CS_FLAGS_COLLECTIVE_WAIT is set
  1255. * along with HL_CS_FLAGS_ENCAP_SIGNALS.
  1256. * This is the CS sequence which has the encapsulated signals.
  1257. */
  1258. __u64 encaps_signal_seq;
  1259. };
  1260. /* Index of queue to put the CB on */
  1261. __u32 queue_index;
  1262. union {
  1263. /*
  1264. * Size of command buffer with valid packets
  1265. * Can be smaller then actual CB size
  1266. */
  1267. __u32 cb_size;
  1268. /* Relevant only when HL_CS_FLAGS_WAIT or
  1269. * HL_CS_FLAGS_COLLECTIVE_WAIT is set.
  1270. * Number of entries in signal_seq_arr
  1271. */
  1272. __u32 num_signal_seq_arr;
  1273. /* Relevant only when HL_CS_FLAGS_WAIT or
  1274. * HL_CS_FLAGS_COLLECTIVE_WAIT is set along
  1275. * with HL_CS_FLAGS_ENCAP_SIGNALS
  1276. * This set the signals range that the user want to wait for
  1277. * out of the whole reserved signals range.
  1278. * e.g if the signals range is 20, and user don't want
  1279. * to wait for signal 8, so he set this offset to 7, then
  1280. * he call the API again with 9 and so on till 20.
  1281. */
  1282. __u32 encaps_signal_offset;
  1283. };
  1284. /* HL_CS_CHUNK_FLAGS_* */
  1285. __u32 cs_chunk_flags;
  1286. /* Relevant only when HL_CS_FLAGS_COLLECTIVE_WAIT is set.
  1287. * This holds the collective engine ID. The wait described by this job
  1288. * will sync with this engine and with all NICs before completion.
  1289. */
  1290. __u32 collective_engine_id;
  1291. /* Align structure to 64 bytes */
  1292. __u32 pad[10];
  1293. };
  1294. /* SIGNAL/WAIT/COLLECTIVE_WAIT flags are mutually exclusive */
  1295. #define HL_CS_FLAGS_FORCE_RESTORE 0x1
  1296. #define HL_CS_FLAGS_SIGNAL 0x2
  1297. #define HL_CS_FLAGS_WAIT 0x4
  1298. #define HL_CS_FLAGS_COLLECTIVE_WAIT 0x8
  1299. #define HL_CS_FLAGS_TIMESTAMP 0x20
  1300. #define HL_CS_FLAGS_STAGED_SUBMISSION 0x40
  1301. #define HL_CS_FLAGS_STAGED_SUBMISSION_FIRST 0x80
  1302. #define HL_CS_FLAGS_STAGED_SUBMISSION_LAST 0x100
  1303. #define HL_CS_FLAGS_CUSTOM_TIMEOUT 0x200
  1304. #define HL_CS_FLAGS_SKIP_RESET_ON_TIMEOUT 0x400
  1305. /*
  1306. * The encapsulated signals CS is merged into the existing CS ioctls.
  1307. * In order to use this feature need to follow the below procedure:
  1308. * 1. Reserve signals, set the CS type to HL_CS_FLAGS_RESERVE_SIGNALS_ONLY
  1309. * the output of this API will be the SOB offset from CFG_BASE.
  1310. * this address will be used to patch CB cmds to do the signaling for this
  1311. * SOB by incrementing it's value.
  1312. * for reverting the reservation use HL_CS_FLAGS_UNRESERVE_SIGNALS_ONLY
  1313. * CS type, note that this might fail if out-of-sync happened to the SOB
  1314. * value, in case other signaling request to the same SOB occurred between
  1315. * reserve-unreserve calls.
  1316. * 2. Use the staged CS to do the encapsulated signaling jobs.
  1317. * use HL_CS_FLAGS_STAGED_SUBMISSION and HL_CS_FLAGS_STAGED_SUBMISSION_FIRST
  1318. * along with HL_CS_FLAGS_ENCAP_SIGNALS flag, and set encaps_signal_offset
  1319. * field. This offset allows app to wait on part of the reserved signals.
  1320. * 3. Use WAIT/COLLECTIVE WAIT CS along with HL_CS_FLAGS_ENCAP_SIGNALS flag
  1321. * to wait for the encapsulated signals.
  1322. */
  1323. #define HL_CS_FLAGS_ENCAP_SIGNALS 0x800
  1324. #define HL_CS_FLAGS_RESERVE_SIGNALS_ONLY 0x1000
  1325. #define HL_CS_FLAGS_UNRESERVE_SIGNALS_ONLY 0x2000
  1326. /*
  1327. * The engine cores CS is merged into the existing CS ioctls.
  1328. * Use it to control the engine cores mode.
  1329. */
  1330. #define HL_CS_FLAGS_ENGINE_CORE_COMMAND 0x4000
  1331. #define HL_CS_STATUS_SUCCESS 0
  1332. #define HL_MAX_JOBS_PER_CS 512
  1333. /* HL_ENGINE_CORE_ values
  1334. *
  1335. * HL_ENGINE_CORE_HALT: engine core halt
  1336. * HL_ENGINE_CORE_RUN: engine core run
  1337. */
  1338. #define HL_ENGINE_CORE_HALT (1 << 0)
  1339. #define HL_ENGINE_CORE_RUN (1 << 1)
  1340. struct hl_cs_in {
  1341. union {
  1342. struct {
  1343. /* this holds address of array of hl_cs_chunk for restore phase */
  1344. __u64 chunks_restore;
  1345. /* holds address of array of hl_cs_chunk for execution phase */
  1346. __u64 chunks_execute;
  1347. };
  1348. /* Valid only when HL_CS_FLAGS_ENGINE_CORE_COMMAND is set */
  1349. struct {
  1350. /* this holds address of array of uint32 for engine_cores */
  1351. __u64 engine_cores;
  1352. /* number of engine cores in engine_cores array */
  1353. __u32 num_engine_cores;
  1354. /* the core command to be sent towards engine cores */
  1355. __u32 core_command;
  1356. };
  1357. };
  1358. union {
  1359. /*
  1360. * Sequence number of a staged submission CS
  1361. * valid only if HL_CS_FLAGS_STAGED_SUBMISSION is set and
  1362. * HL_CS_FLAGS_STAGED_SUBMISSION_FIRST is unset.
  1363. */
  1364. __u64 seq;
  1365. /*
  1366. * Encapsulated signals handle id
  1367. * Valid for two flows:
  1368. * 1. CS with encapsulated signals:
  1369. * when HL_CS_FLAGS_STAGED_SUBMISSION and
  1370. * HL_CS_FLAGS_STAGED_SUBMISSION_FIRST
  1371. * and HL_CS_FLAGS_ENCAP_SIGNALS are set.
  1372. * 2. unreserve signals:
  1373. * valid when HL_CS_FLAGS_UNRESERVE_SIGNALS_ONLY is set.
  1374. */
  1375. __u32 encaps_sig_handle_id;
  1376. /* Valid only when HL_CS_FLAGS_RESERVE_SIGNALS_ONLY is set */
  1377. struct {
  1378. /* Encapsulated signals number */
  1379. __u32 encaps_signals_count;
  1380. /* Encapsulated signals queue index (stream) */
  1381. __u32 encaps_signals_q_idx;
  1382. };
  1383. };
  1384. /* Number of chunks in restore phase array. Maximum number is
  1385. * HL_MAX_JOBS_PER_CS
  1386. */
  1387. __u32 num_chunks_restore;
  1388. /* Number of chunks in execution array. Maximum number is
  1389. * HL_MAX_JOBS_PER_CS
  1390. */
  1391. __u32 num_chunks_execute;
  1392. /* timeout in seconds - valid only if HL_CS_FLAGS_CUSTOM_TIMEOUT
  1393. * is set
  1394. */
  1395. __u32 timeout;
  1396. /* HL_CS_FLAGS_* */
  1397. __u32 cs_flags;
  1398. /* Context ID - Currently not in use */
  1399. __u32 ctx_id;
  1400. __u8 pad[4];
  1401. };
  1402. struct hl_cs_out {
  1403. union {
  1404. /*
  1405. * seq holds the sequence number of the CS to pass to wait
  1406. * ioctl. All values are valid except for 0 and ULLONG_MAX
  1407. */
  1408. __u64 seq;
  1409. /* Valid only when HL_CS_FLAGS_RESERVE_SIGNALS_ONLY is set */
  1410. struct {
  1411. /* This is the reserved signal handle id */
  1412. __u32 handle_id;
  1413. /* This is the signals count */
  1414. __u32 count;
  1415. };
  1416. };
  1417. /* HL_CS_STATUS */
  1418. __u32 status;
  1419. /*
  1420. * SOB base address offset
  1421. * Valid only when HL_CS_FLAGS_RESERVE_SIGNALS_ONLY or HL_CS_FLAGS_SIGNAL is set
  1422. */
  1423. __u32 sob_base_addr_offset;
  1424. /*
  1425. * Count of completed signals in SOB before current signal submission.
  1426. * Valid only when (HL_CS_FLAGS_ENCAP_SIGNALS & HL_CS_FLAGS_STAGED_SUBMISSION)
  1427. * or HL_CS_FLAGS_SIGNAL is set
  1428. */
  1429. __u16 sob_count_before_submission;
  1430. __u16 pad[3];
  1431. };
  1432. union hl_cs_args {
  1433. struct hl_cs_in in;
  1434. struct hl_cs_out out;
  1435. };
  1436. #define HL_WAIT_CS_FLAGS_INTERRUPT 0x2
  1437. #define HL_WAIT_CS_FLAGS_INTERRUPT_MASK 0xFFF00000
  1438. #define HL_WAIT_CS_FLAGS_ANY_CQ_INTERRUPT 0xFFF00000
  1439. #define HL_WAIT_CS_FLAGS_ANY_DEC_INTERRUPT 0xFFE00000
  1440. #define HL_WAIT_CS_FLAGS_MULTI_CS 0x4
  1441. #define HL_WAIT_CS_FLAGS_INTERRUPT_KERNEL_CQ 0x10
  1442. #define HL_WAIT_CS_FLAGS_REGISTER_INTERRUPT 0x20
  1443. #define HL_WAIT_MULTI_CS_LIST_MAX_LEN 32
  1444. struct hl_wait_cs_in {
  1445. union {
  1446. struct {
  1447. /*
  1448. * In case of wait_cs holds the CS sequence number.
  1449. * In case of wait for multi CS hold a user pointer to
  1450. * an array of CS sequence numbers
  1451. */
  1452. __u64 seq;
  1453. /* Absolute timeout to wait for command submission
  1454. * in microseconds
  1455. */
  1456. __u64 timeout_us;
  1457. };
  1458. struct {
  1459. union {
  1460. /* User address for completion comparison.
  1461. * upon interrupt, driver will compare the value pointed
  1462. * by this address with the supplied target value.
  1463. * in order not to perform any comparison, set address
  1464. * to all 1s.
  1465. * Relevant only when HL_WAIT_CS_FLAGS_INTERRUPT is set
  1466. */
  1467. __u64 addr;
  1468. /* cq_counters_handle to a kernel mapped cb which contains
  1469. * cq counters.
  1470. * Relevant only when HL_WAIT_CS_FLAGS_INTERRUPT_KERNEL_CQ is set
  1471. */
  1472. __u64 cq_counters_handle;
  1473. };
  1474. /* Target value for completion comparison */
  1475. __u64 target;
  1476. };
  1477. };
  1478. /* Context ID - Currently not in use */
  1479. __u32 ctx_id;
  1480. /* HL_WAIT_CS_FLAGS_*
  1481. * If HL_WAIT_CS_FLAGS_INTERRUPT is set, this field should include
  1482. * interrupt id according to HL_WAIT_CS_FLAGS_INTERRUPT_MASK
  1483. *
  1484. * in order to wait for any CQ interrupt, set interrupt value to
  1485. * HL_WAIT_CS_FLAGS_ANY_CQ_INTERRUPT.
  1486. *
  1487. * in order to wait for any decoder interrupt, set interrupt value to
  1488. * HL_WAIT_CS_FLAGS_ANY_DEC_INTERRUPT.
  1489. */
  1490. __u32 flags;
  1491. union {
  1492. struct {
  1493. /* Multi CS API info- valid entries in multi-CS array */
  1494. __u8 seq_arr_len;
  1495. __u8 pad[7];
  1496. };
  1497. /* Absolute timeout to wait for an interrupt in microseconds.
  1498. * Relevant only when HL_WAIT_CS_FLAGS_INTERRUPT is set
  1499. */
  1500. __u64 interrupt_timeout_us;
  1501. };
  1502. /*
  1503. * cq counter offset inside the counters cb pointed by cq_counters_handle above.
  1504. * upon interrupt, driver will compare the value pointed
  1505. * by this address (cq_counters_handle + cq_counters_offset)
  1506. * with the supplied target value.
  1507. * relevant only when HL_WAIT_CS_FLAGS_INTERRUPT_KERNEL_CQ is set
  1508. */
  1509. __u64 cq_counters_offset;
  1510. /*
  1511. * Timestamp_handle timestamps buffer handle.
  1512. * relevant only when HL_WAIT_CS_FLAGS_REGISTER_INTERRUPT is set
  1513. */
  1514. __u64 timestamp_handle;
  1515. /*
  1516. * Timestamp_offset is offset inside the timestamp buffer pointed by timestamp_handle above.
  1517. * upon interrupt, if the cq reached the target value then driver will write
  1518. * timestamp to this offset.
  1519. * relevant only when HL_WAIT_CS_FLAGS_REGISTER_INTERRUPT is set
  1520. */
  1521. __u64 timestamp_offset;
  1522. };
  1523. #define HL_WAIT_CS_STATUS_COMPLETED 0
  1524. #define HL_WAIT_CS_STATUS_BUSY 1
  1525. #define HL_WAIT_CS_STATUS_TIMEDOUT 2
  1526. #define HL_WAIT_CS_STATUS_ABORTED 3
  1527. #define HL_WAIT_CS_STATUS_FLAG_GONE 0x1
  1528. #define HL_WAIT_CS_STATUS_FLAG_TIMESTAMP_VLD 0x2
  1529. struct hl_wait_cs_out {
  1530. /* HL_WAIT_CS_STATUS_* */
  1531. __u32 status;
  1532. /* HL_WAIT_CS_STATUS_FLAG* */
  1533. __u32 flags;
  1534. /*
  1535. * valid only if HL_WAIT_CS_STATUS_FLAG_TIMESTAMP_VLD is set
  1536. * for wait_cs: timestamp of CS completion
  1537. * for wait_multi_cs: timestamp of FIRST CS completion
  1538. */
  1539. __s64 timestamp_nsec;
  1540. /* multi CS completion bitmap */
  1541. __u32 cs_completion_map;
  1542. __u32 pad;
  1543. };
  1544. union hl_wait_cs_args {
  1545. struct hl_wait_cs_in in;
  1546. struct hl_wait_cs_out out;
  1547. };
  1548. /* Opcode to allocate device memory */
  1549. #define HL_MEM_OP_ALLOC 0
  1550. /* Opcode to free previously allocated device memory */
  1551. #define HL_MEM_OP_FREE 1
  1552. /* Opcode to map host and device memory */
  1553. #define HL_MEM_OP_MAP 2
  1554. /* Opcode to unmap previously mapped host and device memory */
  1555. #define HL_MEM_OP_UNMAP 3
  1556. /* Opcode to map a hw block */
  1557. #define HL_MEM_OP_MAP_BLOCK 4
  1558. /* Opcode to create DMA-BUF object for an existing device memory allocation
  1559. * and to export an FD of that DMA-BUF back to the caller
  1560. */
  1561. #define HL_MEM_OP_EXPORT_DMABUF_FD 5
  1562. /* Opcode to create timestamps pool for user interrupts registration support
  1563. * The memory will be allocated by the kernel driver, A timestamp buffer which the user
  1564. * will get handle to it for mmap, and another internal buffer used by the
  1565. * driver for registration management
  1566. * The memory will be freed when the user closes the file descriptor(ctx close)
  1567. */
  1568. #define HL_MEM_OP_TS_ALLOC 6
  1569. /* Memory flags */
  1570. #define HL_MEM_CONTIGUOUS 0x1
  1571. #define HL_MEM_SHARED 0x2
  1572. #define HL_MEM_USERPTR 0x4
  1573. #define HL_MEM_FORCE_HINT 0x8
  1574. #define HL_MEM_PREFETCH 0x40
  1575. /**
  1576. * structure hl_mem_in - structure that handle input args for memory IOCTL
  1577. * @union arg: union of structures to be used based on the input operation
  1578. * @op: specify the requested memory operation (one of the HL_MEM_OP_* definitions).
  1579. * @flags: flags for the memory operation (one of the HL_MEM_* definitions).
  1580. * For the HL_MEM_OP_EXPORT_DMABUF_FD opcode, this field holds the DMA-BUF file/FD flags.
  1581. * @ctx_id: context ID - currently not in use.
  1582. * @num_of_elements: number of timestamp elements used only with HL_MEM_OP_TS_ALLOC opcode.
  1583. */
  1584. struct hl_mem_in {
  1585. union {
  1586. /**
  1587. * structure for device memory allocation (used with the HL_MEM_OP_ALLOC op)
  1588. * @mem_size: memory size to allocate
  1589. * @page_size: page size to use on allocation. when the value is 0 the default page
  1590. * size will be taken.
  1591. */
  1592. struct {
  1593. __u64 mem_size;
  1594. __u64 page_size;
  1595. } alloc;
  1596. /**
  1597. * structure for free-ing device memory (used with the HL_MEM_OP_FREE op)
  1598. * @handle: handle returned from HL_MEM_OP_ALLOC
  1599. */
  1600. struct {
  1601. __u64 handle;
  1602. } free;
  1603. /**
  1604. * structure for mapping device memory (used with the HL_MEM_OP_MAP op)
  1605. * @hint_addr: requested virtual address of mapped memory.
  1606. * the driver will try to map the requested region to this hint
  1607. * address, as long as the address is valid and not already mapped.
  1608. * the user should check the returned address of the IOCTL to make
  1609. * sure he got the hint address.
  1610. * passing 0 here means that the driver will choose the address itself.
  1611. * @handle: handle returned from HL_MEM_OP_ALLOC.
  1612. */
  1613. struct {
  1614. __u64 hint_addr;
  1615. __u64 handle;
  1616. } map_device;
  1617. /**
  1618. * structure for mapping host memory (used with the HL_MEM_OP_MAP op)
  1619. * @host_virt_addr: address of allocated host memory.
  1620. * @hint_addr: requested virtual address of mapped memory.
  1621. * the driver will try to map the requested region to this hint
  1622. * address, as long as the address is valid and not already mapped.
  1623. * the user should check the returned address of the IOCTL to make
  1624. * sure he got the hint address.
  1625. * passing 0 here means that the driver will choose the address itself.
  1626. * @size: size of allocated host memory.
  1627. */
  1628. struct {
  1629. __u64 host_virt_addr;
  1630. __u64 hint_addr;
  1631. __u64 mem_size;
  1632. } map_host;
  1633. /**
  1634. * structure for mapping hw block (used with the HL_MEM_OP_MAP_BLOCK op)
  1635. * @block_addr:HW block address to map, a handle and size will be returned
  1636. * to the user and will be used to mmap the relevant block.
  1637. * only addresses from configuration space are allowed.
  1638. */
  1639. struct {
  1640. __u64 block_addr;
  1641. } map_block;
  1642. /**
  1643. * structure for unmapping host memory (used with the HL_MEM_OP_UNMAP op)
  1644. * @device_virt_addr: virtual address returned from HL_MEM_OP_MAP
  1645. */
  1646. struct {
  1647. __u64 device_virt_addr;
  1648. } unmap;
  1649. /**
  1650. * structure for exporting DMABUF object (used with
  1651. * the HL_MEM_OP_EXPORT_DMABUF_FD op)
  1652. * @handle: handle returned from HL_MEM_OP_ALLOC.
  1653. * in Gaudi, where we don't have MMU for the device memory, the
  1654. * driver expects a physical address (instead of a handle) in the
  1655. * device memory space.
  1656. * @mem_size: size of memory allocation. Relevant only for GAUDI
  1657. */
  1658. struct {
  1659. __u64 handle;
  1660. __u64 mem_size;
  1661. } export_dmabuf_fd;
  1662. };
  1663. __u32 op;
  1664. __u32 flags;
  1665. __u32 ctx_id;
  1666. __u32 num_of_elements;
  1667. };
  1668. struct hl_mem_out {
  1669. union {
  1670. /*
  1671. * Used for HL_MEM_OP_MAP as the virtual address that was
  1672. * assigned in the device VA space.
  1673. * A value of 0 means the requested operation failed.
  1674. */
  1675. __u64 device_virt_addr;
  1676. /*
  1677. * Used in HL_MEM_OP_ALLOC
  1678. * This is the assigned handle for the allocated memory
  1679. */
  1680. __u64 handle;
  1681. struct {
  1682. /*
  1683. * Used in HL_MEM_OP_MAP_BLOCK.
  1684. * This is the assigned handle for the mapped block
  1685. */
  1686. __u64 block_handle;
  1687. /*
  1688. * Used in HL_MEM_OP_MAP_BLOCK
  1689. * This is the size of the mapped block
  1690. */
  1691. __u32 block_size;
  1692. __u32 pad;
  1693. };
  1694. /* Returned in HL_MEM_OP_EXPORT_DMABUF_FD. Represents the
  1695. * DMA-BUF object that was created to describe a memory
  1696. * allocation on the device's memory space. The FD should be
  1697. * passed to the importer driver
  1698. */
  1699. __s32 fd;
  1700. };
  1701. };
  1702. union hl_mem_args {
  1703. struct hl_mem_in in;
  1704. struct hl_mem_out out;
  1705. };
  1706. #define HL_DEBUG_MAX_AUX_VALUES 10
  1707. struct hl_debug_params_etr {
  1708. /* Address in memory to allocate buffer */
  1709. __u64 buffer_address;
  1710. /* Size of buffer to allocate */
  1711. __u64 buffer_size;
  1712. /* Sink operation mode: SW fifo, HW fifo, Circular buffer */
  1713. __u32 sink_mode;
  1714. __u32 pad;
  1715. };
  1716. struct hl_debug_params_etf {
  1717. /* Address in memory to allocate buffer */
  1718. __u64 buffer_address;
  1719. /* Size of buffer to allocate */
  1720. __u64 buffer_size;
  1721. /* Sink operation mode: SW fifo, HW fifo, Circular buffer */
  1722. __u32 sink_mode;
  1723. __u32 pad;
  1724. };
  1725. struct hl_debug_params_stm {
  1726. /* Two bit masks for HW event and Stimulus Port */
  1727. __u64 he_mask;
  1728. __u64 sp_mask;
  1729. /* Trace source ID */
  1730. __u32 id;
  1731. /* Frequency for the timestamp register */
  1732. __u32 frequency;
  1733. };
  1734. struct hl_debug_params_bmon {
  1735. /* Two address ranges that the user can request to filter */
  1736. __u64 start_addr0;
  1737. __u64 addr_mask0;
  1738. __u64 start_addr1;
  1739. __u64 addr_mask1;
  1740. /* Capture window configuration */
  1741. __u32 bw_win;
  1742. __u32 win_capture;
  1743. /* Trace source ID */
  1744. __u32 id;
  1745. /* Control register */
  1746. __u32 control;
  1747. /* Two more address ranges that the user can request to filter */
  1748. __u64 start_addr2;
  1749. __u64 end_addr2;
  1750. __u64 start_addr3;
  1751. __u64 end_addr3;
  1752. };
  1753. struct hl_debug_params_spmu {
  1754. /* Event types selection */
  1755. __u64 event_types[HL_DEBUG_MAX_AUX_VALUES];
  1756. /* Number of event types selection */
  1757. __u32 event_types_num;
  1758. /* TRC configuration register values */
  1759. __u32 pmtrc_val;
  1760. __u32 trc_ctrl_host_val;
  1761. __u32 trc_en_host_val;
  1762. };
  1763. /* Opcode for ETR component */
  1764. #define HL_DEBUG_OP_ETR 0
  1765. /* Opcode for ETF component */
  1766. #define HL_DEBUG_OP_ETF 1
  1767. /* Opcode for STM component */
  1768. #define HL_DEBUG_OP_STM 2
  1769. /* Opcode for FUNNEL component */
  1770. #define HL_DEBUG_OP_FUNNEL 3
  1771. /* Opcode for BMON component */
  1772. #define HL_DEBUG_OP_BMON 4
  1773. /* Opcode for SPMU component */
  1774. #define HL_DEBUG_OP_SPMU 5
  1775. /* Opcode for timestamp (deprecated) */
  1776. #define HL_DEBUG_OP_TIMESTAMP 6
  1777. /* Opcode for setting the device into or out of debug mode. The enable
  1778. * variable should be 1 for enabling debug mode and 0 for disabling it
  1779. */
  1780. #define HL_DEBUG_OP_SET_MODE 7
  1781. struct hl_debug_args {
  1782. /*
  1783. * Pointer to user input structure.
  1784. * This field is relevant to specific opcodes.
  1785. */
  1786. __u64 input_ptr;
  1787. /* Pointer to user output structure */
  1788. __u64 output_ptr;
  1789. /* Size of user input structure */
  1790. __u32 input_size;
  1791. /* Size of user output structure */
  1792. __u32 output_size;
  1793. /* HL_DEBUG_OP_* */
  1794. __u32 op;
  1795. /*
  1796. * Register index in the component, taken from the debug_regs_index enum
  1797. * in the various ASIC header files
  1798. */
  1799. __u32 reg_idx;
  1800. /* Enable/disable */
  1801. __u32 enable;
  1802. /* Context ID - Currently not in use */
  1803. __u32 ctx_id;
  1804. };
  1805. /*
  1806. * Various information operations such as:
  1807. * - H/W IP information
  1808. * - Current dram usage
  1809. *
  1810. * The user calls this IOCTL with an opcode that describes the required
  1811. * information. The user should supply a pointer to a user-allocated memory
  1812. * chunk, which will be filled by the driver with the requested information.
  1813. *
  1814. * The user supplies the maximum amount of size to copy into the user's memory,
  1815. * in order to prevent data corruption in case of differences between the
  1816. * definitions of structures in kernel and userspace, e.g. in case of old
  1817. * userspace and new kernel driver
  1818. */
  1819. #define HL_IOCTL_INFO \
  1820. _IOWR('H', 0x01, struct hl_info_args)
  1821. /*
  1822. * Command Buffer
  1823. * - Request a Command Buffer
  1824. * - Destroy a Command Buffer
  1825. *
  1826. * The command buffers are memory blocks that reside in DMA-able address
  1827. * space and are physically contiguous so they can be accessed by the device
  1828. * directly. They are allocated using the coherent DMA API.
  1829. *
  1830. * When creating a new CB, the IOCTL returns a handle of it, and the user-space
  1831. * process needs to use that handle to mmap the buffer so it can access them.
  1832. *
  1833. * In some instances, the device must access the command buffer through the
  1834. * device's MMU, and thus its memory should be mapped. In these cases, user can
  1835. * indicate the driver that such a mapping is required.
  1836. * The resulting device virtual address will be used internally by the driver,
  1837. * and won't be returned to user.
  1838. *
  1839. */
  1840. #define HL_IOCTL_CB \
  1841. _IOWR('H', 0x02, union hl_cb_args)
  1842. /*
  1843. * Command Submission
  1844. *
  1845. * To submit work to the device, the user need to call this IOCTL with a set
  1846. * of JOBS. That set of JOBS constitutes a CS object.
  1847. * Each JOB will be enqueued on a specific queue, according to the user's input.
  1848. * There can be more then one JOB per queue.
  1849. *
  1850. * The CS IOCTL will receive two sets of JOBS. One set is for "restore" phase
  1851. * and a second set is for "execution" phase.
  1852. * The JOBS on the "restore" phase are enqueued only after context-switch
  1853. * (or if its the first CS for this context). The user can also order the
  1854. * driver to run the "restore" phase explicitly
  1855. *
  1856. * Goya/Gaudi:
  1857. * There are two types of queues - external and internal. External queues
  1858. * are DMA queues which transfer data from/to the Host. All other queues are
  1859. * internal. The driver will get completion notifications from the device only
  1860. * on JOBS which are enqueued in the external queues.
  1861. *
  1862. * Greco onwards:
  1863. * There is a single type of queue for all types of engines, either DMA engines
  1864. * for transfers from/to the host or inside the device, or compute engines.
  1865. * The driver will get completion notifications from the device for all queues.
  1866. *
  1867. * For jobs on external queues, the user needs to create command buffers
  1868. * through the CB ioctl and give the CB's handle to the CS ioctl. For jobs on
  1869. * internal queues, the user needs to prepare a "command buffer" with packets
  1870. * on either the device SRAM/DRAM or the host, and give the device address of
  1871. * that buffer to the CS ioctl.
  1872. * For jobs on H/W queues both options of command buffers are valid.
  1873. *
  1874. * This IOCTL is asynchronous in regard to the actual execution of the CS. This
  1875. * means it returns immediately after ALL the JOBS were enqueued on their
  1876. * relevant queues. Therefore, the user mustn't assume the CS has been completed
  1877. * or has even started to execute.
  1878. *
  1879. * Upon successful enqueue, the IOCTL returns a sequence number which the user
  1880. * can use with the "Wait for CS" IOCTL to check whether the handle's CS
  1881. * non-internal JOBS have been completed. Note that if the CS has internal JOBS
  1882. * which can execute AFTER the external JOBS have finished, the driver might
  1883. * report that the CS has finished executing BEFORE the internal JOBS have
  1884. * actually finished executing.
  1885. *
  1886. * Even though the sequence number increments per CS, the user can NOT
  1887. * automatically assume that if CS with sequence number N finished, then CS
  1888. * with sequence number N-1 also finished. The user can make this assumption if
  1889. * and only if CS N and CS N-1 are exactly the same (same CBs for the same
  1890. * queues).
  1891. */
  1892. #define HL_IOCTL_CS \
  1893. _IOWR('H', 0x03, union hl_cs_args)
  1894. /*
  1895. * Wait for Command Submission
  1896. *
  1897. * The user can call this IOCTL with a handle it received from the CS IOCTL
  1898. * to wait until the handle's CS has finished executing. The user will wait
  1899. * inside the kernel until the CS has finished or until the user-requested
  1900. * timeout has expired.
  1901. *
  1902. * If the timeout value is 0, the driver won't sleep at all. It will check
  1903. * the status of the CS and return immediately
  1904. *
  1905. * The return value of the IOCTL is a standard Linux error code. The possible
  1906. * values are:
  1907. *
  1908. * EINTR - Kernel waiting has been interrupted, e.g. due to OS signal
  1909. * that the user process received
  1910. * ETIMEDOUT - The CS has caused a timeout on the device
  1911. * EIO - The CS was aborted (usually because the device was reset)
  1912. * ENODEV - The device wants to do hard-reset (so user need to close FD)
  1913. *
  1914. * The driver also returns a custom define in case the IOCTL call returned 0.
  1915. * The define can be one of the following:
  1916. *
  1917. * HL_WAIT_CS_STATUS_COMPLETED - The CS has been completed successfully (0)
  1918. * HL_WAIT_CS_STATUS_BUSY - The CS is still executing (0)
  1919. * HL_WAIT_CS_STATUS_TIMEDOUT - The CS has caused a timeout on the device
  1920. * (ETIMEDOUT)
  1921. * HL_WAIT_CS_STATUS_ABORTED - The CS was aborted, usually because the
  1922. * device was reset (EIO)
  1923. */
  1924. #define HL_IOCTL_WAIT_CS \
  1925. _IOWR('H', 0x04, union hl_wait_cs_args)
  1926. /*
  1927. * Memory
  1928. * - Map host memory to device MMU
  1929. * - Unmap host memory from device MMU
  1930. *
  1931. * This IOCTL allows the user to map host memory to the device MMU
  1932. *
  1933. * For host memory, the IOCTL doesn't allocate memory. The user is supposed
  1934. * to allocate the memory in user-space (malloc/new). The driver pins the
  1935. * physical pages (up to the allowed limit by the OS), assigns a virtual
  1936. * address in the device VA space and initializes the device MMU.
  1937. *
  1938. * There is an option for the user to specify the requested virtual address.
  1939. *
  1940. */
  1941. #define HL_IOCTL_MEMORY \
  1942. _IOWR('H', 0x05, union hl_mem_args)
  1943. /*
  1944. * Debug
  1945. * - Enable/disable the ETR/ETF/FUNNEL/STM/BMON/SPMU debug traces
  1946. *
  1947. * This IOCTL allows the user to get debug traces from the chip.
  1948. *
  1949. * Before the user can send configuration requests of the various
  1950. * debug/profile engines, it needs to set the device into debug mode.
  1951. * This is because the debug/profile infrastructure is shared component in the
  1952. * device and we can't allow multiple users to access it at the same time.
  1953. *
  1954. * Once a user set the device into debug mode, the driver won't allow other
  1955. * users to "work" with the device, i.e. open a FD. If there are multiple users
  1956. * opened on the device, the driver won't allow any user to debug the device.
  1957. *
  1958. * For each configuration request, the user needs to provide the register index
  1959. * and essential data such as buffer address and size.
  1960. *
  1961. * Once the user has finished using the debug/profile engines, he should
  1962. * set the device into non-debug mode, i.e. disable debug mode.
  1963. *
  1964. * The driver can decide to "kick out" the user if he abuses this interface.
  1965. *
  1966. */
  1967. #define HL_IOCTL_DEBUG \
  1968. _IOWR('H', 0x06, struct hl_debug_args)
  1969. #define HL_COMMAND_START 0x01
  1970. #define HL_COMMAND_END 0x07
  1971. #endif /* HABANALABS_H_ */