Skip to content

netdev: add netdev_register() to keep track of netdev IDs #13746

Merged
benpicco merged 5 commits intoRIOT-OS:masterfrom
benpicco:netdev-id
Aug 17, 2020
Merged

netdev: add netdev_register() to keep track of netdev IDs #13746
benpicco merged 5 commits intoRIOT-OS:masterfrom
benpicco:netdev-id

Conversation

@benpicco
Copy link
Contributor

@benpicco benpicco commented Mar 28, 2020

Contribution description

This introduces the new type and index field to the netdev struct.
The type field is unique for each driver type and thus driver configuration struct. The index is 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_euiXX to use luid_custom for 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

@benpicco benpicco added Area: network Area: Networking Type: new feature The issue requests / The PR implemements a new feature for RIOT State: demonstrator State: This PR (loosely) demonstrates a concept and is not necessarily meant to be merged. labels Mar 28, 2020
@benpicco benpicco requested review from jia200x and miri64 March 29, 2020 21:24
@jia200x
Copy link
Member

jia200x commented Mar 30, 2020

nice one, we could use this for a "netdev_get_by_id" function.

@benpicco benpicco changed the title drivers/netdev_common: add common netdev module to keep track of netdev IDs netdev: add netdev_register() to keep track if netdev IDs Jul 7, 2020
@benpicco benpicco marked this pull request as ready for review July 9, 2020 00:04
@benpicco benpicco added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Jul 9, 2020
@benpicco
Copy link
Contributor Author

benpicco commented Jul 9, 2020

Ok I think I finally found a solution that I'm happy with.

  • uses 2 extra bytes of RAM / netdev
  • no need to update all drivers at once
  • boards can define which EUI providers are connected to which netdev

I can split this PR up, but with this comming all together the samr21-xpro and avr-rss2 will finally use the MAC address printed on their labels in RIOT.

@benpicco benpicco force-pushed the netdev-id branch 2 times, most recently from e41d12d to 911e1d3 Compare July 28, 2020 09:45
miri64
miri64 previously requested changes Jul 28, 2020
@benpicco benpicco removed the State: demonstrator State: This PR (loosely) demonstrates a concept and is not necessarily meant to be merged. label Jul 28, 2020
@miri64
Copy link
Member

miri64 commented Jul 28, 2020

Please rebase #14632 was merged.

@benpicco
Copy link
Contributor Author

benpicco commented Aug 2, 2020

Rebased 😉

@benpicco benpicco added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Aug 7, 2020
@benpicco
Copy link
Contributor Author

Ping?

@fjmolinas
Copy link
Contributor

ping @miri64!

@miri64 miri64 dismissed their stale review August 11, 2020 10:13

Currently don't have time to look into this in-depth :-(

@benpicco benpicco requested a review from maribu August 17, 2020 16:08
@benpicco benpicco changed the title netdev: add netdev_register() to keep track if netdev IDs netdev: add netdev_register() to keep track of netdev IDs Aug 17, 2020
Copy link
Member

@maribu maribu left a comment

Choose a reason for hiding this comment

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

ACK. Looks good to me and Murdock will do the testing for me :-)

@maribu maribu added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Aug 17, 2020
benpicco and others added 5 commits August 17, 2020 22:50
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.
@benpicco
Copy link
Contributor Author

rebased to include #14113

@benpicco benpicco merged commit e80407e into RIOT-OS:master Aug 17, 2020
@benpicco benpicco deleted the netdev-id branch August 17, 2020 21:23
Comment on lines +72 to +75
# Don't register netdevs if there is only a single one of them
ifeq (,$(filter gnrc_netif_single,$(USEMODULE)))
USEMODULE += netdev_register
endif
Copy link
Contributor

Choose a reason for hiding this comment

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

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?

Copy link
Contributor

Choose a reason for hiding this comment

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

This is affecting #13565 now, as the unneeded dependency netdev_register is pulled.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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.

Copy link
Member

Choose a reason for hiding this comment

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

But it changes the dependency resolution. This can indeed change the binary,

Copy link
Member

@miri64 miri64 Sep 30, 2020

Choose a reason for hiding this comment

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

Isn't netdev_register a sub-module to netdev? If not, IMHO there is nothing speaking against it being one. should have read the original question...

Copy link
Member

Choose a reason for hiding this comment

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

I guess we just missed a step in this discussion: #13746 (comment)

Copy link
Member

Choose a reason for hiding this comment

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

how to proceed with that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

but you just provided the solution yourself #13565 (comment)

Copy link
Member

Choose a reason for hiding this comment

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

I thought it was not intended to have a reverse dependency to gnrc_netif_single

Copy link
Member

Choose a reason for hiding this comment

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

I am fine with a reverse dependency how you implemented it. My original concern was about GNRC code in the network device code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: network Area: Networking CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: new feature The issue requests / The PR implemements a new feature for RIOT

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants