Commit graph

9523 commits

Author SHA1 Message Date
Andrzej Kaczmarek
def072ea65 Bluetooth: controller: Rename pdu_adv_hdr to pdu_adv_ext_hdr
pdu_adv_hdr name is quite confusing since it suggests some generic
header for advertising PDUs while this in fact is extended header
which is a part of common extended advertising payload and only applies
to extended advertising PDUs.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-12-04 23:08:15 -05:00
Andrzej Kaczmarek
014eb0ddf8 Bluetooth: controller: Rename ext_hdr_adi_adv_data
The 'adi' part of that member name does not make sense since ADI is
already part of extended header, so we only have 'extended header' and
'advertising data'.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-12-04 23:08:15 -05:00
Andrzej Kaczmarek
85adca4be3 Bluetooth: controller: Use proper handle in advertising events
If handle mapping is enabled, we need to use proper advertising set
handle in HCI event.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-12-04 16:31:44 -05:00
Andrzej Kaczmarek
77fd7fdbd7 Bluetooth: controller: Initialize scan rsp only for legacy adv
When legacy set is configured we need to make sure scan response is
properly initialized with empty data. For extended sets we should not
touch scan response on configure since data for those sets have to be
set explicitly, e.g. we cannot enable scannable advertising set if no
data was set.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-12-04 17:44:13 +01:00
Andrzej Kaczmarek
e4c39d6e19 Bluetooth: controller: Fix AdvA/TgtA for extended adv PDUs
AdvA in extended advertising PDUs was only set if random address was
used. This patch enables proper support for AdvA/TgtA in those PDUs
also with LL Privacy enabled.

On enable, we always update advertising PDU (i.e. ADV_IND, ADV_EXT_IND
or ADV_AUX_IND, depending on advertising set parameters) as well as
scan response PDU.

On RPA timeout, we simply copy old PDU as-is and update AdvA in new
PDU, since both PDUs are exactly the same (except AdvA) so no need to
recreate it step-by-step.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-12-04 17:09:46 +01:00
Emil Gydesen
b527f80f0f Bluetooth: controller: Guard ll_adv_iso_by_hci_handle_* functions
Guards the functions with CONFIG_BT_CTLR_HCI_ADV_HANDLE_MAPPING
and added a non-HCI inline function for them.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2020-12-04 17:09:33 +01:00
Emil Gydesen
2c67c29fd4 Bluetooth: controller: Remove empty BIS packet tx from ULL
The empty BIS packet should be enqueue and handled in the LLL.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2020-12-04 17:09:33 +01:00
Emil Gydesen
47e716ba83 Bluetooth: controller: removed node_rx for big create/terminate
Removed the node_rx argument for the BIG create/terminate
functions. The event should not be sent right after the
command, but needs to wait for transmissions of
empty BIS packets or BIG terminate indications.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2020-12-04 17:09:33 +01:00
Emil Gydesen
b32af6a643 Bluetooth: controller: ll_big_create add check if handle already created
Adds a check to verify that the BIG handle isn't already allocated.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2020-12-04 17:09:33 +01:00
Emil Gydesen
146fd961ef Bluetooth: controller: ull_adv_iso merge unknown adv id check
Merges the 3 checks for checking valid adv when creating a big.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2020-12-04 17:09:33 +01:00
Emil Gydesen
9c9253db5f Bluetooth: controller: Move ISO tx functionality to ull_iso.c
Moves the ISO tx pool and functions from ull_adv_iso.c to
ull_iso.c as the pool and functions will be shared between
BIS and CIS.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2020-12-04 17:09:33 +01:00
Emil Gydesen
e1aa633e67 Bluetooth: controller: Rearrange functions in ull_adv_iso.c
Rearranged the functions so the order of functions match
the common pattern in other ULL files.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2020-12-04 17:09:33 +01:00
Emil Gydesen
41fe6d72a1 Bluetooth: controller: Implements BIG terminate command
Implements the BIG terminate command that terminates a
BIG and returns the appropriate events.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2020-12-04 17:09:33 +01:00
Emil Gydesen
339b9b8df5 Bluetooth: controller: BIG create sends empty BIS PDUs (ULL)
When a BIG is create, it will now start sending empty BIS PDUs;
at least from an ULL perspective, as the LLL support is still
missing.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2020-12-04 17:09:33 +01:00
Emil Gydesen
5a512fbe2f Bluetooth: controller: Implements ULL handling for BIG create command
Implements handling of the BIG create command in the upper link layer.
Does not yet handle sending any BIS events.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2020-12-04 17:09:33 +01:00
Vinayak Kariappa Chettimada
1d63c81033 Bluetooth: controller: Fix Extended Scanning on Coded PHY
Fix Extended Scanning on Coded PHY, auxiliary PDUs on Coded
PHY where not received due to redundant conditional code
only applicable in connection role being copy-pasted during
the development of Extended Scanning feature.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-12-03 13:54:25 -05:00
Vinayak Kariappa Chettimada
d6a3a0a05e Bluetooth: controller: Use memmove to copy overlapping memory
Use memmove to copy overlapping memory when populating the
Common Extended Advertising Header Format in the advertising
PDU.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-12-03 13:54:25 -05:00
Vinayak Kariappa Chettimada
6cc7278b8b Bluetooth: controller: Fix maximum PDU len configuration
Fix maximum PDU len configuration when advertising and/or
scanning on primary channels.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-12-03 13:54:25 -05:00
Piotr Pryga
98b11ee95c Bluetooth: host: Fix data type of advertising set handle
Change type of advertising set handle to 8 bit to comply with
Bluetooth Core spec. type.
Fixes wrong usage of adv. set handle variable in function
bt_le_per_adv_set_param.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2020-12-03 14:53:37 +02:00
Joakim Andersson
180099f9ff Bluetooth: host: Remove irq_lock around connection lookup
Remove irq_lock around connection lookup, this is no longer needed
now that the lookup functions always have a valid reference.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-12-03 13:52:02 +01:00
Joakim Andersson
4350021f09 Bluetooth: host: Make connection lookup functions thread-safe
Make the connection lookup functions thread-safe by re-using the
bt_conn_ref returning NULL mechanism and keeping a valid reference.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-12-03 13:52:02 +01:00
Joakim Andersson
fae964c008 Bluetooth: host: Make bt_conn_ref return NULL if the ref count is zero
Make bt_conn_ref return NULL if the reference count has reached zero.
This makes it possible to re-use bt_conn_ref internally to re-use the
reference count mechanism to check if the reference is in use.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-12-03 13:52:02 +01:00
Andrzej Głąbek
7ee994af0f bluetooth: controller: nrf: Provide info about used DPPI resources
Use common definitions of HAL_USED_PPI_CHANNELS and HAL_USED_PPI_GROUPS
macros that will provide (through z_bt_ctlr_used_nrf_ppi_* variables)
information about either PPI or DPPI (depending on the SoC) resources
used by the Bluetooth controller.
Update also the hal_nordic module revision, to make the related nrfx
allocator aware of those reserved DPPI resources.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2020-12-02 16:44:40 +01:00
Andrzej Głąbek
1f6f383481 bluetooth: controller: nrf: Clean up a bit radio_nrf5_ppi.h
Remove no longer needed definition of NRFX_PPI_CHANNELS_USED_BY_PWM_SW
(after recent changes in the nrf_hw_models models, also for simulated
nRF boards the nrfx_glue.h file is processed, so this symbol is always
defined).
Remove also a couple of *_PPI_x_INCLUDE macros, to make the code a bit
clearer and to avoid things like a build assertion (also removed here)
that checks if HAL_SW_SWITCH_GROUP_TASK_DISABLE_PPI_0_INCLUDE is indeed
defined as BIT(HAL_SW_SWITCH_GROUP_TASK_DISABLE_PPI(0)).

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2020-12-02 16:44:40 +01:00
Asger Munk Nielsen
fbee6cc933 Bluetooth: controller: Create HCI stubs for CIG/CIS and ISO
Put infrastructure for the following HCI commands/events in place:
* LE Read ISO Link Quality command
* LE Read ISO TX Sync command
* LE Set Host Feature Command

Signed-off-by: Asger Munk Nielsen <asmk@oticon.com>
2020-11-30 15:49:30 +01:00
Lingao Meng
1b65fd066f Bluetooth: Mesh: Fix Friend node estalished
Since first poll request send by lpn use friend security
credentials, so, friend nodes should be able to decrypt with
friend security, even if they have not yet established a friendship.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2020-11-30 12:32:37 +02:00
Lingao Meng
084574b470 Bluetooth: Mesh: Fix Friend node handle Key update
When friend node key refresh phase to stage_1, there
are need to add friend update message to friend queue,
but, when friend KR phase to stage_2, must add friend
update to queue.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2020-11-30 12:32:37 +02:00
Lingao Meng
325288d531 Bluetooth: Mesh: Fix friend node cache message
Friend node cache segment message for lpn, message with
sequence number can't change, since could cause lpn replay
attack.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2020-11-30 12:32:37 +02:00
Wolfgang Puffitsch
6aa16e01dd Bluetooth: controller: hci: Fix naming for ISO path setup parameters
Fix field names of bt_hci_cp_le_setup_iso_path in le_setup_iso_path to
make CIS central/periphal compile and adjust parameter names for
ll_setup_iso_path accordingly.

Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
2020-11-28 07:36:16 -05:00
Vinayak Kariappa Chettimada
8bf3ee9f98 Bluetooth: controller: Fix skipped single-shot ticker failure callback
A single-shot ticker in requested state beyond the elapsed
duration or skipped due to collision shall generate an
operation callback with failure status.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-11-26 15:47:02 +01:00
Morten Priess
2d0107ab27 Bluetooth: controller: Fix ticker collision update race
In the case where a BLE connection ticker node collides and does not
trigger a callback to ULL, and at the same time the same node receives a
ticker update request, the update causes the node to be scheduled for
execution a second time. This has the consequence of event_counter going
out of sync, and BLE connection is ultimately lost.

The solution is to mark collsions and re-scheduled nodes as expired, and
use the increased lazy count to identify its state instead of req/ack.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2020-11-26 15:47:02 +01:00
Wolfgang Puffitsch
1547108b19 Bluetooth: controller: HCI commands to read codecs and controller delay
Implement HCI commands to read information about supported codecs and
controller delay.
* Read Local Supported Codecs command (v1 and v2)
* Read Local Supported Codec Capabilities command
* Read Local Supported Controller Delay command

The following functions are implemented as "weak" symbols and should
be overridden to fill in vendor-specific information into the above
commands.
* hci_vendor_read_std_codecs
* hci_vendor_read_vs_codecs
* hci_vendor_read_codec_capabilities
* hci_vendor_read_ctlr_delay

Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
2020-11-26 15:46:17 +01:00
Wolfgang Puffitsch
9437a6a08d Bluetooth: hci: Add definitions for codec and controller delay info
Add defines and structs for reading information about supported codes,
codec capabilities and controller delays. Return parameter structs for
commands that return multiple variable-length fields only model the
fixed-length fields to minimize inconsistencies.

Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
2020-11-26 15:46:17 +01:00
Morten Priess
18c01ecae8 Bluetooth: controller: Make random force on lost anchor configurable
Legacy functionality in ull_conn will force scheduling of a connection
which has missed an anchor point due to lost RX. This kicks in either
for previously skipped events (latenzy_event != 0) or at random
depending on the randomness of the AA bit pattern.

This behavior is good at ensuring that a connection with errors or
aborted RX gets prioitized, and helps break locked round-robin
patterns with lost sync, but it also breaks the predictability of
the round-robin ticker scheduling.

With "must_expire" enabled, this feature also kicks in for scheduling
collisions, which may not be desirable.

This commit adds a configuration flag, BT_CTLR_CONN_RANDOM_FORCE, which
is default enabled (legacy behavior).

Signed-off-by: Morten Priess <mtpr@oticon.com>
2020-11-26 13:51:15 +01:00
Vinayak Kariappa Chettimada
b7976e5633 Bluetooth: host: Fix uninitialized periodic interval parameter
Fix missing initialization of periodic interval value in
advertising report info structure.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-11-26 13:50:03 +01:00
Joakim Andersson
8d3b9bae3b Bluetooth: host: Make acl_data extension of bt_buf user data explicit
Clarify that the acl_data struct includes the bt_buf type as the
first variable in the user data struct.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-11-26 13:15:03 +01:00
Joakim Andersson
431dd9f25b Bluetooth: host: Refactor out buffer handling to new file
Refactor out implementation of functions defined in buf.h to its own
source file buf.c

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-11-26 13:15:03 +01:00
Joakim Andersson
4978c19c05 Bluetooth: host: Refactor out address handling to new file
Refactor implementation of functions defined in addr.h to its own
source file addr.c.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-11-26 13:15:03 +01:00
Piotr Pryga
e54d2a7740 Bluetooth: host: Add HCI set conn CTE TX params wrapper function
Add implementation of a wrapper for HCI_LE_Set_Connection_-
CTE_Transmit_Parameters command.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2020-11-26 13:14:17 +01:00
Piotr Pryga
2589b7ace2 Bluetooth: controller: hci: Add set connection CTE transmit params
Add implementation of HCI_LE_Set_Connection_CTE_Transmit_Parameters
for Bluetooth 5.1 Direction Finding.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2020-11-26 13:14:17 +01:00
Piotr Pryga
0285903aee Bluetooth: controller: Add Direction Finding specific KConfig
Add separated Kconfig file for Bluetooth 5.1 Direction Finding.
Enable controller support for:
 - transmission of CTE
 - 2us antenna switching
 - 1us antenna switching
if build for nRF52833 SOC.
Add HAS_HW_NRF_RADIO_BLE_DF to nrf52833 SOC configuration.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2020-11-26 13:14:17 +01:00
Piotr Pryga
57b55d0fad Bluetooth: controller: Add read antenna information HCI command
Add partial implementation for handling Bluetooth 5.1 Direction
Finding HCI command HCI_LE_Read_Antenna_Information to controller
Upper Link layer.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2020-11-26 13:14:17 +01:00
Piotr Pryga
14890c8eb6 Bluetooth: host: Add read antenna information HCI command
Add Bluetooth 5.1 Direction Finding HCI command:
HCI_LE_Read_Antenna_Information handling to Host.
Add wrapper function to handle send the command
and receive response from Controller.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2020-11-26 13:14:17 +01:00
Trond Einar Snekvik
b0f83d387a Bluetooth: Mesh: Only block mod_sub if status was requested
Adds a cli_reset to mod_sub if no status response was requested. This
adds a non-blocking mode to the mod_sub calls, matching the behavior of
other cfg_cli functions.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2020-11-26 13:04:04 +01:00
Lingao Meng
fe7eda6ac8 Bluetooth: Mesh: Permit kr phase 0x00 to 0x03
MESH/NODE/KR/BI-01-C
Permit kr phase 0x00-->0x03

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2020-11-26 12:21:09 +02:00
Lingao Meng
3d55080bf3 Bluetooth: Mesh: Fixes missing recv net_idx copy to context
Missing copy net_idx to ctx, this cause tx subnet not found
or different with rx subnet, when rx subnet net_idx not zero.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2020-11-26 12:21:09 +02:00
Peter Bigot
cd2a5dd612 bluetooth: mesh: avoid improper access to internal structures
Nothing in the API description the delayed work structure sanctions
direct reference to internal fields.  Do not assume that a delayed
work item can be submitted without delay by invoking k_work_submit()
with a reference to the contained work item.  Instead submit with the
delayed API and no wait.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-11-24 13:04:48 +02:00
Vinayak Kariappa Chettimada
27529e0c0d Bluetooth: controller: Fix periodic sync conditional compilation
Fix Periodic Advertising Synchronization conditional
compilation to allow Extended Scanning feature without
Periodic Advertising Synchronization feature enabled.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-11-23 17:01:50 +01:00
Vinayak Kariappa Chettimada
64874168cb Bluetooth: controller: Fix extended adv/sync report buffer leak
Fix node rx buffer leak if extended advertising and/or
periodic sync reports are masked out by the host.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-11-23 17:01:50 +01:00
Vinayak Kariappa Chettimada
ab82d8e158 Bluetooth: controller: Minor readability different variable use
Use an explicitly named variable to convey auxiliary pointer
present in the PDU chain.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-11-23 17:01:50 +01:00