Bluetooth: controller: split: handle latency for cancelled sync events

Update implementation of periodic advertiser's LLL to
correctly handle event counter values when latencies
introduced due to sync events cancelled by active events
operating in unreserved time space.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit is contained in:
Vinayak Kariappa Chettimada 2020-03-18 17:04:27 +05:30 committed by Carles Cufí
commit 55cebf0eaa

View file

@ -67,11 +67,20 @@ int lll_adv_sync_reset(void)
void lll_adv_sync_prepare(void *param) void lll_adv_sync_prepare(void *param)
{ {
struct lll_prepare_param *p = param; struct lll_prepare_param *p = param;
struct lll_adv_sync *lll = p->param;
uint16_t elapsed;
int err; int err;
err = lll_hfclock_on(); err = lll_hfclock_on();
LL_ASSERT(!err || err == -EINPROGRESS); LL_ASSERT(!err || err == -EINPROGRESS);
/* Instants elapsed */
elapsed = p->lazy + 1;
/* Save the (latency + 1) for use in event */
lll->latency_prepare += elapsed;
/* Invoke common pipeline handling of prepare */
err = lll_prepare(lll_is_abort_cb, abort_cb, prepare_cb, 0, p); err = lll_prepare(lll_is_abort_cb, abort_cb, prepare_cb, 0, p);
LL_ASSERT(!err || err == -EINPROGRESS); LL_ASSERT(!err || err == -EINPROGRESS);
} }
@ -122,31 +131,24 @@ static int prepare_cb(struct lll_prepare_param *prepare_param)
uint8_t data_chan_use; uint8_t data_chan_use;
uint32_t remainder; uint32_t remainder;
uint32_t start_us; uint32_t start_us;
uint16_t lazy;
uint8_t phy_s; uint8_t phy_s;
uint8_t upd; uint8_t upd;
DEBUG_RADIO_START_A(1); DEBUG_RADIO_START_A(1);
/* TODO: Do the below in ULL ? */ /* Deduce the latency */
lazy = prepare_param->lazy; lll->latency_event = lll->latency_prepare - 1;
/* save the latency for use in event */ /* Calculate the current event counter value */
lll->latency_prepare += lazy; event_counter = lll->event_counter + lll->latency_event;
/* calc current event counter value */ /* Update event counter to next value */
event_counter = lll->event_counter + lll->latency_prepare; lll->event_counter = lll->event_counter + lll->latency_prepare;
/* store the next event counter value */ /* Reset accumulated latencies */
lll->event_counter = event_counter + 1;
/* TODO: Do the above in ULL ? */
/* TODO: can we do something in ULL? */
lll->latency_event = lll->latency_prepare;
lll->latency_prepare = 0; lll->latency_prepare = 0;
data_chan_use = lll_chan_sel_2(lll->event_counter - 1, data_chan_use = lll_chan_sel_2(event_counter, lll->data_chan_id,
lll->data_chan_id,
&lll->data_chan_map[0], &lll->data_chan_map[0],
lll->data_chan_count); lll->data_chan_count);