Background:

While testing [1], I found that it would take down my local network if
I left the command prompt open for more than 30 seconds after running
any network command. The network activity light on the board running
U-Boot would go crazy and other network adapters on the network would
start getting watchdog timeouts. So apparently, it is doing something
quite low-level and I don't have any hardware to sniff that (Wireshark
on another computer was no help since all network adapters on the
network stopped working.) So I took a logical approach of looking at
the code to see if I could find anything that would cause this. This
seemed to only happen after I switched from the legacy network
implementation to the lwIP implementation, so I looked for differences
between the two implementations.

After some investigation, I found that the lwIP implementation was
different from the legacy implementation in that it does not call
eth_halt() after a network command. Since the problem happened only
when at the command prompt with no command running, this seemed like a
likely culprit. And indeed, it does seem to fix the issue for me.

For reference, the legacy implementation does something like this
as documented in doc/develop/driver-model/ethernet.rst:

        (some net operation (ping / tftp / whatever...))
        eth_init()
                ops->start()
        eth_send()
                ops->send()
        eth_rx()
                ops->recv()
                (process packet)
                if (ops->free_pkt)
                        ops->free_pkt()
        eth_halt()
                ops->stop()

After this patch, the lwIP implementation will do the same thing for
all ethernet commands.

[1]: 
https://lore.kernel.org/u-boot/20260429-add-ethernet-support-for-genio-520-720-v4-0-be54e1723...@baylibre.com/

During review of v1, we noticed some existing bugs in wget_handle_request()
so two new patches were added to fix those first before attempting the
primary objective.

Signed-off-by: David Lechner <[email protected]>
---
Changes in v2:
- Added two new patches to address existing bugs in the code.
- Don't remove eth_halt() before eth_init().
- Link to v1: 
https://patch.msgid.link/20260509-net-lwip-add-stop-function-v1-1-62d854bfa...@baylibre.com

To: Jerome Forissier <[email protected]>
To: Tom Rini <[email protected]>
To: Ilias Apalodimas <[email protected]>
Cc: Julien Stephan <[email protected]>
Cc: [email protected]

---
David Lechner (3):
      net: lwip: wget: fix error handling in wget_do_request()
      net: lwip: wget: return errno codes from wget_do_request()
      net: lwip: introduce net_lwip_eth_stop() function

 cmd/lwip/ping.c     |  10 ++++-
 cmd/lwip/sntp.c     |  10 ++++-
 include/net-lwip.h  |   1 +
 net/lwip/dhcp.c     |  15 ++++++--
 net/lwip/dns.c      |   7 +++-
 net/lwip/net-lwip.c |   5 +++
 net/lwip/nfs.c      |   4 ++
 net/lwip/tftp.c     |   4 ++
 net/lwip/wget.c     | 107 ++++++++++++++++++++++++++++++----------------------
 9 files changed, 108 insertions(+), 55 deletions(-)
---
base-commit: 36d4c653580824b16574560b21d4401614d8b68e
change-id: 20260509-net-lwip-add-stop-function-7f7794074844

Best regards,
--  
David Lechner <[email protected]>

Reply via email to