/* SPDX-License-Identifier: MIT */1/*2* Copyright (c) 2020-2024, Intel Corporation.3*/45/**6* @file7* @brief JSM shared definitions8*9* @ingroup Jsm10* @brief JSM shared definitions11* @{12*/13#ifndef VPU_JSM_API_H14#define VPU_JSM_API_H1516/*17* Major version changes that break backward compatibility18*/19#define VPU_JSM_API_VER_MAJOR 32021/*22* Minor version changes when API backward compatibility is preserved.23*/24#define VPU_JSM_API_VER_MINOR 292526/*27* API header changed (field names, documentation, formatting) but API itself has not been changed28*/29#define VPU_JSM_API_VER_PATCH 03031/*32* Index in the API version table33*/34#define VPU_JSM_API_VER_INDEX 43536/*37* Number of Priority Bands for Hardware Scheduling38* Bands: Idle(0), Normal(1), Focus(2), RealTime(3)39*/40#define VPU_HWS_NUM_PRIORITY_BANDS 44142/* Max number of impacted contexts that can be dealt with the engine reset command */43#define VPU_MAX_ENGINE_RESET_IMPACTED_CONTEXTS 34445/*46* Pack the API structures to enforce binary compatibility47* Align to 8 bytes for optimal performance48*/49#pragma pack(push, 8)5051/*52* Engine indexes.53*/54#define VPU_ENGINE_COMPUTE 055#define VPU_ENGINE_NB 15657/*58* VPU status values.59*/60#define VPU_JSM_STATUS_SUCCESS 0x0U61#define VPU_JSM_STATUS_PARSING_ERR 0x1U62#define VPU_JSM_STATUS_PROCESSING_ERR 0x2U63#define VPU_JSM_STATUS_PREEMPTED 0x3U64#define VPU_JSM_STATUS_ABORTED 0x4U65#define VPU_JSM_STATUS_USER_CTX_VIOL_ERR 0x5U66#define VPU_JSM_STATUS_GLOBAL_CTX_VIOL_ERR 0x6U67#define VPU_JSM_STATUS_MVNCI_WRONG_INPUT_FORMAT 0x7U68#define VPU_JSM_STATUS_MVNCI_UNSUPPORTED_NETWORK_ELEMENT 0x8U69#define VPU_JSM_STATUS_MVNCI_INVALID_HANDLE 0x9U70#define VPU_JSM_STATUS_MVNCI_OUT_OF_RESOURCES 0xAU71#define VPU_JSM_STATUS_MVNCI_NOT_IMPLEMENTED 0xBU72#define VPU_JSM_STATUS_MVNCI_INTERNAL_ERROR 0xCU73/* Job status returned when the job was preempted mid-inference */74#define VPU_JSM_STATUS_PREEMPTED_MID_INFERENCE 0xDU75#define VPU_JSM_STATUS_MVNCI_CONTEXT_VIOLATION_HW 0xEU7677/*78* Host <-> VPU IPC channels.79* ASYNC commands use a high priority channel, other messages use low-priority ones.80*/81#define VPU_IPC_CHAN_ASYNC_CMD 082#define VPU_IPC_CHAN_GEN_CMD 1083#define VPU_IPC_CHAN_JOB_RET 118485/*86* Job flags bit masks.87*/88enum {89/*90* Null submission mask.91* When set, batch buffer's commands are not processed but returned as92* successful immediately, except fences and timestamps.93* When cleared, batch buffer's commands are processed normally.94* Used for testing and profiling purposes.95*/96VPU_JOB_FLAGS_NULL_SUBMISSION_MASK = (1 << 0U),97/*98* Inline command mask.99* When set, the object in job queue is an inline command (see struct vpu_inline_cmd below).100* When cleared, the object in job queue is a job (see struct vpu_job_queue_entry below).101*/102VPU_JOB_FLAGS_INLINE_CMD_MASK = (1 << 1U),103/*104* VPU private data mask.105* Reserved for the VPU to store private data about the job (or inline command)106* while being processed.107*/108VPU_JOB_FLAGS_PRIVATE_DATA_MASK = 0xFFFF0000U109};110111/*112* Job queue flags bit masks.113*/114enum {115/*116* No job done notification mask.117* When set, indicates that no job done notification should be sent for any118* job from this queue. When cleared, indicates that job done notification119* should be sent for every job completed from this queue.120*/121VPU_JOB_QUEUE_FLAGS_NO_JOB_DONE_MASK = (1 << 0U),122/*123* Native fence usage mask.124* When set, indicates that job queue uses native fences (as inline commands125* in job queue). Such queues may also use legacy fences (as commands in batch buffers).126* When cleared, indicates the job queue only uses legacy fences.127* NOTES:128* 1. For queues using native fences, VPU expects that all jobs in the queue129* are immediately followed by an inline command object. This object is expected130* to be a fence signal command in most cases, but can also be a NOP in case the host131* does not need per-job fence signalling. Other inline commands objects can be132* inserted between "job and inline command" pairs.133* 2. Native fence queues are only supported on VPU 40xx onwards.134*/135VPU_JOB_QUEUE_FLAGS_USE_NATIVE_FENCE_MASK = (1 << 1U),136137/*138* Enable turbo mode for testing NPU performance; not recommended for regular usage.139*/140VPU_JOB_QUEUE_FLAGS_TURBO_MODE = (1 << 2U)141};142143/*144* Max length (including trailing NULL char) of trace entity name (e.g., the145* name of a logging destination or a loggable HW component).146*/147#define VPU_TRACE_ENTITY_NAME_MAX_LEN 32148149/*150* Max length (including trailing NULL char) of a dyndbg command.151*152* NOTE: 96 is used so that the size of 'struct vpu_ipc_msg' in the JSM API is153* 128 bytes (multiple of 64 bytes, the cache line size).154*/155#define VPU_DYNDBG_CMD_MAX_LEN 96156157/*158* For HWS command queue scheduling, we can prioritise command queues inside the159* same process with a relative in-process priority. Valid values for relative160* priority are given below - max and min.161*/162#define VPU_HWS_COMMAND_QUEUE_MAX_IN_PROCESS_PRIORITY 7163#define VPU_HWS_COMMAND_QUEUE_MIN_IN_PROCESS_PRIORITY -7164165/*166* For HWS priority scheduling, we can have multiple realtime priority bands.167* They are numbered 0 to a MAX.168*/169#define VPU_HWS_MAX_REALTIME_PRIORITY_LEVEL 31U170171/*172* vpu_jsm_engine_reset_context flag definitions173*/174#define VPU_ENGINE_RESET_CONTEXT_FLAG_COLLATERAL_DAMAGE_MASK BIT(0)175#define VPU_ENGINE_RESET_CONTEXT_HANG_PRIMARY_CAUSE 0176#define VPU_ENGINE_RESET_CONTEXT_COLLATERAL_DAMAGE 1177178/*179* Invalid command queue handle identifier. Applies to cmdq_id and cmdq_group180* in this API.181*/182#define VPU_HWS_INVALID_CMDQ_HANDLE 0ULL183184/*185* Inline commands types.186*/187/*188* NOP.189* VPU does nothing other than consuming the inline command object.190*/191#define VPU_INLINE_CMD_TYPE_NOP 0x0192/*193* Fence wait.194* VPU waits for the fence current value to reach monitored value.195* Fence wait operations are executed upon job dispatching. While waiting for196* the fence to be satisfied, VPU blocks fetching of the next objects in the queue.197* Jobs present in the queue prior to the fence wait object may be processed198* concurrently.199*/200#define VPU_INLINE_CMD_TYPE_FENCE_WAIT 0x1201/*202* Fence signal.203* VPU sets the fence current value to the provided value. If new current value204* is equal to or higher than monitored value, VPU sends fence signalled notification205* to the host. Fence signal operations are executed upon completion of all the jobs206* present in the queue prior to them, and in-order relative to each other in the queue.207* But jobs in-between them may be processed concurrently and may complete out-of-order.208*/209#define VPU_INLINE_CMD_TYPE_FENCE_SIGNAL 0x2210211/*212* Job scheduling priority bands for both hardware scheduling and OS scheduling.213*/214enum vpu_job_scheduling_priority_band {215VPU_JOB_SCHEDULING_PRIORITY_BAND_IDLE = 0,216VPU_JOB_SCHEDULING_PRIORITY_BAND_NORMAL = 1,217VPU_JOB_SCHEDULING_PRIORITY_BAND_FOCUS = 2,218VPU_JOB_SCHEDULING_PRIORITY_BAND_REALTIME = 3,219VPU_JOB_SCHEDULING_PRIORITY_BAND_COUNT = 4,220};221222/*223* Job format.224* Jobs defines the actual workloads to be executed by a given engine.225*/226struct vpu_job_queue_entry {227/**< Address of VPU commands batch buffer */228u64 batch_buf_addr;229/**< Job ID */230u32 job_id;231/**< Flags bit field, see VPU_JOB_FLAGS_* above */232u32 flags;233/**234* Doorbell ring timestamp taken by KMD from SoC's global system clock, in235* microseconds. NPU can convert this value to its own fixed clock's timebase,236* to match other profiling timestamps.237*/238u64 doorbell_timestamp;239/**< Extra id for job tracking, used only in the firmware perf traces */240u64 host_tracking_id;241/**< Address of the primary preemption buffer to use for this job */242u64 primary_preempt_buf_addr;243/**< Size of the primary preemption buffer to use for this job */244u32 primary_preempt_buf_size;245/**< Size of secondary preemption buffer to use for this job */246u32 secondary_preempt_buf_size;247/**< Address of secondary preemption buffer to use for this job */248u64 secondary_preempt_buf_addr;249u64 reserved_0;250};251252/*253* Inline command format.254* Inline commands are the commands executed at scheduler level (typically,255* synchronization directives). Inline command and job objects must be of256* the same size and have flags field at same offset.257*/258struct vpu_inline_cmd {259u64 reserved_0;260/* Inline command type, see VPU_INLINE_CMD_TYPE_* defines. */261u32 type;262/* Flags bit field, see VPU_JOB_FLAGS_* above. */263u32 flags;264/* Inline command payload. Depends on inline command type. */265union {266/* Fence (wait and signal) commands' payload. */267struct {268/* Fence object handle. */269u64 fence_handle;270/* User VA of the current fence value. */271u64 current_value_va;272/* User VA of the monitored fence value (read-only). */273u64 monitored_value_va;274/* Value to wait for or write in fence location. */275u64 value;276/* User VA of the log buffer in which to add log entry on completion. */277u64 log_buffer_va;278/* NPU private data. */279u64 npu_private_data;280} fence;281/* Other commands do not have a payload. */282/* Payload definition for future inline commands can be inserted here. */283u64 reserved_1[6];284} payload;285};286287/*288* Job queue slots can be populated either with job objects or inline command objects.289*/290union vpu_jobq_slot {291struct vpu_job_queue_entry job;292struct vpu_inline_cmd inline_cmd;293};294295/*296* Job queue control registers.297*/298struct vpu_job_queue_header {299u32 engine_idx;300u32 head;301u32 tail;302u32 flags;303/* Set to 1 to indicate priority_band field is valid */304u32 priority_band_valid;305/*306* Priority for the work of this job queue, valid only if the HWS is NOT used307* and the `priority_band_valid` is set to 1. It is applied only during308* the VPU_JSM_MSG_REGISTER_DB message processing.309* The device firmware might use the `priority_band` to optimize the power310* management logic, but it will not affect the order of jobs.311* Available priority bands: @see enum vpu_job_scheduling_priority_band312*/313u32 priority_band;314/* Inside realtime band assigns a further priority, limited to 0..31 range */315u32 realtime_priority_level;316u32 reserved_0[9];317};318319/*320* Job queue format.321*/322struct vpu_job_queue {323struct vpu_job_queue_header header;324union vpu_jobq_slot slot[];325};326327/**328* Logging entity types.329*330* This enum defines the different types of entities involved in logging.331*/332enum vpu_trace_entity_type {333/** Logging destination (entity where logs can be stored / printed). */334VPU_TRACE_ENTITY_TYPE_DESTINATION = 1,335/** Loggable HW component (HW entity that can be logged). */336VPU_TRACE_ENTITY_TYPE_HW_COMPONENT = 2,337};338339/*340* HWS specific log buffer header details.341* Total size is 32 bytes.342*/343struct vpu_hws_log_buffer_header {344/* Written by VPU after adding a log entry. Initialised by host to 0. */345u32 first_free_entry_index;346/* Incremented by VPU every time the VPU writes the 0th entry; initialised by host to 0. */347u32 wraparound_count;348/*349* This is the number of buffers that can be stored in the log buffer provided by the host.350* It is written by host before passing buffer to VPU. VPU should consider it read-only.351*/352u64 num_of_entries;353u64 reserved[2];354};355356/*357* HWS specific log buffer entry details.358* Total size is 32 bytes.359*/360struct vpu_hws_log_buffer_entry {361/* VPU timestamp must be an invariant timer tick (not impacted by DVFS) */362u64 vpu_timestamp;363/*364* Operation type:365* 0 - context state change366* 1 - queue new work367* 2 - queue unwait sync object368* 3 - queue no more work369* 4 - queue wait sync object370*/371u32 operation_type;372u32 reserved;373/* Operation data depends on operation type */374u64 operation_data[2];375};376377/* Native fence log buffer types. */378enum vpu_hws_native_fence_log_type {379VPU_HWS_NATIVE_FENCE_LOG_TYPE_WAITS = 1,380VPU_HWS_NATIVE_FENCE_LOG_TYPE_SIGNALS = 2381};382383/* HWS native fence log buffer header. */384struct vpu_hws_native_fence_log_header {385union {386struct {387/* Index of the first free entry in buffer. */388u32 first_free_entry_idx;389/* Incremented each time NPU wraps around the buffer to write next entry. */390u32 wraparound_count;391};392/* Field allowing atomic update of both fields above. */393u64 atomic_wraparound_and_entry_idx;394};395/* Log buffer type, see enum vpu_hws_native_fence_log_type. */396u64 type;397/* Allocated number of entries in the log buffer. */398u64 entry_nb;399u64 reserved[2];400};401402/* Native fence log operation types. */403enum vpu_hws_native_fence_log_op {404VPU_HWS_NATIVE_FENCE_LOG_OP_SIGNAL_EXECUTED = 0,405VPU_HWS_NATIVE_FENCE_LOG_OP_WAIT_UNBLOCKED = 1406};407408/* HWS native fence log entry. */409struct vpu_hws_native_fence_log_entry {410/* Newly signaled/unblocked fence value. */411u64 fence_value;412/* Native fence object handle to which this operation belongs. */413u64 fence_handle;414/* Operation type, see enum vpu_hws_native_fence_log_op. */415u64 op_type;416u64 reserved_0;417/*418* VPU_HWS_NATIVE_FENCE_LOG_OP_WAIT_UNBLOCKED only: Timestamp at which fence419* wait was started (in NPU SysTime).420*/421u64 fence_wait_start_ts;422u64 reserved_1;423/* Timestamp at which fence operation was completed (in NPU SysTime). */424u64 fence_end_ts;425};426427/* Native fence log buffer. */428struct vpu_hws_native_fence_log_buffer {429struct vpu_hws_native_fence_log_header header;430struct vpu_hws_native_fence_log_entry entry[];431};432433/*434* Host <-> VPU IPC messages types.435*/436enum vpu_ipc_msg_type {437VPU_JSM_MSG_UNKNOWN = 0xFFFFFFFF,438439/* IPC Host -> Device, Async commands */440VPU_JSM_MSG_ASYNC_CMD = 0x1100,441VPU_JSM_MSG_ENGINE_RESET = VPU_JSM_MSG_ASYNC_CMD,442/**443* Preempt engine. The NPU stops (preempts) all the jobs currently444* executing on the target engine making the engine become idle and ready to445* execute new jobs.446* NOTE: The NPU does not remove unstarted jobs (if any) from job queues of447* the target engine, but it stops processing them (until the queue doorbell448* is rung again); the host is responsible to reset the job queue, either449* after preemption or when resubmitting jobs to the queue.450*/451VPU_JSM_MSG_ENGINE_PREEMPT = 0x1101,452VPU_JSM_MSG_REGISTER_DB = 0x1102,453VPU_JSM_MSG_UNREGISTER_DB = 0x1103,454VPU_JSM_MSG_QUERY_ENGINE_HB = 0x1104,455VPU_JSM_MSG_GET_POWER_LEVEL_COUNT = 0x1105,456VPU_JSM_MSG_GET_POWER_LEVEL = 0x1106,457VPU_JSM_MSG_SET_POWER_LEVEL = 0x1107,458/* @deprecated */459VPU_JSM_MSG_METRIC_STREAMER_OPEN = 0x1108,460/* @deprecated */461VPU_JSM_MSG_METRIC_STREAMER_CLOSE = 0x1109,462/** Configure logging (used to modify configuration passed in boot params). */463VPU_JSM_MSG_TRACE_SET_CONFIG = 0x110a,464/** Return current logging configuration. */465VPU_JSM_MSG_TRACE_GET_CONFIG = 0x110b,466/**467* Get masks of destinations and HW components supported by the firmware468* (may vary between HW generations and FW compile469* time configurations)470*/471VPU_JSM_MSG_TRACE_GET_CAPABILITY = 0x110c,472/** Get the name of a destination or HW component. */473VPU_JSM_MSG_TRACE_GET_NAME = 0x110d,474/**475* Release resource associated with host ssid . All jobs that belong to the host_ssid476* aborted and removed from internal scheduling queues. All doorbells assigned477* to the host_ssid are unregistered and any internal FW resources belonging to478* the host_ssid are released.479*/480VPU_JSM_MSG_SSID_RELEASE = 0x110e,481/**482* Start collecting metric data.483* @see vpu_jsm_metric_streamer_start484*/485VPU_JSM_MSG_METRIC_STREAMER_START = 0x110f,486/**487* Stop collecting metric data. This command will return success if it is called488* for a metric stream that has already been stopped or was never started.489* @see vpu_jsm_metric_streamer_stop490*/491VPU_JSM_MSG_METRIC_STREAMER_STOP = 0x1110,492/**493* Update current and next buffer for metric data collection. This command can494* also be used to request information about the number of collected samples495* and the amount of data written to the buffer.496* @see vpu_jsm_metric_streamer_update497*/498VPU_JSM_MSG_METRIC_STREAMER_UPDATE = 0x1111,499/**500* Request description of selected metric groups and metric counters within501* each group. The VPU will write the description of groups and counters to502* the buffer specified in the command structure.503* @see vpu_jsm_metric_streamer_start504*/505VPU_JSM_MSG_METRIC_STREAMER_INFO = 0x1112,506/** Control command: Priority band setup */507VPU_JSM_MSG_SET_PRIORITY_BAND_SETUP = 0x1113,508/** Control command: Create command queue */509VPU_JSM_MSG_CREATE_CMD_QUEUE = 0x1114,510/** Control command: Destroy command queue */511VPU_JSM_MSG_DESTROY_CMD_QUEUE = 0x1115,512/** Control command: Set context scheduling properties */513VPU_JSM_MSG_SET_CONTEXT_SCHED_PROPERTIES = 0x1116,514/*515* Register a doorbell to notify VPU of new work. The doorbell may later be516* deallocated or reassigned to another context.517*/518VPU_JSM_MSG_HWS_REGISTER_DB = 0x1117,519/** Control command: Log buffer setting */520VPU_JSM_MSG_HWS_SET_SCHEDULING_LOG = 0x1118,521/* Control command: Suspend command queue. */522VPU_JSM_MSG_HWS_SUSPEND_CMDQ = 0x1119,523/* Control command: Resume command queue */524VPU_JSM_MSG_HWS_RESUME_CMDQ = 0x111a,525/* Control command: Resume engine after reset */526VPU_JSM_MSG_HWS_ENGINE_RESUME = 0x111b,527/* Control command: Enable survivability/DCT mode */528VPU_JSM_MSG_DCT_ENABLE = 0x111c,529/* Control command: Disable survivability/DCT mode */530VPU_JSM_MSG_DCT_DISABLE = 0x111d,531/**532* Dump VPU state. To be used for debug purposes only.533* NOTE: Please introduce new ASYNC commands before this one. *534*/535VPU_JSM_MSG_STATE_DUMP = 0x11FF,536537/* IPC Host -> Device, General commands */538VPU_JSM_MSG_GENERAL_CMD = 0x1200,539VPU_JSM_MSG_BLOB_DEINIT_DEPRECATED = VPU_JSM_MSG_GENERAL_CMD,540/**541* Control dyndbg behavior by executing a dyndbg command; equivalent to542* Linux command: `echo '<dyndbg_cmd>' > <debugfs>/dynamic_debug/control`.543*/544VPU_JSM_MSG_DYNDBG_CONTROL = 0x1201,545/**546* Perform the save procedure for the D0i3 entry547*/548VPU_JSM_MSG_PWR_D0I3_ENTER = 0x1202,549550/* IPC Device -> Host, Job completion */551VPU_JSM_MSG_JOB_DONE = 0x2100,552/* IPC Device -> Host, Fence signalled */553VPU_JSM_MSG_NATIVE_FENCE_SIGNALLED = 0x2101,554555/* IPC Device -> Host, Async command completion */556VPU_JSM_MSG_ASYNC_CMD_DONE = 0x2200,557VPU_JSM_MSG_ENGINE_RESET_DONE = VPU_JSM_MSG_ASYNC_CMD_DONE,558VPU_JSM_MSG_ENGINE_PREEMPT_DONE = 0x2201,559VPU_JSM_MSG_REGISTER_DB_DONE = 0x2202,560VPU_JSM_MSG_UNREGISTER_DB_DONE = 0x2203,561VPU_JSM_MSG_QUERY_ENGINE_HB_DONE = 0x2204,562VPU_JSM_MSG_GET_POWER_LEVEL_COUNT_DONE = 0x2205,563VPU_JSM_MSG_GET_POWER_LEVEL_DONE = 0x2206,564VPU_JSM_MSG_SET_POWER_LEVEL_DONE = 0x2207,565/* @deprecated */566VPU_JSM_MSG_METRIC_STREAMER_OPEN_DONE = 0x2208,567/* @deprecated */568VPU_JSM_MSG_METRIC_STREAMER_CLOSE_DONE = 0x2209,569/** Response to VPU_JSM_MSG_TRACE_SET_CONFIG. */570VPU_JSM_MSG_TRACE_SET_CONFIG_RSP = 0x220a,571/** Response to VPU_JSM_MSG_TRACE_GET_CONFIG. */572VPU_JSM_MSG_TRACE_GET_CONFIG_RSP = 0x220b,573/** Response to VPU_JSM_MSG_TRACE_GET_CAPABILITY. */574VPU_JSM_MSG_TRACE_GET_CAPABILITY_RSP = 0x220c,575/** Response to VPU_JSM_MSG_TRACE_GET_NAME. */576VPU_JSM_MSG_TRACE_GET_NAME_RSP = 0x220d,577/** Response to VPU_JSM_MSG_SSID_RELEASE. */578VPU_JSM_MSG_SSID_RELEASE_DONE = 0x220e,579/**580* Response to VPU_JSM_MSG_METRIC_STREAMER_START.581* VPU will return an error result if metric collection cannot be started,582* e.g. when the specified metric mask is invalid.583* @see vpu_jsm_metric_streamer_done584*/585VPU_JSM_MSG_METRIC_STREAMER_START_DONE = 0x220f,586/**587* Response to VPU_JSM_MSG_METRIC_STREAMER_STOP.588* Returns information about collected metric data.589* @see vpu_jsm_metric_streamer_done590*/591VPU_JSM_MSG_METRIC_STREAMER_STOP_DONE = 0x2210,592/**593* Response to VPU_JSM_MSG_METRIC_STREAMER_UPDATE.594* Returns information about collected metric data.595* @see vpu_jsm_metric_streamer_done596*/597VPU_JSM_MSG_METRIC_STREAMER_UPDATE_DONE = 0x2211,598/**599* Response to VPU_JSM_MSG_METRIC_STREAMER_INFO.600* Returns a description of the metric groups and metric counters.601* @see vpu_jsm_metric_streamer_done602*/603VPU_JSM_MSG_METRIC_STREAMER_INFO_DONE = 0x2212,604/**605* Asynchronous event sent from the VPU to the host either when the current606* metric buffer is full or when the VPU has collected a multiple of607* @notify_sample_count samples as indicated through the start command608* (VPU_JSM_MSG_METRIC_STREAMER_START). Returns information about collected609* metric data.610* @see vpu_jsm_metric_streamer_done611*/612VPU_JSM_MSG_METRIC_STREAMER_NOTIFICATION = 0x2213,613/** Response to control command: Priority band setup */614VPU_JSM_MSG_SET_PRIORITY_BAND_SETUP_RSP = 0x2214,615/** Response to control command: Create command queue */616VPU_JSM_MSG_CREATE_CMD_QUEUE_RSP = 0x2215,617/** Response to control command: Destroy command queue */618VPU_JSM_MSG_DESTROY_CMD_QUEUE_RSP = 0x2216,619/** Response to control command: Set context scheduling properties */620VPU_JSM_MSG_SET_CONTEXT_SCHED_PROPERTIES_RSP = 0x2217,621/** Response to control command: Log buffer setting */622VPU_JSM_MSG_HWS_SET_SCHEDULING_LOG_RSP = 0x2218,623/* IPC Device -> Host, HWS notify index entry of log buffer written */624VPU_JSM_MSG_HWS_SCHEDULING_LOG_NOTIFICATION = 0x2219,625/* IPC Device -> Host, HWS completion of a context suspend request */626VPU_JSM_MSG_HWS_SUSPEND_CMDQ_DONE = 0x221a,627/* Response to control command: Resume command queue */628VPU_JSM_MSG_HWS_RESUME_CMDQ_RSP = 0x221b,629/* Response to control command: Resume engine command response */630VPU_JSM_MSG_HWS_RESUME_ENGINE_DONE = 0x221c,631/* Response to control command: Enable survivability/DCT mode */632VPU_JSM_MSG_DCT_ENABLE_DONE = 0x221d,633/* Response to control command: Disable survivability/DCT mode */634VPU_JSM_MSG_DCT_DISABLE_DONE = 0x221e,635/**636* Response to state dump control command.637* NOTE: Please introduce new ASYNC responses before this one. *638*/639VPU_JSM_MSG_STATE_DUMP_RSP = 0x22FF,640641/* IPC Device -> Host, General command completion */642VPU_JSM_MSG_GENERAL_CMD_DONE = 0x2300,643VPU_JSM_MSG_BLOB_DEINIT_DONE = VPU_JSM_MSG_GENERAL_CMD_DONE,644/** Response to VPU_JSM_MSG_DYNDBG_CONTROL. */645VPU_JSM_MSG_DYNDBG_CONTROL_RSP = 0x2301,646/**647* Acknowledgment of completion of the save procedure initiated by648* VPU_JSM_MSG_PWR_D0I3_ENTER649*/650VPU_JSM_MSG_PWR_D0I3_ENTER_DONE = 0x2302,651};652653enum vpu_ipc_msg_status { VPU_JSM_MSG_FREE, VPU_JSM_MSG_ALLOCATED };654655/*656* Host <-> LRT IPC message payload definitions657*/658struct vpu_ipc_msg_payload_engine_reset {659/* Engine to be reset. */660u32 engine_idx;661/* Reserved */662u32 reserved_0;663};664665struct vpu_ipc_msg_payload_engine_preempt {666/* Engine to be preempted. */667u32 engine_idx;668/* ID of the preemption request. */669u32 preempt_id;670};671672/*673* @brief Register doorbell command structure.674* This structure supports doorbell registration for only OS scheduling.675* @see VPU_JSM_MSG_REGISTER_DB676*/677struct vpu_ipc_msg_payload_register_db {678/* Index of the doorbell to register. */679u32 db_idx;680/* Reserved */681u32 reserved_0;682/* Virtual address in Global GTT pointing to the start of job queue. */683u64 jobq_base;684/* Size of the job queue in bytes. */685u32 jobq_size;686/* Host sub-stream ID for the context assigned to the doorbell. */687u32 host_ssid;688};689690/**691* @brief Unregister doorbell command structure.692* Request structure to unregister a doorbell for both HW and OS scheduling.693* @see VPU_JSM_MSG_UNREGISTER_DB694*/695struct vpu_ipc_msg_payload_unregister_db {696/* Index of the doorbell to unregister. */697u32 db_idx;698/* Reserved */699u32 reserved_0;700};701702struct vpu_ipc_msg_payload_query_engine_hb {703/* Engine to return heartbeat value. */704u32 engine_idx;705/* Reserved */706u32 reserved_0;707};708709struct vpu_ipc_msg_payload_power_level {710/**711* Requested power level. The power level value is in the712* range [0, power_level_count-1] where power_level_count713* is the number of available power levels as returned by714* the get power level count command. A power level of 0715* corresponds to the maximum possible power level, while716* power_level_count-1 corresponds to the minimum possible717* power level. Values outside of this range are not718* considered to be valid.719*/720u32 power_level;721/* Reserved */722u32 reserved_0;723};724725struct vpu_ipc_msg_payload_ssid_release {726/* Host sub-stream ID for the context to be released. */727u32 host_ssid;728/* Reserved */729u32 reserved_0;730};731732/**733* @brief Metric streamer start command structure.734* This structure is also used with VPU_JSM_MSG_METRIC_STREAMER_INFO to request metric735* groups and metric counters description from the firmware.736* @see VPU_JSM_MSG_METRIC_STREAMER_START737* @see VPU_JSM_MSG_METRIC_STREAMER_INFO738*/739struct vpu_jsm_metric_streamer_start {740/**741* Bitmask to select the desired metric groups.742* A metric group can belong only to one metric streamer instance at a time.743* Since each metric streamer instance has a unique set of metric groups, it744* can also identify a metric streamer instance if more than one instance was745* started. If the VPU device does not support multiple metric streamer instances,746* then VPU_JSM_MSG_METRIC_STREAMER_START will return an error even if the second747* instance has different groups to the first.748*/749u64 metric_group_mask;750/** Sampling rate in nanoseconds. */751u64 sampling_rate;752/**753* If > 0 the VPU will send a VPU_JSM_MSG_METRIC_STREAMER_NOTIFICATION message754* after every @notify_sample_count samples is collected or dropped by the VPU.755* If set to UINT_MAX the VPU will only generate a notification when the metric756* buffer is full. If set to 0 the VPU will never generate a notification.757*/758u32 notify_sample_count;759u32 reserved_0;760/**761* Address and size of the buffer where the VPU will write metric data. The762* VPU writes all counters from enabled metric groups one after another. If763* there is no space left to write data at the next sample period the VPU764* will switch to the next buffer (@see next_buffer_addr) and will optionally765* send a notification to the host driver if @notify_sample_count is non-zero.766* If @next_buffer_addr is NULL the VPU will stop collecting metric data.767*/768u64 buffer_addr;769u64 buffer_size;770/**771* Address and size of the next buffer to write metric data to after the initial772* buffer is full. If the address is NULL the VPU will stop collecting metric773* data.774*/775u64 next_buffer_addr;776u64 next_buffer_size;777};778779/**780* @brief Metric streamer stop command structure.781* @see VPU_JSM_MSG_METRIC_STREAMER_STOP782*/783struct vpu_jsm_metric_streamer_stop {784/** Bitmask to select the desired metric groups. */785u64 metric_group_mask;786};787788/**789* Provide VPU FW with buffers to write metric data.790* @see VPU_JSM_MSG_METRIC_STREAMER_UPDATE791*/792struct vpu_jsm_metric_streamer_update {793/** Metric group mask that identifies metric streamer instance. */794u64 metric_group_mask;795/**796* Address and size of the buffer where the VPU will write metric data.797* This member dictates how the update operation should perform:798* 1. client needs information about the number of collected samples and the799* amount of data written to the current buffer800* 2. client wants to switch to a new buffer801*802* Case 1. is identified by the buffer address being 0 or the same as the803* currently used buffer address. In this case the buffer size is ignored and804* the size of the current buffer is unchanged. The VPU will return an update805* in the vpu_jsm_metric_streamer_done structure. The internal writing position806* into the buffer is not changed.807*808* Case 2. is identified by the address being non-zero and differs from the809* current buffer address. The VPU will immediately switch data collection to810* the new buffer. Then the VPU will return an update in the811* vpu_jsm_metric_streamer_done structure.812*/813u64 buffer_addr;814u64 buffer_size;815/**816* Address and size of the next buffer to write metric data after the initial817* buffer is full. If the address is NULL the VPU will stop collecting metric818* data but will continue to record dropped samples.819*820* Note that there is a hazard possible if both buffer_addr and the next_buffer_addr821* are non-zero in same update request. It is the host's responsibility to ensure822* that both addresses make sense even if the VPU just switched to writing samples823* from the current to the next buffer.824*/825u64 next_buffer_addr;826u64 next_buffer_size;827};828829struct vpu_ipc_msg_payload_job_done {830/* Engine to which the job was submitted. */831u32 engine_idx;832/* Index of the doorbell to which the job was submitted */833u32 db_idx;834/* ID of the completed job */835u32 job_id;836/* Status of the completed job */837u32 job_status;838/* Host SSID */839u32 host_ssid;840/* Zero Padding */841u32 reserved_0;842/* Command queue id */843u64 cmdq_id;844};845846/*847* Notification message upon native fence signalling.848* @see VPU_JSM_MSG_NATIVE_FENCE_SIGNALLED849*/850struct vpu_ipc_msg_payload_native_fence_signalled {851/* Engine ID. */852u32 engine_idx;853/* Host SSID. */854u32 host_ssid;855/* CMDQ ID */856u64 cmdq_id;857/* Fence object handle. */858u64 fence_handle;859};860861struct vpu_jsm_engine_reset_context {862/* Host SSID */863u32 host_ssid;864/* Zero Padding */865u32 reserved_0;866/* Command queue id */867u64 cmdq_id;868/* See VPU_ENGINE_RESET_CONTEXT_* defines */869u64 flags;870};871872struct vpu_ipc_msg_payload_engine_reset_done {873/* Engine ordinal */874u32 engine_idx;875/* Number of impacted contexts */876u32 num_impacted_contexts;877/* Array of impacted command queue ids and their flags */878struct vpu_jsm_engine_reset_context879impacted_contexts[VPU_MAX_ENGINE_RESET_IMPACTED_CONTEXTS];880};881882struct vpu_ipc_msg_payload_engine_preempt_done {883/* Engine preempted. */884u32 engine_idx;885/* ID of the preemption request. */886u32 preempt_id;887};888889/**890* Response structure for register doorbell command for both OS891* and HW scheduling.892* @see VPU_JSM_MSG_REGISTER_DB893* @see VPU_JSM_MSG_HWS_REGISTER_DB894*/895struct vpu_ipc_msg_payload_register_db_done {896/* Index of the registered doorbell. */897u32 db_idx;898/* Reserved */899u32 reserved_0;900};901902/**903* Response structure for unregister doorbell command for both OS904* and HW scheduling.905* @see VPU_JSM_MSG_UNREGISTER_DB906*/907struct vpu_ipc_msg_payload_unregister_db_done {908/* Index of the unregistered doorbell. */909u32 db_idx;910/* Reserved */911u32 reserved_0;912};913914struct vpu_ipc_msg_payload_query_engine_hb_done {915/* Engine returning heartbeat value. */916u32 engine_idx;917/* Reserved */918u32 reserved_0;919/* Heartbeat value. */920u64 heartbeat;921};922923struct vpu_ipc_msg_payload_get_power_level_count_done {924/**925* Number of supported power levels. The maximum possible926* value of power_level_count is 16 but this may vary across927* implementations.928*/929u32 power_level_count;930/* Reserved */931u32 reserved_0;932/**933* Power consumption limit for each supported power level in934* [0-100%] range relative to power level 0.935*/936u8 power_limit[16];937};938939/* HWS priority band setup request / response */940struct vpu_ipc_msg_payload_hws_priority_band_setup {941/*942* Grace period in 100ns units when preempting another priority band for943* this priority band944*/945u32 grace_period[VPU_HWS_NUM_PRIORITY_BANDS];946/*947* Default quantum in 100ns units for scheduling across processes948* within a priority band949* Minimum value supported by NPU is 1ms (10000 in 100ns units).950*/951u32 process_quantum[VPU_HWS_NUM_PRIORITY_BANDS];952/*953* Default grace period in 100ns units for processes that preempt each954* other within a priority band955*/956u32 process_grace_period[VPU_HWS_NUM_PRIORITY_BANDS];957/*958* For normal priority band, specifies the target VPU percentage959* in situations when it's starved by the focus band.960*/961u32 normal_band_percentage;962/*963* TDR timeout value in milliseconds. Default value of 0 meaning no timeout.964*/965u32 tdr_timeout;966};967968/*969* @brief HWS create command queue request.970* Host will create a command queue via this command.971* Note: Cmdq group is a handle of an object which972* may contain one or more command queues.973* @see VPU_JSM_MSG_CREATE_CMD_QUEUE974* @see VPU_JSM_MSG_CREATE_CMD_QUEUE_RSP975*/976struct vpu_ipc_msg_payload_hws_create_cmdq {977/* Process id */978u64 process_id;979/* Host SSID */980u32 host_ssid;981/* Engine for which queue is being created */982u32 engine_idx;983/* Cmdq group: only used for HWS logging of state changes */984u64 cmdq_group;985/* Command queue id */986u64 cmdq_id;987/* Command queue base */988u64 cmdq_base;989/* Command queue size */990u32 cmdq_size;991/* Zero padding */992u32 reserved_0;993};994995/*996* @brief HWS create command queue response.997* @see VPU_JSM_MSG_CREATE_CMD_QUEUE998* @see VPU_JSM_MSG_CREATE_CMD_QUEUE_RSP999*/1000struct vpu_ipc_msg_payload_hws_create_cmdq_rsp {1001/* Process id */1002u64 process_id;1003/* Host SSID */1004u32 host_ssid;1005/* Engine for which queue is being created */1006u32 engine_idx;1007/* Command queue group */1008u64 cmdq_group;1009/* Command queue id */1010u64 cmdq_id;1011};10121013/* HWS destroy command queue request / response */1014struct vpu_ipc_msg_payload_hws_destroy_cmdq {1015/* Host SSID */1016u32 host_ssid;1017/* Zero Padding */1018u32 reserved;1019/* Command queue id */1020u64 cmdq_id;1021};10221023/* HWS set context scheduling properties request / response */1024struct vpu_ipc_msg_payload_hws_set_context_sched_properties {1025/* Host SSID */1026u32 host_ssid;1027/* Zero Padding */1028u32 reserved_0;1029/* Command queue id */1030u64 cmdq_id;1031/*1032* Priority band to assign to work of this context.1033* Available priority bands: @see enum vpu_job_scheduling_priority_band1034*/1035u32 priority_band;1036/* Inside realtime band assigns a further priority */1037u32 realtime_priority_level;1038/* Priority relative to other contexts in the same process */1039s32 in_process_priority;1040/* Zero padding / Reserved */1041u32 reserved_1;1042/*1043* Context quantum relative to other contexts of same priority in the same process1044* Minimum value supported by NPU is 1ms (10000 in 100ns units).1045*/1046u64 context_quantum;1047/* Grace period when preempting context of the same priority within the same process */1048u64 grace_period_same_priority;1049/* Grace period when preempting context of a lower priority within the same process */1050u64 grace_period_lower_priority;1051};10521053/*1054* @brief Register doorbell command structure.1055* This structure supports doorbell registration for both HW and OS scheduling.1056* Note: Queue base and size are added here so that the same structure can be used for1057* OS scheduling and HW scheduling. For OS scheduling, cmdq_id will be ignored1058* and cmdq_base and cmdq_size will be used. For HW scheduling, cmdq_base and cmdq_size will be1059* ignored and cmdq_id is used.1060* @see VPU_JSM_MSG_HWS_REGISTER_DB1061*/1062struct vpu_jsm_hws_register_db {1063/* Index of the doorbell to register. */1064u32 db_id;1065/* Host sub-stream ID for the context assigned to the doorbell. */1066u32 host_ssid;1067/* ID of the command queue associated with the doorbell. */1068u64 cmdq_id;1069/* Virtual address pointing to the start of command queue. */1070u64 cmdq_base;1071/* Size of the command queue in bytes. */1072u64 cmdq_size;1073};10741075/*1076* @brief Structure to set another buffer to be used for scheduling-related logging.1077* The size of the logging buffer and the number of entries is defined as part of the1078* buffer itself as described next.1079* The log buffer received from the host is made up of;1080* - header: 32 bytes in size, as shown in 'struct vpu_hws_log_buffer_header'.1081* The header contains the number of log entries in the buffer.1082* - log entry: 0 to n-1, each log entry is 32 bytes in size, as shown in1083* 'struct vpu_hws_log_buffer_entry'.1084* The entry contains the VPU timestamp, operation type and data.1085* The host should provide the notify index value of log buffer to VPU. This is a1086* value defined within the log buffer and when written to will generate the1087* scheduling log notification.1088* The host should set engine_idx and vpu_log_buffer_va to 0 to disable logging1089* for a particular engine.1090* VPU will handle one log buffer for each of supported engines.1091* VPU should allow the logging to consume one host_ssid.1092* @see VPU_JSM_MSG_HWS_SET_SCHEDULING_LOG1093* @see VPU_JSM_MSG_HWS_SET_SCHEDULING_LOG_RSP1094* @see VPU_JSM_MSG_HWS_SCHEDULING_LOG_NOTIFICATION1095*/1096struct vpu_ipc_msg_payload_hws_set_scheduling_log {1097/* Engine ordinal */1098u32 engine_idx;1099/* Host SSID */1100u32 host_ssid;1101/*1102* VPU log buffer virtual address.1103* Set to 0 to disable logging for this engine.1104*/1105u64 vpu_log_buffer_va;1106/*1107* Notify index of log buffer. VPU_JSM_MSG_HWS_SCHEDULING_LOG_NOTIFICATION1108* is generated when an event log is written to this index.1109*/1110u64 notify_index;1111/*1112* Field is now deprecated, will be removed when KMD is updated to support removal1113*/1114u32 enable_extra_events;1115/* Zero Padding */1116u32 reserved_0;1117};11181119/*1120* @brief The scheduling log notification is generated by VPU when it writes1121* an event into the log buffer at the notify_index. VPU notifies host with1122* VPU_JSM_MSG_HWS_SCHEDULING_LOG_NOTIFICATION. This is an asynchronous1123* message from VPU to host.1124* @see VPU_JSM_MSG_HWS_SCHEDULING_LOG_NOTIFICATION1125* @see VPU_JSM_MSG_HWS_SET_SCHEDULING_LOG1126*/1127struct vpu_ipc_msg_payload_hws_scheduling_log_notification {1128/* Engine ordinal */1129u32 engine_idx;1130/* Zero Padding */1131u32 reserved_0;1132};11331134/*1135* @brief HWS suspend command queue request and done structure.1136* Host will request the suspend of contexts and VPU will;1137* - Suspend all work on this context1138* - Preempt any running work1139* - Asynchronously perform the above and return success immediately once1140* all items above are started successfully1141* - Notify the host of completion of these operations via1142* VPU_JSM_MSG_HWS_SUSPEND_CMDQ_DONE1143* - Reject any other context operations on a context with an in-flight1144* suspend request running1145* Same structure used when VPU notifies host of completion of a context suspend1146* request. The ids and suspend fence value reported in this command will match1147* the one in the request from the host to suspend the context. Once suspend is1148* complete, VPU will not access any data relating to this command queue until1149* it is resumed.1150* @see VPU_JSM_MSG_HWS_SUSPEND_CMDQ1151* @see VPU_JSM_MSG_HWS_SUSPEND_CMDQ_DONE1152*/1153struct vpu_ipc_msg_payload_hws_suspend_cmdq {1154/* Host SSID */1155u32 host_ssid;1156/* Zero Padding */1157u32 reserved_0;1158/* Command queue id */1159u64 cmdq_id;1160/*1161* Suspend fence value - reported by the VPU suspend context1162* completed once suspend is complete.1163*/1164u64 suspend_fence_value;1165};11661167/*1168* @brief HWS Resume command queue request / response structure.1169* Host will request the resume of a context;1170* - VPU will resume all work on this context1171* - Scheduler will allow this context to be scheduled1172* @see VPU_JSM_MSG_HWS_RESUME_CMDQ1173* @see VPU_JSM_MSG_HWS_RESUME_CMDQ_RSP1174*/1175struct vpu_ipc_msg_payload_hws_resume_cmdq {1176/* Host SSID */1177u32 host_ssid;1178/* Zero Padding */1179u32 reserved_0;1180/* Command queue id */1181u64 cmdq_id;1182};11831184/*1185* @brief HWS Resume engine request / response structure.1186* After a HWS engine reset, all scheduling is stopped on VPU until a engine resume.1187* Host shall send this command to resume scheduling of any valid queue.1188* @see VPU_JSM_MSG_HWS_RESUME_ENGINE1189* @see VPU_JSM_MSG_HWS_RESUME_ENGINE_DONE1190*/1191struct vpu_ipc_msg_payload_hws_resume_engine {1192/* Engine to be resumed */1193u32 engine_idx;1194/* Reserved */1195u32 reserved_0;1196};11971198/**1199* Payload for VPU_JSM_MSG_TRACE_SET_CONFIG[_RSP] and1200* VPU_JSM_MSG_TRACE_GET_CONFIG_RSP messages.1201*1202* The payload is interpreted differently depending on the type of message:1203*1204* - For VPU_JSM_MSG_TRACE_SET_CONFIG, the payload specifies the desired1205* logging configuration to be set.1206*1207* - For VPU_JSM_MSG_TRACE_SET_CONFIG_RSP, the payload reports the logging1208* configuration that was set after a VPU_JSM_MSG_TRACE_SET_CONFIG request.1209* The host can compare this payload with the one it sent in the1210* VPU_JSM_MSG_TRACE_SET_CONFIG request to check whether or not the1211* configuration was set as desired.1212*1213* - VPU_JSM_MSG_TRACE_GET_CONFIG_RSP, the payload reports the current logging1214* configuration.1215*/1216struct vpu_ipc_msg_payload_trace_config {1217/**1218* Logging level (currently set or to be set); see 'mvLog_t' enum for1219* acceptable values. The specified logging level applies to all1220* destinations and HW components1221*/1222u32 trace_level;1223/**1224* Bitmask of logging destinations (currently enabled or to be enabled);1225* bitwise OR of values defined in logging_destination enum.1226*/1227u32 trace_destination_mask;1228/**1229* Bitmask of loggable HW components (currently enabled or to be enabled);1230* bitwise OR of values defined in loggable_hw_component enum.1231*/1232u64 trace_hw_component_mask;1233u64 reserved_0; /**< Reserved for future extensions. */1234};12351236/**1237* Payload for VPU_JSM_MSG_TRACE_GET_CAPABILITY_RSP messages.1238*/1239struct vpu_ipc_msg_payload_trace_capability_rsp {1240u32 trace_destination_mask; /**< Bitmask of supported logging destinations. */1241u32 reserved_0;1242u64 trace_hw_component_mask; /**< Bitmask of supported loggable HW components. */1243u64 reserved_1; /**< Reserved for future extensions. */1244};12451246/**1247* Payload for VPU_JSM_MSG_TRACE_GET_NAME requests.1248*/1249struct vpu_ipc_msg_payload_trace_get_name {1250/**1251* The type of the entity to query name for; see logging_entity_type for1252* possible values.1253*/1254u32 entity_type;1255u32 reserved_0;1256/**1257* The ID of the entity to query name for; possible values depends on the1258* entity type.1259*/1260u64 entity_id;1261};12621263/**1264* Payload for VPU_JSM_MSG_TRACE_GET_NAME_RSP responses.1265*/1266struct vpu_ipc_msg_payload_trace_get_name_rsp {1267/**1268* The type of the entity whose name was queried; see logging_entity_type1269* for possible values.1270*/1271u32 entity_type;1272u32 reserved_0;1273/**1274* The ID of the entity whose name was queried; possible values depends on1275* the entity type.1276*/1277u64 entity_id;1278/** Reserved for future extensions. */1279u64 reserved_1;1280/** The name of the entity. */1281char entity_name[VPU_TRACE_ENTITY_NAME_MAX_LEN];1282};12831284/**1285* Data sent from the VPU to the host in all metric streamer response messages1286* and in asynchronous notification.1287* @see VPU_JSM_MSG_METRIC_STREAMER_START_DONE1288* @see VPU_JSM_MSG_METRIC_STREAMER_STOP_DONE1289* @see VPU_JSM_MSG_METRIC_STREAMER_UPDATE_DONE1290* @see VPU_JSM_MSG_METRIC_STREAMER_INFO_DONE1291* @see VPU_JSM_MSG_METRIC_STREAMER_NOTIFICATION1292*/1293struct vpu_jsm_metric_streamer_done {1294/** Metric group mask that identifies metric streamer instance. */1295u64 metric_group_mask;1296/**1297* Size in bytes of single sample - total size of all enabled counters.1298* Some VPU implementations may align sample_size to more than 8 bytes.1299*/1300u32 sample_size;1301u32 reserved_0;1302/**1303* Number of samples collected since the metric streamer was started.1304* This will be 0 if the metric streamer was not started.1305*/1306u32 samples_collected;1307/**1308* Number of samples dropped since the metric streamer was started. This1309* is incremented every time the metric streamer is not able to write1310* collected samples because the current buffer is full and there is no1311* next buffer to switch to.1312*/1313u32 samples_dropped;1314/** Address of the buffer that contains the latest metric data. */1315u64 buffer_addr;1316/**1317* Number of bytes written into the metric data buffer. In response to the1318* VPU_JSM_MSG_METRIC_STREAMER_INFO request this field contains the size of1319* all group and counter descriptors. The size is updated even if the buffer1320* in the request was NULL or too small to hold descriptors of all counters1321*/1322u64 bytes_written;1323};13241325/**1326* Metric group description placed in the metric buffer after successful completion1327* of the VPU_JSM_MSG_METRIC_STREAMER_INFO command. This is followed by one or more1328* @vpu_jsm_metric_counter_descriptor records.1329* @see VPU_JSM_MSG_METRIC_STREAMER_INFO1330*/1331struct vpu_jsm_metric_group_descriptor {1332/**1333* Offset to the next metric group (8-byte aligned). If this offset is 0 this1334* is the last descriptor. The value of metric_info_size must be greater than1335* or equal to sizeof(struct vpu_jsm_metric_group_descriptor) + name_string_size1336* + description_string_size and must be 8-byte aligned.1337*/1338u32 next_metric_group_info_offset;1339/**1340* Offset to the first metric counter description record (8-byte aligned).1341* @see vpu_jsm_metric_counter_descriptor1342*/1343u32 next_metric_counter_info_offset;1344/** Index of the group. This corresponds to bit index in metric_group_mask. */1345u32 group_id;1346/** Number of counters in the metric group. */1347u32 num_counters;1348/** Data size for all counters, must be a multiple of 8 bytes.*/1349u32 metric_group_data_size;1350/**1351* Metric group domain number. Cannot use multiple, simultaneous metric groups1352* from the same domain.1353*/1354u32 domain;1355/**1356* Counter name string size. The string must include a null termination character.1357* The FW may use a fixed size name or send a different name for each counter.1358* If the VPU uses fixed size strings, all characters from the end of the name1359* to the of the fixed size character array must be zeroed.1360*/1361u32 name_string_size;1362/** Counter description string size, @see name_string_size */1363u32 description_string_size;1364u64 reserved_0;1365/**1366* Right after this structure, the VPU writes name and description of1367* the metric group.1368*/1369};13701371/**1372* Metric counter description, placed in the buffer after vpu_jsm_metric_group_descriptor.1373* @see VPU_JSM_MSG_METRIC_STREAMER_INFO1374*/1375struct vpu_jsm_metric_counter_descriptor {1376/**1377* Offset to the next counter in a group (8-byte aligned). If this offset is1378* 0 this is the last counter in the group.1379*/1380u32 next_metric_counter_info_offset;1381/**1382* Offset to the counter data from the start of samples in this metric group.1383* Note that metric_data_offset % metric_data_size must be 0.1384*/1385u32 metric_data_offset;1386/** Size of the metric counter data in bytes. */1387u32 metric_data_size;1388/** Metric type, see Level Zero API for definitions. */1389u32 tier;1390/** Metric type, see set_metric_type_t for definitions. */1391u32 metric_type;1392/** Metric type, see set_value_type_t for definitions. */1393u32 metric_value_type;1394/**1395* Counter name string size. The string must include a null termination character.1396* The FW may use a fixed size name or send a different name for each counter.1397* If the VPU uses fixed size strings, all characters from the end of the name1398* to the of the fixed size character array must be zeroed.1399*/1400u32 name_string_size;1401/** Counter description string size, @see name_string_size */1402u32 description_string_size;1403/** Counter component name string size, @see name_string_size */1404u32 component_string_size;1405/** Counter string size, @see name_string_size */1406u32 units_string_size;1407u64 reserved_0;1408/**1409* Right after this structure, the VPU writes name, description1410* component and unit strings.1411*/1412};14131414/**1415* Payload for VPU_JSM_MSG_DYNDBG_CONTROL requests.1416*1417* VPU_JSM_MSG_DYNDBG_CONTROL are used to control the VPU FW Dynamic Debug1418* feature, which allows developers to selectively enable / disable MVLOG_DEBUG1419* messages. This is equivalent to the Dynamic Debug functionality provided by1420* Linux1421* (https://www.kernel.org/doc/html/latest/admin-guide/dynamic-debug-howto.html)1422* The host can control Dynamic Debug behavior by sending dyndbg commands, which1423* have the same syntax as Linux1424* dyndbg commands.1425*1426* NOTE: in order for MVLOG_DEBUG messages to be actually printed, the host1427* still has to set the logging level to MVLOG_DEBUG, using the1428* VPU_JSM_MSG_TRACE_SET_CONFIG command.1429*1430* The host can see the current dynamic debug configuration by executing a1431* special 'show' command. The dyndbg configuration will be printed to the1432* configured logging destination using MVLOG_INFO logging level.1433*/1434struct vpu_ipc_msg_payload_dyndbg_control {1435/**1436* Dyndbg command (same format as Linux dyndbg); must be a NULL-terminated1437* string.1438*/1439char dyndbg_cmd[VPU_DYNDBG_CMD_MAX_LEN];1440};14411442/**1443* Payload for VPU_JSM_MSG_PWR_D0I3_ENTER1444*1445* This is a bi-directional payload.1446*/1447struct vpu_ipc_msg_payload_pwr_d0i3_enter {1448/**1449* 0: VPU_JSM_MSG_PWR_D0I3_ENTER_DONE is not sent to the host driver1450* The driver will poll for D0i2 Idle state transitions.1451* 1: VPU_JSM_MSG_PWR_D0I3_ENTER_DONE is sent after VPU state save is complete1452*/1453u32 send_response;1454u32 reserved_0;1455};14561457/**1458* Payload for VPU_JSM_MSG_DCT_ENABLE message.1459*1460* Default values for DCT active/inactive times are 5.3ms and 30ms respectively,1461* corresponding to a 85% duty cycle. This payload allows the host to tune these1462* values according to application requirements.1463*/1464struct vpu_ipc_msg_payload_pwr_dct_control {1465/** Duty cycle active time in microseconds */1466u32 dct_active_us;1467/** Duty cycle inactive time in microseconds */1468u32 dct_inactive_us;1469};14701471/*1472* Payloads union, used to define complete message format.1473*/1474union vpu_ipc_msg_payload {1475struct vpu_ipc_msg_payload_engine_reset engine_reset;1476struct vpu_ipc_msg_payload_engine_preempt engine_preempt;1477struct vpu_ipc_msg_payload_register_db register_db;1478struct vpu_ipc_msg_payload_unregister_db unregister_db;1479struct vpu_ipc_msg_payload_query_engine_hb query_engine_hb;1480struct vpu_ipc_msg_payload_power_level power_level;1481struct vpu_jsm_metric_streamer_start metric_streamer_start;1482struct vpu_jsm_metric_streamer_stop metric_streamer_stop;1483struct vpu_jsm_metric_streamer_update metric_streamer_update;1484struct vpu_ipc_msg_payload_ssid_release ssid_release;1485struct vpu_jsm_hws_register_db hws_register_db;1486struct vpu_ipc_msg_payload_job_done job_done;1487struct vpu_ipc_msg_payload_native_fence_signalled native_fence_signalled;1488struct vpu_ipc_msg_payload_engine_reset_done engine_reset_done;1489struct vpu_ipc_msg_payload_engine_preempt_done engine_preempt_done;1490struct vpu_ipc_msg_payload_register_db_done register_db_done;1491struct vpu_ipc_msg_payload_unregister_db_done unregister_db_done;1492struct vpu_ipc_msg_payload_query_engine_hb_done query_engine_hb_done;1493struct vpu_ipc_msg_payload_get_power_level_count_done get_power_level_count_done;1494struct vpu_jsm_metric_streamer_done metric_streamer_done;1495struct vpu_ipc_msg_payload_trace_config trace_config;1496struct vpu_ipc_msg_payload_trace_capability_rsp trace_capability;1497struct vpu_ipc_msg_payload_trace_get_name trace_get_name;1498struct vpu_ipc_msg_payload_trace_get_name_rsp trace_get_name_rsp;1499struct vpu_ipc_msg_payload_dyndbg_control dyndbg_control;1500struct vpu_ipc_msg_payload_hws_priority_band_setup hws_priority_band_setup;1501struct vpu_ipc_msg_payload_hws_create_cmdq hws_create_cmdq;1502struct vpu_ipc_msg_payload_hws_create_cmdq_rsp hws_create_cmdq_rsp;1503struct vpu_ipc_msg_payload_hws_destroy_cmdq hws_destroy_cmdq;1504struct vpu_ipc_msg_payload_hws_set_context_sched_properties1505hws_set_context_sched_properties;1506struct vpu_ipc_msg_payload_hws_set_scheduling_log hws_set_scheduling_log;1507struct vpu_ipc_msg_payload_hws_scheduling_log_notification hws_scheduling_log_notification;1508struct vpu_ipc_msg_payload_hws_suspend_cmdq hws_suspend_cmdq;1509struct vpu_ipc_msg_payload_hws_resume_cmdq hws_resume_cmdq;1510struct vpu_ipc_msg_payload_hws_resume_engine hws_resume_engine;1511struct vpu_ipc_msg_payload_pwr_d0i3_enter pwr_d0i3_enter;1512struct vpu_ipc_msg_payload_pwr_dct_control pwr_dct_control;1513};15141515/*1516* Host <-> LRT IPC message base structure.1517*1518* NOTE: All instances of this object must be aligned on a 64B boundary1519* to allow proper handling of VPU cache operations.1520*/1521struct vpu_jsm_msg {1522/* Reserved */1523u64 reserved_0;1524/* Message type, see vpu_ipc_msg_type enum. */1525u32 type;1526/* Buffer status, see vpu_ipc_msg_status enum. */1527u32 status;1528/*1529* Request ID, provided by the host in a request message and passed1530* back by VPU in the response message.1531*/1532u32 request_id;1533/* Request return code set by the VPU, see VPU_JSM_STATUS_* defines. */1534u32 result;1535u64 reserved_1;1536/* Message payload depending on message type, see vpu_ipc_msg_payload union. */1537union vpu_ipc_msg_payload payload;1538};15391540#pragma pack(pop)15411542#endif15431544///@}154515461547