Path: blob/master/drivers/accel/amdxdna/aie2_msg_priv.h
26428 views
/* SPDX-License-Identifier: GPL-2.0 */1/*2* Copyright (C) 2022-2024, Advanced Micro Devices, Inc.3*/45#ifndef _AIE2_MSG_PRIV_H_6#define _AIE2_MSG_PRIV_H_78enum aie2_msg_opcode {9MSG_OP_CREATE_CONTEXT = 0x2,10MSG_OP_DESTROY_CONTEXT = 0x3,11MSG_OP_SYNC_BO = 0x7,12MSG_OP_EXECUTE_BUFFER_CF = 0xC,13MSG_OP_QUERY_COL_STATUS = 0xD,14MSG_OP_QUERY_AIE_TILE_INFO = 0xE,15MSG_OP_QUERY_AIE_VERSION = 0xF,16MSG_OP_EXEC_DPU = 0x10,17MSG_OP_CONFIG_CU = 0x11,18MSG_OP_CHAIN_EXEC_BUFFER_CF = 0x12,19MSG_OP_CHAIN_EXEC_DPU = 0x13,20MSG_OP_MAX_XRT_OPCODE,21MSG_OP_SUSPEND = 0x101,22MSG_OP_RESUME = 0x102,23MSG_OP_ASSIGN_MGMT_PASID = 0x103,24MSG_OP_INVOKE_SELF_TEST = 0x104,25MSG_OP_MAP_HOST_BUFFER = 0x106,26MSG_OP_GET_FIRMWARE_VERSION = 0x108,27MSG_OP_SET_RUNTIME_CONFIG = 0x10A,28MSG_OP_GET_RUNTIME_CONFIG = 0x10B,29MSG_OP_REGISTER_ASYNC_EVENT_MSG = 0x10C,30MSG_OP_MAX_DRV_OPCODE,31MSG_OP_GET_PROTOCOL_VERSION = 0x301,32MSG_OP_MAX_OPCODE33};3435enum aie2_msg_status {36AIE2_STATUS_SUCCESS = 0x0,37/* AIE Error codes */38AIE2_STATUS_AIE_SATURATION_ERROR = 0x1000001,39AIE2_STATUS_AIE_FP_ERROR = 0x1000002,40AIE2_STATUS_AIE_STREAM_ERROR = 0x1000003,41AIE2_STATUS_AIE_ACCESS_ERROR = 0x1000004,42AIE2_STATUS_AIE_BUS_ERROR = 0x1000005,43AIE2_STATUS_AIE_INSTRUCTION_ERROR = 0x1000006,44AIE2_STATUS_AIE_ECC_ERROR = 0x1000007,45AIE2_STATUS_AIE_LOCK_ERROR = 0x1000008,46AIE2_STATUS_AIE_DMA_ERROR = 0x1000009,47AIE2_STATUS_AIE_MEM_PARITY_ERROR = 0x100000a,48AIE2_STATUS_AIE_PWR_CFG_ERROR = 0x100000b,49AIE2_STATUS_AIE_BACKTRACK_ERROR = 0x100000c,50AIE2_STATUS_MAX_AIE_STATUS_CODE,51/* MGMT ERT Error codes */52AIE2_STATUS_MGMT_ERT_SELF_TEST_FAILURE = 0x2000001,53AIE2_STATUS_MGMT_ERT_HASH_MISMATCH,54AIE2_STATUS_MGMT_ERT_NOAVAIL,55AIE2_STATUS_MGMT_ERT_INVALID_PARAM,56AIE2_STATUS_MGMT_ERT_ENTER_SUSPEND_FAILURE,57AIE2_STATUS_MGMT_ERT_BUSY,58AIE2_STATUS_MGMT_ERT_APPLICATION_ACTIVE,59MAX_MGMT_ERT_STATUS_CODE,60/* APP ERT Error codes */61AIE2_STATUS_APP_ERT_FIRST_ERROR = 0x3000001,62AIE2_STATUS_APP_INVALID_INSTR,63AIE2_STATUS_APP_LOAD_PDI_FAIL,64MAX_APP_ERT_STATUS_CODE,65/* NPU RTOS Error Codes */66AIE2_STATUS_INVALID_INPUT_BUFFER = 0x4000001,67AIE2_STATUS_INVALID_COMMAND,68AIE2_STATUS_INVALID_PARAM,69AIE2_STATUS_INVALID_OPERATION = 0x4000006,70AIE2_STATUS_ASYNC_EVENT_MSGS_FULL,71AIE2_STATUS_MAX_RTOS_STATUS_CODE,72MAX_AIE2_STATUS_CODE73};7475struct assign_mgmt_pasid_req {76__u16 pasid;77__u16 reserved;78} __packed;7980struct assign_mgmt_pasid_resp {81enum aie2_msg_status status;82} __packed;8384struct map_host_buffer_req {85__u32 context_id;86__u64 buf_addr;87__u64 buf_size;88} __packed;8990struct map_host_buffer_resp {91enum aie2_msg_status status;92} __packed;9394#define MAX_CQ_PAIRS 295struct cq_info {96__u32 head_addr;97__u32 tail_addr;98__u32 buf_addr;99__u32 buf_size;100};101102struct cq_pair {103struct cq_info x2i_q;104struct cq_info i2x_q;105};106107struct create_ctx_req {108__u32 aie_type;109__u8 start_col;110__u8 num_col;111__u16 reserved;112__u8 num_cq_pairs_requested;113__u8 reserved1;114__u16 pasid;115__u32 pad[2];116__u32 sec_comm_target_type;117__u32 context_priority;118} __packed;119120struct create_ctx_resp {121enum aie2_msg_status status;122__u32 context_id;123__u16 msix_id;124__u8 num_cq_pairs_allocated;125__u8 reserved;126struct cq_pair cq_pair[MAX_CQ_PAIRS];127} __packed;128129struct destroy_ctx_req {130__u32 context_id;131} __packed;132133struct destroy_ctx_resp {134enum aie2_msg_status status;135} __packed;136137struct execute_buffer_req {138__u32 cu_idx;139__u32 payload[19];140} __packed;141142struct exec_dpu_req {143__u64 inst_buf_addr;144__u32 inst_size;145__u32 inst_prop_cnt;146__u32 cu_idx;147__u32 payload[35];148} __packed;149150struct execute_buffer_resp {151enum aie2_msg_status status;152} __packed;153154struct aie_tile_info {155__u32 size;156__u16 major;157__u16 minor;158__u16 cols;159__u16 rows;160__u16 core_rows;161__u16 mem_rows;162__u16 shim_rows;163__u16 core_row_start;164__u16 mem_row_start;165__u16 shim_row_start;166__u16 core_dma_channels;167__u16 mem_dma_channels;168__u16 shim_dma_channels;169__u16 core_locks;170__u16 mem_locks;171__u16 shim_locks;172__u16 core_events;173__u16 mem_events;174__u16 shim_events;175__u16 reserved;176};177178struct aie_tile_info_req {179__u32 reserved;180} __packed;181182struct aie_tile_info_resp {183enum aie2_msg_status status;184struct aie_tile_info info;185} __packed;186187struct aie_version_info_req {188__u32 reserved;189} __packed;190191struct aie_version_info_resp {192enum aie2_msg_status status;193__u16 major;194__u16 minor;195} __packed;196197struct aie_column_info_req {198__u64 dump_buff_addr;199__u32 dump_buff_size;200__u32 num_cols;201__u32 aie_bitmap;202} __packed;203204struct aie_column_info_resp {205enum aie2_msg_status status;206__u32 size;207} __packed;208209struct suspend_req {210__u32 place_holder;211} __packed;212213struct suspend_resp {214enum aie2_msg_status status;215} __packed;216217struct resume_req {218__u32 place_holder;219} __packed;220221struct resume_resp {222enum aie2_msg_status status;223} __packed;224225struct check_header_hash_req {226__u64 hash_high;227__u64 hash_low;228} __packed;229230struct check_header_hash_resp {231enum aie2_msg_status status;232} __packed;233234struct query_error_req {235__u64 buf_addr;236__u32 buf_size;237__u32 next_row;238__u32 next_column;239__u32 next_module;240} __packed;241242struct query_error_resp {243enum aie2_msg_status status;244__u32 num_err;245__u32 has_next_err;246__u32 next_row;247__u32 next_column;248__u32 next_module;249} __packed;250251struct protocol_version_req {252__u32 reserved;253} __packed;254255struct protocol_version_resp {256enum aie2_msg_status status;257__u32 major;258__u32 minor;259} __packed;260261struct firmware_version_req {262__u32 reserved;263} __packed;264265struct firmware_version_resp {266enum aie2_msg_status status;267__u32 major;268__u32 minor;269__u32 sub;270__u32 build;271} __packed;272273#define MAX_NUM_CUS 32274#define AIE2_MSG_CFG_CU_PDI_ADDR GENMASK(16, 0)275#define AIE2_MSG_CFG_CU_FUNC GENMASK(24, 17)276struct config_cu_req {277__u32 num_cus;278__u32 cfgs[MAX_NUM_CUS];279} __packed;280281struct config_cu_resp {282enum aie2_msg_status status;283} __packed;284285struct set_runtime_cfg_req {286__u32 type;287__u64 value;288} __packed;289290struct set_runtime_cfg_resp {291enum aie2_msg_status status;292} __packed;293294struct get_runtime_cfg_req {295__u32 type;296} __packed;297298struct get_runtime_cfg_resp {299enum aie2_msg_status status;300__u64 value;301} __packed;302303enum async_event_type {304ASYNC_EVENT_TYPE_AIE_ERROR,305ASYNC_EVENT_TYPE_EXCEPTION,306MAX_ASYNC_EVENT_TYPE307};308309#define ASYNC_BUF_SIZE SZ_8K310struct async_event_msg_req {311__u64 buf_addr;312__u32 buf_size;313} __packed;314315struct async_event_msg_resp {316enum aie2_msg_status status;317enum async_event_type type;318} __packed;319320#define MAX_CHAIN_CMDBUF_SIZE SZ_4K321#define slot_has_space(slot, offset, payload_size) \322(MAX_CHAIN_CMDBUF_SIZE >= (offset) + (payload_size) + \323sizeof(typeof(slot)))324325struct cmd_chain_slot_execbuf_cf {326__u32 cu_idx;327__u32 arg_cnt;328__u32 args[] __counted_by(arg_cnt);329};330331struct cmd_chain_slot_dpu {332__u64 inst_buf_addr;333__u32 inst_size;334__u32 inst_prop_cnt;335__u32 cu_idx;336__u32 arg_cnt;337#define MAX_DPU_ARGS_SIZE (34 * sizeof(__u32))338__u32 args[] __counted_by(arg_cnt);339};340341struct cmd_chain_req {342__u64 buf_addr;343__u32 buf_size;344__u32 count;345} __packed;346347struct cmd_chain_resp {348enum aie2_msg_status status;349__u32 fail_cmd_idx;350enum aie2_msg_status fail_cmd_status;351} __packed;352353#define AIE2_MSG_SYNC_BO_SRC_TYPE GENMASK(3, 0)354#define AIE2_MSG_SYNC_BO_DST_TYPE GENMASK(7, 4)355struct sync_bo_req {356__u64 src_addr;357__u64 dst_addr;358__u32 size;359#define SYNC_BO_DEV_MEM 0360#define SYNC_BO_HOST_MEM 2361__u32 type;362} __packed;363364struct sync_bo_resp {365enum aie2_msg_status status;366} __packed;367#endif /* _AIE2_MSG_PRIV_H_ */368369370