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

l3.h (29192B)


      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  * This file contains L3 definitions internal to the BCM library.
      8  */
      9 
     10 #ifndef _BCM_INT_L3_H
     11 #define _BCM_INT_L3_H
     12 
     13 #include <shared/bitop.h>
     14 
     15 #define INVALID_IP_ADDR		0xffffffff
     16 
     17 #define BCM_L3_IP6_MAX_NETLEN       128
     18 #define BCM_L3_IP6_MAX_NETLEN_FBER  64
     19 #define BCM_L3_IP4_MAX_NETLEN       32
     20 
     21 
     22 
     23 #define _BCM_DEFIP_IPMC_EXPECTED_L3IIF_MAX   \
     24     (SOC_IS_MONTEREY(unit) ? 0x3FF : (SOC_IS_HELIX5(unit) ? 0xFFF : 0x2FFF))
     25 #define _BCM_DEFIP_IPMC_RP_ID_BASE           \
     26     (SOC_IS_MONTEREY(unit) ? 0x400 : (SOC_IS_HELIX5(unit) ? 0x1000 : 0x3000))
     27 #define _BCM_DEFIP_IPMC_RP_SET(rp)           \
     28     (soc_feature(unit, soc_feature_l3defip_rp_l3iif_resolve) ? (rp) : \
     29      ((rp) | _BCM_DEFIP_IPMC_RP_ID_BASE))
     30 #define _BCM_DEFIP_IPMC_RP_GET(rp)           (rp & (~ _BCM_DEFIP_IPMC_RP_ID_BASE))
     31 #define _BCM_DEFIP_IPMC_RP_IS_SET(val)       ((val) > _BCM_DEFIP_IPMC_EXPECTED_L3IIF_MAX)
     32 
     33 extern void _bcm_xgs3_nh_ref_cnt_incr(int unit, unsigned idx);
     34 extern void _bcm_xgs3_nh_ref_cnt_get(int unit, uint32 idx, int ecmp,
     35                                      uint32 *ref_count);
     36 extern int _bcm_xgs3_ecmp_max_grp_size_get(int unit, int ecmp_group_id,
     37                                            int *grp_sz);
     38 extern int _bcm_esw_l3_egress_reference_get(int unit, bcm_if_t mpintf,
     39                                             int ecmp, uint32 *ref_count);
     40 extern int _bcm_esw_l3_egress_ref_dlb_update(int unit, int index,
     41                                             uint32 * ref_count);
     42 extern int bcmi_esw_l3_egress_ref_count_update(int unit, bcm_if_t intf,
     43                                     uint32 flags, int nh_ecmp_id, int incr);
     44 extern int _bcm_esw_l3_gport_construct(int unit, bcm_port_t port,
     45         bcm_module_t modid, bcm_trunk_t tgid, uint32 flags, bcm_port_t *gport);
     46 
     47 extern void bcmi_esw_l3_dependent_cleanup(int unit);
     48 extern int bcmi_l3_init_check(int unit);
     49 /* DGLP Calculation defines */
     50 
     51 /* Shift module value by 7 bits, since port number
     52  * occupies least significant 7 bits.
     53  */
     54 #define BCM_L3_DGLP_MODULE_SHIFT_BITS    7
     55 /* Port number is 7 bits. Maximum port number is 128 */
     56 #define BCM_L3_DGLP_PORT_MASK         0x7f
     57 /* Module id is 8 bits. Maximum modid is 255 */
     58 #define BCM_L3_DGLP_MODULE_ID_MASK       0xff
     59 
     60 #define BCM_L3_DGLP_GET(mod, port) \
     61                  (((mod & BCM_L3_DGLP_MODULE_ID_MASK) \
     62                  << BCM_L3_DGLP_MODULE_SHIFT_BITS) | \
     63                  (port & BCM_L3_DGLP_PORT_MASK))
     64 #define BCM_L3_DGLP_PORT_GET(dglp) \
     65                  (dglp & BCM_L3_DGLP_PORT_MASK)
     66 #define BCM_L3_DGLP_MODULE_ID_GET(dglp) \
     67                  ((dglp >> BCM_L3_DGLP_MODULE_SHIFT_BITS) & \
     68                   BCM_L3_DGLP_MODULE_ID_MASK)
     69 
     70 
     71 #ifdef INCLUDE_L3
     72 
     73 extern int _bcm_esw_l3_vrf_stat_get(int unit, int sync_mode,bcm_vrf_t vrf, 
     74                                    bcm_l3_vrf_stat_t stat, uint64 *val);
     75 #ifdef FB_LPM_DEBUG
     76 extern int lpm128_state_verify(int u);
     77 #endif
     78 
     79 #define LPM_L3_ADDR		0xffffffff
     80 
     81 #define BCM_L3_NO_IP6_SUPPORT(_unit_, _flags_) \
     82     (((_flags_) & BCM_L3_IP6) ?           \
     83      (soc_feature(_unit_, soc_feature_l3_ip6) ? FALSE : TRUE) : FALSE)
     84 
     85 #define BCM_L3_RPE_SET(_flags_) \
     86     (((_flags_) & BCM_L3_RPE) ? TRUE : FALSE)
     87 
     88 
     89 /* 5674 L3 interface defines */
     90 #define BCM_LYNX_L3_INTF_NUM_HI_SHIFT      9
     91 #define BCM_LYNX_L3_INTF_NUM_L0_MASK       0x1ff
     92 
     93 #define BCM_LYNX_LPM_NEXT_PTR_HI_SHIFT      12
     94 #define BCM_LYNX_LPM_NEXT_PTR_L0_MASK       0xfff
     95 
     96 #define _BCM_TR_L3_TRUST_DSCP_PTR_BIT_SIZE 6
     97 #define _BCM_TD_L3_TRUST_DSCP_PTR_BIT_SIZE 7
     98 
     99 /* Generic types. */
    100 #define BCM_L3_CMP_GREATER       (1)
    101 #define BCM_L3_CMP_EQUAL         (0)
    102 #define BCM_L3_CMP_LESS         (-1)
    103 #define BCM_L3_CMP_NOT_EQUAL     (2)
    104 
    105 /* ECMP member operations */
    106 #define BCM_L3_ECMP_MEMBER_OP_SET     0
    107 #define BCM_L3_ECMP_MEMBER_OP_ADD     1
    108 #define BCM_L3_ECMP_MEMBER_OP_DELETE  2
    109 #define BCM_L3_ECMP_MEMBER_OP_REPLACE 3
    110 
    111 /* L3 IP options Default Profile */
    112 #define BCM_L3_IP4_OPTIONS_DEF_PROFILE_INDEX 0x00
    113 
    114 /* L3 subsystem Bookkeeping flags */
    115 #define BCM_L3_BK_DISABLE_ADD_TO_ARL             (1 << 0)
    116 #define BCM_L3_BK_ENABLE_MACDA_OUI_PROFILE       (1 << 1)
    117 
    118 /* L3 ECMP DMA Threshold */
    119 #define L3_ECMP_MEM_DMA_THRESHOLD    512
    120 
    121 /*
    122  * Defines L3 interface
    123  */
    124 typedef struct _bcm_l3_intf_cfg_s {
    125     uint32       l3i_flags;         /* create or replace */
    126     bcm_vrf_t    l3i_vrf;           /* Virtual Router Instance (EZ only) */
    127     int          l3i_index;         /* interface number */
    128     bcm_mac_t    l3i_mac_addr;      /* MAC address for this interface */
    129     bcm_vlan_t   l3i_vid;           /* VLAN ID this interface is for */
    130     bcm_vlan_t   l3i_inner_vlan;    /* Inner VLAN ID for double tagged packets*/
    131     int          l3i_tunnel_idx;    /* tunnel index */
    132     int          l3i_ttl;           /* TTL threshold */
    133     int          l3i_mtu;           /* MTU */
    134     bcm_if_group_t  l3i_group;      /* Interface group number */
    135     bcm_l3_intf_qos_t  vlan_qos;
    136     bcm_l3_intf_qos_t  inner_vlan_qos;
    137     bcm_l3_intf_qos_t  dscp_qos;
    138 #ifdef BCM_TRIUMPH3_SUPPORT
    139     int l3i_class;                  /* Classification class ID */
    140 #endif /* BCM_TRIUMPH3_SUPPORT */
    141 #ifdef BCM_TRIDENT2_SUPPORT
    142     int l3i_ip4_options_profile_id; /* IP4 Options handling Profile ID */
    143     int l3i_nat_realm_id;           /* Interface realm for NAT */
    144 #endif /* BCM_TRIDENT2_SUPPORT */
    145 #if defined(BCM_TRIDENT2_SUPPORT) || defined(BCM_GREYHOUND2_SUPPORT)
    146     int l3i_intf_flags;             /* L3 intf flags */
    147 #endif /* BCM_TRIDENT2_SUPPORT || BCM_GREYHOUND2_SUPPORT */
    148 #ifdef BCM_RIOT_SUPPORT
    149     bcm_gport_t l3i_source_vp;      /* svp for routing in 
    150                                        VFI domain over HG flow */
    151 #endif
    152 #ifdef BCM_TRIDENT3_SUPPORT
    153     uint32 flow_handle;             /* FLOW handle for flex entries. */
    154     uint32 flow_option_handle;      /* FLOW option handle for flex entries. */
    155     bcm_flow_logical_field_t logical_fields[BCM_FLOW_MAX_NOF_LOGICAL_FIELDS]; /* logical fields array for flex entries */
    156     uint32 num_of_fields;           /* number of logical fields. */
    157 #endif /* BCM_TRIDENT3_SUPPORT */
    158 } _bcm_l3_intf_cfg_t;
    159 
    160 /*
    161  * Covers all info needed to config L3 table
    162  */
    163 typedef struct _bcm_l3_cfg_s {
    164     uint32        l3c_flags;        /* See <bcm/l3.h> BCM_L3_* */
    165     uint32        l3c_flags2;       /* See <bcm/l3.h> BCM_L3_* */
    166     bcm_vrf_t     l3c_vrf;          /* Virtual Router Instance (EZ only) */
    167     int           l3c_hw_index;     /* L3 table index */
    168     bcm_ip_t      l3c_ip_addr;      /* IPv4 address */
    169     bcm_ip_t      l3c_src_ip_addr;  /* Source IPv4 address (for IPMC) */
    170     bcm_ip_t      l3c_ip_mask;      /* used by delete by prefix */
    171     bcm_ip6_t     l3c_ip6;          /* IPv6 address */
    172     bcm_ip6_t     l3c_sip6;         /* IPv6 Source address (for IPMC) */
    173     bcm_ip6_t     l3c_ip6_mask;     /* IPv6 delete by prefix */
    174     bcm_vlan_t    l3c_vid;          /* VLAN ID (for IPMC 5695 only) */
    175     bcm_mac_t     l3c_mac_addr;     /* MAC address */
    176     bcm_if_t      l3c_intf;         /* L3 interface number */
    177     bcm_if_t      l3c_ing_intf;     /* L3 ingress Interface associated with this entry*/
    178     bcm_port_t    l3c_port_tgid;    /* port/TGID */
    179     bcm_port_t    l3c_stack_port;   /* Strata stack port if mod not local */
    180     int           l3c_modid;        /* MODID */
    181     int           l3c_tunnel;       /* Tunnel */
    182     int           l3c_prio;         /* Priority */
    183     int           l3c_ipmc_ptr;     /* 5690 index to IPMC table */
    184     int           l3c_lookup_class; /* Classification lookup class id. */
    185     int           l3c_ecmp;         /* Set this to 1 to indicate ECMP route */
    186     int           l3c_ecmp_count;   /* ECMP count */
    187     int           l3c_rp_id;        /* PIM-BIDIR Rendezvous point ID */
    188     int           l3c_eh_q_tag_type;/* EH queue tag type */
    189     int           l3c_eh_q_tag;     /* EH queue tag */
    190     bcm_if_t      l3c_encap_id;     /* Encapsulation index */
    191     int           l3c_flex_ctr_base_id; /* Base flex counter index */
    192     int           l3c_flex_ctr_mode;    /* Flex counter offset mode */
    193     int           l3c_flex_ctr_pool;    /* Flex counter pool number */
    194 #define l3c_ipmc_group   l3c_ip_addr
    195 #ifdef BCM_TRIDENT3_SUPPORT
    196     uint32        l3c_flow_handle;        /* FLOW handle for flex entries. */
    197     uint32        l3c_flow_option_handle; /* FLOW option handle for flex entries. */
    198     bcm_flow_logical_field_t l3c_logical_fields[BCM_FLOW_MAX_NOF_LOGICAL_FIELDS]; /* logical fields array for flex entries */
    199     uint32        l3c_num_of_fields;      /* number of logical fields. */
    200 #endif /* BCM_TRIDENT3_SUPPORT */
    201     int           l3c_ipmc_ptr_l2;  /* L3MC_INDEX_FOR_L2_DISTRIBUTION on TTL/RPF check failure */
    202 } _bcm_l3_cfg_t;
    203 
    204 /*
    205  * defip entry type used in _bcm_defip_cfg_t
    206  */
    207 typedef enum _bcm_defip_entry_type_e {
    208     bcmDefipEntryTypeIp = 0,
    209     bcmDefipEntryTypeFcoe = 1
    210 } _bcm_defip_entry_type;
    211 
    212 /*
    213  * All info needed to configure an IP route.
    214  */
    215 typedef struct _bcm_defip_cfg_s {
    216     uint32        defip_flags;       /* See <bcm/l3.h> BCM_L3_* */
    217     uint32        defip_flags2;      /* See <bcm/l3.h> BCM_L3_* */
    218     uint32        defip_ipmc_flags;  /* MC-ROUTE: See BCM_IPMC_xxx flag definitions. */
    219     bcm_vrf_t     defip_vrf;         /* Virtual Router Instance (EZ only) */
    220     bcm_ip_t      defip_ip_addr;     /* IPv4 subnet address */
    221     bcm_ip6_t     defip_ip6_addr;    /* IPv6 address */
    222     int           defip_sub_len;     /* Subnet prefix length */
    223     int           defip_index;       /* DEFIP table index (Strata only) */
    224     bcm_mac_t     defip_mac_addr;    /* Next hop MAC address (DA) */
    225     bcm_ip_t      defip_nexthop_ip;  /* Next hop IPv4 address */
    226     bcm_ip6_t     defip_nexthop_ip6; /* Next hop IPv6 address */
    227     int           defip_tunnel;      /* Tunnel */
    228     int           defip_prio;        /* Priority */
    229     bcm_if_t      defip_intf;        /* Hardware redirection index.
    230                                       * For Draco, this is an index into
    231                                       * the L3_INTF table.  For Tucana,
    232                                       * this is an index into the L3 table. */
    233     bcm_port_t    defip_port_tgid;   /* destination port */
    234     bcm_port_t    defip_stack_port;  /* Strata stack port if mod not local */
    235     int           defip_modid;       /* destination MODID */
    236     bcm_vlan_t    defip_vid;         /* For BCM5695 per VLAN default route only */
    237     int           defip_ecmp;        /* Set this to 1 to indicate ECMP route */
    238     int           defip_ecmp_count;  /* ECMP count */
    239     int           defip_ecmp_index;  /* ECMP table index (BCM5695 only) */
    240     int           defip_l3hw_index;  /* DEFIP route's L3 table index */
    241     uint32        defip_tunnel_option; /* Tunnel option value. */
    242     bcm_mpls_label_t defip_mpls_label; /* MPLS label.          */
    243     int           defip_lookup_class;/* Classification lookup class id. */
    244     _bcm_defip_entry_type defip_entry_type; /* Entry type, IP or FCOE */
    245     int           defip_fcoe_d_id;   /* D_ID for FCOE entries */
    246     int           defip_fcoe_d_id_mask;/* D_ID mask for FCOE entries */
    247     /* Used to indicate if the entry is in paired tcam or in unpaired TCAM */
    248     int           defip_flags_high; 
    249     int           defip_alpm_cookie; /* returns lookup result to be reused in
    250                                       * insert or delete for alpm */
    251     bcm_if_t      defip_expected_intf; /* MC-ROUTE: Expected L3 Interface used for
    252                                         * multicast RPF check */
    253     int           defip_l3a_rp;      /* MC-ROUTE: Rendezvous point ID */
    254     int           defip_source_port_tgid; /* Expected source port/trunk */
    255     int           defip_source_modid;     /* Expected source module */
    256     int           defip_source_ts;        /* Expected source is trunk? */
    257     bcm_multicast_t defip_mc_group;  /* MC-ROUTE: L3 Multicast group index */
    258 #ifdef BCM_TRIDENT3_SUPPORT
    259     uint32        defip_flow_handle;        /* FLOW handle for flex entries. */
    260     uint32        defip_flow_option_handle; /* FLOW option handle for flex entries. */
    261     uint32        defip_num_of_fields;      /* number of logical fields. */
    262     bcm_flow_logical_field_t defip_logical_fields[BCM_FLOW_MAX_NOF_LOGICAL_FIELDS]; /* logical fields array for flex entries */
    263 #endif /* BCM_TRIDENT3_SUPPORT */
    264     int           defip_flex_ctr_base_id; /* Base flex counter index */
    265     int           defip_flex_ctr_mode;    /* Flex counter offset mode */
    266     int           defip_flex_ctr_pool;    /* Flex counter pool number */
    267 
    268 #ifdef ALPM_ENABLE
    269     /* Used by ALPM */
    270     uint32        user_data[5];      /* Currently used by ALPM */
    271     void          *l1_pvt_node;
    272     void          *pvt_node;
    273     void          *bkt_node;
    274     void          *bkt_info;
    275     uint32        bkt_kshift;       /* carry down ACB pvt_key_len */
    276 
    277     void          *spl_opn;
    278     void          *spl_npn;
    279     void          *spl_pn;
    280     void          *tcam_write;      /* carry _alpm_tcam_write_t info for L1 pvt add during L2 bkt split */
    281     uint32        spl_key[5];
    282     int           spl_key_len;
    283     int           default_miss;     /* Used for pivot's default_miss in ALPM_TCAM_ZONED */
    284     int           fast_delete_all;  /* used only in TH3 fast delete_all */
    285 #endif
    286 } _bcm_defip_cfg_t;
    287 
    288 /*
    289  * Information of DEF_IP binary table (Strata only)
    290  */
    291 typedef struct _bcm_strata_defip_s {
    292     ip_addr_t 	defip_ip_addr;
    293     ip_addr_t 	defip_sub_len;
    294     int		defip_interface;
    295 } _bcm_strata_defip_t;
    296 
    297 /*
    298  * Node for hashed version of SW L3 table (XGS Switch)
    299  */
    300 typedef struct _bcm_l3hash_s {
    301     ip_addr_t l3h_ip_addr;
    302     ip_addr_t l3h_sip_addr;
    303     uint16    l3h_vid;       /* for 5695 IPMC only */
    304     uint16    l3h_flags;
    305     uint32    l3h_use_count;
    306 #define L3H_HOST      1
    307 #define L3H_LPM       2
    308 #define L3H_INVALID   4
    309 } _bcm_l3hash_t;
    310 
    311 /*
    312  * Information about the L3 table (XGS Switch)
    313  */
    314 typedef struct _bcm_l3_table_s {
    315     _bcm_l3hash_t   *l3_hash;    /* hashed version of SW L3 table */
    316     uint32          l3_min;      /* Min index */
    317     uint32          l3_max;      /* Total number of L3 table entries */
    318     uint32          l3_count;    /* Number of entries currently used */
    319 } _bcm_l3_table_t;
    320 
    321 /*
    322  * Definition of linked list of backup routes (XGS Switch)
    323  */
    324 typedef struct _bcm_backup_route_s {
    325     struct _bcm_backup_route_s  *next;
    326     uint16    l3_intf;               /* L3 interface number */
    327     uint16    l3_index;              /* index in L3 table */
    328     ip_addr_t ip_addr;               /* IP subnet address */
    329     unsigned  subnet_len:6;          /* subnet IP prefix len */
    330     unsigned  ecmp:1;                /* ecmp bit */
    331     unsigned  ecmp_count:6;          /* # of ECMP routes */
    332     unsigned  ecmp_index:11;         /* ECMP table index as in BCM5695 */
    333 } _bcm_backup_route_t;
    334 
    335 /*
    336  * Information of one LPM table entry (XGS Switch)
    337  */
    338 typedef struct _bcm_lpm_entry_s {
    339     _bcm_backup_route_t *backup_routes; /* Backup routes (shorter prefix) */
    340     uint16      forward;                /* index of forward LPM _block_ */
    341     uint16      parent;                 /* index of parent LPM _entry_ */
    342     uint16      l3_index;               /* L3 table index for this route */
    343     uint16      l3_intf;                /* L3 interface num for this route */
    344     ip_addr_t   ip_addr;                /* subnet IP address */
    345     unsigned    subnet_len:6;           /* subnet IP prefix len */
    346     unsigned    valid:1;                /* valid bit */
    347     unsigned    final:1;                /* stop bit */
    348     unsigned    dirty:1;                /* needs to be written to h/w tbl */
    349     unsigned    ecmp:1;                 /* ECMP route bit */
    350     unsigned    ecmp_count:6;           /* # of ECMP routes */
    351     unsigned    ecmp_index:11;          /* ECMP table index as in BCM5695 */
    352 } _bcm_lpm_entry_t;
    353 
    354 /*
    355  * Node for LPM update list
    356  */
    357 typedef struct _bcm_update_list_s {
    358     struct _bcm_update_list_s *next;
    359     uint16  block;
    360     uint32  offsets;
    361 } _bcm_update_list_t;
    362 
    363 /*
    364  * Per VLAN default route (Draco 1.5)
    365  */
    366 typedef struct _bcm_per_vlan_def_route_s {
    367     struct _bcm_per_vlan_def_route_s *next;
    368     bcm_vlan_t vid;
    369     uint16 l3_index;
    370 } _bcm_per_vlan_def_route_t;
    371 
    372 /*
    373  * Informatin about the LPM table (XGS Switch only)
    374  */
    375 typedef struct _bcm_l3_defip_table_s {
    376     _bcm_lpm_entry_t *l3_lpm;     /* SW shadow copy of LPM table */
    377     int def_route_index;          /* def route is last in l3_lpm table */
    378     _bcm_per_vlan_def_route_t *pv_def_route; /* Per VLAN def route (5695 only) */
    379     int global_def_route_set;     /* VLAN table based global default route */
    380     int lpm_based_def_route_set;  /* LPM based def route set */
    381 
    382     SHR_BITDCL *lpm_blk_used;     /* LPM bock usage bit mask */
    383     soc_mem_t lpm_mem;            /* name of the DEFIP memory */
    384     soc_mem_t lpmhit_mem;         /* name of the DEFIP HIT memory */
    385     int  lpm_min;                 /* min LPM index */
    386     int  lpm_max;                 /* max LPM index */
    387     int  lpm_block_max;           /* Max number of blocks in LPM table */
    388     int  lpm_block_used;          /* number of blocks used */
    389     int  lpm_entry_used;          /* number of entries used */
    390     int  ecmp_max_paths;          /* maximum number of ECMP paths allowed */
    391     int  ecmp_inuse;              /* in use, ecmp_max_paths cannot be changed */
    392 
    393     /*
    394      * These linked lists contain the entries need to be
    395      * written to HW LPM table after each insertion/deletion
    396      */
    397     _bcm_update_list_t *update_head;  /* head of linked list */
    398     _bcm_update_list_t *update_tail;  /* tail used for inverse the list */
    399 } _bcm_l3_defip_tbl_t;
    400 
    401 /*
    402  * define structure for per Group ECMP info
    403  */
    404 
    405 typedef struct _bcm_l3_ecmp_group_info_s {
    406     int max_paths;         /* Maximum number of ECMP paths per group. */
    407     int alternate_cnt;
    408     uint32 ecmp_flags;     /* Ecmp group flags */
    409 } _bcm_l3_ecmp_group_info_t;
    410 
    411 /*
    412  * define structure for per Group ECMP buffer
    413  */
    414 typedef struct _bcm_l3_ecmp_group_buffer_s {
    415     int        *group_buffer;      /* Ecmp group buffer */
    416     int        *dlb_group_buffer;  /* DLB group buffer */
    417 } _bcm_l3_ecmp_group_buffer_t;
    418 
    419 /*
    420  * define structure for user supplied data in DEFIP traverse
    421  */
    422 typedef struct _bcm_l3_defip_traverse_s {
    423     bcm_l3_route_traverse_cb trav_cb;
    424     void *user_data;
    425     int trav_start;
    426     int trav_end;
    427     int trav_index;
    428     bcm_l3_route_t *route_info;
    429 } _bcm_l3_defip_traverse_t;
    430 
    431 typedef int (*route_trav_cb_fn)(int unit, _bcm_lpm_entry_t *lpm_entry, void *data);
    432 
    433 /*
    434  * Software book keeping for L3 related information
    435  */
    436 typedef struct _bcm_l3_bookkeeping_s {
    437     uint8       l3_initialized;  /* Is L3 module init'ed ? */
    438     SHR_BITDCL *l3_intf_used;    /* L3 outgoing interface usage bit mask */
    439     SHR_BITDCL *add_to_arl;      /* L3 intf is added to ARL bit mask */
    440     int         l3_intf_table_size; /* max number of intf supported by chip */
    441     uint16      l3intf_count;    /* number of intf created */
    442     SHR_BITDCL *l3_iif_used;     /* L3 incoiming interface usage bit mask. */
    443     int         l3_iif_table_size;/* max number of ingress interfaces  */
    444     uint16      l3iif_count;     /* number of ingress interfaces created */
    445     _bcm_strata_defip_t *strata_defip_info;
    446                                  /* SW copy of DEF_IP table (Strata) */
    447     int      defip_table_size;   /* max DEF_IP table entries for chip */
    448     int      defip_count;        /* IP routes added, note each route takes
    449                                     more than one entries in LPM table */
    450     int      defip_ip6_count;    /* IPv6 routes added */
    451     int      l3_table_size;      /* chip L3 table size */
    452     int      l3_ip4_added;       /* IPv4 hosts added */
    453     int      l3_ip6_added;       /* IPv6 hosts added */
    454     int      l3_ipmc4_added;     /* IPv4 IPMC added */
    455     int      l3_ipmc6_added;     /* IPv6 IPMC added */
    456     int      l3_nh_added;        /* Egress Next hops added */
    457     int      l3_ecmp_grp_added;  /* ECMP groups added */
    458     int      ecmp_table_size;    /* max ECMP table entries (D1.5 only) */
    459     int      nh_table_size;      /* max next hop table */
    460     int      tunnel_table_size;  /* max tunnel table entries */
    461     int      dscp_map_size;      /* DSCP-map size */
    462     SHR_BITDCL *dscp_map_used;   /* DSCP-map usage bit mask */
    463     int      num_dscp_maps;      /* Number of DSCP maps available */
    464 #ifdef BCM_TRIDENT_SUPPORT
    465     int     *l3_trunk_nh_store; /* Store for Trunk nextHop */
    466 #endif /* BCM_TRIDENT_SUPPORT */
    467 #ifdef BCM_TRIUMPH2_SUPPORT
    468     int      l3_max_ecmp_mode;   /* ECMP grp scalability control */
    469 #endif /* BCM_TRIUMPH2_SUPPORT */
    470 #ifdef BCM_TRIDENT2_SUPPORT
    471     SHR_BITDCL *ip4_options_bitmap;   /* IP options usage bitmap*/
    472     uint32     *ip4_profiles_hw_idx;   /* IP options usage bitmap*/
    473 #endif /* BCM_TRIDENT2_SUPPORT */
    474     uint32    l3_ip6_max_128b_entries;  /* Max allowed 128b V6 entries */
    475     uint32    flags;             /* bookkeeping flags for L3 subsystem */
    476 #if defined(BCM_RIOT_SUPPORT) || defined(BCM_MULTI_LEVEL_ECMP_SUPPORT)
    477     uint32    l3_ecmp_levels;
    478     uint32    l3_ecmp_overlay_entries;
    479     uint32    l3_ecmp_rh_overlay_entries;
    480 #endif
    481 #ifdef BCM_RIOT_SUPPORT
    482     uint32    l3_intf_overlay_entries;
    483     uint32    l3_nh_overlay_entries;
    484     uint32    riot_enable;
    485 #endif
    486 #if defined (BCM_TOMAHAWK_SUPPORT) || defined (BCM_TRIDENT2PLUS_SUPPORT)
    487     uint8     mc_per_trunk_repl_mode; /* per trunk replication mode */
    488 #endif /* BCM_TOMAHAWK_SUPPORT || BCM_TRIDENT2PLUS_SUPPORT */
    489 #ifdef BCM_RIOT_SUPPORT
    490     uint32    l3_intf_overlay_alloc_mode;
    491     uint32    l3_nh_overlay_alloc_mode;
    492 #endif
    493     uint32   *l3_nh_multi_count;
    494     uint32    l3_nh_reserve_for_ecmp;
    495 #ifdef BCM_TRIDENT3_SUPPORT
    496     uint32    l3_ecmp_group_first_lkup_mem_size;
    497     uint32    l3_ecmp_member_first_lkup_mem_size;
    498 #endif
    499 } _bcm_l3_bookkeeping_t;
    500 
    501 extern _bcm_l3_bookkeeping_t  _bcm_l3_bk_info[BCM_MAX_NUM_UNITS];
    502 
    503 
    504 /*
    505  * L3 interface table usage bit mask operations
    506  */
    507 #define BCM_L3_INTF_USED_GET(_u_, _if_)                           \
    508         SHR_BITGET((_bcm_l3_bk_info[unit]).l3_intf_used, (_if_))
    509 #define BCM_L3_INTF_USED_SET(_u_, _if_)                           \
    510     {                                                             \
    511         SHR_BITSET((_bcm_l3_bk_info[unit]).l3_intf_used, (_if_)); \
    512         (_bcm_l3_bk_info[unit]).l3intf_count++;                   \
    513     }
    514 #define BCM_L3_INTF_USED_CLR(_u_, _if_)                           \
    515     {                                                             \
    516         SHR_BITCLR((_bcm_l3_bk_info[unit]).l3_intf_used, (_if_)); \
    517         (_bcm_l3_bk_info[unit]).l3intf_count--;                   \
    518     }
    519 #define BCM_L3_IIF_USED_GET(_u_, _if_)                           \
    520         SHR_BITGET((_bcm_l3_bk_info[unit]).l3_iif_used, (_if_))
    521 #define BCM_L3_IIF_USED_SET(_u_, _if_)                           \
    522     {                                                             \
    523         SHR_BITSET((_bcm_l3_bk_info[unit]).l3_iif_used, (_if_)); \
    524         (_bcm_l3_bk_info[unit]).l3iif_count++;                   \
    525     }
    526 #define BCM_L3_IIF_USED_CLR(_u_, _if_)                           \
    527     {                                                             \
    528         SHR_BITCLR((_bcm_l3_bk_info[unit]).l3_iif_used, (_if_)); \
    529         (_bcm_l3_bk_info[unit]).l3iif_count--;                   \
    530     }
    531 #define BCM_L3_INTF_ARL_GET(_u_, _if_) \
    532         SHR_BITGET((_bcm_l3_bk_info[unit]).add_to_arl, (_if_))
    533 #define BCM_L3_INTF_ARL_SET(_u_, _if_) \
    534         SHR_BITSET((_bcm_l3_bk_info[unit]).add_to_arl, (_if_))
    535 #define BCM_L3_INTF_ARL_CLR(_u_, _if_) \
    536         SHR_BITCLR((_bcm_l3_bk_info[unit]).add_to_arl, (_if_))
    537 
    538 #define BCM_L3_DSCP_MAP_USED_GET(_u_, _idx_) \
    539         SHR_BITGET((_bcm_l3_bk_info[unit]).dscp_map_used, (_idx_))
    540 #define BCM_L3_DSCP_MAP_USED_SET(_u_, _idx_) \
    541         SHR_BITSET((_bcm_l3_bk_info[unit]).dscp_map_used, (_idx_))
    542 #define BCM_L3_DSCP_MAP_USED_CLR(_u_, _idx_) \
    543         SHR_BITCLR((_bcm_l3_bk_info[unit]).dscp_map_used, (_idx_))
    544 
    545 /* Get and Set macros for bookkeeping FLAGs */
    546 #define BCM_L3_BK_FLAG_SET(_u_, _flag_)       \
    547         ((_bcm_l3_bk_info[unit]).flags) |= (_flag_)
    548 
    549 #define BCM_L3_BK_FLAG_GET(_u_, _flag_)       \
    550         (((_bcm_l3_bk_info[unit]).flags) & (_flag_) ? 1 : 0)
    551 
    552 /* L3X ROUTINES TO BE REMOVED FROM PUBLIC API */
    553 extern int bcm_l3_defip_traverse(int unit, bcm_l3_route_traverse_cb trav_fn,
    554                       uint32 start, uint32 end);
    555 
    556 extern int _bcm_esw_l3_egress_ecmp_get(int unit, bcm_l3_egress_ecmp_t *ecmp,
    557                                        int intf_size, bcm_if_t *intf_array,
    558                                        int *intf_count, int rh_retrieve);
    559 extern int _bcm_esw_l3_ecmp_create(int unit, bcm_l3_egress_ecmp_t *ecmp,
    560                                    int intf_count, bcm_if_t *intf_array, int op,
    561                                    int count, bcm_if_t *intf, int primary_count,
    562                                    SHR_BITDCL *dlb_member_bitmap);
    563 
    564 #define _BCM_EGR_IP_TUNNEL_MPLS_DOUBLE_WIDE(_u_, _tnl_type_)   \
    565        (((soc_feature((_u_), soc_feature_egr_ip_tnl_mpls_double_wide)) \
    566         || (soc_feature((_u_), soc_feature_th3_style_simple_mpls))) \
    567            && (_tnl_type_ == bcmTunnelTypeMpls))
    568 
    569 #define _BCM_EGR_IP_TUNNEL_DOUBLE_WIDE_ENTRY(unit, _tnl_type_)      \
    570        ((_BCM_EGR_IP_TUNNEL_MPLS_DOUBLE_WIDE(unit, _tnl_type_))  || \
    571        (_BCM_TUNNEL_OUTER_HEADER_IPV6(_tnl_type_)))
    572 
    573 
    574 #define _BCM_TUNNEL_OUTER_HEADER_IPV6(_tnl_type_)              \
    575        ((((_tnl_type_) == bcmTunnelTypeIp4In6)              || \
    576          ((_tnl_type_) == bcmTunnelTypeIp6In6)              || \
    577          ((_tnl_type_) == bcmTunnelTypeAutoMulticast6)      || \
    578          ((_tnl_type_) == bcmTunnelTypeIpAnyIn6)            || \
    579          ((_tnl_type_) == bcmTunnelTypeGre4In6)             || \
    580          ((_tnl_type_) == bcmTunnelTypeGre6In6)             || \
    581          ((_tnl_type_) == bcmTunnelTypeGreAnyIn6)           || \
    582          ((_tnl_type_) == bcmTunnelTypePim6SmDr1)           || \
    583          ((_tnl_type_) == bcmTunnelTypePim6SmDr2)           || \
    584          ((_tnl_type_) == bcmTunnelTypeRoeIn6)              || \
    585          ((_tnl_type_) == bcmTunnelTypeWlanWtpToAc6         || \
    586          ((_tnl_type_) == bcmTunnelTypeWlanAcToAc6))        || \
    587          ((_tnl_type_) == bcmTunnelTypeVxlan6)) ? TRUE : FALSE)
    588 
    589 #ifdef BCM_WARM_BOOT_SUPPORT
    590 extern int _bcm_l3_cleanup(int unit);
    591 #else
    592 #define    _bcm_l3_cleanup(u)   (BCM_E_NONE)
    593 #endif /* BCM_WARM_BOOT_SUPPORT */
    594 
    595 #ifdef BCM_WARM_BOOT_SUPPORT
    596 extern int _bcm_esw_l3_sync(int unit);
    597 #endif /* BCM_WARM_BOOT_SUPPORT */
    598 
    599 #ifndef BCM_SW_STATE_DUMP_DISABLE
    600 extern void _bcm_l3_sw_dump(int unit);
    601 extern void _bcm_tr_ext_lpm_sw_dump(int unit);
    602 #endif /* BCM_SW_STATE_DUMP_DISABLE */
    603 
    604 typedef struct bcmi_l3_egress_multi_info_s {
    605     uint32 flags;           /* See BCM_L3_EGRESS_MULTI_XXX flag definitions. */
    606     int number_of_elements; /* number of egress objects to allocate. */
    607 } bcmi_l3_egress_multi_info_t;
    608 
    609 #define BCMI_L3_EGRESS_SOURCE_MULTI_ADD         1
    610 #define BCMI_L3_EGRESS_SOURCE_SINGLE_ADD        2
    611 
    612 
    613 #define BCMI_L3_EGRESS_SOURCE_MASK              0xff 
    614 #define BCMI_L3_EGRESS_SOURCE_SHIFT             24
    615 #define BCMI_L3_EGRESS_SOURCE_VAL_MASK          0xffffff
    616 
    617 #define BCMI_L3_EGRESS_SOURCE_SET(type, val)    \
    618             ((((type) << BCMI_L3_EGRESS_SOURCE_SHIFT) | val))
    619 
    620 #define BCMI_L3_EGRESS_SOURCE_GET(val)    \
    621             ((((val) >> BCMI_L3_EGRESS_SOURCE_SHIFT) & BCMI_L3_EGRESS_SOURCE_MASK))
    622 
    623 
    624 /*
    625  * L3 l3table show flags
    626  */
    627 #define _BCM_L3_SHOW_INDEX    BCM_L3_VXLAN_ONLY
    628 
    629 #if defined(BCM_RIOT_SUPPORT) || defined(BCM_MULTI_LEVEL_ECMP_SUPPORT)
    630 
    631 /* ECMP Single level */
    632 #define BCMI_L3_ECMP_SINGLE_LEVEL         1
    633 
    634 /* Overlay validity checks */
    635 #define BCMI_L3_ECMP_IS_MULTI_LEVEL(_u) \
    636     (((&_bcm_l3_bk_info[unit])->l3_ecmp_levels) > BCMI_L3_ECMP_SINGLE_LEVEL)
    637 
    638 #define BCMI_L3_ECMP_OVERLAY_ENTRIES(_u) \
    639     ((&_bcm_l3_bk_info[_u])->l3_ecmp_overlay_entries)
    640 
    641 /* ECMP Macro flow overlay check */
    642 #define BCM_MACROFLOW_IS_OVERLAY(type) \
    643             ((type == bcmSwitchMacroFlowHashOverlayMinOffset) || \
    644              (type == bcmSwitchMacroFlowHashOverlayMaxOffset) || \
    645              (type == bcmSwitchMacroFlowHashOverlayStrideOffset))
    646 
    647 /* RioT Overlay validity checks */
    648 #define BCMI_RIOT_IS_ENABLED(_u) \
    649     ((&_bcm_l3_bk_info[_u])->riot_enable)
    650 
    651 #define BCMI_L3_NH_OVERLAY_VALID(_u) \
    652     ((BCMI_RIOT_IS_ENABLED(_u)) &&            \
    653     (((&_bcm_l3_bk_info[_u])->l3_nh_overlay_entries) > 0))
    654 
    655 #define BCMI_L3_INTF_OVERLAY_VALID(_u) \
    656     ((BCMI_RIOT_IS_ENABLED(_u)) &&            \
    657     (((&_bcm_l3_bk_info[_u])->l3_intf_overlay_entries) > 0))
    658 
    659 #define BCMI_RIOT_VPN_VFI_IS_SET(_u, _vid) \
    660     ((BCMI_RIOT_IS_ENABLED(_u)) && (_BCM_VPN_VFI_IS_SET((_vid))))
    661 
    662 #define BCMI_RIOT_VPN_VFI_IS_NOT_SET(_u, _vid) \
    663     ((!BCMI_RIOT_IS_ENABLED(_u)) || (!(_BCM_VPN_VFI_IS_SET((_vid)))))
    664 
    665 #define BCMI_GPORT_TYPE_GET(_gport)    \
    666         (((_gport) >> _SHR_GPORT_TYPE_SHIFT) & _SHR_GPORT_TYPE_MASK)
    667 
    668 #endif
    669 #endif	/* INCLUDE_L3 */
    670 
    671 #endif	/* !_BCM_INT_L3_H */