Skip to content

Commit a181042

Browse files
cvinayakcarlescufi
authored andcommitted
Bluetooth: Controller: Update support for Periodic Sync Receive enable
Update support for Periodic Advertising Synchronization Receive Enable command, so that PDUs are received so that contents of Extended Common Payload Format is parsed and process for information like Channel Map Update and BIGInfo. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent 64eaa52 commit a181042

File tree

6 files changed

+40
-30
lines changed

6 files changed

+40
-30
lines changed

subsys/bluetooth/controller/hci/hci.c

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6164,10 +6164,10 @@ static void le_per_adv_sync_report(struct pdu_data *pdu_data,
61646164
uint8_t data_len_max;
61656165
uint8_t *acad = NULL;
61666166
uint8_t hdr_buf_len;
6167-
bool dup = false;
61686167
uint8_t hdr_len;
61696168
uint8_t *ptr;
61706169
int8_t rssi;
6170+
bool drop;
61716171

61726172
if (!(event_mask & BT_EVT_MASK_LE_META_EVENT) ||
61736173
(!(le_event_mask & BT_EVT_MASK_LE_PER_ADVERTISING_REPORT) &&
@@ -6292,31 +6292,37 @@ static void le_per_adv_sync_report(struct pdu_data *pdu_data,
62926292
BT_DBG(" AD Data (%u): <todo>", data_len);
62936293
}
62946294

6295+
if (0) {
6296+
62956297
#if (CONFIG_BT_CTLR_DUP_FILTER_LEN > 0) && \
62966298
defined(CONFIG_BT_CTLR_SYNC_PERIODIC_ADI_SUPPORT)
6297-
if (IS_ENABLED(CONFIG_BT_CTLR_SYNC_PERIODIC_ADI_SUPPORT) && adi) {
6299+
} else if (IS_ENABLED(CONFIG_BT_CTLR_SYNC_PERIODIC_ADI_SUPPORT) &&
6300+
adi) {
62986301
const struct ll_sync_set *sync = HDR_LLL2ULL(ftr->param);
62996302

63006303
/* FIXME: Use correct data status else chain PDU report will
63016304
* be filtered out.
63026305
*/
6303-
dup = sync->nodups && dup_found(PDU_ADV_TYPE_EXT_IND,
6304-
sync->peer_id_addr_type,
6305-
sync->peer_id_addr,
6306-
DUP_EXT_ADV_MODE_PERIODIC,
6307-
adi, 0U);
6308-
}
6306+
drop = !ftr->sync_rx_enabled ||
6307+
(sync->nodups && dup_found(PDU_ADV_TYPE_EXT_IND,
6308+
sync->peer_id_addr_type,
6309+
sync->peer_id_addr,
6310+
DUP_EXT_ADV_MODE_PERIODIC,
6311+
adi, 0U));
63096312
#endif /* CONFIG_BT_CTLR_DUP_FILTER_LEN > 0 &&
63106313
* CONFIG_BT_CTLR_SYNC_PERIODIC_ADI_SUPPORT
63116314
*/
6315+
} else {
6316+
drop = !ftr->sync_rx_enabled;
6317+
}
63126318

63136319
data_len_max = ADV_REPORT_EVT_MAX_LEN -
63146320
sizeof(struct bt_hci_evt_le_meta_event) -
63156321
sizeof(struct bt_hci_evt_le_per_advertising_report);
63166322

63176323
evt_buf = buf;
63186324

6319-
if (!dup && (le_event_mask & BT_EVT_MASK_LE_PER_ADVERTISING_REPORT)) {
6325+
if ((le_event_mask & BT_EVT_MASK_LE_PER_ADVERTISING_REPORT) && !drop) {
63206326
do {
63216327
struct bt_hci_evt_le_per_advertising_report *sep;
63226328
uint8_t data_len_frag;

subsys/bluetooth/controller/ll_sw/lll.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,8 @@ struct node_rx_ftr {
334334
uint8_t aux_w4next:1;
335335
uint8_t aux_failed:1;
336336
#if defined(CONFIG_BT_CTLR_SYNC_PERIODIC)
337-
uint8_t sync_status:2;
337+
uint8_t sync_status:2;
338+
uint8_t sync_rx_enabled:1;
338339
#endif /* CONFIG_BT_CTLR_SYNC_PERIODIC */
339340

340341
uint8_t phy_flags:1;

subsys/bluetooth/controller/ll_sw/lll_sync.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ struct lll_sync {
1818
uint8_t crc_init[3];
1919

2020
uint8_t phy:3;
21-
uint8_t is_rx_enabled:1;
2221
/* Bitmask providing not allowed types of CTE. */
2322
uint8_t cte_type:5;
2423
/* The member is required for filtering by CTE type. If filtering policy is disabled then
2524
* synchronization is terminated for periodic advertisements with wrong CTE type.
2625
*/
2726
uint8_t filter_policy:1;
27+
uint8_t is_rx_enabled:1;
2828
uint8_t is_aux_sched:1;
2929

3030
#if defined(CONFIG_BT_CTLR_SYNC_ISO)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -627,8 +627,7 @@ static int isr_rx(struct lll_sync *lll, uint8_t node_type, uint8_t crc_ok, uint8
627627
struct node_rx_pdu *node_rx;
628628

629629
node_rx = ull_pdu_rx_alloc_peek(3);
630-
if (node_rx &&
631-
(lll->is_rx_enabled || (node_type == NODE_RX_TYPE_SYNC))) {
630+
if (node_rx) {
632631
struct node_rx_ftr *ftr;
633632
struct pdu_adv *pdu;
634633

@@ -646,6 +645,7 @@ static int isr_rx(struct lll_sync *lll, uint8_t node_type, uint8_t crc_ok, uint8
646645
radio_rx_chain_delay_get(lll->phy,
647646
1);
648647
ftr->sync_status = status;
648+
ftr->sync_rx_enabled = lll->is_rx_enabled;
649649

650650
pdu = (void *)node_rx->pdu;
651651

subsys/bluetooth/controller/ll_sw/ull_sync.c

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,10 @@ uint8_t ll_sync_create(uint8_t options, uint8_t sid, uint8_t adv_addr_type,
179179
sync->node_rx_sync_estab = node_rx;
180180
sync->node_rx_lost.hdr.link = link_sync_lost;
181181

182+
/* Reporting initially enabled/disabled */
183+
sync->rx_enable =
184+
!(options & BT_HCI_LE_PER_ADV_CREATE_SYNC_FP_REPORTS_DISABLED);
185+
182186
#if defined(CONFIG_BT_CTLR_SYNC_PERIODIC_ADI_SUPPORT)
183187
sync->nodups = (options &
184188
BT_HCI_LE_PER_ADV_CREATE_SYNC_FP_FILTER_DUPLICATE) ?
@@ -218,6 +222,7 @@ uint8_t ll_sync_create(uint8_t options, uint8_t sid, uint8_t adv_addr_type,
218222

219223
/* Initialize sync LLL context */
220224
lll_sync = &sync->lll;
225+
lll_sync->is_rx_enabled = sync->rx_enable;
221226
lll_sync->skip_prepare = 0U;
222227
lll_sync->skip_event = 0U;
223228
lll_sync->window_widening_prepare_us = 0U;
@@ -227,10 +232,6 @@ uint8_t ll_sync_create(uint8_t options, uint8_t sid, uint8_t adv_addr_type,
227232
lll_sync->filter_policy = scan->per_scan.filter_policy;
228233
#endif /* CONFIG_BT_CTLR_SYNC_PERIODIC_CTE_TYPE_FILTERING */
229234

230-
/* Reporting initially enabled/disabled */
231-
lll_sync->is_rx_enabled =
232-
!(options & BT_HCI_LE_PER_ADV_CREATE_SYNC_FP_REPORTS_DISABLED);
233-
234235
#if defined(CONFIG_BT_CTLR_DF_SCAN_CTE_RX)
235236
ull_df_sync_cfg_init(&lll_sync->df_cfg);
236237
#endif /* CONFIG_BT_CTLR_DF_SCAN_CTE_RX */
@@ -362,18 +363,15 @@ uint8_t ll_sync_terminate(uint16_t handle)
362363
uint8_t ll_sync_recv_enable(uint16_t handle, uint8_t enable)
363364
{
364365
struct ll_sync_set *sync;
365-
struct lll_sync *lll;
366366

367367
sync = ull_sync_is_enabled_get(handle);
368368
if (!sync) {
369369
return BT_HCI_ERR_UNKNOWN_ADV_IDENTIFIER;
370370
}
371371

372372
/* Reporting enabled/disabled */
373-
lll = &sync->lll;
374-
lll->is_rx_enabled = (enable &
375-
BT_HCI_LE_SET_PER_ADV_RECV_ENABLE_ENABLE) ?
376-
1U : 0U;
373+
sync->rx_enable = (enable & BT_HCI_LE_SET_PER_ADV_RECV_ENABLE_ENABLE) ?
374+
1U : 0U;
377375

378376
#if defined(CONFIG_BT_CTLR_SYNC_PERIODIC_ADI_SUPPORT)
379377
sync->nodups = (enable &
@@ -735,7 +733,6 @@ void ull_sync_established_report(memq_link_t *link, struct node_rx_hdr *rx)
735733
struct lll_sync *lll;
736734

737735
ftr = &rx->rx_ftr;
738-
lll = ftr->param;
739736

740737
#if defined(CONFIG_BT_CTLR_SYNC_PERIODIC_CTE_TYPE_FILTERING)
741738
enum sync_status sync_status;
@@ -745,6 +742,8 @@ void ull_sync_established_report(memq_link_t *link, struct node_rx_hdr *rx)
745742
#else
746743
struct pdu_cte_info *rx_cte_info;
747744

745+
lll = ftr->param;
746+
748747
rx_cte_info = pdu_cte_info_get((struct pdu_adv *)((struct node_rx_pdu *)rx)->pdu);
749748
if (rx_cte_info != NULL) {
750749
sync_status = lll_sync_cte_is_allowed(lll->cte_type, lll->filter_policy,
@@ -767,6 +766,7 @@ void ull_sync_established_report(memq_link_t *link, struct node_rx_hdr *rx)
767766
/* Set the sync handle corresponding to the LLL context passed in the node rx
768767
* footer field.
769768
*/
769+
lll = ftr->param;
770770
ull_sync = HDR_LLL2ULL(lll);
771771

772772
/* Prepare and dispatch sync notification */
@@ -808,13 +808,11 @@ void ull_sync_established_report(memq_link_t *link, struct node_rx_hdr *rx)
808808
/* Switch sync event prepare function to one reposnsible for regular PDUs receive */
809809
mfy_lll_prepare.fp = lll_sync_prepare;
810810

811-
if (lll->is_rx_enabled) {
812-
/* Change node type to appropriately handle periodic
813-
* advertising PDU report.
814-
*/
815-
rx->type = NODE_RX_TYPE_SYNC_REPORT;
816-
ull_scan_aux_setup(link, rx);
817-
}
811+
/* Change node type to appropriately handle periodic
812+
* advertising PDU report.
813+
*/
814+
rx->type = NODE_RX_TYPE_SYNC_REPORT;
815+
ull_scan_aux_setup(link, rx);
818816
}
819817
}
820818

@@ -1102,6 +1100,9 @@ static void ticker_cb(uint32_t ticks_at_expire, uint32_t ticks_drift,
11021100

11031101
lll = &sync->lll;
11041102

1103+
/* Commit receive enable changed value */
1104+
lll->is_rx_enabled = sync->rx_enable;
1105+
11051106
/* Increment prepare reference count */
11061107
ref = ull_ref_inc(&sync->ull);
11071108
LL_ASSERT(ref);

subsys/bluetooth/controller/ll_sw/ull_sync_types.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ struct ll_sync_set {
2929
* CONFIG_BT_CTLR_SYNC_PERIODIC_ADI_SUPPORT
3030
*/
3131

32+
uint8_t rx_enable:1;
33+
3234
#if defined(CONFIG_BT_CTLR_SYNC_PERIODIC_ADI_SUPPORT)
3335
uint8_t nodups:1;
3436
#endif

0 commit comments

Comments
 (0)