daniel-p-carvalho opened a new pull request, #20974:
URL: https://github.com/apache/nuttx/pull/20974

   ## Summary
   
   `pic32mz_ifup()` waited for the PHY auto-negotiation in a loop that takes 
over ten seconds to give up, then failed when there was no link partner. With 
no cable the interface could not be brought up, nor anything that depends on it 
(for example a bridge that has to start with the board).
   
   * The wait is bounded to 4 s and a timeout means "no link", not an error: 
`ifup` succeeds and the interface comes up with the carrier off.
   * A work item polls the PHY every second (the PHY interrupt is not wired on 
every board). On link up it reads the negotiated mode, configures the MAC for 
it and turns the carrier on; on link down it turns the carrier off.
   * The code that reads the negotiated speed and duplex moves into 
`pic32mz_phygetmode()`, shared by `ifup` and the poller. The KS8721 and 
DP83848C branches are moved unchanged.
   * `ifdown` only cancels the poller, it does not wait for it: the carrier 
functions take the device lock that `ifdown` is called with.
   
   ## Impact
   
   PIC32MZ Ethernet only (the EV49N51A is the only user in tree). An interface 
with a cable behaves as before. Without a cable `ifup` now returns after 4 s 
instead of failing after 10+ s, and `RUNNING` follows the link afterwards. No 
Kconfig or API change.
   
   ## Testing
   
   Host: Linux x86_64, XC32 v6.00; also built with the Pinguino toolchain used 
by CI (`ev49n51a:netnsh`), no warnings. Board: EV49N51A, running the Ethernet 
to Wi-Fi bridge (`wifibridge`, #20971) with a laptop as the Wi-Fi station and a 
host behind the Ethernet port.
   
   * Cable at boot: bridge up, host pings the board 4/4, as before.
   * Cable unplugged with the bridge running: `eth0` goes from `RUNNING` to 
`UP`, the bridge stays.
   * No cable at boot: AP and bridge come up, `eth0` is `UP` without `RUNNING`; 
after plugging the cable `eth0` is `RUNNING` and the host pings the board 5/5.
   * Station pinging the host through the bridge (240 pings, 0.5 s): two 
unplug/plug cycles, both recovered with no intervention (22 and 30 lost 
replies, which include the time the cable was out).
   
   Not tested: 10 Mb/s negotiation on replug, and the KS8721 and DP83848C PHYs 
(the code is only moved).
   
   `./tools/checkpatch.sh -c -u -m -g` passes.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to