vpu_jsm_api.h 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307
  1. /* SPDX-License-Identifier: MIT */
  2. /*
  3. * Copyright (c) 2020-2024, Intel Corporation.
  4. */
  5. /**
  6. * @file
  7. * @brief JSM shared definitions
  8. *
  9. * @ingroup Jsm
  10. * @brief JSM shared definitions
  11. * @{
  12. */
  13. #ifndef VPU_JSM_API_H
  14. #define VPU_JSM_API_H
  15. /*
  16. * Major version changes that break backward compatibility
  17. */
  18. #define VPU_JSM_API_VER_MAJOR 3
  19. /*
  20. * Minor version changes when API backward compatibility is preserved.
  21. */
  22. #define VPU_JSM_API_VER_MINOR 16
  23. /*
  24. * API header changed (field names, documentation, formatting) but API itself has not been changed
  25. */
  26. #define VPU_JSM_API_VER_PATCH 0
  27. /*
  28. * Index in the API version table
  29. */
  30. #define VPU_JSM_API_VER_INDEX 4
  31. /*
  32. * Number of Priority Bands for Hardware Scheduling
  33. * Bands: RealTime, Focus, Normal, Idle
  34. */
  35. #define VPU_HWS_NUM_PRIORITY_BANDS 4
  36. /* Max number of impacted contexts that can be dealt with the engine reset command */
  37. #define VPU_MAX_ENGINE_RESET_IMPACTED_CONTEXTS 3
  38. /*
  39. * Pack the API structures to enforce binary compatibility
  40. * Align to 8 bytes for optimal performance
  41. */
  42. #pragma pack(push, 8)
  43. /*
  44. * Engine indexes.
  45. */
  46. #define VPU_ENGINE_COMPUTE 0
  47. #define VPU_ENGINE_COPY 1
  48. #define VPU_ENGINE_NB 2
  49. /*
  50. * VPU status values.
  51. */
  52. #define VPU_JSM_STATUS_SUCCESS 0x0U
  53. #define VPU_JSM_STATUS_PARSING_ERR 0x1U
  54. #define VPU_JSM_STATUS_PROCESSING_ERR 0x2U
  55. #define VPU_JSM_STATUS_PREEMPTED 0x3U
  56. #define VPU_JSM_STATUS_ABORTED 0x4U
  57. #define VPU_JSM_STATUS_USER_CTX_VIOL_ERR 0x5U
  58. #define VPU_JSM_STATUS_GLOBAL_CTX_VIOL_ERR 0x6U
  59. #define VPU_JSM_STATUS_MVNCI_WRONG_INPUT_FORMAT 0x7U
  60. #define VPU_JSM_STATUS_MVNCI_UNSUPPORTED_NETWORK_ELEMENT 0x8U
  61. #define VPU_JSM_STATUS_MVNCI_INVALID_HANDLE 0x9U
  62. #define VPU_JSM_STATUS_MVNCI_OUT_OF_RESOURCES 0xAU
  63. #define VPU_JSM_STATUS_MVNCI_NOT_IMPLEMENTED 0xBU
  64. #define VPU_JSM_STATUS_MVNCI_INTERNAL_ERROR 0xCU
  65. /* Job status returned when the job was preempted mid-inference */
  66. #define VPU_JSM_STATUS_PREEMPTED_MID_INFERENCE 0xDU
  67. /*
  68. * Host <-> VPU IPC channels.
  69. * ASYNC commands use a high priority channel, other messages use low-priority ones.
  70. */
  71. #define VPU_IPC_CHAN_ASYNC_CMD 0
  72. #define VPU_IPC_CHAN_GEN_CMD 10
  73. #define VPU_IPC_CHAN_JOB_RET 11
  74. /*
  75. * Job flags bit masks.
  76. */
  77. #define VPU_JOB_FLAGS_NULL_SUBMISSION_MASK 0x00000001
  78. #define VPU_JOB_FLAGS_PRIVATE_DATA_MASK 0xFF000000
  79. /*
  80. * Sizes of the reserved areas in jobs, in bytes.
  81. */
  82. #define VPU_JOB_RESERVED_BYTES 8
  83. /*
  84. * Sizes of the reserved areas in job queues, in bytes.
  85. */
  86. #define VPU_JOB_QUEUE_RESERVED_BYTES 52
  87. /*
  88. * Max length (including trailing NULL char) of trace entity name (e.g., the
  89. * name of a logging destination or a loggable HW component).
  90. */
  91. #define VPU_TRACE_ENTITY_NAME_MAX_LEN 32
  92. /*
  93. * Max length (including trailing NULL char) of a dyndbg command.
  94. *
  95. * NOTE: 96 is used so that the size of 'struct vpu_ipc_msg' in the JSM API is
  96. * 128 bytes (multiple of 64 bytes, the cache line size).
  97. */
  98. #define VPU_DYNDBG_CMD_MAX_LEN 96
  99. /*
  100. * For HWS command queue scheduling, we can prioritise command queues inside the
  101. * same process with a relative in-process priority. Valid values for relative
  102. * priority are given below - max and min.
  103. */
  104. #define VPU_HWS_COMMAND_QUEUE_MAX_IN_PROCESS_PRIORITY 7
  105. #define VPU_HWS_COMMAND_QUEUE_MIN_IN_PROCESS_PRIORITY -7
  106. /*
  107. * For HWS priority scheduling, we can have multiple realtime priority bands.
  108. * They are numbered 0 to a MAX.
  109. */
  110. #define VPU_HWS_MAX_REALTIME_PRIORITY_LEVEL 31U
  111. /*
  112. * vpu_jsm_engine_reset_context flag definitions
  113. */
  114. #define VPU_ENGINE_RESET_CONTEXT_FLAG_COLLATERAL_DAMAGE_MASK BIT(0)
  115. #define VPU_ENGINE_RESET_CONTEXT_HANG_PRIMARY_CAUSE 0
  116. #define VPU_ENGINE_RESET_CONTEXT_COLLATERAL_DAMAGE 1
  117. /*
  118. * Invalid command queue handle identifier. Applies to cmdq_id and cmdq_group
  119. * in this API.
  120. */
  121. #define VPU_HWS_INVALID_CMDQ_HANDLE 0ULL
  122. /*
  123. * Job format.
  124. */
  125. struct vpu_job_queue_entry {
  126. u64 batch_buf_addr; /**< Address of VPU commands batch buffer */
  127. u32 job_id; /**< Job ID */
  128. u32 flags; /**< Flags bit field, see VPU_JOB_FLAGS_* above */
  129. u64 root_page_table_addr; /**< Address of root page table to use for this job */
  130. u64 root_page_table_update_counter; /**< Page tables update events counter */
  131. u64 primary_preempt_buf_addr;
  132. /**< Address of the primary preemption buffer to use for this job */
  133. u32 primary_preempt_buf_size;
  134. /**< Size of the primary preemption buffer to use for this job */
  135. u32 secondary_preempt_buf_size;
  136. /**< Size of secondary preemption buffer to use for this job */
  137. u64 secondary_preempt_buf_addr;
  138. /**< Address of secondary preemption buffer to use for this job */
  139. u8 reserved_0[VPU_JOB_RESERVED_BYTES];
  140. };
  141. /*
  142. * Job queue control registers.
  143. */
  144. struct vpu_job_queue_header {
  145. u32 engine_idx;
  146. u32 head;
  147. u32 tail;
  148. u8 reserved_0[VPU_JOB_QUEUE_RESERVED_BYTES];
  149. };
  150. /*
  151. * Job queue format.
  152. */
  153. struct vpu_job_queue {
  154. struct vpu_job_queue_header header;
  155. struct vpu_job_queue_entry job[];
  156. };
  157. /**
  158. * Logging entity types.
  159. *
  160. * This enum defines the different types of entities involved in logging.
  161. */
  162. enum vpu_trace_entity_type {
  163. /** Logging destination (entity where logs can be stored / printed). */
  164. VPU_TRACE_ENTITY_TYPE_DESTINATION = 1,
  165. /** Loggable HW component (HW entity that can be logged). */
  166. VPU_TRACE_ENTITY_TYPE_HW_COMPONENT = 2,
  167. };
  168. /*
  169. * HWS specific log buffer header details.
  170. * Total size is 32 bytes.
  171. */
  172. struct vpu_hws_log_buffer_header {
  173. /* Written by VPU after adding a log entry. Initialised by host to 0. */
  174. u32 first_free_entry_index;
  175. /* Incremented by VPU every time the VPU overwrites the 0th entry;
  176. * initialised by host to 0.
  177. */
  178. u32 wraparound_count;
  179. /*
  180. * This is the number of buffers that can be stored in the log buffer provided by the host.
  181. * It is written by host before passing buffer to VPU. VPU should consider it read-only.
  182. */
  183. u64 num_of_entries;
  184. u64 reserved[2];
  185. };
  186. /*
  187. * HWS specific log buffer entry details.
  188. * Total size is 32 bytes.
  189. */
  190. struct vpu_hws_log_buffer_entry {
  191. /* VPU timestamp must be an invariant timer tick (not impacted by DVFS) */
  192. u64 vpu_timestamp;
  193. /*
  194. * Operation type:
  195. * 0 - context state change
  196. * 1 - queue new work
  197. * 2 - queue unwait sync object
  198. * 3 - queue no more work
  199. * 4 - queue wait sync object
  200. */
  201. u32 operation_type;
  202. u32 reserved;
  203. /* Operation data depends on operation type */
  204. u64 operation_data[2];
  205. };
  206. /*
  207. * Host <-> VPU IPC messages types.
  208. */
  209. enum vpu_ipc_msg_type {
  210. VPU_JSM_MSG_UNKNOWN = 0xFFFFFFFF,
  211. /* IPC Host -> Device, Async commands */
  212. VPU_JSM_MSG_ASYNC_CMD = 0x1100,
  213. VPU_JSM_MSG_ENGINE_RESET = VPU_JSM_MSG_ASYNC_CMD,
  214. VPU_JSM_MSG_ENGINE_PREEMPT = 0x1101,
  215. VPU_JSM_MSG_REGISTER_DB = 0x1102,
  216. VPU_JSM_MSG_UNREGISTER_DB = 0x1103,
  217. VPU_JSM_MSG_QUERY_ENGINE_HB = 0x1104,
  218. VPU_JSM_MSG_GET_POWER_LEVEL_COUNT = 0x1105,
  219. VPU_JSM_MSG_GET_POWER_LEVEL = 0x1106,
  220. VPU_JSM_MSG_SET_POWER_LEVEL = 0x1107,
  221. /* @deprecated */
  222. VPU_JSM_MSG_METRIC_STREAMER_OPEN = 0x1108,
  223. /* @deprecated */
  224. VPU_JSM_MSG_METRIC_STREAMER_CLOSE = 0x1109,
  225. /** Configure logging (used to modify configuration passed in boot params). */
  226. VPU_JSM_MSG_TRACE_SET_CONFIG = 0x110a,
  227. /** Return current logging configuration. */
  228. VPU_JSM_MSG_TRACE_GET_CONFIG = 0x110b,
  229. /**
  230. * Get masks of destinations and HW components supported by the firmware
  231. * (may vary between HW generations and FW compile
  232. * time configurations)
  233. */
  234. VPU_JSM_MSG_TRACE_GET_CAPABILITY = 0x110c,
  235. /** Get the name of a destination or HW component. */
  236. VPU_JSM_MSG_TRACE_GET_NAME = 0x110d,
  237. /**
  238. * Release resource associated with host ssid . All jobs that belong to the host_ssid
  239. * aborted and removed from internal scheduling queues. All doorbells assigned
  240. * to the host_ssid are unregistered and any internal FW resources belonging to
  241. * the host_ssid are released.
  242. */
  243. VPU_JSM_MSG_SSID_RELEASE = 0x110e,
  244. /**
  245. * Start collecting metric data.
  246. * @see vpu_jsm_metric_streamer_start
  247. */
  248. VPU_JSM_MSG_METRIC_STREAMER_START = 0x110f,
  249. /**
  250. * Stop collecting metric data. This command will return success if it is called
  251. * for a metric stream that has already been stopped or was never started.
  252. * @see vpu_jsm_metric_streamer_stop
  253. */
  254. VPU_JSM_MSG_METRIC_STREAMER_STOP = 0x1110,
  255. /**
  256. * Update current and next buffer for metric data collection. This command can
  257. * also be used to request information about the number of collected samples
  258. * and the amount of data written to the buffer.
  259. * @see vpu_jsm_metric_streamer_update
  260. */
  261. VPU_JSM_MSG_METRIC_STREAMER_UPDATE = 0x1111,
  262. /**
  263. * Request description of selected metric groups and metric counters within
  264. * each group. The VPU will write the description of groups and counters to
  265. * the buffer specified in the command structure.
  266. * @see vpu_jsm_metric_streamer_start
  267. */
  268. VPU_JSM_MSG_METRIC_STREAMER_INFO = 0x1112,
  269. /** Control command: Priority band setup */
  270. VPU_JSM_MSG_SET_PRIORITY_BAND_SETUP = 0x1113,
  271. /** Control command: Create command queue */
  272. VPU_JSM_MSG_CREATE_CMD_QUEUE = 0x1114,
  273. /** Control command: Destroy command queue */
  274. VPU_JSM_MSG_DESTROY_CMD_QUEUE = 0x1115,
  275. /** Control command: Set context scheduling properties */
  276. VPU_JSM_MSG_SET_CONTEXT_SCHED_PROPERTIES = 0x1116,
  277. /*
  278. * Register a doorbell to notify VPU of new work. The doorbell may later be
  279. * deallocated or reassigned to another context.
  280. */
  281. VPU_JSM_MSG_HWS_REGISTER_DB = 0x1117,
  282. /** Control command: Log buffer setting */
  283. VPU_JSM_MSG_HWS_SET_SCHEDULING_LOG = 0x1118,
  284. /* Control command: Suspend command queue. */
  285. VPU_JSM_MSG_HWS_SUSPEND_CMDQ = 0x1119,
  286. /* Control command: Resume command queue */
  287. VPU_JSM_MSG_HWS_RESUME_CMDQ = 0x111a,
  288. /* Control command: Resume engine after reset */
  289. VPU_JSM_MSG_HWS_ENGINE_RESUME = 0x111b,
  290. /* Control command: Enable survivability/DCT mode */
  291. VPU_JSM_MSG_DCT_ENABLE = 0x111c,
  292. /* Control command: Disable survivability/DCT mode */
  293. VPU_JSM_MSG_DCT_DISABLE = 0x111d,
  294. /**
  295. * Dump VPU state. To be used for debug purposes only.
  296. * NOTE: Please introduce new ASYNC commands before this one. *
  297. */
  298. VPU_JSM_MSG_STATE_DUMP = 0x11FF,
  299. /* IPC Host -> Device, General commands */
  300. VPU_JSM_MSG_GENERAL_CMD = 0x1200,
  301. VPU_JSM_MSG_BLOB_DEINIT = VPU_JSM_MSG_GENERAL_CMD,
  302. /**
  303. * Control dyndbg behavior by executing a dyndbg command; equivalent to
  304. * Linux command: `echo '<dyndbg_cmd>' > <debugfs>/dynamic_debug/control`.
  305. */
  306. VPU_JSM_MSG_DYNDBG_CONTROL = 0x1201,
  307. /**
  308. * Perform the save procedure for the D0i3 entry
  309. */
  310. VPU_JSM_MSG_PWR_D0I3_ENTER = 0x1202,
  311. /* IPC Device -> Host, Job completion */
  312. VPU_JSM_MSG_JOB_DONE = 0x2100,
  313. /* IPC Device -> Host, Async command completion */
  314. VPU_JSM_MSG_ASYNC_CMD_DONE = 0x2200,
  315. VPU_JSM_MSG_ENGINE_RESET_DONE = VPU_JSM_MSG_ASYNC_CMD_DONE,
  316. VPU_JSM_MSG_ENGINE_PREEMPT_DONE = 0x2201,
  317. VPU_JSM_MSG_REGISTER_DB_DONE = 0x2202,
  318. VPU_JSM_MSG_UNREGISTER_DB_DONE = 0x2203,
  319. VPU_JSM_MSG_QUERY_ENGINE_HB_DONE = 0x2204,
  320. VPU_JSM_MSG_GET_POWER_LEVEL_COUNT_DONE = 0x2205,
  321. VPU_JSM_MSG_GET_POWER_LEVEL_DONE = 0x2206,
  322. VPU_JSM_MSG_SET_POWER_LEVEL_DONE = 0x2207,
  323. /* @deprecated */
  324. VPU_JSM_MSG_METRIC_STREAMER_OPEN_DONE = 0x2208,
  325. /* @deprecated */
  326. VPU_JSM_MSG_METRIC_STREAMER_CLOSE_DONE = 0x2209,
  327. /** Response to VPU_JSM_MSG_TRACE_SET_CONFIG. */
  328. VPU_JSM_MSG_TRACE_SET_CONFIG_RSP = 0x220a,
  329. /** Response to VPU_JSM_MSG_TRACE_GET_CONFIG. */
  330. VPU_JSM_MSG_TRACE_GET_CONFIG_RSP = 0x220b,
  331. /** Response to VPU_JSM_MSG_TRACE_GET_CAPABILITY. */
  332. VPU_JSM_MSG_TRACE_GET_CAPABILITY_RSP = 0x220c,
  333. /** Response to VPU_JSM_MSG_TRACE_GET_NAME. */
  334. VPU_JSM_MSG_TRACE_GET_NAME_RSP = 0x220d,
  335. /** Response to VPU_JSM_MSG_SSID_RELEASE. */
  336. VPU_JSM_MSG_SSID_RELEASE_DONE = 0x220e,
  337. /**
  338. * Response to VPU_JSM_MSG_METRIC_STREAMER_START.
  339. * VPU will return an error result if metric collection cannot be started,
  340. * e.g. when the specified metric mask is invalid.
  341. * @see vpu_jsm_metric_streamer_done
  342. */
  343. VPU_JSM_MSG_METRIC_STREAMER_START_DONE = 0x220f,
  344. /**
  345. * Response to VPU_JSM_MSG_METRIC_STREAMER_STOP.
  346. * Returns information about collected metric data.
  347. * @see vpu_jsm_metric_streamer_done
  348. */
  349. VPU_JSM_MSG_METRIC_STREAMER_STOP_DONE = 0x2210,
  350. /**
  351. * Response to VPU_JSM_MSG_METRIC_STREAMER_UPDATE.
  352. * Returns information about collected metric data.
  353. * @see vpu_jsm_metric_streamer_done
  354. */
  355. VPU_JSM_MSG_METRIC_STREAMER_UPDATE_DONE = 0x2211,
  356. /**
  357. * Response to VPU_JSM_MSG_METRIC_STREAMER_INFO.
  358. * Returns a description of the metric groups and metric counters.
  359. * @see vpu_jsm_metric_streamer_done
  360. */
  361. VPU_JSM_MSG_METRIC_STREAMER_INFO_DONE = 0x2212,
  362. /**
  363. * Asynchronous event sent from the VPU to the host either when the current
  364. * metric buffer is full or when the VPU has collected a multiple of
  365. * @notify_sample_count samples as indicated through the start command
  366. * (VPU_JSM_MSG_METRIC_STREAMER_START). Returns information about collected
  367. * metric data.
  368. * @see vpu_jsm_metric_streamer_done
  369. */
  370. VPU_JSM_MSG_METRIC_STREAMER_NOTIFICATION = 0x2213,
  371. /** Response to control command: Priority band setup */
  372. VPU_JSM_MSG_SET_PRIORITY_BAND_SETUP_RSP = 0x2214,
  373. /** Response to control command: Create command queue */
  374. VPU_JSM_MSG_CREATE_CMD_QUEUE_RSP = 0x2215,
  375. /** Response to control command: Destroy command queue */
  376. VPU_JSM_MSG_DESTROY_CMD_QUEUE_RSP = 0x2216,
  377. /** Response to control command: Set context scheduling properties */
  378. VPU_JSM_MSG_SET_CONTEXT_SCHED_PROPERTIES_RSP = 0x2217,
  379. /** Response to control command: Log buffer setting */
  380. VPU_JSM_MSG_HWS_SET_SCHEDULING_LOG_RSP = 0x2218,
  381. /* IPC Device -> Host, HWS notify index entry of log buffer written */
  382. VPU_JSM_MSG_HWS_SCHEDULING_LOG_NOTIFICATION = 0x2219,
  383. /* IPC Device -> Host, HWS completion of a context suspend request */
  384. VPU_JSM_MSG_HWS_SUSPEND_CMDQ_DONE = 0x221a,
  385. /* Response to control command: Resume command queue */
  386. VPU_JSM_MSG_HWS_RESUME_CMDQ_RSP = 0x221b,
  387. /* Response to control command: Resume engine command response */
  388. VPU_JSM_MSG_HWS_RESUME_ENGINE_DONE = 0x221c,
  389. /* Response to control command: Enable survivability/DCT mode */
  390. VPU_JSM_MSG_DCT_ENABLE_DONE = 0x221d,
  391. /* Response to control command: Disable survivability/DCT mode */
  392. VPU_JSM_MSG_DCT_DISABLE_DONE = 0x221e,
  393. /**
  394. * Response to state dump control command.
  395. * NOTE: Please introduce new ASYNC responses before this one. *
  396. */
  397. VPU_JSM_MSG_STATE_DUMP_RSP = 0x22FF,
  398. /* IPC Device -> Host, General command completion */
  399. VPU_JSM_MSG_GENERAL_CMD_DONE = 0x2300,
  400. VPU_JSM_MSG_BLOB_DEINIT_DONE = VPU_JSM_MSG_GENERAL_CMD_DONE,
  401. /** Response to VPU_JSM_MSG_DYNDBG_CONTROL. */
  402. VPU_JSM_MSG_DYNDBG_CONTROL_RSP = 0x2301,
  403. /**
  404. * Acknowledgment of completion of the save procedure initiated by
  405. * VPU_JSM_MSG_PWR_D0I3_ENTER
  406. */
  407. VPU_JSM_MSG_PWR_D0I3_ENTER_DONE = 0x2302,
  408. };
  409. enum vpu_ipc_msg_status { VPU_JSM_MSG_FREE, VPU_JSM_MSG_ALLOCATED };
  410. /*
  411. * Host <-> LRT IPC message payload definitions
  412. */
  413. struct vpu_ipc_msg_payload_engine_reset {
  414. /* Engine to be reset. */
  415. u32 engine_idx;
  416. /* Reserved */
  417. u32 reserved_0;
  418. };
  419. struct vpu_ipc_msg_payload_engine_preempt {
  420. /* Engine to be preempted. */
  421. u32 engine_idx;
  422. /* ID of the preemption request. */
  423. u32 preempt_id;
  424. };
  425. /*
  426. * @brief Register doorbell command structure.
  427. * This structure supports doorbell registration for only OS scheduling.
  428. * @see VPU_JSM_MSG_REGISTER_DB
  429. */
  430. struct vpu_ipc_msg_payload_register_db {
  431. /* Index of the doorbell to register. */
  432. u32 db_idx;
  433. /* Reserved */
  434. u32 reserved_0;
  435. /* Virtual address in Global GTT pointing to the start of job queue. */
  436. u64 jobq_base;
  437. /* Size of the job queue in bytes. */
  438. u32 jobq_size;
  439. /* Host sub-stream ID for the context assigned to the doorbell. */
  440. u32 host_ssid;
  441. };
  442. /**
  443. * @brief Unregister doorbell command structure.
  444. * Request structure to unregister a doorbell for both HW and OS scheduling.
  445. * @see VPU_JSM_MSG_UNREGISTER_DB
  446. */
  447. struct vpu_ipc_msg_payload_unregister_db {
  448. /* Index of the doorbell to unregister. */
  449. u32 db_idx;
  450. /* Reserved */
  451. u32 reserved_0;
  452. };
  453. struct vpu_ipc_msg_payload_query_engine_hb {
  454. /* Engine to return heartbeat value. */
  455. u32 engine_idx;
  456. /* Reserved */
  457. u32 reserved_0;
  458. };
  459. struct vpu_ipc_msg_payload_power_level {
  460. /**
  461. * Requested power level. The power level value is in the
  462. * range [0, power_level_count-1] where power_level_count
  463. * is the number of available power levels as returned by
  464. * the get power level count command. A power level of 0
  465. * corresponds to the maximum possible power level, while
  466. * power_level_count-1 corresponds to the minimum possible
  467. * power level. Values outside of this range are not
  468. * considered to be valid.
  469. */
  470. u32 power_level;
  471. /* Reserved */
  472. u32 reserved_0;
  473. };
  474. struct vpu_ipc_msg_payload_ssid_release {
  475. /* Host sub-stream ID for the context to be released. */
  476. u32 host_ssid;
  477. /* Reserved */
  478. u32 reserved_0;
  479. };
  480. /**
  481. * @brief Metric streamer start command structure.
  482. * This structure is also used with VPU_JSM_MSG_METRIC_STREAMER_INFO to request metric
  483. * groups and metric counters description from the firmware.
  484. * @see VPU_JSM_MSG_METRIC_STREAMER_START
  485. * @see VPU_JSM_MSG_METRIC_STREAMER_INFO
  486. */
  487. struct vpu_jsm_metric_streamer_start {
  488. /**
  489. * Bitmask to select the desired metric groups.
  490. * A metric group can belong only to one metric streamer instance at a time.
  491. * Since each metric streamer instance has a unique set of metric groups, it
  492. * can also identify a metric streamer instance if more than one instance was
  493. * started. If the VPU device does not support multiple metric streamer instances,
  494. * then VPU_JSM_MSG_METRIC_STREAMER_START will return an error even if the second
  495. * instance has different groups to the first.
  496. */
  497. u64 metric_group_mask;
  498. /** Sampling rate in nanoseconds. */
  499. u64 sampling_rate;
  500. /**
  501. * If > 0 the VPU will send a VPU_JSM_MSG_METRIC_STREAMER_NOTIFICATION message
  502. * after every @notify_sample_count samples is collected or dropped by the VPU.
  503. * If set to UINT_MAX the VPU will only generate a notification when the metric
  504. * buffer is full. If set to 0 the VPU will never generate a notification.
  505. */
  506. u32 notify_sample_count;
  507. u32 reserved_0;
  508. /**
  509. * Address and size of the buffer where the VPU will write metric data. The
  510. * VPU writes all counters from enabled metric groups one after another. If
  511. * there is no space left to write data at the next sample period the VPU
  512. * will switch to the next buffer (@see next_buffer_addr) and will optionally
  513. * send a notification to the host driver if @notify_sample_count is non-zero.
  514. * If @next_buffer_addr is NULL the VPU will stop collecting metric data.
  515. */
  516. u64 buffer_addr;
  517. u64 buffer_size;
  518. /**
  519. * Address and size of the next buffer to write metric data to after the initial
  520. * buffer is full. If the address is NULL the VPU will stop collecting metric
  521. * data.
  522. */
  523. u64 next_buffer_addr;
  524. u64 next_buffer_size;
  525. };
  526. /**
  527. * @brief Metric streamer stop command structure.
  528. * @see VPU_JSM_MSG_METRIC_STREAMER_STOP
  529. */
  530. struct vpu_jsm_metric_streamer_stop {
  531. /** Bitmask to select the desired metric groups. */
  532. u64 metric_group_mask;
  533. };
  534. /**
  535. * Provide VPU FW with buffers to write metric data.
  536. * @see VPU_JSM_MSG_METRIC_STREAMER_UPDATE
  537. */
  538. struct vpu_jsm_metric_streamer_update {
  539. /** Metric group mask that identifies metric streamer instance. */
  540. u64 metric_group_mask;
  541. /**
  542. * Address and size of the buffer where the VPU will write metric data. If
  543. * the buffer address is 0 or same as the currently used buffer the VPU will
  544. * continue writing metric data to the current buffer. In this case the
  545. * buffer size is ignored and the size of the current buffer is unchanged.
  546. * If the address is non-zero and differs from the current buffer address the
  547. * VPU will immediately switch data collection to the new buffer.
  548. */
  549. u64 buffer_addr;
  550. u64 buffer_size;
  551. /**
  552. * Address and size of the next buffer to write metric data after the initial
  553. * buffer is full. If the address is NULL the VPU will stop collecting metric
  554. * data but will continue to record dropped samples.
  555. *
  556. * Note that there is a hazard possible if both buffer_addr and the next_buffer_addr
  557. * are non-zero in same update request. It is the host's responsibility to ensure
  558. * that both addresses make sense even if the VPU just switched to writing samples
  559. * from the current to the next buffer.
  560. */
  561. u64 next_buffer_addr;
  562. u64 next_buffer_size;
  563. };
  564. struct vpu_ipc_msg_payload_blob_deinit {
  565. /* 64-bit unique ID for the blob to be de-initialized. */
  566. u64 blob_id;
  567. };
  568. struct vpu_ipc_msg_payload_job_done {
  569. /* Engine to which the job was submitted. */
  570. u32 engine_idx;
  571. /* Index of the doorbell to which the job was submitted */
  572. u32 db_idx;
  573. /* ID of the completed job */
  574. u32 job_id;
  575. /* Status of the completed job */
  576. u32 job_status;
  577. /* Host SSID */
  578. u32 host_ssid;
  579. /* Zero Padding */
  580. u32 reserved_0;
  581. /* Command queue id */
  582. u64 cmdq_id;
  583. };
  584. struct vpu_jsm_engine_reset_context {
  585. /* Host SSID */
  586. u32 host_ssid;
  587. /* Zero Padding */
  588. u32 reserved_0;
  589. /* Command queue id */
  590. u64 cmdq_id;
  591. /* See VPU_ENGINE_RESET_CONTEXT_* defines */
  592. u64 flags;
  593. };
  594. struct vpu_ipc_msg_payload_engine_reset_done {
  595. /* Engine ordinal */
  596. u32 engine_idx;
  597. /* Number of impacted contexts */
  598. u32 num_impacted_contexts;
  599. /* Array of impacted command queue ids and their flags */
  600. struct vpu_jsm_engine_reset_context
  601. impacted_contexts[VPU_MAX_ENGINE_RESET_IMPACTED_CONTEXTS];
  602. };
  603. struct vpu_ipc_msg_payload_engine_preempt_done {
  604. /* Engine preempted. */
  605. u32 engine_idx;
  606. /* ID of the preemption request. */
  607. u32 preempt_id;
  608. };
  609. /**
  610. * Response structure for register doorbell command for both OS
  611. * and HW scheduling.
  612. * @see VPU_JSM_MSG_REGISTER_DB
  613. * @see VPU_JSM_MSG_HWS_REGISTER_DB
  614. */
  615. struct vpu_ipc_msg_payload_register_db_done {
  616. /* Index of the registered doorbell. */
  617. u32 db_idx;
  618. /* Reserved */
  619. u32 reserved_0;
  620. };
  621. /**
  622. * Response structure for unregister doorbell command for both OS
  623. * and HW scheduling.
  624. * @see VPU_JSM_MSG_UNREGISTER_DB
  625. */
  626. struct vpu_ipc_msg_payload_unregister_db_done {
  627. /* Index of the unregistered doorbell. */
  628. u32 db_idx;
  629. /* Reserved */
  630. u32 reserved_0;
  631. };
  632. struct vpu_ipc_msg_payload_query_engine_hb_done {
  633. /* Engine returning heartbeat value. */
  634. u32 engine_idx;
  635. /* Reserved */
  636. u32 reserved_0;
  637. /* Heartbeat value. */
  638. u64 heartbeat;
  639. };
  640. struct vpu_ipc_msg_payload_get_power_level_count_done {
  641. /**
  642. * Number of supported power levels. The maximum possible
  643. * value of power_level_count is 16 but this may vary across
  644. * implementations.
  645. */
  646. u32 power_level_count;
  647. /* Reserved */
  648. u32 reserved_0;
  649. /**
  650. * Power consumption limit for each supported power level in
  651. * [0-100%] range relative to power level 0.
  652. */
  653. u8 power_limit[16];
  654. };
  655. struct vpu_ipc_msg_payload_blob_deinit_done {
  656. /* 64-bit unique ID for the blob de-initialized. */
  657. u64 blob_id;
  658. };
  659. /* HWS priority band setup request / response */
  660. struct vpu_ipc_msg_payload_hws_priority_band_setup {
  661. /*
  662. * Grace period in 100ns units when preempting another priority band for
  663. * this priority band
  664. */
  665. u32 grace_period[VPU_HWS_NUM_PRIORITY_BANDS];
  666. /*
  667. * Default quantum in 100ns units for scheduling across processes
  668. * within a priority band
  669. */
  670. u32 process_quantum[VPU_HWS_NUM_PRIORITY_BANDS];
  671. /*
  672. * Default grace period in 100ns units for processes that preempt each
  673. * other within a priority band
  674. */
  675. u32 process_grace_period[VPU_HWS_NUM_PRIORITY_BANDS];
  676. /*
  677. * For normal priority band, specifies the target VPU percentage
  678. * in situations when it's starved by the focus band.
  679. */
  680. u32 normal_band_percentage;
  681. /* Reserved */
  682. u32 reserved_0;
  683. };
  684. /*
  685. * @brief HWS create command queue request.
  686. * Host will create a command queue via this command.
  687. * Note: Cmdq group is a handle of an object which
  688. * may contain one or more command queues.
  689. * @see VPU_JSM_MSG_CREATE_CMD_QUEUE
  690. * @see VPU_JSM_MSG_CREATE_CMD_QUEUE_RSP
  691. */
  692. struct vpu_ipc_msg_payload_hws_create_cmdq {
  693. /* Process id */
  694. u64 process_id;
  695. /* Host SSID */
  696. u32 host_ssid;
  697. /* Engine for which queue is being created */
  698. u32 engine_idx;
  699. /* Cmdq group: only used for HWS logging of state changes */
  700. u64 cmdq_group;
  701. /* Command queue id */
  702. u64 cmdq_id;
  703. /* Command queue base */
  704. u64 cmdq_base;
  705. /* Command queue size */
  706. u32 cmdq_size;
  707. /* Zero padding */
  708. u32 reserved_0;
  709. };
  710. /*
  711. * @brief HWS create command queue response.
  712. * @see VPU_JSM_MSG_CREATE_CMD_QUEUE
  713. * @see VPU_JSM_MSG_CREATE_CMD_QUEUE_RSP
  714. */
  715. struct vpu_ipc_msg_payload_hws_create_cmdq_rsp {
  716. /* Process id */
  717. u64 process_id;
  718. /* Host SSID */
  719. u32 host_ssid;
  720. /* Engine for which queue is being created */
  721. u32 engine_idx;
  722. /* Command queue group */
  723. u64 cmdq_group;
  724. /* Command queue id */
  725. u64 cmdq_id;
  726. };
  727. /* HWS destroy command queue request / response */
  728. struct vpu_ipc_msg_payload_hws_destroy_cmdq {
  729. /* Host SSID */
  730. u32 host_ssid;
  731. /* Zero Padding */
  732. u32 reserved;
  733. /* Command queue id */
  734. u64 cmdq_id;
  735. };
  736. /* HWS set context scheduling properties request / response */
  737. struct vpu_ipc_msg_payload_hws_set_context_sched_properties {
  738. /* Host SSID */
  739. u32 host_ssid;
  740. /* Zero Padding */
  741. u32 reserved_0;
  742. /* Command queue id */
  743. u64 cmdq_id;
  744. /* Priority band to assign to work of this context */
  745. u32 priority_band;
  746. /* Inside realtime band assigns a further priority */
  747. u32 realtime_priority_level;
  748. /* Priority relative to other contexts in the same process */
  749. s32 in_process_priority;
  750. /* Zero padding / Reserved */
  751. u32 reserved_1;
  752. /* Context quantum relative to other contexts of same priority in the same process */
  753. u64 context_quantum;
  754. /* Grace period when preempting context of the same priority within the same process */
  755. u64 grace_period_same_priority;
  756. /* Grace period when preempting context of a lower priority within the same process */
  757. u64 grace_period_lower_priority;
  758. };
  759. /*
  760. * @brief Register doorbell command structure.
  761. * This structure supports doorbell registration for both HW and OS scheduling.
  762. * Note: Queue base and size are added here so that the same structure can be used for
  763. * OS scheduling and HW scheduling. For OS scheduling, cmdq_id will be ignored
  764. * and cmdq_base and cmdq_size will be used. For HW scheduling, cmdq_base and cmdq_size will be
  765. * ignored and cmdq_id is used.
  766. * @see VPU_JSM_MSG_HWS_REGISTER_DB
  767. */
  768. struct vpu_jsm_hws_register_db {
  769. /* Index of the doorbell to register. */
  770. u32 db_id;
  771. /* Host sub-stream ID for the context assigned to the doorbell. */
  772. u32 host_ssid;
  773. /* ID of the command queue associated with the doorbell. */
  774. u64 cmdq_id;
  775. /* Virtual address pointing to the start of command queue. */
  776. u64 cmdq_base;
  777. /* Size of the command queue in bytes. */
  778. u64 cmdq_size;
  779. };
  780. /*
  781. * @brief Structure to set another buffer to be used for scheduling-related logging.
  782. * The size of the logging buffer and the number of entries is defined as part of the
  783. * buffer itself as described next.
  784. * The log buffer received from the host is made up of;
  785. * - header: 32 bytes in size, as shown in 'struct vpu_hws_log_buffer_header'.
  786. * The header contains the number of log entries in the buffer.
  787. * - log entry: 0 to n-1, each log entry is 32 bytes in size, as shown in
  788. * 'struct vpu_hws_log_buffer_entry'.
  789. * The entry contains the VPU timestamp, operation type and data.
  790. * The host should provide the notify index value of log buffer to VPU. This is a
  791. * value defined within the log buffer and when written to will generate the
  792. * scheduling log notification.
  793. * The host should set engine_idx and vpu_log_buffer_va to 0 to disable logging
  794. * for a particular engine.
  795. * VPU will handle one log buffer for each of supported engines.
  796. * VPU should allow the logging to consume one host_ssid.
  797. * @see VPU_JSM_MSG_HWS_SET_SCHEDULING_LOG
  798. * @see VPU_JSM_MSG_HWS_SET_SCHEDULING_LOG_RSP
  799. * @see VPU_JSM_MSG_HWS_SCHEDULING_LOG_NOTIFICATION
  800. */
  801. struct vpu_ipc_msg_payload_hws_set_scheduling_log {
  802. /* Engine ordinal */
  803. u32 engine_idx;
  804. /* Host SSID */
  805. u32 host_ssid;
  806. /*
  807. * VPU log buffer virtual address.
  808. * Set to 0 to disable logging for this engine.
  809. */
  810. u64 vpu_log_buffer_va;
  811. /*
  812. * Notify index of log buffer. VPU_JSM_MSG_HWS_SCHEDULING_LOG_NOTIFICATION
  813. * is generated when an event log is written to this index.
  814. */
  815. u64 notify_index;
  816. /*
  817. * Enable extra events to be output to log for debug of scheduling algorithm.
  818. * Interpreted by VPU as a boolean to enable or disable, expected values are
  819. * 0 and 1.
  820. */
  821. u32 enable_extra_events;
  822. /* Zero Padding */
  823. u32 reserved_0;
  824. };
  825. /*
  826. * @brief The scheduling log notification is generated by VPU when it writes
  827. * an event into the log buffer at the notify_index. VPU notifies host with
  828. * VPU_JSM_MSG_HWS_SCHEDULING_LOG_NOTIFICATION. This is an asynchronous
  829. * message from VPU to host.
  830. * @see VPU_JSM_MSG_HWS_SCHEDULING_LOG_NOTIFICATION
  831. * @see VPU_JSM_MSG_HWS_SET_SCHEDULING_LOG
  832. */
  833. struct vpu_ipc_msg_payload_hws_scheduling_log_notification {
  834. /* Engine ordinal */
  835. u32 engine_idx;
  836. /* Zero Padding */
  837. u32 reserved_0;
  838. };
  839. /*
  840. * @brief HWS suspend command queue request and done structure.
  841. * Host will request the suspend of contexts and VPU will;
  842. * - Suspend all work on this context
  843. * - Preempt any running work
  844. * - Asynchronously perform the above and return success immediately once
  845. * all items above are started successfully
  846. * - Notify the host of completion of these operations via
  847. * VPU_JSM_MSG_HWS_SUSPEND_CMDQ_DONE
  848. * - Reject any other context operations on a context with an in-flight
  849. * suspend request running
  850. * Same structure used when VPU notifies host of completion of a context suspend
  851. * request. The ids and suspend fence value reported in this command will match
  852. * the one in the request from the host to suspend the context. Once suspend is
  853. * complete, VPU will not access any data relating to this command queue until
  854. * it is resumed.
  855. * @see VPU_JSM_MSG_HWS_SUSPEND_CMDQ
  856. * @see VPU_JSM_MSG_HWS_SUSPEND_CMDQ_DONE
  857. */
  858. struct vpu_ipc_msg_payload_hws_suspend_cmdq {
  859. /* Host SSID */
  860. u32 host_ssid;
  861. /* Zero Padding */
  862. u32 reserved_0;
  863. /* Command queue id */
  864. u64 cmdq_id;
  865. /*
  866. * Suspend fence value - reported by the VPU suspend context
  867. * completed once suspend is complete.
  868. */
  869. u64 suspend_fence_value;
  870. };
  871. /*
  872. * @brief HWS Resume command queue request / response structure.
  873. * Host will request the resume of a context;
  874. * - VPU will resume all work on this context
  875. * - Scheduler will allow this context to be scheduled
  876. * @see VPU_JSM_MSG_HWS_RESUME_CMDQ
  877. * @see VPU_JSM_MSG_HWS_RESUME_CMDQ_RSP
  878. */
  879. struct vpu_ipc_msg_payload_hws_resume_cmdq {
  880. /* Host SSID */
  881. u32 host_ssid;
  882. /* Zero Padding */
  883. u32 reserved_0;
  884. /* Command queue id */
  885. u64 cmdq_id;
  886. };
  887. /*
  888. * @brief HWS Resume engine request / response structure.
  889. * After a HWS engine reset, all scheduling is stopped on VPU until a engine resume.
  890. * Host shall send this command to resume scheduling of any valid queue.
  891. * @see VPU_JSM_MSG_HWS_RESUME_ENGINE
  892. * @see VPU_JSM_MSG_HWS_RESUME_ENGINE_DONE
  893. */
  894. struct vpu_ipc_msg_payload_hws_resume_engine {
  895. /* Engine to be resumed */
  896. u32 engine_idx;
  897. /* Reserved */
  898. u32 reserved_0;
  899. };
  900. /**
  901. * Payload for VPU_JSM_MSG_TRACE_SET_CONFIG[_RSP] and
  902. * VPU_JSM_MSG_TRACE_GET_CONFIG_RSP messages.
  903. *
  904. * The payload is interpreted differently depending on the type of message:
  905. *
  906. * - For VPU_JSM_MSG_TRACE_SET_CONFIG, the payload specifies the desired
  907. * logging configuration to be set.
  908. *
  909. * - For VPU_JSM_MSG_TRACE_SET_CONFIG_RSP, the payload reports the logging
  910. * configuration that was set after a VPU_JSM_MSG_TRACE_SET_CONFIG request.
  911. * The host can compare this payload with the one it sent in the
  912. * VPU_JSM_MSG_TRACE_SET_CONFIG request to check whether or not the
  913. * configuration was set as desired.
  914. *
  915. * - VPU_JSM_MSG_TRACE_GET_CONFIG_RSP, the payload reports the current logging
  916. * configuration.
  917. */
  918. struct vpu_ipc_msg_payload_trace_config {
  919. /**
  920. * Logging level (currently set or to be set); see 'mvLog_t' enum for
  921. * acceptable values. The specified logging level applies to all
  922. * destinations and HW components
  923. */
  924. u32 trace_level;
  925. /**
  926. * Bitmask of logging destinations (currently enabled or to be enabled);
  927. * bitwise OR of values defined in logging_destination enum.
  928. */
  929. u32 trace_destination_mask;
  930. /**
  931. * Bitmask of loggable HW components (currently enabled or to be enabled);
  932. * bitwise OR of values defined in loggable_hw_component enum.
  933. */
  934. u64 trace_hw_component_mask;
  935. u64 reserved_0; /**< Reserved for future extensions. */
  936. };
  937. /**
  938. * Payload for VPU_JSM_MSG_TRACE_GET_CAPABILITY_RSP messages.
  939. */
  940. struct vpu_ipc_msg_payload_trace_capability_rsp {
  941. u32 trace_destination_mask; /**< Bitmask of supported logging destinations. */
  942. u32 reserved_0;
  943. u64 trace_hw_component_mask; /**< Bitmask of supported loggable HW components. */
  944. u64 reserved_1; /**< Reserved for future extensions. */
  945. };
  946. /**
  947. * Payload for VPU_JSM_MSG_TRACE_GET_NAME requests.
  948. */
  949. struct vpu_ipc_msg_payload_trace_get_name {
  950. /**
  951. * The type of the entity to query name for; see logging_entity_type for
  952. * possible values.
  953. */
  954. u32 entity_type;
  955. u32 reserved_0;
  956. /**
  957. * The ID of the entity to query name for; possible values depends on the
  958. * entity type.
  959. */
  960. u64 entity_id;
  961. };
  962. /**
  963. * Payload for VPU_JSM_MSG_TRACE_GET_NAME_RSP responses.
  964. */
  965. struct vpu_ipc_msg_payload_trace_get_name_rsp {
  966. /**
  967. * The type of the entity whose name was queried; see logging_entity_type
  968. * for possible values.
  969. */
  970. u32 entity_type;
  971. u32 reserved_0;
  972. /**
  973. * The ID of the entity whose name was queried; possible values depends on
  974. * the entity type.
  975. */
  976. u64 entity_id;
  977. /** Reserved for future extensions. */
  978. u64 reserved_1;
  979. /** The name of the entity. */
  980. char entity_name[VPU_TRACE_ENTITY_NAME_MAX_LEN];
  981. };
  982. /**
  983. * Data sent from the VPU to the host in all metric streamer response messages
  984. * and in asynchronous notification.
  985. * @see VPU_JSM_MSG_METRIC_STREAMER_START_DONE
  986. * @see VPU_JSM_MSG_METRIC_STREAMER_STOP_DONE
  987. * @see VPU_JSM_MSG_METRIC_STREAMER_UPDATE_DONE
  988. * @see VPU_JSM_MSG_METRIC_STREAMER_INFO_DONE
  989. * @see VPU_JSM_MSG_METRIC_STREAMER_NOTIFICATION
  990. */
  991. struct vpu_jsm_metric_streamer_done {
  992. /** Metric group mask that identifies metric streamer instance. */
  993. u64 metric_group_mask;
  994. /**
  995. * Size in bytes of single sample - total size of all enabled counters.
  996. * Some VPU implementations may align sample_size to more than 8 bytes.
  997. */
  998. u32 sample_size;
  999. u32 reserved_0;
  1000. /**
  1001. * Number of samples collected since the metric streamer was started.
  1002. * This will be 0 if the metric streamer was not started.
  1003. */
  1004. u32 samples_collected;
  1005. /**
  1006. * Number of samples dropped since the metric streamer was started. This
  1007. * is incremented every time the metric streamer is not able to write
  1008. * collected samples because the current buffer is full and there is no
  1009. * next buffer to switch to.
  1010. */
  1011. u32 samples_dropped;
  1012. /** Address of the buffer that contains the latest metric data. */
  1013. u64 buffer_addr;
  1014. /**
  1015. * Number of bytes written into the metric data buffer. In response to the
  1016. * VPU_JSM_MSG_METRIC_STREAMER_INFO request this field contains the size of
  1017. * all group and counter descriptors. The size is updated even if the buffer
  1018. * in the request was NULL or too small to hold descriptors of all counters
  1019. */
  1020. u64 bytes_written;
  1021. };
  1022. /**
  1023. * Metric group description placed in the metric buffer after successful completion
  1024. * of the VPU_JSM_MSG_METRIC_STREAMER_INFO command. This is followed by one or more
  1025. * @vpu_jsm_metric_counter_descriptor records.
  1026. * @see VPU_JSM_MSG_METRIC_STREAMER_INFO
  1027. */
  1028. struct vpu_jsm_metric_group_descriptor {
  1029. /**
  1030. * Offset to the next metric group (8-byte aligned). If this offset is 0 this
  1031. * is the last descriptor. The value of metric_info_size must be greater than
  1032. * or equal to sizeof(struct vpu_jsm_metric_group_descriptor) + name_string_size
  1033. * + description_string_size and must be 8-byte aligned.
  1034. */
  1035. u32 next_metric_group_info_offset;
  1036. /**
  1037. * Offset to the first metric counter description record (8-byte aligned).
  1038. * @see vpu_jsm_metric_counter_descriptor
  1039. */
  1040. u32 next_metric_counter_info_offset;
  1041. /** Index of the group. This corresponds to bit index in metric_group_mask. */
  1042. u32 group_id;
  1043. /** Number of counters in the metric group. */
  1044. u32 num_counters;
  1045. /** Data size for all counters, must be a multiple of 8 bytes.*/
  1046. u32 metric_group_data_size;
  1047. /**
  1048. * Metric group domain number. Cannot use multiple, simultaneous metric groups
  1049. * from the same domain.
  1050. */
  1051. u32 domain;
  1052. /**
  1053. * Counter name string size. The string must include a null termination character.
  1054. * The FW may use a fixed size name or send a different name for each counter.
  1055. * If the VPU uses fixed size strings, all characters from the end of the name
  1056. * to the of the fixed size character array must be zeroed.
  1057. */
  1058. u32 name_string_size;
  1059. /** Counter description string size, @see name_string_size */
  1060. u32 description_string_size;
  1061. u64 reserved_0;
  1062. /**
  1063. * Right after this structure, the VPU writes name and description of
  1064. * the metric group.
  1065. */
  1066. };
  1067. /**
  1068. * Metric counter description, placed in the buffer after vpu_jsm_metric_group_descriptor.
  1069. * @see VPU_JSM_MSG_METRIC_STREAMER_INFO
  1070. */
  1071. struct vpu_jsm_metric_counter_descriptor {
  1072. /**
  1073. * Offset to the next counter in a group (8-byte aligned). If this offset is
  1074. * 0 this is the last counter in the group.
  1075. */
  1076. u32 next_metric_counter_info_offset;
  1077. /**
  1078. * Offset to the counter data from the start of samples in this metric group.
  1079. * Note that metric_data_offset % metric_data_size must be 0.
  1080. */
  1081. u32 metric_data_offset;
  1082. /** Size of the metric counter data in bytes. */
  1083. u32 metric_data_size;
  1084. /** Metric type, see Level Zero API for definitions. */
  1085. u32 tier;
  1086. /** Metric type, see set_metric_type_t for definitions. */
  1087. u32 metric_type;
  1088. /** Metric type, see set_value_type_t for definitions. */
  1089. u32 metric_value_type;
  1090. /**
  1091. * Counter name string size. The string must include a null termination character.
  1092. * The FW may use a fixed size name or send a different name for each counter.
  1093. * If the VPU uses fixed size strings, all characters from the end of the name
  1094. * to the of the fixed size character array must be zeroed.
  1095. */
  1096. u32 name_string_size;
  1097. /** Counter description string size, @see name_string_size */
  1098. u32 description_string_size;
  1099. /** Counter component name string size, @see name_string_size */
  1100. u32 component_string_size;
  1101. /** Counter string size, @see name_string_size */
  1102. u32 units_string_size;
  1103. u64 reserved_0;
  1104. /**
  1105. * Right after this structure, the VPU writes name, description
  1106. * component and unit strings.
  1107. */
  1108. };
  1109. /**
  1110. * Payload for VPU_JSM_MSG_DYNDBG_CONTROL requests.
  1111. *
  1112. * VPU_JSM_MSG_DYNDBG_CONTROL are used to control the VPU FW Dynamic Debug
  1113. * feature, which allows developers to selectively enable / disable MVLOG_DEBUG
  1114. * messages. This is equivalent to the Dynamic Debug functionality provided by
  1115. * Linux
  1116. * (https://www.kernel.org/doc/html/latest/admin-guide/dynamic-debug-howto.html)
  1117. * The host can control Dynamic Debug behavior by sending dyndbg commands, which
  1118. * have the same syntax as Linux
  1119. * dyndbg commands.
  1120. *
  1121. * NOTE: in order for MVLOG_DEBUG messages to be actually printed, the host
  1122. * still has to set the logging level to MVLOG_DEBUG, using the
  1123. * VPU_JSM_MSG_TRACE_SET_CONFIG command.
  1124. *
  1125. * The host can see the current dynamic debug configuration by executing a
  1126. * special 'show' command. The dyndbg configuration will be printed to the
  1127. * configured logging destination using MVLOG_INFO logging level.
  1128. */
  1129. struct vpu_ipc_msg_payload_dyndbg_control {
  1130. /**
  1131. * Dyndbg command (same format as Linux dyndbg); must be a NULL-terminated
  1132. * string.
  1133. */
  1134. char dyndbg_cmd[VPU_DYNDBG_CMD_MAX_LEN];
  1135. };
  1136. /**
  1137. * Payload for VPU_JSM_MSG_PWR_D0I3_ENTER
  1138. *
  1139. * This is a bi-directional payload.
  1140. */
  1141. struct vpu_ipc_msg_payload_pwr_d0i3_enter {
  1142. /**
  1143. * 0: VPU_JSM_MSG_PWR_D0I3_ENTER_DONE is not sent to the host driver
  1144. * The driver will poll for D0i2 Idle state transitions.
  1145. * 1: VPU_JSM_MSG_PWR_D0I3_ENTER_DONE is sent after VPU state save is complete
  1146. */
  1147. u32 send_response;
  1148. u32 reserved_0;
  1149. };
  1150. /**
  1151. * Payload for VPU_JSM_MSG_DCT_ENABLE message.
  1152. *
  1153. * Default values for DCT active/inactive times are 5.3ms and 30ms respectively,
  1154. * corresponding to a 85% duty cycle. This payload allows the host to tune these
  1155. * values according to application requirements.
  1156. */
  1157. struct vpu_ipc_msg_payload_pwr_dct_control {
  1158. /** Duty cycle active time in microseconds */
  1159. u32 dct_active_us;
  1160. /** Duty cycle inactive time in microseconds */
  1161. u32 dct_inactive_us;
  1162. };
  1163. /*
  1164. * Payloads union, used to define complete message format.
  1165. */
  1166. union vpu_ipc_msg_payload {
  1167. struct vpu_ipc_msg_payload_engine_reset engine_reset;
  1168. struct vpu_ipc_msg_payload_engine_preempt engine_preempt;
  1169. struct vpu_ipc_msg_payload_register_db register_db;
  1170. struct vpu_ipc_msg_payload_unregister_db unregister_db;
  1171. struct vpu_ipc_msg_payload_query_engine_hb query_engine_hb;
  1172. struct vpu_ipc_msg_payload_power_level power_level;
  1173. struct vpu_jsm_metric_streamer_start metric_streamer_start;
  1174. struct vpu_jsm_metric_streamer_stop metric_streamer_stop;
  1175. struct vpu_jsm_metric_streamer_update metric_streamer_update;
  1176. struct vpu_ipc_msg_payload_blob_deinit blob_deinit;
  1177. struct vpu_ipc_msg_payload_ssid_release ssid_release;
  1178. struct vpu_jsm_hws_register_db hws_register_db;
  1179. struct vpu_ipc_msg_payload_job_done job_done;
  1180. struct vpu_ipc_msg_payload_engine_reset_done engine_reset_done;
  1181. struct vpu_ipc_msg_payload_engine_preempt_done engine_preempt_done;
  1182. struct vpu_ipc_msg_payload_register_db_done register_db_done;
  1183. struct vpu_ipc_msg_payload_unregister_db_done unregister_db_done;
  1184. struct vpu_ipc_msg_payload_query_engine_hb_done query_engine_hb_done;
  1185. struct vpu_ipc_msg_payload_get_power_level_count_done get_power_level_count_done;
  1186. struct vpu_jsm_metric_streamer_done metric_streamer_done;
  1187. struct vpu_ipc_msg_payload_blob_deinit_done blob_deinit_done;
  1188. struct vpu_ipc_msg_payload_trace_config trace_config;
  1189. struct vpu_ipc_msg_payload_trace_capability_rsp trace_capability;
  1190. struct vpu_ipc_msg_payload_trace_get_name trace_get_name;
  1191. struct vpu_ipc_msg_payload_trace_get_name_rsp trace_get_name_rsp;
  1192. struct vpu_ipc_msg_payload_dyndbg_control dyndbg_control;
  1193. struct vpu_ipc_msg_payload_hws_priority_band_setup hws_priority_band_setup;
  1194. struct vpu_ipc_msg_payload_hws_create_cmdq hws_create_cmdq;
  1195. struct vpu_ipc_msg_payload_hws_create_cmdq_rsp hws_create_cmdq_rsp;
  1196. struct vpu_ipc_msg_payload_hws_destroy_cmdq hws_destroy_cmdq;
  1197. struct vpu_ipc_msg_payload_hws_set_context_sched_properties
  1198. hws_set_context_sched_properties;
  1199. struct vpu_ipc_msg_payload_hws_set_scheduling_log hws_set_scheduling_log;
  1200. struct vpu_ipc_msg_payload_hws_scheduling_log_notification hws_scheduling_log_notification;
  1201. struct vpu_ipc_msg_payload_hws_suspend_cmdq hws_suspend_cmdq;
  1202. struct vpu_ipc_msg_payload_hws_resume_cmdq hws_resume_cmdq;
  1203. struct vpu_ipc_msg_payload_hws_resume_engine hws_resume_engine;
  1204. struct vpu_ipc_msg_payload_pwr_d0i3_enter pwr_d0i3_enter;
  1205. struct vpu_ipc_msg_payload_pwr_dct_control pwr_dct_control;
  1206. };
  1207. /*
  1208. * Host <-> LRT IPC message base structure.
  1209. *
  1210. * NOTE: All instances of this object must be aligned on a 64B boundary
  1211. * to allow proper handling of VPU cache operations.
  1212. */
  1213. struct vpu_jsm_msg {
  1214. /* Reserved */
  1215. u64 reserved_0;
  1216. /* Message type, see vpu_ipc_msg_type enum. */
  1217. u32 type;
  1218. /* Buffer status, see vpu_ipc_msg_status enum. */
  1219. u32 status;
  1220. /*
  1221. * Request ID, provided by the host in a request message and passed
  1222. * back by VPU in the response message.
  1223. */
  1224. u32 request_id;
  1225. /* Request return code set by the VPU, see VPU_JSM_STATUS_* defines. */
  1226. u32 result;
  1227. u64 reserved_1;
  1228. /* Message payload depending on message type, see vpu_ipc_msg_payload union. */
  1229. union vpu_ipc_msg_payload payload;
  1230. };
  1231. #pragma pack(pop)
  1232. #endif
  1233. ///@}