blob: f445723296be8e086a73c896ab61093402e1ec96 [file] [log] [blame]
/******************************************************************************
* Copyright Statement:
* --------------------
* This software is protected by Copyright and the information contained
* herein is confidential. The software may not be copied and the information
* contained herein may not be used or disclosed except with the written
* permission of MediaTek Inc. (C) 2005
*
* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
*
* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
*
*******************************************************************************/
#ifndef _PERF_API_H_
#define _PERF_API_H_
#include "kal_general_types.h"
#include "kal_public_defs.h"
#include "kal_public_api.h"
#include "kal_trace.h"
#include "event_info_utility.h"
#include "md_sap.h"
#include "perf_msgid.h"
/********************************************
* TYPE DEFINITIONS & ENUMS *
********************************************/
typedef enum
{
RECOVERY_TYPE_ASSERT = 0,
RECOVERY_TYPE_SIM_PLUG = 0, /// not support yet
RECOVERY_TYPE_FLIGHT_MODE,
RECOVERY_TYPE_REATTACH = RECOVERY_TYPE_FLIGHT_MODE, /// not support yet
RECOVERY_TYPE_LTE_LOCAL_RELEASE,
RECOVERY_TYPE_LTE_RRC_REESTABLISH,
RECOVERY_TYPE_PERF_SUPPORT_NUM, /// the max number PERF support (not include NR)
RECOVERY_TYPE_NR_LOCAL_RELEASE = RECOVERY_TYPE_PERF_SUPPORT_NUM,
RECOVERY_TYPE_NR_RRC_REESTABLISH,
RECOVERY_TYPE_NR_SCG_FAILURE_INFO,
RECOVERY_TYPE_NR_RRC_REDIRECT_FAIL, // RRC ask ERM to notify scenario when redirection fail, and notify NRRC when scenario happened
} protocol_exception_recovery_type_enum;
typedef enum
{
LTE_LOCAL_RELEASE_RESULT_OK,
LTE_LOCAL_RELEASE_RESULT_FAIL
} lte_local_release_result_enum;
typedef enum
{
LTE_RRC_REESTABLISH_RESULT_OK,
LTE_RRC_REESTABLISH_RESULT_ONGOING,
LTE_RRC_REESTABLISH_RESULT_FAIL
} lte_rrc_reestablish_result_enum;
typedef enum
{
PERF_UT_MSG_SEND_NONE = 0,
PERF_UT_MSG_SEND_KAL,
PERF_UT_MSG_SEND_UTT
} perf_ut_msg_send_mode_enum;
/********************
NR related enum
********************/
typedef enum
{
ERROR_RECOVERY_METHOD_NON = 0,
ERROR_RECOVERY_METHOD_RELEASE,
ERROR_RECOVERY_METHOD_REEST,
ERROR_RECOVERY_METHOD_SCG_FAIL_INFO,
} error_recovery_method_enum;
/********************************************
* VARIABLES *
********************************************/
#define PEFR_ALL_PROTOCOL_ID (0xF)
#define PERF_MAX_DEBUG_BUF_SIZE (128) /// in byte
#define PERF_FILENAME_LENGTH (90)
#define PERF_FUNCTION_NAME_LENGTH (50)
/********************************************
* STRUCTURES *
********************************************/
/// interface for Offender
typedef struct
{
void *p_buf;
kal_uint32 size; /// size of p_buf in byte
} protocol_exception_recovery_debug_struct;
/// User API parameter: PROTOCOL_EXCEPTION_RECOVERY()
typedef struct
{
kal_uint8 protocol_id; /**<
0x0 ~ 0x3: protocol stack 1 ~ 4
PEFR_ALL_PROTOCOL_ID (0xF): all protocol stack id
**/
kal_bool disable_escalate_recovery; /// KAL_TRUE: disable escalating recovery feature
protocol_exception_recovery_debug_struct debug;
} protocol_exception_recovery_info_struct;
/// trigger PERF primitive structure (MSG_ID_PROTOCOL_EXCEPTION_RECOVERY)
typedef struct
{
LOCAL_PARA_HDR
protocol_exception_recovery_type_enum recovery_type;
protocol_exception_recovery_info_struct info;
char filename[PERF_FILENAME_LENGTH];
char function_name[PERF_FUNCTION_NAME_LENGTH];
kal_uint32 line;
//kal_uint8 debug_buff_id;
} protocol_exception_recovery_struct;
/// interface for flight mode Actor
typedef struct
{
LOCAL_PARA_HDR
kal_bool is_flight_mode;
kal_uint8 ps_id; /// protocol stack id bitmap
} perf_l4bpwr_flight_mode_recovery_req, perf_l4bpwr_flight_mode_recovery_req_struct;
typedef struct
{
LOCAL_PARA_HDR
kal_bool result;
} perf_l4bpwr_flight_mode_recovery_cnf, perf_l4bpwr_flight_mode_recovery_cnf_struct;
/// interface for LTE local release Actor
typedef struct
{
LOCAL_PARA_HDR
lte_local_release_result_enum cause;
kal_uint8 protocol_id;
} perf_emm_lte_local_release_recovery_cnf, perf_emm_lte_local_release_recovery_cnf_struct;
/// interface for LTE RRC reestablishment Actor
typedef struct
{
LOCAL_PARA_HDR
lte_rrc_reestablish_result_enum cause;
} perf_errc_lte_rrc_reestablishment_recovery_cnf, perf_errc_reestablishment_recovery_cnf_struct;
/********************
NR related Struct.
********************/
/* MSG_ID_ERM_ERROR_IND*/
typedef struct
{
LOCAL_PARA_HDR
protocol_exception_recovery_type_enum err_event;
protocol_exception_recovery_info_struct info;
} erm_error_ind_struct;
/* MSG_ID_ERM_VGMM_ERROR_RECOVERY_REQ */
typedef struct
{
LOCAL_PARA_HDR
error_recovery_method_enum recovery_method;
kal_uint16 timer_period;
} erm_vgmm_error_recovery_req_struct;
/* MSG_ID_ERM_VGMM_ERROR_RECOVERY_CNF */
typedef struct
{
LOCAL_PARA_HDR
} erm_vgmm_error_recovery_cnf_struct;
/********************************************
* MACROS and API *
********************************************/
/// interface for LTE Local Release Actor
/// hook function pointer from EMM to PERF
typedef kal_bool (*perf_query_is_lte_conn_status_idle_f)(kal_uint8 protocol_id);
extern void lte_local_release_actor_hook_conn_status_query_fp(perf_query_is_lte_conn_status_idle_f fp_query);
/// atomic read PERF need update IDLE status (for local release recovery result)
extern void lte_local_release_actor_update_conn_status(kal_bool is_idle, kal_uint8 protocol_id);
kal_bool protocol_exception_recovery_trigger(
module_type module_id,
const char *filename,
const char *function_name,
kal_uint32 line,
protocol_exception_recovery_type_enum recovery_type,
protocol_exception_recovery_info_struct *p_info);
/// Note: User shall "not" use below internal macro directly !
#define __PERF_TRIGGER(_module, _file, _func, _line, _type, _info) \
protocol_exception_recovery_trigger(\
(_module),\
(_file),\
(_func),\
(kal_uint32)(_line),\
(protocol_exception_recovery_type_enum)(_type),\
(protocol_exception_recovery_info_struct *)(_info));
#define _PERF_TRIGGER(_module, _type, _info) \
__PERF_TRIGGER((_module),__FILE__,__func__,__LINE__,(_type),(_info))
#define _PERF_TRIGGER_LITE(_module, _type, _info) \
__PERF_TRIGGER((_module),"","",__LINE__,(_type),(_info))
/// recovery API for general user
#if defined(__MTK_TARGET__) && defined(__PERF_SUPPORT__) && !defined(__DEBUG_ASSERT_SUPPORT__) && !defined(__UE_SIMULATOR__)
/// will change before/after SQC start
#define PROTOCOL_EXCEPTION_RECOVERY _PERF_TRIGGER
#define PROTOCOL_EXCEPTION_RECOVERY_LITE _PERF_TRIGGER_LITE
#define EMM_HOOK_CONN_STATUS_QUERY_FP(_fp) lte_local_release_actor_hook_conn_status_query_fp((_fp))
#define EMM_UPDATE_CONN_STATUS_TO_PERF(_is_idle, _protocol_id) lte_local_release_actor_update_conn_status((_is_idle), (_protocol_id))
#elif defined(UNIT_TEST) && defined(__PERF_SUPPORT__) && !defined(__UE_SIMULATOR__)
/// UT always enable API
#define PROTOCOL_EXCEPTION_RECOVERY _PERF_TRIGGER
#define PROTOCOL_EXCEPTION_RECOVERY_LITE _PERF_TRIGGER_LITE
#define EMM_HOOK_CONN_STATUS_QUERY_FP(_fp) lte_local_release_actor_hook_conn_status_query_fp((_fp))
#define EMM_UPDATE_CONN_STATUS_TO_PERF(_is_idle, _protocol_id) lte_local_release_actor_update_conn_status((_is_idle), (_protocol_id))
#else
/// for other build, always keep assert
#define PROTOCOL_EXCEPTION_RECOVERY(_module, _type, _info) \
ASSERT(0); \
kal_prompt_trace((_module), "[PROTOCOL EXCEPTION] current stage is disable (%x,%x,%x)", (_module), (_type), (_info));
#define PROTOCOL_EXCEPTION_RECOVERY_LITE PROTOCOL_EXCEPTION_RECOVERY
#define EMM_HOOK_CONN_STATUS_QUERY_FP(_fp) lte_local_release_actor_hook_conn_status_query_fp((_fp))
#define EMM_UPDATE_CONN_STATUS_TO_PERF(_is_idle, _protocol_id) if ((_is_idle) && (_protocol_id)){}
#endif // ~ #if defined(__MTK_TARGET__) && !defined(__DEBUG_ASSERT_SUPPORT__) #elif defined(UNIT_TEST) #else
/// recovery API for HISR user
#define PROTOCOL_EXCEPTION_RECOVERY_HISR PROTOCOL_EXCEPTION_RECOVERY
/// recovery API for LISR without multi-thread user
#define PROTOCOL_EXCEPTION_RECOVERY_LISR PROTOCOL_EXCEPTION_RECOVERY
/// recovery API for LISR with multi-thread user
#define PROTOCOL_EXCEPTION_RECOVERY_MT_LISR PROTOCOL_EXCEPTION_RECOVERY
/// Actor result update message send
#ifdef UNIT_TEST
extern perf_ut_msg_send_mode_enum g_ut_enable_msg_send;
#ifdef __GTEST_ENABLE__
#define PERF_UT_MSG_SEND6(...) \
if (g_ut_enable_msg_send == PERF_UT_MSG_SEND_NONE) \
{ \
} \
else if (g_ut_enable_msg_send == PERF_UT_MSG_SEND_UTT) \
{ \
utt_msg_send6(__VA_ARGS__); \
} \
else \
{ \
msg_send6(__VA_ARGS__); \
}
#else
#define PERF_UT_MSG_SEND6(...) \
if (g_ut_enable_msg_send == PERF_UT_MSG_SEND_NONE) \
{ \
} \
else \
{ \
msg_send6(__VA_ARGS__); \
}
#endif // ~ #ifdef __GTEST_ENABLE__ #else
#define PERF_MSG_SEND6(...) PERF_UT_MSG_SEND6(__VA_ARGS__)
#define ENABLE_PERF_MSG_SEND6() do{g_ut_enable_msg_send = PERF_UT_MSG_SEND_UTT;}while(0);
#define ENABLE_PERF_MSG_SEND6_FOR_MSC() do{g_ut_enable_msg_send = PERF_UT_MSG_SEND_KAL;}while(0);
#define DISABLE_PERF_MSG_SEND6() do{g_ut_enable_msg_send = PERF_UT_MSG_SEND_NONE;}while(0);
#define DISABLE_PERF_MSG_SEND6_FOR_MSC DISABLE_PERF_MSG_SEND6
#else
#define PERF_MSG_SEND6(...) msg_send6(__VA_ARGS__)
#endif // ~ #ifdef UNIT_TEST #else
#ifdef __PERF_TEST_MODE__
typedef void (*perf_test_mode_case_f)(void *param);
extern kal_uint32 perf_test_mode_regist_a_case(perf_test_mode_case_f fp, void *param);
#define PERF_REGIST_IT_CASE_FP(_fp, _param) perf_test_mode_regist_a_case((_fp), (void *)(_param))
#else
#define PERF_REGIST_IT_CASE_FP(_fp, _param)
#endif // ~ #ifdef __PERF_TEST_MODE__
#endif // ~ #ifndef _PERF_API_H_