Lines Matching +full:scan +full:- +full:limit
2 * Copyright (c) 2020-2021 Nordic Semiconductor ASA
4 * SPDX-License-Identifier: Apache-2.0
72 * allocated using mem interface. timeout_reload being non-zero is used to
120 struct ll_scan_set *scan; in ll_sync_create() local
125 scan = ull_scan_set_get(SCAN_HANDLE_1M); in ll_sync_create()
126 if (!scan || scan->periodic.sync) { in ll_sync_create()
132 if (!scan_coded || scan_coded->periodic.sync) { in ll_sync_create()
153 scan->periodic.cancelled = 0U; in ll_sync_create()
154 scan->periodic.state = LL_SYNC_STATE_IDLE; in ll_sync_create()
155 scan->periodic.param = NULL; in ll_sync_create()
156 scan->periodic.filter_policy = in ll_sync_create()
159 scan_coded->periodic.cancelled = 0U; in ll_sync_create()
160 scan_coded->periodic.state = LL_SYNC_STATE_IDLE; in ll_sync_create()
161 scan_coded->periodic.param = NULL; in ll_sync_create()
162 scan_coded->periodic.filter_policy = in ll_sync_create()
163 scan->periodic.filter_policy; in ll_sync_create()
166 if (!scan->periodic.filter_policy) { in ll_sync_create()
167 sync->peer_id_addr_type = adv_addr_type; in ll_sync_create()
168 (void)memcpy(sync->peer_id_addr, adv_addr, BDADDR_SIZE); in ll_sync_create()
177 sync->peer_id_addr_type = adv_addr_type; in ll_sync_create()
178 (void)memcpy(sync->peer_id_addr, adv_addr, in ll_sync_create()
179 sizeof(sync->peer_id_addr)); in ll_sync_create()
184 sync->lll.filter_policy = scan->periodic.filter_policy; in ll_sync_create()
188 scan->periodic.sync = sync; in ll_sync_create()
191 scan->lll.is_sync = 1U; in ll_sync_create()
194 scan_coded->periodic.sync = sync; in ll_sync_create()
197 scan_coded->lll.is_sync = 1U; in ll_sync_create()
228 lll = &sync->lll; in ull_sync_setup_from_sync_transfer()
233 chm_last = lll->chm_first; in ull_sync_setup_from_sync_transfer()
234 lll->chm_last = chm_last; in ull_sync_setup_from_sync_transfer()
235 data_chan_map = lll->chm[chm_last].data_chan_map; in ull_sync_setup_from_sync_transfer()
236 (void)memcpy(data_chan_map, si->sca_chm, in ull_sync_setup_from_sync_transfer()
237 sizeof(lll->chm[chm_last].data_chan_map)); in ull_sync_setup_from_sync_transfer()
240 lll->chm[chm_last].data_chan_count = in ull_sync_setup_from_sync_transfer()
242 sizeof(lll->chm[chm_last].data_chan_map)); in ull_sync_setup_from_sync_transfer()
243 if (lll->chm[chm_last].data_chan_count < CHM_USED_COUNT_MIN) { in ull_sync_setup_from_sync_transfer()
248 memcpy(lll->access_addr, si->aa, sizeof(lll->access_addr)); in ull_sync_setup_from_sync_transfer()
249 lll->data_chan_id = lll_chan_id(lll->access_addr); in ull_sync_setup_from_sync_transfer()
250 memcpy(lll->crc_init, si->crc_init, sizeof(lll->crc_init)); in ull_sync_setup_from_sync_transfer()
251 lll->event_counter = sys_le16_to_cpu(si->evt_cntr); in ull_sync_setup_from_sync_transfer()
253 interval = sys_le16_to_cpu(si->interval); in ull_sync_setup_from_sync_transfer()
257 if (sync->timeout != 0 && interval_us != 0) { in ull_sync_setup_from_sync_transfer()
258 sync->timeout_reload = RADIO_SYNC_EVENTS((sync->timeout * 10U * in ull_sync_setup_from_sync_transfer()
272 if (sync->timeout_reload > CONN_ESTAB_COUNTDOWN) { in ull_sync_setup_from_sync_transfer()
273 uint16_t skip_max = sync->timeout_reload - CONN_ESTAB_COUNTDOWN; in ull_sync_setup_from_sync_transfer()
275 if (sync->skip > skip_max) { in ull_sync_setup_from_sync_transfer()
276 sync->skip = skip_max; in ull_sync_setup_from_sync_transfer()
280 sync->sync_expire = CONN_ESTAB_COUNTDOWN; in ull_sync_setup_from_sync_transfer()
285 sca = (si->sca_chm[PDU_SYNC_INFO_SCA_CHM_SCA_BYTE_OFFSET] & in ull_sync_setup_from_sync_transfer()
289 lll->sca = sca; in ull_sync_setup_from_sync_transfer()
291 lll->window_widening_periodic_us = in ull_sync_setup_from_sync_transfer()
295 lll->window_widening_max_us = (interval_us >> 1) - EVENT_IFS_US; in ull_sync_setup_from_sync_transfer()
297 lll->window_size_event_us = OFFS_UNIT_300_US; in ull_sync_setup_from_sync_transfer()
299 lll->window_size_event_us = OFFS_UNIT_30_US; in ull_sync_setup_from_sync_transfer()
303 lll->node_cte_incomplete = NULL; in ull_sync_setup_from_sync_transfer()
308 rx = (void *)sync->node_rx_sync_estab; in ull_sync_setup_from_sync_transfer()
309 rx->hdr.type = NODE_RX_TYPE_SYNC_TRANSFER_RECEIVED; in ull_sync_setup_from_sync_transfer()
310 rx->hdr.handle = sync_handle; in ull_sync_setup_from_sync_transfer()
311 rx->rx_ftr.param = sync; in ull_sync_setup_from_sync_transfer()
314 se_past = (void *)rx->pdu; in ull_sync_setup_from_sync_transfer()
315 se_past->rx_sync.status = BT_HCI_ERR_SUCCESS; in ull_sync_setup_from_sync_transfer()
316 se_past->rx_sync.interval = interval; in ull_sync_setup_from_sync_transfer()
317 se_past->rx_sync.phy = sync->lll.phy; in ull_sync_setup_from_sync_transfer()
318 se_past->rx_sync.sca = sca; in ull_sync_setup_from_sync_transfer()
319 se_past->conn_handle = ll_conn_handle_get(conn); in ull_sync_setup_from_sync_transfer()
320 se_past->service_data = service_data; in ull_sync_setup_from_sync_transfer()
322 conn_interval_us = conn->lll.interval * CONN_INT_UNIT_US; in ull_sync_setup_from_sync_transfer()
325 ready_delay_us = lll_radio_rx_ready_delay_get(lll->phy, PHY_FLAGS_S8); in ull_sync_setup_from_sync_transfer()
327 sync_offset_us = PDU_ADV_SYNC_INFO_OFFSET_GET(si) * lll->window_size_event_us; in ull_sync_setup_from_sync_transfer()
330 sync_offset_us -= EVENT_TICKER_RES_MARGIN_US; in ull_sync_setup_from_sync_transfer()
331 sync_offset_us -= EVENT_JITTER_US; in ull_sync_setup_from_sync_transfer()
332 sync_offset_us -= ready_delay_us; in ull_sync_setup_from_sync_transfer()
341 lll->event_counter += sync_intervals; in ull_sync_setup_from_sync_transfer()
342 sync_offset_us = (sync_intervals * interval_us) - total_offset_us; in ull_sync_setup_from_sync_transfer()
348 /* Calculate initial window widening - see Core Spec vol 6, part B, 5.1.13.1 */ in ull_sync_setup_from_sync_transfer()
358 event_delta = lll->event_counter - last_pa_event_counter; in ull_sync_setup_from_sync_transfer()
364 db = DIV_ROUND_UP(db * (uint64_t)(ull_conn_event_counter(conn) - in ull_sync_setup_from_sync_transfer()
371 /* Limit drift compenstion to the maximum window widening */ in ull_sync_setup_from_sync_transfer()
372 drift_us = MIN((uint32_t)d, lll->window_widening_max_us); in ull_sync_setup_from_sync_transfer()
375 lll->window_size_event_us += drift_us; in ull_sync_setup_from_sync_transfer()
380 lll->event_counter++; in ull_sync_setup_from_sync_transfer()
383 sync_offset_us -= drift_us; in ull_sync_setup_from_sync_transfer()
386 interval_us -= lll->window_widening_periodic_us; in ull_sync_setup_from_sync_transfer()
389 slot_us = PDU_AC_MAX_US(PDU_AC_EXT_PAYLOAD_RX_SIZE, lll->phy); in ull_sync_setup_from_sync_transfer()
398 sync->ull.ticks_active_to_start = 0U; in ull_sync_setup_from_sync_transfer()
399 sync->ull.ticks_prepare_to_start = in ull_sync_setup_from_sync_transfer()
401 sync->ull.ticks_preempt_to_start = in ull_sync_setup_from_sync_transfer()
403 sync->ull.ticks_slot = HAL_TICKER_US_TO_TICKS_CEIL(slot_us); in ull_sync_setup_from_sync_transfer()
405 ticks_slot_offset = MAX(sync->ull.ticks_active_to_start, in ull_sync_setup_from_sync_transfer()
406 sync->ull.ticks_prepare_to_start); in ull_sync_setup_from_sync_transfer()
414 sync->lll_sync_prepare = lll_sync_create_prepare; in ull_sync_setup_from_sync_transfer()
416 ticks_anchor = conn->llcp.prep.ticks_at_expire; in ull_sync_setup_from_sync_transfer()
419 if (conn->lll.role == BT_HCI_ROLE_PERIPHERAL) { in ull_sync_setup_from_sync_transfer()
421 ticks_anchor += HAL_TICKER_US_TO_TICKS(conn->lll.periph.window_widening_event_us); in ull_sync_setup_from_sync_transfer()
432 (sync->ull.ticks_slot + ticks_slot_overhead), in ull_sync_setup_from_sync_transfer()
447 struct ll_scan_set *scan; in ll_sync_create_cancel() local
451 scan = ull_scan_set_get(SCAN_HANDLE_1M); in ll_sync_create_cancel()
452 if (!scan || !scan->periodic.sync) { in ll_sync_create_cancel()
458 if (!scan_coded || !scan_coded->periodic.sync) { in ll_sync_create_cancel()
466 * Setting `scan->periodic.cancelled` to represent cancellation in ll_sync_create_cancel()
467 * requested in the thread context. Checking `scan->periodic.sync` for in ll_sync_create_cancel()
469 * `scan->periodic.cancelled` was set to 1U. in ll_sync_create_cancel()
471 scan->periodic.cancelled = 1U; in ll_sync_create_cancel()
473 scan_coded->periodic.cancelled = 1U; in ll_sync_create_cancel()
476 sync = scan->periodic.sync; in ll_sync_create_cancel()
482 * established. timeout_reload is set when sync is found and setup. It is non-zero until in ll_sync_create_cancel()
484 * - node_rx_sync_estab == NULL && timeout_reload != 0 => sync is established in ll_sync_create_cancel()
485 * - node_rx_sync_estab == NULL && timeout_reload == 0 => sync is terminated in ll_sync_create_cancel()
486 * - node_rx_sync_estab != NULL && timeout_reload == 0 => sync is created in ll_sync_create_cancel()
487 * - node_rx_sync_estab != NULL && timeout_reload != 0 => sync is waiting to be established in ll_sync_create_cancel()
489 if (!sync->node_rx_sync_estab) { in ll_sync_create_cancel()
494 sync->is_stop = 1U; in ll_sync_create_cancel()
497 if (sync->timeout_reload != 0U) { in ll_sync_create_cancel()
506 sync, &sync->lll); in ll_sync_create_cancel()
507 if (err != 0 && err != -EALREADY) { in ll_sync_create_cancel()
519 sync->timeout = 0U; in ll_sync_create_cancel()
522 node_rx = sync->node_rx_sync_estab; in ll_sync_create_cancel()
523 link_sync_estab = node_rx->hdr.link; in ll_sync_create_cancel()
524 link_sync_lost = sync->node_rx_lost.rx.hdr.link; in ll_sync_create_cancel()
533 sync->node_rx_sync_estab = NULL; in ll_sync_create_cancel()
535 node_rx = (void *)&sync->node_rx_lost; in ll_sync_create_cancel()
536 node_rx->hdr.type = NODE_RX_TYPE_SYNC; in ll_sync_create_cancel()
537 node_rx->hdr.handle = LLL_HANDLE_INVALID; in ll_sync_create_cancel()
542 se = (void *)node_rx->pdu; in ll_sync_create_cancel()
543 se->status = BT_HCI_ERR_OP_CANCELLED_BY_HOST; in ll_sync_create_cancel()
548 node_rx->rx_ftr.param = sync; in ll_sync_create_cancel()
568 sync->is_stop = 1U; in ll_sync_terminate()
573 sync, &sync->lll); in ll_sync_terminate()
574 LL_ASSERT_INFO2(err == 0 || err == -EALREADY, handle, err); in ll_sync_terminate()
580 lll_aux = sync->lll.lll_aux; in ll_sync_terminate()
583 err = ull_scan_aux_stop(&sync->lll); in ll_sync_terminate()
590 if (err && (err != -EALREADY)) { in ll_sync_terminate()
595 LL_ASSERT(!aux->parent); in ll_sync_terminate()
601 if (sync->node_rx_sync_estab) { in ll_sync_terminate()
605 node_rx = (void *)sync->node_rx_sync_estab; in ll_sync_terminate()
606 link_sync_estab = node_rx->hdr.link; in ll_sync_terminate()
611 sync->node_rx_sync_estab = NULL; in ll_sync_terminate()
615 link_sync_lost = sync->node_rx_lost.rx.hdr.link; in ll_sync_terminate()
619 sync->timeout_reload = 0U; in ll_sync_terminate()
631 * @param[in] enable Bit number 0 - Reporting Enabled.
632 * Bit number 1 - Duplicate filtering enabled.
633 * All other bits - Reserved for future use.
647 sync->rx_enable = (enable & BT_HCI_LE_SET_PER_ADV_RECV_ENABLE_ENABLE) ? in ll_sync_recv_enable()
651 sync->nodups = (enable & BT_HCI_LE_SET_PER_ADV_RECV_ENABLE_FILTER_DUPLICATE) ? in ll_sync_recv_enable()
726 conn->past.mode = mode; in ll_past_param()
727 conn->past.skip = skip; in ll_past_param()
728 conn->past.timeout = timeout; in ll_past_param()
729 conn->past.cte_type = cte_type; in ll_past_param()
809 if (!sync || !sync->timeout_reload) { in ull_sync_is_enabled_get()
820 (sizeof(struct ll_sync_set) * (CONFIG_BT_PER_ADV_SYNC_MAX - 1))))) { in ull_sync_is_valid_get()
834 return &sync->lll; in ull_sync_lll_is_valid_get()
853 struct lll_sync *lll = &sync->lll; in ull_sync_release()
855 if (lll->node_cte_incomplete) { in ull_sync_release()
860 node_rx = &lll->node_cte_incomplete->rx; in ull_sync_release()
861 link = node_rx->hdr.link; in ull_sync_release()
868 lll->node_cte_incomplete = NULL; in ull_sync_release()
874 sync->timeout = 0U; in ull_sync_release()
879 sync->data_len = 0U; in ull_sync_release()
896 sync->peer_id_addr_type = addr_type; in ull_sync_setup_addr_check()
897 (void)memcpy(sync->peer_id_addr, addr, in ull_sync_setup_addr_check()
906 sync->peer_id_addr)) { in ull_sync_setup_addr_check()
910 sync->peer_id_addr_type = addr_type; in ull_sync_setup_addr_check()
913 sync->peer_addr_resolved = 1U; in ull_sync_setup_addr_check()
920 } else if ((addr_type == sync->peer_id_addr_type) && in ull_sync_setup_addr_check()
921 !memcmp(addr, sync->peer_id_addr, BDADDR_SIZE)) { in ull_sync_setup_addr_check()
929 if ((addr_type == sync->peer_id_addr_type) && in ull_sync_setup_addr_check()
930 !memcmp(addr, sync->peer_id_addr, BDADDR_SIZE)) { in ull_sync_setup_addr_check()
932 sync->peer_addr_resolved = 1U; in ull_sync_setup_addr_check()
942 bool ull_sync_setup_sid_match(struct ll_sync_set *sync, struct ll_scan_set *scan, uint8_t sid) in ull_sync_setup_sid_match() argument
944 return (scan->periodic.state == LL_SYNC_STATE_ADDR_MATCH) && in ull_sync_setup_sid_match()
946 scan->periodic.filter_policy && in ull_sync_setup_sid_match()
947 ull_filter_ull_pal_match(sync->peer_id_addr_type, in ull_sync_setup_sid_match()
948 sync->peer_id_addr, sid)) || in ull_sync_setup_sid_match()
949 (!scan->periodic.filter_policy && in ull_sync_setup_sid_match()
950 (sid == sync->sid))); in ull_sync_setup_sid_match()
953 void ull_sync_setup(struct ll_scan_set *scan, uint8_t phy, in ull_sync_setup() argument
977 sync = scan->periodic.sync; in ull_sync_setup()
978 lll = &sync->lll; in ull_sync_setup()
983 chm_last = lll->chm_first; in ull_sync_setup()
984 lll->chm_last = chm_last; in ull_sync_setup()
985 data_chan_map = lll->chm[chm_last].data_chan_map; in ull_sync_setup()
986 (void)memcpy(data_chan_map, si->sca_chm, in ull_sync_setup()
987 sizeof(lll->chm[chm_last].data_chan_map)); in ull_sync_setup()
990 lll->chm[chm_last].data_chan_count = in ull_sync_setup()
992 sizeof(lll->chm[chm_last].data_chan_map)); in ull_sync_setup()
993 if (lll->chm[chm_last].data_chan_count < CHM_USED_COUNT_MIN) { in ull_sync_setup()
998 memcpy(lll->access_addr, si->aa, sizeof(lll->access_addr)); in ull_sync_setup()
999 lll->data_chan_id = lll_chan_id(lll->access_addr); in ull_sync_setup()
1000 memcpy(lll->crc_init, si->crc_init, sizeof(lll->crc_init)); in ull_sync_setup()
1001 lll->event_counter = sys_le16_to_cpu(si->evt_cntr); in ull_sync_setup()
1002 lll->phy = phy; in ull_sync_setup()
1003 lll->forced = 0U; in ull_sync_setup()
1005 interval = sys_le16_to_cpu(si->interval); in ull_sync_setup()
1010 sync->interval = interval; in ull_sync_setup()
1014 sync->timeout_reload = RADIO_SYNC_EVENTS((sync->timeout * 10U * in ull_sync_setup()
1027 if (sync->timeout_reload > CONN_ESTAB_COUNTDOWN) { in ull_sync_setup()
1028 uint16_t skip_max = sync->timeout_reload - CONN_ESTAB_COUNTDOWN; in ull_sync_setup()
1030 if (sync->skip > skip_max) { in ull_sync_setup()
1031 sync->skip = skip_max; in ull_sync_setup()
1034 sync->skip = 0U; in ull_sync_setup()
1037 sync->sync_expire = CONN_ESTAB_COUNTDOWN; in ull_sync_setup()
1042 sca = (si->sca_chm[PDU_SYNC_INFO_SCA_CHM_SCA_BYTE_OFFSET] & in ull_sync_setup()
1047 lll->sca = sca; in ull_sync_setup()
1050 lll->window_widening_periodic_us = in ull_sync_setup()
1054 lll->window_widening_max_us = (interval_us >> 1) - EVENT_IFS_US; in ull_sync_setup()
1056 lll->window_size_event_us = OFFS_UNIT_300_US; in ull_sync_setup()
1058 lll->window_size_event_us = OFFS_UNIT_30_US; in ull_sync_setup()
1062 lll->node_cte_incomplete = NULL; in ull_sync_setup()
1066 scan->periodic.state = LL_SYNC_STATE_CREATED; in ull_sync_setup()
1067 scan->periodic.param = NULL; in ull_sync_setup()
1072 if (scan == scan_1m) { in ull_sync_setup()
1076 scan_coded->periodic.state = LL_SYNC_STATE_CREATED; in ull_sync_setup()
1077 scan_coded->periodic.param = NULL; in ull_sync_setup()
1079 scan_1m->periodic.state = LL_SYNC_STATE_CREATED; in ull_sync_setup()
1080 scan_1m->periodic.param = NULL; in ull_sync_setup()
1089 rx = (void *)sync->node_rx_sync_estab; in ull_sync_setup()
1090 rx->hdr.type = NODE_RX_TYPE_SYNC; in ull_sync_setup()
1091 rx->hdr.handle = sync_handle; in ull_sync_setup()
1092 rx->rx_ftr.param = sync; in ull_sync_setup()
1093 se = (void *)rx->pdu; in ull_sync_setup()
1094 se->interval = interval; in ull_sync_setup()
1095 se->phy = lll->phy; in ull_sync_setup()
1096 se->sca = sca; in ull_sync_setup()
1099 ftr = &node_rx->rx_ftr; in ull_sync_setup()
1100 pdu = (void *)((struct node_rx_pdu *)node_rx)->pdu; in ull_sync_setup()
1102 ready_delay_us = lll_radio_rx_ready_delay_get(lll->phy, PHY_FLAGS_S8); in ull_sync_setup()
1104 sync_offset_us = ftr->radio_end_us; in ull_sync_setup()
1106 lll->window_size_event_us; in ull_sync_setup()
1109 sync_offset_us -= PDU_AC_US(pdu->len, lll->phy, ftr->phy_flags); in ull_sync_setup()
1110 sync_offset_us -= EVENT_TICKER_RES_MARGIN_US; in ull_sync_setup()
1111 sync_offset_us -= EVENT_JITTER_US; in ull_sync_setup()
1112 sync_offset_us -= ready_delay_us; in ull_sync_setup()
1125 if ((sync_offset_us - ftr->radio_end_us) < overhead_us) { in ull_sync_setup()
1127 lll->event_counter++; in ull_sync_setup()
1130 interval_us -= lll->window_widening_periodic_us; in ull_sync_setup()
1133 slot_us = PDU_AC_MAX_US(PDU_AC_EXT_PAYLOAD_RX_SIZE, lll->phy); in ull_sync_setup()
1142 sync->ull.ticks_active_to_start = 0U; in ull_sync_setup()
1143 sync->ull.ticks_prepare_to_start = in ull_sync_setup()
1145 sync->ull.ticks_preempt_to_start = in ull_sync_setup()
1147 sync->ull.ticks_slot = HAL_TICKER_US_TO_TICKS_CEIL(slot_us); in ull_sync_setup()
1149 ticks_slot_offset = MAX(sync->ull.ticks_active_to_start, in ull_sync_setup()
1150 sync->ull.ticks_prepare_to_start); in ull_sync_setup()
1158 sync->lll_sync_prepare = lll_sync_create_prepare; in ull_sync_setup()
1162 ftr->ticks_anchor - ticks_slot_offset, in ull_sync_setup()
1167 (sync->ull.ticks_slot + ticks_slot_overhead), in ull_sync_setup()
1176 struct ll_scan_set *scan; in ull_sync_setup_reset() local
1178 /* Remove the sync context from being associated with scan contexts */ in ull_sync_setup_reset()
1179 scan = ull_scan_set_get(SCAN_HANDLE_1M); in ull_sync_setup_reset()
1181 scan->periodic.sync = NULL; in ull_sync_setup_reset()
1184 scan->lll.is_sync = 0U; in ull_sync_setup_reset()
1188 scan = ull_scan_set_get(SCAN_HANDLE_PHY_CODED); in ull_sync_setup_reset()
1190 scan->periodic.sync = NULL; in ull_sync_setup_reset()
1193 scan->lll.is_sync = 0U; in ull_sync_setup_reset()
1206 ftr = &rx->rx_ftr;
1207 lll = ftr->param;
1211 if (unlikely(sync->is_stop || !sync->timeout_reload)) {
1219 sync_status = ftr->sync_status;
1223 rx_cte_info = pdu_cte_info_get((struct pdu_adv *)rx->pdu);
1225 sync_status = lll_sync_cte_is_allowed(lll->cte_type, lll->filter_policy,
1226 rx_cte_info->time, rx_cte_info->type);
1228 sync_status = lll_sync_cte_is_allowed(lll->cte_type, lll->filter_policy, 0,
1238 sync->is_term = ((sync_status == SYNC_STAT_TERM) || (sync_status == SYNC_STAT_CONT_SCAN));
1251 rx_establ = (void *)sync->node_rx_sync_estab;
1252 rx_establ->hdr.handle = ull_sync_handle_get(sync);
1253 se = (void *)rx_establ->pdu;
1257 sync->node_rx_sync_estab = NULL;
1260 se->status = (ftr->sync_status == SYNC_STAT_TERM) ?
1264 se->status = BT_HCI_ERR_SUCCESS;
1271 ll_rx_put_sched(rx_establ->hdr.link, rx_establ);
1275 /* Handle periodic advertising PDU and send periodic advertising scan report when
1286 sync->lll_sync_prepare = lll_sync_prepare;
1291 rx->hdr.type = NODE_RX_TYPE_SYNC_REPORT;
1294 rx->hdr.type = NODE_RX_TYPE_RELEASE;
1304 sync = CONTAINER_OF(done->param, struct ll_sync_set, ull);
1307 if (unlikely(sync->is_stop || !sync->timeout_reload)) {
1313 if (done->extra.sync_term) {
1315 if (sync->is_term) {
1340 lll = &sync->lll;
1343 skip_event = lll->skip_event;
1348 if (done->extra.trx_cnt) {
1353 lll->skip_event = sync->skip;
1356 sync->sync_expire = 0U;
1359 elapsed_event = skip_event + lll->lazy_prepare + 1U;
1362 if (done->extra.crc_valid) {
1363 sync->timeout_expire = 0U;
1367 else if (sync->sync_expire) {
1368 if (sync->sync_expire > elapsed_event) {
1369 sync->sync_expire -= elapsed_event;
1377 /* If anchor point not sync-ed, start timeout countdown, and break skip if any */
1378 else if (!sync->timeout_expire) {
1379 sync->timeout_expire = sync->timeout_reload;
1385 if (sync->timeout_expire) {
1386 if (sync->timeout_expire > elapsed_event) {
1387 sync->timeout_expire -= elapsed_event;
1390 lll->skip_event = 0U;
1392 if (sync->timeout_expire <= 6U) {
1406 lll->forced = force_lll;
1410 if ((force) || (skip_event != lll->skip_event)) {
1411 lazy = lll->skip_event + 1U;
1453 lll = &sync->lll;
1456 if (lll->chm_last != lll->chm_first) {
1473 acad_len -= ad_len;
1488 chm_last = lll->chm_last + 1U;
1494 (void)memcpy(lll->chm[chm_last].data_chan_map, chm_upd_ind->chm,
1495 sizeof(lll->chm[chm_last].data_chan_map));
1496 lll->chm[chm_last].data_chan_count =
1497 util_ones_count_get(lll->chm[chm_last].data_chan_map,
1498 sizeof(lll->chm[chm_last].data_chan_map));
1499 if (lll->chm[chm_last].data_chan_count < CHM_USED_COUNT_MIN) {
1504 lll->chm_instant = sys_le16_to_cpu(chm_upd_ind->instant);
1507 lll->chm_last = chm_last;
1518 * @retval -ENOENT Ticker node related with provided sync is already stopped.
1519 * @retval -ENOMEM Couldn't enqueue update ticker job.
1520 * @retval -EFAULT Somethin else went wrong.
1546 return -EFAULT; /* Something went wrong */
1558 return (ret_cb == TICKER_STATUS_FAILURE) ? -ENOENT : -ENOMEM;
1620 sync->peer_addr_resolved = 0U;
1623 node_rx->hdr.link = link_sync_estab;
1624 sync->node_rx_lost.rx.hdr.link = link_sync_lost;
1629 LL_ASSERT(!sync->node_rx_sync_estab);
1630 sync->node_rx_sync_estab = node_rx;
1633 sync->rx_enable = rx_enable;
1636 sync->nodups = nodups;
1638 sync->skip = skip;
1639 sync->is_stop = 0U;
1642 sync->enc = 0U;
1648 sync->timeout = timeout;
1651 sync->timeout_reload = 0U;
1652 sync->timeout_expire = 0U;
1655 sync->sid = sid;
1659 sync->iso.sync_iso = NULL;
1663 lll = &sync->lll;
1664 lll->lll_aux = NULL;
1665 lll->is_rx_enabled = sync->rx_enable;
1666 lll->skip_prepare = 0U;
1667 lll->skip_event = 0U;
1668 lll->window_widening_prepare_us = 0U;
1669 lll->window_widening_event_us = 0U;
1671 lll->cte_type = cte_type;
1675 ull_df_sync_cfg_init(&lll->df_cfg);
1676 LL_ASSERT(!lll->node_cte_incomplete);
1680 ull_hdr_init(&sync->ull);
1698 sync->timeout_reload = 0U;
1716 lll = &sync->lll;
1719 lll->is_rx_enabled = sync->rx_enable;
1722 ref = ull_ref_inc(&sync->ull);
1732 mfy_lll_prepare.fp = sync->lll_sync_prepare;
1776 rx = (void *)sync->node_rx_sync_estab;
1777 rx->hdr.handle = LLL_HANDLE_INVALID;
1782 sync->node_rx_sync_estab = NULL;
1787 se = (void *)rx->pdu;
1788 se->status = BT_HCI_ERR_CONN_FAIL_TO_ESTAB;
1793 ll_rx_put_sched(rx->hdr.link, rx);
1825 if (sync->lll_sync_prepare != lll_sync_prepare) {
1832 rx = (void *)&sync->node_rx_lost;
1833 rx->hdr.handle = ull_sync_handle_get(sync);
1834 rx->hdr.type = NODE_RX_TYPE_SYNC_LOST;
1835 rx->rx_ftr.param = sync;
1838 ll_rx_put_sched(rx->hdr.link, rx);
1841 if (sync->iso.sync_iso) {
1845 sync_iso = sync->iso.sync_iso;
1847 rx = (void *)&sync_iso->node_rx_lost;
1848 rx->hdr.handle = sync_iso->big_handle;
1849 rx->hdr.type = NODE_RX_TYPE_SYNC_ISO;
1850 rx->rx_ftr.param = sync_iso;
1851 *((uint8_t *)rx->pdu) = BT_HCI_ERR_CONN_FAIL_TO_ESTAB;
1854 ll_rx_put_sched(rx->hdr.link, rx);
1865 if (!sync || !sync->timeout) {
1882 (sync->peer_id_addr_type == peer_id_addr_type) &&
1883 !memcmp(sync->peer_id_addr, peer_id_addr, BDADDR_SIZE) &&
1884 (sync->sid == sid)) {
1909 com_hdr = &pdu->adv_ext_ind;
1910 hdr = &com_hdr->ext_hdr;
1912 if (!com_hdr->ext_hdr_len || (com_hdr->ext_hdr_len != 0 && !hdr->cte_info)) {
1917 LL_ASSERT(!hdr->adv_addr);
1918 LL_ASSERT(!hdr->tgt_addr);
1920 return (struct pdu_cte_info *)hdr->data;
1937 if (conn->past.mode == BT_HCI_LE_PAST_MODE_NO_SYNC) {
1938 /* Ignore LL_PERIODIC_SYNC_IND - see Bluetooth Core Specification v5.4
1951 nodups = (conn->past.mode == BT_HCI_LE_PAST_MODE_SYNC_FILTER_DUPLICATES) ? 1U : 0U;
1952 rx_enable = (conn->past.mode == BT_HCI_LE_PAST_MODE_NO_REPORTS) ? 0U : 1U;
1954 sync = ull_sync_create(sid, conn->past.timeout, conn->past.skip, conn->past.cte_type,
1962 sync->lll.filter_policy = 0U;
1965 sync->peer_id_addr_type = addr_type;
1966 sync->peer_addr_resolved = addr_resolved;
1967 memcpy(sync->peer_id_addr, adv_addr, BDADDR_SIZE);
1968 sync->lll.phy = phy;
1976 conn_event_count - conn_evt_current,