Skip to content

Commit ae679bc

Browse files
cvinayakcarlescufi
authored andcommitted
Bluetooth: Controller: Move EVENT_OVERHEAD_START_US verbose assertion
Move the EVENT_OVERHEAD_START_US verbose assertion to each state/role LLL implementation so that correct state/role that is delayed is conveyed in the assertion message. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent 3c34163 commit ae679bc

File tree

13 files changed

+188
-181
lines changed

13 files changed

+188
-181
lines changed

subsys/bluetooth/controller/ll_sw/nordic/lll/lll.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -470,10 +470,7 @@ uint32_t lll_preempt_calc(struct ull_hdr *ull, uint8_t ticker_id,
470470
* duration.
471471
* 3. Increase the preempt to start ticks for future events.
472472
*/
473-
LL_ASSERT_MSG(false, "%s: Actual EVENT_OVERHEAD_START_US = %u",
474-
__func__, HAL_TICKER_TICKS_TO_US(diff));
475-
476-
return 1U;
473+
return diff;
477474
}
478475

479476
return 0U;

subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv.c

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -936,6 +936,7 @@ static int prepare_cb(struct lll_prepare_param *p)
936936
struct lll_adv *lll;
937937
uint32_t remainder;
938938
uint32_t start_us;
939+
uint32_t ret;
939940
uint32_t aa;
940941

941942
DEBUG_RADIO_START_A(1);
@@ -1034,36 +1035,37 @@ static int prepare_cb(struct lll_prepare_param *p)
10341035

10351036
#if defined(CONFIG_BT_CTLR_XTAL_ADVANCED) && \
10361037
(EVENT_OVERHEAD_PREEMPT_US <= EVENT_OVERHEAD_PREEMPT_MIN_US)
1038+
uint32_t overhead;
1039+
1040+
overhead = lll_preempt_calc(ull, (TICKER_ID_ADV_BASE + ull_adv_lll_handle_get(lll)),
1041+
ticks_at_event);
10371042
/* check if preempt to start has changed */
1038-
if (lll_preempt_calc(ull, (TICKER_ID_ADV_BASE +
1039-
ull_adv_lll_handle_get(lll)),
1040-
ticks_at_event)) {
1043+
if (overhead) {
1044+
LL_ASSERT_MSG(false, "%s: Actual EVENT_OVERHEAD_START_US = %u",
1045+
__func__, HAL_TICKER_TICKS_TO_US(overhead));
10411046
radio_isr_set(isr_abort, lll);
10421047
radio_disable();
10431048

10441049
return -ECANCELED;
1045-
} else
1050+
}
10461051
#endif /* CONFIG_BT_CTLR_XTAL_ADVANCED */
1047-
{
1048-
uint32_t ret;
10491052

10501053
#if defined(CONFIG_BT_CTLR_ADV_EXT) && defined(CONFIG_BT_TICKER_EXT_EXPIRE_INFO)
1051-
if (lll->aux) {
1052-
/* fill in aux ptr in pdu */
1053-
ull_adv_aux_lll_auxptr_fill(pdu, lll);
1054-
1055-
/* NOTE: as first primary channel PDU does not use remainder, the packet
1056-
* timer is started one tick in advance to start the radio with
1057-
* microsecond precision, hence compensate for the higher start_us value
1058-
* captured at radio start of the first primary channel PDU.
1059-
*/
1060-
lll->aux->ticks_pri_pdu_offset += 1U;
1061-
}
1054+
if (lll->aux) {
1055+
/* fill in aux ptr in pdu */
1056+
ull_adv_aux_lll_auxptr_fill(pdu, lll);
1057+
1058+
/* NOTE: as first primary channel PDU does not use remainder, the packet
1059+
* timer is started one tick in advance to start the radio with
1060+
* microsecond precision, hence compensate for the higher start_us value
1061+
* captured at radio start of the first primary channel PDU.
1062+
*/
1063+
lll->aux->ticks_pri_pdu_offset += 1U;
1064+
}
10621065
#endif
10631066

1064-
ret = lll_prepare_done(lll);
1065-
LL_ASSERT(!ret);
1066-
}
1067+
ret = lll_prepare_done(lll);
1068+
LL_ASSERT(!ret);
10671069

10681070
DEBUG_RADIO_START_A(1);
10691071

subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_aux.c

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ static int prepare_cb(struct lll_prepare_param *p)
120120
uint32_t start_us;
121121
uint8_t chan_idx;
122122
uint8_t phy_s;
123+
uint32_t ret;
123124
uint8_t upd;
124125
uint32_t aa;
125126

@@ -316,30 +317,31 @@ static int prepare_cb(struct lll_prepare_param *p)
316317

317318
#if defined(CONFIG_BT_CTLR_XTAL_ADVANCED) && \
318319
(EVENT_OVERHEAD_PREEMPT_US <= EVENT_OVERHEAD_PREEMPT_MIN_US)
320+
uint32_t overhead;
321+
322+
overhead = lll_preempt_calc(ull, (TICKER_ID_ADV_AUX_BASE + ull_adv_aux_lll_handle_get(lll)),
323+
ticks_at_event);
319324
/* check if preempt to start has changed */
320-
if (lll_preempt_calc(ull, (TICKER_ID_ADV_AUX_BASE +
321-
ull_adv_aux_lll_handle_get(lll)),
322-
ticks_at_event)) {
325+
if (overhead) {
326+
LL_ASSERT_MSG(false, "%s: Actual EVENT_OVERHEAD_START_US = %u",
327+
__func__, HAL_TICKER_TICKS_TO_US(overhead));
323328
radio_isr_set(lll_isr_abort, lll);
324329
radio_disable();
325330

326331
return -ECANCELED;
327-
} else
332+
}
328333
#endif /* CONFIG_BT_CTLR_XTAL_ADVANCED */
329-
{
330-
uint32_t ret;
331-
332-
if (IS_ENABLED(CONFIG_BT_CTLR_ADV_PERIODIC) &&
333-
IS_ENABLED(CONFIG_BT_TICKER_EXT_EXPIRE_INFO) &&
334-
sec_pdu->adv_ext_ind.ext_hdr_len &&
335-
sec_pdu->adv_ext_ind.ext_hdr.sync_info) {
336-
ull_adv_sync_lll_syncinfo_fill(sec_pdu, lll);
337-
}
338334

339-
ret = lll_prepare_done(lll);
340-
LL_ASSERT(!ret);
335+
if (IS_ENABLED(CONFIG_BT_CTLR_ADV_PERIODIC) &&
336+
IS_ENABLED(CONFIG_BT_TICKER_EXT_EXPIRE_INFO) &&
337+
sec_pdu->adv_ext_ind.ext_hdr_len &&
338+
sec_pdu->adv_ext_ind.ext_hdr.sync_info) {
339+
ull_adv_sync_lll_syncinfo_fill(sec_pdu, lll);
341340
}
342341

342+
ret = lll_prepare_done(lll);
343+
LL_ASSERT(!ret);
344+
343345
DEBUG_RADIO_START_A(1);
344346

345347
return 0;

subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_iso.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ static int prepare_cb_common(struct lll_prepare_param *p)
188188
struct ull_hdr *ull;
189189
uint32_t remainder;
190190
uint32_t start_us;
191+
uint32_t ret;
191192
uint8_t phy;
192193

193194
DEBUG_RADIO_START_A(1);
@@ -417,23 +418,24 @@ static int prepare_cb_common(struct lll_prepare_param *p)
417418
ARG_UNUSED(start_us);
418419
#endif /* !HAL_RADIO_GPIO_HAVE_PA_PIN */
419420

420-
if (0) {
421421
#if defined(CONFIG_BT_CTLR_XTAL_ADVANCED) && \
422422
(EVENT_OVERHEAD_PREEMPT_US <= EVENT_OVERHEAD_PREEMPT_MIN_US)
423+
uint32_t overhead;
424+
425+
overhead = lll_preempt_calc(ull, (TICKER_ID_ADV_ISO_BASE + lll->handle), ticks_at_event);
423426
/* check if preempt to start has changed */
424-
} else if (lll_preempt_calc(ull, (TICKER_ID_ADV_ISO_BASE + lll->handle),
425-
ticks_at_event)) {
427+
if (overhead) {
428+
LL_ASSERT_MSG(false, "%s: Actual EVENT_OVERHEAD_START_US = %u",
429+
__func__, HAL_TICKER_TICKS_TO_US(overhead));
426430
radio_isr_set(lll_isr_abort, lll);
427431
radio_disable();
428432

429433
return -ECANCELED;
434+
}
430435
#endif /* CONFIG_BT_CTLR_XTAL_ADVANCED */
431-
} else {
432-
uint32_t ret;
433436

434-
ret = lll_prepare_done(lll);
435-
LL_ASSERT(!ret);
436-
}
437+
ret = lll_prepare_done(lll);
438+
LL_ASSERT(!ret);
437439

438440
/* Calculate ahead the next subevent channel index */
439441
next_chan_calc(lll, event_counter, data_chan_id);

subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_sync.c

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ static int prepare_cb(struct lll_prepare_param *p)
120120
uint32_t remainder;
121121
uint32_t start_us;
122122
uint8_t phy_s;
123+
uint32_t ret;
123124
uint8_t upd;
124125

125126
DEBUG_RADIO_START_A(1);
@@ -237,28 +238,29 @@ static int prepare_cb(struct lll_prepare_param *p)
237238

238239
#if defined(CONFIG_BT_CTLR_XTAL_ADVANCED) && \
239240
(EVENT_OVERHEAD_PREEMPT_US <= EVENT_OVERHEAD_PREEMPT_MIN_US)
241+
uint32_t overhead;
242+
243+
overhead = lll_preempt_calc(ull, (TICKER_ID_ADV_SYNC_BASE +
244+
ull_adv_sync_lll_handle_get(lll)), ticks_at_event);
240245
/* check if preempt to start has changed */
241-
if (lll_preempt_calc(ull, (TICKER_ID_ADV_SYNC_BASE +
242-
ull_adv_sync_lll_handle_get(lll)),
243-
ticks_at_event)) {
246+
if (overhead) {
247+
LL_ASSERT_MSG(false, "%s: Actual EVENT_OVERHEAD_START_US = %u",
248+
__func__, HAL_TICKER_TICKS_TO_US(overhead));
244249
radio_isr_set(lll_isr_abort, lll);
245250
radio_disable();
246251

247252
return -ECANCELED;
248-
} else
253+
}
249254
#endif /* CONFIG_BT_CTLR_XTAL_ADVANCED */
250-
{
251-
uint32_t ret;
252255

253256
#if defined(CONFIG_BT_CTLR_ADV_ISO) && defined(CONFIG_BT_TICKER_EXT_EXPIRE_INFO)
254-
if (lll->iso) {
255-
ull_adv_iso_lll_biginfo_fill(pdu, lll);
256-
}
257+
if (lll->iso) {
258+
ull_adv_iso_lll_biginfo_fill(pdu, lll);
259+
}
257260
#endif /* CONFIG_BT_CTLR_ADV_ISO && CONFIG_BT_TICKER_EXT_EXPIRE_INFO */
258261

259-
ret = lll_prepare_done(lll);
260-
LL_ASSERT(!ret);
261-
}
262+
ret = lll_prepare_done(lll);
263+
LL_ASSERT(!ret);
262264

263265
DEBUG_RADIO_START_A(1);
264266

subsys/bluetooth/controller/ll_sw/nordic/lll/lll_central.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ static int prepare_cb(struct lll_prepare_param *p)
101101
struct ull_hdr *ull;
102102
uint32_t remainder;
103103
uint8_t cte_len;
104+
uint32_t ret;
104105

105106
DEBUG_RADIO_START_M(1);
106107

@@ -240,21 +241,22 @@ static int prepare_cb(struct lll_prepare_param *p)
240241

241242
#if defined(CONFIG_BT_CTLR_XTAL_ADVANCED) && \
242243
(EVENT_OVERHEAD_PREEMPT_US <= EVENT_OVERHEAD_PREEMPT_MIN_US)
244+
uint32_t overhead;
245+
246+
overhead = lll_preempt_calc(ull, (TICKER_ID_CONN_BASE + lll->handle), ticks_at_event);
243247
/* check if preempt to start has changed */
244-
if (lll_preempt_calc(ull, (TICKER_ID_CONN_BASE + lll->handle),
245-
ticks_at_event)) {
248+
if (overhead) {
249+
LL_ASSERT_MSG(false, "%s: Actual EVENT_OVERHEAD_START_US = %u",
250+
__func__, HAL_TICKER_TICKS_TO_US(overhead));
246251
radio_isr_set(lll_isr_abort, lll);
247252
radio_disable();
248253

249254
return -ECANCELED;
250-
} else
251-
#endif /* CONFIG_BT_CTLR_XTAL_ADVANCED */
252-
{
253-
uint32_t ret;
254-
255-
ret = lll_prepare_done(lll);
256-
LL_ASSERT(!ret);
257255
}
256+
#endif /* !CONFIG_BT_CTLR_XTAL_ADVANCED */
257+
258+
ret = lll_prepare_done(lll);
259+
LL_ASSERT(!ret);
258260

259261
DEBUG_RADIO_START_M(1);
260262

subsys/bluetooth/controller/ll_sw/nordic/lll/lll_central_iso.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -375,21 +375,22 @@ static int prepare_cb(struct lll_prepare_param *p)
375375
ARG_UNUSED(start_us);
376376
#endif /* !HAL_RADIO_GPIO_HAVE_PA_PIN */
377377

378-
if (false) {
379-
380378
#if defined(CONFIG_BT_CTLR_XTAL_ADVANCED) && \
381379
(EVENT_OVERHEAD_PREEMPT_US <= EVENT_OVERHEAD_PREEMPT_MIN_US)
380+
uint32_t overhead;
381+
382+
overhead = lll_preempt_calc(ull, (TICKER_ID_CONN_ISO_BASE + cig_lll->handle),
383+
ticks_at_event);
382384
/* check if preempt to start has changed */
383-
} else if (lll_preempt_calc(ull,
384-
(TICKER_ID_CONN_ISO_BASE + cig_lll->handle),
385-
ticks_at_event)) {
385+
if (overhead) {
386+
LL_ASSERT_MSG(false, "%s: Actual EVENT_OVERHEAD_START_US = %u",
387+
__func__, HAL_TICKER_TICKS_TO_US(overhead));
386388
radio_isr_set(lll_isr_abort, cig_lll);
387389
radio_disable();
388390

389391
return -ECANCELED;
390-
#endif /* CONFIG_BT_CTLR_XTAL_ADVANCED */
391-
392392
}
393+
#endif /* CONFIG_BT_CTLR_XTAL_ADVANCED */
393394

394395
/* Adjust the SN and NESN for skipped CIG events */
395396
cis_handle = cis_handle_curr;

subsys/bluetooth/controller/ll_sw/nordic/lll/lll_peripheral.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ static int prepare_cb(struct lll_prepare_param *p)
113113
struct ull_hdr *ull;
114114
uint32_t remainder;
115115
uint32_t hcto;
116+
uint32_t ret;
116117

117118
DEBUG_RADIO_START_S(1);
118119

@@ -322,21 +323,22 @@ static int prepare_cb(struct lll_prepare_param *p)
322323

323324
#if defined(CONFIG_BT_CTLR_XTAL_ADVANCED) && \
324325
(EVENT_OVERHEAD_PREEMPT_US <= EVENT_OVERHEAD_PREEMPT_MIN_US)
326+
uint32_t overhead;
327+
328+
overhead = lll_preempt_calc(ull, (TICKER_ID_CONN_BASE + lll->handle), ticks_at_event);
325329
/* check if preempt to start has changed */
326-
if (lll_preempt_calc(ull, (TICKER_ID_CONN_BASE + lll->handle),
327-
ticks_at_event)) {
330+
if (overhead) {
331+
LL_ASSERT_MSG(false, "%s: Actual EVENT_OVERHEAD_START_US = %u",
332+
__func__, HAL_TICKER_TICKS_TO_US(overhead));
328333
radio_isr_set(lll_isr_abort, lll);
329334
radio_disable();
330335

331336
return -ECANCELED;
332-
} else
337+
}
333338
#endif /* CONFIG_BT_CTLR_XTAL_ADVANCED */
334-
{
335-
uint32_t ret;
336339

337-
ret = lll_prepare_done(lll);
338-
LL_ASSERT(!ret);
339-
}
340+
ret = lll_prepare_done(lll);
341+
LL_ASSERT(!ret);
340342

341343
DEBUG_RADIO_START_S(1);
342344

subsys/bluetooth/controller/ll_sw/nordic/lll/lll_peripheral_iso.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -350,21 +350,22 @@ static int prepare_cb(struct lll_prepare_param *p)
350350
#endif /* !CONFIG_BT_CTLR_PHY */
351351
#endif /* HAL_RADIO_GPIO_HAVE_LNA_PIN */
352352

353-
if (false) {
354-
355353
#if defined(CONFIG_BT_CTLR_XTAL_ADVANCED) && \
356354
(EVENT_OVERHEAD_PREEMPT_US <= EVENT_OVERHEAD_PREEMPT_MIN_US)
355+
uint32_t overhead;
356+
357+
overhead = lll_preempt_calc(ull, (TICKER_ID_CONN_ISO_BASE + cig_lll->handle),
358+
ticks_at_event);
357359
/* check if preempt to start has changed */
358-
} else if (lll_preempt_calc(ull,
359-
(TICKER_ID_CONN_ISO_BASE + cig_lll->handle),
360-
ticks_at_event)) {
360+
if (overhead) {
361+
LL_ASSERT_MSG(false, "%s: Actual EVENT_OVERHEAD_START_US = %u",
362+
__func__, HAL_TICKER_TICKS_TO_US(overhead));
361363
radio_isr_set(lll_isr_abort, cig_lll);
362364
radio_disable();
363365

364366
return -ECANCELED;
365-
#endif /* CONFIG_BT_CTLR_XTAL_ADVANCED */
366-
367367
}
368+
#endif /* CONFIG_BT_CTLR_XTAL_ADVANCED */
368369

369370
/* Adjust the SN and NESN for skipped CIG events */
370371
uint16_t cis_handle = cis_handle_curr;

0 commit comments

Comments
 (0)