blob: 7dcee980bb7e48513a1059dba1c6ee55feef832e [file] [log] [blame]
Om Prakash Tripathi7e3f45d2016-12-28 16:58:54 +05301/*
2 * Copyright (c) 2017 The Linux Foundation. All rights reserved.
3 *
4 * Permission to use, copy, modify, and/or distribute this software for
5 * any purpose with or without fee is hereby granted, provided that the
6 * above copyright notice and this permission notice appear in all
7 * copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 * PERFORMANCE OF THIS SOFTWARE.
17 */
18
19/*
20 * DOC: Defines scan utility functions
21 */
Om Prakash Tripathi22f95dc2016-12-19 10:45:59 +053022
Abhishek Singh4caf1a92017-02-21 15:01:08 +053023#include <wlan_cmn.h>
Om Prakash Tripathi22f95dc2016-12-19 10:45:59 +053024#include <wlan_scan_ucfg_api.h>
25#include <wlan_scan_utils_api.h>
26#include <../../core/src/wlan_scan_cache_db.h>
27#include <../../core/src/wlan_scan_main.h>
28
29const char*
30util_scan_get_ev_type_name(enum scan_event_type type)
31{
32 static const char * const event_name[] = {
33 [SCAN_EVENT_TYPE_STARTED] = "STARTED",
34 [SCAN_EVENT_TYPE_COMPLETED] = "COMPLETED",
35 [SCAN_EVENT_TYPE_BSS_CHANNEL] = "HOME_CHANNEL",
36 [SCAN_EVENT_TYPE_FOREIGN_CHANNEL] = "FOREIGN_CHANNEL",
37 [SCAN_EVENT_TYPE_DEQUEUED] = "DEQUEUED",
38 [SCAN_EVENT_TYPE_PREEMPTED] = "PREEMPTED",
39 [SCAN_EVENT_TYPE_START_FAILED] = "START_FAILED",
40 [SCAN_EVENT_TYPE_RESTARTED] = "RESTARTED",
41 [SCAN_EVENT_TYPE_FOREIGN_CHANNEL_EXIT] = "FOREIGN_CHANNEL_EXIT",
42 [SCAN_EVENT_TYPE_SUSPENDED] = "SUSPENDED",
43 [SCAN_EVENT_TYPE_RESUMED] = "RESUMED",
44 [SCAN_EVENT_TYPE_NLO_COMPLETE] = "NLO_COMPLETE",
45 [SCAN_EVENT_TYPE_INVALID] = "INVALID",
46 [SCAN_EVENT_TYPE_GPIO_TIMEOUT] = "GPIO_TIMEOUT",
47 [SCAN_EVENT_TYPE_RADIO_MEASUREMENT_START] =
48 "RADIO_MEASUREMENT_START",
49 [SCAN_EVENT_TYPE_RADIO_MEASUREMENT_END] =
50 "RADIO_MEASUREMENT_END",
51 [SCAN_EVENT_TYPE_BSSID_MATCH] = "BSSID_MATCH",
52 [SCAN_EVENT_TYPE_FOREIGN_CHANNEL_GET_NF] =
53 "FOREIGN_CHANNEL_GET_NF",
54 };
55
56 if (type >= SCAN_EVENT_TYPE_MAX) {
57 scm_err("unknown type : %d", type);
58 QDF_ASSERT(0);
59 return "UNKNOWN";
60 }
61
62 return event_name[type];
63}
64
65
66const char*
67util_scan_get_ev_reason_name(enum scan_completion_reason reason)
68{
69 static const char * const reason_name[] = {
70 [SCAN_REASON_NONE] = "NONE",
71 [SCAN_REASON_COMPLETED] = "COMPLETED",
72 [SCAN_REASON_CANCELLED] = "CANCELLED",
73 [SCAN_REASON_PREEMPTED] = "PREEMPTED",
74 [SCAN_REASON_TIMEDOUT] = "TIMEDOUT",
75 [SCAN_REASON_INTERNAL_FAILURE] = "INTERNAL_FAILURE",
76 [SCAN_REASON_SUSPENDED] = "SUSPENDED",
77 [SCAN_REASON_RUN_FAILED] = "RUN_FAILED",
78 [SCAN_REASON_TERMINATION_FUNCTION] = "TERMINATION_FUNCTION",
79 [SCAN_REASON_MAX_OFFCHAN_RETRIES] = "MAX_OFFCHAN_RETRIES",
80 };
81
82 if (reason >= SCAN_REASON_MAX) {
83 scm_err("unknown reason : %d", reason);
84 QDF_ASSERT(0);
85 return "UNKNOWN";
86 }
87
88 return reason_name[reason];
89}
90
91qdf_time_t
92util_get_last_scan_time(struct wlan_objmgr_vdev *vdev)
93{
94 uint8_t pdev_id;
95 struct wlan_scan_obj *scan_obj;
96
97 if (!vdev) {
98 scm_warn("null vdev");
99 QDF_ASSERT(0);
100 return 0;
101 }
102 pdev_id = wlan_scan_vdev_get_pdev_id(vdev);
103 scan_obj = wlan_vdev_get_scan_obj(vdev);
104
105 return scan_obj->pdev_info[pdev_id].last_scan_time;
106}
Abhishek Singh4caf1a92017-02-21 15:01:08 +0530107
108static enum wlan_band scm_chan_to_band(uint32_t chan)
109{
110 if (WLAN_CHAN_IS_2GHZ(chan))
111 return WLAN_BAND_2_4_GHZ;
112
113 return WLAN_BAND_5_GHZ;
114}
115
116static bool util_is_pureg_rate(uint8_t *rates, uint8_t nrates)
117{
118 static const uint8_t g_rates[] = {12, 18, 24, 36, 48, 72, 96, 108};
119 bool pureg = false;
120 uint8_t i, j;
121
122 for (i = 0; i < nrates; i++) {
123 for (j = 0; j < QDF_ARRAY_SIZE(g_rates); j++) {
124 if (WLAN_RV(rates[i]) == g_rates[j]) {
125 pureg = true;
126 break;
127 }
128 }
129 if (pureg)
130 break;
131 }
132
133 return pureg;
134}
135static enum wlan_phymode
136util_scan_get_phymode_5g(struct scan_cache_entry *scan_params)
137{
138 enum wlan_phymode phymode = WLAN_PHYMODE_AUTO;
139 uint16_t ht_cap = 0;
140 struct htcap_cmn_ie *htcap;
141 struct wlan_ie_htinfo_cmn *htinfo;
142 struct wlan_ie_vhtop *vhtop;
143
144 htcap = (struct htcap_cmn_ie *)
145 util_scan_entry_htcap(scan_params);
146 htinfo = (struct wlan_ie_htinfo_cmn *)
147 util_scan_entry_htinfo(scan_params);
148 vhtop = (struct wlan_ie_vhtop *)
149 util_scan_entry_vhtop(scan_params);
150
151 if (!(htcap && htinfo))
152 return WLAN_PHYMODE_11A;
153
154 if (htcap)
155 ht_cap = le16toh(htcap->hc_cap);
156
157 if (util_scan_entry_vhtcap(scan_params) && vhtop) {
158 switch (vhtop->vht_op_chwidth) {
159 case WLAN_VHTOP_CHWIDTH_2040:
160 if ((ht_cap & WLAN_HTCAP_C_CHWIDTH40) &&
161 (htinfo->hi_extchoff ==
162 WLAN_HTINFO_EXTOFFSET_ABOVE))
163 phymode = WLAN_PHYMODE_11AC_VHT40PLUS;
164 else if ((ht_cap & WLAN_HTCAP_C_CHWIDTH40) &&
165 (htinfo->hi_extchoff ==
166 WLAN_HTINFO_EXTOFFSET_BELOW))
167 phymode = WLAN_PHYMODE_11AC_VHT40MINUS;
168 else
169 phymode = WLAN_PHYMODE_11AC_VHT20;
170 break;
171 case WLAN_VHTOP_CHWIDTH_80:
172 if (WLAN_IS_REVSIG_VHT80_80(vhtop))
173 phymode = WLAN_PHYMODE_11AC_VHT80_80;
174 else if (WLAN_IS_REVSIG_VHT160(vhtop))
175 phymode = WLAN_PHYMODE_11AC_VHT160;
176 else
177 phymode = WLAN_PHYMODE_11AC_VHT80;
178 break;
179 case WLAN_VHTOP_CHWIDTH_160:
180 phymode = WLAN_PHYMODE_11AC_VHT160;
181 break;
182 case WLAN_VHTOP_CHWIDTH_80_80:
183 phymode = WLAN_PHYMODE_11AC_VHT80_80;
184 break;
185 default:
186 scm_err("bad channel: %d",
187 vhtop->vht_op_chwidth);
188 break;
189 }
190 } else if ((ht_cap & WLAN_HTCAP_C_CHWIDTH40) &&
191 (htinfo->hi_extchoff == WLAN_HTINFO_EXTOFFSET_ABOVE))
192 phymode = WLAN_PHYMODE_11NA_HT40PLUS;
193 else if ((ht_cap & WLAN_HTCAP_C_CHWIDTH40) &&
194 (htinfo->hi_extchoff == WLAN_HTINFO_EXTOFFSET_BELOW))
195 phymode = WLAN_PHYMODE_11NA_HT40MINUS;
196 else
197 phymode = WLAN_PHYMODE_11NA_HT20;
198
199 return phymode;
200}
201
202static enum wlan_phymode
203util_scan_get_phymode_2g(struct scan_cache_entry *scan_params)
204{
205 enum wlan_phymode phymode = WLAN_PHYMODE_AUTO;
206 uint16_t ht_cap = 0;
207 struct htcap_cmn_ie *htcap;
208 struct wlan_ie_htinfo_cmn *htinfo;
209 struct wlan_ie_vhtop *vhtop;
210
211 htcap = (struct htcap_cmn_ie *)
212 util_scan_entry_htcap(scan_params);
213 htinfo = (struct wlan_ie_htinfo_cmn *)
214 util_scan_entry_htinfo(scan_params);
215 vhtop = (struct wlan_ie_vhtop *)
216 util_scan_entry_vhtop(scan_params);
217
218 if (htcap)
219 ht_cap = le16toh(htcap->hc_cap);
220
221 if (htcap && htinfo) {
222 if ((ht_cap & WLAN_HTCAP_C_CHWIDTH40) &&
223 (htinfo->hi_extchoff == WLAN_HTINFO_EXTOFFSET_ABOVE))
224 phymode = WLAN_PHYMODE_11NG_HT40PLUS;
225 else if ((ht_cap & WLAN_HTCAP_C_CHWIDTH40) &&
226 (htinfo->hi_extchoff == WLAN_HTINFO_EXTOFFSET_BELOW))
227 phymode = WLAN_PHYMODE_11NG_HT40MINUS;
228 else
229 phymode = WLAN_PHYMODE_11NG_HT20;
230 } else if (util_scan_entry_xrates(scan_params)) {
231 /* only 11G stations will have more than 8 rates */
232 phymode = WLAN_PHYMODE_11G;
233 } else {
234 /* Some mischievous g-only APs do not set extended rates */
235 if (util_scan_entry_rates(scan_params)) {
236 if (util_is_pureg_rate(&scan_params->ie_list.rates[2],
237 scan_params->ie_list.rates[1]))
238 phymode = WLAN_PHYMODE_11G;
239 else
240 phymode = WLAN_PHYMODE_11B;
241 } else {
242 phymode = WLAN_PHYMODE_11B;
243 }
244 }
245
246 return phymode;
247}
248
249static QDF_STATUS
250util_scan_parse_chan_switch_wrapper_ie(struct scan_cache_entry *scan_params,
251 struct ie_header *sub_ie, qdf_size_t sub_ie_len)
252{
253 /* Walk through to check nothing is malformed */
254 while (sub_ie_len >= sizeof(struct ie_header)) {
255 /* At least one more header is present */
256 sub_ie_len -= sizeof(struct ie_header);
257
258 if (sub_ie->ie_len == 0) {
259 sub_ie += 1;
260 continue;
261 }
262 if (sub_ie_len < sub_ie->ie_len) {
263 scm_err("Incomplete corrupted IE:%x",
264 WLAN_ELEMID_CHAN_SWITCH_WRAP);
265 return QDF_STATUS_E_INVAL;
266 }
267 switch (sub_ie->ie_id) {
268 case WLAN_ELEMID_COUNTRY:
269 scan_params->ie_list.country = (uint8_t *)sub_ie;
270 break;
271 case WLAN_ELEMID_WIDE_BAND_CHAN_SWITCH:
272 scan_params->ie_list.widebw = (uint8_t *)sub_ie;
273 break;
274 case WLAN_ELEMID_VHT_TX_PWR_ENVLP:
275 scan_params->ie_list.txpwrenvlp = (uint8_t *)sub_ie;
276 break;
277 }
278 /* Consume sub info element */
279 sub_ie_len -= sub_ie->ie_len;
280 /* go to next Sub IE */
281 sub_ie = (struct ie_header *)
282 (((uint8_t *) sub_ie) +
283 sizeof(struct ie_header) + sub_ie->ie_len);
284 }
285
286 return QDF_STATUS_SUCCESS;
287}
288
289static bool
290util_scan_is_hidden_ssid(struct ie_ssid *ssid)
291{
292 uint8_t i;
293
294 /*
295 * We flag this as Hidden SSID if the Length is 0
296 * of the SSID only contains 0's
297 */
298 if (!ssid || !ssid->ssid_len)
299 return true;
300
301 for (i = 0; i < ssid->ssid_len; i++)
302 if (ssid->ssid[i] != 0)
303 return false;
304
305 /* All 0's */
306 return true;
307}
308
309static void
310util_scan_parse_vendor_ie(struct scan_cache_entry *scan_params,
311 struct ie_header *ie)
312{
313
314 if (scan_params->ie_list.vendor == NULL)
315 scan_params->ie_list.vendor = (uint8_t *)ie;
316
317 if (is_wpa_oui((uint8_t *)ie)) {
318 scan_params->ie_list.wpa = (uint8_t *)ie;
319 } else if (is_wps_oui((uint8_t *)ie)) {
320 scan_params->ie_list.wps = (uint8_t *)ie;
321 /* WCN IE should be a subset of WPS IE */
322 if (is_wcn_oui((uint8_t *)ie))
323 scan_params->ie_list.wcn = (uint8_t *)ie;
324 } else if (is_wme_param((uint8_t *)ie)) {
325 scan_params->ie_list.wmeparam = (uint8_t *)ie;
326 } else if (is_wme_info((uint8_t *)ie)) {
327 scan_params->ie_list.wmeinfo = (uint8_t *)ie;
328 } else if (is_atheros_oui((uint8_t *)ie)) {
329 scan_params->ie_list.athcaps = (uint8_t *)ie;
330 } else if (is_atheros_extcap_oui((uint8_t *)ie)) {
331 scan_params->ie_list.athextcaps = (uint8_t *)ie;
332 } else if (is_sfa_oui((uint8_t *)ie)) {
333 scan_params->ie_list.sfa = (uint8_t *)ie;
334 } else if (is_p2p_oui((uint8_t *)ie)) {
335 scan_params->ie_list.p2p = (uint8_t *)ie;
336 } else if (is_qca_whc_oui((uint8_t *)ie,
337 QCA_OUI_WHC_AP_INFO_SUBTYPE)) {
338 scan_params->ie_list.sonadv = (uint8_t *)ie;
339 } else if (is_ht_cap((uint8_t *)ie)) {
340 /* we only care if there isn't already an HT IE (ANA) */
341 if (scan_params->ie_list.htcap == NULL)
342 scan_params->ie_list.htcap =
343 (uint8_t *)&(((struct wlan_vendor_ie_htcap *)ie)->ie);
344 } else if (is_ht_info((uint8_t *)ie)) {
345 /* we only care if there isn't already an HT IE (ANA) */
346 if (scan_params->ie_list.htinfo == NULL)
347 scan_params->ie_list.htinfo =
348 (uint8_t *)&(((struct wlan_vendor_ie_htinfo *)
349 ie)->hi_ie);
350 } else if (is_interop_vht((uint8_t *)ie) &&
351 !(scan_params->ie_list.vhtop)) {
352 /* location where Interop Vht Cap IE and VHT OP IE Present */
353 scan_params->ie_list.vhtcap = (((uint8_t *)(ie)) + 7);
354 scan_params->ie_list.vhtop = (((uint8_t *)(ie)) + 21);
355 } else if (is_bwnss_oui((uint8_t *)ie)) {
356 /*
357 * Bandwidth-NSS map has sub-type & version.
358 * hence copy data just after version byte
359 */
360 scan_params->ie_list.bwnss_map = (((uint8_t *)ie) + 8);
361 }
362}
363
364static QDF_STATUS
365util_scan_populate_bcn_ie_list(struct scan_cache_entry *scan_params)
366{
367 struct ie_header *ie, *sub_ie;
368 uint32_t ie_len, sub_ie_len;
369 QDF_STATUS status;
370
371 ie_len = util_scan_entry_ie_len(scan_params);
372 ie = (struct ie_header *)
373 util_scan_entry_ie_data(scan_params);
374
375 while (ie_len >= sizeof(struct ie_header)) {
376 ie_len -= sizeof(struct ie_header);
377
378 if (!ie->ie_len) {
379 ie += 1;
380 continue;
381 }
382
383 if (ie_len < ie->ie_len) {
384 scm_err("Incomplete corrupted IE:%x",
385 ie->ie_id);
386 return QDF_STATUS_E_INVAL;
387 }
388
389 switch (ie->ie_id) {
390 case WLAN_ELEMID_SSID:
391 scan_params->ie_list.ssid = (uint8_t *)ie;
392 break;
393 case WLAN_ELEMID_RATES:
394 scan_params->ie_list.rates = (uint8_t *)ie;
395 break;
396 case WLAN_ELEMID_DSPARMS:
397 scan_params->channel.chan_idx =
398 ((struct ds_ie *)ie)->cur_chan;
399 break;
400 case WLAN_ELEMID_TIM:
401 scan_params->ie_list.tim = (uint8_t *)ie;
402 scan_params->dtim_period =
403 ((struct wlan_tim_ie *)ie)->tim_period;
404 break;
405 case WLAN_ELEMID_COUNTRY:
406 scan_params->ie_list.country = (uint8_t *)ie;
407 break;
408 case WLAN_ELEMID_QBSS_LOAD:
409 scan_params->ie_list.qbssload = (uint8_t *)ie;
410 break;
411 case WLAN_ELEMID_CHANSWITCHANN:
412 scan_params->ie_list.csa = (uint8_t *)ie;
413 break;
414 case WLAN_ELEMID_IBSSDFS:
415 scan_params->ie_list.ibssdfs = (uint8_t *)ie;
416 break;
417 case WLAN_ELEMID_QUIET:
418 scan_params->ie_list.quiet = (uint8_t *)ie;
419 break;
420 case WLAN_ELEMID_ERP:
421 scan_params->erp = ((struct erp_ie *)ie)->value;
422 break;
423 case WLAN_ELEMID_HTCAP_ANA:
424 scan_params->ie_list.htcap =
425 (uint8_t *)&(((struct htcap_ie *)ie)->ie);
426 break;
427 case WLAN_ELEMID_RSN:
428 scan_params->ie_list.rsn = (uint8_t *)ie;
429 break;
430 case WLAN_ELEMID_XRATES:
431 scan_params->ie_list.xrates = (uint8_t *)ie;
432 break;
433 case WLAN_ELEMID_EXTCHANSWITCHANN:
434 scan_params->ie_list.xcsa = (uint8_t *)ie;
435 break;
436 case WLAN_ELEMID_SECCHANOFFSET:
437 scan_params->ie_list.secchanoff = (uint8_t *)ie;
438 break;
439 case WLAN_ELEMID_HTINFO_ANA:
440 scan_params->ie_list.htinfo =
441 (uint8_t *)&(((struct wlan_ie_htinfo *) ie)->hi_ie);
442 scan_params->channel.chan_idx =
443 ((struct wlan_ie_htinfo_cmn *)
444 (scan_params->ie_list.htinfo))->hi_ctrlchannel;
445 break;
446 case WLAN_ELEMID_WAPI:
447 scan_params->ie_list.wapi = (uint8_t *)ie;
448 break;
449 case WLAN_ELEMID_XCAPS:
450 scan_params->ie_list.extcaps = (uint8_t *)ie;
451 break;
452 case WLAN_ELEMID_VHTCAP:
453 scan_params->ie_list.vhtcap = (uint8_t *)ie;
454 break;
455 case WLAN_ELEMID_VHTOP:
456 scan_params->ie_list.vhtop = (uint8_t *)ie;
457 break;
458 case WLAN_ELEMID_OP_MODE_NOTIFY:
459 scan_params->ie_list.opmode = (uint8_t *)ie;
460 break;
461 case WLAN_ELEMID_MOBILITY_DOMAIN:
462 scan_params->ie_list.mdie = (uint8_t *)ie;
463 break;
464 case WLAN_ELEMID_VENDOR:
465 util_scan_parse_vendor_ie(scan_params,
466 ie);
467 break;
468 case WLAN_ELEMID_CHAN_SWITCH_WRAP:
469 scan_params->ie_list.cswrp = (uint8_t *)ie;
470 /* Go to next sub IE */
471 sub_ie = (struct ie_header *)
472 (((uint8_t *)ie) + sizeof(struct ie_header));
473 sub_ie_len = ie->ie_len;
474 status =
475 util_scan_parse_chan_switch_wrapper_ie(
476 scan_params, sub_ie, sub_ie_len);
477 if (QDF_IS_STATUS_ERROR(status)) {
478 scm_err("failed to parse chan_switch_wrapper_ie");
479 return status;
480 }
481 break;
482 default:
483 break;
484 }
485
486 /* Consume info element */
487 ie_len -= ie->ie_len;
488 /* Go to next IE */
489 ie = (struct ie_header *)
490 (((uint8_t *) ie) +
491 sizeof(struct ie_header) +
492 ie->ie_len);
493 }
494
495 return QDF_STATUS_SUCCESS;
496}
497
498struct scan_cache_entry *
499util_scan_unpack_beacon_frame(uint8_t *frame,
500 qdf_size_t frame_len, uint32_t frm_subtype,
501 struct mgmt_rx_event_params *rx_param)
502{
503 struct wlan_frame_hdr *hdr;
504 struct wlan_bcn_frame *bcn;
505 QDF_STATUS status;
506 struct ie_ssid *ssid;
507 struct scan_cache_entry *scan_entry = NULL;
508
509 scan_entry = qdf_mem_malloc(sizeof(*scan_entry));
510 if (!scan_entry) {
511 scm_err("failed to allocate memory for scan_entry");
512 return NULL;
513 }
514 scan_entry->raw_frame.ptr =
515 qdf_mem_malloc(frame_len);
516 if (!scan_entry->raw_frame.ptr) {
517 scm_err("failed to allocate memory for frame");
518 qdf_mem_free(scan_entry);
519 return NULL;
520 }
521
522 bcn = (struct wlan_bcn_frame *)
523 (frame + sizeof(*hdr));
524 hdr = (struct wlan_frame_hdr *)frame;
525
526 scan_entry->frm_subtype = frm_subtype;
527 qdf_mem_copy(scan_entry->bssid.bytes,
528 hdr->i_addr3, QDF_MAC_ADDR_SIZE);
529 /* Scr addr */
530 qdf_mem_copy(scan_entry->mac_addr.bytes,
531 hdr->i_addr2, QDF_MAC_ADDR_SIZE);
532 scan_entry->seq_num =
533 (le16toh(*(uint16_t *)hdr->i_seq) >> WLAN_SEQ_SEQ_SHIFT);
534
535 scan_entry->rssi_raw = rx_param->rssi;
536 scan_entry->tsf_delta = rx_param->tsf_delta;
537
538 /* store jiffies */
539 scan_entry->rrm_parent_tsf = (u_int32_t) qdf_system_ticks();
540
541 scan_entry->bcn_int = le16toh(bcn->beacon_interval);
542
543 /*
544 * In case if the beacon dosnt have
545 * valid beacon interval falback to def
546 */
547 if (!scan_entry->bcn_int)
548 scan_entry->bcn_int = 100;
549 scan_entry->cap_info.value = le16toh(bcn->capability.value);
550 qdf_mem_copy(scan_entry->tsf_info.data,
551 bcn->timestamp, 8);
552 scan_entry->erp = ERP_NON_ERP_PRESENT;
553
554
555 scan_entry->rssi_timestamp =
556 scan_entry->scan_entry_time =
557 qdf_mc_timer_get_system_time();
558
559 scan_entry->raw_frame.len = frame_len;
560 qdf_mem_copy(scan_entry->raw_frame.ptr,
561 frame, frame_len);
562 status = util_scan_populate_bcn_ie_list(scan_entry);
563 if (QDF_IS_STATUS_ERROR(status)) {
564 scm_err("failed to parse beacon IE");
565 qdf_mem_free(scan_entry->raw_frame.ptr);
566 qdf_mem_free(scan_entry);
567 return NULL;
568 }
569
570 if (!scan_entry->ie_list.rates) {
571 qdf_mem_free(scan_entry->raw_frame.ptr);
572 qdf_mem_free(scan_entry);
573 return NULL;
574 }
575
576 ssid = (struct ie_ssid *)
577 scan_entry->ie_list.ssid;
578
579 if (ssid && (ssid->ssid_len > WLAN_SSID_MAX_LEN)) {
580 qdf_mem_free(scan_entry->raw_frame.ptr);
581 qdf_mem_free(scan_entry);
582 return NULL;
583 }
584
585 if (scan_entry->ie_list.p2p)
586 scan_entry->is_p2p = true;
587
588 /* If no channel info is present in beacon use meta channel */
589 if (!scan_entry->channel.chan_idx) {
590 scan_entry->channel.chan_idx =
591 rx_param->channel;
592 } else if (rx_param->channel !=
593 scan_entry->channel.chan_idx) {
594 scan_entry->channel_mismatch = true;
595 }
596
597 if (util_scan_is_hidden_ssid(ssid)) {
598 scan_entry->ie_list.ssid = NULL;
599 } else {
600 qdf_mem_copy(scan_entry->ssid.ssid,
601 ssid->ssid, WLAN_SSID_MAX_LEN);
602 scan_entry->ssid.length = ssid->ssid_len;
603 scan_entry->hidden_ssid_timestamp =
604 scan_entry->scan_entry_time;
605 }
606
607 if (WLAN_CHAN_IS_5GHZ(scan_entry->channel.chan_idx))
608 scan_entry->phy_mode = util_scan_get_phymode_5g(scan_entry);
609 else
610 scan_entry->phy_mode = util_scan_get_phymode_2g(scan_entry);
611
612 /* TODO calculate channel struct */
613 return scan_entry;
614}