Skip to content
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

configurations: initial header file config and Doxygen group #10077

Closed
wants to merge 2 commits into from

Conversation

jia200x
Copy link
Member

@jia200x jia200x commented Sep 28, 2018

Contribution description

This PR is a PoC of a header file for describing configurations and a new Doxygen group for exposing these configs, in the context of the Configurations Task Force.

We are starting with IEEE802.15.4 Default Channel configurations, because those are used by some examples.

Proposal

  • Configuration macro and default value declared under <module_name>/include/<module_name>_config.h
  • CONFIG_<MODULE_NAME>_ like macro

E.g ieee802154_config.h

// defines CONFIG_IEEE802154_DEFAULT_SUBGHZ_CHANNEL default to 5
#ifndef CONFIG_IEEE802154_DEFAULT_SUBGHZ_CHANNEL
#define CONFIG_IEEE802154_DEFAULT_SUBGHZ_CHANNEL   (5U)
#endif
  • Documentation (Doxygen) is also included in these defines. A new @configurations group is added and all configuration sub-groups are included there.

Configuration values can be modified with either:

  1. CFLAGS (e.g -DCONFIG_IEEE802154_DEFAULT_SUBGHZ_CHANNEL=8)
  2. Writting new <module_name>_config.h files in the application folder with all values
  3. Defining a global header for overwriting configurations.

Implementation

This PR:

  • Adds CONFIG_ prefix to IEEE802.15.4 configurations and move them to a ieee802154_config.h file under sys/net/link_layer/ieee802154/include.
    • Adds a USEMODULE_INCLUDES pointing to the introduced includes folder.
  • Adds a configurations Doxygen group in the root (directly under Modules)
  • Declares a config_ieee802154 group in ieee802154_config.h
    • References all macros from ieee802154_config.h to both net_ieee802154 and config_ieee802154 group.

RFC

  • Are we OK with a CONFIG_ prefix to all RIOT configurations?
  • Are we OK to put configurations header files under module/include?
  • Are we OK with the configurations group in Doxygen?

Sub-groupings (e.g config_net_ieee802154 instead of config_ieee802154) is out of the scope of this PR. If the mechanism is accepted, we can discuss this on the go (it will never break the API but just the way how users see the documentation).

If this PR gets accepted, we will proceed to add a Tracker to gradually add configurations to other RIOT modules.

Testing procedure

  • make doc. Browse to Modules>Configurations
  • Compile gnrc_networking or any example using IEEE802154_DEFAULT_xxx variables

Issues/PRs references

#10058, #9856

@jia200x jia200x added the TF: Config Marks issues and PRs related to the work of the Configuration Task Force label Sep 28, 2018
@jia200x jia200x self-assigned this Sep 28, 2018
@@ -0,0 +1,54 @@
/**
* @defgroup config_ieee802154 IEEE802.15.4 configurations
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mh... Isn't there a way to keep them in their original file and just rename them?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes sense to have all the configurable parameter of each module on a separate header file. Makes it easier to find and edit. Also you can just tell what is the exposed configuration of the module without having to go to the documentation if every module implements a similar file structure.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You would have the same effect (though admitingly it requires extra knowledge) by having them just named CONFIG_… because you can always find them then by using

git grep "^#define\s\+\<CONFIG_"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I totally agree with @miri64 that being able to use grep/ag/rg to search for configuration parameters by looking for #defines with a common prefix like CONFIG_ could be a huge productivity boost.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NB there are some comments in the usage of something to fetch all config parameters (see TF status, expose default configs). Indeed the CONFIG_ prefix is a good idea.

We might still need to add other metadata to the options (type, allowed values, help message, etc) that might need some special format/parsing.

Copy link
Contributor

@danpetry danpetry Nov 13, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea of moving in the direction of putting everything relevant to a module within the module folder, in general. I think this is a somewhat separate issue to the focus of the PR, though, which is to just create a header file which exposes configurations. If we want to move in the direction of less shared files and directories between modules (which I gather there is appetite for), maybe it should be addressed and decided with a focus on that issue, elsewhere?


/**
* @name IEEE802.15.4 sub-GHZ channel.
* @{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having a group for just one macro seems overkill. Why not just use @brief and no group (or the @brief shorthand /**< ... */?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, sure. We can do that

@jcarrano
Copy link
Contributor

jcarrano commented Oct 1, 2018

Are we OK to put configurations header files under module/include?

It would be nice to make a distinction between configurations that change the interface of the module (i.e. affect the publicly accessible header) and those that don't (meaning binary compatibility is preserved).

An example of the latter ("internal config"????) would be enabling extra debug output on a module. No other module should be recompiled as a result of this. Our build system is not currently capable of preventing such unnecessary recompilations, but if we want to have that feature we must start preparing the ground.

@jia200x jia200x requested a review from smlng October 8, 2018 16:21
@smlng smlng added Discussion: RFC The issue/PR is used as a discussion starting point about the item of the issue/PR Process: needs >1 ACK Integration Process: This PR requires more than one ACK labels Oct 9, 2018
Copy link
Member

@smlng smlng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One suggestions for consistency, otherwise I pretty much like the idea of having the *_config.h files to clearly separate and expose global config variables of a module. This would also make tooling (e.g. config GUI) and overriding values (and maybe even autogeneration in the future) very easy.

so big 👍

@@ -37,6 +37,7 @@
#include "periph/gpio.h"
#include "net/netdev.h"
#include "net/netdev/ieee802154.h"
#include "ieee802154_config.h"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't it be more in the spirit of this PR to introduce a at86rf2xx_config.h to set all the values below, and include that here and use ieee802154_config.h only in that new header file?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea!

@@ -28,6 +28,7 @@

#include "net/netdev.h"
#include "net/netdev/ieee802154.h"
#include "ieee802154_config.h"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

@jia200x
Copy link
Member Author

jia200x commented Oct 9, 2018

otherwise I pretty much like the idea of having the *_config.h files to clearly separate and expose global config variables of a module. This would also make tooling (e.g. config GUI) and overriding values (and maybe even autogeneration in the future) very easy.

I'm also with this. Besides helping with the tooling, IMO it's quite clean to expose the interface that way

@jia200x jia200x requested a review from cladmi October 9, 2018 14:55
@jcarrano
Copy link
Contributor

jcarrano commented Oct 9, 2018

Using only one underscore leads to some ambiguity, eg:

CONFIG_A_THE_THING can refer to a.the_thing, a.the.thing, a_the.thing, etc.

If, at some point we use something in the style of #10058, we may run into problems.
If we use two underscores, we can easily define a "macroification" and "demacroification" function (not allowing two successive underscores in a name component may be a good idea too.)

@kaspar030
Copy link
Contributor

Using only one underscore leads to some ambiguity, eg:

CONFIG_A_THE_THING can refer to a.the_thing, a.the.thing, a_the.thing, etc.

Make sure to not use a hash table in the implementation, because hash functions might lead to collisions.

@jcarrano
Copy link
Contributor

jcarrano commented Oct 10, 2018

@kaspar030

Make sure to not use a hash table in the implementation, because hash functions might lead to collisions.

????

@miri64
Copy link
Member

miri64 commented Dec 18, 2018

I guess this is superseded by #10626.

@miri64 miri64 closed this Dec 18, 2018
@miri64
Copy link
Member

miri64 commented Dec 18, 2018

(feel free to re-open if you disagree).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Discussion: RFC The issue/PR is used as a discussion starting point about the item of the issue/PR Process: needs >1 ACK Integration Process: This PR requires more than one ACK TF: Config Marks issues and PRs related to the work of the Configuration Task Force
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants