Commit graph

9523 commits

Author SHA1 Message Date
Vinayak Kariappa Chettimada
938fca2e08 Bluetooth: controller: Use ticker resolution margin in central
Use the vendor specific ticker resolution margin in the
central connection initiation offset calculation.

Related to commit 89ab68f242 ("bluetooth: controller:
Vendor specific ticker resolution margin").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-02-15 12:07:43 -05:00
Vinayak Kariappa Chettimada
ce27b2627f Bluetooth: controller: Remove redundant event margin use
Remove the redundant advanced scheduling event margin used
while finding a free space between existing active central
connections.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-02-15 12:07:43 -05:00
Vinayak Kariappa Chettimada
60730eb702 Bluetooth: controller: Move connection event length calculation
Move the initial connection event length calculation to
when initiating connection so that initiator with advanced
scheduling to place central connections in a non-overlapping
timeline has the correct ticks slot value available.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-02-15 12:07:43 -05:00
Vinayak Kariappa Chettimada
0d255cc270 Bluetooth: controller: Add invalid ACL data length check
Add checks to detect ACL data lengths greater than the
configured maximum Tx buffer size in the controller.
The Host should conform to the LE_ACL_Data_Packet_Length
returned by the LE Read Buffer Size command.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-02-15 08:02:59 -05:00
Vinayak Kariappa Chettimada
08d3e49ee0 Bluetooth: controller: Optimize LOW_LAT_ULL scheduling
Optimize LOW_LAT_ULL scheduling by avoiding redundant
rx_demux mayfly enqueue. Only schedule after checking for
node rx or tx ack presence in the memq.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-02-15 08:02:17 -05:00
Vinayak Kariappa Chettimada
db3f7e7a7b Bluetooth: controller: Use Subsystem defined Periodic Advertising Kconfig
Use the Subsystem defined BT_PER_ADV_SYNC_MAX Kconfig in the
controller implementation of Periodic Advertising Sync Sets.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-02-15 08:01:56 -05:00
Emil Gydesen
92c97a8eec Bluetooth: Audio: Fixed bad L2CAP Kconfig for ISO fragmentation
A line of code was guarded by CONFIG_BT_L2CAP_TX_FRAG_COUNT instead
of CONFIG_BT_ISO_TX_FRAG_COUNT.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-02-15 08:01:34 -05:00
Emil Gydesen
c6132c8fdb Bluetooth: Seperate BT_ISO and BT_AUDIO
ISO is a building block for BT_AUDIO but it is not only
useful for AUDIO, and as such should be possible to
enable without enabling BT_AUDIO.

This commit moves iso.c and iso_internal.h to the
host directory (from host/audio) and removes
the CMakeLists.txt.

The /audio directory is left intact for the Kconfig options
it provides, and as a directory for future BLE Audio
content.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-02-15 08:01:34 -05:00
Emil Gydesen
25be47e7a4 Bluetooth: hci_raw: Move BT_ISO to common Kconfig and fix ISO buffers
This commit moves the BT_ISO to a common (host and controller)
Kconfig and fixes the ISO buffers in hci_raw.c

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-02-15 08:01:34 -05:00
Piotr Pryga
62819022bd Bluetooth: controller: Add release of periodic advertising sync set
Add release of memory acquired for periodic advetising sync. set
when:
- advertising set is removed
- advertising parameters are changed and past PDU type was
  extended advertising PDU

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-02-15 08:00:58 -05:00
Piotr Pryga
c8475b9a3e Bluetooth: controller: ULL: enable TX of CTE with per. adv. PDU
Enable transmission of CTE with periodic advertising PDU.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-02-15 08:00:58 -05:00
Piotr Pryga
f1ef3087d9 Bluetooth: controller: ULL: Add CTE to per. adv. PDU
Add CTE to extended header of periodic advertising PDU.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-02-15 08:00:58 -05:00
Piotr Pryga
4b600fcf9a Bluetooth: controller: Remove assert in functions that get latest adv. PDU
Remove LL_ASSERT from functions that return latest advertising PDU.
The LL_ASSERT was raised in situation that there is no memory to
store unused PDUs memory in a pdu_free queue or extra_data_free queue
Those functions return NULL in such sitation. The returned value is
verified by callers by LL_ASSERT. That gives better context if lack
of memory issue issue occurs.

Besides that there was removed a LL_ASSERT from lll_adv_pdu_and_extra_-
data_alloc. The reasons is the same as above, to give better context
when the lack of memory issue occurs.
This function is used in ULL context (ll_adv_sync_ad_data_set).
If it returns NULL the caller will return BT_HCI_ERR_MEM_CAPACITY_-
EXCEEDED to Host.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-02-15 08:00:58 -05:00
Piotr Pryga
cf47d53c77 Bluetooth: controller: LLL: enable TX of CTE with per. adv. PDU
Enable transmission of CTE with periodic advertising PDU.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-02-15 08:00:58 -05:00
Piotr Pryga
515f95382e Bluetooth: controller: radio: Add DF configuration to enable CTE TX
Add set of functions that will make possible to configure
radio Direction Finding Extension to transmit CTE for periodic
advertising.

Some of the new Radio API functions are provided as separate
functions changing the same Radio peripheral registers, e.g.
radio_df_mode_set_aoa, radio_df_mode_set_aod. This is done on
purpose and is related with lack of DFE in nrf52_bsim.
To avoid use of conditionally compiled constants to represent
e.g. CTE mode; separate functions were introduced.
Thanks to that DF unit tests are able to compile successfully
without changes in nrf52_bsim platform. Also if DFE is added
to nrf52_bsim there is no need to change the code until it is
desired.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-02-15 08:00:58 -05:00
Piotr Pryga
b56a2d1384 Bluetooth: controller: Add extra data storage for ext. adv. configuration
The storage for extra data is required for implementation of
CTE transmission with periodic advertising.

Data required to transmit CTE correctly are compound of two parts:
- PDU field CTEInfo
- radio configuration to transmit actual constant tone at the end
  of PDU.

Extra data is a storage required for radio configuration data.
Nevertheless it must be in compliance with content of CTEInfo field.
Because of that extra data is stored as part of lll_adv_pdu and
is double buffered like PDU memory.

Bluetooth 5.1 spec. allows to enable or disable CTE TX
and change CTE TX parameters when periodic advertising is
enabled. Besides that CTE TX settings may be set before periodic
advertising parameters are set. In such situation ll_adv_sync_set
may be not yet created.
To overcome these constraints ULL should store CTE TX
settings and forward them to LLL only when CTE TX is enabled.
Because of above reasons ULL stores CTE TX settings in ll_adv_set.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-02-15 08:00:58 -05:00
Piotr Pryga
175e9d9c4d Bluetooth: controller: hci: Enable reporting of CTE reception
Enable reporting CTE in periodic advertising reports send to host.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-02-15 08:00:58 -05:00
Piotr Pryga
3c59b6a25f Bluetooth: controller: ll_feat: Add CTE connectionless TX feat.
Add Directin Finding related features:
- transmission of connectionless CTE,
- antenna switching during CTE transmission (AoD),
to list of features supported by controller.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-02-15 08:00:58 -05:00
Ioannis Glaropoulos
2d32ca5e99 bluetooth: controller: remove support for nRF5340 PDK
Remove support for nRF5340 PDK in the BLE controller.
The controller will now support only the nRF5340 DK.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2021-02-15 07:59:43 -05:00
Vinayak Kariappa Chettimada
706551cfe5 Bluetooth: controller: Fix periodic sync cancel for Coded PHY
Fix cancel of Periodic Synchronization on Coded PHY. Reset
the association of periodic sync instance after validation
of command disallowed.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-02-15 07:54:18 -05:00
Vinayak Kariappa Chettimada
fde9ba5c43 Bluetooth: controller: Fix network privacy with resolution disabled
When address resolution is disabled, an identity address has
been added into the resolving list with peer IRK, and device
privacy has not been selected for the peer device then
connection indication shall not be sent to the peer that is
advertising using its identity address.

Fixes #24731.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-02-14 18:17:05 -05:00
Matias Karhumaa
dd63b0baf8 Bluetooth: hci_raw: Fix switch fallthrough
Fix apparently accidental switch fallthrough in bt_buf_get_tx().

Signed-off-by: Matias Karhumaa <matias.karhumaa@gmail.com>
2021-02-14 15:58:05 -05:00
Joakim Andersson
2b3a2c8573 Bluetooth: host: Fail pairing if remote cannot meet required security
Fail after pairing request and response have been exchanged if the
selected pairing method would not result in the required security level.
This avoids the case where we would discover this after having encrypted
the connection and disconnect instead.

This was partially attempted but lacked checking for authentication
requirement when L3 was required, as well as skipping the check if L4
was required but remote did not support Secure Connections since the
check was after we had taken the legacy branch.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-02-11 14:58:03 -05:00
Joakim Andersson
6b8fbfa68a Bluetooth: host: Set error in security changed when not required level
Set the error in the security changed callback when the encryption has
not reached the required security level.
Terminate the pairing procedure in SMP on failure to avoid the security
changed callback being called twice in this case.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-02-11 14:58:03 -05:00
Joakim Andersson
09eb7e066b Bluetooth: host: Terminate the pairing procedure when disconnected
Terminate the pairing procedure when disconnected while this was in
progress. This notifies the application that security has failed and
removes the key entry.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-02-11 14:58:03 -05:00
Joakim Andersson
6b72e6584c Bluetooth: host: Set encryption pending when LE SC bond exists
Set the SMP flag encryption pending in the case where a bond exists
with ediv and rand equal to zero, i.e LE Secure Connections bond.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-02-11 14:58:03 -05:00
Joakim Andersson
0cc5dc1839 Bluetooth: host: Don't call callbacks on unexpected SMP PDUs
When receiving unexpected SMP PDUs with no pairing procedures in
progress don't treat it as a pairing procedure that has failed.
This causes unexpected SMP PDUs to trigger the pairing failed and
security changed callback at unexpected times.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-02-11 14:58:03 -05:00
Joakim Andersson
500ac369ed Bluetooth: shell: Improve security error readability
Improve the readability of security errors by converting the error code
to a string.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-02-11 14:58:03 -05:00
Joakim Andersson
1bf90c6f2f Bluetooth: shell: Add only pairing failed and pairing complete callbacks
Add status only pairing failed callbacks (complete and failed) so that
these handlers can be added without providing the ability for MITM
pairing procedures.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-02-11 14:58:03 -05:00
Joakim Andersson
00d8068b45 Bluetooth: host: Fix wrong error code type passed to security changed
Fix wrong error code type passed to security changed, passed SMP error
code instead of HCI error code.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-02-11 14:58:03 -05:00
Joakim Andersson
bdf1452b4e Bluetooth: host: Rename auth_err_get to security_err_get
Rename auth_err_get to security_err_get which better reflect the
error namespace it converts to. Also update to using the enum definition
instead of uint8_t for local variable holding returned value.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-02-11 14:58:03 -05:00
Faisal Saleem
b8c33efb78 Bluetooth: SMP: fix for bt fixed passkey BT_PASSKEY_INVALID
when BT_PASSKEY_INVALID was set, it never updated the fixed
passkey which made its use ineffective

Signed-off-by: Faisal Saleem <faisal.saleem@setec.com.au>
2021-02-11 14:46:24 -05:00
Joakim Andersson
10841b9a14 Bluetooth: host: Release ATT request buffers once sent
The ATT request buffers are held until the ATT response has been
received. This means that the ATT request buffers are released by the
RX thread, instead of the from the RX priority context of
num_complete.
This can cause a deadlock in the RX thread when we allocate buffers
and all the available buffers are ATT requests, since the RX thread is
the only thread that can release buffers.

Release the ATT request buffers once they have been sent and instead
handle ATT request resending by reconstructing the buffer from the
GATT parameters.

Also re-order the order of resource allocation by allocating the
request context before the buffer. This ensures that we cannot
allocate more buffers for ATT requests than there are ATT requests.

Fixed a buf reference leak that could occur when the ATT request buffer
has been allocated, but GATT returns an error before handing the
responsebility of the buffer to ATT, for example when bt_att_req_alloc
fails.
This is fixed by moving the functionality of att_req_destroy to
bt_att_req_free.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-02-11 12:59:01 -05:00
Joakim Andersson
5cbfdf6311 Bluetooth: host: Remove unused ATT request destroy callback
Remove the ATT request destroy callback which is never assigned
by any of the ATT requests.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-02-11 12:59:01 -05:00
Joakim Andersson
75deefb1b2 Bluetooth: host: Fix indicate without user callback
Fix indicate without func not working properly, when sent as a
non-req by GATT this has two propblems:
 - The indicate would not be treated as a transaction, and back
   to back indicate would be sent without waiting for the confirm
 - The destroy callback would not be called on the indicate parameters
   since the indicate_rsp callback would not be called.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-02-11 12:59:01 -05:00
Luiz Augusto von Dentz
8df6124deb Bluetooth: ATT: Remove BT_ATT_TX_MAX
ATT channels do support queueing buffer so it no longer need to block
waiting the tx_sem besides the buffer allocation already serves the
same purpose as the application will not be able to have more requests
than there are buffers available.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2021-02-11 12:59:01 -05:00
Joakim Andersson
9752cee3d7 Bluetooth: host: Refactor smp handling of conn pointer
Refactor SMP to have a conn pointer where this pointer is used
multiple times.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-02-11 12:59:01 -05:00
Joakim Andersson
fcdb2eef25 Bluetooth: host: Allow requesting new security when security changed
Allow to request a higher security level during the key distribution
phase.

This is required by ATT and L2CAP since they only react to the encrypt
change event where they resend the current request.
The current request might require a higher security level still and
might have to request a higher security level before the pairing
procedure has been finished.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-02-11 12:59:01 -05:00
Joakim Andersson
301317e8fd Bluetooth: host: Handle multiple step security elevation
When ATT resends an ATT request it is sent as a "response" instead of
as a request. This causes the ATT request buffer to be released and
the ATT request cannot be resent one more time.

This causes a problem when the ATT request requires authentication
but the elevation of security is not enforcing MITM protection.
In this case the ATT will first require security level 2 and then resend
the request once this has been reached.
This will lead to a new ATT error response and ATT will require security
level L3.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-02-11 12:59:01 -05:00
Joakim Andersson
2f588f946f Bluetooth: host: Fix update keys when using debug public key check
Fix the update keys check allowing to overwrite the keys when using
debug keys. Instead the check disallowed overwriting keys made using
debug keys.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-02-11 12:59:01 -05:00
Joakim Andersson
abd470cbe6 Bluetooth: shell: Fix gatt write command not cleanup up on error
Fix gatt write command returned "write in progress" when either
hex2bin or bt_gatt_write returned an error.
The write_params.func should not be set if the write command was not
successful.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-02-11 12:59:01 -05:00
Trond Einar Snekvik
512444d863 Bluetooth: Mesh: Update seqnum when re-encrypting for friend
Sets the sequence number when re-encrypting messages from the friend to
the lpn.

This is a regression from #28511.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2021-02-10 08:55:40 -05:00
Trond Einar Snekvik
48526b6925 Bluetooth: Mesh: Initialize msg_ctx when re-encrypting friend msg
Set app_idx and net_idx in the msg_ctx before calling
bt_mesh_keys_resolve when re-encrypting friend messages, as they'll be
referenced inside the function.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2021-02-10 08:55:40 -05:00
Vinayak Kariappa Chettimada
b365ab06a7 Bluetooth: controller: Fix missing advertising PDU len initialization
Fix missing advertising PDU length initialization which
prevented advertising PDU to be transmitted by Radio. This
issue was reproduced when connectable undirected advertising
was enabled without setting an advertising data.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-02-10 07:17:48 -05:00
Trond Einar Snekvik
a281d10cff Bluetooth: Mesh: Store network at the end of provisioning
After #31176, the network would get stored immediately in
bt_mesh_net_create, causing the address and devicekey to get stored as
their zero-initialized version, as they're only being set in the
bt_mesh_comp_provision call, which fires after.

Fixes #32067.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2021-02-08 10:37:08 -05:00
Joel Westerberg
8b14b83940 Bluetooth: ISO: fix error value set but not returned
err was set to -EIO, but function still returned 0.

Fixes: #31847

Signed-off-by: Joel Westerberg <joel@teenage.engineering>
2021-02-05 08:13:14 -05:00
Vinayak Kariappa Chettimada
a980012aa9 Bluetooth: controller: Fix build error with ISO support
Fix build error due to missing include file with ISO support
enabled.

Fixes #31996.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-02-05 06:36:52 -05:00
Emil Hammarstrom
3cf64b17c3 bluetooth: host: expand l2cap CID abbreviation
Reduces some user confusion regarding whether it is related
to "Connection ID", "Channel ID", or "Company ID" for the
uninitiated.

Signed-off-by: Emil Hammarstrom <emil.hammarstrom@assaabloy.com>
2021-02-04 08:31:20 -05:00
Vinayak Kariappa Chettimada
b7acb6bf55 Bluetooth: controller: openisa: Fix to use compiler memory barrier
Fix OpenISA port to include compiler memory barrier as in
commit 1a14f8b3a6 ("Bluetooth: controller: Use DMB instead
of DSB").

Relates to commit 1af2b91c23 ("Bluetooth: controller: Fix
Tx Buffer Overflow") and to commit ef2ece82c0 ("Bluetooth:
controller: openisa: Fix sanitycheck failures") and to
commit c2fc629dd2 ("Bluetooth: controller: 255 byte AD
payload support").

Fixes #31937.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-02-03 14:16:12 -05:00
Vinayak Kariappa Chettimada
59616c0b03 Bluetooth: controller: openisa: Fix unsupported ULL LLL Prio config
Fix for OpenISA rv32m1_vega_ri5cy board not supporting
different IRQ Priority levels for LLL, ULL_HIGH and ULL_LOW
execution contexts.

Fixes #31937.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-02-03 14:16:12 -05:00