-
Notifications
You must be signed in to change notification settings - Fork 2k
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
netdev_new_api: allow .send()
to return > 0 to signal synchronos send
#21012
Conversation
.send()
to return > 0 to signal synchronos send
.send()
to return > 0 to signal synchronos send.send()
to return > 0 to signal synchronos send
.send()
to return > 0 to signal synchronos send.send()
to return > 0 to signal synchronos send
It is not actually inherently synchronous, e.g. with DMA it is possible and in fact quite sensible to have UART asynchronous. Even if only an TX done IRQ is available, providing an async UART interface would be possible with the ISR feeding the data into the UART while allowing the CPU to do other things in between the ISR. I wonder if we are here digging in deeper into the whole of the synchronous periph APIs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's rather revert the slip netdev to the legacy API. No need to add a third case, as this matches behaviour of the legacy API already.
If the driver becomes async, it can easily be converted to return 0 on send - but e.g.
The nice thing about the new API is the change in memory ownership and that we can be a lot more strict about how it behaves. e.g. in the synchronous send case we don't need to generate an event, the legacy API would just generate events 'just in case' - or not, depending on what the driver author felt like. The goal would be to get rid of all the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, makes sense
Since RIOT-OS#21012 a netdev in the new API can return > 0 directly in netdev_driver_t::send() to indicate the driver is naturally synchronous and has already completed the transmission. This adapts lwIP to handle this case explicitly. With it, lwIP will work again on `native`, rather than blocking for a signal that TX has completed that never arrives.
Since RIOT-OS#21012 a netdev in the new API can return > 0 directly in netdev_driver_t::send() to indicate the driver is naturally synchronous and has already completed the transmission. This adapts lwIP to handle this case explicitly. With it, lwIP will work again on `native`, rather than blocking for a signal that TX has completed that never arrives.
Since RIOT-OS#21012 a netdev in the new API can return > 0 directly in netdev_driver_t::send() to indicate the driver is naturally synchronous and has already completed the transmission. The adaption of lwIP to that API change contained a bug: It handled the case after the thread is already blocked waiting for the signal that is never going to arrive. This is now fixed.
Since RIOT-OS#21012 a netdev in the new API can return > 0 directly in netdev_driver_t::send() to indicate the driver is naturally synchronous and has already completed the transmission. The adaption of lwIP to that API change contained a bug: It handled the case after the thread is already blocked waiting for the signal that is never going to arrive. This is now fixed.
Contribution description
The new netdev API makes implementing drivers where
.send
is inherently synchronous (slip, dose, ethos) kind of awkward. They need to memorize the frame size, generate an event, and return the frame size in.confirm_send
to signal completion.However, the new netdev API does not use
.send
return values that are > 0. We can use those to signal that send is complete already and no further action is needed.This makes writing and understanding synchronos drivers much easier, the code changes to support this in GNRC and LWIP are minimal.
Testing procedure
You can test with SLIP with is now trivial to convert:
slip.patch
Issues/PRs references