netdev: add netdev_register() to keep track of netdev IDs #13746
netdev: add netdev_register() to keep track of netdev IDs #13746benpicco merged 5 commits intoRIOT-OS:masterfrom
Conversation
|
nice one, we could use this for a "netdev_get_by_id" function. |
|
Ok I think I finally found a solution that I'm happy with.
I can split this PR up, but with this comming all together the |
e351b47 to
230b541
Compare
e41d12d to
911e1d3
Compare
|
Please rebase #14632 was merged. |
|
Rebased 😉 |
|
Ping? |
|
ping @miri64! |
Currently don't have time to look into this in-depth :-(
maribu
left a comment
There was a problem hiding this comment.
ACK. Looks good to me and Murdock will do the testing for me :-)
It is desireable to have a way to identify network devices. This should be independent from the type of netdev, so a common identifier is needed. Base this on the driver ID and the index in the configuration struct. This way we achive unique IDs that stay consistent for any firmware flashed on a board.
|
rebased to include #14113 |
| # Don't register netdevs if there is only a single one of them | ||
| ifeq (,$(filter gnrc_netif_single,$(USEMODULE))) | ||
| USEMODULE += netdev_register | ||
| endif |
There was a problem hiding this comment.
This is pulling netdev_register almost always now. Although it is a pseudomodule I think the dependency should be changed. AFIK there is no equivalent to gnrc_netif_single for other stacks, right? (@miri64 ?) Should this be added when some netdev_% module is used instead?
There was a problem hiding this comment.
This is affecting #13565 now, as the unneeded dependency netdev_register is pulled.
There was a problem hiding this comment.
netdev_register is a pseudomodule, so it won't do anything on it's own.
If not netdev_ code is used, this will not pull in any additional code.
There was a problem hiding this comment.
But it changes the dependency resolution. This can indeed change the binary,
There was a problem hiding this comment.
Isn't should have read the original question...netdev_register a sub-module to netdev? If not, IMHO there is nothing speaking against it being one.
There was a problem hiding this comment.
I guess we just missed a step in this discussion: #13746 (comment)
There was a problem hiding this comment.
but you just provided the solution yourself #13565 (comment)
There was a problem hiding this comment.
I thought it was not intended to have a reverse dependency to gnrc_netif_single
There was a problem hiding this comment.
I am fine with a reverse dependency how you implemented it. My original concern was about GNRC code in the network device code.
Contribution description
This introduces the new
typeandindexfield to thenetdevstruct.The
typefield is unique for each driver type and thus driver configuration struct. Theindexis the index of the device in the driver configuration struct.For this the driver needs to call
netdev_register()on setup.Only a few drivers have been converted yet as an example.
This creates a unique and stable identifier for network devices that only depends on the board configuration.
With this we can continue (can be split off to a separate PR) to implement an EUI -> device mapping for boards that provide MAC addresses.
As a third step we can also extend
luid_get_euiXXto useluid_customfor the fall-back case.This will allow for stable addresses across driver resets and can be easily implemented as a follow-up to this.
Testing procedure
This is just adding IDs without using them, nothing to test.
Issues/PRs references
required for #14634