Skip to content

Commit

Permalink
Bluetooth: controller: Fix ISO broadcaster pre-transmission groups > 1
Browse files Browse the repository at this point in the history
For pre-transmission groups > 1, the broadcaster link layer would fetch
incorrect payloads from the TX node queue.

Update payload index calculation to reference correct TX payload. Fix
PTO FIXMEs and range checks.

Signed-off-by: Morten Priess <mtpr@oticon.com>
  • Loading branch information
mtpr-ot authored and kartben committed Jan 14, 2025
1 parent 35aea49 commit d58724d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
21 changes: 18 additions & 3 deletions subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_iso.c
Original file line number Diff line number Diff line change
Expand Up @@ -627,9 +627,24 @@ static void isr_tx_common(void *param,
if (!pdu) {
uint8_t payload_index;

payload_index = (lll->bn_curr - 1U) +
(lll->ptc_curr * lll->pto);
payload_count = lll->payload_count + payload_index - lll->bn;
if (lll->ptc_curr) {
uint8_t ptx_idx = lll->ptc_curr - 1;
uint8_t ptx_payload_idx;
uint32_t ptx_group_mult;
uint8_t ptx_group_idx;

/* Calculate group index and multiplier for deriving
* pre-transmission payload index.
*/
ptx_group_idx = ptx_idx / lll->bn;
ptx_payload_idx = ptx_idx - ptx_group_idx * lll->bn;
ptx_group_mult = (ptx_group_idx + 1) * lll->pto;
payload_index = ptx_payload_idx + ptx_group_mult * lll->bn;
} else {
payload_index = lll->bn_curr - 1U;
}

payload_count = lll->payload_count - lll->bn + payload_index;

#if !TEST_WITH_DUMMY_PDU
struct lll_adv_iso_stream *stream;
Expand Down
11 changes: 4 additions & 7 deletions subsys/bluetooth/controller/ll_sw/ull_adv_iso.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,11 @@ static uint8_t big_create(uint8_t big_handle, uint8_t adv_handle, uint8_t num_bi
return BT_HCI_ERR_INVALID_PARAM;
}

/* FIXME: PTO is currently limited to BN */
if (!IN_RANGE(pto, 0x00, bn /*0x0F*/)) {
if (!IN_RANGE(pto, 0x00, 0x0F)) {
return BT_HCI_ERR_INVALID_PARAM;
}

if (bn * irc + pto < nse) {
if (pto && !(bn * irc < nse)) {
return BT_HCI_ERR_INVALID_PARAM;
}
} else {
Expand Down Expand Up @@ -1162,10 +1161,8 @@ static uint8_t ptc_calc(const struct lll_adv_iso *lll, uint32_t event_spacing,
(lll->sub_interval * lll->bn * lll->num_bis)) *
lll->bn;

/* FIXME: Here we restrict to a maximum of BN Pre-Transmission
* subevents per BIS
*/
ptc = MIN(ptc, lll->bn);
/* Restrict PTC to number of available subevents */
ptc = MIN(ptc, lll->nse - lll->bn * lll->irc);

return ptc;
}
Expand Down

0 comments on commit d58724d

Please sign in to comment.