Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Subscribe /

...

Unsubscribe to link state changes

TODO

Getting the Current Link State for an Interface

Some applications may wish to get the physical link state for a specific interface. Link state information may be obtained by calling NetIF_IO_Ctrl() or NetIF_LinkStateGet() with the appropriate arguments.

Calling NetIF_IO_Ctrl() will poll the hardware for the current link state. Alternatively, NetIF_LinkStateGet() gets the approximate link state by reading the interface link state flag. Polling the Ethernet hardware for link state takes significantly longer due to the speed and latency of the MII bus. Consequently, it may not be desirable to poll the hardware in a tight loop. Reading the interface flag is fast, but the flag is only periodically updated by the Net IF every 250mS (default) when using the generic Ethernet PHY driver. PHY drivers that implement link state change interrupts may change the value of the interface flag immediately upon link state change detection. In this scenario, calling NetIF_LinkStateGet() is ideal for these interfaces.

Increasing the Rate of Link State Polling

The application may increase the µC/TCP-IP link state polling rate by calling NetIF_CfgPhyLinkPeriod(). The default value is 250ms.The Micriµm TCP/IP stack offers two API functions : NetIF_LinkStateSubscribe()NetIF_LinkStateUnsubscribe(), allowing the customer application to implement a callback function that will be called when a link state change occurs.

Getting the Current Link State for an Interface

µC/TCP-IP provides two mechanisms for obtaining interface link state.

...

The advantage to Method 2 is that the link state returned is the actual link state as reported by the hardware at the time of the function call. However, the overhead of communicating with the physical layer device may be high and therefore some cycles may be wasted waiting for the result since the connection bus between the CPU and the physical layer device is often only a couple of MHz.

Calling NetIF_IO_Ctrl() will poll the hardware for the current link state. Alternatively, NetIF_LinkStateGet() gets the approximate link state by reading the interface link state flag. Polling the Ethernet hardware for link state takes significantly longer due to the speed and latency of the MII bus. Consequently, it may not be desirable to poll the hardware in a tight loop. Reading the interface flag is fast, but the flag is only periodically updated by the Net IF every 250mS (default) when using the generic Ethernet PHY driver. PHY drivers that implement link state change interrupts may change the value of the interface flag immediately upon link state change detection. In this scenario, calling NetIF_LinkStateGet() is ideal for these interfaces.

Increasing the Rate of Link State Polling

The application may increase the µC/TCP-IP link state polling rate by calling NetIF_CfgPhyLinkPeriod(). The default value is 250ms.

Forcing an Ethernet PHY to a Specific Link State

...