* Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef MB_STRUCT_H
#define MB_STRUCT_H
#include "tsch_defines.h"
#if ((defined STARS_CTRL_CPU) && (!defined ENABLE_VERIFICATION_PATCH))
#include "ascend_hal_define.h"
#endif
#include "mb_struct_callback.h"
#ifdef __cplusplus
extern "C" {
#endif
#define TS_MAILBOX_SIZE (64U)
#define TS_DRV_MAILBOX_VALID_VALUE (0x5a5a)
#define TS_DRV_MAILBOX_RCV_OK_VALUE (0x5b5b)
#define TS_DRV_MAILBOX_RCV_NA_VALUE (0x5c5c)
#define TS_DRV_MAILBOX_INVALID_VALUE (0x0)
#define RECYCLE_EVENT_COUNT (25)
#define APP_EXIT_COUNT_MAX (12)
#define MB_CTRL_MSG_LENGTH (44U)
typedef enum {
TS_DRV_MAILBOX = 0X01,
TS_AICPU_MAILBOX = 0X02,
TS_INVALID_MAILBOX,
} ts_mailbox_type_t;
enum {
TS_NOTIFY_TYPE_CREATE = 0X01,
TS_NOTIFY_TYPE_DELETE = 0X02,
TS_NOTIFY_TYPE_INVALID,
};
enum {
TS_MAILBOX_NOTIFY_TYPE_NOTIFY = 0,
TS_MAILBOX_NOTIFY_TYPE_EVENT = 1,
TS_MAILBOX_NOTIFY_TYPE_INVALID
};
typedef enum {
OP_APP_EXIT = 0x0U,
OP_APP_ABORT,
OP_STREAM_ABORT,
APP_OP_INVALID
} ts_app_op_type_t;
enum {
NOTICE_ACK_IRQ = 0x0000,
CREATE_TASK_CMD_SQCQ = 0X0001,
RELEASE_TASK_CMD_SQCQ,
CREATE_LOG_CMD_SQCQ,
RELEASE_LOG_CMD_SQCQ,
CREATE_DEBUG_CMD_SQCQ,
RELEASE_DEBUG_CMD_SQCQ,
CREATE_PROFILE_CMD_SQCQ,
RELEASE_PROFILE_CMD_SQCQ,
CREATE_HEART_BEAT_SQCQ,
RELEASE_HEART_BEAT_SQCQ,
RECYCLE_EVENT_ID,
RECYCLE_STREAM_SQCQ,
CREATE_CONTAINER_INFO,
CONFIG_P2P_INFO,
RECEIVE_RDMA_INFO,
RESET_NOTIFY_ID,
SYNC_TIME,
APP_EXIT,
RECORD_NOTIFY,
RECEIVE_SHARED_MEMORY_INFO = 0x0014,
HOST_ID_INFO,
CREATE_AICPU_CHANNEL,
RELEASE_AICPU_CHANNEL,
CREATE_CB_SQCQ,
RELEASE_CB_SQCQ,
CREATE_LOGIC_CBCQ,
RELEASE_LOGIC_CBCQ,
MANAGE_NOTIFY_INFO,
MANAGE_EVENT_INFO,
CREATE_VF_MACHINE,
RELEASE_VF_MACHINE,
RESET_EVENT_ID,
CREATE_DRIVER_SQCQ,
RELEASE_DRIVER_SQCQ,
CREATE_LOGIC_CQ,
RELEASE_LOGIC_CQ,
CREATE_DRV_SQCQ,
RELEASE_DRV_SQCQ,
NOTICE_RESOURCE_MAPPING,
APP_EXIT_FINISH_CHECK,
ALLOC_RUNTIME_STREAM_ID,
FREE_RUNTIME_STREAM_ID,
CREATE_TASK_CMD_DVPP_SQCQ,
RELEASE_TASK_CMD_DVPP_SQCQ,
NOTICE_SSID_VF,
QUERY_SSID_VF,
CREATE_TS_SQCQ,
RELEASE_TS_SQCQ,
CREATE_CTRL_SQ,
RELEASE_CTRL_SQ,
NOTICE_SQ_TRIGGER,
CTRL_MSG_PROC,
CONFIG_STARS_URPC,
MAINT_SQ_TASK_SEND,
MAINT_CQ_REPORT_RECV,
CHECK_RTSQ_RECYCLE_STATUS,
AIC_UTIL_START,
AIC_UTIL_END,
CONFIG_QUEUE_SUBSCRIBE,
FAST_RINGBUFFER_CTRL_MSG,
DCMI_CTRL_MSG_PROC,
DVPP_CMDLIST_INFO,
UNMASK_CTRL_CPU_SUBSCRIBE_DOORBELL,
SQ_SWITCH_STREAM = 64,
#ifdef DAVINCI_CLOUD_V2
INVALID_CMD = 0xFF,
#else
INVALID_CMD,
#endif
};
#define TS_MAX_MAILBOX_FUNC_NUM (INVALID_CMD)
typedef struct {
volatile uint32_t ack_irq;
} tsCmdIrqInfo_t;
typedef struct {
volatile uint64_t sq_addr;
volatile uint64_t cq_addr0;
volatile uint16_t sq_idx;
volatile uint16_t cq_idx0;
volatile uint8_t app_flag : 1;
volatile uint8_t sq_ctrl_flag : 1;
volatile uint8_t vf_id : 6;
volatile uint8_t sq_cq_side : 2;
volatile uint8_t has_host_pid : 1;
volatile uint8_t res : 5;
volatile uint8_t sqe_size;
volatile uint8_t cqe_size;
volatile uint16_t cqdepth;
volatile uint16_t sqdepth;
volatile uint32_t pid;
volatile uint16_t cq_irq;
volatile uint16_t smmu_sub_streamid;
volatile uint32_t info[5];
} tsCmdSQCQInfo_t;
typedef union {
struct {
uint32_t sq_lock : 1;
uint32_t wait_lock : 1;
uint32_t dqs_inter_chip : 1;
uint32_t res0 : 29;
} bits;
uint32_t u32;
} tsStreamFlag_t;
enum {
TS_SQCQ_NORMAL_TYPE = 0,
TS_SQCQ_TOPIC_TYPE,
TS_SUB_TYPE_INVALID
};
typedef enum {
TS_NORMAL_INFO_EXT_FLAG_STREAM = 0x1,
TS_NORMAL_INFO_EXT_FLAG_OST = 0x2,
TS_NORMAL_INFO_EXT_FLAG_INVALID
} ts_normal_info_ext_valid_flag_t;
#pragma pack(4)
typedef struct {
volatile uint64_t valid_flag;
volatile tsStreamFlag_t stream_flag;
volatile uint32_t kis_simt_stk_base_addr_l;
volatile uint32_t kis_simt_stk_base_addr_h : 16;
volatile uint32_t res1 : 16;
volatile uint32_t kis_simt_warp_stk_size;
volatile uint32_t kis_simt_dvg_warp_stk_size;
volatile uint32_t pool_id;
volatile uint32_t pool_id_max;
volatile uint32_t stack_phy_base_addr_l;
volatile uint32_t stack_phy_base_addr_h;
} normalInfoExt_t;
typedef struct {
volatile uint8_t mb_spec;
volatile uint8_t mb_specid;
} topicInfoExt_t;
#ifdef ENABLE_VERIFICATION_PATCH
struct trs_ext_info_header {
uint32_t type;
uint32_t host_ssid;
uint32_t hccp_pid;
uint32_t cp_pid;
uint32_t vfid;
uint32_t rsv[11];
char data[0];
};
#endif
typedef struct {
#ifdef STARS_CTRL_CPU
struct trs_ext_info_header header;
#endif
union {
normalInfoExt_t normal_info;
topicInfoExt_t topic_info;
} u;
} infoExMsg_t;
typedef struct {
volatile uint32_t msg_len;
volatile infoExMsg_t *msg;
volatile uint32_t *info;
} infoExt_t;
#pragma pack()
typedef struct {
volatile uint64_t sq_addr;
volatile uint64_t cq_addr0;
volatile uint16_t sq_idx;
volatile uint16_t cq_idx0;
volatile uint8_t app_flag : 1;
volatile uint8_t sq_ctrl_flag : 1;
volatile uint8_t vf_id : 6;
volatile uint8_t sq_cq_side : 2;
volatile uint8_t has_host_pid : 1;
volatile uint8_t sq_addr_is_virtual : 1;
volatile uint8_t cq_addr_is_virtual : 1;
volatile uint8_t is_convert_pid : 1;
volatile uint8_t res : 2;
volatile uint8_t sqe_size;
volatile uint8_t cqe_size;
volatile uint16_t cqdepth;
volatile uint16_t sqdepth;
volatile uint32_t pid;
volatile uint16_t cq_irq;
volatile uint16_t smmu_sub_streamid;
volatile infoExt_t info_ext;
} tsCmdSQCQInfoExt_t;
typedef struct {
volatile uint64_t sq_addr;
volatile uint64_t cq_addr0;
volatile uint64_t cq_addr1;
volatile uint64_t cq_addr2;
volatile uint64_t cq_addr3;
volatile uint16_t sq_idx;
volatile uint16_t cq_idx0;
volatile uint16_t cq_idx1;
volatile uint16_t cq_idx2;
volatile uint16_t cq_idx3;
volatile uint16_t cq_irq;
volatile uint8_t app_flag;
volatile uint8_t cq_slot_size;
volatile uint16_t group_id;
} tsSQCQInfo_t;
typedef struct {
volatile uint16_t event_count;
volatile uint16_t event_id[RECYCLE_EVENT_COUNT];
} ts_recycle_event_id_t;
typedef struct {
volatile uint16_t group_id;
volatile uint16_t tflops;
} ts_container_info_t;
#ifndef STARS_CTRL_CPU
typedef struct {
volatile uint16_t notify_id;
volatile uint16_t operation_type;
volatile uint32_t host_pid;
volatile uint16_t vir_notify_id;
volatile uint8_t vf_id;
volatile uint8_t notify_type;
volatile uint8_t reserved[44];
} ts_notify_info_t;
#else
typedef struct {
volatile uint32_t notify_id;
volatile uint32_t host_pid;
volatile uint16_t operation_type;
volatile uint16_t vir_notify_id;
volatile uint8_t vf_id;
volatile uint8_t notify_type;
volatile uint8_t reserved[42];
} ts_notify_info_t;
#endif
typedef struct {
volatile uint8_t vf_id;
volatile uint8_t resource_type;
volatile uint8_t operation_type;
volatile uint8_t reserve0;
volatile uint16_t vir_id;
volatile uint16_t phy_id;
volatile uint32_t host_pid;
volatile uint8_t reserve[44];
} ts_resource_mapping_notice_t;
typedef struct {
volatile uint32_t event_id;
} ts_free_event_id_info_t;
typedef struct {
volatile uint64_t first_addr;
volatile uint32_t size;
} ts_shared_memory_info_t;
typedef struct {
volatile uint8_t self_id;
volatile uint8_t host_id;
} ts_hostid_info_t;
typedef struct {
volatile uint32_t opcode;
volatile uint32_t length;
volatile uint64_t addr;
volatile uint8_t reserve[40];
} ts_rdma_memory_info_t;
typedef struct {
volatile uint32_t opcode;
volatile uint32_t idx;
volatile uint64_t sq_addr;
volatile uint64_t temp_addr;
volatile uint64_t db_addr;
volatile uint64_t dfx_addr;
volatile uint32_t sq_depth;
volatile uint32_t temp_depth;
volatile uint64_t db_reg;
} ts_rdma_sq_t;
typedef struct {
union Data {
ts_rdma_memory_info_t rdma_memory_info;
ts_rdma_sq_t rdma_sq;
} d;
} ts_rdma_info_t;
typedef struct {
volatile uint8_t remote_devId;
volatile uint8_t status;
volatile uint8_t type;
volatile uint8_t local_devId;
volatile uint32_t reserved2;
volatile uint64_t db_addr;
volatile uint32_t db_size;
volatile uint64_t sram_addr;
volatile uint32_t sram_size;
volatile uint64_t hwts_p2p_addr;
volatile uint32_t hwts_size;
} ts_multi_chip_info_t;
typedef struct {
volatile uint32_t app_count;
volatile uint32_t app_pid[APP_EXIT_COUNT_MAX];
volatile uint8_t app_flag;
volatile uint8_t vf_id;
volatile uint8_t reserved[2];
} ts_app_exit_info_t;
typedef struct {
volatile uint64_t addr;
volatile uint64_t len;
volatile uint32_t pid;
volatile uint8_t vf_id;
} ts_create_fast_ringbuffer_t;
typedef struct {
ts_ctrl_msg_head_t head;
ts_ctrl_msg_body_t body;
} ts_ctrl_msg_info_t;
enum ts_dcmi_msg_type_t {
DCMI_TYPE_STARS_TASK_TIMEOUT_SET = 0,
DCMI_TYPE_STARS_TASK_TIMEOUT_GET,
};
typedef struct {
volatile uint32_t timeout_limit_exp;
volatile uint8_t resv[36];
} ts_dcmi_task_timeout_t;
typedef struct {
volatile uint32_t type;
union {
ts_dcmi_task_timeout_t set_task_timeout_info;
ts_dcmi_task_timeout_t get_task_timeout_info;
} u;
} ts_dcmi_ctrl_msg_body_t;
typedef struct {
ts_ctrl_msg_head_t head;
ts_dcmi_ctrl_msg_body_t body;
} ts_dcmi_ctrl_msg_info_t;
typedef struct {
volatile uint32_t sq_type;
volatile uint32_t sq_id;
volatile uint32_t sq_tail;
volatile uint8_t reserved[44];
} ts_maint_sq_task_send_t;
typedef struct {
volatile uint32_t cq_type;
volatile uint32_t cq_id;
volatile uint32_t cq_head;
volatile uint8_t reserved[44];
} ts_maint_cq_report_recv_t;
typedef struct {
volatile uint64_t sq_addr;
volatile uint64_t cq_addr0;
volatile uint16_t channel_id;
volatile uint16_t sqe_length;
volatile uint16_t cqe_length;
volatile uint16_t sqe_depth;
volatile uint16_t cqe_depth;
} ts_create_aicpu_channel_t;
typedef struct {
volatile uint16_t channel_id;
} ts_release_aicpu_channel_t;
typedef struct {
volatile uint64_t phy_cq_addr;
volatile uint16_t cqe_size;
volatile uint16_t cq_depth;
volatile uint32_t vpid;
volatile uint16_t logic_cqid;
volatile uint16_t phy_cqid;
volatile uint16_t cq_irq;
volatile uint8_t app_flag;
volatile uint8_t thread_bind_irq_flag;
volatile uint8_t vf_id;
volatile uint8_t reserved[3];
volatile uint32_t info[5];
} ts_create_logic_cq_t;
typedef struct {
volatile uint32_t vpid;
volatile uint16_t logic_cqid;
volatile uint16_t phy_cqid;
volatile uint8_t vf_id;
volatile uint8_t reserved[3];
} ts_release_logic_cq_t;
typedef struct {
volatile uint8_t vf_id;
volatile uint8_t aic_num;
volatile uint8_t reserved;
volatile uint8_t vfg_id;
volatile uint32_t vf_aicpu_bitmap;
volatile uint32_t vfg_aicpu_bitmap;
} ts_create_vf_info_t;
typedef struct {
volatile uint8_t vf_id;
volatile uint8_t reserved[3];
} ts_release_vf_info_t;
#pragma pack(4)
typedef struct {
uint32_t sq_id;
uint32_t cq_id;
uint32_t vf_id;
uint32_t pid;
uint16_t ssid;
uint16_t app_flag : 1;
uint16_t rsv : 15;
uint64_t sq_addr;
uint64_t cq_addr;
uint16_t sqe_size;
uint16_t cqe_size;
uint16_t sq_depth;
uint16_t cq_depth;
} ts_reserve_sq_cq_info_t;
#pragma pack()
typedef struct {
uint32_t sq_id;
uint32_t cq_id;
uint32_t vf_id;
uint32_t pid;
uint16_t ssid;
uint16_t app_flag : 1;
uint16_t rsv : 15;
uint32_t info[5];
} notice_ts_sqcq_t;
typedef struct {
uint32_t op;
uint64_t cmdlist_kva;
uint64_t cmdlist_uva;
uint32_t ssid;
} ts_dvpp_cmdlist_info_t;
typedef struct {
uint32_t priority;
uint32_t stream_id;
uint32_t vf_id;
uint32_t pid;
} ts_alloc_runtime_stream_id_t;
typedef struct {
uint32_t stream_id;
} ts_free_runtime_stream_id_t;
typedef struct {
uint8_t vf_id;
uint8_t vfg_id;
uint16_t ss_id;
uint32_t pid;
} notice_ts_ssid_t;
typedef struct {
uint32_t db;
uint32_t irq;
uint8_t idx;
uint8_t reserved[3];
} ts_sq_trigger_msg_t;
typedef struct {
volatile uint8_t vf_id;
volatile uint8_t reserved[3];
} ts_stars_create_vf_info_t;
struct trs_urpc_jetty_config {
uint16_t jetty_ci;
uint16_t jetty_pi;
uint16_t jetty_length_shift;
uint64_t jetty_base_addr;
uint64_t doorbell_addr;
uint32_t jetty_id;
uint8_t func_id;
uint8_t die_id;
uint32_t trans_obj_id : 24;
uint32_t rsv : 2;
uint32_t odr : 3;
uint32_t token_en : 1;
uint32_t rmt_jetty_type : 2;
uint32_t rmt_jetty_or_seg_id;
uint64_t rmt_eid_low;
uint64_t rmt_eid_high;
uint32_t rmt_token_value;
union {
uint8_t int_mode;
uint64_t sq_head_base_addr;
};
uint32_t urpc_aw_wqe_setting_0;
uint32_t urpc_db_wqe_setting_0;
uint8_t urpc_aw_wqe_setting_1;
uint8_t urpc_db_wqe_setting_1;
};
typedef struct {
struct trs_urpc_jetty_config *cq_jetty_info;
struct trs_urpc_jetty_config *sq_head_jetty_info;
uint32_t vf_id;
} ts_config_stars_urpc_info_t;
typedef struct {
uint32_t core_type;
uint32_t vf_id;
} ts_aic_util_message_t;
typedef enum {
STARS_QUEUE_SUBSCRIBE_TYPE_INVALID = 0,
STARS_QUEUE_SUBSCRIBE_TYPE_ACC = 1,
STARS_QUEUE_SUBSCRIBE_TYPE_AI_CPU = 2,
STARS_QUEUE_SUBSCRIBE_TYPE_CTRL_CPU = 3,
STARS_QUEUE_SUBSCRIBE_TYPE_INTER_CHIP = 4
} stars_queue_subscribe_type_t;
typedef enum {
STARS_QUEUE_SUBSCRIBE_OP_CREATE = 0,
STARS_QUEUE_SUBSCRIBE_OP_DELETE
} stars_queue_subscribe_mb_op_type_t;
typedef struct {
uint8_t rtsq_id;
uint8_t *topic_sqe;
} stars_queue_subscribe_aicpu_t;
typedef struct {
uint64_t gqm_base;
} stars_queue_subscribe_ccpu_t;
typedef struct {
uint8_t subscriber_type;
uint8_t op_type;
uint16_t queue_id;
union {
stars_queue_subscribe_aicpu_t aicpu_subscribe;
stars_queue_subscribe_ccpu_t ccpu_subscribe;
} u;
} stars_queue_subscribe_info_t;
#pragma pack(4)
#define MAX_SWITCH_NODE_CNT (3)
typedef struct {
uint16_t sq_id;
uint16_t sq_depth;
uint32_t stream_id;
uint64_t sq_addr;
} sq_swtich_node_t;
typedef struct {
uint32_t cnt;
sq_swtich_node_t nodes[MAX_SWITCH_NODE_CNT];
} stars_switch_sq_for_stream_info_t;
#pragma pack()
typedef struct tag_ts_mailbox {
volatile uint16_t valid;
volatile uint16_t cmd_type;
volatile uint32_t result;
union {
tsCmdIrqInfo_t notice_irq_info;
tsCmdSQCQInfo_t cmd_sqcq_info;
tsSQCQInfo_t sq_cq_info;
ts_recycle_event_id_t recycle_event;
ts_container_info_t container_info;
ts_notify_info_t notify_info;
ts_resource_mapping_notice_t resource_mapping_notice;
ts_free_event_id_info_t free_event_id_info;
ts_rdma_info_t rdma_info;
ts_multi_chip_info_t multi_chip_info;
ts_app_exit_info_t app_exit_info;
ts_shared_memory_info_t shared_memory_info;
ts_hostid_info_t hostid_info;
ts_create_aicpu_channel_t aicpu_channel_info;
ts_release_aicpu_channel_t release_aicpu_channel_info;
ts_create_callback_sqcq_t create_callback_sqcq;
ts_release_callback_sqcq_t release_callback_sqcq;
ts_create_callback_logic_cq_t create_callback_logic_cq;
ts_release_callback_logic_cq_t release_callback_logic_cq;
ts_create_vf_info_t create_vf_info;
ts_release_vf_info_t release_vf_info;
ts_create_logic_cq_t create_logic_cq;
ts_release_logic_cq_t release_logic_cq;
notice_ts_sqcq_t notice_ts_sqcq;
ts_alloc_runtime_stream_id_t alloc_runtime_stream_id;
ts_free_runtime_stream_id_t free_runtime_stream_id;
notice_ts_ssid_t notice_ts_ssid;
ts_sq_trigger_msg_t ts_sq_trigger_msg;
ts_stars_create_vf_info_t stars_create_vf_info;
tsCmdSQCQInfoExt_t cmd_sqcq_info_ext;
ts_config_stars_urpc_info_t config_stars_urpc_info;
ts_ctrl_msg_info_t ctrl_msg_info;
ts_dcmi_ctrl_msg_info_t dcmi_ctrl_msg_info;
ts_maint_sq_task_send_t maint_sq_task_send;
ts_maint_cq_report_recv_t maint_cq_report;
ts_aic_util_message_t aic_util_msg;
ts_reserve_sq_cq_info_t ts_rsv_sq_cq_info;
ts_dvpp_cmdlist_info_t dvpp_cmdlist_info;
stars_queue_subscribe_info_t queue_subscribe_info;
ts_create_fast_ringbuffer_t fast_ringbuffer;
stars_switch_sq_for_stream_info_t sq_switch_info;
} u;
} ts_mailbox_t;
#ifdef __cplusplus
}
#endif
#endif