Skip to content

Commit eea1573

Browse files
Tronilnashif
authored andcommitted
Bluetooth: Controller: Collection of small fixes for BIS
Use PDU_BIS_LLID_FRAMED in empty PDUs for framed BIS Allocate room for header when calculating max_pdu for framed BIS Set group_sync_delay, stream_sync_delay and framed properly for BIS broadcaster Add missing call to isoal_tx_event_prepare() for BIS Signed-off-by: Troels Nilsson <trnn@demant.com> Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
1 parent b1bcd79 commit eea1573

File tree

7 files changed

+66
-26
lines changed

7 files changed

+66
-26
lines changed

subsys/bluetooth/controller/hci/hci.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
#include "ll_sw/ull_sync_internal.h"
6969
#include "ll_sw/ull_conn_internal.h"
7070
#include "ll_sw/ull_sync_iso_internal.h"
71+
#include "ll_sw/ull_iso_internal.h"
7172
#include "ll_sw/ull_df_internal.h"
7273

7374
#include "ll.h"
@@ -7892,7 +7893,9 @@ static void le_big_sync_established(struct pdu_data *pdu,
78927893
* SDU_Interval
78937894
*/
78947895
iso_interval_us = lll->iso_interval * ISO_INT_UNIT_US;
7895-
big_sync_delay = ull_big_sync_delay(lll);
7896+
big_sync_delay = ull_iso_big_sync_delay(lll->num_bis, lll->bis_spacing, lll->nse,
7897+
lll->sub_interval, lll->phy, lll->max_pdu,
7898+
lll->enc);
78967899
if (lll->framing) {
78977900
/* Framed */
78987901
transport_latency_big = big_sync_delay +

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ static int prepare_cb_common(struct lll_prepare_param *p)
294294

295295
if (!link) {
296296
pdu = radio_pkt_empty_get();
297-
pdu->ll_id = PDU_BIS_LLID_START_CONTINUE;
297+
pdu->ll_id = lll->framing ? PDU_BIS_LLID_FRAMED : PDU_BIS_LLID_START_CONTINUE;
298298
pdu->len = 0U;
299299
} else {
300300
pdu = (void *)tx->pdu;
@@ -650,7 +650,8 @@ static void isr_tx_common(void *param,
650650
}
651651
if (!link || (tx->payload_count != payload_count)) {
652652
pdu = radio_pkt_empty_get();
653-
pdu->ll_id = PDU_BIS_LLID_START_CONTINUE;
653+
pdu->ll_id = lll->framing ? PDU_BIS_LLID_FRAMED :
654+
PDU_BIS_LLID_START_CONTINUE;
654655
pdu->len = 0U;
655656
} else {
656657
pdu = (void *)tx->pdu;

subsys/bluetooth/controller/ll_sw/ull_adv_iso.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,14 @@ static uint8_t big_create(uint8_t big_handle, uint8_t adv_handle, uint8_t num_bi
349349
iso_interval_us = iso_interval * PERIODIC_INT_UNIT_US;
350350

351351
} else {
352-
lll_adv_iso->max_pdu = MIN(LL_BIS_OCTETS_TX_MAX, max_sdu);
352+
if (framing) {
353+
/* Try to allocate room for one SDU + header */
354+
lll_adv_iso->max_pdu = MIN(LL_BIS_OCTETS_TX_MAX,
355+
max_sdu + PDU_ISO_SEG_HDR_SIZE +
356+
PDU_ISO_SEG_TIMEOFFSET_SIZE);
357+
} else {
358+
lll_adv_iso->max_pdu = MIN(LL_BIS_OCTETS_TX_MAX, max_sdu);
359+
}
353360

354361
/* FIXME: SDU per max latency */
355362
sdu_per_event = MAX((max_latency * USEC_PER_MSEC / sdu_interval), 2U) -
@@ -1504,11 +1511,19 @@ static void ticker_cb(uint32_t ticks_at_expire, uint32_t ticks_drift,
15041511
static struct lll_prepare_param p;
15051512
struct ll_adv_iso_set *adv_iso = param;
15061513
uint32_t remainder_us;
1514+
uint64_t event_count;
15071515
uint32_t ret;
15081516
uint8_t ref;
15091517

15101518
DEBUG_RADIO_PREPARE_A(1);
15111519

1520+
event_count = adv_iso->lll.payload_count / adv_iso->lll.bn;
1521+
for (int i = 0; i < adv_iso->lll.num_bis; i++) {
1522+
uint16_t stream_handle = adv_iso->lll.stream_handle[i];
1523+
1524+
ull_iso_lll_event_prepare(LL_BIS_ADV_HANDLE_FROM_IDX(stream_handle), event_count);
1525+
}
1526+
15121527
/* Increment prepare reference count */
15131528
ref = ull_ref_inc(&adv_iso->ull);
15141529
LL_ASSERT(ref);

subsys/bluetooth/controller/ll_sw/ull_iso.c

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -321,9 +321,12 @@ uint8_t ll_setup_iso_path(uint16_t handle, uint8_t path_dir, uint8_t path_id,
321321
sdu_interval = lll_iso->sdu_interval;
322322
burst_number = lll_iso->bn;
323323
flush_timeout = 0U; /* Not used for Broadcast ISO */
324-
group_sync_delay = 0U; /* FIXME: */
325-
stream_sync_delay = 0U; /* FIXME: */
326-
framed = 0U; /* FIXME: pick the framing value from context */
324+
group_sync_delay = ull_iso_big_sync_delay(lll_iso->num_bis, lll_iso->bis_spacing,
325+
lll_iso->nse, lll_iso->sub_interval,
326+
lll_iso->phy, lll_iso->max_pdu,
327+
lll_iso->enc);
328+
stream_sync_delay = group_sync_delay - stream_handle * lll_iso->bis_spacing;
329+
framed = lll_iso->framing;
327330
max_octets = lll_iso->max_pdu;
328331
#endif /* CONFIG_BT_CTLR_ADV_ISO */
329332

@@ -347,7 +350,10 @@ uint8_t ll_setup_iso_path(uint16_t handle, uint8_t path_dir, uint8_t path_id,
347350
sdu_interval = lll_iso->sdu_interval;
348351
burst_number = lll_iso->bn;
349352

350-
group_sync_delay = ull_big_sync_delay(lll_iso);
353+
group_sync_delay = ull_iso_big_sync_delay(lll_iso->num_bis, lll_iso->bis_spacing,
354+
lll_iso->nse, lll_iso->sub_interval,
355+
lll_iso->phy, lll_iso->max_pdu,
356+
lll_iso->enc);
351357
stream_sync_delay = group_sync_delay - stream_handle * lll_iso->bis_spacing;
352358
framed = lll_iso->framing;
353359
max_octets = lll_iso->max_pdu;
@@ -881,11 +887,14 @@ uint8_t ll_iso_receive_test(uint16_t handle, uint8_t payload_type)
881887
* BIG_Sync_Delay = (Num_BIS – 1) × BIS_Spacing
882888
* + (NSE – 1) × Sub_Interval + MPT.
883889
*/
884-
group_sync_delay = ull_big_sync_delay(lll_iso);
890+
group_sync_delay = ull_iso_big_sync_delay(lll_iso->num_bis, lll_iso->bis_spacing,
891+
lll_iso->nse, lll_iso->sub_interval,
892+
lll_iso->phy, lll_iso->max_pdu,
893+
lll_iso->enc);
885894
stream_sync_delay = group_sync_delay - stream_handle * lll_iso->bis_spacing;
886895

887896
role = ISOAL_ROLE_BROADCAST_SINK;
888-
framed = 0; /* FIXME: Get value from biginfo */
897+
framed = lll_iso->framing;
889898
bn = lll_iso->bn;
890899
ft = 0;
891900
sdu_interval = lll_iso->sdu_interval;
@@ -1497,15 +1506,38 @@ void ull_iso_lll_event_prepare(uint16_t handle, uint64_t event_count)
14971506
isoal_tx_event_prepare(dp->source_hdl, event_count);
14981507
}
14991508
} else if (IS_ADV_ISO_HANDLE(handle)) {
1500-
/* Send event deadline trigger to ISO-AL.
1501-
* TODO: Can be unified with CIS implementation.
1502-
*/
1509+
struct ll_iso_datapath *dp = NULL;
1510+
struct lll_adv_iso_stream *stream;
1511+
uint16_t stream_handle;
1512+
1513+
stream_handle = LL_BIS_ADV_IDX_FROM_HANDLE(handle);
1514+
stream = ull_adv_iso_stream_get(stream_handle);
1515+
1516+
if (stream) {
1517+
dp = stream->dp;
1518+
}
1519+
1520+
if (dp) {
1521+
isoal_tx_event_prepare(dp->source_hdl, event_count);
1522+
}
15031523
} else {
15041524
LL_ASSERT(0);
15051525
}
15061526
}
15071527
#endif /* CONFIG_BT_CTLR_ADV_ISO || CONFIG_BT_CTLR_CONN_ISO */
15081528

1529+
#if defined(CONFIG_BT_CTLR_ADV_ISO) || defined(CONFIG_BT_CTLR_SYNC_ISO)
1530+
uint32_t ull_iso_big_sync_delay(uint8_t num_bis, uint32_t bis_spacing, uint8_t nse,
1531+
uint32_t sub_interval, uint8_t phy, uint8_t max_pdu, bool enc)
1532+
{
1533+
/* BT Core v5.4 - Vol 6, Part B, Section 4.4.6.4:
1534+
* BIG_Sync_Delay = (Num_BIS – 1) × BIS_Spacing + (NSE – 1) × Sub_Interval + MPT.
1535+
*/
1536+
return (num_bis - 1) * bis_spacing + (nse - 1) * sub_interval +
1537+
BYTES2US(PDU_OVERHEAD_SIZE(phy) + max_pdu + (enc ? 4 : 0), phy);
1538+
}
1539+
#endif /* CONFIG_BT_CTLR_ADV_ISO || CONFIG_BT_CTLR_SYNC_ISO */
1540+
15091541
#if defined(CONFIG_BT_CTLR_SYNC_ISO) || defined(CONFIG_BT_CTLR_CONN_ISO)
15101542
void *ull_iso_pdu_rx_alloc_peek(uint8_t count)
15111543
{

subsys/bluetooth/controller/ll_sw/ull_iso_internal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ void ll_iso_rx_put(memq_link_t *link, void *rx);
2929
void *ll_iso_rx_get(void);
3030
void ll_iso_rx_dequeue(void);
3131
void ll_iso_transmit_test_send_sdu(uint16_t handle, uint32_t ticks_at_expire);
32+
uint32_t ull_iso_big_sync_delay(uint8_t num_bis, uint32_t bis_spacing, uint8_t nse,
33+
uint32_t sub_interval, uint8_t phy, uint8_t max_pdu, bool enc);
3234

3335
/* Must be implemented by vendor if vendor-specific data path is supported */
3436
bool ll_data_path_configured(uint8_t data_path_dir, uint8_t data_path_id);

subsys/bluetooth/controller/ll_sw/ull_sync_iso.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -815,18 +815,6 @@ void ull_sync_iso_done_terminate(struct node_rx_event_done *done)
815815
(ret == TICKER_STATUS_BUSY));
816816
}
817817

818-
uint32_t ull_big_sync_delay(const struct lll_sync_iso *lll_iso)
819-
{
820-
/* BT Core v5.4 - Vol 6, Part B, Section 4.4.6.4:
821-
* BIG_Sync_Delay = (Num_BIS – 1) × BIS_Spacing + (NSE – 1) × Sub_Interval + MPT.
822-
*/
823-
return (lll_iso->num_bis - 1) * lll_iso->bis_spacing +
824-
(lll_iso->nse - 1) * lll_iso->sub_interval +
825-
BYTES2US(PDU_OVERHEAD_SIZE(lll_iso->phy) +
826-
lll_iso->max_pdu + (lll_iso->enc ? 4 : 0),
827-
lll_iso->phy);
828-
}
829-
830818
static void disable(uint8_t sync_idx)
831819
{
832820
struct ll_sync_iso_set *sync_iso;

subsys/bluetooth/controller/ll_sw/ull_sync_iso_internal.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,3 @@ void ull_sync_iso_setup(struct ll_sync_iso_set *sync_iso,
1515
void ull_sync_iso_estab_done(struct node_rx_event_done *done);
1616
void ull_sync_iso_done(struct node_rx_event_done *done);
1717
void ull_sync_iso_done_terminate(struct node_rx_event_done *done);
18-
uint32_t ull_big_sync_delay(const struct lll_sync_iso *lll_iso);

0 commit comments

Comments
 (0)