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

counters.h (46837B)


      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  * Module: internal counter processor work
      8  *
      9  * Purpose:
     10  *     Access to counters hosted by Soc_petra counter processors
     11  */
     12 
     13 #ifndef _BCM_INT_DPP_COUNTERS_H_
     14 #define _BCM_INT_DPP_COUNTERS_H_
     15 
     16 /**************************************************************
     17  * **********************INCLUDES******************************
     18  */
     19 
     20 #include <shared/swstate/sw_state.h>
     21 #include <soc/dpp/dpp_config_defs.h>
     22 #include <soc/dpp/TMC/tmc_api_cnt.h>
     23 #include <soc/types.h>
     24 #include <sal/core/thread.h>
     25 #include <sal/core/sync.h>
     26 #include <bcm/stat.h>
     27 
     28 
     29 /**************************************************************
     30  * ******************* DEFINES, ENUM, MACROS*******************
     31  */
     32 
     33 /*
     34  *  Enum for bits in bitmap listing provided stats in current mode, and for the
     35  *  individual counters within a list of counters to manupulate.
     36  *
     37  *  Note that some of these items would be synthetic in various modes, and many
     38  *  of them will not be supported in all modes.
     39  *
     40  *  WARNING: When adding entries here, add both pkts and bytes versions, in
     41  *  the order as demonstrated.  In several places, it is assumed that one can
     42  *  add one to a pkts value here to get the same bytes value, or subtract one
     43  *  from a bytes value to get a pkts value, in this enum.
     44  *
     45  *  Some of these values may not be supported.
     46  */
     47 
     48 typedef enum bcm_dpp_counter_e {
     49     /* forwarded and dropped frames and bytes */
     50     bcm_dpp_counter_pkts,
     51     bcm_dpp_counter_bytes,
     52     bcm_dpp_counter_green_pkts,
     53     bcm_dpp_counter_green_bytes,
     54     bcm_dpp_counter_not_green_pkts,
     55     bcm_dpp_counter_not_green_bytes,
     56     bcm_dpp_counter_yellow_pkts,
     57     bcm_dpp_counter_yellow_bytes,
     58     bcm_dpp_counter_not_yellow_pkts,
     59     bcm_dpp_counter_not_yellow_bytes,
     60     bcm_dpp_counter_red_pkts,
     61     bcm_dpp_counter_red_bytes,
     62     bcm_dpp_counter_not_red_pkts,
     63     bcm_dpp_counter_not_red_bytes,
     64     /* forwarded frames and bytes */
     65     bcm_dpp_counter_fwd_pkts,
     66     bcm_dpp_counter_fwd_bytes,
     67     bcm_dpp_counter_fwd_green_pkts,
     68     bcm_dpp_counter_fwd_green_bytes,
     69     bcm_dpp_counter_fwd_not_green_pkts,
     70     bcm_dpp_counter_fwd_not_green_bytes,
     71     bcm_dpp_counter_fwd_yellow_pkts,
     72     bcm_dpp_counter_fwd_yellow_bytes,
     73     bcm_dpp_counter_fwd_not_yellow_pkts,
     74     bcm_dpp_counter_fwd_not_yellow_bytes,
     75     bcm_dpp_counter_fwd_red_pkts,
     76     bcm_dpp_counter_fwd_red_bytes,
     77     bcm_dpp_counter_fwd_not_red_pkts,
     78     bcm_dpp_counter_fwd_not_red_bytes,
     79     /* discarded frames and bytes */
     80     bcm_dpp_counter_drop_pkts,
     81     bcm_dpp_counter_drop_bytes,
     82     bcm_dpp_counter_drop_green_pkts,
     83     bcm_dpp_counter_drop_green_bytes,
     84     bcm_dpp_counter_drop_not_green_pkts,
     85     bcm_dpp_counter_drop_not_green_bytes,
     86     bcm_dpp_counter_drop_yellow_pkts,
     87     bcm_dpp_counter_drop_yellow_bytes,
     88     bcm_dpp_counter_drop_not_yellow_pkts,
     89     bcm_dpp_counter_drop_not_yellow_bytes,
     90     bcm_dpp_counter_drop_red_pkts,
     91     bcm_dpp_counter_drop_red_bytes,
     92     bcm_dpp_counter_drop_not_red_pkts,
     93     bcm_dpp_counter_drop_not_red_bytes,
     94 	/* entry by index */
     95     bcm_dpp_counter_offset0_pkts,
     96 	bcm_dpp_counter_offset0_bytes,
     97     bcm_dpp_counter_offset1_pkts,
     98 	bcm_dpp_counter_offset1_bytes,
     99 	bcm_dpp_counter_offset2_pkts,
    100 	bcm_dpp_counter_offset2_bytes,
    101 	bcm_dpp_counter_offset3_pkts,
    102 	bcm_dpp_counter_offset3_bytes,
    103 	bcm_dpp_counter_offset4_pkts,
    104 	bcm_dpp_counter_offset4_bytes,
    105 	bcm_dpp_counter_offset5_pkts,
    106 	bcm_dpp_counter_offset5_bytes,
    107 	bcm_dpp_counter_offset6_pkts,
    108 	bcm_dpp_counter_offset6_bytes,
    109 	bcm_dpp_counter_offset7_pkts,
    110 	bcm_dpp_counter_offset7_bytes,
    111 	/* limit */
    112     bcm_dpp_counter_count /* NOT A VALID ENTRY; MUST BE LAST */
    113 } bcm_dpp_counter_t;
    114 
    115 /* entry bmap- bits mapping*/
    116 #define GREEN_FWD   (1 << SOC_TMC_CNT_BMAP_OFFSET_GREEN_FWD)
    117 #define GREEN_DROP  (1 << SOC_TMC_CNT_BMAP_OFFSET_GREEN_DROP)
    118 #define YELLOW_FWD  (1 << SOC_TMC_CNT_BMAP_OFFSET_YELLOW_FWD)
    119 #define YELLOW_DROP (1 << SOC_TMC_CNT_BMAP_OFFSET_YELLOW_DROP)
    120 #define RED_FWD	    (1 << SOC_TMC_CNT_BMAP_OFFSET_RED_FWD)
    121 #define RED_DROP    (1 << SOC_TMC_CNT_BMAP_OFFSET_RED_DROP)
    122 #define BLACK_FWD   (1 << SOC_TMC_CNT_BMAP_OFFSET_BLACK_FWD)
    123 #define BLACK_DROP  (1 << SOC_TMC_CNT_BMAP_OFFSET_BLACK_DROP)
    124 
    125 /*
    126  *  This is used when querying what stats are available.
    127  */
    128 typedef SHR_BITDCL bcm_dpp_counter_set_t[_SHR_BITDCLSIZE(bcm_dpp_counter_count)];
    129 
    130 /*
    131  *  Specifies the underlying counter source
    132  *
    133  *  This is here only to make debugging easier; it is directly mapped from the
    134  *  value of the counter_source SOC property.
    135  */
    136 
    137 typedef SOC_TMC_CNT_SRC_TYPE _bcm_dpp_counter_source_t;
    138 
    139 /*
    140  *  Diagnostic information tags
    141  */
    142 typedef enum bcm_dpp_counter_diag_info_e {
    143     /* global */
    144     bcm_dpp_counter_diag_info_num_proc,
    145     bcm_dpp_counter_diag_info_bg_active,
    146     bcm_dpp_counter_diag_info_bg_suspend,
    147     bcm_dpp_counter_diag_info_bg_defer,
    148     bcm_dpp_counter_diag_info_fg_hit,
    149     bcm_dpp_counter_diag_info_fifo_read_background,
    150     bcm_dpp_counter_diag_info_fifo_read_deferred,
    151     /* per counter processor */
    152     bcm_dpp_counter_diag_info_fifo_read_passes,
    153     bcm_dpp_counter_diag_info_fifo_read_fails,
    154     bcm_dpp_counter_diag_info_fifo_read_items,
    155     bcm_dpp_counter_diag_info_fifo_read_max,
    156     bcm_dpp_counter_diag_info_fifo_read_last,
    157     bcm_dpp_counter_diag_info_direct_read_passes,
    158     bcm_dpp_counter_diag_info_direct_read_fails,
    159     bcm_dpp_counter_diag_info_cache_updates,
    160     bcm_dpp_counter_diag_info_cache_reads,
    161     bcm_dpp_counter_diag_info_cache_writes,
    162     bcm_dpp_counter_diag_info_api_reads,
    163     bcm_dpp_counter_diag_info_api_writes,
    164     bcm_dpp_counter_diag_info_api_miss_reads,
    165     bcm_dpp_counter_diag_info_api_miss_writes,
    166     bcm_dpp_counter_diag_info_source,
    167     bcm_dpp_counter_diag_info_msb_patten,
    168     bcm_dpp_counter_diag_info_command_id,
    169     bcm_dpp_counter_diag_info_stat_tag_low_bit,
    170     bcm_dpp_counter_diag_info_voq_base,
    171     bcm_dpp_counter_diag_info_voq_per_set,
    172     bcm_dpp_counter_diag_info_format,
    173     bcm_dpp_counter_diag_info_counters,
    174     bcm_dpp_counter_diag_info_sets,
    175     bcm_dpp_counter_diag_info_alloc_local,
    176     bcm_dpp_counter_diag_info_alloc_inuse,
    177     bcm_dpp_counter_diag_info_mode,
    178     bcm_dpp_counter_diag_info_range_start,
    179     bcm_dpp_counter_diag_info_range_end,
    180     /* limit */
    181     bcm_dpp_counter_diag_info_count /* NOT A VALID ENTRY; MUST BE LAST */
    182 } bcm_dpp_counter_diag_info_t;
    183 
    184 /*
    185  *  Counter format
    186  */
    187 typedef enum bcm_dpp_counter_format_e {
    188     bcm_dpp_counter_format_packets,
    189     bcm_dpp_counter_format_bytes,
    190     bcm_dpp_counter_format_packets_and_bytes,
    191     bcm_dpp_counter_format_max_q_size
    192 } bcm_dpp_counter_format_t;
    193 
    194 /*
    195  *  Counter format
    196  */
    197 typedef enum bcm_dpp_counter_replicated_pkts_e {
    198     bcm_dpp_counter_replicated_pkts_all,
    199     bcm_dpp_counter_replicated_pkts_frwrd_and_mc,
    200     bcm_dpp_counter_replicated_pkts_frwrd
    201 } bcm_dpp_counter_replicated_pkts_t;
    202 /*
    203  *  Flags for allocation of counters
    204  *
    205  *  WITH_ID indicates both processor and set ID are specified
    206  *  WITH_PROC indicates processor ID is specified
    207  */
    208 #define BCM_DPP_COUNTER_WITH_ID   0x00000001
    209 #define BCM_DPP_COUNTER_WITH_PROC 0x00000002
    210 
    211 
    212 /*
    213  *  Subcounter index -- each counter is a group, consisting of sub counters.
    214  */
    215 #define _SUB_PKTS 0  /* sub counter for frames */
    216 #define _SUB_BYTES 1 /* sub counter for bytes */
    217 #define _SUB_COUNT 2 /* number of sub counters */
    218 
    219 /* packets and packets mode Subcounter indexes*/
    220 #define _SUB_FWD_PKTS   _SUB_BYTES /* sub counter for forward packets */
    221 #define _SUB_DROP_PKTS  _SUB_PKTS  /* sub counter for droped packets */
    222 
    223 
    224 #define UNSUPPORTED_COUNTER_OFFSET (256)
    225 
    226 #define BCM_DPP_COUNTER_PROC_INFO_VALID 0x1
    227 #define BCM_DPP_COUNTER_PROC_INFO_CONFIGURED_DYNAMICALLY 0x2
    228 
    229 /* set of defines to select which section of SW DB to fill/update*/
    230 #define COUNTER_UPDATE_SELECT_RESERVED                  0x1
    231 #define COUNTER_UPDATE_SELECT_DIAGS                     0x2
    232 #define COUNTER_UPDATE_SELECT_PROC_INFO_ALL             0x4
    233 #define COUNTER_UPDATE_SELECT_PROC_INFO_SPECIFIC_DATA   0x8
    234 #define COUNTER_UPDATE_SELECT_BACKROUND_INFO            0x10
    235 #define COUNTER_UPDATE_SELECT_LIF_INFO                  0x20
    236 #define COUNTER_UPDATE_SELECT_FIFO_INFO                 0x40
    237 #define COUNTER_UPDATE_SELECT_ALL (COUNTER_UPDATE_SELECT_RESERVED      | \
    238                                    COUNTER_UPDATE_SELECT_DIAGS         | \
    239                                    COUNTER_UPDATE_SELECT_PROC_INFO_ALL | \
    240                                    COUNTER_UPDATE_SELECT_BACKROUND_INFO| \
    241                                    COUNTER_UPDATE_SELECT_LIF_INFO      | \
    242                                    COUNTER_UPDATE_SELECT_FIFO_INFO)
    243 
    244 #define COUNTER_OUT_LIF_SOURCE_INDEX (0)
    245 #define COUNTER_IN_LIF_SOURCE_INDEX (1)
    246 
    247 
    248 /**************************************************************
    249  * *****************STRUCTURES*********************************
    250  */
    251 
    252 /* per proc statistics and diagnostics */
    253 typedef struct _bcm_dpp_counter_proc_diag_s {
    254     unsigned int direct_read_passes;        /* direct read successes */
    255     unsigned int direct_read_fails;         /* direct read errors */
    256     unsigned int cache_updates;             /* cache updates (by bg/direct) */
    257     unsigned int cache_reads;               /* cache reads */
    258     unsigned int cache_writes;              /* cache writes */
    259     unsigned int api_reads;                 /* API requested reads */
    260     unsigned int api_writes;                /* API requested writes */
    261     unsigned int api_miss_reads;            /* API req reads to invalid ctr */
    262     unsigned int api_miss_writes;           /* SPI req writes to invalid ctr */
    263 } _bcm_dpp_counter_proc_diag_t;
    264 
    265 typedef struct _bcm_dpp_counter_proc_field_info_s {
    266     unsigned int allocated;                     /* number of allocated sets */
    267     PARSER_HINT_ARR uint8 *inUse;               /* bits indicating in use sets */
    268 } _bcm_dpp_counter_proc_field_info_t;
    269 
    270 /*
    271  *  Per counter processor information
    272  *
    273  *  The term 'counter pair' here refers to the bytes+frames counter pair per
    274  *  element in the hardware, not some larger scale pairing, such as the ingress
    275  *  colour disabled mode; these larger groupings are covered by the format.
    276  *  The term 'counter set' describes such larger grouping.
    277  *
    278  *  Certain sources (such as VOQ or VSI) have implied assignments of the
    279  *  counter sets; those sources will not allocate any in use bits.  Sources
    280  *  that do not imply counter set assignments (such as PP or STAG) will
    281  *  allocate bits for tracking which sets are in use.
    282  */
    283 typedef struct _bcm_dpp_counter_proc_info_s {
    284     uint8 valid;                                 /* bit1 - valid,  bit 2 - if configure via API */
    285     SOC_TMC_CNT_PROCESSOR_ID proc_id;            /* this counter processor ID */
    286     SOC_TMC_CNT_COUNTERS_INFO mode;              /* this counter processor mode */
    287     /* supported counters - native */
    288     SHR_BITDCL native[_SHR_BITDCLSIZE(bcm_dpp_counter_count)];
    289     /* each entry can be unsupported val - unsupported counter/ offset - for native counter/ offsets bmap - for simulated counter*/
    290     uint32 avail_offsets[bcm_dpp_counter_count];   
    291     PARSER_HINT_ALLOW_WB_ACCESS _bcm_dpp_counter_proc_diag_t diag;  /* per proc statistics and diagnostics */
    292     _bcm_dpp_counter_proc_field_info_t field;                       /* field allocation - used for PMF */
    293 } _bcm_dpp_counter_proc_info_t;
    294 
    295 /* per fifo statistics and diagnostics */
    296 typedef struct _bcm_dpp_counter_fifo_info_s {
    297     unsigned int fifo_read_passes;          /* FIFO read successes */
    298     unsigned int fifo_read_fails;           /* FIFO read errors */
    299     unsigned int fifo_read_items;           /* total counters in FIFO reads */
    300     unsigned int fifo_read_max;             /* largest single FIFO read */
    301     unsigned int fifo_read_last;            /* last counter read by FIFO */
    302     uint8 ref_count;                        /* How many engines are enabled and need DMA-Channel (Narro-format)*/
    303 } _bcm_dpp_counter_fifo_info_t;
    304 
    305 typedef struct _bcm_dpp_counter_global_info_s {
    306     uint8 haveStatTag;
    307     /*
    308      *  cache_only controls whether the stat code uses the cached or direct version of the functions.
    309      *  It is controlled by the field control bcmFieldControlStatSyncEnable.
    310      *  When stat sync enabled (this flag is FALSE, the default condition),
    311      *  the field APIs will use uncached access to the counter processors,
    312      *  enabling reads and writes to apply immediately.
    313      *  When stat sync disabled (this flag is TRUE), the field APIs will only use
    314      *  the cached access to the counter processors, which means reads apply to the
    315      *  time of last ejection for a counter, and writes also apply to the time of
    316      *  last ejection for a counter.
    317      */
    318     uint8 cache_only;
    319 } _bcm_dpp_counter_global_info_t;
    320 
    321     /* statistics and diagnostics */
    322 typedef struct _bcm_dpp_counter_diag_s {
    323     /* statistics and diagnostics */
    324     unsigned int fifo_read_background;      /* background FIFO attempts */
    325     unsigned int fifo_read_deferred;        /* deferred FIFO attempts */
    326 } _bcm_dpp_counter_diag_t;
    327 
    328 
    329 typedef struct _bcm_dpp_counter_lif_ranges_s {
    330     int counting_profile;
    331     int lif_stack_priority[BCM_STAT_COUNT_LIF_NUMBER_OF_STACK_IDS];
    332 } _bcm_dpp_counter_lif_ranges_t;
    333 
    334 /* default values of the QP, TC, Cast masks and shifts*/
    335 #define QUEUE_PAIR_MASK         255
    336 #define TRAFFIC_CLASS_MASK      7
    337 #define CAST_MASK               1
    338 #define QUEUE_PAIR_SHIFT        4
    339 #define TRAFFIC_CLASS_SHIFT     1
    340 #define CAST_SHIFT              0
    341 
    342 typedef struct _bcm_dpp_egress_receive_tm_pointer_format_s {
    343     uint32 queue_pair_mask;     /* Which bits to consider from the queue pair
    344                                    field when building the counter pointer. */
    345     uint32 traffic_class_mask;  /* Which bits to consider from the traffic class
    346                                    field when building the counter pointer. */
    347     uint32 cast_mask;           /* Consider (or not) the cast bit when building
    348                                    the counter pointer. */
    349     uint32 queue_pair_shift;
    350     uint32 traffic_class_shift;
    351     uint32 cast_shift;
    352 } _bcm_dpp_egress_receive_tm_pointer_format_t;
    353 
    354 /*
    355  *  Per unit information
    356  */
    357 typedef struct _bcm_dpp_counter_state_s {
    358     /* per unit information */
    359     int cunit;                               /* unit number */
    360     int sampling_interval_configured;        /* is BG thread and DMA configured to be active by SOC or API*/
    361     unsigned int num_counter_procs;         /* number of counter processors */
    362     /* interlocking */
    363     PARSER_HINT_ALLOW_WB_ACCESS int background_defer;                   /* defer background updates */
    364     PARSER_HINT_ALLOW_WB_ACCESS int background_active;                  /* background update occurring */
    365     PARSER_HINT_ALLOW_WB_ACCESS int background_disable;                 /* background updates disabled */
    366     PARSER_HINT_ALLOW_WB_ACCESS int foreground_hit;                     /* a foreground access occurred */
    367     PARSER_HINT_ALLOW_WB_ACCESS _bcm_dpp_counter_diag_t diag; 
    368     /* per processor information */
    369     PARSER_HINT_ALLOW_WB_ACCESS PARSER_HINT_ARR _bcm_dpp_counter_proc_info_t *proc; /* per processor information */
    370     PARSER_HINT_ALLOW_WB_ACCESS PARSER_HINT_ARR_ARR uint64 **counter;    /* cache of this proc's counters */
    371     PARSER_HINT_ALLOW_WB_ACCESS _bcm_dpp_counter_fifo_info_t fifo[SOC_DPP_DEFS_MAX(NOF_COUNTER_FIFOS)];
    372     _bcm_dpp_counter_global_info_t global_info;
    373     _bcm_dpp_counter_lif_ranges_t lif_ranges[SOC_TMC_CNT_LIF_COUNTING_NOF_SOURCES][SOC_TMC_CNT_LIF_COUNTING_MAX_NOF_RANGES_PER_SOURCE]; 
    374     _bcm_dpp_egress_receive_tm_pointer_format_t egress_receive_tm_pointer_format;
    375 } _bcm_dpp_counter_state_t;
    376 
    377 
    378 typedef struct bcm_dpp_counter_bg_thread_and_dma_data {
    379     int running;                            /* unit background thread enable */
    380     int bgWait;                             /* delay per bg iter (microsec) */   
    381     uint8 dma_attached;
    382     uint8 dma_channel[SOC_DPP_DEFS_MAX(NOF_COUNTER_FIFOS)]; /* DMA-Channel attached to each FIFO*/
    383 } bcm_dpp_counter_bg_thread_and_dma_data_t;
    384 
    385 
    386 typedef struct bcm_dpp_counter_proc_and_set_s {
    387     int ctr_proc_id;
    388     int ctr_set_id;
    389 } bcm_dpp_counter_proc_and_set_t;
    390 
    391 
    392 typedef struct bcm_dpp_counter_proc_specific_data_s
    393 {
    394     const bcm_dpp_counter_t *type;
    395     int                     typeSize;
    396     unsigned int            procArr[SOC_DPP_DEFS_MAX(NOF_COUNTER_PROCESSORS) + SOC_DPP_DEFS_MAX(NOF_SMALL_COUNTER_PROCESSORS)];
    397     int                     procArrSize;
    398 }bcm_dpp_counter_proc_specific_data_s;
    399 
    400 /**************************************************************
    401  * *****************GLOBALS************************************
    402  */
    403 
    404 extern const char * const bcm_dpp_counter_t_names[];
    405 extern _bcm_dpp_counter_state_t *_bcm_dpp_counter_state[SOC_MAX_NUM_DEVICES];
    406 extern int _bcm_counter_thread_is_running[SOC_MAX_NUM_DEVICES];
    407 
    408 
    409 
    410 /**************************************************************
    411  * *****************FUNCTIONS**********************************
    412  */
    413 
    414 /*
    415  *   Name
    416  *     bcm_dpp_counter_init
    417  *   Purpose
    418  *     Initialise the counter processor handling
    419  *   Arguments
    420  *     IN int unit = the unit number on which to operate
    421  *   Returns
    422  *     bcm_error_t cast as int
    423  *       BCM_E_NONE if success
    424  *       BCM_E_* otherwise as appropriate
    425  *   Notes
    426  */
    427 extern int
    428 bcm_dpp_counter_init(int unit);
    429 
    430 
    431 /*
    432  *  Name
    433  *    bcm_dpp_counter_reserve_dma_channel
    434  *  Purpose
    435  *    Make a DMA channel un-allocatable. 
    436  *  Arguments
    437  *    int unit = unit number.
    438  *    uint8 channel - reserved channel.
    439  *   Returns
    440  *     bcm_error_t cast as int
    441  *       BCM_E_NONE if success
    442  *       BCM_E_* otherwise as appropriate
    443  *   Notes
    444  *     The only DMAs that allowed also by CRPS will be active
    445  * 
    446  *     Unit must be initialized.
    447  */
    448 int bcm_dpp_counter_reserve_dma_channel(
    449     int unit, 
    450     uint8 channel);
    451 
    452 /*
    453  *   Name
    454  *     bcm_dpp_counter_background_collection_enable_set
    455  *   Purpose
    456  *     Stop the background thread and disable DMA FIFO
    457  *   Arguments
    458  *   Arguments
    459  *     IN int unit = the unit number on which to operate
    460  *     IN int enable = enable/disable counter thread and DMA operation
    461  *   Returns
    462  *     bcm_error_t cast as int
    463  *       BCM_E_NONE if success
    464  *       BCM_E_* otherwise as appropriate
    465  *   Notes
    466  */
    467 extern int 
    468 bcm_dpp_counter_background_collection_enable_set(int unit, int enable);
    469 
    470 /*
    471  *   Name
    472  *     bcm_dpp_counter_background_collection_enable_get
    473  *   Purpose
    474  *     Get the background collection enable/disable mode
    475  *   Arguments
    476  *   Arguments
    477  *     IN int unit = the unit number on which to operate
    478  *     OUT int enable = counter thread status - enable/disable 
    479  *   Returns
    480  *     bcm_error_t cast as int
    481  *       BCM_E_NONE if success
    482  *       BCM_E_* otherwise as appropriate
    483  *   Notes:
    484  *   Not check DMA status
    485  */
    486 extern int 
    487 bcm_dpp_counter_background_collection_enable_get(int unit, int *enable);
    488 
    489 /*
    490  *   Name
    491  *     bcm_dpp_counter_detach
    492  *   Purpose
    493  *     Deinitialise the counter processor handling
    494  *   Arguments
    495  *   Arguments
    496  *     IN int unit = the unit number on which to operate
    497  *   Returns
    498  *     bcm_error_t cast as int
    499  *       BCM_E_NONE if success
    500  *       BCM_E_* otherwise as appropriate
    501  *   Notes
    502  */
    503 extern int
    504 bcm_dpp_counter_detach(int unit);
    505 
    506 /*
    507  *   Name
    508  *     bcm_dpp_counter_avail_get
    509  *   Purpose
    510  *     Get information about which stats are provided for a given counter set.
    511  *   Arguments
    512  *     IN int unit = the unit number on which to operate
    513  *     IN unsigned int proc = the counter processor on which to operate
    514  *     OUT bcm_dpp_counter_set_t *avail = where to put available set
    515  *     OUT bcm_dpp_counter_set_t *native = where to put native set
    516  *   Returns
    517  *     bcm_error_t cast as int
    518  *       BCM_E_NONE if success
    519  *       BCM_E_* otherwise as appropriate
    520  *   Notes
    521  *     The 'available' set includes all stats that are available in the current
    522  *     mode, both native and emulated.
    523  *
    524  *     The 'native' set includes all stats that are supported natively by the
    525  *     current hardware mode.
    526  *
    527  *     Here 'native' refers to stats that are directly supported by the current
    528  *     hardware mode, while 'emulated' refers to stats that can be derived by
    529  *     combining 'native' stats in some way.  For example, if the current
    530  *     hardware mode provides {drop green, drop yellow, drop red}, it is
    531  *     possible to emulate {drop all, drop not green, drop not yellow, drop not
    532  *     red} from the native information.
    533  *
    534  *     In error case, both avail and native will be cleared.
    535  *
    536  *     Current and next generation (Soc_petra and Arad) do not support multiple
    537  *     modes per counter processor, so this only takes counter processor as the
    538  *     argument to determine the mode.  May change in distant future.
    539  */
    540 extern int
    541 bcm_dpp_counter_avail_get(int unit,
    542                           unsigned int proc,
    543                           bcm_dpp_counter_set_t *avail,
    544                           bcm_dpp_counter_set_t *native);
    545 
    546 /*
    547  *   Name
    548  *     bcm_dpp_counter_get(_cached)
    549  *   Purpose
    550  *     Retrieve a specific statistic from a counter set
    551  *   Arguments
    552  *     IN int unit = the unit number on which to operate
    553  *     IN unsigned int proc = the counter processor on which to operate
    554  *     IN unsigned int set_id = the ID of the counter set to read
    555  *     IN bcm_dpp_counter_t type = which stat to retrieve
    556  *     OUT uint64 *stat = where to put the retrieved stat
    557  *   Returns
    558  *     bcm_error_t cast as int
    559  *       BCM_E_NONE for success
    560  *       BCM_E_EMPTY if a requested stat is not available
    561  *       BCM_E_NOT_FOUND if requested set is not in use
    562  *       BCM_E_* otherwise as appropriate
    563  *   Notes
    564  *     It is far more efficient to use the multt_get if you want more than one.
    565  *
    566  *     May return success when getting stats that are not supported in the
    567  *     current mode; such stats will be returned as zero.
    568  *
    569  *     Some stats may be filled in by emulating them (arithmetic on native
    570  *     stats).
    571  *
    572  *     BCM API convention also specs BCM_E_NOT_FOUND if the set_id is invalid.
    573  *
    574  *     The _cached version of the call works exclusively with the cache and
    575  *     does not sync to the hardware.  It should be used in sensitive contexts
    576  *     (such as IRQ handler) or if speed is substantially more important than
    577  *     accuracy, but not in other contexts.  Note that in this mode, any data
    578  *     on the hardware will be ignored, leading to possibly large grained
    579  *     updates on reads and sets eventually including large possibly stale
    580  *     values from hardware. The effect will be significantly more pronounced
    581  *     on slower flows.  Also in this mode, it is possible that a background
    582  *     update will occur during the access, leading to inconsistent values.
    583  */
    584 extern int
    585 bcm_dpp_counter_get(int unit,
    586                     unsigned int proc,
    587                     unsigned int set_id,
    588                     bcm_dpp_counter_t type,
    589                     uint64 *stat);
    590 extern int
    591 bcm_dpp_counter_get_cached(int unit,
    592                            unsigned int proc,
    593                            unsigned int set_id,
    594                            bcm_dpp_counter_t type,
    595                            uint64 *stat);
    596 
    597 /*
    598  *   Name
    599  *     bcm_dpp_counter_set(_cached)
    600  *   Purpose
    601  *     Updates a specific statistic of a counter set
    602  *   Arguments
    603  *     IN int unit = the unit number on which to operate
    604  *     IN unsigned int proc = the counter processor on which to operate
    605  *     IN unsigned int set_id = the ID of the counter set to write
    606  *     IN bcm_dpp_counter_t type = which stat to set
    607  *     IN uint64 stat = the new value for the statistic
    608  *   Returns
    609  *     bcm_error_t cast as int
    610  *       BCM_E_NONE for success
    611  *       BCM_E_EMPTY if a requested stat is not available
    612  *       BCM_E_NOT_FOUND if requested set is not in use
    613  *       BCM_E_* otherwise as appropriate
    614  *   Notes
    615  *     It is far more efficient to use the multt_set if you want more than one.
    616  *
    617  *     May return success even for stats that are not supported in the current
    618  *     mode; no changes will be made for such stats.
    619  *
    620  *     For stats that are emulated by arithmetic, the values of the individual
    621  *     'native' stats participating in an emulated stat are not guaranteed;
    622  *     only that the total will be as written.  It is therefore best to only
    623  *     set native stats or to only set stats to zero.
    624  *
    625  *     BCM API convention also specs BCM_E_NOT_FOUND if the set_id is invalid.
    626  *
    627  *     The _cached version of the call works exclusively with the cache and
    628  *     does not sync to the hardware.  It should be used in sensitive contexts
    629  *     (such as IRQ handler) or if speed is substantially more important than
    630  *     accuracy, but not in other contexts.  Note that in this mode, any data
    631  *     on the hardware will be ignored, leading to possibly large grained
    632  *     updates on reads and sets eventually including large possibly stale
    633  *     values from hardware. The effect will be significantly more pronounced
    634  *     on slower flows.  Also in this mode, it is possible that a background
    635  *     update will occur during the access, leading to inconsistent values.
    636  */
    637 extern int
    638 bcm_dpp_counter_set(int unit,
    639                     unsigned int proc,
    640                     unsigned int set_id,
    641                     bcm_dpp_counter_t type,
    642                     uint64 stat);
    643 extern int
    644 bcm_dpp_counter_set_cached(int unit,
    645                            unsigned int proc,
    646                            unsigned int set_id,
    647                            bcm_dpp_counter_t type,
    648                            uint64 stat);
    649 
    650 /*
    651  *   Name
    652  *     bcm_dpp_counter_multi_get(_cached)
    653  *   Purpose
    654  *     Retrieve specific stats from a counter set
    655  *   Arguments
    656  *     IN int unit = the unit number on which to operate
    657  *     IN unsigned int proc = the counter processor on which to operate
    658  *     IN unsigned int set_id = the ID of the counter set to read
    659  *     IN unsigned int count = number of stats to retrieve
    660  *     IN bcm_dpp_counter_t *type = list of stats to retrieve
    661  *     OUT uint64 *stats = where to put the retrieved stats
    662  *   Returns
    663  *     bcm_error_t cast as int
    664  *       BCM_E_NONE for success
    665  *       BCM_E_EMPTY if a requested stat is not available
    666  *       BCM_E_NOT_FOUND if requested set is not in use
    667  *       BCM_E_* otherwise as appropriate
    668  *   Notes
    669  *     On success, some stats may not have been supported in the particular
    670  *     configuration.  These stats will be zeroed.
    671  *
    672  *     Some stats may be filled in by emulating them (arithmetic on known
    673  *     stats).
    674  *
    675  *     BCM API convention also specs BCM_E_NOT_FOUND if the set_id is invalid.
    676  *
    677  *     type and stat are pointers to the initial element of respective arrays.
    678  *
    679  *     The _cached version of the call works exclusively with the cache and
    680  *     does not sync to the hardware.  It should be used in sensitive contexts
    681  *     (such as IRQ handler) or if speed is substantially more important than
    682  *     accuracy, but not in other contexts.  Note that in this mode, any data
    683  *     on the hardware will be ignored, leading to possibly large grained
    684  *     updates on reads and sets eventually including large possibly stale
    685  *     values from hardware. The effect will be significantly more pronounced
    686  *     on slower flows.  Also in this mode, it is possible that a background
    687  *     update will occur during the access, leading to inconsistent values.
    688  */
    689 extern int
    690 bcm_dpp_counter_multi_get(int unit,
    691                           unsigned int proc,
    692                           unsigned int set_id,
    693                           unsigned int count,
    694                           const bcm_dpp_counter_t *type,
    695                           uint64 *stat);
    696 extern int
    697 bcm_dpp_counter_multi_get_cached(int unit,
    698                                  unsigned int proc,
    699                                  unsigned int set_id,
    700                                  unsigned int count,
    701                                  const bcm_dpp_counter_t *type,
    702                                  uint64 *stat);
    703 
    704 /*
    705  *   Name
    706  *     bcm_dpp_counter_multi_set(_cached)
    707  *   Purpose
    708  *     Set specific stats from a counter set
    709  *   Arguments
    710  *     IN int unit = the unit number on which to operate
    711  *     IN unsigned int proc = the counter processor on which to operate
    712  *     IN unsigned int set_id = the ID of the counter set to write
    713  *     IN unsigned int count = number of stats to set
    714  *     IN bcm_dpp_counter_t *type = list of stats to set
    715  *     IN uint64 *stats = where to put the retrieved stats
    716  *   Returns
    717  *     bcm_error_t cast as int
    718  *       BCM_E_NONE for success
    719  *       BCM_E_EMPTY if a requested stat is not available
    720  *       BCM_E_NOT_FOUND if requested set is not in use
    721  *       BCM_E_* otherwise as appropriate
    722  *   Notes
    723  *     On success, stats that are not supported in the particular mode were
    724  *     ignored (no changes made).
    725  *
    726  *     For stats that are emulated by arithmetic, the values of the individual
    727  *     'native' stats participating in an emulated stat are not guaranteed;
    728  *     only that the total will be as written.  It is therefore best to only
    729  *     set native stats or to only set stats to zero.
    730  *
    731  *     BCM API convention also specs BCM_E_NOT_FOUND if the set_id is invalid.
    732  *
    733  *     type and stat are pointers to the initial element of respective arrays.
    734  *
    735  *     The _cached version of the call works exclusively with the cache and
    736  *     does not sync to the hardware.  It should be used in sensitive contexts
    737  *     (such as IRQ handler) or if speed is substantially more important than
    738  *     accuracy, but not in other contexts.  Note that in this mode, any data
    739  *     on the hardware will be ignored, leading to possibly large grained
    740  *     updates on reads and sets eventually including large possibly stale
    741  *     values from hardware. The effect will be significantly more pronounced
    742  *     on slower flows.  Also in this mode, it is possible that a background
    743  *     update will occur during the access, leading to inconsistent values.
    744  */
    745 extern int
    746 bcm_dpp_counter_multi_set(int unit,
    747                           unsigned int proc,
    748                           unsigned int set_id,
    749                           unsigned int count,
    750                           const bcm_dpp_counter_t *type,
    751                           /*const*/ uint64 *stat);
    752 extern int
    753 bcm_dpp_counter_multi_set_cached(int unit,
    754                                  unsigned int proc,
    755                                  unsigned int set_id,
    756                                  unsigned int count,
    757                                  const bcm_dpp_counter_t *type,
    758                                  /*const*/ uint64 *stat);
    759 
    760 /*
    761  *   Name
    762  *     bcm_dpp_counter_diag_info_get
    763  *   Purpose
    764  *     DIAGNOSTICS: Retrieve information about the counter state on a unit
    765  *   Arguments
    766  *     IN int unit = the unit number on which to operate
    767  *     IN bcm_dpp_counter_diag_info_t info = which item to retrieve
    768  *     IN unsigned int proc = the counter processor on which to operate
    769  *     OUT unsigned int *value = where to put the retrieved value
    770  *   Returns
    771  *     bcm_error_t cast as int
    772  *       BCM_E_NONE if success
    773  *       BCM_E_* otherwise as appropriate
    774  *   Notes
    775  *     Some items apply globally to a unit; others only to a single counter
    776  *     processor.  For those that are for a particular counter processor, the
    777  *     processor number chooses the counter processor.  For all cases, the
    778  *     processor number must be valid, so it is best to use zero as the
    779  *     processor number for any of the global information.
    780  */
    781 extern int
    782 bcm_dpp_counter_diag_info_get(int unit,
    783                               bcm_dpp_counter_diag_info_t info,
    784                               unsigned int proc,
    785                               unsigned int *value);
    786 /**/
    787 extern int
    788 bcm_dpp_counter_egress_receive_tm_pointer_update( int unit,
    789                                                   uint32 queue_pair_mask, 
    790                                                   uint32 traffic_class_mask, 
    791                                                   uint32 cast_mask, 
    792                                                   uint32 queue_pair_shift, 
    793                                                   uint32 traffic_class_shift, 
    794                                                   uint32 cast_shift);
    795 /*
    796  *   Name
    797  *     bcm_dpp_counter_find_egress_que
    798  *   Purpose
    799  *     Find the counter processor and set that is used for egress.
    800  *   Arguments
    801  *     IN int unit = the unit number on which to operate
    802  *     IN unsigned int max_set_cnt - Size of result array
    803  *     IN unsigned int offset = Offset (TC)
    804  *     IN unsigned int tm_port
    805  *     IN unsigned int is_mc
    806  *     IN unsigned int pp_port
    807  *     OUT unsigned int *proc = the counter processor handlng the results
    808  *     OUT unsigned int *set_array = the counter set handling the results
    809  *     OUT unsigned int *set_cnt = the number of actual entries in set_array
    810  *   Returns
    811  *     bcm_error_t cast as int
    812  *       BCM_E_NONE if success
    813  *       BCM_E_NOT_FOUND if the VOQ is not handled by any counter processor
    814  *       BCM_E_* otherwise as appropriate
    815  *   Notes
    816  *     Unwanted OUT arguments may be NULL.
    817  */
    818 
    819 
    820 extern int
    821 bcm_dpp_counter_find_egress_que(int unit,
    822                          unsigned int max_set_cnt,
    823                          unsigned int offset,
    824                          int core_id,
    825                          unsigned int tm_port,
    826                          unsigned int is_mc,
    827                          unsigned int pp_port,
    828                          bcm_dpp_counter_t ctrStat,
    829                          unsigned int *use_color, /* If True, the color of stat was used */
    830                          bcm_dpp_counter_proc_and_set_t *proc_set_array,
    831                          unsigned int *set_cnt);
    832  
    833 /*
    834  *   Name
    835  *     bcm_dpp_counter_find_voq
    836  *   Purpose
    837  *     Find the counter processor and set that is used for a paricular VOQ, and
    838  *     the range of VOQs associated with that processor and set.
    839  *   Arguments
    840  *     IN int unit = the unit number on which to operate
    841  *     IN unsigned int voq = the VOQ of interest
    842  *     OUT unsigned int *proc = the counter processor handlng the VOQ
    843  *     OUT unsigned int *set = the counter set handling the VOQ
    844  *     OUT unsigned int *first = the first VOQ handled by the set
    845  *     OUT unsigned int *last = the last VOQ handled by the set
    846  *   Returns
    847  *     bcm_error_t cast as int
    848  *       BCM_E_NONE if success
    849  *       BCM_E_NOT_FOUND if the VOQ is not handled by any counter processor
    850  *       BCM_E_* otherwise as appropriate
    851  *   Notes
    852  *     Unwanted OUT arguments may be NULL.
    853  */
    854 extern int
    855 bcm_dpp_counter_find_voq(int unit,
    856                          int core_id,
    857                          unsigned int voq,
    858                          bcm_dpp_counter_proc_and_set_t *proc_and_set,
    859                          bcm_dpp_counter_t ctrStat,
    860                          int* nof_found,
    861                          unsigned int *first,
    862                          unsigned int *last);
    863 
    864 /*
    865  *   Name
    866  *     bcm_dpp_counter_find_stag
    867  *   Purpose
    868  *     Find the counter processor and set that is used for a paricular
    869  *     statistics tag, and the range of statistics tags associated with that
    870  *     processor and set.
    871  *   Arguments
    872  *     IN int unit = the unit number on which to operate
    873  *     IN unsigned int stag = the stat tag of interest
    874  *     OUT unsigned int *proc = the counter processor handlng the stat tag
    875  *     OUT unsigned int *set = the counter set handling the stat tag
    876  *     OUT unsigned int *first = the first stat tag handled by the set
    877  *     OUT unsigned int *last = the last stat tag handled by the set
    878  *   Returns
    879  *     bcm_error_t cast as int
    880  *       BCM_E_NONE if success
    881  *       BCM_E_NOT_FOUND if the stat tag is not handled by any counter processor
    882  *       BCM_E_* otherwise as appropriate
    883  *   Notes
    884  *     Unwanted OUT arguments may be NULL.
    885  */
    886 extern int
    887 bcm_dpp_counter_find_stag(int unit,
    888                           unsigned int stag,
    889                           unsigned int *proc,
    890                           unsigned int *set,
    891                           unsigned int *first,
    892                           unsigned int *last);
    893 
    894 /*
    895  *   Name
    896  *     bcm_dpp_counter_find_vsi
    897  *   Purpose
    898  *     Find the counter processor and set that is used for a paricular VSI
    899  *   Arguments
    900  *     IN int unit = the unit number on which to operate
    901  *     IN unsigned int vsi = the VSI of interest
    902  *     OUT unsigned int *proc = the counter processor handlng the VSI
    903  *     OUT unsigned int *set = the counter set handling the VSI
    904  *   Returns
    905  *     bcm_error_t cast as int
    906  *       BCM_E_NONE if success
    907  *       BCM_E_NOT_FOUND if the VSI is not handled by any counter processor
    908  *       BCM_E_* otherwise as appropriate
    909  *   Notes
    910  *     Unwanted OUT arguments may be NULL.
    911  */
    912 extern int
    913 bcm_dpp_counter_find_vsi(int unit,
    914                          unsigned int vsi,
    915                          unsigned int *proc,
    916                          unsigned int *set);
    917 
    918 /*
    919  *   Name
    920  *     bcm_dpp_counter_find_outlif
    921  *   Purpose
    922  *     Find the counter processor and set that is used for a paricular outlif
    923  *   Arguments
    924  *     IN int unit = the unit number on which to operate
    925  *     IN unsigned int voq = the outlif of interest
    926  *     OUT unsigned int *proc = the counter processor handlng the outlif
    927  *     OUT unsigned int *set = the counter set handling the outlif
    928  *   Returns
    929  *     bcm_error_t cast as int
    930  *       BCM_E_NONE if success
    931  *       BCM_E_NOT_FOUND if the outlif is not handled by any counter processor
    932  *       BCM_E_* otherwise as appropriate
    933  *   Notes
    934  *     Unwanted OUT arguments may be NULL.
    935  */
    936 extern int
    937 bcm_dpp_counter_find_outlif(int unit,
    938                             unsigned int outlif,
    939                             unsigned int *proc,
    940                             unsigned int *set);
    941 
    942 /*
    943  *  Name
    944  *    bcm_dpp_counter_alloc
    945  *  Purpose
    946  *    Allocate a counter set from a processor where we are providing allocation
    947  *    from this module (rather than it being implied by the source type).
    948  *  Arguments
    949  *    IN int unit = the unit number on which to operate
    950  *    IN uint32 flags = flags for allocation control
    951  *    IN _bcm_dpp_counter_source_t source = source for the allocated set
    952  *    IN/OUT int *proc = the counter processor for the counter set
    953  *    IN/OUT int *set_id = the ID of the counter set
    954  *   Returns
    955  *     bcm_error_t cast as int
    956  *       BCM_E_NONE if success
    957  *       BCM_E_NOT_FOUND if no available proc using the source
    958  *       BCM_E_CONFIG if we don't allocate that source here
    959  *       BCM_E_RESOURCE if there is no available set for the requested source
    960  *       BCM_E_EXSISTS if we alloc and WITH_ID and it is already in use
    961  *       BCM_E_* otherwise as appropriate
    962  *  Notes
    963  *    If WITH_PROC is specified instead of WITH_ID, will search for a free set
    964  *    on the speicied processor.
    965  *
    966  *    If WITH_ID is specified instead of WITH_PROC, will only try to allocate
    967  *    the specified set on the specified processor.
    968  *
    969  *    If neither WITH_ID nor WITH_PROC is specified, will search for a free set
    970  *    on any processor(s) that are using the requested source.
    971  */
    972 extern int
    973 bcm_dpp_counter_alloc(int unit,
    974                       uint32 flags,
    975                       _bcm_dpp_counter_source_t source,
    976                       unsigned int *proc,
    977                       unsigned int *set);
    978 
    979 /*
    980  *  Name
    981  *    bcm_dpp_counter_free
    982  *  Purpose
    983  *    Free a counter set from a processor where we are providing allocation
    984  *    from this module (rather than it being implied by the source type).
    985  *  Arguments
    986  *    IN int unit = the unit number on which to operate
    987  *    IN unsigned int proc = the counter processor for the counter set
    988  *    IN unsigned int set_id = the ID of the counter set
    989  *   Returns
    990  *     bcm_error_t cast as int
    991  *       BCM_E_NONE if success
    992  *       BCM_E_* otherwise as appropriate
    993  *  Notes
    994  */
    995 extern int
    996 bcm_dpp_counter_free(int unit,
    997                      unsigned int proc,
    998                      unsigned int set);
    999 
   1000 /*
   1001  *  Name
   1002  *    bcm_dpp_counter_bg_enable_set
   1003  *  Purpose
   1004  *    Set background thread's access to the counter processor.
   1005  *  Arguments
   1006  *    IN int unit = the unit number on which to operate
   1007  *    IN int enable = TRUE to allow background updates, FALSE to disallow
   1008  *   Returns
   1009  *     bcm_error_t cast as int
   1010  *       BCM_E_NONE if success
   1011  *       BCM_E_* otherwise as appropriate
   1012  *  Notes
   1013  *    Disabling background updates does not prevent demand accesses reading the
   1014  *    counter hardware, either directly or through the ejection FIFO.
   1015  */
   1016 extern int
   1017 bcm_dpp_counter_bg_enable_set(int unit,
   1018                               int enable);
   1019 
   1020 /*
   1021  *  Name
   1022  *    bcm_dpp_counter_bg_enable_get
   1023  *  Purpose
   1024  *    Set background thread's access to the counter processor.
   1025  *  Arguments
   1026  *    IN int unit = the unit number on which to operate
   1027  *    OUT int *enable = TRUE to allow background updates, FALSE to disallow
   1028  *   Returns
   1029  *     bcm_error_t cast as int
   1030  *       BCM_E_NONE if success
   1031  *       BCM_E_* otherwise as appropriate
   1032  *  Notes
   1033  *    Disabling background updates does not prevent demand accesses reading the
   1034  *    counter hardware, either directly or through the ejection FIFO.
   1035  */
   1036 extern int
   1037 bcm_dpp_counter_bg_enable_get(int unit,
   1038                               int *enable);
   1039 extern int 
   1040 bcm_dpp_counter_stag_lsb_get(
   1041         int unit,
   1042         uint32* stag_lsb,
   1043         uint8* enable);
   1044 
   1045 extern int 
   1046 bcm_dpp_counter_lif_range_is_allocated(
   1047    int unit, 
   1048    uint8* is_allocated);
   1049 extern int 
   1050 bcm_dpp_counter_lif_range_source_is_allocated(
   1051    int unit, 
   1052    SOC_TMC_CNT_SRC_TYPE source, 
   1053    int range_id, 
   1054    uint8* is_allocated);
   1055 
   1056 extern int 
   1057 bcm_dpp_counter_lif_range_get(
   1058     int                  unit,
   1059     int                  counting_profile,
   1060     SOC_TMC_CNT_SRC_TYPE *source,
   1061     int                  *command_id,
   1062     int                  *stif_id,
   1063     SOC_SAND_U32_RANGE   *range,
   1064     uint32               *offset,
   1065     int                  *is_double_entry,
   1066     int                  *engine_range_offset    
   1067    );
   1068 
   1069 extern int 
   1070 bcm_dpp_counter_lif_range_set(
   1071    int                  unit,
   1072    int                  counting_profile,
   1073    SOC_TMC_CNT_SRC_TYPE source,
   1074    int                  range_id,
   1075    int                  stif_counter_id,   
   1076    int                  is_double_entry,       
   1077    SOC_SAND_U32_RANGE   *range,
   1078    int engine_range_offset
   1079    );
   1080 extern int 
   1081 bcm_dpp_counter_lif_counting_priority_set (
   1082    int                                  unit, 
   1083    SOC_TMC_CNT_SRC_TYPE                 source,
   1084    int                                  command_id,
   1085    bcm_stat_counter_lif_stack_id_t      lif_stack_level, 
   1086    int                                  priority);
   1087 
   1088 extern int 
   1089 bcm_dpp_counter_lif_base_val_get(
   1090    int                  unit,
   1091    SOC_TMC_CNT_SRC_TYPE source,
   1092    int                  command_id,
   1093    int                  *base_val);
   1094 
   1095 extern int 
   1096 bcm_dpp_counter_lif_counting_priority_get (
   1097    int                                  unit, 
   1098    SOC_TMC_CNT_SRC_TYPE                 source,
   1099    int                                  command_id,
   1100    bcm_stat_counter_lif_stack_id_t      lif_stack_level, 
   1101    int                                  *priority);
   1102 
   1103 extern int
   1104 bcm_dpp_counter_cache_only_set(
   1105     int unit, 
   1106     uint8 cache_only);
   1107 
   1108 extern int
   1109 bcm_dpp_counter_cache_only_get(
   1110     int unit, 
   1111     uint8* cache_only);
   1112 
   1113 extern int
   1114 bcm_dpp_counter_config_set(
   1115         int unit,
   1116         soc_port_t crps_index,
   1117         int src_core,
   1118         SOC_TMC_CNT_SRC_TYPE src_type,
   1119         int command_id,
   1120         int command_base_offset,
   1121         SOC_TMC_CNT_MODE_EG_TYPE eg_type,
   1122         SOC_TMC_CNT_FORMAT format,
   1123         SOC_TMC_CNT_COUNTER_WE_BITMAP we_val,
   1124         SOC_TMC_CNT_CUSTOM_MODE_PARAMS* custom_mode_params,
   1125         SOC_TMC_CNT_Q_SET_SIZE q_set_size,
   1126         uint32 stag_lsb,
   1127         uint8 clear_cache,
   1128         uint32 multiple_sources,
   1129         int counter_profile_offset);
   1130 int
   1131 bcm_dpp_counter_config_clear(int unit, soc_port_t crps_index, uint8 clear_cache);
   1132 int
   1133 bcm_dpp_counter_config_get(
   1134         int unit,
   1135         soc_port_t crps_index,
   1136         uint8* enabled,
   1137         int* src_core,
   1138         SOC_TMC_CNT_SRC_TYPE* src_type,
   1139         int *command_id,
   1140         int *command_base_offset,
   1141         SOC_TMC_CNT_MODE_EG_TYPE* eg_type,
   1142         SOC_TMC_CNT_FORMAT* format,
   1143         SOC_TMC_CNT_COUNTER_WE_BITMAP* we_val,
   1144         SOC_TMC_CNT_CUSTOM_MODE_PARAMS* custom_mode_params,
   1145         SOC_TMC_CNT_Q_SET_SIZE* q_set_size,
   1146         uint32* stag_lsb,
   1147         int* counter_profile_offset);
   1148 
   1149 #ifdef BCM_WARM_BOOT_SUPPORT_SW_DUMP
   1150 extern int
   1151 _bcm_dpp_counters_sw_dump(int unit);
   1152 #endif /* BCM_WARM_BOOT_SUPPORT_SW_DUMP */
   1153          
   1154 int
   1155 bcm_dpp_counter_state_lock_take(int unit);
   1156 int
   1157 bcm_dpp_counter_state_lock_give(int unit);
   1158 int
   1159 bcm_dpp_counter_state_diag_unmask(int unit);
   1160 int 
   1161 bcm_dpp_counter_state_diag_mask(int unit);
   1162 
   1163 /*
   1164  *  Name
   1165  *    _bcm_dpp_modify_proc_and_index
   1166  *  Purpose
   1167  *    modify the proc and index before reading/writing the counter value from the SW state DB.
   1168  *  Arguments
   1169  *    IN _bcm_dpp_counter_state_t * unitData
   1170  *    OUT unsigned int * proc
   1171  *    OUT unsigned int * finalIndex - the modified index
   1172  *    uint8 subCount - is the function called after subCount was made or not.
   1173  *   Returns
   1174  *     bcm_error_t cast as int
   1175  *       BCM_E_NONE if success
   1176  *  Notes
   1177  *          FOR INGRESS_PP, groupSize=5, num_counters/groupSize is not devided. it cause that the last group in the engine is split between
   1178  *          the current engine and the next one (if defined). therefore, need to modify the index and the proc
   1179  */
   1180 int
   1181 _bcm_dpp_modify_proc_and_index(_bcm_dpp_counter_state_t * unitData, unsigned int *proc, unsigned int * finalIndex, uint8 subCount);
   1182 
   1183 /*
   1184  *  Name
   1185  *  _bcm_dpp_counter_engine_special_condition
   1186  *  Purpose
   1187  *      When engine map size is 3/5/6/7 counters should be splitted between two consequtive engines
   1188  *      Verifies that the next engine is with the correct configuration and can be used
   1189  *  Arguments
   1190  *      IN int unit
   1191  *      IN _bcm_dpp_counter_state_t *unitData = info for the unit
   1192  *      IN int proc = the counter processor on which to operate
   1193  *      OUT int specialCondition = if it meets the criteria - TRUE, if not - FALSE
   1194 */
   1195 int
   1196 _bcm_dpp_counter_engine_special_condition(int unit, _bcm_dpp_counter_state_t *unitData, int proc, int *specialCondition);
   1197 int 
   1198 bcm_dpp_counter_lif_local_profile_get(int unit, int counting_profile, uint8 *local_counting_profile_id);
   1199 
   1200 int 
   1201 bcm_dpp_counter_stat_id_create(
   1202     int unit,
   1203     bcm_gport_t counter_source_gport,
   1204     uint32 counter_source_id, 
   1205     bcm_stat_counter_source_type_t counter_source_type, 
   1206     int command_id, 
   1207     bcm_core_t core_id,
   1208     int *stat_id
   1209     );
   1210 
   1211 #endif /* ndef BCM_INT_DPP_COUNTERS_H */
   1212