From 4e787d0a2aee09b662c180fbb94fa4da24341af5 Mon Sep 17 00:00:00 2001 From: Vinayak Kariappa Chettimada Date: Wed, 16 Feb 2022 11:00:11 +0530 Subject: [PATCH] Bluetooth: Controller: Use conn interval unit for Auxiliary event Use connection interval units of 1250 us for periodic scheduling of Extended Advertising auxiliary PDU events so that auxiliary events can be periodically grouped alongwith the Periodic Advertising Events. This will permit mitigating overlaps amongst them. Signed-off-by: Vinayak Kariappa Chettimada --- subsys/bluetooth/controller/ll_sw/lll.h | 7 ++--- .../ll_sw/nordic/lll/lll_sync_iso.c | 2 +- subsys/bluetooth/controller/ll_sw/ull_adv.c | 15 ++++++++--- .../bluetooth/controller/ll_sw/ull_adv_aux.c | 26 ++++++++++++++----- .../bluetooth/controller/ll_sw/ull_adv_iso.c | 4 +-- .../bluetooth/controller/ll_sw/ull_adv_sync.c | 2 +- subsys/bluetooth/controller/ll_sw/ull_sync.c | 2 +- .../bluetooth/controller/ll_sw/ull_sync_iso.c | 2 +- 8 files changed, 40 insertions(+), 20 deletions(-) diff --git a/subsys/bluetooth/controller/ll_sw/lll.h b/subsys/bluetooth/controller/ll_sw/lll.h index ea740f0dcc1..dc63a3ca72d 100644 --- a/subsys/bluetooth/controller/ll_sw/lll.h +++ b/subsys/bluetooth/controller/ll_sw/lll.h @@ -21,9 +21,10 @@ #define EVENT_DONE_LINK_CNT 1 #endif /* CONFIG_BT_CTLR_LOW_LAT_ULL */ -#define ADV_INT_UNIT_US 625U -#define SCAN_INT_UNIT_US 625U -#define CONN_INT_UNIT_US 1250U +#define ADV_INT_UNIT_US 625U +#define SCAN_INT_UNIT_US 625U +#define CONN_INT_UNIT_US 1250U +#define PERIODIC_INT_UNIT_US 1250U /* Intervals after which connection or sync establishment is considered lost */ #define CONN_ESTAB_COUNTDOWN 6U diff --git a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_sync_iso.c b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_sync_iso.c index a2a0fa1f546..20cdbbf9d38 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_sync_iso.c +++ b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_sync_iso.c @@ -489,7 +489,7 @@ static void isr_rx(void *param) HAL_TICKER_TICKS_TO_US(radio_tmr_start_get()) + radio_tmr_aa_restore() - addr_us_get(lll->phy) + (ceiling_fraction(lll->ptc_curr, lll->bn) * - lll->iso_interval * CONN_INT_UNIT_US); + lll->iso_interval * PERIODIC_INT_UNIT_US); iso_meta->status = 0U; lll->payload[bis_idx][payload_index] = node_rx; diff --git a/subsys/bluetooth/controller/ll_sw/ull_adv.c b/subsys/bluetooth/controller/ll_sw/ull_adv.c index 990e26ef100..9c5f9f28aa2 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_adv.c +++ b/subsys/bluetooth/controller/ll_sw/ull_adv.c @@ -1422,11 +1422,18 @@ uint8_t ll_adv_enable(uint8_t enable) /* Keep aux interval equal or higher than primary PDU * interval. + * Use periodic interval units to represent the + * periodic behavior of scheduling of AUX_ADV_IND PDUs + * so that it is grouped with similar interval units + * used for ACL Connections, Periodic Advertising and + * BIG radio events. */ - aux->interval = adv->interval + - (HAL_TICKER_TICKS_TO_US( - ULL_ADV_RANDOM_DELAY) / - ADV_INT_UNIT_US); + aux->interval = + ceiling_fraction(((uint64_t)adv->interval * + ADV_INT_UNIT_US) + + HAL_TICKER_TICKS_TO_US( + ULL_ADV_RANDOM_DELAY), + PERIODIC_INT_UNIT_US); ret = ull_adv_aux_start(aux, ticks_anchor_aux, ticks_slot_overhead_aux); diff --git a/subsys/bluetooth/controller/ll_sw/ull_adv_aux.c b/subsys/bluetooth/controller/ll_sw/ull_adv_aux.c index f2d28d909dd..9888862ef5b 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_adv_aux.c +++ b/subsys/bluetooth/controller/ll_sw/ull_adv_aux.c @@ -144,10 +144,20 @@ uint8_t ll_adv_aux_ad_data_set(uint8_t handle, uint8_t op, uint8_t frag_pref, uint32_t ticks_anchor; uint32_t ret; - aux->interval = adv->interval + - (HAL_TICKER_TICKS_TO_US( - ULL_ADV_RANDOM_DELAY) / - ADV_INT_UNIT_US); + /* Keep aux interval equal or higher than primary PDU + * interval. + * Use periodic interval units to represent the + * periodic behavior of scheduling of AUX_ADV_IND PDUs + * so that it is grouped with similar interval units + * used for ACL Connections, Periodic Advertising and + * BIG radio events. + */ + aux->interval = + ceiling_fraction(((uint64_t)adv->interval * + ADV_INT_UNIT_US) + + HAL_TICKER_TICKS_TO_US( + ULL_ADV_RANDOM_DELAY), + PERIODIC_INT_UNIT_US); /* TODO: Find the anchor before the group of * active Periodic Advertising events, so @@ -1056,9 +1066,12 @@ uint32_t ull_adv_aux_start(struct ll_adv_aux_set *aux, uint32_t ticks_anchor, uint32_t ticks_slot_overhead) { uint32_t volatile ret_cb; + uint32_t interval_us; uint8_t aux_handle; uint32_t ret; + interval_us = aux->interval * PERIODIC_INT_UNIT_US; + ull_hdr_init(&aux->ull); aux_handle = ull_adv_aux_handle_get(aux); @@ -1066,9 +1079,8 @@ uint32_t ull_adv_aux_start(struct ll_adv_aux_set *aux, uint32_t ticks_anchor, ret = ticker_start(TICKER_INSTANCE_ID_CTLR, TICKER_USER_ID_THREAD, (TICKER_ID_ADV_AUX_BASE + aux_handle), ticks_anchor, 0, - HAL_TICKER_US_TO_TICKS((uint64_t)aux->interval * - ADV_INT_UNIT_US), - TICKER_NULL_REMAINDER, TICKER_NULL_LAZY, + HAL_TICKER_US_TO_TICKS(interval_us), + HAL_TICKER_REMAINDER(interval_us), TICKER_NULL_LAZY, (aux->ull.ticks_slot + ticks_slot_overhead), ticker_cb, aux, ull_ticker_status_give, (void *)&ret_cb); diff --git a/subsys/bluetooth/controller/ll_sw/ull_adv_iso.c b/subsys/bluetooth/controller/ll_sw/ull_adv_iso.c index 4af727c34e5..92cc7677c4b 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_adv_iso.c +++ b/subsys/bluetooth/controller/ll_sw/ull_adv_iso.c @@ -302,7 +302,7 @@ uint8_t ll_big_create(uint8_t big_handle, uint8_t adv_handle, uint8_t num_bis, * or integer multiple of SDU interval for unframed PDUs */ iso_interval_us = ((sdu_interval * lll_adv_iso->bn) / - (bn * CONN_INT_UNIT_US)) * CONN_INT_UNIT_US; + (bn * PERIODIC_INT_UNIT_US)) * PERIODIC_INT_UNIT_US; /* Allocate next PDU */ err = ull_adv_sync_pdu_alloc(adv, ULL_ADV_PDU_EXTRA_DATA_ALLOC_IF_EXIST, @@ -341,7 +341,7 @@ uint8_t ll_big_create(uint8_t big_handle, uint8_t adv_handle, uint8_t num_bis, */ big_info->iso_interval = - sys_cpu_to_le16(iso_interval_us / CONN_INT_UNIT_US); + sys_cpu_to_le16(iso_interval_us / PERIODIC_INT_UNIT_US); big_info->num_bis = lll_adv_iso->num_bis; big_info->nse = lll_adv_iso->nse; big_info->bn = lll_adv_iso->bn; diff --git a/subsys/bluetooth/controller/ll_sw/ull_adv_sync.c b/subsys/bluetooth/controller/ll_sw/ull_adv_sync.c index 0c856b8606d..469b363ce97 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_adv_sync.c +++ b/subsys/bluetooth/controller/ll_sw/ull_adv_sync.c @@ -853,7 +853,7 @@ uint32_t ull_adv_sync_start(struct ll_adv_set *adv, ticks_slot_overhead = 0U; } - interval_us = (uint32_t)sync->interval * CONN_INT_UNIT_US; + interval_us = (uint32_t)sync->interval * PERIODIC_INT_UNIT_US; sync_handle = sync_handle_get(sync); diff --git a/subsys/bluetooth/controller/ll_sw/ull_sync.c b/subsys/bluetooth/controller/ll_sw/ull_sync.c index a2a9c0b18f2..7b0d67f27ff 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_sync.c +++ b/subsys/bluetooth/controller/ll_sw/ull_sync.c @@ -619,7 +619,7 @@ void ull_sync_setup(struct ll_scan_set *scan, struct ll_scan_aux_set *aux, lll->phy = aux->lll.phy; interval = sys_le16_to_cpu(si->interval); - interval_us = interval * CONN_INT_UNIT_US; + interval_us = interval * PERIODIC_INT_UNIT_US; /* Convert fromm 10ms units to interval units */ sync->timeout_reload = RADIO_SYNC_EVENTS((sync->timeout * 10U * diff --git a/subsys/bluetooth/controller/ll_sw/ull_sync_iso.c b/subsys/bluetooth/controller/ll_sw/ull_sync_iso.c index 93584dd8b22..652fa87c6ba 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_sync_iso.c +++ b/subsys/bluetooth/controller/ll_sw/ull_sync_iso.c @@ -383,7 +383,7 @@ void ull_sync_iso_setup(struct ll_sync_iso_set *sync_iso, } lll->iso_interval = sys_le16_to_cpu(bi->iso_interval); - interval_us = lll->iso_interval * CONN_INT_UNIT_US; + interval_us = lll->iso_interval * PERIODIC_INT_UNIT_US; sync_iso->timeout_reload = RADIO_SYNC_EVENTS((sync_iso->timeout * 10U * USEC_PER_MSEC),