sys: net: introduce low-level ethernet driver API#2766
sys: net: introduce low-level ethernet driver API#2766kaspar030 merged 4 commits intoRIOT-OS:masterfrom
Conversation
cpu/native/ng_net/dev_eth_tap.c
Outdated
|
@cgundogan integrated. |
There was a problem hiding this comment.
this is never being called?
There was a problem hiding this comment.
It is supposed to be called from a drivers _isr implementation. Does the test app work (e.g., print something if you sent a packet to the node / broadcast one)?
|
|
I might have an idea to prevent having to copy the data to send into one continuous chunk before you send it: how about splitting the send function in three parts: |
|
Also I am not quite sure about the global functions you defined outside the |
Why not? Those functions are called with the device handle as parameter. Should be easy to dispatch to whatever the network stack needs. |
Do you think we can omit that parameter? The two drivers I have don't need it. |
|
I didn't really follow the latest discussions on netdev and this stuff, but looking at the proposed interface that looks exactly how I remember netdev to look like. Now, that I look at |
|
@OlegHahm ng_netdev pulls at least ng_pkt, ng_pktbuf, ng_netconf. All of them are not needed for a low-level driver. pktbuf alone disqualifies the interface for class-0 devices. And as you realized, the interface is nearly the same, just without those dependencies. That is exactly the purpose / advantage of it. |
Maybe I'm starring at the wrong files. Can you point me to these dependencies?
Sounds completely reasonable to me. But this sounds to me as we should use this interface as a base and put additional features as a kind of add-on on top of it if necessary. (Sorry if I discuss about this from a rather abstract level, but I don't have time to dig into the actual code too much.) |
From Actually pktbuf is not a direct dependency, but Also the
Which interface is "this" in that sentence? :) |
|
Ah, I was indeed looking at the wrong file. Why is device driver interface specified in For the the other depencies, I agree that this is a bit unfortunate. Can we find a way to abstract from this? I agree, that it may make sense to have different network stacks with different focuses (class 0 devices or class 1+ devices, for instance), but on the device driver level, I would have assumed that it is possible to define a basic set of functions that can (almost) always be satisfied.
Sorry, I meant the interface you propose in this PR. |
You're saying it should move to drivers/include?
Agreed. Still personally I always prefer not to dictate implementation through interface, just for the flexibility.
Totally. That's what I tried with this interface. Should be simple to extend it so it also works for radio devices. And it can already be used with the ng network stack. |
That seems the natural place for me to look for a device driver interface - and that's the place where I searched for it.
@haukepetersen, @authmillenon, do you have any opinion on this? |
|
@OlegHahm I'm also of the opinion to put it into drivers (as the legacy version of netdev you found there indicates). @haukepetersen however put it into His argument was more or less, that yes, it's device related and it presents an API for a driver (that can in theory be directly connected to the hardware), but things like this PR and previous discussions not to enforce Does this reflect your argument @haukepetersen? |
|
Why is it that dependent on IMO we should have network device interface (i.e. |
|
@OlegHahm because a network device is required to at least release a sending packet from packet buffer, because it is the last one touching it. Apart from it sure, you can just use arbitrary |
|
I spend some more thoughts about these driver interfaces the last days, but I have not come up with a clear opinion, yet. I understand @kaspar030s thoughts about I guess creating true low-level driver interfaces for ethernet, ieee802.15.4 etc and mapping the |
|
My question about your opinion was more about the directory of |
cpu/native/ng_net/dev_eth_tap.c
Outdated
|
@OlegHahm I think this is squashable? |
|
sure, go ahead |
f0a2b82 to
6c579c6
Compare
|
There was a problem hiding this comment.
empty if case. :) you made me remove the warning.
|
The last two comments are no stoppers. I leave it to you, @kaspar030, if you want to address them. Otherwise go ahead with merging. |
sys/include/dev_eth_autoinit.h
Outdated
|
-rebased |
|
go, travis, go! |
|
|
|
GO. |
sys: net: introduce low-level ethernet driver API
|
🎉 🍻 |
While implementing the ethernet driver for encx24j600, I realized that ng_netdev is too fat for some applications, so I tried to create an interface just for ethernet drivers.
The actual tap device handling is taken from #2558.
edit
Let me rephrase the "too fat" statement, as it is totally inaccurate.
IMHO the currently developed network stack might not be the only one we might have in RIOT.
So when I started developing an ethernet driver for RIOT, I didn't want to tie it to netdev and friends.
netdev does make some assumptions on how a driver has to be implemented, and also implies a lot of dependencies.
This PR introduces a fairly thin interface with no dependencies, which can easily be used with netdev (see #2776), but doesn't depend on it.
I've implemented two drivers using it (the tap driver in this PR and a driver for encx24j600 chips, which I'll PR soon). As always with interfaces designed by yourself, I'm quite happy with the result.
The only disadvantage of using this interface instead of directly writing a driver for netdev is that pktsnips have to be converted to a flat buffer before sending to the device. This could be added to the interface if deemed necessary.