Om Prakash Tripathi | 7e3f45d | 2016-12-28 16:58:54 +0530 | [diff] [blame] | 1 | /* |
Bala Venkatesh | 7a5bee0 | 2019-01-07 16:09:03 +0530 | [diff] [blame] | 2 | * Copyright (c) 2017-2019 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 | |
Sandeep Puligilla | 54d8b64 | 2018-07-06 17:35:26 -0700 | [diff] [blame] | 30 | #define MAX_IE_LEN 1024 |
| 31 | |
Om Prakash Tripathi | 22f95dc | 2016-12-19 10:45:59 +0530 | [diff] [blame] | 32 | const char* |
| 33 | util_scan_get_ev_type_name(enum scan_event_type type) |
| 34 | { |
| 35 | static const char * const event_name[] = { |
| 36 | [SCAN_EVENT_TYPE_STARTED] = "STARTED", |
| 37 | [SCAN_EVENT_TYPE_COMPLETED] = "COMPLETED", |
| 38 | [SCAN_EVENT_TYPE_BSS_CHANNEL] = "HOME_CHANNEL", |
| 39 | [SCAN_EVENT_TYPE_FOREIGN_CHANNEL] = "FOREIGN_CHANNEL", |
| 40 | [SCAN_EVENT_TYPE_DEQUEUED] = "DEQUEUED", |
| 41 | [SCAN_EVENT_TYPE_PREEMPTED] = "PREEMPTED", |
| 42 | [SCAN_EVENT_TYPE_START_FAILED] = "START_FAILED", |
| 43 | [SCAN_EVENT_TYPE_RESTARTED] = "RESTARTED", |
| 44 | [SCAN_EVENT_TYPE_FOREIGN_CHANNEL_EXIT] = "FOREIGN_CHANNEL_EXIT", |
| 45 | [SCAN_EVENT_TYPE_SUSPENDED] = "SUSPENDED", |
| 46 | [SCAN_EVENT_TYPE_RESUMED] = "RESUMED", |
| 47 | [SCAN_EVENT_TYPE_NLO_COMPLETE] = "NLO_COMPLETE", |
Abhishek Singh | 8c6e82d | 2017-03-03 21:57:29 +0530 | [diff] [blame] | 48 | [SCAN_EVENT_TYPE_NLO_MATCH] = "NLO_MATCH", |
Om Prakash Tripathi | 22f95dc | 2016-12-19 10:45:59 +0530 | [diff] [blame] | 49 | [SCAN_EVENT_TYPE_INVALID] = "INVALID", |
| 50 | [SCAN_EVENT_TYPE_GPIO_TIMEOUT] = "GPIO_TIMEOUT", |
| 51 | [SCAN_EVENT_TYPE_RADIO_MEASUREMENT_START] = |
| 52 | "RADIO_MEASUREMENT_START", |
| 53 | [SCAN_EVENT_TYPE_RADIO_MEASUREMENT_END] = |
| 54 | "RADIO_MEASUREMENT_END", |
| 55 | [SCAN_EVENT_TYPE_BSSID_MATCH] = "BSSID_MATCH", |
| 56 | [SCAN_EVENT_TYPE_FOREIGN_CHANNEL_GET_NF] = |
| 57 | "FOREIGN_CHANNEL_GET_NF", |
| 58 | }; |
| 59 | |
Abhishek Singh | 483d914 | 2017-03-06 13:28:13 +0530 | [diff] [blame] | 60 | if (type >= SCAN_EVENT_TYPE_MAX) |
Om Prakash Tripathi | 22f95dc | 2016-12-19 10:45:59 +0530 | [diff] [blame] | 61 | return "UNKNOWN"; |
Om Prakash Tripathi | 22f95dc | 2016-12-19 10:45:59 +0530 | [diff] [blame] | 62 | |
| 63 | return event_name[type]; |
| 64 | } |
| 65 | |
| 66 | |
| 67 | const char* |
| 68 | util_scan_get_ev_reason_name(enum scan_completion_reason reason) |
| 69 | { |
| 70 | static const char * const reason_name[] = { |
| 71 | [SCAN_REASON_NONE] = "NONE", |
| 72 | [SCAN_REASON_COMPLETED] = "COMPLETED", |
| 73 | [SCAN_REASON_CANCELLED] = "CANCELLED", |
| 74 | [SCAN_REASON_PREEMPTED] = "PREEMPTED", |
| 75 | [SCAN_REASON_TIMEDOUT] = "TIMEDOUT", |
| 76 | [SCAN_REASON_INTERNAL_FAILURE] = "INTERNAL_FAILURE", |
| 77 | [SCAN_REASON_SUSPENDED] = "SUSPENDED", |
| 78 | [SCAN_REASON_RUN_FAILED] = "RUN_FAILED", |
| 79 | [SCAN_REASON_TERMINATION_FUNCTION] = "TERMINATION_FUNCTION", |
| 80 | [SCAN_REASON_MAX_OFFCHAN_RETRIES] = "MAX_OFFCHAN_RETRIES", |
Abhijit Pradhan | 0f0e27b | 2018-10-08 10:48:00 +0530 | [diff] [blame] | 81 | [SCAN_REASON_DFS_VIOLATION] = "DFS_NOL_VIOLATION", |
Om Prakash Tripathi | 22f95dc | 2016-12-19 10:45:59 +0530 | [diff] [blame] | 82 | }; |
| 83 | |
Abhishek Singh | 483d914 | 2017-03-06 13:28:13 +0530 | [diff] [blame] | 84 | if (reason >= SCAN_REASON_MAX) |
Om Prakash Tripathi | 22f95dc | 2016-12-19 10:45:59 +0530 | [diff] [blame] | 85 | return "UNKNOWN"; |
Om Prakash Tripathi | 22f95dc | 2016-12-19 10:45:59 +0530 | [diff] [blame] | 86 | |
| 87 | return reason_name[reason]; |
| 88 | } |
| 89 | |
| 90 | qdf_time_t |
| 91 | util_get_last_scan_time(struct wlan_objmgr_vdev *vdev) |
| 92 | { |
| 93 | uint8_t pdev_id; |
| 94 | struct wlan_scan_obj *scan_obj; |
| 95 | |
| 96 | if (!vdev) { |
| 97 | scm_warn("null vdev"); |
| 98 | QDF_ASSERT(0); |
| 99 | return 0; |
| 100 | } |
| 101 | pdev_id = wlan_scan_vdev_get_pdev_id(vdev); |
| 102 | scan_obj = wlan_vdev_get_scan_obj(vdev); |
| 103 | |
Om Prakash Tripathi | 510a27c | 2019-03-01 11:53:18 +0530 | [diff] [blame] | 104 | if (scan_obj) |
| 105 | return scan_obj->pdev_info[pdev_id].last_scan_time; |
| 106 | else |
| 107 | return 0; |
Om Prakash Tripathi | 22f95dc | 2016-12-19 10:45:59 +0530 | [diff] [blame] | 108 | } |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 109 | |
Abhishek Singh | b80af7e | 2017-07-19 18:48:42 +0530 | [diff] [blame] | 110 | enum wlan_band util_scan_scm_chan_to_band(uint32_t chan) |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 111 | { |
| 112 | if (WLAN_CHAN_IS_2GHZ(chan)) |
| 113 | return WLAN_BAND_2_4_GHZ; |
| 114 | |
| 115 | return WLAN_BAND_5_GHZ; |
| 116 | } |
| 117 | |
Shashikala Prabhu | 48ecda8 | 2018-04-13 01:13:30 +0530 | [diff] [blame] | 118 | enum wlan_band util_scan_scm_freq_to_band(uint16_t freq) |
| 119 | { |
| 120 | if (WLAN_REG_IS_24GHZ_CH_FREQ(freq)) |
| 121 | return WLAN_BAND_2_4_GHZ; |
| 122 | |
| 123 | return WLAN_BAND_5_GHZ; |
| 124 | } |
| 125 | |
Abhishek Singh | d4e600f | 2017-02-21 15:16:28 +0530 | [diff] [blame] | 126 | bool util_is_scan_entry_match( |
| 127 | struct scan_cache_entry *entry1, |
| 128 | struct scan_cache_entry *entry2) |
| 129 | { |
| 130 | |
| 131 | if (entry1->cap_info.wlan_caps.ess != |
wadesong | 49ae4cb | 2018-01-22 15:03:12 +0800 | [diff] [blame] | 132 | entry2->cap_info.wlan_caps.ess) |
Abhishek Singh | d4e600f | 2017-02-21 15:16:28 +0530 | [diff] [blame] | 133 | return false; |
| 134 | |
| 135 | if (entry1->cap_info.wlan_caps.ess && |
| 136 | !qdf_mem_cmp(entry1->bssid.bytes, |
Yeshwanth Sriram Guntuka | dca006c | 2018-11-16 17:58:08 +0530 | [diff] [blame] | 137 | entry2->bssid.bytes, QDF_MAC_ADDR_SIZE)) { |
Abhishek Singh | d4e600f | 2017-02-21 15:16:28 +0530 | [diff] [blame] | 138 | /* Check for BSS */ |
Yeshwanth Sriram Guntuka | 294ce11 | 2018-10-23 16:49:19 +0530 | [diff] [blame] | 139 | if (util_is_ssid_match(&entry1->ssid, &entry2->ssid) || |
Yeshwanth Sriram Guntuka | dca006c | 2018-11-16 17:58:08 +0530 | [diff] [blame] | 140 | util_scan_is_null_ssid(&entry1->ssid) || |
| 141 | util_scan_is_null_ssid(&entry2->ssid)) |
Abhishek Singh | d4e600f | 2017-02-21 15:16:28 +0530 | [diff] [blame] | 142 | return true; |
| 143 | } else if (entry1->cap_info.wlan_caps.ibss && |
Ashish Kumar Dhanotiya | 75ccbd4 | 2019-08-29 19:17:44 +0530 | [diff] [blame] | 144 | (entry1->channel.chan_freq == |
| 145 | entry2->channel.chan_freq)) { |
Abhishek Singh | d4e600f | 2017-02-21 15:16:28 +0530 | [diff] [blame] | 146 | /* |
| 147 | * Same channel cannot have same SSID for |
| 148 | * different IBSS, so no need to check BSSID |
| 149 | */ |
| 150 | if (util_is_ssid_match( |
| 151 | &entry1->ssid, &entry2->ssid)) |
| 152 | return true; |
| 153 | } else if (!entry1->cap_info.wlan_caps.ibss && |
| 154 | !entry1->cap_info.wlan_caps.ess && |
| 155 | !qdf_mem_cmp(entry1->bssid.bytes, |
Om Prakash Tripathi | c3fcb68 | 2017-08-01 18:24:55 +0530 | [diff] [blame] | 156 | entry2->bssid.bytes, QDF_MAC_ADDR_SIZE)) { |
Abhishek Singh | d4e600f | 2017-02-21 15:16:28 +0530 | [diff] [blame] | 157 | /* In case of P2P devices, ess and ibss will be set to zero */ |
| 158 | return true; |
| 159 | } |
| 160 | |
| 161 | return false; |
| 162 | } |
| 163 | |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 164 | static bool util_is_pureg_rate(uint8_t *rates, uint8_t nrates) |
| 165 | { |
| 166 | static const uint8_t g_rates[] = {12, 18, 24, 36, 48, 72, 96, 108}; |
| 167 | bool pureg = false; |
| 168 | uint8_t i, j; |
| 169 | |
| 170 | for (i = 0; i < nrates; i++) { |
| 171 | for (j = 0; j < QDF_ARRAY_SIZE(g_rates); j++) { |
| 172 | if (WLAN_RV(rates[i]) == g_rates[j]) { |
| 173 | pureg = true; |
| 174 | break; |
| 175 | } |
| 176 | } |
| 177 | if (pureg) |
| 178 | break; |
| 179 | } |
| 180 | |
| 181 | return pureg; |
| 182 | } |
Abhishek Ambure | 986f5c9 | 2019-10-21 14:52:59 +0530 | [diff] [blame] | 183 | |
| 184 | #ifdef CONFIG_BAND_6GHZ |
| 185 | static enum wlan_phymode |
Abhishek Singh | 3c5f8ef | 2019-11-06 10:02:07 +0530 | [diff] [blame^] | 186 | util_scan_get_phymode_6g(struct wlan_objmgr_pdev *pdev, |
| 187 | struct scan_cache_entry *scan_params) |
Abhishek Ambure | 986f5c9 | 2019-10-21 14:52:59 +0530 | [diff] [blame] | 188 | { |
| 189 | uint8_t len; |
| 190 | struct he_oper_6g_param *he_6g_params; |
| 191 | uint32_t he_oper_params; |
| 192 | enum wlan_phymode phymode = WLAN_PHYMODE_11AXA_HE20; |
| 193 | uint8_t *he_ops; |
Abhishek Singh | 3c5f8ef | 2019-11-06 10:02:07 +0530 | [diff] [blame^] | 194 | uint8_t band_mask = BIT(REG_BAND_6G); |
Abhishek Ambure | 986f5c9 | 2019-10-21 14:52:59 +0530 | [diff] [blame] | 195 | |
| 196 | he_ops = util_scan_entry_heop(scan_params); |
| 197 | if (!util_scan_entry_hecap(scan_params) || !he_ops) |
| 198 | return phymode; |
| 199 | |
| 200 | len = he_ops[1]; |
Abhishek Singh | 3c5f8ef | 2019-11-06 10:02:07 +0530 | [diff] [blame^] | 201 | he_ops += sizeof(struct ie_header); |
Abhishek Ambure | 986f5c9 | 2019-10-21 14:52:59 +0530 | [diff] [blame] | 202 | |
Abhishek Singh | 3c5f8ef | 2019-11-06 10:02:07 +0530 | [diff] [blame^] | 203 | if (len < WLAN_HEOP_FIXED_PARAM_LENGTH) |
Abhishek Ambure | 986f5c9 | 2019-10-21 14:52:59 +0530 | [diff] [blame] | 204 | return phymode; |
| 205 | |
| 206 | /* element id extension */ |
| 207 | he_ops++; |
| 208 | len--; |
| 209 | |
| 210 | he_oper_params = LE_READ_4(he_ops); |
| 211 | if (!(he_oper_params & WLAN_HEOP_6GHZ_INFO_PRESENT_MASK)) |
| 212 | return phymode; |
| 213 | |
Abhishek Singh | 3c5f8ef | 2019-11-06 10:02:07 +0530 | [diff] [blame^] | 214 | /* fixed params - element id extension */ |
| 215 | he_ops += WLAN_HEOP_FIXED_PARAM_LENGTH - 1; |
| 216 | len -= WLAN_HEOP_FIXED_PARAM_LENGTH - 1; |
Abhishek Ambure | 986f5c9 | 2019-10-21 14:52:59 +0530 | [diff] [blame] | 217 | |
| 218 | if (!len) |
| 219 | return phymode; |
| 220 | |
| 221 | /* vht oper params */ |
| 222 | if (he_oper_params & WLAN_HEOP_VHTOP_PRESENT_MASK) { |
Abhishek Singh | 3c5f8ef | 2019-11-06 10:02:07 +0530 | [diff] [blame^] | 223 | if (len < WLAN_HEOP_VHTOP_LENGTH) |
Abhishek Ambure | 986f5c9 | 2019-10-21 14:52:59 +0530 | [diff] [blame] | 224 | return phymode; |
Abhishek Singh | 3c5f8ef | 2019-11-06 10:02:07 +0530 | [diff] [blame^] | 225 | he_ops += WLAN_HEOP_VHTOP_LENGTH; |
| 226 | len -= WLAN_HEOP_VHTOP_LENGTH; |
Abhishek Ambure | 986f5c9 | 2019-10-21 14:52:59 +0530 | [diff] [blame] | 227 | } |
| 228 | |
| 229 | if (!len) |
| 230 | return phymode; |
| 231 | |
| 232 | if (he_oper_params & WLAN_HEOP_CO_LOCATED_BSS_MASK) { |
Abhishek Singh | 3c5f8ef | 2019-11-06 10:02:07 +0530 | [diff] [blame^] | 233 | he_ops += WLAN_HEOP_CO_LOCATED_BSS_LENGTH; |
| 234 | len -= WLAN_HEOP_CO_LOCATED_BSS_LENGTH; |
Abhishek Ambure | 986f5c9 | 2019-10-21 14:52:59 +0530 | [diff] [blame] | 235 | } |
| 236 | |
| 237 | if (len < sizeof(*he_6g_params)) |
| 238 | return phymode; |
| 239 | |
| 240 | he_6g_params = (struct he_oper_6g_param *)he_ops; |
| 241 | |
| 242 | switch (he_6g_params->width) { |
| 243 | case WLAN_HE_6GHZ_CHWIDTH_20: |
| 244 | phymode = WLAN_PHYMODE_11AXA_HE20; |
| 245 | break; |
| 246 | case WLAN_HE_6GHZ_CHWIDTH_40: |
| 247 | phymode = WLAN_PHYMODE_11AXA_HE40; |
| 248 | break; |
| 249 | case WLAN_HE_6GHZ_CHWIDTH_80: |
| 250 | phymode = WLAN_PHYMODE_11AXA_HE80; |
| 251 | break; |
| 252 | case WLAN_HE_6GHZ_CHWIDTH_160_80_80: |
| 253 | if (WLAN_IS_HE80_80(he_6g_params)) |
| 254 | phymode = WLAN_PHYMODE_11AXA_HE80_80; |
| 255 | else if (WLAN_IS_HE160(he_6g_params)) |
| 256 | phymode = WLAN_PHYMODE_11AXA_HE160; |
| 257 | else |
| 258 | phymode = WLAN_PHYMODE_11AXA_HE80; |
| 259 | break; |
| 260 | default: |
| 261 | scm_err("Invalid he_6g_params width: %d", he_6g_params->width); |
| 262 | phymode = WLAN_PHYMODE_11AXA_HE20; |
| 263 | break; |
| 264 | } |
| 265 | |
Abhishek Singh | 3c5f8ef | 2019-11-06 10:02:07 +0530 | [diff] [blame^] | 266 | if (he_6g_params->chan_freq_seg0) |
| 267 | scan_params->channel.cfreq0 = |
| 268 | wlan_reg_chan_band_to_freq(pdev, |
| 269 | he_6g_params->chan_freq_seg0, |
| 270 | band_mask); |
| 271 | if (he_6g_params->chan_freq_seg1) |
| 272 | scan_params->channel.cfreq1 = |
| 273 | wlan_reg_chan_band_to_freq(pdev, |
| 274 | he_6g_params->chan_freq_seg1, |
| 275 | band_mask); |
| 276 | |
Abhishek Ambure | 986f5c9 | 2019-10-21 14:52:59 +0530 | [diff] [blame] | 277 | return phymode; |
| 278 | } |
| 279 | #else |
| 280 | static inline enum wlan_phymode |
Abhishek Singh | 3c5f8ef | 2019-11-06 10:02:07 +0530 | [diff] [blame^] | 281 | util_scan_get_phymode_6g(struct wlan_objmgr_pdev *pdev, |
| 282 | struct scan_cache_entry *scan_params) |
Abhishek Ambure | 986f5c9 | 2019-10-21 14:52:59 +0530 | [diff] [blame] | 283 | { |
| 284 | return WLAN_PHYMODE_AUTO; |
| 285 | } |
| 286 | #endif |
| 287 | |
Abhishek Singh | 3c5f8ef | 2019-11-06 10:02:07 +0530 | [diff] [blame^] | 288 | static inline |
| 289 | uint32_t util_scan_sec_chan_freq_from_htinfo(struct wlan_ie_htinfo_cmn *htinfo, |
| 290 | uint32_t primary_chan_freq) |
| 291 | { |
| 292 | if (htinfo->hi_extchoff == WLAN_HTINFO_EXTOFFSET_ABOVE) |
| 293 | return primary_chan_freq + WLAN_CHAN_SPACING_20MHZ; |
| 294 | else if (htinfo->hi_extchoff == WLAN_HTINFO_EXTOFFSET_BELOW) |
| 295 | return primary_chan_freq - WLAN_CHAN_SPACING_20MHZ; |
| 296 | |
| 297 | return 0; |
| 298 | } |
| 299 | |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 300 | static enum wlan_phymode |
Abhishek Singh | 3c5f8ef | 2019-11-06 10:02:07 +0530 | [diff] [blame^] | 301 | util_scan_get_phymode_5g(struct wlan_objmgr_pdev *pdev, |
| 302 | struct scan_cache_entry *scan_params) |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 303 | { |
| 304 | enum wlan_phymode phymode = WLAN_PHYMODE_AUTO; |
| 305 | uint16_t ht_cap = 0; |
| 306 | struct htcap_cmn_ie *htcap; |
| 307 | struct wlan_ie_htinfo_cmn *htinfo; |
| 308 | struct wlan_ie_vhtop *vhtop; |
Abhishek Singh | 3c5f8ef | 2019-11-06 10:02:07 +0530 | [diff] [blame^] | 309 | uint8_t band_mask = BIT(REG_BAND_5G); |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 310 | |
| 311 | htcap = (struct htcap_cmn_ie *) |
| 312 | util_scan_entry_htcap(scan_params); |
| 313 | htinfo = (struct wlan_ie_htinfo_cmn *) |
| 314 | util_scan_entry_htinfo(scan_params); |
| 315 | vhtop = (struct wlan_ie_vhtop *) |
| 316 | util_scan_entry_vhtop(scan_params); |
| 317 | |
| 318 | if (!(htcap && htinfo)) |
| 319 | return WLAN_PHYMODE_11A; |
| 320 | |
| 321 | if (htcap) |
| 322 | ht_cap = le16toh(htcap->hc_cap); |
| 323 | |
Abhishek Ambure | 986f5c9 | 2019-10-21 14:52:59 +0530 | [diff] [blame] | 324 | if (ht_cap & WLAN_HTCAP_C_CHWIDTH40) |
| 325 | phymode = WLAN_PHYMODE_11NA_HT40; |
| 326 | else |
| 327 | phymode = WLAN_PHYMODE_11NA_HT20; |
| 328 | |
Abhishek Singh | 3c5f8ef | 2019-11-06 10:02:07 +0530 | [diff] [blame^] | 329 | scan_params->channel.cfreq0 = |
| 330 | util_scan_sec_chan_freq_from_htinfo(htinfo, |
| 331 | scan_params->channel.chan_freq); |
| 332 | |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 333 | if (util_scan_entry_vhtcap(scan_params) && vhtop) { |
| 334 | switch (vhtop->vht_op_chwidth) { |
| 335 | case WLAN_VHTOP_CHWIDTH_2040: |
Abhishek Singh | f3f9797 | 2019-09-18 12:13:46 +0530 | [diff] [blame] | 336 | if (ht_cap & WLAN_HTCAP_C_CHWIDTH40) |
| 337 | phymode = WLAN_PHYMODE_11AC_VHT40; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 338 | else |
| 339 | phymode = WLAN_PHYMODE_11AC_VHT20; |
| 340 | break; |
| 341 | case WLAN_VHTOP_CHWIDTH_80: |
| 342 | if (WLAN_IS_REVSIG_VHT80_80(vhtop)) |
| 343 | phymode = WLAN_PHYMODE_11AC_VHT80_80; |
| 344 | else if (WLAN_IS_REVSIG_VHT160(vhtop)) |
| 345 | phymode = WLAN_PHYMODE_11AC_VHT160; |
| 346 | else |
| 347 | phymode = WLAN_PHYMODE_11AC_VHT80; |
| 348 | break; |
| 349 | case WLAN_VHTOP_CHWIDTH_160: |
| 350 | phymode = WLAN_PHYMODE_11AC_VHT160; |
| 351 | break; |
| 352 | case WLAN_VHTOP_CHWIDTH_80_80: |
| 353 | phymode = WLAN_PHYMODE_11AC_VHT80_80; |
| 354 | break; |
| 355 | default: |
| 356 | scm_err("bad channel: %d", |
| 357 | vhtop->vht_op_chwidth); |
Abhishek Singh | f3f9797 | 2019-09-18 12:13:46 +0530 | [diff] [blame] | 358 | phymode = WLAN_PHYMODE_11AC_VHT20; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 359 | break; |
| 360 | } |
Abhishek Singh | 3c5f8ef | 2019-11-06 10:02:07 +0530 | [diff] [blame^] | 361 | if (vhtop->vht_op_ch_freq_seg1) |
| 362 | scan_params->channel.cfreq0 = |
| 363 | wlan_reg_chan_band_to_freq(pdev, |
| 364 | vhtop->vht_op_ch_freq_seg1, |
| 365 | band_mask); |
| 366 | if (vhtop->vht_op_ch_freq_seg2) |
| 367 | scan_params->channel.cfreq1 = |
| 368 | wlan_reg_chan_band_to_freq(pdev, |
| 369 | vhtop->vht_op_ch_freq_seg2, |
| 370 | band_mask); |
Abhishek Ambure | 986f5c9 | 2019-10-21 14:52:59 +0530 | [diff] [blame] | 371 | } |
| 372 | |
| 373 | if (!util_scan_entry_hecap(scan_params)) |
| 374 | return phymode; |
| 375 | |
| 376 | /* for 5Ghz Check for HE, only if VHT cap and HE cap are present */ |
| 377 | if (!IS_WLAN_PHYMODE_VHT(phymode)) |
| 378 | return phymode; |
| 379 | |
| 380 | switch (phymode) { |
| 381 | case WLAN_PHYMODE_11AC_VHT20: |
| 382 | phymode = WLAN_PHYMODE_11AXA_HE20; |
| 383 | break; |
| 384 | case WLAN_PHYMODE_11AC_VHT40: |
| 385 | phymode = WLAN_PHYMODE_11AXA_HE40; |
| 386 | break; |
| 387 | case WLAN_PHYMODE_11AC_VHT80: |
| 388 | phymode = WLAN_PHYMODE_11AXA_HE80; |
| 389 | break; |
| 390 | case WLAN_PHYMODE_11AC_VHT160: |
| 391 | phymode = WLAN_PHYMODE_11AXA_HE160; |
| 392 | break; |
| 393 | case WLAN_PHYMODE_11AC_VHT80_80: |
| 394 | phymode = WLAN_PHYMODE_11AXA_HE80_80; |
| 395 | break; |
| 396 | default: |
| 397 | phymode = WLAN_PHYMODE_11AXA_HE20; |
| 398 | break; |
Abhishek Singh | f3f9797 | 2019-09-18 12:13:46 +0530 | [diff] [blame] | 399 | } |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 400 | |
| 401 | return phymode; |
| 402 | } |
| 403 | |
| 404 | static enum wlan_phymode |
| 405 | util_scan_get_phymode_2g(struct scan_cache_entry *scan_params) |
| 406 | { |
| 407 | enum wlan_phymode phymode = WLAN_PHYMODE_AUTO; |
| 408 | uint16_t ht_cap = 0; |
| 409 | struct htcap_cmn_ie *htcap; |
| 410 | struct wlan_ie_htinfo_cmn *htinfo; |
| 411 | struct wlan_ie_vhtop *vhtop; |
| 412 | |
| 413 | htcap = (struct htcap_cmn_ie *) |
| 414 | util_scan_entry_htcap(scan_params); |
| 415 | htinfo = (struct wlan_ie_htinfo_cmn *) |
| 416 | util_scan_entry_htinfo(scan_params); |
| 417 | vhtop = (struct wlan_ie_vhtop *) |
| 418 | util_scan_entry_vhtop(scan_params); |
| 419 | |
| 420 | if (htcap) |
| 421 | ht_cap = le16toh(htcap->hc_cap); |
| 422 | |
| 423 | if (htcap && htinfo) { |
| 424 | if ((ht_cap & WLAN_HTCAP_C_CHWIDTH40) && |
| 425 | (htinfo->hi_extchoff == WLAN_HTINFO_EXTOFFSET_ABOVE)) |
| 426 | phymode = WLAN_PHYMODE_11NG_HT40PLUS; |
| 427 | else if ((ht_cap & WLAN_HTCAP_C_CHWIDTH40) && |
| 428 | (htinfo->hi_extchoff == WLAN_HTINFO_EXTOFFSET_BELOW)) |
| 429 | phymode = WLAN_PHYMODE_11NG_HT40MINUS; |
| 430 | else |
| 431 | phymode = WLAN_PHYMODE_11NG_HT20; |
| 432 | } else if (util_scan_entry_xrates(scan_params)) { |
| 433 | /* only 11G stations will have more than 8 rates */ |
| 434 | phymode = WLAN_PHYMODE_11G; |
| 435 | } else { |
| 436 | /* Some mischievous g-only APs do not set extended rates */ |
| 437 | if (util_scan_entry_rates(scan_params)) { |
| 438 | if (util_is_pureg_rate(&scan_params->ie_list.rates[2], |
| 439 | scan_params->ie_list.rates[1])) |
| 440 | phymode = WLAN_PHYMODE_11G; |
| 441 | else |
| 442 | phymode = WLAN_PHYMODE_11B; |
| 443 | } else { |
| 444 | phymode = WLAN_PHYMODE_11B; |
| 445 | } |
| 446 | } |
| 447 | |
Abhishek Ambure | 986f5c9 | 2019-10-21 14:52:59 +0530 | [diff] [blame] | 448 | /* Check for VHT only if HT cap is present */ |
| 449 | if (!IS_WLAN_PHYMODE_HT(phymode)) |
| 450 | return phymode; |
| 451 | |
Abhishek Singh | 3c5f8ef | 2019-11-06 10:02:07 +0530 | [diff] [blame^] | 452 | scan_params->channel.cfreq0 = |
| 453 | util_scan_sec_chan_freq_from_htinfo(htinfo, |
| 454 | scan_params->channel.chan_freq); |
| 455 | |
Abhishek Singh | f3f9797 | 2019-09-18 12:13:46 +0530 | [diff] [blame] | 456 | if (util_scan_entry_vhtcap(scan_params) && vhtop) { |
| 457 | switch (vhtop->vht_op_chwidth) { |
| 458 | case WLAN_VHTOP_CHWIDTH_2040: |
| 459 | if (phymode == WLAN_PHYMODE_11NG_HT40PLUS) |
| 460 | phymode = WLAN_PHYMODE_11AC_VHT40PLUS_2G; |
| 461 | else if (phymode == WLAN_PHYMODE_11NG_HT40MINUS) |
| 462 | phymode = WLAN_PHYMODE_11AC_VHT40MINUS_2G; |
| 463 | else |
| 464 | phymode = WLAN_PHYMODE_11AC_VHT20_2G; |
| 465 | |
| 466 | break; |
| 467 | default: |
| 468 | scm_info("bad vht_op_chwidth: %d", |
| 469 | vhtop->vht_op_chwidth); |
| 470 | phymode = WLAN_PHYMODE_11AC_VHT20_2G; |
| 471 | break; |
| 472 | } |
| 473 | } |
| 474 | |
Abhishek Ambure | 986f5c9 | 2019-10-21 14:52:59 +0530 | [diff] [blame] | 475 | if (!util_scan_entry_hecap(scan_params)) |
| 476 | return phymode; |
| 477 | |
| 478 | if (phymode == WLAN_PHYMODE_11AC_VHT40PLUS_2G || |
| 479 | phymode == WLAN_PHYMODE_11NG_HT40PLUS) |
| 480 | phymode = WLAN_PHYMODE_11AXG_HE40PLUS; |
| 481 | else if (phymode == WLAN_PHYMODE_11AC_VHT40MINUS_2G || |
| 482 | phymode == WLAN_PHYMODE_11NG_HT40MINUS) |
| 483 | phymode = WLAN_PHYMODE_11AXG_HE40MINUS; |
| 484 | else |
| 485 | phymode = WLAN_PHYMODE_11AXG_HE20; |
| 486 | |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 487 | return phymode; |
| 488 | } |
| 489 | |
Abhishek Ambure | 986f5c9 | 2019-10-21 14:52:59 +0530 | [diff] [blame] | 490 | static enum wlan_phymode |
Abhishek Singh | 3c5f8ef | 2019-11-06 10:02:07 +0530 | [diff] [blame^] | 491 | util_scan_get_phymode(struct wlan_objmgr_pdev *pdev, |
| 492 | struct scan_cache_entry *scan_params) |
Abhishek Ambure | 986f5c9 | 2019-10-21 14:52:59 +0530 | [diff] [blame] | 493 | { |
| 494 | if (WLAN_REG_IS_24GHZ_CH_FREQ(scan_params->channel.chan_freq)) |
| 495 | return util_scan_get_phymode_2g(scan_params); |
| 496 | else if (WLAN_REG_IS_6GHZ_CHAN_FREQ(scan_params->channel.chan_freq)) |
Abhishek Singh | 3c5f8ef | 2019-11-06 10:02:07 +0530 | [diff] [blame^] | 497 | return util_scan_get_phymode_6g(pdev, scan_params); |
Abhishek Ambure | 986f5c9 | 2019-10-21 14:52:59 +0530 | [diff] [blame] | 498 | else |
Abhishek Singh | 3c5f8ef | 2019-11-06 10:02:07 +0530 | [diff] [blame^] | 499 | return util_scan_get_phymode_5g(pdev, scan_params); |
Abhishek Ambure | 986f5c9 | 2019-10-21 14:52:59 +0530 | [diff] [blame] | 500 | } |
| 501 | |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 502 | static QDF_STATUS |
| 503 | util_scan_parse_chan_switch_wrapper_ie(struct scan_cache_entry *scan_params, |
| 504 | struct ie_header *sub_ie, qdf_size_t sub_ie_len) |
| 505 | { |
| 506 | /* Walk through to check nothing is malformed */ |
| 507 | while (sub_ie_len >= sizeof(struct ie_header)) { |
| 508 | /* At least one more header is present */ |
| 509 | sub_ie_len -= sizeof(struct ie_header); |
| 510 | |
| 511 | if (sub_ie->ie_len == 0) { |
| 512 | sub_ie += 1; |
| 513 | continue; |
| 514 | } |
| 515 | if (sub_ie_len < sub_ie->ie_len) { |
| 516 | scm_err("Incomplete corrupted IE:%x", |
| 517 | WLAN_ELEMID_CHAN_SWITCH_WRAP); |
| 518 | return QDF_STATUS_E_INVAL; |
| 519 | } |
| 520 | switch (sub_ie->ie_id) { |
| 521 | case WLAN_ELEMID_COUNTRY: |
| 522 | scan_params->ie_list.country = (uint8_t *)sub_ie; |
| 523 | break; |
| 524 | case WLAN_ELEMID_WIDE_BAND_CHAN_SWITCH: |
| 525 | scan_params->ie_list.widebw = (uint8_t *)sub_ie; |
| 526 | break; |
| 527 | case WLAN_ELEMID_VHT_TX_PWR_ENVLP: |
| 528 | scan_params->ie_list.txpwrenvlp = (uint8_t *)sub_ie; |
| 529 | break; |
| 530 | } |
| 531 | /* Consume sub info element */ |
| 532 | sub_ie_len -= sub_ie->ie_len; |
| 533 | /* go to next Sub IE */ |
| 534 | sub_ie = (struct ie_header *) |
| 535 | (((uint8_t *) sub_ie) + |
| 536 | sizeof(struct ie_header) + sub_ie->ie_len); |
| 537 | } |
| 538 | |
| 539 | return QDF_STATUS_SUCCESS; |
| 540 | } |
| 541 | |
Om Prakash Tripathi | 1d1525d | 2017-09-08 13:59:34 +0530 | [diff] [blame] | 542 | bool |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 543 | util_scan_is_hidden_ssid(struct ie_ssid *ssid) |
| 544 | { |
| 545 | uint8_t i; |
| 546 | |
| 547 | /* |
| 548 | * We flag this as Hidden SSID if the Length is 0 |
| 549 | * of the SSID only contains 0's |
| 550 | */ |
| 551 | if (!ssid || !ssid->ssid_len) |
| 552 | return true; |
| 553 | |
| 554 | for (i = 0; i < ssid->ssid_len; i++) |
| 555 | if (ssid->ssid[i] != 0) |
| 556 | return false; |
| 557 | |
| 558 | /* All 0's */ |
| 559 | return true; |
| 560 | } |
| 561 | |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 562 | static QDF_STATUS |
Venkateswara Swamy Bandaru | 851184b | 2017-04-25 11:02:39 +0530 | [diff] [blame] | 563 | util_scan_parse_extn_ie(struct scan_cache_entry *scan_params, |
| 564 | struct ie_header *ie) |
| 565 | { |
| 566 | struct extn_ie_header *extn_ie = (struct extn_ie_header *) ie; |
| 567 | |
| 568 | switch (extn_ie->ie_extn_id) { |
Hariharan Basuthkar | 738320e | 2018-11-26 11:19:19 +0530 | [diff] [blame] | 569 | case WLAN_EXTN_ELEMID_MAX_CHAN_SWITCH_TIME: |
| 570 | scan_params->ie_list.mcst = (uint8_t *)ie; |
| 571 | break; |
Venkateswara Swamy Bandaru | 851184b | 2017-04-25 11:02:39 +0530 | [diff] [blame] | 572 | case WLAN_EXTN_ELEMID_SRP: |
Gyanranjan Hazarika | b5d426d | 2017-08-22 21:45:07 -0700 | [diff] [blame] | 573 | scan_params->ie_list.srp = (uint8_t *)ie; |
| 574 | break; |
| 575 | case WLAN_EXTN_ELEMID_HECAP: |
| 576 | scan_params->ie_list.hecap = (uint8_t *)ie; |
| 577 | break; |
| 578 | case WLAN_EXTN_ELEMID_HEOP: |
| 579 | scan_params->ie_list.heop = (uint8_t *)ie; |
Venkateswara Swamy Bandaru | 851184b | 2017-04-25 11:02:39 +0530 | [diff] [blame] | 580 | break; |
Abhishek Singh | b80af7e | 2017-07-19 18:48:42 +0530 | [diff] [blame] | 581 | case WLAN_EXTN_ELEMID_ESP: |
| 582 | scan_params->ie_list.esp = (uint8_t *)ie; |
| 583 | break; |
Rhythm Patwa | a6ba9ee | 2018-05-23 19:29:57 -0700 | [diff] [blame] | 584 | case WLAN_EXTN_ELEMID_MUEDCA: |
| 585 | scan_params->ie_list.muedca = (uint8_t *)ie; |
| 586 | break; |
Rhythm Patwa | 7232cb1 | 2019-09-23 22:09:00 -0700 | [diff] [blame] | 587 | case WLAN_EXTN_ELEMID_HE_6G_CAP: |
| 588 | scan_params->ie_list.hecap_6g = (uint8_t *)ie; |
| 589 | break; |
Venkateswara Swamy Bandaru | 851184b | 2017-04-25 11:02:39 +0530 | [diff] [blame] | 590 | default: |
| 591 | break; |
| 592 | } |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 593 | return QDF_STATUS_SUCCESS; |
Venkateswara Swamy Bandaru | 851184b | 2017-04-25 11:02:39 +0530 | [diff] [blame] | 594 | } |
| 595 | |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 596 | static QDF_STATUS |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 597 | util_scan_parse_vendor_ie(struct scan_cache_entry *scan_params, |
| 598 | struct ie_header *ie) |
| 599 | { |
Jeff Johnson | 82eb212 | 2019-03-20 12:16:13 -0700 | [diff] [blame] | 600 | if (!scan_params->ie_list.vendor) |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 601 | scan_params->ie_list.vendor = (uint8_t *)ie; |
| 602 | |
| 603 | if (is_wpa_oui((uint8_t *)ie)) { |
| 604 | scan_params->ie_list.wpa = (uint8_t *)ie; |
| 605 | } else if (is_wps_oui((uint8_t *)ie)) { |
| 606 | scan_params->ie_list.wps = (uint8_t *)ie; |
| 607 | /* WCN IE should be a subset of WPS IE */ |
| 608 | if (is_wcn_oui((uint8_t *)ie)) |
| 609 | scan_params->ie_list.wcn = (uint8_t *)ie; |
| 610 | } else if (is_wme_param((uint8_t *)ie)) { |
| 611 | scan_params->ie_list.wmeparam = (uint8_t *)ie; |
| 612 | } else if (is_wme_info((uint8_t *)ie)) { |
| 613 | scan_params->ie_list.wmeinfo = (uint8_t *)ie; |
| 614 | } else if (is_atheros_oui((uint8_t *)ie)) { |
| 615 | scan_params->ie_list.athcaps = (uint8_t *)ie; |
| 616 | } else if (is_atheros_extcap_oui((uint8_t *)ie)) { |
| 617 | scan_params->ie_list.athextcaps = (uint8_t *)ie; |
| 618 | } else if (is_sfa_oui((uint8_t *)ie)) { |
| 619 | scan_params->ie_list.sfa = (uint8_t *)ie; |
| 620 | } else if (is_p2p_oui((uint8_t *)ie)) { |
| 621 | scan_params->ie_list.p2p = (uint8_t *)ie; |
Bharat Bhushan Chakravarty | 145d393 | 2017-03-20 12:52:16 -0700 | [diff] [blame] | 622 | } else if (is_qca_son_oui((uint8_t *)ie, |
| 623 | QCA_OUI_WHC_AP_INFO_SUBTYPE)) { |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 624 | scan_params->ie_list.sonadv = (uint8_t *)ie; |
| 625 | } else if (is_ht_cap((uint8_t *)ie)) { |
| 626 | /* we only care if there isn't already an HT IE (ANA) */ |
Jeff Johnson | 82eb212 | 2019-03-20 12:16:13 -0700 | [diff] [blame] | 627 | if (!scan_params->ie_list.htcap) { |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 628 | if (ie->ie_len != (WLAN_VENDOR_HT_IE_OFFSET_LEN + |
| 629 | sizeof(struct htcap_cmn_ie))) |
| 630 | return QDF_STATUS_E_INVAL; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 631 | scan_params->ie_list.htcap = |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 632 | (uint8_t *)&(((struct wlan_vendor_ie_htcap *)ie)->ie); |
| 633 | } |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 634 | } else if (is_ht_info((uint8_t *)ie)) { |
| 635 | /* we only care if there isn't already an HT IE (ANA) */ |
Jeff Johnson | 82eb212 | 2019-03-20 12:16:13 -0700 | [diff] [blame] | 636 | if (!scan_params->ie_list.htinfo) { |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 637 | if (ie->ie_len != WLAN_VENDOR_HT_IE_OFFSET_LEN + |
| 638 | sizeof(struct wlan_ie_htinfo_cmn)) |
| 639 | return QDF_STATUS_E_INVAL; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 640 | scan_params->ie_list.htinfo = |
| 641 | (uint8_t *)&(((struct wlan_vendor_ie_htinfo *) |
| 642 | ie)->hi_ie); |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 643 | } |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 644 | } else if (is_interop_vht((uint8_t *)ie) && |
Min Liu | b218312 | 2019-05-17 13:29:00 +0800 | [diff] [blame] | 645 | !(scan_params->ie_list.vhtcap)) { |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 646 | uint8_t *vendor_ie = (uint8_t *)(ie); |
| 647 | |
| 648 | if (ie->ie_len < ((WLAN_VENDOR_VHTCAP_IE_OFFSET + |
| 649 | sizeof(struct wlan_ie_vhtcaps)) - |
| 650 | sizeof(struct ie_header))) |
| 651 | return QDF_STATUS_E_INVAL; |
| 652 | vendor_ie = ((uint8_t *)(ie)) + WLAN_VENDOR_VHTCAP_IE_OFFSET; |
| 653 | if (vendor_ie[1] != (sizeof(struct wlan_ie_vhtcaps)) - |
| 654 | sizeof(struct ie_header)) |
| 655 | return QDF_STATUS_E_INVAL; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 656 | /* location where Interop Vht Cap IE and VHT OP IE Present */ |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 657 | scan_params->ie_list.vhtcap = (((uint8_t *)(ie)) + |
| 658 | WLAN_VENDOR_VHTCAP_IE_OFFSET); |
| 659 | if (ie->ie_len > ((WLAN_VENDOR_VHTCAP_IE_OFFSET + |
| 660 | sizeof(struct wlan_ie_vhtcaps)) - |
Min Liu | b218312 | 2019-05-17 13:29:00 +0800 | [diff] [blame] | 661 | sizeof(struct ie_header))) { |
| 662 | if (ie->ie_len < ((WLAN_VENDOR_VHTOP_IE_OFFSET + |
| 663 | sizeof(struct wlan_ie_vhtop)) - |
| 664 | sizeof(struct ie_header))) |
| 665 | return QDF_STATUS_E_INVAL; |
| 666 | vendor_ie = ((uint8_t *)(ie)) + |
| 667 | WLAN_VENDOR_VHTOP_IE_OFFSET; |
| 668 | if (vendor_ie[1] != (sizeof(struct wlan_ie_vhtop) - |
| 669 | sizeof(struct ie_header))) |
| 670 | return QDF_STATUS_E_INVAL; |
| 671 | scan_params->ie_list.vhtop = (((uint8_t *)(ie)) + |
| 672 | WLAN_VENDOR_VHTOP_IE_OFFSET); |
| 673 | } |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 674 | } else if (is_bwnss_oui((uint8_t *)ie)) { |
| 675 | /* |
| 676 | * Bandwidth-NSS map has sub-type & version. |
| 677 | * hence copy data just after version byte |
| 678 | */ |
| 679 | scan_params->ie_list.bwnss_map = (((uint8_t *)ie) + 8); |
Abhishek Singh | 7b59903 | 2017-11-10 14:42:31 +0530 | [diff] [blame] | 680 | } else if (is_mbo_oce_oui((uint8_t *)ie)) { |
| 681 | scan_params->ie_list.mbo_oce = (uint8_t *)ie; |
Rathees kumar Chinannan | b8f2d08 | 2018-07-04 15:51:51 +0530 | [diff] [blame] | 682 | } else if (is_extender_oui((uint8_t *)ie)) { |
| 683 | scan_params->ie_list.extender = (uint8_t *)ie; |
Pragaspathi Thilagaraj | 45a8c1e | 2019-04-25 17:20:59 +0530 | [diff] [blame] | 684 | } else if (is_adaptive_11r_oui((uint8_t *)ie)) { |
| 685 | if ((ie->ie_len < OUI_LENGTH) || |
| 686 | (ie->ie_len > MAX_ADAPTIVE_11R_IE_LEN)) |
| 687 | return QDF_STATUS_E_INVAL; |
| 688 | |
| 689 | scan_params->ie_list.adaptive_11r = (uint8_t *)ie + |
| 690 | sizeof(struct ie_header); |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 691 | } |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 692 | return QDF_STATUS_SUCCESS; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 693 | } |
| 694 | |
| 695 | static QDF_STATUS |
Ashish Kumar Dhanotiya | 75ccbd4 | 2019-08-29 19:17:44 +0530 | [diff] [blame] | 696 | util_scan_populate_bcn_ie_list(struct scan_cache_entry *scan_params, |
| 697 | uint8_t *chan_idx) |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 698 | { |
| 699 | struct ie_header *ie, *sub_ie; |
| 700 | uint32_t ie_len, sub_ie_len; |
| 701 | QDF_STATUS status; |
| 702 | |
| 703 | ie_len = util_scan_entry_ie_len(scan_params); |
| 704 | ie = (struct ie_header *) |
| 705 | util_scan_entry_ie_data(scan_params); |
| 706 | |
| 707 | while (ie_len >= sizeof(struct ie_header)) { |
| 708 | ie_len -= sizeof(struct ie_header); |
| 709 | |
| 710 | if (!ie->ie_len) { |
| 711 | ie += 1; |
| 712 | continue; |
| 713 | } |
| 714 | |
| 715 | if (ie_len < ie->ie_len) { |
Om Prakash Tripathi | 8e9beae | 2018-04-27 14:35:39 +0530 | [diff] [blame] | 716 | scm_debug("Incomplete corrupted IE:%x", |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 717 | ie->ie_id); |
| 718 | return QDF_STATUS_E_INVAL; |
| 719 | } |
| 720 | |
| 721 | switch (ie->ie_id) { |
| 722 | case WLAN_ELEMID_SSID: |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 723 | if (ie->ie_len > (sizeof(struct ie_ssid) - |
| 724 | sizeof(struct ie_header))) |
Om Prakash Tripathi | 628dfd3 | 2018-10-18 16:08:28 +0530 | [diff] [blame] | 725 | goto err; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 726 | scan_params->ie_list.ssid = (uint8_t *)ie; |
| 727 | break; |
| 728 | case WLAN_ELEMID_RATES: |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 729 | if (ie->ie_len > WLAN_SUPPORTED_RATES_IE_MAX_LEN) |
Om Prakash Tripathi | 628dfd3 | 2018-10-18 16:08:28 +0530 | [diff] [blame] | 730 | goto err; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 731 | scan_params->ie_list.rates = (uint8_t *)ie; |
| 732 | break; |
| 733 | case WLAN_ELEMID_DSPARMS: |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 734 | if (ie->ie_len != WLAN_DS_PARAM_IE_MAX_LEN) |
| 735 | return QDF_STATUS_E_INVAL; |
Abhishek Singh | c05285d | 2018-01-12 15:19:32 +0530 | [diff] [blame] | 736 | scan_params->ie_list.ds_param = (uint8_t *)ie; |
Ashish Kumar Dhanotiya | 75ccbd4 | 2019-08-29 19:17:44 +0530 | [diff] [blame] | 737 | *chan_idx = |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 738 | ((struct ds_ie *)ie)->cur_chan; |
| 739 | break; |
| 740 | case WLAN_ELEMID_TIM: |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 741 | if (ie->ie_len < WLAN_TIM_IE_MIN_LENGTH) |
Om Prakash Tripathi | 628dfd3 | 2018-10-18 16:08:28 +0530 | [diff] [blame] | 742 | goto err; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 743 | scan_params->ie_list.tim = (uint8_t *)ie; |
| 744 | scan_params->dtim_period = |
| 745 | ((struct wlan_tim_ie *)ie)->tim_period; |
| 746 | break; |
| 747 | case WLAN_ELEMID_COUNTRY: |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 748 | if (ie->ie_len < WLAN_COUNTRY_IE_MIN_LEN) |
Om Prakash Tripathi | 628dfd3 | 2018-10-18 16:08:28 +0530 | [diff] [blame] | 749 | goto err; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 750 | scan_params->ie_list.country = (uint8_t *)ie; |
| 751 | break; |
| 752 | case WLAN_ELEMID_QBSS_LOAD: |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 753 | if (ie->ie_len != sizeof(struct qbss_load_ie) - |
Jingxiang Ge | c5f0bd1 | 2018-06-13 18:00:02 +0800 | [diff] [blame] | 754 | sizeof(struct ie_header)) { |
| 755 | /* |
| 756 | * Expected QBSS IE length is 5Bytes; For some |
| 757 | * old cisco AP, QBSS IE length is 4Bytes, which |
| 758 | * doesn't match with latest spec, So ignore |
| 759 | * QBSS IE in such case. |
| 760 | */ |
| 761 | break; |
| 762 | } |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 763 | scan_params->ie_list.qbssload = (uint8_t *)ie; |
| 764 | break; |
| 765 | case WLAN_ELEMID_CHANSWITCHANN: |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 766 | if (ie->ie_len != WLAN_CSA_IE_MAX_LEN) |
Om Prakash Tripathi | 628dfd3 | 2018-10-18 16:08:28 +0530 | [diff] [blame] | 767 | goto err; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 768 | scan_params->ie_list.csa = (uint8_t *)ie; |
| 769 | break; |
| 770 | case WLAN_ELEMID_IBSSDFS: |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 771 | if (ie->ie_len < WLAN_IBSSDFS_IE_MIN_LEN) |
Om Prakash Tripathi | 628dfd3 | 2018-10-18 16:08:28 +0530 | [diff] [blame] | 772 | goto err; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 773 | scan_params->ie_list.ibssdfs = (uint8_t *)ie; |
| 774 | break; |
| 775 | case WLAN_ELEMID_QUIET: |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 776 | if (ie->ie_len != WLAN_QUIET_IE_MAX_LEN) |
Om Prakash Tripathi | 628dfd3 | 2018-10-18 16:08:28 +0530 | [diff] [blame] | 777 | goto err; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 778 | scan_params->ie_list.quiet = (uint8_t *)ie; |
| 779 | break; |
| 780 | case WLAN_ELEMID_ERP: |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 781 | if (ie->ie_len != (sizeof(struct erp_ie) - |
| 782 | sizeof(struct ie_header))) |
Om Prakash Tripathi | 628dfd3 | 2018-10-18 16:08:28 +0530 | [diff] [blame] | 783 | goto err; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 784 | scan_params->erp = ((struct erp_ie *)ie)->value; |
| 785 | break; |
| 786 | case WLAN_ELEMID_HTCAP_ANA: |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 787 | if (ie->ie_len != sizeof(struct htcap_cmn_ie)) |
Om Prakash Tripathi | 628dfd3 | 2018-10-18 16:08:28 +0530 | [diff] [blame] | 788 | goto err; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 789 | scan_params->ie_list.htcap = |
| 790 | (uint8_t *)&(((struct htcap_ie *)ie)->ie); |
| 791 | break; |
| 792 | case WLAN_ELEMID_RSN: |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 793 | if (ie->ie_len < WLAN_RSN_IE_MIN_LEN) |
Om Prakash Tripathi | 628dfd3 | 2018-10-18 16:08:28 +0530 | [diff] [blame] | 794 | goto err; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 795 | scan_params->ie_list.rsn = (uint8_t *)ie; |
| 796 | break; |
| 797 | case WLAN_ELEMID_XRATES: |
| 798 | scan_params->ie_list.xrates = (uint8_t *)ie; |
| 799 | break; |
| 800 | case WLAN_ELEMID_EXTCHANSWITCHANN: |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 801 | if (ie->ie_len != WLAN_XCSA_IE_MAX_LEN) |
Om Prakash Tripathi | 628dfd3 | 2018-10-18 16:08:28 +0530 | [diff] [blame] | 802 | goto err; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 803 | scan_params->ie_list.xcsa = (uint8_t *)ie; |
| 804 | break; |
| 805 | case WLAN_ELEMID_SECCHANOFFSET: |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 806 | if (ie->ie_len != WLAN_SECCHANOFF_IE_MAX_LEN) |
Om Prakash Tripathi | 628dfd3 | 2018-10-18 16:08:28 +0530 | [diff] [blame] | 807 | goto err; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 808 | scan_params->ie_list.secchanoff = (uint8_t *)ie; |
| 809 | break; |
| 810 | case WLAN_ELEMID_HTINFO_ANA: |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 811 | if (ie->ie_len != sizeof(struct wlan_ie_htinfo_cmn)) |
Om Prakash Tripathi | 628dfd3 | 2018-10-18 16:08:28 +0530 | [diff] [blame] | 812 | goto err; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 813 | scan_params->ie_list.htinfo = |
| 814 | (uint8_t *)&(((struct wlan_ie_htinfo *) ie)->hi_ie); |
Ashish Kumar Dhanotiya | 75ccbd4 | 2019-08-29 19:17:44 +0530 | [diff] [blame] | 815 | *chan_idx = |
| 816 | ((struct wlan_ie_htinfo_cmn *) |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 817 | (scan_params->ie_list.htinfo))->hi_ctrlchannel; |
| 818 | break; |
| 819 | case WLAN_ELEMID_WAPI: |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 820 | if (ie->ie_len < WLAN_WAPI_IE_MIN_LEN) |
Om Prakash Tripathi | 628dfd3 | 2018-10-18 16:08:28 +0530 | [diff] [blame] | 821 | goto err; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 822 | scan_params->ie_list.wapi = (uint8_t *)ie; |
| 823 | break; |
| 824 | case WLAN_ELEMID_XCAPS: |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 825 | if (ie->ie_len > WLAN_EXTCAP_IE_MAX_LEN) |
Om Prakash Tripathi | 628dfd3 | 2018-10-18 16:08:28 +0530 | [diff] [blame] | 826 | goto err; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 827 | scan_params->ie_list.extcaps = (uint8_t *)ie; |
| 828 | break; |
| 829 | case WLAN_ELEMID_VHTCAP: |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 830 | if (ie->ie_len != (sizeof(struct wlan_ie_vhtcaps) - |
| 831 | sizeof(struct ie_header))) |
Om Prakash Tripathi | 628dfd3 | 2018-10-18 16:08:28 +0530 | [diff] [blame] | 832 | goto err; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 833 | scan_params->ie_list.vhtcap = (uint8_t *)ie; |
| 834 | break; |
| 835 | case WLAN_ELEMID_VHTOP: |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 836 | if (ie->ie_len != (sizeof(struct wlan_ie_vhtop) - |
| 837 | sizeof(struct ie_header))) |
Om Prakash Tripathi | 628dfd3 | 2018-10-18 16:08:28 +0530 | [diff] [blame] | 838 | goto err; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 839 | scan_params->ie_list.vhtop = (uint8_t *)ie; |
| 840 | break; |
| 841 | case WLAN_ELEMID_OP_MODE_NOTIFY: |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 842 | if (ie->ie_len != WLAN_OPMODE_IE_MAX_LEN) |
Om Prakash Tripathi | 628dfd3 | 2018-10-18 16:08:28 +0530 | [diff] [blame] | 843 | goto err; |
wadesong | d58eaf4 | 2018-05-23 11:30:02 +0800 | [diff] [blame] | 844 | scan_params->ie_list.opmode = (uint8_t *)ie; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 845 | break; |
| 846 | case WLAN_ELEMID_MOBILITY_DOMAIN: |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 847 | if (ie->ie_len != WLAN_MOBILITY_DOMAIN_IE_MAX_LEN) |
Om Prakash Tripathi | 628dfd3 | 2018-10-18 16:08:28 +0530 | [diff] [blame] | 848 | goto err; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 849 | scan_params->ie_list.mdie = (uint8_t *)ie; |
| 850 | break; |
| 851 | case WLAN_ELEMID_VENDOR: |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 852 | status = util_scan_parse_vendor_ie(scan_params, |
| 853 | ie); |
| 854 | if (QDF_IS_STATUS_ERROR(status)) |
Om Prakash Tripathi | 628dfd3 | 2018-10-18 16:08:28 +0530 | [diff] [blame] | 855 | goto err_status; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 856 | break; |
| 857 | case WLAN_ELEMID_CHAN_SWITCH_WRAP: |
| 858 | scan_params->ie_list.cswrp = (uint8_t *)ie; |
| 859 | /* Go to next sub IE */ |
| 860 | sub_ie = (struct ie_header *) |
| 861 | (((uint8_t *)ie) + sizeof(struct ie_header)); |
| 862 | sub_ie_len = ie->ie_len; |
| 863 | status = |
| 864 | util_scan_parse_chan_switch_wrapper_ie( |
| 865 | scan_params, sub_ie, sub_ie_len); |
| 866 | if (QDF_IS_STATUS_ERROR(status)) { |
Om Prakash Tripathi | 628dfd3 | 2018-10-18 16:08:28 +0530 | [diff] [blame] | 867 | goto err_status; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 868 | } |
| 869 | break; |
Kapil Gupta | de02d4f | 2017-06-05 12:37:59 +0530 | [diff] [blame] | 870 | case WLAN_ELEMID_FILS_INDICATION: |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 871 | if (ie->ie_len < WLAN_FILS_INDICATION_IE_MIN_LEN) |
Om Prakash Tripathi | 628dfd3 | 2018-10-18 16:08:28 +0530 | [diff] [blame] | 872 | goto err; |
Kapil Gupta | de02d4f | 2017-06-05 12:37:59 +0530 | [diff] [blame] | 873 | scan_params->ie_list.fils_indication = (uint8_t *)ie; |
| 874 | break; |
Venkateswara Swamy Bandaru | 851184b | 2017-04-25 11:02:39 +0530 | [diff] [blame] | 875 | case WLAN_ELEMID_EXTN_ELEM: |
gaurank kathpalia | 7d65c1b | 2018-02-07 19:56:00 +0530 | [diff] [blame] | 876 | status = util_scan_parse_extn_ie(scan_params, ie); |
| 877 | if (QDF_IS_STATUS_ERROR(status)) |
Om Prakash Tripathi | 628dfd3 | 2018-10-18 16:08:28 +0530 | [diff] [blame] | 878 | goto err_status; |
Venkateswara Swamy Bandaru | 851184b | 2017-04-25 11:02:39 +0530 | [diff] [blame] | 879 | break; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 880 | default: |
| 881 | break; |
| 882 | } |
| 883 | |
| 884 | /* Consume info element */ |
| 885 | ie_len -= ie->ie_len; |
| 886 | /* Go to next IE */ |
| 887 | ie = (struct ie_header *) |
| 888 | (((uint8_t *) ie) + |
| 889 | sizeof(struct ie_header) + |
| 890 | ie->ie_len); |
| 891 | } |
| 892 | |
| 893 | return QDF_STATUS_SUCCESS; |
Om Prakash Tripathi | 628dfd3 | 2018-10-18 16:08:28 +0530 | [diff] [blame] | 894 | |
| 895 | err: |
| 896 | status = QDF_STATUS_E_INVAL; |
| 897 | err_status: |
| 898 | scm_debug("failed to parse IE - id: %d, len: %d", |
| 899 | ie->ie_id, ie->ie_len); |
| 900 | |
| 901 | return status; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 902 | } |
| 903 | |
Abhishek Singh | b80af7e | 2017-07-19 18:48:42 +0530 | [diff] [blame] | 904 | /** |
| 905 | * util_scan_update_esp_data: update ESP params from beacon/probe response |
| 906 | * @esp_information: pointer to wlan_esp_information |
| 907 | * @scan_entry: new received entry |
| 908 | * |
| 909 | * The Estimated Service Parameters element is |
| 910 | * used by a AP to provide information to another STA which |
| 911 | * can then use the information as input to an algorithm to |
| 912 | * generate an estimate of throughput between the two STAs. |
| 913 | * The ESP Information List field contains from 1 to 4 ESP |
| 914 | * Information fields(each field 24 bits), each corresponding |
| 915 | * to an access category for which estimated service parameters |
| 916 | * information is provided. |
| 917 | * |
| 918 | * Return: None |
| 919 | */ |
| 920 | static void util_scan_update_esp_data(struct wlan_esp_ie *esp_information, |
| 921 | struct scan_cache_entry *scan_entry) |
| 922 | { |
| 923 | |
| 924 | uint8_t *data; |
| 925 | int i = 0; |
Sathyanarayanan | 0a00062 | 2017-10-10 17:17:28 +0530 | [diff] [blame] | 926 | uint64_t total_elements; |
Abhishek Singh | b80af7e | 2017-07-19 18:48:42 +0530 | [diff] [blame] | 927 | struct wlan_esp_info *esp_info; |
| 928 | struct wlan_esp_ie *esp_ie; |
| 929 | |
| 930 | esp_ie = (struct wlan_esp_ie *) |
| 931 | util_scan_entry_esp_info(scan_entry); |
| 932 | |
| 933 | total_elements = esp_ie->esp_len; |
| 934 | data = (uint8_t *)esp_ie + 3; |
| 935 | do_div(total_elements, ESP_INFORMATION_LIST_LENGTH); |
| 936 | |
| 937 | if (total_elements > MAX_ESP_INFORMATION_FIELD) { |
| 938 | scm_err("No of Air time fractions are greater than supported"); |
| 939 | return; |
| 940 | } |
| 941 | |
| 942 | for (i = 0; i < total_elements; i++) { |
| 943 | esp_info = (struct wlan_esp_info *)data; |
| 944 | if (esp_info->access_category == ESP_AC_BK) { |
| 945 | qdf_mem_copy(&esp_information->esp_info_AC_BK, |
| 946 | data, 3); |
| 947 | data = data + ESP_INFORMATION_LIST_LENGTH; |
| 948 | continue; |
| 949 | } |
| 950 | if (esp_info->access_category == ESP_AC_BE) { |
| 951 | qdf_mem_copy(&esp_information->esp_info_AC_BE, |
| 952 | data, 3); |
| 953 | data = data + ESP_INFORMATION_LIST_LENGTH; |
| 954 | continue; |
| 955 | } |
| 956 | if (esp_info->access_category == ESP_AC_VI) { |
| 957 | qdf_mem_copy(&esp_information->esp_info_AC_VI, |
| 958 | data, 3); |
| 959 | data = data + ESP_INFORMATION_LIST_LENGTH; |
| 960 | continue; |
| 961 | } |
| 962 | if (esp_info->access_category == ESP_AC_VO) { |
| 963 | qdf_mem_copy(&esp_information->esp_info_AC_VO, |
| 964 | data, 3); |
| 965 | data = data + ESP_INFORMATION_LIST_LENGTH; |
| 966 | break; |
| 967 | } |
| 968 | } |
| 969 | } |
| 970 | |
| 971 | /** |
| 972 | * util_scan_scm_update_bss_with_esp_dataa: calculate estimated air time |
| 973 | * fraction |
| 974 | * @scan_entry: new received entry |
| 975 | * |
| 976 | * This function process all Access category ESP params and provide |
| 977 | * best effort air time fraction. |
| 978 | * If best effort is not available, it will choose VI, VO and BK in sequence |
| 979 | * |
| 980 | */ |
| 981 | static void util_scan_scm_update_bss_with_esp_data( |
| 982 | struct scan_cache_entry *scan_entry) |
| 983 | { |
| 984 | uint8_t air_time_fraction = 0; |
| 985 | struct wlan_esp_ie esp_information; |
| 986 | |
| 987 | if (!scan_entry->ie_list.esp) |
| 988 | return; |
| 989 | |
| 990 | util_scan_update_esp_data(&esp_information, scan_entry); |
| 991 | |
| 992 | /* |
| 993 | * If the ESP metric is transmitting multiple airtime fractions, then |
| 994 | * follow the sequence AC_BE, AC_VI, AC_VO, AC_BK and pick whichever is |
| 995 | * the first one available |
| 996 | */ |
| 997 | if (esp_information.esp_info_AC_BE.access_category |
| 998 | == ESP_AC_BE) |
| 999 | air_time_fraction = |
| 1000 | esp_information.esp_info_AC_BE. |
| 1001 | estimated_air_fraction; |
| 1002 | else if (esp_information.esp_info_AC_VI.access_category |
| 1003 | == ESP_AC_VI) |
| 1004 | air_time_fraction = |
| 1005 | esp_information.esp_info_AC_VI. |
| 1006 | estimated_air_fraction; |
| 1007 | else if (esp_information.esp_info_AC_VO.access_category |
| 1008 | == ESP_AC_VO) |
| 1009 | air_time_fraction = |
| 1010 | esp_information.esp_info_AC_VO. |
| 1011 | estimated_air_fraction; |
| 1012 | else if (esp_information.esp_info_AC_BK.access_category |
| 1013 | == ESP_AC_BK) |
| 1014 | air_time_fraction = |
| 1015 | esp_information.esp_info_AC_BK. |
| 1016 | estimated_air_fraction; |
| 1017 | scan_entry->air_time_fraction = air_time_fraction; |
| 1018 | } |
| 1019 | |
| 1020 | /** |
| 1021 | * util_scan_scm_calc_nss_supported_by_ap() - finds out nss from AP |
| 1022 | * @scan_entry: new received entry |
| 1023 | * |
| 1024 | * Return: number of nss advertised by AP |
| 1025 | */ |
| 1026 | static int util_scan_scm_calc_nss_supported_by_ap( |
| 1027 | struct scan_cache_entry *scan_params) |
| 1028 | { |
| 1029 | struct htcap_cmn_ie *htcap; |
| 1030 | struct wlan_ie_vhtcaps *vhtcaps; |
| 1031 | uint8_t rx_mcs_map; |
| 1032 | |
| 1033 | htcap = (struct htcap_cmn_ie *) |
| 1034 | util_scan_entry_htcap(scan_params); |
| 1035 | vhtcaps = (struct wlan_ie_vhtcaps *) |
| 1036 | util_scan_entry_vhtcap(scan_params); |
| 1037 | if (vhtcaps) { |
| 1038 | rx_mcs_map = vhtcaps->rx_mcs_map; |
| 1039 | if ((rx_mcs_map & 0xC0) != 0xC0) |
| 1040 | return 4; |
| 1041 | |
| 1042 | if ((rx_mcs_map & 0x30) != 0x30) |
| 1043 | return 3; |
| 1044 | |
| 1045 | if ((rx_mcs_map & 0x0C) != 0x0C) |
| 1046 | return 2; |
| 1047 | } else if (htcap) { |
| 1048 | if (htcap->mcsset[3]) |
| 1049 | return 4; |
| 1050 | |
| 1051 | if (htcap->mcsset[2]) |
| 1052 | return 3; |
| 1053 | |
| 1054 | if (htcap->mcsset[1]) |
| 1055 | return 2; |
| 1056 | |
| 1057 | } |
| 1058 | return 1; |
| 1059 | } |
| 1060 | |
Basamma Yakkanahalli | ab48ce3 | 2018-07-06 18:49:19 +0530 | [diff] [blame] | 1061 | #ifdef WLAN_DFS_CHAN_HIDDEN_SSID |
| 1062 | QDF_STATUS |
| 1063 | util_scan_add_hidden_ssid(struct wlan_objmgr_pdev *pdev, qdf_nbuf_t bcnbuf) |
| 1064 | { |
| 1065 | struct wlan_frame_hdr *hdr; |
| 1066 | struct wlan_bcn_frame *bcn; |
| 1067 | struct wlan_scan_obj *scan_obj; |
| 1068 | struct wlan_ssid *conf_ssid; |
| 1069 | struct ie_header *ie; |
| 1070 | uint32_t frame_len = qdf_nbuf_len(bcnbuf); |
| 1071 | uint16_t bcn_ie_offset, ssid_ie_start_offset, ssid_ie_end_offset; |
| 1072 | uint16_t tmplen, ie_length; |
| 1073 | uint8_t *pbeacon, *tmp; |
| 1074 | bool set_ssid_flag = false; |
| 1075 | struct ie_ssid *ssid; |
| 1076 | uint8_t pdev_id; |
| 1077 | |
| 1078 | if (!pdev) { |
| 1079 | scm_warn("pdev: 0x%pK is NULL", pdev); |
| 1080 | return QDF_STATUS_E_NULL_VALUE; |
| 1081 | } |
| 1082 | pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev); |
| 1083 | scan_obj = wlan_pdev_get_scan_obj(pdev); |
Om Prakash Tripathi | 510a27c | 2019-03-01 11:53:18 +0530 | [diff] [blame] | 1084 | if (!scan_obj) { |
| 1085 | scm_warn("null scan_obj"); |
| 1086 | return QDF_STATUS_E_NULL_VALUE; |
| 1087 | } |
Basamma Yakkanahalli | ab48ce3 | 2018-07-06 18:49:19 +0530 | [diff] [blame] | 1088 | |
| 1089 | conf_ssid = &scan_obj->pdev_info[pdev_id].conf_ssid; |
| 1090 | |
| 1091 | hdr = (struct wlan_frame_hdr *)qdf_nbuf_data(bcnbuf); |
| 1092 | |
| 1093 | /* received bssid does not match configured bssid */ |
| 1094 | if (qdf_mem_cmp(hdr->i_addr3, scan_obj->pdev_info[pdev_id].conf_bssid, |
| 1095 | QDF_MAC_ADDR_SIZE) || |
| 1096 | conf_ssid->length == 0) { |
| 1097 | return QDF_STATUS_SUCCESS; |
| 1098 | } |
| 1099 | |
| 1100 | bcn = (struct wlan_bcn_frame *)(qdf_nbuf_data(bcnbuf) + sizeof(*hdr)); |
| 1101 | pbeacon = (uint8_t *)bcn; |
| 1102 | |
| 1103 | ie = (struct ie_header *)(pbeacon + |
| 1104 | offsetof(struct wlan_bcn_frame, ie)); |
| 1105 | |
| 1106 | bcn_ie_offset = offsetof(struct wlan_bcn_frame, ie); |
| 1107 | ie_length = (uint16_t)(frame_len - sizeof(*hdr) - |
| 1108 | bcn_ie_offset); |
| 1109 | |
| 1110 | while (ie_length >= sizeof(struct ie_header)) { |
| 1111 | ie_length -= sizeof(struct ie_header); |
| 1112 | |
| 1113 | bcn_ie_offset += sizeof(struct ie_header); |
| 1114 | |
| 1115 | if (ie_length < ie->ie_len) { |
| 1116 | scm_debug("Incomplete corrupted IE:%x", ie->ie_id); |
| 1117 | return QDF_STATUS_E_INVAL; |
| 1118 | } |
| 1119 | if (ie->ie_id == WLAN_ELEMID_SSID) { |
| 1120 | if (ie->ie_len > (sizeof(struct ie_ssid) - |
| 1121 | sizeof(struct ie_header))) { |
| 1122 | return QDF_STATUS_E_INVAL; |
| 1123 | } |
| 1124 | ssid = (struct ie_ssid *)ie; |
| 1125 | if (util_scan_is_hidden_ssid(ssid)) { |
| 1126 | set_ssid_flag = true; |
| 1127 | ssid_ie_start_offset = bcn_ie_offset - |
| 1128 | sizeof(struct ie_header); |
| 1129 | ssid_ie_end_offset = bcn_ie_offset + |
| 1130 | ie->ie_len; |
| 1131 | } |
| 1132 | } |
| 1133 | if (ie->ie_len == 0) { |
| 1134 | ie += 1; /* next IE */ |
| 1135 | continue; |
| 1136 | } |
| 1137 | if (ie->ie_id == WLAN_ELEMID_VENDOR && |
| 1138 | is_wps_oui((uint8_t *)ie)) { |
| 1139 | set_ssid_flag = false; |
| 1140 | break; |
| 1141 | } |
| 1142 | /* Consume info element */ |
| 1143 | ie_length -= ie->ie_len; |
| 1144 | /* Go to next IE */ |
| 1145 | ie = (struct ie_header *)(((uint8_t *)ie) + |
| 1146 | sizeof(struct ie_header) + |
| 1147 | ie->ie_len); |
| 1148 | } |
| 1149 | |
| 1150 | if (set_ssid_flag) { |
| 1151 | /* Hidden SSID if the Length is 0 */ |
| 1152 | if (!ssid->ssid_len) { |
| 1153 | /* increase the taillength by length of ssid */ |
| 1154 | if (qdf_nbuf_put_tail(bcnbuf, |
| 1155 | conf_ssid->length) == NULL) { |
| 1156 | scm_debug("No enough tailroom"); |
| 1157 | return QDF_STATUS_E_NOMEM; |
| 1158 | } |
| 1159 | /* length of the buffer to be copied */ |
| 1160 | tmplen = frame_len - |
| 1161 | sizeof(*hdr) - ssid_ie_end_offset; |
| 1162 | /* |
| 1163 | * tmp memory to copy the beacon info |
| 1164 | * after ssid ie. |
| 1165 | */ |
| 1166 | tmp = qdf_mem_malloc(tmplen * sizeof(u_int8_t)); |
Madhvapathi Sriram | b73fc28 | 2019-01-07 09:12:25 +0530 | [diff] [blame] | 1167 | if (!tmp) |
Basamma Yakkanahalli | ab48ce3 | 2018-07-06 18:49:19 +0530 | [diff] [blame] | 1168 | return QDF_STATUS_E_NOMEM; |
Madhvapathi Sriram | b73fc28 | 2019-01-07 09:12:25 +0530 | [diff] [blame] | 1169 | |
Basamma Yakkanahalli | ab48ce3 | 2018-07-06 18:49:19 +0530 | [diff] [blame] | 1170 | /* Copy beacon data after ssid ie to tmp */ |
| 1171 | qdf_nbuf_copy_bits(bcnbuf, (sizeof(*hdr) + |
| 1172 | ssid_ie_end_offset), tmplen, tmp); |
| 1173 | /* Add ssid length */ |
| 1174 | *(pbeacon + (ssid_ie_start_offset + 1)) |
| 1175 | = conf_ssid->length; |
| 1176 | /* Insert the SSID string */ |
| 1177 | qdf_mem_copy((pbeacon + ssid_ie_end_offset), |
| 1178 | conf_ssid->ssid, conf_ssid->length); |
| 1179 | /* Copy rest of the beacon data */ |
| 1180 | qdf_mem_copy((pbeacon + ssid_ie_end_offset + |
| 1181 | conf_ssid->length), tmp, tmplen); |
| 1182 | qdf_mem_free(tmp); |
| 1183 | |
| 1184 | /* Hidden ssid with all 0's */ |
| 1185 | } else if (ssid->ssid_len == conf_ssid->length) { |
| 1186 | /* Insert the SSID string */ |
| 1187 | qdf_mem_copy((pbeacon + ssid_ie_start_offset + |
| 1188 | sizeof(struct ie_header)), |
| 1189 | conf_ssid->ssid, conf_ssid->length); |
| 1190 | } else { |
| 1191 | scm_debug("mismatch in hidden ssid length"); |
| 1192 | return QDF_STATUS_E_INVAL; |
| 1193 | } |
| 1194 | } |
| 1195 | return QDF_STATUS_SUCCESS; |
| 1196 | } |
| 1197 | #endif /* WLAN_DFS_CHAN_HIDDEN_SSID */ |
Pragaspathi Thilagaraj | 45a8c1e | 2019-04-25 17:20:59 +0530 | [diff] [blame] | 1198 | |
| 1199 | #ifdef WLAN_ADAPTIVE_11R |
| 1200 | /** |
| 1201 | * scm_fill_adaptive_11r_cap() - Check if the AP supports adaptive 11r |
| 1202 | * @scan_entry: Pointer to the scan entry |
| 1203 | * |
| 1204 | * Return: true if adaptive 11r is advertised else false |
| 1205 | */ |
| 1206 | static void scm_fill_adaptive_11r_cap(struct scan_cache_entry *scan_entry) |
| 1207 | { |
| 1208 | uint8_t *ie; |
| 1209 | uint8_t data; |
| 1210 | bool adaptive_11r; |
| 1211 | |
| 1212 | ie = util_scan_entry_adaptive_11r(scan_entry); |
| 1213 | if (!ie) |
| 1214 | return; |
| 1215 | |
| 1216 | data = *(ie + OUI_LENGTH); |
| 1217 | adaptive_11r = (data & 0x1) ? true : false; |
| 1218 | |
| 1219 | scan_entry->adaptive_11r_ap = adaptive_11r; |
| 1220 | } |
| 1221 | #else |
| 1222 | static void scm_fill_adaptive_11r_cap(struct scan_cache_entry *scan_entry) |
| 1223 | { |
| 1224 | scan_entry->adaptive_11r_ap = false; |
| 1225 | } |
| 1226 | #endif |
| 1227 | |
Sandeep Puligilla | 54d8b64 | 2018-07-06 17:35:26 -0700 | [diff] [blame] | 1228 | static QDF_STATUS |
| 1229 | util_scan_gen_scan_entry(struct wlan_objmgr_pdev *pdev, |
| 1230 | uint8_t *frame, qdf_size_t frame_len, |
| 1231 | uint32_t frm_subtype, |
| 1232 | struct mgmt_rx_event_params *rx_param, |
Sandeep Puligilla | 949faf5 | 2019-02-15 10:32:00 -0800 | [diff] [blame] | 1233 | struct scan_mbssid_info *mbssid_info, |
Sandeep Puligilla | 54d8b64 | 2018-07-06 17:35:26 -0700 | [diff] [blame] | 1234 | qdf_list_t *scan_list) |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 1235 | { |
| 1236 | struct wlan_frame_hdr *hdr; |
| 1237 | struct wlan_bcn_frame *bcn; |
Sandeep Puligilla | 54d8b64 | 2018-07-06 17:35:26 -0700 | [diff] [blame] | 1238 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 1239 | struct ie_ssid *ssid; |
Sandeep Puligilla | c676459 | 2017-12-05 21:01:52 -0800 | [diff] [blame] | 1240 | struct scan_cache_entry *scan_entry; |
Abhishek Singh | 7b59903 | 2017-11-10 14:42:31 +0530 | [diff] [blame] | 1241 | struct qbss_load_ie *qbss_load; |
Sandeep Puligilla | c676459 | 2017-12-05 21:01:52 -0800 | [diff] [blame] | 1242 | struct scan_cache_node *scan_node; |
Ashish Kumar Dhanotiya | 75ccbd4 | 2019-08-29 19:17:44 +0530 | [diff] [blame] | 1243 | uint8_t i, chan_idx = 0; |
Sandeep Puligilla | c676459 | 2017-12-05 21:01:52 -0800 | [diff] [blame] | 1244 | |
Om Prakash Tripathi | 9b56f5d | 2018-05-29 11:42:19 +0530 | [diff] [blame] | 1245 | scan_entry = qdf_mem_malloc_atomic(sizeof(*scan_entry)); |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 1246 | if (!scan_entry) { |
| 1247 | scm_err("failed to allocate memory for scan_entry"); |
Sandeep Puligilla | 54d8b64 | 2018-07-06 17:35:26 -0700 | [diff] [blame] | 1248 | return QDF_STATUS_E_NOMEM; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 1249 | } |
| 1250 | scan_entry->raw_frame.ptr = |
Om Prakash Tripathi | 9b56f5d | 2018-05-29 11:42:19 +0530 | [diff] [blame] | 1251 | qdf_mem_malloc_atomic(frame_len); |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 1252 | if (!scan_entry->raw_frame.ptr) { |
| 1253 | scm_err("failed to allocate memory for frame"); |
| 1254 | qdf_mem_free(scan_entry); |
Sandeep Puligilla | 54d8b64 | 2018-07-06 17:35:26 -0700 | [diff] [blame] | 1255 | return QDF_STATUS_E_NOMEM; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 1256 | } |
| 1257 | |
| 1258 | bcn = (struct wlan_bcn_frame *) |
| 1259 | (frame + sizeof(*hdr)); |
| 1260 | hdr = (struct wlan_frame_hdr *)frame; |
| 1261 | |
gaurank kathpalia | 26f9833 | 2018-01-29 18:09:06 +0530 | [diff] [blame] | 1262 | /* update timestamp in nanoseconds needed by kernel layers */ |
Arif Hussain | 6fcc790 | 2018-03-22 12:33:12 -0700 | [diff] [blame] | 1263 | scan_entry->boottime_ns = qdf_get_bootbased_boottime_ns(); |
gaurank kathpalia | 26f9833 | 2018-01-29 18:09:06 +0530 | [diff] [blame] | 1264 | |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 1265 | scan_entry->frm_subtype = frm_subtype; |
| 1266 | qdf_mem_copy(scan_entry->bssid.bytes, |
| 1267 | hdr->i_addr3, QDF_MAC_ADDR_SIZE); |
| 1268 | /* Scr addr */ |
| 1269 | qdf_mem_copy(scan_entry->mac_addr.bytes, |
| 1270 | hdr->i_addr2, QDF_MAC_ADDR_SIZE); |
| 1271 | scan_entry->seq_num = |
| 1272 | (le16toh(*(uint16_t *)hdr->i_seq) >> WLAN_SEQ_SEQ_SHIFT); |
| 1273 | |
Shashikala Prabhu | a477ec2 | 2019-10-22 09:41:10 +0530 | [diff] [blame] | 1274 | scan_entry->snr = rx_param->snr; |
| 1275 | scan_entry->avg_snr = WLAN_SNR_IN(scan_entry->snr); |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 1276 | scan_entry->rssi_raw = rx_param->rssi; |
Om Prakash Tripathi | 6af738b | 2017-08-22 15:46:38 +0530 | [diff] [blame] | 1277 | scan_entry->avg_rssi = WLAN_RSSI_IN(scan_entry->rssi_raw); |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 1278 | scan_entry->tsf_delta = rx_param->tsf_delta; |
Ashish Kumar Dhanotiya | 75ccbd4 | 2019-08-29 19:17:44 +0530 | [diff] [blame] | 1279 | scan_entry->pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev); |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 1280 | |
gaurank kathpalia | 26f9833 | 2018-01-29 18:09:06 +0530 | [diff] [blame] | 1281 | /* Copy per chain rssi to scan entry */ |
Yeshwanth Sriram Guntuka | c4a14ea | 2018-09-21 15:08:46 +0530 | [diff] [blame] | 1282 | qdf_mem_copy(scan_entry->per_chain_rssi, rx_param->rssi_ctl, |
gaurank kathpalia | 26f9833 | 2018-01-29 18:09:06 +0530 | [diff] [blame] | 1283 | WLAN_MGMT_TXRX_HOST_MAX_ANTENNA); |
| 1284 | |
Yeshwanth Sriram Guntuka | c4a14ea | 2018-09-21 15:08:46 +0530 | [diff] [blame] | 1285 | if (!wlan_psoc_nif_fw_ext_cap_get(wlan_pdev_get_psoc(pdev), |
| 1286 | WLAN_SOC_CEXT_HW_DB2DBM)) { |
| 1287 | for (i = 0; i < WLAN_MGMT_TXRX_HOST_MAX_ANTENNA; i++) { |
| 1288 | if (scan_entry->per_chain_rssi[i] != |
| 1289 | WLAN_INVALID_PER_CHAIN_SNR) |
| 1290 | scan_entry->per_chain_rssi[i] += |
| 1291 | WLAN_NOISE_FLOOR_DBM_DEFAULT; |
| 1292 | else |
| 1293 | scan_entry->per_chain_rssi[i] = |
| 1294 | WLAN_INVALID_PER_CHAIN_RSSI; |
| 1295 | } |
| 1296 | } |
| 1297 | |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 1298 | /* store jiffies */ |
Sandeep Puligilla | 54d8b64 | 2018-07-06 17:35:26 -0700 | [diff] [blame] | 1299 | scan_entry->rrm_parent_tsf = (uint32_t)qdf_system_ticks(); |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 1300 | |
| 1301 | scan_entry->bcn_int = le16toh(bcn->beacon_interval); |
| 1302 | |
| 1303 | /* |
| 1304 | * In case if the beacon dosnt have |
| 1305 | * valid beacon interval falback to def |
| 1306 | */ |
| 1307 | if (!scan_entry->bcn_int) |
| 1308 | scan_entry->bcn_int = 100; |
| 1309 | scan_entry->cap_info.value = le16toh(bcn->capability.value); |
| 1310 | qdf_mem_copy(scan_entry->tsf_info.data, |
| 1311 | bcn->timestamp, 8); |
| 1312 | scan_entry->erp = ERP_NON_ERP_PRESENT; |
| 1313 | |
Om Prakash Tripathi | cdcbb39 | 2017-04-18 18:51:20 +0530 | [diff] [blame] | 1314 | scan_entry->scan_entry_time = |
| 1315 | qdf_mc_timer_get_system_time(); |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 1316 | |
| 1317 | scan_entry->raw_frame.len = frame_len; |
| 1318 | qdf_mem_copy(scan_entry->raw_frame.ptr, |
| 1319 | frame, frame_len); |
Ashish Kumar Dhanotiya | 75ccbd4 | 2019-08-29 19:17:44 +0530 | [diff] [blame] | 1320 | status = util_scan_populate_bcn_ie_list(scan_entry, &chan_idx); |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 1321 | if (QDF_IS_STATUS_ERROR(status)) { |
Om Prakash Tripathi | 8e9beae | 2018-04-27 14:35:39 +0530 | [diff] [blame] | 1322 | scm_debug("failed to parse beacon IE"); |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 1323 | qdf_mem_free(scan_entry->raw_frame.ptr); |
| 1324 | qdf_mem_free(scan_entry); |
Sandeep Puligilla | 54d8b64 | 2018-07-06 17:35:26 -0700 | [diff] [blame] | 1325 | return QDF_STATUS_E_FAILURE; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 1326 | } |
| 1327 | |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 1328 | ssid = (struct ie_ssid *) |
| 1329 | scan_entry->ie_list.ssid; |
| 1330 | |
| 1331 | if (ssid && (ssid->ssid_len > WLAN_SSID_MAX_LEN)) { |
| 1332 | qdf_mem_free(scan_entry->raw_frame.ptr); |
| 1333 | qdf_mem_free(scan_entry); |
Sandeep Puligilla | 54d8b64 | 2018-07-06 17:35:26 -0700 | [diff] [blame] | 1334 | return QDF_STATUS_E_FAILURE; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 1335 | } |
| 1336 | |
| 1337 | if (scan_entry->ie_list.p2p) |
| 1338 | scan_entry->is_p2p = true; |
| 1339 | |
Ashish Kumar Dhanotiya | 75ccbd4 | 2019-08-29 19:17:44 +0530 | [diff] [blame] | 1340 | if (chan_idx) { |
| 1341 | uint8_t band_mask = BIT(wlan_reg_freq_to_band( |
| 1342 | rx_param->chan_freq)); |
| 1343 | |
| 1344 | scan_entry->channel.chan_freq = |
| 1345 | wlan_reg_chan_band_to_freq( |
| 1346 | pdev, chan_idx, |
| 1347 | band_mask); |
| 1348 | } |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 1349 | /* If no channel info is present in beacon use meta channel */ |
Ashish Kumar Dhanotiya | 75ccbd4 | 2019-08-29 19:17:44 +0530 | [diff] [blame] | 1350 | if (!scan_entry->channel.chan_freq) { |
| 1351 | scan_entry->channel.chan_freq = rx_param->chan_freq; |
| 1352 | } else if (rx_param->chan_freq != |
| 1353 | scan_entry->channel.chan_freq) { |
| 1354 | if (!wlan_reg_is_49ghz_freq(scan_entry->channel.chan_freq)) |
Shashikala Prabhu | 7edbb05 | 2018-04-12 09:55:25 +0530 | [diff] [blame] | 1355 | scan_entry->channel_mismatch = true; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 1356 | } |
| 1357 | |
| 1358 | if (util_scan_is_hidden_ssid(ssid)) { |
| 1359 | scan_entry->ie_list.ssid = NULL; |
Abhishek Singh | 7062efa | 2019-03-05 15:37:07 +0530 | [diff] [blame] | 1360 | scan_entry->is_hidden_ssid = true; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 1361 | } else { |
| 1362 | qdf_mem_copy(scan_entry->ssid.ssid, |
Harprit Chhabada | ab6c10d | 2018-10-31 10:52:34 -0700 | [diff] [blame] | 1363 | ssid->ssid, ssid->ssid_len); |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 1364 | scan_entry->ssid.length = ssid->ssid_len; |
| 1365 | scan_entry->hidden_ssid_timestamp = |
| 1366 | scan_entry->scan_entry_time; |
| 1367 | } |
Sandeep Puligilla | 949faf5 | 2019-02-15 10:32:00 -0800 | [diff] [blame] | 1368 | qdf_mem_copy(&scan_entry->mbssid_info, mbssid_info, |
| 1369 | sizeof(scan_entry->mbssid_info)); |
Abhishek Ambure | 986f5c9 | 2019-10-21 14:52:59 +0530 | [diff] [blame] | 1370 | |
Abhishek Singh | 3c5f8ef | 2019-11-06 10:02:07 +0530 | [diff] [blame^] | 1371 | scan_entry->phy_mode = util_scan_get_phymode(pdev, scan_entry); |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 1372 | |
Abhishek Singh | b80af7e | 2017-07-19 18:48:42 +0530 | [diff] [blame] | 1373 | scan_entry->nss = util_scan_scm_calc_nss_supported_by_ap(scan_entry); |
Pragaspathi Thilagaraj | 45a8c1e | 2019-04-25 17:20:59 +0530 | [diff] [blame] | 1374 | scm_fill_adaptive_11r_cap(scan_entry); |
| 1375 | |
Abhishek Singh | b80af7e | 2017-07-19 18:48:42 +0530 | [diff] [blame] | 1376 | util_scan_scm_update_bss_with_esp_data(scan_entry); |
Abhishek Singh | 7b59903 | 2017-11-10 14:42:31 +0530 | [diff] [blame] | 1377 | qbss_load = (struct qbss_load_ie *) |
| 1378 | util_scan_entry_qbssload(scan_entry); |
| 1379 | if (qbss_load) |
| 1380 | scan_entry->qbss_chan_load = qbss_load->qbss_chan_load; |
Abhishek Singh | b80af7e | 2017-07-19 18:48:42 +0530 | [diff] [blame] | 1381 | |
Om Prakash Tripathi | 9b56f5d | 2018-05-29 11:42:19 +0530 | [diff] [blame] | 1382 | scan_node = qdf_mem_malloc_atomic(sizeof(*scan_node)); |
Sandeep Puligilla | c676459 | 2017-12-05 21:01:52 -0800 | [diff] [blame] | 1383 | if (!scan_node) { |
Om Prakash Tripathi | 5240255 | 2018-02-21 16:31:49 +0530 | [diff] [blame] | 1384 | qdf_mem_free(scan_entry->raw_frame.ptr); |
Sandeep Puligilla | c676459 | 2017-12-05 21:01:52 -0800 | [diff] [blame] | 1385 | qdf_mem_free(scan_entry); |
Sandeep Puligilla | 54d8b64 | 2018-07-06 17:35:26 -0700 | [diff] [blame] | 1386 | return QDF_STATUS_E_FAILURE; |
Sandeep Puligilla | c676459 | 2017-12-05 21:01:52 -0800 | [diff] [blame] | 1387 | } |
| 1388 | |
| 1389 | scan_node->entry = scan_entry; |
| 1390 | qdf_list_insert_front(scan_list, &scan_node->node); |
| 1391 | |
Sandeep Puligilla | 54d8b64 | 2018-07-06 17:35:26 -0700 | [diff] [blame] | 1392 | return status; |
| 1393 | } |
| 1394 | |
| 1395 | /** |
| 1396 | * util_scan_find_ie() - find information element |
| 1397 | * @eid: element id |
| 1398 | * @ies: pointer consisting of IEs |
| 1399 | * @len: IE length |
| 1400 | * |
| 1401 | * Return: NULL if the element ID is not found or |
| 1402 | * a pointer to the first byte of the requested |
| 1403 | * element |
| 1404 | */ |
| 1405 | static uint8_t *util_scan_find_ie(uint8_t eid, uint8_t *ies, |
| 1406 | int32_t len) |
| 1407 | { |
| 1408 | while (len >= 2 && len >= ies[1] + 2) { |
| 1409 | if (ies[0] == eid) |
| 1410 | return ies; |
| 1411 | len -= ies[1] + 2; |
| 1412 | ies += ies[1] + 2; |
| 1413 | } |
| 1414 | |
| 1415 | return NULL; |
| 1416 | } |
| 1417 | |
| 1418 | #ifdef WLAN_FEATURE_MBSSID |
| 1419 | static void util_gen_new_bssid(uint8_t *bssid, uint8_t max_bssid, |
| 1420 | uint8_t mbssid_index, |
| 1421 | uint8_t *new_bssid_addr) |
| 1422 | { |
| 1423 | uint64_t bssid_tmp = 0, new_bssid = 0; |
| 1424 | uint64_t lsb_n; |
| 1425 | int i; |
| 1426 | |
| 1427 | for (i = 0; i < QDF_MAC_ADDR_SIZE; i++) |
| 1428 | bssid_tmp = bssid_tmp << 8 | bssid[i]; |
| 1429 | |
| 1430 | lsb_n = bssid_tmp & ((1 << max_bssid) - 1); |
| 1431 | new_bssid = bssid_tmp; |
| 1432 | new_bssid &= ~((1 << max_bssid) - 1); |
Gurumoorthi Gnanasambandhan | f069fcc | 2019-10-17 17:33:22 +0530 | [diff] [blame] | 1433 | new_bssid |= qdf_do_div((lsb_n + mbssid_index), (1 << max_bssid)); |
Sandeep Puligilla | 54d8b64 | 2018-07-06 17:35:26 -0700 | [diff] [blame] | 1434 | |
| 1435 | for (i = QDF_MAC_ADDR_SIZE - 1; i >= 0; i--) { |
| 1436 | new_bssid_addr[i] = new_bssid & 0xff; |
| 1437 | new_bssid = new_bssid >> 8; |
| 1438 | } |
| 1439 | } |
| 1440 | |
| 1441 | static uint32_t util_gen_new_ie(uint8_t *ie, uint32_t ielen, |
| 1442 | uint8_t *subelement, |
| 1443 | size_t subie_len, uint8_t *new_ie) |
| 1444 | { |
| 1445 | uint8_t *pos, *tmp; |
| 1446 | const uint8_t *tmp_old, *tmp_new; |
| 1447 | uint8_t *sub_copy; |
| 1448 | |
| 1449 | /* copy subelement as we need to change its content to |
| 1450 | * mark an ie after it is processed. |
| 1451 | */ |
| 1452 | sub_copy = qdf_mem_malloc(subie_len); |
| 1453 | if (!sub_copy) |
| 1454 | return 0; |
| 1455 | qdf_mem_copy(sub_copy, subelement, subie_len); |
| 1456 | |
| 1457 | pos = &new_ie[0]; |
| 1458 | |
| 1459 | /* new ssid */ |
| 1460 | tmp_new = util_scan_find_ie(WLAN_ELEMID_SSID, sub_copy, subie_len); |
| 1461 | if (tmp_new) { |
| 1462 | qdf_mem_copy(pos, tmp_new, tmp_new[1] + 2); |
| 1463 | pos += (tmp_new[1] + 2); |
| 1464 | } |
| 1465 | |
| 1466 | /* go through IEs in ie (skip SSID) and subelement, |
| 1467 | * merge them into new_ie |
| 1468 | */ |
| 1469 | tmp_old = util_scan_find_ie(WLAN_ELEMID_SSID, ie, ielen); |
| 1470 | tmp_old = (tmp_old) ? tmp_old + tmp_old[1] + 2 : ie; |
| 1471 | |
| 1472 | while (tmp_old + tmp_old[1] + 2 - ie <= ielen) { |
| 1473 | if (tmp_old[0] == 0) { |
| 1474 | tmp_old++; |
| 1475 | continue; |
| 1476 | } |
| 1477 | |
| 1478 | tmp = (uint8_t *)util_scan_find_ie(tmp_old[0], sub_copy, |
| 1479 | subie_len); |
| 1480 | if (!tmp) { |
| 1481 | /* ie in old ie but not in subelement */ |
| 1482 | if (tmp_old[0] != WLAN_ELEMID_MULTIPLE_BSSID) { |
| 1483 | qdf_mem_copy(pos, tmp_old, tmp_old[1] + 2); |
| 1484 | pos += tmp_old[1] + 2; |
| 1485 | } |
| 1486 | } else { |
| 1487 | /* ie in transmitting ie also in subelement, |
| 1488 | * copy from subelement and flag the ie in subelement |
| 1489 | * as copied (by setting eid field to 0xff). For |
| 1490 | * vendor ie, compare OUI + type + subType to |
| 1491 | * determine if they are the same ie. |
| 1492 | */ |
| 1493 | if (tmp_old[0] == WLAN_ELEMID_VENDOR) { |
| 1494 | if (!qdf_mem_cmp(tmp_old + 2, tmp + 2, 5)) { |
| 1495 | /* same vendor ie, copy from |
| 1496 | * subelement |
| 1497 | */ |
| 1498 | qdf_mem_copy(pos, tmp, tmp[1] + 2); |
| 1499 | pos += tmp[1] + 2; |
| 1500 | tmp[0] = 0xff; |
| 1501 | } else { |
| 1502 | qdf_mem_copy(pos, tmp_old, |
| 1503 | tmp_old[1] + 2); |
| 1504 | pos += tmp_old[1] + 2; |
| 1505 | } |
| 1506 | } else { |
| 1507 | /* copy ie from subelement into new ie */ |
| 1508 | qdf_mem_copy(pos, tmp, tmp[1] + 2); |
| 1509 | pos += tmp[1] + 2; |
| 1510 | tmp[0] = 0xff; |
| 1511 | } |
| 1512 | } |
| 1513 | |
| 1514 | if (tmp_old + tmp_old[1] + 2 - ie == ielen) |
| 1515 | break; |
| 1516 | |
| 1517 | tmp_old += tmp_old[1] + 2; |
| 1518 | } |
| 1519 | |
| 1520 | /* go through subelement again to check if there is any ie not |
| 1521 | * copied to new ie, skip ssid, capability, bssid-index ie |
| 1522 | */ |
| 1523 | tmp_new = sub_copy; |
| 1524 | while (tmp_new + tmp_new[1] + 2 - sub_copy <= subie_len) { |
| 1525 | if (!(tmp_new[0] == WLAN_ELEMID_NONTX_BSSID_CAP || |
| 1526 | tmp_new[0] == WLAN_ELEMID_SSID || |
| 1527 | tmp_new[0] == WLAN_ELEMID_MULTI_BSSID_IDX || |
| 1528 | tmp_new[0] == 0xff)) { |
| 1529 | qdf_mem_copy(pos, tmp_new, tmp_new[1] + 2); |
| 1530 | pos += tmp_new[1] + 2; |
| 1531 | } |
| 1532 | if (tmp_new + tmp_new[1] + 2 - sub_copy == subie_len) |
| 1533 | break; |
| 1534 | tmp_new += tmp_new[1] + 2; |
| 1535 | } |
| 1536 | |
| 1537 | qdf_mem_free(sub_copy); |
| 1538 | return pos - new_ie; |
| 1539 | } |
| 1540 | |
| 1541 | static QDF_STATUS util_scan_parse_mbssid(struct wlan_objmgr_pdev *pdev, |
| 1542 | uint8_t *frame, qdf_size_t frame_len, |
| 1543 | uint32_t frm_subtype, |
| 1544 | struct mgmt_rx_event_params *rx_param, |
| 1545 | qdf_list_t *scan_list) |
| 1546 | { |
| 1547 | struct wlan_bcn_frame *bcn; |
| 1548 | struct wlan_frame_hdr *hdr; |
Sandeep Puligilla | 949faf5 | 2019-02-15 10:32:00 -0800 | [diff] [blame] | 1549 | struct scan_mbssid_info mbssid_info; |
Sandeep Puligilla | 54d8b64 | 2018-07-06 17:35:26 -0700 | [diff] [blame] | 1550 | QDF_STATUS status; |
| 1551 | uint8_t *pos, *subelement, *mbssid_end_pos; |
| 1552 | uint8_t *tmp, *mbssid_index_ie; |
| 1553 | uint32_t subie_len, new_ie_len; |
| 1554 | uint8_t new_bssid[QDF_MAC_ADDR_SIZE], bssid[QDF_MAC_ADDR_SIZE]; |
| 1555 | uint8_t *new_ie; |
| 1556 | uint8_t *ie, *new_frame = NULL; |
| 1557 | uint64_t ielen, new_frame_len; |
| 1558 | |
| 1559 | hdr = (struct wlan_frame_hdr *)frame; |
| 1560 | bcn = (struct wlan_bcn_frame *)(frame + sizeof(struct wlan_frame_hdr)); |
| 1561 | ie = (uint8_t *)&bcn->ie; |
| 1562 | ielen = (uint16_t)(frame_len - |
| 1563 | sizeof(struct wlan_frame_hdr) - |
| 1564 | offsetof(struct wlan_bcn_frame, ie)); |
| 1565 | qdf_mem_copy(bssid, hdr->i_addr3, QDF_MAC_ADDR_SIZE); |
| 1566 | |
| 1567 | if (!util_scan_find_ie(WLAN_ELEMID_MULTIPLE_BSSID, ie, ielen)) |
| 1568 | return QDF_STATUS_E_FAILURE; |
| 1569 | |
| 1570 | pos = ie; |
| 1571 | |
| 1572 | new_ie = qdf_mem_malloc(MAX_IE_LEN); |
Madhvapathi Sriram | b73fc28 | 2019-01-07 09:12:25 +0530 | [diff] [blame] | 1573 | if (!new_ie) |
Sandeep Puligilla | 54d8b64 | 2018-07-06 17:35:26 -0700 | [diff] [blame] | 1574 | return QDF_STATUS_E_NOMEM; |
Sandeep Puligilla | 54d8b64 | 2018-07-06 17:35:26 -0700 | [diff] [blame] | 1575 | |
| 1576 | while (pos < ie + ielen + 2) { |
| 1577 | tmp = util_scan_find_ie(WLAN_ELEMID_MULTIPLE_BSSID, pos, |
| 1578 | ielen - (pos - ie)); |
| 1579 | if (!tmp) |
| 1580 | break; |
| 1581 | |
Sandeep Puligilla | 949faf5 | 2019-02-15 10:32:00 -0800 | [diff] [blame] | 1582 | mbssid_info.profile_count = 1 << tmp[2]; |
Sandeep Puligilla | 54d8b64 | 2018-07-06 17:35:26 -0700 | [diff] [blame] | 1583 | mbssid_end_pos = tmp + tmp[1] + 2; |
| 1584 | /* Skip Element ID, Len, MaxBSSID Indicator */ |
| 1585 | if (tmp[1] < 4) |
| 1586 | break; |
| 1587 | for (subelement = tmp + 3; subelement < mbssid_end_pos - 1; |
| 1588 | subelement += 2 + subelement[1]) { |
| 1589 | subie_len = subelement[1]; |
| 1590 | if (mbssid_end_pos - subelement < 2 + subie_len) |
| 1591 | break; |
| 1592 | if (subelement[0] != 0 || subelement[1] < 4) { |
| 1593 | /* not a valid BSS profile */ |
| 1594 | continue; |
| 1595 | } |
| 1596 | |
| 1597 | if (subelement[2] != WLAN_ELEMID_NONTX_BSSID_CAP || |
| 1598 | subelement[3] != 2) { |
| 1599 | /* The first element within the Nontransmitted |
| 1600 | * BSSID Profile is not the Nontransmitted |
| 1601 | * BSSID Capability element. |
| 1602 | */ |
| 1603 | continue; |
| 1604 | } |
| 1605 | |
| 1606 | /* found a Nontransmitted BSSID Profile */ |
| 1607 | mbssid_index_ie = |
| 1608 | util_scan_find_ie(WLAN_ELEMID_MULTI_BSSID_IDX, |
| 1609 | subelement + 2, subie_len); |
| 1610 | if (!mbssid_index_ie || mbssid_index_ie[1] < 1 || |
| 1611 | mbssid_index_ie[2] == 0) { |
| 1612 | /* No valid Multiple BSSID-Index element */ |
| 1613 | continue; |
| 1614 | } |
Sandeep Puligilla | 949faf5 | 2019-02-15 10:32:00 -0800 | [diff] [blame] | 1615 | qdf_mem_copy(&mbssid_info.trans_bssid, bssid, |
| 1616 | QDF_MAC_ADDR_SIZE); |
| 1617 | mbssid_info.profile_num = mbssid_index_ie[2]; |
Sandeep Puligilla | 54d8b64 | 2018-07-06 17:35:26 -0700 | [diff] [blame] | 1618 | util_gen_new_bssid(bssid, tmp[2], mbssid_index_ie[2], |
| 1619 | new_bssid); |
| 1620 | new_ie_len = util_gen_new_ie(ie, ielen, subelement + 2, |
| 1621 | subie_len, new_ie); |
| 1622 | if (!new_ie_len) |
| 1623 | continue; |
| 1624 | |
| 1625 | new_frame_len = frame_len - ielen + new_ie_len; |
| 1626 | new_frame = qdf_mem_malloc(new_frame_len); |
| 1627 | if (!new_frame) { |
| 1628 | qdf_mem_free(new_ie); |
Sandeep Puligilla | 54d8b64 | 2018-07-06 17:35:26 -0700 | [diff] [blame] | 1629 | return QDF_STATUS_E_NOMEM; |
| 1630 | } |
| 1631 | |
| 1632 | /* |
| 1633 | * Copy the header(24byte), timestamp(8 byte), |
| 1634 | * beaconinterval(2byte) and capability(2byte) |
| 1635 | */ |
| 1636 | qdf_mem_copy(new_frame, frame, 36); |
| 1637 | /* Copy the new ie generated from MBSSID profile*/ |
Sandeep Puligilla | da4a452 | 2019-01-23 13:54:38 -0800 | [diff] [blame] | 1638 | hdr = (struct wlan_frame_hdr *)new_frame; |
| 1639 | qdf_mem_copy(hdr->i_addr2, new_bssid, |
| 1640 | QDF_MAC_ADDR_SIZE); |
| 1641 | qdf_mem_copy(hdr->i_addr3, new_bssid, |
| 1642 | QDF_MAC_ADDR_SIZE); |
| 1643 | /* Copy the new ie generated from MBSSID profile*/ |
Sandeep Puligilla | 54d8b64 | 2018-07-06 17:35:26 -0700 | [diff] [blame] | 1644 | qdf_mem_copy(new_frame + |
Sandeep Puligilla | da4a452 | 2019-01-23 13:54:38 -0800 | [diff] [blame] | 1645 | offsetof(struct wlan_bcn_frame, ie) + |
| 1646 | sizeof(struct wlan_frame_hdr), |
Sandeep Puligilla | 54d8b64 | 2018-07-06 17:35:26 -0700 | [diff] [blame] | 1647 | new_ie, new_ie_len); |
| 1648 | status = util_scan_gen_scan_entry(pdev, new_frame, |
| 1649 | new_frame_len, |
| 1650 | frm_subtype, |
Sandeep Puligilla | 949faf5 | 2019-02-15 10:32:00 -0800 | [diff] [blame] | 1651 | rx_param, |
| 1652 | &mbssid_info, |
| 1653 | scan_list); |
Sandeep Puligilla | 54d8b64 | 2018-07-06 17:35:26 -0700 | [diff] [blame] | 1654 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1655 | qdf_mem_free(new_frame); |
| 1656 | scm_err("failed to generate a scan entry"); |
| 1657 | break; |
| 1658 | } |
| 1659 | /* scan entry makes its own copy so free the frame*/ |
| 1660 | qdf_mem_free(new_frame); |
| 1661 | } |
| 1662 | |
| 1663 | pos = mbssid_end_pos; |
| 1664 | } |
| 1665 | qdf_mem_free(new_ie); |
| 1666 | |
| 1667 | return QDF_STATUS_SUCCESS; |
| 1668 | } |
| 1669 | #else |
| 1670 | static QDF_STATUS util_scan_parse_mbssid(struct wlan_objmgr_pdev *pdev, |
| 1671 | uint8_t *frame, qdf_size_t frame_len, |
| 1672 | uint32_t frm_subtype, |
| 1673 | struct mgmt_rx_event_params *rx_param, |
| 1674 | qdf_list_t *scan_list) |
| 1675 | { |
Sandeep Puligilla | da4a452 | 2019-01-23 13:54:38 -0800 | [diff] [blame] | 1676 | return QDF_STATUS_SUCCESS; |
Sandeep Puligilla | 54d8b64 | 2018-07-06 17:35:26 -0700 | [diff] [blame] | 1677 | } |
| 1678 | #endif |
| 1679 | |
| 1680 | static QDF_STATUS |
| 1681 | util_scan_parse_beacon_frame(struct wlan_objmgr_pdev *pdev, |
| 1682 | uint8_t *frame, |
| 1683 | qdf_size_t frame_len, |
| 1684 | uint32_t frm_subtype, |
| 1685 | struct mgmt_rx_event_params *rx_param, |
| 1686 | qdf_list_t *scan_list) |
| 1687 | { |
| 1688 | struct wlan_bcn_frame *bcn; |
Sandeep Puligilla | 949faf5 | 2019-02-15 10:32:00 -0800 | [diff] [blame] | 1689 | struct wlan_frame_hdr *hdr; |
| 1690 | uint8_t *mbssid_ie = NULL; |
Sandeep Puligilla | 54d8b64 | 2018-07-06 17:35:26 -0700 | [diff] [blame] | 1691 | uint32_t ie_len = 0; |
| 1692 | QDF_STATUS status; |
Sandeep Puligilla | 949faf5 | 2019-02-15 10:32:00 -0800 | [diff] [blame] | 1693 | struct scan_mbssid_info mbssid_info = { 0 }; |
Sandeep Puligilla | 54d8b64 | 2018-07-06 17:35:26 -0700 | [diff] [blame] | 1694 | |
Sandeep Puligilla | 949faf5 | 2019-02-15 10:32:00 -0800 | [diff] [blame] | 1695 | hdr = (struct wlan_frame_hdr *)frame; |
Sandeep Puligilla | 54d8b64 | 2018-07-06 17:35:26 -0700 | [diff] [blame] | 1696 | bcn = (struct wlan_bcn_frame *) |
| 1697 | (frame + sizeof(struct wlan_frame_hdr)); |
| 1698 | ie_len = (uint16_t)(frame_len - |
| 1699 | sizeof(struct wlan_frame_hdr) - |
| 1700 | offsetof(struct wlan_bcn_frame, ie)); |
| 1701 | |
Sandeep Puligilla | 949faf5 | 2019-02-15 10:32:00 -0800 | [diff] [blame] | 1702 | mbssid_ie = util_scan_find_ie(WLAN_ELEMID_MULTIPLE_BSSID, |
| 1703 | (uint8_t *)&bcn->ie, ie_len); |
| 1704 | if (mbssid_ie) { |
| 1705 | qdf_mem_copy(&mbssid_info.trans_bssid, |
| 1706 | hdr->i_addr3, QDF_MAC_ADDR_SIZE); |
| 1707 | mbssid_info.profile_count = 1 << mbssid_ie[2]; |
| 1708 | } |
| 1709 | |
Sandeep Puligilla | da4a452 | 2019-01-23 13:54:38 -0800 | [diff] [blame] | 1710 | status = util_scan_gen_scan_entry(pdev, frame, frame_len, |
| 1711 | frm_subtype, rx_param, |
Sandeep Puligilla | 949faf5 | 2019-02-15 10:32:00 -0800 | [diff] [blame] | 1712 | &mbssid_info, |
Sandeep Puligilla | da4a452 | 2019-01-23 13:54:38 -0800 | [diff] [blame] | 1713 | scan_list); |
| 1714 | |
Sandeep Puligilla | 54d8b64 | 2018-07-06 17:35:26 -0700 | [diff] [blame] | 1715 | /* |
| 1716 | * IF MBSSID IE is present in the beacon then |
| 1717 | * scan component will create a new entry for |
| 1718 | * each BSSID found in the MBSSID |
| 1719 | */ |
Sandeep Puligilla | 949faf5 | 2019-02-15 10:32:00 -0800 | [diff] [blame] | 1720 | if (mbssid_ie) |
Om Prakash Tripathi | c341ca7 | 2018-08-14 15:41:34 +0530 | [diff] [blame] | 1721 | status = util_scan_parse_mbssid(pdev, frame, frame_len, |
| 1722 | frm_subtype, rx_param, |
| 1723 | scan_list); |
Sandeep Puligilla | da4a452 | 2019-01-23 13:54:38 -0800 | [diff] [blame] | 1724 | |
Om Prakash Tripathi | 0e3c541 | 2019-04-08 15:01:34 +0530 | [diff] [blame] | 1725 | if (QDF_IS_STATUS_ERROR(status)) |
| 1726 | scm_debug_rl("Failed to create a scan entry"); |
Sandeep Puligilla | 54d8b64 | 2018-07-06 17:35:26 -0700 | [diff] [blame] | 1727 | |
| 1728 | return status; |
| 1729 | } |
| 1730 | |
| 1731 | qdf_list_t * |
| 1732 | util_scan_unpack_beacon_frame(struct wlan_objmgr_pdev *pdev, uint8_t *frame, |
| 1733 | qdf_size_t frame_len, uint32_t frm_subtype, |
| 1734 | struct mgmt_rx_event_params *rx_param) |
| 1735 | { |
| 1736 | qdf_list_t *scan_list; |
| 1737 | QDF_STATUS status; |
| 1738 | |
| 1739 | scan_list = qdf_mem_malloc_atomic(sizeof(*scan_list)); |
| 1740 | if (!scan_list) { |
| 1741 | scm_err("failed to allocate scan_list"); |
| 1742 | return NULL; |
| 1743 | } |
| 1744 | qdf_list_create(scan_list, MAX_SCAN_CACHE_SIZE); |
| 1745 | |
| 1746 | status = util_scan_parse_beacon_frame(pdev, frame, frame_len, |
| 1747 | frm_subtype, rx_param, |
| 1748 | scan_list); |
| 1749 | if (QDF_IS_STATUS_ERROR(status)) { |
Om Prakash Tripathi | c341ca7 | 2018-08-14 15:41:34 +0530 | [diff] [blame] | 1750 | ucfg_scan_purge_results(scan_list); |
Sandeep Puligilla | 54d8b64 | 2018-07-06 17:35:26 -0700 | [diff] [blame] | 1751 | return NULL; |
| 1752 | } |
| 1753 | |
Sandeep Puligilla | c676459 | 2017-12-05 21:01:52 -0800 | [diff] [blame] | 1754 | return scan_list; |
Abhishek Singh | 4caf1a9 | 2017-02-21 15:01:08 +0530 | [diff] [blame] | 1755 | } |
Om Prakash Tripathi | c3fcb68 | 2017-08-01 18:24:55 +0530 | [diff] [blame] | 1756 | |
| 1757 | QDF_STATUS |
| 1758 | util_scan_entry_update_mlme_info(struct wlan_objmgr_pdev *pdev, |
| 1759 | struct scan_cache_entry *scan_entry) |
| 1760 | { |
| 1761 | |
| 1762 | if (!pdev || !scan_entry) { |
Jeff Johnson | 878533e | 2017-09-18 10:07:54 -0700 | [diff] [blame] | 1763 | 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] | 1764 | return QDF_STATUS_E_INVAL; |
| 1765 | } |
| 1766 | |
| 1767 | return scm_update_scan_mlme_info(pdev, scan_entry); |
| 1768 | } |
Sandeep Puligilla | f57464c | 2017-11-16 23:31:52 -0800 | [diff] [blame] | 1769 | |
| 1770 | bool util_is_scan_completed(struct scan_event *event, bool *success) |
| 1771 | { |
| 1772 | if ((event->type == SCAN_EVENT_TYPE_COMPLETED) || |
| 1773 | (event->type == SCAN_EVENT_TYPE_DEQUEUED) || |
| 1774 | (event->type == SCAN_EVENT_TYPE_START_FAILED)) { |
| 1775 | if ((event->type == SCAN_EVENT_TYPE_COMPLETED) && |
| 1776 | (event->reason == SCAN_REASON_COMPLETED)) |
| 1777 | *success = true; |
| 1778 | else |
| 1779 | *success = false; |
| 1780 | |
| 1781 | return true; |
| 1782 | } |
| 1783 | |
| 1784 | *success = false; |
| 1785 | return false; |
| 1786 | } |
| 1787 | |