Lines Matching refs:chain

89 static inline void aux_chain_release(struct ll_scan_aux_chain *chain);
90 struct ll_scan_aux_chain *scan_aux_chain_is_valid_get(struct ll_scan_aux_chain *chain);
93 static void aux_sync_incomplete(struct ll_scan_aux_chain *chain);
95 static void flush(struct ll_scan_aux_chain *chain);
96 static void chain_start_ticker(struct ll_scan_aux_chain *chain, bool replace);
97 static bool chain_insert_in_sched_list(struct ll_scan_aux_chain *chain);
99 struct ll_scan_aux_chain *chain);
100 static void chain_append_to_list(struct ll_scan_aux_chain **head, struct ll_scan_aux_chain *chain);
101 static bool chain_is_in_list(struct ll_scan_aux_chain *head, struct ll_scan_aux_chain *chain);
1526 struct ll_scan_aux_chain *chain; in ull_scan_aux_setup() local
1559 chain = NULL; in ull_scan_aux_setup()
1575 chain = NULL; in ull_scan_aux_setup()
1599 chain = CONTAINER_OF(lll_aux, struct ll_scan_aux_chain, lll); in ull_scan_aux_setup()
1602 lll = chain->parent; in ull_scan_aux_setup()
1619 chain = CONTAINER_OF(lll_aux, struct ll_scan_aux_chain, lll); in ull_scan_aux_setup()
1620 LL_ASSERT(lll == chain->parent); in ull_scan_aux_setup()
1632 chain = CONTAINER_OF(lll_aux, struct ll_scan_aux_chain, lll); in ull_scan_aux_setup()
1633 LL_ASSERT(sync_lll == chain->parent); in ull_scan_aux_setup()
1716 chain = NULL; in ull_scan_aux_setup()
1739 if (chain) { in ull_scan_aux_setup()
1740 chain->aux_sched = 0U; in ull_scan_aux_setup()
1744 chain_remove_from_list(&scan_aux_set.active_chains, chain); in ull_scan_aux_setup()
1747 chain->is_lll_sched = 0U; in ull_scan_aux_setup()
1760 if (chain) { in ull_scan_aux_setup()
1761 chain->data_len += data_len; in ull_scan_aux_setup()
1762 ftr->aux_data_len = chain->data_len; in ull_scan_aux_setup()
1830 if (IS_ENABLED(CONFIG_BT_CTLR_SYNC_PERIODIC) && chain && sync && adi && in ull_scan_aux_setup()
1832 ull_sync_setup(scan, chain->lll.phy, rx, si); in ull_scan_aux_setup()
1858 if (chain) { in ull_scan_aux_setup()
1859 chain->data_len += data_len; in ull_scan_aux_setup()
1860 ftr->aux_data_len = chain->data_len; in ull_scan_aux_setup()
1908 LL_ASSERT(chain && chain->rx_last); in ull_scan_aux_setup()
1910 chain->rx_last->rx_ftr.extra = rx; in ull_scan_aux_setup()
1911 chain->rx_last = rx; in ull_scan_aux_setup()
1982 if (!chain) { in ull_scan_aux_setup()
1983 chain = aux_chain_acquire(); in ull_scan_aux_setup()
1984 if (!chain) { in ull_scan_aux_setup()
1999 chain->rx_head = chain->rx_last = NULL; in ull_scan_aux_setup()
2000 chain->data_len = data_len; in ull_scan_aux_setup()
2001 chain->is_lll_sched = ftr->aux_lll_sched; in ull_scan_aux_setup()
2002 lll_aux = &chain->lll; in ull_scan_aux_setup()
2007 chain->parent = lll ? (void *)lll : (void *)sync_lll; in ull_scan_aux_setup()
2040 } else if (chain->data_len >= CONFIG_BT_CTLR_SCAN_DATA_LEN_MAX) { in ull_scan_aux_setup()
2063 if (chain->rx_last) { in ull_scan_aux_setup()
2064 chain->rx_last->rx_ftr.extra = rx; in ull_scan_aux_setup()
2066 chain->rx_head = rx; in ull_scan_aux_setup()
2068 chain->rx_last = rx; in ull_scan_aux_setup()
2079 chain->aux_sched = 1U; in ull_scan_aux_setup()
2081 chain->next = scan_aux_set.active_chains; in ull_scan_aux_setup()
2082 scan_aux_set.active_chains = chain; in ull_scan_aux_setup()
2104 if (lll->lll_aux == &chain->lll) { in ull_scan_aux_setup()
2134 chain->ticker_ticks = (ftr->ticks_anchor + ticks_aux_offset) & HAL_TICKER_CNTR_MASK; in ull_scan_aux_setup()
2136 if (!chain_insert_in_sched_list(chain)) { in ull_scan_aux_setup()
2145 chain->aux_sched = 1U; in ull_scan_aux_setup()
2159 if (chain) { in ull_scan_aux_setup()
2163 if (!IS_ENABLED(CONFIG_BT_CTLR_SYNC_PERIODIC) || chain->rx_last) { in ull_scan_aux_setup()
2172 if (chain->rx_last != rx) { in ull_scan_aux_setup()
2173 chain->rx_last->rx_ftr.extra = rx; in ull_scan_aux_setup()
2174 chain->rx_last = rx; in ull_scan_aux_setup()
2182 LL_ASSERT(chain->parent); in ull_scan_aux_setup()
2184 flush_safe(chain); in ull_scan_aux_setup()
2200 struct ll_scan_aux_chain *chain; in ull_scan_aux_done() local
2203 chain = CONTAINER_OF(done->extra.lll, struct ll_scan_aux_chain, lll); in ull_scan_aux_done()
2204 LL_ASSERT(scan_aux_chain_is_valid_get(chain)); in ull_scan_aux_done()
2207 chain_remove_from_list(&scan_aux_set.active_chains, chain); in ull_scan_aux_done()
2209 flush(chain); in ull_scan_aux_done()
2220 struct ll_scan_aux_chain *chain; in ull_scan_aux_lll_parent_get() local
2222 chain = CONTAINER_OF(lll, struct ll_scan_aux_chain, lll); in ull_scan_aux_lll_parent_get()
2228 lllscan = chain->parent; in ull_scan_aux_lll_parent_get()
2235 return chain->parent; in ull_scan_aux_lll_parent_get()
2238 struct ll_scan_aux_chain *scan_aux_chain_is_valid_get(struct ll_scan_aux_chain *chain) in scan_aux_chain_is_valid_get() argument
2240 if (((uint8_t *)chain < (uint8_t *)ll_scan_aux_pool) || in scan_aux_chain_is_valid_get()
2241 ((uint8_t *)chain > ((uint8_t *)ll_scan_aux_pool + in scan_aux_chain_is_valid_get()
2247 return chain; in scan_aux_chain_is_valid_get()
2252 struct ll_scan_aux_chain *chain; in ull_scan_aux_lll_is_valid_get() local
2254 chain = CONTAINER_OF(lll, struct ll_scan_aux_chain, lll); in ull_scan_aux_lll_is_valid_get()
2255 chain = scan_aux_chain_is_valid_get(chain); in ull_scan_aux_lll_is_valid_get()
2256 if (chain) { in ull_scan_aux_lll_is_valid_get()
2257 return &chain->lll; in ull_scan_aux_lll_is_valid_get()
2310 struct ll_scan_aux_chain *chain; in ull_scan_aux_release() local
2315 chain = CONTAINER_OF(lll_aux, struct ll_scan_aux_chain, lll); in ull_scan_aux_release()
2316 lll = chain->parent; in ull_scan_aux_release()
2333 LL_ASSERT(chain->parent); in ull_scan_aux_release()
2336 chain_remove_from_list(&scan_aux_set.active_chains, chain); in ull_scan_aux_release()
2337 flush(chain); in ull_scan_aux_release()
2392 struct ll_scan_aux_chain *chain = curr; in scan_aux_stop_all_chains_for_parent() local
2403 if (chain->is_lll_sched || ull_ref_get(&scan_aux_set.ull) == 0) { in scan_aux_stop_all_chains_for_parent()
2405 flush(chain); in scan_aux_stop_all_chains_for_parent()
2408 chain->next = scan_aux_set.flushing_chains; in scan_aux_stop_all_chains_for_parent()
2409 scan_aux_set.flushing_chains = chain; in scan_aux_stop_all_chains_for_parent()
2468 static inline void aux_chain_release(struct ll_scan_aux_chain *chain) in aux_chain_release() argument
2473 LL_ASSERT(chain->parent); in aux_chain_release()
2474 chain->parent = NULL; in aux_chain_release()
2476 mem_release(chain, &scan_aux_free); in aux_chain_release()
2497 struct ll_scan_aux_chain *chain; in flush_safe() local
2499 chain = param; in flush_safe()
2500 LL_ASSERT(chain->parent); in flush_safe()
2502 if (chain_is_in_list(scan_aux_set.flushing_chains, chain)) { in flush_safe()
2508 if (chain_is_in_list(scan_aux_set.active_chains, chain) && in flush_safe()
2511 chain->next = scan_aux_set.flushing_chains; in flush_safe()
2512 scan_aux_set.flushing_chains = chain; in flush_safe()
2515 flush(chain); in flush_safe()
2519 static void flush(struct ll_scan_aux_chain *chain) in flush() argument
2529 LL_ASSERT(chain->parent); in flush()
2532 chain_remove_from_list(&scan_aux_set.flushing_chains, chain); in flush()
2534 lll = chain->parent; in flush()
2539 if (!scan && chain->aux_sched) { in flush()
2541 aux_sync_incomplete(chain); in flush()
2545 rx = chain->rx_head; in flush()
2547 chain->rx_head = NULL; in flush()
2572 if (lll->lll_aux == &chain->lll) { in flush()
2576 lll->scan_aux_score = chain->lll.hdr.score; in flush()
2582 sync_lll = chain->parent; in flush()
2589 aux_chain_release(chain); in flush()
2593 static void aux_sync_incomplete(struct ll_scan_aux_chain *chain) in aux_sync_incomplete() argument
2599 LL_ASSERT(chain->parent); in aux_sync_incomplete()
2602 lll = chain->parent; in aux_sync_incomplete()
2625 chain->rx_head = rx; in aux_sync_incomplete()
2629 static void chain_start_ticker(struct ll_scan_aux_chain *chain, bool replace) in chain_start_ticker() argument
2640 if (ull_scan_is_valid_get(HDR_LLL2ULL(chain->parent))) { in chain_start_ticker()
2641 if (chain->rx_head == chain->rx_last) { in chain_start_ticker()
2642 struct ll_scan_set *scan = HDR_LLL2ULL(chain->parent); in chain_start_ticker()
2652 struct ll_sync_set *ull_sync = HDR_LLL2ULL(chain->parent); in chain_start_ticker()
2660 ready_delay_us = lll_radio_rx_ready_delay_get(chain->lll.phy, PHY_FLAGS_S8); in chain_start_ticker()
2670 PDU_AC_MAX_US(PDU_AC_EXT_PAYLOAD_RX_SIZE, chain->lll.phy) + in chain_start_ticker()
2697 (chain->ticker_ticks - in chain_start_ticker()
2715 chain->ticker_ticks - ticks_slot_offset, in chain_start_ticker()
2722 ticker_cb, chain, ticker_op_cb, chain); in chain_start_ticker()
2747 struct ll_scan_aux_chain *chain = param; in ticker_cb() local
2759 LL_ASSERT(scan_aux_set.sched_chains == chain); in ticker_cb()
2762 chain_remove_from_list(&scan_aux_set.sched_chains, chain); in ticker_cb()
2763 chain_append_to_list(&scan_aux_set.active_chains, chain); in ticker_cb()
2770 p.param = &chain->lll; in ticker_cb()
2789 struct ll_scan_aux_chain *chain; in ticker_start_failed() local
2792 chain = param; in ticker_start_failed()
2793 chain_remove_from_list(&scan_aux_set.sched_chains, chain); in ticker_start_failed()
2795 flush(chain); in ticker_start_failed()
2838 static bool chain_insert_in_sched_list(struct ll_scan_aux_chain *chain) in chain_insert_in_sched_list() argument
2845 chain->next = NULL; in chain_insert_in_sched_list()
2846 scan_aux_set.sched_chains = chain; in chain_insert_in_sched_list()
2847 chain_start_ticker(chain, false); in chain_insert_in_sched_list()
2852 while (curr && chain_ticker_ticks_diff(chain->ticker_ticks, curr->ticker_ticks) > 0) { in chain_insert_in_sched_list()
2860 ticker_ticks_diff_get(chain->ticker_ticks, prev->ticker_ticks) < ticks_min_delta) || in chain_insert_in_sched_list()
2862 ticker_ticks_diff_get(curr->ticker_ticks, chain->ticker_ticks) < ticks_min_delta)) { in chain_insert_in_sched_list()
2867 chain->next = prev->next; in chain_insert_in_sched_list()
2868 prev->next = chain; in chain_insert_in_sched_list()
2870 chain->next = scan_aux_set.sched_chains; in chain_insert_in_sched_list()
2871 scan_aux_set.sched_chains = chain; in chain_insert_in_sched_list()
2872 chain_start_ticker(chain, true); in chain_insert_in_sched_list()
2878 static void chain_remove_from_list(struct ll_scan_aux_chain **head, struct ll_scan_aux_chain *chain) in chain_remove_from_list() argument
2883 while (curr && curr != chain) { in chain_remove_from_list()
2896 chain->next = NULL; in chain_remove_from_list()
2899 static void chain_append_to_list(struct ll_scan_aux_chain **head, struct ll_scan_aux_chain *chain) in chain_append_to_list() argument
2904 chain->next = NULL; in chain_append_to_list()
2905 *head = chain; in chain_append_to_list()
2913 prev->next = chain; in chain_append_to_list()
2916 static bool chain_is_in_list(struct ll_scan_aux_chain *head, struct ll_scan_aux_chain *chain) in chain_is_in_list() argument
2919 if (head == chain) { in chain_is_in_list()