Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add W5100, W5500, and ECN28J60 interrupt-driven mode #1986

Merged
merged 9 commits into from
Feb 6, 2024
Merged

Conversation

earlephilhower
Copy link
Owner

No polling needed and should reduce latency by using the GPIO interrupt to signal the Pico to read a received packet.

No polling needed and should reduce latency by using the GPIO interrupt to
signal the Pico to read a received packet.
@earlephilhower
Copy link
Owner Author

earlephilhower commented Feb 5, 2024

FWIW this passes the simple WiFiClient tests and reduces delay on ping to ~1.5ms on W5500, ~3.5ms on W5100 , but it does seem to have some LWIP re-entrancy issues I need to track down.

@earlephilhower earlephilhower marked this pull request as ready for review February 6, 2024 19:08
@earlephilhower
Copy link
Owner Author

@JAndrassy this PR should enable you to use IRQ-based reception on your ESP32 WiFi driver as well. The changes to the driver itself should be minimal and it can really reduce latency and CPU overhead.

@JAndrassy
Copy link
Contributor

the esp-hosted firmware maintainers messed up the handshake pin which was originally intended as interrupt signal.
so Arduino implemented the ESPHost library as polling. I too tried to change it to work with interrupt but the signal is wrong.

espressif/esp-hosted#308

@earlephilhower
Copy link
Owner Author

Ah, too bad. This change may also heolp w/the starvation issue you found with LittleFS in your sketch from #1973. If you still have the setup and run either WizNet chip, it might be worth re-adding the LittleFS bits and stting if you get any better performance. With polling it's possible the LWIP lock is always taken when the poll happens...even if it's unlocked at other times. With level-based IRQs, all you need is 1 clock cycle unlocked and it'll catch the interrupt and poll.

Under heavy load the GPIO stack was seen to grow beyond 4 entries,
causing further driver interrupts to be ignored.  Increase the depth
to 8 to give add'l leeway.

Add short docs on specifying the interrupt pin for the WizNet devices.
It took longer to wire up the module than it took to add IRQ based
reception support!
@earlephilhower earlephilhower changed the title Add W5100 and W5500 interrupt-driven mode Add W5100, W5500, and ECN28J60 interrupt-driven mode Feb 6, 2024
@earlephilhower
Copy link
Owner Author

I've had this running for >1hr on various boards with AdvancedWebServer responding to 15 requests/second over 5 browsers plus an additional 2 pings/second. Seems as solid as can be and really does improve average latency a ton.

On the ENC I can get <1ms ping response. On the W5100, if I bump up the SPI from 4MHz to 25MHz I get ping responses of 2ms. Both of which are very stable. With polling the ping would range from 1-20ms (since the Pico would only look for packets every 20ms!), and the web server response under load felt much worse.

@earlephilhower earlephilhower merged commit 842ec24 into master Feb 6, 2024
13 checks passed
@earlephilhower earlephilhower deleted the wizirq branch February 6, 2024 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants