From 0f2980db15f3448533c8a978e71daffbde2cdbf2 Mon Sep 17 00:00:00 2001 From: Vinayak Kariappa Chettimada Date: Tue, 31 Jan 2023 12:30:49 +0530 Subject: [PATCH] Bluetooth: Controller: Maximize BIG event length and preempt PTO & CTRL Maximize BIG event length to extend upto ISO interval, and allow PTO and Control subevents to be pre-emptible. Signed-off-by: Vinayak Kariappa Chettimada --- .../bluetooth/controller/Kconfig.ll_sw_split | 12 +++++ .../bluetooth/controller/ll_sw/ull_adv_iso.c | 53 +++++++++++++------ 2 files changed, 49 insertions(+), 16 deletions(-) diff --git a/subsys/bluetooth/controller/Kconfig.ll_sw_split b/subsys/bluetooth/controller/Kconfig.ll_sw_split index 5fb2c54d085..1fa9031d47f 100644 --- a/subsys/bluetooth/controller/Kconfig.ll_sw_split +++ b/subsys/bluetooth/controller/Kconfig.ll_sw_split @@ -386,6 +386,18 @@ config BT_CTLR_ADV_RESERVE_MAX corresponding to the Advertising Data present at the time of the start/enable of Advertising is used. +config BT_CTLR_ADV_ISO_RESERVE_MAX + bool "Use maximum Broadcast ISO event time reservation" + depends on BT_CTLR_ADV_ISO + default y + help + Use maximum Broadcast ISO event time reservation. If disabled, then + time reservation does not include the pre-transmissions of the last + BIS and any Control subevents. This will allow extended or periodic + advertising events to preempt the BIG events but allow higher radio + utilizations by allowing larger BIG events when not overlapping with + extended or periodic advertising. + config BT_CTLR_ADV_AUX_SYNC_OFFSET int "Pre-defined offset between AUX_ADV_IND and AUX_SYNC_IND" depends on BT_CTLR_ADV_PERIODIC diff --git a/subsys/bluetooth/controller/ll_sw/ull_adv_iso.c b/subsys/bluetooth/controller/ll_sw/ull_adv_iso.c index 4551fac228d..de78352baa2 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_adv_iso.c +++ b/subsys/bluetooth/controller/ll_sw/ull_adv_iso.c @@ -282,27 +282,41 @@ uint8_t ll_big_create(uint8_t big_handle, uint8_t adv_handle, uint8_t num_bis, event_spacing = latency_packing + ctrl_spacing + EVENT_OVERHEAD_START_US + EVENT_OVERHEAD_END_US; - /* Calculate overheads due to extended advertising. */ - aux = HDR_LLL2ULL(adv->lll.aux); - ticks_slot_aux = aux->ull.ticks_slot; - if (IS_ENABLED(CONFIG_BT_CTLR_LOW_LAT)) { - ticks_slot_overhead = MAX(aux->ull.ticks_active_to_start, - aux->ull.ticks_prepare_to_start); + /* Check if aux context allocated before we are creating ISO */ + if (adv->lll.aux) { + aux = HDR_LLL2ULL(adv->lll.aux); } else { - ticks_slot_overhead = 0U; + aux = NULL; + } + + /* Calculate overheads due to extended advertising. */ + if (aux && aux->is_started) { + ticks_slot_aux = aux->ull.ticks_slot; + if (IS_ENABLED(CONFIG_BT_CTLR_LOW_LAT)) { + ticks_slot_overhead = MAX(aux->ull.ticks_active_to_start, + aux->ull.ticks_prepare_to_start); + } else { + ticks_slot_overhead = 0U; + } + ticks_slot_aux += ticks_slot_overhead; + } else { + ticks_slot_aux = 0U; } - ticks_slot_aux += ticks_slot_overhead; /* Calculate overheads due to periodic advertising. */ sync = HDR_LLL2ULL(lll_adv_sync); - ticks_slot_sync = sync->ull.ticks_slot; - if (IS_ENABLED(CONFIG_BT_CTLR_LOW_LAT)) { - ticks_slot_overhead = MAX(sync->ull.ticks_active_to_start, - sync->ull.ticks_prepare_to_start); + if (sync->is_started) { + ticks_slot_sync = sync->ull.ticks_slot; + if (IS_ENABLED(CONFIG_BT_CTLR_LOW_LAT)) { + ticks_slot_overhead = MAX(sync->ull.ticks_active_to_start, + sync->ull.ticks_prepare_to_start); + } else { + ticks_slot_overhead = 0U; + } + ticks_slot_sync += ticks_slot_overhead; } else { - ticks_slot_overhead = 0U; + ticks_slot_sync = 0U; } - ticks_slot_sync += ticks_slot_overhead; /* Calculate total overheads due to extended and periodic advertising */ if (CONFIG_BT_CTLR_ADV_AUX_SYNC_OFFSET > 0U) { @@ -1008,8 +1022,15 @@ static uint32_t adv_iso_start(struct ll_adv_iso_set *adv_iso, EVENT_MSS_US; ctrl_spacing = PDU_BIS_US(sizeof(struct pdu_big_ctrl), lll_iso->enc, lll_iso->phy, lll_iso->phy_flags); - slot_us = (pdu_spacing * lll_iso->nse * lll_iso->num_bis) + - ctrl_spacing; + + if (IS_ENABLED(CONFIG_BT_CTLR_ADV_ISO_RESERVE_MAX)) { + slot_us = (pdu_spacing * lll_iso->nse * lll_iso->num_bis) + + ctrl_spacing; + } else { + slot_us = pdu_spacing * ((lll_iso->nse * lll_iso->num_bis) - + lll_iso->ptc); + } + slot_us += EVENT_OVERHEAD_START_US + EVENT_OVERHEAD_END_US; adv_iso->ull.ticks_active_to_start = 0U;