[net] Introduce abstractions for the New API (NAPI) #1018
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.
(patch note below)
Hi again,
This is more of the code I wrote for UDP tunneling, as mentioned in #1014 . Once again, I don't think it is worth being sent to the Rust mailing list until we've got
kernel::net
in mainline, to avoid potential conflicts (and because I still need some ground work for this whole thing, even if it is only the existence ofDevice
).These abstractions should be enough to write a driver that can at least run a polling function and send socket buffers off into the GRO while checking return states (at least it was enough for mine). That seems to cover most use cases I observed, but there is clearly not everything (for example, I do not have a function to remove the NAPI from its
Device
yet).As a side note, everything is in
kernel::net::gro
, because the header defining all of the structures and methods isinclude/net/gro.h
, so it made sense to me to keep the association between NAPI and GRO in Rust.EDIT:
I'll take a look at why CI fails; I will be honest I was not expecting it to happenMissed a bindings helper header when stripping and testing the code, should be fixed nowThis patch introduces the necessary abstractions to declare, attach, and schedule (as well as prepare the scheduling of) NAPI structures. The NAPI mechanism is necessary to write network device drivers, especially because they help handle passing socket buffers to the Generic Receiver Offload (GRO) mechanism.
Rust drivers can implement the
net::gro::NapiPoller
trait over a type which implements their polling function. Afterwards, a NAPI can be tied to a device with the polling function by callingnet::Device::napi_add
with a type argument implementing the correspondingNapiPoller
trait, as well as a regular argument giving a reference to the NAPI structure used by the network driver.