Skip to content

Commit fe83a9d

Browse files
mtpr-otaescolar
authored andcommitted
Bluetooth: controller: Fixes and improvements for PTO implementation
- Add next pointer to node_rx_iso_meta for pre-transmission linked list (does not increase memory usage as union is larger). - Fix broadcaster not setting PTC with test configuration - Refactor stopping of sync ISO tickers to separate function Signed-off-by: Morten Priess <[email protected]>
1 parent 541b516 commit fe83a9d

File tree

3 files changed

+36
-30
lines changed

3 files changed

+36
-30
lines changed

subsys/bluetooth/controller/ll_sw/lll.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,7 @@ struct node_rx_iso_meta {
396396
uint64_t payload_number:39; /* cisPayloadNumber */
397397
uint64_t status:8; /* Status of reception (OK/not OK) */
398398
uint32_t timestamp; /* Time of reception */
399+
void *next; /* Pointer to next pre-transmission rx_node (BIS) */
399400
};
400401

401402
/* Define invalid/unassigned Controller state/role instance handle */

subsys/bluetooth/controller/ll_sw/ull_adv_iso.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -444,13 +444,15 @@ static uint8_t big_create(uint8_t big_handle, uint8_t adv_handle, uint8_t num_bi
444444
return BT_HCI_ERR_INVALID_PARAM;
445445
}
446446

447+
lll_adv_iso->ptc = ptc_calc(lll_adv_iso, event_spacing, event_spacing_max);
448+
447449
if (test_config) {
448450
lll_adv_iso->pto = pto;
449451

452+
if (pto && !lll_adv_iso->ptc) {
453+
return BT_HCI_ERR_INVALID_PARAM;
454+
}
450455
} else {
451-
lll_adv_iso->ptc = ptc_calc(lll_adv_iso, event_spacing,
452-
event_spacing_max);
453-
454456
/* Pre-Transmission Offset (PTO) */
455457
if (lll_adv_iso->ptc) {
456458
lll_adv_iso->pto = bn / lll_adv_iso->bn;

subsys/bluetooth/controller/ll_sw/ull_sync_iso.c

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ static void ticker_stop_op_cb(uint32_t status, void *param);
6767
static void sync_iso_disable(void *param);
6868
static void disabled_cb(void *param);
6969
static void lll_flush(void *param);
70+
static void stop_ticker(struct ll_sync_iso_set *sync_iso, ticker_op_func fp_op_func);
7071

7172
static memq_link_t link_lll_prepare;
7273
static struct mayfly mfy_lll_prepare = {0U, 0U, &link_lll_prepare, NULL, NULL};
@@ -741,18 +742,10 @@ void ull_sync_iso_done(struct node_rx_event_done *done)
741742

742743
/* Check for establishmet failure */
743744
if (done->extra.estab_failed) {
744-
uint8_t handle;
745-
uint32_t ret;
746-
747745
/* Stop Sync ISO Ticker directly. Establishment failure has been
748746
* notified.
749747
*/
750-
handle = sync_iso_handle_get(sync_iso);
751-
ret = ticker_stop(TICKER_INSTANCE_ID_CTLR, TICKER_USER_ID_ULL_HIGH,
752-
(TICKER_ID_SCAN_SYNC_ISO_BASE +
753-
sync_iso_handle_to_index(handle)), NULL, NULL);
754-
LL_ASSERT((ret == TICKER_STATUS_SUCCESS) ||
755-
(ret == TICKER_STATUS_BUSY));
748+
stop_ticker(sync_iso, NULL);
756749
return;
757750
}
758751

@@ -835,8 +828,6 @@ void ull_sync_iso_done_terminate(struct node_rx_event_done *done)
835828
struct ll_sync_iso_set *sync_iso;
836829
struct lll_sync_iso *lll;
837830
struct node_rx_pdu *rx;
838-
uint8_t handle;
839-
uint32_t ret;
840831

841832
/* Get reference to ULL context */
842833
sync_iso = CONTAINER_OF(done->param, struct ll_sync_iso_set, ull);
@@ -850,13 +841,7 @@ void ull_sync_iso_done_terminate(struct node_rx_event_done *done)
850841
*((uint8_t *)rx->pdu) = lll->term_reason;
851842

852843
/* Stop Sync ISO Ticker */
853-
handle = sync_iso_handle_get(sync_iso);
854-
ret = ticker_stop(TICKER_INSTANCE_ID_CTLR, TICKER_USER_ID_ULL_HIGH,
855-
(TICKER_ID_SCAN_SYNC_ISO_BASE +
856-
sync_iso_handle_to_index(handle)),
857-
ticker_stop_op_cb, (void *)sync_iso);
858-
LL_ASSERT((ret == TICKER_STATUS_SUCCESS) ||
859-
(ret == TICKER_STATUS_BUSY));
844+
stop_ticker(sync_iso, ticker_stop_op_cb);
860845
}
861846

862847
static void disable(uint8_t sync_idx)
@@ -866,6 +851,11 @@ static void disable(uint8_t sync_idx)
866851

867852
sync_iso = &ll_sync_iso[sync_idx];
868853

854+
/* Stop any active resume ticker */
855+
(void)ticker_stop(TICKER_INSTANCE_ID_CTLR, TICKER_USER_ID_ULL_HIGH,
856+
TICKER_ID_SCAN_SYNC_ISO_RESUME_BASE + sync_idx,
857+
NULL, NULL);
858+
869859
err = ull_ticker_stop_with_mark(TICKER_ID_SCAN_SYNC_ISO_BASE +
870860
sync_idx, sync_iso, &sync_iso->lll);
871861
LL_ASSERT_INFO2(err == 0 || err == -EALREADY, sync_idx, err);
@@ -935,8 +925,6 @@ static uint16_t sync_iso_stream_handle_get(struct lll_sync_iso_stream *stream)
935925
static void timeout_cleanup(struct ll_sync_iso_set *sync_iso)
936926
{
937927
struct node_rx_pdu *rx;
938-
uint8_t handle;
939-
uint32_t ret;
940928

941929
/* Populate the Sync Lost which will be enqueued in disabled_cb */
942930
rx = (void *)&sync_iso->node_rx_lost;
@@ -952,13 +940,7 @@ static void timeout_cleanup(struct ll_sync_iso_set *sync_iso)
952940
}
953941

954942
/* Stop Sync ISO Ticker */
955-
handle = sync_iso_handle_get(sync_iso);
956-
ret = ticker_stop(TICKER_INSTANCE_ID_CTLR, TICKER_USER_ID_ULL_HIGH,
957-
(TICKER_ID_SCAN_SYNC_ISO_BASE +
958-
sync_iso_handle_to_index(handle)),
959-
ticker_stop_op_cb, (void *)sync_iso);
960-
LL_ASSERT((ret == TICKER_STATUS_SUCCESS) ||
961-
(ret == TICKER_STATUS_BUSY));
943+
stop_ticker(sync_iso, ticker_stop_op_cb);
962944
}
963945

964946
static void ticker_cb(uint32_t ticks_at_expire, uint32_t ticks_drift,
@@ -1107,3 +1089,24 @@ static void disabled_cb(void *param)
11071089
TICKER_USER_ID_LLL, 0U, &mfy);
11081090
LL_ASSERT(!ret);
11091091
}
1092+
1093+
static void stop_ticker(struct ll_sync_iso_set *sync_iso, ticker_op_func fp_op_func)
1094+
{
1095+
1096+
uint8_t handle;
1097+
uint32_t ret;
1098+
1099+
handle = sync_iso_handle_get(sync_iso);
1100+
1101+
(void)ticker_stop(TICKER_INSTANCE_ID_CTLR, TICKER_USER_ID_ULL_HIGH,
1102+
TICKER_ID_SCAN_SYNC_ISO_RESUME_BASE +
1103+
sync_iso_handle_to_index(handle), NULL, NULL);
1104+
1105+
ret = ticker_stop(TICKER_INSTANCE_ID_CTLR, TICKER_USER_ID_ULL_HIGH,
1106+
TICKER_ID_SCAN_SYNC_ISO_BASE +
1107+
sync_iso_handle_to_index(handle),
1108+
fp_op_func, fp_op_func ? (void *)sync_iso : NULL);
1109+
1110+
LL_ASSERT((ret == TICKER_STATUS_SUCCESS) ||
1111+
(ret == TICKER_STATUS_BUSY));
1112+
}

0 commit comments

Comments
 (0)