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 	uint16_t duration_reload;
31 	uint16_t duration_expire;
32 	uint8_t  phy:3;
33 	uint8_t  is_adv_ind:1;
34 	uint8_t  is_aux_sched:1;
35 
36 	/* temporary storage when aux scan was scheduled from LLL */
37 	struct lll_scan_aux *lll_aux;
38 #endif /* CONFIG_BT_CTLR_ADV_EXT */
39 
40 #if defined(CONFIG_BT_CENTRAL)
41 	uint8_t  adv_addr_type:1;
42 #endif /* CONFIG_BT_CENTRAL */
43 
44 #if defined(CONFIG_BT_CTLR_PRIVACY)
45 	uint8_t  rpa_gen:1;
46 	/* initiator only */
47 	uint8_t rl_idx;
48 #endif /* CONFIG_BT_CTLR_PRIVACY */
49 
50 	uint8_t  init_addr[BDADDR_SIZE];
51 
52 	uint16_t interval;
53 	uint32_t ticks_window;
54 
55 #if defined(CONFIG_BT_CTLR_TX_PWR_DYNAMIC_CONTROL)
56 	int8_t tx_pwr_lvl;
57 #endif /* CONFIG_BT_CTLR_TX_PWR_DYNAMIC_CONTROL */
58 };
59 
60 struct lll_scan_aux {
61 	struct lll_hdr hdr;
62 
63 	uint8_t chan:6;
64 	uint8_t state:1;
65 	uint8_t is_chain_sched:1;
66 
67 	uint8_t phy:3;
68 
69 	uint32_t window_size_us;
70 
71 #if defined(CONFIG_BT_CTLR_TX_PWR_DYNAMIC_CONTROL)
72 	int8_t tx_pwr_lvl;
73 #endif /* CONFIG_BT_CTLR_TX_PWR_DYNAMIC_CONTROL */
74 
75 #if defined(CONFIG_BT_CENTRAL)
76 	struct node_rx_pdu *node_conn_rx;
77 #endif /* CONFIG_BT_CENTRAL */
78 };
79 
80 int lll_scan_init(void);
81 int lll_scan_reset(void);
82 
83 void lll_scan_prepare(void *param);
84 
85 extern uint8_t ull_scan_lll_handle_get(struct lll_scan *lll);
86