Commit graph

38 commits

Author SHA1 Message Date
Damian Krolik 42d928ee93 drivers: ieee802154: fix configuring CSL IE in ACK
The code was assigning a pointer to a scoped buffer to
an object outside that scope. This would cause the driver
would receive garbage instead of a well-formatted IE and
would likely reject the IE. This in turn caused CSL IE
not being included in enhanced ACKs (verified with
wireshark).

Signed-off-by: Damian Krolik <damian.krolik@nordicsemi.no>
2024-04-03 13:57:50 +03:00
Dave Lacerte 379ac5e394 modules: openthread: platform: radio: Time Sync OT Feature support
Add missing otRadioIeInfo structure and add plaform time to transmit frame

Signed-off-by: Dave Lacerte <lacerte.dave@hydroquebec.com>
2024-03-28 16:05:21 -05:00
Maciej Baczmanski 0f1747e4e7 net: openthread: upmerge to 7761b81
additionaly, implement `otPlatRadioResetCsl` functionality

Signed-off-by: Maciej Baczmanski <maciej.baczmanski@nordicsemi.no>
2024-01-26 10:48:02 +01:00
Maciej Baczmanski 36b7f44c1d drivers: ieee802154: fix handling of struct ieee802154_config
`struct ieee802154_config config` is a struct containing an
union. Members of `config` were accessed incorrectly in
`otPlatRadioEnableCsl`. Fix by initializing `config` with `0`
and accessing one member at a time.

Signed-off-by: Maciej Baczmanski <maciej.baczmanski@nordicsemi.no>
2024-01-26 10:48:02 +01:00
Maciej Baczmanski d76bcd346c drivers: ieee802154: fix ACK header IE implementation
- In `set_vendor_ie_header_lm`, case when
`link_metrics_data_len == 0` has been ignored.
This commit fixes that by setting `header_ie->length = 0`
before returning.
- current implementation of enh ACK header IE returns
`-ENOTSUP` when `ack_ie.header_ie == NULL` or
`ack_ie.header_ie->length == 0`. This commit fixes that by
refactoring checks in `nrf5_configure`.

Co-authored-by: Przemyslaw Bida <przemyslaw.bida@nordicsemi.no>

Signed-off-by: Maciej Baczmanski <maciej.baczmanski@nordicsemi.no>
2024-01-26 10:48:02 +01:00
Eduardo Montoya 822e8d4cc4 net: openthread: remove unneded call to otLinkMetricsInit
Platforms calculate Link Metrics values internally after using
`otPlatRadioConfigureEnhAckProbing`.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2024-01-19 09:48:03 +01:00
Eduardo Montoya fe9e306a83 net: openthread: fix otLinkMetricsInit usage
Remove usage of `otPlatRadioGetReceiveSensitivity` without the
`otInstance` parameter.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2024-01-17 09:55:34 +01:00
Eduardo Montoya 5767998d4f drivers: ieee802154: nrf: make selective tx power the default
Remove `IEEE802154_SELECTIVE_TXPOWER` option.

Cache the tx power value in nRF5 driver and make use of it on each
operation.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
Signed-off-by: Jędrzej Ciupis <jedrzej.ciupis@nordicsemi.no>
2024-01-05 09:04:17 +01:00
Jędrzej Ciupis 7afeb62e20 drivers: ieee802154: support Key Identifier Mode > 1
IEEE 802.15.4-2020 defines four possible values for Key Identifier Mode
field of the Auxiliary Security Header. The current ieee802154 driver
API only supports two of them: b00 and b01. This commit adds support for
the two remaining Key Identifier Mode values. It's done by replacing a
field that can only hold Key Index into a field that can holds a pointer
to the entire Key Identifier field.

See IEEE 802.15.4-2020, sections 9.4.2.3 and 9.4.4 for further reference.

Signed-off-by: Jędrzej Ciupis <jedrzej.ciupis@nordicsemi.no>
2023-12-13 13:57:24 +01:00
Eduardo Montoya e504ab5217 net: openthread: add Link Metrics noise floor initialization
It was missing.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2023-11-30 10:05:14 +01:00
Jamie McCrae ce3ba0dfd2 modules: openthread: platform: radio: Rename missed type
Fixes an issue whereby a rename of a variable type has been
forgotten in an instance, which now uses the correct type name

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-11-17 16:00:07 +01:00
Eduardo Montoya b406024148 net: openthread: implement otPlatRadioSetRxOnWhenIdle
OpenThread upmerge to commit `193e77e`.

Implement `otPlatRadioSetRxOnWhenIdle` radio platform API.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2023-11-15 09:59:17 +01:00
Eduardo Montoya 1d0dda794c net: pkt: remove redundant net_pkt_cb_ieee802154 fields
Remove redundant `arb` and `fv2015` fields.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2023-11-03 11:44:40 +01:00
Florian Grandel e9d5a98e9d drivers: ieee802154: improve CSL standard conformance
This change slightly simplifies the configuration of a CSL receiver and
generalized CSL_RX_TIME to EXPECTED_RX_TIME as a re-usable primitive
across several timing-sensitive IEEE 802.15.4 standard sub-protocols
(namely BE-PANs/DSME/CSL/RIT/TSCH).

This API change is based on the rules outlined in RFC #61227.

Fixes: #62918

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-10-20 14:58:32 +02:00
Florian Grandel 80da9ddfef drivers: ieee802154: improve ACK header IE config
Improves standard conformance of the IEEE802154_CONFIG_ENH_ACK_HEADER_IE
option and introduces certain "soft MAC" capabilities around header IEs:
 * Introduces types and helpers that allow driver maintainers to
   represent, parse, write and validate header IEs.
 * Introduces helper functions to access non-aligned fields in header
   IEs, namely element IDs.

Updates the only existing L2 and driver pair that uses
IEEE802154_CONFIG_ENH_ACK_HEADER_IE: OpenThread platform radio and nRF5
and improves header IE validation in the nRF5 driver.

This change should help further driver maintainers to support
OpenThread's CSL and vendor IE extensions. It is based on the rules
specified in RFC #61227.

It is also a precondition to generically support both, "soft MAC" and
"hard MAC", approaches to header IEs in the TSCH protocol, namely the
time synchronization IE.

Fixes: #62940

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-10-20 14:58:23 +02:00
Florian Grandel 62396443fc drivers: ieee802154: deprecate OT "sleep" nomenclature
"Sleeping" has a well defined meaning in Zephyr related to threading and
power management. This differs from OpenThread's definition:

- Deprecates the "SLEEP_TO_TX" capability as it is redundant and
  conflicts with all of Zephyr's nomenclature, #61227, RFC 2863, Thread
  standard and IEEE 802.15.4. This binds the API to an implementation
  detail of OpenThread, instead. See #63670 for the agreed migration path.

- Renames the "SLEEP" event to "RX_OFF" which conforms to the
  nomenclature in Zephyr, this API and IEEE 802.15.4.

Fixes: #62995

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-10-20 14:58:16 +02:00
Florian Grandel 36402b6d2a net: pkt: time: introduce ns timestamp helper
A little refactoring that simplifies dealing with nanosecond timestamp
values in packets and further decouples calling code from PTP:

Benefits:
- simplifies calling code by removing redundant conversions.
- prepares for removing PTP dependencies from net_pkt.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-09-29 16:27:15 +02:00
Florian Grandel e2005b6e48 modules: openthread: radio: OT now uses standard TX timestamp
Synchronizes with the new upstream RX/TX timestamp definition in
OpenThread based on the standard's SFD.

This change is synchronized with the upstream OpenThread implementation
via west.yml.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-09-19 15:21:17 +01:00
Daniel Leung 50a20f7b62 openthread: rename shadow variables
Rename shadow variables found by -Wshadow.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-08-22 11:39:58 +02:00
Florian Grandel 137a7edd6e drivers: ieee802154: nRF5: TX timestamp now refers to start of PHR
Based on the standard based definitions given in previous commits, the
TX timestamp used for timed TX now refers to the start of PHR. As OT
continues to calculate timestamps based on a "start of SHR" definition,
the duration of the PHY specific SHR is added in the OT adaptation layer
to make up for this OT quirk.

Fixes: #59245

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-08-16 17:06:16 +02:00
Florian Grandel 7db0184e1b drivers: ieee802154: nRF5: remove RX PHR offset workaround
Builds upon the newly introduced nrf_802154_phr_timestamp_get() function
to calculate RX timestamps according to the timestamp definitions
introduced in earlier commits and removes the prior workaround to
calculate the start-of-frame message timestamp point.

Fixes: #59245

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-08-16 17:06:16 +02:00
Florian Grandel eacec3dad2 modules: openthread: radio: encapsulate OT 32-bit timestamp
OT does not have 64 bit timestamp support. This is a limitation of OT
and not of the IEEE 802.15.4 driver API. Therefore any workaround
related to such OT idiosyncracies should be encapsulated inside the OT
adapatation layer.

This change moves the OT-specific conversion of OT 32 bit timestamps to
Zephyr 64 bit timestamps into the OT adaptation layer.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-08-16 17:06:16 +02:00
Florian Grandel a4cd5cee40 drivers: ieee802154: consistent high res timestamps
The IEEE 802.15.4 API and networking subsystem were using several
inconsistent timestamp resolutions and types. This change defines all
timestamps with nanosecond resolution and reduces the number of
available types to represent timestamps to two:
* `struct net_ptp_time` for PTP timestamps
* `net_time_t` for all other high resolution timestamps

All timestamps (including PTP timestamps) are now referred to a
"virtual" local network subsystem clock source based on the well-defined
types above. It is the responsibility of network subsystem L2/driver
implementations (notably Ethernet and IEEE 802.15.4 L2 stacks) to ensure
consistency of all timestamps and radio timer values exposed by the
driver API to such a network subsystem uptime reference clock
independent of internal implementation details.

The "virtual" network clock source may be implemented based on arbitrary
hardware peripherals (e.g. a coarse low power RTC counter during sleep
time plus a high resolution/high precision radio timer while receiving
or sending). Such implementation details must be hidden from API
clients, as if the driver used a single high resolution clock source
instead.

For IEEE 802.15.4, whenever timestamps refer to packet send or receive
times, they are measured when the end of the IEEE 802.15.4 SFD (message
timestamp point) is present at the local antenna (reference plane).

Due to its limited range of ~290 years, net_time_t timestamps (and
therefore net_pkt timestamps and times) must not be used to represent
absolute points in time referred to an external epoch independent of
system uptime (e.g.  UTC, TAI, PTP, NTP, ...).

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-07-28 09:06:35 +00:00
Florian Grandel 4edf46d86c net: l2: ieee802154: radio: fix radio utils naming
The IEEE 802.15.4 stack defines radio API helpers that provide
simplified and encapsulated access to radio API features.

These helpers were missing the `_radio_` infix. This infix is introduced
to clearly distinguish between MAC and PHY concerns. While PHY features
may be shared between L2 implementations (including the functions
concerned here), this is not true for MAC features.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-07-10 09:29:10 +02:00
Florian Grandel 1ee4d3ed77 net: l2: ieee802154: document L1/L2 sep. of concerns
The method ieee802154_radio_handle_ack() does not belong to the
PHY/radio layer but to the L2 layer. It is a callback called from the
radio layer into the L2 layer and to be implemented by all L2 stacks.
This is the same pattern as is used for ieee802154_init(). The
'_radio_' infix in this function is therefore confusing and
conceptually wrong.

This change fixes the naming inconsistency and extensively documents
its rationale.

It is assumed that the change can be made without prior deprecation of the
existing method as in the rare cases where users have implemented custom
radio drivers these will break in obvious ways and can easily be fixed.

Nevertheless such a rename would not be justified on its own if it were
not for an important conceptual reason:

The renamed function represents a generic "inversion-of-control" pattern
which will become important in the TSCH context: It allows for clean
separation of concerns between the PHY/radio driver layer and the
MAC/L2 layer even in situations where the radio driver needs to be
involved for performance or deterministic timing reasons. This
"inversion-of-control" pattern can be applied to negotiate timing
sensitive reception and transmission windows, it let's the L2 layer
deterministically timestamp information elements just-in-time with
internal radio timer counter values, etc.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-06-17 16:20:21 -04:00
Florian Grandel b224a099fd net: l2: ieee802154: standardize RSSI value
The RSSI value in net_pkt (net_pkt_cb_ieee802154.rssi) was used
inconsistently across drivers. Some drivers did cast a signed dBm value
directly to net_pkt's unsigned byte value. Others were assigning the
negative value of the signed dBm value and again others were offsetting
and stretching the signed dBm value linearly onto the full unsigned byte
range.

This change standardizes net_pkt's rssi attribute to represent RSSI on
the RX path as an unsigned integer ranging from 0 (–174 dBm) to 254 (80
dBm) and lets 255 represent an "unknown RSSI" (IEEE 802.15.4-2020,
section 6.16.2.8). On the TX path the rssi attribute will always be
zero. Out-of-range values will be truncated to max/min values.

The change also introduces conversion functions to and from signed dBm
values and introduces these consistently to all existing call sites. The
"unknown RSSI" value is represented as INT16_MIN in this case.

In some cases drivers had to be changed to calculate dBm values from
internal hardware specific representations.

The conversion functions are fully covered by unit tests.

Fixes: #58494

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-06-17 07:16:32 -04:00
Robert Lubos f3bdac91b2 net: ieee802154: Remove IEEE802154_2015 option usage
The IEEE802154_2015 option is misleading, as it does not introduce full
802.15.4-2015 standard compliance but only random bits, plus it's
defined at the radio driver level, which brings yet another confusion.
Because of that, the option will be deprecated, and respective parts of
code that made use of it converted to use more specific configurations:

* nRF driver will now use CONFIG_NRF_802154_ENCRYPTION to specify
  whether to compile in TX security
* net_pkt will only add extra 802.15.4 control block fields if
  OpenThread is used, as they were solely used by this L2
* OpenThread radio layer will now use the OpenThread version to
  determine whether to compile in TX security.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-06-01 04:53:02 -04:00
Eduardo Montoya 760d8fc970 modules: openthread: align received frame timestamp to SFD
OpenThread requires that the `mTimestamp` parameter from the `mRxInfo`
struct points to the end of SFD, i.e. beggining of PHR.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2023-04-19 17:15:02 +02:00
Eduardo Montoya 2c4cf25836 modules: openthread: fix handling tx done when sleep to tx is supported
After `otPlatRadioSleep` was fixed to properly set radio state to sleep,
radios supporting `IEEE802154_HW_SLEEP_TO_TX` capability would not be
able to handle `PENDING_EVENT_TX_DONE` while in sleep state.

This commit fixes such case.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2023-04-19 17:13:32 +02:00
Przemyslaw Bida dc5155e5a5 openthread: ieee802154_nrf5: Add implementation of new api.
Adding an Openthread radio API `otPlatRadioSetMacFrameCounterIfLarger`
implementation and the corresponding call to the IEEEE802154 driver.

Signed-off-by: Przemyslaw Bida <przemyslaw.bida@nordicsemi.no>
2023-03-08 11:07:22 +01:00
Maciej Baczmanski e84f246c66 modules: openthread: add otPlatDiagRadioTransmitCarrier
added `otPlatDiagRadioTransmitCarrier` functionality

disabled OT power calibration support

fixed wrong check of `radio_api->stop()` return value
in `otPlatRadioSleep()`

Signed-off-by: Maciej Baczmanski <maciej.baczmanski@nordicsemi.no>
2023-02-24 09:26:01 +01:00
Arkadiusz Balys 3afd564bba modules: openthread: platform: Added setting default tx power
There were some requests from users for adding the possibility
of setting default openthread tx output power using kConfig.
It is possible by adding the CONFIG_OPENTHREAD_DEFAULT_TX_POWER
kConfig and assigning it to the tx_power variable in the radio.c
file in the Openthread module.

Added the possibility to set default openthread power using
kConfig.

Signed-off-by: Arkadiusz Balys <arkadiusz.balys@nordicsemi.no>
2022-12-21 12:21:09 +01:00
Erwan Gouriou 66d4c64966 all: Fix "#if IS_ENABLED(CONFIG_FOO)" occurrences
Clean up occurrences of "#if IS_ENABLED(CONFIG_FOO)" an replace
with classical "#if defined(CONFIG_FOO)".

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2022-12-21 10:09:23 +01:00
Eduardo Montoya 78cf49e0fd net: openthread: fix otPlatRadioSetMacKey when asserts are disabled
Ensure `otPlatRadioSetMacKey` is properly implemented when asserts are
disabled.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2022-11-23 11:37:24 +01:00
Robert Lubos 387a66131e net: pkt: Introduce minimum length requirement to net_pkt_get_frag()
net_pkt_get_frag() and a few other functions did not specify the
allocated fragment length, incorrectly assuming that fixed-sized
buffers are always used.

In order to make the function work properly also with variable-sized
buffers, extend the function argument list with minimum expected
fragment length parameter. This allows to use net_buf_alloc_len()
allocator in variable buffer length configuration, as well as verify if
the fixed-sized buffer is large enough to satisfy the requirements
otherwise.

Update the existing codebase to provide the expected fragment length,
based on the context.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-11-19 07:39:32 -05:00
Florian Grandel f1e9dd2930 drivers: ieee802154: properly announce promisc mode
Most IEEE 802.15.4 drivers do not support promiscuous mode, some do.
There is a dedicated L2 flag to signal this capability to clients.

Unfortunately the IEEE 802.15.4 L2 stack does not announce this flag
even for drivers that correctly expose it in their HW capabilities.
Some clients (notably the OpenThread L2) even uses promiscuous mode
without checking whether the driver actually supports it.

This change lets the vanilla IEEE 802.15.4 L2 check the driver's
HW capabilities to announce promiscuous mode on its 'get_flags()'
interface if supported.

The OpenThread L2 uses a constant (potentially incorrect) response
to 'get_flags()'. Fixing the OpenThread L2 is out of scope of this
change. This change just introduces TODO messages to the OpenThread code
so that the OpenThread team may fix the issue (or delete the TODO if they
deem it irrelevant).

Fixes: #51263

Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
2022-10-17 16:54:37 +02:00
Gerard Marull-Paretas 8faa7b8891 modules: openthread: use zephyr,ieee802154 choice
Use chosen ieee802154 device from DT since
CONFIG_NET_CONFIG_IEEE802154_DEV_NAME is being phased out.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-10 11:57:34 +02:00
Robert Lubos 815ebc316e net: openthread: Move glue code into module directory
Move OpenThread's glue code along with the Kconfig files that configure
OpenThread stack itself into module directory.

Update the maintainers file to reflect this change.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-07-11 11:00:12 +02:00
Renamed from subsys/net/lib/openthread/platform/radio.c (Browse further)