Commit graph

9523 commits

Author SHA1 Message Date
Vinayak Kariappa Chettimada
1cd8eb3a81 Bluetooth: Controller: Fix scan_data_status value
Fix scan_data_status value from being incorrected OR-ed with
the advertising data status.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-17 17:36:19 +02:00
Vinayak Kariappa Chettimada
0fdac865e5 Bluetooth: Controller: Simplify LLL scheduling decision
Simplify the implementation deciding the use of LLL
scheduling for scanning PDUs with close auxiliary offsets.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-17 17:36:19 +02:00
Vinayak Kariappa Chettimada
2feffaf719 Bluetooth: Controller: Release LLL scheduling aux on incomplete data
Add implementation to release Auxiliary Context on failure
to receive auxiliary chain being in LLL scheduling.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-17 17:36:19 +02:00
Andrzej Kaczmarek
48ee84ffda Bluetooth: Controller: Fix aux scheduling from LLL
We need to alloc node prior to calling lll_scan_aux_setup, otherwise
the same node will be peeked inside that function and it will overwrite
some data in our node (e.g. "extra" field).

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-17 17:36:19 +02:00
Vinayak Kariappa Chettimada
d879861d44 Bluetooth: Controller: LLL scheduling for active scanning and initiator
Implementation to use LLL scheduling for close auxiliary
offsets when active scanning and initiating connections.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-17 17:36:19 +02:00
Vinayak Kariappa Chettimada
369dfd50ad Bluetooth: Controller: Fix tag name should be unique violation
Fix tag name should be unique violation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-17 17:36:19 +02:00
Vinayak Kariappa Chettimada
451f0a25f1 Bluetooth: Controller: Resume primary PDU scanning after Auxiliary PDU
Add implementation to resume primary PDU scanning window
after use of LLL scheduling to receive auxiliary PDUs.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-17 17:36:19 +02:00
Vinayak Kariappa Chettimada
25da55afce Bluetooth: Controller: Flush Aux PDUs being in LLL scheduling
When Auxiliary PDUs are scanning by the primary scan's LLL
scheduling, then flush the Auxiliary PDUs when processing
them in the ULL instead of using the disabled callback.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-17 17:36:19 +02:00
Vinayak Kariappa Chettimada
cddf4cc4ed Bluetooth: controller: Extended scanning with LLL scheduling
Extended scanning with LLL scheduling.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2021-08-17 17:36:19 +02:00
Andrzej Kaczmarek
34edd41e76 Bluetooth: controller: Add ull_scan_aux_is_valid_get helper
This can be used to check if pointer is a valid lll_scan_aux pointer,
e.g. if we need to decide what kind of struct is attached to RX node
for further processing.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2021-08-17 17:36:19 +02:00
Andrzej Kaczmarek
1444c331a3 Bluetooth: controller: Fix isr_done_cleanup
We need to reset isr status before returning as otherwise irq will be
triggered over and over again.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-17 17:36:19 +02:00
Vinayak Kariappa Chettimada
be8f1a2519 Bluetooth: Controller: Generate Extended Scan Response report
Added implementation to traverse the Extended Active Scanned
advertising PDUs, generate the Scannable Advertising and
Scan Response Advertising Report.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-17 17:36:19 +02:00
Vinayak Kariappa Chettimada
bf957850ca Bluetooth: Controller: Hold back Extended Scannable PDUs
When Extended Active Scanning hold back the received PDUs in
a linked list and send it to HCI together so that fields
present across these PDUs can be aggregated for generating
the LE Extended Advertising Report.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-17 17:36:19 +02:00
Vinayak Kariappa Chettimada
bbb53446ad Bluetooth: Controller: Flush scanned rx node before scan response PDU
Flush the scanned advertising PDUs to HCI while receiving
the scan response PDU when Extended Active scanning.
This reverts earlier implementation to remember the
advertising PDUs.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-17 17:36:19 +02:00
Vinayak Kariappa Chettimada
9962faf3c6 Bluetooth: Controller: Add support for Extended Active Scanning
Add support for Extended Active Scanning and generation of
Extended Advertising Report with Scan Response event type.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-17 17:36:19 +02:00
Vinayak Kariappa Chettimada
bf20b23f0f Bluetooth: Controller: Reverting Extended scanning with LLL scheduling
Reverting Extended scanning with LLL scheduling as this is
causing unresolvable merge conflict with the commits that
is implementing the Extended Active Scanning support.

Subsequent commit add the revert implementation back again.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-17 17:36:19 +02:00
Vinayak Kariappa Chettimada
854aaeb8ae Bluetooth: Controller: nRF53x: Fix missing sw_switch clear DPPI config
Fix missing sw_switch timer clear DPPI config when
re-enabling Tx or Rx after radio_disable() or
radio_switch_complete_and_disable() call in LLL state/role
contexts.

Relates to commit 1c3659519f ("Bluetooth: controller:
nRF53x: Fix missing sw_switch clear DPPI config").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-17 17:36:19 +02:00
Daniel Leung
378ad046c8 drivers: bluetooth: build as static library
Instead of putting object files inside libzephyr.a,
simply build a separate static library as most other
driver types are doing this already.

Note that the include to subsys/bluetooth has been
moved from under drivers/bluetooth to subsys/bluetooth,
as it is actually the subsystem's job to make sure
the include directories are correct.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-08-17 06:06:03 -04:00
Daniel Leung
23712842d1 bluetooth: audio: build as static library
Make subsys/bluetooth/audio build as a static library.
This is in preparation to enable building the bluetooth
drivers as a static library. That would change the line
"zephyr_include_directories(subsys/bluetooth)" where
this include path is applied to all code compiled.
Its removal will result in subsys/bluetooth/audio not
able to find subsys/bluetooth/common/log.h. So change
subsys/bluetooth/audio to be built as a static library
so it can link to the subsys/bluetooth library where
it can find "log.h" there.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-08-17 06:06:03 -04:00
Vinayak Kariappa Chettimada
d1e64cb9d7 Bluetooth: Controller: Fix hci_core assertion on advertising disable
Fix a race condition that caused the Controller to deadlock
waiting for a semaphore that be given when LLL events have
been disabled.

ULL reference count is checked in thread context to decide
if LLL events are pending, but the reference count can be
decremented by the ULL execution context which prevents the
set `disabled_cb` function not being called due to no
pending event to produce the done events.

Fixed by re-checking if reference count is zero and avoid
waiting to take the semaphore.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-17 10:22:14 +02:00
Saleh Mehdikhani
8618de9be4 Bluetooth: controller: radio: Fix wrong argument of radio_df_ctrl_set
While RADIO_DFECTRL1_TSAMPLESPACING and RADIO_DFECTRL1_TSAMPLESPACINGREF
has similar values, but they are logically different.
As expected by "radio_df_ctrl_set" function, TSAMPLESPACING should be
passed to this function not TSAMPLESPACINGREF.

Signed-off-by: Saleh Mehdikhani <saleh.mehdikhani@unikie.com>
2021-08-17 10:21:10 +02:00
Vinayak Kariappa Chettimada
190532bcc4 Bluetooth: Controller: Only remove duplicate resume events
When events are placed back into pipeline as resume events,
only remove duplicate resume events and not new prepare
events that may have been enqueue between the start of the
pre-empt ticker and its timeout.

Due to new prepare events that was removed, extra done
events generated cause the number of enqueued done events
to overflow and assert.

Fixes #36381.
Fixes #37597.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-16 15:13:11 -04:00
Vinayak Kariappa Chettimada
790a291e24 Bluetooth: Controller: Fix incorrect pipeline iterator index reset
Fix the incorrect iterator index being reset when flushing
duplicate resume events in the pipeline.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-16 15:13:11 -04:00
Vinayak Kariappa Chettimada
82eb2a4019 Bluetooth: Controller: Update AD data race implementation
Update the AD data race condition handling with explicit
revert of `pdu->last` value after detecting the race.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-16 15:12:55 -04:00
Vinayak Kariappa Chettimada
30b4c29aaf Bluetooth: Controller: Minor conditional compile refactor
Minor conditional compile refactor.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-16 12:46:43 +02:00
Vinayak Kariappa Chettimada
c399155bc4 Bluetooth: Controller: Reduce the Rx window switch for continous scan
Reduce the Rx window swithch overhead for continuous scan by
using radio interfae `radio_tmr_start_now` that accounts for
any minimum ticker offset requirement.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-16 12:46:43 +02:00
Vinayak Kariappa Chettimada
22a96ade74 Bluetooth: Controller: Remove radio complete and Tx after scan response
Remove the radio software switch from Rx to Tx after
reception of scan response.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-16 12:46:43 +02:00
Vinayak Kariappa Chettimada
eddd1b18eb Bluetooth: Controller: Remove radio complete and Tx for passive scan
Remove the radio software switch from Rx to Tx when in
passive scanning, as there is no transmission requirement
after reception of a PDU.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-16 12:46:43 +02:00
Vinayak Kariappa Chettimada
dc633856d7 Bluetooth: Controller: Fix uninit update flag given to PDU _latest_get
Fix uninitialized update flag given to PDU _latest_get()
functions.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-13 10:14:50 -04:00
Morten Priess
fdc92ebb27 Bluetooth: controller: Implement ADV re-schedule for new scheduler
The new JIT scheduler does not have slot reservation, which means that
the ticker extension feature for automatically re-scheduling a colliding
non-anchored event, e.g. ADV, cannot be used.

This implementaion reacts to ADV envent done with result ABORTED or
TOO_LATE, and in those cases attempts to re-schedule the ADV event again
within the 10 ms pertubation window.

As the original scheduling, the re-scheduling is randomized, so there
is no absolute predictability as to how many attempts will be made. The
advertiser will attempt with randomly delayed re-schdules until the
window is exhausted.

If re-scheduling is unsuccessful, the weight of the ADV event is
increased, improving it's chances of success in the next event.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2021-08-13 07:30:56 -04:00
Fabio Baltieri
f88a420d69 toolchain: migrate iterable sections calls to the external API
This migrates all the current iterable section usages to the external
API, dropping the "Z_" prefix:

Z_ITERABLE_SECTION_ROM
Z_ITERABLE_SECTION_ROM_GC_ALLOWED
Z_ITERABLE_SECTION_RAM
Z_ITERABLE_SECTION_RAM_GC_ALLOWED
Z_STRUCT_SECTION_ITERABLE
Z_STRUCT_SECTION_ITERABLE_ALTERNATE
Z_STRUCT_SECTION_FOREACH

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2021-08-12 17:47:04 -04:00
Krzysztof Kopyściński
00bfac00ae Bluetooth: gatt: Add option to read multiple without variable length
Currently, with EATT enabled, when bt_gatt_read is called with multiple
handles first it'll try to use gatt_read_mult_vl, and if it fails
gatt_read_mult will be used to try again. Add option to skip
the gatt_read_mult_vl and use gatt_read_mult right away. This is needed
by tests that expect BT_ATT_OP_READ_MULT_REQ but support variable
lenght, thus don't return BT_ATT_ERR_NOT_SUPPORTED.

Removed fallback from read multiple vl to read multiple on
BT_ATT_ERR_NOT_SUPPORTED error.

This was affecting:
GATT/CL/GAR/BV-05-C, GATT/CL/GAR/BI-18-C, GATT/CL/GAR/BI-19-C,
GATT/CL/GAR/BI-20-C, GATT/CL/GAR/BI-21-C, GATT/CL/GAR/BI-22-C

Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
2021-08-12 11:07:08 -04:00
Vinayak Kariappa Chettimada
00d707e470 Bluetooth: Controller: Fix node rx memory corruption regression
Fix the node rx memory pool corruption regression introduced
due to same peer connection being rejected.

Regression introduced in commit 30f260dfaa ("Bluetooth:
controller: Fix adv/scan context access post release").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-12 11:57:12 +02:00
Vinayak Kariappa Chettimada
27b8beaa22 Bluetooth: Controller: Fix to handle relative short preempt timeout
When a new radio event is scheduled with a relatively short
preempt timeout while there is already a started preempt
ticker, then stop the ticker, abort the previous event that
requested the preemption, and request to start ticker with
the new relatively short preempt timeout.

Fixes #30245.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-12 11:56:56 +02:00
Vinayak Kariappa Chettimada
6cd9ec8c8d Bluetooth: Controller: Preempt ticker to use atmost one operation
When there are multiple events in prepare pipeline then fix
the implementation so that only one preempt ticker start
or stop operation is enqueued towards ticker_job for
processing.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-12 11:56:56 +02:00
Lingao Meng
8e1682d1ea samples: conn_cb replace to const zsector
It is more efficient and saves part of RAM
by replacing it with static one dynamically.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2021-08-11 13:42:28 +02:00
Lingao Meng
23a9594944 Bluetooth: Add connect event structure to zsector
Add an optional version for connection events
to save some memory.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2021-08-11 13:42:28 +02:00
Vinayak Kariappa Chettimada
eb22d5acf2 Bluetooth: Controller: Change random address on advertising re-enable
If HCI LE Set Extended Advertising Enable command is sent
again for an advertising set while that set is enabled, then
any change to the random address shall take effect.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-11 07:32:59 -04:00
Vinayak Kariappa Chettimada
e82fcb070a Bluetooth: Controller: Permit enabling already enabled advertising
Permit enabling already enabled advertising. Enabling
advertising when it is already enabled can cause the
random address to change, as specified in the Bluetooth
Specifications.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-11 07:32:59 -04:00
Vinayak Kariappa Chettimada
06f02b570e Bluetooth: Controller: Comment on enabling of already enabled scanning
Add comment about enabling of already enabled scanning.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-11 07:32:59 -04:00
Lingao Meng
6bf35fa749 Bluetooth: Mesh: Fixes Same appkey add to multi netkey
The latest MESH.TS 1.0.1.2 4.15.10 Appkey List Procedures
MESH/NODE/CFG/AKL/BI-04-C

Verify that the IUT can respond to an Config AppKey Add
message with NetKeyIndex and AppKeyIndex already stored.

6. Repeat step 1 with the same AppKey, the same
AppKeyIndex, but NetKeyIndex field set to 0x001.

7. The Lower Tester expects the IUT to respond
with an Config AppKey Status message with the
Status field set to 0x04 (Invalid NetKey) and
the NetKeyIndex and AppKeyIndex values equal to
those sent in step 5.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2021-08-10 07:39:11 -04:00
Vinayak Kariappa Chettimada
4830571356 Bluetooth: Controller: Fix advertising after connections from same peer
Fix the missing resumption of connectable advertising and
release of received connection complete buffers from LLL
after detecting connection from same peer.

Relates to commit 010c5c2f20 ("Bluetooth: controller:
Ignore connections from same peer").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-10 07:36:47 -04:00
Joakim Andersson
79021187ac Bluetooth: host: Check for mandatory callback when accepting new channel
Add a check for the mandatory channel receive callback when the
application provides the L2CAP channel operations.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-08-09 13:03:55 -04:00
Joakim Andersson
921644c5a6 Bluetooth: OTS: Make L2CAP channel recv callback static
Make the OTS module L2CAP channel recv callback a static function.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-08-09 13:03:55 -04:00
Joakim Andersson
9f989a0b00 Bluetooth: OTS: Add configuration for OTS channel TX mtu
Add configuration for Object Transfer Service channel MTU for outgoing
L2CAP SDUs.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-08-09 13:03:55 -04:00
Trond Einar Snekvik
8ab219cde5 bluetooth: Add defines for ECC key lengths
Adds defines for ECC public keys, private keys, DH keys and key
coordinates. Replaces raw numbers throughout.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2021-08-09 16:45:57 +02:00
Piotr Pryga
2675b8d8aa Bluetooth: controller: remove warning about defined bvt unused function
Remove compilation warning about adv_sync_pdu_ad_data_set function
that is defined but not used.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-08-07 20:50:03 -04:00
Piotr Pryga
120751118c Bluetooth: controller: ULL: Add handling of chains in disable CTE
Direction finding functionality allows to send a number of periodic
advertising PDUs in a chain that have CTE.
Disable sending CTE requiers additional steps while removing
cte_info from periodic advertising chains.
Removal of cte_info fields may be just delete of that filed
from extended advertising header. In case the PDUs are empty
PDUs created just to transport CTE. Those PDUs should be removed
from a periodic advertising chain.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-08-07 20:50:03 -04:00
Piotr Pryga
9c23fe0dcc Bluetooth: controller: Add release of chains when get latest adv pdu
Add release of chained PDUs by lll_adv_pdu_and_extra_data_-
latest_get function. It is requier to release unused
PDUs from a chain to avoid PDUs leakage.
It maight happen when chained PDUs were used by Direction
Finding, then lll_adv_pdu_and_extra_data_lates_get is used
instead of lll_adv_pdu_lates_get.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-08-07 20:50:03 -04:00
Piotr Pryga
467d132e6f Bluetooth: controller: Add macro with minimum allowed adv. PDU size
To check if advertising PDU is empty we can compare its length to 1.
To avoid use of magic number, the commit provides a macro for that
purpose.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-08-07 20:50:03 -04:00