Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 75 additions & 12 deletions subsys/bluetooth/controller/ll_sw/ull_scan_aux.c
Original file line number Diff line number Diff line change
Expand Up @@ -440,19 +440,30 @@

ptr = h->data;

#if defined(CONFIG_BT_CTLR_SYNC_PERIODIC)
bool is_aux_addr_match = false;
#endif /* CONFIG_BT_CTLR_SYNC_PERIODIC */

if (h->adv_addr) {
#if defined(CONFIG_BT_CTLR_SYNC_PERIODIC)
/* Check if Periodic Advertising Synchronization to be created
*/
if (sync && (scan->periodic.state != LL_SYNC_STATE_CREATED)) {
/* Check address and update internal state */
#if defined(CONFIG_BT_CTLR_PRIVACY)
ull_sync_setup_addr_check(sync, scan, pdu->tx_addr, ptr,
ftr->rl_idx);
uint8_t rl_idx = ftr->rl_idx;
#else /* !CONFIG_BT_CTLR_PRIVACY */
ull_sync_setup_addr_check(sync, scan, pdu->tx_addr, ptr, 0U);
uint8_t rl_idx = 0U;
#endif /* !CONFIG_BT_CTLR_PRIVACY */

/* Check address and update internal state */
is_aux_addr_match =
ull_sync_setup_addr_check(sync, scan->periodic.filter_policy,
pdu->tx_addr, ptr, rl_idx);
if (is_aux_addr_match) {

Check notice on line 462 in subsys/bluetooth/controller/ll_sw/ull_scan_aux.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

subsys/bluetooth/controller/ll_sw/ull_scan_aux.c:462 - is_aux_addr_match = - ull_sync_setup_addr_check(sync, scan->periodic.filter_policy, - pdu->tx_addr, ptr, rl_idx); + is_aux_addr_match = ull_sync_setup_addr_check( + sync, scan->periodic.filter_policy, pdu->tx_addr, ptr, rl_idx);
scan->periodic.state = LL_SYNC_STATE_ADDR_MATCH;
} else {
scan->periodic.state = LL_SYNC_STATE_IDLE;
}
}
#endif /* CONFIG_BT_CTLR_SYNC_PERIODIC */

Expand Down Expand Up @@ -485,14 +496,21 @@
si = (void *)ptr;
ptr += sizeof(*si);

#if defined(CONFIG_BT_CTLR_SYNC_PERIODIC)
/* Check if Periodic Advertising Synchronization to be created.
* Setup synchronization if address and SID match in the
* Periodic Advertiser List or with the explicitly supplied.
*
* is_aux_addr_match, device address in auxiliary channel PDU;
* scan->periodic.param has not been assigned yet.
* Otherwise, address was in primary channel PDU and we are now
* checking SID (in SyncInfo) in auxiliary channel PDU.
*/
if (IS_ENABLED(CONFIG_BT_CTLR_SYNC_PERIODIC) && aux && sync && adi &&
if (sync && aux && (is_aux_addr_match || (scan->periodic.param == aux)) && adi &&
ull_sync_setup_sid_match(sync, scan, PDU_ADV_ADI_SID_GET(adi))) {
ull_sync_setup(scan, aux->lll.phy, rx, si);
}
#endif /* CONFIG_BT_CTLR_SYNC_PERIODIC */
}

if (h->tx_pwr) {
Expand Down Expand Up @@ -688,6 +706,15 @@
#endif /* CONFIG_BT_CTLR_JIT_SCHEDULING */

#if defined(CONFIG_BT_CTLR_SYNC_PERIODIC)
/* Store the aux context that has Periodic Advertising
* Synchronization address match.
*/
if (sync && (scan->periodic.state == LL_SYNC_STATE_ADDR_MATCH)) {
scan->periodic.param = aux;
}

/* Store the node rx allocated for incomplete report, if needed.
*/
aux->rx_incomplete = rx_incomplete;
rx_incomplete = NULL;
#endif /* CONFIG_BT_CTLR_SYNC_PERIODIC */
Expand Down Expand Up @@ -912,6 +939,7 @@
#if defined(CONFIG_BT_CTLR_SYNC_PERIODIC)
if (sync && (scan->periodic.state != LL_SYNC_STATE_CREATED)) {
scan->periodic.state = LL_SYNC_STATE_IDLE;
scan->periodic.param = NULL;
}
#endif /* CONFIG_BT_CTLR_SYNC_PERIODIC */

Expand Down Expand Up @@ -1514,7 +1542,16 @@
}

#else /* CONFIG_BT_CTLR_SCAN_AUX_USE_CHAINS */

/* NOTE: BT_CTLR_SCAN_AUX_USE_CHAINS is alternative new design with less RAM
* usage for supporting Extended Scanning of simultaneous interleaved
* Extended Advertising chains.
*
* TODO: As the previous design has Bluetooth Qualified Design Listing by
* Nordic Semiconductor ASA, both implementation are present in this file,
* and default builds use CONFIG_BT_CTLR_SCAN_AUX_USE_CHAINS=n. Remove old
* implementation when we have a new Bluetooth Qualified Design Listing
* with the new Extended Scanning and Periodic Sync implementation.
*/
void ull_scan_aux_setup(memq_link_t *link, struct node_rx_pdu *rx)
{
struct node_rx_pdu *rx_incomplete;
Expand Down Expand Up @@ -1774,19 +1811,30 @@

ptr = h->data;

#if defined(CONFIG_BT_CTLR_SYNC_PERIODIC)
bool is_aux_addr_match = false;
#endif /* CONFIG_BT_CTLR_SYNC_PERIODIC */

if (h->adv_addr) {
#if defined(CONFIG_BT_CTLR_SYNC_PERIODIC)
/* Check if Periodic Advertising Synchronization to be created
*/
if (sync && (scan->periodic.state != LL_SYNC_STATE_CREATED)) {
/* Check address and update internal state */
#if defined(CONFIG_BT_CTLR_PRIVACY)
ull_sync_setup_addr_check(sync, scan, pdu->tx_addr, ptr,
ftr->rl_idx);
uint8_t rl_idx = ftr->rl_idx;
#else /* !CONFIG_BT_CTLR_PRIVACY */
ull_sync_setup_addr_check(sync, scan, pdu->tx_addr, ptr, 0U);
uint8_t rl_idx = 0U;
#endif /* !CONFIG_BT_CTLR_PRIVACY */

/* Check address and update internal state */
is_aux_addr_match =
ull_sync_setup_addr_check(sync, scan->periodic.filter_policy,
pdu->tx_addr, ptr, rl_idx);
if (is_aux_addr_match) {

Check notice on line 1833 in subsys/bluetooth/controller/ll_sw/ull_scan_aux.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

subsys/bluetooth/controller/ll_sw/ull_scan_aux.c:1833 - is_aux_addr_match = - ull_sync_setup_addr_check(sync, scan->periodic.filter_policy, - pdu->tx_addr, ptr, rl_idx); + is_aux_addr_match = ull_sync_setup_addr_check( + sync, scan->periodic.filter_policy, pdu->tx_addr, ptr, rl_idx);
scan->periodic.state = LL_SYNC_STATE_ADDR_MATCH;
} else {
scan->periodic.state = LL_SYNC_STATE_IDLE;
}
}
#endif /* CONFIG_BT_CTLR_SYNC_PERIODIC */

Expand Down Expand Up @@ -1819,14 +1867,21 @@
si = (void *)ptr;
ptr += sizeof(*si);

#if defined(CONFIG_BT_CTLR_SYNC_PERIODIC)
/* Check if Periodic Advertising Synchronization to be created.
* Setup synchronization if address and SID match in the
* Periodic Advertiser List or with the explicitly supplied.
*
* is_aux_addr_match, device address in auxiliary channel PDU;
* scan->periodic.param has not been assigned yet.
* Otherwise, address was in primary channel PDU and we are now
* checking SID (in SyncInfo) in auxiliary channel PDU.
*/
if (IS_ENABLED(CONFIG_BT_CTLR_SYNC_PERIODIC) && chain && sync && adi &&
ull_sync_setup_sid_match(sync, scan, PDU_ADV_ADI_SID_GET(adi))) {
if (sync && chain && (is_aux_addr_match || (scan->periodic.param == chain)) &&
adi && ull_sync_setup_sid_match(sync, scan, PDU_ADV_ADI_SID_GET(adi))) {
ull_sync_setup(scan, chain->lll.phy, rx, si);
}
#endif /* CONFIG_BT_CTLR_SYNC_PERIODIC */
}

if (h->tx_pwr) {
Expand Down Expand Up @@ -2008,6 +2063,13 @@
#endif /* CONFIG_BT_CTLR_JIT_SCHEDULING */

#if defined(CONFIG_BT_CTLR_SYNC_PERIODIC)
/* Store the chain context that has Periodic Advertising
* Synchronization address match.
*/
if (sync && (scan->periodic.state == LL_SYNC_STATE_ADDR_MATCH)) {
scan->periodic.param = chain;
}

if (sync_lll) {
struct ll_sync_set *sync_set = HDR_LLL2ULL(sync_lll);

Expand Down Expand Up @@ -2149,6 +2211,7 @@
#if defined(CONFIG_BT_CTLR_SYNC_PERIODIC)
if (sync && (scan->periodic.state != LL_SYNC_STATE_CREATED)) {
scan->periodic.state = LL_SYNC_STATE_IDLE;
scan->periodic.param = NULL;
}
#endif /* CONFIG_BT_CTLR_SYNC_PERIODIC */

Expand Down
5 changes: 5 additions & 0 deletions subsys/bluetooth/controller/ll_sw/ull_scan_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ struct ll_scan_set {
* cancelling sync create, hence the volatile keyword.
*/
struct ll_sync_set *volatile sync;

/* Non-NULL when Periodic Advertising Synchronisation address
* matched.
*/
void *param;
} periodic;
#endif
};
Expand Down
19 changes: 13 additions & 6 deletions subsys/bluetooth/controller/ll_sw/ull_sync.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,13 @@

scan->periodic.cancelled = 0U;
scan->periodic.state = LL_SYNC_STATE_IDLE;
scan->periodic.param = NULL;
scan->periodic.filter_policy =
options & BT_HCI_LE_PER_ADV_CREATE_SYNC_FP_USE_LIST;
if (IS_ENABLED(CONFIG_BT_CTLR_PHY_CODED)) {
scan_coded->periodic.cancelled = 0U;
scan_coded->periodic.state = LL_SYNC_STATE_IDLE;
scan_coded->periodic.param = NULL;
scan_coded->periodic.filter_policy =
scan->periodic.filter_policy;
}
Expand Down Expand Up @@ -880,13 +882,13 @@
mem_release(sync, &sync_free);
}

void ull_sync_setup_addr_check(struct ll_sync_set *sync, struct ll_scan_set *scan,
bool ull_sync_setup_addr_check(struct ll_sync_set *sync, uint8_t filter_policy,
uint8_t addr_type, uint8_t *addr, uint8_t rl_idx)
{
/* Check if Periodic Advertiser list to be used */
if (IS_ENABLED(CONFIG_BT_CTLR_SYNC_PERIODIC_ADV_LIST) &&
scan->periodic.filter_policy) {
filter_policy) {
/* Check in Periodic Advertiser List */

Check notice on line 891 in subsys/bluetooth/controller/ll_sw/ull_sync.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

subsys/bluetooth/controller/ll_sw/ull_sync.c:891 -bool ull_sync_setup_addr_check(struct ll_sync_set *sync, uint8_t filter_policy, - uint8_t addr_type, uint8_t *addr, uint8_t rl_idx) +bool ull_sync_setup_addr_check(struct ll_sync_set *sync, uint8_t filter_policy, uint8_t addr_type, + uint8_t *addr, uint8_t rl_idx) { /* Check if Periodic Advertiser list to be used */ - if (IS_ENABLED(CONFIG_BT_CTLR_SYNC_PERIODIC_ADV_LIST) && - filter_policy) { + if (IS_ENABLED(CONFIG_BT_CTLR_SYNC_PERIODIC_ADV_LIST) && filter_policy) {
if (ull_filter_ull_pal_addr_match(addr_type, addr)) {
/* Remember the address, to check with
* SID in Sync Info
Expand All @@ -896,10 +898,10 @@
BDADDR_SIZE);

/* Address matched */
scan->periodic.state = LL_SYNC_STATE_ADDR_MATCH;
return true;

/* Check in Resolving List */
} else if (IS_ENABLED(CONFIG_BT_CTLR_PRIVACY) &&

Check notice on line 904 in subsys/bluetooth/controller/ll_sw/ull_sync.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

subsys/bluetooth/controller/ll_sw/ull_sync.c:904 - /* Check in Resolving List */ + /* Check in Resolving List */
ull_filter_ull_pal_listed(rl_idx, &addr_type,
sync->peer_id_addr)) {
/* Remember the address, to check with the
Expand All @@ -911,28 +913,30 @@
sync->peer_addr_resolved = 1U;

/* Address matched */
scan->periodic.state = LL_SYNC_STATE_ADDR_MATCH;
return true;
}

/* Check with explicitly supplied address */
} else if ((addr_type == sync->peer_id_addr_type) &&
!memcmp(addr, sync->peer_id_addr, BDADDR_SIZE)) {
/* Address matched */
scan->periodic.state = LL_SYNC_STATE_ADDR_MATCH;
return true;

/* Check identity address with explicitly supplied address */
} else if (IS_ENABLED(CONFIG_BT_CTLR_PRIVACY) &&
(rl_idx < ll_rl_size_get())) {
ll_rl_id_addr_get(rl_idx, &addr_type, addr);

Check notice on line 928 in subsys/bluetooth/controller/ll_sw/ull_sync.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

subsys/bluetooth/controller/ll_sw/ull_sync.c:928 - /* Check identity address with explicitly supplied address */ - } else if (IS_ENABLED(CONFIG_BT_CTLR_PRIVACY) && - (rl_idx < ll_rl_size_get())) { + /* Check identity address with explicitly supplied address */ + } else if (IS_ENABLED(CONFIG_BT_CTLR_PRIVACY) && (rl_idx < ll_rl_size_get())) {
if ((addr_type == sync->peer_id_addr_type) &&
!memcmp(addr, sync->peer_id_addr, BDADDR_SIZE)) {
/* Mark it as identity address from RPA */
sync->peer_addr_resolved = 1U;

/* Identity address matched */
scan->periodic.state = LL_SYNC_STATE_ADDR_MATCH;
return true;
}
}

return false;
}

bool ull_sync_setup_sid_match(struct ll_sync_set *sync, struct ll_scan_set *scan, uint8_t sid)
Expand Down Expand Up @@ -1060,6 +1064,7 @@

/* Set the state to sync create */
scan->periodic.state = LL_SYNC_STATE_CREATED;
scan->periodic.param = NULL;
if (IS_ENABLED(CONFIG_BT_CTLR_PHY_CODED)) {
struct ll_scan_set *scan_1m;

Expand All @@ -1069,8 +1074,10 @@

scan_coded = ull_scan_set_get(SCAN_HANDLE_PHY_CODED);
scan_coded->periodic.state = LL_SYNC_STATE_CREATED;
scan_coded->periodic.param = NULL;
} else {
scan_1m->periodic.state = LL_SYNC_STATE_CREATED;
scan_1m->periodic.param = NULL;
}
}

Expand Down
2 changes: 1 addition & 1 deletion subsys/bluetooth/controller/ll_sw/ull_sync_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
uint16_t ull_sync_handle_get(struct ll_sync_set *sync);
struct ll_sync_set *ull_sync_is_enabled_get(uint16_t handle);
void ull_sync_release(struct ll_sync_set *sync);
void ull_sync_setup_addr_check(struct ll_sync_set *sync, struct ll_scan_set *scan,
bool ull_sync_setup_addr_check(struct ll_sync_set *sync, uint8_t filter_policy,
uint8_t addr_type, uint8_t *addr, uint8_t rl_idx);
bool ull_sync_setup_sid_match(struct ll_sync_set *sync, struct ll_scan_set *scan, uint8_t sid);

Check notice on line 14 in subsys/bluetooth/controller/ll_sw/ull_sync_internal.h

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

subsys/bluetooth/controller/ll_sw/ull_sync_internal.h:14 -bool ull_sync_setup_addr_check(struct ll_sync_set *sync, uint8_t filter_policy, - uint8_t addr_type, uint8_t *addr, uint8_t rl_idx); +bool ull_sync_setup_addr_check(struct ll_sync_set *sync, uint8_t filter_policy, uint8_t addr_type, + uint8_t *addr, uint8_t rl_idx);
void ull_sync_create_from_sync_transfer(uint16_t conn_handle, uint16_t service_data,
struct ll_sync_set *sync,
struct pdu_adv_sync_info *si,
Expand Down
Loading