OpenNSL API Guide and Reference Manual
Link Monitoring and Notification

The OpenNSL API provides a mechanism to scan the ports, monitoring for link-up and link-down events. This is accomplished using a thread to constantly monitor the PHYs for link status, and then calling user-supplied callbacks.

Most PHYs latch link down events, not permitting the status to change to link up until software has read the link down state. After the register containing the link down state has been read, the PHY may transition to link up. If multiple applications (or threads of execution) are accessing the link status registers in the PHY, only the first application to issue the read is guaranteed to see the link as down. The opennsl_port_link_status_get API call retrieves the current link status from the linkscan task, and not by reading the PHY itself, allowing multiple applications to recover the current link status without the possibility of missing an event. For this reason, the use of the supplied linkscan is recommended, and link status should always be retrieved using the appropriate API calls.

The linkscan process ensures that user supplied callbacks are called once for each link-up and link-down event recognized on each port.