Commit graph

21541 commits

Author SHA1 Message Date
Vinayak Kariappa Chettimada
6916eb97ac Bluetooth: controller: openisa: Preempt timeout for next in pipeline
Start new preempt timeout for the next in pipeline when a
new event gets active.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-05-06 15:39:16 +02:00
Vinayak Kariappa Chettimada
8edc998332 Bluetooth: controller: nRF5: Preempt timeout for next in pipeline
Start new preempt timeout for the next in pipeline when a
new event gets active.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-05-06 15:39:16 +02:00
Vinayak Kariappa Chettimada
aeafc9ede5 Bluetooth: controller: openisa: Sync up LLL changes
Sync up with missing LLL changes done related to moving the
handling of pipeline handling into LLL.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-05-06 15:39:16 +02:00
Joakim Andersson
396450b72b Bluetooth: shell: Update L2CAP chan send to reserve for an L2CAP SDU
Update the L2CAP channel send command to correctly reserve the number
of bytes needed for an L2CAP SDU.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-05-06 14:56:18 +02:00
Joakim Andersson
f0e6b400e4 Bluetooth: OTS: Update OTS to use correct reserve define
Update the L2CAP OTS implementation to use the correct reserve
defitition. By not using the correct definition the stack always
allocates a new segment for the packet, which puts more stress on the
stack buffers.
Update TX data size to be more intuitive by adding the overhead, instead
of subtracting it. This increases the default MTU of the implementation.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-05-06 14:56:18 +02:00
Joakim Andersson
11bfbf83ee Bluetooth: shell: Add argument to L2CAP send command for packet length
Add argument to the L2CAP channel send command so that the user can
determine the length of the packet to send, this is useful for testing
various segmentation scenarios.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-05-06 14:56:18 +02:00
Joakim Andersson
69613626ed Bluetooth: host: Document L2CAP channel send buffer sizes
Update the documentation for L2CAp Connection oriented channel send
function to include better description of the L2CAP PDUs (Basic frames)
and L2CAP SDUs (Credit-based frames) so that the application can better
understand how to size the buffer pools and setting the RX mtu.
Document stack behavior on RX path and how the application has to
set up the channel in order to receive segmented packets.
Document stack behavior on TX path for reserving either mandatory or
optional header bytes.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-05-06 14:56:18 +02:00
Joakim Andersson
6483e12a8a Bluetooth: Refactor bluetooth buffer configuration for simplification
Refactor and simplify the bluetooth buffer configurations to improve the
easy of configurations and eliminate invalid ones.
By moving configurations out of host and controller specific
configurations and into a common one it becomes easier to configure
the host and controller separately as the same configurations can be
used as would be for a combined build.

All HCI configurations are now given exluding the matching HCI header,
which eases the configuration as the application don't have to know the
different header sizes.
The BT_RX_BUF_LEN is split into ACL and Event, as well as the suprising
use of Command size.
BT_L2CAP_RX_MTU is removed as the stack does not support reassembling of
HCI ACL data to larger L2CAP PDUs. The application will have to set
ACL RX size and account for the L2CAP PDU header itself.
BT_EATT_RX_MTU was removed as it is only used for setting a different
default value for another option which leads to the stuck kconfig symbol
problem.

The configurations can be updated according to the table below:

** New configuration         | ** Old configuration
All configurations
BT_BUF_ACL_RX_SIZE           | BT_L2CAP_RX_MTU + 4
BT_BUF_ACL_RX_SIZE           | BT_RX_BUF_LEN - 4
BT_BUF_EVT_RX_SIZE           | BT_RX_BUF_LEN - 2
BT_BUF_CMD_TX_SIZE           | BT_RX_BUF_LEN - 3
BT_BUF_CMD_TX_COUNT          | BT_HCI_CMD_COUNT
BT_BUF_EVT_RX_COUNT          | BT_RX_BUF_COUNT
BT_BUF_ACL_RX_COUNT          | BT_RX_BUF_COUNT
BT_BUF_ACL_RX_COUNT          | BT_ACL_RX_COUNT
BT_BUF_EVT_DISCARDABLE_SIZE  | BT_DISCARDABLE_BUF_SIZE - 2
BT_BUF_EVT_DISCARDABLE_COUNT | BT_DISCARDABLE_BUF_COUNT
Controller-build
BT_BUF_ACL_TX_SIZE           | BT_CTLR_TX_BUFFERS_SIZE
BT_BUF_ACL_TX_COUNT          | BT_CTLR_TX_BUFFER
HCI-bridge
BT_BUF_ACL_TX_SIZE           | BT_HCI_ACL_DATA_SIZE
BT_BUF_ACL_TX_COUNT          | 6

Fixed invalid configurations setting either BT_L2CAP_RX_MTU or
BT_CTLR_DATA_LENGTH_MAX larger than BT_RX_BUF_LEN could lead to buffer
overruns.

Fix advertising report max data length calculation.
This always used the BT_DISCARDABLE_BUF_SIZE macro but this feature
can be turned off and advertising reports will be allocated from the RX
buffer in that case. Also controller-build does not have this buffer
(in hci_raw.c). Also the wrong HCI header was used in the calculation,
HCI event header should have been used instead of HCI ACL header.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-05-06 14:56:18 +02:00
Joakim Andersson
7b7b17a495 Bluetooth: Mesh: Set L2CAP TX MTU default to fit public key packet
Set the L2CAP TX MTU default to fit the public key packet in a single
L2CAP fragment. This matches the configuration for RX buffer lengths
being set with this configuration.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-05-06 14:56:18 +02:00
Joakim Andersson
a8d9373b94 Bluetooth: Kconfig: Remove discardable dependency on implementations
Remove discardable buffer dependency on the specific implementations
except for HCI raw.
All of the in-tree Host-side HCI drivers have implemented discardable
buffer behavior.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-05-06 14:56:18 +02:00
Joakim Andersson
eba6350a12 Bluetooth: host: Add macros for calculating buffer sizes
Add macros for calculating buffer sizes, accounting for the various
L2CAP and HCI headers needed as well as the reserved bytes needed.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-05-06 14:56:18 +02:00
Eduardo Montoya
93fda9356f net: openthread: complete CSL receiver API
This commit implements the missing OpenThread APIs related to CSL
receiver configuration.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2021-05-06 07:47:10 -05:00
Vinayak Kariappa Chettimada
d54d75b6fd Bluetooth: controller: nRF5: Add radio ready time save and restore
Added radio interface to save and restore radio ready
timestamp. This will be saved between ISO Subevents and
used in done event for anchor point synchronization and
drift compensation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-05-06 12:18:10 +02:00
Laczen JMS
a71a8dbfca nvs: hardening against bad sector close
A badly written sector close ate that has correct crc8 could allow
jumps outside the assigned flash area. This behavior is fixed.

A possibility existed that a badly erased sector or a incomplete write
of a large item created a empty closed sector. This has been fixed by:
a. Erase verification.
b. Clearing such a sector at startup.

Fixes #34382

Signed-off-by: Laczen JMS <laczenjms@gmail.com>

Co-Authered-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2021-05-06 11:10:05 +02:00
Joakim Andersson
cc401820f3 Bluetooth: shell: Update L2CAP to use new delayable work API
Update shell L2CAP to use the new delayable work API for the delayed
received confirmation response.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-05-05 19:44:09 -04:00
Joakim Andersson
92d80d50b9 Bluetooth: host: Update GATT to use new delayable work API
Update GATT to use the new delayable work API for the delayed
calculation of the database hash and the service changed indication.

When the database hash characteristic is read the hash work needs to be
canceled if in progress and if currently executing wait for it to
complete so that the threads don't both write to the stored value.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-05-05 19:44:09 -04:00
Joakim Andersson
8fcb4318f7 Bluetooth: host: Update connections to use new delayable work API
Update the connections to use the new delayable work API for the
deferred work host timer.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-05-05 19:44:09 -04:00
Joakim Andersson
a14b9145e4 Bluetooth: host: Update AVDTP to use new delayable work API
Update AVDTP to use the new delayable work API for the send host timer.
The AVDTP protocol is incomplete, there is no cancelation of the timer
but it is also never started, as there is no users of the internal
functions, and no public functions exists.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-05-05 19:44:09 -04:00
Joakim Andersson
9c62841b58 Bluetooth: controller: Update privacy to use new delayable work API
Update the implementation of controller based privacy to use the new
delayable work API for the RPA timer. Always use schedule for the
timer since RPAs should not be used more than the configured RPA
timeout.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-05-05 19:44:09 -04:00
Joakim Andersson
b9ea5d9910 Bluetooth: host: Update RFCOMM to new delayable work API
Update RFCOMM to use the new delayable work API for the RTX host timer
used for disconnecting and idling.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-05-05 19:44:09 -04:00
Joakim Andersson
83dc781702 Bluetooth: host: Update ATT to use the new delayable work API
Update ATT to use the new delayable work API for the transaction
host timer.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-05-05 19:44:09 -04:00
Joakim Andersson
8e85259e7b Bluetooth: host: Update SMP to use new delayable work API
Update SMP to use the new delayable work API for the pairing procedure
host timer.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-05-05 19:44:09 -04:00
Joakim Andersson
afc29f3a1c Bluetooth: host: Update L2CAP to use the new delayable work API
Update L2CAP to use the new delayable work API for the signaling
RTX host timer.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-05-05 19:44:09 -04:00
Joakim Andersson
7a7afa570b Bluetooth: host: refactor SMP channel context layout
Refactor the SMP channel context to in order to simplify the memset of
the struct in smp_init. This makes the code easier to read, and easier
to add more structs that should not be reset by memset.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-05-05 19:44:09 -04:00
Joakim Andersson
52a21a9478 Bluetooth: host: Update RPA timer to new delayable work API
Update the RPA timer to the new delayable work API.
Checking for submitted RPA timer no longer needed with the schedule
function, which does not change the deadline.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-05-05 19:44:09 -04:00
Gerard Marull-Paretas
56f1a8ce98 pm: rename PM_DEVICE_GET/SET_POWER_STATE to PM_DEVICE_STATE_GET/SET
Adjust name to be consistent with device PM naming conventions.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-05 18:35:49 -04:00
Gerard Marull-Paretas
6633b05530 pm: move device_pm.c to device_runtime.c
File name should reflect what it contains.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-05 18:35:49 -04:00
Gerard Marull-Paretas
7988ab4a26 pm: rename device_set/get_power_state to pm_device_set/get
Make name consistent with other device PM APIs.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-05 18:35:49 -04:00
Gerard Marull-Paretas
1e50e08bca pm: move device_set/get_power_state to pm/device.h
These are device PM APIs, so move them to the device PM API header.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-05 18:35:49 -04:00
Gerard Marull-Paretas
7bfd3a11f3 device: rename device_pm_control to pm_control
Remove device_ prefix since it is redundant.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-05 18:35:49 -04:00
Gerard Marull-Paretas
570b43a70e pm: rename device_pm_state_str to pm_device_state_str
Prefix all device PM functions/data structures with pm.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-05 18:35:49 -04:00
Gerard Marull-Paretas
d31a9be27c pm: device: rename device_pm struct to pm_device
Prefix all PM related functions/structures with pm.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-05 18:35:49 -04:00
Gerard Marull-Paretas
2c7b763e47 pm: replace DEVICE_PM_* states with PM_DEVICE_*
Prefix device PM states with PM.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-05 18:35:49 -04:00
Gerard Marull-Paretas
ddfd27dbfb pm: replace power/power.h with pm/pm.h
Replace old header with the new one.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-05 18:35:49 -04:00
Gerard Marull-Paretas
c524075780 pm: runtime: rename API with pm_device prefix
Use `pm_device_*` prefix for the device runtime PM API. This adds the
API to the `pm` namespace, making it clear part of the PM subsystem.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-05 18:35:49 -04:00
Gerard Marull-Paretas
f69759d34a pm: rename CONFIG_PM_DEVICE_IDLE to CONFIG_PM_DEVICE_RUNTIME
Make naming clear on the purpose of this option.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-05 18:35:49 -04:00
Gerard Marull-Paretas
0aa3df06c2 pm: move private enum to source using it
`enum device_pm_state` is not used publicly, so move it to the source
using it.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-05 18:35:49 -04:00
Gerard Marull-Paretas
99cbee3f16 pm: move power subsystem to pm
Adjust naming to make things consistent.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-05 18:35:49 -04:00
Gerard Marull-Paretas
25bb163dc2 pm: reorganize headers
- Move PM related APIs to `include/pm` so that it follows API `pm_`
  prefix namespace. In order to make transition easier
  `include/power/power.h` is kept pointing to `include/pm/pm.h`.
- Move most of device PM related content from `include/device.h` to
  `include/pm/device.h` and `include/pm/runtime.h`.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-05 18:35:49 -04:00
Robert Lubos
126da28620 net: lwm2m: Trigger registration update only when registered
Add extra check for the LwM2M client state, to allow triggering of the
Registration Update message only when registered.

This fixes an issue, when the `trigger_update` flag could be set during
the bootstrap procedure (when the value of the Lifetime resource was
set), which resulted in an uneccessary Registration Update message just
after the successful registration.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-05-05 14:04:41 -05:00
Eduardo Montoya
121a164ec0 net: openthread: add CSL receiver API
This commit implements the OpenThread APIs to configure a radio
reception slot at a specific time. This is needed for the correct
functioning of a CSL receiver.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2021-05-05 14:04:14 -05:00
Martin Jäger
08b067f855 canbus: isotp: use new k_work API
Replace soon-to-be-deprecated call to start queue.

Signed-off-by: Martin Jäger <martin@libre.solar>
2021-05-05 13:24:29 -05:00
Vinayak Kariappa Chettimada
167e83df49 Bluetooth: controller: Move le_adv_ext_terminate under broadcaster
Move le_adv_ext_terminate under broadcaster conditional
compilation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-05-05 17:05:52 +02:00
Jennifer Williams
ca75bbef3c tests: boot_time: remove all the code and instrumentation feeding into test
Remove the config BOOT_TIME_MEASUREMENT and corresponding #ifdef'd code
throughout (kernel/init.c, idle.c, core/common.S , reset.S, ... ) which
hold the extern hooks for z_timestamp_main and z_timestamp_idle in the
removed boot_time test suite.

Signed-off-by: Jennifer Williams <jennifer.m.williams@intel.com>
2021-05-05 10:41:15 -04:00
Marek Metelski
1a927b5fbf Bluetooth: shell: Fix implicit gatt client requirement for bt shell
`write_stats` functionality implementation is guarded by
`BT_GATT_CLIENT`, but is also called from commands defined when
`BT_GATT_DYNAMIC_DB` is set. This means that now application will not
build with `BT_SHELL` used, when we set `BT_GATT_DYNAMIC_CB` solely.

Move this functionality to top of the file without guarding
ifdefs, so it can be used in all gatt shell commands.

Signed-off-by: Marek Metelski <marek.metelski01@gmail.com>
2021-05-05 16:03:51 +02:00
Magdalena Kasenberg
d0e0af74da Bluetooth: Add option to log btsnoops over RTT
There is a choice to log btmon logs over UART or RTT.
You can choose number of RTT buffer, set its name and size.

Replaced CONFIG_BT_DEBUG_MONITOR with CONFIG_BT_DEBUG_MONITOR_UART
for UART usage and CONFIG_BT_DEBUG_MONITOR_RTT for RTT.

Signed-off-by: Magdalena Kasenberg <magdalena.kasenberg@codecoup.pl>
2021-05-05 16:03:38 +02:00
Vinayak Kariappa Chettimada
08a679dc4c Bluetooth: controller: Add Broadcast ISO related timing macros
Added Broadcast ISO related timing macros, like T_MSS
Minimum Subevent Space.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-05-05 08:41:40 -04:00
Vinayak Kariappa Chettimada
03c191c281 Bluetooth: controller: Add function to calculate BIS access address
Added a function to calculate the BIS SubEvent access
addresses.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-05-05 08:41:09 -04:00
Vinayak Kariappa Chettimada
3469171041 Bluetooth: controller: Add function to calculate seed access address
Added utility function to calculate seed access address.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-05-05 08:41:09 -04:00
Vinayak Kariappa Chettimada
544acb9804 Bluetooth: controller: Fix missing EVENT_TICKER_RES_MARGIN_US
Fix missing use of EVENT_TICKER_RES_MARGIN_US in Periodic
Synchronization.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-05-05 08:40:44 -04:00