vlan.h (13244B)
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 VLAN definitions internal to the BCM library. 8 */ 9 10 #ifndef _BCM_INT_VLAN_H 11 #define _BCM_INT_VLAN_H 12 13 #include <sal/types.h> 14 #include <bcm/types.h> 15 #include <bcm/vlan.h> 16 17 /* 18 * Define: 19 * VLAN_CHK_ID 20 * Purpose: 21 * Causes a routine to return BCM_E_PARAM if the specified 22 * VLAN ID is out of range. 23 */ 24 #define VLAN_CHK_ID(unit, vid) do { \ 25 if (vid > BCM_VLAN_MAX) return BCM_E_PARAM; \ 26 } while (0) 27 28 /* 29 * Define: 30 * VLAN_CHK_PRIO 31 * Purpose: 32 * Causes a routine to return BCM_E_PARAM if the specified 33 * priority (802.1p CoS) is out of range. 34 */ 35 36 #define VLAN_CHK_PRIO(unit, prio) do { \ 37 if ((prio < BCM_PRIO_MIN || prio > BCM_PRIO_MAX)) return BCM_E_PARAM; \ 38 } while (0); 39 40 #define VLAN_CHK_ACTION(unit, action) do { \ 41 if (action < bcmVlanActionNone || action > bcmVlanActionCopy) return BCM_E_PARAM; \ 42 } while (0); 43 /* 44 *In TH2/TH3, some fields in VLAN_TAB are moved to VLAN_2_TAB. 45 *This macro is to distinguish the two tables where these fields are used. 46 */ 47 #define VLAN_TABLE(unit) \ 48 (SOC_MEM_IS_VALID((unit), VLAN_2_TABm) ? VLAN_2_TABm : VLAN_TABm) 49 50 /* 51 * XGS3 Vlan Translate macros 52 */ 53 #ifdef BCM_XGS3_SWITCH_SUPPORT 54 #define BCM_VLAN_XLATE_PRIO_MASK 0x007 55 #define BCM_VLAN_XLATE_MODID_MASK 0x3f0 56 #define BCM_VLAN_XLATE_INGRESS_MASK 0x400 57 #define BCM_VLAN_XLATE_ADDVID_MASK 0x800 58 59 #define BCM_VLAN_XLATE_MODID_SHIFT 4 60 61 #define BCM_VLAN_XLATE_ING 0 62 #define BCM_VLAN_XLATE_EGR 1 63 #define BCM_VLAN_XLATE_DTAG 2 64 #endif 65 66 #define _BCM_VLAN_XLATE_DUMMY_PORT (2) 67 #define BCM_VLAN_RANGE_NUM 8 68 69 /* 70 * VLAN internal struct used for book keeping 71 */ 72 typedef struct vbmp_s { 73 SHR_BITDCL *w; 74 } vbmp_t; 75 76 /* 77 * Macro : 78 * _BCM_VBMP_LOOKUP 79 * Purpose: 80 * Return TRUE if a VLAN ID exists in a vbmp, FALSE otherwise 81 */ 82 #define _BCM_VBMP_LOOKUP(_bmp_, _vid_) SHR_BITGET(((_bmp_).w), (_vid_)) 83 84 /* 85 * MACRO: 86 * _BCM_VBMP_INSERT 87 * Purpose: 88 * Add a VLAN ID to a vbmap 89 */ 90 #define _BCM_VBMP_INSERT(_bmp_, _vid_) SHR_BITSET(((_bmp_).w), (_vid_)) 91 92 /* 93 * Macro: 94 * _BCM_VBMP_REMOVE 95 * Purpose: 96 * Delete a VLAN ID from a vbmp 97 */ 98 #define _BCM_VBMP_REMOVE(_bmp_, _vid_) SHR_BITCLR(((_bmp_).w), (_vid_)) 99 100 extern int _bcm_esw_vlan_stk_update(int unit, uint32 flags); 101 extern int _bcm_esw_vlan_flood_default_set(int unit, bcm_vlan_mcast_flood_t mode); 102 extern int _bcm_esw_vlan_flood_default_get(int unit, bcm_vlan_mcast_flood_t *mode); 103 extern int _bcm_esw_higig_flood_l2_set(int unit, bcm_vlan_mcast_flood_t mode); 104 extern int _bcm_esw_higig_flood_l2_get(int unit, bcm_vlan_mcast_flood_t *mode); 105 extern int _bcm_esw_higig_flood_l3_set(int unit, bcm_vlan_mcast_flood_t mode); 106 extern int _bcm_esw_higig_flood_l3_get(int unit, bcm_vlan_mcast_flood_t *mode); 107 extern int bcm_esw_vlan_detach(int unit); 108 extern int _bcm_esw_vlan_xlate_key_type_value_get(int unit, int key_type, 109 int *key_value); 110 extern int _bcm_esw_vlan_xlate_key_type_get(int unit, int key_type_value, 111 int *key_type); 112 extern int _bcm_esw_pt_vtkey_type_value_get(int unit, 113 int key_type, int *key_type_value); 114 extern int _bcm_esw_pt_vtkey_type_get(int unit, 115 int key_type_value, int *key_type); 116 extern int _bcm_esw_dvp_vtkey_type_get(int unit, 117 int key_type_value, int *key_type); 118 extern int _bcm_esw_dvp_vtkey_type_value_get(int unit, 119 int key_type, int *key_type_value); 120 121 #if defined(BCM_TRIUMPH3_SUPPORT) 122 extern int _bcm_tr3_vxlate_extd2vxlate(int unit,vlan_xlate_extd_entry_t *vxxent, 123 vlan_xlate_entry_t *vxent, int use_svp); 124 extern int _bcm_tr3_vxlate2vxlate_extd(int unit, vlan_xlate_entry_t *vxent, 125 vlan_xlate_extd_entry_t *vxxent); 126 #endif 127 128 #ifdef BCM_TRX_SUPPORT 129 /* 130 * This structure is used to bookkeeping for vlan ranges 131 * which are added with no association to vlan translate action. 132 * This case happens when using bcm_vlan_translate_action_range_add API 133 * and assigns NULL to 'action' parameter. 134 */ 135 typedef struct vlan_range_bk_s { 136 bcm_vlan_t vlan_low[BCM_VLAN_RANGE_NUM]; /* vlan_low of profile entry */ 137 } vlan_range_bk_t; 138 139 /* 140 * This structure is used to keep track of ref counts for the 141 * vlan_range_bk_t defined above (Vlan ranges added with no assosiaction 142 * to vlan translate action). 143 */ 144 typedef struct vlan_range_bk_ref_cnt_s { 145 int ref_cnt; /* Ref counts for profiles */ 146 } vlan_range_bk_ref_cnt_t; 147 148 #endif /* BCM_TRX_SUPPORT */ 149 150 /* 151 * The entire vlan_info structure is protected by BCM_LOCK. 152 */ 153 154 typedef struct bcm_vlan_info_s { 155 int init; /* TRUE if VLAN module has been inited */ 156 bcm_vlan_t defl; /* Default VLAN */ 157 vbmp_t bmp; /* Bitmap of existing VLANs */ 158 int count; /* Number of existing VLANs */ 159 /* Number of vlan egress xlate entires used to blok port_class settings */ 160 uint16 old_egr_xlate_cnt; 161 bcm_vlan_mcast_flood_t flood_mode;/* Default flood mode */ 162 uint32 *ing_trans; /* Ingress Vlan Translate info */ 163 uint32 *egr_trans; /* Egress Vlan Translate info */ 164 #if defined(BCM_EASY_RELOAD_SUPPORT) 165 vbmp_t egr_vlan_bmp; /* Bitmap of valid EGR_VLAN */ 166 vbmp_t vlan_tab_bmp; /* Bitmap of valid VLAN_TAB */ 167 #endif 168 SHR_BITDCL *qm_bmp; /* Bitmap of allocated queue map */ 169 SHR_BITDCL *qm_it_bmp;/* Bitmap of queue map entry using inner 170 tag */ 171 vbmp_t pre_cfg_bmp; /* per vlan pre-configuration flag */ 172 SHR_BITDCL vp_mode[_SHR_BITDCLSIZE(BCM_VLAN_COUNT)]; /* VP control mode */ 173 int vlan_auto_stack; /* True if turn on auto stack */ 174 #ifdef BCM_TRIDENT3_SUPPORT 175 int shared_vlan_enable; /* Shared vlan enable */ 176 #endif 177 #ifdef BCM_TRX_SUPPORT 178 /* VLAN ranges which are added with no association to vlan xlate action */ 179 vlan_range_bk_t *vlan_range_no_act_array; 180 vlan_range_bk_t *vlan_range_inner_no_act_array; 181 /* Ref counts assosiated with the VLAN ranges */ 182 vlan_range_bk_ref_cnt_t *vlan_range_no_act_ref_cnt_array; 183 vlan_range_bk_ref_cnt_t *vlan_range_inner_no_act_ref_cnt_array; 184 #endif /* BCM_TRX_SUPPORT */ 185 } bcm_vlan_info_t; 186 187 extern bcm_vlan_info_t vlan_info[BCM_MAX_NUM_UNITS]; 188 189 typedef struct _bcm_vlan_translate_data_s{ 190 bcm_port_t port; 191 bcm_vlan_t old_vlan; 192 bcm_vlan_t *new_vlan; 193 int *prio; 194 }_bcm_vlan_translate_data_t; 195 196 /* Key types for VP VLAN/VFI Mermbership */ 197 typedef enum _bcm_vp_vlan_mbrship_key_type_t { 198 _bcm_vp_vlan_mbrship_vp_vlan_type = 0, 199 _bcm_vp_vlan_mbrship_glp_vlan_type, 200 _bcm_vp_vlan_mbrship_vp_vfi_type, 201 _bcm_vp_vlan_mbrship_glp_vfi_type 202 } _bcm_vp_vlan_mbrship_key_type_e; 203 204 /* 205 * Internal key type for egr vxlate lookup. 206 * Maps to HW encoding of VT_ENABLE field in EGR_VLAN_CONTROL mem. 207 * Not applicable for virtual port (VP) based lookups 208 */ 209 typedef enum _bcm_evxlt_lookup_key_e { 210 EVXLT_KEY_TYPE_NOOP = 0, 211 EVXLT_KEY_TYPE_PORT_GROUP_VLAN_DOUBLE = 1, 212 EVXLT_KEY_TYPE_PORT_VLAN_DOUBLE = 2 213 } _bcm_evxlt_lookup_key_t; 214 215 /* 216 * Vlan Translate support routines 217 */ 218 219 #define BCM_VTCACHE_VALID_SET(_c, _valid) _c |= ((_valid & 1) << 31) 220 #define BCM_VTCACHE_ADD_SET(_c, _add) _c |= ((_add & 1) << 30) 221 #define BCM_VTCACHE_PORT_SET(_c, _port) _c |= ((_port & 0xff) << 16) 222 #define BCM_VTCACHE_VID_SET(_c, _vid) _c |= ((_vid & 0xffff) << 0) 223 224 #define BCM_VTCACHE_VALID_GET(_c) ((_c >> 31) & 1) 225 #define BCM_VTCACHE_ADD_GET(_c) ((_c >> 30) & 1) 226 #define BCM_VTCACHE_PORT_GET(_c) ((_c >> 16) & 0xff) 227 #define BCM_VTCACHE_VID_GET(_c) ((_c >> 0) & 0xffff) 228 229 #define VLAN_MEM_CHUNKS_DEFAULT 256 230 #define ING_ACTION_PROFILE_DEFAULT 0 231 232 typedef struct _translate_action_range_traverse_cb_s { 233 bcm_vlan_translate_action_range_traverse_cb usr_cb; 234 } _translate_action_range_traverse_cb_t; 235 236 typedef struct _translate_range_traverse_cb_s { 237 bcm_vlan_translate_range_traverse_cb usr_cb; 238 } _translate_range_traverse_cb_t; 239 240 typedef struct _dtag_range_traverse_cb_s { 241 bcm_vlan_dtag_range_traverse_cb usr_cb; 242 } _dtag_range_traverse_cb_t; 243 244 typedef struct _translate_action_traverse_cb_s { 245 bcm_vlan_translate_action_traverse_cb usr_cb; 246 } _translate_action_traverse_cb_t; 247 248 typedef struct _translate_egress_action_traverse_cb_s { 249 bcm_vlan_translate_egress_action_traverse_cb usr_cb; 250 } _translate_egress_action_traverse_cb_t; 251 252 typedef struct _translate_egress_action_extended_traverse_cb_s { 253 bcm_vlan_translate_egress_action_extended_traverse_cb usr_cb; 254 } _translate_egress_action_extended_traverse_cb_t; 255 256 typedef struct _translate_traverse_cb_s { 257 bcm_vlan_translate_traverse_cb usr_cb; 258 } _translate_traverse_cb_t; 259 260 typedef struct _translate_egress_traverse_cb_s { 261 bcm_vlan_translate_egress_traverse_cb usr_cb; 262 } _translate_egress_traverse_cb_t; 263 264 typedef struct _dtag_traverse_cb_s { 265 bcm_vlan_dtag_traverse_cb usr_cb; 266 } _dtag_traverse_cb_t; 267 268 269 typedef int (*_bcm_vlan_translate_traverse_int_cb)( int unit, void *trv_info, 270 int *stop); 271 272 typedef struct _bcm_vlan_translate_traverse_s { 273 _bcm_vlan_translate_traverse_int_cb int_cb; 274 void *user_cb_st; 275 void *user_data; 276 bcm_vlan_action_set_t *action; 277 bcm_gport_t gport; 278 uint32 key_type; 279 int port_class; 280 bcm_vlan_t outer_vlan; 281 bcm_vlan_t inner_vlan; 282 bcm_vlan_t outer_vlan_high; 283 bcm_vlan_t inner_vlan_high; 284 }_bcm_vlan_translate_traverse_t; 285 286 extern int _bcm_esw_vlan_translate_action_traverse_int_cb(int unit, 287 void* trv_info, 288 int *stop); 289 extern int _bcm_esw_vlan_translate_egress_action_traverse_int_cb(int unit, 290 void* trv_info, 291 int *stop); 292 extern int _bcm_esw_vlan_translate_traverse_int_cb(int unit, void* trv_info, 293 int *stop); 294 extern int _bcm_esw_vlan_translate_egress_traverse_int_cb(int unit, 295 void* trv_info, 296 int *stop); 297 extern int _bcm_esw_vlan_dtag_traverse_int_cb(int unit, void* trv_info, 298 int *stop); 299 extern int _bcm_esw_vlan_translate_traverse_mem(int unit, soc_mem_t mem, 300 _bcm_vlan_translate_traverse_t *trvs_info); 301 302 #ifdef BCM_WARM_BOOT_SUPPORT 303 extern int _bcm_vlan_cleanup(int unit); 304 #else 305 #define _bcm_vlan_cleanup(u) (BCM_E_NONE) 306 #endif /* BCM_WARM_BOOT_SUPPORT */ 307 308 309 extern int _bcm_esw_vlan_untag_update(int unit, bcm_port_t port, int untag); 310 311 #ifdef BCM_WARM_BOOT_SUPPORT 312 extern int _bcm_esw_vlan_sync(int unit); 313 #endif /* BCM_WARM_BOOT_SUPPORT */ 314 315 #ifndef BCM_SW_STATE_DUMP_DISABLE 316 extern void _bcm_vlan_sw_dump(int unit); 317 #endif /* BCM_SW_STATE_DUMP_DISABLE */ 318 319 #if defined(BCM_ESW_SUPPORT) || defined(BCM_PETRA_SUPPORT) || defined(BCM_DFE_SUPPORT) 320 extern int _bcm_vlan_valid_check(int unit, int table, vlan_tab_entry_t *vt, 321 bcm_vlan_t vid); 322 #endif 323 324 #if defined(BCM_EASY_RELOAD_SUPPORT) 325 int _bcm_vlan_valid_set(int unit, int table, bcm_vlan_t vid, int val); 326 #endif 327 328 extern int _bcm_esw_vlan_port_source_vp_lag_set(int unit, bcm_gport_t gport, 329 int vp_lag_vp); 330 extern int _bcm_esw_vlan_port_source_vp_lag_clear(int unit, bcm_gport_t gport, 331 int vp_lag_vp); 332 extern int _bcm_esw_vlan_port_source_vp_lag_get(int unit, bcm_gport_t gport, 333 int *vp_lag_vp); 334 335 extern int _bcm_esw_vlan_system_reserved_get(int unit, int *arg); 336 extern int _bcm_esw_vlan_system_reserved_set(int unit, int arg); 337 338 extern int _bcm_vlan_count_get(int unit, int *arg); 339 extern int _bcm_vbmp_init(vbmp_t *bmp); 340 extern int _bcm_vbmp_destroy(vbmp_t *bmp); 341 342 #if defined(BCM_TRX_SUPPORT) 343 extern int _bcm_trx_vlan_action_profile_ref_count_get(int unit, int index, int *ref_count); 344 extern int _bcm_trx_vlan_action_profile_entry_add(int unit, 345 bcm_vlan_action_set_t *action, 346 uint32 *index); 347 extern int _bcm_trx_vlan_action_profile_entry_delete(int unit, uint32 index); 348 extern int _bcm_trx_vlan_action_verify(int unit, bcm_vlan_action_set_t *action); 349 #endif /* BCM_TRX_SUPPORT */ 350 351 #endif /* !_BCM_INT_VLAN_H */