cambist.c (23262B)
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 * TR test for CAMBIST. 8 * The test has no CLI parameters. Simply call tr 517 from command line. 9 */ 10 11 #include <appl/diag/system.h> 12 #include <shared/alloc.h> 13 #include <sal/core/alloc.h> 14 #include <shared/bsl.h> 15 16 #include <soc/cm.h> 17 #include <soc/dma.h> 18 #include <soc/drv.h> 19 #include <soc/dcb.h> 20 #include <soc/cmicm.h> 21 #include <soc/cmic.h> 22 23 #include <sal/types.h> 24 #include <appl/diag/parse.h> 25 #include <appl/diag/system.h> 26 #include <bcm/port.h> 27 #include <bcm/vlan.h> 28 #include <bcm/link.h> 29 30 #include "testlist.h" 31 32 #ifdef BCM_TOMAHAWK_SUPPORT 33 #include "cambist.h" 34 #include "th_cambist.h" 35 #ifdef BCM_TOMAHAWK2_SUPPORT 36 #include "th2_cambist.h" 37 #endif /*BCM_TOMAHAWK2_SUPPORT*/ 38 #ifdef BCM_TOMAHAWK3_SUPPORT 39 #include "th3_cambist.h" 40 #endif /*BCM_TOMAHAWK3_SUPPORT*/ 41 #ifdef BCM_TRIDENT3_SUPPORT 42 #include <soc/format.h> 43 #include "td3_cambist.h" 44 #endif /* BCM_TRIDENT3_SUPPORT */ 45 #ifdef BCM_MAVERICK2_SUPPORT 46 #include "mv2_cambist.h" 47 #endif /* BCM_MAVERICK2_SUPPORT */ 48 #ifdef BCM_HELIX5_SUPPORT 49 #include "hx5_cambist.h" 50 #endif /* BCM_HELIX5_SUPPORT */ 51 52 #define CAMBIST_TIMEOUT 100000 53 54 typedef struct cambist_test_s { 55 cambist_t *cambist_array; 56 uint32 total_cambist_count; 57 uint32 total_failures; 58 uint32 done_bit_mask; 59 uint32 bist_success_mask; 60 uint32 bad_input; 61 uint32 test_fail; 62 int (*test_config_f)(int unit, int init_or_done); 63 uint32 total_run_count; 64 } cambist_test_t; 65 66 static cambist_test_t *cambist_test_parray[SOC_MAX_NUM_DEVICES]; 67 68 /* 69 * Function: 70 * get_cambist_array 71 * Purpose: 72 * Populate members of cambist_test_t depending on the chip under test. 73 * Parameters: 74 * unit: StrataSwitch Unit #. 75 * 76 * Returns: 77 * Nothing 78 */ 79 80 static void 81 get_cambist_array(int unit) 82 { 83 uint16 dev_id, drv_dev_id; 84 uint8 rev_id, drv_rev_id; 85 86 cambist_test_t *cambist_test_p = cambist_test_parray[unit]; 87 88 soc_cm_get_id (unit, &dev_id, &rev_id); 89 soc_cm_get_id_driver(dev_id, rev_id, &drv_dev_id, &drv_rev_id); 90 91 #ifdef BCM_TOMAHAWK3_SUPPORT 92 if ((dev_id) == BCM56980_DEVICE_ID) { 93 cli_out("\nPopulating memory array for Tomahawk3"); 94 cambist_test_p->cambist_array = th3_cambist_array; 95 cambist_test_p->total_cambist_count = TH3_TOTAL_CAMBIST_COUNT; 96 cambist_test_p->done_bit_mask = TH3_DONE_BIT_MASK; 97 cambist_test_p->bist_success_mask = TH3_BIST_SUCCESS_MASK; 98 } else 99 #endif 100 #ifdef BCM_TOMAHAWK2_SUPPORT 101 if ((dev_id & 0xfff0) == BCM56970_DEVICE_ID) { 102 cli_out("\nPopulating memory array for Tomahawk2"); 103 cambist_test_p->cambist_array = th2_cambist_array; 104 cambist_test_p->total_cambist_count = TH2_TOTAL_CAMBIST_COUNT; 105 cambist_test_p->done_bit_mask = TH2_DONE_BIT_MASK; 106 cambist_test_p->bist_success_mask = TH2_BIST_SUCCESS_MASK; 107 } else 108 #endif 109 #ifdef BCM_TRIDENT3_SUPPORT 110 if (((dev_id ) == BCM56870_DEVICE_ID) || 111 ((dev_id ) == BCM56873_DEVICE_ID)){ 112 cli_out("\nPopulating memory array for Trident3"); 113 cambist_test_p->cambist_array = td3_cambist_array; 114 cambist_test_p->total_cambist_count = TD3_TOTAL_CAMBIST_COUNT; 115 cambist_test_p->done_bit_mask = TD3_DONE_BIT_MASK; 116 cambist_test_p->bist_success_mask = TD3_BIST_SUCCESS_MASK; 117 cambist_test_p->total_run_count = 0; 118 } else 119 #endif 120 #ifdef BCM_MAVERICK2_SUPPORT 121 if (((dev_id ) == BCM56770_DEVICE_ID) || 122 ((dev_id ) == BCM56771_DEVICE_ID)){ 123 cli_out("\nPopulating memory array for Maverick2"); 124 cambist_test_p->cambist_array = mv2_cambist_array; 125 cambist_test_p->total_cambist_count = MV2_TOTAL_CAMBIST_COUNT; 126 cambist_test_p->done_bit_mask = MV2_DONE_BIT_MASK; 127 cambist_test_p->bist_success_mask = MV2_BIST_SUCCESS_MASK; 128 cambist_test_p->total_run_count = 0; 129 } else 130 #endif 131 #ifdef BCM_HELIX5_SUPPORT 132 if ((drv_dev_id) == BCM56370_DEVICE_ID){ 133 cli_out("\nPopulating memory array for Helix5"); 134 cambist_test_p->cambist_array = hx5_cambist_array; 135 cambist_test_p->total_cambist_count = HX5_TOTAL_CAMBIST_COUNT; 136 cambist_test_p->done_bit_mask = HX5_DONE_BIT_MASK; 137 cambist_test_p->bist_success_mask = HX5_BIST_SUCCESS_MASK; 138 cambist_test_p->total_run_count = 0; 139 } else 140 #endif 141 142 if (dev_id == BCM56960_DEVICE_ID) { 143 cli_out("\nPopulating memory array for Tomahawk"); 144 cambist_test_p->cambist_array = th_cambist_array; 145 cambist_test_p->total_cambist_count = TH_TOTAL_CAMBIST_COUNT; 146 cambist_test_p->done_bit_mask = TH_DONE_BIT_MASK; 147 cambist_test_p->bist_success_mask = TH_BIST_SUCCESS_MASK; 148 } else { 149 cli_out("\nUnsupported chip"); 150 cambist_test_p->bad_input = 1; 151 } 152 } 153 154 /* 155 * Function: 156 * run_cambist 157 * Purpose: 158 * Run a CAMBIST for a TCAM. 159 * Parameters: 160 * unit: StrataSwitch Unit #. 161 * cambist_p: Pointer to structure of type cambist_t. 162 * 163 * Returns: 164 * Nothing 165 */ 166 167 static void 168 run_cambist(int unit, cambist_t *cambist_p) 169 { 170 int count; 171 uint32 bist_en; 172 uint32 bist_status = 0; 173 uint64 bist_status_64; 174 uint32 bist_done; 175 uint32 bist_success; 176 uint64 zero_64; 177 int timeout = CAMBIST_TIMEOUT; 178 179 #if defined(BCM_TRIDENT3_SUPPORT) 180 uint64 entbuf; 181 uint32 val_lo = 0; 182 uint32 val_hi = 0; 183 #endif /* BCM_TRIDENT3_SUPPORT */ 184 185 cambist_test_t *cambist_test_p = cambist_test_parray[unit]; 186 #if defined(BCM_TRIDENT3_SUPPORT) 187 COMPILER_64_SET(entbuf, 0x0, 0x0); 188 #endif /* BCM_TRIDENT3_SUPPORT */ 189 COMPILER_64_SET(zero_64, 0x0, 0x0); 190 COMPILER_64_SET(bist_status_64, 0x0, 0x0); 191 192 if (SOC_REG_FIELD_VALID(unit, cambist_p->cambist_config, 193 BIST_DBG_DATA_SLICE_OR_STATUS_SELf)) { 194 soc_reg_field32_modify(unit, cambist_p->cambist_config, REG_PORT_ANY, 195 BIST_DBG_DATA_SLICE_OR_STATUS_SELf, 0x00); 196 } 197 198 if (cambist_p->mode != NO_MODE && cambist_p->mode_field != NO_MODE_FIELD) { 199 soc_reg_field32_modify(unit, cambist_p->cambist_control, REG_PORT_ANY, 200 cambist_p->mode_field, cambist_p->mode); 201 } 202 203 #if defined(BCM_TRIDENT3_SUPPORT) 204 if ((SOC_IS_TRIDENT3X(unit)) && 205 ((SOC_REG_FIELD_VALID(unit, cambist_p->cambist_config, FULLf)) || 206 (SOC_REG_FIELD_VALID(unit, cambist_p->cambist_config, DATAf)))) { 207 (void) soc_reg_get(unit, cambist_p->cambist_config, REG_PORT_ANY, 208 0, &entbuf); 209 val_lo = COMPILER_64_LO(entbuf); 210 val_hi = COMPILER_64_HI(entbuf); 211 soc_format_field32_set(unit, CAM_BIST_CONFIG_64_FORMATfmt, 212 &val_lo, I_BIST_MODEf, cambist_p->mode == NO_MODE ? 0 : 213 cambist_p->mode); 214 COMPILER_64_SET(entbuf, val_hi, val_lo); 215 (void) soc_reg_set(unit, cambist_p->cambist_config, REG_PORT_ANY, 216 0,entbuf); 217 } else 218 #endif /* BCM_TRIDENT3_SUPPORT */ 219 { 220 if (SOC_REG_FIELD_VALID(unit, cambist_p->cambist_config, I_BIST_MODEf)) { 221 soc_reg_field32_modify(unit, cambist_p->cambist_config, REG_PORT_ANY, 222 I_BIST_MODEf, cambist_p->mode == NO_MODE ? 0 : 223 cambist_p->mode); 224 } 225 } 226 227 for (count = 0; count < cambist_p->cambist_count; count++) { 228 cli_out("\nRunning Cambist %s count %0d", 229 cambist_p->cambist_name, count); 230 231 timeout = CAMBIST_TIMEOUT; 232 bist_done = 0; 233 bist_success = 0; 234 bist_en = 0x1 << count; 235 236 if (cambist_p->cambist_enable != NO_CONTROL_ENABLE_FIELD && 237 cambist_p->cambist_control != NO_CONTROL_REGISTER) { 238 soc_reg_field32_modify(unit, cambist_p->cambist_control, REG_PORT_ANY, 239 cambist_p->cambist_enable, bist_en); 240 } 241 #if defined(BCM_TRIDENT3_SUPPORT) 242 if ((SOC_IS_TRIDENT3X(unit)) && 243 ((SOC_REG_FIELD_VALID(unit, cambist_p->cambist_config, FULLf)) || 244 (SOC_REG_FIELD_VALID(unit, cambist_p->cambist_config, DATAf)))) { 245 COMPILER_64_SET(entbuf, 0x0, 0x0); 246 (void) soc_reg_get(unit, cambist_p->cambist_config, REG_PORT_ANY, 247 0, &entbuf); 248 val_lo = COMPILER_64_LO(entbuf); 249 val_hi = COMPILER_64_HI(entbuf); 250 251 soc_format_field32_set(unit, CAM_BIST_CONFIG_64_FORMATfmt, 252 &val_lo, I_BIST_RST_Lf, 0); 253 COMPILER_64_SET(entbuf, val_hi, val_lo); 254 (void) soc_reg_set(unit, 255 cambist_p->cambist_config, REG_PORT_ANY, 256 0,entbuf); 257 258 soc_format_field32_set(unit, CAM_BIST_CONFIG_64_FORMATfmt, 259 &val_lo, I_BIST_ENf, 0); 260 COMPILER_64_SET(entbuf, val_hi, val_lo); 261 (void) soc_reg_set(unit, 262 cambist_p->cambist_config, REG_PORT_ANY, 263 0,entbuf); 264 265 soc_format_field32_set(unit, CAM_BIST_CONFIG_64_FORMATfmt, 266 &val_lo, I_BIST_RST_Lf, 1); 267 COMPILER_64_SET(entbuf, val_hi, val_lo); 268 (void) soc_reg_set(unit, 269 cambist_p->cambist_config, REG_PORT_ANY, 270 0,entbuf); 271 272 soc_format_field32_set(unit, CAM_BIST_CONFIG_64_FORMATfmt, 273 &val_lo, I_BIST_ENf, bist_en); 274 COMPILER_64_SET(entbuf, val_hi, val_lo); 275 (void) soc_reg_set(unit, 276 cambist_p->cambist_config, REG_PORT_ANY, 277 0,entbuf); 278 279 } else 280 #endif /* BCM_TRIDENT3_SUPPORT */ 281 { 282 if (SOC_REG_FIELD_VALID(unit, cambist_p->cambist_config, I_BIST_ENf)) { 283 soc_reg_field32_modify(unit, cambist_p->cambist_config, REG_PORT_ANY, 284 I_BIST_RST_Lf, 0); 285 soc_reg_field32_modify(unit, cambist_p->cambist_config, REG_PORT_ANY, 286 I_BIST_ENf, 0); 287 soc_reg_field32_modify(unit, cambist_p->cambist_config, REG_PORT_ANY, 288 I_BIST_RST_Lf, 1); 289 soc_reg_field32_modify(unit, cambist_p->cambist_config, REG_PORT_ANY, 290 I_BIST_ENf, bist_en); 291 } 292 } 293 294 while (bist_done == 0 && timeout > 0) { 295 (void) soc_reg_get(unit, cambist_p->cambist_status, REG_PORT_ANY, 296 0, &bist_status_64); 297 298 bist_status = COMPILER_64_LO(bist_status_64); 299 300 bist_done = bist_status & cambist_test_p->done_bit_mask; 301 timeout--; 302 } 303 304 if (timeout > 0) { 305 bist_success = bist_status & cambist_test_p->bist_success_mask; 306 307 if (bist_success != 0) { 308 cli_out("\nCambist %s count %0d passed.", 309 cambist_p->cambist_name, count); 310 } else { 311 test_error(unit, "\n*ERROR: Cambist %s count %0d FAILED", 312 cambist_p->cambist_name, count); 313 test_error(unit, "\n bist_status %d bist_done %d bist_success %d", 314 bist_status, bist_done, bist_success); 315 cambist_test_p->test_fail = 1; 316 cambist_test_p->total_failures++; 317 } 318 } else { 319 test_error(unit, "\n*ERROR: Cambist %s count %0d TIMED OUT ", 320 cambist_p->cambist_name, count); 321 test_error(unit, "\n bist_status %d bist_done %d bist_success %d", 322 bist_status, bist_done, bist_success); 323 cambist_test_p->test_fail = 1; 324 cambist_test_p->total_failures++; 325 } 326 327 cambist_test_p->total_run_count++; 328 #if defined(BCM_TRIDENT3_SUPPORT) 329 if ((SOC_IS_TRIDENT3X(unit)) && 330 ((SOC_REG_FIELD_VALID(unit, cambist_p->cambist_config, FULLf)) || 331 (SOC_REG_FIELD_VALID(unit, cambist_p->cambist_config, DATAf)))) { 332 COMPILER_64_SET(entbuf, 0x0, 0x0); 333 (void) soc_reg_get(unit, cambist_p->cambist_config, REG_PORT_ANY, 334 0, &entbuf); 335 val_lo = COMPILER_64_LO(entbuf); 336 val_hi = COMPILER_64_HI(entbuf); 337 soc_format_field32_set(unit, CAM_BIST_CONFIG_64_FORMATfmt, 338 &val_lo, I_BIST_ENf, 0); 339 COMPILER_64_SET(entbuf, val_hi, val_lo); 340 (void) soc_reg_set(unit, 341 cambist_p->cambist_config, REG_PORT_ANY, 342 0,entbuf); 343 } else 344 #endif /* BCM_TRIDENT3_SUPPORT */ 345 346 { 347 if (SOC_REG_FIELD_VALID(unit, cambist_p->cambist_config, I_BIST_ENf)) { 348 soc_reg_field32_modify(unit, cambist_p->cambist_config, REG_PORT_ANY, 349 I_BIST_ENf, 0x0); 350 } 351 } 352 if (cambist_p->cambist_enable != NO_CONTROL_ENABLE_FIELD && 353 cambist_p->cambist_control != NO_CONTROL_REGISTER) { 354 soc_reg_field32_modify(unit, cambist_p->cambist_control, REG_PORT_ANY, 355 cambist_p->cambist_enable, 0x0); 356 } 357 358 (void) soc_reg_set(unit, cambist_p->cambist_status, 359 REG_PORT_ANY, 0, zero_64); 360 } 361 } 362 363 /* 364 * Function: 365 * run_cambist 366 * Purpose: 367 * Run a CAMBIST for a TCAM. 368 * Parameters: 369 * unit: StrataSwitch Unit #. 370 * cambist_p: Pointer to structure of type cambist_t. 371 * 372 * Returns: 373 * Nothing 374 */ 375 376 static void 377 run_all_cambists(int unit) 378 { 379 int i; 380 381 cambist_test_t *cambist_test_p = cambist_test_parray[unit]; 382 383 for (i = 0; i < cambist_test_p->total_cambist_count; i++) { 384 run_cambist(unit, &cambist_test_p->cambist_array[i]); 385 } 386 } 387 388 #ifdef BCM_TOMAHAWK2_SUPPORT 389 /* 390 * init_or_done: 1: init, 0: done 391 */ 392 int 393 cambist_th2_cam_init(int unit, int init_or_done) 394 { 395 int i, pipe; 396 uint32 rval, fval; 397 uint64 rval_64; 398 soc_reg_t reg; 399 soc_field_t tm, atom_disa; 400 struct cam_dbgctrl_table_s { 401 soc_reg_t reg; 402 soc_field_t tm; 403 soc_field_t atom_disable; 404 } th2_cam_dbgctrl_table[] = { 405 {VFP_CAM_CONTROL_SLICE_3_0r, TMf, ATOMICITY_DISABLEf}, 406 {L3_TUNNEL_CAM_DBGCTRL_64r, TMf, ATOMICITY_DISABLEf}, 407 {PARS_RAM_DBGCTRLr, FP_UDF_CAM_TMf, FP_UDF_CAM_ATOMICITY_DISABLEf}, 408 {VLAN_SUBNET_CAM_DBGCTRLr, TMf, ATOMICITY_DISABLEf}, 409 {VP_CAM_DBGCTRLr, MY_STATION_TCAM_ENTRY_ONLY_TMf, ATOMICITY_DISABLEf}, 410 {L3_DEFIP_CAM_DBGCTRL0r, CAM_TMf, CAM_ATOMICITY_DISABLEf}, 411 {MPLS_CAM_DBGCTRL_0r, IP_MULTICAST_TCAM_TMf, IP_MULTICAST_TCAM_ATOMICITY_DISABLEf}, 412 {L2_USER_ENTRY_CAM_DBGCTRLr, TMf, ATOMICITY_DISABLEf}, 413 {EXACT_MATCH_LOGICAL_TABLE_SELECT_CAM_DBGCTRLr, TMf, ATOMICITY_DISABLEf}, 414 {DST_COMPRESSION_CAM_DBGCTRLr, TMf, ATOMICITY_DISABLEf}, 415 {SRC_COMPRESSION_CAM_DBGCTRLr, TMf, ATOMICITY_DISABLEf}, 416 {IFP_LOGICAL_TABLE_SELECT_CAM_DBGCTRLr, TMf, ATOMICITY_DISABLEf}, 417 {RSEL2_CAM_DBGCTRLr, ING_SNAT_ONLY_TMf, ATOMICITY_DISABLEf}, 418 {SW3_RAM_CONTROL_2r, CPU_COS_MAP_TCAM_TMf, CPU_COS_MAP_ATOMICITY_DISABLEf}, 419 {EFP_RAM_CONTROL_2_64r, EFP_CAM_TMf, EFP_TCAM_ATOMICITY_DISABLEf}, 420 {IFP_TCAM0_DBGCTRLr, TMf, ATOMICITY_DISABLEf}, 421 {IFP_TCAM1_DBGCTRLr, TMf, ATOMICITY_DISABLEf}, 422 {IFP_TCAM2_DBGCTRLr, TMf, ATOMICITY_DISABLEf}, 423 {IFP_TCAM3_DBGCTRLr, TMf, ATOMICITY_DISABLEf}, 424 {IFP_TCAM4_DBGCTRLr, TMf, ATOMICITY_DISABLEf}, 425 {IFP_TCAM5_DBGCTRLr, TMf, ATOMICITY_DISABLEf}, 426 {IFP_TCAM6_DBGCTRLr, TMf, ATOMICITY_DISABLEf}, 427 {IFP_TCAM7_DBGCTRLr, TMf, ATOMICITY_DISABLEf}, 428 {IFP_TCAM8_DBGCTRLr, TMf, ATOMICITY_DISABLEf}, 429 {IFP_TCAM9_DBGCTRLr, TMf, ATOMICITY_DISABLEf}, 430 {IFP_TCAM10_DBGCTRLr, TMf, ATOMICITY_DISABLEf}, 431 {IFP_TCAM11_DBGCTRLr, TMf, ATOMICITY_DISABLEf} 432 }; 433 434 for (i = 0; i < COUNTOF(th2_cam_dbgctrl_table); i++) { 435 if (SOC_REG_UNIQUE_ACC(unit, th2_cam_dbgctrl_table[i].reg) != NULL) { 436 for (pipe = 0; pipe < NUM_PIPE(unit); pipe++) { 437 reg = th2_cam_dbgctrl_table[i].reg; 438 tm = th2_cam_dbgctrl_table[i].tm; 439 atom_disa = th2_cam_dbgctrl_table[i].atom_disable; 440 reg = SOC_REG_UNIQUE_ACC(unit, reg)[pipe]; 441 442 if (SOC_REG_IS_64(unit, reg)) { 443 SOC_IF_ERROR_RETURN 444 (soc_reg_get(unit, reg, REG_PORT_ANY, 0, &rval_64)); 445 fval = soc_reg64_field32_get(unit, reg, rval_64, tm); 446 if (init_or_done) { 447 fval |= (1 << 3); /* setting tm[3]=1 select switch clock source out of TCAM */ 448 } else { 449 fval &= ~(1 << 3); /* setting tm[3]=0 use cam internal generic clock source */ 450 } 451 soc_reg64_field32_set(unit, reg, &rval_64, tm, fval); 452 soc_reg64_field32_set(unit, reg, &rval_64, atom_disa, init_or_done ? 1 : 0); 453 SOC_IF_ERROR_RETURN 454 (soc_reg_set(unit, reg, REG_PORT_ANY, 0, rval_64)); 455 } else { 456 SOC_IF_ERROR_RETURN 457 (soc_reg32_get(unit, reg, REG_PORT_ANY, 0, &rval)); 458 fval = soc_reg_field_get(unit, reg, rval, tm); 459 if (init_or_done) { 460 fval |= (1 << 3); /* setting tm[3]=1 select switch clock source out of TCAM */ 461 } else { 462 fval &= ~(1 << 3); /* setting tm[3]=0 use cam internal generic clock source */ 463 } 464 soc_reg_field_set(unit, reg, &rval, tm, fval); 465 soc_reg_field_set(unit, reg, &rval, atom_disa, init_or_done ? 1 : 0); 466 SOC_IF_ERROR_RETURN 467 (soc_reg32_set(unit, reg, REG_PORT_ANY, 0, rval)); 468 } 469 } 470 } else 471 { 472 reg = th2_cam_dbgctrl_table[i].reg; 473 tm = th2_cam_dbgctrl_table[i].tm; 474 atom_disa = th2_cam_dbgctrl_table[i].atom_disable; 475 if (SOC_REG_IS_64(unit, reg)) { 476 SOC_IF_ERROR_RETURN 477 (soc_reg_get(unit, reg, REG_PORT_ANY, 0, &rval_64)); 478 fval = soc_reg64_field32_get(unit, reg, rval_64, tm); 479 if (init_or_done) { 480 fval |= (1 << 3); /* setting tm[3]=1 select switch clock source out of TCAM */ 481 } else { 482 fval &= ~(1 << 3); /* setting tm[3]=0 use cam internal generic clock source */ 483 } 484 soc_reg64_field32_set(unit, reg, &rval_64, tm, fval); 485 soc_reg64_field32_set(unit, reg, &rval_64, atom_disa, init_or_done ? 1 : 0); 486 SOC_IF_ERROR_RETURN 487 (soc_reg_set(unit, reg, REG_PORT_ANY, 0, rval_64)); 488 } else { 489 SOC_IF_ERROR_RETURN 490 (soc_reg32_get(unit, reg, REG_PORT_ANY, 0, &rval)); 491 fval = soc_reg_field_get(unit, reg, rval, tm); 492 if (init_or_done) { 493 fval |= (1 << 3); /* setting tm[3]=1 select switch clock source out of TCAM */ 494 } else { 495 fval &= ~(1 << 3); /* setting tm[3]=0 use cam internal generic clock source */ 496 } 497 soc_reg_field_set(unit, reg, &rval, tm, fval); 498 soc_reg_field_set(unit, reg, &rval, atom_disa, init_or_done ? 1 : 0); 499 SOC_IF_ERROR_RETURN 500 (soc_reg32_set(unit, reg, REG_PORT_ANY, 0, rval)); 501 } 502 } 503 } 504 505 return SOC_E_NONE; 506 } 507 #endif /* BCM_TOMAHAWK2_SUPPORT */ 508 /* 509 * init_or_done: 1: init, 0: done 510 */ 511 int 512 cambist_test_config(int unit, int init_or_done) 513 { 514 uint16 dev_id; 515 uint8 rev_id; 516 517 soc_cm_get_id(unit, &dev_id, &rev_id); 518 #ifdef BCM_TOMAHAWK2_SUPPORT 519 if (SOC_IS_TOMAHAWK2(unit)) { 520 SOC_IF_ERROR_RETURN 521 (WRITE_TOP_CLOCKING_ENFORCE_PSGr(unit, init_or_done ? 0x1fffff: 0)); 522 SOC_IF_ERROR_RETURN 523 (WRITE_TOP_CLOCKING_ENFORCE_PCGr(unit, init_or_done ? 0x7ffff : 0)); 524 if (rev_id == BCM56970_A0_REV_ID) { 525 SOC_IF_ERROR_RETURN(cambist_th2_cam_init(unit, init_or_done)); 526 } 527 } 528 #endif 529 #if defined(BCM_TRIDENT3_SUPPORT) || defined(BCM_TOMAHAWK3_SUPPORT) 530 if (SOC_IS_TRIDENT3X(unit) || SOC_IS_TOMAHAWK3(unit)) { 531 SOC_IF_ERROR_RETURN 532 (WRITE_TOP_CLOCKING_ENFORCE_PSGr(unit, init_or_done ? 0x1fffff: 0)); 533 SOC_IF_ERROR_RETURN 534 (WRITE_TOP_CLOCKING_ENFORCE_PCGr(unit, init_or_done ? 0x7ffff : 0)); 535 } 536 #endif /* BCM_TRIDENT3_SUPPORT */ 537 return 0; 538 } 539 540 int 541 cambist_test_init(int unit, args_t *a, void **pa) 542 { 543 int rv; 544 cambist_test_t *cambist_test_p = cambist_test_parray[unit]; 545 546 cli_out("\nCalling cambist_test_init"); 547 548 cambist_test_p = sal_alloc(sizeof(cambist_test_t), "cambist_test"); 549 sal_memset(cambist_test_p, 0, sizeof(cambist_test_t)); 550 cambist_test_parray[unit] = cambist_test_p; 551 552 cambist_test_p->bad_input = 0; 553 cambist_test_p->test_fail = 0; 554 cambist_test_p->total_failures = 0; 555 cambist_test_p->test_config_f = cambist_test_config; 556 557 get_cambist_array(unit); 558 559 if (cambist_test_p->bad_input == 0) { 560 rv = cambist_test_p->test_config_f(unit, 1); 561 if (rv < 0) { 562 return rv; 563 } 564 } 565 566 return 0; 567 } 568 569 int 570 cambist_test(int unit, args_t *a, void *pa) 571 { 572 cambist_test_t *cambist_test_p = cambist_test_parray[unit]; 573 574 cli_out("\nCalling cambist_test"); 575 576 (void) soc_mem_scan_stop(unit); 577 (void) bcm_linkscan_enable_set(unit, 0); 578 soc_counter_stop(unit); 579 580 if (cambist_test_p->bad_input == 1) { 581 goto done; 582 } 583 584 run_all_cambists(unit); 585 586 done: 587 588 return 0; 589 } 590 591 int 592 cambist_test_done(int unit, void *pa) 593 { 594 int rv; 595 596 cambist_test_t *cambist_test_p = cambist_test_parray[unit]; 597 598 cli_out("\nCalling cambist_test_done"); 599 600 if (cambist_test_p->bad_input == 1) { 601 goto done; 602 } 603 604 rv = cambist_test_p->test_config_f(unit, 0); 605 if (rv < 0) { 606 cambist_test_p->test_fail = 1; 607 goto done; 608 } 609 610 cli_out("\n"); 611 cli_out("\nTotal CAMBISTs run = %0d", cambist_test_p->total_run_count); 612 cli_out("\nTotal failures = %0d", cambist_test_p->total_failures); 613 614 done: 615 616 if (cambist_test_p->bad_input == 1) { 617 cambist_test_p->test_fail = 1; 618 } 619 620 if (cambist_test_p->test_fail == 1) { 621 rv = BCM_E_FAIL; 622 } else { 623 rv = BCM_E_NONE; 624 } 625 626 if (cambist_test_p->test_fail == 0) { 627 cli_out("\n********* All CAMBIST tests passed *********"); 628 } else { 629 test_error(unit, "********** ERROR: CAMBIST test failed *********"); 630 } 631 cli_out("\n"); 632 633 sal_free(cambist_test_p); 634 return rv; 635 } 636 637 #endif /* BCM_TOMAHAWK_SUPPORT */