Skip to content

openthread: Move OpenThread implementation from net to modules #89090

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

ArekBalysNordic
Copy link
Contributor

Move OpenThread-related code from zephyr/subsys/net/l2/openthread/openthread.c to zephyr/modules/openthread/platform/openthread.c.

The primary goal of this refactor is to enable the use of OpenThread as an independent module, without the necessity of Zephyr's networking layer.

This change is particularly beneficial for simple applications that have their own implementation of the IEEE802.15.4 driver and do not require a networking layer. These applications can now disable Zephyr's L2 and IEEE802.15.4 shim layers and directly use the OpenThread module, saving valuable kilobytes of memory.

In this approach, if the CONFIG_NET_L2_OPENTHREAD Kconfig option is set, Zephyr's L2 and IEEE802.15.4 layers will be used, and everything will function as before. The main difference is that the Zephyr's L2 layer now uses the OpenThread module, no longer implementing it.

While most of the functions in include/net/openthread.h have been deprecated, they are still available for use to maintain backwards compatibility.

@ArekBalysNordic
Copy link
Contributor Author

I will add a release note and migration guide entries to this PR soon.

@ArekBalysNordic ArekBalysNordic force-pushed the openthread_separate_from_l2 branch from cc18e05 to 54a60ae Compare April 25, 2025 11:48
@ArekBalysNordic ArekBalysNordic force-pushed the openthread_separate_from_l2 branch from 54a60ae to 1db166c Compare April 25, 2025 12:49
@ArekBalysNordic ArekBalysNordic force-pushed the openthread_separate_from_l2 branch from 1db166c to 6509f4e Compare April 25, 2025 12:51
Copy link
Collaborator

@rlubos rlubos left a comment

Choose a reason for hiding this comment

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

Generally looks fine, but need to figure out what's broken - apart from the twister issues, BabbleSim shows the Thread network fails to start.

@ArekBalysNordic
Copy link
Contributor Author

Generally looks fine, but need to figure out what's broken - apart from the twister issues, BabbleSim shows the Thread network fails to start.

Yeah, I'm debugging it locally to figure it out.

@ArekBalysNordic ArekBalysNordic force-pushed the openthread_separate_from_l2 branch from 6509f4e to 616fbde Compare April 28, 2025 09:35
@github-actions github-actions bot added the Release Notes To be mentioned in the release notes label Apr 28, 2025
@ArekBalysNordic ArekBalysNordic force-pushed the openthread_separate_from_l2 branch 2 times, most recently from 26203f8 to aff1452 Compare April 28, 2025 13:13
@github-actions github-actions bot added the platform: NXP Drivers NXP Semiconductors, drivers label Apr 28, 2025
@github-actions github-actions bot added area: UpdateHub UpdateHub area: Sockets Networking sockets area: Samples Samples labels Apr 28, 2025
@ArekBalysNordic ArekBalysNordic force-pushed the openthread_separate_from_l2 branch 3 times, most recently from d6815ed to 133c4e4 Compare April 29, 2025 06:44
rlubos
rlubos previously approved these changes Apr 29, 2025
Copy link
Collaborator

@rlubos rlubos left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the detailed migration guide.


* Now use:

* ``openthread_mutex_lock``
Copy link
Collaborator

Choose a reason for hiding this comment

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

Minor suggestion: for the new functions we could use func reference to generate links in the documentation

:c:func:`openthread_mutex_lock`

etc

Copy link
Contributor Author

@ArekBalysNordic ArekBalysNordic Apr 29, 2025

Choose a reason for hiding this comment

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

Right, I have it. All new things (structs, kconfigs, functions) are now shown as links. Deprecated functions remain as they were previously.

@ArekBalysNordic ArekBalysNordic force-pushed the openthread_separate_from_l2 branch 2 times, most recently from b61a12e to e84fc07 Compare April 29, 2025 08:26
Copy link
Collaborator

@Damian-Nordic Damian-Nordic left a comment

Choose a reason for hiding this comment

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

Looks great. Some mostly nits found.

rlubos
rlubos previously approved these changes Apr 29, 2025
@ArekBalysNordic
Copy link
Contributor Author

@Damian-Nordic, I've provided all suggested changes, thanks!

@ArekBalysNordic ArekBalysNordic force-pushed the openthread_separate_from_l2 branch from 7bd9745 to 645dfea Compare April 29, 2025 14:26
rlubos
rlubos previously approved these changes Apr 29, 2025
rlubos
rlubos previously approved these changes Apr 29, 2025
Move OpenThread-related code from
zephyr/subsys/net/l2/openthread/openthread.c to
zephyr/modules/openthread/platform/openthread.c.

The primary goal of this refactor is to enable the use
of OpenThread as an independent module, without the necessity
of Zephyr's networking layer.

This change is particularly beneficial for simple applications
that have their own implementation of the IEEE802.15.4 driver
and do not require a networking layer. These applications can
now disable Zephyr's L2 and IEEE802.15.4 shim layers and
directly use the OpenThread module, saving valuable kilobytes
of memory.

In this approach if the CONFIG_NET_L2_OPENTHREAD
Kconfig option is set, Zephyr's L2 and IEEE802.15.4 layers
will be used, and everything will function as before.
The main difference is the Zephyr's L2 layer now uses
the OpenThread module, no longer implementing it.

While most of the functions in include/net/openthread.h
have been deprecated, they are still available for use to
maintain backwards compatibility.

Signed-off-by: Arkadiusz Balys <[email protected]>
Add an entry to the release note and migration guide regarding
moving the OpenThread implementation from the L2 networking layer
to the OpenThread module.

The migration guide note contains information about deprecated
functions, explains what functions should be used instead and
provides a guide for required updates in users' applications.

Signed-off-by: Arkadiusz Balys <[email protected]>
An implementation should use a dedicated function to get
openthread instance instead of using the private L2 data.

Signed-off-by: Arkadiusz Balys <[email protected]>
Some OpenThread logs were moved from L2 to the OpenThread module,
so enable logging from there to keep previous logging visibility.

Signed-off-by: Arkadiusz Balys <[email protected]>
@ArekBalysNordic
Copy link
Contributor Author

Discussed offline that the new openthread.c file should be located outside the platform directory since it is more of a utility than a platform implementation. The same as shell.c that doesn't implement the OpenThread platform as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Networking area: OpenThread area: Samples Samples area: Sockets Networking sockets area: UpdateHub UpdateHub platform: NXP Drivers NXP Semiconductors, drivers Release Notes To be mentioned in the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants