xref: /wlan-dirver/qca-wifi-host-cmn/os_if/linux/scan/inc/wlan_cfg80211_scan.h (revision 91abaccb452c5ef80225d45a998644d4cdd55543)
1 /*
2  * Copyright (c) 2017 The Linux Foundation. All rights reserved.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for
5  * any purpose with or without fee is hereby granted, provided that the
6  * above copyright notice and this permission notice appear in all
7  * copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16  * PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 /**
20  * DOC: declares driver functions interfacing with linux kernel
21  */
22 
23 
24 #ifndef _WLAN_CFG80211_SCAN_H_
25 #define _WLAN_CFG80211_SCAN_H_
26 
27 #include <linux/version.h>
28 #include <linux/netdevice.h>
29 #include <net/cfg80211.h>
30 #include <qca_vendor.h>
31 #include <wlan_scan_public_structs.h>
32 #include <qdf_list.h>
33 #include <qdf_types.h>
34 #include <wlan_scan_ucfg_api.h>
35 
36 
37 /* Max number of scans allowed from userspace */
38 #define WLAN_MAX_SCAN_COUNT 8
39 
40 /* GPS application requirement */
41 #define QCOM_VENDOR_IE_ID 221
42 #define QCOM_OUI1         0x00
43 #define QCOM_OUI2         0xA0
44 #define QCOM_OUI3         0xC6
45 #define QCOM_VENDOR_IE_AGE_TYPE  0x100
46 #define QCOM_VENDOR_IE_AGE_LEN   (sizeof(qcom_ie_age) - 2)
47 #define SCAN_DONE_EVENT_BUF_SIZE 4096
48 
49 /**
50  * typedef struct qcom_ie_age - age ie
51  *
52  * @element_id: Element id
53  * @len: Length
54  * @oui_1: OUI 1
55  * @oui_2: OUI 2
56  * @oui_3: OUI 3
57  * @type: Type
58  * @age: Age
59  * @tsf_delta: tsf delta from FW
60  * @beacon_tsf: original beacon TSF
61  * @seq_ctrl: sequence control field
62  */
63 typedef struct {
64 	u8 element_id;
65 	u8 len;
66 	u8 oui_1;
67 	u8 oui_2;
68 	u8 oui_3;
69 	u32 type;
70 	u32 age;
71 	u32 tsf_delta;
72 	u64 beacon_tsf;
73 	u16 seq_ctrl;
74 } __attribute__ ((packed)) qcom_ie_age;
75 
76 /**
77  * struct osif_scan_pdev - OS scan private strcutre
78  * scan_req_q: Scan request queue
79  * scan_req_q_lock: Protect scan request queue
80  * req_id: Scan request Id
81  * runtime_pm_lock: Runtime suspend lock
82  */
83 struct osif_scan_pdev{
84 	qdf_list_t scan_req_q;
85 	qdf_mutex_t scan_req_q_lock;
86 	wlan_scan_requester req_id;
87 	qdf_runtime_lock_t runtime_pm_lock;
88 };
89 
90 /*
91  * enum scan_source - scan request source
92  * @NL_SCAN: Scan initiated from NL
93  * @VENDOR_SCAN: Scan intiated from vendor command
94  */
95 enum scan_source {
96 	NL_SCAN,
97 	VENDOR_SCAN,
98 };
99 
100 /**
101  * struct scan_req - Scan Request entry
102  * @node : List entry element
103  * @scan_request: scan request holder
104  * @scan_id: scan identifier used across host layers which is generated at WMI
105  * @source: scan request originator (NL/Vendor scan)
106  *
107  * Scan request linked list element
108  */
109 struct scan_req {
110 	qdf_list_node_t node;
111 	struct cfg80211_scan_request *scan_request;
112 	uint32_t scan_id;
113 	uint8_t source;
114 };
115 
116 /**
117  * struct scan_params - Scan params
118  * @source: scan request source
119  * @default_ie: default scan ie
120  *
121  */
122 struct scan_params {
123 	uint8_t source;
124 	struct element_info default_ie;
125 };
126 
127 #ifdef FEATURE_WLAN_SCAN_PNO
128 /**
129  * wlan_cfg80211_sched_scan_start() - cfg80211 scheduled scan(pno) start
130  * @pdev: pdev pointer
131  * @dev: Pointer network device
132  * @request: Pointer to cfg80211 scheduled scan start request
133  * @scan_backoff_multiplier: multiply scan period by this after max cycles
134  *
135  * Return: 0 for success, non zero for failure
136  */
137 int wlan_cfg80211_sched_scan_start(struct wlan_objmgr_pdev *pdev,
138 	struct net_device *dev,
139 	struct cfg80211_sched_scan_request *request,
140 	uint8_t scan_backoff_multiplier);
141 
142 /**
143  * wlan_cfg80211_sched_scan_stop() - cfg80211 scheduled scan(pno) stop
144  * @pdev: pdev pointer
145  * @dev: Pointer network device
146  *
147  * Return: 0 for success, non zero for failure
148  */
149 int wlan_cfg80211_sched_scan_stop(struct wlan_objmgr_pdev *pdev,
150 	struct net_device *dev);
151 #endif
152 
153 /**
154  * wlan_scan_runtime_pm_init() - API to initialize runtime pm context for scan
155  * @pdev: Pointer to pdev
156  *
157  * This will help to initialize scan runtime pm context separately.
158  *
159  * Return: QDF_STATUS
160  */
161 QDF_STATUS wlan_scan_runtime_pm_init(struct wlan_objmgr_pdev *pdev);
162 
163 /**
164  * wlan_scan_runtime_pm_deinit() - API to deinitialize runtime pm
165  * for scan.
166  * @pdev: Pointer to pdev
167  *
168  * This will help to deinitialize scan runtime pm before deinitialize
169  * HIF
170  *
171  * Return: void
172  */
173 void wlan_scan_runtime_pm_deinit(struct wlan_objmgr_pdev *pdev);
174 
175 /**
176  * wlan_cfg80211_scan_priv_init() - API to initialize cfg80211 scan
177  * @pdev: Pointer to net device
178  *
179  * API to initialize cfg80211 scan module.
180  *
181  * Return: QDF_STATUS
182  */
183 QDF_STATUS wlan_cfg80211_scan_priv_init(struct wlan_objmgr_pdev *pdev);
184 
185 /**
186  * wlan_cfg80211_scan_priv_deinit() - API to deinitialize cfg80211 scan
187  * @pdev: Pointer to net device
188  *
189  * API to deinitialize cfg80211 scan module.
190  *
191  * Return: QDF_STATUS
192  */
193 QDF_STATUS wlan_cfg80211_scan_priv_deinit(
194 		struct wlan_objmgr_pdev *pdev);
195 
196 /**
197  * wlan_cfg80211_scan() - API to process cfg80211 scan request
198  * @pdev: Pointer to pdev
199  * @request: Pointer to scan request
200  * @params: scan params
201  *
202  * API to trigger scan and update cfg80211 scan database.
203  * scan dump command can be used to fetch scan results
204  * on receipt of scan complete event.
205  *
206  * Return: 0 for success, non zero for failure
207  */
208 int wlan_cfg80211_scan(struct wlan_objmgr_pdev *pdev,
209 		struct cfg80211_scan_request *request,
210 		struct scan_params *params);
211 
212 /**
213  * wlan_cfg80211_inform_bss_frame() - API to inform beacon to cfg80211
214  * @pdev: Pointer to pdev
215  * @scan_params: scan entry
216  * @request: Pointer to scan request
217  *
218  * API to inform beacon to cfg80211
219  *
220  * Return: void
221  */
222 void wlan_cfg80211_inform_bss_frame(struct wlan_objmgr_pdev *pdev,
223 	struct scan_cache_entry *scan_params);
224 
225 /**
226  * wlan_vendor_abort_scan() - API to vendor abort scan
227  * @pdev: Pointer to pdev
228  * @data: pointer to data
229  * @data_len: Data length
230  *
231  * API to abort scan through vendor command
232  *
233  * Return: 0 for success, non zero for failure
234  */
235 int wlan_vendor_abort_scan(struct wlan_objmgr_pdev *pdev,
236 				const void *data, int data_len);
237 
238 /**
239  * wlan_cfg80211_abort_scan() - API to abort scan through cfg80211
240  * @pdev: Pointer to pdev
241  *
242  * API to abort scan through cfg80211 request
243  *
244  * Return: 0 for success, non zero for failure
245  */
246 int wlan_cfg80211_abort_scan(struct wlan_objmgr_pdev *pdev);
247 
248 /**
249  * wlan_abort_scan() - Generic API to abort scan request
250  * @pdev: Pointer to pdev
251  * @pdev_id: pdev id
252  * @vdev_id: vdev id
253  * @scan_id: scan id
254  * @sync: if wait for scan complete is required
255  *
256  * Generic API to abort scans
257  *
258  * Return: 0 for success, non zero for failure
259  */
260 QDF_STATUS wlan_abort_scan(struct wlan_objmgr_pdev *pdev,
261 				   uint32_t pdev_id,
262 				   uint32_t vdev_id,
263 				   wlan_scan_id scan_id,
264 				   bool sync);
265 
266 /**
267  * wlan_cfg80211_cleanup_scan_queue() - remove entries in scan queue
268  * @pdev: pdev pointer
269  *
270  * Removes entries in scan queue and sends scan complete event to NL
271  *
272  * Return: None
273  */
274 void wlan_cfg80211_cleanup_scan_queue(struct wlan_objmgr_pdev *pdev);
275 
276 
277 #endif
278