xref: /wlan-dirver/qca-wifi-host-cmn/os_if/linux/scan/inc/wlan_cfg80211_scan.h (revision 6ecd284e5a94a1c96e26d571dd47419ac305990d)
1 /*
2  * Copyright (c) 2017-2018 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 #include <wlan_mgmt_txrx_utils_api.h>
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  * @dev: net device (same as what is in scan_request)
107  *
108  * Scan request linked list element
109  */
110 struct scan_req {
111 	qdf_list_node_t node;
112 	struct cfg80211_scan_request *scan_request;
113 	uint32_t scan_id;
114 	uint8_t source;
115 	struct net_device *dev;
116 };
117 
118 /**
119  * struct scan_params - Scan params
120  * @source: scan request source
121  * @default_ie: default scan ie
122  * @half_rate: Half rate flag
123  * @quarter_rate: Quarter rate flag
124  */
125 struct scan_params {
126 	uint8_t source;
127 	struct element_info default_ie;
128 	bool half_rate;
129 	bool quarter_rate;
130 };
131 
132 /**
133  * struct wlan_cfg80211_inform_bss - BSS inform data
134  * @chan: channel the frame was received on
135  * @mgmt: beacon/probe resp frame
136  * @frame_len: frame length
137  * @rssi: signal strength in mBm (100*dBm)
138  * @boottime_ns: timestamp (CLOCK_BOOTTIME) when the information was received.
139  * @per_chain_snr: per chain snr received
140  */
141 struct wlan_cfg80211_inform_bss {
142 	struct ieee80211_channel *chan;
143 	struct ieee80211_mgmt *mgmt;
144 	size_t frame_len;
145 	int rssi;
146 	uint64_t boottime_ns;
147 	uint8_t per_chain_snr[WLAN_MGMT_TXRX_HOST_MAX_ANTENNA];
148 };
149 
150 
151 #ifdef FEATURE_WLAN_SCAN_PNO
152 /**
153  * wlan_cfg80211_sched_scan_start() - cfg80211 scheduled scan(pno) start
154  * @pdev: pdev pointer
155  * @dev: Pointer network device
156  * @request: Pointer to cfg80211 scheduled scan start request
157  * @scan_backoff_multiplier: multiply scan period by this after max cycles
158  *
159  * Return: 0 for success, non zero for failure
160  */
161 int wlan_cfg80211_sched_scan_start(struct wlan_objmgr_pdev *pdev,
162 	struct net_device *dev,
163 	struct cfg80211_sched_scan_request *request,
164 	uint8_t scan_backoff_multiplier);
165 
166 /**
167  * wlan_cfg80211_sched_scan_stop() - cfg80211 scheduled scan(pno) stop
168  * @pdev: pdev pointer
169  * @dev: Pointer network device
170  *
171  * Return: 0 for success, non zero for failure
172  */
173 int wlan_cfg80211_sched_scan_stop(struct wlan_objmgr_pdev *pdev,
174 	struct net_device *dev);
175 #endif
176 
177 /**
178  * wlan_scan_runtime_pm_init() - API to initialize runtime pm context for scan
179  * @pdev: Pointer to pdev
180  *
181  * This will help to initialize scan runtime pm context separately.
182  *
183  * Return: QDF_STATUS
184  */
185 QDF_STATUS wlan_scan_runtime_pm_init(struct wlan_objmgr_pdev *pdev);
186 
187 /**
188  * wlan_scan_runtime_pm_deinit() - API to deinitialize runtime pm
189  * for scan.
190  * @pdev: Pointer to pdev
191  *
192  * This will help to deinitialize scan runtime pm before deinitialize
193  * HIF
194  *
195  * Return: void
196  */
197 void wlan_scan_runtime_pm_deinit(struct wlan_objmgr_pdev *pdev);
198 
199 /**
200  * wlan_cfg80211_scan_priv_init() - API to initialize cfg80211 scan
201  * @pdev: Pointer to net device
202  *
203  * API to initialize cfg80211 scan module.
204  *
205  * Return: QDF_STATUS
206  */
207 QDF_STATUS wlan_cfg80211_scan_priv_init(struct wlan_objmgr_pdev *pdev);
208 
209 /**
210  * wlan_cfg80211_scan_priv_deinit() - API to deinitialize cfg80211 scan
211  * @pdev: Pointer to net device
212  *
213  * API to deinitialize cfg80211 scan module.
214  *
215  * Return: QDF_STATUS
216  */
217 QDF_STATUS wlan_cfg80211_scan_priv_deinit(
218 		struct wlan_objmgr_pdev *pdev);
219 
220 /**
221  * wlan_cfg80211_scan() - API to process cfg80211 scan request
222  * @pdev: Pointer to pdev
223  * @request: Pointer to scan request
224  * @params: scan params
225  *
226  * API to trigger scan and update cfg80211 scan database.
227  * scan dump command can be used to fetch scan results
228  * on receipt of scan complete event.
229  *
230  * Return: 0 for success, non zero for failure
231  */
232 int wlan_cfg80211_scan(struct wlan_objmgr_pdev *pdev,
233 		struct cfg80211_scan_request *request,
234 		struct scan_params *params);
235 
236 /**
237  * wlan_cfg80211_inform_bss_frame_data() - API to inform beacon to cfg80211
238  * @wiphy: wiphy
239  * @bss_data: bss data
240  *
241  * API to inform beacon to cfg80211
242  *
243  * Return: pointer to bss entry
244  */
245 struct cfg80211_bss *
246 wlan_cfg80211_inform_bss_frame_data(struct wiphy *wiphy,
247 		struct wlan_cfg80211_inform_bss *bss);
248 
249 /**
250  * wlan_cfg80211_inform_bss_frame() - API to inform beacon to cfg80211
251  * @pdev: Pointer to pdev
252  * @scan_params: scan entry
253  * @request: Pointer to scan request
254  *
255  * API to inform beacon to cfg80211
256  *
257  * Return: void
258  */
259 void wlan_cfg80211_inform_bss_frame(struct wlan_objmgr_pdev *pdev,
260 	struct scan_cache_entry *scan_params);
261 
262 /**
263  * wlan_vendor_abort_scan() - API to vendor abort scan
264  * @pdev: Pointer to pdev
265  * @data: pointer to data
266  * @data_len: Data length
267  *
268  * API to abort scan through vendor command
269  *
270  * Return: 0 for success, non zero for failure
271  */
272 int wlan_vendor_abort_scan(struct wlan_objmgr_pdev *pdev,
273 				const void *data, int data_len);
274 
275 /**
276  * wlan_cfg80211_abort_scan() - API to abort scan through cfg80211
277  * @pdev: Pointer to pdev
278  *
279  * API to abort scan through cfg80211 request
280  *
281  * Return: 0 for success, non zero for failure
282  */
283 int wlan_cfg80211_abort_scan(struct wlan_objmgr_pdev *pdev);
284 
285 /**
286  * wlan_abort_scan() - Generic API to abort scan request
287  * @pdev: Pointer to pdev
288  * @pdev_id: pdev id
289  * @vdev_id: vdev id
290  * @scan_id: scan id
291  * @sync: if wait for scan complete is required
292  *
293  * Generic API to abort scans
294  *
295  * Return: 0 for success, non zero for failure
296  */
297 QDF_STATUS wlan_abort_scan(struct wlan_objmgr_pdev *pdev,
298 				   uint32_t pdev_id,
299 				   uint32_t vdev_id,
300 				   wlan_scan_id scan_id,
301 				   bool sync);
302 
303 /**
304  * wlan_cfg80211_cleanup_scan_queue() - remove entries in scan queue
305  * @pdev: pdev pointer
306  * @dev: net device pointer
307  *
308  * Removes entries in scan queue depending on dev provided and sends scan
309  * complete event to NL.
310  * Removes all entries in scan queue, if dev provided is NULL
311  *
312  * Return: None
313  */
314 void wlan_cfg80211_cleanup_scan_queue(struct wlan_objmgr_pdev *pdev,
315 				      struct net_device *dev);
316 
317 
318 #endif
319