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 31 #if defined(CONFIG_BT_CTLR_SYNC_ISO) 32 uint8_t sca:3; 33 #endif /* CONFIG_BT_CTLR_SYNC_ISO */ 34 35 #if defined(CONFIG_BT_CTLR_SCAN_AUX_SYNC_RESERVE_MIN) 36 /* Counter used by LLL abort of event when in unreserved time space to 37 * provide near fair scheduling of overlapping multiple Periodic 38 * Sync sets. 39 */ 40 uint8_t abort_count; 41 #endif /* CONFIG_BT_CTLR_SCAN_AUX_SYNC_RESERVE_MIN */ 42 43 uint16_t skip_prepare; 44 uint16_t skip_event; 45 uint16_t event_counter; 46 47 uint16_t data_chan_id; 48 struct { 49 uint8_t data_chan_map[PDU_CHANNEL_MAP_SIZE]; 50 uint8_t data_chan_count:6; 51 } chm[DOUBLE_BUFFER_SIZE]; 52 uint8_t chm_first; 53 uint8_t chm_last; 54 uint16_t chm_instant; 55 56 uint32_t window_widening_periodic_us; 57 uint32_t window_widening_max_us; 58 uint32_t window_widening_prepare_us; 59 uint32_t window_widening_event_us; 60 uint32_t window_size_event_us; 61 62 /* used to store lll_aux when chain is being scanned */ 63 struct lll_scan_aux *volatile lll_aux; 64 65 #if defined(CONFIG_BT_CTLR_DF_SCAN_CTE_RX) 66 struct lll_df_sync df_cfg; 67 /* Member stores one additional IQ report rx node for notification of insufficient 68 * resources to sample all CTEs in currently pending synchronization event. 69 * The member is temporary storage used between prepare of an event and IQ data report 70 * generation. 71 */ 72 struct node_rx_iq_report *node_cte_incomplete; 73 /* Member stores information if there were insufficient IQ report rx nodes for all CTEs 74 * in pending synchronization event. 75 */ 76 bool is_cte_incomplete; 77 #endif /* CONFIG_BT_CTLR_DF_SCAN_CTE_RX */ 78 }; 79 80 int lll_sync_init(void); 81 int lll_sync_reset(void); 82 void lll_sync_create_prepare(void *param); 83 void lll_sync_prepare(void *param); 84 enum sync_status lll_sync_cte_is_allowed(uint8_t cte_type_mask, uint8_t filter_policy, 85 uint8_t rx_cte_time, uint8_t rx_cte_type); 86 extern uint16_t ull_sync_lll_handle_get(struct lll_sync *lll); 87 extern struct lll_sync *ull_sync_lll_is_valid_get(struct lll_sync *lll); 88