Commit graph

9523 commits

Author SHA1 Message Date
Piotr Pryga
39c535fef8 Bluetooth: controller: Make per adv filtering by CTE cond compilable
The filtering of periodic advertisements by scanner may be not needed
in certain situations e.g. while use of periodic advertising by BT ISO.
To make the code smaller and avoid execution of not needed code the
functionality will be conditionally compilable. It may be enabled
or disabled by use of CONFIG_BT_CTLR_SYNC_PERIODIC_CTE_TYPE_FILTERING
Kconfig option.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-10-07 21:36:55 -04:00
Piotr Pryga
e03f9c3042 Bluetooth: controller: Add per sync filt by CTE type for SOC w/o DFE
First implementation of periodic advertising sync filtering
requires existence of Direction Finding Extension in Radio
peripheral.
To add the filtering support for other Nodric SOCs software
based PDU traversing for CTEInfo should be implemented.

In case there is no DFE in Radio peripheral, actual filtering
is done in ULL.

The commit provides necessary changes to previous solution.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-10-07 21:36:55 -04:00
Piotr Pryga
ecf761b4e9 Bluetooth: controller: ULL: add per sync filtering by CTE type
Follow up on changes in lower link layer to add filtering
of periodic advertisements synchronization by CTE type.

The NODE_RX_TYPE_SYNC is used to transport information that:
- Sync is established. In such situation the node_rx
  includes data related with received PDU
- Sync scanning is terminated.
In first case ULL will generate NODE_RX_TYPE_SYNC_REPORT
after sending NODE_RX_TYPE_SYNC.

Also EVENT_DONE_EXTRA_TYPE_SYNC handling has additional
execution path that terminates sync scanning if requested
by lower link layer. In other case it adjusts sync scan
window and maintains timeout as usual.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-10-07 21:36:55 -04:00
Piotr Pryga
9b66a8b47d Bluetooth: controller: rework per scan lll to allow filt by CTE type
Periodic advertisement synchronization may be filtered by CTE type.
If particular CTE type is not allowed then depening on filtering policy:
- if filtering policy is off synchronization if terminated
- if filtering policy is on synchronization is continued to
  synchonize with another device from allowed adverisements list.
If synchronization is established and peer device changes CTE type
to one that is not allowed, synchronization should be maintained.

There are two new execution paths. First one is executed when
synchronization is created. In this case CTEILINE is enabled
to parse PDU for CTEInfo field. In this execution path CTE
type is verified. Second execution path does not include
parsing PDU for CTEInfo and verification of CTE type.

Information about sync allowed is added to node_rx instance
that transports received PDU data. In case the sync has to be
terminated the node_rx will not hold PDU data.

Also done event is extended with information about sync
termination if CTE type is not allowed and filtering
policy is off.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-10-07 21:36:55 -04:00
Piotr Pryga
04e2e84cb7 Bluetooth: radio: move radio_df_cte_inline_set_enabled to radio.c
To enable runtime parsing of PDU to find CTEInfo field CTEINLINE mode
has to be enabled. Thanks to that it is possible to verify if the PDU
has allowed CTE type e.g. for periodic advertising synchornization.
To run CTEInfo parsing other parametrers of CTEINLINE are not relevant.
If Radio is set to disable after PDU END event the CTE sampling
will not be processed.

The commit moves the radio_df_cte_inline_set_enable function to make
it accessible even the direction finding features are disabled.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-10-07 21:36:55 -04:00
Piotr Pryga
ff3045db61 Bluetooth: hci: Add handling of allowed CTE types for per sync create
Add missing code responsible for handling of allowed CTE types
in HCI_LE_Periodic_Advertising_Create_Sync command.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-10-07 21:36:55 -04:00
Vinayak Kariappa Chettimada
2ab8b9061c Bluetooth: Controller: Fix cpu sleep for simulation targets
Use __WFE and __SEV for CPU sleep in simulation too to
avoid stalling and to let ISRs execute during CPU sleep.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-10-07 15:44:10 -04:00
Morten Priess
6344ea984b Bluetooth: controller: Framework for vendor ISO data path
Added weak function for data path dependent ISO-AL sink creation. This
is required for vendor specific ISO-AL data sink operation. Invoke sink
creation for vendor specific data path.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2021-10-07 15:43:17 -04:00
Morten Priess
06900485ec Bluetooth: host: Add bt_configure_data_path for vendor data path
Implemented host function for configuring vendor specific data path for
use with ISO, and fixed passing of path ID in setup.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2021-10-07 15:43:17 -04:00
Wolfgang Puffitsch
f3b97ccfb6 Bluetooth: controller: Introduce Kconfig for Read ISO Link Quality
Introduce Kconfig for Read ISO Link Quality command. Support for the
command is optional according to the specification.

Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
2021-10-04 20:48:01 -04:00
Wolfgang Puffitsch
d58224566d Bluetooth: controller: Reorder variable declarations in ISO HCI commands
Reorder variable declarations in HCI command handlers of ISO-related
commands to conform to reverse Christmas tree style.

Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
2021-10-04 20:48:01 -04:00
Wolfgang Puffitsch
7c0b74bc0d Bluetooth: controller: Fix use of handle field in HCI command handling
Fix use of handle field in HCI command handling for some ISO-related
commands. The response buffer may reuse the command buffer. Therefore,
the handle field must not be copied directly from the command to the
response.

Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
2021-10-04 20:48:01 -04:00
Wolfgang Puffitsch
230f8db0d5 Bluetooth: controller: Update supported commands for ISO
Set bits for ISO-related supported commands depending on selected
features and adjust compilation guards for the respective handler
functions.

Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
2021-10-04 20:48:01 -04:00
Trond Einar Snekvik
cd89f42393 Bluetooth: Mesh: Model extensions walk stops before last model
When reaching the last model in the circular extension linked list, the
walker would abandon the walk before checking the last model. This makes
us skip models when checking the subscription list, potentially causing
incoming messages to be wrongfully ignored.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2021-10-04 20:45:23 -04:00
Emil Gydesen
f9e2fc3fc4 Bluetooth: ISO: Move bt_iso_accept and make static
Move the function and make it static as it is only
used in iso.c and for unicast only.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-10-04 20:40:06 -04:00
Szymon Janc
088fac76ed Bluetooth: Mesh: Fix crash on disconnect
bt_mesh_proxy_role_setup() is called conditionally when peer is
connected and gatt_disconnected() is always called. This leads
to unbalance in role->conn reference count and crash.

Instead of hot-fixing this in gatt_disconnected(), this commit adds
proper bt_mesh_proxy_role_cleanup() API that is called by roles
implementations if cleanup is needed.

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2021-10-04 18:52:08 +02:00
Vinayak Kariappa Chettimada
072c8f2c68 Bluetooth: Controller: Fix assertion failed [evdone]
When there are radio events with time reservations lower
than the preemption timeout of 1.5 ms, the pipeline has to
account for the maximum radio events that can be enqueued
during the preempt timeout duration. All these enqueued
events could be aborted in case of late scheduling needing
as many done event buffers.

During continuous scanning, there can be 1 active radio
event, 1 scan resume and 1 new scan prepare. If there are
peripheral prepares in addition, and due to late scheduling
all these will abort needing 4 done buffers.

If Extended Scanning is supported, then an additional
auxiliary scan event's prepare could be enqueued in the
pipeline during the preemption duration.

Fixes #36381.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-10-04 18:26:11 +02:00
Ingar Kulbrandstad
c1e053c9b3 Bluetooth: Mesh: Missed IV update cannot be captured
It seems that if the IV update is missed, a node cannot
recover it until the IV index has increased to a value
greater than Node's Last known IV + 1.

Signed-off-by: Ingar Kulbrandstad <ingar.kulbrandstad@nordicsemi.no>
2021-10-04 08:37:43 -04:00
Szymon Janc
c589994dc0 bluetooth: Add support for reconfiguring L2CAP channels
This allows application to increase channel's MTU and (in some cases)
MPS. When channel gets reconfigured dedicated callback is called to
inform application.

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2021-10-04 11:05:03 +02:00
Vinayak Kariappa Chettimada
24596f5c08 Bluetooth: Controller: Refactor out sync setup addr and sid check
Refactor out the implementation of Periodic Sync Setup
address check including Periodic Advertiser List and SID.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-10-01 21:48:51 +02:00
Vinayak Kariappa Chettimada
bf01d55107 Bluetooth: Controller: Implement Periodic Advertiser List
Implement support for Periodic Advertiser List to be used
in LE Periodic Advertising Create Sync command.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-10-01 21:48:51 +02:00
Vinayak Kariappa Chettimada
d76711f187 Bluetooth: Controller: Refactor ull_filter adva_get and tgta_get
Refactor `ull_filter_adva_get` and `ull_filter_adva_get` to
input resolving index compare to adv context reference.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-10-01 21:48:51 +02:00
Vinayak Kariappa Chettimada
4bfeee6d9e Bluetooth: Controller: Minor filter accept list related refactoring
Refactoring related to filter accept list, resolving list,
and removed the redundant anon variable.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-10-01 21:48:51 +02:00
Aleksander Wasaznik
a5cf50e61f Bluetooth: Host: Fix resource leak in bt_gatt_unsubscribe
There are two simmilar functions for unsubscribing from GATT handles.

 - `gatt_sub_remove`, which is called on disconnect for every
 subscription will free the `subscriptions` entry when the entry
 represents no subscriptions.

 - `bt_gatt_unsubscribe`, called by the application, which forgets to
 free the `subscriptions` entry.

If all subscriptions grouped in a `subscriptions` entry are removed
using `bt_gatt_unsubscribe` before disconnect, there are no
subscriptions left to call `gatt_sub_remove` on. The `subscriptions`
entry is then never freed.

The above results in a resource leak of a `subscriptions` entry.

This fix makes explicit and enforces the invariant that there should not
be entries in `subscriptions` with an empty subscription list.

Fixes #38688

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2021-10-01 14:38:06 -04:00
Piotr Pryga
982743b765 tests: Bluetooth: df: Add test to verify correctness of relase of PDUs
Add unit tests that will ensure the CTE disable operation does not
cause breaking of LLL operations by too early release of chained PDUs.
The tests verify if numbers of PDUs in free PDUs fifo and free PDUs
memory pool are correct.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-10-01 14:32:49 -04:00
Piotr Pryga
a3378d1c9f Bluetooth: controller: Fix ASSERT caused by ULL releasing chain PDUs
When CTE is enabled for periodic advertising and number of CTE is
greater than number of PDUs in a chain, that are needed to transport
advertising data, there are additional empty PDUs used for transport
CTE.

CTE transmission may be disabled when periodic advertising event is
pending in LLL. rem_cte_info_from_per_adv_chain removed CTEInfo field
from extended advertising header in chained PDUs. When there were found
empty PDUs (created to transport CTE only), they were released from
the chain that was currently used by LLL. That caused an assert in
isr_tx handler due to broken advertising chain.

The rem_cte_info_from_per_adv_chain may not relese PDUs that are in
use by LLL. The PDUs may be released by LLL in prepare step when
advertising pdu double buffer is swapped by lll_adv_sync_data_latest-
_get.

This PR fixes that issue.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-10-01 14:32:49 -04:00
Vinayak Kariappa Chettimada
bacfd0175f Bluetooth: Controller: Fix assert on aux LLL scheduled chain reception
Fix asserted in ULL due to incorrect resumption of scan
window when auxiliary channel chain PDU is LLL scheduled by
a ULL scheduled auxiliary channel PDU reception.

The issue is solved by having `is_chain_sched` flag in the
auxiliary channel scan context and using the already present
`is_aux_sched` in the primary channel scan context to
differentiate if the auxiliary PDU Rx ISR is to return back
to primary channel scan window or to close the auxiliary
chain PDU reception radio event.

Relates to #38146.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-10-01 14:32:24 -04:00
Vinayak Kariappa Chettimada
e123c4e381 Bluetooth: Controller: Fix to ignore aux ptr in scannable advertising
Fix to ignore aux pointer struct in scanning advertising, to
avoid ULL scheduling from setting up ticker to receive chain
PDUs while LLL is receiving scan response PDU.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-10-01 14:32:24 -04:00
Vinayak Kariappa Chettimada
5cb3721313 Bluetooth: Controller: Fix HCI command parameter check failures
Fix assorted HCI command parameter check failures faced
during conformance testing.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-09-30 11:47:57 +02:00
Aleksandr Khromykh
797c17436b Bluetooth: Mesh: logging public key in big endian
Local public key has been logged in little endian but
remote public key in big endian. That has been changed.
Both are logged in big endian to be able to compare in logs.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2021-09-29 15:34:13 -04:00
Aleksandr Khromykh
ebf9a591d6 Bluetooth: Mesh: split debug for prov and prov_device
Debug configuration for prov and prov_device has been split
since prov general modul and it is used for provisioner as well.
It is not necessary to enable prov_device debugging
to debug provisioner.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2021-09-29 15:34:13 -04:00
Rubin Gerritsen
ca088aafbe Bluetooth: host: Warn on incomplete adv reports
When the controller forwards incomplete reports to the host,
the application currently has no way of reassembling them.
Therefore the application may fail to parse the data.

Issue a warning until
https://github.com/zephyrproject-rtos/zephyr/issues/37368
is resolved.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2021-09-29 14:47:47 -04:00
Vinayak Kariappa Chettimada
aa4b75b58c Bluetooth: Controller: Separate address get and read functions
Have separate Bluetooth Device address get and read
functions, remove use of function just to return Extended
Advertising Random address and replace with simple
assignment statement.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-09-29 14:44:47 -04:00
Vinayak Kariappa Chettimada
d7cfb5473b Bluetooth: Controller: Use defines for aux pointer offset unit value
Use defines for aux pointer offset unit value.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-09-29 14:44:47 -04:00
Vinayak Kariappa Chettimada
651137ee11 Bluetooth: Controller: Fix Extended Advertising channel use
Add implementation defined channel index in the auxiliary
pointer of the common extended payload format in the primary
channel PDUs and the same be used in the transmission of
auxiliary PDUs.

Fixes #35668.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-09-29 14:44:47 -04:00
Vinayak Kariappa Chettimada
3075ba92d1 Bluetooth: Controller: Add FIXME for Per Adv chain channel use
Add FIXME comments for missing use of channel selection
algorithm for Periodic Advertising chained PDUs.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-09-29 14:44:47 -04:00
Vinayak Kariappa Chettimada
ec784fd420 Bluetooth: Controller: Add advertiser clock accuracy value
Add implementation to set correct Advertiser's clock
accuracy value in the auxiliary pointer field in the common
extended payload format.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-09-29 14:44:47 -04:00
Vinayak Kariappa Chettimada
6af9a433c2 Bluetooth: controller: Fix populate offset in latest advertising PDU
Fix implementation to populate the aux, and sync offset
in the latest PDU. If both the current and latest of the
double buffer has been filled and LLL did not pick the
latest PDU, then the offset should be filled into the latest
PDU (and not into the first/current PDU).

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-09-29 14:44:47 -04:00
Vinayak Kariappa Chettimada
3ce9b2f2f5 Bluetooth: Controller: Minor indentation fixes
Minor indentation fixes.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-09-29 14:44:47 -04:00
Vinayak Kariappa Chettimada
3a8bf279d9 Bluetooth: Controller: Explicitly typecast void return for memcpy calls
Explicitly typecast void return for memcpy calls.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-09-29 14:44:47 -04:00
Vinayak Kariappa Chettimada
ec10ef601d Bluetooth: Controller: Minor rename of ULL internal function
Rename ULL internal helper function to get the random
address.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-09-29 14:44:47 -04:00
Carles Cufi
301a7103a0 Bluetooth: common: Add build asserts for address struct sizes
In some HCI packed structures we place non-packed structs inside (in
particular the address structs).
Alignment is not an issue for those because all their members are just
byte-aligned, but size is. If the compiler ever packs those it would
become a real problem, and so detect this at build time.
See the link below for more info:
https://stackoverflow.com/a/66389167

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2021-09-29 19:07:52 +02:00
Joakim Andersson
da31a33905 Bluetooth: host: Access local IRKs consistently
Change the way the local IRKs are accessed to be consistent with the
all other uses.
Coverity thinks using the pointer to the array is suspicious in this
case.

Fixes: #38130

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-09-29 10:44:38 -04:00
Joakim Andersson
b7ad63362c Bluetooth: host: Verify valid local identity loaded from settings
Verify that the local identity loaded from the settings key is
valid for the current configuration.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-09-29 10:44:38 -04:00
Vinayak Kariappa Chettimada
ad36dcdf15 Bluetooth: Controller: Use defines for scanning state types
Use defines for scanning state types of passive, active,
initiator and synchronization state.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-09-29 15:05:57 +02:00
Vinayak Kariappa Chettimada
e0ac70ad91 Bluetooth: Controller: Allow resolving list update during passive scan
Allow resolving list update  when passive scanning,
otherwise deny if advertising, active scanning, initiating
or periodic sync create is active.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-09-29 15:05:57 +02:00
Vinayak Kariappa Chettimada
bbe8fe721b Bluetooth: Controller: Fix imprecise data bus error in periodic sync
Fix imprecise data bus error when receiving Periodic
Advertising Report caused due to uninitialized `extra` field
member in the node rx struct passed from ULL to LL thread
context.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-09-29 15:02:37 +02:00
Vinayak Kariappa Chettimada
665a8d2c6e Bluetooth: Controller: Fix repeated per sync drift compensations
Fix repeated periodic sync drift compensation invoked when
receiving chain PDUs which caused memory corruptions and
bus faults.

Use `is_aux_sched` flag in Periodic Sync's LLL context to
differentiate between the first AUX_SYNC_IND PDU followed by
use of LLL scheduling to receive following AUX_CHAIN_IND PDU
versus ULL scheduling being used to receive AUX_CHAIN_IND
PDUs.

Drift compensation to be done only using the AUX_SYNC_IND
PDU and not on reception of AUX_CHAIN_IND PDU using ULL
scheduling.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-09-29 15:02:37 +02:00
Emil Gydesen
8d20e8d5bc Bluetooth: ISO: Add iso accept info struct
Add a new struct that provides information to the upper
layer when accepting an connected isochronous stream.

The CIG ID and CIS ID makes it possible for the upper layer
to determine which ISO channels are "together" in a group.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-09-28 20:19:37 -04:00
Vinayak Kariappa Chettimada
fda7b46f92 Bluetooth: Controller: Update Bluetooth version to 5.3
Update the Bluetooth HCI Version to 5.3.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-09-28 20:18:00 -04:00