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

stat_pp.h (6926B)


      1  /** \file bcm_int/dnx/stat/stat_pp.h
      2  *
      3  * Internal DNX STAT PP
      4  *
      5  * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
      6  * 
      7  * Copyright 2007-2020 Broadcom Inc. All rights reserved.
      8  */
      9 
     10 #ifndef _DNX_STAT_PP_INCLUDED__
     11 /*
     12  * {
     13  */
     14 #define _DNX_STAT_PP_INCLUDED__
     15 
     16 #ifndef BCM_DNX_SUPPORT
     17 #error "This file is for use by DNX (JR2) family only!"
     18 #endif
     19 
     20 /*
     21  * MACROs
     22  * {
     23  */
     24 
     25 /** Statistics profile is composed of 2 bits representing the
     26  *  source engine, and profile ID. Below macros help in set
     27  *  or get for the profile IDs and source engine */
     28 #define STAT_PP_PROFILE_ID_SHIFT   0
     29 #define STAT_PP_PROFILE_ID_MASK    0x3fffffff
     30 #define STAT_PP_PROFILE_ID_GET(profile)   \
     31     (((profile) >> STAT_PP_PROFILE_ID_SHIFT) & STAT_PP_PROFILE_ID_MASK)
     32 #define STAT_PP_IRPP_PROFILE_MAX_VALUE 31
     33 #define STAT_PP_ETPP_PROFILE_MAX_VALUE 31
     34 #define STAT_PP_ERPP_PROFILE_MAX_VALUE 7
     35 #define STAT_PP_IRPP_META_DATA_MAX_SIZE 16
     36 #define STAT_PP_IRPP_META_DATA_UPDATE_MAX_SIZE 3
     37 #define STAT_PP_IRPP_META_DATA_UPDATE_MAX_SHIFT (STAT_PP_IRPP_META_DATA_MAX_SIZE-1)
     38 
     39 #define STAT_PP_IRPP_MAX_CPRS_ITF_ID 9
     40 #define STAT_PP_ETPP_MAX_CPRS_ITF_ID 5
     41 
     42 
     43 #define STAT_PP_PROFILE_INVALID 0
     44 
     45 #define STAT_PP_STAT_IF_NO_STATISTICS_INDICATION 0xF
     46 
     47 /** Invalid meter command id */
     48 #define STAT_PP_INGRESS_METER_COMMAND_ID_INVALID    0
     49 #define STAT_PP_METER_MIN_ID 0
     50 #define STAT_PP_METER_IRPP_MAX_ID 2
     51 #define STAT_PP_METER_ETPP_MAX_ID 1
     52 
     53 /** statistics engine source origin is stored on 2 of the
     54  *  profile ID MSBs as internal values */
     55 #define STAT_PP_PROFILE_IRPP_ENCODED_VALUE 0
     56 #define STAT_PP_PROFILE_ERPP_ENCODED_VALUE 1
     57 #define STAT_PP_PROFILE_ETPP_ENCODED_VALUE 2
     58 #define STAT_PP_PROFILE_ENGINE_SHIFT   30
     59 #define STAT_PP_PROFILE_ENGINE_MASK    3
     60 #define STAT_PP_PROFILE_ENCODED_ENGINE_GET(profile)   \
     61     (((profile) >> STAT_PP_PROFILE_ENGINE_SHIFT) & STAT_PP_PROFILE_ENGINE_MASK)
     62 /** Macros for translating internal engine source values to
     63  *  the BCM values */
     64 #define STAT_PP_PROFILE_ENGINE_IS_IRPP(profile)   \
     65         (STAT_PP_PROFILE_ENCODED_ENGINE_GET(profile) == STAT_PP_PROFILE_IRPP_ENCODED_VALUE)
     66 #define STAT_PP_PROFILE_ENGINE_IS_ERPP(profile)   \
     67         (STAT_PP_PROFILE_ENCODED_ENGINE_GET(profile) == STAT_PP_PROFILE_ERPP_ENCODED_VALUE)
     68 #define STAT_PP_PROFILE_ENGINE_IS_ETPP(profile)   \
     69         (STAT_PP_PROFILE_ENCODED_ENGINE_GET(profile) == STAT_PP_PROFILE_ETPP_ENCODED_VALUE)
     70 #define STAT_PP_PROFILE_ENGINE_GET(profile) \
     71         ((STAT_PP_PROFILE_ENGINE_IS_IRPP(profile)) ? bcmStatCounterInterfaceIngressReceivePp : \
     72         (STAT_PP_PROFILE_ENGINE_IS_ERPP(profile)) ? bcmStatCounterInterfaceEgressReceivePp : \
     73         bcmStatCounterInterfaceEgressTransmitPp)
     74 #define STAT_PP_ENGINE_PROFILE_SET(encoded_profile, profile, engine) \
     75     do \
     76     { \
     77         if (engine == bcmStatCounterInterfaceIngressReceivePp) \
     78         { \
     79             encoded_profile = ((profile & STAT_PP_PROFILE_ID_MASK) << STAT_PP_PROFILE_ID_SHIFT) | \
     80             (STAT_PP_PROFILE_IRPP_ENCODED_VALUE << STAT_PP_PROFILE_ENGINE_SHIFT); \
     81         } \
     82         else if (engine == bcmStatCounterInterfaceEgressReceivePp) \
     83         { \
     84             encoded_profile = ((profile & STAT_PP_PROFILE_ID_MASK) << STAT_PP_PROFILE_ID_SHIFT) | \
     85             (STAT_PP_PROFILE_ERPP_ENCODED_VALUE << STAT_PP_PROFILE_ENGINE_SHIFT); \
     86         } \
     87         else if (engine == bcmStatCounterInterfaceEgressTransmitPp) \
     88         { \
     89             encoded_profile = ((profile & STAT_PP_PROFILE_ID_MASK) << STAT_PP_PROFILE_ID_SHIFT) | \
     90             (STAT_PP_PROFILE_ETPP_ENCODED_VALUE << STAT_PP_PROFILE_ENGINE_SHIFT); \
     91         } \
     92     } while (0)
     93 
     94 #define STAT_PP_ETPP_SWITCH_PROFILE_MAX_PROFILE dnx_data_stat.stat_pp.max_etpp_counting_profile_value_get(unit)
     95 #define STAT_PP_ETPP_SWITCH_PROFILE_SET_MASK 0x1F
     96 #define STAT_PP_ETPP_SWITCH_PROFILE_GET_MASK 0xF8000
     97 #define STAT_PP_ETPP_SWITCH_ID_SHIFT 15
     98 #define STAT_PP_ETPP_SWITCH_ID_GET_SHIFT 0x7FFF
     99 #define STAT_PP_ETPP_SWITCH_CMD_SET(stat_id,stat_pp_profile) \
    100     do \
    101     { \
    102         int orig_stat_pp_profile = STAT_PP_PROFILE_ID_GET(stat_pp_profile); \
    103         stat_pp_profile = stat_id & STAT_PP_ETPP_SWITCH_PROFILE_SET_MASK; \
    104         STAT_PP_ENGINE_PROFILE_SET(stat_pp_profile, stat_pp_profile, bcmStatCounterInterfaceEgressTransmitPp); \
    105         stat_id = (orig_stat_pp_profile << STAT_PP_ETPP_SWITCH_ID_SHIFT) | (stat_id >> 5); \
    106     } while (0)
    107 #define STAT_PP_ETPP_SWITCH_CMD_GET(stat_id,stat_pp_profile) \
    108     do \
    109     { \
    110         int orig_stat_pp_profile = stat_pp_profile; \
    111         stat_pp_profile = (stat_id & STAT_PP_ETPP_SWITCH_PROFILE_GET_MASK) >> STAT_PP_ETPP_SWITCH_ID_SHIFT; \
    112         stat_id = ((stat_id & STAT_PP_ETPP_SWITCH_ID_GET_SHIFT) << 5) | orig_stat_pp_profile;\
    113     } while (0)
    114 
    115 /* Macro for checking if a stat_flag is given and if so --> set stat pp lif fields to 0,
    116  * indicating the lif table manager to allocate stat_pp result type (to be later set by bcm_stat_gport_set()*/
    117 #define STAT_PP_CHECK_AND_SET_STAT_OBJECT_LIF_FIELDS(flags,stat_flag) \
    118     do \
    119     { \
    120         if (_SHR_IS_FLAG_SET(flags, stat_flag)) \
    121         { \
    122             dbal_entry_value_field32_set(unit, entry_handle_id, DBAL_FIELD_STAT_OBJECT_ID, INST_SINGLE, 0); \
    123             dbal_entry_value_field32_set(unit, entry_handle_id, DBAL_FIELD_STAT_OBJECT_CMD, INST_SINGLE, 0); \
    124         } \
    125     } while (0)
    126 
    127 /**
    128  * \brief - verify function - make sure statistics are present
    129  *        in the relevant result type
    130  *
    131  * \param [in] unit - relevant unit
    132  * \param [in] dbal_table_id - relevant dbal table id
    133  * \param [in] dbal_result_type - dbal result type
    134  *
    135  * \return
    136  *   shr_error_e
    137  *
    138  * \remark
    139  *   * None
    140  * \see
    141  *   * None
    142  */
    143 shr_error_e dnx_stat_pp_result_type_verify(
    144     int unit,
    145     dbal_tables_e dbal_table_id,
    146     uint32 dbal_result_type);
    147 
    148 /**
    149  * \brief - Verify function, crps validation
    150  *          If the pp_profile id is valid - get profile info
    151  *          from HW, call crps module for interface_type,
    152  *          profile_id, type_id, stat_id validation
    153  *
    154  * \param [in] unit - relevant unit
    155  * \param [in] core_id - relevant core
    156  * \param [in] stat_id - Object's statistics id
    157  * \param [in] stat_pp_profile - Statistics profile
    158  * \param [in] interface_type - Counter interface type
    159  *
    160  * \return
    161  *   Negative in case of an error.
    162  *
    163  * \remark
    164  *   * None
    165  * \see
    166  *   * None
    167  */
    168 int dnx_stat_pp_crps_verify(
    169     int unit,
    170     bcm_core_t core_id,
    171     uint32 stat_id,
    172     int stat_pp_profile,
    173     int interface_type);
    174 
    175 /**
    176  * \brief - init function, performed during bcm init stage.
    177  *          Indicate no statistics on default invalid statistic profile 0
    178  * \param [in] unit - relevant unit
    179  *
    180  * \return
    181  *   Negative in case of an error. See \ref shr_error_e
    182  *
    183  * \remark
    184  *   * None
    185  * \see
    186  *   * None
    187  */
    188 shr_error_e dnx_stat_pp_init(
    189     int unit);
    190 
    191 /*
    192  * }
    193  */
    194 #endif  /*_DNX_STAT_PP_INCLUDED__*/