Commit graph

550 commits

Author SHA1 Message Date
Jędrzej Ciupis b457645423 drivers: ieee802154: nrf5: fix default value for nRF54H20
The default value of IEEE802154_NRF5_DELAY_TRX_ACC Kconfig option is
based on a symbol that is undefined for nRF54H20. It evaluates as empty,
which leads to compilation errors with very cryptic logs.

This commit assures that a sane value for IEEE802154_NRF5_DELAY_TRX_ACC
is selected at all times, avoiding the compilation errors.

Signed-off-by: Jędrzej Ciupis <jedrzej.ciupis@nordicsemi.no>
2024-05-13 10:21:08 +02:00
Jędrzej Ciupis 774dd16555 drivers: ieee802154: gracefully handle invalid Ack timestamp
The nRF IEEE 802.15.4 driver might report a received Ack frame with
invalid timestamp, if the timestamp could not have been taken. The upper
layers are not prepared to handle such a case as they expect that for a
received frame, the timestamp is always present and valid.

This commit detects this situation and handles it gracefully by
reporting the transmission as failed as if no Ack was received.

Signed-off-by: Jędrzej Ciupis <jedrzej.ciupis@nordicsemi.no>
2024-04-09 07:37:10 -04:00
Fin Maaß 9e8e21b36f drivers: ieee802154: use sys_rand_get directly
use sys_rand_get() directly.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-04-05 12:28:46 +02:00
Georgios Vasilakis 7a8d454e22 soc: nordic: Refactor soc_secure.h
The soc_secure_* function are used by the non-secure application
to access hardware resources which are mapped as secure.
Using these functions for hardware resources mapped as non-secure
is missleading.

We have some soc_secure_* functions which read FICR values.
In nRF91 and nRF53 platforms this made sense since FICR
has hardware fixed mapping as secure.
For nRF54 though the FICR has hardware fixed mapping as non-secure.

This change refactors the soc_secure.h to exclude the functions
which read FICR values from being included when FICR is mapped as
non-secure.

Also updates the hwinfo and ieee802154 drivers to adjust to this change.

Signed-off-by: Georgios Vasilakis <georgios.vasilakis@nordicsemi.no>
2024-04-04 13:17:13 -05:00
Andrzej Kuros 8e8d4af6c1 drivers: ieee802154_nrf5: Use Radio IRQ number from DT
Used RADIO_IRQ number is based on information provided by DT rather
than direct use of RADIO_IRQn.

Signed-off-by: Andrzej Kuroś <andrzej.kuros@nordicsemi.no>
2024-03-05 12:22:08 +01:00
Tomasz Bursztyka af85c8a11d drivers/ieee802154: Use net_pkt API for reading data on upipe driver
Some legacy left overs.
Just simplifying how to read data into a net_pkt.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2024-03-01 15:33:53 +01:00
Ayush Singh 7c9dbde659 ieee802154: ieee802154_cc13xx_cc26xx_subg: Fix 6lowpan for cc1352p7
- Fix using custom setup function
- Enable pRegOverrideTxStd and pRegOverrideTx20 in
  ieee802154_cc13xx_subg_radio_div_setup struct

Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com>
2024-02-17 21:14:30 +01:00
Maciej Baczmanski dbe74b3299 Revert "drivers: ieee802154: nrf: cache radio channel"
This reverts commit 780b12854c.
"drivers: ieee802154: nrf: cache radio channel"

Implementation affected RCP devices in openthread as MAC layer
does not call `Receive()` functions after transmit is done.

Additionally, after sending a frame to a new channel (for example
while discovery operation), radio switches to RX state immediately
after TX, but continues to listen on old channel for about 5ms,
until MAC layer calls `Receive` operation, forcing to change the
channel.

Signed-off-by: Maciej Baczmanski <maciej.baczmanski@nordicsemi.no>
2024-02-07 15:35:29 +00: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 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
Jędrzej Ciupis 8f9a86cf5e drivers: ieee802154: fix nRF5 Rx error handling
The current implementation implicitly assumes that if the device is
configured to have the capability of acting as a CSL endpoint then in
case a delayed reception with matching ID finishes with a timeout no
action is needed. This assumption is correct when RxOnWhenIdle mode is
disabled because the transition to sleep is done automatically by the
driver below. However, it's wrong when RxOnWhenIdle is enabled. This
commit fixes that case by adding a call to event handler that notifies
the higher layer about the event and allows it to transition to RxOff if
needed.

Signed-off-by: Jędrzej Ciupis <jedrzej.ciupis@nordicsemi.no>
2024-01-19 07:25:43 -06:00
Gerard Marull-Paretas 87bb281a9f drivers: ieee802154: b91: add missing PLIC include
Driver was using RISC-V PLIC API without including the necessary
headers.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2024-01-15 09:58:03 +01:00
Pisit Sawangvonganan 80e1482ddd drivers: ieee802154: set 'ieee802154_radio_api' as 'static const'
This change marks each instance of the 'api' as 'static const'.
The rationale is that 'api' is used for declaring internal
module interfaces and is not intended to be modified at runtime.
By using 'static const', we ensure immutability, leading to usage of only
.rodata and a reduction in the .data area.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-01-05 09:04:28 +01:00
Eduardo Montoya 586eca8ad2 drivers: ieee802154: nrf5: add IEEE802154_RX_ON_WHEN_IDLE capability
Add `IEEE802154_RX_ON_WHEN_IDLE` capability.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2024-01-05 09:04:17 +01:00
Eduardo Montoya 780b12854c drivers: ieee802154: nrf: cache radio channel
Cache configured radio channel and apply them only when a relevant
radio task is requested.

This allows to configure the channel in the transmit metadata, thus
avoiding unneeded `nrf_802154` API calls in some scenarios.

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
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
Jędrzej Ciupis 0bad09c7fa drivers: ieee802154: nrf5: support raw mode
When CONFIG_IEEE802154_RAW_MODE is set there is no network interface
that could provide pointer to the device the interface is running on top
of. The current implementation of nRF5 ieee802154 driver implicitly
assumes that such an interface is always present, which leads to crashes
when raw mode is enabled.

This commit adds support for IEEE802154_RAW_MODE in nRF5 ieee802154
driver by latching pointer to the ieee802154 device on initialization if
needed so that it doesn't have to be retrieved using the network
interface in run-time.

Signed-off-by: Jędrzej Ciupis <jedrzej.ciupis@nordicsemi.no>
2023-11-24 09:25:11 +01:00
Jamie McCrae 90dfbf99d8 drivers: ieee802154: nrf5: Fix missed variable rename
Fixes and issue with a variable that has been renamed but whose
reference in the source file has not

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-11-22 09:54:23 +01:00
Ayush Singh 27fe62c33f ieee802154: ieee802154_cc13xx_cc26xx_subg: Add cc1352p7 support
- Add support cc1352p7 used by beagleconnect_freedom
- Since this is a multi interface device, auto config does not work.

Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com>
2023-11-11 18:49:25 -05:00
Alberto Escolar Piedras 4df07224f8 drivers ieee802154_nrf5: Fix infinite loop for simulation on stop
With CSL enabled, when nrf5_stop is called,
nrf_802154_sleep_if_idle() will be called, and if the radio is
busy with another task, another IEEE802154_EVENT_RX_OFF event
will be pended right away, resulting in another call
to nrf5_stop(), effectively busy waiting until the
radio has reached idle.

In simulation, this whole operation (busy wait loop) is
done without letting the CPU sleep, in an infinite loop,
and therefore without letting any time pass
(note that in the POSIX architecture,
no time passes if the CPU does not go to sleep).
And therefore the radio will never be done with whatever
it is doing, resulting in the simulation being stuck
in this loop.

Let's add a very minor delay to this loop, which is
conditionally compiled only for the POSIX architecture.
Which effectively mimics the time it takes for the CPU
to loop thru, let's time pass, and allows the radio
to eventually be done.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-11-08 11:07:30 +01:00
Eduardo Montoya 3676e7c360 drivers: ieee802154: nrf5: set security enabled bit value
Assign `ack_seb` in `net_pkt_cb_ieee802154`.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2023-11-03 09:57:53 +01:00
Eduardo Montoya 09758f21e3 drivers: ieee802154: nrf: limit number of serialized calls
For serialized nRF IEEE 802.15.4 Driver host, avoid using
`nrf_802154_csl_writer_anchor_time_set` too often by caching the CSL
RX time and period and using them to detect any shift on the periodic
pattern.

This improves power consumption by limiting the number of serialized calls.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2023-11-01 11:02:25 +00:00
Benedikt Schmidt 9eb993c063 drivers: ieee802154: fix thread function signatures
Fix thread function signatures to avoid stack corruption on thread exit.

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
2023-10-30 12:24:34 +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 f3cbd27e5a drivers: ieee802154: cc13xx_cc26xx_subg: buflen sanity check
Introduces a (currently redundant) buffer length sanity check to prepare
for L2s that support PHYs with PHY payloads > 127 bytes.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-10-17 19:15:56 +03:00
Florian Grandel 0269170420 drivers: ieee802154: b91: buflen sanity check
Introduces a (currently redundant) buffer length sanity check to prepare
for L2s that support PHYs with PHY payloads > 127 bytes.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-10-17 19:15:56 +03:00
Flavio Ceolin e7bd10ae71 random: Rename random header
rand32.h does not make much sense, since the random subsystem
provides more APIs than just getting a random 32 bits value.

Rename it to random.h and get consistently with other
subsystems.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-10-10 14:23:50 +03:00
Florian Grandel 4b0e730fb1 drivers: ieee802154: cc13xx_cc26xx_subg: check radio op status
Not only the return code of TI's RF command queueing mechanism but also
the command status need to be checked to assert that a command was
executed successfully. This change introduces additional checking of the
command status.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-10-05 12:01:29 +03:00
Florian Grandel f2979edd5c drivers: ieee802154: cc13xx_cc26xx_subg: fix initial CMD_FS
The frequency synchronization command requires a proper frequency to be
set in order to be successfully executed. The command not being executed
leads to unnecessary internal error handling wrt command scheduling.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-10-05 12:01:29 +03:00
Florian Grandel 0c1c443fc6 drivers: ieee802154: cc13xx_cc26xx_subg: improve readability
Moves the RX callback closer to where it's actually being used also
removing the necessity to declare a function prototype.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-10-05 12:01:29 +03:00
Florian Grandel fce4788415 drivers: ieee802154: cc13xx_cc26xx_subg: fix oper. state
The driver API now distinguishes between operational UP/DOWN states as
required by Zephyr's network API and receiver on/off states as an
internal driver state for improved standard conformance.

This change closes the gap between the driver API requirements and the
implementation in this respect.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-10-05 12:01:29 +03:00
Florian Grandel 016d3bed5c drivers: ieee802154: cc13xx_cc26xx_subg: improve locking
Replaces the mutex by a semaphore for ISR readiness as requested by the
driver API specification.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-10-05 12:01:29 +03:00
Florian Grandel 26a0ef15c4 drivers: ieee802154: cc13xx_cc26xx_subg: check for RX up
Checks whether the receiver is already on before trying to switch it on.
This also closes a gap wrt the driver API specification.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-10-05 12:01:29 +03:00
Florian Grandel 35cfe00e91 drivers: ieee802154: cc13xx_cc26xx_subg: remove redundant code
Removes redunant reset statements that update immutable data.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-10-05 12:01:29 +03:00
Florian Grandel 128354ae17 drivers: ieee802154: cc13xx_cc26xx_subg: simplify static funcs
Restructuring and renaming of driver-internal functions for improved
readability and maintainability:
- distinguish between externally exposed API methods
  (cc13xx_cc26xx_sub_* prefix) and internal helper methods
  (drv_* prefix).
- extract a few functions to reduce complexity and improve re-use

Also removes unnecessary initial runtime blanking of static (.bss) data
in the newly introduced extracted buffer initialization functions.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-10-05 12:01:29 +03:00
Florian Grandel c81c38114a drivers: ieee802154: cc13xx_cc26xx_subg: minor cleanup
Cleans up includes and a few other minor non-functional errors in the
CC13/26xx driver.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-10-05 12:01:29 +03:00
Florian Grandel 7ac34d0957 drivers: ieee802154: cc13xx_cc26xx_subg: fix timing regression
Fixes a timing regression introduced by commit
a12a6ab5b9.

This caused a massively increased package error rate.

Fixes: #63324.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-10-02 15:53:45 -04: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 a12a6ab5b9 drivers: ieee802154: introduce channel pages
Replaces the previous approach to define bands via hardware capabilities
by the standard conforming concept of channel pages.

In the short term this allows us to correctly calculate the PHY specific
symbol rate and several parameters that directly depend from the symbol
rate and were previously not being correctly calculated for some of the
drivers whose channel pages could not be represented previously:
* We now support sub-nanosecond precision symbol rates for UWB. Rounding
  errors are being minimized by switching from a divide-then-multiply
  approach to a multiply-then-divide approach.
* UWB HRP: symbol rate depends on channel page specific preamble symbol
  rate which again requires the pulse repetition value to be known
* Several MAC timings are being corrected based on the now correctly
  calculated symbol rates, namely aTurnaroundTime, aUnitBackoffPeriod,
  aBaseSuperframeDuration.

In the long term, this change unlocks such highly promising functional
areas as UWB ranging and SUN-PHY channel hopping in the SubG area (plus
of course any other PHY specific feature).

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-09-27 12:44:15 -04:00
Florian Grandel 7c00b81705 drivers: ieee802154: cc13xx_cc26xx: readability improvement
Aligns the name of the return value variable with what is used elsewhere
in the driver and the subsystem for improved readability and
consistency.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-09-27 12:44:15 -04:00
Florian Grandel ea6248b870 drivers: ieee802154: cc1200: SUN-FSK compatibility
Preparative change to introduce build-time configured channel pages.
This fixes the description of the driver's available PHYs and makes
channel page and channel range independent from runtime attributes.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-09-27 12:44:15 -04:00
Gerson Fernando Budke 037618a638 drivers: ieee802154: rf2xx: Fix rx promiscuous behaviour
When radio is set to promiscuous mode it is desirable to receive
invalid frames. This skip a few checks and allow an invalid and
non-standard frames be delivered for diagnose.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2023-09-27 09:53:08 +02:00
Gerson Fernando Budke 12720fec51 drivers: ieee802154: rf2xx: Fix rf231 invalid frame
The at86rf231 frame buffer access mode read differs from all other
transceivers by only transfer one more byte after PSDU data instead
three. This difference is not evaluated in the current version of
the driver. The current change add the necessary check and read the
missing data (EQ, TRAC).

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2023-09-25 09:52:28 +02:00
Piotr Dymacz 22f6c87afc drivers: ieee802154: cc13xx_cc26xx{_subg}: fix reversed extended address
Based on the 'Technical Reference Manual' for CC13x2/CC26x2 SimpleLink
MCU family, the device contains factory pre-programmed 64-bit IEEE MAC
address for 802.15.4 radio inside two FCFG 32-bit registers:

  1. MAC_15_4_0: first 32-bit of the 64-bit IEEE MAC address
  2. MAC_15_4_1:  last 32-bit of the 64-bit IEEE MAC address

The way current version of the driver setups the address results in
incorrect bytes order (the address is reversed):

  uart:~$ ieee802154 get_ext_addr
  Extended address: AF:03:B7:25:00:4B:12:00

This fixes the problem in both drivers (also in the Sub-GHz version)
which results in use of proper EUI-64 address:

  uart:~$ ieee802154 get_ext_addr
  Extended address: 00:12:4B:00:25:B7:03:AF

IEEE MAC address was confirmed with UniFlash, nRF Sniffer for 802.15.4
and IEEE OUI database (00:12:4B is one of registered OUI for Texas
Instruments).

To prevent confusion in future, short notice about bytes order for
'mac' field in driver's data structures was also included.

Signed-off-by: Piotr Dymacz <pepe2k@gmail.com>
2023-08-30 10:23:50 +02:00
Nick Ward 2d65acca3a drivers: gpio: use gpio_is_ready_dt helper function
Update `struct gpio_dt_spec` use with gpio_is_ready_dt()

Signed-off-by: Nick Ward <nix.ward@gmail.com>
2023-08-28 08:48:35 -05:00
Andrzej Kuros 04d3dcb116 drivers: ieee802154_nrf5: energy_detected api change adjust
The prototype of `nrf_802154_energy_detected` callout has changed.
This commit adjusts to this change.

Signed-off-by: Andrzej Kuroś <andrzej.kuros@nordicsemi.no>
2023-08-20 19:31:21 +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