Lines Matching +full:cs +full:- +full:interval
2 * Copyright (c) 2018-2021 Nordic Semiconductor ASA
4 * SPDX-License-Identifier: Apache-2.0
80 uint16_t interval, uint16_t latency, uint16_t timeout, in ll_create_connection() argument
86 uint16_t interval, uint16_t latency, uint16_t timeout) in ll_create_connection()
134 lll = &scan->lll; in ll_create_connection()
135 lll_coded = &scan_coded->lll; in ll_create_connection()
144 if (!lll_coded->conn) { in ll_create_connection()
145 lll_coded->conn = lll->conn; in ll_create_connection()
150 if (!lll->conn) { in ll_create_connection()
151 lll->conn = lll_coded->conn; in ll_create_connection()
160 lll = &scan->lll; in ll_create_connection()
164 /* NOTE: non-zero PHY value enables initiating connection on that PHY */ in ll_create_connection()
165 lll->phy = phy; in ll_create_connection()
168 lll = &scan->lll; in ll_create_connection()
171 if (lll->conn) { in ll_create_connection()
172 conn_lll = lll->conn; in ll_create_connection()
190 conn_lll = &conn->lll; in ll_create_connection()
192 err = util_aa_le32(conn_lll->access_addr); in ll_create_connection()
195 lll_csrand_get(conn_lll->crc_init, sizeof(conn_lll->crc_init)); in ll_create_connection()
197 conn_lll->handle = 0xFFFF; in ll_create_connection()
198 conn_lll->interval = interval; in ll_create_connection()
199 conn_lll->latency = latency; in ll_create_connection()
201 if (!conn_lll->link_tx_free) { in ll_create_connection()
202 conn_lll->link_tx_free = &conn_lll->link_tx; in ll_create_connection()
205 memq_init(conn_lll->link_tx_free, &conn_lll->memq_tx.head, in ll_create_connection()
206 &conn_lll->memq_tx.tail); in ll_create_connection()
207 conn_lll->link_tx_free = NULL; in ll_create_connection()
209 conn_lll->packet_tx_head_len = 0; in ll_create_connection()
210 conn_lll->packet_tx_head_offset = 0; in ll_create_connection()
212 conn_lll->sn = 0; in ll_create_connection()
213 conn_lll->nesn = 0; in ll_create_connection()
214 conn_lll->empty = 0; in ll_create_connection()
221 conn_lll->phy_tx = PHY_1M; in ll_create_connection()
222 conn_lll->phy_tx_time = PHY_1M; in ll_create_connection()
223 conn_lll->phy_flags = PHY_FLAGS_S8; in ll_create_connection()
224 conn_lll->phy_rx = PHY_1M; in ll_create_connection()
232 conn_lll->rssi_latest = BT_HCI_LE_RSSI_NOT_AVAILABLE; in ll_create_connection()
234 conn_lll->rssi_reported = BT_HCI_LE_RSSI_NOT_AVAILABLE; in ll_create_connection()
235 conn_lll->rssi_sample_count = 0; in ll_create_connection()
240 conn_lll->tx_pwr_lvl = RADIO_TXP_DEFAULT; in ll_create_connection()
244 conn_lll->latency_prepare = 0; in ll_create_connection()
245 conn_lll->latency_event = 0; in ll_create_connection()
246 conn_lll->event_counter = 0; in ll_create_connection()
248 conn_lll->data_chan_count = ull_chan_map_get(conn_lll->data_chan_map); in ll_create_connection()
250 conn_lll->data_chan_hop = 5 + (hop % 12); in ll_create_connection()
251 conn_lll->data_chan_sel = 0; in ll_create_connection()
252 conn_lll->data_chan_use = 0; in ll_create_connection()
253 conn_lll->role = 0; in ll_create_connection()
254 conn_lll->central.initiated = 0; in ll_create_connection()
255 conn_lll->central.cancelled = 0; in ll_create_connection()
256 conn_lll->central.forced = 0; in ll_create_connection()
259 memset(&conn_lll->conn_meta, 0, sizeof(conn_lll->conn_meta)); in ll_create_connection()
263 conn_lll->df_rx_cfg.is_initialized = 0U; in ll_create_connection()
264 conn_lll->df_rx_cfg.hdr.elem_size = sizeof(struct lll_df_conn_rx_params); in ll_create_connection()
267 conn_lll->df_tx_cfg.is_initialized = 0U; in ll_create_connection()
268 conn_lll->df_tx_cfg.cte_rsp_en = 0U; in ll_create_connection()
271 conn->connect_expire = CONN_ESTAB_COUNTDOWN; in ll_create_connection()
272 conn->supervision_expire = 0U; in ll_create_connection()
273 conn_interval_us = (uint32_t)interval * CONN_INT_UNIT_US; in ll_create_connection()
274 conn->supervision_timeout = timeout; in ll_create_connection()
277 conn->apto_expire = 0U; in ll_create_connection()
279 conn->apto_reload = RADIO_CONN_EVENTS((30000000), conn_interval_us); in ll_create_connection()
280 conn->appto_expire = 0U; in ll_create_connection()
285 conn->appto_reload = (conn->apto_reload > (conn_lll->latency + 6)) ? in ll_create_connection()
286 (conn->apto_reload - (conn_lll->latency + 6)) : in ll_create_connection()
287 conn->apto_reload; in ll_create_connection()
290 /* Re-initialize the control procedure data structures */ in ll_create_connection()
296 conn->llcp_terminate.reason_final = 0U; in ll_create_connection()
300 conn->llcp_terminate.node_rx.rx.hdr.link = link; in ll_create_connection()
303 conn->phy_pref_tx = ull_conn_default_phy_tx_get(); in ll_create_connection()
304 conn->phy_pref_rx = ull_conn_default_phy_rx_get(); in ll_create_connection()
308 conn->pause_rx_data = 0U; in ll_create_connection()
311 /* Re-initialize the Tx Q */ in ll_create_connection()
312 ull_tx_q_init(&conn->tx_q); in ll_create_connection()
314 conn_lll->tifs_tx_us = EVENT_IFS_DEFAULT_US; in ll_create_connection()
315 conn_lll->tifs_rx_us = EVENT_IFS_DEFAULT_US; in ll_create_connection()
316 conn_lll->tifs_hcto_us = EVENT_IFS_DEFAULT_US; in ll_create_connection()
317 conn_lll->tifs_cis_us = EVENT_IFS_DEFAULT_US; in ll_create_connection()
320 conn->ull.ticks_active_to_start = 0U; in ll_create_connection()
321 conn->ull.ticks_prepare_to_start = in ll_create_connection()
323 conn->ull.ticks_preempt_to_start = in ll_create_connection()
328 conn->peer_id_addr_type = peer_addr_type; in ll_create_connection()
329 (void)memcpy(conn->peer_id_addr, peer_addr, sizeof(conn->peer_id_addr)); in ll_create_connection()
330 conn->own_id_addr_type = own_id_addr_type; in ll_create_connection()
331 (void)memcpy(conn->own_id_addr, own_id_addr, sizeof(conn->own_id_addr)); in ll_create_connection()
334 lll->conn = conn_lll; in ll_create_connection()
336 ull_hdr_init(&conn->ull); in ll_create_connection()
337 lll_hdr_init(&conn->lll, conn); in ll_create_connection()
341 ready_delay_us = lll_radio_tx_ready_delay_get(conn_lll->phy_tx, in ll_create_connection()
342 conn_lll->phy_flags); in ll_create_connection()
349 conn_lll->dle.eff.max_tx_time = MAX(conn_lll->dle.eff.max_tx_time, in ll_create_connection()
351 lll->phy)); in ll_create_connection()
352 conn_lll->dle.eff.max_rx_time = MAX(conn_lll->dle.eff.max_rx_time, in ll_create_connection()
354 lll->phy)); in ll_create_connection()
356 max_tx_time = conn_lll->dle.eff.max_tx_time; in ll_create_connection()
357 max_rx_time = conn_lll->dle.eff.max_rx_time; in ll_create_connection()
363 PDU_DC_MAX_US(PDU_DC_PAYLOAD_SIZE_MIN, lll->phy)); in ll_create_connection()
365 PDU_DC_MAX_US(PDU_DC_PAYLOAD_SIZE_MIN, lll->phy)); in ll_create_connection()
371 slot_us += conn_lll->tifs_rx_us + (EVENT_CLOCK_JITTER_US << 1); in ll_create_connection()
375 conn->ull.ticks_slot = HAL_TICKER_US_TO_TICKS_CEIL(slot_us); in ll_create_connection()
380 lll->rl_idx = FILTER_IDX_NONE; in ll_create_connection()
381 lll->rpa_gen = 0; in ll_create_connection()
384 lll->rl_idx = ull_filter_rl_find(peer_addr_type, peer_addr, in ll_create_connection()
394 lll->rpa_gen = 1; in ll_create_connection()
398 scan->own_addr_type = own_addr_type; in ll_create_connection()
399 lll->adv_addr_type = peer_addr_type; in ll_create_connection()
400 memcpy(lll->adv_addr, peer_addr, BDADDR_SIZE); in ll_create_connection()
401 lll->conn_timeout = timeout; in ll_create_connection()
403 scan->ticks_window = ull_scan_params_set(lll, 0U, scan_interval, in ll_create_connection()
438 (scan->lll.phy & PHY_1M)) { in ll_connect_enable()
479 scan_lll = &scan_coded->lll; in ll_connect_disable()
481 scan_lll = &scan->lll; in ll_connect_disable()
485 conn_lll = scan_lll->conn; in ll_connect_disable()
495 conn_lll->central.cancelled = 1U; in ll_connect_disable()
501 conn_lll = scan_lll->conn; in ll_connect_disable()
526 node_rx = (void *)&conn->llcp_terminate.node_rx.rx; in ll_connect_disable()
527 link = node_rx->hdr.link; in ll_connect_disable()
533 node_rx->hdr.type = NODE_RX_TYPE_CONNECTION; in ll_connect_disable()
534 node_rx->hdr.handle = 0xffff; in ll_connect_disable()
539 cc = (void *)node_rx->pdu; in ll_connect_disable()
540 cc->status = BT_HCI_ERR_UNKNOWN_CONN_ID; in ll_connect_disable()
546 node_rx->rx_ftr.param = scan_lll; in ll_connect_disable()
573 if (!conn->lll.enc_tx && !conn->lll.enc_rx) { in ll_enc_req_send()
576 } else if (conn->lll.enc_tx && conn->lll.enc_rx) { in ll_enc_req_send()
604 scan->is_enabled = 0U; in ull_central_reset()
605 scan->lll.conn = NULL; in ull_central_reset()
614 scan->is_enabled = 0U; in ull_central_reset()
615 scan->lll.conn = NULL; in ull_central_reset()
635 scan = HDR_LLL2ULL(rx_free->rx_ftr.param); in ull_central_cleanup()
636 conn_lll = scan->lll.conn; in ull_central_cleanup()
638 scan->lll.conn = NULL; in ull_central_cleanup()
640 LL_ASSERT(!conn_lll->link_tx_free); in ull_central_cleanup()
641 link = memq_deinit(&conn_lll->memq_tx.head, in ull_central_cleanup()
642 &conn_lll->memq_tx.tail); in ull_central_cleanup()
644 conn_lll->link_tx_free = link; in ull_central_cleanup()
652 scan->is_enabled = 0U; in ull_central_cleanup()
655 scan->lll.phy = 0U; in ull_central_cleanup()
663 conn_lll = scan_coded->lll.conn; in ull_central_cleanup()
665 scan_coded->lll.conn = NULL; in ull_central_cleanup()
667 scan_coded->is_enabled = 0U; in ull_central_cleanup()
668 scan_coded->lll.phy = 0U; in ull_central_cleanup()
692 /* Get reference to Tx-ed CONNECT_IND PDU */
693 pdu_tx = (void *)rx->pdu;
695 /* Backup peer addr and type, as we reuse the Tx-ed PDU to generate
698 peer_addr_type = pdu_tx->rx_addr;
699 memcpy(peer_addr, &pdu_tx->connect_ind.adv_addr[0], BDADDR_SIZE);
702 chan_sel = pdu_tx->chan_sel;
712 cc->status = 0U;
713 cc->role = 0U;
716 uint8_t rl_idx = ftr->rl_idx;
718 if (ftr->lrpa_used) {
719 memcpy(&cc->local_rpa[0], &pdu_tx->connect_ind.init_addr[0],
722 memset(&cc->local_rpa[0], 0x0, BDADDR_SIZE);
727 ll_rl_id_addr_get(rl_idx, &cc->peer_addr_type,
728 &cc->peer_addr[0]);
730 MARK_AS_IDENTITY_ADDR(cc->peer_addr_type);
733 memcpy(&cc->peer_rpa[0], &peer_addr[0], BDADDR_SIZE);
735 memset(&cc->peer_rpa[0], 0x0, BDADDR_SIZE);
739 cc->peer_addr_type = peer_addr_type;
740 memcpy(cc->peer_addr, &peer_addr[0], BDADDR_SIZE);
743 scan = HDR_LLL2ULL(ftr->param);
745 cc->interval = lll->interval;
746 cc->latency = lll->latency;
747 cc->timeout = scan->lll.conn_timeout;
748 cc->sca = lll_clock_sca_local_get();
750 conn = lll->hdr.parent;
751 lll->handle = ll_conn_handle_get(conn);
752 rx->hdr.handle = lll->handle;
754 /* Set LLCP as connection-wise connected */
759 conn->past = ull_conn_default_past_param_get();
763 lll->tx_pwr_lvl = RADIO_TXP_DEFAULT;
769 link = rx->hdr.link;
774 struct node_rx_cs *cs; local
779 rx_csa = (void *)ftr->extra;
786 link = rx->hdr.link;
788 rx->hdr.handle = lll->handle;
789 rx->hdr.type = NODE_RX_TYPE_CHAN_SEL_ALGO;
791 cs = (void *)rx_csa->pdu;
794 lll->data_chan_sel = 1;
795 lll->data_chan_id = lll_chan_id(lll->access_addr);
797 cs->csa = 0x01;
799 cs->csa = 0x00;
805 ticks_slot_offset = MAX(conn->ull.ticks_active_to_start,
806 conn->ull.ticks_prepare_to_start);
814 conn_interval_us = lll->interval * CONN_INT_UNIT_US;
815 conn_offset_us = ftr->radio_end_us;
818 conn_offset_us -= lll_radio_tx_ready_delay_get(lll->phy_tx,
819 lll->phy_flags);
821 conn_offset_us -= lll_radio_tx_ready_delay_get(0, 0);
834 ticks_at_stop = ftr->ticks_anchor +
835 HAL_TICKER_US_TO_TICKS(conn_offset_us) -
881 ftr->ticks_anchor - ticks_slot_offset,
887 (conn->ull.ticks_slot + ticks_slot_overhead),
918 if (unlikely(conn->lll.handle == 0xFFFF)) {
924 conn->common.is_must_expire = (lazy == TICKER_LAZY_MUST_EXPIRE);
926 /* If this is a must-expire callback, LLCP state machine does not need
938 * active radio event which will re-enable
953 ref = ull_ref_inc(&conn->ull);
956 /* De-mux 2 tx node from FIFO, sufficient to be able to set MD bit */
967 p.param = &conn->lll;
975 /* De-mux remaining tx nodes from FIFO */
989 while (handle--) {
995 if (!conn || conn->lll.role) {
1030 /* NOTE: We are in ULL_LOW which can be pre-empted by ULL_HIGH.
1037 hdr = &scan->ull;
1038 mfy.param = &scan->lll;
1064 lll = scan->lll.conn;
1065 LL_ASSERT(!lll->link_tx_free);
1066 link = memq_deinit(&lll->memq_tx.head, &lll->memq_tx.tail);
1068 lll->link_tx_free = link;
1072 cc = (void *)&conn->llcp_terminate.node_rx.rx;
1073 link = cc->hdr.link;
1079 scan->lll.conn = NULL;