1 /*
2  * Copyright (c) 2018-2019 Nordic Semiconductor ASA
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 struct ll_scan_set {
8 	struct ull_hdr  ull;
9 	struct lll_scan lll;
10 
11 	uint32_t ticks_window;
12 
13 #if defined(CONFIG_BT_CTLR_ADV_EXT)
14 	struct node_rx_pdu *node_rx_scan_term;
15 	uint16_t duration_lazy;
16 
17 	uint8_t is_stop:1;
18 #endif /* CONFIG_BT_CTLR_ADV_EXT */
19 
20 	uint8_t is_enabled:1;
21 	uint8_t own_addr_type:2;
22 
23 #if defined(CONFIG_BT_CTLR_SYNC_PERIODIC)
24 	struct {
25 		uint8_t filter_policy:1;
26 		uint8_t cancelled:1;
27 		uint8_t state:2;
28 
29 		/* Non-Null when creating sync, reset in ISR context on
30 		 * synchronisation state and checked in Thread context when
31 		 * cancelling sync create, hence the volatile keyword.
32 		 */
33 		struct ll_sync_set *volatile sync;
34 
35 		/* Non-NULL when Periodic Advertising Synchronisation address
36 		 * matched.
37 		 */
38 		void *param;
39 	} periodic;
40 #endif
41 };
42 
43 struct ll_scan_aux_chain {
44 	struct lll_scan_aux lll;
45 
46 	/* lll_scan or lll_sync */
47 	void *volatile parent;
48 
49 	/* Current nodes in this chain */
50 	/* TODO - do we need both head and tail? */
51 	struct node_rx_pdu *rx_head;
52 	struct node_rx_pdu *rx_last;
53 
54 	/* current ticker timeout for this chain */
55 	uint32_t ticker_ticks;
56 
57 	/* Next chain in list (if any) */
58 	struct ll_scan_aux_chain *next;
59 
60 	/* Current total advertising data */
61 	uint16_t data_len;
62 
63 	/* This chain is LLL scheduled */
64 	uint8_t is_lll_sched:1;
65 	/* Last emitted node_rx's aux_sched (only used in sync contexts) */
66 	uint8_t aux_sched:1;
67 };
68 
69 struct ll_scan_aux_set {
70 	struct ull_hdr      ull;
71 
72 #if defined(CONFIG_BT_CTLR_SCAN_AUX_USE_CHAINS)
73 	struct ll_scan_aux_chain *sched_chains;
74 	struct ll_scan_aux_chain *active_chains;
75 	struct ll_scan_aux_chain *flushing_chains;
76 #else /* !CONFIG_BT_CTLR_SCAN_AUX_USE_CHAINS */
77 	struct lll_scan_aux lll;
78 
79 	/* lll_scan or lll_sync */
80 	void *volatile parent;
81 
82 	struct node_rx_pdu *rx_head;
83 	struct node_rx_pdu *rx_last;
84 
85 	uint16_t data_len;
86 
87 #if defined(CONFIG_BT_CTLR_SYNC_PERIODIC)
88 	struct node_rx_pdu *rx_incomplete;
89 #endif
90 #endif /* !CONFIG_BT_CTLR_SCAN_AUX_USE_CHAINS */
91 };
92