ipmc.h (12919B)
1 /* 2 * 3 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 4 * 5 * Copyright 2007-2020 Broadcom Inc. All rights reserved. 6 * 7 * This file contains IPMC definitions internal to the BCM library. 8 */ 9 10 #ifndef _BCM_INT_IPMC_H 11 #define _BCM_INT_IPMC_H 12 13 #include <bcm/types.h> 14 #include <bcm/ipmc.h> 15 16 #ifdef INCLUDE_L3 17 18 #define BCM_MC_PER_TRUNK_REPL_MODE(_u_) _bcm_l3_bk_info[_u_].mc_per_trunk_repl_mode 19 20 typedef struct _bcm_esw_ipmc_l3entry_info_s 21 { 22 uint32 flags; /* See <bcm/l3.h> BCM_L3_* */ 23 bcm_vrf_t vrf; /* Virtual Router Instance (EZ only) */ 24 bcm_ip_t ip_addr; /* IPv4 address */ 25 bcm_ip_t src_ip_addr; /* Source IPv4 address (for IPMC) */ 26 bcm_ip6_t ip6; /* IPv6 address */ 27 bcm_ip6_t sip6; /* IPv6 Source address (for IPMC) */ 28 bcm_vlan_t vid; /* VLAN ID (for IPMC 5695 only) */ 29 int prio; /* Priority */ 30 int ipmc_ptr; /* 5690 index to IPMC table */ 31 int lookup_class; /* Classification lookup class id. */ 32 int rp_id; /* Rendezvous point ID */ 33 bcm_if_t ing_intf; /* L3 ingress interface associated with this Entry */ 34 int ipmc_ptr_l2; /* l2 receivers for L3 errors */ 35 #if defined(BCM_TRIDENT3_SUPPORT) 36 uint32 flow_handle; /* FLOW handle for flex entries. */ 37 uint32 flow_option_handle; /* FLOW option handle for flex entries. */ 38 bcm_flow_logical_field_t logical_fields[BCM_FLOW_MAX_NOF_LOGICAL_FIELDS]; /* logical fields array for flex entries. */ 39 uint32 num_logical_fields; /* number of logical fields. */ 40 #endif 41 #define ipmc_group ip_addr 42 } _bcm_esw_ipmc_l3entry_info_t; 43 44 typedef struct _bcm_esw_ipmc_l3entry_s 45 { 46 int l3index; 47 int ip6; 48 _bcm_esw_ipmc_l3entry_info_t l3info; 49 struct _bcm_esw_ipmc_l3entry_s *next; 50 } _bcm_esw_ipmc_l3entry_t; 51 52 typedef struct _bcm_esw_ipmc_group_info_s 53 { 54 int ref_count; /* Reference count is incremented when a L3 entry pointing 55 to this IPMC group is added, or when bcm_multicast_create 56 allocates this IPMC index. */ 57 int defip_ref_count; /* Reference count is incremented when a DEFIP entry 58 pointing to this IPMC group is added */ 59 _bcm_esw_ipmc_l3entry_t *l3entry_list; /* Linked list of L3 entries 60 sharing this IPMC group */ 61 } _bcm_esw_ipmc_group_info_t; 62 63 typedef struct _bcm_esw_ipmc_s 64 { 65 int ipmc_initialized; 66 int ipmc_size; 67 int ipmc_count; 68 #if defined(BCM_XGS3_SWITCH_SUPPORT) 69 _bcm_esw_ipmc_group_info_t *ipmc_group_info; 70 int ipmc_valid_as_hit; /* L3_IPMC "valid" field is used as hit-bit (ER)*/ 71 #endif /* XGS3 devices */ 72 #if defined(BCM_XGS12_SWITCH_SUPPORT) 73 SHR_BITDCL *ipmc_allocated; 74 int *ipmc_l3_index; 75 #endif /* XGS1 or XGS2 devices */ 76 } _bcm_esw_ipmc_t; 77 78 79 /* IPMC info structure to be used by multiple source files */ 80 extern _bcm_esw_ipmc_t esw_ipmc_info[BCM_MAX_NUM_UNITS]; 81 82 /* MACROS to manipulate IPMC info structure */ 83 #define IPMC_GROUP_INFO(unit, n) \ 84 (&esw_ipmc_info[unit].ipmc_group_info[n]) 85 86 #define IPMC_USED_SET(unit, n) \ 87 { \ 88 if ((esw_ipmc_info[unit].ipmc_group_info[n].ref_count == 0) && \ 89 (esw_ipmc_info[unit].ipmc_group_info[n].defip_ref_count == 0)) { \ 90 esw_ipmc_info[unit].ipmc_count++; \ 91 } \ 92 esw_ipmc_info[unit].ipmc_group_info[n].ref_count++; \ 93 } 94 95 #define IPMC_USED_CLR(unit, n) \ 96 { \ 97 esw_ipmc_info[unit].ipmc_group_info[n].ref_count--; \ 98 if ((esw_ipmc_info[unit].ipmc_group_info[n].ref_count == 0) && \ 99 (esw_ipmc_info[unit].ipmc_group_info[n].defip_ref_count == 0)) { \ 100 esw_ipmc_info[unit].ipmc_count--; \ 101 } \ 102 } 103 104 #define IPMC_USED_ISSET(unit, n) \ 105 (esw_ipmc_info[unit].ipmc_group_info[n].ref_count > 0) 106 107 #define IPMC_USED_ONE(unit, n) \ 108 { \ 109 if (esw_ipmc_info[unit].ipmc_group_info[n].ref_count != 0) { \ 110 esw_ipmc_info[unit].ipmc_group_info[n].ref_count = 1; \ 111 } \ 112 } 113 114 #define IPMC_DEFIP_USED_SET(unit, n) \ 115 { \ 116 if ((esw_ipmc_info[unit].ipmc_group_info[n].ref_count == 0) && \ 117 (esw_ipmc_info[unit].ipmc_group_info[n].defip_ref_count == 0)) { \ 118 esw_ipmc_info[unit].ipmc_count++; \ 119 } \ 120 esw_ipmc_info[unit].ipmc_group_info[n].defip_ref_count++; \ 121 } 122 123 #define IPMC_DEFIP_USED_CLR(unit, n) \ 124 { \ 125 esw_ipmc_info[unit].ipmc_group_info[n].defip_ref_count--; \ 126 if ((esw_ipmc_info[unit].ipmc_group_info[n].ref_count == 0) && \ 127 (esw_ipmc_info[unit].ipmc_group_info[n].defip_ref_count == 0)) { \ 128 esw_ipmc_info[unit].ipmc_count--; \ 129 } \ 130 } 131 132 #define IPMC_DEFIP_COUNT_SET(unit, n, count) \ 133 { \ 134 if ((esw_ipmc_info[unit].ipmc_group_info[n].ref_count == 0) && \ 135 (esw_ipmc_info[unit].ipmc_group_info[n].defip_ref_count == 0)) { \ 136 esw_ipmc_info[unit].ipmc_count++; \ 137 } \ 138 esw_ipmc_info[unit].ipmc_group_info[n].defip_ref_count = count;\ 139 } 140 141 #define IPMC_ID(unit, id) \ 142 if ((id < 0) || (id >= esw_ipmc_info[unit].ipmc_size)) \ 143 { return BCM_E_PARAM; } 144 145 #define IPMC_INIT(unit) \ 146 if (!soc_feature(unit, soc_feature_ip_mcast)) { \ 147 return BCM_E_UNAVAIL; \ 148 } else if (!esw_ipmc_info[unit].ipmc_initialized) { \ 149 return BCM_E_INIT; \ 150 } 151 152 #define IPMC_INFO(unit) (&esw_ipmc_info[unit]) 153 #define IPMC_GROUP_NUM(unit) (esw_ipmc_info[unit].ipmc_size) 154 155 #define IPMC_LOCK(unit) \ 156 soc_mem_lock(unit, L3_IPMCm) 157 #define IPMC_UNLOCK(unit) \ 158 soc_mem_unlock(unit, L3_IPMCm) 159 160 #define IPMC_VALID_AS_HIT(unit) (esw_ipmc_info[unit].ipmc_valid_as_hit) 161 162 extern int _bcm_esw_ipmc_stk_update(int unit, uint32 flags); 163 164 165 typedef struct _bcm_ext_nh_list_s { 166 struct _bcm_ext_nh_list_s *next; 167 int encap_id; 168 int repl_type; 169 }_bcm_ext_nh_list_t; 170 171 typedef struct _bcm_ext_repl_q_list_s { 172 struct _bcm_ext_repl_q_list_s *next ; 173 _bcm_ext_nh_list_t *first_nh_ptr; 174 _bcm_ext_nh_list_t *last_nh_ptr; 175 int queue_id; 176 int profile_id; 177 int buf_type ; 178 int l2_copy; 179 int repl_count ; 180 int repl_hash; 181 } _bcm_ext_repl_q_list_t; 182 183 typedef struct _bcm_ext_q_ipmc_s { 184 _bcm_ext_repl_q_list_t *first_q_ptr; 185 _bcm_ext_repl_q_list_t *last_q_ptr; 186 int ipmcid; 187 int list_start_index; 188 int repl_count ; 189 int queue_hash ; 190 } _bcm_ext_q_ipmc_t; 191 192 typedef struct _bcm_repl_list_info_s { 193 int index; 194 int hash; 195 int list_size; 196 int refcount; 197 int first_ipmc; 198 struct _bcm_repl_list_info_s *next; 199 } _bcm_repl_list_info_t; 200 201 #define _BCM_VLAN_VEC_HASH(vec) _shr_crc32b(0, (uint8 *)vec, \ 202 BCM_VLAN_COUNT) 203 204 extern int _bcm_esw_ipmc_egress_intf_set(int unit, int mc_index, 205 bcm_port_t port, int if_count, 206 bcm_if_t *if_array, int is_l3, 207 int check_port); 208 extern int bcm_esw_ipmc_egress_intf_get(int unit, int mc_index, 209 bcm_port_t port, int if_max, 210 bcm_if_t *if_array, int *if_count); 211 extern int bcm_esw_ipmc_get_by_index(int unit, int index, 212 bcm_ipmc_addr_t *data); 213 extern int _bcm_esw_ipmc_port_trunkid_get(int unit, bcm_port_t port, int *tgid); 214 extern int _bcm_esw_ipmc_egress_intf_set_for_trunk_first_member(int unit, 215 int mc_index, 216 bcm_port_t port, 217 int if_count, 218 bcm_if_t *if_array, 219 int is_l3, 220 int check_port, 221 bcm_trunk_t tgid); 222 extern int _bcm_esw_ipmc_egress_intf_set_for_same_pipe_member(int unit, 223 int mc_index, 224 bcm_port_t port, 225 bcm_port_t first_port, 226 bcm_trunk_t tgid); 227 extern int _bcm_esw_ipmc_egress_intf_add_trunk_member(int unit, int mc_index, 228 bcm_port_t port); 229 extern int _bcm_esw_ipmc_egress_intf_del_trunk_member(int unit, int mc_index, 230 bcm_port_t port); 231 extern int _bcm_esw_ipmc_egress_intf_add_for_trunk(int unit, int mc_index, 232 bcm_trunk_t tgid, int encap_id, 233 int is_l3); 234 extern int _bcm_esw_ipmc_egress_intf_del_for_trunk(int unit, int mc_index, 235 bcm_trunk_t tgid, int if_max, 236 int encap_id, int is_l3); 237 extern int _bcm_esw_ipmc_egress_intf_add_in_per_trunk_mode(int unit, 238 int mc_index, 239 bcm_port_t port, 240 int encap_id, 241 int is_l3); 242 extern int _bcm_esw_ipmc_egress_intf_del_in_per_trunk_mode(int unit, 243 int mc_index, 244 bcm_port_t port, 245 int if_max, 246 int encap_id, 247 int is_l3); 248 249 #ifdef BCM_WARM_BOOT_SUPPORT 250 #define _BCM_IPMC_WB_REPL_LIST 0x1 251 #define _BCM_IPMC_WB_MULTICAST_MODE 0x2 252 #define _BCM_IPMC_WB_IPMC_GROUP_TYPE_MULTICAST 0x4 253 #define _BCM_IPMC_WB_L2MC_GROUP_TYPE_MULTICAST 0x8 254 #define _BCM_IPMC_WB_FLAGS_ALL 0xf 255 256 extern int _bcm_esw_ipmc_repl_wb_flags_set(int unit, uint8 flags, 257 uint8 flags_mask); 258 extern int _bcm_esw_ipmc_repl_wb_flags_get(int unit, uint8 flags_mask, 259 uint8 *flags); 260 extern int _bcm_esw_ipmc_sync(int unit); 261 #endif /* BCM_WARM_BOOT_SUPPORT */ 262 263 #ifndef BCM_SW_STATE_DUMP_DISABLE 264 extern void _bcm_ipmc_sw_dump(int unit); 265 #endif /* BCM_SW_STATE_DUMP_DISABLE */ 266 267 extern int _bcm_esw_ipmc_idx_ret_type_set(int unit, int arg); 268 extern int _bcm_esw_ipmc_idx_ret_type_get(int unit, int *arg); 269 extern int _bcm_esw_ipmc_repl_threshold_set(int unit, int arg); 270 extern int _bcm_esw_ipmc_repl_threshold_get(int unit, int *arg); 271 272 extern bcm_error_t 273 _bcm_esw_ipmc_stat_counter_get(int unit, 274 int sync_mode, 275 bcm_ipmc_addr_t *info, 276 bcm_ipmc_stat_t stat, 277 uint32 num_entries, 278 uint32 *counter_indexes, 279 bcm_stat_value_t *counter_values); 280 #else 281 #define _bcm_esw_ipmc_stk_update(_u,_f) BCM_E_NONE 282 #endif /* INCLUDE_L3 */ 283 284 #endif /* !_BCM_INT_IPMC_H */