gnrc_netif: implementation of dynamic GNRC_NETIF_NUMOF approach#12994
gnrc_netif: implementation of dynamic GNRC_NETIF_NUMOF approach#12994miri64 merged 8 commits intoRIOT-OS:masterfrom
Conversation
sys/net/gnrc/netif/gnrc_netif.c
Outdated
| if ((netif == NULL) && (_netifs[i].ops == NULL)) { | ||
| netif = &_netifs[i]; | ||
| } | ||
| if(DEVELHELP && GNRC_NETIF_SINGLE && netif_iter(NULL)) { |
There was a problem hiding this comment.
| if(DEVELHELP && GNRC_NETIF_SINGLE && netif_iter(NULL)) { | |
| if (DEVELHELP && GNRC_NETIF_SINGLE && netif_iter(NULL)) { |
|
I removed the WIP label |
92779d5 to
b13c746
Compare
smlng
left a comment
There was a problem hiding this comment.
to me it looks like all *_create functions can be changed from int to void as always 0 is returned. Otherwise, nice work!
|
@smlng solved. In order to rebase, I will need to squash. May I? |
|
yeah, please squash and rebase. |
98d4c1c to
4a503e9
Compare
|
@smlng done! |
miri64
left a comment
There was a problem hiding this comment.
IMHO at least examples/gnrc_minimal should use the new macro, better would be if the build system could detect somehow how many network devices there are and set it if it is only one.
|
|
||
| #ifndef GNRC_NETIF_SINGLE | ||
| #define GNRC_NETIF_SINGLE (0) | ||
| #endif |
There was a problem hiding this comment.
This should be exposed in sys/include/net/gnrc/netif/conf.h IMHO! This is an important optimization option that should not be hidden (also I think its usage isn't localized to the gnrc_netif module, no?)
sys/net/gnrc/netif/gnrc_netif.c
Outdated
| netif = &_netifs[i]; | ||
| } | ||
| if (DEVELHELP && GNRC_NETIF_SINGLE && netif_iter(NULL)) { | ||
| DEBUG("gnrc_netif: GNRC_NETIF_SINGLE set but more than one interface is being registered."); |
There was a problem hiding this comment.
Make this a LOG_WARNING (also line length!)
sys/net/gnrc/netif/gnrc_netif.c
Outdated
| if ((netif == NULL) && (_netifs[i].ops == NULL)) { | ||
| netif = &_netifs[i]; | ||
| } | ||
| if (DEVELHELP && GNRC_NETIF_SINGLE && netif_iter(NULL)) { |
There was a problem hiding this comment.
| if (DEVELHELP && GNRC_NETIF_SINGLE && netif_iter(NULL)) { | |
| if (IS_ACTIVE(DEVELHELP) && GNRC_NETIF_SINGLE && netif_iter(NULL)) { |
There was a problem hiding this comment.
done! I also added IS_ACTIVE to GNRC_NETIF_SINGLE
There was a problem hiding this comment.
hmmm maybe is cleaner to change here that GNRC_NETIF_SINGLE to the gnrc_netif_highlander call.
sys/net/gnrc/netif/gnrc_netif.c
Outdated
| } | ||
| if (DEVELHELP && GNRC_NETIF_SINGLE && netif_iter(NULL)) { | ||
| DEBUG("gnrc_netif: GNRC_NETIF_SINGLE set but more than one interface is being registered."); | ||
| assert(false); |
There was a problem hiding this comment.
| assert(false); | |
| assert(netif_iter(NULL) == NULL); |
tests/gnrc_netif/common.c
Outdated
| #include "od.h" | ||
|
|
||
| static netdev_test_t _devs[GNRC_NETIF_NUMOF]; | ||
| static netdev_test_t _devs[4]; |
There was a problem hiding this comment.
This needs a new internal define in common.h!
There was a problem hiding this comment.
I forgot to add it during the PR cleanup phase
|
Let's merge #13226 first |
4a503e9 to
31be76e
Compare
|
strange... do you have the |
|
anyway, I will investigate |
|
Indeed when I set |
|
ok, then I think I know what happened. The |
|
could you quickly check if that works for you? If so, I can open a PR (unless you are faster) |
|
Yes this works! |
|
I'm on it |
|
It's there: #13736 |
|
Similarly to the above, the test for emcute is failing, but it works when |
'GNRC_NETIF_NUMOF' has been removed in PR RIOT-OS#12994. The solution applied here has been adapted from a patch applied to (deprecated) 'ndn-riot' package [1]. From now on, it is the responsibility of the programmer to indicate how many interfaces are available/usable. [1] https://github.com/RIOT-OS/RIOT/pull/12994/files#diff-5c72dbe2d11f0fdf149c8a398c1175c3
'GNRC_NETIF_NUMOF' has been removed in PR RIOT-OS#12994. The solution applied here has been adapted from a patch applied to (deprecated) 'ndn-riot' package [1]. From now on, it is the responsibility of the programmer to indicate how many interfaces are available/usable. [1] https://github.com/RIOT-OS/RIOT/pull/12994/files#diff-5c72dbe2d11f0fdf149c8a398c1175c3
'GNRC_NETIF_NUMOF' has been removed in PR RIOT-OS#12994. The solution applied here has been adapted from a patch applied to (deprecated) 'ndn-riot' package [1]. From now on, it is the responsibility of the programmer to indicate how many interfaces are available/usable. [1] https://github.com/RIOT-OS/RIOT/pull/12994/files#diff-5c72dbe2d11f0fdf149c8a398c1175c3
'GNRC_NETIF_NUMOF' has been removed in PR RIOT-OS#12994. The solution applied here has been adapted from a patch applied to (deprecated) 'ndn-riot' package [1]. From now on, it is the responsibility of the programmer to indicate how many interfaces are available/usable. [1] https://github.com/RIOT-OS/RIOT/pull/12994/files#diff-5c72dbe2d11f0fdf149c8a398c1175c3
'GNRC_NETIF_NUMOF' has been removed in PR RIOT-OS#12994. The solution applied here has been adapted from a patch applied to (deprecated) 'ndn-riot' package [1]. From now on, it is the responsibility of the programmer to indicate how many interfaces are available/usable. [1] https://github.com/RIOT-OS/RIOT/pull/12994/files#diff-5c72dbe2d11f0fdf149c8a398c1175c3
'GNRC_NETIF_NUMOF' has been removed in PR RIOT-OS#12994. The solution applied here has been adapted from a patch applied to (deprecated) 'ndn-riot' package [1]. From now on, it is the responsibility of the programmer to indicate how many interfaces are available/usable. [1] https://github.com/RIOT-OS/RIOT/pull/12994/files#diff-5c72dbe2d11f0fdf149c8a398c1175c3
'GNRC_NETIF_NUMOF' has been removed in PR RIOT-OS#12994. The solution applied here has been adapted from a patch applied to (deprecated) 'ndn-riot' package [1]. From now on, it is the responsibility of the programmer to indicate how many interfaces are available/usable. [1] https://github.com/RIOT-OS/RIOT/pull/12994/files#diff-5c72dbe2d11f0fdf149c8a398c1175c3
'GNRC_NETIF_NUMOF' has been removed in PR RIOT-OS#12994. The solution applied here has been adapted from a patch applied to (deprecated) 'ndn-riot' package [1]. From now on, it is the responsibility of the programmer to indicate how many interfaces are available/usable. [1] https://github.com/RIOT-OS/RIOT/pull/12994/files#diff-5c72dbe2d11f0fdf149c8a398c1175c3
'GNRC_NETIF_NUMOF' has been removed in PR RIOT-OS#12994. The solution applied here has been adapted from a patch applied to (deprecated) 'ndn-riot' package [1]. From now on, it is the responsibility of the programmer to indicate how many interfaces are available/usable. [1] https://github.com/RIOT-OS/RIOT/pull/12994/files#diff-5c72dbe2d11f0fdf149c8a398c1175c3
'GNRC_NETIF_NUMOF' has been removed in PR RIOT-OS#12994. The solution applied here has been adapted from a patch applied to (deprecated) 'ndn-riot' package [1]. From now on, it is the responsibility of the programmer to indicate how many interfaces are available/usable. [1] https://github.com/RIOT-OS/RIOT/pull/12994/files#diff-5c72dbe2d11f0fdf149c8a398c1175c3
'GNRC_NETIF_NUMOF' has been removed in PR RIOT-OS#12994. The solution applied here has been adapted from a patch applied to (deprecated) 'ndn-riot' package [1]. From now on, it is the responsibility of the programmer to indicate how many interfaces are available/usable. [1] https://github.com/RIOT-OS/RIOT/pull/12994/files#diff-5c72dbe2d11f0fdf149c8a398c1175c3
'GNRC_NETIF_NUMOF' has been removed in PR RIOT-OS#12994. The solution applied here has been adapted from a patch applied to (deprecated) 'ndn-riot' package [1]. From now on, it is the responsibility of the programmer to indicate how many interfaces are available/usable. [1] https://github.com/RIOT-OS/RIOT/pull/12994/files#diff-5c72dbe2d11f0fdf149c8a398c1175c3
'GNRC_NETIF_NUMOF' has been removed in PR RIOT-OS#12994. The solution applied here has been adapted from a patch applied to (deprecated) 'ndn-riot' package [1]. From now on, it is the responsibility of the programmer to indicate how many interfaces are available/usable. [1] https://github.com/RIOT-OS/RIOT/pull/12994/files#diff-5c72dbe2d11f0fdf149c8a398c1175c3
Contribution description
This PR is an implementation of the ideas proposed in #9903
It removes the internal allocation of
gnrc_netif_tobjects in gnrc_netif and assumes thegnrc_netif_xxx_createcaller allocates the network interface. This means the allocation is decentralized and we move to a linked list approach forgnrc_netif_numofandgnrc_netif_iter(as described in #9903)Some benefits:
gnrc_netif_xxx_createand they will be in the linked list :)I added a
GNRC_NETIF_SINGLEmacro (as proposed in #9903) to keep the optimizations when there's a single interface.Testing procedure
This should be carefully tested. Probably 95% of testing here is just compile tests, but it would be nice to ensure that the single interface optimization (
GNRC_NETIF_SINGLE) still works as the originalGNRC_NETIF_NUMOF==1.Also, ensure that the devices still work.
Issues/PRs references
#9903
Alternative to #12308
Fixes stuff like #11979