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

crps_mgmt.h (8560B)


      1  /** \file bcm_int/dnx/stat/crps/crps_mgmt.h
      2  * 
      3  * Internal DNX CRPS MGMT
      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_CRPS_MGMT_INCLUDED__
     11 /*
     12  * { 
     13  */
     14 #define _DNX_CRPS_MGMT_INCLUDED__
     15 
     16 #ifndef BCM_DNX_SUPPORT
     17 #error "This file is for use by DNX (JR2) family only!"
     18 #endif
     19 
     20 #include <bcm/policer.h>
     21 #include <bcm/stat.h>
     22 #include <soc/dnx/dnx_data/auto_generated/dnx_data_meter.h>
     23 
     24 /*
     25  * MACROs
     26  * {
     27  */
     28 
     29 #define DNX_CRPS_DATABASE_RESOURCE "CRPS DATABASE"
     30 
     31 /*
     32  *  Subcounter index -- each counter is a group, consisting of sub counters.
     33  */
     34 #define DNX_CRPS_MGMT_SUB_CTR1 0  /** sub counter for packets (ctr1) */
     35 #define DNX_CRPS_MGMT_SUB_CTR2 1 /** sub counter for bytes (ctr2)  */
     36 #define DNX_CRPS_MGMT_SUB_COUNT 2 /** number of sub counters */
     37 
     38 /** 
     39   * \brief - engine is valid only if the configuration started and ended
     40   */
     41 #define DNX_CRPS_MGMT_ENGINE_VALID_GET(_unit, _core_id, _engine_id, _valid) \
     42 {\
     43         int _conf_started; \
     44         int _conf_done; \
     45         SHR_IF_ERR_EXIT(dnx_crps_db.proc.config_started.get(_unit, _core_id, _engine_id, &_conf_started)); \
     46         SHR_IF_ERR_EXIT(dnx_crps_db.proc.config_done.get(_unit, _core_id, _engine_id, &_conf_done)); \
     47         _valid = ((_conf_started == TRUE) && (_conf_done == TRUE)) ? TRUE : FALSE; \
     48 }
     49 
     50 /** 
     51   * \brief -  check if the engine_id is one of the engines that can be used for eth policer. there is one for ingress and one for egress.
     52   *             thiese engines are small and can be used as single bucket mode only
     53   */
     54 #define DNX_CRPS_METER_SHMEM_IS_METER_SINGLE_BUCKET_ENGINE(_unit, _engine_id) \
     55     (_engine_id == dnx_data_meter.mem_mgmt.ingress_single_bucket_engine_get(_unit) || \
     56      _engine_id == dnx_data_meter.mem_mgmt.egress_single_bucket_engine_get(_unit))
     57 
     58 /**
     59   * \brief - return if the given source is OAM source
     60   */
     61 #define DNX_CRPS_MGMT_SOURCE_IS_OAM(_unit, _source) \
     62         (_source == bcmStatCounterInterfaceIngressOam || _source == bcmStatCounterInterfaceEgressOam || _source == bcmStatCounterInterfaceOamp)
     63 
     64 /**
     65   * \brief - invalid dma channel definition
     66   */
     67 #define DNX_CRPS_INVALID_DMA_CHANNEL (-1)
     68 
     69 /*
     70  * }
     71  */
     72 
     73 /*
     74  * Typdef/Enums/Structures
     75  * {
     76  */
     77 
     78 /** internal Enum to select the section in the policer-crps shared memory engines. */
     79 typedef enum
     80 {
     81     dnx_crps_mgmt_shmem_section_all = bcmPolicerEngineSectionAll,
     82     dnx_crps_mgmt_shmem_section_low = bcmPolicerEngineSectionLow,
     83     dnx_crps_mgmt_shmem_section_high = bcmPolicerEngineSectionHigh
     84 } dnx_crps_mgmt_shmem_section_t;
     85 
     86 /*
     87  * Functions prototypes
     88  * {
     89  */
     90 
     91 /** 
     92  * \brief - take lock of the counters dma fifos
     93  */
     94 shr_error_e dnx_crps_fifo_state_lock_take(
     95     int unit);
     96 
     97 /** 
     98  * \brief - give lock of the counters dma fifos
     99  */
    100 shr_error_e dnx_crps_fifo_state_lock_give(
    101     int unit);
    102 
    103 /** 
    104  * \brief - take lock of the counters cache
    105  */
    106 shr_error_e dnx_crps_counter_state_lock_take(
    107     int unit);
    108 
    109 /** 
    110  * \brief - give lock of the counters cache
    111  */
    112 shr_error_e dnx_crps_counter_state_lock_give(
    113     int unit);
    114 
    115 /**
    116  * \brief - Initialize dnx crps module
    117  * 
    118  * \par DIRECT_INPUT:
    119  *   \param [in] unit -  Unit-ID 
    120  *   
    121  * \par INDIRECT INPUT:
    122  *   * DNX data related crps module information
    123  * \par DIRECT OUTPUT:
    124  *   shr_error_e 
    125  * \par INDIRECT OUTPUT
    126  *   * crps HW related regs/mems
    127  * \remark
    128  *   * None
    129  * \see
    130  *   * None
    131  */
    132 shr_error_e dnx_crps_init(
    133     int unit);
    134 
    135 /**
    136  * \brief - Deinitialize dnx crps module
    137  * 
    138  * \par DIRECT_INPUT:
    139  *   \param [in] unit -  Unit-ID 
    140  *   
    141  * \par INDIRECT INPUT:
    142  *   * None
    143  * \par DIRECT OUTPUT:
    144  *   shr_error_e 
    145  * \par INDIRECT OUTPUT
    146  *   * None
    147  * \remark
    148  *   * None
    149  * \see
    150  *   * None
    151  */
    152 shr_error_e dnx_crps_deinit(
    153     int unit);
    154 
    155 /**
    156  * \brief - attach or detach an engine memory for meter use.
    157  *            called from policer mgmt.
    158  * \par DIRECT_INPUT:
    159  *   \param [in] unit -  Unit-ID 
    160  *   \param [in] core_id -  core-ID 
    161  *   \param [in] engine_id -  engine-ID 
    162  *   \param [in] section -  for big engines, there are two sections. One can use both, low or high.  
    163  *   \param [in] is_ingress - is the database belong to ingress meter
    164  *   \param [in] attach -  True for attach, false for detach
    165  * \par INDIRECT INPUT:
    166  *   * None
    167  * \par DIRECT OUTPUT:
    168  *   shr_error_e 
    169  * \par INDIRECT OUTPUT
    170  *   * None
    171  * \remark
    172  *   * support core ALL
    173  * \see
    174  *   * None
    175  */
    176 shr_error_e dnx_crps_mgmt_meter_engine_attach_detach(
    177     int unit,
    178     int core_id,
    179     int engine_id,
    180     dnx_crps_mgmt_shmem_section_t section,
    181     int is_ingress,
    182     int attach);
    183 
    184 /**
    185  * \brief - verify funcion to check that the engine+section is available for meter usage
    186  *            called policer_mgmt
    187  * \par DIRECT_INPUT:
    188  *   \param [in] unit -  Unit-ID 
    189  *   \param [in] core_id -  core-ID 
    190  *   \param [in] engine_id -  engine-ID 
    191  *   \param [in] section -  for big engines, there are two sections. One can use both, low or high.  
    192  * \par INDIRECT INPUT:
    193  *   * None
    194  * \par DIRECT OUTPUT:
    195  *   shr_error_e 
    196  * \par INDIRECT OUTPUT
    197  *   * None
    198  * \remark
    199  *   * support core ALL
    200  * \see
    201  *   * None
    202  */
    203 shr_error_e dnx_crps_meter_engine_available_verify(
    204     int unit,
    205     int core_id,
    206     int engine_id,
    207     dnx_crps_mgmt_shmem_section_t section);
    208 
    209 /**
    210  * \brief
    211  *  wrapper function for disable the eviction of all engines.
    212  *  function perform:
    213  *  1. disable all active eviction engines.
    214  *  2. wait that the last counters will be copied to host.
    215  *  3. process the host fifo by demend in order to clear the fifo.
    216  *
    217  * \param [in] unit -unit id
    218  * \return
    219  *  shr_error_e
    220  * \remark
    221  *   function should be called before doing manual sync, part of warm boot or during de-init, in order to support automatic sync warmboot.
    222  * \see
    223  *   NONE
    224  */
    225 shr_error_e dnx_crps_eviction_disable_wrapper(
    226     int unit);
    227 
    228 /**
    229 * \brief
    230 *  verify function, which serve other modules who use the crps and wants to verify that the counter that is generated can be counted.
    231 *  the function search for an engine that can count the input object_stat_id according to the parameters given.
    232 *
    233 * \param [in] unit -unit id
    234 * \param [in] core_id - core id
    235 * \param [in] source_type - the source type that connected to the engine
    236 * \param [in] command_id - command/interface id
    237 * \param [in] type_id - type id
    238 * \param [in] object_stat_id - the counter pointer
    239 * \return
    240 *  shr_error_e
    241 * \remark
    242 *   NONE
    243 * \see
    244 *   NONE
    245  */
    246 shr_error_e dnx_crps_mgmt_counter_generation_verify(
    247     int unit,
    248     int core_id,
    249     bcm_stat_counter_interface_type_t source_type,
    250     int command_id,
    251     int type_id,
    252     int object_stat_id);
    253 
    254 /**
    255 * \brief
    256 *   verification database - database_id is allocated and valid core_id
    257 * \par DIRECT INPUT:
    258 *   \param [in] unit    -  Unit-ID
    259 *   \param [in] database  -  database configuration
    260 *   \param [in] core_all_valid  -  TRUE - bcm_core_all allowed;
    261 *          FALSE - unique core, bcm_core_all is not allowed
    262 * \par INDIRECT INPUT:
    263 *   * None
    264 * \par DIRECT OUTPUT:
    265 *   shr_error_e -
    266 * \par INDIRECT OUTPUT:
    267 *   * None
    268 * \remark
    269 *   * None
    270 * \see
    271 *   * None
    272 */
    273 shr_error_e dnx_crps_mgmt_database_structure_verify(
    274     int unit,
    275     bcm_stat_counter_database_t * database,
    276     int core_all_valid);
    277 
    278 /**
    279 * \brief
    280  *  verification on command_id in correct range according to the
    281  *  source
    282 * \par DIRECT INPUT:
    283 *   \param [in] unit    -  Unit-ID
    284  *  \param [in] source  -  source type
    285  *  \param [in] command_id  -  the command id that has to be
    286  *         checked
    287 * \par INDIRECT INPUT:
    288 *   * None
    289 * \par DIRECT OUTPUT:
    290 *   shr_error_e -
    291 * \par INDIRECT OUTPUT:
    292 *   * None
    293 * \remark
    294 *   * None
    295 * \see
    296 *   * None
    297 */
    298 shr_error_e dnx_crps_mgmt_counter_command_id_verify(
    299     int unit,
    300     bcm_stat_counter_interface_type_t source,
    301     int command_id);
    302 
    303 /**
    304 * \brief
    305 *  get the bank id (in the shared memory between crps and meter) according to the engine id and the section.
    306 *  source
    307 *  \par DIRECT INPUT:
    308 *  \param [in] unit    -  Unit-ID
    309 *  \param [in] engine_id  -  engine id 
    310 *  \param [in] section  -  engine section. (each engine has two banks, called sections).
    311 *  \param [out] bank_id    -  bank id
    312 * \par INDIRECT INPUT:
    313 *   * None
    314 * \par DIRECT OUTPUT:
    315 *   shr_error_e -
    316 * \par INDIRECT OUTPUT:
    317 *   * None
    318 * \remark
    319 *   * None
    320 * \see
    321 *   * None
    322 */
    323 shr_error_e dnx_crps_mgmt_meter_shmem_bank_id_get(
    324     int unit,
    325     int engine_id,
    326     dnx_crps_mgmt_shmem_section_t section,
    327     int *bank_id);
    328 
    329 #endif/*_DNX_CRPS_MGMT_INCLUDED__*/