forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 483
[net] Introduce abstractions for the New API (NAPI) #1018
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
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Lymkwi
Lymkwi
force-pushed
the
rust-napi
branch
from
June 27, 2023 15:35
2ec31e1 to
ee7f9bb
Compare
This 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 calling `net::Device::napi_add` with a type argument implementing the corresponding `NapiPoller` trait, as well as a regular argument giving a reference to the NAPI structure used by the network driver. Signed-off-by: Amélie Gonzalez <lymkwi@vulpinecitrus.info>
@Lymkwi
Lymkwi
force-pushed
the
rust-napi
branch
from
June 27, 2023 16:02
ee7f9bb to
930eca9
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Uh oh!
There was an error while loading. Please reload this page.
(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::netin 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
Deviceyet).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 happen (削除ここまで)Missed 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::NapiPollertrait 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_addwith a type argument implementing the correspondingNapiPollertrait, as well as a regular argument giving a reference to the NAPI structure used by the network driver.