flowtracker.c (109409B)
1 /* 2 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 3 * 4 * Copyright 2007-2019 Broadcom Inc. All rights reserved. 5 */ 6 7 #include <shared/bslenum.h> 8 #include <shared/bsl.h> 9 10 #include <soc/defs.h> 11 #include <soc/drv.h> 12 13 #include <bcm/error.h> 14 #include <bcm/flowtracker.h> 15 #include <bcm/collector.h> 16 17 #include <bcm_int/esw/xgs5.h> 18 #include <bcm_int/esw/tomahawk.h> 19 #include <bcm_int/esw/trident3.h> 20 21 #if defined (BCM_FLOWTRACKER_SUPPORT) 22 #include <bcm_int/esw/flowtracker/ft_group.h> 23 #include <bcm_int/esw/flowtracker/ft_export.h> 24 #include <bcm_int/esw/flowtracker/ft_user.h> 25 #endif /* BCM_FLOWTRACKER_SUPPORT */ 26 27 static sal_mutex_t mutex[BCM_MAX_NUM_UNITS]; 28 29 int bcm_esw_flowtracker_lock(int unit) 30 { 31 if (mutex[unit] == NULL) 32 { 33 return BCM_E_INIT; 34 } 35 36 sal_mutex_take(mutex[unit], sal_mutex_FOREVER); 37 38 return BCM_E_NONE; 39 } 40 41 int bcm_esw_flowtracker_unlock(int unit) 42 { 43 if (mutex[unit] == NULL) 44 { 45 return BCM_E_INIT; 46 } 47 48 if (sal_mutex_give(mutex[unit]) != 0) 49 { 50 return BCM_E_INTERNAL; 51 } 52 53 return BCM_E_NONE; 54 } 55 56 /* 57 * Function: 58 * bcm_esw_flowtracker_init 59 * Purpose: 60 * Initialize the Flowtracker subsystem. 61 * Parameters: 62 * unit - (IN) BCM device number 63 * Returns: 64 * BCM_E_XXX - BCM error code. 65 */ 66 int bcm_esw_flowtracker_init(int unit) 67 { 68 int result = BCM_E_UNAVAIL; 69 70 /* Create mutex */ 71 if (mutex[unit] == NULL) 72 { 73 mutex[unit] = sal_mutex_create("ft.mutex"); 74 75 if (mutex[unit] == NULL) 76 { 77 return BCM_E_MEMORY; 78 } 79 } 80 81 /* Learning and exporting features via UC are both 82 * supported together only on TH series platforms. 83 * Call TH flowtracker APIs. 84 */ 85 #if defined(INCLUDE_FLOWTRACKER) 86 if ((soc_feature(unit, soc_feature_uc_flowtracker_learn) && 87 soc_feature(unit, soc_feature_uc_flowtracker_export)) || 88 soc_feature(unit, soc_feature_mv2_style_flowtracker)) { 89 result = _bcm_th_ft_init(unit); 90 } else 91 #endif /* INCLUDE_FLOWTRACKER */ 92 #if defined(BCM_FLOWTRACKER_SUPPORT) 93 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 94 result = bcmi_ft_init(unit); 95 } else 96 #endif /* BCM_FLOWTRACKER_SUPPORT */ 97 { 98 /* If flowtracker is not supported then just return. */ 99 sal_mutex_destroy(mutex[unit]); 100 mutex[unit] = NULL; 101 102 return BCM_E_NONE; 103 } 104 105 /* If init itself fails, there is no point in having the mutex. 106 * Destroy it. 107 */ 108 if (BCM_FAILURE(result)) 109 { 110 sal_mutex_destroy(mutex[unit]); 111 112 mutex[unit] = NULL; 113 } 114 115 return result; 116 } 117 118 119 /* Shut down the Flowtracker subsystem. */ 120 int bcm_esw_flowtracker_detach(int unit) 121 { 122 int result = BCM_E_UNAVAIL; 123 /* Learning and exporting features via UC are both 124 * supported together only on TH series platforms. 125 * Call TH flowtracker APIs. 126 */ 127 #if defined(INCLUDE_FLOWTRACKER) 128 if ((soc_feature(unit, soc_feature_uc_flowtracker_learn) && 129 soc_feature(unit, soc_feature_uc_flowtracker_export)) || 130 soc_feature(unit, soc_feature_mv2_style_flowtracker)) { 131 /* Take lock */ 132 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 133 result= _bcm_th_ft_detach(unit); 134 /* Release lock */ 135 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 136 } else 137 #endif /* INCLUDE_FLOWTRACKER */ 138 #if defined(BCM_FLOWTRACKER_SUPPORT) 139 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 140 /* Take lock */ 141 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 142 result = bcmi_ft_cleanup(unit); 143 /* Release lock */ 144 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 145 } else 146 #endif /* bcmi_ft_export_state_clear */ 147 { 148 /* If FT is not yet supported then do not do anything. */ 149 return BCM_E_NONE; 150 } 151 152 return result; 153 } 154 155 /* 156 * Function: 157 * bcm_flowtracker_export_template_validate 158 * Purpose: 159 * Validate the template and return the list supported by the 160 * device. 161 * Parameters: 162 * unit - (IN) Unit number. 163 * flow_group_id - (IN) Flowtracker flow group software ID. 164 * num_in_export_elements - (IN) Number of export elements intended in the tempate. 165 * in_export_elements - (IN) List of export elements intended to be in the template. 166 * num_out_export_elements - (IN/OUT) Number of export elements in the supportable tempate. 167 * out_export_elements - (OUT) List of export elements in the template supportable by hardware. 168 * Returns: 169 * BCM_E_xxx 170 * Notes: 171 */ 172 int 173 bcm_esw_flowtracker_export_template_validate( 174 int unit, 175 bcm_flowtracker_group_t flow_group_id, 176 int max_in_export_elements, 177 bcm_flowtracker_export_element_info_t *in_export_elements, 178 int max_out_export_elements, 179 bcm_flowtracker_export_element_info_t *out_export_elements, 180 int *actual_out_export_elements) 181 { 182 int result = BCM_E_UNAVAIL; 183 184 #if defined(BCM_FLOWTRACKER_SUPPORT) 185 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 186 187 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 188 result = bcmi_ft_export_template_validate(unit, 189 flow_group_id, 190 max_in_export_elements, 191 in_export_elements, 192 max_out_export_elements, 193 out_export_elements, 194 actual_out_export_elements); 195 } 196 /* Release lock */ 197 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 198 #endif 199 200 return result; 201 } 202 203 /* 204 * Function: 205 * bcm_esw_flowtracker_export_template_create 206 * Purpose: 207 * Create an export template 208 * Parameters: 209 * unit - (IN) BCM device number 210 * options - (IN) Template create options 211 * id - (INOUT) Template Id 212 * set_id - (IN) set_id to be used for the template 213 * num_export_elements - (IN) Number of elements in the template 214 * list_of_export_elements - (IN) Export element list 215 * Returns: 216 * BCM_E_XXX - BCM error code. 217 */ 218 int bcm_esw_flowtracker_export_template_create( 219 int unit, 220 uint32 options, 221 bcm_flowtracker_export_template_t *id, 222 uint16 set_id, 223 int num_export_elements, 224 bcm_flowtracker_export_element_info_t *list_of_export_elements) 225 { 226 int result = BCM_E_UNAVAIL; 227 /* Take lock */ 228 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 229 /* Learning and exporting features via UC are both 230 * supported together only on TH series platforms. 231 * Call TH flowtracker APIs. 232 */ 233 #if defined(INCLUDE_FLOWTRACKER) 234 if ((soc_feature(unit, soc_feature_uc_flowtracker_learn) && 235 soc_feature(unit, soc_feature_uc_flowtracker_export)) || 236 soc_feature(unit, soc_feature_mv2_style_flowtracker)) { 237 result = _bcm_th_ft_export_template_create(unit, 238 options, 239 id, 240 set_id, 241 num_export_elements, 242 list_of_export_elements); 243 } else 244 #endif 245 #if defined(BCM_FLOWTRACKER_SUPPORT) 246 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 247 result = bcmi_ft_template_create(unit, 248 options, 249 id, 250 set_id, 251 num_export_elements, 252 list_of_export_elements); 253 } else 254 #endif /* BCM_FLOWTRACKER_SUPPORT */ 255 { 256 result = BCM_E_UNAVAIL; 257 } 258 259 /* Release lock */ 260 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 261 return result; 262 } 263 264 /* 265 * Function: 266 * bcm_esw_flowtracker_export_template_get 267 * Purpose: 268 * Get a flowtracker export template with ID. 269 * Parameters: 270 * unit - (IN) BCM device number 271 * id - (IN) Template Id 272 * set_id - (OUT) Set Id of the template 273 * max_size - (IN) Size of the export element list array 274 * list_of_export_elements - (OUT) Export element list 275 * list_size - (OUT) Number of elements in the list 276 * Returns: 277 * BCM_E_XXX - BCM error code. 278 */ 279 int bcm_esw_flowtracker_export_template_get( 280 int unit, 281 bcm_flowtracker_export_template_t id, 282 uint16 *set_id, 283 int max_size, 284 bcm_flowtracker_export_element_info_t *list_of_export_elements, 285 int *list_size) 286 { 287 int result = BCM_E_UNAVAIL; 288 /* Take lock */ 289 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 290 /* Learning and exporting features via UC are both 291 * supported together only on TH series platforms. 292 * Call TH flowtracker APIs. 293 */ 294 #if defined(INCLUDE_FLOWTRACKER) 295 if ((soc_feature(unit, soc_feature_uc_flowtracker_learn) && 296 soc_feature(unit, soc_feature_uc_flowtracker_export)) || 297 soc_feature(unit, soc_feature_mv2_style_flowtracker)) { 298 result = _bcm_th_ft_export_template_get(unit, 299 id, 300 set_id, 301 max_size, 302 list_of_export_elements, 303 list_size); 304 } else 305 #endif 306 #if defined(BCM_FLOWTRACKER_SUPPORT) 307 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 308 result = bcmi_ft_template_get(unit, 309 id, 310 set_id, 311 max_size, 312 list_of_export_elements, 313 list_size); 314 } else 315 #endif /* BCM_FLOWTRACKER_SUPPORT */ 316 { 317 result = BCM_E_UNAVAIL; 318 } 319 320 /* Release lock */ 321 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 322 return result; 323 } 324 325 /* 326 * Function: 327 * bcm_esw_flowtracker_export_template_destroy 328 * Purpose: 329 * Destroy a flowtracker export template 330 * Parameters: 331 * unit - (IN) BCM device number 332 * id - (IN) Template Id 333 * Returns: 334 * BCM_E_XXX - BCM error code. 335 */ 336 int bcm_esw_flowtracker_export_template_destroy( 337 int unit, 338 bcm_flowtracker_export_template_t id) 339 { 340 int result = BCM_E_UNAVAIL; 341 /* Take lock */ 342 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 343 /* Learning and exporting features via UC are both 344 * supported together only on TH series platforms. 345 * Call TH flowtracker APIs. 346 */ 347 #if defined(INCLUDE_FLOWTRACKER) 348 if ((soc_feature(unit, soc_feature_uc_flowtracker_learn) && 349 soc_feature(unit, soc_feature_uc_flowtracker_export)) || 350 soc_feature(unit, soc_feature_mv2_style_flowtracker)) { 351 result= _bcm_th_ft_export_template_destroy(unit, 352 id); 353 } else 354 #endif 355 #if defined(BCM_FLOWTRACKER_SUPPORT) 356 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 357 result = bcmi_ft_template_destroy(unit, id); 358 } else 359 #endif /* BCM_FLOWTRACKER_SUPPORT */ 360 { 361 result = BCM_E_UNAVAIL; 362 } 363 364 /* Release lock */ 365 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 366 return result; 367 } 368 369 370 /* 371 * Function: 372 * bcm_esw_flowtracker_collector_create 373 * Purpose: 374 * Create a flowtracker collector with given collector info. 375 * Parameters: 376 * unit - (IN) BCM device number 377 * options - (IN) Collector create options 378 * id - (INOUT) Collector Id 379 * collector_info - (IN) Collector info 380 * Returns: 381 * BCM_E_XXX - BCM error code. 382 */ 383 int bcm_esw_flowtracker_collector_create( 384 int unit, 385 uint32 options, 386 bcm_flowtracker_collector_t *collector_id, 387 bcm_flowtracker_collector_info_t *collector_info) 388 { 389 int result = BCM_E_UNAVAIL; 390 /* Take lock */ 391 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 392 /* Learning and exporting features via UC are both 393 * supported together only on TH series platforms. 394 * Call TH flowtracker APIs. 395 */ 396 #if defined(INCLUDE_FLOWTRACKER) 397 if ((soc_feature(unit, soc_feature_uc_flowtracker_learn) && 398 soc_feature(unit, soc_feature_uc_flowtracker_export)) || 399 soc_feature(unit, soc_feature_mv2_style_flowtracker)) { 400 result = _bcm_th_ft_collector_create(unit, options, 401 collector_id, 402 collector_info); 403 } else 404 #endif 405 { 406 result = BCM_E_UNAVAIL; 407 } 408 409 /* Release lock */ 410 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 411 return result; 412 } 413 414 /* 415 * Function: 416 * bcm_esw_flowtracker_collector_get 417 * Purpose: 418 * Get flowtracker collector information 419 * Parameters: 420 * unit - (IN) BCM device number 421 * id - (IN) Collector Id 422 * collector_info - (OUT) Collector info 423 * Returns: 424 * BCM_E_XXX - BCM error code. 425 */ 426 int bcm_esw_flowtracker_collector_get( 427 int unit, 428 bcm_flowtracker_collector_t id, 429 bcm_flowtracker_collector_info_t *collector_info) 430 { 431 int result = BCM_E_UNAVAIL; 432 /* Take lock */ 433 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 434 /* Learning and exporting features via UC are both 435 * supported together only on TH series platforms. 436 * Call TH flowtracker APIs. 437 */ 438 #if defined(INCLUDE_FLOWTRACKER) 439 if ((soc_feature(unit, soc_feature_uc_flowtracker_learn) && 440 soc_feature(unit, soc_feature_uc_flowtracker_export)) || 441 soc_feature(unit, soc_feature_mv2_style_flowtracker)) { 442 result = _bcm_th_ft_collector_get(unit, id, 443 collector_info); 444 } else 445 #endif 446 { 447 result = BCM_E_UNAVAIL; 448 } 449 450 /* Release lock */ 451 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 452 return result; 453 } 454 455 456 /* 457 * Function: 458 * bcm_esw_flowtracker_collector_get_all 459 * Purpose: 460 * Get the list of all flowtracker collector Ids configured. 461 * Parameters: 462 * unit - (IN) BCM device number 463 * max_size - (IN) Size of the collector list array 464 * collector_list - (OUT) List of collector Ids configured 465 * list_size - (OUT) NUmber of elements in the list 466 * Returns: 467 * BCM_E_XXX - BCM error code. 468 */ 469 int bcm_esw_flowtracker_collector_get_all( 470 int unit, 471 int max_size, 472 bcm_flowtracker_collector_t *collector_list, 473 int *list_size) 474 { 475 int result = BCM_E_UNAVAIL; 476 477 /* Take lock */ 478 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 479 /* Learning and exporting features via UC are both 480 * supported together only on TH series platforms. 481 * Call TH flowtracker APIs. 482 */ 483 #if defined(INCLUDE_FLOWTRACKER) 484 if ((soc_feature(unit, soc_feature_uc_flowtracker_learn) && 485 soc_feature(unit, soc_feature_uc_flowtracker_export)) || 486 soc_feature(unit, soc_feature_mv2_style_flowtracker)) { 487 result = _bcm_th_ft_collector_get_all(unit, 488 max_size, 489 collector_list, 490 list_size); 491 } else 492 #endif 493 { 494 result = BCM_E_UNAVAIL; 495 } 496 497 /* Release lock */ 498 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 499 500 return result; 501 } 502 503 /* 504 * Function: 505 * bcm_esw_flowtracker_collector_destroy 506 * Purpose: 507 * Destroy a flowtracker collector 508 * Parameters: 509 * unit - (IN) BCM device number 510 * collector_id - (IN) Collector Id 511 * Returns: 512 * BCM_E_XXX - BCM error code. 513 */ 514 int bcm_esw_flowtracker_collector_destroy( 515 int unit, 516 bcm_flowtracker_collector_t id) 517 { 518 int result = BCM_E_UNAVAIL; 519 /* Take lock */ 520 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 521 /* Learning and exporting features via UC are both 522 * supported together only on TH series platforms. 523 * Call TH flowtracker APIs. 524 */ 525 #if defined(INCLUDE_FLOWTRACKER) 526 if ((soc_feature(unit, soc_feature_uc_flowtracker_learn) && 527 soc_feature(unit, soc_feature_uc_flowtracker_export)) || 528 soc_feature(unit, soc_feature_mv2_style_flowtracker)) { 529 result= _bcm_th_ft_collector_destroy(unit, id); 530 } else 531 #endif 532 { 533 result = BCM_E_UNAVAIL; 534 } 535 536 /* Release lock */ 537 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 538 return result; 539 } 540 541 /* 542 * Function: 543 * bcm_esw_flowtracker_group_create 544 * Purpose: 545 * Create a flowtracker flow group 546 * Parameters: 547 * unit - (IN) BCM device number 548 * options - (IN) Group create options 549 * id - (INOUT) Group Id 550 * flow_group_info - (IN) Group Info 551 * Returns: 552 * BCM_E_XXX - BCM error code. 553 */ 554 int bcm_esw_flowtracker_group_create( 555 int unit, 556 uint32 options, 557 bcm_flowtracker_group_t *flow_group_id, 558 bcm_flowtracker_group_info_t *flow_group_info) 559 { 560 int result = BCM_E_UNAVAIL; 561 /* Take lock */ 562 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 563 /* Learning and exporting features via UC are both 564 * supported together only on TH series platforms. 565 * Call TH flowtracker APIs. 566 */ 567 #if defined(INCLUDE_FLOWTRACKER) 568 if ((soc_feature(unit, soc_feature_uc_flowtracker_learn) && 569 soc_feature(unit, soc_feature_uc_flowtracker_export)) || 570 soc_feature(unit, soc_feature_mv2_style_flowtracker)) { 571 result = _bcm_th_ft_flow_group_create(unit, options, 572 flow_group_id, 573 flow_group_info); 574 } else 575 #endif 576 #if defined(BCM_FLOWTRACKER_SUPPORT) 577 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 578 result = bcmi_ft_group_create(unit, options, 579 flow_group_id, 580 flow_group_info); 581 } else 582 #endif 583 { 584 return (BCM_E_UNAVAIL); 585 } 586 587 /* Release lock */ 588 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 589 return result; 590 } 591 592 /* 593 * Function: 594 * bcm_esw_flowtracker_group_get 595 * Purpose: 596 * Get flowtracker flow group information 597 * Parameters: 598 * unit - (IN) BCM device number 599 * id - (IN) Group Id 600 * flow_group_info - (OUT) Group Info 601 * Returns: 602 * BCM_E_XXX - BCM error code. 603 */ 604 int bcm_esw_flowtracker_group_get( 605 int unit, 606 bcm_flowtracker_group_t id, 607 bcm_flowtracker_group_info_t *flow_group_info) 608 { 609 int result = BCM_E_UNAVAIL; 610 /* Take lock */ 611 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 612 /* Learning and exporting features via UC are both 613 * supported together only on TH series platforms. 614 * Call TH flowtracker APIs. 615 */ 616 #if defined(INCLUDE_FLOWTRACKER) 617 if ((soc_feature(unit, soc_feature_uc_flowtracker_learn) && 618 soc_feature(unit, soc_feature_uc_flowtracker_export)) || 619 soc_feature(unit, soc_feature_mv2_style_flowtracker)) { 620 result= _bcm_th_ft_flow_group_get(unit, id, 621 flow_group_info); 622 } else 623 #endif 624 #if defined(BCM_FLOWTRACKER_SUPPORT) 625 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 626 result = bcmi_ft_group_get(unit, id, flow_group_info); 627 } else 628 #endif 629 { 630 return (BCM_E_UNAVAIL); 631 } 632 633 /* Release lock */ 634 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 635 return result; 636 } 637 638 /* 639 * Function: 640 * bcm_esw_flowtracker_group_get_all 641 * Purpose: 642 * Get list of all flow groups created 643 * Parameters: 644 * unit - (IN) BCM device number 645 * max_size - (IN) Size of the flow group list array 646 * flow_group_list - (OUT) List of flow groups created 647 * list_size - (OUT) Number of flow grups in the list 648 * Returns: 649 * BCM_E_XXX - BCM error code. 650 */ 651 int bcm_esw_flowtracker_group_get_all( 652 int unit, 653 int max_size, 654 bcm_flowtracker_group_t *flow_group_list, 655 int *list_size) 656 { 657 int result = BCM_E_UNAVAIL; 658 /* Take lock */ 659 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 660 /* Learning and exporting features via UC are both 661 * supported together only on TH series platforms. 662 * Call TH flowtracker APIs. 663 */ 664 #if defined(INCLUDE_FLOWTRACKER) 665 if ((soc_feature(unit, soc_feature_uc_flowtracker_learn) && 666 soc_feature(unit, soc_feature_uc_flowtracker_export)) || 667 soc_feature(unit, soc_feature_mv2_style_flowtracker)) { 668 result = _bcm_th_ft_flow_group_get_all(unit, 669 max_size, 670 flow_group_list, 671 list_size); 672 } else 673 #endif 674 #if defined(BCM_FLOWTRACKER_SUPPORT) 675 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 676 result = bcmi_ft_group_get_all(unit, 677 max_size, flow_group_list, list_size); 678 } else 679 #endif 680 { 681 return (BCM_E_UNAVAIL); 682 } 683 684 /* Release lock */ 685 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 686 return result; 687 } 688 689 /* 690 * Function: 691 * bcm_esw_flowtracker_group_flow_limit_set 692 * Purpose: 693 * Set flow limit on the flow group 694 * Parameters: 695 * unit - (IN) BCM device number 696 * id - (IN) Flow group Id 697 * flow_limit - (IN) Max number of flows that can be learnt on the group 698 * Returns: 699 * BCM_E_XXX - BCM error code. 700 */ 701 int bcm_esw_flowtracker_group_flow_limit_set( 702 int unit, 703 bcm_flowtracker_group_t id, 704 uint32 flow_limit) 705 { 706 int result = BCM_E_UNAVAIL; 707 /* Take lock */ 708 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 709 /* Learning and exporting features via UC are both 710 * supported together only on TH series platforms. 711 * Call TH flowtracker APIs. 712 */ 713 #if defined(INCLUDE_FLOWTRACKER) 714 if ((soc_feature(unit, soc_feature_uc_flowtracker_learn) && 715 soc_feature(unit, soc_feature_uc_flowtracker_export)) || 716 soc_feature(unit, soc_feature_mv2_style_flowtracker)) { 717 result = _bcm_th_ft_flow_group_flow_limit_set(unit, id, 718 flow_limit); 719 } else 720 #endif 721 #if defined(BCM_FLOWTRACKER_SUPPORT) 722 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 723 result = bcmi_ft_group_flow_limit_set(unit, id, flow_limit); 724 } else 725 #endif 726 { 727 return (BCM_E_UNAVAIL); 728 } 729 730 /* Release lock */ 731 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 732 return result; 733 } 734 735 /* 736 * Function: 737 * bcm_esw_ft_flow_group_flow_limit_get 738 * Purpose: 739 * Get flow limit of the flow group 740 * Parameters: 741 * unit - (IN) BCM device number 742 * id - (IN) Flow group Id 743 * flow_limit - (OUT) Flow limit 744 * Returns: 745 * BCM_E_XXX - BCM error code. 746 */ 747 int bcm_esw_flowtracker_group_flow_limit_get( 748 int unit, 749 bcm_flowtracker_group_t id, 750 uint32 *flow_limit) 751 { 752 int result = BCM_E_UNAVAIL; 753 /* Take lock */ 754 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 755 /* Learning and exporting features via UC are both 756 * supported together only on TH series platforms. 757 * Call TH flowtracker APIs. 758 */ 759 #if defined(INCLUDE_FLOWTRACKER) 760 if ((soc_feature(unit, soc_feature_uc_flowtracker_learn) && 761 soc_feature(unit, soc_feature_uc_flowtracker_export)) || 762 soc_feature(unit, soc_feature_mv2_style_flowtracker)) { 763 result = _bcm_th_ft_flow_group_flow_limit_get(unit, id, 764 flow_limit); 765 } else 766 #endif 767 #if defined(BCM_FLOWTRACKER_SUPPORT) 768 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 769 result = bcmi_ft_group_flow_limit_get(unit, id, flow_limit); 770 } else 771 #endif 772 { 773 return (BCM_E_UNAVAIL); 774 } 775 776 /* Release lock */ 777 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 778 return result; 779 } 780 781 /* 782 * Function: 783 * bcm_esw_flowtracker_group_stat_modeid_set 784 * Purpose: 785 * Set stat mode id to provided flow tracker group. 786 * Parameters: 787 * unit - (IN) BCM device number 788 * id - (IN) Flow group Id 789 * stat_modeid - (IN) Stat Mode Id 790 * Returns: 791 * BCM_E_XXX - BCM error code. 792 */ 793 int bcm_esw_flowtracker_group_stat_modeid_set(int unit, 794 bcm_flowtracker_group_t id, 795 uint32 stat_modeid) 796 { 797 int result = BCM_E_UNAVAIL; 798 /* Take lock */ 799 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 800 /* Set stat modeid created using flex stat api */ 801 #if defined(INCLUDE_FLOWTRACKER) 802 if (soc_feature(unit, soc_feature_mv2_style_flowtracker)) { 803 result = _bcm_th_ft_flow_group_stat_modeid_set(unit, id, 804 stat_modeid); 805 } 806 #endif 807 /* Release lock */ 808 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 809 return result; 810 } 811 812 /* 813 * Function: 814 * bcm_esw_flowtracker_group_stat_modeid_get 815 * Purpose: 816 * Get flow limit of the flow group 817 * Parameters: 818 * unit - (IN) BCM device number 819 * id - (IN) Flow group Id 820 * stat_modeid - (OUT) Stat Modeid associated to flow tracker group 821 * Returns: 822 * BCM_E_XXX - BCM error code. 823 */ 824 int bcm_esw_flowtracker_group_stat_modeid_get(int unit, 825 bcm_flowtracker_group_t id, 826 uint32 *stat_modeid) 827 { 828 int result = BCM_E_UNAVAIL; 829 /* Take lock */ 830 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 831 /* Get stat modeid created using flex stat api */ 832 #if defined(INCLUDE_FLOWTRACKER) 833 if (soc_feature(unit, soc_feature_mv2_style_flowtracker)) { 834 result = _bcm_th_ft_flow_group_stat_modeid_get(unit, id, 835 stat_modeid); 836 } 837 #endif 838 839 /* Release lock */ 840 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 841 return result; 842 } 843 844 /* 845 * Function: 846 * bcm_esw_flowtracker_group_age_timer_set 847 * Purpose: 848 * Set aging timer interval in ms on the flow group. Aging interval has to 849 * be configured in steps of 1sec with a minimum of 1sec. Default value of 850 * 1 minute. 851 * Parameters: 852 * unit - (IN) BCM device number 853 * id - (IN) Flow group Id 854 * aging_interval_ms - (IN) Aging interval in msec 855 * Returns: 856 * BCM_E_XXX - BCM error code. 857 */ 858 int bcm_esw_flowtracker_group_age_timer_set( 859 int unit, 860 bcm_flowtracker_group_t id, 861 uint32 aging_interval_ms) 862 { 863 int result = BCM_E_UNAVAIL; 864 /* Take lock */ 865 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 866 /* Learning and exporting features via UC are both 867 * supported together only on TH series platforms. 868 * Call TH flowtracker APIs. 869 */ 870 #if defined(INCLUDE_FLOWTRACKER) 871 if ((soc_feature(unit, soc_feature_uc_flowtracker_learn) && 872 soc_feature(unit, soc_feature_uc_flowtracker_export)) || 873 soc_feature(unit, soc_feature_mv2_style_flowtracker)) { 874 result = _bcm_th_ft_flow_group_age_timer_set(unit, id, 875 aging_interval_ms); 876 } else 877 #endif 878 #if defined(BCM_FLOWTRACKER_SUPPORT) 879 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 880 result = bcmi_ft_group_age_out_set(unit, id, aging_interval_ms); 881 } else 882 #endif 883 { 884 return (BCM_E_UNAVAIL); 885 } 886 887 /* Release lock */ 888 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 889 return result; 890 } 891 892 /* 893 * Function: 894 * _bcm_th_ft_flow_group_age_timer_get 895 * Purpose: 896 * Get aging timer interval in ms set on the flow group. 897 * Parameters: 898 * unit - (IN) BCM device number 899 * id - (IN) Flow group Id 900 * aging_interval_ms - (OUT) Aging interval in msec 901 * Returns: 902 * BCM_E_XXX - BCM error code. 903 */ 904 int bcm_esw_flowtracker_group_age_timer_get( 905 int unit, 906 bcm_flowtracker_group_t id, 907 uint32 *aging_interval_ms) 908 { 909 int result = BCM_E_UNAVAIL; 910 /* Take lock */ 911 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 912 /* Learning and exporting features via UC are both 913 * supported together only on TH series platforms. 914 * Call TH flowtracker APIs. 915 */ 916 #if defined(INCLUDE_FLOWTRACKER) 917 if ((soc_feature(unit, soc_feature_uc_flowtracker_learn) && 918 soc_feature(unit, soc_feature_uc_flowtracker_export)) || 919 soc_feature(unit, soc_feature_mv2_style_flowtracker)) { 920 result = _bcm_th_ft_flow_group_age_timer_get(unit, id, 921 aging_interval_ms); 922 } else 923 #endif 924 #if defined(BCM_FLOWTRACKER_SUPPORT) 925 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 926 result = bcmi_ft_group_age_out_get(unit, id, aging_interval_ms); 927 } else 928 #endif 929 { 930 return (BCM_E_UNAVAIL); 931 } 932 933 934 /* Release lock */ 935 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 936 return result; 937 } 938 939 /* Set export trigger information of the flow group with ID. */ 940 int bcm_esw_flowtracker_group_export_trigger_set( 941 int unit, 942 bcm_flowtracker_group_t id, 943 bcm_flowtracker_export_trigger_info_t *export_trigger_info) 944 { 945 int result = BCM_E_UNAVAIL; 946 /* Take lock */ 947 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 948 /* Learning and exporting features via UC are both 949 * supported together only on TH series platforms. 950 */ 951 #if defined(INCLUDE_FLOWTRACKER) 952 if (soc_feature(unit, soc_feature_uc_flowtracker_learn) && 953 soc_feature(unit, soc_feature_uc_flowtracker_export)) { 954 result = _bcm_th_ft_flow_group_export_trigger_set(unit, id, 955 export_trigger_info); 956 } else 957 #endif 958 #if defined(BCM_FLOWTRACKER_SUPPORT) 959 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 960 result = bcmi_ft_group_export_trigger_set( 961 unit, id, 962 export_trigger_info); 963 } 964 #endif 965 /* Release lock */ 966 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 967 return result; 968 } 969 970 /* Get export trigger information of the flow group with ID. */ 971 int bcm_esw_flowtracker_group_export_trigger_get( 972 int unit, 973 bcm_flowtracker_group_t id, 974 bcm_flowtracker_export_trigger_info_t *export_trigger_info) 975 { 976 int result = BCM_E_UNAVAIL; 977 /* Take lock */ 978 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 979 /* Learning and exporting features via UC are both 980 * supported together only on TH series platforms. 981 */ 982 #if defined(INCLUDE_FLOWTRACKER) 983 if (soc_feature(unit, soc_feature_uc_flowtracker_learn) && 984 soc_feature(unit, soc_feature_uc_flowtracker_export)) { 985 result = _bcm_th_ft_flow_group_export_trigger_get(unit, id, 986 export_trigger_info); 987 } else 988 #endif 989 #if defined(BCM_FLOWTRACKER_SUPPORT) 990 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 991 result = bcmi_ft_group_export_trigger_get( 992 unit, id, 993 export_trigger_info); 994 } 995 #endif 996 /* Release lock */ 997 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 998 return result; 999 } 1000 1001 /* 1002 * Function: 1003 * bcm_esw_flowtracker_group_flow_count_get 1004 * Purpose: 1005 * Get the number of flows learnt in the flow group 1006 * Parameters: 1007 * unit - (IN) BCM device number 1008 * id - (IN) Flow group Id 1009 * flow_count - (OUT) Number of flows learnt 1010 * Returns: 1011 * BCM_E_XXX - BCM error code. 1012 */ 1013 int bcm_esw_flowtracker_group_flow_count_get( 1014 int unit, 1015 bcm_flowtracker_group_t id, 1016 uint32 *flow_count) 1017 { 1018 int result = BCM_E_UNAVAIL; 1019 /* Take lock */ 1020 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 1021 /* Learning and exporting features via UC are both 1022 * supported together only on TH series platforms. 1023 * Call TH flowtracker APIs. 1024 */ 1025 #if defined(INCLUDE_FLOWTRACKER) 1026 if ((soc_feature(unit, soc_feature_uc_flowtracker_learn) && 1027 soc_feature(unit, soc_feature_uc_flowtracker_export)) || 1028 soc_feature(unit, soc_feature_mv2_style_flowtracker)) { 1029 result = _bcm_th_ft_flow_group_flow_count_get(unit, id, 1030 flow_count); 1031 } 1032 #endif 1033 /* Release lock */ 1034 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 1035 return result; 1036 } 1037 1038 /* 1039 * Function: 1040 * bcm_esw_flowtracker_group_destroy 1041 * Purpose: 1042 * Destroy a flowtracker flow group 1043 * Parameters: 1044 * unit - (IN) BCM device number 1045 * id - (IN) Flow group Id 1046 * Returns: 1047 * BCM_E_XXX - BCM error code. 1048 */ 1049 int bcm_esw_flowtracker_group_destroy( 1050 int unit, 1051 bcm_flowtracker_group_t id) 1052 { 1053 int result = BCM_E_UNAVAIL; 1054 /* Take lock */ 1055 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 1056 /* Learning and exporting features via UC are both 1057 * supported together only on TH series platforms. 1058 * Call TH flowtracker APIs. 1059 */ 1060 #if defined(INCLUDE_FLOWTRACKER) 1061 if ((soc_feature(unit, soc_feature_uc_flowtracker_learn) && 1062 soc_feature(unit, soc_feature_uc_flowtracker_export)) || 1063 soc_feature(unit, soc_feature_mv2_style_flowtracker)) { 1064 result= _bcm_th_ft_flow_group_destroy( 1065 unit, id); 1066 } else 1067 #endif 1068 #if defined(BCM_FLOWTRACKER_SUPPORT) 1069 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 1070 result = bcmi_ft_group_destroy(unit, id); 1071 } else 1072 #endif 1073 { 1074 return (BCM_E_UNAVAIL); 1075 } 1076 1077 /* Release lock */ 1078 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 1079 1080 return result; 1081 } 1082 1083 /* 1084 * Function: 1085 * bcm_esw_flowtracker_group_clear 1086 * Purpose: 1087 * Clear a flow group's flow entries. 1088 * Parameters: 1089 * unit - (IN) BCM device number 1090 * id - (IN) Flow group Id 1091 * flags - (IN) Clear params 1092 * Returns: 1093 * BCM_E_XXX - BCM error code. 1094 */ 1095 int bcm_esw_flowtracker_group_clear( 1096 int unit, 1097 bcm_flowtracker_group_t id, 1098 uint32 flags) 1099 { 1100 int result = BCM_E_UNAVAIL; 1101 1102 #if defined(INCLUDE_FLOWTRACKER) 1103 /* Take lock */ 1104 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 1105 /* Learning and exporting features via UC are both 1106 * supported together only on TH series platforms. 1107 * Call TH flowtracker APIs. 1108 */ 1109 if ((soc_feature(unit, soc_feature_uc_flowtracker_learn) && 1110 soc_feature(unit, soc_feature_uc_flowtracker_export)) || 1111 soc_feature(unit, soc_feature_mv2_style_flowtracker)) { 1112 result= _bcm_th_ft_group_clear(unit, id, flags); 1113 } 1114 /* Release lock */ 1115 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 1116 #endif 1117 1118 #if defined(BCM_FLOWTRACKER_SUPPORT) 1119 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 1120 result = bcm_esw_flowtracker_group_multi_clear(unit, flags, 1, &id); 1121 } 1122 #endif 1123 1124 return result; 1125 } 1126 1127 /* 1128 * Function: 1129 * bcm_esw_flowtracker_group_collector_add 1130 * Purpose: 1131 * Associate flow group to a collector with an export template. 1132 * Parameters: 1133 * unit - (IN) BCM device number 1134 * flow_group_id - (IN) Flow group Id 1135 * collector_id - (IN) Collector Id 1136 * template_id - (IN) Template Id 1137 * Returns: 1138 * BCM_E_XXX - BCM error code. 1139 */ 1140 int bcm_esw_flowtracker_group_collector_add( 1141 int unit, 1142 bcm_flowtracker_group_t flow_group_id, 1143 bcm_flowtracker_collector_t collector_id, 1144 bcm_flowtracker_export_template_t template_id) 1145 { 1146 int result = BCM_E_UNAVAIL; 1147 1148 /* Take lock */ 1149 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 1150 1151 #if defined(INCLUDE_FLOWTRACKER) 1152 /* Learning and exporting features via UC are both 1153 * supported together only on TH series platforms. 1154 * Call TH flowtracker APIs. 1155 */ 1156 if ((soc_feature(unit, soc_feature_uc_flowtracker_learn) && 1157 soc_feature(unit, soc_feature_uc_flowtracker_export)) || 1158 soc_feature(unit, soc_feature_mv2_style_flowtracker)) { 1159 result = _bcm_th_ft_flow_group_collector_add(unit, flow_group_id, 1160 collector_id, template_id); 1161 } else 1162 #endif 1163 { 1164 result = BCM_E_UNAVAIL; 1165 } 1166 1167 /* Release lock */ 1168 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 1169 return result; 1170 } 1171 1172 /* 1173 * Function: 1174 * bcm_esw_flowtracker_group_collector_delete 1175 * Purpose: 1176 * Dis-associate flow group from a collector with an export template. 1177 * Parameters: 1178 * unit - (IN) BCM device number 1179 * flow_group_id - (IN) Flow group Id 1180 * collector_id - (IN) Collector Id 1181 * template_id - (IN) Template Id 1182 * Returns: 1183 * BCM_E_XXX - BCM error code. 1184 */ 1185 int bcm_esw_flowtracker_group_collector_delete( 1186 int unit, 1187 bcm_flowtracker_group_t flow_group_id, 1188 bcm_flowtracker_collector_t collector_id, 1189 bcm_flowtracker_export_template_t template_id) 1190 { 1191 int result = BCM_E_UNAVAIL; 1192 1193 /* Take lock */ 1194 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 1195 1196 #if defined(INCLUDE_FLOWTRACKER) 1197 /* Learning and exporting features via UC are both 1198 * supported together only on TH series platforms. 1199 * Call TH flowtracker APIs. 1200 */ 1201 if ((soc_feature(unit, soc_feature_uc_flowtracker_learn) && 1202 soc_feature(unit, soc_feature_uc_flowtracker_export)) || 1203 soc_feature(unit, soc_feature_mv2_style_flowtracker)) { 1204 result = _bcm_th_ft_flow_group_collector_delete(unit, flow_group_id, 1205 collector_id, template_id); 1206 } else 1207 #endif 1208 { 1209 result = BCM_E_UNAVAIL; 1210 } 1211 1212 /* Release lock */ 1213 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 1214 1215 return result; 1216 } 1217 1218 /* 1219 * Function: 1220 * bcm_esw_flowtracker_group_collector_get_all 1221 * Purpose: 1222 * Get list of all collectors, templates attached to a flow group 1223 * Parameters: 1224 * unit - (IN) BCM device number 1225 * flow_group_id - (IN) Flow group Id 1226 * max_list_size - (IN) Size of the list arrays 1227 * list_of_collectors - (OUT) Collector list 1228 * list_of_templates - (OUT) Template list 1229 * list_size - (OUT) Number of elements in the lists 1230 * Returns: 1231 * BCM_E_XXX - BCM error code. 1232 */ 1233 int bcm_esw_flowtracker_group_collector_get_all( 1234 int unit, 1235 bcm_flowtracker_group_t flow_group_id, 1236 int max_list_size, 1237 bcm_flowtracker_collector_t *list_of_collectors, 1238 bcm_flowtracker_export_template_t *list_of_templates, 1239 int *list_size) 1240 { 1241 int result = BCM_E_UNAVAIL; 1242 1243 /* Take lock */ 1244 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 1245 1246 #if defined(INCLUDE_FLOWTRACKER) 1247 /* Learning and exporting features via UC are both 1248 * supported together only on TH series platforms. 1249 * Call TH flowtracker APIs. 1250 */ 1251 if ((soc_feature(unit, soc_feature_uc_flowtracker_learn) && 1252 soc_feature(unit, soc_feature_uc_flowtracker_export)) || 1253 soc_feature(unit, soc_feature_mv2_style_flowtracker)) { 1254 result= _bcm_th_ft_flow_group_collector_get_all( 1255 unit, flow_group_id, max_list_size, list_of_collectors, 1256 list_of_templates, list_size); 1257 } else 1258 #endif 1259 { 1260 result = BCM_E_UNAVAIL; 1261 } 1262 1263 /* Release lock */ 1264 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 1265 1266 1267 return result; 1268 } 1269 1270 /* 1271 * Function: 1272 * bcm_esw_flowtracker_group_collector_attach 1273 * Purpose: 1274 * Associate flow group to a collector with an export template. 1275 * Parameters: 1276 * unit - (IN) BCM device number 1277 * flow_group_id - (IN) Flow group Id 1278 * collector_id - (IN) Collector Id 1279 * template_id - (IN) Template Id 1280 * Returns: 1281 * BCM_E_XXX - BCM error code. 1282 */ 1283 int bcm_esw_flowtracker_group_collector_attach( 1284 int unit, 1285 bcm_flowtracker_group_t flow_group_id, 1286 bcm_flowtracker_collector_t collector_id, 1287 int export_profile_id, 1288 bcm_flowtracker_export_template_t template_id) 1289 { 1290 int result = BCM_E_UNAVAIL; 1291 1292 /* Take lock */ 1293 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 1294 1295 #if defined(INCLUDE_FLOWTRACKER) 1296 if ((soc_feature(unit, soc_feature_uc_flowtracker_learn) && 1297 soc_feature(unit, soc_feature_uc_flowtracker_export))) { 1298 result = _bcm_th_ft_group_collector_attach(unit, flow_group_id, 1299 collector_id, 1300 export_profile_id, 1301 template_id); 1302 } else 1303 #endif 1304 #if defined(BCM_FLOWTRACKER_SUPPORT) 1305 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 1306 result = bcmi_ft_group_collector_attach(unit, 1307 flow_group_id, 1308 collector_id, 1309 export_profile_id, 1310 template_id); 1311 1312 } else 1313 #endif /* BCM_FLOWTRACKER_SUPPORT */ 1314 { 1315 result = BCM_E_UNAVAIL; 1316 } 1317 1318 /* Release lock */ 1319 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 1320 return result; 1321 } 1322 1323 /* 1324 * Function: 1325 * bcm_esw_flowtracker_group_collector_detach 1326 * Purpose: 1327 * Dis-associate flow group from a collector with an export template. 1328 * Parameters: 1329 * unit - (IN) BCM device number 1330 * flow_group_id - (IN) Flow group Id 1331 * collector_id - (IN) Collector Id 1332 * template_id - (IN) Template Id 1333 * Returns: 1334 * BCM_E_XXX - BCM error code. 1335 */ 1336 int bcm_esw_flowtracker_group_collector_detach( 1337 int unit, 1338 bcm_flowtracker_group_t flow_group_id, 1339 bcm_flowtracker_collector_t collector_id, 1340 int export_profile_id, 1341 bcm_flowtracker_export_template_t template_id) 1342 { 1343 int result = BCM_E_UNAVAIL; 1344 1345 /* Take lock */ 1346 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 1347 1348 #if defined(INCLUDE_FLOWTRACKER) 1349 if ((soc_feature(unit, soc_feature_uc_flowtracker_learn) && 1350 soc_feature(unit, soc_feature_uc_flowtracker_export))) { 1351 result = _bcm_th_ft_group_collector_detach(unit, flow_group_id, 1352 collector_id, 1353 export_profile_id, 1354 template_id); 1355 } else 1356 #endif 1357 #if defined(BCM_FLOWTRACKER_SUPPORT) 1358 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 1359 result = bcmi_ft_group_collector_detach(unit, 1360 flow_group_id, 1361 collector_id, 1362 export_profile_id, 1363 template_id); 1364 1365 } else 1366 #endif /* BCM_FLOWTRACKER_SUPPORT */ 1367 { 1368 result = BCM_E_UNAVAIL; 1369 } 1370 1371 /* Release lock */ 1372 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 1373 1374 return result; 1375 } 1376 1377 /* 1378 * Function: 1379 * bcm_esw_flowtracker_group_collector_attach_get_all 1380 * Purpose: 1381 * Get list of all collectors, templates attached to a flow group 1382 * Parameters: 1383 * unit - (IN) BCM device number 1384 * flow_group_id - (IN) Flow group Id 1385 * max_list_size - (IN) Size of the list arrays 1386 * list_of_collectors - (OUT) Collector list 1387 * list_of_templates - (OUT) Template list 1388 * list_size - (OUT) Number of elements in the lists 1389 * Returns: 1390 * BCM_E_XXX - BCM error code. 1391 */ 1392 int bcm_esw_flowtracker_group_collector_attach_get_all( 1393 int unit, 1394 bcm_flowtracker_group_t flow_group_id, 1395 int max_list_size, 1396 bcm_flowtracker_collector_t *list_of_collectors, 1397 int *list_of_export_profile_ids, 1398 bcm_flowtracker_export_template_t *list_of_templates, 1399 int *list_size) 1400 { 1401 int result = BCM_E_UNAVAIL; 1402 1403 /* Take lock */ 1404 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 1405 1406 #if defined(INCLUDE_FLOWTRACKER) 1407 if ((soc_feature(unit, soc_feature_uc_flowtracker_learn) && 1408 soc_feature(unit, soc_feature_uc_flowtracker_export))) { 1409 result = 1410 _bcm_th_ft_group_collector_attach_get_all(unit, flow_group_id, 1411 max_list_size, 1412 list_of_collectors, 1413 list_of_export_profile_ids, 1414 list_of_templates, 1415 list_size); 1416 } else 1417 #endif 1418 #if defined(BCM_FLOWTRACKER_SUPPORT) 1419 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 1420 result = bcmi_ft_group_collector_attach_get_all(unit, 1421 flow_group_id, 1422 max_list_size, 1423 list_of_collectors, 1424 list_of_export_profile_ids, 1425 list_of_templates, 1426 list_size); 1427 1428 } else 1429 #endif /* BCM_FLOWTRACKER_SUPPORT */ 1430 { 1431 result = BCM_E_UNAVAIL; 1432 } 1433 1434 /* Release lock */ 1435 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 1436 1437 1438 return result; 1439 } 1440 1441 1442 /* 1443 * Function: 1444 * bcm_esw_flowtracker_group_data_get 1445 * Purpose: 1446 * Get flow data for a given flow key within the given flow group. 1447 * Parameters: 1448 * unit - (IN) BCM device number 1449 * flow_group_id - (IN) Flow group Id 1450 * flow_key - (IN) Five tuple that constitutes a flow 1451 * flow_data - (OUT) Data associated with the flow key 1452 * Returns: 1453 * BCM_E_XXX - BCM error code. 1454 */ 1455 int bcm_esw_flowtracker_group_data_get( 1456 int unit, 1457 bcm_flowtracker_group_t flow_group_id, 1458 bcm_flowtracker_flow_key_t *flow_key, 1459 bcm_flowtracker_flow_data_t *flow_data) 1460 { 1461 int result = BCM_E_UNAVAIL; 1462 /* Take lock */ 1463 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 1464 /* Learning and exporting features via UC are both 1465 * supported together only on TH series platforms. 1466 * Call TH flowtracker APIs. 1467 */ 1468 #if defined(INCLUDE_FLOWTRACKER) 1469 if ((soc_feature(unit, soc_feature_uc_flowtracker_learn) && 1470 soc_feature(unit, soc_feature_uc_flowtracker_export)) || 1471 soc_feature(unit, soc_feature_mv2_style_flowtracker)) { 1472 result= _bcm_th_ft_group_data_get(unit, flow_group_id, 1473 flow_key, flow_data); 1474 } 1475 #endif 1476 /* Release lock */ 1477 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 1478 return result; 1479 } 1480 1481 void bcmi_esw_flowtracker_sw_dump(int unit) { 1482 1483 #if defined(BCM_FLOWTRACKER_SUPPORT) 1484 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 1485 bcmi_ft_state_dump(unit); 1486 } 1487 #endif 1488 } 1489 1490 /* 1491 * Function: 1492 * bcm_esw_flowtracker_group_collector_copy_info_get 1493 * Purpose: 1494 * Get flowtracker group's collector copy info. 1495 * Parameters: 1496 * unit - (IN) BCM device number 1497 * id - (IN) Flow group Id 1498 * info - (OUT) Collector copy inforamtion. 1499 * Returns: 1500 * BCM_E_XXX - BCM error code. 1501 */ 1502 int 1503 bcm_esw_flowtracker_group_collector_copy_info_get( 1504 int unit, 1505 bcm_flowtracker_group_t id, 1506 bcm_flowtracker_collector_copy_info_t *info) 1507 { 1508 1509 1510 int result = BCM_E_UNAVAIL; 1511 #if defined(BCM_FLOWTRACKER_SUPPORT) 1512 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 1513 1514 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1) && 1515 (soc_feature(unit, soc_feature_flowtracker_ver_1_collector_copy))) { 1516 result = bcmi_ft_group_collector_copy_get(unit, id, info); 1517 } 1518 1519 /* Release lock */ 1520 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 1521 #endif 1522 1523 return result; 1524 } 1525 1526 /* 1527 * Function: 1528 * bcm_esw_flowtracker_group_collector_copy_info_set 1529 * Purpose: 1530 * Set flowtracker group's collector copy info. 1531 * Parameters: 1532 * unit - (IN) BCM device number 1533 * id - (IN) Flow group Id 1534 * info - (IN) Collector copy inforamtion. 1535 * Returns: 1536 * BCM_E_XXX - BCM error code. 1537 */ 1538 int 1539 bcm_esw_flowtracker_group_collector_copy_info_set( 1540 int unit, 1541 bcm_flowtracker_group_t id, 1542 bcm_flowtracker_collector_copy_info_t info) 1543 { 1544 1545 int result = BCM_E_UNAVAIL; 1546 #if defined(BCM_FLOWTRACKER_SUPPORT) 1547 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 1548 1549 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1) && 1550 (soc_feature(unit, soc_feature_flowtracker_ver_1_collector_copy))) { 1551 1552 result = bcmi_ft_group_collector_copy_set(unit, id, info); 1553 } 1554 1555 /* Release lock */ 1556 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 1557 #endif 1558 1559 return result; 1560 } 1561 1562 /* 1563 * Function: 1564 * bcm_esw_flowtracker_group_meter_info_set 1565 * Purpose: 1566 * set meter inforamtion for flowtracker group. 1567 * Parameters: 1568 * unit - (IN) BCM device number 1569 * id - (IN) Flow group Id 1570 * info - (IN) meter info. 1571 * Returns: 1572 * BCM_E_XXX - BCM error code. 1573 */ 1574 1575 int 1576 bcm_esw_flowtracker_group_meter_info_set( 1577 int unit, 1578 bcm_flowtracker_group_t id, 1579 bcm_flowtracker_meter_info_t info) 1580 { 1581 1582 1583 int result = BCM_E_UNAVAIL; 1584 #if defined(BCM_FLOWTRACKER_SUPPORT) 1585 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 1586 1587 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1) && 1588 (soc_feature(unit, soc_feature_flowtracker_ver_1_metering))) { 1589 result = bcmi_ft_group_meter_profile_set(unit, id, info); 1590 } 1591 1592 /* Release lock */ 1593 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 1594 #endif 1595 1596 return result; 1597 } 1598 1599 /* 1600 * Function: 1601 * bcm_esw_flowtracker_group_meter_info_get 1602 * Purpose: 1603 * Get meter inforamtion for flowtracker group. 1604 * Parameters: 1605 * unit - (IN) BCM device number 1606 * id - (IN) Flow group Id 1607 * info - (OUT) meter info. 1608 * Returns: 1609 * BCM_E_XXX - BCM error code. 1610 */ 1611 int 1612 bcm_esw_flowtracker_group_meter_info_get( 1613 int unit, 1614 bcm_flowtracker_group_t id, 1615 bcm_flowtracker_meter_info_t *info) 1616 { 1617 1618 int result = BCM_E_UNAVAIL; 1619 #if defined(BCM_FLOWTRACKER_SUPPORT) 1620 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 1621 1622 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1) && 1623 (soc_feature(unit, soc_feature_flowtracker_ver_1_metering))) { 1624 1625 result = bcmi_ft_group_meter_profile_get(unit, id, info); 1626 } 1627 1628 /* Release lock */ 1629 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 1630 #endif 1631 1632 return result; 1633 } 1634 1635 /* 1636 * Function: 1637 * bcm_esw_flowtracker_check_create 1638 * Purpose: 1639 * Create flowtracker check. 1640 * Parameters: 1641 * unit - (IN) BCM device number 1642 * options - (IN) Options to create check 1643 * check_info - (IN) check info. 1644 * check_id - (OUT) Software id of check 1645 * Returns: 1646 * BCM_E_XXX - BCM error code. 1647 */ 1648 int 1649 bcm_esw_flowtracker_check_create( 1650 int unit, 1651 uint32 options, 1652 bcm_flowtracker_check_info_t check_info, 1653 bcm_flowtracker_check_t *check_id) 1654 { 1655 int result = BCM_E_UNAVAIL; 1656 1657 #if defined(BCM_FLOWTRACKER_SUPPORT) 1658 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 1659 1660 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 1661 result = bcmi_ft_check_create(unit, options, check_info, check_id); 1662 } 1663 1664 /* Release lock */ 1665 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 1666 #endif 1667 1668 return result; 1669 } 1670 1671 /* 1672 * Function: 1673 * bcm_esw_flowtracker_check_get 1674 * Purpose: 1675 * Create flowtracker check. 1676 * Parameters: 1677 * unit - (IN) BCM device number 1678 * check_id - (IN) Software id of check 1679 * check_info - (OUT) check info. 1680 * Returns: 1681 * BCM_E_XXX - BCM error code. 1682 */ 1683 int 1684 bcm_esw_flowtracker_check_get( 1685 int unit, 1686 bcm_flowtracker_check_t check_id, 1687 bcm_flowtracker_check_info_t *check_info) 1688 { 1689 int result = BCM_E_UNAVAIL; 1690 1691 #if defined(BCM_FLOWTRACKER_SUPPORT) 1692 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 1693 1694 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 1695 result = bcmi_ft_check_get(unit, check_id, check_info); 1696 } 1697 1698 /* Release lock */ 1699 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 1700 #endif 1701 1702 return result; 1703 } 1704 1705 1706 /* 1707 * Function: 1708 * bcm_esw_flowtracker_check_destroy 1709 * Purpose: 1710 * Create flowtracker check. 1711 * Parameters: 1712 * unit - (IN) BCM device number 1713 * check_id - (IN) Software id of check 1714 * Returns: 1715 * BCM_E_XXX - BCM error code. 1716 */ 1717 int 1718 bcm_esw_flowtracker_check_destroy( 1719 int unit, 1720 bcm_flowtracker_check_t check_id) 1721 { 1722 int result = BCM_E_UNAVAIL; 1723 1724 #if defined(BCM_FLOWTRACKER_SUPPORT) 1725 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 1726 1727 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 1728 result = bcmi_ft_check_destroy(unit, check_id); 1729 } 1730 1731 /* Release lock */ 1732 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 1733 #endif 1734 1735 return result; 1736 } 1737 1738 1739 /* Destroy all the flow checks. */ 1740 int bcm_esw_flowtracker_check_destroy_all( 1741 int unit) 1742 { 1743 int result = BCM_E_UNAVAIL; 1744 1745 #if defined(BCM_FLOWTRACKER_SUPPORT) 1746 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 1747 1748 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 1749 result = bcmi_ft_check_destroy_all(unit); 1750 } 1751 1752 /* Release lock */ 1753 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 1754 #endif 1755 1756 return result; 1757 } 1758 1759 1760 /* Traverse through the flow checks and run callback at each valid entry. */ 1761 int bcm_esw_flowtracker_check_traverse( 1762 int unit, 1763 bcm_flowtracker_check_traverse_cb cb, 1764 void *user_data) 1765 { 1766 1767 int result = BCM_E_UNAVAIL; 1768 1769 #if defined(BCM_FLOWTRACKER_SUPPORT) 1770 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 1771 1772 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 1773 result = bcmi_ft_check_traverse(unit, cb, user_data); 1774 } 1775 1776 /* Release lock */ 1777 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 1778 #endif 1779 1780 return result; 1781 } 1782 1783 1784 1785 /* Set action information of flow check. */ 1786 int bcm_esw_flowtracker_check_action_info_set( 1787 int unit, 1788 bcm_flowtracker_check_t check_id, 1789 bcm_flowtracker_check_action_info_t info) 1790 { 1791 1792 int result = BCM_E_UNAVAIL; 1793 1794 #if defined(BCM_FLOWTRACKER_SUPPORT) 1795 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 1796 1797 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 1798 result = bcmi_ft_check_action_info_set(unit, check_id, info); 1799 } 1800 1801 /* Release lock */ 1802 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 1803 #endif 1804 1805 return result; 1806 } 1807 1808 1809 /* Get action information of flow check. */ 1810 int bcm_esw_flowtracker_check_action_info_get( 1811 int unit, 1812 bcm_flowtracker_check_t check_id, 1813 bcm_flowtracker_check_action_info_t *info) 1814 { 1815 1816 int result = BCM_E_UNAVAIL; 1817 1818 #if defined(BCM_FLOWTRACKER_SUPPORT) 1819 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 1820 1821 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 1822 result = bcmi_ft_check_action_info_get(unit, check_id, info); 1823 } 1824 1825 /* Release lock */ 1826 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 1827 #endif 1828 1829 return result; 1830 } 1831 1832 1833 1834 /* Set export information of flow check. */ 1835 int bcm_esw_flowtracker_check_export_info_set( 1836 int unit, 1837 bcm_flowtracker_check_t check_id, 1838 bcm_flowtracker_check_export_info_t info) 1839 { 1840 1841 int result = BCM_E_UNAVAIL; 1842 1843 #if defined(BCM_FLOWTRACKER_SUPPORT) 1844 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 1845 1846 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 1847 result = bcmi_ft_check_export_info_set(unit, check_id, info); 1848 } 1849 1850 /* Release lock */ 1851 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 1852 #endif 1853 1854 return result; 1855 } 1856 1857 1858 /* Get export information of flow check. */ 1859 int bcm_esw_flowtracker_check_export_info_get( 1860 int unit, 1861 bcm_flowtracker_check_t check_id, 1862 bcm_flowtracker_check_export_info_t *info) 1863 { 1864 1865 int result = BCM_E_UNAVAIL; 1866 1867 #if defined(BCM_FLOWTRACKER_SUPPORT) 1868 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 1869 1870 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 1871 result = bcmi_ft_check_export_info_get(unit, check_id, info); 1872 } 1873 1874 /* Release lock */ 1875 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 1876 #endif 1877 1878 return result; 1879 } 1880 1881 1882 /* Add flow check to this flowtracker group */ 1883 int bcm_esw_flowtracker_group_check_add( 1884 int unit, 1885 bcm_flowtracker_group_t group_id, 1886 bcm_flowtracker_check_t check_id) 1887 { 1888 1889 int result = BCM_E_UNAVAIL; 1890 1891 #if defined(BCM_FLOWTRACKER_SUPPORT) 1892 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 1893 1894 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 1895 result = bcmi_ft_group_flowchecker_add(unit, group_id, check_id); 1896 } 1897 1898 /* Release lock */ 1899 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 1900 #endif 1901 1902 return result; 1903 1904 } 1905 1906 /* Delete flow check from this flowtracker group. */ 1907 int bcm_esw_flowtracker_group_check_delete( 1908 int unit, 1909 bcm_flowtracker_group_t group_id, 1910 bcm_flowtracker_check_t check_id) 1911 { 1912 int result = BCM_E_UNAVAIL; 1913 1914 #if defined(BCM_FLOWTRACKER_SUPPORT) 1915 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 1916 1917 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 1918 result = bcmi_ft_group_flowchecker_delete(unit, group_id, check_id); 1919 } 1920 1921 /* Release lock */ 1922 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 1923 #endif 1924 1925 return result; 1926 1927 } 1928 1929 1930 /* Get all the checks associated with the group. */ 1931 int bcm_esw_flowtracker_group_check_get_all( 1932 int unit, 1933 bcm_flowtracker_group_t group_id, 1934 int max_checks, 1935 bcm_flowtracker_check_t *list_of_check_ids, 1936 int *num_checks) 1937 { 1938 int result = BCM_E_UNAVAIL; 1939 1940 #if defined(BCM_FLOWTRACKER_SUPPORT) 1941 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 1942 1943 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 1944 result = bcmi_flowtracker_check_get_all(unit, group_id, 1, 1945 max_checks, list_of_check_ids, num_checks); 1946 } 1947 1948 /* Release lock */ 1949 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 1950 #endif 1951 1952 return result; 1953 1954 } 1955 1956 1957 /* Set tracking parameter for this flowtracker group. */ 1958 int bcm_esw_flowtracker_group_tracking_params_set( 1959 int unit, 1960 bcm_flowtracker_group_t id, 1961 int num_tracking_params, 1962 bcm_flowtracker_tracking_param_info_t *list_of_tracking_params) 1963 { 1964 int result = BCM_E_UNAVAIL; 1965 1966 /* Take lock */ 1967 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 1968 #if defined(INCLUDE_FLOWTRACKER) 1969 if (soc_feature(unit, soc_feature_uc_flowtracker_learn) && 1970 soc_feature(unit, soc_feature_uc_flowtracker_export)) { 1971 result = _bcm_th_ft_flow_group_tracking_params_set(unit, id, 1972 num_tracking_params, 1973 list_of_tracking_params); 1974 } else 1975 #endif 1976 #if defined(BCM_FLOWTRACKER_SUPPORT) 1977 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 1978 result = bcmi_ft_group_tracking_param_set(unit, id, 1979 num_tracking_params, list_of_tracking_params); 1980 } 1981 #endif 1982 /* Release lock */ 1983 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 1984 1985 return result; 1986 } 1987 1988 /* Get flowtracker tracking parameters for this group. */ 1989 int bcm_esw_flowtracker_group_tracking_params_get( 1990 int unit, 1991 bcm_flowtracker_group_t id, 1992 int max_size, 1993 bcm_flowtracker_tracking_param_info_t *list_of_tracking_params, 1994 int *list_size) 1995 { 1996 1997 int result = BCM_E_UNAVAIL; 1998 1999 /* Take lock */ 2000 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 2001 #if defined(INCLUDE_FLOWTRACKER) 2002 if (soc_feature(unit, soc_feature_uc_flowtracker_learn) && 2003 soc_feature(unit, soc_feature_uc_flowtracker_export)) { 2004 result = _bcm_th_ft_flow_group_tracking_params_get(unit, id, 2005 max_size, 2006 list_size, 2007 list_of_tracking_params); 2008 } else 2009 #endif 2010 #if defined(BCM_FLOWTRACKER_SUPPORT) 2011 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 2012 result = bcmi_ft_group_tracking_param_get(unit, id, max_size, 2013 list_of_tracking_params, list_size); 2014 } 2015 #endif 2016 /* Release lock */ 2017 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 2018 2019 return result; 2020 2021 } 2022 2023 /* 2024 * Function: 2025 * bcm_esw_flowtracker_group_multi_clear 2026 * Purpose: 2027 * Clear data for multiple groups. 2028 * Parameters: 2029 * unit - (IN) BCM device number 2030 * id - (IN) Flow group Id 2031 * num_groups - (IN) Number of groups to clear 2032 * list_of_group_ids - (IN) List of Groups ids to be cleared. 2033 * Returns: 2034 * BCM_E_XXX - BCM error code. 2035 */ 2036 int 2037 bcm_esw_flowtracker_group_multi_clear( 2038 int unit, 2039 uint32 flags, 2040 int num_groups, 2041 bcm_flowtracker_group_t *list_of_group_ids) 2042 { 2043 int result = BCM_E_UNAVAIL; 2044 2045 #if defined(BCM_FLOWTRACKER_SUPPORT) 2046 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 2047 2048 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 2049 result = bcmi_ft_group_flush_set(unit, 2050 flags, num_groups, list_of_group_ids); 2051 } 2052 /* Release lock */ 2053 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 2054 #endif 2055 2056 return result; 2057 } 2058 2059 2060 /* 2061 * Function: 2062 * bcm_esw_flowtracker_group_control_set 2063 * Purpose: 2064 * Set value of group control. 2065 * Parameters: 2066 * unit - (IN) BCM device number 2067 * id - (IN) Flow group Id 2068 * type - (IN) type of group control. 2069 * arg - (IN) value of control 2070 * Returns: 2071 * BCM_E_XXX - BCM error code. 2072 */ 2073 int 2074 bcm_esw_flowtracker_group_control_set( 2075 int unit, 2076 bcm_flowtracker_group_t id, 2077 bcm_flowtracker_group_control_type_t type, 2078 int arg) 2079 { 2080 int result = BCM_E_UNAVAIL; 2081 2082 #if defined(BCM_FLOWTRACKER_SUPPORT) 2083 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 2084 2085 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 2086 result = bcmi_flowtracker_group_control_set(unit, id, type, arg); 2087 } 2088 /* Release lock */ 2089 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 2090 #endif 2091 2092 return result; 2093 } 2094 2095 /* 2096 * Function: 2097 * bcm_esw_flowtracker_group_control_get 2098 * Purpose: 2099 * Get value of group control. 2100 * Parameters: 2101 * unit - (IN) BCM device number 2102 * id - (IN) Flow group Id 2103 * type - (IN) type of group control. 2104 * arg - (OUT) return value of control 2105 * Returns: 2106 * BCM_E_XXX - BCM error code. 2107 */ 2108 int 2109 bcm_esw_flowtracker_group_control_get( 2110 int unit, 2111 bcm_flowtracker_group_t id, 2112 bcm_flowtracker_group_control_type_t type, 2113 int *arg) 2114 { 2115 int result = BCM_E_UNAVAIL; 2116 2117 #if defined(BCM_FLOWTRACKER_SUPPORT) 2118 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 2119 2120 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 2121 result = bcmi_flowtracker_group_control_get(unit, id, type, arg); 2122 } 2123 /* Release lock */ 2124 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 2125 #endif 2126 2127 return result; 2128 2129 } 2130 2131 2132 /* 2133 * Function: 2134 * bcm_esw_flowtracker_group_cpu_notification_get 2135 * Purpose: 2136 * Get CPU notifications on the group 2137 * Parameters: 2138 * unit - (IN) BCM device number 2139 * id - (IN) Flow group Id 2140 * info - (IN) Cpu notification inforamtion 2141 * Returns: 2142 * BCM_E_XXX - BCM error code. 2143 */ 2144 int 2145 bcm_esw_flowtracker_group_cpu_notification_get( 2146 int unit, 2147 bcm_flowtracker_group_t id, 2148 bcm_flowtracker_cpu_notification_info_t *info) 2149 { 2150 2151 int result = BCM_E_UNAVAIL; 2152 2153 #if defined(BCM_FLOWTRACKER_SUPPORT) 2154 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 2155 2156 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 2157 result = bcmi_ft_group_cpu_notification_trigger_get( 2158 unit, id, info); 2159 } 2160 /* Release lock */ 2161 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 2162 #endif 2163 2164 return result; 2165 } 2166 2167 /* 2168 * Function: 2169 * bcm_esw_flowtracker_group_cpu_notification_set 2170 * Purpose: 2171 * Set CPU notifications on the group 2172 * Parameters: 2173 * unit - (IN) BCM device number 2174 * id - (IN) Flow group Id 2175 * info - (IN) CPU notification inforamtion 2176 * Returns: 2177 * BCM_E_XXX - BCM error code. 2178 */ 2179 int 2180 bcm_esw_flowtracker_group_cpu_notification_set( 2181 int unit, 2182 bcm_flowtracker_group_t id, 2183 bcm_flowtracker_cpu_notification_info_t *info) 2184 { 2185 2186 int result = BCM_E_UNAVAIL; 2187 2188 #if defined(BCM_FLOWTRACKER_SUPPORT) 2189 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 2190 2191 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 2192 result = bcmi_ft_group_cpu_notification_trigger_set( 2193 unit, id, info); 2194 } 2195 /* Release lock */ 2196 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 2197 #endif 2198 2199 return result; 2200 } 2201 2202 /* 2203 * Function: 2204 * bcm_esw_flowtracker_group_stat_set 2205 * Purpose: 2206 * Set Group statistics 2207 * Parameters: 2208 * unit - (IN) BCM device number 2209 * id - (IN) Flow group Id 2210 * group_stats - (IN) Group statistics 2211 * Returns: 2212 * BCM_E_XXX - BCM error code. 2213 */ 2214 int 2215 bcm_esw_flowtracker_group_stat_set( 2216 int unit, 2217 bcm_flowtracker_group_t id, 2218 bcm_flowtracker_group_stat_t *group_stat) 2219 { 2220 2221 2222 int result = BCM_E_UNAVAIL; 2223 2224 #if defined(BCM_FLOWTRACKER_SUPPORT) 2225 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 2226 2227 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 2228 result = bcmi_ft_group_stat_set(unit, id, group_stat); 2229 } 2230 /* Release lock */ 2231 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 2232 #endif 2233 2234 return result; 2235 } 2236 2237 /* 2238 * Function: 2239 * bcm_esw_flowtracker_group_stat_get 2240 * Purpose: 2241 * Get Group statistics 2242 * Parameters: 2243 * unit - (IN) BCM device number 2244 * id - (IN) Flow group Id 2245 * group_stats - (OUT) Group statistics 2246 * Returns: 2247 * BCM_E_XXX - BCM error code. 2248 */ 2249 int 2250 bcm_esw_flowtracker_group_stat_get( 2251 int unit, 2252 bcm_flowtracker_group_t id, 2253 bcm_flowtracker_group_stat_t *group_stat) 2254 { 2255 2256 int result = BCM_E_UNAVAIL; 2257 2258 #if defined(BCM_FLOWTRACKER_SUPPORT) 2259 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 2260 2261 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 2262 result = bcmi_ft_group_stat_get(unit, id, group_stat); 2263 } 2264 /* Release lock */ 2265 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 2266 #endif 2267 2268 return result; 2269 } 2270 2271 2272 /* 2273 * Function: 2274 * bcm_flowtracker_export_record_register 2275 * Purpose: 2276 * Register callback routine for Local collector Flowtracker 2277 * record export. 2278 * Parameters: 2279 * unit - (IN) Unit number. 2280 * collector_id - (IN) Flowtracker collector Software ID. 2281 * callback_options - (IN) Flowtracker export callback options. 2282 * callback_fn - (IN) <UNDEF> 2283 * userdata - (IN) <UNDEF> 2284 * Returns: 2285 * BCM_E_xxx 2286 * Notes: 2287 */ 2288 int 2289 bcm_esw_flowtracker_export_record_register( 2290 int unit, 2291 bcm_flowtracker_collector_t collector_id, 2292 bcm_flowtracker_collector_callback_options_t callback_options, 2293 bcm_flowtracker_export_record_cb_f callback_fn, 2294 void *userdata) 2295 { 2296 int result = BCM_E_UNAVAIL; 2297 2298 #if defined(BCM_FLOWTRACKER_SUPPORT) 2299 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 2300 2301 if (soc_feature(unit, soc_feature_bscan_ft_fifodma_support)) { 2302 result = bcmi_ft_export_record_register(unit, 2303 collector_id, 2304 callback_options, 2305 callback_fn, 2306 userdata); 2307 } 2308 /* Release lock */ 2309 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 2310 #endif 2311 2312 return result; 2313 } 2314 2315 /* 2316 * Function: 2317 * bcm_flowtracker_export_record_unregister 2318 * Purpose: 2319 * Unregister callback routine for Local collector Flowtracker 2320 * record export. 2321 * Parameters: 2322 * unit - (IN) Unit number. 2323 * collector_id - (IN) Flowtracker collector Software ID. 2324 * callback_options - (IN) Flowtracker export callback options. 2325 * callback_fn - (IN) <UNDEF> 2326 * Returns: 2327 * BCM_E_xxx 2328 * Notes: 2329 */ 2330 int 2331 bcm_esw_flowtracker_export_record_unregister( 2332 int unit, 2333 bcm_flowtracker_collector_t collector_id, 2334 bcm_flowtracker_collector_callback_options_t callback_options, 2335 bcm_flowtracker_export_record_cb_f callback_fn) 2336 { 2337 int result = BCM_E_UNAVAIL; 2338 2339 #if defined(BCM_FLOWTRACKER_SUPPORT) 2340 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 2341 2342 if (soc_feature(unit, soc_feature_bscan_ft_fifodma_support)) { 2343 result = bcmi_ft_export_record_unregister(unit, 2344 collector_id, 2345 callback_options, 2346 callback_fn); 2347 } 2348 /* Release lock */ 2349 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 2350 #endif 2351 2352 return result; 2353 } 2354 2355 2356 /* 2357 * Function: 2358 * bcm_esw_flowtracker_user_entry_add 2359 * Purpose: 2360 * Add a user flow entry basis user input key elements. API 2361 * expects that all tracking parametrs of type = 'KEY' in the 2362 * group are specified. 2363 * Parameters: 2364 * unit - (IN) Unit number. 2365 * flow_group_id - (IN) Flowtracker flow group ID. 2366 * options - (IN) Options for creting the flowtracker user entry. 2367 * num_user_entry_params - (IN) Number of user entry params. 2368 * user_entry_param_list - (IN) List of user entry params to add flow entry. 2369 * entry_handle - (OUT) User entry handle corresponding to the entry added. 2370 * Returns: 2371 * BCM_E_xxx 2372 * Notes: 2373 */ 2374 int 2375 bcm_esw_flowtracker_user_entry_add( 2376 int unit, 2377 bcm_flowtracker_group_t flow_group_id, 2378 uint32 options, 2379 int num_user_entry_params, 2380 bcm_flowtracker_tracking_param_info_t *user_entry_param_list, 2381 bcm_flowtracker_user_entry_handle_t *entry_handle) 2382 { 2383 int result = BCM_E_UNAVAIL; 2384 2385 #if defined(BCM_FLOWTRACKER_SUPPORT) 2386 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 2387 2388 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 2389 result = bcmi_ftk_user_entry_add(unit, 2390 flow_group_id, 2391 options, 2392 num_user_entry_params, 2393 user_entry_param_list, 2394 entry_handle); 2395 } 2396 /* Release lock */ 2397 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 2398 #endif 2399 2400 return result; 2401 } 2402 2403 /* 2404 * Function: 2405 * bcm_esw_flowtracker_user_entry_get 2406 * Purpose: 2407 * Fetch user entry info given the entry handle. 2408 * Parameters: 2409 * unit - (IN) Unit number. 2410 * entry_handle - (IN) Flowtracker user entry handle. 2411 * num_user_entry_params - (IN) Number of user entry params. 2412 * user_entry_param_list - (IN/OUT) List of user entry params added in the flow entry. 2413 * actual_user_entry_params - (OUT) Actual number of params in the user entry. 2414 * Returns: 2415 * BCM_E_xxx 2416 * Notes: 2417 */ 2418 int 2419 bcm_esw_flowtracker_user_entry_get( 2420 int unit, 2421 bcm_flowtracker_user_entry_handle_t *entry_handle, 2422 int num_user_entry_params, 2423 bcm_flowtracker_tracking_param_info_t *user_entry_param_list, 2424 int *actual_user_entry_params) 2425 { 2426 int result = BCM_E_UNAVAIL; 2427 2428 #if defined(BCM_FLOWTRACKER_SUPPORT) 2429 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 2430 2431 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 2432 result = bcmi_ftk_user_entry_get(unit, 2433 entry_handle, 2434 num_user_entry_params, 2435 user_entry_param_list, 2436 actual_user_entry_params); 2437 } 2438 /* Release lock */ 2439 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 2440 #endif 2441 2442 return result; 2443 } 2444 2445 /* 2446 * Function: 2447 * bcm_esw_flowtracker_user_entry_get_all 2448 * Purpose: 2449 * Fetch all user entries added in a against a given flow group. 2450 * Parameters: 2451 * unit - (IN) Unit number. 2452 * flow_group_id - (IN) Flowtracker flow group ID. 2453 * num_user_entry_handles - (IN) Number of export elements intended in the tempate. 2454 * user_entry_handle_list - (IN/OUT) List of user entry handles corresponding to the user entries added. 2455 * actual_user_entry_handles - (OUT) Actual number of user entry handles corresponding to the entries added. 2456 * Returns: 2457 * BCM_E_xxx 2458 * Notes: 2459 */ 2460 int 2461 bcm_esw_flowtracker_user_entry_get_all( 2462 int unit, 2463 bcm_flowtracker_group_t flow_group_id, 2464 int num_user_entry_handles, 2465 bcm_flowtracker_user_entry_handle_t *user_entry_handle_list, 2466 int *actual_user_entry_handles) 2467 { 2468 int result = BCM_E_UNAVAIL; 2469 2470 #if defined(BCM_FLOWTRACKER_SUPPORT) 2471 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 2472 2473 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 2474 result = bcmi_ftk_user_entry_get_all(unit, 2475 flow_group_id, 2476 num_user_entry_handles, 2477 user_entry_handle_list, 2478 actual_user_entry_handles); 2479 } 2480 /* Release lock */ 2481 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 2482 #endif 2483 2484 return result; 2485 } 2486 2487 /* 2488 * Function: 2489 * bcm_esw_flowtracker_user_entry_delete 2490 * Purpose: 2491 * Delete user flow entry that is added earlier. 2492 * Parameters: 2493 * unit - (IN) Unit number. 2494 * flow_group_id - (IN) Flowtracker flow group ID. 2495 * entry_handle - (IN) User entry handle corresponding to the entry added. 2496 * Returns: 2497 * BCM_E_xxx 2498 * Notes: 2499 */ 2500 int 2501 bcm_esw_flowtracker_user_entry_delete( 2502 int unit, 2503 bcm_flowtracker_group_t flow_group_id, 2504 bcm_flowtracker_user_entry_handle_t *entry_handle) 2505 { 2506 int result = BCM_E_UNAVAIL; 2507 2508 #if defined(BCM_FLOWTRACKER_SUPPORT) 2509 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 2510 2511 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 2512 result = bcmi_ftk_user_entry_delete(unit, 2513 flow_group_id, 2514 entry_handle); 2515 } 2516 /* Release lock */ 2517 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 2518 #endif 2519 2520 return result; 2521 } 2522 2523 /* 2524 * Function: 2525 * bcm_esw_flowtracker_user_entry_delete_all 2526 * Purpose: 2527 * Delete user flow entry that is added earlier. 2528 * Parameters: 2529 * unit - (IN) Unit number. 2530 * flow_group_id - (IN) Flowtracker flow group ID. 2531 * Returns: 2532 * BCM_E_xxx 2533 * Notes: 2534 */ 2535 int 2536 bcm_esw_flowtracker_user_entry_delete_all( 2537 int unit, 2538 bcm_flowtracker_group_t flow_group_id) 2539 { 2540 int result = BCM_E_UNAVAIL; 2541 2542 #if defined(BCM_FLOWTRACKER_SUPPORT) 2543 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 2544 2545 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 2546 result = bcmi_ftk_user_entry_delete_all(unit, 2547 flow_group_id); 2548 } 2549 /* Release lock */ 2550 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 2551 #endif 2552 2553 return result; 2554 } 2555 2556 2557 2558 /* 2559 * Function: 2560 * bcm_esw_flowtracker_sync 2561 * Purpose: 2562 * Warmboot sync routine for flowtracker 2563 * Parameters: 2564 * unit - (IN) Unit number. 2565 * Returns: 2566 * BCM_E_xxx 2567 * Notes: 2568 */ 2569 int 2570 bcm_esw_flowtracker_sync( 2571 int unit) 2572 { 2573 int result = BCM_E_UNAVAIL; 2574 2575 #ifdef BCM_WARM_BOOT_SUPPORT 2576 #if defined(BCM_FLOWTRACKER_SUPPORT) 2577 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 2578 2579 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 2580 result = bcmi_ft_sync(unit); 2581 } 2582 /* Release lock */ 2583 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 2584 #endif 2585 #endif 2586 2587 return result; 2588 } 2589 2590 /* 2591 * Function: 2592 * bcm_esw_flowtracker_template_transmit_config_set 2593 * Purpose: 2594 * Set the template set transmit configuration 2595 * Parameters: 2596 * unit - (IN) BCM device number 2597 * template_id - (IN) Template Id 2598 * collector_id - (IN) Collector Id 2599 * config - (IN) Template transmit config 2600 * Returns: 2601 * BCM_E_XXX - BCM error code. 2602 */ 2603 int 2604 bcm_esw_flowtracker_template_transmit_config_set( 2605 int unit, 2606 bcm_flowtracker_export_template_t template_id, 2607 bcm_flowtracker_collector_t collector_id, 2608 bcm_flowtracker_template_transmit_config_t *config) 2609 { 2610 int result = BCM_E_UNAVAIL; 2611 #if defined(INCLUDE_FLOWTRACKER) 2612 /* Take lock */ 2613 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 2614 if (soc_feature(unit, soc_feature_uc_flowtracker_export)) { 2615 result = _bcm_th_ft_template_transmit_config_set(unit, template_id, 2616 collector_id, config); 2617 } 2618 /* Release lock */ 2619 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 2620 #endif /* INCLUDE_FLOWTRACKER */ 2621 return result; 2622 } 2623 2624 /* 2625 * Function: 2626 * bcm_esw_flowtracker_template_transmit_config_get 2627 * Purpose: 2628 * Get the template set transmit configuration 2629 * Parameters: 2630 * unit - (IN) BCM device number 2631 * template_id - (IN) Template Id 2632 * collector_id - (IN) Collector Id 2633 * config - (OUT) Template transmit config 2634 * Returns: 2635 * BCM_E_XXX - BCM error code. 2636 */ 2637 int 2638 bcm_esw_flowtracker_template_transmit_config_get( 2639 int unit, 2640 bcm_flowtracker_export_template_t template_id, 2641 bcm_flowtracker_collector_t collector_id, 2642 bcm_flowtracker_template_transmit_config_t *config) 2643 { 2644 int result = BCM_E_UNAVAIL; 2645 #if defined(INCLUDE_FLOWTRACKER) 2646 /* Take lock */ 2647 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 2648 if (soc_feature(unit, soc_feature_uc_flowtracker_export)) { 2649 result = _bcm_th_ft_template_transmit_config_get(unit, 2650 template_id, 2651 collector_id, 2652 config); 2653 } 2654 /* Release lock */ 2655 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 2656 #endif /* INCLUDE_FLOWTRACKER */ 2657 return result; 2658 } 2659 2660 /* 2661 * Function: 2662 * bcm_esw_flowtracker_group_actions_set 2663 * Purpose: 2664 * Set list of actions on a flow group. 2665 * Parameters: 2666 * unit - (IN) BCM device number 2667 * flow_group_id - (IN) Flow group Id 2668 * flags - (IN) Flags 2669 * num_actions - (IN) Number of actions in the list. 2670 * action_list - (IN) Action list. 2671 * Returns: 2672 * BCM_E_XXX - BCM error code. 2673 */ 2674 int bcm_esw_flowtracker_group_actions_set( 2675 int unit, 2676 bcm_flowtracker_group_t flow_group_id, 2677 uint32 flags, 2678 int num_actions, 2679 bcm_flowtracker_group_action_info_t *action_list) 2680 { 2681 int result = BCM_E_UNAVAIL; 2682 #if defined(INCLUDE_FLOWTRACKER) 2683 /* Take lock */ 2684 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 2685 if ((soc_feature(unit, soc_feature_uc_flowtracker_learn) && 2686 soc_feature(unit, soc_feature_uc_flowtracker_export)) || 2687 soc_feature(unit, soc_feature_mv2_style_flowtracker)) { 2688 result = _bcm_th_ft_group_actions_set(unit, flow_group_id, flags, 2689 num_actions, action_list); 2690 } 2691 /* Release lock */ 2692 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 2693 #endif /* INCLUDE_FLOWTRACKER */ 2694 return result; 2695 } 2696 2697 /* 2698 * Function: 2699 * bcm_esw_flowtracker_group_actions_get 2700 * Purpose: 2701 * Get list of actions applied on a flow group. 2702 * Parameters: 2703 * unit - (IN) BCM device number 2704 * flow_group_id - (IN) Flow group Id 2705 * flags - (IN) Flags 2706 * max_actions - (IN) Maximum number of actions that can be 2707 * accomodated in the list. 2708 * action_list - (OUT) Action list. 2709 * num_actions - (OUT) Actual number of actions in the list 2710 * Returns: 2711 * BCM_E_XXX - BCM error code. 2712 */ 2713 int bcm_esw_flowtracker_group_actions_get( 2714 int unit, 2715 bcm_flowtracker_group_t flow_group_id, 2716 uint32 flags, 2717 int max_actions, 2718 bcm_flowtracker_group_action_info_t *action_list, 2719 int *num_actions) 2720 { 2721 int result = BCM_E_UNAVAIL; 2722 #if defined(INCLUDE_FLOWTRACKER) 2723 /* Take lock */ 2724 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 2725 if ((soc_feature(unit, soc_feature_uc_flowtracker_learn) && 2726 soc_feature(unit, soc_feature_uc_flowtracker_export)) || 2727 soc_feature(unit, soc_feature_mv2_style_flowtracker)) { 2728 result = _bcm_th_ft_group_actions_get(unit, flow_group_id, flags, 2729 max_actions, action_list, 2730 num_actions); 2731 } 2732 /* Release lock */ 2733 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 2734 #endif /* INCLUDE_FLOWTRACKER */ 2735 return result; 2736 } 2737 2738 /* 2739 * Function: 2740 * bcm_esw_flowtracker_elephant_profile_create 2741 * Purpose: 2742 * Create flowtracker elephant profile 2743 * Parameters: 2744 * unit - (IN) BCM device number 2745 * options - (IN) Elephant profile creation options. 2746 * profile - (IN) Elephant profile information 2747 * profile_id - (IN/OUT) Elephant profile id 2748 * Returns: 2749 * BCM_E_XXX - BCM error code. 2750 */ 2751 int bcm_esw_flowtracker_elephant_profile_create( 2752 int unit, 2753 uint32 options, 2754 bcm_flowtracker_elephant_profile_info_t *profile, 2755 bcm_flowtracker_elephant_profile_t *profile_id) 2756 { 2757 int result = BCM_E_UNAVAIL; 2758 #if defined(INCLUDE_FLOWTRACKER) 2759 /* Take lock */ 2760 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 2761 if ((soc_feature(unit, soc_feature_uc_flowtracker_learn) && 2762 soc_feature(unit, soc_feature_uc_flowtracker_export)) || 2763 soc_feature(unit, soc_feature_mv2_style_flowtracker)) { 2764 result = _bcm_th_ft_elephant_profile_create(unit, options, 2765 profile, profile_id); 2766 } 2767 /* Release lock */ 2768 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 2769 #endif /* INCLUDE_FLOWTRACKER */ 2770 return result; 2771 } 2772 /* 2773 * Function: 2774 * bcm_esw_flowtracker_elephant_profile_destroy 2775 * Purpose: 2776 * Destroy a flowtracker elephant profile. 2777 * Parameters: 2778 * unit - (IN) BCM device number 2779 * profile_id - (IN/OUT) Elephant profile id 2780 * Returns: 2781 * BCM_E_XXX - BCM error code. 2782 */ 2783 int bcm_esw_flowtracker_elephant_profile_destroy( 2784 int unit, 2785 bcm_flowtracker_elephant_profile_t profile_id) 2786 { 2787 int result = BCM_E_UNAVAIL; 2788 #if defined(INCLUDE_FLOWTRACKER) 2789 /* Take lock */ 2790 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 2791 if ((soc_feature(unit, soc_feature_uc_flowtracker_learn) && 2792 soc_feature(unit, soc_feature_uc_flowtracker_export)) || 2793 soc_feature(unit, soc_feature_mv2_style_flowtracker)) { 2794 result = _bcm_th_ft_elephant_profile_destroy(unit, profile_id); 2795 } 2796 /* Release lock */ 2797 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 2798 #endif /* INCLUDE_FLOWTRACKER */ 2799 return result; 2800 } 2801 2802 /* 2803 * Function: 2804 * bcm_esw_flowtracker_elephant_profile_get 2805 * Purpose: 2806 * Get flowtracker elephant profile information. 2807 * Parameters: 2808 * unit - (IN) BCM device number 2809 * profile_id - (IN) Elephant profile id 2810 * profile - (OUT) Elephant profile information 2811 * Returns: 2812 * BCM_E_XXX - BCM error code. 2813 */ 2814 int bcm_esw_flowtracker_elephant_profile_get( 2815 int unit, 2816 bcm_flowtracker_elephant_profile_t profile_id, 2817 bcm_flowtracker_elephant_profile_info_t *profile) 2818 { 2819 int result = BCM_E_UNAVAIL; 2820 #if defined(INCLUDE_FLOWTRACKER) 2821 /* Take lock */ 2822 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 2823 if ((soc_feature(unit, soc_feature_uc_flowtracker_learn) && 2824 soc_feature(unit, soc_feature_uc_flowtracker_export)) || 2825 soc_feature(unit, soc_feature_mv2_style_flowtracker)) { 2826 result = _bcm_th_ft_elephant_profile_get(unit, 2827 profile_id, 2828 profile); 2829 } 2830 /* Release lock */ 2831 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 2832 #endif /* INCLUDE_FLOWTRACKER */ 2833 return result; 2834 } 2835 2836 /* 2837 * Function: 2838 * bcm_esw_flowtracker_elephant_profile_get_all 2839 * Purpose: 2840 * Get the list of all flowtracker elephant profiles configured. 2841 * Parameters: 2842 * unit - (IN) BCM device number 2843 * max - (IN) Max number of profile information that can be 2844 * accomodated within profile_list. 2845 * profile_list - (OUT) List of Elephant profile Ids configured 2846 * count - (OUT) Actual number of elephant profiles 2847 * Returns: 2848 * BCM_E_XXX - BCM error code. 2849 */ 2850 int bcm_esw_flowtracker_elephant_profile_get_all( 2851 int unit, 2852 int max, 2853 bcm_flowtracker_elephant_profile_t *profile_list, 2854 int *count) 2855 { 2856 int result = BCM_E_UNAVAIL; 2857 #if defined(INCLUDE_FLOWTRACKER) 2858 /* Take lock */ 2859 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 2860 if ((soc_feature(unit, soc_feature_uc_flowtracker_learn) && 2861 soc_feature(unit, soc_feature_uc_flowtracker_export)) || 2862 soc_feature(unit, soc_feature_mv2_style_flowtracker)) { 2863 result = _bcm_th_ft_elephant_profile_get_all(unit, max, 2864 profile_list, 2865 count); 2866 } 2867 /* Release lock */ 2868 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 2869 #endif /* INCLUDE_FLOWTRACKER */ 2870 return result; 2871 } 2872 2873 /* 2874 * Function: 2875 * bcm_esw_flowtracker_group_elephant_profile_attach 2876 * Purpose: 2877 * Attach a flow group with an elephant profile. 2878 * Parameters: 2879 * unit - (IN) BCM device number 2880 * flow_group_id - (IN) Flow group Id 2881 * profile_id - (IN) Elephant profile id 2882 * Returns: 2883 * BCM_E_XXX - BCM error code. 2884 */ 2885 int bcm_esw_flowtracker_group_elephant_profile_attach( 2886 int unit, 2887 bcm_flowtracker_group_t flow_group_id, 2888 bcm_flowtracker_elephant_profile_t profile_id) 2889 { 2890 int result = BCM_E_UNAVAIL; 2891 #if defined(INCLUDE_FLOWTRACKER) 2892 /* Take lock */ 2893 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 2894 if ((soc_feature(unit, soc_feature_uc_flowtracker_learn) && 2895 soc_feature(unit, soc_feature_uc_flowtracker_export)) || 2896 soc_feature(unit, soc_feature_mv2_style_flowtracker)) { 2897 result = _bcm_th_ft_group_elephant_profile_attach(unit, 2898 flow_group_id, 2899 profile_id); 2900 } 2901 /* Release lock */ 2902 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 2903 #endif /* INCLUDE_FLOWTRACKER */ 2904 return result; 2905 } 2906 2907 /* 2908 * Function: 2909 * bcm_esw_flowtracker_group_elephant_profile_attach_get 2910 * Purpose: 2911 * Get the elephant profile Id attached with a flow group. 2912 * Parameters: 2913 * unit - (IN) BCM device number 2914 * flow_group_id - (IN) Flow group Id 2915 * profile_id - (OUT) Elephant profile id 2916 * Returns: 2917 * BCM_E_XXX - BCM error code. 2918 */ 2919 int bcm_esw_flowtracker_group_elephant_profile_attach_get( 2920 int unit, 2921 bcm_flowtracker_group_t flow_group_id, 2922 bcm_flowtracker_elephant_profile_t *profile_id) 2923 { 2924 int result = BCM_E_UNAVAIL; 2925 #if defined(INCLUDE_FLOWTRACKER) 2926 /* Take lock */ 2927 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 2928 if ((soc_feature(unit, soc_feature_uc_flowtracker_learn) && 2929 soc_feature(unit, soc_feature_uc_flowtracker_export)) || 2930 soc_feature(unit, soc_feature_mv2_style_flowtracker)) { 2931 result = _bcm_th_ft_group_elephant_profile_attach_get(unit, 2932 flow_group_id, 2933 profile_id); 2934 } 2935 /* Release lock */ 2936 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 2937 #endif /* INCLUDE_FLOWTRACKER */ 2938 return result; 2939 } 2940 2941 /* 2942 * Function: 2943 * bcm_esw_flowtracker_group_elephant_profile_detach 2944 * Purpose: 2945 * Detach a flow group from an elephant profile. 2946 * Parameters: 2947 * unit - (IN) BCM device number 2948 * flow_group_id - (IN) Flow group Id 2949 * Returns: 2950 * BCM_E_XXX - BCM error code. 2951 */ 2952 int bcm_esw_flowtracker_group_elephant_profile_detach( 2953 int unit, 2954 bcm_flowtracker_group_t flow_group_id) 2955 { 2956 int result = BCM_E_UNAVAIL; 2957 #if defined(INCLUDE_FLOWTRACKER) 2958 /* Take lock */ 2959 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 2960 if ((soc_feature(unit, soc_feature_uc_flowtracker_learn) && 2961 soc_feature(unit, soc_feature_uc_flowtracker_export)) || 2962 soc_feature(unit, soc_feature_mv2_style_flowtracker)) { 2963 result = _bcm_th_ft_group_elephant_profile_detach(unit, 2964 flow_group_id); 2965 } 2966 /* Release lock */ 2967 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 2968 #endif /* INCLUDE_FLOWTRACKER */ 2969 return result; 2970 } 2971 #ifdef BCM_WARM_BOOT_SUPPORT 2972 /* 2973 * Function: 2974 * _bcm_esw_flowtracker_sync 2975 * Purpose: 2976 * Warmboot scache sync 2977 * Parameters: 2978 * unit - (IN) Unit number. 2979 * Returns: 2980 * BCM_E_XXX 2981 * Notes: 2982 */ 2983 int _bcm_esw_flowtracker_sync(int unit) 2984 { 2985 int result = BCM_E_UNAVAIL; 2986 #if defined(INCLUDE_FLOWTRACKER) 2987 /* Take lock */ 2988 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 2989 if ((soc_feature(unit, soc_feature_uc_flowtracker_learn) && 2990 soc_feature(unit, soc_feature_uc_flowtracker_export)) || 2991 soc_feature(unit, soc_feature_mv2_style_flowtracker)) { 2992 result = _bcm_th_ft_sync(unit); 2993 } 2994 /* Release lock */ 2995 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 2996 #endif /* INCLUDE_FLOWTRACKER */ 2997 return result; 2998 } 2999 #endif /* BCM_WARM_BOOT_SUPPORT */ 3000 3001 /* 3002 * Function: 3003 * _bcm_esw_flowtracker_ucast_cosq_resolve 3004 * Purpose: 3005 * Convert the user passed cosq value to H/w cosq value 3006 * Parameters: 3007 * unit - (IN) BCM device number 3008 * cosq - (IN) Cosq value passed by the user 3009 * hw_cosq - (OUT) Cosq value to be programmed in the H/w 3010 * Returns: 3011 * BCM_E_XXX - BCM error code. 3012 */ 3013 int 3014 _bcm_esw_flowtracker_ucast_cosq_resolve(int unit, uint32 cosq, int *hw_cosq) 3015 { 3016 int rv = BCM_E_NONE; 3017 3018 if (BCM_GPORT_IS_UCAST_QUEUE_GROUP(cosq)) { 3019 if (SOC_IS_TOMAHAWKX(unit)) { 3020 #if defined(BCM_TOMAHAWK_SUPPORT) 3021 rv = _bcm_th_cosq_index_resolve(unit, cosq, 0, 3022 _BCM_TH_COSQ_INDEX_STYLE_UCAST_QUEUE, 3023 NULL, hw_cosq, NULL); 3024 #endif /* BCM_TOMAHAWK_SUPPORT */ 3025 } else if (SOC_IS_TRIDENT3(unit)) { 3026 #if defined(BCM_TRIDENT3_SUPPORT) 3027 rv = _bcm_td3_cosq_index_resolve(unit, cosq, 0, 3028 _BCM_TH_COSQ_INDEX_STYLE_UCAST_QUEUE, 3029 NULL, hw_cosq, NULL); 3030 #endif /* BCM_TRIDENT3_SUPPORT */ 3031 } else { 3032 rv = BCM_E_UNAVAIL; 3033 } 3034 } else { 3035 *hw_cosq = cosq; 3036 rv = BCM_E_NONE; 3037 } 3038 return rv; 3039 } 3040 3041 /* 3042 * Function: 3043 * _bcm_esw_flowtracker_mcast_cosq_resolve 3044 * Purpose: 3045 * Convert the user passed cosq value to H/w cosq value 3046 * Parameters: 3047 * unit - (IN) BCM device number 3048 * cosq - (IN) Cosq value passed by the user 3049 * hw_cosq - (OUT) Cosq value to be programmed in the H/w 3050 * Returns: 3051 * BCM_E_XXX - BCM error code. 3052 */ 3053 int 3054 _bcm_esw_flowtracker_mcast_cosq_resolve(int unit, uint32 cosq, int *hw_cosq) 3055 { 3056 int rv = BCM_E_UNAVAIL; 3057 3058 if (BCM_GPORT_IS_MCAST_QUEUE_GROUP(cosq)) { 3059 if (SOC_IS_TOMAHAWKX(unit)) { 3060 #if defined(BCM_TOMAHAWK_SUPPORT) 3061 rv = _bcm_th_cosq_index_resolve(unit, cosq, 0, 3062 _BCM_TH_COSQ_INDEX_STYLE_MCAST_QUEUE, 3063 NULL, hw_cosq, NULL); 3064 #endif /* BCM_TOMAHAWK_SUPPORT */ 3065 } else if (SOC_IS_TRIDENT3(unit)) { 3066 #if defined(BCM_TRIDENT3_SUPPORT) 3067 rv = _bcm_td3_cosq_index_resolve(unit, cosq, 0, 3068 _BCM_TH_COSQ_INDEX_STYLE_MCAST_QUEUE, 3069 NULL, hw_cosq, NULL); 3070 #endif /* BCM_TRIDENT3_SUPPORT */ 3071 } else { 3072 rv = BCM_E_UNAVAIL; 3073 } 3074 } else { 3075 *hw_cosq = cosq; 3076 rv = BCM_E_NONE; 3077 } 3078 return rv; 3079 } 3080 3081 void _bcm_esw_flowtracker_sw_dump(int unit) 3082 { 3083 #if defined(INCLUDE_FLOWTRACKER) 3084 if ((soc_feature(unit, soc_feature_uc_flowtracker_learn) || 3085 soc_feature(unit, soc_feature_uc_flowtracker_export)) || 3086 soc_feature(unit, soc_feature_mv2_style_flowtracker)) { 3087 _bcm_xgs5_flowtracker_sw_dump(unit); 3088 } 3089 #endif /* INCLUDE_FLOWTRACKER */ 3090 } 3091 3092 /* 3093 * Function: 3094 * _bcm_esw_flowtracker_dump_stats_learn 3095 * Purpose: 3096 * Dump the learn statistics 3097 * Parameters: 3098 * unit - (IN) BCM device number 3099 * Returns: 3100 * BCM_E_XXX - BCM error code. 3101 */ 3102 void _bcm_esw_flowtracker_dump_stats_learn(int unit) 3103 { 3104 #if defined(INCLUDE_FLOWTRACKER) 3105 if (soc_feature(unit, soc_feature_uc_flowtracker_learn) || 3106 soc_feature(unit, soc_feature_uc_flowtracker_export)) { 3107 _bcm_xgs5_flowtracker_dump_stats_learn(unit); 3108 } 3109 #endif /* INCLUDE_FLOWTRACKER */ 3110 } 3111 3112 /* 3113 * Function: 3114 * _bcm_esw_flowtracker_dump_stats_export 3115 * Purpose: 3116 * Dump the export statistics 3117 * Parameters: 3118 * unit - (IN) BCM device number 3119 * Returns: 3120 * BCM_E_XXX - BCM error code. 3121 */ 3122 void _bcm_esw_flowtracker_dump_stats_export(int unit) 3123 { 3124 #if defined(INCLUDE_FLOWTRACKER) 3125 if (soc_feature(unit, soc_feature_uc_flowtracker_learn) || 3126 soc_feature(unit, soc_feature_uc_flowtracker_export)) { 3127 _bcm_xgs5_flowtracker_dump_stats_export(unit); 3128 } 3129 #endif /* INCLUDE_FLOWTRACKER */ 3130 } 3131 3132 /* 3133 * Function: 3134 * _bcm_esw_flowtracker_dump_stats_age 3135 * Purpose: 3136 * Dump the age statistics 3137 * Parameters: 3138 * unit - (IN) BCM device number 3139 * Returns: 3140 * BCM_E_XXX - BCM error code. 3141 */ 3142 void _bcm_esw_flowtracker_dump_stats_age(int unit) 3143 { 3144 #if defined(INCLUDE_FLOWTRACKER) 3145 if (soc_feature(unit, soc_feature_uc_flowtracker_learn) || 3146 soc_feature(unit, soc_feature_uc_flowtracker_export)) { 3147 _bcm_xgs5_flowtracker_dump_stats_age(unit); 3148 } 3149 #endif /* INCLUDE_FLOWTRACKER */ 3150 } 3151 3152 /* 3153 * Function: 3154 * _bcm_esw_flowtracker_dump_stats_elephant 3155 * Purpose: 3156 * Dump the elephant statistics 3157 * Parameters: 3158 * unit - (IN) BCM device number 3159 * Returns: 3160 * BCM_E_XXX - BCM error code. 3161 */ 3162 void _bcm_esw_flowtracker_dump_stats_elephant(int unit) 3163 { 3164 #if defined(INCLUDE_FLOWTRACKER) 3165 if (soc_feature(unit, soc_feature_uc_flowtracker_learn) || 3166 soc_feature(unit, soc_feature_uc_flowtracker_export)) { 3167 _bcm_xgs5_flowtracker_dump_stats_elephant(unit); 3168 } 3169 #endif /* INCLUDE_FLOWTRACKER */ 3170 } 3171 3172 /* 3173 * Function: 3174 * bcm_esw_flowtracker_chip_debug_info_set 3175 * Purpose: 3176 * Set chip debug information. 3177 * Parameters: 3178 * unit - (IN) BCM device number 3179 * num_debug_info - (OUT) actunal number of parameters 3180 * info - (OUT) memory to send parameters. 3181 * Returns: 3182 * BCM_E_XXX - BCM error code. 3183 */ 3184 int bcm_esw_flowtracker_chip_debug_info_set( 3185 int unit, 3186 int num_debug_info, 3187 bcm_flowtracker_chip_debug_info_t *info) 3188 { 3189 int result = BCM_E_UNAVAIL; 3190 3191 #if defined(BCM_FLOWTRACKER_SUPPORT) 3192 /* Take lock */ 3193 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 3194 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 3195 result = bcmi_ft_chip_debug_info_set(unit, num_debug_info, info); 3196 } 3197 /* Release lock */ 3198 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 3199 #endif /* BCM_FLOWTRACKER_SUPPORT */ 3200 3201 return result; 3202 } 3203 3204 3205 /* 3206 * Function: 3207 * bcm_esw_flowtracker_chip_debug_info_get 3208 * Purpose: 3209 * Get chip debug information. 3210 * Parameters: 3211 * unit - (IN) BCM device number 3212 * max_debug_info - (INOUT) maximum number that user wants. 3213 * info - (OUT) memory to send parameters. 3214 * num_debug_info - (OUT) actunal number of parameters 3215 * Returns: 3216 * BCM_E_XXX - BCM error code. 3217 */ 3218 int bcm_esw_flowtracker_chip_debug_info_get( 3219 int unit, 3220 int max_debug_info, 3221 bcm_flowtracker_chip_debug_info_t *info, 3222 int *num_debug_info) 3223 { 3224 int result = BCM_E_UNAVAIL; 3225 3226 #if defined(BCM_FLOWTRACKER_SUPPORT) 3227 /* Take lock */ 3228 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 3229 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 3230 result = bcmi_ft_chip_debug_info_get(unit, max_debug_info, 3231 info, num_debug_info); 3232 } 3233 /* Release lock */ 3234 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 3235 #endif /* BCM_FLOWTRACKER_SUPPORT */ 3236 3237 return result; 3238 } 3239 3240 #if defined(BCM_FLOWTRACKER_SUPPORT) 3241 /* 3242 * Function: 3243 * bcmi_ft_group_hw_install 3244 * Purpose: 3245 * Install hardware resource for the group. 3246 * Description: 3247 * Install flowtracker group. 3248 * Parameters: 3249 * unit - (IN) BCM device id 3250 * id - (IN) FT group id. 3251 * 3252 * Returns: 3253 * BCM_E_XXX 3254 */ 3255 int 3256 bcmi_esw_ft_group_hw_install( 3257 int unit, 3258 bcm_flowtracker_group_t id) 3259 { 3260 int result = BCM_E_UNAVAIL; 3261 3262 /* Take lock */ 3263 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 3264 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 3265 result = bcmi_ft_group_hw_install(unit, id); 3266 } 3267 /* Release lock */ 3268 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 3269 3270 return result; 3271 } 3272 3273 /* 3274 * Function: 3275 * bcmi_ft_group_hw_uninstall 3276 * Purpose: 3277 * Uninstall hardware resource for the group. 3278 * Parameters: 3279 * unit - (IN) BCM device id 3280 * id - (IN) FT group id. 3281 * 3282 * Returns: 3283 * BCM_E_XXX 3284 */ 3285 int 3286 bcmi_esw_ft_group_hw_uninstall( 3287 int unit, 3288 bcm_flowtracker_group_t id) 3289 3290 { 3291 int result = BCM_E_UNAVAIL; 3292 3293 /* Take lock */ 3294 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 3295 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 3296 result = bcmi_ft_group_hw_uninstall(unit, id); 3297 } 3298 /* Release lock */ 3299 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 3300 3301 return result; 3302 } 3303 3304 /* 3305 * Function: 3306 * bcmi_esw_ft_group_extraction_mode_set 3307 * Purpose: 3308 * Set extraction mode. 3309 * Parameters: 3310 * unit - (IN) BCM device id 3311 * key_or_data - (IN) key/data 3312 * id - (IN) FT group id. 3313 * mode - (IN) Mode of the extration key/data. 3314 * 3315 * Returns: 3316 * BCM_E_XXX 3317 */ 3318 int 3319 bcmi_esw_ft_group_extraction_mode_set( 3320 int unit, 3321 int key_or_data, 3322 bcm_flowtracker_group_t id, 3323 bcmi_ft_group_key_data_mode_t mode) 3324 { 3325 int result = BCM_E_UNAVAIL; 3326 3327 /* Take lock */ 3328 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 3329 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 3330 result = bcmi_ft_group_extraction_mode_set(unit, key_or_data, id, mode); 3331 } 3332 /* Release lock */ 3333 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 3334 3335 return result; 3336 } 3337 3338 /* 3339 * Function: 3340 * bcmi_esw_ft_group_extraction_mode_get 3341 * Purpose: 3342 * Get extraction mode. 3343 * Parameters: 3344 * unit - (IN) BCM device id 3345 * key_or_data - (IN) key/data 3346 * id - (IN) FT group id. 3347 * mode - (OUT) Mode of the extration key/data. 3348 * 3349 * Returns: 3350 * BCM_E_XXX 3351 */ 3352 int 3353 bcmi_esw_ft_group_extraction_mode_get( 3354 int unit, 3355 int key_or_data, 3356 bcm_flowtracker_group_t id, 3357 bcmi_ft_group_key_data_mode_t *mode) 3358 { 3359 int result = BCM_E_UNAVAIL; 3360 3361 /* Take lock */ 3362 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 3363 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 3364 result = bcmi_ft_group_extraction_mode_get(unit, key_or_data, id, mode); 3365 } 3366 /* Release lock */ 3367 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 3368 3369 return result; 3370 } 3371 3372 /* 3373 * Function: 3374 * bcmi_esw_ft_group_extraction_hw_info_set 3375 * Purpose: 3376 * Set hardware extraction info in group sw state. 3377 * Parameters: 3378 * unit - (IN) BCM device id 3379 * id - (IN) FT group id. 3380 * key_or_data - (IN) key/data 3381 * num_elements - (IN) Number of elements of hw extraction. 3382 * elements - (IN) list of hw extrator info. 3383 * 3384 * Returns: 3385 * BCM_E_XXX 3386 */ 3387 int 3388 bcmi_esw_ft_group_extraction_hw_info_set( 3389 int unit, 3390 bcm_flowtracker_group_t id, 3391 int key_or_data, 3392 int num_elements, 3393 bcmi_ft_hw_extractor_info_t *elements) 3394 { 3395 int result = BCM_E_UNAVAIL; 3396 3397 /* Take lock */ 3398 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 3399 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 3400 result = bcmi_ft_group_extraction_hw_info_set(unit, id, key_or_data, 3401 num_elements, elements); 3402 } 3403 /* Release lock */ 3404 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 3405 3406 return result; 3407 } 3408 3409 3410 /* 3411 * Function: 3412 * bcmi_esw_ft_group_extraction_hw_info_get 3413 * Purpose: 3414 * Get hardware extraction info in group sw state. 3415 * Parameters: 3416 * unit - (IN) BCM device id 3417 * id - (IN) FT group id. 3418 * key_or_data - (IN) key/data 3419 * max_elements - (IN) Max elements that user asked for. 3420 * elements - (OUT) list of hw extrator info. 3421 * num_elements - (OUT) Number of elements of hw extraction. 3422 * 3423 * Returns: 3424 * BCM_E_XXX 3425 */ 3426 int 3427 bcmi_esw_ft_group_extraction_hw_info_get( 3428 int unit, 3429 int key_or_data, 3430 bcm_flowtracker_group_t id, 3431 int max_elements, 3432 bcmi_ft_hw_extractor_info_t *elements, 3433 int *num_elements) 3434 { 3435 int result = BCM_E_UNAVAIL; 3436 3437 /* Take lock */ 3438 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 3439 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 3440 result = bcmi_ft_group_extraction_hw_info_get(unit, key_or_data, id, 3441 max_elements, elements, 3442 num_elements); 3443 } 3444 /* Release lock */ 3445 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 3446 3447 return result; 3448 } 3449 3450 3451 /* 3452 * Function: 3453 * bcmi_esw_ft_group_extraction_alu_info_set 3454 * Purpose: 3455 * Set Alu extraction info in group sw state. 3456 * Parameters: 3457 * unit - (IN) BCM device id 3458 * id - (IN) FT group id. 3459 * num_alu_info - (IN) Number of ALU/lod info structure. 3460 * alu_info - (IN) list if ALU/load information. 3461 * 3462 * Returns: 3463 * BCM_E_XXX 3464 */ 3465 int 3466 bcmi_esw_ft_group_extraction_alu_info_set( 3467 int unit, 3468 bcm_flowtracker_group_t id, 3469 int key_or_data, 3470 int num_alu_info, 3471 bcmi_ft_group_alu_info_t *alu_info) 3472 { 3473 int result = BCM_E_UNAVAIL; 3474 3475 /* Take lock */ 3476 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 3477 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 3478 result = bcmi_ft_group_extraction_alu_info_set(unit, id, key_or_data, 3479 num_alu_info, alu_info); 3480 } 3481 /* Release lock */ 3482 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 3483 3484 return result; 3485 } 3486 3487 /* 3488 * Function: 3489 * bcmi_esw_ft_group_extraction_alu_info_get 3490 * Purpose: 3491 * Get Alu extraction info of group sw state. 3492 * Parameters: 3493 * unit - (IN) BCM device id 3494 * id - (IN) FT group id. 3495 * max_alu_info - (IN) max information user asked for. 3496 * alu_info - (OUT) list if ALU/load information. 3497 * num_alu_info - (OUT) Number of ALU/lod info structure. 3498 * 3499 * Returns: 3500 * BCM_E_XXX 3501 */ 3502 int 3503 bcmi_esw_ft_group_extraction_alu_info_get( 3504 int unit, 3505 bcm_flowtracker_group_t id, 3506 int key_or_data, 3507 int max_alu_info, 3508 bcmi_ft_group_alu_info_t *alu_info, 3509 int *num_alu_info) 3510 { 3511 int result = BCM_E_UNAVAIL; 3512 3513 /* Take lock */ 3514 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 3515 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 3516 result = bcmi_ft_group_extraction_alu_info_get(unit, id, key_or_data, 3517 max_alu_info, alu_info, 3518 num_alu_info); 3519 } 3520 /* Release lock */ 3521 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 3522 3523 return result; 3524 } 3525 3526 /* 3527 * Function: 3528 * bcmi_esw_ft_group_param_update 3529 * Purpose: 3530 * Update group state parameters. 3531 * Parameters: 3532 * unit - (IN) BCM device id 3533 * id - (IN) FT group id. 3534 * param - (IN) Group's parameters. 3535 * opr - (IN) operation to be performed on data. 3536 * arg - (IN) argument value. 3537 * 3538 * Returns: 3539 * BCM_E_XXX 3540 */ 3541 int 3542 bcmi_esw_ft_group_param_update(int unit, 3543 bcm_flowtracker_group_t id, 3544 bcmi_ft_group_params_t param, 3545 bcmi_ft_group_params_operation_t opr, 3546 int arg) 3547 { 3548 int result = BCM_E_UNAVAIL; 3549 3550 /* Take lock */ 3551 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 3552 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 3553 result = bcmi_ft_group_param_update(unit, id, param, opr, arg); 3554 } 3555 /* Release lock */ 3556 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 3557 3558 return result; 3559 } 3560 3561 /* 3562 * Function: 3563 * bcmi_esw_ft_group_param_retrieve 3564 * Purpose: 3565 * Get group state parameters. 3566 * Parameters: 3567 * unit - (IN) BCM device id 3568 * id - (IN) FT group id. 3569 * param - (IN) Group's parameters. 3570 * arg - (OUT) argument value. 3571 * 3572 * Returns: 3573 * BCM_E_XXX 3574 */ 3575 int 3576 bcmi_esw_ft_group_param_retrieve(int unit, 3577 bcm_flowtracker_group_t id, 3578 bcmi_ft_group_params_t param, 3579 int *arg) 3580 3581 { 3582 int result = BCM_E_UNAVAIL; 3583 3584 /* Take lock */ 3585 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_lock(unit)); 3586 if (soc_feature(unit, soc_feature_flex_flowtracker_ver_1)) { 3587 result = bcmi_ft_group_param_retrieve(unit, id, param, arg); 3588 } 3589 /* Release lock */ 3590 BCM_IF_ERROR_RETURN(bcm_esw_flowtracker_unlock(unit)); 3591 3592 return result; 3593 } 3594 3595 #endif /* BCM_FLOWTRACKER_SUPPORT */ 3596