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.h (3602B)


      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  * This file contains STAT definitions internal to the BCM library.
      8  */
      9 
     10 #ifndef _BCM_INT_STAT_H
     11 #define _BCM_INT_STAT_H
     12 
     13 #include <bcm/stat.h>
     14 #include <soc/counter.h>
     15 
     16 /*
     17  * Utility routines for statistics accumulation
     18  */
     19 
     20 /* The REG_* macros require the following declaration in any function which
     21  * uses them:
     22  */
     23 
     24 #define REG_MATH_DECL \
     25         uint64 reg_val
     26 
     27 #define REG_ADD(unit, port, reg, val)					   \
     28     if (SOC_REG_IS_VALID(unit, reg) && SOC_REG_IS_COUNTER(unit, reg)) {	   \
     29         if (SOC_CONTROL(unit)->counter_interval == 0 /*counter thread is off*/) { \
     30             SOC_IF_ERROR_RETURN(soc_reg_get(unit, reg, port, 0, &reg_val));      \
     31         } else {                                                            \
     32             SOC_IF_ERROR_RETURN(soc_counter_get(unit, port, reg,            \
     33                                             0, &reg_val));                  \
     34         }                                                                   \
     35 	COMPILER_64_ADD_64(val, reg_val);				                        \
     36     }
     37 
     38 
     39 #define REG_SUB(unit, port, reg, val)					   \
     40     if (SOC_REG_IS_VALID(unit, reg) && SOC_REG_IS_COUNTER(unit, reg)) {	   \
     41         if (SOC_CONTROL(unit)->counter_interval == 0 /*counter thread is off*/) { \
     42             SOC_IF_ERROR_RETURN(soc_reg_get(unit, reg, port, 0, &reg_val));      \
     43         } else {                                                            \
     44             SOC_IF_ERROR_RETURN(soc_counter_get(unit, port, reg,            \
     45                                             0, &reg_val));                  \
     46         }                                                                  \
     47         if (COMPILER_64_GT(val, reg_val)) {                                \
     48 	    COMPILER_64_SUB_64(val, reg_val);				   \
     49         } else {                                                           \
     50             COMPILER_64_ZERO(val);                                         \
     51         }                                                                  \
     52     }
     53 
     54 /* Library-private functions exported from stat_generic.c */
     55 extern int _bcm_petra_stat_generic_get(int unit, bcm_port_t port,
     56                                  bcm_stat_val_t type, uint64 *val);
     57 
     58 extern int _bcm_petra_stat_ge_get(int unit, bcm_port_t port,
     59                                  bcm_stat_val_t type, uint64 *val);
     60 
     61 extern int _bcm_petra_stat_mxq_ge_get(int unit, bcm_port_t port,
     62                                  bcm_stat_val_t type, uint64 *val);
     63 
     64 int _bcm_petra_stat_counter_non_dma_extra_get(int unit,
     65                                   soc_counter_non_dma_id_t non_dma_id,
     66                                                     bcm_port_t port,
     67                                                     uint64 *val);
     68 extern int
     69 _soc_controlled_counter_get_info(int unit, soc_port_t port, soc_reg_t ctr_reg,
     70                             int *base_index, int *num_entries, char **cname);
     71 
     72 #ifdef BCM_ARAD_SUPPORT
     73 int _bcm_petra_stat_recover(int unit, bcm_pbmp_t okay_nif_ports, uint32 counter_flags, int counter_interval, bcm_pbmp_t counter_pbmp);
     74 #endif
     75 
     76 #if defined(BCM_DPP_SUPPORT)
     77 int 
     78 _bcm_petra_stat_counter_lif_counting_get(
     79     int unit, 
     80     uint32 flags, 
     81     bcm_stat_counter_source_t *source, 
     82     bcm_stat_counter_lif_mask_t *counting_mask, 
     83     bcm_stat_counter_lif_stack_id_t *lif_stack_id_to_count);
     84 #endif /* defined(BCM_DPP_SUPPORT) */
     85 
     86 #endif /* !_BCM_INT_STAT_H */