init.c (64818B)
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 * BCM Library Initialization 8 * 9 * This module calls the initialization routine of each BCM module. 10 * 11 * Initial System Configuration 12 * 13 * Each module should initialize itself without reference to other BCM 14 * library modules to avoid a chicken-and-the-egg problem. To do 15 * this, each module should initialize its respective internal state 16 * and hardware tables to match the Initial System Configuration. The 17 * Initial System Configuration is: 18 * 19 * STG 1 containing VLAN 1 20 * STG 1 all ports in the DISABLED state 21 * VLAN 1 with 22 * PBMP = all switching Ethernet ports (non-fabric) and the CPU. 23 * UBMP = all switching Ethernet ports (non-fabric). 24 * No trunks configured 25 * No mirroring configured 26 * All L2 and L3 tables empty 27 * Ingress VLAN filtering disabled 28 * BPDU reception enabled 29 */ 30 31 #include <sal/types.h> 32 #include <sal/core/time.h> 33 #include <sal/core/boot.h> 34 #include <shared/bsl.h> 35 #include <soc/cmext.h> 36 #include <soc/counter.h> 37 #include <soc/l2x.h> 38 #include <soc/mem.h> 39 #include <soc/debug.h> 40 #include <soc/phyctrl.h> 41 42 #include <bcm/init.h> 43 #include <bcm/error.h> 44 #include <bcm/rx.h> 45 #include <bcm/pkt.h> 46 #include <bcm/ipfix.h> 47 48 #ifdef SW_AUTONEG_SUPPORT 49 #include <bcm_int/common/sw_an.h> 50 #endif 51 52 #include <bcm_int/api_xlate_port.h> 53 #include <bcm_int/control.h> 54 #include <bcm_int/common/lock.h> 55 #ifdef BCM_RCPU_SUPPORT 56 #include <bcm_int/esw/rcpu.h> 57 #endif 58 #include <bcm_int/esw/mirror.h> 59 #include <bcm_int/esw/stat.h> 60 #include <bcm_int/esw/mcast.h> 61 #include <bcm_int/esw/range.h> 62 63 #include <bcm_int/esw/mbcm.h> 64 #include <bcm_int/esw/ipfix.h> 65 #include <bcm_int/esw/mirror.h> 66 #include <bcm_int/esw/stack.h> 67 #include <bcm_int/esw_dispatch.h> 68 #include <bcm_int/esw/stg.h> 69 #include <bcm_int/esw/switch.h> 70 #include <bcm_int/esw/vlan.h> 71 #include <bcm_int/esw/cosq.h> 72 #include <bcm_int/esw/rx.h> 73 #include <bcm_int/esw/rate.h> 74 #ifdef BCM_INSTRUMENTATION_SUPPORT 75 #include <bcm_int/esw/instrumentation.h> 76 #endif /* BCM_INSTRUMENTATION_SUPPORT */ 77 #ifdef BCM_KATANA_SUPPORT 78 #include <bcm_int/esw/katana.h> 79 #endif 80 #if defined(BCM_KATANA_SUPPORT) || defined(BCM_TRIUMPH3_SUPPORT) || \ 81 defined(BCM_GREYHOUND2_SUPPORT) 82 #include <bcm_int/esw/policer.h> 83 #endif /* BCM_KATANA_SUPPORT || BCM_TRIUMPH3_SUPPORT || 84 BCM_GREYHOUND2_SUPPORT */ 85 #ifdef BCM_TRX_SUPPORT 86 #include <bcm_int/esw/trx.h> 87 #endif /* BCM_TRX_SUPPORT */ 88 #ifdef BCM_HURRICANE2_SUPPORT 89 #include <bcm_int/esw/hurricane2.h> 90 #endif 91 92 #if defined(BCM_SABER2_SUPPORT) 93 #include <bcm_int/esw/saber2.h> 94 #endif /* BCM_SABER2_SUPPORT */ 95 96 #if defined(BCM_SABER2_SUPPORT) 97 #include <bcm_int/esw/saber2.h> 98 #include <bcm_int/common/sat.h> 99 #endif /* BCM_SABER2_SUPPORT */ 100 101 #if defined(BCM_TOMAHAWK3_SUPPORT) 102 #include <bcm_int/tomahawk3_dispatch.h> 103 #include <bcm_int/esw/tomahawk3.h> 104 #endif /* BCM_TOMAHAWK3_SUPPORT */ 105 106 #ifdef BCM_WARM_BOOT_SUPPORT 107 #include <bcm_int/esw/vlan.h> 108 #include <bcm_int/esw/trunk.h> 109 #include <bcm_int/esw/field.h> 110 #include <bcm_int/esw/l3.h> 111 #include <bcm_int/esw/mcast.h> 112 #include <bcm_int/esw/port.h> 113 #endif 114 115 #ifdef INCLUDE_MACSEC 116 #include <bcm_int/common/macsec_cmn.h> 117 #endif /* INCLUDE_MACSEC */ 118 119 #ifdef INCLUDE_FCMAP 120 #include <bcm_int/common/fcmap_cmn.h> 121 #endif /* INCLUDE_FCMAP */ 122 123 #ifdef BCM_TOMAHAWK_SUPPORT 124 #include <soc/tomahawk.h> 125 #include <bcm_int/esw/tomahawk.h> 126 #endif 127 #ifdef BCM_MONTEREY_SUPPORT 128 #include <soc/monterey.h> 129 #include <bcm_int/esw/monterey.h> 130 #endif 131 132 #ifdef BCM_GREYHOUND2_SUPPORT 133 #include <bcm_int/esw/greyhound2.h> 134 #endif 135 136 #ifdef BCM_TOMAHAWK2_SUPPORT 137 #include <soc/tomahawk2.h> 138 #endif 139 140 #ifdef BCM_TRIDENT3_SUPPORT 141 #include <soc/trident3.h> 142 #endif 143 144 #ifdef CANCUN_SUPPORT 145 #include <soc/esw/cancun.h> 146 #endif /* CANCUN_SUPPORT */ 147 148 #include <bcm_int/esw_dispatch.h> 149 #include <shared/shr_bprof.h> 150 #if defined(INCLUDE_XFLOW_MACSEC) 151 #include <bcm_int/common/xflow_macsec_cmn.h> 152 #endif 153 154 #define BCM_CHECK_ERROR_RETURN(rv, dispname) \ 155 if ((rv < 0) && (rv != BCM_E_UNAVAIL)) { \ 156 LOG_WARN(BSL_LS_BCM_INIT, \ 157 (BSL_META_U(unit, "bcm_init failed in %s\n"), \ 158 shr_bprof_stats_name(dispname))); \ 159 return (rv); \ 160 } 161 162 #if defined(BCM_TOMAHAWK_SUPPORT) 163 extern int soc_ctr_evict_start(int unit, uint32 flags, sal_usecs_t interval); 164 #endif 165 #if defined(BCM_TRIUMPH3_SUPPORT) 166 extern int _bcm_esw_tr3_port_lanes_init(int unit); 167 #endif 168 #if defined(INCLUDE_GDPLL) 169 extern int _bcm_esw_gdpll_init(int unit); 170 #endif 171 #if defined(BCM_MONTEREY_SUPPORT) 172 extern int _bcm_esw_time_capture_init(int unit); 173 #endif 174 #if defined(BCM_TIMESYNC_TIME_CAPTURE_SUPPORT) 175 extern int bcm_esw_time_capture_ts_init(int unit); 176 extern int bcm_esw_time_capture_ts_deinit(int unit); 177 #endif /* BCM_TIMESYNC_TIME_CAPTURE_SUPPORT */ 178 /* 179 * Function: 180 * _bcm_lock_init 181 * Purpose: 182 * Allocate BCM_LOCK. 183 */ 184 185 STATIC int 186 _bcm_lock_init(int unit) 187 { 188 if (_bcm_lock[unit] == NULL) { 189 _bcm_lock[unit] = sal_mutex_create("bcm_config_lock"); 190 } 191 192 if (_bcm_lock[unit] == NULL) { 193 return BCM_E_MEMORY; 194 } 195 196 return BCM_E_NONE; 197 } 198 199 /* 200 * Function: 201 * _bcm_lock_deinit 202 * Purpose: 203 * De-allocate BCM_LOCK. 204 */ 205 206 STATIC int 207 _bcm_lock_deinit(int unit) 208 { 209 if (_bcm_lock[unit] != NULL) { 210 sal_mutex_destroy(_bcm_lock[unit]); 211 _bcm_lock[unit] = NULL; 212 } 213 return BCM_E_NONE; 214 } 215 216 #define _DEINIT_INFO_VERB(_mod) \ 217 LOG_VERBOSE(BSL_LS_BCM_COMMON, \ 218 (BSL_META_U(unit, \ 219 "bcm_detach: Deinitializing %s...\n"), \ 220 _mod)); 221 222 #define _DEINIT_CHECK_ERR(_rv, _mod) \ 223 if (_rv != BCM_E_NONE && _rv != BCM_E_UNAVAIL) { \ 224 LOG_WARN(BSL_LS_BCM_INIT, \ 225 (BSL_META_U(unit, \ 226 "Warning: Deinitializing %s returned %d\n"), \ 227 _mod, _rv)); \ 228 } 229 230 /* 231 * Function: 232 * _bcm_esw_modules_deinit 233 * Purpose: 234 * bcm_detach_late_txrx() will deinit all modules except TX and RX. 235 * A regular bcm_detach() must follow to detach the remaining modules. 236 * De-initialize bcm modules 237 * Parameters: 238 * unit - (IN) BCM device number. 239 * Returns: 240 * BCM_E_XXX 241 */ 242 STATIC int 243 _bcm_esw_modules_deinit(int unit) 244 { 245 int rv; /* Operation return status. */ 246 #ifdef INCLUDE_KNET 247 uint8 deinit_knet = TRUE; 248 #endif 249 250 #ifdef INCLUDE_KNET 251 if (SOC_WARM_BOOT(unit) && SOC_KNET_MODE(unit) && 252 soc_property_get(unit, spn_WARMBOOT_KNET_SHUTDOWN_MODE, 0)) { 253 deinit_knet = FALSE; 254 } 255 #endif 256 257 /* Only TX/RX deinit should be done here */ 258 if (BCM_CONTROL(unit)->attach_state == _bcmControlStateDeinitAll) { 259 _DEINIT_INFO_VERB("rx"); 260 rv = bcm_esw_rx_deinit(unit); 261 /* There is no tx deinit defined currently */ 262 BCM_UNLOCK(unit); 263 _bcm_lock_deinit(unit); 264 return rv; 265 } 266 267 #ifdef INCLUDE_TELEMETRY 268 if (soc_feature(unit, soc_feature_telemetry)) { 269 _DEINIT_INFO_VERB("telemetry"); 270 rv = bcm_esw_telemetry_detach(unit); 271 _DEINIT_CHECK_ERR(rv, "telemetry"); 272 } 273 #endif 274 275 #ifdef BCM_COLLECTOR_SUPPORT 276 if (soc_feature(unit, soc_feature_collector)) { 277 _DEINIT_INFO_VERB("collector"); 278 rv = bcm_esw_collector_detach(unit); 279 _DEINIT_CHECK_ERR(rv, "collector"); 280 } 281 #endif 282 283 #if defined(BCM_TSN_SUPPORT) 284 if (soc_feature(unit, soc_feature_tsn)){ 285 _DEINIT_INFO_VERB("tsn"); 286 rv = bcm_esw_tsn_detach(unit); 287 _DEINIT_CHECK_ERR(rv, "tsn"); 288 } 289 #endif /* BCM_TSN_SUPPORT */ 290 291 /* Temporarily disable eapps modules on MV2 SVK till integration is complete */ 292 if (!(SOC_IS_MAVERICK2(unit) && !SAL_BOOT_BCMSIM)) { 293 #ifdef INCLUDE_BFD 294 if (soc_feature(unit, soc_feature_bfd)) { 295 _DEINIT_INFO_VERB("bfd"); 296 rv = bcm_esw_bfd_detach(unit); 297 _DEINIT_CHECK_ERR(rv, "bfd"); 298 } 299 #endif 300 #ifdef INCLUDE_PTP 301 if (soc_feature(unit, soc_feature_ptp)) { 302 _DEINIT_INFO_VERB("ptp"); 303 rv = bcm_esw_ptp_detach(unit); 304 _DEINIT_CHECK_ERR(rv, "ptp"); 305 } 306 #endif 307 if (soc_feature(unit, soc_feature_oam)) 308 { 309 _DEINIT_INFO_VERB("oam"); 310 rv = bcm_esw_oam_detach(unit); 311 _DEINIT_CHECK_ERR(rv, "oam"); 312 } 313 } 314 #ifdef INCLUDE_L3 315 if (soc_feature(unit, soc_feature_failover)) 316 { 317 _DEINIT_INFO_VERB("failover"); 318 rv = bcm_esw_failover_cleanup(unit); 319 _DEINIT_CHECK_ERR(rv, "failover"); 320 } 321 #endif 322 323 if (soc_feature(unit, soc_feature_time_support)) 324 { 325 _DEINIT_INFO_VERB("time"); 326 rv = bcm_esw_time_deinit(unit); 327 _DEINIT_CHECK_ERR(rv, "time"); 328 } 329 330 _DEINIT_INFO_VERB("udf"); 331 rv = bcm_esw_udf_detach(unit); 332 _DEINIT_CHECK_ERR(rv, "udf"); 333 334 #if defined(INCLUDE_FLOWTRACKER) || defined(BCM_FLOWTRACKER_SUPPORT) 335 if (soc_feature(unit, soc_feature_uc_flowtracker_learn) || 336 soc_feature(unit, soc_feature_uc_flowtracker_export) || 337 soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 338 339 _DEINIT_INFO_VERB("flowtracker"); 340 rv = bcm_esw_flowtracker_detach(unit); 341 _DEINIT_CHECK_ERR(rv, "flowtracker"); 342 } 343 344 #endif /* INCLUDE_FLOWTRACKER || BCM_FLOWTRACKER_SUPPORT */ 345 346 #if defined(BCM_TIMESYNC_TIME_CAPTURE_SUPPORT) 347 if (soc_feature(unit, soc_feature_timesync_time_capture)) { 348 BCM_IF_ERROR_RETURN(bcm_esw_time_capture_ts_deinit(unit)); 349 } 350 #endif /* BCM_TIMESYNC_TIME_CAPTURE_SUPPORT */ 351 352 #if defined (INCLUDE_IFA) 353 if (soc_feature(unit, soc_feature_ifa)) { 354 _DEINIT_INFO_VERB("ifa"); 355 rv = bcm_esw_ifa_detach(unit); 356 _DEINIT_CHECK_ERR(rv, "ifa"); 357 } 358 #endif /* INCLUDE_IFA */ 359 360 #ifdef BCM_FIELD_SUPPORT 361 _DEINIT_INFO_VERB("auth"); 362 rv = bcm_esw_auth_detach(unit); 363 _DEINIT_CHECK_ERR(rv, "auth"); 364 365 _DEINIT_INFO_VERB("field"); 366 rv = bcm_esw_field_detach(unit); 367 _DEINIT_CHECK_ERR(rv, "field"); 368 #ifdef BCM_TOMAHAWK_SUPPORT 369 if (SOC_IS_TOMAHAWKX(unit) || SOC_IS_TRIDENT3X(unit)) { 370 if (SOC_MEM_IS_VALID(unit, IFP_RANGE_CHECKm)) { 371 _DEINIT_INFO_VERB("range"); 372 rv = bcm_esw_range_detach(unit); 373 _DEINIT_CHECK_ERR(rv, "range"); 374 } 375 } 376 #endif 377 #endif /* BCM_FIELD_SUPPORT */ 378 379 #ifdef INCLUDE_L3 380 _DEINIT_INFO_VERB("proxy"); 381 rv = bcm_esw_proxy_cleanup(unit); 382 _DEINIT_CHECK_ERR(rv, "proxy"); 383 384 _DEINIT_INFO_VERB("multicast"); 385 rv = bcm_esw_multicast_detach(unit); 386 _DEINIT_CHECK_ERR(rv, "multicast"); 387 388 if (soc_feature(unit, soc_feature_port_extension)) { 389 _DEINIT_INFO_VERB("extender"); 390 rv = bcm_esw_extender_cleanup(unit); 391 _DEINIT_CHECK_ERR(rv, "extender"); 392 } 393 394 if (soc_feature(unit, soc_feature_vxlan) || 395 soc_feature(unit, soc_feature_vxlan_lite)) { 396 _DEINIT_INFO_VERB("vxlan"); 397 rv = bcm_esw_vxlan_cleanup(unit); 398 _DEINIT_CHECK_ERR(rv, "vxlan"); 399 } 400 401 if (soc_feature(unit, soc_feature_l2gre)) { 402 _DEINIT_INFO_VERB("l2gre"); 403 rv = bcm_esw_l2gre_cleanup(unit); 404 _DEINIT_CHECK_ERR(rv, "l2gre"); 405 } 406 407 if (soc_feature(unit, soc_feature_niv)) { 408 _DEINIT_INFO_VERB("niv"); 409 rv = bcm_esw_niv_cleanup(unit); 410 _DEINIT_CHECK_ERR(rv, "niv"); 411 } 412 413 if (soc_feature(unit, soc_feature_trill)) { 414 _DEINIT_INFO_VERB("trill"); 415 rv = bcm_esw_trill_cleanup(unit); 416 _DEINIT_CHECK_ERR(rv, "trill"); 417 } 418 419 _DEINIT_INFO_VERB("subport"); 420 rv = bcm_esw_subport_cleanup(unit); 421 _DEINIT_CHECK_ERR(rv, "subport"); 422 423 #ifdef BCM_MPLS_SUPPORT 424 _DEINIT_INFO_VERB("mpls"); 425 rv = bcm_esw_mpls_cleanup(unit); 426 _DEINIT_CHECK_ERR(rv, "mpls"); 427 #endif /* BCM_MPLS_SUPPORT */ 428 429 _DEINIT_INFO_VERB("ipmc"); 430 rv = bcm_esw_ipmc_detach(unit); 431 _DEINIT_CHECK_ERR(rv, "ipmc"); 432 433 _DEINIT_INFO_VERB("l3"); 434 /* 435 * COVERITY 436 * 437 * Coverity reports a call chain of depth greater than 20, but well 438 * before the stack overflows, it calls bcm_esw_switch_control_get 439 * with one control selection, then follows another control's path 440 * to find more levels of stack. This is spurious. 441 */ 442 /* coverity[stack_use_overflow : FALSE] */ 443 rv = bcm_esw_l3_cleanup(unit); 444 _DEINIT_CHECK_ERR(rv, "l3"); 445 #endif /* INCLUDE_L3 */ 446 447 /* Delaying RX deinit so the CPU can stil receive packets 448 * even when other modules are deinitialized. */ 449 if (!(BCM_CONTROL(unit)->attach_state == _bcmControlStateDeinitLateTxRx)) { 450 _DEINIT_INFO_VERB("rx"); 451 rv = bcm_esw_rx_deinit(unit); 452 _DEINIT_CHECK_ERR(rv, "rx"); 453 } 454 455 #if 0 456 _DEINIT_INFO_VERB("tx"); 457 rv = bcm_esw_tx_deinit(unit); 458 _DEINIT_CHECK_ERR(rv, "tx"); 459 #endif 460 461 _DEINIT_INFO_VERB("mirror"); 462 rv = bcm_esw_mirror_deinit(unit); 463 _DEINIT_CHECK_ERR(rv, "mirror"); 464 465 #ifdef INCLUDE_KNET 466 if (deinit_knet) { 467 _DEINIT_INFO_VERB("knet"); 468 rv = bcm_esw_knet_cleanup(unit); 469 _DEINIT_CHECK_ERR(rv, "knet"); 470 } 471 #endif 472 473 _DEINIT_INFO_VERB("stacking"); 474 rv = _bcm_esw_stk_detach(unit); 475 _DEINIT_CHECK_ERR(rv, "stacking"); 476 477 _DEINIT_INFO_VERB("stats"); 478 rv = _bcm_esw_stat_detach(unit); 479 _DEINIT_CHECK_ERR(rv, "stats"); 480 481 _DEINIT_INFO_VERB("linkscan"); 482 rv = bcm_esw_linkscan_detach(unit); 483 _DEINIT_CHECK_ERR(rv, "linkscan"); 484 485 #ifdef SW_AUTONEG_SUPPORT 486 if (soc_feature(unit, soc_feature_sw_autoneg)) { 487 _DEINIT_INFO_VERB("SW_AN"); 488 rv = bcm_sw_an_module_deinit(unit); 489 _DEINIT_CHECK_ERR(rv, "SW_AN"); 490 } 491 #endif 492 493 _DEINIT_INFO_VERB("mcast"); 494 rv = _bcm_esw_mcast_detach(unit); 495 _DEINIT_CHECK_ERR(rv, "mcast"); 496 497 _DEINIT_INFO_VERB("cosq"); 498 rv = bcm_esw_cosq_deinit(unit); 499 _DEINIT_CHECK_ERR(rv, "cosq"); 500 501 _DEINIT_INFO_VERB("trunk"); 502 rv = bcm_esw_trunk_detach(unit); 503 _DEINIT_CHECK_ERR(rv, "trunk"); 504 505 _DEINIT_INFO_VERB("vlan"); 506 rv = bcm_esw_vlan_detach(unit); 507 _DEINIT_CHECK_ERR(rv, "vlan"); 508 509 _DEINIT_INFO_VERB("stg"); 510 rv = bcm_esw_stg_detach(unit); 511 _DEINIT_CHECK_ERR(rv, "stg"); 512 513 _DEINIT_INFO_VERB("l2"); 514 rv = bcm_esw_l2_detach(unit); 515 _DEINIT_CHECK_ERR(rv, "l2"); 516 517 _DEINIT_INFO_VERB("port"); 518 rv = _bcm_esw_port_deinit(unit); 519 _DEINIT_CHECK_ERR(rv, "port"); 520 521 _DEINIT_INFO_VERB("ipfix"); 522 rv = _bcm_esw_ipfix_deinit(unit); 523 _DEINIT_CHECK_ERR(rv, "ipfix"); 524 525 _DEINIT_INFO_VERB("mbcm"); 526 rv = mbcm_deinit(unit); 527 _DEINIT_CHECK_ERR(rv, "mbcm"); 528 529 #ifdef INCLUDE_L3 530 _DEINIT_INFO_VERB("wlan"); 531 rv = bcm_esw_wlan_detach(unit); 532 _DEINIT_CHECK_ERR(rv, "wlan"); 533 534 _DEINIT_INFO_VERB("mim"); 535 rv = bcm_esw_mim_detach(unit); 536 _DEINIT_CHECK_ERR(rv, "mim"); 537 #endif 538 539 _DEINIT_INFO_VERB("qos"); 540 rv = bcm_esw_qos_detach(unit); 541 _DEINIT_CHECK_ERR(rv, "qos"); 542 543 _DEINIT_INFO_VERB("switch"); 544 rv = _bcm_esw_switch_detach(unit); 545 _DEINIT_CHECK_ERR(rv, "switch"); 546 547 #ifdef BCM_TRX_SUPPORT 548 if (soc_feature(unit, soc_feature_virtual_switching) || 549 soc_feature(unit, soc_feature_int_common_init)) { 550 _DEINIT_INFO_VERB("common"); 551 rv = _bcm_common_cleanup(unit); 552 _DEINIT_CHECK_ERR(rv, "common"); 553 } 554 #endif /* BCM_TRX_SUPPORT */ 555 #if defined(BCM_KATANA_SUPPORT) || defined(BCM_TRIUMPH3_SUPPORT) || \ 556 defined(BCM_GLOBAL_METER_SUPPORT) 557 /* Service meter */ 558 if (soc_feature(unit, soc_feature_global_meter)) { 559 _DEINIT_INFO_VERB("gmeter"); 560 rv = _bcm_esw_global_meter_cleanup(unit); 561 _DEINIT_CHECK_ERR(rv, "gmeter"); 562 } 563 #endif /* BCM_KATANA_SUPPORT || BCM_TRIUMPH3_SUPPORT || 564 BCM_GLOBAL_METER_SUPPORT */ 565 566 #if defined(BCM_SABER2_SUPPORT) 567 if (soc_feature(unit, soc_feature_sat)) 568 { 569 _DEINIT_INFO_VERB("sat"); 570 rv = bcm_sb2_sat_detach(unit); 571 _DEINIT_CHECK_ERR(rv, "sat"); 572 573 _DEINIT_INFO_VERB("sat common"); 574 rv = bcm_common_sat_detach(unit); 575 _DEINIT_CHECK_ERR(rv, "sat common"); 576 } 577 #endif 578 579 #if defined(BCM_RCPU_SUPPORT) && defined(BCM_XGS3_SWITCH_SUPPORT) 580 _DEINIT_INFO_VERB("rcpu"); 581 rv = _bcm_esw_rcpu_deinit(unit); 582 _DEINIT_CHECK_ERR(rv, "rcpu"); 583 #endif /* BCM_RCPU_SUPPORT && BCM_XGS3_SWITCH_SUPPORT */ 584 585 #if defined(BCM_TOMAHAWK_SUPPORT) 586 _DEINIT_INFO_VERB("latency"); 587 rv = bcm_esw_switch_latency_deinit(unit); 588 _DEINIT_CHECK_ERR(rv, "latency"); 589 #endif 590 #if defined(INCLUDE_XFLOW_MACSEC) 591 BCM_IF_ERROR_RETURN(_bcm_common_xflow_macsec_deinit(unit)); 592 #endif 593 594 LOG_VERBOSE(BSL_LS_BCM_COMMON, 595 (BSL_META_U(unit, 596 "bcm_detach: All modules deinitialized.\n"))); 597 598 BCM_UNLOCK(unit); 599 /* LOCK deinit should not be performed only during the final detach */ 600 if (!(BCM_CONTROL(unit)->attach_state == _bcmControlStateDeinitLateTxRx)) { 601 _bcm_lock_deinit(unit); 602 } 603 604 return rv; 605 } 606 607 #define _THREAD_STOP_CHECK_ERR(_rv, _mod) \ 608 if (_rv != BCM_E_NONE && _rv != BCM_E_UNAVAIL) { \ 609 LOG_WARN(BSL_LS_BCM_INIT, \ 610 (BSL_META_U(unit, \ 611 "Warning: Stopping %s thread returned %d\n"), \ 612 _mod, _rv)); \ 613 } 614 615 /* 616 * Function: 617 * _bcm_esw_threads_shutdown 618 * Purpose: 619 * Terminate all the spawned threads for specific unit. 620 * Parameters: 621 * unit - unit being detached 622 * Returns: 623 * BCM_E_XXX 624 */ 625 STATIC int 626 _bcm_esw_threads_shutdown(int unit) 627 { 628 int rv; /* Operation return status. */ 629 630 rv = _bcm_esw_port_mon_stop(unit); 631 _THREAD_STOP_CHECK_ERR(rv, "portmon"); 632 #ifdef BCM_TRIUMPH3_SUPPORT 633 if SOC_IS_TRIUMPH3(unit) { 634 rv = _bcm_esw_ibod_sync_recovery_stop(unit); 635 _THREAD_STOP_CHECK_ERR(rv, "ibod sync"); 636 } 637 #endif /* BCM_TRIUMPH3_SUPPORT */ 638 rv = bcm_esw_linkscan_enable_set(unit, 0); 639 _THREAD_STOP_CHECK_ERR(rv, "linkscan"); 640 641 #ifdef SW_AUTONEG_SUPPORT 642 if (soc_feature(unit, soc_feature_sw_autoneg)) { 643 rv = bcm_sw_an_enable_set(unit, 0); 644 _THREAD_STOP_CHECK_ERR(rv, "SW_AN"); 645 } 646 #endif 647 648 #ifdef BCM_XGS_SWITCH_SUPPORT 649 rv = soc_l2x_stop(unit); 650 _THREAD_STOP_CHECK_ERR(rv, "l2x"); 651 #endif /* BCM_XGS3_SWITCH_SUPPORT */ 652 #ifdef BCM_TRIUMPH3_SUPPORT 653 if SOC_IS_TRIUMPH3(unit) { 654 rv = soc_tr3_l2_bulk_age_stop(unit); 655 _THREAD_STOP_CHECK_ERR(rv, "l2 age"); 656 } 657 #endif /* BCM_TRIUMPH3_SUPPORT */ 658 #ifdef BCM_TRIDENT2_SUPPORT 659 if SOC_IS_TRIDENT2X(unit) { 660 rv = soc_td2_l2_bulk_age_stop(unit); 661 _THREAD_STOP_CHECK_ERR(rv, "l2 age"); 662 } 663 #endif /* BCM_TRIDENT2_SUPPORT */ 664 rv = soc_counter_detach(unit); 665 _THREAD_STOP_CHECK_ERR(rv, "counter"); 666 667 return BCM_E_NONE; 668 } 669 670 sal_usecs_t _bcm_modules_init_time; 671 672 #ifdef INCLUDE_TCL 673 #define _BCM_MOD_INIT_CER(unit, rtn, dispname, init) { \ 674 if (init) { \ 675 sal_usecs_t stime, etime; \ 676 int rv; \ 677 LOG_VERBOSE(BSL_LS_BCM_COMMON, \ 678 (BSL_META_U(unit, \ 679 "bcm_init: (%s)\n"), \ 680 shr_bprof_stats_name(dispname))); \ 681 stime = sal_time_usecs(); \ 682 SHR_BPROF_STATS_TIME(dispname) { \ 683 rv = rtn(unit); \ 684 BCM_CHECK_ERROR_RETURN(rv, dispname); \ 685 } \ 686 etime = sal_time_usecs(); \ 687 if (SOC_WARM_BOOT(unit)) { \ 688 LOG_CLI((BSL_META_U(unit, \ 689 "bcm_init: %8s took %10d usec\n"), \ 690 shr_bprof_stats_name(dispname), \ 691 SAL_USECS_SUB(etime, stime))); \ 692 _bcm_modules_init_time += SAL_USECS_SUB(etime, stime); \ 693 } else { \ 694 LOG_VERBOSE(BSL_LS_BCM_COMMON, \ 695 (BSL_META_U(unit, \ 696 "bcm_init: %8s took %10d usec\n"), \ 697 shr_bprof_stats_name(dispname), \ 698 SAL_USECS_SUB(etime, stime))); \ 699 _bcm_modules_init_time += SAL_USECS_SUB(etime, stime); \ 700 } \ 701 } else { \ 702 LOG_WARN(BSL_LS_BCM_INIT, \ 703 (BSL_META_U(unit, \ 704 "bcm_init: skipped %s init\n"), \ 705 shr_bprof_stats_name(dispname))); \ 706 } \ 707 } 708 #else 709 #define _BCM_MOD_INIT_CER(unit, rtn, dispname, init) { \ 710 if (init) { \ 711 sal_usecs_t stime, etime; \ 712 int rv; \ 713 LOG_VERBOSE(BSL_LS_BCM_COMMON, \ 714 (BSL_META_U(unit, \ 715 "bcm_init: (%s)\n"), \ 716 shr_bprof_stats_name(dispname))); \ 717 stime = sal_time_usecs(); \ 718 SHR_BPROF_STATS_TIME(dispname) { \ 719 rv = rtn(unit); \ 720 BCM_CHECK_ERROR_RETURN(rv, dispname); \ 721 } \ 722 etime = sal_time_usecs(); \ 723 LOG_VERBOSE(BSL_LS_BCM_COMMON, \ 724 (BSL_META_U(unit, \ 725 "bcm_init: %8s took %10d usec\n"),\ 726 shr_bprof_stats_name(dispname), \ 727 SAL_USECS_SUB(etime, stime))); \ 728 _bcm_modules_init_time += SAL_USECS_SUB(etime, stime); \ 729 } else { \ 730 LOG_WARN(BSL_LS_BCM_INIT, \ 731 (BSL_META_U(unit, \ 732 "bcm_init: skipped %s init\n"), \ 733 shr_bprof_stats_name(dispname))); \ 734 } \ 735 } 736 #endif 737 738 #ifdef INCLUDE_TCL 739 #define _BCM_MOD_INIT_IER(unit, rtn, dispname, init) { \ 740 if (init) { \ 741 sal_usecs_t stime, etime; \ 742 int rv; \ 743 LOG_VERBOSE(BSL_LS_BCM_COMMON, \ 744 (BSL_META_U(unit, \ 745 "bcm_init: (%s)\n"), \ 746 shr_bprof_stats_name(dispname))); \ 747 stime = sal_time_usecs(); \ 748 SHR_BPROF_STATS_TIME(dispname) { \ 749 rv = rtn(unit); \ 750 BCM_IF_ERROR_RETURN(rv); \ 751 } \ 752 etime = sal_time_usecs(); \ 753 if (SOC_WARM_BOOT(unit)) { \ 754 LOG_CLI((BSL_META_U(unit, \ 755 "bcm_init: %8s took %10d usec\n"), \ 756 shr_bprof_stats_name(dispname), \ 757 SAL_USECS_SUB(etime, stime))); \ 758 _bcm_modules_init_time += SAL_USECS_SUB(etime, stime); \ 759 } else { \ 760 LOG_VERBOSE(BSL_LS_BCM_COMMON, \ 761 (BSL_META_U(unit, \ 762 "bcm_init: %8s took %10d usec\n"), \ 763 shr_bprof_stats_name(dispname), \ 764 SAL_USECS_SUB(etime, stime))); \ 765 _bcm_modules_init_time += SAL_USECS_SUB(etime, stime); \ 766 } \ 767 } else { \ 768 LOG_WARN(BSL_LS_BCM_INIT, \ 769 (BSL_META_U(unit, \ 770 "bcm_init: skipped %s init\n"), \ 771 shr_bprof_stats_name(dispname))); \ 772 } \ 773 } 774 #else 775 #define _BCM_MOD_INIT_IER(unit, rtn, dispname, init) { \ 776 if (init) { \ 777 sal_usecs_t stime, etime; \ 778 int rv; \ 779 LOG_VERBOSE(BSL_LS_BCM_COMMON, \ 780 (BSL_META_U(unit, \ 781 "bcm_init: (%s)\n"), \ 782 shr_bprof_stats_name(dispname))); \ 783 stime = sal_time_usecs(); \ 784 SHR_BPROF_STATS_TIME(dispname) { \ 785 rv = rtn(unit); \ 786 BCM_IF_ERROR_RETURN(rv); \ 787 } \ 788 etime = sal_time_usecs(); \ 789 LOG_VERBOSE(BSL_LS_BCM_COMMON, \ 790 (BSL_META_U(unit, \ 791 "bcm_init: %8s took %10d usec\n"),\ 792 shr_bprof_stats_name(dispname), \ 793 SAL_USECS_SUB(etime, stime))); \ 794 _bcm_modules_init_time += SAL_USECS_SUB(etime, stime); \ 795 } else { \ 796 LOG_WARN(BSL_LS_BCM_INIT, \ 797 (BSL_META_U(unit, \ 798 "bcm_init: skipped %s init\n"), \ 799 shr_bprof_stats_name(dispname))); \ 800 } \ 801 } 802 #endif 803 804 /* 805 * Function: 806 * _bcm_modules_init 807 * Purpose: 808 * Initialize bcm modules 809 * Parameters: 810 * unit - StrataSwitch unit #. 811 * flags - Combination of bit selectors (see init.h) 812 * Returns: 813 * BCM_E_XXX 814 */ 815 816 817 STATIC int 818 _bcm_modules_init(int unit) 819 { 820 int init_cond, init_cond2 = 0; /* init condition */ 821 #ifdef INCLUDE_KNET 822 uint8 init_knet = TRUE; 823 #endif 824 #ifdef CANCUN_SUPPORT 825 uint32 cancun_ver; 826 #endif 827 SHR_BPROF_STATS_DECL; 828 /* 829 * Initialize each bcm module 830 */ 831 832 if (!SOC_UNIT_VALID(unit)) { 833 return BCM_E_UNIT; 834 } 835 836 #ifdef INCLUDE_KNET 837 if (SOC_WARM_BOOT(unit) && SOC_KNET_MODE(unit) && 838 soc_property_get(unit, spn_WARMBOOT_KNET_SHUTDOWN_MODE, 0)) { 839 init_knet = FALSE; 840 } 841 #endif 842 #ifdef CANCUN_SUPPORT 843 if (soc_feature(unit, soc_feature_cancun)) { 844 SOC_IF_ERROR_RETURN(soc_cancun_version_get(unit, &cancun_ver)); 845 /* For TD3 and MV2, TWAMP_OWAMP is supported only from 6.0.0 & 4.0.0 and above respectively */ 846 /* Adding this check here because CANCUN version is available only after loading CIH. 847 * This function is called during regular init and warmboot re-init as well. 848 * This feature currently affects tx and field modules only. 849 */ 850 if ((SOC_IS_TRIDENT3(unit) && (cancun_ver >= SOC_CANCUN_VERSION_DEF_6_0_0)) || 851 (SOC_IS_MAVERICK2(unit) && (cancun_ver >= SOC_CANCUN_VERSION_DEF_4_0_0))) { 852 SOC_FEATURE_SET(unit, soc_feature_twamp_owamp_support); 853 } 854 } 855 #endif 856 857 /* Only Tx and Rx modules will be initialized if attaching early 858 * during warmboot to minimize CPU TX/RX inactivity time. 859 */ 860 if (BCM_CONTROL(unit)->attach_state == _bcmControlStateTxRxInit) { 861 #ifdef INCLUDE_KNET 862 if (init_knet) { 863 _BCM_MOD_INIT_CER(unit, bcm_esw_knet_init, SHR_BPROF_BCM_KNET, TRUE); 864 } 865 #endif 866 _BCM_MOD_INIT_CER(unit, bcm_esw_tx_init, SHR_BPROF_BCM_TX, TRUE); 867 _BCM_MOD_INIT_CER(unit, bcm_esw_rx_init, SHR_BPROF_BCM_RX, TRUE); 868 869 return BCM_E_NONE; 870 } 871 #if defined(BCM_TRIDENT3_SUPPORT) 872 if (SOC_IS_TRIDENT3X(unit) && soc_feature(unit, soc_feature_higig_over_ethernet)) { 873 soc_td3_hgoe_feature_update(unit); 874 } 875 #endif 876 877 #ifdef CANCUN_SUPPORT 878 if (soc_feature(unit, soc_feature_cancun)) { 879 SOC_IF_ERROR_RETURN(soc_cancun_version_get(unit, &cancun_ver)); 880 if ((SOC_IS_TRIDENT3(unit) && (cancun_ver >= SOC_CANCUN_VERSION_DEF_6_1_3)) || 881 (SOC_IS_MAVERICK2(unit) && (cancun_ver >= SOC_CANCUN_VERSION_DEF_4_1_2))) { 882 SOC_FEATURE_SET(unit, soc_feature_enable_flow_based_udf_extraction); 883 SOC_IF_ERROR_RETURN(soc_td3_flow_based_udf_enable(unit)); 884 } 885 } 886 #endif 887 888 /* Must call mbcm init first to ensure driver properly installed */ 889 BCM_IF_ERROR_RETURN(mbcm_init(unit)); 890 891 #if defined(BCM_WARM_BOOT_SUPPORT) 892 if (SOC_WARM_BOOT(unit) && !SOC_IS_XGS12_FABRIC(unit)) { 893 /* Init local module id. */ 894 BCM_IF_ERROR_RETURN(bcm_esw_reload_stk_my_modid_get(unit)); 895 } 896 #endif /* BCM_WARM_BOOT_SUPPORT */ 897 898 /* When adding new modules, double check init condition 899 * TRUE - init the module always 900 * init_cond - Conditional init based on boot flags/soc properties 901 */ 902 #ifdef BCM_TRIUMPH_SUPPORT 903 if (soc_feature(unit, soc_feature_virtual_switching) || 904 soc_feature(unit, soc_feature_gport_service_counters) || 905 soc_feature(unit, soc_feature_fast_init) || 906 soc_feature(unit, soc_feature_int_common_init)){ 907 /* Initialize the common data module here to avoid multiple 908 * initializations in the required modules. */ 909 _BCM_MOD_INIT_CER(unit, _bcm_common_init, SHR_BPROF_BCM_COMMON, TRUE); 910 } 911 #endif /* BCM_TRIUMPH_SUPPORT */ 912 913 _BCM_MOD_INIT_CER(unit, bcm_esw_port_init, SHR_BPROF_BCM_PORT, TRUE); 914 /* switch to default miim intr mode from polling mode after port init done */ 915 SOC_CONTROL(unit)->miimIntrEnb = soc_property_get(unit, 916 spn_MIIM_INTR_ENABLE, 1); 917 init_cond = (!(SAL_BOOT_SIMULATION && 918 soc_property_get(unit, spn_SKIP_L2_VLAN_INIT, 0))); 919 _BCM_MOD_INIT_CER(unit, bcm_esw_stg_init, SHR_BPROF_BCM_STG, TRUE); 920 #if defined(BCM_TOMAHAWK3_SUPPORT) 921 if (SOC_IS_TOMAHAWK3(unit)) { 922 _BCM_MOD_INIT_CER( 923 unit, bcm_tomahawk3_l2_init, SHR_BPROF_BCM_L2, init_cond); 924 _BCM_MOD_INIT_CER( 925 unit, bcm_tomahawk3_vlan_init, SHR_BPROF_BCM_VLAN, init_cond); 926 } else 927 #endif 928 { 929 _BCM_MOD_INIT_CER(unit, bcm_esw_l2_init, SHR_BPROF_BCM_L2, init_cond); 930 _BCM_MOD_INIT_CER( 931 unit, bcm_esw_vlan_init, SHR_BPROF_BCM_VLAN, init_cond); 932 } 933 init_cond = (!(SAL_BOOT_SIMULATION && 934 soc_property_get(unit, "skip_trunk_init", 0))); 935 _BCM_MOD_INIT_CER(unit, bcm_esw_trunk_init, SHR_BPROF_BCM_TRUNK, init_cond); 936 937 init_cond = soc_property_get(unit, "init_all_modules", 938 (SAL_BOOT_BCMSIM) || (!SAL_BOOT_SIMULATION)); 939 init_cond2 = init_cond || (soc_property_get(unit, "skip_cosq_init", 940 0) ? FALSE : TRUE); 941 _BCM_MOD_INIT_CER(unit, bcm_esw_cosq_init, SHR_BPROF_BCM_COSQ, init_cond2); 942 943 init_cond2 = init_cond && (!soc_property_get(unit, "skip_mcast_init", 0)); 944 _BCM_MOD_INIT_CER(unit, bcm_esw_mcast_init, SHR_BPROF_BCM_MCAST, init_cond2); 945 _BCM_MOD_INIT_CER(unit, bcm_esw_linkscan_init, SHR_BPROF_BCM_LINKSCAN, TRUE); 946 947 #ifdef SW_AUTONEG_SUPPORT 948 if (soc_feature(unit, soc_feature_sw_autoneg)) { 949 _BCM_MOD_INIT_CER(unit, bcm_sw_an_module_init, SHR_BPROF_BCM_SW_AN, TRUE); 950 } 951 #endif 952 953 #ifdef BCM_TOMAHAWK_SUPPORT 954 if (SOC_IS_TOMAHAWKX(unit)) { 955 /* Register linkscan callback routine */ 956 soc_asf_register_linkscan_cb(unit); 957 } 958 #endif 959 960 #if defined(BCM_TRIUMPH3_SUPPORT) 961 if (SOC_IS_TRIUMPH3(unit) && !SOC_IS_HELIX4(unit) && 962 (_tr3_port_config_id[unit] == 112 || _tr3_port_config_id[unit] == 12)) { 963 _bcm_esw_tr3_port_lanes_init(unit); 964 } 965 #endif 966 _BCM_MOD_INIT_CER(unit, bcm_esw_stat_init, SHR_BPROF_BCM_STAT, TRUE); 967 init_cond2 = init_cond || (soc_property_get(unit, "skip_stack_init", 968 0) ? FALSE : TRUE); 969 _BCM_MOD_INIT_CER(unit, bcm_esw_stk_init, SHR_BPROF_BCM_STK, init_cond2); 970 _BCM_MOD_INIT_CER(unit, _bcm_esw_rate_init, SHR_BPROF_BCM_RATE, init_cond); 971 #ifdef INCLUDE_KNET 972 /* KNET module already initialized during early attach */ 973 if (BCM_CONTROL(unit)->attach_state != _bcmControlStateTxRxInited) { 974 if (init_knet) { 975 _BCM_MOD_INIT_CER(unit, bcm_esw_knet_init, SHR_BPROF_BCM_KNET, init_cond); 976 } 977 } 978 #endif 979 #if defined(BCM_TOMAHAWK_SUPPORT) 980 if (SOC_IS_TOMAHAWKX(unit)) { 981 if (SOC_MEM_IS_VALID(unit, FP_UDF_TCAMm)) { 982 _BCM_MOD_INIT_CER(unit, bcm_esw_udf_init, SHR_BPROF_BCM_UDF, init_cond); 983 } 984 } else { 985 _BCM_MOD_INIT_CER(unit, bcm_esw_udf_init, SHR_BPROF_BCM_UDF, init_cond); 986 } 987 #else 988 _BCM_MOD_INIT_CER(unit, bcm_esw_udf_init, SHR_BPROF_BCM_UDF, init_cond); 989 #endif 990 #ifdef BCM_FIELD_SUPPORT 991 #ifdef BCM_TOMAHAWK_SUPPORT 992 if (SOC_IS_TOMAHAWKX(unit) || SOC_IS_TRIDENT3X(unit)) { 993 if (SOC_MEM_IS_VALID(unit, IFP_RANGE_CHECKm)) { 994 _BCM_MOD_INIT_IER(unit, bcm_esw_range_init, SHR_BPROF_BCM_RANGE, init_cond); 995 } 996 } 997 #endif 998 if (!SOC_IS_SHADOW(unit)) { 999 init_cond2 = init_cond && (!soc_property_get(unit, "skip_field_init", 0)); 1000 if (soc_feature(unit, soc_feature_field)) { 1001 _BCM_MOD_INIT_IER(unit, bcm_esw_field_init, SHR_BPROF_BCM_FIELD, 1002 init_cond2); 1003 } 1004 } 1005 #endif 1006 1007 #if defined(BCM_KATANA_SUPPORT) || defined(BCM_TRIUMPH3_SUPPORT) || \ 1008 defined(BCM_GLOBAL_METER_SUPPORT) 1009 /* Service meter */ 1010 if (soc_feature(unit, soc_feature_global_meter)) { 1011 _BCM_MOD_INIT_IER(unit, bcm_esw_global_meter_init, 1012 SHR_BPROF_BCM_GLB_METER, init_cond); 1013 } 1014 #endif /* BCM_KATANA_SUPPORT || BCM_TRIUMPH3_SUPPORT || 1015 BCM_GLOBAL_METER_SUPPORT */ 1016 1017 init_cond2 = init_cond || (soc_property_get(unit, "skip_mirror_init", 1018 0) ? FALSE : TRUE); 1019 _BCM_MOD_INIT_CER(unit, bcm_esw_mirror_init, SHR_BPROF_BCM_MIRROR, init_cond2); 1020 /* TX module already initialized during early attach */ 1021 if (BCM_CONTROL(unit)->attach_state != _bcmControlStateTxRxInited) { 1022 _BCM_MOD_INIT_CER(unit, bcm_esw_tx_init, SHR_BPROF_BCM_TX, TRUE); 1023 } 1024 1025 /* RX init is done in phases during early attach */ 1026 _BCM_MOD_INIT_CER(unit, bcm_esw_rx_init, SHR_BPROF_BCM_RX, TRUE); 1027 #ifdef INCLUDE_L3 1028 if (soc_feature(unit, soc_feature_failover)) { 1029 _BCM_MOD_INIT_IER(unit, bcm_esw_failover_init, SHR_BPROF_BCM_FAILOVER, init_cond); 1030 } 1031 #endif 1032 #ifdef INCLUDE_L3 1033 if (soc_feature(unit, soc_feature_l3) && soc_property_get(unit, spn_L3_ENABLE, 1)) { 1034 init_cond2 = init_cond && (!soc_property_get(unit, "skip_l3_init", 0)); 1035 _BCM_MOD_INIT_IER(unit, bcm_esw_l3_init, SHR_BPROF_BCM_L3, init_cond2); 1036 } 1037 #ifdef BCM_HURRICANE3_SUPPORT 1038 else if (!soc_feature(unit, soc_feature_l3) && 1039 soc_feature(unit, soc_feature_miml_no_l3)) { 1040 _BCM_MOD_INIT_IER(unit, bcm_esw_l3_init, SHR_BPROF_BCM_L3, init_cond); 1041 } 1042 #endif 1043 if (soc_feature(unit, soc_feature_ip_mcast)) { 1044 init_cond2 = init_cond && (!soc_property_get(unit, "skip_ipmc_init", 0)); 1045 _BCM_MOD_INIT_IER(unit, bcm_esw_ipmc_init, SHR_BPROF_BCM_IPMC, init_cond2); 1046 } 1047 1048 #ifdef BCM_MPLS_SUPPORT 1049 if (soc_feature(unit, soc_feature_mpls)) { 1050 init_cond2 = init_cond && (!soc_property_get(unit, "skip_mpls_init", 0)); 1051 _BCM_MOD_INIT_IER(unit, bcm_esw_mpls_init, SHR_BPROF_BCM_MPLS, init_cond2); 1052 if (!init_cond2) { 1053 /* TD3TBD, to remove this after mpls completed */ 1054 SOC_FEATURE_CLEAR(unit, soc_feature_mpls); 1055 } 1056 } 1057 #endif 1058 if (soc_feature(unit, soc_feature_mim)) { 1059 init_cond2 = init_cond && (!soc_property_get(unit, "skip_mim_init", 0)); 1060 _BCM_MOD_INIT_IER(unit, bcm_esw_mim_init, SHR_BPROF_BCM_MIM, init_cond2); 1061 } 1062 if (soc_feature(unit, soc_feature_wlan)) { 1063 _BCM_MOD_INIT_IER(unit, bcm_esw_wlan_init, SHR_BPROF_BCM_WLAN, init_cond); 1064 } 1065 _BCM_MOD_INIT_IER(unit, bcm_esw_proxy_init, SHR_BPROF_BCM_PROXY, init_cond); 1066 #endif 1067 /* KT2 doesn't need L3 support for Coe/Linkphy subport initialization 1068 * whereas L3 support is needed for traditional subport initialization 1069 */ 1070 #if defined(INCLUDE_L3) || defined(BCM_KATANA2_SUPPORT) 1071 if (soc_feature(unit, soc_feature_subport) || 1072 soc_feature(unit, soc_feature_linkphy_coe) || 1073 soc_feature(unit, soc_feature_subtag_coe) || 1074 soc_feature(unit, soc_feature_hgproxy_subtag_coe)) { 1075 _BCM_MOD_INIT_IER(unit, bcm_esw_subport_init, SHR_BPROF_BCM_SUBPORT, init_cond); 1076 } 1077 #endif /* INCLUDE_L3 || BCM_KATANA2_SUPPORT */ 1078 if (soc_feature(unit, soc_feature_qos_profile)) { 1079 init_cond2 = init_cond && (!soc_property_get(unit, "skip_qos_init", 0)); 1080 _BCM_MOD_INIT_IER(unit, bcm_esw_qos_init, SHR_BPROF_BCM_QOS, init_cond2); 1081 } 1082 1083 #ifdef INCLUDE_L3 1084 if (soc_feature(unit, soc_feature_trill)) { 1085 _BCM_MOD_INIT_IER(unit, bcm_esw_trill_init, SHR_BPROF_BCM_TRILL, init_cond); 1086 } 1087 if (soc_feature(unit, soc_feature_niv)) { 1088 _BCM_MOD_INIT_IER(unit, bcm_esw_niv_init, SHR_BPROF_BCM_NIV, init_cond); 1089 } 1090 if (soc_feature(unit, soc_feature_l2gre)) { 1091 _BCM_MOD_INIT_IER(unit, bcm_esw_l2gre_init, SHR_BPROF_BCM_L2GRE, init_cond); 1092 } 1093 if (soc_feature(unit, soc_feature_vxlan) || 1094 soc_feature(unit, soc_feature_vxlan_lite)) { 1095 _BCM_MOD_INIT_IER(unit, bcm_esw_vxlan_init, 1096 SHR_BPROF_BCM_VXLAN, init_cond); 1097 } 1098 if (soc_feature(unit, soc_feature_flex_flow)) { 1099 _BCM_MOD_INIT_IER(unit, bcm_esw_flow_init, SHR_BPROF_BCM_FLOW, init_cond); 1100 } 1101 if (soc_feature(unit, soc_feature_hash_flex_bin)) { 1102 init_cond2 = init_cond || (soc_property_get(unit, "skip_hash_init", 1103 0) ? FALSE : TRUE); 1104 _BCM_MOD_INIT_IER(unit, bcm_esw_hash_init, SHR_BPROF_BCM_HASH, 1105 init_cond2); 1106 } 1107 if (soc_feature(unit, soc_feature_port_extension)) { 1108 _BCM_MOD_INIT_IER(unit, bcm_esw_extender_init, SHR_BPROF_BCM_EXTENDER, init_cond); 1109 } 1110 1111 /* This must be after the modules upon which it is build, in order 1112 * for Warm Boot to operate correctly. */ 1113 _BCM_MOD_INIT_IER(unit, bcm_esw_multicast_init, SHR_BPROF_BCM_MULTICAST, init_cond); 1114 #endif 1115 #ifdef BCM_FIELD_SUPPORT 1116 if (soc_feature(unit, soc_feature_field)) { 1117 init_cond2 = init_cond && (!soc_property_get(unit, "skip_auth_init", 0)); 1118 _BCM_MOD_INIT_IER(unit, bcm_esw_auth_init, SHR_BPROF_BCM_AUTH, init_cond2); 1119 } 1120 #endif 1121 #ifdef INCLUDE_REGEX 1122 if (soc_feature(unit, soc_feature_regex)) { 1123 _BCM_MOD_INIT_IER(unit, bcm_esw_regex_init, SHR_BPROF_BCM_REGEX, init_cond); 1124 } 1125 #endif 1126 if (soc_feature(unit, soc_feature_time_support)) { 1127 _BCM_MOD_INIT_IER(unit, bcm_esw_time_init, SHR_BPROF_BCM_TIME, init_cond); 1128 } 1129 /* Temporarily disable eapps modules on MV2 SVK till integration is complete */ 1130 if (!(SOC_IS_MAVERICK2(unit) && !SAL_BOOT_BCMSIM)) { 1131 if (soc_feature(unit, soc_feature_oam) || 1132 soc_feature(unit, soc_feature_fp_based_oam)) { 1133 _BCM_MOD_INIT_IER(unit, bcm_esw_oam_init, SHR_BPROF_BCM_OAM, TRUE); 1134 } 1135 } 1136 #ifdef BCM_INSTRUMENTATION_SUPPORT 1137 if (soc_feature(unit, soc_feature_visibility)) { 1138 BCM_IF_ERROR_RETURN(bcm_esw_pkt_trace_init(unit)); 1139 } 1140 #endif 1141 #ifdef INCLUDE_BFD 1142 if (soc_feature(unit, soc_feature_bfd)) { 1143 _BCM_MOD_INIT_IER(unit, bcm_esw_bfd_init, SHR_BPROF_BCM_BFD, init_cond); 1144 } 1145 #endif 1146 if (!(SOC_IS_MAVERICK2(unit) && !SAL_BOOT_BCMSIM)) { 1147 #ifdef INCLUDE_PTP 1148 if (soc_feature(unit, soc_feature_ptp)) { 1149 _BCM_MOD_INIT_IER(unit, bcm_esw_ptp_init, SHR_BPROF_BCM_PTP, init_cond); 1150 } 1151 #endif 1152 #if defined(BCM_TSN_SUPPORT) 1153 if (soc_feature(unit, soc_feature_tsn)){ 1154 _BCM_MOD_INIT_CER(unit, bcm_esw_tsn_init, SHR_BPROF_BCM_TSN, TRUE); 1155 } 1156 #endif /* BCM_TSN_SUPPORT */ 1157 } 1158 1159 /* 1160 * No need to call Port downsizer during warmboot 1161 */ 1162 #ifdef BCM_KATANA_SUPPORT 1163 if (SOC_IS_KATANA(unit) 1164 #if defined(BCM_WARM_BOOT_SUPPORT) 1165 && (!SOC_WARM_BOOT(unit)) 1166 #endif /* BCM_WARM_BOOT_SUPPORT */ 1167 ) { 1168 BCM_IF_ERROR_RETURN(bcm_kt_port_downsizer_chk_reinit(unit)); 1169 } 1170 #endif 1171 1172 #if defined(BCM_COLLECTOR_SUPPORT) 1173 if (soc_feature(unit, soc_feature_collector)) { 1174 _BCM_MOD_INIT_IER(unit, bcm_esw_collector_init, SHR_BPROF_BCM_COLLECTOR, 1175 TRUE); 1176 } 1177 #endif 1178 1179 #if defined(INCLUDE_TELEMETRY) 1180 if (soc_feature(unit, soc_feature_telemetry)) { 1181 _BCM_MOD_INIT_IER(unit, bcm_esw_telemetry_init, SHR_BPROF_BCM_TELEMETRY, 1182 TRUE); 1183 } 1184 #endif 1185 1186 #if defined(BCM_TRIDENT2_SUPPORT) 1187 if (soc_feature(unit, soc_feature_fcoe)) { 1188 _BCM_MOD_INIT_IER(unit, bcm_esw_fcoe_init, SHR_BPROF_BCM_FCOE, init_cond); 1189 } 1190 #endif 1191 #ifdef BCM_HURRICANE2_SUPPORT 1192 if (SOC_IS_HURRICANE2(unit)) { 1193 BCM_IF_ERROR_RETURN(bcm_hr2_dual_port_mode_reinit(unit)); 1194 } 1195 #endif 1196 #if defined(BCM_SABER2_SUPPORT) 1197 if (soc_feature(unit, soc_feature_sat)) { 1198 BCM_IF_ERROR_RETURN(bcm_common_sat_init(unit)); 1199 1200 _BCM_MOD_INIT_IER(unit, bcm_sb2_sat_init, SHR_BPROF_BCM_SAT, 1201 init_cond); 1202 } 1203 #endif 1204 1205 #if defined(INCLUDE_FLOWTRACKER) || defined(BCM_FLOWTRACKER_SUPPORT) 1206 /* Flowtracker is possible in 3 cases. 1207 * Call flow tracker init only if one of the cases is true. 1208 * 1209 * Learn and export by FW. (Ex: TH/TH2/TH3) 1210 * Learn by HW and export by FW. (Ex: TD3B0/MV2) 1211 * Learn and export by HW. (Ex: HX5). 1212 */ 1213 if (soc_feature(unit, soc_feature_uc_flowtracker_learn) || 1214 soc_feature(unit, soc_feature_uc_flowtracker_export) || 1215 soc_feature(unit, soc_feature_mv2_style_flowtracker) || 1216 soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 1217 _BCM_MOD_INIT_IER(unit, bcm_esw_flowtracker_init, SHR_BPROF_BCM_FT, TRUE); 1218 } 1219 #endif /* INCLUDE_FLOWTRACKER || BCM_FLOWTRACKER_SUPPORT */ 1220 1221 #if defined(INCLUDE_GDPLL) 1222 if (SOC_IS_MONTEREY(unit)) { 1223 BCM_IF_ERROR_RETURN(_bcm_esw_gdpll_init(unit)); 1224 } 1225 #endif 1226 1227 #if defined(BCM_MONTEREY_SUPPORT) 1228 if (SOC_IS_MONTEREY(unit)) { 1229 BCM_IF_ERROR_RETURN(_bcm_esw_time_capture_init(unit)); 1230 } 1231 #endif 1232 1233 #if defined(BCM_TIMESYNC_TIME_CAPTURE_SUPPORT) 1234 if (soc_feature(unit, soc_feature_timesync_time_capture)) { 1235 BCM_IF_ERROR_RETURN(bcm_esw_time_capture_ts_init(unit)); 1236 } 1237 #endif /* BCM_TIMESYNC_TIME_CAPTURE_SUPPORT */ 1238 1239 #if defined(BCM_TOMAHAWK_SUPPORT) 1240 if (SOC_IS_TOMAHAWKX(unit)) { 1241 if (soc_feature(unit, soc_feature_untethered_otp)) { 1242 BCM_IF_ERROR_RETURN(bcmi_port_force_lb_set(unit)); 1243 } else { 1244 BCM_IF_ERROR_RETURN(bcm_th_phy_lb_set(unit)); 1245 } 1246 } 1247 #endif 1248 1249 #if defined(BCM_GREYHOUND2_SUPPORT) 1250 if (SOC_IS_GREYHOUND2(unit)) { 1251 BCM_IF_ERROR_RETURN(bcmi_gh2_port_force_lb_set(unit)); 1252 } 1253 #endif /* BCM_GREYHOUND2_SUPPORT */ 1254 1255 #if defined(BCM_MONTEREY_SUPPORT) 1256 if (SOC_IS_MONTEREY(unit)) { 1257 SOC_IF_ERROR_RETURN(soc_monterey_gatingconfig_init(unit)); 1258 1259 } 1260 #endif 1261 #if defined(BCM_MONTEREY_SUPPORT) 1262 if (SOC_IS_MONTEREY(unit)) { 1263 SOC_IF_ERROR_RETURN(soc_monterey_gatingconfig_init(unit)); 1264 1265 } 1266 #endif 1267 #if defined(INCLUDE_XFLOW_MACSEC) 1268 _BCM_MOD_INIT_IER(unit, _bcm_common_xflow_macsec_init, SHR_BPROF_BCM_XFLOW_MACSEC, TRUE); 1269 #endif 1270 1271 #ifdef INCLUDE_IFA 1272 if (soc_feature(unit, soc_feature_ifa)) { 1273 _BCM_MOD_INIT_IER(unit, bcm_esw_ifa_init, SHR_BPROF_BCM_IFA, TRUE); 1274 } 1275 #endif 1276 1277 if (SOC_WARM_BOOT(unit)) { 1278 LOG_CLI((BSL_META_U(unit, 1279 "bcm_init all modules took %10d usec\n"), 1280 _bcm_modules_init_time)); 1281 } else { 1282 LOG_VERBOSE(BSL_LS_BCM_COMMON, (BSL_META_U(unit, 1283 "bcm_init all modules took %10d usec\n"), 1284 _bcm_modules_init_time)); 1285 } 1286 1287 return BCM_E_NONE; 1288 } 1289 1290 #if defined(BCM_XGS3_SWITCH_SUPPORT) 1291 #ifdef BCM_WARM_BOOT_SUPPORT 1292 1293 STATIC int 1294 _bcm_mem_scache_init(int unit) 1295 { 1296 SOC_IF_ERROR_RETURN(soc_mem_cache_scache_init(unit)); 1297 return BCM_E_NONE; 1298 } 1299 1300 int 1301 _bcm_mem_scache_sync(int unit) 1302 { 1303 SOC_IF_ERROR_RETURN(soc_mem_cache_scache_sync(unit)); 1304 return BCM_E_NONE; 1305 } 1306 1307 STATIC int 1308 _bcm_switch_control_scache_init(int unit) 1309 { 1310 return soc_switch_control_scache_init(unit); 1311 } 1312 1313 int 1314 _bcm_switch_control_scache_sync(int unit) 1315 { 1316 return soc_switch_control_scache_sync(unit); 1317 } 1318 1319 1320 #endif /* BCM_WARM_BOOT_SUPPORT */ 1321 #endif /* defined(BCM_XGS3_SWITCH_SUPPORT) */ 1322 1323 /* 1324 * Function: 1325 * _bcm_esw_init 1326 * Purpose: 1327 * Initialize the BCM API layer only, without resetting the switch chip. 1328 * Parameters: 1329 * unit - StrataSwitch unit #. 1330 * Returns: 1331 * BCM_E_XXX 1332 */ 1333 1334 STATIC int 1335 _bcm_esw_init(int unit) 1336 { 1337 1338 int warmboot_post_config = FALSE; 1339 1340 BCM_IF_ERROR_RETURN(_bcm_lock_init(unit)); 1341 1342 /* Skip rest of the initialization if early attaching */ 1343 if (BCM_CONTROL(unit)->attach_state == _bcmControlStateTxRxInit) { 1344 if(SOC_WARM_BOOT(unit)) { 1345 return (_bcm_modules_init(unit)); 1346 } else { 1347 /* Not supported if not warm booting */ 1348 return BCM_E_CONFIG; 1349 } 1350 } 1351 1352 SOC_CONTROL(unit)->soc_flags &= ~SOC_F_ALL_MODULES_INITED; 1353 1354 /* If linkscan is running, disable it. */ 1355 bcm_esw_linkscan_enable_set(unit, 0); 1356 1357 #ifdef INCLUDE_MACSEC 1358 BCM_IF_ERROR_RETURN(_bcm_common_macsec_init(unit)); 1359 #endif /* INCLUDE_MACSEC */ 1360 1361 #ifdef INCLUDE_FCMAP 1362 BCM_IF_ERROR_RETURN(_bcm_common_fcmap_init(unit)); 1363 #endif /* INCLUDE_FCMAP */ 1364 1365 #if defined(BCM_XGS3_SWITCH_SUPPORT) 1366 #ifdef BCM_WARM_BOOT_SUPPORT 1367 /* switch global warmboot state init/reinit */ 1368 BCM_IF_ERROR_RETURN(_bcm_switch_control_scache_init(unit)); 1369 1370 /* mem cache warmboot state init/reinit */ 1371 BCM_IF_ERROR_RETURN(_bcm_mem_scache_init(unit)); 1372 1373 #if defined(BCM_OLP_SUPPORT) 1374 if (soc_feature(unit, soc_feature_olp)) { 1375 /* Recover switch olp status before l2 module init */ 1376 BCM_IF_ERROR_RETURN(_bcm_esw_switch_olp_init(unit)); 1377 } 1378 #endif 1379 1380 #endif /* BCM_WARM_BOOT_SUPPORT */ 1381 #endif /* defined(BCM_XGS3_SWITCH_SUPPORT) */ 1382 1383 BCM_IF_ERROR_RETURN(_bcm_modules_init(unit)); 1384 1385 #ifdef BCM_TRIDENT_SUPPORT 1386 /* Workaround to initialize WRED memories to known state. */ 1387 if ((SOC_IS_TRIDENT(unit) || SOC_IS_TITAN(unit)) && 1388 !SOC_WARM_BOOT(unit)) { 1389 BCM_IF_ERROR_RETURN(_bcm_td_wred_mem_war(unit)); 1390 } 1391 #endif 1392 #ifdef BCM_TRIUMPH3_SUPPORT 1393 if (!SOC_WARM_BOOT(unit)) { 1394 /* Helix4 XL port XMAC FIFO UR handling */ 1395 if (SOC_IS_HELIX4(unit)) { 1396 /* coverity[negative_returns] */ 1397 if (!SAL_BOOT_SIMULATION) { 1398 BCM_IF_ERROR_RETURN(_bcm_tr3_port_ur_chk(unit, -1, -1)); 1399 } 1400 } 1401 } 1402 #endif 1403 1404 #ifdef BCM_XGS3_SWITCH_SUPPORT 1405 BCM_IF_ERROR_RETURN(_bcm_esw_switch_init(unit)); 1406 #endif 1407 1408 if (SOC_WARM_BOOT(unit)) { 1409 warmboot_post_config = TRUE; 1410 SOC_WARM_BOOT_DONE(unit); 1411 } 1412 1413 if (warmboot_post_config == TRUE) { 1414 /* To avoid acctidently reconfigure hardware, write to register is 1415 * bypassed during the warm boot until SOC_WARM_BOOT_DONE */ 1416 /* for the cases that we do need to reconfigure hardware, we do it here */ 1417 1418 /* When warmboot from releases not enabling MOR by default, need to 1419 * enable MOR after warmboot. 1420 */ 1421 #if defined(BCM_TOMAHAWK2_SUPPORT) 1422 if (SOC_IS_TOMAHAWK2(unit) 1423 &&(2 == soc_property_get(unit, spn_BUFFER_STATS_COLLECT_TYPE, 1))){ 1424 SOC_IF_ERROR_RETURN 1425 (soc_tomahawk2_mmu_pstats_mor_enable(unit)); 1426 } 1427 #endif 1428 #if defined(BCM_TRIDENT3_SUPPORT) 1429 if (SOC_IS_TRIDENT3X(unit) 1430 &&(2 == soc_property_get(unit, spn_BUFFER_STATS_COLLECT_TYPE, 1))){ 1431 SOC_IF_ERROR_RETURN 1432 (soc_trident3_mmu_pstats_mor_enable(unit)); 1433 } 1434 #endif 1435 1436 #if defined(BCM_TOMAHAWK_SUPPORT) || defined(BCM_TRIDENT3_SUPPORT) 1437 if (SOC_IS_TOMAHAWKX(unit) || SOC_IS_TRIDENT3X(unit)) { 1438 if (soc_property_get(unit, "ctr_evict_enable", 1) && 1439 (SOC_CONTROL(unit)->counter_interval > 0)) { 1440 /* Clear all previously accumulated counter value in SW */ 1441 soc_counter_ctr_reset_to_zero(unit); 1442 /* WB done. Set counter to Evition mode */ 1443 SOC_IF_ERROR_RETURN 1444 (soc_ctr_evict_start(unit, 0, 1445 SOC_CONTROL(unit)->counter_interval)); 1446 } 1447 } 1448 #endif 1449 } 1450 1451 #if defined(BCM_RCPU_SUPPORT) && defined(BCM_XGS3_SWITCH_SUPPORT) 1452 BCM_IF_ERROR_RETURN(_bcm_esw_rcpu_init(unit)); 1453 #endif /* BCM_RCPU_SUPPORT && BCM_XGS3_SWITCH_SUPPORT */ 1454 1455 SOC_CONTROL(unit)->soc_flags |= SOC_F_ALL_MODULES_INITED; 1456 if (SOC_HW_RESET(unit)) { 1457 SOC_HW_RESET_DONE(unit); 1458 } 1459 1460 return BCM_E_NONE; 1461 } 1462 1463 /* 1464 * Function: 1465 * bcm_esw_init 1466 * Purpose: 1467 * Initialize the BCM API layer only, without resetting the switch chip. 1468 * Parameters: 1469 * unit - StrataSwitch unit #. 1470 * Returns: 1471 * BCM_E_XXX 1472 */ 1473 1474 int 1475 bcm_esw_init(int unit) 1476 { 1477 if (0 == SOC_UNIT_VALID(unit)) { 1478 return BCM_E_UNIT; 1479 } 1480 return _bcm_esw_init(unit); 1481 } 1482 1483 int 1484 bcm_shadow_init(int unit) 1485 { 1486 return bcm_esw_init(unit); 1487 } 1488 1489 /* 1490 * Function: 1491 * _bcm_esw_reinit_s3mii_war 1492 * Purpose: 1493 * Partially ReInitialize the BCM API layer only. 1494 * Used for the SW Workaround for S3MII. 1495 * Presently used in Katana Only. 1496 * Parameters: 1497 * unit - StrataSwitch unit #. 1498 * Returns: 1499 * BCM_E_XXX 1500 */ 1501 1502 int 1503 _bcm_esw_reinit_ka_war(int unit) 1504 { 1505 BCM_IF_ERROR_RETURN(_bcm_lock_init(unit)); 1506 bcm_esw_linkscan_enable_set(unit, 0); 1507 #ifdef INCLUDE_MACSEC 1508 BCM_IF_ERROR_RETURN(_bcm_common_macsec_init(unit)); 1509 #endif /* INCLUDE_MACSEC */ 1510 #ifdef INCLUDE_FCMAP 1511 BCM_IF_ERROR_RETURN(_bcm_common_fcmap_init(unit)); 1512 #endif /* INCLUDE_FCMAP */ 1513 SOC_IF_ERROR_RETURN(_bcm_modules_init(unit)); 1514 1515 return BCM_E_NONE; 1516 } 1517 1518 /* _bcm_esw_attach 1519 * Purpose: 1520 * Attach and initialize bcm device 1521 * Parameters: 1522 * unit - unit being detached 1523 * Returns: 1524 * BCM_E_XXX 1525 */ 1526 int 1527 _bcm_esw_attach(int unit, char *subtype) 1528 { 1529 int dunit; 1530 int rv; 1531 1532 COMPILER_REFERENCE(subtype); 1533 1534 BCM_CONTROL(unit)->capability |= BCM_CAPA_LOCAL; 1535 dunit = BCM_CONTROL(unit)->unit; 1536 1537 /* Initialize soc layer */ 1538 if ((NULL == SOC_CONTROL(dunit)) || 1539 (0 == (SOC_CONTROL(dunit)->soc_flags & SOC_F_ATTACHED))) { 1540 return (BCM_E_INIT); 1541 } 1542 1543 if (SOC_WARM_BOOT(unit) || /* portmap might be different to config file */ 1544 (NULL == SOC_CTR_CTRL(unit))) { 1545 rv = soc_counter_attach(unit); 1546 BCM_IF_ERROR_RETURN(rv); 1547 } 1548 1549 /* Initialize bcm layer */ 1550 BCM_CONTROL(unit)->chip_vendor = SOC_PCI_VENDOR(dunit); 1551 BCM_CONTROL(unit)->chip_device = SOC_PCI_DEVICE(dunit); 1552 BCM_CONTROL(unit)->chip_revision = SOC_PCI_REVISION(dunit); 1553 if (SOC_IS_XGS_SWITCH(dunit)) { 1554 BCM_CONTROL(unit)->capability |= BCM_CAPA_SWITCH; 1555 } 1556 if (SOC_IS_XGS_FABRIC(dunit)) { 1557 BCM_CONTROL(unit)->capability |= BCM_CAPA_FABRIC; 1558 } 1559 if (soc_feature(dunit, soc_feature_l3)) { 1560 BCM_CONTROL(unit)->capability |= BCM_CAPA_L3; 1561 } 1562 if (soc_feature(dunit, soc_feature_ip_mcast)) { 1563 BCM_CONTROL(unit)->capability |= 1564 BCM_CAPA_IPMC; 1565 } 1566 1567 /* Initialize port mappings */ 1568 _bcm_api_xlate_port_init(unit); 1569 1570 rv = _bcm_esw_init(unit); 1571 return (rv); 1572 } 1573 1574 int 1575 _bcm_shadow_attach(int unit, char *subtype) 1576 { 1577 return _bcm_esw_attach(unit, subtype); 1578 } 1579 1580 /* _bcm_esw_match 1581 * Purpose: 1582 * match BCM control subtype strings for ESW types 1583 * Parameters: 1584 * unit - unit being detached 1585 * Returns: 1586 * 0 match 1587 * !0 no match 1588 */ 1589 int 1590 _bcm_esw_match(int unit, char *subtype_a, char *subtype_b) 1591 { 1592 COMPILER_REFERENCE(unit); 1593 return sal_strcmp(subtype_a, subtype_b); 1594 } 1595 1596 int 1597 _bcm_shadow_match(int unit, char *subtype_a, char *subtype_b) 1598 { 1599 return _bcm_esw_match(unit, subtype_a, subtype_b); 1600 } 1601 1602 /* 1603 * Function: 1604 * bcm_esw_init_selective 1605 * Purpose: 1606 * Initialize specific bcm modules as desired. 1607 * Parameters: 1608 * unit - StrataSwitch unit #. 1609 * module_number - Indicate module number 1610 * Returns: 1611 * BCM_E_XXX 1612 */ 1613 1614 int 1615 bcm_esw_init_selective(int unit, uint32 module_number) 1616 { 1617 switch (module_number) { 1618 case BCM_MODULE_PORT : 1619 BCM_IF_ERROR_RETURN(bcm_esw_port_init(unit)); 1620 break; 1621 case BCM_MODULE_L2 : 1622 BCM_IF_ERROR_RETURN(bcm_esw_l2_init(unit)); 1623 break; 1624 case BCM_MODULE_VLAN : 1625 BCM_IF_ERROR_RETURN(bcm_esw_vlan_init(unit)); 1626 break; 1627 case BCM_MODULE_TRUNK : 1628 BCM_IF_ERROR_RETURN(bcm_esw_trunk_init(unit)); 1629 break; 1630 case BCM_MODULE_COSQ : 1631 BCM_IF_ERROR_RETURN(bcm_esw_cosq_init(unit)); 1632 break; 1633 case BCM_MODULE_MCAST : 1634 BCM_IF_ERROR_RETURN(bcm_esw_mcast_init(unit)); 1635 break; 1636 case BCM_MODULE_LINKSCAN : 1637 BCM_IF_ERROR_RETURN(bcm_esw_linkscan_init(unit)); 1638 break; 1639 case BCM_MODULE_STAT : 1640 BCM_IF_ERROR_RETURN(bcm_esw_stat_init(unit)); 1641 break; 1642 case BCM_MODULE_MIRROR : 1643 BCM_IF_ERROR_RETURN(bcm_esw_mirror_init(unit)); 1644 break; 1645 case BCM_MODULE_HASH : 1646 BCM_IF_ERROR_RETURN(bcm_esw_hash_init(unit)); 1647 break; 1648 #ifdef INCLUDE_L3 1649 case BCM_MODULE_L3 : 1650 BCM_IF_ERROR_RETURN(bcm_esw_l3_init(unit)); 1651 BCM_IF_ERROR_RETURN(bcm_esw_proxy_init(unit)); 1652 break; 1653 case BCM_MODULE_IPMC : 1654 BCM_IF_ERROR_RETURN(bcm_esw_ipmc_init(unit)); 1655 break; 1656 #ifdef BCM_MPLS_SUPPORT 1657 case BCM_MODULE_MPLS : 1658 BCM_IF_ERROR_RETURN(bcm_esw_mpls_init(unit)); 1659 break; 1660 #endif /* BCM_MPLS_SUPPORT */ 1661 case BCM_MODULE_MIM : 1662 BCM_IF_ERROR_RETURN(bcm_esw_mim_init(unit)); 1663 break; 1664 case BCM_MODULE_SUBPORT : 1665 BCM_IF_ERROR_RETURN(bcm_esw_subport_init(unit)); 1666 break; 1667 case BCM_MODULE_WLAN : 1668 BCM_IF_ERROR_RETURN(bcm_esw_wlan_init(unit)); 1669 break; 1670 #endif /* INCLUDE_L3 */ 1671 case BCM_MODULE_QOS : 1672 BCM_IF_ERROR_RETURN(bcm_esw_qos_init(unit)); 1673 break; 1674 case BCM_MODULE_STACK : 1675 BCM_IF_ERROR_RETURN(bcm_esw_stk_init(unit)); 1676 break; 1677 case BCM_MODULE_STG : 1678 BCM_IF_ERROR_RETURN(bcm_esw_stg_init(unit)); 1679 break; 1680 case BCM_MODULE_TX : 1681 BCM_IF_ERROR_RETURN(bcm_esw_tx_init(unit)); 1682 break; 1683 #ifdef BCM_FIELD_SUPPORT 1684 case BCM_MODULE_AUTH : 1685 BCM_IF_ERROR_RETURN(bcm_esw_auth_init(unit)); 1686 break; 1687 #endif 1688 case BCM_MODULE_RX : 1689 BCM_IF_ERROR_RETURN(bcm_esw_rx_init(unit)); 1690 break; 1691 case BCM_MODULE_UDF : 1692 BCM_IF_ERROR_RETURN(bcm_esw_udf_init(unit)); 1693 break; 1694 #ifdef BCM_FIELD_SUPPORT 1695 case BCM_MODULE_FIELD : 1696 BCM_IF_ERROR_RETURN(bcm_esw_field_init(unit)); 1697 break; 1698 #endif /* BCM_FIELD_SUPPORT */ 1699 case BCM_MODULE_TIME : 1700 BCM_IF_ERROR_RETURN(bcm_esw_time_init(unit)); 1701 break; 1702 case BCM_MODULE_FABRIC : 1703 break; 1704 case BCM_MODULE_POLICER : 1705 break; 1706 case BCM_MODULE_OAM : 1707 BCM_IF_ERROR_RETURN(bcm_esw_oam_init(unit)); 1708 break; 1709 #ifdef INCLUDE_L3 1710 case BCM_MODULE_FAILOVER : 1711 BCM_IF_ERROR_RETURN(bcm_esw_failover_init(unit)); 1712 break; 1713 #endif 1714 case BCM_MODULE_VSWITCH : 1715 break; 1716 #ifdef INCLUDE_L3 1717 case BCM_MODULE_MULTICAST: 1718 BCM_IF_ERROR_RETURN(bcm_esw_multicast_init(unit)); 1719 break; 1720 case BCM_MODULE_TRILL : 1721 BCM_IF_ERROR_RETURN(bcm_esw_trill_init(unit)); 1722 break; 1723 case BCM_MODULE_NIV : 1724 BCM_IF_ERROR_RETURN(bcm_esw_niv_init(unit)); 1725 break; 1726 case BCM_MODULE_L2GRE : 1727 BCM_IF_ERROR_RETURN(bcm_esw_l2gre_init(unit)); 1728 break; 1729 case BCM_MODULE_VXLAN : 1730 BCM_IF_ERROR_RETURN(bcm_esw_vxlan_init(unit)); 1731 break; 1732 case BCM_MODULE_EXTENDER : 1733 BCM_IF_ERROR_RETURN(bcm_esw_extender_init(unit)); 1734 break; 1735 case BCM_MODULE_FLOW : 1736 BCM_IF_ERROR_RETURN(bcm_esw_flow_init(unit)); 1737 break; 1738 #endif 1739 #ifdef INCLUDE_PTP 1740 case BCM_MODULE_PTP: 1741 BCM_IF_ERROR_RETURN(bcm_esw_ptp_init(unit)); 1742 break; 1743 #endif 1744 #ifdef INCLUDE_BFD 1745 case BCM_MODULE_BFD: 1746 BCM_IF_ERROR_RETURN(bcm_esw_bfd_init(unit)); 1747 break; 1748 #endif 1749 #ifdef INCLUDE_REGEX 1750 case BCM_MODULE_REGEX : 1751 BCM_IF_ERROR_RETURN(bcm_esw_regex_init(unit)); 1752 break; 1753 #endif /* BCM_MPLS_SUPPORT */ 1754 #ifdef BCM_COLLECTOR_SUPPORT 1755 case BCM_MODULE_COLLECTOR : 1756 BCM_IF_ERROR_RETURN(bcm_esw_collector_init(unit)); 1757 break; 1758 #endif /* BCM_COLLECTOR_SUPPORT */ 1759 #ifdef BCM_TSN_SUPPORT 1760 case BCM_MODULE_TSN: 1761 BCM_IF_ERROR_RETURN(bcm_esw_tsn_init(unit)); 1762 break; 1763 #endif /* BCM_TSN_SUPPORT */ 1764 #if defined(INCLUDE_FLOWTRACKER) || defined(BCM_FLOWTRACKER_SUPPORT) 1765 case BCM_MODULE_FLOWTRACKER: 1766 if (soc_feature(unit, soc_feature_uc_flowtracker_learn) || 1767 soc_feature(unit, soc_feature_uc_flowtracker_export) || 1768 soc_feature(unit, soc_feature_mv2_style_flowtracker) || 1769 soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 1770 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_init(unit)); 1771 } else { 1772 return BCM_E_UNAVAIL; 1773 } 1774 break; 1775 #endif /*INCLUDE_FLOWTRACKER || BCM_FLOWTRACKER_SUPPORT */ 1776 #ifdef INCLUDE_TELEMETRY 1777 case BCM_MODULE_TELEMETRY: 1778 if (soc_feature(unit, soc_feature_telemetry)) { 1779 BCM_IF_ERROR_RETURN(bcm_esw_telemetry_init(unit)); 1780 } else { 1781 return BCM_E_UNAVAIL; 1782 } 1783 break; 1784 #endif /* INCLUDE_TELEMETRY */ 1785 #ifdef INCLUDE_IFA 1786 case BCM_MODULE_IFA: 1787 if (soc_feature(unit, soc_feature_ifa)) { 1788 BCM_IF_ERROR_RETURN(bcm_esw_ifa_init(unit)); 1789 } else { 1790 return BCM_E_UNAVAIL; 1791 } 1792 break; 1793 #endif /* BCM_IFA_SUPPORT */ 1794 1795 default: 1796 return BCM_E_UNAVAIL; 1797 } 1798 return BCM_E_NONE; 1799 } 1800 1801 /* 1802 * Function: 1803 * bcm_esw_init_check 1804 * Purpose: 1805 * Return value from system_init() operation. 1806 * Parameters: 1807 * unit- StrataSwitch unit #. 1808 * Returns: 1809 * BCM_E_XXX 1810 */ 1811 int 1812 bcm_esw_init_check(int unit) 1813 { 1814 if (!SOC_UNIT_VALID(unit)) { 1815 return BCM_E_UNIT; 1816 } 1817 1818 return BCM_CONTROL(unit)->system_initialized_rv; 1819 } 1820 1821 1822 /* 1823 * Function: 1824 * _bcm_esw_detach 1825 * Purpose: 1826 * Clean up bcm layer when unit is detached 1827 * Parameters: 1828 * unit - unit being detached 1829 * Returns: 1830 * BCM_E_XXX 1831 */ 1832 int 1833 _bcm_esw_detach(int unit) 1834 { 1835 int rv; /* Operation return status. */ 1836 1837 /* Shut down all the spawned threads. */ 1838 /* Threads should have been killed during the initial detach */ 1839 if (!(BCM_CONTROL(unit)->attach_state == _bcmControlStateDeinitAll)) { 1840 rv = _bcm_esw_threads_shutdown(unit); 1841 BCM_IF_ERROR_NOT_UNAVAIL_RETURN(rv); 1842 } 1843 1844 /* 1845 * Don't move up, holding lock or disabling hw operations 1846 * might prevent theads clean exit. 1847 */ 1848 BCM_LOCK(unit); 1849 1850 rv = _bcm_esw_modules_deinit(unit); 1851 1852 BCM_IF_ERROR_NOT_UNAVAIL_RETURN(rv); 1853 1854 return rv; 1855 } 1856 1857 int 1858 _bcm_shadow_detach(int unit) 1859 { 1860 return _bcm_esw_detach(unit); 1861 } 1862 1863 /* 1864 * Function: 1865 * bcm_esw_info_get 1866 * Purpose: 1867 * Provide unit information to caller 1868 * Parameters: 1869 * unit - switch device 1870 * info - (OUT) bcm unit info structure 1871 * Returns: 1872 * BCM_E_XXX 1873 */ 1874 int 1875 bcm_esw_info_get(int unit, bcm_info_t *info) 1876 { 1877 uint16 dev_id = 0; 1878 uint8 rev_id = 0; 1879 1880 if (!SOC_UNIT_VALID(unit)) { 1881 return BCM_E_UNIT; 1882 } 1883 if (info == NULL) { 1884 return BCM_E_PARAM; 1885 } 1886 soc_cm_get_id(unit, &dev_id, &rev_id); 1887 info->vendor = SOC_PCI_VENDOR(unit); 1888 info->device = dev_id; 1889 info->revision = rev_id; 1890 info->capability = 0; 1891 if (SOC_IS_XGS_FABRIC(unit) || SOC_IS_XGS_FABRIC_TITAN(unit)) { 1892 info->capability |= BCM_INFO_FABRIC; 1893 } else { 1894 info->capability |= BCM_INFO_SWITCH; 1895 } 1896 if (soc_feature(unit, soc_feature_l3)) { 1897 info->capability |= BCM_INFO_L3; 1898 } 1899 if (soc_feature(unit, soc_feature_ip_mcast)) { 1900 info->capability |= BCM_INFO_IPMC; 1901 } 1902 info->num_pipes = NUM_PIPE(unit); 1903 return BCM_E_NONE; 1904 } 1905 1906 1907 /* ASSUMES unit PARAMETER which is not in macro's list. */ 1908 #define CLEAR_CALL(_rtn, _name) { \ 1909 int rv; \ 1910 rv = (_rtn)(unit); \ 1911 if (rv < 0 && rv != BCM_E_UNAVAIL) { \ 1912 LOG_ERROR(BSL_LS_BCM_INIT, \ 1913 (BSL_META_U(unit, \ 1914 "bcm_clear %d: %s failed %d. %s\n"), \ 1915 unit, _name, rv, bcm_errmsg(rv))); \ 1916 return rv; \ 1917 } \ 1918 } 1919 1920 /* 1921 * Function: 1922 * bcm_esw_clear 1923 * Purpose: 1924 * Initialize a device without a full reset 1925 * Parameters: 1926 * unit - The unit number of the device to clear 1927 * Returns: 1928 * BCM_E_XXX 1929 * Notes: 1930 * For each module, call the underlying init/clear operation 1931 */ 1932 int 1933 bcm_esw_clear(int unit) 1934 { 1935 #if defined(BCM_TOMAHAWK3_SUPPORT) 1936 /* Added to handle SDK functions calling esw version, 1937 * instead of Tomahawk3's version 1938 */ 1939 if (SOC_IS_TOMAHAWK3(unit)) { 1940 return bcm_tomahawk3_clear(unit); 1941 } 1942 #endif /* BCM_TOMAHAWK3_SUPPORT */ 1943 return _bcm_esw_init(unit); 1944 } 1945 1946