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