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 	} periodic;
35 #endif
36 };
37 
38 struct ll_scan_aux_chain {
39 	struct lll_scan_aux lll;
40 
41 	/* lll_scan or lll_sync */
42 	void *volatile parent;
43 
44 	/* Current nodes in this chain */
45 	/* TODO - do we need both head and tail? */
46 	struct node_rx_pdu *rx_head;
47 	struct node_rx_pdu *rx_last;
48 
49 	/* current ticker timeout for this chain */
50 	uint32_t ticker_ticks;
51 
52 	/* Next chain in list (if any) */
53 	struct ll_scan_aux_chain *next;
54 
55 	/* Current total advertising data */
56 	uint16_t data_len;
57 
58 	/* This chain is LLL scheduled */
59 	uint8_t is_lll_sched:1;
60 	/* Last emitted node_rx's aux_sched (only used in sync contexts) */
61 	uint8_t aux_sched:1;
62 };
63 
64 struct ll_scan_aux_set {
65 	struct ull_hdr      ull;
66 
67 #if defined(CONFIG_BT_CTLR_SCAN_AUX_USE_CHAINS)
68 	struct ll_scan_aux_chain *sched_chains;
69 	struct ll_scan_aux_chain *active_chains;
70 	struct ll_scan_aux_chain *flushing_chains;
71 #else /* !CONFIG_BT_CTLR_SCAN_AUX_USE_CHAINS */
72 	struct lll_scan_aux lll;
73 
74 	/* lll_scan or lll_sync */
75 	void *volatile parent;
76 
77 	struct node_rx_pdu *rx_head;
78 	struct node_rx_pdu *rx_last;
79 
80 	uint16_t data_len;
81 
82 #if defined(CONFIG_BT_CTLR_SYNC_PERIODIC)
83 	struct node_rx_pdu *rx_incomplete;
84 #endif
85 #endif /* !CONFIG_BT_CTLR_SCAN_AUX_USE_CHAINS */
86 };
87