Commit graph

202 commits

Author SHA1 Message Date
Vinayak Kariappa Chettimada
19099fc980 Bluetooth: Controller: Use define for invalid LLL context handle
Use a define for invalid LLL context handle instead of
0xFFFF magic value.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-27 06:47:21 -04:00
Vinayak Kariappa Chettimada
1c564e750b Bluetooth: Controller: Use id addr type to check same peer connection
Store and check device identity addr type of public or
random.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-27 06:47:21 -04:00
Vinayak Kariappa Chettimada
f06ac2be2c Bluetooth: Controller: Fix LLL events pending check from ULL Low
ULL reference count is checked in ULL_LOW context to decide
if LLL events are pending, but the reference count can be
decremented by the ULL HIGH execution context which can
prevent the set `disabled_cb` function not being called due
to no pending event to produce the done events.

Fixed by checking the reference count in the ULL HIGH
execution context using a mayfly to schedule the check.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-27 06:46:55 -04:00
Vinayak Kariappa Chettimada
d2be89d725 Bluetooth: Controller: Use consistent naming for ticker op callbacks
Use consistent naming for ticker operation callback
functions.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-27 06:46:55 -04:00
Erik Brockhoff
f41b3d7879 Bluetooth: Controller: Fix conn param req ack/req reset
llcp.conn_param.ack was reset on tx of conn param rsp, however this
should only be done once the expected conn update ind is received
and sets the cu.ack flag to indicate cu procedure 'takes over'.

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-25 18:07:35 -04:00
Vinayak Kariappa Chettimada
1ce46fd7a6 Bluetooth: Controller: Add PDU time calculation for S2 Coded PHY
Add PDU time calculation macro for S2 and S8 Coded PHY.
Rename PKT_AC_US to PDU_AC_MAX_US.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-25 18:06:47 -04:00
Vinayak Kariappa Chettimada
88b155de31 Bluetooth: Controller: Rename PKT_US to PDU_DC_MAX_US
Rename PKT_US to PDU_DC_MAX_US.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-25 18:06:47 -04:00
Vinayak Kariappa Chettimada
869d3c24d7 Bluetooth: Controller: Rename PKT_DC_US to PDU_MAX_US
Rename PKT_DC_US to PDU_MAX_US.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-25 18:06:47 -04:00
Piotr Pryga
8382d6e5be Bluetooth: controller: Add CTE Rx params struct to lll_conn declaration
Add struct ll_df_conn_rx_params sturcutre to struct lll_conn.
This is storage for parametrers required to configure radio
for CTE reception in connected mode by lower link layer.

Add required includes to make the controller code compilable
after change struct ll_conn.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-08-18 20:11:10 -04:00
Piotr Pryga
ee71d95011 Bluetooth: controller: Add CTE Rx params struct to ll_conn declaration
Add struct ll_df_conn_rx_params sturcutre to struct ll_conn.
This is storage for parametrers required to configure radio
for CTE reception in connected mode.

Add required includes to make the controller code compilable
after change struct ll_conn.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-08-18 20:11:10 -04:00
Vinayak Kariappa Chettimada
97adf875b8 Bluetooth: Controller: Flush pending Tx PDUs before PHY update
Flush any pending Tx PDUs in the lower link layer before
enqueueing PHY_UPDATE_IND PDU with instant to ensure the
PDU is transmitted before the instant occurs.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-07-28 11:38:42 +02:00
Vinayak Kariappa Chettimada
d8f4759c5f Bluetooth: Controller: Fail on multiple PHY use in PHY_UPDATE_IND
Disconnect connection if peer central uses multiple PHYs in
PHY_UPDATE_IND PDU.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-07-28 11:38:15 +02:00
Vinayak Kariappa Chettimada
0bd05c0ed9 Bluetooth: Controller: Rename CPR mutual exclusion functions
Rename CPR mutual exclusion function to not sound similar to
OS mutex interfaces.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-07-01 13:30:50 -04:00
Vinayak Kariappa Chettimada
a8d4c062fa Bluetooth: Controller: Use inline functions for CPR mutex operations
Use inline functions for CPR mutex operations.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-07-01 13:30:50 -04:00
Vinayak Kariappa Chettimada
d518337835 Bluetooth: Controller: Cleanup mutual exclusion in CPR implementation
Minor cleanup of the implementation of mutual exclusion
of LE Connection Parameter Request amongst active
connections.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-07-01 13:30:50 -04:00
Vinayak Kariappa Chettimada
d3c27aeb8f Bluetooth: Controller: Fix Data Length Update node Rx reservations
Reserve a minimum node rx of 2 that can happen when local
central initiated PHY Update reserves 2 node rx, one for PHY
Update complete and another for Data Length Update complete
notification. Otherwise, a peripheral only needs 1
additional node rx to generate Data Length Update complete
when PHY Update completes.

Relates to #36381.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-06-29 17:05:20 -04:00
Vinayak Kariappa Chettimada
ecf7106177 Bluetooth: Controller: Minor change to use IS_ENABLED
Minor changes to use IS_ENABLED and updates to comments in
code.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-06-29 17:05:20 -04:00
Morten Priess
d1f71e93a0 Bluetooth: controller: CIS/CIG teardown at ACL disconnect
When an ACL connection with active CISes terminates, inject CIS/CIG
teardown to ensure CIS is stopped before ACL disconnection completes.
This includes stopping CIG ticker when last CIS has stopped.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2021-06-16 10:38:38 +02:00
Vinayak Kariappa Chettimada
adae515d8d Bluetooth: controller: Fix conn setup regression
Fix incorrect and redundant use of ticker user id ULL_LOW
instead of ULL_HIGH when setting up a connection using a
mayfly to disable LLL context. Also, the LLL context pointer
is invalid, where node rx is passed instead of LLL context.

Use the ULL disabled callback when done event has not yet
been processed, or a direct connection setup in ULL_HIGH
context when ULL is already disabled (reference count is
zero) is sufficient.

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

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-06-04 12:13:34 -05:00
Vinayak Kariappa Chettimada
30f260dfaa Bluetooth: controller: Fix adv/scan context access post release
Fix advertiser and scanning context being accessed on done
event when connection complete node rx that is processed
earlier has release them.

Relates to #30735.
Fixes #35013.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-05-10 18:19:00 +02:00
Vinayak Kariappa Chettimada
32d9b68944 Bluetooth: controller: Implement LE Set Host Feature Command
Added implementation of HCI LE Set Host Feature command.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-05-07 15:25:18 +02:00
Vinayak Kariappa Chettimada
ed59ceba62 Bluetooth: controller: Replace use if LL_FEAT with ll_feat_get()
Replace the use of LL_FEAT define with ll_feat_get() so that
feature set value can be updated at runtime with host
feature bit values.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-05-07 15:25:18 +02:00
Joakim Andersson
6483e12a8a Bluetooth: Refactor bluetooth buffer configuration for simplification
Refactor and simplify the bluetooth buffer configurations to improve the
easy of configurations and eliminate invalid ones.
By moving configurations out of host and controller specific
configurations and into a common one it becomes easier to configure
the host and controller separately as the same configurations can be
used as would be for a combined build.

All HCI configurations are now given exluding the matching HCI header,
which eases the configuration as the application don't have to know the
different header sizes.
The BT_RX_BUF_LEN is split into ACL and Event, as well as the suprising
use of Command size.
BT_L2CAP_RX_MTU is removed as the stack does not support reassembling of
HCI ACL data to larger L2CAP PDUs. The application will have to set
ACL RX size and account for the L2CAP PDU header itself.
BT_EATT_RX_MTU was removed as it is only used for setting a different
default value for another option which leads to the stuck kconfig symbol
problem.

The configurations can be updated according to the table below:

** New configuration         | ** Old configuration
All configurations
BT_BUF_ACL_RX_SIZE           | BT_L2CAP_RX_MTU + 4
BT_BUF_ACL_RX_SIZE           | BT_RX_BUF_LEN - 4
BT_BUF_EVT_RX_SIZE           | BT_RX_BUF_LEN - 2
BT_BUF_CMD_TX_SIZE           | BT_RX_BUF_LEN - 3
BT_BUF_CMD_TX_COUNT          | BT_HCI_CMD_COUNT
BT_BUF_EVT_RX_COUNT          | BT_RX_BUF_COUNT
BT_BUF_ACL_RX_COUNT          | BT_RX_BUF_COUNT
BT_BUF_ACL_RX_COUNT          | BT_ACL_RX_COUNT
BT_BUF_EVT_DISCARDABLE_SIZE  | BT_DISCARDABLE_BUF_SIZE - 2
BT_BUF_EVT_DISCARDABLE_COUNT | BT_DISCARDABLE_BUF_COUNT
Controller-build
BT_BUF_ACL_TX_SIZE           | BT_CTLR_TX_BUFFERS_SIZE
BT_BUF_ACL_TX_COUNT          | BT_CTLR_TX_BUFFER
HCI-bridge
BT_BUF_ACL_TX_SIZE           | BT_HCI_ACL_DATA_SIZE
BT_BUF_ACL_TX_COUNT          | 6

Fixed invalid configurations setting either BT_L2CAP_RX_MTU or
BT_CTLR_DATA_LENGTH_MAX larger than BT_RX_BUF_LEN could lead to buffer
overruns.

Fix advertising report max data length calculation.
This always used the BT_DISCARDABLE_BUF_SIZE macro but this feature
can be turned off and advertising reports will be allocated from the RX
buffer in that case. Also controller-build does not have this buffer
(in hci_raw.c). Also the wrong HCI header was used in the calculation,
HCI event header should have been used instead of HCI ACL header.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-05-06 14:56:18 +02:00
Vinayak Kariappa Chettimada
a4d2e062cb Bluetooth: controller: Fix regression in central initiated terminate
Fix regression in central initiated terminate introduced in
commit 3a80785947 ("Bluetooth: controller: Fix connection
terminate to happen on event done").

The regression caused an additional central connection event
transmitting PDU  after the previous connection event had
received acknowledgment for the terminate_ind PDU from the
peripheral.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-05-05 14:21:05 +02:00
Vinayak Kariappa Chettimada
236755198b Bluetooth: controller: Rename use of params to param
Rename the use of params word with param.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-05-05 14:15:05 +02:00
Wolfgang Puffitsch
feb9943e84 Bluetooth: controller: Fix overflow with preferred periodicity
Avoid possibly overflowing maximum interval when calculating interval
with preferred periodicity.

Changed calculation to round down from maximum interval and reset to
maximum in case of underflowing minimum interval.

Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
2021-04-26 13:38:34 +02:00
Asger Munk Nielsen
19650299fb Bluetooth: controller: Moved sdu_interval field members
Moved sdu_interval struct members from llcp_cis to cis group,
to match spec and enable access by ULL

Signed-off-by: Asger Munk Nielsen <asmk@oticon.com>
2021-04-23 15:00:45 +02:00
Vinayak Kariappa Chettimada
41e9493ae1 Bluetooth: controller: Fix missing encryption procedure state check
Fix a missing encryption procedure state check which allowed
out of order receive of START_ENC_RSP PDU, which made the
controller to believe its already in an encryption procedure
in progress state.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-04-19 10:59:01 -04:00
Vinayak Kariappa Chettimada
82925a8c99 Bluetooth: controller: Avoid sizeof to access ULL/LLL struct member
Avoid using sizeof to access ULL and LLL struct members.
Based on the alignment requirements of structures, due to
padding between structure members, use of sizeof of previous
struct member to access next struct member is incorrect.

Continue to use explicitly stored parent pointer to access
ULL context. Combine event header and ULL header so that
the parent pointer point directly to the combined ULL
struct.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-04-19 10:26:38 +02:00
Vinayak Kariappa Chettimada
3a80785947 Bluetooth: controller: Fix connection terminate to happen on event done
Fix conn_cleanup to be performed in the event done. The
regression was introduced in
commit 5412f61ac6 ("Bluetooth: controller: Introduce
separate done memq").

Now that done event is handled asynchronously outside the
handling of the terminate node rx type, it is necessary that
terminate node rx type is generated after the done event.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-04-19 10:26:38 +02:00
Morten Priess
4277af8f55 Bluetooth: controller: Rename BT_TICKER_COMPATIBILITY_MODE
Renamed to BT_TICKER_LOW_LAT in ticker, and changed selected
conditionally compiled code to use IS_DEFINED macro.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2021-04-13 12:15:12 +02:00
Vinayak Kariappa Chettimada
ab5d8432d3 Bluetooth: controller: Fix PHY Update procedure checks
Fix PHY update procedure to check transaction violations.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-03-30 19:42:46 +02:00
Vinayak Kariappa Chettimada
03fa38aa7e Bluetooth: controller: Fix ping procedure checks
Fix ping procedure to check transaction violations.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-03-30 19:42:46 +02:00
Vinayak Kariappa Chettimada
f8cec621d2 Bluetooth: controller: Fix data length update procedure checks
Fix data legnth update procedure to check transaction
violations.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-03-30 19:42:46 +02:00
Vinayak Kariappa Chettimada
fa95660b63 Bluetooth: controller: Fix reject extended indication checks
Fix reject extended indication PDU dispatch to check
transaction violations.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-03-30 19:42:46 +02:00
Vinayak Kariappa Chettimada
ef9e429228 Bluetooth: controller: Fix unknown control PDU checks
Fix unknown control procedure handling to check transaction
violations.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-03-30 19:42:46 +02:00
Vinayak Kariappa Chettimada
9cb8b0af89 Bluetooth: controller: Fix Feature Exchange checks
Fix Feature Exchange procedure to check transaction
violations.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-03-30 19:42:46 +02:00
Vinayak Kariappa Chettimada
fb5b5b7069 Bluetooth: controller: Add control procedure lock
Add control procedure lock flag to detection procedure
transaction violations.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-03-30 19:42:46 +02:00
Vinayak Kariappa Chettimada
34451a9970 Bluetooth: controller: Conditional compile adv addr used by initiator
Conditional compile adv_addr which is only used by
controller when supporting initiator/central role.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-03-30 14:04:23 +02:00
Morten Priess
e0b8881622 Bluetooth: controller: Temporary LLCP CIS_REQ/CIS_IND handling
Implemented LL_CIS_REQ/RSP and LL_CIS_IND handling to allow a central
to establish a CIS connection. Implementation is temporary, for
test/development purpose and should be re-implemented in the new LLCP
framework when ready.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2021-03-27 08:57:03 -04:00
Flavio Ceolin
9fd4ea91b7 coccinelle: Remove extra semicolon
coccicheck --mode=patch --cocci=semicolon.cocci

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-03-25 11:35:30 -05:00
Vinayak Kariappa Chettimada
7f727ac322 Bluetooth: controller: Fix regression in ctrl tx queue handling
Fix control Tx buffer leak into data Tx pool that happens
after a cross-over control procedure response was paused due
to currently active encryption setup procedure, and a new
control Tx PDU in addition to the paused one is enqueued
thereafter.

When the control tx PDUs is resumed but not yet enqueued
towards the radio, if there is a new control Tx PDU enqueued
then the paused control Tx PDU is not set as the head of the
control PDUs in the Tx queue. This caused the paused control
Tx PDU to be associated with data Tx pool, hence causing the
incorrect release into data Tx pool.

Relates to the commit bff76b4cce ("Bluetooth: controller:
split: Fix control tx queue handling") and to the
commit 6991d09977 ("Bluetooth: controller: Fix control tx
queue handling").

Fixes #32898.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-03-18 11:52:23 -04:00
Wolfgang Puffitsch
010c5c2f20 Bluetooth: controller: Ignore connections from same peer
Ignore connection indications from peers that are already
connected. This is to bring the behavior of the controller in
accordance with [5.2, Vol 6, Part B, 4.5 Connection state]:
"If an advertiser receives a connection request from an initiator it
is already connected to, it shall ignore that request."

Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
2021-03-17 15:32:47 -04:00
Vinayak Kariappa Chettimada
dec6140685 Bluetooth: controller: Fix dev assert in CPR implementation
Replace a development assertion in the implementation of
Connection Parameter Request Procedure with an internal
comment and handle transaction violation be ignoring the
PDU.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-03-16 10:02:05 +01:00
Vinayak Kariappa Chettimada
f9511079b2 Bluetooth: controller: Remove vendor specific internal LLL include
Remove inclusion of vendor specific internal LLL include
files in ULL source code.

Prefix `lll/` include file path to correctly include vendor
defined types and function implementation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-03-01 11:24:40 +01:00
Wolfgang Puffitsch
70f3e5a726 Bluetooth: controller: Add guards for feature_rsp_send
Add compilation guards for the feature_rsp_send function to avoid
compilation errors for some configurations.

Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
2021-02-16 12:02:00 -05: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
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
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
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