bcm_iunimac.c (21212B)
1 /* 2 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 3 * 4 * Copyright 2007-2019 Broadcom Inc. All rights reserved. 5 */ 6 7 #ifdef INCLUDE_PLP_IMACSEC 8 #include "bcm_iunimac.h" 9 10 #define LINE_SIDE 0 11 #define SYSTEM_SIDE 1 12 13 /*************************************************************** 14 * Unimac driver functions. 15 */ 16 /* 17 * Function: 18 * imacsec_plp_base_t_unimac_init 19 * Purpose: 20 * Initialize the MAC 21 * Initialization is done as a part of the PHY initialization sequence 22 * that initializes MAC to default settings. 23 * Parameters: 24 * @param unit (input) BCM unit number 25 * @param port (input) - port number 26 * @param if_side (input) - Select the side 27 * 0 LINE_SIDE 28 * 1 SYSTEM_SIDE 29 * Notes: 30 * The MAC will be put in Auto config mode at initilization 31 * MAX Frame Size = 0x3fff 32 * IPG = 12 33 * TX and RX are enabled 34 */ 35 int 36 imacsec_plp_base_t_unimac_init(int unit, soc_port_t port,int if_side) 37 { 38 int rv=0; 39 phy_ctrl_t *pc; 40 bcm_plp_base_t_sec_phy_access_t *imacsec_des; 41 EXT_PHY_INIT_CHECK(unit,port); 42 pc = EXT_PHY_SW_STATE(unit, port); 43 imacsec_des = IMACSEC_DES_PTR_GET(pc); 44 if(imacsec_des->unimac == NULL){ 45 return SOC_E_INTERNAL; 46 } 47 if(if_side==SYSTEM_SIDE){ 48 port = PHY_UNIMAC_V2_SWITCH_PORT(port); 49 } else{ 50 port = PHY_UNIMAC_V2_LINE_PORT(port); 51 } 52 rv = BMACSEC_MAC_INIT(imacsec_des->unimac,port); 53 return rv; 54 } 55 56 /* 57 * Function: 58 * imacsec_plp_base_t_unimac_auto_cfg 59 * Purpose: 60 * This function puts the MAC in auto config if auto_cfg is 1. 61 * Parameters: 62 * @param unit (input) BCM unit number 63 * @param port (input) - port number 64 * @param if_side (input) - Select the side 65 * 0 LINE_SIDE 66 * 1 SYSTEM_SIDE 67 * @param auto_cfg - Auto configuration flag 68 * 1 = Auto configuration 69 * 0 = Forced mode 70 * Notes: 71 */ 72 int 73 imacsec_plp_base_t_unimac_auto_cfg(int unit, soc_port_t port,int if_side, int auto_cfg) 74 { 75 int rv=0; 76 phy_ctrl_t *pc; 77 bcm_plp_base_t_sec_phy_access_t *imacsec_des; 78 EXT_PHY_INIT_CHECK(unit,port); 79 pc = EXT_PHY_SW_STATE(unit, port); 80 imacsec_des = IMACSEC_DES_PTR_GET(pc); 81 if(imacsec_des->unimac == NULL){ 82 return SOC_E_INTERNAL; 83 } 84 if(if_side==SYSTEM_SIDE){ 85 port = PHY_UNIMAC_V2_SWITCH_PORT(port); 86 } else{ 87 port = PHY_UNIMAC_V2_LINE_PORT(port); 88 } 89 rv = BMACSEC_MAC_AUTO_CONFIG_SET(imacsec_des->unimac,port,auto_cfg); 90 return rv; 91 } 92 93 94 /* 95 * Function: 96 * imacsec_plp_base_t_unimac_reset 97 * Purpose: 98 * This function puts the MAC in reset if reset is 1 else takes MAC 99 * out of reset 100 * Parameters: 101 * @param unit (input) BCM unit number 102 * @param port (input) - port number 103 * @param if_side (input) - Select the side 104 * 0 LINE_SIDE 105 * 1 SYSTEM_SIDE 106 * @param reset - Reset MAC 107 * 1 = Put in Reset 108 * 0 = Take out of reset 109 * Notes: 110 */ 111 int 112 imacsec_plp_base_t_unimac_reset(int unit, soc_port_t port,int if_side, int reset) 113 { 114 int rv=0; 115 phy_ctrl_t *pc; 116 bcm_plp_base_t_sec_phy_access_t *imacsec_des; 117 EXT_PHY_INIT_CHECK(unit,port); 118 pc = EXT_PHY_SW_STATE(unit, port); 119 imacsec_des = IMACSEC_DES_PTR_GET(pc); 120 if(imacsec_des->unimac == NULL){ 121 return SOC_E_INTERNAL; 122 } 123 if(if_side==SYSTEM_SIDE){ 124 port = PHY_UNIMAC_V2_SWITCH_PORT(port); 125 } else{ 126 port = PHY_UNIMAC_V2_LINE_PORT(port); 127 } 128 rv = BMACSEC_MAC_RESET(imacsec_des->unimac,port,reset); 129 return rv; 130 } 131 132 /* 133 * Function: 134 * imacsec_plp_base_t_unimac_enable_set 135 * Purpose: 136 * Enable/Disable MAC 137 * Parameters: 138 * @param unit (input) BCM unit number 139 * @param port (input) - port number 140 * @param if_side (input) - Select the side 141 * 0 LINE_SIDE 142 * 1 SYSTEM_SIDE 143 * @param enable - Enable flag 144 * 1 = Enable MAC 145 * 0 = Disable MAC 146 * Notes: 147 */ 148 int 149 imacsec_plp_base_t_unimac_enable_set(int unit, soc_port_t port,int if_side, int enable) 150 { 151 int rv=0; 152 phy_ctrl_t *pc; 153 bcm_plp_base_t_sec_phy_access_t *imacsec_des; 154 EXT_PHY_INIT_CHECK(unit,port); 155 pc = EXT_PHY_SW_STATE(unit, port); 156 imacsec_des = IMACSEC_DES_PTR_GET(pc); 157 if(imacsec_des->unimac == NULL){ 158 return SOC_E_INTERNAL; 159 } 160 if(if_side==SYSTEM_SIDE){ 161 port = PHY_UNIMAC_V2_SWITCH_PORT(port); 162 } else{ 163 port = PHY_UNIMAC_V2_LINE_PORT(port); 164 } 165 rv = BMACSEC_MAC_ENABLE_SET(imacsec_des->unimac,port,enable); 166 return rv; 167 } 168 169 /* 170 * Function: 171 * imacsec_plp_base_t_unimac_enable_get 172 * Purpose: 173 * Get the enable status of MAC 174 * Parameters: 175 * @param unit (input) BCM unit number 176 * @param port (input) - port number 177 * @param if_side (input) - Select the side 178 * 0 LINE_SIDE 179 * 1 SYSTEM_SIDE 180 * @param enable - (OUT)Enable flag 181 * 1 = Enable MAC 182 * 0 = Disable MAC 183 * Notes: 184 */ 185 int 186 imacsec_plp_base_t_unimac_enable_get(int unit, soc_port_t port, int if_side, int *enable) 187 { 188 int rv=0; 189 phy_ctrl_t *pc; 190 bcm_plp_base_t_sec_phy_access_t *imacsec_des; 191 EXT_PHY_INIT_CHECK(unit,port); 192 pc = EXT_PHY_SW_STATE(unit, port); 193 imacsec_des = IMACSEC_DES_PTR_GET(pc); 194 if(imacsec_des->unimac == NULL){ 195 return SOC_E_INTERNAL; 196 } 197 if(if_side==SYSTEM_SIDE){ 198 port = PHY_UNIMAC_V2_SWITCH_PORT(port); 199 } else{ 200 port = PHY_UNIMAC_V2_LINE_PORT(port); 201 } 202 rv = BMACSEC_MAC_ENABLE_GET(imacsec_des->unimac,port,enable); 203 return rv; 204 } 205 /* 206 * Function: 207 * imacsec_plp_base_t_unimac_speed_set 208 * Purpose: 209 * Set Speed of the MAC 210 * Parameters: 211 * @param unit (input) BCM unit number 212 * @param port (input) - port number 213 * @param if_side (input) - Select the side 214 * 0 LINE_SIDE 215 * 1 SYSTEM_SIDE 216 * @param speed - 1000 - 1000Mbps 217 * 100 - 100Mbps 218 * 10 - 10Mbps 219 * Notes: 220 */ 221 int 222 imacsec_plp_base_t_unimac_speed_set(int unit, soc_port_t port, int if_side, int speed) 223 { 224 int rv=0; 225 phy_ctrl_t *pc; 226 bcm_plp_base_t_sec_phy_access_t *imacsec_des; 227 EXT_PHY_INIT_CHECK(unit,port); 228 pc = EXT_PHY_SW_STATE(unit, port); 229 imacsec_des = IMACSEC_DES_PTR_GET(pc); 230 if(imacsec_des->unimac == NULL){ 231 return SOC_E_INTERNAL; 232 } 233 if(if_side==SYSTEM_SIDE){ 234 port = PHY_UNIMAC_V2_SWITCH_PORT(port); 235 } else{ 236 port = PHY_UNIMAC_V2_LINE_PORT(port); 237 } 238 rv = BMACSEC_MAC_SPEED_SET(imacsec_des->unimac,port,speed); 239 return rv; 240 } 241 /* 242 * Function: 243 * imacsec_plp_base_t_unimac_speed_get 244 * Purpose: 245 * Get Speed of the MAC 246 * Parameters: 247 * @param unit (input) BCM unit number 248 * @param port (input) - port number 249 * @param if_side (input) - Select the side 250 * 0 LINE_SIDE 251 * 1 SYSTEM_SIDE 252 * @param speed - (OUT) 1000 - 1000Mbps 253 * 100 - 100Mbps 254 * 10 - 10Mbps 255 * Notes: 256 */ 257 int 258 imacsec_plp_base_t_unimac_speed_get(int unit, soc_port_t port, int if_side, int *speed) 259 { 260 int rv=0; 261 phy_ctrl_t *pc; 262 bcm_plp_base_t_sec_phy_access_t *imacsec_des; 263 EXT_PHY_INIT_CHECK(unit,port); 264 pc = EXT_PHY_SW_STATE(unit, port); 265 imacsec_des = IMACSEC_DES_PTR_GET(pc); 266 if(imacsec_des->unimac == NULL){ 267 return SOC_E_INTERNAL; 268 } 269 if(if_side==SYSTEM_SIDE){ 270 port = PHY_UNIMAC_V2_SWITCH_PORT(port); 271 } else{ 272 port = PHY_UNIMAC_V2_LINE_PORT(port); 273 } 274 rv = BMACSEC_MAC_SPEED_GET(imacsec_des->unimac,port,speed); 275 return rv; 276 } 277 /* 278 * Function: 279 * imacsec_plp_base_t_unimac_duplex_set 280 * Purpose: 281 * Set Duplex of the MAC 282 * Parameters: 283 * @param unit (input) BCM unit number 284 * @param port (input) - port number 285 * @param if_side (input) - Select the side 286 * 0 LINE_SIDE 287 * 1 SYSTEM_SIDE 288 * @param duplex - 1 - Full Duplex 289 * 0 - Half Duplex 290 * Notes: 291 */ 292 int 293 imacsec_plp_base_t_unimac_duplex_set(int unit, soc_port_t port, int if_side, int duplex) 294 { 295 int rv=0; 296 phy_ctrl_t *pc; 297 bcm_plp_base_t_sec_phy_access_t *imacsec_des; 298 EXT_PHY_INIT_CHECK(unit,port); 299 pc = EXT_PHY_SW_STATE(unit, port); 300 imacsec_des = IMACSEC_DES_PTR_GET(pc); 301 if(imacsec_des->unimac == NULL){ 302 return SOC_E_INTERNAL; 303 } 304 if(if_side==SYSTEM_SIDE){ 305 port = PHY_UNIMAC_V2_SWITCH_PORT(port); 306 } else{ 307 port = PHY_UNIMAC_V2_LINE_PORT(port); 308 } 309 rv = BMACSEC_MAC_DUPLEX_SET(imacsec_des->unimac,port,duplex); 310 return rv; 311 } 312 313 /* 314 * Function: 315 * imacsec_plp_base_t_unimac_duplex_get 316 * Purpose: 317 * Get Duplex of the MAC 318 * Parameters: 319 * @param unit (input) BCM unit number 320 * @param port (input) - port number 321 * @param if_side (input) - Select the side 322 * 0 LINE_SIDE 323 * 1 SYSTEM_SIDE 324 * @param duplex - (OUT) 0 - Full Duplex 325 * 1 - Half Duplex 326 * Notes: 327 */ 328 int 329 imacsec_plp_base_t_unimac_duplex_get(int unit, soc_port_t port, int if_side, int *duplex) 330 { 331 int rv=0; 332 phy_ctrl_t *pc; 333 bcm_plp_base_t_sec_phy_access_t *imacsec_des; 334 EXT_PHY_INIT_CHECK(unit,port); 335 pc = EXT_PHY_SW_STATE(unit, port); 336 imacsec_des = IMACSEC_DES_PTR_GET(pc); 337 if(imacsec_des->unimac == NULL){ 338 return SOC_E_INTERNAL; 339 } 340 if(if_side==SYSTEM_SIDE){ 341 port = PHY_UNIMAC_V2_SWITCH_PORT(port); 342 } else{ 343 port = PHY_UNIMAC_V2_LINE_PORT(port); 344 } 345 rv = BMACSEC_MAC_DUPLEX_GET(imacsec_des->unimac,port,duplex); 346 return rv; 347 } 348 /* 349 * Function: 350 * imacsec_plp_base_t_unimac_pause_set 351 * Purpose: 352 * Set pause of the MAC 353 * Parameters: 354 * @param unit (input) BCM unit number 355 * @param port (input) - port number 356 * @param if_side (input) - Select the side 357 * 0 LINE_SIDE 358 * 1 SYSTEM_SIDE 359 * @param pause - 1 - Pause enable 360 * 0 - Pause disable 361 * Notes: 362 */ 363 int 364 imacsec_plp_base_t_unimac_pause_set(int unit, soc_port_t port, int if_side, int pause) 365 { 366 int rv=0; 367 phy_ctrl_t *pc; 368 bcm_plp_base_t_sec_phy_access_t *imacsec_des; 369 EXT_PHY_INIT_CHECK(unit,port); 370 pc = EXT_PHY_SW_STATE(unit, port); 371 imacsec_des = IMACSEC_DES_PTR_GET(pc); 372 if(imacsec_des->unimac == NULL){ 373 return SOC_E_INTERNAL; 374 } 375 if(if_side==SYSTEM_SIDE){ 376 port = PHY_UNIMAC_V2_SWITCH_PORT(port); 377 } else{ 378 port = PHY_UNIMAC_V2_LINE_PORT(port); 379 } 380 rv = BMACSEC_MAC_PAUSE_SET(imacsec_des->unimac,port,pause); 381 return rv; 382 } 383 /* 384 * Function: 385 * imacsec_plp_base_t_unimac_update_ipg 386 * Purpose: 387 * Set IPG of the MAC 388 * Parameters: 389 * @param unit (input) BCM unit number 390 * @param port (input) - port number 391 * @param if_side (input) - Select the side 392 * 0 LINE_SIDE 393 * 1 SYSTEM_SIDE 394 * @param ipg - IPG value 395 * Notes: 396 */ 397 int 398 imacsec_plp_base_t_unimac_update_ipg(int unit, soc_port_t port, int if_side, int ipg) 399 { 400 int rv=0; 401 phy_ctrl_t *pc; 402 bcm_plp_base_t_sec_phy_access_t *imacsec_des; 403 EXT_PHY_INIT_CHECK(unit,port); 404 pc = EXT_PHY_SW_STATE(unit, port); 405 imacsec_des = IMACSEC_DES_PTR_GET(pc); 406 if(imacsec_des->unimac == NULL){ 407 return SOC_E_INTERNAL; 408 } 409 if(if_side==SYSTEM_SIDE){ 410 port = PHY_UNIMAC_V2_SWITCH_PORT(port); 411 } else{ 412 port = PHY_UNIMAC_V2_LINE_PORT(port); 413 } 414 rv = BMACSEC_MAC_IPG_SET(imacsec_des->unimac,port,ipg); 415 return rv; 416 } 417 418 /* 419 * Function: 420 * imacsec_plp_base_t_unimac_max_frame_set 421 * Purpose: 422 * Set Max frame of the MAC 423 * 424 * Maximum Frame size shouldn;t be less 48 and cannot be greater than 425 * 0x3fff 426 * 427 * Parameters: 428 * @param unit (input) BCM unit number 429 * @param port (input) - port number 430 * @param if_side (input) - Select the side 431 * 0 LINE_SIDE 432 * 1 SYSTEM_SIDE 433 * @param max_frame - Max frame value 434 * Notes: 435 */ 436 int 437 imacsec_plp_base_t_unimac_max_frame_set(int unit, soc_port_t port, int if_side, uint32 max_frame) 438 { 439 int rv=0; 440 phy_ctrl_t *pc; 441 bcm_plp_base_t_sec_phy_access_t *imacsec_des; 442 EXT_PHY_INIT_CHECK(unit,port); 443 pc = EXT_PHY_SW_STATE(unit, port); 444 imacsec_des = IMACSEC_DES_PTR_GET(pc); 445 if(imacsec_des->unimac == NULL){ 446 return SOC_E_INTERNAL; 447 } 448 if(if_side==SYSTEM_SIDE){ 449 port = PHY_UNIMAC_V2_SWITCH_PORT(port); 450 } else{ 451 port = PHY_UNIMAC_V2_LINE_PORT(port); 452 } 453 rv = BMACSEC_MAC_MAX_FRAME_SET(imacsec_des->unimac,port,max_frame); 454 return rv; 455 } 456 /* 457 * Function: 458 * imacsec_plp_base_t_unimac_frame_len_check_enable 459 * Purpose: 460 * Enable the frame length check error mask in RSV vector 461 * to signal error to encryption block 462 * Parameters: 463 * 464 * @param unit (input) BCM unit number 465 * @param port (input) - port number 466 * @param if_side (input) - Select the side 467 * 0 LINE_SIDE 468 * 1 SYSTEM_SIDE 469 * enable - Enable the error mask 470 * 1 - enable 471 * 0 - disable 472 * Notes: 473 */ 474 int 475 imacsec_plp_base_t_unimac_frame_len_check_enable(int unit, soc_port_t port, 476 int if_side, int enable) 477 { 478 int rv=0; 479 phy_ctrl_t *pc; 480 bcm_plp_base_t_sec_phy_access_t *imacsec_des; 481 EXT_PHY_INIT_CHECK(unit,port); 482 pc = EXT_PHY_SW_STATE(unit, port); 483 imacsec_des = IMACSEC_DES_PTR_GET(pc); 484 if(imacsec_des->unimac == NULL){ 485 return SOC_E_INTERNAL; 486 } 487 if(if_side==SYSTEM_SIDE){ 488 port = PHY_UNIMAC_V2_SWITCH_PORT(port); 489 } else{ 490 port = PHY_UNIMAC_V2_LINE_PORT(port); 491 } 492 rv = BMACSEC_MAC_FRAME_LEN_CHECK_ENABLE(imacsec_des->unimac,port,enable); 493 return rv; 494 } 495 /* 496 * Function: 497 * imacsec_plp_base_t_unimac_max_frame_get 498 * Purpose: 499 * Get Max frame of the MAC 500 * Parameters: 501 * @param unit (input) BCM unit number 502 * @param port (input) - port number 503 * @param if_side (input) - Select the side 504 * 0 LINE_SIDE 505 * 1 SYSTEM_SIDE 506 * @param max_frame - (OUT) Max frame 507 * Notes: 508 */ 509 int 510 imacsec_plp_base_t_unimac_max_frame_get(int unit, soc_port_t port, int if_side, uint32 *max_frame) 511 { 512 int rv=0; 513 phy_ctrl_t *pc; 514 bcm_plp_base_t_sec_phy_access_t *imacsec_des; 515 EXT_PHY_INIT_CHECK(unit,port); 516 pc = EXT_PHY_SW_STATE(unit, port); 517 imacsec_des = IMACSEC_DES_PTR_GET(pc); 518 if(imacsec_des->unimac == NULL){ 519 return SOC_E_INTERNAL; 520 } 521 if(if_side==SYSTEM_SIDE){ 522 port = PHY_UNIMAC_V2_SWITCH_PORT(port); 523 } else{ 524 port = PHY_UNIMAC_V2_LINE_PORT(port); 525 } 526 rv = BMACSEC_MAC_MAX_FRAME_GET(imacsec_des->unimac,port,max_frame); 527 return rv; 528 } 529 /* 530 * Function: 531 * imacsec_plp_base_t_unimac_pause_frame_fwd_set 532 * Purpose: 533 * Enable/Disable Pause Frame Forward 534 * Parameters: 535 * @param unit (input) BCM unit number 536 * @param port (input) - port number 537 * @param if_side (input) - Select the side 538 * 0 LINE_SIDE 539 * 1 SYSTEM_SIDE 540 * @param pause_fwd - Pause forward 541 * 1 - Forward pause 542 * 0 - Consume PAUSE. 543 * Notes: 544 */ 545 int 546 imacsec_plp_base_t_unimac_pause_frame_fwd_set(int unit, soc_port_t port, int if_side, int pause_fwd) 547 { 548 int rv=0; 549 phy_ctrl_t *pc; 550 bcm_plp_base_t_sec_phy_access_t *imacsec_des; 551 EXT_PHY_INIT_CHECK(unit,port); 552 pc = EXT_PHY_SW_STATE(unit, port); 553 imacsec_des = IMACSEC_DES_PTR_GET(pc); 554 if(imacsec_des->unimac == NULL){ 555 return SOC_E_INTERNAL; 556 } 557 if(if_side==SYSTEM_SIDE){ 558 port = PHY_UNIMAC_V2_SWITCH_PORT(port); 559 } else{ 560 port = PHY_UNIMAC_V2_LINE_PORT(port); 561 } 562 rv = BMACSEC_MAC_PAUSE_FRAME_FWD_SET(imacsec_des->unimac,port,pause_fwd); 563 return rv; 564 } 565 /* 566 * Function: 567 * imacsec_plp_base_t_unimac_pause_frame_fwd_get 568 * Purpose: 569 * Get the status of Pause Frame Forward 570 * Parameters: 571 * @param unit (input) BCM unit number 572 * @param port (input) - port number 573 * @param if_side (input) - Select the side 574 * 0 LINE_SIDE 575 * 1 SYSTEM_SIDE 576 * @param pause_fwd - Pause forward 577 * 1 - Forward pause 578 * 0 - Consume PAUSE. 579 * Notes: 580 */ 581 int 582 imacsec_plp_base_t_unimac_pause_frame_fwd_get(int unit, soc_port_t port, int if_side, int *pause_fwd) 583 { 584 int rv=0; 585 phy_ctrl_t *pc; 586 bcm_plp_base_t_sec_phy_access_t *imacsec_des; 587 EXT_PHY_INIT_CHECK(unit,port); 588 pc = EXT_PHY_SW_STATE(unit, port); 589 imacsec_des = IMACSEC_DES_PTR_GET(pc); 590 if(imacsec_des->unimac == NULL){ 591 return SOC_E_INTERNAL; 592 } 593 if(if_side==SYSTEM_SIDE){ 594 port = PHY_UNIMAC_V2_SWITCH_PORT(port); 595 } else{ 596 port = PHY_UNIMAC_V2_LINE_PORT(port); 597 } 598 rv = BMACSEC_MAC_PAUSE_FRAME_FWD_GET(imacsec_des->unimac,port,pause_fwd); 599 return rv; 600 } 601 602 /* 603 * Function: 604 * imacsec_plp_base_t_unimac_rx_enable_set 605 * Purpose: 606 * Enable/Disable MAC RX 607 * Parameters: 608 * @param unit (input) BCM unit number 609 * @param port (input) - port number 610 * @param if_side (input) - Select the side 611 * 0 LINE_SIDE 612 * 1 SYSTEM_SIDE 613 614 * enable - Enable the Rx 615 * 1 - enable 616 * 0 - disable 617 * Notes: 618 */ 619 int 620 imacsec_plp_base_t_unimac_rx_enable_set(int unit, soc_port_t port, int if_side, int enable) 621 { 622 int rv=0; 623 phy_ctrl_t *pc; 624 bcm_plp_base_t_sec_phy_access_t *imacsec_des; 625 EXT_PHY_INIT_CHECK(unit,port); 626 pc = EXT_PHY_SW_STATE(unit, port); 627 imacsec_des = IMACSEC_DES_PTR_GET(pc); 628 if(imacsec_des->unimac == NULL){ 629 return SOC_E_INTERNAL; 630 } 631 if(if_side==SYSTEM_SIDE){ 632 port = PHY_UNIMAC_V2_SWITCH_PORT(port); 633 } else{ 634 port = PHY_UNIMAC_V2_LINE_PORT(port); 635 } 636 rv = BMACSEC_MAC_RX_ENABLE_SET(imacsec_des->unimac,port,enable); 637 return rv; 638 639 } 640 641 /* 642 * Function: 643 * imacsec_plp_base_t_unimac_tx_enable_set 644 * Purpose: 645 * Enable/Disable MAC TX 646 * Parameters: 647 * @param unit (input) BCM unit number 648 * @param port (input) - port number 649 * @param if_side (input) - Select the side 650 * 0 LINE_SIDE 651 * 1 SYSTEM_SIDE 652 653 * enable - Enable the Tx 654 * 1 - enable 655 * 0 - disable 656 * Notes: 657 */ 658 int 659 imacsec_plp_base_t_unimac_tx_enable_set(int unit, soc_port_t port, int if_side, int enable) 660 { 661 int rv=0; 662 phy_ctrl_t *pc; 663 bcm_plp_base_t_sec_phy_access_t *imacsec_des; 664 EXT_PHY_INIT_CHECK(unit,port); 665 pc = EXT_PHY_SW_STATE(unit, port); 666 imacsec_des = IMACSEC_DES_PTR_GET(pc); 667 if(imacsec_des->unimac == NULL){ 668 return SOC_E_INTERNAL; 669 } 670 if(if_side==SYSTEM_SIDE){ 671 port = PHY_UNIMAC_V2_SWITCH_PORT(port); 672 } else{ 673 port = PHY_UNIMAC_V2_LINE_PORT(port); 674 } 675 rv = BMACSEC_MAC_TX_ENABLE_SET(imacsec_des->unimac,port,enable); 676 return rv; 677 } 678 679 /* 680 * Function: 681 * imacsec_plp_base_t_unimac_tx_datapath_flush 682 * Purpose: 683 * TX-FIFO flush control enable 684 * Parameters: 685 * @param unit (input) BCM unit number 686 * @param port (input) - port number 687 * @param if_side (input) - Select the side 688 * 0 LINE_SIDE 689 * 1 SYSTEM_SIDE 690 * Notes: Before calling TX datapath flush user has to disable pause function 691 * once TX_FIFO is empty reenable the pause function 692 */ 693 int 694 imacsec_plp_base_t_unimac_tx_datapath_flush(int unit, soc_port_t port, int if_side, int enable) 695 { 696 int rv=0; 697 phy_ctrl_t *pc; 698 bcm_plp_base_t_sec_phy_access_t *imacsec_des; 699 EXT_PHY_INIT_CHECK(unit,port); 700 pc = EXT_PHY_SW_STATE(unit, port); 701 imacsec_des = IMACSEC_DES_PTR_GET(pc); 702 if(imacsec_des->unimac == NULL){ 703 return SOC_E_INTERNAL; 704 } 705 if(if_side==SYSTEM_SIDE){ 706 port = PHY_UNIMAC_V2_SWITCH_PORT(port); 707 } else{ 708 port = PHY_UNIMAC_V2_LINE_PORT(port); 709 } 710 rv = BMACSEC_MAC_TX_DATAPATH_FLUSH(imacsec_des->unimac, port, enable); 711 return rv; 712 } 713 714 /* 715 * Function: 716 * imacsec_plp_base_t_unimac_switch_side_set_params 717 * Purpose: 718 * To set Switch side speed, duplex and pause parameters 719 * Parameters: 720 * @param unit (input) BCM unit number 721 * @param port (input) - port number 722 * switch_side_policy - PHY_MAC_SWITCH_FIXED 723 * ( Switch side is in fixed mode, and the speed 724 * duplex and pause settings are provided by the 725 * caller ). 726 * - PHY_MAC_SWITCH_FOLLOWS_LINE 727 * ( Switch side follows line side operating 728 * parameters. Autoconfig mode ). 729 * - PHY_MAC_SWITCH_DUPLEX_GATEWAY 730 * ( half-duplex on Line-side MAC, and 731 * full-duplex on switch-side MAC ) 732 * speed - Speed to set 733 * 10 = 10Mbps 734 * 100 = 100Mbps 735 * 1000 = 1000Mbps 736 * duplex - Half Duplex = BMACSEC_HALF_DUPLEX 737 * - Full Duplex = BMACSEC_FULL_DUPLEX 738 * pause_enable - 1 = enables pause 739 * - 0 = disables pause. 740 * Returns: 741 */ 742 int 743 imacsec_plp_base_t_unimac_switch_side_set_params(int unit, soc_port_t port, 744 phy_mac_policy_t switch_side_policy, 745 int speed, int duplex, int pause_enable) 746 { 747 int rv=0; 748 rv = phy_unimac_switch_side_set_params(unit, port, 749 switch_side_policy, 750 speed, duplex,pause_enable); 751 return rv; 752 } 753 754 #endif /* INCLUDE_PLP_IMACSEC */