yu.dong | c33b307 | 2024-08-21 23:14:49 -0700 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * Copyright Statement: |
| 3 | * -------------------- |
| 4 | * This software is protected by Copyright and the information contained |
| 5 | * herein is confidential. The software may not be copied and the information |
| 6 | * contained herein may not be used or disclosed except with the written |
| 7 | * permission of MediaTek Inc. (C) 2005 |
| 8 | * |
| 9 | * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES |
| 10 | * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") |
| 11 | * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON |
| 12 | * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, |
| 13 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF |
| 14 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. |
| 15 | * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE |
| 16 | * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR |
| 17 | * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH |
| 18 | * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO |
| 19 | * NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S |
| 20 | * SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. |
| 21 | * |
| 22 | * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE |
| 23 | * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, |
| 24 | * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, |
| 25 | * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO |
| 26 | * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. |
| 27 | * |
| 28 | * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE |
| 29 | * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF |
| 30 | * LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND |
| 31 | * RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER |
| 32 | * THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). |
| 33 | * |
| 34 | *******************************************************************************/ |
| 35 | #ifndef _PERF_API_H_ |
| 36 | #define _PERF_API_H_ |
| 37 | |
| 38 | #include "kal_general_types.h" |
| 39 | #include "kal_public_defs.h" |
| 40 | #include "kal_public_api.h" |
| 41 | #include "kal_trace.h" |
| 42 | #include "event_info_utility.h" |
| 43 | #include "md_sap.h" |
| 44 | #include "perf_msgid.h" |
| 45 | |
| 46 | /******************************************** |
| 47 | * TYPE DEFINITIONS & ENUMS * |
| 48 | ********************************************/ |
| 49 | typedef enum |
| 50 | { |
| 51 | RECOVERY_TYPE_ASSERT = 0, |
| 52 | RECOVERY_TYPE_SIM_PLUG = 0, /// not support yet |
| 53 | RECOVERY_TYPE_FLIGHT_MODE, |
| 54 | RECOVERY_TYPE_REATTACH = RECOVERY_TYPE_FLIGHT_MODE, /// not support yet |
| 55 | RECOVERY_TYPE_LTE_LOCAL_RELEASE, |
| 56 | RECOVERY_TYPE_LTE_RRC_REESTABLISH, |
| 57 | RECOVERY_TYPE_PERF_SUPPORT_NUM, /// the max number PERF support (not include NR) |
| 58 | |
| 59 | RECOVERY_TYPE_NR_LOCAL_RELEASE = RECOVERY_TYPE_PERF_SUPPORT_NUM, |
| 60 | RECOVERY_TYPE_NR_RRC_REESTABLISH, |
| 61 | RECOVERY_TYPE_NR_SCG_FAILURE_INFO, |
| 62 | RECOVERY_TYPE_NR_RRC_REDIRECT_FAIL, // RRC ask ERM to notify scenario when redirection fail, and notify NRRC when scenario happened |
| 63 | } protocol_exception_recovery_type_enum; |
| 64 | |
| 65 | typedef enum |
| 66 | { |
| 67 | LTE_LOCAL_RELEASE_RESULT_OK, |
| 68 | LTE_LOCAL_RELEASE_RESULT_FAIL |
| 69 | } lte_local_release_result_enum; |
| 70 | |
| 71 | typedef enum |
| 72 | { |
| 73 | LTE_RRC_REESTABLISH_RESULT_OK, |
| 74 | LTE_RRC_REESTABLISH_RESULT_ONGOING, |
| 75 | LTE_RRC_REESTABLISH_RESULT_FAIL |
| 76 | } lte_rrc_reestablish_result_enum; |
| 77 | |
| 78 | typedef enum |
| 79 | { |
| 80 | PERF_UT_MSG_SEND_NONE = 0, |
| 81 | PERF_UT_MSG_SEND_KAL, |
| 82 | PERF_UT_MSG_SEND_UTT |
| 83 | } perf_ut_msg_send_mode_enum; |
| 84 | |
| 85 | /******************** |
| 86 | NR related enum |
| 87 | ********************/ |
| 88 | |
| 89 | typedef enum |
| 90 | { |
| 91 | ERROR_RECOVERY_METHOD_NON = 0, |
| 92 | ERROR_RECOVERY_METHOD_RELEASE, |
| 93 | ERROR_RECOVERY_METHOD_REEST, |
| 94 | ERROR_RECOVERY_METHOD_SCG_FAIL_INFO, |
| 95 | } error_recovery_method_enum; |
| 96 | |
| 97 | /******************************************** |
| 98 | * VARIABLES * |
| 99 | ********************************************/ |
| 100 | #define PEFR_ALL_PROTOCOL_ID (0xF) |
| 101 | #define PERF_MAX_DEBUG_BUF_SIZE (128) /// in byte |
| 102 | #define PERF_FILENAME_LENGTH (90) |
| 103 | #define PERF_FUNCTION_NAME_LENGTH (50) |
| 104 | |
| 105 | /******************************************** |
| 106 | * STRUCTURES * |
| 107 | ********************************************/ |
| 108 | /// interface for Offender |
| 109 | typedef struct |
| 110 | { |
| 111 | void *p_buf; |
| 112 | kal_uint32 size; /// size of p_buf in byte |
| 113 | } protocol_exception_recovery_debug_struct; |
| 114 | |
| 115 | /// User API parameter: PROTOCOL_EXCEPTION_RECOVERY() |
| 116 | typedef struct |
| 117 | { |
| 118 | kal_uint8 protocol_id; /**< |
| 119 | 0x0 ~ 0x3: protocol stack 1 ~ 4 |
| 120 | PEFR_ALL_PROTOCOL_ID (0xF): all protocol stack id |
| 121 | **/ |
| 122 | kal_bool disable_escalate_recovery; /// KAL_TRUE: disable escalating recovery feature |
| 123 | protocol_exception_recovery_debug_struct debug; |
| 124 | } protocol_exception_recovery_info_struct; |
| 125 | |
| 126 | /// trigger PERF primitive structure (MSG_ID_PROTOCOL_EXCEPTION_RECOVERY) |
| 127 | typedef struct |
| 128 | { |
| 129 | LOCAL_PARA_HDR |
| 130 | |
| 131 | protocol_exception_recovery_type_enum recovery_type; |
| 132 | protocol_exception_recovery_info_struct info; |
| 133 | char filename[PERF_FILENAME_LENGTH]; |
| 134 | char function_name[PERF_FUNCTION_NAME_LENGTH]; |
| 135 | kal_uint32 line; |
| 136 | //kal_uint8 debug_buff_id; |
| 137 | } protocol_exception_recovery_struct; |
| 138 | |
| 139 | /// interface for flight mode Actor |
| 140 | typedef struct |
| 141 | { |
| 142 | LOCAL_PARA_HDR |
| 143 | |
| 144 | kal_bool is_flight_mode; |
| 145 | kal_uint8 ps_id; /// protocol stack id bitmap |
| 146 | } perf_l4bpwr_flight_mode_recovery_req, perf_l4bpwr_flight_mode_recovery_req_struct; |
| 147 | |
| 148 | typedef struct |
| 149 | { |
| 150 | LOCAL_PARA_HDR |
| 151 | |
| 152 | kal_bool result; |
| 153 | } perf_l4bpwr_flight_mode_recovery_cnf, perf_l4bpwr_flight_mode_recovery_cnf_struct; |
| 154 | |
| 155 | /// interface for LTE local release Actor |
| 156 | typedef struct |
| 157 | { |
| 158 | LOCAL_PARA_HDR |
| 159 | |
| 160 | lte_local_release_result_enum cause; |
| 161 | kal_uint8 protocol_id; |
| 162 | } perf_emm_lte_local_release_recovery_cnf, perf_emm_lte_local_release_recovery_cnf_struct; |
| 163 | |
| 164 | /// interface for LTE RRC reestablishment Actor |
| 165 | typedef struct |
| 166 | { |
| 167 | LOCAL_PARA_HDR |
| 168 | |
| 169 | lte_rrc_reestablish_result_enum cause; |
| 170 | } perf_errc_lte_rrc_reestablishment_recovery_cnf, perf_errc_reestablishment_recovery_cnf_struct; |
| 171 | |
| 172 | /******************** |
| 173 | NR related Struct. |
| 174 | ********************/ |
| 175 | /* MSG_ID_ERM_ERROR_IND*/ |
| 176 | typedef struct |
| 177 | { |
| 178 | LOCAL_PARA_HDR |
| 179 | |
| 180 | protocol_exception_recovery_type_enum err_event; |
| 181 | protocol_exception_recovery_info_struct info; |
| 182 | } erm_error_ind_struct; |
| 183 | |
| 184 | /* MSG_ID_ERM_VGMM_ERROR_RECOVERY_REQ */ |
| 185 | typedef struct |
| 186 | { |
| 187 | LOCAL_PARA_HDR |
| 188 | |
| 189 | error_recovery_method_enum recovery_method; |
| 190 | kal_uint16 timer_period; |
| 191 | } erm_vgmm_error_recovery_req_struct; |
| 192 | |
| 193 | /* MSG_ID_ERM_VGMM_ERROR_RECOVERY_CNF */ |
| 194 | typedef struct |
| 195 | { |
| 196 | LOCAL_PARA_HDR |
| 197 | } erm_vgmm_error_recovery_cnf_struct; |
| 198 | /******************************************** |
| 199 | * MACROS and API * |
| 200 | ********************************************/ |
| 201 | /// interface for LTE Local Release Actor |
| 202 | /// hook function pointer from EMM to PERF |
| 203 | typedef kal_bool (*perf_query_is_lte_conn_status_idle_f)(kal_uint8 protocol_id); |
| 204 | extern void lte_local_release_actor_hook_conn_status_query_fp(perf_query_is_lte_conn_status_idle_f fp_query); |
| 205 | |
| 206 | /// atomic read PERF need update IDLE status (for local release recovery result) |
| 207 | extern void lte_local_release_actor_update_conn_status(kal_bool is_idle, kal_uint8 protocol_id); |
| 208 | |
| 209 | kal_bool protocol_exception_recovery_trigger( |
| 210 | module_type module_id, |
| 211 | const char *filename, |
| 212 | const char *function_name, |
| 213 | kal_uint32 line, |
| 214 | protocol_exception_recovery_type_enum recovery_type, |
| 215 | protocol_exception_recovery_info_struct *p_info); |
| 216 | /// Note: User shall "not" use below internal macro directly ! |
| 217 | #define __PERF_TRIGGER(_module, _file, _func, _line, _type, _info) \ |
| 218 | protocol_exception_recovery_trigger(\ |
| 219 | (_module),\ |
| 220 | (_file),\ |
| 221 | (_func),\ |
| 222 | (kal_uint32)(_line),\ |
| 223 | (protocol_exception_recovery_type_enum)(_type),\ |
| 224 | (protocol_exception_recovery_info_struct *)(_info)); |
| 225 | |
| 226 | #define _PERF_TRIGGER(_module, _type, _info) \ |
| 227 | __PERF_TRIGGER((_module),__FILE__,__func__,__LINE__,(_type),(_info)) |
| 228 | |
| 229 | #define _PERF_TRIGGER_LITE(_module, _type, _info) \ |
| 230 | __PERF_TRIGGER((_module),"","",__LINE__,(_type),(_info)) |
| 231 | |
| 232 | /// recovery API for general user |
| 233 | #if defined(__MTK_TARGET__) && defined(__PERF_SUPPORT__) && !defined(__DEBUG_ASSERT_SUPPORT__) && !defined(__UE_SIMULATOR__) |
| 234 | /// will change before/after SQC start |
| 235 | #define PROTOCOL_EXCEPTION_RECOVERY _PERF_TRIGGER |
| 236 | #define PROTOCOL_EXCEPTION_RECOVERY_LITE _PERF_TRIGGER_LITE |
| 237 | #define EMM_HOOK_CONN_STATUS_QUERY_FP(_fp) lte_local_release_actor_hook_conn_status_query_fp((_fp)) |
| 238 | #define EMM_UPDATE_CONN_STATUS_TO_PERF(_is_idle, _protocol_id) lte_local_release_actor_update_conn_status((_is_idle), (_protocol_id)) |
| 239 | |
| 240 | #elif defined(UNIT_TEST) && defined(__PERF_SUPPORT__) && !defined(__UE_SIMULATOR__) |
| 241 | /// UT always enable API |
| 242 | #define PROTOCOL_EXCEPTION_RECOVERY _PERF_TRIGGER |
| 243 | #define PROTOCOL_EXCEPTION_RECOVERY_LITE _PERF_TRIGGER_LITE |
| 244 | #define EMM_HOOK_CONN_STATUS_QUERY_FP(_fp) lte_local_release_actor_hook_conn_status_query_fp((_fp)) |
| 245 | #define EMM_UPDATE_CONN_STATUS_TO_PERF(_is_idle, _protocol_id) lte_local_release_actor_update_conn_status((_is_idle), (_protocol_id)) |
| 246 | |
| 247 | #else |
| 248 | /// for other build, always keep assert |
| 249 | #define PROTOCOL_EXCEPTION_RECOVERY(_module, _type, _info) \ |
| 250 | ASSERT(0); \ |
| 251 | kal_prompt_trace((_module), "[PROTOCOL EXCEPTION] current stage is disable (%x,%x,%x)", (_module), (_type), (_info)); |
| 252 | #define PROTOCOL_EXCEPTION_RECOVERY_LITE PROTOCOL_EXCEPTION_RECOVERY |
| 253 | #define EMM_HOOK_CONN_STATUS_QUERY_FP(_fp) lte_local_release_actor_hook_conn_status_query_fp((_fp)) |
| 254 | #define EMM_UPDATE_CONN_STATUS_TO_PERF(_is_idle, _protocol_id) if ((_is_idle) && (_protocol_id)){} |
| 255 | |
| 256 | #endif // ~ #if defined(__MTK_TARGET__) && !defined(__DEBUG_ASSERT_SUPPORT__) #elif defined(UNIT_TEST) #else |
| 257 | |
| 258 | /// recovery API for HISR user |
| 259 | #define PROTOCOL_EXCEPTION_RECOVERY_HISR PROTOCOL_EXCEPTION_RECOVERY |
| 260 | |
| 261 | /// recovery API for LISR without multi-thread user |
| 262 | #define PROTOCOL_EXCEPTION_RECOVERY_LISR PROTOCOL_EXCEPTION_RECOVERY |
| 263 | |
| 264 | /// recovery API for LISR with multi-thread user |
| 265 | #define PROTOCOL_EXCEPTION_RECOVERY_MT_LISR PROTOCOL_EXCEPTION_RECOVERY |
| 266 | |
| 267 | /// Actor result update message send |
| 268 | #ifdef UNIT_TEST |
| 269 | extern perf_ut_msg_send_mode_enum g_ut_enable_msg_send; |
| 270 | #ifdef __GTEST_ENABLE__ |
| 271 | #define PERF_UT_MSG_SEND6(...) \ |
| 272 | if (g_ut_enable_msg_send == PERF_UT_MSG_SEND_NONE) \ |
| 273 | { \ |
| 274 | } \ |
| 275 | else if (g_ut_enable_msg_send == PERF_UT_MSG_SEND_UTT) \ |
| 276 | { \ |
| 277 | utt_msg_send6(__VA_ARGS__); \ |
| 278 | } \ |
| 279 | else \ |
| 280 | { \ |
| 281 | msg_send6(__VA_ARGS__); \ |
| 282 | } |
| 283 | #else |
| 284 | #define PERF_UT_MSG_SEND6(...) \ |
| 285 | if (g_ut_enable_msg_send == PERF_UT_MSG_SEND_NONE) \ |
| 286 | { \ |
| 287 | } \ |
| 288 | else \ |
| 289 | { \ |
| 290 | msg_send6(__VA_ARGS__); \ |
| 291 | } |
| 292 | #endif // ~ #ifdef __GTEST_ENABLE__ #else |
| 293 | |
| 294 | #define PERF_MSG_SEND6(...) PERF_UT_MSG_SEND6(__VA_ARGS__) |
| 295 | #define ENABLE_PERF_MSG_SEND6() do{g_ut_enable_msg_send = PERF_UT_MSG_SEND_UTT;}while(0); |
| 296 | #define ENABLE_PERF_MSG_SEND6_FOR_MSC() do{g_ut_enable_msg_send = PERF_UT_MSG_SEND_KAL;}while(0); |
| 297 | #define DISABLE_PERF_MSG_SEND6() do{g_ut_enable_msg_send = PERF_UT_MSG_SEND_NONE;}while(0); |
| 298 | #define DISABLE_PERF_MSG_SEND6_FOR_MSC DISABLE_PERF_MSG_SEND6 |
| 299 | #else |
| 300 | #define PERF_MSG_SEND6(...) msg_send6(__VA_ARGS__) |
| 301 | #endif // ~ #ifdef UNIT_TEST #else |
| 302 | |
| 303 | #ifdef __PERF_TEST_MODE__ |
| 304 | typedef void (*perf_test_mode_case_f)(void *param); |
| 305 | extern kal_uint32 perf_test_mode_regist_a_case(perf_test_mode_case_f fp, void *param); |
| 306 | #define PERF_REGIST_IT_CASE_FP(_fp, _param) perf_test_mode_regist_a_case((_fp), (void *)(_param)) |
| 307 | #else |
| 308 | #define PERF_REGIST_IT_CASE_FP(_fp, _param) |
| 309 | #endif // ~ #ifdef __PERF_TEST_MODE__ |
| 310 | |
| 311 | #endif // ~ #ifndef _PERF_API_H_ |