stack.h (8595B)
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 * File: stack_int.h 8 */ 9 10 #ifndef _BCM_INT_STACK_H_ 11 #define _BCM_INT_STACK_H_ 12 13 #include <bcm/stack.h> 14 15 /* 16 * Stack tag structure 17 */ 18 typedef struct stk_tag_s { 19 #if defined(LE_HOST) 20 uint32 rsvp:2; 21 uint32 stk_modid:5; 22 uint32 ed:1; 23 uint32 em:1; 24 uint32 md:1; 25 uint32 mirr:1; 26 uint32 pfm:2; 27 uint32 dst_rtag:3; 28 uint32 dst_tgid:3; 29 uint32 dst_t:1; 30 uint32 src_rtag:3; 31 uint32 src_tgid:3; 32 uint32 src_t:1; 33 uint32 stk_cnt:5; 34 #else 35 uint32 stk_cnt:5; 36 uint32 src_t:1; 37 uint32 src_tgid:3; 38 uint32 src_rtag:3; 39 uint32 dst_t:1; 40 uint32 dst_tgid:3; 41 uint32 dst_rtag:3; 42 uint32 pfm:2; 43 uint32 mirr:1; 44 uint32 md:1; 45 uint32 em:1; 46 uint32 ed:1; 47 uint32 stk_modid:5; 48 uint32 rsvp:2; 49 #endif 50 } stk_tag_t; 51 52 #define STK_TAG_LEN 4 53 54 #define STACK_TAG(_scnt, _st, _stgid, _srtag, _dt, _dtgid, \ 55 _drtag, _pfm, _m, _md, _em, _ed, _smod) \ 56 ((_scnt & 0x1f) << 27 |\ 57 (_st & 0x1) << 26 |\ 58 (_stgid & 0x7) << 23 |\ 59 (_srtag & 0x7) << 20 |\ 60 (_dt & 0x1) << 19 |\ 61 (_dtgid & 0x7) << 16 |\ 62 (_drtag & 0x7) << 13 |\ 63 (_pfm & 0x3) << 11 |\ 64 (_m & 0x1) << 10 |\ 65 (_md & 0x1) << 9 |\ 66 (_em & 0x1) << 8 |\ 67 (_ed & 0x1) << 7 |\ 68 (_smod & 0x1f) << 2) 69 70 #define STK_MODID_GET(_tag) \ 71 ((_tag >> 2) & 0x1f) 72 73 #define STK_MODID_SET(_ptr_tag, _smod) \ 74 (*_ptr_tag = ((*_ptr_tag & ~(0x1f << 2)) | ((_smod & 0x1f) << 2))) 75 76 #define STK_CNT_GET(_tag) \ 77 ((_tag >> 27) & 0x1f) 78 79 #define STK_CNT_SET(_ptr_tag, _cnt) \ 80 (*_ptr_tag = ((*_ptr_tag & ~(0x1f << 27)) | ((_cnt & 0x1f) << 27))) 81 82 #define STK_PFM_GET(_tag) \ 83 ((_tag >> 11) & 0x3) 84 85 #define STK_PFM_SET(_ptr_tag, _pfm) \ 86 (*_ptr_tag = ((*_ptr_tag & ~(0x3 << 11)) | ((_pfm & 0x3) << 11))) 87 88 #if defined(BCM_TRIUMPH3_SUPPORT) || defined(BCM_HELIX4_SUPPORT) 89 /* Saves the trunk id that the port belonged to 90 * during a link flap. 91 */ 92 typedef struct { 93 int trunk_id[SOC_MAX_NUM_PORTS]; 94 } _bcm_stk_trident_linkflap_trunk_map_t; 95 96 extern 97 _bcm_stk_trident_linkflap_trunk_map_t _bcm_stk_trident_linkflap_trunk_map[]; 98 99 #define _BCM_PORT_TRUNK_LINKFLAP_SET(_u, _p, _t) \ 100 _bcm_stk_trident_linkflap_trunk_map[_u].trunk_id[_p] = _t 101 #define _BCM_PORT_TRUNK_LINKFLAP_GET(_u, _p) \ 102 _bcm_stk_trident_linkflap_trunk_map[_u].trunk_id[_p] 103 #define _BCM_PORT_TRUNK_LINKFLAP_CLEAR(_u, _p) \ 104 _bcm_stk_trident_linkflap_trunk_map[_u].trunk_id[_p] = BCM_TRUNK_INVALID 105 #endif 106 107 enum { 108 _BCM_STK_PORT_MODPORT_OP_SET = 1, 109 _BCM_STK_PORT_MODPORT_OP_ADD, 110 _BCM_STK_PORT_MODPORT_OP_DELETE, 111 _BCM_STK_PORT_MODPORT_OP_COUNT 112 }; 113 114 enum { 115 _BCM_STK_PORT_MODPORT_DMVOQ_GRP_OP_SET = 1, 116 _BCM_STK_PORT_MODPORT_DMVOQ_GRP_OP_GET, 117 _BCM_STK_PORT_MODPORT_DMVOQ_GRP_OP_COUNT 118 }; 119 120 extern int _bcm_esw_stk_detach(int unit); 121 122 typedef void (*_bcm_stk_modid_chg_cb_t)( 123 int unit, 124 int modid, 125 void *userdata); 126 127 extern int _bcm_esw_stk_modid_chg_cb_register(int unit, 128 _bcm_stk_modid_chg_cb_t cb, 129 void *userdata); 130 extern int _bcm_esw_stk_modid_chg_cb_unregister(int unit, 131 _bcm_stk_modid_chg_cb_t cb); 132 extern int _bcm_esw_stk_modmap_map(int unit, int setget, 133 bcm_module_t mod_in, bcm_port_t port_in, 134 bcm_module_t *mod_out, bcm_port_t *port_out); 135 136 #ifdef BCM_TOMAHAWK_SUPPORT 137 extern int _bcm_esw_stk_asymmetric_dual_modmap_map(int unit, int setget, 138 bcm_module_t *mod_in, bcm_port_t *port_in); 139 #endif /* BCM_TOMAHAWK_SUPPORT */ 140 141 #ifdef BCM_TRIDENT2PLUS_SUPPORT 142 extern int _bcm_esw_my_modid_additional_check(int unit, bcm_module_t modid, int *result); 143 extern int _bcm_esw_stk_modid_range_info_get(int unit, int *mod_base, uint32 *mod_mask); 144 extern int _bcm_esw_stk_modid_range_set(int unit, int mod_base, uint32 mod_mask, uint32 valid); 145 #endif /* BCM_TRIDENT2PLUS_SUPPORT */ 146 147 extern int _bcm_esw_tr_trunk_override_ucast_set(int unit, bcm_port_t port, 148 bcm_trunk_t hgtid, int modid, int enable); 149 150 extern int _bcm_esw_tr_trunk_override_ucast_get(int unit, bcm_port_t port, 151 bcm_trunk_t hgtid, int modid, int *enable); 152 extern int _bcm_esw_src_modid_base_index_get(int unit, bcm_module_t modid, 153 int is_local, int *base_index); 154 extern int _bcm_esw_src_modid_port_get(int unit, int stm_inx, bcm_module_t *modid, 155 int *port); 156 extern int _bcm_esw_src_mod_port_table_index_get(int unit, bcm_module_t modid, 157 bcm_port_t port, int *index); 158 extern int _bcm_esw_src_mod_port_table_index_get_from_port(int unit, 159 bcm_port_t port, 160 int *index); 161 162 extern int 163 bcm_stk_modport_voq_cosq_profile_get(int unit, bcm_port_t ing_port, 164 bcm_module_t dest_modid, int *profile_id); 165 166 extern int 167 bcm_stk_modport_voq_cosq_profile_set(int unit, bcm_port_t ing_port, 168 bcm_module_t dest_modid, int profile_id); 169 170 #if defined(BCM_TRIUMPH3_SUPPORT) || defined(BCM_HELIX4_SUPPORT) 171 extern int 172 _bcm_td_stk_modport_map_linkscan_handler(int unit, 173 bcm_port_t port, bcm_port_info_t *info); 174 extern int 175 _bcm_td_stk_modport_map_member_link_handler(int unit, 176 bcm_gport_t port, 177 bcm_trunk_t tid, 178 int test_only, 179 int *status); 180 #endif 181 182 extern int bcmi_esw_src_modid_base_index_bk_init(int unit); 183 184 #define BCM_MODID_TYPE_COE 0x1 185 #define BCM_MODID_TYPE_MULTI_NEXT_HOPS 0x2 186 187 extern int _bcm_stk_aux_modport_valid(int unit, uint32 type, 188 bcm_module_t modid, bcm_port_t port); 189 190 extern int _bcm_stk_aux_mod_valid(int unit, uint32 type, int modid); 191 192 extern int _bcm_stk_aux_modport_info_get(int unit, uint32 type, 193 bcm_stk_modid_config_t *modIdInfo); 194 195 #if defined(BCM_WARM_BOOT_SUPPORT) 196 extern int bcm_esw_reload_stk_my_modid_get(int unit); 197 extern int _bcm_esw_stk_sync(int unit); 198 #endif /* BCM_WARM_BOOT_SUPPORT */ 199 200 #ifdef BCM_WARM_BOOT_SUPPORT_SW_DUMP 201 extern void _bcm_stk_sw_dump(int unit); 202 #endif /* BCM_WARM_BOOT_SUPPORT_SW_DUMP */ 203 204 typedef struct module_id_mask_s { 205 uint32 mod_base; /* module base for extra modules */ 206 uint32 mod_mask; /* module mask for extra modules */ 207 } module_id_mask_t; 208 #if defined(BCM_TRIDENT_SUPPORT) || defined(BCM_HURRICANE3_SUPPORT) 209 /* In XGS3 devices prior to Trident, tables that contain per (modid, port) 210 * information, such as the SOURCE_TRUNK_MAP table, contain 211 * (SOC_MODID_MAX + 1) * (SOC_PORT_ADDR_MAX + 1) entries. The index to such 212 * tables is formed by modid * (SOC_PORT_ADDR_MAX + 1) + port. In Trident, 213 * the index is computed differently. First, the source modid is used to index 214 * a table that gives a base index, such as the SOURCE_TRUNK_MAP_MODBASE table. 215 * The base index is then added to port ID to derive the final index. 216 */ 217 typedef struct src_modid_base_index_bookkeeping_s { 218 uint16 *num_ports; /* An array keeping track of number of ports per module */ 219 SHR_BITDCL *src_mod_port_table_bitmap; 220 /* Keeps track of which entries are used in tables that 221 are indexed by source modid base index and port */ 222 int *coe_module_id_list; /* Keeps track of modules allocated for CoE */ 223 module_id_mask_t module_id_range; /* Keeps track of modules of multiple next hops on port */ 224 uint32 default_base_idx; /* Default base index for non-configured MOD IDs */ 225 int *multi_nexthop_module_id_list; /* Keeps track of modules allocated for Multi Next Hops */ 226 int *module_id_type_list; /* Keeps track of modules allocated*/ 227 } src_modid_base_index_bookkeeping_t; 228 #endif 229 #if defined(BCM_TRIDENT2PLUS_SUPPORT) 230 extern int _bcm_esw_stk_get_mod_config_by_type(int unit, int flags, int mod_index, 231 int *mod_id, int *valid, int *base_idx); 232 #endif 233 234 #endif /* !_BCM_INT_STACK_H_ */