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
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 96 additions & 3 deletions doc/releases/migration-guide-4.2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,102 @@ Networking
the server commands, enable :kconfig:option:`NET_ZPERF_SERVER`. If server support
is not needed, :kconfig:option:`ZVFS_POLL_MAX` can possibly be reduced.

* The OpenThread-related Kconfig options from ``subsys/net/l2/openthread/Kconfig`` have been moved to
``modules/openthread/Kconfig``. All the Kconfig options remain the same. You can still use them in the
same way as before, but to modify them, use the new path in the menuconfig or guiconfig.
OpenThread
==========

* The OpenThread stack integration in Zephyr has undergone a major refactor.
The implementation has been moved from the Zephyr networking layer (``subsys/net/l2/openthread/``)
to a dedicated module (``modules/openthread/``).

* OpenThread is now a standalone module in Zephyr.
It can be used independently of Zephyr's networking stack (L2 and IEEE802.15.4 shim layers).
This enables new use cases, such as applications that use OpenThread directly with their
own IEEE802.15.4 driver, or that do not need the full Zephyr networking stack.

* Most functions in the :zephyr_file:`include/zephyr/net/openthread.h` file have been deprecated.
These deprecated APIs are still available for backward compatibility, but new applications should
use the new APIs provided by the OpenThread module. The following list summarizes the changes:

* Mutex handling:

* Previously:

* ``openthread_api_mutex_lock``
* ``openthread_api_mutex_try_lock``
* ``openthread_api_mutex_unlock``

* Now use:

* :c:func:`openthread_mutex_lock`
* :c:func:`openthread_mutex_try_lock`
* :c:func:`openthread_mutex_unlock`

* OpenThread starting:

* Previously: ``openthread_start``
* Now use: :c:func:`openthread_run`

* Callback registration:

* Previously:

* ``openthread_state_changed_cb_register``
* ``openthread_state_changed_cb_unregister``

* Now use:

* :c:func:`openthread_state_changed_callback_register`
* :c:func:`openthread_state_changed_callback_unregister`

* Callback structure:

* Previously: ``openthread_state_changed_cb``
* Now use: :c:struct:`openthread_state_changed_callback`

* The following :c:struct:`openthread_context` struct fields are deprecated and shall not be used
in new code anymore:

* ``instance``
* ``api_lock``
* ``work_q``
* ``api_work``
* ``state_change_cbs``

* The new functions that were not present before:

* :c:func:`openthread_init` to initialize the OpenThread stack.
* :c:func:`openthread_stop` to stop and disable the OpenThread stack.
* :c:func:`openthread_set_receive_cb` to set the receive callback for the OpenThread stack.

* The OpenThread-related Kconfig options from ``subsys/net/l2/openthread/Kconfig``
have been moved to :zephyr_file:`modules/openthread/Kconfig`. All Kconfig options remain the same.
You can still use them in the same way as before, but to modify them, use the new path in the
menuconfig or guiconfig.

* If the :kconfig:option:`CONFIG_NET_L2_OPENTHREAD` Kconfig option is enabled, Zephyr's L2 layer
will use the new OpenThread module API as its backend. The L2 layer no longer implements
OpenThread itself, but delegates the implementation to the module.

* For existing applications using OpenThread through Zephyr's networking stack:

* Your application should continue to work, as the old APIs are still available for compatibility.
However, you are encouraged to migrate to the new APIs for future-proofing and use the new
modular structure.
* Update any references to OpenThread Kconfig options to use the new path
(``modules/openthread/Kconfig``) in your configuration tools.

* For applications using :c:struct:`openthread_context` or other deprecated APIs:

* Begin migrating to the new APIs. The deprecated APIs will be removed in a future release.
* Avoid direct use of :c:struct:`openthread_context` and related fields; use the new
initialization and callback registration functions instead.

* For new applications or those using OpenThread without Zephyr L2:

* Use the new initialization (:c:func:`openthread_init`), run (:c:func:`openthread_run`),
and callback registration APIs (:c:func:`openthread_state_change_callback_register`).
* You can now use OpenThread directly, without enabling Zephyr's L2 or IEEE802.15.4 layers, if
your use case allows.

SPI
===
Expand Down
7 changes: 6 additions & 1 deletion doc/releases/release-notes-4.2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,12 @@ New APIs and options

* OpenThread

* Moved OpenThread-related Kconfig options from ``subsys/net/l2/openthread/Kconfig`` to ``modules/openthread/Kconfig``.
* Moved OpenThread-related Kconfig options from ``subsys/net/l2/openthread/Kconfig`` to
``modules/openthread/Kconfig``.
* OpenThread has been refactored into a standalone module, decoupled from Zephyr's networking
stack. Most old APIs have been deprecated and the new APIs are used by the Zephyr L2 layer to
maintain backward compatibility. For migration steps and details, see the
:ref:`migration guide <migration_4.2>`.

* Sensor

Expand Down
2 changes: 1 addition & 1 deletion drivers/hdlc_rcp_if/hdlc_rcp_if_nxp.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ static void hdlc_iface_init(struct net_if *iface)

ctx->ot_context = net_if_l2_data(iface);

otPlatRadioGetIeeeEui64(ctx->ot_context->instance, eui64.m8);
otPlatRadioGetIeeeEui64(openthread_get_default_instance(), eui64.m8);
net_if_set_link_addr(iface, eui64.m8, OT_EXT_ADDRESS_SIZE, NET_LINK_IEEE802154);
}

Expand Down
Loading