[RFC] Network Device representation

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).

  1. We can use netif_t descriptor to indirectly identify a network device. This is similar to Linux (e.g ip command requires an interface). We also keep doing this indirectly with the ifconfig command in RIOT, althogh it’s hardcoded to GNRC netif. But we could extend this principle to netif_t so it’s always possible to associate one netif_t to a specific device. Note that there are already lists of netif_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 be netifs without a device (e.g virtual interfaces)
  2. 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?

IMO I would try to do both, but for different purposes:

I’m not sure if we need to identify network devices (at device driver level). We usually want to configure link parameters (e.g channel, csma_params, etc), but this can (and I guess should) be configured using a netif(similar to IOCTL in Linux). Since we can always iterate the netif list, this can be used to have access to all network devices.

But I think we could indeed start the discussion of “generic device descriptors” for handling common stuff for devices (power modes, on/off, ISR handling, init, etc). We could then inherit the device driver from this common interface.

Thoughts on this?

If you can have multiple instances of a device, the state of those different instances must be kept somewhere.

So far, this was done by extending netdev_t.

Where should that state be kept now?

So far, this was done by extending netdev_t.

With this you mean e.g netdev_ieee80214_t?

For IEEE 802.15.4 these states would still be kept in the radio device descriptors and each instance of the SubMAC.