From d6c3e04eb8a15e747c6ef445bff7b0563aa22052 Mon Sep 17 00:00:00 2001 From: Vinayak Kariappa Chettimada Date: Thu, 15 Dec 2022 13:05:23 +0530 Subject: [PATCH] Bluetooth: Controller: Central maximum data PDU size time spacing Use the maximum data PDU size time reservation space considering the Data length could be updated from default 27 bytes to maximum support size. If maximum time reservation is disabled then time space reservation corresponding to the default data length at the time of the start/enable of Central role is used. Note, currently this value is only used to space multiple central connections and not for actual ticker time reservations. Signed-off-by: Vinayak Kariappa Chettimada --- .../bluetooth/controller/Kconfig.ll_sw_split | 14 ++++++ subsys/bluetooth/controller/ll_sw/ull_sched.c | 45 +++++++++++++++++-- .../bsim_bt/bsim_test_multiple/prj.conf | 4 ++ 3 files changed, 59 insertions(+), 4 deletions(-) diff --git a/subsys/bluetooth/controller/Kconfig.ll_sw_split b/subsys/bluetooth/controller/Kconfig.ll_sw_split index d591c69bee6..1bbe41ecd96 100644 --- a/subsys/bluetooth/controller/Kconfig.ll_sw_split +++ b/subsys/bluetooth/controller/Kconfig.ll_sw_split @@ -459,6 +459,20 @@ config BT_CTLR_CENTRAL_SPACING (active clock jitter) + 17040 (PDU rx) = (radio event overheads + 34234) microseconds. +config BT_CTLR_CENTRAL_RESERVE_MAX + bool "Use maximum data PDU size time reservation for Central" + depends on BT_CENTRAL + default y + help + Use the maximum data PDU size time reservation considering the Data + length could be updated from default 27 bytes to maximum support size. + If maximum time reservation is disabled then time reservation + corresponding to the default data length at the time of the + start/enable of Central role is used. + + Note, currently this value is only used to space multiple central + connections and not for actual ticker time reservations. + config BT_CTLR_SLOT_RESERVATION_UPDATE bool "Update event length reservation after PHY or DLE update" depends on !BT_LL_SW_LLCP_LEGACY && (BT_CTLR_DATA_LENGTH || BT_CTLR_PHY) diff --git a/subsys/bluetooth/controller/ll_sw/ull_sched.c b/subsys/bluetooth/controller/ll_sw/ull_sched.c index 4866b770db8..3be5cb03bcc 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_sched.c +++ b/subsys/bluetooth/controller/ll_sw/ull_sched.c @@ -4,9 +4,8 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include - #include +#include #include "hal/ccm.h" #include "hal/radio.h" @@ -44,7 +43,7 @@ #include "ull_adv_internal.h" #include "ull_conn_internal.h" -#include +#include "ll_feat.h" #include "hal/debug.h" @@ -875,8 +874,46 @@ static struct ull_hdr *ull_hdr_get_cb(uint8_t ticker_id, uint32_t *ticks_slot) conn = ll_conn_get(ticker_id - TICKER_ID_CONN_BASE); if (conn && !conn->lll.role) { + uint32_t ticks_slot_conn; + + if (IS_ENABLED(CONFIG_BT_CTLR_CENTRAL_RESERVE_MAX)) { + uint32_t ready_delay_us; + uint16_t max_tx_time; + uint16_t max_rx_time; + uint32_t time_us; + +#if defined(CONFIG_BT_CTLR_PHY) + ready_delay_us = + lll_radio_tx_ready_delay_get(conn->lll.phy_tx, + conn->lll.phy_flags); +#else + ready_delay_us = + lll_radio_tx_ready_delay_get(0U, 0U); +#endif + +#if defined(CONFIG_BT_CTLR_PHY_CODED) + max_tx_time = PDU_DC_MAX_US(LL_LENGTH_OCTETS_TX_MAX, + PHY_CODED); + max_rx_time = PDU_DC_MAX_US(LL_LENGTH_OCTETS_RX_MAX, + PHY_CODED); +#else /* !CONFIG_BT_CTLR_PHY_CODED */ + max_tx_time = PDU_DC_MAX_US(LL_LENGTH_OCTETS_TX_MAX, + PHY_1M); + max_rx_time = PDU_DC_MAX_US(LL_LENGTH_OCTETS_RX_MAX, + PHY_1M); +#endif /* !CONFIG_BT_CTLR_PHY_CODED */ + + time_us = EVENT_OVERHEAD_START_US + + ready_delay_us + max_rx_time + + EVENT_IFS_US + max_tx_time; + ticks_slot_conn = + HAL_TICKER_US_TO_TICKS(time_us); + } else { + ticks_slot_conn = conn->ull.ticks_slot; + } + *ticks_slot = - MAX(conn->ull.ticks_slot, + MAX(ticks_slot_conn, HAL_TICKER_US_TO_TICKS( CONFIG_BT_CTLR_CENTRAL_SPACING)); diff --git a/tests/bluetooth/bsim_bt/bsim_test_multiple/prj.conf b/tests/bluetooth/bsim_bt/bsim_test_multiple/prj.conf index ef79513c895..0fb600d717c 100644 --- a/tests/bluetooth/bsim_bt/bsim_test_multiple/prj.conf +++ b/tests/bluetooth/bsim_bt/bsim_test_multiple/prj.conf @@ -45,3 +45,7 @@ CONFIG_BT_CTLR_RX_BUFFERS=6 # (Event Overhead + Radio Ready Delay + Rx window + 1064 + 154 + 1064) CONFIG_BT_CTLR_ADVANCED_FEATURES=y CONFIG_BT_CTLR_CENTRAL_SPACING=3750 + +# Do not use max data PDU size time reservation for connection events spacing +# instead use lesser value as supplied in CONFIG_BT_CTLR_CENTRAL_SPACING +CONFIG_BT_CTLR_CENTRAL_RESERVE_MAX=n