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

oam.c (93498B)


      1 /*
      2  * 
      3  * 
      4  * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
      5  * 
      6  * Copyright 2007-2019 Broadcom Inc. All rights reserved.
      7  */
      8 
      9 #include <soc/defs.h>
     10 #include <soc/drv.h>
     11 
     12 #include <bcm/oam.h>
     13 #include <bcm/trunk.h>
     14 #include <bcm/error.h>
     15 #include <bcm/field.h>
     16 #include <bcm_int/esw/oam.h>
     17 #include <bcm_int/esw_dispatch.h>
     18 #include <shared/bslenum.h>
     19 #include <shared/bsl.h>
     20 
     21 #if defined(BCM_TRIUMPH2_SUPPORT) || defined(BCM_APOLLO_SUPPORT) || \
     22     defined(BCM_VALKYRIE2_SUPPORT)
     23 #include <bcm_int/esw/triumph2.h>
     24 #endif
     25 
     26 #if defined(BCM_TRIUMPH2_SUPPORT)
     27 #include <bcm_int/esw/triumph3.h>
     28 #endif
     29 
     30 #if defined(BCM_ENDURO_SUPPORT)
     31 #include <bcm_int/esw/enduro.h>
     32 #endif
     33 
     34 #if defined(BCM_TRIUMPH3_SUPPORT)
     35 #include <bcm_int/esw/triumph3.h>
     36 #endif
     37 
     38 #if defined(BCM_KATANA2_SUPPORT)
     39 #include <bcm_int/esw/katana2.h>
     40 #endif
     41 #if defined(BCM_TRIDENT2PLUS_SUPPORT)
     42 #include <bcm_int/esw/trident2plus.h>
     43 #endif
     44 
     45 #if defined (BCM_SABER2_SUPPORT)
     46 #include <bcm_int/esw/saber2.h>
     47 #endif
     48 
     49 #if defined (BCM_MONTEREY_SUPPORT)
     50 #include <bcm_int/esw/apache.h>
     51 #endif
     52 
     53 #if defined (BCM_APACHE_SUPPORT)
     54 #include <bcm_int/esw/apache.h>
     55 #endif
     56 
     57 #if defined (BCM_METROLITE_SUPPORT)
     58 #include <bcm_int/esw/metrolite.h>
     59 #endif
     60 
     61 /*
     62  * Macro:
     63  *     _BCM_OAM_ALLOC
     64  * Purpose:
     65  *      Generic memory allocation routine.
     66  * Parameters:
     67  *    _ptr_     - Pointer to allocated memory.
     68  *    _ptype_   - Pointer type.
     69  *    _size_    - Size of heap memory to be allocated.
     70  *    _descr_   - Information about this memory allocation.
     71  */
     72 #define _BCM_OAM_ALLOC(_ptr_,_ptype_,_size_,_descr_)                     \
     73             do {                                                         \
     74                 if (NULL == (_ptr_)) {                                   \
     75                    (_ptr_) = (_ptype_ *) sal_alloc((_size_), (_descr_)); \
     76                 }                                                        \
     77                 if((_ptr_) != NULL) {                                    \
     78                     sal_memset((_ptr_), 0, (_size_));                    \
     79                 }  else {                                                \
     80                     LOG_ERROR(BSL_LS_BCM_OAM, \
     81                               (BSL_META("OAM Error: Allocation failure %s\n"), \
     82                                (_descr_)));                              \
     83                 }                                                        \
     84             } while (0)
     85 
     86 static sal_mutex_t mutex[BCM_MAX_NUM_UNITS];
     87 
     88 int bcm_esw_oam_lock(int unit)
     89 {
     90     if (mutex[unit] == NULL)
     91     {
     92         return BCM_E_INIT;
     93     }
     94 
     95     sal_mutex_take(mutex[unit], sal_mutex_FOREVER);
     96 
     97     return BCM_E_NONE;
     98 }
     99 
    100 int bcm_esw_oam_unlock(int unit)
    101 {
    102     if (mutex[unit] == NULL)
    103     {
    104         return BCM_E_INIT;
    105     }
    106 
    107     if (sal_mutex_give(mutex[unit]) != 0)
    108     {
    109         return BCM_E_INTERNAL;
    110     }
    111 
    112     return BCM_E_NONE;
    113 }
    114 
    115 /*
    116  * Function:
    117  *      bcm_esw_oam_init
    118  * Purpose:
    119  *      Initialize the OAM subsystem
    120  * Parameters:
    121  *      unit - (IN) Unit number.
    122  * result =s:
    123  *      BCM_E_XXX
    124  * Notes:
    125  */
    126 int 
    127 bcm_esw_oam_init(int unit)
    128 {
    129     int result = BCM_E_UNAVAIL;
    130 
    131 #if defined(BCM_TRIUMPH2_SUPPORT) || defined(BCM_APOLLO_SUPPORT) || \
    132     defined(BCM_VALKYRIE2_SUPPORT)
    133     if (soc_feature(unit, soc_feature_oam))
    134     {
    135 #if defined(BCM_TRIUMPH3_SUPPORT) || defined(BCM_HURRICANE2_SUPPORT) ||\
    136     defined(BCM_GREYHOUND_SUPPORT)
    137         if ((SOC_IS_TRIUMPH3(unit)) || SOC_IS_HURRICANE2(unit) ||
    138             SOC_IS_GREYHOUND(unit) || SOC_IS_HURRICANE3(unit) ||
    139             SOC_IS_GREYHOUND2(unit)) {
    140             result = bcm_tr3_oam_init(unit);
    141         } else
    142 #endif
    143 /* KT2 OAM */
    144 #if defined(BCM_KATANA2_SUPPORT)
    145             if (SOC_IS_SABER2(unit)) {
    146 #if defined (BCM_SABER2_SUPPORT)
    147                 return bcm_sb2_oam_init(unit);
    148 #endif
    149             } else if (SOC_IS_KATANA2(unit)) {
    150                 result = bcm_kt2_oam_init(unit);
    151             }else
    152 #endif
    153         {
    154             if (mutex[unit] == NULL)
    155             {
    156                 mutex[unit] = sal_mutex_create("oam.mutex");
    157 
    158                 if (mutex[unit] == NULL)
    159                 {
    160                     return BCM_E_MEMORY;
    161                 }
    162             }
    163 #if defined(BCM_ENDURO_SUPPORT)
    164             if (SOC_IS_ENDURO(unit) || SOC_IS_KATANAX(unit))
    165             {
    166                 result = bcm_en_oam_init(unit);
    167             } else
    168 #endif
    169             {
    170                 result = bcm_tr2x_oam_init(unit);
    171             }
    172 
    173             if (BCM_FAILURE(result))
    174             {
    175                 sal_mutex_destroy(mutex[unit]);
    176 
    177                 mutex[unit] = NULL;
    178             }
    179         }
    180     }
    181 #endif
    182 #if defined(BCM_TRIDENT2PLUS_SUPPORT)
    183     if(soc_feature(unit, soc_feature_fp_based_oam)) {
    184         result = bcm_td2p_oam_init(unit);
    185     }
    186 #endif
    187     return result;
    188 }
    189 
    190 /*
    191  * Function:
    192  *      bcm_esw_oam_detach
    193  * Purpose:
    194  *      Shut down the OAM subsystem
    195  * Parameters:
    196  *      unit - (IN) Unit number.
    197  * result =s:
    198  *      BCM_E_XXX
    199  * Notes:
    200  */
    201 int 
    202 bcm_esw_oam_detach(int unit)
    203 {
    204     int result = BCM_E_UNAVAIL;
    205 
    206 #if defined(BCM_TRIUMPH2_SUPPORT) || defined(BCM_APOLLO_SUPPORT) || \
    207     defined(BCM_VALKYRIE2_SUPPORT)
    208     if (soc_feature(unit, soc_feature_oam))
    209     {
    210 #if defined(BCM_TRIUMPH3_SUPPORT) || defined(BCM_HURRICANE2_SUPPORT) ||\
    211 	defined(BCM_GREYHOUND_SUPPORT)
    212         if ((SOC_IS_TRIUMPH3(unit)) || SOC_IS_HURRICANE2(unit) ||
    213 	     SOC_IS_GREYHOUND(unit) || SOC_IS_HURRICANE3(unit) ||
    214 	     SOC_IS_GREYHOUND2(unit)) {
    215             result = bcm_tr3_oam_detach(unit);
    216         } else
    217 #endif
    218 /* KT2 OAM */
    219 #if defined(BCM_KATANA2_SUPPORT)
    220         if (SOC_IS_KATANA2(unit)) {
    221             if (SOC_IS_SABER2(unit)) {
    222 #if defined (BCM_SABER2_SUPPORT)
    223                 result = bcm_sb2_oam_detach(unit);
    224 #endif
    225             }else if (SOC_IS_KATANA2(unit)) {
    226                 result = bcm_kt2_oam_detach(unit);
    227             }
    228         } else
    229 #endif
    230         {
    231             if (mutex[unit] == NULL)
    232             {
    233                 return BCM_E_NONE;
    234             }
    235 
    236             BCM_IF_ERROR_RETURN(bcm_esw_oam_lock(unit));
    237 
    238 #if defined(BCM_ENDURO_SUPPORT)
    239             if (SOC_IS_ENDURO(unit) || SOC_IS_KATANAX(unit))
    240             {
    241                 result = bcm_en_oam_detach(unit);
    242             } else
    243 #endif
    244             {
    245                 result = bcm_tr2x_oam_detach(unit);
    246             }
    247 
    248             BCM_IF_ERROR_RETURN(bcm_esw_oam_unlock(unit));
    249 
    250             sal_mutex_destroy(mutex[unit]);
    251 
    252             mutex[unit] = NULL;
    253         }
    254     }
    255 #endif
    256 
    257 #if defined(BCM_TRIDENT2PLUS_SUPPORT)
    258     if(soc_feature(unit, soc_feature_fp_based_oam)) {
    259 #if defined (INCLUDE_CCM) || defined (INCLUDE_BHH) || defined(INCLUDE_MPLS_LM_DM)
    260         result = bcm_fp_oam_detach(unit);
    261 #endif /* INCLUDE_CCM || INCLUDE_BHH || INCLUDE_MPLS_LM_DM */
    262     }
    263 #endif
    264     return result;
    265 }
    266 
    267 /*
    268  * Function:
    269  *      bcm_esw_oam_group_create
    270  * Purpose:
    271  *      Create or replace an OAM group object
    272  * Parameters:
    273  *      unit - (IN) Unit number.
    274  *      group_info - (IN/OUT) Pointer to an OAM group structure
    275  * result =s:
    276  *      BCM_E_XXX
    277  * Notes:
    278  */
    279 int 
    280 bcm_esw_oam_group_create(
    281     int unit, 
    282     bcm_oam_group_info_t *group_info)
    283 {
    284     int result = BCM_E_UNAVAIL;
    285 
    286     if (NULL == group_info) {
    287         /* Input parameter check. */
    288         return (BCM_E_PARAM);
    289     }
    290 
    291 #if defined(INCLUDE_CCM) || defined(INCLUDE_BHH)
    292 #if defined(BCM_TRIDENT2PLUS_SUPPORT)
    293     if (soc_feature(unit, soc_feature_fp_based_oam) && 
    294         (soc_feature(unit, soc_feature_uc_ccm) || 
    295          soc_feature(unit, soc_feature_bhh)))
    296     {
    297         result = bcm_fp_oam_group_create(unit, group_info);
    298     }
    299 #endif
    300 #endif
    301 #if defined(BCM_TRIUMPH2_SUPPORT) || defined(BCM_APOLLO_SUPPORT) || \
    302     defined(BCM_VALKYRIE2_SUPPORT)
    303     if (soc_feature(unit, soc_feature_oam))
    304     {
    305         /* Check if alarm priority value is in valid range. */
    306         if ((group_info->lowest_alarm_priority
    307                 < bcmOAMGroupFaultAlarmPriorityDefectsAll)
    308             || (group_info->lowest_alarm_priority
    309                 > bcmOAMGroupFaultAlarmPriorityDefectsNone)) 
    310         {
    311             return BCM_E_PARAM;
    312         }
    313 
    314 #if defined(BCM_TRIUMPH3_SUPPORT) || defined(BCM_HURRICANE2_SUPPORT)
    315         if ((SOC_IS_TRIUMPH3(unit)) || SOC_IS_HURRICANE2(unit) ||
    316 	     SOC_IS_GREYHOUND(unit) || SOC_IS_HURRICANE3(unit) ||
    317 	     SOC_IS_GREYHOUND2(unit)) {
    318             result = bcm_tr3_oam_group_create(unit, group_info);
    319         } else
    320 #endif
    321 #if defined(BCM_KATANA2_SUPPORT)
    322         if(SOC_IS_SABER2(unit)) {
    323 #if defined (BCM_SABER2_SUPPORT)
    324             result = bcm_sb2_oam_group_create(unit, group_info);
    325 #endif
    326         }
    327         else if (SOC_IS_KATANA2(unit)) {
    328             result = bcm_kt2_oam_group_create(unit, group_info);
    329         } else
    330 #endif
    331         {
    332             BCM_IF_ERROR_RETURN(bcm_esw_oam_lock(unit));
    333 
    334 #if defined(BCM_ENDURO_SUPPORT)
    335         if (SOC_IS_ENDURO(unit) || SOC_IS_KATANAX(unit))
    336         {
    337             result = bcm_en_oam_group_create(unit, group_info);
    338         } else
    339 #endif
    340             {
    341                 result = bcm_tr2x_oam_group_create(unit, group_info);
    342             }
    343 
    344             BCM_IF_ERROR_RETURN(bcm_esw_oam_unlock(unit));
    345         }
    346     }
    347 #endif
    348 
    349     return result;
    350 }
    351 
    352 /*
    353  * Function:
    354  *      bcm_esw_oam_group_get
    355  * Purpose:
    356  *      Get an OAM group object
    357  * Parameters:
    358  *      unit - (IN) Unit number.
    359  *      group - (IN) The ID of the group object to get
    360  *      group_info - (OUT) Pointer to an OAM group structure to receive the data
    361  * result =s:
    362  *      BCM_E_XXX
    363  * Notes:
    364  */
    365 int 
    366 bcm_esw_oam_group_get(
    367     int unit, 
    368     bcm_oam_group_t group, 
    369     bcm_oam_group_info_t *group_info)
    370 {
    371     int result = BCM_E_UNAVAIL;
    372 
    373     if (NULL == group_info) {
    374         /* Input parameter check. */
    375         return (BCM_E_PARAM);
    376     }
    377 
    378 #if defined(INCLUDE_CCM) || defined(INCLUDE_BHH)
    379 #if defined(BCM_TRIDENT2PLUS_SUPPORT)
    380     if (soc_feature(unit, soc_feature_fp_based_oam) && 
    381         (soc_feature(unit, soc_feature_uc_ccm) || 
    382          soc_feature(unit, soc_feature_bhh)))
    383     {
    384         result = bcm_fp_oam_group_get(unit, group, group_info);
    385     }
    386 #endif
    387 #endif
    388 #if defined(BCM_TRIUMPH2_SUPPORT) || defined(BCM_APOLLO_SUPPORT) || \
    389     defined(BCM_VALKYRIE2_SUPPORT)
    390     if (soc_feature(unit, soc_feature_oam))
    391     {
    392 
    393 #if defined(BCM_TRIUMPH3_SUPPORT) || defined(BCM_HURRICANE2_SUPPORT)
    394         if ((SOC_IS_TRIUMPH3(unit)) || SOC_IS_HURRICANE2(unit) || 
    395             SOC_IS_GREYHOUND(unit) || SOC_IS_HURRICANE3(unit) ||
    396             SOC_IS_GREYHOUND2(unit)) {
    397             result = bcm_tr3_oam_group_get(unit, group, group_info);
    398         } else
    399 #endif
    400 /* KT2 OAM  */
    401 #if defined(BCM_KATANA2_SUPPORT)
    402         if (SOC_IS_KATANA2(unit)) {
    403             if (SOC_IS_SABER2(unit)) {
    404 #if defined (BCM_SABER2_SUPPORT)
    405                 result = bcm_sb2_oam_group_get(unit, group, group_info);
    406 #endif
    407             } else if (SOC_IS_KATANA2(unit)) {
    408                 result = bcm_kt2_oam_group_get(unit, group, group_info);
    409             }
    410         } else
    411 #endif
    412         {
    413             BCM_IF_ERROR_RETURN(bcm_esw_oam_lock(unit));
    414 #if defined(BCM_ENDURO_SUPPORT)
    415             if (SOC_IS_ENDURO(unit) || SOC_IS_KATANAX(unit))
    416             {
    417                 result = bcm_en_oam_group_get(unit, group, group_info);
    418             } else
    419 #endif
    420             {
    421                 result = bcm_tr2x_oam_group_get(unit, group, group_info);
    422             }
    423 
    424             BCM_IF_ERROR_RETURN(bcm_esw_oam_unlock(unit));
    425         }
    426     }
    427 #endif
    428 
    429     return result;
    430 }
    431 
    432 /*
    433  * Function:
    434  *      bcm_esw_oam_group_destroy
    435  * Purpose:
    436  *      Destroy an OAM group object.  All OAM endpoints associated
    437  *      with the group will also be destroyed.
    438  * Parameters:
    439  *      unit - (IN) Unit number.
    440  *      group - (IN) The ID of the OAM group object to destroy
    441  * result =s:
    442  *      BCM_E_XXX
    443  * Notes:
    444  */
    445 int 
    446 bcm_esw_oam_group_destroy(
    447     int unit, 
    448     bcm_oam_group_t group)
    449 {
    450     int result = BCM_E_UNAVAIL;
    451 #if defined(INCLUDE_CCM) || defined(INCLUDE_BHH)
    452 #if defined(BCM_TRIDENT2PLUS_SUPPORT)
    453     if (soc_feature(unit, soc_feature_fp_based_oam) && 
    454         (soc_feature(unit, soc_feature_uc_ccm) || 
    455          soc_feature(unit, soc_feature_bhh)))
    456     {
    457         result = bcm_fp_oam_group_destroy(unit, group);
    458     }
    459 #endif
    460 #endif
    461 #if defined(BCM_TRIUMPH2_SUPPORT) || defined(BCM_APOLLO_SUPPORT) || \
    462     defined(BCM_VALKYRIE2_SUPPORT)
    463     if (soc_feature(unit, soc_feature_oam))
    464     {
    465 
    466 #if defined(BCM_TRIUMPH3_SUPPORT) || defined(BCM_HURRICANE2_SUPPORT)
    467         if ((SOC_IS_TRIUMPH3(unit)) || SOC_IS_HURRICANE2(unit) ||
    468             SOC_IS_GREYHOUND(unit) || SOC_IS_HURRICANE3(unit) ||
    469             SOC_IS_GREYHOUND2(unit)) {
    470             result = bcm_tr3_oam_group_destroy(unit, group);
    471         } else
    472 #endif
    473 /* KT2 OAM  */
    474 #if defined(BCM_KATANA2_SUPPORT)
    475         if (SOC_IS_KATANA2(unit)) {
    476             if (SOC_IS_SABER2(unit)) {
    477 #if defined (BCM_SABER2_SUPPORT)
    478                 result = bcm_sb2_oam_group_destroy(unit, group);
    479 #endif
    480             } else if (SOC_IS_KATANA2(unit)) {
    481                 result = bcm_kt2_oam_group_destroy(unit, group);
    482             }
    483         } else
    484 #endif
    485         {
    486             BCM_IF_ERROR_RETURN(bcm_esw_oam_lock(unit));
    487 #if defined(BCM_ENDURO_SUPPORT)
    488             if (SOC_IS_ENDURO(unit) || SOC_IS_KATANAX(unit))
    489             {
    490                 result = bcm_en_oam_group_destroy(unit, group);
    491             } else
    492 #endif
    493             {
    494                 result = bcm_tr2x_oam_group_destroy(unit, group);
    495             }
    496 
    497             BCM_IF_ERROR_RETURN(bcm_esw_oam_unlock(unit));
    498         }
    499     }
    500 #endif
    501 
    502     return result;
    503 }
    504 
    505 /*
    506  * Function:
    507  *      bcm_esw_oam_group_destroy_all
    508  * Purpose:
    509  *      Destroy all OAM group objects.  All OAM endpoints will also be
    510  *      destroyed.
    511  * Parameters:
    512  *      unit - (IN) Unit number.
    513  * result =s:
    514  *      BCM_E_XXX
    515  * Notes:
    516  */
    517 int 
    518 bcm_esw_oam_group_destroy_all(
    519     int unit)
    520 {
    521     int result = BCM_E_UNAVAIL;
    522 #if defined(INCLUDE_CCM) || defined(INCLUDE_BHH)
    523 #if defined(BCM_TRIDENT2PLUS_SUPPORT)
    524     if (soc_feature(unit, soc_feature_fp_based_oam) && 
    525         (soc_feature(unit, soc_feature_bhh)))
    526     {
    527         result = bcm_fp_oam_group_destroy_all(unit);
    528     }
    529 #endif
    530 #endif
    531 #if defined(BCM_TRIUMPH2_SUPPORT) || defined(BCM_APOLLO_SUPPORT) || \
    532     defined(BCM_VALKYRIE2_SUPPORT)
    533     if (soc_feature(unit, soc_feature_oam))
    534     {
    535 #if defined(BCM_TRIUMPH3_SUPPORT) || defined(BCM_HURRICANE2_SUPPORT)
    536         if ((SOC_IS_TRIUMPH3(unit)) || SOC_IS_HURRICANE2(unit) ||
    537             SOC_IS_GREYHOUND(unit) || SOC_IS_HURRICANE3(unit) ||
    538             SOC_IS_GREYHOUND2(unit)) {
    539             result = bcm_tr3_oam_group_destroy_all(unit);
    540         } else
    541 #endif
    542 /* KT2 OAM */
    543 #if defined(BCM_KATANA2_SUPPORT)
    544         if (SOC_IS_KATANA2(unit)) {
    545             if (SOC_IS_SABER2(unit)) {
    546 #if defined (BCM_SABER2_SUPPORT)
    547                 result = bcm_sb2_oam_group_destroy_all(unit);
    548 #endif
    549             } else if (SOC_IS_KATANA2(unit)) {
    550                 result = bcm_kt2_oam_group_destroy_all(unit);
    551             }
    552         } else
    553 #endif
    554         {
    555             BCM_IF_ERROR_RETURN(bcm_esw_oam_lock(unit));
    556 
    557 #if defined(BCM_ENDURO_SUPPORT)
    558         if (SOC_IS_ENDURO(unit) || SOC_IS_KATANAX(unit))
    559         {
    560             result = bcm_en_oam_group_destroy_all(unit);
    561         } else
    562 #endif
    563             {
    564                 result = bcm_tr2x_oam_group_destroy_all(unit);
    565             }
    566 
    567             BCM_IF_ERROR_RETURN(bcm_esw_oam_unlock(unit));
    568         }
    569     }
    570 #endif
    571 
    572     return result;
    573 }
    574 
    575 /*
    576  * Function:
    577  *      bcm_esw_oam_group_traverse
    578  * Purpose:
    579  *      Traverse the entire set of OAM groups, calling a specified
    580  *      callback for each one
    581  * Parameters:
    582  *      unit - (IN) Unit number.
    583  *      cb - (IN) A pointer to the callback function to call for each OAM group
    584  *      user_data - (IN) Pointer to user data to supply in the callback
    585  * result =s:
    586  *      BCM_E_XXX
    587  * Notes:
    588  */
    589 int 
    590 bcm_esw_oam_group_traverse(
    591     int unit, 
    592     bcm_oam_group_traverse_cb cb, 
    593     void *user_data)
    594 {
    595     int result = BCM_E_UNAVAIL;
    596 #if defined(INCLUDE_CCM) || defined(INCLUDE_BHH)
    597 #if defined(BCM_TRIDENT2PLUS_SUPPORT)
    598     if (soc_feature(unit, soc_feature_fp_based_oam) && 
    599         (soc_feature(unit, soc_feature_uc_ccm) || 
    600          soc_feature(unit, soc_feature_bhh)))
    601     {
    602         result = bcm_fp_oam_group_traverse(unit, cb, user_data);
    603     }
    604 #endif
    605 #endif
    606 #if defined(BCM_TRIUMPH2_SUPPORT) || defined(BCM_APOLLO_SUPPORT) || \
    607     defined(BCM_VALKYRIE2_SUPPORT)
    608     if (soc_feature(unit, soc_feature_oam))
    609     {
    610 
    611 #if defined(BCM_TRIUMPH3_SUPPORT) || defined(BCM_HURRICANE2_SUPPORT)
    612         if ((SOC_IS_TRIUMPH3(unit)) || SOC_IS_HURRICANE2(unit)||
    613              SOC_IS_GREYHOUND(unit) || SOC_IS_HURRICANE3(unit) ||
    614              SOC_IS_GREYHOUND2(unit)) {
    615             result = bcm_tr3_oam_group_traverse(unit, cb, user_data);
    616         } else
    617 #endif
    618 /* KT2 OAM  */
    619 #if defined(BCM_KATANA2_SUPPORT)
    620         if (SOC_IS_KATANA2(unit)) {
    621             if (SOC_IS_SABER2(unit)) {
    622 #if defined (BCM_SABER2_SUPPORT)
    623                 result = bcm_sb2_oam_group_traverse(unit, cb, user_data);
    624 #endif
    625             } else if (SOC_IS_KATANA2(unit)) {
    626                 result = bcm_kt2_oam_group_traverse(unit, cb, user_data);
    627             }
    628         } else 
    629 #endif
    630         {
    631             BCM_IF_ERROR_RETURN(bcm_esw_oam_lock(unit));
    632 #if defined(BCM_ENDURO_SUPPORT)
    633             if (SOC_IS_ENDURO(unit) || SOC_IS_KATANAX(unit))
    634             {
    635                 result = bcm_en_oam_group_traverse(unit, cb, user_data);
    636             } else
    637 #endif
    638             {
    639                 result = bcm_tr2x_oam_group_traverse(unit, cb, user_data);
    640             }
    641 
    642             BCM_IF_ERROR_RETURN(bcm_esw_oam_unlock(unit));
    643         }
    644     }
    645 #endif
    646 
    647     return result;
    648 }
    649 
    650 /*
    651  * Function:
    652  *      bcm_esw_oam_endpoint_create
    653  * Purpose:
    654  *      Create or replace an OAM endpoint object
    655  * Parameters:
    656  *      unit - (IN) Unit number.
    657  *      endpoint_info - (IN/OUT) Pointer to an OAM endpoint structure
    658  * result =s:
    659  *      BCM_E_XXX
    660  * Notes:
    661  */
    662 int 
    663 bcm_esw_oam_endpoint_create(
    664     int unit, 
    665     bcm_oam_endpoint_info_t *endpoint_info)
    666 {
    667     int result = BCM_E_UNAVAIL;
    668 
    669     if (NULL == endpoint_info) {
    670         /* Input parameter check. */
    671         return (BCM_E_PARAM);
    672     }
    673 #if defined(INCLUDE_CCM) || defined(INCLUDE_BHH) || defined(INCLUDE_MPLS_LM_DM)
    674 #if defined(BCM_TRIDENT2PLUS_SUPPORT)
    675     if (soc_feature(unit, soc_feature_fp_based_oam) &&
    676         (soc_feature(unit, soc_feature_uc_ccm) ||
    677          soc_feature(unit, soc_feature_bhh)    ||
    678          soc_feature(unit, soc_feature_mpls_lm_dm)))
    679     {
    680         result = bcm_fp_oam_endpoint_create(unit, endpoint_info);
    681     }
    682 #endif /* BCM_TRIDENT2PLUS_SUPPORT */
    683 #endif /* INCLUDE_CCM || INCLUDE_BHH || INCLUDE_MPLS_LM_DM */
    684 
    685 #if defined(BCM_TRIUMPH2_SUPPORT) || defined(BCM_APOLLO_SUPPORT) || \
    686     defined(BCM_VALKYRIE2_SUPPORT)
    687     if (soc_feature(unit, soc_feature_oam))
    688     {
    689 
    690 #if defined(BCM_TRIUMPH3_SUPPORT) || defined(BCM_HURRICANE2_SUPPORT)
    691         if ((SOC_IS_TRIUMPH3(unit)) || SOC_IS_HURRICANE2(unit)
    692             || SOC_IS_GREYHOUND(unit) || SOC_IS_HURRICANE3(unit)
    693             || SOC_IS_GREYHOUND2(unit)) {
    694             result = bcm_tr3_oam_endpoint_create(unit, endpoint_info);
    695         } else
    696 #endif
    697 /* KT2 OAM */
    698 #if defined(BCM_KATANA2_SUPPORT)
    699         if(SOC_IS_SABER2(unit)){
    700 #if defined (BCM_SABER2_SUPPORT)
    701             result = bcm_sb2_oam_endpoint_create(unit, endpoint_info);
    702 #endif
    703         }
    704         else if (SOC_IS_KATANA2(unit)) {
    705             result = bcm_kt2_oam_endpoint_create(unit, endpoint_info);
    706         } else
    707 #endif
    708         {
    709             BCM_IF_ERROR_RETURN(bcm_esw_oam_lock(unit));
    710 #if defined(BCM_ENDURO_SUPPORT)
    711             if (SOC_IS_ENDURO(unit) || SOC_IS_KATANAX(unit))
    712             {
    713                 result = bcm_en_oam_endpoint_create(unit, endpoint_info);
    714             } else
    715 #endif
    716             {
    717                 result = bcm_tr2x_oam_endpoint_create(unit, endpoint_info);
    718             }
    719 
    720             BCM_IF_ERROR_RETURN(bcm_esw_oam_unlock(unit));
    721         }
    722     }
    723 #endif
    724 
    725     return result;
    726 }
    727 
    728 /*
    729  * Function:
    730  *      bcm_esw_oam_endpoint_get
    731  * Purpose:
    732  *      Get an OAM endpoint object
    733  * Parameters:
    734  *      unit - (IN) Unit number.
    735  *      endpoint - (IN) The ID of the endpoint object to get
    736  *      endpoint_info - (OUT) Pointer to an OAM endpoint structure to receive the data
    737  * result =s:
    738  *      BCM_E_XXX
    739  * Notes:
    740  */
    741 int 
    742 bcm_esw_oam_endpoint_get(
    743     int unit, 
    744     bcm_oam_endpoint_t endpoint, 
    745     bcm_oam_endpoint_info_t *endpoint_info)
    746 {
    747     int result = BCM_E_UNAVAIL;
    748 
    749     if (NULL == endpoint_info) {
    750         /* Input parameter check. */
    751         return (BCM_E_PARAM);
    752     }
    753 
    754 #if defined(INCLUDE_CCM) || defined(INCLUDE_BHH) || defined(INCLUDE_MPLS_LM_DM)
    755 #if defined(BCM_TRIDENT2PLUS_SUPPORT)
    756     if (soc_feature(unit, soc_feature_fp_based_oam) &&
    757         (soc_feature(unit, soc_feature_uc_ccm) ||
    758          soc_feature(unit, soc_feature_bhh)    ||
    759          soc_feature(unit, soc_feature_mpls_lm_dm)))
    760     {
    761         result = bcm_fp_oam_endpoint_get(unit, endpoint, endpoint_info);
    762     }
    763 #endif /* BCM_TRIDENT2PLUS_SUPPORT */
    764 #endif /* INCLUDE_CCM || INCLUDE_BHH || INCLUDE_MPLS_LM_DM */
    765 
    766 #if defined(BCM_TRIUMPH2_SUPPORT) || defined(BCM_APOLLO_SUPPORT) || \
    767     defined(BCM_VALKYRIE2_SUPPORT)
    768     if (soc_feature(unit, soc_feature_oam))
    769     {
    770 
    771 #if defined(BCM_TRIUMPH3_SUPPORT) || defined(BCM_HURRICANE2_SUPPORT)
    772         if ((SOC_IS_TRIUMPH3(unit)) || SOC_IS_HURRICANE2(unit)||
    773             SOC_IS_GREYHOUND(unit) || SOC_IS_HURRICANE3(unit) ||
    774             SOC_IS_GREYHOUND2(unit)) {
    775             result = bcm_tr3_oam_endpoint_get(unit, endpoint, endpoint_info);
    776         } else
    777 #endif
    778 /* KT2 OAM */
    779 #if defined(BCM_KATANA2_SUPPORT)
    780         if (SOC_IS_KATANA2(unit)) {
    781             if (SOC_IS_SABER2(unit)) {
    782 #if defined (BCM_SABER2_SUPPORT)
    783                 result = bcm_sb2_oam_endpoint_get(unit, endpoint, endpoint_info);
    784 #endif
    785             } else if (SOC_IS_KATANA2(unit)) {
    786                 result = bcm_kt2_oam_endpoint_get(unit, endpoint, endpoint_info);
    787             }
    788         } else
    789 #endif
    790         {
    791             BCM_IF_ERROR_RETURN(bcm_esw_oam_lock(unit));
    792 #if defined(BCM_ENDURO_SUPPORT)
    793             if (SOC_IS_ENDURO(unit) || SOC_IS_KATANAX(unit))
    794             {
    795                 result = bcm_en_oam_endpoint_get(unit, endpoint, endpoint_info);
    796             } else
    797 #endif
    798             {
    799                 result = bcm_tr2x_oam_endpoint_get(unit, endpoint, endpoint_info);
    800             }
    801             BCM_IF_ERROR_RETURN(bcm_esw_oam_unlock(unit));
    802         }
    803     }
    804 #endif
    805 
    806     return result;
    807 }
    808 
    809 /*
    810  * Function:
    811  *      bcm_esw_oam_endpoint_destroy
    812  * Purpose:
    813  *      Destroy an OAM endpoint object
    814  * Parameters:
    815  *      unit - (IN) Unit number.
    816  *      endpoint - (IN) The ID of the OAM endpoint object to destroy
    817  * result =s:
    818  *      BCM_E_XXX
    819  * Notes:
    820  */
    821 int 
    822 bcm_esw_oam_endpoint_destroy(
    823     int unit, 
    824     bcm_oam_endpoint_t endpoint)
    825 {
    826     int result = BCM_E_UNAVAIL;
    827 
    828 #if defined(INCLUDE_CCM) || defined(INCLUDE_BHH) || defined(INCLUDE_MPLS_LM_DM)
    829 #if defined(BCM_TRIDENT2PLUS_SUPPORT)
    830     if (soc_feature(unit, soc_feature_fp_based_oam) &&
    831         (soc_feature(unit, soc_feature_uc_ccm) ||
    832          soc_feature(unit, soc_feature_bhh)    ||
    833          soc_feature(unit, soc_feature_mpls_lm_dm)))
    834     {
    835         result = bcm_fp_oam_endpoint_destroy(unit, endpoint);
    836     }
    837 #endif /* BCM_TRIDENT2PLUS_SUPPORT */
    838 #endif /* INCLUDE_CCM || INCLUDE_BHH || INCLUDE_MPLS_LM_DM */
    839 
    840 #if defined(BCM_TRIUMPH2_SUPPORT) || defined(BCM_APOLLO_SUPPORT) || \
    841     defined(BCM_VALKYRIE2_SUPPORT)
    842     if (soc_feature(unit, soc_feature_oam))
    843     {
    844 #if defined(BCM_TRIUMPH3_SUPPORT) || defined(BCM_HURRICANE2_SUPPORT)
    845         if ((SOC_IS_TRIUMPH3(unit)) || SOC_IS_HURRICANE2(unit) ||
    846              SOC_IS_GREYHOUND(unit) || SOC_IS_HURRICANE3(unit) ||
    847              SOC_IS_GREYHOUND2(unit)) {
    848             result = bcm_tr3_oam_endpoint_destroy(unit, endpoint);
    849         } else
    850 #endif
    851 /* KT2 OAM */
    852 #if defined(BCM_KATANA2_SUPPORT)
    853         if (SOC_IS_KATANA2(unit)) {
    854             if (SOC_IS_SABER2(unit)) {
    855 #if defined (BCM_SABER2_SUPPORT)
    856                 result = bcm_sb2_oam_endpoint_destroy(unit, endpoint);
    857 #endif
    858             } else if (SOC_IS_KATANA2(unit)) {
    859                 result = bcm_kt2_oam_endpoint_destroy(unit, endpoint);
    860             }
    861         } else
    862 #endif
    863         {
    864             BCM_IF_ERROR_RETURN(bcm_esw_oam_lock(unit));
    865 #if defined(BCM_ENDURO_SUPPORT)
    866             if (SOC_IS_ENDURO(unit) || SOC_IS_KATANAX(unit))
    867             {
    868                 result = bcm_en_oam_endpoint_destroy(unit, endpoint);
    869             } else
    870 #endif
    871             {
    872                 result = bcm_tr2x_oam_endpoint_destroy(unit, endpoint);
    873             }
    874 
    875             BCM_IF_ERROR_RETURN(bcm_esw_oam_unlock(unit));
    876         }
    877     }
    878 #endif
    879 
    880     return result;
    881 }
    882 
    883 /*
    884  * Function:
    885  *      bcm_esw_oam_endpoint_destroy_all
    886  * Purpose:
    887  *      Destroy all OAM endpoint objects associated with a given OAM
    888  *      group
    889  * Parameters:
    890  *      unit - (IN) Unit number.
    891  *      group - (IN) The OAM group whose endpoints should be destroyed
    892  * result =s:
    893  *      BCM_E_XXX
    894  * Notes:
    895  */
    896 int 
    897 bcm_esw_oam_endpoint_destroy_all(
    898     int unit, 
    899     bcm_oam_group_t group)
    900 {
    901     int result = BCM_E_UNAVAIL;
    902 
    903 #if defined(INCLUDE_CCM) || defined(INCLUDE_BHH)
    904 #if defined(BCM_TRIDENT2PLUS_SUPPORT)
    905     if (soc_feature(unit, soc_feature_fp_based_oam) && 
    906         (soc_feature(unit, soc_feature_bhh)))
    907     {
    908         result = bcm_fp_oam_endpoint_destroy_all(unit, group);
    909     }
    910 #endif
    911 #endif
    912 #if defined(BCM_TRIUMPH2_SUPPORT) || defined(BCM_APOLLO_SUPPORT) || \
    913     defined(BCM_VALKYRIE2_SUPPORT)
    914     if (soc_feature(unit, soc_feature_oam))
    915     {
    916 #if defined(BCM_TRIUMPH3_SUPPORT) || defined(BCM_HURRICANE2_SUPPORT)
    917         if ((SOC_IS_TRIUMPH3(unit)) || SOC_IS_HURRICANE2(unit)||
    918              SOC_IS_GREYHOUND(unit) || SOC_IS_HURRICANE3(unit) ||
    919              SOC_IS_GREYHOUND2(unit)) {
    920             result = bcm_tr3_oam_endpoint_destroy_all(unit, group);
    921         } else
    922 #endif
    923 /* KT2 OAM */
    924 #if defined(BCM_KATANA2_SUPPORT)
    925         if (SOC_IS_KATANA2(unit)) {
    926             if (SOC_IS_SABER2(unit)) {
    927 #if defined (BCM_SABER2_SUPPORT)
    928                 result = bcm_sb2_oam_endpoint_destroy_all(unit, group);
    929 #endif
    930             } else if (SOC_IS_KATANA2(unit)) {
    931                 result = bcm_kt2_oam_endpoint_destroy_all(unit, group);
    932             }
    933         } else
    934 #endif
    935         {
    936             BCM_IF_ERROR_RETURN(bcm_esw_oam_lock(unit));
    937 
    938 #if defined(BCM_ENDURO_SUPPORT)
    939             if (SOC_IS_ENDURO(unit) || SOC_IS_KATANAX(unit))
    940             {
    941                 result = bcm_en_oam_endpoint_destroy_all(unit, group);
    942             } else
    943 #endif
    944             {
    945                 result = bcm_tr2x_oam_endpoint_destroy_all(unit, group);
    946             }
    947 
    948             BCM_IF_ERROR_RETURN(bcm_esw_oam_unlock(unit));
    949         }
    950     }
    951 #endif
    952 
    953     return result;
    954 }
    955 
    956 /*
    957  * Function:
    958  *      bcm_esw_oam_endpoint_traverse
    959  * Purpose:
    960  *      Traverse the set of OAM endpoints associated with the
    961  *      specified group, calling a specified callback for each one
    962  * Parameters:
    963  *      unit - (IN) Unit number.
    964  *      group - (IN) The OAM group whose endpoints should be traversed
    965  *      cb - (IN) A pointer to the callback function to call for each OAM endpoint in the specified group
    966  *      user_data - (IN) Pointer to user data to supply in the callback
    967  * result =s:
    968  *      BCM_E_XXX
    969  * Notes:
    970  */
    971 int 
    972 bcm_esw_oam_endpoint_traverse(
    973     int unit, 
    974     bcm_oam_group_t group, 
    975     bcm_oam_endpoint_traverse_cb cb, 
    976     void *user_data)
    977 {
    978     int result = BCM_E_UNAVAIL;
    979 #if defined(INCLUDE_CCM) || defined(INCLUDE_BHH)
    980 #if defined(BCM_TRIDENT2PLUS_SUPPORT)
    981     if ((soc_feature(unit, soc_feature_fp_based_oam) && (soc_feature(unit, soc_feature_bhh)))
    982         || (soc_feature(unit, soc_feature_uc_ccm)))
    983     {
    984         result = bcm_fp_oam_endpoint_traverse(unit, group, cb, user_data);
    985     }
    986 #endif
    987 #endif
    988 #if defined(BCM_TRIUMPH2_SUPPORT) || defined(BCM_APOLLO_SUPPORT) || \
    989     defined(BCM_VALKYRIE2_SUPPORT)
    990     if (soc_feature(unit, soc_feature_oam))
    991     {
    992 #if defined(BCM_TRIUMPH3_SUPPORT) || defined(BCM_HURRICANE2_SUPPORT)
    993         if ((SOC_IS_TRIUMPH3(unit)) || SOC_IS_HURRICANE2(unit) ||
    994              SOC_IS_GREYHOUND(unit) || SOC_IS_HURRICANE3(unit) ||
    995              SOC_IS_GREYHOUND2(unit)) {
    996             result = bcm_tr3_oam_endpoint_traverse(unit, group, cb, user_data);
    997         } else
    998 #endif
    999 /* KT2 OAM */
   1000 #if defined(BCM_KATANA2_SUPPORT)
   1001         if (SOC_IS_KATANA2(unit)) {
   1002             if (SOC_IS_SABER2(unit)) {
   1003 #if defined (BCM_SABER2_SUPPORT)
   1004                 result = bcm_sb2_oam_endpoint_traverse(unit, group, cb, user_data);
   1005 #endif
   1006             } else if (SOC_IS_KATANA2(unit)) {
   1007                 result = bcm_kt2_oam_endpoint_traverse(unit, group, cb, user_data);
   1008             }
   1009         } else
   1010 #endif
   1011         {
   1012             BCM_IF_ERROR_RETURN(bcm_esw_oam_lock(unit));
   1013 
   1014 #if defined(BCM_ENDURO_SUPPORT)
   1015             if (SOC_IS_ENDURO(unit) || SOC_IS_KATANAX(unit))
   1016             {
   1017                 result = bcm_en_oam_endpoint_traverse(unit, group, cb, user_data);
   1018             } else
   1019 #endif
   1020             {
   1021                 result = bcm_tr2x_oam_endpoint_traverse(unit, group, cb, user_data);
   1022             }
   1023 
   1024             BCM_IF_ERROR_RETURN(bcm_esw_oam_unlock(unit));
   1025         }
   1026     }
   1027 #endif
   1028 
   1029     return result;
   1030 }
   1031 
   1032 /*
   1033  * Function:
   1034  *      bcm_esw_oam_event_register
   1035  * Purpose:
   1036  *      Register a callback for handling OAM events
   1037  * Parameters:
   1038  *      unit - (IN) Unit number.
   1039  *      event_types - (IN) The set of OAM events for which the specified callback should be called
   1040  *      cb - (IN) A pointer to the callback function to call for the specified OAM events
   1041  *      user_data - (IN) Pointer to user data to supply in the callback
   1042  * result =s:
   1043  *      BCM_E_XXX
   1044  * Notes:
   1045  */
   1046 int 
   1047 bcm_esw_oam_event_register(
   1048     int unit, 
   1049     bcm_oam_event_types_t event_types, 
   1050     bcm_oam_event_cb cb, 
   1051     void *user_data)
   1052 {
   1053     int result = BCM_E_UNAVAIL;
   1054 
   1055 #if defined(INCLUDE_CCM) || defined(INCLUDE_BHH) || defined(INCLUDE_MPLS_LM_DM)
   1056 #if defined(BCM_TRIDENT2PLUS_SUPPORT)
   1057     if (soc_feature(unit, soc_feature_fp_based_oam) &&
   1058         (soc_feature(unit, soc_feature_uc_ccm) ||
   1059          soc_feature(unit, soc_feature_bhh)    ||
   1060          soc_feature(unit, soc_feature_mpls_lm_dm)))
   1061     {
   1062         result = bcm_fp_oam_event_register(unit, event_types, cb, user_data);
   1063     }
   1064 #endif /* BCM_TRIDENT2PLUS_SUPPORT */
   1065 #endif /* INCLUDE_CCM || INCLUDE_BHH || INCLUDE_MPLS_LM_DM */
   1066 
   1067 #if defined(BCM_TRIUMPH2_SUPPORT) || defined(BCM_APOLLO_SUPPORT) || \
   1068     defined(BCM_VALKYRIE2_SUPPORT)
   1069     if (soc_feature(unit, soc_feature_oam))
   1070     {
   1071 #if defined(BCM_TRIUMPH3_SUPPORT) || defined(BCM_HURRICANE2_SUPPORT)
   1072         if ((SOC_IS_TRIUMPH3(unit)) || SOC_IS_HURRICANE2(unit)||
   1073              SOC_IS_GREYHOUND(unit) || SOC_IS_HURRICANE3(unit) ||
   1074              SOC_IS_GREYHOUND2(unit)) {
   1075             result = bcm_tr3_oam_event_register(unit, event_types, cb, user_data);
   1076         } else
   1077 #endif
   1078 /* KT2 OAM */
   1079 #if defined(BCM_KATANA2_SUPPORT)
   1080         if (SOC_IS_KATANA2(unit)) {
   1081             if (SOC_IS_SABER2(unit)) {
   1082 #if defined (BCM_SABER2_SUPPORT)
   1083                 result = bcm_sb2_oam_event_register(unit, event_types, cb, user_data);
   1084 #endif
   1085             } else if (SOC_IS_KATANA2(unit)) {
   1086                 result = bcm_kt2_oam_event_register(unit, event_types, cb, user_data);
   1087             }
   1088         } else
   1089 #endif
   1090         {
   1091             BCM_IF_ERROR_RETURN(bcm_esw_oam_lock(unit));
   1092 
   1093 #if defined(BCM_ENDURO_SUPPORT)
   1094             if (SOC_IS_ENDURO(unit) || SOC_IS_KATANAX(unit))
   1095             {
   1096                 result = bcm_en_oam_event_register(unit, event_types, cb, user_data);
   1097             } else
   1098 #endif
   1099             {
   1100                 result = bcm_tr2x_oam_event_register(unit, event_types, cb, user_data);
   1101             }
   1102 
   1103             BCM_IF_ERROR_RETURN(bcm_esw_oam_unlock(unit));
   1104         }
   1105     }
   1106 #endif
   1107 
   1108     return result;
   1109 }
   1110 
   1111 /*
   1112  * Function:
   1113  *      bcm_esw_oam_event_unregister
   1114  * Purpose:
   1115  *      Unregister a callback for handling OAM events
   1116  * Parameters:
   1117  *      unit - (IN) Unit number.
   1118  *      event_types - (IN) The set of OAM events for which the specified callback should not be called
   1119  *      cb - (IN) A pointer to the callback function to unregister from the specified OAM events
   1120  * result =s:
   1121  *      BCM_E_XXX
   1122  * Notes:
   1123  */
   1124 int 
   1125 bcm_esw_oam_event_unregister(
   1126     int unit, 
   1127     bcm_oam_event_types_t event_types, 
   1128     bcm_oam_event_cb cb)
   1129 {
   1130     int result = BCM_E_UNAVAIL;
   1131 
   1132 #if defined(INCLUDE_CCM) || defined(INCLUDE_BHH) || defined(INCLUDE_MPLS_LM_DM)
   1133 #if defined(BCM_TRIDENT2PLUS_SUPPORT)
   1134     if (soc_feature(unit, soc_feature_fp_based_oam) &&
   1135         (soc_feature(unit, soc_feature_uc_ccm) ||
   1136          soc_feature(unit, soc_feature_bhh)    ||
   1137          soc_feature(unit, soc_feature_mpls_lm_dm)))
   1138     {
   1139         result = bcm_fp_oam_event_unregister(unit, event_types, cb);
   1140     }
   1141 #endif /* BCM_TRIDENT2PLUS_SUPPORT */
   1142 #endif /* INCLUDE_CCM || INCLUDE_BHH || INCLUDE_MPLS_LM_DM */
   1143 
   1144 #if defined(BCM_TRIUMPH2_SUPPORT) || defined(BCM_APOLLO_SUPPORT) || \
   1145     defined(BCM_VALKYRIE2_SUPPORT)
   1146     if (soc_feature(unit, soc_feature_oam))
   1147     {
   1148 #if defined(BCM_TRIUMPH3_SUPPORT) || defined(BCM_HURRICANE2_SUPPORT)
   1149         if ((SOC_IS_TRIUMPH3(unit)) || SOC_IS_HURRICANE2(unit) ||
   1150              SOC_IS_GREYHOUND(unit) || SOC_IS_HURRICANE3(unit) ||
   1151              SOC_IS_GREYHOUND2(unit)) {
   1152             result = bcm_tr3_oam_event_unregister(unit, event_types, cb);
   1153         } else
   1154 #endif
   1155 /* KT2 OAM */
   1156 #if defined(BCM_KATANA2_SUPPORT)
   1157         if (SOC_IS_KATANA2(unit)) {
   1158             if (SOC_IS_SABER2(unit)) {
   1159 #if defined (BCM_SABER2_SUPPORT)
   1160                 result = bcm_sb2_oam_event_unregister(unit, event_types, cb);
   1161 #endif
   1162             } else if (SOC_IS_KATANA2(unit)) {
   1163                 result = bcm_kt2_oam_event_unregister(unit, event_types, cb);
   1164             }
   1165         } else
   1166 #endif
   1167         {
   1168             BCM_IF_ERROR_RETURN(bcm_esw_oam_lock(unit));
   1169 
   1170 #if defined(BCM_ENDURO_SUPPORT)
   1171             if (SOC_IS_ENDURO(unit) || SOC_IS_KATANAX(unit))
   1172             {
   1173                 result = bcm_en_oam_event_unregister(unit, event_types, cb);
   1174             } else
   1175 #endif
   1176             {
   1177                 result = bcm_tr2x_oam_event_unregister(unit, event_types, cb);
   1178             }
   1179 
   1180             BCM_IF_ERROR_RETURN(bcm_esw_oam_unlock(unit));
   1181         }
   1182     }
   1183 #endif
   1184 
   1185     return result;
   1186 }
   1187 
   1188 #ifdef BCM_WARM_BOOT_SUPPORT
   1189 /*
   1190  * Function:
   1191  *      _bcm_esw_oam_sync
   1192  * Purpose:
   1193  *      Unregister a callback for handling OAM events
   1194  * Parameters:
   1195  *      unit - (IN) Unit number.
   1196  *      event_types - (IN) The set of OAM events for which the specified callback should not be called
   1197  *      cb - (IN) A pointer to the callback function to unregister from the specified OAM events
   1198  * result =s:
   1199  *      BCM_E_XXX
   1200  * Notes:
   1201  */
   1202 int 
   1203 _bcm_esw_oam_sync(int unit)
   1204 {
   1205     int result = BCM_E_UNAVAIL;
   1206 
   1207 #if defined(INCLUDE_BHH) || defined(INCLUDE_MPLS_LM_DM)
   1208 #if defined(BCM_APACHE_SUPPORT)
   1209     if ((soc_feature(unit, soc_feature_fp_based_oam)) &&
   1210         (soc_feature(unit, soc_feature_bhh)         ||
   1211          soc_feature(unit, soc_feature_mpls_lm_dm)))
   1212     {
   1213         result = _bcm_fp_oam_sync(unit);
   1214     }
   1215 #endif /* BCM_APACHE_SUPPORT */
   1216 #endif /* INCLUDE_BHH || INCLUDE_MPLS_LM_DM */
   1217 
   1218 #if defined(BCM_TRIUMPH2_SUPPORT) || defined(BCM_APOLLO_SUPPORT) || \
   1219     defined(BCM_VALKYRIE2_SUPPORT)
   1220     if (soc_feature(unit, soc_feature_oam))
   1221     {
   1222 
   1223 #if defined(BCM_TRIUMPH3_SUPPORT) || defined(BCM_HURRICANE2_SUPPORT)
   1224         if ((SOC_IS_TRIUMPH3(unit)) || SOC_IS_HURRICANE2(unit)
   1225             || SOC_IS_GREYHOUND(unit) || SOC_IS_HURRICANE3(unit)
   1226             || SOC_IS_GREYHOUND2(unit)) {
   1227             result = _bcm_tr3_oam_sync(unit);
   1228         } else
   1229 #endif
   1230 /* KT2 OAM */
   1231 #if defined(BCM_KATANA2_SUPPORT)
   1232         if (SOC_IS_KATANA2(unit)) {
   1233             if (SOC_IS_SABER2(unit)) {
   1234 #if defined (BCM_SABER2_SUPPORT)
   1235                 result = _bcm_sb2_oam_sync(unit);
   1236 #endif
   1237             } else if (SOC_IS_KATANA2(unit)) {
   1238                 result = _bcm_kt2_oam_sync(unit);
   1239             }
   1240         } else
   1241 #endif
   1242         {
   1243             BCM_IF_ERROR_RETURN(bcm_esw_oam_lock(unit));
   1244 
   1245 #if defined(BCM_ENDURO_SUPPORT)
   1246             if (SOC_IS_ENDURO(unit) || SOC_IS_KATANAX(unit))
   1247             {
   1248                 result = _bcm_en_oam_sync(unit);
   1249             }
   1250             else
   1251 #endif
   1252             {
   1253                 result = _bcm_tr2x_oam_sync(unit);
   1254             }
   1255 
   1256             BCM_IF_ERROR_RETURN(bcm_esw_oam_unlock(unit));
   1257         }
   1258     }
   1259 #endif
   1260 
   1261     return result;
   1262 }
   1263 #endif /* BCM_WARM_BOOT_SUPPORT */
   1264 
   1265 #ifdef BCM_WARM_BOOT_SUPPORT_SW_DUMP
   1266 /*
   1267  * Function:
   1268  *     _bcm_oam_sw_dump
   1269  * Purpose:
   1270  *     Displays oam information maintained by software.
   1271  * Parameters:
   1272  *     unit - Device unit number
   1273  * Returns:
   1274  *     None
   1275  */
   1276 void
   1277 _bcm_oam_sw_dump(int unit)
   1278 {
   1279 #if defined(INCLUDE_CCM) || defined(INCLUDE_BHH) || defined(INCLUDE_MPLS_LM_DM)
   1280 #if defined(BCM_TRIDENT2PLUS_SUPPORT)
   1281     if (soc_feature(unit, soc_feature_fp_based_oam))
   1282     {
   1283         _bcm_fp_oam_sw_dump(unit);
   1284     }
   1285 #endif
   1286 #endif /* INCLUDE_CCM || INCLUDE_BHH || INCLUDE_MPLS_LM_DM */
   1287 #if defined(BCM_TRIUMPH2_SUPPORT) || defined(BCM_APOLLO_SUPPORT) || \
   1288     defined(BCM_VALKYRIE2_SUPPORT)
   1289     if (soc_feature(unit, soc_feature_oam))
   1290     {
   1291 #if defined(BCM_TRIUMPH3_SUPPORT) || defined(BCM_HURRICANE2_SUPPORT)
   1292         if ((SOC_IS_TRIUMPH3(unit)) || SOC_IS_HURRICANE2(unit)||
   1293             SOC_IS_GREYHOUND(unit) || SOC_IS_HURRICANE3(unit) ||
   1294             SOC_IS_GREYHOUND2(unit)) {
   1295             _bcm_tr3_oam_sw_dump(unit);
   1296         } else
   1297 #endif
   1298 /* KT2 OAM */
   1299 #if defined(BCM_KATANA2_SUPPORT)
   1300         if (SOC_IS_KATANA2(unit)) {
   1301             if (SOC_IS_SABER2(unit)) {
   1302 #if defined (BCM_SABER2_SUPPORT)
   1303                 _bcm_sb2_oam_sw_dump(unit);
   1304 #endif
   1305             } else if (SOC_IS_KATANA2(unit)) {
   1306                 _bcm_kt2_oam_sw_dump(unit);
   1307             }
   1308         } else
   1309 #endif
   1310 #if defined(BCM_ENDURO_SUPPORT)
   1311         if (SOC_IS_ENDURO(unit) || SOC_IS_KATANAX(unit))
   1312         {
   1313             _bcm_en_oam_sw_dump(unit);
   1314         }
   1315         else
   1316 #endif
   1317         {
   1318             _bcm_tr2x_oam_sw_dump(unit);
   1319         }
   1320     }
   1321 #endif
   1322     return;
   1323 }
   1324 #endif
   1325 
   1326 
   1327 int
   1328 bcm_esw_oam_loopback_add(int unit, bcm_oam_loopback_t *loopback_ptr)
   1329 {
   1330     int result = BCM_E_UNAVAIL;
   1331 
   1332 
   1333 #if defined(INCLUDE_BHH)
   1334 #if defined(BCM_APACHE_SUPPORT)
   1335     if ((soc_feature(unit, soc_feature_fp_based_oam)) && 
   1336         (soc_feature(unit, soc_feature_bhh)))
   1337     {
   1338         result = bcm_fp_oam_loopback_add(unit, loopback_ptr);
   1339     }
   1340 #endif
   1341     if ((soc_feature(unit, soc_feature_oam)) && (soc_feature(unit, soc_feature_bhh)))
   1342     {
   1343 
   1344 #if defined(BCM_KATANA2_SUPPORT)
   1345         if (SOC_IS_KATANA2(unit)) {
   1346             if (SOC_IS_SABER2(unit)) {
   1347 #if defined (BCM_SABER2_SUPPORT)
   1348                 return bcm_sb2_oam_loopback_add(unit, loopback_ptr);
   1349 #endif
   1350             } else if (SOC_IS_KATANA2(unit)) {
   1351                 return bcm_kt2_oam_loopback_add(unit, loopback_ptr);
   1352             }
   1353         }
   1354 #endif
   1355 
   1356 #if defined(BCM_TRIUMPH3_SUPPORT)
   1357         if (SOC_IS_TRIUMPH3(unit)) {
   1358             return bcm_tr3_oam_loopback_add(unit, loopback_ptr);
   1359         }
   1360 #endif
   1361 
   1362 #if defined(BCM_KATANA_SUPPORT)
   1363         BCM_IF_ERROR_RETURN(bcm_esw_oam_lock(unit));
   1364 
   1365         if (SOC_IS_KATANAX(unit))
   1366         {
   1367             result = bcm_en_oam_loopback_add(unit, loopback_ptr);
   1368         }
   1369 
   1370         BCM_IF_ERROR_RETURN(bcm_esw_oam_unlock(unit));
   1371 #endif 
   1372 
   1373     }
   1374 #endif
   1375 
   1376     return result;
   1377 }
   1378 
   1379 int
   1380 bcm_esw_oam_loopback_get(int unit, bcm_oam_loopback_t *loopback_ptr)
   1381 {
   1382     int result = BCM_E_UNAVAIL;
   1383 
   1384 #if defined(INCLUDE_BHH)
   1385 #if defined(BCM_APACHE_SUPPORT)
   1386     if ((soc_feature(unit, soc_feature_fp_based_oam)) && 
   1387         (soc_feature(unit, soc_feature_bhh)))
   1388     {
   1389         result = bcm_fp_oam_loopback_get(unit, loopback_ptr);
   1390     }
   1391 #endif
   1392     if ((soc_feature(unit, soc_feature_oam)) && (soc_feature(unit, soc_feature_bhh)))
   1393     {
   1394 
   1395 #if defined(BCM_KATANA2_SUPPORT)
   1396         if (SOC_IS_KATANA2(unit)) {
   1397             if (SOC_IS_SABER2(unit)) {
   1398 #if defined (BCM_SABER2_SUPPORT)
   1399                 return bcm_sb2_oam_loopback_get(unit, loopback_ptr);
   1400 #endif
   1401             } else if (SOC_IS_KATANA2(unit)) {
   1402                 return bcm_kt2_oam_loopback_get(unit, loopback_ptr);
   1403             }
   1404         }
   1405 #endif 
   1406 
   1407 #if defined(BCM_TRIUMPH3_SUPPORT)
   1408         if (SOC_IS_TRIUMPH3(unit)) {
   1409             return bcm_tr3_oam_loopback_get(unit, loopback_ptr);
   1410         }
   1411 #endif 
   1412 
   1413 #if defined(BCM_KATANA_SUPPORT)
   1414         BCM_IF_ERROR_RETURN(bcm_esw_oam_lock(unit));
   1415 
   1416         if (SOC_IS_KATANAX(unit))
   1417         {
   1418             result = bcm_en_oam_loopback_get(unit, loopback_ptr);
   1419         }
   1420 
   1421         BCM_IF_ERROR_RETURN(bcm_esw_oam_unlock(unit));
   1422 #endif
   1423 
   1424     }
   1425 #endif 
   1426 
   1427     return result;
   1428 }
   1429 
   1430 int
   1431 bcm_esw_oam_loopback_delete(int unit, bcm_oam_loopback_t *loopback_ptr)
   1432 {
   1433     int result = BCM_E_UNAVAIL;
   1434 
   1435 #if defined(INCLUDE_BHH)
   1436 #if defined(BCM_APACHE_SUPPORT)
   1437     if ((soc_feature(unit, soc_feature_fp_based_oam)) && 
   1438         (soc_feature(unit, soc_feature_bhh)))
   1439     {
   1440         result = bcm_fp_oam_loopback_delete(unit, loopback_ptr);
   1441     }
   1442 #endif
   1443     if ((soc_feature(unit, soc_feature_oam)) && (soc_feature(unit, soc_feature_bhh)))
   1444     {
   1445 
   1446 #if defined(BCM_KATANA2_SUPPORT)
   1447         if (SOC_IS_KATANA2(unit)) {
   1448             if (SOC_IS_SABER2(unit)) {
   1449 #if defined (BCM_SABER2_SUPPORT)
   1450                 return bcm_sb2_oam_loopback_delete(unit, loopback_ptr);
   1451 #endif
   1452             } else if (SOC_IS_KATANA2(unit)) {
   1453                 return bcm_kt2_oam_loopback_delete(unit, loopback_ptr);
   1454             }
   1455         }
   1456 #endif
   1457 
   1458 #if defined(BCM_TRIUMPH3_SUPPORT)
   1459         if (SOC_IS_TRIUMPH3(unit)) {
   1460             return bcm_tr3_oam_loopback_delete(unit, loopback_ptr);
   1461         }
   1462 #endif
   1463 
   1464 #if defined(BCM_KATANA_SUPPORT) 
   1465         BCM_IF_ERROR_RETURN(bcm_esw_oam_lock(unit));
   1466 
   1467         if (SOC_IS_KATANAX(unit))
   1468         {
   1469             result = bcm_en_oam_loopback_delete(unit, loopback_ptr);
   1470         }
   1471 
   1472         BCM_IF_ERROR_RETURN(bcm_esw_oam_unlock(unit));
   1473 #endif
   1474 
   1475     }
   1476 #endif
   1477 
   1478     return result;
   1479 }
   1480 
   1481 int 
   1482 bcm_esw_oam_loss_add(
   1483     int unit, 
   1484     bcm_oam_loss_t *loss_ptr)
   1485 {
   1486     int result = BCM_E_UNAVAIL;
   1487 
   1488 #if defined(INCLUDE_BHH) || defined(INCLUDE_MPLS_LM_DM)
   1489 #if defined(BCM_APACHE_SUPPORT)
   1490     if ((soc_feature(unit, soc_feature_fp_based_oam)) &&
   1491         (soc_feature(unit, soc_feature_bhh)         ||
   1492          soc_feature(unit, soc_feature_mpls_lm_dm)))
   1493     {
   1494         result = bcm_fp_oam_loss_add(unit, loss_ptr);
   1495     }
   1496 #endif /* BCM_APACHE_SUPPORT */
   1497 #endif /* INCLUDE_BHH || INCLUDE_MPLS_LM_DM */
   1498 
   1499 #if defined(INCLUDE_BHH) || defined(INCLUDE_ETH_LM_DM) ||                     \
   1500     defined (INCLUDE_MPLS_LM_DM)
   1501     if ((soc_feature(unit, soc_feature_oam)) && 
   1502         (soc_feature(unit, soc_feature_bhh)||(soc_feature(unit, soc_feature_eth_lm_dm)))) 
   1503     {
   1504 
   1505 #if defined(BCM_KATANA2_SUPPORT)
   1506         if (SOC_IS_KATANA2(unit)) {
   1507             if (SOC_IS_SABER2(unit)) {
   1508 #if defined (BCM_SABER2_SUPPORT)
   1509                 return bcm_sb2_oam_loss_add(unit, loss_ptr);
   1510 #endif
   1511             } else if (SOC_IS_KATANA2(unit)) {
   1512 #if defined(INCLUDE_BHH)
   1513                 return bcm_kt2_oam_loss_add(unit, loss_ptr);
   1514 #endif                
   1515             }
   1516         }
   1517 #endif      /* KATANA2 */
   1518 
   1519 #if defined(BCM_TRIUMPH3_SUPPORT) && defined(INCLUDE_BHH)
   1520         if (SOC_IS_TRIUMPH3(unit)) {
   1521             return bcm_tr3_oam_loss_add(unit, loss_ptr);
   1522         }
   1523 #endif      /* TRIUMPH3 */
   1524 
   1525     }
   1526 #endif      /* BHH */
   1527 
   1528     return result;
   1529 }
   1530 
   1531 int 
   1532 bcm_esw_oam_loss_delete(
   1533     int unit, 
   1534     bcm_oam_loss_t *loss_ptr)
   1535 {
   1536     int result = BCM_E_UNAVAIL;
   1537 #if defined(INCLUDE_BHH) || defined(INCLUDE_MPLS_LM_DM)
   1538 #if defined(BCM_APACHE_SUPPORT)
   1539     if ((soc_feature(unit, soc_feature_fp_based_oam)) &&
   1540         (soc_feature(unit, soc_feature_bhh)         ||
   1541          soc_feature(unit, soc_feature_mpls_lm_dm)))
   1542     {
   1543         result = bcm_fp_oam_loss_delete(unit, loss_ptr);
   1544     }
   1545 #endif /* BCM_APACHE_SUPPORT */
   1546 #endif /* INCLUDE_BHH || INCLUDE_MPLS_LM_DM */
   1547 
   1548 #if defined(INCLUDE_BHH) || defined(INCLUDE_ETH_LM_DM) ||                     \
   1549     defined (INCLUDE_MPLS_LM_DM)
   1550     if ((soc_feature(unit, soc_feature_oam)) && 
   1551         (soc_feature(unit, soc_feature_bhh)||(soc_feature(unit, soc_feature_eth_lm_dm)))) 
   1552     {
   1553 
   1554 #if defined(BCM_KATANA2_SUPPORT)
   1555         if (SOC_IS_KATANA2(unit)) {
   1556             if (SOC_IS_SABER2(unit)) {
   1557 #if defined (BCM_SABER2_SUPPORT)
   1558                 return bcm_sb2_oam_loss_delete(unit, loss_ptr);
   1559 #endif
   1560             } else if (SOC_IS_KATANA2(unit)) {
   1561 #if defined(INCLUDE_BHH)            
   1562                 return bcm_kt2_oam_loss_delete(unit, loss_ptr);
   1563 #endif                
   1564             }
   1565         } 
   1566 #endif      /* KATANA2 */
   1567 
   1568 #if defined(BCM_TRIUMPH3_SUPPORT) && defined(INCLUDE_BHH)
   1569         if (SOC_IS_TRIUMPH3(unit)) {
   1570             return bcm_tr3_oam_loss_delete(unit, loss_ptr);
   1571         } 
   1572 #endif      /* TRIUMPH3 */
   1573 
   1574 
   1575     }
   1576 #endif
   1577 
   1578     return result;
   1579 }
   1580 
   1581 int 
   1582 bcm_esw_oam_loss_get(
   1583     int unit, 
   1584     bcm_oam_loss_t *loss_ptr)
   1585 {
   1586     int result = BCM_E_UNAVAIL;
   1587 #if defined(INCLUDE_BHH) || defined(INCLUDE_MPLS_LM_DM)
   1588 #if defined(BCM_APACHE_SUPPORT)
   1589     if ((soc_feature(unit, soc_feature_fp_based_oam)) &&
   1590         (soc_feature(unit, soc_feature_bhh)         ||
   1591          soc_feature(unit, soc_feature_mpls_lm_dm)))
   1592     {
   1593         result = bcm_fp_oam_loss_get(unit, loss_ptr);
   1594     }
   1595 #endif /* BCM_APACHE_SUPPORT */
   1596 #endif /* INCLUDE_BHH || INCLUDE_MPLS_LM_DM */
   1597 
   1598 #if defined(INCLUDE_BHH) || defined(INCLUDE_ETH_LM_DM) ||                     \
   1599     defined (INCLUDE_MPLS_LM_DM)
   1600     if ((soc_feature(unit, soc_feature_oam)) && 
   1601         (soc_feature(unit, soc_feature_bhh)||(soc_feature(unit, soc_feature_eth_lm_dm)))) 
   1602     {
   1603 
   1604 #if defined(BCM_KATANA2_SUPPORT)
   1605         if (SOC_IS_KATANA2(unit)) {
   1606             if (SOC_IS_SABER2(unit)) {
   1607 #if defined (BCM_SABER2_SUPPORT)
   1608                 return bcm_sb2_oam_loss_get(unit, loss_ptr);
   1609 #endif
   1610             } else if (SOC_IS_KATANA2(unit)) {
   1611 #if defined(INCLUDE_BHH)            
   1612                 return bcm_kt2_oam_loss_get(unit, loss_ptr);
   1613 #endif                
   1614             }
   1615         }
   1616 #endif      /* KATANA2 */
   1617 
   1618 #if defined(BCM_TRIUMPH3_SUPPORT) && defined(INCLUDE_BHH)
   1619         if (SOC_IS_TRIUMPH3(unit)) {
   1620             return bcm_tr3_oam_loss_get(unit, loss_ptr);
   1621         }
   1622 #endif      /* TRIUMPH3 */
   1623 
   1624     }
   1625 #endif      /* BHH */
   1626 
   1627     return result;
   1628 }
   1629 
   1630 int 
   1631 bcm_esw_oam_delay_add(
   1632     int unit, 
   1633     bcm_oam_delay_t *delay_ptr)
   1634 {
   1635     int result = BCM_E_UNAVAIL;
   1636 #if defined(INCLUDE_BHH) || defined(INCLUDE_MPLS_LM_DM)
   1637 #if defined(BCM_APACHE_SUPPORT)
   1638     if ((soc_feature(unit, soc_feature_fp_based_oam)) &&
   1639         (soc_feature(unit, soc_feature_bhh)         ||
   1640          soc_feature(unit, soc_feature_mpls_lm_dm)))
   1641     {
   1642         result = bcm_fp_oam_delay_add(unit, delay_ptr);
   1643     }
   1644 #endif /* BCM_APACHE_SUPPORT */
   1645 #endif /* INCLUDE_BHH || INCLUDE_MPLS_LM_DM */
   1646 
   1647 #if defined(INCLUDE_BHH) || defined(INCLUDE_ETH_LM_DM) ||                     \
   1648     defined (INCLUDE_MPLS_LM_DM)
   1649     if ((soc_feature(unit, soc_feature_oam)) && 
   1650         (soc_feature(unit, soc_feature_bhh)||(soc_feature(unit, soc_feature_eth_lm_dm)))) 
   1651     {
   1652 
   1653 #if defined(BCM_KATANA2_SUPPORT)
   1654         if (SOC_IS_KATANA2(unit)) {
   1655             if (SOC_IS_SABER2(unit)) {
   1656 #if defined (BCM_SABER2_SUPPORT)
   1657                 return bcm_sb2_oam_delay_add(unit, delay_ptr);
   1658 #endif
   1659             } else if (SOC_IS_KATANA2(unit)) {
   1660 #if defined(INCLUDE_BHH)            
   1661                 return bcm_kt2_oam_delay_add(unit, delay_ptr);
   1662 #endif                
   1663             }
   1664         }
   1665 #endif      /* KATANA2 */
   1666 
   1667 #if defined(BCM_TRIUMPH3_SUPPORT) && defined(INCLUDE_BHH)
   1668         if (SOC_IS_TRIUMPH3(unit)) {
   1669             return bcm_tr3_oam_delay_add(unit, delay_ptr);
   1670         }
   1671 #endif      /* TRIUMPH3 */
   1672 
   1673     }
   1674 #endif      /* BHH */
   1675 
   1676     return result;
   1677 }
   1678 
   1679 int 
   1680 bcm_esw_oam_delay_delete(
   1681     int unit, 
   1682     bcm_oam_delay_t *delay_ptr)
   1683 {
   1684     int result = BCM_E_UNAVAIL;
   1685 #if defined(INCLUDE_BHH) || defined(INCLUDE_MPLS_LM_DM)
   1686 #if defined(BCM_APACHE_SUPPORT)
   1687     if ((soc_feature(unit, soc_feature_fp_based_oam)) &&
   1688         (soc_feature(unit, soc_feature_bhh)         ||
   1689          soc_feature(unit, soc_feature_mpls_lm_dm)))
   1690     {
   1691         result = bcm_fp_oam_delay_delete(unit, delay_ptr);
   1692     }
   1693 #endif /* BCM_APACHE_SUPPORT */
   1694 #endif /* INCLUDE_BHH || INCLUDE_MPLS_LM_DM */
   1695 
   1696 #if defined(INCLUDE_BHH) || defined(INCLUDE_ETH_LM_DM) ||                     \
   1697     defined (INCLUDE_MPLS_LM_DM)
   1698     if ((soc_feature(unit, soc_feature_oam)) && 
   1699         (soc_feature(unit, soc_feature_bhh)||(soc_feature(unit, soc_feature_eth_lm_dm)))) 
   1700     {
   1701 
   1702 #if defined(BCM_KATANA2_SUPPORT)
   1703         if (SOC_IS_KATANA2(unit)) {
   1704             if (SOC_IS_SABER2(unit)) {
   1705 #if defined (BCM_SABER2_SUPPORT)
   1706                 return bcm_sb2_oam_delay_delete(unit, delay_ptr);
   1707 #endif
   1708             } else if (SOC_IS_KATANA2(unit)) {
   1709 #if defined(INCLUDE_BHH)            
   1710                 return bcm_kt2_oam_delay_delete(unit, delay_ptr);
   1711 #endif
   1712             }
   1713         } 
   1714 #endif /* KATANA2 */
   1715 
   1716 #if defined(BCM_TRIUMPH3_SUPPORT) && defined(INCLUDE_BHH)
   1717         if (SOC_IS_TRIUMPH3(unit)) {
   1718             return bcm_tr3_oam_delay_delete(unit, delay_ptr);
   1719         } 
   1720 #endif /*TRIUMPH3 */
   1721 
   1722     }
   1723 #endif /* BHH */
   1724 
   1725     return result;
   1726 }
   1727 
   1728 int 
   1729 bcm_esw_oam_delay_get(
   1730     int unit, 
   1731     bcm_oam_delay_t *delay_ptr)
   1732 {
   1733     int result = BCM_E_UNAVAIL;
   1734 #if defined(INCLUDE_BHH) || defined(INCLUDE_MPLS_LM_DM)
   1735 #if defined(BCM_APACHE_SUPPORT)
   1736     if ((soc_feature(unit, soc_feature_fp_based_oam)) &&
   1737         (soc_feature(unit, soc_feature_bhh)         ||
   1738          soc_feature(unit, soc_feature_mpls_lm_dm)))
   1739     {
   1740         result = bcm_fp_oam_delay_get(unit, delay_ptr);
   1741     }
   1742 #endif /* BCM_APACHE_SUPPORT */
   1743 #endif /* INCLUDE_BHH || INCLUDE_MPLS_LM_DM */
   1744 
   1745 #if defined(INCLUDE_BHH) || defined(INCLUDE_ETH_LM_DM) ||                     \
   1746     defined (INCLUDE_MPLS_LM_DM)
   1747     if ((soc_feature(unit, soc_feature_oam)) && 
   1748         (soc_feature(unit, soc_feature_bhh)||(soc_feature(unit, soc_feature_eth_lm_dm)))) 
   1749     {
   1750 
   1751 #if defined(BCM_KATANA2_SUPPORT)
   1752         if (SOC_IS_KATANA2(unit)) {
   1753             if (SOC_IS_SABER2(unit)) {
   1754 #if defined (BCM_SABER2_SUPPORT)
   1755                 return bcm_sb2_oam_delay_get(unit, delay_ptr);
   1756 #endif
   1757             } else if (SOC_IS_KATANA2(unit)) {
   1758 #if defined(INCLUDE_BHH)            
   1759                 return bcm_kt2_oam_delay_get(unit, delay_ptr);
   1760 #endif
   1761             }
   1762         } 
   1763 #endif /* KATANA2 */
   1764 
   1765 #if defined(BCM_TRIUMPH3_SUPPORT) && defined(INCLUDE_BHH)
   1766         if (SOC_IS_TRIUMPH3(unit)) {
   1767             return bcm_tr3_oam_delay_get(unit, delay_ptr);
   1768         } 
   1769 #endif /* TRIUMPH3 */
   1770 
   1771     }
   1772 #endif /* BHH */
   1773 
   1774     return result;
   1775 }
   1776 
   1777 int 
   1778 bcm_esw_oam_endpoint_action_set(
   1779     int unit,
   1780     bcm_oam_endpoint_t id,
   1781     bcm_oam_endpoint_action_t *action) 
   1782 {
   1783     int result = BCM_E_UNAVAIL;
   1784 #if defined(BCM_KATANA2_SUPPORT)
   1785     if ((soc_feature(unit, soc_feature_oam)) &&  (SOC_IS_KATANA2(unit))) { 
   1786         if (SOC_IS_SABER2(unit)){
   1787 #if defined (BCM_SABER2_SUPPORT)
   1788             result = bcm_sb2_oam_endpoint_action_set(unit, id, action);
   1789 #endif
   1790         } else if (SOC_IS_KATANA2(unit)) {
   1791             result = bcm_kt2_oam_endpoint_action_set(unit, id, action); 
   1792         }
   1793     } 
   1794 #endif /* BCM_KATANA2_SUPPORT */
   1795     return result;
   1796 }
   1797 
   1798 int 
   1799 bcm_esw_oam_control_get(
   1800     int unit,
   1801     bcm_oam_control_type_t type,
   1802     uint64            *arg) 
   1803 {
   1804     int result = BCM_E_UNAVAIL;
   1805 #if defined(BCM_KATANA2_SUPPORT)
   1806     if ((soc_feature(unit, soc_feature_oam)) &&  (SOC_IS_KATANA2(unit))) { 
   1807         if (SOC_IS_SABER2(unit)) {
   1808 #if defined (BCM_SABER2_SUPPORT)
   1809             result = bcm_sb2_oam_control_get(unit, type, arg); 
   1810 #endif
   1811         } else if (SOC_IS_KATANA2(unit)) {
   1812             result = bcm_kt2_oam_control_get(unit, type, arg); 
   1813         }
   1814     } 
   1815 #endif /* BCM_KATANA2_SUPPORT */
   1816     return result;
   1817 }
   1818 
   1819 int 
   1820 bcm_esw_oam_control_set(
   1821     int unit,
   1822     bcm_oam_control_type_t type,
   1823     uint64            arg) 
   1824 {
   1825     int result = BCM_E_UNAVAIL;
   1826 #if defined(BCM_KATANA2_SUPPORT)
   1827     if ((soc_feature(unit, soc_feature_oam)) &&  (SOC_IS_KATANA2(unit))) { 
   1828         if (SOC_IS_SABER2(unit)) {
   1829 #if defined (BCM_SABER2_SUPPORT)
   1830             result = bcm_sb2_oam_control_set(unit, type, arg); 
   1831 #endif
   1832         } else if (SOC_IS_KATANA2(unit)) {
   1833             result = bcm_kt2_oam_control_set(unit, type, arg); 
   1834         }
   1835     } 
   1836 #endif /* BCM_KATANA2_SUPPORT */
   1837     return result;
   1838 }
   1839 
   1840 int
   1841 bcm_esw_oam_lookup_enable_set(
   1842         int unit, 
   1843         bcm_oam_lookup_type_t type, 
   1844         bcm_oam_condition_t condition,
   1845         int enable)
   1846 {
   1847     int result = BCM_E_UNAVAIL;
   1848 #if defined(BCM_SABER2_SUPPORT)
   1849     if ((soc_feature(unit, soc_feature_oam)) &&  (SOC_IS_SABER2(unit))) {
   1850         result = bcm_sb2_oam_lookup_enable_set(unit, type, condition,
   1851                 enable);
   1852     }
   1853 #endif /* BCM_SABER2_SUPPORT */
   1854     return result;
   1855 }
   1856 
   1857 int
   1858 bcm_esw_oam_lookup_enable_multi_set(
   1859         int unit, 
   1860         bcm_oam_lookup_types_t type, 
   1861         bcm_oam_conditions_t condition,
   1862         int enable)
   1863 {
   1864     int result = BCM_E_UNAVAIL;
   1865 #if defined(BCM_SABER2_SUPPORT)
   1866     if ((soc_feature(unit, soc_feature_oam)) &&  (SOC_IS_SABER2(unit))) {
   1867         result = bcm_sb2_oam_lookup_enable_multi_set(unit, type, 
   1868                 condition, enable);
   1869     }
   1870 #endif /* BCM_SABER2_SUPPORT */
   1871     return result;
   1872 }
   1873 
   1874 int
   1875 bcm_esw_oam_lookup_enable_get(
   1876         int unit, 
   1877         bcm_oam_lookup_type_t type, 
   1878         bcm_oam_conditions_t *condition)
   1879 {
   1880     int result = BCM_E_UNAVAIL;
   1881 #if defined(BCM_SABER2_SUPPORT)
   1882     if ((soc_feature(unit, soc_feature_oam)) &&  (SOC_IS_SABER2(unit))) {
   1883             result = bcm_sb2_oam_lookup_enable_get(unit, type, condition);
   1884     }
   1885 #endif /* BCM_SABER2_SUPPORT */
   1886     return result;
   1887 }
   1888 
   1889 int
   1890 bcm_esw_oam_pm_profile_create(
   1891         int unit,
   1892         bcm_oam_pm_profile_info_t *profile_info)
   1893 {
   1894     int result = BCM_E_UNAVAIL;
   1895 
   1896 #if defined(INCLUDE_BHH) || defined(INCLUDE_MPLS_LM_DM)
   1897 #if defined(BCM_APACHE_SUPPORT)
   1898     if ((soc_feature(unit, soc_feature_fp_based_oam)) &&
   1899         (soc_feature(unit, soc_feature_oam_pm)))
   1900     {
   1901         result = bcm_fp_oam_pm_profile_create(unit, profile_info);
   1902     }
   1903 #endif /* BCM_APACHE_SUPPORT */
   1904 #endif /* INCLUDE_BHH || INCLUDE_MPLS_LM_DM */
   1905 
   1906 #if defined(BCM_KATANA2_SUPPORT)
   1907     if ((soc_feature(unit, soc_feature_oam)) 
   1908             && (soc_feature(unit, soc_feature_oam_pm)) ) {
   1909         if (SOC_IS_SABER2(unit)) {
   1910 #if defined(BCM_SABER2_SUPPORT)
   1911             result = bcm_sb2_oam_pm_profile_create(unit, profile_info);
   1912 #endif /* BCM_SABER2_SUPPORT */
   1913         } else {  
   1914 #if defined(INCLUDE_BHH)
   1915             result = bcm_kt2_oam_pm_profile_create(unit, profile_info);
   1916 #endif
   1917         }
   1918     }
   1919 #endif
   1920 
   1921     return result;
   1922 }
   1923 
   1924 int
   1925 bcm_esw_oam_pm_profile_delete(
   1926         int unit,
   1927         bcm_oam_pm_profile_t profile_id)
   1928 {
   1929     int result = BCM_E_UNAVAIL;
   1930 
   1931 #if defined(INCLUDE_BHH) || defined(INCLUDE_MPLS_LM_DM)
   1932 #if defined(BCM_APACHE_SUPPORT)
   1933     if ((soc_feature(unit, soc_feature_fp_based_oam)) &&
   1934         (soc_feature(unit, soc_feature_oam_pm)))
   1935     {
   1936         result = bcm_fp_oam_pm_profile_delete(unit, profile_id);
   1937     }
   1938 #endif /* BCM_APACHE_SUPPORT */
   1939 #endif /* INCLUDE_BHH || INCLUDE_MPLS_LM_DM */
   1940 
   1941 #if defined(BCM_KATANA2_SUPPORT)
   1942     if ((soc_feature(unit, soc_feature_oam)) 
   1943             && (soc_feature(unit, soc_feature_oam_pm))) {
   1944         if (SOC_IS_SABER2(unit)) {
   1945 #if defined(BCM_SABER2_SUPPORT)
   1946             result = bcm_sb2_oam_pm_profile_delete(unit, profile_id);
   1947 #endif /* BCM_SABER2_SUPPORT */
   1948         } else {
   1949 #if defined(INCLUDE_BHH)
   1950             result = bcm_kt2_oam_pm_profile_delete(unit, profile_id);
   1951 #endif
   1952         }
   1953     }
   1954 #endif
   1955 
   1956     return result;
   1957 }
   1958 
   1959 int
   1960 bcm_esw_oam_pm_profile_delete_all(
   1961         int unit)
   1962 {
   1963     int result = BCM_E_UNAVAIL;
   1964 
   1965 #if defined(INCLUDE_BHH) || defined(INCLUDE_MPLS_LM_DM)
   1966 #if defined(BCM_APACHE_SUPPORT)
   1967     if ((soc_feature(unit, soc_feature_fp_based_oam)) &&
   1968         (soc_feature(unit, soc_feature_oam_pm)))
   1969     {
   1970         result = bcm_fp_oam_pm_profile_delete_all(unit);
   1971     }
   1972 #endif /* BCM_APACHE_SUPPORT */
   1973 #endif /* INCLUDE_BHH || INCLUDE_MPLS_LM_DM */
   1974 
   1975 #if defined(BCM_KATANA2_SUPPORT)
   1976     if ((soc_feature(unit, soc_feature_oam)) 
   1977             && (soc_feature(unit, soc_feature_oam_pm))) {
   1978         if (SOC_IS_SABER2(unit)) {
   1979 #if defined(BCM_SABER2_SUPPORT)
   1980             result = bcm_sb2_oam_pm_profile_delete_all(unit);
   1981 #endif /* BCM_SABER2_SUPPORT */
   1982         } else {
   1983 #if defined(INCLUDE_BHH)
   1984             result = bcm_kt2_oam_pm_profile_delete_all(unit);
   1985 #endif
   1986         }
   1987     }
   1988 #endif /* BCM_SABER2_SUPPORT */
   1989     return result;
   1990 }
   1991 
   1992 int
   1993 bcm_esw_oam_pm_profile_detach(
   1994         int unit,
   1995         bcm_oam_endpoint_t endpoint_id,
   1996         int profile_id)
   1997 {
   1998     int result = BCM_E_UNAVAIL;
   1999 
   2000 #if defined(INCLUDE_BHH) || defined(INCLUDE_MPLS_LM_DM)
   2001 #if defined(BCM_APACHE_SUPPORT)
   2002     if ((soc_feature(unit, soc_feature_fp_based_oam)) &&
   2003         (soc_feature(unit, soc_feature_oam_pm)))
   2004     {
   2005         result = bcm_fp_oam_pm_profile_detach(unit, endpoint_id,
   2006                                                    profile_id);
   2007     }
   2008 #endif /* BCM_APACHE_SUPPORT */
   2009 #endif /* INCLUDE_BHH || INCLUDE_MPLS_LM_DM */
   2010 
   2011 #if defined(BCM_KATANA2_SUPPORT)
   2012     if ((soc_feature(unit, soc_feature_oam)) 
   2013             && (soc_feature(unit, soc_feature_oam_pm))){
   2014         if (SOC_IS_SABER2(unit)) {
   2015 #if defined(BCM_SABER2_SUPPORT)
   2016             result = bcm_sb2_oam_pm_profile_detach(unit, endpoint_id, 
   2017                                                    profile_id);
   2018 #endif  
   2019         } else  {
   2020 #if defined(INCLUDE_BHH)
   2021             result = bcm_kt2_oam_pm_profile_detach(unit, endpoint_id, 
   2022                     profile_id);
   2023 #endif /* INCLUDE_BHH */
   2024     }
   2025     }
   2026 #endif /* BCM_KATANA2_SUPPORT */
   2027     return result;
   2028 }
   2029 
   2030 int
   2031 bcm_esw_oam_pm_profile_get(
   2032     int unit,
   2033     bcm_oam_pm_profile_info_t *profile_info)
   2034 {
   2035     int result = BCM_E_UNAVAIL;
   2036 
   2037 #if defined(INCLUDE_BHH) || defined(INCLUDE_MPLS_LM_DM)
   2038 #if defined(BCM_APACHE_SUPPORT)
   2039     if ((soc_feature(unit, soc_feature_fp_based_oam)) &&
   2040         (soc_feature(unit, soc_feature_oam_pm))) {
   2041         result = bcm_fp_oam_pm_profile_get(unit, profile_info);
   2042     }
   2043 #endif /* BCM_APACHE_SUPPORT */
   2044 #endif /* INCLUDE_BHH || INCLUDE_MPLS_LM_DM */
   2045 
   2046 #if defined(BCM_KATANA2_SUPPORT)
   2047     if ((soc_feature(unit, soc_feature_oam)) 
   2048             && (soc_feature(unit, soc_feature_oam_pm))){
   2049         if (SOC_IS_SABER2(unit)) {
   2050 #if defined(BCM_SABER2_SUPPORT)
   2051             result = bcm_sb2_oam_pm_profile_get(unit, profile_info);
   2052 #endif    
   2053         } else {
   2054 #if defined(INCLUDE_BHH)
   2055             result = bcm_kt2_oam_pm_profile_get(unit, profile_info);
   2056 #endif /* INCLUDE_BHH */
   2057     }
   2058     }
   2059 #endif /* BCM_KATANA2_SUPPORT */
   2060     return result;
   2061 }
   2062 
   2063 int
   2064 bcm_esw_oam_pm_profile_traverse(
   2065     int unit,
   2066     bcm_oam_pm_profile_traverse_cb cb,
   2067     void *user_data)
   2068 {
   2069     int result = BCM_E_UNAVAIL;
   2070 
   2071 #if defined(INCLUDE_BHH) || defined(INCLUDE_MPLS_LM_DM)
   2072 #if defined(BCM_APACHE_SUPPORT)
   2073     if ((soc_feature(unit, soc_feature_fp_based_oam)) &&
   2074         (soc_feature(unit, soc_feature_oam_pm)))
   2075     {
   2076         result = bcm_fp_oam_pm_profile_traverse(unit, cb, user_data);
   2077     }
   2078 #endif /* BCM_APACHE_SUPPORT */
   2079 #endif /* INCLUDE_BHH || INCLUDE_MPLS_LM_DM */
   2080 
   2081 #if defined(BCM_KATANA2_SUPPORT)
   2082     if ((soc_feature(unit, soc_feature_oam)) 
   2083             && (soc_feature(unit, soc_feature_oam_pm))){
   2084         if (SOC_IS_SABER2(unit)) {
   2085 #if defined(BCM_SABER2_SUPPORT)
   2086             result = bcm_sb2_oam_pm_profile_traverse(unit, cb, user_data);
   2087 #endif    
   2088         } else {
   2089 #if defined(INCLUDE_BHH)
   2090             result = bcm_kt2_oam_pm_profile_traverse(unit, cb, user_data);
   2091 #endif /* INCLUDE_BHH */
   2092     }
   2093     }
   2094 #endif /* BCM_KATANA2_SUPPORT */
   2095     return result;
   2096 }
   2097 
   2098 int
   2099 bcm_esw_oam_pm_stats_get(
   2100     int unit,
   2101     bcm_oam_endpoint_t endpoint_id,
   2102     bcm_oam_pm_stats_t *stats_ptr)
   2103 {
   2104     int result = BCM_E_UNAVAIL;
   2105 
   2106 #if defined(INCLUDE_BHH) || defined(INCLUDE_MPLS_LM_DM)
   2107 #if defined(BCM_APACHE_SUPPORT)
   2108     if ((soc_feature(unit, soc_feature_fp_based_oam)) &&
   2109         (soc_feature(unit, soc_feature_oam_pm)))
   2110     {
   2111         result = bcm_fp_oam_pm_stats_get(unit, endpoint_id, stats_ptr);
   2112     }
   2113 #endif /* BCM_APACHE_SUPPORT */
   2114 #endif /* INCLUDE_BHH || INCLUDE_MPLS_LM_DM */
   2115 
   2116 #if defined(BCM_KATANA2_SUPPORT)
   2117     if ((soc_feature(unit, soc_feature_oam)) 
   2118             && (soc_feature(unit, soc_feature_oam_pm))) {
   2119         if(SOC_IS_SABER2(unit)) {
   2120 #if defined(BCM_SABER2_SUPPORT)
   2121             result = bcm_sb2_oam_pm_stats_get(unit, endpoint_id, stats_ptr);
   2122 #endif
   2123         } else {
   2124 #if defined(INCLUDE_BHH)
   2125             result = bcm_kt2_oam_pm_stats_get(unit, endpoint_id, stats_ptr);
   2126 #endif /* INCLUDE_BHH */
   2127     }
   2128     }
   2129 #endif /* BCM_KATANA2_SUPPORT */
   2130     return result;
   2131 }
   2132 
   2133 int
   2134 bcm_esw_oam_pm_event_register(
   2135     int unit,
   2136     bcm_oam_event_types_t event_types,
   2137     bcm_oam_pm_event_cb cb,
   2138     void *user_data)
   2139 {
   2140     int result = BCM_E_UNAVAIL;
   2141 
   2142 #if defined(INCLUDE_BHH) || defined(INCLUDE_MPLS_LM_DM)
   2143 #if defined(BCM_APACHE_SUPPORT)
   2144     if ((soc_feature(unit, soc_feature_fp_based_oam)) &&
   2145         (soc_feature(unit, soc_feature_oam_pm)))
   2146     {
   2147         result = bcm_fp_oam_pm_event_register(unit, event_types, cb,
   2148                 user_data);
   2149     }
   2150 #endif /* BCM_APACHE_SUPPORT */
   2151 #endif /* INCLUDE_BHH || INCLUDE_MPLS_LM_DM */
   2152 
   2153 #if defined(BCM_SABER2_SUPPORT)
   2154     if ((soc_feature(unit, soc_feature_oam)) 
   2155         && (soc_feature(unit, soc_feature_oam_pm))
   2156         &&  (SOC_IS_SABER2(unit))) {
   2157         result = bcm_sb2_oam_pm_event_register(unit, event_types, cb, 
   2158                 user_data);
   2159     }
   2160 #endif /* BCM_SABER2_SUPPORT */
   2161     return result;
   2162 }
   2163 
   2164 int
   2165 bcm_esw_oam_pm_event_unregister(
   2166     int unit,
   2167     bcm_oam_event_types_t event_types,
   2168     bcm_oam_pm_event_cb cb)
   2169 {
   2170     int result = BCM_E_UNAVAIL;
   2171 
   2172 #if defined(INCLUDE_BHH) || defined(INCLUDE_MPLS_LM_DM)
   2173 #if defined(BCM_APACHE_SUPPORT)
   2174     if ((soc_feature(unit, soc_feature_fp_based_oam)) &&
   2175         (soc_feature(unit, soc_feature_oam_pm)))
   2176     {
   2177         result = bcm_fp_oam_pm_event_unregister(unit, event_types, cb);
   2178     }
   2179 #endif /* BCM_APACHE_SUPPORT */
   2180 #endif /* INCLUDE_BHH || INCLUDE_MPLS_LM_DM */
   2181 
   2182 #if defined(BCM_SABER2_SUPPORT)
   2183     if ((soc_feature(unit, soc_feature_oam)) 
   2184         && (soc_feature(unit, soc_feature_oam_pm))
   2185         &&  (SOC_IS_SABER2(unit))) {
   2186         result = bcm_sb2_oam_pm_event_unregister(unit, event_types, cb);
   2187     }
   2188 #endif /* BCM_SABER2_SUPPORT */
   2189     return result;
   2190 }
   2191 
   2192 int
   2193 bcm_esw_oam_pm_profile_attach_get(
   2194         int unit, 
   2195         bcm_oam_endpoint_t endpoint_id,
   2196         bcm_oam_pm_profile_t *profile_id)
   2197 {
   2198     int result = BCM_E_UNAVAIL;
   2199 
   2200 #if defined(INCLUDE_BHH) || defined(INCLUDE_MPLS_LM_DM)
   2201 #if defined(BCM_APACHE_SUPPORT)
   2202     if ((soc_feature(unit, soc_feature_fp_based_oam)) &&
   2203         (soc_feature(unit, soc_feature_oam_pm)))
   2204     {
   2205         result = bcm_fp_oam_pm_profile_attach_get(unit, endpoint_id,
   2206                                                   profile_id);
   2207     }
   2208 #endif /* BCM_APACHE_SUPPORT */
   2209 #endif /* INCLUDE_BHH || INCLUDE_MPLS_LM_DM */
   2210 
   2211 #if defined(BCM_KATANA2_SUPPORT)
   2212     if ((soc_feature(unit, soc_feature_oam)) 
   2213             && (soc_feature(unit, soc_feature_oam_pm))){
   2214         if (SOC_IS_SABER2(unit)) {
   2215 #if defined(BCM_SABER2_SUPPORT)
   2216         result = bcm_sb2_oam_pm_profile_attach_get(unit, endpoint_id, profile_id);
   2217 #endif
   2218         } else {
   2219 #if defined(INCLUDE_BHH)
   2220             result = bcm_kt2_oam_pm_profile_attach_get(unit, endpoint_id, profile_id);
   2221 #endif /* INCLUDE_BHH */
   2222         }
   2223     }
   2224 #endif /* BCM_SABER2_SUPPORT */
   2225     return result;
   2226 }
   2227 
   2228 int
   2229 bcm_esw_oam_pm_profile_attach(
   2230         int unit, 
   2231         bcm_oam_endpoint_t endpoint_id, 
   2232         bcm_oam_pm_profile_t profile_id)
   2233 {
   2234     int result = BCM_E_UNAVAIL;
   2235 
   2236 #if defined(INCLUDE_BHH) || defined(INCLUDE_MPLS_LM_DM)
   2237 #if defined(BCM_APACHE_SUPPORT)
   2238     if ((soc_feature(unit, soc_feature_fp_based_oam)) &&
   2239         (soc_feature(unit, soc_feature_oam_pm)))
   2240     {
   2241         result = bcm_fp_oam_pm_profile_attach(unit, endpoint_id, profile_id);
   2242     }
   2243 #endif /* BCM_APACHE_SUPPORT */
   2244 #endif /* INCLUDE_BHH || INCLUDE_MPLS_LM_DM */
   2245 
   2246 #if defined(BCM_KATANA2_SUPPORT)
   2247     if ((soc_feature(unit, soc_feature_oam)) 
   2248             && (soc_feature(unit, soc_feature_oam_pm))) {
   2249         if (SOC_IS_SABER2(unit)) {
   2250 #if defined(BCM_SABER2_SUPPORT)
   2251         result = bcm_sb2_oam_pm_profile_attach(unit, endpoint_id, profile_id);
   2252         } else {
   2253 #endif    
   2254 #if defined(INCLUDE_BHH)
   2255             result = bcm_kt2_oam_pm_profile_attach(unit, endpoint_id, profile_id);
   2256 #endif /* INCLUDE_BHH */
   2257         }
   2258     }
   2259 #endif /* BCM_SABER2_SUPPORT */
   2260     return result;
   2261 }
   2262 
   2263 int
   2264 bcm_esw_oam_pm_raw_data_read_done(
   2265         int unit,
   2266         bcm_oam_event_types_t event_types,
   2267         uint32 read_index)
   2268 {
   2269     int result = BCM_E_UNAVAIL;
   2270 
   2271 #if defined(INCLUDE_BHH) || defined(INCLUDE_MPLS_LM_DM)
   2272 #if defined(BCM_APACHE_SUPPORT)
   2273     if ((soc_feature(unit, soc_feature_fp_based_oam)) &&
   2274         (soc_feature(unit, soc_feature_oam_pm)))
   2275     {
   2276         result = bcm_fp_oam_pm_raw_data_read_done(unit, event_types, 
   2277                                                   read_index);
   2278     }
   2279 #endif /* BCM_APACHE_SUPPORT */
   2280 #endif /* INCLUDE_BHH || INCLUDE_MPLS_LM_DM */
   2281 
   2282 #if defined(BCM_SABER2_SUPPORT)
   2283     if ((soc_feature(unit, soc_feature_oam)) 
   2284         && (soc_feature(unit, soc_feature_oam_pm))
   2285         &&  (SOC_IS_SABER2(unit))) {
   2286         result = bcm_sb2_oam_pm_raw_data_read_done(unit, event_types, read_index);
   2287     }
   2288 #endif /* BCM_SABER2_SUPPORT */
   2289     return result;
   2290 }
   2291 
   2292 int
   2293 _bcm_oam_olp_fp_hw_index_get(int unit,
   2294                              bcm_field_olp_header_type_t olp_hdr_type,
   2295                              int *hwindex)
   2296 {
   2297     if (soc_feature(unit, soc_feature_oam)) {
   2298         if (SOC_IS_SABER2(unit)) {
   2299 #if defined (BCM_SABER2_SUPPORT)
   2300             return _bcm_sb2_oam_olp_fp_hw_index_get(unit, olp_hdr_type, hwindex);
   2301 #endif
   2302         } else if (SOC_IS_KATANA2(unit)) {
   2303 #if defined (BCM_KATANA2_SUPPORT)
   2304             return _bcm_kt2_oam_olp_fp_hw_index_get(unit, olp_hdr_type, hwindex);
   2305 #endif
   2306         }
   2307     } else if(soc_feature(unit, soc_feature_fp_based_oam)) {
   2308 #if defined(BCM_TRIDENT2PLUS_SUPPORT)
   2309        return _bcm_td2p_oam_olp_fp_hw_index_get(unit, olp_hdr_type, hwindex);
   2310 #endif
   2311     }
   2312 
   2313     return BCM_E_UNAVAIL;
   2314 }
   2315 
   2316 int
   2317 _bcm_oam_olp_hw_index_olp_type_get(int unit,
   2318                                    int hwindex,
   2319                                    bcm_field_olp_header_type_t *olp_hdr_type)
   2320 {
   2321     if (soc_feature(unit, soc_feature_oam)) {
   2322         if (SOC_IS_SABER2(unit)) {
   2323 #if defined (BCM_SABER2_SUPPORT)
   2324             return _bcm_sb2_oam_olp_hw_index_olp_type_get(
   2325                                                    unit, hwindex, olp_hdr_type);
   2326 #endif
   2327         } else if (SOC_IS_KATANA2(unit)) {
   2328 #if defined (BCM_KATANA2_SUPPORT)
   2329             return _bcm_kt2_oam_olp_hw_index_olp_type_get(
   2330                                                     unit, hwindex, olp_hdr_type);
   2331 #endif
   2332         }
   2333     } else if(soc_feature(unit, soc_feature_fp_based_oam)) {
   2334 #if defined(BCM_TRIDENT2PLUS_SUPPORT)
   2335        return _bcm_td2p_oam_olp_hw_index_olp_type_get(
   2336                                                     unit, hwindex, olp_hdr_type);
   2337 #endif
   2338     }
   2339 
   2340     return BCM_E_UNAVAIL;
   2341 }
   2342 
   2343 int
   2344 bcm_esw_oam_opcode_group_set(
   2345         int unit, 
   2346         bcm_oam_protocol_type_t  proto,
   2347         bcm_oam_opcodes_t opcodes, 
   2348         uint8 opcode_group)
   2349 {
   2350     int result = BCM_E_UNAVAIL;
   2351 #if defined(BCM_SABER2_SUPPORT)
   2352     if ((soc_feature(unit, soc_feature_oam)) 
   2353             &&  (SOC_IS_SABER2(unit))) {
   2354         result = bcm_sb2_oam_opcode_group_set(unit, proto, opcodes, opcode_group);
   2355     }    
   2356 #endif /* BCM_SABER2_SUPPORT */
   2357     return result;
   2358 }
   2359 
   2360 int
   2361 bcm_esw_oam_opcode_group_get(
   2362         int unit, 
   2363         bcm_oam_protocol_type_t  proto,
   2364         bcm_oam_opcode_t opcode, 
   2365         uint8 *opcode_group)
   2366 {
   2367     int result = BCM_E_UNAVAIL;
   2368 #if defined(BCM_SABER2_SUPPORT)
   2369     if ((soc_feature(unit, soc_feature_oam)) 
   2370             &&  (SOC_IS_SABER2(unit))) {
   2371         result = bcm_sb2_oam_opcode_group_get(unit, proto, opcode, opcode_group);
   2372     }    
   2373 #endif /* BCM_SABER2_SUPPORT */
   2374     return result;
   2375 }
   2376 int
   2377 bcm_esw_oam_endpoint_gport_egress_attach(int unit,
   2378                                          bcm_oam_endpoint_t endpoint,
   2379                                          bcm_gport_t gport)
   2380 {
   2381     int result = BCM_E_UNAVAIL;
   2382 #if defined(BCM_SABER2_SUPPORT)
   2383     if ((soc_feature(unit, soc_feature_oam)) 
   2384             &&  (SOC_IS_SABER2(unit))) {
   2385         result = bcm_sb2_oam_endpoint_gport_egress_attach(unit, endpoint,
   2386                                                           gport);
   2387     }    
   2388 #endif /* BCM_SABER2_SUPPORT */
   2389     return result;
   2390 }
   2391 
   2392 int
   2393 bcm_esw_oam_endpoint_gport_egress_detach(int unit,
   2394                                          bcm_oam_endpoint_t endpoint,
   2395                                          bcm_gport_t gport)
   2396 {
   2397     int result = BCM_E_UNAVAIL;
   2398 #if defined(BCM_SABER2_SUPPORT)
   2399     if ((soc_feature(unit, soc_feature_oam)) 
   2400             &&  (SOC_IS_SABER2(unit))) {
   2401         result = bcm_sb2_oam_endpoint_gport_egress_detach(unit, endpoint,
   2402                                                           gport);
   2403     }    
   2404 #endif /* BCM_SABER2_SUPPORT */
   2405     return result;
   2406 }
   2407 
   2408 int
   2409 bcm_esw_oam_endpoint_gport_egress_attach_get(int unit,
   2410                                          bcm_oam_endpoint_t endpoint,
   2411                                          int size,
   2412                                          bcm_gport_t *gport,
   2413                                          int *num_gports)
   2414 {
   2415     int result = BCM_E_UNAVAIL;
   2416 #if defined(BCM_SABER2_SUPPORT)
   2417     if ((soc_feature(unit, soc_feature_oam)) 
   2418             &&  (SOC_IS_SABER2(unit))) {
   2419         result = bcm_sb2_oam_endpoint_gport_egress_attach_get(unit,
   2420                                                         endpoint, 
   2421                                                         size, 
   2422                                                         gport, 
   2423                                                         num_gports);
   2424     }    
   2425 #endif /* BCM_SABER2_SUPPORT */
   2426     return result;
   2427 }
   2428 
   2429 int
   2430 bcm_esw_oam_endpoint_egress_intf_egress_attach(int unit,
   2431                                          bcm_oam_endpoint_t endpoint_id,
   2432                                          bcm_if_t egress_intf)
   2433 {
   2434     int result = BCM_E_UNAVAIL;
   2435 #if defined(BCM_SABER2_SUPPORT)
   2436     if ((soc_feature(unit, soc_feature_oam)) 
   2437             &&  (SOC_IS_SABER2(unit))) {
   2438         
   2439         result = bcm_sb2_oam_endpoint_egress_intf_egress_attach(unit,
   2440                 endpoint_id, 
   2441                 egress_intf);
   2442     }    
   2443 #endif /* BCM_SABER2_SUPPORT */
   2444     return result;
   2445 }
   2446 
   2447 int
   2448 bcm_esw_oam_endpoint_egress_intf_egress_detach(int unit,
   2449                                          bcm_oam_endpoint_t endpoint_id,
   2450                                          bcm_if_t egress_intf)
   2451 {
   2452     int result = BCM_E_UNAVAIL;
   2453 #if defined(BCM_SABER2_SUPPORT)
   2454     if ((soc_feature(unit, soc_feature_oam)) 
   2455             &&  (SOC_IS_SABER2(unit))) {
   2456 
   2457         result = bcm_sb2_oam_endpoint_egress_intf_egress_detach(unit,
   2458                     endpoint_id,
   2459                     egress_intf);
   2460     }    
   2461 #endif /* BCM_SABER2_SUPPORT */
   2462     return result;
   2463 }
   2464 
   2465 int
   2466 bcm_esw_oam_endpoint_egress_intf_egress_attach_get(int unit,
   2467                                          bcm_oam_endpoint_t endpoint_id,
   2468                                          int max_count,
   2469                                          bcm_if_t *egress_intf,
   2470                                          int *count)
   2471 {
   2472     int result = BCM_E_UNAVAIL;
   2473 #if defined(BCM_SABER2_SUPPORT)
   2474     if ((soc_feature(unit, soc_feature_oam)) 
   2475             &&  (SOC_IS_SABER2(unit))) {
   2476 
   2477         result = bcm_sb2_oam_endpoint_egress_intf_egress_attach_get(unit,
   2478                     endpoint_id,
   2479                     max_count,
   2480                     egress_intf,
   2481                     count);
   2482     }    
   2483 #endif /* BCM_SABER2_SUPPORT */
   2484     return result;
   2485 }
   2486 
   2487 /*
   2488  * Function:
   2489  *      _bcm_oam_drop_control_fp_encode
   2490  * Purpose:
   2491  *      Convert a Drop Control mep_type to FP data
   2492  *      and mask
   2493  * Parameters:
   2494  *      unit     - (IN)  Unit number.
   2495  *      mep_type - (IN)  Mep type
   2496  *      data     - (OUT) Data for FP qualifier
   2497  *      mask     - (OUT) Mask for FP qualifier
   2498  * Returns:
   2499  *      BCM_E_XXX
   2500  * Notes:
   2501  */
   2502 int
   2503 _bcm_oam_drop_control_fp_encode (int unit,
   2504                                  bcm_field_oam_drop_mep_type_t mep_type,
   2505                                  uint8 *data,
   2506                                  uint8 *mask)
   2507 {
   2508 #if defined(BCM_APACHE_SUPPORT)
   2509     if (soc_feature(unit, soc_feature_fp_oam_drop_control)) {
   2510         return _bcm_apache_oam_drop_control_fp_encode(mep_type, data, mask);
   2511     }
   2512 #endif
   2513     return BCM_E_UNAVAIL;
   2514 }
   2515  
   2516 /*
   2517  *      bcm_esw_oam_endpoint_faults_multi_get
   2518  * Purpose:
   2519  *      Function to get faults for multiple endpoints per protocl
   2520  *      in a single call.
   2521  * Parameters:
   2522  *      unit                (IN) BCM device number
   2523  *      flags               (IN) Flags is kept unused as of now. 
   2524  *                               This is for any future enhancement
   2525  *      endpoint_protocol   (IN) Protocol type of the endpoints to retrieve faults
   2526  *      max_endpoints       (IN) Number of max endpoint for the protocol
   2527  *      faults              (OUT) Pointer to faults for all endpoints
   2528  *      endpoint_count      (OUT) Pointer to Number of valid endpoints with faults, 
   2529  *                                by get API. 
   2530  *
   2531  * Returns:
   2532  *      BCM_E_NONE          No error
   2533  *      BCM_E_XXXX          Error
   2534  */
   2535 
   2536 
   2537 int 
   2538 bcm_esw_oam_endpoint_faults_multi_get(
   2539         int unit,
   2540         uint32 flags,
   2541         bcm_oam_protocol_type_t endpoint_protocol,
   2542         uint32 max_endpoints,
   2543         bcm_oam_endpoint_fault_t *faults,
   2544         uint32 *endpoint_count)
   2545 {
   2546     int result = BCM_E_UNAVAIL;
   2547 
   2548 #if (defined(BCM_KATANA_SUPPORT) || defined(BCM_TRIUMPH3_SUPPORT)) && defined(INCLUDE_BHH) \
   2549     && defined(INCLUDE_OAM_FAULTS_MULTI_GET)
   2550 
   2551     if (soc_feature(unit, soc_feature_oam) &&
   2552         soc_feature(unit, soc_feature_faults_multi_ep_get)) {
   2553         if (SOC_IS_SABER2(unit)) {
   2554             result = bcm_sb2_oam_endpoint_faults_multi_get(
   2555                          unit,
   2556                          flags,
   2557                          endpoint_protocol,
   2558                          max_endpoints,
   2559                          faults,
   2560                          endpoint_count);
   2561         } else if (SOC_IS_KATANA2(unit)) {
   2562             result = bcm_kt2_oam_endpoint_faults_multi_get(
   2563                          unit,
   2564                         flags,
   2565                         endpoint_protocol,
   2566                         max_endpoints,
   2567                        faults,
   2568                        endpoint_count);
   2569         } else if (SOC_IS_TRIUMPH3(unit)) {
   2570             result = bcm_tr3_oam_endpoint_faults_multi_get(
   2571                          unit,
   2572                         flags,
   2573                         endpoint_protocol,
   2574                         max_endpoints,
   2575                         faults,
   2576                         endpoint_count);
   2577 
   2578         } else if (SOC_IS_KATANA(unit)) {
   2579             result = bcm_en_oam_endpoint_faults_multi_get(
   2580                          unit,
   2581                          flags,
   2582                          endpoint_protocol,
   2583                          max_endpoints,
   2584                          faults,
   2585                          endpoint_count);
   2586         }
   2587     }
   2588 #endif /* BCM_KATANA_SUPPORT */
   2589 
   2590     return result; 
   2591 }
   2592 
   2593 int 
   2594 bcm_esw_oam_opcodes_count_profile_create(
   2595         int unit, 
   2596         uint8 *lm_count_profile)
   2597 {
   2598     int result = BCM_E_UNAVAIL; 
   2599 #if defined(BCM_METROLITE_SUPPORT)
   2600         if(SOC_IS_METROLITE(unit)) {
   2601         result = bcm_ml_oam_opcodes_count_profile_create(
   2602             unit,
   2603             lm_count_profile);
   2604         }
   2605 #endif
   2606     return result;
   2607 }
   2608 
   2609 int 
   2610 bcm_esw_oam_opcodes_count_profile_delete(
   2611         int unit, 
   2612         uint8 lm_count_profile)
   2613 {
   2614     int result = BCM_E_UNAVAIL; 
   2615 #if defined(BCM_METROLITE_SUPPORT)
   2616     if(SOC_IS_METROLITE(unit)) {
   2617     result = bcm_ml_oam_opcodes_count_profile_delete(
   2618         unit, 
   2619         lm_count_profile); 
   2620     }
   2621 #endif
   2622     return result;
   2623 }
   2624 
   2625 int 
   2626 bcm_esw_oam_opcodes_count_profile_get(
   2627         int unit, 
   2628         uint8 lm_count_profile, 
   2629         uint8 count_enable, 
   2630         bcm_oam_opcodes_t *opcodes_bitmap)
   2631 {
   2632     int result = BCM_E_UNAVAIL;
   2633 #if defined(BCM_METROLITE_SUPPORT)
   2634     if(SOC_IS_METROLITE(unit)) {
   2635     result = bcm_ml_oam_opcodes_count_profile_get(
   2636         unit, 
   2637         lm_count_profile, 
   2638         count_enable, 
   2639         opcodes_bitmap); 
   2640     }
   2641 #endif  
   2642     return result;
   2643 }
   2644 
   2645 int 
   2646 bcm_esw_oam_opcodes_count_profile_set(
   2647         int unit, 
   2648         uint8 lm_count_profile, 
   2649         uint8 count_enable, 
   2650         bcm_oam_opcodes_t *opcodes_bitmap)
   2651 {
   2652     int result = BCM_E_UNAVAIL; 
   2653 #if defined(BCM_METROLITE_SUPPORT)
   2654     if(SOC_IS_METROLITE(unit)) {
   2655     result = bcm_ml_oam_opcodes_count_profile_set(
   2656         unit, 
   2657         lm_count_profile, 
   2658         count_enable, 
   2659         opcodes_bitmap); 
   2660     }
   2661 #endif
   2662     return result;
   2663 }
   2664 
   2665 int 
   2666 bcm_esw_oam_trunk_ports_add(
   2667         int unit, 
   2668         bcm_gport_t trunk_gport, 
   2669         int max_ports, 
   2670         bcm_gport_t *port_arr)
   2671 {
   2672     int result = BCM_E_UNAVAIL; 
   2673 #if defined (INCLUDE_CCM) || defined (INCLUDE_BHH) || defined(INCLUDE_MPLS_LM_DM)
   2674 #if defined(BCM_TRIDENT2PLUS_SUPPORT)
   2675     if((SOC_IS_TRIDENT2PLUS(unit) || SOC_IS_MONTEREY(unit)) &&
   2676        soc_feature(unit, soc_feature_fp_based_oam)) {
   2677     result = bcm_fp_oam_trunk_ports_add(
   2678              unit,
   2679              trunk_gport,
   2680              max_ports,
   2681              port_arr);
   2682     }
   2683 #endif
   2684 #endif
   2685 
   2686 #if defined(BCM_KATANA2_SUPPORT)
   2687         if(SOC_IS_SABER2(unit)){
   2688 #if defined (BCM_SABER2_SUPPORT)
   2689             result = bcm_sb2_oam_trunk_ports_add(unit, trunk_gport, max_ports, port_arr);
   2690 #endif
   2691         }
   2692         else if (SOC_IS_KATANA2(unit)) {
   2693             result = bcm_kt2_oam_trunk_ports_add(unit, trunk_gport, max_ports, port_arr);
   2694         }
   2695 #endif
   2696 
   2697 #if defined (INCLUDE_BHH)
   2698     if (SOC_IS_KATANA(unit)) {
   2699 #if defined(BCM_KATANA_SUPPORT)
   2700         result = bcm_en_oam_trunk_ports_add(unit, trunk_gport,
   2701                                             max_ports, port_arr);
   2702 #endif /* BCM_KATANA_SUPPORT */
   2703     } else if (SOC_IS_TRIUMPH3(unit)) {
   2704 #if defined(BCM_TRIUMPH3_SUPPORT)
   2705         result = bcm_tr3_oam_trunk_ports_add(unit, trunk_gport,
   2706                                              max_ports, port_arr);
   2707 #endif /* BCM_TRIUMPH3_SUPPORT */
   2708     }
   2709 #endif /* INCLUDE_BHH */
   2710     return result;
   2711 }
   2712 
   2713 int 
   2714 bcm_esw_oam_trunk_ports_delete(
   2715         int unit, 
   2716         bcm_gport_t trunk_gport, 
   2717         int max_ports, 
   2718         bcm_gport_t *port_arr)
   2719 {
   2720     int result = BCM_E_UNAVAIL; 
   2721 #if defined (INCLUDE_CCM) || defined (INCLUDE_BHH) || defined(INCLUDE_MPLS_LM_DM)
   2722 #if defined(BCM_TRIDENT2PLUS_SUPPORT)
   2723     if(SOC_IS_TRIDENT2PLUS(unit) &&
   2724        soc_feature(unit, soc_feature_fp_based_oam)) {
   2725     result = bcm_fp_oam_trunk_ports_delete(
   2726              unit,
   2727              trunk_gport,
   2728              max_ports,
   2729              port_arr);
   2730     }
   2731 #endif
   2732 #endif
   2733 
   2734 #if defined(BCM_KATANA2_SUPPORT)
   2735         if(SOC_IS_SABER2(unit)){
   2736 #if defined (BCM_SABER2_SUPPORT)
   2737             result = bcm_sb2_oam_trunk_ports_delete(unit, trunk_gport, max_ports, port_arr);
   2738 #endif
   2739         }
   2740         else if (SOC_IS_KATANA2(unit)) {
   2741             result = bcm_kt2_oam_trunk_ports_delete(unit, trunk_gport, max_ports, port_arr);
   2742         }
   2743 #endif
   2744 
   2745 #if defined (INCLUDE_BHH)
   2746     if (SOC_IS_KATANA(unit)) {
   2747 #if defined(BCM_KATANA_SUPPORT)
   2748         result = bcm_en_oam_trunk_ports_delete(unit, trunk_gport,
   2749                                                max_ports, port_arr);
   2750 #endif /* BCM_KATANA_SUPPORT */
   2751     } else if (SOC_IS_TRIUMPH3(unit)) {
   2752 #if defined(BCM_TRIUMPH3_SUPPORT)
   2753         result = bcm_tr3_oam_trunk_ports_delete(unit, trunk_gport,
   2754                                                 max_ports, port_arr);
   2755 #endif /* BCM_TRIUMPH3_SUPPORT */
   2756     }
   2757 #endif /* INCLUDE_BHH */
   2758     return result;
   2759 }
   2760 
   2761 int 
   2762 bcm_esw_oam_trunk_ports_get(
   2763         int unit, 
   2764         bcm_gport_t trunk_gport, 
   2765         int max_ports, 
   2766         bcm_gport_t *port_arr,
   2767         int *port_count)
   2768 {
   2769     int result = BCM_E_UNAVAIL; 
   2770 #if defined (INCLUDE_CCM) || defined (INCLUDE_BHH) || defined(INCLUDE_MPLS_LM_DM)
   2771 #if defined(BCM_TRIDENT2PLUS_SUPPORT)
   2772     if(SOC_IS_TRIDENT2PLUS(unit) &&
   2773        soc_feature(unit, soc_feature_fp_based_oam)) {
   2774     result = bcm_fp_oam_trunk_ports_get(
   2775              unit,
   2776              trunk_gport,
   2777              max_ports,
   2778              port_arr,
   2779              port_count);
   2780     }
   2781 #endif
   2782 #endif
   2783 
   2784 #if defined (INCLUDE_BHH)
   2785     if (SOC_IS_KATANA(unit)) {
   2786 #if defined(BCM_KATANA_SUPPORT)
   2787         result = bcm_en_oam_trunk_ports_get(unit, trunk_gport, max_ports,
   2788                                             port_arr, port_count);
   2789 #endif /* BCM_KATANA_SUPPORT */
   2790     } else if (SOC_IS_TRIUMPH3(unit)) {
   2791 #if defined(BCM_TRIUMPH3_SUPPORT)
   2792         result = bcm_tr3_oam_trunk_ports_get(unit, trunk_gport, max_ports,
   2793                                              port_arr, port_count);
   2794 #endif /* BCM_TRIUMPH3_SUPPORT */
   2795     }
   2796 #endif /* INCLUDE_BHH */
   2797    return result;
   2798 }
   2799 
   2800 /*
   2801  * Function:
   2802  *      bcm_esw_oam_csf_add
   2803  * Purpose:
   2804  *      Start CSF PDU transmission
   2805  * Parameters:
   2806  *      unit    - (IN)    Unit number.
   2807  *      csf_ptr - (INOUT) CSF object
   2808  * result =s:
   2809  *      BCM_E_XXX
   2810  * Notes:
   2811  */
   2812 int bcm_esw_oam_csf_add(int unit, bcm_oam_csf_t *csf_ptr)
   2813 {
   2814 #if defined(INCLUDE_BHH)
   2815     if (!soc_feature(unit, soc_feature_bhh)) {
   2816         return BCM_E_UNAVAIL;
   2817     }
   2818 
   2819     if (SOC_IS_SABER2(unit)) {
   2820 #if defined(BCM_SABER2_SUPPORT)
   2821         return bcm_sb2_oam_csf_add(unit, csf_ptr);
   2822 #endif /* BCM_KATANA2_SUPPORT */
   2823     } else if (SOC_IS_KATANA2(unit)) {
   2824 #if defined(BCM_KATANA2_SUPPORT)
   2825         return bcm_kt2_oam_csf_add(unit, csf_ptr);
   2826 #endif /* BCM_KATANA2_SUPPORT */
   2827     } else if (SOC_IS_TRIUMPH3(unit)) {
   2828 #if defined(BCM_TRIUMPH3_SUPPORT)
   2829         return bcm_tr3_oam_csf_add(unit, csf_ptr);
   2830 #endif /* BCM_TRIUMPH3_SUPPORT */
   2831     } else if (SOC_IS_KATANA(unit)) {
   2832 #if defined(BCM_KATANA_SUPPORT)
   2833         return bcm_en_oam_csf_add(unit, csf_ptr);
   2834 #endif /* BCM_KATANA_SUPPORT */
   2835     } else if (soc_feature(unit, soc_feature_fp_based_oam)) {
   2836 #if defined(BCM_APACHE_SUPPORT)
   2837         return _bcm_fp_oam_csf_add(unit, csf_ptr);
   2838 #endif /* BCM_APACHE_SUPPORT */
   2839     }
   2840 
   2841 #endif /* INCLUDE_BHH */
   2842 
   2843     return BCM_E_UNAVAIL;
   2844 }
   2845 
   2846 /*
   2847  * Function:
   2848  *      bcm_esw_oam_csf_get
   2849  * Purpose:
   2850  *      Get CSF info
   2851  * Parameters:
   2852  *      unit    - (IN)  Unit number.
   2853  *      csf_ptr - (OUT) CSF object
   2854  * result =s:
   2855  *      BCM_E_XXX
   2856  * Notes:
   2857  */
   2858 int bcm_esw_oam_csf_get(int unit, bcm_oam_csf_t *csf_ptr)
   2859 {
   2860 #if defined(INCLUDE_BHH)
   2861     if (!soc_feature(unit, soc_feature_bhh)) {
   2862         return BCM_E_UNAVAIL;
   2863     }
   2864 
   2865     if (SOC_IS_SABER2(unit)) {
   2866 #if defined(BCM_SABER2_SUPPORT)
   2867         return bcm_sb2_oam_csf_get(unit, csf_ptr);
   2868 #endif /* BCM_KATANA2_SUPPORT */
   2869     } else if (SOC_IS_KATANA2(unit)) {
   2870 #if defined(BCM_KATANA2_SUPPORT)
   2871         return bcm_kt2_oam_csf_get(unit, csf_ptr);
   2872 #endif /* BCM_KATANA2_SUPPORT */
   2873     } else if (SOC_IS_TRIUMPH3(unit)) {
   2874 #if defined(BCM_TRIUMPH3_SUPPORT)
   2875         return bcm_tr3_oam_csf_get(unit, csf_ptr);
   2876 #endif /* BCM_TRIUMPH3_SUPPORT */
   2877     } else if (SOC_IS_KATANA(unit)) {
   2878 #if defined(BCM_KATANA_SUPPORT)
   2879         return bcm_en_oam_csf_get(unit, csf_ptr);
   2880 #endif /* BCM_KATANA_SUPPORT */
   2881     } else if (soc_feature(unit, soc_feature_fp_based_oam)) {
   2882 #if defined(BCM_APACHE_SUPPORT)
   2883         return _bcm_fp_oam_csf_get(unit, csf_ptr);
   2884 #endif /* BCM_APACHE_SUPPORT */
   2885     }
   2886 
   2887 #endif /* INCLUDE_BHH */
   2888     return BCM_E_UNAVAIL;
   2889 }
   2890 
   2891 /*
   2892  * Function:
   2893  *      bcm_esw_oam_csf_delete
   2894  * Purpose:
   2895  *      Stop CSF PDU transmission
   2896  * Parameters:
   2897  *      unit    - (IN  Unit number.
   2898  *      csf_ptr - (IN) CSF object
   2899  * result =s:
   2900  *      BCM_E_XXX
   2901  * Notes:
   2902  */
   2903 int bcm_esw_oam_csf_delete(int unit, bcm_oam_csf_t *csf_ptr)
   2904 {
   2905 #if defined(INCLUDE_BHH)
   2906     if (!soc_feature(unit, soc_feature_bhh)) {
   2907         return BCM_E_UNAVAIL;
   2908     }
   2909 
   2910     if (SOC_IS_SABER2(unit)) {
   2911 #if defined(BCM_SABER2_SUPPORT)
   2912         return bcm_sb2_oam_csf_delete(unit, csf_ptr);
   2913 #endif /* BCM_KATANA2_SUPPORT */
   2914     } else if (SOC_IS_KATANA2(unit)) {
   2915 #if defined(BCM_KATANA2_SUPPORT)
   2916         return bcm_kt2_oam_csf_delete(unit, csf_ptr);
   2917 #endif /* BCM_KATANA2_SUPPORT */
   2918     } else if (SOC_IS_TRIUMPH3(unit)) {
   2919 #if defined(BCM_TRIUMPH3_SUPPORT)
   2920         return bcm_tr3_oam_csf_delete(unit, csf_ptr);
   2921 #endif /* BCM_TRIUMPH3_SUPPORT */
   2922     } else if (SOC_IS_KATANA(unit)) {
   2923 #if defined(BCM_KATANA_SUPPORT)
   2924         return bcm_en_oam_csf_delete(unit, csf_ptr);
   2925 #endif /* BCM_KATANA_SUPPORT */
   2926     } else if (soc_feature(unit, soc_feature_fp_based_oam)) {
   2927 #if defined(BCM_APACHE_SUPPORT)
   2928         return _bcm_fp_oam_csf_delete(unit, csf_ptr);
   2929 #endif /* BCM_APACHE_SUPPORT */
   2930     }
   2931 
   2932 #endif /* INCLUDE_BHH */
   2933     return BCM_E_UNAVAIL;
   2934 }
   2935 
   2936 #if defined (INCLUDE_BHH)
   2937 int _bcm_oam_bhh_appl_callback(int unit,
   2938                                     int uC,
   2939                                     soc_cmic_uc_shutdown_stage_t stage,
   2940                                     void *user_data) {
   2941     int result = BCM_E_UNAVAIL;
   2942 
   2943     if (soc_feature(unit, soc_feature_bhh) &&
   2944         (stage == SOC_CMIC_UC_SHUTDOWN_HALTED)) {
   2945         if (SOC_IS_SABER2(unit)) {
   2946             result = _bcm_sb2_oam_bhh_appl_callback (unit, uC, stage,
   2947                                                      user_data);
   2948         } else if (SOC_IS_KATANA2(unit)) {
   2949             result = _bcm_kt2_oam_bhh_appl_callback (unit, uC, stage,
   2950                                                      user_data);
   2951         } else if (SOC_IS_APACHE(unit)) {
   2952             result = _bcm_fp_oam_bhh_appl_callback (unit, uC, stage,
   2953                                                      user_data);
   2954         } else if (SOC_IS_TRIUMPH3(unit)) {
   2955             result = _bcm_tr3_oam_bhh_appl_callback (unit, uC, stage,
   2956                                                      user_data);
   2957         } else if (SOC_IS_KATANA(unit)) {
   2958             result = _bcm_en_oam_bhh_appl_callback (unit, uC, stage,
   2959                                                      user_data);
   2960         }
   2961     }
   2962 
   2963     return result;
   2964 
   2965 }
   2966 #endif
   2967 
   2968 #if defined (INCLUDE_ETH_LM_DM)
   2969 int _bcm_oam_eth_lm_dm_appl_callback(int unit,
   2970                                     int uC,
   2971                                     soc_cmic_uc_shutdown_stage_t stage,
   2972                                     void *user_data) {
   2973     int result = BCM_E_UNAVAIL;
   2974 
   2975     if (soc_feature(unit, soc_feature_eth_lm_dm) &&
   2976         (stage == SOC_CMIC_UC_SHUTDOWN_HALTED)) {
   2977         if (SOC_IS_SABER2(unit)) {
   2978             result = _bcm_sb2_oam_eth_lm_dm_appl_callback (unit, uC, stage,
   2979                                                      user_data);
   2980         }
   2981     }
   2982 
   2983     return result;
   2984 
   2985 }
   2986 #endif
   2987 
   2988 #if defined (INCLUDE_MPLS_LM_DM)
   2989 int _bcm_oam_mpls_lm_dm_appl_callback(int unit,
   2990                                     int uC,
   2991                                     soc_cmic_uc_shutdown_stage_t stage,
   2992                                     void *user_data) {
   2993     int result = BCM_E_UNAVAIL;
   2994 
   2995     /* soc feature mpls_lm_dm is present only for Apache, not for Saber2 */
   2996     if (stage == SOC_CMIC_UC_SHUTDOWN_HALTED) {
   2997         if (SOC_IS_SABER2(unit)) {
   2998             result = _bcm_sb2_oam_mpls_lm_dm_appl_callback (unit, uC, stage,
   2999                                                      user_data);
   3000         }else if ((SOC_IS_APACHE(unit)) && 
   3001             soc_feature(unit, soc_feature_mpls_lm_dm)) {
   3002             result = _bcm_fp_oam_mpls_lm_dm_appl_callback (unit, uC, stage,
   3003                                                      user_data);
   3004         } 
   3005     }
   3006 
   3007     return result;
   3008 
   3009 }
   3010 #endif
   3011 
   3012 /*
   3013  * Function:
   3014  *      _bcm_esw_oam_lmep_trunk_tx_config_recover
   3015  * Purpose:
   3016  *     Recover OAM local endpoint trunk member index configuration.
   3017  * Parameters:
   3018  *     unit        - (IN) BCM device number
   3019  *     port_id     - (IN) Port number for which trunk_index needs to be recovered
   3020  *     trunk_id    - (IN) Trunk id for which member index is to be recovered
   3021  *     trunk_index - (Out) Pointer to derive trunk member index
   3022  * Returns:
   3023  *     BCM_E_XXX
   3024  */
   3025     int
   3026 _bcm_esw_oam_lmep_tx_trunk_config_recover(int unit, 
   3027         bcm_trunk_t             trunk_id, 
   3028         bcm_port_t              port_id,
   3029         int                     *trunk_index)
   3030 {
   3031     bcm_trunk_member_t      *member_array = NULL; /* Trunk member array */
   3032     int                     member_count = 0;     /* No. of member ports in trunk */
   3033     bcm_trunk_info_t        trunk_info;
   3034     int                     index;
   3035     bcm_gport_t             gport;        /* Gport value. */
   3036     int rv;
   3037 
   3038     /* Get count of ports in this trunk. */
   3039     rv = bcm_esw_trunk_get(unit, trunk_id, NULL, 0,
   3040             NULL, &member_count);
   3041 
   3042     if(BCM_FAILURE(rv)) {
   3043         return (BCM_E_NONE);
   3044     }
   3045 
   3046     if (0 == member_count) {
   3047         /* No members have been added to the trunk group yet */
   3048         return (BCM_E_NONE);
   3049     }
   3050 
   3051     BCM_IF_ERROR_RETURN(bcm_esw_port_gport_get(unit, port_id, &gport));
   3052 
   3053     _BCM_OAM_ALLOC(member_array, bcm_trunk_member_t,
   3054             sizeof(bcm_trunk_member_t) * member_count, "Trunk info");
   3055     if (NULL == member_array) {
   3056         return (BCM_E_MEMORY);
   3057     }
   3058 
   3059     /* Get Trunk Info for the Trunk ID. */
   3060     rv = bcm_esw_trunk_get(unit, trunk_id, &trunk_info,
   3061             member_count, member_array, &member_count);
   3062     if (BCM_FAILURE(rv)) {
   3063         sal_free(member_array);
   3064         return (BCM_E_NONE);
   3065     }
   3066     /* Iterate to get the trunk member index for the gport */
   3067     for(index = 0;index < member_count; index++) {
   3068 
   3069         if(member_array[index].gport == gport) {
   3070             *trunk_index = index;
   3071             break;
   3072 
   3073         }
   3074     }
   3075 
   3076     sal_free(member_array);
   3077 
   3078     return (BCM_E_NONE);
   3079 }
   3080 
   3081 int bcm_esw_oam_mpls_tp_channel_type_tx_set(int unit, bcm_oam_mpls_tp_channel_type_t channel_type, int value)
   3082 {
   3083 
   3084     int result = BCM_E_UNAVAIL;
   3085 #if defined (INCLUDE_BHH)
   3086 #if defined(BCM_APACHE_SUPPORT)
   3087     if ((soc_feature(unit, soc_feature_fp_based_oam)) &&
   3088         (soc_feature(unit, soc_feature_bhh)))
   3089     {
   3090         result = bcm_fp_oam_mpls_tp_channel_type_tx_set(unit, channel_type, value);
   3091     }
   3092 #endif
   3093     if ((soc_feature(unit, soc_feature_oam)) && (soc_feature(unit, soc_feature_bhh)))
   3094     {
   3095 /* KT2 OAM */
   3096 #if defined(BCM_KATANA2_SUPPORT)
   3097         if (SOC_IS_KATANA2(unit)) {
   3098             if (SOC_IS_SABER2(unit)) {
   3099 #if defined (BCM_SABER2_SUPPORT)
   3100                 result = bcm_sb2_oam_mpls_tp_channel_type_tx_set(unit, channel_type, value);
   3101 #endif
   3102             } else if (SOC_IS_KATANA2(unit)) {
   3103                 result = bcm_kt2_oam_mpls_tp_channel_type_tx_set(unit, channel_type, value);
   3104             }
   3105         }
   3106 #endif
   3107 #if defined(BCM_TRIUMPH3_SUPPORT)
   3108         if (SOC_IS_TRIUMPH3(unit)) {
   3109             result = bcm_tr3_oam_mpls_tp_channel_type_tx_set(unit, channel_type, value);
   3110         }
   3111 #endif
   3112 #if defined(BCM_KATANA_SUPPORT)
   3113         BCM_IF_ERROR_RETURN(bcm_esw_oam_lock(unit));
   3114         if (SOC_IS_KATANAX(unit))
   3115         {
   3116                 result = bcm_en_oam_mpls_tp_channel_type_tx_set(unit, channel_type, value);
   3117         }
   3118         BCM_IF_ERROR_RETURN(bcm_esw_oam_unlock(unit));
   3119 #endif
   3120     }
   3121 #endif
   3122 
   3123     return result;
   3124 }
   3125 
   3126 int bcm_esw_oam_mpls_tp_channel_type_tx_get(int unit, bcm_oam_mpls_tp_channel_type_t channel_type, int *value)
   3127 {
   3128 
   3129     int result = BCM_E_UNAVAIL;
   3130 #if defined (INCLUDE_BHH)
   3131 #if defined(BCM_APACHE_SUPPORT)
   3132     if ((soc_feature(unit, soc_feature_fp_based_oam)) &&
   3133         (soc_feature(unit, soc_feature_bhh)))
   3134     {
   3135         result = bcm_fp_oam_mpls_tp_channel_type_tx_get(unit, channel_type, value);
   3136     }
   3137 #endif
   3138     if ((soc_feature(unit, soc_feature_oam)) && (soc_feature(unit, soc_feature_bhh)))
   3139     {
   3140 /* KT2 OAM */
   3141 #if defined(BCM_KATANA2_SUPPORT)
   3142         if (SOC_IS_KATANA2(unit)) {
   3143             if (SOC_IS_SABER2(unit)) {
   3144 #if defined (BCM_SABER2_SUPPORT)
   3145                 result = bcm_sb2_oam_mpls_tp_channel_type_tx_get(unit, channel_type, value);
   3146 #endif
   3147             } else if (SOC_IS_KATANA2(unit)) {
   3148                 result = bcm_kt2_oam_mpls_tp_channel_type_tx_get(unit, channel_type, value);
   3149             }
   3150         }
   3151 #endif
   3152 #if defined(BCM_TRIUMPH3_SUPPORT)
   3153         if (SOC_IS_TRIUMPH3(unit)) {
   3154             result = bcm_tr3_oam_mpls_tp_channel_type_tx_get(unit, channel_type, value);
   3155         }
   3156 #endif
   3157 #if defined(BCM_KATANA_SUPPORT)
   3158         BCM_IF_ERROR_RETURN(bcm_esw_oam_lock(unit));
   3159         if (SOC_IS_KATANAX(unit))
   3160         {
   3161                 result = bcm_en_oam_mpls_tp_channel_type_tx_get(unit, channel_type, value);
   3162         }
   3163         BCM_IF_ERROR_RETURN(bcm_esw_oam_unlock(unit));
   3164 #endif
   3165     }
   3166 #endif
   3167 
   3168     return result;
   3169 }
   3170 
   3171 int bcm_esw_oam_upmep_cosq_set(int unit, bcm_oam_upmep_pdu_type_t upmep_pdu_type,
   3172                            bcm_cos_queue_t cosq)
   3173 {
   3174 
   3175     int result = BCM_E_UNAVAIL;
   3176     if (soc_feature(unit, soc_feature_oam))
   3177     {
   3178 #if defined(BCM_KATANA2_SUPPORT)
   3179         if (SOC_IS_KATANA2(unit)) {
   3180             if (SOC_IS_SABER2(unit)) {
   3181 #if defined (BCM_SABER2_SUPPORT)
   3182                 result = bcm_sb2_oam_upmep_cosq_set(unit, upmep_pdu_type, cosq);
   3183 #endif
   3184             } else if (SOC_IS_KATANA2(unit)) {
   3185                 result = bcm_kt2_oam_upmep_cosq_set(unit, upmep_pdu_type, cosq);
   3186             }
   3187         }
   3188 #endif
   3189 
   3190     }
   3191     return result;
   3192 }
   3193 
   3194 int bcm_esw_oam_upmep_cosq_get(int unit, bcm_oam_upmep_pdu_type_t upmep_pdu_type,
   3195                            bcm_cos_queue_t *cosq)
   3196 {
   3197 
   3198     int result = BCM_E_UNAVAIL;
   3199     if (soc_feature(unit, soc_feature_oam))
   3200     {
   3201 #if defined(BCM_KATANA2_SUPPORT)
   3202         if (SOC_IS_KATANA2(unit)) {
   3203             if (SOC_IS_SABER2(unit)) {
   3204 #if defined (BCM_SABER2_SUPPORT)
   3205                 result = bcm_sb2_oam_upmep_cosq_get(unit, upmep_pdu_type, cosq);
   3206 #endif
   3207             } else if (SOC_IS_KATANA2(unit)) {
   3208                 result = bcm_kt2_oam_upmep_cosq_get(unit, upmep_pdu_type, cosq);
   3209             }
   3210         }
   3211 #endif
   3212 
   3213     }
   3214     return result;
   3215 }