diag_dnx_utils.h (4680B)
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: diag_dnx_utils.h 8 * Purpose: Misc utilities for the usage by dnx shell commands 9 */ 10 11 #ifndef _INCLUDE_DNX_UTILS_H 12 #define _INCLUDE_DNX_UTILS_H 13 14 #ifndef BCM_DNX_SUPPORT 15 #error "This file is for use by DNX (JR2) family only!" 16 #endif 17 18 #include <soc/dnx/dnx_visibility.h> 19 #include <sal/compiler.h> 20 21 #include <bcm_int/dnx/cmn/dnxcmn.h> 22 23 /* 24 * Macro 25 * { 26 */ 27 28 #define DNX_PP_BLOCK_IS_READY_CONT(core_mcr, block_mcr, log_mcr) \ 29 if (dnx_debug_block_is_ready(unit, core_mcr, block_mcr) != _SHR_E_NONE) \ 30 { \ 31 if(log_mcr) \ 32 { \ 33 LOG_CLI(("No packet detected on %s(%s) for core=%d\n", \ 34 dnx_pp_block_name(unit, block_mcr), dnx_pp_block_direction(unit, block_mcr), core_mcr)); \ 35 } \ 36 continue; \ 37 } 38 39 #define DNX_PP_BLOCK_IS_READY_EXIT(core_mcr, block_mcr, log_mcr) \ 40 if (dnx_debug_block_is_ready(unit, core_mcr, block_mcr) != _SHR_E_NONE) \ 41 { \ 42 if(log_mcr) \ 43 { \ 44 LOG_CLI(("No packet detected on %s(%s) for core=%d\n", \ 45 dnx_pp_block_name(unit, block_mcr), dnx_pp_block_direction(unit, block_mcr), core_mcr)); \ 46 } \ 47 SHR_EXIT(); \ 48 } 49 50 /** 51 * \brief - iterate over the relevant cores 52 * if core_id is BCM_CORE_ALL will iterate over all supported cores. 53 * Otherwise the iteration will be over the given core. 54 */ 55 #ifndef ADAPTER_SERVER_MODE 56 #define SH_DNX_CORES_ITER(unit, core_mcr, core_id_mcr) \ 57 DNXCMN_CORES_ITER(unit, core_mcr, core_id_mcr) 58 #else 59 #define SH_DNX_CORES_ITER(unit, core_mcr, core_id_mcr) \ 60 for(core_id_mcr = ((core_mcr == BCM_CORE_ALL) ? 0 : core_mcr);\ 61 core_id_mcr < ((core_mcr == BCM_CORE_ALL) ? 1 : (core_mcr + 1));\ 62 core_id_mcr++) 63 #endif 64 65 /* 66 * Take ABS from subtraction of 2 numbers and calculate result percentage from first 67 */ 68 #define DNX_64_ABS_DEVIATION(first_u64, second_u64, result_u64) \ 69 if (COMPILER_64_GT(first_u64, second_u64)) \ 70 { \ 71 COMPILER_64_COPY(result_u64, first_u64); \ 72 COMPILER_64_SUB_64(result_u64, second_u64); \ 73 } \ 74 else \ 75 { \ 76 COMPILER_64_COPY(result_u64, second_u64); \ 77 COMPILER_64_SUB_64(result_u64, first_u64); \ 78 } \ 79 COMPILER_64_UMUL_32(result_u64, 100); \ 80 COMPILER_64_UDIV_64(result_u64, first_u64) 81 82 /* 83 * } 84 */ 85 /* 86 * \brief - Check if TDM is supported and enabled in either mode 87 * \return 88 * _SHR_E_UNIT - if TDM is unavailable 89 * _SHR_E_NONE - TDM Available 90 */ 91 shr_error_e sh_dnx_is_tdm_available( 92 int unit, 93 rhlist_t * void_list); 94 95 #endif /* _INCLUDE_DNX_UTILS_H */