appl_ref_init_utils.h (6286B)
1 /** \file appl_ref_init_utils.h 2 * 3 * init and deinit utitlity functions to be used by the INIT_DNX command. 4 */ 5 6 /* 7 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 8 * 9 * Copyright 2007-2020 Broadcom Inc. All rights reserved. 10 */ 11 12 #ifndef FILE_APPL_REF_DNXC_INIT_UTILS_H_INCLUDED 13 /* { */ 14 #define FILE_APPL_REF_DNXC_INIT_UTILS_H_INCLUDED 15 16 #if !defined(BCM_DNX_SUPPORT) && !defined(BCM_DNXF_SUPPORT) 17 #error "This file is for use by DNXC family only!" 18 #endif 19 20 #include <shared/utilex/utilex_seq.h> 21 #include <bcm/init.h> 22 /* 23 * MACROs: 24 * { 25 */ 26 27 /* 28 * } 29 */ 30 31 /* 32 * Memory Leak detection Activated. 33 */ 34 #define APPL_INIT_ADVANCED_F_MEM_LEAK_DETECT BCM_INIT_ADVANCED_F_MEM_LEAK_DETECT 35 /* 36 * Memory Logging 37 */ 38 #define APPL_INIT_ADVANCED_F_MEM_LOG BCM_INIT_ADVANCED_F_MEM_LOG 39 40 /* 41 * Time Stamp saving Activated. 42 */ 43 #define APPL_INIT_ADVANCED_F_TIME_STAMP BCM_INIT_ADVANCED_F_TIME_STAMP 44 /* 45 * Time Stamp saving Activated. 46 */ 47 #define APPL_INIT_ADVANCED_F_TIME_LOG BCM_INIT_ADVANCED_F_TIME_LOG 48 /* 49 * SW state resources Logging 50 */ 51 #define APPL_INIT_ADVANCED_F_SWSTATE_LOG BCM_INIT_ADVANCED_F_SWSTATE_LOG 52 /* 53 * Access only 54 */ 55 #define APPL_INIT_ADVANCED_F_ACCESS_ONLY BCM_INIT_ADVANCED_F_ACCESS_ONLY 56 /* 57 * Multithreading activated. 58 */ 59 #define APPL_INIT_ADVANCED_F_MULTITHREAD BCM_INIT_ADVANCED_F_MULTITHREAD 60 /* 61 * KBP Multithreading activated. 62 */ 63 #define APPL_INIT_ADVANCED_F_KBP_MULTITHREAD BCM_INIT_ADVANCED_F_KBP_MULTITHREAD 64 /* 65 * Heat-up 66 */ 67 #define APPL_INIT_ADVANCED_F_HEAT_UP BCM_INIT_ADVANCED_F_HEAT_UP 68 69 /** 70 * \brief 71 * Time threshold flag EXPLICIT - used for testing how much time each step in the Init takes. 72 * If EXPLICIT flag is specified, the value will be taken from a user-defined array(appl_init_time_thresh_expl). 73 * If no flag is specified, default value (APPL_INIT_STEP_TIME_THRESH_DEFAULT, defined at appl_ref_init_utils.h) will be assumed. 74 * If flag is set to PER_DEVICE the value will be taken from device specific data. 75 */ 76 #define APPL_INIT_ADVANCED_F_TIME_THRESH_EXPLICIT UTILEX_SEQ_STEP_F_TIME_THRESH_EXPLICIT 77 #define APPL_INIT_ADVANCED_F_TIME_THRESH_PER_DEVICE UTILEX_SEQ_STEP_F_TIME_THRESH_PER_DEVICE 78 79 /* 80 * Default time threshold (in microseconds) for the time each 81 * step is taking during init. This value was chosen because the 82 * majority of the steps are below it. For steps that are 83 * expected to be above the default, a specific threshold can be 84 * set. 85 */ 86 #define APPL_INIT_STEP_TIME_THRESH_DEFAULT 100000 87 88 /* 89 * Structs and Enums: 90 * { 91 */ 92 93 /** 94 * \brief Application init step/sub-step structure. 95 * 96 * Each step in the application Init/Deinit process should be well defined. 97 * Each step should have an Init and Deinit function. 98 * General step flags are required so applications can be masked using soc properties and invoked within 99 * the diag shell. 100 */ 101 typedef struct appl_dnxc_init_step_s appl_dnxc_init_step_t; 102 struct appl_dnxc_init_step_s 103 { 104 /** 105 * step id 106 */ 107 int step_id; 108 /** 109 * Step name 110 */ 111 char *name; 112 /** 113 * enable/disable soc property suffix 114 */ 115 char *suffix; 116 /** 117 * Callback to add function 118 */ 119 utilex_seq_cb_f init_func; 120 /** 121 * Callback to remove function 122 */ 123 utilex_seq_cb_f deinit_func; 124 /** 125 * Flag function CB that will run prior to the init function of 126 * this step to determine which flags are needed to the step 127 * according to the CB logic - could be looking for certain SOC 128 * properties for example. 129 */ 130 utilex_seq_flag_cb_f flag_function; 131 /** 132 * Step Flags, internal flags used by the system's logic 133 */ 134 int step_flags; 135 136 /** 137 * List of substeps (optional - might be null if not required) 138 */ 139 const appl_dnxc_init_step_t *sub_list; 140 141 }; 142 143 /** 144 * \brief Structure holding information for steps and their relative time thresholds. 145 * 146 * This structure is used for steps with APPL_INIT_ADVANCED_F_TIME_THRESH_EXPLICIT 147 * flag in order to link the Step ID to the specific user defined time threshold. 148 */ 149 typedef struct 150 { 151 /** 152 * Step ID, used to uniquely identify a step. 153 */ 154 int step_id; 155 156 /** 157 * Time threshold - the maximum time the step should take in 158 * microseconds. 159 */ 160 sal_time_t time_thresh; 161 } appl_init_time_thresh_info_t; 162 163 /* 164 * } 165 */ 166 167 168 /* 169 * Function Declarations: 170 * { 171 */ 172 173 /** 174 * \brief - Deep conversion of appl_dnxc_init_step_t to utilex_seq_step_t 175 * The conversion allocate memory that should be freed using 'dnx_step_list_destroy()' 176 * 177 * \param [in] unit - Unit ID 178 * \param [in] dnx_step_list - Application list of steps 179 * \param [in] step_list - utilex list of steps 180 * 181 * \return 182 * shr_error_e 183 * 184 * \remark 185 * * None 186 * \see 187 * * None 188 */ 189 shr_error_e 190 appl_dnxc_init_step_list_convert( 191 int unit, 192 const appl_dnxc_init_step_t * dnx_step_list, 193 utilex_seq_step_t ** step_list); 194 195 /** 196 * \brief - Converting dnxc application sequence to utilex_seq 197 * 198 * \param [in] unit - Unit ID 199 * \param [in] step_list - list of steps 200 * \param [in] forward - whether to run forward or backward functions 201 * \param [in] seq - returns utilex sequence 202 * 203 * \return 204 * shr_error_e 205 * 206 * \remark 207 * * None 208 * \see 209 * * None 210 */ 211 shr_error_e 212 appl_dnxc_init_seq_convert( 213 int unit, 214 const appl_dnxc_init_step_t * step_list, 215 int forward, 216 utilex_seq_t * seq); 217 218 /** 219 * \brief - Running dnxc application list backward and forward 220 * 221 * \param [in] unit - Unit ID 222 * \param [in] step_list - a list of steps 223 * \param [in] forward - Whether to run the list forward (TRUE - forward, FALSE - backward) 224 * 225 * \return 226 * shr_error_e 227 * 228 * \remark 229 * * None 230 * \see 231 * * None 232 */ 233 shr_error_e 234 appl_dnxc_steps_convert_and_run( 235 int unit, 236 const appl_dnxc_init_step_t *step_list, 237 int forward); 238 239 240 /** 241 * \brief - Deallocate an allocated list of utilex steps 242 * 243 * \param [in] unit - Unit ID 244 * \param [in] step_list - List of steps 245 * 246 * \return 247 * shr_error_e 248 * 249 * \remark 250 * * None 251 * \see 252 * * None 253 */ 254 shr_error_e 255 appl_dnxc_init_step_list_destory( 256 int unit, 257 utilex_seq_step_t * step_list); 258 /* 259 * } 260 */ 261 262 /* } */ 263 #endif