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

maverick2.h (41644B)


      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  * File:        maverick2.h
      8  * Purpose:     Function declarations for Maverick2 Internal functions.
      9  */
     10 
     11 #ifndef _BCM_INT_MAVERICK2_H_
     12 #define _BCM_INT_MAVERICK2_H_
     13 
     14 #include <bcm_int/esw/mbcm.h>
     15 #include <bcm_int/esw/cosq.h>
     16 #include <bcm/oob.h>
     17 #include <bcm_int/esw/pfc_deadlock.h>
     18 #include <soc/profile_mem.h>
     19 
     20 #if defined(BCM_MAVERICK2_SUPPORT)
     21 #include <soc/esw/port.h>
     22 #include <bcm_int/esw/l2.h>
     23 #include <bcm_int/esw/trident3.h>
     24 
     25 extern int bcmi_mv2_port_fn_drv_init(int unit);
     26 
     27 #if 0
     28 #define TD3_ECMP_MODE_SINGLE 0x0
     29 #define TD3_ECMP_MODE_HIERARCHICAL 0x1
     30 
     31 /* entries_per_profile comes from MAXIDX in PHB_MAPPING_TBL_1
     32  * MAXIDX     => 8703,  #(136 ports x 64 profiles) */
     33 #define _BCM_TD3_PHB_MAP_TAB1_ENTRIES_PER_PROFILE       (132)
     34 
     35 extern int _bcm_td3_port_phb_map_tab1_default_entry_add
     36                (int unit, soc_profile_mem_t *prof);
     37 
     38 extern int bcm_td3_port_init(int unit);
     39 
     40 extern int bcm_td3_port_ing_pri_cng_set(int unit, bcm_port_t port,
     41                                         int untagged, int pkt_pri, int cfi,
     42                                         int int_pri, bcm_color_t color);
     43 extern int bcm_td3_port_ing_pri_cng_get(int unit, bcm_port_t port,
     44                                         int untagged, int pkt_pri, int cfi,
     45                                         int *int_pri, bcm_color_t *color);
     46 
     47 extern int bcm_td3_port_cfg_init(int unit, bcm_port_t port,
     48                                  bcm_vlan_data_t *vlan_data);
     49 extern int bcm_td3_port_cfg_get(int, bcm_port_t, bcm_port_cfg_t *);
     50 extern int
     51 bcm_td3_port_cfg_set(int unit, bcm_port_t port, bcm_port_cfg_t *port_cfg);
     52 
     53 extern int _bcm_td3_egr_port_tab_conv(int unit, soc_field_t *field,
     54                                       soc_mem_t* mem);
     55 extern int _bcm_td3_port_tab_conv(int unit, soc_field_t *field, soc_mem_t *mem);
     56 
     57 /* VLAN Module */
     58 extern int 
     59 _bcm_vlan_vfi_untag_profile_entry_op(int unit, void **entries, 
     60                                      int entries_per_set, int add, uint32 *index);
     61 extern int 
     62 _bcm_vlan_vfi_untag_profile_mem_reference(int unit, int idx,int entries_per_set);
     63 extern int 
     64 _bcm_vlan_vfi_untag_profile_ref_count(int unit, int index, int *ref_count);
     65 extern int 
     66 bcm_td3_vlan_vfi_untag_init(int unit, bcm_vlan_t vid, pbmp_t pbmp);
     67 
     68 extern int
     69 _bcm_td3_vlan_vfi_profile_entry_set(int unit, bcm_vlan_t vlan_vfi,
     70                                     void *entry_data);
     71 extern int
     72 bcm_td3_vlan_vfi_untag_add(int unit, bcm_vlan_t vid, pbmp_t pbmp, pbmp_t ubmp);
     73 extern int
     74 bcm_td3_vlan_vfi_untag_delete(int unit, bcm_vlan_t vid, pbmp_t pbmp);
     75 extern int
     76 bcm_td3_vlan_table_ut_port_get(int unit, bcm_vlan_t vid, pbmp_t *ut_pbmp);
     77 extern int
     78 bcm_td3_vlan_vfi_untag_destroy(int unit, bcm_vlan_t vlan);
     79 
     80 /* VLAN XLATE */
     81 extern int _bcm_td3_vlan_mac_action_add(int unit, bcm_mac_t mac, 
     82                                         bcm_vlan_action_set_t *action);
     83 extern int
     84 _bcm_td3_vlan_mac_action_get(int unit, bcm_mac_t mac,
     85                              bcm_vlan_action_set_t *action);
     86 extern int
     87 _bcm_td3_vlan_mac_delete(int unit, bcm_mac_t mac);
     88 
     89 extern int
     90 _bcm_td3_vlan_mac_delete_all(int unit);
     91 
     92 extern int
     93 _bcm_td3_vlan_mac_action_traverse(int unit,
     94                                   bcm_vlan_mac_action_traverse_cb cb,
     95                                   void *user_data);
     96 /* COSQ Module */
     97 extern int
     98 bcm_td3_cosq_init(int unit);
     99 
    100 extern int
    101 bcm_td3_cosq_config_get(int unit, int *numq);
    102 
    103 extern int
    104 bcm_td3_cosq_config_set(int unit, int numq);
    105 
    106 extern int
    107 bcm_td3_cosq_gport_attach(int unit, bcm_gport_t input_gport,
    108                           bcm_gport_t parent_gport, bcm_cos_queue_t cosq);
    109 
    110 extern int
    111 bcm_td3_cosq_gport_detach(int unit, bcm_gport_t input_gport,
    112                           bcm_gport_t parent_gport, bcm_cos_queue_t cosq);
    113 
    114 extern int
    115 bcm_td3_cosq_gport_attach_get(int unit, bcm_gport_t sched_gport,
    116                               bcm_gport_t *input_gport, bcm_cos_queue_t *cosq);
    117 
    118 extern int
    119 bcm_td3_cosq_gport_traverse(int unit, bcm_cosq_gport_traverse_cb cb,
    120                             void *user_data);
    121 
    122 extern int
    123 bcm_td3_cosq_gport_child_get(int unit, bcm_gport_t in_gport,
    124                              bcm_cos_queue_t cosq, bcm_gport_t *out_gport);
    125 
    126 typedef enum {
    127     _BCM_TD3_COSQ_INDEX_STYLE_WRED_QUEUE,
    128     _BCM_TD3_COSQ_INDEX_STYLE_WRED_PORT,
    129     _BCM_TD3_COSQ_INDEX_STYLE_WRED_DEVICE,
    130     _BCM_TD3_COSQ_INDEX_STYLE_UCAST_QUEUE,
    131     _BCM_TD3_COSQ_INDEX_STYLE_MCAST_QUEUE,
    132     _BCM_TD3_COSQ_INDEX_STYLE_EGR_POOL,
    133     _BCM_TD3_COSQ_INDEX_STYLE_COS,
    134     _BCM_TD3_COSQ_INDEX_STYLE_COUNT
    135 } _bcm_td3_cosq_index_style_t;
    136 
    137 extern int
    138 _bcm_td3_cosq_port_resolve(int unit, bcm_gport_t gport, bcm_module_t *modid,
    139                            bcm_port_t *port, bcm_trunk_t *trunk_id, int *id,
    140                            int *qnum);
    141 
    142 extern int
    143 _bcm_td3_cosq_port_cos_resolve(int unit, bcm_port_t port, bcm_cos_t cos,
    144                                _bcm_td3_cosq_index_style_t style,
    145                                bcm_gport_t *gport);
    146 
    147 extern int
    148 bcm_td3_cosq_sched_weight_max_get(int unit, int mode, int *weight_max);
    149 
    150 extern int
    151 bcm_td3_cosq_gport_sched_get(int unit, bcm_gport_t gport, bcm_cos_queue_t cosq,
    152                              int *mode, int *weight);
    153 
    154 extern int
    155 bcm_td3_cosq_gport_sched_set(int unit, bcm_gport_t gport, bcm_cos_queue_t cosq,
    156                              int mode, int weight);
    157 
    158 extern int
    159 bcm_td3_cosq_port_sched_get(int unit, bcm_pbmp_t pbm, int *mode, int *weights,
    160                             int *delay);
    161 
    162 extern int
    163 bcm_td3_cosq_port_sched_set(int unit, bcm_pbmp_t pbm, int mode, const int
    164                             *weights, int delay);
    165 
    166 extern int
    167 bcm_td3_cosq_discard_set(int unit, uint32 flags);
    168 
    169 extern int
    170 bcm_td3_cosq_discard_get(int unit, uint32 *flags);
    171 
    172 extern int
    173 bcm_td3_cosq_discard_port_set(int unit, bcm_port_t port, bcm_cos_queue_t cosq,
    174                               uint32 color, int drop_start, int drop_slope,
    175                               int average_time);
    176 
    177 extern int
    178 bcm_td3_cosq_discard_port_get(int unit, bcm_port_t port, bcm_cos_queue_t cosq,
    179                               uint32 color, int *drop_start, int *drop_slope,
    180                               int *average_time);
    181 
    182 extern int
    183 bcm_td3_cosq_gport_discard_set(int unit, bcm_gport_t gport,
    184                                bcm_cos_queue_t cosq,
    185                                bcm_cosq_gport_discard_t *discard);
    186 
    187 extern int
    188 bcm_td3_cosq_gport_discard_get(int unit, bcm_gport_t gport,
    189                                bcm_cos_queue_t cosq,
    190                                bcm_cosq_gport_discard_t *discard);
    191 
    192 extern int
    193 bcm_td3_cosq_gport_bandwidth_get(int unit, bcm_gport_t gport,
    194                                  bcm_cos_queue_t cosq, uint32 *kbits_sec_min,
    195                                  uint32 *kbits_sec_max, uint32 *flags);
    196 
    197 extern int
    198 bcm_td3_cosq_gport_bandwidth_set(int unit, bcm_gport_t gport,
    199                                  bcm_cos_queue_t cosq, uint32 kbits_sec_min,
    200                                  uint32 kbits_sec_max, uint32 flags);
    201 
    202 extern int
    203 bcm_td3_cosq_port_bandwidth_get(int unit, bcm_port_t port, bcm_cos_queue_t cosq,
    204                                 uint32 *min_quantum, uint32 *max_quantum,
    205                                 uint32 *burst_quantum, uint32 *flags);
    206 
    207 extern int
    208 bcm_td3_cosq_port_bandwidth_set(int unit, bcm_port_t port, bcm_cos_queue_t cosq,
    209                                 uint32 min_quantum, uint32 max_quantum,
    210                                 uint32 burst_quantum, uint32 flags);
    211 
    212 extern int bcm_td3_cosq_port_attach(int unit, bcm_port_t port);
    213 extern int bcm_td3_cosq_port_detach(int unit, bcm_port_t port);
    214 
    215 extern int
    216 bcm_td3_rx_queue_channel_set_test(int unit, bcm_cos_queue_t queue_id,
    217                                   bcm_rx_chan_t chan_id);
    218 
    219 extern int
    220 bcm_td3_egr_mpls_combo_map_default(uint32 unit);
    221 
    222 extern int 
    223 bcm_td3_egr_mpls_combo_map_create(uint32 unit,
    224                                   int *egr_mpls_combo_map_created,
    225                                   soc_profile_mem_t **egr_mpls_combo_map);
    226 
    227 extern int
    228 bcm_td3_egr_mpls_combo_dump(uint32 unit,
    229                           soc_profile_mem_t *profile);
    230 
    231 extern void
    232 bcm_td3_egr_mpls_combo_map_info_init(uint32 unit);
    233 
    234 extern int 
    235 bcm_td3_qos_map_create(uint32 unit, uint32 *index, int entry_per_index);
    236 
    237 extern int bcm_td3_cosq_control_set(int unit, bcm_gport_t gport,
    238                                     bcm_cos_queue_t cosq,
    239                                     bcm_cosq_control_t type, int arg);
    240 extern int bcm_td3_cosq_control_get(int unit, bcm_gport_t gport,
    241                                     bcm_cos_queue_t cosq,
    242                                     bcm_cosq_control_t type, int *arg);
    243 extern int 
    244 _bcm_td3_cosq_index_resolve(int unit, bcm_port_t port,
    245                             bcm_cos_queue_t cosq, _bcm_td3_cosq_index_style_t style,
    246                             bcm_port_t *local_port, int *index, int *count);
    247 
    248 extern int
    249 bcm_td3_cosq_bst_profile_set(int unit,
    250                             bcm_gport_t port,
    251                             bcm_cos_queue_t cosq,
    252                             bcm_bst_stat_id_t bid,
    253                             bcm_cosq_bst_profile_t *profile);
    254 
    255 extern int
    256 bcm_td3_cosq_bst_profile_get(int unit,
    257                             bcm_gport_t port,
    258                             bcm_cos_queue_t cosq,
    259                             bcm_bst_stat_id_t bid,
    260                             bcm_cosq_bst_profile_t *profile);
    261 
    262 extern int
    263 bcm_td3_cosq_bst_stat_get(int unit,
    264                          bcm_gport_t port,
    265                          bcm_cos_queue_t cosq,
    266                          bcm_bst_stat_id_t bid,
    267                          uint32 options,
    268                          uint64 *pvalue);
    269 
    270 extern int
    271 bcm_td3_cosq_bst_stat_multi_get(int unit,
    272                                bcm_gport_t port,
    273                                bcm_cos_queue_t cosq,
    274                                uint32 options,
    275                                int max_values,
    276                                bcm_bst_stat_id_t *id_list,
    277                                uint64 *pvalues);
    278 
    279 extern int
    280 bcm_td3_cosq_bst_stat_clear(int unit, bcm_gport_t port,
    281                            bcm_cos_queue_t cosq, bcm_bst_stat_id_t bid);
    282 
    283 extern int bcm_td3_cosq_bst_stat_sync(int unit, bcm_bst_stat_id_t bid);
    284 
    285 extern int
    286 _bcm_td3_bst_hdrm_stat_clear(int unit,
    287                             bcm_gport_t gport,
    288                             bcm_cos_queue_t cosq);
    289 
    290 extern int
    291 _bcm_td3_cosq_bst_hdrm_stat_get(int unit,
    292                                bcm_gport_t gport,
    293                                bcm_cos_queue_t cosq,
    294                                uint32 options,
    295                                uint64 *pvalue);
    296 
    297 extern int
    298 bcm_td3_cosq_mapping_set(int unit, bcm_port_t gport, bcm_cos_t priority,
    299                          bcm_cos_queue_t cosq);
    300 
    301 extern int
    302 bcm_td3_cosq_mapping_get(int unit, bcm_port_t gport, bcm_cos_t priority,
    303                          bcm_cos_queue_t *cosq);
    304 
    305 extern int
    306 bcm_td3_cosq_gport_mapping_set(int unit, bcm_port_t ing_port,
    307                                bcm_cos_t int_pri, uint32 flags,
    308                                bcm_gport_t gport, bcm_cos_queue_t cosq);
    309 
    310 extern int
    311 bcm_td3_cosq_gport_mapping_get(int unit, bcm_port_t ing_port,
    312                                bcm_cos_t int_pri, uint32 flags,
    313                                bcm_gport_t *gport, bcm_cos_queue_t *cosq);
    314 
    315 extern int
    316 bcm_td3_cosq_port_pfc_op(int unit, bcm_port_t port,
    317                          bcm_switch_control_t sctype, _bcm_cosq_op_t op,
    318                          bcm_gport_t *gport, int gport_count);
    319 
    320 extern int
    321 bcm_td3_cosq_port_pfc_get(int unit, bcm_port_t port,
    322                           bcm_switch_control_t sctype,
    323                           bcm_gport_t *gport, int gport_count,
    324                           int *actual_gport_count);
    325 
    326 extern int
    327 bcm_td3_cosq_pfc_class_mapping_set(int unit, bcm_gport_t port,
    328                                    int array_count,
    329                                    bcm_cosq_pfc_class_mapping_t *mapping_array);
    330 
    331 extern int
    332 bcm_td3_cosq_pfc_class_mapping_get(int unit, bcm_gport_t port,
    333                                    int array_max,
    334                                    bcm_cosq_pfc_class_mapping_t *mapping_array,
    335                                    int *array_count);
    336 
    337 extern int
    338 _bcm_td3_port_enqueue_set(int unit, bcm_port_t gport, int enable);
    339 extern int
    340 _bcm_td3_port_enqueue_get(int unit, bcm_port_t gport, int *enable);
    341 /* OOB support */
    342 /* OOB FC Tx side global configuration API */
    343 extern int bcm_td3_oob_fc_tx_config_set(
    344     int unit,
    345     bcm_oob_fc_tx_config_t *config);
    346 
    347 /* OOB FC Tx side global configuration get API */
    348 extern int bcm_td3_oob_fc_tx_config_get(
    349     int unit,
    350     bcm_oob_fc_tx_config_t *config);
    351 
    352 extern int
    353 _bcm_td3_oob_fc_tx_port_control_set(int unit, bcm_port_t port,
    354                                    int status, int dir);
    355 extern int
    356 _bcm_td3_oob_fc_tx_port_control_get(int unit, bcm_port_t port,
    357                                    int *status, int dir);
    358 
    359 /* OOB FC Tx side global info get API */
    360 extern int bcm_td3_oob_fc_tx_info_get(
    361     int unit,
    362     bcm_oob_fc_tx_info_t *info);
    363 
    364 /*
    365  * OOB FC Rx Interface side Traffic Class to Priority Mapping Multi Set
    366  * API
    367  */
    368 extern int bcm_td3_oob_fc_rx_port_tc_mapping_multi_set(
    369     int unit,
    370     bcm_oob_fc_rx_intf_id_t intf_id,
    371     bcm_gport_t gport,
    372     int array_count,
    373     uint32 *tc,
    374     uint32 *pri_bmp);
    375 
    376 /*
    377  * OOB FC Rx Interface side Traffic Class to Priority Mapping Multi Get
    378  * API
    379  */
    380 extern int bcm_td3_oob_fc_rx_port_tc_mapping_multi_get(
    381     int unit,
    382     bcm_oob_fc_rx_intf_id_t intf_id,
    383     bcm_gport_t gport,
    384     int array_max,
    385     uint32 *tc,
    386     uint32 *pri_bmp,
    387     int *array_count);
    388 
    389 /* OOB FC Rx Interface side Traffic Class to Priority Mapping set API */
    390 extern int bcm_td3_oob_fc_rx_port_tc_mapping_set(
    391     int unit,
    392     bcm_oob_fc_rx_intf_id_t intf_id,
    393     bcm_gport_t gport,
    394     uint32 tc,
    395     uint32 pri_bmp);
    396 
    397 /* OOB FC Rx Interface side Traffic Class to Priority Mapping get API */
    398 extern int bcm_td3_oob_fc_rx_port_tc_mapping_get(
    399     int unit,
    400     bcm_oob_fc_rx_intf_id_t intf_id,
    401     bcm_gport_t gport,
    402     uint32 tc,
    403     uint32 *pri_bmp);
    404 
    405 /* OOB FC Rx Interface side Configuration set API */
    406 extern int bcm_td3_oob_fc_rx_config_set(
    407     int unit,
    408     bcm_oob_fc_rx_intf_id_t intf_id,
    409     bcm_oob_fc_rx_config_t *config,
    410     int array_count,
    411     bcm_gport_t *gport_array);
    412 
    413 /* OOB FC Rx Interface side Configuration get API */
    414 extern int bcm_td3_oob_fc_rx_config_get(
    415     int unit,
    416     bcm_oob_fc_rx_intf_id_t intf_id,
    417     bcm_oob_fc_rx_config_t *config,
    418     int array_max,
    419     bcm_gport_t *gport_array,
    420     int *array_count);
    421 
    422 /* OOB FC Rx Interface side Channel offset value for a port */
    423 extern int bcm_td3_oob_fc_rx_port_offset_get(
    424     int unit,
    425     bcm_oob_fc_rx_intf_id_t intf_id,
    426     bcm_gport_t gport,
    427     uint32 *offset);
    428 
    429 /* OOB STATS global configuration set API */
    430 extern int bcm_td3_oob_stats_config_set(
    431     int unit,
    432     bcm_oob_stats_config_t *config);
    433 
    434 /* OOB STATS global configuration get API */
    435 extern int bcm_td3_oob_stats_config_get(
    436     int unit,
    437     bcm_oob_stats_config_t *config);
    438 
    439 
    440 /* OOB STATS configuration of service pool list multi set API */
    441 extern int bcm_td3_oob_stats_pool_mapping_multi_set(
    442     int unit,
    443     int array_count,
    444     int *offset_array,
    445     uint8 *dir_array,
    446     bcm_service_pool_id_t *pool_array);
    447 
    448 /* OOB STATS configuration of service pool list multi get API */
    449 extern int bcm_td3_oob_stats_pool_mapping_multi_get(
    450     int unit,
    451     int array_max,
    452     int *offset_array,
    453     uint8 *dir_array,
    454     bcm_service_pool_id_t *pool_array,
    455     int *array_count);
    456 
    457 /* OOB STATS configuration of service pool list set API */
    458 extern int bcm_td3_oob_stats_pool_mapping_set(
    459     int unit,
    460     int offset,
    461     uint8 dir,
    462     bcm_service_pool_id_t pool);
    463 
    464 /* OOB STATS configuration of service pool list get API */
    465 extern int bcm_td3_oob_stats_pool_mapping_get(
    466     int unit,
    467     int offset,
    468     uint8 *dir,
    469     bcm_service_pool_id_t *pool);
    470 
    471 /* OOB STATS configuration of Queue list set API */
    472 extern int bcm_td3_oob_stats_queue_mapping_multi_set(
    473     int unit,
    474     int array_count,
    475     int *offset_array,
    476     bcm_gport_t *gport_array);
    477 
    478 /* OOB STATS configuration of Queue list get API */
    479 extern int bcm_td3_oob_stats_queue_mapping_multi_get(
    480     int unit,
    481     int array_max,
    482     int *offset_array,
    483     bcm_gport_t *gport_array,
    484     int *array_count);
    485 
    486 /* OOB STATS configuration of Queue list set API */
    487 extern int bcm_td3_oob_stats_queue_mapping_set(
    488     int unit,
    489     int offset,
    490     bcm_gport_t gport);
    491 
    492 /* OOB STATS configuration of Queue list get API */
    493 extern int bcm_td3_oob_stats_queue_mapping_get(
    494     int unit,
    495     int offset,
    496     bcm_gport_t *gport);
    497 
    498 
    499 
    500 /*
    501  * 8 Priority Groups supported.
    502  */
    503 #define TD3_PRIOROTY_GROUP_ID_MIN 0
    504 #define TD3_PRIOROTY_GROUP_ID_MAX 7
    505 /*
    506  * Inpur priority range.
    507  * PFC : 0-7
    508  * SAFC : 0-15
    509  */
    510 #define TD3_PFC_INPUT_PRIORITY_MIN  0
    511 #define TD3_PFC_INPUT_PRIORITY_MAX  7
    512 #define TD3_SAFC_INPUT_PRIORITY_MIN TD3_PFC_INPUT_PRIORITY_MIN
    513 #define TD3_SAFC_INPUT_PRIORITY_MAX 15
    514 
    515 extern int
    516 bcm_td3_port_priority_group_mapping_set(int unit, bcm_gport_t gport,
    517                                         int prio, int priority_group);
    518 extern int
    519 bcm_td3_port_priority_group_mapping_get(int unit, bcm_gport_t gport,
    520                                         int prio, int *priority_group);
    521 extern int
    522 bcm_td3_port_priority_group_config_set(int unit, bcm_gport_t gport,
    523     int priority_group, bcm_port_priority_group_config_t *prigrp_config);
    524 extern int
    525 bcm_td3_port_priority_group_config_get(int unit, bcm_gport_t gport,
    526     int priority_group, bcm_port_priority_group_config_t *prigrp_config);
    527 extern int
    528 _bcm_td3_cosq_inv_mapping_get(int unit, bcm_gport_t gport,
    529                               bcm_cos_queue_t cosq,
    530                               uint32 flags, bcm_port_t *ing_port,
    531                               bcm_cos_t *priority);
    532 
    533 /* pfc deadlock */
    534 extern int
    535 _bcm_td3_pfc_deadlock_init(int unit);
    536 
    537 extern int
    538 _bcm_td3_pfc_deadlock_hw_cos_index_get(int unit,
    539                                        bcm_cos_t priority,
    540                                        int *hw_cos_index);
    541 extern int
    542 _bcm_td3_pfc_deadlock_hw_cos_index_set(int unit,
    543                                        bcm_cos_t priority,
    544                                        int *hw_cos_index);
    545 extern int
    546 _bcm_td3_pfc_deadlock_chip_config_get(int unit,
    547                                       bcm_cos_t priority,
    548                                       soc_reg_t* chip_config);
    549 extern int
    550 _bcm_td3_pfc_deadlock_hw_oper(int unit,
    551                               _bcm_pfc_deadlock_oper_t operation,
    552                                bcm_cos_t priority,
    553                               _bcm_pfc_deadlock_config_t *config);
    554 extern int
    555 _bcm_td3_pfc_deadlock_q_config_helper(int unit,
    556                                       _bcm_pfc_deadlock_oper_t operation,
    557                                       bcm_gport_t gport,
    558                                       bcm_cosq_pfc_deadlock_queue_config_t *config,
    559                                       uint8 *enable_status);
    560 extern int
    561 bcm_td3_pfc_deadlock_ignore_pfc_xoff_gen(int unit, int priority,
    562                                         bcm_port_t port, uint32 *rval32);
    563 extern int
    564 _bcm_td3_pfc_deadlock_recovery_end(int unit, int cos, bcm_port_t port);
    565 extern int
    566 _bcm_td3_pfc_deadlock_recovery_begin(int unit, int cos, int pipe, int pipe_mmu_port);
    567 extern int
    568 _bcm_td3_pfc_deadlock_recovery_reset(int unit);
    569 extern int
    570 _bcm_td3_pfc_deadlock_monitor(int unit);
    571 
    572 
    573 extern int
    574 bcm_td3_cosq_port_pps_set(int unit, bcm_port_t port, bcm_cos_queue_t cosq,
    575                           int pps);
    576 
    577 extern int
    578 bcm_td3_cosq_port_pps_get(int unit, bcm_port_t port, bcm_cos_queue_t cosq,
    579                           int *pps);
    580 
    581 extern int
    582 bcm_td3_cosq_port_burst_set(int unit, bcm_port_t port, bcm_cos_queue_t cosq,
    583                             int burst);
    584 
    585 extern int
    586 bcm_td3_cosq_port_burst_get(int unit, bcm_port_t port, bcm_cos_queue_t cosq,
    587                             int *burst);
    588 
    589 extern int
    590 bcm_td3_port_rate_egress_set(int unit, bcm_port_t port, uint32 bandwidth,
    591                              uint32 burst, uint32 mode);
    592 
    593 extern int
    594 bcm_td3_port_rate_egress_get(int unit, bcm_port_t port, uint32 *bandwidth,
    595                              uint32 *burst, uint32 *mode);
    596 
    597 extern int
    598 bcm_td3_port_drain_cells(int unit, int port);
    599 
    600 extern int
    601 bcm_td3_cosq_cpu_cosq_enable_set(int unit, bcm_cos_queue_t cosq, int enable);
    602 
    603 extern int
    604 bcm_td3_cosq_cpu_cosq_enable_get(int unit, bcm_cos_queue_t cosq,
    605                                  int *enable);
    606 
    607 extern int
    608 bcm_td3_cosq_field_classifier_get(int unit, int classifier_id,
    609                                   bcm_cosq_classifier_t *classifier);
    610 
    611 extern int
    612 bcm_td3_cosq_field_classifier_id_create(int unit, bcm_cosq_classifier_t
    613                                         *classifier, int *classifier_id);
    614 
    615 extern int
    616 bcm_td3_cosq_field_classifier_id_destroy(int unit, int classifier_id);
    617 
    618 extern int
    619 bcm_td3_cosq_field_classifier_map_set(int unit, int classifier_id, int count,
    620         bcm_cos_t *priority_array, bcm_cos_queue_t *cosq_array);
    621 
    622 extern int
    623 bcm_td3_cosq_field_classifier_map_get(int unit, int classifier_id,int array_max,
    624         bcm_cos_t *priority_array, bcm_cos_queue_t *cosq_array, int *array_count);
    625 
    626 extern int
    627 bcm_td3_cosq_field_classifier_map_clear(int unit, int classifier_id);
    628 
    629 extern int
    630 bcm_td3_cosq_safc_class_mapping_set(int unit, bcm_gport_t port, int array_count,
    631                                 bcm_cosq_safc_class_mapping_t *mapping_array);
    632 
    633 extern int
    634 bcm_td3_cosq_safc_class_mapping_get(int unit, bcm_gport_t port, int array_max,
    635                                 bcm_cosq_safc_class_mapping_t *mapping_array,
    636                                 int *array_count);
    637 
    638 /* Subport functions */
    639 extern int bcm_td3_subport_coe_init(int unit);
    640 #if defined(INCLUDE_L3)
    641 /* L3 ECMP DLB */
    642 extern void _bcm_td3_ecmp_dlb_deinit(int unit);
    643 extern int _bcm_td3_ecmp_dlb_init(int unit);
    644 extern int bcm_td3_l3_egress_dlb_attr_set(int unit, int nh_index,
    645         bcm_l3_egress_t *egr);
    646 extern int bcm_td3_l3_egress_dlb_attr_destroy(int unit, int nh_index);
    647 extern int bcm_td3_l3_egress_dlb_attr_get(int unit, int nh_index,
    648         bcm_l3_egress_t *egr);
    649 extern int bcm_td3_l3_egress_ecmp_dlb_create(int unit,
    650         bcm_l3_egress_ecmp_t *ecmp, int intf_count, bcm_if_t *intf_array);
    651 extern int bcm_td3_l3_egress_ecmp_dlb_destroy(int unit,
    652         bcm_if_t mpintf);
    653 extern int bcm_td3_l3_egress_ecmp_dlb_get(int unit,
    654         bcm_l3_egress_ecmp_t *ecmp);
    655 extern int bcm_td3_l3_egress_dlb_attr_get(int unit, int nh_index, bcm_l3_egress_t *egr);
    656 extern  int bcm_td3_l3_egress_ecmp_dlb_ethertype_set(
    657     int unit, uint32 flags, int ethertype_count, int *ethertype_array);
    658 
    659 extern int bcm_td3_l3_egress_ecmp_dlb_ethertype_get(int unit, 
    660     uint32 *flags, int ethertype_max, int *ethertype_array, int *ethertype_count);
    661 
    662 extern int _bcm_td3_ecmp_dlb_config_set(int unit, bcm_switch_control_t type,
    663         int arg);
    664 extern int _bcm_td3_ecmp_dlb_config_get(int unit, bcm_switch_control_t type,
    665         int *arg);
    666 extern void bcm_td3_ecmp_dlb_sw_dump(int unit);
    667 extern int
    668 bcm_td3_l3_conflict_get(int unit, bcm_l3_key_t *ipkey, bcm_l3_key_t *cf_array,
    669                         int cf_max, int *cf_count);
    670 
    671 #endif /* INCLUDE_L3 */
    672 
    673 #if defined(INCLUDE_L3)
    674 extern int _bcm_td3_flow_port_resolve(
    675     int unit,
    676     bcm_gport_t flow_port_id,
    677     bcm_if_t encap_id,
    678     bcm_module_t *modid,
    679     bcm_port_t *port,
    680     bcm_trunk_t *trunk_id,
    681     int *id);
    682 
    683 extern int _bcm_td3_l3_flex_nh_add(
    684     int unit,
    685     int idx,
    686     bcm_l3_egress_t *nh_entry,
    687     uint32 *egr_nh,
    688     int ipmc);
    689 
    690 extern int _bcm_td3_l3_flex_nh_entry_parse(
    691     int unit,
    692     uint32 *egr_entry_ptr,
    693     uint32 index,
    694     bcm_l3_egress_t *nh_entry);
    695 
    696 extern int _bcm_td3_flow_next_hop_set(
    697     int unit,
    698     int nh_index,
    699     uint32 flags,
    700     int vp,
    701     int drop);
    702 
    703 extern int _bcm_td3_flow_egress_reset(
    704     int unit,
    705     int nh_index);
    706 
    707 extern int _bcm_td3_flow_egress_get(
    708     int unit,
    709     bcm_l3_egress_t *egr,
    710     int nh_index);
    711 
    712 extern int _bcm_td3_l3_flex_intf_add(
    713     int unit,
    714     _bcm_l3_intf_cfg_t *intf_info,
    715     uint32 *l3_if_entry_p);
    716 
    717 extern int _bcm_td3_l3_flex_intf_get(
    718     int unit,
    719     _bcm_l3_intf_cfg_t *intf_info,
    720     uint32 *l3_if_entry_p);
    721 
    722 extern int _bcm_td3_l3_flex_entry_get(
    723     int unit,
    724     _bcm_l3_cfg_t *l3cfg,
    725      int *nh_idx,
    726      int *embd);
    727 
    728 extern int _bcm_td3_l3_flex_ent_parse(
    729      int unit,
    730      soc_mem_t mem,
    731      _bcm_l3_cfg_t *l3cfg,
    732      int *nh_idx,
    733      void *l3x_entry);
    734 
    735 extern int _bcm_td3_l3_flex_entry_add(
    736     int unit,
    737      _bcm_l3_cfg_t *l3cfg,
    738      int nh_idx);
    739 
    740 extern int _bcm_td3_l3_flex_entry_del(
    741     int unit,
    742      _bcm_l3_cfg_t *l3cfg);
    743 
    744 extern int _bcm_td3_lpm_flex_ent_init(
    745     int unit,
    746      _bcm_defip_cfg_t *lpm_cfg,
    747     defip_entry_t *lpm_entry);
    748 
    749 extern int _bcm_td3_lpm_prepare_flex_defip_entry(
    750     int unit,
    751     _bcm_defip_cfg_t *lpm_cfg,
    752     int nh_ecmp_idx,
    753     defip_entry_t *lpm_entry);
    754 
    755 extern int _bcm_td3_lpm_flex_ent_get_key(
    756     int unit,
    757     _bcm_defip_cfg_t *lpm_cfg,
    758     defip_entry_t *lpm_entry,
    759     uint32 key_type);
    760 
    761 extern int _bcm_td3_lpm_flex_ent_parse(
    762      int unit,
    763      uint32 *lpm_entry,
    764      uint32 key_type,
    765      soc_mem_t mem,
    766      _bcm_defip_cfg_t *lpm_cfg,
    767      int *nh_idx);
    768 
    769 extern int _bcm_defip_pair128_flex_get_key(
    770      int unit,
    771      uint32 *hw_entry,
    772      _bcm_defip_cfg_t *lpm_cfg);
    773 
    774 extern int _bcm_l3_defip_pair128_flex_add(
    775      int unit,
    776      _bcm_defip_cfg_t *lpm_cfg,
    777      int nh_ecmp_idx,
    778      uint32 *hw_entry);
    779 
    780 extern int _bcm_td3_mpls_gre_label_add(
    781     int unit,
    782     bcm_l3_egress_t *egr,
    783     int nh_index,
    784     uint32 flags);
    785 
    786 extern int _bcm_td3_mpls_gre_label_get(
    787     int unit,
    788     int vc_swap_index,
    789     bcm_l3_egress_t *egr);
    790 
    791 extern int _bcm_td3_mpls_gre_label_delete(
    792     int unit,
    793     int index,
    794     soc_mem_t view_id);
    795 #endif /* INCLUDE_L3 */
    796 
    797 extern int _bcm_td3_flex_l2_from_l2x(
    798     int unit,
    799     bcm_l2_addr_t *l2addr,
    800     l2x_entry_t *l2x_entry,
    801     int *mb_index);
    802 
    803 extern int _bcm_td3_flex_l2_to_l2x(
    804     int unit,
    805     l2x_entry_t *l2x_entry,
    806     bcm_l2_addr_t *l2addr,
    807     int key_only);
    808 
    809 extern int _bcm_td3_flex_l2_replace_data_mask_setup(
    810     int unit,
    811     _bcm_l2_replace_t *rep);
    812 
    813 extern int _bcm_td3_flex_l2_bulk_replace_modport(
    814     int unit,
    815      _bcm_l2_replace_t *rep_st);
    816 
    817 extern int
    818 bcm_td3_cosq_stat_set(int unit, bcm_gport_t port,
    819                      bcm_cos_queue_t cosq,
    820                      bcm_cosq_stat_t stat, uint64 value);
    821 extern int
    822 bcm_td3_cosq_stat_get(int unit, bcm_gport_t port,
    823                      bcm_cos_queue_t cosq,
    824                      bcm_cosq_stat_t stat, int sync_mode,
    825                      uint64 *value);
    826 extern int bcmi_td3_port_fn_drv_init(int unit);
    827 extern int bcmi_td3_port_soc_resource_init(int unit, int nport,
    828                                  bcm_port_resource_t *resource,
    829                                  soc_port_resource_t *soc_resource);
    830 extern int bcmi_td3_port_resource_validate(int unit,
    831                             soc_port_schedule_state_t *port_schedule_state);
    832 extern int bcmi_td3_pre_flexport_tdm(int unit,
    833                             soc_port_schedule_state_t *port_schedule_state);
    834 extern int bcmi_td3_post_flexport_tdm(int unit,
    835                             soc_port_schedule_state_t *port_schedule_state);
    836 extern int bcmi_td3_clport_update(int unit,
    837                             soc_port_schedule_state_t *port_schedule_state);
    838 extern int bcmi_td3_port_attach_mmu(int unit, int port);
    839 extern int bcmi_td3_port_detach_asf(int unit, bcm_port_t port);
    840 extern int bcmi_td3_port_enable(int unit,
    841                              soc_port_schedule_state_t *port_schedule_state);
    842 extern int bcmi_td3_port_disable(int unit,
    843                              soc_port_schedule_state_t *port_schedule_state);
    844 extern int bcmi_mv2_port_speed_1g_update(int unit, bcm_port_t port, int speed);
    845 extern int bcmi_td3_speed_ability_get(int unit, bcm_port_t port,
    846                                       bcm_port_abil_t *mask);
    847 extern void bcm_td3_pstats_deinit(int unit);
    848 extern int  bcm_td3_pstats_init(int unit);
    849 extern int bcmi_td3_port_detach_stack(int unit, bcm_port_t port);
    850 extern int bcmi_td3_port_attach_stack(int unit, bcm_port_t port);
    851 
    852 #ifdef BCM_WARM_BOOT_SUPPORT_SW_DUMP
    853 extern void bcm_td3_cosq_sw_dump(int unit);
    854 #endif
    855 #ifdef BCM_WARM_BOOT_SUPPORT
    856 extern int bcm_td3_cosq_sync(int unit);
    857 #endif /* BCM_WARM_BOOT_SUPPORT */
    858 
    859 /* RIOT related defines */
    860 
    861 #ifdef BCM_RIOT_SUPPORT
    862 
    863 
    864 /* TD3 : EGR_L3_NEXT_HOP-KEY_TYPEf */
    865 #define BCMI_TD3_L3_EGR_NH_MCAST_ENTRY_TYPE  7
    866 #define BCMI_TD3_L3_EGR_NH_SD_TAG_ENTRY_TYPE 2
    867 
    868 
    869 /* L3 interface banks values */
    870 #define BCMI_TD3_L3_INTF_ENT_PER_BANK        2048
    871 #define BCMI_TD3_L3_INTF_BANKS_MAX           8
    872 
    873 /* L3 next hop banks values */
    874 #define BCMI_TD3_L3_NH_ENT_PER_BANK          4096
    875 #define BCMI_TD3_L3_NH_BANKS_MAX             16
    876 
    877 
    878 /* NH destination encodings, masks and macros */
    879 #define BCMI_TD3_L3_NH_DEST_DGLP_SHIFT       16
    880 #define BCMI_TD3_L3_NH_DEST_DGLP_MASK        0xFFFF   /* 15 bits value */
    881 #define BCMI_TD3_L3_NH_DEST_DGLP_EN_MASK     0x3      /* 2 bits value */
    882 #define BCMI_TD3_L3_NH_DEST_DGLP_ENCODING    0x0      /* 15 bits value */
    883 #define BCMI_TD3_L3_NH_DEST_DVP_SHIFT        16       /* 14 bits value */
    884 #define BCMI_TD3_L3_NH_DEST_DVP_MASK         0xFFFF   /* 14 bits value */
    885 #define BCMI_TD3_L3_NH_DEST_DVP_EN_MASK      0x3      /* 4 bits value */
    886 #define BCMI_TD3_L3_NH_DEST_DVP_ENCODING     0x1      /* 15 bits value */
    887 #define BCMI_TD3_L3_NH_DEST_LAG_SHIFT        13       /* 14 bits value */
    888 #define BCMI_TD3_L3_NH_DEST_LAG_MASK         0x1FFF   /* 14 bits value */
    889 #define BCMI_TD3_L3_NH_DEST_LAG_EN_MASK      0xF      /* 4 bits value */
    890 #define BCMI_TD3_L3_NH_DEST_LAG_ENCODING     0x1      /* 15 bits value */
    891 
    892 
    893 #define BCMI_TD3_L3_NH_DEST_DVP_GET(gport) \
    894             ((BCMI_TD3_L3_NH_DEST_DVP_ENCODING << BCMI_TD3_L3_NH_DEST_DVP_SHIFT) | \
    895             (gport & BCMI_TD3_L3_NH_DEST_DVP_MASK))
    896 
    897 #define BCMI_TD3_L3_NH_DEST_LAG_GET(gport) \
    898             ((BCMI_TD3_L3_NH_DEST_LAG_ENCODING << BCMI_TD3_L3_NH_DEST_LAG_SHIFT) | \
    899             (gport & BCMI_TD3_L3_NH_DEST_LAG_MASK))
    900 
    901 #define BCMI_TD3_L3_NH_DEST_DGLP_GET(gport) \
    902             ((BCMI_TD3_L3_NH_DEST_DGLP_ENCODING << BCMI_TD3_L3_NH_DEST_DGLP_SHIFT) | \
    903             (gport & BCMI_TD3_L3_NH_DEST_DGLP_MASK))
    904 
    905 #define BCMI_TD3_L3_NH_DEST_IS_DGLP(_dest)  \
    906             ((((_dest) >> BCMI_TD3_L3_NH_DEST_DGLP_SHIFT) & BCMI_TD3_L3_NH_DEST_DGLP_EN_MASK) == \
    907             BCMI_TD3_L3_NH_DEST_DGLP_ENCODING)
    908 #define BCMI_TD3_L3_NH_PORT_DGLP_GET(_dest) \
    909             (((_dest) & BCMI_TD3_L3_NH_DEST_DGLP_MASK))
    910 
    911 #define BCMI_TD3_L3_NH_DEST_IS_LAG(_dest)  \
    912             (BCMI_TD3_L3_NH_DEST_IS_DGLP(_dest) && ((((_dest) >> BCMI_TD3_L3_NH_DEST_LAG_SHIFT) & BCMI_TD3_L3_NH_DEST_LAG_EN_MASK) == \
    913             BCMI_TD3_L3_NH_DEST_LAG_ENCODING))
    914 
    915 #define BCMI_TD3_L3_NH_PORT_LAG_GET(_dest) \
    916             (((_dest) & BCMI_TD3_L3_NH_DEST_LAG_MASK))
    917 
    918 #define BCMI_TD3_L3_NH_DEST_IS_DVP(_dest)  \
    919             ((((_dest) >> BCMI_TD3_L3_NH_DEST_DVP_SHIFT) & BCMI_TD3_L3_NH_DEST_DVP_EN_MASK) == \
    920             BCMI_TD3_L3_NH_DEST_DVP_ENCODING)
    921 
    922 #define BCMI_TD3_L3_NH_PORT_DVP_GET(_dest) \
    923             (((_dest) & BCMI_TD3_L3_NH_DEST_DVP_MASK))
    924 
    925 /* Td3 : EGR_L3_NEXT_HOP-NEXT_PTR field types */
    926 #define BCMI_TD3_L3_NH_EGR_NEXT_PTR_TYPE_DVP    1
    927 #define BCMI_TD3_L3_NH_EGR_NEXT_PTR_TYPE_NH     2
    928 #define BCMI_TD3_L3_NH_EGR_NEXT_PTR_TYPE_VC_SWAP 3
    929 
    930 /* RioT Overlay validity checks */
    931 #define BCMI_RIOT_IS_ENABLED(_u) \
    932     ((&_bcm_l3_bk_info[_u])->riot_enable)
    933 
    934 #define BCMI_L3_NH_OVERLAY_VALID(_u) \
    935     ((BCMI_RIOT_IS_ENABLED(_u)) &&            \
    936     (((&_bcm_l3_bk_info[_u])->l3_nh_overlay_entries) > 0))
    937 
    938 #define BCMI_L3_INTF_OVERLAY_VALID(_u) \
    939     ((BCMI_RIOT_IS_ENABLED(_u)) &&            \
    940     (((&_bcm_l3_bk_info[_u])->l3_intf_overlay_entries) > 0))
    941 
    942 #define BCMI_RIOT_VPN_VFI_IS_SET(_u, _vid) \
    943     ((BCMI_RIOT_IS_ENABLED(_u)) && (_BCM_VPN_VFI_IS_SET((_vid))))
    944 
    945 #define BCMI_RIOT_VPN_VFI_IS_NOT_SET(_u, _vid) \
    946     ((!BCMI_RIOT_IS_ENABLED(_u)) || (!(_BCM_VPN_VFI_IS_SET((_vid)))))
    947 
    948 #define BCMI_GPORT_TYPE_GET(_gport)    \
    949         (((_gport) >> _SHR_GPORT_TYPE_SHIFT) & _SHR_GPORT_TYPE_MASK)
    950 
    951 #define BCMI_L3_NH_FLEX_VIEW(ent_type) (ent_type >= 9)
    952 #define BCMI_LPM_FLEX_VIEW(ent_type) (ent_type > 1)
    953 
    954 /* DESTINATION_FORMAT DEST_TYPE encodings */
    955 #define BCMI_TD3_DEST_TYPE_INVALID  0
    956 #define BCMI_TD3_DEST_TYPE0_DVP     1
    957 #define BCMI_TD3_DEST_TYPE0_DGPP    2
    958 #define BCMI_TD3_DEST_TYPE0_NH      3
    959 #define BCMI_TD3_DEST_TYPE1_ECMP    1
    960 #define BCMI_TD3_DEST_TYPE1_L2MC    2
    961 #define BCMI_TD3_DEST_TYPE1_IPMC    3
    962 #define BCMI_TD3_DEST_TYPE2_LAG     1
    963 
    964 #define BCMI_TD3_EGR_L3_NEXTHOP_WIDTH  160
    965 
    966 /*
    967  * The below infrastructure is done specially for nh-nh association management.
    968  * When overlay nh is associated with underlay nh, we will have to keep
    969  * backward tracing to redraw association if underlay NH is changed.
    970  */
    971 typedef struct _td3_ol_nh_link_s {
    972     int o_nh_idx;
    973     struct _td3_ol_nh_link_s *next_link;
    974 } td3_ol_nh_link_t;
    975 
    976 typedef struct _td3_ul_nh_link_s {
    977     int u_nh_idx;
    978     td3_ol_nh_link_t *ol_nh_assoc;
    979     struct _td3_ul_nh_link_s *ul_nh_link;
    980 } td3_ul_nh_link_t;
    981 
    982 /* TD3 specific routines */
    983 extern int bcmi_td3_l3_riot_init(int unit);
    984 extern int bcmi_td3_get_port_from_destination(int unit,
    985                uint32 dest, bcm_l3_egress_t *nh);
    986 
    987 extern int bcm_td3_riot_l3_nh_dest_set(int unit, bcm_l3_egress_t *nh_entry, ing_l3_next_hop_entry_t *nh_dest);
    988 /* ol-ul association routines */
    989 extern int bcmi_td3_l3_nh_assoc_ol_ul_link_sw_add(int unit,
    990                int ol_nh, int ul_nh);
    991 extern int bcmi_td3_l3_nh_assoc_ol_ul_link_delete(int unit, int nh_idx);
    992 extern int bcmi_td3_l3_nh_assoc_ol_ul_link_is_required(int unit, int vp_nh_index);
    993 extern int bcmi_td3_l3_nh_assoc_ol_ul_link_replace(int unit,
    994                int old_ul, int new_ul);
    995 extern int bcmi_td3_l3_nh_assoc_ol_ul_link_sw_delete(int unit, int ol_nh,
    996                int ul_nh);
    997 extern int bcmi_td3_l3_nh_assoc_ol_ul_link_reinit(int unit, int ol_nh_idx);
    998 extern int bcmi_td3_riot_l3_nh_dest_set(int unit,
    999                bcm_l3_egress_t *nh_entry, uint32 *nh_dest);
   1000 #endif /* BCM_RIOT_SUPPORT */
   1001 
   1002 #ifdef BCM_SPECIAL_LABEL_SUPPORT
   1003 
   1004 /************************* MPLS related Changes **********************/
   1005 
   1006 #define BCMI_MPLS_LABEL_ID_MAX          (0xfffff)
   1007 #define BCMI_MPLS_LABEL_ID_VALID(_label_)             \
   1008              (((_label_) >= 0) &&                         \
   1009              ((_label_) <= BCMI_MPLS_LABEL_ID_MAX))
   1010 
   1011 #define BCMI_MPLS_LABEL_MASK_MAX        (0xfffff)
   1012 #define BCMI_MPLS_LABEL_MASK_VALID(_mask_)            \
   1013              (((_mask_) >= 0) &&                      \
   1014              (((_mask_) <= BCMI_MPLS_LABEL_MASK_MAX))
   1015 
   1016 #define BCMI_MPLS_EXP_MAX          (0x7)
   1017 #define BCMI_MPLS_EXP_VALID(exp)                      \
   1018              (((exp) >= 0) &&                         \
   1019              ((exp) <= BCMI_MPLS_EXP_MAX))
   1020 
   1021 #define BCMI_MPLS_EXP_MASK_MAX        (0x7)
   1022 #define BCMI_MPLS_EXP_MASK_VALID(_mask_)              \
   1023              (((_mask_) >= 0) &&                      \
   1024              (((_mask_) <= BCMI_MPLS_EXP_MASK_MAX))
   1025 #define BCMI_MPLS_TTL_MAX          (0xFF)
   1026 #define BCMI_MPLS_TTL_VALID(ttl)                      \
   1027              (((ttl) >= 0) &&                         \
   1028              ((ttl) <= BCMI_MPLS_TTL_MAX))
   1029 
   1030 #define BCMI_MPLS_TTL_MASK_MAX        (0xff)
   1031 #define BCMI_MPLS_TTL_MASK_VALID(_mask_)              \
   1032              (((_mask_) >= 0) &&                      \
   1033              (((_mask_) <= BCMI_MPLS_TTL_MASK_MAX))
   1034 
   1035 #define BCMI_MPLS_CONSTRUCT_LABEL(val, exp, ttl, bos) \
   1036             (((val) << 12) | ((exp) << 9) |           \
   1037             ((bos) << 8) | (ttl))
   1038 
   1039 #define BCMI_MPLS_LABEL_VAL_FROM_LABEL_GET(mpls_label)\
   1040             (((mpls_label) >> 12) & 0xFFFFF)
   1041 
   1042 #define BCMI_MPLS_EXP_FROM_LABEL_GET(mpls_label)      \
   1043             (((mpls_label) >> 9) & 0x7)
   1044 
   1045 #define BCMI_MPLS_BOS_FROM_LABEL_GET(mpls_label)      \
   1046             (((mpls_label) >> 8) & 0x1)
   1047 
   1048 #define BCMI_MPLS_TTL_FROM_LABEL_GET(mpls_label)      \
   1049             ((mpls_label) & 0xFF)
   1050 
   1051 /***************** Function Decalarations *********************/
   1052 extern int bcmi_mpls_special_label_init(int unit);
   1053 extern void bcmi_mpls_special_label_deinit(int unit);
   1054 
   1055 extern int bcmi_mpls_special_label_identifier_add(int unit,
   1056             bcm_mpls_special_label_type_t label_type,
   1057             bcm_mpls_special_label_t label_info);
   1058 extern int bcmi_mpls_special_label_identifier_get(int unit,
   1059             bcm_mpls_special_label_type_t label_type,
   1060             bcm_mpls_special_label_t *label_info);
   1061 extern int bcmi_mpls_special_label_identifier_delete(int unit,
   1062             bcm_mpls_special_label_type_t label_type,
   1063             bcm_mpls_special_label_t label_info);
   1064 extern int bcmi_mpls_special_label_identifier_delete_all(int unit);
   1065 extern int bcmi_mpls_special_label_identifier_traverse(int unit,
   1066             bcm_mpls_special_label_identifier_traverse_cb cb,
   1067             void *user_data);
   1068 
   1069 
   1070 extern int bcmi_mpls_special_label_egress_add(int unit,
   1071             bcm_mpls_special_label_type_t label_type,
   1072             bcm_mpls_special_label_t label_info);
   1073 extern int bcmi_mpls_special_label_egress_get(int unit,
   1074             bcm_mpls_special_label_type_t label_type,
   1075             bcm_mpls_special_label_t *label_info);
   1076 extern int bcmi_mpls_special_label_egress_delete(int unit,
   1077             bcm_mpls_special_label_type_t label_type,
   1078             bcm_mpls_special_label_t label_info);
   1079 extern int bcmi_mpls_special_label_egress_delete_all(int unit);
   1080 extern int bcmi_mpls_special_label_egress_traverse(int unit,
   1081             bcm_mpls_special_label_egress_traverse_cb cb,
   1082             void *user_data);
   1083 
   1084 extern int bcmi_mpls_special_label_push_action_set(int unit,
   1085             bcm_mpls_special_label_push_element_t *element,
   1086             bcm_mpls_special_label_push_type_t push_type);
   1087 
   1088 extern int bcmi_mpls_special_label_push_action_get(int unit,
   1089             bcm_mpls_special_label_push_element_t *element,
   1090             bcm_mpls_special_label_push_type_t *push_type);
   1091 
   1092 extern int _bcm_td3_def_vfi_profile_add(int unit,
   1093             int is_eline, uint32 *profile_index);
   1094 
   1095 /***************** Structure Decalarations *********************/
   1096 
   1097 typedef struct bcmi_mpls_special_label_control_s {
   1098     uint32 label_value;
   1099     uint32 label_mask;
   1100     int    label_type;
   1101     int    valid;
   1102     int    ref_count;
   1103     int    cancun_added;
   1104 }bcmi_mpls_special_label_control_t;
   1105 
   1106 extern bcmi_mpls_special_label_control_t *bcmi_special_label_precedence_state[BCM_MAX_NUM_UNITS];
   1107 
   1108 /***************************************************************/
   1109 #endif /*BCM_SPECIAL_LABEL_SUPPORT*/
   1110 #endif
   1111 
   1112 #if defined(INCLUDE_FLOWTRACKER)
   1113 
   1114 /* Flow Tracker Flex Stat Enable Bit */
   1115 #define MV2_FT_FLEX_STAT_ENABLE_BIT 19
   1116 #define MV2_FT_FLEX_STAT_MODEID_BIT 20
   1117 
   1118 /* Flow Tracker Config Modes */
   1119 #define MV2_FT_CONFIG_MODE_MIXED_MODE1_ID   1
   1120 #define MV2_FT_CONFIG_MODE_MIXED_MODE2_ID   2
   1121 #define MV2_FT_CONFIG_MODE_QW_MODE1_ID      3
   1122 #define MV2_FT_CONFIG_MODE_QW_MODE2_ID      4
   1123 #define MV2_FT_CONFIG_MODE_QW_MODE3_ID      5
   1124 
   1125 /* Flow Tracker Pools Supported for config mode */
   1126 #define MV2_FT_CONFIG_MODE_MIXED_MODE1_FLEX_COUNTERS   32768
   1127 #define MV2_FT_CONFIG_MODE_MIXED_MODE2_FLEX_COUNTERS   65536
   1128 #define MV2_FT_CONFIG_MODE_QW_MODE1_FLEX_COUNTERS      16384
   1129 #define MV2_FT_CONFIG_MODE_QW_MODE2_FLEX_COUNTERS      32768
   1130 #define MV2_FT_CONFIG_MODE_QW_MODE3_FLEX_COUNTERS      65536
   1131 
   1132 /* Flowtracker module APIs */
   1133 extern int _bcm_mv2_flowtracker_config_init(int unit, _bcm_int_ft_info_t *ft_info);
   1134 extern int _bcm_mv2_flowtracker_config_detach(int unit);
   1135 extern int _bcm_mv2_flowtracker_config_mode_stats_get(int unit,
   1136                                                       uint8 ft_config_mode,
   1137                                                       uint32 *no_of_stats);
   1138 extern int _bcm_mv2_flowtracker_flow_group_default_config_set(int unit,
   1139                                                               bcm_flowtracker_group_t id);
   1140 extern int _bcm_mv2_flowtracker_flow_group_config_clear(int unit,
   1141                                                         bcm_flowtracker_group_t id);
   1142 extern int _bcm_mv2_flowtracker_flow_group_flow_limit_set(int unit,
   1143                                                           bcm_flowtracker_group_t id,
   1144                                                           uint32 flow_limit);
   1145 extern int _bcm_mv2_flowtracker_flow_group_flow_limit_get(int unit,
   1146                                                           bcm_flowtracker_group_t id,
   1147                                                           uint32 *flow_limit);
   1148 extern int _bcm_mv2_flowtracker_flow_group_stat_modeid_set(int unit,
   1149                                                            bcm_flowtracker_group_t id,
   1150                                                            uint32 stat_modeid);
   1151 extern int _bcm_mv2_flowtracker_flow_group_stat_modeid_get(int unit,
   1152                                                            bcm_flowtracker_group_t id,
   1153                                                            uint32 *stat_modeid);
   1154 extern int _bcm_mv2_flowtracker_flow_group_flow_count_get(int unit,
   1155                                                           bcm_flowtracker_group_t id,
   1156                                                           uint32 *flow_count);
   1157 
   1158 #endif /* INCLUDE_FLOWTRACKER */
   1159 #endif /* BCM_MAVERICK2_SUPPORT  */
   1160 
   1161 #endif /* !_BCM_INT_MAVERICK2_H_ */
   1162