esp32/network_ppp: Restructure to match extmod/network_ppp_lwip. #17138
+302
−214
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
The ESP32 PPP implementation predates the generic implementation in
extmod
. The newextmod
implementation has a few advantages such as a better deinit procedure (the ESP32 implementation would not clean up properly and cause crashes if recreated) and using the UART IRQ functionality instead of running a task to read data from the UART.This change restructures the ESP implementation to be much closer to the new
extmod
version, while also bringing a few tiny improvements from the ESP32 version to theextmod
version. The diff betweenextmod/network_ppp_lwip.c
andports/esp32/network_ppp.c
is now a small set of easy to review ESP32 port-specific changes.Testing
I've been running these changes for months on a few custom boards (original ESP32 and ESP32S3) with three different modem chips to connect to the Internet via PPP. Those firmware versions do contain a bunch of other changes as well (for example #17135, which I highly recommend also gets considered if this PR gets merged since it fixes a broken behaviour in the UART that can now get triggered by this updated PPP version) so it's not a completely clean test. I'm fairly confident in the changes, and the approach makes sense, but I'd be happy to see other people giving it a go as well and letting me know if they spot anything.
Note for reviewers: Instead of reviewing the changes to the ESP32 version directly, it might be easier to review the differences to the
extmod
version first (they should make sense on their own) and then compare the diff between theextmod
and ESP32 versions:git diff --no-index extmod/network_ppp_lwip.c ports/esp32/network_ppp.c
Trade-offs and Alternatives
I didn't fully replace the ESP32 version with the
extmod
version since there are distinct differences, and the ESP32 port does not use the lwIP version shipped by us but the modified version shipped as part of the ESP-IDF.I've also aimed to keep the ESP32 version backwards compatible, thus it implements a few extra arguments and settings compared to the
extmod
version. Removing these deprecated arguments and porting the missing features over to theextmod
version was out of scope for this PR, to keep it a bit easier to review.We might want to add a message for future contributors to be aware that these two files are now very similar and that many changes could probably be applied to both.