Lines Matching +full:mu +full:- +full:side +full:- +full:b
1 // SPDX-License-Identifier: GPL-2.0-only
4 * Copyright 2003-2008, Jouni Malinen <j@w1.fi>
7 * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
9 * Copyright 2013-2014 Intel Mobile Communications GmbH
10 * Copyright (C) 2015 - 2017 Intel Deutschland GmbH
11 * Copyright (C) 2018 - 2020 Intel Corporation
29 #include "driver-ops.h"
97 * has happened -- the work that runs from this timer will
105 if (!timer_pending(&sdata->u.mgd.timer) || in run_again()
106 time_before(timeout, sdata->u.mgd.timer.expires)) in run_again()
107 mod_timer(&sdata->u.mgd.timer, timeout); in run_again()
112 if (sdata->vif.driver_flags & IEEE80211_VIF_BEACON_FILTER) in ieee80211_sta_reset_beacon_monitor()
115 if (ieee80211_hw_check(&sdata->local->hw, CONNECTION_MONITOR)) in ieee80211_sta_reset_beacon_monitor()
118 mod_timer(&sdata->u.mgd.bcn_mon_timer, in ieee80211_sta_reset_beacon_monitor()
119 round_jiffies_up(jiffies + sdata->u.mgd.beacon_timeout)); in ieee80211_sta_reset_beacon_monitor()
124 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_sta_reset_conn_monitor()
126 if (unlikely(!ifmgd->associated)) in ieee80211_sta_reset_conn_monitor()
129 if (ifmgd->probe_send_count) in ieee80211_sta_reset_conn_monitor()
130 ifmgd->probe_send_count = 0; in ieee80211_sta_reset_conn_monitor()
132 if (ieee80211_hw_check(&sdata->local->hw, CONNECTION_MONITOR)) in ieee80211_sta_reset_conn_monitor()
135 mod_timer(&ifmgd->conn_mon_timer, in ieee80211_sta_reset_conn_monitor()
141 return (1 << ecw) - 1; in ecw2cw()
155 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_determine_chantype()
161 chandef->chan = channel; in ieee80211_determine_chantype()
162 chandef->width = NL80211_CHAN_WIDTH_20_NOHT; in ieee80211_determine_chantype()
163 chandef->center_freq1 = channel->center_freq; in ieee80211_determine_chantype()
164 chandef->freq1_offset = channel->freq_offset; in ieee80211_determine_chantype()
166 if (channel->band == NL80211_BAND_6GHZ) { in ieee80211_determine_chantype()
175 } else if (sband->band == NL80211_BAND_S1GHZ) { in ieee80211_determine_chantype()
179 chandef->width = ieee80211_s1g_channel_width(channel); in ieee80211_determine_chantype()
189 memcpy(&sta_ht_cap, &sband->ht_cap, sizeof(sta_ht_cap)); in ieee80211_determine_chantype()
199 chandef->width = NL80211_CHAN_WIDTH_20; in ieee80211_determine_chantype()
201 ht_cfreq = ieee80211_channel_to_frequency(ht_oper->primary_chan, in ieee80211_determine_chantype()
202 channel->band); in ieee80211_determine_chantype()
204 if (!tracking && channel->center_freq != ht_cfreq) { in ieee80211_determine_chantype()
213 …"Wrong control channel: center-freq: %d ht-cfreq: %d ht->primary_chan: %d band: %d - Disabling HT\… in ieee80211_determine_chantype()
214 channel->center_freq, ht_cfreq, in ieee80211_determine_chantype()
215 ht_oper->primary_chan, channel->band); in ieee80211_determine_chantype()
233 if (!vht_oper || !sband->vht_cap.vht_supported) { in ieee80211_determine_chantype()
239 if (!(ifmgd->flags & IEEE80211_STA_DISABLE_HE) && he_oper && in ieee80211_determine_chantype()
240 (le32_to_cpu(he_oper->he_oper_params) & in ieee80211_determine_chantype()
248 memcpy(&he_oper_vht_cap, he_oper->optional, 3); in ieee80211_determine_chantype()
251 if (!ieee80211_chandef_vht_oper(&sdata->local->hw, vht_cap_info, in ieee80211_determine_chantype()
254 if (!(ifmgd->flags & IEEE80211_STA_DISABLE_HE)) in ieee80211_determine_chantype()
260 } else if (!ieee80211_chandef_vht_oper(&sdata->local->hw, in ieee80211_determine_chantype()
264 if (!(ifmgd->flags & IEEE80211_STA_DISABLE_VHT)) in ieee80211_determine_chantype()
272 if (!(ifmgd->flags & IEEE80211_STA_DISABLE_VHT)) in ieee80211_determine_chantype()
285 if (!(ifmgd->flags & IEEE80211_STA_DISABLE_VHT)) in ieee80211_determine_chantype()
300 * connection. This keeps us from playing ping-pong with regulatory, in ieee80211_determine_chantype()
302 * - connect to an AP with 80 MHz, world regdom allows 80 MHz in ieee80211_determine_chantype()
303 * - AP advertises regdom US in ieee80211_determine_chantype()
304 * - CRDA loads regdom US with 80 MHz prohibited (old database) in ieee80211_determine_chantype()
305 * - the code below detects an unsupported channel, downgrades, and in ieee80211_determine_chantype()
307 * - disconnect causes CRDA to reload world regdomain and the game in ieee80211_determine_chantype()
316 cfg80211_chandef_identical(chandef, &sdata->vif.bss_conf.chandef)) in ieee80211_determine_chantype()
325 * tracking the APs beacon for bandwidth changes - otherwise we in ieee80211_determine_chantype()
331 while (!cfg80211_chandef_usable(sdata->local->hw.wiphy, chandef, in ieee80211_determine_chantype()
334 if (WARN_ON(chandef->width == NL80211_CHAN_WIDTH_20_NOHT)) { in ieee80211_determine_chantype()
344 if (!he_oper || !cfg80211_chandef_usable(sdata->wdev.wiphy, chandef, in ieee80211_determine_chantype()
348 if (chandef->width != vht_chandef.width && !tracking) in ieee80211_determine_chantype()
366 struct ieee80211_local *local = sdata->local; in ieee80211_config_bw()
367 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_config_bw()
368 struct ieee80211_channel *chan = sdata->vif.bss_conf.chandef.chan; in ieee80211_config_bw()
370 local->hw.wiphy->bands[chan->band]; in ieee80211_config_bw()
379 if (ifmgd->flags & IEEE80211_STA_DISABLE_HT || !ht_oper) in ieee80211_config_bw()
382 /* don't check VHT if we associated as non-VHT station */ in ieee80211_config_bw()
383 if (ifmgd->flags & IEEE80211_STA_DISABLE_VHT) in ieee80211_config_bw()
386 /* don't check HE if we associated as non-HE station */ in ieee80211_config_bw()
387 if (ifmgd->flags & IEEE80211_STA_DISABLE_HE || in ieee80211_config_bw()
392 return -EINVAL; in ieee80211_config_bw()
395 * if bss configuration changed store the new one - in ieee80211_config_bw()
398 ht_opmode = le16_to_cpu(ht_oper->operation_mode); in ieee80211_config_bw()
399 if (sdata->vif.bss_conf.ht_operation_mode != ht_opmode) { in ieee80211_config_bw()
401 sdata->vif.bss_conf.ht_operation_mode = ht_opmode; in ieee80211_config_bw()
405 vht_cap_info = le32_to_cpu(vht_cap->vht_cap_info); in ieee80211_config_bw()
417 * any good -- we couldn't use it with the AP. in ieee80211_config_bw()
419 if (ifmgd->flags & IEEE80211_STA_DISABLE_80P80MHZ && in ieee80211_config_bw()
422 if (ifmgd->flags & IEEE80211_STA_DISABLE_160MHZ && in ieee80211_config_bw()
425 if (ifmgd->flags & IEEE80211_STA_DISABLE_40MHZ && in ieee80211_config_bw()
429 if (cfg80211_chandef_identical(&chandef, &sdata->vif.bss_conf.chandef)) in ieee80211_config_bw()
435 ifmgd->bssid, chandef.chan->center_freq, in ieee80211_config_bw()
436 chandef.chan->freq_offset, chandef.width, in ieee80211_config_bw()
440 if (flags != (ifmgd->flags & (IEEE80211_STA_DISABLE_HT | in ieee80211_config_bw()
448 "AP %pM changed bandwidth in a way we can't support - disconnect\n", in ieee80211_config_bw()
449 ifmgd->bssid); in ieee80211_config_bw()
450 return -EINVAL; in ieee80211_config_bw()
469 return -EINVAL; in ieee80211_config_bw()
472 if (new_sta_bw > sta->cur_max_bandwidth) in ieee80211_config_bw()
473 new_sta_bw = sta->cur_max_bandwidth; in ieee80211_config_bw()
475 if (new_sta_bw < sta->sta.bandwidth) { in ieee80211_config_bw()
476 sta->sta.bandwidth = new_sta_bw; in ieee80211_config_bw()
484 "AP %pM changed bandwidth to incompatible one - disconnect\n", in ieee80211_config_bw()
485 ifmgd->bssid); in ieee80211_config_bw()
489 if (new_sta_bw > sta->sta.bandwidth) { in ieee80211_config_bw()
490 sta->sta.bandwidth = new_sta_bw; in ieee80211_config_bw()
507 u32 flags = channel->flags; in ieee80211_add_ht_ie()
511 BUILD_BUG_ON(sizeof(ht_cap) != sizeof(sband->ht_cap)); in ieee80211_add_ht_ie()
513 memcpy(&ht_cap, &sband->ht_cap, sizeof(ht_cap)); in ieee80211_add_ht_ie()
536 * capable of 40 MHz -- some broken APs will never fall in ieee80211_add_ht_ie()
539 if (sdata->u.mgd.flags & IEEE80211_STA_DISABLE_40MHZ) { in ieee80211_add_ht_ie()
572 * Note - the function may set the owner of the MU-MIMO capability
579 struct ieee80211_local *local = sdata->local; in ieee80211_add_vht_ie()
585 BUILD_BUG_ON(sizeof(vht_cap) != sizeof(sband->vht_cap)); in ieee80211_add_vht_ie()
587 memcpy(&vht_cap, &sband->vht_cap, sizeof(vht_cap)); in ieee80211_add_vht_ie()
593 if (sdata->u.mgd.flags & IEEE80211_STA_DISABLE_80P80MHZ) { in ieee80211_add_vht_ie()
602 if (sdata->u.mgd.flags & IEEE80211_STA_DISABLE_160MHZ) { in ieee80211_add_vht_ie()
611 if (!(ap_vht_cap->vht_cap_info & in ieee80211_add_vht_ie()
615 else if (!(ap_vht_cap->vht_cap_info & in ieee80211_add_vht_ie()
620 * If some other vif is using the MU-MIMO capablity we cannot associate in ieee80211_add_vht_ie()
621 * using MU-MIMO - this will lead to contradictions in the group-id in ieee80211_add_vht_ie()
624 * simultaneous associations with MU-MIMO. in ieee80211_add_vht_ie()
630 list_for_each_entry_rcu(other, &local->interfaces, list) { in ieee80211_add_vht_ie()
631 if (other->vif.mu_mimo_owner) { in ieee80211_add_vht_ie()
639 sdata->vif.mu_mimo_owner = true; in ieee80211_add_vht_ie()
644 ap_bf_sts = le32_to_cpu(ap_vht_cap->vht_cap_info) & mask; in ieee80211_add_vht_ie()
671 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); in ieee80211_add_he_ie()
673 reg_cap = cfg80211_chandef_usable(sdata->wdev.wiphy, in ieee80211_add_he_ie()
674 &chanctx_conf->def, in ieee80211_add_he_ie()
688 2 + 1 + sizeof(he_cap->he_cap_elem) + in ieee80211_add_he_ie()
689 ieee80211_he_mcs_nss_size(&he_cap->he_cap_elem) + in ieee80211_add_he_ie()
690 ieee80211_he_ppe_size(he_cap->ppe_thres[0], in ieee80211_add_he_ie()
691 he_cap->he_cap_elem.phy_cap_info); in ieee80211_add_he_ie()
700 struct ieee80211_local *local = sdata->local; in ieee80211_send_assoc()
701 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_send_assoc()
702 struct ieee80211_mgd_assoc_data *assoc_data = ifmgd->assoc_data; in ieee80211_send_assoc()
717 if (assoc_data->ie_len) in ieee80211_send_assoc()
719 assoc_data->ie, in ieee80211_send_assoc()
720 assoc_data->ie_len); in ieee80211_send_assoc()
725 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); in ieee80211_send_assoc()
730 chan = chanctx_conf->def.chan; in ieee80211_send_assoc()
732 sband = local->hw.wiphy->bands[chan->band]; in ieee80211_send_assoc()
733 shift = ieee80211_vif_get_shift(&sdata->vif); in ieee80211_send_assoc()
735 if (assoc_data->supp_rates_len) { in ieee80211_send_assoc()
739 * in the association request (e.g. D-Link DAP 1353 in in ieee80211_send_assoc()
740 * b-only mode)... in ieee80211_send_assoc()
742 rates_len = ieee80211_parse_bitrates(&chanctx_conf->def, sband, in ieee80211_send_assoc()
743 assoc_data->supp_rates, in ieee80211_send_assoc()
744 assoc_data->supp_rates_len, in ieee80211_send_assoc()
753 for (i = 0; i < sband->n_bitrates; i++) { in ieee80211_send_assoc()
759 skb = alloc_skb(local->hw.extra_tx_headroom + in ieee80211_send_assoc()
761 2 + assoc_data->ssid_len + /* SSID */ in ieee80211_send_assoc()
764 2 + 2 * sband->n_channels + /* supported channels */ in ieee80211_send_assoc()
771 assoc_data->ie_len + /* extra IEs */ in ieee80211_send_assoc()
772 (assoc_data->fils_kek_len ? 16 /* AES-SIV */ : 0) + in ieee80211_send_assoc()
778 skb_reserve(skb, local->hw.extra_tx_headroom); in ieee80211_send_assoc()
782 if (sband->band == NL80211_BAND_2GHZ) { in ieee80211_send_assoc()
787 if (assoc_data->capability & WLAN_CAPABILITY_PRIVACY) in ieee80211_send_assoc()
790 if ((assoc_data->capability & WLAN_CAPABILITY_SPECTRUM_MGMT) && in ieee80211_send_assoc()
791 ieee80211_hw_check(&local->hw, SPECTRUM_MGMT)) in ieee80211_send_assoc()
794 if (ifmgd->flags & IEEE80211_STA_ENABLE_RRM) in ieee80211_send_assoc()
798 memcpy(mgmt->da, assoc_data->bss->bssid, ETH_ALEN); in ieee80211_send_assoc()
799 memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN); in ieee80211_send_assoc()
800 memcpy(mgmt->bssid, assoc_data->bss->bssid, ETH_ALEN); in ieee80211_send_assoc()
802 listen_int = cpu_to_le16(sband->band == NL80211_BAND_S1GHZ ? in ieee80211_send_assoc()
803 ieee80211_encode_usf(local->hw.conf.listen_interval) : in ieee80211_send_assoc()
804 local->hw.conf.listen_interval); in ieee80211_send_assoc()
805 if (!is_zero_ether_addr(assoc_data->prev_bssid)) { in ieee80211_send_assoc()
807 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | in ieee80211_send_assoc()
809 mgmt->u.reassoc_req.capab_info = cpu_to_le16(capab); in ieee80211_send_assoc()
810 mgmt->u.reassoc_req.listen_interval = listen_int; in ieee80211_send_assoc()
811 memcpy(mgmt->u.reassoc_req.current_ap, assoc_data->prev_bssid, in ieee80211_send_assoc()
815 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | in ieee80211_send_assoc()
817 mgmt->u.assoc_req.capab_info = cpu_to_le16(capab); in ieee80211_send_assoc()
818 mgmt->u.assoc_req.listen_interval = listen_int; in ieee80211_send_assoc()
822 pos = skb_put(skb, 2 + assoc_data->ssid_len); in ieee80211_send_assoc()
825 *pos++ = assoc_data->ssid_len; in ieee80211_send_assoc()
826 memcpy(pos, assoc_data->ssid, assoc_data->ssid_len); in ieee80211_send_assoc()
828 if (sband->band == NL80211_BAND_S1GHZ) in ieee80211_send_assoc()
841 for (i = 0; i < sband->n_bitrates; i++) { in ieee80211_send_assoc()
843 int rate = DIV_ROUND_UP(sband->bitrates[i].bitrate, in ieee80211_send_assoc()
852 pos = skb_put(skb, rates_len - count + 2); in ieee80211_send_assoc()
854 *pos++ = rates_len - count; in ieee80211_send_assoc()
856 for (i++; i < sband->n_bitrates; i++) { in ieee80211_send_assoc()
859 rate = DIV_ROUND_UP(sband->bitrates[i].bitrate, in ieee80211_send_assoc()
874 *pos++ = ieee80211_chandef_max_power(&chanctx_conf->def); in ieee80211_send_assoc()
883 (sband->band != NL80211_BAND_6GHZ || in ieee80211_send_assoc()
884 !ext_capa || ext_capa->datalen < 1 || in ieee80211_send_assoc()
885 !(ext_capa->data[0] & WLAN_EXT_CAPA1_EXT_CHANNEL_SWITCHING))) { in ieee80211_send_assoc()
887 pos = skb_put(skb, 2 * sband->n_channels + 2); in ieee80211_send_assoc()
889 *pos++ = 2 * sband->n_channels; in ieee80211_send_assoc()
890 for (i = 0; i < sband->n_channels; i++) { in ieee80211_send_assoc()
892 sband->channels[i].center_freq); in ieee80211_send_assoc()
898 if (ieee80211_hw_check(&local->hw, SUPPORTS_ONLY_HE_MULTI_BSSID) && in ieee80211_send_assoc()
899 !(ifmgd->flags & IEEE80211_STA_DISABLE_HE) && assoc_data->ie_len && in ieee80211_send_assoc()
900 ext_capa && ext_capa->datalen >= 3) in ieee80211_send_assoc()
901 ext_capa->data[2] |= WLAN_EXT_CAPA3_MULTI_BSSID_SUPPORT; in ieee80211_send_assoc()
904 if (assoc_data->ie_len) { in ieee80211_send_assoc()
928 /* 60 GHz (Multi-band, DMG, MMS) can't happen */ in ieee80211_send_assoc()
933 noffset = ieee80211_ie_split_ric(assoc_data->ie, in ieee80211_send_assoc()
934 assoc_data->ie_len, in ieee80211_send_assoc()
940 skb_put_data(skb, assoc_data->ie + offset, noffset - offset); in ieee80211_send_assoc()
944 if (WARN_ON_ONCE((ifmgd->flags & IEEE80211_STA_DISABLE_HT) && in ieee80211_send_assoc()
945 !(ifmgd->flags & IEEE80211_STA_DISABLE_VHT))) in ieee80211_send_assoc()
946 ifmgd->flags |= IEEE80211_STA_DISABLE_VHT; in ieee80211_send_assoc()
948 if (sband->band != NL80211_BAND_6GHZ && in ieee80211_send_assoc()
949 !(ifmgd->flags & IEEE80211_STA_DISABLE_HT)) in ieee80211_send_assoc()
950 ieee80211_add_ht_ie(sdata, skb, assoc_data->ap_ht_param, in ieee80211_send_assoc()
951 sband, chan, sdata->smps_mode); in ieee80211_send_assoc()
954 if (assoc_data->ie_len) { in ieee80211_send_assoc()
965 /* 60 GHz (Multi-band, DMG, MMS) can't happen */ in ieee80211_send_assoc()
969 noffset = ieee80211_ie_split(assoc_data->ie, assoc_data->ie_len, in ieee80211_send_assoc()
972 skb_put_data(skb, assoc_data->ie + offset, noffset - offset); in ieee80211_send_assoc()
977 if (assoc_data->ie_len) { in ieee80211_send_assoc()
995 noffset = ieee80211_ie_split(assoc_data->ie, assoc_data->ie_len, in ieee80211_send_assoc()
998 pos = skb_put(skb, noffset - offset); in ieee80211_send_assoc()
999 memcpy(pos, assoc_data->ie + offset, noffset - offset); in ieee80211_send_assoc()
1003 if (sband->band != NL80211_BAND_6GHZ && in ieee80211_send_assoc()
1004 !(ifmgd->flags & IEEE80211_STA_DISABLE_VHT)) in ieee80211_send_assoc()
1006 &assoc_data->ap_vht_cap); in ieee80211_send_assoc()
1012 if (ifmgd->flags & IEEE80211_STA_DISABLE_HT || in ieee80211_send_assoc()
1013 (sband->band == NL80211_BAND_5GHZ && in ieee80211_send_assoc()
1014 ifmgd->flags & IEEE80211_STA_DISABLE_VHT)) in ieee80211_send_assoc()
1015 ifmgd->flags |= IEEE80211_STA_DISABLE_HE; in ieee80211_send_assoc()
1017 if (!(ifmgd->flags & IEEE80211_STA_DISABLE_HE)) in ieee80211_send_assoc()
1020 /* if present, add any custom non-vendor IEs that go after HE */ in ieee80211_send_assoc()
1021 if (assoc_data->ie_len) { in ieee80211_send_assoc()
1022 noffset = ieee80211_ie_split_vendor(assoc_data->ie, in ieee80211_send_assoc()
1023 assoc_data->ie_len, in ieee80211_send_assoc()
1025 skb_put_data(skb, assoc_data->ie + offset, noffset - offset); in ieee80211_send_assoc()
1029 if (assoc_data->wmm) { in ieee80211_send_assoc()
1030 if (assoc_data->uapsd) { in ieee80211_send_assoc()
1031 qos_info = ifmgd->uapsd_queues; in ieee80211_send_assoc()
1032 qos_info |= (ifmgd->uapsd_max_sp_len << in ieee80211_send_assoc()
1041 if (sband->band == NL80211_BAND_S1GHZ) { in ieee80211_send_assoc()
1043 ieee80211_add_s1g_capab_ie(sdata, &sband->s1g_cap, skb); in ieee80211_send_assoc()
1047 if (assoc_data->ie_len) { in ieee80211_send_assoc()
1048 noffset = assoc_data->ie_len; in ieee80211_send_assoc()
1049 skb_put_data(skb, assoc_data->ie + offset, noffset - offset); in ieee80211_send_assoc()
1052 if (assoc_data->fils_kek_len && in ieee80211_send_assoc()
1059 kfree(ifmgd->assoc_req_ies); in ieee80211_send_assoc()
1060 ifmgd->assoc_req_ies = kmemdup(ie_start, pos - ie_start, GFP_ATOMIC); in ieee80211_send_assoc()
1061 ifmgd->assoc_req_ies_len = pos - ie_start; in ieee80211_send_assoc()
1065 IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; in ieee80211_send_assoc()
1066 if (ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS)) in ieee80211_send_assoc()
1067 IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS | in ieee80211_send_assoc()
1078 skb = ieee80211_pspoll_get(&local->hw, &sdata->vif); in ieee80211_send_pspoll()
1082 pspoll = (struct ieee80211_pspoll *) skb->data; in ieee80211_send_pspoll()
1083 pspoll->frame_control |= cpu_to_le16(IEEE80211_FCTL_PM); in ieee80211_send_pspoll()
1085 IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; in ieee80211_send_pspoll()
1095 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_send_nullfunc()
1097 skb = ieee80211_nullfunc_get(&local->hw, &sdata->vif, in ieee80211_send_nullfunc()
1098 !ieee80211_hw_check(&local->hw, DOESNT_SUPPORT_QOS_NDP)); in ieee80211_send_nullfunc()
1102 nullfunc = (struct ieee80211_hdr_3addr *) skb->data; in ieee80211_send_nullfunc()
1104 nullfunc->frame_control |= cpu_to_le16(IEEE80211_FCTL_PM); in ieee80211_send_nullfunc()
1106 IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT | in ieee80211_send_nullfunc()
1109 if (ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS)) in ieee80211_send_nullfunc()
1110 IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS; in ieee80211_send_nullfunc()
1112 if (ifmgd->flags & IEEE80211_STA_CONNECTION_POLL) in ieee80211_send_nullfunc()
1113 IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_CTL_USE_MINRATE; in ieee80211_send_nullfunc()
1125 if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_STATION)) in ieee80211_send_4addr_nullfunc()
1128 skb = dev_alloc_skb(local->hw.extra_tx_headroom + 30); in ieee80211_send_4addr_nullfunc()
1132 skb_reserve(skb, local->hw.extra_tx_headroom); in ieee80211_send_4addr_nullfunc()
1137 nullfunc->frame_control = fc; in ieee80211_send_4addr_nullfunc()
1138 memcpy(nullfunc->addr1, sdata->u.mgd.bssid, ETH_ALEN); in ieee80211_send_4addr_nullfunc()
1139 memcpy(nullfunc->addr2, sdata->vif.addr, ETH_ALEN); in ieee80211_send_4addr_nullfunc()
1140 memcpy(nullfunc->addr3, sdata->u.mgd.bssid, ETH_ALEN); in ieee80211_send_4addr_nullfunc()
1141 memcpy(nullfunc->addr4, sdata->vif.addr, ETH_ALEN); in ieee80211_send_4addr_nullfunc()
1143 IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; in ieee80211_send_4addr_nullfunc()
1152 struct ieee80211_local *local = sdata->local; in ieee80211_chswitch_work()
1153 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_chswitch_work()
1160 mutex_lock(&local->mtx); in ieee80211_chswitch_work()
1161 mutex_lock(&local->chanctx_mtx); in ieee80211_chswitch_work()
1163 if (!ifmgd->associated) in ieee80211_chswitch_work()
1166 if (!sdata->vif.csa_active) in ieee80211_chswitch_work()
1171 * with multi-vif. once reservation is complete it will re-schedule the in ieee80211_chswitch_work()
1176 if (sdata->reserved_chanctx) { in ieee80211_chswitch_work()
1182 * with multi-vif csa driver may call ieee80211_csa_finish() in ieee80211_chswitch_work()
1186 if (sdata->reserved_ready) in ieee80211_chswitch_work()
1189 if (sdata->vif.bss_conf.chandef.width != in ieee80211_chswitch_work()
1190 sdata->csa_chandef.width) { in ieee80211_chswitch_work()
1201 switch (sdata->csa_chandef.width) { in ieee80211_chswitch_work()
1219 mgd_sta = sta_info_get(sdata, ifmgd->bssid); in ieee80211_chswitch_work()
1221 local->hw.wiphy->bands[sdata->csa_chandef.chan->band]; in ieee80211_chswitch_work()
1224 if (sdata->vif.bss_conf.chandef.width > in ieee80211_chswitch_work()
1225 sdata->csa_chandef.width) { in ieee80211_chswitch_work()
1226 mgd_sta->sta.bandwidth = bw; in ieee80211_chswitch_work()
1236 ieee80211_queue_work(&sdata->local->hw, in ieee80211_chswitch_work()
1237 &ifmgd->csa_connection_drop_work); in ieee80211_chswitch_work()
1241 if (sdata->vif.bss_conf.chandef.width < in ieee80211_chswitch_work()
1242 sdata->csa_chandef.width) { in ieee80211_chswitch_work()
1243 mgd_sta->sta.bandwidth = bw; in ieee80211_chswitch_work()
1251 if (!cfg80211_chandef_identical(&sdata->vif.bss_conf.chandef, in ieee80211_chswitch_work()
1252 &sdata->csa_chandef)) { in ieee80211_chswitch_work()
1255 ieee80211_queue_work(&sdata->local->hw, in ieee80211_chswitch_work()
1256 &ifmgd->csa_connection_drop_work); in ieee80211_chswitch_work()
1260 ifmgd->csa_waiting_bcn = true; in ieee80211_chswitch_work()
1266 mutex_unlock(&local->chanctx_mtx); in ieee80211_chswitch_work()
1267 mutex_unlock(&local->mtx); in ieee80211_chswitch_work()
1273 struct ieee80211_local *local = sdata->local; in ieee80211_chswitch_post_beacon()
1274 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_chswitch_post_beacon()
1279 WARN_ON(!sdata->vif.csa_active); in ieee80211_chswitch_post_beacon()
1281 if (sdata->csa_block_tx) { in ieee80211_chswitch_post_beacon()
1284 sdata->csa_block_tx = false; in ieee80211_chswitch_post_beacon()
1287 sdata->vif.csa_active = false; in ieee80211_chswitch_post_beacon()
1288 ifmgd->csa_waiting_bcn = false; in ieee80211_chswitch_post_beacon()
1293 ifmgd->beacon_crc_valid = false; in ieee80211_chswitch_post_beacon()
1299 ieee80211_queue_work(&local->hw, in ieee80211_chswitch_post_beacon()
1300 &ifmgd->csa_connection_drop_work); in ieee80211_chswitch_post_beacon()
1304 cfg80211_ch_switch_notify(sdata->dev, &sdata->reserved_chandef); in ieee80211_chswitch_post_beacon()
1310 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_chswitch_done()
1316 ieee80211_queue_work(&sdata->local->hw, in ieee80211_chswitch_done()
1317 &ifmgd->csa_connection_drop_work); in ieee80211_chswitch_done()
1319 ieee80211_queue_work(&sdata->local->hw, &ifmgd->chswitch_work); in ieee80211_chswitch_done()
1329 ieee80211_queue_work(&sdata->local->hw, &sdata->u.mgd.chswitch_work); in ieee80211_chswitch_timer()
1335 struct ieee80211_local *local = sdata->local; in ieee80211_sta_abort_chanswitch()
1337 if (!local->ops->abort_channel_switch) in ieee80211_sta_abort_chanswitch()
1340 mutex_lock(&local->mtx); in ieee80211_sta_abort_chanswitch()
1342 mutex_lock(&local->chanctx_mtx); in ieee80211_sta_abort_chanswitch()
1344 mutex_unlock(&local->chanctx_mtx); in ieee80211_sta_abort_chanswitch()
1346 if (sdata->csa_block_tx) in ieee80211_sta_abort_chanswitch()
1350 sdata->csa_block_tx = false; in ieee80211_sta_abort_chanswitch()
1351 sdata->vif.csa_active = false; in ieee80211_sta_abort_chanswitch()
1353 mutex_unlock(&local->mtx); in ieee80211_sta_abort_chanswitch()
1364 struct ieee80211_local *local = sdata->local; in ieee80211_sta_process_chanswitch()
1365 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_sta_process_chanswitch()
1366 struct cfg80211_bss *cbss = ifmgd->associated; in ieee80211_sta_process_chanswitch()
1380 if (local->scanning) in ieee80211_sta_process_chanswitch()
1383 current_band = cbss->channel->band; in ieee80211_sta_process_chanswitch()
1384 bss = (void *)cbss->priv; in ieee80211_sta_process_chanswitch()
1386 bss->vht_cap_info, in ieee80211_sta_process_chanswitch()
1387 ifmgd->flags, in ieee80211_sta_process_chanswitch()
1388 ifmgd->associated->bssid, &csa_ie); in ieee80211_sta_process_chanswitch()
1400 ieee80211_queue_work(&local->hw, in ieee80211_sta_process_chanswitch()
1401 &ifmgd->csa_connection_drop_work); in ieee80211_sta_process_chanswitch()
1405 if (beacon && sdata->vif.csa_active && !ifmgd->csa_waiting_bcn) { in ieee80211_sta_process_chanswitch()
1411 } else if (sdata->vif.csa_active || res) { in ieee80211_sta_process_chanswitch()
1416 if (!cfg80211_chandef_usable(local->hw.wiphy, &csa_ie.chandef, in ieee80211_sta_process_chanswitch()
1422 ifmgd->associated->bssid, in ieee80211_sta_process_chanswitch()
1423 csa_ie.chandef.chan->center_freq, in ieee80211_sta_process_chanswitch()
1424 csa_ie.chandef.chan->freq_offset, in ieee80211_sta_process_chanswitch()
1428 ieee80211_queue_work(&local->hw, in ieee80211_sta_process_chanswitch()
1429 &ifmgd->csa_connection_drop_work); in ieee80211_sta_process_chanswitch()
1434 &sdata->vif.bss_conf.chandef) && in ieee80211_sta_process_chanswitch()
1436 if (ifmgd->csa_ignored_same_chan) in ieee80211_sta_process_chanswitch()
1440 ifmgd->associated->bssid); in ieee80211_sta_process_chanswitch()
1441 ifmgd->csa_ignored_same_chan = true; in ieee80211_sta_process_chanswitch()
1446 * Drop all TDLS peers - either we disconnect or move to a different in ieee80211_sta_process_chanswitch()
1453 mutex_lock(&local->mtx); in ieee80211_sta_process_chanswitch()
1454 mutex_lock(&local->chanctx_mtx); in ieee80211_sta_process_chanswitch()
1455 conf = rcu_dereference_protected(sdata->vif.chanctx_conf, in ieee80211_sta_process_chanswitch()
1456 lockdep_is_held(&local->chanctx_mtx)); in ieee80211_sta_process_chanswitch()
1465 if (local->use_chanctx && in ieee80211_sta_process_chanswitch()
1466 !ieee80211_hw_check(&local->hw, CHANCTX_STA_CSA)) { in ieee80211_sta_process_chanswitch()
1468 "driver doesn't support chan-switch with channel contexts\n"); in ieee80211_sta_process_chanswitch()
1479 chanctx->mode, false); in ieee80211_sta_process_chanswitch()
1486 mutex_unlock(&local->chanctx_mtx); in ieee80211_sta_process_chanswitch()
1488 sdata->vif.csa_active = true; in ieee80211_sta_process_chanswitch()
1489 sdata->csa_chandef = csa_ie.chandef; in ieee80211_sta_process_chanswitch()
1490 sdata->csa_block_tx = csa_ie.mode; in ieee80211_sta_process_chanswitch()
1491 ifmgd->csa_ignored_same_chan = false; in ieee80211_sta_process_chanswitch()
1493 if (sdata->csa_block_tx) in ieee80211_sta_process_chanswitch()
1496 mutex_unlock(&local->mtx); in ieee80211_sta_process_chanswitch()
1498 cfg80211_ch_switch_started_notify(sdata->dev, &csa_ie.chandef, in ieee80211_sta_process_chanswitch()
1501 if (local->ops->channel_switch) { in ieee80211_sta_process_chanswitch()
1509 ieee80211_queue_work(&local->hw, &ifmgd->chswitch_work); in ieee80211_sta_process_chanswitch()
1511 mod_timer(&ifmgd->chswitch_timer, in ieee80211_sta_process_chanswitch()
1512 TU_TO_EXP_TIME((csa_ie.count - 1) * in ieee80211_sta_process_chanswitch()
1513 cbss->beacon_interval)); in ieee80211_sta_process_chanswitch()
1523 sdata->vif.csa_active = true; in ieee80211_sta_process_chanswitch()
1524 sdata->csa_block_tx = csa_ie.mode; in ieee80211_sta_process_chanswitch()
1526 ieee80211_queue_work(&local->hw, &ifmgd->csa_connection_drop_work); in ieee80211_sta_process_chanswitch()
1527 mutex_unlock(&local->chanctx_mtx); in ieee80211_sta_process_chanswitch()
1528 mutex_unlock(&local->mtx); in ieee80211_sta_process_chanswitch()
1539 int chan = ieee80211_frequency_to_channel(channel->center_freq); in ieee80211_find_80211h_pwr_constr()
1548 country_ie_len -= 3; in ieee80211_find_80211h_pwr_constr()
1550 switch (channel->band) { in ieee80211_find_80211h_pwr_constr()
1566 u8 first_channel = triplet->chans.first_channel; in ieee80211_find_80211h_pwr_constr()
1571 for (i = 0; i < triplet->chans.num_channels; i++) { in ieee80211_find_80211h_pwr_constr()
1574 *chan_pwr = triplet->chans.max_power; in ieee80211_find_80211h_pwr_constr()
1583 country_ie_len -= 3; in ieee80211_find_80211h_pwr_constr()
1601 * APs clearly state the range is -127 to 127 dBm, which indicates in ieee80211_find_cisco_dtpc()
1619 __le16 capab = mgmt->u.probe_resp.capab_info; in ieee80211_handle_pwr_constr()
1621 if (ieee80211_is_s1g_beacon(mgmt->frame_control)) in ieee80211_handle_pwr_constr()
1631 max_t(int, 0, chan_pwr - pwr_reduction_80211h); in ieee80211_handle_pwr_constr()
1650 if (sdata->ap_power_level == new_ap_level) in ieee80211_handle_pwr_constr()
1654 "Limiting TX power to %d (%d - %d) dBm as advertised by %pM\n", in ieee80211_handle_pwr_constr()
1656 sdata->u.mgd.bssid); in ieee80211_handle_pwr_constr()
1660 if (sdata->ap_power_level == new_ap_level) in ieee80211_handle_pwr_constr()
1665 pwr_level_cisco, sdata->u.mgd.bssid); in ieee80211_handle_pwr_constr()
1668 sdata->ap_power_level = new_ap_level; in ieee80211_handle_pwr_constr()
1678 struct ieee80211_conf *conf = &local->hw.conf; in ieee80211_enable_ps()
1684 if (local->scanning) in ieee80211_enable_ps()
1687 if (conf->dynamic_ps_timeout > 0 && in ieee80211_enable_ps()
1688 !ieee80211_hw_check(&local->hw, SUPPORTS_DYNAMIC_PS)) { in ieee80211_enable_ps()
1689 mod_timer(&local->dynamic_ps_timer, jiffies + in ieee80211_enable_ps()
1690 msecs_to_jiffies(conf->dynamic_ps_timeout)); in ieee80211_enable_ps()
1692 if (ieee80211_hw_check(&local->hw, PS_NULLFUNC_STACK)) in ieee80211_enable_ps()
1695 if (ieee80211_hw_check(&local->hw, PS_NULLFUNC_STACK) && in ieee80211_enable_ps()
1696 ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS)) in ieee80211_enable_ps()
1699 conf->flags |= IEEE80211_CONF_PS; in ieee80211_enable_ps()
1706 struct ieee80211_conf *conf = &local->hw.conf; in ieee80211_change_ps()
1708 if (local->ps_sdata) { in ieee80211_change_ps()
1709 ieee80211_enable_ps(local, local->ps_sdata); in ieee80211_change_ps()
1710 } else if (conf->flags & IEEE80211_CONF_PS) { in ieee80211_change_ps()
1711 conf->flags &= ~IEEE80211_CONF_PS; in ieee80211_change_ps()
1713 del_timer_sync(&local->dynamic_ps_timer); in ieee80211_change_ps()
1714 cancel_work_sync(&local->dynamic_ps_enable_work); in ieee80211_change_ps()
1720 struct ieee80211_if_managed *mgd = &sdata->u.mgd; in ieee80211_powersave_allowed()
1724 if (!mgd->powersave) in ieee80211_powersave_allowed()
1727 if (mgd->broken_ap) in ieee80211_powersave_allowed()
1730 if (!mgd->associated) in ieee80211_powersave_allowed()
1733 if (mgd->flags & IEEE80211_STA_CONNECTION_POLL) in ieee80211_powersave_allowed()
1736 if (!mgd->have_beacon) in ieee80211_powersave_allowed()
1740 sta = sta_info_get(sdata, mgd->bssid); in ieee80211_powersave_allowed()
1755 if (!ieee80211_hw_check(&local->hw, SUPPORTS_PS)) { in ieee80211_recalc_ps()
1756 local->ps_sdata = NULL; in ieee80211_recalc_ps()
1760 list_for_each_entry(sdata, &local->interfaces, list) { in ieee80211_recalc_ps()
1763 if (sdata->vif.type == NL80211_IFTYPE_AP) { in ieee80211_recalc_ps()
1771 if (sdata->vif.type != NL80211_IFTYPE_STATION) in ieee80211_recalc_ps()
1778 u8 dtimper = found->u.mgd.dtim_period; in ieee80211_recalc_ps()
1780 timeout = local->dynamic_ps_forced_timeout; in ieee80211_recalc_ps()
1783 local->hw.conf.dynamic_ps_timeout = timeout; in ieee80211_recalc_ps()
1789 local->hw.conf.ps_dtim_period = dtimper; in ieee80211_recalc_ps()
1790 local->ps_sdata = found; in ieee80211_recalc_ps()
1792 local->ps_sdata = NULL; in ieee80211_recalc_ps()
1802 if (sdata->vif.bss_conf.ps != ps_allowed) { in ieee80211_recalc_ps_vif()
1803 sdata->vif.bss_conf.ps = ps_allowed; in ieee80211_recalc_ps_vif()
1814 if (local->hw.conf.flags & IEEE80211_CONF_PS) { in ieee80211_dynamic_ps_disable_work()
1815 local->hw.conf.flags &= ~IEEE80211_CONF_PS; in ieee80211_dynamic_ps_disable_work()
1819 ieee80211_wake_queues_by_reason(&local->hw, in ieee80211_dynamic_ps_disable_work()
1830 struct ieee80211_sub_if_data *sdata = local->ps_sdata; in ieee80211_dynamic_ps_enable_work()
1839 ifmgd = &sdata->u.mgd; in ieee80211_dynamic_ps_enable_work()
1841 if (local->hw.conf.flags & IEEE80211_CONF_PS) in ieee80211_dynamic_ps_enable_work()
1844 if (local->hw.conf.dynamic_ps_timeout > 0) { in ieee80211_dynamic_ps_enable_work()
1847 mod_timer(&local->dynamic_ps_timer, jiffies + in ieee80211_dynamic_ps_enable_work()
1849 local->hw.conf.dynamic_ps_timeout)); in ieee80211_dynamic_ps_enable_work()
1858 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); in ieee80211_dynamic_ps_enable_work()
1859 for (q = 0; q < local->hw.queues; q++) { in ieee80211_dynamic_ps_enable_work()
1860 if (local->queue_stop_reasons[q]) { in ieee80211_dynamic_ps_enable_work()
1861 spin_unlock_irqrestore(&local->queue_stop_reason_lock, in ieee80211_dynamic_ps_enable_work()
1863 mod_timer(&local->dynamic_ps_timer, jiffies + in ieee80211_dynamic_ps_enable_work()
1865 local->hw.conf.dynamic_ps_timeout)); in ieee80211_dynamic_ps_enable_work()
1869 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in ieee80211_dynamic_ps_enable_work()
1872 if (ieee80211_hw_check(&local->hw, PS_NULLFUNC_STACK) && in ieee80211_dynamic_ps_enable_work()
1873 !(ifmgd->flags & IEEE80211_STA_NULLFUNC_ACKED)) { in ieee80211_dynamic_ps_enable_work()
1875 mod_timer(&local->dynamic_ps_timer, jiffies + in ieee80211_dynamic_ps_enable_work()
1877 local->hw.conf.dynamic_ps_timeout)); in ieee80211_dynamic_ps_enable_work()
1885 if (!(ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS) && in ieee80211_dynamic_ps_enable_work()
1886 ieee80211_hw_check(&local->hw, PS_NULLFUNC_STACK)) || in ieee80211_dynamic_ps_enable_work()
1887 (ifmgd->flags & IEEE80211_STA_NULLFUNC_ACKED)) { in ieee80211_dynamic_ps_enable_work()
1888 ifmgd->flags &= ~IEEE80211_STA_NULLFUNC_ACKED; in ieee80211_dynamic_ps_enable_work()
1889 local->hw.conf.flags |= IEEE80211_CONF_PS; in ieee80211_dynamic_ps_enable_work()
1898 ieee80211_queue_work(&local->hw, &local->dynamic_ps_enable_work); in ieee80211_dynamic_ps_timer()
1907 struct cfg80211_chan_def chandef = sdata->vif.bss_conf.chandef; in ieee80211_dfs_cac_timer_work()
1909 mutex_lock(&sdata->local->mtx); in ieee80211_dfs_cac_timer_work()
1910 if (sdata->wdev.cac_started) { in ieee80211_dfs_cac_timer_work()
1912 cfg80211_cac_event(sdata->dev, &chandef, in ieee80211_dfs_cac_timer_work()
1916 mutex_unlock(&sdata->local->mtx); in ieee80211_dfs_cac_timer_work()
1922 struct ieee80211_local *local = sdata->local; in __ieee80211_sta_handle_tspec_ac_params()
1923 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in __ieee80211_sta_handle_tspec_ac_params()
1927 if (local->hw.queues < IEEE80211_NUM_ACS) in __ieee80211_sta_handle_tspec_ac_params()
1931 struct ieee80211_sta_tx_tspec *tx_tspec = &ifmgd->tx_tspec[ac]; in __ieee80211_sta_handle_tspec_ac_params()
1935 if (tx_tspec->action == TX_TSPEC_ACTION_NONE && in __ieee80211_sta_handle_tspec_ac_params()
1936 tx_tspec->admitted_time && in __ieee80211_sta_handle_tspec_ac_params()
1937 time_after(now, tx_tspec->time_slice_start + HZ)) { in __ieee80211_sta_handle_tspec_ac_params()
1938 tx_tspec->consumed_tx_time = 0; in __ieee80211_sta_handle_tspec_ac_params()
1939 tx_tspec->time_slice_start = now; in __ieee80211_sta_handle_tspec_ac_params()
1941 if (tx_tspec->downgraded) in __ieee80211_sta_handle_tspec_ac_params()
1942 tx_tspec->action = in __ieee80211_sta_handle_tspec_ac_params()
1946 switch (tx_tspec->action) { in __ieee80211_sta_handle_tspec_ac_params()
1949 if (drv_conf_tx(local, sdata, ac, &sdata->tx_conf[ac])) in __ieee80211_sta_handle_tspec_ac_params()
1953 tx_tspec->action = TX_TSPEC_ACTION_NONE; in __ieee80211_sta_handle_tspec_ac_params()
1954 tx_tspec->downgraded = false; in __ieee80211_sta_handle_tspec_ac_params()
1958 if (time_after(now, tx_tspec->time_slice_start + HZ)) { in __ieee80211_sta_handle_tspec_ac_params()
1959 tx_tspec->action = TX_TSPEC_ACTION_NONE; in __ieee80211_sta_handle_tspec_ac_params()
1963 /* downgrade next lower non-ACM AC */ in __ieee80211_sta_handle_tspec_ac_params()
1967 if (!(sdata->wmm_acm & BIT(7 - 2 * non_acm_ac))) in __ieee80211_sta_handle_tspec_ac_params()
1971 * makes no sense and we have to transmit somehow - the in __ieee80211_sta_handle_tspec_ac_params()
1979 &sdata->tx_conf[non_acm_ac])) in __ieee80211_sta_handle_tspec_ac_params()
1983 tx_tspec->action = TX_TSPEC_ACTION_NONE; in __ieee80211_sta_handle_tspec_ac_params()
1985 schedule_delayed_work(&ifmgd->tx_tspec_wk, in __ieee80211_sta_handle_tspec_ac_params()
1986 tx_tspec->time_slice_start + HZ - now + 1); in __ieee80211_sta_handle_tspec_ac_params()
2020 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_sta_wmm_params()
2026 if (!local->ops->conf_tx) in ieee80211_sta_wmm_params()
2029 if (local->hw.queues < IEEE80211_NUM_ACS) in ieee80211_sta_wmm_params()
2038 if (ifmgd->flags & IEEE80211_STA_UAPSD_ENABLED) in ieee80211_sta_wmm_params()
2039 uapsd_queues = ifmgd->uapsd_queues; in ieee80211_sta_wmm_params()
2042 /* -1 is the initial value of ifmgd->mu_edca_last_param_set. in ieee80211_sta_wmm_params()
2046 mu_edca_count = mu_edca ? mu_edca->mu_qos_info & 0x0f : -1; in ieee80211_sta_wmm_params()
2047 if (count == ifmgd->wmm_last_param_set && in ieee80211_sta_wmm_params()
2048 mu_edca_count == ifmgd->mu_edca_last_param_set) in ieee80211_sta_wmm_params()
2050 ifmgd->wmm_last_param_set = count; in ieee80211_sta_wmm_params()
2051 ifmgd->mu_edca_last_param_set = mu_edca_count; in ieee80211_sta_wmm_params()
2054 left = wmm_param_len - 8; in ieee80211_sta_wmm_params()
2058 sdata->wmm_acm = 0; in ieee80211_sta_wmm_params()
2059 for (; left >= 4; left -= 4, pos += 4) { in ieee80211_sta_wmm_params()
2068 sdata->wmm_acm |= BIT(1) | BIT(2); /* BK/- */ in ieee80211_sta_wmm_params()
2073 params[ac].mu_edca_param_rec = mu_edca->ac_bk; in ieee80211_sta_wmm_params()
2078 sdata->wmm_acm |= BIT(4) | BIT(5); /* CL/VI */ in ieee80211_sta_wmm_params()
2083 params[ac].mu_edca_param_rec = mu_edca->ac_vi; in ieee80211_sta_wmm_params()
2088 sdata->wmm_acm |= BIT(6) | BIT(7); /* VO/NC */ in ieee80211_sta_wmm_params()
2093 params[ac].mu_edca_param_rec = mu_edca->ac_vo; in ieee80211_sta_wmm_params()
2099 sdata->wmm_acm |= BIT(0) | BIT(3); /* BE/EE */ in ieee80211_sta_wmm_params()
2104 params[ac].mu_edca_param_rec = mu_edca->ac_be; in ieee80211_sta_wmm_params()
2148 ifmgd->tx_tspec[ac].downgraded); in ieee80211_sta_wmm_params()
2149 sdata->tx_conf[ac] = params[ac]; in ieee80211_sta_wmm_params()
2150 if (!ifmgd->tx_tspec[ac].downgraded && in ieee80211_sta_wmm_params()
2158 sdata->vif.bss_conf.qos = true; in ieee80211_sta_wmm_params()
2164 lockdep_assert_held(&sdata->local->mtx); in __ieee80211_stop_poll()
2166 sdata->u.mgd.flags &= ~IEEE80211_STA_CONNECTION_POLL; in __ieee80211_stop_poll()
2167 ieee80211_run_deferred_scan(sdata->local); in __ieee80211_stop_poll()
2172 mutex_lock(&sdata->local->mtx); in ieee80211_stop_poll()
2174 mutex_unlock(&sdata->local->mtx); in ieee80211_stop_poll()
2180 struct ieee80211_bss_conf *bss_conf = &sdata->vif.bss_conf; in ieee80211_handle_bss_capability()
2200 if (sband->band == NL80211_BAND_5GHZ || in ieee80211_handle_bss_capability()
2201 sband->band == NL80211_BAND_6GHZ) in ieee80211_handle_bss_capability()
2204 if (use_protection != bss_conf->use_cts_prot) { in ieee80211_handle_bss_capability()
2205 bss_conf->use_cts_prot = use_protection; in ieee80211_handle_bss_capability()
2209 if (use_short_preamble != bss_conf->use_short_preamble) { in ieee80211_handle_bss_capability()
2210 bss_conf->use_short_preamble = use_short_preamble; in ieee80211_handle_bss_capability()
2214 if (use_short_slot != bss_conf->use_short_slot) { in ieee80211_handle_bss_capability()
2215 bss_conf->use_short_slot = use_short_slot; in ieee80211_handle_bss_capability()
2226 struct ieee80211_bss *bss = (void *)cbss->priv; in ieee80211_set_associated()
2227 struct ieee80211_local *local = sdata->local; in ieee80211_set_associated()
2228 struct ieee80211_bss_conf *bss_conf = &sdata->vif.bss_conf; in ieee80211_set_associated()
2232 bss_conf->assoc_capability, bss->has_erp_value, bss->erp_value); in ieee80211_set_associated()
2234 sdata->u.mgd.beacon_timeout = usecs_to_jiffies(ieee80211_tu_to_usec( in ieee80211_set_associated()
2235 beacon_loss_count * bss_conf->beacon_int)); in ieee80211_set_associated()
2237 sdata->u.mgd.associated = cbss; in ieee80211_set_associated()
2238 memcpy(sdata->u.mgd.bssid, cbss->bssid, ETH_ALEN); in ieee80211_set_associated()
2242 sdata->u.mgd.flags |= IEEE80211_STA_RESET_SIGNAL_AVE; in ieee80211_set_associated()
2244 if (sdata->vif.p2p || in ieee80211_set_associated()
2245 sdata->vif.driver_flags & IEEE80211_VIF_GET_NOA_UPDATE) { in ieee80211_set_associated()
2249 ies = rcu_dereference(cbss->ies); in ieee80211_set_associated()
2254 ies->data, ies->len, in ieee80211_set_associated()
2256 (u8 *) &bss_conf->p2p_noa_attr, in ieee80211_set_associated()
2257 sizeof(bss_conf->p2p_noa_attr)); in ieee80211_set_associated()
2259 sdata->u.mgd.p2p_noa_index = in ieee80211_set_associated()
2260 bss_conf->p2p_noa_attr.index; in ieee80211_set_associated()
2272 if (sdata->u.mgd.have_beacon) { in ieee80211_set_associated()
2279 bss_conf->dtim_period = sdata->u.mgd.dtim_period ?: 1; in ieee80211_set_associated()
2280 bss_conf->beacon_rate = bss->beacon_rate; in ieee80211_set_associated()
2283 bss_conf->beacon_rate = NULL; in ieee80211_set_associated()
2284 bss_conf->dtim_period = 0; in ieee80211_set_associated()
2287 bss_conf->assoc = 1; in ieee80211_set_associated()
2290 if (sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI && in ieee80211_set_associated()
2291 bss_conf->cqm_rssi_thold) in ieee80211_set_associated()
2295 if (bss_conf->arp_addr_cnt) in ieee80211_set_associated()
2300 mutex_lock(&local->iflist_mtx); in ieee80211_set_associated()
2302 mutex_unlock(&local->iflist_mtx); in ieee80211_set_associated()
2307 netif_carrier_on(sdata->dev); in ieee80211_set_associated()
2314 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_set_disassoc()
2315 struct ieee80211_local *local = sdata->local; in ieee80211_set_disassoc()
2323 if (WARN_ON(!ifmgd->associated)) in ieee80211_set_disassoc()
2328 ifmgd->associated = NULL; in ieee80211_set_disassoc()
2329 netif_carrier_off(sdata->dev); in ieee80211_set_disassoc()
2333 * to do it before sending disassoc, as otherwise the null-packet in ieee80211_set_disassoc()
2336 if (local->hw.conf.flags & IEEE80211_CONF_PS) { in ieee80211_set_disassoc()
2337 local->hw.conf.flags &= ~IEEE80211_CONF_PS; in ieee80211_set_disassoc()
2340 local->ps_sdata = NULL; in ieee80211_set_disassoc()
2342 /* disable per-vif ps */ in ieee80211_set_disassoc()
2365 if (ieee80211_hw_check(&local->hw, DEAUTH_NEED_MGD_TX_PREP) && in ieee80211_set_disassoc()
2366 !ifmgd->have_beacon) in ieee80211_set_disassoc()
2367 drv_mgd_prepare_tx(sdata->local, sdata, 0); in ieee80211_set_disassoc()
2369 ieee80211_send_deauth_disassoc(sdata, ifmgd->bssid, in ieee80211_set_disassoc()
2370 ifmgd->bssid, stype, reason, in ieee80211_set_disassoc()
2374 /* flush out frame - make sure the deauth was actually sent */ in ieee80211_set_disassoc()
2379 eth_zero_addr(ifmgd->bssid); in ieee80211_set_disassoc()
2389 sdata->vif.bss_conf.assoc = false; in ieee80211_set_disassoc()
2391 ifmgd->p2p_noa_index = -1; in ieee80211_set_disassoc()
2392 memset(&sdata->vif.bss_conf.p2p_noa_attr, 0, in ieee80211_set_disassoc()
2393 sizeof(sdata->vif.bss_conf.p2p_noa_attr)); in ieee80211_set_disassoc()
2395 /* on the next assoc, re-program HT/VHT parameters */ in ieee80211_set_disassoc()
2396 memset(&ifmgd->ht_capa, 0, sizeof(ifmgd->ht_capa)); in ieee80211_set_disassoc()
2397 memset(&ifmgd->ht_capa_mask, 0, sizeof(ifmgd->ht_capa_mask)); in ieee80211_set_disassoc()
2398 memset(&ifmgd->vht_capa, 0, sizeof(ifmgd->vht_capa)); in ieee80211_set_disassoc()
2399 memset(&ifmgd->vht_capa_mask, 0, sizeof(ifmgd->vht_capa_mask)); in ieee80211_set_disassoc()
2401 /* reset MU-MIMO ownership and group data */ in ieee80211_set_disassoc()
2402 memset(sdata->vif.bss_conf.mu_group.membership, 0, in ieee80211_set_disassoc()
2403 sizeof(sdata->vif.bss_conf.mu_group.membership)); in ieee80211_set_disassoc()
2404 memset(sdata->vif.bss_conf.mu_group.position, 0, in ieee80211_set_disassoc()
2405 sizeof(sdata->vif.bss_conf.mu_group.position)); in ieee80211_set_disassoc()
2407 sdata->vif.mu_mimo_owner = false; in ieee80211_set_disassoc()
2409 sdata->ap_power_level = IEEE80211_UNSET_POWER_LEVEL; in ieee80211_set_disassoc()
2411 del_timer_sync(&local->dynamic_ps_timer); in ieee80211_set_disassoc()
2412 cancel_work_sync(&local->dynamic_ps_enable_work); in ieee80211_set_disassoc()
2415 if (sdata->vif.bss_conf.arp_addr_cnt) in ieee80211_set_disassoc()
2418 sdata->vif.bss_conf.qos = false; in ieee80211_set_disassoc()
2425 /* disassociated - set to defaults now */ in ieee80211_set_disassoc()
2428 del_timer_sync(&sdata->u.mgd.conn_mon_timer); in ieee80211_set_disassoc()
2429 del_timer_sync(&sdata->u.mgd.bcn_mon_timer); in ieee80211_set_disassoc()
2430 del_timer_sync(&sdata->u.mgd.timer); in ieee80211_set_disassoc()
2431 del_timer_sync(&sdata->u.mgd.chswitch_timer); in ieee80211_set_disassoc()
2433 sdata->vif.bss_conf.dtim_period = 0; in ieee80211_set_disassoc()
2434 sdata->vif.bss_conf.beacon_rate = NULL; in ieee80211_set_disassoc()
2436 ifmgd->have_beacon = false; in ieee80211_set_disassoc()
2438 ifmgd->flags = 0; in ieee80211_set_disassoc()
2439 mutex_lock(&local->mtx); in ieee80211_set_disassoc()
2442 sdata->vif.csa_active = false; in ieee80211_set_disassoc()
2443 ifmgd->csa_waiting_bcn = false; in ieee80211_set_disassoc()
2444 ifmgd->csa_ignored_same_chan = false; in ieee80211_set_disassoc()
2445 if (sdata->csa_block_tx) { in ieee80211_set_disassoc()
2448 sdata->csa_block_tx = false; in ieee80211_set_disassoc()
2450 mutex_unlock(&local->mtx); in ieee80211_set_disassoc()
2453 memset(ifmgd->tx_tspec, 0, sizeof(ifmgd->tx_tspec)); in ieee80211_set_disassoc()
2454 cancel_delayed_work_sync(&ifmgd->tx_tspec_wk); in ieee80211_set_disassoc()
2456 sdata->encrypt_headroom = IEEE80211_ENCRYPT_HEADROOM; in ieee80211_set_disassoc()
2461 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_reset_ap_probe()
2462 struct ieee80211_local *local = sdata->local; in ieee80211_reset_ap_probe()
2464 mutex_lock(&local->mtx); in ieee80211_reset_ap_probe()
2465 if (!(ifmgd->flags & IEEE80211_STA_CONNECTION_POLL)) in ieee80211_reset_ap_probe()
2470 mutex_lock(&local->iflist_mtx); in ieee80211_reset_ap_probe()
2472 mutex_unlock(&local->iflist_mtx); in ieee80211_reset_ap_probe()
2474 if (ieee80211_hw_check(&sdata->local->hw, CONNECTION_MONITOR)) in ieee80211_reset_ap_probe()
2484 mod_timer(&ifmgd->conn_mon_timer, in ieee80211_reset_ap_probe()
2488 mutex_unlock(&local->mtx); in ieee80211_reset_ap_probe()
2495 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_sta_tx_wmm_ac_notify()
2501 if (!ieee80211_is_data_qos(hdr->frame_control)) in ieee80211_sta_tx_wmm_ac_notify()
2506 tx_tspec = &ifmgd->tx_tspec[ac]; in ieee80211_sta_tx_wmm_ac_notify()
2508 if (likely(!tx_tspec->admitted_time)) in ieee80211_sta_tx_wmm_ac_notify()
2511 if (time_after(now, tx_tspec->time_slice_start + HZ)) { in ieee80211_sta_tx_wmm_ac_notify()
2512 tx_tspec->consumed_tx_time = 0; in ieee80211_sta_tx_wmm_ac_notify()
2513 tx_tspec->time_slice_start = now; in ieee80211_sta_tx_wmm_ac_notify()
2515 if (tx_tspec->downgraded) { in ieee80211_sta_tx_wmm_ac_notify()
2516 tx_tspec->action = TX_TSPEC_ACTION_STOP_DOWNGRADE; in ieee80211_sta_tx_wmm_ac_notify()
2517 schedule_delayed_work(&ifmgd->tx_tspec_wk, 0); in ieee80211_sta_tx_wmm_ac_notify()
2521 if (tx_tspec->downgraded) in ieee80211_sta_tx_wmm_ac_notify()
2524 tx_tspec->consumed_tx_time += tx_time; in ieee80211_sta_tx_wmm_ac_notify()
2526 if (tx_tspec->consumed_tx_time >= tx_tspec->admitted_time) { in ieee80211_sta_tx_wmm_ac_notify()
2527 tx_tspec->downgraded = true; in ieee80211_sta_tx_wmm_ac_notify()
2528 tx_tspec->action = TX_TSPEC_ACTION_DOWNGRADE; in ieee80211_sta_tx_wmm_ac_notify()
2529 schedule_delayed_work(&ifmgd->tx_tspec_wk, 0); in ieee80211_sta_tx_wmm_ac_notify()
2538 if (!ieee80211_is_any_nullfunc(hdr->frame_control) || in ieee80211_sta_tx_notify()
2539 !sdata->u.mgd.probe_send_count) in ieee80211_sta_tx_notify()
2543 sdata->u.mgd.probe_send_count = 0; in ieee80211_sta_tx_notify()
2545 sdata->u.mgd.nullfunc_failed = true; in ieee80211_sta_tx_notify()
2546 ieee80211_queue_work(&sdata->local->hw, &sdata->work); in ieee80211_sta_tx_notify()
2556 skb = ieee80211_build_probe_req(sdata, src, dst, (u32)-1, channel, in ieee80211_mlme_send_probe_req()
2565 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_mgd_probe_ap_send()
2567 u8 *dst = ifmgd->associated->bssid; in ieee80211_mgd_probe_ap_send()
2568 u8 unicast_limit = max(1, max_probe_tries - 3); in ieee80211_mgd_probe_ap_send()
2576 if (ifmgd->probe_send_count >= unicast_limit) in ieee80211_mgd_probe_ap_send()
2586 ifmgd->probe_send_count++; in ieee80211_mgd_probe_ap_send()
2589 mutex_lock(&sdata->local->sta_mtx); in ieee80211_mgd_probe_ap_send()
2593 mutex_unlock(&sdata->local->sta_mtx); in ieee80211_mgd_probe_ap_send()
2596 if (ieee80211_hw_check(&sdata->local->hw, REPORTS_TX_ACK_STATUS)) { in ieee80211_mgd_probe_ap_send()
2597 ifmgd->nullfunc_failed = false; in ieee80211_mgd_probe_ap_send()
2598 if (!(ifmgd->flags & IEEE80211_STA_DISABLE_HE)) in ieee80211_mgd_probe_ap_send()
2599 ifmgd->probe_send_count--; in ieee80211_mgd_probe_ap_send()
2601 ieee80211_send_nullfunc(sdata->local, sdata, false); in ieee80211_mgd_probe_ap_send()
2606 ssid = ieee80211_bss_get_ie(ifmgd->associated, WLAN_EID_SSID); in ieee80211_mgd_probe_ap_send()
2612 ieee80211_mlme_send_probe_req(sdata, sdata->vif.addr, dst, in ieee80211_mgd_probe_ap_send()
2614 ifmgd->associated->channel); in ieee80211_mgd_probe_ap_send()
2618 ifmgd->probe_timeout = jiffies + msecs_to_jiffies(probe_wait_ms); in ieee80211_mgd_probe_ap_send()
2619 run_again(sdata, ifmgd->probe_timeout); in ieee80211_mgd_probe_ap_send()
2625 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_mgd_probe_ap()
2633 if (!ifmgd->associated) in ieee80211_mgd_probe_ap()
2636 mutex_lock(&sdata->local->mtx); in ieee80211_mgd_probe_ap()
2638 if (sdata->local->tmp_channel || sdata->local->scanning) { in ieee80211_mgd_probe_ap()
2639 mutex_unlock(&sdata->local->mtx); in ieee80211_mgd_probe_ap()
2645 "detected beacon loss from AP (missed %d beacons) - probing\n", in ieee80211_mgd_probe_ap()
2648 ieee80211_cqm_beacon_loss_notify(&sdata->vif, GFP_KERNEL); in ieee80211_mgd_probe_ap()
2662 if (ifmgd->flags & IEEE80211_STA_CONNECTION_POLL) in ieee80211_mgd_probe_ap()
2665 ifmgd->flags |= IEEE80211_STA_CONNECTION_POLL; in ieee80211_mgd_probe_ap()
2667 mutex_unlock(&sdata->local->mtx); in ieee80211_mgd_probe_ap()
2672 mutex_lock(&sdata->local->iflist_mtx); in ieee80211_mgd_probe_ap()
2673 ieee80211_recalc_ps(sdata->local); in ieee80211_mgd_probe_ap()
2674 mutex_unlock(&sdata->local->iflist_mtx); in ieee80211_mgd_probe_ap()
2676 ifmgd->probe_send_count = 0; in ieee80211_mgd_probe_ap()
2686 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_ap_probereq_get()
2692 if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_STATION)) in ieee80211_ap_probereq_get()
2697 if (ifmgd->associated) in ieee80211_ap_probereq_get()
2698 cbss = ifmgd->associated; in ieee80211_ap_probereq_get()
2699 else if (ifmgd->auth_data) in ieee80211_ap_probereq_get()
2700 cbss = ifmgd->auth_data->bss; in ieee80211_ap_probereq_get()
2701 else if (ifmgd->assoc_data) in ieee80211_ap_probereq_get()
2702 cbss = ifmgd->assoc_data->bss; in ieee80211_ap_probereq_get()
2709 "invalid SSID element (len=%d)", ssid ? ssid[1] : -1)) in ieee80211_ap_probereq_get()
2714 skb = ieee80211_build_probe_req(sdata, sdata->vif.addr, cbss->bssid, in ieee80211_ap_probereq_get()
2715 (u32) -1, cbss->channel, in ieee80211_ap_probereq_get()
2735 cfg80211_tx_mlme_mgmt(sdata->dev, buf, len); in ieee80211_report_disconnect()
2737 cfg80211_rx_mlme_mgmt(sdata->dev, buf, len); in ieee80211_report_disconnect()
2739 drv_event_callback(sdata->local, sdata, &event); in ieee80211_report_disconnect()
2744 struct ieee80211_local *local = sdata->local; in __ieee80211_disconnect()
2745 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in __ieee80211_disconnect()
2750 if (!ifmgd->associated) { in __ieee80211_disconnect()
2755 tx = !sdata->csa_block_tx; in __ieee80211_disconnect()
2760 cfg80211_unlink_bss(local->hw.wiphy, ifmgd->associated); in __ieee80211_disconnect()
2765 mutex_lock(&local->mtx); in __ieee80211_disconnect()
2766 sdata->vif.csa_active = false; in __ieee80211_disconnect()
2767 ifmgd->csa_waiting_bcn = false; in __ieee80211_disconnect()
2768 if (sdata->csa_block_tx) { in __ieee80211_disconnect()
2771 sdata->csa_block_tx = false; in __ieee80211_disconnect()
2773 mutex_unlock(&local->mtx); in __ieee80211_disconnect()
2786 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_beacon_connection_loss_work()
2788 if (ifmgd->associated) in ieee80211_beacon_connection_loss_work()
2789 ifmgd->beacon_loss_count++; in ieee80211_beacon_connection_loss_work()
2791 if (ifmgd->connection_loss) { in ieee80211_beacon_connection_loss_work()
2793 ifmgd->bssid); in ieee80211_beacon_connection_loss_work()
2812 struct ieee80211_hw *hw = &sdata->local->hw; in ieee80211_beacon_loss()
2816 sdata->u.mgd.connection_loss = false; in ieee80211_beacon_loss()
2817 ieee80211_queue_work(hw, &sdata->u.mgd.beacon_connection_loss_work); in ieee80211_beacon_loss()
2824 struct ieee80211_hw *hw = &sdata->local->hw; in ieee80211_connection_loss()
2828 sdata->u.mgd.connection_loss = true; in ieee80211_connection_loss()
2829 ieee80211_queue_work(hw, &sdata->u.mgd.beacon_connection_loss_work); in ieee80211_connection_loss()
2837 struct ieee80211_mgd_auth_data *auth_data = sdata->u.mgd.auth_data; in ieee80211_destroy_auth_data()
2847 del_timer_sync(&sdata->u.mgd.timer); in ieee80211_destroy_auth_data()
2848 sta_info_destroy_addr(sdata, auth_data->bss->bssid); in ieee80211_destroy_auth_data()
2850 eth_zero_addr(sdata->u.mgd.bssid); in ieee80211_destroy_auth_data()
2852 sdata->u.mgd.flags = 0; in ieee80211_destroy_auth_data()
2853 mutex_lock(&sdata->local->mtx); in ieee80211_destroy_auth_data()
2855 mutex_unlock(&sdata->local->mtx); in ieee80211_destroy_auth_data()
2858 cfg80211_put_bss(sdata->local->hw.wiphy, auth_data->bss); in ieee80211_destroy_auth_data()
2860 sdata->u.mgd.auth_data = NULL; in ieee80211_destroy_auth_data()
2866 struct ieee80211_mgd_assoc_data *assoc_data = sdata->u.mgd.assoc_data; in ieee80211_destroy_assoc_data()
2876 del_timer_sync(&sdata->u.mgd.timer); in ieee80211_destroy_assoc_data()
2877 sta_info_destroy_addr(sdata, assoc_data->bss->bssid); in ieee80211_destroy_assoc_data()
2879 eth_zero_addr(sdata->u.mgd.bssid); in ieee80211_destroy_assoc_data()
2881 sdata->u.mgd.flags = 0; in ieee80211_destroy_assoc_data()
2882 sdata->vif.mu_mimo_owner = false; in ieee80211_destroy_assoc_data()
2884 mutex_lock(&sdata->local->mtx); in ieee80211_destroy_assoc_data()
2886 mutex_unlock(&sdata->local->mtx); in ieee80211_destroy_assoc_data()
2889 cfg80211_abandon_assoc(sdata->dev, assoc_data->bss); in ieee80211_destroy_assoc_data()
2893 sdata->u.mgd.assoc_data = NULL; in ieee80211_destroy_assoc_data()
2899 struct ieee80211_local *local = sdata->local; in ieee80211_auth_challenge()
2900 struct ieee80211_mgd_auth_data *auth_data = sdata->u.mgd.auth_data; in ieee80211_auth_challenge()
2905 pos = mgmt->u.auth.variable; in ieee80211_auth_challenge()
2906 ieee802_11_parse_elems(pos, len - (pos - (u8 *)mgmt), false, &elems, in ieee80211_auth_challenge()
2907 mgmt->bssid, auth_data->bss->bssid); in ieee80211_auth_challenge()
2910 auth_data->expected_transaction = 4; in ieee80211_auth_challenge()
2911 drv_mgd_prepare_tx(sdata->local, sdata, 0); in ieee80211_auth_challenge()
2912 if (ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS)) in ieee80211_auth_challenge()
2915 ieee80211_send_auth(sdata, 3, auth_data->algorithm, 0, in ieee80211_auth_challenge()
2916 elems.challenge - 2, elems.challenge_len + 2, in ieee80211_auth_challenge()
2917 auth_data->bss->bssid, auth_data->bss->bssid, in ieee80211_auth_challenge()
2918 auth_data->key, auth_data->key_len, in ieee80211_auth_challenge()
2919 auth_data->key_idx, tx_flags); in ieee80211_auth_challenge()
2925 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_mark_sta_auth()
2930 ifmgd->auth_data->done = true; in ieee80211_mark_sta_auth()
2931 ifmgd->auth_data->timeout = jiffies + IEEE80211_AUTH_WAIT_ASSOC; in ieee80211_mark_sta_auth()
2932 ifmgd->auth_data->timeout_started = true; in ieee80211_mark_sta_auth()
2933 run_again(sdata, ifmgd->auth_data->timeout); in ieee80211_mark_sta_auth()
2936 mutex_lock(&sdata->local->sta_mtx); in ieee80211_mark_sta_auth()
2939 WARN_ONCE(1, "%s: STA %pM not found", sdata->name, bssid); in ieee80211_mark_sta_auth()
2950 mutex_unlock(&sdata->local->sta_mtx); in ieee80211_mark_sta_auth()
2957 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_rx_mgmt_auth()
2970 if (!ifmgd->auth_data || ifmgd->auth_data->done) in ieee80211_rx_mgmt_auth()
2973 memcpy(bssid, ifmgd->auth_data->bss->bssid, ETH_ALEN); in ieee80211_rx_mgmt_auth()
2975 if (!ether_addr_equal(bssid, mgmt->bssid)) in ieee80211_rx_mgmt_auth()
2978 auth_alg = le16_to_cpu(mgmt->u.auth.auth_alg); in ieee80211_rx_mgmt_auth()
2979 auth_transaction = le16_to_cpu(mgmt->u.auth.auth_transaction); in ieee80211_rx_mgmt_auth()
2980 status_code = le16_to_cpu(mgmt->u.auth.status_code); in ieee80211_rx_mgmt_auth()
2982 if (auth_alg != ifmgd->auth_data->algorithm || in ieee80211_rx_mgmt_auth()
2984 auth_transaction != ifmgd->auth_data->expected_transaction) || in ieee80211_rx_mgmt_auth()
2986 (auth_transaction < ifmgd->auth_data->expected_transaction || in ieee80211_rx_mgmt_auth()
2989 mgmt->sa, auth_alg, ifmgd->auth_data->algorithm, in ieee80211_rx_mgmt_auth()
2991 ifmgd->auth_data->expected_transaction); in ieee80211_rx_mgmt_auth()
2996 cfg80211_rx_mlme_mgmt(sdata->dev, (u8 *)mgmt, len); in ieee80211_rx_mgmt_auth()
3006 mgmt->sa, status_code); in ieee80211_rx_mgmt_auth()
3010 drv_event_callback(sdata->local, sdata, &event); in ieee80211_rx_mgmt_auth()
3014 switch (ifmgd->auth_data->algorithm) { in ieee80211_rx_mgmt_auth()
3024 if (ifmgd->auth_data->expected_transaction != 4) { in ieee80211_rx_mgmt_auth()
3032 ifmgd->auth_data->algorithm); in ieee80211_rx_mgmt_auth()
3037 drv_event_callback(sdata->local, sdata, &event); in ieee80211_rx_mgmt_auth()
3038 if (ifmgd->auth_data->algorithm != WLAN_AUTH_SAE || in ieee80211_rx_mgmt_auth()
3040 ifmgd->auth_data->expected_transaction == 2)) { in ieee80211_rx_mgmt_auth()
3042 return; /* ignore frame -- wait for timeout */ in ieee80211_rx_mgmt_auth()
3043 } else if (ifmgd->auth_data->algorithm == WLAN_AUTH_SAE && in ieee80211_rx_mgmt_auth()
3046 ifmgd->auth_data->peer_confirmed = true; in ieee80211_rx_mgmt_auth()
3049 cfg80211_rx_mlme_mgmt(sdata->dev, (u8 *)mgmt, len); in ieee80211_rx_mgmt_auth()
3112 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_rx_mgmt_deauth()
3113 u16 reason_code = le16_to_cpu(mgmt->u.deauth.reason_code); in ieee80211_rx_mgmt_deauth()
3120 if (!ether_addr_equal(mgmt->bssid, mgmt->sa)) { in ieee80211_rx_mgmt_deauth()
3121 ieee80211_tdls_handle_disconnect(sdata, mgmt->sa, reason_code); in ieee80211_rx_mgmt_deauth()
3125 if (ifmgd->associated && in ieee80211_rx_mgmt_deauth()
3126 ether_addr_equal(mgmt->bssid, ifmgd->associated->bssid)) { in ieee80211_rx_mgmt_deauth()
3127 const u8 *bssid = ifmgd->associated->bssid; in ieee80211_rx_mgmt_deauth()
3140 if (ifmgd->assoc_data && in ieee80211_rx_mgmt_deauth()
3141 ether_addr_equal(mgmt->bssid, ifmgd->assoc_data->bss->bssid)) { in ieee80211_rx_mgmt_deauth()
3142 const u8 *bssid = ifmgd->assoc_data->bss->bssid; in ieee80211_rx_mgmt_deauth()
3151 cfg80211_rx_mlme_mgmt(sdata->dev, (u8 *)mgmt, len); in ieee80211_rx_mgmt_deauth()
3160 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_rx_mgmt_disassoc()
3168 if (!ifmgd->associated || in ieee80211_rx_mgmt_disassoc()
3169 !ether_addr_equal(mgmt->bssid, ifmgd->associated->bssid)) in ieee80211_rx_mgmt_disassoc()
3172 reason_code = le16_to_cpu(mgmt->u.disassoc.reason_code); in ieee80211_rx_mgmt_disassoc()
3174 if (!ether_addr_equal(mgmt->bssid, mgmt->sa)) { in ieee80211_rx_mgmt_disassoc()
3175 ieee80211_tdls_handle_disconnect(sdata, mgmt->sa, reason_code); in ieee80211_rx_mgmt_disassoc()
3180 mgmt->sa, reason_code, in ieee80211_rx_mgmt_disassoc()
3217 for (j = 0; j < sband->n_bitrates; j++) { in ieee80211_get_rates()
3221 br = &sband->bitrates[j]; in ieee80211_get_rates()
3223 brate = DIV_ROUND_UP(br->bitrate, (1 << shift) * 5); in ieee80211_get_rates()
3241 if (elems->ext_capab_len < 10) in ieee80211_twt_req_supported()
3244 if (!(elems->ext_capab[9] & WLAN_EXT_CAPA10_TWT_RESPONDER_SUPPORT)) in ieee80211_twt_req_supported()
3247 return sta->sta.he_cap.he_cap_elem.mac_cap_info[0] & in ieee80211_twt_req_supported()
3257 if (sdata->vif.bss_conf.twt_requester != twt) { in ieee80211_recalc_twt_req()
3258 sdata->vif.bss_conf.twt_requester = twt; in ieee80211_recalc_twt_req()
3269 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_assoc_success()
3270 struct ieee80211_local *local = sdata->local; in ieee80211_assoc_success()
3274 struct ieee80211_bss_conf *bss_conf = &sdata->vif.bss_conf; in ieee80211_assoc_success()
3276 struct ieee80211_mgd_assoc_data *assoc_data = ifmgd->assoc_data; in ieee80211_assoc_success()
3277 bool is_6ghz = cbss->channel->band == NL80211_BAND_6GHZ; in ieee80211_assoc_success()
3278 bool is_s1g = cbss->channel->band == NL80211_BAND_S1GHZ; in ieee80211_assoc_success()
3286 pos = mgmt->u.assoc_resp.variable; in ieee80211_assoc_success()
3287 aid = le16_to_cpu(mgmt->u.assoc_resp.aid); in ieee80211_assoc_success()
3289 pos = (u8 *) mgmt->u.s1g_assoc_resp.variable; in ieee80211_assoc_success()
3292 capab_info = le16_to_cpu(mgmt->u.assoc_resp.capab_info); in ieee80211_assoc_success()
3293 ieee802_11_parse_elems(pos, len - (pos - (u8 *)mgmt), false, elems, in ieee80211_assoc_success()
3294 mgmt->bssid, assoc_data->bss->bssid); in ieee80211_assoc_success()
3296 if (elems->aid_resp) in ieee80211_assoc_success()
3297 aid = le16_to_cpu(elems->aid_resp->aid); in ieee80211_assoc_success()
3301 * (802.11-2016 9.4.1.8 AID field) in ieee80211_assoc_success()
3305 ifmgd->broken_ap = false; in ieee80211_assoc_success()
3311 ifmgd->broken_ap = true; in ieee80211_assoc_success()
3314 if (!is_s1g && !elems->supp_rates) { in ieee80211_assoc_success()
3319 sdata->vif.bss_conf.aid = aid; in ieee80211_assoc_success()
3320 ifmgd->tdls_chan_switch_prohibited = in ieee80211_assoc_success()
3321 elems->ext_capab && elems->ext_capab_len >= 5 && in ieee80211_assoc_success()
3322 (elems->ext_capab[4] & WLAN_EXT_CAPA5_TDLS_CH_SW_PROHIBITED); in ieee80211_assoc_success()
3329 * "Vodafone PocketWiFi 2", "ZTE MF60" and a similar T-Mobile device. in ieee80211_assoc_success()
3332 ((assoc_data->wmm && !elems->wmm_param) || in ieee80211_assoc_success()
3333 (!(ifmgd->flags & IEEE80211_STA_DISABLE_HT) && in ieee80211_assoc_success()
3334 (!elems->ht_cap_elem || !elems->ht_operation)) || in ieee80211_assoc_success()
3335 (!(ifmgd->flags & IEEE80211_STA_DISABLE_VHT) && in ieee80211_assoc_success()
3336 (!elems->vht_cap_elem || !elems->vht_operation)))) { in ieee80211_assoc_success()
3341 ies = rcu_dereference(cbss->ies); in ieee80211_assoc_success()
3343 bss_ies = kmemdup(ies, sizeof(*ies) + ies->len, in ieee80211_assoc_success()
3349 ieee802_11_parse_elems(bss_ies->data, bss_ies->len, in ieee80211_assoc_success()
3351 mgmt->bssid, in ieee80211_assoc_success()
3352 assoc_data->bss->bssid); in ieee80211_assoc_success()
3353 if (assoc_data->wmm && in ieee80211_assoc_success()
3354 !elems->wmm_param && bss_elems.wmm_param) { in ieee80211_assoc_success()
3355 elems->wmm_param = bss_elems.wmm_param; in ieee80211_assoc_success()
3364 if (!elems->ht_cap_elem && bss_elems.ht_cap_elem && in ieee80211_assoc_success()
3365 !(ifmgd->flags & IEEE80211_STA_DISABLE_HT)) { in ieee80211_assoc_success()
3366 elems->ht_cap_elem = bss_elems.ht_cap_elem; in ieee80211_assoc_success()
3370 if (!elems->ht_operation && bss_elems.ht_operation && in ieee80211_assoc_success()
3371 !(ifmgd->flags & IEEE80211_STA_DISABLE_HT)) { in ieee80211_assoc_success()
3372 elems->ht_operation = bss_elems.ht_operation; in ieee80211_assoc_success()
3376 if (!elems->vht_cap_elem && bss_elems.vht_cap_elem && in ieee80211_assoc_success()
3377 !(ifmgd->flags & IEEE80211_STA_DISABLE_VHT)) { in ieee80211_assoc_success()
3378 elems->vht_cap_elem = bss_elems.vht_cap_elem; in ieee80211_assoc_success()
3382 if (!elems->vht_operation && bss_elems.vht_operation && in ieee80211_assoc_success()
3383 !(ifmgd->flags & IEEE80211_STA_DISABLE_VHT)) { in ieee80211_assoc_success()
3384 elems->vht_operation = bss_elems.vht_operation; in ieee80211_assoc_success()
3395 if (!is_6ghz && !(ifmgd->flags & IEEE80211_STA_DISABLE_HT) && in ieee80211_assoc_success()
3396 (!elems->wmm_param || !elems->ht_cap_elem || !elems->ht_operation)) { in ieee80211_assoc_success()
3403 if (!is_6ghz && !(ifmgd->flags & IEEE80211_STA_DISABLE_VHT) && in ieee80211_assoc_success()
3404 (!elems->vht_cap_elem || !elems->vht_operation)) { in ieee80211_assoc_success()
3411 if (is_6ghz && !(ifmgd->flags & IEEE80211_STA_DISABLE_HE) && in ieee80211_assoc_success()
3412 !elems->he_6ghz_capa) { in ieee80211_assoc_success()
3419 mutex_lock(&sdata->local->sta_mtx); in ieee80211_assoc_success()
3424 sta = sta_info_get(sdata, cbss->bssid); in ieee80211_assoc_success()
3426 mutex_unlock(&sdata->local->sta_mtx); in ieee80211_assoc_success()
3433 mutex_unlock(&sdata->local->sta_mtx); in ieee80211_assoc_success()
3438 if (!(ifmgd->flags & IEEE80211_STA_DISABLE_HE) && in ieee80211_assoc_success()
3439 (!elems->he_cap || !elems->he_operation)) { in ieee80211_assoc_success()
3440 mutex_unlock(&sdata->local->sta_mtx); in ieee80211_assoc_success()
3448 if (elems->ht_cap_elem && !(ifmgd->flags & IEEE80211_STA_DISABLE_HT)) in ieee80211_assoc_success()
3450 elems->ht_cap_elem, sta); in ieee80211_assoc_success()
3452 if (elems->vht_cap_elem && !(ifmgd->flags & IEEE80211_STA_DISABLE_VHT)) in ieee80211_assoc_success()
3454 elems->vht_cap_elem, sta); in ieee80211_assoc_success()
3456 if (elems->he_operation && !(ifmgd->flags & IEEE80211_STA_DISABLE_HE) && in ieee80211_assoc_success()
3457 elems->he_cap) { in ieee80211_assoc_success()
3459 elems->he_cap, in ieee80211_assoc_success()
3460 elems->he_cap_len, in ieee80211_assoc_success()
3461 elems->he_6ghz_capa, in ieee80211_assoc_success()
3464 bss_conf->he_support = sta->sta.he_cap.has_he; in ieee80211_assoc_success()
3465 if (elems->rsnx && elems->rsnx_len && in ieee80211_assoc_success()
3466 (elems->rsnx[0] & WLAN_RSNX_CAPA_PROTECTED_TWT) && in ieee80211_assoc_success()
3467 wiphy_ext_feature_isset(local->hw.wiphy, in ieee80211_assoc_success()
3469 bss_conf->twt_protected = true; in ieee80211_assoc_success()
3471 bss_conf->twt_protected = false; in ieee80211_assoc_success()
3475 bss_conf->he_support = false; in ieee80211_assoc_success()
3476 bss_conf->twt_requester = false; in ieee80211_assoc_success()
3477 bss_conf->twt_protected = false; in ieee80211_assoc_success()
3480 if (bss_conf->he_support) { in ieee80211_assoc_success()
3481 bss_conf->he_bss_color.color = in ieee80211_assoc_success()
3482 le32_get_bits(elems->he_operation->he_oper_params, in ieee80211_assoc_success()
3484 bss_conf->he_bss_color.partial = in ieee80211_assoc_success()
3485 le32_get_bits(elems->he_operation->he_oper_params, in ieee80211_assoc_success()
3487 bss_conf->he_bss_color.enabled = in ieee80211_assoc_success()
3488 !le32_get_bits(elems->he_operation->he_oper_params, in ieee80211_assoc_success()
3491 if (bss_conf->he_bss_color.enabled) in ieee80211_assoc_success()
3494 bss_conf->htc_trig_based_pkt_ext = in ieee80211_assoc_success()
3495 le32_get_bits(elems->he_operation->he_oper_params, in ieee80211_assoc_success()
3497 bss_conf->frame_time_rts_th = in ieee80211_assoc_success()
3498 le32_get_bits(elems->he_operation->he_oper_params, in ieee80211_assoc_success()
3501 bss_conf->multi_sta_back_32bit = in ieee80211_assoc_success()
3502 sta->sta.he_cap.he_cap_elem.mac_cap_info[2] & in ieee80211_assoc_success()
3505 bss_conf->ack_enabled = in ieee80211_assoc_success()
3506 sta->sta.he_cap.he_cap_elem.mac_cap_info[2] & in ieee80211_assoc_success()
3509 bss_conf->uora_exists = !!elems->uora_element; in ieee80211_assoc_success()
3510 if (elems->uora_element) in ieee80211_assoc_success()
3511 bss_conf->uora_ocw_range = elems->uora_element[0]; in ieee80211_assoc_success()
3513 ieee80211_he_op_ie_to_bss_conf(&sdata->vif, elems->he_operation); in ieee80211_assoc_success()
3514 ieee80211_he_spr_ie_to_bss_conf(&sdata->vif, elems->he_spr); in ieee80211_assoc_success()
3518 if (cbss->transmitted_bss) { in ieee80211_assoc_success()
3519 bss_conf->nontransmitted = true; in ieee80211_assoc_success()
3520 ether_addr_copy(bss_conf->transmitter_bssid, in ieee80211_assoc_success()
3521 cbss->transmitted_bss->bssid); in ieee80211_assoc_success()
3522 bss_conf->bssid_indicator = cbss->max_bssid_indicator; in ieee80211_assoc_success()
3523 bss_conf->bssid_index = cbss->bssid_index; in ieee80211_assoc_success()
3538 if (elems->opmode_notif && in ieee80211_assoc_success()
3539 !(*elems->opmode_notif & IEEE80211_OPMODE_NOTIF_RX_NSS_TYPE_BF)) { in ieee80211_assoc_success()
3542 nss = *elems->opmode_notif & IEEE80211_OPMODE_NOTIF_RX_NSS_MASK; in ieee80211_assoc_success()
3545 sta->sta.rx_nss = nss; in ieee80211_assoc_success()
3550 if (ifmgd->flags & IEEE80211_STA_MFP_ENABLED) { in ieee80211_assoc_success()
3552 sta->sta.mfp = true; in ieee80211_assoc_success()
3554 sta->sta.mfp = false; in ieee80211_assoc_success()
3557 sta->sta.wme = (elems->wmm_param || elems->s1g_capab) && in ieee80211_assoc_success()
3558 local->hw.queues >= IEEE80211_NUM_ACS; in ieee80211_assoc_success()
3561 if (!err && !(ifmgd->flags & IEEE80211_STA_CONTROL_PORT)) in ieee80211_assoc_success()
3566 sta->sta.addr); in ieee80211_assoc_success()
3568 mutex_unlock(&sdata->local->sta_mtx); in ieee80211_assoc_success()
3573 if (sdata->wdev.use_4addr) in ieee80211_assoc_success()
3574 drv_sta_set_4addr(local, sdata, &sta->sta, true); in ieee80211_assoc_success()
3576 mutex_unlock(&sdata->local->sta_mtx); in ieee80211_assoc_success()
3580 * of the first value the AP uses. Setting -1 here has in ieee80211_assoc_success()
3582 * 4-bit value. in ieee80211_assoc_success()
3584 ifmgd->wmm_last_param_set = -1; in ieee80211_assoc_success()
3585 ifmgd->mu_edca_last_param_set = -1; in ieee80211_assoc_success()
3587 if (ifmgd->flags & IEEE80211_STA_DISABLE_WMM) { in ieee80211_assoc_success()
3589 } else if (!ieee80211_sta_wmm_params(local, sdata, elems->wmm_param, in ieee80211_assoc_success()
3590 elems->wmm_param_len, in ieee80211_assoc_success()
3591 elems->mu_edca_param_set)) { in ieee80211_assoc_success()
3594 /* set the disable-WMM flag in this case to disable in ieee80211_assoc_success()
3601 ifmgd->flags |= IEEE80211_STA_DISABLE_WMM; in ieee80211_assoc_success()
3605 if (elems->max_idle_period_ie) { in ieee80211_assoc_success()
3606 bss_conf->max_idle_period = in ieee80211_assoc_success()
3607 le16_to_cpu(elems->max_idle_period_ie->max_idle_period); in ieee80211_assoc_success()
3608 bss_conf->protected_keep_alive = in ieee80211_assoc_success()
3609 !!(elems->max_idle_period_ie->idle_options & in ieee80211_assoc_success()
3613 bss_conf->max_idle_period = 0; in ieee80211_assoc_success()
3614 bss_conf->protected_keep_alive = false; in ieee80211_assoc_success()
3619 bss_conf->assoc_capability = capab_info; in ieee80211_assoc_success()
3623 * If we're using 4-addr mode, let the AP know that we're in ieee80211_assoc_success()
3624 * doing so, so that it can create the STA VLAN on its side in ieee80211_assoc_success()
3626 if (ifmgd->use_4addr) in ieee80211_assoc_success()
3646 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_rx_mgmt_assoc_resp()
3647 struct ieee80211_mgd_assoc_data *assoc_data = ifmgd->assoc_data; in ieee80211_rx_mgmt_assoc_resp()
3650 int ac, uapsd_queues = -1; in ieee80211_rx_mgmt_assoc_resp()
3664 if (!ether_addr_equal(assoc_data->bss->bssid, mgmt->bssid)) in ieee80211_rx_mgmt_assoc_resp()
3667 cbss = assoc_data->bss; in ieee80211_rx_mgmt_assoc_resp()
3677 reassoc = ieee80211_is_reassoc_resp(mgmt->frame_control); in ieee80211_rx_mgmt_assoc_resp()
3678 capab_info = le16_to_cpu(mgmt->u.assoc_resp.capab_info); in ieee80211_rx_mgmt_assoc_resp()
3679 status_code = le16_to_cpu(mgmt->u.assoc_resp.status_code); in ieee80211_rx_mgmt_assoc_resp()
3680 pos = mgmt->u.assoc_resp.variable; in ieee80211_rx_mgmt_assoc_resp()
3681 aid = le16_to_cpu(mgmt->u.assoc_resp.aid); in ieee80211_rx_mgmt_assoc_resp()
3682 if (cbss->channel->band == NL80211_BAND_S1GHZ) { in ieee80211_rx_mgmt_assoc_resp()
3683 pos = (u8 *) mgmt->u.s1g_assoc_resp.variable; in ieee80211_rx_mgmt_assoc_resp()
3689 reassoc ? "Rea" : "A", mgmt->sa, in ieee80211_rx_mgmt_assoc_resp()
3692 if (assoc_data->fils_kek_len && in ieee80211_rx_mgmt_assoc_resp()
3696 ieee802_11_parse_elems(pos, len - (pos - (u8 *)mgmt), false, &elems, in ieee80211_rx_mgmt_assoc_resp()
3697 mgmt->bssid, assoc_data->bss->bssid); in ieee80211_rx_mgmt_assoc_resp()
3701 elems.timeout_int->type == WLAN_TIMEOUT_ASSOC_COMEBACK) { in ieee80211_rx_mgmt_assoc_resp()
3703 tu = le32_to_cpu(elems.timeout_int->value); in ieee80211_rx_mgmt_assoc_resp()
3707 mgmt->sa, tu, ms); in ieee80211_rx_mgmt_assoc_resp()
3708 assoc_data->timeout = jiffies + msecs_to_jiffies(ms); in ieee80211_rx_mgmt_assoc_resp()
3709 assoc_data->timeout_started = true; in ieee80211_rx_mgmt_assoc_resp()
3711 run_again(sdata, assoc_data->timeout); in ieee80211_rx_mgmt_assoc_resp()
3717 mgmt->sa, status_code); in ieee80211_rx_mgmt_assoc_resp()
3721 drv_event_callback(sdata->local, sdata, &event); in ieee80211_rx_mgmt_assoc_resp()
3724 /* oops -- internal error -- send timeout for now */ in ieee80211_rx_mgmt_assoc_resp()
3726 cfg80211_assoc_timeout(sdata->dev, cbss); in ieee80211_rx_mgmt_assoc_resp()
3730 drv_event_callback(sdata->local, sdata, &event); in ieee80211_rx_mgmt_assoc_resp()
3743 if (sdata->tx_conf[ac].uapsd) in ieee80211_rx_mgmt_assoc_resp()
3747 cfg80211_rx_assoc_resp(sdata->dev, cbss, (u8 *)mgmt, len, uapsd_queues, in ieee80211_rx_mgmt_assoc_resp()
3748 ifmgd->assoc_req_ies, ifmgd->assoc_req_ies_len); in ieee80211_rx_mgmt_assoc_resp()
3755 struct ieee80211_local *local = sdata->local; in ieee80211_rx_bss_info()
3761 channel = ieee80211_get_channel_khz(local->hw.wiphy, in ieee80211_rx_bss_info()
3768 sdata->vif.bss_conf.beacon_rate = bss->beacon_rate; in ieee80211_rx_bss_info()
3777 struct ieee80211_mgmt *mgmt = (void *)skb->data; in ieee80211_rx_mgmt_probe_resp()
3779 struct ieee80211_rx_status *rx_status = (void *) skb->cb; in ieee80211_rx_mgmt_probe_resp()
3781 size_t baselen, len = skb->len; in ieee80211_rx_mgmt_probe_resp()
3783 ifmgd = &sdata->u.mgd; in ieee80211_rx_mgmt_probe_resp()
3794 channel = ieee80211_get_channel(sdata->local->hw.wiphy, in ieee80211_rx_mgmt_probe_resp()
3795 rx_status->freq); in ieee80211_rx_mgmt_probe_resp()
3799 if (!ether_addr_equal(mgmt->da, sdata->vif.addr) && in ieee80211_rx_mgmt_probe_resp()
3800 (channel->band != NL80211_BAND_6GHZ || in ieee80211_rx_mgmt_probe_resp()
3801 !is_broadcast_ether_addr(mgmt->da))) in ieee80211_rx_mgmt_probe_resp()
3804 baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt; in ieee80211_rx_mgmt_probe_resp()
3810 if (ifmgd->associated && in ieee80211_rx_mgmt_probe_resp()
3811 ether_addr_equal(mgmt->bssid, ifmgd->associated->bssid)) in ieee80211_rx_mgmt_probe_resp()
3826 * XXX: This list needs to be dynamic -- userspace needs to be able to
3847 if (ifmgd->flags & IEEE80211_STA_RESET_SIGNAL_AVE) { in ieee80211_handle_beacon_sig()
3848 ifmgd->flags &= ~IEEE80211_STA_RESET_SIGNAL_AVE; in ieee80211_handle_beacon_sig()
3849 ewma_beacon_signal_init(&ifmgd->ave_beacon_signal); in ieee80211_handle_beacon_sig()
3850 ifmgd->last_cqm_event_signal = 0; in ieee80211_handle_beacon_sig()
3851 ifmgd->count_beacon_signal = 1; in ieee80211_handle_beacon_sig()
3852 ifmgd->last_ave_beacon_signal = 0; in ieee80211_handle_beacon_sig()
3854 ifmgd->count_beacon_signal++; in ieee80211_handle_beacon_sig()
3857 ewma_beacon_signal_add(&ifmgd->ave_beacon_signal, -rx_status->signal); in ieee80211_handle_beacon_sig()
3859 if (ifmgd->rssi_min_thold != ifmgd->rssi_max_thold && in ieee80211_handle_beacon_sig()
3860 ifmgd->count_beacon_signal >= IEEE80211_SIGNAL_AVE_MIN_COUNT) { in ieee80211_handle_beacon_sig()
3861 int sig = -ewma_beacon_signal_read(&ifmgd->ave_beacon_signal); in ieee80211_handle_beacon_sig()
3862 int last_sig = ifmgd->last_ave_beacon_signal; in ieee80211_handle_beacon_sig()
3871 if (sig > ifmgd->rssi_max_thold && in ieee80211_handle_beacon_sig()
3872 (last_sig <= ifmgd->rssi_min_thold || last_sig == 0)) { in ieee80211_handle_beacon_sig()
3873 ifmgd->last_ave_beacon_signal = sig; in ieee80211_handle_beacon_sig()
3876 } else if (sig < ifmgd->rssi_min_thold && in ieee80211_handle_beacon_sig()
3877 (last_sig >= ifmgd->rssi_max_thold || in ieee80211_handle_beacon_sig()
3879 ifmgd->last_ave_beacon_signal = sig; in ieee80211_handle_beacon_sig()
3885 if (bss_conf->cqm_rssi_thold && in ieee80211_handle_beacon_sig()
3886 ifmgd->count_beacon_signal >= IEEE80211_SIGNAL_AVE_MIN_COUNT && in ieee80211_handle_beacon_sig()
3887 !(sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI)) { in ieee80211_handle_beacon_sig()
3888 int sig = -ewma_beacon_signal_read(&ifmgd->ave_beacon_signal); in ieee80211_handle_beacon_sig()
3889 int last_event = ifmgd->last_cqm_event_signal; in ieee80211_handle_beacon_sig()
3890 int thold = bss_conf->cqm_rssi_thold; in ieee80211_handle_beacon_sig()
3891 int hyst = bss_conf->cqm_rssi_hyst; in ieee80211_handle_beacon_sig()
3894 (last_event == 0 || sig < last_event - hyst)) { in ieee80211_handle_beacon_sig()
3895 ifmgd->last_cqm_event_signal = sig; in ieee80211_handle_beacon_sig()
3897 &sdata->vif, in ieee80211_handle_beacon_sig()
3902 ifmgd->last_cqm_event_signal = sig; in ieee80211_handle_beacon_sig()
3904 &sdata->vif, in ieee80211_handle_beacon_sig()
3910 if (bss_conf->cqm_rssi_low && in ieee80211_handle_beacon_sig()
3911 ifmgd->count_beacon_signal >= IEEE80211_SIGNAL_AVE_MIN_COUNT) { in ieee80211_handle_beacon_sig()
3912 int sig = -ewma_beacon_signal_read(&ifmgd->ave_beacon_signal); in ieee80211_handle_beacon_sig()
3913 int last_event = ifmgd->last_cqm_event_signal; in ieee80211_handle_beacon_sig()
3914 int low = bss_conf->cqm_rssi_low; in ieee80211_handle_beacon_sig()
3915 int high = bss_conf->cqm_rssi_high; in ieee80211_handle_beacon_sig()
3919 ifmgd->last_cqm_event_signal = sig; in ieee80211_handle_beacon_sig()
3921 &sdata->vif, in ieee80211_handle_beacon_sig()
3926 ifmgd->last_cqm_event_signal = sig; in ieee80211_handle_beacon_sig()
3928 &sdata->vif, in ieee80211_handle_beacon_sig()
3938 if (ether_addr_equal(tx_bssid, bss->bssid)) in ieee80211_rx_our_beacon()
3940 if (!bss->transmitted_bss) in ieee80211_rx_our_beacon()
3942 return ether_addr_equal(tx_bssid, bss->transmitted_bss->bssid); in ieee80211_rx_our_beacon()
3949 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_rx_mgmt_beacon()
3950 struct ieee80211_bss_conf *bss_conf = &sdata->vif.bss_conf; in ieee80211_rx_mgmt_beacon()
3954 struct ieee80211_local *local = sdata->local; in ieee80211_rx_mgmt_beacon()
3962 u8 *bssid, *variable = mgmt->u.beacon.variable; in ieee80211_rx_mgmt_beacon()
3968 bssid = ieee80211_get_bssid(hdr, len, sdata->vif.type); in ieee80211_rx_mgmt_beacon()
3969 if (ieee80211_is_s1g_beacon(mgmt->frame_control)) { in ieee80211_rx_mgmt_beacon()
3972 if (ieee80211_is_s1g_short_beacon(ext->frame_control)) in ieee80211_rx_mgmt_beacon()
3973 variable = ext->u.s1g_short_beacon.variable; in ieee80211_rx_mgmt_beacon()
3975 variable = ext->u.s1g_beacon.variable; in ieee80211_rx_mgmt_beacon()
3978 baselen = (u8 *) variable - (u8 *) mgmt; in ieee80211_rx_mgmt_beacon()
3983 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); in ieee80211_rx_mgmt_beacon()
3990 ieee80211_channel_to_khz(chanctx_conf->def.chan)) { in ieee80211_rx_mgmt_beacon()
3994 chan = chanctx_conf->def.chan; in ieee80211_rx_mgmt_beacon()
3997 if (ifmgd->assoc_data && ifmgd->assoc_data->need_beacon && in ieee80211_rx_mgmt_beacon()
3998 ieee80211_rx_our_beacon(bssid, ifmgd->assoc_data->bss)) { in ieee80211_rx_mgmt_beacon()
4000 len - baselen, false, &elems, in ieee80211_rx_mgmt_beacon()
4002 ifmgd->assoc_data->bss->bssid); in ieee80211_rx_mgmt_beacon()
4007 ifmgd->dtim_period = elems.dtim_period; in ieee80211_rx_mgmt_beacon()
4008 ifmgd->have_beacon = true; in ieee80211_rx_mgmt_beacon()
4009 ifmgd->assoc_data->need_beacon = false; in ieee80211_rx_mgmt_beacon()
4010 if (ieee80211_hw_check(&local->hw, TIMING_BEACON_ONLY)) { in ieee80211_rx_mgmt_beacon()
4011 sdata->vif.bss_conf.sync_tsf = in ieee80211_rx_mgmt_beacon()
4012 le64_to_cpu(mgmt->u.beacon.timestamp); in ieee80211_rx_mgmt_beacon()
4013 sdata->vif.bss_conf.sync_device_ts = in ieee80211_rx_mgmt_beacon()
4014 rx_status->device_timestamp; in ieee80211_rx_mgmt_beacon()
4015 sdata->vif.bss_conf.sync_dtim_count = elems.dtim_count; in ieee80211_rx_mgmt_beacon()
4019 bss_conf->profile_periodicity = in ieee80211_rx_mgmt_beacon()
4020 elems.mbssid_config_ie->profile_periodicity; in ieee80211_rx_mgmt_beacon()
4022 bss_conf->profile_periodicity = 0; in ieee80211_rx_mgmt_beacon()
4026 bss_conf->ema_ap = true; in ieee80211_rx_mgmt_beacon()
4028 bss_conf->ema_ap = false; in ieee80211_rx_mgmt_beacon()
4031 ifmgd->assoc_data->timeout = jiffies; in ieee80211_rx_mgmt_beacon()
4032 ifmgd->assoc_data->timeout_started = true; in ieee80211_rx_mgmt_beacon()
4033 run_again(sdata, ifmgd->assoc_data->timeout); in ieee80211_rx_mgmt_beacon()
4038 if (!ifmgd->associated || in ieee80211_rx_mgmt_beacon()
4039 !ieee80211_rx_our_beacon(bssid, ifmgd->associated)) in ieee80211_rx_mgmt_beacon()
4041 bssid = ifmgd->associated->bssid; in ieee80211_rx_mgmt_beacon()
4043 if (!(rx_status->flag & RX_FLAG_NO_SIGNAL_VAL)) in ieee80211_rx_mgmt_beacon()
4047 if (ifmgd->flags & IEEE80211_STA_CONNECTION_POLL) { in ieee80211_rx_mgmt_beacon()
4064 if (!ieee80211_is_s1g_beacon(hdr->frame_control)) in ieee80211_rx_mgmt_beacon()
4065 ncrc = crc32_be(0, (void *)&mgmt->u.beacon.beacon_int, 4); in ieee80211_rx_mgmt_beacon()
4067 len - baselen, false, &elems, in ieee80211_rx_mgmt_beacon()
4069 mgmt->bssid, bssid); in ieee80211_rx_mgmt_beacon()
4071 if (ieee80211_hw_check(&local->hw, PS_NULLFUNC_STACK) && in ieee80211_rx_mgmt_beacon()
4072 ieee80211_check_tim(elems.tim, elems.tim_len, bss_conf->aid)) { in ieee80211_rx_mgmt_beacon()
4073 if (local->hw.conf.dynamic_ps_timeout > 0) { in ieee80211_rx_mgmt_beacon()
4074 if (local->hw.conf.flags & IEEE80211_CONF_PS) { in ieee80211_rx_mgmt_beacon()
4075 local->hw.conf.flags &= ~IEEE80211_CONF_PS; in ieee80211_rx_mgmt_beacon()
4080 } else if (!local->pspolling && sdata->u.mgd.powersave) { in ieee80211_rx_mgmt_beacon()
4081 local->pspolling = true; in ieee80211_rx_mgmt_beacon()
4085 * able to send ps-poll frame and receive a in ieee80211_rx_mgmt_beacon()
4095 if (sdata->vif.p2p || in ieee80211_rx_mgmt_beacon()
4096 sdata->vif.driver_flags & IEEE80211_VIF_GET_NOA_UPDATE) { in ieee80211_rx_mgmt_beacon()
4101 len - baselen, in ieee80211_rx_mgmt_beacon()
4105 if (sdata->u.mgd.p2p_noa_index != noa.index) { in ieee80211_rx_mgmt_beacon()
4107 sdata->u.mgd.p2p_noa_index = noa.index; in ieee80211_rx_mgmt_beacon()
4108 memcpy(&bss_conf->p2p_noa_attr, &noa, sizeof(noa)); in ieee80211_rx_mgmt_beacon()
4114 ifmgd->beacon_crc_valid = false; in ieee80211_rx_mgmt_beacon()
4116 } else if (sdata->u.mgd.p2p_noa_index != -1) { in ieee80211_rx_mgmt_beacon()
4118 sdata->u.mgd.p2p_noa_index = -1; in ieee80211_rx_mgmt_beacon()
4119 memset(&bss_conf->p2p_noa_attr, 0, sizeof(bss_conf->p2p_noa_attr)); in ieee80211_rx_mgmt_beacon()
4121 ifmgd->beacon_crc_valid = false; in ieee80211_rx_mgmt_beacon()
4125 if (ifmgd->csa_waiting_bcn) in ieee80211_rx_mgmt_beacon()
4136 if (ieee80211_hw_check(&local->hw, TIMING_BEACON_ONLY) && in ieee80211_rx_mgmt_beacon()
4137 !ieee80211_is_s1g_beacon(hdr->frame_control)) { in ieee80211_rx_mgmt_beacon()
4138 sdata->vif.bss_conf.sync_tsf = in ieee80211_rx_mgmt_beacon()
4139 le64_to_cpu(mgmt->u.beacon.timestamp); in ieee80211_rx_mgmt_beacon()
4140 sdata->vif.bss_conf.sync_device_ts = in ieee80211_rx_mgmt_beacon()
4141 rx_status->device_timestamp; in ieee80211_rx_mgmt_beacon()
4142 sdata->vif.bss_conf.sync_dtim_count = elems.dtim_count; in ieee80211_rx_mgmt_beacon()
4145 if ((ncrc == ifmgd->beacon_crc && ifmgd->beacon_crc_valid) || in ieee80211_rx_mgmt_beacon()
4146 ieee80211_is_s1g_short_beacon(mgmt->frame_control)) in ieee80211_rx_mgmt_beacon()
4148 ifmgd->beacon_crc = ncrc; in ieee80211_rx_mgmt_beacon()
4149 ifmgd->beacon_crc_valid = true; in ieee80211_rx_mgmt_beacon()
4153 ieee80211_sta_process_chanswitch(sdata, rx_status->mactime, in ieee80211_rx_mgmt_beacon()
4154 rx_status->device_timestamp, in ieee80211_rx_mgmt_beacon()
4157 if (!(ifmgd->flags & IEEE80211_STA_DISABLE_WMM) && in ieee80211_rx_mgmt_beacon()
4167 if (!ifmgd->have_beacon) { in ieee80211_rx_mgmt_beacon()
4169 bss_conf->dtim_period = elems.dtim_period ?: 1; in ieee80211_rx_mgmt_beacon()
4172 ifmgd->have_beacon = true; in ieee80211_rx_mgmt_beacon()
4174 mutex_lock(&local->iflist_mtx); in ieee80211_rx_mgmt_beacon()
4176 mutex_unlock(&local->iflist_mtx); in ieee80211_rx_mgmt_beacon()
4188 if (!ieee80211_is_s1g_beacon(hdr->frame_control)) in ieee80211_rx_mgmt_beacon()
4190 le16_to_cpu(mgmt->u.beacon.capab_info), in ieee80211_rx_mgmt_beacon()
4193 mutex_lock(&local->sta_mtx); in ieee80211_rx_mgmt_beacon()
4202 mutex_unlock(&local->sta_mtx); in ieee80211_rx_mgmt_beacon()
4217 rx_status->band); in ieee80211_rx_mgmt_beacon()
4218 mutex_unlock(&local->sta_mtx); in ieee80211_rx_mgmt_beacon()
4238 rx_status = (struct ieee80211_rx_status *) skb->cb; in ieee80211_sta_rx_queued_ext()
4239 hdr = (struct ieee80211_hdr *) skb->data; in ieee80211_sta_rx_queued_ext()
4240 fc = le16_to_cpu(hdr->frame_control); in ieee80211_sta_rx_queued_ext()
4245 ieee80211_rx_mgmt_beacon(sdata, hdr, skb->len, rx_status); in ieee80211_sta_rx_queued_ext()
4260 rx_status = (struct ieee80211_rx_status *) skb->cb; in ieee80211_sta_rx_queued_mgmt()
4261 mgmt = (struct ieee80211_mgmt *) skb->data; in ieee80211_sta_rx_queued_mgmt()
4262 fc = le16_to_cpu(mgmt->frame_control); in ieee80211_sta_rx_queued_mgmt()
4269 skb->len, rx_status); in ieee80211_sta_rx_queued_mgmt()
4275 ieee80211_rx_mgmt_auth(sdata, mgmt, skb->len); in ieee80211_sta_rx_queued_mgmt()
4278 ieee80211_rx_mgmt_deauth(sdata, mgmt, skb->len); in ieee80211_sta_rx_queued_mgmt()
4281 ieee80211_rx_mgmt_disassoc(sdata, mgmt, skb->len); in ieee80211_sta_rx_queued_mgmt()
4285 ieee80211_rx_mgmt_assoc_resp(sdata, mgmt, skb->len); in ieee80211_sta_rx_queued_mgmt()
4288 if (mgmt->u.action.category == WLAN_CATEGORY_SPECTRUM_MGMT) { in ieee80211_sta_rx_queued_mgmt()
4289 ies_len = skb->len - in ieee80211_sta_rx_queued_mgmt()
4298 mgmt->u.action.u.chan_switch.variable, in ieee80211_sta_rx_queued_mgmt()
4299 ies_len, true, &elems, mgmt->bssid, NULL); in ieee80211_sta_rx_queued_mgmt()
4305 rx_status->mactime, in ieee80211_sta_rx_queued_mgmt()
4306 rx_status->device_timestamp, in ieee80211_sta_rx_queued_mgmt()
4308 } else if (mgmt->u.action.category == WLAN_CATEGORY_PUBLIC) { in ieee80211_sta_rx_queued_mgmt()
4309 ies_len = skb->len - in ieee80211_sta_rx_queued_mgmt()
4321 mgmt->u.action.u.ext_chan_switch.variable, in ieee80211_sta_rx_queued_mgmt()
4322 ies_len, true, &elems, mgmt->bssid, NULL); in ieee80211_sta_rx_queued_mgmt()
4329 &mgmt->u.action.u.ext_chan_switch.data; in ieee80211_sta_rx_queued_mgmt()
4332 rx_status->mactime, in ieee80211_sta_rx_queued_mgmt()
4333 rx_status->device_timestamp, in ieee80211_sta_rx_queued_mgmt()
4346 ieee80211_queue_work(&sdata->local->hw, &sdata->work); in ieee80211_sta_timer()
4363 struct ieee80211_local *local = sdata->local; in ieee80211_auth()
4364 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_auth()
4365 struct ieee80211_mgd_auth_data *auth_data = ifmgd->auth_data; in ieee80211_auth()
4374 return -EINVAL; in ieee80211_auth()
4376 auth_data->tries++; in ieee80211_auth()
4378 if (auth_data->tries > IEEE80211_AUTH_MAX_TRIES) { in ieee80211_auth()
4380 auth_data->bss->bssid); in ieee80211_auth()
4386 cfg80211_unlink_bss(local->hw.wiphy, auth_data->bss); in ieee80211_auth()
4388 return -ETIMEDOUT; in ieee80211_auth()
4391 if (auth_data->algorithm == WLAN_AUTH_SAE) in ieee80211_auth()
4398 auth_data->bss->bssid, auth_data->tries, in ieee80211_auth()
4401 auth_data->expected_transaction = 2; in ieee80211_auth()
4403 if (auth_data->algorithm == WLAN_AUTH_SAE) { in ieee80211_auth()
4404 trans = auth_data->sae_trans; in ieee80211_auth()
4405 status = auth_data->sae_status; in ieee80211_auth()
4406 auth_data->expected_transaction = trans; in ieee80211_auth()
4409 if (ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS)) in ieee80211_auth()
4413 ieee80211_send_auth(sdata, trans, auth_data->algorithm, status, in ieee80211_auth()
4414 auth_data->data, auth_data->data_len, in ieee80211_auth()
4415 auth_data->bss->bssid, in ieee80211_auth()
4416 auth_data->bss->bssid, NULL, 0, 0, in ieee80211_auth()
4420 if (auth_data->algorithm == WLAN_AUTH_SAE) in ieee80211_auth()
4421 auth_data->timeout = jiffies + in ieee80211_auth()
4424 auth_data->timeout = jiffies + IEEE80211_AUTH_TIMEOUT; in ieee80211_auth()
4426 auth_data->timeout = in ieee80211_auth()
4430 auth_data->timeout_started = true; in ieee80211_auth()
4431 run_again(sdata, auth_data->timeout); in ieee80211_auth()
4438 struct ieee80211_mgd_assoc_data *assoc_data = sdata->u.mgd.assoc_data; in ieee80211_do_assoc()
4439 struct ieee80211_local *local = sdata->local; in ieee80211_do_assoc()
4443 assoc_data->tries++; in ieee80211_do_assoc()
4444 if (assoc_data->tries > IEEE80211_ASSOC_MAX_TRIES) { in ieee80211_do_assoc()
4446 assoc_data->bss->bssid); in ieee80211_do_assoc()
4452 cfg80211_unlink_bss(local->hw.wiphy, assoc_data->bss); in ieee80211_do_assoc()
4454 return -ETIMEDOUT; in ieee80211_do_assoc()
4458 assoc_data->bss->bssid, assoc_data->tries, in ieee80211_do_assoc()
4462 if (!ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS)) { in ieee80211_do_assoc()
4463 assoc_data->timeout = jiffies + IEEE80211_ASSOC_TIMEOUT; in ieee80211_do_assoc()
4464 assoc_data->timeout_started = true; in ieee80211_do_assoc()
4465 run_again(sdata, assoc_data->timeout); in ieee80211_do_assoc()
4467 assoc_data->timeout = in ieee80211_do_assoc()
4470 assoc_data->timeout_started = true; in ieee80211_do_assoc()
4471 run_again(sdata, assoc_data->timeout); in ieee80211_do_assoc()
4480 struct ieee80211_local *local = sdata->local; in ieee80211_mgd_conn_tx_status()
4482 sdata->u.mgd.status_fc = fc; in ieee80211_mgd_conn_tx_status()
4483 sdata->u.mgd.status_acked = acked; in ieee80211_mgd_conn_tx_status()
4484 sdata->u.mgd.status_received = true; in ieee80211_mgd_conn_tx_status()
4486 ieee80211_queue_work(&local->hw, &sdata->work); in ieee80211_mgd_conn_tx_status()
4491 struct ieee80211_local *local = sdata->local; in ieee80211_sta_work()
4492 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_sta_work()
4496 if (ifmgd->status_received) { in ieee80211_sta_work()
4497 __le16 fc = ifmgd->status_fc; in ieee80211_sta_work()
4498 bool status_acked = ifmgd->status_acked; in ieee80211_sta_work()
4500 ifmgd->status_received = false; in ieee80211_sta_work()
4501 if (ifmgd->auth_data && ieee80211_is_auth(fc)) { in ieee80211_sta_work()
4503 if (ifmgd->auth_data->algorithm == in ieee80211_sta_work()
4505 ifmgd->auth_data->timeout = in ieee80211_sta_work()
4509 ifmgd->auth_data->timeout = in ieee80211_sta_work()
4512 run_again(sdata, ifmgd->auth_data->timeout); in ieee80211_sta_work()
4514 ifmgd->auth_data->timeout = jiffies - 1; in ieee80211_sta_work()
4516 ifmgd->auth_data->timeout_started = true; in ieee80211_sta_work()
4517 } else if (ifmgd->assoc_data && in ieee80211_sta_work()
4521 ifmgd->assoc_data->timeout = in ieee80211_sta_work()
4523 run_again(sdata, ifmgd->assoc_data->timeout); in ieee80211_sta_work()
4525 ifmgd->assoc_data->timeout = jiffies - 1; in ieee80211_sta_work()
4527 ifmgd->assoc_data->timeout_started = true; in ieee80211_sta_work()
4531 if (ifmgd->auth_data && ifmgd->auth_data->timeout_started && in ieee80211_sta_work()
4532 time_after(jiffies, ifmgd->auth_data->timeout)) { in ieee80211_sta_work()
4533 if (ifmgd->auth_data->done) { in ieee80211_sta_work()
4547 memcpy(bssid, ifmgd->auth_data->bss->bssid, ETH_ALEN); in ieee80211_sta_work()
4551 cfg80211_auth_timeout(sdata->dev, bssid); in ieee80211_sta_work()
4552 drv_event_callback(sdata->local, sdata, &event); in ieee80211_sta_work()
4554 } else if (ifmgd->auth_data && ifmgd->auth_data->timeout_started) in ieee80211_sta_work()
4555 run_again(sdata, ifmgd->auth_data->timeout); in ieee80211_sta_work()
4557 if (ifmgd->assoc_data && ifmgd->assoc_data->timeout_started && in ieee80211_sta_work()
4558 time_after(jiffies, ifmgd->assoc_data->timeout)) { in ieee80211_sta_work()
4559 if ((ifmgd->assoc_data->need_beacon && !ifmgd->have_beacon) || in ieee80211_sta_work()
4561 struct cfg80211_bss *bss = ifmgd->assoc_data->bss; in ieee80211_sta_work()
4569 cfg80211_assoc_timeout(sdata->dev, bss); in ieee80211_sta_work()
4570 drv_event_callback(sdata->local, sdata, &event); in ieee80211_sta_work()
4572 } else if (ifmgd->assoc_data && ifmgd->assoc_data->timeout_started) in ieee80211_sta_work()
4573 run_again(sdata, ifmgd->assoc_data->timeout); in ieee80211_sta_work()
4575 if (ifmgd->flags & IEEE80211_STA_CONNECTION_POLL && in ieee80211_sta_work()
4576 ifmgd->associated) { in ieee80211_sta_work()
4580 memcpy(bssid, ifmgd->associated->bssid, ETH_ALEN); in ieee80211_sta_work()
4582 if (ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS)) in ieee80211_sta_work()
4588 if (!ifmgd->probe_send_count) in ieee80211_sta_work()
4590 else if (ifmgd->nullfunc_failed) { in ieee80211_sta_work()
4591 if (ifmgd->probe_send_count < max_tries) { in ieee80211_sta_work()
4594 bssid, ifmgd->probe_send_count, in ieee80211_sta_work()
4605 } else if (time_is_after_jiffies(ifmgd->probe_timeout)) in ieee80211_sta_work()
4606 run_again(sdata, ifmgd->probe_timeout); in ieee80211_sta_work()
4607 else if (ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS)) { in ieee80211_sta_work()
4613 } else if (ifmgd->probe_send_count < max_tries) { in ieee80211_sta_work()
4617 ifmgd->probe_send_count, max_tries); in ieee80211_sta_work()
4640 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_sta_bcn_mon_timer()
4642 if (sdata->vif.csa_active && !ifmgd->csa_waiting_bcn) in ieee80211_sta_bcn_mon_timer()
4645 if (sdata->vif.driver_flags & IEEE80211_VIF_BEACON_FILTER) in ieee80211_sta_bcn_mon_timer()
4648 sdata->u.mgd.connection_loss = false; in ieee80211_sta_bcn_mon_timer()
4649 ieee80211_queue_work(&sdata->local->hw, in ieee80211_sta_bcn_mon_timer()
4650 &sdata->u.mgd.beacon_connection_loss_work); in ieee80211_sta_bcn_mon_timer()
4657 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_sta_conn_mon_timer()
4658 struct ieee80211_local *local = sdata->local; in ieee80211_sta_conn_mon_timer()
4662 if (sdata->vif.csa_active && !ifmgd->csa_waiting_bcn) in ieee80211_sta_conn_mon_timer()
4665 sta = sta_info_get(sdata, ifmgd->bssid); in ieee80211_sta_conn_mon_timer()
4669 timeout = sta->status_stats.last_ack; in ieee80211_sta_conn_mon_timer()
4670 if (time_before(sta->status_stats.last_ack, sta->rx_stats.last_rx)) in ieee80211_sta_conn_mon_timer()
4671 timeout = sta->rx_stats.last_rx; in ieee80211_sta_conn_mon_timer()
4678 mod_timer(&ifmgd->conn_mon_timer, round_jiffies_up(timeout)); in ieee80211_sta_conn_mon_timer()
4682 ieee80211_queue_work(&local->hw, &ifmgd->monitor_work); in ieee80211_sta_conn_mon_timer()
4696 if (sdata->vif.type == NL80211_IFTYPE_STATION) { in ieee80211_restart_sta_timer()
4700 if (!ieee80211_hw_check(&sdata->local->hw, CONNECTION_MONITOR)) in ieee80211_restart_sta_timer()
4701 ieee80211_queue_work(&sdata->local->hw, in ieee80211_restart_sta_timer()
4702 &sdata->u.mgd.monitor_work); in ieee80211_restart_sta_timer()
4709 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_mgd_quiesce()
4714 if (ifmgd->auth_data || ifmgd->assoc_data) { in ieee80211_mgd_quiesce()
4715 const u8 *bssid = ifmgd->auth_data ? in ieee80211_mgd_quiesce()
4716 ifmgd->auth_data->bss->bssid : in ieee80211_mgd_quiesce()
4717 ifmgd->assoc_data->bss->bssid; in ieee80211_mgd_quiesce()
4728 if (ifmgd->assoc_data) in ieee80211_mgd_quiesce()
4730 if (ifmgd->auth_data) in ieee80211_mgd_quiesce()
4732 cfg80211_tx_mlme_mgmt(sdata->dev, frame_buf, in ieee80211_mgd_quiesce()
4736 /* This is a bit of a hack - we should find a better and more generic in ieee80211_mgd_quiesce()
4753 if (ifmgd->associated && !sdata->local->wowlan) { in ieee80211_mgd_quiesce()
4760 memcpy(bssid, ifmgd->associated->bssid, ETH_ALEN); in ieee80211_mgd_quiesce()
4769 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_sta_restart()
4772 if (!ifmgd->associated) { in ieee80211_sta_restart()
4777 if (sdata->flags & IEEE80211_SDATA_DISCONNECT_RESUME) { in ieee80211_sta_restart()
4778 sdata->flags &= ~IEEE80211_SDATA_DISCONNECT_RESUME; in ieee80211_sta_restart()
4781 ifmgd->associated->bssid, in ieee80211_sta_restart()
4796 ifmgd = &sdata->u.mgd; in ieee80211_sta_setup_sdata()
4797 INIT_WORK(&ifmgd->monitor_work, ieee80211_sta_monitor_work); in ieee80211_sta_setup_sdata()
4798 INIT_WORK(&ifmgd->chswitch_work, ieee80211_chswitch_work); in ieee80211_sta_setup_sdata()
4799 INIT_WORK(&ifmgd->beacon_connection_loss_work, in ieee80211_sta_setup_sdata()
4801 INIT_WORK(&ifmgd->csa_connection_drop_work, in ieee80211_sta_setup_sdata()
4803 INIT_WORK(&ifmgd->request_smps_work, ieee80211_request_smps_mgd_work); in ieee80211_sta_setup_sdata()
4804 INIT_DELAYED_WORK(&ifmgd->tdls_peer_del_work, in ieee80211_sta_setup_sdata()
4806 timer_setup(&ifmgd->timer, ieee80211_sta_timer, 0); in ieee80211_sta_setup_sdata()
4807 timer_setup(&ifmgd->bcn_mon_timer, ieee80211_sta_bcn_mon_timer, 0); in ieee80211_sta_setup_sdata()
4808 timer_setup(&ifmgd->conn_mon_timer, ieee80211_sta_conn_mon_timer, 0); in ieee80211_sta_setup_sdata()
4809 timer_setup(&ifmgd->chswitch_timer, ieee80211_chswitch_timer, 0); in ieee80211_sta_setup_sdata()
4810 INIT_DELAYED_WORK(&ifmgd->tx_tspec_wk, in ieee80211_sta_setup_sdata()
4813 ifmgd->flags = 0; in ieee80211_sta_setup_sdata()
4814 ifmgd->powersave = sdata->wdev.ps; in ieee80211_sta_setup_sdata()
4815 ifmgd->uapsd_queues = sdata->local->hw.uapsd_queues; in ieee80211_sta_setup_sdata()
4816 ifmgd->uapsd_max_sp_len = sdata->local->hw.uapsd_max_sp_len; in ieee80211_sta_setup_sdata()
4817 ifmgd->p2p_noa_index = -1; in ieee80211_sta_setup_sdata()
4819 if (sdata->local->hw.wiphy->features & NL80211_FEATURE_DYNAMIC_SMPS) in ieee80211_sta_setup_sdata()
4820 ifmgd->req_smps = IEEE80211_SMPS_AUTOMATIC; in ieee80211_sta_setup_sdata()
4822 ifmgd->req_smps = IEEE80211_SMPS_OFF; in ieee80211_sta_setup_sdata()
4825 spin_lock_init(&ifmgd->teardown_lock); in ieee80211_sta_setup_sdata()
4826 ifmgd->teardown_skb = NULL; in ieee80211_sta_setup_sdata()
4827 ifmgd->orig_teardown_skb = NULL; in ieee80211_sta_setup_sdata()
4837 list_for_each_entry_rcu(sdata, &local->interfaces, list) { in ieee80211_mlme_notify_scan_completed()
4847 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_ht_vht_rx_chains()
4853 if (ifmgd->flags & IEEE80211_STA_DISABLE_HT) in ieee80211_ht_vht_rx_chains()
4859 chains = ieee80211_mcs_to_chains(&ht_cap->mcs); in ieee80211_ht_vht_rx_chains()
4866 if (ifmgd->flags & IEEE80211_STA_DISABLE_VHT) in ieee80211_ht_vht_rx_chains()
4875 tx_mcs_map = le16_to_cpu(vht_cap->supp_mcs.tx_mcs_map); in ieee80211_ht_vht_rx_chains()
4876 for (nss = 8; nss > 0; nss--) { in ieee80211_ht_vht_rx_chains()
4877 if (((tx_mcs_map >> (2 * (nss - 1))) & 3) != in ieee80211_ht_vht_rx_chains()
4900 ap_min_req_set = le16_to_cpu(he_op->he_mcs_nss_set); in ieee80211_verify_sta_he_mcs_support()
4905 &sta_he_cap->he_mcs_nss_supp; in ieee80211_verify_sta_he_mcs_support()
4915 * possible. Each of the sta_mcs_map_* is a 16-bit struct built in ieee80211_verify_sta_he_mcs_support()
4916 * of 2 bits per NSS (1-8), with the values defined in enum in ieee80211_verify_sta_he_mcs_support()
4922 for (nss = 8; nss > 0; nss--) { in ieee80211_verify_sta_he_mcs_support()
4923 u8 sta_rx_val = (sta_mcs_map_rx >> (2 * (nss - 1))) & 3; in ieee80211_verify_sta_he_mcs_support()
4924 u8 sta_tx_val = (sta_mcs_map_tx >> (2 * (nss - 1))) & 3; in ieee80211_verify_sta_he_mcs_support()
4925 u8 ap_val = (ap_min_req_set >> (2 * (nss - 1))) & 3; in ieee80211_verify_sta_he_mcs_support()
4953 struct ieee80211_local *local = sdata->local; in ieee80211_prep_channel()
4954 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_prep_channel()
4962 bool is_6ghz = cbss->channel->band == NL80211_BAND_6GHZ; in ieee80211_prep_channel()
4963 bool is_5ghz = cbss->channel->band == NL80211_BAND_5GHZ; in ieee80211_prep_channel()
4964 struct ieee80211_bss *bss = (void *)cbss->priv; in ieee80211_prep_channel()
4969 sband = local->hw.wiphy->bands[cbss->channel->band]; in ieee80211_prep_channel()
4971 ifmgd->flags &= ~(IEEE80211_STA_DISABLE_40MHZ | in ieee80211_prep_channel()
4976 if (!sband->ht_cap.ht_supported && !is_6ghz) { in ieee80211_prep_channel()
4977 ifmgd->flags |= IEEE80211_STA_DISABLE_HT; in ieee80211_prep_channel()
4978 ifmgd->flags |= IEEE80211_STA_DISABLE_VHT; in ieee80211_prep_channel()
4979 ifmgd->flags |= IEEE80211_STA_DISABLE_HE; in ieee80211_prep_channel()
4982 if (!sband->vht_cap.vht_supported && is_5ghz) { in ieee80211_prep_channel()
4983 ifmgd->flags |= IEEE80211_STA_DISABLE_VHT; in ieee80211_prep_channel()
4984 ifmgd->flags |= IEEE80211_STA_DISABLE_HE; in ieee80211_prep_channel()
4988 ifmgd->flags |= IEEE80211_STA_DISABLE_HE; in ieee80211_prep_channel()
4992 if (!(ifmgd->flags & IEEE80211_STA_DISABLE_HT) && !is_6ghz) { in ieee80211_prep_channel()
5004 ifmgd->flags |= IEEE80211_STA_DISABLE_HT; in ieee80211_prep_channel()
5009 if (!(ifmgd->flags & IEEE80211_STA_DISABLE_VHT) && !is_6ghz) { in ieee80211_prep_channel()
5020 ifmgd->flags |= IEEE80211_STA_DISABLE_HT; in ieee80211_prep_channel()
5021 ifmgd->flags |= IEEE80211_STA_DISABLE_VHT; in ieee80211_prep_channel()
5022 ifmgd->flags |= IEEE80211_STA_DISABLE_HE; in ieee80211_prep_channel()
5027 ifmgd->flags |= IEEE80211_STA_DISABLE_VHT; in ieee80211_prep_channel()
5032 if (!(ifmgd->flags & IEEE80211_STA_DISABLE_HE)) { in ieee80211_prep_channel()
5036 ies = rcu_dereference(cbss->ies); in ieee80211_prep_channel()
5038 ies->data, ies->len); in ieee80211_prep_channel()
5046 ifmgd->flags |= IEEE80211_STA_DISABLE_HE; in ieee80211_prep_channel()
5051 for (i = 0; i < sband->n_channels; i++) { in ieee80211_prep_channel()
5052 if (sband->channels[i].flags & (IEEE80211_CHAN_DISABLED | in ieee80211_prep_channel()
5061 ifmgd->flags |= IEEE80211_STA_DISABLE_VHT; in ieee80211_prep_channel()
5063 if (sband->band == NL80211_BAND_S1GHZ) { in ieee80211_prep_channel()
5075 ifmgd->flags |= ieee80211_determine_chantype(sdata, sband, in ieee80211_prep_channel()
5076 cbss->channel, in ieee80211_prep_channel()
5077 bss->vht_cap_info, in ieee80211_prep_channel()
5082 sdata->needed_rx_chains = min(ieee80211_ht_vht_rx_chains(sdata, cbss), in ieee80211_prep_channel()
5083 local->rx_chains); in ieee80211_prep_channel()
5087 if (ifmgd->flags & IEEE80211_STA_DISABLE_HE && is_6ghz) { in ieee80211_prep_channel()
5088 sdata_info(sdata, "Rejecting non-HE 6/7 GHz connection"); in ieee80211_prep_channel()
5089 return -EINVAL; in ieee80211_prep_channel()
5093 sdata->smps_mode = IEEE80211_SMPS_OFF; in ieee80211_prep_channel()
5095 mutex_lock(&local->mtx); in ieee80211_prep_channel()
5110 ifmgd->flags |= ieee80211_chandef_downgrade(&chandef); in ieee80211_prep_channel()
5115 mutex_unlock(&local->mtx); in ieee80211_prep_channel()
5122 const u8 *tim_ie = cfg80211_find_ie(WLAN_EID_TIM, ies->data, ies->len); in ieee80211_get_dtim()
5123 const u8 *idx_ie = cfg80211_find_ie(WLAN_EID_MULTI_BSSID_IDX, ies->data, in ieee80211_get_dtim()
5124 ies->len); in ieee80211_get_dtim()
5133 *dtim_count = valid ? tim->dtim_count : 0; in ieee80211_get_dtim()
5136 *dtim_period = valid ? tim->dtim_period : 0; in ieee80211_get_dtim()
5138 /* Check if value is overridden by non-transmitted profile */ in ieee80211_get_dtim()
5145 *dtim_count = idx->dtim_count; in ieee80211_get_dtim()
5148 *dtim_period = idx->dtim_period; in ieee80211_get_dtim()
5157 struct ieee80211_local *local = sdata->local; in ieee80211_prep_connection()
5158 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_prep_connection()
5159 struct ieee80211_bss *bss = (void *)cbss->priv; in ieee80211_prep_connection()
5165 sband = local->hw.wiphy->bands[cbss->channel->band]; in ieee80211_prep_connection()
5167 if (WARN_ON(!ifmgd->auth_data && !ifmgd->assoc_data)) in ieee80211_prep_connection()
5168 return -EINVAL; in ieee80211_prep_connection()
5171 if (local->in_reconfig) in ieee80211_prep_connection()
5172 return -EBUSY; in ieee80211_prep_connection()
5176 have_sta = sta_info_get(sdata, cbss->bssid); in ieee80211_prep_connection()
5181 new_sta = sta_info_alloc(sdata, cbss->bssid, GFP_KERNEL); in ieee80211_prep_connection()
5183 return -ENOMEM; in ieee80211_prep_connection()
5188 * new channel. We can't - completely race-free - change the basic in ieee80211_prep_connection()
5192 * call that from changing the channel - only for IDLE and perhaps in ieee80211_prep_connection()
5202 int min_rate = INT_MAX, min_rate_index = -1; in ieee80211_prep_connection()
5204 int shift = ieee80211_vif_get_shift(&sdata->vif); in ieee80211_prep_connection()
5207 if (cbss->channel->band == NL80211_BAND_S1GHZ) { in ieee80211_prep_connection()
5212 ieee80211_get_rates(sband, bss->supp_rates, in ieee80211_prep_connection()
5213 bss->supp_rates_len, in ieee80211_prep_connection()
5225 * we can connect -- with a warning. in ieee80211_prep_connection()
5234 return -EINVAL; in ieee80211_prep_connection()
5242 new_sta->sta.supp_rates[cbss->channel->band] = rates; in ieee80211_prep_connection()
5247 sdata->vif.bss_conf.basic_rates = basic_rates; in ieee80211_prep_connection()
5250 if (cbss->channel->band == NL80211_BAND_2GHZ && in ieee80211_prep_connection()
5252 sdata->flags |= IEEE80211_SDATA_OPERATING_GMODE; in ieee80211_prep_connection()
5254 sdata->flags &= ~IEEE80211_SDATA_OPERATING_GMODE; in ieee80211_prep_connection()
5257 memcpy(ifmgd->bssid, cbss->bssid, ETH_ALEN); in ieee80211_prep_connection()
5260 sdata->vif.bss_conf.beacon_int = cbss->beacon_interval; in ieee80211_prep_connection()
5262 ies = rcu_dereference(cbss->beacon_ies); in ieee80211_prep_connection()
5264 sdata->vif.bss_conf.sync_tsf = ies->tsf; in ieee80211_prep_connection()
5265 sdata->vif.bss_conf.sync_device_ts = in ieee80211_prep_connection()
5266 bss->device_ts_beacon; in ieee80211_prep_connection()
5269 &sdata->vif.bss_conf.sync_dtim_count, in ieee80211_prep_connection()
5271 } else if (!ieee80211_hw_check(&sdata->local->hw, in ieee80211_prep_connection()
5273 ies = rcu_dereference(cbss->proberesp_ies); in ieee80211_prep_connection()
5274 /* must be non-NULL since beacon IEs were NULL */ in ieee80211_prep_connection()
5275 sdata->vif.bss_conf.sync_tsf = ies->tsf; in ieee80211_prep_connection()
5276 sdata->vif.bss_conf.sync_device_ts = in ieee80211_prep_connection()
5277 bss->device_ts_presp; in ieee80211_prep_connection()
5278 sdata->vif.bss_conf.sync_dtim_count = 0; in ieee80211_prep_connection()
5280 sdata->vif.bss_conf.sync_tsf = 0; in ieee80211_prep_connection()
5281 sdata->vif.bss_conf.sync_device_ts = 0; in ieee80211_prep_connection()
5282 sdata->vif.bss_conf.sync_dtim_count = 0; in ieee80211_prep_connection()
5292 return -EINVAL; in ieee80211_prep_connection()
5317 WARN_ON_ONCE(!ether_addr_equal(ifmgd->bssid, cbss->bssid)); in ieee80211_prep_connection()
5320 if (local->scanning) in ieee80211_prep_connection()
5330 struct ieee80211_local *local = sdata->local; in ieee80211_mgd_auth()
5331 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_mgd_auth()
5339 switch (req->auth_type) { in ieee80211_mgd_auth()
5345 return -EOPNOTSUPP; in ieee80211_mgd_auth()
5367 return -EOPNOTSUPP; in ieee80211_mgd_auth()
5370 if (ifmgd->assoc_data) in ieee80211_mgd_auth()
5371 return -EBUSY; in ieee80211_mgd_auth()
5373 auth_data = kzalloc(sizeof(*auth_data) + req->auth_data_len + in ieee80211_mgd_auth()
5374 req->ie_len, GFP_KERNEL); in ieee80211_mgd_auth()
5376 return -ENOMEM; in ieee80211_mgd_auth()
5378 auth_data->bss = req->bss; in ieee80211_mgd_auth()
5380 if (req->auth_data_len >= 4) { in ieee80211_mgd_auth()
5381 if (req->auth_type == NL80211_AUTHTYPE_SAE) { in ieee80211_mgd_auth()
5382 __le16 *pos = (__le16 *) req->auth_data; in ieee80211_mgd_auth()
5384 auth_data->sae_trans = le16_to_cpu(pos[0]); in ieee80211_mgd_auth()
5385 auth_data->sae_status = le16_to_cpu(pos[1]); in ieee80211_mgd_auth()
5387 memcpy(auth_data->data, req->auth_data + 4, in ieee80211_mgd_auth()
5388 req->auth_data_len - 4); in ieee80211_mgd_auth()
5389 auth_data->data_len += req->auth_data_len - 4; in ieee80211_mgd_auth()
5394 * removal and re-addition of the STA entry in in ieee80211_mgd_auth()
5397 cont_auth = ifmgd->auth_data && req->bss == ifmgd->auth_data->bss; in ieee80211_mgd_auth()
5399 if (req->ie && req->ie_len) { in ieee80211_mgd_auth()
5400 memcpy(&auth_data->data[auth_data->data_len], in ieee80211_mgd_auth()
5401 req->ie, req->ie_len); in ieee80211_mgd_auth()
5402 auth_data->data_len += req->ie_len; in ieee80211_mgd_auth()
5405 if (req->key && req->key_len) { in ieee80211_mgd_auth()
5406 auth_data->key_len = req->key_len; in ieee80211_mgd_auth()
5407 auth_data->key_idx = req->key_idx; in ieee80211_mgd_auth()
5408 memcpy(auth_data->key, req->key, req->key_len); in ieee80211_mgd_auth()
5411 auth_data->algorithm = auth_alg; in ieee80211_mgd_auth()
5415 if (ifmgd->auth_data) { in ieee80211_mgd_auth()
5416 if (cont_auth && req->auth_type == NL80211_AUTHTYPE_SAE) { in ieee80211_mgd_auth()
5417 auth_data->peer_confirmed = in ieee80211_mgd_auth()
5418 ifmgd->auth_data->peer_confirmed; in ieee80211_mgd_auth()
5424 ifmgd->auth_data = auth_data; in ieee80211_mgd_auth()
5431 if (cont_auth && req->auth_type == NL80211_AUTHTYPE_SAE && in ieee80211_mgd_auth()
5432 auth_data->peer_confirmed && auth_data->sae_trans == 2) in ieee80211_mgd_auth()
5433 ieee80211_mark_sta_auth(sdata, req->bss->bssid); in ieee80211_mgd_auth()
5435 if (ifmgd->associated) { in ieee80211_mgd_auth()
5440 ifmgd->associated->bssid, req->bss->bssid); in ieee80211_mgd_auth()
5450 sdata_info(sdata, "authenticate with %pM\n", req->bss->bssid); in ieee80211_mgd_auth()
5452 err = ieee80211_prep_connection(sdata, req->bss, cont_auth, false); in ieee80211_mgd_auth()
5458 sta_info_destroy_addr(sdata, req->bss->bssid); in ieee80211_mgd_auth()
5463 cfg80211_ref_bss(local->hw.wiphy, auth_data->bss); in ieee80211_mgd_auth()
5467 eth_zero_addr(ifmgd->bssid); in ieee80211_mgd_auth()
5469 ifmgd->auth_data = NULL; in ieee80211_mgd_auth()
5470 mutex_lock(&sdata->local->mtx); in ieee80211_mgd_auth()
5472 mutex_unlock(&sdata->local->mtx); in ieee80211_mgd_auth()
5480 bool is_6ghz = req->bss->channel->band == NL80211_BAND_6GHZ; in ieee80211_mgd_assoc()
5481 bool is_5ghz = req->bss->channel->band == NL80211_BAND_5GHZ; in ieee80211_mgd_assoc()
5482 struct ieee80211_local *local = sdata->local; in ieee80211_mgd_assoc()
5483 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_mgd_assoc()
5484 struct ieee80211_bss *bss = (void *)req->bss->priv; in ieee80211_mgd_assoc()
5492 assoc_data = kzalloc(sizeof(*assoc_data) + req->ie_len, GFP_KERNEL); in ieee80211_mgd_assoc()
5494 return -ENOMEM; in ieee80211_mgd_assoc()
5497 ssidie = ieee80211_bss_get_ie(req->bss, WLAN_EID_SSID); in ieee80211_mgd_assoc()
5498 if (!ssidie || ssidie[1] > sizeof(assoc_data->ssid)) { in ieee80211_mgd_assoc()
5501 return -EINVAL; in ieee80211_mgd_assoc()
5503 memcpy(assoc_data->ssid, ssidie + 2, ssidie[1]); in ieee80211_mgd_assoc()
5504 assoc_data->ssid_len = ssidie[1]; in ieee80211_mgd_assoc()
5507 if (ifmgd->associated) { in ieee80211_mgd_assoc()
5512 ifmgd->associated->bssid, req->bss->bssid); in ieee80211_mgd_assoc()
5522 if (ifmgd->auth_data && !ifmgd->auth_data->done) { in ieee80211_mgd_assoc()
5523 err = -EBUSY; in ieee80211_mgd_assoc()
5527 if (ifmgd->assoc_data) { in ieee80211_mgd_assoc()
5528 err = -EBUSY; in ieee80211_mgd_assoc()
5532 if (ifmgd->auth_data) { in ieee80211_mgd_assoc()
5536 match = ether_addr_equal(ifmgd->bssid, req->bss->bssid); in ieee80211_mgd_assoc()
5542 ifmgd->beacon_crc_valid = false; in ieee80211_mgd_assoc()
5544 assoc_data->wmm = bss->wmm_used && in ieee80211_mgd_assoc()
5545 (local->hw.queues >= IEEE80211_NUM_ACS); in ieee80211_mgd_assoc()
5549 * We still associate in non-HT mode (11a/b/g) if any one of these in ieee80211_mgd_assoc()
5551 * We can set this to true for non-11n hardware, that'll be checked in ieee80211_mgd_assoc()
5554 for (i = 0; i < req->crypto.n_ciphers_pairwise; i++) { in ieee80211_mgd_assoc()
5555 if (req->crypto.ciphers_pairwise[i] == WLAN_CIPHER_SUITE_WEP40 || in ieee80211_mgd_assoc()
5556 req->crypto.ciphers_pairwise[i] == WLAN_CIPHER_SUITE_TKIP || in ieee80211_mgd_assoc()
5557 req->crypto.ciphers_pairwise[i] == WLAN_CIPHER_SUITE_WEP104) { in ieee80211_mgd_assoc()
5558 ifmgd->flags |= IEEE80211_STA_DISABLE_HT; in ieee80211_mgd_assoc()
5559 ifmgd->flags |= IEEE80211_STA_DISABLE_VHT; in ieee80211_mgd_assoc()
5560 ifmgd->flags |= IEEE80211_STA_DISABLE_HE; in ieee80211_mgd_assoc()
5561 netdev_info(sdata->dev, in ieee80211_mgd_assoc()
5566 sband = local->hw.wiphy->bands[req->bss->channel->band]; in ieee80211_mgd_assoc()
5569 if (!bss->wmm_used) { in ieee80211_mgd_assoc()
5570 ifmgd->flags |= IEEE80211_STA_DISABLE_HT; in ieee80211_mgd_assoc()
5571 ifmgd->flags |= IEEE80211_STA_DISABLE_VHT; in ieee80211_mgd_assoc()
5572 ifmgd->flags |= IEEE80211_STA_DISABLE_HE; in ieee80211_mgd_assoc()
5573 netdev_info(sdata->dev, in ieee80211_mgd_assoc()
5577 memcpy(&ifmgd->ht_capa, &req->ht_capa, sizeof(ifmgd->ht_capa)); in ieee80211_mgd_assoc()
5578 memcpy(&ifmgd->ht_capa_mask, &req->ht_capa_mask, in ieee80211_mgd_assoc()
5579 sizeof(ifmgd->ht_capa_mask)); in ieee80211_mgd_assoc()
5581 memcpy(&ifmgd->vht_capa, &req->vht_capa, sizeof(ifmgd->vht_capa)); in ieee80211_mgd_assoc()
5582 memcpy(&ifmgd->vht_capa_mask, &req->vht_capa_mask, in ieee80211_mgd_assoc()
5583 sizeof(ifmgd->vht_capa_mask)); in ieee80211_mgd_assoc()
5585 memcpy(&ifmgd->s1g_capa, &req->s1g_capa, sizeof(ifmgd->s1g_capa)); in ieee80211_mgd_assoc()
5586 memcpy(&ifmgd->s1g_capa_mask, &req->s1g_capa_mask, in ieee80211_mgd_assoc()
5587 sizeof(ifmgd->s1g_capa_mask)); in ieee80211_mgd_assoc()
5589 if (req->ie && req->ie_len) { in ieee80211_mgd_assoc()
5590 memcpy(assoc_data->ie, req->ie, req->ie_len); in ieee80211_mgd_assoc()
5591 assoc_data->ie_len = req->ie_len; in ieee80211_mgd_assoc()
5594 if (req->fils_kek) { in ieee80211_mgd_assoc()
5595 /* should already be checked in cfg80211 - so warn */ in ieee80211_mgd_assoc()
5596 if (WARN_ON(req->fils_kek_len > FILS_MAX_KEK_LEN)) { in ieee80211_mgd_assoc()
5597 err = -EINVAL; in ieee80211_mgd_assoc()
5600 memcpy(assoc_data->fils_kek, req->fils_kek, in ieee80211_mgd_assoc()
5601 req->fils_kek_len); in ieee80211_mgd_assoc()
5602 assoc_data->fils_kek_len = req->fils_kek_len; in ieee80211_mgd_assoc()
5605 if (req->fils_nonces) in ieee80211_mgd_assoc()
5606 memcpy(assoc_data->fils_nonces, req->fils_nonces, in ieee80211_mgd_assoc()
5609 assoc_data->bss = req->bss; in ieee80211_mgd_assoc()
5611 if (ifmgd->req_smps == IEEE80211_SMPS_AUTOMATIC) { in ieee80211_mgd_assoc()
5612 if (ifmgd->powersave) in ieee80211_mgd_assoc()
5613 sdata->smps_mode = IEEE80211_SMPS_DYNAMIC; in ieee80211_mgd_assoc()
5615 sdata->smps_mode = IEEE80211_SMPS_OFF; in ieee80211_mgd_assoc()
5617 sdata->smps_mode = ifmgd->req_smps; in ieee80211_mgd_assoc()
5619 assoc_data->capability = req->bss->capability; in ieee80211_mgd_assoc()
5620 assoc_data->supp_rates = bss->supp_rates; in ieee80211_mgd_assoc()
5621 assoc_data->supp_rates_len = bss->supp_rates_len; in ieee80211_mgd_assoc()
5624 ht_ie = ieee80211_bss_get_ie(req->bss, WLAN_EID_HT_OPERATION); in ieee80211_mgd_assoc()
5626 assoc_data->ap_ht_param = in ieee80211_mgd_assoc()
5627 ((struct ieee80211_ht_operation *)(ht_ie + 2))->ht_param; in ieee80211_mgd_assoc()
5629 ifmgd->flags |= IEEE80211_STA_DISABLE_HT; in ieee80211_mgd_assoc()
5630 vht_ie = ieee80211_bss_get_ie(req->bss, WLAN_EID_VHT_CAPABILITY); in ieee80211_mgd_assoc()
5632 memcpy(&assoc_data->ap_vht_cap, vht_ie + 2, in ieee80211_mgd_assoc()
5635 ifmgd->flags |= IEEE80211_STA_DISABLE_VHT | in ieee80211_mgd_assoc()
5639 if (WARN((sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_UAPSD) && in ieee80211_mgd_assoc()
5640 ieee80211_hw_check(&local->hw, PS_NULLFUNC_STACK), in ieee80211_mgd_assoc()
5641 "U-APSD not supported with HW_PS_NULLFUNC_STACK\n")) in ieee80211_mgd_assoc()
5642 sdata->vif.driver_flags &= ~IEEE80211_VIF_SUPPORTS_UAPSD; in ieee80211_mgd_assoc()
5644 if (bss->wmm_used && bss->uapsd_supported && in ieee80211_mgd_assoc()
5645 (sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_UAPSD)) { in ieee80211_mgd_assoc()
5646 assoc_data->uapsd = true; in ieee80211_mgd_assoc()
5647 ifmgd->flags |= IEEE80211_STA_UAPSD_ENABLED; in ieee80211_mgd_assoc()
5649 assoc_data->uapsd = false; in ieee80211_mgd_assoc()
5650 ifmgd->flags &= ~IEEE80211_STA_UAPSD_ENABLED; in ieee80211_mgd_assoc()
5653 if (req->prev_bssid) in ieee80211_mgd_assoc()
5654 memcpy(assoc_data->prev_bssid, req->prev_bssid, ETH_ALEN); in ieee80211_mgd_assoc()
5656 if (req->use_mfp) { in ieee80211_mgd_assoc()
5657 ifmgd->mfp = IEEE80211_MFP_REQUIRED; in ieee80211_mgd_assoc()
5658 ifmgd->flags |= IEEE80211_STA_MFP_ENABLED; in ieee80211_mgd_assoc()
5660 ifmgd->mfp = IEEE80211_MFP_DISABLED; in ieee80211_mgd_assoc()
5661 ifmgd->flags &= ~IEEE80211_STA_MFP_ENABLED; in ieee80211_mgd_assoc()
5664 if (req->flags & ASSOC_REQ_USE_RRM) in ieee80211_mgd_assoc()
5665 ifmgd->flags |= IEEE80211_STA_ENABLE_RRM; in ieee80211_mgd_assoc()
5667 ifmgd->flags &= ~IEEE80211_STA_ENABLE_RRM; in ieee80211_mgd_assoc()
5669 if (req->crypto.control_port) in ieee80211_mgd_assoc()
5670 ifmgd->flags |= IEEE80211_STA_CONTROL_PORT; in ieee80211_mgd_assoc()
5672 ifmgd->flags &= ~IEEE80211_STA_CONTROL_PORT; in ieee80211_mgd_assoc()
5674 sdata->control_port_protocol = req->crypto.control_port_ethertype; in ieee80211_mgd_assoc()
5675 sdata->control_port_no_encrypt = req->crypto.control_port_no_encrypt; in ieee80211_mgd_assoc()
5676 sdata->control_port_over_nl80211 = in ieee80211_mgd_assoc()
5677 req->crypto.control_port_over_nl80211; in ieee80211_mgd_assoc()
5678 sdata->control_port_no_preauth = req->crypto.control_port_no_preauth; in ieee80211_mgd_assoc()
5679 sdata->encrypt_headroom = ieee80211_cs_headroom(local, &req->crypto, in ieee80211_mgd_assoc()
5680 sdata->vif.type); in ieee80211_mgd_assoc()
5684 ifmgd->assoc_data = assoc_data; in ieee80211_mgd_assoc()
5685 ifmgd->dtim_period = 0; in ieee80211_mgd_assoc()
5686 ifmgd->have_beacon = false; in ieee80211_mgd_assoc()
5689 if (!(ifmgd->flags & IEEE80211_STA_DISABLE_HT)) { in ieee80211_mgd_assoc()
5692 if (req->flags & ASSOC_REQ_DISABLE_HT) in ieee80211_mgd_assoc()
5695 memcpy(&sta_ht_cap, &sband->ht_cap, sizeof(sta_ht_cap)); in ieee80211_mgd_assoc()
5699 if (!(ifmgd->flags & IEEE80211_STA_DISABLE_40MHZ) && in ieee80211_mgd_assoc()
5700 sband->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40 && in ieee80211_mgd_assoc()
5704 if (!(ifmgd->flags & IEEE80211_STA_DISABLE_VHT) && in ieee80211_mgd_assoc()
5705 req->flags & ASSOC_REQ_DISABLE_VHT) in ieee80211_mgd_assoc()
5709 if (req->flags & ASSOC_REQ_DISABLE_HT) { in ieee80211_mgd_assoc()
5710 ifmgd->flags |= IEEE80211_STA_DISABLE_HT; in ieee80211_mgd_assoc()
5711 ifmgd->flags |= IEEE80211_STA_DISABLE_VHT; in ieee80211_mgd_assoc()
5712 ifmgd->flags |= IEEE80211_STA_DISABLE_HE; in ieee80211_mgd_assoc()
5715 if (req->flags & ASSOC_REQ_DISABLE_VHT) in ieee80211_mgd_assoc()
5716 ifmgd->flags |= IEEE80211_STA_DISABLE_VHT; in ieee80211_mgd_assoc()
5718 err = ieee80211_prep_connection(sdata, req->bss, true, override); in ieee80211_mgd_assoc()
5723 beacon_ies = rcu_dereference(req->bss->beacon_ies); in ieee80211_mgd_assoc()
5725 if (ieee80211_hw_check(&sdata->local->hw, NEED_DTIM_BEFORE_ASSOC) && in ieee80211_mgd_assoc()
5732 ifmgd->bssid); in ieee80211_mgd_assoc()
5733 assoc_data->timeout = TU_TO_EXP_TIME(req->bss->beacon_interval); in ieee80211_mgd_assoc()
5734 assoc_data->timeout_started = true; in ieee80211_mgd_assoc()
5735 assoc_data->need_beacon = true; in ieee80211_mgd_assoc()
5741 &ifmgd->dtim_period); in ieee80211_mgd_assoc()
5743 ifmgd->have_beacon = true; in ieee80211_mgd_assoc()
5744 assoc_data->timeout = jiffies; in ieee80211_mgd_assoc()
5745 assoc_data->timeout_started = true; in ieee80211_mgd_assoc()
5747 if (ieee80211_hw_check(&local->hw, TIMING_BEACON_ONLY)) { in ieee80211_mgd_assoc()
5748 sdata->vif.bss_conf.sync_tsf = beacon_ies->tsf; in ieee80211_mgd_assoc()
5749 sdata->vif.bss_conf.sync_device_ts = in ieee80211_mgd_assoc()
5750 bss->device_ts_beacon; in ieee80211_mgd_assoc()
5751 sdata->vif.bss_conf.sync_dtim_count = dtim_count; in ieee80211_mgd_assoc()
5755 beacon_ies->data, beacon_ies->len); in ieee80211_mgd_assoc()
5756 if (elem && elem->datalen >= 3) in ieee80211_mgd_assoc()
5757 sdata->vif.bss_conf.profile_periodicity = elem->data[2]; in ieee80211_mgd_assoc()
5759 sdata->vif.bss_conf.profile_periodicity = 0; in ieee80211_mgd_assoc()
5762 beacon_ies->data, beacon_ies->len); in ieee80211_mgd_assoc()
5763 if (elem && elem->datalen >= 11 && in ieee80211_mgd_assoc()
5764 (elem->data[10] & WLAN_EXT_CAPA11_EMA_SUPPORT)) in ieee80211_mgd_assoc()
5765 sdata->vif.bss_conf.ema_ap = true; in ieee80211_mgd_assoc()
5767 sdata->vif.bss_conf.ema_ap = false; in ieee80211_mgd_assoc()
5769 assoc_data->timeout = jiffies; in ieee80211_mgd_assoc()
5770 assoc_data->timeout_started = true; in ieee80211_mgd_assoc()
5774 run_again(sdata, assoc_data->timeout); in ieee80211_mgd_assoc()
5776 if (bss->corrupt_data) { in ieee80211_mgd_assoc()
5778 if (bss->corrupt_data & IEEE80211_BSS_CORRUPT_BEACON) { in ieee80211_mgd_assoc()
5779 if (bss->corrupt_data & in ieee80211_mgd_assoc()
5784 } else if (bss->corrupt_data & IEEE80211_BSS_CORRUPT_PROBE_RESP) in ieee80211_mgd_assoc()
5792 eth_zero_addr(ifmgd->bssid); in ieee80211_mgd_assoc()
5794 ifmgd->assoc_data = NULL; in ieee80211_mgd_assoc()
5803 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_mgd_deauth()
5805 bool tx = !req->local_state_change; in ieee80211_mgd_deauth()
5807 if (ifmgd->auth_data && in ieee80211_mgd_deauth()
5808 ether_addr_equal(ifmgd->auth_data->bss->bssid, req->bssid)) { in ieee80211_mgd_deauth()
5811 req->bssid, req->reason_code, in ieee80211_mgd_deauth()
5812 ieee80211_get_reason_code_string(req->reason_code)); in ieee80211_mgd_deauth()
5814 drv_mgd_prepare_tx(sdata->local, sdata, 0); in ieee80211_mgd_deauth()
5815 ieee80211_send_deauth_disassoc(sdata, req->bssid, req->bssid, in ieee80211_mgd_deauth()
5817 req->reason_code, tx, in ieee80211_mgd_deauth()
5822 req->reason_code); in ieee80211_mgd_deauth()
5827 if (ifmgd->assoc_data && in ieee80211_mgd_deauth()
5828 ether_addr_equal(ifmgd->assoc_data->bss->bssid, req->bssid)) { in ieee80211_mgd_deauth()
5831 req->bssid, req->reason_code, in ieee80211_mgd_deauth()
5832 ieee80211_get_reason_code_string(req->reason_code)); in ieee80211_mgd_deauth()
5834 drv_mgd_prepare_tx(sdata->local, sdata, 0); in ieee80211_mgd_deauth()
5835 ieee80211_send_deauth_disassoc(sdata, req->bssid, req->bssid, in ieee80211_mgd_deauth()
5837 req->reason_code, tx, in ieee80211_mgd_deauth()
5842 req->reason_code); in ieee80211_mgd_deauth()
5846 if (ifmgd->associated && in ieee80211_mgd_deauth()
5847 ether_addr_equal(ifmgd->associated->bssid, req->bssid)) { in ieee80211_mgd_deauth()
5850 req->bssid, req->reason_code, in ieee80211_mgd_deauth()
5851 ieee80211_get_reason_code_string(req->reason_code)); in ieee80211_mgd_deauth()
5854 req->reason_code, tx, frame_buf); in ieee80211_mgd_deauth()
5857 req->reason_code); in ieee80211_mgd_deauth()
5861 return -ENOTCONN; in ieee80211_mgd_deauth()
5867 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_mgd_disassoc()
5877 if (ifmgd->associated != req->bss) in ieee80211_mgd_disassoc()
5878 return -ENOLINK; in ieee80211_mgd_disassoc()
5882 req->bss->bssid, req->reason_code, ieee80211_get_reason_code_string(req->reason_code)); in ieee80211_mgd_disassoc()
5884 memcpy(bssid, req->bss->bssid, ETH_ALEN); in ieee80211_mgd_disassoc()
5886 req->reason_code, !req->local_state_change, in ieee80211_mgd_disassoc()
5890 req->reason_code); in ieee80211_mgd_disassoc()
5897 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_mgd_stop()
5904 cancel_work_sync(&ifmgd->monitor_work); in ieee80211_mgd_stop()
5905 cancel_work_sync(&ifmgd->beacon_connection_loss_work); in ieee80211_mgd_stop()
5906 cancel_work_sync(&ifmgd->request_smps_work); in ieee80211_mgd_stop()
5907 cancel_work_sync(&ifmgd->csa_connection_drop_work); in ieee80211_mgd_stop()
5908 cancel_work_sync(&ifmgd->chswitch_work); in ieee80211_mgd_stop()
5909 cancel_delayed_work_sync(&ifmgd->tdls_peer_del_work); in ieee80211_mgd_stop()
5912 if (ifmgd->assoc_data) { in ieee80211_mgd_stop()
5913 struct cfg80211_bss *bss = ifmgd->assoc_data->bss; in ieee80211_mgd_stop()
5915 cfg80211_assoc_timeout(sdata->dev, bss); in ieee80211_mgd_stop()
5917 if (ifmgd->auth_data) in ieee80211_mgd_stop()
5919 spin_lock_bh(&ifmgd->teardown_lock); in ieee80211_mgd_stop()
5920 if (ifmgd->teardown_skb) { in ieee80211_mgd_stop()
5921 kfree_skb(ifmgd->teardown_skb); in ieee80211_mgd_stop()
5922 ifmgd->teardown_skb = NULL; in ieee80211_mgd_stop()
5923 ifmgd->orig_teardown_skb = NULL; in ieee80211_mgd_stop()
5925 kfree(ifmgd->assoc_req_ies); in ieee80211_mgd_stop()
5926 ifmgd->assoc_req_ies = NULL; in ieee80211_mgd_stop()
5927 ifmgd->assoc_req_ies_len = 0; in ieee80211_mgd_stop()
5928 spin_unlock_bh(&ifmgd->teardown_lock); in ieee80211_mgd_stop()
5929 del_timer_sync(&ifmgd->timer); in ieee80211_mgd_stop()
5942 cfg80211_cqm_rssi_notify(sdata->dev, rssi_event, rssi_level, gfp); in ieee80211_cqm_rssi_notify()
5950 trace_api_cqm_beacon_loss_notify(sdata->local, sdata); in ieee80211_cqm_beacon_loss_notify()
5952 cfg80211_cqm_beacon_loss_notify(sdata->dev, gfp); in ieee80211_cqm_beacon_loss_notify()