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

tunnel.c (19824B)


      1 /*
      2  * 
      3  * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
      4  * 
      5  * Copyright 2007-2019 Broadcom Inc. All rights reserved.
      6  *
      7  * File:    tunnel.c
      8  * Purpose: Manages tunnel configuration
      9  */
     10 
     11 #include <soc/defs.h>
     12 
     13 #ifdef INCLUDE_L3
     14 
     15 #include <sal/core/libc.h>
     16 
     17 #include <soc/drv.h>
     18 #include <soc/mem.h>
     19 #include <soc/util.h>
     20 #include <soc/debug.h>
     21 
     22 #include <bcm/l3.h>
     23 #include <bcm/tunnel.h>
     24 
     25 #include <bcm_int/esw/mbcm.h>
     26 #include <bcm_int/esw/l3.h>
     27 #include <bcm_int/esw_dispatch.h>
     28 #ifdef  BCM_XGS_SWITCH_SUPPORT
     29 #include <bcm_int/esw/firebolt.h>
     30 
     31 #if defined(BCM_TRX_SUPPORT)
     32 #include <bcm_int/esw/trx.h>
     33 #endif /* BCM_TRX_SUPPORT */
     34 
     35 #if defined(BCM_TRIUMPH2_SUPPORT)
     36 #include <bcm_int/esw/triumph2.h>
     37 #endif /* BCM_TRIUMPH2_SUPPORT */
     38 
     39 #if defined(BCM_TRIUMPH3_SUPPORT)
     40 #include <bcm_int/esw/triumph3.h>
     41 #endif /* BCM_TRIUMPH2_SUPPORT */
     42 
     43 
     44 #endif  /* BCM_XGS_SWITCH_SUPPORT */
     45 
     46 
     47 /* 
     48  * Function:
     49  *      bcm_esw_tunnel_terminator_add
     50  * Purpose: 
     51  *      Add a tunnel terminator for DIP-SIP
     52  * Parameters: 
     53  *      unit - (IN)SOC unit number.
     54  *      info - (IN)Tunnel information.
     55  * Returns:
     56  *      BCM_E_XXX
     57  * Note:
     58  *      The following restrictions are used:
     59  *       - DIP must not be 0; DIP mask must be 0xFFFFFFFF
     60  *       - SIP mask must be either 0xFFFFFFFF or 0.  If it is
     61  *         0xFFFFFFFF, then SIP can not be 0.
     62  */
     63 int
     64 bcm_esw_tunnel_terminator_add(int unit, bcm_tunnel_terminator_t *info)
     65 {
     66     /* Input parameters check. */
     67     if (NULL == info) {
     68         return (BCM_E_PARAM);
     69     }
     70 
     71     /* Vrf is in device supported range check. */
     72     if ((info->vrf > SOC_VRF_MAX(unit)) || 
     73         (info->vrf < BCM_L3_VRF_DEFAULT)) {
     74         return (BCM_E_PARAM);
     75     }
     76   
     77     /*  Check that device supports ipv6. */
     78     if (BCM_L3_NO_IP6_SUPPORT(unit, info->flags)) {
     79         return (BCM_E_UNAVAIL);
     80     }
     81 	
     82     if (soc_feature(unit, soc_feature_no_tunnel)) {
     83         return (BCM_E_UNAVAIL);
     84     }
     85 
     86 #if defined(BCM_XGS3_SWITCH_SUPPORT)
     87     if (SOC_IS_XGS3_SWITCH(unit) && !SOC_IS_HAWKEYE(unit) &&
     88         soc_feature(unit, soc_feature_l3)) {
     89         return bcm_xgs3_tunnel_terminator_add(unit, info);
     90     }
     91 #endif  /* BCM_XGS3_SWITCH_SUPPORT */
     92     return BCM_E_UNAVAIL;
     93 }
     94 
     95 /* 
     96  * Function:
     97  *      bcm_esw_tunnel_terminator_delete
     98  * Purpose: 
     99  *      Delete a tunnel terminator.
    100  * Parameters: 
    101  *      unit - (IN)SOC unit number.
    102  *      info - (IN)Tunnel deletion lookup key.
    103  * Returns:
    104  *      BCM_E_XXX
    105  */
    106 int
    107 bcm_esw_tunnel_terminator_delete(int unit, bcm_tunnel_terminator_t *info)
    108 {
    109     /* Input parameters check. */
    110     if (NULL == info) {
    111         return (BCM_E_PARAM);
    112     }
    113 
    114     /* Vrf is in device supported range check. */
    115     if ((info->vrf > SOC_VRF_MAX(unit)) || 
    116         (info->vrf < BCM_L3_VRF_DEFAULT)) {
    117         return (BCM_E_PARAM);
    118     }
    119   
    120     /*  Check that device supports ipv6. */
    121     if (BCM_L3_NO_IP6_SUPPORT(unit, info->flags)) {
    122         return (BCM_E_UNAVAIL);
    123     }
    124 
    125     if (soc_feature(unit, soc_feature_no_tunnel)) {
    126         return (BCM_E_UNAVAIL);
    127     }
    128 
    129 #if defined(BCM_XGS3_SWITCH_SUPPORT)
    130     if (SOC_IS_XGS3_SWITCH(unit) && !SOC_IS_HAWKEYE(unit) &&
    131         soc_feature(unit, soc_feature_l3)) {
    132         return bcm_xgs3_tunnel_terminator_delete(unit, info);
    133     }
    134 #endif  /* BCM_XGS3_SWITCH_SUPPORT */
    135     return BCM_E_UNAVAIL;
    136 }
    137 
    138 /* 
    139  * Function:
    140  *      bcm_esw_tunnel_terminator_update
    141  * Purpose: 
    142  *      Update a tunnel terminator for DIP-SIP
    143  * Parameters: 
    144  *      unit - (IN)SOC unit number.
    145  *      info - (IN)Tunnel lookup key & updated tunnel information.
    146  * Returns:
    147  *      BCM_E_XXX
    148  */
    149 int
    150 bcm_esw_tunnel_terminator_update(int unit, bcm_tunnel_terminator_t *info)
    151 {
    152     /* Input parameters check. */
    153     if (NULL == info) {
    154         return (BCM_E_PARAM);
    155     }
    156 	
    157     /* Vrf is in device supported range check. */
    158     if ((info->vrf > SOC_VRF_MAX(unit)) || 
    159         (info->vrf < BCM_L3_VRF_DEFAULT)) {
    160         return (BCM_E_PARAM);
    161     }
    162   
    163     /*  Check that device supports ipv6. */
    164     if (BCM_L3_NO_IP6_SUPPORT(unit, info->flags)) {
    165         return (BCM_E_UNAVAIL);
    166     }
    167 
    168     if (soc_feature(unit, soc_feature_no_tunnel)) {
    169         return (BCM_E_UNAVAIL);
    170     }
    171 
    172 #if defined(BCM_XGS3_SWITCH_SUPPORT)
    173     if (SOC_IS_XGS3_SWITCH(unit) && !SOC_IS_HAWKEYE(unit) &&
    174         soc_feature(unit, soc_feature_l3)) {
    175         return bcm_xgs3_tunnel_terminator_update(unit, info);
    176     }
    177 #endif  /* BCM_XGS3_SWITCH_SUPPORT */
    178     return BCM_E_UNAVAIL;
    179 }
    180 
    181 /* 
    182  * Function:
    183  *      bcm_esw_tunnel_terminator_get
    184  * Purpose: 
    185  *      Get a tunnel terminator info.  
    186  * Parameters: 
    187  *      unit - (IN)SOC unit number.
    188  *      info - (IN/OUT)Lookup key & extracted tunnel information.
    189  * Returns:
    190  *      BCM_E_XXX
    191  */
    192 int
    193 bcm_esw_tunnel_terminator_get(int unit, bcm_tunnel_terminator_t *info)
    194 {
    195     /* Input parameters check. */
    196     if (NULL == info) {
    197         return (BCM_E_PARAM);
    198     }
    199 
    200     /* Vrf is in device supported range check. */
    201     if ((info->vrf > SOC_VRF_MAX(unit)) || 
    202         (info->vrf < BCM_L3_VRF_DEFAULT)) {
    203         return (BCM_E_PARAM);
    204     }
    205   
    206     /*  Check that device supports ipv6. */
    207     if (BCM_L3_NO_IP6_SUPPORT(unit, info->flags)) {
    208         return (BCM_E_UNAVAIL);
    209     }
    210 
    211     if (soc_feature(unit, soc_feature_no_tunnel)) {
    212         return (BCM_E_UNAVAIL);
    213     }
    214 
    215 #if defined(BCM_XGS3_SWITCH_SUPPORT)
    216     if (SOC_IS_XGS3_SWITCH(unit) && !SOC_IS_HAWKEYE(unit) &&
    217         soc_feature(unit, soc_feature_l3)) {
    218         return bcm_xgs3_tunnel_terminator_get(unit, info);
    219     }
    220 #endif  /* BCM_XGS3_SWITCH_SUPPORT */
    221     return BCM_E_UNAVAIL;
    222 }
    223 
    224 /*
    225  * Function:
    226  *      bcm_esw_tunnel_terminator_traverse
    227  * Purpose:
    228  *      Traverse all tunnel terminator entries
    229  * Parameters:
    230  *      unit - (IN)SOC unit number. 
    231  *      cb - (IN)User callback function, called once per entry
    232  *      user_data - (IN)User supplied cookie used in parameter in callback function
    233  * Returns:
    234  *      BCM_E_XXX
    235  */
    236 int
    237 bcm_esw_tunnel_terminator_traverse(int unit, 
    238                              bcm_tunnel_terminator_traverse_cb cb,
    239                              void *user_data)
    240 {
    241     if (soc_feature(unit, soc_feature_no_tunnel)) {
    242         return (BCM_E_UNAVAIL);
    243     }
    244 
    245 #if defined(BCM_XGS3_SWITCH_SUPPORT)
    246     if (SOC_IS_XGS3_SWITCH(unit) && !SOC_IS_HAWKEYE(unit) &&
    247         soc_feature(unit, soc_feature_l3)) {
    248         return bcm_xgs3_tunnel_terminator_traverse(unit, cb, user_data);
    249     }
    250 #endif  /* BCM_XGS3_SWITCH_SUPPORT */
    251     return BCM_E_UNAVAIL;
    252 }
    253 
    254 /*
    255  * Function:
    256  *      bcm_esw_tunnel_initiator_set
    257  * Purpose:
    258  *      Set the tunnel property for the given L3 interface
    259  * Parameters:
    260  *      unit  - (IN)SOC unit number.
    261  *      intf  - (IN)L3 interface info.(ONLY ifindex used to identify interface).
    262  *      tunnel -(IN)The tunnel header information.
    263  * Returns:
    264  *      BCM_E_XXX
    265  */
    266 int
    267 bcm_esw_tunnel_initiator_set(int unit, bcm_l3_intf_t *intf,
    268                              bcm_tunnel_initiator_t *tunnel)
    269 {
    270     /* Input parameters check. */
    271     if (NULL == tunnel) {
    272         return (BCM_E_PARAM);
    273     }
    274 
    275     /*  Check that device supports ipv6. */
    276     if (BCM_L3_NO_IP6_SUPPORT(unit, tunnel->flags)) {
    277         return (BCM_E_UNAVAIL);
    278     }
    279 
    280     if (soc_feature(unit, soc_feature_no_tunnel)) {
    281         return (BCM_E_UNAVAIL);
    282     }
    283 
    284 #if defined(BCM_XGS3_SWITCH_SUPPORT)
    285     if (SOC_IS_XGS3_SWITCH(unit) && !SOC_IS_HAWKEYE(unit) &&
    286         soc_feature(unit, soc_feature_l3)) {
    287         return (bcm_xgs3_tunnel_initiator_set(unit, intf, tunnel));
    288     }
    289 #endif /* BCM_XGS3_SWITCH_SUPPORT */
    290     return BCM_E_UNAVAIL;
    291 }
    292 
    293 /*
    294  * Function:
    295  *      bcm_esw_tunnel_initiator_clear
    296  * Purpose:
    297  *      Delete the tunnel association for the given L3 interface
    298  * Parameters:
    299  *      unit - (IN)SOC unit number.
    300  *      intf - (IN)L3 interface info.(ONLY ifindex used to identify interface).
    301  * Returns:
    302  *      BCM_E_XXX
    303  */
    304 int
    305 bcm_esw_tunnel_initiator_clear(int unit, bcm_l3_intf_t *intf)
    306 {
    307     if (soc_feature(unit, soc_feature_no_tunnel)) {
    308         return (BCM_E_UNAVAIL);
    309     }
    310 
    311 #if defined(BCM_XGS3_SWITCH_SUPPORT)
    312     if (SOC_IS_XGS3_SWITCH(unit) && !SOC_IS_HAWKEYE(unit) &&
    313         soc_feature(unit, soc_feature_l3)) {
    314         return bcm_xgs3_tunnel_initiator_clear(unit, intf);
    315     }
    316 #endif  /* BCM_XGS3_SWITCH_SUPPORT */
    317     return BCM_E_UNAVAIL;
    318 }
    319 
    320 /*
    321  * Function:
    322  *      bcm_esw_tunnel_initiator_get
    323  * Purpose:
    324  *      Get the tunnel properties for the given L3 interface
    325  * Parameters:
    326  *      unit   - (IN)SOC unit number. 
    327  *      intf   - (IN)L3 interface info (ONLY ifindex used to find interface).
    328  *      tunnel - (IN/OUT) The tunnel header information
    329  * Returns:
    330  *      BCM_E_XXX
    331  */
    332 int
    333 bcm_esw_tunnel_initiator_get(int unit, bcm_l3_intf_t *l3_intf,
    334                              bcm_tunnel_initiator_t *tunnel)
    335 {
    336     if (soc_feature(unit, soc_feature_no_tunnel)) {
    337         return (BCM_E_UNAVAIL);
    338     }
    339 
    340 #if defined(BCM_XGS3_SWITCH_SUPPORT)
    341     if (SOC_IS_XGS3_SWITCH(unit) && !SOC_IS_HAWKEYE(unit) &&
    342         soc_feature(unit, soc_feature_l3)) {
    343         return bcm_xgs3_tunnel_initiator_get(unit, l3_intf, tunnel);
    344     }
    345 #endif  /* BCM_XGS3_SWITCH_SUPPORT */
    346     return BCM_E_UNAVAIL;
    347 }
    348 
    349 /*
    350  * Function:
    351  *      bcm_esw_tunnel_initiator_traverse
    352  * Purpose:
    353  *      Traverse all tunnel initiator entries
    354  * Parameters:
    355  *      unit - (IN)SOC unit number. 
    356  *      cb - (IN)User callback function, called once per entry
    357  *      user_data - (IN)User supplied cookie used in parameter in callback function
    358  * Returns:
    359  *      BCM_E_XXX
    360  */
    361 int
    362 bcm_esw_tunnel_initiator_traverse(int unit, 
    363                              bcm_tunnel_initiator_traverse_cb cb,
    364                              void *user_data)
    365 {
    366     if (soc_feature(unit, soc_feature_no_tunnel)) {
    367         return (BCM_E_UNAVAIL);
    368     }
    369 
    370 #if defined(BCM_XGS3_SWITCH_SUPPORT)
    371     if (SOC_IS_XGS3_SWITCH(unit) && !SOC_IS_HAWKEYE(unit) &&
    372         soc_feature(unit, soc_feature_l3)) {
    373         return bcm_xgs3_tunnel_initiator_traverse(unit, cb, user_data);
    374     }
    375 #endif  /* BCM_XGS3_SWITCH_SUPPORT */
    376     return BCM_E_UNAVAIL;
    377 }
    378 
    379 /*
    380  * Function:
    381  *      bcm_esw_tunnel_config_set
    382  * Purpose:
    383  *      Set the global tunnel property
    384  * Parameters:
    385  *      unit    - (IN)SOC unit number 
    386  *      tconfig - (IN)Global information about the L3 tunneling config.
    387  * Returns:
    388  *      BCM_E_XXX
    389  */
    390 int
    391 bcm_esw_tunnel_config_set(int unit, bcm_tunnel_config_t *tconfig)
    392 {
    393     if (soc_feature(unit, soc_feature_no_tunnel)) {
    394         return (BCM_E_UNAVAIL);
    395     }
    396 
    397 #if defined(BCM_XGS3_SWITCH_SUPPORT)
    398     if (SOC_IS_XGS3_SWITCH(unit) && !SOC_IS_HAWKEYE(unit) &&
    399         soc_feature(unit, soc_feature_l3)) {
    400         return bcm_xgs3_tunnel_config_set(unit, tconfig);
    401     }
    402 #endif  /* BCM_XGS3_SWITCH_SUPPORT */
    403     return BCM_E_UNAVAIL;
    404 }
    405 
    406 /*
    407  * Function: 
    408  *      bcm_tunnel_dscp_map_create
    409  * Purpose:
    410  *      Create a tunnel DSCP map instance.
    411  * Parameters:
    412  *      unit         - (IN)  SOC unit #
    413  *      flags        - (IN)  BCM_L3_XXX
    414  *      dscp_map_id  - (OUT) Allocated DSCP map ID
    415  * Returns:
    416  *      BCM_E_XXX
    417  */
    418 int
    419 bcm_esw_tunnel_dscp_map_create(int unit, uint32 flags, int *dscp_map_id)
    420 {
    421 #if defined(BCM_XGS3_SWITCH_SUPPORT)
    422     if (SOC_IS_XGS3_SWITCH(unit) && !SOC_IS_HAWKEYE(unit) &&
    423         soc_feature(unit, soc_feature_l3)) {
    424         return (bcm_xgs3_tunnel_dscp_map_create(unit, flags, dscp_map_id));
    425     }
    426 #endif
    427     return BCM_E_UNAVAIL;
    428 }
    429     
    430 /*
    431  * Function:
    432  *      bcm_tunnel_dscp_map_destroy
    433  * Purpose:
    434  *      Destroy an existing tunnel DSCP map instance.
    435  * Parameters:
    436  *      unit        - (IN) SOC unit #
    437  *      dscp_map_id - (IN) DSCP map ID
    438  * Returns:
    439  *      BCM_E_XXX
    440  */ 
    441 int
    442 bcm_esw_tunnel_dscp_map_destroy(int unit, int dscp_map_id)
    443 {   
    444 #if defined(BCM_XGS3_SWITCH_SUPPORT)
    445     if (SOC_IS_XGS3_SWITCH(unit) && !SOC_IS_HAWKEYE(unit) &&
    446         soc_feature(unit, soc_feature_l3)) {
    447         return (bcm_xgs3_tunnel_dscp_map_destroy(unit, dscp_map_id));
    448     }
    449 #endif
    450     return BCM_E_UNAVAIL;
    451 }
    452 
    453 /*
    454  * Function:
    455  *      bcm_tunnel_dscp_map_set
    456  * Purpose:
    457  *      Set the mapping of { internal priority, color }
    458  *      to a DSCP value for outer tunnel headers
    459  *      in the specified DSCP map instance.
    460  * Parameters:
    461  *      unit         - (IN) SOC unit #
    462  *      dscp_map_id  - (IN) DSCP map ID
    463  *      priority - (IN) Internal priority
    464  *      color    - (IN) bcmColor*
    465  *      dscp     - (IN) DSCP value
    466  * Returns:
    467  *      BCM_E_XXX
    468  */
    469 int
    470 bcm_esw_tunnel_dscp_map_set(int unit, int dscp_map_id, 
    471                             bcm_tunnel_dscp_map_t *dscp_map)
    472 {
    473     int rv = BCM_E_UNAVAIL;
    474 #if defined(BCM_TRX_SUPPORT)
    475     bcm_port_t port;
    476 #endif /* BCM_TRX_SUPPORT */
    477 
    478 
    479     if ((0 == SOC_IS_XGS3_SWITCH(unit)) ||  
    480         (1 == SOC_IS_HAWKEYE(unit)) || 
    481         (0 == soc_feature(unit, soc_feature_l3))) {
    482         return (rv);
    483     }
    484 
    485 #if defined(BCM_XGS3_SWITCH_SUPPORT)
    486 
    487     if ((dscp_map == NULL) ||
    488         (dscp_map_id < 0) ||
    489         (dscp_map_id >= BCM_XGS3_L3_TUNNEL_DSCP_MAP_TBL_SIZE(unit)) ||
    490         (dscp_map->priority < BCM_PRIO_MIN) ||
    491         (dscp_map->priority > BCM_PRIO_MAX) ||
    492         (dscp_map->dscp < 0) ||
    493         (dscp_map->dscp > 63)) {
    494         return (BCM_E_PARAM);
    495     }
    496 
    497     if (!BCM_L3_DSCP_MAP_USED_GET(unit, dscp_map_id)) {
    498         return (BCM_E_NOT_FOUND);
    499     }
    500 
    501 #if defined(BCM_TRX_SUPPORT)
    502     if (SOC_IS_TRX(unit)) {
    503 
    504         /* Set dscp map for each port. */
    505         PBMP_PORT_ITER(unit, port) {
    506             rv = bcm_esw_tunnel_dscp_map_port_set(unit, port, dscp_map);
    507             if (BCM_FAILURE(rv)) {
    508                 break;
    509             }
    510         }
    511     } else 
    512 #endif /* BCM_TRX_SUPPORT */
    513     { 
    514         rv = bcm_xgs3_tunnel_dscp_map_set(unit, dscp_map_id, dscp_map);
    515     }
    516 #endif /* BCM_XGS3_SWITCH_SUPPORT */
    517     return (rv);
    518 }
    519     
    520 /*
    521  * Function:
    522  *      bcm_tunnel_dscp_map_get
    523  * Purpose:
    524  *      Set the mapping of { internal priority, color }
    525  *      to a DSCP value for outer tunnel headers
    526  *      in the specified DSCP map instance.
    527  * Parameters:
    528  *      unit         - (IN)  SOC unit #
    529  *      dscp_map_id  - (IN)  DSCP map ID
    530  *      priority - (IN)  Internal priority
    531  *      color    - (IN)  bcmColor*
    532  *      dscp     - (OUT) DSCP value
    533  * Returns:
    534  *      BCM_E_XXX
    535  */     
    536 int     
    537 bcm_esw_tunnel_dscp_map_get(int unit, int dscp_map_id, 
    538                             bcm_tunnel_dscp_map_t *dscp_map)
    539 {
    540     int rv = BCM_E_UNAVAIL;
    541 #if defined(BCM_TRX_SUPPORT)
    542     bcm_port_t port;
    543 #endif /* BCM_TRX_SUPPORT */
    544 
    545     if ((0 == SOC_IS_XGS3_SWITCH(unit)) ||  
    546         (1 == SOC_IS_HAWKEYE(unit)) || 
    547         (0 == soc_feature(unit, soc_feature_l3))) {
    548         return (rv);
    549     }
    550 
    551 #if defined(BCM_XGS3_SWITCH_SUPPORT)
    552 
    553     if ((dscp_map == NULL) ||
    554         (dscp_map_id < 0) ||
    555         (dscp_map_id >= BCM_XGS3_L3_TUNNEL_DSCP_MAP_TBL_SIZE(unit)) ||
    556         (dscp_map->priority < BCM_PRIO_MIN) ||
    557         (dscp_map->priority > BCM_PRIO_MAX) ||
    558         (dscp_map->dscp < 0) ||
    559         (dscp_map->dscp > 63)) {
    560         return (BCM_E_PARAM);
    561     }
    562 
    563     if (!BCM_L3_DSCP_MAP_USED_GET(unit, dscp_map_id)) {
    564         return (BCM_E_NOT_FOUND);
    565     }
    566 
    567 #if defined(BCM_TRX_SUPPORT)
    568     if (SOC_IS_TRX(unit)) {
    569         /* Read dscp map from forst available port. */
    570         PBMP_PORT_ITER(unit, port) {
    571             rv = bcm_esw_tunnel_dscp_map_port_get(unit, port, dscp_map);
    572             break;
    573         }
    574     } else 
    575 #endif /* BCM_TRX_SUPPORT */
    576     {
    577         rv = bcm_xgs3_tunnel_dscp_map_get(unit, dscp_map_id, dscp_map);
    578     }
    579 #endif /* BCM_XGS3_SWITCH_SUPPORT */
    580     return (rv);
    581 }
    582 
    583 /*
    584 * Function:
    585 *      bcm_tunnel_dscp_map_port_set
    586 * Purpose:
    587 *      Set the mapping of { internal priority, color }
    588 *      to a DSCP value for outer tunnel headers
    589 *      for a specific port.
    590 * Parameters:
    591 *      unit         - (IN) BCM device number
    592 *      port         - (IN) Egress port number.
    593 *      dscp_map     - (IN) mapping of internal priority & color to a dscp
    594 * Returns:
    595 *      BCM_E_XXX
    596 */
    597 int
    598 bcm_esw_tunnel_dscp_map_port_set(int unit, bcm_port_t port,
    599                              bcm_tunnel_dscp_map_t *dscp_map)
    600 {
    601 #if defined(BCM_TRX_SUPPORT)
    602     if (SOC_IS_TRX(unit) && soc_feature(unit, soc_feature_l3)) {
    603         return (_bcm_trx_tunnel_dscp_map_port_set(unit, port, dscp_map));
    604     }
    605 #endif
    606     return BCM_E_UNAVAIL;
    607 }
    608 /*
    609 * Function:
    610 *      bcm_tunnel_dscp_map_port_get
    611 * Purpose:
    612 *      Get the mapping of { internal priority, color }
    613 *      to a DSCP value for outer tunnel headers
    614 *      for a specific port.
    615 * Parameters:
    616 *      unit         - (IN) SOC unit #
    617 *      port         - (IN) Egress port number.
    618 *      dscp_map     - (IN/OUT) IN priority, color
    619 *                              OUT dscp value
    620 * Returns:
    621 *      BCM_E_XXX
    622 */
    623 int
    624 bcm_esw_tunnel_dscp_map_port_get(int unit, bcm_port_t port,
    625                                  bcm_tunnel_dscp_map_t *dscp_map)
    626 {
    627 #if defined(BCM_TRX_SUPPORT)
    628     if (SOC_IS_TRX(unit) && soc_feature(unit, soc_feature_l3)) {
    629         return (_bcm_trx_tunnel_dscp_map_port_get(unit, port, dscp_map));
    630     }
    631 #endif
    632     return (BCM_E_UNAVAIL);
    633 }
    634 
    635 /*
    636  * Function:
    637  *      bcm_esw_tunnel_config_get 
    638  * Purpose:
    639  *      Get the global tunnel property
    640  * Parameters:
    641  *      unit    - (IN)SOC unit number. 
    642  *      tconfig - (IN/OUT)Global information about the L3 tunneling config.
    643  * Returns:
    644  *      BCM_E_XXX
    645  */
    646 int
    647 bcm_esw_tunnel_config_get(int unit, bcm_tunnel_config_t *tconfig)
    648 {
    649     if (soc_feature(unit, soc_feature_no_tunnel)) {
    650         return (BCM_E_UNAVAIL);
    651     }
    652 
    653 #if defined(BCM_XGS3_SWITCH_SUPPORT)
    654     if (SOC_IS_XGS3_SWITCH(unit) && !SOC_IS_HAWKEYE(unit) &&
    655         soc_feature(unit, soc_feature_l3)) {
    656         return bcm_xgs3_tunnel_config_get(unit, tconfig);
    657     }
    658 #endif  /* BCM_XGS3_SWITCH_SUPPORT */
    659     return BCM_E_UNAVAIL;
    660 }
    661 
    662 /*
    663  * Function:
    664  *      bcm_tunnel_terminator_vlan_set 
    665  * Purpose:
    666  *      Set the allowed VLANs for a WLAN tunnel
    667  * Parameters:
    668  *      unit    - (IN)SOC unit number. 
    669  *      tunnel  - (IN)Tunnel ID.
    670  *      vlan_vec - (IN)VLAN vector
    671  * Returns:
    672  *      BCM_E_XXX
    673  */
    674 int
    675 bcm_esw_tunnel_terminator_vlan_set(int unit, bcm_gport_t tunnel, 
    676                                bcm_vlan_vector_t vlan_vec)
    677 {
    678     int rv = BCM_E_UNAVAIL;
    679 
    680     if (soc_feature(unit, soc_feature_no_tunnel)) {
    681         return (BCM_E_UNAVAIL);
    682     }
    683 
    684 #if defined(BCM_TRIUMPH2_SUPPORT) || defined(BCM_TRIUMPH3_SUPPORT)
    685     if (soc_feature(unit, soc_feature_wlan)) {
    686 #if defined(BCM_TRIUMPH3_SUPPORT)
    687         if (SOC_IS_TRIUMPH3(unit)) {
    688             rv = bcm_tr3_wlan_tunnel_terminator_vlan_set(unit, tunnel, vlan_vec);
    689         } else 
    690 #endif /* BCM_TRIUMPH3_SUPPORT */
    691         {
    692             rv = bcm_tr2_tunnel_terminator_vlan_set(unit, tunnel, vlan_vec);
    693 
    694         }
    695     }
    696 #endif /* BCM_TRIUMPH2_SUPPORT || BCM_TRIUMPH3_SUPPORT */
    697     return rv;
    698 }
    699 
    700 /*
    701  * Function:
    702  *      bcm_tunnel_terminator_vlan_get 
    703  * Purpose:
    704  *      Get the allowed VLANs for a WLAN tunnel
    705  * Parameters:
    706  *      unit    - (IN)SOC unit number. 
    707  *      tunnel  - (IN)Tunnel ID.
    708  *      vlan_vec - (OUT)VLAN vector
    709  * Returns:
    710  *      BCM_E_XXX
    711  */
    712 int
    713 bcm_esw_tunnel_terminator_vlan_get(int unit, bcm_gport_t tunnel, 
    714                                bcm_vlan_vector_t *vlan_vec)
    715 {
    716     int rv = BCM_E_UNAVAIL;
    717 
    718     if (soc_feature(unit, soc_feature_no_tunnel)) {
    719         return (BCM_E_UNAVAIL);
    720     }
    721 
    722 #if defined(BCM_TRIUMPH2_SUPPORT) || defined(BCM_TRIUMPH3_SUPPORT)
    723     if (soc_feature(unit, soc_feature_wlan)) {
    724 #if defined(BCM_TRIUMPH3_SUPPORT)
    725         if (SOC_IS_TRIUMPH3(unit)) {
    726             rv = bcm_tr3_wlan_tunnel_terminator_vlan_get(unit, tunnel, vlan_vec);
    727         } else
    728 #endif /* BCM_TRIUMPH3_SUPPORT */
    729         {
    730             rv = bcm_tr2_tunnel_terminator_vlan_get(unit, tunnel, vlan_vec);
    731         }
    732     }
    733 #endif /* BCM_TRIUMPH2_SUPPORT || BCM_TRIUMPH3_SUPPORT */
    734     return rv;
    735 }
    736 
    737 #else /* INCLUDE_L3 */
    738 int _bcm_esw_tunnel_not_empty;
    739 #endif /* INCLUDE_L3 */