Bluetooth: controller: Fix ISO broadcaster pre-transmission groups > 1

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>
This commit is contained in:
Morten Priess 2024-08-22 14:42:56 +02:00 committed by Benjamin Cabé
commit d58724d7d7
2 changed files with 22 additions and 10 deletions

View file

@ -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;

View file

@ -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 {
@ -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;
}