Uh oh!
There was an error while loading. Please reload this page.
rust: add initial netdevice support - #908
Conversation
fujita
commented
Oct 7, 2022
The CI system failure? The same code successfully passed the CIs on my repository: |
| ndo_get_tstamp: None, | ||
| }; | ||
| const unsafe fn build_device_ops() -> &'static bindings::net_device_ops { |
There was a problem hiding this comment.
The unsafe function needs a specification about the condition when it's safe to use by comment Safety.
| let ptr = unsafe { bindings::dev_get_drvdata(&mut (*netdev).dev) }; | ||
| let dev = unsafe { Device::from_ptr(netdev) }; | ||
| let data = unsafe { T::Data::borrow(ptr) }; |
There was a problem hiding this comment.
It lacks the SAFETY comment. There are many other places also lacking a SAFETY comment.
Besides, It is better to use from_kernel_result to wrap a rust crate::error::Result to a Linux kernel result.
For 'net_device', I find it's more common to use netdev_priv to get data from the device.
Richardhongyu
commented
Oct 10, 2022
I'm not a reviewer. Just have a look because I also wrap |
fujita
commented
Oct 11, 2022
Thanks for the pointer.
|
Richardhongyu
commented
Oct 14, 2022
It seems that I lack a BTW, our PRs both wrap the |
fujita
commented
Oct 16, 2022
How it can be with
Surely. Your PR includes most of |
Richardhongyu
commented
Oct 17, 2022
For The above procedure can be constrainted in the |
fujita
commented
Oct 17, 2022
In the probe function, the driver calculates a pointer to the driver-defined data by using You have your virtio-net code somewhere? Still not sure how your registration works. btw, updated the code; adds SAFETY comments and uses |
Richardhongyu
commented
Oct 17, 2022
I just merge part of the The |
fujita
commented
Oct 17, 2022
virtio abstraction should not use |
The previous version has a problem. The private data should be added to the net_device in the probe function. This is done by storing the pointer where The virtio_device should have its this private data by the probe_callback function. |
fujita
commented
Oct 17, 2022
I see what you try to do with |
Richardhongyu
commented
Oct 17, 2022
Yes. This will lose the efficience of cache the data in the close area, making it similar to using 'dev->driver_data' in performance. |
fujita
commented
Oct 17, 2022
I think that using |
One thing I'm worried is that I don't know whether the data pointed by |
fujita
commented
Oct 19, 2022
Why you needs to use both
What do you mean? |
Are you sure that |
fujita
commented
Oct 19, 2022
Yeah, I can't find any places where networking core touches |
Richardhongyu
commented
Oct 19, 2022
I may find an example. This |
fujita
commented
Oct 19, 2022
Hmm, this driver doesn't use |
Richardhongyu
commented
Oct 19, 2022
That driver does only use I will check whether there is a way to use |
Your code looks quite promising! The only issue I see is a couple missing EDIT: Actually I noticed you're still using I am also not a reviewer, just yet another person eager to develop network drivers for Linux in Rust. The kernel is in dire need of an API on the Rust side to write network drivers so that every person who wants to write one doesn't have to reinvent the wheel so to speak. As I see it right now, this PR is a very good base that doesn't break the way things like I have a question however, wouldn't it be time to split everything related to |
Added minimum abstration APIs for network device drivers. Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
fujita
commented
Mar 7, 2023
Thanks for the comments! I've just update the code against the latest linux-rust branch.
It was just easier for me to submit a single module for initial submission. But it will be split in the future. |
Added minimum abstration APIs for network device drivers.
Signed-off-by: FUJITA Tomonori fujita.tomonori@gmail.com