stat_ge.c (53529B)
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 8 #include <soc/drv.h> 9 #include <soc/counter.h> 10 #include <soc/debug.h> 11 #include <shared/bsl.h> 12 #include <bcm/stat.h> 13 #include <bcm/error.h> 14 15 #include <bcm_int/esw/stat.h> 16 17 #include <bcm_int/esw_dispatch.h> 18 19 /* 20 * Function: 21 * _bcm_stat_ge_get_set 22 * Description: 23 * Get the specified statistic for a GE port in 1000 Mb mode on the 24 * StrataSwitch family of devices. 25 * Parameters: 26 * unit - StrataSwitch PCI device unit number (driver internal). 27 * port - zero-based port number 28 * sync_mode - if 1 read hw counter else sw accumualated counter 29 * type - SNMP statistics type (see bcm/stat.h) 30 * val - (OUT) 64 bit statistic counter value 31 * Returns: 32 * BCM_E_NONE - Success. 33 * BCM_E_PARAM - Illegal parameter. 34 * BCM_E_INTERNAL - Chip access failure. 35 */ 36 int 37 _bcm_stat_ge_get_set(int unit, bcm_port_t port, 38 int sync_mode, int stat_op, 39 bcm_stat_val_t type, uint64 *val, 40 int incl_non_ge_stat) 41 { 42 uint64 count, count1; 43 int reg_op = (stat_op == _BCM_STAT_GET)? _BCM_STAT_REG_ADD: 44 _BCM_STAT_REG_CLEAR; 45 int reg_sub_op = (stat_op == _BCM_STAT_GET)? _BCM_STAT_REG_SUB: 46 _BCM_STAT_REG_CLEAR; 47 48 #ifdef BCM_TOMAHAWK_SUPPORT 49 soc_ctr_control_info_t ctrl_info; 50 ctrl_info.instance = -1; 51 #endif /* BCM_TOMAHAWK_SUPPORT */ 52 53 COMPILER_REFERENCE(&count); /* Work around PPC compiler bug */ 54 COMPILER_REFERENCE(&count1); 55 COMPILER_64_ZERO(count); 56 COMPILER_64_ZERO(count1); 57 58 switch (type) { 59 /* *** RFC 1213 *** */ 60 61 case snmpIfInOctets: 62 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GRBYTr, &count); /* bytes rcvd */ 63 if (SOC_REG_IS_VALID(unit, GRRBYTr)) { 64 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 65 GRRBYTr, &count); /* Runt bytes */ 66 } else { 67 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 68 RRBYTr, &count); /* Runt bytes */ 69 } 70 break; 71 case snmpIfInUcastPkts: /* Unicast packets received */ 72 if (soc_feature(unit, soc_feature_hw_stats_calc)) { 73 if (SOC_REG_IS_VALID(unit, GRUCr) 74 && !((SOC_IS_RAPTOR(unit) || SOC_IS_RAVEN(unit)) 75 && SOC_IS_STACK_PORT(unit, port))) { 76 if (COUNT_OVR_ERRORS(unit)) { 77 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GRUCr, &count); 78 } else { 79 if (incl_non_ge_stat && SOC_REG_IS_VALID(unit, RUC_64r)) { 80 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RUC_64r, 81 &count); /* unicast pkts rcvd */ 82 } else { 83 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GRUCr, &count); 84 BCM_STAT_REG_OPER(unit, port, 85 sync_mode, reg_op, 86 GROVRr, &count); /* + oversize, good FCS */ 87 } 88 } 89 } else { 90 if (incl_non_ge_stat) { 91 /* RUC switch register has the count of all received packets, 92 * add the count when incl_non_ge_stat flag is set. 93 */ 94 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RUCr, 95 &count); /* unicast pkts rcvd */ 96 } 97 } 98 } else { 99 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 100 GRPKTr, &count); /* all pkts rcvd */ 101 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, 102 GRMCAr, &count); /* - multicast */ 103 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, 104 GRBCAr, &count); /* - broadcast */ 105 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, 106 GRALNr, &count); /* - bad FCS, dribble bit */ 107 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, 108 GRFCSr, &count); /* - bad FCS, no dribble bit */ 109 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, 110 GRJBRr, &count); /* - oversize, bad FCS */ 111 if (SOC_REG_IS_VALID(unit, GRMTUEr)) { 112 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, GRMTUEr, 113 &count); /* - mtu exceeded, good FCS */ 114 } 115 if (SOC_REG_IS_VALID(unit, GRFLRr)) { 116 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, 117 GRFLRr, &count); /* - good FCS, bad length */ 118 } 119 if (SOC_REG_IS_VALID(unit, GRXCFr)) { 120 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, 121 GRXCFr, &count); /* - good FCS, all MAC ctrl */ 122 } 123 124 if ((SOC_REG_IS_VALID(unit, GROVRr)) && 125 (COUNT_OVR_ERRORS(unit))) { 126 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, GROVRr, 127 &count); /* - oversize, good FCS */ 128 } 129 } 130 break; 131 case snmpIfInNUcastPkts: /* Non Unicast packets received */ 132 if (COUNT_OVR_ERRORS(unit)) { 133 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 134 GRMCAr, &count); /* multicast */ 135 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 136 GRBCAr, &count); /* broadcast */ 137 } else { 138 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 139 GRUCr, &count); /* unicast excl */ 140 /* oversize */ 141 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 142 GRMCAr, &count); /* multicast */ 143 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 144 GRBCAr, &count); /* broadcast */ 145 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 146 GROVRr, &count); /* oversize */ 147 if (SOC_REG_IS_VALID(unit, RUC_64r)) { 148 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, RUC_64r, &count); /* - unicast */ 149 } else { 150 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, RUCr, &count); /* - unicast */ 151 } 152 } 153 break; 154 case snmpIfInBroadcastPkts: /* Broadcast packets received */ 155 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 156 GRBCAr, &count); /* broadcast pkts rcvd */ 157 break; 158 case snmpIfInMulticastPkts: /* Multicast packets received */ 159 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 160 GRMCAr, &count); /* multicast pkts rcvd */ 161 break; 162 case snmpIfInDiscards: /* Dropped packets including aborted */ 163 if (soc_feature(unit, soc_feature_stat_xgs3)) { 164 if (incl_non_ge_stat) { 165 if (SOC_REG_IS_VALID(unit, RDBGC0_64r)) { 166 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 167 RDBGC0_64r, &count); 168 } else { 169 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 170 RDBGC0r, &count); /* Ingress drop conditions */ 171 } 172 BCM_IF_ERROR_RETURN 173 (_bcm_stat_counter_non_dma_extra_get(unit, 174 SOC_COUNTER_NON_DMA_PORT_DROP_PKT_ING, 175 port, &count1)); 176 COMPILER_64_ADD_64(count, count1); 177 } 178 } 179 break; 180 case snmpIfInErrors: /* Receive packets containing errors */ 181 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 182 GRUNDr, &count); /* undersize pkts, good FCS */ 183 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 184 GRFRGr, &count); /* undersize pkts, bad FCS */ 185 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 186 GRFCSr, &count); /* FCS errors */ 187 if (SOC_REG_IS_VALID(unit, GRMTUEr)) { 188 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 189 GRMTUEr, &count); /* mtu exceeded pkts, good FCS */ 190 } else if (COUNT_OVR_ERRORS(unit)) { 191 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 192 GROVRr, &count); /* oversize pkts, good FCS */ 193 } 194 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 195 GRJBRr, &count); /* oversize pkts, bad FCS */ 196 break; 197 case snmpIfInUnknownProtos: 198 break; 199 case snmpIfOutOctets: 200 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 201 GTBYTr, &count); /* transmit bytes */ 202 break; 203 case snmpIfOutUcastPkts: 204 #if defined(BCM_RAPTOR_SUPPORT) || defined(BCM_FIREBOLT2_SUPPORT) || \ 205 defined(BCM_TRX_SUPPORT) 206 if (soc_feature(unit, soc_feature_hw_stats_calc)) { 207 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 208 GTUCr, &count); /* unicast pkts sent */ 209 if (!COUNT_OVR_ERRORS(unit)) { 210 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 211 GTOVRr, &count); /* + oversize, good FCS */ 212 } 213 } else 214 #endif /* BCM_RAPTOR_SUPPORT || BCM_FIREBOLT2_SUPPORT || BCM_TRX_SUPPORT */ 215 { 216 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 217 GTPKTr, &count); /* all pkts xmited */ 218 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, 219 GTMCAr, &count); /* - multicast */ 220 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, 221 GTBCAr, &count); /* - broadcast */ 222 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, 223 GTFCSr, &count); /* - bad FCS */ 224 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, 225 GTJBRr, &count); /* - oversize, bad FCS */ 226 if (COUNT_OVR_ERRORS(unit)) { 227 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, 228 GTOVRr, &count); /* - oversize, good FCS */ 229 } 230 } 231 break; 232 case snmpIfOutNUcastPkts: 233 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 234 GTMCAr, &count); /* multicast pkts */ 235 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 236 GTBCAr, &count); /* broadcast pkts */ 237 break; 238 case snmpIfOutBroadcastPkts: 239 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 240 GTBCAr, &count); /* broadcast pkts */ 241 break; 242 case snmpIfOutMulticastPkts: 243 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 244 GTMCAr, &count); /* multicast pkts */ 245 break; 246 case snmpIfOutDiscards: 247 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 248 GTEDFr, &count); /* multiple deferral */ 249 if (soc_feature(unit, soc_feature_stat_xgs3)) { 250 if (incl_non_ge_stat) { 251 if (SOC_REG_IS_VALID(unit, HOLDr)) { /* L2 MTU drops */ 252 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 253 HOLDr, &count); 254 } else if (SOC_REG_IS_VALID(unit, HOL_DROPr)) { 255 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 256 HOL_DROPr, &count); 257 } 258 if (SOC_REG_IS_VALID(unit, TDBGC3_64r)) { 259 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, TDBGC3_64r, &count); 260 } else { 261 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, TDBGC3r, &count); 262 } 263 if (SOC_REG_IS_VALID(unit, EGRDROPPKTCOUNTr)) { 264 BCM_IF_ERROR_RETURN(_bcm_stat_counter_extra_get 265 (unit, EGRDROPPKTCOUNTr, port, &count1)); 266 } 267 COMPILER_64_ADD_64(count, count1); 268 BCM_IF_ERROR_RETURN 269 (bcm_esw_cosq_stat_get(unit, port, BCM_COS_INVALID, 270 bcmCosqStatDroppedPackets, &count1)); 271 COMPILER_64_ADD_64(count, count1); 272 } 273 } 274 /* other causes of discards? */ 275 break; 276 case snmpIfOutErrors: 277 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 278 GTXCLr, &count); /* excessive collisions */ 279 break; 280 case snmpIfOutQLen: { 281 uint32 qcount; 282 if (incl_non_ge_stat) { 283 if (bcm_esw_port_queued_count_get(unit, port, &qcount) >= 0) { 284 COMPILER_64_ADD_32(count, qcount); 285 } 286 } 287 } 288 break; 289 case snmpIpInReceives: 290 if (soc_feature(unit, soc_feature_stat_xgs3)) { 291 if (incl_non_ge_stat) { 292 if (SOC_REG_IS_VALID(unit, RIPC4_64r)) { 293 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RIPC4_64r, &count); 294 } else { 295 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RIPC4r, &count); 296 } 297 } 298 } 299 break; 300 case snmpIpInHdrErrors: 301 if (soc_feature(unit, soc_feature_stat_xgs3)) { 302 if (incl_non_ge_stat) { 303 if (SOC_REG_IS_VALID(unit, RIPD4_64r)) { 304 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RIPD4_64r, &count); 305 } else { 306 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RIPD4r, &count); 307 } 308 } 309 } 310 break; 311 /* ipInAddrErrors */ 312 case snmpIpForwDatagrams: 313 if (soc_feature(unit, soc_feature_stat_xgs3)) { 314 if (incl_non_ge_stat) { 315 if (SOC_REG_IS_VALID(unit, TDBGC4_64r)) { 316 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, TDBGC4_64r, &count); 317 } else { 318 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, TDBGC4r, &count); 319 } 320 } 321 } 322 break; 323 /* ipInUnknownProtos */ 324 case snmpIpInDiscards: 325 if (soc_feature(unit, soc_feature_stat_xgs3)) { 326 if (incl_non_ge_stat) { 327 if (SOC_REG_IS_VALID(unit, RIPHE4_64r)) { 328 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RIPHE4_64r, &count); 329 } else { 330 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RIPHE4r, &count); 331 } 332 if (SOC_REG_IS_VALID(unit, RIPD4_64r)) { 333 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RIPD4_64r, &count); 334 } else { 335 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RIPD4r, &count); 336 } 337 } 338 } 339 break; 340 /* ipInDelivers */ 341 /* ipOutRequests */ 342 /* ipOutDiscards */ 343 /* ipOutNoRoutes */ 344 345 /* *** RFC 1493 *** */ 346 347 case snmpDot1dBasePortDelayExceededDiscards: 348 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 349 GTEDFr, &count); /* multiple deferral */ 350 break; 351 case snmpDot1dBasePortMtuExceededDiscards: 352 if (SOC_REG_IS_VALID(unit, GRMTUEr)) { 353 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 354 GRMTUEr, &count); /* mtu exceeded pkts */ 355 } else if (COUNT_OVR_ERRORS(unit)) { 356 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 357 GROVRr, &count); /* oversize pkts */ 358 } 359 break; 360 case snmpDot1dTpPortInFrames: /* should be only bridge mgmt */ 361 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GRPKTr, &count); 362 break; 363 case snmpDot1dTpPortOutFrames: /* should be only bridge mgmt */ 364 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GTPKTr, &count); 365 break; 366 case snmpDot1dPortInDiscards: 367 if (soc_feature(unit, soc_feature_stat_xgs3)) { 368 if (incl_non_ge_stat) { 369 if (SOC_REG_IS_VALID(unit, RDISC_64r)) { 370 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RDISC_64r, &count); 371 } else { 372 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RDISCr, &count); 373 } 374 if (SOC_REG_IS_VALID(unit, RIPD4_64r)) { 375 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RIPD4_64r, &count); 376 } else { 377 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RIPD4r, &count); 378 } 379 if (SOC_REG_IS_VALID(unit, RIPD6_64r)) { 380 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RIPD6_64r, &count); 381 } else { 382 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RIPD6r, &count); 383 } 384 if (SOC_REG_IS_VALID(unit, RPORTD_64r)) { 385 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RPORTD_64r, &count); 386 } else { 387 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RPORTDr, &count); 388 } 389 } 390 } 391 break; 392 393 /* *** RFC 1757 *** */ 394 395 case snmpEtherStatsDropEvents: 396 if (soc_feature(unit, soc_feature_stat_xgs3)) { 397 if (incl_non_ge_stat) { 398 if (SOC_REG_IS_VALID(unit, RDISC_64r)) { 399 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RDISC_64r, &count); 400 } else { 401 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RDISCr, &count); 402 } 403 } 404 } 405 break; 406 case snmpEtherStatsOctets: 407 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GRBYTr, &count); 408 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GTBYTr, &count); 409 if (SOC_REG_IS_VALID(unit, GRRBYTr)) { 410 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 411 GRRBYTr, &count); /* Runt bytes */ 412 } else { 413 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 414 RRBYTr, &count); /* Runt bytes */ 415 } 416 break; 417 case snmpEtherStatsPkts: 418 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GRPKTr, &count); 419 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GTPKTr, &count); 420 if (SOC_REG_IS_VALID(unit, GRRPKTr)) { 421 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 422 GRRPKTr, &count); /* Runt packets */ 423 } else { 424 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 425 RRPKTr, &count); /* Runt packets */ 426 } 427 break; 428 case snmpEtherStatsBroadcastPkts: 429 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GRBCAr, &count); 430 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GTBCAr, &count); 431 break; 432 case snmpEtherStatsMulticastPkts: 433 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GRMCAr, &count); 434 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GTMCAr, &count); 435 break; 436 case snmpEtherStatsCRCAlignErrors: /* CRC errors + alignment errors */ 437 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GRFCSr, &count); 438 break; 439 case snmpEtherStatsUndersizePkts: /* Undersize frames */ 440 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GRUNDr, &count); 441 break; 442 case snmpEtherStatsOversizePkts: 443 if (soc_feature(unit, soc_feature_stat_jumbo_adj)) { 444 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GROVRr, &count); 445 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GTOVRr, &count); 446 } else { 447 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GRJBRr, &count); 448 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GTJBRr, &count); 449 } 450 break; 451 case snmpEtherRxOversizePkts: 452 if (soc_feature(unit, soc_feature_stat_jumbo_adj)) { 453 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GROVRr, &count); 454 } 455 break; 456 case snmpEtherTxOversizePkts: 457 if (soc_feature(unit, soc_feature_stat_jumbo_adj)) { 458 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GTOVRr, &count); 459 } 460 break; 461 case snmpEtherStatsFragments: 462 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GRFRGr, &count); 463 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GTFRGr, &count); 464 break; 465 case snmpEtherStatsJabbers: 466 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GRJBRr, &count); 467 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GTJBRr, &count); 468 break; 469 case snmpEtherStatsCollisions: 470 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GTNCLr, &count); 471 break; 472 case snmpEtherStatsPkts64Octets: 473 if (soc_feature(unit, soc_feature_stat_xgs3)) { 474 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GR64r, &count); 475 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GT64r, &count); 476 } 477 break; 478 case snmpEtherStatsPkts65to127Octets: 479 if (soc_feature(unit, soc_feature_stat_xgs3)) { 480 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GR127r, &count); 481 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GT127r, &count); 482 } 483 break; 484 case snmpEtherStatsPkts128to255Octets: 485 if (soc_feature(unit, soc_feature_stat_xgs3)) { 486 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GR255r, &count); 487 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GT255r, &count); 488 } 489 break; 490 case snmpEtherStatsPkts256to511Octets: 491 if (soc_feature(unit, soc_feature_stat_xgs3)) { 492 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GR511r, &count); 493 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GT511r, &count); 494 } 495 break; 496 case snmpEtherStatsPkts512to1023Octets: 497 if (soc_feature(unit, soc_feature_stat_xgs3)) { 498 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GR1023r, &count); 499 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GT1023r, &count); 500 } 501 break; 502 case snmpEtherStatsPkts1024to1518Octets: 503 if (soc_feature(unit, soc_feature_stat_xgs3)) { 504 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GR1518r, &count); 505 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GT1518r, &count); 506 } 507 break; 508 509 /* *** not actually in rfc1757 *** */ 510 511 case snmpBcmEtherStatsPkts1519to1522Octets: 512 if (soc_feature(unit, soc_feature_stat_xgs3)) { 513 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GRMGVr, &count); 514 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GTMGVr, &count); 515 } 516 break; 517 case snmpBcmEtherStatsPkts1522to2047Octets: 518 if (soc_feature(unit, soc_feature_stat_xgs3)) { 519 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GR2047r, &count); 520 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, GRMGVr, &count); 521 522 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GT2047r, &count); 523 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, GTMGVr, &count); 524 } 525 break; 526 case snmpBcmEtherStatsPkts2048to4095Octets: 527 if (soc_feature(unit, soc_feature_stat_xgs3)) { 528 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GR4095r, &count); 529 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GT4095r, &count); 530 } 531 break; 532 case snmpBcmEtherStatsPkts4095to9216Octets: 533 if (soc_feature(unit, soc_feature_stat_xgs3)) { 534 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GR9216r, &count); 535 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GT9216r, &count); 536 } 537 break; 538 #ifdef BCM_KATANA_SUPPORT 539 case snmpBcmEtherStatsPkts9217to16383Octets: /* not in rfc1757 */ 540 if(SOC_IS_KATANA(unit)) 541 { 542 if (soc_feature(unit, soc_feature_stat_xgs3)) { 543 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 544 GR16383r, &count); 545 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 546 GT16383r, &count); 547 } 548 } 549 break; 550 #endif 551 case snmpBcmReceivedPkts64Octets: 552 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GR64r, &count); 553 break; 554 case snmpBcmReceivedPkts65to127Octets: 555 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GR127r, &count); 556 break; 557 case snmpBcmReceivedPkts128to255Octets: 558 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GR255r, &count); 559 break; 560 case snmpBcmReceivedPkts256to511Octets: 561 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GR511r, &count); 562 break; 563 case snmpBcmReceivedPkts512to1023Octets: 564 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GR1023r, &count); 565 break; 566 case snmpBcmReceivedPkts1024to1518Octets: 567 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GR1518r, &count); 568 break; 569 case snmpBcmReceivedPkts1519to2047Octets: 570 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GR2047r, &count); 571 break; 572 case snmpBcmReceivedPkts2048to4095Octets: 573 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GR4095r, &count); 574 break; 575 case snmpBcmReceivedPkts4095to9216Octets: 576 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GR9216r, &count); 577 break; 578 case snmpBcmReceivedPkts9217to16383Octets: 579 if (SOC_REG_IS_VALID(unit, GR16383r)) { 580 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GR16383r, &count); 581 } else { 582 return BCM_E_UNAVAIL; 583 } 584 break; 585 case snmpBcmTransmittedPkts64Octets: 586 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GT64r, &count); 587 break; 588 case snmpBcmTransmittedPkts65to127Octets: 589 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GT127r, &count); 590 break; 591 case snmpBcmTransmittedPkts128to255Octets: 592 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GT255r, &count); 593 break; 594 case snmpBcmTransmittedPkts256to511Octets: 595 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GT511r, &count); 596 break; 597 case snmpBcmTransmittedPkts512to1023Octets: 598 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GT1023r, &count); 599 break; 600 case snmpBcmTransmittedPkts1024to1518Octets: 601 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GT1518r, &count); 602 break; 603 case snmpBcmTransmittedPkts1519to2047Octets: 604 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GT2047r, &count); 605 break; 606 case snmpBcmTransmittedPkts2048to4095Octets: 607 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GT4095r, &count); 608 break; 609 case snmpBcmTransmittedPkts4095to9216Octets: 610 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GT9216r, &count); 611 break; 612 case snmpBcmTransmittedPkts9217to16383Octets: 613 if (SOC_REG_IS_VALID(unit, GT16383r)) { 614 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GT16383r, &count); 615 } else { 616 return BCM_E_UNAVAIL; 617 } 618 break; 619 case snmpEtherStatsTXNoErrors: 620 /* FE = TPKT - (TNCL + TOVR + TFRG + TUND) */ 621 /* GE = GTPKT - (GTOVR + GTIPD + GTABRT) */ 622 #if defined(BCM_RAPTOR_SUPPORT) || defined(BCM_FIREBOLT2_SUPPORT) || \ 623 defined(BCM_TRX_SUPPORT) 624 if (soc_feature(unit, soc_feature_hw_stats_calc)) { 625 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 626 GTPOKr, &count); /* All good packets */ 627 } else 628 #endif /* BCM_RAPTOR_SUPPORT || BCM_FIREBOLT2_SUPPORT || BCM_TRX_SUPPORT */ 629 { 630 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 631 GTPKTr, &count); /* All Packets */ 632 if (COUNT_OVR_ERRORS(unit)) { 633 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, 634 GTOVRr, &count); /* Oversize */ 635 } 636 } 637 break; 638 case snmpEtherStatsRXNoErrors: 639 #if defined(BCM_RAPTOR_SUPPORT) || defined(BCM_FIREBOLT2_SUPPORT) || \ 640 defined(BCM_TRX_SUPPORT) 641 /* Some chips have a dedicated register for this stat */ 642 if (soc_feature(unit, soc_feature_hw_stats_calc)) { 643 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GRPOKr, &count); 644 } else 645 #endif /* BCM_RAPTOR_SUPPORT || BCM_FIREBOLT2_SUPPORT || BCM_TRX_SUPPORT */ 646 { 647 /* 648 * GE = GRPKT - (GRFCS + GRXUO + GRFLR + GRCDE + GRFCR + 649 * GRUND + GROVR + GRJBR + GRIPCHK/GRIPHE) 650 */ 651 652 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GRPKTr, &count); 653 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, GRFCSr, &count); 654 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, GRXUOr, &count); 655 656 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, GRCDEr, &count); 657 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, GRFCRr, &count); 658 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, GRUNDr, &count); 659 if (SOC_REG_IS_VALID(unit, GRMTUEr)) { 660 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, 661 GRMTUEr, &count); /* mtu exceeded pkts */ 662 } else if (COUNT_OVR_ERRORS(unit)) { 663 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, 664 GROVRr, &count); /* oversize pkts */ 665 } 666 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, GRJBRr, &count); 667 } 668 break; 669 /* *** RFC 2665 *** */ 670 671 case snmpDot3StatsAlignmentErrors: 672 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GRALNr, &count); 673 break; 674 case snmpDot3StatsFCSErrors: 675 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GRFCSr, &count); 676 break; 677 case snmpDot3StatsSingleCollisionFrames: 678 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GTSCLr, &count); 679 break; 680 case snmpDot3StatsMultipleCollisionFrames: 681 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GTMCLr, &count); 682 break; 683 case snmpDot3StatsSQETTestErrors: 684 /* always 0 */ 685 break; 686 case snmpDot3StatsDeferredTransmissions: 687 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GTDFRr, &count); 688 break; 689 case snmpDot3StatsLateCollisions: 690 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GTLCLr, &count); 691 break; 692 case snmpDot3StatsExcessiveCollisions: 693 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GTXCLr, &count); 694 break; 695 case snmpDot3StatsInternalMacTransmitErrors: 696 /* always 0 */ 697 break; 698 case snmpDot3StatsCarrierSenseErrors: 699 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GRFCRr, &count); 700 break; 701 case snmpDot3StatsFrameTooLongs: 702 if (soc_feature(unit, soc_feature_stat_jumbo_adj)) { 703 if (SOC_REG_IS_VALID(unit, GRMTUEr)) { 704 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 705 GRMTUEr, &count); /* mtu exceeded pkts */ 706 } else { 707 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 708 GROVRr, &count); /* oversized pkts */ 709 } 710 } else { 711 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GRJBRr, &count); 712 } 713 break; 714 case snmpDot3StatsInternalMacReceiveErrors: 715 /* always 0 */ 716 break; 717 case snmpDot3StatsSymbolErrors: 718 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GRCDEr, &count); 719 break; 720 case snmpDot3ControlInUnknownOpcodes: 721 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GRXUOr, &count); 722 break; 723 case snmpDot3InPauseFrames: 724 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GRXPFr, &count); 725 break; 726 case snmpDot3OutPauseFrames: 727 if (incl_non_ge_stat) { 728 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GTXPFr, &count); 729 } /* Else avoid double-counting of pause frames on GXMACs */ 730 break; 731 732 /* *** RFC 2233 high capacity versions of RFC1213 objects *** */ 733 734 case snmpIfHCInOctets: 735 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 736 GRBYTr, &count); /* bytes rcvd */ 737 if (SOC_REG_IS_VALID(unit, GRRBYTr)) { 738 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 739 GRRBYTr, &count); /* Runt bytes */ 740 } else { 741 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 742 RRBYTr, &count); /* Runt bytes */ 743 } 744 break; 745 case snmpIfHCInUcastPkts: 746 if (soc_feature(unit, soc_feature_hw_stats_calc)) { 747 if (SOC_REG_IS_VALID(unit, GRUCr) 748 && !((SOC_IS_RAPTOR(unit) || SOC_IS_RAVEN(unit)) 749 && SOC_IS_STACK_PORT(unit, port))) { 750 if (COUNT_OVR_ERRORS(unit)) { 751 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GRUCr, &count); 752 } else { 753 if (incl_non_ge_stat && SOC_REG_IS_VALID(unit, RUC_64r)) { 754 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RUC_64r, 755 &count); /* unicast pkts rcvd */ 756 } else { 757 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GRUCr, &count); 758 BCM_STAT_REG_OPER(unit, port, 759 sync_mode, reg_op, 760 GROVRr, &count); /* + oversize, good FCS */ 761 } 762 } 763 } else { 764 if (incl_non_ge_stat) { 765 /* RUC switch register has the count of all received packets, 766 * add the count when incl_non_ge_stat flag is set. 767 */ 768 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RUCr, &count); /* unicast pkts rcvd */ 769 } 770 } 771 } else { 772 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 773 GRPKTr, &count); /* all pkts rcvd */ 774 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, 775 GRMCAr, &count); /* - multicast */ 776 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, 777 GRBCAr, &count); /* - broadcast */ 778 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, 779 GRALNr, &count); /* - bad FCS, dribble bit */ 780 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, 781 GRFCSr, &count); /* - bad FCS, no dribble bit */ 782 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, 783 GRJBRr, &count); /* - oversize, bad FCS */ 784 if (SOC_REG_IS_VALID(unit, GRMTUEr)) { 785 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, 786 GRMTUEr, &count); /* mtu exceeded pkts */ 787 } else if (COUNT_OVR_ERRORS(unit)) { 788 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, 789 GROVRr, &count); /* oversize pkts */ 790 } 791 if (SOC_REG_IS_VALID(unit, GRFLRr)) { 792 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, 793 GRFLRr, &count); /* - good FCS, bad length */ 794 } 795 if (SOC_REG_IS_VALID(unit, GRXCFr)) { 796 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, 797 GRXCFr, &count); /* - good FCS, all MAC ctrl */ 798 } 799 } 800 break; 801 case snmpIfHCInMulticastPkts: 802 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 803 GRMCAr, &count); /* multicast */ 804 break; 805 case snmpIfHCInBroadcastPkts: 806 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 807 GRBCAr, &count); /* broadcast */ 808 break; 809 case snmpIfHCOutOctets: 810 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 811 GTBYTr, &count); /* transmit bytes */ 812 break; 813 case snmpIfHCOutUcastPkts: 814 #if defined(BCM_RAPTOR_SUPPORT) || defined(BCM_FIREBOLT2_SUPPORT) || \ 815 defined(BCM_TRX_SUPPORT) 816 if (soc_feature(unit, soc_feature_hw_stats_calc)) { 817 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 818 GTUCr, &count); /* All good packets */ 819 if (!COUNT_OVR_ERRORS(unit)) { 820 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 821 GTOVRr, &count); /* + oversize pkts */ 822 } 823 } else 824 #endif /* BCM_RAPTOR_SUPPORT || BCM_FIREBOLT2_SUPPORT || BCM_TRX_SUPPORT */ 825 { 826 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 827 GTPKTr, &count); /* all pkts xmited */ 828 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, 829 GTMCAr, &count); /* - multicast */ 830 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, 831 GTBCAr, &count); /* - broadcast */ 832 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, 833 GTFCSr, &count); /* - bad FCS */ 834 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, 835 GTJBRr, &count); /* - oversize, bad FCS */ 836 if (COUNT_OVR_ERRORS(unit)) { 837 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, 838 GTOVRr, &count); /* - oversize, good FCS */ 839 } 840 } 841 break; 842 case snmpIfHCOutMulticastPkts: 843 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 844 GTMCAr, &count); /* multicast xmited */ 845 break; 846 case snmpIfHCOutBroadcastPckts: 847 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 848 GTBCAr, &count); /* broadcast xmited */ 849 break; 850 851 /* *** RFC 2465 *** */ 852 853 case snmpIpv6IfStatsInReceives: 854 if (soc_feature(unit, soc_feature_stat_xgs3)) { 855 if (incl_non_ge_stat) { 856 if (SOC_REG_IS_VALID(unit, RIPC6_64r)) { 857 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RIPC6_64r, &count); 858 } else { 859 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RIPC6r, &count); 860 } 861 if (SOC_REG_IS_VALID(unit, IMRP6_64r)) { 862 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IMRP6_64r, &count); 863 } else { 864 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IMRP6r, &count); 865 } 866 } 867 } 868 break; 869 case snmpIpv6IfStatsInHdrErrors: 870 if (soc_feature(unit, soc_feature_stat_xgs3)) { 871 if (incl_non_ge_stat) { 872 if (SOC_REG_IS_VALID(unit, RIPD6_64r)) { 873 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RIPD6_64r, &count); 874 } else { 875 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RIPD6r, &count); 876 } 877 } 878 } 879 break; 880 case snmpIpv6IfStatsInAddrErrors: 881 if (soc_feature(unit, soc_feature_stat_xgs3)) { 882 if (incl_non_ge_stat) { 883 if (SOC_REG_IS_VALID(unit, RIPHE6_64r)) { 884 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RIPHE6_64r, &count); 885 } else { 886 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RIPHE6r, &count); 887 } 888 } 889 } 890 break; 891 case snmpIpv6IfStatsInDiscards: 892 if (soc_feature(unit, soc_feature_stat_xgs3)) { 893 if (incl_non_ge_stat) { 894 if (SOC_REG_IS_VALID(unit, RIPHE6_64r)) { 895 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RIPHE6_64r, &count); 896 } else { 897 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RIPHE6r, &count); 898 } 899 if (SOC_REG_IS_VALID(unit, RIPD6_64r)) { 900 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RIPD6_64r, &count); 901 } else { 902 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RIPD6r, &count); 903 } 904 } 905 } 906 break; 907 case snmpIpv6IfStatsOutForwDatagrams: 908 if (soc_feature(unit, soc_feature_stat_xgs3)) { 909 if (incl_non_ge_stat) { 910 if (SOC_REG_IS_VALID(unit, TDBGC0_64r)) { 911 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, TDBGC0_64r, &count); 912 } else { 913 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, TDBGC0r, &count); 914 } 915 } 916 } 917 break; 918 case snmpIpv6IfStatsOutDiscards: 919 if (soc_feature(unit, soc_feature_stat_xgs3)) { 920 if (incl_non_ge_stat) { 921 if (SOC_REG_IS_VALID(unit, TDBGC1_64r)) { 922 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, TDBGC1_64r, &count); 923 } else { 924 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, TDBGC1r, &count); 925 } 926 } 927 } 928 break; 929 case snmpIpv6IfStatsInMcastPkts: 930 if (soc_feature(unit, soc_feature_stat_xgs3)) { 931 if (incl_non_ge_stat) { 932 if (SOC_REG_IS_VALID(unit, IMRP6_64r)) { 933 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IMRP6_64r, &count); 934 } else { 935 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IMRP6r, &count); 936 } 937 } 938 } 939 break; 940 case snmpIpv6IfStatsOutMcastPkts: 941 if (soc_feature(unit, soc_feature_stat_xgs3)) { 942 if (incl_non_ge_stat) { 943 if (SOC_REG_IS_VALID(unit, TDBGC2_64r)) { 944 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, TDBGC2_64r, &count); 945 } else { 946 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, TDBGC2r, &count); 947 } 948 } 949 } 950 break; 951 952 /* *** IEEE 802.1bb *** */ 953 case snmpIeee8021PfcRequests: 954 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GTXPPr, &count); 955 break; 956 case snmpIeee8021PfcIndications: 957 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GRXPPr, &count); 958 break; 959 960 /* *** RFC 1284 - unsupported in XGS *** */ 961 case snmpDot3StatsInRangeLengthError: 962 break; 963 964 /* *** RFC 4837 - unsupported in XGS *** */ 965 case snmpDot3OmpEmulationCRC8Errors: 966 case snmpDot3MpcpRxGate: 967 case snmpDot3MpcpRxRegister: 968 case snmpDot3MpcpTxRegRequest: 969 case snmpDot3MpcpTxRegAck: 970 case snmpDot3MpcpTxReport: 971 case snmpDot3EponFecCorrectedBlocks: 972 case snmpDot3EponFecUncorrectableBlocks: 973 break; 974 975 /* IPMC counters (broadcom specific) */ 976 977 case snmpBcmIPMCBridgedPckts: 978 if (soc_feature(unit, soc_feature_ip_mcast)) { 979 if (soc_feature(unit, soc_feature_stat_xgs3)) { 980 if (incl_non_ge_stat) { 981 if (SOC_REG_IS_VALID(unit, RDBGC1_64r)) { 982 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RDBGC1_64r, &count); 983 } else { 984 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RDBGC1r, &count); 985 } 986 } 987 } 988 } 989 break; 990 case snmpBcmIPMCRoutedPckts: 991 if (soc_feature(unit, soc_feature_ip_mcast)) { 992 if (soc_feature(unit, soc_feature_stat_xgs3)) { 993 if (incl_non_ge_stat) { 994 if (SOC_REG_IS_VALID(unit, IMRP4_64r)) { 995 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IMRP4_64r, &count); 996 } else { 997 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IMRP4r, &count); 998 } 999 if (SOC_REG_IS_VALID(unit, IMRP6_64r)) { 1000 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IMRP6_64r, &count); 1001 } else { 1002 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IMRP6r, &count); 1003 } 1004 } 1005 } 1006 } 1007 break; 1008 case snmpBcmIPMCInDroppedPckts: 1009 if (soc_feature(unit, soc_feature_ip_mcast)) { 1010 if (soc_feature(unit, soc_feature_stat_xgs3)) { 1011 if (incl_non_ge_stat) { 1012 if (SOC_REG_IS_VALID(unit, RDBGC2_64r)) { 1013 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RDBGC2_64r, &count); 1014 } else { 1015 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RDBGC2r, &count); 1016 } 1017 } 1018 } 1019 } 1020 break; 1021 case snmpBcmIPMCOutDroppedPckts: 1022 if (soc_feature(unit, soc_feature_ip_mcast)) { 1023 if (soc_feature(unit, soc_feature_stat_xgs3)) { 1024 if (incl_non_ge_stat) { 1025 if (SOC_REG_IS_VALID(unit, TDBGC5_64r)) { 1026 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, TDBGC5_64r, &count); 1027 } else { 1028 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, TDBGC5r, &count); 1029 } 1030 } 1031 } 1032 } 1033 break; 1034 1035 /* EA (broadcom specific) - unsupported in XGS */ 1036 case snmpBcmPonInDroppedOctets: 1037 case snmpBcmPonOutDroppedOctets: 1038 case snmpBcmPonInDelayedOctets: 1039 case snmpBcmPonOutDelayedOctets: 1040 case snmpBcmPonInDelayedHundredUs: 1041 case snmpBcmPonOutDelayedHundredUs: 1042 case snmpBcmPonInFrameErrors: 1043 case snmpBcmPonInOamFrames: 1044 case snmpBcmPonOutOamFrames: 1045 case snmpBcmPonOutUnusedOctets: 1046 break; 1047 1048 /* PFC Control Frame Counters */ 1049 case snmpBcmRxPFCControlFrame: 1050 if (SOC_REG_IS_VALID(unit, GRPFCr)) { 1051 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GRPFCr, &count); 1052 } 1053 break; 1054 1055 case snmpBcmTxPFCControlFrame: 1056 if (SOC_REG_IS_VALID(unit, GTPFCr)) { 1057 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, GTPFCr, &count); 1058 } 1059 break; 1060 1061 case snmpFcmPortClass3RxFrames: 1062 if (soc_feature(unit, soc_feature_fcoe)) { 1063 if (SOC_REG_IS_VALID(unit, RDBGC3_64r)) { 1064 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RDBGC3_64r, &count); 1065 } else { 1066 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RDBGC3r, &count); 1067 } 1068 } else { 1069 return BCM_E_UNAVAIL; 1070 } 1071 break; 1072 1073 case snmpFcmPortClass3TxFrames: 1074 if (soc_feature(unit, soc_feature_fcoe)) { 1075 if (SOC_REG_IS_VALID(unit, TDBGC6_64r)) { 1076 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, TDBGC6_64r, &count); 1077 } else { 1078 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, TDBGC6r, &count); 1079 } 1080 } else { 1081 return BCM_E_UNAVAIL; 1082 } 1083 break; 1084 1085 case snmpFcmPortClass3Discards: 1086 if (soc_feature(unit, soc_feature_fcoe)) { 1087 if (SOC_REG_IS_VALID(unit, RDBGC4_64r)) { 1088 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RDBGC4_64r, &count); 1089 } else { 1090 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RDBGC4r, &count); 1091 } 1092 } else { 1093 return BCM_E_UNAVAIL; 1094 } 1095 break; 1096 1097 case snmpFcmPortClass2RxFrames: 1098 if (soc_feature(unit, soc_feature_fcoe)) { 1099 if (SOC_REG_IS_VALID(unit, RDBGC5_64r)) { 1100 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RDBGC5_64r, &count); 1101 } else { 1102 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RDBGC5r, &count); 1103 } 1104 } else { 1105 return BCM_E_UNAVAIL; 1106 } 1107 break; 1108 1109 case snmpFcmPortClass2TxFrames: 1110 if (soc_feature(unit, soc_feature_fcoe)) { 1111 if (SOC_REG_IS_VALID(unit, TDBGC7_64r)) { 1112 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, TDBGC7_64r, &count); 1113 } else { 1114 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, TDBGC7r, &count); 1115 } 1116 } else { 1117 return BCM_E_UNAVAIL; 1118 } 1119 break; 1120 1121 case snmpFcmPortClass2Discards: 1122 if (soc_feature(unit, soc_feature_fcoe)) { 1123 if (SOC_REG_IS_VALID(unit, RDBGC6_64r)) { 1124 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RDBGC6_64r, &count); 1125 } else { 1126 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RDBGC6r, &count); 1127 } 1128 } else { 1129 return BCM_E_UNAVAIL; 1130 } 1131 break; 1132 1133 case snmpFcmPortInvalidCRCs: 1134 if (soc_feature(unit, soc_feature_fcoe)) { 1135 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 1136 EGR_FCOE_INVALID_CRC_FRAMESr, &count); 1137 } else { 1138 return BCM_E_UNAVAIL; 1139 } 1140 break; 1141 1142 case snmpFcmPortDelimiterErrors: 1143 if (soc_feature(unit, soc_feature_fcoe)) { 1144 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 1145 EGR_FCOE_DELIMITER_ERROR_FRAMESr, 1146 &count); 1147 } else { 1148 return BCM_E_UNAVAIL; 1149 } 1150 break; 1151 #ifdef BCM_TOMAHAWK_SUPPORT 1152 case snmpBcmSampleIngressPkts: 1153 case snmpBcmSampleIngressSnapshotPkts: 1154 case snmpBcmSampleIngressSampledPkts: 1155 if (soc_feature(unit, soc_feature_sflow_counters)) { 1156 ctrl_info.instance_type = SOC_CTR_INSTANCE_TYPE_SFLOW; 1157 1158 if (type == snmpBcmSampleIngressPkts) { 1159 ctrl_info.instance = SOC_SFLOW_CTR_TYPE_SAMPLE_POOL; 1160 } else if (type == snmpBcmSampleIngressSnapshotPkts) { 1161 ctrl_info.instance = SOC_SFLOW_CTR_TYPE_SAMPLE_POOL_SNAPSHOT; 1162 } else { /* snmpBcmSampleIngressSampledPkts */ 1163 ctrl_info.instance = SOC_SFLOW_CTR_TYPE_SAMPLE_COUNT; 1164 } 1165 1166 if (stat_op == _BCM_STAT_GET) { 1167 BCM_IF_ERROR_RETURN 1168 (soc_counter_generic_get(unit, 1169 SOC_COUNTER_NON_DMA_SFLOW_ING_PKT, 1170 ctrl_info, sync_mode, port, 1171 &count)); 1172 } else { /* _BCM_STAT_CLEAR */ 1173 BCM_IF_ERROR_RETURN 1174 (soc_counter_generic_set(unit, 1175 SOC_COUNTER_NON_DMA_SFLOW_ING_PKT, 1176 ctrl_info, 0, port, count)); 1177 } 1178 } 1179 break; 1180 case snmpBcmSampleFlexPkts: 1181 case snmpBcmSampleFlexSnapshotPkts: 1182 case snmpBcmSampleFlexSampledPkts: 1183 if (soc_feature(unit, soc_feature_sflow_counters)) { 1184 ctrl_info.instance_type = SOC_CTR_INSTANCE_TYPE_SFLOW; 1185 1186 if (type == snmpBcmSampleFlexPkts) { 1187 ctrl_info.instance = SOC_SFLOW_CTR_TYPE_SAMPLE_POOL; 1188 } else if (type == snmpBcmSampleFlexSnapshotPkts) { 1189 ctrl_info.instance = SOC_SFLOW_CTR_TYPE_SAMPLE_POOL_SNAPSHOT; 1190 } else { /* snmpBcmSampleFlexSampledPkts */ 1191 ctrl_info.instance = SOC_SFLOW_CTR_TYPE_SAMPLE_COUNT; 1192 } 1193 1194 if (stat_op == _BCM_STAT_GET) { 1195 BCM_IF_ERROR_RETURN 1196 (soc_counter_generic_get(unit, 1197 SOC_COUNTER_NON_DMA_SFLOW_FLEX_PKT, 1198 ctrl_info, sync_mode, port, &count)); 1199 } else { /* _BCM_STAT_CLEAR */ 1200 BCM_IF_ERROR_RETURN 1201 (soc_counter_generic_set(unit, 1202 SOC_COUNTER_NON_DMA_SFLOW_FLEX_PKT, 1203 ctrl_info, 0, port, count)); 1204 } 1205 } 1206 break; 1207 #endif /* BCM_TOMAHAWK_SUPPORT */ 1208 1209 case snmpBcmTxE2ECCControlFrames: 1210 if (SOC_REG_IS_VALID(unit, XTHOLr)) { 1211 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, XTHOLr, 1212 &count); 1213 } 1214 break; 1215 1216 case snmpBcmRxDot3LengthMismatches: 1217 if (SOC_REG_IS_VALID(unit, GRFLRr)) { 1218 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 1219 GRFLRr, &count); /* Good FCS, bad length */ 1220 } else { 1221 return BCM_E_UNAVAIL; 1222 } 1223 break; 1224 1225 default: 1226 if (type < snmpValCount) { 1227 return BCM_E_UNAVAIL; 1228 } 1229 LOG_VERBOSE(BSL_LS_SOC_COMMON, 1230 (BSL_META_U(unit, 1231 "bcm_stat_get: Statistic not supported: %d\n"), type)); 1232 return BCM_E_PARAM; 1233 } 1234 1235 if (stat_op == _BCM_STAT_GET) { 1236 *val = count; 1237 } 1238 1239 return BCM_E_NONE; 1240 }