subport.h (36438B)
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 subport definitions internal to the BCM library. 8 */ 9 10 #include <sal/core/sync.h> 11 #include <bcm/subport.h> 12 #include <bcm/error.h> 13 #include <soc/scache.h> 14 #include <bcm_int/esw/flex_ctr.h> 15 16 #ifndef _BCM_INT_ESW_SUBPORT_H_ 17 #define _BCM_INT_ESW_SUBPORT_H_ 18 19 /** Raghu Start change */ 20 21 /***************************************** 22 * Subport CoE common section - start 23 */ 24 25 /* The common data structures between KT2 and TD2+ Subport-CoE 26 implementation */ 27 28 /* SUBPORT GPORT CoE subtype shift & mask definitions */ 29 30 /* Subport CoE Common defines */ 31 32 #define _BCM_COE_PORT_TYPE_ETHERNET 0 33 #define _BCM_COE_PORT_TYPE_CASCADED 4 34 #define _BCM_COE_PORT_TYPE_CASCADED_LINKPHY 0 35 #define _BCM_COE_PORT_TYPE_CASCADED_SUBTAG 1 36 37 /* Subport group type defs */ 38 #define _BCM_SUBPORT_COE_TYPE_ETHERNET 0 39 #define _BCM_SUBPORT_COE_TYPE_CASCADED 1 40 41 /* Subport type defs */ 42 #define _BCM_SUBPORT_COE_TYPE_LINKPHY 2 43 #define _BCM_SUBPORT_COE_TYPE_SUBTAG 3 44 #define _BCM_SUBPORT_COE_TYPE_GENERAL 1 45 46 /* 47 * LinkPHY/SubTag Subport group gport format 48 * bit 31-26 -- gport type (subport group) 49 * bit 25-24 -- subport group type (cascaded) 50 * bit 19-18 -- subport subtype (linkphy / subtag / general) 51 * bit 17 -- subport group is trunk indicator 52 * bit 16-9 -- subport group port number/trunk group id 53 * bit 8-0 -- subport group index 54 */ 55 #define _BCM_SUBPORT_COE_GROUP_TYPE_MASK 0x3 56 #define _BCM_SUBPORT_COE_GROUP_TYPE_SHIFT 24 57 #define _BCM_SUBPORT_COE_GROUP_SUBTYPE_MASK 0x3 58 #define _BCM_SUBPORT_COE_GROUP_SUBTYPE_SHIFT 18 59 #define _BCM_SUBPORT_COE_GROUP_PORT_MASK 0xFF 60 #define _BCM_SUBPORT_COE_GROUP_PORT_SHIFT 9 61 #define _BCM_SUBPORT_COE_GROUP_SPGID_MASK 0x1FF 62 #define _BCM_SUBPORT_COE_GROUP_SPGID_SHIFT 0 63 64 /* 65 * LinkPHY/SubTag Subport port gport format 66 * bit 31-26 -- gport type (subport port) 67 * bit 25-24 -- subport port type (LinkPHY / SubTag/ General) 68 * bit 23-15 -- zero 69 * bit 14-07 -- subport module index(range 0 to 255) 70 * bit 06-00 -- subport port index (range 0 to 127) 71 */ 72 73 #define _BCM_SUBPORT_COE_PORT_TYPE_MASK 0x3 74 #define _BCM_SUBPORT_COE_PORT_TYPE_SHIFT 24 75 #define _BCM_SUBPORT_COE_PORT_ZERO_BITS_MASK 0x1FF 76 #define _BCM_SUBPORT_COE_PORT_ZERO_BITS_SHIFT 15 77 #define _BCM_SUBPORT_COE_PORT_MODULE_MASK 0xFF 78 #define _BCM_SUBPORT_COE_PORT_MODULE_SHIFT 7 79 #define _BCM_SUBPORT_COE_PORT_PORT_MASK 0x7F 80 #define _BCM_SUBPORT_COE_PORT_PORT_SHIFT 0 81 82 #define _BCM_SUBPORT_COE_PORT_VALUE_MASK 0x7FFF 83 84 #define BCM_SUBPORT_COE_DEFAULT_ETHERTYPE 0x8874 85 86 /* Check if gport is LinkPHY subport_group */ 87 #define _BCM_COE_GPORT_IS_LINKPHY_SUBPORT_GROUP(_subport_group) \ 88 ((((_subport_group >> _BCM_SUBPORT_COE_GROUP_SUBTYPE_SHIFT) & \ 89 _BCM_SUBPORT_COE_GROUP_SUBTYPE_MASK) == \ 90 _BCM_SUBPORT_COE_TYPE_LINKPHY) && \ 91 (((_subport_group >> _BCM_SUBPORT_COE_GROUP_TYPE_SHIFT) & \ 92 _BCM_SUBPORT_COE_GROUP_TYPE_MASK) == \ 93 _BCM_SUBPORT_COE_TYPE_CASCADED)) 94 95 96 /* Check if gport is SubTag subport_group */ 97 #define _BCM_COE_GPORT_IS_SUBTAG_SUBPORT_GROUP(_subport_group) \ 98 ((((_subport_group >> _BCM_SUBPORT_COE_GROUP_SUBTYPE_SHIFT) & \ 99 _BCM_SUBPORT_COE_GROUP_SUBTYPE_MASK) == \ 100 _BCM_SUBPORT_COE_TYPE_SUBTAG) && \ 101 (((_subport_group >> _BCM_SUBPORT_COE_GROUP_TYPE_SHIFT) & \ 102 _BCM_SUBPORT_COE_GROUP_TYPE_MASK) == \ 103 _BCM_SUBPORT_COE_TYPE_CASCADED)) 104 105 106 /* Check if gport is general subport_group */ 107 #define _BCM_COE_GPORT_IS_GENERAL_SUBPORT_GROUP(_subport_group) \ 108 ((((_subport_group >> _BCM_SUBPORT_COE_GROUP_SUBTYPE_SHIFT) & \ 109 _BCM_SUBPORT_COE_GROUP_SUBTYPE_MASK) == \ 110 _BCM_SUBPORT_COE_TYPE_GENERAL) && \ 111 (((_subport_group >> _BCM_SUBPORT_COE_GROUP_TYPE_SHIFT) & \ 112 _BCM_SUBPORT_COE_GROUP_TYPE_MASK) == \ 113 _BCM_SUBPORT_COE_TYPE_CASCADED)) 114 115 /* Set the subport port gport type */ 116 #define _BCM_SUBPORT_COE_PORT_TYPE_SET(_subport_port, _type) \ 117 (_subport_port |= ((_type & _BCM_SUBPORT_COE_PORT_TYPE_MASK) \ 118 << _BCM_SUBPORT_COE_PORT_TYPE_SHIFT)) 119 120 121 /* Get port number/trunk id associated with subport_group gport */ 122 #define _BCM_SUBPORT_COE_GROUP_PORT_GET(_subport_group) \ 123 ((_subport_group >> _BCM_SUBPORT_COE_GROUP_PORT_SHIFT) & \ 124 _BCM_SUBPORT_COE_GROUP_PORT_MASK) 125 126 /* Get group id associated with subport_group gport */ 127 #define _BCM_SUBPORT_COE_GROUP_ID_GET(_subport_group) \ 128 (((_subport_group) >> _BCM_SUBPORT_COE_GROUP_SPGID_SHIFT) & \ 129 _BCM_SUBPORT_COE_GROUP_SPGID_MASK) 130 131 #define _BCM_SUBPORT_COE_GROUP_TYPE_CASCADED_SET(_subport_group) \ 132 ((_subport_group) |= ((_BCM_SUBPORT_COE_TYPE_CASCADED & \ 133 _BCM_SUBPORT_COE_GROUP_TYPE_MASK) \ 134 << _BCM_SUBPORT_COE_GROUP_TYPE_SHIFT)) 135 136 /* 137 * Subtended port Function Vector Driver 138 */ 139 typedef struct bcm_esw_subport_drv_s { 140 /* 141 * Subport APIs 142 */ 143 144 /* Initial subport module handlers */ 145 146 /* Initalize enhanced subport module */ 147 int (*subport_init)(int unit); 148 /* Create Subport group */ 149 int (*subport_group_create)(int unit, bcm_subport_group_config_t *config, 150 bcm_gport_t *group); 151 /* Delete Subport group */ 152 int (*subport_group_get)(int unit, bcm_gport_t group, 153 bcm_subport_group_config_t *config); 154 /* Traverse Subport group */ 155 int (*subport_group_traverse)(int unit, bcm_gport_t subport_group, 156 bcm_subport_port_traverse_cb cb, void *user_data); 157 /* Destroy Subport group */ 158 int (*subport_group_destroy)(int unit, bcm_gport_t group); 159 /* Set LinkPhy config */ 160 int (*subport_linkphy_config_set)(int unit, bcm_gport_t port, 161 bcm_subport_group_linkphy_config_t *linkphy_config); 162 /* Get LinkPhy config */ 163 int (*subport_linkphy_config_get)(int unit, bcm_gport_t port, 164 bcm_subport_group_linkphy_config_t *linkphy_config); 165 166 /* Subport port add */ 167 int (*subport_port_add)(int unit, bcm_subport_config_t *config, 168 bcm_gport_t *port); 169 /* Subport port get */ 170 int (*subport_port_get)(int unit, bcm_gport_t port, 171 bcm_subport_config_t *config); 172 /* Subport port traverse */ 173 int (*subport_port_traverse)(int unit, 174 bcm_subport_port_traverse_cb cb, 175 void *user_data); 176 /* Subport port stat set */ 177 int (*subport_port_stat_set)(int unit, bcm_gport_t port, 178 int stream_id, 179 bcm_subport_stat_t stat_type, uint64 val); 180 /* Subport port stat get */ 181 int (*subport_port_stat_get)(int unit, bcm_gport_t port, int stream_id, 182 bcm_subport_stat_t stat_type, uint64 *val); 183 /* Subport port delete */ 184 int (*subport_port_delete)(int unit, bcm_gport_t port); 185 /* Subport module cleanup */ 186 int (*subport_cleanup)(int unit); 187 188 /* CoE module handlers */ 189 190 /* Init CoE subport module handlers */ 191 int (*coe_init)(int unit); 192 /* Create Subport group */ 193 int (*coe_group_create)(int unit, bcm_subport_group_config_t *config, 194 bcm_gport_t *group); 195 /* Delete Subport group */ 196 int (*coe_group_get)(int unit, bcm_gport_t group, 197 bcm_subport_group_config_t *config); 198 /* Traverse Subport group */ 199 int (*coe_group_traverse)(int unit, bcm_gport_t subport_group, 200 bcm_subport_port_traverse_cb cb, 201 void *user_data); 202 /* Destroy Subport group */ 203 int (*coe_group_destroy)(int unit, bcm_gport_t group); 204 /* Set LinkPhy config */ 205 int (*coe_group_linkphy_config_set)(int unit, bcm_gport_t port, 206 bcm_subport_group_linkphy_config_t *linkphy_config); 207 /* Get LinkPhy config */ 208 int (*coe_group_linkphy_config_get)(int unit, bcm_gport_t port, 209 bcm_subport_group_linkphy_config_t *linkphy_config); 210 211 /* Subport port add */ 212 int (*coe_port_add)(int unit, bcm_subport_config_t *config, 213 bcm_gport_t *port); 214 /* Subport port get */ 215 int (*coe_port_get)(int unit, bcm_gport_t port, 216 bcm_subport_config_t *config); 217 /* Subport port traverse */ 218 int (*coe_port_traverse)(int unit, bcm_subport_port_traverse_cb cb, 219 void *user_data); 220 /* Subport port stat set */ 221 int (*coe_port_stat_set)(int unit, bcm_gport_t port, int stream_id, 222 bcm_subport_stat_t stat_type, uint64 val); 223 /* Subport port stat get */ 224 int (*coe_port_stat_get)(int unit, bcm_gport_t port, int stream_id, 225 bcm_subport_stat_t stat_type, uint64 *val); 226 /* Subport port delete */ 227 int (*coe_port_delete)(int unit, bcm_gport_t port); 228 /* Subport module cleanup */ 229 int (*coe_cleanup)(int unit); 230 /* subport_linkphy_rx_error_register */ 231 int (*subport_linkphy_rx_error_register) (int unit, 232 bcm_subport_linkphy_rx_errors_t errors, 233 bcm_subport_linkphy_rx_error_reg_info_t *reg_info, 234 void *user_data); 235 /* subport_linkphy_rx_error_unregister */ 236 int (*subport_linkphy_rx_error_unregister) (int unit, 237 bcm_subport_linkphy_rx_errors_t errors); 238 /* subport_gport mod-port get */ 239 int (*subport_gport_modport_get) (int unit, 240 bcm_gport_t subport_gport, bcm_module_t *module, 241 bcm_port_t *port); 242 243 } bcm_esw_subport_drv_t; 244 245 extern bcm_esw_subport_drv_t *bcm_esw_subport_drv[BCM_MAX_NUM_UNITS]; 246 247 #define BCM_ESW_SUBPORT_DRV(_u) (bcm_esw_subport_drv[(_u)]) 248 249 extern int bcmi_subport_common_init(int unit, bcm_esw_subport_drv_t *drv); 250 251 /* 252 * Bitmap of subport group id 253 * Each Subport group created has unique group id 254 * across all ports in the device irrespective of 255 * group type LinkPHY/SubTag 256 */ 257 extern SHR_BITDCL *_bcm_subport_group_bitmap[BCM_MAX_NUM_UNITS]; 258 259 /* Count of all subport groups created */ 260 extern int _bcm_subport_group_count[BCM_MAX_NUM_UNITS]; 261 262 /* Count subport port per subport group*/ 263 extern int *(_bcm_subport_group_subport_port_count[BCM_MAX_NUM_UNITS]); 264 265 266 /********************************* 267 * Subport common section - end 268 */ 269 270 /***************************************** 271 * General purpose subport section - start 272 */ 273 274 /* Bitmap of general subport group id */ 275 extern SHR_BITDCL *_bcm_general_subport_group_bitmap[BCM_MAX_NUM_UNITS]; 276 277 /* Count of all general subport groups created */ 278 extern int _bcm_general_subport_group_count[BCM_MAX_NUM_UNITS]; 279 280 /* general subport port info structure */ 281 typedef struct { 282 /* Subport group gort attached to */ 283 bcm_gport_t group; 284 int valid; 285 } _bcm_general_subport_port_info_t; 286 287 extern _bcm_general_subport_port_info_t 288 *(_bcm_general_subport_port_info[BCM_MAX_NUM_UNITS]); 289 290 /***************************************** 291 * General purpose subport section - end 292 */ 293 294 /********************************* 295 * SubTag subport section - start 296 */ 297 298 /* Bitmap of SubTag subport group id */ 299 extern SHR_BITDCL *_bcm_subtag_group_bitmap[BCM_MAX_NUM_UNITS]; 300 301 /* Count of all SubTag subport groups created */ 302 extern int _bcm_subtag_subport_group_count[BCM_MAX_NUM_UNITS]; 303 304 extern SHR_BITDCL *_bcm_subtag_vlan_id_bitmap 305 [BCM_MAX_NUM_UNITS][SOC_MAX_NUM_PORTS]; 306 307 extern SHR_BITDCL *_bcm_subport_port_group_bitmap[BCM_MAX_NUM_UNITS]; 308 309 /* SubTag subport port info structure */ 310 typedef struct { 311 /* Subport group gort attached to */ 312 bcm_gport_t group; 313 /* VLAN ID */ 314 bcm_vlan_t vlan; 315 int valid; 316 int subtag_tcam_hw_idx; 317 int modport_subport_idx; 318 /* Subport-Port, represented as GPORT_SUBPORT */ 319 bcm_gport_t subport_port; 320 /* Associated subport, represented as GPORT_MODPORT */ 321 bcm_gport_t subport_modport; 322 int phb_valid; 323 int priority; 324 int color; 325 int nh_index; 326 } _bcm_subtag_subport_port_info_t; 327 328 extern _bcm_subtag_subport_port_info_t 329 *(_bcm_subtag_subport_port_info[BCM_MAX_NUM_UNITS]); 330 331 /********************************* 332 * SubTag subport section - end 333 */ 334 335 336 /**** Misc section start */ 337 338 extern sal_mutex_t _bcm_subport_mutex[BCM_MAX_NUM_UNITS]; 339 340 #define _BCM_SUBPORT_COE_LOCK(unit) \ 341 sal_mutex_take(_bcm_subport_mutex[unit], sal_mutex_FOREVER); 342 343 #define _BCM_SUBPORT_COE_UNLOCK(unit) \ 344 sal_mutex_give(_bcm_subport_mutex[unit]); 345 346 347 #define _BCM_SUBPORT_COE_CHECK_INIT(_unit_) \ 348 if (!_bcm_subport_group_bitmap[_unit_]) \ 349 return BCM_E_INIT 350 351 /**** Misc section end */ 352 353 354 /** Common defines for CoE implementation - start */ 355 356 /* 357 * Subport group usage bitmap operations 358 */ 359 #define _BCM_SUBPORT_COE_GROUP_USED_GET(_u_, _group_) \ 360 SHR_BITGET(_bcm_subport_group_bitmap[_u_], (_group_)) 361 362 #define _BCM_SUBPORT_COE_GROUP_USED_SET(_u_, _group_) \ 363 SHR_BITSET(_bcm_subport_group_bitmap[_u_], (_group_)) 364 365 #define _BCM_SUBPORT_COE_GROUP_USED_CLR(_u_, _group_) \ 366 SHR_BITCLR(_bcm_subport_group_bitmap[_u_], (_group_)) 367 368 /* 369 * General subport group usage bitmap operations 370 */ 371 #define _BCM_GENERAL_SUBPORT_GROUP_USED_GET(_u_, _group_) \ 372 SHR_BITGET(_bcm_general_subport_group_bitmap[_u_], (_group_)) 373 374 #define _BCM_GENERAL_SUBPORT_GROUP_USED_SET(_u_, _group_) \ 375 SHR_BITSET(_bcm_general_subport_group_bitmap[_u_], (_group_)) 376 377 #define _BCM_GENERAL_SUBPORT_GROUP_USED_CLR(_u_, _group_) \ 378 SHR_BITCLR(_bcm_general_subport_group_bitmap[_u_], (_group_)) 379 380 /* 381 * SubTag subport group usage bitmap operations 382 */ 383 #define _BCM_SUBPORT_COE_SUBTAG_GROUP_USED_GET(_u_, _group_) \ 384 SHR_BITGET(_bcm_subtag_group_bitmap[_u_], (_group_)) 385 386 #define _BCM_SUBPORT_COE_SUBTAG_GROUP_USED_SET(_u_, _group_) \ 387 SHR_BITSET(_bcm_subtag_group_bitmap[_u_], (_group_)) 388 389 #define _BCM_SUBPORT_COE_SUBTAG_GROUP_USED_CLR(_u_, _group_) \ 390 SHR_BITCLR(_bcm_subtag_group_bitmap[_u_], (_group_)) 391 392 /* Katana2 SubTag VLAN id usage bitmap for given port*/ 393 #define _BCM_COE_SUBTAG_VLAN_ID_USED_GET(_u_, _p, _vlan_id_) \ 394 SHR_BITGET(_bcm_subtag_vlan_id_bitmap[_u_][_p], (_vlan_id_)) 395 396 #define _BCM_COE_SUBTAG_VLAN_ID_USED_SET(_u_, _p, _vlan_id_) \ 397 SHR_BITSET(_bcm_subtag_vlan_id_bitmap[_u_][_p], (_vlan_id_)) 398 399 #define _BCM_COE_SUBTAG_VLAN_ID_USED_CLR(_u_, _p, _vlan_id_) \ 400 SHR_BITCLR(_bcm_subtag_vlan_id_bitmap[_u_][_p], (_vlan_id_)) 401 402 403 /* Set the SubTag subport group gport */ 404 405 /* The encoding is like this, based on the flags used: 406 GPORT-TYPE-SUBPORT, SUBTYPE-SUBPORT, PHYSICAL-PORT, GroupId 407 */ 408 409 #define _BCM_SUBPORT_COE_SUBTAG_GROUP_SET(_subport_group, \ 410 _port, _gid) \ 411 (BCM_GPORT_SUBPORT_GROUP_SET((_subport_group), \ 412 (((_BCM_SUBPORT_COE_TYPE_SUBTAG & \ 413 _BCM_SUBPORT_COE_GROUP_SUBTYPE_MASK) \ 414 << _BCM_SUBPORT_COE_GROUP_SUBTYPE_SHIFT) | \ 415 ((_port & _BCM_SUBPORT_COE_GROUP_PORT_MASK) \ 416 << _BCM_SUBPORT_COE_GROUP_PORT_SHIFT) | \ 417 ((_gid & _BCM_SUBPORT_COE_GROUP_SPGID_MASK) \ 418 << _BCM_SUBPORT_COE_GROUP_SPGID_SHIFT)))) 419 420 /* Set the LinkPHY subport group gport */ 421 422 /* The encoding is like this, based on the flags used: 423 GPORT-TYPE-SUBPORT, SUBTYPE-LINKPHY, PHYSICAL-PORT, GroupId 424 */ 425 #define _BCM_COE_LINKPHY_SUBPORT_GROUP_SET(_subport_group, \ 426 _port, _gid) \ 427 (BCM_GPORT_SUBPORT_GROUP_SET((_subport_group), \ 428 (((_BCM_SUBPORT_COE_TYPE_LINKPHY & \ 429 _BCM_SUBPORT_COE_GROUP_SUBTYPE_MASK) \ 430 << _BCM_SUBPORT_COE_GROUP_SUBTYPE_SHIFT) | \ 431 ((_port & _BCM_SUBPORT_COE_GROUP_PORT_MASK) \ 432 << _BCM_SUBPORT_COE_GROUP_PORT_SHIFT) | \ 433 ((_gid & _BCM_SUBPORT_COE_GROUP_SPGID_MASK) \ 434 << _BCM_SUBPORT_COE_GROUP_SPGID_SHIFT)))) 435 436 /* Set the general group gport */ 437 438 /* The encoding is like this, based on the flags used: 439 GPORT-TYPE-SUBPORT, SUBTYPE-GENERAL, PHYSICAL-PORT, GroupId 440 */ 441 #define _BCM_GENERAL_SUBPORT_GROUP_SET(_subport_group, \ 442 _port, _gid) \ 443 (BCM_GPORT_SUBPORT_GROUP_SET((_subport_group), \ 444 (((_BCM_SUBPORT_COE_TYPE_GENERAL & \ 445 _BCM_SUBPORT_COE_GROUP_SUBTYPE_MASK) \ 446 << _BCM_SUBPORT_COE_GROUP_SUBTYPE_SHIFT) | \ 447 ((_port & _BCM_SUBPORT_COE_GROUP_PORT_MASK) \ 448 << _BCM_SUBPORT_COE_GROUP_PORT_SHIFT) | \ 449 ((_gid & _BCM_SUBPORT_COE_GROUP_SPGID_MASK) \ 450 << _BCM_SUBPORT_COE_GROUP_SPGID_SHIFT)))) 451 452 /** Common defines for CoE implementation - end */ 453 454 455 #ifdef BCM_HGPROXY_COE_SUPPORT 456 457 #define _BCM_SUBPORT_COE_SUBTAG_PORT_INFO_VALID_GET(unit, tcam_hw_id) \ 458 (_bcm_subtag_subport_port_info[unit][tcam_hw_id].valid) 459 460 #define _BCM_SUBPORT_COE_SUBTAG_PORT_INFO_GROUP_GET(unit, tcam_hw_id) \ 461 (_bcm_subtag_subport_port_info[unit][tcam_hw_id].group) 462 463 #define _BCM_SUBPORT_COE_SUBTAG_PORT_INFO_VLAN_GET(unit, tcam_hw_id) \ 464 (_bcm_subtag_subport_port_info[unit][tcam_hw_id].vlan) 465 466 #define _BCM_SUBPORT_COE_SUBTAG_PORT_INFO_TCAM_HW_ID_GET(unit, tcam_hw_id) \ 467 (_bcm_subtag_subport_port_info[unit][tcam_hw_id].subtag_tcam_hw_idx) 468 469 #define _BCM_SUBPORT_COE_SUBTAG_PORT_INFO_SUBPORT_MODPORT_GET(unit, tcam_hw_id) \ 470 (_bcm_subtag_subport_port_info[unit][tcam_hw_id].subport_modport) 471 472 #define _BCM_SUBPORT_COE_SUBTAG_PORT_INFO_MODPORT_IDX_GET(unit, tcam_hw_id) \ 473 (_bcm_subtag_subport_port_info[unit][tcam_hw_id].modport_subport_idx) 474 475 #define _BCM_SUBPORT_COE_SUBTAG_PORT_INFO_SET(unit, tcam_hw_id, tcam_hw_mem_idx, \ 476 sp_group, vlan_id, subport_port_val, subport_modport_val, phbValid, \ 477 pri, col, is_valid, modport_subport_idx_val) \ 478 { \ 479 _bcm_subtag_subport_port_info[unit][tcam_hw_id].group = sp_group; \ 480 _bcm_subtag_subport_port_info[unit][tcam_hw_id].vlan = vlan_id; \ 481 _bcm_subtag_subport_port_info[unit] \ 482 [tcam_hw_id].subtag_tcam_hw_idx = \ 483 tcam_hw_mem_idx; \ 484 _bcm_subtag_subport_port_info[unit][tcam_hw_id].subport_port = \ 485 subport_port_val; \ 486 _bcm_subtag_subport_port_info[unit][tcam_hw_id].subport_modport = \ 487 subport_modport_val; \ 488 _bcm_subtag_subport_port_info[unit][tcam_hw_id].phb_valid = phbValid; \ 489 _bcm_subtag_subport_port_info[unit][tcam_hw_id].priority = pri; \ 490 _bcm_subtag_subport_port_info[unit][tcam_hw_id].color = col; \ 491 _bcm_subtag_subport_port_info[unit][tcam_hw_id].valid = is_valid; \ 492 _bcm_subtag_subport_port_info[unit][tcam_hw_id].modport_subport_idx = \ 493 modport_subport_idx_val; \ 494 } 495 496 /* Set the subport port gport mod,port id */ 497 #define _BCM_SUBPORT_COE_PORT_ID_SET(_subport_port, mod, port) \ 498 (BCM_GPORT_SUBPORT_PORT_SET((_subport_port), \ 499 ((mod & _BCM_SUBPORT_COE_PORT_MODULE_MASK) \ 500 << _BCM_SUBPORT_COE_PORT_MODULE_SHIFT) | \ 501 ((port & _BCM_SUBPORT_COE_PORT_PORT_MASK) \ 502 << _BCM_SUBPORT_COE_PORT_PORT_SHIFT))) 503 504 /* Get the subport port gport mod id */ 505 #define _BCM_SUBPORT_COE_PORT_ID_MOD_GET(_subport_port) \ 506 ((_subport_port >> _BCM_SUBPORT_COE_PORT_MODULE_SHIFT) & \ 507 _BCM_SUBPORT_COE_PORT_MODULE_MASK) 508 509 /* Get the subport port gport port id */ 510 #define _BCM_SUBPORT_COE_PORT_ID_PORT_GET(_subport_port) \ 511 ((_subport_port >> _BCM_SUBPORT_COE_PORT_PORT_SHIFT) & \ 512 _BCM_SUBPORT_COE_PORT_PORT_MASK) 513 514 /* Get the subport port gport mod id */ 515 #define _BCM_SUBPORT_COE_PORT_ID_GET(_subport_port) \ 516 ((_subport_port & (_BCM_SUBPORT_COE_PORT_VALUE_MASK))) 517 518 /* Check if gport is SubTag subport_port */ 519 #define _BCM_COE_GPORT_IS_SUBTAG_SUBPORT_PORT(_unit, _subport_port) \ 520 (((((_subport_port) >> _BCM_SUBPORT_COE_PORT_TYPE_SHIFT) & \ 521 _BCM_SUBPORT_COE_PORT_TYPE_MASK) == \ 522 _BCM_SUBPORT_COE_TYPE_SUBTAG) && \ 523 ((((_subport_port) >> _BCM_SUBPORT_COE_PORT_ZERO_BITS_SHIFT) & \ 524 _BCM_SUBPORT_COE_PORT_ZERO_BITS_MASK) == 0)) 525 526 /* Traverse all valid hgproxy SubTag subport ports */ 527 #define BCM_HGPROXY_SUBTAG_COE_PORT_ITER(i, gport) \ 528 if ((soc_feature(unit, soc_feature_hgproxy_subtag_coe) || \ 529 (soc_feature(unit, soc_feature_channelized_switching))) && \ 530 (_bcm_subtag_subport_port_info[unit] != NULL)) \ 531 for (i = 0; i < SOC_INFO(unit).max_subport_coe_ports; i++) \ 532 if((_bcm_subtag_subport_port_info[unit][i].valid) && \ 533 (gport = \ 534 _bcm_subtag_subport_port_info[unit][i].subport_port)) 535 536 /* Get the subport port gport mod id */ 537 #define _BCM_SUBPORT_COE_PORT_GLP_GET(_subport_port) \ 538 (_BCM_SUBPORT_COE_PORT_ID_MOD_GET(_subport_port) << 8 ) | \ 539 (_BCM_SUBPORT_COE_PORT_ID_PORT_GET(_subport_port)) 540 541 #endif /* BCM_HGPROXY_COE_SUPPORT */ 542 543 544 #ifdef BCM_APACHE_SUPPORT 545 546 #define _BCM_APACHE_SUBPORT_COE_GROUP_MAX (256) 547 #define _BCM_APACHE_SUBPORT_COE_PORT_MAX (256) 548 #define _BCM_APACHE_MAX_SUBPORT_COE_PER_PORT (80) 549 550 #endif /* BCM_APACHE_SUPPORT */ 551 552 /** End change */ 553 554 #ifdef BCM_KATANA2_SUPPORT 555 556 /* Subport Common defines */ 557 #define _BCM_KT2_PORT_TYPE_ETHERNET _BCM_COE_PORT_TYPE_ETHERNET 558 #define _BCM_KT2_PORT_TYPE_CASCADED _BCM_COE_PORT_TYPE_CASCADED 559 #define _BCM_KT2_PORT_TYPE_CASCADED_LINKPHY _BCM_COE_PORT_TYPE_CASCADED_LINKPHY 560 #define _BCM_KT2_PORT_TYPE_CASCADED_SUBTAG _BCM_COE_PORT_TYPE_CASCADED_SUBTAG 561 562 #define _BCM_KT2_GPORT_IS_LINKPHY_OR_SUBTAG_SUBPORT_GPORT(_unit, _gport) \ 563 (BCM_GPORT_IS_SUBPORT_PORT(_gport) && \ 564 ((soc_feature(_unit, soc_feature_linkphy_coe) && \ 565 _BCM_KT2_GPORT_IS_LINKPHY_SUBPORT_PORT (_unit, _gport)) || \ 566 (soc_feature(_unit, soc_feature_subtag_coe) && \ 567 _BCM_KT2_GPORT_IS_SUBTAG_SUBPORT_PORT (_unit, _gport)) || \ 568 (soc_feature(_unit, soc_feature_general_cascade) && \ 569 _BCM_KT2_GPORT_IS_GENERAL_SUBPORT_PORT (_unit, _gport)))) 570 571 /* LinkPHY subport specific defines */ 572 #define _BCM_KT2_LINKPHY_STREAMS_MAX 1024 573 #define _BCM_KT2_LINKPHY_PER_PORT_STREAMS_MAX 128 574 #define _BCM_KT2_LINKPHY_PER_BLK_STREAMS_MAX 128 575 /* 576 * Maximum number of streams supported are 2 per 577 * subport where each subport port can support 4 578 * Stream Ids in the range Id, Id + 3. 579 */ 580 #define _BCM_KT2_LINKPHY_MAX_STREAM_IDS_PER_PORT 4 581 582 #define _BCM_SB2_MAX_LINKPHY_PORTS 4 583 #define _BCM_SB2_MAX_INT_STREAMS_PER_LINKPHY_PORT 8 584 #define _BCM_SB2_MAX_EXT_STREAMS_PER_LINKPHY_PORT 32 585 586 #define _BCM_ML_MAX_LINKPHY_PORTS 4 587 #define _BCM_ML_MAX_INT_STREAMS_PER_LINKPHY_PORT 6 588 #define _BCM_ML_MAX_EXT_STREAMS_PER_LINKPHY_PORT 24 589 #define _BCM_ML_LINKPHY_PER_BLK_STREAMS_MAX 24 590 591 /* 592 * Katana2: 593 * There are two tables in TXLP Block in MXQ8 and MXQ9 blocks 594 * 1. TXLP_PORT_ADDR_MAP_TABLE - This is programmed when the 595 * port is in Non-linkPhy Mode. The start_addr and the end_addr 596 * are set based on the speed of the port. 597 * 2. TXLP_STREAM_ADDR_MAP_TABLE - This is programmed when the 598 * port is in LinkPhy mode. The startaddr and end_addr are 599 * programmed per stream. 600 * The buffer allocation done as part of the above should be unique 601 * There are 3423 lines of buffer, reserving the first 0x5f lines 602 * of buffer for the ports which are in Non-LinkPhy mode. 603 * When LinkPhy is enabled on a port, the start_addr and end_addr 604 * for the port in TXLP_PORT_ADDR_MAP_TABLE is set to 0. And the 605 * buffer allocated to the port previously is unused. Since the port 606 * is in LinkPhy mode the start_addr and end_addr in 607 * TXLP_STREAM_ADDR_MAP_TABLE is programmed with buffer space 608 * leaving buffer space from 0x0 to 0x5f as reserve for Non-linkPhy 609 * Ports. 610 */ 611 #define _BCM_KT2_LINKPHY_STREAM_ID_FLUSH_TIMEOUT 20000 612 613 /* 614 * Katana2 LinkPHY/SubTag subport feature supports 615 * 1.creation of multiple logical subport groups per port. 616 * Port/trunk_id and group id are stored in subport group gport. 617 * 2.attachment of multiple subport ports to a subport group 618 * A subport port is represented by 619 * a. (port, external stream id array)] for LinkPHY subport 620 * b. (port, VLAN) for SubTag subport 621 * Group id and subport_port id are stored in subport port gport. 622 */ 623 624 #define _BCM_KT2_SUBPORT_TYPE_ETHERNET _BCM_SUBPORT_COE_TYPE_ETHERNET 625 #define _BCM_KT2_SUBPORT_TYPE_CASCADED _BCM_SUBPORT_COE_TYPE_CASCADED 626 #define _BCM_KT2_SUBPORT_TYPE_LINKPHY _BCM_SUBPORT_COE_TYPE_LINKPHY 627 #define _BCM_KT2_SUBPORT_TYPE_SUBTAG _BCM_SUBPORT_COE_TYPE_SUBTAG 628 #define _BCM_KT2_SUBPORT_TYPE_GENERAL _BCM_SUBPORT_COE_TYPE_GENERAL 629 630 /* 631 * LinkPHY/SubTag Subport group gport format 632 * bit 31-26 -- gport type (subport group) 633 * bit 25-24 -- subport group type (cascaded) 634 * bit 18-17 -- subport subtype (linkphy / subtag / general) 635 * bit 17 -- subport group is trunk indicator 636 * bit 16-9 -- subport group port number/trunk group id 637 * bit 8 -0 -- subport group index 638 */ 639 #define _BCM_KT2_SUBPORT_GROUP_TYPE_MASK \ 640 _BCM_SUBPORT_COE_GROUP_TYPE_MASK 641 #define _BCM_KT2_SUBPORT_GROUP_TYPE_SHIFT \ 642 _BCM_SUBPORT_COE_GROUP_TYPE_SHIFT 643 #define _BCM_KT2_SUBPORT_GROUP_SUBTYPE_MASK \ 644 _BCM_SUBPORT_COE_GROUP_SUBTYPE_MASK 645 #define _BCM_KT2_SUBPORT_GROUP_SUBTYPE_SHIFT \ 646 _BCM_SUBPORT_COE_GROUP_SUBTYPE_SHIFT 647 #define _BCM_KT2_SUBPORT_GROUP_PORT_MASK \ 648 _BCM_SUBPORT_COE_GROUP_PORT_MASK 649 #define _BCM_KT2_SUBPORT_GROUP_PORT_SHIFT \ 650 _BCM_SUBPORT_COE_GROUP_PORT_SHIFT 651 #define _BCM_KT2_SUBPORT_GROUP_SPGID_MASK \ 652 _BCM_SUBPORT_COE_GROUP_SPGID_MASK 653 #define _BCM_KT2_SUBPORT_GROUP_SPGID_SHIFT \ 654 _BCM_SUBPORT_COE_GROUP_SPGID_SHIFT 655 /* 656 * LinkPHY/SubTag Subport port gport format 657 * bit 31-26 -- gport type (subport port) 658 * bit 25-24 -- subport port type (LinkPHY / SubTag/ General) 659 * bit 23-08 -- zero 660 * bit 07-00 -- subport port index (range 42 to 169) 661 */ 662 663 #define _BCM_KT2_SUBPORT_PORT_TYPE_MASK 0x3 664 #define _BCM_KT2_SUBPORT_PORT_TYPE_SHIFT 24 665 #define _BCM_KT2_SUBPORT_PORT_ZERO_BITS_MASK 0xFFFF 666 #define _BCM_KT2_SUBPORT_PORT_ZERO_BITS_SHIFT 8 667 #define _BCM_KT2_SUBPORT_PORT_PP_PORT_MASK 0xFF 668 #define _BCM_KT2_SUBPORT_PORT_PP_PORT_SHIFT 0 669 670 /* Check if gport is LinkPHY subport_group */ 671 #define _BCM_KT2_GPORT_IS_LINKPHY_SUBPORT_GROUP(_subport_group) \ 672 _BCM_COE_GPORT_IS_LINKPHY_SUBPORT_GROUP(_subport_group) 673 674 /* Check if gport is SubTag subport_group */ 675 #define _BCM_KT2_GPORT_IS_SUBTAG_SUBPORT_GROUP(_subport_group) \ 676 _BCM_COE_GPORT_IS_SUBTAG_SUBPORT_GROUP(_subport_group) 677 678 /* Check if gport is general subport_group */ 679 #define _BCM_KT2_GPORT_IS_GENERAL_SUBPORT_GROUP(_subport_group) \ 680 _BCM_COE_GPORT_IS_GENERAL_SUBPORT_GROUP(_subport_group) 681 682 /* Set the subport port gport type*/ 683 #define _BCM_KT2_SUBPORT_PORT_TYPE_SET(_subport_port, _type) \ 684 _BCM_SUBPORT_COE_PORT_TYPE_SET(_subport_port, _type) 685 686 /* Set the subport port gport pp_port id*/ 687 #define _BCM_KT2_SUBPORT_PORT_ID_SET(_subport_port, _pp_port) \ 688 (BCM_GPORT_SUBPORT_PORT_SET((_subport_port), \ 689 ((_pp_port & _BCM_KT2_SUBPORT_PORT_PP_PORT_MASK) \ 690 << _BCM_KT2_SUBPORT_PORT_PP_PORT_SHIFT))) 691 692 /* Get the subport port gport pp_port id */ 693 #define _BCM_KT2_SUBPORT_PORT_ID_GET(_subport_port) \ 694 (((_subport_port) >> _BCM_KT2_SUBPORT_PORT_PP_PORT_SHIFT) & \ 695 _BCM_KT2_SUBPORT_PORT_PP_PORT_MASK) 696 697 698 /* Check if gport is LinkPHY subport_port */ 699 #define _BCM_KT2_GPORT_IS_LINKPHY_SUBPORT_PORT(_unit, _subport_port) \ 700 (((((_subport_port) >> _BCM_KT2_SUBPORT_PORT_TYPE_SHIFT) & \ 701 _BCM_KT2_SUBPORT_PORT_TYPE_MASK) == \ 702 _BCM_KT2_SUBPORT_TYPE_LINKPHY) && \ 703 ((((_subport_port) >> _BCM_KT2_SUBPORT_PORT_ZERO_BITS_SHIFT) & \ 704 _BCM_KT2_SUBPORT_PORT_ZERO_BITS_MASK) == 0) && \ 705 (BCM_PBMP_MEMBER(SOC_INFO(_unit).linkphy_pp_port_pbm, \ 706 (((_subport_port) >> _BCM_KT2_SUBPORT_PORT_PP_PORT_SHIFT) & \ 707 _BCM_KT2_SUBPORT_PORT_PP_PORT_MASK)))) 708 709 /* Check if gport is SubTag subport_port */ 710 #define _BCM_KT2_GPORT_IS_SUBTAG_SUBPORT_PORT(_unit, _subport_port) \ 711 (((((_subport_port) >> _BCM_KT2_SUBPORT_PORT_TYPE_SHIFT) & \ 712 _BCM_KT2_SUBPORT_PORT_TYPE_MASK) == \ 713 _BCM_KT2_SUBPORT_TYPE_SUBTAG) && \ 714 ((((_subport_port) >> _BCM_KT2_SUBPORT_PORT_ZERO_BITS_SHIFT) & \ 715 _BCM_KT2_SUBPORT_PORT_ZERO_BITS_MASK) == 0) && \ 716 (BCM_PBMP_MEMBER(SOC_INFO(_unit).subtag_pp_port_pbm, \ 717 (((_subport_port) >> _BCM_KT2_SUBPORT_PORT_PP_PORT_SHIFT) & \ 718 _BCM_KT2_SUBPORT_PORT_PP_PORT_MASK)))) 719 720 /* Check if gport is General subport_port */ 721 #define _BCM_KT2_GPORT_IS_GENERAL_SUBPORT_PORT(_unit, _subport_port) \ 722 (((((_subport_port) >> _BCM_KT2_SUBPORT_PORT_TYPE_SHIFT) & \ 723 _BCM_KT2_SUBPORT_PORT_TYPE_MASK) == \ 724 _BCM_KT2_SUBPORT_TYPE_GENERAL) && \ 725 ((((_subport_port) >> _BCM_KT2_SUBPORT_PORT_ZERO_BITS_SHIFT) & \ 726 _BCM_KT2_SUBPORT_PORT_ZERO_BITS_MASK) == 0) && \ 727 (BCM_PBMP_MEMBER(SOC_INFO(_unit).general_pp_port_pbm, \ 728 (((_subport_port) >> _BCM_KT2_SUBPORT_PORT_PP_PORT_SHIFT) & \ 729 _BCM_KT2_SUBPORT_PORT_PP_PORT_MASK)))) 730 731 732 typedef struct { 733 bcm_port_t port; 734 int port_type; 735 bcm_vlan_t subtag; 736 int num_streams; 737 uint16 dev_int_stream_id[BCM_SUBPORT_CONFIG_MAX_STREAMS]; 738 } _bcm_kt2_subport_info_t; 739 740 #endif /* BCM_KATANA2_SUPPORT */ 741 742 #ifdef BCM_WARM_BOOT_SUPPORT 743 #define BCM_SUBPORT_WB_VERSION_1_0 SOC_SCACHE_VERSION(1,0) 744 #define BCM_SUBPORT_WB_VERSION_1_1 SOC_SCACHE_VERSION(1,1) 745 #define BCM_SUBPORT_WB_DEFAULT_VERSION BCM_SUBPORT_WB_VERSION_1_1 746 747 extern int _bcm_esw_subport_sync(int unit); 748 #endif /* BCM_WARM_BOOT_SUPPORT */ 749 750 #ifdef BCM_WARM_BOOT_SUPPORT_SW_DUMP 751 extern void _bcm_tr_subport_sw_dump(int unit); 752 extern void _bcm_tr2_subport_sw_dump(int unit); 753 extern void _bcm_kt2_subport_sw_dump(int unit); 754 755 #endif /* BCM_WARM_BOOT_SUPPORT_SW_DUMP */ 756 757 extern int 758 _bcm_subport_physical_port_get(int unit, int pp_port, 759 int *local_port); 760 761 extern int 762 _bcmi_linkphy_subport_stream_dfc_update(int unit, 763 bcm_subport_config_t *config, 764 int pp_port_index, 765 int ext_stream_id, 766 int enable); 767 768 extern int 769 _bcmi_linkphy_subport_stream_flush(int unit, 770 bcm_subport_config_t *config, 771 int pp_port_index, 772 int ext_stream_id); 773 774 extern int 775 _bcm_coe_subtag_subport_port_subport_num_get(int unit, 776 bcm_gport_t subport, 777 bcm_port_t *port, 778 int *index); 779 780 extern int 781 _bcm_coe_subtag_subport_num_subport_gport_get(int unit, 782 int subport_num, 783 bcm_gport_t *subport_gport); 784 785 extern int 786 _bcm_coe_subport_mod_port_subport_num_get(int unit, 787 bcm_module_t modid, 788 bcm_port_t portid, 789 int *subport_num); 790 791 792 #ifdef BCM_CHANNELIZED_SWITCHING_SUPPORT 793 794 #define BCMI_CES_MAX_CHANNEL_ID 255 795 796 #define BCMI_CES_SUBPORT_PKT_VLAN_CHK(_u_, v) \ 797 (v > BCMI_CES_MAX_CHANNEL_ID) 798 799 800 typedef struct _bcm_subport_port_group_state_s { 801 int num_groups; 802 SHR_BITDCL *_bcm_subport_port_group_bitmap; 803 int *_bcm_subport_port_group_refcnt; 804 }_bcm_subport_port_group_state_t; 805 806 extern _bcm_subport_port_group_state_t subport_port_group_state[BCM_MAX_NUM_UNITS]; 807 808 809 #define _BCM_SUBPORT_PORT_GROUP_CNT(unit) \ 810 subport_port_group_state[unit].num_groups 811 812 #define _BCM_SUBPORT_PORT_GROUP_BMP(unit) \ 813 (subport_port_group_state[unit])._bcm_subport_port_group_bitmap 814 815 #define _BCM_SUBPORT_PORT_GROUP_REFCNT(unit) \ 816 (subport_port_group_state[unit])._bcm_subport_port_group_refcnt 817 818 #define _BCM_SUBPORT_PORT_GROUP_ID_REFCNT(unit, id) \ 819 (subport_port_group_state[unit])._bcm_subport_port_group_refcnt[id] 820 821 /* Function definitions: CES */ 822 extern bcm_error_t 823 bcmi_subport_port_group_init(int unit); 824 825 extern bcm_error_t 826 bcmi_subport_port_group_id_create(int unit, 827 uint32 options, 828 bcm_subport_port_group_t *group_id); 829 extern bcm_error_t 830 bcmi_subport_port_group_id_destroy(int unit, bcm_subport_port_group_t group_id); 831 832 extern bcm_error_t 833 bcmi_subport_port_group_id_destroy_all(int unit); 834 835 extern bcm_error_t 836 bcmi_subport_port_group_id_get(int unit, bcm_subport_port_group_t group_id); 837 838 extern bcm_error_t 839 bcmi_subport_port_group_id_get_all(int unit, 840 int max_groups, 841 bcm_subport_port_group_t *group_idz, 842 int *group_size); 843 extern bcm_error_t 844 bcmi_subport_port_group_subport_multi_set(int unit, 845 bcm_subport_port_group_t group_id, 846 int num_ports, 847 bcm_gport_t *subport_gports); 848 849 extern bcm_error_t 850 bcmi_subport_port_group_subport_multi_get(int unit, 851 bcm_subport_port_group_t group_id, 852 int max_subports, 853 bcm_gport_t *subport_gports, 854 int *num_subports); 855 #define BCMI_PORT_GROUP_CLEANUP_IF_ERROR(rv) \ 856 do { \ 857 if (BCM_FAILURE(rv)) { \ 858 goto cleanup; \ 859 } \ 860 } while(0); 861 862 863 864 extern int 865 bcmi_subport_tunnel_pbmp_profile_init(int unit); 866 867 extern int 868 bcmi_subport_tunnel_pbmp_profile_create(int unit, 869 int num_subports, 870 bcm_gport_t *subport_gports, 871 int *profile_index); 872 873 extern int 874 bcmi_subport_tunnel_pbmp_profile_get(int unit, 875 int num_subports, 876 bcm_gport_t *subport_gports, 877 int *profile_index); 878 879 extern int 880 bcmi_subport_tunnel_pbmp_profile_destroy(int unit, 881 int profile_index); 882 extern int 883 bcmi_subport_tunnel_pbmp_profile_destroy_all(int unit); 884 885 extern int 886 bcmi_subport_multicast_lc_pbm_set(int unit, 887 int repl_group, 888 bcm_gport_t subport_gport, 889 int set_reset); 890 891 extern int 892 bcmi_subport_multicast_lc_pbm_clear_all(int unit, 893 int repl_group); 894 895 extern int 896 _bcm_coe_subtag_subport_port_get_by_modport(int unit, 897 bcm_gport_t modport_gport, 898 bcm_gport_t *subport_gport); 899 900 901 902 #define BCMI_FB6_SUBPORT_MODID_PORT_MAX (128) 903 904 #endif /*BCM_CHANNELIZED_SWITCHING_SUPPORT*/ 905 906 #endif /* !_BCM_INT_ESW_SUBPORT_H_ */