show.c (62155B)
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 * Show CLI commands 8 * 9 * Also contains: 10 * Check CLI command 11 * Clear CLI command 12 */ 13 14 #include <appl/diag/system.h> 15 #include <appl/diag/dport.h> 16 #include <shared/bsl.h> 17 #include <bcm/stat.h> 18 #include <bcm/error.h> 19 #include <bcm/init.h> 20 #include <bcm_int/esw_dispatch.h> 21 22 #include <soc/drv.h> 23 #include <soc/mem.h> 24 #include <soc/mcm/driver.h> 25 26 #include <sal/appl/pci.h> 27 28 #if defined(VXWORKS) 29 #include <netShow.h> 30 #include <muxLib.h> 31 #endif /* VXWORKS */ 32 33 #if defined(VXWORKS_NETWORK_STACK_6_5) 34 #include <net/utils/netstat.h> 35 #endif /* VXWORKS_NETWORK_STACK_6_5 */ 36 37 #if defined(BCM_TRIDENT_SUPPORT) 38 #include <soc/trident.h> 39 #endif /* BCM_TRIDENT_SUPPORT */ 40 41 #if defined(BCM_TRIUMPH3_SUPPORT) 42 #include <soc/triumph3.h> 43 #endif /* BCM_TRIUMPH3_SUPPORT */ 44 45 #if defined(BCM_KATANA_SUPPORT) 46 #include <soc/katana.h> 47 #endif /* BCM_KATANA_SUPPORT */ 48 49 #if defined(BCM_SABER2_SUPPORT) 50 #include <soc/saber2.h> 51 #endif /* BCM_SABER2_SUPPORT */ 52 53 #if defined(BCM_KATANA2_SUPPORT) 54 #include <soc/katana2.h> 55 #include <bcm_int/esw/katana2.h> 56 #endif /* BCM_KATANA2_SUPPORT */ 57 58 #if defined(BCM_TRIDENT2_SUPPORT) 59 #include <soc/trident2.h> 60 #endif /* BCM_TRIDENT2_SUPPORT */ 61 62 #if defined(BCM_TRIDENT2PLUS_SUPPORT) 63 #include <soc/td2_td2p.h> 64 #endif /* BCM_TRIDENT2PLUS_SUPPORT */ 65 66 #if defined(BCM_TRIDENT3_SUPPORT) 67 #include <soc/trident3.h> 68 #endif /* BCM_TRIDENT3_SUPPORT */ 69 70 #if defined(BCM_HELIX5_SUPPORT) 71 #include <soc/helix5.h> 72 #endif /* BCM_HELIX5_SUPPORT */ 73 74 #if defined(BCM_APACHE_SUPPORT) 75 #include <soc/apache.h> 76 #endif /* BCM_APACHE_SUPPORT */ 77 78 #if defined(BCM_MONTEREY_SUPPORT) 79 #include <soc/monterey.h> 80 #endif /* BCM_MONTEREY_SUPPORT */ 81 82 #if defined(BCM_HURRICANE2_SUPPORT) 83 #include <soc/hurricane2.h> 84 #endif /* BCM_HURRICANE2_SUPPORT */ 85 86 #if defined(BCM_TOMAHAWK_SUPPORT) 87 #include <soc/tomahawk.h> 88 #endif /* BCM_TOMAHAWK_SUPPORT */ 89 90 #if defined(BCM_TOMAHAWK3_SUPPORT) 91 #include <soc/tomahawk3.h> 92 #endif /* BCM_TOMAHAWK3_SUPPORT */ 93 94 #if defined(BCM_KATANA2_SUPPORT) 95 cmd_result_t 96 do_show_linkphy_config(int unit); 97 #endif /* BCM_KATANA2_SUPPORT */ 98 99 #if defined(BCM_TRIDENT2PLUS_SUPPORT) 100 #include <bcm_int/esw/trident2.h> 101 #endif 102 103 /* 104 * Utility routine for show command 105 */ 106 107 cmd_result_t 108 do_show_memory(int unit, soc_mem_t mem, int copyno) 109 { 110 int entries; 111 char *ufname; 112 int blk; 113 114 ufname = SOC_MEM_UFNAME(unit, mem); 115 if (!soc_mem_is_sorted(unit, mem) && 116 !soc_mem_is_hashed(unit, mem) && 117 mem != VLAN_TABm) { 118 cli_out("ERROR: %s table is not sorted or hashed\n", 119 ufname); 120 return CMD_FAIL; 121 } 122 123 SOC_MEM_BLOCK_ITER(unit, mem, blk) { 124 if (copyno != COPYNO_ALL && copyno != blk) { 125 continue; 126 } 127 if ((entries = soc_mem_entries(unit, mem, blk)) < 0) { 128 cli_out("Error reading number of entries: %s\n", 129 soc_errmsg(entries)); 130 131 return CMD_FAIL; 132 } 133 134 cli_out("%s.%s contains %d entries\n", 135 ufname, SOC_BLOCK_NAME(unit, blk), entries); 136 } 137 138 return CMD_OK; 139 } 140 141 /* 142 * Show something to a user. 143 */ 144 145 /* 146 * *** ORDER *** 147 * 148 * The order of these tables must match the switch statements below. 149 */ 150 static parse_key_t show_arg[] = { 151 "Pci", /* 0 */ 152 "Counters", /* 1 */ 153 "Errors", /* 2 */ 154 "Interrupts", /* 3 */ 155 "Chips", /* 4 */ 156 "Statistics", /* 5 */ 157 "MIB", /* 6 */ 158 "TeMPmonitor", /* 7 */ 159 "MaterialProcess", /* 8 */ 160 "RingOSC", /* 9 */ 161 "PortMAP", /* 10 */ 162 "Rate", /* 11 */ 163 "Voltage", /* 12 */ 164 "LinkPhyCounter", /* 13 */ 165 }; 166 167 static int show_arg_cnt = PARSE_ENTRIES(show_arg); 168 169 static parse_key_t show_ctr_arg[] = { 170 "Changed", /* 0 */ 171 "Same", /* 1 */ 172 "Zero", /* 2 */ 173 "NonZero", /* 3 */ 174 "Hex", /* 4 */ 175 "Raw", /* 5 */ 176 "All", /* 6 */ 177 "ErDisc", /* 7 */ 178 "MmuStatus", /* 8 */ 179 }; 180 181 static int show_ctr_arg_cnt = PARSE_ENTRIES(show_ctr_arg); 182 183 #define GETTIME sal_time_usecs() 184 #define DCLTIME sal_usecs_t 185 #define FMTTIME "%u pkt/sec" 186 #define RATE(x) ((x) * 1000000) 187 /* 188 * Data structure for saving the previous value of counters so we can 189 * tell which counters that have changed since last shown. 190 */ 191 typedef struct counter_time_val_s { 192 DCLTIME prev_time; 193 uint64 val; 194 }counter_time_val_t; 195 196 STATIC counter_time_val_t *counter_time_val[SOC_MAX_NUM_DEVICES]; 197 198 cmd_result_t 199 cmd_esw_show(int unit, args_t *a) 200 { 201 soc_control_t *soc = SOC_CONTROL(unit); 202 soc_pbmp_t pbmp; 203 bcm_pbmp_t bcm_pbmp; 204 bcm_port_config_t pcfg; 205 const parse_key_t *cmd; 206 char *c; 207 soc_mem_t mem; 208 int copyno; 209 int flags; 210 soc_regaddrlist_t alist; 211 soc_reg_t ctr_reg; 212 soc_port_t port, dport; 213 int commachr = soc_property_get(unit, spn_DIAG_COMMA, ','); 214 char buf_val[32]; 215 #if defined(BCM_KATANA2_SUPPORT) || defined(BCM_TRIDENT2PLUS_SUPPORT) 216 int rv = 0; 217 #endif 218 #ifdef BCM_TRIDENT2PLUS_SUPPORT 219 int i, count, queue_mode, array_count = 0; 220 int *ar_idx_array = NULL; 221 soc_port_t *port_array = NULL; 222 #endif 223 224 if (!(c = ARG_GET(a))) { /* Nothing to do */ 225 return(CMD_USAGE); /* Print usage line */ 226 } 227 228 #if defined(BCM_KATANA2_SUPPORT) 229 if (!sal_strcasecmp(c, "linkphy")) { 230 do_show_linkphy_config(unit); 231 return CMD_OK; 232 } 233 #endif 234 235 #if defined (VXWORKS) 236 #if defined (VXWORKS_NETWORK_STACK_6_5) 237 if (!sal_strcasecmp(c, "ip")) { 238 netstat("-p ip -f inet"); 239 return CMD_OK; 240 } 241 if (!sal_strcasecmp(c, "icmp")) { 242 netstat("-p icmp -f inet"); 243 return CMD_OK; 244 } 245 if (!sal_strcasecmp(c, "arp")) { 246 arpShow(); 247 return CMD_OK; 248 } 249 if (!sal_strcasecmp(c, "udp")) { 250 netstat("-p udp -f inet"); 251 return CMD_OK; 252 } 253 if (!sal_strcasecmp(c, "tcp")) { 254 netstat("-p tcp -f inet"); 255 return CMD_OK; 256 } 257 if (!sal_strcasecmp(c, "mux")) { 258 muxShow(NULL, 0); 259 return CMD_OK; 260 } 261 if (!sal_strcasecmp(c, "routes")) { 262 netstat("-a -r"); 263 return CMD_OK; 264 } 265 if (!sal_strcasecmp(c, "hosts")){ 266 hostShow(); 267 return CMD_OK; 268 } 269 #else /* !VXWORKS_NETWORK_STACK_6_5 */ 270 if (!sal_strcasecmp(c, "ip")) { 271 ipstatShow(FALSE); 272 return CMD_OK; 273 } 274 if (!sal_strcasecmp(c, "icmp")) { 275 icmpstatShow(); 276 return CMD_OK; 277 } 278 if (!sal_strcasecmp(c, "arp")) { 279 arpShow(); 280 return CMD_OK; 281 } 282 if (!sal_strcasecmp(c, "udp")) { 283 udpstatShow(); 284 return CMD_OK; 285 } 286 if (!sal_strcasecmp(c, "tcp")) { 287 tcpstatShow(); 288 return CMD_OK; 289 } 290 if (!sal_strcasecmp(c, "mux")) { 291 #if defined(IDTRP334) 292 cli_out("muxShow not available on this BSP\n"); 293 #else 294 muxShow(NULL, 0); 295 #endif 296 return CMD_OK; 297 } 298 if (!sal_strcasecmp(c, "routes")) { 299 routeShow(); 300 return CMD_OK; 301 } 302 if (!sal_strcasecmp(c, "hosts")){ 303 hostShow(); 304 return CMD_OK; 305 } 306 #endif /* VXWORKS_NETWORK_STACK_6_5 */ 307 #endif 308 309 #if defined(BROADCOM_DEBUG) 310 if (!sal_strcasecmp(c, "feature") || !sal_strcasecmp(c, "features")) { 311 int all; 312 soc_feature_t f; 313 314 c = ARG_GET(a); 315 if (c == NULL) { 316 all = 0; 317 } else { 318 all = 1; 319 } 320 cli_out("Unit %d features:\n", unit); 321 322 for (f = 0; f < soc_feature_count; f++) { 323 if (soc_feature(unit, f)) { 324 cli_out("\t%s\n", soc_feature_name[f]); 325 } else if (all) { 326 cli_out("\t[%s]\n", soc_feature_name[f]); 327 } 328 } 329 return CMD_OK; 330 } 331 332 if (!sal_strcasecmp(c, "soc_is") || !sal_strcasecmp(c, "soc_is_chip")) { 333 #define SOC_IS_SHOW(unit, a) if (a(unit)) { cli_out("\t%s\n", #a); } 334 SOC_IS_SHOW(unit, SOC_IS_DRACO1) 335 SOC_IS_SHOW(unit, SOC_IS_DRACO15) 336 SOC_IS_SHOW(unit, SOC_IS_DRACO) 337 SOC_IS_SHOW(unit, SOC_IS_HERCULES1) 338 SOC_IS_SHOW(unit, SOC_IS_LYNX) 339 SOC_IS_SHOW(unit, SOC_IS_TUCANA) 340 SOC_IS_SHOW(unit, SOC_IS_XGS12_SWITCH) 341 SOC_IS_SHOW(unit, SOC_IS_HERCULES15) 342 SOC_IS_SHOW(unit, SOC_IS_HERCULES15) 343 SOC_IS_SHOW(unit, SOC_IS_HERCULES) 344 SOC_IS_SHOW(unit, SOC_IS_FIREBOLT) 345 SOC_IS_SHOW(unit, SOC_IS_FB) 346 SOC_IS_SHOW(unit, SOC_IS_FB_FX_HX) 347 SOC_IS_SHOW(unit, SOC_IS_HB_GW) 348 SOC_IS_SHOW(unit, SOC_IS_HBX) 349 SOC_IS_SHOW(unit, SOC_IS_FBX) 350 SOC_IS_SHOW(unit, SOC_IS_HURRICANE2) 351 SOC_IS_SHOW(unit, SOC_IS_GREYHOUND) 352 SOC_IS_SHOW(unit, SOC_IS_HELIX) 353 SOC_IS_SHOW(unit, SOC_IS_HELIX1) 354 SOC_IS_SHOW(unit, SOC_IS_HELIX15) 355 SOC_IS_SHOW(unit, SOC_IS_FELIX) 356 SOC_IS_SHOW(unit, SOC_IS_FELIX1) 357 SOC_IS_SHOW(unit, SOC_IS_FELIX15) 358 SOC_IS_SHOW(unit, SOC_IS_RAPTOR) 359 SOC_IS_SHOW(unit, SOC_IS_RAVEN) 360 SOC_IS_SHOW(unit, SOC_IS_HAWKEYE) 361 SOC_IS_SHOW(unit, SOC_IS_FX_HX) 362 SOC_IS_SHOW(unit, SOC_IS_GOLDWING) 363 SOC_IS_SHOW(unit, SOC_IS_HUMV) 364 SOC_IS_SHOW(unit, SOC_IS_BRADLEY) 365 SOC_IS_SHOW(unit, SOC_IS_FIREBOLT2) 366 SOC_IS_SHOW(unit, SOC_IS_TRIUMPH) 367 SOC_IS_SHOW(unit, SOC_IS_ENDURO) 368 SOC_IS_SHOW(unit, SOC_IS_HURRICANE) 369 SOC_IS_SHOW(unit, SOC_IS_HURRICANEX) 370 SOC_IS_SHOW(unit, SOC_IS_TR_VL) 371 SOC_IS_SHOW(unit, SOC_IS_VALKYRIE) 372 SOC_IS_SHOW(unit, SOC_IS_SCORPION) 373 SOC_IS_SHOW(unit, SOC_IS_SC_CQ) 374 SOC_IS_SHOW(unit, SOC_IS_CONQUEROR) 375 SOC_IS_SHOW(unit, SOC_IS_TRIUMPH2) 376 SOC_IS_SHOW(unit, SOC_IS_APOLLO) 377 SOC_IS_SHOW(unit, SOC_IS_VALKYRIE2) 378 SOC_IS_SHOW(unit, SOC_IS_TRIDENT) 379 SOC_IS_SHOW(unit, SOC_IS_TITAN) 380 SOC_IS_SHOW(unit, SOC_IS_TD_TT) 381 SOC_IS_SHOW(unit, SOC_IS_SHADOW) 382 SOC_IS_SHOW(unit, SOC_IS_TRIUMPH3) 383 SOC_IS_SHOW(unit, SOC_IS_HELIX4) 384 SOC_IS_SHOW(unit, SOC_IS_KATANA) 385 SOC_IS_SHOW(unit, SOC_IS_KATANAX) 386 SOC_IS_SHOW(unit, SOC_IS_KATANA2) 387 SOC_IS_SHOW(unit, SOC_IS_TRIDENT2) 388 SOC_IS_SHOW(unit, SOC_IS_TITAN2) 389 SOC_IS_SHOW(unit, SOC_IS_TD2_TT2) 390 SOC_IS_SHOW(unit, SOC_IS_TOMAHAWK) 391 SOC_IS_SHOW(unit, SOC_IS_TOMAHAWK2) 392 SOC_IS_SHOW(unit, SOC_IS_TOMAHAWK3) 393 SOC_IS_SHOW(unit, SOC_IS_TRIDENT3X) 394 SOC_IS_SHOW(unit, SOC_IS_TRX) 395 SOC_IS_SHOW(unit, SOC_IS_XGS) 396 SOC_IS_SHOW(unit, SOC_IS_XGS_FABRIC) 397 SOC_IS_SHOW(unit, SOC_IS_XGS_SWITCH) 398 SOC_IS_SHOW(unit, SOC_IS_XGS12_FABRIC) 399 SOC_IS_SHOW(unit, SOC_IS_XGS3_SWITCH) 400 SOC_IS_SHOW(unit, SOC_IS_XGS3_FABRIC) 401 SOC_IS_SHOW(unit, SOC_IS_ARAD) 402 SOC_IS_SHOW(unit, SOC_IS_ARADPLUS) 403 SOC_IS_SHOW(unit, SOC_IS_ARDON) 404 SOC_IS_SHOW(unit, SOC_IS_ARAD_A0) 405 SOC_IS_SHOW(unit, SOC_IS_ARAD_B0) 406 SOC_IS_SHOW(unit, SOC_IS_ARAD_B1) 407 SOC_IS_SHOW(unit, SOC_IS_ARADPLUS_A0) 408 SOC_IS_SHOW(unit, SOC_IS_ARAD_B0_AND_ABOVE) 409 SOC_IS_SHOW(unit, SOC_IS_ARAD_B1_AND_BELOW) 410 SOC_IS_SHOW(unit, SOC_IS_ARADPLUS_AND_BELOW) 411 SOC_IS_SHOW(unit, SOC_IS_ACP) 412 SOC_IS_SHOW(unit, SOC_IS_QMX) 413 SOC_IS_SHOW(unit, SOC_IS_JERICHO) 414 SOC_IS_SHOW(unit, SOC_IS_QMX_A0) 415 SOC_IS_SHOW(unit, SOC_IS_JERICHO_A0) 416 SOC_IS_SHOW(unit, SOC_IS_FE1600_A0) 417 SOC_IS_SHOW(unit, SOC_IS_FE1600_B0) 418 SOC_IS_SHOW(unit, SOC_IS_FE1600_B0_AND_ABOVE) 419 SOC_IS_SHOW(unit, SOC_IS_FE1600) 420 SOC_IS_SHOW(unit, SOC_IS_FE3200) 421 SOC_IS_SHOW(unit, SOC_IS_FE3200_A0) 422 SOC_IS_SHOW(unit, SOC_IS_DFE_TYPE) 423 SOC_IS_SHOW(unit, SOC_IS_FE1600_REDUCED) 424 SOC_IS_SHOW(unit, SOC_IS_BCM88754_A0) 425 SOC_IS_SHOW(unit, SOC_IS_RELOADING) 426 427 return CMD_OK; 428 } 429 430 if (!sal_strcasecmp(c, "param") || !sal_strcasecmp(c, "params")) { 431 if (!(c = ARG_GET(a))) { 432 /* Current unit */ 433 soc_chip_dump(unit, SOC_DRIVER(unit)); 434 } else { 435 int chip, pcidev; 436 chip = sal_ctoi(c, 0); 437 if ((chip >= 0x5600 && chip <= 0x56ff) || 438 (chip >= 0xb000 && chip <= 0xbfff)) { 439 /* search for driver for pci device id */ 440 pcidev = chip; 441 for (chip = 0; chip < SOC_NUM_SUPPORTED_CHIPS; chip++) { 442 if (pcidev == soc_base_driver_table[chip]->pci_device) { 443 soc_chip_dump(-1, soc_base_driver_table[chip]); 444 return CMD_OK; 445 } 446 } 447 cli_out("Chip device %x not found\n", pcidev); 448 return CMD_FAIL; 449 } 450 /* specific chip requested */ 451 if (chip >= SOC_NUM_SUPPORTED_CHIPS) { 452 cli_out("Bad chip parameter: %d. Max is %d\n", 453 chip, SOC_NUM_SUPPORTED_CHIPS); 454 } else if (!SOC_DRIVER_ACTIVE(chip)) { 455 cli_out("Chip %d is not supported.\n", chip); 456 } else { 457 soc_chip_dump(-1, soc_base_driver_table[chip]); 458 } 459 } 460 return CMD_OK; 461 } 462 if (!sal_strcasecmp(c, "unit") || !sal_strcasecmp(c, "units")) { 463 int u; 464 soc_control_t *usoc; 465 466 c = ARG_GET(a); 467 if (c != NULL) { /* specific unit */ 468 u = sal_ctoi(c, 0); 469 if (!SOC_UNIT_VALID(u)) { 470 cli_out("Unit %d is not valid\n", u); 471 return CMD_FAIL; 472 } 473 usoc = SOC_CONTROL(u); 474 if (!(usoc->soc_flags & SOC_F_ATTACHED)) { 475 cli_out("Unit %d (detached)\n", u); 476 return CMD_OK; 477 } 478 cli_out("Unit %d chip %s%s\n", 479 u, 480 soc_dev_name(u), 481 u == unit ? " (current)" : ""); 482 soc_chip_dump(u, SOC_DRIVER(u)); 483 } else { /* all units */ 484 for (u = 0; u < soc_ndev; u++) { 485 if (!SOC_UNIT_VALID(SOC_NDEV_IDX2DEV(u))) { 486 continue; 487 } 488 usoc = SOC_CONTROL(SOC_NDEV_IDX2DEV(u)); 489 cli_out("Unit %d chip %s%s\n", 490 SOC_NDEV_IDX2DEV(u), 491 soc_dev_name(SOC_NDEV_IDX2DEV(u)), 492 SOC_NDEV_IDX2DEV(u) == unit ? " (current)" : ""); 493 } 494 } 495 return CMD_OK; 496 } 497 #endif 498 499 /* Can only check memory this way if unit is attached */ 500 if (soc_attached(unit)) { 501 if (!sal_strcasecmp(c, "sa") || !sal_strcasecmp(c, "sarl")) { 502 cli_out("Software ARL table: \n"); 503 #ifdef BCM_TRIUMPH3_SUPPORT 504 if ((SOC_IS_TRIUMPH3(unit)) && 505 (soc_feature(unit, soc_feature_esm_support))) { 506 int int_count = 0; 507 int ext1_count = 0; 508 int ext2_count = 0; 509 if ((SOC_CONTROL(unit)->arlShadow == NULL) && 510 (SOC_CONTROL(unit)->arlShadow_ext1 == NULL) && 511 (SOC_CONTROL(unit)->arlShadow_ext2 == NULL)) { 512 cli_out("none\n"); 513 } else { 514 if (SOC_CONTROL(unit)->arlShadow != NULL) { 515 int_count = shr_avl_count(SOC_CONTROL(unit)->arlShadow); 516 } 517 if (SOC_CONTROL(unit)->arlShadow_ext1 != NULL) { 518 ext1_count = shr_avl_count( 519 SOC_CONTROL(unit)->arlShadow_ext1); 520 } 521 if (SOC_CONTROL(unit)->arlShadow_ext2 != NULL) { 522 ext2_count = shr_avl_count( 523 SOC_CONTROL(unit)->arlShadow_ext2); 524 } 525 cli_out("Entries on internal mem: %d\n" 526 "Entries on external mem: %d\n " 527 "Total %d entries \n", 528 int_count, ext1_count + ext2_count, 529 int_count + ext1_count + ext2_count); 530 } 531 } else 532 #endif 533 { 534 if (SOC_CONTROL(unit)->arlShadow == NULL) { 535 cli_out("none\n"); 536 } else { 537 cli_out("%d entries\n", 538 shr_avl_count(SOC_CONTROL(unit)->arlShadow)); 539 } 540 } 541 return CMD_OK; 542 } 543 544 if (parse_memory_name(unit, &mem, c, ©no, 0) >= 0) { 545 return do_show_memory(unit, mem, copyno); 546 } 547 } else { /* show based on chip */ 548 } 549 550 cmd = parse_lookup(c, show_arg, sizeof(show_arg[0]), show_arg_cnt); 551 if (!cmd) { 552 cli_out("%s: Error: Invalid option %s\n", ARG_CMD(a), c); 553 return(CMD_FAIL); 554 } 555 556 switch(cmd - show_arg) { 557 #if !defined(BCM_ICS) && !defined(NO_SAL_APPL) 558 case 0: /* PCI */ 559 /* COVERITY: Intentional, stack use of 5168 bytes */ 560 /* coverity[stack_use_callee_max : FALSE] */ 561 /* coverity[stack_use_overflow : FALSE] */ 562 pci_print_all(); 563 break; 564 #endif 565 case 1: /* Counters */ 566 flags = 0; 567 568 while ((c = ARG_GET(a)) != NULL) { 569 cmd = parse_lookup(c, 570 show_ctr_arg, sizeof (show_ctr_arg[0]), 571 show_ctr_arg_cnt); 572 573 switch (cmd - show_ctr_arg) { 574 case 0: 575 flags |= SHOW_CTR_CHANGED; 576 break; 577 case 1: 578 flags |= SHOW_CTR_SAME; 579 break; 580 case 2: 581 flags |= SHOW_CTR_Z; 582 break; 583 case 3: 584 flags |= SHOW_CTR_NZ; 585 break; 586 case 4: 587 flags |= SHOW_CTR_HEX; 588 break; 589 case 5: 590 flags |= SHOW_CTR_RAW; 591 break; 592 case 6: 593 flags |= (SHOW_CTR_CHANGED | SHOW_CTR_SAME | 594 SHOW_CTR_Z | SHOW_CTR_NZ); 595 break; 596 case 7: 597 flags |= SHOW_CTR_ED; 598 break; 599 case 8: 600 flags |= SHOW_CTR_MS; 601 break; 602 default: 603 goto break_for; 604 } 605 } 606 break_for: 607 608 /* 609 * Supply defaults 610 */ 611 612 if ((flags & (SHOW_CTR_CHANGED | SHOW_CTR_SAME)) == 0) { 613 flags |= SHOW_CTR_CHANGED; 614 } 615 616 if ((flags & (SHOW_CTR_Z | SHOW_CTR_NZ)) == 0) { 617 flags |= SHOW_CTR_NZ; 618 } 619 620 if (c == NULL) { 621 ctr_reg = INVALIDr; /* All registers */ 622 SOC_PBMP_ASSIGN(pbmp, PBMP_ALL(unit)); 623 } else if (parse_pbmp(unit, c, &pbmp) >= 0) { 624 ctr_reg = INVALIDr; /* All registers, selected ports */ 625 } else { 626 int i; 627 628 if (soc_regaddrlist_alloc(&alist) < 0) { 629 cli_out("Could not allocate address list. Memory error.\n"); 630 return CMD_FAIL; 631 } 632 633 if (parse_symbolic_reference(unit, &alist, c) < 0) { 634 cli_out("Syntax error parsing \"%s\"\n", c); 635 soc_regaddrlist_free(&alist); 636 return CMD_FAIL; 637 } 638 639 ctr_reg = alist.ainfo[0].reg; 640 641 if (!SOC_REG_IS_COUNTER(unit, ctr_reg)) { 642 cli_out("%s: Register is not a counter: %s\n", ARG_CMD(a), c); 643 soc_regaddrlist_free(&alist); 644 return(CMD_FAIL); 645 } 646 647 SOC_PBMP_CLEAR(pbmp); 648 649 for (i = 0; i < alist.count; i++) { 650 SOC_PBMP_PORT_ADD(pbmp, alist.ainfo[i].port); 651 } 652 soc_regaddrlist_free(&alist); 653 } 654 655 if (soc_feature(unit, soc_feature_cpuport_stat_dma)) { 656 pbmp_t temp_pbmp; 657 SOC_PBMP_CLEAR(temp_pbmp); 658 SOC_PBMP_OR(temp_pbmp, PBMP_PORT_ALL(unit)); 659 SOC_PBMP_OR(temp_pbmp, PBMP_CMIC(unit)); 660 SOC_PBMP_AND(pbmp, temp_pbmp); 661 } else { 662 SOC_PBMP_AND(pbmp, PBMP_PORT_ALL(unit)); 663 } 664 do_show_counters(unit, ctr_reg, pbmp, flags); 665 666 break; 667 case 2: /* Errors */ 668 cli_out("%s: Errors: SDRAM(%d) CFAP(%d) first-CELL(%d) MMU-SR(%d)\n", 669 ARG_CMD(a), 670 soc->stat.err_sdram, soc->stat.err_cfap, 671 soc->stat.err_fcell, soc->stat.err_sr); 672 cli_out("%s Timeout-Schan(%d),MII(%d)\n", 673 ARG_CMD(a), soc->stat.err_sc_tmo, soc->stat.err_mii_tmo); 674 break; 675 case 3: /* Interrupts */ 676 cli_out("%s: Interrupts: Total(%d) Schan-total(%d),error(%d) " 677 "Link(%d)\n", 678 ARG_CMD(a), soc->stat.intr, soc->stat.intr_sc, 679 soc->stat.intr_sce, soc->stat.intr_ls); 680 cli_out("%s: GBP-full(%d) PCI-fatal(%d),parity(%d)\n", 681 ARG_CMD(a), soc->stat.intr_gbp, soc->stat.intr_pci_fe, 682 soc->stat.intr_pci_pe); 683 684 if (soc_feature(unit, soc_feature_tslam_dma)) { 685 cli_out("%s: Table-DMA(%d),TSlam-DMA(%d)\n", 686 ARG_CMD(a), 687 soc->stat.intr_tdma, soc->stat.intr_tslam); 688 } 689 if (soc_feature(unit, soc_feature_fifo_dma)) { 690 cli_out("%s: Ch0-fifo-DMA(%d),Ch1-fifo-DMA(%d)\n", 691 ARG_CMD(a), 692 soc->stat.intr_fifo_dma[0], soc->stat.intr_fifo_dma[1]); 693 cli_out("%s: Ch2-fifo-DMA(%d),Ch3-fifo-DMA(%d)\n", 694 ARG_CMD(a), 695 soc->stat.intr_fifo_dma[2], soc->stat.intr_fifo_dma[3]); 696 } 697 cli_out("%s: I2C(%d),MII(%d),Stats(%d)," 698 "Desc(%d),Chain(%d)\n", 699 ARG_CMD(a), 700 soc->stat.intr_i2c, 701 soc->stat.intr_mii, 702 soc->stat.intr_stats, 703 soc->stat.intr_desc, 704 soc->stat.intr_chain); 705 break; 706 case 4: /* Chips */ 707 cli_out("Known chips:\n"); 708 soc_cm_display_known_devices(); 709 break; 710 case 5: /* Statistics */ 711 case 6: /* MIB */ 712 if (bcm_port_config_get(unit, &pcfg) != BCM_E_NONE) { 713 cli_out("%s: Error: bcm ports not initialized\n", ARG_CMD(a)); 714 return CMD_FAIL; 715 } 716 717 flags = 0; 718 if ((c = ARG_GET(a)) != NULL) { /* Ports specified? */ 719 if (0 != parse_bcm_pbmp(unit, c, &bcm_pbmp)) { 720 cli_out("%s: Invalid ports: %s\n", ARG_CMD(a), c); 721 return(CMD_FAIL); 722 } 723 if ((c = ARG_GET(a)) != NULL && sal_strcasecmp(c, "all") == 0) { 724 flags = 1; 725 } 726 } else { 727 BCM_PBMP_ASSIGN(bcm_pbmp, pcfg.port); 728 } 729 730 DPORT_BCM_PBMP_ITER(unit, bcm_pbmp, dport, port) { 731 bcm_stat_val_t s; 732 char *sname; 733 char *_stat_names[] = BCM_STAT_NAME_INITIALIZER; 734 int rv; 735 uint64 val; 736 737 cli_out("%s: Statistics for Unit %d port %s\n", 738 ARG_CMD(a), unit, BCM_PORT_NAME(unit, port)); 739 740 bcm_stat_sync(unit); 741 742 for (s = 0; s < snmpValCount; s++) { 743 sname = _stat_names[s]; 744 if (!sname) { 745 continue; 746 } 747 748 rv = bcm_stat_get(unit, port, s, &val);; 749 750 if ((rv < 0) && (rv != BCM_E_UNAVAIL)) { 751 cli_out("%8s\t%s (stat %d): %s\n", 752 "-", sname, s, bcm_errmsg(rv)); 753 continue; 754 } 755 if (rv == BCM_E_UNAVAIL) { 756 continue; 757 } 758 759 if (flags == 0 && COMPILER_64_IS_ZERO(val)) { 760 continue; 761 } 762 763 if (COMPILER_64_HI(val) == 0) { 764 cli_out("%8u\t%s (stat %d)\n", 765 COMPILER_64_LO(val), sname, s); 766 } else { 767 cli_out("0x%08x%08x\t%s (stat %d)\n", 768 COMPILER_64_HI(val), 769 COMPILER_64_LO(val), 770 sname, s); 771 } 772 } 773 } 774 break; 775 case 7: 776 /* TeMPmonitor */ 777 { 778 int avg_cur, max_peak,cur,peak; 779 int num_temp_out; 780 int index; 781 bcm_switch_temperature_monitor_t temp_out[20]; 782 783 avg_cur = 0; 784 max_peak = 0x80000000; 785 BCM_IF_ERROR_RETURN(bcm_switch_temperature_monitor_get(unit, 786 20,temp_out,&num_temp_out)); 787 for (index = 0; index < num_temp_out; index++) { 788 cur = temp_out[index].curr; 789 peak = temp_out[index].peak; 790 cli_out("temperature monitor %d: current=%3d.%d, peak=%3d.%d\n", 791 index, 792 cur/10, 793 cur >=0? cur%10:(-cur)%10, /* remove minus sign */ 794 peak/10, 795 peak >=0? peak%10:(-peak)%10); /*remove minus sign */ 796 avg_cur += cur; 797 if (max_peak < peak) { 798 max_peak = peak; 799 } 800 } 801 avg_cur = avg_cur/index; 802 cli_out("average current temperature is %3d.%d\n", 803 avg_cur/10,avg_cur >= 0? avg_cur%10: (-avg_cur)%10); 804 cli_out("maximum peak temperature is %d.%d\n", 805 max_peak/10,max_peak >= 0? max_peak%10: (-max_peak)%10); 806 } 807 break; 808 case 8: /* MaterialProcess */ 809 #ifdef BCM_MONTEREY_SUPPORT 810 if (SOC_IS_MONTEREY(unit)) { 811 (void)soc_monterey_show_material_process(unit);; 812 } else 813 #endif /* BCM_MONTEREY_SUPPORT */ 814 #ifdef BCM_APACHE_SUPPORT 815 if (SOC_IS_APACHE(unit)) { 816 (void)soc_apache_show_material_process(unit);; 817 } else 818 #endif /* BCM_APACHE_SUPPORT */ 819 #ifdef BCM_TRIDENT2_SUPPORT 820 if (SOC_IS_TRIDENT2(unit) || SOC_IS_TITAN2(unit)) { 821 (void)soc_trident2_show_material_process(unit);; 822 } else 823 #endif /* BCM_TRIDENT_SUPPORT */ 824 #ifdef BCM_TRIDENT_SUPPORT 825 if (SOC_IS_TRIDENT(unit) || SOC_IS_TITAN(unit)) { 826 (void)soc_trident_show_material_process(unit); 827 } 828 #endif /* BCM_TRIDENT_SUPPORT */ 829 #ifdef BCM_HURRICANE2_SUPPORT 830 if (SOC_IS_HURRICANE2(unit)) { 831 (void)soc_hu2_show_material_process(unit); 832 } 833 #endif /* BCM_HURRICANE2_SUPPORT */ 834 #ifdef BCM_KATANA2_SUPPORT 835 if (SOC_IS_KATANA2(unit)) { 836 (void)soc_kt2_show_material_process(unit); 837 } 838 #endif /* BCM_KATANA2_SUPPORT */ 839 break; 840 case 9: /* RingOSC */ 841 #ifdef BCM_MONTEREY_SUPPORT 842 if (SOC_IS_MONTEREY(unit)) { 843 (void)soc_monterey_show_ring_osc(unit); 844 } else 845 #endif /* BCM_MONTEREY_SUPPORT */ 846 #ifdef BCM_APACHE_SUPPORT 847 if (SOC_IS_APACHE(unit)) { 848 (void)soc_apache_show_ring_osc(unit); 849 } else 850 #endif /* BCM_APACHE_SUPPORT */ 851 #ifdef BCM_TRIDENT2_SUPPORT 852 if (SOC_IS_TD2_TT2(unit)) { 853 #ifdef BCM_TOMAHAWK_SUPPORT 854 if (SOC_IS_TOMAHAWKX(unit)) { 855 (void)soc_tomahawk_show_ring_osc(unit); 856 } else 857 #endif /* BCM_TOMAHAWK_SUPPORT */ 858 #ifdef BCM_TRIDENT3_SUPPORT 859 if (SOC_IS_TRIDENT3X(unit)) { 860 (void)soc_trident3_show_ring_osc(unit); 861 } else 862 #endif /* BCM_TRIDENT3_SUPPORT */ 863 { 864 (void)soc_trident2_show_ring_osc(unit); 865 } 866 } else 867 #endif /* BCM_TRIDENT_SUPPORT */ 868 #ifdef BCM_TRIDENT_SUPPORT 869 if (SOC_IS_TD_TT(unit)) { 870 (void)soc_trident_show_ring_osc(unit); 871 } 872 #endif /* BCM_TRIDENT_SUPPORT */ 873 #ifdef BCM_KATANA_SUPPORT 874 if (SOC_IS_KATANA(unit)) { 875 (void)soc_katana_show_ring_osc(unit); 876 } 877 #endif /* BCM_KATANA_SUPPORT */ 878 #ifdef BCM_KATANA2_SUPPORT 879 if (SOC_IS_KATANA2(unit)) { 880 (void)soc_kt2_show_ring_osc(unit); 881 } 882 #endif /* BCM_KATANA2_SUPPORT */ 883 #ifdef BCM_HURRICANE2_SUPPORT 884 if (SOC_IS_HURRICANE2(unit)) { 885 (void)soc_hu2_show_ring_osc(unit);; 886 } 887 #endif /* BCM_HURRICANE2_SUPPORT */ 888 break; 889 case 10: /* PortMAP */ 890 if (soc_feature(unit, soc_feature_logical_port_num)) { 891 if (!soc_feature(unit, soc_feature_two_ingress_pipes) && 892 !soc_feature(unit, soc_feature_multi_pipe_mapped_ports)) { 893 cli_out(" pm(pgw) logical " 894 "physical idb lanes speed_max mmu ucq/Numq mcq/Numq\n"); 895 } else { 896 #ifdef BCM_TRIDENT2PLUS_SUPPORT 897 if (SOC_IS_TRIDENT2PLUS(unit)) { 898 ar_idx_array = sal_alloc(sizeof(int) * 2960, 899 "cosq hw index when show counter"); 900 if (NULL == ar_idx_array) { 901 return BCM_E_MEMORY; 902 } 903 port_array = sal_alloc(sizeof(soc_port_t) * 2960, 904 "port array of mmu queues when show counter"); 905 if (NULL == port_array) { 906 sal_free(ar_idx_array); 907 return BCM_E_MEMORY; 908 } 909 cli_out(" pipe logical " 910 "physical mmu ucast_Qbase/Numq mcast_Qbase/Numq" 911 " endpoint_queue/Numq service_queue/Numq\n"); 912 _bcm_td2_cosq_hw_idx_get(unit, 2960, port_array, 913 ar_idx_array, &array_count); 914 } else 915 #endif 916 #ifdef BCM_TOMAHAWK3_SUPPORT 917 if (SOC_IS_TOMAHAWK3(unit)) { 918 cli_out(" pipe logical " 919 "physical MMU(local) MMU(chip) ucast_Qbase/Numq mcast_Qbase/Numq\n"); 920 } else 921 #endif /* BCM_TOMAHAWK3_SUPPORT */ 922 { 923 cli_out(" pipe logical " 924 "physical idb mmu ucast_Qbase/Numq mcast_Qbase/Numq\n"); 925 } 926 } 927 PBMP_ALL_ITER(unit, port) { 928 int phy_port, mmu_port, idb_port, cosq, numq, uc_cosq, uc_numq, pipe; 929 int num_lanes, speed_max, pm, pgw; 930 pipe = SOC_INFO(unit).port_pipe[port]; 931 pm = SOC_INFO(unit).port_serdes[port]; 932 pgw = SOC_INFO(unit).port_group[port]; 933 num_lanes = SOC_INFO(unit).port_num_lanes[port]; 934 speed_max = SOC_INFO(unit).port_speed_max[port]; 935 phy_port = SOC_INFO(unit).port_l2p_mapping[port]; 936 idb_port = SOC_INFO(unit).port_l2i_mapping[port]; 937 mmu_port = SOC_INFO(unit).port_p2m_mapping[phy_port]; 938 cosq = SOC_INFO(unit).port_cosq_base[port]; 939 numq = SOC_INFO(unit).port_num_cosq[port]; 940 uc_cosq = SOC_INFO(unit).port_uc_cosq_base[port]; 941 uc_numq = SOC_INFO(unit).port_num_uc_cosq[port]; 942 #ifdef BCM_TRIDENT2_SUPPORT 943 #ifdef BCM_MONTEREY_SUPPORT 944 if (SOC_IS_MONTEREY(unit)) { 945 cosq = soc_monterey_logical_qnum_hw_qnum(unit, port, cosq, 0); 946 uc_cosq = soc_monterey_logical_qnum_hw_qnum(unit, port, 947 uc_cosq, 1); 948 } else 949 #endif /* BCM_APACHE_SUPPORT */ 950 #ifdef BCM_APACHE_SUPPORT 951 if (SOC_IS_APACHE(unit)) { 952 cosq = soc_apache_logical_qnum_hw_qnum(unit, port, cosq, 0); 953 uc_cosq = soc_apache_logical_qnum_hw_qnum(unit, port, 954 uc_cosq, 1); 955 } else 956 #endif /* BCM_APACHE_SUPPORT */ 957 if (SOC_IS_TD2_TT2(unit) && !SOC_IS_TOMAHAWKX(unit) && !SOC_IS_TRIDENT3X(unit)) { 958 cosq = soc_td2_logical_qnum_hw_qnum(unit, port, cosq, 0); 959 uc_cosq = soc_td2_logical_qnum_hw_qnum(unit, port, uc_cosq, 960 1); 961 } 962 #endif /* BCM_TRIDENT2_SUPPORT */ 963 if (!soc_feature(unit, soc_feature_two_ingress_pipes) && 964 !soc_feature(unit, soc_feature_multi_pipe_mapped_ports)) { 965 cli_out(" %8s %2d(%d) %3d %3d %3d " 966 "%2d %6d %3d %4d/%-4d %4d/%-4d\n", 967 SOC_INFO(unit).port_name[port], (pm < 0 ? 0: pm), 968 (pgw < 0 ? 0 : pgw), port, phy_port, idb_port, 969 num_lanes, speed_max, mmu_port, uc_cosq, uc_numq, 970 cosq, numq); 971 } else { 972 #ifdef BCM_TRIDENT2PLUS_SUPPORT 973 if (SOC_IS_TRIDENT2PLUS(unit)) { 974 cli_out(" %8s %3d %3d %3d " 975 "%3d %4d/%-4d %4d/%-4d", 976 SOC_INFO(unit).port_name[port], pipe, port, 977 phy_port, mmu_port, uc_cosq, uc_numq, cosq, numq); 978 rv = bcm_esw_port_control_get(unit, port, 979 bcmPortControlCustomerQueuing, &queue_mode); 980 if (BCM_FAILURE(rv)) { 981 sal_free(ar_idx_array); 982 sal_free(port_array); 983 return rv; 984 } 985 if (queue_mode == 4 || queue_mode == 3) { 986 if (queue_mode == 4) { 987 cli_out(" "); 988 } else if (queue_mode == 3) { 989 cli_out(" "); 990 } 991 count = 0; 992 for (i = 0; i < array_count; i++) { 993 if (port_array[i] == port) { 994 cli_out("%4d, ", ar_idx_array[i]); 995 count++; 996 } 997 } 998 if (count) { 999 cli_out("/%-4d", count); 1000 } 1001 } 1002 cli_out("\n"); 1003 } else 1004 #endif 1005 #ifdef BCM_TOMAHAWK3_SUPPORT 1006 if (SOC_IS_TOMAHAWK3(unit)) { 1007 mmu_port = SOC_TH3_MMU_CHIP_PORT(unit,port); 1008 cli_out(" %8s %3d %3d %3d %3d " 1009 " %3d %4d/%-4d %4d/%-4d\n", 1010 SOC_INFO(unit).port_name[port], pipe, port, 1011 phy_port, idb_port, mmu_port, uc_cosq, uc_numq, 1012 cosq, numq); 1013 } else 1014 #endif /* BCM_TOMAHAWK3_SUPPORT */ 1015 1016 { 1017 cli_out(" %8s %3d %3d %3d %3d " 1018 "%3d %4d/%-4d %4d/%-4d\n", 1019 SOC_INFO(unit).port_name[port], pipe, port, 1020 phy_port, idb_port, mmu_port, uc_cosq, uc_numq, 1021 cosq, numq); 1022 } 1023 } 1024 } 1025 #ifdef BCM_TRIDENT2PLUS_SUPPORT 1026 if (ar_idx_array != NULL) { 1027 sal_free(ar_idx_array); 1028 } 1029 if (port_array != NULL) { 1030 sal_free(port_array); 1031 } 1032 #endif 1033 } 1034 break; 1035 case 11: /* Ingress Traffic rate */ 1036 if (bcm_port_config_get(unit, &pcfg) != BCM_E_NONE) { 1037 cli_out("%s: Error: bcm ports not initialized\n", ARG_CMD(a)); 1038 return CMD_FAIL; 1039 } 1040 1041 flags = 0; 1042 if (counter_time_val[unit] == NULL) { 1043 1044 counter_time_val[unit] = sal_alloc(SOC_MAX_NUM_PORTS * 1045 sizeof (counter_time_val_t), 1046 "save_ctrs_time_val"); 1047 1048 if (counter_time_val[unit] == NULL) { 1049 cli_out("Failed to allocate the counter_time_val\n"); 1050 return (CMD_FAIL); 1051 } 1052 1053 sal_memset(counter_time_val[unit], 0, 1054 SOC_MAX_NUM_PORTS * 1055 sizeof (counter_time_val_t)); 1056 } 1057 1058 if ((c = ARG_GET(a)) != NULL) { /* Ports specified? */ 1059 if (!sal_strcasecmp(c, "CaptureOff")) { 1060 if (counter_time_val[unit] != NULL) { 1061 sal_free(counter_time_val[unit]); 1062 return (CMD_OK); 1063 } 1064 } else if (0 != parse_bcm_pbmp(unit, c, &bcm_pbmp)) { 1065 cli_out("%s: Invalid ports: %s\n", ARG_CMD(a), c); 1066 return(CMD_FAIL); 1067 } else if (sal_strcasecmp(c, "all") == 0) { 1068 flags = 1; 1069 } 1070 } else { 1071 BCM_PBMP_ASSIGN(bcm_pbmp, pcfg.port); 1072 } 1073 1074 DPORT_BCM_PBMP_ITER(unit, bcm_pbmp, dport, port) { 1075 bcm_stat_val_t s; 1076 char *sname; 1077 bcm_stat_val_t _stat[] = { 1078 snmpIfInUcastPkts, 1079 snmpIfInBroadcastPkts, 1080 snmpIfInMulticastPkts 1081 }; 1082 char *_stat_names[] = BCM_STAT_NAME_INITIALIZER; 1083 int rv; 1084 uint64 val; 1085 uint64 rate; 1086 uint64 tmp; 1087 uint64 ctr_old, ctr_new, ctr_diff; 1088 #if !defined(COMPILER_HAS_LONGLONG) || defined(__KERNEL__) 1089 uint32 ctr_diff32; 1090 uint32 rate32; 1091 #endif 1092 DCLTIME curr_time, diff; 1093 COMPILER_64_ZERO(val); 1094 COMPILER_64_ZERO(rate); 1095 1096 for (s = 0; s < (sizeof(_stat)/sizeof(_stat[0])); s++) { 1097 sname = _stat_names[_stat[s]]; 1098 if (!sname) { 1099 continue; 1100 } 1101 1102 1103 rv = bcm_stat_sync_get(unit, port, _stat[s], &tmp); 1104 1105 if (rv < 0) { 1106 cli_out("%8s\t%s (stat %d): %s\n", 1107 "-", sname, s, bcm_errmsg(rv)); 1108 continue; 1109 } 1110 1111 COMPILER_64_ADD_64(val, tmp); 1112 } 1113 1114 curr_time = GETTIME; 1115 diff = curr_time - counter_time_val[unit][port].prev_time; 1116 COMPILER_64_SET(ctr_new, COMPILER_64_HI(val), COMPILER_64_LO(val)); 1117 ctr_old = counter_time_val[unit][port].val; 1118 COMPILER_64_DELTA(ctr_diff, ctr_old, ctr_new); 1119 1120 1121 #if !defined(COMPILER_HAS_LONGLONG) || defined(__KERNEL__) 1122 COMPILER_64_TO_32_LO(ctr_diff32, ctr_diff); 1123 rate32 = _shr_div_exp10(ctr_diff32, diff, 6); 1124 COMPILER_64_SET(rate, 0, rate32); 1125 #else 1126 rate = ((ctr_diff * 1000000))/diff; 1127 #endif 1128 1129 counter_time_val[unit][port].prev_time = curr_time; 1130 counter_time_val[unit][port].val = val; 1131 1132 if (flags == 0 && COMPILER_64_IS_ZERO(rate)) { 1133 continue; 1134 } 1135 1136 sal_memset(buf_val, 0, sizeof(buf_val)); 1137 format_uint64_decimal(buf_val, rate, commachr); 1138 cli_out("Ingress traffic Rate[%s] = %s pkts/sec\n", 1139 BCM_PORT_NAME(unit, port), buf_val); 1140 1141 } 1142 break; 1143 case 12: /* Voltages */ 1144 #ifdef BCM_SABER2_SUPPORT 1145 if (SOC_IS_SABER2(unit)) { 1146 (void)soc_sb2_show_voltage(unit); 1147 } else 1148 #endif /* BCM_SABER2_SUPPORT */ 1149 #ifdef BCM_KATANA2_SUPPORT 1150 if (SOC_IS_KATANA2(unit)) { 1151 (void)soc_kt2_show_voltage(unit); 1152 } 1153 #endif /* BCM_KATANA2_SUPPORT */ 1154 #ifdef BCM_TRIDENT2PLUS_SUPPORT 1155 if (SOC_IS_TD2P_TT2P(unit)) { 1156 SOC_IF_ERROR_RETURN(soc_td2p_show_voltage(unit)); 1157 } 1158 #endif /* BCM_TRIDENT2PLUS_SUPPORT */ 1159 #ifdef BCM_MONTEREY_SUPPORT 1160 if (SOC_IS_MONTEREY(unit)) { 1161 SOC_IF_ERROR_RETURN(soc_monterey_show_voltage(unit)); 1162 } 1163 #endif /* BCM_APACHE_SUPPORT */ 1164 #ifdef BCM_APACHE_SUPPORT 1165 if (SOC_IS_APACHE(unit)) { 1166 SOC_IF_ERROR_RETURN(soc_apache_show_voltage(unit)); 1167 } 1168 #endif /* BCM_APACHE_SUPPORT */ 1169 #ifdef BCM_TOMAHAWK_SUPPORT 1170 if (SOC_IS_TOMAHAWKX(unit)) { 1171 SOC_IF_ERROR_RETURN(soc_tomahawk_show_voltage(unit)); 1172 } 1173 #endif /* BCM_TOMAHAWK_SUPPORT */ 1174 #ifdef BCM_HELIX5_SUPPORT 1175 if (SOC_IS_HELIX5(unit)) { 1176 SOC_IF_ERROR_RETURN(soc_helix5_show_voltage(unit)); 1177 } 1178 #endif /* BCM_HELIX5_SUPPORT */ 1179 1180 break; 1181 case 13: 1182 #ifdef BCM_KATANA2_SUPPORT 1183 if ((soc_feature(unit, soc_feature_linkphy_coe) && 1184 SOC_INFO(unit).linkphy_enabled)) { 1185 int sid = -1; 1186 uint32 flag = 0; 1187 if ((c = ARG_GET(a)) != NULL) { 1188 if (!sal_strcasecmp(c, "StreamID")) { 1189 flag = 1; 1190 sid = ((c = ARG_GET(a)) != NULL) ? parse_integer(c) : -1; 1191 } else { 1192 cli_out("Invalid argument\n"); 1193 return(CMD_FAIL); 1194 } 1195 } 1196 rv = bcm_kt2_subport_port_stat_show(unit, flag, sid); 1197 if(SOC_FAILURE(rv)) { 1198 if (rv == BCM_E_INIT) { 1199 cli_out("LinkPHY counter is not initialized\n"); 1200 } 1201 return(CMD_FAIL); 1202 } 1203 } 1204 #endif /* BCM_KATANA2_SUPPORT */ 1205 break; 1206 default: 1207 return(CMD_FAIL); 1208 } 1209 1210 return(CMD_OK); 1211 } 1212 1213 /* 1214 * Clear something for a user. 1215 */ 1216 1217 cmd_result_t 1218 cmd_esw_clear(int unit, args_t *a) 1219 { 1220 char *parm = ARG_GET(a); 1221 soc_mem_t mem; 1222 soc_pbmp_t pbmp; 1223 bcm_pbmp_t bcm_pbmp; 1224 int force_all = 0; 1225 int r, copyno; 1226 bcm_port_config_t pcfg; 1227 int flags; 1228 char *c; 1229 soc_port_t port, dport; 1230 int rv = CMD_OK; 1231 1232 if (!sh_check_attached(ARG_CMD(a), unit)) { 1233 return CMD_FAIL; 1234 } 1235 1236 if (!parm) { 1237 return CMD_USAGE; 1238 } 1239 1240 if (!sal_strcasecmp(parm, "all")) { 1241 force_all = 1; 1242 parm = ARG_GET(a); 1243 } 1244 1245 if (!parm) { 1246 return CMD_USAGE; 1247 } 1248 1249 1250 if (!sal_strcasecmp(parm, "counters") || 1251 !sal_strcasecmp(parm, "c")) { 1252 uint64 val; 1253 1254 if ((parm = ARG_GET(a)) == NULL) { 1255 if (soc_feature(unit, soc_feature_cpuport_stat_dma)) { 1256 SOC_PBMP_ASSIGN(pbmp, PBMP_ALL(unit)); 1257 if ((soc_feature(unit, soc_feature_linkphy_coe) && 1258 SOC_INFO(unit).linkphy_enabled) || 1259 (soc_feature(unit, soc_feature_subtag_coe) && 1260 SOC_INFO(unit).subtag_enabled)) { 1261 SOC_PBMP_CLEAR(pbmp); 1262 SOC_PBMP_ASSIGN(pbmp, PBMP_PORT_ALL(unit)); 1263 SOC_PBMP_PORT_ADD(pbmp, CMIC_PORT(unit)); 1264 SOC_PBMP_PORT_ADD(pbmp, LB_PORT(unit)); 1265 } 1266 1267 } else { 1268 SOC_PBMP_ASSIGN(pbmp, PBMP_PORT_ALL(unit)); 1269 } 1270 } else if (parse_pbmp(unit, parm, &pbmp) < 0) { 1271 cli_out("%s: Invalid port bitmap: %s\n", ARG_CMD(a), parm); 1272 return CMD_FAIL; 1273 } 1274 /* Remove the lb ports from the bitmap */ 1275 if (soc_feature(unit, soc_feature_internal_loopback)) { 1276 SOC_PBMP_REMOVE(pbmp, PBMP_LB(unit)); 1277 } 1278 1279 if ((r = soc_counter_set32_by_port(unit, pbmp, 0)) < 0) { 1280 cli_out("ERROR: Clear counters failed: %s\n", soc_errmsg(r)); 1281 return CMD_FAIL; 1282 } 1283 1284 /* 1285 * Clear the diagnostics' copy of the counters so 'show 1286 * counters' knows they're clear. 1287 */ 1288 1289 COMPILER_64_ZERO(val); 1290 1291 counter_val_set_by_port(unit, pbmp, val); 1292 return CMD_OK; 1293 } 1294 1295 if (!sal_strcasecmp(parm, "stats")) { 1296 int rv = CMD_OK; 1297 soc_port_t port, dport; 1298 bcm_pbmp_t bcm_pbmp; 1299 bcm_port_config_t pcfg; 1300 1301 if (bcm_port_config_get(unit, &pcfg) != BCM_E_NONE) { 1302 cli_out("%s: Error: bcm ports not initialized\n", ARG_CMD(a)); 1303 return CMD_FAIL; 1304 } 1305 1306 if ((parm = ARG_GET(a)) == NULL) { 1307 if (soc_feature(unit, soc_feature_cpuport_stat_dma)) { 1308 SOC_PBMP_ASSIGN(pbmp, pcfg.all); 1309 } else { 1310 SOC_PBMP_ASSIGN(pbmp, pcfg.port); 1311 } 1312 } else if (parse_bcm_pbmp(unit, parm, &bcm_pbmp) < 0) { 1313 cli_out("%s: Invalid port bitmap: %s\n", ARG_CMD(a), parm); 1314 return CMD_FAIL; 1315 } 1316 1317 /* coverity[uninit_use : FALSE] */ 1318 DPORT_BCM_PBMP_ITER(unit, bcm_pbmp, dport, port) { 1319 int rv; 1320 1321 if ((rv = bcm_stat_clear(unit, port)) != BCM_E_NONE) { 1322 cli_out("%s: Unit %d Port %d failed to clear stats: %s\n", 1323 ARG_CMD(a), unit, port, bcm_errmsg(rv)); 1324 rv = CMD_FAIL; 1325 } 1326 } 1327 return(rv); 1328 } 1329 1330 if (!sal_strcasecmp(parm, "snmpstats")) { 1331 if (bcm_port_config_get(unit, &pcfg) != BCM_E_NONE) { 1332 cli_out("%s: Error: bcm ports not initialized\n", ARG_CMD(a)); 1333 return CMD_FAIL; 1334 } 1335 1336 flags = 0; 1337 if ((c = ARG_GET(a)) != NULL) { /* Ports specified? */ 1338 if (0 != parse_bcm_pbmp(unit, c, &bcm_pbmp)) { 1339 cli_out("%s: Invalid ports: %s\n", ARG_CMD(a), c); 1340 return(CMD_FAIL); 1341 } 1342 if ((c = ARG_GET(a)) != NULL && sal_strcasecmp(c, "all") == 0) { 1343 flags = 1; 1344 } 1345 } else { 1346 BCM_PBMP_ASSIGN(bcm_pbmp, pcfg.port); 1347 } 1348 1349 DPORT_BCM_PBMP_ITER(unit, bcm_pbmp, dport, port) { 1350 bcm_stat_val_t s; 1351 char *sname; 1352 char *_stat_names[] = BCM_STAT_NAME_INITIALIZER; 1353 1354 cli_out("%s: Statistics for Unit %d port %s\n", 1355 ARG_CMD(a), unit, BCM_PORT_NAME(unit, port)); 1356 1357 for (s = 0; s < snmpValCount; s++) { 1358 sname = _stat_names[s]; 1359 if (!sname) { 1360 continue; 1361 } 1362 1363 rv = bcm_stat_clear_single(unit, port, s); 1364 1365 if (rv < 0) { 1366 cli_out("%8s\t%s (stat %d): %s\n", 1367 "-", sname, s, bcm_errmsg(rv)); 1368 continue; 1369 } 1370 1371 if (flags == 0) { 1372 continue; 1373 } 1374 1375 } 1376 } 1377 return(rv); 1378 } 1379 1380 if (!sal_strcasecmp(parm, "dev")) { 1381 int rv; 1382 rv = bcm_clear(unit); 1383 if (rv < 0) { 1384 cli_out("%s ERROR: Unit %d. bcm_clear returned %d: %s\n", 1385 ARG_CMD(a), unit, rv, bcm_errmsg(rv)); 1386 return CMD_FAIL; 1387 } 1388 return CMD_OK; 1389 } 1390 1391 if (!sal_strcasecmp(parm, "sa") || !sal_strcasecmp(parm, "sarl")) { 1392 if (SOC_CONTROL(unit)->arlShadow != NULL) { 1393 sal_mutex_take(SOC_CONTROL(unit)->arlShadowMutex, 1394 sal_mutex_FOREVER); 1395 shr_avl_delete_all(SOC_CONTROL(unit)->arlShadow); 1396 sal_mutex_give(SOC_CONTROL(unit)->arlShadowMutex); 1397 } 1398 return CMD_OK; 1399 } 1400 1401 do { 1402 if (parse_memory_name(unit, &mem, parm, ©no, 0) < 0) { 1403 cli_out("ERROR: unknown table \"%s\"\n", parm); 1404 return CMD_FAIL; 1405 } 1406 1407 if ((r = soc_mem_clear(unit, mem, copyno, force_all)) < 0) { 1408 cli_out("ERROR: clear table %s failed: %s\n", 1409 SOC_MEM_UFNAME(unit, mem), soc_errmsg(r)); 1410 return CMD_FAIL; 1411 } 1412 } while ((parm = ARG_GET(a)) != NULL); 1413 1414 return CMD_OK; 1415 } 1416 1417 /* 1418 * Check something for a user. 1419 */ 1420 1421 char check_usage[] = 1422 "Parameters: check [SYNC] <TABLE>\n\t" 1423 "Verifies consistency of a memory table (sorted tables only).\n\t" 1424 "If the SYNC flag is used, checks that all copies are equal.\n"; 1425 1426 cmd_result_t 1427 cmd_check(int unit, args_t *a) 1428 { 1429 char *parm = ARG_GET(a); 1430 soc_mem_t mem; 1431 int blk, copyno; 1432 char *ufname; 1433 int index, min, max, entries, entry_bytes; 1434 uint32 previous[SOC_MAX_MEM_WORDS], current[SOC_MAX_MEM_WORDS]; 1435 uint32 *entry_null; 1436 int r, rv = CMD_OK; 1437 int sync = 0; 1438 int port_counts[SOC_MAX_NUM_PORTS]; 1439 int iters, blkfirst; 1440 1441 if (!sh_check_attached(ARG_CMD(a), unit)) 1442 return CMD_FAIL; 1443 1444 if (parm != NULL && sal_strcasecmp(parm, "sync") == 0) { 1445 sync = 1; 1446 parm = ARG_GET(a); 1447 } 1448 1449 if (parm == NULL) { 1450 return CMD_USAGE; 1451 } 1452 1453 if (parse_memory_name(unit, &mem, parm, ©no, 0) < 0) { 1454 cli_out("ERROR: unknown table \"%s\"\n", parm); 1455 return CMD_FAIL; 1456 } 1457 1458 ufname = SOC_MEM_UFNAME(unit, mem); 1459 min = soc_mem_index_min(unit, mem); 1460 max = soc_mem_index_max(unit, mem); 1461 entry_bytes = 4 * soc_mem_entry_words(unit, mem); 1462 entry_null = soc_mem_entry_null(unit, mem); 1463 1464 if (!soc_mem_is_sorted(unit, mem)) { 1465 goto skip_sort_check; 1466 } 1467 1468 sal_memset(port_counts, 0, sizeof(port_counts)); 1469 1470 iters = 0; 1471 SOC_MEM_BLOCK_ITER(unit, mem, blk) { 1472 if (copyno != COPYNO_ALL && copyno != blk) { 1473 continue; 1474 } 1475 iters += 1; 1476 entries = soc_mem_entries(unit, mem, blk); 1477 1478 for (index = min; index <= max; index++) { 1479 if ((r = soc_mem_read(unit, mem, blk, index, current)) < 0) { 1480 cli_out("ERROR: failed reading %s.%s[%d]: %s\n", 1481 ufname, SOC_BLOCK_NAME(unit, blk), 1482 index, soc_errmsg(r)); 1483 return CMD_FAIL; 1484 } 1485 1486 if (sal_memcmp(current, entry_null, entry_bytes) == 0) 1487 break; /* Found null key */ 1488 1489 if (index > min && 1490 soc_mem_compare_key(unit, mem, current, previous) <= 0) { 1491 cli_out("ERROR: non-increasing key at %s.%s[%d]\n", 1492 ufname, SOC_BLOCK_NAME(unit, blk), index); 1493 rv = CMD_FAIL; 1494 } 1495 1496 sal_memcpy(previous, current, entry_bytes); 1497 } 1498 1499 /* Make sure entry count matches number of entries found */ 1500 1501 if (index != min + entries) { 1502 cli_out("ERROR: last non-null key was found at %s.%s[%d]\n", 1503 ufname, SOC_BLOCK_NAME(unit, blk), index - 1); 1504 cli_out("ERROR: but was expected to be at %s.%s[%d]\n", 1505 ufname, SOC_BLOCK_NAME(unit, blk), min + entries); 1506 cli_out("ERROR: based on a table entry count of %d\n", 1507 entries); 1508 rv = CMD_FAIL; 1509 } 1510 1511 /* Make sure remaining entries in table are null */ 1512 1513 for (; index <= max; index++) { 1514 if ((r = soc_mem_read(unit, mem, blk, index, current)) < 0) { 1515 cli_out("ERROR: failed reading %s.%s[%d]: %s\n", 1516 ufname, SOC_BLOCK_NAME(unit, blk), 1517 index, soc_errmsg(r)); 1518 return CMD_FAIL; 1519 } 1520 1521 if (sal_memcmp(current, entry_null, entry_bytes) != 0) { 1522 cli_out("ERROR: entry at %s.%s[%d] should contain null key\n", 1523 ufname, SOC_BLOCK_NAME(unit, blk), index); 1524 rv = CMD_FAIL; 1525 } 1526 } 1527 } 1528 1529 /* 1530 * Optionally check that all copies of a table have identical contents. 1531 */ 1532 1533 skip_sort_check: 1534 1535 if (sync) { 1536 for (index = min; index <= max; index++) { 1537 iters = 0; 1538 blkfirst = 0; 1539 SOC_MEM_BLOCK_ITER(unit, mem, blk) { 1540 if (copyno != COPYNO_ALL && copyno != blk) { 1541 continue; 1542 } 1543 if (++iters == 1) { 1544 blkfirst = blk; 1545 } 1546 if ((r = soc_mem_read(unit, mem, blk, index, 1547 iters == 1 ? previous : current) < 0)) { 1548 cli_out("ERROR: failed reading %s.%s[%d]: %s\n", 1549 ufname, SOC_BLOCK_NAME(unit, blk), 1550 index, soc_errmsg(r)); 1551 return CMD_FAIL; 1552 } 1553 1554 if (iters > 1) { 1555 if (sal_memcmp(current, previous, entry_bytes) != 0) { 1556 cli_out("ERROR: %s.%s[%d] does not match %s.%s[%d]\n", 1557 ufname, SOC_BLOCK_NAME(unit, blk), index, 1558 ufname, SOC_BLOCK_NAME(unit, blkfirst), index); 1559 rv = CMD_FAIL; 1560 } 1561 } 1562 } 1563 } 1564 } 1565 1566 return rv; 1567 } 1568 1569 1570 #if defined(BCM_KATANA2_SUPPORT) 1571 /* 1572 * data structure to store the hw linkphy information 1573 */ 1574 typedef struct linkphy_info_s { 1575 int port; 1576 int ppp; 1577 uint32 ext_stream_id; /* external stream id ingressing a port */ 1578 uint32 adj_ext_stream_id; /* base adjusted port external stream Id */ 1579 uint16 blk_int_stream_id; /* block internal stream id range 0 - 127 */ 1580 uint16 dev_int_stream_id; /* device internal stream id range 0 - 255 */ 1581 uint32 rxlp_stream_active; 1582 uint32 txlp_ext_stream_id; 1583 uint32 txlp_stream_active; 1584 }linkphy_info_t; 1585 1586 /* 1587 * Function: _linkphy_print_header 1588 * Purpose: Print header string for output. 1589 * Parameters: None. 1590 * Returns: Nothing 1591 */ 1592 void 1593 _linkphy_print_header(void) 1594 { 1595 cli_out("+----+---+-----+-----+-----+-----+-----+-----+-----+\n"); 1596 cli_out("| | |Rxlp |Port |Blk |Dev |Rxlp |Txlp |Txlp |\n"); 1597 cli_out("| | |Ext |Ext |Int |Int |Actv |Ext |Actv |\n"); 1598 cli_out("|port|ppp|StrId|StrId|StrId|StrId|StrId|StrId|StrId|\n"); 1599 cli_out("+----+---+-----+-----+-----+-----+-----+-----+-----+\n"); 1600 } 1601 1602 /* 1603 * Function: _linkphy_print_seperator 1604 * Purpose: Print header string for output. 1605 * Parameters: None. 1606 * Returns: Nothing 1607 */ 1608 void 1609 _linkphy_print_separator(void) 1610 { 1611 cli_out("+----+---+-----+-----+-----+-----+-----+-----+-----+\n"); 1612 } 1613 1614 /* 1615 * Function: _linkphy_print_summary 1616 * Purpose: Print summary values 1617 * Parameters: Summary values 1618 * Returns: Nothing 1619 */ 1620 void 1621 _linkphy_print_summary(int unit, linkphy_info_t info) 1622 { 1623 cli_out("|%4d|%3d|%5d|%5d|%5d|%5d|%5d|%5d|%5d|\n", 1624 info.port, info.ppp, info.ext_stream_id, 1625 info.adj_ext_stream_id, info.blk_int_stream_id, 1626 info.dev_int_stream_id, info.rxlp_stream_active, 1627 info.txlp_ext_stream_id, info.txlp_stream_active); 1628 } 1629 1630 /* 1631 * Function: do_show_linkphy_config 1632 * Purpose: retrieves all the hardware information 1633 * each linkphy port. 1634 * Parameters: Summary values 1635 * Returns: Failure/Success 1636 */ 1637 cmd_result_t 1638 do_show_linkphy_config(int unit) 1639 { 1640 int port = -1, ppp = -1, rv = BCM_E_NONE; 1641 int lp_block = 0, lp_index = 0, copyno = 0; 1642 int idx_min = 0, idx_max = 0, idx = 0; 1643 int reg_hi, stream_bit = 0; 1644 soc_mem_t mem, port_mem; 1645 soc_reg_t reg = INVALIDr; 1646 uint32 regval = 0, valid = 0; 1647 uint64 rval64, data; 1648 int field_word = 0, bit_pos = 0; 1649 soc_info_t *si = &SOC_INFO(unit); 1650 uint32 fldbuf[4] = { 0 }; 1651 rxlp_internal_stream_map_port_0_entry_t rxlp_int_stream_map_port; 1652 txlp_port_stream_bitmap_table_entry_t txlp_port_stream_bitmap; 1653 txlp_int2ext_stream_map_table_entry_t txlp_int2ext_stream_map; 1654 device_stream_id_to_pp_port_map_entry_t dev_sid_to_pp_entry; 1655 uint16 blk_int_stream_id = 0, dev_int_stream_id = 0; 1656 uint32 port_ext_stream_id_base = 0, adj_ext_stream_id = 0; 1657 uint32 ext_stream_id = 0, txlp_ext_stream_id = 0; 1658 uint32 int_stream_id_base = 0; 1659 uint32 rxlp_stream_active = 0, txlp_stream_active = 0; 1660 linkphy_info_t info; 1661 1662 /* check if LinkPhy is enabled on any port */ 1663 if (BCM_PBMP_IS_NULL(si->linkphy_pbm)) { 1664 cli_out("Linkphy is not enabled on any port\n"); 1665 return CMD_FAIL; 1666 } 1667 1668 sal_memset(&info, 0, sizeof(linkphy_info_t)); 1669 1670 _linkphy_print_header(); 1671 BCM_PBMP_ITER(si->linkphy_pbm, port) { 1672 1673 /* get the block and index for the LinkPHY memory */ 1674 rv = soc_kt2_linkphy_port_blk_idx_get(unit, port, &lp_block, &lp_index); 1675 if (rv < 0) { 1676 cli_out("LinkPHY block, index get failed for port %d\n", port); 1677 return CMD_FAIL; 1678 } 1679 1680 /* 1681 * read RXLP internal stream map table for external to block internal 1682 * stream id. 1683 */ 1684 1685 port_mem = RXLP_INTERNAL_STREAM_MAP_PORT_0m; 1686 1687 if (!SOC_MEM_FIELD_VALID(unit, port_mem, INTERNAL_STREAM_IDf)) { 1688 continue; 1689 } 1690 sal_memset(&rxlp_int_stream_map_port, 0, 1691 sizeof(rxlp_internal_stream_map_port_0_entry_t)); 1692 1693 /* 1694 * Internal stream id = 1695 * RXLP_INTERNAL_STREAM_MAP_PORTn.rxlp0/1 [Internal Stream ID]; 1696 */ 1697 switch (lp_index) { 1698 case 0: 1699 port_mem = RXLP_INTERNAL_STREAM_MAP_PORT_0m; 1700 break; 1701 case 1: 1702 port_mem = RXLP_INTERNAL_STREAM_MAP_PORT_1m; 1703 break; 1704 case 2: 1705 port_mem = RXLP_INTERNAL_STREAM_MAP_PORT_2m; 1706 break; 1707 case 3: 1708 port_mem = RXLP_INTERNAL_STREAM_MAP_PORT_3m; 1709 break; 1710 default: 1711 return CMD_FAIL; 1712 }; 1713 1714 idx_min = soc_mem_index_min(unit, port_mem); 1715 idx_max = soc_mem_index_max(unit, port_mem); 1716 1717 for (idx = idx_min; idx <= idx_max; idx++) { 1718 1719 copyno = SOC_MEM_BLOCK_ANY(unit, port_mem) + lp_block; 1720 SOC_IF_ERROR_RETURN(soc_mem_read(unit, port_mem, copyno, idx, 1721 &rxlp_int_stream_map_port)); 1722 valid = soc_mem_field32_get(unit, port_mem, 1723 (uint32 *)&rxlp_int_stream_map_port, VALIDf); 1724 if (!valid) { 1725 continue; 1726 } 1727 1728 blk_int_stream_id = soc_mem_field32_get(unit, port_mem, 1729 (uint32 *)&rxlp_int_stream_map_port, INTERNAL_STREAM_IDf); 1730 adj_ext_stream_id = idx; 1731 reg = RXLP_PORT_STREAM_ID_BASEr; 1732 if (SOC_REG_PORT_VALID(unit, reg, port)) { 1733 SOC_IF_ERROR_RETURN( 1734 READ_RXLP_PORT_STREAM_ID_BASEr(unit, port, ®val)); 1735 port_ext_stream_id_base = soc_reg_field_get(unit, reg, 1736 regval, BASEf); 1737 } 1738 ext_stream_id = adj_ext_stream_id + port_ext_stream_id_base; 1739 1740 reg = RXLP_INT_STREAM_ID_BASEr; 1741 if (SOC_REG_PORT_VALID(unit, reg, port)) { 1742 SOC_IF_ERROR_RETURN( 1743 READ_RXLP_INT_STREAM_ID_BASEr(unit, port, ®val)); 1744 int_stream_id_base = soc_reg_field_get(unit, reg, 1745 regval, BASEf); 1746 } 1747 dev_int_stream_id = blk_int_stream_id + int_stream_id_base; 1748 1749 reg_hi = (int ) (blk_int_stream_id / 64); 1750 stream_bit = (int ) blk_int_stream_id % 64; 1751 1752 reg = (reg_hi) ? RXLP_PORT_ACTIVE_STREAM_BITMAP_HIr : 1753 RXLP_PORT_ACTIVE_STREAM_BITMAP_LOr; 1754 if (SOC_REG_PORT_VALID(unit, reg, port)) { 1755 SOC_IF_ERROR_RETURN(soc_reg_get(unit, reg, port, 0, &rval64)); 1756 data = soc_reg64_field_get(unit, reg, 1757 rval64, ACTIVE_STREAM_BITMAPf); 1758 if (COMPILER_64_BITTEST(data, stream_bit)) { 1759 rxlp_stream_active = 1; 1760 } 1761 } 1762 1763 mem = TXLP_PORT_STREAM_BITMAP_TABLEm; 1764 if (SOC_MEM_FIELD_VALID(unit, mem, STREAM_BITMAPf)) { 1765 1766 copyno = SOC_MEM_BLOCK_ANY(unit, mem) + lp_block; 1767 SOC_IF_ERROR_RETURN(soc_mem_read(unit, mem, copyno, lp_index, 1768 &txlp_port_stream_bitmap)); 1769 soc_mem_field_get(unit, mem, (uint32 *)&txlp_port_stream_bitmap, 1770 STREAM_BITMAPf, fldbuf); 1771 1772 field_word = blk_int_stream_id / 32; 1773 bit_pos = blk_int_stream_id % 32; 1774 if (fldbuf[field_word] & (1 << bit_pos)) { 1775 txlp_stream_active = 1; 1776 } 1777 } 1778 mem = TXLP_INT2EXT_STREAM_MAP_TABLEm; 1779 /* get the block and index for the LinkPHY memory */ 1780 sal_memset(&txlp_int2ext_stream_map, 0, 1781 sizeof(txlp_int2ext_stream_map_table_entry_t)); 1782 copyno = SOC_MEM_BLOCK_ANY(unit, mem) + lp_block; 1783 (void) soc_mem_read(unit, mem, copyno, blk_int_stream_id, 1784 &txlp_int2ext_stream_map); 1785 valid = soc_mem_field32_get(unit, mem, 1786 (uint32 *)&txlp_int2ext_stream_map, 1787 VALIDf); 1788 if (valid) { 1789 txlp_ext_stream_id = soc_mem_field32_get(unit, mem, 1790 (uint32 *)&txlp_int2ext_stream_map, 1791 EXTERNAL_SIDf); 1792 } 1793 1794 /* get the pp_port from dev stream id */ 1795 mem = DEVICE_STREAM_ID_TO_PP_PORT_MAPm; 1796 sal_memset(&dev_sid_to_pp_entry, 0, 1797 sizeof(dev_sid_to_pp_entry)); 1798 copyno = SOC_MEM_BLOCK_ANY(unit, mem); 1799 (void) soc_mem_read(unit, mem, copyno, dev_int_stream_id, 1800 &dev_sid_to_pp_entry); 1801 ppp = soc_mem_field32_get(unit, mem, 1802 (uint32 *)&dev_sid_to_pp_entry, 1803 PP_PORTf); 1804 info.port = port; 1805 info.ppp = ppp; 1806 info.ext_stream_id = ext_stream_id; 1807 info.adj_ext_stream_id = adj_ext_stream_id; 1808 info.blk_int_stream_id = blk_int_stream_id; 1809 info.dev_int_stream_id = dev_int_stream_id; 1810 info.rxlp_stream_active = rxlp_stream_active; 1811 info.txlp_ext_stream_id = txlp_ext_stream_id; 1812 info.txlp_stream_active = txlp_stream_active; 1813 1814 _linkphy_print_summary(unit, info); 1815 } /* for */ 1816 _linkphy_print_separator(); 1817 } 1818 _linkphy_print_separator(); 1819 1820 return CMD_OK; 1821 } 1822 #endif /* BCM_KATANA2_SUPPORT */ 1823