1 /* 2 * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 * Description: diag common header file 15 * This file should be changed only infrequently and with great care. 16 */ 17 18 #ifndef __ZDIAG_COMMON_H__ 19 #define __ZDIAG_COMMON_H__ 20 21 #include "errcode.h" 22 #include "diag_config.h" 23 24 #define MUX_START_FLAG 0xDEADBEEF 25 #define MUX_PKT_VER 0xfd 26 27 typedef enum { 28 MUX_PKT_CMD = 0, 29 MUX_PKT_IND = 1, 30 MUX_PKT_ACK = 3, 31 } mux_pkt_type_t; 32 33 typedef enum { 34 DIAG_PKT_PROC_USR_ASYNC_CMD_IND, 35 DIAG_PKT_PROC_USR_SYNC_CMD_IND, 36 DIAG_PKT_PROC_PORT_PKT, 37 DIAG_PKT_PPOC_LOCAL_EXEC_Q, 38 DIAG_PKT_PPOC_OUT_PUT_Q, 39 } diag_pkt_proc_t; 40 41 typedef enum { 42 DIAG_ADDR_ATTRIBUTE_VALID = 0x1, 43 DIAG_ADDR_ATTRIBUTE_HCC = 0x2, 44 DIAG_ADDR_ATTRIBUTE_HSO_CONNECT = 0x4, 45 } diag_addr_attribute_t; 46 47 typedef struct { 48 uint32_t module; /* source module ID */ 49 uint32_t dest_mod; /* destination module ID */ 50 uint32_t no; /* No. */ 51 uint32_t id; /* ID */ 52 uint32_t time; 53 int8_t data[0]; /* User Data Cache */ 54 } diag_cmd_log_layer_ind_stru_t; 55 #define DIAG_FULL_LOG_HEADER_SIZE sizeof(diag_cmd_log_layer_ind_stru_t) 56 57 typedef struct { 58 uint16_t sn; /* cmd sn */ 59 uint16_t crc16; /* crc16 */ 60 61 uint16_t cmd_id; /* cmd id */ 62 uint16_t param_size; /* param size */ 63 uint8_t param[0]; /* data */ 64 } msp_diag_head_req_stru_t; 65 #define DIAG_REQ_HEADER_SIZE sizeof(msp_diag_head_req_stru_t) 66 67 typedef struct { 68 uint16_t cmd_id; /* cmd id */ 69 uint16_t param_size; /* param size */ 70 uint8_t param[0]; /* data */ 71 } msp_diag_head_ind_stru_t; 72 #define DIAG_IND_HEADER_SIZE sizeof(msp_diag_head_ind_stru_t) 73 74 typedef struct { 75 uint16_t sn; /* cmd sn */ 76 uint8_t ctrl; /* auto ack:0xfe,initiative ack:0 */ 77 uint8_t pad; 78 uint16_t cmd_id; /* cmd id */ 79 uint16_t param_size; /* param size */ 80 uint8_t param[0]; /* data */ 81 } msp_diag_head_cnf_stru_t; 82 #define DIAG_CNF_HEADER_SIZE sizeof(msp_diag_head_cnf_stru_t) 83 84 typedef struct { 85 uint32_t start_flag; /* start flag fixed 0xDEADBEAF */ 86 uint32_t au_id; /* MSP AUID. */ 87 uint8_t type; /* ind:0,ack:2,system ack:3 */ 88 uint8_t ver; /* diag cmd version,0xff:old version,0xfe:crc16version,0xfd:nb version */ 89 uint16_t cmd_id; /* mark unencrypted cmd id only 0x5000,0x5002,0x5003 */ 90 91 uint16_t crc16; /* crc16 */ 92 93 uint8_t dst; 94 uint8_t src; 95 96 uint8_t ctrl; 97 uint8_t pad[1]; 98 uint16_t packet_data_size; /* puc_packet_data size, not include sizeof(MSP_MUX_PACKET_HEAD_STRU). */ 99 100 uint8_t puc_packet_data[0]; /* data:Encrypted means encrypted data, otherwise plain text */ 101 } msp_mux_packet_head_stru_t; 102 #define DIAG_MUX_HEADER_SIZE sizeof(msp_mux_packet_head_stru_t) 103 104 #endif 105