vlan.h (11893B)
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 * 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 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 /* 129 * The entire vlan_info structure is protected by BCM_LOCK. 130 */ 131 132 typedef struct bcm_vlan_info_s { 133 int init; /* TRUE if VLAN module has been inited */ 134 bcm_vlan_t defl; /* Default VLAN */ 135 vbmp_t bmp; /* Bitmap of existing VLANs */ 136 int count; /* Number of existing VLANs */ 137 /* Number of vlan egress xlate entires used to blok port_class settings */ 138 uint16 old_egr_xlate_cnt; 139 bcm_vlan_mcast_flood_t flood_mode;/* Default flood mode */ 140 uint32 *ing_trans; /* Ingress Vlan Translate info */ 141 uint32 *egr_trans; /* Egress Vlan Translate info */ 142 #if defined(BCM_EASY_RELOAD_SUPPORT) 143 vbmp_t egr_vlan_bmp; /* Bitmap of valid EGR_VLAN */ 144 vbmp_t vlan_tab_bmp; /* Bitmap of valid VLAN_TAB */ 145 #endif 146 SHR_BITDCL *qm_bmp; /* Bitmap of allocated queue map */ 147 SHR_BITDCL *qm_it_bmp;/* Bitmap of queue map entry using inner 148 tag */ 149 vbmp_t pre_cfg_bmp; /* per vlan pre-configuration flag */ 150 SHR_BITDCL vp_mode[_SHR_BITDCLSIZE(BCM_VLAN_COUNT)]; /* VP control mode */ 151 int vlan_auto_stack; /* True if turn on auto stack */ 152 #ifdef BCM_TRIDENT3_SUPPORT 153 int shared_vlan_enable; /* Shared vlan enable */ 154 #endif 155 } bcm_vlan_info_t; 156 157 extern bcm_vlan_info_t vlan_info[BCM_MAX_NUM_UNITS]; 158 159 typedef struct _bcm_vlan_translate_data_s{ 160 bcm_port_t port; 161 bcm_vlan_t old_vlan; 162 bcm_vlan_t *new_vlan; 163 int *prio; 164 }_bcm_vlan_translate_data_t; 165 166 /* Key types for VP VLAN/VFI Mermbership */ 167 typedef enum _bcm_vp_vlan_mbrship_key_type_t { 168 _bcm_vp_vlan_mbrship_vp_vlan_type = 0, 169 _bcm_vp_vlan_mbrship_glp_vlan_type, 170 _bcm_vp_vlan_mbrship_vp_vfi_type, 171 _bcm_vp_vlan_mbrship_glp_vfi_type 172 } _bcm_vp_vlan_mbrship_key_type_e; 173 174 /* 175 * Internal key type for egr vxlate lookup. 176 * Maps to HW encoding of VT_ENABLE field in EGR_VLAN_CONTROL mem. 177 * Not applicable for virtual port (VP) based lookups 178 */ 179 typedef enum _bcm_evxlt_lookup_key_e { 180 EVXLT_KEY_TYPE_NOOP = 0, 181 EVXLT_KEY_TYPE_PORT_GROUP_VLAN_DOUBLE = 1, 182 EVXLT_KEY_TYPE_PORT_VLAN_DOUBLE = 2 183 } _bcm_evxlt_lookup_key_t; 184 185 /* 186 * Vlan Translate support routines 187 */ 188 189 #define BCM_VTCACHE_VALID_SET(_c, _valid) _c |= ((_valid & 1) << 31) 190 #define BCM_VTCACHE_ADD_SET(_c, _add) _c |= ((_add & 1) << 30) 191 #define BCM_VTCACHE_PORT_SET(_c, _port) _c |= ((_port & 0xff) << 16) 192 #define BCM_VTCACHE_VID_SET(_c, _vid) _c |= ((_vid & 0xffff) << 0) 193 194 #define BCM_VTCACHE_VALID_GET(_c) ((_c >> 31) & 1) 195 #define BCM_VTCACHE_ADD_GET(_c) ((_c >> 30) & 1) 196 #define BCM_VTCACHE_PORT_GET(_c) ((_c >> 16) & 0xff) 197 #define BCM_VTCACHE_VID_GET(_c) ((_c >> 0) & 0xffff) 198 199 #define VLAN_MEM_CHUNKS_DEFAULT 256 200 #define ING_ACTION_PROFILE_DEFAULT 0 201 202 typedef struct _translate_action_range_traverse_cb_s { 203 bcm_vlan_translate_action_range_traverse_cb usr_cb; 204 } _translate_action_range_traverse_cb_t; 205 206 typedef struct _translate_range_traverse_cb_s { 207 bcm_vlan_translate_range_traverse_cb usr_cb; 208 } _translate_range_traverse_cb_t; 209 210 typedef struct _dtag_range_traverse_cb_s { 211 bcm_vlan_dtag_range_traverse_cb usr_cb; 212 } _dtag_range_traverse_cb_t; 213 214 typedef struct _translate_action_traverse_cb_s { 215 bcm_vlan_translate_action_traverse_cb usr_cb; 216 } _translate_action_traverse_cb_t; 217 218 typedef struct _translate_egress_action_traverse_cb_s { 219 bcm_vlan_translate_egress_action_traverse_cb usr_cb; 220 } _translate_egress_action_traverse_cb_t; 221 222 typedef struct _translate_traverse_cb_s { 223 bcm_vlan_translate_traverse_cb usr_cb; 224 } _translate_traverse_cb_t; 225 226 typedef struct _translate_egress_traverse_cb_s { 227 bcm_vlan_translate_egress_traverse_cb usr_cb; 228 } _translate_egress_traverse_cb_t; 229 230 typedef struct _dtag_traverse_cb_s { 231 bcm_vlan_dtag_traverse_cb usr_cb; 232 } _dtag_traverse_cb_t; 233 234 235 typedef int (*_bcm_vlan_translate_traverse_int_cb)( int unit, void *trv_info, 236 int *stop); 237 238 typedef struct _bcm_vlan_translate_traverse_s { 239 _bcm_vlan_translate_traverse_int_cb int_cb; 240 void *user_cb_st; 241 void *user_data; 242 bcm_vlan_action_set_t *action; 243 bcm_gport_t gport; 244 uint32 key_type; 245 int port_class; 246 bcm_vlan_t outer_vlan; 247 bcm_vlan_t inner_vlan; 248 bcm_vlan_t outer_vlan_high; 249 bcm_vlan_t inner_vlan_high; 250 }_bcm_vlan_translate_traverse_t; 251 252 extern int _bcm_esw_vlan_translate_action_traverse_int_cb(int unit, 253 void* trv_info, 254 int *stop); 255 extern int _bcm_esw_vlan_translate_egress_action_traverse_int_cb(int unit, 256 void* trv_info, 257 int *stop); 258 extern int _bcm_esw_vlan_translate_traverse_int_cb(int unit, void* trv_info, 259 int *stop); 260 extern int _bcm_esw_vlan_translate_egress_traverse_int_cb(int unit, 261 void* trv_info, 262 int *stop); 263 extern int _bcm_esw_vlan_dtag_traverse_int_cb(int unit, void* trv_info, 264 int *stop); 265 extern int _bcm_esw_vlan_translate_traverse_mem(int unit, soc_mem_t mem, 266 _bcm_vlan_translate_traverse_t *trvs_info); 267 268 #ifdef BCM_WARM_BOOT_SUPPORT 269 extern int _bcm_vlan_cleanup(int unit); 270 #else 271 #define _bcm_vlan_cleanup(u) (BCM_E_NONE) 272 #endif /* BCM_WARM_BOOT_SUPPORT */ 273 274 275 extern int _bcm_esw_vlan_untag_update(int unit, bcm_port_t port, int untag); 276 277 #ifdef BCM_WARM_BOOT_SUPPORT 278 extern int _bcm_esw_vlan_sync(int unit); 279 #endif /* BCM_WARM_BOOT_SUPPORT */ 280 281 #ifndef BCM_SW_STATE_DUMP_DISABLE 282 extern void _bcm_vlan_sw_dump(int unit); 283 #endif /* BCM_SW_STATE_DUMP_DISABLE */ 284 285 #if defined(BCM_ESW_SUPPORT) || defined(BCM_PETRA_SUPPORT) || defined(BCM_DFE_SUPPORT) 286 extern int _bcm_vlan_valid_check(int unit, int table, vlan_tab_entry_t *vt, 287 bcm_vlan_t vid); 288 #endif 289 290 #if defined(BCM_EASY_RELOAD_SUPPORT) 291 int _bcm_vlan_valid_set(int unit, int table, bcm_vlan_t vid, int val); 292 #endif 293 294 extern int _bcm_esw_vlan_port_source_vp_lag_set(int unit, bcm_gport_t gport, 295 int vp_lag_vp); 296 extern int _bcm_esw_vlan_port_source_vp_lag_clear(int unit, bcm_gport_t gport, 297 int vp_lag_vp); 298 extern int _bcm_esw_vlan_port_source_vp_lag_get(int unit, bcm_gport_t gport, 299 int *vp_lag_vp); 300 301 extern int _bcm_esw_vlan_system_reserved_get(int unit, int *arg); 302 extern int _bcm_esw_vlan_system_reserved_set(int unit, int arg); 303 304 extern int _bcm_vlan_count_get(int unit, int *arg); 305 extern int _bcm_vbmp_init(vbmp_t *bmp); 306 extern int _bcm_vbmp_destroy(vbmp_t *bmp); 307 308 #if defined(BCM_TRX_SUPPORT) 309 extern int _bcm_trx_vlan_action_profile_ref_count_get(int unit, int index, int *ref_count); 310 extern int _bcm_trx_vlan_action_profile_entry_add(int unit, 311 bcm_vlan_action_set_t *action, 312 uint32 *index); 313 extern int _bcm_trx_vlan_action_profile_entry_delete(int unit, uint32 index); 314 extern int _bcm_trx_vlan_action_verify(int unit, bcm_vlan_action_set_t *action); 315 #endif /* BCM_TRX_SUPPORT */ 316 317 #endif /* !_BCM_INT_VLAN_H */