1 /* 2 * Copyright (c) 2017-2020 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: This file contains all SCAN component's APIs 21 */ 22 23 #include "cfg_ucfg_api.h" 24 #include "wlan_scan_api.h" 25 26 void wlan_scan_cfg_get_passive_dwelltime(struct wlan_objmgr_psoc *psoc, 27 uint32_t *dwell_time) 28 { 29 struct wlan_scan_obj *scan_obj; 30 31 scan_obj = wlan_psoc_get_scan_obj(psoc); 32 if (!scan_obj) 33 return; 34 *dwell_time = scan_obj->scan_def.passive_dwell; 35 } 36 37 void wlan_scan_cfg_set_passive_dwelltime(struct wlan_objmgr_psoc *psoc, 38 uint32_t dwell_time) 39 { 40 struct wlan_scan_obj *scan_obj; 41 42 scan_obj = wlan_psoc_get_scan_obj(psoc); 43 if (!scan_obj) 44 return; 45 scan_obj->scan_def.passive_dwell = dwell_time; 46 } 47 48 void wlan_scan_cfg_get_active_dwelltime(struct wlan_objmgr_psoc *psoc, 49 uint32_t *dwell_time) 50 { 51 struct wlan_scan_obj *scan_obj; 52 53 scan_obj = wlan_psoc_get_scan_obj(psoc); 54 if (!scan_obj) 55 return; 56 *dwell_time = scan_obj->scan_def.active_dwell; 57 } 58 59 void wlan_scan_cfg_set_active_dwelltime(struct wlan_objmgr_psoc *psoc, 60 uint32_t dwell_time) 61 { 62 struct wlan_scan_obj *scan_obj; 63 64 scan_obj = wlan_psoc_get_scan_obj(psoc); 65 if (!scan_obj) 66 return; 67 scan_obj->scan_def.active_dwell = dwell_time; 68 } 69 70 void wlan_scan_cfg_get_active_2g_dwelltime(struct wlan_objmgr_psoc *psoc, 71 uint32_t *dwell_time) 72 { 73 struct wlan_scan_obj *scan_obj; 74 75 scan_obj = wlan_psoc_get_scan_obj(psoc); 76 if (!scan_obj) 77 return; 78 79 *dwell_time = scan_obj->scan_def.active_dwell_2g; 80 } 81 82 void wlan_scan_cfg_set_active_2g_dwelltime(struct wlan_objmgr_psoc *psoc, 83 uint32_t dwell_time) 84 { 85 struct wlan_scan_obj *scan_obj; 86 87 scan_obj = wlan_psoc_get_scan_obj(psoc); 88 if (!scan_obj) 89 return; 90 scan_obj->scan_def.active_dwell_2g = dwell_time; 91 } 92 93 void wlan_scan_cfg_get_conc_active_dwelltime(struct wlan_objmgr_psoc *psoc, 94 uint32_t *dwell_time) 95 { 96 struct wlan_scan_obj *scan_obj; 97 98 scan_obj = wlan_psoc_get_scan_obj(psoc); 99 if (!scan_obj) 100 return; 101 102 *dwell_time = scan_obj->scan_def.conc_active_dwell; 103 } 104 105 void wlan_scan_cfg_set_conc_active_dwelltime(struct wlan_objmgr_psoc *psoc, 106 uint32_t dwell_time) 107 { 108 struct wlan_scan_obj *scan_obj; 109 110 scan_obj = wlan_psoc_get_scan_obj(psoc); 111 if (!scan_obj) 112 return; 113 114 scan_obj->scan_def.conc_active_dwell = dwell_time; 115 } 116 117 void wlan_scan_cfg_get_conc_passive_dwelltime(struct wlan_objmgr_psoc *psoc, 118 uint32_t *dwell_time) 119 { 120 struct wlan_scan_obj *scan_obj; 121 122 scan_obj = wlan_psoc_get_scan_obj(psoc); 123 if (!scan_obj) 124 return; 125 126 *dwell_time = scan_obj->scan_def.conc_passive_dwell; 127 } 128 129 void wlan_scan_cfg_set_conc_passive_dwelltime(struct wlan_objmgr_psoc *psoc, 130 uint32_t dwell_time) 131 { 132 struct wlan_scan_obj *scan_obj; 133 134 scan_obj = wlan_psoc_get_scan_obj(psoc); 135 if (!scan_obj) 136 return; 137 138 scan_obj->scan_def.conc_passive_dwell = dwell_time; 139 } 140 141 void 142 wlan_scan_cfg_get_dfs_chan_scan_allowed(struct wlan_objmgr_psoc *psoc, 143 bool *enable_dfs_scan) 144 { 145 struct wlan_scan_obj *scan_obj; 146 147 scan_obj = wlan_psoc_get_scan_obj(psoc); 148 if (!scan_obj) 149 return; 150 151 *enable_dfs_scan = scan_obj->scan_def.allow_dfs_chan_in_scan; 152 } 153 154 void 155 wlan_scan_cfg_set_dfs_chan_scan_allowed(struct wlan_objmgr_psoc *psoc, 156 bool enable_dfs_scan) 157 { 158 struct wlan_scan_obj *scan_obj; 159 160 scan_obj = wlan_psoc_get_scan_obj(psoc); 161 if (!scan_obj) 162 return; 163 164 scan_obj->scan_def.allow_dfs_chan_in_scan = enable_dfs_scan; 165 } 166 167 bool wlan_scan_cfg_honour_nl_scan_policy_flags(struct wlan_objmgr_psoc *psoc) 168 { 169 struct wlan_scan_obj *scan_obj; 170 171 scan_obj = wlan_psoc_get_scan_obj(psoc); 172 if (!scan_obj) 173 return false; 174 175 return scan_obj->scan_def.honour_nl_scan_policy_flags; 176 } 177 178 void wlan_scan_cfg_get_conc_max_resttime(struct wlan_objmgr_psoc *psoc, 179 uint32_t *rest_time) 180 { 181 struct wlan_scan_obj *scan_obj; 182 183 scan_obj = wlan_psoc_get_scan_obj(psoc); 184 if (!scan_obj) 185 return; 186 187 *rest_time = scan_obj->scan_def.conc_max_rest_time; 188 } 189 190 void wlan_scan_cfg_get_conc_min_resttime(struct wlan_objmgr_psoc *psoc, 191 uint32_t *rest_time) 192 { 193 struct wlan_scan_obj *scan_obj; 194 195 scan_obj = wlan_psoc_get_scan_obj(psoc); 196 if (!scan_obj) 197 return; 198 199 *rest_time = scan_obj->scan_def.conc_min_rest_time; 200 } 201 202 bool wlan_scan_is_snr_monitor_enabled(struct wlan_objmgr_psoc *psoc) 203 { 204 struct wlan_scan_obj *scan_obj; 205 206 scan_obj = wlan_psoc_get_scan_obj(psoc); 207 if (!scan_obj) 208 return cfg_default(CFG_ENABLE_SNR_MONITORING); 209 210 return scan_obj->scan_def.scan_f_chan_stat_evnt; 211 } 212 213 QDF_STATUS 214 wlan_scan_process_bcn_probe_rx_sync(struct wlan_objmgr_psoc *psoc, 215 qdf_nbuf_t buf, 216 struct mgmt_rx_event_params *rx_param, 217 enum mgmt_frame_type frm_type) 218 { 219 struct scan_bcn_probe_event *bcn = NULL; 220 QDF_STATUS status; 221 222 if ((frm_type != MGMT_PROBE_RESP) && 223 (frm_type != MGMT_BEACON)) { 224 scm_err("frame is not beacon or probe resp"); 225 status = QDF_STATUS_E_INVAL; 226 goto free; 227 } 228 229 bcn = qdf_mem_malloc_atomic(sizeof(*bcn)); 230 if (!bcn) { 231 status = QDF_STATUS_E_NOMEM; 232 goto free; 233 } 234 bcn->rx_data = 235 qdf_mem_malloc_atomic(sizeof(*rx_param)); 236 if (!bcn->rx_data) { 237 status = QDF_STATUS_E_NOMEM; 238 goto free; 239 } 240 241 if (frm_type == MGMT_PROBE_RESP) 242 bcn->frm_type = MGMT_SUBTYPE_PROBE_RESP; 243 else 244 bcn->frm_type = MGMT_SUBTYPE_BEACON; 245 246 status = wlan_objmgr_psoc_try_get_ref(psoc, WLAN_SCAN_ID); 247 if (QDF_IS_STATUS_ERROR(status)) { 248 scm_info("unable to get reference"); 249 goto free; 250 } 251 252 bcn->psoc = psoc; 253 bcn->buf = buf; 254 qdf_mem_copy(bcn->rx_data, rx_param, sizeof(*rx_param)); 255 256 return __scm_handle_bcn_probe(bcn); 257 free: 258 if (bcn && bcn->rx_data) 259 qdf_mem_free(bcn->rx_data); 260 if (bcn) 261 qdf_mem_free(bcn); 262 if (buf) 263 qdf_nbuf_free(buf); 264 265 return status; 266 } 267 268 qdf_time_t wlan_scan_get_aging_time(struct wlan_objmgr_psoc *psoc) 269 { 270 struct wlan_scan_obj *scan_obj; 271 272 scan_obj = wlan_psoc_get_scan_obj(psoc); 273 if (!scan_obj) 274 return cfg_default(CFG_SCAN_AGING_TIME) * 1000; 275 276 return scan_obj->scan_def.scan_cache_aging_time; 277 } 278