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>
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>
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>
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>
Add compilation guards for the feature_rsp_send function to avoid
compilation errors for some configurations.
Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
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>
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>
Fix regression in adding the state for Connection Parameter
Request being rejected where in Connection Parameter Request
Procedure state machine was prematurely reset before the
reject PDU was enqueued.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix deferred Connection Parameter Request offset population
by introduction of explicit states waiting for the offset
calculations to complete in the ULL_LOW context.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix deferred Connection Update offset population by
introduction of explicit states waiting for the offset
calculation to complete in the ULL_LOW context.
Fixes#29636.
The problem was, in an encrypted connection the enqueued PDU
to be transmitted is encrypt in the prepare callback by the
hardware and swapped to a different buffer for transmission;
the deferred offset population did not reflect in the
transmitted PDU as it was filled in the cleartext buffer
while encryption completed into the encrypted buffer.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix implementation to run local peripheral initiated control
procedure with instant in parallel with remote initiated
encryption procedure.
Relates to #28887.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
If a PHY update is waiting for the instant to be reached and the master
starts the encryption procedure, store the pending PHY update procedure
and handle it simultaneously with the encryption setup.
This fix prevents the encryption setup from stalling and thereby timing
out after 40s, after which the master drops the link.
The ll_conn::llcp::encryption can not longer be unioned with the
ll_conn::llcp:phy_upd_ind as one would overwrite the other.
Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
Add conditional compilation on peripheral and central
specific control procedure implementation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Defined 625 and 1250 as context specific interval common to ULL and LLL.
Checked with bluetooth sanity checks.
Fixes#23314.
Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
Some proprietary protocols that reuse the Bluetooth LLCP logic requires
that the CPR interval has a valid range that differs from the Bluetooth
specification defined.
Vendor must implement the function (ull_vendor.h)
uint16_t ull_conn_interval_min_get(struct ll_conn *conn)
that returns the valid limit for the given connection.
Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
We have convenient PHY_1M, PHY_2M and PHY_CODED symbols defined but
they are not used too much in the code. This replaces all usages of
magic numbers and other symbols as PHY constants with those symbols.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Under CONFIG_BT_TICKER_EXT configuration, the ticker interface has been
extended to support enabling/disabling must-expire scheduling. This
means that conn and slave ticker start calls can now omit must-expire
default-on configuration, relying on LLL updating the mode as needed.
Signed-off-by: Morten Priess <mtpr@oticon.com>
If we allocate a node in LLL and it turns out that we don't need it
(e.g. allocated connection on AUX_CONNECT_REQ, but connection handshake
did not complete and we don't need it) we still need to send it to ULL
to be released. We can use existing NODE_RX_TYPE_DC_PDU_RELEASE node
type for this purpose, but we just need to make sure it's passed from
LLL to ULL properly.
Also, since this now does not only release DC PDUs, let's change its
name to a more generic one.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Validate the disconnect reason in the disconnect command, according
to the the core specification.
7.1.6 Disconnect command:
Authentication Failure error code (0x05), Other End Terminated Connec-
tion error codes (0x13 to 0x15), Unsupported Remote Feature error code
(0x1A), Pairing with Unit Key Not Supported error code (0x29) and Unac-
ceptable Connection Parameters error code (0x3B).
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Release the CUI/CPR lock if the connection owning the lock is
terminated.
This can happen if a device performing a CUI/CPR procedure gets a LSTO
before the procedeure completes or the procedure itself TO.
Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
When CONFIG_BT_CTLR_CONN_META is enabled and the ticker "must_expire"
feature is used, collisions may cause incorrect decrement of the
supervision_expire counter, resulting in a too early link supervision
timeout.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Fix PHY Update control procedure to accept the preferred Tx
coding options (S2 or S8) requested even if there is no
actual PHY change happening on procedure completion.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Legacy functionality in ull_conn will force scheduling of a connection
which has missed an anchor point due to lost RX. This kicks in either
for previously skipped events (latenzy_event != 0) or at random
depending on the randomness of the AA bit pattern.
This behavior is good at ensuring that a connection with errors or
aborted RX gets prioitized, and helps break locked round-robin
patterns with lost sync, but it also breaks the predictability of
the round-robin ticker scheduling.
With "must_expire" enabled, this feature also kicks in for scheduling
collisions, which may not be desirable.
This commit adds a configuration flag, BT_CTLR_CONN_RANDOM_FORCE, which
is default enabled (legacy behavior).
Signed-off-by: Morten Priess <mtpr@oticon.com>
The same code block for marking an object with
ull_disable_mark, stopping the ticker and then unmarking
the object appeared multiple places; often with a regression
bug where instead of unmarking it in case of error, it would
be "remarked".
This commit fixes the bug, and moves the functionality to
a common function.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Replaces all existing variants of value clamping with the MIN and MAX
macros with the CLAMP macro.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Added implementation to perform Periodic Sync Terminate,
generation of Sync Lost on terminate and on remote device
termination of Periodic Advertising.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Refactor out drift compensation implementation so as to
reuse it for Periodic Sync feature.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Refactor out clock ppm interface so that it can be reused
for Periodic Advertising Sync feature.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix implicit declaration warning for peripheral_latency_cancel
by moving it to ull_slave file.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix controller implementation to cancel peripheral latency
when initiating new control procedures.
Fixes#28699.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add checks to abort connection radio event preparation and
start, if the connection terminates with a race condition
with new radio event being prepared or being in prepare
pipeline.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix undeclared CONFIG_BT_CTLR_DATA_LENGTH_MAX when Force
MD bit automatic feature is enabled in nRF51 Series.
Fixes#28774.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added automatic runtime calculation of Forced MD bit count
based on incoming Tx buffer throughput.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix premature connection event close due to the new Tx
buffers not being de-multiplexed and routed to connection's
Lower Link Layer context when they arrive while being
inside the connection's radio event.
Also, fix master prepare to demux and enqueue two Tx buffers
so that MD bit can be set correctly.
Relates to #27981.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Refactor ull_conn_tx_ack function as it no longer needs to
return the connection context back to caller.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix for handling REJECT_IND PDU received for PHY Update,
Connection Parameter Request and Data Length Update control
procedures.
If a link layer control procedure collision occurs, example
with local initiated PHY Update Procedure, and peer sends a
REJECT_IND PDU, then the PHY Update Procedure is stalled.
Fixes#28282.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
-Wimplicit-fallthrough=2 requires a fallthrough comment or a compiler
to tells gcc that this happens intentionally.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Return BT_HCI_ERR_INVALID_CONN_ID if an invalid handle is
given by the HCI; currently sometimes BT_HCI_ERR_CMD_DISALLOWED
is returned
Signed-off-by: Andries Kruithof <Andries.Kruithof@nordicsemi.no>
Updated implementation to have consistent initialization of
ret_cb use when passing it to ticker function calls.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add explicit opcode check when handling received unknown
response PDU.
Without this, for example, an in progress Data Length Update
procedure state was reset when receiving an unknown response
to slave initiated feature request.
Fixes#26252.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>