1 /* 2 * Copyright (c) 2017-2019 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_conc_active_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.conc_active_dwell; 80 } 81 82 void wlan_scan_cfg_set_conc_active_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 91 scan_obj->scan_def.conc_active_dwell = dwell_time; 92 } 93 94 void wlan_scan_cfg_get_conc_passive_dwelltime(struct wlan_objmgr_psoc *psoc, 95 uint32_t *dwell_time) 96 { 97 struct wlan_scan_obj *scan_obj; 98 99 scan_obj = wlan_psoc_get_scan_obj(psoc); 100 if (!scan_obj) 101 return; 102 103 *dwell_time = scan_obj->scan_def.conc_passive_dwell; 104 } 105 106 void wlan_scan_cfg_set_conc_passive_dwelltime(struct wlan_objmgr_psoc *psoc, 107 uint32_t dwell_time) 108 { 109 struct wlan_scan_obj *scan_obj; 110 111 scan_obj = wlan_psoc_get_scan_obj(psoc); 112 if (!scan_obj) 113 return; 114 115 scan_obj->scan_def.conc_passive_dwell = dwell_time; 116 } 117 118 void 119 wlan_scan_cfg_get_dfs_chan_scan_allowed(struct wlan_objmgr_psoc *psoc, 120 bool *enable_dfs_scan) 121 { 122 struct wlan_scan_obj *scan_obj; 123 124 scan_obj = wlan_psoc_get_scan_obj(psoc); 125 if (!scan_obj) 126 return; 127 128 *enable_dfs_scan = scan_obj->scan_def.allow_dfs_chan_in_scan; 129 } 130 131 void 132 wlan_scan_cfg_set_dfs_chan_scan_allowed(struct wlan_objmgr_psoc *psoc, 133 bool enable_dfs_scan) 134 { 135 struct wlan_scan_obj *scan_obj; 136 137 scan_obj = wlan_psoc_get_scan_obj(psoc); 138 if (!scan_obj) 139 return; 140 141 scan_obj->scan_def.allow_dfs_chan_in_scan = enable_dfs_scan; 142 } 143 144 bool wlan_scan_cfg_honour_nl_scan_policy_flags(struct wlan_objmgr_psoc *psoc) 145 { 146 struct wlan_scan_obj *scan_obj; 147 148 scan_obj = wlan_psoc_get_scan_obj(psoc); 149 if (!scan_obj) 150 return false; 151 152 return scan_obj->scan_def.honour_nl_scan_policy_flags; 153 } 154 155 void wlan_scan_cfg_get_conc_max_resttime(struct wlan_objmgr_psoc *psoc, 156 uint32_t *rest_time) 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 *rest_time = scan_obj->scan_def.conc_max_rest_time; 165 } 166 167 void wlan_scan_cfg_get_conc_min_resttime(struct wlan_objmgr_psoc *psoc, 168 uint32_t *rest_time) 169 { 170 struct wlan_scan_obj *scan_obj; 171 172 scan_obj = wlan_psoc_get_scan_obj(psoc); 173 if (!scan_obj) 174 return; 175 176 *rest_time = scan_obj->scan_def.conc_min_rest_time; 177 } 178 179 bool wlan_scan_is_snr_monitor_enabled(struct wlan_objmgr_psoc *psoc) 180 { 181 struct wlan_scan_obj *scan_obj; 182 183 scan_obj = wlan_psoc_get_scan_obj(psoc); 184 if (!scan_obj) 185 return cfg_default(CFG_ENABLE_SNR_MONITORING); 186 187 return scan_obj->scan_def.scan_f_chan_stat_evnt; 188 } 189 190 QDF_STATUS 191 wlan_scan_process_bcn_probe_rx_sync(struct wlan_objmgr_psoc *psoc, 192 qdf_nbuf_t buf, 193 struct mgmt_rx_event_params *rx_param, 194 enum mgmt_frame_type frm_type) 195 { 196 struct scan_bcn_probe_event *bcn = NULL; 197 QDF_STATUS status; 198 199 if ((frm_type != MGMT_PROBE_RESP) && 200 (frm_type != MGMT_BEACON)) { 201 scm_err("frame is not beacon or probe resp"); 202 status = QDF_STATUS_E_INVAL; 203 goto free; 204 } 205 206 bcn = qdf_mem_malloc_atomic(sizeof(*bcn)); 207 if (!bcn) { 208 status = QDF_STATUS_E_NOMEM; 209 goto free; 210 } 211 bcn->rx_data = 212 qdf_mem_malloc_atomic(sizeof(*rx_param)); 213 if (!bcn->rx_data) { 214 status = QDF_STATUS_E_NOMEM; 215 goto free; 216 } 217 218 if (frm_type == MGMT_PROBE_RESP) 219 bcn->frm_type = MGMT_SUBTYPE_PROBE_RESP; 220 else 221 bcn->frm_type = MGMT_SUBTYPE_BEACON; 222 223 status = wlan_objmgr_psoc_try_get_ref(psoc, WLAN_SCAN_ID); 224 if (QDF_IS_STATUS_ERROR(status)) { 225 scm_info("unable to get reference"); 226 goto free; 227 } 228 229 bcn->psoc = psoc; 230 bcn->buf = buf; 231 qdf_mem_copy(bcn->rx_data, rx_param, sizeof(*rx_param)); 232 233 return __scm_handle_bcn_probe(bcn); 234 free: 235 if (bcn && bcn->rx_data) 236 qdf_mem_free(bcn->rx_data); 237 if (bcn) 238 qdf_mem_free(bcn); 239 if (buf) 240 qdf_nbuf_free(buf); 241 242 return status; 243 } 244