1*5113495bSYour Name /*
2*5113495bSYour Name * Copyright (c) 2017-2021 The Linux Foundation. All rights reserved.
3*5113495bSYour Name * Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved.
4*5113495bSYour Name *
5*5113495bSYour Name * Permission to use, copy, modify, and/or distribute this software for
6*5113495bSYour Name * any purpose with or without fee is hereby granted, provided that the
7*5113495bSYour Name * above copyright notice and this permission notice appear in all
8*5113495bSYour Name * copies.
9*5113495bSYour Name *
10*5113495bSYour Name * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11*5113495bSYour Name * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12*5113495bSYour Name * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13*5113495bSYour Name * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14*5113495bSYour Name * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15*5113495bSYour Name * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16*5113495bSYour Name * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17*5113495bSYour Name * PERFORMANCE OF THIS SOFTWARE.
18*5113495bSYour Name */
19*5113495bSYour Name
20*5113495bSYour Name /*
21*5113495bSYour Name * DOC: This file contains all SCAN component's APIs
22*5113495bSYour Name */
23*5113495bSYour Name
24*5113495bSYour Name #include "cfg_ucfg_api.h"
25*5113495bSYour Name #include "wlan_scan_api.h"
26*5113495bSYour Name #include "../../core/src/wlan_scan_manager.h"
27*5113495bSYour Name #ifdef WLAN_POLICY_MGR_ENABLE
28*5113495bSYour Name #include <wlan_policy_mgr_api.h>
29*5113495bSYour Name #include "wlan_policy_mgr_public_struct.h"
30*5113495bSYour Name #endif
31*5113495bSYour Name
wlan_scan_cfg_get_passive_dwelltime(struct wlan_objmgr_psoc * psoc,uint32_t * dwell_time)32*5113495bSYour Name void wlan_scan_cfg_get_passive_dwelltime(struct wlan_objmgr_psoc *psoc,
33*5113495bSYour Name uint32_t *dwell_time)
34*5113495bSYour Name {
35*5113495bSYour Name struct wlan_scan_obj *scan_obj;
36*5113495bSYour Name
37*5113495bSYour Name scan_obj = wlan_psoc_get_scan_obj(psoc);
38*5113495bSYour Name if (!scan_obj)
39*5113495bSYour Name return;
40*5113495bSYour Name *dwell_time = scan_obj->scan_def.passive_dwell;
41*5113495bSYour Name }
42*5113495bSYour Name
wlan_scan_cfg_set_passive_dwelltime(struct wlan_objmgr_psoc * psoc,uint32_t dwell_time)43*5113495bSYour Name void wlan_scan_cfg_set_passive_dwelltime(struct wlan_objmgr_psoc *psoc,
44*5113495bSYour Name uint32_t dwell_time)
45*5113495bSYour Name {
46*5113495bSYour Name struct wlan_scan_obj *scan_obj;
47*5113495bSYour Name
48*5113495bSYour Name scan_obj = wlan_psoc_get_scan_obj(psoc);
49*5113495bSYour Name if (!scan_obj)
50*5113495bSYour Name return;
51*5113495bSYour Name scan_obj->scan_def.passive_dwell = dwell_time;
52*5113495bSYour Name }
53*5113495bSYour Name
wlan_scan_cfg_get_active_dwelltime(struct wlan_objmgr_psoc * psoc,uint32_t * dwell_time)54*5113495bSYour Name void wlan_scan_cfg_get_active_dwelltime(struct wlan_objmgr_psoc *psoc,
55*5113495bSYour Name uint32_t *dwell_time)
56*5113495bSYour Name {
57*5113495bSYour Name struct wlan_scan_obj *scan_obj;
58*5113495bSYour Name
59*5113495bSYour Name scan_obj = wlan_psoc_get_scan_obj(psoc);
60*5113495bSYour Name if (!scan_obj)
61*5113495bSYour Name return;
62*5113495bSYour Name *dwell_time = scan_obj->scan_def.active_dwell;
63*5113495bSYour Name }
64*5113495bSYour Name
wlan_scan_cfg_set_active_dwelltime(struct wlan_objmgr_psoc * psoc,uint32_t dwell_time)65*5113495bSYour Name void wlan_scan_cfg_set_active_dwelltime(struct wlan_objmgr_psoc *psoc,
66*5113495bSYour Name uint32_t dwell_time)
67*5113495bSYour Name {
68*5113495bSYour Name struct wlan_scan_obj *scan_obj;
69*5113495bSYour Name
70*5113495bSYour Name scan_obj = wlan_psoc_get_scan_obj(psoc);
71*5113495bSYour Name if (!scan_obj)
72*5113495bSYour Name return;
73*5113495bSYour Name scan_obj->scan_def.active_dwell = dwell_time;
74*5113495bSYour Name }
75*5113495bSYour Name
wlan_scan_cfg_get_active_2g_dwelltime(struct wlan_objmgr_psoc * psoc,uint32_t * dwell_time)76*5113495bSYour Name void wlan_scan_cfg_get_active_2g_dwelltime(struct wlan_objmgr_psoc *psoc,
77*5113495bSYour Name uint32_t *dwell_time)
78*5113495bSYour Name {
79*5113495bSYour Name struct wlan_scan_obj *scan_obj;
80*5113495bSYour Name
81*5113495bSYour Name scan_obj = wlan_psoc_get_scan_obj(psoc);
82*5113495bSYour Name if (!scan_obj)
83*5113495bSYour Name return;
84*5113495bSYour Name
85*5113495bSYour Name *dwell_time = scan_obj->scan_def.active_dwell_2g;
86*5113495bSYour Name }
87*5113495bSYour Name
wlan_scan_cfg_set_active_2g_dwelltime(struct wlan_objmgr_psoc * psoc,uint32_t dwell_time)88*5113495bSYour Name void wlan_scan_cfg_set_active_2g_dwelltime(struct wlan_objmgr_psoc *psoc,
89*5113495bSYour Name uint32_t dwell_time)
90*5113495bSYour Name {
91*5113495bSYour Name struct wlan_scan_obj *scan_obj;
92*5113495bSYour Name
93*5113495bSYour Name scan_obj = wlan_psoc_get_scan_obj(psoc);
94*5113495bSYour Name if (!scan_obj)
95*5113495bSYour Name return;
96*5113495bSYour Name scan_obj->scan_def.active_dwell_2g = dwell_time;
97*5113495bSYour Name }
98*5113495bSYour Name
99*5113495bSYour Name #ifdef CONFIG_BAND_6GHZ
wlan_scan_cfg_get_active_6g_dwelltime(struct wlan_objmgr_psoc * psoc,uint32_t * dwell_time)100*5113495bSYour Name QDF_STATUS wlan_scan_cfg_get_active_6g_dwelltime(struct wlan_objmgr_psoc *psoc,
101*5113495bSYour Name uint32_t *dwell_time)
102*5113495bSYour Name {
103*5113495bSYour Name struct wlan_scan_obj *scan_obj;
104*5113495bSYour Name
105*5113495bSYour Name scan_obj = wlan_psoc_get_scan_obj(psoc);
106*5113495bSYour Name if (!scan_obj)
107*5113495bSYour Name return QDF_STATUS_E_INVAL;
108*5113495bSYour Name
109*5113495bSYour Name *dwell_time = scan_obj->scan_def.active_dwell_6g;
110*5113495bSYour Name
111*5113495bSYour Name return QDF_STATUS_SUCCESS;
112*5113495bSYour Name }
113*5113495bSYour Name
wlan_scan_cfg_set_active_6g_dwelltime(struct wlan_objmgr_psoc * psoc,uint32_t dwell_time)114*5113495bSYour Name QDF_STATUS wlan_scan_cfg_set_active_6g_dwelltime(struct wlan_objmgr_psoc *psoc,
115*5113495bSYour Name uint32_t dwell_time)
116*5113495bSYour Name {
117*5113495bSYour Name struct wlan_scan_obj *scan_obj;
118*5113495bSYour Name
119*5113495bSYour Name scan_obj = wlan_psoc_get_scan_obj(psoc);
120*5113495bSYour Name if (!scan_obj)
121*5113495bSYour Name return QDF_STATUS_E_INVAL;
122*5113495bSYour Name
123*5113495bSYour Name scan_obj->scan_def.active_dwell_6g = dwell_time;
124*5113495bSYour Name
125*5113495bSYour Name return QDF_STATUS_SUCCESS;
126*5113495bSYour Name }
127*5113495bSYour Name
wlan_scan_cfg_get_passive_6g_dwelltime(struct wlan_objmgr_psoc * psoc,uint32_t * dwell_time)128*5113495bSYour Name QDF_STATUS wlan_scan_cfg_get_passive_6g_dwelltime(struct wlan_objmgr_psoc *psoc,
129*5113495bSYour Name uint32_t *dwell_time)
130*5113495bSYour Name {
131*5113495bSYour Name struct wlan_scan_obj *scan_obj;
132*5113495bSYour Name
133*5113495bSYour Name scan_obj = wlan_psoc_get_scan_obj(psoc);
134*5113495bSYour Name if (!scan_obj)
135*5113495bSYour Name return QDF_STATUS_E_INVAL;
136*5113495bSYour Name
137*5113495bSYour Name *dwell_time = scan_obj->scan_def.passive_dwell_6g;
138*5113495bSYour Name
139*5113495bSYour Name return QDF_STATUS_SUCCESS;
140*5113495bSYour Name }
141*5113495bSYour Name
wlan_scan_cfg_set_passive_6g_dwelltime(struct wlan_objmgr_psoc * psoc,uint32_t dwell_time)142*5113495bSYour Name QDF_STATUS wlan_scan_cfg_set_passive_6g_dwelltime(struct wlan_objmgr_psoc *psoc,
143*5113495bSYour Name uint32_t dwell_time)
144*5113495bSYour Name {
145*5113495bSYour Name struct wlan_scan_obj *scan_obj;
146*5113495bSYour Name
147*5113495bSYour Name scan_obj = wlan_psoc_get_scan_obj(psoc);
148*5113495bSYour Name if (!scan_obj)
149*5113495bSYour Name return QDF_STATUS_E_INVAL;
150*5113495bSYour Name
151*5113495bSYour Name scan_obj->scan_def.passive_dwell_6g = dwell_time;
152*5113495bSYour Name
153*5113495bSYour Name return QDF_STATUS_SUCCESS;
154*5113495bSYour Name }
155*5113495bSYour Name
wlan_scan_cfg_get_min_dwelltime_6g(struct wlan_objmgr_psoc * psoc,uint32_t * min_dwell_time_6ghz)156*5113495bSYour Name void wlan_scan_cfg_get_min_dwelltime_6g(struct wlan_objmgr_psoc *psoc,
157*5113495bSYour Name uint32_t *min_dwell_time_6ghz)
158*5113495bSYour Name {
159*5113495bSYour Name struct wlan_scan_obj *scan_obj;
160*5113495bSYour Name
161*5113495bSYour Name scan_obj = wlan_psoc_get_scan_obj(psoc);
162*5113495bSYour Name if (!scan_obj)
163*5113495bSYour Name return;
164*5113495bSYour Name *min_dwell_time_6ghz = scan_obj->scan_def.min_dwell_time_6g;
165*5113495bSYour Name }
166*5113495bSYour Name
wlan_scan_cfg_set_scan_mode_6g(struct wlan_objmgr_psoc * psoc,enum scan_mode_6ghz scan_mode_6g)167*5113495bSYour Name QDF_STATUS wlan_scan_cfg_set_scan_mode_6g(struct wlan_objmgr_psoc *psoc,
168*5113495bSYour Name enum scan_mode_6ghz scan_mode_6g)
169*5113495bSYour Name {
170*5113495bSYour Name struct wlan_scan_obj *scan_obj;
171*5113495bSYour Name
172*5113495bSYour Name scan_obj = wlan_psoc_get_scan_obj(psoc);
173*5113495bSYour Name if (!scan_obj)
174*5113495bSYour Name return QDF_STATUS_E_INVAL;
175*5113495bSYour Name
176*5113495bSYour Name scan_obj->scan_def.scan_mode_6g = scan_mode_6g;
177*5113495bSYour Name
178*5113495bSYour Name return QDF_STATUS_SUCCESS;
179*5113495bSYour Name }
180*5113495bSYour Name #endif
181*5113495bSYour Name
182*5113495bSYour Name #ifdef WLAN_POLICY_MGR_ENABLE
wlan_scan_update_pno_dwell_time(struct wlan_objmgr_vdev * vdev,struct pno_scan_req_params * req,struct scan_default_params * scan_def)183*5113495bSYour Name void wlan_scan_update_pno_dwell_time(struct wlan_objmgr_vdev *vdev,
184*5113495bSYour Name struct pno_scan_req_params *req,
185*5113495bSYour Name struct scan_default_params *scan_def)
186*5113495bSYour Name {
187*5113495bSYour Name bool sap_or_p2p_present;
188*5113495bSYour Name struct wlan_objmgr_psoc *psoc;
189*5113495bSYour Name
190*5113495bSYour Name psoc = wlan_vdev_get_psoc(vdev);
191*5113495bSYour Name
192*5113495bSYour Name if (!psoc)
193*5113495bSYour Name return;
194*5113495bSYour Name
195*5113495bSYour Name sap_or_p2p_present = policy_mgr_get_beaconing_mode_count(psoc, NULL) ||
196*5113495bSYour Name policy_mgr_mode_specific_connection_count
197*5113495bSYour Name (psoc,
198*5113495bSYour Name PM_P2P_CLIENT_MODE, NULL);
199*5113495bSYour Name
200*5113495bSYour Name if (sap_or_p2p_present) {
201*5113495bSYour Name req->active_dwell_time = scan_def->conc_active_dwell;
202*5113495bSYour Name req->passive_dwell_time = scan_def->conc_passive_dwell;
203*5113495bSYour Name }
204*5113495bSYour Name }
205*5113495bSYour Name #endif
206*5113495bSYour Name
wlan_scan_cfg_get_conc_active_dwelltime(struct wlan_objmgr_psoc * psoc,uint32_t * dwell_time)207*5113495bSYour Name void wlan_scan_cfg_get_conc_active_dwelltime(struct wlan_objmgr_psoc *psoc,
208*5113495bSYour Name uint32_t *dwell_time)
209*5113495bSYour Name {
210*5113495bSYour Name struct wlan_scan_obj *scan_obj;
211*5113495bSYour Name
212*5113495bSYour Name scan_obj = wlan_psoc_get_scan_obj(psoc);
213*5113495bSYour Name if (!scan_obj)
214*5113495bSYour Name return;
215*5113495bSYour Name
216*5113495bSYour Name *dwell_time = scan_obj->scan_def.conc_active_dwell;
217*5113495bSYour Name }
218*5113495bSYour Name
wlan_scan_cfg_set_conc_active_dwelltime(struct wlan_objmgr_psoc * psoc,uint32_t dwell_time)219*5113495bSYour Name void wlan_scan_cfg_set_conc_active_dwelltime(struct wlan_objmgr_psoc *psoc,
220*5113495bSYour Name uint32_t dwell_time)
221*5113495bSYour Name {
222*5113495bSYour Name struct wlan_scan_obj *scan_obj;
223*5113495bSYour Name
224*5113495bSYour Name scan_obj = wlan_psoc_get_scan_obj(psoc);
225*5113495bSYour Name if (!scan_obj)
226*5113495bSYour Name return;
227*5113495bSYour Name
228*5113495bSYour Name scan_obj->scan_def.conc_active_dwell = dwell_time;
229*5113495bSYour Name }
230*5113495bSYour Name
wlan_scan_cfg_get_conc_passive_dwelltime(struct wlan_objmgr_psoc * psoc,uint32_t * dwell_time)231*5113495bSYour Name void wlan_scan_cfg_get_conc_passive_dwelltime(struct wlan_objmgr_psoc *psoc,
232*5113495bSYour Name uint32_t *dwell_time)
233*5113495bSYour Name {
234*5113495bSYour Name struct wlan_scan_obj *scan_obj;
235*5113495bSYour Name
236*5113495bSYour Name scan_obj = wlan_psoc_get_scan_obj(psoc);
237*5113495bSYour Name if (!scan_obj)
238*5113495bSYour Name return;
239*5113495bSYour Name
240*5113495bSYour Name *dwell_time = scan_obj->scan_def.conc_passive_dwell;
241*5113495bSYour Name }
242*5113495bSYour Name
wlan_scan_cfg_set_conc_passive_dwelltime(struct wlan_objmgr_psoc * psoc,uint32_t dwell_time)243*5113495bSYour Name void wlan_scan_cfg_set_conc_passive_dwelltime(struct wlan_objmgr_psoc *psoc,
244*5113495bSYour Name uint32_t dwell_time)
245*5113495bSYour Name {
246*5113495bSYour Name struct wlan_scan_obj *scan_obj;
247*5113495bSYour Name
248*5113495bSYour Name scan_obj = wlan_psoc_get_scan_obj(psoc);
249*5113495bSYour Name if (!scan_obj)
250*5113495bSYour Name return;
251*5113495bSYour Name
252*5113495bSYour Name scan_obj->scan_def.conc_passive_dwell = dwell_time;
253*5113495bSYour Name }
254*5113495bSYour Name
255*5113495bSYour Name void
wlan_scan_cfg_get_dfs_chan_scan_allowed(struct wlan_objmgr_psoc * psoc,bool * enable_dfs_scan)256*5113495bSYour Name wlan_scan_cfg_get_dfs_chan_scan_allowed(struct wlan_objmgr_psoc *psoc,
257*5113495bSYour Name bool *enable_dfs_scan)
258*5113495bSYour Name {
259*5113495bSYour Name struct wlan_scan_obj *scan_obj;
260*5113495bSYour Name
261*5113495bSYour Name scan_obj = wlan_psoc_get_scan_obj(psoc);
262*5113495bSYour Name if (!scan_obj)
263*5113495bSYour Name return;
264*5113495bSYour Name
265*5113495bSYour Name *enable_dfs_scan = scan_obj->scan_def.allow_dfs_chan_in_scan;
266*5113495bSYour Name }
267*5113495bSYour Name
268*5113495bSYour Name void
wlan_scan_cfg_set_dfs_chan_scan_allowed(struct wlan_objmgr_psoc * psoc,bool enable_dfs_scan)269*5113495bSYour Name wlan_scan_cfg_set_dfs_chan_scan_allowed(struct wlan_objmgr_psoc *psoc,
270*5113495bSYour Name bool enable_dfs_scan)
271*5113495bSYour Name {
272*5113495bSYour Name struct wlan_scan_obj *scan_obj;
273*5113495bSYour Name
274*5113495bSYour Name scan_obj = wlan_psoc_get_scan_obj(psoc);
275*5113495bSYour Name if (!scan_obj)
276*5113495bSYour Name return;
277*5113495bSYour Name
278*5113495bSYour Name scan_obj->scan_def.allow_dfs_chan_in_scan = enable_dfs_scan;
279*5113495bSYour Name }
280*5113495bSYour Name
wlan_scan_cfg_honour_nl_scan_policy_flags(struct wlan_objmgr_psoc * psoc)281*5113495bSYour Name bool wlan_scan_cfg_honour_nl_scan_policy_flags(struct wlan_objmgr_psoc *psoc)
282*5113495bSYour Name {
283*5113495bSYour Name struct wlan_scan_obj *scan_obj;
284*5113495bSYour Name
285*5113495bSYour Name scan_obj = wlan_psoc_get_scan_obj(psoc);
286*5113495bSYour Name if (!scan_obj)
287*5113495bSYour Name return false;
288*5113495bSYour Name
289*5113495bSYour Name return scan_obj->scan_def.honour_nl_scan_policy_flags;
290*5113495bSYour Name }
291*5113495bSYour Name
wlan_scan_cfg_get_conc_max_resttime(struct wlan_objmgr_psoc * psoc,uint32_t * rest_time)292*5113495bSYour Name void wlan_scan_cfg_get_conc_max_resttime(struct wlan_objmgr_psoc *psoc,
293*5113495bSYour Name uint32_t *rest_time)
294*5113495bSYour Name {
295*5113495bSYour Name struct wlan_scan_obj *scan_obj;
296*5113495bSYour Name
297*5113495bSYour Name scan_obj = wlan_psoc_get_scan_obj(psoc);
298*5113495bSYour Name if (!scan_obj)
299*5113495bSYour Name return;
300*5113495bSYour Name
301*5113495bSYour Name *rest_time = scan_obj->scan_def.conc_max_rest_time;
302*5113495bSYour Name }
303*5113495bSYour Name
wlan_scan_cfg_get_conc_min_resttime(struct wlan_objmgr_psoc * psoc,uint32_t * rest_time)304*5113495bSYour Name void wlan_scan_cfg_get_conc_min_resttime(struct wlan_objmgr_psoc *psoc,
305*5113495bSYour Name uint32_t *rest_time)
306*5113495bSYour Name {
307*5113495bSYour Name struct wlan_scan_obj *scan_obj;
308*5113495bSYour Name
309*5113495bSYour Name scan_obj = wlan_psoc_get_scan_obj(psoc);
310*5113495bSYour Name if (!scan_obj)
311*5113495bSYour Name return;
312*5113495bSYour Name
313*5113495bSYour Name *rest_time = scan_obj->scan_def.conc_min_rest_time;
314*5113495bSYour Name }
315*5113495bSYour Name
wlan_scan_is_snr_monitor_enabled(struct wlan_objmgr_psoc * psoc)316*5113495bSYour Name bool wlan_scan_is_snr_monitor_enabled(struct wlan_objmgr_psoc *psoc)
317*5113495bSYour Name {
318*5113495bSYour Name struct wlan_scan_obj *scan_obj;
319*5113495bSYour Name
320*5113495bSYour Name scan_obj = wlan_psoc_get_scan_obj(psoc);
321*5113495bSYour Name if (!scan_obj)
322*5113495bSYour Name return cfg_default(CFG_ENABLE_SNR_MONITORING);
323*5113495bSYour Name
324*5113495bSYour Name return scan_obj->scan_def.scan_f_chan_stat_evnt;
325*5113495bSYour Name }
326*5113495bSYour Name
327*5113495bSYour Name QDF_STATUS
wlan_scan_process_bcn_probe_rx_sync(struct wlan_objmgr_psoc * psoc,qdf_nbuf_t buf,struct mgmt_rx_event_params * rx_param,enum mgmt_frame_type frm_type)328*5113495bSYour Name wlan_scan_process_bcn_probe_rx_sync(struct wlan_objmgr_psoc *psoc,
329*5113495bSYour Name qdf_nbuf_t buf,
330*5113495bSYour Name struct mgmt_rx_event_params *rx_param,
331*5113495bSYour Name enum mgmt_frame_type frm_type)
332*5113495bSYour Name {
333*5113495bSYour Name struct scan_bcn_probe_event *bcn = NULL;
334*5113495bSYour Name QDF_STATUS status;
335*5113495bSYour Name
336*5113495bSYour Name if ((frm_type != MGMT_PROBE_RESP) &&
337*5113495bSYour Name (frm_type != MGMT_BEACON)) {
338*5113495bSYour Name scm_err("frame is not beacon or probe resp");
339*5113495bSYour Name status = QDF_STATUS_E_INVAL;
340*5113495bSYour Name goto free;
341*5113495bSYour Name }
342*5113495bSYour Name
343*5113495bSYour Name bcn = qdf_mem_malloc_atomic(sizeof(*bcn));
344*5113495bSYour Name if (!bcn) {
345*5113495bSYour Name status = QDF_STATUS_E_NOMEM;
346*5113495bSYour Name goto free;
347*5113495bSYour Name }
348*5113495bSYour Name bcn->rx_data =
349*5113495bSYour Name qdf_mem_malloc_atomic(sizeof(*rx_param));
350*5113495bSYour Name if (!bcn->rx_data) {
351*5113495bSYour Name status = QDF_STATUS_E_NOMEM;
352*5113495bSYour Name goto free;
353*5113495bSYour Name }
354*5113495bSYour Name
355*5113495bSYour Name if (frm_type == MGMT_PROBE_RESP)
356*5113495bSYour Name bcn->frm_type = MGMT_SUBTYPE_PROBE_RESP;
357*5113495bSYour Name else
358*5113495bSYour Name bcn->frm_type = MGMT_SUBTYPE_BEACON;
359*5113495bSYour Name
360*5113495bSYour Name status = wlan_objmgr_psoc_try_get_ref(psoc, WLAN_SCAN_ID);
361*5113495bSYour Name if (QDF_IS_STATUS_ERROR(status)) {
362*5113495bSYour Name scm_info("unable to get reference");
363*5113495bSYour Name goto free;
364*5113495bSYour Name }
365*5113495bSYour Name
366*5113495bSYour Name bcn->psoc = psoc;
367*5113495bSYour Name bcn->buf = buf;
368*5113495bSYour Name
369*5113495bSYour Name /*
370*5113495bSYour Name * Save the rnr entries from the frame into rnr db.
371*5113495bSYour Name * The RNR entry would have the partner links as well.
372*5113495bSYour Name * If the partner link is a non-tx profile, and if there
373*5113495bSYour Name * is no MBSSID info for that partner link, then look up
374*5113495bSYour Name * into the rnr db will help to identify if that partner
375*5113495bSYour Name * is a non-tx profile.
376*5113495bSYour Name */
377*5113495bSYour Name bcn->save_rnr_info = true;
378*5113495bSYour Name qdf_mem_copy(bcn->rx_data, rx_param, sizeof(*rx_param));
379*5113495bSYour Name
380*5113495bSYour Name return __scm_handle_bcn_probe(bcn);
381*5113495bSYour Name free:
382*5113495bSYour Name if (bcn && bcn->rx_data)
383*5113495bSYour Name qdf_mem_free(bcn->rx_data);
384*5113495bSYour Name if (bcn)
385*5113495bSYour Name qdf_mem_free(bcn);
386*5113495bSYour Name if (buf)
387*5113495bSYour Name qdf_nbuf_free(buf);
388*5113495bSYour Name
389*5113495bSYour Name return status;
390*5113495bSYour Name }
391*5113495bSYour Name
wlan_scan_get_aging_time(struct wlan_objmgr_psoc * psoc)392*5113495bSYour Name qdf_time_t wlan_scan_get_aging_time(struct wlan_objmgr_psoc *psoc)
393*5113495bSYour Name {
394*5113495bSYour Name struct wlan_scan_obj *scan_obj;
395*5113495bSYour Name
396*5113495bSYour Name scan_obj = wlan_psoc_get_scan_obj(psoc);
397*5113495bSYour Name if (!scan_obj)
398*5113495bSYour Name return cfg_default(CFG_SCAN_AGING_TIME) * 1000;
399*5113495bSYour Name
400*5113495bSYour Name return scan_obj->scan_def.scan_cache_aging_time;
401*5113495bSYour Name }
402*5113495bSYour Name
wlan_scan_set_aging_time(struct wlan_objmgr_psoc * psoc,qdf_time_t time)403*5113495bSYour Name QDF_STATUS wlan_scan_set_aging_time(struct wlan_objmgr_psoc *psoc,
404*5113495bSYour Name qdf_time_t time)
405*5113495bSYour Name {
406*5113495bSYour Name struct wlan_scan_obj *scan_obj;
407*5113495bSYour Name QDF_STATUS status = QDF_STATUS_E_FAILURE;
408*5113495bSYour Name
409*5113495bSYour Name scan_obj = wlan_psoc_get_scan_obj(psoc);
410*5113495bSYour Name if (!scan_obj)
411*5113495bSYour Name return status;
412*5113495bSYour Name
413*5113495bSYour Name if (!cfg_in_range(CFG_SCAN_AGING_TIME, time / 1000)) {
414*5113495bSYour Name status = QDF_STATUS_E_RANGE;
415*5113495bSYour Name return status;
416*5113495bSYour Name }
417*5113495bSYour Name
418*5113495bSYour Name scan_obj->scan_def.scan_cache_aging_time = time;
419*5113495bSYour Name status = QDF_STATUS_SUCCESS;
420*5113495bSYour Name return status;
421*5113495bSYour Name }
422*5113495bSYour Name
wlan_scan_start(struct scan_start_request * req)423*5113495bSYour Name QDF_STATUS wlan_scan_start(struct scan_start_request *req)
424*5113495bSYour Name {
425*5113495bSYour Name struct scheduler_msg msg = {0};
426*5113495bSYour Name QDF_STATUS status;
427*5113495bSYour Name
428*5113495bSYour Name if (!req || !req->vdev) {
429*5113495bSYour Name scm_err("req or vdev within req is NULL");
430*5113495bSYour Name scm_scan_free_scan_request_mem(req);
431*5113495bSYour Name return QDF_STATUS_E_NULL_VALUE;
432*5113495bSYour Name }
433*5113495bSYour Name
434*5113495bSYour Name if (!scm_is_scan_allowed(req->vdev)) {
435*5113495bSYour Name scm_err_rl("scan disabled, rejecting the scan req");
436*5113495bSYour Name scm_scan_free_scan_request_mem(req);
437*5113495bSYour Name return QDF_STATUS_E_AGAIN;
438*5113495bSYour Name }
439*5113495bSYour Name
440*5113495bSYour Name /*
441*5113495bSYour Name * Try to get vdev reference. Return if reference could
442*5113495bSYour Name * not be taken. Reference will be released once scan
443*5113495bSYour Name * request handling completes along with free of @req.
444*5113495bSYour Name */
445*5113495bSYour Name status = wlan_objmgr_vdev_try_get_ref(req->vdev, WLAN_SCAN_ID);
446*5113495bSYour Name if (QDF_IS_STATUS_ERROR(status)) {
447*5113495bSYour Name scm_info("unable to get reference");
448*5113495bSYour Name scm_scan_free_scan_request_mem(req);
449*5113495bSYour Name return status;
450*5113495bSYour Name }
451*5113495bSYour Name
452*5113495bSYour Name msg.bodyptr = req;
453*5113495bSYour Name msg.callback = scm_scan_start_req;
454*5113495bSYour Name msg.flush_callback = scm_scan_start_flush_callback;
455*5113495bSYour Name
456*5113495bSYour Name status = scheduler_post_message(QDF_MODULE_ID_OS_IF,
457*5113495bSYour Name QDF_MODULE_ID_SCAN,
458*5113495bSYour Name QDF_MODULE_ID_OS_IF, &msg);
459*5113495bSYour Name if (QDF_IS_STATUS_ERROR(status)) {
460*5113495bSYour Name wlan_objmgr_vdev_release_ref(req->vdev, WLAN_SCAN_ID);
461*5113495bSYour Name scm_scan_free_scan_request_mem(req);
462*5113495bSYour Name }
463*5113495bSYour Name
464*5113495bSYour Name return status;
465*5113495bSYour Name }
466*5113495bSYour Name
wlan_scan_cancel(struct scan_cancel_request * req)467*5113495bSYour Name QDF_STATUS wlan_scan_cancel(struct scan_cancel_request *req)
468*5113495bSYour Name {
469*5113495bSYour Name struct scheduler_msg msg = {0};
470*5113495bSYour Name QDF_STATUS status;
471*5113495bSYour Name
472*5113495bSYour Name if (!req || !req->vdev) {
473*5113495bSYour Name scm_err("req or vdev within req is NULL");
474*5113495bSYour Name if (req)
475*5113495bSYour Name qdf_mem_free(req);
476*5113495bSYour Name return QDF_STATUS_E_NULL_VALUE;
477*5113495bSYour Name }
478*5113495bSYour Name
479*5113495bSYour Name status = wlan_objmgr_vdev_try_get_ref(req->vdev, WLAN_SCAN_ID);
480*5113495bSYour Name if (QDF_IS_STATUS_ERROR(status)) {
481*5113495bSYour Name scm_info("Failed to get vdev ref; status:%d", status);
482*5113495bSYour Name goto req_free;
483*5113495bSYour Name }
484*5113495bSYour Name
485*5113495bSYour Name msg.bodyptr = req;
486*5113495bSYour Name msg.callback = scm_scan_cancel_req;
487*5113495bSYour Name msg.flush_callback = scm_scan_cancel_flush_callback;
488*5113495bSYour Name
489*5113495bSYour Name status = scheduler_post_message(QDF_MODULE_ID_OS_IF,
490*5113495bSYour Name QDF_MODULE_ID_SCAN,
491*5113495bSYour Name QDF_MODULE_ID_OS_IF, &msg);
492*5113495bSYour Name if (QDF_IS_STATUS_ERROR(status))
493*5113495bSYour Name goto vdev_put;
494*5113495bSYour Name
495*5113495bSYour Name return QDF_STATUS_SUCCESS;
496*5113495bSYour Name
497*5113495bSYour Name vdev_put:
498*5113495bSYour Name wlan_objmgr_vdev_release_ref(req->vdev, WLAN_SCAN_ID);
499*5113495bSYour Name
500*5113495bSYour Name req_free:
501*5113495bSYour Name qdf_mem_free(req);
502*5113495bSYour Name
503*5113495bSYour Name return status;
504*5113495bSYour Name }
505*5113495bSYour Name
506*5113495bSYour Name wlan_scan_id
wlan_scan_get_scan_id(struct wlan_objmgr_psoc * psoc)507*5113495bSYour Name wlan_scan_get_scan_id(struct wlan_objmgr_psoc *psoc)
508*5113495bSYour Name {
509*5113495bSYour Name wlan_scan_id id;
510*5113495bSYour Name struct wlan_scan_obj *scan;
511*5113495bSYour Name
512*5113495bSYour Name if (!psoc) {
513*5113495bSYour Name QDF_ASSERT(0);
514*5113495bSYour Name scm_err("null psoc");
515*5113495bSYour Name return 0;
516*5113495bSYour Name }
517*5113495bSYour Name
518*5113495bSYour Name scan = wlan_psoc_get_scan_obj(psoc);
519*5113495bSYour Name if (!scan) {
520*5113495bSYour Name scm_err("scan object null");
521*5113495bSYour Name return 0;
522*5113495bSYour Name }
523*5113495bSYour Name
524*5113495bSYour Name id = qdf_atomic_inc_return(&scan->scan_ids);
525*5113495bSYour Name id = id & WLAN_SCAN_ID_MASK;
526*5113495bSYour Name /* Mark this scan request as triggered by host
527*5113495bSYour Name * by setting WLAN_HOST_SCAN_REQ_ID_PREFIX flag.
528*5113495bSYour Name */
529*5113495bSYour Name id = id | WLAN_HOST_SCAN_REQ_ID_PREFIX;
530*5113495bSYour Name scm_debug("scan_id: 0x%x", id);
531*5113495bSYour Name
532*5113495bSYour Name return id;
533*5113495bSYour Name }
534*5113495bSYour Name
535*5113495bSYour Name QDF_STATUS
wlan_scan_init_default_params(struct wlan_objmgr_vdev * vdev,struct scan_start_request * req)536*5113495bSYour Name wlan_scan_init_default_params(struct wlan_objmgr_vdev *vdev,
537*5113495bSYour Name struct scan_start_request *req)
538*5113495bSYour Name {
539*5113495bSYour Name struct scan_default_params *def;
540*5113495bSYour Name
541*5113495bSYour Name if (!vdev | !req) {
542*5113495bSYour Name scm_err("vdev: 0x%pK, req: 0x%pK", vdev, req);
543*5113495bSYour Name return QDF_STATUS_E_INVAL;
544*5113495bSYour Name }
545*5113495bSYour Name def = wlan_vdev_get_def_scan_params(vdev);
546*5113495bSYour Name if (!def) {
547*5113495bSYour Name scm_err("wlan_vdev_get_def_scan_params returned NULL");
548*5113495bSYour Name return QDF_STATUS_E_NULL_VALUE;
549*5113495bSYour Name }
550*5113495bSYour Name
551*5113495bSYour Name /* Zero out everything and explicitly set fields as required */
552*5113495bSYour Name qdf_mem_zero(req, sizeof(*req));
553*5113495bSYour Name
554*5113495bSYour Name req->vdev = vdev;
555*5113495bSYour Name req->scan_req.vdev_id = wlan_vdev_get_id(vdev);
556*5113495bSYour Name req->scan_req.scan_type = SCAN_TYPE_DEFAULT;
557*5113495bSYour Name req->scan_req.scan_priority = def->scan_priority;
558*5113495bSYour Name req->scan_req.dwell_time_active = def->active_dwell;
559*5113495bSYour Name req->scan_req.dwell_time_active_2g = def->active_dwell_2g;
560*5113495bSYour Name req->scan_req.min_dwell_time_6g = def->min_dwell_time_6g;
561*5113495bSYour Name req->scan_req.dwell_time_active_6g = def->active_dwell_6g;
562*5113495bSYour Name req->scan_req.dwell_time_passive_6g = def->passive_dwell_6g;
563*5113495bSYour Name req->scan_req.dwell_time_passive = def->passive_dwell;
564*5113495bSYour Name req->scan_req.min_rest_time = def->min_rest_time;
565*5113495bSYour Name req->scan_req.max_rest_time = def->max_rest_time;
566*5113495bSYour Name req->scan_req.repeat_probe_time = def->repeat_probe_time;
567*5113495bSYour Name req->scan_req.probe_spacing_time = def->probe_spacing_time;
568*5113495bSYour Name req->scan_req.idle_time = def->idle_time;
569*5113495bSYour Name req->scan_req.max_scan_time = def->max_scan_time;
570*5113495bSYour Name req->scan_req.probe_delay = def->probe_delay;
571*5113495bSYour Name req->scan_req.burst_duration = def->burst_duration;
572*5113495bSYour Name req->scan_req.n_probes = def->num_probes;
573*5113495bSYour Name req->scan_req.adaptive_dwell_time_mode =
574*5113495bSYour Name def->adaptive_dwell_time_mode;
575*5113495bSYour Name req->scan_req.scan_flags = def->scan_flags;
576*5113495bSYour Name req->scan_req.scan_events = def->scan_events;
577*5113495bSYour Name req->scan_req.scan_random.randomize = def->enable_mac_spoofing;
578*5113495bSYour Name
579*5113495bSYour Name return QDF_STATUS_SUCCESS;
580*5113495bSYour Name }
581*5113495bSYour Name
582*5113495bSYour Name wlan_scan_requester
wlan_scan_register_requester(struct wlan_objmgr_psoc * psoc,uint8_t * name,scan_event_handler event_cb,void * arg)583*5113495bSYour Name wlan_scan_register_requester(struct wlan_objmgr_psoc *psoc,
584*5113495bSYour Name uint8_t *name,
585*5113495bSYour Name scan_event_handler event_cb,
586*5113495bSYour Name void *arg)
587*5113495bSYour Name {
588*5113495bSYour Name int i, j;
589*5113495bSYour Name struct wlan_scan_obj *scan;
590*5113495bSYour Name struct scan_requester_info *requesters;
591*5113495bSYour Name wlan_scan_requester requester = {0};
592*5113495bSYour Name
593*5113495bSYour Name if (!psoc) {
594*5113495bSYour Name scm_err("null psoc");
595*5113495bSYour Name return 0;
596*5113495bSYour Name }
597*5113495bSYour Name scan = wlan_psoc_get_scan_obj(psoc);
598*5113495bSYour Name if (!scan)
599*5113495bSYour Name return 0;
600*5113495bSYour Name
601*5113495bSYour Name requesters = scan->requesters;
602*5113495bSYour Name qdf_spin_lock_bh(&scan->lock);
603*5113495bSYour Name for (i = 0; i < WLAN_MAX_REQUESTORS; ++i) {
604*5113495bSYour Name if (requesters[i].requester == 0) {
605*5113495bSYour Name requesters[i].requester =
606*5113495bSYour Name WLAN_SCAN_REQUESTER_ID_PREFIX | i;
607*5113495bSYour Name j = 0;
608*5113495bSYour Name while (name[j] && (j < (WLAN_MAX_MODULE_NAME - 1))) {
609*5113495bSYour Name requesters[i].module[j] = name[j];
610*5113495bSYour Name ++j;
611*5113495bSYour Name }
612*5113495bSYour Name requesters[i].module[j] = 0;
613*5113495bSYour Name requesters[i].ev_handler.func = event_cb;
614*5113495bSYour Name requesters[i].ev_handler.arg = arg;
615*5113495bSYour Name requester = requesters[i].requester;
616*5113495bSYour Name break;
617*5113495bSYour Name }
618*5113495bSYour Name }
619*5113495bSYour Name qdf_spin_unlock_bh(&scan->lock);
620*5113495bSYour Name scm_debug("module: %s, event_cb: 0x%pK, arg: 0x%pK, reqid: %d",
621*5113495bSYour Name name, event_cb, arg, requester);
622*5113495bSYour Name
623*5113495bSYour Name return requester;
624*5113495bSYour Name }
625*5113495bSYour Name
626*5113495bSYour Name void
wlan_scan_unregister_requester(struct wlan_objmgr_psoc * psoc,wlan_scan_requester requester)627*5113495bSYour Name wlan_scan_unregister_requester(struct wlan_objmgr_psoc *psoc,
628*5113495bSYour Name wlan_scan_requester requester)
629*5113495bSYour Name {
630*5113495bSYour Name int idx;
631*5113495bSYour Name struct wlan_scan_obj *scan;
632*5113495bSYour Name struct scan_requester_info *requesters;
633*5113495bSYour Name
634*5113495bSYour Name idx = requester & WLAN_SCAN_REQUESTER_ID_PREFIX;
635*5113495bSYour Name if (idx != WLAN_SCAN_REQUESTER_ID_PREFIX) {
636*5113495bSYour Name scm_err("prefix didn't match for requester id %d", requester);
637*5113495bSYour Name return;
638*5113495bSYour Name }
639*5113495bSYour Name
640*5113495bSYour Name idx = requester & WLAN_SCAN_REQUESTER_ID_MASK;
641*5113495bSYour Name if (idx >= WLAN_MAX_REQUESTORS) {
642*5113495bSYour Name scm_err("requester id %d greater than max value", requester);
643*5113495bSYour Name return;
644*5113495bSYour Name }
645*5113495bSYour Name
646*5113495bSYour Name if (!psoc) {
647*5113495bSYour Name scm_err("null psoc");
648*5113495bSYour Name return;
649*5113495bSYour Name }
650*5113495bSYour Name scan = wlan_psoc_get_scan_obj(psoc);
651*5113495bSYour Name if (!scan)
652*5113495bSYour Name return;
653*5113495bSYour Name requesters = scan->requesters;
654*5113495bSYour Name scm_debug("reqid: %d", requester);
655*5113495bSYour Name
656*5113495bSYour Name qdf_spin_lock_bh(&scan->lock);
657*5113495bSYour Name requesters[idx].requester = 0;
658*5113495bSYour Name requesters[idx].module[0] = 0;
659*5113495bSYour Name requesters[idx].ev_handler.func = NULL;
660*5113495bSYour Name requesters[idx].ev_handler.arg = NULL;
661*5113495bSYour Name qdf_spin_unlock_bh(&scan->lock);
662*5113495bSYour Name }
663*5113495bSYour Name
wlan_scan_cfg_skip_6g_and_indoor_freq(struct wlan_objmgr_psoc * psoc)664*5113495bSYour Name bool wlan_scan_cfg_skip_6g_and_indoor_freq(struct wlan_objmgr_psoc *psoc)
665*5113495bSYour Name {
666*5113495bSYour Name struct wlan_scan_obj *scan_obj;
667*5113495bSYour Name
668*5113495bSYour Name scan_obj = wlan_psoc_get_scan_obj(psoc);
669*5113495bSYour Name if (!scan_obj)
670*5113495bSYour Name return false;
671*5113495bSYour Name
672*5113495bSYour Name return scan_obj->scan_def.skip_6g_and_indoor_freq;
673*5113495bSYour Name }
674*5113495bSYour Name
wlan_scan_get_last_scan_ageout_time(struct wlan_objmgr_psoc * psoc,uint32_t * last_scan_ageout_time)675*5113495bSYour Name void wlan_scan_get_last_scan_ageout_time(struct wlan_objmgr_psoc *psoc,
676*5113495bSYour Name uint32_t *last_scan_ageout_time)
677*5113495bSYour Name {
678*5113495bSYour Name struct wlan_scan_obj *scan_obj;
679*5113495bSYour Name
680*5113495bSYour Name scan_obj = wlan_psoc_get_scan_obj(psoc);
681*5113495bSYour Name if (!scan_obj) {
682*5113495bSYour Name *last_scan_ageout_time = 0;
683*5113495bSYour Name return;
684*5113495bSYour Name }
685*5113495bSYour Name *last_scan_ageout_time =
686*5113495bSYour Name scan_obj->scan_def.last_scan_ageout_time;
687*5113495bSYour Name }
688*5113495bSYour Name
689*5113495bSYour Name #ifdef FEATURE_SET
690*5113495bSYour Name /**
691*5113495bSYour Name * wlan_scan_get_pno_scan_support() - Check if pno scan support is enabled
692*5113495bSYour Name * @psoc: pointer to psoc object
693*5113495bSYour Name *
694*5113495bSYour Name * Return: pno scan_support_enabled flag
695*5113495bSYour Name */
wlan_scan_get_pno_scan_support(struct wlan_objmgr_psoc * psoc)696*5113495bSYour Name static bool wlan_scan_get_pno_scan_support(struct wlan_objmgr_psoc *psoc)
697*5113495bSYour Name {
698*5113495bSYour Name struct wlan_scan_obj *scan_obj;
699*5113495bSYour Name
700*5113495bSYour Name scan_obj = wlan_psoc_get_scan_obj(psoc);
701*5113495bSYour Name if (!scan_obj) {
702*5113495bSYour Name scm_err("NULL scan obj");
703*5113495bSYour Name return cfg_default(CFG_PNO_SCAN_SUPPORT);
704*5113495bSYour Name }
705*5113495bSYour Name
706*5113495bSYour Name return scan_obj->pno_cfg.scan_support_enabled;
707*5113495bSYour Name }
708*5113495bSYour Name
709*5113495bSYour Name /**
710*5113495bSYour Name * wlan_scan_is_connected_scan_enabled() - API to get scan enabled after connect
711*5113495bSYour Name * @psoc: pointer to psoc object
712*5113495bSYour Name *
713*5113495bSYour Name * Return: value.
714*5113495bSYour Name */
wlan_scan_is_connected_scan_enabled(struct wlan_objmgr_psoc * psoc)715*5113495bSYour Name static bool wlan_scan_is_connected_scan_enabled(struct wlan_objmgr_psoc *psoc)
716*5113495bSYour Name {
717*5113495bSYour Name struct wlan_scan_obj *scan_obj;
718*5113495bSYour Name
719*5113495bSYour Name scan_obj = wlan_psoc_get_scan_obj(psoc);
720*5113495bSYour Name if (!scan_obj) {
721*5113495bSYour Name scm_err("Failed to get scan object");
722*5113495bSYour Name return cfg_default(CFG_ENABLE_CONNECTED_SCAN);
723*5113495bSYour Name }
724*5113495bSYour Name
725*5113495bSYour Name return scan_obj->scan_def.enable_connected_scan;
726*5113495bSYour Name }
727*5113495bSYour Name
wlan_scan_get_feature_info(struct wlan_objmgr_psoc * psoc,struct wlan_scan_features * scan_feature_set)728*5113495bSYour Name void wlan_scan_get_feature_info(struct wlan_objmgr_psoc *psoc,
729*5113495bSYour Name struct wlan_scan_features *scan_feature_set)
730*5113495bSYour Name {
731*5113495bSYour Name scan_feature_set->pno_in_unassoc_state =
732*5113495bSYour Name wlan_scan_get_pno_scan_support(psoc);
733*5113495bSYour Name if (scan_feature_set->pno_in_unassoc_state)
734*5113495bSYour Name scan_feature_set->pno_in_assoc_state =
735*5113495bSYour Name wlan_scan_is_connected_scan_enabled(psoc);
736*5113495bSYour Name }
737*5113495bSYour Name #endif
738*5113495bSYour Name
739*5113495bSYour Name #ifdef WLAN_POLICY_MGR_ENABLE
740*5113495bSYour Name /**
741*5113495bSYour Name * wlan_scan_update_hint_bssid() - Update rnr hint bssid info
742*5113495bSYour Name * @psoc: objmgr psoc
743*5113495bSYour Name * @req: Scan request
744*5113495bSYour Name * @ll_sap_freq: ll sap freq
745*5113495bSYour Name *
746*5113495bSYour Name * Use to update hint_bssid if low latency Sap is UP
747*5113495bSYour Name *
748*5113495bSYour Name * Return: void
749*5113495bSYour Name */
750*5113495bSYour Name static void
wlan_scan_update_hint_bssid(struct wlan_objmgr_psoc * psoc,struct scan_start_request * req,qdf_freq_t ll_sap_freq)751*5113495bSYour Name wlan_scan_update_hint_bssid(struct wlan_objmgr_psoc *psoc,
752*5113495bSYour Name struct scan_start_request *req,
753*5113495bSYour Name qdf_freq_t ll_sap_freq)
754*5113495bSYour Name {
755*5113495bSYour Name struct hint_bssid hint_bssid[WLAN_SCAN_MAX_HINT_BSSID] = {0};
756*5113495bSYour Name uint32_t i;
757*5113495bSYour Name uint32_t count = 0;
758*5113495bSYour Name qdf_freq_t freq;
759*5113495bSYour Name
760*5113495bSYour Name if (!req->scan_req.num_hint_bssid)
761*5113495bSYour Name return;
762*5113495bSYour Name
763*5113495bSYour Name for (i = 0; i < req->scan_req.num_hint_bssid; i++) {
764*5113495bSYour Name freq = req->scan_req.hint_bssid[i].freq_flags >> 16;
765*5113495bSYour Name if (!freq)
766*5113495bSYour Name continue;
767*5113495bSYour Name if (!policy_mgr_2_freq_always_on_same_mac(psoc,
768*5113495bSYour Name ll_sap_freq,
769*5113495bSYour Name freq)) {
770*5113495bSYour Name qdf_mem_copy(
771*5113495bSYour Name &hint_bssid[count].bssid,
772*5113495bSYour Name &req->scan_req.hint_bssid[i].bssid,
773*5113495bSYour Name sizeof(hint_bssid[i].bssid));
774*5113495bSYour Name hint_bssid[count].freq_flags =
775*5113495bSYour Name req->scan_req.hint_bssid[i].freq_flags;
776*5113495bSYour Name count++;
777*5113495bSYour Name }
778*5113495bSYour Name }
779*5113495bSYour Name qdf_mem_zero(req->scan_req.hint_bssid,
780*5113495bSYour Name sizeof(req->scan_req.hint_bssid));
781*5113495bSYour Name if (count)
782*5113495bSYour Name qdf_mem_copy(req->scan_req.hint_bssid, hint_bssid,
783*5113495bSYour Name sizeof(hint_bssid));
784*5113495bSYour Name req->scan_req.num_hint_bssid = count;
785*5113495bSYour Name }
786*5113495bSYour Name
787*5113495bSYour Name /**
788*5113495bSYour Name * wlan_scan_update_hint_s_ssid() - Update rnr hint short ssid info
789*5113495bSYour Name * @psoc: objmgr psoc
790*5113495bSYour Name * @req: Scan request
791*5113495bSYour Name * @ll_sap_freq: ll sap freq
792*5113495bSYour Name *
793*5113495bSYour Name * Use to update hint_s_ssid if low latency Sap is UP
794*5113495bSYour Name *
795*5113495bSYour Name * Return: void
796*5113495bSYour Name */
797*5113495bSYour Name static
wlan_scan_update_hint_s_ssid(struct wlan_objmgr_psoc * psoc,struct scan_start_request * req,qdf_freq_t ll_sap_freq)798*5113495bSYour Name void wlan_scan_update_hint_s_ssid(struct wlan_objmgr_psoc *psoc,
799*5113495bSYour Name struct scan_start_request *req,
800*5113495bSYour Name qdf_freq_t ll_sap_freq)
801*5113495bSYour Name {
802*5113495bSYour Name struct hint_short_ssid hint_s_ssid[WLAN_SCAN_MAX_HINT_BSSID] = {0};
803*5113495bSYour Name uint32_t i;
804*5113495bSYour Name uint32_t count = 0;
805*5113495bSYour Name qdf_freq_t freq;
806*5113495bSYour Name
807*5113495bSYour Name if (!req->scan_req.num_hint_s_ssid)
808*5113495bSYour Name return;
809*5113495bSYour Name
810*5113495bSYour Name for (i = 0; i < req->scan_req.num_hint_s_ssid; i++) {
811*5113495bSYour Name freq = req->scan_req.hint_s_ssid[i].freq_flags >> 16;
812*5113495bSYour Name if (!freq)
813*5113495bSYour Name continue;
814*5113495bSYour Name if (!policy_mgr_2_freq_always_on_same_mac(psoc,
815*5113495bSYour Name ll_sap_freq,
816*5113495bSYour Name freq)) {
817*5113495bSYour Name qdf_mem_copy(
818*5113495bSYour Name &hint_s_ssid[count].short_ssid,
819*5113495bSYour Name &req->scan_req.hint_s_ssid[i].short_ssid,
820*5113495bSYour Name sizeof(hint_s_ssid[i].short_ssid));
821*5113495bSYour Name hint_s_ssid[count].freq_flags =
822*5113495bSYour Name req->scan_req.hint_s_ssid[i].freq_flags;
823*5113495bSYour Name count++;
824*5113495bSYour Name }
825*5113495bSYour Name }
826*5113495bSYour Name qdf_mem_zero(req->scan_req.hint_s_ssid,
827*5113495bSYour Name sizeof(req->scan_req.hint_s_ssid));
828*5113495bSYour Name if (count)
829*5113495bSYour Name qdf_mem_copy(req->scan_req.hint_s_ssid, hint_s_ssid,
830*5113495bSYour Name sizeof(hint_s_ssid));
831*5113495bSYour Name req->scan_req.num_hint_s_ssid = count;
832*5113495bSYour Name }
833*5113495bSYour Name
wlan_scan_update_low_latency_profile_chnlist(struct wlan_objmgr_vdev * vdev,struct scan_start_request * req)834*5113495bSYour Name void wlan_scan_update_low_latency_profile_chnlist(
835*5113495bSYour Name struct wlan_objmgr_vdev *vdev,
836*5113495bSYour Name struct scan_start_request *req)
837*5113495bSYour Name {
838*5113495bSYour Name uint32_t num_scan_channels = 0, i;
839*5113495bSYour Name struct wlan_objmgr_psoc *psoc;
840*5113495bSYour Name qdf_freq_t freq, ll_sap_freq;
841*5113495bSYour Name
842*5113495bSYour Name psoc = wlan_vdev_get_psoc(vdev);
843*5113495bSYour Name if (!psoc) {
844*5113495bSYour Name scm_err("psoc is null");
845*5113495bSYour Name return;
846*5113495bSYour Name }
847*5113495bSYour Name
848*5113495bSYour Name /*
849*5113495bSYour Name * Get ll_sap freq api will be cleaned up once macro is enabled
850*5113495bSYour Name */
851*5113495bSYour Name #ifndef WLAN_FEATURE_LL_LT_SAP
852*5113495bSYour Name ll_sap_freq = policy_mgr_get_ll_sap_freq(psoc);
853*5113495bSYour Name #else
854*5113495bSYour Name ll_sap_freq = policy_mgr_get_ll_ht_sap_freq(psoc);
855*5113495bSYour Name #endif
856*5113495bSYour Name
857*5113495bSYour Name if (!ll_sap_freq)
858*5113495bSYour Name return;
859*5113495bSYour Name
860*5113495bSYour Name wlan_scan_update_hint_bssid(psoc, req, ll_sap_freq);
861*5113495bSYour Name wlan_scan_update_hint_s_ssid(psoc, req, ll_sap_freq);
862*5113495bSYour Name /*
863*5113495bSYour Name * Scenario: LL SAP is present and scan is requested.
864*5113495bSYour Name * Allow scan on freq on mutually exclusive mac.
865*5113495bSYour Name */
866*5113495bSYour Name for (i = 0; i < req->scan_req.chan_list.num_chan; i++) {
867*5113495bSYour Name freq = req->scan_req.chan_list.chan[i].freq;
868*5113495bSYour Name if (policy_mgr_2_freq_always_on_same_mac(psoc,
869*5113495bSYour Name ll_sap_freq,
870*5113495bSYour Name freq))
871*5113495bSYour Name continue;
872*5113495bSYour Name
873*5113495bSYour Name req->scan_req.chan_list.chan[num_scan_channels++] =
874*5113495bSYour Name req->scan_req.chan_list.chan[i];
875*5113495bSYour Name }
876*5113495bSYour Name if (num_scan_channels < req->scan_req.chan_list.num_chan)
877*5113495bSYour Name scm_debug("For DBS: only 2.4Ghz chan and for SBS: mutually exclusive ll-sap 5GHz chan allowed, total-chan %d, remaining-chan %d, ll-sap chan %d",
878*5113495bSYour Name req->scan_req.chan_list.num_chan,
879*5113495bSYour Name num_scan_channels,
880*5113495bSYour Name ll_sap_freq);
881*5113495bSYour Name req->scan_req.chan_list.num_chan = num_scan_channels;
882*5113495bSYour Name }
883*5113495bSYour Name #endif
884*5113495bSYour Name
885*5113495bSYour Name QDF_STATUS
wlan_scan_get_entry_by_mac_addr(struct wlan_objmgr_pdev * pdev,struct qdf_mac_addr * bssid,struct element_info * frame)886*5113495bSYour Name wlan_scan_get_entry_by_mac_addr(struct wlan_objmgr_pdev *pdev,
887*5113495bSYour Name struct qdf_mac_addr *bssid,
888*5113495bSYour Name struct element_info *frame)
889*5113495bSYour Name {
890*5113495bSYour Name return scm_scan_get_entry_by_mac_addr(pdev, bssid, frame);
891*5113495bSYour Name }
892*5113495bSYour Name
wlan_scan_register_mbssid_cb(struct wlan_objmgr_psoc * psoc,update_mbssid_bcn_prb_rsp cb)893*5113495bSYour Name QDF_STATUS wlan_scan_register_mbssid_cb(struct wlan_objmgr_psoc *psoc,
894*5113495bSYour Name update_mbssid_bcn_prb_rsp cb)
895*5113495bSYour Name {
896*5113495bSYour Name return scm_scan_register_mbssid_cb(psoc, cb);
897*5113495bSYour Name }
898*5113495bSYour Name
899*5113495bSYour Name struct scan_cache_entry *
wlan_scan_get_entry_by_bssid(struct wlan_objmgr_pdev * pdev,struct qdf_mac_addr * bssid)900*5113495bSYour Name wlan_scan_get_entry_by_bssid(struct wlan_objmgr_pdev *pdev,
901*5113495bSYour Name struct qdf_mac_addr *bssid)
902*5113495bSYour Name {
903*5113495bSYour Name return scm_scan_get_entry_by_bssid(pdev, bssid);
904*5113495bSYour Name }
905*5113495bSYour Name
906*5113495bSYour Name QDF_STATUS
wlan_scan_get_mld_addr_by_link_addr(struct wlan_objmgr_pdev * pdev,struct qdf_mac_addr * link_addr,struct qdf_mac_addr * mld_mac_addr)907*5113495bSYour Name wlan_scan_get_mld_addr_by_link_addr(struct wlan_objmgr_pdev *pdev,
908*5113495bSYour Name struct qdf_mac_addr *link_addr,
909*5113495bSYour Name struct qdf_mac_addr *mld_mac_addr)
910*5113495bSYour Name {
911*5113495bSYour Name return scm_get_mld_addr_by_link_addr(pdev, link_addr, mld_mac_addr);
912*5113495bSYour Name }
913*5113495bSYour Name
914*5113495bSYour Name struct scan_cache_entry *
wlan_scan_get_scan_entry_by_mac_freq(struct wlan_objmgr_pdev * pdev,struct qdf_mac_addr * bssid,uint16_t freq)915*5113495bSYour Name wlan_scan_get_scan_entry_by_mac_freq(struct wlan_objmgr_pdev *pdev,
916*5113495bSYour Name struct qdf_mac_addr *bssid,
917*5113495bSYour Name uint16_t freq)
918*5113495bSYour Name {
919*5113495bSYour Name return scm_scan_get_scan_entry_by_mac_freq(pdev, bssid, freq);
920*5113495bSYour Name }
921*5113495bSYour Name
wlan_scan_get_aux_support(struct wlan_objmgr_psoc * psoc)922*5113495bSYour Name bool wlan_scan_get_aux_support(struct wlan_objmgr_psoc *psoc)
923*5113495bSYour Name
924*5113495bSYour Name {
925*5113495bSYour Name struct wlan_scan_obj *scan_obj;
926*5113495bSYour Name
927*5113495bSYour Name scan_obj = wlan_psoc_get_scan_obj(psoc);
928*5113495bSYour Name if (!scan_obj)
929*5113495bSYour Name return false;
930*5113495bSYour Name
931*5113495bSYour Name if (scan_obj->aux_mac_support)
932*5113495bSYour Name scm_debug("aux mac support: %d", scan_obj->aux_mac_support);
933*5113495bSYour Name else
934*5113495bSYour Name scm_debug("aux mac not supported");
935*5113495bSYour Name
936*5113495bSYour Name return scan_obj->aux_mac_support;
937*5113495bSYour Name }
938*5113495bSYour Name
939