Skip to content

Commit da792a9

Browse files
cvinayakkartben
authored andcommitted
Bluetooth: Controller: Fix interleaved extended scanning assert
Fix interleaved extended scanning assert. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent 00e8cdc commit da792a9

File tree

3 files changed

+33
-8
lines changed

3 files changed

+33
-8
lines changed

subsys/bluetooth/controller/ll_sw/lll.h

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,18 @@ struct node_rx_ftr {
351351
* chaining, to reserve node_rx for CSA#2 event
352352
* generation etc.
353353
*/
354-
void *aux_ptr;
355-
uint8_t aux_phy;
354+
void *lll_aux; /* LLL scheduled auxiliary context associated to
355+
* the scan context when enqueuing the node rx.
356+
* This does not overlap the below aux_ptr or
357+
* aux_phy which are used before enqueue when
358+
* setting up LLL scheduling.
359+
*/
360+
void *aux_ptr; /* aux pointer stored when LLL scheduling the
361+
* auxiliary PDU reception by scan context.
362+
*/
363+
uint8_t aux_phy; /* aux phy stored when LLL scheduling the
364+
* auxiliary PDU reception by scan context.
365+
*/
356366
struct cte_conn_iq_report *iq_report;
357367
};
358368
uint32_t ticks_anchor;
@@ -531,9 +541,9 @@ struct event_done_extra {
531541
*/
532542
};
533543

534-
#if defined(CONFIG_BT_CTLR_ADV_EXT)
544+
#if defined(CONFIG_BT_CTLR_SCAN_AUX_USE_CHAINS)
535545
void *lll;
536-
#endif /* CONFIG_BT_CTLR_ADV_EXT */
546+
#endif /* CONFIG_BT_CTLR_SCAN_AUX_USE_CHAINS */
537547
};
538548

539549
#if defined(CONFIG_BT_CTLR_LE_ENC)

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,10 @@ static void abort_cb(struct lll_prepare_param *prepare_param, void *param)
676676

677677
e = ull_done_extra_type_set(EVENT_DONE_EXTRA_TYPE_SCAN_AUX);
678678
LL_ASSERT(e);
679+
680+
#if defined(CONFIG_BT_CTLR_SCAN_AUX_USE_CHAINS)
679681
e->lll = param;
682+
#endif /* CONFIG_BT_CTLR_SCAN_AUX_USE_CHAINS */
680683

681684
lll_done(param);
682685
}
@@ -716,7 +719,10 @@ static void isr_done(void *param)
716719

717720
e = ull_done_extra_type_set(EVENT_DONE_EXTRA_TYPE_SCAN_AUX);
718721
LL_ASSERT(e);
722+
723+
#if defined(CONFIG_BT_CTLR_SCAN_AUX_USE_CHAINS)
719724
e->lll = param;
725+
#endif /* CONFIG_BT_CTLR_SCAN_AUX_USE_CHAINS */
720726
}
721727

722728
lll_isr_cleanup(param);
@@ -1209,6 +1215,7 @@ static int isr_rx_pdu(struct lll_scan *lll, struct lll_scan_aux *lll_aux,
12091215
lll_aux->state = 1U;
12101216
} else {
12111217
ftr->param = lll;
1218+
ftr->lll_aux = lll->lll_aux;
12121219
radio_isr_set(isr_tx_scan_req_lll_schedule,
12131220
node_rx);
12141221
lll->lll_aux->state = 1U;
@@ -1278,6 +1285,7 @@ static int isr_rx_pdu(struct lll_scan *lll, struct lll_scan_aux *lll_aux,
12781285
* LLL scheduling in the reception of this current PDU.
12791286
*/
12801287
ftr->param = lll;
1288+
ftr->lll_aux = lll->lll_aux;
12811289
ftr->scan_rsp = lll->lll_aux->state;
12821290

12831291
/* Further auxiliary PDU reception will be chain PDUs */
@@ -1661,7 +1669,10 @@ static void isr_early_abort(void *param)
16611669

16621670
e = ull_done_extra_type_set(EVENT_DONE_EXTRA_TYPE_SCAN_AUX);
16631671
LL_ASSERT(e);
1672+
1673+
#if defined(CONFIG_BT_CTLR_SCAN_AUX_USE_CHAINS)
16641674
e->lll = param;
1675+
#endif /* CONFIG_BT_CTLR_SCAN_AUX_USE_CHAINS */
16651676

16661677
lll_isr_early_abort(param);
16671678
}

subsys/bluetooth/controller/ll_sw/ull_scan_aux.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,13 +268,17 @@ void ull_scan_aux_setup(memq_link_t *link, struct node_rx_pdu *rx)
268268
sync_lll = NULL;
269269

270270
/* Node that does not have valid aux context but has
271-
* valid scan set was scheduled from LLL. We can
272-
* retrieve aux context from lll_scan as it was stored
273-
* there when superior PDU was handled.
271+
* valid scan set was scheduled from LLL.
274272
*/
275273
lll = ftr->param;
276274

277-
lll_aux = lll->lll_aux;
275+
/* We can not retrieve aux context that was stored in
276+
* lll_scan when superior PDU was handled, as it may be
277+
* reset to NULL before this node rx is processed here.
278+
* The reset happens when new extended advertising chain
279+
* is being received before we process the node here.
280+
*/
281+
lll_aux = ftr->lll_aux;
278282
LL_ASSERT(lll_aux);
279283

280284
aux = HDR_LLL2ULL(lll_aux);

0 commit comments

Comments
 (0)