Skip to content

Commit 5aae5d2

Browse files
cvinayakcarlescufi
authored andcommitted
Bluetooth: Controller: Fix Connected ISO for aborted prepare
Fix Connected ISO implementation to correctly handle SN, NESN and payload_count when prepare callback is aborted due to CPU overhead related latencies. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent ae679bc commit 5aae5d2

File tree

2 files changed

+42
-4
lines changed

2 files changed

+42
-4
lines changed

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

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ static int prepare_cb(struct lll_prepare_param *p)
155155
uint16_t lazy;
156156
uint32_t ret;
157157
uint8_t phy;
158+
int err = 0;
158159

159160
DEBUG_RADIO_START_M(1);
160161

@@ -385,10 +386,11 @@ static int prepare_cb(struct lll_prepare_param *p)
385386
if (overhead) {
386387
LL_ASSERT_MSG(false, "%s: Actual EVENT_OVERHEAD_START_US = %u",
387388
__func__, HAL_TICKER_TICKS_TO_US(overhead));
388-
radio_isr_set(lll_isr_abort, cig_lll);
389+
390+
radio_isr_set(isr_done, cis_lll);
389391
radio_disable();
390392

391-
return -ECANCELED;
393+
err = -ECANCELED;
392394
}
393395
#endif /* CONFIG_BT_CTLR_XTAL_ADVANCED */
394396

@@ -409,10 +411,30 @@ static int prepare_cb(struct lll_prepare_param *p)
409411
/* sn and nesn are 1-bit, only Least Significant bit is needed */
410412
cis_lll->sn += cis_lll->tx.bn * cis_lazy;
411413
cis_lll->nesn += cis_lll->rx.bn * cis_lazy;
414+
415+
/* Adjust sn and nesn for canceled events */
416+
if (err) {
417+
/* Adjust sn when flushing Tx */
418+
/* FIXME: When Flush Timeout is implemented */
419+
if (cis_lll->tx.bn_curr <= cis_lll->tx.bn) {
420+
lll_flush_tx(cis_lll);
421+
}
422+
423+
/* Adjust nesn when flushing Rx */
424+
/* FIXME: When Flush Timeout is implemented */
425+
if (cis_lll->rx.bn_curr <= cis_lll->rx.bn) {
426+
lll_flush_rx(cis_lll);
427+
}
428+
}
412429
}
413430
}
414431
} while (cis_lll);
415432

433+
/* Return if prepare callback cancelled */
434+
if (err) {
435+
return err;
436+
}
437+
416438
/* Prepare is done */
417439
ret = lll_prepare_done(cig_lll);
418440
LL_ASSERT(!ret);

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

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ static int prepare_cb(struct lll_prepare_param *p)
173173
uint16_t lazy;
174174
uint32_t ret;
175175
uint8_t phy;
176+
int err = 0;
176177

177178
DEBUG_RADIO_START_S(1);
178179

@@ -360,10 +361,11 @@ static int prepare_cb(struct lll_prepare_param *p)
360361
if (overhead) {
361362
LL_ASSERT_MSG(false, "%s: Actual EVENT_OVERHEAD_START_US = %u",
362363
__func__, HAL_TICKER_TICKS_TO_US(overhead));
363-
radio_isr_set(lll_isr_abort, cig_lll);
364+
365+
radio_isr_set(isr_done, cis_lll);
364366
radio_disable();
365367

366-
return -ECANCELED;
368+
err = -ECANCELED;
367369
}
368370
#endif /* CONFIG_BT_CTLR_XTAL_ADVANCED */
369371

@@ -399,9 +401,23 @@ static int prepare_cb(struct lll_prepare_param *p)
399401
/* sn and nesn are 1-bit, only Least Significant bit is needed */
400402
cis_lll->sn += cis_lll->tx.bn * lazy;
401403
cis_lll->nesn += cis_lll->rx.bn * lazy;
404+
405+
/* Adjust sn and nesn for canceled events */
406+
if (err) {
407+
/* Adjust nesn when flushing Rx */
408+
/* FIXME: When Flush Timeout is implemented */
409+
if (cis_lll->rx.bn_curr <= cis_lll->rx.bn) {
410+
lll_flush_rx(cis_lll);
411+
}
412+
}
402413
}
403414
};
404415

416+
/* Return if prepare callback cancelled */
417+
if (err) {
418+
return err;
419+
}
420+
405421
/* Prepare is done */
406422
ret = lll_prepare_done(cig_lll);
407423
LL_ASSERT(!ret);

0 commit comments

Comments
 (0)