Om Prakash Tripathi | 7e3f45d | 2016-12-28 16:58:54 +0530 | [diff] [blame] | 1 | /* |
wadesong | 49ae4cb | 2018-01-22 15:03:12 +0800 | [diff] [blame] | 2 | * Copyright (c) 2017-2018 The Linux Foundation. All rights reserved. |
Om Prakash Tripathi | 7e3f45d | 2016-12-28 16:58:54 +0530 | [diff] [blame] | 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: Defines scan utility functions |
| 21 | */ |
Om Prakash Tripathi | 22f95dc | 2016-12-19 10:45:59 +0530 | [diff] [blame] | 22 | |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 23 | #include <wlan_cmn.h> |
Om Prakash Tripathi | 22f95dc | 2016-12-19 10:45:59 +0530 | [diff] [blame] | 24 | #include <wlan_scan_ucfg_api.h> |
| 25 | #include <wlan_scan_utils_api.h> |
| 26 | #include <../../core/src/wlan_scan_cache_db.h> |
| 27 | #include <../../core/src/wlan_scan_main.h> |
Shashikala Prabhu | 48ecda8 | 2018-04-13 01:13:30 +0530 | [diff] [blame] | 28 | #include <wlan_reg_services_api.h> |
Om Prakash Tripathi | 22f95dc | 2016-12-19 10:45:59 +0530 | [diff] [blame] | 29 | |
| 30 | const char* |
| 31 | util_scan_get_ev_type_name(enum scan_event_type type) |
| 32 | { |
| 33 | static const char * const event_name[] = { |
| 34 | [SCAN_EVENT_TYPE_STARTED] = "STARTED", |
| 35 | [SCAN_EVENT_TYPE_COMPLETED] = "COMPLETED", |
| 36 | [SCAN_EVENT_TYPE_BSS_CHANNEL] = "HOME_CHANNEL", |
| 37 | [SCAN_EVENT_TYPE_FOREIGN_CHANNEL] = "FOREIGN_CHANNEL", |
| 38 | [SCAN_EVENT_TYPE_DEQUEUED] = "DEQUEUED", |
| 39 | [SCAN_EVENT_TYPE_PREEMPTED] = "PREEMPTED", |
| 40 | [SCAN_EVENT_TYPE_START_FAILED] = "START_FAILED", |
| 41 | [SCAN_EVENT_TYPE_RESTARTED] = "RESTARTED", |
| 42 | [SCAN_EVENT_TYPE_FOREIGN_CHANNEL_EXIT] = "FOREIGN_CHANNEL_EXIT", |
| 43 | [SCAN_EVENT_TYPE_SUSPENDED] = "SUSPENDED", |
| 44 | [SCAN_EVENT_TYPE_RESUMED] = "RESUMED", |
| 45 | [SCAN_EVENT_TYPE_NLO_COMPLETE] = "NLO_COMPLETE", |
Abhishek Singh | 8c6e82d | 2017-03-03 21:57:29 +0530 | [diff] [blame] | 46 | [SCAN_EVENT_TYPE_NLO_MATCH] = "NLO_MATCH", |
Om Prakash Tripathi | 22f95dc | 2016-12-19 10:45:59 +0530 | [diff] [blame] | 47 | [SCAN_EVENT_TYPE_INVALID] = "INVALID", |
| 48 | [SCAN_EVENT_TYPE_GPIO_TIMEOUT] = "GPIO_TIMEOUT", |
| 49 | [SCAN_EVENT_TYPE_RADIO_MEASUREMENT_START] = |
| 50 | "RADIO_MEASUREMENT_START", |
| 51 | [SCAN_EVENT_TYPE_RADIO_MEASUREMENT_END] = |
| 52 | "RADIO_MEASUREMENT_END", |
| 53 | [SCAN_EVENT_TYPE_BSSID_MATCH] = "BSSID_MATCH", |
| 54 | [SCAN_EVENT_TYPE_FOREIGN_CHANNEL_GET_NF] = |
| 55 | "FOREIGN_CHANNEL_GET_NF", |
| 56 | }; |
| 57 | |
Abhishek Singh | 483d914 | 2017-03-06 13:28:13 +0530 | [diff] [blame] | 58 | if (type >= SCAN_EVENT_TYPE_MAX) |
Om Prakash Tripathi | 22f95dc | 2016-12-19 10:45:59 +0530 | [diff] [blame] | 59 | return "UNKNOWN"; |
Om Prakash Tripathi | 22f95dc | 2016-12-19 10:45:59 +0530 | [diff] [blame] | 60 | |
| 61 | return event_name[type]; |
| 62 | } |
| 63 | |
| 64 | |
| 65 | const char* |
| 66 | util_scan_get_ev_reason_name(enum scan_completion_reason reason) |
| 67 | { |
| 68 | static const char * const reason_name[] = { |
| 69 | [SCAN_REASON_NONE] = "NONE", |
| 70 | [SCAN_REASON_COMPLETED] = "COMPLETED", |
| 71 | [SCAN_REASON_CANCELLED] = "CANCELLED", |
| 72 | [SCAN_REASON_PREEMPTED] = "PREEMPTED", |
| 73 | [SCAN_REASON_TIMEDOUT] = "TIMEDOUT", |
| 74 | [SCAN_REASON_INTERNAL_FAILURE] = "INTERNAL_FAILURE", |
| 75 | [SCAN_REASON_SUSPENDED] = "SUSPENDED", |
| 76 | [SCAN_REASON_RUN_FAILED] = "RUN_FAILED", |
| 77 | [SCAN_REASON_TERMINATION_FUNCTION] = "TERMINATION_FUNCTION", |
| 78 | [SCAN_REASON_MAX_OFFCHAN_RETRIES] = "MAX_OFFCHAN_RETRIES", |
| 79 | }; |
| 80 | |
Abhishek Singh | 483d914 | 2017-03-06 13:28:13 +0530 | [diff] [blame] | 81 | if (reason >= SCAN_REASON_MAX) |
Om Prakash Tripathi | 22f95dc | 2016-12-19 10:45:59 +0530 | [diff] [blame] | 82 | return "UNKNOWN"; |
Om Prakash Tripathi | 22f95dc | 2016-12-19 10:45:59 +0530 | [diff] [blame] | 83 | |
| 84 | return reason_name[reason]; |
| 85 | } |
| 86 | |
| 87 | qdf_time_t |
| 88 | util_get_last_scan_time(struct wlan_objmgr_vdev *vdev) |
| 89 | { |
| 90 | uint8_t pdev_id; |
| 91 | struct wlan_scan_obj *scan_obj; |
| 92 | |
| 93 | if (!vdev) { |
| 94 | scm_warn("null vdev"); |
| 95 | QDF_ASSERT(0); |
| 96 | return 0; |
| 97 | } |
| 98 | pdev_id = wlan_scan_vdev_get_pdev_id(vdev); |
| 99 | scan_obj = wlan_vdev_get_scan_obj(vdev); |
| 100 | |
| 101 | return scan_obj->pdev_info[pdev_id].last_scan_time; |
| 102 | } |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 103 | |
Abhishek Singh | b80af7e | 2017-07-19 18:48:42 +0530 | [diff] [blame] | 104 | enum wlan_band util_scan_scm_chan_to_band(uint32_t chan) |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 105 | { |
| 106 | if (WLAN_CHAN_IS_2GHZ(chan)) |
| 107 | return WLAN_BAND_2_4_GHZ; |
| 108 | |
| 109 | return WLAN_BAND_5_GHZ; |
| 110 | } |
| 111 | |
Shashikala Prabhu | 48ecda8 | 2018-04-13 01:13:30 +0530 | [diff] [blame] | 112 | enum wlan_band util_scan_scm_freq_to_band(uint16_t freq) |
| 113 | { |
| 114 | if (WLAN_REG_IS_24GHZ_CH_FREQ(freq)) |
| 115 | return WLAN_BAND_2_4_GHZ; |
| 116 | |
| 117 | return WLAN_BAND_5_GHZ; |
| 118 | } |
| 119 | |
Abhishek Singh | d4e600f | 2017-02-21 15:16:28 +0530 | [diff] [blame] | 120 | bool util_is_scan_entry_match( |
| 121 | struct scan_cache_entry *entry1, |
| 122 | struct scan_cache_entry *entry2) |
| 123 | { |
| 124 | |
| 125 | if (entry1->cap_info.wlan_caps.ess != |
wadesong | 49ae4cb | 2018-01-22 15:03:12 +0800 | [diff] [blame] | 126 | entry2->cap_info.wlan_caps.ess) |
Abhishek Singh | d4e600f | 2017-02-21 15:16:28 +0530 | [diff] [blame] | 127 | return false; |
| 128 | |
| 129 | if (entry1->cap_info.wlan_caps.ess && |
| 130 | !qdf_mem_cmp(entry1->bssid.bytes, |
Om Prakash Tripathi | c3fcb68 | 2017-08-01 18:24:55 +0530 | [diff] [blame] | 131 | entry2->bssid.bytes, QDF_MAC_ADDR_SIZE) && |
Abhishek Singh | b80af7e | 2017-07-19 18:48:42 +0530 | [diff] [blame] | 132 | util_scan_scm_chan_to_band( |
Abhishek Singh | d4e600f | 2017-02-21 15:16:28 +0530 | [diff] [blame] | 133 | entry1->channel.chan_idx) == |
Abhishek Singh | b80af7e | 2017-07-19 18:48:42 +0530 | [diff] [blame] | 134 | util_scan_scm_chan_to_band(entry2->channel.chan_idx)) { |
Abhishek Singh | d4e600f | 2017-02-21 15:16:28 +0530 | [diff] [blame] | 135 | /* Check for BSS */ |
| 136 | if (util_is_ssid_match( |
| 137 | &entry1->ssid, &entry2->ssid)) |
| 138 | return true; |
| 139 | } else if (entry1->cap_info.wlan_caps.ibss && |
| 140 | (entry1->channel.chan_idx == |
| 141 | entry2->channel.chan_idx)) { |
| 142 | /* |
| 143 | * Same channel cannot have same SSID for |
| 144 | * different IBSS, so no need to check BSSID |
| 145 | */ |
| 146 | if (util_is_ssid_match( |
| 147 | &entry1->ssid, &entry2->ssid)) |
| 148 | return true; |
| 149 | } else if (!entry1->cap_info.wlan_caps.ibss && |
| 150 | !entry1->cap_info.wlan_caps.ess && |
| 151 | !qdf_mem_cmp(entry1->bssid.bytes, |
Om Prakash Tripathi | c3fcb68 | 2017-08-01 18:24:55 +0530 | [diff] [blame] | 152 | entry2->bssid.bytes, QDF_MAC_ADDR_SIZE)) { |
Abhishek Singh | d4e600f | 2017-02-21 15:16:28 +0530 | [diff] [blame] | 153 | /* In case of P2P devices, ess and ibss will be set to zero */ |
| 154 | return true; |
| 155 | } |
| 156 | |
| 157 | return false; |
| 158 | } |
| 159 | |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 160 | static bool util_is_pureg_rate(uint8_t *rates, uint8_t nrates) |
| 161 | { |
| 162 | static const uint8_t g_rates[] = {12, 18, 24, 36, 48, 72, 96, 108}; |
| 163 | bool pureg = false; |
| 164 | uint8_t i, j; |
| 165 | |
| 166 | for (i = 0; i < nrates; i++) { |
| 167 | for (j = 0; j < QDF_ARRAY_SIZE(g_rates); j++) { |
| 168 | if (WLAN_RV(rates[i]) == g_rates[j]) { |
| 169 | pureg = true; |
| 170 | break; |
| 171 | } |
| 172 | } |
| 173 | if (pureg) |
| 174 | break; |
| 175 | } |
| 176 | |
| 177 | return pureg; |
| 178 | } |
| 179 | static enum wlan_phymode |
| 180 | util_scan_get_phymode_5g(struct scan_cache_entry *scan_params) |
| 181 | { |
| 182 | enum wlan_phymode phymode = WLAN_PHYMODE_AUTO; |
| 183 | uint16_t ht_cap = 0; |
| 184 | struct htcap_cmn_ie *htcap; |
| 185 | struct wlan_ie_htinfo_cmn *htinfo; |
| 186 | struct wlan_ie_vhtop *vhtop; |
| 187 | |
| 188 | htcap = (struct htcap_cmn_ie *) |
| 189 | util_scan_entry_htcap(scan_params); |
| 190 | htinfo = (struct wlan_ie_htinfo_cmn *) |
| 191 | util_scan_entry_htinfo(scan_params); |
| 192 | vhtop = (struct wlan_ie_vhtop *) |
| 193 | util_scan_entry_vhtop(scan_params); |
| 194 | |
| 195 | if (!(htcap && htinfo)) |
| 196 | return WLAN_PHYMODE_11A; |
| 197 | |
| 198 | if (htcap) |
| 199 | ht_cap = le16toh(htcap->hc_cap); |
| 200 | |
| 201 | if (util_scan_entry_vhtcap(scan_params) && vhtop) { |
| 202 | switch (vhtop->vht_op_chwidth) { |
| 203 | case WLAN_VHTOP_CHWIDTH_2040: |
| 204 | if ((ht_cap & WLAN_HTCAP_C_CHWIDTH40) && |
| 205 | (htinfo->hi_extchoff == |
| 206 | WLAN_HTINFO_EXTOFFSET_ABOVE)) |
| 207 | phymode = WLAN_PHYMODE_11AC_VHT40PLUS; |
| 208 | else if ((ht_cap & WLAN_HTCAP_C_CHWIDTH40) && |
| 209 | (htinfo->hi_extchoff == |
| 210 | WLAN_HTINFO_EXTOFFSET_BELOW)) |
| 211 | phymode = WLAN_PHYMODE_11AC_VHT40MINUS; |
| 212 | else |
| 213 | phymode = WLAN_PHYMODE_11AC_VHT20; |
| 214 | break; |
| 215 | case WLAN_VHTOP_CHWIDTH_80: |
| 216 | if (WLAN_IS_REVSIG_VHT80_80(vhtop)) |
| 217 | phymode = WLAN_PHYMODE_11AC_VHT80_80; |
| 218 | else if (WLAN_IS_REVSIG_VHT160(vhtop)) |
| 219 | phymode = WLAN_PHYMODE_11AC_VHT160; |
| 220 | else |
| 221 | phymode = WLAN_PHYMODE_11AC_VHT80; |
| 222 | break; |
| 223 | case WLAN_VHTOP_CHWIDTH_160: |
| 224 | phymode = WLAN_PHYMODE_11AC_VHT160; |
| 225 | break; |
| 226 | case WLAN_VHTOP_CHWIDTH_80_80: |
| 227 | phymode = WLAN_PHYMODE_11AC_VHT80_80; |
| 228 | break; |
| 229 | default: |
| 230 | scm_err("bad channel: %d", |
| 231 | vhtop->vht_op_chwidth); |
| 232 | break; |
| 233 | } |
| 234 | } else if ((ht_cap & WLAN_HTCAP_C_CHWIDTH40) && |
| 235 | (htinfo->hi_extchoff == WLAN_HTINFO_EXTOFFSET_ABOVE)) |
| 236 | phymode = WLAN_PHYMODE_11NA_HT40PLUS; |
| 237 | else if ((ht_cap & WLAN_HTCAP_C_CHWIDTH40) && |
| 238 | (htinfo->hi_extchoff == WLAN_HTINFO_EXTOFFSET_BELOW)) |
| 239 | phymode = WLAN_PHYMODE_11NA_HT40MINUS; |
| 240 | else |
| 241 | phymode = WLAN_PHYMODE_11NA_HT20; |
| 242 | |
| 243 | return phymode; |
| 244 | } |
| 245 | |
| 246 | static enum wlan_phymode |
| 247 | util_scan_get_phymode_2g(struct scan_cache_entry *scan_params) |
| 248 | { |
| 249 | enum wlan_phymode phymode = WLAN_PHYMODE_AUTO; |
| 250 | uint16_t ht_cap = 0; |
| 251 | struct htcap_cmn_ie *htcap; |
| 252 | struct wlan_ie_htinfo_cmn *htinfo; |
| 253 | struct wlan_ie_vhtop *vhtop; |
| 254 | |
| 255 | htcap = (struct htcap_cmn_ie *) |
| 256 | util_scan_entry_htcap(scan_params); |
| 257 | htinfo = (struct wlan_ie_htinfo_cmn *) |
| 258 | util_scan_entry_htinfo(scan_params); |
| 259 | vhtop = (struct wlan_ie_vhtop *) |
| 260 | util_scan_entry_vhtop(scan_params); |
| 261 | |
| 262 | if (htcap) |
| 263 | ht_cap = le16toh(htcap->hc_cap); |
| 264 | |
| 265 | if (htcap && htinfo) { |
| 266 | if ((ht_cap & WLAN_HTCAP_C_CHWIDTH40) && |
| 267 | (htinfo->hi_extchoff == WLAN_HTINFO_EXTOFFSET_ABOVE)) |
| 268 | phymode = WLAN_PHYMODE_11NG_HT40PLUS; |
| 269 | else if ((ht_cap & WLAN_HTCAP_C_CHWIDTH40) && |
| 270 | (htinfo->hi_extchoff == WLAN_HTINFO_EXTOFFSET_BELOW)) |
| 271 | phymode = WLAN_PHYMODE_11NG_HT40MINUS; |
| 272 | else |
| 273 | phymode = WLAN_PHYMODE_11NG_HT20; |
| 274 | } else if (util_scan_entry_xrates(scan_params)) { |
| 275 | /* only 11G stations will have more than 8 rates */ |
| 276 | phymode = WLAN_PHYMODE_11G; |
| 277 | } else { |
| 278 | /* Some mischievous g-only APs do not set extended rates */ |
| 279 | if (util_scan_entry_rates(scan_params)) { |
| 280 | if (util_is_pureg_rate(&scan_params->ie_list.rates[2], |
| 281 | scan_params->ie_list.rates[1])) |
| 282 | phymode = WLAN_PHYMODE_11G; |
| 283 | else |
| 284 | phymode = WLAN_PHYMODE_11B; |
| 285 | } else { |
| 286 | phymode = WLAN_PHYMODE_11B; |
| 287 | } |
| 288 | } |
| 289 | |
| 290 | return phymode; |
| 291 | } |
| 292 | |
| 293 | static QDF_STATUS |
| 294 | util_scan_parse_chan_switch_wrapper_ie(struct scan_cache_entry *scan_params, |
| 295 | struct ie_header *sub_ie, qdf_size_t sub_ie_len) |
| 296 | { |
| 297 | /* Walk through to check nothing is malformed */ |
| 298 | while (sub_ie_len >= sizeof(struct ie_header)) { |
| 299 | /* At least one more header is present */ |
| 300 | sub_ie_len -= sizeof(struct ie_header); |
| 301 | |
| 302 | if (sub_ie->ie_len == 0) { |
| 303 | sub_ie += 1; |
| 304 | continue; |
| 305 | } |
| 306 | if (sub_ie_len < sub_ie->ie_len) { |
| 307 | scm_err("Incomplete corrupted IE:%x", |
| 308 | WLAN_ELEMID_CHAN_SWITCH_WRAP); |
| 309 | return QDF_STATUS_E_INVAL; |
| 310 | } |
| 311 | switch (sub_ie->ie_id) { |
| 312 | case WLAN_ELEMID_COUNTRY: |
| 313 | scan_params->ie_list.country = (uint8_t *)sub_ie; |
| 314 | break; |
| 315 | case WLAN_ELEMID_WIDE_BAND_CHAN_SWITCH: |
| 316 | scan_params->ie_list.widebw = (uint8_t *)sub_ie; |
| 317 | break; |
| 318 | case WLAN_ELEMID_VHT_TX_PWR_ENVLP: |
| 319 | scan_params->ie_list.txpwrenvlp = (uint8_t *)sub_ie; |
| 320 | break; |
| 321 | } |
| 322 | /* Consume sub info element */ |
| 323 | sub_ie_len -= sub_ie->ie_len; |
| 324 | /* go to next Sub IE */ |
| 325 | sub_ie = (struct ie_header *) |
| 326 | (((uint8_t *) sub_ie) + |
| 327 | sizeof(struct ie_header) + sub_ie->ie_len); |
| 328 | } |
| 329 | |
| 330 | return QDF_STATUS_SUCCESS; |
| 331 | } |
| 332 | |
Om Prakash Tripathi | 1d1525d | 2017-09-08 13:59:34 +0530 | [diff] [blame] | 333 | bool |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 334 | util_scan_is_hidden_ssid(struct ie_ssid *ssid) |
| 335 | { |
| 336 | uint8_t i; |
| 337 | |
| 338 | /* |
| 339 | * We flag this as Hidden SSID if the Length is 0 |
| 340 | * of the SSID only contains 0's |
| 341 | */ |
| 342 | if (!ssid || !ssid->ssid_len) |
| 343 | return true; |
| 344 | |
| 345 | for (i = 0; i < ssid->ssid_len; i++) |
| 346 | if (ssid->ssid[i] != 0) |
| 347 | return false; |
| 348 | |
| 349 | /* All 0's */ |
| 350 | return true; |
| 351 | } |
| 352 | |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 353 | static QDF_STATUS |
Venkateswara Swamy Bandaru | 851184b | 2017-04-25 11:02:39 +0530 | [diff] [blame] | 354 | util_scan_parse_extn_ie(struct scan_cache_entry *scan_params, |
| 355 | struct ie_header *ie) |
| 356 | { |
| 357 | struct extn_ie_header *extn_ie = (struct extn_ie_header *) ie; |
| 358 | |
| 359 | switch (extn_ie->ie_extn_id) { |
| 360 | case WLAN_EXTN_ELEMID_SRP: |
Gyanranjan Hazarika | b5d426d | 2017-08-22 21:45:07 -0700 | [diff] [blame] | 361 | scan_params->ie_list.srp = (uint8_t *)ie; |
| 362 | break; |
| 363 | case WLAN_EXTN_ELEMID_HECAP: |
| 364 | scan_params->ie_list.hecap = (uint8_t *)ie; |
| 365 | break; |
| 366 | case WLAN_EXTN_ELEMID_HEOP: |
| 367 | scan_params->ie_list.heop = (uint8_t *)ie; |
Venkateswara Swamy Bandaru | 851184b | 2017-04-25 11:02:39 +0530 | [diff] [blame] | 368 | break; |
Abhishek Singh | b80af7e | 2017-07-19 18:48:42 +0530 | [diff] [blame] | 369 | case WLAN_EXTN_ELEMID_ESP: |
| 370 | scan_params->ie_list.esp = (uint8_t *)ie; |
| 371 | break; |
Rhythm Patwa | a6ba9ee | 2018-05-23 19:29:57 -0700 | [diff] [blame] | 372 | case WLAN_EXTN_ELEMID_MUEDCA: |
| 373 | scan_params->ie_list.muedca = (uint8_t *)ie; |
| 374 | break; |
Venkateswara Swamy Bandaru | 851184b | 2017-04-25 11:02:39 +0530 | [diff] [blame] | 375 | default: |
| 376 | break; |
| 377 | } |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 378 | return QDF_STATUS_SUCCESS; |
Venkateswara Swamy Bandaru | 851184b | 2017-04-25 11:02:39 +0530 | [diff] [blame] | 379 | } |
| 380 | |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 381 | static QDF_STATUS |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 382 | util_scan_parse_vendor_ie(struct scan_cache_entry *scan_params, |
| 383 | struct ie_header *ie) |
| 384 | { |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 385 | if (scan_params->ie_list.vendor == NULL) |
| 386 | scan_params->ie_list.vendor = (uint8_t *)ie; |
| 387 | |
| 388 | if (is_wpa_oui((uint8_t *)ie)) { |
| 389 | scan_params->ie_list.wpa = (uint8_t *)ie; |
| 390 | } else if (is_wps_oui((uint8_t *)ie)) { |
| 391 | scan_params->ie_list.wps = (uint8_t *)ie; |
| 392 | /* WCN IE should be a subset of WPS IE */ |
| 393 | if (is_wcn_oui((uint8_t *)ie)) |
| 394 | scan_params->ie_list.wcn = (uint8_t *)ie; |
| 395 | } else if (is_wme_param((uint8_t *)ie)) { |
| 396 | scan_params->ie_list.wmeparam = (uint8_t *)ie; |
| 397 | } else if (is_wme_info((uint8_t *)ie)) { |
| 398 | scan_params->ie_list.wmeinfo = (uint8_t *)ie; |
| 399 | } else if (is_atheros_oui((uint8_t *)ie)) { |
| 400 | scan_params->ie_list.athcaps = (uint8_t *)ie; |
| 401 | } else if (is_atheros_extcap_oui((uint8_t *)ie)) { |
| 402 | scan_params->ie_list.athextcaps = (uint8_t *)ie; |
| 403 | } else if (is_sfa_oui((uint8_t *)ie)) { |
| 404 | scan_params->ie_list.sfa = (uint8_t *)ie; |
| 405 | } else if (is_p2p_oui((uint8_t *)ie)) { |
| 406 | scan_params->ie_list.p2p = (uint8_t *)ie; |
Bharat Bhushan Chakravarty | 145d393 | 2017-03-20 12:52:16 -0700 | [diff] [blame] | 407 | } else if (is_qca_son_oui((uint8_t *)ie, |
| 408 | QCA_OUI_WHC_AP_INFO_SUBTYPE)) { |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 409 | scan_params->ie_list.sonadv = (uint8_t *)ie; |
| 410 | } else if (is_ht_cap((uint8_t *)ie)) { |
| 411 | /* we only care if there isn't already an HT IE (ANA) */ |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 412 | if (scan_params->ie_list.htcap == NULL) { |
| 413 | if (ie->ie_len != (WLAN_VENDOR_HT_IE_OFFSET_LEN + |
| 414 | sizeof(struct htcap_cmn_ie))) |
| 415 | return QDF_STATUS_E_INVAL; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 416 | scan_params->ie_list.htcap = |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 417 | (uint8_t *)&(((struct wlan_vendor_ie_htcap *)ie)->ie); |
| 418 | } |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 419 | } else if (is_ht_info((uint8_t *)ie)) { |
| 420 | /* we only care if there isn't already an HT IE (ANA) */ |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 421 | if (scan_params->ie_list.htinfo == NULL) { |
| 422 | if (ie->ie_len != WLAN_VENDOR_HT_IE_OFFSET_LEN + |
| 423 | sizeof(struct wlan_ie_htinfo_cmn)) |
| 424 | return QDF_STATUS_E_INVAL; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 425 | scan_params->ie_list.htinfo = |
| 426 | (uint8_t *)&(((struct wlan_vendor_ie_htinfo *) |
| 427 | ie)->hi_ie); |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 428 | } |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 429 | } else if (is_interop_vht((uint8_t *)ie) && |
| 430 | !(scan_params->ie_list.vhtop)) { |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 431 | uint8_t *vendor_ie = (uint8_t *)(ie); |
| 432 | |
| 433 | if (ie->ie_len < ((WLAN_VENDOR_VHTCAP_IE_OFFSET + |
| 434 | sizeof(struct wlan_ie_vhtcaps)) - |
| 435 | sizeof(struct ie_header))) |
| 436 | return QDF_STATUS_E_INVAL; |
| 437 | vendor_ie = ((uint8_t *)(ie)) + WLAN_VENDOR_VHTCAP_IE_OFFSET; |
| 438 | if (vendor_ie[1] != (sizeof(struct wlan_ie_vhtcaps)) - |
| 439 | sizeof(struct ie_header)) |
| 440 | return QDF_STATUS_E_INVAL; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 441 | /* location where Interop Vht Cap IE and VHT OP IE Present */ |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 442 | scan_params->ie_list.vhtcap = (((uint8_t *)(ie)) + |
| 443 | WLAN_VENDOR_VHTCAP_IE_OFFSET); |
| 444 | if (ie->ie_len > ((WLAN_VENDOR_VHTCAP_IE_OFFSET + |
| 445 | sizeof(struct wlan_ie_vhtcaps)) - |
| 446 | sizeof(struct ie_header)) && |
| 447 | ie->ie_len < ((WLAN_VENDOR_VHTOP_IE_OFFSET + |
| 448 | sizeof(struct wlan_ie_vhtop)) - |
| 449 | sizeof(struct ie_header))) |
| 450 | return QDF_STATUS_E_INVAL; |
| 451 | vendor_ie = ((uint8_t *)(ie)) + WLAN_VENDOR_VHTOP_IE_OFFSET; |
| 452 | if (vendor_ie[1] != (sizeof(struct wlan_ie_vhtop) - |
| 453 | sizeof(struct ie_header))) |
| 454 | return QDF_STATUS_E_INVAL; |
| 455 | scan_params->ie_list.vhtop = (((uint8_t *)(ie)) + |
| 456 | WLAN_VENDOR_VHTOP_IE_OFFSET); |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 457 | } else if (is_bwnss_oui((uint8_t *)ie)) { |
| 458 | /* |
| 459 | * Bandwidth-NSS map has sub-type & version. |
| 460 | * hence copy data just after version byte |
| 461 | */ |
| 462 | scan_params->ie_list.bwnss_map = (((uint8_t *)ie) + 8); |
Abhishek Singh | 7b59903 | 2017-11-10 14:42:31 +0530 | [diff] [blame] | 463 | } else if (is_mbo_oce_oui((uint8_t *)ie)) { |
| 464 | scan_params->ie_list.mbo_oce = (uint8_t *)ie; |
Rathees kumar Chinannan | b8f2d08 | 2018-07-04 15:51:51 +0530 | [diff] [blame] | 465 | } else if (is_extender_oui((uint8_t *)ie)) { |
| 466 | scan_params->ie_list.extender = (uint8_t *)ie; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 467 | } |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 468 | return QDF_STATUS_SUCCESS; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 469 | } |
| 470 | |
| 471 | static QDF_STATUS |
| 472 | util_scan_populate_bcn_ie_list(struct scan_cache_entry *scan_params) |
| 473 | { |
| 474 | struct ie_header *ie, *sub_ie; |
| 475 | uint32_t ie_len, sub_ie_len; |
| 476 | QDF_STATUS status; |
| 477 | |
| 478 | ie_len = util_scan_entry_ie_len(scan_params); |
| 479 | ie = (struct ie_header *) |
| 480 | util_scan_entry_ie_data(scan_params); |
| 481 | |
| 482 | while (ie_len >= sizeof(struct ie_header)) { |
| 483 | ie_len -= sizeof(struct ie_header); |
| 484 | |
| 485 | if (!ie->ie_len) { |
| 486 | ie += 1; |
| 487 | continue; |
| 488 | } |
| 489 | |
| 490 | if (ie_len < ie->ie_len) { |
Om Prakash Tripathi | 8e9beae | 2018-04-27 14:35:39 +0530 | [diff] [blame] | 491 | scm_debug("Incomplete corrupted IE:%x", |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 492 | ie->ie_id); |
| 493 | return QDF_STATUS_E_INVAL; |
| 494 | } |
| 495 | |
| 496 | switch (ie->ie_id) { |
| 497 | case WLAN_ELEMID_SSID: |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 498 | if (ie->ie_len > (sizeof(struct ie_ssid) - |
| 499 | sizeof(struct ie_header))) |
| 500 | return QDF_STATUS_E_INVAL; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 501 | scan_params->ie_list.ssid = (uint8_t *)ie; |
| 502 | break; |
| 503 | case WLAN_ELEMID_RATES: |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 504 | if (ie->ie_len > WLAN_SUPPORTED_RATES_IE_MAX_LEN) |
| 505 | return QDF_STATUS_E_INVAL; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 506 | scan_params->ie_list.rates = (uint8_t *)ie; |
| 507 | break; |
| 508 | case WLAN_ELEMID_DSPARMS: |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 509 | if (ie->ie_len != WLAN_DS_PARAM_IE_MAX_LEN) |
| 510 | return QDF_STATUS_E_INVAL; |
Abhishek Singh | c05285d | 2018-01-12 15:19:32 +0530 | [diff] [blame] | 511 | scan_params->ie_list.ds_param = (uint8_t *)ie; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 512 | scan_params->channel.chan_idx = |
| 513 | ((struct ds_ie *)ie)->cur_chan; |
| 514 | break; |
| 515 | case WLAN_ELEMID_TIM: |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 516 | if (ie->ie_len < WLAN_TIM_IE_MIN_LENGTH) |
| 517 | return QDF_STATUS_E_INVAL; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 518 | scan_params->ie_list.tim = (uint8_t *)ie; |
| 519 | scan_params->dtim_period = |
| 520 | ((struct wlan_tim_ie *)ie)->tim_period; |
| 521 | break; |
| 522 | case WLAN_ELEMID_COUNTRY: |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 523 | if (ie->ie_len < WLAN_COUNTRY_IE_MIN_LEN) |
| 524 | return QDF_STATUS_E_INVAL; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 525 | scan_params->ie_list.country = (uint8_t *)ie; |
| 526 | break; |
| 527 | case WLAN_ELEMID_QBSS_LOAD: |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 528 | if (ie->ie_len != sizeof(struct qbss_load_ie) - |
Jingxiang Ge | c5f0bd1 | 2018-06-13 18:00:02 +0800 | [diff] [blame] | 529 | sizeof(struct ie_header)) { |
| 530 | /* |
| 531 | * Expected QBSS IE length is 5Bytes; For some |
| 532 | * old cisco AP, QBSS IE length is 4Bytes, which |
| 533 | * doesn't match with latest spec, So ignore |
| 534 | * QBSS IE in such case. |
| 535 | */ |
| 536 | break; |
| 537 | } |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 538 | scan_params->ie_list.qbssload = (uint8_t *)ie; |
| 539 | break; |
| 540 | case WLAN_ELEMID_CHANSWITCHANN: |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 541 | if (ie->ie_len != WLAN_CSA_IE_MAX_LEN) |
| 542 | return QDF_STATUS_E_INVAL; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 543 | scan_params->ie_list.csa = (uint8_t *)ie; |
| 544 | break; |
| 545 | case WLAN_ELEMID_IBSSDFS: |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 546 | if (ie->ie_len < WLAN_IBSSDFS_IE_MIN_LEN) |
| 547 | return QDF_STATUS_E_INVAL; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 548 | scan_params->ie_list.ibssdfs = (uint8_t *)ie; |
| 549 | break; |
| 550 | case WLAN_ELEMID_QUIET: |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 551 | if (ie->ie_len != WLAN_QUIET_IE_MAX_LEN) |
| 552 | return QDF_STATUS_E_INVAL; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 553 | scan_params->ie_list.quiet = (uint8_t *)ie; |
| 554 | break; |
| 555 | case WLAN_ELEMID_ERP: |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 556 | if (ie->ie_len != (sizeof(struct erp_ie) - |
| 557 | sizeof(struct ie_header))) |
| 558 | return QDF_STATUS_E_INVAL; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 559 | scan_params->erp = ((struct erp_ie *)ie)->value; |
| 560 | break; |
| 561 | case WLAN_ELEMID_HTCAP_ANA: |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 562 | if (ie->ie_len != sizeof(struct htcap_cmn_ie)) |
| 563 | return QDF_STATUS_E_INVAL; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 564 | scan_params->ie_list.htcap = |
| 565 | (uint8_t *)&(((struct htcap_ie *)ie)->ie); |
| 566 | break; |
| 567 | case WLAN_ELEMID_RSN: |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 568 | if (ie->ie_len < WLAN_RSN_IE_MIN_LEN) |
| 569 | return QDF_STATUS_E_INVAL; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 570 | scan_params->ie_list.rsn = (uint8_t *)ie; |
| 571 | break; |
| 572 | case WLAN_ELEMID_XRATES: |
| 573 | scan_params->ie_list.xrates = (uint8_t *)ie; |
| 574 | break; |
| 575 | case WLAN_ELEMID_EXTCHANSWITCHANN: |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 576 | if (ie->ie_len != WLAN_XCSA_IE_MAX_LEN) |
| 577 | return QDF_STATUS_E_INVAL; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 578 | scan_params->ie_list.xcsa = (uint8_t *)ie; |
| 579 | break; |
| 580 | case WLAN_ELEMID_SECCHANOFFSET: |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 581 | if (ie->ie_len != WLAN_SECCHANOFF_IE_MAX_LEN) |
| 582 | return QDF_STATUS_E_INVAL; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 583 | scan_params->ie_list.secchanoff = (uint8_t *)ie; |
| 584 | break; |
| 585 | case WLAN_ELEMID_HTINFO_ANA: |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 586 | if (ie->ie_len != sizeof(struct wlan_ie_htinfo_cmn)) |
| 587 | return QDF_STATUS_E_INVAL; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 588 | scan_params->ie_list.htinfo = |
| 589 | (uint8_t *)&(((struct wlan_ie_htinfo *) ie)->hi_ie); |
| 590 | scan_params->channel.chan_idx = |
| 591 | ((struct wlan_ie_htinfo_cmn *) |
| 592 | (scan_params->ie_list.htinfo))->hi_ctrlchannel; |
| 593 | break; |
| 594 | case WLAN_ELEMID_WAPI: |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 595 | if (ie->ie_len < WLAN_WAPI_IE_MIN_LEN) |
| 596 | return QDF_STATUS_E_INVAL; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 597 | scan_params->ie_list.wapi = (uint8_t *)ie; |
| 598 | break; |
| 599 | case WLAN_ELEMID_XCAPS: |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 600 | if (ie->ie_len > WLAN_EXTCAP_IE_MAX_LEN) |
| 601 | return QDF_STATUS_E_INVAL; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 602 | scan_params->ie_list.extcaps = (uint8_t *)ie; |
| 603 | break; |
| 604 | case WLAN_ELEMID_VHTCAP: |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 605 | if (ie->ie_len != (sizeof(struct wlan_ie_vhtcaps) - |
| 606 | sizeof(struct ie_header))) |
| 607 | return QDF_STATUS_E_INVAL; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 608 | scan_params->ie_list.vhtcap = (uint8_t *)ie; |
| 609 | break; |
| 610 | case WLAN_ELEMID_VHTOP: |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 611 | if (ie->ie_len != (sizeof(struct wlan_ie_vhtop) - |
| 612 | sizeof(struct ie_header))) |
| 613 | return QDF_STATUS_E_INVAL; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 614 | scan_params->ie_list.vhtop = (uint8_t *)ie; |
| 615 | break; |
| 616 | case WLAN_ELEMID_OP_MODE_NOTIFY: |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 617 | if (ie->ie_len != WLAN_OPMODE_IE_MAX_LEN) |
| 618 | return QDF_STATUS_E_INVAL; |
wadesong | d58eaf4 | 2018-05-23 11:30:02 +0800 | [diff] [blame] | 619 | scan_params->ie_list.opmode = (uint8_t *)ie; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 620 | break; |
| 621 | case WLAN_ELEMID_MOBILITY_DOMAIN: |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 622 | if (ie->ie_len != WLAN_MOBILITY_DOMAIN_IE_MAX_LEN) |
| 623 | return QDF_STATUS_E_INVAL; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 624 | scan_params->ie_list.mdie = (uint8_t *)ie; |
| 625 | break; |
| 626 | case WLAN_ELEMID_VENDOR: |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 627 | status = util_scan_parse_vendor_ie(scan_params, |
| 628 | ie); |
| 629 | if (QDF_IS_STATUS_ERROR(status)) |
| 630 | return status; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 631 | break; |
| 632 | case WLAN_ELEMID_CHAN_SWITCH_WRAP: |
| 633 | scan_params->ie_list.cswrp = (uint8_t *)ie; |
| 634 | /* Go to next sub IE */ |
| 635 | sub_ie = (struct ie_header *) |
| 636 | (((uint8_t *)ie) + sizeof(struct ie_header)); |
| 637 | sub_ie_len = ie->ie_len; |
| 638 | status = |
| 639 | util_scan_parse_chan_switch_wrapper_ie( |
| 640 | scan_params, sub_ie, sub_ie_len); |
| 641 | if (QDF_IS_STATUS_ERROR(status)) { |
| 642 | scm_err("failed to parse chan_switch_wrapper_ie"); |
| 643 | return status; |
| 644 | } |
| 645 | break; |
Kapil Gupta | de02d4f | 2017-06-05 12:37:59 +0530 | [diff] [blame] | 646 | case WLAN_ELEMID_FILS_INDICATION: |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 647 | if (ie->ie_len < WLAN_FILS_INDICATION_IE_MIN_LEN) |
| 648 | return QDF_STATUS_E_INVAL; |
Kapil Gupta | de02d4f | 2017-06-05 12:37:59 +0530 | [diff] [blame] | 649 | scan_params->ie_list.fils_indication = (uint8_t *)ie; |
| 650 | break; |
Venkateswara Swamy Bandaru | 851184b | 2017-04-25 11:02:39 +0530 | [diff] [blame] | 651 | case WLAN_ELEMID_EXTN_ELEM: |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 652 | status = util_scan_parse_extn_ie(scan_params, ie); |
| 653 | if (QDF_IS_STATUS_ERROR(status)) |
| 654 | return status; |
Venkateswara Swamy Bandaru | 851184b | 2017-04-25 11:02:39 +0530 | [diff] [blame] | 655 | break; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 656 | default: |
| 657 | break; |
| 658 | } |
| 659 | |
| 660 | /* Consume info element */ |
| 661 | ie_len -= ie->ie_len; |
| 662 | /* Go to next IE */ |
| 663 | ie = (struct ie_header *) |
| 664 | (((uint8_t *) ie) + |
| 665 | sizeof(struct ie_header) + |
| 666 | ie->ie_len); |
| 667 | } |
| 668 | |
| 669 | return QDF_STATUS_SUCCESS; |
| 670 | } |
| 671 | |
Abhishek Singh | b80af7e | 2017-07-19 18:48:42 +0530 | [diff] [blame] | 672 | /** |
| 673 | * util_scan_update_esp_data: update ESP params from beacon/probe response |
| 674 | * @esp_information: pointer to wlan_esp_information |
| 675 | * @scan_entry: new received entry |
| 676 | * |
| 677 | * The Estimated Service Parameters element is |
| 678 | * used by a AP to provide information to another STA which |
| 679 | * can then use the information as input to an algorithm to |
| 680 | * generate an estimate of throughput between the two STAs. |
| 681 | * The ESP Information List field contains from 1 to 4 ESP |
| 682 | * Information fields(each field 24 bits), each corresponding |
| 683 | * to an access category for which estimated service parameters |
| 684 | * information is provided. |
| 685 | * |
| 686 | * Return: None |
| 687 | */ |
| 688 | static void util_scan_update_esp_data(struct wlan_esp_ie *esp_information, |
| 689 | struct scan_cache_entry *scan_entry) |
| 690 | { |
| 691 | |
| 692 | uint8_t *data; |
| 693 | int i = 0; |
Sathyanarayanan | 0a00062 | 2017-10-10 17:17:28 +0530 | [diff] [blame] | 694 | uint64_t total_elements; |
Abhishek Singh | b80af7e | 2017-07-19 18:48:42 +0530 | [diff] [blame] | 695 | struct wlan_esp_info *esp_info; |
| 696 | struct wlan_esp_ie *esp_ie; |
| 697 | |
| 698 | esp_ie = (struct wlan_esp_ie *) |
| 699 | util_scan_entry_esp_info(scan_entry); |
| 700 | |
| 701 | total_elements = esp_ie->esp_len; |
| 702 | data = (uint8_t *)esp_ie + 3; |
| 703 | do_div(total_elements, ESP_INFORMATION_LIST_LENGTH); |
| 704 | |
| 705 | if (total_elements > MAX_ESP_INFORMATION_FIELD) { |
| 706 | scm_err("No of Air time fractions are greater than supported"); |
| 707 | return; |
| 708 | } |
| 709 | |
| 710 | for (i = 0; i < total_elements; i++) { |
| 711 | esp_info = (struct wlan_esp_info *)data; |
| 712 | if (esp_info->access_category == ESP_AC_BK) { |
| 713 | qdf_mem_copy(&esp_information->esp_info_AC_BK, |
| 714 | data, 3); |
| 715 | data = data + ESP_INFORMATION_LIST_LENGTH; |
| 716 | continue; |
| 717 | } |
| 718 | if (esp_info->access_category == ESP_AC_BE) { |
| 719 | qdf_mem_copy(&esp_information->esp_info_AC_BE, |
| 720 | data, 3); |
| 721 | data = data + ESP_INFORMATION_LIST_LENGTH; |
| 722 | continue; |
| 723 | } |
| 724 | if (esp_info->access_category == ESP_AC_VI) { |
| 725 | qdf_mem_copy(&esp_information->esp_info_AC_VI, |
| 726 | data, 3); |
| 727 | data = data + ESP_INFORMATION_LIST_LENGTH; |
| 728 | continue; |
| 729 | } |
| 730 | if (esp_info->access_category == ESP_AC_VO) { |
| 731 | qdf_mem_copy(&esp_information->esp_info_AC_VO, |
| 732 | data, 3); |
| 733 | data = data + ESP_INFORMATION_LIST_LENGTH; |
| 734 | break; |
| 735 | } |
| 736 | } |
| 737 | } |
| 738 | |
| 739 | /** |
| 740 | * util_scan_scm_update_bss_with_esp_dataa: calculate estimated air time |
| 741 | * fraction |
| 742 | * @scan_entry: new received entry |
| 743 | * |
| 744 | * This function process all Access category ESP params and provide |
| 745 | * best effort air time fraction. |
| 746 | * If best effort is not available, it will choose VI, VO and BK in sequence |
| 747 | * |
| 748 | */ |
| 749 | static void util_scan_scm_update_bss_with_esp_data( |
| 750 | struct scan_cache_entry *scan_entry) |
| 751 | { |
| 752 | uint8_t air_time_fraction = 0; |
| 753 | struct wlan_esp_ie esp_information; |
| 754 | |
| 755 | if (!scan_entry->ie_list.esp) |
| 756 | return; |
| 757 | |
| 758 | util_scan_update_esp_data(&esp_information, scan_entry); |
| 759 | |
| 760 | /* |
| 761 | * If the ESP metric is transmitting multiple airtime fractions, then |
| 762 | * follow the sequence AC_BE, AC_VI, AC_VO, AC_BK and pick whichever is |
| 763 | * the first one available |
| 764 | */ |
| 765 | if (esp_information.esp_info_AC_BE.access_category |
| 766 | == ESP_AC_BE) |
| 767 | air_time_fraction = |
| 768 | esp_information.esp_info_AC_BE. |
| 769 | estimated_air_fraction; |
| 770 | else if (esp_information.esp_info_AC_VI.access_category |
| 771 | == ESP_AC_VI) |
| 772 | air_time_fraction = |
| 773 | esp_information.esp_info_AC_VI. |
| 774 | estimated_air_fraction; |
| 775 | else if (esp_information.esp_info_AC_VO.access_category |
| 776 | == ESP_AC_VO) |
| 777 | air_time_fraction = |
| 778 | esp_information.esp_info_AC_VO. |
| 779 | estimated_air_fraction; |
| 780 | else if (esp_information.esp_info_AC_BK.access_category |
| 781 | == ESP_AC_BK) |
| 782 | air_time_fraction = |
| 783 | esp_information.esp_info_AC_BK. |
| 784 | estimated_air_fraction; |
| 785 | scan_entry->air_time_fraction = air_time_fraction; |
| 786 | } |
| 787 | |
| 788 | /** |
| 789 | * util_scan_scm_calc_nss_supported_by_ap() - finds out nss from AP |
| 790 | * @scan_entry: new received entry |
| 791 | * |
| 792 | * Return: number of nss advertised by AP |
| 793 | */ |
| 794 | static int util_scan_scm_calc_nss_supported_by_ap( |
| 795 | struct scan_cache_entry *scan_params) |
| 796 | { |
| 797 | struct htcap_cmn_ie *htcap; |
| 798 | struct wlan_ie_vhtcaps *vhtcaps; |
| 799 | uint8_t rx_mcs_map; |
| 800 | |
| 801 | htcap = (struct htcap_cmn_ie *) |
| 802 | util_scan_entry_htcap(scan_params); |
| 803 | vhtcaps = (struct wlan_ie_vhtcaps *) |
| 804 | util_scan_entry_vhtcap(scan_params); |
| 805 | if (vhtcaps) { |
| 806 | rx_mcs_map = vhtcaps->rx_mcs_map; |
| 807 | if ((rx_mcs_map & 0xC0) != 0xC0) |
| 808 | return 4; |
| 809 | |
| 810 | if ((rx_mcs_map & 0x30) != 0x30) |
| 811 | return 3; |
| 812 | |
| 813 | if ((rx_mcs_map & 0x0C) != 0x0C) |
| 814 | return 2; |
| 815 | } else if (htcap) { |
| 816 | if (htcap->mcsset[3]) |
| 817 | return 4; |
| 818 | |
| 819 | if (htcap->mcsset[2]) |
| 820 | return 3; |
| 821 | |
| 822 | if (htcap->mcsset[1]) |
| 823 | return 2; |
| 824 | |
| 825 | } |
| 826 | return 1; |
| 827 | } |
| 828 | |
Basamma Yakkanahalli | ab48ce3 | 2018-07-06 18:49:19 +0530 | [diff] [blame^] | 829 | #ifdef WLAN_DFS_CHAN_HIDDEN_SSID |
| 830 | QDF_STATUS |
| 831 | util_scan_add_hidden_ssid(struct wlan_objmgr_pdev *pdev, qdf_nbuf_t bcnbuf) |
| 832 | { |
| 833 | struct wlan_frame_hdr *hdr; |
| 834 | struct wlan_bcn_frame *bcn; |
| 835 | struct wlan_scan_obj *scan_obj; |
| 836 | struct wlan_ssid *conf_ssid; |
| 837 | struct ie_header *ie; |
| 838 | uint32_t frame_len = qdf_nbuf_len(bcnbuf); |
| 839 | uint16_t bcn_ie_offset, ssid_ie_start_offset, ssid_ie_end_offset; |
| 840 | uint16_t tmplen, ie_length; |
| 841 | uint8_t *pbeacon, *tmp; |
| 842 | bool set_ssid_flag = false; |
| 843 | struct ie_ssid *ssid; |
| 844 | uint8_t pdev_id; |
| 845 | |
| 846 | if (!pdev) { |
| 847 | scm_warn("pdev: 0x%pK is NULL", pdev); |
| 848 | return QDF_STATUS_E_NULL_VALUE; |
| 849 | } |
| 850 | pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev); |
| 851 | scan_obj = wlan_pdev_get_scan_obj(pdev); |
| 852 | |
| 853 | conf_ssid = &scan_obj->pdev_info[pdev_id].conf_ssid; |
| 854 | |
| 855 | hdr = (struct wlan_frame_hdr *)qdf_nbuf_data(bcnbuf); |
| 856 | |
| 857 | /* received bssid does not match configured bssid */ |
| 858 | if (qdf_mem_cmp(hdr->i_addr3, scan_obj->pdev_info[pdev_id].conf_bssid, |
| 859 | QDF_MAC_ADDR_SIZE) || |
| 860 | conf_ssid->length == 0) { |
| 861 | return QDF_STATUS_SUCCESS; |
| 862 | } |
| 863 | |
| 864 | bcn = (struct wlan_bcn_frame *)(qdf_nbuf_data(bcnbuf) + sizeof(*hdr)); |
| 865 | pbeacon = (uint8_t *)bcn; |
| 866 | |
| 867 | ie = (struct ie_header *)(pbeacon + |
| 868 | offsetof(struct wlan_bcn_frame, ie)); |
| 869 | |
| 870 | bcn_ie_offset = offsetof(struct wlan_bcn_frame, ie); |
| 871 | ie_length = (uint16_t)(frame_len - sizeof(*hdr) - |
| 872 | bcn_ie_offset); |
| 873 | |
| 874 | while (ie_length >= sizeof(struct ie_header)) { |
| 875 | ie_length -= sizeof(struct ie_header); |
| 876 | |
| 877 | bcn_ie_offset += sizeof(struct ie_header); |
| 878 | |
| 879 | if (ie_length < ie->ie_len) { |
| 880 | scm_debug("Incomplete corrupted IE:%x", ie->ie_id); |
| 881 | return QDF_STATUS_E_INVAL; |
| 882 | } |
| 883 | if (ie->ie_id == WLAN_ELEMID_SSID) { |
| 884 | if (ie->ie_len > (sizeof(struct ie_ssid) - |
| 885 | sizeof(struct ie_header))) { |
| 886 | return QDF_STATUS_E_INVAL; |
| 887 | } |
| 888 | ssid = (struct ie_ssid *)ie; |
| 889 | if (util_scan_is_hidden_ssid(ssid)) { |
| 890 | set_ssid_flag = true; |
| 891 | ssid_ie_start_offset = bcn_ie_offset - |
| 892 | sizeof(struct ie_header); |
| 893 | ssid_ie_end_offset = bcn_ie_offset + |
| 894 | ie->ie_len; |
| 895 | } |
| 896 | } |
| 897 | if (ie->ie_len == 0) { |
| 898 | ie += 1; /* next IE */ |
| 899 | continue; |
| 900 | } |
| 901 | if (ie->ie_id == WLAN_ELEMID_VENDOR && |
| 902 | is_wps_oui((uint8_t *)ie)) { |
| 903 | set_ssid_flag = false; |
| 904 | break; |
| 905 | } |
| 906 | /* Consume info element */ |
| 907 | ie_length -= ie->ie_len; |
| 908 | /* Go to next IE */ |
| 909 | ie = (struct ie_header *)(((uint8_t *)ie) + |
| 910 | sizeof(struct ie_header) + |
| 911 | ie->ie_len); |
| 912 | } |
| 913 | |
| 914 | if (set_ssid_flag) { |
| 915 | /* Hidden SSID if the Length is 0 */ |
| 916 | if (!ssid->ssid_len) { |
| 917 | /* increase the taillength by length of ssid */ |
| 918 | if (qdf_nbuf_put_tail(bcnbuf, |
| 919 | conf_ssid->length) == NULL) { |
| 920 | scm_debug("No enough tailroom"); |
| 921 | return QDF_STATUS_E_NOMEM; |
| 922 | } |
| 923 | /* length of the buffer to be copied */ |
| 924 | tmplen = frame_len - |
| 925 | sizeof(*hdr) - ssid_ie_end_offset; |
| 926 | /* |
| 927 | * tmp memory to copy the beacon info |
| 928 | * after ssid ie. |
| 929 | */ |
| 930 | tmp = qdf_mem_malloc(tmplen * sizeof(u_int8_t)); |
| 931 | if (!tmp) { |
| 932 | scm_debug("tmp memory alloc failed"); |
| 933 | return QDF_STATUS_E_NOMEM; |
| 934 | } |
| 935 | /* Copy beacon data after ssid ie to tmp */ |
| 936 | qdf_nbuf_copy_bits(bcnbuf, (sizeof(*hdr) + |
| 937 | ssid_ie_end_offset), tmplen, tmp); |
| 938 | /* Add ssid length */ |
| 939 | *(pbeacon + (ssid_ie_start_offset + 1)) |
| 940 | = conf_ssid->length; |
| 941 | /* Insert the SSID string */ |
| 942 | qdf_mem_copy((pbeacon + ssid_ie_end_offset), |
| 943 | conf_ssid->ssid, conf_ssid->length); |
| 944 | /* Copy rest of the beacon data */ |
| 945 | qdf_mem_copy((pbeacon + ssid_ie_end_offset + |
| 946 | conf_ssid->length), tmp, tmplen); |
| 947 | qdf_mem_free(tmp); |
| 948 | |
| 949 | /* Hidden ssid with all 0's */ |
| 950 | } else if (ssid->ssid_len == conf_ssid->length) { |
| 951 | /* Insert the SSID string */ |
| 952 | qdf_mem_copy((pbeacon + ssid_ie_start_offset + |
| 953 | sizeof(struct ie_header)), |
| 954 | conf_ssid->ssid, conf_ssid->length); |
| 955 | } else { |
| 956 | scm_debug("mismatch in hidden ssid length"); |
| 957 | return QDF_STATUS_E_INVAL; |
| 958 | } |
| 959 | } |
| 960 | return QDF_STATUS_SUCCESS; |
| 961 | } |
| 962 | #endif /* WLAN_DFS_CHAN_HIDDEN_SSID */ |
| 963 | |
Sandeep Puligilla | c676459 | 2017-12-05 21:01:52 -0800 | [diff] [blame] | 964 | qdf_list_t * |
Shashikala Prabhu | 7edbb05 | 2018-04-12 09:55:25 +0530 | [diff] [blame] | 965 | util_scan_unpack_beacon_frame(struct wlan_objmgr_pdev *pdev, uint8_t *frame, |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 966 | qdf_size_t frame_len, uint32_t frm_subtype, |
| 967 | struct mgmt_rx_event_params *rx_param) |
| 968 | { |
| 969 | struct wlan_frame_hdr *hdr; |
| 970 | struct wlan_bcn_frame *bcn; |
| 971 | QDF_STATUS status; |
| 972 | struct ie_ssid *ssid; |
Sandeep Puligilla | c676459 | 2017-12-05 21:01:52 -0800 | [diff] [blame] | 973 | struct scan_cache_entry *scan_entry; |
Abhishek Singh | 7b59903 | 2017-11-10 14:42:31 +0530 | [diff] [blame] | 974 | struct qbss_load_ie *qbss_load; |
Sandeep Puligilla | c676459 | 2017-12-05 21:01:52 -0800 | [diff] [blame] | 975 | qdf_list_t *scan_list; |
| 976 | struct scan_cache_node *scan_node; |
| 977 | |
Om Prakash Tripathi | 9b56f5d | 2018-05-29 11:42:19 +0530 | [diff] [blame] | 978 | scan_list = qdf_mem_malloc_atomic(sizeof(*scan_list)); |
Sandeep Puligilla | c676459 | 2017-12-05 21:01:52 -0800 | [diff] [blame] | 979 | if (!scan_list) { |
| 980 | scm_err("failed to allocate scan_list"); |
| 981 | return NULL; |
| 982 | } |
| 983 | qdf_list_create(scan_list, MAX_SCAN_CACHE_SIZE); |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 984 | |
Om Prakash Tripathi | 9b56f5d | 2018-05-29 11:42:19 +0530 | [diff] [blame] | 985 | scan_entry = qdf_mem_malloc_atomic(sizeof(*scan_entry)); |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 986 | if (!scan_entry) { |
| 987 | scm_err("failed to allocate memory for scan_entry"); |
Sandeep Puligilla | c676459 | 2017-12-05 21:01:52 -0800 | [diff] [blame] | 988 | qdf_mem_free(scan_list); |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 989 | return NULL; |
| 990 | } |
| 991 | scan_entry->raw_frame.ptr = |
Om Prakash Tripathi | 9b56f5d | 2018-05-29 11:42:19 +0530 | [diff] [blame] | 992 | qdf_mem_malloc_atomic(frame_len); |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 993 | if (!scan_entry->raw_frame.ptr) { |
| 994 | scm_err("failed to allocate memory for frame"); |
| 995 | qdf_mem_free(scan_entry); |
Sandeep Puligilla | c676459 | 2017-12-05 21:01:52 -0800 | [diff] [blame] | 996 | qdf_mem_free(scan_list); |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 997 | return NULL; |
| 998 | } |
| 999 | |
| 1000 | bcn = (struct wlan_bcn_frame *) |
| 1001 | (frame + sizeof(*hdr)); |
| 1002 | hdr = (struct wlan_frame_hdr *)frame; |
| 1003 | |
gaurank kathpalia | 26f9833 | 2018-01-29 18:09:06 +0530 | [diff] [blame] | 1004 | /* update timestamp in nanoseconds needed by kernel layers */ |
Arif Hussain | 6fcc790 | 2018-03-22 12:33:12 -0700 | [diff] [blame] | 1005 | scan_entry->boottime_ns = qdf_get_bootbased_boottime_ns(); |
gaurank kathpalia | 26f9833 | 2018-01-29 18:09:06 +0530 | [diff] [blame] | 1006 | |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 1007 | scan_entry->frm_subtype = frm_subtype; |
| 1008 | qdf_mem_copy(scan_entry->bssid.bytes, |
| 1009 | hdr->i_addr3, QDF_MAC_ADDR_SIZE); |
| 1010 | /* Scr addr */ |
| 1011 | qdf_mem_copy(scan_entry->mac_addr.bytes, |
| 1012 | hdr->i_addr2, QDF_MAC_ADDR_SIZE); |
| 1013 | scan_entry->seq_num = |
| 1014 | (le16toh(*(uint16_t *)hdr->i_seq) >> WLAN_SEQ_SEQ_SHIFT); |
| 1015 | |
| 1016 | scan_entry->rssi_raw = rx_param->rssi; |
Om Prakash Tripathi | 6af738b | 2017-08-22 15:46:38 +0530 | [diff] [blame] | 1017 | scan_entry->avg_rssi = WLAN_RSSI_IN(scan_entry->rssi_raw); |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 1018 | scan_entry->tsf_delta = rx_param->tsf_delta; |
| 1019 | |
gaurank kathpalia | 26f9833 | 2018-01-29 18:09:06 +0530 | [diff] [blame] | 1020 | /* Copy per chain rssi to scan entry */ |
| 1021 | qdf_mem_copy(scan_entry->per_chain_snr, rx_param->rssi_ctl, |
| 1022 | WLAN_MGMT_TXRX_HOST_MAX_ANTENNA); |
| 1023 | |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 1024 | /* store jiffies */ |
| 1025 | scan_entry->rrm_parent_tsf = (u_int32_t) qdf_system_ticks(); |
| 1026 | |
| 1027 | scan_entry->bcn_int = le16toh(bcn->beacon_interval); |
| 1028 | |
| 1029 | /* |
| 1030 | * In case if the beacon dosnt have |
| 1031 | * valid beacon interval falback to def |
| 1032 | */ |
| 1033 | if (!scan_entry->bcn_int) |
| 1034 | scan_entry->bcn_int = 100; |
| 1035 | scan_entry->cap_info.value = le16toh(bcn->capability.value); |
| 1036 | qdf_mem_copy(scan_entry->tsf_info.data, |
| 1037 | bcn->timestamp, 8); |
| 1038 | scan_entry->erp = ERP_NON_ERP_PRESENT; |
| 1039 | |
Om Prakash Tripathi | cdcbb39 | 2017-04-18 18:51:20 +0530 | [diff] [blame] | 1040 | scan_entry->scan_entry_time = |
| 1041 | qdf_mc_timer_get_system_time(); |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 1042 | |
| 1043 | scan_entry->raw_frame.len = frame_len; |
| 1044 | qdf_mem_copy(scan_entry->raw_frame.ptr, |
| 1045 | frame, frame_len); |
| 1046 | status = util_scan_populate_bcn_ie_list(scan_entry); |
| 1047 | if (QDF_IS_STATUS_ERROR(status)) { |
Om Prakash Tripathi | 8e9beae | 2018-04-27 14:35:39 +0530 | [diff] [blame] | 1048 | scm_debug("failed to parse beacon IE"); |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 1049 | qdf_mem_free(scan_entry->raw_frame.ptr); |
| 1050 | qdf_mem_free(scan_entry); |
Sandeep Puligilla | c676459 | 2017-12-05 21:01:52 -0800 | [diff] [blame] | 1051 | qdf_mem_free(scan_list); |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 1052 | return NULL; |
| 1053 | } |
| 1054 | |
| 1055 | if (!scan_entry->ie_list.rates) { |
| 1056 | qdf_mem_free(scan_entry->raw_frame.ptr); |
| 1057 | qdf_mem_free(scan_entry); |
Sandeep Puligilla | c676459 | 2017-12-05 21:01:52 -0800 | [diff] [blame] | 1058 | qdf_mem_free(scan_list); |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 1059 | return NULL; |
| 1060 | } |
| 1061 | |
| 1062 | ssid = (struct ie_ssid *) |
| 1063 | scan_entry->ie_list.ssid; |
| 1064 | |
| 1065 | if (ssid && (ssid->ssid_len > WLAN_SSID_MAX_LEN)) { |
| 1066 | qdf_mem_free(scan_entry->raw_frame.ptr); |
| 1067 | qdf_mem_free(scan_entry); |
Sandeep Puligilla | c676459 | 2017-12-05 21:01:52 -0800 | [diff] [blame] | 1068 | qdf_mem_free(scan_list); |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 1069 | return NULL; |
| 1070 | } |
| 1071 | |
| 1072 | if (scan_entry->ie_list.p2p) |
| 1073 | scan_entry->is_p2p = true; |
| 1074 | |
| 1075 | /* If no channel info is present in beacon use meta channel */ |
| 1076 | if (!scan_entry->channel.chan_idx) { |
| 1077 | scan_entry->channel.chan_idx = |
| 1078 | rx_param->channel; |
| 1079 | } else if (rx_param->channel != |
| 1080 | scan_entry->channel.chan_idx) { |
Shashikala Prabhu | 7edbb05 | 2018-04-12 09:55:25 +0530 | [diff] [blame] | 1081 | if (!wlan_reg_chan_is_49ghz(pdev, scan_entry->channel.chan_idx)) |
| 1082 | scan_entry->channel_mismatch = true; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 1083 | } |
| 1084 | |
| 1085 | if (util_scan_is_hidden_ssid(ssid)) { |
| 1086 | scan_entry->ie_list.ssid = NULL; |
| 1087 | } else { |
| 1088 | qdf_mem_copy(scan_entry->ssid.ssid, |
| 1089 | ssid->ssid, WLAN_SSID_MAX_LEN); |
| 1090 | scan_entry->ssid.length = ssid->ssid_len; |
| 1091 | scan_entry->hidden_ssid_timestamp = |
| 1092 | scan_entry->scan_entry_time; |
| 1093 | } |
| 1094 | |
| 1095 | if (WLAN_CHAN_IS_5GHZ(scan_entry->channel.chan_idx)) |
| 1096 | scan_entry->phy_mode = util_scan_get_phymode_5g(scan_entry); |
| 1097 | else |
| 1098 | scan_entry->phy_mode = util_scan_get_phymode_2g(scan_entry); |
| 1099 | |
Abhishek Singh | b80af7e | 2017-07-19 18:48:42 +0530 | [diff] [blame] | 1100 | scan_entry->nss = util_scan_scm_calc_nss_supported_by_ap(scan_entry); |
| 1101 | util_scan_scm_update_bss_with_esp_data(scan_entry); |
Abhishek Singh | 7b59903 | 2017-11-10 14:42:31 +0530 | [diff] [blame] | 1102 | qbss_load = (struct qbss_load_ie *) |
| 1103 | util_scan_entry_qbssload(scan_entry); |
| 1104 | if (qbss_load) |
| 1105 | scan_entry->qbss_chan_load = qbss_load->qbss_chan_load; |
Abhishek Singh | b80af7e | 2017-07-19 18:48:42 +0530 | [diff] [blame] | 1106 | |
Om Prakash Tripathi | 9b56f5d | 2018-05-29 11:42:19 +0530 | [diff] [blame] | 1107 | scan_node = qdf_mem_malloc_atomic(sizeof(*scan_node)); |
Sandeep Puligilla | c676459 | 2017-12-05 21:01:52 -0800 | [diff] [blame] | 1108 | if (!scan_node) { |
Om Prakash Tripathi | 5240255 | 2018-02-21 16:31:49 +0530 | [diff] [blame] | 1109 | qdf_mem_free(scan_entry->raw_frame.ptr); |
Sandeep Puligilla | c676459 | 2017-12-05 21:01:52 -0800 | [diff] [blame] | 1110 | qdf_mem_free(scan_entry); |
| 1111 | qdf_mem_free(scan_list); |
| 1112 | return NULL; |
| 1113 | } |
| 1114 | |
| 1115 | scan_node->entry = scan_entry; |
| 1116 | qdf_list_insert_front(scan_list, &scan_node->node); |
| 1117 | |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 1118 | /* TODO calculate channel struct */ |
Sandeep Puligilla | c676459 | 2017-12-05 21:01:52 -0800 | [diff] [blame] | 1119 | return scan_list; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 1120 | } |
Om Prakash Tripathi | c3fcb68 | 2017-08-01 18:24:55 +0530 | [diff] [blame] | 1121 | |
| 1122 | QDF_STATUS |
| 1123 | util_scan_entry_update_mlme_info(struct wlan_objmgr_pdev *pdev, |
| 1124 | struct scan_cache_entry *scan_entry) |
| 1125 | { |
| 1126 | |
| 1127 | if (!pdev || !scan_entry) { |
Jeff Johnson | 878533e | 2017-09-18 10:07:54 -0700 | [diff] [blame] | 1128 | scm_err("pdev 0x%pK, scan_entry: 0x%pK", pdev, scan_entry); |
Om Prakash Tripathi | c3fcb68 | 2017-08-01 18:24:55 +0530 | [diff] [blame] | 1129 | return QDF_STATUS_E_INVAL; |
| 1130 | } |
| 1131 | |
| 1132 | return scm_update_scan_mlme_info(pdev, scan_entry); |
| 1133 | } |
Sandeep Puligilla | f57464c | 2017-11-16 23:31:52 -0800 | [diff] [blame] | 1134 | |
| 1135 | bool util_is_scan_completed(struct scan_event *event, bool *success) |
| 1136 | { |
| 1137 | if ((event->type == SCAN_EVENT_TYPE_COMPLETED) || |
| 1138 | (event->type == SCAN_EVENT_TYPE_DEQUEUED) || |
| 1139 | (event->type == SCAN_EVENT_TYPE_START_FAILED)) { |
| 1140 | if ((event->type == SCAN_EVENT_TYPE_COMPLETED) && |
| 1141 | (event->reason == SCAN_REASON_COMPLETED)) |
| 1142 | *success = true; |
| 1143 | else |
| 1144 | *success = false; |
| 1145 | |
| 1146 | return true; |
| 1147 | } |
| 1148 | |
| 1149 | *success = false; |
| 1150 | return false; |
| 1151 | } |
| 1152 | |