2 * Marvell Wireless LAN device driver: scan ioctl and command handling
4 * Copyright (C) 2011-2014, Marvell International Ltd.
6 * This software file (the "File") is distributed by Marvell International
7 * Ltd. under the terms of the GNU General Public License Version 2, June 1991
8 * (the "License"). You may use, redistribute and/or modify this File in
9 * accordance with the terms and conditions of the License, a copy of which
10 * is available by writing to the Free Software Foundation, Inc.,
11 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
12 * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
14 * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
16 * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
17 * this warranty disclaimer.
28 /* The maximum number of channels the firmware can scan per command */
29 #define MWIFIEX_MAX_CHANNELS_PER_SPECIFIC_SCAN 14
31 #define MWIFIEX_DEF_CHANNELS_PER_SCAN_CMD 4
33 /* Memory needed to store a max sized Channel List TLV for a firmware scan */
34 #define CHAN_TLV_MAX_SIZE (sizeof(struct mwifiex_ie_types_header) \
35 + (MWIFIEX_MAX_CHANNELS_PER_SPECIFIC_SCAN \
36 *sizeof(struct mwifiex_chan_scan_param_set)))
38 /* Memory needed to store supported rate */
39 #define RATE_TLV_MAX_SIZE (sizeof(struct mwifiex_ie_types_rates_param_set) \
40 + HOSTCMD_SUPPORTED_RATES)
42 /* Memory needed to store a max number/size WildCard SSID TLV for a firmware
44 #define WILDCARD_SSID_TLV_MAX_SIZE \
45 (MWIFIEX_MAX_SSID_LIST_LENGTH * \
46 (sizeof(struct mwifiex_ie_types_wildcard_ssid_params) \
47 + IEEE80211_MAX_SSID_LEN))
49 /* Maximum memory needed for a mwifiex_scan_cmd_config with all TLVs at max */
50 #define MAX_SCAN_CFG_ALLOC (sizeof(struct mwifiex_scan_cmd_config) \
51 + sizeof(struct mwifiex_ie_types_num_probes) \
52 + sizeof(struct mwifiex_ie_types_htcap) \
55 + WILDCARD_SSID_TLV_MAX_SIZE)
58 union mwifiex_scan_cmd_config_tlv {
59 /* Scan configuration (variable length) */
60 struct mwifiex_scan_cmd_config config;
61 /* Max allocated block */
62 u8 config_alloc_buf[MAX_SCAN_CFG_ALLOC];
70 static u8 mwifiex_wpa_oui[CIPHER_SUITE_MAX][4] = {
71 { 0x00, 0x50, 0xf2, 0x02 }, /* TKIP */
72 { 0x00, 0x50, 0xf2, 0x04 }, /* AES */
74 static u8 mwifiex_rsn_oui[CIPHER_SUITE_MAX][4] = {
75 { 0x00, 0x0f, 0xac, 0x02 }, /* TKIP */
76 { 0x00, 0x0f, 0xac, 0x04 }, /* AES */
80 _dbg_security_flags(int log_level, const char *func, const char *desc,
81 struct mwifiex_private *priv,
82 struct mwifiex_bssdescriptor *bss_desc)
84 _mwifiex_dbg(priv->adapter, log_level,
85 "info: %s: %s:\twpa_ie=%#x wpa2_ie=%#x WEP=%s WPA=%s WPA2=%s\tEncMode=%#x privacy=%#x\n",
87 bss_desc->bcn_wpa_ie ?
88 bss_desc->bcn_wpa_ie->vend_hdr.element_id : 0,
89 bss_desc->bcn_rsn_ie ?
90 bss_desc->bcn_rsn_ie->ieee_hdr.element_id : 0,
91 priv->sec_info.wep_enabled ? "e" : "d",
92 priv->sec_info.wpa_enabled ? "e" : "d",
93 priv->sec_info.wpa2_enabled ? "e" : "d",
94 priv->sec_info.encryption_mode,
97 #define dbg_security_flags(mask, desc, priv, bss_desc) \
98 _dbg_security_flags(MWIFIEX_DBG_##mask, desc, __func__, priv, bss_desc)
101 has_ieee_hdr(struct ieee_types_generic *ie, u8 key)
103 return (ie && ie->ieee_hdr.element_id == key);
107 has_vendor_hdr(struct ieee_types_vendor_specific *ie, u8 key)
109 return (ie && ie->vend_hdr.element_id == key);
113 * This function parses a given IE for a given OUI.
115 * This is used to parse a WPA/RSN IE to find if it has
116 * a given oui in PTK.
119 mwifiex_search_oui_in_ie(struct ie_body *iebody, u8 *oui)
123 count = iebody->ptk_cnt[0];
125 /* There could be multiple OUIs for PTK hence
127 2) Check all the OUIs for AES.
128 3) If one of them is AES then pass success. */
130 if (!memcmp(iebody->ptk_body, oui, sizeof(iebody->ptk_body)))
131 return MWIFIEX_OUI_PRESENT;
135 iebody = (struct ie_body *) ((u8 *) iebody +
136 sizeof(iebody->ptk_body));
139 pr_debug("info: %s: OUI is not found in PTK\n", __func__);
140 return MWIFIEX_OUI_NOT_PRESENT;
144 * This function checks if a given OUI is present in a RSN IE.
146 * The function first checks if a RSN IE is present or not in the
147 * BSS descriptor. It tries to locate the OUI only if such an IE is
151 mwifiex_is_rsn_oui_present(struct mwifiex_bssdescriptor *bss_desc, u32 cipher)
154 struct ie_body *iebody;
155 u8 ret = MWIFIEX_OUI_NOT_PRESENT;
157 if (has_ieee_hdr(bss_desc->bcn_rsn_ie, WLAN_EID_RSN)) {
158 iebody = (struct ie_body *)
159 (((u8 *) bss_desc->bcn_rsn_ie->data) +
161 oui = &mwifiex_rsn_oui[cipher][0];
162 ret = mwifiex_search_oui_in_ie(iebody, oui);
170 * This function checks if a given OUI is present in a WPA IE.
172 * The function first checks if a WPA IE is present or not in the
173 * BSS descriptor. It tries to locate the OUI only if such an IE is
177 mwifiex_is_wpa_oui_present(struct mwifiex_bssdescriptor *bss_desc, u32 cipher)
180 struct ie_body *iebody;
181 u8 ret = MWIFIEX_OUI_NOT_PRESENT;
183 if (has_vendor_hdr(bss_desc->bcn_wpa_ie, WLAN_EID_VENDOR_SPECIFIC)) {
184 iebody = (struct ie_body *) bss_desc->bcn_wpa_ie->data;
185 oui = &mwifiex_wpa_oui[cipher][0];
186 ret = mwifiex_search_oui_in_ie(iebody, oui);
194 * This function compares two SSIDs and checks if they match.
197 mwifiex_ssid_cmp(struct cfg80211_ssid *ssid1, struct cfg80211_ssid *ssid2)
199 if (!ssid1 || !ssid2 || (ssid1->ssid_len != ssid2->ssid_len))
201 return memcmp(ssid1->ssid, ssid2->ssid, ssid1->ssid_len);
205 * This function checks if wapi is enabled in driver and scanned network is
206 * compatible with it.
209 mwifiex_is_bss_wapi(struct mwifiex_private *priv,
210 struct mwifiex_bssdescriptor *bss_desc)
212 if (priv->sec_info.wapi_enabled &&
213 has_ieee_hdr(bss_desc->bcn_wapi_ie, WLAN_EID_BSS_AC_ACCESS_DELAY))
219 * This function checks if driver is configured with no security mode and
220 * scanned network is compatible with it.
223 mwifiex_is_bss_no_sec(struct mwifiex_private *priv,
224 struct mwifiex_bssdescriptor *bss_desc)
226 if (!priv->sec_info.wep_enabled && !priv->sec_info.wpa_enabled &&
227 !priv->sec_info.wpa2_enabled &&
228 !has_vendor_hdr(bss_desc->bcn_wpa_ie, WLAN_EID_VENDOR_SPECIFIC) &&
229 !has_ieee_hdr(bss_desc->bcn_rsn_ie, WLAN_EID_RSN) &&
230 !priv->sec_info.encryption_mode && !bss_desc->privacy) {
237 * This function checks if static WEP is enabled in driver and scanned network
238 * is compatible with it.
241 mwifiex_is_bss_static_wep(struct mwifiex_private *priv,
242 struct mwifiex_bssdescriptor *bss_desc)
244 if (priv->sec_info.wep_enabled && !priv->sec_info.wpa_enabled &&
245 !priv->sec_info.wpa2_enabled && bss_desc->privacy) {
252 * This function checks if wpa is enabled in driver and scanned network is
253 * compatible with it.
256 mwifiex_is_bss_wpa(struct mwifiex_private *priv,
257 struct mwifiex_bssdescriptor *bss_desc)
259 if (!priv->sec_info.wep_enabled && priv->sec_info.wpa_enabled &&
260 !priv->sec_info.wpa2_enabled &&
261 has_vendor_hdr(bss_desc->bcn_wpa_ie, WLAN_EID_VENDOR_SPECIFIC)
263 * Privacy bit may NOT be set in some APs like
264 * LinkSys WRT54G && bss_desc->privacy
267 dbg_security_flags(INFO, "WPA", priv, bss_desc);
274 * This function checks if wpa2 is enabled in driver and scanned network is
275 * compatible with it.
278 mwifiex_is_bss_wpa2(struct mwifiex_private *priv,
279 struct mwifiex_bssdescriptor *bss_desc)
281 if (!priv->sec_info.wep_enabled && !priv->sec_info.wpa_enabled &&
282 priv->sec_info.wpa2_enabled &&
283 has_ieee_hdr(bss_desc->bcn_rsn_ie, WLAN_EID_RSN)) {
285 * Privacy bit may NOT be set in some APs like
286 * LinkSys WRT54G && bss_desc->privacy
288 dbg_security_flags(INFO, "WAP2", priv, bss_desc);
295 * This function checks if adhoc AES is enabled in driver and scanned network is
296 * compatible with it.
299 mwifiex_is_bss_adhoc_aes(struct mwifiex_private *priv,
300 struct mwifiex_bssdescriptor *bss_desc)
302 if (!priv->sec_info.wep_enabled && !priv->sec_info.wpa_enabled &&
303 !priv->sec_info.wpa2_enabled &&
304 !has_vendor_hdr(bss_desc->bcn_wpa_ie, WLAN_EID_VENDOR_SPECIFIC) &&
305 !has_ieee_hdr(bss_desc->bcn_rsn_ie, WLAN_EID_RSN) &&
306 !priv->sec_info.encryption_mode && bss_desc->privacy) {
313 * This function checks if dynamic WEP is enabled in driver and scanned network
314 * is compatible with it.
317 mwifiex_is_bss_dynamic_wep(struct mwifiex_private *priv,
318 struct mwifiex_bssdescriptor *bss_desc)
320 if (!priv->sec_info.wep_enabled && !priv->sec_info.wpa_enabled &&
321 !priv->sec_info.wpa2_enabled &&
322 !has_vendor_hdr(bss_desc->bcn_wpa_ie, WLAN_EID_VENDOR_SPECIFIC) &&
323 !has_ieee_hdr(bss_desc->bcn_rsn_ie, WLAN_EID_RSN) &&
324 priv->sec_info.encryption_mode && bss_desc->privacy) {
325 dbg_security_flags(INFO, "dynamic", priv, bss_desc);
332 * This function checks if a scanned network is compatible with the driver
335 * WEP WPA WPA2 ad-hoc encrypt Network
336 * enabled enabled enabled AES mode Privacy WPA WPA2 Compatible
337 * 0 0 0 0 NONE 0 0 0 yes No security
338 * 0 1 0 0 x 1x 1 x yes WPA (disable
340 * 0 0 1 0 x 1x x 1 yes WPA2 (disable
342 * 0 0 0 1 NONE 1 0 0 yes Ad-hoc AES
343 * 1 0 0 0 NONE 1 0 0 yes Static WEP
345 * 0 0 0 0 !=NONE 1 0 0 yes Dynamic WEP
347 * Compatibility is not matched while roaming, except for mode.
350 mwifiex_is_network_compatible(struct mwifiex_private *priv,
351 struct mwifiex_bssdescriptor *bss_desc, u32 mode)
353 struct mwifiex_adapter *adapter = priv->adapter;
355 bss_desc->disable_11n = false;
357 /* Don't check for compatibility if roaming */
358 if (priv->media_connected &&
359 (priv->bss_mode == NL80211_IFTYPE_STATION) &&
360 (bss_desc->bss_mode == NL80211_IFTYPE_STATION))
363 if (priv->wps.session_enable) {
364 mwifiex_dbg(adapter, IOCTL,
365 "info: return success directly in WPS period\n");
369 if (bss_desc->chan_sw_ie_present) {
370 mwifiex_dbg(adapter, INFO,
371 "Don't connect to AP with WLAN_EID_CHANNEL_SWITCH\n");
375 if (mwifiex_is_bss_wapi(priv, bss_desc)) {
376 mwifiex_dbg(adapter, INFO,
377 "info: return success for WAPI AP\n");
381 if (bss_desc->bss_mode == mode) {
382 if (mwifiex_is_bss_no_sec(priv, bss_desc)) {
385 } else if (mwifiex_is_bss_static_wep(priv, bss_desc)) {
386 /* Static WEP enabled */
387 mwifiex_dbg(adapter, INFO,
388 "info: Disable 11n in WEP mode.\n");
389 bss_desc->disable_11n = true;
391 } else if (mwifiex_is_bss_wpa(priv, bss_desc)) {
393 if (((priv->adapter->config_bands & BAND_GN ||
394 priv->adapter->config_bands & BAND_AN) &&
395 bss_desc->bcn_ht_cap) &&
396 !mwifiex_is_wpa_oui_present(bss_desc,
397 CIPHER_SUITE_CCMP)) {
399 if (mwifiex_is_wpa_oui_present
400 (bss_desc, CIPHER_SUITE_TKIP)) {
401 mwifiex_dbg(adapter, INFO,
402 "info: Disable 11n if AES\t"
403 "is not supported by AP\n");
404 bss_desc->disable_11n = true;
410 } else if (mwifiex_is_bss_wpa2(priv, bss_desc)) {
412 if (((priv->adapter->config_bands & BAND_GN ||
413 priv->adapter->config_bands & BAND_AN) &&
414 bss_desc->bcn_ht_cap) &&
415 !mwifiex_is_rsn_oui_present(bss_desc,
416 CIPHER_SUITE_CCMP)) {
418 if (mwifiex_is_rsn_oui_present
419 (bss_desc, CIPHER_SUITE_TKIP)) {
420 mwifiex_dbg(adapter, INFO,
421 "info: Disable 11n if AES\t"
422 "is not supported by AP\n");
423 bss_desc->disable_11n = true;
429 } else if (mwifiex_is_bss_adhoc_aes(priv, bss_desc)) {
430 /* Ad-hoc AES enabled */
432 } else if (mwifiex_is_bss_dynamic_wep(priv, bss_desc)) {
433 /* Dynamic WEP enabled */
437 /* Security doesn't match */
438 dbg_security_flags(ERROR, "failed", priv, bss_desc);
442 /* Mode doesn't match */
447 * This function creates a channel list for the driver to scan, based
448 * on region/band information.
450 * This routine is used for any scan that is not provided with a
451 * specific channel list to scan.
454 mwifiex_scan_create_channel_list(struct mwifiex_private *priv,
455 const struct mwifiex_user_scan_cfg
457 struct mwifiex_chan_scan_param_set
461 enum nl80211_band band;
462 struct ieee80211_supported_band *sband;
463 struct ieee80211_channel *ch;
464 struct mwifiex_adapter *adapter = priv->adapter;
467 for (band = 0; (band < NUM_NL80211_BANDS) ; band++) {
469 if (!priv->wdev.wiphy->bands[band])
472 sband = priv->wdev.wiphy->bands[band];
474 for (i = 0; (i < sband->n_channels) ; i++) {
475 ch = &sband->channels[i];
476 if (ch->flags & IEEE80211_CHAN_DISABLED)
478 scan_chan_list[chan_idx].radio_type = band;
481 user_scan_in->chan_list[0].scan_time)
482 scan_chan_list[chan_idx].max_scan_time =
483 cpu_to_le16((u16) user_scan_in->
484 chan_list[0].scan_time);
485 else if (ch->flags & IEEE80211_CHAN_NO_IR)
486 scan_chan_list[chan_idx].max_scan_time =
487 cpu_to_le16(adapter->passive_scan_time);
489 scan_chan_list[chan_idx].max_scan_time =
490 cpu_to_le16(adapter->active_scan_time);
492 if (ch->flags & IEEE80211_CHAN_NO_IR)
493 scan_chan_list[chan_idx].chan_scan_mode_bitmap
494 |= (MWIFIEX_PASSIVE_SCAN |
495 MWIFIEX_HIDDEN_SSID_REPORT);
497 scan_chan_list[chan_idx].chan_scan_mode_bitmap
498 &= ~MWIFIEX_PASSIVE_SCAN;
499 scan_chan_list[chan_idx].chan_number =
502 scan_chan_list[chan_idx].chan_scan_mode_bitmap
503 |= MWIFIEX_DISABLE_CHAN_FILT;
506 scan_chan_list[chan_idx].max_scan_time =
507 cpu_to_le16(adapter->specific_scan_time);
516 /* This function creates a channel list tlv for bgscan config, based
517 * on region/band information.
520 mwifiex_bgscan_create_channel_list(struct mwifiex_private *priv,
521 const struct mwifiex_bg_scan_cfg
523 struct mwifiex_chan_scan_param_set
526 enum nl80211_band band;
527 struct ieee80211_supported_band *sband;
528 struct ieee80211_channel *ch;
529 struct mwifiex_adapter *adapter = priv->adapter;
532 for (band = 0; (band < NUM_NL80211_BANDS); band++) {
533 if (!priv->wdev.wiphy->bands[band])
536 sband = priv->wdev.wiphy->bands[band];
538 for (i = 0; (i < sband->n_channels) ; i++) {
539 ch = &sband->channels[i];
540 if (ch->flags & IEEE80211_CHAN_DISABLED)
542 scan_chan_list[chan_idx].radio_type = band;
544 if (bgscan_cfg_in->chan_list[0].scan_time)
545 scan_chan_list[chan_idx].max_scan_time =
546 cpu_to_le16((u16)bgscan_cfg_in->
547 chan_list[0].scan_time);
548 else if (ch->flags & IEEE80211_CHAN_NO_IR)
549 scan_chan_list[chan_idx].max_scan_time =
550 cpu_to_le16(adapter->passive_scan_time);
552 scan_chan_list[chan_idx].max_scan_time =
553 cpu_to_le16(adapter->
556 if (ch->flags & IEEE80211_CHAN_NO_IR)
557 scan_chan_list[chan_idx].chan_scan_mode_bitmap
558 |= MWIFIEX_PASSIVE_SCAN;
560 scan_chan_list[chan_idx].chan_scan_mode_bitmap
561 &= ~MWIFIEX_PASSIVE_SCAN;
563 scan_chan_list[chan_idx].chan_number =
571 /* This function appends rate TLV to scan config command. */
573 mwifiex_append_rate_tlv(struct mwifiex_private *priv,
574 struct mwifiex_scan_cmd_config *scan_cfg_out,
577 struct mwifiex_ie_types_rates_param_set *rates_tlv;
578 u8 rates[MWIFIEX_SUPPORTED_RATES], *tlv_pos;
581 memset(rates, 0, sizeof(rates));
583 tlv_pos = (u8 *)scan_cfg_out->tlv_buf + scan_cfg_out->tlv_buf_len;
585 if (priv->scan_request)
586 rates_size = mwifiex_get_rates_from_cfg80211(priv, rates,
589 rates_size = mwifiex_get_supported_rates(priv, rates);
591 mwifiex_dbg(priv->adapter, CMD,
592 "info: SCAN_CMD: Rates size = %d\n",
594 rates_tlv = (struct mwifiex_ie_types_rates_param_set *)tlv_pos;
595 rates_tlv->header.type = cpu_to_le16(WLAN_EID_SUPP_RATES);
596 rates_tlv->header.len = cpu_to_le16((u16) rates_size);
597 memcpy(rates_tlv->rates, rates, rates_size);
598 scan_cfg_out->tlv_buf_len += sizeof(rates_tlv->header) + rates_size;
604 * This function constructs and sends multiple scan config commands to
607 * Previous routines in the code flow have created a scan command configuration
608 * with any requested TLVs. This function splits the channel TLV into maximum
609 * channels supported per scan lists and sends the portion of the channel TLV,
610 * along with the other TLVs, to the firmware.
613 mwifiex_scan_channel_list(struct mwifiex_private *priv,
614 u32 max_chan_per_scan, u8 filtered_scan,
615 struct mwifiex_scan_cmd_config *scan_cfg_out,
616 struct mwifiex_ie_types_chan_list_param_set
618 struct mwifiex_chan_scan_param_set *scan_chan_list)
620 struct mwifiex_adapter *adapter = priv->adapter;
622 struct mwifiex_chan_scan_param_set *tmp_chan_list;
623 struct mwifiex_chan_scan_param_set *start_chan;
624 u32 tlv_idx, rates_size, cmd_no;
629 if (!scan_cfg_out || !chan_tlv_out || !scan_chan_list) {
630 mwifiex_dbg(priv->adapter, ERROR,
631 "info: Scan: Null detect: %p, %p, %p\n",
632 scan_cfg_out, chan_tlv_out, scan_chan_list);
636 /* Check csa channel expiry before preparing scan list */
637 mwifiex_11h_get_csa_closed_channel(priv);
639 chan_tlv_out->header.type = cpu_to_le16(TLV_TYPE_CHANLIST);
641 /* Set the temp channel struct pointer to the start of the desired
643 tmp_chan_list = scan_chan_list;
645 /* Loop through the desired channel list, sending a new firmware scan
646 commands for each max_chan_per_scan channels (or for 1,6,11
647 individually if configured accordingly) */
648 while (tmp_chan_list->chan_number) {
653 chan_tlv_out->header.len = 0;
654 start_chan = tmp_chan_list;
658 * Construct the Channel TLV for the scan command. Continue to
659 * insert channel TLVs until:
660 * - the tlv_idx hits the maximum configured per scan command
661 * - the next channel to insert is 0 (end of desired channel
663 * - done_early is set (controlling individual scanning of
666 while (tlv_idx < max_chan_per_scan &&
667 tmp_chan_list->chan_number && !done_early) {
669 if (tmp_chan_list->chan_number == priv->csa_chan) {
674 radio_type = tmp_chan_list->radio_type;
675 mwifiex_dbg(priv->adapter, INFO,
676 "info: Scan: Chan(%3d), Radio(%d),\t"
677 "Mode(%d, %d), Dur(%d)\n",
678 tmp_chan_list->chan_number,
679 tmp_chan_list->radio_type,
680 tmp_chan_list->chan_scan_mode_bitmap
681 & MWIFIEX_PASSIVE_SCAN,
682 (tmp_chan_list->chan_scan_mode_bitmap
683 & MWIFIEX_DISABLE_CHAN_FILT) >> 1,
684 le16_to_cpu(tmp_chan_list->max_scan_time));
686 /* Copy the current channel TLV to the command being
688 memcpy(chan_tlv_out->chan_scan_param + tlv_idx,
690 sizeof(chan_tlv_out->chan_scan_param));
692 /* Increment the TLV header length by the size
694 le16_add_cpu(&chan_tlv_out->header.len,
695 sizeof(chan_tlv_out->chan_scan_param));
698 * The tlv buffer length is set to the number of bytes
699 * of the between the channel tlv pointer and the start
700 * of the tlv buffer. This compensates for any TLVs
701 * that were appended before the channel list.
703 scan_cfg_out->tlv_buf_len = (u32) ((u8 *) chan_tlv_out -
704 scan_cfg_out->tlv_buf);
706 /* Add the size of the channel tlv header and the data
708 scan_cfg_out->tlv_buf_len +=
709 (sizeof(chan_tlv_out->header)
710 + le16_to_cpu(chan_tlv_out->header.len));
712 /* Increment the index to the channel tlv we are
716 /* Count the total scan time per command */
718 le16_to_cpu(tmp_chan_list->max_scan_time);
722 /* Stop the loop if the *current* channel is in the
723 1,6,11 set and we are not filtering on a BSSID
725 if (!filtered_scan &&
726 (tmp_chan_list->chan_number == 1 ||
727 tmp_chan_list->chan_number == 6 ||
728 tmp_chan_list->chan_number == 11))
731 /* Increment the tmp pointer to the next channel to
735 /* Stop the loop if the *next* channel is in the 1,6,11
736 set. This will cause it to be the only channel
737 scanned on the next interation */
738 if (!filtered_scan &&
739 (tmp_chan_list->chan_number == 1 ||
740 tmp_chan_list->chan_number == 6 ||
741 tmp_chan_list->chan_number == 11))
745 /* The total scan time should be less than scan command timeout
747 if (total_scan_time > MWIFIEX_MAX_TOTAL_SCAN_TIME) {
748 mwifiex_dbg(priv->adapter, ERROR,
749 "total scan time %dms\t"
750 "is over limit (%dms), scan skipped\n",
752 MWIFIEX_MAX_TOTAL_SCAN_TIME);
757 rates_size = mwifiex_append_rate_tlv(priv, scan_cfg_out,
760 priv->adapter->scan_channels = start_chan;
762 /* Send the scan command to the firmware with the specified
764 if (priv->adapter->ext_scan)
765 cmd_no = HostCmd_CMD_802_11_SCAN_EXT;
767 cmd_no = HostCmd_CMD_802_11_SCAN;
769 ret = mwifiex_send_cmd(priv, cmd_no, HostCmd_ACT_GEN_SET,
770 0, scan_cfg_out, false);
772 /* rate IE is updated per scan command but same starting
773 * pointer is used each time so that rate IE from earlier
774 * scan_cfg_out->buf is overwritten with new one.
776 scan_cfg_out->tlv_buf_len -=
777 sizeof(struct mwifiex_ie_types_header) + rates_size;
780 mwifiex_cancel_pending_scan_cmd(adapter);
792 * This function constructs a scan command configuration structure to use
795 * Application layer or other functions can invoke network scanning
796 * with a scan configuration supplied in a user scan configuration structure.
797 * This structure is used as the basis of one or many scan command configuration
798 * commands that are sent to the command processing module and eventually to the
801 * This function creates a scan command configuration structure based on the
802 * following user supplied parameters (if present):
805 * - Number of Probes to be sent
808 * If the SSID or BSSID filter is not present, the filter is disabled/cleared.
809 * If the number of probes is not set, adapter default setting is used.
812 mwifiex_config_scan(struct mwifiex_private *priv,
813 const struct mwifiex_user_scan_cfg *user_scan_in,
814 struct mwifiex_scan_cmd_config *scan_cfg_out,
815 struct mwifiex_ie_types_chan_list_param_set **chan_list_out,
816 struct mwifiex_chan_scan_param_set *scan_chan_list,
817 u8 *max_chan_per_scan, u8 *filtered_scan,
818 u8 *scan_current_only)
820 struct mwifiex_adapter *adapter = priv->adapter;
821 struct mwifiex_ie_types_num_probes *num_probes_tlv;
822 struct mwifiex_ie_types_scan_chan_gap *chan_gap_tlv;
823 struct mwifiex_ie_types_wildcard_ssid_params *wildcard_ssid_tlv;
824 struct mwifiex_ie_types_bssid_list *bssid_tlv;
836 struct mwifiex_ie_types_htcap *ht_cap;
837 struct mwifiex_ie_types_bss_mode *bss_mode;
839 /* The tlv_buf_len is calculated for each scan command. The TLVs added
840 in this routine will be preserved since the routine that sends the
841 command will append channelTLVs at *chan_list_out. The difference
842 between the *chan_list_out and the tlv_buf start will be used to
843 calculate the size of anything we add in this routine. */
844 scan_cfg_out->tlv_buf_len = 0;
846 /* Running tlv pointer. Assigned to chan_list_out at end of function
847 so later routines know where channels can be added to the command
849 tlv_pos = scan_cfg_out->tlv_buf;
851 /* Initialize the scan as un-filtered; the flag is later set to TRUE
852 below if a SSID or BSSID filter is sent in the command */
853 *filtered_scan = false;
855 /* Initialize the scan as not being only on the current channel. If
856 the channel list is customized, only contains one channel, and is
857 the active channel, this is set true and data flow is not halted. */
858 *scan_current_only = false;
862 /* Default the ssid_filter flag to TRUE, set false under
863 certain wildcard conditions and qualified by the existence
864 of an SSID list before marking the scan as filtered */
867 /* Set the BSS type scan filter, use Adapter setting if
869 scan_cfg_out->bss_mode =
870 (u8)(user_scan_in->bss_mode ?: adapter->scan_mode);
872 /* Set the number of probes to send, use Adapter setting
874 num_probes = user_scan_in->num_probes ?: adapter->scan_probes;
877 * Set the BSSID filter to the incoming configuration,
878 * if non-zero. If not set, it will remain disabled
881 memcpy(scan_cfg_out->specific_bssid,
882 user_scan_in->specific_bssid,
883 sizeof(scan_cfg_out->specific_bssid));
885 if (adapter->ext_scan &&
886 !is_zero_ether_addr(scan_cfg_out->specific_bssid)) {
888 (struct mwifiex_ie_types_bssid_list *)tlv_pos;
889 bssid_tlv->header.type = cpu_to_le16(TLV_TYPE_BSSID);
890 bssid_tlv->header.len = cpu_to_le16(ETH_ALEN);
891 memcpy(bssid_tlv->bssid, user_scan_in->specific_bssid,
893 tlv_pos += sizeof(struct mwifiex_ie_types_bssid_list);
896 for (i = 0; i < user_scan_in->num_ssids; i++) {
897 ssid_len = user_scan_in->ssid_list[i].ssid_len;
900 (struct mwifiex_ie_types_wildcard_ssid_params *)
902 wildcard_ssid_tlv->header.type =
903 cpu_to_le16(TLV_TYPE_WILDCARDSSID);
904 wildcard_ssid_tlv->header.len = cpu_to_le16(
905 (u16) (ssid_len + sizeof(wildcard_ssid_tlv->
909 * max_ssid_length = 0 tells firmware to perform
910 * specific scan for the SSID filled, whereas
911 * max_ssid_length = IEEE80211_MAX_SSID_LEN is for
915 wildcard_ssid_tlv->max_ssid_length = 0;
917 wildcard_ssid_tlv->max_ssid_length =
918 IEEE80211_MAX_SSID_LEN;
920 if (!memcmp(user_scan_in->ssid_list[i].ssid,
922 wildcard_ssid_tlv->max_ssid_length = 0xfe;
924 memcpy(wildcard_ssid_tlv->ssid,
925 user_scan_in->ssid_list[i].ssid, ssid_len);
927 tlv_pos += (sizeof(wildcard_ssid_tlv->header)
928 + le16_to_cpu(wildcard_ssid_tlv->header.len));
930 mwifiex_dbg(adapter, INFO,
931 "info: scan: ssid[%d]: %s, %d\n",
932 i, wildcard_ssid_tlv->ssid,
933 wildcard_ssid_tlv->max_ssid_length);
935 /* Empty wildcard ssid with a maxlen will match many or
936 potentially all SSIDs (maxlen == 32), therefore do
937 not treat the scan as
939 if (!ssid_len && wildcard_ssid_tlv->max_ssid_length)
944 * The default number of channels sent in the command is low to
945 * ensure the response buffer from the firmware does not
946 * truncate scan results. That is not an issue with an SSID
947 * or BSSID filter applied to the scan results in the firmware.
949 if ((i && ssid_filter) ||
950 !is_zero_ether_addr(scan_cfg_out->specific_bssid))
951 *filtered_scan = true;
953 if (user_scan_in->scan_chan_gap) {
954 mwifiex_dbg(adapter, INFO,
955 "info: scan: channel gap = %d\n",
956 user_scan_in->scan_chan_gap);
958 MWIFIEX_MAX_CHANNELS_PER_SPECIFIC_SCAN;
960 chan_gap_tlv = (void *)tlv_pos;
961 chan_gap_tlv->header.type =
962 cpu_to_le16(TLV_TYPE_SCAN_CHANNEL_GAP);
963 chan_gap_tlv->header.len =
964 cpu_to_le16(sizeof(chan_gap_tlv->chan_gap));
965 chan_gap_tlv->chan_gap =
966 cpu_to_le16((user_scan_in->scan_chan_gap));
968 sizeof(struct mwifiex_ie_types_scan_chan_gap);
971 scan_cfg_out->bss_mode = (u8) adapter->scan_mode;
972 num_probes = adapter->scan_probes;
976 * If a specific BSSID or SSID is used, the number of channels in the
977 * scan command will be increased to the absolute maximum.
980 *max_chan_per_scan = MWIFIEX_MAX_CHANNELS_PER_SPECIFIC_SCAN;
982 *max_chan_per_scan = MWIFIEX_DEF_CHANNELS_PER_SCAN_CMD;
984 if (adapter->ext_scan) {
985 bss_mode = (struct mwifiex_ie_types_bss_mode *)tlv_pos;
986 bss_mode->header.type = cpu_to_le16(TLV_TYPE_BSS_MODE);
987 bss_mode->header.len = cpu_to_le16(sizeof(bss_mode->bss_mode));
988 bss_mode->bss_mode = scan_cfg_out->bss_mode;
989 tlv_pos += sizeof(bss_mode->header) +
990 le16_to_cpu(bss_mode->header.len);
993 /* If the input config or adapter has the number of Probes set,
997 mwifiex_dbg(adapter, INFO,
998 "info: scan: num_probes = %d\n",
1001 num_probes_tlv = (struct mwifiex_ie_types_num_probes *) tlv_pos;
1002 num_probes_tlv->header.type = cpu_to_le16(TLV_TYPE_NUMPROBES);
1003 num_probes_tlv->header.len =
1004 cpu_to_le16(sizeof(num_probes_tlv->num_probes));
1005 num_probes_tlv->num_probes = cpu_to_le16((u16) num_probes);
1007 tlv_pos += sizeof(num_probes_tlv->header) +
1008 le16_to_cpu(num_probes_tlv->header.len);
1012 if (ISSUPP_11NENABLED(priv->adapter->fw_cap_info) &&
1013 (priv->adapter->config_bands & BAND_GN ||
1014 priv->adapter->config_bands & BAND_AN)) {
1015 ht_cap = (struct mwifiex_ie_types_htcap *) tlv_pos;
1016 memset(ht_cap, 0, sizeof(struct mwifiex_ie_types_htcap));
1017 ht_cap->header.type = cpu_to_le16(WLAN_EID_HT_CAPABILITY);
1018 ht_cap->header.len =
1019 cpu_to_le16(sizeof(struct ieee80211_ht_cap));
1021 mwifiex_band_to_radio_type(priv->adapter->config_bands);
1022 mwifiex_fill_cap_info(priv, radio_type, &ht_cap->ht_cap);
1023 tlv_pos += sizeof(struct mwifiex_ie_types_htcap);
1026 /* Append vendor specific IE TLV */
1027 mwifiex_cmd_append_vsie_tlv(priv, MWIFIEX_VSIE_MASK_SCAN, &tlv_pos);
1030 * Set the output for the channel TLV to the address in the tlv buffer
1031 * past any TLVs that were added in this function (SSID, num_probes).
1032 * Channel TLVs will be added past this for each scan command,
1033 * preserving the TLVs that were previously added.
1036 (struct mwifiex_ie_types_chan_list_param_set *) tlv_pos;
1038 if (user_scan_in && user_scan_in->chan_list[0].chan_number) {
1040 mwifiex_dbg(adapter, INFO,
1041 "info: Scan: Using supplied channel list\n");
1044 chan_idx < MWIFIEX_USER_SCAN_CHAN_MAX &&
1045 user_scan_in->chan_list[chan_idx].chan_number;
1048 channel = user_scan_in->chan_list[chan_idx].chan_number;
1049 scan_chan_list[chan_idx].chan_number = channel;
1052 user_scan_in->chan_list[chan_idx].radio_type;
1053 scan_chan_list[chan_idx].radio_type = radio_type;
1055 scan_type = user_scan_in->chan_list[chan_idx].scan_type;
1057 if (scan_type == MWIFIEX_SCAN_TYPE_PASSIVE)
1058 scan_chan_list[chan_idx].chan_scan_mode_bitmap
1059 |= (MWIFIEX_PASSIVE_SCAN |
1060 MWIFIEX_HIDDEN_SSID_REPORT);
1062 scan_chan_list[chan_idx].chan_scan_mode_bitmap
1063 &= ~MWIFIEX_PASSIVE_SCAN;
1065 scan_chan_list[chan_idx].chan_scan_mode_bitmap
1066 |= MWIFIEX_DISABLE_CHAN_FILT;
1068 if (user_scan_in->chan_list[chan_idx].scan_time) {
1069 scan_dur = (u16) user_scan_in->
1070 chan_list[chan_idx].scan_time;
1072 if (scan_type == MWIFIEX_SCAN_TYPE_PASSIVE)
1073 scan_dur = adapter->passive_scan_time;
1074 else if (*filtered_scan)
1075 scan_dur = adapter->specific_scan_time;
1077 scan_dur = adapter->active_scan_time;
1080 scan_chan_list[chan_idx].min_scan_time =
1081 cpu_to_le16(scan_dur);
1082 scan_chan_list[chan_idx].max_scan_time =
1083 cpu_to_le16(scan_dur);
1086 /* Check if we are only scanning the current channel */
1087 if ((chan_idx == 1) &&
1088 (user_scan_in->chan_list[0].chan_number ==
1089 priv->curr_bss_params.bss_descriptor.channel)) {
1090 *scan_current_only = true;
1091 mwifiex_dbg(adapter, INFO,
1092 "info: Scan: Scanning current channel only\n");
1094 chan_num = chan_idx;
1096 mwifiex_dbg(adapter, INFO,
1097 "info: Scan: Creating full region channel list\n");
1098 chan_num = mwifiex_scan_create_channel_list(priv, user_scan_in,
1106 * This function inspects the scan response buffer for pointers to
1109 * TLVs can be included at the end of the scan response BSS information.
1111 * Data in the buffer is parsed pointers to TLVs that can potentially
1112 * be passed back in the response.
1115 mwifiex_ret_802_11_scan_get_tlv_ptrs(struct mwifiex_adapter *adapter,
1116 struct mwifiex_ie_types_data *tlv,
1117 u32 tlv_buf_size, u32 req_tlv_type,
1118 struct mwifiex_ie_types_data **tlv_data)
1120 struct mwifiex_ie_types_data *current_tlv;
1126 tlv_buf_left = tlv_buf_size;
1129 mwifiex_dbg(adapter, INFO,
1130 "info: SCAN_RESP: tlv_buf_size = %d\n",
1133 while (tlv_buf_left >= sizeof(struct mwifiex_ie_types_header)) {
1135 tlv_type = le16_to_cpu(current_tlv->header.type);
1136 tlv_len = le16_to_cpu(current_tlv->header.len);
1138 if (sizeof(tlv->header) + tlv_len > tlv_buf_left) {
1139 mwifiex_dbg(adapter, ERROR,
1140 "SCAN_RESP: TLV buffer corrupt\n");
1144 if (req_tlv_type == tlv_type) {
1146 case TLV_TYPE_TSFTIMESTAMP:
1147 mwifiex_dbg(adapter, INFO,
1148 "info: SCAN_RESP: TSF\t"
1149 "timestamp TLV, len = %d\n",
1151 *tlv_data = current_tlv;
1153 case TLV_TYPE_CHANNELBANDLIST:
1154 mwifiex_dbg(adapter, INFO,
1155 "info: SCAN_RESP: channel\t"
1156 "band list TLV, len = %d\n",
1158 *tlv_data = current_tlv;
1161 mwifiex_dbg(adapter, ERROR,
1162 "SCAN_RESP: unhandled TLV = %d\n",
1164 /* Give up, this seems corrupted */
1173 tlv_buf_left -= (sizeof(tlv->header) + tlv_len);
1175 (struct mwifiex_ie_types_data *) (current_tlv->data +
1182 * This function parses provided beacon buffer and updates
1183 * respective fields in bss descriptor structure.
1185 int mwifiex_update_bss_desc_with_ie(struct mwifiex_adapter *adapter,
1186 struct mwifiex_bssdescriptor *bss_entry)
1190 struct ieee_types_fh_param_set *fh_param_set;
1191 struct ieee_types_ds_param_set *ds_param_set;
1192 struct ieee_types_cf_param_set *cf_param_set;
1193 struct ieee_types_ibss_param_set *ibss_param_set;
1200 u8 found_data_rate_ie;
1202 struct ieee_types_vendor_specific *vendor_ie;
1203 const u8 wpa_oui[4] = { 0x00, 0x50, 0xf2, 0x01 };
1204 const u8 wmm_oui[4] = { 0x00, 0x50, 0xf2, 0x02 };
1206 found_data_rate_ie = false;
1208 current_ptr = bss_entry->beacon_buf;
1209 bytes_left = bss_entry->beacon_buf_size;
1211 /* Process variable IE */
1212 while (bytes_left >= 2) {
1213 element_id = *current_ptr;
1214 element_len = *(current_ptr + 1);
1215 total_ie_len = element_len + sizeof(struct ieee_types_header);
1217 if (bytes_left < total_ie_len) {
1218 mwifiex_dbg(adapter, ERROR,
1219 "err: InterpretIE: in processing\t"
1220 "IE, bytes left < IE length\n");
1223 switch (element_id) {
1225 bss_entry->ssid.ssid_len = element_len;
1226 memcpy(bss_entry->ssid.ssid, (current_ptr + 2),
1228 mwifiex_dbg(adapter, INFO,
1229 "info: InterpretIE: ssid: %-32s\n",
1230 bss_entry->ssid.ssid);
1233 case WLAN_EID_SUPP_RATES:
1234 memcpy(bss_entry->data_rates, current_ptr + 2,
1236 memcpy(bss_entry->supported_rates, current_ptr + 2,
1238 rate_size = element_len;
1239 found_data_rate_ie = true;
1242 case WLAN_EID_FH_PARAMS:
1244 (struct ieee_types_fh_param_set *) current_ptr;
1245 memcpy(&bss_entry->phy_param_set.fh_param_set,
1247 sizeof(struct ieee_types_fh_param_set));
1250 case WLAN_EID_DS_PARAMS:
1252 (struct ieee_types_ds_param_set *) current_ptr;
1254 bss_entry->channel = ds_param_set->current_chan;
1256 memcpy(&bss_entry->phy_param_set.ds_param_set,
1258 sizeof(struct ieee_types_ds_param_set));
1261 case WLAN_EID_CF_PARAMS:
1263 (struct ieee_types_cf_param_set *) current_ptr;
1264 memcpy(&bss_entry->ss_param_set.cf_param_set,
1266 sizeof(struct ieee_types_cf_param_set));
1269 case WLAN_EID_IBSS_PARAMS:
1271 (struct ieee_types_ibss_param_set *)
1273 memcpy(&bss_entry->ss_param_set.ibss_param_set,
1275 sizeof(struct ieee_types_ibss_param_set));
1278 case WLAN_EID_ERP_INFO:
1279 bss_entry->erp_flags = *(current_ptr + 2);
1282 case WLAN_EID_PWR_CONSTRAINT:
1283 bss_entry->local_constraint = *(current_ptr + 2);
1284 bss_entry->sensed_11h = true;
1287 case WLAN_EID_CHANNEL_SWITCH:
1288 bss_entry->chan_sw_ie_present = true;
1289 case WLAN_EID_PWR_CAPABILITY:
1290 case WLAN_EID_TPC_REPORT:
1291 case WLAN_EID_QUIET:
1292 bss_entry->sensed_11h = true;
1295 case WLAN_EID_EXT_SUPP_RATES:
1297 * Only process extended supported rate
1298 * if data rate is already found.
1299 * Data rate IE should come before
1300 * extended supported rate IE
1302 if (found_data_rate_ie) {
1303 if ((element_len + rate_size) >
1304 MWIFIEX_SUPPORTED_RATES)
1306 (MWIFIEX_SUPPORTED_RATES -
1309 bytes_to_copy = element_len;
1311 rate = (u8 *) bss_entry->data_rates;
1313 memcpy(rate, current_ptr + 2, bytes_to_copy);
1315 rate = (u8 *) bss_entry->supported_rates;
1317 memcpy(rate, current_ptr + 2, bytes_to_copy);
1321 case WLAN_EID_VENDOR_SPECIFIC:
1322 vendor_ie = (struct ieee_types_vendor_specific *)
1326 (vendor_ie->vend_hdr.oui, wpa_oui,
1328 bss_entry->bcn_wpa_ie =
1329 (struct ieee_types_vendor_specific *)
1331 bss_entry->wpa_offset = (u16)
1332 (current_ptr - bss_entry->beacon_buf);
1333 } else if (!memcmp(vendor_ie->vend_hdr.oui, wmm_oui,
1336 sizeof(struct ieee_types_wmm_parameter) ||
1338 sizeof(struct ieee_types_wmm_info))
1340 * Only accept and copy the WMM IE if
1341 * it matches the size expected for the
1342 * WMM Info IE or the WMM Parameter IE.
1344 memcpy((u8 *) &bss_entry->wmm_ie,
1345 current_ptr, total_ie_len);
1349 bss_entry->bcn_rsn_ie =
1350 (struct ieee_types_generic *) current_ptr;
1351 bss_entry->rsn_offset = (u16) (current_ptr -
1352 bss_entry->beacon_buf);
1354 case WLAN_EID_BSS_AC_ACCESS_DELAY:
1355 bss_entry->bcn_wapi_ie =
1356 (struct ieee_types_generic *) current_ptr;
1357 bss_entry->wapi_offset = (u16) (current_ptr -
1358 bss_entry->beacon_buf);
1360 case WLAN_EID_HT_CAPABILITY:
1361 bss_entry->bcn_ht_cap = (struct ieee80211_ht_cap *)
1363 sizeof(struct ieee_types_header));
1364 bss_entry->ht_cap_offset = (u16) (current_ptr +
1365 sizeof(struct ieee_types_header) -
1366 bss_entry->beacon_buf);
1368 case WLAN_EID_HT_OPERATION:
1369 bss_entry->bcn_ht_oper =
1370 (struct ieee80211_ht_operation *)(current_ptr +
1371 sizeof(struct ieee_types_header));
1372 bss_entry->ht_info_offset = (u16) (current_ptr +
1373 sizeof(struct ieee_types_header) -
1374 bss_entry->beacon_buf);
1376 case WLAN_EID_VHT_CAPABILITY:
1377 bss_entry->disable_11ac = false;
1378 bss_entry->bcn_vht_cap =
1379 (void *)(current_ptr +
1380 sizeof(struct ieee_types_header));
1381 bss_entry->vht_cap_offset =
1382 (u16)((u8 *)bss_entry->bcn_vht_cap -
1383 bss_entry->beacon_buf);
1385 case WLAN_EID_VHT_OPERATION:
1386 bss_entry->bcn_vht_oper =
1387 (void *)(current_ptr +
1388 sizeof(struct ieee_types_header));
1389 bss_entry->vht_info_offset =
1390 (u16)((u8 *)bss_entry->bcn_vht_oper -
1391 bss_entry->beacon_buf);
1393 case WLAN_EID_BSS_COEX_2040:
1394 bss_entry->bcn_bss_co_2040 = current_ptr;
1395 bss_entry->bss_co_2040_offset =
1396 (u16) (current_ptr - bss_entry->beacon_buf);
1398 case WLAN_EID_EXT_CAPABILITY:
1399 bss_entry->bcn_ext_cap = current_ptr;
1400 bss_entry->ext_cap_offset =
1401 (u16) (current_ptr - bss_entry->beacon_buf);
1403 case WLAN_EID_OPMODE_NOTIF:
1404 bss_entry->oper_mode = (void *)current_ptr;
1405 bss_entry->oper_mode_offset =
1406 (u16)((u8 *)bss_entry->oper_mode -
1407 bss_entry->beacon_buf);
1413 current_ptr += element_len + 2;
1415 /* Need to account for IE ID and IE Len */
1416 bytes_left -= (element_len + 2);
1418 } /* while (bytes_left > 2) */
1423 * This function converts radio type scan parameter to a band configuration
1424 * to be used in join command.
1427 mwifiex_radio_type_to_band(u8 radio_type)
1429 switch (radio_type) {
1430 case HostCmd_SCAN_RADIO_TYPE_A:
1432 case HostCmd_SCAN_RADIO_TYPE_BG:
1439 * This is an internal function used to start a scan based on an input
1442 * This uses the input user scan configuration information when provided in
1443 * order to send the appropriate scan commands to firmware to populate or
1444 * update the internal driver scan table.
1446 int mwifiex_scan_networks(struct mwifiex_private *priv,
1447 const struct mwifiex_user_scan_cfg *user_scan_in)
1450 struct mwifiex_adapter *adapter = priv->adapter;
1451 struct cmd_ctrl_node *cmd_node;
1452 union mwifiex_scan_cmd_config_tlv *scan_cfg_out;
1453 struct mwifiex_ie_types_chan_list_param_set *chan_list_out;
1454 struct mwifiex_chan_scan_param_set *scan_chan_list;
1456 u8 scan_current_chan_only;
1457 u8 max_chan_per_scan;
1458 unsigned long flags;
1460 if (adapter->scan_processing) {
1461 mwifiex_dbg(adapter, WARN,
1462 "cmd: Scan already in process...\n");
1466 if (priv->scan_block) {
1467 mwifiex_dbg(adapter, WARN,
1468 "cmd: Scan is blocked during association...\n");
1472 if (adapter->surprise_removed || adapter->is_cmd_timedout) {
1473 mwifiex_dbg(adapter, ERROR,
1474 "Ignore scan. Card removed or firmware in bad state\n");
1478 spin_lock_irqsave(&adapter->mwifiex_cmd_lock, flags);
1479 adapter->scan_processing = true;
1480 spin_unlock_irqrestore(&adapter->mwifiex_cmd_lock, flags);
1482 scan_cfg_out = kzalloc(sizeof(union mwifiex_scan_cmd_config_tlv),
1484 if (!scan_cfg_out) {
1489 scan_chan_list = kcalloc(MWIFIEX_USER_SCAN_CHAN_MAX,
1490 sizeof(struct mwifiex_chan_scan_param_set),
1492 if (!scan_chan_list) {
1493 kfree(scan_cfg_out);
1498 mwifiex_config_scan(priv, user_scan_in, &scan_cfg_out->config,
1499 &chan_list_out, scan_chan_list, &max_chan_per_scan,
1500 &filtered_scan, &scan_current_chan_only);
1502 ret = mwifiex_scan_channel_list(priv, max_chan_per_scan, filtered_scan,
1503 &scan_cfg_out->config, chan_list_out,
1506 /* Get scan command from scan_pending_q and put to cmd_pending_q */
1508 spin_lock_irqsave(&adapter->scan_pending_q_lock, flags);
1509 if (!list_empty(&adapter->scan_pending_q)) {
1510 cmd_node = list_first_entry(&adapter->scan_pending_q,
1511 struct cmd_ctrl_node, list);
1512 list_del(&cmd_node->list);
1513 spin_unlock_irqrestore(&adapter->scan_pending_q_lock,
1515 mwifiex_insert_cmd_to_pending_q(adapter, cmd_node,
1517 queue_work(adapter->workqueue, &adapter->main_work);
1519 /* Perform internal scan synchronously */
1520 if (!priv->scan_request) {
1521 mwifiex_dbg(adapter, INFO,
1522 "wait internal scan\n");
1523 mwifiex_wait_queue_complete(adapter, cmd_node);
1526 spin_unlock_irqrestore(&adapter->scan_pending_q_lock,
1531 kfree(scan_cfg_out);
1532 kfree(scan_chan_list);
1535 spin_lock_irqsave(&adapter->mwifiex_cmd_lock, flags);
1536 adapter->scan_processing = false;
1537 spin_unlock_irqrestore(&adapter->mwifiex_cmd_lock, flags);
1543 * This function prepares a scan command to be sent to the firmware.
1545 * This uses the scan command configuration sent to the command processing
1546 * module in command preparation stage to configure a scan command structure
1547 * to send to firmware.
1549 * The fixed fields specifying the BSS type and BSSID filters as well as a
1550 * variable number/length of TLVs are sent in the command to firmware.
1552 * Preparation also includes -
1553 * - Setting command ID, and proper size
1554 * - Ensuring correct endian-ness
1556 int mwifiex_cmd_802_11_scan(struct host_cmd_ds_command *cmd,
1557 struct mwifiex_scan_cmd_config *scan_cfg)
1559 struct host_cmd_ds_802_11_scan *scan_cmd = &cmd->params.scan;
1561 /* Set fixed field variables in scan command */
1562 scan_cmd->bss_mode = scan_cfg->bss_mode;
1563 memcpy(scan_cmd->bssid, scan_cfg->specific_bssid,
1564 sizeof(scan_cmd->bssid));
1565 memcpy(scan_cmd->tlv_buffer, scan_cfg->tlv_buf, scan_cfg->tlv_buf_len);
1567 cmd->command = cpu_to_le16(HostCmd_CMD_802_11_SCAN);
1569 /* Size is equal to the sizeof(fixed portions) + the TLV len + header */
1570 cmd->size = cpu_to_le16((u16) (sizeof(scan_cmd->bss_mode)
1571 + sizeof(scan_cmd->bssid)
1572 + scan_cfg->tlv_buf_len + S_DS_GEN));
1578 * This function checks compatibility of requested network with current
1581 int mwifiex_check_network_compatibility(struct mwifiex_private *priv,
1582 struct mwifiex_bssdescriptor *bss_desc)
1589 if ((mwifiex_get_cfp(priv, (u8) bss_desc->bss_band,
1590 (u16) bss_desc->channel, 0))) {
1591 switch (priv->bss_mode) {
1592 case NL80211_IFTYPE_STATION:
1593 case NL80211_IFTYPE_ADHOC:
1594 ret = mwifiex_is_network_compatible(priv, bss_desc,
1597 mwifiex_dbg(priv->adapter, ERROR,
1598 "Incompatible network settings\n");
1608 /* This function checks if SSID string contains all zeroes or length is zero */
1609 static bool mwifiex_is_hidden_ssid(struct cfg80211_ssid *ssid)
1613 for (idx = 0; idx < ssid->ssid_len; idx++) {
1614 if (ssid->ssid[idx])
1621 /* This function checks if any hidden SSID found in passive scan channels
1622 * and save those channels for specific SSID active scan
1624 static int mwifiex_save_hidden_ssid_channels(struct mwifiex_private *priv,
1625 struct cfg80211_bss *bss)
1627 struct mwifiex_bssdescriptor *bss_desc;
1631 /* Allocate and fill new bss descriptor */
1632 bss_desc = kzalloc(sizeof(*bss_desc), GFP_KERNEL);
1636 ret = mwifiex_fill_new_bss_desc(priv, bss, bss_desc);
1640 if (mwifiex_is_hidden_ssid(&bss_desc->ssid)) {
1641 mwifiex_dbg(priv->adapter, INFO, "found hidden SSID\n");
1642 for (chid = 0 ; chid < MWIFIEX_USER_SCAN_CHAN_MAX; chid++) {
1643 if (priv->hidden_chan[chid].chan_number ==
1644 bss->channel->hw_value)
1647 if (!priv->hidden_chan[chid].chan_number) {
1648 priv->hidden_chan[chid].chan_number =
1649 bss->channel->hw_value;
1650 priv->hidden_chan[chid].radio_type =
1652 priv->hidden_chan[chid].scan_type =
1653 MWIFIEX_SCAN_TYPE_ACTIVE;
1664 static int mwifiex_update_curr_bss_params(struct mwifiex_private *priv,
1665 struct cfg80211_bss *bss)
1667 struct mwifiex_bssdescriptor *bss_desc;
1669 unsigned long flags;
1671 /* Allocate and fill new bss descriptor */
1672 bss_desc = kzalloc(sizeof(struct mwifiex_bssdescriptor), GFP_KERNEL);
1676 ret = mwifiex_fill_new_bss_desc(priv, bss, bss_desc);
1680 ret = mwifiex_check_network_compatibility(priv, bss_desc);
1684 spin_lock_irqsave(&priv->curr_bcn_buf_lock, flags);
1685 /* Make a copy of current BSSID descriptor */
1686 memcpy(&priv->curr_bss_params.bss_descriptor, bss_desc,
1687 sizeof(priv->curr_bss_params.bss_descriptor));
1689 /* The contents of beacon_ie will be copied to its own buffer
1690 * in mwifiex_save_curr_bcn()
1692 mwifiex_save_curr_bcn(priv);
1693 spin_unlock_irqrestore(&priv->curr_bcn_buf_lock, flags);
1696 /* beacon_ie buffer was allocated in function
1697 * mwifiex_fill_new_bss_desc(). Free it now.
1699 kfree(bss_desc->beacon_buf);
1705 mwifiex_parse_single_response_buf(struct mwifiex_private *priv, u8 **bss_info,
1706 u32 *bytes_left, u64 fw_tsf, u8 *radio_type,
1707 bool ext_scan, s32 rssi_val)
1709 struct mwifiex_adapter *adapter = priv->adapter;
1710 struct mwifiex_chan_freq_power *cfp;
1711 struct cfg80211_bss *bss;
1717 u16 beacon_size = 0;
1721 u16 cap_info_bitmap;
1724 struct mwifiex_fixed_bcn_param *bcn_param;
1725 struct mwifiex_bss_priv *bss_priv;
1727 if (*bytes_left >= sizeof(beacon_size)) {
1728 /* Extract & convert beacon size from command buffer */
1729 beacon_size = le16_to_cpu(*(__le16 *)(*bss_info));
1730 *bytes_left -= sizeof(beacon_size);
1731 *bss_info += sizeof(beacon_size);
1734 if (!beacon_size || beacon_size > *bytes_left) {
1735 *bss_info += *bytes_left;
1740 /* Initialize the current working beacon pointer for this BSS
1743 current_ptr = *bss_info;
1745 /* Advance the return beacon pointer past the current beacon */
1746 *bss_info += beacon_size;
1747 *bytes_left -= beacon_size;
1749 curr_bcn_bytes = beacon_size;
1751 /* First 5 fields are bssid, RSSI(for legacy scan only),
1752 * time stamp, beacon interval, and capability information
1754 if (curr_bcn_bytes < ETH_ALEN + sizeof(u8) +
1755 sizeof(struct mwifiex_fixed_bcn_param)) {
1756 mwifiex_dbg(adapter, ERROR,
1757 "InterpretIE: not enough bytes left\n");
1761 memcpy(bssid, current_ptr, ETH_ALEN);
1762 current_ptr += ETH_ALEN;
1763 curr_bcn_bytes -= ETH_ALEN;
1766 rssi = (s32) *current_ptr;
1767 rssi = (-rssi) * 100; /* Convert dBm to mBm */
1768 current_ptr += sizeof(u8);
1769 curr_bcn_bytes -= sizeof(u8);
1770 mwifiex_dbg(adapter, INFO,
1771 "info: InterpretIE: RSSI=%d\n", rssi);
1776 bcn_param = (struct mwifiex_fixed_bcn_param *)current_ptr;
1777 current_ptr += sizeof(*bcn_param);
1778 curr_bcn_bytes -= sizeof(*bcn_param);
1780 timestamp = le64_to_cpu(bcn_param->timestamp);
1781 beacon_period = le16_to_cpu(bcn_param->beacon_period);
1783 cap_info_bitmap = le16_to_cpu(bcn_param->cap_info_bitmap);
1784 mwifiex_dbg(adapter, INFO,
1785 "info: InterpretIE: capabilities=0x%X\n",
1788 /* Rest of the current buffer are IE's */
1789 ie_buf = current_ptr;
1790 ie_len = curr_bcn_bytes;
1791 mwifiex_dbg(adapter, INFO,
1792 "info: InterpretIE: IELength for this AP = %d\n",
1795 while (curr_bcn_bytes >= sizeof(struct ieee_types_header)) {
1796 u8 element_id, element_len;
1798 element_id = *current_ptr;
1799 element_len = *(current_ptr + 1);
1800 if (curr_bcn_bytes < element_len +
1801 sizeof(struct ieee_types_header)) {
1802 mwifiex_dbg(adapter, ERROR,
1803 "%s: bytes left < IE length\n", __func__);
1806 if (element_id == WLAN_EID_DS_PARAMS) {
1807 channel = *(current_ptr +
1808 sizeof(struct ieee_types_header));
1812 current_ptr += element_len + sizeof(struct ieee_types_header);
1813 curr_bcn_bytes -= element_len +
1814 sizeof(struct ieee_types_header);
1818 struct ieee80211_channel *chan;
1821 /* Skip entry if on csa closed channel */
1822 if (channel == priv->csa_chan) {
1823 mwifiex_dbg(adapter, WARN,
1824 "Dropping entry on csa closed channel\n");
1830 band = mwifiex_radio_type_to_band(*radio_type &
1833 cfp = mwifiex_get_cfp(priv, band, channel, 0);
1835 freq = cfp ? cfp->freq : 0;
1837 chan = ieee80211_get_channel(priv->wdev.wiphy, freq);
1839 if (chan && !(chan->flags & IEEE80211_CHAN_DISABLED)) {
1840 bss = cfg80211_inform_bss(priv->wdev.wiphy,
1841 chan, CFG80211_BSS_FTYPE_UNKNOWN,
1843 cap_info_bitmap, beacon_period,
1844 ie_buf, ie_len, rssi, GFP_KERNEL);
1846 bss_priv = (struct mwifiex_bss_priv *)bss->priv;
1847 bss_priv->band = band;
1848 bss_priv->fw_tsf = fw_tsf;
1849 if (priv->media_connected &&
1850 !memcmp(bssid, priv->curr_bss_params.
1851 bss_descriptor.mac_address,
1853 mwifiex_update_curr_bss_params(priv,
1855 cfg80211_put_bss(priv->wdev.wiphy, bss);
1858 if ((chan->flags & IEEE80211_CHAN_RADAR) ||
1859 (chan->flags & IEEE80211_CHAN_NO_IR)) {
1860 mwifiex_dbg(adapter, INFO,
1861 "radar or passive channel %d\n",
1863 mwifiex_save_hidden_ssid_channels(priv, bss);
1867 mwifiex_dbg(adapter, WARN, "missing BSS channel IE\n");
1873 static void mwifiex_complete_scan(struct mwifiex_private *priv)
1875 struct mwifiex_adapter *adapter = priv->adapter;
1877 adapter->survey_idx = 0;
1878 if (adapter->curr_cmd->wait_q_enabled) {
1879 adapter->cmd_wait_q.status = 0;
1880 if (!priv->scan_request) {
1881 mwifiex_dbg(adapter, INFO,
1882 "complete internal scan\n");
1883 mwifiex_complete_cmd(adapter, adapter->curr_cmd);
1888 /* This function checks if any hidden SSID found in passive scan channels
1889 * and do specific SSID active scan for those channels
1892 mwifiex_active_scan_req_for_passive_chan(struct mwifiex_private *priv)
1895 struct mwifiex_adapter *adapter = priv->adapter;
1897 struct mwifiex_user_scan_cfg *user_scan_cfg;
1899 if (adapter->active_scan_triggered || !priv->scan_request) {
1900 adapter->active_scan_triggered = false;
1904 if (!priv->hidden_chan[0].chan_number) {
1905 mwifiex_dbg(adapter, INFO, "No BSS with hidden SSID found on DFS channels\n");
1908 user_scan_cfg = kzalloc(sizeof(*user_scan_cfg), GFP_KERNEL);
1913 memset(user_scan_cfg, 0, sizeof(*user_scan_cfg));
1915 for (id = 0; id < MWIFIEX_USER_SCAN_CHAN_MAX; id++) {
1916 if (!priv->hidden_chan[id].chan_number)
1918 memcpy(&user_scan_cfg->chan_list[id],
1919 &priv->hidden_chan[id],
1920 sizeof(struct mwifiex_user_scan_chan));
1923 adapter->active_scan_triggered = true;
1924 user_scan_cfg->num_ssids = priv->scan_request->n_ssids;
1925 user_scan_cfg->ssid_list = priv->scan_request->ssids;
1927 ret = mwifiex_scan_networks(priv, user_scan_cfg);
1928 kfree(user_scan_cfg);
1930 memset(&priv->hidden_chan, 0, sizeof(priv->hidden_chan));
1933 dev_err(priv->adapter->dev, "scan failed: %d\n", ret);
1939 static void mwifiex_check_next_scan_command(struct mwifiex_private *priv)
1941 struct mwifiex_adapter *adapter = priv->adapter;
1942 struct cmd_ctrl_node *cmd_node;
1943 unsigned long flags;
1945 spin_lock_irqsave(&adapter->scan_pending_q_lock, flags);
1946 if (list_empty(&adapter->scan_pending_q)) {
1947 spin_unlock_irqrestore(&adapter->scan_pending_q_lock, flags);
1949 spin_lock_irqsave(&adapter->mwifiex_cmd_lock, flags);
1950 adapter->scan_processing = false;
1951 spin_unlock_irqrestore(&adapter->mwifiex_cmd_lock, flags);
1953 mwifiex_active_scan_req_for_passive_chan(priv);
1955 if (!adapter->ext_scan)
1956 mwifiex_complete_scan(priv);
1958 if (priv->scan_request) {
1959 mwifiex_dbg(adapter, INFO,
1960 "info: notifying scan done\n");
1961 cfg80211_scan_done(priv->scan_request, 0);
1962 priv->scan_request = NULL;
1964 priv->scan_aborting = false;
1965 mwifiex_dbg(adapter, INFO,
1966 "info: scan already aborted\n");
1968 } else if ((priv->scan_aborting && !priv->scan_request) ||
1970 spin_unlock_irqrestore(&adapter->scan_pending_q_lock, flags);
1972 mwifiex_cancel_pending_scan_cmd(adapter);
1974 spin_lock_irqsave(&adapter->mwifiex_cmd_lock, flags);
1975 adapter->scan_processing = false;
1976 spin_unlock_irqrestore(&adapter->mwifiex_cmd_lock, flags);
1978 if (!adapter->active_scan_triggered) {
1979 if (priv->scan_request) {
1980 mwifiex_dbg(adapter, INFO,
1981 "info: aborting scan\n");
1982 cfg80211_scan_done(priv->scan_request, 1);
1983 priv->scan_request = NULL;
1985 priv->scan_aborting = false;
1986 mwifiex_dbg(adapter, INFO,
1987 "info: scan already aborted\n");
1991 /* Get scan command from scan_pending_q and put to
1994 cmd_node = list_first_entry(&adapter->scan_pending_q,
1995 struct cmd_ctrl_node, list);
1996 list_del(&cmd_node->list);
1997 spin_unlock_irqrestore(&adapter->scan_pending_q_lock, flags);
1998 mwifiex_insert_cmd_to_pending_q(adapter, cmd_node, true);
2005 * This function handles the command response of scan.
2007 * The response buffer for the scan command has the following
2010 * .-------------------------------------------------------------.
2011 * | Header (4 * sizeof(t_u16)): Standard command response hdr |
2012 * .-------------------------------------------------------------.
2013 * | BufSize (t_u16) : sizeof the BSS Description data |
2014 * .-------------------------------------------------------------.
2015 * | NumOfSet (t_u8) : Number of BSS Descs returned |
2016 * .-------------------------------------------------------------.
2017 * | BSSDescription data (variable, size given in BufSize) |
2018 * .-------------------------------------------------------------.
2019 * | TLV data (variable, size calculated using Header->Size, |
2020 * | BufSize and sizeof the fixed fields above) |
2021 * .-------------------------------------------------------------.
2023 int mwifiex_ret_802_11_scan(struct mwifiex_private *priv,
2024 struct host_cmd_ds_command *resp)
2027 struct mwifiex_adapter *adapter = priv->adapter;
2028 struct host_cmd_ds_802_11_scan_rsp *scan_rsp;
2029 struct mwifiex_ie_types_data *tlv_data;
2030 struct mwifiex_ie_types_tsf_timestamp *tsf_tlv;
2036 struct mwifiex_ie_types_chan_band_list_param_set *chan_band_tlv;
2037 struct chan_band_param_set *chan_band;
2041 struct cfg80211_wowlan_nd_match *pmatch;
2042 struct cfg80211_sched_scan_request *nd_config = NULL;
2044 is_bgscan_resp = (le16_to_cpu(resp->command)
2045 == HostCmd_CMD_802_11_BG_SCAN_QUERY);
2047 scan_rsp = &resp->params.bg_scan_query_resp.scan_resp;
2049 scan_rsp = &resp->params.scan_resp;
2052 if (scan_rsp->number_of_sets > MWIFIEX_MAX_AP) {
2053 mwifiex_dbg(adapter, ERROR,
2054 "SCAN_RESP: too many AP returned (%d)\n",
2055 scan_rsp->number_of_sets);
2057 goto check_next_scan;
2060 /* Check csa channel expiry before parsing scan response */
2061 mwifiex_11h_get_csa_closed_channel(priv);
2063 bytes_left = le16_to_cpu(scan_rsp->bss_descript_size);
2064 mwifiex_dbg(adapter, INFO,
2065 "info: SCAN_RESP: bss_descript_size %d\n",
2068 scan_resp_size = le16_to_cpu(resp->size);
2070 mwifiex_dbg(adapter, INFO,
2071 "info: SCAN_RESP: returned %d APs before parsing\n",
2072 scan_rsp->number_of_sets);
2074 bss_info = scan_rsp->bss_desc_and_tlv_buffer;
2077 * The size of the TLV buffer is equal to the entire command response
2078 * size (scan_resp_size) minus the fixed fields (sizeof()'s), the
2079 * BSS Descriptions (bss_descript_size as bytesLef) and the command
2080 * response header (S_DS_GEN)
2082 tlv_buf_size = scan_resp_size - (bytes_left
2083 + sizeof(scan_rsp->bss_descript_size)
2084 + sizeof(scan_rsp->number_of_sets)
2087 tlv_data = (struct mwifiex_ie_types_data *) (scan_rsp->
2088 bss_desc_and_tlv_buffer +
2091 /* Search the TLV buffer space in the scan response for any valid
2093 mwifiex_ret_802_11_scan_get_tlv_ptrs(adapter, tlv_data, tlv_buf_size,
2094 TLV_TYPE_TSFTIMESTAMP,
2095 (struct mwifiex_ie_types_data **)
2098 /* Search the TLV buffer space in the scan response for any valid
2100 mwifiex_ret_802_11_scan_get_tlv_ptrs(adapter, tlv_data, tlv_buf_size,
2101 TLV_TYPE_CHANNELBANDLIST,
2102 (struct mwifiex_ie_types_data **)
2106 if (priv->wdev.wiphy->wowlan_config)
2107 nd_config = priv->wdev.wiphy->wowlan_config->nd_config;
2112 kzalloc(sizeof(struct cfg80211_wowlan_nd_match) +
2113 sizeof(struct cfg80211_wowlan_nd_match *) *
2114 scan_rsp->number_of_sets, GFP_ATOMIC);
2116 if (adapter->nd_info)
2117 adapter->nd_info->n_matches = scan_rsp->number_of_sets;
2120 for (idx = 0; idx < scan_rsp->number_of_sets && bytes_left; idx++) {
2122 * If the TSF TLV was appended to the scan results, save this
2123 * entry's TSF value in the fw_tsf field. It is the firmware's
2124 * TSF value at the time the beacon or probe response was
2128 memcpy(&fw_tsf, &tsf_tlv->tsf_data[idx * TSF_DATA_SIZE],
2131 if (chan_band_tlv) {
2132 chan_band = &chan_band_tlv->chan_band_param[idx];
2133 radio_type = &chan_band->radio_type;
2138 if (chan_band_tlv && adapter->nd_info) {
2139 adapter->nd_info->matches[idx] =
2140 kzalloc(sizeof(*pmatch) +
2141 sizeof(u32), GFP_ATOMIC);
2143 pmatch = adapter->nd_info->matches[idx];
2146 memset(pmatch, 0, sizeof(*pmatch));
2147 if (chan_band_tlv) {
2148 pmatch->n_channels = 1;
2149 pmatch->channels[0] =
2150 chan_band->chan_number;
2155 ret = mwifiex_parse_single_response_buf(priv, &bss_info,
2157 le64_to_cpu(fw_tsf),
2158 radio_type, false, 0);
2160 goto check_next_scan;
2164 mwifiex_check_next_scan_command(priv);
2169 * This function prepares an extended scan command to be sent to the firmware
2171 * This uses the scan command configuration sent to the command processing
2172 * module in command preparation stage to configure a extended scan command
2173 * structure to send to firmware.
2175 int mwifiex_cmd_802_11_scan_ext(struct mwifiex_private *priv,
2176 struct host_cmd_ds_command *cmd,
2179 struct host_cmd_ds_802_11_scan_ext *ext_scan = &cmd->params.ext_scan;
2180 struct mwifiex_scan_cmd_config *scan_cfg = data_buf;
2182 memcpy(ext_scan->tlv_buffer, scan_cfg->tlv_buf, scan_cfg->tlv_buf_len);
2184 cmd->command = cpu_to_le16(HostCmd_CMD_802_11_SCAN_EXT);
2186 /* Size is equal to the sizeof(fixed portions) + the TLV len + header */
2187 cmd->size = cpu_to_le16((u16)(sizeof(ext_scan->reserved)
2188 + scan_cfg->tlv_buf_len + S_DS_GEN));
2193 /* This function prepares an background scan config command to be sent
2196 int mwifiex_cmd_802_11_bg_scan_config(struct mwifiex_private *priv,
2197 struct host_cmd_ds_command *cmd,
2200 struct host_cmd_ds_802_11_bg_scan_config *bgscan_config =
2201 &cmd->params.bg_scan_config;
2202 struct mwifiex_bg_scan_cfg *bgscan_cfg_in = data_buf;
2203 u8 *tlv_pos = bgscan_config->tlv;
2205 u32 ssid_len, chan_idx, scan_type, scan_dur, chan_num;
2207 struct mwifiex_ie_types_num_probes *num_probes_tlv;
2208 struct mwifiex_ie_types_repeat_count *repeat_count_tlv;
2209 struct mwifiex_ie_types_min_rssi_threshold *rssi_threshold_tlv;
2210 struct mwifiex_ie_types_bgscan_start_later *start_later_tlv;
2211 struct mwifiex_ie_types_wildcard_ssid_params *wildcard_ssid_tlv;
2212 struct mwifiex_ie_types_chan_list_param_set *chan_list_tlv;
2213 struct mwifiex_chan_scan_param_set *temp_chan;
2215 cmd->command = cpu_to_le16(HostCmd_CMD_802_11_BG_SCAN_CONFIG);
2216 cmd->size = cpu_to_le16(sizeof(*bgscan_config) + S_DS_GEN);
2218 bgscan_config->action = cpu_to_le16(bgscan_cfg_in->action);
2219 bgscan_config->enable = bgscan_cfg_in->enable;
2220 bgscan_config->bss_type = bgscan_cfg_in->bss_type;
2221 bgscan_config->scan_interval =
2222 cpu_to_le32(bgscan_cfg_in->scan_interval);
2223 bgscan_config->report_condition =
2224 cpu_to_le32(bgscan_cfg_in->report_condition);
2226 /* stop sched scan */
2227 if (!bgscan_config->enable)
2230 bgscan_config->chan_per_scan = bgscan_cfg_in->chan_per_scan;
2232 num_probes = (bgscan_cfg_in->num_probes ? bgscan_cfg_in->
2233 num_probes : priv->adapter->scan_probes);
2236 num_probes_tlv = (struct mwifiex_ie_types_num_probes *)tlv_pos;
2237 num_probes_tlv->header.type = cpu_to_le16(TLV_TYPE_NUMPROBES);
2238 num_probes_tlv->header.len =
2239 cpu_to_le16(sizeof(num_probes_tlv->num_probes));
2240 num_probes_tlv->num_probes = cpu_to_le16((u16)num_probes);
2242 tlv_pos += sizeof(num_probes_tlv->header) +
2243 le16_to_cpu(num_probes_tlv->header.len);
2246 if (bgscan_cfg_in->repeat_count) {
2248 (struct mwifiex_ie_types_repeat_count *)tlv_pos;
2249 repeat_count_tlv->header.type =
2250 cpu_to_le16(TLV_TYPE_REPEAT_COUNT);
2251 repeat_count_tlv->header.len =
2252 cpu_to_le16(sizeof(repeat_count_tlv->repeat_count));
2253 repeat_count_tlv->repeat_count =
2254 cpu_to_le16(bgscan_cfg_in->repeat_count);
2256 tlv_pos += sizeof(repeat_count_tlv->header) +
2257 le16_to_cpu(repeat_count_tlv->header.len);
2260 if (bgscan_cfg_in->rssi_threshold) {
2261 rssi_threshold_tlv =
2262 (struct mwifiex_ie_types_min_rssi_threshold *)tlv_pos;
2263 rssi_threshold_tlv->header.type =
2264 cpu_to_le16(TLV_TYPE_RSSI_LOW);
2265 rssi_threshold_tlv->header.len =
2266 cpu_to_le16(sizeof(rssi_threshold_tlv->rssi_threshold));
2267 rssi_threshold_tlv->rssi_threshold =
2268 cpu_to_le16(bgscan_cfg_in->rssi_threshold);
2270 tlv_pos += sizeof(rssi_threshold_tlv->header) +
2271 le16_to_cpu(rssi_threshold_tlv->header.len);
2274 for (i = 0; i < bgscan_cfg_in->num_ssids; i++) {
2275 ssid_len = bgscan_cfg_in->ssid_list[i].ssid.ssid_len;
2278 (struct mwifiex_ie_types_wildcard_ssid_params *)tlv_pos;
2279 wildcard_ssid_tlv->header.type =
2280 cpu_to_le16(TLV_TYPE_WILDCARDSSID);
2281 wildcard_ssid_tlv->header.len = cpu_to_le16(
2282 (u16)(ssid_len + sizeof(wildcard_ssid_tlv->
2285 /* max_ssid_length = 0 tells firmware to perform
2286 * specific scan for the SSID filled, whereas
2287 * max_ssid_length = IEEE80211_MAX_SSID_LEN is for
2291 wildcard_ssid_tlv->max_ssid_length = 0;
2293 wildcard_ssid_tlv->max_ssid_length =
2294 IEEE80211_MAX_SSID_LEN;
2296 memcpy(wildcard_ssid_tlv->ssid,
2297 bgscan_cfg_in->ssid_list[i].ssid.ssid, ssid_len);
2299 tlv_pos += (sizeof(wildcard_ssid_tlv->header)
2300 + le16_to_cpu(wildcard_ssid_tlv->header.len));
2303 chan_list_tlv = (struct mwifiex_ie_types_chan_list_param_set *)tlv_pos;
2305 if (bgscan_cfg_in->chan_list[0].chan_number) {
2306 dev_dbg(priv->adapter->dev, "info: bgscan: Using supplied channel list\n");
2308 chan_list_tlv->header.type = cpu_to_le16(TLV_TYPE_CHANLIST);
2311 chan_idx < MWIFIEX_BG_SCAN_CHAN_MAX &&
2312 bgscan_cfg_in->chan_list[chan_idx].chan_number;
2314 temp_chan = chan_list_tlv->chan_scan_param + chan_idx;
2316 /* Increment the TLV header length by size appended */
2317 le16_add_cpu(&chan_list_tlv->header.len,
2318 sizeof(chan_list_tlv->chan_scan_param));
2320 temp_chan->chan_number =
2321 bgscan_cfg_in->chan_list[chan_idx].chan_number;
2322 temp_chan->radio_type =
2323 bgscan_cfg_in->chan_list[chan_idx].radio_type;
2326 bgscan_cfg_in->chan_list[chan_idx].scan_type;
2328 if (scan_type == MWIFIEX_SCAN_TYPE_PASSIVE)
2329 temp_chan->chan_scan_mode_bitmap
2330 |= MWIFIEX_PASSIVE_SCAN;
2332 temp_chan->chan_scan_mode_bitmap
2333 &= ~MWIFIEX_PASSIVE_SCAN;
2335 if (bgscan_cfg_in->chan_list[chan_idx].scan_time) {
2336 scan_dur = (u16)bgscan_cfg_in->
2337 chan_list[chan_idx].scan_time;
2339 scan_dur = (scan_type ==
2340 MWIFIEX_SCAN_TYPE_PASSIVE) ?
2341 priv->adapter->passive_scan_time :
2342 priv->adapter->specific_scan_time;
2345 temp_chan->min_scan_time = cpu_to_le16(scan_dur);
2346 temp_chan->max_scan_time = cpu_to_le16(scan_dur);
2349 dev_dbg(priv->adapter->dev,
2350 "info: bgscan: Creating full region channel list\n");
2352 mwifiex_bgscan_create_channel_list(priv, bgscan_cfg_in,
2355 le16_add_cpu(&chan_list_tlv->header.len,
2357 sizeof(chan_list_tlv->chan_scan_param[0]));
2360 tlv_pos += (sizeof(chan_list_tlv->header)
2361 + le16_to_cpu(chan_list_tlv->header.len));
2363 if (bgscan_cfg_in->start_later) {
2365 (struct mwifiex_ie_types_bgscan_start_later *)tlv_pos;
2366 start_later_tlv->header.type =
2367 cpu_to_le16(TLV_TYPE_BGSCAN_START_LATER);
2368 start_later_tlv->header.len =
2369 cpu_to_le16(sizeof(start_later_tlv->start_later));
2370 start_later_tlv->start_later =
2371 cpu_to_le16(bgscan_cfg_in->start_later);
2373 tlv_pos += sizeof(start_later_tlv->header) +
2374 le16_to_cpu(start_later_tlv->header.len);
2377 /* Append vendor specific IE TLV */
2378 mwifiex_cmd_append_vsie_tlv(priv, MWIFIEX_VSIE_MASK_BGSCAN, &tlv_pos);
2380 le16_add_cpu(&cmd->size, tlv_pos - bgscan_config->tlv);
2385 int mwifiex_stop_bg_scan(struct mwifiex_private *priv)
2387 struct mwifiex_bg_scan_cfg *bgscan_cfg;
2389 if (!priv->sched_scanning) {
2390 dev_dbg(priv->adapter->dev, "bgscan already stopped!\n");
2394 bgscan_cfg = kzalloc(sizeof(*bgscan_cfg), GFP_KERNEL);
2398 bgscan_cfg->bss_type = MWIFIEX_BSS_MODE_INFRA;
2399 bgscan_cfg->action = MWIFIEX_BGSCAN_ACT_SET;
2400 bgscan_cfg->enable = false;
2402 if (mwifiex_send_cmd(priv, HostCmd_CMD_802_11_BG_SCAN_CONFIG,
2403 HostCmd_ACT_GEN_SET, 0, bgscan_cfg, true)) {
2409 priv->sched_scanning = false;
2415 mwifiex_update_chan_statistics(struct mwifiex_private *priv,
2416 struct mwifiex_ietypes_chanstats *tlv_stat)
2418 struct mwifiex_adapter *adapter = priv->adapter;
2420 struct mwifiex_fw_chan_stats *fw_chan_stats;
2421 struct mwifiex_chan_stats chan_stats;
2423 fw_chan_stats = (void *)((u8 *)tlv_stat +
2424 sizeof(struct mwifiex_ie_types_header));
2425 num_chan = le16_to_cpu(tlv_stat->header.len) /
2426 sizeof(struct mwifiex_chan_stats);
2428 for (i = 0 ; i < num_chan; i++) {
2429 chan_stats.chan_num = fw_chan_stats->chan_num;
2430 chan_stats.bandcfg = fw_chan_stats->bandcfg;
2431 chan_stats.flags = fw_chan_stats->flags;
2432 chan_stats.noise = fw_chan_stats->noise;
2433 chan_stats.total_bss = le16_to_cpu(fw_chan_stats->total_bss);
2434 chan_stats.cca_scan_dur =
2435 le16_to_cpu(fw_chan_stats->cca_scan_dur);
2436 chan_stats.cca_busy_dur =
2437 le16_to_cpu(fw_chan_stats->cca_busy_dur);
2438 mwifiex_dbg(adapter, INFO,
2439 "chan=%d, noise=%d, total_network=%d scan_duration=%d, busy_duration=%d\n",
2440 chan_stats.chan_num,
2442 chan_stats.total_bss,
2443 chan_stats.cca_scan_dur,
2444 chan_stats.cca_busy_dur);
2445 memcpy(&adapter->chan_stats[adapter->survey_idx++], &chan_stats,
2446 sizeof(struct mwifiex_chan_stats));
2451 /* This function handles the command response of extended scan */
2452 int mwifiex_ret_802_11_scan_ext(struct mwifiex_private *priv,
2453 struct host_cmd_ds_command *resp)
2455 struct mwifiex_adapter *adapter = priv->adapter;
2456 struct host_cmd_ds_802_11_scan_ext *ext_scan_resp;
2457 struct mwifiex_ie_types_header *tlv;
2458 struct mwifiex_ietypes_chanstats *tlv_stat;
2459 u16 buf_left, type, len;
2461 struct host_cmd_ds_command *cmd_ptr;
2462 struct cmd_ctrl_node *cmd_node;
2463 unsigned long cmd_flags, scan_flags;
2464 bool complete_scan = false;
2466 mwifiex_dbg(adapter, INFO, "info: EXT scan returns successfully\n");
2468 ext_scan_resp = &resp->params.ext_scan;
2470 tlv = (void *)ext_scan_resp->tlv_buffer;
2471 buf_left = le16_to_cpu(resp->size) - (sizeof(*ext_scan_resp) + S_DS_GEN
2474 while (buf_left >= sizeof(struct mwifiex_ie_types_header)) {
2475 type = le16_to_cpu(tlv->type);
2476 len = le16_to_cpu(tlv->len);
2478 if (buf_left < (sizeof(struct mwifiex_ie_types_header) + len)) {
2479 mwifiex_dbg(adapter, ERROR,
2480 "error processing scan response TLVs");
2485 case TLV_TYPE_CHANNEL_STATS:
2486 tlv_stat = (void *)tlv;
2487 mwifiex_update_chan_statistics(priv, tlv_stat);
2493 buf_left -= len + sizeof(struct mwifiex_ie_types_header);
2494 tlv = (void *)((u8 *)tlv + len +
2495 sizeof(struct mwifiex_ie_types_header));
2498 spin_lock_irqsave(&adapter->cmd_pending_q_lock, cmd_flags);
2499 spin_lock_irqsave(&adapter->scan_pending_q_lock, scan_flags);
2500 if (list_empty(&adapter->scan_pending_q)) {
2501 complete_scan = true;
2502 list_for_each_entry(cmd_node, &adapter->cmd_pending_q, list) {
2503 cmd_ptr = (void *)cmd_node->cmd_skb->data;
2504 if (le16_to_cpu(cmd_ptr->command) ==
2505 HostCmd_CMD_802_11_SCAN_EXT) {
2506 mwifiex_dbg(adapter, INFO,
2507 "Scan pending in command pending list");
2508 complete_scan = false;
2513 spin_unlock_irqrestore(&adapter->scan_pending_q_lock, scan_flags);
2514 spin_unlock_irqrestore(&adapter->cmd_pending_q_lock, cmd_flags);
2517 mwifiex_complete_scan(priv);
2522 /* This function This function handles the event extended scan report. It
2523 * parses extended scan results and informs to cfg80211 stack.
2525 int mwifiex_handle_event_ext_scan_report(struct mwifiex_private *priv,
2529 struct mwifiex_adapter *adapter = priv->adapter;
2531 u32 bytes_left, bytes_left_for_tlv, idx;
2533 struct mwifiex_ie_types_data *tlv;
2534 struct mwifiex_ie_types_bss_scan_rsp *scan_rsp_tlv;
2535 struct mwifiex_ie_types_bss_scan_info *scan_info_tlv;
2539 struct mwifiex_event_scan_result *event_scan = buf;
2540 u8 num_of_set = event_scan->num_of_set;
2541 u8 *scan_resp = buf + sizeof(struct mwifiex_event_scan_result);
2542 u16 scan_resp_size = le16_to_cpu(event_scan->buf_size);
2544 if (num_of_set > MWIFIEX_MAX_AP) {
2545 mwifiex_dbg(adapter, ERROR,
2546 "EXT_SCAN: Invalid number of AP returned (%d)!!\n",
2549 goto check_next_scan;
2552 bytes_left = scan_resp_size;
2553 mwifiex_dbg(adapter, INFO,
2554 "EXT_SCAN: size %d, returned %d APs...",
2555 scan_resp_size, num_of_set);
2556 mwifiex_dbg_dump(adapter, CMD_D, "EXT_SCAN buffer:", buf,
2558 sizeof(struct mwifiex_event_scan_result));
2560 tlv = (struct mwifiex_ie_types_data *)scan_resp;
2562 for (idx = 0; idx < num_of_set && bytes_left; idx++) {
2563 type = le16_to_cpu(tlv->header.type);
2564 len = le16_to_cpu(tlv->header.len);
2565 if (bytes_left < sizeof(struct mwifiex_ie_types_header) + len) {
2566 mwifiex_dbg(adapter, ERROR,
2567 "EXT_SCAN: Error bytes left < TLV length\n");
2570 scan_rsp_tlv = NULL;
2571 scan_info_tlv = NULL;
2572 bytes_left_for_tlv = bytes_left;
2574 /* BSS response TLV with beacon or probe response buffer
2575 * at the initial position of each descriptor
2577 if (type != TLV_TYPE_BSS_SCAN_RSP)
2580 bss_info = (u8 *)tlv;
2581 scan_rsp_tlv = (struct mwifiex_ie_types_bss_scan_rsp *)tlv;
2582 tlv = (struct mwifiex_ie_types_data *)(tlv->data + len);
2583 bytes_left_for_tlv -=
2584 (len + sizeof(struct mwifiex_ie_types_header));
2586 while (bytes_left_for_tlv >=
2587 sizeof(struct mwifiex_ie_types_header) &&
2588 le16_to_cpu(tlv->header.type) != TLV_TYPE_BSS_SCAN_RSP) {
2589 type = le16_to_cpu(tlv->header.type);
2590 len = le16_to_cpu(tlv->header.len);
2591 if (bytes_left_for_tlv <
2592 sizeof(struct mwifiex_ie_types_header) + len) {
2593 mwifiex_dbg(adapter, ERROR,
2594 "EXT_SCAN: Error in processing TLV,\t"
2595 "bytes left < TLV length\n");
2596 scan_rsp_tlv = NULL;
2597 bytes_left_for_tlv = 0;
2601 case TLV_TYPE_BSS_SCAN_INFO:
2603 (struct mwifiex_ie_types_bss_scan_info *)tlv;
2605 sizeof(struct mwifiex_ie_types_bss_scan_info) -
2606 sizeof(struct mwifiex_ie_types_header)) {
2607 bytes_left_for_tlv = 0;
2614 tlv = (struct mwifiex_ie_types_data *)(tlv->data + len);
2616 (len + sizeof(struct mwifiex_ie_types_header));
2617 bytes_left_for_tlv -=
2618 (len + sizeof(struct mwifiex_ie_types_header));
2624 /* Advance pointer to the beacon buffer length and
2625 * update the bytes count so that the function
2626 * wlan_interpret_bss_desc_with_ie() can handle the
2627 * scan buffer withut any change
2629 bss_info += sizeof(u16);
2630 bytes_left -= sizeof(u16);
2632 if (scan_info_tlv) {
2633 rssi = (s32)(s16)(le16_to_cpu(scan_info_tlv->rssi));
2634 rssi *= 100; /* Convert dBm to mBm */
2635 mwifiex_dbg(adapter, INFO,
2636 "info: InterpretIE: RSSI=%d\n", rssi);
2637 fw_tsf = le64_to_cpu(scan_info_tlv->tsf);
2638 radio_type = &scan_info_tlv->radio_type;
2642 ret = mwifiex_parse_single_response_buf(priv, &bss_info,
2643 &bytes_left, fw_tsf,
2644 radio_type, true, rssi);
2646 goto check_next_scan;
2650 if (!event_scan->more_event)
2651 mwifiex_check_next_scan_command(priv);
2657 * This function prepares command for background scan query.
2659 * Preparation includes -
2660 * - Setting command ID and proper size
2661 * - Setting background scan flush parameter
2662 * - Ensuring correct endian-ness
2664 int mwifiex_cmd_802_11_bg_scan_query(struct host_cmd_ds_command *cmd)
2666 struct host_cmd_ds_802_11_bg_scan_query *bg_query =
2667 &cmd->params.bg_scan_query;
2669 cmd->command = cpu_to_le16(HostCmd_CMD_802_11_BG_SCAN_QUERY);
2670 cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_802_11_bg_scan_query)
2673 bg_query->flush = 1;
2679 * This function inserts scan command node to the scan pending queue.
2682 mwifiex_queue_scan_cmd(struct mwifiex_private *priv,
2683 struct cmd_ctrl_node *cmd_node)
2685 struct mwifiex_adapter *adapter = priv->adapter;
2686 unsigned long flags;
2688 cmd_node->wait_q_enabled = true;
2689 cmd_node->condition = &adapter->scan_wait_q_woken;
2690 spin_lock_irqsave(&adapter->scan_pending_q_lock, flags);
2691 list_add_tail(&cmd_node->list, &adapter->scan_pending_q);
2692 spin_unlock_irqrestore(&adapter->scan_pending_q_lock, flags);
2696 * This function sends a scan command for all available channels to the
2697 * firmware, filtered on a specific SSID.
2699 static int mwifiex_scan_specific_ssid(struct mwifiex_private *priv,
2700 struct cfg80211_ssid *req_ssid)
2702 struct mwifiex_adapter *adapter = priv->adapter;
2704 struct mwifiex_user_scan_cfg *scan_cfg;
2706 if (adapter->scan_processing) {
2707 mwifiex_dbg(adapter, WARN,
2708 "cmd: Scan already in process...\n");
2712 if (priv->scan_block) {
2713 mwifiex_dbg(adapter, WARN,
2714 "cmd: Scan is blocked during association...\n");
2718 scan_cfg = kzalloc(sizeof(struct mwifiex_user_scan_cfg), GFP_KERNEL);
2722 scan_cfg->ssid_list = req_ssid;
2723 scan_cfg->num_ssids = 1;
2725 ret = mwifiex_scan_networks(priv, scan_cfg);
2732 * Sends IOCTL request to start a scan.
2734 * This function allocates the IOCTL request buffer, fills it
2735 * with requisite parameters and calls the IOCTL handler.
2737 * Scan command can be issued for both normal scan and specific SSID
2738 * scan, depending upon whether an SSID is provided or not.
2740 int mwifiex_request_scan(struct mwifiex_private *priv,
2741 struct cfg80211_ssid *req_ssid)
2745 if (down_interruptible(&priv->async_sem)) {
2746 mwifiex_dbg(priv->adapter, ERROR,
2747 "%s: acquire semaphore fail\n",
2752 priv->adapter->scan_wait_q_woken = false;
2754 if (req_ssid && req_ssid->ssid_len != 0)
2755 /* Specific SSID scan */
2756 ret = mwifiex_scan_specific_ssid(priv, req_ssid);
2759 ret = mwifiex_scan_networks(priv, NULL);
2761 up(&priv->async_sem);
2767 * This function appends the vendor specific IE TLV to a buffer.
2770 mwifiex_cmd_append_vsie_tlv(struct mwifiex_private *priv,
2771 u16 vsie_mask, u8 **buffer)
2773 int id, ret_len = 0;
2774 struct mwifiex_ie_types_vendor_param_set *vs_param_set;
2782 * Traverse through the saved vendor specific IE array and append
2783 * the selected(scan/assoc/adhoc) IE as TLV to the command
2785 for (id = 0; id < MWIFIEX_MAX_VSIE_NUM; id++) {
2786 if (priv->vs_ie[id].mask & vsie_mask) {
2788 (struct mwifiex_ie_types_vendor_param_set *)
2790 vs_param_set->header.type =
2791 cpu_to_le16(TLV_TYPE_PASSTHROUGH);
2792 vs_param_set->header.len =
2793 cpu_to_le16((((u16) priv->vs_ie[id].ie[1])
2795 memcpy(vs_param_set->ie, priv->vs_ie[id].ie,
2796 le16_to_cpu(vs_param_set->header.len));
2797 *buffer += le16_to_cpu(vs_param_set->header.len) +
2798 sizeof(struct mwifiex_ie_types_header);
2799 ret_len += le16_to_cpu(vs_param_set->header.len) +
2800 sizeof(struct mwifiex_ie_types_header);
2807 * This function saves a beacon buffer of the current BSS descriptor.
2809 * The current beacon buffer is saved so that it can be restored in the
2810 * following cases that makes the beacon buffer not to contain the current
2811 * ssid's beacon buffer.
2812 * - The current ssid was not found somehow in the last scan.
2813 * - The current ssid was the last entry of the scan table and overloaded.
2816 mwifiex_save_curr_bcn(struct mwifiex_private *priv)
2818 struct mwifiex_bssdescriptor *curr_bss =
2819 &priv->curr_bss_params.bss_descriptor;
2821 if (!curr_bss->beacon_buf_size)
2824 /* allocate beacon buffer at 1st time; or if it's size has changed */
2825 if (!priv->curr_bcn_buf ||
2826 priv->curr_bcn_size != curr_bss->beacon_buf_size) {
2827 priv->curr_bcn_size = curr_bss->beacon_buf_size;
2829 kfree(priv->curr_bcn_buf);
2830 priv->curr_bcn_buf = kmalloc(curr_bss->beacon_buf_size,
2832 if (!priv->curr_bcn_buf)
2836 memcpy(priv->curr_bcn_buf, curr_bss->beacon_buf,
2837 curr_bss->beacon_buf_size);
2838 mwifiex_dbg(priv->adapter, INFO,
2839 "info: current beacon saved %d\n",
2840 priv->curr_bcn_size);
2842 curr_bss->beacon_buf = priv->curr_bcn_buf;
2844 /* adjust the pointers in the current BSS descriptor */
2845 if (curr_bss->bcn_wpa_ie)
2846 curr_bss->bcn_wpa_ie =
2847 (struct ieee_types_vendor_specific *)
2848 (curr_bss->beacon_buf +
2849 curr_bss->wpa_offset);
2851 if (curr_bss->bcn_rsn_ie)
2852 curr_bss->bcn_rsn_ie = (struct ieee_types_generic *)
2853 (curr_bss->beacon_buf +
2854 curr_bss->rsn_offset);
2856 if (curr_bss->bcn_ht_cap)
2857 curr_bss->bcn_ht_cap = (struct ieee80211_ht_cap *)
2858 (curr_bss->beacon_buf +
2859 curr_bss->ht_cap_offset);
2861 if (curr_bss->bcn_ht_oper)
2862 curr_bss->bcn_ht_oper = (struct ieee80211_ht_operation *)
2863 (curr_bss->beacon_buf +
2864 curr_bss->ht_info_offset);
2866 if (curr_bss->bcn_vht_cap)
2867 curr_bss->bcn_vht_cap = (void *)(curr_bss->beacon_buf +
2868 curr_bss->vht_cap_offset);
2870 if (curr_bss->bcn_vht_oper)
2871 curr_bss->bcn_vht_oper = (void *)(curr_bss->beacon_buf +
2872 curr_bss->vht_info_offset);
2874 if (curr_bss->bcn_bss_co_2040)
2875 curr_bss->bcn_bss_co_2040 =
2876 (curr_bss->beacon_buf + curr_bss->bss_co_2040_offset);
2878 if (curr_bss->bcn_ext_cap)
2879 curr_bss->bcn_ext_cap = curr_bss->beacon_buf +
2880 curr_bss->ext_cap_offset;
2882 if (curr_bss->oper_mode)
2883 curr_bss->oper_mode = (void *)(curr_bss->beacon_buf +
2884 curr_bss->oper_mode_offset);
2888 * This function frees the current BSS descriptor beacon buffer.
2891 mwifiex_free_curr_bcn(struct mwifiex_private *priv)
2893 kfree(priv->curr_bcn_buf);
2894 priv->curr_bcn_buf = NULL;