switch.h (4579B)
1 /* 2 * 3 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 4 * 5 * Copyright 2007-2019 Broadcom Inc. All rights reserved. 6 * 7 * Common internal definitions for BCM switch module 8 */ 9 10 #ifndef _BCM_INT_SWITCH_H_ 11 #define _BCM_INT_SWITCH_H_ 12 13 #include <soc/dnxc/multithread_analyzer.h> 14 15 #ifdef CRASH_RECOVERY_SUPPORT 16 #include <soc/dcmn/dcmn_crash_recovery.h> 17 #include <soc/dcmn/dcmn_crash_recovery_test.h> 18 #include <soc/dcmn/dcmn_crash_recovery_utils.h> 19 #else 20 #if defined(BCM_DNX_SUPPORT) 21 #include <soc/dnx/dnx_err_recovery_manager.h> 22 #endif 23 #if defined(BCM_DNX_SUPPORT) || defined(BCM_DNXF_SUPPORT) 24 #include <soc/dnxc/dnxc_wb_test_utils.h> 25 #endif 26 #endif 27 28 #ifdef BCM_WARM_BOOT_SUPPORT 29 #include <bcm_int/control.h> 30 31 32 #include <soc/defs.h> 33 extern char warmboot_api_function_name[SOC_MAX_NUM_DEVICES][100]; 34 #if defined(BCM_WARM_BOOT_API_TEST) && (defined(BCM_DNX_SUPPORT) || defined(BCM_DNXF_SUPPORT)) 35 extern char dnxc_warmboot_api_function_name[SOC_MAX_NUM_DEVICES][DNXC_WARMBOOT_API_FUNCTION_NAME_MAX_LEN]; 36 #endif 37 38 extern int _bcm_switch_state_sync(int unit, bcm_dtype_t dtype); 39 40 #if (defined(BCM_PETRA_SUPPORT) || defined(BCM_DFE_SUPPORT)) && defined(BCM_WARM_BOOT_API_TEST) 41 42 #include <soc/dcmn/dcmn_wb.h> 43 #endif /* BCM_PETRA_SUPPORT && BCM_WARM_BOOT_API_TEST */ 44 45 #define BCM_STATE_SYNC(_u) \ 46 /* next line actually call sync only in autosync mode */ \ 47 _bcm_switch_state_sync(_u, dtype); 48 49 #else /* !BCM_WARM_BOOT_SUPPORT */ 50 #define BCM_STATE_SYNC(_u) 51 #endif /* BCM_WARM_BOOT_SUPPORT */ 52 53 54 /************** WARM BOOT API TEST ********************/ 55 56 #if defined(BCM_WARM_BOOT_API_TEST) 57 #define DNXC_WARM_BOOT_API_TEST_RESET(unit) \ 58 do { \ 59 dnxc_warm_boot_api_test_reset(unit); \ 60 } while(0) 61 62 #define DNXC_WARM_BOOT_API_TEST_FUNCTION_NAME_UPDATE(unit) \ 63 sal_strncpy(dnxc_warmboot_api_function_name[unit], __FUNCTION__, DNXC_WARMBOOT_API_FUNCTION_NAME_MAX_LEN - 1) 64 65 #define DNXC_WB_API_TEST_COUNTER_INCREASE(unit) \ 66 do { \ 67 dnxc_wb_api_test_counter_increase(unit); \ 68 } while(0) 69 #define DNXC_WB_API_TEST_COUNTER_DECREASE(unit) \ 70 do { \ 71 dnxc_wb_api_test_counter_decrease(unit); \ 72 } while(0) 73 #else 74 #define DNXC_WARM_BOOT_API_TEST_RESET(unit) 75 #define DNXC_WARM_BOOT_API_TEST_FUNCTION_NAME_UPDATE(unit) 76 #define DNXC_WB_API_TEST_COUNTER_INCREASE(unit) 77 #define DNXC_WB_API_TEST_COUNTER_DECREASE(unit) 78 #endif 79 80 /******************************************************/ 81 82 83 84 /****************** CRASH RECOVERY **************************/ 85 86 #ifdef CRASH_RECOVERY_SUPPORT 87 #define BCM_PRE_API_LOGIC_HOOK(unit)\ 88 SOC_CR_DOCUMENT_API_NAME(unit);\ 89 BCM_CR_TEST_TRANSACTION_START(unit);\ 90 SOC_CR_DISP_ERR_CHECK(soc_dcmn_cr_dispatcher_transaction_start(unit)) 91 #define BCM_POST_API_LOGIC_HOOK(unit)\ 92 SOC_CR_DOCUMENT_API_NAME(unit);\ 93 SOC_CR_DISP_ERR_CHECK(soc_dcmn_cr_dispatcher_transaction_end(unit));\ 94 BCM_CR_TEST_TRANSACTION_END(unit) 95 #elif !defined(BCM_DNX_SUPPORT) && !defined(BCM_DNXF_SUPPORT) 96 #define BCM_PRE_API_LOGIC_HOOK(unit) 97 #define BCM_POST_API_LOGIC_HOOK(unit) 98 #endif 99 100 /*************************************************************/ 101 102 103 104 /******************* ERROR RECOVERY ***************************/ 105 #if defined(BCM_DNX_SUPPORT) 106 #define DNXC_ERR_RECOVERY_TRANSACTION_START(_unit) DNX_ERR_RECOVERY_TRANSACTION_START(_unit) 107 #define DNXC_ERR_RECOVERY_TRANSACTION_END(_unit) DNX_ERR_RECOVERY_TRANSACTION_END(_unit) 108 #else 109 #define DNXC_ERR_RECOVERY_TRANSACTION_START(_unit) 110 #define DNXC_ERR_RECOVERY_TRANSACTION_END(_unit) 111 #endif 112 /**************************************************************/ 113 114 115 /* API TRANSACTION START and API TRANSACTION END */ 116 117 #if (defined(BCM_DNX_SUPPORT) || defined(BCM_DNXF_SUPPORT)) && ! defined (CRASH_RECOVERY_SUPPORT) 118 #define BCM_PRE_API_LOGIC_HOOK(unit) \ 119 DNXC_WARM_BOOT_API_TEST_FUNCTION_NAME_UPDATE(unit);\ 120 DNXC_WB_API_TEST_COUNTER_INCREASE(unit); \ 121 DNXC_ERR_RECOVERY_TRANSACTION_START(unit); \ 122 DNXC_MTA(dnxc_multithread_analyzer_declare_api_in_play(unit, __FUNCTION__, MTA_FLAG_DISPATCHER, TRUE));\ 123 124 #define BCM_POST_API_LOGIC_HOOK(unit) \ 125 DNXC_MTA(dnxc_multithread_analyzer_declare_api_in_play(unit, __FUNCTION__, MTA_FLAG_DISPATCHER, FALSE));\ 126 DNXC_ERR_RECOVERY_TRANSACTION_END(unit); \ 127 DNXC_WARM_BOOT_API_TEST_RESET(unit); \ 128 DNXC_WB_API_TEST_COUNTER_DECREASE(unit) 129 #endif 130 131 #endif /* _BCM_INT_SWITCH_H_ */