lwip intermediate link down handling
Hi together,
after working more deeply into the link status register handling of Ethernet PHYs i did notice that the Link Status bit in the Basic Status Register (BSR) is Latched Low. That is also the reason why we need to read it twice. The ST driver just uses the value (ignoring the intermediate value).
This Latch mechanism means that we can detect an intermediate link down (link down and up again).
Now I'm thinking about how to handle this situation properly:
Any network parameter like Duplex mode or status changed need a call to HAL_ETH_SetMACConfig.
As of HAL code i need to call HAL_ETH_Stop_IT prior calling HAL_ETH_SetMACConfig and HAL_ETH_Start_IT. So an intermediate link down will maybe drop already received data or at least interrupt a already (re-)established connection.
The intermediate link down in general will need a netif_set_link_down() and a netif_set_link_up which re-trigger things like DHCP, AutoIP, gratuitous ARP, ...
When we have very short intermediate link downs (which implies that we check very often for link status) it's maybe not needed as it's not likely that something like the speed/duplex mode has changed or the DHCP lease time elapsed (ST's implementation currently uses a 100ms delayed task for this).
Now especially when we have a longer intermediate link down situation (e.g. because our link checking is delayed or doesn't run that often in general), ignoring the intermediate link state at all is very risky as we could get inconsistent states.
So to do this in a right manner now i have following questions:
- Is it really needed to update the HAL_ETH_SetMACConfig and therefore need to call HAL_ETH_Stop_IT ?
- When speed and duplex mode didn't changed is it enough to just call netif_set_link_down and netif_set_link_up or are there other things to consider?
Regards,
Philipp
