1 /*
2  * Copyright (c) 2018-2019 Nordic Semiconductor ASA
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 struct lll_scan {
8 	struct lll_hdr hdr;
9 
10 #if defined(CONFIG_BT_CENTRAL)
11 	/* NOTE: conn context SHALL be after lll_hdr,
12 	 *       check ull_conn_setup how it access the connection LLL
13 	 *       context.
14 	 */
15 	struct lll_conn *volatile conn;
16 
17 	uint8_t  adv_addr[BDADDR_SIZE];
18 	uint32_t conn_win_offset_us;
19 	uint16_t conn_timeout;
20 #endif /* CONFIG_BT_CENTRAL */
21 
22 	uint8_t  state:1;
23 	uint8_t  chan:2;
24 	uint8_t  filter_policy:2;
25 	uint8_t  type:1;
26 	uint8_t  init_addr_type:1;
27 	uint8_t  is_stop:1;
28 
29 #if defined(CONFIG_BT_CTLR_ADV_EXT)
30 	/* Reference to aux context when scanning auxiliary PDU */
31 	struct lll_scan_aux *lll_aux;
32 
33 	uint16_t duration_reload;
34 	uint16_t duration_expire;
35 	uint8_t  phy:3;
36 	uint8_t  is_adv_ind:1;
37 	uint8_t  is_aux_sched:1;
38 #if defined(CONFIG_BT_CTLR_SYNC_PERIODIC)
39 	uint8_t  is_sync:1;
40 #endif /* CONFIG_BT_CTLR_SYNC_PERIODIC */
41 #endif /* CONFIG_BT_CTLR_ADV_EXT */
42 
43 #if defined(CONFIG_BT_CENTRAL)
44 	uint8_t  adv_addr_type:1;
45 #endif /* CONFIG_BT_CENTRAL */
46 
47 #if defined(CONFIG_BT_CTLR_PRIVACY)
48 	uint8_t  rpa_gen:1;
49 	/* initiator only */
50 	uint8_t rl_idx;
51 #endif /* CONFIG_BT_CTLR_PRIVACY */
52 
53 	uint8_t  init_addr[BDADDR_SIZE];
54 
55 	uint16_t interval;
56 	uint32_t ticks_window;
57 
58 #if defined(CONFIG_BT_CTLR_TX_PWR_DYNAMIC_CONTROL)
59 	int8_t tx_pwr_lvl;
60 #endif /* CONFIG_BT_CTLR_TX_PWR_DYNAMIC_CONTROL */
61 };
62 
63 struct lll_scan_aux {
64 	struct lll_hdr hdr;
65 
66 	uint8_t chan:6;
67 	uint8_t state:1;
68 	uint8_t is_chain_sched:1;
69 
70 	uint8_t phy:3;
71 
72 	uint32_t window_size_us;
73 
74 #if defined(CONFIG_BT_CENTRAL)
75 	struct node_rx_pdu *node_conn_rx;
76 #endif /* CONFIG_BT_CENTRAL */
77 };
78 
79 
80 /* Define to check if filter is enabled and in addition if it is Extended Scan
81  * Filtering.
82  */
83 #define SCAN_FP_FILTER BIT(0)
84 #define SCAN_FP_EXT    BIT(1)
85 
86 int lll_scan_init(void);
87 int lll_scan_reset(void);
88 
89 void lll_scan_prepare(void *param);
90 
91 extern uint8_t ull_scan_lll_handle_get(struct lll_scan *lll);
92 extern struct lll_scan *ull_scan_lll_is_valid_get(struct lll_scan *lll);
93 extern struct lll_scan_aux *ull_scan_aux_lll_is_valid_get(struct lll_scan_aux *lll);
94