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_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_duplex_str2id(char* name);
char* tapi_cfg_phy_duplex_id2str(int duplex);
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.

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

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

Returns:

Status code

te_errno tapi_cfg_phy_duplex_admin_set(const char* ta, const char* if_name, int state)

Set PHY duplex state.

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_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.

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

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

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.

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

state

Pointer to mode state: true - the mode is advertised false - the mode is not advertised

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: false - the mode is not advertised true - the mode is advertised

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 true if the requested link mode is supported, to false otherwise

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 true if the requested link mode is advertised, to false otherwise

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.

Parameters:

ta

Test Agent name

if_name

Interface name

mode_name

Link mode name

state

If true, link mode should be advertised, if false - it should not be advertised

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 true if link partner advertises the link mode and to false otherwise

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_duplex_str2id(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; or -1 if name string does not recognized

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; 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