-
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: implementation of dynamic GNRC_NETIF_NUMOF approach #12994
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if(DEVELHELP && GNRC_NETIF_SINGLE && netif_iter(NULL)) { | |
if (DEVELHELP && GNRC_NETIF_SINGLE && netif_iter(NULL)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done!
I removed the WIP label |
92779d5
to
b13c746
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
@@ -38,6 +38,10 @@ extern "C" { | |||
*/ | |||
#define NETDEV_MSG_TYPE_EVENT (0x1234) | |||
|
|||
#ifndef GNRC_NETIF_SINGLE | |||
#define GNRC_NETIF_SINGLE (0) | |||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ping?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done!
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make this a LOG_WARNING
(also line length!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done!
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ping
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done! I also added IS_ACTIVE to GNRC_NETIF_SINGLE
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmmm maybe is cleaner to change here that GNRC_NETIF_SINGLE to the gnrc_netif_highlander
call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done!
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert(false); | |
assert(netif_iter(NULL) == NULL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done!
tests/gnrc_netif/common.c
Outdated
@@ -24,7 +24,7 @@ | |||
#include "net/netdev_test.h" | |||
#include "od.h" | |||
|
|||
static netdev_test_t _devs[GNRC_NETIF_NUMOF]; | |||
static netdev_test_t _devs[4]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs a new internal define in common.h
!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forgot to add it during the PR cleanup phase
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done!
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_t
objects in gnrc_netif and assumes thegnrc_netif_xxx_create
caller allocates the network interface. This means the allocation is decentralized and we move to a linked list approach forgnrc_netif_numof
andgnrc_netif_iter
(as described in #9903)Some benefits:
gnrc_netif_xxx_create
and they will be in the linked list :)I added a
GNRC_NETIF_SINGLE
macro (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