xref: /wlan-driver/qcacld-3.0/core/hdd/src/wlan_hdd_scan.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2012-2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for
6  * any purpose with or without fee is hereby granted, provided that the
7  * above copyright notice and this permission notice appear in all
8  * copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17  * PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 /**
21  * DOC: wlan_hdd_scan.h
22  *
23  * WLAN Host Device Driver scan related implementation
24  *
25  */
26 
27 #if !defined(WLAN_HDD_SCAN_H)
28 #define WLAN_HDD_SCAN_H
29 
30 #include "wlan_hdd_main.h"
31 #include "csr_inside_api.h"
32 #include <wlan_cfg80211_scan.h>
33 #include "qca_vendor.h"
34 
35 extern const struct nla_policy scan_policy[
36 			QCA_WLAN_VENDOR_ATTR_SCAN_MAX + 1];
37 
38 #define FEATURE_TRIGGER_SCAN_VENDOR_COMMANDS \
39 { \
40 	.info.vendor_id = QCA_NL80211_VENDOR_ID, \
41 	.info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TRIGGER_SCAN, \
42 	.flags = WIPHY_VENDOR_CMD_NEED_WDEV | \
43 		WIPHY_VENDOR_CMD_NEED_NETDEV | \
44 		WIPHY_VENDOR_CMD_NEED_RUNNING, \
45 	.doit = wlan_hdd_cfg80211_vendor_scan, \
46 	vendor_command_policy(scan_policy, \
47 			      QCA_WLAN_VENDOR_ATTR_SCAN_MAX) \
48 },
49 
50 #define EXTSCAN_PARAM_MAX QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX
51 
52 int hdd_scan_context_init(struct hdd_context *hdd_ctx);
53 void hdd_scan_context_destroy(struct hdd_context *hdd_ctx);
54 
55 int wlan_hdd_cfg80211_scan(struct wiphy *wiphy,
56 			   struct cfg80211_scan_request *request);
57 
58 #ifdef FEATURE_WLAN_SCAN_PNO
59 int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
60 				       struct net_device *dev,
61 				       struct cfg80211_sched_scan_request
62 				       *request);
63 
64 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 12, 0)
65 /**
66  * wlan_hdd_cfg80211_sched_scan_stop() - stop cfg80211 scheduled (PNO) scan
67  * @wiphy: Pointer to wiphy
68  * @dev: Pointer network device
69  *
70  * Note, this returns success if the driver is recovering or unloading to
71  * prevent race conditions between PLD initiating an unload and kernel
72  * initiating a scheduled scan stop via cfg80211. Unload is expected to stop
73  * any pending scheduled scans in this case.
74  *
75  * Return: 0 for success, non zero for failure
76  */
77 int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
78 				      struct net_device *dev);
79 #else
80 int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
81 				      struct net_device *dev,
82 				      uint64_t reqid);
83 
84 #endif /* KERNEL_VERSION(4, 12, 0) */
85 
86 /**
87  * wlan_hdd_sched_scan_stop() - stop scheduled (PNO) scans
88  * @dev: Pointer network device
89  *
90  * Return: 0 for success, non zero for failure
91  */
92 int wlan_hdd_sched_scan_stop(struct net_device *dev);
93 #else
wlan_hdd_sched_scan_stop(struct net_device * dev)94 static inline int wlan_hdd_sched_scan_stop(struct net_device *dev)
95 {
96 	return 0;
97 }
98 #endif /* End of FEATURE_WLAN_SCAN_PNO */
99 
100 int wlan_hdd_cfg80211_vendor_scan(struct wiphy *wiphy,
101 		struct wireless_dev *wdev, const void *data,
102 		int data_len);
103 
104 /**
105  * wlan_hdd_vendor_abort_scan() - API to process vendor command for
106  * abort scan
107  * @wiphy: Pointer to wiphy
108  * @wdev: Pointer to net device
109  * @data : Pointer to the data
110  * @data_len : length of the data
111  *
112  * This is called from supplicant to abort scan
113  *
114  * Return: zero for success and non zero for failure.
115  */
116 int wlan_hdd_vendor_abort_scan(
117 	struct wiphy *wiphy, struct wireless_dev *wdev,
118 	const void *data, int data_len);
119 
120 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0)) || \
121 	defined(CFG80211_ABORT_SCAN)
122 void wlan_hdd_cfg80211_abort_scan(struct wiphy *wiphy,
123 				  struct wireless_dev *wdev);
124 #endif
125 
126 /**
127  * hdd_init_scan_reject_params() - init scan reject params
128  * @hdd_ctx: hdd contxt
129  *
130  * Return: None
131  */
132 void hdd_init_scan_reject_params(struct hdd_context *hdd_ctx);
133 
134 /**
135  * wlan_hdd_cfg80211_scan_block() - scan block handler
136  * @adapter: HDD adapter to work against
137  *
138  * Return: none
139  */
140 void wlan_hdd_cfg80211_scan_block(struct hdd_adapter *adapter);
141 
142 #ifdef FEATURE_WLAN_EXTSCAN
143 extern const struct nla_policy
144 wlan_hdd_extscan_config_policy[EXTSCAN_PARAM_MAX + 1];
145 extern const struct nla_policy
146 wlan_hdd_pno_config_policy[QCA_WLAN_VENDOR_ATTR_PNO_MAX + 1];
147 
148 #define FEATURE_EXTSCAN_VENDOR_COMMANDS					       \
149 {									       \
150 	.info.vendor_id = QCA_NL80211_VENDOR_ID,			       \
151 	.info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START,		       \
152 	.flags = WIPHY_VENDOR_CMD_NEED_WDEV |				       \
153 		 WIPHY_VENDOR_CMD_NEED_NETDEV | WIPHY_VENDOR_CMD_NEED_RUNNING, \
154 	.doit = wlan_hdd_cfg80211_extscan_start,			       \
155 	vendor_command_policy(wlan_hdd_extscan_config_policy,		       \
156 			      EXTSCAN_PARAM_MAX)			       \
157 },									       \
158 {									       \
159 	.info.vendor_id = QCA_NL80211_VENDOR_ID,			       \
160 	.info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP,		       \
161 	.flags = WIPHY_VENDOR_CMD_NEED_WDEV |				       \
162 		 WIPHY_VENDOR_CMD_NEED_NETDEV | WIPHY_VENDOR_CMD_NEED_RUNNING, \
163 	.doit = wlan_hdd_cfg80211_extscan_stop,				       \
164 	vendor_command_policy(wlan_hdd_extscan_config_policy,		       \
165 			      EXTSCAN_PARAM_MAX)			       \
166 },									       \
167 {									       \
168 	.info.vendor_id = QCA_NL80211_VENDOR_ID,			       \
169 	.info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES,     \
170 	.flags = WIPHY_VENDOR_CMD_NEED_WDEV |				       \
171 		 WIPHY_VENDOR_CMD_NEED_NETDEV | WIPHY_VENDOR_CMD_NEED_RUNNING, \
172 	.doit = wlan_hdd_cfg80211_extscan_get_capabilities,		       \
173 	vendor_command_policy(wlan_hdd_extscan_config_policy,		       \
174 			      EXTSCAN_PARAM_MAX)			       \
175 },									       \
176 {									       \
177 	.info.vendor_id = QCA_NL80211_VENDOR_ID,			       \
178 	.info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS,   \
179 	.flags = WIPHY_VENDOR_CMD_NEED_WDEV |				       \
180 		 WIPHY_VENDOR_CMD_NEED_NETDEV | WIPHY_VENDOR_CMD_NEED_RUNNING, \
181 	.doit = wlan_hdd_cfg80211_extscan_get_cached_results,		       \
182 	vendor_command_policy(wlan_hdd_extscan_config_policy,		       \
183 			      EXTSCAN_PARAM_MAX)			       \
184 },									       \
185 {									       \
186 	.info.vendor_id = QCA_NL80211_VENDOR_ID,			       \
187 	.info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST,    \
188 	.flags = WIPHY_VENDOR_CMD_NEED_WDEV |				       \
189 		 WIPHY_VENDOR_CMD_NEED_NETDEV | WIPHY_VENDOR_CMD_NEED_RUNNING, \
190 	.doit = wlan_hdd_cfg80211_extscan_set_bssid_hotlist,		       \
191 	vendor_command_policy(wlan_hdd_extscan_config_policy,		       \
192 			      EXTSCAN_PARAM_MAX)			       \
193 },									       \
194 {									       \
195 	.info.vendor_id = QCA_NL80211_VENDOR_ID,			       \
196 	.info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST,  \
197 	.flags = WIPHY_VENDOR_CMD_NEED_WDEV |				       \
198 		 WIPHY_VENDOR_CMD_NEED_NETDEV | WIPHY_VENDOR_CMD_NEED_RUNNING, \
199 	.doit = wlan_hdd_cfg80211_extscan_reset_bssid_hotlist,		       \
200 	vendor_command_policy(wlan_hdd_extscan_config_policy,		       \
201 			      EXTSCAN_PARAM_MAX)			       \
202 },									       \
203 {									       \
204 	.info.vendor_id = QCA_NL80211_VENDOR_ID,			       \
205 	.info.subcmd =							       \
206 		QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE,      \
207 	.flags = WIPHY_VENDOR_CMD_NEED_WDEV |				       \
208 		 WIPHY_VENDOR_CMD_NEED_NETDEV | WIPHY_VENDOR_CMD_NEED_RUNNING, \
209 	.doit = wlan_hdd_cfg80211_extscan_set_significant_change,	       \
210 	vendor_command_policy(wlan_hdd_extscan_config_policy,		       \
211 			      EXTSCAN_PARAM_MAX)			       \
212 },									       \
213 {									       \
214 	.info.vendor_id = QCA_NL80211_VENDOR_ID,			       \
215 	.info.subcmd =							       \
216 		QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE,    \
217 	.flags = WIPHY_VENDOR_CMD_NEED_WDEV |				       \
218 		 WIPHY_VENDOR_CMD_NEED_NETDEV | WIPHY_VENDOR_CMD_NEED_RUNNING, \
219 	.doit = wlan_hdd_cfg80211_extscan_reset_significant_change,	       \
220 	vendor_command_policy(wlan_hdd_extscan_config_policy,		       \
221 			      EXTSCAN_PARAM_MAX)			       \
222 },									       \
223 {									       \
224 	.info.vendor_id = QCA_NL80211_VENDOR_ID,			       \
225 	.info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_PNO_SET_LIST,	       \
226 	.flags = WIPHY_VENDOR_CMD_NEED_WDEV |				       \
227 		 WIPHY_VENDOR_CMD_NEED_NETDEV | WIPHY_VENDOR_CMD_NEED_RUNNING, \
228 	.doit = wlan_hdd_cfg80211_set_epno_list,				       \
229 	vendor_command_policy(wlan_hdd_pno_config_policy,		       \
230 			      QCA_WLAN_VENDOR_ATTR_PNO_MAX)		       \
231 },									       \
232 {									       \
233 	.info.vendor_id = QCA_NL80211_VENDOR_ID,			       \
234 	.info.subcmd =							       \
235 		QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_PNO_SET_PASSPOINT_LIST,      \
236 	.flags = WIPHY_VENDOR_CMD_NEED_WDEV |				       \
237 		 WIPHY_VENDOR_CMD_NEED_NETDEV | WIPHY_VENDOR_CMD_NEED_RUNNING, \
238 	.doit = wlan_hdd_cfg80211_set_passpoint_list,			       \
239 	vendor_command_policy(wlan_hdd_pno_config_policy,		       \
240 			      QCA_WLAN_VENDOR_ATTR_PNO_MAX)		       \
241 },									       \
242 {									       \
243 	.info.vendor_id = QCA_NL80211_VENDOR_ID,			       \
244 	.info.subcmd =							       \
245 		QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_PNO_RESET_PASSPOINT_LIST,    \
246 	.flags = WIPHY_VENDOR_CMD_NEED_WDEV |				       \
247 		 WIPHY_VENDOR_CMD_NEED_NETDEV | WIPHY_VENDOR_CMD_NEED_RUNNING, \
248 	.doit = wlan_hdd_cfg80211_reset_passpoint_list,			       \
249 	vendor_command_policy(wlan_hdd_pno_config_policy,		       \
250 			      QCA_WLAN_VENDOR_ATTR_PNO_MAX)		       \
251 },
252 #else
253 #define FEATURE_EXTSCAN_VENDOR_COMMANDS
254 #endif /* FEATURE_WLAN_EXTSCAN */
255 
256 #endif /* end #if !defined(WLAN_HDD_SCAN_H) */
257 
258