Sarthak-Pandey opened a new pull request, #20588:
URL: https://github.com/apache/nuttx/pull/20588

   ## Summary
   
   Fixes #19304.
   
   Previously, the W5500 Ethernet driver treated any transient receive glitch 
or unexpected interrupt status bit as fatal and responded with `w5500_fence()` 
— putting the chip into permanent reset, setting `w_bifup = false`, and never 
recovering. Additionally, `netdev_carrier_off()` was never called, leaving the 
network stack queueing into a dead interface, while re-enabling the interrupt 
line on an open-drain INTn with default pull-down caused a continuous level-low 
interrupt storm / LPWORK livelock on RP2040.
   
   This PR addresses all failure modes reported in #19304:
   1. **Interrupt path hardening (`w5500_interrupt_work`)**:
      - Acknowledges all pending `Sn_IR` bits read and acts only on `RECV` and 
`SEND_OK`. Warns on unexpected bits (`CON`, `DISCON`, `TIMEOUT`) without 
fencing.
      - Clears pending interrupts on unused sockets (1-7) instead of jumping to 
error.
      - Never calls `w5500_fence()` from the interrupt path.
   2. **Soft recovery & Retry Threshold (`w5500_receive`)**:
      - Adds `W5500_MAX_RX_ERRORS` (threshold of 5 consecutive errors).
      - Introduces `w5500_resync_socket0()` to softly close and reopen Socket 0 
in MACRAW mode and reset the TX buffer mirror upon receive size mismatch / 
glitches, dropping only the bad frame instead of taking down the entire 
hardware.
      - Resets the error counter upon successful packet reception.
      - Calls `netdev_carrier_off(&self->w_dev)` if the error threshold is 
exceeded and terminal hardware failure genuinely occurs.
   3. **Command completion wait (`w5500_cmd`)**:
      - Implements `w5500_cmd()` to wait for `Sn_CR` to clear to `0` after 
commands (`OPEN`, `CLOSE`, `RECV`), avoiding read races during fast SPI burst 
transactions.
   4. **Interrupt storm prevention**:
      - In `w5500_interrupt_work()`, only re-enables Ethernet interrupts at 
`done:` if `self->w_bifup` remains `true`.
      - In `boards/arm/rp2040/common/src/rp2040_common_initialize.c`, 
explicitly enables internal pull-up on `CONFIG_RP2040_W5500_INT_GPIO` so the 
active-low open-drain pin does not float low when the chip is reset.
   
   ## Impact
   
   - **Users**: High network traffic, flood ping, and rapid connect/close TCP 
connection bursts no longer permanently freeze the W5500 interface.
   - **Hardware**: W5500-EVB-Pico (RP2040) and W5500-EVB-Pico2 (RP23XX).
   - **Compatibility**: Fully backwards-compatible; adheres to WIZnet W5500 
datasheet command sequences and NuttX network driver specifications.
   
   ## Testing
   
   - Verified against `apache/nuttx` master.
   - Tested on RP2040 / RP23xx W5500 reference glue:
     - Rapid connect/close socket bursts (200x telnet connections).
     - Flood ping / soak test with zero packet loss.
     - Verified no LPWORK interrupt storm occurs when chip is placed in reset.
   


-- 
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