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

qos.c (24496B)


      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  * All Rights Reserved.$
      7  *
      8  * QoS module
      9  */
     10 #include <sal/core/libc.h>
     11 
     12 #include <soc/defs.h>
     13 #include <soc/drv.h>
     14 #include <soc/mem.h>
     15 #include <soc/l2u.h>
     16 #include <soc/util.h>
     17 #include <soc/debug.h>
     18 #include <bcm/l2.h>
     19 #include <bcm/l3.h>
     20 #include <bcm/port.h>
     21 #include <bcm/error.h>
     22 #include <bcm/vlan.h>
     23 #include <bcm/ipmc.h>
     24 #include <bcm/qos.h>
     25 #include <bcm/stack.h>
     26 #include <bcm/topo.h>
     27 
     28 #include <bcm_int/esw/mbcm.h>
     29 #include <bcm_int/esw/l3.h>
     30 #include <bcm_int/esw/qos.h>
     31 #include <bcm_int/esw_dispatch.h>
     32 #include <bcm_int/esw/xgs3.h>
     33 #if defined(BCM_TRX_SUPPORT)
     34 #include <bcm_int/esw/trx.h>
     35 #endif /* BCM_TRX_SUPPORT */
     36 #if defined(BCM_TRIUMPH2_SUPPORT)
     37 #include <bcm_int/esw/triumph2.h>
     38 #endif /* BCM_TRIUMPH2_SUPPORT */
     39 #if defined(BCM_TRIUMPH_SUPPORT)
     40 #include <bcm_int/esw/triumph.h>
     41 #endif /* BCM_TRIUMPH_SUPPORT */
     42 #if defined(BCM_TRIDENT2_SUPPORT)
     43 #include <bcm_int/esw/trident2.h>
     44 #endif /* BCM_TRIDENT2_SUPPORT */
     45 #if defined(BCM_GREYHOUND_SUPPORT)
     46 #include <bcm_int/esw/greyhound.h>
     47 #endif /* BCM_GREYHOUND_SUPPORT */
     48 #if defined(BCM_TOMAHAWK_SUPPORT)
     49 #include <bcm_int/esw/tomahawk.h>
     50 #endif /* BCM_TOMAHAWK_SUPPORT */
     51 #ifdef BCM_KATANA2_SUPPORT
     52 #include <bcm_int/esw/katana2.h>
     53 #endif
     54 
     55 /* Initialize the QoS module. */
     56 int 
     57 bcm_esw_qos_init(int unit)
     58 {
     59     int rv = BCM_E_NONE;
     60 
     61 #if defined(BCM_TRX_SUPPORT)
     62     if (SOC_IS_TD2_TT2(unit) || SOC_IS_KATANA2(unit)) {
     63         port_tab_entry_t pent;
     64         bcm_port_t port;
     65         bcm_pbmp_t all_pbmp;
     66         uint32 dscp_index = 0;
     67 
     68         if (!SOC_WARM_BOOT(unit)) {
     69             uint32 dscp_map_entries[SOC_MAX_MEM_FIELD_WORDS];
     70             int  count = 0, i = 0;
     71             void *entries_buf[1];
     72             soc_mem_t mem;
     73 
     74             /* Create the default profile */
     75             sal_memset(dscp_map_entries, 0, sizeof(dscp_map_entries));
     76 
     77             entries_buf[0] = &dscp_map_entries;
     78             BCM_IF_ERROR_RETURN(
     79                 _bcm_dscp_table_entry_add(unit, entries_buf, 64, &dscp_index));
     80 
     81             count = 0;
     82             mem = SOC_IS_TRIDENT3X(unit) ? LPORT_TABm : PORT_TABm;
     83             soc_mem_lock(unit, mem);
     84 
     85             BCM_PBMP_CLEAR(all_pbmp);
     86             BCM_PBMP_ASSIGN(all_pbmp, PBMP_ALL(unit));
     87 #ifdef BCM_KATANA2_SUPPORT
     88             if (SOC_IS_KATANA2(unit) &&
     89                 soc_feature(unit, soc_feature_flex_port)) {
     90                 BCM_IF_ERROR_RETURN(
     91                     _bcm_kt2_flexio_pbmp_update(unit, &all_pbmp));
     92             }
     93             if (soc_feature(unit, soc_feature_linkphy_coe) ||
     94                 soc_feature(unit, soc_feature_subtag_coe)) {
     95                 _bcm_kt2_subport_pbmp_update(unit, &all_pbmp);
     96             }
     97 #endif
     98 
     99             PBMP_ITER(all_pbmp, port) {
    100                 if (IS_LB_PORT(unit, port)) {
    101                     continue;
    102                 }
    103 
    104                 if (SOC_IS_TRIDENT3X(unit)) {
    105                     rv = _bcm_esw_port_tab_set(unit, port,
    106                             _BCM_CPU_TABS_BOTH, TRUST_DSCP_PTRf,
    107                             dscp_index / 64);
    108                     if (BCM_FAILURE(rv)) {
    109                         soc_mem_unlock(unit, mem);
    110                         return rv;
    111                     }
    112                 } else {
    113                     /* Get profile index from port table. */
    114                     rv = soc_mem_read(unit, mem, MEM_BLOCK_ANY, port, &pent);
    115 
    116                     if (BCM_FAILURE(rv)) {
    117                         soc_mem_unlock(unit, mem);
    118                         return rv;
    119                     }
    120                     soc_mem_field32_set(unit, mem, &pent, TRUST_DSCP_PTRf,
    121                             dscp_index / 64);
    122                     rv = soc_mem_write(unit, mem, MEM_BLOCK_ALL, port, &pent);
    123 
    124                     if (BCM_FAILURE(rv)) {
    125                         soc_mem_unlock(unit, mem);
    126                         return rv;
    127                     }
    128                 }
    129                 count++;
    130             }
    131             soc_mem_unlock(unit, mem);
    132             for (i = 1; i < count; i++) {
    133                  BCM_IF_ERROR_RETURN(
    134                      _bcm_dscp_table_entry_reference(unit, dscp_index, 0));
    135             }
    136         } /* !SOC_WARM_BOOT  */
    137 #ifdef BCM_TOMAHAWK3_SUPPORT
    138         else if(SOC_IS_TOMAHAWK3(unit)) {
    139             /* In WarmBoot scenario update the profile table reference count */
    140             BCM_PBMP_CLEAR(all_pbmp);
    141             BCM_PBMP_ASSIGN(all_pbmp, PBMP_ALL(unit));
    142 
    143             PBMP_ITER(all_pbmp, port) {
    144                 if (IS_LB_PORT(unit, port)) {
    145                     continue;
    146                 }
    147                 SOC_IF_ERROR_RETURN(
    148                     soc_mem_read(unit, PORT_TABm, MEM_BLOCK_ALL, port, &pent));
    149                 dscp_index =
    150                   soc_mem_field32_get(unit, PORT_TABm, &pent, TRUST_DSCP_PTRf);
    151                 BCM_IF_ERROR_RETURN(
    152                     _bcm_dscp_table_entry_reference(unit, dscp_index * 64, 64));
    153             }
    154         }
    155 #endif /* BCM_TOMAHAWK3_SUPPORT */
    156     }
    157 #endif
    158 
    159 #if defined(BCM_TRIDENT2_SUPPORT)
    160     if (SOC_IS_TRIDENT2X(unit) || SOC_IS_TRIDENT3X(unit)) {
    161         rv = bcm_td2_qos_init(unit);
    162     }
    163 #endif
    164 
    165 #if defined(BCM_TOMAHAWK_SUPPORT)
    166     if (SOC_IS_TOMAHAWKX(unit) && !SOC_IS_TOMAHAWK3(unit)) {
    167         rv = bcm_th_qos_init(unit);
    168     }
    169 #endif
    170 #if defined(BCM_TRIUMPH2_SUPPORT)
    171     if (SOC_IS_TRIUMPH2(unit) || SOC_IS_APOLLO(unit) ||
    172         SOC_IS_VALKYRIE2(unit) || SOC_IS_ENDURO(unit) ||
    173         SOC_IS_TD_TT(unit) || SOC_IS_HURRICANEX(unit) ||
    174         SOC_IS_KATANAX(unit) || SOC_IS_TRIUMPH3(unit)||
    175         SOC_IS_GREYHOUND(unit) || SOC_IS_GREYHOUND2(unit)) {
    176 
    177         rv = bcm_tr2_qos_init(unit);
    178     }
    179 #endif
    180 #if defined(BCM_TRIUMPH_SUPPORT)
    181     if (SOC_IS_TRIUMPH(unit) || SOC_IS_VALKYRIE(unit)) {
    182         rv = bcm_tr_qos_init(unit);
    183     }
    184 #endif
    185 #if defined(BCM_TRIDENT_SUPPORT)
    186     if (SOC_IS_TD_TT(unit) || SOC_IS_KATANAX(unit) ||
    187         SOC_IS_TRIUMPH3(unit)) {
    188         soc_mem_t mem = EGR_MAP_MHm;
    189 
    190         if (soc_mem_is_valid(unit, mem)) {
    191             uint32 idx;
    192             uint8 *mbuf;
    193             egr_map_mh_entry_t *mapmh = NULL;
    194             uint32 min = soc_mem_index_min(unit, mem);
    195             uint32 max = soc_mem_index_max(unit, mem);
    196             int alloc_sz =
    197                 sizeof(egr_map_mh_entry_t) * soc_mem_index_count(unit, mem);
    198 
    199             /* Program the table */
    200             mbuf = soc_cm_salloc(unit, alloc_sz, SOC_MEM_NAME(unit, mem));
    201             if (NULL == mbuf) {
    202                 rv = BCM_E_MEMORY;
    203             }
    204             soc_mem_lock(unit, mem);
    205             if (BCM_SUCCESS(rv)) {
    206                 sal_memset(mbuf, 0, alloc_sz);
    207             }
    208             if (BCM_SUCCESS(rv)) {
    209                 for (idx = min; idx <= max; idx++) {
    210                     mapmh = soc_mem_table_idx_to_pointer(unit, mem,
    211                                              egr_map_mh_entry_t *, mbuf, idx);
    212                     soc_mem_field32_set(unit, mem, mapmh, HG_TCf, idx & 0xf);
    213                 }
    214             }
    215             if (BCM_SUCCESS(rv)) {
    216                 rv = soc_mem_write_range(unit, mem, MEM_BLOCK_ANY, min, max, mbuf);
    217             }
    218             soc_mem_unlock(unit, mem);
    219             if (mbuf != NULL) {
    220                 soc_cm_sfree(unit, mbuf);
    221             }
    222         }
    223     }
    224 #endif
    225 
    226 #if defined(BCM_GREYHOUND_SUPPORT)
    227     if (SOC_IS_GREYHOUND(unit)||SOC_IS_HURRICANE3(unit)||
    228         SOC_IS_GREYHOUND2(unit)) {
    229         rv = bcm_gh_qos_init(unit);
    230     }
    231 #endif
    232 #ifdef BCM_WARM_BOOT_SUPPORT
    233 #if defined BCM_KATANA2_SUPPORT || defined BCM_TRIDENT2_SUPPORT
    234     if ((SOC_IS_KATANA2(unit)) || SOC_IS_TRIDENT2X(unit) || SOC_IS_TRIDENT3X(unit)) {
    235         rv = _bcm_notify_qos_reinit_to_fp (unit);
    236     }
    237 #endif /* BCM_KATANA2_SUPPORT, BCM_TRIDENT2_SUPPORT */
    238 #endif /* BCM_WARM_BOOT_SUPPORT */
    239 
    240 
    241     return rv;
    242 }
    243 
    244 /* Detach the QoS module. */
    245 int 
    246 bcm_esw_qos_detach(int unit)
    247 {
    248     int rv = BCM_E_NONE;
    249 #if defined(BCM_TRIUMPH2_SUPPORT)
    250     if (SOC_IS_TRIUMPH2(unit) || SOC_IS_APOLLO(unit) ||
    251         SOC_IS_VALKYRIE2(unit) || SOC_IS_ENDURO(unit) ||
    252         SOC_IS_TD_TT(unit) || SOC_IS_HURRICANEX(unit) ||
    253         SOC_IS_KATANAX(unit) || SOC_IS_TRIUMPH3(unit)||
    254         SOC_IS_GREYHOUND(unit) || SOC_IS_GREYHOUND2(unit)) {
    255         rv = bcm_tr2_qos_detach(unit);
    256     }
    257 #endif
    258 #if defined(BCM_TRIUMPH_SUPPORT)
    259     if (SOC_IS_TRIUMPH(unit) || SOC_IS_VALKYRIE(unit)) {
    260         rv = bcm_tr_qos_detach(unit);
    261     }
    262 #endif
    263 #if defined(BCM_TRIDENT2_SUPPORT)
    264     if (SOC_IS_TRIDENT2(unit) || SOC_IS_TRIDENT3X(unit)) {
    265         rv = bcm_td2_qos_detach(unit);
    266     }
    267 #endif
    268 
    269 #if defined(BCM_GREYHOUND_SUPPORT)
    270     if (SOC_IS_GREYHOUND(unit)||SOC_IS_HURRICANE3(unit)||
    271         SOC_IS_GREYHOUND2(unit)) {
    272         rv = bcm_gh_qos_detach(unit);
    273     }
    274 #endif
    275 #if defined(BCM_TOMAHAWK_SUPPORT)
    276     if (SOC_IS_TOMAHAWKX(unit) && !SOC_IS_TOMAHAWK3(unit)) {
    277         rv = bcm_th_qos_detach(unit);
    278     }
    279 #endif
    280 
    281 
    282     return rv;
    283 }
    284 
    285 /* Create a QoS map profile */
    286 int 
    287 bcm_esw_qos_map_create(int unit, uint32 flags, int *map_id)
    288 {
    289     int rv = BCM_E_UNAVAIL;
    290 
    291 #if defined(BCM_HURRICANE_SUPPORT)
    292     /* For HurricaneX/Greyhound, there is no support for MPLS and L3 */
    293     if ((SOC_IS_HURRICANEX(unit) || SOC_IS_GREYHOUND(unit)) &&
    294         ((flags & BCM_QOS_MAP_MPLS) || (flags & BCM_QOS_MAP_L3))) {
    295         return rv;
    296     }
    297 #endif /* BCM_HURRICANE_SUPPORT */
    298 
    299 #if defined(BCM_GREYHOUND2_SUPPORT)
    300     /*
    301      * For Greyhound2, there is no support for MPLS.
    302      * For L3, it only supports egress DSCP mapping for VXLAN tunnel support.
    303      */
    304     if (SOC_IS_GREYHOUND2(unit)) {
    305         if (flags & BCM_QOS_MAP_MPLS) {
    306             return rv;
    307         }
    308         /* GH2-B0 support ingress DSCP mapping for VXLAN-RIOT */
    309         if (!soc_feature(unit, soc_feature_vxlan_lite_riot)) {
    310             if ((flags & BCM_QOS_MAP_L3) && (flags & BCM_QOS_MAP_INGRESS)) {
    311                 return rv;
    312             }
    313         }
    314     }
    315 #endif /* BCM_GREYHOUND2_SUPPORT */
    316 
    317 #ifdef BCM_TRIDENT2_SUPPORT
    318     if ((QOS_FLAGS_ARE_FCOE(flags) || (flags & BCM_QOS_MAP_L2_VLAN_ETAG)) 
    319         && (SOC_IS_TRIDENT2X(unit) || SOC_IS_TRIDENT3X(unit))) {
    320         return bcm_td2_qos_map_create(unit, flags, map_id);
    321     }
    322 #endif
    323 
    324 #ifdef BCM_GREYHOUND_SUPPORT
    325     if ((flags & BCM_QOS_MAP_L2_VLAN_ETAG) 
    326         && (SOC_IS_GREYHOUND(unit)||SOC_IS_HURRICANE3(unit)||
    327             SOC_IS_GREYHOUND2(unit))) {
    328         return bcm_gh_qos_map_create(unit, flags, map_id);
    329     }
    330 #endif
    331 
    332 #if defined(BCM_TOMAHAWK_SUPPORT)
    333     if ((flags & BCM_QOS_MAP_L2_VLAN_ETAG) &&
    334         SOC_IS_TOMAHAWKX(unit)) {
    335         if (SOC_IS_TOMAHAWK3(unit)) {
    336             /* TH3 does not support L2 VLAN ETAG */
    337             return rv;
    338         } else {
    339             return bcm_th_qos_map_create(unit, flags, map_id);
    340         }
    341     }
    342 #endif
    343 
    344 #if defined(BCM_TRIUMPH2_SUPPORT)
    345     if (SOC_IS_TRIUMPH2(unit) || SOC_IS_APOLLO(unit) ||
    346         SOC_IS_VALKYRIE2(unit) || SOC_IS_ENDURO(unit) ||
    347         SOC_IS_TD_TT(unit) || SOC_IS_HURRICANEX(unit) ||
    348         SOC_IS_KATANAX(unit) || SOC_IS_TRIUMPH3(unit)||
    349         SOC_IS_GREYHOUND(unit) || SOC_IS_GREYHOUND2(unit)) {
    350         rv = bcm_tr2_qos_map_create(unit, flags, map_id);
    351     }
    352 #endif
    353 #if defined(BCM_TRIUMPH_SUPPORT)
    354     if (SOC_IS_TRIUMPH(unit) || SOC_IS_VALKYRIE(unit)) {
    355         rv = bcm_tr_qos_map_create(unit, flags, map_id);
    356     }
    357 #endif
    358     return rv;
    359 }
    360 
    361 /* Destroy a QoS map profile */
    362 int 
    363 bcm_esw_qos_map_destroy(int unit, int map_id)
    364 {
    365     int rv = BCM_E_UNAVAIL;
    366 #ifdef BCM_TRIDENT2_SUPPORT
    367     if ((SOC_IS_TRIDENT2X(unit) || SOC_IS_TRIDENT3X(unit))
    368          && (QOS_MAP_IS_FCOE(map_id) || QOS_MAP_IS_L2_VLAN_ETAG(map_id))) {
    369         return bcm_td2_qos_map_destroy(unit, map_id);
    370     }
    371 #endif
    372 #ifdef BCM_GREYHOUND_SUPPORT
    373     if ((SOC_IS_GREYHOUND(unit)||SOC_IS_HURRICANE3(unit) ||
    374         SOC_IS_GREYHOUND2(unit))&& 
    375         QOS_MAP_IS_L2_VLAN_ETAG(map_id)) {
    376         return bcm_gh_qos_map_destroy(unit, map_id);
    377     }
    378 #endif
    379 #ifdef BCM_TOMAHAWK_SUPPORT
    380     if (SOC_IS_TOMAHAWKX(unit)&& QOS_MAP_IS_L2_VLAN_ETAG(map_id)) {
    381         if (SOC_IS_TOMAHAWK3(unit)) {
    382             /* TH3 does not support L2 VLAN ETAG */
    383             return rv;
    384         } else {
    385             return bcm_th_qos_map_destroy(unit, map_id);
    386         }
    387     }
    388 #endif
    389 #if defined(BCM_TRIUMPH2_SUPPORT)
    390     if (SOC_IS_TRIUMPH2(unit) || SOC_IS_APOLLO(unit) ||
    391         SOC_IS_VALKYRIE2(unit) || SOC_IS_ENDURO(unit) ||
    392         SOC_IS_TD_TT(unit) || SOC_IS_HURRICANEX(unit) ||
    393         SOC_IS_KATANAX(unit) || SOC_IS_TRIUMPH3(unit)||
    394         SOC_IS_GREYHOUND(unit) || SOC_IS_GREYHOUND2(unit)) {
    395         rv = bcm_tr2_qos_map_destroy(unit, map_id);
    396     }
    397 #endif
    398 #if defined(BCM_TRIUMPH_SUPPORT)
    399     if (SOC_IS_TRIUMPH(unit) || SOC_IS_VALKYRIE(unit)) {
    400         rv = bcm_tr_qos_map_destroy(unit, map_id);
    401     }
    402 #endif
    403     return rv;
    404 }
    405 
    406 /* Add an entry to a QoS map */
    407 int 
    408 bcm_esw_qos_map_add(int unit, uint32 flags, bcm_qos_map_t *map, int map_id)
    409 {
    410     int rv = BCM_E_UNAVAIL;
    411 #ifdef BCM_TRIDENT2_SUPPORT
    412     if ((SOC_IS_TRIDENT2X(unit)|| SOC_IS_TRIDENT3X(unit))&& 
    413         (QOS_MAP_IS_FCOE(map_id)|| QOS_MAP_IS_L2_VLAN_ETAG(map_id))) {
    414         return bcm_td2_qos_map_add(unit, flags, map, map_id);
    415     }
    416 #endif
    417 #ifdef BCM_GREYHOUND_SUPPORT
    418     if ((SOC_IS_GREYHOUND(unit)||SOC_IS_HURRICANE3(unit)||
    419         SOC_IS_GREYHOUND2(unit))&& 
    420         QOS_MAP_IS_L2_VLAN_ETAG(map_id)) {
    421         return bcm_gh_qos_map_add(unit, flags, map, map_id);
    422     }
    423 #endif
    424 #ifdef BCM_TOMAHAWK_SUPPORT
    425     if (SOC_IS_TOMAHAWKX(unit)&& QOS_MAP_IS_L2_VLAN_ETAG(map_id)) {
    426         if (SOC_IS_TOMAHAWK3(unit)) {
    427             /* TH3 does not support L2 VLAN ETAG */
    428             return rv;
    429         } else {
    430             return bcm_th_qos_map_add(unit, flags, map, map_id);
    431         }
    432     }
    433 #endif
    434 #if defined(BCM_TRIUMPH2_SUPPORT)
    435     if (SOC_IS_TRIUMPH2(unit) || SOC_IS_APOLLO(unit) ||
    436         SOC_IS_VALKYRIE2(unit) || SOC_IS_ENDURO(unit) ||
    437         SOC_IS_TD_TT(unit) || SOC_IS_HURRICANEX(unit) ||
    438         SOC_IS_KATANAX(unit) || SOC_IS_TRIUMPH3(unit)||
    439         SOC_IS_GREYHOUND(unit) || SOC_IS_GREYHOUND2(unit)) {
    440         rv = bcm_tr2_qos_map_add(unit, flags, map, map_id, 0);
    441     }
    442 #endif
    443 #if defined(BCM_TRIUMPH_SUPPORT)
    444     if (SOC_IS_TRIUMPH(unit) || SOC_IS_VALKYRIE(unit)) {
    445         rv = bcm_tr_qos_map_add(unit, flags, map, map_id);
    446     }
    447 #endif
    448     return rv;
    449 }
    450 
    451 /* bcm_esw_qos_map_multi_get */
    452 int
    453 bcm_esw_qos_map_multi_get(int unit, uint32 flags,
    454                           int map_id, int array_size, 
    455                           bcm_qos_map_t *array, int *array_count)
    456 {
    457     int rv = BCM_E_UNAVAIL;
    458 
    459 #ifdef BCM_TRIDENT2_SUPPORT
    460     if ((SOC_IS_TRIDENT2X(unit)|| SOC_IS_TRIDENT3X(unit))
    461         && (QOS_MAP_IS_L2_VLAN_ETAG(map_id) ||
    462             QOS_MAP_IS_FCOE(map_id))) {
    463         return bcm_td2_qos_map_multi_get(unit, flags, map_id, array_size, array, 
    464                                        array_count);
    465     }
    466 #endif
    467 
    468 #ifdef BCM_GREYHOUND_SUPPORT
    469     if ((SOC_IS_GREYHOUND(unit)||SOC_IS_HURRICANE3(unit)||
    470         SOC_IS_GREYHOUND2(unit))&& 
    471         QOS_MAP_IS_L2_VLAN_ETAG(map_id)) {
    472         return bcm_gh_qos_map_multi_get(unit, flags, map_id, array_size, array, 
    473                                        array_count);
    474     }
    475 #endif
    476 
    477 #ifdef BCM_TOMAHAWK_SUPPORT
    478     if (SOC_IS_TOMAHAWKX(unit)&& QOS_MAP_IS_L2_VLAN_ETAG(map_id)) {
    479         if (SOC_IS_TOMAHAWK3(unit)) {
    480             /* TH3 does not support L2 VLAN ETAG */
    481             return rv;
    482         } else {
    483             return bcm_th_qos_map_multi_get(unit, flags, map_id,
    484                                     array_size, array, array_count);
    485         }
    486     }
    487 #endif
    488     
    489 #if defined(BCM_TRIUMPH2_SUPPORT)
    490     if (SOC_IS_TRIUMPH2(unit) || SOC_IS_APOLLO(unit) ||
    491         SOC_IS_VALKYRIE2(unit) || SOC_IS_ENDURO(unit) ||
    492         SOC_IS_TD_TT(unit) || SOC_IS_HURRICANEX(unit) ||
    493         SOC_IS_KATANAX(unit) || SOC_IS_TRIUMPH3(unit)||
    494         SOC_IS_GREYHOUND(unit) || SOC_IS_GREYHOUND2(unit)) {
    495         rv = bcm_tr2_qos_map_multi_get(unit, flags, map_id, array_size, array, 
    496                                        array_count);
    497     }
    498 #endif
    499 #if defined(BCM_TRIUMPH_SUPPORT)
    500     if (SOC_IS_TRIUMPH(unit) || SOC_IS_VALKYRIE(unit)) {
    501         rv = bcm_tr_qos_map_multi_get(unit, flags, map_id, array_size, array, 
    502                                        array_count);
    503     }
    504 #endif
    505     return rv;
    506 }
    507 
    508 /* Clear an entry from a QoS map */
    509 int 
    510 bcm_esw_qos_map_delete(int unit, uint32 flags, bcm_qos_map_t *map, int map_id)
    511 {
    512     int rv = BCM_E_UNAVAIL;
    513 #ifdef BCM_TRIDENT2_SUPPORT
    514     if ((SOC_IS_TRIDENT2X(unit)|| SOC_IS_TRIDENT3X(unit))&& 
    515         (QOS_MAP_IS_FCOE(map_id) || QOS_MAP_IS_L2_VLAN_ETAG(map_id))) {
    516         return bcm_td2_qos_map_delete(unit, flags, map, map_id);
    517     }
    518 #endif
    519 #ifdef BCM_GREYHOUND_SUPPORT
    520     if ((SOC_IS_GREYHOUND(unit)||SOC_IS_HURRICANE3(unit)||
    521         SOC_IS_GREYHOUND2(unit))&& 
    522         QOS_MAP_IS_L2_VLAN_ETAG(map_id)) {
    523         return bcm_gh_qos_map_delete(unit, flags, map, map_id);
    524     }
    525 #endif
    526 #ifdef BCM_TOMAHAWK_SUPPORT
    527     if (SOC_IS_TOMAHAWKX(unit)&& QOS_MAP_IS_L2_VLAN_ETAG(map_id)) {
    528         if (SOC_IS_TOMAHAWK3(unit)) {
    529             /* TH3 does not support L2 VLAN ETAG */
    530             return rv;
    531         } else {
    532             return bcm_th_qos_map_delete(unit, flags, map, map_id);
    533         }
    534     }
    535 #endif
    536 #if defined(BCM_TRIUMPH2_SUPPORT)
    537     if (SOC_IS_TRIUMPH2(unit) || SOC_IS_APOLLO(unit) ||
    538         SOC_IS_VALKYRIE2(unit) || SOC_IS_ENDURO(unit) ||
    539         SOC_IS_TD_TT(unit) || SOC_IS_HURRICANEX(unit) ||
    540         SOC_IS_KATANAX(unit) || SOC_IS_TRIUMPH3(unit)||
    541         SOC_IS_GREYHOUND(unit) || SOC_IS_GREYHOUND2(unit)) {
    542         rv = bcm_tr2_qos_map_delete(unit, flags, map, map_id);
    543     }
    544 #endif
    545 #if defined(BCM_TRIUMPH_SUPPORT)
    546     if (SOC_IS_TRIUMPH(unit) || SOC_IS_VALKYRIE(unit)) {
    547         rv = bcm_tr_qos_map_delete(unit, flags, map, map_id);
    548     }
    549 #endif
    550     return rv;
    551 }
    552 
    553 /* Attach a QoS map to an object (Gport) */
    554 int 
    555 bcm_esw_qos_port_map_set(int unit, bcm_gport_t port, int ing_map, int egr_map)
    556 {
    557     int rv = BCM_E_UNAVAIL;
    558 #ifdef BCM_TRIDENT2_SUPPORT
    559     if ((SOC_IS_TRIDENT2X(unit) || SOC_IS_TRIDENT3X(unit))
    560         && (QOS_MAP_IS_FCOE(ing_map) || QOS_MAP_IS_L2_VLAN_ETAG(ing_map) 
    561         || QOS_MAP_IS_FCOE(egr_map))) {
    562         return bcm_td2_qos_port_map_set(unit, port, ing_map, egr_map);
    563     }
    564 #endif
    565 #ifdef BCM_GREYHOUND_SUPPORT
    566     if ((SOC_IS_GREYHOUND(unit)||SOC_IS_HURRICANE3(unit)||
    567         SOC_IS_GREYHOUND2(unit))
    568         && (QOS_MAP_IS_L2_VLAN_ETAG(ing_map) || QOS_MAP_IS_L2_VLAN_ETAG(egr_map))) {
    569         return bcm_gh_qos_port_map_set(unit, port, ing_map, egr_map);
    570     }
    571 #endif
    572 #ifdef BCM_TOMAHAWK_SUPPORT
    573     if (SOC_IS_TOMAHAWKX(unit) &&
    574         (QOS_MAP_IS_L2_VLAN_ETAG(ing_map) ||
    575         QOS_MAP_IS_L2_VLAN_ETAG(egr_map))) {
    576         if (SOC_IS_TOMAHAWK3(unit)) {
    577             /* TH3 does not support L2 VLAN ETAG */
    578             return BCM_E_PARAM;
    579         } else {
    580             return bcm_th_qos_port_map_set(unit, port, ing_map, egr_map);
    581         }
    582     }
    583 #endif
    584 #if defined(BCM_TRIUMPH2_SUPPORT)
    585     if (SOC_IS_TRIUMPH2(unit) || SOC_IS_APOLLO(unit) ||
    586         SOC_IS_VALKYRIE2(unit) || SOC_IS_ENDURO(unit) ||
    587         SOC_IS_TD_TT(unit) || SOC_IS_HURRICANEX(unit) ||
    588         SOC_IS_KATANAX(unit) || SOC_IS_TRIUMPH3(unit)||
    589         SOC_IS_GREYHOUND(unit) || SOC_IS_GREYHOUND2(unit)) {
    590 
    591         rv = bcm_tr2_qos_port_map_set(unit, port, ing_map, egr_map);
    592     }
    593 #endif
    594 #if defined(BCM_TRIUMPH_SUPPORT)
    595     if (SOC_IS_TRIUMPH(unit) || SOC_IS_VALKYRIE(unit)) {
    596         rv = bcm_tr_qos_port_map_set(unit, port, ing_map, egr_map);
    597     }
    598 #endif
    599     return rv;
    600 }
    601 
    602 
    603 /* bcm_qos_port_map_type_get*/
    604 int
    605 bcm_esw_qos_port_map_type_get(int unit, bcm_gport_t port, uint32 flags,
    606                           int *map_id)
    607 {
    608     int rv = BCM_E_UNAVAIL;
    609 
    610 #ifdef BCM_TRIDENT2_SUPPORT
    611     if ((SOC_IS_TRIDENT2X(unit) || SOC_IS_TRIDENT3X(unit))
    612         && (QOS_FLAGS_ARE_FCOE(flags) || (flags & BCM_QOS_MAP_L2_VLAN_ETAG))) {
    613        
    614         return bcm_td2_qos_port_map_type_get(unit, port, flags, map_id);
    615     }
    616 #endif
    617 
    618 #ifdef BCM_TOMAHAWK_SUPPORT
    619     if (SOC_IS_TOMAHAWKX(unit) &&
    620         (flags & BCM_QOS_MAP_L2_VLAN_ETAG)) {
    621         if (SOC_IS_TOMAHAWK3(unit)) {
    622             /* TH3 does not support L2 VLAN ETAG */
    623             return rv;
    624         } else {
    625             return bcm_th_qos_port_map_type_get(unit, port, flags, map_id);
    626         }
    627     }
    628 #endif
    629 
    630 #if defined(BCM_TRIUMPH2_SUPPORT)
    631     if (SOC_IS_TRIUMPH2(unit) || SOC_IS_APOLLO(unit) ||
    632         SOC_IS_VALKYRIE2(unit) || SOC_IS_ENDURO(unit) ||
    633         SOC_IS_TD_TT(unit) || SOC_IS_HURRICANEX(unit) ||
    634         SOC_IS_KATANAX(unit) || SOC_IS_TRIUMPH3(unit)||
    635         SOC_IS_GREYHOUND(unit)) {
    636 
    637         rv = bcm_tr2_qos_port_map_type_get(unit, port, flags, map_id);
    638     }
    639 #endif
    640 
    641 
    642     return rv;
    643 }
    644 
    645 
    646 /* bcm_qos_port_map_get */
    647 int
    648 bcm_esw_qos_port_map_get(int unit, bcm_gport_t port, 
    649                          int *ing_map, int *egr_map)
    650 {
    651     return BCM_E_UNAVAIL;
    652 }
    653 
    654 /* bcm_qos_port_vlan_map_set */
    655 int
    656 bcm_esw_qos_port_vlan_map_set(int unit,  bcm_port_t port, bcm_vlan_t vid,
    657                               int ing_map, int egr_map)
    658 {
    659     int rv = BCM_E_UNAVAIL;
    660     
    661 #if defined(BCM_TRIUMPH2_SUPPORT)
    662     if ( SOC_IS_KATANAX(unit) || SOC_IS_TRIUMPH3(unit) || SOC_IS_TD_TT(unit) || \
    663          SOC_IS_GREYHOUND(unit) || SOC_IS_HURRICANE3(unit) || \
    664          SOC_IS_HURRICANE2(unit) || SOC_IS_GREYHOUND2(unit)) {
    665         rv = bcm_tr2_qos_port_vlan_map_set(unit, port, vid, ing_map, egr_map);
    666     }
    667 #endif
    668 
    669     return rv;
    670 }
    671 
    672 /* bcm_qos_port_vlan_map_get */
    673 int
    674 bcm_esw_qos_port_vlan_map_get(int unit, bcm_port_t port, bcm_vlan_t vid,
    675                               int *ing_map, int *egr_map)
    676 {
    677     int rv = BCM_E_UNAVAIL;
    678     
    679 #if defined(BCM_TRIUMPH2_SUPPORT)
    680     if ( SOC_IS_KATANAX(unit) || SOC_IS_TRIUMPH3(unit) || SOC_IS_TD_TT(unit) || \
    681          SOC_IS_GREYHOUND(unit) || SOC_IS_HURRICANE3(unit) || \
    682          SOC_IS_HURRICANE2(unit) || SOC_IS_GREYHOUND2(unit)) {
    683         rv = bcm_tr2_qos_port_vlan_map_get(unit, port, vid, ing_map, egr_map);
    684     }
    685 #endif
    686     return rv;
    687 
    688 }
    689 
    690 /* bcm_qos_multi_get */
    691 int
    692 bcm_esw_qos_multi_get(int unit, int array_size, int *map_ids_array, 
    693                       int *flags_array, int *array_count)
    694 {
    695     int rv = BCM_E_UNAVAIL;
    696 #if defined(BCM_TRIUMPH2_SUPPORT)
    697     if (SOC_IS_TRIUMPH2(unit) || SOC_IS_APOLLO(unit) ||
    698         SOC_IS_VALKYRIE2(unit) || SOC_IS_ENDURO(unit) ||
    699         SOC_IS_TD_TT(unit) || SOC_IS_HURRICANEX(unit) ||
    700         SOC_IS_KATANAX(unit) || SOC_IS_TRIUMPH3(unit)||
    701         SOC_IS_GREYHOUND(unit) || SOC_IS_GREYHOUND2(unit)) {
    702         rv = bcm_tr2_qos_multi_get(unit, array_size, map_ids_array, 
    703                                    flags_array, array_count);
    704     }
    705 #endif
    706 #if defined(BCM_TRIUMPH_SUPPORT)
    707     if (SOC_IS_TRIUMPH(unit) || SOC_IS_VALKYRIE(unit)) {
    708         rv = bcm_tr_qos_multi_get(unit, array_size, map_ids_array, 
    709                                    flags_array, array_count);
    710     }
    711 #endif
    712     return rv;
    713 }
    714 
    715 #ifdef BCM_WARM_BOOT_SUPPORT
    716 int
    717 _bcm_esw_qos_sync(int unit)
    718 {
    719     int rv = BCM_E_UNAVAIL;
    720 #if defined(BCM_TRIUMPH2_SUPPORT)
    721     if (SOC_IS_TRIUMPH2(unit) || SOC_IS_APOLLO(unit) ||
    722         SOC_IS_VALKYRIE2(unit) || SOC_IS_ENDURO(unit) ||
    723         SOC_IS_TD_TT(unit) || SOC_IS_HURRICANEX(unit) ||
    724         SOC_IS_KATANAX(unit) || SOC_IS_TRIUMPH3(unit)||
    725         SOC_IS_GREYHOUND(unit) || SOC_IS_GREYHOUND2(unit)) {
    726         rv = _bcm_tr2_qos_sync(unit);
    727     }
    728 #endif
    729 #if defined(BCM_TRIUMPH_SUPPORT)
    730     if (SOC_IS_TRIUMPH(unit) || SOC_IS_VALKYRIE(unit)) {
    731         rv = _bcm_tr_qos_sync(unit);
    732     }
    733 #endif
    734     return rv;
    735 }
    736 #endif /* BCM_WARM_BOOT_SUPPORT */
    737 
    738 #ifdef BCM_WARM_BOOT_SUPPORT_SW_DUMP
    739 void
    740 _bcm_esw_qos_sw_dump(int unit)
    741 {
    742 #if defined(BCM_TRIUMPH2_SUPPORT)
    743     if (SOC_IS_TRIUMPH2(unit) || SOC_IS_APOLLO(unit) ||
    744         SOC_IS_VALKYRIE2(unit) || SOC_IS_ENDURO(unit) ||
    745         SOC_IS_TD_TT(unit) || SOC_IS_HURRICANEX(unit) ||
    746         SOC_IS_KATANAX(unit) || SOC_IS_TRIUMPH3(unit)||
    747         SOC_IS_GREYHOUND(unit) || SOC_IS_GREYHOUND2(unit)) {
    748         _bcm_tr2_qos_sw_dump(unit);
    749     }
    750 #endif
    751 #if defined(BCM_TRIUMPH_SUPPORT)
    752     if (SOC_IS_TRIUMPH(unit) || SOC_IS_VALKYRIE(unit)) {
    753         _bcm_tr_qos_sw_dump(unit);
    754     }
    755 #endif
    756 #if defined (BCM_TRIDENT2_SUPPORT)
    757     if (SOC_IS_TRIDENT2X(unit)) {
    758         _bcm_td2_qos_sw_dump(unit);
    759     }
    760 #endif
    761 #if defined(BCM_TOMAHAWK_SUPPORT)
    762     if (SOC_IS_TOMAHAWKX(unit) && !SOC_IS_TOMAHAWK3(unit)) {
    763         _bcm_th_qos_sw_dump(unit);
    764     }
    765 #endif
    766 }
    767 #endif /* BCM_WARM_BOOT_SUPPORT_SW_DUMP */