Disclaimer!
This discussion is intended to be a “network stack independent” discussion.
Thus, all components refer to the generic one (e.g netif_t
, not gnrc_netif_t
).
Network Device representation
I would like to open a discussion regarding how to represent a network device and what’s the role of the network interfaces.
For a long time we have been using netdev
as a “network device descriptor”, as
well as a “network device interface”. An example of the former if the netdev_register
module that stores the index and device type in the netdev_t
structure or the
fact that we can “identify” a network device driver by a netdev_t
pointer. An example
of the latter is controlling the network device via netdev_driver_t
(send,
recv, get, set, isr).
Since the Radio HAL and SubMAC got merged, there’s intentionally no common interface for PHY/transceiver (as explained during the PHY/MAC rework breakout session of the summit). Also, netdev is not a mandatory dependency anymore.
There are still some reasons to have a generic way to represent a network device.
E.g see this discussion
regarding where to store index and device type). So far we have being using netdev_t
for that purpose, but we are slowly starting to have sort of duplicated descriptors
(e.g netif_t
vs netdev_t
) or mixed semantics.
So, the question is, do we need a common representation/interface for network devices? If so, I see 2 options (that are not necessarilly mutually exclusive).
- We can use
netif_t
descriptor to indirectly identify a network device. This is similar to Linux (e.gip
command requires an interface). We also keep doing this indirectly with theifconfig
command in RIOT, althogh it’s hardcoded to GNRC netif. But we could extend this principle tonetif_t
so it’s always possible to associate onenetif_t
to a specific device. Note that there are already lists ofnetif_t
(see netif_register), so we could already iterate the network interface to get a specific device. Note that this takes into consideration that there might benetif
s without a device (e.g virtual interfaces) - We can define a common network descriptor (e.g
netdev_t
, but we should be very careful with mixing interface and descriptor semantics). In this case, we can provide a list/array of “network descriptors” that get the original device back. This means all network device driver interfaces (e.g IEEE 802.15.4 Radio HAL) would inherit from this common device descriptor.
What are your thoughts on this topic?