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

cosq_ingress.h (10531B)


      1 /*
      2  * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
      3  * 
      4  * Copyright 2007-2020 Broadcom Inc. All rights reserved.
      5  */
      6 /*
      7  * ! \file cosq_ingress.h
      8  * Reserved.$ 
      9  */
     10 
     11 #ifndef _DNX_COSQ_INGRESS_H_INCLUDED_
     12 /*
     13  * { 
     14  */
     15 #define _DNX_COSQ_INGRESS_H_INCLUDED_
     16 
     17 #ifndef BCM_DNX_SUPPORT
     18 #error "This file is for use by DNX (JR2) family only!"
     19 #endif
     20 
     21 #include <bcm/types.h>
     22 #include <bcm_int/dnx/algo/template_mngr/template_manager_types.h>
     23 
     24 /*
     25  * specifies the ingress counter type
     26  */
     27 typedef enum dnx_ingress_counter_type_e
     28 {
     29     DNX_INGRESS_COUTNER_TYPE_PACKET,
     30     DNX_INGRESS_COUTNER_TYPE_BYTE
     31 } dnx_ingress_counter_type_t;
     32 
     33 /**
     34  * \brief - Structure for collecting IRE counter info
     35  */
     36 typedef struct
     37 {
     38     /**
     39      * NOF NIF packets
     40      */
     41     int nif_pkt_ovf;
     42     uint64 nif_pkt_cnt;
     43     /**
     44      * NOF RCYH packets
     45      */
     46     int rcyh_pkt_ovf;
     47     uint64 rcyh_pkt_cnt;
     48     /**
     49      * NOF RCYL packets
     50      */
     51     int rcyl_pkt_ovf;
     52     uint64 rcyl_pkt_cnt;
     53     /**
     54      * NOF CPU packets
     55      */
     56     int cpu_pkt_ovf;
     57     uint64 cpu_pkt_cnt;
     58     /**
     59      * NOF OLP packets
     60      */
     61     int olp_pkt_ovf;
     62     uint64 olp_pkt_cnt;
     63     /**
     64      * NOF OAMP packets
     65      */
     66     int oamp_pkt_ovf;
     67     uint64 oamp_pkt_cnt;
     68     /**
     69      * NOF register interface packets
     70      */
     71     int reg_if_pkt_ovf;
     72     uint64 reg_if_pkt_cnt;
     73 } dnx_ingress_ire_counter_info_t;
     74 
     75 /**
     76  * \brief - Structure for collecting SQM counter info
     77  */
     78 typedef struct
     79 {
     80     /**
     81      * NOF en-queue packets
     82      */
     83     int enq_pkt_ovf;
     84     uint64 pkt_enq_cnt;
     85     /**
     86      * NOF de-queue packets
     87      */
     88     int deq_pkt_ovf;
     89     uint64 pkt_deq_cnt;
     90 } dnx_ingress_sqm_counter_info_t;
     91 
     92 /**
     93  * \brief - Structure for collecting IPT counter info
     94  */
     95 typedef struct
     96 {
     97     /**
     98      * NOF packets from CGM
     99      */
    100     int cgm_pkt_ovf;
    101     uint32 pkt_cgm_cnt;
    102     /**
    103      * NOF packet request from SPB
    104      */
    105     int spb_pkt_ovf;
    106     uint32 pkt_spb_cnt;
    107     /**
    108      * NOF packets with discard request from ITPP
    109      */
    110     int itpp_disc_pkt_ovf;
    111     uint32 pkt_itpp_disc_cnt;
    112 } dnx_ingress_ipt_counter_info_t;
    113 
    114 /**
    115  * \brief - Initialize dnx ingress_congestion module
    116  * 
    117  * \par DIRECT_INPUT:
    118  *   \param [in] unit -  Unit-ID 
    119  * \par DIRECT OUTPUT:
    120  *   shr_error_e 
    121  * \remark
    122  *   * None
    123  * \see
    124  *   * None
    125  */
    126 shr_error_e dnx_cosq_ingress_init(
    127     int unit);
    128 
    129 /**
    130  * \brief - Deinitialize  dnx ingress_congestion module
    131  * 
    132  * \par DIRECT_INPUT:
    133  *   \param [in] unit -  Unit-ID 
    134  * \par DIRECT OUTPUT:
    135  *   shr_error_e 
    136  * \remark
    137  *   * None
    138  * \see
    139  *   * None
    140  */
    141 shr_error_e dnx_cosq_ingress_deinit(
    142     int unit);
    143 
    144 /**
    145  * \brief - set provided port to have fixed/ not fixed priority
    146  * according to provided parameter
    147  * 
    148  * \par DIRECT_INPUT:
    149  *   \param [in] unit -  Unit-ID 
    150  * \par DIRECT_INPUT:
    151  *   \param [in] port -  port-ID 
    152  * \par DIRECT_INPUT:
    153  *   \param [in] is_fixed - the value of is_fixed property
    154  * \par DIRECT OUTPUT:
    155  *   shr_error_e 
    156  * \remark
    157  *   * None
    158  * \see
    159  *   * None
    160  */
    161 shr_error_e dnx_cosq_port_fixed_priority_set(
    162     int unit,
    163     bcm_port_t port,
    164     uint8 is_fixed);
    165 
    166 /**
    167  * \brief - get  is_fixed  property for provided port
    168  * according to provided parameter
    169  * 
    170  * \par DIRECT_INPUT:
    171  *   \param [in] unit -  Unit-ID 
    172  * \par DIRECT_INPUT:
    173  *   \param [in] port -  port-ID 
    174  * \par DIRECT_INPUT:
    175  *   \param [in] is_fixed - pointer to return the value of is_fixed property
    176  * \par DIRECT OUTPUT:
    177  *   shr_error_e 
    178  * \remark
    179  *   * None
    180  * \see
    181  *   * None
    182  */
    183 shr_error_e dnx_cosq_port_fixed_priority_get(
    184     int unit,
    185     bcm_port_t port,
    186     uint8 *is_fixed);
    187 
    188 /**
    189  * \brief - Callback to perform COSQ ingress part
    190  *  for port to be added
    191  * 
    192  * \par DIRECT_INPUT:
    193  *   \param [in] unit -  Unit-ID 
    194  *   
    195  * \par INDIRECT INPUT:
    196  *   * port which is in process of being added
    197  * \par DIRECT OUTPUT:
    198  *   shr_error_e 
    199  * \par INDIRECT OUTPUT
    200  *   *  HW configuration of ingress port
    201  * \remark
    202  *   * Invoked during bcm_dnx_port_add
    203  * \see
    204  *   * None
    205  */
    206 shr_error_e dnx_cosq_ingress_port_add_handle(
    207     int unit);
    208 
    209 /**
    210  * \brief - Callback to clean COSQ ingress data
    211  *  from port which is in process of removing
    212  * 
    213  * \par DIRECT_INPUT:
    214  *   \param [in] unit -  Unit-ID 
    215  *   
    216  * \par INDIRECT INPUT:
    217  *   * port which is in process of being removed
    218  * \par DIRECT OUTPUT:
    219  *   shr_error_e 
    220  * \par INDIRECT OUTPUT
    221  *   *  HW configuration of the port
    222  * \remark
    223  *   * Invoked during bcm_dnx_port_remove
    224  *   * Must be invoked before Ingress Port handles port removing
    225  * \see
    226  *   * None
    227  */
    228 shr_error_e dnx_cosq_ingress_port_remove_handle(
    229     int unit);
    230 
    231 /**
    232  * \brief - return (list of) input port for the specified local port as provided to CGM block.
    233  * Currently,
    234  *   CGM uses PP port as an input port, unless "overwrite pp_port by reassembly" is turned on.
    235  * Probably in future devices, CGM would use TM port as an input port
    236  *
    237  * \param [in] unit -  Unit-ID
    238  * \param [in] local_port -  local_port
    239  * \param [out] nof_entries - nof of entries in table cgm_in_port
    240  * \param [out] cgm_in_port - output array
    241  *
    242  * \return
    243  *   shr_error_e
    244  * \remark
    245  *   * None
    246  * \see
    247  *   * None
    248  */
    249 shr_error_e dnx_cosq_cgm_in_port_get(
    250     int unit,
    251     bcm_port_t local_port,
    252     int *nof_entries,
    253     uint32 cgm_in_port[]);
    254 
    255 /**
    256  * \brief - restore usage of dram by allowing traffic movement from sram to dram,
    257  *          this is only part of the sequence of restoring traffic to dram
    258  *
    259  * \param [in] unit - unit number
    260  *
    261  * \return
    262  *   shr_error_e
    263  *
    264  * \remark
    265  *   * None
    266  * \see
    267  *   * None
    268  */
    269 shr_error_e dnx_cosq_ingress_dram_bound_traffic_to_dram_restore(
    270     int unit);
    271 
    272 /**
    273  * \brief - stop usage of dram by blocking traffic movement from sram to dram,
    274  *          this is only part of the sequence of stopping traffic to dram
    275  *
    276  * \param [in] unit - unit number
    277  *
    278  * \return
    279  *   shr_error_e
    280  *
    281  * \remark
    282  *   * None
    283  * \see
    284  *   * None
    285  */
    286 shr_error_e dnx_cosq_ingress_dram_bound_traffic_to_dram_stop(
    287     int unit);
    288 
    289 /**
    290  * \brief - Function to get the IRE counter information
    291  *
    292  * \param [in] unit - unit number 
    293  * \param [in] core - core id
    294  * \param [out] counter_info - store counter information
    295  * 
    296  * \return int 
    297  */
    298 shr_error_e dnx_ingress_ire_counter_info_get(
    299     int unit,
    300     int core,
    301     dnx_ingress_ire_counter_info_t * counter_info);
    302 
    303 /**
    304  * \brief - Function to get the SQM counter information
    305  *
    306  * \param [in] unit - unit number 
    307  * \param [in] core - core id
    308  * \param [out] counter_info - store counter information
    309  * 
    310  * \return int 
    311  */
    312 shr_error_e dnx_ingress_sqm_counter_info_get(
    313     int unit,
    314     int core,
    315     dnx_ingress_sqm_counter_info_t * counter_info);
    316 
    317 /**
    318  * \brief - Function to get the IPT counter information
    319  *
    320  * \param [in] unit - unit number 
    321  * \param [in] core - core id
    322  * \param [out] counter_info - store counter information
    323  * 
    324  * \return int 
    325  */
    326 shr_error_e dnx_ingress_ipt_counter_info_get(
    327     int unit,
    328     int core,
    329     dnx_ingress_ipt_counter_info_t * counter_info);
    330 
    331 /**
    332  * \brief Function to create a VSQ gport from vsq index and vsq 
    333  *        type.
    334  * 
    335  * \param unit 
    336  * \param core 
    337  * \param vsq_group 
    338  * \param vsq_group_idx 
    339  * \param vsq_gport 
    340  * 
    341  * \return int 
    342  */
    343 int dnx_ingress_congestion_vsq_gport_get(
    344     int unit,
    345     int core,
    346     int vsq_group,
    347     int vsq_group_idx,
    348     bcm_gport_t * vsq_gport);
    349 
    350 /**
    351  * 
    352  * \brief - Function to configure the device overall ingress 
    353  *        receive rate. The rate is given in Mega packets per
    354  *        second
    355  * 
    356  * \param unit 
    357  * \param rate_mpps - the rate in mega packets per second
    358  * 
    359  * \return int 
    360  */
    361 int dnx_cosq_ingress_receive_packet_rate_limit_set(
    362     int unit,
    363     int rate_mpps);
    364 
    365 /**
    366  * 
    367  * \brief - Function to get the device overall ingress 
    368  *        receive rate. The rate is given in Mega packets per
    369  *        second.
    370  * 
    371  * \param [in] unit 
    372  * \param [in] rate_mpps - the rate in mega packets per second
    373  * 
    374  * \return int 
    375  */
    376 
    377 int dnx_cosq_ingress_receive_packet_rate_limit_get(
    378     int unit,
    379     int *rate_mpps);
    380 
    381 /**
    382  * brief - callback function to print the template manager for VOQ compensation profile
    383  *
    384  * \param [in] unit - Relevant unit.
    385  * \param [in] data - data to print. here it is the VOQ Compensation per profile
    386  *
    387  * \retval shr_error_e -
    388  *   Error return value
    389  * \remark
    390  *   None
    391  * \see
    392  *   shr_error_e
    393  */
    394 void dnx_cosq_ingress_compensation_profile_print_cb(
    395     int unit,
    396     const void *data);
    397 
    398 /**
    399  * \brief - Function to set the guaranteed rate to one of the 
    400  *        ingress shapers
    401  * 
    402  * \param unit - unit
    403  * \param gport - gport of type
    404  *  BCM_COSQ_GPORT_IS_INGRESS_RECEIVE_RCY_GUARANTEED
    405  *  BCM_COSQ_GPORT_IS_INGRESS_RECEIVE_CPU_GUARANTEED
    406  * \param cosq - unused. Must be 0
    407  * \param kbits_sec_min - unused. Must be 0
    408  * \param kbits_sec_max - rate in Kbps
    409  * \param flags - unused. Must be 0
    410  * 
    411  * \return int 
    412  */
    413 int dnx_cosq_ingress_receive_bandwith_set(
    414     int unit,
    415     bcm_gport_t gport,
    416     bcm_cos_queue_t cosq,
    417     uint32 kbits_sec_min,
    418     uint32 kbits_sec_max,
    419     uint32 flags);
    420 
    421 /**
    422  * 
    423  * \brief - Function to retrieve the actual ingress shaper rate
    424  *  
    425  * \param unit - unit
    426  * \param gport - gport of type
    427  *  BCM_COSQ_GPORT_IS_INGRESS_RECEIVE_RCY_GUARANTEED
    428  *  BCM_COSQ_GPORT_IS_INGRESS_RECEIVE_CPU_GUARANTEED
    429  * \param cosq - unused. Must be 0
    430  * \param kbits_sec_min - ingress shaper rate min. Always 0.
    431  * \param kbits_sec_max - ingress shaper rate
    432  * \param flags 
    433  * 
    434  * \return int 
    435  */
    436 int dnx_cosq_ingress_receive_bandwith_get(
    437     int unit,
    438     bcm_gport_t gport,
    439     bcm_cos_queue_t cosq,
    440     uint32 *kbits_sec_min,
    441     uint32 *kbits_sec_max,
    442     uint32 *flags);
    443 
    444 /**
    445  * \brief - Function to calculate the best timer cycles and 
    446  *        grant size for the ingress shaper in order to reach as
    447  *        close as possible the passed rate. 
    448  *        Rate is in Mega bytes per second
    449  *
    450  * \param [in] unit - unit id.
    451  * \param [in] rate - desired rate
    452  * \param [in] max_nof_timer_cycles - maximal value of timer cycles
    453  * \param [in] max_grant_size_val   - maximal value of grant size
    454  * \param [out] best_grant_size   - result grant size
    455  * \param [out] best_timer_cycles - result timer cycles
    456  */
    457 shr_error_e dnx_cosq_ingress_receive_shaper_grant_size_and_timer_cycles_calc(
    458     int unit,
    459     uint32 rate,
    460     uint32 max_nof_timer_cycles,
    461     uint32 max_grant_size_val,
    462     uint32 *best_grant_size,
    463     uint32 *best_timer_cycles);
    464 
    465 #endif /** _DNX_COSQ_INGRESS_H_INCLUDED_ */