init.h (6300B)
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 * File: stat.h 8 * Purpose: STAT internal definitions to the BCM library. 9 */ 10 11 #ifndef _BCM_INT_DNXF_INIT_H_ 12 #define _BCM_INT_DNXF_INIT_H_ 13 14 #ifndef BCM_DNXF_SUPPORT 15 #error "This file is for use by DNXF (Ramon) family only!" 16 #endif 17 18 #include <shared/shrextend/shrextend_debug.h> 19 #include <shared/utilex/utilex_seq.h> 20 #include <sal/core/time.h> 21 22 /** 23 * Default time threshold (in microseconds) for the time each 24 * step is taking during init. This value was chosen because the 25 * majority of the steps are below it. For steps that are 26 * expected to be above the default DNXF Data can be used. 27 */ 28 #define BCM_DNXF_INIT_STEP_TIME_THRESH_DEFAULT 1000000 29 30 /** 31 * \brief 32 * Time threshold flags - used for testing how much time each step in the Init takes. 33 * If flag is set to PER_DEVICE the value will be taken from DNX data. THIS FLAG CAN NOT BE USED FOR STEPS BEFORE DNX DATA IS INITIALIZED 34 * If no flag is specified, default value will be assumed. 35 */ 36 #define DNXF_INIT_STEP_F_TIME_THRESH_PER_DEVICE UTILEX_SEQ_STEP_F_TIME_THRESH_PER_DEVICE 37 38 /** 39 * Skip Step due to WB 40 */ 41 #define DNXF_INIT_STEP_F_WB_SKIP UTILEX_SEQ_STEP_F_WB_SKIP 42 43 typedef enum 44 { 45 /** 46 * Invalid Value, used to indicate to APIs that this input is 47 * not relevant 48 */ 49 DNXF_INIT_STEP_INVALID_STEP = UTILEX_SEQ_STEP_INVALID, 50 /** 51 * Value used get the first step of the enum 52 */ 53 DNXF_INIT_STEP_FIRST_STEP = UTILEX_SEQ_STEP_INVALID + 1, 54 /** 55 * INIT Mark SOC FLAGS NOT INITED 56 */ 57 DNXF_INIT_STEP_MARK_NOT_INITED, 58 /** 59 * INIT DNX Data 60 */ 61 DNXF_INIT_STEP_DNX_DATA, 62 /** 63 * INIT SW State and HA modules 64 */ 65 DNXF_INIT_STEP_SW_STATE, 66 /** 67 * INIT SOC 68 */ 69 DNXF_INIT_STEP_SOC, 70 /** 71 * INIT Port module 72 */ 73 DNXF_INIT_STEP_PORT, 74 /** 75 * INIT Linkscan module 76 */ 77 DNXF_INIT_STEP_LINKSCAN, 78 /** 79 * INIT Stat module 80 */ 81 DNXF_INIT_STEP_STAT, 82 /** 83 * INIT Stack module 84 */ 85 DNXF_INIT_STEP_STACK, 86 /** 87 * INIT Multicast module 88 */ 89 DNXF_INIT_STEP_MULTICAST, 90 /** 91 * INIT Fabric module 92 */ 93 DNXF_INIT_STEP_FABRIC, 94 /** 95 * INIT RX module 96 */ 97 DNXF_INIT_STEP_RX, 98 /** 99 * INIT Tune 100 */ 101 DNXF_INIT_STEP_TUNE, 102 /** 103 * Mark init done 104 */ 105 DNXF_INIT_STEP_INIT_DONE, 106 /** 107 * Number of init steps. 108 */ 109 DNXF_INIT_STEP_COUNT, 110 /** 111 * Dummy step, used to indicate the last step for a step list. 112 */ 113 DNXF_INIT_STEP_LAST_STEP = UTILEX_SEQ_STEP_LAST 114 } dnxf_init_step_id_e; 115 116 /** 117 * \brief ptr to step cb function returning shr_error_e, to be 118 * used in each init/deinit step. the step_list_info and the 119 * flags are used for internal purposes, and are managed by the 120 * mechanism. 121 */ 122 typedef shr_error_e( 123 *dnxf_step_cb) ( 124 int unit); 125 126 /** 127 * \brief ptr to step flag cb function returning 128 * shr_error_e, to be used in each init step to decode flags 129 * according to a given step logic ( for example Step X should 130 * be skipped if SOC property Y is set to value Z etc). to do 131 * so, one would need to return in dynamic flags the 132 * DNX_INIT_STEP_F_SKIP_DYNAMIC flag. 133 */ 134 typedef shr_error_e( 135 *dnxf_step_flag_cb) ( 136 int unit, 137 int *dynamic_flags); 138 139 /** 140 * \brief step/sub-step structure. 141 * 142 * each step in the Init/Deinit process should be well defined. 143 * each step should have an Init and Deinit function. 144 * the Deinit function should not access the HW, just free SW resources. 145 * a flag CB can also be used, so each step can activate flags according 146 * to dedicated SOC properties or other logic. 147 */ 148 typedef struct dnxf_init_step_s dnxf_init_step_t; 149 150 struct dnxf_init_step_s 151 { 152 /** 153 * Step ID, used to uniquely identify a step. 154 */ 155 dnxf_init_step_id_e step_id; 156 157 /** 158 * Step name 159 */ 160 char *step_name; 161 162 /** 163 * Init function CB that will run during the Init Sequence. 164 */ 165 dnxf_step_cb init_function; 166 167 /** 168 * Deinit function CB that will run during the Deinit Sequence. 169 */ 170 dnxf_step_cb deinit_function; 171 172 /** 173 * Step Flags, internal flags used by the system's logic 174 */ 175 int step_flags; 176 177 /** 178 * Time threshold - the maximum time the step should take in 179 * microseconds. If set to 0 the default value will be used. 180 */ 181 sal_time_t time_thresh; 182 }; 183 184 /** 185 * \brief dnxf init arguments structure. 186 * 187 * This structure should contain user's information. 188 * currently soc properties can be used to update it 189 * until advanced init is implemented 190 */ 191 typedef struct 192 { 193 /** 194 * this is used to start the init sequence from a certain step. 195 * this will be used after stopping the init sequence with last 196 * step. the default for this should be the 197 * DNXF_INIT_STEP_LAST_STEP step id. 198 */ 199 dnxf_init_step_id_e first_step; 200 201 /** 202 * this is used to stop the init sequence at a certain step. 203 * to continue use the init function with first step defined as 204 * next step of this. the default for this should be the 205 * DNXF_INIT_STEP_LAST_STEP step id. 206 */ 207 dnxf_init_step_id_e last_step; 208 } dnxf_init_info_t; 209 210 /** 211 * \brief - Get the time threshold of a given step in BCM init according to the 212 * step ID and the step fags. If called with flag UTILEX_SEQ_STEP_INVALID 213 * will return the overall threshold for the full sequence. In this case 214 * flags are not relevant. 215 * 216 * \param [in] unit - Unit # 217 * \param [in] step_id - Step ID 218 * \param [in] flags - Step flags 219 * \param [out] time_thresh - Time threshold for the specified step 220 * \return 221 * shr_error_e 222 * \remark 223 * * None 224 * \see 225 * * None 226 */ 227 shr_error_e dnxf_time_thresh_cb( 228 int unit, 229 int step_id, 230 uint32 flags, 231 sal_usecs_t *time_thresh); 232 233 shr_error_e 234 dnxf_init_step_list_destory( 235 int unit, 236 utilex_seq_step_t * step_list); 237 238 /** 239 * \brief Convert dnxf_init_deinit_seq to utilex list 240 */ 241 shr_error_e 242 dnxf_init_step_list_convert( 243 int unit, 244 const dnxf_init_step_t * dnxf_step_list, 245 utilex_seq_step_t ** step_list); 246 247 #endif /*_BCM_INT_DNXF_INIT_H_*/