Skip to content

Commit 8743311

Browse files
Bluetooth: Controller: Dispatch rx nodes for sync immediately
Periodic advertising reports can be reated directly from single PDU as they do not require any information from superior PDU, so we can dispatch them immediately instead of buffering in aux context and flushing at the end of chain. This also resolves proper order of Periodic advertising and IQ reports. Signed-off-by: Andrzej Kaczmarek <[email protected]>
1 parent 7be9bce commit 8743311

File tree

1 file changed

+35
-17
lines changed

1 file changed

+35
-17
lines changed

subsys/bluetooth/controller/ll_sw/ull_scan_aux.c

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -361,22 +361,29 @@ void ull_scan_aux_setup(memq_link_t *link, struct node_rx_hdr *rx)
361361
goto ull_scan_aux_rx_flush;
362362
}
363363

364-
aux->rx_last = NULL;
364+
aux->rx_head = aux->rx_last = NULL;
365365
lll_aux = &aux->lll;
366366

367367
ull_hdr_init(&aux->ull);
368368
lll_hdr_init(lll_aux, aux);
369369

370-
aux->parent = lll ? (void *)lll : (void *)lll_sync;
370+
aux->parent = lll ? (void *)lll : (void *)sync_lll;
371371
}
372372

373-
/* Enqueue the rx in aux context */
374-
if (aux->rx_last) {
375-
aux->rx_last->rx_ftr.extra = rx;
373+
/* In sync context we can dispatch rx immediately, in scan context we
374+
* enqueue rx in aux context and will flush them after scan is complete.
375+
*/
376+
if (sync_lll) {
377+
ll_rx_put(link, rx);
378+
ll_rx_sched();
376379
} else {
377-
aux->rx_head = rx;
380+
if (aux->rx_last) {
381+
aux->rx_last->rx_ftr.extra = rx;
382+
} else {
383+
aux->rx_head = rx;
384+
}
385+
aux->rx_last = rx;
378386
}
379-
aux->rx_last = rx;
380387

381388
lll_aux->chan = aux_ptr->chan_idx;
382389
lll_aux->phy = BIT(aux_ptr->phy);
@@ -511,7 +518,16 @@ void ull_scan_aux_setup(memq_link_t *link, struct node_rx_hdr *rx)
511518

512519
hdr = &aux->ull;
513520

514-
aux->rx_last->rx_ftr.extra = rx;
521+
/* Enqueue last rx in aux context if possible, otherwise send
522+
* immediately since we are in sync context.
523+
*/
524+
if (aux->rx_last) {
525+
aux->rx_last->rx_ftr.extra = rx;
526+
} else {
527+
LL_ASSERT(sync_lll);
528+
ll_rx_put(link, rx);
529+
ll_rx_sched();
530+
}
515531

516532
/* ref == 0
517533
* All PDUs were scheduled from LLL and there is no pending done
@@ -686,22 +702,24 @@ static void done_disabled_cb(void *param)
686702
static void flush(struct ll_scan_aux_set *aux)
687703
{
688704
struct node_rx_hdr *rx;
689-
struct lll_scan *lll;
690705

706+
/* Nodes are enqueued only in scan context so need to send them now */
691707
rx = aux->rx_head;
692-
lll = rx->rx_ftr.param;
693-
if (ull_scan_is_valid_get(HDR_LLL2ULL(lll))) {
708+
if (rx) {
709+
struct lll_scan *lll;
710+
711+
lll = aux->parent;
694712
lll->lll_aux = NULL;
713+
714+
ll_rx_put(rx->link, rx);
715+
ll_rx_sched();
695716
} else {
696-
struct lll_sync *lll_sync;
717+
struct lll_sync *lll;
697718

698-
lll_sync = rx->rx_ftr.param;
699-
lll_sync->lll_aux = NULL;
719+
lll = aux->parent;
720+
lll->lll_aux = NULL;
700721
}
701722

702-
ll_rx_put(rx->link, rx);
703-
ll_rx_sched();
704-
705723
aux_release(aux);
706724
}
707725

0 commit comments

Comments
 (0)