Commit graph

21541 commits

Author SHA1 Message Date
Eduardo Montoya
99ccdabee3 net: openthread: remove misleading NCP configuration option
Remove `OPENTHREAD_CONFIG_NCP_BUFFER_SIZE` define since it does not
exist in OpenThread.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2021-02-16 15:30:36 +03:00
Wolfgang Puffitsch
ef1f8c34f1 Bluetooth: controller: Add support for ISO feature bits
Add support for ISO feature bits. This includes extending fields that
hold features to 64 bits to be able to handle the host-controlled
"Isochronous Channels" feature.

Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
2021-02-15 17:33:46 -05:00
Wolfgang Puffitsch
45bdff1509 Bluetooth: controller: Add CIS-related LL control PDU types
Add definitions for LL_CIS_REQ, LL_CIS_RSP, and LL_CIS_IND PDUs.

Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
2021-02-15 17:33:46 -05:00
Wolfgang Puffitsch
119d22a7b9 Bluetooth: controller: Refactor LLCP PDU length checks
Refactor LLCP PDU length checks to avoid constructing a look-up-table.

Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
2021-02-15 17:33:46 -05:00
Wolfgang Puffitsch
b452321c51 Bluetooth: controller: Add init/reset stubs for CIS central/peripheral ULL
Add stub functions to initialize and reset CIS central and CIS
peripheral roles in ULL.

Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
2021-02-15 17:33:46 -05:00
Wolfgang Puffitsch
4c9f89352b Bluetooth: controller: CIS HCI event generation
Implement generation of CIS Request and CIS Established events in HCI
layer.

Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
2021-02-15 17:33:46 -05:00
Wolfgang Puffitsch
adaf45cf4b Bluetooth: controller: Define ULL/LLL interface for CIS central and periph
Define interface between ULL and LLL for CIS central and peripheral.

Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
2021-02-15 17:33:46 -05:00
Kumar Gala
464d82618f arm: Remove Musca-A SoC/board support
Remove support for the Musca-A board.  This board is rarely used, few
are available and superceded by Musca-B and Musca-S.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-02-15 21:04:23 +03:00
Vinayak Kariappa Chettimada
2bfaadffb8 Bluetooth: controller: Add Tx fragmentation assertion
Added Tx fragmentation implementation assertion to check
invalid offset use due to any memory corruptions.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-02-15 12:07:59 -05:00
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
Jukka Rissanen
1364a9c52e net: tls: Allow access to TLS socket in userspace
If userspace is enabled, then the TLS context needs to be
made a NET_SOCKET kernel object. Without this the userspace
cannot access TLS sockets.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-02-15 10:56:44 -05:00
Kuba Sanak
a17f19907b lorawan: Add userspace-defined battery level callback API
Provide the LoRaWAN stack with an optional callback to be
called whenever the battery level needs to be read.

In the case of callback not being provided, the LoRaWAN
stack will report 255 (battery level unavailable) as per
the LoRaWAN spec.

Signed-off-by: Kuba Sanak <contact@kuba.fyi>
2021-02-15 08:19:03 -05:00
Flavio Ceolin
86a624e2a2 power: Remove PM_STATE_LOCK option
Simplify pm subsystem removing PM_STATE_LOCK option. Constraints API is
small and is a key component of power subsystem.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-02-15 08:08:36 -05:00
Flavio Ceolin
3f87c5a0f4 power: Rename constraint API
Replace pm_ctrl_* with pm_constraint.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-02-15 08:08:36 -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
Hubert Miś
5e43418cf9 net: coap: acknowledgement initialization helper
When handling CoAP Confirmable requests, there is a common
Acknowledgement initialization procedure that repeats for each
response packet initialization. This patch adds a function that
simplifies Acknowledgement initialization procedure encapsulating
repeating code.

Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
2021-02-15 10:17:11 +02:00
Jacob Siverskog
b4454f63ef usb: mass storage: use inquiry parameters from Kconfig
support custom inquiry vendor id, product id and revision.

Signed-off-by: Jacob Siverskog <jacob@teenage.engineering>
2021-02-14 18:31: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
Johann Fischer
7ab50b66ce usb: bluetooth: fix OUT buffer handling
acl_read_cb does not handle incoming (ACL) data
if BT_CTLR_TX_BUFFER_SIZE is greater than
USB_MAX_FS_BULK_MPS - BT_HCI_ACL_HDR_SIZE.

Since the host adjusts the data according to
the BT_CTLR_TX_BUFFER_SIZE and does not use ZLP
we cannot start usb_transfer over the possible length of
the whole packet, with or without USB_TRANS_NO_ZLP flag.
But we can read the packet length from the header and
call net_buf_put() when the whole packet is received.

Fixes: #31922

Reported-by: Matias Karhumaa <matias.karhumaa@gmail.com>
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2021-02-14 16:38:56 -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