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> |
| 28 | |
| 29 | const char* |
| 30 | util_scan_get_ev_type_name(enum scan_event_type type) |
| 31 | { |
| 32 | static const char * const event_name[] = { |
| 33 | [SCAN_EVENT_TYPE_STARTED] = "STARTED", |
| 34 | [SCAN_EVENT_TYPE_COMPLETED] = "COMPLETED", |
| 35 | [SCAN_EVENT_TYPE_BSS_CHANNEL] = "HOME_CHANNEL", |
| 36 | [SCAN_EVENT_TYPE_FOREIGN_CHANNEL] = "FOREIGN_CHANNEL", |
| 37 | [SCAN_EVENT_TYPE_DEQUEUED] = "DEQUEUED", |
| 38 | [SCAN_EVENT_TYPE_PREEMPTED] = "PREEMPTED", |
| 39 | [SCAN_EVENT_TYPE_START_FAILED] = "START_FAILED", |
| 40 | [SCAN_EVENT_TYPE_RESTARTED] = "RESTARTED", |
| 41 | [SCAN_EVENT_TYPE_FOREIGN_CHANNEL_EXIT] = "FOREIGN_CHANNEL_EXIT", |
| 42 | [SCAN_EVENT_TYPE_SUSPENDED] = "SUSPENDED", |
| 43 | [SCAN_EVENT_TYPE_RESUMED] = "RESUMED", |
| 44 | [SCAN_EVENT_TYPE_NLO_COMPLETE] = "NLO_COMPLETE", |
Abhishek Singh | 8c6e82d | 2017-03-03 21:57:29 +0530 | [diff] [blame] | 45 | [SCAN_EVENT_TYPE_NLO_MATCH] = "NLO_MATCH", |
Om Prakash Tripathi | 22f95dc | 2016-12-19 10:45:59 +0530 | [diff] [blame] | 46 | [SCAN_EVENT_TYPE_INVALID] = "INVALID", |
| 47 | [SCAN_EVENT_TYPE_GPIO_TIMEOUT] = "GPIO_TIMEOUT", |
| 48 | [SCAN_EVENT_TYPE_RADIO_MEASUREMENT_START] = |
| 49 | "RADIO_MEASUREMENT_START", |
| 50 | [SCAN_EVENT_TYPE_RADIO_MEASUREMENT_END] = |
| 51 | "RADIO_MEASUREMENT_END", |
| 52 | [SCAN_EVENT_TYPE_BSSID_MATCH] = "BSSID_MATCH", |
| 53 | [SCAN_EVENT_TYPE_FOREIGN_CHANNEL_GET_NF] = |
| 54 | "FOREIGN_CHANNEL_GET_NF", |
| 55 | }; |
| 56 | |
Abhishek Singh | 483d914 | 2017-03-06 13:28:13 +0530 | [diff] [blame] | 57 | if (type >= SCAN_EVENT_TYPE_MAX) |
Om Prakash Tripathi | 22f95dc | 2016-12-19 10:45:59 +0530 | [diff] [blame] | 58 | return "UNKNOWN"; |
Om Prakash Tripathi | 22f95dc | 2016-12-19 10:45:59 +0530 | [diff] [blame] | 59 | |
| 60 | return event_name[type]; |
| 61 | } |
| 62 | |
| 63 | |
| 64 | const char* |
| 65 | util_scan_get_ev_reason_name(enum scan_completion_reason reason) |
| 66 | { |
| 67 | static const char * const reason_name[] = { |
| 68 | [SCAN_REASON_NONE] = "NONE", |
| 69 | [SCAN_REASON_COMPLETED] = "COMPLETED", |
| 70 | [SCAN_REASON_CANCELLED] = "CANCELLED", |
| 71 | [SCAN_REASON_PREEMPTED] = "PREEMPTED", |
| 72 | [SCAN_REASON_TIMEDOUT] = "TIMEDOUT", |
| 73 | [SCAN_REASON_INTERNAL_FAILURE] = "INTERNAL_FAILURE", |
| 74 | [SCAN_REASON_SUSPENDED] = "SUSPENDED", |
| 75 | [SCAN_REASON_RUN_FAILED] = "RUN_FAILED", |
| 76 | [SCAN_REASON_TERMINATION_FUNCTION] = "TERMINATION_FUNCTION", |
| 77 | [SCAN_REASON_MAX_OFFCHAN_RETRIES] = "MAX_OFFCHAN_RETRIES", |
| 78 | }; |
| 79 | |
Abhishek Singh | 483d914 | 2017-03-06 13:28:13 +0530 | [diff] [blame] | 80 | if (reason >= SCAN_REASON_MAX) |
Om Prakash Tripathi | 22f95dc | 2016-12-19 10:45:59 +0530 | [diff] [blame] | 81 | return "UNKNOWN"; |
Om Prakash Tripathi | 22f95dc | 2016-12-19 10:45:59 +0530 | [diff] [blame] | 82 | |
| 83 | return reason_name[reason]; |
| 84 | } |
| 85 | |
| 86 | qdf_time_t |
| 87 | util_get_last_scan_time(struct wlan_objmgr_vdev *vdev) |
| 88 | { |
| 89 | uint8_t pdev_id; |
| 90 | struct wlan_scan_obj *scan_obj; |
| 91 | |
| 92 | if (!vdev) { |
| 93 | scm_warn("null vdev"); |
| 94 | QDF_ASSERT(0); |
| 95 | return 0; |
| 96 | } |
| 97 | pdev_id = wlan_scan_vdev_get_pdev_id(vdev); |
| 98 | scan_obj = wlan_vdev_get_scan_obj(vdev); |
| 99 | |
| 100 | return scan_obj->pdev_info[pdev_id].last_scan_time; |
| 101 | } |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 102 | |
Abhishek Singh | b80af7e | 2017-07-19 18:48:42 +0530 | [diff] [blame] | 103 | enum wlan_band util_scan_scm_chan_to_band(uint32_t chan) |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 104 | { |
| 105 | if (WLAN_CHAN_IS_2GHZ(chan)) |
| 106 | return WLAN_BAND_2_4_GHZ; |
| 107 | |
| 108 | return WLAN_BAND_5_GHZ; |
| 109 | } |
| 110 | |
Abhishek Singh | d4e600f | 2017-02-21 15:16:28 +0530 | [diff] [blame] | 111 | bool util_is_scan_entry_match( |
| 112 | struct scan_cache_entry *entry1, |
| 113 | struct scan_cache_entry *entry2) |
| 114 | { |
| 115 | |
| 116 | if (entry1->cap_info.wlan_caps.ess != |
wadesong | 49ae4cb | 2018-01-22 15:03:12 +0800 | [diff] [blame] | 117 | entry2->cap_info.wlan_caps.ess) |
Abhishek Singh | d4e600f | 2017-02-21 15:16:28 +0530 | [diff] [blame] | 118 | return false; |
| 119 | |
| 120 | if (entry1->cap_info.wlan_caps.ess && |
| 121 | !qdf_mem_cmp(entry1->bssid.bytes, |
Om Prakash Tripathi | c3fcb68 | 2017-08-01 18:24:55 +0530 | [diff] [blame] | 122 | entry2->bssid.bytes, QDF_MAC_ADDR_SIZE) && |
Abhishek Singh | b80af7e | 2017-07-19 18:48:42 +0530 | [diff] [blame] | 123 | util_scan_scm_chan_to_band( |
Abhishek Singh | d4e600f | 2017-02-21 15:16:28 +0530 | [diff] [blame] | 124 | entry1->channel.chan_idx) == |
Abhishek Singh | b80af7e | 2017-07-19 18:48:42 +0530 | [diff] [blame] | 125 | util_scan_scm_chan_to_band(entry2->channel.chan_idx)) { |
Abhishek Singh | d4e600f | 2017-02-21 15:16:28 +0530 | [diff] [blame] | 126 | /* Check for BSS */ |
| 127 | if (util_is_ssid_match( |
| 128 | &entry1->ssid, &entry2->ssid)) |
| 129 | return true; |
| 130 | } else if (entry1->cap_info.wlan_caps.ibss && |
| 131 | (entry1->channel.chan_idx == |
| 132 | entry2->channel.chan_idx)) { |
| 133 | /* |
| 134 | * Same channel cannot have same SSID for |
| 135 | * different IBSS, so no need to check BSSID |
| 136 | */ |
| 137 | if (util_is_ssid_match( |
| 138 | &entry1->ssid, &entry2->ssid)) |
| 139 | return true; |
| 140 | } else if (!entry1->cap_info.wlan_caps.ibss && |
| 141 | !entry1->cap_info.wlan_caps.ess && |
| 142 | !qdf_mem_cmp(entry1->bssid.bytes, |
Om Prakash Tripathi | c3fcb68 | 2017-08-01 18:24:55 +0530 | [diff] [blame] | 143 | entry2->bssid.bytes, QDF_MAC_ADDR_SIZE)) { |
Abhishek Singh | d4e600f | 2017-02-21 15:16:28 +0530 | [diff] [blame] | 144 | /* In case of P2P devices, ess and ibss will be set to zero */ |
| 145 | return true; |
| 146 | } |
| 147 | |
| 148 | return false; |
| 149 | } |
| 150 | |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 151 | static bool util_is_pureg_rate(uint8_t *rates, uint8_t nrates) |
| 152 | { |
| 153 | static const uint8_t g_rates[] = {12, 18, 24, 36, 48, 72, 96, 108}; |
| 154 | bool pureg = false; |
| 155 | uint8_t i, j; |
| 156 | |
| 157 | for (i = 0; i < nrates; i++) { |
| 158 | for (j = 0; j < QDF_ARRAY_SIZE(g_rates); j++) { |
| 159 | if (WLAN_RV(rates[i]) == g_rates[j]) { |
| 160 | pureg = true; |
| 161 | break; |
| 162 | } |
| 163 | } |
| 164 | if (pureg) |
| 165 | break; |
| 166 | } |
| 167 | |
| 168 | return pureg; |
| 169 | } |
| 170 | static enum wlan_phymode |
| 171 | util_scan_get_phymode_5g(struct scan_cache_entry *scan_params) |
| 172 | { |
| 173 | enum wlan_phymode phymode = WLAN_PHYMODE_AUTO; |
| 174 | uint16_t ht_cap = 0; |
| 175 | struct htcap_cmn_ie *htcap; |
| 176 | struct wlan_ie_htinfo_cmn *htinfo; |
| 177 | struct wlan_ie_vhtop *vhtop; |
| 178 | |
| 179 | htcap = (struct htcap_cmn_ie *) |
| 180 | util_scan_entry_htcap(scan_params); |
| 181 | htinfo = (struct wlan_ie_htinfo_cmn *) |
| 182 | util_scan_entry_htinfo(scan_params); |
| 183 | vhtop = (struct wlan_ie_vhtop *) |
| 184 | util_scan_entry_vhtop(scan_params); |
| 185 | |
| 186 | if (!(htcap && htinfo)) |
| 187 | return WLAN_PHYMODE_11A; |
| 188 | |
| 189 | if (htcap) |
| 190 | ht_cap = le16toh(htcap->hc_cap); |
| 191 | |
| 192 | if (util_scan_entry_vhtcap(scan_params) && vhtop) { |
| 193 | switch (vhtop->vht_op_chwidth) { |
| 194 | case WLAN_VHTOP_CHWIDTH_2040: |
| 195 | if ((ht_cap & WLAN_HTCAP_C_CHWIDTH40) && |
| 196 | (htinfo->hi_extchoff == |
| 197 | WLAN_HTINFO_EXTOFFSET_ABOVE)) |
| 198 | phymode = WLAN_PHYMODE_11AC_VHT40PLUS; |
| 199 | else if ((ht_cap & WLAN_HTCAP_C_CHWIDTH40) && |
| 200 | (htinfo->hi_extchoff == |
| 201 | WLAN_HTINFO_EXTOFFSET_BELOW)) |
| 202 | phymode = WLAN_PHYMODE_11AC_VHT40MINUS; |
| 203 | else |
| 204 | phymode = WLAN_PHYMODE_11AC_VHT20; |
| 205 | break; |
| 206 | case WLAN_VHTOP_CHWIDTH_80: |
| 207 | if (WLAN_IS_REVSIG_VHT80_80(vhtop)) |
| 208 | phymode = WLAN_PHYMODE_11AC_VHT80_80; |
| 209 | else if (WLAN_IS_REVSIG_VHT160(vhtop)) |
| 210 | phymode = WLAN_PHYMODE_11AC_VHT160; |
| 211 | else |
| 212 | phymode = WLAN_PHYMODE_11AC_VHT80; |
| 213 | break; |
| 214 | case WLAN_VHTOP_CHWIDTH_160: |
| 215 | phymode = WLAN_PHYMODE_11AC_VHT160; |
| 216 | break; |
| 217 | case WLAN_VHTOP_CHWIDTH_80_80: |
| 218 | phymode = WLAN_PHYMODE_11AC_VHT80_80; |
| 219 | break; |
| 220 | default: |
| 221 | scm_err("bad channel: %d", |
| 222 | vhtop->vht_op_chwidth); |
| 223 | break; |
| 224 | } |
| 225 | } else if ((ht_cap & WLAN_HTCAP_C_CHWIDTH40) && |
| 226 | (htinfo->hi_extchoff == WLAN_HTINFO_EXTOFFSET_ABOVE)) |
| 227 | phymode = WLAN_PHYMODE_11NA_HT40PLUS; |
| 228 | else if ((ht_cap & WLAN_HTCAP_C_CHWIDTH40) && |
| 229 | (htinfo->hi_extchoff == WLAN_HTINFO_EXTOFFSET_BELOW)) |
| 230 | phymode = WLAN_PHYMODE_11NA_HT40MINUS; |
| 231 | else |
| 232 | phymode = WLAN_PHYMODE_11NA_HT20; |
| 233 | |
| 234 | return phymode; |
| 235 | } |
| 236 | |
| 237 | static enum wlan_phymode |
| 238 | util_scan_get_phymode_2g(struct scan_cache_entry *scan_params) |
| 239 | { |
| 240 | enum wlan_phymode phymode = WLAN_PHYMODE_AUTO; |
| 241 | uint16_t ht_cap = 0; |
| 242 | struct htcap_cmn_ie *htcap; |
| 243 | struct wlan_ie_htinfo_cmn *htinfo; |
| 244 | struct wlan_ie_vhtop *vhtop; |
| 245 | |
| 246 | htcap = (struct htcap_cmn_ie *) |
| 247 | util_scan_entry_htcap(scan_params); |
| 248 | htinfo = (struct wlan_ie_htinfo_cmn *) |
| 249 | util_scan_entry_htinfo(scan_params); |
| 250 | vhtop = (struct wlan_ie_vhtop *) |
| 251 | util_scan_entry_vhtop(scan_params); |
| 252 | |
| 253 | if (htcap) |
| 254 | ht_cap = le16toh(htcap->hc_cap); |
| 255 | |
| 256 | if (htcap && htinfo) { |
| 257 | if ((ht_cap & WLAN_HTCAP_C_CHWIDTH40) && |
| 258 | (htinfo->hi_extchoff == WLAN_HTINFO_EXTOFFSET_ABOVE)) |
| 259 | phymode = WLAN_PHYMODE_11NG_HT40PLUS; |
| 260 | else if ((ht_cap & WLAN_HTCAP_C_CHWIDTH40) && |
| 261 | (htinfo->hi_extchoff == WLAN_HTINFO_EXTOFFSET_BELOW)) |
| 262 | phymode = WLAN_PHYMODE_11NG_HT40MINUS; |
| 263 | else |
| 264 | phymode = WLAN_PHYMODE_11NG_HT20; |
| 265 | } else if (util_scan_entry_xrates(scan_params)) { |
| 266 | /* only 11G stations will have more than 8 rates */ |
| 267 | phymode = WLAN_PHYMODE_11G; |
| 268 | } else { |
| 269 | /* Some mischievous g-only APs do not set extended rates */ |
| 270 | if (util_scan_entry_rates(scan_params)) { |
| 271 | if (util_is_pureg_rate(&scan_params->ie_list.rates[2], |
| 272 | scan_params->ie_list.rates[1])) |
| 273 | phymode = WLAN_PHYMODE_11G; |
| 274 | else |
| 275 | phymode = WLAN_PHYMODE_11B; |
| 276 | } else { |
| 277 | phymode = WLAN_PHYMODE_11B; |
| 278 | } |
| 279 | } |
| 280 | |
| 281 | return phymode; |
| 282 | } |
| 283 | |
| 284 | static QDF_STATUS |
| 285 | util_scan_parse_chan_switch_wrapper_ie(struct scan_cache_entry *scan_params, |
| 286 | struct ie_header *sub_ie, qdf_size_t sub_ie_len) |
| 287 | { |
| 288 | /* Walk through to check nothing is malformed */ |
| 289 | while (sub_ie_len >= sizeof(struct ie_header)) { |
| 290 | /* At least one more header is present */ |
| 291 | sub_ie_len -= sizeof(struct ie_header); |
| 292 | |
| 293 | if (sub_ie->ie_len == 0) { |
| 294 | sub_ie += 1; |
| 295 | continue; |
| 296 | } |
| 297 | if (sub_ie_len < sub_ie->ie_len) { |
| 298 | scm_err("Incomplete corrupted IE:%x", |
| 299 | WLAN_ELEMID_CHAN_SWITCH_WRAP); |
| 300 | return QDF_STATUS_E_INVAL; |
| 301 | } |
| 302 | switch (sub_ie->ie_id) { |
| 303 | case WLAN_ELEMID_COUNTRY: |
| 304 | scan_params->ie_list.country = (uint8_t *)sub_ie; |
| 305 | break; |
| 306 | case WLAN_ELEMID_WIDE_BAND_CHAN_SWITCH: |
| 307 | scan_params->ie_list.widebw = (uint8_t *)sub_ie; |
| 308 | break; |
| 309 | case WLAN_ELEMID_VHT_TX_PWR_ENVLP: |
| 310 | scan_params->ie_list.txpwrenvlp = (uint8_t *)sub_ie; |
| 311 | break; |
| 312 | } |
| 313 | /* Consume sub info element */ |
| 314 | sub_ie_len -= sub_ie->ie_len; |
| 315 | /* go to next Sub IE */ |
| 316 | sub_ie = (struct ie_header *) |
| 317 | (((uint8_t *) sub_ie) + |
| 318 | sizeof(struct ie_header) + sub_ie->ie_len); |
| 319 | } |
| 320 | |
| 321 | return QDF_STATUS_SUCCESS; |
| 322 | } |
| 323 | |
Om Prakash Tripathi | 1d1525d | 2017-09-08 13:59:34 +0530 | [diff] [blame] | 324 | bool |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 325 | util_scan_is_hidden_ssid(struct ie_ssid *ssid) |
| 326 | { |
| 327 | uint8_t i; |
| 328 | |
| 329 | /* |
| 330 | * We flag this as Hidden SSID if the Length is 0 |
| 331 | * of the SSID only contains 0's |
| 332 | */ |
| 333 | if (!ssid || !ssid->ssid_len) |
| 334 | return true; |
| 335 | |
| 336 | for (i = 0; i < ssid->ssid_len; i++) |
| 337 | if (ssid->ssid[i] != 0) |
| 338 | return false; |
| 339 | |
| 340 | /* All 0's */ |
| 341 | return true; |
| 342 | } |
| 343 | |
| 344 | static void |
Venkateswara Swamy Bandaru | 851184b | 2017-04-25 11:02:39 +0530 | [diff] [blame] | 345 | util_scan_parse_extn_ie(struct scan_cache_entry *scan_params, |
| 346 | struct ie_header *ie) |
| 347 | { |
| 348 | struct extn_ie_header *extn_ie = (struct extn_ie_header *) ie; |
| 349 | |
| 350 | switch (extn_ie->ie_extn_id) { |
| 351 | case WLAN_EXTN_ELEMID_SRP: |
Gyanranjan Hazarika | b5d426d | 2017-08-22 21:45:07 -0700 | [diff] [blame] | 352 | scan_params->ie_list.srp = (uint8_t *)ie; |
| 353 | break; |
| 354 | case WLAN_EXTN_ELEMID_HECAP: |
| 355 | scan_params->ie_list.hecap = (uint8_t *)ie; |
| 356 | break; |
| 357 | case WLAN_EXTN_ELEMID_HEOP: |
| 358 | scan_params->ie_list.heop = (uint8_t *)ie; |
Venkateswara Swamy Bandaru | 851184b | 2017-04-25 11:02:39 +0530 | [diff] [blame] | 359 | break; |
Abhishek Singh | b80af7e | 2017-07-19 18:48:42 +0530 | [diff] [blame] | 360 | case WLAN_EXTN_ELEMID_ESP: |
| 361 | scan_params->ie_list.esp = (uint8_t *)ie; |
| 362 | break; |
Venkateswara Swamy Bandaru | 851184b | 2017-04-25 11:02:39 +0530 | [diff] [blame] | 363 | default: |
| 364 | break; |
| 365 | } |
| 366 | } |
| 367 | |
| 368 | static void |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 369 | util_scan_parse_vendor_ie(struct scan_cache_entry *scan_params, |
| 370 | struct ie_header *ie) |
| 371 | { |
| 372 | |
| 373 | if (scan_params->ie_list.vendor == NULL) |
| 374 | scan_params->ie_list.vendor = (uint8_t *)ie; |
| 375 | |
| 376 | if (is_wpa_oui((uint8_t *)ie)) { |
| 377 | scan_params->ie_list.wpa = (uint8_t *)ie; |
| 378 | } else if (is_wps_oui((uint8_t *)ie)) { |
| 379 | scan_params->ie_list.wps = (uint8_t *)ie; |
| 380 | /* WCN IE should be a subset of WPS IE */ |
| 381 | if (is_wcn_oui((uint8_t *)ie)) |
| 382 | scan_params->ie_list.wcn = (uint8_t *)ie; |
| 383 | } else if (is_wme_param((uint8_t *)ie)) { |
| 384 | scan_params->ie_list.wmeparam = (uint8_t *)ie; |
| 385 | } else if (is_wme_info((uint8_t *)ie)) { |
| 386 | scan_params->ie_list.wmeinfo = (uint8_t *)ie; |
| 387 | } else if (is_atheros_oui((uint8_t *)ie)) { |
| 388 | scan_params->ie_list.athcaps = (uint8_t *)ie; |
| 389 | } else if (is_atheros_extcap_oui((uint8_t *)ie)) { |
| 390 | scan_params->ie_list.athextcaps = (uint8_t *)ie; |
| 391 | } else if (is_sfa_oui((uint8_t *)ie)) { |
| 392 | scan_params->ie_list.sfa = (uint8_t *)ie; |
| 393 | } else if (is_p2p_oui((uint8_t *)ie)) { |
| 394 | scan_params->ie_list.p2p = (uint8_t *)ie; |
Bharat Bhushan Chakravarty | 145d393 | 2017-03-20 12:52:16 -0700 | [diff] [blame] | 395 | } else if (is_qca_son_oui((uint8_t *)ie, |
| 396 | QCA_OUI_WHC_AP_INFO_SUBTYPE)) { |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 397 | scan_params->ie_list.sonadv = (uint8_t *)ie; |
| 398 | } else if (is_ht_cap((uint8_t *)ie)) { |
| 399 | /* we only care if there isn't already an HT IE (ANA) */ |
| 400 | if (scan_params->ie_list.htcap == NULL) |
| 401 | scan_params->ie_list.htcap = |
| 402 | (uint8_t *)&(((struct wlan_vendor_ie_htcap *)ie)->ie); |
| 403 | } else if (is_ht_info((uint8_t *)ie)) { |
| 404 | /* we only care if there isn't already an HT IE (ANA) */ |
| 405 | if (scan_params->ie_list.htinfo == NULL) |
| 406 | scan_params->ie_list.htinfo = |
| 407 | (uint8_t *)&(((struct wlan_vendor_ie_htinfo *) |
| 408 | ie)->hi_ie); |
| 409 | } else if (is_interop_vht((uint8_t *)ie) && |
| 410 | !(scan_params->ie_list.vhtop)) { |
| 411 | /* location where Interop Vht Cap IE and VHT OP IE Present */ |
| 412 | scan_params->ie_list.vhtcap = (((uint8_t *)(ie)) + 7); |
| 413 | scan_params->ie_list.vhtop = (((uint8_t *)(ie)) + 21); |
| 414 | } else if (is_bwnss_oui((uint8_t *)ie)) { |
| 415 | /* |
| 416 | * Bandwidth-NSS map has sub-type & version. |
| 417 | * hence copy data just after version byte |
| 418 | */ |
| 419 | scan_params->ie_list.bwnss_map = (((uint8_t *)ie) + 8); |
Abhishek Singh | 7b59903 | 2017-11-10 14:42:31 +0530 | [diff] [blame] | 420 | } else if (is_mbo_oce_oui((uint8_t *)ie)) { |
| 421 | scan_params->ie_list.mbo_oce = (uint8_t *)ie; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 422 | } |
| 423 | } |
| 424 | |
| 425 | static QDF_STATUS |
| 426 | util_scan_populate_bcn_ie_list(struct scan_cache_entry *scan_params) |
| 427 | { |
| 428 | struct ie_header *ie, *sub_ie; |
| 429 | uint32_t ie_len, sub_ie_len; |
| 430 | QDF_STATUS status; |
| 431 | |
| 432 | ie_len = util_scan_entry_ie_len(scan_params); |
| 433 | ie = (struct ie_header *) |
| 434 | util_scan_entry_ie_data(scan_params); |
| 435 | |
| 436 | while (ie_len >= sizeof(struct ie_header)) { |
| 437 | ie_len -= sizeof(struct ie_header); |
| 438 | |
| 439 | if (!ie->ie_len) { |
| 440 | ie += 1; |
| 441 | continue; |
| 442 | } |
| 443 | |
| 444 | if (ie_len < ie->ie_len) { |
| 445 | scm_err("Incomplete corrupted IE:%x", |
| 446 | ie->ie_id); |
| 447 | return QDF_STATUS_E_INVAL; |
| 448 | } |
| 449 | |
| 450 | switch (ie->ie_id) { |
| 451 | case WLAN_ELEMID_SSID: |
| 452 | scan_params->ie_list.ssid = (uint8_t *)ie; |
| 453 | break; |
| 454 | case WLAN_ELEMID_RATES: |
| 455 | scan_params->ie_list.rates = (uint8_t *)ie; |
| 456 | break; |
| 457 | case WLAN_ELEMID_DSPARMS: |
Abhishek Singh | c05285d | 2018-01-12 15:19:32 +0530 | [diff] [blame^] | 458 | scan_params->ie_list.ds_param = (uint8_t *)ie; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 459 | scan_params->channel.chan_idx = |
| 460 | ((struct ds_ie *)ie)->cur_chan; |
| 461 | break; |
| 462 | case WLAN_ELEMID_TIM: |
| 463 | scan_params->ie_list.tim = (uint8_t *)ie; |
| 464 | scan_params->dtim_period = |
| 465 | ((struct wlan_tim_ie *)ie)->tim_period; |
| 466 | break; |
| 467 | case WLAN_ELEMID_COUNTRY: |
| 468 | scan_params->ie_list.country = (uint8_t *)ie; |
| 469 | break; |
| 470 | case WLAN_ELEMID_QBSS_LOAD: |
| 471 | scan_params->ie_list.qbssload = (uint8_t *)ie; |
| 472 | break; |
| 473 | case WLAN_ELEMID_CHANSWITCHANN: |
| 474 | scan_params->ie_list.csa = (uint8_t *)ie; |
| 475 | break; |
| 476 | case WLAN_ELEMID_IBSSDFS: |
| 477 | scan_params->ie_list.ibssdfs = (uint8_t *)ie; |
| 478 | break; |
| 479 | case WLAN_ELEMID_QUIET: |
| 480 | scan_params->ie_list.quiet = (uint8_t *)ie; |
| 481 | break; |
| 482 | case WLAN_ELEMID_ERP: |
| 483 | scan_params->erp = ((struct erp_ie *)ie)->value; |
| 484 | break; |
| 485 | case WLAN_ELEMID_HTCAP_ANA: |
| 486 | scan_params->ie_list.htcap = |
| 487 | (uint8_t *)&(((struct htcap_ie *)ie)->ie); |
| 488 | break; |
| 489 | case WLAN_ELEMID_RSN: |
| 490 | scan_params->ie_list.rsn = (uint8_t *)ie; |
| 491 | break; |
| 492 | case WLAN_ELEMID_XRATES: |
| 493 | scan_params->ie_list.xrates = (uint8_t *)ie; |
| 494 | break; |
| 495 | case WLAN_ELEMID_EXTCHANSWITCHANN: |
| 496 | scan_params->ie_list.xcsa = (uint8_t *)ie; |
| 497 | break; |
| 498 | case WLAN_ELEMID_SECCHANOFFSET: |
| 499 | scan_params->ie_list.secchanoff = (uint8_t *)ie; |
| 500 | break; |
| 501 | case WLAN_ELEMID_HTINFO_ANA: |
| 502 | scan_params->ie_list.htinfo = |
| 503 | (uint8_t *)&(((struct wlan_ie_htinfo *) ie)->hi_ie); |
| 504 | scan_params->channel.chan_idx = |
| 505 | ((struct wlan_ie_htinfo_cmn *) |
| 506 | (scan_params->ie_list.htinfo))->hi_ctrlchannel; |
| 507 | break; |
| 508 | case WLAN_ELEMID_WAPI: |
| 509 | scan_params->ie_list.wapi = (uint8_t *)ie; |
| 510 | break; |
| 511 | case WLAN_ELEMID_XCAPS: |
| 512 | scan_params->ie_list.extcaps = (uint8_t *)ie; |
| 513 | break; |
| 514 | case WLAN_ELEMID_VHTCAP: |
| 515 | scan_params->ie_list.vhtcap = (uint8_t *)ie; |
| 516 | break; |
| 517 | case WLAN_ELEMID_VHTOP: |
| 518 | scan_params->ie_list.vhtop = (uint8_t *)ie; |
| 519 | break; |
| 520 | case WLAN_ELEMID_OP_MODE_NOTIFY: |
| 521 | scan_params->ie_list.opmode = (uint8_t *)ie; |
| 522 | break; |
| 523 | case WLAN_ELEMID_MOBILITY_DOMAIN: |
| 524 | scan_params->ie_list.mdie = (uint8_t *)ie; |
| 525 | break; |
| 526 | case WLAN_ELEMID_VENDOR: |
| 527 | util_scan_parse_vendor_ie(scan_params, |
| 528 | ie); |
| 529 | break; |
| 530 | case WLAN_ELEMID_CHAN_SWITCH_WRAP: |
| 531 | scan_params->ie_list.cswrp = (uint8_t *)ie; |
| 532 | /* Go to next sub IE */ |
| 533 | sub_ie = (struct ie_header *) |
| 534 | (((uint8_t *)ie) + sizeof(struct ie_header)); |
| 535 | sub_ie_len = ie->ie_len; |
| 536 | status = |
| 537 | util_scan_parse_chan_switch_wrapper_ie( |
| 538 | scan_params, sub_ie, sub_ie_len); |
| 539 | if (QDF_IS_STATUS_ERROR(status)) { |
| 540 | scm_err("failed to parse chan_switch_wrapper_ie"); |
| 541 | return status; |
| 542 | } |
| 543 | break; |
Kapil Gupta | de02d4f | 2017-06-05 12:37:59 +0530 | [diff] [blame] | 544 | case WLAN_ELEMID_FILS_INDICATION: |
| 545 | scan_params->ie_list.fils_indication = (uint8_t *)ie; |
| 546 | break; |
Venkateswara Swamy Bandaru | 851184b | 2017-04-25 11:02:39 +0530 | [diff] [blame] | 547 | case WLAN_ELEMID_EXTN_ELEM: |
| 548 | util_scan_parse_extn_ie(scan_params, ie); |
| 549 | break; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 550 | default: |
| 551 | break; |
| 552 | } |
| 553 | |
| 554 | /* Consume info element */ |
| 555 | ie_len -= ie->ie_len; |
| 556 | /* Go to next IE */ |
| 557 | ie = (struct ie_header *) |
| 558 | (((uint8_t *) ie) + |
| 559 | sizeof(struct ie_header) + |
| 560 | ie->ie_len); |
| 561 | } |
| 562 | |
| 563 | return QDF_STATUS_SUCCESS; |
| 564 | } |
| 565 | |
Abhishek Singh | b80af7e | 2017-07-19 18:48:42 +0530 | [diff] [blame] | 566 | /** |
| 567 | * util_scan_update_esp_data: update ESP params from beacon/probe response |
| 568 | * @esp_information: pointer to wlan_esp_information |
| 569 | * @scan_entry: new received entry |
| 570 | * |
| 571 | * The Estimated Service Parameters element is |
| 572 | * used by a AP to provide information to another STA which |
| 573 | * can then use the information as input to an algorithm to |
| 574 | * generate an estimate of throughput between the two STAs. |
| 575 | * The ESP Information List field contains from 1 to 4 ESP |
| 576 | * Information fields(each field 24 bits), each corresponding |
| 577 | * to an access category for which estimated service parameters |
| 578 | * information is provided. |
| 579 | * |
| 580 | * Return: None |
| 581 | */ |
| 582 | static void util_scan_update_esp_data(struct wlan_esp_ie *esp_information, |
| 583 | struct scan_cache_entry *scan_entry) |
| 584 | { |
| 585 | |
| 586 | uint8_t *data; |
| 587 | int i = 0; |
Sathyanarayanan | 0a00062 | 2017-10-10 17:17:28 +0530 | [diff] [blame] | 588 | uint64_t total_elements; |
Abhishek Singh | b80af7e | 2017-07-19 18:48:42 +0530 | [diff] [blame] | 589 | struct wlan_esp_info *esp_info; |
| 590 | struct wlan_esp_ie *esp_ie; |
| 591 | |
| 592 | esp_ie = (struct wlan_esp_ie *) |
| 593 | util_scan_entry_esp_info(scan_entry); |
| 594 | |
| 595 | total_elements = esp_ie->esp_len; |
| 596 | data = (uint8_t *)esp_ie + 3; |
| 597 | do_div(total_elements, ESP_INFORMATION_LIST_LENGTH); |
| 598 | |
| 599 | if (total_elements > MAX_ESP_INFORMATION_FIELD) { |
| 600 | scm_err("No of Air time fractions are greater than supported"); |
| 601 | return; |
| 602 | } |
| 603 | |
| 604 | for (i = 0; i < total_elements; i++) { |
| 605 | esp_info = (struct wlan_esp_info *)data; |
| 606 | if (esp_info->access_category == ESP_AC_BK) { |
| 607 | qdf_mem_copy(&esp_information->esp_info_AC_BK, |
| 608 | data, 3); |
| 609 | data = data + ESP_INFORMATION_LIST_LENGTH; |
| 610 | continue; |
| 611 | } |
| 612 | if (esp_info->access_category == ESP_AC_BE) { |
| 613 | qdf_mem_copy(&esp_information->esp_info_AC_BE, |
| 614 | data, 3); |
| 615 | data = data + ESP_INFORMATION_LIST_LENGTH; |
| 616 | continue; |
| 617 | } |
| 618 | if (esp_info->access_category == ESP_AC_VI) { |
| 619 | qdf_mem_copy(&esp_information->esp_info_AC_VI, |
| 620 | data, 3); |
| 621 | data = data + ESP_INFORMATION_LIST_LENGTH; |
| 622 | continue; |
| 623 | } |
| 624 | if (esp_info->access_category == ESP_AC_VO) { |
| 625 | qdf_mem_copy(&esp_information->esp_info_AC_VO, |
| 626 | data, 3); |
| 627 | data = data + ESP_INFORMATION_LIST_LENGTH; |
| 628 | break; |
| 629 | } |
| 630 | } |
| 631 | } |
| 632 | |
| 633 | /** |
| 634 | * util_scan_scm_update_bss_with_esp_dataa: calculate estimated air time |
| 635 | * fraction |
| 636 | * @scan_entry: new received entry |
| 637 | * |
| 638 | * This function process all Access category ESP params and provide |
| 639 | * best effort air time fraction. |
| 640 | * If best effort is not available, it will choose VI, VO and BK in sequence |
| 641 | * |
| 642 | */ |
| 643 | static void util_scan_scm_update_bss_with_esp_data( |
| 644 | struct scan_cache_entry *scan_entry) |
| 645 | { |
| 646 | uint8_t air_time_fraction = 0; |
| 647 | struct wlan_esp_ie esp_information; |
| 648 | |
| 649 | if (!scan_entry->ie_list.esp) |
| 650 | return; |
| 651 | |
| 652 | util_scan_update_esp_data(&esp_information, scan_entry); |
| 653 | |
| 654 | /* |
| 655 | * If the ESP metric is transmitting multiple airtime fractions, then |
| 656 | * follow the sequence AC_BE, AC_VI, AC_VO, AC_BK and pick whichever is |
| 657 | * the first one available |
| 658 | */ |
| 659 | if (esp_information.esp_info_AC_BE.access_category |
| 660 | == ESP_AC_BE) |
| 661 | air_time_fraction = |
| 662 | esp_information.esp_info_AC_BE. |
| 663 | estimated_air_fraction; |
| 664 | else if (esp_information.esp_info_AC_VI.access_category |
| 665 | == ESP_AC_VI) |
| 666 | air_time_fraction = |
| 667 | esp_information.esp_info_AC_VI. |
| 668 | estimated_air_fraction; |
| 669 | else if (esp_information.esp_info_AC_VO.access_category |
| 670 | == ESP_AC_VO) |
| 671 | air_time_fraction = |
| 672 | esp_information.esp_info_AC_VO. |
| 673 | estimated_air_fraction; |
| 674 | else if (esp_information.esp_info_AC_BK.access_category |
| 675 | == ESP_AC_BK) |
| 676 | air_time_fraction = |
| 677 | esp_information.esp_info_AC_BK. |
| 678 | estimated_air_fraction; |
| 679 | scan_entry->air_time_fraction = air_time_fraction; |
| 680 | } |
| 681 | |
| 682 | /** |
| 683 | * util_scan_scm_calc_nss_supported_by_ap() - finds out nss from AP |
| 684 | * @scan_entry: new received entry |
| 685 | * |
| 686 | * Return: number of nss advertised by AP |
| 687 | */ |
| 688 | static int util_scan_scm_calc_nss_supported_by_ap( |
| 689 | struct scan_cache_entry *scan_params) |
| 690 | { |
| 691 | struct htcap_cmn_ie *htcap; |
| 692 | struct wlan_ie_vhtcaps *vhtcaps; |
| 693 | uint8_t rx_mcs_map; |
| 694 | |
| 695 | htcap = (struct htcap_cmn_ie *) |
| 696 | util_scan_entry_htcap(scan_params); |
| 697 | vhtcaps = (struct wlan_ie_vhtcaps *) |
| 698 | util_scan_entry_vhtcap(scan_params); |
| 699 | if (vhtcaps) { |
| 700 | rx_mcs_map = vhtcaps->rx_mcs_map; |
| 701 | if ((rx_mcs_map & 0xC0) != 0xC0) |
| 702 | return 4; |
| 703 | |
| 704 | if ((rx_mcs_map & 0x30) != 0x30) |
| 705 | return 3; |
| 706 | |
| 707 | if ((rx_mcs_map & 0x0C) != 0x0C) |
| 708 | return 2; |
| 709 | } else if (htcap) { |
| 710 | if (htcap->mcsset[3]) |
| 711 | return 4; |
| 712 | |
| 713 | if (htcap->mcsset[2]) |
| 714 | return 3; |
| 715 | |
| 716 | if (htcap->mcsset[1]) |
| 717 | return 2; |
| 718 | |
| 719 | } |
| 720 | return 1; |
| 721 | } |
| 722 | |
Sandeep Puligilla | c676459 | 2017-12-05 21:01:52 -0800 | [diff] [blame] | 723 | qdf_list_t * |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 724 | util_scan_unpack_beacon_frame(uint8_t *frame, |
| 725 | qdf_size_t frame_len, uint32_t frm_subtype, |
| 726 | struct mgmt_rx_event_params *rx_param) |
| 727 | { |
| 728 | struct wlan_frame_hdr *hdr; |
| 729 | struct wlan_bcn_frame *bcn; |
| 730 | QDF_STATUS status; |
| 731 | struct ie_ssid *ssid; |
Sandeep Puligilla | c676459 | 2017-12-05 21:01:52 -0800 | [diff] [blame] | 732 | struct scan_cache_entry *scan_entry; |
Abhishek Singh | 7b59903 | 2017-11-10 14:42:31 +0530 | [diff] [blame] | 733 | struct qbss_load_ie *qbss_load; |
Sandeep Puligilla | c676459 | 2017-12-05 21:01:52 -0800 | [diff] [blame] | 734 | qdf_list_t *scan_list; |
| 735 | struct scan_cache_node *scan_node; |
| 736 | |
| 737 | scan_list = qdf_mem_malloc(sizeof(*scan_list)); |
| 738 | if (!scan_list) { |
| 739 | scm_err("failed to allocate scan_list"); |
| 740 | return NULL; |
| 741 | } |
| 742 | qdf_list_create(scan_list, MAX_SCAN_CACHE_SIZE); |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 743 | |
| 744 | scan_entry = qdf_mem_malloc(sizeof(*scan_entry)); |
| 745 | if (!scan_entry) { |
| 746 | scm_err("failed to allocate memory for scan_entry"); |
Sandeep Puligilla | c676459 | 2017-12-05 21:01:52 -0800 | [diff] [blame] | 747 | qdf_mem_free(scan_list); |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 748 | return NULL; |
| 749 | } |
| 750 | scan_entry->raw_frame.ptr = |
| 751 | qdf_mem_malloc(frame_len); |
| 752 | if (!scan_entry->raw_frame.ptr) { |
| 753 | scm_err("failed to allocate memory for frame"); |
| 754 | qdf_mem_free(scan_entry); |
Sandeep Puligilla | c676459 | 2017-12-05 21:01:52 -0800 | [diff] [blame] | 755 | qdf_mem_free(scan_list); |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 756 | return NULL; |
| 757 | } |
| 758 | |
| 759 | bcn = (struct wlan_bcn_frame *) |
| 760 | (frame + sizeof(*hdr)); |
| 761 | hdr = (struct wlan_frame_hdr *)frame; |
| 762 | |
| 763 | scan_entry->frm_subtype = frm_subtype; |
| 764 | qdf_mem_copy(scan_entry->bssid.bytes, |
| 765 | hdr->i_addr3, QDF_MAC_ADDR_SIZE); |
| 766 | /* Scr addr */ |
| 767 | qdf_mem_copy(scan_entry->mac_addr.bytes, |
| 768 | hdr->i_addr2, QDF_MAC_ADDR_SIZE); |
| 769 | scan_entry->seq_num = |
| 770 | (le16toh(*(uint16_t *)hdr->i_seq) >> WLAN_SEQ_SEQ_SHIFT); |
| 771 | |
| 772 | scan_entry->rssi_raw = rx_param->rssi; |
Om Prakash Tripathi | 6af738b | 2017-08-22 15:46:38 +0530 | [diff] [blame] | 773 | scan_entry->avg_rssi = WLAN_RSSI_IN(scan_entry->rssi_raw); |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 774 | scan_entry->tsf_delta = rx_param->tsf_delta; |
| 775 | |
| 776 | /* store jiffies */ |
| 777 | scan_entry->rrm_parent_tsf = (u_int32_t) qdf_system_ticks(); |
| 778 | |
| 779 | scan_entry->bcn_int = le16toh(bcn->beacon_interval); |
| 780 | |
| 781 | /* |
| 782 | * In case if the beacon dosnt have |
| 783 | * valid beacon interval falback to def |
| 784 | */ |
| 785 | if (!scan_entry->bcn_int) |
| 786 | scan_entry->bcn_int = 100; |
| 787 | scan_entry->cap_info.value = le16toh(bcn->capability.value); |
| 788 | qdf_mem_copy(scan_entry->tsf_info.data, |
| 789 | bcn->timestamp, 8); |
| 790 | scan_entry->erp = ERP_NON_ERP_PRESENT; |
| 791 | |
Om Prakash Tripathi | cdcbb39 | 2017-04-18 18:51:20 +0530 | [diff] [blame] | 792 | scan_entry->scan_entry_time = |
| 793 | qdf_mc_timer_get_system_time(); |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 794 | |
| 795 | scan_entry->raw_frame.len = frame_len; |
| 796 | qdf_mem_copy(scan_entry->raw_frame.ptr, |
| 797 | frame, frame_len); |
| 798 | status = util_scan_populate_bcn_ie_list(scan_entry); |
| 799 | if (QDF_IS_STATUS_ERROR(status)) { |
| 800 | scm_err("failed to parse beacon IE"); |
| 801 | qdf_mem_free(scan_entry->raw_frame.ptr); |
| 802 | qdf_mem_free(scan_entry); |
Sandeep Puligilla | c676459 | 2017-12-05 21:01:52 -0800 | [diff] [blame] | 803 | qdf_mem_free(scan_list); |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 804 | return NULL; |
| 805 | } |
| 806 | |
| 807 | if (!scan_entry->ie_list.rates) { |
| 808 | qdf_mem_free(scan_entry->raw_frame.ptr); |
| 809 | qdf_mem_free(scan_entry); |
Sandeep Puligilla | c676459 | 2017-12-05 21:01:52 -0800 | [diff] [blame] | 810 | qdf_mem_free(scan_list); |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 811 | return NULL; |
| 812 | } |
| 813 | |
| 814 | ssid = (struct ie_ssid *) |
| 815 | scan_entry->ie_list.ssid; |
| 816 | |
| 817 | if (ssid && (ssid->ssid_len > WLAN_SSID_MAX_LEN)) { |
| 818 | qdf_mem_free(scan_entry->raw_frame.ptr); |
| 819 | qdf_mem_free(scan_entry); |
Sandeep Puligilla | c676459 | 2017-12-05 21:01:52 -0800 | [diff] [blame] | 820 | qdf_mem_free(scan_list); |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 821 | return NULL; |
| 822 | } |
| 823 | |
| 824 | if (scan_entry->ie_list.p2p) |
| 825 | scan_entry->is_p2p = true; |
| 826 | |
| 827 | /* If no channel info is present in beacon use meta channel */ |
| 828 | if (!scan_entry->channel.chan_idx) { |
| 829 | scan_entry->channel.chan_idx = |
| 830 | rx_param->channel; |
| 831 | } else if (rx_param->channel != |
| 832 | scan_entry->channel.chan_idx) { |
| 833 | scan_entry->channel_mismatch = true; |
| 834 | } |
| 835 | |
| 836 | if (util_scan_is_hidden_ssid(ssid)) { |
| 837 | scan_entry->ie_list.ssid = NULL; |
| 838 | } else { |
| 839 | qdf_mem_copy(scan_entry->ssid.ssid, |
| 840 | ssid->ssid, WLAN_SSID_MAX_LEN); |
| 841 | scan_entry->ssid.length = ssid->ssid_len; |
| 842 | scan_entry->hidden_ssid_timestamp = |
| 843 | scan_entry->scan_entry_time; |
| 844 | } |
| 845 | |
| 846 | if (WLAN_CHAN_IS_5GHZ(scan_entry->channel.chan_idx)) |
| 847 | scan_entry->phy_mode = util_scan_get_phymode_5g(scan_entry); |
| 848 | else |
| 849 | scan_entry->phy_mode = util_scan_get_phymode_2g(scan_entry); |
| 850 | |
Abhishek Singh | b80af7e | 2017-07-19 18:48:42 +0530 | [diff] [blame] | 851 | scan_entry->nss = util_scan_scm_calc_nss_supported_by_ap(scan_entry); |
| 852 | util_scan_scm_update_bss_with_esp_data(scan_entry); |
Abhishek Singh | 7b59903 | 2017-11-10 14:42:31 +0530 | [diff] [blame] | 853 | qbss_load = (struct qbss_load_ie *) |
| 854 | util_scan_entry_qbssload(scan_entry); |
| 855 | if (qbss_load) |
| 856 | scan_entry->qbss_chan_load = qbss_load->qbss_chan_load; |
Abhishek Singh | b80af7e | 2017-07-19 18:48:42 +0530 | [diff] [blame] | 857 | |
Sandeep Puligilla | c676459 | 2017-12-05 21:01:52 -0800 | [diff] [blame] | 858 | scan_node = qdf_mem_malloc(sizeof(*scan_node)); |
| 859 | if (!scan_node) { |
| 860 | qdf_mem_free(scan_entry); |
| 861 | qdf_mem_free(scan_list); |
| 862 | return NULL; |
| 863 | } |
| 864 | |
| 865 | scan_node->entry = scan_entry; |
| 866 | qdf_list_insert_front(scan_list, &scan_node->node); |
| 867 | |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 868 | /* TODO calculate channel struct */ |
Sandeep Puligilla | c676459 | 2017-12-05 21:01:52 -0800 | [diff] [blame] | 869 | return scan_list; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 870 | } |
Om Prakash Tripathi | c3fcb68 | 2017-08-01 18:24:55 +0530 | [diff] [blame] | 871 | |
| 872 | QDF_STATUS |
| 873 | util_scan_entry_update_mlme_info(struct wlan_objmgr_pdev *pdev, |
| 874 | struct scan_cache_entry *scan_entry) |
| 875 | { |
| 876 | |
| 877 | if (!pdev || !scan_entry) { |
Jeff Johnson | 878533e | 2017-09-18 10:07:54 -0700 | [diff] [blame] | 878 | 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] | 879 | return QDF_STATUS_E_INVAL; |
| 880 | } |
| 881 | |
| 882 | return scm_update_scan_mlme_info(pdev, scan_entry); |
| 883 | } |