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

tsn_stat.h (10650B)


      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-2019 Broadcom Inc. All rights reserved.
      6  *
      7  * Purpose:
      8  * This file contains TSN stat definitions internal to the BCM library.
      9  */
     10 
     11 #ifndef __BCM_INT_TSN_STAT_H__
     12 #define __BCM_INT_TSN_STAT_H__
     13 
     14 #include <bcm/types.h>
     15 #include <bcm/tsn.h>
     16 
     17 #if defined(BCM_TSN_SUPPORT)
     18 /* TSN stat portcnt table data structure */
     19 typedef struct tsn_stat_portcnt_table_info_s {
     20     bcm_tsn_stat_t portcnt_stat;
     21     soc_mem_t portcnt_mem;
     22     soc_field_t portcnt_field;
     23 } tsn_stat_portcnt_table_info_t;
     24 
     25 /* Per-chip device info for TSN stat portcnt */
     26 typedef struct tsn_stat_portcnt_dev_info_s {
     27     const tsn_stat_portcnt_table_info_t *portcnt_table_info;
     28     const int num_stats;
     29 } tsn_stat_portcnt_dev_info_t;
     30 
     31 /* reserved group id */
     32 #define BCMI_TSN_FLOWCNT_GROUP_ID_RESERVED (0)
     33 
     34 /* action type for tsn stat counter */
     35 typedef enum bcmi_tsn_stat_counter_action_e {
     36     bcmiTsnStatCounterActionWrite = 0,
     37     bcmiTsnStatCounterActionRead = 1,
     38     bcmiTsnStatCounterActionReadSync = 2,
     39     bcmiTsnStatCounterActionCount = 3
     40 } bcmi_tsn_stat_counter_action_t;
     41 
     42 /* per-chip control drivers */
     43 typedef struct tsn_stat_flowcnt_dev_info_s {
     44     int (*tsn_stat_flowcnt_init) (int);
     45 #if defined(BCM_WARM_BOOT_SUPPORT)
     46     int (*tsn_stat_flowcnt_get_scache_size) (int, int *);
     47     int (*tsn_stat_flowcnt_sync) (int, uint8 *);
     48     int (*tsn_stat_flowcnt_reload_l1) (int);
     49     int (*tsn_stat_flowcnt_reload_l2) (int, uint8 *);
     50 #endif /* BCM_WARM_BOOT_SUPPORT */
     51     int (*tsn_stat_flowcnt_cleanup) (int);
     52     int (*tsn_stat_flowcnt_counter_sync_all) (int);
     53     int (*tsn_stat_flowcnt_counter_sync_stat) (int, bcm_tsn_stat_t);
     54     int (*tsn_stat_flowcnt_group_id_encode)(int, bcm_tsn_stat_group_type_t ,
     55                                             uint32, bcm_tsn_stat_group_t *);
     56     int (*tsn_stat_flowcnt_group_id_decode)(int, bcm_tsn_stat_group_t,
     57                                             bcm_tsn_stat_group_type_t *,
     58                                             uint32 *);
     59     int (*tsn_stat_flowcnt_group_refcnt_get)(int, bcm_tsn_stat_group_type_t,
     60                                              uint32, int *);
     61     int (*tsn_stat_flowcnt_group_enable_value_set)(int,
     62                                                    bcm_tsn_stat_group_type_t,
     63                                                    uint32, uint32);
     64     int (*tsn_stat_flowcnt_group_enable_value_get)(int,
     65                                                    bcm_tsn_stat_group_type_t,
     66                                                    uint32, uint32 *);
     67     int (*tsn_stat_flowcnt_group_enable_value_exist_check)
     68             (int, bcm_tsn_stat_group_type_t, uint32);
     69     int (*tsn_stat_flowcnt_group_enable_value_insert)(int,
     70                                                       bcm_tsn_stat_group_type_t,
     71                                                       uint32, uint32 *);
     72     int (*tsn_stat_flowcnt_group_enable_value_delete)(int,
     73                                                       bcm_tsn_stat_group_type_t,
     74                                                       uint32);
     75     int (*tsn_stat_flowcnt_group_enable_value_encode)(int,
     76                                                       bcm_tsn_stat_group_type_t,
     77                                                       bcm_tsn_stat_t *,
     78                                                       uint32, uint32 *);
     79     int (*tsn_stat_flowcnt_group_enable_value_decode)(int,
     80                                                       bcm_tsn_stat_group_type_t,
     81                                                       uint32, bcm_tsn_stat_t *,
     82                                                       uint32, int *);
     83     int (*tsn_stat_flowcnt_group_traverse)(int, bcm_tsn_stat_group_traverse_cb,
     84                                            void *);
     85     int (*tsn_stat_flowcnt_counter_access)(int, bcm_tsn_sr_flow_t,
     86                                            bcmi_tsn_stat_counter_action_t,
     87                                            uint32, bcm_tsn_stat_t *,
     88                                            uint64 *, uint64 *);
     89     int (*tsn_stat_flowcnt_counter_update)(int unit,
     90                                            soc_mem_t mem,
     91                                            int mem_idx,
     92                                            uint64 new_count);
     93     int (*tsn_stat_flowcnt_flow_set)(int, bcm_tsn_sr_flow_t,
     94                                      bcm_tsn_stat_group_type_t, uint32);
     95     int (*tsn_stat_flowcnt_flow_get)(int, bcm_tsn_sr_flow_t,
     96                                      bcm_tsn_stat_group_type_t, uint32 *);
     97     int (*tsn_stat_flowcnt_flow_get_fbmp)(int, bcm_tsn_stat_t,
     98                                           SHR_BITDCL*, uint32);
     99 } tsn_stat_flowcnt_dev_info_t;
    100 
    101 /*
    102  * Per-chip control drivers for TSN stat threshold
    103  */
    104 typedef struct tsn_stat_threshold_ctrl_info_s {
    105     int (*tsn_stat_threshold_ctrl_init)(int);
    106     int (*tsn_stat_threshold_ctrl_set)(
    107         int, bcm_tsn_stat_threshold_source_t, bcm_tsn_stat_t,
    108         bcm_tsn_stat_threshold_config_t *);
    109     int (*tsn_stat_threshold_ctrl_get)(
    110         int, bcm_tsn_stat_threshold_source_t, bcm_tsn_stat_t,
    111         bcm_tsn_stat_threshold_config_t *);
    112 } tsn_stat_threshold_ctrl_info_t;
    113 
    114 /* per-chip control drivers for TAF gate */
    115 typedef struct tsn_taf_gate_stat_dev_info_s {
    116     int (*tsn_taf_gate_stat_init)(int);
    117     int (*tsn_taf_gate_stat_cleanup)(int);
    118 } tsn_taf_gate_stat_dev_info_t;
    119 
    120 /*
    121  * Structure for TSN stat device specific info
    122  */
    123 typedef struct bcmi_esw_tsn_stat_dev_info_s {
    124     /* Per-chip TSN stat portcnt device info */
    125     const tsn_stat_portcnt_dev_info_t *tsn_stat_portcnt_dev_info;
    126     /* Per-chip TSN stat flowcnt device info */
    127     const tsn_stat_flowcnt_dev_info_t *tsn_stat_flowcnt_dev_info;
    128     /* Per-chip TSN stat threshold control drivers */
    129     const tsn_stat_threshold_ctrl_info_t *tsn_stat_threshold_ctrl_info;
    130 } bcmi_esw_tsn_stat_dev_info_t;
    131 
    132 /* TSN stat portcnt usage bitmap operations modes */
    133 typedef enum bcmi_tsn_stat_portcnt_used_operation_e {
    134     BCM_TSN_STAT_PORTCNT_USED_SET,
    135     BCM_TSN_STAT_PORTCNT_USED_CLEAR
    136 } bcmi_tsn_stat_portcnt_used_operation_t;
    137 
    138 /* Library-private functions exported from tsn_stat.c */
    139 #ifdef BCM_WARM_BOOT_SUPPORT
    140 extern int
    141 bcmi_esw_tsn_stat_portcnt_sync(int unit);
    142 extern int
    143 bcmi_esw_tsn_stat_portcnt_reload(int unit);
    144 extern int
    145 bcmi_esw_tsn_stat_flowcnt_sync(int unit);
    146 extern int
    147 bcmi_esw_tsn_stat_flowcnt_reload(int unit);
    148 extern int
    149 bcmi_esw_tsn_taf_sync(int unit);
    150 extern int
    151 bcmi_esw_tsn_taf_reload(int unit);
    152 #endif /* BCM_WARM_BOOT_SUPPORT */
    153 extern int
    154 bcmi_esw_tsn_stat_init(int unit);
    155 extern int
    156 bcmi_esw_tsn_stat_cleanup(int unit);
    157 extern int
    158 bcmi_esw_tsn_stat_portcnt_set(
    159     int unit,
    160     bcm_gport_t port,
    161     bcm_tsn_stat_t stat,
    162     uint64 val);
    163 extern int
    164 bcmi_esw_tsn_stat_portcnt_get(
    165     int unit,
    166     bcm_gport_t port,
    167     int sync_mode,
    168     bcm_tsn_stat_t stat,
    169     uint64 *val);
    170 extern int
    171 bcmi_esw_tsn_stat_portcnt_used_update(
    172     int unit,
    173     bcm_gport_t port,
    174     bcm_tsn_stat_t stat,
    175     bcmi_tsn_stat_portcnt_used_operation_t op);
    176 extern int
    177 bcmi_esw_tsn_stat_portcnt_stat_sync(int unit, bcm_tsn_stat_t stat);
    178 extern int
    179 bcmi_esw_tsn_stat_portcnt_hw_sw_get(
    180     int unit,
    181     bcm_tsn_stat_t stat,
    182     bcm_gport_t port,
    183     uint64 *hw_value,
    184     uint64 *sw_value);
    185 extern int
    186 bcmi_esw_tsn_stat_portcnt_hw_set(
    187     int unit,
    188     bcm_tsn_stat_t stat,
    189     bcm_gport_t port,
    190     uint64 hw_value);
    191 extern int
    192 bcmi_esw_tsn_stat_threshold_set(
    193     int unit,
    194     bcm_tsn_stat_threshold_source_t source,
    195     bcm_tsn_stat_t stat,
    196     bcm_tsn_stat_threshold_config_t *config);
    197 extern int
    198 bcmi_esw_tsn_stat_threshold_get(
    199     int unit,
    200     bcm_tsn_stat_threshold_source_t source,
    201     bcm_tsn_stat_t stat,
    202     bcm_tsn_stat_threshold_config_t *config);
    203 
    204 extern int
    205 bcmi_esw_tsn_stat_flowcnt_group_create(int unit,
    206                                        bcm_tsn_stat_group_type_t group_type,
    207                                        int count, bcm_tsn_stat_t *stat_arr,
    208                                        bcm_tsn_stat_group_t *stat_id);
    209 extern int
    210 bcmi_esw_tsn_stat_flowcnt_group_set(int unit, bcm_tsn_stat_group_t stat_id,
    211                                     int count, bcm_tsn_stat_t *stat_arr);
    212 extern int
    213 bcmi_esw_tsn_stat_flowcnt_group_get(int unit, bcm_tsn_stat_group_t stat_id,
    214                                     bcm_tsn_stat_group_type_t *ret_group_type,
    215                                     int max, bcm_tsn_stat_t *stat_arr,
    216                                     int *count);
    217 extern int
    218 bcmi_esw_tsn_stat_flowcnt_group_destroy(int unit, bcm_tsn_stat_group_t stat_id);
    219 extern int
    220 bcmi_esw_tsn_stat_flowcnt_group_traverse(int unit,
    221                                          bcm_tsn_stat_group_traverse_cb cb,
    222                                          void *user_data);
    223 extern int
    224 bcmi_esw_tsn_stat_flowcnt_flow_set(int unit, bcm_tsn_sr_flow_t flow_id,
    225                                    bcm_tsn_stat_group_type_t group_type,
    226                                    bcm_tsn_stat_group_t new_stat_id);
    227 extern int
    228 bcmi_esw_tsn_stat_flowcnt_flow_get(int unit, bcm_tsn_sr_flow_t flow_id,
    229                                    bcm_tsn_stat_group_type_t group_type,
    230                                    bcm_tsn_stat_group_t *stat_id);
    231 
    232 extern int
    233 bcmi_esw_tsn_stat_flowcnt_set(int unit, bcm_tsn_sr_flow_t flow_id,
    234                               uint32 arr_cnt,
    235                               bcm_tsn_stat_t *stat_type_arr,
    236                               uint64 *stat_value_arr);
    237 extern int
    238 bcmi_esw_tsn_stat_flowcnt_get(int unit, bcm_tsn_sr_flow_t flow_id,
    239                               int sync_mode, uint32 arr_cnt,
    240                               bcm_tsn_stat_t *stat_type_arr,
    241                               uint64 *stat_value_arr);
    242 extern int
    243 bcmi_esw_tsn_stat_flowcnt_hw_sw_get(int unit, bcm_tsn_stat_t stat,
    244                                     bcm_tsn_sr_flow_t flow_id,
    245                                     uint64 *hw_value, uint64 *sw_value);
    246 extern int
    247 bcmi_esw_tsn_stat_flowcnt_hw_set(int unit, bcm_tsn_stat_t stat,
    248                                  bcm_tsn_sr_flow_t flow_id,
    249                                  uint64 hw_value);
    250 extern int
    251 bcmi_esw_tsn_stat_flowcnt_fbmp_get(int unit, bcm_tsn_stat_t stat,
    252                                    SHR_BITDCL *fbmp, uint32 fbmp_size);
    253 extern int
    254 bcmi_esw_tsn_stat_flowcnt_stat_sync(int unit, bcm_tsn_stat_t stat);
    255 
    256 extern int
    257 bcmi_esw_tsn_stat_counter_update(
    258     int unit,
    259     soc_mem_t mem,
    260     int mem_idx,
    261     uint64 new_count);
    262 
    263 #endif /* BCM_TSN_SUPPORT */
    264 #endif /* __BCM_INT_TSN_STAT_H__ */
    265