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

flowcnt.h (8416B)


      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:        flowcnt.h
      8  * Purpose:     
      9  */
     10 #ifndef _BCM_INT_FLOWCNT_H_
     11 #define _BCM_INT_FLOWCNT_H_
     12 
     13 #include <soc/drv.h>
     14 #include <soc/mem.h>
     15 #include <soc/profile_mem.h>
     16 #include <shared/idxres_afl.h>
     17 #include <bcm/error.h>
     18 
     19  
     20 /* ******************************************************************  */
     21 /*              COMPOSITION OF STAT COUNTER ID                         */
     22 /* ******************************************************************  */
     23 /*              mode_id =  Max 3 bits (Total Eight modes)              */
     24 /*              group_mode_id = Max 5 bits (Total 32)                  */
     25 /*              pool_id = 4 (Max Pool:16)                              */
     26 /*              a/c object_id=4 (Max Object:32)                        */
     27 /*              15 bits for base index                                 */
     28 /*              000    0-0000    0000   -00000     000-0000 0000-0000 */
     29 /*              Mode3b Group5b   Pool4b -A/cObj4b  base-index          */
     30 /* ****************************************************************  */
     31 #define _BCM_FLOWCNT_MODE_START_BIT     29
     32 #define _BCM_FLOWCNT_MODE_END_BIT       31
     33 #define _BCM_FLOWCNT_GROUP_START_BIT    24
     34 #define _BCM_FLOWCNT_GROUP_END_BIT      28
     35 #define _BCM_FLOWCNT_POOL_START_BIT     20
     36 #define _BCM_FLOWCNT_POOL_END_BIT       23
     37 #define _BCM_FLOWCNT_OBJECT_START_BIT   15
     38 #define _BCM_FLOWCNT_OBJECT_END_BIT     19
     39 #define _BCM_FLOWCNT_BASE_IDX_START_BIT  0
     40 #define _BCM_FLOWCNT_BASE_IDX_END_BIT   13
     41 
     42 #define _BCM_FLOWCNT_MODE_MASK \
     43     ((1<<(_BCM_FLOWCNT_MODE_END_BIT - _BCM_FLOWCNT_MODE_START_BIT+1))-1)
     44 #define _BCM_FLOWCNT_GROUP_MASK \
     45     ((1<<(_BCM_FLOWCNT_GROUP_END_BIT - _BCM_FLOWCNT_GROUP_START_BIT+1))-1)
     46 #define _BCM_FLOWCNT_POOL_MASK \
     47     ((1<<(_BCM_FLOWCNT_POOL_END_BIT - _BCM_FLOWCNT_POOL_START_BIT+1))-1)
     48 #define _BCM_FLOWCNT_OBJECT_MASK \
     49     ((1<<(_BCM_FLOWCNT_OBJECT_END_BIT - _BCM_FLOWCNT_OBJECT_START_BIT+1))-1)
     50 #define _BCM_FLOWCNT_BASE_IDX_MASK \
     51     ((1<<(_BCM_FLOWCNT_BASE_IDX_END_BIT-_BCM_FLOWCNT_BASE_IDX_START_BIT+1))-1)
     52 
     53 #define _BCM_STAT_FLOWCNT_MAX_PROFILES      (2)
     54 #define _BCM_STAT_FLOWCNT_MAX_PROFILE_GROUP (4)
     55 #define _BCM_STAT_FLOWCNT_MAX_SELECTORS     (16)
     56 
     57 typedef enum _bcm_flowcnt_stat_type_e {
     58     bcmFlowcntStatTypePacket = 1,
     59     bcmFlowcntStatTypeByte = 2    
     60 }_bcm_flowcnt_stat_type_t;
     61 
     62 typedef struct _bcm_flowcnt_group_mode_attr_selector_s {
     63     uint32 counter_offset;              /* Counter Offset */
     64     bcm_stat_group_mode_attr_t attr;    /* Attribute Selector */
     65     uint32 attr_value;                  /* Attribute Values */
     66 }_bcm_flowcnt_group_mode_attr_selector_t;
     67 
     68 typedef struct  _bcm_esw_flowcnt_profile_group_s {
     69     uint32        available;
     70     uint32        reference_count;
     71     uint32        total_counters;
     72     bcm_stat_group_mode_t    group_mode;    
     73     uint32        flags;    
     74     uint32        num_selectors;
     75     _bcm_flowcnt_group_mode_attr_selector_t *attr_selectors;
     76 }_bcm_esw_flowcnt_profile_group_t;
     77 
     78 typedef struct  _bcm_esw_flowcnt_profile_s {
     79     soc_profile_mem_t   profile_mem;
     80     soc_mem_t   profile_table;
     81     bcm_stat_group_mode_attr_t  attr;
     82     bcm_stat_flex_direction_t   direction;
     83     int num_entries; /* numbers of entries per group */
     84     int num_groups;  /* numbers of group per profile */
     85     _bcm_esw_flowcnt_profile_group_t *flowcnt_group;
     86 }_bcm_esw_flowcnt_profile_t;
     87 
     88 typedef struct  _bcm_esw_flowcnt_pool_stat_s {
     89     uint32  used_entries;
     90     uint32  attached_entries;
     91 }_bcm_esw_flowcnt_pool_stat_t;
     92 
     93 typedef struct _bcm_esw_flowcnt_pool_s {
     94     soc_mem_t   mem;
     95     shr_aidxres_list_handle_t flowcnt_aidxres_list_handle;    
     96     uint32 *flow_packet_counter;
     97     uint64 *flow_byte_counter;
     98     uint64 *flow_packet64_counter;    
     99     uint16 *flow_base_index_reference_count;
    100     uint16 *associate_profile_group;
    101     _bcm_flowcnt_stat_type_t  *flow_stat_type;
    102     bcm_stat_object_t *object;
    103     _bcm_esw_flowcnt_pool_stat_t  pool_stat;
    104 }_bcm_esw_flowcnt_pool_t;
    105 
    106 typedef struct  _bcm_flowcnt_control_s {
    107     int init;
    108     sal_mutex_t flowcnt_mutex;
    109     uint32 *default_attr_mode_id[_BCM_STAT_FLOWCNT_MAX_PROFILES];
    110     /* chip specific */
    111     _bcm_esw_flowcnt_profile_t *flowcnt_profile;
    112     int num_profiles;
    113     _bcm_esw_flowcnt_pool_t *flowcnt_pool;
    114     int num_pools;
    115     int counter_block; /* max counter offset value in power of two */
    116 }_bcm_esw_flowcnt_control_t;
    117 
    118 
    119 typedef enum _bcm_flowcnt_group_mode_e {
    120    bcmFlowcntProfileGroup1 = bcmStatGroupModeCount,
    121    bcmFlowcntProfileGroup2, 
    122    bcmFlowcntProfileGroup3, 
    123    bcmFlowcntProfileGroup4 
    124 }_bcm_flowcnt_group_mode_t;
    125 
    126 
    127 #ifdef BCM_WARM_BOOT_SUPPORT
    128 typedef struct _bcm_flowcnt_warmboot_info_s {
    129     uint32 default_attr_mode_id
    130            [_BCM_STAT_FLOWCNT_MAX_PROFILES][bcmStatGroupModeAttrMaxValue];
    131 }_bcm_flowcnt_warmboot_info_t;
    132 
    133 typedef struct _bcm_flowcnt_warmboot_group_info_s {
    134     uint32 group_mode;
    135     uint32 flags;
    136     uint32 total_counters;
    137     uint32 num_selectors;
    138     _bcm_flowcnt_group_mode_attr_selector_t attr_selectors
    139                                             [_BCM_STAT_FLOWCNT_MAX_SELECTORS];
    140 }_bcm_flowcnt_warmboot_group_info_t;
    141 #endif
    142     
    143 extern int _bcm_esw_flowcnt_init(int unit);
    144 extern int _bcm_esw_flowcnt_cleanup(int unit);
    145 extern int _bcm_esw_flowcnt_group_create(int unit, bcm_stat_object_t object,
    146                 bcm_stat_group_mode_t group_mode, uint32 *stat_counter_id,
    147                 uint32 *num_entries);
    148 extern int _bcm_esw_flowcnt_object_table_attach(int unit, 
    149                 bcm_stat_object_t object, soc_mem_t table, uint32 index,
    150                 int profile_group, uint32 base_idx, uint32 pool_idx,
    151                 void *entry_data1);
    152 extern void _bcm_esw_flowcnt_counter_id_get(uint32 stat_counter_id,
    153                 bcm_stat_group_mode_t *group, bcm_stat_object_t *object,
    154                 uint32 *profile_group, uint32 *pool_idx,
    155                 uint32 *base_idx);
    156 extern int _bcm_esw_flowcnt_counter_set(int unit, uint32 index,
    157                 soc_mem_t table, uint32 byte_flag, uint32 counter_index,
    158                 bcm_stat_value_t *value);
    159 extern int _bcm_esw_flowcnt_counter_get(int unit, int sync_mode,
    160                 uint32 index, soc_mem_t table, uint32 byte_flag,
    161                 uint32 counter_index, bcm_stat_value_t *value);              
    162 extern int _bcm_esw_flowcnt_group_mode_id_create(int unit, uint32 flags,
    163                 uint32 total_counters, uint32 num_selectors,
    164                 bcm_stat_group_mode_attr_selector_t *attr_selectors,
    165                 uint32 *mode_id);
    166 extern int _bcm_esw_flowcnt_group_mode_id_get(int unit, uint32 mode_id,
    167                 uint32 *flags, uint32 *total_counters,
    168                 uint32 num_selectors, 
    169                 bcm_stat_group_mode_attr_selector_t *attr_selectors,
    170                 uint32 *actual_num_selectors);
    171 extern int _bcm_esw_flowcnt_group_mode_id_destroy(int unit, uint32 mode_id);
    172 extern int _bcm_esw_flowcnt_custom_group_create(int unit, uint32 mode_id,
    173                 bcm_stat_object_t object, uint32 *stat_counter_id,
    174                 uint32 *num_entries);
    175 extern int _bcm_esw_flowcnt_object_table_detach(int unit, soc_mem_t ingress_table,
    176                 uint32 index);
    177 extern int _bcm_esw_flowcnt_stat_id_get(int unit, soc_mem_t mem, int index,
    178                 uint32 *stat_counter_id);
    179 extern int _bcm_esw_flowcnt_stat_type_validate(int unit, soc_mem_t table,
    180                 int index, _bcm_flowcnt_stat_type_t flow_stat_type);
    181 extern int _bcm_esw_flowcnt_group_destroy(int unit, uint32 stat_counter_id);
    182 extern int _bcm_esw_flowcnt_group_dump_info(int unit, int all_flag,
    183                 bcm_stat_object_t object, bcm_stat_group_mode_t group);
    184 extern int _bcm_esw_flowcnt_counter_raw_set(int unit,
    185                 uint32 stat_counter_id, uint32 byte_flag,
    186                 uint32 counter_index, bcm_stat_value_t *value);
    187 extern int _bcm_esw_flowcnt_counter_raw_get(int unit, int sync_mode,
    188                 uint32 stat_counter_id, uint32 byte_flag,
    189                 uint32 counter_index, bcm_stat_value_t *value);
    190 extern int _bcm_esw_flowcnt_total_counters_get(int unit,
    191                 uint32 stat_counter_id, uint32 *total_counters);
    192 
    193 #ifdef BCM_WARM_BOOT_SUPPORT
    194 extern int _bcm_esw_flowcnt_sync(int unit);
    195 #endif
    196 #endif  /* !_BCM_INT_FLOWCNT_H_ */