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

mmu_config.h (13656B)


      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 
      8 
      9 #ifndef _SOC_MMU_CONFIG_H_
     10 #define _SOC_MMU_CONFIG_H_
     11 
     12 /*
     13  * general syntax: buf.object[id].attribute[.port]="string"
     14  * Some examples of "cell value" string type:
     15  *   1000b (b for byte)
     16  *   1000k (k for kilobyte)
     17  *   1000m (m for megabyte)
     18  *   1000c (c for cell)
     19  *
     20  * objects     attributes        string type and trident register for reference
     21  * ========================================================================
     22  * device
     23  *            headroom           cell value
     24  *
     25  * pool#                         # is pool id
     26  *            size               cell value or %
     27  *                               This size will affect both ingress and egress
     28  *                               pool size, it is recommended to use percentage
     29  *                               since the total pool size calculate for
     30  *                               ingress and egress are different.
     31  *            yellow_size        cell value or %
     32  *                               If the specified value is percentage, it is
     33  *                               the percentage of the value specified by the
     34  *                               size attribute
     35  *                               Use the same value for size, yellow_size, and
     36  *                               red_size or use 100% for yellow_size and
     37  *                               red_size to disable color aware.
     38  *            red_size           cell value or %
     39  *                               (see notes for yellow_size)
     40  *
     41  * port
     42  *            guarantee          cell value
     43  *            pool_limit         cell value
     44  *            pool_resume        cell value
     45  *            pkt_size           cell value
     46  *
     47  * prigroup#                     # is priority group
     48  *            guarantee          cell value
     49  *                               specify 0 to disable
     50  *            headroom           cell value
     51  *            device_headroom_enable boolean
     52  *            port_guarantee_enable boolean
     53  *            port_max_enable    boolean
     54  *            pool_scale         floating point number value between 1/64 and 8
     55  *                               Dynamic method will be enabled if this
     56  *                               attribute is specified.
     57  *            pool_limit         cell value
     58  *            pool_resume        cell value
     59  *            pool_floor         cell value
     60  *            flow_control_enable boolean
     61  *
     62  * queue#                        # is queue id
     63  * equeue#                       # is extended queue id
     64  * mqueue#                       # is multicast queue id
     65  *            guarantee          cell value
     66  *            pool_scale         floating point number value between 1/64 and 8
     67  *                               Dynamic method will be enabled if this
     68  *                               attribute is specified.
     69  *            pool_limit         cell value
     70  *                               Specify 0 to indicate disabling queue limit
     71  *                               and allow to use shared space.
     72  *            pool_resume        cell value
     73  *            yellow_limit       cell value for static or % for dynamic
     74  *                               Use the same value for pool_limit,
     75  *                               yellow_limit and red_limit to disable color
     76  *                               aware.
     77  *                               Use percentage (such as 12.5%, ... 100%) to
     78  *                               indicate dynamic color limit
     79  *            red_limit          cell value for static or % for dynamic
     80  *                               (see notes for yellow_limit)
     81  *            yellow_resume      cell value
     82  *            red_resume         cell value
     83  *
     84  * ===== mapping =====
     85  * general syntax: buf.map.from_object.to_object[.port]="string"
     86  * string is a command separated value list, use 0 if the value is missing
     87  * for example:
     88  *     "a,b,c" has same effect as "a,b,c,0,0,0"
     89  *     "a,,c" has same effect as "a,0,c"
     90  *
     91  * buf.map.pri.prigroup[.port]="a,b,c,..."
     92  *   a is priority group id for priority 0
     93  *   b is priority group id for priority 1
     94  *   ...
     95  *
     96  * buf.map.prigroup.pool[.port]="a,b,c,..."
     97  *   a is service pool id for priority group 0
     98  *   b is service pool id for priority group 1
     99  *   ...
    100  *
    101  * buf.map.queue.pool[.port]="a,b,c,..."
    102  * buf.map.mqueue.pool[.port]="a,b,c,..."
    103  *   a is service pool id for queue 0
    104  *   b is service pool id for queue 1
    105  *   ...
    106  */
    107 
    108 #define _MMU_CFG_BUF_DYNAMIC_FLAG        (0x80000000)
    109 #define _MMU_CFG_BUF_PERCENT_FLAG        (0x40000000)
    110 /*
    111 *                               Flag indicates use below encoding as the percentage of color limit to
    112 *                               green threshold in dynamic buffer mode:
    113 *                               0: 100% of green threshold
    114 *                               1: 12.5% of green threshold
    115 *                               2: 25% of green threshold
    116 *                               3: 37.5% of green threshold
    117 *                               4: 50% of green threshold
    118 *                               5: 67.5% of green threshold
    119 *                               6: 75% of green threshold
    120 *                               7: 87.5% of green threshold
    121 */
    122 #define _MMU_CFG_BUF_DYNAMIC_MAPPING_TYPE_1        (0x20000000)
    123 
    124 #ifdef BCM_KATANA2_SUPPORT
    125 #define SOC_MMU_CFG_SERVICE_POOL_MAX    4
    126 #define SOC_MMU_CFG_PORT_MAX            170
    127 #define SOC_MMU_CFG_PRI_GROUP_MAX       8
    128 #define SOC_MMU_CFG_INT_PRI_MAX         16
    129 #define SOC_MMU_CFG_QGROUP_MAX          256
    130 #define SOC_MMU_CFG_EQUEUE_MAX          4096 
    131 #define SOC_MMU_CFG_RQE_QUEUE_MAX       12
    132 #define SOC_MMU_CFG_XPE_MAX             4
    133 #else
    134 #define SOC_MMU_CFG_SERVICE_POOL_MAX    4
    135 #if defined(BCM_TOMAHAWK3_SUPPORT)
    136 #define SOC_MMU_CFG_PORT_MAX            160
    137 #else
    138 #define SOC_MMU_CFG_PORT_MAX            136
    139 #endif
    140 #define SOC_MMU_CFG_PRI_GROUP_MAX       8
    141 #define SOC_MMU_CFG_INT_PRI_MAX         16
    142 #define SOC_MMU_CFG_QGROUP_MAX          256
    143 #define SOC_MMU_CFG_EQUEUE_MAX          512
    144 #define SOC_MMU_CFG_RQE_QUEUE_MAX       11
    145 #define SOC_MMU_CFG_XPE_MAX             4
    146 #endif
    147 #if defined(BCM_TOMAHAWK3_SUPPORT)
    148 #define SOC_MMU_CFG_ITM_MAX             2
    149 #define SOC_MMU_CFG_NUM_PROFILES_MAX    8
    150 #define SOC_MMU_CFG_COS_MAX             12
    151 #endif
    152 
    153 #if defined(BCM_TOMAHAWK3_SUPPORT)
    154 typedef struct _soc_mmu_cfg_buf_mapping_profile_s
    155 {
    156      int inpri_to_prigroup_uc[SOC_MMU_CFG_INT_PRI_MAX];
    157      int inpri_to_prigroup_mc[SOC_MMU_CFG_INT_PRI_MAX];
    158      int prigroup_to_servicepool[SOC_MMU_CFG_PRI_GROUP_MAX];
    159      int prigroup_to_headroompool[SOC_MMU_CFG_PRI_GROUP_MAX];
    160      int pfcpri_to_prigroup[SOC_MMU_CFG_PRI_GROUP_MAX];
    161      int valid;
    162 } _soc_mmu_cfg_buf_mapping_profile_t;
    163 #endif 
    164 
    165 typedef struct _soc_mmu_cfg_buf_prigroup_s {
    166     int pool_idx; /* from mapping variable */
    167     int guarantee;
    168     int headroom;
    169     int user_delay;
    170     int switch_delay;
    171     int pkt_size;
    172     int device_headroom_enable;
    173     int port_guarantee_enable;
    174     int port_max_enable;
    175     int pool_scale;
    176     int pool_limit;
    177     int pool_resume;
    178     int pool_floor;
    179     int flow_control_enable;
    180 #if defined(BCM_TOMAHAWK3_SUPPORT)
    181     int lossless;
    182 #endif
    183 } _soc_mmu_cfg_buf_prigroup_t;
    184 
    185 typedef struct _soc_mmu_cfg_buf_qgroup_s
    186 {
    187     int guarantee;
    188 #if defined(BCM_TOMAHAWK3_SUPPORT)
    189     int guarantee_mc;
    190 #endif
    191     int discard_enable;
    192     int pool_scale;
    193     int pool_limit;
    194     int pool_resume;
    195     int yellow_limit;
    196     int red_limit;
    197     int yellow_resume;
    198     int red_resume;
    199 } _soc_mmu_cfg_buf_qgroup_t;
    200 
    201 typedef struct _soc_mmu_cfg_buf_queue_s
    202 {
    203     int numq;
    204     int pool_idx; /* from mapping variable */
    205     int guarantee;
    206     int discard_enable;
    207     int pool_scale;
    208     int pool_limit;
    209     int pool_resume;
    210     int color_discard_enable;
    211     int yellow_limit;
    212     int red_limit;
    213     int yellow_resume;
    214     int red_resume;
    215     int qgroup_id;
    216     int qgroup_min_enable;
    217     int mcq_entry_guarantee;
    218     int mcq_entry_reserved;
    219     int mcqe_limit;
    220     int pkt_guarantee;
    221     int pkt_pool_scale;
    222 } _soc_mmu_cfg_buf_queue_t;
    223 
    224 typedef struct _soc_mmu_cfg_buf_pool_s {
    225     int size;
    226     int yellow_size;
    227     int red_size;
    228     int total; /* calculated value (not from config variable) */
    229     int port_guarantee; /* calculated value (not from config variable) */
    230     int prigroup_guarantee; /* calculated value (not from config variable) */
    231     int prigroup_headroom; /* calculated value (not from config variable) */
    232     int queue_guarantee; /* calculated value (not from config variable) */
    233     int queue_group_guarantee;/* calculated value (not from config variable) */
    234     int rqe_guarantee; /* calculated value (not from config variable) */
    235     int asf_reserved; /* calculated value (not from config variable) */
    236     int mcq_entry_reserved;
    237     int total_mcq_entry;
    238     int total_rqe_entry;
    239 } _soc_mmu_cfg_buf_pool_t;
    240 
    241 typedef struct _soc_mmu_cfg_buf_port_pool_s {
    242     int guarantee;
    243     int pool_limit;
    244     int pool_resume;
    245 } _soc_mmu_cfg_buf_port_pool_t;
    246 
    247 typedef struct _soc_mmu_cfg_buf_port_s
    248 {
    249     int guarantee;
    250     int pool_limit;
    251     int pool_resume;
    252     int pkt_size;
    253 #if defined(BCM_TOMAHAWK3_SUPPORT)
    254     int pri_to_prigroup_profile_idx;
    255     int prigroup_profile_idx;
    256 #endif
    257     _soc_mmu_cfg_buf_prigroup_t prigroups[SOC_MMU_CFG_PRI_GROUP_MAX];
    258     _soc_mmu_cfg_buf_queue_t *queues;
    259     int pri_to_prigroup[SOC_MMU_CFG_INT_PRI_MAX]; /* from mapping variable */
    260     _soc_mmu_cfg_buf_port_pool_t pools[SOC_MMU_CFG_SERVICE_POOL_MAX];
    261 } _soc_mmu_cfg_buf_port_t;
    262 
    263 typedef struct _soc_mmu_cfg_buf_mcengine_queue_s {
    264     int pool_idx;
    265     int guarantee;
    266     int pool_scale;
    267     int pool_limit;
    268     int discard_enable;
    269     int yellow_limit;
    270     int red_limit;
    271     int ext_guarantee;
    272     int pkt_guarantee;
    273     int ext_pool_scale;
    274     int pkt_pool_scale;
    275 } _soc_mmu_cfg_buf_mcengine_queue_t;
    276 
    277 typedef struct soc_th_mmu_rsvd_buffer_s {
    278     int ing_rsvd_cells;
    279     int egr_rsvd_cells;
    280     int asf_rsvd_cells;
    281     int mcq_entry_rsvd;
    282 } _soc_mmu_rsvd_buffer_t;
    283 
    284 typedef struct _soc_mmu_cfg_buf_s
    285 {
    286     int headroom;
    287     _soc_mmu_rsvd_buffer_t rsvd_buffers[4];
    288     _soc_mmu_cfg_buf_pool_t pools[SOC_MMU_CFG_SERVICE_POOL_MAX];
    289 #if defined(BCM_TOMAHAWK3_SUPPORT)
    290     _soc_mmu_cfg_buf_pool_t pools_itm[SOC_MMU_CFG_ITM_MAX][SOC_MMU_CFG_SERVICE_POOL_MAX];
    291 #endif
    292     _soc_mmu_cfg_buf_pool_t pools_xpe[SOC_MMU_CFG_XPE_MAX][SOC_MMU_CFG_SERVICE_POOL_MAX];
    293     _soc_mmu_cfg_buf_port_t ports[SOC_MMU_CFG_PORT_MAX];
    294     _soc_mmu_cfg_buf_qgroup_t qgroups[SOC_MMU_CFG_QGROUP_MAX];
    295     _soc_mmu_cfg_buf_mcengine_queue_t rqe_queues[SOC_MMU_CFG_RQE_QUEUE_MAX];
    296     _soc_mmu_cfg_buf_queue_t  equeues[SOC_MMU_CFG_EQUEUE_MAX];
    297 #if defined(BCM_TOMAHAWK3_SUPPORT)
    298     _soc_mmu_cfg_buf_mapping_profile_t mapprofiles[SOC_MMU_CFG_NUM_PROFILES_MAX];
    299 #endif
    300     /* equeues must be the last member of this strucutre */
    301 } _soc_mmu_cfg_buf_t;
    302 
    303 #define SOC_MMU_CFG_INIT(cfg)   \
    304             sal_memset(cfg, 0, sizeof(_soc_mmu_cfg_buf_t))
    305 
    306 /*
    307  * flags to specifiy various capablities of the MMU for the device.
    308  */
    309 
    310 /* supports port min guarentee */
    311 #define SOC_MMU_CFG_F_PORT_MIN              0x01
    312 
    313 /* supports per port per pool min guarentee */
    314 #define SOC_MMU_CFG_F_PORT_POOL_MIN         0x02
    315 #define SOC_MMU_CFG_F_RQE                   0x04
    316 #define SOC_MMU_CFG_F_EGR_MCQ_ENTRY         0x08
    317 
    318 typedef struct _soc_mmu_device_info_s {
    319     uint32  flags;
    320     uint32  max_pkt_byte;
    321     uint32  mmu_hdr_byte;
    322     uint32  jumbo_pkt_size;
    323     uint32  default_mtu_size;
    324     uint32  mmu_total_cell;
    325     uint32  mmu_cell_size;
    326     uint32  num_pg;
    327     uint32  num_service_pool;
    328     uint32  total_mcq_entry;
    329     uint32  total_rqe_queue_entry;
    330     uint32  rqe_queue_num;
    331 } _soc_mmu_device_info_t;
    332 
    333 typedef enum soc_mmu_pkt_buf_size_e {
    334     _MMU_PKT_BUF_SIZE_9MB = 0,
    335     _MMU_PKT_BUF_SIZE_12MB,
    336     _MMU_PKT_BUF_SIZE_16MB,
    337     _MMU_PKT_BUF_SIZE_MAX_COUNT
    338 } soc_mmu_pkt_buf_size_t;
    339 
    340 typedef enum soc_mmu_params_e {
    341     _MMU_MAX_PACKET_BYTES = 0,
    342     _MMU_PHYSICAL_CELLS,
    343     _MMU_TOTAL_CELLS,
    344     _MMU_RSVD_CELLS_CFAP,
    345     _MMU_MAX_PARAMS
    346 } soc_mmu_params_t;
    347 
    348 extern uint32 soc_mmu_pkt_buf_size_arr[_MMU_PKT_BUF_SIZE_MAX_COUNT][_MMU_MAX_PARAMS];
    349 
    350 typedef enum soc_mmu_type_e {
    351     _MMU_DEFAULT_THRES_TYPE = 0,
    352     _MMU_QENTRY_BASED,
    353     _MMU_EXTMEM_BASED,
    354     _MMU_MAX_THRESHOLD_TYPE
    355 } soc_mmu_type_t;
    356 
    357 #define _MMU_CFG_MMU_BYTES_TO_CELLS(byte,cellhdr) (((byte) + (cellhdr) - 1) / (cellhdr))
    358 
    359 #define _SOC_MMU_CFG_DEV_POOL_NUM(dcfg) ((dcfg)->num_service_pool)
    360 #define _SOC_MMU_CFG_DEV_PG_NUM(dcfg) ((dcfg)->num_pg)
    361 #define _SOC_MMU_CFG_MMU_TOTAL_CELLS(dcfg)  ((dcfg)->mmu_total_cell)
    362 
    363 #if 0
    364 #define _SOC_MMU_CFG_DEV_EXT_NUM_COSQ(dcfg, port) (dcfg)->port_ext_num_cosq[port]
    365 #define _SOC_MMU_CFG_DEV_MC_NUM_COSQ(dcfg, port) (dcfg)->port_mc_num_cosq[port]
    366 #define _SOC_MMU_CFG_DEV_UC_NUM_COSQ(dcfg, port) (dcfg)->port_uc_num_cosq[port]
    367 #endif
    368 
    369 void
    370 _soc_mmu_cfg_property_get_cells(int unit, soc_port_t port, const char *obj,
    371         int index, const char *attr, int allow_dynamic,
    372         int *setting, int byte_per_cell,
    373         soc_mmu_type_t threshold_type);
    374 
    375 void
    376 _soc_mmu_cfg_buf_read(int unit, _soc_mmu_cfg_buf_t *buf,
    377                                  _soc_mmu_device_info_t *devcfg);
    378 
    379 int
    380 _soc_mmu_cfg_buf_calculate(int unit, _soc_mmu_cfg_buf_t *buf,
    381                            _soc_mmu_device_info_t *devcfg);
    382 
    383 int
    384 _soc_mmu_cfg_buf_check(int unit, _soc_mmu_cfg_buf_t *buf, 
    385                         _soc_mmu_device_info_t *devcfg);
    386 
    387 _soc_mmu_cfg_buf_t* soc_mmu_cfg_alloc(int unit);
    388 void soc_mmu_cfg_free(int unit, _soc_mmu_cfg_buf_t *cfg);
    389 
    390 #endif /* _SOC_MMU_CONFIG_H_ */
    391