gnrc_netif: add gnrc_netif_highlander function#13226
Conversation
|
In general 👍. I'm not 100% sure about the name, but maybe some sleep gets me over that. I also want to make some sample checks if the size does not change. |
|
hmmmm maybe |
My problem with both this name and the one proposed in the PR, is that it implies to me that the function returns |
|
|
| * | ||
| * @attention Requires prior locking | ||
| * @note Assumed to be true, when @ref GNRC_NETIF_NUMOF == 1 and | ||
| * @note Assumed to be true, when @ref gnrc_netif_single return true and |
There was a problem hiding this comment.
Independent of the name
| * @note Assumed to be true, when @ref gnrc_netif_single return true and | |
| * @note Assumed to be true, when @ref gnrc_netif_single() return true and |
The more I think about it: Does anything speak against this joke ( |
+1 on my side :P |
|
Then lets go ahead with that :-) |
miri64
left a comment
There was a problem hiding this comment.
At a closer glance, apart from the rename, there are some issues other issues:
sys/include/net/gnrc/netif.h
Outdated
| if(GNRC_NETIF_NUMOF == 1) { | ||
| return true; | ||
| } | ||
| else { | ||
| return false; | ||
| } |
There was a problem hiding this comment.
Can be boiled down to
return (GNRC_NETIF_NUMOF == 1);There was a problem hiding this comment.
I didn't have enough coffee that day
| return gnrc_netif_is_rtr(netif) && gnrc_netif_is_6ln(netif); | ||
| /* if flag checkers even evaluate, otherwise just assume their result */ | ||
| if (GNRC_IPV6_NIB_CONF_6LR && (IS_USED(MODULE_GNRC_IPV6_ROUTER) || | ||
| (GNRC_NETIF_NUMOF > 1) || |
There was a problem hiding this comment.
| (GNRC_NETIF_NUMOF > 1) || | |
| (!gnrc_netif_single()) || |
| if((!gnrc_netif_single() && | ||
| IS_USED(MODULE_GNRC_SIXLOWPAN)) || \ | ||
| IS_USED(MODULE_GNRC_SIXLOENC)) { | ||
| switch (netif->device_type) { | ||
| #ifdef MODULE_GNRC_SIXLOENC | ||
| case NETDEV_TYPE_ETHERNET: | ||
| return (netif->flags & GNRC_NETIF_FLAGS_6LO); | ||
| #endif | ||
| case NETDEV_TYPE_IEEE802154: | ||
| case NETDEV_TYPE_CC110X: | ||
| case NETDEV_TYPE_BLE: | ||
| case NETDEV_TYPE_NRFMIN: | ||
| case NETDEV_TYPE_ESP_NOW: | ||
| return true; | ||
| default: | ||
| return false; | ||
| } | ||
| } |
There was a problem hiding this comment.
Have you checked the memory impact of moving this to static inline? examples/gnrc_border_router should be the application to look at.
There was a problem hiding this comment.
yes, it increased. The last commit fixes that problem (gnrc_netif_is_6lo is still static inline but I added a non-static function to check if the device requires 6Lo).
Now gnrc_border_router has the same size with and without this PR :)
|
@miri64 may I squash? |
|
Yes, please! |
93338a2 to
0c54b77
Compare
|
done :) |
miri64
left a comment
There was a problem hiding this comment.
Tested with make all. The binaries for examples/gnrc_networking / examples/gnrc_border_router do have the same size, but their make objdump output differs (this might have different reasons though). For unification it could make sense to also adapt gnrc_netif_is_6ln() to the new style, but this can also be done in a follow-up cleanup.
|
There were some errors due to functions defined with macros. Instead of adding "(void)" here and there, I changed those functions to their inline variant. |
|
Let's merge #13605 first |
Merged |
|
No need to let Murdock run this twice ;-). |
miri64
left a comment
There was a problem hiding this comment.
Some style nits were introduced. Also, one style fix is possible without much notice.
|
Done. When I squash, I will also change the commit that introduces the function to reflect the new name of the function. |
| else { | ||
| /* XXX this is just a work-around ideally this should be defined in some | ||
| * run-time interface configuration */ | ||
| DEBUG("auto_init_gnrc_rpl: please specify an interface" \ |
There was a problem hiding this comment.
You are removing a space here. The \ is also not necessary.
| DEBUG("auto_init_gnrc_rpl: please specify an interface" \ | |
| DEBUG("auto_init_gnrc_rpl: please specify an interface " |
|
@jia200x this needs rebasing now |
7ca3efb to
c2e491d
Compare
|
squashed and rebased |
miri64
left a comment
There was a problem hiding this comment.
ACK. Let's finally merge this! The line noted can also be fixed as a follow-up.
| #ifdef MODULE_GNRC_SIXLOENC | ||
| case NETDEV_TYPE_ETHERNET: | ||
| return (netif->flags & GNRC_NETIF_FLAGS_6LO); | ||
| #endif |
There was a problem hiding this comment.
In theory this can also use link-time optimization as well:
case NETDEV_TYPE_ETHERNET:
if (IS_USED(MODULE_GNRC_SIXLOENC)) {
return (netif->flags & GNRC_NETIF_FLAGS_6LO);
}
/* intentionally falls through */
Contribution description
This PR defines a
gnrc_netif_singlefunction that indicates if there's only one GNRC network interface.It has the same purpose of
GNRC_NETIF_NUMOF == 1but having it as a function makes the migration to #12994 easier.I also rearranged some functions to use standard ifs instead of macros, so the code is more readable and can be checked by static tests.
Testing procedure
make docIssues/PRs references