openbcm

Git mirror of https://github.com/Broadcom-Network-Switching-Software/OpenBCM
git clone git://git.finwo.net/mirror/broadcom/openbcm
Log | Files | Refs | README

switch.h (5601B)


      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-2020 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 #include <assert.h>
     15 
     16 #ifdef CRASH_RECOVERY_SUPPORT
     17 #include <soc/dcmn/dcmn_crash_recovery.h>
     18 #include <soc/dcmn/dcmn_crash_recovery_test.h>
     19 #include <soc/dcmn/dcmn_crash_recovery_utils.h>
     20 #else
     21 #if defined(BCM_DNX_SUPPORT)
     22 #include <soc/dnx/dnx_err_recovery_manager.h>
     23 #endif
     24 #if defined(BCM_DNX_SUPPORT) || defined(BCM_DNXF_SUPPORT)
     25 #include <soc/dnxc/dnxc_wb_test_utils.h>
     26 #endif
     27 #endif
     28 
     29 #ifdef BCM_WARM_BOOT_SUPPORT
     30 #include <bcm_int/control.h>
     31 
     32 
     33 #include <soc/defs.h>
     34 extern char warmboot_api_function_name[SOC_MAX_NUM_DEVICES][100];
     35 #if defined(BCM_WARM_BOOT_API_TEST) && (defined(BCM_DNX_SUPPORT) || defined(BCM_DNXF_SUPPORT))
     36 extern char dnxc_warmboot_api_function_name[SOC_MAX_NUM_DEVICES][DNXC_WARMBOOT_API_FUNCTION_NAME_MAX_LEN];
     37 #endif
     38 
     39 extern int _bcm_switch_state_sync(int unit, bcm_dtype_t dtype);
     40 
     41 #if (defined(BCM_PETRA_SUPPORT) || defined(BCM_DFE_SUPPORT)) && defined(BCM_WARM_BOOT_API_TEST)
     42 
     43 #include <soc/dcmn/dcmn_wb.h>
     44 #endif /* BCM_PETRA_SUPPORT && BCM_WARM_BOOT_API_TEST */
     45 
     46 #define BCM_STATE_SYNC(_u) \
     47     /* next line actually call sync only in autosync mode */ \
     48     _bcm_switch_state_sync(_u, dtype);
     49 
     50 #else /* !BCM_WARM_BOOT_SUPPORT */
     51 #define BCM_STATE_SYNC(_u)
     52 #endif /* BCM_WARM_BOOT_SUPPORT */
     53 
     54 
     55 /************** WARM BOOT API TEST ********************/
     56 
     57 #if defined(BCM_WARM_BOOT_API_TEST)
     58 #define DNXC_WARM_BOOT_API_TEST_RESET(unit) \
     59     do { \
     60         if (dnxc_warm_boot_api_test_reset(unit) != 0) \
     61         {\
     62             assert(0);\
     63         }\
     64     } while(0)
     65 
     66 #if defined(BCM_DNX_SUPPORT) || defined(BCM_DNXF_SUPPORT)
     67 #define DNXC_WARM_BOOT_API_TEST_FUNCTION_NAME_UPDATE(unit)                                                                  \
     68     do {                                                                                                                    \
     69         if (dnxc_wb_all_reset_test_utils_preconditions(unit))                                                               \
     70         {                                                                                                                   \
     71             sal_strncpy(dnxc_warmboot_api_function_name[unit], __func__, DNXC_WARMBOOT_API_FUNCTION_NAME_MAX_LEN - 1);  \
     72         }                                                                                                                   \
     73     } while(0)
     74 #else /* defined(BCM_DNX_SUPPORT) || defined(BCM_DNXF_SUPPORT) */
     75 #define DNXC_WARM_BOOT_API_TEST_FUNCTION_NAME_UPDATE(unit) \
     76     sal_strncpy(dnxc_warmboot_api_function_name[unit], __func__, DNXC_WARMBOOT_API_FUNCTION_NAME_MAX_LEN - 1)
     77 #endif /* defined(BCM_DNX_SUPPORT) || defined(BCM_DNXF_SUPPORT) */
     78 
     79 
     80 #define DNXC_WB_API_TEST_COUNTER_INCREASE(unit) \
     81     do { \
     82         dnxc_wb_api_test_counter_increase(unit); \
     83     } while(0)
     84 #define DNXC_WB_API_TEST_COUNTER_DECREASE(unit) \
     85     do { \
     86         dnxc_wb_api_test_counter_decrease(unit); \
     87     } while(0)
     88 #else
     89 #define DNXC_WARM_BOOT_API_TEST_RESET(unit)
     90 #define DNXC_WARM_BOOT_API_TEST_FUNCTION_NAME_UPDATE(unit)
     91 #define DNXC_WB_API_TEST_COUNTER_INCREASE(unit)
     92 #define DNXC_WB_API_TEST_COUNTER_DECREASE(unit)
     93 #endif
     94 
     95 /******************************************************/
     96 
     97 
     98 
     99 /****************** CRASH RECOVERY **************************/
    100 
    101 #ifdef CRASH_RECOVERY_SUPPORT
    102 #define BCM_PRE_API_LOGIC_HOOK(unit)\
    103     SOC_CR_DOCUMENT_API_NAME(unit);\
    104     BCM_CR_TEST_TRANSACTION_START(unit);\
    105     SOC_CR_DISP_ERR_CHECK(soc_dcmn_cr_dispatcher_transaction_start(unit))
    106 #define BCM_POST_API_LOGIC_HOOK(unit)\
    107     SOC_CR_DOCUMENT_API_NAME(unit);\
    108     SOC_CR_DISP_ERR_CHECK(soc_dcmn_cr_dispatcher_transaction_end(unit));\
    109     BCM_CR_TEST_TRANSACTION_END(unit)
    110 #elif !defined(BCM_DNX_SUPPORT) && !defined(BCM_DNXF_SUPPORT)
    111 #define BCM_PRE_API_LOGIC_HOOK(unit)
    112 #define BCM_POST_API_LOGIC_HOOK(unit)
    113 #endif
    114 
    115 /*************************************************************/
    116 
    117 
    118 
    119 /******************* ERROR RECOVERY ***************************/
    120 #if defined(BCM_DNX_SUPPORT)
    121 #define DNXC_ERR_RECOVERY_TRANSACTION_START(_unit) DNX_ERR_RECOVERY_TRANSACTION_START(_unit)
    122 #define DNXC_ERR_RECOVERY_TRANSACTION_END(_unit) DNX_ERR_RECOVERY_TRANSACTION_END(_unit)
    123 #else
    124 #define DNXC_ERR_RECOVERY_TRANSACTION_START(_unit)
    125 #define DNXC_ERR_RECOVERY_TRANSACTION_END(_unit)
    126 #endif
    127 /**************************************************************/
    128 
    129 
    130 /* API TRANSACTION START and API TRANSACTION END */
    131 
    132 #if (defined(BCM_DNX_SUPPORT) || defined(BCM_DNXF_SUPPORT)) && ! defined (CRASH_RECOVERY_SUPPORT)
    133 #define BCM_PRE_API_LOGIC_HOOK(unit)                 \
    134     DNXC_WARM_BOOT_API_TEST_FUNCTION_NAME_UPDATE(unit);\
    135     DNXC_WB_API_TEST_COUNTER_INCREASE(unit);           \
    136     DNXC_ERR_RECOVERY_TRANSACTION_START(unit);         \
    137     DNXC_MTA(dnxc_multithread_analyzer_declare_api_in_play(unit, __func__, MTA_FLAG_DISPATCHER, TRUE));\
    138 
    139 #define BCM_POST_API_LOGIC_HOOK(unit)        \
    140     DNXC_MTA(dnxc_multithread_analyzer_declare_api_in_play(unit, __func__, MTA_FLAG_DISPATCHER, FALSE));\
    141     DNXC_ERR_RECOVERY_TRANSACTION_END(unit);                                                                \
    142     DNXC_WARM_BOOT_API_TEST_RESET(unit);                                                                    \
    143     DNXC_WB_API_TEST_COUNTER_DECREASE(unit)
    144 #endif
    145 
    146 #endif /* _BCM_INT_SWITCH_H_ */