I'm opening this issue to synchronize and keep track of the netif rework.
From the documentation, netdev acts as an interface to "provide a uniform API for network stacks to interacts with network device drivers".
In practice, the network stack interacts with an interface (e.g gnrc_netif) and then there's mixed transceiver, PHY and MAC layer logic.
Some consequences of this:
at86rf2xx radios go back to the idle_state after sending. This behavior is not valid e.g in TSCHRelated work:
https://github.com/RIOT-OS/RIOT/issues/7736
It's needed to allocate one gnrc_netif_t thread per network interface. Besides allocating more resources than needed, this is sometimes problematic for platforms that have several transceivers.
See https://github.com/RIOT-OS/RIOT/issues/10496
Related work:
Each stack needs to handle radio events, auto_init logic and MAC layers.
Some consequences of this:
at86rf2xx in OpenThread. It's similar in LWIP.If we can provide interfaces between this components we could benefit of:
For IEEE802.15.4, the PHY layer can be implemented as a SubMAC layer (see #13376 ) in order to take advantage of the interface of most device drivers (MAC hw accelerations already included in the device).
Moving the initialization and transceiver ISR logic out of the interface allows as to reuse code and immediately extend the support for more radios in LWIP, OpenThread, etc.
With this we could e.g get rid of these lines since the device initialization doesn't depend of the stack.
Interfaces can be represented with pointers. All events can be handled by only one thread or OS mechanism (e.g see https://github.com/RIOT-OS/RIOT/pull/12474).
We shouldn't worry if a radio doesn't support Auto-ACK, retransmissions, etc. Also, we could have more powerful MAC layers (IEEE802.15.4 with security, pan coordinators, etc).
This means the network interface is handled by the OS and not by the network stack. Network stacks can then reuse link layer logic (MAC, upper PHY). With this we can have a more uniform experience between different network stacks.
This whole rework can be done in the following phases
netif API (TO BE REVISED, see https://github.com/RIOT-OS/RIOT/issues/12688#issuecomment-587082089)This step is required in order to provide a network stack independent netif.
netif_t a pointer instead of a stack defined type (#11879)netif API to add send/recv operations (analog to sock, but intended to be used from network stacks or applications that send data via an interface)gnrc_netif to netifgnrc_pktbuf dependencies in gnrc_netif_xxx functions)gnrc_netif events to external event handlers + callbacks.gnrc_netif_ops_t ops into netif_ops_thttps://github.com/RIOT-OS/RIOT/issues/11483
https://github.com/RIOT-OS/RIOT/pull/11473
This is intended to be addressed to: https://github.com/RIOT-OS/RIOT/issues/4876
@RIOT-OS/maintainers there have been some offline conversation with some maintainers (@haukepetersen, @bergzand, @kaspar030, @miri64, @leandrolanzieri, @PeterKietzmann).
Unfortunately we didn't have time to discuss this during the RIOT summit, so I open this issue for syncing.
All kind of feedback on the fundamentals or roadmap is more than welcome!
Also related to this: https://github.com/RIOT-OS/RIOT/issues/12469
@maribu added to the road map
Define an interface for stack independent packet allocation, data handling and passing data up to the stack
[…]
- [ ] Remove GNRC dependencies in MAC layers (e.g
gnrc_pktbufdependencies ingnrc_netif_xxxfunctions)
I thought we figured last week, that this makes things more complicated than it need be…
I thought we figured last week, that this makes things more complicated than it need be…
What I meant with that was: make the MAC layer component independent of GNRC
@miri64 rephrased :)
I renamed it to "lower network stack" rework, since the network interface are only one of the components involved
I would like to share some thoughts about the "Write network stack independent network interfaces" part:
After some time, I think it's different to distinguish these 2 elements:
For 1., it's clear that the representation of a network interface should be agnostic to the network stack (e.g running ifconfig should work with all network stacks, same as sock). We already have most of this functions (' netif_iter,netif_get_opt`, etc).
However, 2. doesn't necessarily need a unique entry point (e.g netdev_recv and netif_send function) or a global allocator (netbuf). Here are some of the reasons:
netif_recv and netif_send function. Only access to a dedicated layer is needed.event_thread module (#12474 ), and this logic can be used by all Network Stacks. This would simplify much more the integration of network stacksAnd last but not least, solving the netif problem first doesn't solve the problems of radios with different caps and lack of MAC layers, so I would probably give more priority to the devices/link layer rework.
Any comments?
To make this easier to follow, I will split this rework in 2 independent reworks:
this is reorganized in #13771 and #13763 , so I will close the issue.