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

tcb.h (4649B)


      1 /*
      2  * 
      3  *
      4  * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
      5  * 
      6  * Copyright 2007-2020 Broadcom Inc. All rights reserved.
      7  */
      8 
      9 #if defined (INCLUDE_TCB) && defined (BCM_TCB_SUPPORT)
     10 
     11 #include <soc/types.h>
     12 #include <bcm/cosq.h>
     13 #include <soc/defs.h>
     14 
     15 #define _BCM_TCB_MAX_NUM    16
     16 #define _BCM_TCB_PROFILE_MAX_NUM  16
     17 #define _BCM_TCB_RD_MAX_NUM 1024
     18 
     19 typedef int (*_bcm_cosq_tcb_hw_intr_cb)(int unit);
     20 typedef int (*_bcm_cosq_tcb_hw_intr_enable)(int unit, int enable);
     21 
     22 typedef struct _bcm_cosq_tcb_info_s {
     23     SHR_BITDCL    *profile_bmp;
     24     int profile_ref_count[_BCM_TCB_PROFILE_MAX_NUM];
     25 }_bcm_cosq_tcb_info_t, *_bcm_cosq_tcb_info_p;
     26 
     27 
     28 typedef struct _bcm_cosq_tcb_unit_ctrl_s {
     29     int                             tcb_num;
     30     int                             cell_bytes;
     31     int                             threshold_max;
     32     uint16                          tcb_enabled_bmp;
     33     uint16                          tcb_config_init_bmp;
     34     _bcm_cosq_tcb_info_p            tcb_info[_BCM_TCB_MAX_NUM];
     35     bcm_cosq_tcb_callback_t         tcb_evt_cb;
     36     void                            *tcb_evt_user_data;
     37 
     38     sal_mutex_t                     tcb_reslock;
     39 } _bcm_cosq_tcb_unit_ctrl_t;
     40 
     41 typedef struct _bcm_cosq_tcb_pipe_port_tab_s {
     42     SHR_BITDCL    ipipe_bmp;
     43     int ipipe_member[2];
     44     SHR_BITDCL    epipe_bmp;
     45     int epipe_member[2];
     46     char *ipipe_range;
     47     char *epipe_range;
     48     char *iport_range;
     49     char *eport_range;
     50     char *ucq_range;
     51 }_bcm_cosq_tcb_pipe_port_tab_t;
     52 
     53 extern _bcm_cosq_tcb_unit_ctrl_t *_bcm_cosq_tcb_unit_control[BCM_MAX_NUM_UNITS];
     54 
     55 #define TCB_UNIT_CONTROL(unit)        (_bcm_cosq_tcb_unit_control[unit])
     56 
     57 #define TCB_INIT(unit)    \
     58       if (TCB_UNIT_CONTROL(unit) == NULL) {\
     59           return BCM_E_INIT; }
     60 
     61 #define TCB_LOCK(unit)                                              \
     62         do {                                                        \
     63             if (TCB_UNIT_CONTROL(unit)->tcb_reslock) {              \
     64                 sal_mutex_take(TCB_UNIT_CONTROL(unit)->tcb_reslock, \
     65                                sal_mutex_FOREVER);                  \
     66             }                                                       \
     67         } while(0)
     68 #define TCB_UNLOCK(unit)                                            \
     69         do {                                                        \
     70             if (TCB_UNIT_CONTROL(unit)->tcb_reslock) {              \
     71                 sal_mutex_give(TCB_UNIT_CONTROL(unit)->tcb_reslock);\
     72             }                                                       \
     73         } while(0)
     74 
     75 #define TCB_ID_CHECK(tcb_id)  \
     76     if (tcb_id < 0 || tcb_id >= TCB_UNIT_CONTROL(unit)->tcb_num) { \
     77         return BCM_E_PARAM;  }
     78 
     79 #define _TCB_PIPE0    0x1
     80 #define _TCB_PIPE1    0x2
     81 #define _TCB_PIPE2    0x4
     82 #define _TCB_PIPE3    0x8
     83 
     84 #define _TCB_SGPP_TYPE_MASK    0x10000
     85 #define _TCB_SGPP_MASK         0xffff
     86 
     87 #define _SHR_TCB_TRACK_IADMN_DROP_SHIFT    0
     88 #define _SHR_TCB_TRACK_EADMN_DROP_SHIFT    1
     89 #define _SHR_TCB_TRACK_WRED_DROP_SHIFT     2
     90 #define _SHR_TCB_TRACK_CFAP_DROP_SHIFT     3
     91 
     92 #define _TCB_EVENT_DROP_REASON_IADMN_MASK   0x10
     93 #define _TCB_EVENT_DROP_REASON_EADMN_MASK   0x08
     94 #define _TCB_EVENT_DROP_REASON_WRED_MASK    0x04
     95 #define _TCB_EVENT_DROP_REASON_CFAP_MASK    0x02
     96 #define _TCB_EVENT_DROP_REASON_PURGE_MASK   0x01
     97 
     98 #define _TCB_IDLE_PHASE           0x0
     99 #define _TCB_PRE_TRIGGER_PHASE    0x1
    100 #define _TCB_POST_TRIGGER_PHASE   0x2
    101 #define _TCB_FROZEN_PHASE         0x3
    102 
    103 
    104 #define _TCB_SCOPE_UCQ        0x0
    105 #define _TCB_SCOPE_Q_GROUP    0x1
    106 #define _TCB_SCOPE_ING_PORT   0x2
    107 #define _TCB_SCOPE_EGR_PORT   0x3
    108 #define _TCB_SCOPE_ING_PIPE   0x4
    109 #define _TCB_SCOPE_EGR_PIPE   0x5
    110 
    111 #define _TCB_BUF_STATUS_WRAPPED   0x0
    112 #define _TCB_BUF_STATUS_PTR       0x1
    113 #define _TCB_BUF_STATUS_EVT_NUM   0x2
    114 #define _TCB_BUF_STATUS_0_USED    0x3
    115 
    116 #define _TCB_TRIGGER_MAX         0xf
    117 #define _TCB_CAP_NUM_MIN         2
    118 #define _TCB_CAP_NUM_MAX         1024
    119 #define _TCB_CAP_TIM_MAX         65535
    120 #define _TCB_PRE_SAMP_RATE_MAX   0x10
    121 #define _TCB_POST_SAMP_RATE_MAX  0x10
    122 
    123 #define _TCB_TRIGGER_DEFAULT         0xf
    124 #define _TCB_CAP_NUM_DEFAULT         304
    125 #define _TCB_CAP_TIM_DEFAULT         _TCB_CAP_TIM_MAX
    126 #define _TCB_CAP_TIM_FACTOR          10
    127 #define _TCB_CAP_TIM_MAX_DEVIATION  (_TCB_CAP_TIM_FACTOR - 1)
    128 #define _TCB_PRE_SAMP_RATE_DEFAULT   7
    129 #define _TCB_POST_SAMP_RATE_DEFAULT  15
    130 
    131 extern int _bcm_cosq_tcb_uc_queue_resolve(int unit, bcm_cosq_buffer_id_t buffer_id,
    132                                           int queue, bcm_gport_t *uc_gport);
    133 
    134 #endif /* INCLUDE_TCB && BCM_TCB_SUPPORT */