Commit graph

9523 commits

Author SHA1 Message Date
Piotr Pryga
ff94b9f676 Bluetooth: controller: Add double buffer for DF sync configuration
CTE sampling enable or disable requests should be provided to LLL.
Double buffer of lll_df_sync_cfg is added to lll_sync for that purpose
Thanks to that:
- there is no need to synchronize LLL with LL thread
- LLL has always access to valid configuration (new or former)

The configuration is stored in double buffer as instances
of lll_df_sync_cfg, not as pointers. This is the only
difference between double buffer pattern used to store adverising PDU.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-05-06 16:27:16 +02:00
Piotr Pryga
aa51f0a0dc Bluetooth: controller: Add DF per. adv. sync. configuration stucture
Add new structure lll_df_sync_cfg to store DF configuration
for periodic advertising synchronization.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-05-06 16:27:16 +02:00
Piotr Pryga
4d706bb6fb Bluetooth: controller: Add IQ report mem pool management
Add functions that will allow to mangage IQ reports memory pool
e.g. allocate or relase new IQ report nodes.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-05-06 16:27:16 +02:00
Piotr Pryga
bdaf4eed9a Bluetooth: controller: New node_rx type for IQ sample report
Add new kind of node_rx type that will store IQ samples report.
The structure includes node_rx_hdr and may be used by the same
queues that are used to forward regular node_rx_pdu objects
between LLL and ULL.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-05-06 16:27:16 +02:00
Piotr Pryga
68704c8cb1 Bluetooth: controller: Add Kconfig option to enable conn-less CTE sampling
Direction Finding support requires possibility to receive and sample CTE
attached to periodic advertising PDUs. New option will be used to enable
or disable the functionality. New option is introduced to avoid using
double statements checking if BT_CTLR_DF_CTE_RX and BT_CTLR_SYNC_-
-PERIODIC are enabled.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-05-06 16:27:16 +02:00
Piotr Pryga
2e1e8aff8d Bluetooth: controller: Add Kconfig option to enable debugging code in DF
To avid enabling HCI drived debugging, like in other controller source
files, Direction Finding has its own option BT_CTLR_DF_DEBUG_ENABLE.
This gives fine grained control deubgging output.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-05-06 16:27:16 +02:00
Piotr Pryga
2f7b0b7392 Bluetooth: controller: Disable not implemented DF features
Set to disabled not yet implemented Direction Finding features.
The features will be enabled by default when they are implemented.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-05-06 16:27:16 +02:00
Piotr Pryga
5779a2d7f2 Bluetooth: controller: radio: Add function to get PDU ant. switch pattern
IQ samples report requires information about antenna switch pattern
that was used to measure RSSI. RSSI is measured during PDU receive.
For Nordic Radio peripheral the PDU antenna is selected by first antenna
switch pattern set in SWITCHPATTERN register. That pattern is providded
by device tree. This information is already available in radio_df.c.
The information is required by LLL, that has access to functions
provided in radio_df.c. New function was provided to return PDU antenna
switch pattern.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-05-06 16:27:16 +02:00
Vinayak Kariappa Chettimada
737cab2614 Bluetooth: controller: openisa: Check preempt event on timeout
Check whether the preempt event matches with the head of the
pipeline before aborting the currently active event.

This is required to avoid preemption of events that became
active due to done event and there has been a race in
stopping the preempt ticker.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-05-06 15:39:16 +02:00
Vinayak Kariappa Chettimada
5b75bdf589 Bluetooth: controller: nRF5: Check preempt event on timeout
Check whether the preempt event matches with the head of the
pipeline before aborting the currently active event.

This is required to avoid preemption of events that became
active due to done event and there has been a race in
stopping the preempt ticker.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-05-06 15:39:16 +02:00
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
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
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
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
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
Vinayak Kariappa Chettimada
0da63124d2 Bluetooth: controller: Add ticker allocation for BIG events
Add ticker node allocations for BIG radio event scheduling.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-05-05 08:40:28 -04:00
Vinayak Kariappa Chettimada
12f04da828 Bluetooth: controller: Minor rename in BIS PDU data members
Renamed offset and offset_units to offs and offs_unit to be
consistent with rest of the other structures.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-05-05 08:40:06 -04:00
Vinayak Kariappa Chettimada
eb5874ca7b Bluetooth: controller: Fix ULL reference decrement on done event
Fix ULL reference count decrement to be performed before the
done events are handled, so that correct reference count is
used to determine if events are pending in the pipeline.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-05-05 08:39:41 -04:00
Vinayak Kariappa Chettimada
b0bba245ea Bluetooth: controller: HCI: Allow processing a list of events
Update HCI driver implementation in the controller to
process a list of controller events by traversing net buf
frags.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-05-05 08:39:25 -04:00
Vinayak Kariappa Chettimada
323b8efe75 Bluetooth: controller: Reorder feature bits
Reorder Channel Selection Algorithm #2 and Minimum Number of
Used Channels Procedure bits.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-05-05 08:38:56 -04:00
Vinayak Kariappa Chettimada
4eca1a821c Bluetooth: controller: Add ticker allocation for BIG Sync events
Add ticker node allocations for BIG Sync radio event
scheduling.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-05-05 08:36:43 -04:00
Vinayak Kariappa Chettimada
415e068e16 Bluetooth: controller: Conditional compile ISO Tx functions
Conditional compile ISO Tx related declarations and
implementation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-05-05 08:36:27 -04:00
Vinayak Kariappa Chettimada
a4d2e062cb Bluetooth: controller: Fix regression in central initiated terminate
Fix regression in central initiated terminate introduced in
commit 3a80785947 ("Bluetooth: controller: Fix connection
terminate to happen on event done").

The regression caused an additional central connection event
transmitting PDU  after the previous connection event had
received acknowledgment for the terminate_ind PDU from the
peripheral.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-05-05 14:21:05 +02:00
Andrzej Kaczmarek
b8dfecfdc5 Bluetooth: conn: Fix invalid ref on conn object
We should unref conn object if skipped during lookup.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2021-05-05 14:20:05 +02:00
Emil Gydesen
3e6ea470a1 Bluetooth: ISO: Additional text for setting unidir values for the CIG
Add additional text to explain why we use the TX values if RX is
disabled and vice versa.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-05-05 14:19:38 +02:00