-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
net: config: handle autoconfiguration of multiple interfaces #29750
Comments
The |
It's surprising how many times "Yes" is the answer to the question "Can DT fix that?" |
Yes, DT could probably be used here. As always, patches are welcome. |
Just had a great use case for this 😁 I lent out my wrt54gl (an original!) a long time ago, and I might finally see it returned soon. Would be a fun retro-computing project to Zephyr running on it and work on getting all features supported. Might provide some interesting new features for Zephyr along the way. |
@gmarull - PTAL when you have a moment, would be great to get your input here. |
I generally agree that the right place for this in Zephyr is devicetree. This has always been our escape mechanism when Kconfig doesn't scale. I don't have enough networking knowledge to comment in depth, but I'd really love to see the networking subsystem become more DT aware in general. I do have some comments on the detailed RFC:
I think you meant something like If so, note that helper macros are always possible, and you can use a slightly different syntax, to get a bit more readable (but completely equivalent) results. Example:
It will all just be concatenated into a single byte array.
... by default, but you can do this too to just take exactly what you want from an include: include:
- name: foo.yaml
property-allowlist:
- i-want-this-one
- and-this-one
- name: bar.yaml
property-blocklist:
- do-not-include-this-one
- or-this-one |
@mbolivar-nordic - thanks for the suggestions (esp the ipv6 version). Had the same idea in mind with the IPv4 addresses. Was just kind of rushing, talking, taking notes while I noticed I like the idea of using binary versions of IP addresses but am also worried that they might be annoying for users. It's not a problem for IPv4, but kind of annoying for IPv6 (unless we had some similar macro). strings would generally make things a bit bloated, otoh. @rlubos, do you know of a convenient macro for specifying IPv6 addresses in binary? I can imagine one way to do it, but it would involve some level of macrobatocs (h/t @henrikbrixandersen) |
Nothing comes to my mind, unfortunately. Personally, I'd lean towards string representation of IP addresses, especially for IPv6, a commonly used test address |
Exactly - I occasional remind myself that this could probably be done at compile time via C++ and |
Is there at least a way to dynamically switch between the multiple interfaces if I cannot get them both enabled at the same time? Having different software builds for this seems unreasonable. |
I'm not sure I follow, you can have mutliple interfaces enabled at the same time, the issue is about the The IP stack will choose the right interface based on the destination IP address, or you can also use the |
Notes from the chat: |
commit 0817d36 Author: Jason Kridner <[email protected]> Date: Sun Mar 12 09:35:42 2023 -0400 sensortest: increase send rate commit d84dcba Author: Jason Kridner <[email protected]> Date: Fri Dec 16 00:38:16 2022 -0500 sensortest: make subghz the default An overlay to enable 2.4GHz will be needed until this issue is fixed: zephyrproject-rtos#29750 commit aeb1d88 Author: Vaishnav Achath <[email protected]> Date: Mon Oct 24 20:57:36 2022 +0530 samples: add beagleconnect freedom C7 sensortest sample Signed-off-by: Vaishnav Achath <[email protected]>
An overlay to enable 2.4GHz will be needed until this issue is fixed: zephyrproject-rtos#29750
What about extending settings subsystem with features necessary for storing hierarchical network config data and then providing a way to compile in default settings based on yaml definitions? |
Hi all, Below is a simple example yaml file that illustrates how the config data could be used.
WDYT? |
@jukkar - thanks so much for being the first one to take the plunge 😁 At first glance, this looks fine to me, but a lot of things look fine at first glance. And of course, in terms of the network elements you captured here, I think they make sense. YAML makes complete sense from a high level - it is the glue that binds a lot of things together, and is supported quite well in many places. At the same time, I wonder if there is an actual standard schema of this sort (i.e. an IEEE spec or standard, or IETF RFC that captures best practices). Food for thought: The OpenWrt solution is (maybe not coincidentally?) like Zephyr's Settings - a key-value format (with extra "quirks") that is necessarily string based. Also, OpenWrt makes heavy use of Lua (which is actually pretty good for embedded DSLs and also structured data). DevicetreeThere is a YAML to DT converter maintained by friends at Konsulko. Yes, I know it sounds funny, but in all seriousness, a lot of markup languages can usually be translated from one format to another. With that, at least, we would be able to re-use some existing DT mechanisms where we get the compile-time const aspect of config data that (IMO) really serves Zephyr quite well. So it's a +1 for the secondary SW configuration root node proposed by @carlocaione, but at the same time, it opens up a lot of other possibilities if combined with the YAML approach proposed by @jukkar. At the same time, we don't yet incorporate any runtime DT (DTB) or YAML parsers, and storage is a bit of a concern. Settings DBI have concerns about the Settings DB. It is a key-value store and is necessarily string-based. Sure, it's human-readable, but so is JSON or YAML, or XML and those are standardized. Concerns:
|
That is an interesting idea to use DT as an intermediate layer that passes the configuration data to zephyr instance. I just wonder the tooling to get this work during the build.
Indeed 👍
I think we do not want to incorporate any new parsers to zephyr image. IMHO all the processing of yaml should be done in host side.
I was mainly thinking Settings DB here as that could be used as a provision db inside zephyr. So the initial settings db could be provided by a yaml file, then that could be mounted in zephyr as read-write and any modifications to it could be remembered and restored in next boot. But that is kind of system level thing and I am not sure if we want to go there here and perhaps that is best left for the vendors to tackle. |
I did some experimenting with yaml2dts which can be found at https://github.com/pantoniou/yamldt with these results:
Example:
Which when "pretty-printed" produces this output
I had to change this to:
which "pretty-printed" looks like this
which was then accepted by the tool
|
Hard to say. I would guess that it is in use in Yocto-related things. The author would likely accept PRs and has also actively contributed to https://github.com/pantoniou/dtc The cc @pantoniou |
commit 0817d36 Author: Jason Kridner <[email protected]> Date: Sun Mar 12 09:35:42 2023 -0400 sensortest: increase send rate commit d84dcba Author: Jason Kridner <[email protected]> Date: Fri Dec 16 00:38:16 2022 -0500 sensortest: make subghz the default An overlay to enable 2.4GHz will be needed until this issue is fixed: zephyrproject-rtos#29750 commit aeb1d88 Author: Vaishnav Achath <[email protected]> Date: Mon Oct 24 20:57:36 2022 +0530 samples: add beagleconnect freedom C7 sensortest sample Signed-off-by: Vaishnav Achath <[email protected]> sensortest: add CONFIG_GPIO bcf: sensortest: update button api samples: bcf: sensortest: button_handler function type
commit 0817d36 Author: Jason Kridner <[email protected]> Date: Sun Mar 12 09:35:42 2023 -0400 sensortest: increase send rate commit d84dcba Author: Jason Kridner <[email protected]> Date: Fri Dec 16 00:38:16 2022 -0500 sensortest: make subghz the default An overlay to enable 2.4GHz will be needed until this issue is fixed: zephyrproject-rtos#29750 commit aeb1d88 Author: Vaishnav Achath <[email protected]> Date: Mon Oct 24 20:57:36 2022 +0530 samples: add beagleconnect freedom C7 sensortest sample Signed-off-by: Vaishnav Achath <[email protected]> sensortest: add CONFIG_GPIO bcf: sensortest: update button api samples: bcf: sensortest: button_handler function type
commit 0817d36 Author: Jason Kridner <[email protected]> Date: Sun Mar 12 09:35:42 2023 -0400 sensortest: increase send rate commit d84dcba Author: Jason Kridner <[email protected]> Date: Fri Dec 16 00:38:16 2022 -0500 sensortest: make subghz the default An overlay to enable 2.4GHz will be needed until this issue is fixed: zephyrproject-rtos#29750 commit aeb1d88 Author: Vaishnav Achath <[email protected]> Date: Mon Oct 24 20:57:36 2022 +0530 samples: add beagleconnect freedom C7 sensortest sample Signed-off-by: Vaishnav Achath <[email protected]> sensortest: add CONFIG_GPIO bcf: sensortest: update button api samples: bcf: sensortest: button_handler function type
commit 0817d36 Author: Jason Kridner <[email protected]> Date: Sun Mar 12 09:35:42 2023 -0400 sensortest: increase send rate commit d84dcba Author: Jason Kridner <[email protected]> Date: Fri Dec 16 00:38:16 2022 -0500 sensortest: make subghz the default An overlay to enable 2.4GHz will be needed until this issue is fixed: zephyrproject-rtos#29750 commit aeb1d88 Author: Vaishnav Achath <[email protected]> Date: Mon Oct 24 20:57:36 2022 +0530 samples: add beagleconnect freedom C7 sensortest sample Signed-off-by: Vaishnav Achath <[email protected]> sensortest: add CONFIG_GPIO bcf: sensortest: update button api samples: bcf: sensortest: button_handler function type
commit 0817d36 Author: Jason Kridner <[email protected]> Date: Sun Mar 12 09:35:42 2023 -0400 sensortest: increase send rate commit d84dcba Author: Jason Kridner <[email protected]> Date: Fri Dec 16 00:38:16 2022 -0500 sensortest: make subghz the default An overlay to enable 2.4GHz will be needed until this issue is fixed: zephyrproject-rtos#29750 commit aeb1d88 Author: Vaishnav Achath <[email protected]> Date: Mon Oct 24 20:57:36 2022 +0530 samples: add beagleconnect freedom C7 sensortest sample Signed-off-by: Vaishnav Achath <[email protected]> sensortest: add CONFIG_GPIO bcf: sensortest: update button api samples: bcf: sensortest: button_handler function type driver funkiness hacking try Try to enable I2C sensors bcf: guess what mcuboot needs bcf: throw in a bunch of configs bcf: throw in a bunch more configs bcf: try using a Kconfig.defconfig if statement bcf: more logic into Kconfig.defconfig bcf: try to avoid circular dependency in Kconfig.defconfig bcf: typo in Kconfig.defconfig bcf: issues in Kconfig.defconfig bcf: issues in Kconfig.defconfig bcf: issues in Kconfig.defconfig bcf: enable some more defconfig items bcf: grrr.... undefined logging stuff... unsure how to fix samples: bcf: sensortest: fix sensor names * Remove ACCEL * Use dt names, not labels * Make sure to enable CONFIG_SENSOR
An overlay to enable 2.4GHz will be needed until this issue is fixed: zephyrproject-rtos#29750
- Add support for CC1352P7 based BeagleConnect Freedom development board. - add beagleconnect freedom C7 sensortest sample An overlay to enable 2.4GHz will be needed until this issue is fixed: zephyrproject-rtos#29750 Signed-off-by: Vaishnav Achath <[email protected]>
The settings subsystem is entirely optional, and adding a dependency to it is probably not a good idea. Also, this would then need pre-baking the settings which would require yet more tooling. |
commit 0817d36 Author: Jason Kridner <[email protected]> Date: Sun Mar 12 09:35:42 2023 -0400 sensortest: increase send rate commit d84dcba Author: Jason Kridner <[email protected]> Date: Fri Dec 16 00:38:16 2022 -0500 sensortest: make subghz the default An overlay to enable 2.4GHz will be needed until this issue is fixed: zephyrproject-rtos#29750 commit aeb1d88 Author: Vaishnav Achath <[email protected]> Date: Mon Oct 24 20:57:36 2022 +0530 samples: add beagleconnect freedom C7 sensortest sample Signed-off-by: Vaishnav Achath <[email protected]> sensortest: add CONFIG_GPIO bcf: sensortest: update button api samples: bcf: sensortest: button_handler function type driver funkiness hacking try Try to enable I2C sensors bcf: guess what mcuboot needs bcf: throw in a bunch of configs bcf: throw in a bunch more configs bcf: try using a Kconfig.defconfig if statement bcf: more logic into Kconfig.defconfig bcf: try to avoid circular dependency in Kconfig.defconfig bcf: typo in Kconfig.defconfig bcf: issues in Kconfig.defconfig bcf: issues in Kconfig.defconfig bcf: issues in Kconfig.defconfig bcf: enable some more defconfig items bcf: grrr.... undefined logging stuff... unsure how to fix samples: bcf: sensortest: fix sensor names * Remove ACCEL * Use dt names, not labels * Make sure to enable CONFIG_SENSOR
Introduction
This is a proposal for a minimal subset of Devicetree bindings to allow for autoconfiguration of multiple network interfaces via
DT_INST_FOREACH_STATUS_OKAY()
.The primary reason for using DT is to allow for relatively easy scaling in comparison to Kconfig. The network stack was added to Zephyr before Devicetree came to Zephyr, when most devices had (at most!) 1 network interface. Now, we run on devices with multiple Ethernet ports, WiFi, BLE, etc. Imagine trying to use Kconfig to configure a 32-port router or something along those lines.
Problem description
Zephyr is beginning to see some increased need to support multiple network interfaces on a single device. Obvious examples would include dual-radio devices (with 5 GHz and 2.4 GHz transceivers) and dual-mac devices (multiplexing 2.4 GHz IEEE 802.15.4 and BLE).
We also need to support Ethernet, IP over CAN, SLIP, PPP, USB CDC ACM, among others.
The current issue is that our network stack only supports auto-configuration of a single network interface (and additionally, one IPv6 or IPv4 address per interface).
E.g. from
samples/net/sockets/echo_server/prj.conf
Proposed change
DT_FOR_EACH_INST_STATUS_OKAY()
Detailed RFC
Proposed change (Detailed)
How to associate IP addresses with a particular device? Either
For X in
addr
,netmask
, androute
,dns
:Either of the following (should debate the relative usefulness and choose 1):
ipv4-X = <ip1 ip2 ip3 ip4>;
(array of uint32's, can be validated at compile-time)ipv4-X = "ip1", "ip2", "ip3", "ip4";
(string-list, easier for users, probably requires runtime validation)Either of the following (should debate the relative usefulness and choose 1):
ipv6-X = [ip1 ip2 ip3];
(giant byte array, can be validated at compile-time)ipv6-X = "ip1", "ip2", "ip3", "ip4";
(string-list, easier for users, probably requires runtime validation)Address mode selection (an enumeration):
There are some special-case network interface types that might require additional DT bindings - e.g. PPP requires a peer address, IEEE 802.15.4 has short and long addresses, it may be desirable to specify an alternate MAC address for Ethernet, some configurations may require multicast addresses, etc. In the future, we may add TAP adaptors for packet sniffing, or ethernet bridging, or virtual interfaces.
Specification should be handled via inheritance in DT bindings.
An interesting aspect of this storage-wise, is that the number of IP addresses per interface would be exactly the number that are configured in Devicetree - no more, no less, which is nice in terms of code / memory usage.
Dependencies
Devicetree bindings are additive. However, the network subsystem might have some instances that will need some refactoring in the case that Kconfig values are used directly.
List specific areas of the network subsystem here that will require attention:
*
Concerns and Unresolved Questions
Currently, there are many samples and tests that depend on Kconfig as the primary means of network interface configuration. Those samples and tests would need to be updated.
Additionally, many board definitions and products rely on Kconfig to configure network interfaces.
Alternatives
Intentionally blank
Is your enhancement proposal related to a problem? Please describe.
Yes!
This was conceptualized when working on #29598.
When more than 1 IEEE 802.15.4 address is present, the
echo_client
/echo_server
applications misbehave.I tried the following which should allow more than 1 network interface
And appended
-DCONFIG_NET_CONFIG_IEEE802154_DEV_NAME="\"IEEE802154_1\""
to indicate that network autoconfiguration should use the secondary IEEE 802.15.4 network interface, but then it simply hangs indefinitely until there is a timeout.I think it's attempting to initialize "IEEE802154_0" but I'm not 100% certain.
The particular code in play here is:
Describe the solution you'd like
I think rather than "hard-coding" the network interfaces in Kconfig, we should probably introduce DT bindings for network configuration. That way, any number of interfaces can be instantiated and their IP addresses can be set in .dts rather than in a .conf file.
The DT bindings would need to cover a number of uses cases:
Describe alternatives you've considered
See above
Additional context
This issue was discovered in the process of #29598. We would ideally like to demonstrate IEEE 802.15.4 at 2.4 GHz working simultaneously with Sub GHz IEEE 802.15.4. Technically speaking, I could set
-DCONFIG_IEEE802154_CC13XX_CC26XX=n
on the command line here when building withoverlay-802154-subg.conf
but if that were the case, I would most likely also want anoverlay-802154-multi.conf
where both the 2.4 GHz and SubGHz PHYs are active.Suggestions welcome. I also don't like manually setting
CONFIG_IEEE802154_CC13XX_CC26XX=n
- maybe there is a generic way to disable 2.4 GHz IEEE 802.15.4? There seems to be only one option forCONFIG_IEEE802154=y
, maybe it would be wise to addCONFIG_IEEE802154_SUB_GHZ=y
as well.The text was updated successfully, but these errors were encountered: