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 (118669B)


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