Lines Matching refs:adv

71 inline uint16_t ull_adv_handle_get(struct ll_adv_set *adv);
91 static void conn_release(struct ll_adv_set *adv);
96 static void adv_max_events_duration_set(struct ll_adv_set *adv,
109 static uint8_t adv_scan_pdu_addr_update(struct ll_adv_set *adv,
112 static const uint8_t *adva_update(struct ll_adv_set *adv, struct pdu_adv *pdu);
113 static void tgta_update(struct ll_adv_set *adv, struct pdu_adv *pdu);
116 static void init_set(struct ll_adv_set *adv);
136 struct ll_adv_set *adv = &ll_adv[0]; in ll_adv_cmds_set() local
139 adv->hci_handle = 0; in ll_adv_cmds_set()
141 adv->is_created = 1; in ll_adv_cmds_set()
161 struct ll_adv_set *adv; in ll_adv_set_by_hci_handle_get() local
164 adv = &ll_adv[0]; in ll_adv_set_by_hci_handle_get()
166 for (idx = 0U; idx < BT_CTLR_ADV_SET; idx++, adv++) { in ll_adv_set_by_hci_handle_get()
167 if (adv->is_created && (adv->hci_handle == hci_handle)) { in ll_adv_set_by_hci_handle_get()
178 struct ll_adv_set *adv, *adv_empty; in ll_adv_set_by_hci_handle_get_or_new() local
181 adv = &ll_adv[0]; in ll_adv_set_by_hci_handle_get_or_new()
184 for (idx = 0U; idx < BT_CTLR_ADV_SET; idx++, adv++) { in ll_adv_set_by_hci_handle_get_or_new()
185 if (adv->is_created) { in ll_adv_set_by_hci_handle_get_or_new()
186 if (adv->hci_handle == hci_handle) { in ll_adv_set_by_hci_handle_get_or_new()
191 adv_empty = adv; in ll_adv_set_by_hci_handle_get_or_new()
206 struct ll_adv_set *adv; in ll_adv_set_hci_handle_get() local
208 adv = ull_adv_set_get(handle); in ll_adv_set_hci_handle_get()
209 LL_ASSERT(adv && adv->is_created); in ll_adv_set_hci_handle_get()
211 return adv->hci_handle; in ll_adv_set_hci_handle_get()
245 struct ll_adv_set *adv; local
249 adv = is_disabled_get(handle);
250 if (!adv) {
271 if (adv->lll.sync) {
274 sync = HDR_LLL2ULL(adv->lll.sync);
283 adv->lll.phy_p = PHY_1M;
297 if (adv->lll.sync &&
303 sync = HDR_LLL2ULL(adv->lll.sync);
332 adv->lll.phy_p = phy_p;
333 adv->lll.phy_flags = PHY_FLAGS_S8;
336 adv->lll.phy_p = PHY_1M;
339 is_new_set = !adv->is_created;
340 adv->is_created = 1;
341 adv->is_ad_data_cmplt = 1U;
342 adv->max_skip = skip;
351 adv->interval = interval;
353 adv->interval = 0;
355 adv->lll.chan_map = chan_map;
356 adv->lll.filter_policy = filter_policy;
359 adv->lll.scan_req_notify = sreq;
363 pdu = lll_adv_data_peek(&adv->lll);
381 struct lll_adv_aux *lll_aux = adv->lll.aux;
392 if (adv->lll.sync) {
395 sync = HDR_LLL2ULL(adv->lll.sync);
396 adv->lll.sync = NULL;
404 adv->lll.aux = NULL;
443 adv->ad_data_backup.len = 0U;
448 adv->ad_data_backup.len = pdu->len -
450 memcpy(adv->ad_data_backup.data, pdu->adv_ind.data,
451 adv->ad_data_backup.len);
457 adv->own_addr_type = own_addr_type;
458 if (adv->own_addr_type == BT_HCI_OWN_ADDR_RPA_OR_PUBLIC ||
459 adv->own_addr_type == BT_HCI_OWN_ADDR_RPA_OR_RANDOM) {
460 adv->peer_addr_type = direct_addr_type;
461 memcpy(&adv->peer_addr, direct_addr, BDADDR_SIZE);
610 adv->lll.phy_s = phy_s;
619 adv->lll.phy_s);
639 adv->sid = sid;
661 err = ull_adv_aux_hdr_set_clear(adv,
670 lll_adv_aux_data_enqueue(adv->lll.aux, sec_idx);
671 lll_adv_data_enqueue(&adv->lll, pri_idx);
691 memcpy(pdu->adv_ind.data, adv->ad_data_backup.data,
692 adv->ad_data_backup.len);
694 adv->ad_data_backup.len;
705 lll_hdr_init(&adv->lll, adv);
717 (void)lll_adv_data_release(&adv->lll.scan_rsp);
718 lll_adv_data_reset(&adv->lll.scan_rsp);
719 err = lll_adv_aux_data_init(&adv->lll.scan_rsp);
724 pdu = lll_adv_scan_rsp_peek(&adv->lll);
730 pdu = lll_adv_scan_rsp_peek(&adv->lll);
737 (void)lll_adv_data_release(&adv->lll.scan_rsp);
738 lll_adv_data_reset(&adv->lll.scan_rsp);
739 err = lll_adv_data_init(&adv->lll.scan_rsp);
744 pdu = lll_adv_scan_rsp_peek(&adv->lll);
772 struct ll_adv_set *adv; local
774 adv = ull_adv_set_get(handle);
775 if (!adv) {
779 return ull_adv_data_set(adv, len, data);
791 struct ll_adv_set *adv; local
793 adv = ull_adv_set_get(handle);
794 if (!adv) {
798 return ull_scan_rsp_set(adv, len, data);
830 struct ll_adv_set *adv; local
839 adv = is_disabled_get(handle);
840 if (!adv) {
861 adv = ull_adv_is_enabled_get(handle);
862 if (!adv) {
872 lll = &adv->lll;
875 hci_err = adv_scan_pdu_addr_update(adv,
882 if (!adv->lll.node_rx_adv_term) {
892 type = &adv->lll.node_rx_adv_term->hdr.type;
897 adv_max_events_duration_set(adv,
922 lll = &adv->lll;
930 if (adv->own_addr_type == BT_HCI_OWN_ADDR_RPA_OR_PUBLIC ||
931 adv->own_addr_type == BT_HCI_OWN_ADDR_RPA_OR_RANDOM) {
933 lll->rl_idx = ull_filter_rl_find(adv->peer_addr_type,
934 adv->peer_addr, NULL);
955 err = lll_adv_data_init(&adv->lll.scan_rsp);
968 hci_err = adv_scan_pdu_addr_update(adv, pdu_adv, pdu_scan);
1150 adv->link_cc_free = link;
1151 adv->node_rx_cc_free = node_rx;
1160 conn_release(adv);
1176 if (adv->lll.conn) {
1177 conn_release(adv);
1188 if (adv->lll.conn) {
1189 conn_release(adv);
1202 adv->lll.node_rx_adv_term = (void *)node_rx_adv_term;
1207 adv_max_events_duration_set(adv, 0U, 0U);
1210 adv_max_events_duration_set(adv, duration,
1214 adv->lll.node_rx_adv_term = NULL;
1215 adv_max_events_duration_set(adv, 0U, 0U);
1221 adv->event_counter = 0U;
1241 uint16_t interval = adv->interval;
1276 ull_hdr_init(&adv->ull);
1279 adv->ull.ticks_active_to_start = 0;
1280 adv->ull.ticks_prepare_to_start =
1282 adv->ull.ticks_preempt_to_start =
1284 adv->ull.ticks_slot = HAL_TICKER_US_TO_TICKS_CEIL(time_us);
1286 ticks_slot_offset = MAX(adv->ull.ticks_active_to_start,
1287 adv->ull.ticks_prepare_to_start);
1329 (adv->ull.ticks_slot + ticks_slot_overhead),
1331 (adv->ull.ticks_slot + ticks_slot_overhead),
1332 ticker_cb, adv,
1352 ticker_stop_cb, adv,
1357 const uint32_t ticks_slot = adv->ull.ticks_slot +
1371 err = ull_adv_aux_hdr_set_clear(adv,
1470 ticks_slot_overhead2 = ull_adv_sync_evt_init(adv, sync, NULL);
1471 ret = ull_adv_sync_start(adv, sync,
1480 lll_adv_aux_data_enqueue(adv->lll.aux, sec_idx);
1501 interval_us = (uint64_t)adv->interval * ADV_INT_UNIT_US;
1503 if (adv->max_skip == 0U) {
1513 aux->interval = (interval_us * (adv->max_skip + 1))
1567 ticker_cb, adv,
1593 adv->is_enabled = 1;
1625 if (adv->lll.conn) {
1626 conn_release(adv);
1720 struct ll_adv_set *adv = &ll_adv[handle]; local
1721 struct lll_adv *lll = &adv->lll;
1724 adv->is_created = 0;
1751 inline uint16_t ull_adv_handle_get(struct ll_adv_set *adv) argument
1753 return ((uint8_t *)adv - (uint8_t *)ll_adv) / sizeof(*adv);
1763 struct ll_adv_set *adv; local
1765 adv = ull_adv_set_get(handle);
1766 if (!adv || !adv->is_enabled) {
1770 return adv;
1775 struct ll_adv_set *adv; local
1777 adv = ull_adv_is_enabled_get(handle);
1779 return adv != NULL;
1784 struct ll_adv_set *adv; local
1786 adv = ull_adv_is_enabled_get(handle);
1787 if (!adv) {
1791 return adv->lll.filter_policy;
1797 struct ll_adv_set *adv; local
1799 adv = ull_adv_set_get(handle);
1800 if (!adv || !adv->is_created) {
1804 return adv;
1808 void ull_adv_aux_created(struct ll_adv_set *adv) argument
1810 if (adv->lll.aux && adv->is_enabled) {
1811 uint8_t aux_handle = ull_adv_aux_handle_get(HDR_LLL2ULL(adv->lll.aux));
1812 uint8_t handle = ull_adv_handle_get(adv);
1816 ticker_update_op_cb, adv, 0,
1823 uint8_t ull_adv_data_set(struct ll_adv_set *adv, uint8_t len, argument
1835 prev = lll_adv_data_peek(&adv->lll);
1843 adv->ad_data_backup.len = len;
1844 memcpy(adv->ad_data_backup.data, data, adv->ad_data_backup.len);
1853 pdu = lll_adv_data_alloc(&adv->lll, &idx);
1859 lll_adv_data_alloc(&adv->lll, &idx_test);
1879 if (adv->is_enabled) {
1884 lll = &adv->lll;
1887 err = ull_adv_time_update(adv, pdu, pdu_scan);
1893 lll_adv_data_enqueue(&adv->lll, idx);
1898 uint8_t ull_scan_rsp_set(struct ll_adv_set *adv, uint8_t len, argument
1910 prev = lll_adv_scan_rsp_peek(&adv->lll);
1914 err = lll_adv_data_init(&adv->lll.scan_rsp);
1919 prev = lll_adv_scan_rsp_peek(&adv->lll);
1923 pdu = lll_adv_scan_rsp_alloc(&adv->lll, &idx);
1934 if (adv->is_enabled) {
1939 lll = &adv->lll;
1944 err = ull_adv_time_update(adv, pdu_adv_scan, pdu);
1951 lll_adv_scan_rsp_enqueue(&adv->lll, idx);
1956 static uint32_t ticker_update_rand(struct ll_adv_set *adv, uint32_t ticks_delay_window, argument
1974 TICKER_ID_ADV_BASE + ull_adv_handle_get(adv),
1977 fp_op_func, adv);
1996 struct ll_adv_set *adv; local
2000 adv = CONTAINER_OF(done->param, struct ll_adv_set, ull);
2001 lll = &adv->lll;
2012 const uint32_t ticks_adv_airtime = adv->ticks_at_expire +
2022 if (adv->delay_at_expire + ticks_elapsed <= ULL_ADV_RANDOM_DELAY) {
2024 delay_remain = ULL_ADV_RANDOM_DELAY - (adv->delay_at_expire +
2032 uint32_t interval_us = adv->interval * ADV_INT_UNIT_US;
2041 ticks_adjust_minus = HAL_TICKER_US_TO_TICKS(interval_us) + adv->delay;
2044 if (adv->remain_duration_us > interval_us) {
2048 adv->remain_duration_us += interval_us +
2050 adv->delay_at_expire);
2059 random_delay = ticker_update_rand(adv, delay_remain - prepare_overhead,
2064 adv->delay = random_delay;
2065 adv->delay += adv->delay_at_expire;
2070 adv->lll.hdr.score -= 1;
2074 if (done->extra.type == EVENT_DONE_EXTRA_TYPE_ADV && adv->lll.aux) {
2082 if (adv->max_events && (adv->event_counter >= adv->max_events)) {
2083 adv->max_events = 0U;
2087 } else if (adv->remain_duration_us &&
2088 (adv->remain_duration_us <=
2089 ((uint64_t)adv->interval * ADV_INT_UNIT_US))) {
2090 adv->remain_duration_us = 0U;
2098 handle = ull_adv_handle_get(adv);
2104 rx->rx_ftr.param_adv_term.num_events = adv->event_counter;
2116 ticker_stop_aux_op_cb, adv);
2121 ticker_stop_ext_op_cb, adv);
2130 const uint8_t *ull_adv_pdu_update_addrs(struct ll_adv_set *adv, argument
2147 adv_addr = adva_update(adv, pdu);
2158 tgta_update(adv, pdu);
2164 uint8_t ull_adv_time_update(struct ll_adv_set *adv, struct pdu_adv *pdu, argument
2175 lll = &adv->lll;
2196 if (adv->ull.ticks_slot > time_ticks) {
2197 ticks_minus = adv->ull.ticks_slot - time_ticks;
2199 } else if (adv->ull.ticks_slot < time_ticks) {
2201 ticks_plus = time_ticks - adv->ull.ticks_slot;
2210 ull_adv_handle_get(adv)),
2219 adv->ull.ticks_slot = time_ticks;
2264 struct ll_adv_set *adv; local
2266 adv = ull_adv_set_get(handle);
2267 if (!adv || adv->is_enabled) {
2271 return adv;
2344 struct ll_adv_set *adv = context->context; local
2346 struct ll_adv_set *adv = param; local
2355 lll = &adv->lll;
2366 if ((adv->max_events && adv->event_counter >= adv->max_events) ||
2367 (adv->remain_duration_us &&
2368 adv->remain_duration_us <= (uint64_t)adv->interval * ADV_INT_UNIT_US)) {
2377 ref = ull_ref_inc(&adv->ull);
2382 if (adv->lll.aux) {
2394 adv->lll.aux->ticks_pri_pdu_offset = ticks_to_expire;
2395 adv->lll.aux->us_pri_pdu_offset = other_remainder;
2422 adv->ticks_at_expire = ticks_at_expire;
2425 adv->delay_at_expire = adv->delay;
2435 if (adv->lll.aux) {
2436 ull_adv_aux_offset_get(adv);
2454 random_delay = ticker_update_rand(adv, ULL_ADV_RANDOM_DELAY, 0U, 0U,
2457 adv->delay = random_delay;
2473 if (adv->remain_duration_us && adv->event_counter > 0U) {
2476 ticks_drift = adv->delay_at_expire;
2478 uint32_t interval_us = (uint64_t)adv->interval * ADV_INT_UNIT_US;
2483 if (adv->remain_duration_us > elapsed_us + interval_us +
2485 adv->remain_duration_us -= elapsed_us;
2487 adv->remain_duration_us = interval_us;
2491 adv->event_counter += event_counter_inc;
2504 struct ll_adv_set *adv = param; local
2505 struct pdu_adv *pdu = lll_adv_data_peek(&adv->lll);
2519 (connectable && !adv->lll.conn) ||
2529 struct ll_adv_set *adv = param; local
2533 handle = ull_adv_handle_get(adv);
2538 ticker_stop_op_cb, adv);
2572 struct ll_adv_set *adv; local
2576 adv = param;
2577 hdr = &adv->ull;
2583 mfy.param = &adv->lll;
2598 disabled_cb(&adv->lll);
2604 struct ll_adv_set *adv; local
2609 adv = ((struct lll_hdr *)param)->parent;
2611 LL_ASSERT(adv->link_cc_free);
2612 link = adv->link_cc_free;
2613 adv->link_cc_free = NULL;
2615 LL_ASSERT(adv->node_rx_cc_free);
2616 rx = adv->node_rx_cc_free;
2617 adv->node_rx_cc_free = NULL;
2629 if (adv->lll.node_rx_adv_term) {
2634 handle = ull_adv_handle_get(adv);
2637 rx = (void *)adv->lll.node_rx_adv_term;
2642 rx->rx_ftr.param_adv_term.num_events = adv->event_counter;
2651 static void conn_release(struct ll_adv_set *adv) argument
2653 struct lll_conn *lll = adv->lll.conn;
2662 adv->lll.conn = NULL;
2664 ll_rx_release(adv->node_rx_cc_free);
2665 adv->node_rx_cc_free = NULL;
2666 ll_rx_link_release(adv->link_cc_free);
2667 adv->link_cc_free = NULL;
2694 static void adv_max_events_duration_set(struct ll_adv_set *adv, argument
2698 adv->event_counter = 0;
2699 adv->max_events = max_ext_adv_evts;
2700 adv->remain_duration_us = (uint32_t)duration * 10U * USEC_PER_MSEC;
2722 struct ll_adv_set *adv; local
2725 adv = param;
2726 lll_aux = adv->lll.aux;
2731 hdr->disabled_param = adv;
2774 struct ll_adv_set *adv; local
2778 adv = param;
2779 hdr = &adv->ull;
2785 mfy.param = &adv->lll;
2800 ext_disabled_cb(&adv->lll);
2825 struct ll_adv_set *adv; local
2830 adv = ull_adv_is_enabled_get(handle);
2831 if (!adv) {
2844 if (adv->lll.conn) {
2846 adv->lll.conn->periph.cancelled = 1U;
2852 if (unlikely(adv->lll.conn->periph.initiated)) {
2858 mark = ull_disable_mark(adv);
2859 LL_ASSERT(mark == adv);
2862 if (adv->lll.is_hdcd) {
2869 mark = ull_disable_unmark(adv);
2870 LL_ASSERT(mark == adv);
2883 mark = ull_disable_unmark(adv);
2884 LL_ASSERT(mark == adv);
2889 err = ull_disable(&adv->lll);
2892 mark = ull_disable_unmark(adv);
2893 LL_ASSERT(mark == adv);
2896 struct lll_adv_aux *lll_aux = adv->lll.aux;
2911 if (adv->lll.conn) {
2912 conn_release(adv);
2917 struct lll_adv *lll = &adv->lll;
2930 adv->is_enabled = 0U;
2941 static uint8_t adv_scan_pdu_addr_update(struct ll_adv_set *adv, argument
2949 lll = &adv->lll;
3007 adv_addr = ull_adv_pdu_update_addrs(adv, pdu_adv_to_update);
3027 ull_adv_pdu_update_addrs(adv, pdu_scan);
3060 static const uint8_t *adva_update(struct ll_adv_set *adv, struct pdu_adv *pdu) argument
3063 const uint8_t *rpa = ull_filter_adva_get(adv->lll.rl_idx);
3075 own_id_addr = adv->rnd_addr;
3083 (void)memcpy(adv->own_id_addr, own_id_addr, BDADDR_SIZE);
3099 static void tgta_update(struct ll_adv_set *adv, struct pdu_adv *pdu) argument
3105 rx_addr = ull_filter_tgta_get(adv->lll.rl_idx);
3131 static void init_set(struct ll_adv_set *adv) argument
3133 adv->interval = BT_LE_ADV_INTERVAL_DEFAULT;
3135 adv->own_addr_type = BT_HCI_OWN_ADDR_RPA_OR_PUBLIC;
3137 adv->lll.chan_map = BT_LE_ADV_CHAN_MAP_ALL;
3138 adv->lll.filter_policy = BT_LE_ADV_FP_NO_FILTER;
3140 adv->delay = 0U;