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