l2.h (9289B)
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 8 #ifndef _BCM_INT_L2_H 9 #define _BCM_INT_L2_H 10 11 #include <bcm/types.h> 12 #include <bcm/l2.h> 13 14 #include <sal/core/sync.h> 15 16 #ifndef BCM_SW_STATE_DUMP_DISABLE 17 extern void _bcm_l2_sw_dump(int unit); 18 #endif /* BCM_SW_STATE_DUMP_DISABLE */ 19 20 21 #define L2_MEM_CHUNKS_DEFAULT 100 22 typedef int (*_bcm_l2_traverse_int_cb)(int unit, void *trav_st); 23 24 typedef struct _bcm_l2_traverse_s { 25 uint32 *data; /* L2 Entry */ 26 soc_mem_t mem; /* Traversed memory */ 27 int mem_idx; /* Index of currently read entry */ 28 bcm_l2_traverse_cb user_cb; /* User callback function */ 29 void *user_data; /* Data provided by the user, cookie */ 30 _bcm_l2_traverse_int_cb int_cb; /* Internal callback function */ 31 }_bcm_l2_traverse_t; 32 33 extern int _bcm_esw_l2_traverse(int unit, _bcm_l2_traverse_t *trav_st); 34 35 typedef struct _bcm_l2_replace_dest_s { 36 bcm_module_t module; 37 bcm_port_t port; 38 bcm_trunk_t trunk; 39 int vp; 40 } _bcm_l2_replace_dest_t; 41 42 /* _bcm_l2_replaces_t.int_flags (internal flags) */ 43 #define _BCM_L2_REPLACE_INT_NO_ACTION 0x0001 44 #define _BCM_L2_REPLACE_INT_MATCH_DISCARD_SRC 0x0002 45 #define _BCM_L2_REPLACE_INT_MATCH_SRC_HIT 0x0004 46 #define _BCM_L2_REPLACE_INT_MATCH_DES_HIT 0x0008 47 #define _BCM_L2_REPLACE_INT_MATCH_NATIVE 0x0010 48 #define _BCM_L2_REPLACE_INT_MATCH_ONLY_STATIC 0x0020 49 #define _BCM_L2_REPLACE_IGNORE_PORTID 0x0040 50 #define _BCM_L2_REPLACE_INT_MATCH_MESH 0x0080 51 52 typedef struct _bcm_l2_replace_s { 53 uint32 flags; /* BCM_L2_REPLACE_XXX */ 54 uint32 int_flags; /* _BCM_L2_REPLACE_INT_XXX */ 55 uint32 key_l2_flags; /* bcm_l2_addr_t.flags */ 56 uint32 key_l2_flags2; /* bcm_l2_addr_t.flags2 */ 57 int key_type; 58 bcm_mac_t key_mac; 59 bcm_vlan_t key_vlan; 60 int key_vfi; 61 int key_class_id; 62 int key_int_pri; 63 _bcm_l2_replace_dest_t match_dest; 64 _bcm_l2_replace_dest_t new_dest; 65 l2x_entry_t match_data; 66 l2x_entry_t match_mask; 67 l2x_entry_t new_data; 68 l2x_entry_t new_mask; 69 bcm_l2_traverse_cb trav_fn; 70 void *user_data; 71 uint32 view_id; /* flex view identifier */ 72 } _bcm_l2_replace_t; 73 74 typedef struct _bcm_l2_match_s { 75 bcm_l2_addr_t *match_addr; 76 bcm_l2_addr_t *addr_mask; 77 bcm_l2_traverse_cb trav_fn; 78 void *user_data; 79 } _bcm_l2_match_t; 80 81 82 #define _BCM_L2_MATCH_ENTRY_BUF_SIZE (16 * 1024) 83 #define _BCM_L2_MATCH_ENTRY_BUF_COUNT 32 84 typedef struct _bcm_l2_match_ctrl_s { 85 sal_sem_t sem; 86 int entry_wr_idx; 87 l2x_entry_t *l2x_entry_buf[_BCM_L2_MATCH_ENTRY_BUF_COUNT]; 88 int preserved; 89 } _bcm_l2_match_ctrl_t; 90 91 typedef struct _bcm_l2_gport_params_s { 92 int param0; 93 int param1; 94 uint32 type; 95 }_bcm_l2_gport_params_t; 96 97 extern int _l2_init[BCM_MAX_NUM_UNITS]; 98 extern _bcm_l2_match_ctrl_t *_bcm_l2_match_ctrl[BCM_MAX_NUM_UNITS]; 99 /* 100 * Define: 101 * L2_INIT 102 * Purpose: 103 * Causes a routine to return BCM_E_INIT (or some other 104 * error) if L2 software module is not yet initialized. 105 */ 106 107 #define L2_INIT(unit) do { \ 108 if (_l2_init[unit] < 0) return _l2_init[unit]; \ 109 if (_l2_init[unit] == 0) return BCM_E_INIT; \ 110 } while (0); 111 112 extern int _bcm_esw_l2_gport_parse(int unit, bcm_l2_addr_t *l2addr, 113 _bcm_l2_gport_params_t *params); 114 extern int _bcm_esw_l2_gport_construct(int unit, bcm_l2_addr_t *l2addr, 115 _bcm_l2_gport_params_t *params); 116 117 extern int _bcm_get_op_from_flags(uint32 flags, uint32 *op, uint32 *sync_op); 118 extern int _bcm_esw_l2_from_l2x(int unit, soc_mem_t mem, bcm_l2_addr_t *l2addr, 119 uint32 *l2_entry); 120 extern void _bcm_l2_register_callback(int unit, int flags, l2x_entry_t *entry_del, 121 l2x_entry_t *entry_add, void *fn_data); 122 123 /* extended aging per_port_age_control mode field values */ 124 #define XGS_PPAMODE_PORTMOD 0x0 125 #define XGS_PPAMODE_VLAN 0x1 126 #define XGS_PPAMODE_PORTMOD_VLAN 0x2 127 #define XGS_PPAMODE_RSVD 0x3 128 #define XGS_PPAMODE_PORTMOD_REPLACE 0x4 129 #define XGS_PPAMODE_VLAN_REPLACE 0x5 130 #define XGS_PPAMODE_PORTMOD_VLAN_REPLACE 0x6 131 132 #define BCMSIM_L2XMSG_INTERVAL 60000000 133 #ifdef BCM_TOMAHAWK3_SUPPORT 134 #define BCMSIM_L2XLRN_INTERVAL 1000000 135 #define BCM_L2XLRN_INTERVAL_DEFAULT 250000 136 #endif /* BCM_TOMAHAWK3_SUPPORT */ 137 138 /* type field [14:13] for destination type in L2_ENTRY/L2_USER_ENTRY*/ 139 #define _BCM_L2_DEST_TYPE_MASK (3U << 13) 140 #define _BCM_L2_DEST_TYPE_TRUNK 0 /* type field [14:13] = 0 */ 141 142 #define _BCM_L2_DEST_TYPE_NHI (3U << 13) 143 144 #define _BCM_L2_DEST_STATION_HIT (1U << 13) 145 #define _BCM_L2_DEST_STATION_IPV4 (1U << 3) 146 #define _BCM_L2_DEST_STATION_IPV6 (1U << 4) 147 #define _BCM_L2_DEST_STATION_ARP_RARP (1U << 5) 148 #define _BCM_L2_DEST_STATION_OAM (1U << 6) 149 #define _BCM_L2_DEST_STATION_FCOE (1U << 7) 150 #define _BCM_L2_DEST_STATION_IPV4_MCAST (1U << 8) 151 #define _BCM_L2_DEST_STATION_IPV6_MCAST (1U << 9) 152 153 /* L2 Learn class defines */ 154 #define _BCM_L2_LEARN_CLASSID_MIN 0 155 #define _BCM_L2_LEARN_CLASSID_MAX 3 156 #define BCM_L2_LEARN_CLASSID_VALID(_cid_) do { \ 157 if ((_cid_ < _BCM_L2_LEARN_CLASSID_MIN) || \ 158 (_cid_ > _BCM_L2_LEARN_CLASSID_MAX)) { return BCM_E_PARAM; } \ 159 } while(0); 160 161 #define BCM_L2_PRE_SET(_flags_) \ 162 (((_flags_) & BCM_L2_SETPRI) ? TRUE : FALSE) 163 164 #if defined(BCM_TRIUMPH_SUPPORT) /* BCM_TRIUMPH_SUPPORT */ 165 typedef struct _bcm_l2_station_entry_s { 166 int sid; /* Entry identifier. */ 167 int prio; /* Entry priority. */ 168 uint32 hw_index; /* Entry hardware index. */ 169 uint32 flags; /* Entry flags. */ 170 uint32 *tcam_ent; /* TCAM entry. */ 171 } _bcm_l2_station_entry_t; 172 173 typedef struct _bcm_l2_station_control_s { 174 sal_mutex_t sc_lock; 175 _bcm_l2_station_entry_t **entry_arr; /* L2 station entry array. */ 176 int entries_total; /* Total number of entries. */ 177 int entries_free; /* Count of unused entries. */ 178 int entry_count; /* Count of used entries. */ 179 _bcm_l2_station_entry_t **entry_arr_2; /* L2 station entry array. */ 180 int entries_total_2;/* Total number of entries. */ 181 int entries_free_2; /* Count of unused entries. */ 182 int entry_count_2; /* Count of used entries. */ 183 #ifdef BCM_KATANA2_SUPPORT 184 int port_entries_total; /* Count of total Port MAC 185 entries */ 186 int port_entries_free; /* Count of total PORT MAC 187 entries */ 188 #endif 189 #if defined(BCM_KATANA2_SUPPORT) || defined(BCM_TRIDENT2PLUS_SUPPORT) 190 int olp_entries_total; /* Count of total OLP MAC 191 entries */ 192 int olp_entries_free; /* Count of total OLP MAC 193 entries */ 194 #endif 195 uint32 last_allocated_sid; 196 uint32 last_allocated_sid_2; /* for MY_STATION_TCAM_2 */ 197 } _bcm_l2_station_control_t; 198 199 /* L2 BULK unified table indexes */ 200 #define _BCM_L2_BULK_MATCH_DATA_INX 0 201 #define _BCM_L2_BULK_MATCH_MASK_INX 1 202 #define _BCM_L2_BULK_REPLACE_DATA_INX 2 203 #define _BCM_L2_BULK_REPLACE_MASK_INX 3 204 205 #endif /* !BCM_TRIUMPH_SUPPORT */ 206 207 #if defined(BCM_TRIUMPH3_SUPPORT) 208 209 typedef struct l2_count_s { 210 int l2_entry_1; 211 int l2_entry_2; 212 int ext_l2_entry_1; 213 int ext_l2_entry_2; 214 } l2_count_t; 215 216 typedef struct l2_count_data_s { 217 uint32 flags; 218 l2_count_t l2_count; 219 } l2_count_data_t; 220 221 #define L2_DUMP_COUNT 1<<0 222 223 extern l2_count_data_t _l2_addr_counts; 224 225 #endif 226 227 #ifdef BCM_WARM_BOOT_SUPPORT 228 extern int _bcm_esw_l2_wb_sync(int unit); 229 #endif /* BCM_WARM_BOOT_SUPPORT */ 230 231 #if defined(INCLUDE_L3) 232 extern int _bcm_td3_l2_change_fields_add(int unit,bcm_l2_change_fields_t *l2_info); 233 extern int _bcm_td3_l2_change_fields_egress_key_set(int unit, soc_mem_t mem, bcm_l2_change_fields_t *l2_info, uint32 *entry); 234 extern int _bcm_td3_l2_change_fields_egress_entry_get(int unit, soc_mem_t mem, uint32* entry, bcm_l2_change_fields_t *l2_info); 235 extern int _bcm_td3_change_l2_fields_entry_traverse(int unit, soc_mem_t mem, bcm_l2_change_fields_traverse_cb cb, void *user_data); 236 #endif /* INCLUDE_L3 */ 237 #endif /* !_BCM_INT_L2_H */