sw_state_defs.h (28531B)
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 * INFO: this module is the entry point (the root) for the entire SDK global 8 * sw state. 9 * if we look at the sw state as a tree, then the root lies at shr_sw_state_t, 10 * it's main branches (module's entry points) are defined here inside this file. 11 * and it continue to expand in the specific module's .h files (which are 12 * the files in shared/swstate/sw_state_includes.h) 13 */ 14 #ifndef _SHR_SW_STATE_DEFS_H 15 /* { */ 16 #define _SHR_SW_STATE_DEFS_H 17 18 #include <soc/types.h> 19 #include <sal/core/sync.h> 20 #include <shared/swstate/sw_state_includes.h> 21 #include <shared/swstate/sw_state_example.h> 22 #ifdef BCM_DNX_SUPPORT 23 /* { */ 24 #include <soc/dnx/dbal/dbal_structures.h> 25 /* } */ 26 #endif 27 #include <soc/dpp/dpp_sw_state.h> 28 #include <bcm_int/dpp/bcm_sw_state.h> 29 #include <shared/swstate/sw_state_workarounds.h> 30 #include <shared/swstate/sw_state_def_init_indexes.h> 31 #include <shared/swstate/sw_state.h> 32 #include <soc/error.h> 33 #include <bcm/error.h> 34 #include <shared/swstate/sw_state_defs_issu_test.h> 35 36 37 #if !defined(BCM_WARM_BOOT_SUPPORT) 38 #include <shared/swstate/sw_state_no_wb_defs.h> 39 #else 40 /* if we do SOC_INIT_FUNC_DEFS it breaks some tests */ 41 #define SW_STATE_INIT_FUNC_DEFS\ 42 int _rv = SOC_E_NONE 43 44 /* if we do SOC_FUNC_RETURN it breaks some tests */ 45 #define SW_STATE_FUNC_RETURN\ 46 goto exit;\ 47 exit:\ 48 return _rv 49 50 /* if we do SOC_FUNC_RETURN it breaks some tests */ 51 #define SW_STATE_IF_ERR_EXIT(_rc)\ 52 _SOC_IF_ERR_EXIT(_rc) 53 54 /* 55 * allow masking of some of the sw state autosync calls as specified by the specific set/get access functions. 56 * in order to mask autosynv call for some of the state the sw state autocoder should be re-run in order to regenerate the access functions, 57 * the following hint should be added to the struct that need to be excluded PARSER_HINT_AUTOSYNC_EXCLUDE 58 * usage example: mask autosync for counter structures as they are being extensively accessed by counter thread. 59 */ 60 #define ALLOW_MASKING_AUTOSYNC_CALLS (1) 61 62 #define SW_STATE_DO_AUTOSYNC(access_function_permission) \ 63 (!ALLOW_MASKING_AUTOSYNC_CALLS || access_function_permission) 64 65 /* for now follow the autosync routine */ 66 #define SW_STATE_DO_JOURNALING(unit)\ 67 (SOC_CR_ENABALED(unit)) 68 69 /* 70 * define this flag to give away High Availability 71 * and SW state validations/diags : 72 * !!! SHR_THIN_SW_STATE !!! 73 * if defined: 74 * AutoSync warnboot will not be supported 75 * Journaling/Crash Recovery will not be supported 76 * Sanity access validations will not be supported 77 * diagnostic tools will not be supported 78 * 79 * this flag should be disabled in case these features are not needed 80 * and performance is crutial to the system 81 */ 82 #if !defined(CRASH_RECOVERY_SUPPORT) 83 #if 1 84 #define SHR_THIN_SW_STATE 1 85 #endif 86 #endif 87 88 /* 89 * When this flag is defined some sanity Validations will be added to 90 * the SW State Access function, this may introduce some performance decrease 91 */ 92 93 94 /* 95 * define this flag to enable autosync optimization (autosync only if modified) 96 * use this empiricly to get better performance in autosync mode. 97 * the optimization will only call external storage I/O callbacks if 98 * state has changed by the "set" call. 99 * it introduce a negligble overhead of checking if the set changes the state 100 * but if application's storage is slow it may save a lot of time by not accessing 101 * it in cases data wasn't modified 102 * 103 * #define SW_STATE_AUTOSYNC_OPTIMIZATION 104 */ 105 106 107 108 109 /* sw state flags */ 110 #define SW_STATE_NONE (0) 111 #define SW_STATE_IS_WB_CHECK (1 << 0) 112 #define SW_STATE_ALLOW_AUTOSYNC (1 << 1) 113 114 #ifdef SHR_SW_STATE_VERIFICATIONS 115 #define SHR_SW_STATE_VERIFY(op)\ 116 SW_STATE_IF_ERR_EXIT(op) 117 #else 118 #define SHR_SW_STATE_VERIFY(op) 119 #endif 120 121 /**********************************************/ 122 /*********** CORE ACCESS MACROS ***************/ 123 /**********************************************/ 124 #ifdef SHR_THIN_SW_STATE /*SHR_THIN_SW_STATE*/ 125 126 #define SHR_SW_STATE_SET(unit, location, input, type, flags, dbg_string)\ 127 location = input; 128 #define SHR_SW_STATE_MEMSET(unit, location, input, type, flags, dbg_string)\ 129 sal_memcpy(&location, input, sizeof(type)); 130 131 #else /*SHR_THIN_SW_STATE*/ 132 133 #define SHR_SW_STATE_SET(unit, location, input, type, flags, dbg_string)\ 134 shr_sw_state_memcpy(unit, (uint8 *) &location, (uint8 *) &input, sizeof(type), flags); 135 136 137 /* the following macro is for catching valgrind issues of "variable.set(&value)" with uninitalized value */ 138 139 #if 1 140 #define SW_STATE_VALGRIND_USE(location, type) 141 #endif 142 143 #define SHR_SW_STATE_MEMSET(unit, location, input, type, flags, dbg_string)\ 144 do { \ 145 shr_sw_state_memcpy(unit,(uint8 *) &location, (uint8 *) input, sizeof(type), flags); \ 146 SW_STATE_VALGRIND_USE(location, type); \ 147 } while(0) 148 149 #endif /*SHR_THIN_SW_STATE*/ 150 151 #define SHR_SW_STATE_ALLOC(unit, location, size, flags, dbg_string)\ 152 shr_sw_state_alloc(unit, (uint8**) &location, size, flags, dbg_string); 153 #define SHR_SW_STATE_FREE(unit, location, flags, dbg_string)\ 154 shr_sw_state_free(unit, (uint8*) location, flags); 155 #define SHR_SW_STATE_IS_ALLOC(unit, location, is_alloc, flags, dbg_string)\ 156 *is_alloc = (location) ? 1 : 0; 157 158 /**********************************************/ 159 /**********************************************/ 160 /**********************************************/ 161 162 163 164 165 /**********************************************/ 166 /******** SHR_BITDCL ACCESS MACROS ************/ 167 /**********************************************/ 168 /* we allocate one more byte to save the num of extra bit allocated */ 169 #define SHR_SW_STATE_ALLOC_BITMAP(unit, location, nof_bits_to_alloc, flags, dbg_string)\ 170 shr_sw_state_alloc(unit, (uint8**) &location, SHR_BITALLOCSIZE(_nof_bits_to_alloc) + 1, flags, dbg_string);\ 171 shr_sw_state_shr_bitdcl_nof_bits_update(unit, (uint8 *)(location), (nof_bits_to_alloc), flags); 172 173 #ifdef SHR_THIN_SW_STATE /*SHR_THIN_SW_STATE*/ 174 175 #define SHR_SW_STATE_BIT_SET(_unit, _flags, _sw_state_bmp, __bit_num)\ 176 SHR_BITSET(_sw_state_bmp, __bit_num); 177 #define SHR_SW_STATE_BIT_CLEAR(_unit, _flags ,_sw_state_bmp, __bit_num)\ 178 SHR_BITCLR(_sw_state_bmp, __bit_num); 179 #define SHR_SW_STATE_BIT_GET(_unit, _flags, _sw_state_bmp, __bit_num , _bit_result)\ 180 *(_bit_result) = (SHR_BITGET(_sw_state_bmp, __bit_num) > 0) ? 1: 0; 181 #define SHR_SW_STATE_BIT_RANGE_READ(_unit, _flags, _sw_state_bmp, _sw_state_bmp_first, _result_first, __range, _result_bmp)\ 182 SHR_BITCOPY_RANGE(_result_bmp, result_first, _sw_state_bmp, _sw_state_bmp_first, __range); 183 #define SHR_SW_STATE_BIT_RANGE_WRITE(_unit, _flags, _sw_state_bmp, _sw_state_bmp_first, _input_bmp_first, __range, _input_bmp)\ 184 SHR_BITCOPY_RANGE(_sw_state_bmp, _sw_state_bmp_first, _input_bmp, _input_bmp_first, __range); 185 #define SHR_SW_STATE_BIT_RANGE_AND(_unit, _flags, _sw_state_bmp, _input_bmp, _sw_state_bmp_first, __count)\ 186 SHR_BITAND_RANGE(_input_bmp, _sw_state_bmp, _sw_state_bmp_first, __count, _sw_state_bmp); 187 #define SHR_SW_STATE_BIT_RANGE_OR(_unit, _flags, _sw_state_bmp, _input_bmp, _sw_state_bmp_first, __count)\ 188 SHR_BITOR_RANGE(_input_bmp, _sw_state_bmp, _sw_state_bmp_first, __count, _sw_state_bmp); 189 #define SHR_SW_STATE_BIT_RANGE_XOR(_unit, _flags, _sw_state_bmp, _input_bmp, _sw_state_bmp_first, __count)\ 190 SHR_BITXOR_RANGE(_input_bmp, _sw_state_bmp, _sw_state_bmp_first, __count, _sw_state_bmp); 191 #define SHR_SW_STATE_BIT_RANGE_REMOVE(_unit, _flags, _sw_state_bmp, _input_bmp, _sw_state_bmp_first, __count)\ 192 SHR_BITREMOVE_RANGE(_input_bmp, _sw_state_bmp, _sw_state_bmp_first, __count, _sw_state_bmp); 193 #define SHR_SW_STATE_BIT_RANGE_NEGATE(_unit, _flags, _sw_state_bmp, _sw_state_bmp_first, __count)\ 194 SHR_BITNEGATE_RANGE(_sw_state_bmp, _sw_state_bmp_first, __count, _sw_state_bmp); 195 #define SHR_SW_STATE_BIT_RANGE_CLEAR(_unit, _flags, _sw_state_bmp, _sw_state_bmp_first, __count)\ 196 SHR_BITCLR_RANGE(_sw_state_bmp, _sw_state_bmp_first, __count); 197 #define SHR_SW_STATE_BIT_RANGE_SET(_unit, _flags, _sw_state_bmp, _sw_state_bmp_first, __count)\ 198 SHR_BITSET_RANGE(_sw_state_bmp, _sw_state_bmp_first, __count); 199 #define SHR_SW_STATE_BIT_RANGE_NULL(_unit, _flags, _sw_state_bmp, _sw_state_bmp_first, __count, _bool_result)\ 200 *(_bool_result) = (SHR_BITNULL_RANGE(_sw_state_bmp, _sw_state_bmp_first, __count) > 0) ? 1: 0; 201 #define SHR_SW_STATE_BIT_RANGE_TEST(_unit, _flags, _sw_state_bmp, _sw_state_bmp_first, __count, _bool_result)\ 202 SHR_BITTEST_RANGE(_sw_state_bmp, _sw_state_bmp_first, __count, *(_bool_result)); 203 #define SHR_SW_STATE_BIT_RANGE_EQ(_unit, _flags, _sw_state_bmp, _sw_state_bmp_first, __count, _input_bmp, _bool_result)\ 204 *(_bool_result) = (SHR_BITEQ_RANGE(_input_bmp, _sw_state_bmp, _sw_state_bmp_first, __count) > 0) ? 1: 0; 205 #define SHR_SW_STATE_BIT_RANGE_COUNT(_unit, _flags, _sw_state_bmp, _sw_state_bmp_first, __range, _int_result)\ 206 shr_bitop_range_count(_sw_state_bmp, _sw_state_bmp_first, __range, _int_result); 207 208 #else /*SHR_THIN_SW_STATE*/ 209 210 #define SHR_SW_STATE_BIT_SET(_unit, _flags, _sw_state_bmp, __bit_num)\ 211 do {\ 212 sw_state_bitdcl_param_t param;\ 213 param.flags = _flags; param.op = SW_ST_BIT_SET; param.sw_state_bmp = _sw_state_bmp; param._bit_num = __bit_num;\ 214 SHR_SW_STATE_BIT_OP(_unit, param);\ 215 } while(0) 216 #define SHR_SW_STATE_BIT_CLEAR(_unit, _flags ,_sw_state_bmp, __bit_num)\ 217 do {\ 218 sw_state_bitdcl_param_t param;\ 219 param.flags = _flags; param.op = SW_ST_BIT_CLEAR;\ 220 param.sw_state_bmp = _sw_state_bmp; param._bit_num = __bit_num;\ 221 SHR_SW_STATE_BIT_OP(_unit, param);\ 222 } while(0) 223 #define SHR_SW_STATE_BIT_GET(_unit, _flags, _sw_state_bmp, __bit_num , _bit_result)\ 224 do {\ 225 sw_state_bitdcl_param_t param;\ 226 param.flags = _flags; param.op = SW_ST_BIT_GET; param.sw_state_bmp = _sw_state_bmp;\ 227 param._bit_num = __bit_num; param.bit_result = _bit_result;\ 228 SHR_SW_STATE_BIT_OP(_unit, param);\ 229 } while(0) 230 #define SHR_SW_STATE_BIT_RANGE_READ(_unit, _flags, _sw_state_bmp, _sw_state_bmp_first, _result_first, __range, _result_bmp)\ 231 do {\ 232 sw_state_bitdcl_param_t param;\ 233 param.flags = _flags; param.op = SW_ST_BIT_RANGE_READ;\ 234 param.sw_state_bmp = _sw_state_bmp; param.sw_state_bmp_first = _sw_state_bmp_first; param.result_first = _result_first;\ 235 param._range = __range; param.result_bmp = _result_bmp;\ 236 SHR_SW_STATE_BIT_OP(_unit, param);\ 237 } while(0) 238 #define SHR_SW_STATE_BIT_RANGE_WRITE(_unit, _flags, _sw_state_bmp, _sw_state_bmp_first, _input_bmp_first, __range, _input_bmp)\ 239 do {\ 240 sw_state_bitdcl_param_t param;\ 241 param.flags = _flags; param.op = SW_ST_BIT_RANGE_WRITE; param.sw_state_bmp = _sw_state_bmp;\ 242 param.sw_state_bmp_first = _sw_state_bmp_first; param.input_bmp_first = _input_bmp_first; param._range = __range; param.input_bmp = _input_bmp;\ 243 SHR_SW_STATE_BIT_OP(_unit, param);\ 244 } while(0) 245 #define SHR_SW_STATE_BIT_RANGE_AND(_unit, _flags, _sw_state_bmp, _input_bmp, _sw_state_bmp_first, __count)\ 246 do {\ 247 sw_state_bitdcl_param_t param;\ 248 param.flags = _flags; param.op = SW_ST_BIT_RANGE_AND;\ 249 param.sw_state_bmp = _sw_state_bmp; param.input_bmp = _input_bmp; param.sw_state_bmp_first = _sw_state_bmp_first; param._range = __count;\ 250 SHR_SW_STATE_BIT_OP(_unit, param);\ 251 } while(0) 252 #define SHR_SW_STATE_BIT_RANGE_OR(_unit, _flags, _sw_state_bmp, _input_bmp, _sw_state_bmp_first, __count)\ 253 do {\ 254 sw_state_bitdcl_param_t param;\ 255 param.flags = _flags; param.op = SW_ST_BIT_RANGE_OR;\ 256 param.sw_state_bmp = _sw_state_bmp; param.input_bmp = _input_bmp; param.sw_state_bmp_first = _sw_state_bmp_first; param._range = __count;\ 257 SHR_SW_STATE_BIT_OP(_unit, param);\ 258 } while(0) 259 #define SHR_SW_STATE_BIT_RANGE_XOR(_unit, _flags, _sw_state_bmp, _input_bmp, _sw_state_bmp_first, __count)\ 260 do {\ 261 sw_state_bitdcl_param_t param;\ 262 param.flags = _flags; param.op = SW_ST_BIT_RANGE_XOR;\ 263 param.sw_state_bmp = _sw_state_bmp; param.input_bmp = _input_bmp; param.sw_state_bmp_first = _sw_state_bmp_first; param._range = __count;\ 264 SHR_SW_STATE_BIT_OP(_unit, param);\ 265 } while(0) 266 #define SHR_SW_STATE_BIT_RANGE_REMOVE(_unit, _flags, _sw_state_bmp, _input_bmp, _sw_state_bmp_first, __count)\ 267 do {\ 268 sw_state_bitdcl_param_t param;\ 269 param.flags = _flags; param.op = SW_ST_BIT_RANGE_REMOVE;\ 270 param.sw_state_bmp = _sw_state_bmp; param.input_bmp = _input_bmp; param.sw_state_bmp_first = _sw_state_bmp_first; param._range = __count;\ 271 SHR_SW_STATE_BIT_OP(_unit, param);\ 272 } while(0) 273 #define SHR_SW_STATE_BIT_RANGE_NEGATE(_unit, _flags, _sw_state_bmp, _sw_state_bmp_first, __count)\ 274 do {\ 275 sw_state_bitdcl_param_t param;\ 276 param.flags = _flags; param.op = SW_ST_BIT_RANGE_NEGATE; param.sw_state_bmp = _sw_state_bmp;\ 277 param.sw_state_bmp_first = _sw_state_bmp_first; param._range = __count;\ 278 SHR_SW_STATE_BIT_OP(_unit, param);\ 279 } while(0) 280 #define SHR_SW_STATE_BIT_RANGE_CLEAR(_unit, _flags, _sw_state_bmp, _sw_state_bmp_first, __count)\ 281 do {\ 282 sw_state_bitdcl_param_t param;\ 283 param.flags = _flags; param.op = SW_ST_BIT_RANGE_CLEAR; param.sw_state_bmp = _sw_state_bmp;\ 284 param.sw_state_bmp_first = _sw_state_bmp_first; param._range = __count;\ 285 SHR_SW_STATE_BIT_OP(_unit, param);\ 286 } while(0) 287 #define SHR_SW_STATE_BIT_RANGE_SET(_unit, _flags, _sw_state_bmp, _sw_state_bmp_first, __count)\ 288 do {\ 289 sw_state_bitdcl_param_t param;\ 290 param.flags = _flags; param.op = SW_ST_BIT_RANGE_SET; param.sw_state_bmp = _sw_state_bmp;\ 291 param.sw_state_bmp_first = _sw_state_bmp_first; param._range = __count;\ 292 SHR_SW_STATE_BIT_OP(_unit, param);\ 293 } while(0) 294 #define SHR_SW_STATE_BIT_RANGE_NULL(_unit, _flags, _sw_state_bmp, _sw_state_bmp_first, __count, _bool_result)\ 295 do {\ 296 sw_state_bitdcl_param_t param;\ 297 param.flags = _flags; param.op = SW_ST_BIT_RANGE_NULL; param.sw_state_bmp = _sw_state_bmp;\ 298 param.sw_state_bmp_first = _sw_state_bmp_first; param._range = __count; param.bool_result = _bool_result;\ 299 SHR_SW_STATE_BIT_OP(_unit, param);\ 300 } while(0) 301 #define SHR_SW_STATE_BIT_RANGE_TEST(_unit, _flags, _sw_state_bmp, _sw_state_bmp_first, __count, _bool_result)\ 302 do {\ 303 sw_state_bitdcl_param_t param;\ 304 param.flags = _flags; param.op = SW_ST_BIT_RANGE_TEST; param.sw_state_bmp = _sw_state_bmp;\ 305 param.sw_state_bmp_first = _sw_state_bmp_first; param._range = __count; param.bool_result = _bool_result;\ 306 SHR_SW_STATE_BIT_OP(_unit, param);\ 307 } while(0) 308 #define SHR_SW_STATE_BIT_RANGE_EQ(_unit, _flags, _sw_state_bmp, _sw_state_bmp_first, __count, _input_bmp, _bool_result)\ 309 do {\ 310 sw_state_bitdcl_param_t param;\ 311 param.flags = _flags; param.op = SW_ST_BIT_RANGE_EQ; param.sw_state_bmp = _sw_state_bmp;\ 312 param.sw_state_bmp_first = _sw_state_bmp_first; param._range = __count; param.input_bmp = _input_bmp; param.bool_result = _bool_result;\ 313 SHR_SW_STATE_BIT_OP(_unit, param);\ 314 } while(0) 315 #define SHR_SW_STATE_BIT_RANGE_COUNT(_unit, _flags, _sw_state_bmp, _sw_state_bmp_first, __range, _int_result)\ 316 do {\ 317 sw_state_bitdcl_param_t param;\ 318 param.flags = _flags; param.op = SW_ST_BIT_RANGE_COUNT; param.sw_state_bmp = _sw_state_bmp;\ 319 param.sw_state_bmp_first = _sw_state_bmp_first; param._range = __range; param.int_result = _int_result;\ 320 SHR_SW_STATE_BIT_OP(_unit, param);\ 321 } while(0) 322 323 #endif /*SHR_THIN_SW_STATE*/ 324 325 /**********************************************/ 326 /**********************************************/ 327 /**********************************************/ 328 329 330 331 332 /**********************************************/ 333 /****** SW_STATE_BUFFER ACCESS MACROS *********/ 334 /**********************************************/ 335 #define SW_STATE_MEMREAD(unit, dst, location, offset, length, flags, debug_str)\ 336 sal_memcpy((void *) dst, (void *) (location + offset), length); 337 #define SW_STATE_MEMCMP(unit, buffer, location, offset, length, output, flags, debug_str)\ 338 *output = sal_memcmp((void *) buffer, (void *) (location + offset), length); 339 340 /* can fall back into regular assignments for improved performance */ 341 #ifdef SHR_THIN_SW_STATE /*SHR_THIN_SW_STATE*/ 342 343 #define SW_STATE_MEMSET(unit, location, offset, value, length, flags, debug_str)\ 344 sal_memset((uint8 *) (location + offset), value, length); 345 #define SW_STATE_MEMWRITE(unit, input, location, offset, length, flags, debug_str)\ 346 sal_memcpy((uint8 *) (location + offset), (uint8 *) input, length); 347 348 #else /*SHR_THIN_SW_STATE*/ 349 350 #define SW_STATE_MEMSET(unit, location, offset, value, length, flags, debug_str)\ 351 shr_sw_state_memset(unit,(uint8 *) (location + offset), value, length, flags); 352 #define SW_STATE_MEMWRITE(unit, input, location, offset, length, flags, debug_str)\ 353 shr_sw_state_memcpy(unit,(uint8 *) (location + offset), (uint8 *) input, length, flags); 354 355 #endif /*SHR_THIN_SW_STATE*/ 356 357 358 359 /**********************************************/ 360 /********** PBMP ACCESS MACROS ****************/ 361 /**********************************************/ 362 /* can fall back into regular assignments for improved performance */ 363 #ifdef SHR_THIN_SW_STATE /*SHR_THIN_SW_STATE*/ 364 365 #define SHR_SW_STATE_PBMP_NEQ(unit, path, input_pbmp, result, flags, debug_string)\ 366 *result = (_SHR_PBMP_NEQ(path, input_pbmp) > 0) ? 1: 0; 367 #define SHR_SW_STATE_PBMP_EQ(unit, path, input_pbmp, result, flags, debug_string)\ 368 *result = (_SHR_PBMP_EQ(path, input_pbmp) > 0) ? 1: 0; 369 #define SHR_SW_STATE_PBMP_MEMBER(unit, path, input_port, result, flags, debug_string)\ 370 *result = (_SHR_PBMP_MEMBER(path, input_port) > 0) ? 1: 0; 371 #define SHR_SW_STATE_PBMP_NOT_NULL(unit, path, result, flags, debug_string)\ 372 *result = (_SHR_PBMP_NOT_NULL(path) > 0) ? 1: 0; 373 #define SHR_SW_STATE_PBMP_IS_NULL(unit, path, result, flags, debug_string)\ 374 *result = (_SHR_PBMP_IS_NULL(path) > 0) ? 1: 0; 375 #define SHR_SW_STATE_PBMP_COUNT(unit, path, result, flags, debug_string)\ 376 _SHR_PBMP_COUNT(path, *result); 377 #define SHR_SW_STATE_PBMP_XOR(unit, path, input_pbmp, flags, debug_string)\ 378 _SHR_PBMP_XOR(path, input_pbmp); 379 #define SHR_SW_STATE_PBMP_REMOVE(unit, path, input_pbmp, flags, debug_string)\ 380 _SHR_PBMP_REMOVE(path, input_pbmp); 381 #define SHR_SW_STATE_PBMP_ASSIGN(unit, path, input_pbmp, flags, debug_string)\ 382 _SHR_PBMP_ASSIGN(path, input_pbmp); 383 #define SHR_SW_STATE_PBMP_GET(unit, path, output_pbmp, flags, debug_string)\ 384 _SHR_PBMP_ASSIGN(*output_pbmp, path); 385 #define SHR_SW_STATE_PBMP_AND(unit, path, input_pbmp, flags, debug_string)\ 386 _SHR_PBMP_AND(path, input_pbmp); 387 #define SHR_SW_STATE_PBMP_NEGATE(unit, path, input_pbmp, flags, debug_string)\ 388 _SHR_PBMP_NEGATE(path, input_pbmp); 389 #define SHR_SW_STATE_PBMP_OR(unit, path, input_pbmp, flags, debug_string)\ 390 _SHR_PBMP_OR(path, input_pbmp); 391 #define SHR_SW_STATE_PBMP_CLEAR(unit, path, flags, debug_string)\ 392 _SHR_PBMP_CLEAR(path); 393 #define SHR_SW_STATE_PBMP_PORT_ADD(unit, path, input_port, flags, debug_string)\ 394 _SHR_PBMP_PORT_ADD(path, input_port); 395 #define SHR_SW_STATE_PBMP_PORT_FLIP(unit, path, input_port, flags, debug_string)\ 396 _SHR_PBMP_PORT_FLIP(path, input_port); 397 #define SHR_SW_STATE_PBMP_PORT_REMOVE(unit, path, input_port, flags, debug_string)\ 398 _SHR_PBMP_PORT_REMOVE(path, input_port); 399 #define SHR_SW_STATE_PBMP_PORT_SET(unit, path, input_port, flags, debug_string)\ 400 _SHR_PBMP_PORT_SET(path, input_port); 401 #define SHR_SW_STATE_PBMP_PORTS_RANGE_ADD(unit, path, input_port, range, flags, debug_string)\ 402 _SHR_PBMP_PORTS_RANGE_ADD(path, input_port, range); 403 #define SHR_SW_STATE_PBMP_FMT(unit, path, buffer, flags, debug_string)\ 404 _SHR_PBMP_FMT(path, buffer); 405 406 #else /*SHR_THIN_SW_STATE*/ 407 408 #define SHR_SW_STATE_PBMP_NEQ(unit, path, input_pbmp, result, flags, debug_string)\ 409 shr_sw_state_pbmp_operation(unit, &path, SW_ST_PBMP_NEQ, &input_pbmp, NULL, -1, -1, result, NULL, NULL, flags, debug_string) 410 #define SHR_SW_STATE_PBMP_EQ(unit, path, input_pbmp, result, flags, debug_string)\ 411 shr_sw_state_pbmp_operation(unit, &path, SW_ST_PBMP_EQ, &input_pbmp, NULL, -1, -1, result, NULL, NULL, flags, debug_string) 412 #define SHR_SW_STATE_PBMP_MEMBER(unit, path, input_port, result, flags, debug_string)\ 413 shr_sw_state_pbmp_operation(unit, &path, SW_ST_PBMP_MEMBER, NULL, NULL, input_port, -1, result, NULL, NULL, flags, debug_string) 414 #define SHR_SW_STATE_PBMP_NOT_NULL(unit, path, result, flags, debug_string)\ 415 shr_sw_state_pbmp_operation(unit, &path, SW_ST_PBMP_NOT_NULL, NULL, NULL, -1, -1, result, NULL, NULL, flags, debug_string) 416 #define SHR_SW_STATE_PBMP_IS_NULL(unit, path, result, flags, debug_string)\ 417 shr_sw_state_pbmp_operation(unit, &path, SW_ST_PBMP_IS_NULL, NULL, NULL, -1, -1, result, NULL, NULL, flags, debug_string) 418 #define SHR_SW_STATE_PBMP_COUNT(unit, path, result, flags, debug_string)\ 419 shr_sw_state_pbmp_operation(unit, &path, SW_ST_PBMP_COUNT, NULL, NULL, -1, -1, NULL, result, NULL, flags, debug_string) 420 #define SHR_SW_STATE_PBMP_XOR(unit, path, input_pbmp, flags, debug_string)\ 421 shr_sw_state_pbmp_operation(unit, &path, SW_ST_PBMP_XOR, &input_pbmp, NULL, -1, -1, NULL, NULL, NULL, flags, debug_string) 422 #define SHR_SW_STATE_PBMP_REMOVE(unit, path, input_pbmp, flags, debug_string)\ 423 shr_sw_state_pbmp_operation(unit, &path, SW_ST_PBMP_REMOVE, &input_pbmp, NULL, -1, -1, NULL, NULL, NULL, flags, debug_string) 424 #define SHR_SW_STATE_PBMP_ASSIGN(unit, path, input_pbmp, flags, debug_string)\ 425 shr_sw_state_pbmp_operation(unit, &path, SW_ST_PBMP_ASSIGN, &input_pbmp, NULL, -1, -1, NULL, NULL, NULL, flags, debug_string) 426 #define SHR_SW_STATE_PBMP_GET(unit, path, output_pbmp, flags, debug_string)\ 427 shr_sw_state_pbmp_operation(unit, &path, SW_ST_PBMP_GET, NULL, output_pbmp, -1, -1, NULL, NULL, NULL, flags, debug_string) 428 #define SHR_SW_STATE_PBMP_AND(unit, path, input_pbmp, flags, debug_string)\ 429 shr_sw_state_pbmp_operation(unit, &path, SW_ST_PBMP_AND, &input_pbmp, NULL, -1, -1, NULL, NULL, NULL, flags, debug_string) 430 #define SHR_SW_STATE_PBMP_NEGATE(unit, path, input_pbmp, flags, debug_string)\ 431 shr_sw_state_pbmp_operation(unit, &path, SW_ST_PBMP_NEGATE, &input_pbmp, NULL, -1, -1, NULL, NULL, NULL, flags, debug_string) 432 #define SHR_SW_STATE_PBMP_OR(unit, path, input_pbmp, flags, debug_string)\ 433 shr_sw_state_pbmp_operation(unit, &path, SW_ST_PBMP_OR, &input_pbmp, NULL, -1, -1, NULL, NULL, NULL, flags, debug_string) 434 #define SHR_SW_STATE_PBMP_CLEAR(unit, path, flags, debug_string)\ 435 shr_sw_state_pbmp_operation(unit, &path, SW_ST_PBMP_CLEAR, NULL, NULL, -1, -1, NULL, NULL, NULL, flags, debug_string) 436 #define SHR_SW_STATE_PBMP_PORT_ADD(unit, path, input_port, flags, debug_string)\ 437 shr_sw_state_pbmp_operation(unit, &path, SW_ST_PBMP_PORT_ADD, NULL, NULL, input_port, -1, NULL, NULL, NULL, flags, debug_string) 438 #define SHR_SW_STATE_PBMP_PORT_FLIP(unit, path, input_port, flags, debug_string)\ 439 shr_sw_state_pbmp_operation(unit, &path, SW_ST_PBMP_PORT_FLIP, NULL, NULL, input_port, -1, NULL, NULL, NULL, flags, debug_string) 440 #define SHR_SW_STATE_PBMP_PORT_REMOVE(unit, path, input_port, flags, debug_string)\ 441 shr_sw_state_pbmp_operation(unit, &path, SW_ST_PBMP_PORT_REMOVE, NULL, NULL, input_port, -1, NULL, NULL, NULL, flags, debug_string) 442 #define SHR_SW_STATE_PBMP_PORT_SET(unit, path, input_port, flags, debug_string)\ 443 shr_sw_state_pbmp_operation(unit, &path, SW_ST_PBMP_PORT_SET, NULL, NULL, input_port, -1, NULL, NULL, NULL, flags, debug_string) 444 #define SHR_SW_STATE_PBMP_PORTS_RANGE_ADD(unit, path, input_port, range, flags, debug_string)\ 445 shr_sw_state_pbmp_operation(unit, &path, SW_ST_PBMP_PORTS_RANGE_ADD, NULL, NULL, input_port, range, NULL, NULL, NULL, flags, debug_string) 446 #define SHR_SW_STATE_PBMP_FMT(unit, path, buffer, flags, debug_string)\ 447 shr_sw_state_pbmp_operation(unit, &path, SW_ST_PBMP_FMT, NULL, NULL, -1, -1, NULL, NULL, buffer, flags, debug_string) 448 449 #endif /*SHR_THIN_SW_STATE*/ 450 451 /**********************************************/ 452 /**********************************************/ 453 /**********************************************/ 454 455 456 457 #ifdef SHR_SW_STATE_VERIFICATIONS 458 #define SW_STATE_NULL_CHECK(param) \ 459 do{ \ 460 if((param) == NULL){ \ 461 _sw_state_access_debug_hook(0);\ 462 LOG_ERROR(BSL_LS_SHARED_SWSTATE, (BSL_META_U(unit, "sw state ERROR: trying to free something that was never allocated\n")));\ 463 /* for now - just print to screen; in the future - consider returnning error */ \ 464 return _SHR_E_NONE; \ 465 } \ 466 } while(0) 467 468 #define SW_STATE_IS_WARM_BOOT_CHECK() \ 469 do{ \ 470 if (SOC_WARM_BOOT(unit)) {\ 471 _sw_state_access_debug_hook(1);\ 472 LOG_ERROR(BSL_LS_SHARED_SWSTATE, (BSL_META_U(unit,\ 473 "sw state ERROR: trying to set/alloc during warm reboot. for debug, use breakpoint on _sw_state_access_debug_hook\n")));\ 474 return _SHR_E_DISABLED;\ 475 }\ 476 } while(0) 477 478 #define SW_STATE_IS_DEINIT_CHECK() \ 479 do{ \ 480 if (SOC_IS_DETACHING(unit)) {\ 481 _sw_state_access_debug_hook(2);\ 482 LOG_ERROR(BSL_LS_SHARED_SWSTATE, (BSL_META_U(unit,\ 483 "sw state ERROR: trying to free/modify during deinit. for debug, use breakpoint on _sw_state_access_debug_hook\n")));\ 484 return _SHR_E_DISABLED;\ 485 }\ 486 } while(0) 487 488 #define SW_STATE_IS_ALREADY_ALLOCATED_CHECK(__ptr) \ 489 do{ \ 490 if (__ptr) {\ 491 _sw_state_access_debug_hook(3);\ 492 LOG_ERROR(BSL_LS_SHARED_SWSTATE, (BSL_META_U(unit,\ 493 "sw state ERROR: trying to allocate something that is already allocated. for debug, use breakpoint on _sw_state_access_debug_hook\n")));\ 494 return _SHR_E_EXISTS;\ 495 }\ 496 } while(0) 497 498 #define SW_STATE_OUT_OF_BOUND_CHECK(__index, __max, __param) \ 499 do{ \ 500 if (__index > __max) {\ 501 _sw_state_access_debug_hook(4);\ 502 LOG_ERROR(BSL_LS_SHARED_SWSTATE, (BSL_META_U(unit,\ 503 "\nSW STATE ERROR: INDEX OUT OF BOUND.\n\ 504 Trying to access "#__param" with index %d out of %d.\n\ 505 For debug, use breakpoint on _sw_state_access_debug_hook\n"),\ 506 (int)(__index), (int)(__max)));\ 507 return _SHR_E_PARAM;\ 508 }\ 509 } while(0) 510 511 512 #else /*SHR_SW_STATE_VERIFICATIONS*/ 513 #define SW_STATE_NULL_CHECK(param) 514 #define SW_STATE_IS_WARM_BOOT_CHECK() 515 #define SW_STATE_IS_DEINIT_CHECK() 516 #define SW_STATE_IS_ALREADY_ALLOCATED_CHECK(__ptr) 517 #define SW_STATE_OUT_OF_BOUND_CHECK(__index, __max, __param) 518 #endif /*SHR_SW_STATE_VERIFICATIONS*/ 519 520 #define SW_STATE_MODIFY_OPS_CHECKS(flags)\ 521 if (flags & SW_STATE_IS_WB_CHECK) {\ 522 SW_STATE_IS_WARM_BOOT_CHECK();\ 523 }\ 524 SW_STATE_IS_DEINIT_CHECK(); 525 526 /* there is another null check above SW_STATE_NULL_CHECK for free purpose 527 this null check is for use purpose */ 528 529 #define SW_STATE_NULL_ACCESS_CHECK(param) \ 530 do{ \ 531 if((param) == NULL){ \ 532 _sw_state_access_debug_hook(5);\ 533 LOG_ERROR(BSL_LS_SHARED_SWSTATE, (BSL_META_U(unit, "\nsw state ERROR: NULL REFERENCE \n")));\ 534 return _SHR_E_MEMORY; \ 535 } \ 536 } while(0) 537 538 #ifdef SHR_SW_STATE_VERIFICATIONS 539 #define SW_STATE_BITDCL_VERIFY(parent_verify_call, ptr, from_bit, to_bit, param_name) \ 540 do{ \ 541 uint32 nof_allocated_bits = 0; \ 542 _rv = parent_verify_call; \ 543 if (_rv != _SHR_E_NONE) return _rv; \ 544 SW_STATE_NULL_ACCESS_CHECK(ptr); \ 545 shr_sw_state_shr_bitdcl_nof_bits_get(unit, (uint8*)ptr, &nof_allocated_bits); \ 546 SW_STATE_OUT_OF_BOUND_CHECK(from_bit, nof_allocated_bits, param_name); \ 547 SW_STATE_OUT_OF_BOUND_CHECK(to_bit , nof_allocated_bits, param_name); \ 548 } while(0) 549 #else 550 #define SW_STATE_BITDCL_VERIFY(parent_verify_call, ptr, from_bit, to_bit, param_name) 551 #endif 552 553 #endif /* BCM_WARM_BOOT_SUPPORT */ 554 555 #ifdef BCM_PETRA_SUPPORT 556 /* { */ 557 typedef struct soc_dpp_sw_state_s { 558 soc_dpp_bcm_sw_state_t bcm; 559 soc_dpp_soc_sw_state_t soc; 560 soc_dpp_shr_sw_state_t shr; 561 } soc_dpp_sw_state_t; 562 /* } */ 563 #endif 564 565 /* 566 * shr_sw_state_t 567 * This is the highest level view of memory managed by 'sw state' 568 * it is split into two sections: DNX (JR2) and DPP (pre JR2 - PETRA) 569 */ 570 typedef struct shr_sw_state_s { 571 #ifdef BCM_PETRA_SUPPORT 572 /* { */ 573 soc_dpp_sw_state_t dpp; 574 /* } */ 575 #endif 576 #ifdef _SHR_SW_STATE_EXM 577 PARSER_HINT_PTR two_levels_example_t *exm; 578 PARSER_HINT_PTR mix_stat_dyn_example_t *exmMixStatDyn; 579 PARSER_HINT_PTR mini_example_t *miniExm; 580 PARSER_HINT_PTR sw_state_issu_example_t *issu_example; 581 #endif 582 PARSER_HINT_PTR sw_state_issu_test_t *issu_test; 583 } shr_sw_state_t; 584 /* } */ 585 586 #endif /* _SHR_SW_STATE_DEFS_H */