Call vApplicationIPNetworkEventHook In Zynq Network Interface On State Change

Are there plans to update the prvEMACHandlerTask in the Zynq Network Interface to call the vApplicationIPNetworkEventHook in the event of a link status change? I’d like to take action if the link goes down.

I’m sure I can recreate the calls down into XEmacPs_PhyRead to monitor the link status myself, but it seems redundant since the EMAC Handler Task is already monitoring it.


It is not something on our immediate roadmap but I would encourage you to update as you need then, provide it is backward compatible, create a pull request in the git repo:

Yes, we plan to change the behaviour about the Link Status (LS).

How it works now: as long as packet are received, we don’t want to disturb the MII bus and the LS is assumed to be high. The status is read in this statement:

xStatus = ulReadMDIO( PHY_REG_01_BMSR );

In quiet times, when no packets come in, the PHY will be polled at a low pace, e.g. 15 seconds ( see PHY_LS_HIGH_CHECK_TIME_MS ).
As long as the LS is down, polling will be frequent, every second ( PHY_LS_LOW_CHECK_TIME_MS ).

If would not be good to poll the status from a different task because it is non-reentrant. It is better to call xGetPhyLinkStatus() in stead.

About the slow polling: one time I was polling the LS frequently. I saw that it interfered with the network activity: the performance dropped dramatically.

Some questions to you:

Just curious, what action would you like to take when the LS goes down?
When the LS goes up, would you like to run the DHCP process again?
And what do you think of very short disconnections, would you like to notice them?

I’ll be honest, at the moment I don’t really have a grand plan for what I want to do if the network goes out. Right now I am still learning FreeRTOS & Zynq, so I just have some basic tasks running. My goal right now was to print a message out to the console if the network went down. Long term I was kind of thinking there might be tasks that I would want to start/stop based on if the network was connected. And by connected/disconnected, I’m thinking long duration probably (like was the cable disconnected).

Just to clarify, is xGetPhyLinkStatus() safe for me to call? As noted, I figured I would just tie into the vApplicationIPNetworkEventHook(), but I have a couple slow periodic tasks that I could drop that call into in the short term and then just call the hook myself.

Yes it is safe to call xGetPhyLinkStatus() from any task. It tells if the link is up or down, but the information may run a little behind.
At this moment, vApplicationIPNetworkEventHook() is called when the Link Status is up and when an IP-address has been obtained. After a eNetworkUp event, the device can connect to the network.