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

vxlan.c (86405B)


      1 /*
      2  * 
      3  * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
      4  * 
      5  * Copyright 2007-2019 Broadcom Inc. All rights reserved.
      6  *
      7  * ESW VXLAN API
      8  */
      9 
     10 #if defined(INCLUDE_L3)
     11 
     12 #include <soc/drv.h>
     13 #include <soc/scache.h>
     14 #include <soc/util.h>
     15 
     16 #include <bcm/types.h>
     17 #include <bcm/error.h>
     18 #include <bcm/vxlan.h>
     19 #include <bcm_int/esw/mbcm.h>
     20 #include <bcm_int/esw_dispatch.h>
     21 #include <bcm_int/esw/trident2.h>
     22 #if defined(BCM_TRIDENT2_SUPPORT)
     23 #include <bcm_int/esw/vxlan.h>
     24 #endif
     25 #include <bcm_int/esw/flex_ctr.h>
     26 #include <bcm_int/esw/vpn.h>
     27 #include <bcm_int/esw/virtual.h>
     28 #if defined(BCM_TRIDENT2PLUS_SUPPORT)
     29 #include <bcm_int/esw/trident2plus.h>
     30 #endif
     31 #if defined(BCM_GREYHOUND2_SUPPORT)
     32 #include <bcm_int/esw/greyhound2.h>
     33 #endif /* BCM_GREYHOUND2_SUPPORT */
     34 
     35 
     36 #define VXLAN_INFO(_unit_)   (_bcm_td2_vxlan_bk_info[_unit_])
     37 
     38 /*
     39  * Function:
     40  *    bcm_esw_vxlan_init
     41  * Purpose:
     42  *    Init  VXLAN module
     43  * Parameters:
     44  *    IN :  unit
     45  * Returns:
     46  *    BCM_E_XXX
     47  */
     48 
     49 int
     50 bcm_esw_vxlan_init(int unit)
     51 {
     52 #ifdef BCM_TRIDENT2_SUPPORT
     53     if (soc_feature(unit, soc_feature_vxlan)) {
     54         return bcm_td2_vxlan_init(unit);
     55     } else
     56 #endif /* BCM_TRIDENT2_SUPPORT */
     57 #if defined(BCM_GREYHOUND2_SUPPORT)
     58     if (soc_feature(unit, soc_feature_vxlan_lite)) {
     59         return bcmi_gh2_vxlan_init(unit);
     60     } else
     61 #endif /* BCM_GREYHOUND2_SUPPORT */
     62     {
     63         return BCM_E_UNAVAIL;
     64     }
     65 }
     66 
     67 
     68  /* Function:
     69  *      bcm_vxlan_cleanup
     70  * Purpose:
     71  *      Detach the VXLAN module, clear all HW states
     72  * Parameters:
     73  *      unit     - Device Number
     74  * Returns:
     75  *      BCM_E_XXXX
     76  */
     77 
     78 int
     79 bcm_esw_vxlan_cleanup(int unit)
     80 {
     81 #ifdef BCM_TRIDENT2_SUPPORT
     82     if (soc_feature(unit, soc_feature_vxlan)) {
     83         return bcm_td2_vxlan_cleanup(unit);
     84     } else
     85 #endif /* BCM_TRIDENT2_SUPPORT */
     86 #if defined(BCM_GREYHOUND2_SUPPORT)
     87     if (soc_feature(unit, soc_feature_vxlan_lite)) {
     88         return bcmi_gh2_vxlan_cleanup(unit);
     89     } else
     90 #endif /* BCM_GREYHOUND2_SUPPORT */
     91     {
     92         return BCM_E_UNAVAIL;
     93     }
     94 }
     95 
     96  /* Function:
     97  *      bcm_esw_vxlan_vpn_create
     98  * Purpose:
     99  *      Createl L2-VPN instance
    100  * Parameters:
    101  *      unit     - Device Number
    102  *      info     - VXLAN VPN Config
    103  * Returns:
    104  *      BCM_E_XXXX
    105  */
    106 
    107 int 
    108 bcm_esw_vxlan_vpn_create( int unit, bcm_vxlan_vpn_config_t *info)
    109 {
    110     int rv;
    111 
    112 #if defined(BCM_TRIDENT2_SUPPORT)
    113     if (soc_feature(unit, soc_feature_vxlan)) {
    114          if (info == NULL) {
    115             return BCM_E_PARAM;
    116          }
    117 
    118          rv = bcm_td2_vxlan_lock(unit);
    119          if ( rv == BCM_E_NONE ) {
    120               rv = bcm_td2_vxlan_vpn_create(unit, info);
    121               bcm_td2_vxlan_unlock (unit);
    122          }
    123 
    124     } else
    125 #endif
    126 #if defined(BCM_GREYHOUND2_SUPPORT)
    127     if (soc_feature(unit, soc_feature_vxlan_lite)) {
    128         if (info == NULL) {
    129             return BCM_E_PARAM;
    130         }
    131         rv = bcmi_gh2_vxlan_lock(unit);
    132         if (rv == BCM_E_NONE) {
    133             rv = bcmi_gh2_vxlan_vpn_create(unit, info);
    134             bcmi_gh2_vxlan_unlock(unit);
    135         }
    136     } else
    137 #endif /* BCM_GREYHOUND2_SUPPORT */
    138     {
    139         rv = BCM_E_UNAVAIL;
    140     }
    141 
    142     return rv;
    143 }
    144 
    145  /* Function:
    146  *      bcm_esw_vxlan_vpn_destroy
    147  * Purpose:
    148  *      Delete L2-VPN instance
    149  * Parameters:
    150  *      unit     - Device Number
    151  *      l2vpn   - VXLAN VPN
    152  * Returns:
    153  *      BCM_E_XXXX
    154  */
    155 
    156 int 
    157 bcm_esw_vxlan_vpn_destroy(int unit, bcm_vpn_t l2vpn)
    158 {
    159     int rv;
    160 
    161 #if defined(BCM_TRIDENT2_SUPPORT)
    162     if (soc_feature(unit, soc_feature_vxlan)) {
    163          rv = bcm_td2_vxlan_lock(unit);
    164          if ( rv == BCM_E_NONE ) {
    165               rv = bcm_td2_vxlan_vpn_destroy(unit, l2vpn);
    166               bcm_td2_vxlan_unlock (unit);
    167          }
    168     } else
    169 #endif
    170 #if defined(BCM_GREYHOUND2_SUPPORT)
    171     if (soc_feature(unit, soc_feature_vxlan_lite)) {
    172         rv = bcmi_gh2_vxlan_lock(unit);
    173         if (rv == BCM_E_NONE) {
    174             rv = bcmi_gh2_vxlan_vpn_destroy(unit, l2vpn);
    175             bcmi_gh2_vxlan_unlock(unit);
    176         }
    177     } else
    178 #endif /* BCM_GREYHOUND2_SUPPORT */
    179     {
    180         rv = BCM_E_UNAVAIL;
    181     }
    182 
    183     return rv;
    184 }
    185 
    186  /* Function:
    187  *      bcm_vxlan_vpn_destroy_all
    188  * Purpose:
    189  *      Delete all L2-VPN instances
    190  * Parameters:
    191  *      unit     - Device Number
    192  * Returns:
    193  *      BCM_E_XXXX
    194  */
    195 
    196 int 
    197 bcm_esw_vxlan_vpn_destroy_all(int unit)
    198 {
    199     int rv;
    200 
    201 #if defined(BCM_TRIDENT2_SUPPORT)
    202     if (soc_feature(unit, soc_feature_vxlan)) {
    203          rv = bcm_td2_vxlan_lock(unit);
    204          if ( rv == BCM_E_NONE ) {
    205               rv = bcm_td2_vxlan_vpn_destroy_all(unit);
    206               bcm_td2_vxlan_unlock (unit);
    207          }
    208     } else
    209 #endif
    210 #if defined(BCM_GREYHOUND2_SUPPORT)
    211     if (soc_feature(unit, soc_feature_vxlan_lite)) {
    212         rv = bcmi_gh2_vxlan_lock(unit);
    213         if (rv == BCM_E_NONE) {
    214             rv = bcmi_gh2_vxlan_vpn_destroy_all(unit);
    215             bcmi_gh2_vxlan_unlock(unit);
    216         }
    217     } else
    218 #endif /* BCM_GREYHOUND2_SUPPORT */
    219     {
    220         rv = BCM_E_UNAVAIL;
    221     }
    222 
    223     return rv;
    224 }
    225 
    226 /*
    227  * Function:
    228  *      bcm_vxlan_vpn_traverse
    229  * Purpose:
    230  *      VXLAN VPN Traverse
    231  * Parameters:
    232  *      unit  - (IN)  Device Number
    233  *      cb   - (IN)  User callback function, called once per entry
    234  *      user_data  -  (IN/OUT) Cookie
    235  * Returns:
    236  *      BCM_E_XXXX
    237  */
    238 int 
    239 bcm_esw_vxlan_vpn_traverse(int unit, bcm_vxlan_vpn_traverse_cb cb, 
    240                                                           void *user_data)
    241 {
    242     int rv;
    243 
    244 #if defined(BCM_TRIDENT2_SUPPORT)
    245     if (soc_feature(unit, soc_feature_vxlan)) {
    246          rv = bcm_td2_vxlan_lock(unit);
    247          if ( rv == BCM_E_NONE ) {
    248               rv = bcm_td2_vxlan_vpn_traverse(unit, cb, user_data);
    249               bcm_td2_vxlan_unlock (unit);
    250          }
    251     } else
    252 #endif
    253 #if defined(BCM_GREYHOUND2_SUPPORT)
    254     if (soc_feature(unit, soc_feature_vxlan_lite)) {
    255         rv = bcmi_gh2_vxlan_lock(unit);
    256         if (rv == BCM_E_NONE) {
    257             rv = bcmi_gh2_vxlan_vpn_traverse(unit, cb, user_data);
    258             bcmi_gh2_vxlan_unlock(unit);
    259         }
    260     } else
    261 #endif /* BCM_GREYHOUND2_SUPPORT */
    262     {
    263         rv = BCM_E_UNAVAIL;
    264     }
    265 
    266     return rv;
    267 }
    268 
    269 /*
    270  * Function:
    271  *      bcm_esw_vxlan_port_traverse
    272  * Purpose:
    273  *      VXLAN port Traverse
    274  * Parameters:
    275  *      unit  - (IN)  Device Number
    276  *      cb   - (IN)  User callback function, called once per entry
    277  *      user_data  -  (IN/OUT) Cookie
    278  * Returns:
    279  *      BCM_E_XXXX
    280  */
    281 int 
    282 bcm_esw_vxlan_port_traverse(int unit, bcm_vxlan_port_traverse_cb cb, 
    283                                                           void *user_data)
    284 {
    285     int rv;
    286 
    287 #if defined(BCM_TRIDENT2_SUPPORT)
    288     if (soc_feature(unit, soc_feature_vxlan)) {
    289          rv = bcm_td2_vxlan_lock(unit);
    290          if ( rv == BCM_E_NONE ) {
    291               rv = bcm_td2_vxlan_port_traverse(unit, cb, user_data);
    292               bcm_td2_vxlan_unlock (unit);
    293          }
    294     } else
    295 #endif
    296 #if defined(BCM_GREYHOUND2_SUPPORT)
    297     if (soc_feature(unit, soc_feature_vxlan_lite)) {
    298         rv = bcmi_gh2_vxlan_lock(unit);
    299         if (rv == BCM_E_NONE) {
    300             rv = bcmi_gh2_vxlan_port_traverse(unit, cb, user_data);
    301             bcmi_gh2_vxlan_unlock(unit);
    302         }
    303     } else
    304 #endif /* BCM_GREYHOUND2_SUPPORT */
    305     {
    306         rv = BCM_E_UNAVAIL;
    307     }
    308 
    309     return rv;
    310 }
    311 
    312  /* Function:
    313  *      bcm_vxlan_vpn_get
    314  * Purpose:
    315  *      Get L2-VPN instance
    316  * Parameters:
    317  *      unit     - Device Number
    318  *      l2vpn   - VXLAN VPN
    319  *      info     - VXLAN VPN Config
    320  * Returns:
    321  *      BCM_E_XXXX
    322  */
    323 
    324 int 
    325 bcm_esw_vxlan_vpn_get( int unit, bcm_vpn_t l2vpn, bcm_vxlan_vpn_config_t *info)
    326 {
    327     int rv;
    328 
    329 #if defined(BCM_TRIDENT2_SUPPORT)
    330     if (soc_feature(unit, soc_feature_vxlan)) {
    331          if (info == NULL) {
    332             return BCM_E_PARAM;
    333          }
    334          rv = bcm_td2_vxlan_lock(unit);
    335          if ( rv == BCM_E_NONE ) {
    336               rv = bcm_td2_vxlan_vpn_get(unit, l2vpn, info);
    337               bcm_td2_vxlan_unlock (unit);
    338          }
    339     } else
    340 #endif
    341 #if defined(BCM_GREYHOUND2_SUPPORT)
    342     if (soc_feature(unit, soc_feature_vxlan_lite)) {
    343         if (info == NULL) {
    344             return BCM_E_PARAM;
    345         }
    346         rv = bcmi_gh2_vxlan_lock(unit);
    347         if (rv == BCM_E_NONE) {
    348             rv = bcmi_gh2_vxlan_vpn_get(unit, l2vpn, info);
    349             bcmi_gh2_vxlan_unlock(unit);
    350         }
    351     } else
    352 #endif /* BCM_GREYHOUND2_SUPPORT */
    353     {
    354         rv = BCM_E_UNAVAIL;
    355     }
    356 
    357     return rv;
    358 }
    359 
    360  /* Function:
    361  *      bcm_esw_vxlan_port_add
    362  * Purpose:
    363  *      Add Access/Network VXLAN port
    364  * Parameters:
    365  *      unit     - Device Number
    366  *      l2vpn   - VXLAN VPN
    367  *      vxlan_port     - VXLAN Gport
    368  * Returns:
    369  *      BCM_E_XXXX
    370  */
    371 
    372 int 
    373 bcm_esw_vxlan_port_add(int unit, bcm_vpn_t l2vpn, bcm_vxlan_port_t *vxlan_port)
    374 {
    375     int rv;
    376 
    377 #if defined(BCM_TRIDENT2_SUPPORT)
    378     if (soc_feature(unit, soc_feature_vxlan)) {
    379          if (vxlan_port == NULL) {
    380             return BCM_E_PARAM;
    381          }
    382          rv = bcm_td2_vxlan_lock(unit);
    383          if ( rv == BCM_E_NONE ) {
    384               rv = bcm_td2_vxlan_port_add(unit, l2vpn, vxlan_port);
    385               bcm_td2_vxlan_unlock (unit);
    386          }
    387     } else
    388 #endif
    389 #if defined(BCM_GREYHOUND2_SUPPORT)
    390     if (soc_feature(unit, soc_feature_vxlan_lite)) {
    391         if (vxlan_port == NULL) {
    392             return BCM_E_PARAM;
    393         }
    394         rv = bcmi_gh2_vxlan_lock(unit);
    395         if (rv == BCM_E_NONE) {
    396             rv = bcmi_gh2_vxlan_port_add(unit, l2vpn, vxlan_port);
    397             bcmi_gh2_vxlan_unlock(unit);
    398         }
    399     } else
    400 #endif /* BCM_GREYHOUND2_SUPPORT */
    401     {
    402         rv = BCM_E_UNAVAIL;
    403     }
    404 
    405     return rv;
    406 }
    407 
    408  /* Function:
    409  *      bcm_esw_vxlan_port_delete
    410  * Purpose:
    411  *      Delete Access/Network VXLAN port
    412  * Parameters:
    413  *      unit     - Device Number
    414  *      l2vpn   - VXLAN VPN
    415  *      vxlan_port_id     - VXLAN Gport Id
    416  * Returns:
    417  *      BCM_E_XXXX
    418  */
    419 
    420 int 
    421 bcm_esw_vxlan_port_delete( int unit, bcm_vpn_t l2vpn, bcm_gport_t vxlan_port_id)
    422 {
    423     int rv;
    424 
    425 #if defined(BCM_TRIDENT2_SUPPORT)
    426     if (soc_feature(unit, soc_feature_vxlan)) {
    427          rv = bcm_td2_vxlan_lock(unit);
    428          if ( rv == BCM_E_NONE ) {
    429               rv = bcm_td2_vxlan_port_delete(unit, l2vpn, vxlan_port_id);
    430               bcm_td2_vxlan_unlock (unit);
    431          }
    432     } else
    433 #endif
    434 #if defined(BCM_GREYHOUND2_SUPPORT)
    435     if (soc_feature(unit, soc_feature_vxlan_lite)) {
    436         rv = bcmi_gh2_vxlan_lock(unit);
    437         if (rv == BCM_E_NONE) {
    438             rv = bcmi_gh2_vxlan_port_delete(unit, l2vpn, vxlan_port_id);
    439             bcmi_gh2_vxlan_unlock(unit);
    440         }
    441     } else
    442 #endif /* BCM_GREYHOUND2_SUPPORT */
    443     {
    444         rv = BCM_E_UNAVAIL;
    445     }
    446 
    447     return rv;
    448 }
    449 
    450  /* Function:
    451  *      bcm_esw_vxlan_port_delete_all
    452  * Purpose:
    453  *      Delete all Access/Network VXLAN ports
    454  * Parameters:
    455  *      unit     - Device Number
    456  *      l2vpn   - VXLAN VPN
    457  * Returns:
    458  *      BCM_E_XXXX
    459  */
    460 
    461 int 
    462 bcm_esw_vxlan_port_delete_all(int unit, bcm_vpn_t l2vpn)
    463 {
    464     int rv;
    465 
    466 #if defined(BCM_TRIDENT2_SUPPORT)
    467     if (soc_feature(unit, soc_feature_vxlan)) {
    468          rv = bcm_td2_vxlan_lock(unit);
    469          if ( rv == BCM_E_NONE ) {
    470               rv = bcm_td2_vxlan_port_delete_all(unit, l2vpn);
    471               bcm_td2_vxlan_unlock (unit);
    472          }
    473     } else
    474 #endif
    475 #if defined(BCM_GREYHOUND2_SUPPORT)
    476     if (soc_feature(unit, soc_feature_vxlan_lite)) {
    477         rv = bcmi_gh2_vxlan_lock(unit);
    478         if (rv == BCM_E_NONE) {
    479             rv = bcmi_gh2_vxlan_port_delete_all(unit, l2vpn);
    480             bcmi_gh2_vxlan_unlock(unit);
    481         }
    482     } else
    483 #endif /* BCM_GREYHOUND2_SUPPORT */
    484     {
    485         rv = BCM_E_UNAVAIL;
    486     }
    487 
    488     return rv;
    489 }
    490 
    491  /* Function:
    492  *      bcm_esw_vxlan_port_get
    493  * Purpose:
    494  *      Get Access/Network VXLAN port info
    495  * Parameters:
    496  *      unit     - Device Number
    497  *      l2vpn   - VXLAN VPN
    498  *      vxlan_port     - VXLAN Gport
    499  * Returns:
    500  *      BCM_E_XXXX
    501  */
    502 
    503 int 
    504 bcm_esw_vxlan_port_get(int unit, bcm_vpn_t l2vpn, bcm_vxlan_port_t *vxlan_port)
    505 {
    506     int rv;
    507 
    508 #if defined(BCM_TRIDENT2_SUPPORT)
    509     if (soc_feature(unit, soc_feature_vxlan)) {
    510          if (vxlan_port == NULL) {
    511             return BCM_E_PARAM;
    512          }
    513          rv = bcm_td2_vxlan_lock(unit);
    514          if ( rv == BCM_E_NONE ) {
    515               rv = bcm_td2_vxlan_port_get(unit, l2vpn, vxlan_port);
    516               bcm_td2_vxlan_unlock (unit);
    517          }
    518     } else
    519 #endif
    520 #if defined(BCM_GREYHOUND2_SUPPORT)
    521     if (soc_feature(unit, soc_feature_vxlan_lite)) {
    522         if (vxlan_port == NULL) {
    523             return BCM_E_PARAM;
    524         }
    525         rv = bcmi_gh2_vxlan_lock(unit);
    526         if (rv == BCM_E_NONE) {
    527             rv = bcmi_gh2_vxlan_port_get(unit, l2vpn, vxlan_port);
    528             bcmi_gh2_vxlan_unlock(unit);
    529         }
    530     } else
    531 #endif /* BCM_GREYHOUND2_SUPPORT */
    532     {
    533         rv = BCM_E_UNAVAIL;
    534     }
    535 
    536     return rv;
    537 }
    538 
    539  /* Function:
    540  *      bcm_esw_vxlan_port_get_all
    541  * Purpose:
    542  *      Get all Access/Network VXLAN port info
    543  * Parameters:
    544  *      unit     - (IN) Device Number
    545  *      l2vpn   - VXLAN VPN
    546  *      port_max   - (IN) Maximum number of VXLAN ports in array
    547  *      port_array - (OUT) Array of VXLAN ports
    548  *      port_count - (OUT) Number of VXLAN ports returned in array
    549  * Returns:
    550  *      BCM_E_XXXX
    551  */
    552 
    553 int 
    554 bcm_esw_vxlan_port_get_all(
    555     int unit, 
    556     bcm_vpn_t l2vpn, 
    557     int port_max, 
    558     bcm_vxlan_port_t *port_array, 
    559     int *port_count)
    560 {
    561     int rv;
    562 
    563 #if defined(BCM_TRIDENT2_SUPPORT)
    564     if (soc_feature(unit, soc_feature_vxlan)) {
    565          if (port_count == NULL) {
    566             return BCM_E_PARAM;
    567          }
    568          rv = bcm_td2_vxlan_lock(unit);
    569          if ( rv == BCM_E_NONE ) {
    570               rv = bcm_td2_vxlan_port_get_all(unit, l2vpn, port_max, port_array, port_count);
    571               bcm_td2_vxlan_unlock (unit);
    572          }
    573     } else
    574 #endif
    575 #if defined(BCM_GREYHOUND2_SUPPORT)
    576     if (soc_feature(unit, soc_feature_vxlan_lite)) {
    577         if (port_count == NULL) {
    578             return BCM_E_PARAM;
    579         }
    580         rv = bcmi_gh2_vxlan_lock(unit);
    581         if (rv == BCM_E_NONE) {
    582             rv = bcmi_gh2_vxlan_port_get_all(unit, l2vpn, port_max, port_array, port_count);
    583             bcmi_gh2_vxlan_unlock(unit);
    584         }
    585     } else
    586 #endif /* BCM_GREYHOUND2_SUPPORT */
    587     {
    588         rv = BCM_E_UNAVAIL;
    589     }
    590 
    591     return rv;
    592 }
    593 
    594  /* Function:
    595  *      bcm_esw_vxlan_tunnel_initiator_create
    596  * Purpose:
    597  *      Create VXLAN Tunnel Initiator 
    598  * Parameters:
    599  *      unit     - Device Number
    600  *      info     - VXLAN Tunnel Initiator info
    601  * Returns:
    602  *      BCM_E_XXXX
    603  */
    604 
    605 int 
    606 bcm_esw_vxlan_tunnel_initiator_create(int unit, bcm_tunnel_initiator_t *info)
    607 {
    608     int rv;
    609 
    610 #if defined(BCM_TRIDENT2_SUPPORT)
    611     if (soc_feature(unit, soc_feature_vxlan)) {
    612          if (info == NULL) {
    613             return BCM_E_PARAM;
    614          }
    615          rv = bcm_td2_vxlan_lock(unit);
    616          if ( rv == BCM_E_NONE ) {
    617               rv = bcm_td2_vxlan_tunnel_initiator_create(unit, info);
    618               bcm_td2_vxlan_unlock (unit);
    619          }
    620     } else
    621 #endif
    622 #if defined(BCM_GREYHOUND2_SUPPORT)
    623     if (soc_feature(unit, soc_feature_vxlan_lite)) {
    624         if (info == NULL) {
    625             return BCM_E_PARAM;
    626         }
    627         rv = bcmi_gh2_vxlan_lock(unit);
    628         if (rv == BCM_E_NONE) {
    629             rv = bcmi_gh2_vxlan_tunnel_initiator_create(unit, info);
    630             bcmi_gh2_vxlan_unlock(unit);
    631         }
    632     } else
    633 #endif /* BCM_GREYHOUND2_SUPPORT */
    634     {
    635         rv = BCM_E_UNAVAIL;
    636     }
    637 
    638     return rv;
    639 }
    640 
    641 
    642  /* Function:
    643  *      bcm_esw_vxlan_tunnel_initiator_destroy
    644  * Purpose:
    645  *      Delete VXLAN Tunnel Initiator 
    646  * Parameters:
    647  *      unit     - Device Number
    648  *      vxlan_tunnel_id     - VXLAN Tunnel Initiator Id
    649  * Returns:
    650  *      BCM_E_XXXX
    651  */
    652 
    653 int 
    654 bcm_esw_vxlan_tunnel_initiator_destroy(int unit, bcm_gport_t vxlan_tunnel_id)
    655 {
    656     int rv;
    657 
    658 #if defined(BCM_TRIDENT2_SUPPORT)
    659     if (soc_feature(unit, soc_feature_vxlan)) {
    660          rv = bcm_td2_vxlan_lock(unit);
    661          if ( rv == BCM_E_NONE ) {
    662               rv = bcm_td2_vxlan_tunnel_initiator_destroy(unit, vxlan_tunnel_id);
    663               bcm_td2_vxlan_unlock (unit);
    664          }
    665     } else
    666 #endif
    667 #if defined(BCM_GREYHOUND2_SUPPORT)
    668     if (soc_feature(unit, soc_feature_vxlan_lite)) {
    669         rv = bcmi_gh2_vxlan_lock(unit);
    670         if (rv == BCM_E_NONE) {
    671             rv = bcmi_gh2_vxlan_tunnel_initiator_destroy(unit, vxlan_tunnel_id);
    672             bcmi_gh2_vxlan_unlock(unit);
    673         }
    674     } else
    675 #endif /* BCM_GREYHOUND2_SUPPORT */
    676     {
    677         rv = BCM_E_UNAVAIL;
    678     }
    679 
    680     return rv;
    681 }
    682 
    683  /* Function:
    684  *      bcm_esw_vxlan_tunnel_initiator_destroy_all
    685  * Purpose:
    686  *      Delete all VXLAN Tunnel Initiators 
    687  * Parameters:
    688  *      unit     - Device Number
    689  * Returns:
    690  *      BCM_E_XXXX
    691  */
    692 
    693 int 
    694 bcm_esw_vxlan_tunnel_initiator_destroy_all(int unit)
    695 {
    696     int rv;
    697 
    698 #if defined(BCM_TRIDENT2_SUPPORT)
    699     if (soc_feature(unit, soc_feature_vxlan)) {
    700          rv = bcm_td2_vxlan_lock(unit);
    701          if ( rv == BCM_E_NONE ) {
    702               rv = bcm_td2_vxlan_tunnel_initiator_destroy_all(unit);
    703               bcm_td2_vxlan_unlock (unit);
    704          }
    705     } else
    706 #endif
    707 #if defined(BCM_GREYHOUND2_SUPPORT)
    708     if (soc_feature(unit, soc_feature_vxlan_lite)) {
    709         rv = bcmi_gh2_vxlan_lock(unit);
    710         if (rv == BCM_E_NONE) {
    711             rv = bcmi_gh2_vxlan_tunnel_initiator_destroy_all(unit);
    712             bcmi_gh2_vxlan_unlock(unit);
    713         }
    714     } else
    715 #endif /* BCM_GREYHOUND2_SUPPORT */
    716     {
    717         rv = BCM_E_UNAVAIL;
    718     }
    719 
    720     return rv;
    721 }
    722 
    723  /* Function:
    724  *      bcm_esw_vxlan_tunnel_initiator_get
    725  * Purpose:
    726  *      Get  VXLAN Tunnel Initiator Info
    727  * Parameters:
    728  *      unit     - Device Number
    729  *      info     - VXLAN Tunnel Initiator info
    730  * Returns:
    731  *      BCM_E_XXXX
    732  */
    733 
    734 int 
    735 bcm_esw_vxlan_tunnel_initiator_get(int unit, bcm_tunnel_initiator_t *info)
    736 {
    737     int rv;
    738 
    739 #if defined(BCM_TRIDENT2_SUPPORT)
    740     if (soc_feature(unit, soc_feature_vxlan)) {
    741          if (info == NULL) {
    742             return BCM_E_PARAM;
    743          }
    744          rv = bcm_td2_vxlan_lock(unit);
    745          if ( rv == BCM_E_NONE ) {
    746               rv = bcm_td2_vxlan_tunnel_initiator_get(unit, info);
    747               bcm_td2_vxlan_unlock (unit);
    748          }
    749     } else
    750 #endif
    751 #if defined(BCM_GREYHOUND2_SUPPORT)
    752     if (soc_feature(unit, soc_feature_vxlan_lite)) {
    753         if (info == NULL) {
    754             return BCM_E_PARAM;
    755         }
    756         rv = bcmi_gh2_vxlan_lock(unit);
    757         if (rv == BCM_E_NONE) {
    758             rv = bcmi_gh2_vxlan_tunnel_initiator_get(unit, info);
    759             bcmi_gh2_vxlan_unlock(unit);
    760         }
    761     } else
    762 #endif /* BCM_GREYHOUND2_SUPPORT */
    763     {
    764         rv = BCM_E_UNAVAIL;
    765     }
    766 
    767     return rv;
    768 }
    769 
    770 /*
    771  * Function:
    772  *      bcm_esw_vxlan_tunnel_initiator_traverse
    773  * Purpose:
    774  *      VXLAN Tunnel Initiator Traverse
    775  * Parameters:
    776  *      unit     - Device Number
    777  *      cb     - User callback function, called once per entry
    778  *      user_data     - Cookie
    779  * Returns:
    780  *      BCM_E_XXXX
    781  */
    782 
    783 int
    784 bcm_esw_vxlan_tunnel_initiator_traverse(int unit, bcm_tunnel_initiator_traverse_cb cb, void *user_data)
    785 {
    786     int rv;
    787 
    788 #if defined(BCM_TRIDENT2_SUPPORT)
    789     if (soc_feature(unit, soc_feature_vxlan)) {
    790         rv = bcm_td2_vxlan_lock(unit);
    791         if ( rv == BCM_E_NONE ) {
    792             rv = bcm_td2_vxlan_tunnel_initiator_traverse(unit, cb, user_data);
    793             bcm_td2_vxlan_unlock (unit);
    794         }
    795     } else
    796 #endif
    797 #if defined(BCM_GREYHOUND2_SUPPORT)
    798     if (soc_feature(unit, soc_feature_vxlan_lite)) {
    799         rv = bcmi_gh2_vxlan_lock(unit);
    800         if (rv == BCM_E_NONE) {
    801             rv = bcmi_gh2_vxlan_tunnel_initiator_traverse(unit, cb, user_data);
    802             bcmi_gh2_vxlan_unlock(unit);
    803         }
    804     } else
    805 #endif /* BCM_GREYHOUND2_SUPPORT */
    806     {
    807         rv = BCM_E_UNAVAIL;
    808     }
    809 
    810     return rv;
    811 }
    812 
    813  /* Function:
    814  *      bcm_esw_vxlan_tunnel_terminator_create
    815  * Purpose:
    816  *      Create VXLAN Tunnel terminator
    817  * Parameters:
    818  *      unit     - Device Number
    819  *      info     - VXLAN Tunnel terminator info
    820  * Returns:
    821  *      BCM_E_XXXX
    822  */
    823 
    824 int 
    825 bcm_esw_vxlan_tunnel_terminator_create(int unit, bcm_tunnel_terminator_t *info)
    826 {
    827     int rv;
    828 
    829 #if defined(BCM_TRIDENT2_SUPPORT)
    830     if (soc_feature(unit, soc_feature_vxlan)) {
    831          if (info == NULL) {
    832             return BCM_E_PARAM;
    833          }
    834          rv = bcm_td2_vxlan_lock(unit);
    835          if ( rv == BCM_E_NONE ) {
    836               rv = bcm_td2_vxlan_tunnel_terminator_create(unit, info);
    837               bcm_td2_vxlan_unlock (unit);
    838          }
    839     } else
    840 #endif
    841 #if defined(BCM_GREYHOUND2_SUPPORT)
    842     if (soc_feature(unit, soc_feature_vxlan_lite)) {
    843         if (info == NULL) {
    844             return BCM_E_PARAM;
    845         }
    846         rv = bcmi_gh2_vxlan_lock(unit);
    847         if (rv == BCM_E_NONE) {
    848             rv = bcmi_gh2_vxlan_tunnel_terminator_create(unit, info);
    849             bcmi_gh2_vxlan_unlock(unit);
    850         }
    851     } else
    852 #endif /* BCM_GREYHOUND2_SUPPORT */
    853     {
    854         rv = BCM_E_UNAVAIL;
    855     }
    856 
    857     return rv;
    858 }
    859 
    860  /* Function:
    861  *      bcm_esw_vxlan_tunnel_terminator_update
    862  * Purpose:
    863  *      Update VXLAN Tunnel terminator
    864  * Parameters:
    865  *      unit     - Device Number
    866  *      info     - VXLAN Tunnel terminator info
    867  * Returns:
    868  *      BCM_E_XXXX
    869  */
    870 
    871 int 
    872 bcm_esw_vxlan_tunnel_terminator_update(int unit, bcm_tunnel_terminator_t *info)
    873 {
    874     int rv;
    875 
    876 #if defined(BCM_TRIDENT2_SUPPORT)
    877     if (soc_feature(unit, soc_feature_vxlan)) {
    878          if (info == NULL) {
    879             return BCM_E_PARAM;
    880          }
    881          rv = bcm_td2_vxlan_lock(unit);
    882          if ( rv == BCM_E_NONE ) {
    883               rv = bcm_td2_vxlan_tunnel_terminator_update(unit, info);
    884               bcm_td2_vxlan_unlock (unit);
    885          }
    886     } else
    887 #endif
    888 #if defined(BCM_GREYHOUND2_SUPPORT)
    889     if (soc_feature(unit, soc_feature_vxlan_lite)) {
    890         if (info == NULL) {
    891             return BCM_E_PARAM;
    892         }
    893         rv = bcmi_gh2_vxlan_lock(unit);
    894         if (rv == BCM_E_NONE) {
    895             rv = bcmi_gh2_vxlan_tunnel_terminator_update(unit, info);
    896             bcmi_gh2_vxlan_unlock(unit);
    897         }
    898     } else
    899 #endif /* BCM_GREYHOUND2_SUPPORT */
    900     {
    901         rv = BCM_E_UNAVAIL;
    902     }
    903 
    904     return rv;
    905 }
    906 
    907  /* Function:
    908  *      bcm_esw_vxlan_tunnel_terminator_destroy
    909  * Purpose:
    910  *      Destroy VXLAN Tunnel terminator
    911  * Parameters:
    912  *      unit     - Device Number
    913  *      vxlan_tunnel_id     - VXLAN Tunnel Initiator Id
    914  * Returns:
    915  *      BCM_E_XXXX
    916  */
    917 
    918 int 
    919 bcm_esw_vxlan_tunnel_terminator_destroy(int unit, bcm_gport_t vxlan_tunnel_id)
    920 {
    921     int rv;
    922 
    923 #if defined(BCM_TRIDENT2_SUPPORT)
    924     if (soc_feature(unit, soc_feature_vxlan)) {
    925          rv = bcm_td2_vxlan_lock(unit);
    926          if ( rv == BCM_E_NONE ) {
    927               rv = bcm_td2_vxlan_tunnel_terminator_destroy(unit, vxlan_tunnel_id);
    928               bcm_td2_vxlan_unlock (unit);
    929          }
    930     } else
    931 #endif
    932 #if defined(BCM_GREYHOUND2_SUPPORT)
    933     if (soc_feature(unit, soc_feature_vxlan_lite)) {
    934         rv = bcmi_gh2_vxlan_lock(unit);
    935         if (rv == BCM_E_NONE) {
    936             rv = bcmi_gh2_vxlan_tunnel_terminator_destroy(unit, vxlan_tunnel_id);
    937             bcmi_gh2_vxlan_unlock(unit);
    938         }
    939     } else
    940 #endif /* BCM_GREYHOUND2_SUPPORT */
    941     {
    942         rv = BCM_E_UNAVAIL;
    943     }
    944 
    945     return rv;
    946 }
    947 
    948  /* Function:
    949  *      bcm_esw_vxlan_tunnel_terminator_destroy_all
    950  * Purpose:
    951  *      Destroy all VXLAN Tunnel terminators
    952  * Parameters:
    953  *      unit     - Device Number
    954  * Returns:
    955  *      BCM_E_XXXX
    956  */
    957 
    958 int 
    959 bcm_esw_vxlan_tunnel_terminator_destroy_all(int unit)
    960 {
    961     int rv;
    962 
    963 #if defined(BCM_TRIDENT2_SUPPORT)
    964     if (soc_feature(unit, soc_feature_vxlan)) {
    965          rv = bcm_td2_vxlan_lock(unit);
    966          if ( rv == BCM_E_NONE ) {
    967               rv = bcm_td2_vxlan_tunnel_terminator_destroy_all(unit);
    968               bcm_td2_vxlan_unlock (unit);
    969          }
    970     } else
    971 #endif
    972 #if defined(BCM_GREYHOUND2_SUPPORT)
    973     if (soc_feature(unit, soc_feature_vxlan_lite)) {
    974         rv = bcmi_gh2_vxlan_lock(unit);
    975         if (rv == BCM_E_NONE) {
    976             rv = bcmi_gh2_vxlan_tunnel_terminator_destroy_all(unit);
    977             bcmi_gh2_vxlan_unlock(unit);
    978         }
    979     } else
    980 #endif /* BCM_GREYHOUND2_SUPPORT */
    981     {
    982         rv = BCM_E_UNAVAIL;
    983     }
    984 
    985     return rv;
    986 }
    987 
    988  /* Function:
    989  *      bcm_esw_vxlan_tunnel_terminator_get
    990  * Purpose:
    991  *      Get  VXLAN Tunnel terminator Info
    992  * Parameters:
    993  *      unit     - Device Number
    994  *      info     - VXLAN Tunnel terminator info
    995  * Returns:
    996  *      BCM_E_XXXX
    997  */
    998 
    999 int 
   1000 bcm_esw_vxlan_tunnel_terminator_get( int unit, bcm_tunnel_terminator_t *info)
   1001 {
   1002     int rv;
   1003 
   1004 #if defined(BCM_TRIDENT2_SUPPORT)
   1005     if (soc_feature(unit, soc_feature_vxlan)) {
   1006          if (info == NULL) {
   1007             return BCM_E_PARAM;
   1008          }
   1009          rv = bcm_td2_vxlan_lock(unit);
   1010          if ( rv == BCM_E_NONE ) {
   1011               rv = bcm_td2_vxlan_tunnel_terminator_get(unit, info);
   1012               bcm_td2_vxlan_unlock (unit);
   1013          }
   1014     } else
   1015 #endif
   1016 #if defined(BCM_GREYHOUND2_SUPPORT)
   1017     if (soc_feature(unit, soc_feature_vxlan_lite)) {
   1018         if (info == NULL) {
   1019             return BCM_E_PARAM;
   1020         }
   1021         rv = bcmi_gh2_vxlan_lock(unit);
   1022         if (rv == BCM_E_NONE) {
   1023             rv = bcmi_gh2_vxlan_tunnel_terminator_get(unit, info);
   1024             bcmi_gh2_vxlan_unlock(unit);
   1025         }
   1026     } else
   1027 #endif /* BCM_GREYHOUND2_SUPPORT */
   1028     {
   1029         rv = BCM_E_UNAVAIL;
   1030     }
   1031 
   1032     return rv;
   1033 }
   1034 
   1035 /*
   1036  * Function:
   1037  *      bcm_esw_vxlan_tunnel_terminator_traverse
   1038  * Purpose:
   1039  *      VXLAN Tunnel Terminator Traverse
   1040  * Parameters:
   1041  *      unit     - Device Number
   1042  *      cb     - User callback function, called once per entry
   1043  *      user_data     - Cookie
   1044  * Returns:
   1045  *      BCM_E_XXXX
   1046  */
   1047 
   1048 int
   1049 bcm_esw_vxlan_tunnel_terminator_traverse(int unit, bcm_tunnel_terminator_traverse_cb cb, void *user_data)
   1050 {
   1051     int rv;
   1052 
   1053 #if defined(BCM_TRIDENT2_SUPPORT)
   1054     if (soc_feature(unit, soc_feature_vxlan)) {
   1055         rv = bcm_td2_vxlan_lock(unit);
   1056         if ( rv == BCM_E_NONE ) {
   1057             rv = bcm_td2_vxlan_tunnel_terminator_traverse(unit, cb, user_data);
   1058             bcm_td2_vxlan_unlock (unit);
   1059         }
   1060     } else
   1061 #endif
   1062 #if defined(BCM_GREYHOUND2_SUPPORT)
   1063     if (soc_feature(unit, soc_feature_vxlan_lite)) {
   1064         rv = bcmi_gh2_vxlan_lock(unit);
   1065         if (rv == BCM_E_NONE) {
   1066             rv = bcmi_gh2_vxlan_tunnel_terminator_traverse(unit, cb, user_data);
   1067             bcmi_gh2_vxlan_unlock(unit);
   1068         }
   1069     } else
   1070 #endif /* BCM_GREYHOUND2_SUPPORT */
   1071     {
   1072         rv = BCM_E_UNAVAIL;
   1073     }
   1074 
   1075     return rv;
   1076 }
   1077 
   1078 /*
   1079  * Function:
   1080  *      _bcm_esw_vxlan_trunk_member_add
   1081  * Purpose:
   1082  *      Set VXLAN state for trunk members being added to a trunk group.
   1083  * Parameters:
   1084  *     unit  - (IN) Device Number
   1085  *     trunk_id - (IN)  Trunk Group ID
   1086  *     trunk_member_count - (IN) Count of Trunk members to be added
   1087  *     trunk_member_array - (IN) Trunk member ports to be added
   1088  * Returns:
   1089  *      BCM_E_XXX
   1090  */     
   1091 int
   1092 _bcm_esw_vxlan_trunk_member_add(int unit, bcm_trunk_t trunk_id, 
   1093         int trunk_member_count, bcm_port_t *trunk_member_array) 
   1094 {
   1095     int rv = BCM_E_UNAVAIL;
   1096 #ifdef BCM_TRIDENT2_SUPPORT
   1097     if (soc_feature(unit, soc_feature_vxlan)) {
   1098         rv = bcm_td2_vxlan_trunk_member_add(unit, trunk_id,
   1099                  trunk_member_count, trunk_member_array);
   1100     }
   1101 #endif
   1102     return rv;
   1103 }
   1104 
   1105 /*
   1106  * Function:
   1107  *      _bcm_esw_trill_trunk_member_delete
   1108  * Purpose:
   1109  *      Clear VXLAN state for trunk members leaving a trunk group.
   1110  * Parameters:
   1111  *     unit  - (IN) Device Number
   1112  *     trunk_id - (IN)  Trunk Group ID
   1113  *     trunk_member_count - (IN) Count of Trunk members to be deleted
   1114  *     trunk_member_array - (IN) Trunk member ports to be deleted
   1115  * Returns:
   1116  *      BCM_E_XXX
   1117  */     
   1118 int
   1119 _bcm_esw_vxlan_trunk_member_delete(int unit, bcm_trunk_t trunk_id, 
   1120         int trunk_member_count, bcm_port_t *trunk_member_array) 
   1121 {
   1122     int rv;
   1123 
   1124 #ifdef BCM_TRIDENT2_SUPPORT
   1125     if (soc_feature(unit, soc_feature_vxlan)) {
   1126         rv = bcm_td2_vxlan_trunk_member_delete(unit, trunk_id,
   1127                  trunk_member_count, trunk_member_array);
   1128     } else
   1129 #endif
   1130 #if defined(BCM_GREYHOUND2_SUPPORT)
   1131     if (soc_feature(unit, soc_feature_vxlan_lite)) {
   1132         rv = bcmi_gh2_vxlan_trunk_member_delete(unit, trunk_id,
   1133                                                trunk_member_count,
   1134                                                trunk_member_array);
   1135     } else
   1136 #endif /* BCM_GREYHOUND2_SUPPORT */
   1137     {
   1138         rv = BCM_E_UNAVAIL;
   1139     }
   1140 
   1141     return rv;
   1142 }
   1143 
   1144 /*
   1145  * Function:
   1146  *      _bcm_esw_vxlan_port_source_vp_lag_set
   1147  * Purpose:
   1148  *      Set source VP LAG for a VXLAN virtual port.
   1149  * Parameters:
   1150  *      unit  - (IN) SOC unit number. 
   1151  *      gport - (IN) VXLAN virtual port GPORT ID. 
   1152  *      vp_lag_vp - (IN) VP representing the VP LAG. 
   1153  * Returns:
   1154  *      BCM_X_XXX
   1155  */
   1156 int
   1157 _bcm_esw_vxlan_port_source_vp_lag_set(int unit, bcm_gport_t gport,
   1158         int vp_lag_vp)
   1159 {
   1160     int rv = BCM_E_UNAVAIL;
   1161 
   1162 #if defined(BCM_TRIDENT2_SUPPORT)
   1163     if (soc_feature(unit, soc_feature_vxlan)
   1164         && soc_feature(unit, soc_feature_vp_lag)) {
   1165         rv = bcm_td2_vxlan_lock(unit);
   1166         if (rv == BCM_E_NONE) {
   1167             rv = bcm_td2_vxlan_port_source_vp_lag_set(unit, gport, vp_lag_vp);
   1168             bcm_td2_vxlan_unlock(unit);
   1169         }
   1170     }
   1171 #endif /* BCM_TRIDENT2_SUPPORT && INCLUDE_L3 */
   1172 
   1173     return rv;
   1174 }
   1175 
   1176 /*
   1177  * Function:
   1178  *      _bcm_esw_vxlan_port_source_vp_lag_clear
   1179  * Purpose:
   1180  *      Clear source VP LAG for a VXLAN virtual port.
   1181  * Parameters:
   1182  *      unit  - (IN) SOC unit number. 
   1183  *      gport - (IN) VXLAN virtual port GPORT ID. 
   1184  *      vp_lag_vp - (IN) VP representing the VP LAG. 
   1185  * Returns:
   1186  *      BCM_X_XXX
   1187  */
   1188 int
   1189 _bcm_esw_vxlan_port_source_vp_lag_clear(int unit, bcm_gport_t gport,
   1190         int vp_lag_vp)
   1191 {
   1192     int rv = BCM_E_UNAVAIL;
   1193 
   1194 #if defined(BCM_TRIDENT2_SUPPORT)
   1195     if (soc_feature(unit, soc_feature_vxlan)
   1196         && soc_feature(unit, soc_feature_vp_lag)) {
   1197         rv = bcm_td2_vxlan_lock(unit);
   1198         if (rv == BCM_E_NONE) {
   1199             rv = bcm_td2_vxlan_port_source_vp_lag_clear(unit, gport, vp_lag_vp);
   1200             bcm_td2_vxlan_unlock(unit);
   1201         }
   1202     }
   1203 #endif /* BCM_TRIDENT2_SUPPORT && INCLUDE_L3 */
   1204 
   1205     return rv;
   1206 }
   1207 
   1208 /*
   1209  * Function:
   1210  *      _bcm_esw_vxlan_port_source_vp_lag_get
   1211  * Purpose:
   1212  *      Get source VP LAG for a VXLAN virtual port.
   1213  * Parameters:
   1214  *      unit  - (IN) SOC unit number. 
   1215  *      gport - (IN) VXLAN virtual port GPORT ID. 
   1216  *      vp_lag_vp - (OUT) VP representing the VP LAG. 
   1217  * Returns:
   1218  *      BCM_X_XXX
   1219  */
   1220 int
   1221 _bcm_esw_vxlan_port_source_vp_lag_get(int unit, bcm_gport_t gport,
   1222         int *vp_lag_vp)
   1223 {
   1224     int rv = BCM_E_UNAVAIL;
   1225 
   1226 #if defined(BCM_TRIDENT2_SUPPORT)
   1227     if (soc_feature(unit, soc_feature_vxlan)
   1228         && soc_feature(unit, soc_feature_vp_lag)) {
   1229         rv = bcm_td2_vxlan_lock(unit);
   1230         if (rv == BCM_E_NONE) {
   1231             rv = bcm_td2_vxlan_port_source_vp_lag_get(unit, gport, vp_lag_vp);
   1232             bcm_td2_vxlan_unlock(unit);
   1233         }
   1234     }
   1235 #endif /* BCM_TRIDENT2_SUPPORT && INCLUDE_L3 */
   1236 
   1237     return rv;
   1238 }
   1239 
   1240 #if defined(BCM_TRIDENT2_SUPPORT)
   1241 /*
   1242  * Function:
   1243  *      _bcm_esw_vxlan_stat_get_table_info
   1244  * Description:
   1245  *      Provides relevant flex table information(table-name,index with
   1246  *      direction)  for given ingress interface.
   1247  *
   1248  * Parameters:
   1249  *      unit             - (IN) unit number
   1250  *      port             - (IN) Vxlan gport
   1251  *      vpn              - (IN) vpn (VFI)
   1252  *      num_of_tables    - (OUT) Number of flex counter tables
   1253  *      table_info       - (OUT) Flex counter tables information
   1254  *
   1255  * Return Value:
   1256  *      BCM_E_XXX
   1257  * Notes:
   1258  */
   1259 static 
   1260 bcm_error_t _bcm_esw_vxlan_stat_get_table_info(
   1261             int                        unit,
   1262             bcm_gport_t                port,
   1263             bcm_vpn_t                  vpn,
   1264             uint32                     *num_of_tables,
   1265             bcm_stat_flex_table_info_t *table_info)
   1266 {
   1267     int vp = 0;
   1268     int vfi = 0;
   1269     int vp_type = 0;
   1270     int egress_tunnel_flag = 0;
   1271     int nh_idx = -1;
   1272     int entry_type = 0;
   1273     _bcm_vp_info_t vp_info;
   1274     int d = 0; /*vxlan decoupled mode*/
   1275 
   1276     if (!soc_feature(unit,soc_feature_advanced_flex_counter)) {
   1277         return BCM_E_UNAVAIL;
   1278     }
   1279 
   1280     /* Parameter validation checks */
   1281     if (!SOC_UNIT_VALID(unit)) {
   1282         return BCM_E_UNIT;
   1283     }
   1284 
   1285 #if defined(BCM_TRIDENT3_SUPPORT)
   1286     if (soc_feature(unit, soc_feature_vxlan_decoupled_mode)) {
   1287         d = 1;
   1288     }
   1289 #endif
   1290 
   1291     if (!(BCM_GPORT_INVALID == port) && BCM_GPORT_IS_VXLAN_PORT(port)) {
   1292         egr_dvp_attribute_entry_t  egr_dvp_attribute;
   1293         ing_dvp_table_entry_t dvp;
   1294         egr_l3_next_hop_entry_t egr_nh;
   1295 
   1296         /* Ingress Vxlan VP */
   1297         vp = BCM_GPORT_VXLAN_PORT_ID_GET(port);
   1298         if (!_bcm_vp_used_get(unit, vp, _bcmVpTypeVxlan)) {
   1299             return BCM_E_NOT_FOUND;
   1300         }
   1301 
   1302         table_info[*num_of_tables].table=SOURCE_VPm;
   1303         table_info[*num_of_tables].index=vp;
   1304         table_info[*num_of_tables].direction=bcmStatFlexDirectionIngress;
   1305         (*num_of_tables)++;
   1306 
   1307         BCM_IF_ERROR_RETURN (READ_ING_DVP_TABLEm(unit, MEM_BLOCK_ANY, vp,
   1308                                         &dvp));
   1309 
   1310         BCM_IF_ERROR_RETURN(_bcm_vp_info_get(unit, vp, &vp_info));
   1311         if (vp_info.flags & _BCM_VP_INFO_NETWORK_PORT) {
   1312             egress_tunnel_flag = TRUE;
   1313         }
   1314 
   1315         /* Network port*/
   1316         if (egress_tunnel_flag) {
   1317             BCM_IF_ERROR_RETURN(
   1318                 soc_mem_read(unit, EGR_DVP_ATTRIBUTEm, MEM_BLOCK_ANY, 
   1319                              vp, &egr_dvp_attribute));
   1320 #if defined(BCM_TRIDENT3_SUPPORT)
   1321             if (SOC_MEM_FIELD_VALID(unit, EGR_DVP_ATTRIBUTEm, DATA_TYPEf)) {
   1322                 vp_type = soc_mem_field32_get(unit, EGR_DVP_ATTRIBUTEm,
   1323                                             &egr_dvp_attribute, DATA_TYPEf);
   1324             } else
   1325 #endif
   1326             {
   1327                 vp_type = soc_mem_field32_get(unit, EGR_DVP_ATTRIBUTEm,
   1328                                             &egr_dvp_attribute, VP_TYPEf);
   1329             }
   1330 
   1331             if (vp_type == _BCM_VXLAN_EGRESS_DEST_VP_TYPE) { /* vxlan vp type */
   1332                 /* Egress Vxlan (DVP) */
   1333 #if defined(BCM_TRIDENT3_SUPPORT)
   1334                 if (!SOC_MEM_IS_VALID(unit, EGR_DVP_ATTRIBUTE_1m)) {
   1335                     table_info[*num_of_tables].table = EGR_DVP_ATTRIBUTEm;
   1336                 } else 
   1337 #endif
   1338                 {
   1339                     table_info[*num_of_tables].table=EGR_DVP_ATTRIBUTE_1m;
   1340                 }
   1341                 table_info[*num_of_tables].index=vp;
   1342                 table_info[*num_of_tables].direction=bcmStatFlexDirectionEgress;
   1343                 (*num_of_tables)++;
   1344             } 
   1345         } else { /* Access port */
   1346             nh_idx = soc_ING_DVP_TABLEm_field32_get(unit, &dvp, NEXT_HOP_INDEXf);
   1347             BCM_IF_ERROR_RETURN(
   1348                 soc_mem_read(unit, EGR_L3_NEXT_HOPm, MEM_BLOCK_ANY, 
   1349                              nh_idx, &egr_nh));
   1350 #if defined(BCM_TRIDENT3_SUPPORT)
   1351             if (SOC_IS_TRIDENT3X(unit)) {
   1352                 entry_type = soc_mem_field32_get(unit,
   1353                     EGR_L3_NEXT_HOPm, &egr_nh, DATA_TYPEf);
   1354             } else
   1355 #endif
   1356             {
   1357                 entry_type = soc_mem_field32_get(unit,
   1358                     EGR_L3_NEXT_HOPm, &egr_nh, ENTRY_TYPEf);
   1359             }
   1360             if (entry_type == BCM_VXLAN_TAG_VIEW(d)) { /* vxlan sd tag */
   1361                 /* Next hop for access */
   1362                 table_info[*num_of_tables].table=EGR_L3_NEXT_HOPm;
   1363                 table_info[*num_of_tables].index=nh_idx;
   1364                 table_info[*num_of_tables].direction=bcmStatFlexDirectionEgress;
   1365                 (*num_of_tables)++;
   1366             }
   1367  
   1368         }
   1369     }
   1370 
   1371     if ( !(_BCM_VXLAN_VPN_INVALID == vpn) &&
   1372         ((_BCM_VPN_IS_VXLAN_ELINE(vpn) || _BCM_VPN_IS_VXLAN_ELAN(vpn)))) {
   1373         /* Ingress Vxlan VPN */
   1374         _BCM_VXLAN_VPN_GET(vfi, _BCM_VPN_TYPE_VFI, vpn);
   1375         if (!_bcm_vfi_used_get(unit, vfi, _bcmVfiTypeVxlan)) {
   1376             return BCM_E_NOT_FOUND;
   1377         }
   1378 
   1379         table_info[*num_of_tables].table=VFIm;
   1380         table_info[*num_of_tables].index=vfi;
   1381         table_info[*num_of_tables].direction=bcmStatFlexDirectionIngress;
   1382         (*num_of_tables)++;
   1383 
   1384         /* Egress Vxlan VPN */
   1385         if (vp_type != 2) { 
   1386             table_info[*num_of_tables].table=EGR_VFIm;
   1387             table_info[*num_of_tables].index=vfi;
   1388             table_info[*num_of_tables].direction=bcmStatFlexDirectionEgress;
   1389             (*num_of_tables)++;
   1390         }
   1391     }
   1392 
   1393     if (*num_of_tables == 0) {
   1394         return BCM_E_PARAM;
   1395     }
   1396 
   1397     return BCM_E_NONE;
   1398 }
   1399 #endif /* BCM_TRIDENT2_SUPPORT */
   1400 
   1401 /*
   1402  * Function:
   1403  *      bcm_esw_vxlan_stat_attach
   1404  * Description:
   1405  *      Attach counters entries to the given  vxlan port and vpn. 
   1406  *      Allocate flex counter and assign counter index and offset for the index 
   1407  *      pointed by vxlan vpn(VFI) and port(tunnel)
   1408  *
   1409  * Parameters:
   1410  *      unit             - (IN) unit number
   1411  *      port             - (IN) Vxlan gport
   1412  *      vpn              - (IN) vpn (VFI)
   1413  *      stat_counter_id  - (IN) Stat Counter ID.
   1414  *
   1415  * Return Value:
   1416  *      BCM_E_XXX
   1417  * Notes:
   1418  */
   1419     
   1420 int  bcm_esw_vxlan_stat_attach (
   1421                             int                 unit,
   1422                             bcm_gport_t         port,
   1423                             bcm_vpn_t           vpn,
   1424                             uint32              stat_counter_id)
   1425 {
   1426 #if defined(BCM_TRIDENT2_SUPPORT)
   1427     int                        rv = BCM_E_NONE;
   1428     int                        counter_flag = 0;
   1429     soc_mem_t                  table[3]={0};
   1430     bcm_stat_flex_direction_t  direction = bcmStatFlexDirectionIngress;
   1431     uint32                     pool_number = 0;
   1432     uint32                     base_index = 0;
   1433     bcm_stat_flex_mode_t       offset_mode = 0;
   1434     bcm_stat_object_t          object = bcmStatObjectIngPort;
   1435     bcm_stat_group_mode_t      group_mode = bcmStatGroupModeSingle;
   1436     uint32                     count = 0;
   1437     uint32                     actual_num_tables = 0;
   1438     uint32                     num_of_tables = 0;
   1439     bcm_stat_flex_table_info_t table_info[BCM_STAT_VXLAN_FLEX_COUNTER_MAX_TABLES] = {{0, 0, 0}};
   1440     uint32                     flex_table_index=0;
   1441 
   1442     if (!soc_feature(unit,soc_feature_advanced_flex_counter)) {
   1443         return BCM_E_UNAVAIL;
   1444     }
   1445 
   1446     /* Parameter validation checks */
   1447     if (!SOC_UNIT_VALID(unit)) {
   1448         return BCM_E_UNIT;
   1449     }
   1450 
   1451     if ((BCM_GPORT_INVALID != port) && !(BCM_GPORT_IS_VXLAN_PORT(port))) {
   1452         return BCM_E_PORT;
   1453     }
   1454 
   1455     if ((BCM_GPORT_INVALID != port) && (BCM_VXLAN_VPN_INVALID != vpn)) {
   1456         return BCM_E_PARAM;
   1457     }
   1458 
   1459     /* Get pool, base index group mode and offset modes from stat counter id */
   1460     _bcm_esw_stat_get_counter_id_info(
   1461                   unit, stat_counter_id,
   1462                   &group_mode, &object, &offset_mode, &pool_number, &base_index);
   1463 
   1464     /* Validate object and group mode */
   1465     BCM_IF_ERROR_RETURN(_bcm_esw_stat_validate_object(unit, object, &direction));
   1466     BCM_IF_ERROR_RETURN(_bcm_esw_stat_validate_group(unit, group_mode));
   1467 
   1468     /* Get Table index to attach flexible counter */
   1469     BCM_IF_ERROR_RETURN(_bcm_esw_stat_flex_get_table_info(
   1470                         unit, object, 3, &actual_num_tables, &table[0], &direction));
   1471     BCM_IF_ERROR_RETURN(_bcm_esw_vxlan_stat_get_table_info(
   1472                         unit, port, vpn, &num_of_tables, &table_info[0]));
   1473 
   1474     for (count = 0; count < num_of_tables; count++) {
   1475         for (flex_table_index=0; 
   1476              flex_table_index < actual_num_tables ; 
   1477              flex_table_index++) {
   1478             if ((table_info[count].direction == direction) &&
   1479                 (table_info[count].table == table[flex_table_index])) {
   1480                 if (direction == bcmStatFlexDirectionIngress) {
   1481                     counter_flag = 1;
   1482                     rv = _bcm_esw_stat_flex_attach_ingress_table_counters(
   1483                            unit,
   1484                            table_info[count].table,
   1485                            table_info[count].index,
   1486                            offset_mode,
   1487                            base_index,
   1488                            pool_number);
   1489                     if(BCM_FAILURE(rv)) {
   1490                         break;
   1491                     }
   1492                 } else {
   1493                     counter_flag = 1;
   1494                     rv = _bcm_esw_stat_flex_attach_egress_table_counters(
   1495                          unit,
   1496                          table_info[count].table,
   1497                          table_info[count].index,
   1498                          0,
   1499                          offset_mode,
   1500                          base_index,
   1501                          pool_number);
   1502                     if(BCM_FAILURE(rv)) {
   1503                         break;
   1504                     }
   1505                 } 
   1506              }
   1507         }
   1508     }
   1509 
   1510     if (counter_flag == 0) {
   1511         rv = BCM_E_NOT_FOUND;
   1512     }
   1513     return rv;
   1514 #else 
   1515     return BCM_E_UNAVAIL;
   1516 #endif /* BCM_TRIDENT2_SUPPORT */
   1517 }
   1518 
   1519 
   1520 /*
   1521  * Function:
   1522  *      bcm_esw_vxlan_stat_detach
   1523  * Description:
   1524  *      Detach counter entries to the given  vxlan port and vpn. 
   1525  *
   1526  * Parameters:
   1527  *      unit             - (IN) unit number
   1528  *      port             - (IN) Vxlan gport
   1529  *      vpn              - (IN) vpn (VFI)
   1530  *
   1531  * Return Value:
   1532  *      BCM_E_XXX
   1533  * Notes:
   1534  */
   1535 int   bcm_esw_vxlan_stat_detach (
   1536                             int                 unit,
   1537                             bcm_gport_t         port,
   1538                             bcm_vpn_t           vpn)
   1539 {
   1540 
   1541 #if defined(BCM_TRIDENT2_SUPPORT)
   1542     uint32                     count = 0;
   1543     uint32                     num_of_tables = 0;
   1544     bcm_stat_flex_table_info_t table_info[BCM_STAT_VXLAN_FLEX_COUNTER_MAX_TABLES];
   1545     bcm_error_t                rv = BCM_E_NONE;
   1546     bcm_error_t      err_code[BCM_STAT_FLEX_COUNTER_MAX_DIRECTION] = {BCM_E_NONE};
   1547 
   1548     if (!soc_feature(unit,soc_feature_advanced_flex_counter)) {
   1549         return BCM_E_UNAVAIL;
   1550     }
   1551 
   1552     /* Parameter validation checks */
   1553     if (!SOC_UNIT_VALID(unit)) {
   1554         return BCM_E_UNIT;
   1555     }
   1556 
   1557     if ((BCM_GPORT_INVALID != port) && !(BCM_GPORT_IS_VXLAN_PORT(port))) {
   1558         return BCM_E_PORT;
   1559     }
   1560 
   1561     /* Get the table index to be detached */
   1562     BCM_IF_ERROR_RETURN(_bcm_esw_vxlan_stat_get_table_info(
   1563                    unit, port, vpn, &num_of_tables, &table_info[0]));
   1564 
   1565     for (count = 0; count < num_of_tables; count++) {
   1566         if (table_info[count].direction == bcmStatFlexDirectionIngress) {
   1567             rv = _bcm_esw_stat_flex_detach_ingress_table_counters(
   1568                     unit, table_info[count].table, table_info[count].index);
   1569             /* remember the first error code, but allow loop finish */
   1570             if (BCM_E_NONE != rv &&
   1571                 BCM_E_NONE == err_code[bcmStatFlexDirectionIngress]) {
   1572                 err_code[bcmStatFlexDirectionIngress] = rv;
   1573             }
   1574         } else  {
   1575             rv = _bcm_esw_stat_flex_detach_egress_table_counters(
   1576                     unit, 0, table_info[count].table, table_info[count].index);
   1577             /* remember the first error code, but allow loop finish */
   1578             if (BCM_E_NONE != rv &&
   1579                 BCM_E_NONE == err_code[bcmStatFlexDirectionEgress]) {
   1580                 err_code[bcmStatFlexDirectionEgress] = rv;
   1581             }
   1582         }
   1583     }
   1584 
   1585     /* In case of success on one direction, and return NOT_FOUND on the other,
   1586        we still take it as a success */
   1587     BCM_STAT_FLEX_DETACH_RETURN(err_code)
   1588 
   1589 #else 
   1590     return BCM_E_UNAVAIL;
   1591 #endif /* BCM_TRIDENT2_SUPPORT */
   1592 }
   1593 
   1594 /*
   1595  * Function:
   1596  *      _bcm_esw_vxlan_stat_counter_get
   1597  *
   1598  * Description:
   1599  *  Get Vxlan counter value for specified vxlan port and vpn
   1600  *  if sync_mode is set, sync the sw accumulated count
   1601  *  with hw count value first, else return sw count.  
   1602  *
   1603  * Parameters:
   1604  *      unit             - (IN) unit number
   1605  *      sync_mode        - (IN) hwcount is to be synced to sw count 
   1606  *      port             - (IN) Vxlan gport
   1607  *      vpn              - (IN) vpn (VFI)
   1608  *      stat             - (IN) Vxlan counter stat types
   1609  *      num_entries      - (IN) Number of counter Entries
   1610  *      counter_indexes  - (IN) Pointer to Counter indexes entries
   1611  *      counter_values   - (OUT) Pointer to counter values
   1612  *
   1613  * Return Value:
   1614  *      BCM_E_XXX
   1615  * Notes:
   1616  */
   1617  int   
   1618  _bcm_esw_vxlan_stat_counter_get(int                 unit, 
   1619                                  int                 sync_mode, 
   1620                                  bcm_gport_t         port,
   1621                                  bcm_vpn_t           vpn,
   1622                                  bcm_vxlan_stat_t    stat, 
   1623                                  uint32              num_entries, 
   1624                                  uint32              *counter_indexes, 
   1625                                  bcm_stat_value_t    *counter_values)
   1626 {   
   1627 
   1628 #if defined(BCM_TRIDENT2_SUPPORT)
   1629     uint32                     table_count = 0;
   1630     uint32                     index_count = 0;
   1631     uint32                     num_of_tables = 0;
   1632     bcm_stat_flex_direction_t  direction = bcmStatFlexDirectionIngress;
   1633     uint32                     byte_flag = 0;
   1634     bcm_stat_flex_table_info_t table_info[BCM_STAT_VXLAN_FLEX_COUNTER_MAX_TABLES];
   1635     uint8 isEline=0xFF;
   1636 
   1637     if (!soc_feature(unit,soc_feature_advanced_flex_counter)) {
   1638         return BCM_E_UNAVAIL;
   1639     }
   1640 
   1641     /* Parameter validation checks */
   1642     if (!SOC_UNIT_VALID(unit)) {
   1643         return BCM_E_UNIT;
   1644     }
   1645 
   1646     if ((BCM_GPORT_INVALID != port) && !(BCM_GPORT_IS_VXLAN_PORT(port))) {
   1647         return BCM_E_PORT;
   1648     }
   1649 
   1650     if (vpn != BCM_VXLAN_VPN_INVALID) {
   1651          BCM_IF_ERROR_RETURN 
   1652               (_bcm_td2_vxlan_vpn_is_eline(unit, vpn, &isEline));
   1653     }
   1654 
   1655     if ((num_entries > 0) &&
   1656         ((NULL == counter_indexes) || (NULL == counter_values))) {
   1657         return BCM_E_PARAM;
   1658     }
   1659 
   1660     /* Get the flex counter direction - ingress/egress */
   1661     if ((stat == bcmVxlanOutPackets) ||
   1662         (stat == bcmVxlanOutBytes)) {
   1663          direction = bcmStatFlexDirectionEgress;
   1664     } else {
   1665          direction = bcmStatFlexDirectionIngress;
   1666     }
   1667     if ((stat == bcmVxlanOutPackets) ||
   1668         (stat == bcmVxlanInPackets)) {
   1669         byte_flag=0;
   1670     } else {
   1671         byte_flag=1;
   1672     }
   1673    
   1674     /*  Get Table index to read the flex counter */
   1675     BCM_IF_ERROR_RETURN(_bcm_esw_vxlan_stat_get_table_info(
   1676                         unit, port, vpn, &num_of_tables, &table_info[0]));
   1677 
   1678     /* Get the flex counter for the attached table index */
   1679     for (table_count = 0; table_count < num_of_tables ; table_count++) {
   1680          if (table_info[table_count].direction == direction) {
   1681              for (index_count = 0; index_count < num_entries ; index_count++) {
   1682                   BCM_IF_ERROR_RETURN(_bcm_esw_stat_counter_get(
   1683                                       unit, sync_mode,
   1684                                       table_info[table_count].index,
   1685                                       table_info[table_count].table,
   1686                                       0,
   1687                                       byte_flag,
   1688                                       counter_indexes[index_count],
   1689                                       &counter_values[index_count]));
   1690              }
   1691          }
   1692     }
   1693 
   1694     return BCM_E_NONE;
   1695 #else 
   1696     return BCM_E_UNAVAIL;
   1697 #endif /* BCM_TRIDENT2_SUPPORT */
   1698 
   1699 }
   1700 
   1701 /*
   1702  * Function:
   1703  *      bcm_esw_vxlan_stat_counter_get
   1704  *
   1705  * Description:
   1706  *  Get Vxlan counter value for specified vxlan port and vpn
   1707  *
   1708  * Parameters:
   1709  *      unit             - (IN) unit number
   1710  *      port             - (IN) Vxlan gport
   1711  *      vpn              - (IN) vpn (VFI)
   1712  *      stat             - (IN) Vxlan counter stat types
   1713  *      num_entries      - (IN) Number of counter Entries
   1714  *      counter_indexes  - (IN) Pointer to Counter indexes entries
   1715  *      counter_values   - (OUT) Pointer to counter values
   1716  *
   1717  * Return Value:
   1718  *      BCM_E_XXX
   1719  * Notes:
   1720  */
   1721  int   
   1722  bcm_esw_vxlan_stat_counter_get(int                 unit, 
   1723                                 bcm_gport_t         port,
   1724                                 bcm_vpn_t           vpn,
   1725                                 bcm_vxlan_stat_t    stat, 
   1726                                 uint32              num_entries, 
   1727                                 uint32              *counter_indexes, 
   1728                                 bcm_stat_value_t    *counter_values)
   1729 {   
   1730 
   1731  return _bcm_esw_vxlan_stat_counter_get(unit, 0, port, vpn, stat, num_entries, 
   1732                                         counter_indexes, counter_values);
   1733 
   1734 }
   1735 
   1736 /*
   1737  * Function:
   1738  *      bcm_esw_vxlan_stat_counter_sync_get
   1739  *
   1740  * Description:
   1741  *  Get Vxlan counter value for specified vxlan port and vpn
   1742  *  sw accumulated counters synced with hw count.
   1743  *
   1744  * Parameters:
   1745  *      unit             - (IN) unit number
   1746  *      port             - (IN) Vxlan gport
   1747  *      vpn              - (IN) vpn (VFI)
   1748  *      stat             - (IN) Vxlan counter stat types
   1749  *      num_entries      - (IN) Number of counter Entries
   1750  *      counter_indexes  - (IN) Pointer to Counter indexes entries
   1751  *      counter_values   - (OUT) Pointer to counter values
   1752  *
   1753  * Return Value:
   1754  *      BCM_E_XXX
   1755  * Notes:
   1756  */
   1757  int   
   1758  bcm_esw_vxlan_stat_counter_sync_get(int                 unit, 
   1759                                      bcm_gport_t         port,
   1760                                      bcm_vpn_t           vpn,
   1761                                      bcm_vxlan_stat_t    stat, 
   1762                                      uint32              num_entries, 
   1763                                      uint32              *counter_indexes, 
   1764                                      bcm_stat_value_t    *counter_values)
   1765 {   
   1766 
   1767  return _bcm_esw_vxlan_stat_counter_get(unit, 1, port, vpn, stat, num_entries, 
   1768                                         counter_indexes, counter_values);
   1769 
   1770 }
   1771 
   1772 /*
   1773  * Function:
   1774  *      bcm_esw_vxlan_stat_counter_set
   1775  *
   1776  * Description:
   1777  *  Set Vxlan counter value for specified vxlan port and vpn
   1778  *
   1779  * Parameters:
   1780  *      unit             - (IN) unit number
   1781  *      port             - (IN) Vxlan gport
   1782  *      vpn              - (IN) vpn (VFI)
   1783  *      stat             - (IN) Vxlan counter stat types
   1784  *      num_entries      - (IN) Number of counter Entries
   1785  *      counter_indexes  - (IN) Pointer to Counter indexes entries
   1786  *      counter_values   - (OUT) Pointer to counter values
   1787  *
   1788  * Return Value:
   1789  *      BCM_E_XXX
   1790  * Notes:
   1791  */
   1792 int   bcm_esw_vxlan_stat_counter_set(
   1793                             int                 unit, 
   1794                             bcm_gport_t         port,
   1795                             bcm_vpn_t           vpn,
   1796                             bcm_vxlan_stat_t    stat, 
   1797                             uint32              num_entries, 
   1798                             uint32              *counter_indexes, 
   1799                             bcm_stat_value_t    *counter_values)
   1800 {
   1801 #if defined(BCM_TRIDENT2_SUPPORT)
   1802     uint32                     table_count=0;
   1803     uint32                     index_count=0;
   1804     uint32                     num_of_tables=0;
   1805     bcm_stat_flex_direction_t  direction=bcmStatFlexDirectionIngress;
   1806     uint32                     byte_flag=0;
   1807     bcm_stat_flex_table_info_t table_info[BCM_STAT_VXLAN_FLEX_COUNTER_MAX_TABLES];
   1808     uint8 isEline=0xFF;
   1809 
   1810     if (!soc_feature(unit,soc_feature_advanced_flex_counter)) {
   1811         return BCM_E_UNAVAIL;
   1812     }
   1813 
   1814     /* Parameter validation checks */
   1815     if (!SOC_UNIT_VALID(unit)) {
   1816         return BCM_E_UNIT;
   1817     }
   1818 
   1819     if ((BCM_GPORT_INVALID != port) && !(BCM_GPORT_IS_VXLAN_PORT(port))) {
   1820         return BCM_E_PORT;
   1821     }
   1822 
   1823     if (vpn != BCM_VXLAN_VPN_INVALID) {
   1824          BCM_IF_ERROR_RETURN 
   1825               (_bcm_td2_vxlan_vpn_is_eline(unit, vpn, &isEline));
   1826     }
   1827 
   1828     if ((num_entries > 0) &&
   1829         ((NULL == counter_indexes) || (NULL == counter_values))) {
   1830         return BCM_E_PARAM;
   1831     }
   1832 
   1833     /* Get the flex counter direction - ingress/egress */
   1834     if ((stat == bcmVxlanOutPackets) ||
   1835         (stat == bcmVxlanOutBytes)) {
   1836          direction = bcmStatFlexDirectionEgress;
   1837     } else {
   1838          direction = bcmStatFlexDirectionIngress;
   1839     }
   1840     if (stat == bcmVxlanOutPackets || stat == bcmVxlanInPackets) {
   1841         byte_flag=0;
   1842     } else {
   1843         byte_flag=1;
   1844     }
   1845    
   1846     /*  Get Table index to read the flex counter */
   1847     BCM_IF_ERROR_RETURN(_bcm_esw_vxlan_stat_get_table_info(
   1848                         unit, port, vpn, &num_of_tables, &table_info[0]));
   1849 
   1850     /* Get the flex counter for the attached table index */
   1851     for (table_count = 0; table_count < num_of_tables ; table_count++) {
   1852          if (table_info[table_count].direction == direction) {
   1853              for (index_count = 0; index_count < num_entries; index_count++) {
   1854                   BCM_IF_ERROR_RETURN(_bcm_esw_stat_counter_set(
   1855                                       unit,
   1856                                       table_info[table_count].index,
   1857                                       table_info[table_count].table,
   1858                                       0,
   1859                                       byte_flag,
   1860                                       counter_indexes[index_count],
   1861                                       &counter_values[index_count]));
   1862              }
   1863          }
   1864     }
   1865     return BCM_E_NONE;
   1866 #else 
   1867     return BCM_E_UNAVAIL;
   1868 #endif /* BCM_TRIDENT2_SUPPORT */
   1869 }
   1870 
   1871 
   1872 /*
   1873  * Function:
   1874  *      bcm_vxlan_stat_enable_set
   1875  * Description:
   1876  *     Enable/disable collection of statistics on the indicated port and vpn. 
   1877  * Parameters:
   1878  *      unit            - (IN) unit number
   1879  *      port            - (IN) Vxlan gport
   1880  *      vpn             - (IN) vpn (VFI)
   1881  *      enable - (IN) Non-zero to enable counter collection, zero to disable.
   1882  *
   1883  * Return Value:
   1884  *      BCM_E_XXX
   1885  * Notes:
   1886  *     if vpn = BCM_VXLAN_VPN_INVALID,collection of statistics on the indicated port.
   1887  */
   1888 int   bcm_esw_vxlan_stat_enable_set(
   1889                             int              unit, 
   1890                             bcm_gport_t      port, 
   1891                             bcm_vpn_t        vpn, 
   1892                             int              enable)
   1893 {
   1894 #if defined(BCM_TRIDENT2_SUPPORT)
   1895    uint32                     num_of_tables=0;
   1896    uint32                     num_stat_counter_ids=0;
   1897    bcm_stat_flex_table_info_t table_info[BCM_STAT_FLEX_COUNTER_MAX_DIRECTION];
   1898    bcm_stat_object_t          object=bcmStatObjectIngPort;
   1899    uint32                     stat_counter_id[BCM_STAT_FLEX_COUNTER_MAX_DIRECTION]={0};
   1900    uint32                     num_entries=0;
   1901    int                        index=0;
   1902 
   1903    if (!soc_feature(unit,soc_feature_advanced_flex_counter)) {
   1904        return BCM_E_UNAVAIL;
   1905    }
   1906    
   1907    /* Parameter validation checks */
   1908    if (!SOC_UNIT_VALID(unit)) {
   1909        return BCM_E_UNIT;
   1910    }
   1911    
   1912    if ((BCM_GPORT_INVALID != port) && !(BCM_GPORT_IS_VXLAN_PORT(port))) {
   1913        return BCM_E_PORT;
   1914    }
   1915 
   1916    if ((BCM_GPORT_INVALID != port) && (BCM_VXLAN_VPN_INVALID != vpn)) {
   1917        return BCM_E_PARAM;
   1918    }
   1919 
   1920    BCM_IF_ERROR_RETURN(_bcm_esw_vxlan_stat_get_table_info(
   1921                        unit,port,vpn,&num_of_tables,&table_info[0]));
   1922 
   1923    if (enable ) {
   1924        for(index=0;index < num_of_tables ;index++) {
   1925            if(table_info[index].direction == bcmStatFlexDirectionIngress) {
   1926                BCM_IF_ERROR_RETURN(_bcm_esw_stat_flex_get_ingress_object(
   1927                                  unit,table_info[index].table,
   1928                                  table_info[index].index,NULL,&object));
   1929            } else {
   1930                BCM_IF_ERROR_RETURN(_bcm_esw_stat_flex_get_egress_object(
   1931                                      unit,table_info[index].table,
   1932                                      table_info[index].index,NULL,&object));               
   1933            } 
   1934 
   1935            BCM_IF_ERROR_RETURN(bcm_esw_stat_group_create(
   1936                               unit,object,bcmStatGroupModeSingle,
   1937                               &stat_counter_id[table_info[index].direction],
   1938                               &num_entries));         
   1939            BCM_IF_ERROR_RETURN(bcm_esw_vxlan_stat_attach(
   1940                               unit,port,vpn,
   1941                               stat_counter_id[table_info[index].direction]));          
   1942        }
   1943     return BCM_E_NONE;
   1944    } else {
   1945        BCM_IF_ERROR_RETURN(_bcm_esw_stat_flex_get_counter_id(
   1946                           unit, num_of_tables,&table_info[0],
   1947                           &num_stat_counter_ids,&stat_counter_id[0]));
   1948      
   1949        if ((stat_counter_id[bcmStatFlexDirectionIngress] == 0) &&
   1950            (stat_counter_id[bcmStatFlexDirectionEgress] == 0)) {
   1951            return BCM_E_PARAM;
   1952        }     
   1953        BCM_IF_ERROR_RETURN(bcm_esw_vxlan_stat_detach(unit,port,vpn));        
   1954        if (stat_counter_id[bcmStatFlexDirectionIngress] != 0) {
   1955            BCM_IF_ERROR_RETURN(bcm_esw_stat_group_destroy(
   1956                                unit,
   1957                                stat_counter_id[bcmStatFlexDirectionIngress]));         
   1958        }
   1959        if (stat_counter_id[bcmStatFlexDirectionEgress] != 0) {
   1960            BCM_IF_ERROR_RETURN(bcm_esw_stat_group_destroy(
   1961                                unit,
   1962                                stat_counter_id[bcmStatFlexDirectionEgress]));          
   1963        }
   1964     return BCM_E_NONE;
   1965    }
   1966 #else
   1967     return BCM_E_UNAVAIL;   
   1968 #endif
   1969 }
   1970 
   1971 /*
   1972  * Function:
   1973  *      bcm_esw_vxlan_stat_multi_get
   1974  *
   1975  * Description:
   1976  *  Get Multiple Vxlan counter value for specified vxlan port and vpn for multiple stat
   1977  *  types
   1978  *
   1979  * Parameters:
   1980  *      unit             - (IN) unit number
   1981  *      port             - (IN) Vxlan gport
   1982  *      vpn              - (IN) vpn (VFI)
   1983  *      nstat            - (IN) Number of elements in stat array
   1984  *      stat_arr         - (IN) Collected statistics descriptors array
   1985  *      value_arr        - (OUT) Collected counters values
   1986  *
   1987  * Return Value:
   1988  *      BCM_E_XXX
   1989  * Notes:
   1990  */
   1991 int   bcm_esw_vxlan_stat_multi_get(
   1992                             int                 unit, 
   1993                             bcm_gport_t         port,
   1994                             bcm_vpn_t           vpn,
   1995                             int                 nstat, 
   1996                             bcm_vxlan_stat_t    *stat_arr,
   1997                             uint64              *value_arr)
   1998 {
   1999 #if defined(BCM_TRIDENT2_SUPPORT)
   2000     int              rv = BCM_E_NONE;
   2001     int              idx;
   2002     uint32           counter_indexes = 0;
   2003     bcm_stat_value_t counter_values = {0};
   2004     uint8 isEline=0xFF;
   2005 
   2006     if (!soc_feature(unit,soc_feature_advanced_flex_counter)) {
   2007         return BCM_E_UNAVAIL;
   2008     }
   2009 
   2010     if ((BCM_GPORT_INVALID != port) && !(BCM_GPORT_IS_VXLAN_PORT(port))) {
   2011         return BCM_E_PORT;
   2012     }
   2013 
   2014     /* Parameter validation checks */
   2015     if (!SOC_UNIT_VALID(unit)) {
   2016         return BCM_E_UNIT;
   2017     }
   2018 
   2019     if (vpn != BCM_VXLAN_VPN_INVALID) {
   2020          BCM_IF_ERROR_RETURN 
   2021               (_bcm_td2_vxlan_vpn_is_eline(unit, vpn, &isEline));
   2022     }
   2023 
   2024     if ((nstat > 0) && ((NULL == stat_arr) || (NULL == value_arr))) {
   2025         return BCM_E_PARAM;
   2026     }
   2027 
   2028     /* Iterate of all stats array to retrieve flex counter values */
   2029     for (idx = 0; idx < nstat ;idx++) {
   2030          BCM_IF_ERROR_RETURN(bcm_esw_vxlan_stat_counter_get( 
   2031                              unit, port, vpn, stat_arr[idx], 
   2032                              1, &counter_indexes, &counter_values));
   2033          if ((stat_arr[idx] == bcmVxlanOutPackets) || 
   2034             (stat_arr[idx] == bcmVxlanInPackets)) {
   2035              COMPILER_64_SET(value_arr[idx],
   2036                              COMPILER_64_HI(counter_values.packets64),
   2037                              COMPILER_64_LO(counter_values.packets64));
   2038          } else {
   2039              COMPILER_64_SET(value_arr[idx],
   2040                              COMPILER_64_HI(counter_values.bytes),
   2041                              COMPILER_64_LO(counter_values.bytes));
   2042          }
   2043     }
   2044     return rv;
   2045 #else 
   2046     return BCM_E_UNAVAIL;
   2047 #endif /* BCM_TRIDENT2_SUPPORT */
   2048 
   2049 }
   2050 
   2051 /*
   2052  * Function:
   2053  *      bcm_esw_vxlan_stat_multi_get32
   2054  *
   2055  * Description:
   2056  *  Get 32bit Vxlan counter value for specified vxlan port and vpn for multiple stat
   2057  *  types
   2058  *
   2059  * Parameters:
   2060  *      unit             - (IN) unit number
   2061  *      port             - (IN) Vxlan gport
   2062  *      vpn              - (IN) vpn (VFI)
   2063  *      nstat            - (IN) Number of elements in stat array
   2064  *      stat_arr         - (IN) Collected statistics descriptors array
   2065  *      value_arr        - (OUT) Collected counters values
   2066  *
   2067  * Return Value:
   2068  *      BCM_E_XXX
   2069  * Notes:
   2070  */
   2071 int   bcm_esw_vxlan_stat_multi_get32(
   2072                             int                 unit, 
   2073                             bcm_gport_t         port,
   2074                             bcm_vpn_t           vpn,
   2075                             int                 nstat, 
   2076                             bcm_vxlan_stat_t    *stat_arr,
   2077                             uint32              *value_arr)
   2078 {
   2079 #if defined(BCM_TRIDENT2_SUPPORT)
   2080     int              rv = BCM_E_NONE;
   2081     int              idx;
   2082     uint32           counter_indexes = 0;
   2083     bcm_stat_value_t counter_values = {0};
   2084     uint8 isEline=0xFF;
   2085 
   2086     if (!soc_feature(unit,soc_feature_advanced_flex_counter)) {
   2087         return BCM_E_UNAVAIL;
   2088     }
   2089 
   2090     /* Parameter validation checks */
   2091     if (!SOC_UNIT_VALID(unit)) {
   2092         return BCM_E_UNIT;
   2093     }
   2094 
   2095     if ((BCM_GPORT_INVALID != port) && !(BCM_GPORT_IS_VXLAN_PORT(port))) {
   2096         return BCM_E_PORT;
   2097     }
   2098 
   2099     if (vpn != BCM_VXLAN_VPN_INVALID) {
   2100          BCM_IF_ERROR_RETURN 
   2101               (_bcm_td2_vxlan_vpn_is_eline(unit, vpn, &isEline));
   2102     }
   2103 
   2104     if ((nstat > 0) &&
   2105         ((NULL == stat_arr) || (NULL == value_arr))) {
   2106         return BCM_E_PARAM;
   2107     }
   2108 
   2109     /* Iterate of all stats array to retrieve flex counter values */
   2110     for (idx = 0; idx < nstat ;idx++) {
   2111          BCM_IF_ERROR_RETURN(bcm_esw_vxlan_stat_counter_get( 
   2112                              unit, port, vpn, stat_arr[idx], 
   2113                              1, &counter_indexes, &counter_values));
   2114          if ((stat_arr[idx] == bcmVxlanOutPackets) || 
   2115             (stat_arr[idx] == bcmVxlanInPackets)) {
   2116                 value_arr[idx] = counter_values.packets;
   2117          } else {
   2118              value_arr[idx] = COMPILER_64_LO(counter_values.bytes);
   2119          }
   2120     }
   2121     return rv;
   2122 #else 
   2123     return BCM_E_UNAVAIL;
   2124 #endif /* BCM_TRIDENT2_SUPPORT */
   2125 }
   2126 
   2127 /*
   2128  * Function:
   2129  *      bcm_esw_vxlan_stat_multi_set
   2130  *
   2131  * Description:
   2132  *  Set Vxlan counter value for specified vxlan port and vpn for multiple stat
   2133  *  types
   2134  *
   2135  * Parameters:
   2136  *      unit             - (IN) unit number
   2137  *      port             - (IN) Vxlan gport
   2138  *      vpn              - (IN) vpn (VFI)
   2139  *      stat             - (IN) Vxlan counter stat types
   2140  *      num_entries      - (IN) Number of counter Entries
   2141  *      counter_indexes  - (IN) Pointer to Counter indexes entries
   2142  *      counter_values   - (OUT) Pointer to counter values
   2143  *
   2144  * Return Value:
   2145  *      BCM_E_XXX
   2146  * Notes:
   2147  */
   2148 int  bcm_esw_vxlan_stat_multi_set(
   2149                             int                 unit, 
   2150                             bcm_gport_t         port,
   2151                             bcm_vpn_t           vpn,
   2152                             int                 nstat, 
   2153                             bcm_vxlan_stat_t    *stat_arr,
   2154                             uint64              *value_arr)
   2155 {
   2156 #if defined(BCM_TRIDENT2_SUPPORT)
   2157     int              rv = BCM_E_NONE;
   2158     int              idx;
   2159     uint32           counter_indexes = 0;
   2160     bcm_stat_value_t counter_values = {0};
   2161     uint8 isEline=0xFF;
   2162 
   2163     if (!soc_feature(unit,soc_feature_advanced_flex_counter)) {
   2164         return BCM_E_UNAVAIL;
   2165     }
   2166 
   2167     /* Parameter validation checks */
   2168     if (!SOC_UNIT_VALID(unit)) {
   2169         return BCM_E_UNIT;
   2170     }
   2171 
   2172     if ((BCM_GPORT_INVALID != port) && !(BCM_GPORT_IS_VXLAN_PORT(port))) {
   2173         return BCM_E_PORT;
   2174     }
   2175 
   2176     if (vpn != BCM_VXLAN_VPN_INVALID) {
   2177          BCM_IF_ERROR_RETURN 
   2178               (_bcm_td2_vxlan_vpn_is_eline(unit, vpn, &isEline));
   2179     }
   2180 
   2181     if ((nstat > 0) && ((NULL == stat_arr) || (NULL == value_arr))) {
   2182         return BCM_E_PARAM;
   2183     }
   2184 
   2185     /* Iterate f all stats array to retrieve flex counter values */
   2186     for (idx = 0; idx < nstat ;idx++) {
   2187          if ((stat_arr[idx] == bcmVxlanOutPackets) || 
   2188             (stat_arr[idx] == bcmVxlanInPackets)) {
   2189               counter_values.packets = COMPILER_64_LO(value_arr[idx]);
   2190          } else {
   2191               COMPILER_64_SET(counter_values.bytes,
   2192                               COMPILER_64_HI(value_arr[idx]),
   2193                               COMPILER_64_LO(value_arr[idx]));
   2194          }
   2195          BCM_IF_ERROR_RETURN(bcm_esw_vxlan_stat_counter_set( 
   2196                              unit, port, vpn, stat_arr[idx], 
   2197                              1, &counter_indexes, &counter_values));
   2198     }
   2199     return rv;
   2200 #else 
   2201     return BCM_E_UNAVAIL;
   2202 #endif /* BCM_TRIDENT2_SUPPORT */
   2203 }
   2204 
   2205 /*
   2206  * Function:
   2207  *      bcm_esw_vxlan_stat_multi_set32
   2208  *
   2209  * Description:
   2210  *  Set 32bit Vxlan counter value for specified vxlan port and vpn for multiple stat
   2211  *  types
   2212  *
   2213  * Parameters:
   2214  *      unit             - (IN) unit number
   2215  *      port             - (IN) Vxlan gport
   2216  *      vpn              - (IN) vpn (VFI)
   2217  *      stat             - (IN) Vxlan counter stat types
   2218  *      num_entries      - (IN) Number of counter Entries
   2219  *      counter_indexes  - (IN) Pointer to Counter indexes entries
   2220  *      counter_values   - (OUT) Pointer to counter values
   2221  *
   2222  * Return Value:
   2223  *      BCM_E_XXX
   2224  * Notes:
   2225  */
   2226 
   2227 int   bcm_esw_vxlan_stat_multi_set32(
   2228                             int                 unit, 
   2229                             bcm_gport_t         port,
   2230                             bcm_vpn_t           vpn,
   2231                             int                 nstat, 
   2232                             bcm_vxlan_stat_t    *stat_arr,
   2233                             uint32              *value_arr)
   2234 {
   2235 #if defined(BCM_TRIDENT2_SUPPORT)
   2236     int              rv = BCM_E_NONE;
   2237     int              idx;
   2238     uint32           counter_indexes = 0;
   2239     bcm_stat_value_t counter_values = {0};
   2240     uint8 isEline=0xFF;
   2241 
   2242     if (!soc_feature(unit,soc_feature_advanced_flex_counter)) {
   2243         return BCM_E_UNAVAIL;
   2244     }
   2245 
   2246     /* Parameter validation checks */
   2247     if (!SOC_UNIT_VALID(unit)) {
   2248         return BCM_E_UNIT;
   2249     }
   2250 
   2251     if ((BCM_GPORT_INVALID != port) && !(BCM_GPORT_IS_VXLAN_PORT(port))) {
   2252         return BCM_E_PORT;
   2253     }
   2254 
   2255     if (vpn != BCM_VXLAN_VPN_INVALID) {
   2256          BCM_IF_ERROR_RETURN 
   2257               (_bcm_td2_vxlan_vpn_is_eline(unit, vpn, &isEline));
   2258     }
   2259 
   2260     if ((nstat > 0) && ((NULL == stat_arr) || (NULL == value_arr))) {
   2261         return BCM_E_PARAM;
   2262     }
   2263 
   2264     /* Iterate of all stats array to retrieve flex counter values */
   2265     for (idx = 0; idx < nstat ;idx++) {
   2266          if ((stat_arr[idx] == bcmVxlanOutPackets) || 
   2267             (stat_arr[idx] == bcmVxlanInPackets)) {
   2268              counter_values.packets = value_arr[idx];
   2269          } else {
   2270              COMPILER_64_SET(counter_values.bytes,0,value_arr[idx]);
   2271          }
   2272          BCM_IF_ERROR_RETURN(bcm_esw_vxlan_stat_counter_set( 
   2273                              unit, port, vpn, stat_arr[idx], 
   2274                              1, &counter_indexes, &counter_values));
   2275     }
   2276     return rv;
   2277 #else 
   2278     return BCM_E_UNAVAIL;
   2279 #endif /* BCM_TRIDENT2_SUPPORT */
   2280 }
   2281 
   2282 /*
   2283  * Function: 
   2284  *      bcm_esw_vxlan_stat_id_get
   2285  *
   2286  * Description: 
   2287  *      Get Stat Counter if associated with given vxlan port and vpn
   2288  *
   2289  * Parameters: 
   2290  *      unit             - (IN) bcm device
   2291  *      port             - (IN) Vxlan gport
   2292  *      vpn              - (IN) vpn (VFI)
   2293  *      stat             - (IN) Vxlan counter stat types
   2294  *      stat_counter_id  - (IN) Stat Counter ID.
   2295  *
   2296  * Returns:
   2297  *      BCM_E_NONE - Success
   2298  *      BCM_E_XXX
   2299  * Notes:
   2300  */
   2301 
   2302 int   bcm_esw_vxlan_stat_id_get(
   2303                             int                 unit,
   2304                             bcm_gport_t         port,
   2305                             bcm_vpn_t           vpn,
   2306                             bcm_vxlan_stat_t    stat, 
   2307                             uint32              *stat_counter_id) 
   2308 {
   2309 #if defined(BCM_TRIDENT2_SUPPORT)
   2310     bcm_stat_flex_direction_t  direction = bcmStatFlexDirectionIngress;
   2311     uint32                     num_of_tables = 0;
   2312     bcm_stat_flex_table_info_t table_info[BCM_STAT_VXLAN_FLEX_COUNTER_MAX_TABLES];
   2313     uint32                     index = 0;
   2314     uint32                     num_stat_counter_ids = 0;
   2315     uint8 isEline=0xFF;
   2316 
   2317     if (!soc_feature(unit,soc_feature_advanced_flex_counter)) {
   2318         return BCM_E_UNAVAIL;
   2319     }
   2320 
   2321     /* Parameter validation checks */
   2322     if (!SOC_UNIT_VALID(unit)) {
   2323         return BCM_E_UNIT;
   2324     }
   2325 
   2326     if ((BCM_GPORT_INVALID != port) && !(BCM_GPORT_IS_VXLAN_PORT(port))) {
   2327         return BCM_E_PORT;
   2328     }
   2329 
   2330     if (vpn != BCM_VXLAN_VPN_INVALID) {
   2331          BCM_IF_ERROR_RETURN 
   2332               (_bcm_td2_vxlan_vpn_is_eline(unit, vpn, &isEline));
   2333     }
   2334 
   2335     if (NULL == stat_counter_id) {
   2336         return BCM_E_PARAM;
   2337     }
   2338 
   2339     if ((stat == bcmVxlanOutPackets) ||
   2340         (stat == bcmVxlanOutBytes)) {
   2341          direction = bcmStatFlexDirectionEgress;
   2342     } else {
   2343          direction = bcmStatFlexDirectionIngress;
   2344     }
   2345 
   2346     /*  Get Tables, for which flex counter are attached  */
   2347     BCM_IF_ERROR_RETURN(_bcm_esw_vxlan_stat_get_table_info(
   2348                         unit, port, vpn, &num_of_tables, &table_info[0]));
   2349 
   2350     /* Retrieve stat counter id */
   2351     for (index = 0; index < num_of_tables ; index++) {
   2352          if (table_info[index].direction == direction)
   2353              return _bcm_esw_stat_flex_get_counter_id(
   2354                                   unit, 1, &table_info[index],
   2355                                   &num_stat_counter_ids, stat_counter_id);
   2356     }
   2357     return BCM_E_NOT_FOUND;
   2358 #else 
   2359     return BCM_E_UNAVAIL;
   2360 #endif /* BCM_TRIDENT2_SUPPORT */
   2361 }
   2362 
   2363 /*
   2364  * Function:
   2365  *      bcm_esw_vxlan_dip_stat_attach
   2366  * Description:
   2367  *  Attach counters entries to the given VXLAN DIP.
   2368  *
   2369  * Parameters:
   2370  *      unit             - (IN) unit number
   2371  *      vxlan_dip        - (IN) vxlan dip 
   2372  *      stat_counter_id  - (IN) Stat Counter ID.
   2373  *
   2374  * Return Value:
   2375  *      BCM_E_XXX
   2376  */
   2377 bcm_error_t bcm_esw_vxlan_dip_stat_attach(
   2378             int unit,
   2379             bcm_ip_t vxlan_dip,
   2380             uint32 stat_counter_id)
   2381 {
   2382 #if defined(BCM_TRIDENT2_SUPPORT)
   2383     if (SOC_IS_TD2_TT2(unit)) {
   2384         return _bcm_td2_vxlan_dip_stat_attach(unit, vxlan_dip, stat_counter_id);
   2385     }
   2386 #endif
   2387 
   2388     return BCM_E_UNAVAIL;
   2389 }
   2390 
   2391 /*
   2392  * Function:
   2393  *      bcm_esw_vxlan_dip_stat_detach
   2394  * Description:
   2395  *      Detach counters entries to the given vxlan dip
   2396  *
   2397  * Parameters:
   2398  *      unit             - (IN) unit number
   2399  *      vxlan_dip        - (IN) vxlan dip
   2400  *
   2401  * Return Value:
   2402  *      BCM_E_XXX
   2403  * Notes:
   2404  */
   2405 bcm_error_t bcm_esw_vxlan_dip_stat_detach(
   2406             int unit,
   2407             bcm_ip_t vxlan_dip)
   2408 {
   2409 #if defined(BCM_TRIDENT2_SUPPORT)
   2410     if (SOC_IS_TD2_TT2(unit)) {    
   2411         return _bcm_td2_vxlan_dip_stat_detach(unit, vxlan_dip);
   2412     }
   2413 #endif
   2414 
   2415     return BCM_E_UNAVAIL;
   2416 }
   2417 
   2418 /*
   2419  * Function:
   2420  *      bcm_esw_vxlan_dip_stat_counter_get
   2421  * Description:
   2422  * Get the specified counter statistic for an VXLAN DIP.
   2423  *
   2424  * Parameters:
   2425  *      unit             - (IN) unit number
   2426  *      vxlan dip        - (IN) vxlan dip
   2427  *      stat             - (IN) Type of the counter to retrieve
   2428  *                              I.e. ingress/egress byte/packet)
   2429  *      num_entries      - (IN) Number of counter Entries
   2430  *      counter_indexes  - (IN) Pointer to Counter indexes entries
   2431  *      counter_values   - (OUT) Pointer to counter values
   2432  *
   2433  * Return Value:
   2434  *      BCM_E_XXX
   2435  * Notes:
   2436  */
   2437 bcm_error_t bcm_esw_vxlan_dip_stat_counter_get(
   2438                               int              unit,
   2439                               bcm_ip_t  vxlan_dip,
   2440                               bcm_vxlan_dip_stat_t  stat,
   2441                               uint32           num_entries,
   2442                               uint32           *counter_indexes,
   2443                               bcm_stat_value_t *counter_values)
   2444 {
   2445 #if defined(BCM_TRIDENT2_SUPPORT)
   2446     if (SOC_IS_TD2_TT2(unit)) {    
   2447         return _bcm_td2_vxlan_dip_stat_counter_get(unit, 0, vxlan_dip, stat, 
   2448                     num_entries, counter_indexes, counter_values);
   2449     }
   2450 #endif
   2451 
   2452     return BCM_E_UNAVAIL;
   2453 }
   2454 
   2455 
   2456 
   2457 /*
   2458  * Function:
   2459  *      bcm_esw_vxlan_dip_stat_counter_set
   2460  * Description:
   2461  *  Set the specified counter statistic for an VXLAN DIP.
   2462  *
   2463  * Parameters:
   2464  *      unit             - (IN) unit number
   2465  *      vxlan_dip        - (IN) vxlan dip
   2466  *      stat             - (IN) Type of the counter to retrieve
   2467  *                              I.e. ingress/egress byte/packet)
   2468  *      num_entries      - (IN) Number of counter Entries
   2469  *      counter_indexes  - (IN) Pointer to Counter indexes entries
   2470  *      counter_values   - (IN) Pointer to counter values
   2471  *
   2472  * Return Value:
   2473  *      BCM_E_XXX
   2474  * Notes:
   2475  */
   2476 bcm_error_t bcm_esw_vxlan_dip_stat_counter_set(
   2477             int unit,
   2478             bcm_ip_t vxlan_dip,
   2479             bcm_vxlan_dip_stat_t stat,
   2480             uint32 num_entries,
   2481             uint32 *counter_indexes,
   2482             bcm_stat_value_t *counter_values)
   2483 {
   2484 #if defined(BCM_TRIDENT2_SUPPORT)
   2485     if (SOC_IS_TD2_TT2(unit)) {
   2486         return _bcm_td2_vxlan_dip_stat_counter_set(unit, vxlan_dip, stat,
   2487                     num_entries, counter_indexes, counter_values);
   2488     }
   2489 #endif
   2490 
   2491     return BCM_E_UNAVAIL;
   2492 }
   2493 
   2494 
   2495 
   2496 
   2497 /*
   2498  * Function:
   2499  *      bcm_esw_vxlan_dip_stat_multi_get
   2500  *
   2501  * Description:
   2502  *  Get 64-bit counter value for multiple VXLAN DIP statistic types.
   2503  *
   2504  * Parameters:
   2505  *      unit             - (IN) unit number
   2506  *      vxlan_dip        - (IN) vxlan dip
   2507  *      nstat            - (IN) Number of elements in stat array
   2508  *      stat_arr         - (IN) Collected statistics descriptors array
   2509  *      value_arr        - (OUT) Collected counters values
   2510  *
   2511  * Return Value:
   2512  *      BCM_E_XXX
   2513  * Notes:
   2514  */  
   2515  bcm_error_t  bcm_esw_vxlan_dip_stat_multi_get(
   2516                             int                   unit, 
   2517                             bcm_ip_t              vxlan_dip,
   2518                             int                   nstat, 
   2519                             bcm_vxlan_dip_stat_t  *stat_arr,
   2520                             uint64                *value_arr)
   2521 {
   2522 #if defined(BCM_TRIDENT2_SUPPORT)
   2523     if (SOC_IS_TD2_TT2(unit)) {    
   2524         return _bcm_td2_vxlan_dip_stat_multi_get (
   2525                     unit, vxlan_dip, nstat, stat_arr, value_arr);
   2526     }
   2527 #endif
   2528 
   2529     return BCM_E_UNAVAIL;
   2530 }
   2531 
   2532 /*
   2533  * Function:
   2534  *      bcm_esw_vxlan_dip_stat_multi_get32
   2535  *
   2536  * Description:
   2537  *  Get 32-bit counter value for multiple VXLAN DIP statistic types.
   2538  *
   2539  * Parameters:
   2540  *      unit             - (IN) unit number
   2541  *      vxlan_dip        - (IN) Ivxlan dip
   2542  *      nstat            - (IN) Number of elements in stat array
   2543  *      stat_arr         - (IN) Collected statistics descriptors array
   2544  *      value_arr        - (OUT) Collected counters values
   2545  *
   2546  * Return Value:
   2547  *      BCM_E_XXX
   2548  * Notes:
   2549  */
   2550  bcm_error_t  bcm_esw_vxlan_dip_stat_multi_get32(
   2551                             int                   unit, 
   2552                             bcm_ip_t              vxlan_dip,
   2553                             int                   nstat, 
   2554                             bcm_vxlan_dip_stat_t  *stat_arr,
   2555                             uint32                *value_arr)
   2556 {
   2557 #if defined(BCM_TRIDENT2_SUPPORT)
   2558     if (SOC_IS_TD2_TT2(unit)) {    
   2559         return _bcm_td2_vxlan_dip_stat_multi_get32 (
   2560                      unit, vxlan_dip, nstat, stat_arr, value_arr);
   2561     }
   2562 #endif
   2563 
   2564     return BCM_E_UNAVAIL;
   2565 }
   2566 
   2567 /*
   2568  * Function:
   2569  *     bcm_esw_vxlan_dip_stat_multi_set
   2570  *
   2571  * Description:
   2572  *  Set 64-bit counter value for multiple VXLAN DIP statistic types.  
   2573  *
   2574  * Parameters:
   2575  *      unit             - (IN) unit number
   2576  *      vxlan_dip        - (IN) vxlan dip
   2577  *      stat             - (IN) vxlan dip entry counter stat types
   2578  *      num_entries      - (IN) Number of counter Entries
   2579  *      counter_indexes  - (IN) Pointer to Counter indexes entries
   2580  *      counter_values   - (OUT) Pointer to counter values
   2581  *
   2582  * Return Value:
   2583  *      BCM_E_XXX
   2584  * Notes:
   2585  */
   2586 bcm_error_t  bcm_esw_vxlan_dip_stat_multi_set(
   2587                             int                 unit, 
   2588                             bcm_ip_t            vxlan_dip,
   2589                             int                 nstat, 
   2590                             bcm_vxlan_dip_stat_t    *stat_arr,
   2591                             uint64              *value_arr)
   2592 {
   2593 #if defined(BCM_TRIDENT2_SUPPORT)
   2594     if (SOC_IS_TD2_TT2(unit)) {    
   2595         return _bcm_td2_vxlan_dip_stat_multi_set (
   2596                     unit, vxlan_dip, nstat, stat_arr, value_arr);
   2597     }
   2598 #endif
   2599 
   2600     return BCM_E_UNAVAIL;
   2601 }
   2602 
   2603 
   2604 /*
   2605  * Function:
   2606  *      bcm_esw_vxlan_dip_stat_multi_set32
   2607  *
   2608  * Description:
   2609  *  Set 32-bit counter value for multiple VXLAN DIP statistic types.
   2610  *  
   2611  * Parameters:
   2612  *      unit             - (IN) unit number
   2613  *      vxlan_dip        - (IN) vxlan dip
   2614  *      stat             - (IN) vxlan dip entry counter stat types
   2615  *      num_entries      - (IN) Number of counter Entries
   2616  *      counter_indexes  - (IN) Pointer to Counter indexes entries
   2617  *      counter_values   - (OUT) Pointer to counter values
   2618  *
   2619  * Return Value:
   2620  *      BCM_E_XXX
   2621  * Notes:
   2622  */
   2623 
   2624  bcm_error_t  bcm_esw_vxlan_dip_stat_multi_set32(
   2625                             int                   unit, 
   2626                             bcm_ip_t              vxlan_dip,
   2627                             int                   nstat, 
   2628                             bcm_vxlan_dip_stat_t  *stat_arr,
   2629                             uint32                *value_arr)
   2630 {
   2631 #if defined(BCM_TRIDENT2_SUPPORT)
   2632     if (SOC_IS_TD2_TT2(unit)) {    
   2633         return _bcm_td2_vxlan_dip_stat_multi_set32 (
   2634                     unit, vxlan_dip, nstat, stat_arr, value_arr);
   2635     }
   2636 #endif
   2637 
   2638     return BCM_E_UNAVAIL;
   2639 }
   2640 
   2641 /*
   2642  * Function:
   2643  *      bcm_esw_vxlan_dip_stat_id_get
   2644  * Description:
   2645  *    Retrieve associated stat counter for given VXLAN DIP.
   2646  *
   2647  * Parameters:
   2648  *      unit             - (IN) unit number
   2649  *      vxlan_dip        - (IN) vxlan dip entry information
   2650  *      stat             - (IN) Type of the counter to retrieve
   2651  *                              I.e. ingress/egress byte/packet)
   2652  *      Stat_counter_id  - (OUT) Stat Counter ID
   2653  * Return Value:
   2654  *      BCM_E_XXX
   2655  * Notes:
   2656  */
   2657 bcm_error_t bcm_esw_vxlan_dip_stat_id_get(
   2658             int unit,
   2659             bcm_ip_t vxlan_dip,
   2660             bcm_vxlan_dip_stat_t stat,
   2661             uint32 *stat_counter_id)
   2662 {
   2663 #if defined(BCM_TRIDENT2_SUPPORT)
   2664     if (SOC_IS_TD2_TT2(unit)) { 
   2665         return _bcm_td2_vxlan_dip_stat_id_get(unit, vxlan_dip, stat, stat_counter_id);
   2666     }
   2667 #endif
   2668 
   2669     return BCM_E_UNAVAIL;
   2670 }
   2671 
   2672 #ifndef BCM_SW_STATE_DUMP_DISABLE
   2673 /*
   2674  * Function:
   2675  *     _bcm_vxlan_sw_dump
   2676  * Purpose:
   2677  *     Displays VXLAN information maintained by software.
   2678  * Parameters:
   2679  *     unit - Device unit number
   2680  * Returns:
   2681  *     None
   2682  */
   2683 void
   2684 _bcm_vxlan_sw_dump(int unit)
   2685 {
   2686 #ifdef BCM_TRIDENT2_SUPPORT
   2687     if (soc_feature(unit, soc_feature_vxlan)) {
   2688         _bcm_td2_vxlan_sw_dump(unit);
   2689     }
   2690 #endif /* BCM_TRIDENT2_SUPPORT */
   2691 
   2692 #if defined(BCM_GREYHOUND2_SUPPORT)
   2693     if (soc_feature(unit, soc_feature_vxlan_lite)) {
   2694         bcmi_gh2_vxlan_sw_dump(unit);
   2695     }
   2696 #endif /* BCM_GREYHOUND2_SUPPORT */
   2697 
   2698     return;
   2699 }
   2700 #endif /* BCM_SW_STATE_DUMP_DISABLE */
   2701 
   2702 #ifdef BCM_WARM_BOOT_SUPPORT
   2703 
   2704 #define BCM_WB_VERSION_1_0                SOC_SCACHE_VERSION(1, 0)
   2705 #define BCM_WB_VERSION_1_1                SOC_SCACHE_VERSION(1, 1)
   2706 #define BCM_WB_VERSION_1_2                SOC_SCACHE_VERSION(1, 2)
   2707 #define BCM_WB_VERSION_1_3                SOC_SCACHE_VERSION(1, 3)
   2708 #define BCM_WB_VERSION_1_4                SOC_SCACHE_VERSION(1, 4)
   2709 #define BCM_WB_VERSION_1_5                SOC_SCACHE_VERSION(1, 5)
   2710 #define BCM_WB_VERSION_1_6                SOC_SCACHE_VERSION(1, 6)
   2711 #define BCM_WB_DEFAULT_VERSION            BCM_WB_VERSION_1_6
   2712 
   2713 /*
   2714  * Function:
   2715  *      _bcm_esw_vxlan_sync
   2716  *
   2717  * Purpose:
   2718  *      Record VXLAN module persistent info for Level 2 Warm Boot
   2719  *
   2720  * Warm Boot Version Map:
   2721  *  WB_VERSION_1_0
   2722  *    vxlan_tunnel_term         Each entry stores a Vxlan Tunnel Terminator 
   2723  *                              (SIP, DIP, Tunnel State). Max entries: 16K
   2724  *    vxlan_tunnel_init         Each entry stores a Vxlan Tunnel Initiator 
   2725  *                              (SIP, DIP, Tunnel State). Max entries: 16K 
   2726  *    vxlan_ip_tnl_bitmap       Stores the BITMAP of Vxlan Tunnel usage
   2727  *    mk.flags                  From match_key, Each entry stores a flags for
   2728  *                              multicast tunnel. Max entries: 16K
   2729  *    mk.match_tunnel_index     From match_key, Each entry stores a index 
   2730  *                              for multicast tunnel. Max entries: 16K
   2731  *
   2732  *    If these fields are not stored in scache, after warmboot, VXlan API's 
   2733  *    will corrupt hardware-entries and randomly-destroy Vxlan datapath 
   2734  *    forwarding behavior.
   2735  *
   2736  * Parameters:
   2737  *      unit - (IN) Device Unit Number.
   2738  * 
   2739  * Returns:
   2740  *      BCM_E_XXX
   2741  */
   2742  
   2743 int
   2744 _bcm_esw_vxlan_sync(int unit)
   2745 {
   2746 #ifdef BCM_TRIDENT2_SUPPORT
   2747     int sz, rv = BCM_E_NONE;
   2748     int i, num_tnl = 0, num_vp = 0;
   2749     int stable_size;
   2750     bcm_gport_t gport;
   2751     uint8 *vxlan_state;
   2752     soc_scache_handle_t scache_handle;
   2753     _bcm_td2_vxlan_bookkeeping_t *vxlan_info;
   2754     int num_vfi = 0;
   2755 #endif /* BCM_TRIDENT2_SUPPORT */
   2756 
   2757 #if defined(BCM_GREYHOUND2_SUPPORT)
   2758     if (soc_feature(unit, soc_feature_vxlan_lite)) {
   2759         return bcmi_gh2_vxlan_sync(unit);
   2760     }
   2761 #endif /* BCM_GREYHOUND2_SUPPORT */
   2762 
   2763 #ifdef BCM_TRIDENT2_SUPPORT
   2764     if (!soc_feature(unit, soc_feature_vxlan)) {
   2765         return BCM_E_UNAVAIL;
   2766     }
   2767 
   2768     /* Parameter validation checks */
   2769     if (!SOC_UNIT_VALID(unit)) {
   2770         return BCM_E_UNIT;
   2771     }
   2772 
   2773     vxlan_info = VXLAN_INFO(unit);
   2774 
   2775     SOC_IF_ERROR_RETURN(soc_stable_size_get(unit, &stable_size));
   2776 
   2777     /* Requires extended scache support level-2 warmboot */
   2778     if ((stable_size == 0) || (SOC_WARM_BOOT_SCACHE_IS_LIMITED(unit))) {
   2779         return BCM_E_NONE;
   2780     }
   2781 
   2782     SOC_SCACHE_HANDLE_SET(scache_handle, unit, BCM_MODULE_VXLAN, 0);
   2783     rv = _bcm_esw_scache_ptr_get(unit, scache_handle, FALSE,
   2784                                  0, &vxlan_state, 
   2785                                  BCM_WB_DEFAULT_VERSION, NULL);
   2786     if (BCM_FAILURE(rv) && (rv != BCM_E_INTERNAL)) {
   2787         return rv;
   2788     }
   2789 
   2790     num_vp = soc_mem_index_count(unit, SOURCE_VPm);
   2791     num_tnl = soc_mem_index_count(unit, EGR_IP_TUNNELm);
   2792     sz = num_vp * sizeof(_bcm_vxlan_tunnel_endpoint_t);
   2793 
   2794     /* Store each Vxlan Tunnnel Terminator entry (SIP, DIP, Tunnel State) */
   2795     /* 
   2796      *  vxlan_tunnel_term points to a struct array with a base type of 
   2797      *  _bcm_vxlan_tunnel_endpoint_t, sized to hold the info of each virtual 
   2798      *  port tunnel.
   2799      *
   2800      *  SOURCE_VPm hw index equals to array index, related to the IP & state 
   2801      *  info of each VP.
   2802      *  
   2803      *  _bcm_vxlan_tunnel_endpoint_t[size of (SOURCE_VPm)]  *vxlan_tunnel_term
   2804      */
   2805     
   2806     sal_memcpy(vxlan_state, vxlan_info->vxlan_tunnel_term, sz);
   2807     vxlan_state += sz;
   2808     
   2809     /* Store each Vxlan Tunnel Initiator entry (SIP, DIP, Tunnel State) */
   2810     /* 
   2811      *  Same as vxlan_tunnel_term 
   2812      */
   2813      
   2814     sal_memcpy(vxlan_state, vxlan_info->vxlan_tunnel_init, sz);
   2815     vxlan_state += sz;
   2816     
   2817     /* Store the BITMAP of Vxlan Tunnel usage */
   2818     /* 
   2819      *  vxlan_ip_tnl_bitmap points to a struct array with a base type of uint32.
   2820      *  sized to hold the maximum number of Egress IP Tunnel.
   2821      *
   2822      *  EGR_IP_TUNNELm hw index used as offset of this wide bitmap.
   2823      *
   2824      *  uint32[(size of (EGR_IP_TUNNELm) + 31) / 32]    *vxlan_ip_tnl_bitmap 
   2825      */
   2826     
   2827     sal_memcpy(vxlan_state, vxlan_info->vxlan_ip_tnl_bitmap, 
   2828                 SHR_BITALLOCSIZE(num_tnl));
   2829     vxlan_state += SHR_BITALLOCSIZE(num_tnl);
   2830 
   2831     /* Store the flags & match_tunnel_index of each Match Key */
   2832     /* 
   2833      *  Since we can't recover flags & match_tunnel_index from HW if we 
   2834      *  configure a multicast tunnel(see _bcm_td2_vxlan_match_add with 
   2835      *  BCM_VXLAN_PORT_MULTICAST flag), so we need to store it for warmboot 
   2836      *  recovery. 
   2837  */
   2838      
   2839     for (i = 0; i < num_vp; i++) {
   2840         sal_memcpy(vxlan_state, &(vxlan_info->match_key[i].flags), 
   2841                     sizeof(uint32));
   2842         vxlan_state += sizeof(uint32);        
   2843         sal_memcpy(vxlan_state, &(vxlan_info->match_key[i].match_tunnel_index), 
   2844                     sizeof(uint32));
   2845         vxlan_state += sizeof(uint32);
   2846     }
   2847 
   2848     /*
   2849      * Since we can't recover index && gport(trunk_id, modid, port) &&
   2850      * match_vlan && match_inner_vlan from HW if we add this vxlan port to
   2851      * VPLAG, so we need to store it for warmboot recovery. 
   2852      */
   2853     for (i = 0; i < num_vp; i++) {
   2854         sal_memcpy(vxlan_state, &(vxlan_info->match_key[i].index), 
   2855                    sizeof(uint32));
   2856         vxlan_state += sizeof(uint32); 
   2857         if (vxlan_info->match_key[i].trunk_id != -1) {
   2858             BCM_GPORT_TRUNK_SET(gport, vxlan_info->match_key[i].trunk_id);
   2859         } else if (vxlan_info->match_key[i].modid != -1) {
   2860             BCM_GPORT_MODPORT_SET(gport,
   2861                                   vxlan_info->match_key[i].modid,
   2862                                   vxlan_info->match_key[i].port);
   2863         } else {
   2864             gport = BCM_GPORT_INVALID;
   2865         }
   2866         sal_memcpy(vxlan_state, &gport, sizeof(bcm_gport_t));
   2867         vxlan_state += sizeof(bcm_gport_t);
   2868         sal_memcpy(vxlan_state, &(vxlan_info->match_key[i].match_vlan), 
   2869                    sizeof(bcm_vlan_t));
   2870         vxlan_state += sizeof(bcm_vlan_t); 
   2871         sal_memcpy(vxlan_state, &(vxlan_info->match_key[i].match_inner_vlan), 
   2872                    sizeof(bcm_vlan_t));
   2873         vxlan_state += sizeof(bcm_vlan_t); 
   2874     }
   2875 
   2876     num_vfi = soc_mem_index_count(unit, VFIm);
   2877     for (i = 0; i < num_vfi; i++) {
   2878         sal_memcpy(vxlan_state, &(vxlan_info->vxlan_vpn_vlan[i]),
   2879                    sizeof(bcm_vlan_t));
   2880         vxlan_state += sizeof(bcm_vlan_t);
   2881     }
   2882     /* Store the type of each vxlan vpn */
   2883     for (i = 0; i < num_vfi; i++) {
   2884         sal_memcpy(vxlan_state, &(vxlan_info->vxlan_vpn_info[i].sip),
   2885                    sizeof(bcm_ip_t));
   2886         vxlan_state += sizeof(bcm_ip_t);
   2887         sal_memcpy(vxlan_state, &(vxlan_info->vxlan_vpn_info[i].vnid),
   2888                    sizeof(uint32));
   2889         vxlan_state += sizeof(uint32);
   2890         sal_memcpy(vxlan_state, &(vxlan_info->vxlan_vpn_info[i].vxlan_vpn_type),
   2891                    sizeof(uint8));
   2892         vxlan_state += sizeof(uint8);        
   2893     }
   2894     /* Store the vfi index for vp */
   2895     for (i = 0; i < num_vp; i++) {
   2896         sal_memcpy(vxlan_state, &(vxlan_info->match_key[i].vfi),
   2897                    sizeof(int));
   2898         vxlan_state += sizeof(int);
   2899 
   2900     }
   2901     return rv;
   2902     
   2903 #endif
   2904 
   2905     return BCM_E_UNAVAIL;
   2906 }
   2907 #endif /* BCM_WARM_BOOT_SUPPORT */
   2908 
   2909 #else   /* INCLUDE_L3 */
   2910  int bcm_esw_vxlan_not_empty;
   2911 #endif  /* INCLUDE_L3 */
   2912