-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gnrc_netif_t: A dynamic approach to ~~GNRC_NETIF_NUMOF~~. #9903
Comments
How about changing all Combined with a runtime assert on adding the second netif if |
What are the use case for |
I had this idea also. It would keep the optimizations but make it optional.
Border router e.g. or like @gschorcht mentioned: boards with more than one network device.
I would say yes. If an application developer does not want all devices, they can remove |
I have a ESP32 board that has
I have tried the following approach. Board's
This approach requires hat the following lines in
The question is whether it a wished behavior that all network interfaces of a board are always activated automatically or whether should the application developer have the control. What I have seen is that most of the boards have only one network interface and they already activate it automatically in their So why not to activate all network interface automatically? |
See my answer to your deleted comment in #9903 (comment) |
This will be hell to test btw. |
(It is already, but by making it optional a test for this should be introduced) |
@miri64 When I was fixing the ifneq (,$(filter esp_now,$(USEMODULE)))
$(eval GNRC_NETIF_NUMOF=$(shell echo $$(($(GNRC_NETIF_NUMOF)+1))))
USEMODULE += esp_wifi_any
endif
ifneq (,$(filter esp_wifi,$(USEMODULE)))
$(eval GNRC_NETIF_NUMOF=$(shell echo $$(($(GNRC_NETIF_NUMOF)+1))))
USEMODULE += esp_wifi_any
endif That is, with each enabled netdev driver module, the number of netifs is increased by one. It could be done in same way in driver makefiles or in board definitions. The problem is that this definition of BTW, in case of ESP32, I had to add this to Lines 282 to 293 in 6a4c764
|
This seems to be more of a build system specific workaround until we get rid of |
Found back about this one. A solution to remove the need to have |
You could still have a board that has e.g. two MRF24J40 modules, so you would get two interfaces. Just counting the number of netif modules would not help here. However, RIOT already iterates over all interfaces for each module in #ifdef MODULE_MRF24J40
#include "mrf24j40_params.h"
#define MRF24J40_NUM ARRAY_SIZE(mrf24j40_params)
#else
#define MRF24J40_NUM (0)
#endif
…
#define GNRC_NETIF_NUMOF (MRF24J40_NUM + …) |
+1 for the linked list approach of interfaces!
This would certainly do the trick. A short question: is this intended to be only for GNRC_NETIF_NUMOF, or is it also for other macros (e.g LWIP_NETIF_NUMOF)? Also note that since #11879 got merged, |
I am not aware that lwIP optimizes for number of interfaces. In fact lwIP uses already linked-lists. I don't think that this can or should be generalized for all network stacks. There are network stacks (emb6 or uIP e.g.) that are specifically designed for single-interface use. |
#12994 was merged, so the approach proposed here is now implemented. |
While there are compile-time benefits to cap the number of interfaces, recent questions by users and contributors opened the question if a statically defined
GNRC_NETIF_NUMOF
(and thus a predefined array) isn't to intransparent and really the most sensible approach. IMHO it could actually be pretty easy with minor API changes to go to a linked-list-based approach by just adding anext
member aboveops
.RIOT/sys/include/net/gnrc/netif.h
Lines 62 to 64 in 8d1d509
would become
For allocation it could just be allocated on the stack of the network interface's thread.
Of course,
gnrc_netif_iter()
could be simplified a lot then as well ;-).The biggest disadvantage I see is that we loose some
#ifdef GNRC_NETIF_NUMOF == 1
optimizations through-out the code (which also would require changing, which is why this rework could become quite major though the change to the API is as I said pretty minor).Let me know what you think.
(@gschorcht this might also be of interest to you as well)
The text was updated successfully, but these errors were encountered: