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

firebolt.h (120342B)


      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  * File:        firebolt.h
      8  * Purpose:     Function declarations for Firebolt bcm functions
      9  */
     10 
     11 #ifndef _BCM_INT_FIREBOLT_H_
     12 #define _BCM_INT_FIREBOLT_H_
     13 
     14 #include <bcm_int/esw/mbcm.h>
     15 #include <bcm_int/esw/field.h>
     16 #include <bcm_int/esw/l2.h>
     17 #include <bcm_int/esw/l3.h>
     18 #include <soc/l2u.h>
     19 #include <soc/l3x.h>
     20 #include <shared/l3.h>
     21 
     22 #include <bcm/field.h>
     23 #include <bcm/tunnel.h>
     24 #include <bcm/proxy.h>
     25 
     26 #ifdef INCLUDE_L3
     27 
     28 /* Magic numbers  definition. */
     29 #define BCM_XGS3_L3_IPV6_PREFIX_LEN      (128)
     30 #define BCM_XGS3_L3_IPV4_PREFIX_LEN       (32)
     31 #define BCM_XGS3_BITS_IN_BYTE       (8) /* Number of bits in one byte.      */
     32 #define BCM_XGS3_FULL_BYTE       (0xff) /* All bits set in a byte.          */
     33 
     34 /* Egress idx scale numbers. */
     35 #define BCM_L3_IDX_SCALE_200K       (0x30D40) /* 200K indexes */
     36 #define BCM_L3_IDX_SCALE_100K       (0x186a0) /* 100K indexes */
     37 
     38 /* Reserved trap to cpu nh index.   */
     39 #define BCM_XGS3_L3_L2CPU_NH_IDX(_u_)  \
     40         (_bcm_l3_bk_info[_u_].l3_nh_reserve_for_ecmp ?  \
     41         (BCM_XGS3_L3_ECMP_MAX_GROUPS(_u_) + 1) : (1))
     42 
     43 #define BCM_XGS3_L3_INVALID_INDEX  (-1) /* Generic invalid table index.     */
     44 
     45 /* Egress object start index    */
     46 #define BCM_XGS3_EGRESS_IDX_MIN(unit)   _SHR_L3_EGRESS_IDX_MIN
     47 
     48 #define BCM_XGS3_EGRESS_IDX_SCALE(_u_)  \
     49         (soc_feature(_u_, soc_feature_l3_egress_idx_scale_200K) ?  \
     50         (BCM_L3_IDX_SCALE_200K) : (BCM_L3_IDX_SCALE_100K))
     51 
     52 /* Multipath egress object  */
     53 #define BCM_XGS3_MPATH_EGRESS_IDX_MIN(unit)   \
     54     (BCM_XGS3_EGRESS_IDX_MIN(unit) +  BCM_XGS3_EGRESS_IDX_SCALE(unit))
     55 
     56  /* MPLS interface egress start index */
     57 #define BCM_XGS3_MPLS_IF_EGRESS_IDX_MIN(unit) \
     58     (BCM_XGS3_MPATH_EGRESS_IDX_MIN(unit) +  BCM_XGS3_EGRESS_IDX_SCALE(unit))
     59 
     60 /* DVP Egress object Index range. */
     61 #define BCM_XGS3_DVP_EGRESS_IDX_MIN(unit) \
     62     (BCM_XGS3_MPLS_IF_EGRESS_IDX_MIN(unit) +  BCM_XGS3_EGRESS_IDX_SCALE(unit))
     63 
     64  /* Proxy next hop egress object */
     65 #define BCM_XGS3_PROXY_EGRESS_IDX_MIN(unit) \
     66     (BCM_XGS3_DVP_EGRESS_IDX_MIN(unit) +  BCM_XGS3_EGRESS_IDX_SCALE(unit))
     67 
     68 /* BLACK_HOLE nhop idx */
     69 #define BCM_XGS3_L3_BLACK_HOLE_NH_IDX(_u_)  \
     70         (_bcm_l3_bk_info[_u_].l3_nh_reserve_for_ecmp ?  \
     71         (BCM_XGS3_L3_ECMP_MAX_GROUPS(_u_)) : (0))
     72 
     73 #define BCM_XGS3_L3_ENTRY_IN_DEFIP 0x0
     74 #define BCM_XGS3_L3_ENTRY_IN_DEFIP_PAIR 0x01
     75 
     76 /* Software table width. */
     77 #define _BCM_SINGLE_WIDE    (1)
     78 #define _BCM_DOUBLE_WIDE    (2)
     79 #define _BCM_TRIPLE_WIDE    (3)
     80 #define _BCM_QUAD_WIDE      (4)
     81 
     82  
     83 /* Masks */
     84 #define BCM_XGS3_L3_INVALID_ENT_SZ (0xffff)/* L3 table invalid entry size.  */
     85 #define BCM_XGS3_UINT32_FULL_MASK  (0xffffffff)/* Full uint32 mask.         */
     86 #define BCM_XGS3_L3_IP4_FULL_MASK  BCM_XGS3_UINT32_FULL_MASK/* Full ipv4 mask.*/
     87 
     88 /* Software Tables operations. */
     89 #define  BCM_XGS3_L3_OP_GET                 (1 << 0) /* Table get.   */
     90 #define  BCM_XGS3_L3_OP_ADD                 (1 << 1) /* Table set.   */
     91 #define  BCM_XGS3_L3_OP_DEL                 (1 << 2) /* Table remove.*/
     92 #define  BCM_XGS3_L3_OP_GET_REVERSE         (1 << 3) /* get table from end */
     93 /* L3 module internal flags definition. */
     94 #define  _BCM_L3_SHR_EGRESS_MODE            (1 << 0) /* Egress object enable. */
     95 #define  _BCM_L3_SHR_WITH_ID                (1 << 1) /* Index provided.       */
     96 #define  _BCM_L3_SHR_UPDATE                 (1 << 2) /* Update existing entry.*/
     97 #define  _BCM_L3_SHR_MATCH_DISABLE          (1 << 3) /* Don't try to match an */
     98                                                      /* entry to existing one */ 
     99                                                      /* but create a new .    */ 
    100 #define  _BCM_L3_SHR_SKIP_INDEX_ZERO        (1 << 4) /* Skip entry 0 in a     */
    101                                                      /* table.                */
    102 #define  _BCM_L3_SHR_WRITE_DISABLE          (1 << 5) /* Don't write to HW     */
    103 #define  _BCM_L3_SHR_INGRESS_MODE           (1 << 6) /* Ingress object enable.*/
    104 #define  _BCM_L3_SHR_HOST_ADD_MODE          (1 << 7) /* Enable/Disable return
    105                                                       * value for L3HostAdd.  */
    106 #define  _BCM_L3_SHR_INGRESS_INTF_MAP       (1 << 8) /* Ingress object Mapping  
    107                                                       * to Vlan mode.         */
    108 #define  _BCM_L3_SHR_TABLE_TRAVERSE_CONTROL (1 << 9) /* Manage/control the common 
    109                                                       * table-ops table traversal */
    110 #define  _BCM_L3_SHR_L3_INTF_VLAN_SPLIT_EGRESS (1 << 10) /* Egress objects with the
    111                                                           * same l3a_vid can have 
    112                                                           * different egress 
    113                                                           * properties */
    114 
    115 #define  _BCM_L3_SHR_OVERLAY_OBJECT         (1 << 11) /* L3 object cerated
    116                                                          in overlay domain */
    117 
    118 #define  _BCM_L3_SHR_NO_ECMP_OVERLAP        (1 << 12) /* NHI won't overlap ECMP */
    119 #define  _BCM_L3_SHR_WIDE_FLEX_ENTRY        (1 << 13) /* double-wide flex entry */
    120 #define  _BCM_L3_SHR_CLEAN                  (1 << 14) /* Only clean, do not delete  */
    121 
    122 #ifdef BCM_TRIDENT2_SUPPORT
    123 #define _BCM_L3_IIF_PROFILE_DO_NOT_UPDATE   (1 << 0) /* Do not update L3 IIF
    124                                                       * profile entry        */
    125 #endif /* BCM_TRIDEN2_SUPPORT */
    126 
    127 /* Tunnel initiator entry types. */
    128 #define BCM_XGS3_TUNNEL_INIT_NONE     (0x0)
    129 #define BCM_XGS3_TUNNEL_INIT_V4       (0x1)
    130 #define BCM_XGS3_TUNNEL_INIT_V6       (0x2)
    131 #define BCM_XGS3_TUNNEL_INIT_MPLS     (0x3)
    132 #ifdef BCM_TRIDENT3_SUPPORT
    133 #define BCM_XGS3_TUNNEL_INIT_MPLS_TD3 (0x14)
    134 #define BCM_XGS3_TUNNEL_INIT_V6_TD3   (0x12)
    135 #endif
    136 
    137 /*      
    138  * Universe of flags values shared with include/bcm/l3.h BCM_L3_ECMP_*.
    139  * This flag is used only while creating ecmp RH/DLB/DGM group on
    140  * device which stores RH/DLB/DGM set in member table and reset when done.
    141  * The flag need not be saved and is not used for any state recovery later.
    142  * These are internal flags for now. However, if another group flag with
    143  * these values are defined, these will need to be redefined to another
    144  * unused values
    145  */
    146 #define BCM_L3_ECMP_RH_OPT              0x80000000
    147 #define BCM_L3_ECMP_DLB_OPT             0x40000000
    148 #define BCM_L3_ECMP_DGM_OPT             0x20000000
    149 
    150 /*
    151  * values used to internal L3 flags
    152  */
    153 #define  _BCM_L3_ANY        0
    154 #define  _BCM_L3_VXLAN_ONLY 1 /* corespond with BCM_L3_VXLAN_ONLY*/
    155 #define  _BCM_L3_L2GRE_ONLY 2 /* corespond with BCM_L3_L2GRE_ONLY*/
    156 #define  _BCM_L3_TRILL_ONLY 3 /* corespond with BCM_L3_TRILL_ONLY*/
    157 #define  _BCM_L3_FIELD_ONLY 4 /* corespond with BCM_L3_FLAGS2_FIELD_ONLY*/
    158 #define  _BCM_L3_FLOW_ONLY  5 /* corespond with BCM_L3_FLOW_ONLY*/
    159 #define  _BCM_L3_MPLS_PHP   6 /* corespond with BCM_L3_FLAGS2_MPLS_PHP */
    160 #define  _BCM_L3_FCOE_ONLY  7 /* corespond with BCM_L3_FLAGS2_FCOE_ONLY*/
    161 
    162 /*
    163  * Maximum number of ecmp paths.
    164  * For optimized Resilient Hashing, max paths is max flowset entries
    165  */
    166 #define BCM_XGS3_L3_ECMP_MAX(_u_)   \
    167    ((((SOC_IS_TOMAHAWK3(_u_)) || (SOC_IS_TOMAHAWK2(_u_))) &&       \
    168      soc_feature(_u_, soc_feature_ecmp_resilient_hash_optimized)) ? (32768) : \
    169     (SOC_IS_TOMAHAWK(_u_) &&        \
    170      soc_feature(_u_, soc_feature_ecmp_resilient_hash_optimized)) ? (16384) : \
    171     (SOC_IS_MONTEREY(_u_)) ? (256) : \
    172     (SOC_IS_HURRICANE4(_u_)) ? (64) : \
    173     (soc_feature(_u_, soc_feature_l3_ecmp_1k_groups)) ? (1024) : \
    174     (SOC_IS_TRIDENT(_u_)) ? (256) : \
    175     (SOC_IS_KATANAX(_u_) && soc_feature(_u_, soc_feature_ecmp_1k_paths_4_subgroups)) ? (1024) : \
    176     (SOC_IS_SC_CQ(_u_)) ? (256) : \
    177     ((SOC_IS_GREYHOUND(_u_) || SOC_IS_HURRICANE3(_u_) || SOC_IS_GREYHOUND2(_u_) ||\
    178       SOC_IS_SABER2(_u_))) ? (64) : (32))
    179 
    180 /* For historical reason, the following two MACROs coexist.
    181  * BCM_XGS3_L3_ECMP_MAX_GROUPS, BCM_XGS3_L3_ECMP_MAX_GROUPS_2
    182  * Rules for new chips:
    183  * - Always use BCM_XGS3_L3_ECMP_MAX_GROUPS
    184  * - Keep both updated and equal for new chips.
    185  */
    186 
    187 /* Maximum number of ecmp groups.*/
    188 #define BCM_XGS3_L3_ECMP_MAX_GROUPS(_u_)                  \
    189     ((SOC_IS_HELIX5(_u_)) ? (1024) : \
    190     (SOC_IS_HURRICANE4(_u_)) ? (256) : \
    191     (SOC_IS_TRIDENT2PLUS(_u_) || SOC_IS_TOMAHAWK2(_u_) || \
    192       SOC_IS_TRIDENT3X(_u_)) ? (4096) : \
    193     (SOC_IS_MONTEREY(_u_)) ? (512) : \
    194     ((soc_feature(_u_, soc_feature_l3_ecmp_4k_groups)) ? (4096) : \
    195     ((soc_feature(_u_, soc_feature_l3_ecmp_2k_groups)) ? (2048) : \
    196     (SOC_IS_TRIUMPH3(_u_)                             ||  \
    197     (soc_feature(_u_, soc_feature_l3_ecmp_1k_groups)) ||  \
    198     (BCM_XGS3_L3_MAX_ECMP_MODE(_u_))) ? \
    199     (1024) : \
    200     ((SOC_IS_GREYHOUND(_u_) || SOC_IS_HURRICANE3(_u_) || \
    201     SOC_IS_SABER2(_u_))) ? ((soc_feature(_u_, soc_feature_sb2plus_1k_ecmp_groups)) ? (1024) : (128) ) :\
    202     SOC_IS_FIRELIGHT(_u_) ? (64) : \
    203     (SOC_IS_GREYHOUND2(_u_) ? (256) : (512)))))
    204 
    205 #define BCM_XGS3_L3_ECMP_MAX_GROUPS_2(_u_)                         \
    206     ((SOC_IS_TRIDENT2PLUS(_u_) || SOC_IS_TOMAHAWK2(_u_)) ? (4096) : \
    207     ((SOC_IS_MONTEREY(_u_)) ? (512) : \
    208      (SOC_IS_HURRICANE4(_u_)) ? (256) : \
    209      (soc_feature(_u_, soc_feature_l3_ecmp_4k_groups)) ? (4096) : \
    210      (soc_feature(_u_, soc_feature_l3_ecmp_2k_groups)) ? (2048) : \
    211      (1024)))
    212 
    213 
    214 #define BCM_XGS3_L3_EGRESS_MODE_ISSET(_u_)  \
    215             ((BCM_XGS3_L3_FLAGS(_u_) & _BCM_L3_SHR_EGRESS_MODE))
    216 
    217 #define BCM_XGS3_L3_INGRESS_MODE_ISSET(_u_)  \
    218             ((BCM_XGS3_L3_FLAGS(_u_) & _BCM_L3_SHR_INGRESS_MODE))
    219 
    220 #define BCM_XGS3_L3_INGRESS_INTF_MAP_MODE_ISSET(_u_)  \
    221             ((BCM_XGS3_L3_FLAGS(_u_) & _BCM_L3_SHR_INGRESS_INTF_MAP))
    222 
    223 #define BCM_XGS3_L3_INTF_VLAN_SPLIT_EGRESS_MODE_ISSET(_u_)  \
    224             ((BCM_XGS3_L3_FLAGS(_u_) & _BCM_L3_SHR_L3_INTF_VLAN_SPLIT_EGRESS))
    225 
    226 #define BCM_XGS3_L3_HOST_AS_ROUTE_MODE_ISSET(_u_)  \
    227             ((BCM_XGS3_L3_FLAGS(_u_) & _BCM_L3_SHR_HOST_ADD_MODE))
    228 
    229 #define BCM_XGS3_L3_MPATH_EGRESS_UNSUPPORTED(_u_)                \
    230     ((!BCM_XGS3_L3_INITIALIZED(_u_)) ? (BCM_E_INIT) :            \
    231      (!BCM_XGS3_L3_ECMP_MAX_PATHS(_u_)) ? (BCM_E_UNAVAIL) :      \
    232      (!BCM_XGS3_L3_EGRESS_MODE_ISSET(_u_))? (BCM_E_DISABLED) : BCM_E_NONE)  
    233 
    234 /*
    235  * Supplied as opaque data to del by interface routines
    236  */
    237 typedef struct _bcm_if_del_pattern_s {
    238     
    239     bcm_if_t l3_intf;   /* Interface index.                         */
    240     int negate;         /* 0 means match pattern; 1 means not match */
    241 } _bcm_if_del_pattern_t;
    242 
    243 /*
    244  * Supplied as opaque data to table walk routines.
    245  */
    246 typedef struct _bcm_trvs_range_s {
    247     int current_count; /* Current entry index. */
    248     int start;         /* Start index to read. */
    249     int end;           /* Last index to read.  */
    250 } _bcm_trvs_range_t;
    251 
    252 /* General comparison/action  routine. */
    253                                 /*unit, pattern,  data1, data2  cmp_result*/
    254 typedef int (*bcm_xgs3_ent_op_cb)(int,   void *,  void*,  void*,  int *);
    255 
    256 /*
    257  * Supplied as opaque data to show/update/delete 
    258  * matching a certain rule routines. 
    259  */
    260 typedef struct _bcm_l3_trvrs_data_s { 
    261      int flags;                          /* Entry flags to match.         */
    262      void *pattern;                      /* Test pattern to match.        */
    263      bcm_xgs3_ent_op_cb cmp_cb;          /* Test match routine.           */
    264      bcm_xgs3_ent_op_cb op_cb;           /* Delete operation routine.     */
    265      bcm_l3_route_traverse_cb defip_cb;  /* Caller notification callback. */
    266      bcm_l3_egress_traverse_cb egress_cb;/* Caller notification callback. */
    267      bcm_l3_ingress_traverse_cb ingress_cb; /* Caller notification callback. */
    268      void *cookie;                       /* User cookie to pass back incb.*/
    269 } _bcm_l3_trvrs_data_t;
    270 
    271 /* Tunnel initiator data. */ 
    272 typedef struct _bcm_tnl_init_data_s {
    273      int tnl_idx;            /* Tunnel initiator entry index in hw. */
    274 }_bcm_tnl_init_data_t;
    275 
    276 /* Tunnel terminator type encoding. */
    277 typedef struct _bcm_tnl_term_type_s {
    278     int tnl_auto;                  /* Tunnel terminator type AUTO/CONFIG. */
    279     int tnl_sub_type;              /* Tunnel terminator sutbype.          */
    280     int tnl_udp;                   /* UDP tunnel flag.                    */
    281     int tnl_udp_type;              /* UDP type - for CAPWAP and AMT       */
    282     int tnl_pim_sm;                /* PIM_SM tunnel flag.                 */
    283     int tnl_gre;                   /* GRE tunnel flag.                    */
    284     int tnl_gre_v4_payload;        /* GRE IPv4 payload allowed.           */
    285     int tnl_gre_v6_payload;        /* GRE IPv4 payload allowed.           */
    286     int tnl_outer_hdr_ipv6;        /* Tunnel outer header is IPv6.        */
    287     int tnl_protocol;              /* Tunnel outer IP header protocol     */
    288 }_bcm_tnl_term_type_t;
    289 
    290 /* Ingress interface descriptor. */
    291 typedef struct _bcm_l3_ingress_intf_s {
    292     int intf_id;                   /* Interface id.         */
    293     uint32 flags;                  /* Inteface flags.       */
    294     int vrf;                       /* Virtual router id.    */
    295     bcm_l3_ingress_urpf_mode_t urpf_mode;      /* urpf mode */
    296     int if_class;                  /* Interface class id.   */
    297     int qos_map_id;           /* Qos_map identifier */
    298     bcm_vlan_t  ipmc_intf_id; /* IPMC L2 distribution Vlan */
    299     uint32 profile_flags;          /* IIF profile flags.       */
    300     int ip4_options_profile_id; /* IP options Profile */
    301     int nat_realm_id;       /* Realm id to detect if nat needs to be done */
    302     int tunnel_term_ecn_map_id;              /* tunnel termination ecn map id*/
    303 } _bcm_l3_ingress_intf_t;
    304 
    305 /* Generic l3 table extension structure. */
    306 typedef struct _bcm_l3_tbl_ext_s {
    307     uint32 ref_count;         /* Entry reference count.   */
    308     uint16 data_hash;         /* Table key hash.          */
    309     uint8  l3_flag;           /* l3 flag: 0-any; 1-vxlan;2-l2gre;3-trill.    */
    310 } _bcm_l3_tbl_ext_t;
    311 
    312 /* Generic l3 table structure. */
    313 typedef struct _bcm_l3_tbl_s {
    314     int idx_min;                     /* First table index.     */
    315     int idx_max;                     /* Last table index.      */
    316     int idx_maxused;                 /* Maximum used index.    */ 
    317 #if defined(BCM_RIOT_SUPPORT) || defined(BCM_MULTI_LEVEL_ECMP_SUPPORT)
    318     int split_idx;
    319     int split_maxused;
    320 #endif
    321     _bcm_l3_tbl_ext_t *ext_arr;      /* Entries extended info. */
    322 } _bcm_l3_tbl_t;
    323 
    324 /* Generic l3 table insertion/delete/update structure. */
    325 typedef struct _bcm_l3_tbl_op_s {
    326     _bcm_l3_tbl_t *tbl_ptr;  /* Software table pointer.                  */
    327     uint32 oper_flags;       /* Operation flags. (Add/Replce) etc.       */
    328     int  width;             /* Number of entries required for one record*/ 
    329     int  entry_index;        /* Entry table index.                       */
    330     void *entry_buffer;      /* Table entry data.                        */
    331     void    *info;          /* Parameter to be passed */
    332                              /* Entry hash calculation routine.          */
    333     int (*hash_func) (int, void *, uint16 *); 
    334                              /* Entry comparison routine.                */
    335     int (*cmp_func) (int, void *, int, int *);
    336                              /* Entry addtion routine.                   */
    337     int (*add_func) (int, int, void *, void *);
    338                              /* Entry deletion routine.                  */
    339     int (*delete_func) (int, int, void *);
    340 } _bcm_l3_tbl_op_t;
    341 
    342 
    343 /*
    344  * Ecmp configuration info.
    345  */
    346 typedef struct _bcm_l3_ecmp_info_s {
    347     int ecmp_max_paths;         /* Maximum number of ECMP paths. */
    348     int ecmp_inuse;             /* No changes to ecmp_max_paths. */
    349     int *ecmp_flags;            /* ECMP group flags for max groups of all devices. */
    350 #ifdef BCM_TOMAHAWK_SUPPORT
    351     uint32 ecmp_mode;
    352     int ecmp_rh_max_paths;         /* Maximum number of Resilient Hashing ECMP paths. */
    353 #endif /* BCM_TOMAHAWK_SUPPORT */
    354 #if defined(BCM_TOMAHAWK2_SUPPORT) || defined(BCM_TRIDENT3_SUPPORT)
    355     int ecmp_dlb_max_paths;     /* Maximum number of DLB ECMP paths. */
    356 #endif /* BCM_TOMAHAWK2_SUPPORT || BCM_TRIDENT3_SUPPORT */
    357 } _bcm_l3_ecmp_info_t;
    358 
    359 #if defined(BCM_MIRAGE_SUPPORT)
    360 #define BCM_MIRAGE_L3_PORT             (0x1f)
    361 #endif /* BCM_MIRAGE_SUPPORT */
    362 
    363 #if defined(BCM_RAPTOR_SUPPORT) || defined(BCM_MIRAGE_SUPPORT) || \
    364     defined(BCM_HAWKEYE_SUPPORT)
    365 
    366 #define BCM_XGS3_L3_RP_MAX_PREFIXES(_unit_) \
    367            (soc_feature((_unit_), soc_feature_fp_routing_mirage) ? (126) : \
    368            (soc_feature((_unit_), soc_feature_fp_routing_hk) ? (14) : (254)))
    369 
    370 #define BCM_XGS3_V4_IN_V6_OFFSET          (12)
    371 #define BCM_XGS3_L3_ENT_VALID         (1 << 0)
    372 
    373 /* 
    374  * Raptor host/routes entry information. 
    375  */
    376 typedef struct _bcm_rp_l3_entry_s {
    377     bcm_field_entry_t rule_hdlr; /* Hw FP entry handler.*/
    378     int prefixlen;               /* Prefix length.      */
    379     union {
    380         bcm_ip_t ip4;            /* IPv6 address.       */
    381         bcm_ip6_t ip6;           /* IPv4 address.       */
    382     }addr;
    383     int nh_idx;                  /* Next hop index.     */
    384     int flags;                   /* Entry flags.        */
    385 } _bcm_rp_l3_entry_t;
    386 
    387 /* 
    388  * FP groups handlers & info.  
    389  */  
    390 typedef struct _bcm_rp_l3_fp_group_s {
    391     bcm_field_group_t grp_hdlr;  /* Hw FP group handler.             */
    392     int max_prefix_len_idx;      /* Max prefix length rule index.    */
    393     int min_prefix_len_idx;      /* Min prefix length rule index.    */
    394     int rule_count;              /* Number of active rules in group. */ 
    395 } _bcm_rp_l3_fp_group_t;
    396 
    397 /* 
    398  * Raptor L3 table for hosts & routes
    399  */
    400 typedef struct _bcm_rp_l3_data_s {
    401     _bcm_rp_l3_fp_group_t *l3_grp;   /* Hw FP group handlers.           */
    402     _bcm_rp_l3_entry_t *l3_arr;      /* Hosts/Routes array.             */
    403     int route_maxused_rule_id;       /* Maximum rule id for routes.     */
    404     int host_minused_rule_id;        /* Minimum rule id for hosts.      */
    405     int rules_per_group;             /* Number of rules per group.      */
    406     int l3_group_num;                /* Number of FP groups used for l3.*/
    407 } _bcm_rp_l3_data_t;
    408 #endif /* BCM_RAPTOR_SUPPORT || BCM_MIRAGE_SUPPORT || BCM_HAWKEYE_SUPPORT */
    409 
    410 /* 
    411  *  Hw operation calls;
    412  */
    413 typedef struct _bcm_l3_hw_calls_s {
    414 
    415     /*
    416      *  Interface calls. 
    417      */
    418     /* Flush all the tables routine. */
    419     int (*l3_clear_all)(int unit);
    420     /* Interface info get routine. */
    421     int (*if_get) (int unit, _bcm_l3_intf_cfg_t *intf_info);
    422     /* Interface add routine. */
    423     int (*if_add) (int unit, _bcm_l3_intf_cfg_t *intf_info);
    424     /* Interface delete routine. */
    425     int (*if_del) (int unit, int ifindex);
    426     /* Get vrf info for interface. */
    427     int (*if_vrf_get)(int unit, _bcm_l3_intf_cfg_t *intf_info);
    428     /* Bind interface to vrf. */
    429     int (*if_vrf_bind)(int unit, _bcm_l3_intf_cfg_t *intf_info);
    430     /* Unbind interface from vrf. */
    431     int (*if_vrf_unbind)(int unit, _bcm_l3_intf_cfg_t *intf_info);
    432     /* Set interface classification group. */
    433     int (*if_group_set)(int unit, _bcm_l3_intf_cfg_t *intf_info);
    434     /* Get interface classification group. */
    435     int (*if_group_get)(int unit, _bcm_l3_intf_cfg_t *intf_info);
    436     /* Get interface as tunnel initiator info. */
    437     int (*if_tnl_init_get)(int unit, int ifindex, 
    438                            _bcm_tnl_init_data_t *tnl_info);
    439     /* Set interface as tunnel initiator. */
    440     int (*if_tnl_init_set)(int unit, int ifindex, 
    441                            _bcm_tnl_init_data_t *tnl_info);
    442     /* Unset interface as tunnel initiator. */
    443     int(*if_tnl_init_reset)(int unit, int ifindex);
    444 
    445     /*
    446      *  Next hop calls. 
    447      */
    448     /* Get next hop entry. */
    449     int (*nh_get)(int unit, int idx,  bcm_l3_egress_t  *nh_entry);
    450     /* Add next hop entry. */
    451     int (*nh_add)(int unit, int idx, void *nh_entry, void *info);
    452     /* Delete next hop entry. */
    453     int (*nh_del)(int unit, int idx, void *info);
    454     /* Next hop traverse routine. */ 
    455     int (*nh_update_match)(int unit, _bcm_l3_trvrs_data_t *trv_data);
    456 
    457 
    458     /* 
    459      * Ecmp group handling. 
    460      */
    461     /* Get ecmp group members. */
    462     int (*ecmp_grp_get)(int unit, int ecmp_idx, int ecmp_count, int *nh_idx);
    463     /* Add ecmp group. */
    464     int (*ecmp_grp_add)(int unit, int ecmp_grp, void *buf, void *info);
    465     /* Delete ecmp group. */
    466     int (*ecmp_grp_del)(int unit, int ecmp_grp, void *info);
    467 
    468     /* 
    469      *  L3 entry calls. 
    470      */
    471     /* Get l3 entry. */ 
    472     int (*l3_get)(int unit, _bcm_l3_cfg_t *l3cfg, int *nh_idx);
    473     /* Add l3 entry. */ 
    474     int (*l3_add)(int unit, _bcm_l3_cfg_t *l3cfg, int nh_idx);
    475     /* Del l3 entry. */ 
    476     int (*l3_del)(int unit, _bcm_l3_cfg_t *l3cfg);
    477     /* Get l3 entry by index. */
    478     int (*l3_get_by_idx)(int unit,  void *dma_ptr, int idx, 
    479                          _bcm_l3_cfg_t *l3cfg, int *nh_idx);
    480     /* Get l3 entry bucket start index*/ 
    481     int (*l3_bucket_get)(int unit,_bcm_l3_cfg_t *l3cfg, 
    482                          int *idx_primary, int *idx_secondary);
    483     int (*l3_traverse) (int unit, int flags, uint32 start, uint32 end,
    484                           bcm_l3_host_traverse_cb cb, void *user_data);
    485     int (*l3_del_match) (int unit, int flags, void *pattern,
    486                          bcm_xgs3_ent_op_cb cmp_func,
    487                          bcm_l3_host_traverse_cb notify_cb, void *user_data);
    488 
    489     /*
    490      *  Multicast calls. 
    491      */
    492     /* Read mcast entry. */
    493     int (*ipmc_get)(int unit, _bcm_l3_cfg_t *l3cfg);
    494     /* Add mcast entry. */
    495     int (*ipmc_add)(int unit, _bcm_l3_cfg_t *l3cfg);
    496     /* Delete mcast entry. */
    497     int (*ipmc_del)(int unit, _bcm_l3_cfg_t *l3cfg);
    498     /* Get l3 mcast entry by index. */
    499     int (*ipmc_get_by_idx)(int unit, void *dma_ptr, 
    500                            int idx, _bcm_l3_cfg_t *l3cfg);
    501     /* 
    502      *  LPM calls. 
    503      */
    504     /*  Get route entry. */  
    505     int (*lpm_get)(int unit, _bcm_defip_cfg_t *lpm_cfg, int *nh_ecmp_idx);
    506     /*  Add route entry. */  
    507     int (*lpm_add)(int unit, _bcm_defip_cfg_t *lpm_cfg, int nh_ecmp_idx);
    508     /*  Delete route entry. */  
    509     int (*lpm_del)(int unit, _bcm_defip_cfg_t *lpm_cfg);
    510     /*  Generic travers all entries call. */
    511     int (*lpm_update_match)(int unit, _bcm_l3_trvrs_data_t *trv_data);
    512 
    513     /* 
    514      *  Ingress interface calls.
    515      */
    516     /* Get ingress interface entry. */
    517     int (*ing_intf_get)(int unit, iif_entry_t *iif_hw_entry,
    518             _bcm_l3_ingress_intf_t *iif);
    519 
    520     /* Add ingress interface entry. */
    521     int (*ing_intf_add)(int unit, _bcm_l3_ingress_intf_t *iif,
    522             iif_entry_t *iif_hw_entry, iif_entry_t *new_entry);
    523 
    524     /* Delete ingress interface entry. */
    525     int (*ing_intf_del)(int unit, int intf_id);
    526 
    527     /* Ingress interface traverse routine. */ 
    528     int (*ing_intf_update_match)(int unit, _bcm_l3_trvrs_data_t *trv_data);
    529 
    530 
    531     /* 
    532      *  Tunnel terminator calls.
    533      */
    534     /* Get tunnel terminator entry. */
    535     int (*tnl_term_get)(int unit, bcm_tunnel_terminator_t *info);
    536 
    537     /* Add tunnel terminator entry. */
    538     int (*tnl_term_add)(int unit, bcm_tunnel_terminator_t *info);
    539 
    540     /* Delete tunnel terminator entry. */
    541     int (*tnl_term_del)(int unit, bcm_tunnel_terminator_t *info);
    542 
    543     /* Traverse tunnel terminator entries. */
    544     int (*tnl_term_traverse)(int unit, 
    545                              bcm_tunnel_terminator_traverse_cb cb,
    546                              void *user_data);
    547 
    548     /* 
    549      *  Tunnel initiator calls.
    550      */
    551     /* Get tunnel initiator entry. */
    552     int (*tnl_init_get)(int unit, int idx, bcm_tunnel_initiator_t *tnl_info);
    553     /* Add tunnel initiator entry. */
    554     int (*tnl_init_add)(int unit, int idx, void *buf, void *info);
    555     /* Delete tunnel initiator entry. */
    556     int (*tnl_init_del)(int unit, int idx, void *info);
    557 
    558     /* 
    559      *  Tunnel dscp calls.
    560      */
    561     /* Get tunnel dscp entry. */
    562     int (*tnl_dscp_get)(int unit, int id, bcm_tunnel_dscp_map_t *tnl_info);
    563     /* Add tunnel dscp entry. */
    564     int (*tnl_dscp_set)(int unit, int id, void *buf);
    565 
    566     /*
    567      *  Proxy Next hop calls. 
    568      */
    569     /* Get Proxy next hop entry. */
    570     int (*proxy_nh_get)(int unit, int idx,  bcm_proxy_egress_t  *nh_entry);
    571     /* Add Proxy next hop entry. */
    572     int (*proxy_nh_add)(int unit, int idx, void *nh_entry, void *info);
    573 } _bcm_l3_hw_calls_t;
    574 
    575 /* Table propertires & entry sizes.  */
    576 typedef struct _bcm_l3_table_prop_s {
    577     soc_mem_t  tbl_mem;          /* Table memory location. */
    578     uint16     tbl_entry_sz;     /* Table entry size.      */
    579     void       *tbl_mem_fields;  /* Table memory fields.   */ 
    580 } _bcm_l3_table_prop_t;
    581 
    582 /* Intra chip common fields. */
    583 
    584 /* L3 interface memory fields. */
    585 typedef struct _bcm_l3_intf_fields_s {
    586     soc_field_t vlan_id;         /* Vlan id field.                */
    587     soc_field_t mac_addr;        /* Physical address field.       */ 
    588     soc_field_t ttl;             /* Time To Live threshold field. */
    589     soc_field_t tnl_id;          /* Tunnel initiator id field.    */
    590     soc_field_t l2_switch;       /* L2 switch interface field.    */
    591 #if defined(BCM_TRIUMPH3_SUPPORT) || defined(BCM_KATANA2_SUPPORT)
    592     soc_field_t class_id;        /* Class id                      */
    593 #endif /* BCM_TRIUMPH3_SUPPORT || BCM_KATANA2_SUPPORT*/
    594 }_bcm_l3_intf_fields_t;
    595 
    596 /* Next hop table fields. */
    597 typedef struct _bcm_l3_nh_fields_s {
    598     soc_field_t mac_addr;        /* Physical address field.       */
    599     soc_field_t ifindex;         /* Interface index field.        */
    600     soc_field_t module;          /* Module id field.              */
    601     soc_field_t port_tgid;       /* Port/trung id field.          */
    602 #ifdef BCM_TRIDENT3_SUPPORT
    603     soc_field_t dest;            /* Destination field.            */
    604 #endif
    605 }_bcm_l3_nh_fields_t;
    606 
    607 /* l3 table fields. */
    608 typedef struct _bcm_l3_fields_s {
    609     soc_field_t vrf;             /* Virtual router id field.       */
    610     soc_field_t hit;             /* Entry used field.              */
    611     soc_field_t rpe;             /* Priority override field.       */
    612     soc_field_t dst_discard;     /* Destination discard field.     */
    613     soc_field_t nh_idx;          /* Next hop index field.          */
    614     soc_field_t priority;        /* Priority field.                */
    615     soc_field_t valid;           /* Valid entry field.             */
    616     soc_field_t l3mc_index;      /* ????  field.                   */
    617     soc_field_t vlan_id;         /* Vlan id field.                 */
    618 #ifdef BCM_FIREBOLT_SUPPORT
    619     soc_field_t v6_entry;        /* IPv6 field.                    */
    620     soc_field_t ipmc_entry;      /* IPMC field.                    */
    621 #endif /* BCM_FIREBOLT_SUPPORT */
    622 #ifdef BCM_TRX_SUPPORT
    623     soc_field_t class_id;         /* Class id field.               */
    624 #endif /* BCM_TRX_SUPPORT */
    625 #ifdef BCM_TRIUMPH3_SUPPORT
    626     soc_field_t l3_intf;         /* L3 interface for embedded NHs */
    627     soc_field_t mac_addr;        /* MAC addr for embedded NHs     */
    628     soc_field_t ip4;             /* IPv4 address */
    629     soc_field_t key_type;        /* Entry key type */
    630     soc_field_t l3_oif;          /* Outgoing intf  */
    631     soc_field_t glp;             /* Global logical port */
    632     soc_field_t local_addr;      /* Pkts destined for local IP stack */
    633     soc_field_t bfd_enable;      /* BFD enable */
    634 #endif /* BCM_TRIUMPH3_SUPPORT */
    635 #ifdef BCM_TOMAHAWK_SUPPORT
    636     soc_field_t macda_low;       /* Lower 24 bits of MACDA */
    637     soc_field_t dst_vif;         /* VNTAG dst_vif/ETAG vid */
    638     soc_field_t oui_profile_id;  /* Idx into MAC_DA_OUI_PROFILE table */
    639     soc_field_t vntag_etag_profile_id; /* Idx into VNTAG_ETAG_PROFILE table */
    640 #endif
    641 #ifdef BCM_TRIDENT2_SUPPORT
    642     soc_field_t eh_tag_type;     /* EH queue tag assignment */    
    643     soc_field_t eh_queue_tag;    /* EH queue tag */
    644     soc_field_t copy_to_cpu;     /* Copy to cpu bit for embedded NHs */
    645 #endif /*BCM_TRIDENT2_SUPPORT*/
    646 #if defined(BCM_TRIDENT3_SUPPORT) || defined(BCM_TOMAHAWK3_SUPPORT)
    647     soc_field_t dest;         /* DESTINATION field */
    648     soc_field_t base_valid0;  /* base valid0 */
    649     soc_field_t base_valid1;  /* base valid1 */
    650 #endif
    651 #ifdef BCM_TRIDENT2PLUS_SUPPORT
    652     soc_field_t dest_type;        /* Destination type field */
    653     soc_field_t destination;      /* Destination field */
    654     soc_field_t macda_lsb;        /* Lower 24 bits of MACDA */
    655     soc_field_t oui_profile_index;/* Idx into MACDA_OUI_PROFILE table */
    656     soc_field_t oui_profile_valid;/* Indicates that the OUI bits of MACDA are profiled */
    657 #endif /*BCM_TRIDENT2PLUS_SUPPORT*/
    658 #ifdef BCM_MONTEREY_SUPPORT
    659     soc_field_t roe_decap;        /* ROE Tunnel Decap Control field */
    660 #endif
    661 }_bcm_l3_fields_t;
    662 
    663 /* L3 chip operation structure. */
    664 typedef struct _bcm_l3_hw_op_table_s {
    665     _bcm_l3_table_prop_t l3_intf;       /* L3 Interface memory.            */
    666     _bcm_l3_table_prop_t l3_ing_intf;   /* L3 Ingress Interface memory.    */
    667     _bcm_l3_table_prop_t l3_nh;         /* L3 Next hop table memory.       */
    668     _bcm_l3_table_prop_t l3_v4;         /* L3 v4 table memory.             */
    669     _bcm_l3_table_prop_t l3_v6;         /* L3 v6 table memory.             */
    670 #ifdef BCM_TRIUMPH3_SUPPORT
    671     _bcm_l3_table_prop_t l3_v4_2;       /* Double wide L3 ISM v4 table memory. */
    672     _bcm_l3_table_prop_t l3_v6_4;       /* Quad wide L3 ISM v6 table memory.   */
    673     _bcm_l3_table_prop_t l3_v4_esm;     /* L3 ESM v4 table memory.             */
    674     _bcm_l3_table_prop_t l3_v4_esm_wide;/* Wide L3 ESM v4 table memory.        */
    675     _bcm_l3_table_prop_t l3_v6_esm;     /* L3 ESM v6 table memory.             */
    676     _bcm_l3_table_prop_t l3_v6_esm_wide;/* Wide L3 ESM v6 table memory         */
    677 #endif
    678     _bcm_l3_table_prop_t l3_ipmc_v4;    /* L3 v4 ipmc table memory.        */
    679     _bcm_l3_table_prop_t l3_ipmc_v6;    /* L3 v6 ipmc table memory.        */
    680     _bcm_l3_table_prop_t l3_defip;      /* L3 route table memory.          */
    681     _bcm_l3_table_prop_t l3_tnl_init_v4;/* Tunnel initiator v4 tbl memory. */
    682     _bcm_l3_table_prop_t l3_tnl_init_v6;/* Tunnel initiator v6 tbl memory. */
    683     _bcm_l3_table_prop_t l3_tnl_init_mpls;/* Tunnel initiator mpls tbl memory. */
    684     _bcm_l3_table_prop_t l3_tnl_term;   /* Tunnel terminator tbl memory.   */
    685     _bcm_l3_table_prop_t l3_tnl_dscp;   /* Tunnel DSCP tbl memory.         */
    686     _bcm_l3_table_prop_t l3_ecmp;       /* ECMP table memory.              */
    687     _bcm_l3_table_prop_t l3_v6_prefix_map;/* IPv6 prefix map memory.       */
    688     _bcm_l3_hw_calls_t *hw_call;        /* Chip programming routines set.  */ 
    689 } _bcm_l3_hw_op_table_t;
    690 
    691 
    692 /* L3 software tables. */
    693 typedef struct _bcm_l3_module_data_s {
    694     uint32                   l3_op_flags;   /* Unit operation flags.     */ 
    695     _bcm_l3_hw_op_table_t    l3_hw_op;      /* HW operation table.       */
    696     _bcm_l3_ecmp_info_t      l3_ecmp_info;  /* Ecmp groups size info.    */
    697     _bcm_l3_tbl_t            l3_next_hop;   /* Next hop table.           */
    698     _bcm_l3_tbl_t            l3_ecmp_grp;   /* Ecmp groups table.        */
    699 #if defined(BCM_TOMAHAWK3_SUPPORT)
    700     _bcm_l3_tbl_t            l3_hecmp_grp; /*Hierarchical ECMP grp table.*/
    701 #endif /* BCM_TOMAHAWK3_SUPPORT */
    702     _bcm_l3_tbl_t            l3_ecmp;       /* Ecmp entry table          */
    703     _bcm_l3_tbl_t            l3_tnl_init;   /* Tunnel initiator table.   */
    704     _bcm_l3_tbl_t            l3_ing_intf;   /* L3 IIF Table   */
    705     _bcm_l3_tbl_t            l3_intf;       /* L3 EGR INTF Table         */
    706 #if defined(BCM_RAPTOR_SUPPORT) || defined(BCM_MIRAGE_SUPPORT) || \
    707     defined(BCM_HAWKEYE_SUPPORT)
    708     _bcm_rp_l3_data_t        l3_rp_prefix;   /* Raptor prefixes table.    */  
    709 #endif /* BCM_RAPTOR_SUPPORT || BCM_MIRAGE_SUPPORT || BCM_HAWKEYE_SUPPORT */
    710 #ifdef BCM_TRIUMPH2_SUPPORT
    711     /* Max paths per ECMP groups (to support variable size ECMP 
    712      * groups and 1K ECMP groups) */
    713     uint16                   *l3_ecmp_maxpaths_pergroup;
    714 #endif /* BCM_TRIUMPH2_SUPPORT */
    715     SHR_BITDCL               *l3_intf_used_nh; /* Set if L3 interface was
    716                                                 * ever set in Next Hop
    717                                                 * table */
    718 #if defined(BCM_TOMAHAWK2_SUPPORT) || defined(BCM_TRIDENT3_SUPPORT)
    719     uint16                   *l3_ecmp_alternate_cnt;
    720 #endif /* BCM_TOMAHAWK2_SUPPORT */
    721 #if defined(BCM_TOMAHAWK2_SUPPORT) || defined(BCM_TRIDENT3_SUPPORT)
    722     SHR_BITDCL               *l3_ecmp_dlb_member_bitmap;
    723 #endif /* BCM_TOMAHAWK2_SUPPORT  || BCM_TRIDENT3_SUPPORT*/
    724 #ifdef BCM_TRIDENT2_SUPPORT
    725     SHR_BITDCL               *nh_realm_id_bitmap;   /* NAT realm ID explicitly
    726                                                        specified or not. */
    727  #endif /* BCM_TRIDENT2_SUPPORT */
    728 } _bcm_l3_module_data_t;
    729 
    730 extern _bcm_l3_module_data_t *l3_module_data[BCM_MAX_NUM_UNITS];
    731 
    732 /* Macros. */
    733 /* Software table access macros. */ 
    734 #define BCM_XGS3_L3_TBL(_u_, _var_)      (l3_module_data[_u_]->l3_ ## _var_)
    735 #define BCM_XGS3_L3_TBL_PTR(_u_, _var_)  (&(BCM_XGS3_L3_TBL(_u_, _var_)))
    736 
    737 #define BCM_XGS3_L3_IF_IDX_MIN(_u_) (BCM_XGS3_L3_TBL_PTR(_u_, intf)->idx_min) /* idx starting Id */
    738 #define BCM_XGS3_L3_IF_IDX_MAX(_u_) (BCM_XGS3_L3_TBL_PTR(_u_, intf)->idx_max) /* idx ending Id */
    739 /* maximum allowable intf number to use */
    740 #define BCM_XGS3_L3_IF_MAX_COUNT(_u_) (BCM_XGS3_L3_IF_IDX_MAX(_u_) - BCM_XGS3_L3_IF_IDX_MIN(_u_) + 1) 
    741 
    742 /* L3 module operational flags. */
    743 #define BCM_XGS3_L3_FLAGS(_u_)           (l3_module_data[_u_]->l3_op_flags)
    744 
    745 #ifdef BCM_TRIUMPH2_SUPPORT
    746 #define BCM_XGS3_L3_MAX_PATHS_PERGROUP_PTR(_u_) \
    747         (l3_module_data[_u_]->l3_ecmp_maxpaths_pergroup)
    748 #endif /* BCM_TRIUMPH2_SUPPORT */
    749 
    750 #if defined(BCM_TOMAHAWK2_SUPPORT) || defined(BCM_TRIDENT3_SUPPORT)
    751 #define BCM_XGS3_L3_ALTERNATE_CNT_PTR(_u_) \
    752         (l3_module_data[_u_]->l3_ecmp_alternate_cnt)
    753 #endif /* BCM_TOMAHAWK2_SUPPORT */
    754 #if defined(BCM_TOMAHAWK2_SUPPORT) || defined(BCM_TRIDENT3_SUPPORT)
    755 #define BCM_XGS3_L3_ECMP_DLB_MEMBER_PTR(_u_) \
    756     (l3_module_data[_u_]->l3_ecmp_dlb_member_bitmap)
    757 #define BCM_XGS3_L3_ECMP_DLB_MAX_PATHS(_u_) \
    758     (BCM_XGS3_L3_TBL(_u_, ecmp_info).ecmp_dlb_max_paths)
    759 #define BCM_XGS3_L3_ECMP_DLB_MEMBER_GROUP_PTR(_u_, _group_idx_) \
    760     (&(BCM_XGS3_L3_ECMP_DLB_MEMBER_PTR(_u_)[_SHR_BITDCLSIZE(BCM_XGS3_L3_ECMP_DLB_MAX_PATHS(_u_) * 2) * (_group_idx_)]))
    761 #endif /* BCM_TOMAHAWK2_SUPPORT  || BCM_TRIDENT3_SUPPORT */
    762 
    763 /* L3 Egress Interface usage by Next Hop bitmap */
    764 #define BCM_XGS3_L3_INTF_USED_NH(_u_)                  \
    765     (l3_module_data[_u_]->l3_intf_used_nh)
    766 #define BCM_XGS3_L3_INTF_USED_NH_GET(_u_, _idx_)        \
    767     SHR_BITGET(BCM_XGS3_L3_INTF_USED_NH(_u_), (_idx_))
    768 #define BCM_XGS3_L3_INTF_USED_NH_SET(_u_, _idx_)        \
    769     SHR_BITSET(BCM_XGS3_L3_INTF_USED_NH(_u_), (_idx_))
    770 #define BCM_XGS3_L3_INTF_USED_NH_CLR(_u_, _idx_)        \
    771     SHR_BITCLR(BCM_XGS3_L3_INTF_USED_NH(_u_), (_idx_))
    772 
    773 #ifdef BCM_TRIDENT2_SUPPORT
    774 /* L3 egress object is configured with NAT realm ID explicitly specified. */
    775 #define BCM_XGS3_L3_NH_NAT_REALM_ID_VALID(_u_)                   \
    776     (l3_module_data[_u_]->nh_realm_id_bitmap)
    777 #define BCM_XGS3_L3_NH_NAT_REALM_ID_VALID_GET(_u_, _idx_)        \
    778     SHR_BITGET(BCM_XGS3_L3_NH_NAT_REALM_ID_VALID(_u_), (_idx_))
    779 #define BCM_XGS3_L3_NH_NAT_REALM_ID_VALID_SET(_u_, _idx_)                 \
    780     SHR_BITSET(BCM_XGS3_L3_NH_NAT_REALM_ID_VALID(_u_), (_idx_))
    781 #define BCM_XGS3_L3_NH_NAT_REALM_ID_VALID_CLR(_u_, _idx_)                 \
    782     SHR_BITCLR(BCM_XGS3_L3_NH_NAT_REALM_ID_VALID(_u_), (_idx_))
    783 #endif
    784 
    785 /* HW calls verification & execution macros. */
    786 /* Check if hw call is set. */
    787 #define BCM_XGS3_L3_HWCALL_CHECK(_u_, FN)              \
    788             (BCM_XGS3_L3_TBL(_u_, hw_op).hw_call &&    \
    789             (BCM_XGS3_L3_TBL(_u_, hw_op).hw_call->FN))
    790 /* Call execution macro. */
    791 #define BCM_XGS3_L3_HWCALL_EXEC(_u_, FN)            \
    792             (*(BCM_XGS3_L3_TBL(_u_, hw_op).hw_call->FN))
    793 /* Get function pointer macro. */
    794 #define BCM_XGS3_L3_HWCALL(_u_, FN)  \
    795             (BCM_XGS3_L3_TBL(_u_, hw_op).hw_call->FN)
    796 
    797 /* Generic memory allocation routine. */
    798 #define BCM_XGS3_L3_ALLOC(_ptr_,_size_,_descr_)                      \
    799             do {                                                     \
    800                 if ((FALSE == BCM_XGS3_L3_INITIALIZED(unit)) ||      \
    801                     (NULL == (_ptr_))) {                             \
    802                    _ptr_ = sal_alloc((_size_),(_descr_));            \
    803                 }                                                    \
    804                 if((_ptr_) != NULL) {                                \
    805                     sal_memset((_ptr_), 0, (_size_));                \
    806                 }                                                    \
    807             } while (0)
    808 
    809 /* Calculate final comparison result based on compare & negate  */
    810 #define BCM_XGS3_L3_IS_EQUAL(_res_, _negate_)                 \
    811             (((_res_ == BCM_L3_CMP_EQUAL) && (!_negate_)) ||  \
    812              ((_res_ != BCM_L3_CMP_EQUAL) && (_negate_)))
    813 
    814 /* Decrement counter if positive. */
    815 #define BCM_XGS3_L3_DEC_IF_POSITIVE(_val_) ((_val_ > 0) ?  _val_-- : _val_)
    816 
    817 #ifdef BCM_MPLS_SUPPORT
    818 /* Invalid mpls label.*/
    819 #define BCM_XGS3_L3_MPLS_LBL_MAX      (0xfffff) 
    820 #define BCM_XGS3_L3_INVALID_MPLS_LABEL  (BCM_XGS3_L3_MPLS_LBL_MAX + 1)
    821 #define BCM_XGS3_L3_MPLS_LBL_VALID(_label_)                      \
    822              (_label_ <= BCM_XGS3_L3_MPLS_LBL_MAX)
    823 #endif /* BCM_MPLS_SUPPORT */
    824 
    825 /* L3 memories map & configuration structure. */
    826 #define BCM_L3_MEM_ENT_SIZE(_u_, _mem_)         \
    827              WORDS2BYTES(soc_mem_entry_words((_u_), (_mem_)))
    828 
    829 #define BCM_XGS3_L3_MEM(_u_, _var_)                          \
    830             ((BCM_XGS3_L3_TBL(_u_, hw_op).l3_ ## _var_).tbl_mem)
    831 
    832 #define BCM_XGS3_L3_ENT_SZ(_u_, _var_)                       \
    833             ((BCM_XGS3_L3_TBL(_u_, hw_op).l3_ ## _var_).tbl_entry_sz)
    834 
    835 #define BCM_XGS3_L3_MEM_FIELDS(_u_, _var_)                   \
    836             ((BCM_XGS3_L3_TBL(_u_, hw_op).l3_ ## _var_).tbl_mem_fields)
    837 
    838 #define BCM_XGS3_L3_HW_CALL(_u_)                             \
    839             (BCM_XGS3_L3_TBL(_u_, hw_op).hw_call)
    840 
    841 /* Tables protection macros. */
    842 #define BCM_XGS3_L3_LOCK(_u_, _var_)                         \
    843             MEM_LOCK(_u_, BCM_XGS3_L3_MEM(_u_, _var_))
    844 
    845 #define BCM_XGS3_L3_UNLOCK(_u_, _var_)                       \
    846             MEM_UNLOCK(_u_, BCM_XGS3_L3_MEM(_u_, _var_))
    847 
    848 /* L3 Module locks */
    849 
    850 #define BCM_XGS3_L3_MODULE_LOCK(_u_)                         \
    851             L3_LOCK(_u_)
    852 
    853 #define BCM_XGS3_L3_MODULE_UNLOCK(_u_)                       \
    854             L3_UNLOCK(_u_)
    855 
    856 /* Global sdk L3 structure references. */
    857 /* L3 initialized flag. */
    858 #define BCM_XGS3_L3_INITIALIZED(_u_) _bcm_l3_bk_info[_u_].l3_initialized
    859 /* L3 interface count. */
    860 #define BCM_XGS3_L3_IF_COUNT(_u_) _bcm_l3_bk_info[_u_].l3intf_count
    861 /* L3 interface inuse bitmap array. */
    862 #define BCM_XGS3_L3_IF_INUSE(_u_) _bcm_l3_bk_info[_u_].l3_intf_used
    863 /* L3 interface added to arl bitmap. */
    864 #define BCM_XGS3_L3_IF_ADD2ARL(_u_) _bcm_l3_bk_info[_u_].add_to_arl
    865 /* Interface table size. */
    866 #define BCM_XGS3_L3_IF_TBL_SIZE(_u_) _bcm_l3_bk_info[_u_].l3_intf_table_size
    867 /* L3 ingress interface count. */
    868 #define BCM_XGS3_L3_ING_IF_COUNT(_u_) _bcm_l3_bk_info[_u_].l3iif_count
    869 /* L3 ingress interface inuse bitmap array. */
    870 #define BCM_XGS3_L3_ING_IF_INUSE(_u_) _bcm_l3_bk_info[_u_].l3_iif_used
    871 /* L3 ingress interface table size. */
    872 #define BCM_XGS3_L3_ING_IF_TBL_SIZE(_u_) _bcm_l3_bk_info[_u_].l3_iif_table_size
    873 /* Next hop table size. */
    874 #define BCM_XGS3_L3_NH_TBL_SIZE(_u_) _bcm_l3_bk_info[_u_].nh_table_size
    875 /* Ecmp table size. */
    876 #define BCM_XGS3_L3_ECMP_TBL_SIZE(_u_) _bcm_l3_bk_info[_u_].ecmp_table_size
    877 /* Defip table size. */
    878 #define BCM_XGS3_L3_DEFIP_TBL_SIZE(_u_) _bcm_l3_bk_info[_u_].defip_table_size
    879 /* Tunnel table size. */
    880 #define BCM_XGS3_L3_TUNNEL_TBL_SIZE(_u_) _bcm_l3_bk_info[_u_].tunnel_table_size
    881 #ifdef BCM_TRIUMPH2_SUPPORT
    882 #define BCM_XGS3_L3_MAX_ECMP_MODE(_u_) _bcm_l3_bk_info[_u_].l3_max_ecmp_mode
    883 #else 
    884 #define BCM_XGS3_L3_MAX_ECMP_MODE(_u_) 0
    885 #endif /* BCM_TRIUMPH2_SUPPORT */
    886 
    887 /* Tunnel DSCP map inuse bitmap array. */
    888 #define BCM_XGS3_L3_TUNNEL_DSCP_MAP_INUSE(_u_) \
    889     _bcm_l3_bk_info[_u_].dscp_map_used
    890 /* Number of Tunnel DSCP map instances. */
    891 #define BCM_XGS3_L3_TUNNEL_DSCP_MAP_TBL_SIZE(_u_) \
    892     _bcm_l3_bk_info[_u_].num_dscp_maps
    893 
    894 #define BCM_XGS3_L3_NH_MULTI_COUNT(_u_)  _bcm_l3_bk_info[_u_].l3_nh_multi_count
    895 
    896 /* Cpu interface index. */
    897 #if defined(BCM_RIOT_SUPPORT)
    898 #define BCM_XGS3_L3_L2CPU_INTF_IDX(_u_)     \
    899                ((BCMI_L3_INTF_OVERLAY_VALID(_u_) && BCMI_L3_INTF_MEM_ALLOC_MODE(_u_)) ? \
    900                 (soc_mem_index_max((_u_), BCM_XGS3_L3_MEM(_u_, intf)) - BCMI_L3_INTF_OVERLAY_ENTRIES(_u_)) : \
    901                 (soc_mem_index_max((_u_), BCM_XGS3_L3_MEM(_u_, intf))))
    902 #else
    903 #define BCM_XGS3_L3_L2CPU_INTF_IDX(_u_)     \
    904                 (soc_mem_index_max((_u_), BCM_XGS3_L3_MEM(_u_, intf)))
    905 #endif /* BCM_RIOT_SUPPORT */
    906 
    907 #define BCM_XGS3_L3_BLACK_HOLE_INTF_IDX(u) 0
    908 
    909 #define BCM_XGS3_L3_INTF_IDX_MIN(_u_)  BCM_XGS3_L3_TBL(_u_, intf).idx_min
    910 
    911 /* For Easyrider, reserve 8 L3_INTF entries MPLS incoming interfaces */
    912 #define BCM_XGS3_L3_MPLS_INTF_IDX_MIN(_u_)                  \
    913                 (SOC_IS_EASYRIDER((_u_)) ?                  \
    914                  BCM_XGS3_L3_L2CPU_INTF_IDX(_u_) - 9 :      \
    915                  BCM_XGS3_L3_L2CPU_INTF_IDX(_u_))
    916 
    917 #define BCM_XGS3_L3_MPLS_INTF_IDX_MAX(_u_)                  \
    918                 (SOC_IS_EASYRIDER((_u_)) ?                  \
    919                  BCM_XGS3_L3_L2CPU_INTF_IDX(_u_) - 1 :      \
    920                  BCM_XGS3_L3_L2CPU_INTF_IDX(_u_))
    921 
    922 
    923 /* Set interface index */
    924 #define BCM_XGS3_L3_INTF_IDX_SET(_l3_intf_,_ifindex_)           \
    925             {                                                   \
    926                 _l3_intf_.l3i_index = _ifindex_;                \
    927                 _l3_intf_.l3i_flags |= BCM_L3_WITH_ID;          \
    928             }
    929 
    930 /* Copy IPv4 address into lower 4 bytes of IPv6 address. */
    931 #define BCM_XGS3_L3_CP_V4_ADDR_TO_V6(_v6_,_v4_)                      \
    932             {                                                        \
    933                 sal_memset(_v6_, 0, 12);                             \
    934                 sal_memcpy((uint8 *)_v6_ + BCM_XGS3_V4_IN_V6_OFFSET, \
    935                        &_v4_, sizeof(bcm_ip_t));                     \
    936             }
    937 
    938 /* Unipath egress object index valid. */
    939 #define BCM_XGS3_L3_EGRESS_IDX_VALID(_u_, _idx_)                     \
    940             ((_idx_ >= BCM_XGS3_EGRESS_IDX_MIN(_u_) ) &&            \
    941              (_idx_ < BCM_XGS3_EGRESS_IDX_MIN(_u_) +                \
    942               BCM_XGS3_L3_NH_TBL_SIZE(_u_)))
    943 
    944 /* Multipath egress object index valid. */
    945 /*Used table size as some legacy chips does not use ECMP_GROUP*/
    946 #define BCM_XGS3_L3_MPATH_EGRESS_IDX_VALID(_u_, _idx_)              \
    947        ((_idx_ >= BCM_XGS3_MPATH_EGRESS_IDX_MIN(_u_)) &&                 \
    948         (_idx_ < (BCM_XGS3_MPATH_EGRESS_IDX_MIN(_u_) +                   \
    949                   BCM_XGS3_L3_ECMP_MAX_GROUPS(_u_))))
    950 
    951 /*Use ECMP Max group size for the device that support ECMP_GROUP*/
    952 #define BCMI_XGS3_L3_MPATH_GROUP_IDX_VALID(_u_, _idx_)              \
    953     ((_idx_ >= BCM_XGS3_MPATH_EGRESS_IDX_MIN(_u_)) &&                 \
    954      (_idx_ < (BCM_XGS3_MPATH_EGRESS_IDX_MIN(_u_) +                   \
    955                BCM_XGS3_L3_ECMP_MAX_GROUPS(_u_))))
    956 
    957 /* DVP next hop egress object index valid. */
    958 #define BCM_XGS3_DVP_EGRESS_IDX_VALID(_u_, _idx_)                     \
    959             ((_idx_ >= BCM_XGS3_DVP_EGRESS_IDX_MIN(_u_) ) &&          \
    960              (_idx_ < BCM_XGS3_DVP_EGRESS_IDX_MIN(_u_) +              \
    961               BCM_XGS3_L3_NH_TBL_SIZE(_u_)))
    962 
    963 /* Proxy next hop egress object index valid. */
    964 #define BCM_XGS3_PROXY_EGRESS_IDX_VALID(_u_, _idx_)                     \
    965             ((_idx_ >= BCM_XGS3_PROXY_EGRESS_IDX_MIN(_u_)) &&           \
    966              (_idx_ < BCM_XGS3_PROXY_EGRESS_IDX_MIN(_u_) +              \
    967               BCM_XGS3_L3_NH_TBL_SIZE(_u_)))
    968 
    969 /* Counter update macro. */
    970 #define BCM_XGS3_L3_GEN_CNTR_UPD(_cntr_,_op_)               \
    971             _cntr_ += (_op_)?(1):(-1)
    972 
    973 /* Trunk id validation macro. */
    974 #define BCM_XGS3_L3_IF_INVALID_TGID_RETURN(unit, _flags_,_port_tgid_)      \
    975             if (_flags_ & BCM_L3_TGID) {                                   \
    976                 if (_port_tgid_ &                                          \
    977                     ~(BCM_TGID_PORT_TRUNK_MASK(unit) |                     \
    978                       BCM_TGID_PORT_TRUNK_MASK_HI(unit))){                 \
    979                     return (BCM_E_BADID);                                  \
    980                 }                                                          \
    981             }
    982 /* Check if l3 entry is multicast. */
    983 #define BCM_XGS3_L3_MCAST_ENTRY(_l3cfg_)                     \
    984             ((((_l3cfg_)->l3c_flags & BCM_L3_IP6) &&         \
    985               (BCM_IP6_MULTICAST((_l3cfg_)->l3c_ip6))) ||    \
    986              ((!((_l3cfg_)->l3c_flags & BCM_L3_IP6)) &&      \
    987               (BCM_IP4_MULTICAST((_l3cfg_)->l3c_ip_addr)))) 
    988 
    989 /* Lookup error or overrite not supported return macro. */
    990 #define BCM_XGS3_IF_ERROR_OR_ENTRY_EXISTS_RETURN(_rv_)      \
    991             if (_rv_ < 0 && _rv_ != BCM_E_NOT_FOUND) {      \
    992                 return rv;                                  \
    993             } else if (!_rv_) {                             \
    994                 return BCM_E_EXISTS;                        \
    995             }
    996 
    997 /* Lookup error return macro. */ 
    998 #define BCM_XGS3_LKUP_IF_ERROR_RETURN(_rv_, _not_found_err_code_) \
    999             if (_rv_ == SOC_E_NOT_FOUND) {                        \
   1000                 return _not_found_err_code_;                      \
   1001             } else if (_rv_ < 0) {                                \
   1002                 return _rv_;                                      \
   1003             }
   1004 
   1005 #define BCM_XGS3_V6_FLD32_GET_IF_FBX(_u_, _v6_, _mem_, _buf_, _fld_) \
   1006           ((_v6_ && SOC_IS_FBX(_u_) &&                               \
   1007              SOC_MEM_FIELD_VALID(_u_, _mem_, _fld_)) ?               \
   1008                soc_mem_field32_get(_u_, _mem_, _buf_, _fld_) : 0)
   1009 
   1010 #define BCM_XGS3_V6_FLD32_SET_IF_FBX(_u_, _v6_, _mem_, _buf_, _fld_, _val_)\
   1011             if (_v6_ && SOC_IS_FBX(_u_) &&                                 \
   1012                 SOC_MEM_FIELD_VALID(_u_, _mem_, _fld_)) {                  \
   1013                soc_mem_field32_set(_u_, _mem_, _buf_, _fld_, _val_);       \
   1014             }
   1015 
   1016 #ifdef BCM_FIREBOLT_SUPPORT
   1017 /* Increment counter if device is firebolt. */ 
   1018 #define BCM_XGS3_INC_IF_FIREBOLT(_u_,_idx_)               \
   1019             _idx_ +=  (SOC_IS_FBX(_u_) && \
   1020                        (!(SOC_IS_RAPTOR(_u_)||SOC_IS_HAWKEYE(_u_)))) ? 1 : 0
   1021  
   1022 /* Calculate ip6/ipmc index based on ip4 entry index. */ 
   1023 #define BCM_XGS3_FB_IPMC_IP6_IDX_CALC(_u_,_idx_,_result_,_flags_) \
   1024             if(SOC_IS_FBX(_u_) && (!SOC_IS_RAPTOR(_u_))) {        \
   1025                 _result_ = _idx_;                                 \
   1026                 if (_flags_ & BCM_L3_IP6) {                       \
   1027                      if (_flags_ & BCM_L3_IPMC) {                 \
   1028                          _result_ >>= 2;                          \
   1029                           _idx_ += 3;                             \
   1030                      } else {                                     \
   1031                          _result_ >>= 1;                          \
   1032                          _idx_++;                                 \
   1033                      }                                            \
   1034                 } else if (SOC_IS_TRX(_u_) &&                     \
   1035                           (_flags_ & BCM_L3_IPMC)) {              \
   1036                          _result_ >>= 1;                          \
   1037                          _idx_++;                                 \
   1038                 }                                                 \
   1039             }
   1040 #endif /* BCM_FIREBOLT_SUPPORT */
   1041 /* L3 table usage statistics.*/
   1042 /* L3 table size. */
   1043 #define BCM_XGS3_L3_TBL_SIZE(_u_)      _bcm_l3_bk_info[_u_].l3_table_size
   1044 #define BCM_XGS3_L3_IP4_CNT(_u_)       _bcm_l3_bk_info[_u_].l3_ip4_added
   1045 #define BCM_XGS3_L3_IP6_CNT(_u_)       _bcm_l3_bk_info[_u_].l3_ip6_added
   1046 #define BCM_XGS3_L3_IP4_IPMC_CNT(_u_)  _bcm_l3_bk_info[_u_].l3_ipmc4_added
   1047 #define BCM_XGS3_L3_IP6_IPMC_CNT(_u_)  _bcm_l3_bk_info[_u_].l3_ipmc6_added
   1048 #define BCM_XGS3_L3_IP6_MAX_128B_ENTRIES(_u_) \
   1049                             _bcm_l3_bk_info[_u_].l3_ip6_max_128b_entries
   1050 #define BCM_XGS3_L3_NH_CNT(_u_)        _bcm_l3_bk_info[_u_].l3_nh_added
   1051 #define BCM_XGS3_L3_ECMP_GRP_CNT(_u_)  _bcm_l3_bk_info[_u_].l3_ecmp_grp_added
   1052 
   1053 
   1054  
   1055 /* Defip table usage statistics.*/
   1056 #define BCM_XGS3_L3_DEFIP_TBL_SIZE(_u_) _bcm_l3_bk_info[_u_].defip_table_size
   1057 #define BCM_XGS3_L3_DEFIP_IP4_CNT(_u_)  _bcm_l3_bk_info[_u_].defip_count
   1058 #define BCM_XGS3_L3_DEFIP_IP6_CNT(_u_)  _bcm_l3_bk_info[_u_].defip_ip6_count
   1059 #define BCM_XGS3_L3_DEFIP_CNT_UPD(_u_,_ipv6_,_o_)                             \
   1060             if(_ipv6_) {                                                      \
   1061                BCM_XGS3_L3_GEN_CNTR_UPD(BCM_XGS3_L3_DEFIP_IP6_CNT(_u_),_o_);  \
   1062             }                                                                 \
   1063             else {                                                            \
   1064                BCM_XGS3_L3_GEN_CNTR_UPD(BCM_XGS3_L3_DEFIP_IP4_CNT(_u_),_o_);  \
   1065             }
   1066 /* Defip table usage update macros. */ 
   1067 #define BCM_XGS3_L3_DEFIP_CNT_INC(_u_,_ipv6_)      \
   1068             BCM_XGS3_L3_DEFIP_CNT_UPD(_u_,_ipv6_,1)
   1069 #define BCM_XGS3_L3_DEFIP_CNT_DEC(_u_,_ipv6_)      \
   1070             BCM_XGS3_L3_DEFIP_CNT_UPD(_u_,_ipv6_,0)
   1071 
   1072 /* Route operation params verification macro. */
   1073 #define BCM_XGS3_L3_DEFIP_INVALID_PARAMS_RETURN(_u_, _lpm_cfg_)              \
   1074             if (!_lpm_cfg_) {                                                \
   1075                 return (BCM_E_PARAM);                                        \
   1076             }                                                                \
   1077             if ((_lpm_cfg_)->defip_flags & BCM_L3_IP6) {                     \
   1078                 if((_lpm_cfg_)->defip_sub_len > BCM_L3_IP6_MAX_NETLEN) {     \
   1079                     return (BCM_E_PARAM);                                    \
   1080                 }                                                            \
   1081             } else if((_lpm_cfg_)->defip_sub_len > BCM_L3_IP4_MAX_NETLEN) {  \
   1082                   return (BCM_E_PARAM);                                      \
   1083             }                                                                \
   1084 /* Traverse table not empty check macro. */ 
   1085 #define BCM_XGS3_L3_IF_DEFIP_CNT_ZERO_RETURN(_u_, _ipv6_)            \
   1086             if (((_ipv6_) && !BCM_XGS3_L3_DEFIP_IP6_CNT((_u_))) ||   \
   1087                 (!(_ipv6_) && !BCM_XGS3_L3_DEFIP_IP4_CNT((_u_)))) {  \
   1088                   return BCM_E_NONE;                                 \
   1089             }
   1090 
   1091 /* Generic table management macros. */
   1092 #define BCM_XGS3_L3_ENT_HASH(_tbl_ptr, _i_) ((_tbl_ptr)->ext_arr[_i_]).data_hash
   1093 
   1094 /* Compare entry hash macro. */
   1095 #define BCM_XGS3_L3_ENT_HASH_CMP(_tbl_ptr, _i_, _h_)             \
   1096             (_h_ == ((_tbl_ptr)->ext_arr[_i_]).data_hash)
   1097 
   1098 /* Reset entry extended info macro. */
   1099 #define BCM_XGS3_L3_ENT_RESET(_tbl_ptr, _i_, _width_)                         \
   1100             {                                                                 \
   1101                 int _idx_;                                                    \
   1102                 for (_idx_ = 0; _idx_ < (_width_); _idx_++) {                 \
   1103                      sal_memset(((_tbl_ptr)->ext_arr + (_i_ + _idx_)), 0,     \
   1104                            sizeof(_bcm_l3_tbl_ext_t));                        \
   1105                 }                                                             \
   1106             }
   1107 
   1108 /* Init entry extended info macro. */
   1109 #define BCM_XGS3_L3_ENT_INIT(_tbl_ptr, _i_, _width_, _hash_)                  \
   1110             {                                                                 \
   1111                 int _idx_;                                                    \
   1112                 for (_idx_ = 0; _idx_ < (_width_); _idx_++) {                 \
   1113                     ((_tbl_ptr)->ext_arr[(_i_) + _idx_]).data_hash = (_hash_);\
   1114                     if (0 == ((_tbl_ptr)->ext_arr[(_i_) + _idx_]).ref_count) {\
   1115                         ((_tbl_ptr)->ext_arr[(_i_) + _idx_]).ref_count = 1;   \
   1116                     }                                                         \
   1117                 }                                                             \
   1118             }
   1119 
   1120 /* Hash update extended info macro. */
   1121 #define BCM_XGS3_L3_ENT_HASH_UPDATE(_tbl_ptr, _i_, _width_, _hash_)                  \
   1122             {                                                                 \
   1123                 int _idx_;                                                    \
   1124                 for (_idx_ = 0; _idx_ < (_width_); _idx_++) {                 \
   1125                     ((_tbl_ptr)->ext_arr[(_i_) + _idx_]).data_hash = (_hash_);\
   1126                 }                                                             \
   1127             }
   1128 
   1129 /* Set L3 flags . */
   1130 #define BCM_XGS3_L3_ENT_FLAG_SET(_tbl_ptr, _i_, _width_, _flag_)              \
   1131             {                                                                 \
   1132                 int _idx_;                                                    \
   1133                 for (_idx_ = 0; _idx_ < (_width_); _idx_++) {                 \
   1134                     ((_tbl_ptr)->ext_arr[(_i_) + _idx_]).l3_flag = (_flag_);  \
   1135                 }                                                             \
   1136             }
   1137  
   1138 /* Get L3 flags. */
   1139 #define BCM_XGS3_L3_ENT_FLAG(_tbl_ptr, _i_)           \
   1140             ((_tbl_ptr)->ext_arr[_i_]).l3_flag
   1141 
   1142 
   1143 /* Get entry reference count. */
   1144 #define BCM_XGS3_L3_ENT_REF_CNT(_tbl_ptr, _i_)                   \
   1145             ((_tbl_ptr)->ext_arr[_i_]).ref_count
   1146 
   1147 /* Increment entry reference count. */
   1148 #define BCM_XGS3_L3_ENT_REF_CNT_INC(_tbl_ptr, _i_, _width_)           \
   1149             {                                                         \
   1150                 int _idx_ = (_width_);                                \
   1151                 for (_idx_ = 0; _idx_ < (_width_); _idx_++) {         \
   1152                     ((_tbl_ptr)->ext_arr[(_i_) + _idx_]).ref_count++; \
   1153                 }                                                     \
   1154             }
   1155 /* Decrement entry reference count. */
   1156 #define BCM_XGS3_L3_ENT_REF_CNT_DEC(_tbl_ptr, _i_, _width_)           \
   1157             {                                                         \
   1158                 int _idx_ = (_width_);                                \
   1159                 for (_idx_ = 0; _idx_ < (_width_); _idx_++) {         \
   1160                     if (((_tbl_ptr)->ext_arr[(_i_) + _idx_]).ref_count > 0) { \
   1161                          ((_tbl_ptr)->ext_arr[(_i_) + _idx_]).ref_count--; \
   1162                     	} \
   1163                 }                                                     \
   1164             }
   1165 
   1166 /* Maximum number of paths in ecmp group on device. */
   1167 #define BCM_XGS3_L3_ECMP_MAX_PATHS(_u_)                  \
   1168             BCM_XGS3_L3_TBL(_u_, ecmp_info).ecmp_max_paths
   1169 
   1170 #ifdef BCM_TOMAHAWK_SUPPORT
   1171 /* Maximum number of paths in ecmp RH group on device. */
   1172 #define BCM_XGS3_L3_ECMP_RH_MAX_PATHS(_u_)                  \
   1173             BCM_XGS3_L3_TBL(_u_, ecmp_info).ecmp_rh_max_paths
   1174 #endif /* BCM_TOMAHAWK_SUPPORT */
   1175 
   1176 /* Maximum ecmp group id. */ 
   1177 #define BCM_XGS3_L3_ECMP_IN_USE(_u_)                     \
   1178             BCM_XGS3_L3_TBL(_u_, ecmp_info).ecmp_inuse
   1179 
   1180 /* ECMP group flags */
   1181 #define BCM_XGS3_L3_ECMP_GROUP_FLAGS_SET(_u_, _id_, _f_)  \
   1182            (BCM_XGS3_L3_TBL((_u_), ecmp_info).ecmp_flags[(_id_)] |= (_f_))
   1183 
   1184 #define BCM_XGS3_L3_ECMP_GROUP_FLAGS_RESET(_u_, _id_, _f_)  \
   1185            (BCM_XGS3_L3_TBL((_u_), ecmp_info).ecmp_flags[(_id_)] &= ~(_f_))
   1186 
   1187 #define BCM_XGS3_L3_ECMP_GROUP_FLAGS_ISSET(_u_, _id_, _f_)  \
   1188            (BCM_XGS3_L3_TBL((_u_), ecmp_info).ecmp_flags[(_id_)] & (_f_))
   1189            
   1190 /* Calculate number of ecmp group next hops. */
   1191 #define BCM_XGS3_L3_ECMP_GROUP_SIZE(_ecmp_count_)  (_ecmp_count_ + 1)
   1192 
   1193 #define BCM_XGS3_L3_CNTRS_RESET(_u_)                           \
   1194             do {                                               \
   1195                 _bcm_l3_bk_info[_u_].l3intf_count = 0;         \
   1196                 _bcm_l3_bk_info[_u_].defip_count= 0;           \
   1197                 _bcm_l3_bk_info[_u_].defip_ip6_count= 0;       \
   1198                 _bcm_l3_bk_info[_u_].l3_ip4_added= 0;          \
   1199                 _bcm_l3_bk_info[_u_].l3_ip6_added= 0;          \
   1200                 _bcm_l3_bk_info[_u_].l3_ipmc4_added= 0;        \
   1201                 _bcm_l3_bk_info[_u_].l3_ipmc6_added= 0;        \
   1202                 _bcm_l3_bk_info[_u_].l3_nh_added = 0;          \
   1203                 _bcm_l3_bk_info[_u_].l3_ecmp_grp_added = 0;    \
   1204             } while (0)
   1205 
   1206 
   1207 #if defined(BCM_RAPTOR_SUPPORT) || defined(BCM_MIRAGE_SUPPORT) || \
   1208     defined(BCM_HAWKEYE_SUPPORT)
   1209 #undef BCM_XGS3_L3_FORWARD_IPV4_WITH_OPTIONS 
   1210 #define BCM_XGS3_L3_RP_HOST_ENTRY(_ent_)                               \
   1211             (((_ent_->flags & BCM_L3_IP6) &&                           \
   1212               (_ent_->prefixlen == BCM_XGS3_L3_IPV6_PREFIX_LEN)) ||    \
   1213              ((!(_ent_->flags & BCM_L3_IP6)) &&                        \
   1214               (_ent_->prefixlen == BCM_XGS3_L3_IPV4_PREFIX_LEN)))
   1215 #endif /* BCM_RAPTOR_SUPPORT || BCM_MIRAGE_SUPPORT || BCM_HAWKEYE_SUPPORT */
   1216 extern int _bcm_xgs3_l3_set_tnl_term_type(int unit, 
   1217                                            bcm_tunnel_terminator_t *tnl_info,
   1218                                            _bcm_tnl_term_type_t *tnl_type);
   1219 extern int _bcm_xgs3_l3_get_tnl_term_type(int unit, 
   1220                                           bcm_tunnel_terminator_t *tnl_info,
   1221                                           _bcm_tnl_term_type_t *tnl_type);
   1222                                
   1223 extern int _bcm_xgs3_egress_l3_intf_id_free(int unit, int id);
   1224 extern int _bcm_xgs3_egress_l3_intf_id_alloc(int unit,  _bcm_l3_intf_cfg_t *info);
   1225 extern int _bcm_xgs3_route_tables_resize(int unit,  int arg);
   1226 #endif /*  INCLUDE_L3  */
   1227 /* Read memory macro. */
   1228 #define BCM_XGS3_MEM_READ(_u_, _m_, _idx_, _buf_)                          \
   1229 	        ((SOC_MEM_IS_VALID(_u_, _m_)) ?                                \
   1230             soc_mem_read(_u_, _m_, MEM_BLOCK_ANY, _idx_, (void *)_buf_) :  \
   1231             BCM_E_UNAVAIL)
   1232 
   1233 /* Write memory macro. */
   1234 #define BCM_XGS3_MEM_WRITE(_u_, _m_, _idx_, _buf_)                         \
   1235 	        ((SOC_MEM_IS_VALID(_u_, _m_)) ?                                \
   1236             soc_mem_write(_u_, _m_, MEM_BLOCK_ALL, _idx_, (void *)_buf_) : \
   1237             BCM_E_UNAVAIL)
   1238 
   1239 /* Clear memory macro. */
   1240 #define BCM_XGS3_MEM_CLEAR(_u_, _m_)                                       \
   1241 	        ((SOC_MEM_IS_VALID(_u_, _m_)) ?                                \
   1242              soc_mem_clear(_u_, _m_, MEM_BLOCK_ALL, TRUE) : BCM_E_NONE)
   1243 
   1244 
   1245 /* Caluculate kbit per second rate in  64kbit quantum equivalent. */
   1246 #define BCM_XGS3_PORT_RATE_64KBIT_QUANTUM(_kbit_, _rate_)      \
   1247             {                                                  \
   1248                if (_kbit_ > (0xFFFFFFFF - 63)) {               \
   1249                    _kbit_ = (0xFFFFFFFF - 63);                 \
   1250                }                                               \
   1251                if ((_rate_ = (_kbit_ + 63) / 64) > 0x3FFFF) {  \
   1252                     _rate_ = 0x3FFFF;                          \
   1253                }                                               \
   1254             }
   1255 
   1256 /* Set bitmap in register entry. */ 
   1257 #if defined(BCM_TRIUMPH_SUPPORT) || defined(BCM_RAPTOR_SUPPORT)
   1258 #define _BCM_XGS3_REG_BITMAP_SET(_unit_, _reg_, _fld_, _buf_, _pbmp_)        \
   1259     do {                                                                     \
   1260         if (soc_feature((_unit_), soc_feature_table_hi)) {                   \
   1261             if (SOC_REG_IS_64(_unit_, (_reg_)))  {                             \
   1262                 soc_reg64_field32_set((_unit_), (_reg_), (_buf_),            \
   1263                                       (_fld_##_HIf),                         \
   1264                                       SOC_PBMP_WORD_GET((_pbmp_), 1));       \
   1265                 soc_reg64_field32_set((_unit_), (_reg_), (_buf_),            \
   1266                                       (_fld_##_LOf),                         \
   1267                                       SOC_PBMP_WORD_GET((_pbmp_), 0));       \
   1268             } else  {                                                        \
   1269                 soc_reg_field_set((_unit_), (_reg_),                         \
   1270                                   ((uint32 *)((void *)(_buf_))),             \
   1271                                   (_fld_##_HIf),                             \
   1272                                   SOC_PBMP_WORD_GET((_pbmp_), 1));           \
   1273                 soc_reg_field_set((_unit_), (_reg_),                         \
   1274                                   ((uint32 *)((void *)(_buf_))),             \
   1275                                   (_fld_##_LOf),                             \
   1276                                   SOC_PBMP_WORD_GET((_pbmp_), 0));           \
   1277             }                                                                \
   1278         } else {                                                             \
   1279             if (SOC_REG_IS_64(_unit_, (_reg_)))  {                             \
   1280                 soc_reg64_field32_set((_unit_), (_reg_), (_buf_),            \
   1281                                       (_fld_##f),                            \
   1282                                       SOC_PBMP_WORD_GET((_pbmp_), 0));       \
   1283             } else  {                                                        \
   1284                 soc_reg_field_set((_unit_), (_reg_),                         \
   1285                                   ((uint32 *)((void *)(_buf_))),             \
   1286                                   (_fld_##f),                                \
   1287                                   SOC_PBMP_WORD_GET((_pbmp_), 0));           \
   1288             }                                                                \
   1289         }                                                                    \
   1290     } while (0)
   1291 
   1292 /* Get bitmap from memory entry. */ 
   1293 #define _BCM_XGS3_REG_BITMAP_GET(_unit_, _reg_, _fld_, _buf_, _pbmp_)        \
   1294     do {                                                                     \
   1295         if (soc_feature((_unit_), soc_feature_table_hi)) {                   \
   1296             if (SOC_REG_IS_64(_unit_, (_reg_)))  {                             \
   1297                 SOC_PBMP_WORD_SET((_pbmp_), 0,                               \
   1298                                   soc_reg64_field32_get((_unit_), (_reg_),   \
   1299                                                         (_buf_),             \
   1300                                                         (_fld_##_LOf)));     \
   1301                 SOC_PBMP_WORD_SET((_pbmp_), 1,                               \
   1302                                   soc_reg64_field32_get((_unit_), (_reg_),   \
   1303                                                         (_buf_),             \
   1304                                                         (_fld_##_HIf)));     \
   1305             } else  {                                                        \
   1306                 SOC_PBMP_WORD_SET((_pbmp_), 0,                               \
   1307                                   soc_reg_field_get((_unit_), (_reg_),       \
   1308                                                     (_buf_), (_fld_##_LOf)));\
   1309                 SOC_PBMP_WORD_SET((_pbmp_), 1,                               \
   1310                                   soc_reg_field_get((_unit_), (_reg_),       \
   1311                                                     (_buf_), (_fld_##_HIf)));\
   1312             }                                                                \
   1313         } else {                                                             \
   1314             if (SOC_REG_IS_64(_unit_, (_reg_)))  {                             \
   1315                 SOC_PBMP_WORD_SET((_pbmp_), 0,                               \
   1316                                   soc_reg64_field32_get((_unit_), (_reg_),   \
   1317                                                         (_buf_),             \
   1318                                                         (_fld_##f)));        \
   1319             } else  {                                                        \
   1320                 SOC_PBMP_WORD_SET((_pbmp_), 0,                               \
   1321                                   soc_reg_field_get((_unit_), (_reg_),       \
   1322                                                     (_buf_), (_fld_##f)));   \
   1323             }                                                                \
   1324         }                                                                    \
   1325     } while (0)
   1326 #else  /* BCM_TRIUMPH_SUPPORT || BCM_RAPTOR_SUPPORT */
   1327 #define _BCM_XGS3_REG_BITMAP_SET(_unit_, _reg_, _fld_, _buf_, _pbmp_)        \
   1328     do {                                                                     \
   1329         if (SOC_REG_IS_64(_unit_, (_reg_)))  {                                 \
   1330             soc_reg64_field32_set((_unit_), (_reg_), (_buf_),                \
   1331                                   (_fld_##f),                                \
   1332                                   SOC_PBMP_WORD_GET((_pbmp_), 0));           \
   1333         } else  {                                                            \
   1334             soc_reg_field_set((_unit_), (_reg_),                             \
   1335                               ((uint32 *)((void *)(_buf_))), (_fld_##f),     \
   1336                               SOC_PBMP_WORD_GET((_pbmp_), 0));               \
   1337         }                                                                    \
   1338     } while (0)
   1339 
   1340 /* Get bitmap from memory entry. */ 
   1341 #define _BCM_XGS3_REG_BITMAP_GET(_unit_, _reg_, _fld_, _buf_, _pbmp_)        \
   1342     do {                                                                     \
   1343         if (SOC_REG_IS_64(_unit_, (_reg_)))  {                                 \
   1344             SOC_PBMP_WORD_SET((_pbmp_), 0,                                   \
   1345                               soc_reg64_field32_get((_unit_), (_reg_),       \
   1346                                                     (_buf_),                 \
   1347                                                     (_fld_##f)));            \
   1348         } else  {                                                            \
   1349             SOC_PBMP_WORD_SET((_pbmp_), 0,                                   \
   1350                               soc_reg_field_get((_unit_), (_reg_),           \
   1351                                                 (_buf_), (_fld_##f)));       \
   1352         }                                                                    \
   1353     } while (0)
   1354 #endif /* BCM_TRIUMPH_SUPPORT || BCM_RAPTOR_SUPPORT */
   1355 /* 
   1356  *  FUNCTIONS  PROTOTYPES.
   1357  */
   1358 
   1359 /* 6 bit field, msb indicates trunk */
   1360 #define BCM_TGID_TRUNK_LO_BITS(unit)       (SOC_TRUNK_BIT_POS(unit))
   1361 #define BCM_TGID_TRUNK_INDICATOR(unit)     (1 << SOC_TRUNK_BIT_POS(unit))
   1362 #define BCM_TGID_PORT_TRUNK_MASK(unit)     ((1 << SOC_TRUNK_BIT_POS(unit)) - 1)
   1363 #define BCM_TGID_PORT_TRUNK_MASK_HI(unit)  (0x3 << SOC_TRUNK_BIT_POS(unit))
   1364 
   1365 
   1366 /*
   1367  * Routines for internal use
   1368  */
   1369 
   1370 extern int _bcm_fb_l2_from_l2u(int unit, 
   1371                         bcm_l2_addr_t *l2addr, l2u_entry_t *l2u_entry);
   1372 extern int _bcm_fb_l2_to_l2u(int unit, 
   1373                       l2u_entry_t *l2u_entry, bcm_l2_addr_t *l2addr);
   1374 extern int _bcm_fb_l2_from_l2x(int unit,
   1375                      bcm_l2_addr_t *l2addr, l2x_entry_t *l2x_entry);
   1376 extern int _bcm_fb_l2_to_l2x(int unit,
   1377                    l2x_entry_t *l2x_entry, bcm_l2_addr_t *l2addr);
   1378 
   1379 /****************************************************************
   1380  *
   1381  * Firebolt functions
   1382  */
   1383 
   1384 extern int bcm_fb_l2_init(int unit);
   1385 extern int bcm_fb_l2_term(int unit);
   1386 extern int bcm_fb_l2_addr_get(int unit, bcm_mac_t mac_addr, bcm_vlan_t vid,
   1387                        bcm_l2_addr_t *l2addr);
   1388 extern int bcm_fb_l2_addr_add(int unit, bcm_l2_addr_t *l2addr);
   1389 extern int bcm_fb_l2_addr_delete(int, bcm_mac_t, bcm_vlan_t);
   1390 extern int bcm_fb_l2_addr_delete_by_port(int, bcm_module_t, bcm_port_t,
   1391                                   uint32);
   1392 extern int bcm_fb_l2_addr_delete_by_mac(int, bcm_mac_t, uint32);
   1393 extern int bcm_fb_l2_addr_delete_by_vlan(int, bcm_vlan_t, uint32);
   1394 extern int bcm_fb_l2_addr_delete_by_trunk(int, bcm_trunk_t, uint32);
   1395 extern int bcm_fb_l2_addr_delete_by_mac_port(int, bcm_mac_t,
   1396                                       bcm_module_t, bcm_port_t,
   1397                                       uint32);
   1398 extern int bcm_fb_l2_addr_delete_by_vlan_port(int, bcm_vlan_t,
   1399                                        bcm_module_t, bcm_port_t,
   1400                                        uint32);
   1401 extern int _bcm_fb_l2_addr_replace_by_vlan_dest(int unit, uint32 flags, 
   1402                                                 _bcm_l2_replace_t *rep_st);
   1403 extern int bcm_fb_l2_addr_delete_mcast(int unit, uint32 flags);
   1404 extern int bcm_fb_l2_conflict_get(int, bcm_l2_addr_t *, bcm_l2_addr_t *,
   1405                            int, int *);
   1406 
   1407 #ifndef BCM_SW_STATE_DUMP_DISABLE
   1408 extern void _bcm_fb_l2_sw_dump(int unit);
   1409 #endif /* BCM_SW_STATE_DUMP_DISABLE */
   1410 #ifndef BCM_SW_STATE_DUMP_DISABLE
   1411 extern void _bcm_xgs3_mcast_sw_dump(int unit);
   1412 #endif /* BCM_SW_STATE_DUMP_DISABLE */
   1413 
   1414 extern int bcm_xgs3_port_cfg_init(int, bcm_port_t, bcm_vlan_data_t *);
   1415 extern int bcm_xgs3_port_cfg_get(int, bcm_port_t, bcm_port_cfg_t *);
   1416 extern int bcm_xgs3_port_cfg_set(int, bcm_port_t, bcm_port_cfg_t *);
   1417 
   1418 extern int _bcm_xgs3_trunk_table_write(int unit, bcm_port_t port, int tid);
   1419 extern int _bcm_xgs3_trunk_table_read(int unit, bcm_port_t port, int *tid);
   1420 
   1421 extern int bcm_fb_er_vlan_init(int unit, bcm_vlan_data_t *vd);
   1422 extern int bcm_fb_er_vlan_create(int unit, bcm_vlan_t vid);
   1423 extern int bcm_fb_er_vlan_destroy(int unit, bcm_vlan_t vid);
   1424 extern int bcm_fb_er_vlan_stg_get(int unit, bcm_vlan_t vid, bcm_stg_t *stg_ptr);
   1425 extern int bcm_fb_er_vlan_stg_set(int unit, bcm_vlan_t vid, bcm_stg_t stg);
   1426 extern int bcm_fb_er_vlan_reload(int unit, vbmp_t *bmp, int *count);
   1427 #ifdef BCM_WARM_BOOT_SUPPORT
   1428 extern int _bcm_fb2_vlan_profile_reload(int unit);
   1429 #endif /* BCM_WARM_BOOT_SUPPORT */
   1430 
   1431 #ifndef BCM_SW_STATE_DUMP_DISABLE
   1432 extern void _bcm_fb2_vlan_profile_sw_dump(int unit);
   1433 #endif /* BCM_SW_STATE_DUMP_DISABLE */
   1434 
   1435 extern int bcm_xgs3_port_rate_ingress_set(int unit, bcm_port_t port,
   1436                                  uint32 kbits_sec, 
   1437                                  uint32 kbits_burst);
   1438 extern int bcm_xgs3_port_rate_ingress_get(int unit, bcm_port_t port,
   1439                                  uint32 *kbits_sec, 
   1440                                  uint32 *kbits_burst);
   1441 extern int bcm_fb_port_rate_pause_get(int unit, bcm_port_t port,
   1442                                uint32 *kbits_pause, 
   1443                                uint32 *kbits_resume);
   1444 
   1445 extern int _bcm_fb_port_protocol_vlan_add(int unit, bcm_port_t port,
   1446                                           bcm_port_frametype_t frame,
   1447                                           bcm_port_ethertype_t ether, 
   1448                                           bcm_vlan_t vid);
   1449 extern int _bcm_fb_port_protocol_vlan_delete(int unit, bcm_port_t port,
   1450                                              bcm_port_frametype_t frame,
   1451                                              bcm_port_ethertype_t ether);
   1452 extern int _bcm_fb_port_untagged_vlan_data_update(int unit, bcm_port_t port,
   1453                                                   bcm_vlan_t pdvid, 
   1454                                                   bcm_vlan_t ndvid);
   1455  
   1456 extern int _bcm_fb_port_tpid_get(int unit, bcm_port_t port, uint16 *tpid);
   1457 extern int _bcm_fb_port_tpid_set(int unit, bcm_port_t port, uint16 tpid);
   1458 extern int _bcm_fb_port_dtag_mode_set(int unit, bcm_port_t port, int mode, 
   1459                                       int dt_mode, int ignore_tag);
   1460 extern int _bcm_fb_port_dtag_mode_get(int unit, bcm_port_t port, int *mode);
   1461 
   1462 #if defined(BCM_FIREBOLT2_SUPPORT) || defined(BCM_TRX_SUPPORT) || \
   1463         defined(BCM_RAVEN_SUPPORT)
   1464 extern int _bcm_fb2_egr_vlan_control_field_set(int unit, bcm_port_t port,
   1465                                                soc_field_t field, uint32 value);
   1466 extern int _bcm_fb2_port_tpid_get(int unit, bcm_port_t port, uint16 *tpid);
   1467 extern int _bcm_fb2_port_tpid_set(int unit, bcm_port_t port, uint16 tpid, int *index);
   1468 extern int _bcm_fb2_port_tpid_delete_all(int unit, bcm_port_t port);
   1469 extern int _bcm_fb2_port_tpid_delete(int unit, bcm_port_t port, uint16 tpid);
   1470 extern int _bcm_fb2_port_tpid_add(int unit, bcm_port_t port, uint16 tpid, 
   1471                                   int color_select);
   1472 extern int _bcm_fb2_port_tpid_get_all(int unit, bcm_port_t port, int size, 
   1473                         uint16 *tpid_array,int *color_array, int *count);
   1474 extern int _bcm_xgs3_vlan_profile_detach(int unit);
   1475 #endif /* BCM_FIREBOLT2_SUPPORT || BCM_TRX_SUPPORT || BCM_RAVEN_SUPPORT */
   1476 
   1477 extern int bcm_xgs3_port_sample_rate_set(int unit, bcm_port_t port, 
   1478                                 int ingress_rate, int egress_rate);
   1479 extern int bcm_xgs3_port_sample_rate_get(int unit, bcm_port_t port, 
   1480                                 int *ingress_rate, int *egress_rate);
   1481 
   1482 extern int _bcm_xgs3_l2mc_size_get(int unit, int *size);
   1483 extern int _bcm_xgs3_l2mc_index_is_set(int unit, int l2mc_id, int *is_set);
   1484 extern int _bcm_xgs3_l2mc_free_index(int unit, int *l2mc_id);
   1485 extern int _bcm_xgs3_l2mc_id_alloc(int unit, int l2mc_id);
   1486 extern int _bcm_xgs3_l2mc_id_free(int unit, int l2mc_id);
   1487 extern int bcm_xgs3_l2_addr_mcast_delete_all(int unit);
   1488 extern int bcm_xgs3_mcast_addr_add(int, bcm_mcast_addr_t *);
   1489 extern int bcm_xgs3_mcast_addr_remove(int, bcm_mac_t, bcm_vlan_t);
   1490 extern int bcm_xgs3_mcast_port_get(int, bcm_mac_t, bcm_vlan_t,
   1491                              bcm_mcast_addr_t *);
   1492 extern int _bcm_xgs3_mcast_index_port_get(int unit, int l2mc_index, 
   1493                                bcm_mcast_addr_t *mcaddr);
   1494 extern int bcm_xgs3_mcast_init(int);
   1495 extern int bcm_xgs3_mcast_addr_add_w_l2mcindex(int unit,
   1496                                          bcm_mcast_addr_t *mcaddr);
   1497 extern int bcm_xgs3_mcast_addr_remove_w_l2mcindex(int unit,
   1498                                             bcm_mcast_addr_t *mcaddr);
   1499 extern int bcm_xgs3_mcast_port_add(int unit, bcm_mcast_addr_t *mcaddr);
   1500 extern int bcm_xgs3_mcast_port_remove(int unit, bcm_mcast_addr_t *mcaddr);
   1501 extern int _bcm_xgs3_mcast_detach(int unit);
   1502 
   1503 extern int bcm_xgs3_stg_stp_init(int unit, bcm_stg_t stg);
   1504 extern int bcm_xgs3_stg_stp_set(int unit, bcm_stg_t stg, 
   1505                          bcm_port_t port, int stp_state);
   1506 extern int bcm_xgs3_stg_stp_get(int unit, bcm_stg_t stg, 
   1507                          bcm_port_t port, int *stp_state);
   1508 
   1509 extern uint32 _bcm_xgs3_vlan_mcast_idx_get(int unit, const void *entbuf,
   1510                         soc_field_t field);
   1511 extern void _bcm_xgs3_vlan_mcast_idx_set(int unit, void *entbuf,
   1512                         soc_field_t field, uint32 fval);
   1513 extern int bcm_xgs3_vlan_init(int unit, bcm_vlan_data_t *vd);
   1514 extern int bcm_xgs3_vlan_create(int unit, bcm_vlan_t vid);
   1515 extern int bcm_xgs3_vlan_destroy(int unit, bcm_vlan_t vid);
   1516 extern int bcm_xgs3_vlan_port_add(int unit, bcm_vlan_t vid, pbmp_t pbmp,
   1517                                   pbmp_t ubmp, pbmp_t ing_pbmp);
   1518 extern int bcm_xgs3_vlan_port_remove(int unit, bcm_vlan_t vid, pbmp_t pbmp,
   1519                                      pbmp_t ubmp, pbmp_t ing_pbmp);
   1520 extern int _bcm_xgs3_vlan_table_port_add(int unit, bcm_vlan_t vid, pbmp_t pbmp,
   1521                               pbmp_t ubmp, pbmp_t ing_pbmp, int table);
   1522 extern int _bcm_xgs3_vlan_table_port_remove(int unit, bcm_vlan_t vid, pbmp_t pbmp,
   1523                                  pbmp_t ubmp, pbmp_t ing_pbmp, int table);
   1524 extern int bcm_xgs3_vlan_port_get(int unit, bcm_vlan_t vid, pbmp_t *pbmp,
   1525                                   pbmp_t *ubmp, pbmp_t *ing_bmp);
   1526 extern int _bcm_xgs3_vlan_table_port_get(int unit, bcm_vlan_t vid, pbmp_t *pbmp,
   1527                               pbmp_t *ubmp, pbmp_t *ing_pbmp, uint32 table);
   1528 extern int bcm_xgs3_vlan_stg_get(int unit, bcm_vlan_t vid, 
   1529 			   bcm_stg_t *stg_ptr);
   1530 extern int bcm_xgs3_vlan_stg_set(int unit, bcm_vlan_t vid, bcm_stg_t stg);
   1531 extern int bcm_xgs3_vlan_reload(int unit, vbmp_t *bmp, int *count);
   1532 extern int _bcm_xgs3_vlan_mcast_flood_set(int unit,
   1533                             bcm_vlan_t vlan,
   1534                             bcm_vlan_mcast_flood_t mode);
   1535 extern int _bcm_xgs3_vlan_mcast_flood_get(int unit,
   1536                             bcm_vlan_t vlan,
   1537                             bcm_vlan_mcast_flood_t *mode);
   1538 extern int _bcm_xgs3_vlan_control_vlan_set(int unit, bcm_vlan_t vid,
   1539                             uint32 valid_fields, bcm_vlan_control_vlan_t *control);
   1540 extern int _bcm_xgs3_vlan_control_vlan_get(int unit, bcm_vlan_t vid,
   1541                             uint32 valid_fields, bcm_vlan_control_vlan_t *control);
   1542 extern int _bcm_xgs3_vlan_control_vpn_set(int unit, bcm_vlan_t vid,
   1543                             uint32 valid_fields, bcm_vlan_control_vlan_t *control);
   1544 extern int _bcm_xgs3_vlan_control_vpn_get(int unit, bcm_vlan_t vid,
   1545                             uint32 valid_fields, bcm_vlan_control_vlan_t *control);
   1546 
   1547 extern int _bcm_fb_vlan_translate_add(int unit, int port, 
   1548                                       bcm_vlan_t old_vid,
   1549                                       bcm_vlan_t new_vid, 
   1550                                       int prio, int xtable);
   1551 extern int _bcm_fb_vlan_translate_delete(int unit, int port, 
   1552                                          bcm_vlan_t old_vid,int xtable);
   1553 extern int _bcm_fb_vlan_translate_get(int unit, int port, bcm_vlan_t old_vid,
   1554                                       bcm_vlan_t *new_vid, int *prio, int xtable);
   1555 extern int _bcm_fb_vlan_translate_traverse_int_cb(int unit, void *trv_info);
   1556 extern int _bcm_fb_vlan_translate_parse(int unit, soc_mem_t mem, uint32* vent,
   1557                              _bcm_vlan_translate_traverse_t *trvs_info);
   1558 extern int bcm_fb_cosq_init(int unit);
   1559 extern int bcm_fb_cosq_detach(int unit, int software_state_only);
   1560 extern int bcm_fb_cosq_config_set(int unit, int numq);
   1561 extern int bcm_fb_cosq_config_get(int unit, int *numq);
   1562 extern int bcm_fb_er_cosq_mapping_set(int unit,
   1563 				      bcm_port_t port,
   1564 				      bcm_cos_t priority,
   1565 				      bcm_cos_queue_t cosq);
   1566 extern int bcm_fb_er_cosq_mapping_get(int unit,
   1567 				      bcm_port_t port,
   1568 				      bcm_cos_t priority,
   1569 				      bcm_cos_queue_t *cosq);
   1570 extern int bcm_fb_cosq_port_sched_set(int unit, bcm_pbmp_t, int mode,
   1571                                const int weights[], int delay);
   1572 extern int bcm_fb_cosq_port_sched_get(int unit, bcm_pbmp_t, int *mode,
   1573                                int weights[], int *delay);
   1574 extern int bcm_fb_cosq_sched_weight_max_get(int unit, int mode,
   1575                                      int *weight_max);
   1576 extern int bcm_fb_cosq_port_bandwidth_set(int unit, bcm_port_t port,
   1577                                           bcm_cos_queue_t cosq,
   1578                                           uint32 kbits_sec_min,
   1579                                           uint32 kbits_sec_max,
   1580                                           uint32 kbits_sec_burst,
   1581                                           uint32 flags);
   1582 extern int bcm_fb_cosq_port_bandwidth_get(int unit, bcm_port_t port,
   1583                                           bcm_cos_queue_t cosq,
   1584                                           uint32 *kbits_sec_min,
   1585                                           uint32 *kbits_sec_max,
   1586                                           uint32 *kbits_sec_burst,
   1587                                           uint32 *flags);
   1588 extern int
   1589 _bcm_xgs3_protocol_pkt_ctrl_set(int unit, int old_protocol_pkt_index,
   1590                                 bcm_vlan_protocol_packet_ctrl_t *protocol_pkt,
   1591                                 int *protocol_pkt_index);
   1592 extern int
   1593 _bcm_xgs3_protocol_pkt_ctrl_get(int unit, int proto_index,
   1594                                 bcm_vlan_protocol_packet_ctrl_t *protocol_pkt);
   1595 extern int
   1596 _bcm_xgs3_protocol_packet_actions_validate(int unit,
   1597                                       bcm_vlan_protocol_packet_ctrl_t *pkt);
   1598 
   1599 #ifdef BCM_FIREBOLT2_SUPPORT
   1600 extern int bcm_fb2_cosq_port_pps_set(int unit, bcm_port_t port,
   1601                                      bcm_cos_queue_t cosq, int pps);
   1602 extern int bcm_fb2_cosq_port_pps_get(int unit, bcm_port_t port,
   1603                                      bcm_cos_queue_t cosq, int *pps);
   1604 extern int bcm_fb2_cosq_port_burst_set(int unit, bcm_port_t port,
   1605                                        bcm_cos_queue_t cosq, int burst);
   1606 extern int bcm_fb2_cosq_port_burst_get(int unit, bcm_port_t port,
   1607                                        bcm_cos_queue_t cosq, int *burst);
   1608 #endif /* BCM_FIREBOLT2_SUPPORT */
   1609 extern int bcm_fb_cosq_discard_set(int unit, uint32 flags);
   1610 extern int bcm_fb_cosq_discard_get(int unit, uint32 *flags);
   1611 extern int bcm_fb_cosq_discard_port_set(int unit, bcm_port_t port,
   1612                                  bcm_cos_queue_t cosq,
   1613                                  uint32 color,
   1614                                  int drop_start,
   1615                                  int drop_slope,
   1616                                  int average_time);
   1617 extern int bcm_fb_cosq_discard_port_get(int unit, bcm_port_t port,
   1618                                  bcm_cos_queue_t cosq,
   1619                                  uint32 color,
   1620                                  int *drop_start,
   1621                                  int *drop_slope,
   1622                                  int *average_time);
   1623 #ifdef BCM_WARM_BOOT_SUPPORT
   1624 extern int bcm_fb_cosq_sync(int unit);
   1625 #endif /* BCM_WARM_BOOT_SUPPORT */
   1626 #ifndef BCM_SW_STATE_DUMP_DISABLE
   1627 extern void bcm_fb_cosq_sw_dump(int unit);
   1628 #endif /* BCM_SW_STATE_DUMP_DISABLE */
   1629 
   1630 #ifdef INCLUDE_L3
   1631 extern int bcm_xgs3_l3_fbx_defip_init(int unit);
   1632 extern int bcm_xgs3_l3_fbx_defip_deinit(int unit);
   1633 extern int bcm_xgs3_l3_egress_mode_set(int unit, int mode);
   1634 extern int _bcm_xgs3_l3_multipathCountUpdate (int unit, int set);
   1635 extern int bcm_xgs3_l3_egress_mode_get(int unit, int *mode);
   1636 extern int bcm_xgs3_l3_ingress_mode_set(int unit, int mode);
   1637 extern int bcm_xgs3_l3_ingress_mode_get(int unit, int *mode);
   1638 extern int bcm_xgs3_l3_host_as_route_return_set(int unit, int mode);
   1639 extern int bcm_xgs3_l3_host_as_route_return_get(int unit, int *mode);
   1640 extern int bcm_xgs3_l3_ingress_intf_map_set(int unit, int mode);
   1641 extern int bcm_xgs3_l3_ingress_intf_map_get(int unit, int *mode);
   1642 
   1643 
   1644 extern int bcm_xgs3_l3_tables_init(int unit);
   1645 extern int bcm_xgs3_l3_tables_cleanup(int);
   1646 extern int bcm_xgs3_l3_enable(int, int);
   1647 extern int bcm_xgs3_l3_intf_get(int, _bcm_l3_intf_cfg_t *);
   1648 extern int bcm_xgs3_l3_intf_get_by_vid(int, _bcm_l3_intf_cfg_t *);
   1649 extern int bcm_xgs3_l3_intf_create(int, _bcm_l3_intf_cfg_t *);
   1650 extern int bcm_xgs3_l3_intf_id_create(int, _bcm_l3_intf_cfg_t *);
   1651 extern int bcm_xgs3_l3_intf_lookup(int, _bcm_l3_intf_cfg_t *);
   1652 extern int bcm_xgs3_l3_intf_del(int, _bcm_l3_intf_cfg_t *);
   1653 extern int bcm_xgs3_l3_intf_del_all(int);
   1654 
   1655 extern int bcm_xgs3_l3_ingress_create(int unit, 
   1656                                      bcm_l3_ingress_t *ing_intf, bcm_if_t *intf_id);
   1657 extern int bcm_xgs3_l3_ingress_destroy(int unit, bcm_if_t intf_id);
   1658 extern int bcm_xgs3_l3_ingress_get(int unit, bcm_if_t intf_id, bcm_l3_ingress_t *ing_intf);
   1659 extern int bcm_xgs3_l3_ingress_traverse(int unit, bcm_l3_ingress_traverse_cb trav_fn,
   1660                             void *user_data);
   1661 extern int bcm_xgs3_l3_ingress_find(int unit, bcm_l3_ingress_t *ing_intf, 
   1662                         bcm_if_t *intf_id);
   1663 
   1664 extern int bcm_xgs3_l3_egress_create(int unit, uint32 flags, 
   1665                                      bcm_l3_egress_t *egr, bcm_if_t *intf);
   1666 extern int bcm_xgs3_l3_egress_destroy(int unit, bcm_if_t intf);
   1667 extern int bcm_xgs3_l3_egress_get (int unit, bcm_if_t intf, 
   1668                                    bcm_l3_egress_t *egr);
   1669 extern int bcm_xgs3_l3_egress_find(int unit, bcm_l3_egress_t *egr, 
   1670                                     bcm_if_t *intf);
   1671 extern int bcm_xgs3_l3_egress_traverse(int unit, 
   1672                                        bcm_l3_egress_traverse_cb trav_fn,
   1673                                        void *user_data);
   1674 extern int bcm_xgs3_l3_egress_multipath_create(int unit, uint32 flags, 
   1675                                                uint32 ecmp_flags,
   1676                                                int intf_count, 
   1677                                                bcm_if_t *intf_array, 
   1678                                                bcm_if_t *mpintf,
   1679                                                int primary_count,
   1680                                                SHR_BITDCL *dlb_member_bitmap);
   1681 extern int bcm_xgs3_l3_egress_multipath_max_create(int unit, uint32 flags, 
   1682                                     uint32 ecmp_flags,
   1683                                     int intf_count,
   1684                                     int max_paths,
   1685                                     bcm_if_t *intf_array, 
   1686                                     bcm_if_t *mpintf,
   1687                                     int primary_count,
   1688                                     SHR_BITDCL *dlb_member_bitmap);
   1689 extern int bcm_xgs3_l3_egress_ecmp_max_paths_get(int unit, bcm_if_t mpintf,
   1690                                                  int *max_paths, int *raw_max_paths);
   1691 extern int _bcm_xgs3_l3_ecmp_grp_info_get(int unit, int grp_idx, 
   1692                                           int *group_size, int *base_idx);
   1693 extern int _bcm_xgs3_l3_ecmp_grp_info_set(int unit, int grp_idx,
   1694                                           void *l3_ecmp_count,
   1695                                           void *initial_l3_ecmp_group,
   1696                                           int initial_l3_ecmp_flag,
   1697                                           int group_size, int base_idx,
   1698                                           int alternate_cnt,
   1699                                           uint32 ecmp_flags);
   1700 extern int _bcm_xgs3_l3_ecmp_info_get(int unit, bcm_l3_egress_ecmp_t *ecmp_info);
   1701 
   1702 extern int _bcm_xgs3_l3_ecmp_member_get(int unit, bcm_l3_egress_ecmp_t *ecmp_info, 
   1703                                         int ecmp_member_size, 
   1704                                         bcm_l3_ecmp_member_t *ecmp_member_array,
   1705                                         int *ecmp_member_count);
   1706 extern int _bcm_xgs3_l3_ecmp_member_set(int unit, bcm_l3_egress_ecmp_t *ecmp_info,
   1707                                         int ecmp_member_count, 
   1708                                         bcm_l3_ecmp_member_t *ecmp_member);
   1709 extern int bcm_xgs3_l3_ecmp_destroy(int unit, bcm_if_t ecmp_group_id);
   1710 extern int bcm_xgs3_l3_ecmp_get(int unit, bcm_l3_egress_ecmp_t *ecmp_info, 
   1711                                 int ecmp_member_size, 
   1712                                 bcm_l3_ecmp_member_t *ecmp_member_array, 
   1713                                 int *ecmp_member_count);
   1714 extern int bcm_xgs3_l3_ecmp_find(int unit, int ecmp_member_count, 
   1715                                  bcm_l3_ecmp_member_t *ecmp_member_array, 
   1716                                  bcm_l3_egress_ecmp_t *ecmp_info);
   1717 extern int bcm_xgs3_l3_ecmp_traverse(int unit, bcm_l3_ecmp_traverse_cb trav_fn,
   1718                                      void *user_data);
   1719 extern int bcm_xgs3_l3_egress_multipath_destroy(int unit, bcm_if_t mpintf);
   1720 extern int bcm_xgs3_l3_egress_multipath_get(int unit, bcm_if_t mpintf,
   1721                                             int intf_size,
   1722                                             bcm_if_t *intf_array, 
   1723                                             int *intf_count);
   1724 extern int bcm_xgs3_l3_egress_multipath_add(int unit, bcm_if_t mpintf, 
   1725                                             bcm_if_t intf);
   1726 extern int bcm_xgs3_l3_egress_multipath_delete(int unit, bcm_if_t mpintf,
   1727                                                bcm_if_t intf);
   1728 extern int bcm_xgs3_l3_egress_multipath_find(int unit, int intf_count,
   1729                                              bcm_if_t *intf_array, 
   1730                                              bcm_if_t *mpintf);
   1731 extern int bcm_xgs3_l3_egress_multipath_traverse(int unit,
   1732                              bcm_l3_egress_multipath_traverse_cb trav_fn,
   1733                              void *user_data);
   1734 extern int bcm_xgs3_l3_egress_ecmp_traverse(int unit,
   1735                              bcm_l3_egress_ecmp_traverse_cb trav_fn,
   1736                              void *user_data);
   1737 extern int bcm_xgs3_l3_get(int, _bcm_l3_cfg_t *);
   1738 extern int bcm_xgs3_l3_add(int, _bcm_l3_cfg_t *);
   1739 extern int bcm_xgs3_l3_del(int, _bcm_l3_cfg_t *);
   1740 extern int bcm_xgs3_l3_del_prefix(int, _bcm_l3_cfg_t *);
   1741 extern int bcm_xgs3_l3_del_intf(int, _bcm_l3_cfg_t *, int);
   1742 extern int bcm_xgs3_l3_del_all(int);
   1743 extern int bcm_xgs3_l3_replace(int, _bcm_l3_cfg_t *);
   1744 extern int bcm_xgs3_l3_age(int unit, uint32 flags, 
   1745                            bcm_l3_host_traverse_cb age_out, void *user_data);
   1746 extern int bcm_xgs3_l3_ip4_traverse(int unit, uint32 flags, uint32 start,
   1747                                     uint32 end, bcm_l3_host_traverse_cb cb,
   1748                                     void *user_data);
   1749 extern int bcm_xgs3_l3_ip6_traverse(int unit, uint32 flags, uint32 start,
   1750                                     uint32 end, bcm_l3_host_traverse_cb cb,
   1751                                     void *user_data);
   1752 
   1753 extern int bcm_xgs3_l3_conflict_get(int unit, bcm_l3_key_t *ipkey,
   1754                bcm_l3_key_t *cf_array, int cf_max, int *cf_count);
   1755 
   1756 extern int bcm_xgs3_defip_get(int, _bcm_defip_cfg_t *);
   1757 extern int bcm_xgs3_defip_find(int, _bcm_defip_cfg_t *);
   1758 extern int bcm_xgs3_defip_ecmp_get_all(int, _bcm_defip_cfg_t *,
   1759                                   bcm_l3_route_t *, int, int *);
   1760 extern int bcm_xgs3_defip_add(int unit, _bcm_defip_cfg_t *lpm_cfg);
   1761 extern int bcm_xgs3_defip_del(int unit, _bcm_defip_cfg_t *lpm_cfg);
   1762 extern int bcm_xgs3_defip_del_intf(int, _bcm_defip_cfg_t *, int);
   1763 extern int bcm_xgs3_defip_del_all(int);
   1764 extern int bcm_xgs3_defip_age(int unit, bcm_l3_route_traverse_cb age_out,
   1765                               void *user_data);
   1766 extern int bcm_xgs3_defip_traverse(int unit, int flags, 
   1767                                    uint32 start, uint32 end, 
   1768                                    bcm_l3_route_traverse_cb trav_fn, 
   1769                                    void *user_data);
   1770 extern int bcm_xgs3_defip_verify_internal_mem_usage(int unit);
   1771 
   1772 extern int bcm_xgs3_defip_ip4_traverse(int unit, uint32 start, uint32 end, 
   1773                                        bcm_l3_route_traverse_cb trav_fn, 
   1774                                        void *user_data);
   1775 extern int bcm_xgs3_defip_ip6_traverse(int unit, uint32 start, uint32 end, 
   1776                                        bcm_l3_route_traverse_cb trav_fn, 
   1777                                        void *user_data);
   1778 extern int bcm_xgs3_l3_ip6_prefix_map_get(int unit, int map_size, 
   1779                                           bcm_ip6_t *ip6_array, int *ip6_count);
   1780 extern int bcm_xgs3_l3_ip6_prefix_map_add(int unit, bcm_ip6_t ip6_addr);
   1781 extern int bcm_xgs3_l3_ip6_prefix_map_delete(int unit, bcm_ip6_t ip6_addr);
   1782 extern int bcm_xgs3_l3_ip6_prefix_map_delete_all(int unit);
   1783 
   1784 extern int bcm_xgs3_l3_info(int unit, bcm_l3_info_t *l3_info);
   1785 extern int bcm_xgs3_l3_get_by_index(int unit, int index, _bcm_l3_cfg_t *l3cfg);
   1786 extern int bcm_xgs3_l3_del_by_index(int unit, int index, int ip6_flag);
   1787 extern int bcm_xgs3_max_ecmp_get(int unit, int *max_paths);
   1788 extern int bcm_xgs3_max_ecmp_set(int unit, int max_paths);
   1789 
   1790 extern int bcm_xgs3_tunnel_terminator_add(int unit, 
   1791                                           bcm_tunnel_terminator_t *info);
   1792 extern int bcm_xgs3_tunnel_terminator_delete(int unit, 
   1793                                              bcm_tunnel_terminator_t *info);
   1794 extern int bcm_xgs3_tunnel_terminator_update(int unit,
   1795                                              bcm_tunnel_terminator_t *info);
   1796 extern int bcm_xgs3_tunnel_terminator_get(int unit,
   1797                                           bcm_tunnel_terminator_t *info);
   1798 extern int bcm_xgs3_tunnel_terminator_traverse(int unit, 
   1799                                          bcm_tunnel_terminator_traverse_cb cb,
   1800                                          void *user_data);
   1801 extern int bcm_xgs3_tunnel_initiator_set(int unit, bcm_l3_intf_t *intf,
   1802                                          bcm_tunnel_initiator_t *tunnel);
   1803 extern int bcm_xgs3_tunnel_initiator_clear(int unit, bcm_l3_intf_t *intf);
   1804 extern int bcm_xgs3_tunnel_initiator_get(int unit, bcm_l3_intf_t *intf,
   1805                                          bcm_tunnel_initiator_t *tunnel);
   1806 extern int bcm_xgs3_tunnel_initiator_traverse(int unit, 
   1807                                          bcm_tunnel_initiator_traverse_cb cb,
   1808                                          void *user_data);                                         
   1809 extern int bcm_xgs3_tunnel_dscp_map_create(int unit, uint32 flags, int *dscp_map_id);
   1810 extern int bcm_xgs3_tunnel_dscp_map_destroy(int unit, int dscp_map_id);
   1811 extern int bcm_xgs3_tunnel_dscp_map_set(int unit, int dscp_map_id,
   1812                                         bcm_tunnel_dscp_map_t *dscp_map);
   1813 extern int bcm_xgs3_tunnel_dscp_map_get(int unit, int dscp_map_id,
   1814                                         bcm_tunnel_dscp_map_t *dscp_map);
   1815 extern int bcm_xgs3_tunnel_config_set(int unit, bcm_tunnel_config_t *tconfig);
   1816 extern int bcm_xgs3_tunnel_config_get(int unit, bcm_tunnel_config_t *tconfig);
   1817 
   1818 extern int bcm_fb_er_ipmc_init(int unit);
   1819 extern int bcm_fb_er_ipmc_detach(int unit);
   1820 extern int bcm_fb_er_ipmc_get(int unit, int index, bcm_ipmc_addr_t *ipmc);
   1821 extern int bcm_fb_er_ipmc_lookup(int unit, int *index, bcm_ipmc_addr_t *ipmc);
   1822 extern int bcm_fb_er_ipmc_add(int unit, bcm_ipmc_addr_t *ipmc);
   1823 extern int bcm_fb_er_ipmc_put(int unit, int index, bcm_ipmc_addr_t *ipmc);
   1824 extern int bcm_fb_er_ipmc_delete(int unit, bcm_ipmc_addr_t *ipmc);
   1825 extern int bcm_fb_er_ipmc_delete_all(int unit);
   1826 extern int bcm_fb_er_ipmc_enable(int unit, int enable);
   1827 extern int bcm_fb_er_ipmc_src_port_check(int unit, int enable);
   1828 extern int bcm_fb_er_ipmc_src_ip_search(int unit, int enable);
   1829 extern int bcm_fb_er_ipmc_egress_port_set(int unit, bcm_port_t port,
   1830                                    const bcm_mac_t mac,  int untag,
   1831                                    bcm_vlan_t vid, int ttl_threshold);
   1832 extern int bcm_fb_er_ipmc_egress_port_get(int unit, bcm_port_t port,
   1833                                    sal_mac_addr_t mac, int *untag,
   1834                                    bcm_vlan_t *vid,
   1835                                    int *ttl_threshold);
   1836 extern int bcm_xgs3_ipmc_traverse(int unit, uint32 flags, bcm_ipmc_traverse_cb cb, 
   1837                                   void *user_data);
   1838 extern int bcm_xgs3_ipmc_age(int unit, uint32 flags, bcm_ipmc_traverse_cb age_cb,
   1839                              void *user_data);
   1840 extern int bcm_xgs3_ipmc_id_alloc(int unit, int ipmc_id);
   1841 extern int bcm_xgs3_ipmc_id_free(int unit, int ipmc_id);
   1842 extern int bcm_xgs3_ipmc_id_is_set(int unit, int ipmc_id, int *is_set);
   1843 extern int bcm_xgs3_ipmc_create(int unit, int *ipmc_id);
   1844 extern int _bcm_xgs3_ipmc_valid_as_hit_get(int unit, int *valid_as_hit);
   1845 
   1846 extern int bcm_fb_ipmc_repl_init(int unit);
   1847 extern int bcm_fb_ipmc_repl_detach(int unit);
   1848 extern int bcm_fb_ipmc_repl_get(int unit, int index, bcm_port_t port,
   1849                          bcm_vlan_vector_t vlan_vec);
   1850 extern int bcm_fb_ipmc_repl_add(int unit, int index, bcm_port_t port,
   1851                          bcm_vlan_t vlan);
   1852 extern int bcm_fb_ipmc_repl_delete(int unit, int index, bcm_port_t port,
   1853                             bcm_vlan_t vlan);
   1854 extern int _bcm_fb_ipmc_egress_intf_add(int unit, int ipmc_id,
   1855                                         bcm_port_t port, 
   1856                                         int nh_index, int is_l3);
   1857 extern int _bcm_fb_ipmc_egress_intf_delete(int unit, int ipmc_id,
   1858                                            bcm_port_t port, int if_max,
   1859                                            int nh_index, int is_l3);
   1860 #ifdef BCM_TRX_SUPPORT
   1861 extern int _bcm_tr_l3_ingress_interface_get(int unit, 
   1862                                             iif_entry_t *iif_hw_entry,
   1863                                             _bcm_l3_ingress_intf_t *iif);
   1864 extern int _bcm_tr_l3_ingress_interface_set(int unit, 
   1865                                             _bcm_l3_ingress_intf_t *iif,
   1866                                            iif_entry_t *iif_hw_entry, 
   1867                                            iif_entry_t *new_entry);
   1868 #endif
   1869 #ifdef BCM_TRIDENT2_SUPPORT
   1870 extern int _bcm_l3_iif_profile_recover(int unit, 
   1871                                        iif_profile_entry_t *l3_iif_profile,
   1872                                        uint8 index);
   1873 #endif
   1874 extern int bcm_fb_ipmc_repl_delete_all(int unit, int index,
   1875                                 bcm_port_t port);
   1876 extern int bcm_fb_ipmc_repl_set(int unit, int mc_index, bcm_port_t port,
   1877                                 bcm_vlan_vector_t vlan_vec);
   1878 extern int bcm_fb_ipmc_egress_intf_add(int unit, int index, bcm_port_t port,
   1879                                 bcm_l3_intf_t *l3_intf);
   1880 extern int bcm_fb_ipmc_egress_intf_delete(int unit, int index, bcm_port_t port,
   1881                                    bcm_l3_intf_t *l3_intf);
   1882 extern int bcm_fb_ipmc_egress_intf_set(int unit, int mc_index,
   1883                                        bcm_port_t port, int if_count,
   1884                                        bcm_if_t *if_array, int is_l3, int check_port);
   1885 extern int bcm_fb_ipmc_egress_intf_get(int unit, int mc_index,
   1886                                        bcm_port_t port,
   1887                                        int if_max, bcm_if_t *if_array,
   1888                                        int *if_count);
   1889 
   1890 extern int bcm_xgs3_nh_get(int unit, int nh_idx, bcm_l3_egress_t *nh_info);
   1891 extern int bcm_xgs3_nh_add(int unit, uint32 flags, 
   1892                            bcm_l3_egress_t *nh_info, int *index);
   1893 extern int bcm_xgs3_nh_del(int unit, uint32 flags, int nh_index);
   1894 extern int bcm_xgs3_ecmp_group_del(int unit, int ecmp_index, uint32 flags);
   1895 extern int bcm_xgs3_get_nh_from_egress_object(int unit, bcm_if_t intf,
   1896                                               uint32 *mpath_flag, int ref_count, int *index);
   1897 extern int bcm_xgs3_get_ref_count_from_nhi(int unit, uint32 flags,
   1898                                                int *ref_count, int nh_ecmp_index);
   1899 extern int bcmi_xgs3_l3_egress_ref_count_update(int unit, bcm_if_t intf,
   1900                                                   uint32 flags, int nh_ecmp_id, int inc_dec);
   1901 extern int bcmi_xgs3_fp_l3_egress_ref_count_update (int unit);
   1902 extern int bcm_xgs3_tnl_init_add(int unit, uint32 flags, 
   1903                                  bcm_tunnel_initiator_t *tnl_entry, int *index);
   1904 extern int bcm_xgs3_tnl_init_del(int unit, uint32 flags, int ent_index);
   1905 extern int _bcm_xgs3_l3_get_tunnel_id(int unit, int ifindex, int *tunnel_id);
   1906 extern int _bcm_xgs3_tbl_add(int unit, _bcm_l3_tbl_op_t *data);
   1907 extern int _bcm_xgs3_tbl_del(int unit, _bcm_l3_tbl_op_t *data);
   1908 
   1909 #ifdef BCM_TRIDENT2_SUPPORT
   1910 extern int _bcm_xgs3_l3_nh_nat_realm_id_valid_sync(int unit,
   1911                                                    uint8 **scache_ptr,
   1912                                                    int offset);
   1913 #endif
   1914 
   1915 #if defined(BCM_TRIDENT2_SUPPORT) || defined(BCM_GREYHOUND2_SUPPORT)
   1916 extern int _bcm_xgs3_l3_tnl_init_find(int unit, bcm_tunnel_initiator_t *info,
   1917                                       int *tnl_idx);
   1918 #endif /* BCM_TRIDENT2_SUPPORT || BCM_GREYHOUND2_SUPPORT */
   1919 extern int bcm_xgs3_multicast_egress_delete_all(int unit,
   1920                                                 bcm_multicast_t group);
   1921 extern int bcm_xgs3_multicast_egress_set(int unit, bcm_multicast_t group,
   1922                                          int port_count,
   1923                                          bcm_gport_t *port_array,
   1924                                          bcm_if_t *encap_array);
   1925 extern int _bcm_xgs3_multicast_ipmc_read(int unit, int ipmc_id, 
   1926                                          bcm_pbmp_t *l2_pbmp,
   1927                                          bcm_pbmp_t *l3_pbmp);
   1928 extern int bcm_xgs3_multicast_group_get(int unit, bcm_multicast_t group,
   1929                                         uint32 *flags);
   1930 extern int bcm_xgs3_multicast_group_traverse(int unit,
   1931                               bcm_multicast_group_traverse_cb_t trav_fn, 
   1932                                              uint32 flags, void *user_data);
   1933 extern int _bcm_xgs3_trvrs_flags_cmp(int unit, int req_flags,
   1934                                      int ent_flags, int *idx);
   1935 extern int _bcm_xgs3_l3_get_nh_info(int unit, _bcm_l3_cfg_t *l3cfg, int nh_idx);
   1936 extern void _bcm_xgs3_host_ent_init(int unit, _bcm_l3_cfg_t *l3cfg, int nh_valid,
   1937                                                        bcm_l3_host_t *host_info);
   1938 extern int bcm_xgs3_host_as_route(int unit, _bcm_l3_cfg_t *l3cfg,
   1939                                      int operation, int orig_rv);
   1940 extern int _bcm_xgs3_nh_init_add(int unit, _bcm_l3_cfg_t *l3cfg,
   1941                           _bcm_defip_cfg_t *lpm_cfg, int *index);
   1942 
   1943 extern int _bcm_xgs3_nh_entry_parse(int unit, uint32 *ing_entry_ptr, 
   1944                                     uint32 *egr_entry_ptr,  uint32 *egr_entry_2_ptr, uint32 index,
   1945                                     bcm_l3_egress_t *nh_entry, uint8 *nh_ent_type);
   1946 
   1947 extern int _bcm_xgs3_l3_intf_cmp(int unit, void *pattern, void *data1,
   1948                                          void *data2, int *cmp_result);
   1949 
   1950 extern int _bcm_fb_lpm_get(int unit, _bcm_defip_cfg_t *lpm_cfg, int *nh_ecmp_idx);
   1951 extern int _bcm_fb_lpm_add(int unit, _bcm_defip_cfg_t *lpm_cfg, int nh_ecmp_idx);
   1952 extern int _bcm_fb_lpm_del(int unit, _bcm_defip_cfg_t *lpm_cfg);
   1953 extern int _bcm_fb_lpm_update_match(int unit, _bcm_l3_trvrs_data_t *trv_data);
   1954 
   1955 /* The following are not implemented for Firebolt */
   1956 extern int bcm_xgs3_lpm_defip_sw_tbl_empty(int unit, int *count);
   1957 extern int bcm_xgs3_lpm_defip_hw_tbl_empty(int unit, int *count);
   1958 extern int bcm_xgs3_lpm_check_table(int unit);
   1959 extern int bcm_xgs3_lpm_delete(int unit, _bcm_defip_cfg_t *lpm_cfg);
   1960 extern int bcm_xgs3_lpm_insert(int unit, _bcm_defip_cfg_t *lpm_cfg);
   1961 extern int bcm_xgs3_lpm_lookup(int unit, ip_addr_t iproute,
   1962                                _bcm_defip_cfg_t* lpm_cfg);
   1963 extern int bcm_xgs3_adj_mac_add(int unit, bcm_mac_t dmac, int *index);
   1964 extern int bcm_xgs3_adj_mac_del(int unit, int ent_index);
   1965 extern int bcm_xgs3_l3_egress_id_parse(int unit, bcm_if_t intf, 
   1966                                        uint32 *flags, int *nh_ecmp_id);
   1967 extern int bcm_xgs3_l3_tbl_dma(int unit, soc_mem_t tbl_mem, uint16
   1968                                tbl_entry_sz, const char *descr, char **res_ptr,
   1969                                int *entry_count);
   1970 extern int bcm_xgs3_internal_lpm_vrf_calc(int unit, _bcm_defip_cfg_t *lpm_cfg, 
   1971                                            int *vrf_id, int *vrf_mask);
   1972 extern int bcm_ext_lpm_vrf_get(int unit, int vrf_id, int vrf_mask, int global);
   1973 extern int bcm_xgs3_l3_mask6_apply(bcm_ip6_t mask, bcm_ip6_t addr);
   1974 extern void bcm_xgs3_nh_inc_ref_count(int unit, int nh_index);
   1975 extern void bcm_xgs3_nh_dec_ref_count(int unit, int nh_index);
   1976 extern int bcm_xgs3_nh_ref_count_get(int unit, int nh_index, int *ref_count);
   1977 
   1978 extern int _bcm_xgs3_tbl_free_idx_get(int unit, _bcm_l3_tbl_op_t *data);
   1979 extern int bcm_xgs3_proxy_nh_add(int unit, uint32 flags, bcm_proxy_egress_t *proxy_nh_info, int *index);
   1980 extern int bcm_xgs3_proxy_nh_get(int unit, int nh_idx, bcm_proxy_egress_t *proxy_nh_info);
   1981 
   1982 #ifdef BCM_WARM_BOOT_SUPPORT
   1983 extern int _bcm_xgs3_ipmc_reinit(int unit);
   1984 extern int _bcm_xgs3_ipmc_repl_reload(int unit);
   1985 extern int _bcm_xgs3_l3_reinit(int unit);
   1986 extern int _bcm_fb_ipmc_sync(int unit, uint8 **scache_ptr);
   1987 extern int _bcm_fb_ipmc_scahce_size_get(int uint, uint32 *size);
   1988 extern int _bcm_fb_ipmc_repl_scache_recover(int unit, uint8 **scache_ptr);
   1989 #else
   1990 #define _bcm_xgs3_ipmc_reinit(_u)    (BCM_E_UNAVAIL)
   1991 #define _bcm_xgs3_ipmc_repl_reload(_u)    (BCM_E_UNAVAIL)
   1992 #define _bcm_xgs3_l3_reinit(_u)    (BCM_E_UNAVAIL)
   1993 #define _bcm_fb_ipmc_sync(_u, _s)    (BCM_E_UNAVAIL)
   1994 #define _bcm_fb_ipmc_scahce_size_get(_u, _s)    (BCM_E_UNAVAIL)
   1995 #define _bcm_fb_ipmc_repl_scache_recover(_u, _s)    (BCM_E_UNAVAIL)
   1996 #endif /* BCM_WARM_BOOT_SUPPORT */
   1997 
   1998 #ifndef BCM_SW_STATE_DUMP_DISABLE
   1999 extern void _bcm_xgs3_ipmc_sw_dump(int unit);
   2000 extern void _bcm_xgs3_ipmc_repl_sw_dump(int unit);
   2001 #endif /* BCM_SW_STATE_DUMP_DISABLE */
   2002 
   2003 /* clean l3 dependent state from other modules*/
   2004 extern void bcmi_l3_dependent_free_resources(int unit);
   2005 #endif /* INCLUDE_L3 */
   2006 
   2007 extern int bcm_fb_port_rate_egress_set(int unit, bcm_port_t port,
   2008                                 uint32 kbits_sec, 
   2009                                 uint32 kbits_burst, uint32 mode);
   2010 extern int bcm_fb_port_rate_egress_get(int unit, bcm_port_t port,
   2011                                 uint32 *kbits_sec, 
   2012                                 uint32 *kbits_burst, uint32 *mode);
   2013 
   2014 /* Utility routines for tracking outer tpid entries in Firebolt2 */
   2015 extern int _bcm_fb2_outer_tpid_detach(int unit);
   2016 extern int _bcm_fb2_outer_tpid_init(int unit); 
   2017 extern int _bcm_fb2_priority_map_init(int unit); 
   2018 extern int _bcm_fb2_outer_tpid_entry_delete(int unit, int index);
   2019 extern int _bcm_fb2_outer_tpid_entry_get(int unit, uint16 *tpid, int index);
   2020 extern uint16 _bcm_fb2_outer_tpid_default_get(int unit);
   2021 extern int _bcm_fb2_outer_tpid_entry_add(int unit, uint16 tpid, int *index);
   2022 extern int _bcm_fb2_outer_tpid_lkup(int unit, uint16, int *index);
   2023 extern int _bcm_fb2_outer_tpid_tab_lock(int unit);
   2024 extern int _bcm_fb2_outer_tpid_tab_unlock(int unit);
   2025 extern int _bcm_fb2_outer_tpid_tab_ref_count_add(int unit, int index, int count);
   2026 
   2027 /* Utility routines for metering and egress rate control */
   2028 extern uint8 _bcm_fb_kbits_to_bucketsize(uint32 kbits_burst);
   2029 extern uint32 _bcm_fb_bucketsize_to_kbits(uint8 reg_val);
   2030 
   2031 #if defined(BCM_FIREBOLT2_SUPPORT) || defined(BCM_RAPTOR_SUPPORT) || \
   2032     defined(BCM_TRX_SUPPORT)
   2033 /* Utility routines for metering and egress rate control */
   2034 extern uint32 _bcm_fb2_kbits_to_bucket_encoding(uint32 kbits_burst,
   2035                                                 int linear_mode);
   2036 extern uint32 _bcm_fb2_bucket_encoding_to_kbits(uint32 reg_val,
   2037                                                 int linear_mode);
   2038 #endif /* BCM_FIREBOLT2_SUPPORT || BCM_RAPTOR_SUPPORT || BCM_TRIUMPH_SUPPORT */
   2039 
   2040 #if defined(BCM_FIREBOLT2_SUPPORT) || defined(BCM_RAPTOR_SUPPORT) || \
   2041     defined(BCM_TRX_SUPPORT)
   2042 /* Utility routines for metering and egress rate control */
   2043 #define _BCM_XGS_METER_FLAG_NON_LINEAR  0x01
   2044 #define _BCM_XGS_METER_FLAG_GRANULARITY 0x02
   2045 #define _BCM_XGS_METER_FLAG_PACKET_MODE 0x04
   2046 #define _BCM_XGS_METER_FLAG_FP_POLICER  0x08
   2047 #define _BCM_XGS_METER_FLAG_DOUBLE_REFRESH_FREQ  0x10
   2048 #define _BCM_XGS_METER_FLAG_NON_BURST_CORRECTION 0x20
   2049 #define _BCM_XGS_METER_FLAG_RESET 0x40
   2050 #define _BCM_XGS_METER_FLAG_BUCKET_IN_8KB 0x80
   2051 #define _BCM_XGS_METER_FLAG_GRANULARITY_SELECTIVE 0x100
   2052 #define _BCM_XGS_METER_FLAG_GRANULARITY_SELECT0 0x01000000
   2053 #define _BCM_XGS_METER_FLAG_GRANULARITY_SELECT1 0x02000000
   2054 #define _BCM_XGS_METER_FLAG_GRANULARITY_SELECT2 0x04000000
   2055 #define _BCM_XGS_METER_FLAG_GRANULARITY_SELECT3 0x08000000
   2056 #define _BCM_XGS_METER_FLAG_GRANULARITY_SELECT4 0x10000000
   2057 #define _BCM_XGS_METER_FLAG_GRANULARITY_SELECT5 0x20000000
   2058 #define _BCM_XGS_METER_FLAG_GRANULARITY_SELECT6 0x40000000
   2059 #define _BCM_XGS_METER_FLAG_GRANULARITY_SELECT7 0x80000000
   2060 #define _BCM_XGS_METER_FLAG_FP_TD2_POLICER 0x200
   2061 #define _BCM_XGS_METER_FLAG_REFRESH_RATE_15p625 0x400
   2062 
   2063 #define _BCM_XGS_METER_FLAG_GRANULARITY_SELECT_MASK 0xff000000
   2064 #define _BCM_XGS_METER_FLAG_GRANULARITY_SELECT_SHIFT 24
   2065 
   2066 extern int _bcm_xgs_kbits_to_bucket_encoding(uint32 kbits_sec,
   2067                                              uint32 kbits_burst,
   2068                                              uint32 flags,
   2069                                              int refresh_bitsize,
   2070                                              int bucket_max_bitsize,
   2071                                              uint32 *refresh_rate,
   2072                                              uint32 *bucketsize,
   2073                                              uint32 *granularity);
   2074 extern uint32 _bcm_xgs_bucket_encoding_to_kbits(uint32 refresh_rate,
   2075                                                 uint32 bucket_max,
   2076                                                 uint32 granularity,
   2077                                                 uint32 flags,
   2078                                                 uint32 *kbits_sec,
   2079                                                 uint32 *kbits_burst);
   2080 extern int _bcm_xgs_kbits_to_dual_bucket_encoding(uint32 kbits_sec,
   2081                                                   uint32 kbits_burst,
   2082                                                   uint32 flags,
   2083                                                   int refresh_bitsize,
   2084                                                   int bucket_max_bitsize,
   2085                                                   int granularity_start, 
   2086                                                   uint32 *refresh_rate,
   2087                                                   uint32 *bucketsize,
   2088                                                   uint32 *granularity);
   2089 #endif /* BCM_FIREBOLT2_SUPPORT || BCM_RAPTOR_SUPPORT || BCM_TRIUMPH_SUPPORT */
   2090 #if defined(BCM_KATANA_SUPPORT) || defined(BCM_TRIUMPH3_SUPPORT) || \
   2091     defined(BCM_GREYHOUND2_SUPPORT)
   2092 extern int _bcm_xgs_kbits_to_bucket_encoding_with_granularity(uint32 kbits_sec,
   2093                                              uint32 kbits_burst,
   2094                                              uint32 flags,
   2095                                              int refresh_bitsize,
   2096                                              int bucket_max_bitsize,
   2097                                              uint32 *refresh_rate,
   2098                                              uint32 *bucketsize,
   2099                                              uint32 *granularity);
   2100 
   2101 #endif /* BCM_KATANA_SUPPORT || BCM_TRIUMPH3_SUPPORT ||
   2102           BCM_GREYHOUND2_SUPPORT */
   2103 extern int bcm_fb_vlan_init(int unit, bcm_vlan_data_t *vd);
   2104 extern int bcm_fb_vlan_port_get(int unit, bcm_vlan_t vid,
   2105                          pbmp_t *pbmp, pbmp_t *ubmp);
   2106 extern int bcm_fb_vlan_stg_get(int unit, bcm_vlan_t vid, bcm_stg_t *stg_ptr);
   2107 
   2108 #ifdef BCM_FIELD_SUPPORT
   2109 #include <bcm_int/esw/field.h>
   2110 extern int _bcm_field_fb_init(int unit, _field_control_t *control);
   2111 
   2112 /* These functions are in src/bcm/esw/firebolt/field.c, 
   2113  * and used by firebolt, raptor, triumph */
   2114 extern int _bcm_field_fb_table_fpf_destroy(_qual_info_t **table, int size);
   2115 
   2116 extern int _bcm_field_fb_policer_install(int unit, _field_entry_t *f_ent, 
   2117                                          _field_policer_t *f_pl);
   2118 extern int _field_fb_policer_mem_get(int unit, _field_entry_t *f_ent,
   2119                                      soc_mem_t *mem);
   2120 extern int _bcm_field_fb_slice_clear(int unit, _field_group_t *fg, _field_slice_t *fs);
   2121 extern int _bcm_field_fb_group_install(int unit, _field_group_t *fg);
   2122 extern int _bcm_field_fb_selcodes_install(int unit, _field_group_t *fg, 
   2123                                           uint8 slice_numb, bcm_pbmp_t pbmp,
   2124                                           int selcode_index);
   2125 extern int _bcm_field_fb_write_slice_map(int unit, _field_stage_t *stage_fc,
   2126                                          _field_group_t *fg);
   2127 extern int _bcm_field_fb_mtp_release(int unit, _field_entry_t *f_ent, 
   2128                                      int tcam_idx);
   2129 extern int _bcm_field_fb_entry_remove(int unit, _field_entry_t *f_ent, 
   2130                                       int tcam_idx);
   2131 extern int _bcm_field_fb_entry_move(int unit, _field_entry_t *f_ent,
   2132                                     int parts_count, int *tcam_idx_old, 
   2133                                     int *tcam_idx_new);
   2134 extern void _bcm_field_fb_counter_adjust_wide_mode(int unit, 
   2135                                                    soc_mem_t policy_mem,
   2136                                                    _field_stat_t *f_st,
   2137                                                    _field_entry_t *f_ent_pri, 
   2138                                                    _field_entry_t *f_ent_sec, 
   2139                                                    int new_slice_numb,
   2140                                                    uint32 p_entry_pri[],
   2141                                                    uint32 p_entry_sec[]);
   2142 extern void _bcm_field_fb_meter_adjust_wide_mode(int unit, 
   2143                                                  soc_mem_t policy_mem,
   2144                                                  _field_policer_t *f_pl,
   2145                                                  _field_entry_t *f_ent_pri, 
   2146                                                  _field_entry_t *f_ent_sec, 
   2147                                                  uint32 p_entry_pri[],
   2148                                                  uint32 p_entry_sec[]);
   2149 extern int _field_fb_tcam_policy_mem_get(int unit, _field_stage_id_t stage_id,
   2150                                          soc_mem_t *tcam_mem,
   2151                                          soc_mem_t *policy_mem);
   2152 extern int _field_fb_tcam_policy_clear(int unit, _field_entry_t *f_ent,
   2153                                        _field_stage_id_t stage_id,
   2154                                        int tcam_idx);
   2155 extern int _bcm_field_entry_qual_get(int unit, bcm_field_entry_t entry,
   2156                                      int qual, _field_entry_t **entry_p);
   2157 
   2158 extern int _bcm_field_fb_meter_action_set(int unit, _field_entry_t *f_ent,
   2159                                           soc_mem_t mem, uint32 *buf);
   2160 extern int _bcm_field_fb_stat_hw_mode_to_bmap(int unit, uint16 mode, 
   2161                                               _field_stage_id_t stage_id, 
   2162                                               uint32 *hw_bmap,
   2163                                               uint8 *hw_entry_count);
   2164 extern int _bcm_field_fb_counter_get(int unit, _field_stage_t *stage_fc,
   2165                           soc_mem_t counter_x_mem, uint32 *mem_x_buf,
   2166                           soc_mem_t counter_y_mem, uint32 *mem_y_buf,
   2167                           int idx, uint64 *packet_count, uint64 *byte_count);
   2168 extern int _bcm_field_fb_counter_set(int unit, _field_stage_t *stage_fc,
   2169                           soc_mem_t counter_x_mem, uint32 *mem_x_buf,
   2170                           soc_mem_t counter_y_mem, uint32 *mem_y_buf,
   2171                           int idx, uint64 *packet_count, uint64 *byte_count);
   2172 extern int _bcm_field_fb_stat_index_get(int unit, _field_stat_t *f_st, 
   2173                                         bcm_field_stat_t stat,
   2174                                         int *idx1, int *idx2, int *idx3,
   2175                                         uint32 *flags);
   2176 extern int _bcm_field_fb_lookup_mode_set(int unit, uint8 slice_numb, 
   2177                                          _field_group_t *fg, uint8 flags);
   2178 extern int
   2179 _bcm_field_egress_selcode_satisfies_qset(_field_stage_t   *stage_fc,
   2180                                          bcm_field_qset_t *qset_req,
   2181                                          int primary, int secondary,
   2182                                          int *result);
   2183 extern int _bcm_field_fb_mode_set(int unit, uint8 slice_numb, 
   2184                                   _field_group_t *fg, uint8 flags);
   2185 extern int _bcm_field_fb_group_inner_vlan_overlay_get (int unit, int *value);
   2186 extern int _bcm_field_fb_data_qualifier_ethertype_delete(int unit, int qual_id,
   2187                                  bcm_field_data_ethertype_t *etype);
   2188 extern int _bcm_field_fb_data_qualifier_ethertype_add(int unit, int qual_id,
   2189                                  bcm_field_data_ethertype_t *etype);
   2190 extern int _bcm_field_fb_data_qualifier_ip_protocol_add(int unit,  int qual_id,
   2191                           bcm_field_data_ip_protocol_t *ip_protocol);
   2192 extern int _bcm_field_fb_data_qualifier_ip_protocol_delete(int unit,  int qual_id,
   2193                           bcm_field_data_ip_protocol_t *ip_protocol);
   2194 extern int _bcm_field_fb_data_qualifier_packet_format_add(int unit,int qual_id,
   2195                                 bcm_field_data_packet_format_t *packet_format);
   2196 extern int _bcm_field_fb_data_qualifier_packet_format_delete(int unit,int qual_id,
   2197                                 bcm_field_data_packet_format_t *packet_format);
   2198 extern int _bcm_field_fb_udf_ipprotocol_set(int unit, int index, 
   2199                                             uint32 flags, uint8 proto);
   2200 extern int _bcm_field_fb_udf_ipprotocol_get(int unit, int index, 
   2201                                             uint32 *flags, uint8 *proto);
   2202 extern int _bcm_field_fb_udf_ethertype_set(int unit, int index,
   2203                                            bcm_port_frametype_t frametype,
   2204                                            bcm_port_ethertype_t ethertype);
   2205 extern int _bcm_field_fb_udf_ethertype_get(int unit, int index,
   2206                                            bcm_port_frametype_t *frametype,
   2207                                            bcm_port_ethertype_t *ethertype);
   2208 extern int _bcm_field_fb_udf_ipprotocol_delete_all(int unit);
   2209 extern int _bcm_field_fb_udf_ethertype_delete_all(int unit);
   2210 extern int _bcm_field_fb_qualify_ip_type_encode_get(int unit,
   2211                                                     _field_group_t *fg,
   2212                                                     uint32 hw_data,
   2213                                                     uint32 hw_mask,
   2214                                                     bcm_field_IpType_t *type);
   2215 #if defined(BCM_FIREBOLT2_SUPPORT)
   2216 extern int _bcm_field_vfp_doublewide_key_select_get(int unit, int *value);
   2217 extern int _bcm_field_fb2_qualify_ttl(int unit, bcm_field_entry_t entry,
   2218                                       uint8 data, uint8 mask);
   2219 extern int _bcm_field_fb2_qualify_ttl_get(int unit, bcm_field_entry_t entry,
   2220                                           uint8 *data, uint8 *mask);
   2221 
   2222 #endif /* BCM_FIREBOLT2_SUPPORT */
   2223 
   2224 
   2225 #if defined(INCLUDE_L3)
   2226 int
   2227 _bcm_field_policy_set_l3_info(int unit, soc_mem_t mem, 
   2228                              int value, uint32 *buf);
   2229 int _bcm_fb_get_largest_prefix(int u, int ipv6, void *e,
   2230                               int *index, int *pfx_len, int* count);
   2231 int _bcm_fb_lpm_defip_cfg_get(int unit, int ipv6, void *defip_lpm_entry,
   2232                          _bcm_defip_cfg_t *lpm_cfg, int *nh_ecmp_idx);
   2233 int _bcm_fb_lpm128_add(int unit, _bcm_defip_cfg_t *lpm_cfg, int nh_ecmp_idx);
   2234 int _bcm_fb_lpm128_get(int unit, _bcm_defip_cfg_t *lpm_cfg, int *nh_ecmp_idx);
   2235 int _bcm_fb_lpm128_del(int unit, _bcm_defip_cfg_t *lpm_cfg);
   2236 int bcm_fb_lpm128_update_match(int unit, _bcm_l3_trvrs_data_t *trv_data);
   2237 int bcm_xgs3_l3_tbl_range_dma(int unit, soc_mem_t tbl_mem, uint16 tbl_entry_sz,
   2238                          const char *descr, int start, int end, char **res_ptr);
   2239 extern int _bcm_fb_lpm128_update_match(int unit, _bcm_l3_trvrs_data_t *trv_data);
   2240 int _bcm_fb_lpm128_get_smallest_movable_prefix(int u, int ipv6,
   2241                                               void *e, void *eupr, int *index,
   2242                                               int *pfx_len, int*count);
   2243 int
   2244 _bcm_fb_lpm128_defip_cfg_get(int unit, void *e, void *eupr, 
   2245                              _bcm_defip_cfg_t *lpm_cfg, int *nh_ecmp_idx);
   2246 int
   2247 _bcm_fb_lpm_ent_parse(int unit, _bcm_defip_cfg_t *lpm_cfg, int *nh_ecmp_idx,
   2248                       uint32 *lpm_entry, int *b128);
   2249 int
   2250 _bcm_xgs3_l3_egress_intf_ref_count_update(int unit, int intf_count,
   2251                                           bcm_if_t *intf_array, int inc_dec);
   2252 
   2253 
   2254 /* Egress multi flags and APIs */
   2255 
   2256 /* L3 Multiple Egress Object related flags. */
   2257 #define BCMI_L3_EGRESS_MULTI_WITH_ID (1 << 0)   /* Create multiple egress objects
   2258                                                   with id. */
   2259 
   2260 extern int
   2261 bcmi_l3_egress_multi_alloc(int unit, bcm_l3_egress_multi_info_t egress_multi_info,
   2262     bcm_if_t *base_egress_id);
   2263 extern int
   2264 bcmi_l3_egress_multi_free(int unit, bcm_if_t base_egress_id);
   2265 
   2266 #ifdef BCM_TRIDENT3_SUPPORT
   2267 extern int
   2268 bcmi_l3_intf_vpn_set(int unit, bcm_if_t l3_intf_id, bcm_vpn_t vpn, uint32 flags);
   2269 extern int
   2270 bcmi_l3_intf_vpn_get(int unit, bcm_if_t l3_intf_id, bcm_vpn_t *vpn, uint32 *flags);
   2271 extern int
   2272 bcmi_ecmp_dlb_status_get(int unit, int *dlb_status);
   2273 extern int
   2274 bcmi_ecmp_rh_status_get(int unit, int *rh_status);
   2275 #endif
   2276 
   2277 extern int
   2278 bcmi_l3_nh_multi_count_get(int unit, bcm_if_t nh_index);
   2279 
   2280 extern int
   2281 _bcm_fb_lpm_prepare_defip_entry(int unit, _bcm_defip_cfg_t *lpm_cfg,
   2282                                 int nh_ecmp_idx, uint32 *lpm_entry,
   2283                                 uint32 *lpm_entry_upr);
   2284 extern int
   2285 _bcm_fb_lpm_prepare_defip_data(int unit,
   2286                                _bcm_defip_cfg_t *lpm_cfg,
   2287                                int nh_ecmp_idx,
   2288                                uint32 *lpm_data,
   2289                                uint32 *lpm_hit,
   2290                                int upper);
   2291 
   2292 #endif /* INCLUDE_L3 */
   2293 #endif /* BCM_FIELD_SUPPORT */
   2294 
   2295 #endif  /* !_BCM_INT_FIREBOLT_H_ */