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

mpls.h (20084B)


      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-2020 Broadcom Inc. All rights reserved.
      6  *
      7  * This file contains mpls definitions internal to the BCM library.
      8  */
      9 
     10 #ifndef _BCM_INT_MPLS_H
     11 #define _BCM_INT_MPLS_H
     12 
     13 #include <bcm_int/esw/vpn.h>
     14 #include <bcm/mpls.h>
     15 
     16 #define _BCM_TR_MPLS_EXP_MAP_TABLE_TYPE_MASK    0x300
     17 #define _BCM_TR_MPLS_EXP_MAP_TABLE_TYPE_INGRESS 0x100
     18 #define _BCM_TR_MPLS_EXP_MAP_TABLE_TYPE_EGRESS  0x300
     19 #define _BCM_TR_MPLS_EXP_MAP_TABLE_TYPE_EGRESS_L2  0x200
     20 #define _BCM_TR_MPLS_EXP_MAP_TABLE_NUM_MASK     0x0ff
     21 
     22 #define _BCM_MPLS_NUM_MPLS_ENTRIES_PER_INDEX(unit)  \
     23     (((soc_feature(unit, soc_feature_egr_ip_tnl_mpls_double_wide) \
     24     || soc_feature(unit, soc_feature_th3_style_simple_mpls)))? 8 : 4)
     25 
     26 #define _BCM_MPLS_EGR_L3_INTF_MPLS_INDEX_OFFSET_MASK(unit)  \
     27     (((soc_feature(unit, soc_feature_egr_ip_tnl_mpls_double_wide)  \
     28     || soc_feature(unit, soc_feature_th3_style_simple_mpls)))? 0x7 : 0x3)
     29 
     30 /*
     31  * MPLS port state - need to remember where to find the port.
     32  * Flags indicate the type of the port and hence the tables where the data is.
     33  * The match attributes are the keys for the various hash tables.
     34  */
     35 #define _BCM_MPLS_PORT_MATCH_TYPE_NONE         (1 << 0)
     36 #define _BCM_MPLS_PORT_MATCH_TYPE_VLAN   (1 << 1)
     37 #define _BCM_MPLS_PORT_MATCH_TYPE_INNER_VLAN (1 << 2)
     38 #define _BCM_MPLS_PORT_MATCH_TYPE_VLAN_STACKED        (1 << 3)
     39 #define _BCM_MPLS_PORT_MATCH_TYPE_VLAN_PRI  (1 << 4)
     40 #define _BCM_MPLS_PORT_MATCH_TYPE_PORT         (1 << 5)
     41 #define _BCM_MPLS_PORT_MATCH_TYPE_TRUNK       (1 << 6)
     42 #define _BCM_MPLS_PORT_MATCH_TYPE_LABEL        (1 << 7)
     43 #define _BCM_MPLS_PORT_MATCH_TYPE_LABEL_PORT     (1 << 8)
     44 #define _BCM_MPLS_PORT_MATCH_TYPE_PORT_SUBPORT_PKT_VID (1 << 9)
     45 #define _BCM_MPLS_PORT_MATCH_TYPE_PORT_SUBPORT_PKT_VID_INNER_VLAN (1 << 10)
     46 #define _BCM_MPLS_PORT_MATCH_TYPE_PORT_SUBPORT_PKT_VID_OUTER_VLAN (1 << 11)
     47 #define _BCM_MPLS_PORT_MATCH_TYPE_SHARE (1 << 12)
     48 #define _BCM_MPLS_PORT_MATCH_TYPE_VLAN_TAG   (1 << 13)
     49 #define _BCM_MPLS_PORT_MATCH_TYPE_INNER_VLAN_TAG   (1 << 14)
     50 
     51 /*
     52  * MPLS LABEL ACTION - indicate the ACTION associated with the LABEL 
     53  */
     54 
     55 #define _BCM_MPLS_ACTION_NOOP  0x0
     56 #define _BCM_MPLS_ACTION_PUSH  0x1
     57 #define _BCM_MPLS_ACTION_SWAP  0x2
     58 #define _BCM_MPLS_ACTION_RESERVED  0x3
     59 #define _BCM_MPLS_ACTION_PRESERVED 0x3
     60 #define _BCM_MPLS_ACTION_SEQUENCE 0x4
     61 #define _BCM_MPLS_ACTION_MASK (0xFFFF)
     62 #define _BCM_MPLS_ACTION_LABEL_ALLOC_SHIFT (16)
     63 #define _BCM_MPLS_ACTION_LABEL_ALLOC (1 << _BCM_MPLS_ACTION_LABEL_ALLOC_SHIFT)
     64 #define _BCM_MPLS_ACTION_GET(_f) ((_f) & _BCM_MPLS_ACTION_MASK)
     65 
     66 #define _BCM_MPLS_EGRESS_LABEL_PRESERVE(unit, flags) \
     67             (soc_feature(unit, soc_feature_mpls_swap_label_preserve) && \
     68             (flags & BCM_MPLS_EGRESS_LABEL_PRESERVE))
     69 
     70 /*
     71  * MPLS FORWARDING ACTION - indicate the FORWARDING ACTION associated with the LABEL 
     72  */
     73 #define _BCM_MPLS_FORWARD_NEXT_HOP  0x0
     74 #define _BCM_MPLS_FORWARD_ECMP_GROUP  0x1
     75 #define _BCM_MPLS_FORWARD_MULTICAST_GROUP  0x2
     76 
     77 typedef struct _bcm_tr_mpls_match_port_info_s {
     78     uint32     flags;
     79     uint32     index; /* Index of memory where port info is programmed */
     80     bcm_trunk_t trunk_id; /* Trunk group ID */
     81     bcm_module_t modid; /* Module id */
     82     bcm_port_t port; /* Port */
     83     bcm_vlan_t match_vlan;
     84     bcm_vlan_t match_inner_vlan;
     85     bcm_vlan_t match_subport_pkt_vid;
     86     bcm_mpls_label_t match_label; /* MPLS label */
     87     int match_count; /* Number of matches from VLAN_XLATE configured */
     88     bcm_trunk_t fo_trunk_id; /* vp-less failover port Trunk group ID */
     89     bcm_module_t fo_modid; /* vp-less failover port Module id */
     90     bcm_port_t fo_port; /* vp-less failover port, flags and label same as primary*/
     91 } _bcm_tr_mpls_match_port_info_t;
     92 
     93 typedef struct _bcm_mpls_vpws_vp_map_info_s {
     94     int             vp1; /* Access VP */
     95     int             vp2; /* Network VP */
     96     int             vp3; /* Primary Network VP */
     97     int             vp_b_1;
     98     int             vp_b_2;
     99     int             vp_b_3;
    100 } _bcm_mpls_vpws_vp_map_info_t;
    101 
    102 /*
    103  * Software book keeping for MPLS related information
    104  */
    105 typedef struct _bcm_tr_mpls_bookkeeping_s {
    106     int         initialized;        /* Set to TRUE when MPLS module initialized */
    107     SHR_BITDCL  *vrf_bitmap;        /* VRF bitmap */
    108     SHR_BITDCL  *vpws_bitmap;       /* VPWS vpn usage bitmap  */
    109     SHR_BITDCL  *vc_c_bitmap;       /* VC_AND_LABEL index bitmap (1st 4K)*/
    110     SHR_BITDCL  *vc_nc_bitmap;      /* VC_AND_LABEL index bitmap (2nd 4K)*/
    111     SHR_BITDCL  *pw_term_bitmap;    /* ING_PW_TERM_COUNTERS index bitmap */
    112     SHR_BITDCL  *pw_init_bitmap;    /* ING_PW_TERM_COUNTERS index bitmap */
    113     SHR_BITDCL  *tnl_bitmap;        /* EGR_IP_TUNNEL_MPLS index bitmap */
    114     SHR_BITDCL  *ip_tnl_bitmap;     /* EGR_IP_TUNNEL index bitmap */
    115     SHR_BITDCL  *egr_mpls_bitmap;   /* Egress EXP/PRI maps usage bitmap */
    116     uint32      *egr_mpls_hw_idx;   /* Actual profile number used */
    117     SHR_BITDCL  *ing_exp_map_bitmap;/* Ingress EXP map usage bitmap */
    118     SHR_BITDCL  *egr_l2_exp_map_bitmap; /* Egress_L2 EXP map usage bitmap */
    119 #ifdef BCM_APACHE_SUPPORT
    120     SHR_BITDCL  *ing_exp_to_phb_cng_map_bitmap;/* Ingress EXP to PHB and CNG */
    121                                                /* map usage bitmap */
    122     SHR_BITDCL  *egr_exp_to_phb_cng_map_bitmap;/* Egress EXP to PHB and CNG */
    123                                                /* map usage bitmap */
    124 #endif
    125     sal_mutex_t mpls_mutex;	        /* Protection mutex. */
    126     _bcm_tr_mpls_match_port_info_t *match_key; /* Match Key for Dual Hash */
    127     uint16       *vc_swap_ref_count; /* Reference count for VC_AND_SWAP entries */
    128     uint16       *egr_tunnel_ref_count; /* Reference count for EGR_MPLS_TUNNEL entries */
    129     uint16       *ing_qmap_ref_count; /* Reference count for ING_QUEUE_MAP entries */
    130     _bcm_mpls_vpws_vp_map_info_t       *vpws_vp_map; /* VP map for VPWS */
    131     int          *trunk_vp_map;     /* VP map for trunk binding */
    132     SHR_BITDCL  *svp_profile_set_bitmap; /* SOURCE_VP dscp & dot1p prifile set bitmap */
    133     SHR_BITDCL  *network_vp_bitmap; /* Network side VP bitmap */
    134 #if defined(BCM_TRIDENT3_SUPPORT)
    135     int *egr_vc_swap_lbl_action; /*store label actions in TD3 to make it work like TD2+*/
    136 #endif
    137     uint32       *failover_vp; /* failover vp for primary vp */
    138 
    139   /*
    140    * On some chips (e.g., TR3/TD2/TD2+), EGR_DVP_ATTRIBUTE_1 is overlaid on
    141    * EGR_MPLS_VC_AND_SWAP_LABEL_TABLE.
    142    * This is to record the offset of EGR_DVP_ATTRIBUTE_1 table to the start of
    143    * EGR_MPLS_VC_AND_SWAP_LABEL_TABLE.
    144    */
    145     uint32        overlaid_dvp_offset_start;
    146     uint32        overlaid_dvp_offset_end;
    147 } _bcm_tr_mpls_bookkeeping_t;
    148 
    149 extern _bcm_tr_mpls_bookkeeping_t  _bcm_tr_mpls_bk_info[BCM_MAX_NUM_UNITS];
    150 
    151 extern int _bcm_esw_mpls_port_source_vp_lag_set(
    152                                     int unit,
    153                                     bcm_gport_t gport,
    154                                     int vp_lag_vp);
    155 extern int _bcm_esw_mpls_port_source_vp_lag_clear(
    156                                     int unit,
    157                                     bcm_gport_t gport,
    158                                     int vp_lag_vp);
    159 extern int _bcm_esw_mpls_port_source_vp_lag_get(
    160                                     int unit,
    161                                     bcm_gport_t gport,
    162                                     int *vp_lag_vp);
    163 
    164 
    165 #ifdef INCLUDE_L3 
    166 
    167 extern int _bcm_esw_mpls_label_stat_counter_get(int unit, int sync_mode, 
    168                                                 bcm_mpls_label_t label, 
    169                                                 bcm_gport_t port,
    170                                                 bcm_mpls_stat_t stat, 
    171                                                 uint32 num_entries,
    172                                                 uint32 *counter_indexes, 
    173                                               bcm_stat_value_t *counter_values);
    174 #endif /* INCLUDE_L3 */                                              
    175 
    176 /* MPLS VC_AND_SWAP NextHop Indices List.  */
    177 typedef struct _bcm_mpls_vp_nh_list_s {
    178     int  vp_nh_idx;
    179     struct _bcm_mpls_vp_nh_list_s  *link;
    180 }_bcm_mpls_vp_nh_list_t;
    181 
    182 /* MPLS Egress NhopList */
    183 typedef struct _bcm_mpls_egr_nhopList_s {
    184     struct _bcm_mpls_egr_nhopList_s	*link;
    185     bcm_if_t  egr_if;                        /* Egress Object If */
    186     _bcm_mpls_vp_nh_list_t	*vp_head_ptr;
    187 }_bcm_mpls_egr_nhopList_t;
    188 
    189 typedef struct _bcm_mpls_old_nh_info_s {
    190     int old_nh_index;
    191     int old_tpid_idx;
    192     int old_macda_idx;
    193     int old_vc_swap_idx;
    194     bcm_if_t old_tunnel_if;
    195 } _bcm_mpls_old_nh_info_t;
    196 
    197 #ifdef BCM_TRIDENT3_SUPPORT
    198 /*EGR_SEQUENCE_NUMBER_TABLE is shared by IP_TUNNEL,VC_SWAP tables.
    199  *For VC_SWAP table offset starts after IP_TUNNEL range as per cancun register
    200  *EGR_SEQUENCE_NUMBER_CTRL*/
    201 #define EGR_PW_SEQNUM_VCSWAP_OFFSET(_unit) \
    202                     (soc_mem_index_count(unit, EGR_IP_TUNNELm))
    203 #endif
    204 /***************************************************
    205  ***************************************************
    206  ********                                   ********
    207  ******                                       ******
    208  ****    Segment Routing Feature Defines        ****
    209  ******              START                    ******
    210  */
    211 
    212 /*
    213  * The below indexes derive how many free entries
    214  * you want to keep at a give amount of time.
    215  * you may not want to know everything available
    216  * as you may not need all and it is too memmory
    217  * consuming.
    218  * 8 will work well as you need max 8 single entries
    219  * to fill largest entry in current h/w configuration.
    220  */
    221 #define MAX_ENTRY_INDEXES                             8
    222 #define MAX_FREE_ENTRY_INDEXES                        8
    223 
    224 
    225 #define BCMI_EGR_IP_TUNNEL_MPLS_START_OF_ENTRY        (1 << 0)
    226 #define BCMI_EGR_IP_TUNNEL_MPLS_ENTRY_USED            (1 << 1)
    227 #define BCMI_EGR_IP_TUNNEL_MPLS_ENTRY_CHECKED         (1 << 2)
    228 #define BCMI_EGR_IP_TUNNEL_MPLS_ENTRY_ZERO            (1 << 3)
    229 
    230 /* S/w list of all interfaces pointing to mpls tnl */
    231 typedef struct intf_list_s {
    232     bcm_if_t intf_num;
    233     struct intf_list_s *next;
    234 } intf_list_t;
    235 
    236 /* s/w state of each mpls tnl entry */
    237 typedef struct bcmi_egr_tnl_mpls_label_entry_s {
    238     intf_list_t *intf_list; /* associated interface list */
    239     int flags;              /* flags */
    240     int num_elements;       /* Number of elements in this tnl */
    241 } bcmi_egr_ip_tnl_mpls_label_entry_t;
    242 
    243 
    244 typedef struct bcmi_egr_tnl_mpls_tunnel_entry_s {
    245     bcmi_egr_ip_tnl_mpls_label_entry_t **label_entry; /*Label entries in Tunnel */
    246 } bcmi_egr_ip_tnl_mpls_tunnel_entry_t;
    247 
    248 
    249 typedef struct bcmi_egr_ip_tnl_free_indexes_s {
    250     /* free indexes of each entry type */
    251     int free_entry_indexes[MAX_ENTRY_INDEXES][MAX_FREE_ENTRY_INDEXES];
    252     /* count of free indexes of each entry type */
    253     int free_index_count[MAX_ENTRY_INDEXES];
    254 } bcmi_egr_ip_tnl_free_indexes_t;
    255 
    256 /***************************************************
    257  ***************************************************
    258  ********                                   ********
    259  ******                                       ******
    260  ****      Segment Routing Feature Defines      ****
    261  ******               END                     ******
    262  */
    263 
    264 #define _BCM_MPLS_VPN_TYPE_L3           _BCM_VPN_TYPE_L3
    265 #define _BCM_MPLS_VPN_TYPE_VPWS         _BCM_VPN_TYPE_VPWS
    266 #define _BCM_MPLS_VPN_TYPE_VPLS         _BCM_VPN_TYPE_VFI
    267 
    268 #define _BCM_MPLS_VPN_SET(_vpn_, _type_, _id_) \
    269         _BCM_VPN_SET(_vpn_, _type_, _id_)
    270 
    271 #define _BCM_MPLS_VPN_GET(_id_, _type_,  _vpn_) \
    272         _BCM_VPN_GET(_id_, _type_, _vpn_)
    273 
    274 #define _BCM_MPLS_VPN_IS_L3(_vpn_)   _BCM_VPN_IS_L3(_vpn_)
    275 
    276 #define _BCM_MPLS_VPN_IS_VPLS(_vpn_) _BCM_VPN_IS_VPLS(_vpn_)
    277 
    278 #define _BCM_MPLS_VPN_IS_VPWS(_vpn_) _BCM_VPN_IS_VPWS(_vpn_)
    279 
    280 #define _BCM_MPLS_VPN_IS_SET(_vpn_)    \
    281         (_BCM_MPLS_VPN_IS_L3(_vpn_) \
    282         || _BCM_MPLS_VPN_IS_VPLS(_vpn_) \
    283         || _BCM_MPLS_VPN_IS_VPWS(_vpn_))
    284 
    285 #define _BCM_MPLS_GPORT_FAILOVER_VPLESS  (1 << 24)
    286 #define _BCM_MPLS_GPORT_FAILOVER_VPLESS_SET(_gp) ((_gp) | _BCM_MPLS_GPORT_FAILOVER_VPLESS)
    287 #define _BCM_MPLS_GPORT_FAILOVER_VPLESS_GET(_gp) ((_gp) & _BCM_MPLS_GPORT_FAILOVER_VPLESS)
    288 #define _BCM_MPLS_GPORT_FAILOVER_VPLESS_CLEAR(_gp) ((_gp) & (~_BCM_MPLS_GPORT_FAILOVER_VPLESS))
    289 
    290 /* 
    291  * L3_IIF table is used to get the VRF & classid and is 
    292  * carved out as follows:
    293  *      0 - 4095 : 4K entries indexed by VLAN for non-tunnel/non-mpls packets
    294  *   4096 - 4607 : 512 entries directly indexed from L3_TUNNEL
    295  *   4608 - 6655 : 2K entries for MPLS pop & route packet (one for each VRF)
    296  *   6656 - 8191 : unused
    297  */
    298 #define _BCM_TR_MPLS_L3_IIF_BASE        4095
    299 
    300 /*
    301  * Index 63 of the ING_PRI_CNG_MAP table is a special value
    302  * in HW indicating no to trust the packet's 802.1p pri/cfi.
    303  * Here, we use index 62 as an identity mapping
    304  * (pkt_pri => int_pri) and (pkt_cfi => int_color)
    305  */
    306 #define _BCM_TR_MPLS_PRI_CNG_MAP_IDENTITY   62
    307 #define _BCM_TR_MPLS_PRI_CNG_MAP_NONE       63
    308 #define _BCM_TR_MPLS_HASH_ELEMENTS 1024
    309 
    310 #ifndef BCM_SW_STATE_DUMP_DISABLE
    311 extern void _bcm_mpls_sw_dump(int unit);
    312 #endif /* BCM_SW_STATE_DUMP_DISABLE */
    313 
    314 #if defined(BCM_WARM_BOOT_SUPPORT) && defined(INCLUDE_L3)
    315 extern int _bcm_esw_mpls_sync(int unit);
    316 extern int _bcm_esw_mpls_match_key_recover(int unit);
    317 #ifdef INCLUDE_L3
    318 extern int _bcm_esw_mpls_tunnel_switch_traverse_no_lock(int unit,
    319                bcm_mpls_tunnel_switch_traverse_cb cb, void *user_data);
    320 #endif
    321 #endif
    322 
    323 /*
    324  * VRF table usage bitmap operations
    325  */
    326 #define _BCM_MPLS_VRF_USED_GET(_u_, _vrf_) \
    327         SHR_BITGET(MPLS_INFO(_u_)->vrf_bitmap, (_vrf_))
    328 #define _BCM_MPLS_VRF_USED_SET(_u_, _vrf_) \
    329         SHR_BITSET(MPLS_INFO((_u_))->vrf_bitmap, (_vrf_))
    330 #define _BCM_MPLS_VRF_USED_CLR(_u_, _vrf_) \
    331         SHR_BITCLR(MPLS_INFO((_u_))->vrf_bitmap, (_vrf_))
    332 
    333 /*
    334  * VPWS usage bitmap operations (num VPs / 2)
    335  */
    336 #define _BCM_MPLS_VPWS_USED_GET(_u_, _i_) \
    337         SHR_BITGET(MPLS_INFO(_u_)->vpws_bitmap, (_i_))
    338 
    339 #define _BCM_MPLS_VPWS_USED_SET(_u_, _i_) \
    340         SHR_BITSET(MPLS_INFO((_u_))->vpws_bitmap, (_i_))
    341 #define _BCM_MPLS_VPWS_USED_CLR(_u_, _i_) \
    342         SHR_BITCLR(MPLS_INFO((_u_))->vpws_bitmap, (_i_))
    343 
    344 /*
    345  * VC_AND_LABEL (1st 4K - pw_init counters) usage bitmap operations
    346  */
    347 #define _BCM_MPLS_VC_COUNT_USED_GET(_u_, _vc_) \
    348         SHR_BITGET(MPLS_INFO(_u_)->vc_c_bitmap, (_vc_))
    349 #define _BCM_MPLS_VC_COUNT_USED_SET(_u_, _vc_) \
    350         SHR_BITSET(MPLS_INFO((_u_))->vc_c_bitmap, (_vc_))
    351 #define _BCM_MPLS_VC_COUNT_USED_CLR(_u_, _vc_) \
    352         SHR_BITCLR(MPLS_INFO((_u_))->vc_c_bitmap, (_vc_))
    353 
    354 /*
    355  * VC_AND_LABEL (2nd 4K - no counters) usage bitmap operations
    356  */
    357 #define _BCM_MPLS_VC_NON_COUNT_USED_GET(_u_, _vc_) \
    358         SHR_BITGET(MPLS_INFO(_u_)->vc_nc_bitmap, (_vc_))
    359 #define _BCM_MPLS_VC_NON_COUNT_USED_SET(_u_, _vc_) \
    360         SHR_BITSET(MPLS_INFO((_u_))->vc_nc_bitmap, (_vc_))
    361 #define _BCM_MPLS_VC_NON_COUNT_USED_CLR(_u_, _vc_) \
    362         SHR_BITCLR(MPLS_INFO((_u_))->vc_nc_bitmap, (_vc_))
    363 
    364 /*
    365  * "Pseudo-wire termination counters" usage bitmap operations
    366  */
    367 #define _BCM_MPLS_PW_TERM_USED_GET(_u_, _pt_) \
    368         SHR_BITGET(MPLS_INFO(_u_)->pw_term_bitmap, (_pt_))
    369 #define _BCM_MPLS_PW_TERM_USED_SET(_u_, _pt_) \
    370         SHR_BITSET(MPLS_INFO((_u_))->pw_term_bitmap, (_pt_))
    371 #define _BCM_MPLS_PW_TERM_USED_CLR(_u_, _pt_) \
    372         SHR_BITCLR(MPLS_INFO((_u_))->pw_term_bitmap, (_pt_))
    373 
    374 /*
    375  * "Pseudo-wire Initiation counters" usage bitmap operations
    376  */
    377 #define _BCM_MPLS_PW_INIT_USED_GET(_u_, _pt_) \
    378         SHR_BITGET(MPLS_INFO(_u_)->pw_init_bitmap, (_pt_))
    379 #define _BCM_MPLS_PW_INIT_USED_SET(_u_, _pt_) \
    380         SHR_BITSET(MPLS_INFO((_u_))->pw_init_bitmap, (_pt_))
    381 #define _BCM_MPLS_PW_INIT_USED_CLR(_u_, _pt_) \
    382         SHR_BITCLR(MPLS_INFO((_u_))->pw_init_bitmap, (_pt_))
    383 
    384 /*
    385  * EGR_IP_TUNNEL_MPLS table usage bitmap operations
    386  * (there are 4 MPLS entries for each EGR_IP_TUNNEL_MPLS entry)
    387  */
    388 #define _BCM_MPLS_TNL_USED_GET(_u_, _tnl_) \
    389         SHR_BITGET(MPLS_INFO(_u_)->tnl_bitmap, (_tnl_))
    390 #define _BCM_MPLS_TNL_USED_SET(_u_, _tnl_) \
    391         SHR_BITSET(MPLS_INFO((_u_))->tnl_bitmap, (_tnl_))
    392 #define _BCM_MPLS_TNL_USED_CLR(_u_, _tnl_) \
    393         SHR_BITCLR(MPLS_INFO((_u_))->tnl_bitmap, (_tnl_))
    394 #define _BCM_MPLS_TNL_USED_RANGE_GET(_u_, _tnl_, _bit_count_, _result_) \
    395         SHR_BITTEST_RANGE(MPLS_INFO(_u_)->tnl_bitmap, _tnl_, _bit_count_, _result_)
    396 
    397 /*
    398  * EGR_IP_TUNNEL_IP table usage bitmap operations
    399  */
    400 #define _BCM_MPLS_IP_TNL_USED_GET(_u_, _tnl_) \
    401         SHR_BITGET(MPLS_INFO(_u_)->ip_tnl_bitmap, (_tnl_))
    402 #define _BCM_MPLS_IP_TNL_USED_SET(_u_, _tnl_) \
    403         SHR_BITSET(MPLS_INFO((_u_))->ip_tnl_bitmap, (_tnl_))
    404 #define _BCM_MPLS_IP_TNL_USED_CLR(_u_, _tnl_) \
    405         SHR_BITCLR(MPLS_INFO((_u_))->ip_tnl_bitmap, (_tnl_))
    406 /*
    407  * Egress PRI->EXP/DOT1P map usage bitmap operations
    408  */
    409 #define _BCM_EGR_MPLS_MAP_USED_GET(_u_, _map_) \
    410         SHR_BITGET(MPLS_INFO(_u_)->egr_mpls_bitmap, (_map_))
    411 #define _BCM_EGR_MPLS_MAP_USED_SET(_u_, _map_) \
    412         SHR_BITSET(MPLS_INFO((_u_))->egr_mpls_bitmap, (_map_))
    413 #define _BCM_EGR_MPLS_MAP_USED_CLR(_u_, _map_) \
    414         SHR_BITCLR(MPLS_INFO((_u_))->egr_mpls_bitmap, (_map_))
    415 
    416 /*
    417  * Ingress EXP->DOT1P map usage bitmap operations
    418  */
    419 #define _BCM_MPLS_ING_EXP_MAP_USED_GET(_u_, _map_) \
    420         SHR_BITGET(MPLS_INFO(_u_)->ing_exp_map_bitmap, (_map_))
    421 #define _BCM_MPLS_ING_EXP_MAP_USED_SET(_u_, _map_) \
    422         SHR_BITSET(MPLS_INFO((_u_))->ing_exp_map_bitmap, (_map_))
    423 #define _BCM_MPLS_ING_EXP_MAP_USED_CLR(_u_, _map_) \
    424         SHR_BITCLR(MPLS_INFO((_u_))->ing_exp_map_bitmap, (_map_))
    425 /*
    426  * Egress EXP->DOT1P map usage bitmap operations
    427  */
    428 #define _BCM_MPLS_EGR_EXP_MAP_USED_GET(_u_, _map_) \
    429               SHR_BITGET(MPLS_INFO(_u_)->egr_l2_exp_map_bitmap, (_map_))
    430 #define _BCM_MPLS_EGR_EXP_MAP_USED_SET(_u_, _map_) \
    431               SHR_BITSET(MPLS_INFO((_u_))->egr_l2_exp_map_bitmap, (_map_))
    432 #define _BCM_MPLS_EGR_EXP_MAP_USED_CLR(_u_, _map_) \
    433               SHR_BITCLR(MPLS_INFO((_u_))->egr_l2_exp_map_bitmap, (_map_))
    434 #ifdef BCM_APACHE_SUPPORT
    435 /*
    436  *  * Ingress EXP->PBH and CNG map usage bitmap operations
    437  */
    438 #define _BCM_MPLS_ING_EXP_TO_PHB_CNG_MAP_USED_GET(_u_, _map_) \
    439         SHR_BITGET(MPLS_INFO(_u_)->ing_exp_to_phb_cng_map_bitmap, (_map_))
    440 #define _BCM_MPLS_ING_EXP_TO_PHB_CNG_MAP_USED_SET(_u_, _map_) \
    441         SHR_BITSET(MPLS_INFO((_u_))->ing_exp_to_phb_cng_map_bitmap, (_map_))
    442 #define _BCM_MPLS_ING_EXP_TO_PHB_CNG_MAP_USED_CLR(_u_, _map_) \
    443         SHR_BITCLR(MPLS_INFO((_u_))->ing_exp_to_phb_cng_map_bitmap, (_map_))
    444 /*
    445  *  * Egress EXP->PBH and CNG map usage bitmap operations
    446  */
    447 #define _BCM_MPLS_EGR_EXP_TO_PHB_CNG_MAP_USED_GET(_u_, _map_) \
    448               SHR_BITGET(MPLS_INFO(_u_)->egr_exp_to_phb_cng_map_bitmap, (_map_))
    449 #define _BCM_MPLS_EGR_EXP_TO_PHB_CNG_MAP_USED_SET(_u_, _map_) \
    450             SHR_BITSET(MPLS_INFO((_u_))->egr_exp_to_phb_cng_map_bitmap, (_map_))
    451 #define _BCM_MPLS_EGR_EXP_TO_PHB_CNG_MAP_USED_CLR(_u_, _map_) \
    452             SHR_BITCLR(MPLS_INFO((_u_))->egr_exp_to_phb_cng_map_bitmap, (_map_))
    453 #endif
    454 /*
    455  * SVP profile set usage bitmap operations
    456  */
    457 #define _BCM_MPLS_SVP_PROFILE_SET_USED_GET(_u_, _vp_) \
    458         SHR_BITGET(MPLS_INFO(_u_)->svp_profile_set_bitmap, (_vp_))
    459 #define _BCM_MPLS_SVP_PROFILE_SET_USED_SET(_u_, _vp_) \
    460         SHR_BITSET(MPLS_INFO((_u_))->svp_profile_set_bitmap, (_vp_))
    461 #define _BCM_MPLS_SVP_PROFILE_SET_USED_CLR(_u_, _vp_) \
    462         SHR_BITCLR(MPLS_INFO((_u_))->svp_profile_set_bitmap, (_vp_))
    463 
    464 /*
    465  * Network-port VP bitmap operations
    466  */
    467 #define _BCM_MPLS_NETWORK_VP_USED_GET(_u_, _vp_) \
    468         SHR_BITGET(MPLS_INFO(_u_)->network_vp_bitmap, (_vp_))
    469 #define _BCM_MPLS_NETWORK_VP_USED_SET(_u_, _vp_) \
    470         SHR_BITSET(MPLS_INFO((_u_))->network_vp_bitmap, (_vp_))
    471 #define _BCM_MPLS_NETWORK_VP_USED_CLR(_u_, _vp_) \
    472         SHR_BITCLR(MPLS_INFO((_u_))->network_vp_bitmap, (_vp_))
    473 
    474 #define _BCM_MPLS_CLEANUP(_rv_) \
    475        if ( (_rv_) < 0) { \
    476            goto cleanup; \
    477        }
    478 extern int _egr_qos_id2hw_idx (int unit,int qos_id,int *hw_inx);
    479 extern int _egr_qos_hw_idx2id (int unit, int hw_idx, int *map_id);
    480 
    481 #define _BCM_VC_SWAP_TBL_FLEX_DATA_TYPE 5
    482 #endif	/* !_BCM_INT_MPLS_H */