From 918585263e6cf0db396cb51c6ee4eaea2f409819 Mon Sep 17 00:00:00 2001 From: Vinayak Kariappa Chettimada Date: Tue, 28 Jun 2022 20:28:39 +0530 Subject: [PATCH] Bluetooth: Controller: Use maximum Adv PDU size time reservation Use the maximum advertising PDU size time reservation consider the Advertising Data could be updated from zero to maximum support size. If maximum time reservation is disabled then time reservation corresponding to the Advertising Data present at the time of the start/enable of Advertising is used. Signed-off-by: Vinayak Kariappa Chettimada --- .../bluetooth/controller/Kconfig.ll_sw_split | 11 ++++++++ subsys/bluetooth/controller/ll_sw/ull_adv.c | 15 +++++++++-- .../bluetooth/controller/ll_sw/ull_adv_aux.c | 10 +++++++ subsys/bluetooth/controller/ll_sw/ull_sched.c | 26 +++++++++++-------- 4 files changed, 49 insertions(+), 13 deletions(-) diff --git a/subsys/bluetooth/controller/Kconfig.ll_sw_split b/subsys/bluetooth/controller/Kconfig.ll_sw_split index b5ec064f8f1..cff32f6392f 100644 --- a/subsys/bluetooth/controller/Kconfig.ll_sw_split +++ b/subsys/bluetooth/controller/Kconfig.ll_sw_split @@ -232,6 +232,17 @@ config BT_CTLR_ADV_SYNC_PDU_BACK2BACK_AFS Specific AUX Frame Space to be used for back-to-back transmission of periodic advertising trains. Time specified in microseconds. +config BT_CTLR_ADV_RESERVE_MAX + bool "Use maximum Advertising PDU size time reservation" + depends on BT_BROADCASTER && BT_CTLR_ADV_EXT + default y + help + Use the maximum advertising PDU size time reservation considering the + Advertising Data could be updated from zero to maximum support size. + If maximum time reservation is disabled then time reservation + corresponding to the Advertising Data present at the time of the + start/enable of Advertising is used. + config BT_CTLR_ADV_DATA_BUF_MAX int "Advertising Data Maximum Buffers" depends on BT_BROADCASTER diff --git a/subsys/bluetooth/controller/ll_sw/ull_adv.c b/subsys/bluetooth/controller/ll_sw/ull_adv.c index 94491f04a6b..a4747e48b9c 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_adv.c +++ b/subsys/bluetooth/controller/ll_sw/ull_adv.c @@ -1415,9 +1415,20 @@ uint8_t ll_adv_enable(uint8_t enable) * started. */ if (sync) { - const uint32_t ticks_slot_aux = - aux->ull.ticks_slot + + uint32_t ticks_slot_aux; +#if defined(CONFIG_BT_CTLR_ADV_RESERVE_MAX) + uint32_t us_slot; + + us_slot = ull_adv_aux_time_get(aux, + PDU_AC_PAYLOAD_SIZE_MAX, + PDU_AC_PAYLOAD_SIZE_MAX); + ticks_slot_aux = + HAL_TICKER_US_TO_TICKS(us_slot) + ticks_slot_overhead_aux; +#else + ticks_slot_aux = aux->ull.ticks_slot + + ticks_slot_overhead_aux; +#endif /* Schedule periodic advertising PDU after * auxiliary PDUs. diff --git a/subsys/bluetooth/controller/ll_sw/ull_adv_aux.c b/subsys/bluetooth/controller/ll_sw/ull_adv_aux.c index 273a7391b6b..7836032c457 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_adv_aux.c +++ b/subsys/bluetooth/controller/ll_sw/ull_adv_aux.c @@ -1079,9 +1079,13 @@ uint32_t ull_adv_aux_evt_init(struct ll_adv_aux_set *aux, uint32_t ticks_slot; int err; +#if defined(CONFIG_BT_CTLR_ADV_RESERVE_MAX) time_us = ull_adv_aux_time_get(aux, PDU_AC_PAYLOAD_SIZE_MAX, PDU_AC_PAYLOAD_SIZE_MAX); ticks_slot = HAL_TICKER_US_TO_TICKS(time_us); +#else + ticks_slot = aux->ull.ticks_slot; +#endif err = ull_sched_adv_aux_sync_free_slot_get(TICKER_USER_ID_THREAD, (ticks_slot + @@ -1210,6 +1214,12 @@ uint32_t ull_adv_aux_time_get(const struct ll_adv_aux_set *aux, uint8_t pdu_len, lll_aux = &aux->lll; lll = lll_aux->adv; + if (IS_ENABLED(CONFIG_BT_CTLR_ADV_RESERVE_MAX) && + (lll->phy_s == PHY_CODED)) { + pdu_len = PDU_AC_EXT_PAYLOAD_OVERHEAD; + pdu_scan_len = PDU_AC_EXT_PAYLOAD_OVERHEAD; + } + /* NOTE: 16-bit values are sufficient for minimum radio event time * reservation, 32-bit are used here so that reservations for * whole back-to-back chaining of PDUs can be accomodated where diff --git a/subsys/bluetooth/controller/ll_sw/ull_sched.c b/subsys/bluetooth/controller/ll_sw/ull_sched.c index fe1c7e31d76..85b129e833b 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_sched.c +++ b/subsys/bluetooth/controller/ll_sw/ull_sched.c @@ -833,13 +833,15 @@ static struct ull_hdr *ull_hdr_get_cb(uint8_t ticker_id, uint32_t *ticks_slot) aux = ull_adv_aux_get(ticker_id - TICKER_ID_ADV_AUX_BASE); if (aux) { - uint32_t time_us; + if (IS_ENABLED(CONFIG_BT_CTLR_ADV_RESERVE_MAX)) { + uint32_t time_us; - time_us = ull_adv_aux_time_get(aux, - PDU_AC_PAYLOAD_SIZE_MAX, - PDU_AC_PAYLOAD_SIZE_MAX); - - *ticks_slot = HAL_TICKER_US_TO_TICKS(time_us); + time_us = ull_adv_aux_time_get(aux, PDU_AC_PAYLOAD_SIZE_MAX, + PDU_AC_PAYLOAD_SIZE_MAX); + *ticks_slot = HAL_TICKER_US_TO_TICKS(time_us); + } else { + *ticks_slot = aux->ull.ticks_slot; + } return &aux->ull; } @@ -851,12 +853,14 @@ static struct ull_hdr *ull_hdr_get_cb(uint8_t ticker_id, uint32_t *ticks_slot) sync = ull_adv_sync_get(ticker_id - TICKER_ID_ADV_SYNC_BASE); if (sync) { - uint32_t time_us; + if (IS_ENABLED(CONFIG_BT_CTLR_ADV_RESERVE_MAX)) { + uint32_t time_us; - time_us = ull_adv_sync_time_get(sync, - PDU_AC_PAYLOAD_SIZE_MAX); - - *ticks_slot = HAL_TICKER_US_TO_TICKS(time_us); + time_us = ull_adv_sync_time_get(sync, PDU_AC_PAYLOAD_SIZE_MAX); + *ticks_slot = HAL_TICKER_US_TO_TICKS(time_us); + } else { + *ticks_slot = sync->ull.ticks_slot; + } return &sync->ull; }