NetPhy_LinkStateGet()

The Ethernet PHY’s LinkStateGet() function determines the current Ethernet link state. Results are passed back to the caller in a NET_DEV_LINK_ETHER structure which contains fields for link speed and duplex. This function is called periodically by µC/TCP-IP.

Files

Every physical layer driver’s net_phy.c

Prototype

          static void NetPhy_LinkStateGet (NET_IF             *pif,
                                           NET_DEV_LINK_ETHER *plink_state,
                                           NET_ERR            *perr);

Note that since every PHY driver’s LinkStateGet() function is accessed only by function pointer via the PHY driver’s API structure, it doesn’t need to be globally available and should therefore be declared as ‘static’.

Arguments

pif

Pointer to the interface to get a PHY’s current link state.

plink_state

Pointer to a link state structure to return link state information. The NET_DEV_LINK_ETHER structure contains two fields for link speed and duplex. Link speed is returned via plink_state->Spd :

NET_PHY_SPD_0
NET_PHY_SPD_10

NET_PHY_SPD_100

And link duplex is returned via plink_state->Duplex :

NET_PHY_DUPLEX_UNKNOWN
NET_PHY_DUPLEX_HALF
NET_PHY_DUPLEX_FULL

NET_PHY_SPD_0 and NET_PHY_DUPLEX_UNKNOWN represent an unlinked or unknown link state if an error occurs.

perr

Pointer to variable that will receive the return error code from this function.

Returned Values

None.

Required Configuration

None.

Notes/Warnings

The generic PHY driver does not return a link state. Instead, in order to avoid access to extended registers which are PHY specific, the driver attempts to determine link state by analyzing the PHY and PHY partner capabilities. The best combination of auto-negotiated link state is selected as the current link state.