port.c (101141B)
1 /* 2 * 3 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 4 * 5 * Copyright 2007-2019 Broadcom Inc. All rights reserved. 6 * 7 * File: src/bcmx/port.c 8 * Purpose: BCMX port APIs 9 */ 10 11 #include <sal/core/libc.h> 12 #include <shared/alloc.h> 13 14 #include <bcm/types.h> 15 16 #include <bcmx/port.h> 17 #include <bcmx/lport.h> 18 #include <bcmx/bcmx.h> 19 #include <bcmx/lplist.h> 20 21 #include "bcmx_int.h" 22 23 #define BCMX_PORT_INIT_CHECK BCMX_READY_CHECK 24 25 #define BCMX_PORT_SET_ERROR_CHECK(_unit, _check, _rv) \ 26 BCMX_SET_ERROR_CHECK(_unit, _check, _rv) 27 28 #define BCMX_PORT_DELETE_ERROR_CHECK(_unit, _check, _rv) \ 29 BCMX_DELETE_ERROR_CHECK(_unit, _check, _rv) 30 31 #define BCMX_PORT_GET_IS_VALID(_unit, _rv) \ 32 BCMX_ERROR_IS_VALID(_unit, _rv) 33 34 35 #define BCMX_PORT_ABILITY_T_PTR_TO_BCM(_ability) \ 36 ((bcm_port_ability_t *)(_ability)) 37 38 #define BCMX_PORT_ENCAP_CONFIG_T_PTR_TO_BCM(_config) \ 39 ((bcm_port_encap_config_t *)(_config)) 40 41 #define BCMX_PORT_CONGESTION_CONFIG_T_PTR_TO_BCM(_config) \ 42 ((bcm_port_congestion_config_t *)(_config)) 43 44 #define BCMX_PORT_MATCH_INFO_T_PTR_TO_BCM(_port_match_info) \ 45 ((bcm_port_match_info_t *)(_port_match_info)) 46 47 #define BCMX_PORT_TIMESYNC_CONFIG_T_PTR_TO_BCM(_config) \ 48 ((bcm_port_phy_timesync_config_t *)(_config)) 49 50 #define BCMX_PORT_TIMESYNC_ENHANCED_CAPTURE_T_PTR_TO_BCM(_value) \ 51 ((bcm_port_phy_timesync_enhanced_capture_t *)(_value)) 52 53 /* 54 * Function: 55 * bcmx_port_config_t_init 56 * Purpose: 57 * Initialize a Port config object struct. 58 * Parameters: 59 * pconfig - Pointer to the Port Config object struct. 60 * Returns: 61 * NONE 62 */ 63 void 64 bcmx_port_config_t_init(bcmx_port_config_t *pconfig) 65 { 66 if (pconfig != NULL) { 67 sal_memset(pconfig, 0, sizeof (*pconfig)); 68 } 69 70 return; 71 } 72 73 74 /* 75 * Function: 76 * bcmx_port_encap_config_t_init 77 * Purpose: 78 * Initialize a port encapsulation configuration object struct. 79 * Parameters: 80 * encap_config - Pointer to the struct to be initialized. 81 * Returns: 82 * NONE 83 */ 84 void 85 bcmx_port_encap_config_t_init(bcmx_port_encap_config_t *encap_config) 86 { 87 if (encap_config != NULL) { 88 bcm_port_encap_config_t_init 89 (BCMX_PORT_ENCAP_CONFIG_T_PTR_TO_BCM(encap_config)); 90 } 91 92 return; 93 } 94 95 /* 96 * Function: 97 * bcmx_port_congestion_config_t_init 98 * Purpose: 99 * Initialize a port congestion configuration object struct. 100 * Parameters: 101 * config - Pointer to the struct to be initialized. 102 * Returns: 103 * NONE 104 */ 105 void 106 bcmx_port_congestion_config_t_init(bcmx_port_congestion_config_t *config) 107 { 108 if (config != NULL) { 109 bcm_port_congestion_config_t_init 110 (BCMX_PORT_CONGESTION_CONFIG_T_PTR_TO_BCM(config)); 111 } 112 113 return; 114 } 115 116 /* 117 * Function: 118 * bcmx_port_match_info_t_init 119 * Purpose: 120 * Initialize a port match info object struct. 121 * Parameters: 122 * port_match_info - Pointer to the struct to be initialized. 123 * Returns: 124 * NONE 125 */ 126 void 127 bcmx_port_match_info_t_init(bcmx_port_match_info_t *port_match_info) 128 { 129 if (port_match_info != NULL) { 130 bcm_port_match_info_t_init 131 (BCMX_PORT_MATCH_INFO_T_PTR_TO_BCM(port_match_info)); 132 } 133 134 return; 135 } 136 137 /* 138 * Function: 139 * bcmx_port_phy_timesync_config_t_init 140 * Purpose: 141 * Initialize a port phy_timesync config object struct. 142 * Parameters: 143 * conf - Pointer to the struct to be initialized. 144 * Returns: 145 * NONE 146 */ 147 void 148 bcmx_port_phy_timesync_config_t_init(bcmx_port_phy_timesync_config_t *conf) 149 { 150 if (conf != NULL) { 151 bcm_port_phy_timesync_config_t_init 152 (BCMX_PORT_TIMESYNC_CONFIG_T_PTR_TO_BCM(conf)); 153 } 154 155 return; 156 } 157 158 159 int 160 bcmx_port_config_get(bcmx_port_config_t *config) 161 { 162 bcm_port_config_t bcm_cfg; 163 int i, bcm_unit; 164 165 BCMX_PORT_INIT_CHECK; 166 167 BCMX_PARAM_NULL_CHECK(config); 168 169 BCM_IF_ERROR_RETURN(bcmx_lplist_clear(&config->fe)); 170 BCM_IF_ERROR_RETURN(bcmx_lplist_clear(&config->ge)); 171 BCM_IF_ERROR_RETURN(bcmx_lplist_clear(&config->xe)); 172 BCM_IF_ERROR_RETURN(bcmx_lplist_clear(&config->ce)); 173 BCM_IF_ERROR_RETURN(bcmx_lplist_clear(&config->e)); 174 BCM_IF_ERROR_RETURN(bcmx_lplist_clear(&config->hg)); 175 BCM_IF_ERROR_RETURN(bcmx_lplist_clear(&config->port)); 176 BCM_IF_ERROR_RETURN(bcmx_lplist_clear(&config->cpu)); 177 BCM_IF_ERROR_RETURN(bcmx_lplist_clear(&config->all)); 178 BCM_IF_ERROR_RETURN(bcmx_lplist_clear(&config->stack_int)); 179 BCM_IF_ERROR_RETURN(bcmx_lplist_clear(&config->stack_ext)); 180 181 BCMX_UNIT_ITER(bcm_unit, i) { 182 BCM_IF_ERROR_RETURN(bcm_port_config_get(bcm_unit, &bcm_cfg)); 183 BCM_IF_ERROR_RETURN 184 (BCMX_LPLIST_PBMP_ADD(&config->fe, bcm_unit, bcm_cfg.fe)); 185 BCM_IF_ERROR_RETURN 186 (BCMX_LPLIST_PBMP_ADD(&config->ge, bcm_unit, bcm_cfg.ge)); 187 BCM_IF_ERROR_RETURN 188 (BCMX_LPLIST_PBMP_ADD(&config->xe, bcm_unit, bcm_cfg.xe)); 189 BCM_IF_ERROR_RETURN 190 (BCMX_LPLIST_PBMP_ADD(&config->ce, bcm_unit, bcm_cfg.ce)); 191 BCM_IF_ERROR_RETURN 192 (BCMX_LPLIST_PBMP_ADD(&config->e, bcm_unit, bcm_cfg.e)); 193 BCM_IF_ERROR_RETURN 194 (BCMX_LPLIST_PBMP_ADD(&config->hg, bcm_unit, bcm_cfg.hg)); 195 BCM_IF_ERROR_RETURN 196 (BCMX_LPLIST_PBMP_ADD(&config->port, bcm_unit, bcm_cfg.port)); 197 BCM_IF_ERROR_RETURN 198 (BCMX_LPLIST_PBMP_ADD(&config->cpu, bcm_unit, bcm_cfg.cpu)); 199 BCM_IF_ERROR_RETURN 200 (BCMX_LPLIST_PBMP_ADD(&config->all, bcm_unit, bcm_cfg.all)); 201 202 /* Set 'stack_int' for cleanliness in case this field is 203 * supported in the future. 204 */ 205 BCM_IF_ERROR_RETURN 206 (BCMX_LPLIST_PBMP_ADD(&config->stack_int, bcm_unit, 207 bcm_cfg.stack_int)); 208 /* 209 * Member 'stack_ext' is all ports using hg/hg2 packet 210 * encapsulation and forwarding semantics. 211 */ 212 BCM_IF_ERROR_RETURN 213 (BCMX_LPLIST_PBMP_ADD(&config->stack_ext, bcm_unit, 214 bcm_cfg.stack_ext)); 215 } 216 217 return BCM_E_NONE; 218 } 219 220 int bcmx_port_lplist_populate(bcmx_lplist_t *list, uint32 flags) 221 { 222 bcm_port_config_t bcm_cfg; 223 int i, bcm_unit; 224 225 BCMX_PORT_INIT_CHECK; 226 227 BCM_IF_ERROR_RETURN(bcmx_lplist_clear(list)); 228 229 /* All ports requested? */ 230 if (flags & BCMX_PORT_LP_ALL) { 231 flags |= 232 (BCMX_PORT_LP_FE | 233 BCMX_PORT_LP_GE | 234 BCMX_PORT_LP_XE | 235 BCMX_PORT_LP_CE | 236 BCMX_PORT_LP_HG | 237 BCMX_PORT_LP_E | 238 BCMX_PORT_LP_PORT | 239 BCMX_PORT_LP_CPU | 240 BCMX_PORT_LP_STACK_INT | 241 BCMX_PORT_LP_STACK_EXT); 242 } 243 244 245 BCMX_UNIT_ITER(bcm_unit, i) { 246 247 BCM_IF_ERROR_RETURN(bcm_port_config_get(bcm_unit, &bcm_cfg)); 248 249 if (flags & BCMX_PORT_LP_FE) { 250 BCM_IF_ERROR_RETURN 251 (BCMX_LPLIST_PBMP_ADD(list, bcm_unit, bcm_cfg.fe)); 252 } 253 254 if (flags & BCMX_PORT_LP_GE) { 255 BCM_IF_ERROR_RETURN 256 (BCMX_LPLIST_PBMP_ADD(list, bcm_unit, bcm_cfg.ge)); 257 } 258 259 if (flags & BCMX_PORT_LP_XE) { 260 BCM_IF_ERROR_RETURN 261 (BCMX_LPLIST_PBMP_ADD(list, bcm_unit, bcm_cfg.xe)); 262 } 263 264 if (flags & BCMX_PORT_LP_CE) { 265 BCM_IF_ERROR_RETURN 266 (BCMX_LPLIST_PBMP_ADD(list, bcm_unit, bcm_cfg.ce)); 267 } 268 269 if (flags & BCMX_PORT_LP_HG) { 270 BCM_IF_ERROR_RETURN 271 (BCMX_LPLIST_PBMP_ADD(list, bcm_unit, bcm_cfg.hg)); 272 } 273 274 if (flags & BCMX_PORT_LP_E) { 275 BCM_IF_ERROR_RETURN 276 (BCMX_LPLIST_PBMP_ADD(list, bcm_unit, bcm_cfg.e)); 277 } 278 279 if (flags & BCMX_PORT_LP_PORT) { 280 BCM_IF_ERROR_RETURN 281 (BCMX_LPLIST_PBMP_ADD(list, bcm_unit, bcm_cfg.port)); 282 } 283 284 if (flags & BCMX_PORT_LP_CPU) { 285 BCM_IF_ERROR_RETURN 286 (BCMX_LPLIST_PBMP_ADD(list, bcm_unit, bcm_cfg.cpu)); 287 } 288 289 if (flags & BCMX_PORT_LP_STACK_INT) { 290 BCM_IF_ERROR_RETURN 291 (BCMX_LPLIST_PBMP_ADD(list, bcm_unit, bcm_cfg.stack_int)); 292 } 293 294 if (flags & BCMX_PORT_LP_STACK_EXT) { 295 BCM_IF_ERROR_RETURN 296 (BCMX_LPLIST_PBMP_ADD(list, bcm_unit, bcm_cfg.stack_ext)); 297 } 298 299 } 300 301 return BCM_E_NONE; 302 } 303 304 int 305 bcmx_port_enable_set(bcmx_lport_t port, int enable) 306 { 307 int bcm_unit; 308 bcm_port_t bcm_port; 309 310 BCMX_PORT_INIT_CHECK; 311 312 BCM_IF_ERROR_RETURN 313 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 314 BCMX_DEST_CONVERT_DEFAULT)); 315 316 return bcm_port_enable_set(bcm_unit, bcm_port, 317 enable); 318 } 319 320 321 int 322 bcmx_port_enable_get(bcmx_lport_t port, int *enable) 323 { 324 int bcm_unit; 325 bcm_port_t bcm_port; 326 327 BCMX_PORT_INIT_CHECK; 328 329 BCMX_PARAM_NULL_CHECK(enable); 330 331 BCM_IF_ERROR_RETURN 332 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 333 BCMX_DEST_CONVERT_DEFAULT)); 334 335 return bcm_port_enable_get(bcm_unit, bcm_port, 336 enable); 337 } 338 339 void 340 bcmx_port_ability_t_init(bcmx_port_ability_t *ability) 341 { 342 if (ability != NULL) { 343 bcm_port_ability_t_init(BCMX_PORT_ABILITY_T_PTR_TO_BCM(ability)); 344 } 345 } 346 347 int 348 bcmx_port_ability_advert_set(bcmx_lport_t port, 349 bcmx_port_ability_t *ability_mask) 350 { 351 int bcm_unit; 352 bcm_port_t bcm_port; 353 354 BCMX_PORT_INIT_CHECK; 355 356 BCMX_PARAM_NULL_CHECK(ability_mask); 357 358 BCM_IF_ERROR_RETURN 359 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 360 BCMX_DEST_CONVERT_DEFAULT)); 361 362 return bcm_port_ability_advert_set(bcm_unit, bcm_port, 363 BCMX_PORT_ABILITY_T_PTR_TO_BCM 364 (ability_mask)); 365 } 366 367 int 368 bcmx_port_ability_advert_get(bcmx_lport_t port, 369 bcmx_port_ability_t *ability_mask) 370 { 371 int bcm_unit; 372 bcm_port_t bcm_port; 373 374 BCMX_PORT_INIT_CHECK; 375 376 BCMX_PARAM_NULL_CHECK(ability_mask); 377 378 BCM_IF_ERROR_RETURN 379 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 380 BCMX_DEST_CONVERT_DEFAULT)); 381 382 return bcm_port_ability_advert_get(bcm_unit, bcm_port, 383 BCMX_PORT_ABILITY_T_PTR_TO_BCM 384 (ability_mask)); 385 } 386 387 int bcmx_port_ability_remote_get(bcmx_lport_t port, 388 bcmx_port_ability_t *ability_mask) 389 { 390 int bcm_unit; 391 bcm_port_t bcm_port; 392 393 BCMX_PORT_INIT_CHECK; 394 395 BCMX_PARAM_NULL_CHECK(ability_mask); 396 397 BCM_IF_ERROR_RETURN 398 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 399 BCMX_DEST_CONVERT_DEFAULT)); 400 401 return bcm_port_ability_remote_get(bcm_unit, bcm_port, 402 BCMX_PORT_ABILITY_T_PTR_TO_BCM 403 (ability_mask)); 404 } 405 406 int 407 bcmx_port_ability_local_get(bcmx_lport_t port, 408 bcmx_port_ability_t *ability_mask) 409 410 { 411 int bcm_unit; 412 bcm_port_t bcm_port; 413 414 BCMX_PORT_INIT_CHECK; 415 416 BCMX_PARAM_NULL_CHECK(ability_mask); 417 418 BCM_IF_ERROR_RETURN 419 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 420 BCMX_DEST_CONVERT_DEFAULT)); 421 422 return bcm_port_ability_local_get(bcm_unit, bcm_port, 423 BCMX_PORT_ABILITY_T_PTR_TO_BCM 424 (ability_mask)); 425 } 426 427 int 428 bcmx_port_advert_set(bcmx_lport_t port, bcm_port_abil_t ability_mask) 429 { 430 int bcm_unit; 431 bcm_port_t bcm_port; 432 433 BCMX_PORT_INIT_CHECK; 434 435 BCM_IF_ERROR_RETURN 436 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 437 BCMX_DEST_CONVERT_DEFAULT)); 438 439 return bcm_port_advert_set(bcm_unit, bcm_port, 440 ability_mask); 441 } 442 443 444 int 445 bcmx_port_advert_get(bcmx_lport_t port, bcm_port_abil_t *ability_mask) 446 { 447 int bcm_unit; 448 bcm_port_t bcm_port; 449 450 BCMX_PORT_INIT_CHECK; 451 452 BCMX_PARAM_NULL_CHECK(ability_mask); 453 454 BCM_IF_ERROR_RETURN 455 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 456 BCMX_DEST_CONVERT_DEFAULT)); 457 458 return bcm_port_advert_get(bcm_unit, bcm_port, 459 ability_mask); 460 } 461 462 463 int 464 bcmx_port_advert_remote_get(bcmx_lport_t port, bcm_port_abil_t *ability_mask) 465 { 466 int bcm_unit; 467 bcm_port_t bcm_port; 468 469 BCMX_PORT_INIT_CHECK; 470 471 BCMX_PARAM_NULL_CHECK(ability_mask); 472 473 BCM_IF_ERROR_RETURN 474 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 475 BCMX_DEST_CONVERT_DEFAULT)); 476 477 return bcm_port_advert_remote_get(bcm_unit, bcm_port, 478 ability_mask); 479 } 480 481 482 int 483 bcmx_port_ability_get(bcmx_lport_t port, bcm_port_abil_t *local_ability_mask) 484 { 485 int bcm_unit; 486 bcm_port_t bcm_port; 487 488 BCMX_PORT_INIT_CHECK; 489 490 BCMX_PARAM_NULL_CHECK(local_ability_mask); 491 492 BCM_IF_ERROR_RETURN 493 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 494 BCMX_DEST_CONVERT_DEFAULT)); 495 496 return bcm_port_ability_get(bcm_unit, bcm_port, 497 local_ability_mask); 498 } 499 500 501 int 502 bcmx_port_untagged_vlan_set(bcmx_lport_t port, bcm_vlan_t vid) 503 { 504 int bcm_unit; 505 bcm_port_t bcm_port; 506 507 BCMX_PORT_INIT_CHECK; 508 509 BCM_IF_ERROR_RETURN 510 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 511 BCMX_DEST_CONVERT_DEFAULT)); 512 513 return bcm_port_untagged_vlan_set(bcm_unit, bcm_port, 514 vid); 515 } 516 517 518 int 519 bcmx_port_untagged_vlan_get(bcmx_lport_t port, bcm_vlan_t *vid_ptr) 520 { 521 int bcm_unit; 522 bcm_port_t bcm_port; 523 524 BCMX_PORT_INIT_CHECK; 525 526 BCMX_PARAM_NULL_CHECK(vid_ptr); 527 528 BCM_IF_ERROR_RETURN 529 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 530 BCMX_DEST_CONVERT_DEFAULT)); 531 532 return bcm_port_untagged_vlan_get(bcm_unit, bcm_port, 533 vid_ptr); 534 } 535 536 537 int 538 bcmx_port_untagged_priority_set(bcmx_lport_t port, int priority) 539 { 540 int bcm_unit; 541 bcm_port_t bcm_port; 542 543 BCMX_PORT_INIT_CHECK; 544 545 BCM_IF_ERROR_RETURN 546 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 547 BCMX_DEST_CONVERT_DEFAULT)); 548 549 return bcm_port_untagged_priority_set(bcm_unit, bcm_port, 550 priority); 551 } 552 553 554 int 555 bcmx_port_untagged_priority_get(bcmx_lport_t port, int *priority) 556 { 557 int bcm_unit; 558 bcm_port_t bcm_port; 559 560 BCMX_PORT_INIT_CHECK; 561 562 BCMX_PARAM_NULL_CHECK(priority); 563 564 BCM_IF_ERROR_RETURN 565 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 566 BCMX_DEST_CONVERT_DEFAULT)); 567 568 return bcm_port_untagged_priority_get(bcm_unit, bcm_port, 569 priority); 570 } 571 572 573 int 574 bcmx_port_dscp_map_mode_set(bcmx_lport_t port, int mode) 575 { 576 int bcm_unit; 577 bcm_port_t bcm_port; 578 579 BCMX_PORT_INIT_CHECK; 580 581 BCM_IF_ERROR_RETURN 582 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 583 BCMX_DEST_CONVERT_DEFAULT)); 584 585 return bcm_port_dscp_map_mode_set(bcm_unit, bcm_port, 586 mode); 587 } 588 589 int 590 bcmx_port_dscp_map_mode_get(bcmx_lport_t port, int *mode) 591 { 592 int bcm_unit; 593 bcm_port_t bcm_port; 594 595 BCMX_PORT_INIT_CHECK; 596 597 BCMX_PARAM_NULL_CHECK(mode); 598 599 BCM_IF_ERROR_RETURN 600 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 601 BCMX_DEST_CONVERT_DEFAULT)); 602 603 return bcm_port_dscp_map_mode_get(bcm_unit, bcm_port, 604 mode); 605 } 606 607 int 608 bcmx_port_dscp_map_set(bcmx_lport_t port, 609 int srccp, 610 int mapcp, 611 int prio) 612 { 613 int rv = BCM_E_UNAVAIL, tmp_rv; 614 615 BCMX_PORT_INIT_CHECK; 616 617 if (port == BCMX_LPORT_ETHER_ALL) { 618 int i, bcm_unit; 619 int bcm_port_all = -1; /* all ether ports in BCM */ 620 621 BCMX_UNIT_ITER(bcm_unit, i) { 622 tmp_rv = bcm_port_dscp_map_set(bcm_unit, bcm_port_all, 623 srccp, mapcp, prio); 624 BCM_IF_ERROR_RETURN 625 (BCMX_PORT_SET_ERROR_CHECK(bcm_unit, tmp_rv, &rv)); 626 } 627 } else { 628 int bcm_unit; 629 bcm_port_t bcm_port; 630 631 BCM_IF_ERROR_RETURN 632 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 633 BCMX_DEST_CONVERT_DEFAULT)); 634 635 rv = bcm_port_dscp_map_set(bcm_unit, bcm_port, 636 srccp, mapcp, prio); 637 } 638 639 return rv; 640 } 641 642 643 int 644 bcmx_port_dscp_map_get(bcmx_lport_t port, 645 int srccp, 646 int *mapcp, 647 int *prio) 648 { 649 BCMX_PORT_INIT_CHECK; 650 651 BCMX_PARAM_NULL_CHECK(mapcp); 652 BCMX_PARAM_NULL_CHECK(prio); 653 654 if (port == BCMX_LPORT_ETHER_ALL) { 655 int rv, i, bcm_unit; 656 int bcm_port_all = -1; /* all ether ports in BCM */ 657 658 BCMX_UNIT_ITER(bcm_unit, i) { 659 rv = bcm_port_dscp_map_get(bcm_unit, bcm_port_all, 660 srccp, mapcp, prio); 661 if (BCMX_PORT_GET_IS_VALID(bcm_unit, rv)) { 662 return rv; 663 } 664 } 665 } else { 666 int bcm_unit; 667 bcm_port_t bcm_port; 668 669 BCM_IF_ERROR_RETURN 670 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 671 BCMX_DEST_CONVERT_DEFAULT)); 672 673 return bcm_port_dscp_map_get(bcm_unit, bcm_port, 674 srccp, mapcp, prio); 675 } 676 677 return BCM_E_UNAVAIL; 678 } 679 680 681 int 682 bcmx_port_linkscan_get(bcmx_lport_t port, int *linkscan) 683 { 684 int bcm_unit; 685 bcm_port_t bcm_port; 686 687 BCMX_PORT_INIT_CHECK; 688 689 BCMX_PARAM_NULL_CHECK(linkscan); 690 691 BCM_IF_ERROR_RETURN 692 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 693 BCMX_DEST_CONVERT_DEFAULT)); 694 695 return bcm_port_linkscan_get(bcm_unit, bcm_port, 696 linkscan); 697 } 698 699 700 int 701 bcmx_port_linkscan_set(bcmx_lport_t port, int linkscan) 702 { 703 int bcm_unit; 704 bcm_port_t bcm_port; 705 706 BCMX_PORT_INIT_CHECK; 707 708 BCM_IF_ERROR_RETURN 709 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 710 BCMX_DEST_CONVERT_DEFAULT)); 711 712 return bcm_port_linkscan_set(bcm_unit, bcm_port, 713 linkscan); 714 } 715 716 717 int 718 bcmx_port_autoneg_get(bcmx_lport_t port, int *autoneg) 719 { 720 int bcm_unit; 721 bcm_port_t bcm_port; 722 723 BCMX_PORT_INIT_CHECK; 724 725 BCMX_PARAM_NULL_CHECK(autoneg); 726 727 BCM_IF_ERROR_RETURN 728 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 729 BCMX_DEST_CONVERT_DEFAULT)); 730 731 return bcm_port_autoneg_get(bcm_unit, bcm_port, 732 autoneg); 733 } 734 735 736 int 737 bcmx_port_autoneg_set(bcmx_lport_t port, int autoneg) 738 { 739 int bcm_unit; 740 bcm_port_t bcm_port; 741 742 BCMX_PORT_INIT_CHECK; 743 744 BCM_IF_ERROR_RETURN 745 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 746 BCMX_DEST_CONVERT_DEFAULT)); 747 748 return bcm_port_autoneg_set(bcm_unit, bcm_port, 749 autoneg); 750 } 751 752 753 int 754 bcmx_port_speed_max(bcmx_lport_t port, int *speed) 755 { 756 int bcm_unit; 757 bcm_port_t bcm_port; 758 759 BCMX_PORT_INIT_CHECK; 760 761 BCMX_PARAM_NULL_CHECK(speed); 762 763 BCM_IF_ERROR_RETURN 764 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 765 BCMX_DEST_CONVERT_DEFAULT)); 766 767 return bcm_port_speed_max(bcm_unit, bcm_port, 768 speed); 769 } 770 771 772 int 773 bcmx_port_speed_get(bcmx_lport_t port, int *speed) 774 { 775 int bcm_unit; 776 bcm_port_t bcm_port; 777 778 BCMX_PORT_INIT_CHECK; 779 780 BCMX_PARAM_NULL_CHECK(speed); 781 782 BCM_IF_ERROR_RETURN 783 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 784 BCMX_DEST_CONVERT_DEFAULT)); 785 786 return bcm_port_speed_get(bcm_unit, bcm_port, 787 speed); 788 } 789 790 791 int 792 bcmx_port_speed_set(bcmx_lport_t port, int speed) 793 { 794 int bcm_unit; 795 bcm_port_t bcm_port; 796 797 BCMX_PORT_INIT_CHECK; 798 799 BCM_IF_ERROR_RETURN 800 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 801 BCMX_DEST_CONVERT_DEFAULT)); 802 803 return bcm_port_speed_set(bcm_unit, bcm_port, 804 speed); 805 } 806 807 808 int 809 bcmx_port_master_get(bcmx_lport_t port, int *ms) 810 { 811 int bcm_unit; 812 bcm_port_t bcm_port; 813 814 BCMX_PORT_INIT_CHECK; 815 816 BCMX_PARAM_NULL_CHECK(ms); 817 818 BCM_IF_ERROR_RETURN 819 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 820 BCMX_DEST_CONVERT_DEFAULT)); 821 822 return bcm_port_master_get(bcm_unit, bcm_port, 823 ms); 824 } 825 826 827 int 828 bcmx_port_master_set(bcmx_lport_t port, int ms) 829 { 830 int bcm_unit; 831 bcm_port_t bcm_port; 832 833 BCMX_PORT_INIT_CHECK; 834 835 BCM_IF_ERROR_RETURN 836 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 837 BCMX_DEST_CONVERT_DEFAULT)); 838 839 return bcm_port_master_set(bcm_unit, bcm_port, 840 ms); 841 } 842 843 844 int 845 bcmx_port_interface_get(bcmx_lport_t port, bcm_port_if_t *intf) 846 { 847 int bcm_unit; 848 bcm_port_t bcm_port; 849 850 BCMX_PORT_INIT_CHECK; 851 852 BCMX_PARAM_NULL_CHECK(intf); 853 854 BCM_IF_ERROR_RETURN 855 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 856 BCMX_DEST_CONVERT_DEFAULT)); 857 858 return bcm_port_interface_get(bcm_unit, bcm_port, 859 intf); 860 } 861 862 863 int 864 bcmx_port_interface_set(bcmx_lport_t port, bcm_port_if_t intf) 865 { 866 int bcm_unit; 867 bcm_port_t bcm_port; 868 869 BCMX_PORT_INIT_CHECK; 870 871 BCM_IF_ERROR_RETURN 872 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 873 BCMX_DEST_CONVERT_DEFAULT)); 874 875 return bcm_port_interface_set(bcm_unit, bcm_port, 876 intf); 877 } 878 879 880 int 881 bcmx_port_duplex_get(bcmx_lport_t port, int *duplex) 882 { 883 int bcm_unit; 884 bcm_port_t bcm_port; 885 886 BCMX_PORT_INIT_CHECK; 887 888 BCM_IF_ERROR_RETURN 889 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 890 BCMX_DEST_CONVERT_DEFAULT)); 891 892 return bcm_port_duplex_get(bcm_unit, bcm_port, 893 duplex); 894 } 895 896 897 int 898 bcmx_port_duplex_set(bcmx_lport_t port, int duplex) 899 { 900 int bcm_unit; 901 bcm_port_t bcm_port; 902 903 BCMX_PORT_INIT_CHECK; 904 905 BCM_IF_ERROR_RETURN 906 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 907 BCMX_DEST_CONVERT_DEFAULT)); 908 909 return bcm_port_duplex_set(bcm_unit, bcm_port, 910 duplex); 911 } 912 913 914 int 915 bcmx_port_pause_get(bcmx_lport_t port, 916 int *pause_tx, 917 int *pause_rx) 918 { 919 int bcm_unit; 920 bcm_port_t bcm_port; 921 922 BCMX_PORT_INIT_CHECK; 923 924 BCMX_PARAM_NULL_CHECK(pause_tx); 925 BCMX_PARAM_NULL_CHECK(pause_rx); 926 927 BCM_IF_ERROR_RETURN 928 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 929 BCMX_DEST_CONVERT_DEFAULT)); 930 931 return bcm_port_pause_get(bcm_unit, bcm_port, 932 pause_tx, pause_rx); 933 } 934 935 936 int 937 bcmx_port_pause_set(bcmx_lport_t port, 938 int pause_tx, 939 int pause_rx) 940 { 941 int bcm_unit; 942 bcm_port_t bcm_port; 943 944 BCMX_PORT_INIT_CHECK; 945 946 BCM_IF_ERROR_RETURN 947 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 948 BCMX_DEST_CONVERT_DEFAULT)); 949 950 return bcm_port_pause_set(bcm_unit, bcm_port, 951 pause_tx, pause_rx); 952 } 953 954 955 int 956 bcmx_port_pause_addr_get(bcmx_lport_t port, bcm_mac_t mac) 957 { 958 int bcm_unit; 959 bcm_port_t bcm_port; 960 961 BCMX_PORT_INIT_CHECK; 962 963 BCM_IF_ERROR_RETURN 964 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 965 BCMX_DEST_CONVERT_DEFAULT)); 966 967 return bcm_port_pause_addr_get(bcm_unit, bcm_port, 968 mac); 969 } 970 971 972 int 973 bcmx_port_pause_addr_set(bcmx_lport_t port, bcm_mac_t mac) 974 { 975 int bcm_unit; 976 bcm_port_t bcm_port; 977 978 BCMX_PORT_INIT_CHECK; 979 980 BCM_IF_ERROR_RETURN 981 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 982 BCMX_DEST_CONVERT_DEFAULT)); 983 984 return bcm_port_pause_addr_set(bcm_unit, bcm_port, 985 mac); 986 } 987 988 989 int 990 bcmx_port_pause_sym_set(bcmx_lport_t port, int pause) 991 { 992 int bcm_unit; 993 bcm_port_t bcm_port; 994 995 BCMX_PORT_INIT_CHECK; 996 997 BCM_IF_ERROR_RETURN 998 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 999 BCMX_DEST_CONVERT_DEFAULT)); 1000 1001 return bcm_port_pause_sym_set(bcm_unit, bcm_port, 1002 pause); 1003 } 1004 1005 1006 int 1007 bcmx_port_pause_sym_get(bcmx_lport_t port, int *pause) 1008 { 1009 int bcm_unit; 1010 bcm_port_t bcm_port; 1011 1012 BCMX_PORT_INIT_CHECK; 1013 1014 BCMX_PARAM_NULL_CHECK(pause); 1015 1016 BCM_IF_ERROR_RETURN 1017 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 1018 BCMX_DEST_CONVERT_DEFAULT)); 1019 1020 return bcm_port_pause_sym_get(bcm_unit, bcm_port, 1021 pause); 1022 } 1023 1024 1025 int 1026 bcmx_port_update(bcmx_lport_t port, int link) 1027 { 1028 int bcm_unit; 1029 bcm_port_t bcm_port; 1030 1031 BCMX_PORT_INIT_CHECK; 1032 1033 BCM_IF_ERROR_RETURN 1034 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 1035 BCMX_DEST_CONVERT_DEFAULT)); 1036 1037 return bcm_port_update(bcm_unit, bcm_port, 1038 link); 1039 } 1040 1041 1042 int 1043 bcmx_port_frame_max_set(bcmx_lport_t port, int size) 1044 { 1045 int bcm_unit; 1046 bcm_port_t bcm_port; 1047 1048 BCMX_PORT_INIT_CHECK; 1049 1050 BCM_IF_ERROR_RETURN 1051 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 1052 BCMX_DEST_CONVERT_DEFAULT)); 1053 1054 return bcm_port_frame_max_set(bcm_unit, bcm_port, 1055 size); 1056 } 1057 1058 int 1059 bcmx_port_frame_max_get(bcmx_lport_t port, int *size) 1060 { 1061 int bcm_unit; 1062 bcm_port_t bcm_port; 1063 1064 BCMX_PORT_INIT_CHECK; 1065 1066 BCMX_PARAM_NULL_CHECK(size); 1067 1068 BCM_IF_ERROR_RETURN 1069 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 1070 BCMX_DEST_CONVERT_DEFAULT)); 1071 1072 return bcm_port_frame_max_get(bcm_unit, bcm_port, 1073 size); 1074 } 1075 1076 int 1077 bcmx_port_l3_mtu_set(bcmx_lport_t port, int size) 1078 { 1079 int bcm_unit; 1080 bcm_port_t bcm_port; 1081 1082 BCMX_PORT_INIT_CHECK; 1083 1084 BCM_IF_ERROR_RETURN 1085 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 1086 BCMX_DEST_CONVERT_DEFAULT)); 1087 1088 return bcm_port_l3_mtu_set(bcm_unit, bcm_port, 1089 size); 1090 } 1091 1092 int 1093 bcmx_port_l3_mtu_get(bcmx_lport_t port, int *size) 1094 { 1095 int bcm_unit; 1096 bcm_port_t bcm_port; 1097 1098 BCMX_PORT_INIT_CHECK; 1099 1100 BCMX_PARAM_NULL_CHECK(size); 1101 1102 BCM_IF_ERROR_RETURN 1103 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 1104 BCMX_DEST_CONVERT_DEFAULT)); 1105 1106 return bcm_port_l3_mtu_get(bcm_unit, bcm_port, 1107 size); 1108 } 1109 1110 int 1111 bcmx_port_jam_set(bcmx_lport_t port, int enable) 1112 { 1113 int bcm_unit; 1114 bcm_port_t bcm_port; 1115 1116 BCMX_PORT_INIT_CHECK; 1117 1118 BCM_IF_ERROR_RETURN 1119 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 1120 BCMX_DEST_CONVERT_DEFAULT)); 1121 1122 return bcm_port_jam_set(bcm_unit, bcm_port, 1123 enable); 1124 } 1125 1126 int 1127 bcmx_port_jam_get(bcmx_lport_t port, int *enable) 1128 { 1129 int bcm_unit; 1130 bcm_port_t bcm_port; 1131 1132 BCMX_PORT_INIT_CHECK; 1133 1134 BCMX_PARAM_NULL_CHECK(enable); 1135 1136 BCM_IF_ERROR_RETURN 1137 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 1138 BCMX_DEST_CONVERT_DEFAULT)); 1139 1140 return bcm_port_jam_get(bcm_unit, bcm_port, 1141 enable); 1142 } 1143 1144 int 1145 bcmx_port_ifg_set(bcmx_lport_t port, 1146 int speed, 1147 bcm_port_duplex_t duplex, 1148 int bit_times) 1149 { 1150 int bcm_unit; 1151 bcm_port_t bcm_port; 1152 1153 BCMX_PORT_INIT_CHECK; 1154 1155 BCM_IF_ERROR_RETURN 1156 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 1157 BCMX_DEST_CONVERT_DEFAULT)); 1158 1159 return bcm_port_ifg_set(bcm_unit, bcm_port, 1160 speed, duplex, bit_times); 1161 } 1162 1163 int 1164 bcmx_port_ifg_get(bcmx_lport_t port, 1165 int speed, 1166 bcm_port_duplex_t duplex, 1167 int *bit_times) 1168 { 1169 int bcm_unit; 1170 bcm_port_t bcm_port; 1171 1172 BCMX_PORT_INIT_CHECK; 1173 1174 BCMX_PARAM_NULL_CHECK(bit_times); 1175 1176 BCM_IF_ERROR_RETURN 1177 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 1178 BCMX_DEST_CONVERT_DEFAULT)); 1179 1180 return bcm_port_ifg_get(bcm_unit, bcm_port, 1181 speed, duplex, bit_times); 1182 } 1183 1184 int 1185 bcmx_port_phy_get(bcmx_lport_t port, 1186 uint32 flags, 1187 uint32 phy_reg_addr, 1188 uint32 *phy_data) 1189 { 1190 int bcm_unit; 1191 bcm_port_t bcm_port; 1192 1193 BCMX_PORT_INIT_CHECK; 1194 1195 BCMX_PARAM_NULL_CHECK(phy_data); 1196 1197 BCM_IF_ERROR_RETURN 1198 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 1199 BCMX_DEST_CONVERT_DEFAULT)); 1200 1201 return bcm_port_phy_get(bcm_unit, bcm_port, 1202 flags, phy_reg_addr, phy_data); 1203 } 1204 1205 int 1206 bcmx_port_phy_set(bcmx_lport_t port, 1207 uint32 flags, 1208 uint32 phy_reg_addr, 1209 uint32 phy_data) 1210 { 1211 int bcm_unit; 1212 bcm_port_t bcm_port; 1213 1214 BCMX_PORT_INIT_CHECK; 1215 1216 BCM_IF_ERROR_RETURN 1217 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 1218 BCMX_DEST_CONVERT_DEFAULT)); 1219 1220 return bcm_port_phy_set(bcm_unit, bcm_port, 1221 flags, phy_reg_addr, phy_data); 1222 } 1223 1224 int 1225 bcmx_port_phy_modify(bcmx_lport_t port, 1226 uint32 flags, 1227 uint32 phy_reg_addr, 1228 uint32 phy_data, 1229 uint32 phy_mask) 1230 { 1231 int bcm_unit; 1232 bcm_port_t bcm_port; 1233 1234 BCMX_PORT_INIT_CHECK; 1235 1236 BCM_IF_ERROR_RETURN 1237 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 1238 BCMX_DEST_CONVERT_DEFAULT)); 1239 1240 return bcm_port_phy_modify(bcm_unit, bcm_port, 1241 flags, phy_reg_addr, phy_data, phy_mask); 1242 } 1243 1244 int 1245 bcmx_port_mdix_set(bcmx_lport_t port, bcm_port_mdix_t mode) 1246 { 1247 int bcm_unit; 1248 bcm_port_t bcm_port; 1249 1250 BCMX_PORT_INIT_CHECK; 1251 1252 BCM_IF_ERROR_RETURN 1253 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 1254 BCMX_DEST_CONVERT_DEFAULT)); 1255 1256 return bcm_port_mdix_set(bcm_unit, bcm_port, 1257 mode); 1258 } 1259 1260 int 1261 bcmx_port_mdix_get(bcmx_lport_t port, bcm_port_mdix_t *mode) 1262 { 1263 int bcm_unit; 1264 bcm_port_t bcm_port; 1265 1266 BCMX_PORT_INIT_CHECK; 1267 1268 BCMX_PARAM_NULL_CHECK(mode); 1269 1270 BCM_IF_ERROR_RETURN 1271 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 1272 BCMX_DEST_CONVERT_DEFAULT)); 1273 1274 return bcm_port_mdix_get(bcm_unit, bcm_port, 1275 mode); 1276 } 1277 1278 int 1279 bcmx_port_mdix_status_get(bcmx_lport_t port, 1280 bcm_port_mdix_status_t *status) 1281 { 1282 int bcm_unit; 1283 bcm_port_t bcm_port; 1284 1285 BCMX_PORT_INIT_CHECK; 1286 1287 BCMX_PARAM_NULL_CHECK(status); 1288 1289 BCM_IF_ERROR_RETURN 1290 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 1291 BCMX_DEST_CONVERT_DEFAULT)); 1292 1293 return bcm_port_mdix_status_get(bcm_unit, bcm_port, 1294 status); 1295 } 1296 1297 int 1298 bcmx_port_medium_config_set(bcmx_lport_t port, 1299 bcm_port_medium_t medium, 1300 bcm_phy_config_t *config) 1301 { 1302 int bcm_unit; 1303 bcm_port_t bcm_port; 1304 1305 BCMX_PORT_INIT_CHECK; 1306 1307 BCMX_PARAM_NULL_CHECK(config); 1308 1309 BCM_IF_ERROR_RETURN 1310 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 1311 BCMX_DEST_CONVERT_DEFAULT)); 1312 1313 return bcm_port_medium_config_set(bcm_unit, bcm_port, 1314 medium, config); 1315 } 1316 1317 int 1318 bcmx_port_medium_config_get(bcmx_lport_t port, 1319 bcm_port_medium_t medium, 1320 bcm_phy_config_t *config) 1321 { 1322 int bcm_unit; 1323 bcm_port_t bcm_port; 1324 1325 BCMX_PORT_INIT_CHECK; 1326 1327 BCMX_PARAM_NULL_CHECK(config); 1328 1329 BCM_IF_ERROR_RETURN 1330 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 1331 BCMX_DEST_CONVERT_DEFAULT)); 1332 1333 return bcm_port_medium_config_get(bcm_unit, bcm_port, 1334 medium, config); 1335 } 1336 1337 int 1338 bcmx_port_medium_get(bcmx_lport_t port, bcm_port_medium_t *medium) 1339 { 1340 int bcm_unit; 1341 bcm_port_t bcm_port; 1342 1343 BCMX_PORT_INIT_CHECK; 1344 1345 BCMX_PARAM_NULL_CHECK(medium); 1346 1347 BCM_IF_ERROR_RETURN 1348 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 1349 BCMX_DEST_CONVERT_DEFAULT)); 1350 1351 return bcm_port_medium_get(bcm_unit, bcm_port, 1352 medium); 1353 } 1354 1355 int 1356 bcmx_port_loopback_set(bcmx_lport_t port, int loopback) 1357 { 1358 int bcm_unit; 1359 bcm_port_t bcm_port; 1360 1361 BCMX_PORT_INIT_CHECK; 1362 1363 BCM_IF_ERROR_RETURN 1364 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 1365 BCMX_DEST_CONVERT_DEFAULT)); 1366 1367 return bcm_port_loopback_set(bcm_unit, bcm_port, 1368 loopback); 1369 } 1370 1371 1372 int 1373 bcmx_port_loopback_get(bcmx_lport_t port, int *loopback) 1374 { 1375 int bcm_unit; 1376 bcm_port_t bcm_port; 1377 1378 BCMX_PORT_INIT_CHECK; 1379 1380 BCMX_PARAM_NULL_CHECK(loopback); 1381 1382 BCM_IF_ERROR_RETURN 1383 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 1384 BCMX_DEST_CONVERT_DEFAULT)); 1385 1386 return bcm_port_loopback_get(bcm_unit, bcm_port, 1387 loopback); 1388 } 1389 1390 1391 int 1392 bcmx_port_stp_get(bcmx_lport_t port, int *state) 1393 { 1394 int bcm_unit; 1395 bcm_port_t bcm_port; 1396 1397 BCMX_PORT_INIT_CHECK; 1398 1399 BCMX_PARAM_NULL_CHECK(state); 1400 1401 BCM_IF_ERROR_RETURN 1402 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 1403 BCMX_DEST_CONVERT_DEFAULT)); 1404 1405 return bcm_port_stp_get(bcm_unit, bcm_port, 1406 state); 1407 } 1408 1409 1410 int 1411 bcmx_port_stp_set(bcmx_lport_t port, int state) 1412 { 1413 int bcm_unit; 1414 bcm_port_t bcm_port; 1415 1416 BCMX_PORT_INIT_CHECK; 1417 1418 BCM_IF_ERROR_RETURN 1419 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 1420 BCMX_DEST_CONVERT_DEFAULT)); 1421 1422 return bcm_port_stp_set(bcm_unit, bcm_port, 1423 state); 1424 } 1425 1426 1427 int 1428 bcmx_port_discard_get(bcmx_lport_t port, int *mode) 1429 { 1430 int bcm_unit; 1431 bcm_port_t bcm_port; 1432 1433 BCMX_PORT_INIT_CHECK; 1434 1435 BCMX_PARAM_NULL_CHECK(mode); 1436 1437 BCM_IF_ERROR_RETURN 1438 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 1439 BCMX_DEST_CONVERT_DEFAULT)); 1440 1441 return bcm_port_discard_get(bcm_unit, bcm_port, 1442 mode); 1443 } 1444 1445 1446 int 1447 bcmx_port_discard_set(bcmx_lport_t port, int mode) 1448 { 1449 int bcm_unit; 1450 bcm_port_t bcm_port; 1451 1452 BCMX_PORT_INIT_CHECK; 1453 1454 BCM_IF_ERROR_RETURN 1455 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 1456 BCMX_DEST_CONVERT_DEFAULT)); 1457 1458 return bcm_port_discard_set(bcm_unit, bcm_port, 1459 mode); 1460 } 1461 1462 /* 1463 * bcmx_port_learn_get/set() 1464 * Notes: 1465 * Supports physical and virtual ports. 1466 * If 'port' is a physical port, apply to device where port resides. 1467 * If 'port' is a virtual port, apply to all devices. 1468 */ 1469 int 1470 bcmx_port_learn_get(bcmx_lport_t port, uint32 *flags) 1471 { 1472 int rv; 1473 int i, bcm_unit; 1474 bcm_port_t bcm_port; 1475 1476 BCMX_PORT_INIT_CHECK; 1477 1478 BCMX_PARAM_NULL_CHECK(flags); 1479 1480 if (!BCM_GPORT_IS_SET(port)) { 1481 return BCM_E_PORT; 1482 } 1483 1484 if (BCM_SUCCESS(_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 1485 BCMX_DEST_CONVERT_DEFAULT))) { 1486 return bcm_port_learn_get(bcm_unit, bcm_port, flags); 1487 } 1488 1489 BCMX_UNIT_ITER(bcm_unit, i) { 1490 rv = bcm_port_learn_get(bcm_unit, port, flags); 1491 if (BCMX_PORT_GET_IS_VALID(bcm_unit, rv)) { 1492 return rv; 1493 } 1494 } 1495 1496 return BCM_E_UNAVAIL; 1497 } 1498 1499 int 1500 bcmx_port_learn_set(bcmx_lport_t port, uint32 flags) 1501 { 1502 int rv = BCM_E_UNAVAIL, tmp_rv; 1503 int i, bcm_unit; 1504 bcm_port_t bcm_port; 1505 1506 BCMX_PORT_INIT_CHECK; 1507 1508 if (!BCM_GPORT_IS_SET(port)) { 1509 return BCM_E_PORT; 1510 } 1511 1512 if (BCM_SUCCESS(_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 1513 BCMX_DEST_CONVERT_DEFAULT))) { 1514 return bcm_port_learn_set(bcm_unit, bcm_port, flags); 1515 } 1516 1517 BCMX_UNIT_ITER(bcm_unit, i) { 1518 tmp_rv = bcm_port_learn_set(bcm_unit, port, flags); 1519 BCM_IF_ERROR_RETURN(BCMX_PORT_SET_ERROR_CHECK(bcm_unit, tmp_rv, &rv)); 1520 } 1521 1522 return rv; 1523 } 1524 1525 1526 int 1527 bcmx_port_learn_modify(bcmx_lport_t port, uint32 add, uint32 remove) 1528 { 1529 int bcm_unit; 1530 bcm_port_t bcm_port; 1531 1532 BCMX_PORT_INIT_CHECK; 1533 1534 BCM_IF_ERROR_RETURN 1535 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 1536 BCMX_DEST_CONVERT_DEFAULT)); 1537 1538 return bcm_port_learn_modify(bcm_unit, bcm_port, 1539 add, remove); 1540 } 1541 1542 1543 int 1544 bcmx_port_link_status_get(bcmx_lport_t port, int *up) 1545 { 1546 int bcm_unit; 1547 bcm_port_t bcm_port; 1548 1549 BCMX_PORT_INIT_CHECK; 1550 1551 BCMX_PARAM_NULL_CHECK(up); 1552 1553 BCM_IF_ERROR_RETURN 1554 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 1555 BCMX_DEST_CONVERT_DEFAULT)); 1556 1557 return bcm_port_link_status_get(bcm_unit, bcm_port, 1558 up); 1559 } 1560 1561 1562 int 1563 bcmx_port_link_failed_clear(bcm_gport_t port) 1564 { 1565 int bcm_unit; 1566 bcm_port_t bcm_port; 1567 1568 BCMX_PORT_INIT_CHECK; 1569 1570 BCM_IF_ERROR_RETURN 1571 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 1572 BCMX_DEST_CONVERT_DEFAULT)); 1573 1574 return bcm_port_link_failed_clear(bcm_unit, bcm_port); 1575 } 1576 1577 1578 int 1579 bcmx_port_ifilter_get(bcmx_lport_t port, int *mode) 1580 { 1581 int bcm_unit; 1582 bcm_port_t bcm_port; 1583 1584 BCMX_PORT_INIT_CHECK; 1585 1586 BCMX_PARAM_NULL_CHECK(mode); 1587 1588 BCM_IF_ERROR_RETURN 1589 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 1590 BCMX_DEST_CONVERT_DEFAULT)); 1591 1592 return bcm_port_ifilter_get(bcm_unit, bcm_port, 1593 mode); 1594 } 1595 1596 1597 int 1598 bcmx_port_ifilter_set(bcmx_lport_t port, int mode) 1599 { 1600 int bcm_unit; 1601 bcm_port_t bcm_port; 1602 1603 BCMX_PORT_INIT_CHECK; 1604 1605 BCM_IF_ERROR_RETURN 1606 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 1607 BCMX_DEST_CONVERT_DEFAULT)); 1608 1609 return bcm_port_ifilter_set(bcm_unit, bcm_port, 1610 mode); 1611 } 1612 1613 1614 /* 1615 * bcmx_port_vlan_member_get/set() 1616 * Notes: 1617 * Supports physical and virtual ports. 1618 * If 'port' is a physical port, apply to device where port resides. 1619 * If 'port' is a virtual port, apply to all devices. 1620 */ 1621 int 1622 bcmx_port_vlan_member_get(bcmx_lport_t port, uint32 *flags) 1623 { 1624 int rv; 1625 int i, bcm_unit; 1626 bcm_port_t bcm_port; 1627 1628 BCMX_PORT_INIT_CHECK; 1629 1630 BCMX_PARAM_NULL_CHECK(flags); 1631 1632 if (!BCM_GPORT_IS_SET(port)) { 1633 return BCM_E_PORT; 1634 } 1635 1636 if (BCM_SUCCESS(_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 1637 BCMX_DEST_CONVERT_DEFAULT))) { 1638 return bcm_port_vlan_member_get(bcm_unit, bcm_port, flags); 1639 } 1640 1641 BCMX_UNIT_ITER(bcm_unit, i) { 1642 rv = bcm_port_vlan_member_get(bcm_unit, port, flags); 1643 if (BCMX_PORT_GET_IS_VALID(bcm_unit, rv)) { 1644 return rv; 1645 } 1646 } 1647 1648 return BCM_E_UNAVAIL; 1649 } 1650 1651 int 1652 bcmx_port_vlan_member_set(bcmx_lport_t port, uint32 flags) 1653 { 1654 int rv = BCM_E_UNAVAIL, tmp_rv; 1655 int i, bcm_unit; 1656 bcm_port_t bcm_port; 1657 1658 BCMX_PORT_INIT_CHECK; 1659 1660 if (!BCM_GPORT_IS_SET(port)) { 1661 return BCM_E_PORT; 1662 } 1663 1664 if (BCM_SUCCESS(_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 1665 BCMX_DEST_CONVERT_DEFAULT))) { 1666 return bcm_port_vlan_member_set(bcm_unit, bcm_port, flags); 1667 } 1668 1669 BCMX_UNIT_ITER(bcm_unit, i) { 1670 tmp_rv = bcm_port_vlan_member_set(bcm_unit, port, flags); 1671 BCM_IF_ERROR_RETURN(BCMX_PORT_SET_ERROR_CHECK(bcm_unit, tmp_rv, &rv)); 1672 } 1673 1674 return rv; 1675 } 1676 1677 1678 int 1679 bcmx_port_bpdu_enable_set(bcmx_lport_t port, int enable) 1680 { 1681 int bcm_unit; 1682 bcm_port_t bcm_port; 1683 1684 BCMX_PORT_INIT_CHECK; 1685 1686 BCM_IF_ERROR_RETURN 1687 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 1688 BCMX_DEST_CONVERT_DEFAULT)); 1689 1690 return bcm_port_bpdu_enable_set(bcm_unit, bcm_port, 1691 enable); 1692 } 1693 1694 1695 int 1696 bcmx_port_bpdu_enable_get(bcmx_lport_t port, int *enable) 1697 { 1698 int bcm_unit; 1699 bcm_port_t bcm_port; 1700 1701 BCMX_PORT_INIT_CHECK; 1702 1703 BCMX_PARAM_NULL_CHECK(enable); 1704 1705 BCM_IF_ERROR_RETURN 1706 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 1707 BCMX_DEST_CONVERT_DEFAULT)); 1708 1709 return bcm_port_bpdu_enable_get(bcm_unit, bcm_port, 1710 enable); 1711 } 1712 1713 1714 int 1715 bcmx_port_l3_enable_set(bcmx_lport_t port, int enable) 1716 { 1717 int bcm_unit; 1718 bcm_port_t bcm_port; 1719 1720 BCMX_PORT_INIT_CHECK; 1721 1722 BCM_IF_ERROR_RETURN 1723 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 1724 BCMX_DEST_CONVERT_DEFAULT)); 1725 1726 return bcm_port_l3_enable_set(bcm_unit, bcm_port, 1727 enable); 1728 } 1729 1730 1731 int 1732 bcmx_port_l3_enable_get(bcmx_lport_t port, int *enable) 1733 { 1734 int bcm_unit; 1735 bcm_port_t bcm_port; 1736 1737 BCMX_PORT_INIT_CHECK; 1738 1739 BCMX_PARAM_NULL_CHECK(enable); 1740 1741 BCM_IF_ERROR_RETURN 1742 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 1743 BCMX_DEST_CONVERT_DEFAULT)); 1744 1745 return bcm_port_l3_enable_get(bcm_unit, bcm_port, 1746 enable); 1747 } 1748 1749 1750 int 1751 bcmx_port_tgid_set(bcmx_lport_t port, int tid, int psc) 1752 { 1753 int bcm_unit; 1754 bcm_port_t bcm_port; 1755 1756 BCMX_PORT_INIT_CHECK; 1757 1758 BCM_IF_ERROR_RETURN 1759 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 1760 BCMX_DEST_CONVERT_DEFAULT)); 1761 1762 return bcm_port_tgid_set(bcm_unit, bcm_port, 1763 tid, psc); 1764 } 1765 1766 int 1767 bcmx_port_tgid_get(bcmx_lport_t port, int *tid, int *psc) 1768 { 1769 int bcm_unit; 1770 bcm_port_t bcm_port; 1771 1772 BCMX_PORT_INIT_CHECK; 1773 1774 BCMX_PARAM_NULL_CHECK(tid); 1775 BCMX_PARAM_NULL_CHECK(psc); 1776 1777 BCM_IF_ERROR_RETURN 1778 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 1779 BCMX_DEST_CONVERT_DEFAULT)); 1780 1781 return bcm_port_tgid_get(bcm_unit, bcm_port, 1782 tid, psc); 1783 } 1784 1785 int 1786 bcmx_port_pfm_set(bcmx_lport_t port, int mode) 1787 { 1788 int bcm_unit; 1789 bcm_port_t bcm_port; 1790 1791 BCMX_PORT_INIT_CHECK; 1792 1793 BCM_IF_ERROR_RETURN 1794 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 1795 BCMX_DEST_CONVERT_DEFAULT)); 1796 1797 return bcm_port_pfm_set(bcm_unit, bcm_port, 1798 mode); 1799 } 1800 1801 1802 int 1803 bcmx_port_pfm_get(bcmx_lport_t port, int *mode) 1804 { 1805 int bcm_unit; 1806 bcm_port_t bcm_port; 1807 1808 BCMX_PORT_INIT_CHECK; 1809 1810 BCMX_PARAM_NULL_CHECK(mode); 1811 1812 BCM_IF_ERROR_RETURN 1813 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 1814 BCMX_DEST_CONVERT_DEFAULT)); 1815 1816 return bcm_port_pfm_get(bcm_unit, bcm_port, 1817 mode); 1818 } 1819 1820 1821 int 1822 bcmx_port_encap_set(bcmx_lport_t port, int mode) 1823 { 1824 int bcm_unit; 1825 bcm_port_t bcm_port; 1826 1827 BCMX_PORT_INIT_CHECK; 1828 1829 BCM_IF_ERROR_RETURN 1830 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 1831 BCMX_DEST_CONVERT_DEFAULT)); 1832 1833 BCM_IF_ERROR_RETURN 1834 (bcm_port_encap_set(bcm_unit, bcm_port, 1835 mode)); 1836 1837 /* Update BCMX internal port flag state */ 1838 return _bcmx_port_changed(port); 1839 } 1840 1841 1842 int 1843 bcmx_port_encap_get(bcmx_lport_t port, int *mode) 1844 { 1845 int bcm_unit; 1846 bcm_port_t bcm_port; 1847 1848 BCMX_PORT_INIT_CHECK; 1849 1850 BCMX_PARAM_NULL_CHECK(mode); 1851 1852 BCM_IF_ERROR_RETURN 1853 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 1854 BCMX_DEST_CONVERT_DEFAULT)); 1855 1856 return bcm_port_encap_get(bcm_unit, bcm_port, 1857 mode); 1858 } 1859 1860 1861 int 1862 bcmx_port_encap_config_set(bcm_gport_t gport, 1863 bcmx_port_encap_config_t *encap_config) 1864 { 1865 int bcm_unit; 1866 bcm_port_t bcm_port; 1867 1868 BCMX_PORT_INIT_CHECK; 1869 1870 BCMX_PARAM_NULL_CHECK(encap_config); 1871 1872 BCM_IF_ERROR_RETURN 1873 (_bcmx_dest_to_unit_port(gport, &bcm_unit, &bcm_port, 1874 BCMX_DEST_CONVERT_DEFAULT)); 1875 1876 return bcm_port_encap_config_set(bcm_unit, gport, 1877 BCMX_PORT_ENCAP_CONFIG_T_PTR_TO_BCM 1878 (encap_config)); 1879 } 1880 1881 1882 int 1883 bcmx_port_encap_config_get(bcm_gport_t gport, 1884 bcmx_port_encap_config_t *encap_config) 1885 { 1886 int bcm_unit; 1887 bcm_port_t bcm_port; 1888 1889 BCMX_PORT_INIT_CHECK; 1890 1891 BCMX_PARAM_NULL_CHECK(encap_config); 1892 1893 BCM_IF_ERROR_RETURN 1894 (_bcmx_dest_to_unit_port(gport, &bcm_unit, &bcm_port, 1895 BCMX_DEST_CONVERT_DEFAULT)); 1896 1897 return bcm_port_encap_config_get(bcm_unit, gport, 1898 BCMX_PORT_ENCAP_CONFIG_T_PTR_TO_BCM 1899 (encap_config)); 1900 } 1901 1902 1903 int 1904 bcmx_port_queued_count_get(bcmx_lport_t port, uint32 *count) 1905 { 1906 int bcm_unit; 1907 bcm_port_t bcm_port; 1908 1909 BCMX_PORT_INIT_CHECK; 1910 1911 BCMX_PARAM_NULL_CHECK(count); 1912 1913 BCM_IF_ERROR_RETURN 1914 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 1915 BCMX_DEST_CONVERT_DEFAULT)); 1916 1917 return bcm_port_queued_count_get(bcm_unit, bcm_port, 1918 count); 1919 } 1920 1921 1922 int 1923 bcmx_port_protocol_vlan_add(bcmx_lport_t port, 1924 bcm_port_frametype_t frame, 1925 bcm_port_ethertype_t ether, 1926 bcm_vlan_t vid) 1927 { 1928 int bcm_unit; 1929 bcm_port_t bcm_port; 1930 1931 BCMX_PORT_INIT_CHECK; 1932 1933 BCM_IF_ERROR_RETURN 1934 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 1935 BCMX_DEST_CONVERT_DEFAULT)); 1936 1937 return bcm_port_protocol_vlan_add(bcm_unit, bcm_port, 1938 frame, ether, vid); 1939 } 1940 1941 1942 int 1943 bcmx_port_protocol_vlan_delete(bcmx_lport_t port, 1944 bcm_port_frametype_t frame, 1945 bcm_port_ethertype_t ether) 1946 { 1947 int bcm_unit; 1948 bcm_port_t bcm_port; 1949 1950 BCMX_PORT_INIT_CHECK; 1951 1952 BCM_IF_ERROR_RETURN 1953 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 1954 BCMX_DEST_CONVERT_DEFAULT)); 1955 1956 return bcm_port_protocol_vlan_delete(bcm_unit, bcm_port, 1957 frame, ether); 1958 } 1959 1960 1961 int 1962 bcmx_port_protocol_vlan_delete_all(bcmx_lport_t port) 1963 { 1964 int bcm_unit; 1965 bcm_port_t bcm_port; 1966 1967 BCMX_PORT_INIT_CHECK; 1968 1969 BCM_IF_ERROR_RETURN 1970 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 1971 BCMX_DEST_CONVERT_DEFAULT)); 1972 1973 return bcm_port_protocol_vlan_delete_all(bcm_unit, bcm_port); 1974 } 1975 1976 1977 /* 1978 * Enable traffic from source port "port" to destination ports in 1979 * the lplist. Ports not in the lplist will be blocked. 1980 * 1981 * The use of "modid" in this routine is deprecated. That parameter 1982 * is ignored. 1983 */ 1984 1985 int 1986 bcmx_port_egress_set(bcmx_lport_t port, 1987 int modid, 1988 bcmx_lplist_t lplist) 1989 { 1990 int rv = BCM_E_UNAVAIL, tmp_rv; 1991 int dest_unit; 1992 bcm_pbmp_t pbmp; 1993 bcm_module_t src_mod; 1994 bcm_port_t src_port; 1995 int i; 1996 1997 COMPILER_REFERENCE(modid); 1998 1999 BCMX_PORT_INIT_CHECK; 2000 2001 BCM_IF_ERROR_RETURN 2002 (_bcmx_dest_to_modid_port(port, &src_mod, &src_port, 2003 BCMX_DEST_CONVERT_DEFAULT)); 2004 2005 /* 2006 * Iterate over units; for each unit, extract bitmap from 2007 * lplist. Call bcm_port_egress_set with that bitmap using 2008 * the (port, mod-id) derived from the (source) port. 2009 * 2010 * If an error is returned on non-NULL bitmap, return that error 2011 */ 2012 BCMX_UNIT_ITER(dest_unit, i) { 2013 BCMX_LPLIST_TO_PBMP(lplist, dest_unit, pbmp); 2014 tmp_rv = bcm_port_egress_set(dest_unit, src_port, (int)src_mod, pbmp); 2015 BCM_IF_ERROR_RETURN(BCMX_PORT_SET_ERROR_CHECK(dest_unit, tmp_rv, &rv)); 2016 } 2017 2018 return rv; 2019 } 2020 2021 2022 /* 2023 * Get the current settings for enabled traffic from source port "port" 2024 * to other ports in the system. 2025 * 2026 * The use of "modid" in this routine is deprecated. That parameter 2027 * is ignored. 2028 */ 2029 2030 int 2031 bcmx_port_egress_get(bcmx_lport_t port, 2032 int modid, 2033 bcmx_lplist_t *lplist) 2034 { 2035 int rv = BCM_E_UNAVAIL, tmp_rv; 2036 int dest_unit; 2037 bcm_pbmp_t pbmp; 2038 bcm_module_t src_mod; 2039 bcm_port_t src_port; 2040 int i; 2041 2042 COMPILER_REFERENCE(modid); 2043 2044 BCMX_PORT_INIT_CHECK; 2045 2046 BCMX_PARAM_NULL_CHECK(lplist); 2047 2048 BCM_IF_ERROR_RETURN 2049 (_bcmx_dest_to_modid_port(port, &src_mod, &src_port, 2050 BCMX_DEST_CONVERT_DEFAULT)); 2051 2052 BCM_IF_ERROR_RETURN(bcmx_lplist_clear(lplist)); 2053 2054 BCMX_UNIT_ITER(dest_unit, i) { 2055 tmp_rv = bcm_port_egress_get(dest_unit, src_port, 2056 (int)src_mod, &pbmp); 2057 if (BCMX_PORT_GET_IS_VALID(dest_unit, tmp_rv)) { 2058 rv = tmp_rv; 2059 if (BCM_SUCCESS(tmp_rv)) { 2060 rv = BCMX_LPLIST_PBMP_ADD(lplist, dest_unit, pbmp); 2061 } else { 2062 break; 2063 } 2064 } 2065 } 2066 2067 return rv; 2068 } 2069 2070 2071 int 2072 bcmx_port_modid_enable_set(bcmx_lport_t port, 2073 int modid, 2074 int enable) 2075 { 2076 int bcm_unit; 2077 bcm_port_t bcm_port; 2078 2079 BCMX_PORT_INIT_CHECK; 2080 2081 BCM_IF_ERROR_RETURN 2082 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 2083 BCMX_DEST_CONVERT_DEFAULT)); 2084 2085 return bcm_port_modid_enable_set(bcm_unit, bcm_port, 2086 modid, enable); 2087 } 2088 2089 2090 int 2091 bcmx_port_modid_enable_get(bcmx_lport_t port, 2092 int modid, 2093 int *enable) 2094 { 2095 int bcm_unit; 2096 bcm_port_t bcm_port; 2097 2098 BCMX_PORT_INIT_CHECK; 2099 2100 BCMX_PARAM_NULL_CHECK(enable); 2101 2102 BCM_IF_ERROR_RETURN 2103 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 2104 BCMX_DEST_CONVERT_DEFAULT)); 2105 2106 return bcm_port_modid_enable_get(bcm_unit, bcm_port, 2107 modid, enable); 2108 } 2109 2110 2111 int 2112 bcmx_port_flood_block_set(bcmx_lport_t ingress_port, 2113 bcmx_lport_t egress_port, 2114 uint32 flags) 2115 { 2116 int ingress_bcm_unit, egress_bcm_unit; 2117 bcm_port_t ingress_bcm_port, egress_bcm_port; 2118 2119 BCMX_PORT_INIT_CHECK; 2120 2121 BCM_IF_ERROR_RETURN 2122 (_bcmx_dest_to_unit_port(ingress_port, 2123 &ingress_bcm_unit, &ingress_bcm_port, 2124 BCMX_DEST_CONVERT_DEFAULT)); 2125 2126 BCM_IF_ERROR_RETURN 2127 (_bcmx_dest_to_unit_port(egress_port, 2128 &egress_bcm_unit, &egress_bcm_port, 2129 BCMX_DEST_CONVERT_DEFAULT)); 2130 2131 if (ingress_bcm_unit != egress_bcm_unit) { 2132 return BCM_E_PARAM; 2133 } 2134 2135 return bcm_port_flood_block_set(ingress_bcm_unit, 2136 ingress_bcm_port, 2137 egress_bcm_port, 2138 flags); 2139 } 2140 2141 2142 int 2143 bcmx_port_flood_block_get(bcmx_lport_t ingress_port, 2144 bcmx_lport_t egress_port, 2145 uint32 *flags) 2146 { 2147 int ingress_bcm_unit, egress_bcm_unit; 2148 bcm_port_t ingress_bcm_port, egress_bcm_port; 2149 2150 BCMX_PORT_INIT_CHECK; 2151 2152 BCMX_PARAM_NULL_CHECK(flags); 2153 2154 BCM_IF_ERROR_RETURN 2155 (_bcmx_dest_to_unit_port(ingress_port, 2156 &ingress_bcm_unit, &ingress_bcm_port, 2157 BCMX_DEST_CONVERT_DEFAULT)); 2158 2159 BCM_IF_ERROR_RETURN 2160 (_bcmx_dest_to_unit_port(egress_port, 2161 &egress_bcm_unit, &egress_bcm_port, 2162 BCMX_DEST_CONVERT_DEFAULT)); 2163 2164 if (ingress_bcm_unit != egress_bcm_unit) { 2165 return BCM_E_PARAM; 2166 } 2167 2168 return bcm_port_flood_block_get(ingress_bcm_unit, 2169 ingress_bcm_port, 2170 egress_bcm_port, 2171 flags); 2172 } 2173 2174 2175 int 2176 bcmx_port_rate_egress_set(bcmx_lport_t port, 2177 uint32 kbits_sec, 2178 uint32 kbits_burst) 2179 { 2180 int bcm_unit; 2181 bcm_port_t bcm_port; 2182 2183 BCMX_PORT_INIT_CHECK; 2184 2185 BCM_IF_ERROR_RETURN 2186 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 2187 BCMX_DEST_CONVERT_DEFAULT)); 2188 2189 return bcm_port_rate_egress_set(bcm_unit, bcm_port, 2190 kbits_sec, kbits_burst); 2191 } 2192 2193 2194 int 2195 bcmx_port_rate_egress_get(bcmx_lport_t port, 2196 uint32 *kbits_sec, 2197 uint32 *kbits_burst) 2198 { 2199 int bcm_unit; 2200 bcm_port_t bcm_port; 2201 2202 BCMX_PORT_INIT_CHECK; 2203 2204 BCMX_PARAM_NULL_CHECK(kbits_sec); 2205 BCMX_PARAM_NULL_CHECK(kbits_burst); 2206 2207 BCM_IF_ERROR_RETURN 2208 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 2209 BCMX_DEST_CONVERT_DEFAULT)); 2210 2211 return bcm_port_rate_egress_get(bcm_unit, bcm_port, 2212 kbits_sec, kbits_burst); 2213 } 2214 2215 2216 int 2217 bcmx_port_rate_ingress_set(bcmx_lport_t port, 2218 uint32 kbits_sec, 2219 uint32 kbits_burst) 2220 { 2221 int bcm_unit; 2222 bcm_port_t bcm_port; 2223 2224 BCMX_PORT_INIT_CHECK; 2225 2226 BCM_IF_ERROR_RETURN 2227 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 2228 BCMX_DEST_CONVERT_DEFAULT)); 2229 2230 return bcm_port_rate_ingress_set(bcm_unit, bcm_port, 2231 kbits_sec, kbits_burst); 2232 } 2233 2234 2235 int 2236 bcmx_port_rate_ingress_get(bcmx_lport_t port, 2237 uint32 *kbits_sec, 2238 uint32 *kbits_burst) 2239 { 2240 int bcm_unit; 2241 bcm_port_t bcm_port; 2242 2243 BCMX_PORT_INIT_CHECK; 2244 2245 BCMX_PARAM_NULL_CHECK(kbits_sec); 2246 BCMX_PARAM_NULL_CHECK(kbits_burst); 2247 2248 BCM_IF_ERROR_RETURN 2249 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 2250 BCMX_DEST_CONVERT_DEFAULT)); 2251 2252 return bcm_port_rate_ingress_get(bcm_unit, bcm_port, 2253 kbits_sec, kbits_burst); 2254 } 2255 2256 2257 int 2258 bcmx_port_rate_pause_set(bcmx_lport_t port, 2259 uint32 kbits_pause, 2260 uint32 kbits_resume) 2261 { 2262 int bcm_unit; 2263 bcm_port_t bcm_port; 2264 2265 BCMX_PORT_INIT_CHECK; 2266 2267 BCM_IF_ERROR_RETURN 2268 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 2269 BCMX_DEST_CONVERT_DEFAULT)); 2270 2271 return bcm_port_rate_pause_set(bcm_unit, bcm_port, 2272 kbits_pause, kbits_resume); 2273 } 2274 2275 2276 int 2277 bcmx_port_rate_pause_get(bcmx_lport_t port, 2278 uint32 *kbits_pause, 2279 uint32 *kbits_resume) 2280 { 2281 int bcm_unit; 2282 bcm_port_t bcm_port; 2283 2284 BCMX_PORT_INIT_CHECK; 2285 2286 BCMX_PARAM_NULL_CHECK(kbits_pause); 2287 BCMX_PARAM_NULL_CHECK(kbits_resume); 2288 2289 BCM_IF_ERROR_RETURN 2290 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 2291 BCMX_DEST_CONVERT_DEFAULT)); 2292 2293 return bcm_port_rate_pause_get(bcm_unit, bcm_port, 2294 kbits_pause, kbits_resume); 2295 } 2296 2297 2298 int 2299 bcmx_port_sample_rate_set(bcmx_lport_t port, 2300 int ingress_rate, 2301 int egress_rate) 2302 { 2303 int bcm_unit; 2304 bcm_port_t bcm_port; 2305 2306 BCMX_PORT_INIT_CHECK; 2307 2308 BCM_IF_ERROR_RETURN 2309 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 2310 BCMX_DEST_CONVERT_DEFAULT)); 2311 2312 return bcm_port_sample_rate_set(bcm_unit, bcm_port, 2313 ingress_rate, egress_rate); 2314 } 2315 2316 2317 int 2318 bcmx_port_sample_rate_get(bcmx_lport_t port, 2319 int *ingress_rate, 2320 int *egress_rate) 2321 { 2322 int bcm_unit; 2323 bcm_port_t bcm_port; 2324 2325 BCMX_PORT_INIT_CHECK; 2326 2327 BCMX_PARAM_NULL_CHECK(ingress_rate); 2328 BCMX_PARAM_NULL_CHECK(egress_rate); 2329 2330 BCM_IF_ERROR_RETURN 2331 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 2332 BCMX_DEST_CONVERT_DEFAULT)); 2333 2334 return bcm_port_sample_rate_get(bcm_unit, bcm_port, 2335 ingress_rate, egress_rate); 2336 } 2337 2338 2339 int 2340 bcmx_port_dtag_mode_set(bcmx_lport_t port, int mode) 2341 { 2342 int bcm_unit; 2343 bcm_port_t bcm_port; 2344 2345 BCMX_PORT_INIT_CHECK; 2346 2347 BCM_IF_ERROR_RETURN 2348 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 2349 BCMX_DEST_CONVERT_DEFAULT)); 2350 2351 return bcm_port_dtag_mode_set(bcm_unit, bcm_port, 2352 mode); 2353 } 2354 2355 2356 int 2357 bcmx_port_dtag_mode_get(bcmx_lport_t port, int *mode) 2358 { 2359 int bcm_unit; 2360 bcm_port_t bcm_port; 2361 2362 BCMX_PORT_INIT_CHECK; 2363 2364 BCMX_PARAM_NULL_CHECK(mode); 2365 2366 BCM_IF_ERROR_RETURN 2367 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 2368 BCMX_DEST_CONVERT_DEFAULT)); 2369 2370 return bcm_port_dtag_mode_get(bcm_unit, bcm_port, 2371 mode); 2372 } 2373 2374 2375 int 2376 bcmx_port_tpid_set(bcmx_lport_t port, uint16 tpid) 2377 { 2378 int bcm_unit; 2379 bcm_port_t bcm_port; 2380 2381 BCMX_PORT_INIT_CHECK; 2382 2383 BCM_IF_ERROR_RETURN 2384 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 2385 BCMX_DEST_CONVERT_DEFAULT)); 2386 2387 return bcm_port_tpid_set(bcm_unit, bcm_port, 2388 tpid); 2389 } 2390 2391 2392 int 2393 bcmx_port_tpid_get(bcmx_lport_t port, uint16 *tpid) 2394 { 2395 int bcm_unit; 2396 bcm_port_t bcm_port; 2397 2398 BCMX_PORT_INIT_CHECK; 2399 2400 BCMX_PARAM_NULL_CHECK(tpid); 2401 2402 BCM_IF_ERROR_RETURN 2403 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 2404 BCMX_DEST_CONVERT_DEFAULT)); 2405 2406 return bcm_port_tpid_get(bcm_unit, bcm_port, 2407 tpid); 2408 } 2409 2410 int 2411 bcmx_port_tpid_add(bcmx_lport_t port, uint16 tpid, int color_select) 2412 { 2413 int bcm_unit; 2414 bcm_port_t bcm_port; 2415 2416 BCMX_PORT_INIT_CHECK; 2417 2418 BCM_IF_ERROR_RETURN 2419 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 2420 BCMX_DEST_CONVERT_DEFAULT)); 2421 2422 return bcm_port_tpid_add(bcm_unit, bcm_port, 2423 tpid, color_select); 2424 } 2425 2426 int 2427 bcmx_port_tpid_delete(bcmx_lport_t port, uint16 tpid) 2428 { 2429 int bcm_unit; 2430 bcm_port_t bcm_port; 2431 2432 BCMX_PORT_INIT_CHECK; 2433 2434 BCM_IF_ERROR_RETURN 2435 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 2436 BCMX_DEST_CONVERT_DEFAULT)); 2437 2438 return bcm_port_tpid_delete(bcm_unit, bcm_port, 2439 tpid); 2440 } 2441 2442 int 2443 bcmx_port_tpid_delete_all(bcmx_lport_t port) 2444 { 2445 int bcm_unit; 2446 bcm_port_t bcm_port; 2447 2448 BCMX_PORT_INIT_CHECK; 2449 2450 BCM_IF_ERROR_RETURN 2451 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 2452 BCMX_DEST_CONVERT_DEFAULT)); 2453 2454 return bcm_port_tpid_delete_all(bcm_unit, bcm_port); 2455 } 2456 2457 int 2458 bcmx_port_inner_tpid_set(bcmx_lport_t port, uint16 tpid) 2459 { 2460 int bcm_unit; 2461 bcm_port_t bcm_port; 2462 2463 BCMX_PORT_INIT_CHECK; 2464 2465 BCM_IF_ERROR_RETURN 2466 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 2467 BCMX_DEST_CONVERT_DEFAULT)); 2468 2469 return bcm_port_inner_tpid_set(bcm_unit, bcm_port, 2470 tpid); 2471 } 2472 2473 int 2474 bcmx_port_inner_tpid_get(bcmx_lport_t port, uint16 *tpid) 2475 { 2476 int bcm_unit; 2477 bcm_port_t bcm_port; 2478 2479 BCMX_PORT_INIT_CHECK; 2480 2481 BCMX_PARAM_NULL_CHECK(tpid); 2482 2483 BCM_IF_ERROR_RETURN 2484 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 2485 BCMX_DEST_CONVERT_DEFAULT)); 2486 2487 return bcm_port_inner_tpid_get(bcm_unit, bcm_port, 2488 tpid); 2489 } 2490 2491 int 2492 bcmx_port_cable_diag(bcmx_lport_t port, bcm_port_cable_diag_t *status) 2493 { 2494 int bcm_unit; 2495 bcm_port_t bcm_port; 2496 2497 BCMX_PORT_INIT_CHECK; 2498 2499 BCMX_PARAM_NULL_CHECK(status); 2500 2501 BCM_IF_ERROR_RETURN 2502 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 2503 BCMX_DEST_CONVERT_DEFAULT)); 2504 2505 return bcm_port_cable_diag(bcm_unit, bcm_port, 2506 status); 2507 } 2508 2509 int 2510 bcmx_port_info_get(bcmx_lport_t port, bcm_port_info_t *info) 2511 { 2512 int bcm_unit; 2513 bcm_port_t bcm_port; 2514 2515 BCMX_PORT_INIT_CHECK; 2516 2517 BCMX_PARAM_NULL_CHECK(info); 2518 2519 BCM_IF_ERROR_RETURN 2520 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 2521 BCMX_DEST_CONVERT_DEFAULT)); 2522 2523 return bcm_port_info_get(bcm_unit, bcm_port, 2524 info); 2525 } 2526 2527 2528 int 2529 bcmx_port_info_set(bcmx_lport_t port, bcm_port_info_t *info) 2530 { 2531 int bcm_unit; 2532 bcm_port_t bcm_port; 2533 2534 BCMX_PORT_INIT_CHECK; 2535 2536 BCMX_PARAM_NULL_CHECK(info); 2537 2538 BCM_IF_ERROR_RETURN 2539 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 2540 BCMX_DEST_CONVERT_DEFAULT)); 2541 2542 return bcm_port_info_set(bcm_unit, bcm_port, 2543 info); 2544 } 2545 2546 2547 int 2548 bcmx_port_selective_get(bcmx_lport_t port, bcm_port_info_t *info) 2549 { 2550 int bcm_unit; 2551 bcm_port_t bcm_port; 2552 2553 BCMX_PORT_INIT_CHECK; 2554 2555 BCMX_PARAM_NULL_CHECK(info); 2556 2557 BCM_IF_ERROR_RETURN 2558 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 2559 BCMX_DEST_CONVERT_DEFAULT)); 2560 2561 return bcm_port_selective_get(bcm_unit, bcm_port, 2562 info); 2563 } 2564 2565 2566 int 2567 bcmx_port_selective_set(bcmx_lport_t port, bcm_port_info_t *info) 2568 { 2569 int bcm_unit; 2570 bcm_port_t bcm_port; 2571 2572 BCMX_PORT_INIT_CHECK; 2573 2574 BCMX_PARAM_NULL_CHECK(info); 2575 2576 BCM_IF_ERROR_RETURN 2577 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 2578 BCMX_DEST_CONVERT_DEFAULT)); 2579 2580 return bcm_port_selective_set(bcm_unit, bcm_port, 2581 info); 2582 } 2583 2584 2585 int 2586 bcmx_port_info_restore(bcmx_lport_t port, bcm_port_info_t *info) 2587 { 2588 int bcm_unit; 2589 bcm_port_t bcm_port; 2590 2591 BCMX_PORT_INIT_CHECK; 2592 2593 BCMX_PARAM_NULL_CHECK(info); 2594 2595 BCM_IF_ERROR_RETURN 2596 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 2597 BCMX_DEST_CONVERT_DEFAULT)); 2598 2599 return bcm_port_info_restore(bcm_unit, bcm_port, 2600 info); 2601 } 2602 2603 2604 int 2605 bcmx_port_info_save(bcmx_lport_t port, bcm_port_info_t *info) 2606 { 2607 int bcm_unit; 2608 bcm_port_t bcm_port; 2609 2610 BCMX_PORT_INIT_CHECK; 2611 2612 BCMX_PARAM_NULL_CHECK(info); 2613 2614 BCM_IF_ERROR_RETURN 2615 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 2616 BCMX_DEST_CONVERT_DEFAULT)); 2617 2618 return bcm_port_info_save(bcm_unit, bcm_port, 2619 info); 2620 } 2621 2622 2623 int 2624 bcmx_port_fault_get(bcmx_lport_t port, uint32 *flags) 2625 { 2626 int bcm_unit; 2627 bcm_port_t bcm_port; 2628 2629 BCMX_PORT_INIT_CHECK; 2630 2631 BCMX_PARAM_NULL_CHECK(flags); 2632 2633 BCM_IF_ERROR_RETURN 2634 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 2635 BCMX_DEST_CONVERT_DEFAULT)); 2636 2637 return bcm_port_fault_get(bcm_unit, bcm_port, 2638 flags); 2639 } 2640 2641 int 2642 bcmx_port_priority_color_set(bcmx_lport_t port, int prio, bcm_color_t color) 2643 { 2644 int bcm_unit; 2645 bcm_port_t bcm_port; 2646 2647 BCMX_PORT_INIT_CHECK; 2648 2649 BCM_IF_ERROR_RETURN 2650 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 2651 BCMX_DEST_CONVERT_DEFAULT)); 2652 2653 return bcm_port_priority_color_set(bcm_unit, bcm_port, 2654 prio, color); 2655 } 2656 2657 2658 int 2659 bcmx_port_priority_color_get(bcmx_lport_t port, int prio, bcm_color_t *color) 2660 { 2661 int bcm_unit; 2662 bcm_port_t bcm_port; 2663 2664 BCMX_PORT_INIT_CHECK; 2665 2666 BCMX_PARAM_NULL_CHECK(color); 2667 2668 BCM_IF_ERROR_RETURN 2669 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 2670 BCMX_DEST_CONVERT_DEFAULT)); 2671 2672 return bcm_port_priority_color_get(bcm_unit, bcm_port, 2673 prio, color); 2674 } 2675 2676 int 2677 bcmx_port_cfi_color_set(bcmx_lport_t port, int cfi, bcm_color_t color) 2678 { 2679 int bcm_unit; 2680 bcm_port_t bcm_port; 2681 2682 BCMX_PORT_INIT_CHECK; 2683 2684 BCM_IF_ERROR_RETURN 2685 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 2686 BCMX_DEST_CONVERT_DEFAULT)); 2687 2688 return bcm_port_cfi_color_set(bcm_unit, bcm_port, 2689 cfi, color); 2690 } 2691 2692 2693 int 2694 bcmx_port_cfi_color_get(bcmx_lport_t port, int cfi, bcm_color_t *color) 2695 { 2696 int bcm_unit; 2697 bcm_port_t bcm_port; 2698 2699 BCMX_PORT_INIT_CHECK; 2700 2701 BCMX_PARAM_NULL_CHECK(color); 2702 2703 BCM_IF_ERROR_RETURN 2704 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 2705 BCMX_DEST_CONVERT_DEFAULT)); 2706 2707 return bcm_port_cfi_color_get(bcm_unit, bcm_port, 2708 cfi, color); 2709 } 2710 2711 int 2712 bcmx_port_vlan_priority_map_set(bcmx_lport_t port, 2713 int pkt_pri, int cfi, 2714 int internal_pri, bcm_color_t color) 2715 { 2716 int bcm_unit; 2717 bcm_port_t bcm_port; 2718 2719 BCMX_PORT_INIT_CHECK; 2720 2721 BCM_IF_ERROR_RETURN 2722 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 2723 BCMX_DEST_CONVERT_DEFAULT)); 2724 2725 return bcm_port_vlan_priority_map_set(bcm_unit, bcm_port, 2726 pkt_pri, cfi, 2727 internal_pri, color); 2728 } 2729 2730 int 2731 bcmx_port_vlan_priority_map_get(bcmx_lport_t port, 2732 int pkt_pri, int cfi, 2733 int *internal_pri, bcm_color_t *color) 2734 { 2735 int bcm_unit; 2736 bcm_port_t bcm_port; 2737 2738 BCMX_PORT_INIT_CHECK; 2739 2740 BCMX_PARAM_NULL_CHECK(internal_pri); 2741 BCMX_PARAM_NULL_CHECK(color); 2742 2743 BCM_IF_ERROR_RETURN 2744 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 2745 BCMX_DEST_CONVERT_DEFAULT)); 2746 2747 return bcm_port_vlan_priority_map_get(bcm_unit, bcm_port, 2748 pkt_pri, cfi, 2749 internal_pri, color); 2750 } 2751 2752 int 2753 bcmx_port_vlan_priority_unmap_set(bcmx_lport_t port, 2754 int internal_pri, bcm_color_t color, 2755 int pkt_pri, int cfi) 2756 { 2757 int bcm_unit; 2758 bcm_port_t bcm_port; 2759 2760 BCMX_PORT_INIT_CHECK; 2761 2762 BCM_IF_ERROR_RETURN 2763 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 2764 BCMX_DEST_CONVERT_DEFAULT)); 2765 2766 return bcm_port_vlan_priority_unmap_set(bcm_unit, bcm_port, 2767 internal_pri, color, 2768 pkt_pri, cfi); 2769 } 2770 2771 int 2772 bcmx_port_vlan_priority_unmap_get(bcmx_lport_t port, 2773 int internal_pri, bcm_color_t color, 2774 int *pkt_pri, int *cfi) 2775 { 2776 int bcm_unit; 2777 bcm_port_t bcm_port; 2778 2779 BCMX_PORT_INIT_CHECK; 2780 2781 BCMX_PARAM_NULL_CHECK(pkt_pri); 2782 BCMX_PARAM_NULL_CHECK(cfi); 2783 2784 BCM_IF_ERROR_RETURN 2785 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 2786 BCMX_DEST_CONVERT_DEFAULT)); 2787 2788 return bcm_port_vlan_priority_unmap_get(bcm_unit, bcm_port, 2789 internal_pri, color, 2790 pkt_pri, cfi); 2791 } 2792 2793 int 2794 bcmx_port_vlan_inner_tag_set(bcmx_lport_t port, uint16 inner_tag) 2795 { 2796 int bcm_unit; 2797 bcm_port_t bcm_port; 2798 2799 BCMX_PORT_INIT_CHECK; 2800 2801 BCM_IF_ERROR_RETURN 2802 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 2803 BCMX_DEST_CONVERT_DEFAULT)); 2804 2805 return bcm_port_vlan_inner_tag_set(bcm_unit, bcm_port, 2806 inner_tag); 2807 } 2808 2809 int 2810 bcmx_port_vlan_inner_tag_get(bcmx_lport_t port, uint16 *inner_tag) 2811 { 2812 int bcm_unit; 2813 bcm_port_t bcm_port; 2814 2815 BCMX_PORT_INIT_CHECK; 2816 2817 BCMX_PARAM_NULL_CHECK(inner_tag); 2818 2819 BCM_IF_ERROR_RETURN 2820 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 2821 BCMX_DEST_CONVERT_DEFAULT)); 2822 2823 return bcm_port_vlan_inner_tag_get(bcm_unit, bcm_port, 2824 inner_tag); 2825 } 2826 2827 int 2828 bcmx_port_class_set(bcmx_lport_t port, bcm_port_class_t pclass, uint32 pclass_id) 2829 { 2830 int bcm_unit; 2831 bcm_port_t bcm_port; 2832 2833 BCMX_PORT_INIT_CHECK; 2834 2835 BCM_IF_ERROR_RETURN 2836 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 2837 BCMX_DEST_CONVERT_DEFAULT)); 2838 2839 return bcm_port_class_set(bcm_unit, bcm_port, 2840 pclass, 2841 pclass_id); 2842 } 2843 2844 int 2845 bcmx_port_class_get(bcmx_lport_t port, bcm_port_class_t pclass, uint32 *pclass_id) 2846 { 2847 int bcm_unit; 2848 bcm_port_t bcm_port; 2849 2850 BCMX_PORT_INIT_CHECK; 2851 2852 BCMX_PARAM_NULL_CHECK(pclass_id); 2853 2854 BCM_IF_ERROR_RETURN 2855 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 2856 BCMX_DEST_CONVERT_DEFAULT)); 2857 2858 return bcm_port_class_get(bcm_unit, bcm_port, 2859 pclass, 2860 pclass_id); 2861 } 2862 2863 2864 int 2865 bcmx_port_l3_modify_set(bcmx_lport_t port, uint32 flags) 2866 { 2867 int bcm_unit; 2868 bcm_port_t bcm_port; 2869 2870 BCMX_PORT_INIT_CHECK; 2871 2872 BCM_IF_ERROR_RETURN 2873 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 2874 BCMX_DEST_CONVERT_DEFAULT)); 2875 2876 return bcm_port_l3_modify_set(bcm_unit, bcm_port, 2877 flags); 2878 } 2879 2880 int 2881 bcmx_port_l3_modify_get(bcmx_lport_t port, uint32 *flags) 2882 { 2883 int bcm_unit; 2884 bcm_port_t bcm_port; 2885 2886 BCMX_PORT_INIT_CHECK; 2887 2888 BCMX_PARAM_NULL_CHECK(flags); 2889 2890 BCM_IF_ERROR_RETURN 2891 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 2892 BCMX_DEST_CONVERT_DEFAULT)); 2893 2894 return bcm_port_l3_modify_get(bcm_unit, bcm_port, 2895 flags); 2896 } 2897 2898 int 2899 bcmx_port_ipmc_modify_set(bcmx_lport_t port, uint32 flags) 2900 { 2901 int bcm_unit; 2902 bcm_port_t bcm_port; 2903 2904 BCMX_PORT_INIT_CHECK; 2905 2906 BCM_IF_ERROR_RETURN 2907 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 2908 BCMX_DEST_CONVERT_DEFAULT)); 2909 2910 return bcm_port_ipmc_modify_set(bcm_unit, bcm_port, 2911 flags); 2912 } 2913 2914 int 2915 bcmx_port_ipmc_modify_get(bcmx_lport_t port, uint32 *flags) 2916 { 2917 int bcm_unit; 2918 bcm_port_t bcm_port; 2919 2920 BCMX_PORT_INIT_CHECK; 2921 2922 BCMX_PARAM_NULL_CHECK(flags); 2923 2924 BCM_IF_ERROR_RETURN 2925 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 2926 BCMX_DEST_CONVERT_DEFAULT)); 2927 2928 return bcm_port_ipmc_modify_get(bcm_unit, bcm_port, 2929 flags); 2930 } 2931 2932 int 2933 bcmx_port_phy_control_set(bcmx_lport_t port, 2934 bcm_port_phy_control_t type, uint32 value) 2935 { 2936 int bcm_unit; 2937 bcm_port_t bcm_port; 2938 2939 BCMX_PORT_INIT_CHECK; 2940 2941 BCM_IF_ERROR_RETURN 2942 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 2943 BCMX_DEST_CONVERT_DEFAULT)); 2944 2945 return bcm_port_phy_control_set(bcm_unit, bcm_port, 2946 type, value); 2947 } 2948 2949 int 2950 bcmx_port_phy_control_get(bcmx_lport_t port, 2951 bcm_port_phy_control_t type, uint32 *value) 2952 { 2953 int bcm_unit; 2954 bcm_port_t bcm_port; 2955 2956 BCMX_PORT_INIT_CHECK; 2957 2958 BCMX_PARAM_NULL_CHECK(value); 2959 2960 BCM_IF_ERROR_RETURN 2961 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 2962 BCMX_DEST_CONVERT_DEFAULT)); 2963 2964 return bcm_port_phy_control_get(bcm_unit, bcm_port, 2965 type, value); 2966 } 2967 2968 int 2969 bcmx_port_force_vlan_set(bcmx_lport_t port, 2970 bcm_vlan_t vlan, int pkt_prio, uint32 flags) 2971 { 2972 int bcm_unit; 2973 bcm_port_t bcm_port; 2974 2975 BCMX_PORT_INIT_CHECK; 2976 2977 BCM_IF_ERROR_RETURN 2978 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 2979 BCMX_DEST_CONVERT_DEFAULT)); 2980 2981 return bcm_port_force_vlan_set(bcm_unit, bcm_port, 2982 vlan, pkt_prio, flags); 2983 } 2984 2985 int 2986 bcmx_port_force_vlan_get(bcmx_lport_t port, 2987 bcm_vlan_t *vlan, int *pkt_prio, uint32 *flags) 2988 { 2989 int bcm_unit; 2990 bcm_port_t bcm_port; 2991 2992 BCMX_PORT_INIT_CHECK; 2993 2994 BCMX_PARAM_NULL_CHECK(flags); 2995 2996 BCM_IF_ERROR_RETURN 2997 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 2998 BCMX_DEST_CONVERT_DEFAULT)); 2999 3000 return bcm_port_force_vlan_get(bcm_unit, bcm_port, 3001 vlan, pkt_prio, flags); 3002 } 3003 3004 int 3005 bcmx_port_gport_get(bcmx_lport_t port, bcm_gport_t *gport) 3006 { 3007 BCMX_PORT_INIT_CHECK; 3008 3009 BCMX_PARAM_NULL_CHECK(gport); 3010 3011 BCMX_LPORT_VALID_CHECK(port); 3012 *gport = port; 3013 3014 return BCM_E_NONE; 3015 } 3016 3017 /* 3018 * Function: 3019 * bcmx_port_control_set(bcmx_lport_t port, 3020 bcm_port_control_t type, int value) 3021 * Description: 3022 * Enable/Disable specified port feature. 3023 * Parameters: 3024 * port - lport to control 3025 * type - Port control parameter 3026 * value - new value of control parameter 3027 * Return Value: 3028 * BCM_E_NONE 3029 * BCM_E_UNAVAIL - Functionality not available 3030 */ 3031 3032 int 3033 bcmx_port_control_set(bcmx_lport_t port, bcm_port_control_t type, int arg) 3034 { 3035 int bcm_unit; 3036 bcm_port_t bcm_port; 3037 3038 BCMX_PORT_INIT_CHECK; 3039 3040 BCM_IF_ERROR_RETURN 3041 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 3042 BCMX_DEST_CONVERT_DEFAULT)); 3043 3044 return bcm_port_control_set(bcm_unit, bcm_port, type, arg); 3045 } 3046 3047 /* 3048 * Function: 3049 * bcmx_port_control_get(bcmx_lport_t port, 3050 bcm_port_control_t type, int *value) 3051 * Description: 3052 * Get the status of specified port feature. 3053 * Parameters: 3054 * port - lport to control 3055 * type - Port control parameter 3056 * value - (OUT) Current value of control parameter 3057 * Return Value: 3058 * BCM_E_NONE 3059 * BCM_E_UNAVAIL - Functionality not available 3060 */ 3061 3062 int 3063 bcmx_port_control_get(bcmx_lport_t port, bcm_port_control_t type, int *arg) 3064 { 3065 int bcm_unit; 3066 bcm_port_t bcm_port; 3067 3068 BCMX_PORT_INIT_CHECK; 3069 3070 BCMX_PARAM_NULL_CHECK(arg); 3071 3072 BCM_IF_ERROR_RETURN 3073 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 3074 BCMX_DEST_CONVERT_DEFAULT)); 3075 3076 return bcm_port_control_get(bcm_unit, bcm_port, type, arg); 3077 } 3078 3079 3080 /* 3081 * Function: 3082 * bcmx_port_stat_enable_set 3083 * Purpose: 3084 * Enable/disable packet and byte counters for the selected 3085 * gport. 3086 * Parameters: 3087 * port - GPORT ID, physical (lport) or virtual port 3088 * enable - Non-zero to enable counter collection, zero to disable 3089 * Returns: 3090 * BCM_E_XXX 3091 * Notes: 3092 */ 3093 int 3094 bcmx_port_stat_enable_set(bcm_gport_t port, int enable) 3095 { 3096 int rv = BCM_E_UNAVAIL, tmp_rv; 3097 int bcm_unit; 3098 bcm_port_t bcm_port; 3099 int i; 3100 3101 BCMX_PORT_INIT_CHECK; 3102 3103 if (!BCM_GPORT_IS_SET(port)) { 3104 return BCM_E_PORT; 3105 } 3106 3107 /* Physical port, apply to unit where port resides */ 3108 if (BCM_SUCCESS(_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 3109 BCMX_DEST_CONVERT_DEFAULT))) { 3110 return bcm_port_stat_enable_set(bcm_unit, port, enable); 3111 } 3112 3113 /* Virtual port, enable/disable stat in all units */ 3114 BCMX_UNIT_ITER(bcm_unit, i) { 3115 tmp_rv = bcm_port_stat_enable_set(bcm_unit, port, enable); 3116 BCM_IF_ERROR_RETURN(BCMX_PORT_SET_ERROR_CHECK(bcm_unit, tmp_rv, &rv)); 3117 } 3118 3119 return rv; 3120 } 3121 3122 /* 3123 * Function: 3124 * bcmx_port_stat_get 3125 * Purpose: 3126 * Get 64-bit counter value for specified port statistic type. 3127 * Parameters: 3128 * port - GPORT ID, physical (lport) or virtual port 3129 * stat - Type of the counter to retrieve 3130 * val - (OUT) Pointer to a counter value 3131 * Returns: 3132 * BCM_E_XXX 3133 * Notes: 3134 */ 3135 int 3136 bcmx_port_stat_get(bcm_gport_t port, bcm_port_stat_t stat, uint64 *val) 3137 { 3138 int rv = BCM_E_UNAVAIL, tmp_rv; 3139 int bcm_unit; 3140 bcm_port_t bcm_port; 3141 uint64 tmp_val; 3142 int i; 3143 3144 BCMX_PORT_INIT_CHECK; 3145 3146 if (!BCM_GPORT_IS_SET(port)) { 3147 return BCM_E_PORT; 3148 } 3149 BCMX_PARAM_NULL_CHECK(val); 3150 3151 /* Physical port, get stat from unit where port resides */ 3152 if (BCM_SUCCESS(_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 3153 BCMX_DEST_CONVERT_DEFAULT))) { 3154 return bcm_port_stat_get(bcm_unit, port, stat, val); 3155 } 3156 3157 /* Virtual port, gather stats from all units */ 3158 COMPILER_64_ZERO(*val); 3159 BCMX_UNIT_ITER(bcm_unit, i) { 3160 tmp_rv = bcm_port_stat_get(bcm_unit, port, stat, &tmp_val); 3161 if (BCMX_PORT_GET_IS_VALID(bcm_unit, tmp_rv)) { 3162 rv = tmp_rv; 3163 if (BCM_SUCCESS(tmp_rv)) { 3164 COMPILER_64_ADD_64(*val, tmp_val); 3165 } else { 3166 break; 3167 } 3168 } 3169 } 3170 3171 return rv; 3172 } 3173 3174 /* 3175 * Function: 3176 * bcmx_port_stat_get32 3177 * Purpose: 3178 * Get lower 32-bit counter value for specified port statistic 3179 * type. 3180 * Parameters: 3181 * port - GPORT ID, physical (lport) or virtual port 3182 * stat - Type of the counter to retrieve 3183 * val - (OUT) Pointer to a counter value 3184 * Returns: 3185 * BCM_E_XXX 3186 * Notes: 3187 */ 3188 int 3189 bcmx_port_stat_get32(bcm_gport_t port, bcm_port_stat_t stat, uint32 *val) 3190 { 3191 int rv = BCM_E_UNAVAIL, tmp_rv; 3192 int bcm_unit; 3193 bcm_port_t bcm_port; 3194 uint32 tmp_val; 3195 int i; 3196 3197 BCMX_PORT_INIT_CHECK; 3198 3199 if (!BCM_GPORT_IS_SET(port)) { 3200 return BCM_E_PORT; 3201 } 3202 BCMX_PARAM_NULL_CHECK(val); 3203 3204 /* Physical port, get stat from unit where port resides */ 3205 if (BCM_SUCCESS(_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 3206 BCMX_DEST_CONVERT_DEFAULT))) { 3207 return bcm_port_stat_get32(bcm_unit, port, stat, val); 3208 } 3209 3210 /* Virtual port, gather stats from all units */ 3211 *val = 0; 3212 BCMX_UNIT_ITER(bcm_unit, i) { 3213 tmp_rv = bcm_port_stat_get32(bcm_unit, port, stat, &tmp_val); 3214 if (BCMX_PORT_GET_IS_VALID(bcm_unit, tmp_rv)) { 3215 rv = tmp_rv; 3216 if (BCM_SUCCESS(tmp_rv)) { 3217 *val += tmp_val; 3218 } else { 3219 break; 3220 } 3221 } 3222 } 3223 3224 return rv; 3225 } 3226 3227 /* 3228 * Function: 3229 * bcmx_port_stat_set 3230 * Purpose: 3231 * Set 64-bit counter value for specified port statistic type. 3232 * Parameters: 3233 * port - GPORT ID, physical (lport) or virtual port 3234 * stat - Type of the counter to set 3235 * val - New counter value 3236 * Returns: 3237 * BCM_E_XXX 3238 * Notes: 3239 */ 3240 int 3241 bcmx_port_stat_set(bcm_gport_t port, bcm_port_stat_t stat, uint64 val) 3242 { 3243 int rv = BCM_E_UNAVAIL, tmp_rv; 3244 int bcm_unit; 3245 bcm_port_t bcm_port; 3246 int i; 3247 3248 BCMX_PORT_INIT_CHECK; 3249 3250 if (!BCM_GPORT_IS_SET(port)) { 3251 return BCM_E_PORT; 3252 } 3253 3254 /* Physical port, set stat in unit where port resides */ 3255 if (BCM_SUCCESS(_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 3256 BCMX_DEST_CONVERT_DEFAULT))) { 3257 return bcm_port_stat_set(bcm_unit, port, stat, val); 3258 } 3259 3260 /* Virtual port, set stat in all units */ 3261 BCMX_UNIT_ITER(bcm_unit, i) { 3262 tmp_rv = bcm_port_stat_set(bcm_unit, port, stat, val); 3263 BCM_IF_ERROR_RETURN(BCMX_PORT_SET_ERROR_CHECK(bcm_unit, tmp_rv, &rv)); 3264 } 3265 3266 return rv; 3267 } 3268 3269 /* 3270 * Function: 3271 * bcmx_port_stat_set32 3272 * Purpose: 3273 * Set lower 32-bit counter value for specified port statistic 3274 * type. 3275 * Parameters: 3276 * port - GPORT ID, physical (lport) or virtual port 3277 * stat - Type of the counter to set 3278 * val - New counter value 3279 * Returns: 3280 * BCM_E_XXX 3281 * Notes: 3282 */ 3283 int 3284 bcmx_port_stat_set32(bcm_gport_t port, bcm_port_stat_t stat, uint32 val) 3285 { 3286 int rv = BCM_E_UNAVAIL, tmp_rv; 3287 int bcm_unit; 3288 bcm_port_t bcm_port; 3289 int i; 3290 3291 BCMX_PORT_INIT_CHECK; 3292 3293 if (!BCM_GPORT_IS_SET(port)) { 3294 return BCM_E_PORT; 3295 } 3296 3297 /* Physical port, set stat in unit where port resides */ 3298 if (BCM_SUCCESS(_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 3299 BCMX_DEST_CONVERT_DEFAULT))) { 3300 return bcm_port_stat_set32(bcm_unit, port, stat, val); 3301 } 3302 3303 /* Virtual port, set stat in all units */ 3304 BCMX_UNIT_ITER(bcm_unit, i) { 3305 tmp_rv = bcm_port_stat_set32(bcm_unit, port, stat, val); 3306 BCM_IF_ERROR_RETURN(BCMX_PORT_SET_ERROR_CHECK(bcm_unit, tmp_rv, &rv)); 3307 } 3308 3309 return rv; 3310 } 3311 3312 /* 3313 * Function: 3314 * bcmx_port_stat_multi_get 3315 * Purpose: 3316 * Get 64-bit counter value for multiple port statistic types. 3317 * Parameters: 3318 * port - GPORT ID, physical (lport) or virtual port 3319 * nstat - Number of elements in stat array 3320 * stat_arr - Collected statistics descriptors array 3321 * value_arr - (OUT) Collected counters values 3322 * Returns: 3323 * BCM_E_XXX 3324 * Notes: 3325 */ 3326 int 3327 bcmx_port_stat_multi_get(bcm_gport_t port, int nstat, 3328 bcm_port_stat_t *stat_arr, uint64 *value_arr) 3329 { 3330 int rv = BCM_E_UNAVAIL, tmp_rv; 3331 int bcm_unit; 3332 bcm_port_t bcm_port; 3333 uint64 *tmp_val; 3334 int i; 3335 3336 BCMX_PORT_INIT_CHECK; 3337 3338 if (!BCM_GPORT_IS_SET(port)) { 3339 return BCM_E_PORT; 3340 } 3341 BCMX_PARAM_ARRAY_NULL_CHECK(nstat, stat_arr); 3342 BCMX_PARAM_ARRAY_NULL_CHECK(nstat, value_arr); 3343 3344 /* Physical port, get stat from unit where port resides */ 3345 if (BCM_SUCCESS(_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 3346 BCMX_DEST_CONVERT_DEFAULT))) { 3347 return bcm_port_stat_multi_get(bcm_unit, port, nstat, 3348 stat_arr, value_arr); 3349 } 3350 3351 /* Virtual port, gather stats from all units */ 3352 tmp_val = sal_alloc(sizeof(uint64) * nstat, "bcmx port stat"); 3353 if (tmp_val == NULL) { 3354 return BCM_E_MEMORY; 3355 } 3356 3357 for (i = 0; i < nstat; i++) { 3358 COMPILER_64_ZERO(value_arr[i]); 3359 } 3360 BCMX_UNIT_ITER(bcm_unit, i) { 3361 tmp_rv = bcm_port_stat_multi_get(bcm_unit, port, nstat, 3362 stat_arr, tmp_val); 3363 if (BCMX_PORT_GET_IS_VALID(bcm_unit, tmp_rv)) { 3364 rv = tmp_rv; 3365 if (BCM_SUCCESS(tmp_rv)) { 3366 for (i = 0; i < nstat; i++) { 3367 COMPILER_64_ADD_64(value_arr[i], tmp_val[i]); 3368 } 3369 } else { 3370 break; 3371 } 3372 } 3373 } 3374 3375 sal_free(tmp_val); 3376 3377 return rv; 3378 } 3379 3380 /* 3381 * Function: 3382 * bcmx_port_stat_multi_get32 3383 * Purpose: 3384 * Get lower 32-bit counter value for multiple port statistic 3385 * types. 3386 * Parameters: 3387 * port - GPORT ID, physical (lport) or virtual port 3388 * nstat - Number of elements in stat array 3389 * stat_arr - Collected statistics descriptors array 3390 * value_arr - (OUT) Collected counters values 3391 * Returns: 3392 * BCM_E_XXX 3393 * Notes: 3394 */ 3395 int 3396 bcmx_port_stat_multi_get32(bcm_gport_t port, int nstat, 3397 bcm_port_stat_t *stat_arr, uint32 *value_arr) 3398 { 3399 int rv = BCM_E_UNAVAIL, tmp_rv; 3400 int bcm_unit; 3401 bcm_port_t bcm_port; 3402 uint32 *tmp_val; 3403 int i; 3404 3405 BCMX_PORT_INIT_CHECK; 3406 3407 if (!BCM_GPORT_IS_SET(port)) { 3408 return BCM_E_PORT; 3409 } 3410 BCMX_PARAM_NULL_CHECK(stat_arr); 3411 BCMX_PARAM_NULL_CHECK(value_arr); 3412 3413 /* Physical port, get stat from unit where port resides */ 3414 if (BCM_SUCCESS(_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 3415 BCMX_DEST_CONVERT_DEFAULT))) { 3416 return bcm_port_stat_multi_get32(bcm_unit, port, nstat, 3417 stat_arr, value_arr); 3418 } 3419 3420 /* Virtual port, gather stats from all units */ 3421 tmp_val = sal_alloc(sizeof(uint32) * nstat, "bcmx port stat"); 3422 if (tmp_val == NULL) { 3423 return BCM_E_MEMORY; 3424 } 3425 3426 for (i = 0; i < nstat; i++) { 3427 value_arr[i] = 0; 3428 } 3429 BCMX_UNIT_ITER(bcm_unit, i) { 3430 tmp_rv = bcm_port_stat_multi_get32(bcm_unit, port, nstat, 3431 stat_arr, tmp_val); 3432 if (BCMX_PORT_GET_IS_VALID(bcm_unit, tmp_rv)) { 3433 rv = tmp_rv; 3434 if (BCM_SUCCESS(tmp_rv)) { 3435 for (i = 0; i < nstat; i++) { 3436 value_arr[i] += tmp_val[i]; 3437 } 3438 } else { 3439 break; 3440 } 3441 } 3442 } 3443 3444 sal_free(tmp_val); 3445 3446 return rv; 3447 } 3448 3449 /* 3450 * Function: 3451 * bcmx_port_stat_multi_set 3452 * Purpose: 3453 * Set 64-bit counter value for multiple port statistic types. 3454 * Parameters: 3455 * port - GPORT ID, physical (lport) or virtual port 3456 * nstat - Number of elements in stat array 3457 * stat_arr - New statistics descriptors array 3458 * value_arr - New counters values to set 3459 * Returns: 3460 * BCM_E_XXX 3461 * Notes: 3462 */ 3463 int 3464 bcmx_port_stat_multi_set(bcm_gport_t port, int nstat, 3465 bcm_port_stat_t *stat_arr, uint64 *value_arr) 3466 { 3467 int rv = BCM_E_UNAVAIL, tmp_rv; 3468 int bcm_unit; 3469 bcm_port_t bcm_port; 3470 int i; 3471 3472 BCMX_PORT_INIT_CHECK; 3473 3474 if (!BCM_GPORT_IS_SET(port)) { 3475 return BCM_E_PORT; 3476 } 3477 BCMX_PARAM_NULL_CHECK(stat_arr); 3478 BCMX_PARAM_NULL_CHECK(value_arr); 3479 3480 /* Physical port, set stat in unit where port resides */ 3481 if (BCM_SUCCESS(_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 3482 BCMX_DEST_CONVERT_DEFAULT))) { 3483 return bcm_port_stat_multi_set(bcm_unit, port, nstat, 3484 stat_arr, value_arr); 3485 } 3486 3487 /* Virtual port, set stat in all units */ 3488 BCMX_UNIT_ITER(bcm_unit, i) { 3489 tmp_rv = bcm_port_stat_multi_set(bcm_unit, port, nstat, 3490 stat_arr, value_arr); 3491 BCM_IF_ERROR_RETURN(BCMX_PORT_SET_ERROR_CHECK(bcm_unit, tmp_rv, &rv)); 3492 } 3493 3494 return rv; 3495 } 3496 3497 /* 3498 * Function: 3499 * bcmx_port_stat_multi_set32 3500 * Purpose: 3501 * Set lower 32-bit counter value for multiple port statistic 3502 * types. 3503 * Parameters: 3504 * port - GPORT ID, physical (lport) or virtual port 3505 * nstat - Number of elements in stat array 3506 * stat_arr - New statistics descriptors array 3507 * value_arr - New counters values to set 3508 * Returns: 3509 * BCM_E_XXX 3510 * Notes: 3511 */ 3512 int 3513 bcmx_port_stat_multi_set32(bcm_gport_t port, int nstat, 3514 bcm_port_stat_t *stat_arr, uint32 *value_arr) 3515 { 3516 int rv = BCM_E_UNAVAIL, tmp_rv; 3517 int bcm_unit; 3518 bcm_port_t bcm_port; 3519 int i; 3520 3521 BCMX_PORT_INIT_CHECK; 3522 3523 if (!BCM_GPORT_IS_SET(port)) { 3524 return BCM_E_PORT; 3525 } 3526 BCMX_PARAM_NULL_CHECK(stat_arr); 3527 BCMX_PARAM_NULL_CHECK(value_arr); 3528 3529 /* Physical port, set stat in unit where port resides */ 3530 if (BCM_SUCCESS(_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 3531 BCMX_DEST_CONVERT_DEFAULT))) { 3532 return bcm_port_stat_multi_set32(bcm_unit, port, nstat, 3533 stat_arr, value_arr); 3534 } 3535 3536 /* Virtual port, set stat in all units */ 3537 BCMX_UNIT_ITER(bcm_unit, i) { 3538 tmp_rv = bcm_port_stat_multi_set32(bcm_unit, port, nstat, 3539 stat_arr, value_arr); 3540 BCM_IF_ERROR_RETURN(BCMX_PORT_SET_ERROR_CHECK(bcm_unit, tmp_rv, &rv)); 3541 } 3542 3543 return rv; 3544 } 3545 3546 /* 3547 * Function: 3548 * bcmx_port_subsidiary_ports_get 3549 * Purpose: 3550 * Given a controlling port, this API returns the set of ancillary ports 3551 * belonging to the group (port block) that can be configured to operate 3552 * either as a single high-speed port or multiple GE ports. If the input 3553 * port is not a controlling port, an empty list is returned. 3554 * Parameters: 3555 * port - Controlling port 3556 * lplist - (OUT) List of ports associated with the hot-swap group 3557 * Returns: 3558 * BCM_E_XXX 3559 * Notes: 3560 */ 3561 int 3562 bcmx_port_subsidiary_ports_get(bcm_gport_t port, bcmx_lplist_t *lplist) 3563 { 3564 int rv; 3565 int bcm_unit; 3566 bcm_port_t bcm_port; 3567 bcm_pbmp_t pbmp; 3568 3569 BCMX_PORT_INIT_CHECK; 3570 3571 BCMX_PARAM_NULL_CHECK(lplist); 3572 3573 BCM_IF_ERROR_RETURN(bcmx_lplist_clear(lplist)); 3574 3575 BCM_IF_ERROR_RETURN 3576 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 3577 BCMX_DEST_CONVERT_DEFAULT)); 3578 3579 rv = bcm_port_subsidiary_ports_get(bcm_unit, port, &pbmp); 3580 if (BCM_SUCCESS(rv)) { 3581 rv = BCMX_LPLIST_PBMP_ADD(lplist, bcm_unit, pbmp); 3582 } 3583 3584 return rv; 3585 } 3586 3587 3588 /* 3589 * Function: 3590 * bcmx_port_congestion_config_set 3591 * Purpose: 3592 * Set end-to-end congestion control. 3593 * Parameters: 3594 * port - Logical port number 3595 * config - Structure containing the congestion configuration 3596 * Returns: 3597 * BCM_E_XXX 3598 */ 3599 int 3600 bcmx_port_congestion_config_set(bcm_gport_t port, 3601 bcmx_port_congestion_config_t *config) 3602 { 3603 int bcm_unit; 3604 bcm_port_t bcm_port; 3605 3606 BCMX_PORT_INIT_CHECK; 3607 3608 BCMX_PARAM_NULL_CHECK(config); 3609 3610 BCM_IF_ERROR_RETURN 3611 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 3612 BCMX_DEST_CONVERT_DEFAULT)); 3613 3614 return bcm_port_congestion_config_set 3615 (bcm_unit, port, BCMX_PORT_CONGESTION_CONFIG_T_PTR_TO_BCM(config)); 3616 } 3617 3618 /* 3619 * Function: 3620 * bcmx_port_congestion_config_get 3621 * Purpose: 3622 * Get end-to-end congestion control configuration. 3623 * Parameters: 3624 * port - Logical port number 3625 * config - (OUT) Structure containing the congestion configuration 3626 * Returns: 3627 * BCM_E_XXX 3628 */ 3629 int 3630 bcmx_port_congestion_config_get(bcm_gport_t port, 3631 bcmx_port_congestion_config_t *config) 3632 { 3633 int bcm_unit; 3634 bcm_port_t bcm_port; 3635 3636 BCMX_PORT_INIT_CHECK; 3637 3638 BCMX_PARAM_NULL_CHECK(config); 3639 3640 BCM_IF_ERROR_RETURN 3641 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 3642 BCMX_DEST_CONVERT_DEFAULT)); 3643 3644 return bcm_port_congestion_config_get 3645 (bcm_unit, port, BCMX_PORT_CONGESTION_CONFIG_T_PTR_TO_BCM(config)); 3646 } 3647 3648 3649 /* 3650 * Function: 3651 * bcmx_port_match_add 3652 * Purpose: 3653 * Add a match to an existing port. 3654 * Parameters: 3655 * port - Gport 3656 * match - Match criteria 3657 * Returns: 3658 * BCM_E_XXX 3659 */ 3660 int 3661 bcmx_port_match_add(bcm_gport_t port, bcmx_port_match_info_t *match) 3662 { 3663 int rv = BCM_E_UNAVAIL, tmp_rv; 3664 int i, bcm_unit; 3665 3666 BCMX_PORT_INIT_CHECK; 3667 3668 BCMX_PARAM_NULL_CHECK(match); 3669 3670 BCMX_UNIT_ITER(bcm_unit, i) { 3671 tmp_rv = bcm_port_match_add 3672 (bcm_unit, port, BCMX_PORT_MATCH_INFO_T_PTR_TO_BCM(match)); 3673 3674 BCM_IF_ERROR_RETURN(BCMX_PORT_SET_ERROR_CHECK(bcm_unit, tmp_rv, &rv)); 3675 } 3676 3677 return rv; 3678 } 3679 3680 /* 3681 * Function: 3682 * bcmx_port_match_delete 3683 * Purpose: 3684 * Remove a match from an existing port. 3685 * Parameters: 3686 * port - Gport 3687 * match - Match criteria 3688 * Returns: 3689 * BCM_E_XXX 3690 */ 3691 int 3692 bcmx_port_match_delete(bcm_gport_t port, bcmx_port_match_info_t *match) 3693 { 3694 int rv = BCM_E_UNAVAIL, tmp_rv; 3695 int i, bcm_unit; 3696 3697 BCMX_PORT_INIT_CHECK; 3698 3699 BCMX_PARAM_NULL_CHECK(match); 3700 3701 BCMX_UNIT_ITER(bcm_unit, i) { 3702 tmp_rv = bcm_port_match_delete 3703 (bcm_unit, port, BCMX_PORT_MATCH_INFO_T_PTR_TO_BCM(match)); 3704 3705 BCM_IF_ERROR_RETURN 3706 (BCMX_PORT_DELETE_ERROR_CHECK(bcm_unit, tmp_rv, &rv)); 3707 } 3708 3709 return rv; 3710 } 3711 3712 /* 3713 * Function: 3714 * bcmx_port_match_replace 3715 * Purpose: 3716 * Replace an old match with a new one for an existing port. 3717 * Parameters: 3718 * port - Gport 3719 * old_match - Old match criteria 3720 * new_match - New match criteria 3721 * Returns: 3722 * BCM_E_XXX 3723 */ 3724 int 3725 bcmx_port_match_replace(bcm_gport_t port, 3726 bcmx_port_match_info_t *old_match, 3727 bcmx_port_match_info_t *new_match) 3728 { 3729 int rv = BCM_E_UNAVAIL, tmp_rv; 3730 int i, bcm_unit; 3731 3732 BCMX_PORT_INIT_CHECK; 3733 3734 BCMX_PARAM_NULL_CHECK(old_match); 3735 BCMX_PARAM_NULL_CHECK(new_match); 3736 3737 BCMX_UNIT_ITER(bcm_unit, i) { 3738 tmp_rv = bcm_port_match_replace 3739 (bcm_unit, port, 3740 BCMX_PORT_MATCH_INFO_T_PTR_TO_BCM(old_match), 3741 BCMX_PORT_MATCH_INFO_T_PTR_TO_BCM(new_match)); 3742 3743 BCM_IF_ERROR_RETURN(BCMX_PORT_SET_ERROR_CHECK(bcm_unit, tmp_rv, &rv)); 3744 } 3745 3746 return rv; 3747 } 3748 3749 /* 3750 * Function: 3751 * bcmx_port_match_multi_get 3752 * Purpose: 3753 * Replace an old match with a new one for an existing port. 3754 * Parameters: 3755 * port - Gport 3756 * size - Array size 3757 * match_array - (OUT) Match array 3758 * count - (OUT) Number of match entries returned in array 3759 * Returns: 3760 * BCM_E_XXX 3761 */ 3762 int 3763 bcmx_port_match_multi_get(bcm_gport_t port, int size, 3764 bcmx_port_match_info_t *match_array, 3765 int *count) 3766 { 3767 int rv; 3768 int i, bcm_unit; 3769 3770 BCMX_PORT_INIT_CHECK; 3771 3772 BCMX_PARAM_ARRAY_NULL_CHECK(size, match_array); 3773 BCMX_PARAM_NULL_CHECK(count); 3774 3775 BCMX_UNIT_ITER(bcm_unit, i) { 3776 rv = bcm_port_match_multi_get 3777 (bcm_unit, port, size, 3778 BCMX_PORT_MATCH_INFO_T_PTR_TO_BCM(match_array), count); 3779 3780 if (BCMX_PORT_GET_IS_VALID(bcm_unit, rv)) { 3781 return rv; 3782 } 3783 } 3784 3785 return BCM_E_UNAVAIL; 3786 } 3787 3788 /* 3789 * Function: 3790 * bcmx_port_match_set 3791 * Purpose: 3792 * Assign a set of matches to an existing port. 3793 * Parameters: 3794 * port - Gport 3795 * size - Number of entries in match array 3796 * match_array - Match array 3797 * Returns: 3798 * BCM_E_XXX 3799 */ 3800 int 3801 bcmx_port_match_set(bcm_gport_t port, int size, 3802 bcmx_port_match_info_t *match_array) 3803 { 3804 int rv = BCM_E_UNAVAIL, tmp_rv; 3805 int i, bcm_unit; 3806 3807 BCMX_PORT_INIT_CHECK; 3808 3809 BCMX_PARAM_NULL_CHECK(match_array); 3810 3811 BCMX_UNIT_ITER(bcm_unit, i) { 3812 tmp_rv = bcm_port_match_set 3813 (bcm_unit, port, size, 3814 BCMX_PORT_MATCH_INFO_T_PTR_TO_BCM(match_array)); 3815 3816 BCM_IF_ERROR_RETURN(BCMX_PORT_SET_ERROR_CHECK(bcm_unit, tmp_rv, &rv)); 3817 } 3818 3819 return rv; 3820 } 3821 3822 /* 3823 * Function: 3824 * bcmx_port_match_delete_all 3825 * Purpose: 3826 * Delete all matches for an existing port. 3827 * Parameters: 3828 * port - Gport 3829 * Returns: 3830 * BCM_E_XXX 3831 */ 3832 int 3833 bcmx_port_match_delete_all(bcm_gport_t port) 3834 { 3835 int rv = BCM_E_UNAVAIL, tmp_rv; 3836 int i, bcm_unit; 3837 3838 BCMX_PORT_INIT_CHECK; 3839 3840 BCMX_UNIT_ITER(bcm_unit, i) { 3841 tmp_rv = bcm_port_match_delete_all(bcm_unit, port); 3842 BCM_IF_ERROR_RETURN 3843 (BCMX_PORT_DELETE_ERROR_CHECK(bcm_unit, tmp_rv, &rv)); 3844 } 3845 3846 return rv; 3847 } 3848 3849 /* 3850 * Function: 3851 * bcmx_port_phy_timesync_config_set 3852 * Purpose: 3853 * Set phy_timesync configuration for port. 3854 * Parameters: 3855 * port - Port 3856 * conf - Timesync configuration 3857 * Returns: 3858 * BCM_E_XXX 3859 */ 3860 int 3861 bcmx_port_phy_timesync_config_set(bcm_gport_t port, 3862 bcmx_port_phy_timesync_config_t *conf) 3863 { 3864 int bcm_unit; 3865 bcm_port_t bcm_port; 3866 3867 BCMX_PORT_INIT_CHECK; 3868 3869 BCMX_PARAM_NULL_CHECK(conf); 3870 3871 BCM_IF_ERROR_RETURN 3872 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 3873 BCMX_DEST_CONVERT_DEFAULT)); 3874 3875 return bcm_port_phy_timesync_config_set(bcm_unit, port, 3876 BCMX_PORT_TIMESYNC_CONFIG_T_PTR_TO_BCM 3877 (conf)); 3878 } 3879 3880 /* 3881 * Function: 3882 * bcmx_port_phy_timesync_config_get 3883 * Purpose: 3884 * Get phy_timesync configuration for port. 3885 * Parameters: 3886 * port - Port 3887 * conf - (OUT) Timesync configuration 3888 * Returns: 3889 * BCM_E_XXX 3890 */ 3891 int 3892 bcmx_port_phy_timesync_config_get(bcm_gport_t port, 3893 bcmx_port_phy_timesync_config_t *conf) 3894 { 3895 int bcm_unit; 3896 bcm_port_t bcm_port; 3897 3898 BCMX_PORT_INIT_CHECK; 3899 3900 BCMX_PARAM_NULL_CHECK(conf); 3901 3902 BCM_IF_ERROR_RETURN 3903 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 3904 BCMX_DEST_CONVERT_DEFAULT)); 3905 3906 return bcm_port_phy_timesync_config_get(bcm_unit, port, 3907 BCMX_PORT_TIMESYNC_CONFIG_T_PTR_TO_BCM 3908 (conf)); 3909 } 3910 3911 /* 3912 * Function: 3913 * bcmx_port_phy_timesync_enhanced_capture_get 3914 * Purpose: 3915 * Get phy_timesync configuration for port. 3916 * Parameters: 3917 * port - Port 3918 * value - (OUT) Enhanced capture info 3919 * Returns: 3920 * BCM_E_XXX 3921 */ 3922 int 3923 bcmx_port_phy_timesync_enhanced_capture_get(bcm_gport_t port, 3924 bcmx_port_phy_timesync_enhanced_capture_t *value) 3925 { 3926 int bcm_unit; 3927 bcm_port_t bcm_port; 3928 3929 BCMX_PORT_INIT_CHECK; 3930 3931 BCMX_PARAM_NULL_CHECK(value); 3932 3933 BCM_IF_ERROR_RETURN 3934 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 3935 BCMX_DEST_CONVERT_DEFAULT)); 3936 3937 return bcm_port_phy_timesync_enhanced_capture_get(bcm_unit, port, 3938 BCMX_PORT_TIMESYNC_ENHANCED_CAPTURE_T_PTR_TO_BCM 3939 (value)); 3940 } 3941 3942 3943 /* 3944 * Function: 3945 * bcmx_port_control_phy_timesync_set 3946 * Purpose: 3947 * Set phy_timesync control value. 3948 * Parameters: 3949 * port - Port 3950 * type - Timesync control 3951 * value - Value 3952 * Returns: 3953 * BCM_E_XXX 3954 */ 3955 int 3956 bcmx_port_control_phy_timesync_set(bcm_gport_t port, 3957 bcm_port_control_phy_timesync_t type, uint64 value) 3958 { 3959 int bcm_unit; 3960 bcm_port_t bcm_port; 3961 3962 BCMX_PORT_INIT_CHECK; 3963 3964 BCM_IF_ERROR_RETURN 3965 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 3966 BCMX_DEST_CONVERT_DEFAULT)); 3967 3968 return bcm_port_control_phy_timesync_set(bcm_unit, port, type, value); 3969 } 3970 3971 3972 /* 3973 * Function: 3974 * bcmx_port_control_phy_timesync_get 3975 * Purpose: 3976 * Get phy_timesync control value. 3977 * Parameters: 3978 * port - Port 3979 * type - Timesync control 3980 * value - (OUT) Value 3981 * Returns: 3982 * BCM_E_XXX 3983 */ 3984 int 3985 bcmx_port_control_phy_timesync_get(bcm_gport_t port, 3986 bcm_port_control_phy_timesync_t type, uint64 *value) 3987 { 3988 int bcm_unit; 3989 bcm_port_t bcm_port; 3990 3991 BCMX_PORT_INIT_CHECK; 3992 3993 BCMX_PARAM_NULL_CHECK(value); 3994 3995 BCM_IF_ERROR_RETURN 3996 (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port, 3997 BCMX_DEST_CONVERT_DEFAULT)); 3998 3999 return bcm_port_control_phy_timesync_get(bcm_unit, port, type, value); 4000 } 4001