1 /* 2 * Copyright (C) 2013 Realtek Semiconductor Corp. 3 * All Rights Reserved. 4 * 5 * This program is the proprietary software of Realtek Semiconductor 6 * Corporation and/or its licensors, and only be used, duplicated, 7 * modified or distributed under the authorized license from Realtek. 8 * 9 * ANY USE OF THE SOFTWARE OTHER THAN AS AUTHORIZED UNDER 10 * THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED. 11 * 12 * Purpose : RTL8367/RTL8367C switch high-level API 13 * 14 * Feature : The file includes port module high-layer API defination 15 * 16 */ 17 18#ifndef __RTK_API_PORT_H__ 19#define __RTK_API_PORT_H__ 20 21/* 22 * Data Type Declaration 23 */ 24 25#define PHY_CONTROL_REG 0 26#define PHY_STATUS_REG 1 27#define PHY_AN_ADVERTISEMENT_REG 4 28#define PHY_AN_LINKPARTNER_REG 5 29#define PHY_1000_BASET_CONTROL_REG 9 30#define PHY_1000_BASET_STATUS_REG 10 31#define PHY_RESOLVED_REG 26 32 33#define RTK_EFID_MAX 0x7 34 35#define RTK_FIBER_FORCE_1000M 3 36#define RTK_FIBER_FORCE_100M 5 37#define RTK_FIBER_FORCE_100M1000M 7 38 39#define RTK_INDRECT_ACCESS_CRTL 0x1f00 40#define RTK_INDRECT_ACCESS_STATUS 0x1f01 41#define RTK_INDRECT_ACCESS_ADDRESS 0x1f02 42#define RTK_INDRECT_ACCESS_WRITE_DATA 0x1f03 43#define RTK_INDRECT_ACCESS_READ_DATA 0x1f04 44#define RTK_INDRECT_ACCESS_DELAY 0x1f80 45#define RTK_INDRECT_ACCESS_BURST 0x1f81 46#define RTK_RW_MASK 0x2 47#define RTK_CMD_MASK 0x1 48#define RTK_PHY_BUSY_OFFSET 2 49 50 51typedef enum rtk_mode_ext_e 52{ 53 MODE_EXT_DISABLE = 0, 54 MODE_EXT_RGMII, 55 MODE_EXT_MII_MAC, 56 MODE_EXT_MII_PHY, 57 MODE_EXT_TMII_MAC, 58 MODE_EXT_TMII_PHY, 59 MODE_EXT_GMII, 60 MODE_EXT_RMII_MAC, 61 MODE_EXT_RMII_PHY, 62 MODE_EXT_SGMII, 63 MODE_EXT_HSGMII, 64 MODE_EXT_END 65} rtk_mode_ext_t; 66 67typedef enum rtk_port_duplex_e 68{ 69 PORT_HALF_DUPLEX = 0, 70 PORT_FULL_DUPLEX, 71 PORT_DUPLEX_END 72} rtk_port_duplex_t; 73 74typedef enum rtk_port_linkStatus_e 75{ 76 PORT_LINKDOWN = 0, 77 PORT_LINKUP, 78 PORT_LINKSTATUS_END 79} rtk_port_linkStatus_t; 80 81typedef struct rtk_port_mac_ability_s 82{ 83 rtk_uint32 forcemode; 84 rtk_uint32 speed; 85 rtk_uint32 duplex; 86 rtk_uint32 link; 87 rtk_uint32 nway; 88 rtk_uint32 txpause; 89 rtk_uint32 rxpause; 90}rtk_port_mac_ability_t; 91 92typedef struct rtk_port_phy_ability_s 93{ 94 rtk_uint32 AutoNegotiation; /*PHY register 0.12 setting for auto-negotiation process*/ 95 rtk_uint32 Half_10; /*PHY register 4.5 setting for 10BASE-TX half duplex capable*/ 96 rtk_uint32 Full_10; /*PHY register 4.6 setting for 10BASE-TX full duplex capable*/ 97 rtk_uint32 Half_100; /*PHY register 4.7 setting for 100BASE-TX half duplex capable*/ 98 rtk_uint32 Full_100; /*PHY register 4.8 setting for 100BASE-TX full duplex capable*/ 99 rtk_uint32 Full_1000; /*PHY register 9.9 setting for 1000BASE-T full duplex capable*/ 100 rtk_uint32 FC; /*PHY register 4.10 setting for flow control capability*/ 101 rtk_uint32 AsyFC; /*PHY register 4.11 setting for asymmetric flow control capability*/ 102} rtk_port_phy_ability_t; 103 104typedef rtk_uint32 rtk_port_phy_data_t; /* phy page */ 105 106typedef enum rtk_port_phy_mdix_mode_e 107{ 108 PHY_AUTO_CROSSOVER_MODE= 0, 109 PHY_FORCE_MDI_MODE, 110 PHY_FORCE_MDIX_MODE, 111 PHY_FORCE_MODE_END 112} rtk_port_phy_mdix_mode_t; 113 114typedef enum rtk_port_phy_mdix_status_e 115{ 116 PHY_STATUS_AUTO_MDI_MODE= 0, 117 PHY_STATUS_AUTO_MDIX_MODE, 118 PHY_STATUS_FORCE_MDI_MODE, 119 PHY_STATUS_FORCE_MDIX_MODE, 120 PHY_STATUS_FORCE_MODE_END 121} rtk_port_phy_mdix_status_t; 122 123typedef rtk_uint32 rtk_port_phy_page_t; /* phy page */ 124 125typedef enum rtk_port_phy_reg_e 126{ 127 PHY_REG_CONTROL = 0, 128 PHY_REG_STATUS, 129 PHY_REG_IDENTIFIER_1, 130 PHY_REG_IDENTIFIER_2, 131 PHY_REG_AN_ADVERTISEMENT, 132 PHY_REG_AN_LINKPARTNER, 133 PHY_REG_1000_BASET_CONTROL = 9, 134 PHY_REG_1000_BASET_STATUS, 135 PHY_REG_END = 32 136} rtk_port_phy_reg_t; 137 138typedef enum rtk_port_phy_test_mode_e 139{ 140 PHY_TEST_MODE_NORMAL= 0, 141 PHY_TEST_MODE_1, 142 PHY_TEST_MODE_2, 143 PHY_TEST_MODE_3, 144 PHY_TEST_MODE_4, 145 PHY_TEST_MODE_END 146} rtk_port_phy_test_mode_t; 147 148typedef enum rtk_port_speed_e 149{ 150 PORT_SPEED_10M = 0, 151 PORT_SPEED_100M, 152 PORT_SPEED_1000M, 153 PORT_SPEED_500M, 154 PORT_SPEED_2500M, 155 PORT_SPEED_END 156} rtk_port_speed_t; 157 158typedef enum rtk_port_media_e 159{ 160 PORT_MEDIA_COPPER = 0, 161 PORT_MEDIA_FIBER, 162 PORT_MEDIA_END 163}rtk_port_media_t; 164 165typedef struct rtk_rtctResult_s 166{ 167 rtk_port_speed_t linkType; 168 union 169 { 170 struct fe_result_s 171 { 172 rtk_uint32 isRxShort; 173 rtk_uint32 isTxShort; 174 rtk_uint32 isRxOpen; 175 rtk_uint32 isTxOpen; 176 rtk_uint32 isRxMismatch; 177 rtk_uint32 isTxMismatch; 178 rtk_uint32 isRxLinedriver; 179 rtk_uint32 isTxLinedriver; 180 rtk_uint32 rxLen; 181 rtk_uint32 txLen; 182 } fe_result; 183 184 struct ge_result_s 185 { 186 rtk_uint32 channelAShort; 187 rtk_uint32 channelBShort; 188 rtk_uint32 channelCShort; 189 rtk_uint32 channelDShort; 190 191 rtk_uint32 channelAOpen; 192 rtk_uint32 channelBOpen; 193 rtk_uint32 channelCOpen; 194 rtk_uint32 channelDOpen; 195 196 rtk_uint32 channelAMismatch; 197 rtk_uint32 channelBMismatch; 198 rtk_uint32 channelCMismatch; 199 rtk_uint32 channelDMismatch; 200 201 rtk_uint32 channelALinedriver; 202 rtk_uint32 channelBLinedriver; 203 rtk_uint32 channelCLinedriver; 204 rtk_uint32 channelDLinedriver; 205 206 rtk_uint32 channelALen; 207 rtk_uint32 channelBLen; 208 rtk_uint32 channelCLen; 209 rtk_uint32 channelDLen; 210 } ge_result; 211 }result; 212} rtk_rtctResult_t; 213 214/* Function Name: 215 * rtk_port_phyAutoNegoAbility_set 216 * Description: 217 * Set ethernet PHY auto-negotiation desired ability. 218 * Input: 219 * port - port id. 220 * pAbility - Ability structure 221 * Output: 222 * None 223 * Return: 224 * RT_ERR_OK - OK 225 * RT_ERR_FAILED - Failed 226 * RT_ERR_SMI - SMI access error 227 * RT_ERR_PORT_ID - Invalid port number. 228 * RT_ERR_PHY_REG_ID - Invalid PHY address 229 * RT_ERR_INPUT - Invalid input parameters. 230 * RT_ERR_BUSYWAIT_TIMEOUT - PHY access busy 231 * Note: 232 * If Full_1000 bit is set to 1, the AutoNegotiation will be automatic set to 1. While both AutoNegotiation and Full_1000 are set to 0, the PHY speed and duplex selection will 233 * be set as following 100F > 100H > 10F > 10H priority sequence. 234 */ 235extern rtk_api_ret_t rtk_port_phyAutoNegoAbility_set(rtk_port_t port, rtk_port_phy_ability_t *pAbility); 236 237/* Function Name: 238 * rtk_port_phyAutoNegoAbility_get 239 * Description: 240 * Get PHY ability through PHY registers. 241 * Input: 242 * port - Port id. 243 * Output: 244 * pAbility - Ability structure 245 * Return: 246 * RT_ERR_OK - OK 247 * RT_ERR_FAILED - Failed 248 * RT_ERR_SMI - SMI access error 249 * RT_ERR_PORT_ID - Invalid port number. 250 * RT_ERR_PHY_REG_ID - Invalid PHY address 251 * RT_ERR_INPUT - Invalid input parameters. 252 * RT_ERR_BUSYWAIT_TIMEOUT - PHY access busy 253 * Note: 254 * Get the capablity of specified PHY. 255 */ 256extern rtk_api_ret_t rtk_port_phyAutoNegoAbility_get(rtk_port_t port, rtk_port_phy_ability_t *pAbility); 257 258/* Function Name: 259 * rtk_port_phyForceModeAbility_set 260 * Description: 261 * Set the port speed/duplex mode/pause/asy_pause in the PHY force mode. 262 * Input: 263 * port - port id. 264 * pAbility - Ability structure 265 * Output: 266 * None 267 * Return: 268 * RT_ERR_OK - OK 269 * RT_ERR_FAILED - Failed 270 * RT_ERR_SMI - SMI access error 271 * RT_ERR_PORT_ID - Invalid port number. 272 * RT_ERR_PHY_REG_ID - Invalid PHY address 273 * RT_ERR_INPUT - Invalid input parameters. 274 * RT_ERR_BUSYWAIT_TIMEOUT - PHY access busy 275 * Note: 276 * If Full_1000 bit is set to 1, the AutoNegotiation will be automatic set to 1. While both AutoNegotiation and Full_1000 are set to 0, the PHY speed and duplex selection will 277 * be set as following 100F > 100H > 10F > 10H priority sequence. 278 */ 279extern rtk_api_ret_t rtk_port_phyForceModeAbility_set(rtk_port_t port, rtk_port_phy_ability_t *pAbility); 280 281/* Function Name: 282 * rtk_port_phyForceModeAbility_get 283 * Description: 284 * Get PHY ability through PHY registers. 285 * Input: 286 * port - Port id. 287 * Output: 288 * pAbility - Ability structure 289 * Return: 290 * RT_ERR_OK - OK 291 * RT_ERR_FAILED - Failed 292 * RT_ERR_SMI - SMI access error 293 * RT_ERR_PORT_ID - Invalid port number. 294 * RT_ERR_PHY_REG_ID - Invalid PHY address 295 * RT_ERR_INPUT - Invalid input parameters. 296 * RT_ERR_BUSYWAIT_TIMEOUT - PHY access busy 297 * Note: 298 * Get the capablity of specified PHY. 299 */ 300extern rtk_api_ret_t rtk_port_phyForceModeAbility_get(rtk_port_t port, rtk_port_phy_ability_t *pAbility); 301 302/* Function Name: 303 * rtk_port_phyStatus_get 304 * Description: 305 * Get ethernet PHY linking status 306 * Input: 307 * port - Port id. 308 * Output: 309 * linkStatus - PHY link status 310 * speed - PHY link speed 311 * duplex - PHY duplex mode 312 * Return: 313 * RT_ERR_OK - OK 314 * RT_ERR_FAILED - Failed 315 * RT_ERR_SMI - SMI access error 316 * RT_ERR_PORT_ID - Invalid port number. 317 * RT_ERR_PHY_REG_ID - Invalid PHY address 318 * RT_ERR_INPUT - Invalid input parameters. 319 * RT_ERR_BUSYWAIT_TIMEOUT - PHY access busy 320 * Note: 321 * API will return auto negotiation status of phy. 322 */ 323extern rtk_api_ret_t rtk_port_phyStatus_get(rtk_port_t port, rtk_port_linkStatus_t *pLinkStatus, rtk_port_speed_t *pSpeed, rtk_port_duplex_t *pDuplex); 324 325/* Function Name: 326 * rtk_port_macForceLink_set 327 * Description: 328 * Set port force linking configuration. 329 * Input: 330 * port - port id. 331 * pPortability - port ability configuration 332 * Output: 333 * None 334 * Return: 335 * RT_ERR_OK - OK 336 * RT_ERR_FAILED - Failed 337 * RT_ERR_SMI - SMI access error 338 * RT_ERR_PORT_ID - Invalid port number. 339 * Note: 340 * This API can set Port/MAC force mode properties. 341 */ 342extern rtk_api_ret_t rtk_port_macForceLink_set(rtk_port_t port, rtk_port_mac_ability_t *pPortability); 343 344/* Function Name: 345 * rtk_port_macForceLink_get 346 * Description: 347 * Get port force linking configuration. 348 * Input: 349 * port - Port id. 350 * Output: 351 * pPortability - port ability configuration 352 * Return: 353 * RT_ERR_OK - OK 354 * RT_ERR_FAILED - Failed 355 * RT_ERR_SMI - SMI access error 356 * RT_ERR_PORT_ID - Invalid port number. 357 * RT_ERR_INPUT - Invalid input parameters. 358 * Note: 359 * This API can get Port/MAC force mode properties. 360 */ 361extern rtk_api_ret_t rtk_port_macForceLink_get(rtk_port_t port, rtk_port_mac_ability_t *pPortability); 362 363/* Function Name: 364 * rtk_port_macForceLinkExt_set 365 * Description: 366 * Set external interface force linking configuration. 367 * Input: 368 * port - external port ID 369 * mode - external interface mode 370 * pPortability - port ability configuration 371 * Output: 372 * None 373 * Return: 374 * RT_ERR_OK - OK 375 * RT_ERR_FAILED - Failed 376 * RT_ERR_SMI - SMI access error 377 * RT_ERR_INPUT - Invalid input parameters. 378 * Note: 379 * This API can set external interface force mode properties. 380 * The external interface can be set to: 381 * - MODE_EXT_DISABLE, 382 * - MODE_EXT_RGMII, 383 * - MODE_EXT_MII_MAC, 384 * - MODE_EXT_MII_PHY, 385 * - MODE_EXT_TMII_MAC, 386 * - MODE_EXT_TMII_PHY, 387 * - MODE_EXT_GMII, 388 * - MODE_EXT_RMII_MAC, 389 * - MODE_EXT_RMII_PHY, 390 * - MODE_EXT_SGMII, 391 * - MODE_EXT_HSGMII 392 */ 393extern rtk_api_ret_t rtk_port_macForceLinkExt_set(rtk_port_t port, rtk_mode_ext_t mode, rtk_port_mac_ability_t *pPortability); 394 395/* Function Name: 396 * rtk_port_macForceLinkExt_get 397 * Description: 398 * Set external interface force linking configuration. 399 * Input: 400 * port - external port ID 401 * Output: 402 * pMode - external interface mode 403 * pPortability - port ability configuration 404 * Return: 405 * RT_ERR_OK - OK 406 * RT_ERR_FAILED - Failed 407 * RT_ERR_SMI - SMI access error 408 * RT_ERR_INPUT - Invalid input parameters. 409 * Note: 410 * This API can get external interface force mode properties. 411 */ 412extern rtk_api_ret_t rtk_port_macForceLinkExt_get(rtk_port_t port, rtk_mode_ext_t *pMode, rtk_port_mac_ability_t *pPortability); 413 414/* Function Name: 415 * rtk_port_macStatus_get 416 * Description: 417 * Get port link status. 418 * Input: 419 * port - Port id. 420 * Output: 421 * pPortstatus - port ability configuration 422 * Return: 423 * RT_ERR_OK - OK 424 * RT_ERR_FAILED - Failed 425 * RT_ERR_SMI - SMI access error 426 * RT_ERR_PORT_ID - Invalid port number. 427 * Note: 428 * This API can get Port/PHY properties. 429 */ 430extern rtk_api_ret_t rtk_port_macStatus_get(rtk_port_t port, rtk_port_mac_ability_t *pPortstatus); 431 432/* Function Name: 433 * rtk_port_macLocalLoopbackEnable_set 434 * Description: 435 * Set Port Local Loopback. (Redirect TX to RX.) 436 * Input: 437 * port - Port id. 438 * enable - Loopback state, 0:disable, 1:enable 439 * Output: 440 * None. 441 * Return: 442 * RT_ERR_OK - OK 443 * RT_ERR_FAILED - Failed 444 * RT_ERR_SMI - SMI access error 445 * RT_ERR_PORT_ID - Invalid port number. 446 * Note: 447 * This API can enable/disable Local loopback in MAC. 448 * For UTP port, This API will also enable the digital 449 * loopback bit in PHY register for sync of speed between 450 * PHY and MAC. For EXT port, users need to force the 451 * link state by themself. 452 */ 453extern rtk_api_ret_t rtk_port_macLocalLoopbackEnable_set(rtk_port_t port, rtk_enable_t enable); 454 455/* Function Name: 456 * rtk_port_macLocalLoopbackEnable_get 457 * Description: 458 * Get Port Local Loopback. (Redirect TX to RX.) 459 * Input: 460 * port - Port id. 461 * Output: 462 * pEnable - Loopback state, 0:disable, 1:enable 463 * Return: 464 * RT_ERR_OK - OK 465 * RT_ERR_FAILED - Failed 466 * RT_ERR_SMI - SMI access error 467 * RT_ERR_PORT_ID - Invalid port number. 468 * Note: 469 * None. 470 */ 471extern rtk_api_ret_t rtk_port_macLocalLoopbackEnable_get(rtk_port_t port, rtk_enable_t *pEnable); 472 473/* Function Name: 474 * rtk_port_phyReg_set 475 * Description: 476 * Set PHY register data of the specific port. 477 * Input: 478 * port - port id. 479 * reg - Register id 480 * regData - Register data 481 * Output: 482 * None 483 * Return: 484 * RT_ERR_OK - OK 485 * RT_ERR_FAILED - Failed 486 * RT_ERR_SMI - SMI access error 487 * RT_ERR_PORT_ID - Invalid port number. 488 * RT_ERR_PHY_REG_ID - Invalid PHY address 489 * RT_ERR_BUSYWAIT_TIMEOUT - PHY access busy 490 * Note: 491 * This API can set PHY register data of the specific port. 492 */ 493extern rtk_api_ret_t rtk_port_phyReg_set(rtk_port_t port, rtk_port_phy_reg_t reg, rtk_port_phy_data_t value); 494 495/* Function Name: 496 * rtk_port_phyReg_get 497 * Description: 498 * Get PHY register data of the specific port. 499 * Input: 500 * port - Port id. 501 * reg - Register id 502 * Output: 503 * pData - Register data 504 * Return: 505 * RT_ERR_OK - OK 506 * RT_ERR_FAILED - Failed 507 * RT_ERR_SMI - SMI access error 508 * RT_ERR_PORT_ID - Invalid port number. 509 * RT_ERR_PHY_REG_ID - Invalid PHY address 510 * RT_ERR_BUSYWAIT_TIMEOUT - PHY access busy 511 * Note: 512 * This API can get PHY register data of the specific port. 513 */ 514extern rtk_api_ret_t rtk_port_phyReg_get(rtk_port_t port, rtk_port_phy_reg_t reg, rtk_port_phy_data_t *pData); 515 516/* Function Name: 517 * rtk_port_backpressureEnable_set 518 * Description: 519 * Set the half duplex backpressure enable status of the specific port. 520 * Input: 521 * port - port id. 522 * enable - Back pressure status. 523 * Output: 524 * None 525 * Return: 526 * RT_ERR_OK - OK 527 * RT_ERR_FAILED - Failed 528 * RT_ERR_SMI - SMI access error 529 * RT_ERR_PORT_ID - Invalid port number. 530 * RT_ERR_ENABLE - Invalid enable input. 531 * Note: 532 * This API can set the half duplex backpressure enable status of the specific port. 533 * The half duplex backpressure enable status of the port is as following: 534 * - DISABLE 535 * - ENABLE 536 */ 537extern rtk_api_ret_t rtk_port_backpressureEnable_set(rtk_port_t port, rtk_enable_t enable); 538 539/* Function Name: 540 * rtk_port_backpressureEnable_get 541 * Description: 542 * Get the half duplex backpressure enable status of the specific port. 543 * Input: 544 * port - Port id. 545 * Output: 546 * pEnable - Back pressure status. 547 * Return: 548 * RT_ERR_OK - OK 549 * RT_ERR_FAILED - Failed 550 * RT_ERR_SMI - SMI access error 551 * RT_ERR_PORT_ID - Invalid port number. 552 * Note: 553 * This API can get the half duplex backpressure enable status of the specific port. 554 * The half duplex backpressure enable status of the port is as following: 555 * - DISABLE 556 * - ENABLE 557 */ 558extern rtk_api_ret_t rtk_port_backpressureEnable_get(rtk_port_t port, rtk_enable_t *pEnable); 559 560/* Function Name: 561 * rtk_port_adminEnable_set 562 * Description: 563 * Set port admin configuration of the specific port. 564 * Input: 565 * port - port id. 566 * enable - Back pressure status. 567 * Output: 568 * None 569 * Return: 570 * RT_ERR_OK - OK 571 * RT_ERR_FAILED - Failed 572 * RT_ERR_SMI - SMI access error 573 * RT_ERR_PORT_ID - Invalid port number. 574 * RT_ERR_ENABLE - Invalid enable input. 575 * Note: 576 * This API can set port admin configuration of the specific port. 577 * The port admin configuration of the port is as following: 578 * - DISABLE 579 * - ENABLE 580 */ 581extern rtk_api_ret_t rtk_port_adminEnable_set(rtk_port_t port, rtk_enable_t enable); 582 583/* Function Name: 584 * rtk_port_adminEnable_get 585 * Description: 586 * Get port admin configurationof the specific port. 587 * Input: 588 * port - Port id. 589 * Output: 590 * pEnable - Back pressure status. 591 * Return: 592 * RT_ERR_OK - OK 593 * RT_ERR_FAILED - Failed 594 * RT_ERR_SMI - SMI access error 595 * RT_ERR_PORT_ID - Invalid port number. 596 * Note: 597 * This API can get port admin configuration of the specific port. 598 * The port admin configuration of the port is as following: 599 * - DISABLE 600 * - ENABLE 601 */ 602extern rtk_api_ret_t rtk_port_adminEnable_get(rtk_port_t port, rtk_enable_t *pEnable); 603 604/* Function Name: 605 * rtk_port_isolation_set 606 * Description: 607 * Set permitted port isolation portmask 608 * Input: 609 * port - port id. 610 * pPortmask - Permit port mask 611 * Output: 612 * None 613 * Return: 614 * RT_ERR_OK - OK 615 * RT_ERR_FAILED - Failed 616 * RT_ERR_SMI - SMI access error 617 * RT_ERR_PORT_ID - Invalid port number. 618 * RT_ERR_PORT_MASK - Invalid portmask. 619 * Note: 620 * This API set the port mask that a port can trasmit packet to of each port 621 * A port can only transmit packet to ports included in permitted portmask 622 */ 623extern rtk_api_ret_t rtk_port_isolation_set(rtk_port_t port, rtk_portmask_t *pPortmask); 624 625/* Function Name: 626 * rtk_port_isolation_get 627 * Description: 628 * Get permitted port isolation portmask 629 * Input: 630 * port - Port id. 631 * Output: 632 * pPortmask - Permit port mask 633 * Return: 634 * RT_ERR_OK - OK 635 * RT_ERR_FAILED - Failed 636 * RT_ERR_SMI - SMI access error 637 * RT_ERR_PORT_ID - Invalid port number. 638 * Note: 639 * This API get the port mask that a port can trasmit packet to of each port 640 * A port can only transmit packet to ports included in permitted portmask 641 */ 642extern rtk_api_ret_t rtk_port_isolation_get(rtk_port_t port, rtk_portmask_t *pPortmask); 643 644/* Function Name: 645 * rtk_port_rgmiiDelayExt_set 646 * Description: 647 * Set RGMII interface delay value for TX and RX. 648 * Input: 649 * txDelay - TX delay value, 1 for delay 2ns and 0 for no-delay 650 * rxDelay - RX delay value, 0~7 for delay setup. 651 * Output: 652 * None 653 * Return: 654 * RT_ERR_OK - OK 655 * RT_ERR_FAILED - Failed 656 * RT_ERR_SMI - SMI access error 657 * RT_ERR_INPUT - Invalid input parameters. 658 * Note: 659 * This API can set external interface 2 RGMII delay. 660 * In TX delay, there are 2 selection: no-delay and 2ns delay. 661 * In RX dekay, there are 8 steps for delay tunning. 0 for no-delay, and 7 for maximum delay. 662 */ 663extern rtk_api_ret_t rtk_port_rgmiiDelayExt_set(rtk_port_t port, rtk_data_t txDelay, rtk_data_t rxDelay); 664 665/* Function Name: 666 * rtk_port_rgmiiDelayExt_get 667 * Description: 668 * Get RGMII interface delay value for TX and RX. 669 * Input: 670 * None 671 * Output: 672 * pTxDelay - TX delay value 673 * pRxDelay - RX delay value 674 * Return: 675 * RT_ERR_OK - OK 676 * RT_ERR_FAILED - Failed 677 * RT_ERR_SMI - SMI access error 678 * RT_ERR_INPUT - Invalid input parameters. 679 * Note: 680 * This API can set external interface 2 RGMII delay. 681 * In TX delay, there are 2 selection: no-delay and 2ns delay. 682 * In RX dekay, there are 8 steps for delay tunning. 0 for n0-delay, and 7 for maximum delay. 683 */ 684extern rtk_api_ret_t rtk_port_rgmiiDelayExt_get(rtk_port_t port, rtk_data_t *pTxDelay, rtk_data_t *pRxDelay); 685 686/* Function Name: 687 * rtk_port_phyEnableAll_set 688 * Description: 689 * Set all PHY enable status. 690 * Input: 691 * enable - PHY Enable State. 692 * Output: 693 * None 694 * Return: 695 * RT_ERR_OK - OK 696 * RT_ERR_FAILED - Failed 697 * RT_ERR_SMI - SMI access error 698 * RT_ERR_ENABLE - Invalid enable input. 699 * Note: 700 * This API can set all PHY status. 701 * The configuration of all PHY is as following: 702 * - DISABLE 703 * - ENABLE 704 */ 705extern rtk_api_ret_t rtk_port_phyEnableAll_set(rtk_enable_t enable); 706 707/* Function Name: 708 * rtk_port_phyEnableAll_get 709 * Description: 710 * Get all PHY enable status. 711 * Input: 712 * None 713 * Output: 714 * pEnable - PHY Enable State. 715 * Return: 716 * RT_ERR_OK - OK 717 * RT_ERR_FAILED - Failed 718 * RT_ERR_SMI - SMI access error 719 * Note: 720 * This API can set all PHY status. 721 * The configuration of all PHY is as following: 722 * - DISABLE 723 * - ENABLE 724 */ 725extern rtk_api_ret_t rtk_port_phyEnableAll_get(rtk_enable_t *pEnable); 726 727/* Function Name: 728 * rtk_port_efid_set 729 * Description: 730 * Set port-based enhanced filtering database 731 * Input: 732 * port - Port id. 733 * efid - Specified enhanced filtering database. 734 * Output: 735 * None 736 * Return: 737 * RT_ERR_OK - OK 738 * RT_ERR_FAILED - Failed 739 * RT_ERR_SMI - SMI access error 740 * RT_ERR_L2_FID - Invalid fid. 741 * RT_ERR_INPUT - Invalid input parameter. 742 * RT_ERR_PORT_ID - Invalid port ID. 743 * Note: 744 * The API can set port-based enhanced filtering database. 745 */ 746extern rtk_api_ret_t rtk_port_efid_set(rtk_port_t port, rtk_data_t efid); 747 748/* Function Name: 749 * rtk_port_efid_get 750 * Description: 751 * Get port-based enhanced filtering database 752 * Input: 753 * port - Port id. 754 * Output: 755 * pEfid - Specified enhanced filtering database. 756 * Return: 757 * RT_ERR_OK - OK 758 * RT_ERR_FAILED - Failed 759 * RT_ERR_SMI - SMI access error 760 * RT_ERR_INPUT - Invalid input parameters. 761 * RT_ERR_PORT_ID - Invalid port ID. 762 * Note: 763 * The API can get port-based enhanced filtering database status. 764 */ 765extern rtk_api_ret_t rtk_port_efid_get(rtk_port_t port, rtk_data_t *pEfid); 766 767/* Function Name: 768 * rtk_port_phyComboPortMedia_set 769 * Description: 770 * Set Combo port media type 771 * Input: 772 * port - Port id. (Should be Port 4) 773 * media - Media (COPPER or FIBER) 774 * Output: 775 * None. 776 * Return: 777 * RT_ERR_OK - OK 778 * RT_ERR_FAILED - Failed 779 * RT_ERR_SMI - SMI access error 780 * RT_ERR_INPUT - Invalid input parameters. 781 * RT_ERR_PORT_ID - Invalid port ID. 782 * Note: 783 * The API can Set Combo port media type. 784 */ 785extern rtk_api_ret_t rtk_port_phyComboPortMedia_set(rtk_port_t port, rtk_port_media_t media); 786 787/* Function Name: 788 * rtk_port_phyComboPortMedia_get 789 * Description: 790 * Get Combo port media type 791 * Input: 792 * port - Port id. (Should be Port 4) 793 * Output: 794 * pMedia - Media (COPPER or FIBER) 795 * Return: 796 * RT_ERR_OK - OK 797 * RT_ERR_FAILED - Failed 798 * RT_ERR_SMI - SMI access error 799 * RT_ERR_INPUT - Invalid input parameters. 800 * RT_ERR_PORT_ID - Invalid port ID. 801 * Note: 802 * The API can Set Combo port media type. 803 */ 804extern rtk_api_ret_t rtk_port_phyComboPortMedia_get(rtk_port_t port, rtk_port_media_t *pMedia); 805 806/* Function Name: 807 * rtk_port_rtctEnable_set 808 * Description: 809 * Enable RTCT test 810 * Input: 811 * pPortmask - Port mask of RTCT enabled port 812 * Output: 813 * None 814 * Return: 815 * RT_ERR_OK - OK 816 * RT_ERR_FAILED - Failed 817 * RT_ERR_SMI - SMI access error 818 * RT_ERR_PORT_MASK - Invalid port mask. 819 * Note: 820 * The API can enable RTCT Test 821 */ 822extern rtk_api_ret_t rtk_port_rtctEnable_set(rtk_portmask_t *pPortmask); 823 824/* Function Name: 825 * rtk_port_rtctResult_get 826 * Description: 827 * Get the result of RTCT test 828 * Input: 829 * port - Port ID 830 * Output: 831 * pRtctResult - The result of RTCT result 832 * Return: 833 * RT_ERR_OK - OK 834 * RT_ERR_FAILED - Failed 835 * RT_ERR_SMI - SMI access error 836 * RT_ERR_PORT_ID - Invalid port ID. 837 * RT_ERR_PHY_RTCT_NOT_FINISH - Testing does not finish. 838 * Note: 839 * The API can get RTCT test result. 840 * RTCT test may takes 4.8 seconds to finish its test at most. 841 * Thus, if this API return RT_ERR_PHY_RTCT_NOT_FINISH or 842 * other error code, the result can not be referenced and 843 * user should call this API again until this API returns 844 * a RT_ERR_OK. 845 * The result is stored at pRtctResult->ge_result 846 * pRtctResult->linkType is unused. 847 * The unit of channel length is 2.5cm. Ex. 300 means 300 * 2.5 = 750cm = 7.5M 848 */ 849extern rtk_api_ret_t rtk_port_rtctResult_get(rtk_port_t port, rtk_rtctResult_t *pRtctResult); 850 851 852#endif /* __RTK_API_PORT_H__ */ 853 854 855 856