Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bluetooth: Controller: Fix CIS accept fails with unsupp parameters #68227

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions subsys/bluetooth/controller/Kconfig.ll_sw_split
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,16 @@ config BT_CTLR_SCAN_ENABLE_STRICT
Enforce returning HCI Error Command Disallowed on enabling/disabling
already enabled/disabled scanning.

config BT_CTLR_CIS_ACCEPT_MIN_OFFSET_STRICT
bool "Enforce Strict CIS Minimum Offset Check"
depends on BT_CTLR_PERIPHERAL_ISO
help
Enforce strict check of CIS minimum offset accepted by the peripheral
considering that there will be no overlap of ACL connection with the
CIG events. Radio and CPU overheads for an ACL connection event is
considered and checks the CIS minimum offset is greater than the time
reservation for the ACL connection.

config BT_CTLR_ISOAL_SN_STRICT
bool "Enforce Strict Tx ISO Data Sequence Number use"
depends on !BT_CTLR_ISOAL_PSN_IGNORE && (BT_CTLR_ADV_ISO || \
Expand Down
23 changes: 20 additions & 3 deletions subsys/bluetooth/controller/ll_sw/ull_central_iso.c
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ uint8_t ll_cig_parameters_commit(uint8_t cig_id, uint16_t *handles)
mpt_c = PDU_CIS_MAX_US(cis->lll.tx.max_pdu, tx, cis->lll.tx.phy);
mpt_p = PDU_CIS_MAX_US(cis->lll.rx.max_pdu, rx, cis->lll.rx.phy);

se[i].length = mpt_c + EVENT_IFS_US + mpt_p + EVENT_MSS_US;
se[i].length = mpt_c + EVENT_IFS_MAX_US + mpt_p + EVENT_MSS_MAX_US;
max_se_length = MAX(max_se_length, se[i].length);

/* Total number of subevents needed */
Expand Down Expand Up @@ -836,8 +836,17 @@ uint8_t ull_central_iso_setup(uint16_t cis_handle,

/* ACL connection of the new CIS */
conn = ll_conn_get(cis->lll.acl_handle);

/* WORKAROUND:
* Some peer controller implementations are not able to establish CIS
* if the instant is equal to the current event count where CIS_IND PDU
* is received.
* ull_conn_event_counter() returns the current event count, CIS_IND PDU
* will be transmitted in the next event, hence add 2 so that the
* instant is one ahead of the event where CIS_IND PDU is transmitted.
*/
event_counter = ull_conn_event_counter(conn);
instant = MAX(*conn_event_count, event_counter + 1);
instant = MAX(*conn_event_count, event_counter + 2U);

#if defined(CONFIG_BT_CTLR_JIT_SCHEDULING)
uint32_t cis_offset;
Expand Down Expand Up @@ -948,7 +957,15 @@ int ull_central_iso_cis_offset_get(uint16_t cis_handle,

conn = ll_conn_get(cis->lll.acl_handle);

cis->central.instant = ull_conn_event_counter(conn) + 3U;
/* WORKAROUND:
* Some peer controller implementations are not able to establish CIS
* if the instant is equal to the current event count where CIS_IND PDU
* is received.
* ull_conn_event_counter() returns the current event count, CIS_REQ PDU
* CIS_RSP PDU and CIS_IND PDU take 3 connection events. Add 1 extra so
* that the instant is one ahead of where CIS_IND PDU is transmitted.
*/
cis->central.instant = ull_conn_event_counter(conn) + 4U;
*conn_event_count = cis->central.instant;

/* Provide CIS offset range
Expand Down
3 changes: 2 additions & 1 deletion subsys/bluetooth/controller/ll_sw/ull_peripheral_iso.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ uint8_t ll_cis_accept(uint16_t handle)
if (conn) {
uint32_t cis_offset_min;

if (IS_ENABLED(CONFIG_BT_CTLR_PERIPHERAL_ISO_EARLY_CIG_START)) {
if (IS_ENABLED(CONFIG_BT_CTLR_PERIPHERAL_ISO_EARLY_CIG_START) ||
!IS_ENABLED(CONFIG_BT_CTLR_CIS_ACCEPT_MIN_OFFSET_STRICT)) {
/* Early start allows offset down to spec defined minimum */
cis_offset_min = CIS_MIN_OFFSET_MIN;
} else {
Expand Down
1 change: 1 addition & 0 deletions tests/bluetooth/init/prj_ctlr_5_x_dbg.conf
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ CONFIG_BT_CTLR_ADV_RESERVE_MAX=n
CONFIG_BT_CTLR_ADV_ISO_RESERVE_MAX=n
CONFIG_BT_CTLR_SYNC_ISO_RESERVE_MAX=n
CONFIG_BT_CTLR_CENTRAL_RESERVE_MAX=n
CONFIG_BT_CTLR_CIS_ACCEPT_MIN_OFFSET_STRICT=y
CONFIG_BT_CTLR_EVENT_OVERHEAD_RESERVE_MAX=n
CONFIG_BT_CTLR_PROFILE_ISR=y
CONFIG_BT_CTLR_DEBUG_PINS=y
Expand Down
2 changes: 2 additions & 0 deletions tests/bluetooth/init/prj_ctlr_dbg.conf
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ CONFIG_BT_CTLR_LLL_PRIO=0
CONFIG_BT_CTLR_ULL_HIGH_PRIO=1
CONFIG_BT_CTLR_XTAL_ADVANCED=n
CONFIG_BT_CTLR_SCHED_ADVANCED=n
CONFIG_BT_CTLR_CIS_ACCEPT_MIN_OFFSET_STRICT=n
CONFIG_BT_CTLR_EVENT_OVERHEAD_RESERVE_MAX=y
CONFIG_BT_CTLR_RADIO_ENABLE_FAST=y
CONFIG_BT_CTLR_TIFS_HW=n
CONFIG_BT_CTLR_TX_RETRY_DISABLE=y
Expand Down
6 changes: 3 additions & 3 deletions tests/bluetooth/tester/nrf5340_hci_ipc_cpunet.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Apply this overlay at hci_ipc controller build
CONFIG_BT_CTLR_CONN_ISO_LOW_LATENCY_POLICY=y
CONFIG_BT_CTLR_DATA_LENGTH_MAX=100
CONFIG_BT_BUF_ACL_RX_SIZE=100
CONFIG_BT_CTLR_PERIPHERAL_ISO_EARLY_CIG_START=y
CONFIG_BT_CTLR_DATA_LENGTH_MAX=100
CONFIG_BT_CTLR_CONN_ISO_LOW_LATENCY_POLICY=y
CONFIG_BT_CTLR_ISOAL_PSN_IGNORE=y
CONFIG_BT_CTLR_PHY_CODED=n
2 changes: 1 addition & 1 deletion tests/bluetooth/tester/src/btp_bap_broadcast.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ static void stream_recv(struct bt_bap_stream *stream,
struct btp_bap_broadcast_remote_source *broadcaster;
struct btp_bap_broadcast_stream *b_stream = stream_bap_to_broadcast(stream);

if (b_stream->already_sent == false) {
if ((b_stream->already_sent == false) && (info->flags & BT_ISO_FLAGS_VALID)) {
/* For now, send just a first packet, to limit the number
* of logs and not unnecessarily spam through btp.
*/
Expand Down
2 changes: 1 addition & 1 deletion tests/bluetooth/tester/src/btp_bap_unicast.c
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ static void stream_recv(struct bt_bap_stream *stream,
{
struct btp_bap_unicast_stream *u_stream = stream_bap_to_unicast(stream);

if (u_stream->already_sent == false) {
if ((u_stream->already_sent == false) && (info->flags & BT_ISO_FLAGS_VALID)) {
/* For now, send just a first packet, to limit the number
* of logs and not unnecessarily spam through btp.
*/
Expand Down
Loading