Skip to content

Commit e486a06

Browse files
Tronilkartben
authored andcommitted
Bluetooth: Controller: Remove unneeded members from ull_hdr
Several members of the ull_hdr can be removed, saving 12 bytes from all ULL instances used (and a bit of code as well) ticks_active_to_start is always 0 and can be removed completely ticks_prepare_to_start is always set to HAL_TICKER_US_TO_TICKS(EVENT_OVERHEAD_XTAL_US), so replace usage of it by this constant ticks_preempt_to_start is always set to HAL_TICKER_US_TO_TICKS(EVENT_OVERHEAD_PREEMPT_MIN_US), so replace usage of it by this constant In addition, remove logic handling usage of XON_BITMASK since it was only used by the long removed legacy LL Signed-off-by: Troels Nilsson <[email protected]>
1 parent a87e8dc commit e486a06

File tree

17 files changed

+30
-205
lines changed

17 files changed

+30
-205
lines changed

subsys/bluetooth/controller/ll_sw/lll.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@
3232
/* Intervals after which connection or sync establishment is considered lost */
3333
#define CONN_ESTAB_COUNTDOWN 6U
3434

35-
#if defined(CONFIG_BT_CTLR_XTAL_ADVANCED)
36-
#define XON_BITMASK BIT(31) /* XTAL has been retained from previous prepare */
37-
#endif /* CONFIG_BT_CTLR_XTAL_ADVANCED */
38-
3935
#if defined(CONFIG_BT_BROADCASTER)
4036
#if defined(CONFIG_BT_CTLR_ADV_SET)
4137
#define BT_CTLR_ADV_SET CONFIG_BT_CTLR_ADV_SET
@@ -213,19 +209,7 @@ struct ull_hdr {
213209
*/
214210

215211
/* Event parameters */
216-
/* TODO: The intention is to use the greater of the
217-
* ticks_prepare_to_start or ticks_active_to_start as the prepare
218-
* offset. At the prepare tick generate a software interrupt
219-
* serviceable by application as the per role configurable advance
220-
* radio event notification, usable for data acquisitions.
221-
* ticks_preempt_to_start is the per role dynamic preempt offset,
222-
* which shall be based on role's preparation CPU usage
223-
* requirements.
224-
*/
225212
struct {
226-
uint32_t ticks_active_to_start;
227-
uint32_t ticks_prepare_to_start;
228-
uint32_t ticks_preempt_to_start;
229213
uint32_t ticks_slot;
230214
};
231215

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

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -612,16 +612,7 @@ void lll_abort_cb(struct lll_prepare_param *prepare_param, void *param)
612612

613613
uint32_t lll_event_offset_get(struct ull_hdr *ull)
614614
{
615-
if (0) {
616-
#if defined(CONFIG_BT_CTLR_XTAL_ADVANCED)
617-
} else if (ull->ticks_prepare_to_start & XON_BITMASK) {
618-
return MAX(ull->ticks_active_to_start,
619-
ull->ticks_preempt_to_start);
620-
#endif /* CONFIG_BT_CTLR_XTAL_ADVANCED */
621-
} else {
622-
return MAX(ull->ticks_active_to_start,
623-
ull->ticks_prepare_to_start);
624-
}
615+
return HAL_TICKER_US_TO_TICKS(EVENT_OVERHEAD_XTAL_US);
625616
}
626617

627618
uint32_t lll_preempt_calc(struct ull_hdr *ull, uint8_t ticker_id,
@@ -1108,9 +1099,8 @@ static uint32_t preempt_ticker_start(struct lll_event *first,
11081099
p = &next->prepare_param;
11091100
ull = HDR_LLL2ULL(p->param);
11101101
preempt_anchor = p->ticks_at_expire;
1111-
preempt_to = MAX(ull->ticks_active_to_start,
1112-
ull->ticks_prepare_to_start) -
1113-
ull->ticks_preempt_to_start;
1102+
preempt_to = HAL_TICKER_US_TO_TICKS(EVENT_OVERHEAD_XTAL_US) -
1103+
HAL_TICKER_US_TO_TICKS(EVENT_OVERHEAD_PREEMPT_MIN_US);
11141104

11151105
ticks_at_preempt_new = preempt_anchor + preempt_to;
11161106
ticks_at_preempt_new &= HAL_TICKER_CNTR_MASK;
@@ -1134,9 +1124,8 @@ static uint32_t preempt_ticker_start(struct lll_event *first,
11341124
p = &first->prepare_param;
11351125
ull = HDR_LLL2ULL(p->param);
11361126
preempt_anchor = p->ticks_at_expire;
1137-
preempt_to = MAX(ull->ticks_active_to_start,
1138-
ull->ticks_prepare_to_start) -
1139-
ull->ticks_preempt_to_start;
1127+
preempt_to = HAL_TICKER_US_TO_TICKS(EVENT_OVERHEAD_XTAL_US) -
1128+
HAL_TICKER_US_TO_TICKS(EVENT_OVERHEAD_PREEMPT_MIN_US);
11401129

11411130
ticks_at_preempt_new = preempt_anchor + preempt_to;
11421131
ticks_at_preempt_new &= HAL_TICKER_CNTR_MASK;

subsys/bluetooth/controller/ll_sw/openisa/lll/lll.c

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -385,16 +385,7 @@ int lll_clk_off(void)
385385

386386
uint32_t lll_event_offset_get(struct ull_hdr *ull)
387387
{
388-
if (0) {
389-
#if defined(CONFIG_BT_CTLR_XTAL_ADVANCED)
390-
} else if (ull->ticks_prepare_to_start & XON_BITMASK) {
391-
return MAX(ull->ticks_active_to_start,
392-
ull->ticks_preempt_to_start);
393-
#endif /* CONFIG_BT_CTLR_XTAL_ADVANCED */
394-
} else {
395-
return MAX(ull->ticks_active_to_start,
396-
ull->ticks_prepare_to_start);
397-
}
388+
return HAL_TICKER_US_TO_TICKS(EVENT_OVERHEAD_XTAL_US);
398389
}
399390

400391
uint32_t lll_preempt_calc(struct ull_hdr *ull, uint8_t ticker_id,
@@ -674,9 +665,8 @@ static uint32_t preempt_ticker_start(struct lll_event *evt,
674665
p = &evt->prepare_param;
675666
ull = HDR_LLL2ULL(p->param);
676667
preempt_anchor = p->ticks_at_expire;
677-
preempt_to = MAX(ull->ticks_active_to_start,
678-
ull->ticks_prepare_to_start) -
679-
ull->ticks_preempt_to_start;
668+
preempt_to = HAL_TICKER_US_TO_TICKS(EVENT_OVERHEAD_XTAL_US) -
669+
HAL_TICKER_US_TO_TICKS(EVENT_OVERHEAD_PREEMPT_MIN_US);
680670

681671
/* Setup pre empt timeout */
682672
ret = ticker_start(TICKER_INSTANCE_ID_CTLR,

subsys/bluetooth/controller/ll_sw/ull_adv.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,16 +1275,9 @@ uint8_t ll_adv_enable(uint8_t enable)
12751275
/* Initialize ULL context before radio event scheduling is started. */
12761276
ull_hdr_init(&adv->ull);
12771277

1278-
/* TODO: active_to_start feature port */
1279-
adv->ull.ticks_active_to_start = 0;
1280-
adv->ull.ticks_prepare_to_start =
1281-
HAL_TICKER_US_TO_TICKS(EVENT_OVERHEAD_XTAL_US);
1282-
adv->ull.ticks_preempt_to_start =
1283-
HAL_TICKER_US_TO_TICKS(EVENT_OVERHEAD_PREEMPT_MIN_US);
12841278
adv->ull.ticks_slot = HAL_TICKER_US_TO_TICKS_CEIL(time_us);
12851279

1286-
ticks_slot_offset = MAX(adv->ull.ticks_active_to_start,
1287-
adv->ull.ticks_prepare_to_start);
1280+
ticks_slot_offset = HAL_TICKER_US_TO_TICKS(EVENT_OVERHEAD_XTAL_US);
12881281

12891282
if (IS_ENABLED(CONFIG_BT_CTLR_LOW_LAT)) {
12901283
ticks_slot_overhead = ticks_slot_offset;

subsys/bluetooth/controller/ll_sw/ull_adv_aux.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2521,17 +2521,10 @@ uint32_t ull_adv_aux_evt_init(struct ll_adv_aux_set *aux,
25212521

25222522
time_us = aux_time_min_get(aux);
25232523

2524-
/* TODO: active_to_start feature port */
2525-
aux->ull.ticks_active_to_start = 0;
2526-
aux->ull.ticks_prepare_to_start =
2527-
HAL_TICKER_US_TO_TICKS(EVENT_OVERHEAD_XTAL_US);
2528-
aux->ull.ticks_preempt_to_start =
2529-
HAL_TICKER_US_TO_TICKS(EVENT_OVERHEAD_PREEMPT_MIN_US);
25302524
aux->ull.ticks_slot = HAL_TICKER_US_TO_TICKS_CEIL(time_us);
25312525

25322526
if (IS_ENABLED(CONFIG_BT_CTLR_LOW_LAT)) {
2533-
ticks_slot_overhead = MAX(aux->ull.ticks_active_to_start,
2534-
aux->ull.ticks_prepare_to_start);
2527+
ticks_slot_overhead = HAL_TICKER_US_TO_TICKS(EVENT_OVERHEAD_XTAL_US);
25352528
} else {
25362529
ticks_slot_overhead = 0;
25372530
}
@@ -3328,9 +3321,8 @@ static void mfy_aux_offset_get(void *param)
33283321
/* Assertion check for delayed aux_offset calculations */
33293322
ticks_now = ticker_ticks_now_get();
33303323
ticks_elapsed = ticker_ticks_diff_get(ticks_now, ticks_current);
3331-
ticks_to_start = MAX(adv->ull.ticks_active_to_start,
3332-
adv->ull.ticks_prepare_to_start) -
3333-
adv->ull.ticks_preempt_to_start;
3324+
ticks_to_start = HAL_TICKER_US_TO_TICKS(EVENT_OVERHEAD_XTAL_US) -
3325+
HAL_TICKER_US_TO_TICKS(EVENT_OVERHEAD_PREEMPT_MIN_US);
33343326
LL_ASSERT(ticks_elapsed < ticks_to_start);
33353327
}
33363328

subsys/bluetooth/controller/ll_sw/ull_adv_iso.c

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,7 @@ static uint8_t big_create(uint8_t big_handle, uint8_t adv_handle, uint8_t num_bi
260260
if (aux && aux->is_started) {
261261
ticks_slot_aux = aux->ull.ticks_slot;
262262
if (IS_ENABLED(CONFIG_BT_CTLR_LOW_LAT)) {
263-
ticks_slot_overhead =
264-
MAX(aux->ull.ticks_active_to_start,
265-
aux->ull.ticks_prepare_to_start);
263+
ticks_slot_overhead = HAL_TICKER_US_TO_TICKS(EVENT_OVERHEAD_XTAL_US);
266264
} else {
267265
ticks_slot_overhead = 0U;
268266
}
@@ -275,9 +273,7 @@ static uint8_t big_create(uint8_t big_handle, uint8_t adv_handle, uint8_t num_bi
275273
ticks_slot_aux = HAL_TICKER_US_TO_TICKS_CEIL(time_us);
276274
if (IS_ENABLED(CONFIG_BT_CTLR_LOW_LAT)) {
277275
/* Assume primary overheads may be inherited by aux */
278-
ticks_slot_overhead =
279-
MAX(adv->ull.ticks_active_to_start,
280-
adv->ull.ticks_prepare_to_start);
276+
ticks_slot_overhead = HAL_TICKER_US_TO_TICKS(EVENT_OVERHEAD_XTAL_US);
281277
} else {
282278
ticks_slot_overhead = 0U;
283279
}
@@ -299,8 +295,7 @@ static uint8_t big_create(uint8_t big_handle, uint8_t adv_handle, uint8_t num_bi
299295
}
300296

301297
if (IS_ENABLED(CONFIG_BT_CTLR_LOW_LAT)) {
302-
ticks_slot_overhead = MAX(sync->ull.ticks_active_to_start,
303-
sync->ull.ticks_prepare_to_start);
298+
ticks_slot_overhead = HAL_TICKER_US_TO_TICKS(EVENT_OVERHEAD_XTAL_US);
304299
} else {
305300
ticks_slot_overhead = 0U;
306301
}
@@ -1304,15 +1299,9 @@ static uint32_t adv_iso_start(struct ll_adv_iso_set *adv_iso,
13041299

13051300
slot_us = adv_iso_time_get(adv_iso, false);
13061301

1307-
adv_iso->ull.ticks_active_to_start = 0U;
1308-
adv_iso->ull.ticks_prepare_to_start =
1309-
HAL_TICKER_US_TO_TICKS(EVENT_OVERHEAD_XTAL_US);
1310-
adv_iso->ull.ticks_preempt_to_start =
1311-
HAL_TICKER_US_TO_TICKS(EVENT_OVERHEAD_PREEMPT_MIN_US);
13121302
adv_iso->ull.ticks_slot = HAL_TICKER_US_TO_TICKS_CEIL(slot_us);
13131303

1314-
ticks_slot_offset = MAX(adv_iso->ull.ticks_active_to_start,
1315-
adv_iso->ull.ticks_prepare_to_start);
1304+
ticks_slot_offset = HAL_TICKER_US_TO_TICKS(EVENT_OVERHEAD_XTAL_US);
13161305
if (IS_ENABLED(CONFIG_BT_CTLR_LOW_LAT)) {
13171306
ticks_slot_overhead = ticks_slot_offset;
13181307
} else {

subsys/bluetooth/controller/ll_sw/ull_adv_sync.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -804,16 +804,9 @@ uint32_t ull_adv_sync_evt_init(struct ll_adv_set *adv,
804804

805805
time_us = sync_time_get(sync, pdu);
806806

807-
/* TODO: active_to_start feature port */
808-
sync->ull.ticks_active_to_start = 0U;
809-
sync->ull.ticks_prepare_to_start =
810-
HAL_TICKER_US_TO_TICKS(EVENT_OVERHEAD_XTAL_US);
811-
sync->ull.ticks_preempt_to_start =
812-
HAL_TICKER_US_TO_TICKS(EVENT_OVERHEAD_PREEMPT_MIN_US);
813807
sync->ull.ticks_slot = HAL_TICKER_US_TO_TICKS_CEIL(time_us);
814808

815-
ticks_slot_offset = MAX(sync->ull.ticks_active_to_start,
816-
sync->ull.ticks_prepare_to_start);
809+
ticks_slot_offset = HAL_TICKER_US_TO_TICKS(EVENT_OVERHEAD_XTAL_US);
817810
if (IS_ENABLED(CONFIG_BT_CTLR_LOW_LAT)) {
818811
ticks_slot_overhead = ticks_slot_offset;
819812
} else {

subsys/bluetooth/controller/ll_sw/ull_central.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -316,13 +316,6 @@ uint8_t ll_create_connection(uint16_t scan_interval, uint16_t scan_window,
316316
conn_lll->tifs_hcto_us = EVENT_IFS_DEFAULT_US;
317317
conn_lll->tifs_cis_us = EVENT_IFS_DEFAULT_US;
318318

319-
/* TODO: active_to_start feature port */
320-
conn->ull.ticks_active_to_start = 0U;
321-
conn->ull.ticks_prepare_to_start =
322-
HAL_TICKER_US_TO_TICKS(EVENT_OVERHEAD_XTAL_US);
323-
conn->ull.ticks_preempt_to_start =
324-
HAL_TICKER_US_TO_TICKS(EVENT_OVERHEAD_PREEMPT_MIN_US);
325-
326319
#if defined(CONFIG_BT_CTLR_CHECK_SAME_PEER_CONN)
327320
/* Remember peer and own identity address */
328321
conn->peer_id_addr_type = peer_addr_type;
@@ -802,8 +795,7 @@ void ull_central_setup(struct node_rx_pdu *rx, struct node_rx_ftr *ftr,
802795

803796
ll_rx_put_sched(link, rx);
804797

805-
ticks_slot_offset = MAX(conn->ull.ticks_active_to_start,
806-
conn->ull.ticks_prepare_to_start);
798+
ticks_slot_offset = HAL_TICKER_US_TO_TICKS(EVENT_OVERHEAD_XTAL_US);
807799
if (IS_ENABLED(CONFIG_BT_CTLR_LOW_LAT)) {
808800
ticks_slot_overhead = ticks_slot_offset;
809801
} else {

subsys/bluetooth/controller/ll_sw/ull_central_iso.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -600,11 +600,6 @@ uint8_t ll_cig_parameters_commit(uint8_t cig_id, uint16_t *handles)
600600
slot_us += EVENT_OVERHEAD_START_US + EVENT_OVERHEAD_END_US;
601601

602602
/* Populate the ULL hdr with event timings overheads */
603-
cig->ull.ticks_active_to_start = 0U;
604-
cig->ull.ticks_prepare_to_start =
605-
HAL_TICKER_US_TO_TICKS(EVENT_OVERHEAD_XTAL_US);
606-
cig->ull.ticks_preempt_to_start =
607-
HAL_TICKER_US_TO_TICKS(EVENT_OVERHEAD_PREEMPT_MIN_US);
608603
cig->ull.ticks_slot = HAL_TICKER_US_TO_TICKS_CEIL(slot_us);
609604
#endif /* !CONFIG_BT_CTLR_JIT_SCHEDULING */
610605

subsys/bluetooth/controller/ll_sw/ull_conn.c

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2251,18 +2251,6 @@ void ull_conn_update_parameters(struct ll_conn *conn, uint8_t is_cu_proc, uint8_
22512251

22522252
ticks_at_expire = conn->llcp.prep.ticks_at_expire;
22532253

2254-
#if defined(CONFIG_BT_CTLR_XTAL_ADVANCED)
2255-
/* restore to normal prepare */
2256-
if (conn->ull.ticks_prepare_to_start & XON_BITMASK) {
2257-
uint32_t ticks_prepare_to_start =
2258-
MAX(conn->ull.ticks_active_to_start, conn->ull.ticks_preempt_to_start);
2259-
2260-
conn->ull.ticks_prepare_to_start &= ~XON_BITMASK;
2261-
2262-
ticks_at_expire -= (conn->ull.ticks_prepare_to_start - ticks_prepare_to_start);
2263-
}
2264-
#endif /* CONFIG_BT_CTLR_XTAL_ADVANCED */
2265-
22662254
#if defined(CONFIG_BT_CTLR_PHY)
22672255
ready_delay_us = lll_radio_tx_ready_delay_get(lll->phy_tx,
22682256
lll->phy_flags);
@@ -2353,10 +2341,7 @@ void ull_conn_update_parameters(struct ll_conn *conn, uint8_t is_cu_proc, uint8_
23532341

23542342
/* calculate the offset */
23552343
if (IS_ENABLED(CONFIG_BT_CTLR_LOW_LAT)) {
2356-
ticks_slot_overhead =
2357-
MAX(conn->ull.ticks_active_to_start,
2358-
conn->ull.ticks_prepare_to_start);
2359-
2344+
ticks_slot_overhead = HAL_TICKER_US_TO_TICKS(EVENT_OVERHEAD_XTAL_US);
23602345
} else {
23612346
ticks_slot_overhead = 0U;
23622347
}

0 commit comments

Comments
 (0)