Ethernet PHY configuration
Overview
// global functions te_errno tapi_cfg_phy_autoneg_get(const char* ta, const char* if_name, int* state); te_errno tapi_cfg_phy_autoneg_set(const char* ta, const char* if_name, int state); te_errno tapi_cfg_phy_duplex_oper_get(const char* ta, const char* if_name, int* state); te_errno tapi_cfg_phy_duplex_admin_get(const char* ta, const char* if_name, int* state); te_errno tapi_cfg_phy_duplex_admin_set(const char* ta, const char* if_name, int state); te_errno tapi_cfg_phy_port_get(const char* ta, const char* if_name, enum te_phy_port* state); te_errno tapi_cfg_phy_speed_oper_get(const char* ta, const char* if_name, int* speed); te_errno tapi_cfg_phy_speed_admin_get(const char* ta, const char* if_name, int* speed); te_errno tapi_cfg_phy_speed_admin_set(const char* ta, const char* if_name, int speed); te_errno tapi_cfg_phy_mode_oper_get(const char* ta, const char* if_name, int* speed, int* duplex); te_errno tapi_cfg_phy_mode_admin_get(const char* ta, const char* if_name, int* speed, int* duplex); te_errno tapi_cfg_phy_mode_admin_set(const char* ta, const char* if_name, int speed, int duplex); te_errno tapi_cfg_phy_state_get(const char* ta, const char* if_name, int* state); te_errno tapi_cfg_phy_state_wait_up(const char* ta, const char* if_name, int timeout); te_errno tapi_cfg_phy_is_mode_advertised(const char* ta, const char* if_name, int speed, int duplex, bool* state); te_errno tapi_cfg_phy_advertise_mode(const char* ta, const char* if_name, int speed, int duplex, bool state); te_errno tapi_cfg_phy_mode_supported(const char* ta, const char* if_name, const char* mode_name, bool* supported); te_errno tapi_cfg_phy_mode_adv_get(const char* ta, const char* if_name, const char* mode_name, bool* state); te_errno tapi_cfg_phy_mode_adv_set(const char* ta, const char* if_name, const char* mode_name, bool state); te_errno tapi_cfg_phy_lp_advertised(const char* ta, const char* if_name, const char* mode_name, bool* advertised); te_errno tapi_cfg_phy_commit(const char* ta, const char* if_name); int tapi_cfg_phy_autoneg_str2id(const char* name); int tapi_cfg_phy_duplex_str2id(const char* name); enum te_phy_port tapi_cfg_phy_port_str2id(const char* name); int tapi_cfg_phy_speed_str2id(const char* name); const char* tapi_cfg_phy_autoneg_id2str(int autoneg); const char* tapi_cfg_phy_duplex_id2str(int duplex); const char* tapi_cfg_phy_port_id2str(enum te_phy_port port); const char* tapi_cfg_phy_speed_id2str(int speed); te_errno tapi_cfg_phy_advertise_one(const char* ta, const char* if_name, int advert_speed, int advert_duplex); te_errno tapi_cfg_phy_pause_lp_adv_get(const char* ta, const char* if_name, int* state); te_errno tapi_cfg_phy_autoneg_lp_adv_get(const char* ta, const char* if_name, int* state); te_errno tapi_cfg_phy_autoneg_oper_get(const char* ta, const char* if_name, int* state); te_errno tapi_cfg_phy_autoneg_admin_get(const char* ta, const char* if_name, int* state); te_errno tapi_cfg_phy_autoneg_admin_set(const char* ta, const char* if_name, int state); // macros #define TE_PHY_SLEEP_TIME
Detailed Documentation
Global Functions
te_errno tapi_cfg_phy_autoneg_get(const char* ta, const char* if_name, int* state)
Get PHY autonegotiation state.
Parameters:
ta |
Test Agent name |
if_name |
Interface name |
state |
Pointer to the returned autonegotiation state value: TE_PHY_AUTONEG_OFF - autonegotiation OFF TE_PHY_AUTONEG_ON - autonegotiation ON |
Returns:
Status code.
te_errno tapi_cfg_phy_autoneg_set(const char* ta, const char* if_name, int state)
Set PHY autonegotiation state.
This function changes tree in CS locally and tapi_cfg_phy_commit() must be used to apply these changes.
Parameters:
ta |
Test Agent name |
if_name |
Interface name |
state |
Autonegotiation state value: TE_PHY_AUTONEG_OFF - autonegotiation OFF TE_PHY_AUTONEG_ON - autonegotiation ON |
Returns:
Status code
te_errno tapi_cfg_phy_duplex_oper_get(const char* ta, const char* if_name, int* state)
Get PHY duplex oper state.
NOTE: Output parameters are valid if function returns positive result only.
Parameters:
ta |
Test Agent name |
if_name |
Interface name |
state |
Pointer to the returned duplex state value: TE_PHY_DUPLEX_HALF - half duplex TE_PHY_DUPLEX_FULL - full duplex TE_PHY_DUPLEX_UNKNOWN - duplex unknown |
Returns:
Status code
te_errno tapi_cfg_phy_duplex_admin_get(const char* ta, const char* if_name, int* state)
Get PHY duplex admin state.
NOTE: Output parameters are valid if function returns positive result only.
Parameters:
ta |
Test Agent name |
if_name |
Interface name |
state |
Pointer to the returned duplex state value: TE_PHY_DUPLEX_HALF - half duplex TE_PHY_DUPLEX_FULL - full duplex TE_PHY_DUPLEX_UNKNOWN - duplex unknown |
Returns:
Status code
te_errno tapi_cfg_phy_duplex_admin_set(const char* ta, const char* if_name, int state)
Set PHY duplex state.
This function changes tree in CS locally and tapi_cfg_phy_commit() must be used to apply these changes.
Parameters:
ta |
Test Agent name |
if_name |
Interface name |
state |
Duplex state value: TE_PHY_DUPLEX_HALF - half duplex TE_PHY_DUPLEX_FULL - full duplex |
Returns:
Status code
te_errno tapi_cfg_phy_port_get(const char* ta, const char* if_name, enum te_phy_port* state)
Get PHY port.
Parameters:
ta |
Test Agent name |
if_name |
Interface name |
state |
Pointer to the returned physical connector type |
Returns:
Status code
te_errno tapi_cfg_phy_speed_oper_get(const char* ta, const char* if_name, int* speed)
Get PHY speed oper value.
Parameters:
ta |
Test Agent name |
if_name |
Interface name |
speed |
Pointer to the returned speed value (in Mbit/sec) |
Returns:
Status code
te_errno tapi_cfg_phy_speed_admin_get(const char* ta, const char* if_name, int* speed)
Get PHY speed admin value.
Parameters:
ta |
Test Agent name |
if_name |
Interface name |
speed |
Pointer to the returned speed value (in Mbit/sec) |
Returns:
Status code
te_errno tapi_cfg_phy_speed_admin_set(const char* ta, const char* if_name, int speed)
Set PHY speed.
This function changes tree in CS locally and tapi_cfg_phy_commit() must be used to apply these changes.
Parameters:
ta |
Test Agent name |
if_name |
Interface name |
speed |
Speed value (Mbit/sec) |
Returns:
Status code
te_errno tapi_cfg_phy_mode_oper_get(const char* ta, const char* if_name, int* speed, int* duplex)
Get PHY interface mode: speed and duplex oper state.
Parameters:
ta |
Test Agent name |
if_name |
Interface name |
speed |
Speed value (Mbit/sec) |
duplex |
Duplex state value TE_PHY_DUPLEX_HALF - half duplex TE_PHY_DUPLEX_FULL - full duplex TE_PHY_DUPLEX_UNKNOWN - duplex unknown |
Returns:
Status code
te_errno tapi_cfg_phy_mode_admin_get(const char* ta, const char* if_name, int* speed, int* duplex)
Get PHY interface mode: speed and duplex admin state.
Parameters:
ta |
Test Agent name |
if_name |
Interface name |
speed |
Speed value (Mbit/sec) |
duplex |
Duplex state value TE_PHY_DUPLEX_HALF - half duplex TE_PHY_DUPLEX_FULL - full duplex TE_PHY_DUPLEX_UNKNOWN - duplex unknown |
Returns:
Status code
te_errno tapi_cfg_phy_mode_admin_set(const char* ta, const char* if_name, int speed, int duplex)
Set PHY interface mode: speed and duplex state.
This function changes tree in CS locally and tapi_cfg_phy_commit() must be used to apply these changes.
Parameters:
ta |
Test Agent name |
if_name |
Interface name |
speed |
Speed value (Mbit/sec) |
duplex |
Duplex state value TE_PHY_DUPLEX_HALF - half duplex TE_PHY_DUPLEX_FULL - full duplex |
Returns:
Status code
te_errno tapi_cfg_phy_state_get(const char* ta, const char* if_name, int* state)
Get PHY link state.
NOTE: Output parameters are valid if function returns positive result only.
Parameters:
ta |
Test Agent name |
if_name |
Interface name |
state |
Pointer to the returned link state value: TE_PHY_STATE_DOWN - link down TE_PHY_STATE_UP - link up |
Returns:
Status code
te_errno tapi_cfg_phy_state_wait_up(const char* ta, const char* if_name, int timeout)
Wait until an interface is UP.
Parameters:
ta |
Test Agent name |
if_name |
Interface name |
timeout |
Timeout (in milliseconds) |
Returns:
Status code.
te_errno tapi_cfg_phy_is_mode_advertised(const char* ta, const char* if_name, int speed, int duplex, bool* state)
Check that PHY mode is advertised.
This function only checks link modes defining link speed and duplex. If any of the link modes with matching speed and duplex is enabled, this function reports advertised state. To check specific link mode or link mode not related to speed/duplex use tapi_cfg_phy_mode_get().
Parameters:
ta |
Test Agent name |
if_name |
Interface name |
speed |
Speed value (Mbit/sec, see linux/ethtool.h for more details) |
duplex |
Duplex state value: TE_PHY_DUPLEX_HALF - half duplex TE_PHY_DUPLEX_FULL - full duplex TE_PHY_DUPLEX_UNKNOWN - duplex unknown |
state |
Pointer to mode state: |
Returns:
Status code
te_errno tapi_cfg_phy_advertise_mode(const char* ta, const char* if_name, int speed, int duplex, bool state)
Set PHY mode to advertising state.
This function will change advertising state for all link modes with matching speed and duplex. For more detailed control use tapi_cfg_phy_mode_set().
Parameters:
ta |
Test Agent name |
if_name |
Interface name |
speed |
Speed value (Mbit/sec, see linux/ethtool.h for more details) |
duplex |
Duplex state value: TE_PHY_DUPLEX_HALF - half duplex TE_PHY_DUPLEX_FULL - full duplex |
state |
Mode state: |
Returns:
Status code
te_errno tapi_cfg_phy_mode_supported(const char* ta, const char* if_name, const char* mode_name, bool* supported)
Check whether a specific link mode is supported.
Parameters:
ta |
Test Agent name |
if_name |
Interface name |
mode_name |
Link mode name |
supported |
Will be set to |
Returns:
Status code.
te_errno tapi_cfg_phy_mode_adv_get(const char* ta, const char* if_name, const char* mode_name, bool* state)
Check whether a specific link mode is advertised.
Parameters:
ta |
Test Agent name |
if_name |
Interface name |
mode_name |
Link mode name |
state |
Will be set to |
Returns:
Status code.
te_errno tapi_cfg_phy_mode_adv_set(const char* ta, const char* if_name, const char* mode_name, bool state)
Set advertising state for a link mode.
This function changes tree in CS locally and tapi_cfg_phy_commit() must be used to apply these changes.
Parameters:
ta |
Test Agent name |
if_name |
Interface name |
mode_name |
Link mode name |
state |
If |
Returns:
Status code.
te_errno tapi_cfg_phy_lp_advertised(const char* ta, const char* if_name, const char* mode_name, bool* advertised)
Check whether link partner advertises a given link mode.
Parameters:
ta |
Test Agent name |
if_name |
Interface name |
mode_name |
Link mode name |
advertised |
Will be set to |
Returns:
Status code.
te_errno tapi_cfg_phy_commit(const char* ta, const char* if_name)
Commit PHY interface changes to TAs.
Parameters:
ta |
Test Agent name |
if_name |
Interface name |
Returns:
Status code
int tapi_cfg_phy_autoneg_str2id(const char* name)
Get PHY autoneg state by name string.
Parameters:
name |
Autoneg state name string |
Returns:
TE_PHY_AUTONEG_ON - autonegatiation on; TE_PHY_AUTONEG_OFF - autonegatiation off; TE_PHY_AUTONEG_UNKNOWN - autonegatiation unknown; or -1 if name string does not recognized
int tapi_cfg_phy_duplex_str2id(const char* name)
Get PHY duplex state by name string.
Parameters:
name |
Duplex state name string |
Returns:
TE_PHY_DUPLEX_HALF - half duplex; TE_PHY_DUPLEX_FULL - full duplex; TE_PHY_DUPLEX_UNKNOWN - duplex unknown; or -1 if name string does not recognized
enum te_phy_port tapi_cfg_phy_port_str2id(const char* name)
Get PHY physical connector type by name string.
Parameters:
name |
Port type name string |
Returns:
TE_PHY_PORT_TP - Twisted Pair; TE_PHY_PORT_AUI - Attachment Unit Interface; TE_PHY_PORT_FIBRE - Fibre; TE_PHY_PORT_BNC - BNC/coax; TE_PHY_PORT_DA - Direct Attach; TE_PHY_PORT_NONE - No physical port; TE_PHY_PORT_OTHER - Unknown port type; or -1 if name string does not recognized
int tapi_cfg_phy_speed_str2id(const char* name)
Get PHY speed state by name string.
Parameters:
name |
Speed state name string |
Returns:
TE_PHY_SPEED_* or 0 if name string does not recognized
const char* tapi_cfg_phy_autoneg_id2str(int autoneg)
Get PHY autoneg state by id.
Parameters:
autoneg |
Autoneg state id |
Returns:
#TE_PHY_AUTONEG_STRING_ON - autonegatiation on; #TE_PHY_AUTONEG_STRING_OFF - autonegatiation off; #TE_PHY_AUTONEG_STRING_UNKNOWN - autonegatiation unknown; or NULL if id does not recognized
const char* tapi_cfg_phy_duplex_id2str(int duplex)
Get PHY duplex state by id.
Parameters:
duplex |
Duplex state id |
Returns:
half - half duplex; full - full duplex; unknown - unknown duplex; or NULL if id does not recognized
const char* tapi_cfg_phy_port_id2str(enum te_phy_port port)
Get PHY physical connector type by name id.
Parameters:
port |
Port type id |
Returns:
TE_PHY_PORT_STRING_TP - Twisted Pair; TE_PHY_PORT_STRING_AUI - Attachment Unit Interface; TE_PHY_PORT_STRING_FIBRE - Fibre; TE_PHY_PORT_STRING_BNC - BNC/coax; TE_PHY_PORT_STRING_DA - Direct Attach; TE_PHY_PORT_STRING_NONE - No physical port; TE_PHY_PORT_STRING_OTHER - Unknown port type; or NULL if id does not recognized
const char* tapi_cfg_phy_speed_id2str(int speed)
Get PHY speed state by id.
Parameters:
speed |
Speed state id |
Returns:
TE_PHY_SPEED_STRING_* or NULL if id does not recognized
te_errno tapi_cfg_phy_advertise_one(const char* ta, const char* if_name, int advert_speed, int advert_duplex)
Turn off all advertised modes and advertise only one.
FIXME: this function calls tapi_cfg_phy_commit(), it may be not convenient.
Parameters:
ta |
Test agent |
if_name |
Interface name |
advert_speed |
Speed to advertise (Mbit/sec) |
advert_duplex |
Duplex to advertise |
Returns:
Operation status code.
te_errno tapi_cfg_phy_pause_lp_adv_get(const char* ta, const char* if_name, int* state)
Get PHY link partner advertised pause frame use.
NOTE: Output parameters are valid if function returns positive result only.
Parameters:
ta |
Test Agent name |
if_name |
Interface name |
state |
Pointer to the returned pause frame use value: TE_PHY_PAUSE_NONE - no pause frame use TE_PHY_PAUSE_TX_ONLY - transmit only TE_PHY_PAUSE_SYMMETRIC - symmetric TE_PHY_PAUSE_SYMMETRIC_RX_ONLY - symmetric or receive only |
Returns:
Status code
te_errno tapi_cfg_phy_autoneg_lp_adv_get(const char* ta, const char* if_name, int* state)
Get PHY link partner advertised autonegotiation state.
NOTE: Output parameters are valid if function returns positive result only.
Parameters:
ta |
Test Agent name |
if_name |
Interface name |
state |
Pointer to the returned autonegotiation state value: TE_PHY_AUTONEG_OFF - autonegotiation OFF TE_PHY_AUTONEG_ON - autonegotiation ON |
Returns:
Status code
te_errno tapi_cfg_phy_autoneg_oper_get(const char* ta, const char* if_name, int* state)
Get PHY autonegotiation oper state.
This function is outdated, use tapi_cfg_phy_autoneg_get().
Parameters:
ta |
Test Agent name |
if_name |
Interface name |
state |
Pointer to the returned autonegotiation state value: TE_PHY_AUTONEG_OFF - autonegotiation OFF TE_PHY_AUTONEG_ON - autonegotiation ON |
Returns:
Status code
te_errno tapi_cfg_phy_autoneg_admin_get(const char* ta, const char* if_name, int* state)
Get PHY autonegotiation admin state.
This function is outdated, use tapi_cfg_phy_autoneg_get().
Parameters:
ta |
Test Agent name |
if_name |
Interface name |
state |
Pointer to the returned autonegotiation state value: TE_PHY_AUTONEG_OFF - autonegotiation OFF TE_PHY_AUTONEG_ON - autonegotiation ON |
Returns:
Status code
te_errno tapi_cfg_phy_autoneg_admin_set(const char* ta, const char* if_name, int state)
Set PHY autonegotiation state.
This function is outdated, use tapi_cfg_phy_autoneg_set().
Parameters:
ta |
Test Agent name |
if_name |
Interface name |
state |
Autonegotiation state value: TE_PHY_AUTONEG_OFF - autonegotiation OFF TE_PHY_AUTONEG_ON - autonegotiation ON |
Returns:
Status code