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

mib_stat.h (15521B)


      1 /** \file bcm_int/dnx/stat/mib/mib_stat.h
      2  * 
      3  * Internal DNX STAT MIB 
      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_MIB_STAT_INCLUDED__
     11 /*
     12  * { 
     13  */
     14 #define _DNX_MIB_STAT_INCLUDED__
     15 
     16 #ifndef BCM_DNX_SUPPORT
     17 #error "This file is for use by DNX (JR2) family only!"
     18 #endif
     19 
     20 /*
     21  * MACROs
     22  * {
     23  */
     24 /**
     25  * \brief -
     26  * Maximal amount of HW counters (either for subtraction or addition operation) that are needed to calculate a single bcm counter.
     27  */
     28 #define DNX_MIB_MAX_COUNTER_BUNDLE 4
     29 
     30 /*
     31  * }
     32  */
     33 
     34 /*
     35  * Typedefs
     36  * {
     37  */
     38 typedef enum dnx_mib_counter
     39 {
     40     /** fabric counters*/
     41     dnx_mib_counter_tx_control_cells,
     42     dnx_mib_counter_tx_data_cells,
     43     dnx_mib_counter_tx_data_bytes,
     44     dnx_mib_counter_rx_crc_errors_data_cells,
     45     dnx_mib_counter_rx_crc_errors_control_cells_nonbypass,
     46     dnx_mib_counter_rx_crc_errors_control_cells_bypass,
     47     dnx_mib_counter_rx_fec_correctable_error,
     48     dnx_mib_counter_rx_control_cells,
     49     dnx_mib_counter_rx_data_cells,
     50     dnx_mib_counter_rx_data_bytes,
     51     dnx_mib_counter_rx_dropped_retransmitted_control,
     52     dnx_mib_counter_tx_asyn_fifo_rate,
     53     dnx_mib_counter_rx_asyn_fifo_rate,
     54     dnx_mib_counter_rx_lfec_fec_uncorrrectable_errors,
     55     dnx_mib_counter_rx_llfc_primary_pipe,
     56     dnx_mib_counter_rx_llfc_second_pipe,
     57     dnx_mib_counter_rx_llfc_third_pipe,
     58     dnx_mib_counter_rx_kpcs_errors,
     59     dnx_mib_counter_rx_kpcs_bypass_errors,
     60     dnx_mib_counter_rx_rs_fec_bit_error,
     61     dnx_mib_counter_rx_rs_fec_symbol_error_rate,
     62 
     63     /** interlaken counters */
     64     dnx_mib_counter_ilkn_rx_pkt,
     65     dnx_mib_counter_ilkn_tx_pkt,
     66     dnx_mib_counter_ilkn_rx_bytes,
     67     dnx_mib_counter_ilkn_tx_bytes,
     68     dnx_mib_counter_ilkn_rx_err_pkt,
     69     dnx_mib_counter_ilkn_tx_err_pkt,
     70 
     71     /** nif counters */
     72     dnx_mib_counter_nif_rx_fec_correctable_errors,
     73     dnx_mib_counter_nif_rx_fec_uncorrectable_errors,
     74     dnx_mib_counter_nif_rx_bip_errors,
     75     dnx_mib_counter_nif_rx_stats_drop_events_sch_low,
     76     dnx_mib_counter_nif_rx_stats_drop_events_sch_high,
     77     dnx_mib_counter_nif_rx_stats_drop_events_sch_tdm,
     78 
     79     /** nif ethernet counters */
     80     dnx_mib_counter_nif_eth_r64,
     81     dnx_mib_counter_nif_eth_r127,
     82     dnx_mib_counter_nif_eth_r255,
     83     dnx_mib_counter_nif_eth_r511,
     84     dnx_mib_counter_nif_eth_r1023,
     85     dnx_mib_counter_nif_eth_r1518,
     86     dnx_mib_counter_nif_eth_rmgv,
     87     dnx_mib_counter_nif_eth_r2047,
     88     dnx_mib_counter_nif_eth_r4095,
     89     dnx_mib_counter_nif_eth_r9216,
     90     dnx_mib_counter_nif_eth_r16383,
     91     dnx_mib_counter_nif_eth_rbca,
     92     dnx_mib_counter_nif_eth_rprog0,
     93     dnx_mib_counter_nif_eth_rprog1,
     94     dnx_mib_counter_nif_eth_rprog2,
     95     dnx_mib_counter_nif_eth_rprog3,
     96     dnx_mib_counter_nif_eth_rpkt,
     97     dnx_mib_counter_nif_eth_rpok,
     98     dnx_mib_counter_nif_eth_ruca,
     99     dnx_mib_counter_nif_eth_rmca,
    100     dnx_mib_counter_nif_eth_rxpf,
    101     dnx_mib_counter_nif_eth_rxpp,
    102     dnx_mib_counter_nif_eth_rxcf,
    103     dnx_mib_counter_nif_eth_rfcs,
    104     dnx_mib_counter_nif_eth_rerpkt,
    105     dnx_mib_counter_nif_eth_rflr,
    106     dnx_mib_counter_nif_eth_rjbr,
    107     dnx_mib_counter_nif_eth_rmtue,
    108     dnx_mib_counter_nif_eth_rovr,
    109     dnx_mib_counter_nif_eth_rvln,
    110     dnx_mib_counter_nif_eth_rdvln,
    111     dnx_mib_counter_nif_eth_rxuo,
    112     dnx_mib_counter_nif_eth_rxuda,
    113     dnx_mib_counter_nif_eth_rxwsa,
    114     dnx_mib_counter_nif_eth_rprm,
    115     dnx_mib_counter_nif_eth_rpfc0,
    116     dnx_mib_counter_nif_eth_rpfcoff0,
    117     dnx_mib_counter_nif_eth_rpfc1,
    118     dnx_mib_counter_nif_eth_rpfcoff1,
    119     dnx_mib_counter_nif_eth_rpfc2,
    120     dnx_mib_counter_nif_eth_rpfcoff2,
    121     dnx_mib_counter_nif_eth_rpfc3,
    122     dnx_mib_counter_nif_eth_rpfcoff3,
    123     dnx_mib_counter_nif_eth_rpfc4,
    124     dnx_mib_counter_nif_eth_rpfcoff4,
    125     dnx_mib_counter_nif_eth_rpfc5,
    126     dnx_mib_counter_nif_eth_rpfcoff5,
    127     dnx_mib_counter_nif_eth_rpfc6,
    128     dnx_mib_counter_nif_eth_rpfcoff6,
    129     dnx_mib_counter_nif_eth_rpfc7,
    130     dnx_mib_counter_nif_eth_rpfcoff7,
    131     dnx_mib_counter_nif_eth_rund,
    132     dnx_mib_counter_nif_eth_rfrg,
    133     dnx_mib_counter_nif_eth_rrpkt,
    134     dnx_mib_counter_nif_eth_t64,
    135     dnx_mib_counter_nif_eth_t127,
    136     dnx_mib_counter_nif_eth_t255,
    137     dnx_mib_counter_nif_eth_t511,
    138     dnx_mib_counter_nif_eth_t1023,
    139     dnx_mib_counter_nif_eth_t1518,
    140     dnx_mib_counter_nif_eth_tmgv,
    141     dnx_mib_counter_nif_eth_t2047,
    142     dnx_mib_counter_nif_eth_t4095,
    143     dnx_mib_counter_nif_eth_t9216,
    144     dnx_mib_counter_nif_eth_t16383,
    145     dnx_mib_counter_nif_eth_tbca,
    146     dnx_mib_counter_nif_eth_tpfc0,
    147     dnx_mib_counter_nif_eth_tpfcoff0,
    148     dnx_mib_counter_nif_eth_tpfc1,
    149     dnx_mib_counter_nif_eth_tpfcoff1,
    150     dnx_mib_counter_nif_eth_tpfc2,
    151     dnx_mib_counter_nif_eth_tpfcoff2,
    152     dnx_mib_counter_nif_eth_tpfc3,
    153     dnx_mib_counter_nif_eth_tpfcoff3,
    154     dnx_mib_counter_nif_eth_tpfc4,
    155     dnx_mib_counter_nif_eth_tpfcoff4,
    156     dnx_mib_counter_nif_eth_tpfc5,
    157     dnx_mib_counter_nif_eth_tpfcoff5,
    158     dnx_mib_counter_nif_eth_tpfc6,
    159     dnx_mib_counter_nif_eth_tpfcoff6,
    160     dnx_mib_counter_nif_eth_tpfc7,
    161     dnx_mib_counter_nif_eth_tpfcoff7,
    162     dnx_mib_counter_nif_eth_tpkt,
    163     dnx_mib_counter_nif_eth_tpok,
    164     dnx_mib_counter_nif_eth_tuca,
    165     dnx_mib_counter_nif_eth_tufl,
    166     dnx_mib_counter_nif_eth_tmca,
    167     dnx_mib_counter_nif_eth_txpf,
    168     dnx_mib_counter_nif_eth_txpp,
    169     dnx_mib_counter_nif_eth_txcf,
    170     dnx_mib_counter_nif_eth_tfcs,
    171     dnx_mib_counter_nif_eth_terr,
    172     dnx_mib_counter_nif_eth_tovr,
    173     dnx_mib_counter_nif_eth_tjbr,
    174     dnx_mib_counter_nif_eth_trpkt,
    175     dnx_mib_counter_nif_eth_tfrg,
    176     dnx_mib_counter_nif_eth_tvln,
    177     dnx_mib_counter_nif_eth_tdvln,
    178     dnx_mib_counter_nif_eth_rbyt,
    179     dnx_mib_counter_nif_eth_rrbyt,
    180     dnx_mib_counter_nif_eth_tbyt,
    181 
    182     /** nif CLU counters */
    183     dnx_mib_counter_nif_eth_rverify,
    184     dnx_mib_counter_nif_eth_rreply,
    185     dnx_mib_counter_nif_eth_rmcrc,
    186     dnx_mib_counter_nif_eth_rtrfu,
    187     dnx_mib_counter_nif_eth_rschcrc,
    188     dnx_mib_counter_nif_eth_rx_eee_lpi_event,
    189     dnx_mib_counter_nif_eth_rx_eee_lpi_duration,
    190     dnx_mib_counter_nif_eth_rx_llfc_phy,
    191     dnx_mib_counter_nif_eth_rx_llfc_log,
    192     dnx_mib_counter_nif_eth_rx_llfc_crc,
    193     dnx_mib_counter_nif_eth_rx_hcfc,
    194     dnx_mib_counter_nif_eth_rx_hcfc_crc,
    195     dnx_mib_counter_nif_eth_tverify,
    196     dnx_mib_counter_nif_eth_treply,
    197     dnx_mib_counter_nif_eth_tscl,
    198     dnx_mib_counter_nif_eth_tmcl,
    199     dnx_mib_counter_nif_eth_tlcl,
    200     dnx_mib_counter_nif_eth_txcl,
    201     dnx_mib_counter_nif_eth_tx_eee_lpi_event,
    202     dnx_mib_counter_nif_eth_tx_eee_lpi_duration,
    203     dnx_mib_counter_nif_eth_tx_llfc_log,
    204     dnx_mib_counter_nif_eth_tx_hcfc,
    205     dnx_mib_counter_nif_eth_tncl,
    206     dnx_mib_counter_nif_eth_xthol,
    207     dnx_mib_counter_nif_eth_tspare0,
    208     dnx_mib_counter_nif_eth_tspare1,
    209     dnx_mib_counter_nif_eth_tspare2,
    210     dnx_mib_counter_nif_eth_tspare3,
    211 
    212     /** Must be last */
    213     dnx_mib_counter_nof
    214 } dnx_mib_counter_t;
    215 
    216 /*
    217  * }
    218  */
    219 
    220 /*
    221  * Functions prototypes
    222  * {
    223  */
    224 
    225 /**
    226 * \brief
    227 *   Get the specified statistics by counter_idx
    228 * \param [in] unit - unit id
    229 * \param [in] port - logic port
    230 * \param [in] type - stat type
    231 * \param [in] counter_idx - counter index
    232 * \param [out] value - counter value
    233 * \return
    234 *   shr_error_e - Error Type
    235 * \remark
    236 *   * None
    237 * \see
    238 *   * None
    239 */
    240 shr_error_e dnx_stat_get_by_counter_idx(
    241     int unit,
    242     bcm_port_t port,
    243     bcm_stat_val_t type,
    244     int counter_idx,
    245     uint64 *value);
    246 
    247 /**
    248 * \brief
    249 *   initialize dnx stat mib module
    250 * \param [in] unit - unit id
    251 * \return
    252 *   shr_error_e - Error Type
    253 * \remark
    254 *   * None
    255 * \see
    256 *   * None
    257 */
    258 shr_error_e dnx_mib_init(
    259     int unit);
    260 
    261 /**
    262 * \brief
    263 *   deinitialize dnx mib module
    264 * \param [in] unit - unit id
    265 * \return
    266 *   shr_error_e - Error Type
    267 * \remark
    268 *   * None
    269 * \see
    270 *   * None
    271 */
    272 shr_error_e dnx_mib_deinit(
    273     int unit);
    274 
    275 /**
    276  * \brief - Configure counter for the port addition
    277  *
    278  * \param [in] unit - Relevant unit
    279  *
    280  * \return
    281  *   shr_error_e
    282  *
    283  * \remark
    284  *   * None
    285  * \see
    286  *   * None
    287  */
    288 shr_error_e dnx_counter_port_add(
    289     int unit);
    290 
    291 /**
    292  * \brief - Configure counter for the port removal
    293  *
    294  * \param [in] unit - Relevant unit
    295  *
    296  * \return
    297  *   shr_error_e
    298  *
    299  * \remark
    300  *   * None
    301  * \see
    302  *   * None
    303  */
    304 shr_error_e dnx_counter_port_remove(
    305     int unit);
    306 
    307 /**
    308 * \brief
    309 *   initialize mib stat fabric by fmac instance
    310 * \param [in] unit - unit id
    311 * \param [in] fsrd_idx - fsrd instance
    312 * \return
    313 *   shr_error_e - Error Type
    314 * \remark
    315 *   * None
    316 * \see
    317 *   * None
    318 */
    319 shr_error_e mib_stat_fabric_fsrd_init(
    320     int unit,
    321     int fsrd_idx);
    322 
    323 /**
    324 * \brief
    325 *   start counter thread
    326 * \param [in] unit - unit id
    327 * \return
    328 *   shr_error_e - Error Type
    329 * \remark
    330 *   * None
    331 * \see
    332 *   * None
    333 */
    334 shr_error_e dnx_init_mib_thread_start(
    335     int unit);
    336 
    337 /**
    338 * \brief
    339 *   stop counter thread
    340 * \param [in] unit - unit id
    341 * \return
    342 *   shr_error_e - Error Type
    343 * \remark
    344 *   * None
    345 * \see
    346 *   * None
    347 */
    348 shr_error_e dnx_init_mib_thread_stop(
    349     int unit);
    350 
    351 /**
    352 * \brief
    353 *   Callback pointer to obtain list of counters (addition and subtraction) from bcm counter type
    354 * \param [in] unit - unit id
    355 * \param [in] port - logical port
    356 * \param [in] type - bcm counter type \see bcm_stat_val_t
    357 * \param [in] max_nof_counters_to_add - maximal counters_to_add array size
    358 * \param [in] max_nof_counters_subtract - maximal counters_to_subtract array size
    359 * \param [out] nof_counters_to_add - actual counters_to_add array size
    360 * \param [out] counters_to_add - counters to add
    361 * \param [out] nof_counters_to_subtract - actual counters_to_subtract array size
    362 * \param [out] counters_to_subtract - counters to subtract
    363 * \return
    364 *   shr_error_e - Error Type
    365 * \remark
    366 *   * This callback is only required for special cases where regular dnx data mapping is not enough.
    367 * \see
    368 *   * None
    369 */
    370 typedef shr_error_e(
    371     *dnx_mib_counters_map_get_cb_f) (
    372     int unit,
    373     bcm_port_t port,
    374     bcm_stat_val_t type,
    375     int max_nof_counters_to_add,
    376     int max_nof_counters_subtract,
    377     int *nof_counters_to_add,
    378     dnx_mib_counter_t * counters_to_add,
    379     int *nof_counters_to_subtract,
    380     dnx_mib_counter_t * counters_to_subtract);
    381 
    382 /**
    383 * \brief - general cb for getting a list of hw mib counters given a bcm counter type. \see dnx_mib_counters_to_get_cb_f.
    384 */
    385 shr_error_e dnx_mib_counters_map_get_cb(
    386     int unit,
    387     bcm_port_t port,
    388     bcm_stat_val_t type,
    389     int max_nof_counters_to_add,
    390     int max_nof_counters_subtract,
    391     int *nof_counters_to_add,
    392     dnx_mib_counter_t * counters_to_add,
    393     int *nof_counters_to_subtract,
    394     dnx_mib_counter_t * counters_to_subtract);
    395 
    396 /**
    397 * \brief - cb for getting an empty list of hw mib counters given a bcm counter type. \see dnx_mib_counters_to_get_cb_f.
    398 * This callback is used to not fail bcm_stat_get API for bcm types which are legal for other ports than the given port.
    399 * For the given port type instead of failing we just return a counter value of 0.
    400 */
    401 shr_error_e dnx_mib_counters_map_get_dummy_cb(
    402     int unit,
    403     bcm_port_t port,
    404     bcm_stat_val_t type,
    405     int max_nof_counters_to_add,
    406     int max_nof_counters_subtract,
    407     int *nof_counters_to_add,
    408     dnx_mib_counter_t * counters_to_add,
    409     int *nof_counters_to_subtract,
    410     dnx_mib_counter_t * counters_to_subtract);
    411 
    412 /**
    413  * \brief - DNX callback to get the length of MIB counters.
    414  * \remark - Currently it's assumed that counter length is common among diferent counter_set types.
    415  *
    416  * \see soc_get_counter_length_f.
    417  */
    418 int dnx_mib_counter_length_get(
    419     int unit,
    420     int counter_id,
    421     int *length);
    422 
    423 /**
    424  * \brief - DNX callback to read fmac MIB counters. \see soc_get_counter_f.
    425  */
    426 int dnx_mib_fmac_counter_get(
    427     int unit,
    428     int counter_id,
    429     int port,
    430     uint64 *val,
    431     uint32 *clear_on_read);
    432 
    433 /**
    434  * \brief - DNX callback to clear fmac MIB counters. \see soc_clear_counter_f.
    435  */
    436 int dnx_mib_fmac_counter_clear(
    437     int unit,
    438     int counter_id,
    439     int port);
    440 
    441 /**
    442  * \brief - DNX callback to read NIF (both ETH and ILKN) MIB counters. \see soc_get_counter_f.
    443  */
    444 int dnx_mib_nif_counter_get(
    445     int unit,
    446     int counter_id,
    447     int port,
    448     uint64 *val,
    449     uint32 *clear_on_read);
    450 
    451 /**
    452  * \brief - DNX callback dnx_mib_counter_tto clear NIF MIB (both ETH and ILKN) counters. \see soc_clear_counter_f.
    453  */
    454 int dnx_mib_nif_counter_clear(
    455     int unit,
    456     int counter_id,
    457     int port);
    458 
    459 /**
    460  * \brief - DNX callback to read ILKN MIB counters. \see soc_get_counter_f.
    461  */
    462 int dnx_mib_ilkn_counter_get(
    463     int unit,
    464     int counter_id,
    465     int port,
    466     uint64 *val,
    467     uint32 *clear_on_read);
    468 
    469 /**
    470  * \brief - DNX callback to clear ILKN MIB counters. \see soc_clear_counter_f.
    471  */
    472 int dnx_mib_ilkn_counter_clear(
    473     int unit,
    474     int counter_id,
    475     int port);
    476 
    477 /**
    478  * \brief - DNX callback to read NIF ETH MIB counters. \see soc_get_counter_f.
    479  */
    480 int dnx_mib_nif_eth_counter_get(
    481     int unit,
    482     int counter_id,
    483     int port,
    484     uint64 *val,
    485     uint32 *clear_on_read);
    486 
    487 /**
    488  * \brief - DNX callback to clear NIF ETH MIB counters. \see soc_clear_counter_f.
    489  */
    490 int dnx_mib_nif_eth_counter_clear(
    491     int unit,
    492     int counter_id,
    493     int port);
    494 
    495 /**
    496  * \brief - DNX callback to read flexe MAC MIB counters. \see soc_get_counter_f.
    497  */
    498 int dnx_mib_flexe_mac_counter_get(
    499     int unit,
    500     int counter_id,
    501     int port,
    502     uint64 *val,
    503     uint32 *clear_on_read);
    504 
    505 /**
    506  * \brief - DNX callback to clear flexe MAC ETH MIB counters. \see soc_clear_counter_f.
    507  */
    508 int dnx_mib_flexe_mac_counter_clear(
    509     int unit,
    510     int counter_id,
    511     int port);
    512 
    513 /**
    514  * \brief -
    515  *   Indication whether the given counter is enabled for the given port.
    516  *   This function is used to filter coutners per port.
    517  *
    518  * \param [in] unit - unit id
    519  * \param [in] port - logical port
    520  * \param [in] index - index to controlled counter array
    521  * \param [out] enable - Indication whether the counter is enabled
    522  * \param [out] printable - Indication whether the counter is printable
    523  * \return
    524  *   shr_error_e - Error Type
    525  * \remark
    526  *   None
    527  * \see
    528  *   * None
    529  */
    530 shr_error_e dnx_mib_counter_enable_get(
    531     int unit,
    532     bcm_port_t port,
    533     int index,
    534     int *enable,
    535     int *printable);
    536 
    537 /**
    538  * \brief - DNX callback to get MIB counters. \see soc_get_counter_f.
    539  */
    540 int dnx_mib_counter_get(
    541     int unit,
    542     int counter_id,
    543     int port,
    544     uint64 *val,
    545     uint32 *clear_on_read);
    546 
    547 /**
    548  * \brief - DNX callback to clear MIB counters. \see soc_clear_counter_f.
    549  */
    550 int dnx_mib_counter_clear(
    551     int unit,
    552     int counter_id,
    553     int port);
    554 
    555 /**
    556 * \brief
    557 *   map bcm stat type and port to a set of controlled hw counters
    558 * \param [in] unit - unit id
    559 * \param [in] port - logical port
    560 * \param [in] type - bcm stat type \see bcm_stat_val_t
    561 * \param [in] max_array_size - maximal array size
    562 * \param [out] add_counters - list of controlled counters to add
    563 * \param [out] add_array_size - number of controlled counters to add
    564 * \param [out] sub_counters - list of controlled counters to subtract
    565 * \param [out] sub_array_size - number of controlled counters to subtract
    566 * \return
    567 *   shr_error_e - Error Type
    568 * \remark
    569 *   Counters list can be extract either directly from dnx data or from a callback provided by dnx data
    570 * \see
    571 *   * None
    572 */
    573 shr_error_e dnx_mib_mapping_stat_get(
    574     int unit,
    575     bcm_port_t port,
    576     bcm_stat_val_t type,
    577     int max_array_size,
    578     dnx_mib_counter_t * add_counters,
    579     int *add_array_size,
    580     dnx_mib_counter_t * sub_counters,
    581     int *sub_array_size);
    582 
    583 #endif/*_DNX_mib_MGMT_INCLUDED__*/