1 /* 2 * Copyright (c) 2020 Nordic Semiconductor ASA 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 /* Periodic advertisements synchronization status. */ 8 enum sync_status { 9 SYNC_STAT_ALLOWED, 10 SYNC_STAT_READY, 11 SYNC_STAT_CONT_SCAN, 12 SYNC_STAT_TERM 13 }; 14 15 struct lll_sync { 16 struct lll_hdr hdr; 17 18 uint8_t access_addr[4]; 19 uint8_t crc_init[3]; 20 21 uint8_t phy:3; 22 /* Bitmask providing not allowed types of CTE. */ 23 uint8_t cte_type:5; 24 /* The member is required for filtering by CTE type. If filtering policy is disabled then 25 * synchronization is terminated for periodic advertisements with wrong CTE type. 26 */ 27 uint8_t filter_policy:1; 28 uint8_t is_rx_enabled:1; 29 uint8_t is_aux_sched:1; 30 uint8_t forced:1; 31 32 #if defined(CONFIG_BT_CTLR_SYNC_ISO) || \ 33 defined(CONFIG_BT_CTLR_SYNC_TRANSFER_RECEIVER) || \ 34 defined(CONFIG_BT_CTLR_SYNC_TRANSFER_SENDER) 35 uint8_t sca:3; 36 #endif /* CONFIG_BT_CTLR_SYNC_ISO || CONFIG_BT_CTLR_SYNC_TRANSFER_RECEIVER/SENDER */ 37 38 #if defined(CONFIG_BT_CTLR_SCAN_AUX_SYNC_RESERVE_MIN) 39 /* Counter used by LLL abort of event when in unreserved time space to 40 * provide near fair scheduling of overlapping multiple Periodic 41 * Sync sets. 42 */ 43 uint8_t abort_count; 44 #endif /* CONFIG_BT_CTLR_SCAN_AUX_SYNC_RESERVE_MIN */ 45 46 uint16_t skip_prepare; 47 uint16_t lazy_prepare; 48 uint16_t skip_event; 49 uint16_t event_counter; 50 51 uint16_t data_chan_id; 52 struct { 53 uint8_t data_chan_map[PDU_CHANNEL_MAP_SIZE]; 54 uint8_t data_chan_count:6; 55 } chm[DOUBLE_BUFFER_SIZE]; 56 uint8_t chm_first; 57 uint8_t chm_last; 58 uint16_t chm_instant; 59 60 uint32_t window_widening_periodic_us; 61 uint32_t window_widening_max_us; 62 uint32_t window_widening_prepare_us; 63 uint32_t window_widening_event_us; 64 uint32_t window_size_event_us; 65 66 /* used to store lll_aux when chain is being scanned */ 67 struct lll_scan_aux *volatile lll_aux; 68 69 #if defined(CONFIG_BT_CTLR_DF_SCAN_CTE_RX) 70 struct lll_df_sync df_cfg; 71 /* Member stores one additional IQ report rx node for notification of insufficient 72 * resources to sample all CTEs in currently pending synchronization event. 73 * The member is temporary storage used between prepare of an event and IQ data report 74 * generation. 75 */ 76 struct node_rx_iq_report *node_cte_incomplete; 77 /* Member stores information if there were insufficient IQ report rx nodes for all CTEs 78 * in pending synchronization event. 79 */ 80 bool is_cte_incomplete; 81 #endif /* CONFIG_BT_CTLR_DF_SCAN_CTE_RX */ 82 }; 83 84 int lll_sync_init(void); 85 int lll_sync_reset(void); 86 void lll_sync_create_prepare(void *param); 87 void lll_sync_prepare(void *param); 88 enum sync_status lll_sync_cte_is_allowed(uint8_t cte_type_mask, uint8_t filter_policy, 89 uint8_t rx_cte_time, uint8_t rx_cte_type); 90 extern uint16_t ull_sync_lll_handle_get(struct lll_sync *lll); 91 extern struct lll_sync *ull_sync_lll_is_valid_get(struct lll_sync *lll); 92