Commit graph

9523 commits

Author SHA1 Message Date
Vinayak Kariappa Chettimada
3664cb9f62 Bluetooth: controller: Fix BT_CTLR_ULL_HIGH_PRIO default value
Fix BT_CTLR_ULL_HIGH_PRIO default value to equal
BT_CTLR_LLL_PRIO value if BT_CTLR_LOW_LAT is enabled, else
default ULL_HIGH to lower IRQ priority level in comparison
to LLL IRQ priority level. If BT_CTLR_ZLI is enabled,
BT_CTLR_ULL_HIGH_PRIO can default to a priority level value
of 0 and still be lower priority level than the LLL which
is placed at Zero Latency IRQ priority level (highest
priority in the CPU).

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-02-03 14:16:12 -05:00
Trond Einar Snekvik
2bd5b63dfd Bluetooth: Mesh: Verify network buffer max len
As network_decode needs a target buffer for decoding, the max PDU length
must be checked to prevent overflow on the target buffer. When receiving
a proxy configuration message with excessive length, there's no previous
check for this.

Also pulls the NET PDU length defines out into net.h, so they can be
used when defining the target buffers.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2021-02-03 13:12:09 -05:00
Vinayak Kariappa Chettimada
1af2b91c23 Bluetooth: controller: Fix Tx Buffer Overflow
Fix Tx Buffer Overflow caused by uninitialized node_tx
memory being used by ULL ISR context due to Compiler
Instructions Reordering in the use of MFIFO_ENQUEUE.

The MFIFO last index was committed before the data element
was stored in the MFIFO due to Compiler Instructions
Reordering.

This is fixed now by adding a Data Memory Barrier
instruction alongwith a compiler memory clobber.

Fixes #30378.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-02-02 14:00:57 -05:00
Vinayak Kariappa Chettimada
1a14f8b3a6 Bluetooth: controller: Use DMB instead of DSB
Use of Data Memory Barrier instruction with memory clobber
in ARM Cortex M architectures is sufficient in the
controller implementation to keep compiler data access
instructions in order so that an ISR vectoring has memory
accesses in the correct order as intented by design.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-02-02 14:00:57 -05:00
Joakim Andersson
97d59a7c6d Bluetooth: host: Mark the option BT_FIXED_PASSKEY as insecure
Mark the option BT_FIXED_PASSKEY as an insecure option.
During Legacy pairing the passkey is used as encryption key, and
brute-forcing this is easy.
During LE Secure Connections the passkey is checked one bit at a time,
so when it is fixed the passkey can be deduced with series of pairing
attempts.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-02-02 11:09:05 -05:00
Joakim Andersson
b9695c07cd Bluetooth: kconfig: Fix SMP dependency on BT_ECC
The Bluetooth SMP protocol depends on the BT_ECC for the LE Secure
Connections pairing. Since this feature cannot be disabled we must
select this dependency.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-02-02 11:09:05 -05:00
Joakim Andersson
971404eee9 Bluetooth: host: Fix fixed passkey for legacy pairing
Fix fixed passkey for legacy pairing. The pairing procedure fails
because the temporary key (TK) has not been set for this pairing
procedure.

Fix this by always requesting the legacy TK.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-02-02 11:09:05 -05:00
Joakim Andersson
2d50761c3e Bluetooth: shell: Fix misleading shell message id-create failed
Fix misleading message in the bluetooth shell when the id-create
command returns en error code. In this case both failure and success
messages are printed.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-02-02 08:46:17 -05:00
Joakim Andersson
e800ec1cf3 Bluetooth: host: Add options to control behavior of the init command
Add options to control the behavior of the init command.
Option no-settings-load allows the user to create identities
with the id-create command after bt_enable() but before settings_load().
Option no-ready-cb allows the user to test using synchronous enable,
since this sometimes leads to different behavior of the stack.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-02-02 08:46:17 -05:00
Joakim Andersson
8a55e04e23 Bluetooth: host: Prevent bt_rand calls before bt_enable
Prevent the bt_rand function from being called before bt_enable.
Depending on the implementation of bt_rand this function cannot
be called before bluetooth has been initialized. With host supplied
crypto functions the HCI LE rand command is used for example.

The use case for calling bt_id_create before bt_enable is meant for
when the application has storage for the identity instead of the stack.
So we add the requirement that the application has to have storage
for the identity resolving key (IRK) in addition when the local
device is privacy-enabled.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-02-02 08:46:17 -05:00
Vinayak Kariappa Chettimada
30634334a8 Bluetooth: controller: Fix ULL_HIGH priority to be lower than LLL
Fix the default ULL_HIGH execution priority to be lower than
LLL execution priority to reduce Radio ISR service latency.

Also, default to Zero Latency IRQ for Radio ISR if enabled
in the kernel.

Fixes #29994.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-02-02 08:09:29 -05:00
Vinayak Kariappa Chettimada
929dae8cad Bluetooth: controller: Add ISR cputime measurement
Adding ISR cputime measurement for Radio, LLL, ULL_HIGH and
ULL_LOW execution contexts.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-02-02 08:09:29 -05:00
Andrzej Kaczmarek
ebb5b9a558 Bluetooth: shell: Fix 'bt per-adv-data'
ad_len parameter is not length of complete advertising data, but number
of bt_data structs passed to bt_le_per_adv_set_data - we pass only one.

Also memset target buffer before converting hex string so data shorter
than specified will be right-padded with zeroes instead of some
leftovers.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2021-02-02 07:15:40 -05:00
Nicolas LANTZ
942979b252 Bluetooth: Mesh: Fix fix mod_sub_get_vnd
pass cid instead of CID_NVAL in parameters of mod_member_list_get

Signed-off-by: Nicolas LANTZ <nicolas.lantz@ubicore.net>
2021-02-01 08:38:24 -05:00
Vinayak Kariappa Chettimada
b8b946f37f Bluetooth: controller: Fix rx_demux scheduling for LOW_LAT_ULL
Fix the mayfly callee id for the rx_demux scheduling under
the LOW_LAT_ULL implementation. This could be causing
undefined mayfly execution behavior in nRF51x SoC.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-02-01 08:36:19 -05:00
Joakim Andersson
c14da53772 Bluetooth: host: Remove the deprecated bt_conn_create_slave_le function
Remove the deprecated bt_conn_create_slave_le function.
This was deprecated in the 2.3.0 release.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-01-29 12:53:10 -05:00
Vinayak Kariappa Chettimada
1afbe0770c Bluetooth: controller: Fix accept scan en/disable if already en/disabled
Conform to Bluetooth Specification, if the LE_Scan_Enable
parameter is set to 0x01 and scanning is already enabled,
any change to the Filter_Duplicates setting shall take
effect. Disabling scanning when it is disabled has no
effect.

Fixes #31019.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-01-29 08:02:46 -05:00
Nicolas LANTZ
3ff1eb618f Bluetooth: Mesh: Fix mod app key get vnd
pass cid instead of CID_NVAL in parameters of mod_member_list_get

Signed-off-by: Nicolas LANTZ <nicolas.lantz@ubicore.net>
2021-01-28 07:52:06 -05:00
Vinayak Kariappa Chettimada
7712caa1a7 Bluetooth: controller: Fix peripheral conditional compilation
Fix regression in peripheral only build conditional
compilation introduced in commit 8a9bda307cc1 ("Bluetooth:
controller: Fix CPR conditional compilation").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-01-27 13:35:48 -05:00
Vinayak Kariappa Chettimada
7295204af9 Bluetooth: controller: Fix CPR conditional compilation
Move the newly added Connection Parameter Request reject
state implementation under conditional compilation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-01-27 13:35:48 -05:00
Vinayak Kariappa Chettimada
804419592f Bluetooth: controller: Fix incorrect reset of CPR reject state
Fix regression in adding the state for Connection Parameter
Request being rejected where in Connection Parameter Request
Procedure state machine was prematurely reset before the
reject PDU was enqueued.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-01-27 13:35:48 -05:00
Vinayak Kariappa Chettimada
7bf202791f Bluetooth: controller: Fix missing initialization
Fix missing initialization of ticks_to_offset value on
instantiation of new peripheral context.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-01-27 13:35:48 -05:00
Vinayak Kariappa Chettimada
b5cba3c955 Bluetooth: controller: Minor identation changes
Minor changes to indentations in advanced scheduling
implementation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-01-27 13:35:48 -05:00
Vinayak Kariappa Chettimada
b150d3a90f Bluetooth: controller: Fix repeated offsets in CPR PDU
Fix repeated offsets in LE Connection Parameter Request PDU
due to rounding errors. Use tick units of connection
interval to calculate the offset units.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-01-27 13:35:48 -05:00
Vinayak Kariappa Chettimada
a8e25d9402 Bluetooth: controller: Fix deferred Conn Param Req offset population
Fix deferred Connection Parameter Request offset population
by introduction of explicit states waiting for the offset
calculations to complete in the ULL_LOW context.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-01-27 13:35:48 -05:00
Vinayak Kariappa Chettimada
383e688e3f Bluetooth: controller: Fix deferred Conn Update offset population
Fix deferred Connection Update offset population by
introduction of explicit states waiting for the offset
calculation to complete in the ULL_LOW context.

Fixes #29636.

The problem was, in an encrypted connection the enqueued PDU
to be transmitted is encrypt in the prepare callback by the
hardware and swapped to a different buffer for transmission;
the deferred offset population did not reflect in the
transmitted PDU as it was filled in the cleartext buffer
while encryption completed into the encrypted buffer.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-01-27 13:35:48 -05:00
Vinayak Kariappa Chettimada
2919989ee9 Bluetooth: controller: Fix compilation error with encryption disabled
Fix compilation error with encryption support disabled in the
controller.

Fixes #31693.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-01-27 07:57:28 -05:00
Piotr Pryga
53b4da93e9 Bluetooth: controller: ll_sw: Fix wrong cmake code that adds radio_df.c
Fix error introduced by pull request:
https://github.com/zephyrproject-rtos/zephyr/pull/31591

Zephyrs CMake extension function zephyr_library_sources_ifdef()
does not allow to use complex conditions to toggle if
sources should be included in build or not.
It allows to use only single variable as an input for
feature_toggle argument because it is double-expanded
in contition statement in the function.

In case there is a requirement that source file is included
when more complicated condition is true we have to fall-back
to reqular if() statement and zephyr_library_sources().

The fix is required because without it radio_df.c source
is never compiled. If DF functionality is enabled build
will fail because of missing functions implementation.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-01-27 07:57:03 -05:00
Joakim Andersson
3102f3b081 Bluetooth: host: Fail pairing with identical public key
Fail the pairing procedure when both devices have the same non-debug
public key.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-01-26 13:41:56 -05:00
Vinayak Kariappa Chettimada
8f537de8c4 Bluetooth: controller: Fix encryption and procedure with instant
Fix implementation to run local peripheral initiated control
procedure with instant in parallel with remote initiated
encryption procedure.

Relates to #28887.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-01-26 06:18:39 -05:00
Thomas Ebert Hansen
d4347339f5 Bluetooth: controller: Fix enc. setup during PHY update
If a PHY update is waiting for the instant to be reached and the master
starts the encryption procedure, store the pending PHY update procedure
and handle it simultaneously with the encryption setup.

This fix prevents the encryption setup from stalling and thereby timing
out after 40s, after which the master drops the link.

The ll_conn::llcp::encryption can not longer be unioned with the
ll_conn::llcp:phy_upd_ind as one would overwrite the other.

Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
2021-01-26 06:18:39 -05:00
Vinayak Kariappa Chettimada
d2415fcfd0 Bluetooth: controller: Add peripheral/central conditional compilations
Add conditional compilation on peripheral and central
specific control procedure implementation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-01-26 06:18:39 -05:00
Vinayak Kariappa Chettimada
abcee4dc2b Bluetooth: controller: Fix BIG Sync Terminate command
Fix BIG Sync Terminate Command to generate Sync Established
event if Sync initiation is in progress.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-01-26 06:18:23 -05:00
Vinayak Kariappa Chettimada
eaa0215c74 Bluetooth: controller: Fix missing node rx allocation for ISO establish
Added missing allocation of node rx buffer required for
generation of Broadcast ISO Sync Established.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-01-26 06:18:23 -05:00
Emil Gydesen
085d2eda8d Bluetooth: Audio: Add missing unref for ISO recv
The net_buf was never unref'ed when the host received an
ISO package that was a SINGLE.

Also adds a few additional debug messages.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-01-25 21:47:06 -05:00
Emil Gydesen
aed1db5782 Bluetooth: shell: Fix number of optional args for iso send
`iso send` may take an optional "count" parameter but the
number of optional arguments was incorrect.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-01-25 21:47:06 -05:00
Piotr Pryga
a8c18ff5f4 tests: Bluetooth: df: Fix build error, missing antenna config in DTS
The DF tests are implemented to be executed with nrf52_bsim platform.
The nrf52_bsim platform does not include Direction Finding Extenstion.
Due to that, radio_df.c compilation failed with error about missing
antenna configuration in DTS.

To solve the problem, I've changed nrf.cmake to include radio_df.c
file when CONFIG_BT_CTLR_DF is defined and CONFIG_SOC_SERIES_BSIM_NRFXX
is not definded.

Thanks to that any other platform is not affected. The file will not
build if there is no appropriate configuration or there are missing
features in a hardwared.

Unit tests have provided stub imlpementation or radio functionality.
If nrf52_bsim has implemented Direction Finding Extension, the
DF unit tests code will stil work and will not require additional
changes. Also content of the file is not affected by contional
compilation entries.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-01-25 21:46:34 -05:00
Joakim Andersson
dbe4a5f0d2 Bluetooth: host: Remove ATT modification of L2CAP conn pointer
Remove ATT modifying the L2CAP channel state by unassigning the
the connection pointer on timeout.
Unassigning this pointer does not prevent the ATT channel from receiving
since bt_l2cap_recv does not inspect this pointer before calling the
channel receive function.
This prevented the disconnected callback from being called on the
channel after the channel had timed out, but since the disconnected
callback now handles this case this workaroun is no longer needed.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-01-25 18:49:30 -05:00
Joakim Andersson
28bddf9380 Bluetooth: host: Handle ATT timeout on disconnected ATT channel
Handle ATT timeout on disconnected ATT channel.
When the ATT channel is disconnected with a pending request the ATT
timeout is canceled and the response processed with an error code.
However canceling of delayed work is not guaranted to succeed, e.g:
"Work queue thread has removed the work item from the queue but has not
 called its handler"
This could lead to timeout handler being invoked after the disconnected
handler.

Fixes: #29098

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-01-25 18:49:30 -05:00
Vinayak Kariappa Chettimada
c2513eb993 Bluetooth: controller: Fix PHY update procedure cachability
Fix missing PHY update procedure cachability omitted in
commit 16dbb9a4fe ("Bluetooth: controller: split: Fix cmd
disallowed and collision disconnects").

Relates to #31473.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-01-25 11:49:28 +01:00
Piotr Pryga
609701fa21 Bluetooth: controller: radio: Fix compilation error
Fix compilation error caused by use of wrong header file:
nrfx/hal/nrf_radio.h instead of hal/nrf_radio.h.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-01-22 09:49:03 -05:00
Rubin Gerritsen
76c5707639 bluetooth: controller: Disable Coded PHY by default.
Coded PHY is only enabled by default if the application is using
BT_HCI_RAW.

Coded PHY is not needed in most applications.
By disabling Coded PHY, most applications will:

* Get smaller in terms of flash and ram usage
* Not get vurnerable to devices trying to switch to Coded and
  thereby increasing power consumption.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2021-01-21 15:57:48 -05:00
Piotr Pryga
ff1d8efd38 Bluetooth: controller: Fix error when max ant. pattern len not defined
Fix compilation error if CONFIG_BT_CTLR_DF is not defined.
If DF was not enabled, there was missing CONFIG_BT_CTLR_DF_MAX_-
ANT_SW_PATTERN_LEN and undeclared symbol was found.

Split ll_df.h into two parts:
- ll_df.h that is generally includeable and allows to successfully
  compile sources when DF is not enabled.
- ll_df_internal.h to be used in soucres that are compiled when
  DF is enabled.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-01-20 14:55:24 +01:00
Piotr Pryga
0b230ae639 Bluetooth: controller: Add DF initialization to controller init sequence
Direction Finding requires initalization of a set of registers
in Radio peripheral. Also it requires information about antenna
matrix unit that are provided by end user in DTS overlay.
Implemented initialization step is responsible for validation of
hardware information delivered by DTS and setting up DF related
registers in Radio.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-01-20 14:55:24 +01:00
Piotr Pryga
f3e04898eb Bluetooth: controller: ll_sw: nordic: Add DF antenna configuration handling
Add support for Direction Finding antenna configuration in
Nordic hal of Bluetooth controller.
Add handling of response for HCI_LE_Read_Antenna_Information
HCI command in controller (upper and lower link layer).
Handling of response to the command requires antenna matrix
configuration.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-01-20 14:55:24 +01:00
Andrzej Głąbek
dbf9d99e54 bluetooth/controller: Update paths in inclusions of nrfx HAL files
After nrfx glue code was decoupled from nrfx sources, it is no longer
feasible to use those inclusions in the <nrfx/hal/nrf_*.h> form (there
is no point in adding the main directory of the hal_nordic module as
an include path solely for this reason). Remove then the nrfx/ part.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2021-01-19 17:35:04 +01:00
Joakim Andersson
66427d370b Bluetooth: host: Fix size of L2CAP disconnect request pool
Fix size of L2CAP disconnect request buffer pool which did not include
the size of the L2CAP signal header.

Regression from: 3346aa4d39

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-01-18 19:12:20 +01:00
Nirosharn Amarasinghe
b2fcda8efb Bluetooth: Controller: re-factor magic constants
Defined 625 and 1250 as context specific interval common to ULL and LLL.
Checked with bluetooth sanity checks.

Fixes #23314.

Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
2021-01-18 19:12:12 +01:00
Thomas Ebert Hansen
65b453d44e Bluetooth: controller: Fix header inclusion
Use correct headers to make the inclusion of lll.h work when
CONFIG_BT_CTLR_USER_EXT is enabled.

Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
2021-01-18 19:07:06 +01:00
Thomas Ebert Hansen
c3f557c12b Bluetooth: controller: User defined CPR intervals
Some proprietary protocols that reuse the Bluetooth LLCP logic requires
that the CPR interval has a valid range that differs from the Bluetooth
specification defined.

Vendor must implement the function (ull_vendor.h)
uint16_t ull_conn_interval_min_get(struct ll_conn *conn)
that returns the valid limit for the given connection.

Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
2021-01-18 19:07:06 +01:00