xref: /wlan-dirver/qca-wifi-host-cmn/os_if/linux/scan/inc/wlan_cfg80211_scan.h (revision 928e3ecad0fabf5320100a0d8fbde785757aa071)
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 #ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
41 /* GPS application requirement */
42 #define QCOM_VENDOR_IE_ID 221
43 #define QCOM_OUI1         0x00
44 #define QCOM_OUI2         0xA0
45 #define QCOM_OUI3         0xC6
46 #define QCOM_VENDOR_IE_AGE_TYPE  0x100
47 #define QCOM_VENDOR_IE_AGE_LEN   (sizeof(qcom_ie_age) - 2)
48 #define SCAN_DONE_EVENT_BUF_SIZE 4096
49 #define INVAL_SCAN_ID        0xFFFFFFFF
50 #define INVAL_VDEV_ID        0xFFFFFFFF
51 #define INVAL_PDEV_ID        0xFFFFFFFF
52 
53 
54 /**
55  * typedef struct qcom_ie_age - age ie
56  *
57  * @element_id: Element id
58  * @len: Length
59  * @oui_1: OUI 1
60  * @oui_2: OUI 2
61  * @oui_3: OUI 3
62  * @type: Type
63  * @age: Age
64  * @tsf_delta: tsf delta from FW
65  * @beacon_tsf: original beacon TSF
66  * @seq_ctrl: sequence control field
67  */
68 typedef struct {
69 	u8 element_id;
70 	u8 len;
71 	u8 oui_1;
72 	u8 oui_2;
73 	u8 oui_3;
74 	u32 type;
75 	u32 age;
76 	u32 tsf_delta;
77 	u64 beacon_tsf;
78 	u16 seq_ctrl;
79 } __attribute__ ((packed)) qcom_ie_age;
80 #endif
81 
82 /**
83  * struct osif_scan_pdev - OS scan private strcutre
84  * scan_req_q: Scan request queue
85  * req_id: Scan request Id
86 */
87 struct osif_scan_pdev{
88 	qdf_list_t scan_req_q;
89 	wlan_scan_requester req_id;
90 };
91 
92 /*
93  * enum scan_source - scan request source
94  * @NL_SCAN: Scan initiated from NL
95  * @VENDOR_SCAN: Scan intiated from vendor command
96  */
97 enum scan_source {
98 	NL_SCAN,
99 	VENDOR_SCAN,
100 };
101 
102 /**
103  * struct scan_req - Scan Request entry
104  * @node : List entry element
105  * @scan_request: scan request holder
106  * @scan_id: scan identifier used across host layers which is generated at WMI
107  * @source: scan request originator (NL/Vendor scan)
108  *
109  * Scan request linked list element
110  */
111 struct scan_req {
112 	qdf_list_node_t node;
113 	struct cfg80211_scan_request *scan_request;
114 	uint32_t scan_id;
115 	uint8_t source;
116 };
117 
118 #ifdef FEATURE_WLAN_SCAN_PNO
119 /**
120  * wlan_cfg80211_sched_scan_start() - cfg80211 scheduled scan(pno) start
121  * @pdev: pdev pointer
122  * @dev: Pointer network device
123  * @request: Pointer to cfg80211 scheduled scan start request
124  *
125  * Return: 0 for success, non zero for failure
126  */
127 int wlan_cfg80211_sched_scan_start(struct wlan_objmgr_pdev *pdev,
128 	struct net_device *dev,
129 	struct cfg80211_sched_scan_request *request);
130 
131 /**
132  * wlan_cfg80211_sched_scan_stop() - cfg80211 scheduled scan(pno) stop
133  * @pdev: pdev pointer
134  * @dev: Pointer network device
135  *
136  * Return: 0 for success, non zero for failure
137  */
138 int wlan_cfg80211_sched_scan_stop(struct wlan_objmgr_pdev *pdev,
139 	struct net_device *dev);
140 #endif
141 
142 /**
143  * wlan_cfg80211_scan_priv_init() - API to initialize cfg80211 scan
144  * @pdev: Pointer to net device
145  *
146  * API to initialize cfg80211 scan module.
147  *
148  * Return: QDF_STATUS
149  */
150 QDF_STATUS wlan_cfg80211_scan_priv_init(struct wlan_objmgr_pdev *pdev);
151 
152 /**
153  * wlan_cfg80211_scan_priv_deinit() - API to deinitialize cfg80211 scan
154  * @pdev: Pointer to net device
155  *
156  * API to deinitialize cfg80211 scan module.
157  *
158  * Return: QDF_STATUS
159  */
160 QDF_STATUS wlan_cfg80211_scan_priv_deinit(
161 		struct wlan_objmgr_pdev *pdev);
162 
163 /**
164  * wlan_cfg80211_scan() - API to process cfg80211 scan request
165  * @pdev: Pointer to pdev
166  * @request: Pointer to scan request
167  * @source: source of scan request
168  *
169  * API to trigger scan and update cfg80211 scan database.
170  * scan dump command can be used to fetch scan results
171  * on receipt of scan complete event.
172  *
173  * Return: 0 for success, non zero for failure
174  */
175 int wlan_cfg80211_scan(struct wlan_objmgr_pdev *pdev,
176 		struct cfg80211_scan_request *request,
177 		uint8_t source);
178 
179 /**
180  * wlan_cfg80211_inform_bss_frame() - API to inform beacon to cfg80211
181  * @pdev: Pointer to pdev
182  * @scan_params: scan entry
183  * @request: Pointer to scan request
184  *
185  * API to inform beacon to cfg80211
186  *
187  * Return: void
188  */
189 void wlan_cfg80211_inform_bss_frame(struct wlan_objmgr_pdev *pdev,
190 	struct scan_cache_entry *scan_params);
191 
192 /**
193  * wlan_vendor_abort_scan() - API to vendor abort scan
194  * @pdev: Pointer to pdev
195  * @data: pointer to data
196  * @data_len: Data length
197  *
198  * API to abort scan through vendor command
199  *
200  * Return: 0 for success, non zero for failure
201  */
202 int wlan_vendor_abort_scan(struct wlan_objmgr_pdev *pdev,
203 				const void *data, int data_len);
204 
205 /**
206  * wlan_cfg80211_abort_scan() - API to abort scan through cfg80211
207  * @pdev: Pointer to pdev
208  *
209  * API to abort scan through cfg80211 request
210  *
211  * Return: 0 for success, non zero for failure
212  */
213 int wlan_cfg80211_abort_scan(struct wlan_objmgr_pdev *pdev);
214 
215 /**
216  * wlan_abort_scan() - Generic API to abort scan request
217  * @pdev: Pointer to pdev
218  * @pdev_id: pdev id
219  * @vdev_id: vdev id
220  * @scan_id: scan id
221  *
222  * Generic API to abort scans
223  *
224  * Return: 0 for success, non zero for failure
225  */
226 QDF_STATUS wlan_abort_scan(struct wlan_objmgr_pdev *pdev,
227 				   uint32_t pdev_id,
228 				   uint32_t vdev_id,
229 				   wlan_scan_id scan_id);
230 
231 /**
232  * wlan_cfg80211_cleanup_scan_queue() - remove entries in scan queue
233  * @pdev: pdev pointer
234  *
235  * Removes entries in scan queue and sends scan complete event to NL
236  *
237  * Return: None
238  */
239 void wlan_cfg80211_cleanup_scan_queue(struct wlan_objmgr_pdev *pdev);
240 
241 
242 #endif
243