vlan.c (25167B)
1 /* 2 * 3 * 4 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 5 * 6 * Copyright 2007-2019 Broadcom Inc. All rights reserved. 7 */ 8 9 #include <shared/bsl.h> 10 11 #include <soc/drv.h> 12 #include <soc/scache.h> 13 #include <bcm/stat.h> 14 #include <bcm/vlan.h> 15 #include <bcm_int/esw/vlan.h> 16 #include <bcm_int/esw/trx.h> 17 #include <bcm_int/esw/flowcnt.h> 18 #include <bcm_int/esw_dispatch.h> 19 20 /* 21 * Function: 22 * _bcm_hr3_vlan_translate_stat_table_info_get 23 * Description: 24 * Provides relevant flex table information(table-name,index) 25 * for given ingress vlan translation 26 * 27 * Parameters: 28 * unit - (IN) unit number 29 * port - (IN) Generic port 30 * key_type - (IN) Key Type : bcmVlanTranslateKey* 31 * outer_vlan - (IN) Packet outer VLAN ID 32 * inner_vlan - (IN) Packet inner VLAN ID 33 * table - (OUT) accounting object table 34 * index - (OUT) accounting object table index 35 * 36 * Return Value: 37 * BCM_E_XXX 38 * Notes: 39 */ 40 STATIC int 41 _bcm_hr3_vlan_translate_stat_table_info_get( 42 int unit, 43 bcm_gport_t port, 44 bcm_vlan_translate_key_t key_type, 45 bcm_vlan_t outer_vlan, 46 bcm_vlan_t inner_vlan, 47 soc_mem_t *table, 48 uint32 *index) 49 { 50 int rv=BCM_E_NONE; 51 vlan_xlate_entry_t vent={{0}}; 52 vlan_xlate_entry_t vlan_xlate_entry={{0}}; 53 int idx=0; 54 soc_mem_t mem; 55 56 mem = VLAN_XLATEm; 57 /* get table and its index */ 58 sal_memset(&vent, 0, sizeof(vlan_xlate_entry_t)); 59 BCM_IF_ERROR_RETURN (_bcm_trx_vlan_translate_entry_assemble( 60 unit, &vent, port, key_type, inner_vlan, outer_vlan)); 61 soc_mem_lock(unit, mem); 62 rv = soc_mem_search(unit, mem, MEM_BLOCK_ALL, &idx, &vent, 63 &vlan_xlate_entry, 0); 64 soc_mem_unlock(unit, mem); 65 66 if (BCM_SUCCESS(rv)) { 67 *table = mem; 68 *index = idx; 69 } 70 return rv; 71 } 72 73 /* 74 * Function: 75 * _bcm_hr3_vlan_translate_stat_detach 76 * Description: 77 * Detach counters entries for the given ingress vlan translation table. 78 * 79 * Parameters: 80 * unit - (IN) unit number 81 * Port - (IN) GPORT (global port) identifier 82 * key_type - (IN) VLAN translation key type 83 * outer_vlan - (IN) Outer VLAN ID or tag 84 * inner_vlan - (IN) Inner VLAN ID or tag 85 * 86 * Return Value: 87 * BCM_E_XXX 88 * Notes: 89 */ 90 int 91 _bcm_hr3_vlan_translate_stat_detach( 92 int unit, 93 bcm_gport_t port, 94 bcm_vlan_translate_key_t key_type, 95 bcm_vlan_t outer_vlan, 96 bcm_vlan_t inner_vlan) 97 { 98 soc_mem_t table=0; 99 uint32 index; 100 101 BCM_IF_ERROR_RETURN(_bcm_hr3_vlan_translate_stat_table_info_get( 102 unit, port, key_type, outer_vlan, inner_vlan, 103 &table, &index)); 104 105 return _bcm_esw_flowcnt_object_table_detach(unit, table, index); 106 107 } 108 109 110 /* 111 * Function: 112 * _bcm_hr3_vlan_translate_stat_attach 113 * Description: 114 * attach counters entries for the given ingress vlan translation table. 115 * 116 * Parameters: 117 * unit - (IN) unit number 118 * Port - (IN) GPORT (global port) identifier 119 * key_type - (IN) VLAN translation key type 120 * outer_vlan - (IN) Outer VLAN ID or tag 121 * inner_vlan - (IN) Inner VLAN ID or tag 122 * Stat_counter_id - (IN) Stat Counter ID. 123 * 124 * Return Value: 125 * BCM_E_XXX 126 * Notes: 127 */ 128 int 129 _bcm_hr3_vlan_translate_stat_attach( 130 int unit, 131 bcm_gport_t port, 132 bcm_vlan_translate_key_t key_type, 133 bcm_vlan_t outer_vlan, 134 bcm_vlan_t inner_vlan, 135 uint32 stat_counter_id) 136 { 137 bcm_stat_group_mode_t group_mode = bcmStatGroupModeSingle; 138 bcm_stat_object_t object = bcmStatObjectIngPort; 139 uint32 profile_group, pool_index, base_index; 140 soc_mem_t table=0; 141 uint32 index; 142 143 _bcm_esw_flowcnt_counter_id_get(stat_counter_id, &group_mode, &object, 144 &profile_group, &pool_index, &base_index); 145 146 BCM_IF_ERROR_RETURN(_bcm_hr3_vlan_translate_stat_table_info_get( 147 unit, port, key_type, outer_vlan, inner_vlan, 148 &table, &index)); 149 150 return _bcm_esw_flowcnt_object_table_attach( 151 unit, object, table, index, profile_group, base_index, 152 pool_index, NULL); 153 } 154 155 /* Function: 156 * _bcm_hr3_vlan_translate_stat_counter_set 157 * Description: 158 * Set counter values into a ingress vlan translation table 159 * 160 * Parameters: 161 * unit - (IN) unit number 162 * Port - (IN) GPORT (global port) identifier 163 * key_type - (IN) VLAN translation key type 164 * outer_vlan - (IN) Outer VLAN ID or tag 165 * inner_vlan - (IN) Inner VLAN ID or tag 166 * stat - (IN) Type of the counter to retrieve 167 * I.e. ingress/egress byte/packet) 168 * num_entries - (IN) Number of counter Entries 169 * counter_indexes - (IN) Pointer to Counter indexes entries 170 * counter_values - (IN) Pointer to counter values 171 * 172 * Return Value: 173 * BCM_E_XXX 174 * Notes: 175 */ 176 int _bcm_hr3_vlan_translate_stat_counter_set( 177 int unit, 178 bcm_gport_t port, 179 bcm_vlan_translate_key_t key_type, 180 bcm_vlan_t outer_vlan, 181 bcm_vlan_t inner_vlan, 182 bcm_vlan_stat_t stat, 183 uint32 num_entries, 184 uint32 *counter_indexes, 185 bcm_stat_value_t *counter_values) 186 { 187 uint32 byte_flag=0; 188 uint32 index_count=0; 189 soc_mem_t table=0; 190 uint32 index; 191 192 if ((stat == bcmVlanStatIngressPackets) || 193 (stat == bcmVlanStatEgressPackets)) { 194 byte_flag=0; 195 } else { 196 byte_flag=1; 197 } 198 199 BCM_IF_ERROR_RETURN(_bcm_hr3_vlan_translate_stat_table_info_get( 200 unit, port, key_type, outer_vlan, inner_vlan, 201 &table, &index)); 202 203 for (index_count=0; index_count < num_entries ; index_count++) { 204 BCM_IF_ERROR_RETURN(_bcm_esw_flowcnt_counter_set( 205 unit, index, table, byte_flag, 206 counter_indexes[index_count], 207 &counter_values[index_count])); 208 } 209 return BCM_E_NONE; 210 } 211 212 /* 213 * Function: 214 * _bcm_hr3_vlan_translate_stat_counter_get 215 * Description: 216 * Get counter values from ingress vlan translation table 217 * if sync_mode is set, sync the sw accumulated count 218 * with hw count value first, else return sw count. 219 * 220 * Parameters: 221 * unit - (IN) unit number 222 * sync_mode - (IN) hwcount is to be synced to sw count 223 * Port - (IN) GPORT (global port) identifier 224 * key_type - (IN) VLAN translation key type 225 * outer_vlan - (IN) Outer VLAN ID or tag 226 * inner_vlan - (IN) Inner VLAN ID or tag 227 * stat - (IN) Type of the counter to retrieve 228 * I.e. ingress/egress byte/packet) 229 * num_entries - (IN) Number of counter Entries 230 * counter_indexes - (IN) Pointer to Counter indexes entries 231 * counter_values - (OUT) Pointer to counter values 232 * 233 * Return Value: 234 * BCM_E_XXX 235 * Notes: 236 */ 237 int _bcm_hr3_vlan_translate_stat_counter_get( 238 int unit, 239 int sync_mode, 240 bcm_gport_t port, 241 bcm_vlan_translate_key_t key_type, 242 bcm_vlan_t outer_vlan, 243 bcm_vlan_t inner_vlan, 244 bcm_vlan_stat_t stat, 245 uint32 num_entries, 246 uint32 *counter_indexes, 247 bcm_stat_value_t *counter_values) 248 { 249 250 uint32 byte_flag=0; 251 uint32 index_count=0; 252 soc_mem_t table=0; 253 uint32 index; 254 255 if ((stat == bcmVlanStatIngressPackets) || 256 (stat == bcmVlanStatEgressPackets)) { 257 byte_flag=0; 258 } else { 259 byte_flag=1; 260 } 261 262 BCM_IF_ERROR_RETURN(_bcm_hr3_vlan_translate_stat_table_info_get( 263 unit, port, key_type, outer_vlan, inner_vlan, 264 &table, &index)); 265 for (index_count=0; index_count < num_entries ; index_count++) { 266 BCM_IF_ERROR_RETURN(_bcm_esw_flowcnt_counter_get( 267 unit, sync_mode, index, table, byte_flag, 268 counter_indexes[index_count], 269 &counter_values[index_count])); 270 } 271 return BCM_E_NONE; 272 } 273 274 275 /* 276 * Function: 277 * _bcm_hr3_vlan_translate_stat_enable_set 278 * Purpose: 279 * Enable/disable collection of statistics on the indicated 280 * ingress VLAN translation. 281 * Parameters: 282 * unit - (IN) Unit number. 283 * port - (IN) Generic port 284 * key_type - (IN) Key Type : bcmVlanTranslateKey* 285 * outer_vlan - (IN) Packet outer VLAN ID 286 * inner_vlan - (IN) Packet inner VLAN ID 287 * enable - (IN) Non-zero to enable counter collection, zero to disable. 288 * Returns: 289 * BCM_E_xxx 290 * Notes: 291 */ 292 int 293 _bcm_hr3_vlan_translate_stat_enable_set(int unit, bcm_gport_t port, 294 bcm_vlan_translate_key_t key_type, 295 bcm_vlan_t outer_vlan, 296 bcm_vlan_t inner_vlan, 297 int enable) 298 { 299 soc_mem_t table=0; 300 uint32 index; 301 bcm_stat_object_t object=bcmStatObjectIngVlanXlate; 302 uint32 stat_counter_id; 303 uint32 num_entries = 0; 304 305 BCM_IF_ERROR_RETURN(_bcm_hr3_vlan_translate_stat_table_info_get( 306 unit, port, key_type, outer_vlan, inner_vlan, 307 &table, &index)); 308 309 if (enable) { 310 BCM_IF_ERROR_RETURN(bcm_esw_stat_group_create( 311 unit,object,bcmStatGroupModeSingle, 312 &stat_counter_id, 313 &num_entries)); 314 BCM_IF_ERROR_RETURN(bcm_esw_vlan_translate_stat_attach( 315 unit,port,key_type,outer_vlan,inner_vlan, 316 stat_counter_id)); 317 318 } else { 319 BCM_IF_ERROR_RETURN(_bcm_esw_flowcnt_stat_id_get( 320 unit, table, index, &stat_counter_id)); 321 BCM_IF_ERROR_RETURN(bcm_esw_vlan_translate_stat_detach( 322 unit,port,key_type,outer_vlan,inner_vlan)); 323 BCM_IF_ERROR_RETURN(bcm_esw_stat_group_destroy( 324 unit, stat_counter_id)); 325 326 } 327 return BCM_E_NONE; 328 } 329 330 /* 331 * Function: 332 * bcm_esw_vlan_translate_stat_id_get 333 * Description: 334 * Get stat counter id associated with given ingress vlan 335 * 336 * Parameters: 337 * unit - (IN) unit number 338 * Port - (IN) GPORT (global port) identifier 339 * key_type - (IN) VLAN translation key type 340 * outer_vlan - (IN) Outer VLAN ID or tag 341 * inner_vlan - (IN) Inner VLAN ID or tag 342 * stat - (IN) Type of the counter to retrieve 343 * I.e. ingress/egress byte/packet) 344 * Stat_counter_id - (OUT) Stat Counter ID 345 * Return Value: 346 * BCM_E_XXX 347 * Notes: 348 */ 349 int _bcm_hr3_vlan_translate_stat_id_get( 350 int unit, 351 bcm_gport_t port, 352 bcm_vlan_translate_key_t key_type, 353 bcm_vlan_t outer_vlan, 354 bcm_vlan_t inner_vlan, 355 bcm_vlan_stat_t stat, 356 uint32 *stat_counter_id) 357 { 358 soc_mem_t table=0; 359 uint32 index; 360 _bcm_flowcnt_stat_type_t stat_type; 361 362 BCM_IF_ERROR_RETURN(_bcm_hr3_vlan_translate_stat_table_info_get( 363 unit, port, key_type, outer_vlan, inner_vlan, 364 &table, &index)); 365 366 if (stat == bcmVlanStatIngressPackets) { 367 stat_type = bcmFlowcntStatTypePacket; 368 } else if (stat == bcmVlanStatIngressBytes){ 369 stat_type = bcmFlowcntStatTypeByte; 370 } else { 371 return BCM_E_PARAM; 372 } 373 BCM_IF_ERROR_RETURN(_bcm_esw_flowcnt_stat_type_validate( 374 unit, table, index, stat_type)); 375 376 return _bcm_esw_flowcnt_stat_id_get( 377 unit, table, index, stat_counter_id); 378 } 379 380 /* 381 * Function: 382 * _bcm_hr3_vlan_translate_egress_stat_table_info_get 383 * Description: 384 * Provides relevant flex table information(table-name,index) 385 * for given ingress vlan translation 386 * 387 * Parameters: 388 * unit - (IN) unit number 389 * port_class - (IN) Port class 390 * key_type - (IN) Key Type : bcmVlanTranslateKey* 391 * outer_vlan - (IN) Packet outer VLAN ID 392 * inner_vlan - (IN) Packet inner VLAN ID 393 * table - (OUT) accounting object table 394 * index - (OUT) accounting object table index 395 * 396 * Return Value: 397 * BCM_E_XXX 398 * Notes: 399 */ 400 STATIC int 401 _bcm_hr3_vlan_translate_egress_stat_table_info_get( 402 int unit, 403 int port_class, 404 bcm_vlan_t outer_vlan, 405 bcm_vlan_t inner_vlan, 406 soc_mem_t *table, 407 uint32 *index) 408 { 409 int rv=BCM_E_NONE; 410 egr_vlan_xlate_entry_t vent={{0}}; 411 egr_vlan_xlate_entry_t egr_vlan_xlate_entry={{0}}; 412 int idx=0; 413 soc_mem_t mem; 414 bcm_module_t modid=0; 415 bcm_trunk_t tgid = -1; 416 int id = -1; 417 418 if (BCM_GPORT_IS_SET(port_class)) { 419 if (!BCM_GPORT_IS_TUNNEL(port_class)) { 420 BCM_IF_ERROR_RETURN(_bcm_esw_gport_resolve( 421 unit, port_class, &modid, 422 &port_class,&tgid, &id)); 423 } 424 if ((-1 != tgid || -1 != id) && !BCM_GPORT_IS_TUNNEL(port_class)) { 425 return BCM_E_PORT; 426 } 427 } else { 428 if (!SOC_PORT_CLASS_VALID(unit, port_class)) { 429 return BCM_E_PORT; 430 } 431 } 432 433 mem = EGR_VLAN_XLATEm; 434 /* get table and its index */ 435 sal_memset(&vent, 0, sizeof(egr_vlan_xlate_entry_t)); 436 BCM_IF_ERROR_RETURN (_bcm_trx_vlan_translate_egress_entry_assemble( 437 unit, &vent, port_class, outer_vlan, inner_vlan)); 438 soc_mem_lock(unit, mem); 439 rv = soc_mem_search(unit, mem, MEM_BLOCK_ALL, &idx, &vent, 440 &egr_vlan_xlate_entry, 0); 441 soc_mem_unlock(unit, mem); 442 443 if (BCM_SUCCESS(rv)) { 444 *table = mem; 445 *index = idx; 446 } 447 return rv; 448 } 449 450 /* 451 * Function: 452 * _bcm_hr3_vlan_translate_egress_stat_attach 453 * Description: 454 * Attach counters for the given egress vlan translation table 455 * 456 * Parameters: 457 * unit - (IN) unit number 458 * port_class - (IN) Port class 459 * outer_vlan - (IN) Outer VLAN ID 460 * inner_vlan - (IN) Inner VLAN ID 461 * Stat_counter_id - (IN) Stat Counter ID. 462 * 463 * Return Value: 464 * BCM_E_XXX 465 * Notes: 466 */ 467 int 468 _bcm_hr3_vlan_translate_egress_stat_attach( 469 int unit, 470 int port_class, 471 bcm_vlan_t outer_vlan, 472 bcm_vlan_t inner_vlan, 473 uint32 stat_counter_id) 474 { 475 bcm_stat_group_mode_t group_mode = bcmStatGroupModeSingle; 476 bcm_stat_object_t object = bcmStatObjectIngPort; 477 uint32 profile_group, pool_index, base_index; 478 soc_mem_t table=0; 479 uint32 index; 480 481 _bcm_esw_flowcnt_counter_id_get(stat_counter_id, &group_mode, &object, 482 &profile_group, &pool_index, &base_index); 483 484 BCM_IF_ERROR_RETURN(_bcm_hr3_vlan_translate_egress_stat_table_info_get( 485 unit, port_class, outer_vlan, inner_vlan, 486 &table, &index)); 487 488 return _bcm_esw_flowcnt_object_table_attach( 489 unit, object, table, index, profile_group, base_index, 490 pool_index, NULL); 491 492 } 493 494 /* 495 * Function: 496 * _bcm_hr3_vlan_translate_egress_stat_counter_get 497 * Description: 498 * Get counter values from egress vlan translation table 499 * if sync_mode is set, sync the sw accumulated count 500 * with hw count value first, else return sw count. 501 * 502 * Parameters: 503 * unit - (IN) unit number 504 * sync_mode - (IN) hwcount is to be synced to sw count 505 * port_class - (IN) Port class 506 * outer_vlan - (IN) Outer VLAN ID 507 * inner_vlan - (IN) Inner VLAN ID 508 * stat - (IN) Type of the counter to retrieve 509 * I.e. ingress/egress byte/packet) 510 * num_entries - (IN) Number of counter Entries 511 * counter_indexes - (IN) Pointer to Counter indexes entries 512 * counter_values - (OUT) Pointer to counter values 513 * 514 * Return Value: 515 * BCM_E_XXX 516 * Notes: 517 */ 518 int 519 _bcm_hr3_vlan_translate_egress_stat_counter_get( 520 int unit, 521 int sync_mode, 522 int port_class, 523 bcm_vlan_t outer_vlan, 524 bcm_vlan_t inner_vlan, 525 bcm_vlan_stat_t stat, 526 uint32 num_entries, 527 uint32 *counter_indexes, 528 bcm_stat_value_t *counter_values) 529 { 530 uint32 byte_flag=0; 531 uint32 index_count=0; 532 soc_mem_t table=0; 533 uint32 index; 534 535 if ((stat == bcmVlanStatIngressPackets) || 536 (stat == bcmVlanStatEgressPackets)) { 537 byte_flag=0; 538 } else { 539 byte_flag=1; 540 } 541 542 BCM_IF_ERROR_RETURN(_bcm_hr3_vlan_translate_egress_stat_table_info_get( 543 unit, port_class, outer_vlan, inner_vlan, 544 &table, &index)); 545 546 for (index_count=0; index_count < num_entries ; index_count++) { 547 BCM_IF_ERROR_RETURN(_bcm_esw_flowcnt_counter_get( 548 unit, sync_mode, index, table, byte_flag, 549 counter_indexes[index_count], 550 &counter_values[index_count])); 551 } 552 return BCM_E_NONE; 553 554 } 555 556 /* 557 * Function: 558 * _bcm_hr3_vlan_translate_egress_stat_counter_set 559 * Description: 560 * Set counter values from egress vlan translation table . 561 * 562 * Parameters: 563 * unit - (IN) unit number 564 * port_class - (IN) Port class 565 * outer_vlan - (IN) Outer VLAN ID 566 * inner_vlan - (IN) Inner VLAN ID 567 * stat - (IN) Type of the counter to retrieve 568 * I.e. ingress/egress byte/packet) 569 * num_entries - (IN) Number of counter Entries 570 * counter_indexes - (IN) Pointer to Counter indexes entries 571 * counter_values - (IN) Pointer to counter values 572 * 573 * Return Value: 574 * BCM_E_XXX 575 * Notes: 576 */ 577 int 578 _bcm_hr3_vlan_translate_egress_stat_counter_set( 579 int unit, 580 int port_class, 581 bcm_vlan_t outer_vlan, 582 bcm_vlan_t inner_vlan, 583 bcm_vlan_stat_t stat, 584 uint32 num_entries, 585 uint32 *counter_indexes, 586 bcm_stat_value_t *counter_values) 587 { 588 589 uint32 byte_flag=0; 590 uint32 index_count=0; 591 soc_mem_t table=0; 592 uint32 index; 593 594 if ((stat == bcmVlanStatIngressPackets) || 595 (stat == bcmVlanStatEgressPackets)) { 596 byte_flag=0; 597 } else { 598 byte_flag=1; 599 } 600 601 BCM_IF_ERROR_RETURN(_bcm_hr3_vlan_translate_egress_stat_table_info_get( 602 unit, port_class, outer_vlan, inner_vlan, 603 &table, &index)); 604 605 for (index_count=0; index_count < num_entries ; index_count++) { 606 BCM_IF_ERROR_RETURN(_bcm_esw_flowcnt_counter_set( 607 unit, index, table, byte_flag, 608 counter_indexes[index_count], 609 &counter_values[index_count])); 610 } 611 return BCM_E_NONE; 612 } 613 614 /* 615 * Function: 616 * _bcm_hr3_vlan_translate_egress_stat_id_get 617 * Description: 618 * Get stat counter id associated with given egress vlan 619 * 620 * Parameters: 621 * unit - (IN) unit number 622 * port_class - (IN) Port class 623 * outer_vlan - (IN) Outer VLAN ID 624 * inner_vlan - (IN) Inner VLAN ID 625 * stat - (IN) Type of the counter to retrieve 626 * I.e. ingress/egress byte/packet) 627 * Stat_counter_id - (OUT) Stat Counter ID 628 * 629 * Return Value: 630 * BCM_E_XXX 631 * Notes: 632 */ 633 int _bcm_hr3_vlan_translate_egress_stat_id_get( 634 int unit, 635 int port_class, 636 bcm_vlan_t outer_vlan, 637 bcm_vlan_t inner_vlan, 638 bcm_vlan_stat_t stat, 639 uint32 *stat_counter_id) 640 { 641 soc_mem_t table=0; 642 uint32 index; 643 _bcm_flowcnt_stat_type_t stat_type; 644 645 646 BCM_IF_ERROR_RETURN(_bcm_hr3_vlan_translate_egress_stat_table_info_get( 647 unit, port_class, outer_vlan, inner_vlan, 648 &table, &index)); 649 650 if (stat == bcmVlanStatIngressPackets) { 651 stat_type = bcmFlowcntStatTypePacket; 652 } else if (stat == bcmVlanStatIngressBytes){ 653 stat_type = bcmFlowcntStatTypeByte; 654 } else { 655 return BCM_E_PARAM; 656 } 657 BCM_IF_ERROR_RETURN(_bcm_esw_flowcnt_stat_type_validate( 658 unit, table, index, stat_type)); 659 660 return _bcm_esw_flowcnt_stat_id_get( 661 unit, table, index, stat_counter_id); 662 663 } 664 665 /* 666 * Function: 667 * _bcm_hr3_vlan_translate_egress_stat_detach 668 * Description: 669 * Detach counters for the given egress vlan translation table 670 * 671 * Parameters: 672 * unit - (IN) unit number 673 * port_class - (IN) Port class 674 * outer_vlan - (IN) Outer VLAN ID 675 * inner_vlan - (IN) Inner VLAN ID 676 * 677 * Return Value: 678 * BCM_E_XXX 679 * Notes: 680 */ 681 int _bcm_hr3_vlan_translate_egress_stat_detach( 682 int unit, 683 int port_class, 684 bcm_vlan_t outer_vlan, 685 bcm_vlan_t inner_vlan) 686 { 687 soc_mem_t table=0; 688 uint32 index; 689 690 BCM_IF_ERROR_RETURN(_bcm_hr3_vlan_translate_egress_stat_table_info_get( 691 unit, port_class, outer_vlan, inner_vlan, 692 &table, &index)); 693 694 return _bcm_esw_flowcnt_object_table_detach(unit, table, index); 695 696 } 697 698 699 /* 700 * Function: 701 * _bcm_hr3_vlan_translate_egress_stat_enable_set 702 * Purpose: 703 * Enable/disable collection of statistics on the indicated 704 * egress VLAN translation. 705 * Parameters: 706 * unit - (IN) Unit number. 707 * port_class - (IN) Group ID of ingress port 708 * outer_vlan - (IN) Packet outer VLAN ID 709 * inner_vlan - (IN) Packet inner VLAN ID 710 * enable - (IN) Non-zero to enable counter collection, zero to disable. 711 * Returns: 712 * BCM_E_xxx 713 * Notes: 714 */ 715 int 716 _bcm_hr3_vlan_translate_egress_stat_enable_set(int unit, int port_class, 717 bcm_vlan_t outer_vlan, 718 bcm_vlan_t inner_vlan, 719 int enable) 720 { 721 soc_mem_t table=0; 722 uint32 index; 723 bcm_stat_object_t object=bcmStatObjectEgrVlanXlate; 724 uint32 stat_counter_id; 725 uint32 num_entries = 0; 726 727 728 BCM_IF_ERROR_RETURN(_bcm_hr3_vlan_translate_egress_stat_table_info_get( 729 unit, port_class, outer_vlan, inner_vlan, 730 &table, &index)); 731 732 if (enable) { 733 BCM_IF_ERROR_RETURN(bcm_esw_stat_group_create( 734 unit,object,bcmStatGroupModeSingle, 735 &stat_counter_id, 736 &num_entries)); 737 BCM_IF_ERROR_RETURN(bcm_esw_vlan_translate_egress_stat_attach( 738 unit, port_class, outer_vlan, inner_vlan, 739 stat_counter_id)); 740 741 } else { 742 BCM_IF_ERROR_RETURN(_bcm_esw_flowcnt_stat_id_get( 743 unit, table, index, &stat_counter_id)); 744 BCM_IF_ERROR_RETURN(bcm_esw_vlan_translate_egress_stat_detach( 745 unit, port_class, outer_vlan, inner_vlan)); 746 BCM_IF_ERROR_RETURN(bcm_esw_stat_group_destroy( 747 unit, stat_counter_id)); 748 749 } 750 return BCM_E_NONE; 751 }