Lines Matching +full:local +full:- +full:cap +full:- +full:size
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 - 2022 Intel Corporation
29 #include "driver-ops.h"
98 * has happened -- the work that runs from this timer will
106 if (!timer_pending(&sdata->u.mgd.timer) || in run_again()
107 time_before(timeout, sdata->u.mgd.timer.expires)) in run_again()
108 mod_timer(&sdata->u.mgd.timer, timeout); in run_again()
113 if (sdata->vif.driver_flags & IEEE80211_VIF_BEACON_FILTER) in ieee80211_sta_reset_beacon_monitor()
116 if (ieee80211_hw_check(&sdata->local->hw, CONNECTION_MONITOR)) in ieee80211_sta_reset_beacon_monitor()
119 mod_timer(&sdata->u.mgd.bcn_mon_timer, in ieee80211_sta_reset_beacon_monitor()
120 round_jiffies_up(jiffies + sdata->u.mgd.beacon_timeout)); in ieee80211_sta_reset_beacon_monitor()
125 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_sta_reset_conn_monitor()
127 if (unlikely(!ifmgd->associated)) in ieee80211_sta_reset_conn_monitor()
130 if (ifmgd->probe_send_count) in ieee80211_sta_reset_conn_monitor()
131 ifmgd->probe_send_count = 0; in ieee80211_sta_reset_conn_monitor()
133 if (ieee80211_hw_check(&sdata->local->hw, CONNECTION_MONITOR)) in ieee80211_sta_reset_conn_monitor()
136 mod_timer(&ifmgd->conn_mon_timer, in ieee80211_sta_reset_conn_monitor()
142 return (1 << ecw) - 1; in ecw2cw()
165 chandef->chan = channel; in ieee80211_determine_chantype()
166 chandef->width = NL80211_CHAN_WIDTH_20_NOHT; in ieee80211_determine_chantype()
167 chandef->center_freq1 = channel->center_freq; in ieee80211_determine_chantype()
168 chandef->freq1_offset = channel->freq_offset; in ieee80211_determine_chantype()
170 if (channel->band == NL80211_BAND_6GHZ) { in ieee80211_determine_chantype()
184 } else if (sband->band == NL80211_BAND_S1GHZ) { in ieee80211_determine_chantype()
188 chandef->width = ieee80211_s1g_channel_width(channel); in ieee80211_determine_chantype()
198 memcpy(&sta_ht_cap, &sband->ht_cap, sizeof(sta_ht_cap)); in ieee80211_determine_chantype()
210 chandef->width = NL80211_CHAN_WIDTH_20; in ieee80211_determine_chantype()
212 ht_cfreq = ieee80211_channel_to_frequency(ht_oper->primary_chan, in ieee80211_determine_chantype()
213 channel->band); in ieee80211_determine_chantype()
215 if (!tracking && channel->center_freq != ht_cfreq) { in ieee80211_determine_chantype()
224 …"Wrong control channel: center-freq: %d ht-cfreq: %d ht->primary_chan: %d band: %d - Disabling HT\… in ieee80211_determine_chantype()
225 channel->center_freq, ht_cfreq, in ieee80211_determine_chantype()
226 ht_oper->primary_chan, channel->band); in ieee80211_determine_chantype()
235 if (sta_ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40) { in ieee80211_determine_chantype()
246 if (!vht_oper || !sband->vht_cap.vht_supported) { in ieee80211_determine_chantype()
255 (le32_to_cpu(he_oper->he_oper_params) & in ieee80211_determine_chantype()
263 memcpy(&he_oper_vht_cap, he_oper->optional, 3); in ieee80211_determine_chantype()
266 if (!ieee80211_chandef_vht_oper(&sdata->local->hw, vht_cap_info, in ieee80211_determine_chantype()
275 } else if (!ieee80211_chandef_vht_oper(&sdata->local->hw, in ieee80211_determine_chantype()
314 if (eht_oper && (eht_oper->params & IEEE80211_EHT_OPER_INFO_PRESENT)) { in ieee80211_determine_chantype()
347 * connection. This keeps us from playing ping-pong with regulatory, in ieee80211_determine_chantype()
349 * - connect to an AP with 80 MHz, world regdom allows 80 MHz in ieee80211_determine_chantype()
350 * - AP advertises regdom US in ieee80211_determine_chantype()
351 * - CRDA loads regdom US with 80 MHz prohibited (old database) in ieee80211_determine_chantype()
352 * - the code below detects an unsupported channel, downgrades, and in ieee80211_determine_chantype()
354 * - disconnect causes CRDA to reload world regdomain and the game in ieee80211_determine_chantype()
363 cfg80211_chandef_identical(chandef, &link->conf->chandef)) in ieee80211_determine_chantype()
372 * tracking the APs beacon for bandwidth changes - otherwise we in ieee80211_determine_chantype()
378 while (!cfg80211_chandef_usable(sdata->local->hw.wiphy, chandef, in ieee80211_determine_chantype()
381 if (WARN_ON(chandef->width == NL80211_CHAN_WIDTH_20_NOHT)) { in ieee80211_determine_chantype()
392 if (!he_oper || !cfg80211_chandef_usable(sdata->wdev.wiphy, chandef, in ieee80211_determine_chantype()
396 if (!eht_oper || !cfg80211_chandef_usable(sdata->wdev.wiphy, chandef, in ieee80211_determine_chantype()
400 if (chandef->width != vht_chandef.width && !tracking) in ieee80211_determine_chantype()
418 struct ieee80211_sub_if_data *sdata = link->sdata; in ieee80211_config_bw()
419 struct ieee80211_local *local = sdata->local; in ieee80211_config_bw() local
420 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_config_bw()
421 struct ieee80211_channel *chan = link->conf->chandef.chan; in ieee80211_config_bw()
423 local->hw.wiphy->bands[chan->band]; in ieee80211_config_bw()
431 if (link->u.mgd.conn_flags & IEEE80211_CONN_DISABLE_HT || !ht_oper) in ieee80211_config_bw()
434 /* don't check VHT if we associated as non-VHT station */ in ieee80211_config_bw()
435 if (link->u.mgd.conn_flags & IEEE80211_CONN_DISABLE_VHT) in ieee80211_config_bw()
438 /* don't check HE if we associated as non-HE station */ in ieee80211_config_bw()
439 if (link->u.mgd.conn_flags & IEEE80211_CONN_DISABLE_HE || in ieee80211_config_bw()
441 ieee80211_vif_type_p2p(&sdata->vif))) { in ieee80211_config_bw()
446 /* don't check EHT if we associated as non-EHT station */ in ieee80211_config_bw()
447 if (link->u.mgd.conn_flags & IEEE80211_CONN_DISABLE_EHT || in ieee80211_config_bw()
449 ieee80211_vif_type_p2p(&sdata->vif))) in ieee80211_config_bw()
453 * if bss configuration changed store the new one - in ieee80211_config_bw()
456 ht_opmode = le16_to_cpu(ht_oper->operation_mode); in ieee80211_config_bw()
457 if (link->conf->ht_operation_mode != ht_opmode) { in ieee80211_config_bw()
459 link->conf->ht_operation_mode = ht_opmode; in ieee80211_config_bw()
463 vht_cap_info = le32_to_cpu(vht_cap->vht_cap_info); in ieee80211_config_bw()
467 link->u.mgd.conn_flags, in ieee80211_config_bw()
478 * any good -- we couldn't use it with the AP. in ieee80211_config_bw()
480 if (link->u.mgd.conn_flags & IEEE80211_CONN_DISABLE_80P80MHZ && in ieee80211_config_bw()
483 if (link->u.mgd.conn_flags & IEEE80211_CONN_DISABLE_160MHZ && in ieee80211_config_bw()
486 if (link->u.mgd.conn_flags & IEEE80211_CONN_DISABLE_40MHZ && in ieee80211_config_bw()
490 if (cfg80211_chandef_identical(&chandef, &link->conf->chandef)) in ieee80211_config_bw()
495 link->u.mgd.bssid, chandef.chan->center_freq, in ieee80211_config_bw()
496 chandef.chan->freq_offset, chandef.width, in ieee80211_config_bw()
500 if (flags != (link->u.mgd.conn_flags & in ieee80211_config_bw()
511 "AP %pM changed caps/bw in a way we can't support (0x%x/0x%x) - disconnect\n", in ieee80211_config_bw()
512 link->u.mgd.bssid, flags, ifmgd->flags); in ieee80211_config_bw()
513 return -EINVAL; in ieee80211_config_bw()
520 "AP %pM changed bandwidth to incompatible one - disconnect\n", in ieee80211_config_bw()
521 link->u.mgd.bssid); in ieee80211_config_bw()
538 u32 flags = channel->flags; in ieee80211_add_ht_ie()
539 u16 cap; in ieee80211_add_ht_ie() local
542 BUILD_BUG_ON(sizeof(ht_cap) != sizeof(sband->ht_cap)); in ieee80211_add_ht_ie()
544 memcpy(&ht_cap, &sband->ht_cap, sizeof(ht_cap)); in ieee80211_add_ht_ie()
548 cap = ht_cap.cap; in ieee80211_add_ht_ie()
553 cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40; in ieee80211_add_ht_ie()
554 cap &= ~IEEE80211_HT_CAP_SGI_40; in ieee80211_add_ht_ie()
559 cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40; in ieee80211_add_ht_ie()
560 cap &= ~IEEE80211_HT_CAP_SGI_40; in ieee80211_add_ht_ie()
567 * capable of 40 MHz -- some broken APs will never fall in ieee80211_add_ht_ie()
571 cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40; in ieee80211_add_ht_ie()
572 cap &= ~IEEE80211_HT_CAP_SGI_40; in ieee80211_add_ht_ie()
576 cap &= ~IEEE80211_HT_CAP_SM_PS; in ieee80211_add_ht_ie()
583 cap |= WLAN_HT_CAP_SM_PS_DISABLED << in ieee80211_add_ht_ie()
587 cap |= WLAN_HT_CAP_SM_PS_STATIC << in ieee80211_add_ht_ie()
591 cap |= WLAN_HT_CAP_SM_PS_DYNAMIC << in ieee80211_add_ht_ie()
598 ieee80211_ie_build_ht_cap(pos, &ht_cap, cap); in ieee80211_add_ht_ie()
603 * Note - the function returns true to own the MU-MIMO capability
611 struct ieee80211_local *local = sdata->local; in ieee80211_add_vht_ie() local
613 u32 cap; in ieee80211_add_vht_ie() local
618 BUILD_BUG_ON(sizeof(vht_cap) != sizeof(sband->vht_cap)); in ieee80211_add_vht_ie()
620 memcpy(&vht_cap, &sband->vht_cap, sizeof(vht_cap)); in ieee80211_add_vht_ie()
624 cap = vht_cap.cap; in ieee80211_add_vht_ie()
627 u32 bw = cap & IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK; in ieee80211_add_vht_ie()
629 cap &= ~IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK; in ieee80211_add_vht_ie()
632 cap |= IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ; in ieee80211_add_vht_ie()
636 cap &= ~IEEE80211_VHT_CAP_SHORT_GI_160; in ieee80211_add_vht_ie()
637 cap &= ~IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK; in ieee80211_add_vht_ie()
644 if (!(ap_vht_cap->vht_cap_info & in ieee80211_add_vht_ie()
646 cap &= ~(IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE | in ieee80211_add_vht_ie()
648 else if (!(ap_vht_cap->vht_cap_info & in ieee80211_add_vht_ie()
650 cap &= ~IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE; in ieee80211_add_vht_ie()
653 * If some other vif is using the MU-MIMO capability we cannot associate in ieee80211_add_vht_ie()
654 * using MU-MIMO - this will lead to contradictions in the group-id in ieee80211_add_vht_ie()
657 * simultaneous associations with MU-MIMO. in ieee80211_add_vht_ie()
659 if (cap & IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE) { in ieee80211_add_vht_ie()
663 list_for_each_entry_rcu(other, &local->interfaces, list) { in ieee80211_add_vht_ie()
664 if (other->vif.bss_conf.mu_mimo_owner) { in ieee80211_add_vht_ie()
670 cap &= ~IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE; in ieee80211_add_vht_ie()
677 ap_bf_sts = le32_to_cpu(ap_vht_cap->vht_cap_info) & mask; in ieee80211_add_vht_ie()
678 our_bf_sts = cap & mask; in ieee80211_add_vht_ie()
681 cap &= ~mask; in ieee80211_add_vht_ie()
682 cap |= ap_bf_sts; in ieee80211_add_vht_ie()
687 ieee80211_ie_build_vht_cap(pos, &vht_cap, cap); in ieee80211_add_vht_ie()
706 ieee80211_vif_type_p2p(&sdata->vif)); in ieee80211_add_he_ie()
710 /* get a max size estimate */ in ieee80211_add_he_ie()
712 2 + 1 + sizeof(he_cap->he_cap_elem) + in ieee80211_add_he_ie()
713 ieee80211_he_mcs_nss_size(&he_cap->he_cap_elem) + in ieee80211_add_he_ie()
714 ieee80211_he_ppe_size(he_cap->ppe_thres[0], in ieee80211_add_he_ie()
715 he_cap->he_cap_elem.phy_cap_info); in ieee80211_add_he_ie()
721 skb_trim(skb, skb->len - (pre_he_pos + he_cap_size - pos)); in ieee80211_add_he_ie()
736 ieee80211_vif_type_p2p(&sdata->vif)); in ieee80211_add_eht_ie()
738 ieee80211_vif_type_p2p(&sdata->vif)); in ieee80211_add_eht_ie()
748 2 + 1 + sizeof(eht_cap->eht_cap_elem) + in ieee80211_add_eht_ie()
749 ieee80211_eht_mcs_nss_size(&he_cap->he_cap_elem, in ieee80211_add_eht_ie()
750 &eht_cap->eht_cap_elem, in ieee80211_add_eht_ie()
752 ieee80211_eht_ppe_size(eht_cap->eht_ppe_thres[0], in ieee80211_add_eht_ie()
753 eht_cap->eht_cap_elem.phy_cap_info); in ieee80211_add_eht_ie()
770 if (assoc_data->supp_rates_len) { in ieee80211_assoc_add_rates()
774 * in the association request (e.g. D-Link DAP 1353 in in ieee80211_assoc_add_rates()
775 * b-only mode)... in ieee80211_assoc_add_rates()
778 assoc_data->supp_rates, in ieee80211_assoc_add_rates()
779 assoc_data->supp_rates_len, in ieee80211_assoc_add_rates()
787 rates_len = sband->n_bitrates; in ieee80211_assoc_add_rates()
788 for (i = 0; i < sband->n_bitrates; i++) in ieee80211_assoc_add_rates()
801 for (i = 0; i < sband->n_bitrates; i++) { in ieee80211_assoc_add_rates()
803 int rate = DIV_ROUND_UP(sband->bitrates[i].bitrate, in ieee80211_assoc_add_rates()
812 pos = skb_put(skb, rates_len - count + 2); in ieee80211_assoc_add_rates()
814 *pos++ = rates_len - count; in ieee80211_assoc_add_rates()
816 for (i++; i < sband->n_bitrates; i++) { in ieee80211_assoc_add_rates()
820 rate = DIV_ROUND_UP(sband->bitrates[i].bitrate, in ieee80211_assoc_add_rates()
858 /* 60 GHz (Multi-band, DMG, MMS) can't happen */ in ieee80211_add_before_ht_elems()
872 skb_put_data(skb, elems + offset, noffset - offset); in ieee80211_add_before_ht_elems()
892 /* 60 GHz (Multi-band, DMG, MMS) can't happen */ in ieee80211_add_before_vht_elems()
903 skb_put_data(skb, elems + offset, noffset - offset); in ieee80211_add_before_vht_elems()
937 skb_put_data(skb, elems + offset, noffset - offset); in ieee80211_add_before_he_elems()
959 enum nl80211_iftype iftype = ieee80211_vif_type_p2p(&sdata->vif); in ieee80211_assoc_link_elems()
960 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_assoc_link_elems()
961 struct ieee80211_mgd_assoc_data *assoc_data = ifmgd->assoc_data; in ieee80211_assoc_link_elems()
962 struct cfg80211_bss *cbss = assoc_data->link[link_id].bss; in ieee80211_assoc_link_elems()
963 struct ieee80211_channel *chan = cbss->channel; in ieee80211_assoc_link_elems()
965 struct ieee80211_local *local = sdata->local; in ieee80211_assoc_link_elems() local
977 /* need a last for termination - we use 0 == SSID */ \ in ieee80211_assoc_link_elems()
978 if (!WARN_ON(present_elems_len >= PRESENT_ELEMS_MAX - 1)) \ in ieee80211_assoc_link_elems()
984 smps_mode = link->smps_mode; in ieee80211_assoc_link_elems()
985 else if (sdata->u.mgd.powersave) in ieee80211_assoc_link_elems()
997 chanctx_conf = rcu_dereference(link->conf->chanctx_conf); in ieee80211_assoc_link_elems()
999 width = chanctx_conf->def.width; in ieee80211_assoc_link_elems()
1003 sband = local->hw.wiphy->bands[chan->band]; in ieee80211_assoc_link_elems()
1006 if (sband->band == NL80211_BAND_2GHZ) { in ieee80211_assoc_link_elems()
1011 if ((cbss->capability & WLAN_CAPABILITY_SPECTRUM_MGMT) && in ieee80211_assoc_link_elems()
1012 ieee80211_hw_check(&local->hw, SPECTRUM_MGMT)) in ieee80211_assoc_link_elems()
1015 if (sband->band != NL80211_BAND_S1GHZ) in ieee80211_assoc_link_elems()
1040 (sband->band != NL80211_BAND_6GHZ || in ieee80211_assoc_link_elems()
1041 !ext_capa || ext_capa->datalen < 1 || in ieee80211_assoc_link_elems()
1042 !(ext_capa->data[0] & WLAN_EXT_CAPA1_EXT_CHANNEL_SWITCHING))) { in ieee80211_assoc_link_elems()
1044 pos = skb_put(skb, 2 * sband->n_channels + 2); in ieee80211_assoc_link_elems()
1046 *pos++ = 2 * sband->n_channels; in ieee80211_assoc_link_elems()
1047 for (i = 0; i < sband->n_channels; i++) { in ieee80211_assoc_link_elems()
1048 int cf = sband->channels[i].center_freq; in ieee80211_assoc_link_elems()
1061 if (sband->band != NL80211_BAND_6GHZ && in ieee80211_assoc_link_elems()
1062 !(assoc_data->link[link_id].conn_flags & IEEE80211_CONN_DISABLE_HT)) { in ieee80211_assoc_link_elems()
1064 assoc_data->link[link_id].ap_ht_param, in ieee80211_assoc_link_elems()
1066 assoc_data->link[link_id].conn_flags); in ieee80211_assoc_link_elems()
1075 if (sband->band != NL80211_BAND_6GHZ && in ieee80211_assoc_link_elems()
1076 !(assoc_data->link[link_id].conn_flags & IEEE80211_CONN_DISABLE_VHT)) { in ieee80211_assoc_link_elems()
1079 &assoc_data->link[link_id].ap_vht_cap, in ieee80211_assoc_link_elems()
1080 assoc_data->link[link_id].conn_flags); in ieee80211_assoc_link_elems()
1083 link->conf->mu_mimo_owner = mu_mimo_owner; in ieee80211_assoc_link_elems()
1091 if (assoc_data->link[link_id].conn_flags & IEEE80211_CONN_DISABLE_HT || in ieee80211_assoc_link_elems()
1092 (sband->band == NL80211_BAND_5GHZ && in ieee80211_assoc_link_elems()
1093 assoc_data->link[link_id].conn_flags & IEEE80211_CONN_DISABLE_VHT)) in ieee80211_assoc_link_elems()
1094 assoc_data->link[link_id].conn_flags |= in ieee80211_assoc_link_elems()
1103 if (!(assoc_data->link[link_id].conn_flags & IEEE80211_CONN_DISABLE_HE)) { in ieee80211_assoc_link_elems()
1105 assoc_data->link[link_id].conn_flags); in ieee80211_assoc_link_elems()
1110 * careful - need to know about all the present elems before in ieee80211_assoc_link_elems()
1114 if (!(assoc_data->link[link_id].conn_flags & IEEE80211_CONN_DISABLE_EHT)) in ieee80211_assoc_link_elems()
1117 if (link_id == assoc_data->assoc_link_id) in ieee80211_assoc_link_elems()
1124 if (!(assoc_data->link[link_id].conn_flags & IEEE80211_CONN_DISABLE_EHT)) in ieee80211_assoc_link_elems()
1127 if (sband->band == NL80211_BAND_S1GHZ) { in ieee80211_assoc_link_elems()
1129 ieee80211_add_s1g_capab_ie(sdata, &sband->s1g_cap, skb); in ieee80211_assoc_link_elems()
1132 if (iftd && iftd->vendor_elems.data && iftd->vendor_elems.len) in ieee80211_assoc_link_elems()
1133 skb_put_data(skb, iftd->vendor_elems.data, iftd->vendor_elems.len); in ieee80211_assoc_link_elems()
1136 link->u.mgd.conn_flags = assoc_data->link[link_id].conn_flags; in ieee80211_assoc_link_elems()
1145 unsigned int skb_len = skb->len; in ieee80211_add_non_inheritance_elem()
1159 /* should at least be sorted in the sense of normal -> ext */ in ieee80211_add_non_inheritance_elem()
1191 *len = skb->len - skb_len - 2; in ieee80211_add_non_inheritance_elem()
1199 struct ieee80211_local *local = sdata->local; in ieee80211_assoc_add_ml_elem() local
1200 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_assoc_add_ml_elem()
1201 struct ieee80211_mgd_assoc_data *assoc_data = ifmgd->assoc_data; in ieee80211_assoc_add_ml_elem()
1210 if (!sdata->vif.valid_links) in ieee80211_assoc_add_ml_elem()
1213 ift_ext_capa = cfg80211_get_iftype_ext_capa(local->hw.wiphy, in ieee80211_assoc_add_ml_elem()
1214 ieee80211_vif_type_p2p(&sdata->vif)); in ieee80211_assoc_add_ml_elem()
1216 eml_capa = cpu_to_le16(ift_ext_capa->eml_capabilities); in ieee80211_assoc_add_ml_elem()
1217 mld_capa_ops = cpu_to_le16(ift_ext_capa->mld_capa_and_ops); in ieee80211_assoc_add_ml_elem()
1224 ml_elem->control = in ieee80211_assoc_add_ml_elem()
1228 common->len = sizeof(*common) + in ieee80211_assoc_add_ml_elem()
1230 memcpy(common->mld_mac_addr, sdata->vif.addr, ETH_ALEN); in ieee80211_assoc_add_ml_elem()
1236 common->len += 2; /* EML capabilities */ in ieee80211_assoc_add_ml_elem()
1237 ml_elem->control |= in ieee80211_assoc_add_ml_elem()
1253 if (!assoc_data->link[link_id].bss || in ieee80211_assoc_add_ml_elem()
1254 link_id == assoc_data->assoc_link_id) in ieee80211_assoc_add_ml_elem()
1257 extra_elems = assoc_data->link[link_id].elems; in ieee80211_assoc_add_ml_elem()
1258 extra_elems_len = assoc_data->link[link_id].elems_len; in ieee80211_assoc_add_ml_elem()
1268 skb_put_data(skb, assoc_data->link[link_id].addr, in ieee80211_assoc_add_ml_elem()
1288 extra_elems_len - extra_used); in ieee80211_assoc_add_ml_elem()
1303 struct ieee80211_local *local = sdata->local; in ieee80211_send_assoc() local
1304 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_send_assoc()
1305 struct ieee80211_mgd_assoc_data *assoc_data = ifmgd->assoc_data; in ieee80211_send_assoc()
1314 enum nl80211_iftype iftype = ieee80211_vif_type_p2p(&sdata->vif); in ieee80211_send_assoc()
1319 size_t size; in ieee80211_send_assoc() local
1323 if (assoc_data->ie_len) in ieee80211_send_assoc()
1325 assoc_data->ie, in ieee80211_send_assoc()
1326 assoc_data->ie_len); in ieee80211_send_assoc()
1330 size = local->hw.extra_tx_headroom + in ieee80211_send_assoc()
1332 2 + assoc_data->ssid_len + /* SSID */ in ieee80211_send_assoc()
1333 assoc_data->ie_len + /* extra IEs */ in ieee80211_send_assoc()
1334 (assoc_data->fils_kek_len ? 16 /* AES-SIV */ : 0) + in ieee80211_send_assoc()
1338 struct cfg80211_bss *cbss = assoc_data->link[link_id].bss; in ieee80211_send_assoc()
1345 sband = local->hw.wiphy->bands[cbss->channel->band]; in ieee80211_send_assoc()
1349 size += assoc_data->link[link_id].elems_len; in ieee80211_send_assoc()
1351 size += 4 + sband->n_bitrates; in ieee80211_send_assoc()
1353 size += 2 + 2 * sband->n_channels; in ieee80211_send_assoc()
1357 size += iftd->vendor_elems.len; in ieee80211_send_assoc()
1360 size += 4; in ieee80211_send_assoc()
1363 size += 2 + sizeof(struct ieee80211_ht_cap); in ieee80211_send_assoc()
1364 size += 2 + sizeof(struct ieee80211_vht_cap); in ieee80211_send_assoc()
1365 size += 2 + 1 + sizeof(struct ieee80211_he_cap_elem) + in ieee80211_send_assoc()
1369 if (sband->band == NL80211_BAND_6GHZ) in ieee80211_send_assoc()
1370 size += 2 + 1 + sizeof(struct ieee80211_he_6ghz_capa); in ieee80211_send_assoc()
1372 size += 2 + 1 + sizeof(struct ieee80211_eht_cap_elem) + in ieee80211_send_assoc()
1376 /* non-inheritance element */ in ieee80211_send_assoc()
1377 size += 2 + 2 + PRESENT_ELEMS_MAX; in ieee80211_send_assoc()
1380 if (cbss->capability & WLAN_CAPABILITY_PRIVACY) in ieee80211_send_assoc()
1384 if (sdata->vif.valid_links) { in ieee80211_send_assoc()
1385 /* consider the multi-link element with STA profile */ in ieee80211_send_assoc()
1386 size += sizeof(struct ieee80211_multi_link_elem); in ieee80211_send_assoc()
1387 /* max common info field in basic multi-link element */ in ieee80211_send_assoc()
1388 size += sizeof(struct ieee80211_mle_basic_common_info) + in ieee80211_send_assoc()
1394 * note this over-estimates a bit because there's no in ieee80211_send_assoc()
1397 size += (n_links - 1) * in ieee80211_send_assoc()
1403 link = sdata_dereference(sdata->link[assoc_data->assoc_link_id], sdata); in ieee80211_send_assoc()
1405 return -EINVAL; in ieee80211_send_assoc()
1407 if (WARN_ON(!assoc_data->link[assoc_data->assoc_link_id].bss)) in ieee80211_send_assoc()
1408 return -EINVAL; in ieee80211_send_assoc()
1410 skb = alloc_skb(size, GFP_KERNEL); in ieee80211_send_assoc()
1412 return -ENOMEM; in ieee80211_send_assoc()
1414 skb_reserve(skb, local->hw.extra_tx_headroom); in ieee80211_send_assoc()
1416 if (ifmgd->flags & IEEE80211_STA_ENABLE_RRM) in ieee80211_send_assoc()
1420 if (ieee80211_hw_check(&local->hw, SUPPORTS_ONLY_HE_MULTI_BSSID) && in ieee80211_send_assoc()
1421 !(link->u.mgd.conn_flags & IEEE80211_CONN_DISABLE_HE) && in ieee80211_send_assoc()
1422 ext_capa && ext_capa->datalen >= 3) in ieee80211_send_assoc()
1423 ext_capa->data[2] |= WLAN_EXT_CAPA3_MULTI_BSSID_SUPPORT; in ieee80211_send_assoc()
1426 memcpy(mgmt->da, sdata->vif.cfg.ap_addr, ETH_ALEN); in ieee80211_send_assoc()
1427 memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN); in ieee80211_send_assoc()
1428 memcpy(mgmt->bssid, sdata->vif.cfg.ap_addr, ETH_ALEN); in ieee80211_send_assoc()
1430 listen_int = cpu_to_le16(assoc_data->s1g ? in ieee80211_send_assoc()
1431 ieee80211_encode_usf(local->hw.conf.listen_interval) : in ieee80211_send_assoc()
1432 local->hw.conf.listen_interval); in ieee80211_send_assoc()
1433 if (!is_zero_ether_addr(assoc_data->prev_ap_addr)) { in ieee80211_send_assoc()
1435 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | in ieee80211_send_assoc()
1437 capab_pos = &mgmt->u.reassoc_req.capab_info; in ieee80211_send_assoc()
1438 mgmt->u.reassoc_req.listen_interval = listen_int; in ieee80211_send_assoc()
1439 memcpy(mgmt->u.reassoc_req.current_ap, in ieee80211_send_assoc()
1440 assoc_data->prev_ap_addr, ETH_ALEN); in ieee80211_send_assoc()
1444 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | in ieee80211_send_assoc()
1446 capab_pos = &mgmt->u.assoc_req.capab_info; in ieee80211_send_assoc()
1447 mgmt->u.assoc_req.listen_interval = listen_int; in ieee80211_send_assoc()
1452 pos = skb_put(skb, 2 + assoc_data->ssid_len); in ieee80211_send_assoc()
1455 *pos++ = assoc_data->ssid_len; in ieee80211_send_assoc()
1456 memcpy(pos, assoc_data->ssid, assoc_data->ssid_len); in ieee80211_send_assoc()
1462 assoc_data->ie, in ieee80211_send_assoc()
1463 assoc_data->ie_len, in ieee80211_send_assoc()
1464 assoc_data->assoc_link_id, link, in ieee80211_send_assoc()
1468 /* if present, add any custom non-vendor IEs */ in ieee80211_send_assoc()
1469 if (assoc_data->ie_len) { in ieee80211_send_assoc()
1470 noffset = ieee80211_ie_split_vendor(assoc_data->ie, in ieee80211_send_assoc()
1471 assoc_data->ie_len, in ieee80211_send_assoc()
1473 skb_put_data(skb, assoc_data->ie + offset, noffset - offset); in ieee80211_send_assoc()
1477 if (assoc_data->wmm) { in ieee80211_send_assoc()
1478 if (assoc_data->uapsd) { in ieee80211_send_assoc()
1479 qos_info = ifmgd->uapsd_queues; in ieee80211_send_assoc()
1480 qos_info |= (ifmgd->uapsd_max_sp_len << in ieee80211_send_assoc()
1490 if (assoc_data->ie_len) { in ieee80211_send_assoc()
1491 noffset = assoc_data->ie_len; in ieee80211_send_assoc()
1492 skb_put_data(skb, assoc_data->ie + offset, noffset - offset); in ieee80211_send_assoc()
1495 if (assoc_data->fils_kek_len) { in ieee80211_send_assoc()
1504 kfree(ifmgd->assoc_req_ies); in ieee80211_send_assoc()
1505 ifmgd->assoc_req_ies = kmemdup(ie_start, pos - ie_start, GFP_ATOMIC); in ieee80211_send_assoc()
1506 if (!ifmgd->assoc_req_ies) { in ieee80211_send_assoc()
1508 return -ENOMEM; in ieee80211_send_assoc()
1511 ifmgd->assoc_req_ies_len = pos - ie_start; in ieee80211_send_assoc()
1513 drv_mgd_prepare_tx(local, sdata, &info); in ieee80211_send_assoc()
1515 IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; in ieee80211_send_assoc()
1516 if (ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS)) in ieee80211_send_assoc()
1517 IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS | in ieee80211_send_assoc()
1524 void ieee80211_send_pspoll(struct ieee80211_local *local, in ieee80211_send_pspoll() argument
1530 skb = ieee80211_pspoll_get(&local->hw, &sdata->vif); in ieee80211_send_pspoll()
1534 pspoll = (struct ieee80211_pspoll *) skb->data; in ieee80211_send_pspoll()
1535 pspoll->frame_control |= cpu_to_le16(IEEE80211_FCTL_PM); in ieee80211_send_pspoll()
1537 IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; in ieee80211_send_pspoll()
1541 void ieee80211_send_nullfunc(struct ieee80211_local *local, in ieee80211_send_nullfunc() argument
1547 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_send_nullfunc()
1549 skb = ieee80211_nullfunc_get(&local->hw, &sdata->vif, -1, in ieee80211_send_nullfunc()
1550 !ieee80211_hw_check(&local->hw, in ieee80211_send_nullfunc()
1555 nullfunc = (struct ieee80211_hdr_3addr *) skb->data; in ieee80211_send_nullfunc()
1557 nullfunc->frame_control |= cpu_to_le16(IEEE80211_FCTL_PM); in ieee80211_send_nullfunc()
1559 IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT | in ieee80211_send_nullfunc()
1562 if (ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS)) in ieee80211_send_nullfunc()
1563 IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS; in ieee80211_send_nullfunc()
1565 if (ifmgd->flags & IEEE80211_STA_CONNECTION_POLL) in ieee80211_send_nullfunc()
1566 IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_CTL_USE_MINRATE; in ieee80211_send_nullfunc()
1571 void ieee80211_send_4addr_nullfunc(struct ieee80211_local *local, in ieee80211_send_4addr_nullfunc() argument
1578 if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_STATION)) in ieee80211_send_4addr_nullfunc()
1581 skb = dev_alloc_skb(local->hw.extra_tx_headroom + 30); in ieee80211_send_4addr_nullfunc()
1585 skb_reserve(skb, local->hw.extra_tx_headroom); in ieee80211_send_4addr_nullfunc()
1590 nullfunc->frame_control = fc; in ieee80211_send_4addr_nullfunc()
1591 memcpy(nullfunc->addr1, sdata->deflink.u.mgd.bssid, ETH_ALEN); in ieee80211_send_4addr_nullfunc()
1592 memcpy(nullfunc->addr2, sdata->vif.addr, ETH_ALEN); in ieee80211_send_4addr_nullfunc()
1593 memcpy(nullfunc->addr3, sdata->deflink.u.mgd.bssid, ETH_ALEN); in ieee80211_send_4addr_nullfunc()
1594 memcpy(nullfunc->addr4, sdata->vif.addr, ETH_ALEN); in ieee80211_send_4addr_nullfunc()
1596 IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; in ieee80211_send_4addr_nullfunc()
1597 IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_CTL_USE_MINRATE; in ieee80211_send_4addr_nullfunc()
1606 struct ieee80211_sub_if_data *sdata = link->sdata; in ieee80211_chswitch_work()
1607 struct ieee80211_local *local = sdata->local; in ieee80211_chswitch_work() local
1608 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_chswitch_work()
1615 mutex_lock(&local->mtx); in ieee80211_chswitch_work()
1616 mutex_lock(&local->chanctx_mtx); in ieee80211_chswitch_work()
1618 if (!ifmgd->associated) in ieee80211_chswitch_work()
1621 if (!link->conf->csa_active) in ieee80211_chswitch_work()
1626 * with multi-vif. once reservation is complete it will re-schedule the in ieee80211_chswitch_work()
1631 if (link->reserved_chanctx) { in ieee80211_chswitch_work()
1633 * with multi-vif csa driver may call ieee80211_csa_finish() in ieee80211_chswitch_work()
1637 if (link->reserved_ready) in ieee80211_chswitch_work()
1645 ieee80211_queue_work(&sdata->local->hw, in ieee80211_chswitch_work()
1646 &ifmgd->csa_connection_drop_work); in ieee80211_chswitch_work()
1653 if (!cfg80211_chandef_identical(&link->conf->chandef, in ieee80211_chswitch_work()
1654 &link->csa_chandef)) { in ieee80211_chswitch_work()
1657 ieee80211_queue_work(&sdata->local->hw, in ieee80211_chswitch_work()
1658 &ifmgd->csa_connection_drop_work); in ieee80211_chswitch_work()
1662 link->u.mgd.csa_waiting_bcn = true; in ieee80211_chswitch_work()
1668 mutex_unlock(&local->chanctx_mtx); in ieee80211_chswitch_work()
1669 mutex_unlock(&local->mtx); in ieee80211_chswitch_work()
1675 struct ieee80211_sub_if_data *sdata = link->sdata; in ieee80211_chswitch_post_beacon()
1676 struct ieee80211_local *local = sdata->local; in ieee80211_chswitch_post_beacon() local
1677 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_chswitch_post_beacon()
1682 WARN_ON(!link->conf->csa_active); in ieee80211_chswitch_post_beacon()
1684 if (link->csa_block_tx) { in ieee80211_chswitch_post_beacon()
1685 ieee80211_wake_vif_queues(local, sdata, in ieee80211_chswitch_post_beacon()
1687 link->csa_block_tx = false; in ieee80211_chswitch_post_beacon()
1690 link->conf->csa_active = false; in ieee80211_chswitch_post_beacon()
1691 link->u.mgd.csa_waiting_bcn = false; in ieee80211_chswitch_post_beacon()
1696 link->u.mgd.beacon_crc_valid = false; in ieee80211_chswitch_post_beacon()
1702 ieee80211_queue_work(&local->hw, in ieee80211_chswitch_post_beacon()
1703 &ifmgd->csa_connection_drop_work); in ieee80211_chswitch_post_beacon()
1707 cfg80211_ch_switch_notify(sdata->dev, &link->reserved_chandef, 0); in ieee80211_chswitch_post_beacon()
1713 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_chswitch_done()
1715 if (WARN_ON(sdata->vif.valid_links)) in ieee80211_chswitch_done()
1722 ieee80211_queue_work(&sdata->local->hw, in ieee80211_chswitch_done()
1723 &ifmgd->csa_connection_drop_work); in ieee80211_chswitch_done()
1725 ieee80211_queue_work(&sdata->local->hw, in ieee80211_chswitch_done()
1726 &sdata->deflink.u.mgd.chswitch_work); in ieee80211_chswitch_done()
1736 ieee80211_queue_work(&link->sdata->local->hw, in ieee80211_chswitch_timer()
1737 &link->u.mgd.chswitch_work); in ieee80211_chswitch_timer()
1743 struct ieee80211_sub_if_data *sdata = link->sdata; in ieee80211_sta_abort_chanswitch()
1744 struct ieee80211_local *local = sdata->local; in ieee80211_sta_abort_chanswitch() local
1746 if (!local->ops->abort_channel_switch) in ieee80211_sta_abort_chanswitch()
1749 mutex_lock(&local->mtx); in ieee80211_sta_abort_chanswitch()
1751 mutex_lock(&local->chanctx_mtx); in ieee80211_sta_abort_chanswitch()
1753 mutex_unlock(&local->chanctx_mtx); in ieee80211_sta_abort_chanswitch()
1755 if (link->csa_block_tx) in ieee80211_sta_abort_chanswitch()
1756 ieee80211_wake_vif_queues(local, sdata, in ieee80211_sta_abort_chanswitch()
1759 link->csa_block_tx = false; in ieee80211_sta_abort_chanswitch()
1760 link->conf->csa_active = false; in ieee80211_sta_abort_chanswitch()
1762 mutex_unlock(&local->mtx); in ieee80211_sta_abort_chanswitch()
1773 struct ieee80211_sub_if_data *sdata = link->sdata; in ieee80211_sta_process_chanswitch()
1774 struct ieee80211_local *local = sdata->local; in ieee80211_sta_process_chanswitch() local
1775 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_sta_process_chanswitch()
1776 struct cfg80211_bss *cbss = link->u.mgd.bss; in ieee80211_sta_process_chanswitch()
1790 if (local->scanning) in ieee80211_sta_process_chanswitch()
1793 current_band = cbss->channel->band; in ieee80211_sta_process_chanswitch()
1794 bss = (void *)cbss->priv; in ieee80211_sta_process_chanswitch()
1796 bss->vht_cap_info, in ieee80211_sta_process_chanswitch()
1797 link->u.mgd.conn_flags, in ieee80211_sta_process_chanswitch()
1798 link->u.mgd.bssid, &csa_ie); in ieee80211_sta_process_chanswitch()
1812 if (beacon && link->conf->csa_active && in ieee80211_sta_process_chanswitch()
1813 !link->u.mgd.csa_waiting_bcn) { in ieee80211_sta_process_chanswitch()
1819 } else if (link->conf->csa_active || res) { in ieee80211_sta_process_chanswitch()
1824 if (link->conf->chandef.chan->band != in ieee80211_sta_process_chanswitch()
1825 csa_ie.chandef.chan->band) { in ieee80211_sta_process_chanswitch()
1828 link->u.mgd.bssid, in ieee80211_sta_process_chanswitch()
1829 csa_ie.chandef.chan->center_freq, in ieee80211_sta_process_chanswitch()
1835 if (!cfg80211_chandef_usable(local->hw.wiphy, &csa_ie.chandef, in ieee80211_sta_process_chanswitch()
1841 link->u.mgd.bssid, in ieee80211_sta_process_chanswitch()
1842 csa_ie.chandef.chan->center_freq, in ieee80211_sta_process_chanswitch()
1843 csa_ie.chandef.chan->freq_offset, in ieee80211_sta_process_chanswitch()
1851 &link->conf->chandef) && in ieee80211_sta_process_chanswitch()
1853 if (link->u.mgd.csa_ignored_same_chan) in ieee80211_sta_process_chanswitch()
1857 link->u.mgd.bssid); in ieee80211_sta_process_chanswitch()
1858 link->u.mgd.csa_ignored_same_chan = true; in ieee80211_sta_process_chanswitch()
1863 * Drop all TDLS peers - either we disconnect or move to a different in ieee80211_sta_process_chanswitch()
1870 mutex_lock(&local->mtx); in ieee80211_sta_process_chanswitch()
1871 mutex_lock(&local->chanctx_mtx); in ieee80211_sta_process_chanswitch()
1872 conf = rcu_dereference_protected(link->conf->chanctx_conf, in ieee80211_sta_process_chanswitch()
1873 lockdep_is_held(&local->chanctx_mtx)); in ieee80211_sta_process_chanswitch()
1882 if (local->use_chanctx && in ieee80211_sta_process_chanswitch()
1883 !ieee80211_hw_check(&local->hw, CHANCTX_STA_CSA)) { in ieee80211_sta_process_chanswitch()
1885 "driver doesn't support chan-switch with channel contexts\n"); in ieee80211_sta_process_chanswitch()
1896 chanctx->mode, false); in ieee80211_sta_process_chanswitch()
1903 mutex_unlock(&local->chanctx_mtx); in ieee80211_sta_process_chanswitch()
1905 link->conf->csa_active = true; in ieee80211_sta_process_chanswitch()
1906 link->csa_chandef = csa_ie.chandef; in ieee80211_sta_process_chanswitch()
1907 link->csa_block_tx = csa_ie.mode; in ieee80211_sta_process_chanswitch()
1908 link->u.mgd.csa_ignored_same_chan = false; in ieee80211_sta_process_chanswitch()
1909 link->u.mgd.beacon_crc_valid = false; in ieee80211_sta_process_chanswitch()
1911 if (link->csa_block_tx) in ieee80211_sta_process_chanswitch()
1912 ieee80211_stop_vif_queues(local, sdata, in ieee80211_sta_process_chanswitch()
1914 mutex_unlock(&local->mtx); in ieee80211_sta_process_chanswitch()
1916 cfg80211_ch_switch_started_notify(sdata->dev, &csa_ie.chandef, 0, in ieee80211_sta_process_chanswitch()
1919 if (local->ops->channel_switch) { in ieee80211_sta_process_chanswitch()
1921 drv_channel_switch(local, sdata, &ch_switch); in ieee80211_sta_process_chanswitch()
1927 ieee80211_queue_work(&local->hw, &link->u.mgd.chswitch_work); in ieee80211_sta_process_chanswitch()
1929 mod_timer(&link->u.mgd.chswitch_timer, in ieee80211_sta_process_chanswitch()
1930 TU_TO_EXP_TIME((csa_ie.count - 1) * in ieee80211_sta_process_chanswitch()
1931 cbss->beacon_interval)); in ieee80211_sta_process_chanswitch()
1934 mutex_lock(&local->mtx); in ieee80211_sta_process_chanswitch()
1935 mutex_lock(&local->chanctx_mtx); in ieee80211_sta_process_chanswitch()
1944 link->conf->csa_active = true; in ieee80211_sta_process_chanswitch()
1945 link->csa_block_tx = csa_ie.mode; in ieee80211_sta_process_chanswitch()
1947 ieee80211_queue_work(&local->hw, &ifmgd->csa_connection_drop_work); in ieee80211_sta_process_chanswitch()
1948 mutex_unlock(&local->chanctx_mtx); in ieee80211_sta_process_chanswitch()
1949 mutex_unlock(&local->mtx); in ieee80211_sta_process_chanswitch()
1960 int chan = ieee80211_frequency_to_channel(channel->center_freq); in ieee80211_find_80211h_pwr_constr()
1969 country_ie_len -= 3; in ieee80211_find_80211h_pwr_constr()
1971 switch (channel->band) { in ieee80211_find_80211h_pwr_constr()
1996 u8 first_channel = triplet->chans.first_channel; in ieee80211_find_80211h_pwr_constr()
2001 for (i = 0; i < triplet->chans.num_channels; i++) { in ieee80211_find_80211h_pwr_constr()
2004 *chan_pwr = triplet->chans.max_power; in ieee80211_find_80211h_pwr_constr()
2013 country_ie_len -= 3; in ieee80211_find_80211h_pwr_constr()
2031 * APs clearly state the range is -127 to 127 dBm, which indicates in ieee80211_find_cisco_dtpc()
2045 struct ieee80211_sub_if_data *sdata = link->sdata; in ieee80211_handle_pwr_constr()
2050 __le16 capab = mgmt->u.probe_resp.capab_info; in ieee80211_handle_pwr_constr()
2052 if (ieee80211_is_s1g_beacon(mgmt->frame_control)) in ieee80211_handle_pwr_constr()
2062 max_t(int, 0, chan_pwr - pwr_reduction_80211h); in ieee80211_handle_pwr_constr()
2081 if (link->ap_power_level == new_ap_level) in ieee80211_handle_pwr_constr()
2085 "Limiting TX power to %d (%d - %d) dBm as advertised by %pM\n", in ieee80211_handle_pwr_constr()
2087 link->u.mgd.bssid); in ieee80211_handle_pwr_constr()
2091 if (link->ap_power_level == new_ap_level) in ieee80211_handle_pwr_constr()
2096 pwr_level_cisco, link->u.mgd.bssid); in ieee80211_handle_pwr_constr()
2099 link->ap_power_level = new_ap_level; in ieee80211_handle_pwr_constr()
2106 static void ieee80211_enable_ps(struct ieee80211_local *local, in ieee80211_enable_ps() argument
2109 struct ieee80211_conf *conf = &local->hw.conf; in ieee80211_enable_ps()
2115 if (local->scanning) in ieee80211_enable_ps()
2118 if (conf->dynamic_ps_timeout > 0 && in ieee80211_enable_ps()
2119 !ieee80211_hw_check(&local->hw, SUPPORTS_DYNAMIC_PS)) { in ieee80211_enable_ps()
2120 mod_timer(&local->dynamic_ps_timer, jiffies + in ieee80211_enable_ps()
2121 msecs_to_jiffies(conf->dynamic_ps_timeout)); in ieee80211_enable_ps()
2123 if (ieee80211_hw_check(&local->hw, PS_NULLFUNC_STACK)) in ieee80211_enable_ps()
2124 ieee80211_send_nullfunc(local, sdata, true); in ieee80211_enable_ps()
2126 if (ieee80211_hw_check(&local->hw, PS_NULLFUNC_STACK) && in ieee80211_enable_ps()
2127 ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS)) in ieee80211_enable_ps()
2130 conf->flags |= IEEE80211_CONF_PS; in ieee80211_enable_ps()
2131 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS); in ieee80211_enable_ps()
2135 static void ieee80211_change_ps(struct ieee80211_local *local) in ieee80211_change_ps() argument
2137 struct ieee80211_conf *conf = &local->hw.conf; in ieee80211_change_ps()
2139 if (local->ps_sdata) { in ieee80211_change_ps()
2140 ieee80211_enable_ps(local, local->ps_sdata); in ieee80211_change_ps()
2141 } else if (conf->flags & IEEE80211_CONF_PS) { in ieee80211_change_ps()
2142 conf->flags &= ~IEEE80211_CONF_PS; in ieee80211_change_ps()
2143 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS); in ieee80211_change_ps()
2144 del_timer_sync(&local->dynamic_ps_timer); in ieee80211_change_ps()
2145 cancel_work_sync(&local->dynamic_ps_enable_work); in ieee80211_change_ps()
2151 struct ieee80211_local *local = sdata->local; in ieee80211_powersave_allowed() local
2152 struct ieee80211_if_managed *mgd = &sdata->u.mgd; in ieee80211_powersave_allowed()
2156 if (!mgd->powersave) in ieee80211_powersave_allowed()
2159 if (mgd->broken_ap) in ieee80211_powersave_allowed()
2162 if (!mgd->associated) in ieee80211_powersave_allowed()
2165 if (mgd->flags & IEEE80211_STA_CONNECTION_POLL) in ieee80211_powersave_allowed()
2168 if (!(local->hw.wiphy->flags & WIPHY_FLAG_SUPPORTS_MLO) && in ieee80211_powersave_allowed()
2169 !sdata->deflink.u.mgd.have_beacon) in ieee80211_powersave_allowed()
2173 sta = sta_info_get(sdata, sdata->vif.cfg.ap_addr); in ieee80211_powersave_allowed()
2182 void ieee80211_recalc_ps(struct ieee80211_local *local) in ieee80211_recalc_ps() argument
2188 if (!ieee80211_hw_check(&local->hw, SUPPORTS_PS) || in ieee80211_recalc_ps()
2189 ieee80211_hw_check(&local->hw, SUPPORTS_DYNAMIC_PS)) { in ieee80211_recalc_ps()
2190 local->ps_sdata = NULL; in ieee80211_recalc_ps()
2194 list_for_each_entry(sdata, &local->interfaces, list) { in ieee80211_recalc_ps()
2197 if (sdata->vif.type == NL80211_IFTYPE_AP) { in ieee80211_recalc_ps()
2205 if (sdata->vif.type != NL80211_IFTYPE_STATION) in ieee80211_recalc_ps()
2212 u8 dtimper = found->deflink.u.mgd.dtim_period; in ieee80211_recalc_ps()
2214 timeout = local->dynamic_ps_forced_timeout; in ieee80211_recalc_ps()
2217 local->hw.conf.dynamic_ps_timeout = timeout; in ieee80211_recalc_ps()
2223 local->hw.conf.ps_dtim_period = dtimper; in ieee80211_recalc_ps()
2224 local->ps_sdata = found; in ieee80211_recalc_ps()
2226 local->ps_sdata = NULL; in ieee80211_recalc_ps()
2229 ieee80211_change_ps(local); in ieee80211_recalc_ps()
2236 if (sdata->vif.cfg.ps != ps_allowed) { in ieee80211_recalc_ps_vif()
2237 sdata->vif.cfg.ps = ps_allowed; in ieee80211_recalc_ps_vif()
2244 struct ieee80211_local *local = in ieee80211_dynamic_ps_disable_work() local
2248 if (local->hw.conf.flags & IEEE80211_CONF_PS) { in ieee80211_dynamic_ps_disable_work()
2249 local->hw.conf.flags &= ~IEEE80211_CONF_PS; in ieee80211_dynamic_ps_disable_work()
2250 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS); in ieee80211_dynamic_ps_disable_work()
2253 ieee80211_wake_queues_by_reason(&local->hw, in ieee80211_dynamic_ps_disable_work()
2261 struct ieee80211_local *local = in ieee80211_dynamic_ps_enable_work() local
2264 struct ieee80211_sub_if_data *sdata = local->ps_sdata; in ieee80211_dynamic_ps_enable_work()
2273 ifmgd = &sdata->u.mgd; in ieee80211_dynamic_ps_enable_work()
2275 if (local->hw.conf.flags & IEEE80211_CONF_PS) in ieee80211_dynamic_ps_enable_work()
2278 if (local->hw.conf.dynamic_ps_timeout > 0) { in ieee80211_dynamic_ps_enable_work()
2280 if (drv_tx_frames_pending(local)) { in ieee80211_dynamic_ps_enable_work()
2281 mod_timer(&local->dynamic_ps_timer, jiffies + in ieee80211_dynamic_ps_enable_work()
2283 local->hw.conf.dynamic_ps_timeout)); in ieee80211_dynamic_ps_enable_work()
2292 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); in ieee80211_dynamic_ps_enable_work()
2293 for (q = 0; q < local->hw.queues; q++) { in ieee80211_dynamic_ps_enable_work()
2294 if (local->queue_stop_reasons[q]) { in ieee80211_dynamic_ps_enable_work()
2295 spin_unlock_irqrestore(&local->queue_stop_reason_lock, in ieee80211_dynamic_ps_enable_work()
2297 mod_timer(&local->dynamic_ps_timer, jiffies + in ieee80211_dynamic_ps_enable_work()
2299 local->hw.conf.dynamic_ps_timeout)); in ieee80211_dynamic_ps_enable_work()
2303 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in ieee80211_dynamic_ps_enable_work()
2306 if (ieee80211_hw_check(&local->hw, PS_NULLFUNC_STACK) && in ieee80211_dynamic_ps_enable_work()
2307 !(ifmgd->flags & IEEE80211_STA_NULLFUNC_ACKED)) { in ieee80211_dynamic_ps_enable_work()
2308 if (drv_tx_frames_pending(local)) { in ieee80211_dynamic_ps_enable_work()
2309 mod_timer(&local->dynamic_ps_timer, jiffies + in ieee80211_dynamic_ps_enable_work()
2311 local->hw.conf.dynamic_ps_timeout)); in ieee80211_dynamic_ps_enable_work()
2313 ieee80211_send_nullfunc(local, sdata, true); in ieee80211_dynamic_ps_enable_work()
2315 ieee80211_flush_queues(local, sdata, false); in ieee80211_dynamic_ps_enable_work()
2319 if (!(ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS) && in ieee80211_dynamic_ps_enable_work()
2320 ieee80211_hw_check(&local->hw, PS_NULLFUNC_STACK)) || in ieee80211_dynamic_ps_enable_work()
2321 (ifmgd->flags & IEEE80211_STA_NULLFUNC_ACKED)) { in ieee80211_dynamic_ps_enable_work()
2322 ifmgd->flags &= ~IEEE80211_STA_NULLFUNC_ACKED; in ieee80211_dynamic_ps_enable_work()
2323 local->hw.conf.flags |= IEEE80211_CONF_PS; in ieee80211_dynamic_ps_enable_work()
2324 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS); in ieee80211_dynamic_ps_enable_work()
2330 struct ieee80211_local *local = from_timer(local, t, dynamic_ps_timer); in ieee80211_dynamic_ps_timer() local
2332 ieee80211_queue_work(&local->hw, &local->dynamic_ps_enable_work); in ieee80211_dynamic_ps_timer()
2341 struct cfg80211_chan_def chandef = link->conf->chandef; in ieee80211_dfs_cac_timer_work()
2342 struct ieee80211_sub_if_data *sdata = link->sdata; in ieee80211_dfs_cac_timer_work()
2344 mutex_lock(&sdata->local->mtx); in ieee80211_dfs_cac_timer_work()
2345 if (sdata->wdev.cac_started) { in ieee80211_dfs_cac_timer_work()
2347 cfg80211_cac_event(sdata->dev, &chandef, in ieee80211_dfs_cac_timer_work()
2351 mutex_unlock(&sdata->local->mtx); in ieee80211_dfs_cac_timer_work()
2357 struct ieee80211_local *local = sdata->local; in __ieee80211_sta_handle_tspec_ac_params() local
2358 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in __ieee80211_sta_handle_tspec_ac_params()
2362 if (local->hw.queues < IEEE80211_NUM_ACS) in __ieee80211_sta_handle_tspec_ac_params()
2366 struct ieee80211_sta_tx_tspec *tx_tspec = &ifmgd->tx_tspec[ac]; in __ieee80211_sta_handle_tspec_ac_params()
2370 if (tx_tspec->action == TX_TSPEC_ACTION_NONE && in __ieee80211_sta_handle_tspec_ac_params()
2371 tx_tspec->admitted_time && in __ieee80211_sta_handle_tspec_ac_params()
2372 time_after(now, tx_tspec->time_slice_start + HZ)) { in __ieee80211_sta_handle_tspec_ac_params()
2373 tx_tspec->consumed_tx_time = 0; in __ieee80211_sta_handle_tspec_ac_params()
2374 tx_tspec->time_slice_start = now; in __ieee80211_sta_handle_tspec_ac_params()
2376 if (tx_tspec->downgraded) in __ieee80211_sta_handle_tspec_ac_params()
2377 tx_tspec->action = in __ieee80211_sta_handle_tspec_ac_params()
2381 switch (tx_tspec->action) { in __ieee80211_sta_handle_tspec_ac_params()
2384 if (drv_conf_tx(local, &sdata->deflink, ac, in __ieee80211_sta_handle_tspec_ac_params()
2385 &sdata->deflink.tx_conf[ac])) in __ieee80211_sta_handle_tspec_ac_params()
2386 link_err(&sdata->deflink, in __ieee80211_sta_handle_tspec_ac_params()
2389 tx_tspec->action = TX_TSPEC_ACTION_NONE; in __ieee80211_sta_handle_tspec_ac_params()
2390 tx_tspec->downgraded = false; in __ieee80211_sta_handle_tspec_ac_params()
2394 if (time_after(now, tx_tspec->time_slice_start + HZ)) { in __ieee80211_sta_handle_tspec_ac_params()
2395 tx_tspec->action = TX_TSPEC_ACTION_NONE; in __ieee80211_sta_handle_tspec_ac_params()
2399 /* downgrade next lower non-ACM AC */ in __ieee80211_sta_handle_tspec_ac_params()
2403 if (!(sdata->wmm_acm & BIT(7 - 2 * non_acm_ac))) in __ieee80211_sta_handle_tspec_ac_params()
2407 * makes no sense and we have to transmit somehow - the in __ieee80211_sta_handle_tspec_ac_params()
2414 if (drv_conf_tx(local, &sdata->deflink, ac, in __ieee80211_sta_handle_tspec_ac_params()
2415 &sdata->deflink.tx_conf[non_acm_ac])) in __ieee80211_sta_handle_tspec_ac_params()
2416 link_err(&sdata->deflink, in __ieee80211_sta_handle_tspec_ac_params()
2419 tx_tspec->action = TX_TSPEC_ACTION_NONE; in __ieee80211_sta_handle_tspec_ac_params()
2421 schedule_delayed_work(&ifmgd->tx_tspec_wk, in __ieee80211_sta_handle_tspec_ac_params()
2422 tx_tspec->time_slice_start + HZ - now + 1); in __ieee80211_sta_handle_tspec_ac_params()
2436 ieee80211_link_info_change_notify(sdata, &sdata->deflink, in ieee80211_sta_handle_tspec_ac_params()
2451 struct ieee80211_sub_if_data *sdata = link->sdata; in ieee80211_mgd_set_link_qos_params()
2452 struct ieee80211_local *local = sdata->local; in ieee80211_mgd_set_link_qos_params() local
2453 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_mgd_set_link_qos_params()
2454 struct ieee80211_tx_queue_params *params = link->tx_conf; in ieee80211_mgd_set_link_qos_params()
2463 ifmgd->tx_tspec[ac].downgraded); in ieee80211_mgd_set_link_qos_params()
2464 if (!ifmgd->tx_tspec[ac].downgraded && in ieee80211_mgd_set_link_qos_params()
2465 drv_conf_tx(local, link, ac, ¶ms[ac])) in ieee80211_mgd_set_link_qos_params()
2474 ieee80211_sta_wmm_params(struct ieee80211_local *local, in ieee80211_sta_wmm_params() argument
2479 struct ieee80211_sub_if_data *sdata = link->sdata; in ieee80211_sta_wmm_params()
2481 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_sta_wmm_params()
2487 if (!local->ops->conf_tx) in ieee80211_sta_wmm_params()
2490 if (local->hw.queues < IEEE80211_NUM_ACS) in ieee80211_sta_wmm_params()
2499 if (ifmgd->flags & IEEE80211_STA_UAPSD_ENABLED) in ieee80211_sta_wmm_params()
2500 uapsd_queues = ifmgd->uapsd_queues; in ieee80211_sta_wmm_params()
2503 /* -1 is the initial value of ifmgd->mu_edca_last_param_set. in ieee80211_sta_wmm_params()
2507 mu_edca_count = mu_edca ? mu_edca->mu_qos_info & 0x0f : -1; in ieee80211_sta_wmm_params()
2508 if (count == link->u.mgd.wmm_last_param_set && in ieee80211_sta_wmm_params()
2509 mu_edca_count == link->u.mgd.mu_edca_last_param_set) in ieee80211_sta_wmm_params()
2511 link->u.mgd.wmm_last_param_set = count; in ieee80211_sta_wmm_params()
2512 link->u.mgd.mu_edca_last_param_set = mu_edca_count; in ieee80211_sta_wmm_params()
2515 left = wmm_param_len - 8; in ieee80211_sta_wmm_params()
2519 sdata->wmm_acm = 0; in ieee80211_sta_wmm_params()
2520 for (; left >= 4; left -= 4, pos += 4) { in ieee80211_sta_wmm_params()
2529 sdata->wmm_acm |= BIT(1) | BIT(2); /* BK/- */ in ieee80211_sta_wmm_params()
2534 params[ac].mu_edca_param_rec = mu_edca->ac_bk; in ieee80211_sta_wmm_params()
2539 sdata->wmm_acm |= BIT(4) | BIT(5); /* CL/VI */ in ieee80211_sta_wmm_params()
2544 params[ac].mu_edca_param_rec = mu_edca->ac_vi; in ieee80211_sta_wmm_params()
2549 sdata->wmm_acm |= BIT(6) | BIT(7); /* VO/NC */ in ieee80211_sta_wmm_params()
2554 params[ac].mu_edca_param_rec = mu_edca->ac_vo; in ieee80211_sta_wmm_params()
2560 sdata->wmm_acm |= BIT(0) | BIT(3); /* BE/EE */ in ieee80211_sta_wmm_params()
2565 params[ac].mu_edca_param_rec = mu_edca->ac_be; in ieee80211_sta_wmm_params()
2604 link->tx_conf[ac] = params[ac]; in ieee80211_sta_wmm_params()
2609 link->conf->qos = true; in ieee80211_sta_wmm_params()
2615 lockdep_assert_held(&sdata->local->mtx); in __ieee80211_stop_poll()
2617 sdata->u.mgd.flags &= ~IEEE80211_STA_CONNECTION_POLL; in __ieee80211_stop_poll()
2618 ieee80211_run_deferred_scan(sdata->local); in __ieee80211_stop_poll()
2623 mutex_lock(&sdata->local->mtx); in ieee80211_stop_poll()
2625 mutex_unlock(&sdata->local->mtx); in ieee80211_stop_poll()
2631 struct ieee80211_bss_conf *bss_conf = link->conf; in ieee80211_handle_bss_capability()
2651 if (sband->band == NL80211_BAND_5GHZ || in ieee80211_handle_bss_capability()
2652 sband->band == NL80211_BAND_6GHZ) in ieee80211_handle_bss_capability()
2655 if (use_protection != bss_conf->use_cts_prot) { in ieee80211_handle_bss_capability()
2656 bss_conf->use_cts_prot = use_protection; in ieee80211_handle_bss_capability()
2660 if (use_short_preamble != bss_conf->use_short_preamble) { in ieee80211_handle_bss_capability()
2661 bss_conf->use_short_preamble = use_short_preamble; in ieee80211_handle_bss_capability()
2665 if (use_short_slot != bss_conf->use_short_slot) { in ieee80211_handle_bss_capability()
2666 bss_conf->use_short_slot = use_short_slot; in ieee80211_handle_bss_capability()
2676 struct ieee80211_sub_if_data *sdata = link->sdata; in ieee80211_link_set_associated()
2677 struct ieee80211_bss_conf *bss_conf = link->conf; in ieee80211_link_set_associated()
2678 struct ieee80211_bss *bss = (void *)cbss->priv; in ieee80211_link_set_associated()
2682 sdata->u.mgd.beacon_timeout = in ieee80211_link_set_associated()
2684 bss_conf->beacon_int)); in ieee80211_link_set_associated()
2687 bss_conf->assoc_capability, in ieee80211_link_set_associated()
2688 bss->has_erp_value, in ieee80211_link_set_associated()
2689 bss->erp_value); in ieee80211_link_set_associated()
2693 link->u.mgd.bss = cbss; in ieee80211_link_set_associated()
2694 memcpy(link->u.mgd.bssid, cbss->bssid, ETH_ALEN); in ieee80211_link_set_associated()
2696 if (sdata->vif.p2p || in ieee80211_link_set_associated()
2697 sdata->vif.driver_flags & IEEE80211_VIF_GET_NOA_UPDATE) { in ieee80211_link_set_associated()
2701 ies = rcu_dereference(cbss->ies); in ieee80211_link_set_associated()
2706 ies->data, ies->len, in ieee80211_link_set_associated()
2708 (u8 *) &bss_conf->p2p_noa_attr, in ieee80211_link_set_associated()
2709 sizeof(bss_conf->p2p_noa_attr)); in ieee80211_link_set_associated()
2711 link->u.mgd.p2p_noa_index = in ieee80211_link_set_associated()
2712 bss_conf->p2p_noa_attr.index; in ieee80211_link_set_associated()
2719 if (link->u.mgd.have_beacon) { in ieee80211_link_set_associated()
2726 bss_conf->dtim_period = link->u.mgd.dtim_period ?: 1; in ieee80211_link_set_associated()
2727 bss_conf->beacon_rate = bss->beacon_rate; in ieee80211_link_set_associated()
2730 bss_conf->beacon_rate = NULL; in ieee80211_link_set_associated()
2731 bss_conf->dtim_period = 0; in ieee80211_link_set_associated()
2735 if (sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI && in ieee80211_link_set_associated()
2736 bss_conf->cqm_rssi_thold) in ieee80211_link_set_associated()
2746 struct ieee80211_local *local = sdata->local; in ieee80211_set_associated() local
2747 struct ieee80211_vif_cfg *vif_cfg = &sdata->vif.cfg; in ieee80211_set_associated()
2751 sdata->u.mgd.associated = true; in ieee80211_set_associated()
2754 struct cfg80211_bss *cbss = assoc_data->link[link_id].bss; in ieee80211_set_associated()
2760 link = sdata_dereference(sdata->link[link_id], sdata); in ieee80211_set_associated()
2770 ieee80211_led_assoc(local, 1); in ieee80211_set_associated()
2772 vif_cfg->assoc = 1; in ieee80211_set_associated()
2775 if (vif_cfg->arp_addr_cnt) in ieee80211_set_associated()
2778 if (sdata->vif.valid_links) { in ieee80211_set_associated()
2783 struct cfg80211_bss *cbss = assoc_data->link[link_id].bss; in ieee80211_set_associated()
2788 link = sdata_dereference(sdata->link[link_id], sdata); in ieee80211_set_associated()
2804 mutex_lock(&local->iflist_mtx); in ieee80211_set_associated()
2805 ieee80211_recalc_ps(local); in ieee80211_set_associated()
2806 mutex_unlock(&local->iflist_mtx); in ieee80211_set_associated()
2808 /* leave this here to not change ordering in non-MLO cases */ in ieee80211_set_associated()
2809 if (!sdata->vif.valid_links) in ieee80211_set_associated()
2810 ieee80211_recalc_smps(sdata, &sdata->deflink); in ieee80211_set_associated()
2813 netif_carrier_on(sdata->dev); in ieee80211_set_associated()
2820 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_set_disassoc()
2821 struct ieee80211_local *local = sdata->local; in ieee80211_set_disassoc() local
2833 if (WARN_ON(!ifmgd->associated)) in ieee80211_set_disassoc()
2838 ifmgd->associated = false; in ieee80211_set_disassoc()
2841 sdata->deflink.u.mgd.bss = NULL; in ieee80211_set_disassoc()
2843 netif_carrier_off(sdata->dev); in ieee80211_set_disassoc()
2847 * to do it before sending disassoc, as otherwise the null-packet in ieee80211_set_disassoc()
2850 if (local->hw.conf.flags & IEEE80211_CONF_PS) { in ieee80211_set_disassoc()
2851 local->hw.conf.flags &= ~IEEE80211_CONF_PS; in ieee80211_set_disassoc()
2852 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS); in ieee80211_set_disassoc()
2854 local->ps_sdata = NULL; in ieee80211_set_disassoc()
2856 /* disable per-vif ps */ in ieee80211_set_disassoc()
2869 ieee80211_flush_queues(local, sdata, true); in ieee80211_set_disassoc()
2879 if (ieee80211_hw_check(&local->hw, DEAUTH_NEED_MGD_TX_PREP) && in ieee80211_set_disassoc()
2880 !sdata->deflink.u.mgd.have_beacon) { in ieee80211_set_disassoc()
2881 drv_mgd_prepare_tx(sdata->local, sdata, &info); in ieee80211_set_disassoc()
2884 ieee80211_send_deauth_disassoc(sdata, sdata->vif.cfg.ap_addr, in ieee80211_set_disassoc()
2885 sdata->vif.cfg.ap_addr, stype, in ieee80211_set_disassoc()
2889 /* flush out frame - make sure the deauth was actually sent */ in ieee80211_set_disassoc()
2891 ieee80211_flush_queues(local, sdata, false); in ieee80211_set_disassoc()
2893 drv_mgd_complete_tx(sdata->local, sdata, &info); in ieee80211_set_disassoc()
2896 eth_zero_addr(sdata->deflink.u.mgd.bssid); in ieee80211_set_disassoc()
2897 eth_zero_addr(sdata->vif.cfg.ap_addr); in ieee80211_set_disassoc()
2899 sdata->vif.cfg.ssid_len = 0; in ieee80211_set_disassoc()
2905 if (!sdata->vif.valid_links) in ieee80211_set_disassoc()
2908 ieee80211_led_assoc(local, 0); in ieee80211_set_disassoc()
2910 sdata->vif.cfg.assoc = false; in ieee80211_set_disassoc()
2912 sdata->deflink.u.mgd.p2p_noa_index = -1; in ieee80211_set_disassoc()
2913 memset(&sdata->vif.bss_conf.p2p_noa_attr, 0, in ieee80211_set_disassoc()
2914 sizeof(sdata->vif.bss_conf.p2p_noa_attr)); in ieee80211_set_disassoc()
2916 /* on the next assoc, re-program HT/VHT parameters */ in ieee80211_set_disassoc()
2917 memset(&ifmgd->ht_capa, 0, sizeof(ifmgd->ht_capa)); in ieee80211_set_disassoc()
2918 memset(&ifmgd->ht_capa_mask, 0, sizeof(ifmgd->ht_capa_mask)); in ieee80211_set_disassoc()
2919 memset(&ifmgd->vht_capa, 0, sizeof(ifmgd->vht_capa)); in ieee80211_set_disassoc()
2920 memset(&ifmgd->vht_capa_mask, 0, sizeof(ifmgd->vht_capa_mask)); in ieee80211_set_disassoc()
2923 * reset MU-MIMO ownership and group data in default link, in ieee80211_set_disassoc()
2926 memset(sdata->vif.bss_conf.mu_group.membership, 0, in ieee80211_set_disassoc()
2927 sizeof(sdata->vif.bss_conf.mu_group.membership)); in ieee80211_set_disassoc()
2928 memset(sdata->vif.bss_conf.mu_group.position, 0, in ieee80211_set_disassoc()
2929 sizeof(sdata->vif.bss_conf.mu_group.position)); in ieee80211_set_disassoc()
2930 if (!sdata->vif.valid_links) in ieee80211_set_disassoc()
2932 sdata->vif.bss_conf.mu_mimo_owner = false; in ieee80211_set_disassoc()
2934 sdata->deflink.ap_power_level = IEEE80211_UNSET_POWER_LEVEL; in ieee80211_set_disassoc()
2936 del_timer_sync(&local->dynamic_ps_timer); in ieee80211_set_disassoc()
2937 cancel_work_sync(&local->dynamic_ps_enable_work); in ieee80211_set_disassoc()
2940 if (sdata->vif.cfg.arp_addr_cnt) in ieee80211_set_disassoc()
2943 sdata->vif.bss_conf.qos = false; in ieee80211_set_disassoc()
2944 if (!sdata->vif.valid_links) { in ieee80211_set_disassoc()
2953 /* disassociated - set to defaults now */ in ieee80211_set_disassoc()
2954 ieee80211_set_wmm_default(&sdata->deflink, false, false); in ieee80211_set_disassoc()
2956 del_timer_sync(&sdata->u.mgd.conn_mon_timer); in ieee80211_set_disassoc()
2957 del_timer_sync(&sdata->u.mgd.bcn_mon_timer); in ieee80211_set_disassoc()
2958 del_timer_sync(&sdata->u.mgd.timer); in ieee80211_set_disassoc()
2959 del_timer_sync(&sdata->deflink.u.mgd.chswitch_timer); in ieee80211_set_disassoc()
2961 sdata->vif.bss_conf.dtim_period = 0; in ieee80211_set_disassoc()
2962 sdata->vif.bss_conf.beacon_rate = NULL; in ieee80211_set_disassoc()
2964 sdata->deflink.u.mgd.have_beacon = false; in ieee80211_set_disassoc()
2965 sdata->deflink.u.mgd.tracking_signal_avg = false; in ieee80211_set_disassoc()
2966 sdata->deflink.u.mgd.disable_wmm_tracking = false; in ieee80211_set_disassoc()
2968 ifmgd->flags = 0; in ieee80211_set_disassoc()
2969 sdata->deflink.u.mgd.conn_flags = 0; in ieee80211_set_disassoc()
2970 mutex_lock(&local->mtx); in ieee80211_set_disassoc()
2972 for (link_id = 0; link_id < ARRAY_SIZE(sdata->link); link_id++) { in ieee80211_set_disassoc()
2975 link = sdata_dereference(sdata->link[link_id], sdata); in ieee80211_set_disassoc()
2981 sdata->vif.bss_conf.csa_active = false; in ieee80211_set_disassoc()
2982 sdata->deflink.u.mgd.csa_waiting_bcn = false; in ieee80211_set_disassoc()
2983 sdata->deflink.u.mgd.csa_ignored_same_chan = false; in ieee80211_set_disassoc()
2984 if (sdata->deflink.csa_block_tx) { in ieee80211_set_disassoc()
2985 ieee80211_wake_vif_queues(local, sdata, in ieee80211_set_disassoc()
2987 sdata->deflink.csa_block_tx = false; in ieee80211_set_disassoc()
2989 mutex_unlock(&local->mtx); in ieee80211_set_disassoc()
2992 memset(ifmgd->tx_tspec, 0, sizeof(ifmgd->tx_tspec)); in ieee80211_set_disassoc()
2993 cancel_delayed_work_sync(&ifmgd->tx_tspec_wk); in ieee80211_set_disassoc()
2995 sdata->vif.bss_conf.pwr_reduction = 0; in ieee80211_set_disassoc()
2996 sdata->vif.bss_conf.tx_pwr_env_num = 0; in ieee80211_set_disassoc()
2997 memset(sdata->vif.bss_conf.tx_pwr_env, 0, in ieee80211_set_disassoc()
2998 sizeof(sdata->vif.bss_conf.tx_pwr_env)); in ieee80211_set_disassoc()
3005 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_reset_ap_probe()
3006 struct ieee80211_local *local = sdata->local; in ieee80211_reset_ap_probe() local
3008 mutex_lock(&local->mtx); in ieee80211_reset_ap_probe()
3009 if (!(ifmgd->flags & IEEE80211_STA_CONNECTION_POLL)) in ieee80211_reset_ap_probe()
3014 mutex_lock(&local->iflist_mtx); in ieee80211_reset_ap_probe()
3015 ieee80211_recalc_ps(local); in ieee80211_reset_ap_probe()
3016 mutex_unlock(&local->iflist_mtx); in ieee80211_reset_ap_probe()
3018 if (ieee80211_hw_check(&sdata->local->hw, CONNECTION_MONITOR)) in ieee80211_reset_ap_probe()
3028 mod_timer(&ifmgd->conn_mon_timer, in ieee80211_reset_ap_probe()
3032 mutex_unlock(&local->mtx); in ieee80211_reset_ap_probe()
3039 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_sta_tx_wmm_ac_notify()
3045 if (!ieee80211_is_data_qos(hdr->frame_control)) in ieee80211_sta_tx_wmm_ac_notify()
3050 tx_tspec = &ifmgd->tx_tspec[ac]; in ieee80211_sta_tx_wmm_ac_notify()
3052 if (likely(!tx_tspec->admitted_time)) in ieee80211_sta_tx_wmm_ac_notify()
3055 if (time_after(now, tx_tspec->time_slice_start + HZ)) { in ieee80211_sta_tx_wmm_ac_notify()
3056 tx_tspec->consumed_tx_time = 0; in ieee80211_sta_tx_wmm_ac_notify()
3057 tx_tspec->time_slice_start = now; in ieee80211_sta_tx_wmm_ac_notify()
3059 if (tx_tspec->downgraded) { in ieee80211_sta_tx_wmm_ac_notify()
3060 tx_tspec->action = TX_TSPEC_ACTION_STOP_DOWNGRADE; in ieee80211_sta_tx_wmm_ac_notify()
3061 schedule_delayed_work(&ifmgd->tx_tspec_wk, 0); in ieee80211_sta_tx_wmm_ac_notify()
3065 if (tx_tspec->downgraded) in ieee80211_sta_tx_wmm_ac_notify()
3068 tx_tspec->consumed_tx_time += tx_time; in ieee80211_sta_tx_wmm_ac_notify()
3070 if (tx_tspec->consumed_tx_time >= tx_tspec->admitted_time) { in ieee80211_sta_tx_wmm_ac_notify()
3071 tx_tspec->downgraded = true; in ieee80211_sta_tx_wmm_ac_notify()
3072 tx_tspec->action = TX_TSPEC_ACTION_DOWNGRADE; in ieee80211_sta_tx_wmm_ac_notify()
3073 schedule_delayed_work(&ifmgd->tx_tspec_wk, 0); in ieee80211_sta_tx_wmm_ac_notify()
3082 if (!ieee80211_is_any_nullfunc(hdr->frame_control) || in ieee80211_sta_tx_notify()
3083 !sdata->u.mgd.probe_send_count) in ieee80211_sta_tx_notify()
3087 sdata->u.mgd.probe_send_count = 0; in ieee80211_sta_tx_notify()
3089 sdata->u.mgd.nullfunc_failed = true; in ieee80211_sta_tx_notify()
3090 ieee80211_queue_work(&sdata->local->hw, &sdata->work); in ieee80211_sta_tx_notify()
3100 skb = ieee80211_build_probe_req(sdata, src, dst, (u32)-1, channel, in ieee80211_mlme_send_probe_req()
3109 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_mgd_probe_ap_send()
3110 u8 *dst = sdata->vif.cfg.ap_addr; in ieee80211_mgd_probe_ap_send()
3111 u8 unicast_limit = max(1, max_probe_tries - 3); in ieee80211_mgd_probe_ap_send()
3114 if (WARN_ON(sdata->vif.valid_links)) in ieee80211_mgd_probe_ap_send()
3122 if (ifmgd->probe_send_count >= unicast_limit) in ieee80211_mgd_probe_ap_send()
3132 ifmgd->probe_send_count++; in ieee80211_mgd_probe_ap_send()
3135 mutex_lock(&sdata->local->sta_mtx); in ieee80211_mgd_probe_ap_send()
3139 mutex_unlock(&sdata->local->sta_mtx); in ieee80211_mgd_probe_ap_send()
3142 if (ieee80211_hw_check(&sdata->local->hw, REPORTS_TX_ACK_STATUS)) { in ieee80211_mgd_probe_ap_send()
3143 ifmgd->nullfunc_failed = false; in ieee80211_mgd_probe_ap_send()
3144 ieee80211_send_nullfunc(sdata->local, sdata, false); in ieee80211_mgd_probe_ap_send()
3146 ieee80211_mlme_send_probe_req(sdata, sdata->vif.addr, dst, in ieee80211_mgd_probe_ap_send()
3147 sdata->vif.cfg.ssid, in ieee80211_mgd_probe_ap_send()
3148 sdata->vif.cfg.ssid_len, in ieee80211_mgd_probe_ap_send()
3149 sdata->deflink.u.mgd.bss->channel); in ieee80211_mgd_probe_ap_send()
3152 ifmgd->probe_timeout = jiffies + msecs_to_jiffies(probe_wait_ms); in ieee80211_mgd_probe_ap_send()
3153 run_again(sdata, ifmgd->probe_timeout); in ieee80211_mgd_probe_ap_send()
3159 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_mgd_probe_ap()
3162 if (WARN_ON(sdata->vif.valid_links)) in ieee80211_mgd_probe_ap()
3170 if (!ifmgd->associated) in ieee80211_mgd_probe_ap()
3173 mutex_lock(&sdata->local->mtx); in ieee80211_mgd_probe_ap()
3175 if (sdata->local->tmp_channel || sdata->local->scanning) { in ieee80211_mgd_probe_ap()
3176 mutex_unlock(&sdata->local->mtx); in ieee80211_mgd_probe_ap()
3180 if (sdata->local->suspending) { in ieee80211_mgd_probe_ap()
3182 mutex_unlock(&sdata->local->mtx); in ieee80211_mgd_probe_ap()
3189 "detected beacon loss from AP (missed %d beacons) - probing\n", in ieee80211_mgd_probe_ap()
3192 ieee80211_cqm_beacon_loss_notify(&sdata->vif, GFP_KERNEL); in ieee80211_mgd_probe_ap()
3206 if (ifmgd->flags & IEEE80211_STA_CONNECTION_POLL) in ieee80211_mgd_probe_ap()
3209 ifmgd->flags |= IEEE80211_STA_CONNECTION_POLL; in ieee80211_mgd_probe_ap()
3211 mutex_unlock(&sdata->local->mtx); in ieee80211_mgd_probe_ap()
3216 mutex_lock(&sdata->local->iflist_mtx); in ieee80211_mgd_probe_ap()
3217 ieee80211_recalc_ps(sdata->local); in ieee80211_mgd_probe_ap()
3218 mutex_unlock(&sdata->local->iflist_mtx); in ieee80211_mgd_probe_ap()
3220 ifmgd->probe_send_count = 0; in ieee80211_mgd_probe_ap()
3230 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_ap_probereq_get()
3236 if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_STATION || in ieee80211_ap_probereq_get()
3237 sdata->vif.valid_links)) in ieee80211_ap_probereq_get()
3242 if (ifmgd->associated) in ieee80211_ap_probereq_get()
3243 cbss = sdata->deflink.u.mgd.bss; in ieee80211_ap_probereq_get()
3244 else if (ifmgd->auth_data) in ieee80211_ap_probereq_get()
3245 cbss = ifmgd->auth_data->bss; in ieee80211_ap_probereq_get()
3246 else if (ifmgd->assoc_data && ifmgd->assoc_data->link[0].bss) in ieee80211_ap_probereq_get()
3247 cbss = ifmgd->assoc_data->link[0].bss; in ieee80211_ap_probereq_get()
3253 if (WARN_ONCE(!ssid || ssid->datalen > IEEE80211_MAX_SSID_LEN, in ieee80211_ap_probereq_get()
3255 ssid ? ssid->datalen : -1)) in ieee80211_ap_probereq_get()
3258 ssid_len = ssid->datalen; in ieee80211_ap_probereq_get()
3260 skb = ieee80211_build_probe_req(sdata, sdata->vif.addr, cbss->bssid, in ieee80211_ap_probereq_get()
3261 (u32) -1, cbss->channel, in ieee80211_ap_probereq_get()
3262 ssid->data, ssid_len, in ieee80211_ap_probereq_get()
3281 cfg80211_tx_mlme_mgmt(sdata->dev, buf, len, reconnect); in ieee80211_report_disconnect()
3283 cfg80211_rx_mlme_mgmt(sdata->dev, buf, len); in ieee80211_report_disconnect()
3285 drv_event_callback(sdata->local, sdata, &event); in ieee80211_report_disconnect()
3290 struct ieee80211_local *local = sdata->local; in __ieee80211_disconnect() local
3291 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in __ieee80211_disconnect()
3296 if (!ifmgd->associated) { in __ieee80211_disconnect()
3302 tx = sdata->vif.valid_links || !sdata->deflink.csa_block_tx; in __ieee80211_disconnect()
3304 if (!ifmgd->driver_disconnect) { in __ieee80211_disconnect()
3310 * of multi-link, it's not clear that all of them really are in __ieee80211_disconnect()
3315 link_id < ARRAY_SIZE(sdata->link); in __ieee80211_disconnect()
3319 link = sdata_dereference(sdata->link[link_id], sdata); in __ieee80211_disconnect()
3322 cfg80211_unlink_bss(local->hw.wiphy, link->u.mgd.bss); in __ieee80211_disconnect()
3323 link->u.mgd.bss = NULL; in __ieee80211_disconnect()
3328 ifmgd->driver_disconnect ? in __ieee80211_disconnect()
3332 mutex_lock(&local->mtx); in __ieee80211_disconnect()
3334 sdata->vif.bss_conf.csa_active = false; in __ieee80211_disconnect()
3335 sdata->deflink.u.mgd.csa_waiting_bcn = false; in __ieee80211_disconnect()
3336 if (sdata->deflink.csa_block_tx) { in __ieee80211_disconnect()
3337 ieee80211_wake_vif_queues(local, sdata, in __ieee80211_disconnect()
3339 sdata->deflink.csa_block_tx = false; in __ieee80211_disconnect()
3341 mutex_unlock(&local->mtx); in __ieee80211_disconnect()
3345 ifmgd->reconnect); in __ieee80211_disconnect()
3346 ifmgd->reconnect = false; in __ieee80211_disconnect()
3356 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_beacon_connection_loss_work()
3358 if (ifmgd->connection_loss) { in ieee80211_beacon_connection_loss_work()
3360 sdata->vif.cfg.ap_addr); in ieee80211_beacon_connection_loss_work()
3362 ifmgd->connection_loss = false; in ieee80211_beacon_connection_loss_work()
3363 } else if (ifmgd->driver_disconnect) { in ieee80211_beacon_connection_loss_work()
3366 sdata->vif.cfg.ap_addr); in ieee80211_beacon_connection_loss_work()
3368 ifmgd->driver_disconnect = false; in ieee80211_beacon_connection_loss_work()
3370 if (ifmgd->associated) in ieee80211_beacon_connection_loss_work()
3371 sdata->deflink.u.mgd.beacon_loss_count++; in ieee80211_beacon_connection_loss_work()
3388 struct ieee80211_hw *hw = &sdata->local->hw; in ieee80211_beacon_loss()
3392 sdata->u.mgd.connection_loss = false; in ieee80211_beacon_loss()
3393 ieee80211_queue_work(hw, &sdata->u.mgd.beacon_connection_loss_work); in ieee80211_beacon_loss()
3400 struct ieee80211_hw *hw = &sdata->local->hw; in ieee80211_connection_loss()
3404 sdata->u.mgd.connection_loss = true; in ieee80211_connection_loss()
3405 ieee80211_queue_work(hw, &sdata->u.mgd.beacon_connection_loss_work); in ieee80211_connection_loss()
3412 struct ieee80211_hw *hw = &sdata->local->hw; in ieee80211_disconnect()
3416 if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_STATION)) in ieee80211_disconnect()
3419 sdata->u.mgd.driver_disconnect = true; in ieee80211_disconnect()
3420 sdata->u.mgd.reconnect = reconnect; in ieee80211_disconnect()
3421 ieee80211_queue_work(hw, &sdata->u.mgd.beacon_connection_loss_work); in ieee80211_disconnect()
3428 struct ieee80211_mgd_auth_data *auth_data = sdata->u.mgd.auth_data; in ieee80211_destroy_auth_data()
3438 del_timer_sync(&sdata->u.mgd.timer); in ieee80211_destroy_auth_data()
3439 sta_info_destroy_addr(sdata, auth_data->ap_addr); in ieee80211_destroy_auth_data()
3442 sdata->deflink.u.mgd.conn_flags = 0; in ieee80211_destroy_auth_data()
3443 eth_zero_addr(sdata->deflink.u.mgd.bssid); in ieee80211_destroy_auth_data()
3444 ieee80211_link_info_change_notify(sdata, &sdata->deflink, in ieee80211_destroy_auth_data()
3446 sdata->u.mgd.flags = 0; in ieee80211_destroy_auth_data()
3448 mutex_lock(&sdata->local->mtx); in ieee80211_destroy_auth_data()
3449 ieee80211_link_release_channel(&sdata->deflink); in ieee80211_destroy_auth_data()
3451 mutex_unlock(&sdata->local->mtx); in ieee80211_destroy_auth_data()
3454 cfg80211_put_bss(sdata->local->hw.wiphy, auth_data->bss); in ieee80211_destroy_auth_data()
3456 sdata->u.mgd.auth_data = NULL; in ieee80211_destroy_auth_data()
3469 struct ieee80211_mgd_assoc_data *assoc_data = sdata->u.mgd.assoc_data; in ieee80211_destroy_assoc_data()
3479 del_timer_sync(&sdata->u.mgd.timer); in ieee80211_destroy_assoc_data()
3480 sta_info_destroy_addr(sdata, assoc_data->ap_addr); in ieee80211_destroy_assoc_data()
3482 sdata->deflink.u.mgd.conn_flags = 0; in ieee80211_destroy_assoc_data()
3483 eth_zero_addr(sdata->deflink.u.mgd.bssid); in ieee80211_destroy_assoc_data()
3484 ieee80211_link_info_change_notify(sdata, &sdata->deflink, in ieee80211_destroy_assoc_data()
3486 sdata->u.mgd.flags = 0; in ieee80211_destroy_assoc_data()
3487 sdata->vif.bss_conf.mu_mimo_owner = false; in ieee80211_destroy_assoc_data()
3496 ARRAY_SIZE(assoc_data->link)); in ieee80211_destroy_assoc_data()
3499 data.bss[i] = assoc_data->link[i].bss; in ieee80211_destroy_assoc_data()
3501 if (sdata->vif.valid_links) in ieee80211_destroy_assoc_data()
3502 data.ap_mld_addr = assoc_data->ap_addr; in ieee80211_destroy_assoc_data()
3504 cfg80211_assoc_failure(sdata->dev, &data); in ieee80211_destroy_assoc_data()
3507 mutex_lock(&sdata->local->mtx); in ieee80211_destroy_assoc_data()
3508 ieee80211_link_release_channel(&sdata->deflink); in ieee80211_destroy_assoc_data()
3510 mutex_unlock(&sdata->local->mtx); in ieee80211_destroy_assoc_data()
3514 sdata->u.mgd.assoc_data = NULL; in ieee80211_destroy_assoc_data()
3520 struct ieee80211_local *local = sdata->local; in ieee80211_auth_challenge() local
3521 struct ieee80211_mgd_auth_data *auth_data = sdata->u.mgd.auth_data; in ieee80211_auth_challenge()
3529 pos = mgmt->u.auth.variable; in ieee80211_auth_challenge()
3531 len - (pos - (u8 *)mgmt)); in ieee80211_auth_challenge()
3534 auth_data->expected_transaction = 4; in ieee80211_auth_challenge()
3535 drv_mgd_prepare_tx(sdata->local, sdata, &info); in ieee80211_auth_challenge()
3536 if (ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS)) in ieee80211_auth_challenge()
3539 ieee80211_send_auth(sdata, 3, auth_data->algorithm, 0, in ieee80211_auth_challenge()
3541 challenge->datalen + sizeof(*challenge), in ieee80211_auth_challenge()
3542 auth_data->ap_addr, auth_data->ap_addr, in ieee80211_auth_challenge()
3543 auth_data->key, auth_data->key_len, in ieee80211_auth_challenge()
3544 auth_data->key_idx, tx_flags); in ieee80211_auth_challenge()
3549 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_mark_sta_auth()
3550 const u8 *ap_addr = ifmgd->auth_data->ap_addr; in ieee80211_mark_sta_auth()
3555 ifmgd->auth_data->done = true; in ieee80211_mark_sta_auth()
3556 ifmgd->auth_data->timeout = jiffies + IEEE80211_AUTH_WAIT_ASSOC; in ieee80211_mark_sta_auth()
3557 ifmgd->auth_data->timeout_started = true; in ieee80211_mark_sta_auth()
3558 run_again(sdata, ifmgd->auth_data->timeout); in ieee80211_mark_sta_auth()
3561 mutex_lock(&sdata->local->sta_mtx); in ieee80211_mark_sta_auth()
3564 WARN_ONCE(1, "%s: STA %pM not found", sdata->name, ap_addr); in ieee80211_mark_sta_auth()
3575 mutex_unlock(&sdata->local->sta_mtx); in ieee80211_mark_sta_auth()
3582 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_rx_mgmt_auth()
3597 if (!ifmgd->auth_data || ifmgd->auth_data->done) in ieee80211_rx_mgmt_auth()
3600 if (!ether_addr_equal(ifmgd->auth_data->ap_addr, mgmt->bssid)) in ieee80211_rx_mgmt_auth()
3603 auth_alg = le16_to_cpu(mgmt->u.auth.auth_alg); in ieee80211_rx_mgmt_auth()
3604 auth_transaction = le16_to_cpu(mgmt->u.auth.auth_transaction); in ieee80211_rx_mgmt_auth()
3605 status_code = le16_to_cpu(mgmt->u.auth.status_code); in ieee80211_rx_mgmt_auth()
3607 if (auth_alg != ifmgd->auth_data->algorithm || in ieee80211_rx_mgmt_auth()
3609 auth_transaction != ifmgd->auth_data->expected_transaction) || in ieee80211_rx_mgmt_auth()
3611 (auth_transaction < ifmgd->auth_data->expected_transaction || in ieee80211_rx_mgmt_auth()
3614 mgmt->sa, auth_alg, ifmgd->auth_data->algorithm, in ieee80211_rx_mgmt_auth()
3616 ifmgd->auth_data->expected_transaction); in ieee80211_rx_mgmt_auth()
3621 cfg80211_rx_mlme_mgmt(sdata->dev, (u8 *)mgmt, len); in ieee80211_rx_mgmt_auth()
3629 ifmgd->auth_data->waiting = true; in ieee80211_rx_mgmt_auth()
3630 ifmgd->auth_data->timeout = in ieee80211_rx_mgmt_auth()
3632 ifmgd->auth_data->timeout_started = true; in ieee80211_rx_mgmt_auth()
3633 run_again(sdata, ifmgd->auth_data->timeout); in ieee80211_rx_mgmt_auth()
3638 mgmt->sa, status_code); in ieee80211_rx_mgmt_auth()
3642 drv_event_callback(sdata->local, sdata, &event); in ieee80211_rx_mgmt_auth()
3646 switch (ifmgd->auth_data->algorithm) { in ieee80211_rx_mgmt_auth()
3656 if (ifmgd->auth_data->expected_transaction != 4) { in ieee80211_rx_mgmt_auth()
3664 ifmgd->auth_data->algorithm); in ieee80211_rx_mgmt_auth()
3670 drv_event_callback(sdata->local, sdata, &event); in ieee80211_rx_mgmt_auth()
3671 if (ifmgd->auth_data->algorithm != WLAN_AUTH_SAE || in ieee80211_rx_mgmt_auth()
3673 ifmgd->auth_data->expected_transaction == 2)) { in ieee80211_rx_mgmt_auth()
3675 return; /* ignore frame -- wait for timeout */ in ieee80211_rx_mgmt_auth()
3676 } else if (ifmgd->auth_data->algorithm == WLAN_AUTH_SAE && in ieee80211_rx_mgmt_auth()
3679 ifmgd->auth_data->peer_confirmed = true; in ieee80211_rx_mgmt_auth()
3682 cfg80211_rx_mlme_mgmt(sdata->dev, (u8 *)mgmt, len); in ieee80211_rx_mgmt_auth()
3684 drv_mgd_complete_tx(sdata->local, sdata, &info); in ieee80211_rx_mgmt_auth()
3747 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_rx_mgmt_deauth()
3748 u16 reason_code = le16_to_cpu(mgmt->u.deauth.reason_code); in ieee80211_rx_mgmt_deauth()
3755 if (!ether_addr_equal(mgmt->bssid, mgmt->sa)) { in ieee80211_rx_mgmt_deauth()
3756 ieee80211_tdls_handle_disconnect(sdata, mgmt->sa, reason_code); in ieee80211_rx_mgmt_deauth()
3760 if (ifmgd->associated && in ieee80211_rx_mgmt_deauth()
3761 ether_addr_equal(mgmt->bssid, sdata->vif.cfg.ap_addr)) { in ieee80211_rx_mgmt_deauth()
3763 sdata->vif.cfg.ap_addr, reason_code, in ieee80211_rx_mgmt_deauth()
3773 if (ifmgd->assoc_data && in ieee80211_rx_mgmt_deauth()
3774 ether_addr_equal(mgmt->bssid, ifmgd->assoc_data->ap_addr)) { in ieee80211_rx_mgmt_deauth()
3777 ifmgd->assoc_data->ap_addr, reason_code, in ieee80211_rx_mgmt_deauth()
3782 cfg80211_rx_mlme_mgmt(sdata->dev, (u8 *)mgmt, len); in ieee80211_rx_mgmt_deauth()
3791 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_rx_mgmt_disassoc()
3799 if (!ifmgd->associated || in ieee80211_rx_mgmt_disassoc()
3800 !ether_addr_equal(mgmt->bssid, sdata->vif.cfg.ap_addr)) in ieee80211_rx_mgmt_disassoc()
3803 reason_code = le16_to_cpu(mgmt->u.disassoc.reason_code); in ieee80211_rx_mgmt_disassoc()
3805 if (!ether_addr_equal(mgmt->bssid, mgmt->sa)) { in ieee80211_rx_mgmt_disassoc()
3806 ieee80211_tdls_handle_disconnect(sdata, mgmt->sa, reason_code); in ieee80211_rx_mgmt_disassoc()
3811 sdata->vif.cfg.ap_addr, reason_code, in ieee80211_rx_mgmt_disassoc()
3850 for (j = 0; j < sband->n_bitrates; j++) { in ieee80211_get_rates()
3854 br = &sband->bitrates[j]; in ieee80211_get_rates()
3856 brate = DIV_ROUND_UP(br->bitrate, (1 << shift) * 5); in ieee80211_get_rates()
3874 if (elems->ext_capab_len < 10) in ieee80211_twt_req_supported()
3877 if (!(elems->ext_capab[9] & WLAN_EXT_CAPA10_TWT_RESPONDER_SUPPORT)) in ieee80211_twt_req_supported()
3880 return link_sta->pub->he_cap.he_cap_elem.mac_cap_info[0] & in ieee80211_twt_req_supported()
3890 if (link->conf->twt_requester != twt) { in ieee80211_recalc_twt_req()
3891 link->conf->twt_requester = twt; in ieee80211_recalc_twt_req()
3904 ieee80211_vif_type_p2p(&sdata->vif)); in ieee80211_twt_bcast_support()
3906 return bss_conf->he_support && in ieee80211_twt_bcast_support()
3907 (link_sta->pub->he_cap.he_cap_elem.mac_cap_info[2] & in ieee80211_twt_bcast_support()
3910 (own_he_cap->he_cap_elem.mac_cap_info[2] & in ieee80211_twt_bcast_support()
3922 struct ieee80211_sub_if_data *sdata = link->sdata; in ieee80211_assoc_config_link()
3923 struct ieee80211_mgd_assoc_data *assoc_data = sdata->u.mgd.assoc_data; in ieee80211_assoc_config_link()
3924 struct ieee80211_bss_conf *bss_conf = link->conf; in ieee80211_assoc_config_link()
3925 struct ieee80211_local *local = sdata->local; in ieee80211_assoc_config_link() local
3930 .link_id = link == &sdata->deflink ? -1 : link->link_id, in ieee80211_assoc_config_link()
3933 bool is_6ghz = cbss->channel->band == NL80211_BAND_6GHZ; in ieee80211_assoc_config_link()
3934 bool is_s1g = cbss->channel->band == NL80211_BAND_S1GHZ; in ieee80211_assoc_config_link()
3946 capab_info = le16_to_cpu(mgmt->u.assoc_resp.capab_info); in ieee80211_assoc_config_link()
3948 if (!is_s1g && !elems->supp_rates) { in ieee80211_assoc_config_link()
3954 link->u.mgd.tdls_chan_switch_prohibited = in ieee80211_assoc_config_link()
3955 elems->ext_capab && elems->ext_capab_len >= 5 && in ieee80211_assoc_config_link()
3956 (elems->ext_capab[4] & WLAN_EXT_CAPA5_TDLS_CH_SW_PROHIBITED); in ieee80211_assoc_config_link()
3963 * "Vodafone PocketWiFi 2", "ZTE MF60" and a similar T-Mobile device. in ieee80211_assoc_config_link()
3966 ((assoc_data->wmm && !elems->wmm_param) || in ieee80211_assoc_config_link()
3967 (!(link->u.mgd.conn_flags & IEEE80211_CONN_DISABLE_HT) && in ieee80211_assoc_config_link()
3968 (!elems->ht_cap_elem || !elems->ht_operation)) || in ieee80211_assoc_config_link()
3969 (!(link->u.mgd.conn_flags & IEEE80211_CONN_DISABLE_VHT) && in ieee80211_assoc_config_link()
3970 (!elems->vht_cap_elem || !elems->vht_operation)))) { in ieee80211_assoc_config_link()
3975 ies = rcu_dereference(cbss->ies); in ieee80211_assoc_config_link()
3977 bss_ies = kmemdup(ies, sizeof(*ies) + ies->len, in ieee80211_assoc_config_link()
3985 parse_params.start = bss_ies->data; in ieee80211_assoc_config_link()
3986 parse_params.len = bss_ies->len; in ieee80211_assoc_config_link()
3993 if (assoc_data->wmm && in ieee80211_assoc_config_link()
3994 !elems->wmm_param && bss_elems->wmm_param) { in ieee80211_assoc_config_link()
3995 elems->wmm_param = bss_elems->wmm_param; in ieee80211_assoc_config_link()
4004 if (!elems->ht_cap_elem && bss_elems->ht_cap_elem && in ieee80211_assoc_config_link()
4005 !(link->u.mgd.conn_flags & IEEE80211_CONN_DISABLE_HT)) { in ieee80211_assoc_config_link()
4006 elems->ht_cap_elem = bss_elems->ht_cap_elem; in ieee80211_assoc_config_link()
4010 if (!elems->ht_operation && bss_elems->ht_operation && in ieee80211_assoc_config_link()
4011 !(link->u.mgd.conn_flags & IEEE80211_CONN_DISABLE_HT)) { in ieee80211_assoc_config_link()
4012 elems->ht_operation = bss_elems->ht_operation; in ieee80211_assoc_config_link()
4016 if (!elems->vht_cap_elem && bss_elems->vht_cap_elem && in ieee80211_assoc_config_link()
4017 !(link->u.mgd.conn_flags & IEEE80211_CONN_DISABLE_VHT)) { in ieee80211_assoc_config_link()
4018 elems->vht_cap_elem = bss_elems->vht_cap_elem; in ieee80211_assoc_config_link()
4022 if (!elems->vht_operation && bss_elems->vht_operation && in ieee80211_assoc_config_link()
4023 !(link->u.mgd.conn_flags & IEEE80211_CONN_DISABLE_VHT)) { in ieee80211_assoc_config_link()
4024 elems->vht_operation = bss_elems->vht_operation; in ieee80211_assoc_config_link()
4036 if (!is_6ghz && !(link->u.mgd.conn_flags & IEEE80211_CONN_DISABLE_HT) && in ieee80211_assoc_config_link()
4037 (!elems->wmm_param || !elems->ht_cap_elem || !elems->ht_operation)) { in ieee80211_assoc_config_link()
4044 if (!is_6ghz && !(link->u.mgd.conn_flags & IEEE80211_CONN_DISABLE_VHT) && in ieee80211_assoc_config_link()
4045 (!elems->vht_cap_elem || !elems->vht_operation)) { in ieee80211_assoc_config_link()
4052 if (is_6ghz && !(link->u.mgd.conn_flags & IEEE80211_CONN_DISABLE_HE) && in ieee80211_assoc_config_link()
4053 !elems->he_6ghz_capa) { in ieee80211_assoc_config_link()
4060 if (WARN_ON(!link->conf->chandef.chan)) { in ieee80211_assoc_config_link()
4064 sband = local->hw.wiphy->bands[link->conf->chandef.chan->band]; in ieee80211_assoc_config_link()
4066 if (!(link->u.mgd.conn_flags & IEEE80211_CONN_DISABLE_HE) && in ieee80211_assoc_config_link()
4067 (!elems->he_cap || !elems->he_operation)) { in ieee80211_assoc_config_link()
4075 if (elems->ht_cap_elem && !(link->u.mgd.conn_flags & IEEE80211_CONN_DISABLE_HT)) in ieee80211_assoc_config_link()
4077 elems->ht_cap_elem, in ieee80211_assoc_config_link()
4080 if (elems->vht_cap_elem && !(link->u.mgd.conn_flags & IEEE80211_CONN_DISABLE_VHT)) in ieee80211_assoc_config_link()
4082 elems->vht_cap_elem, in ieee80211_assoc_config_link()
4085 if (elems->he_operation && !(link->u.mgd.conn_flags & IEEE80211_CONN_DISABLE_HE) && in ieee80211_assoc_config_link()
4086 elems->he_cap) { in ieee80211_assoc_config_link()
4088 elems->he_cap, in ieee80211_assoc_config_link()
4089 elems->he_cap_len, in ieee80211_assoc_config_link()
4090 elems->he_6ghz_capa, in ieee80211_assoc_config_link()
4093 bss_conf->he_support = link_sta->pub->he_cap.has_he; in ieee80211_assoc_config_link()
4094 if (elems->rsnx && elems->rsnx_len && in ieee80211_assoc_config_link()
4095 (elems->rsnx[0] & WLAN_RSNX_CAPA_PROTECTED_TWT) && in ieee80211_assoc_config_link()
4096 wiphy_ext_feature_isset(local->hw.wiphy, in ieee80211_assoc_config_link()
4098 bss_conf->twt_protected = true; in ieee80211_assoc_config_link()
4100 bss_conf->twt_protected = false; in ieee80211_assoc_config_link()
4104 if (elems->eht_operation && elems->eht_cap && in ieee80211_assoc_config_link()
4105 !(link->u.mgd.conn_flags & IEEE80211_CONN_DISABLE_EHT)) { in ieee80211_assoc_config_link()
4107 elems->he_cap, in ieee80211_assoc_config_link()
4108 elems->he_cap_len, in ieee80211_assoc_config_link()
4109 elems->eht_cap, in ieee80211_assoc_config_link()
4110 elems->eht_cap_len, in ieee80211_assoc_config_link()
4113 bss_conf->eht_support = link_sta->pub->eht_cap.has_eht; in ieee80211_assoc_config_link()
4115 bss_conf->eht_support = false; in ieee80211_assoc_config_link()
4118 bss_conf->he_support = false; in ieee80211_assoc_config_link()
4119 bss_conf->twt_requester = false; in ieee80211_assoc_config_link()
4120 bss_conf->twt_protected = false; in ieee80211_assoc_config_link()
4121 bss_conf->eht_support = false; in ieee80211_assoc_config_link()
4124 bss_conf->twt_broadcast = in ieee80211_assoc_config_link()
4127 if (bss_conf->he_support) { in ieee80211_assoc_config_link()
4128 bss_conf->he_bss_color.color = in ieee80211_assoc_config_link()
4129 le32_get_bits(elems->he_operation->he_oper_params, in ieee80211_assoc_config_link()
4131 bss_conf->he_bss_color.partial = in ieee80211_assoc_config_link()
4132 le32_get_bits(elems->he_operation->he_oper_params, in ieee80211_assoc_config_link()
4134 bss_conf->he_bss_color.enabled = in ieee80211_assoc_config_link()
4135 !le32_get_bits(elems->he_operation->he_oper_params, in ieee80211_assoc_config_link()
4138 if (bss_conf->he_bss_color.enabled) in ieee80211_assoc_config_link()
4141 bss_conf->htc_trig_based_pkt_ext = in ieee80211_assoc_config_link()
4142 le32_get_bits(elems->he_operation->he_oper_params, in ieee80211_assoc_config_link()
4144 bss_conf->frame_time_rts_th = in ieee80211_assoc_config_link()
4145 le32_get_bits(elems->he_operation->he_oper_params, in ieee80211_assoc_config_link()
4148 bss_conf->uora_exists = !!elems->uora_element; in ieee80211_assoc_config_link()
4149 if (elems->uora_element) in ieee80211_assoc_config_link()
4150 bss_conf->uora_ocw_range = elems->uora_element[0]; in ieee80211_assoc_config_link()
4152 ieee80211_he_op_ie_to_bss_conf(&sdata->vif, elems->he_operation); in ieee80211_assoc_config_link()
4153 ieee80211_he_spr_ie_to_bss_conf(&sdata->vif, elems->he_spr); in ieee80211_assoc_config_link()
4157 if (cbss->transmitted_bss) { in ieee80211_assoc_config_link()
4158 bss_conf->nontransmitted = true; in ieee80211_assoc_config_link()
4159 ether_addr_copy(bss_conf->transmitter_bssid, in ieee80211_assoc_config_link()
4160 cbss->transmitted_bss->bssid); in ieee80211_assoc_config_link()
4161 bss_conf->bssid_indicator = cbss->max_bssid_indicator; in ieee80211_assoc_config_link()
4162 bss_conf->bssid_index = cbss->bssid_index; in ieee80211_assoc_config_link()
4177 if (elems->opmode_notif && in ieee80211_assoc_config_link()
4178 !(*elems->opmode_notif & IEEE80211_OPMODE_NOTIF_RX_NSS_TYPE_BF)) { in ieee80211_assoc_config_link()
4181 nss = *elems->opmode_notif & IEEE80211_OPMODE_NOTIF_RX_NSS_MASK; in ieee80211_assoc_config_link()
4184 link_sta->pub->rx_nss = nss; in ieee80211_assoc_config_link()
4189 * of the first value the AP uses. Setting -1 here has in ieee80211_assoc_config_link()
4191 * 4-bit value. in ieee80211_assoc_config_link()
4193 link->u.mgd.wmm_last_param_set = -1; in ieee80211_assoc_config_link()
4194 link->u.mgd.mu_edca_last_param_set = -1; in ieee80211_assoc_config_link()
4196 if (link->u.mgd.disable_wmm_tracking) { in ieee80211_assoc_config_link()
4198 } else if (!ieee80211_sta_wmm_params(local, link, elems->wmm_param, in ieee80211_assoc_config_link()
4199 elems->wmm_param_len, in ieee80211_assoc_config_link()
4200 elems->mu_edca_param_set)) { in ieee80211_assoc_config_link()
4210 link->u.mgd.disable_wmm_tracking = true; in ieee80211_assoc_config_link()
4213 if (elems->max_idle_period_ie) { in ieee80211_assoc_config_link()
4214 bss_conf->max_idle_period = in ieee80211_assoc_config_link()
4215 le16_to_cpu(elems->max_idle_period_ie->max_idle_period); in ieee80211_assoc_config_link()
4216 bss_conf->protected_keep_alive = in ieee80211_assoc_config_link()
4217 !!(elems->max_idle_period_ie->idle_options & in ieee80211_assoc_config_link()
4221 bss_conf->max_idle_period = 0; in ieee80211_assoc_config_link()
4222 bss_conf->protected_keep_alive = false; in ieee80211_assoc_config_link()
4227 bss_conf->assoc_capability = capab_info; in ieee80211_assoc_config_link()
4241 struct ieee80211_sub_if_data *sdata = link->sdata; in ieee80211_mgd_setup_link_sta()
4242 struct ieee80211_local *local = sdata->local; in ieee80211_mgd_setup_link_sta() local
4243 struct ieee80211_bss *bss = (void *)cbss->priv; in ieee80211_mgd_setup_link_sta()
4246 int min_rate = INT_MAX, min_rate_index = -1; in ieee80211_mgd_setup_link_sta()
4248 int shift = ieee80211_vif_get_shift(&sdata->vif); in ieee80211_mgd_setup_link_sta()
4251 memcpy(link_sta->addr, cbss->bssid, ETH_ALEN); in ieee80211_mgd_setup_link_sta()
4252 memcpy(link_sta->pub->addr, cbss->bssid, ETH_ALEN); in ieee80211_mgd_setup_link_sta()
4255 if (cbss->channel->band == NL80211_BAND_S1GHZ) { in ieee80211_mgd_setup_link_sta()
4260 sband = local->hw.wiphy->bands[cbss->channel->band]; in ieee80211_mgd_setup_link_sta()
4262 ieee80211_get_rates(sband, bss->supp_rates, bss->supp_rates_len, in ieee80211_mgd_setup_link_sta()
4272 * we can connect -- with a warning. in ieee80211_mgd_setup_link_sta()
4278 return -EINVAL; in ieee80211_mgd_setup_link_sta()
4285 link_sta->pub->supp_rates[cbss->channel->band] = rates; in ieee80211_mgd_setup_link_sta()
4289 link->conf->basic_rates = basic_rates; in ieee80211_mgd_setup_link_sta()
4292 link->operating_11g_mode = sband->band == NL80211_BAND_2GHZ && in ieee80211_mgd_setup_link_sta()
4313 if (link->u.mgd.conn_flags & IEEE80211_CONN_DISABLE_HT) in ieee80211_max_rx_chains()
4317 if (ht_cap_elem && ht_cap_elem->datalen >= sizeof(*ht_cap)) { in ieee80211_max_rx_chains()
4318 ht_cap = (void *)ht_cap_elem->data; in ieee80211_max_rx_chains()
4319 chains = ieee80211_mcs_to_chains(&ht_cap->mcs); in ieee80211_max_rx_chains()
4326 if (link->u.mgd.conn_flags & IEEE80211_CONN_DISABLE_VHT) in ieee80211_max_rx_chains()
4330 if (vht_cap_elem && vht_cap_elem->datalen >= sizeof(*vht_cap)) { in ieee80211_max_rx_chains()
4334 vht_cap = (void *)vht_cap_elem->data; in ieee80211_max_rx_chains()
4335 tx_mcs_map = le16_to_cpu(vht_cap->supp_mcs.tx_mcs_map); in ieee80211_max_rx_chains()
4336 for (nss = 8; nss > 0; nss--) { in ieee80211_max_rx_chains()
4337 if (((tx_mcs_map >> (2 * (nss - 1))) & 3) != in ieee80211_max_rx_chains()
4345 if (link->u.mgd.conn_flags & IEEE80211_CONN_DISABLE_HE) in ieee80211_max_rx_chains()
4348 ies = rcu_dereference(cbss->ies); in ieee80211_max_rx_chains()
4350 ies->data, ies->len); in ieee80211_max_rx_chains()
4352 if (!he_cap_elem || he_cap_elem->datalen < sizeof(*he_cap)) in ieee80211_max_rx_chains()
4356 he_cap = (void *)(he_cap_elem->data + 1); in ieee80211_max_rx_chains()
4360 if (he_cap_elem->datalen < 1 + mcs_nss_size + sizeof(*he_cap)) in ieee80211_max_rx_chains()
4366 mcs_80_map = le16_to_cpu(he_mcs_nss_supp->tx_mcs_80); in ieee80211_max_rx_chains()
4368 for (i = 7; i >= 0; i--) { in ieee80211_max_rx_chains()
4377 support_160 = he_cap->phy_cap_info[0] & in ieee80211_max_rx_chains()
4383 mcs_160_map = le16_to_cpu(he_mcs_nss_supp->tx_mcs_160); in ieee80211_max_rx_chains()
4384 for (i = 7; i >= 0; i--) { in ieee80211_max_rx_chains()
4410 ies->data, ies->len); in ieee80211_verify_peer_he_mcs_support()
4416 if (he_cap_elem->datalen < 1 + sizeof(*he_cap)) { in ieee80211_verify_peer_he_mcs_support()
4423 he_cap = (void *)(he_cap_elem->data + 1); in ieee80211_verify_peer_he_mcs_support()
4427 if (he_cap_elem->datalen < 1 + sizeof(*he_cap) + mcs_nss_size) { in ieee80211_verify_peer_he_mcs_support()
4429 "Invalid HE elem with nss size, Disable HE\n"); in ieee80211_verify_peer_he_mcs_support()
4436 mcs_80_map_tx = le16_to_cpu(he_mcs_nss_supp->tx_mcs_80); in ieee80211_verify_peer_he_mcs_support()
4437 mcs_80_map_rx = le16_to_cpu(he_mcs_nss_supp->rx_mcs_80); in ieee80211_verify_peer_he_mcs_support()
4439 /* P802.11-REVme/D0.3 in ieee80211_verify_peer_he_mcs_support()
4444 * Single spatial stream HE-MCSs 0 to 7 (transmit and receive) in all in ieee80211_verify_peer_he_mcs_support()
4458 ap_min_req_set = le16_to_cpu(he_op->he_mcs_nss_set); in ieee80211_verify_peer_he_mcs_support()
4470 * P802.11-REVme/D0.3 in ieee80211_verify_peer_he_mcs_support()
4474 * transmit at each of the <HE-MCS, NSS> tuple values indicated by the in ieee80211_verify_peer_he_mcs_support()
4475 * Basic HE-MCS And NSS Set field of the HE Operation parameter of the in ieee80211_verify_peer_he_mcs_support()
4476 * MLME-START.request primitive and shall be able to receive at each of in ieee80211_verify_peer_he_mcs_support()
4477 * the <HE-MCS, NSS> tuple values indicated by the Supported HE-MCS and in ieee80211_verify_peer_he_mcs_support()
4481 for (nss = 8; nss > 0; nss--) { in ieee80211_verify_peer_he_mcs_support()
4482 u8 ap_op_val = (ap_min_req_set >> (2 * (nss - 1))) & 3; in ieee80211_verify_peer_he_mcs_support()
4489 ap_rx_val = (mcs_80_map_rx >> (2 * (nss - 1))) & 3; in ieee80211_verify_peer_he_mcs_support()
4490 ap_tx_val = (mcs_80_map_tx >> (2 * (nss - 1))) & 3; in ieee80211_verify_peer_he_mcs_support()
4512 ieee80211_vif_type_p2p(&sdata->vif)); in ieee80211_verify_sta_he_mcs_support()
4519 ap_min_req_set = le16_to_cpu(he_op->he_mcs_nss_set); in ieee80211_verify_sta_he_mcs_support()
4532 &sta_he_cap->he_mcs_nss_supp; in ieee80211_verify_sta_he_mcs_support()
4542 * possible. Each of the sta_mcs_map_* is a 16-bit struct built in ieee80211_verify_sta_he_mcs_support()
4543 * of 2 bits per NSS (1-8), with the values defined in enum in ieee80211_verify_sta_he_mcs_support()
4549 for (nss = 8; nss > 0; nss--) { in ieee80211_verify_sta_he_mcs_support()
4550 u8 sta_rx_val = (sta_mcs_map_rx >> (2 * (nss - 1))) & 3; in ieee80211_verify_sta_he_mcs_support()
4551 u8 sta_tx_val = (sta_mcs_map_tx >> (2 * (nss - 1))) & 3; in ieee80211_verify_sta_he_mcs_support()
4552 u8 ap_val = (ap_min_req_set >> (2 * (nss - 1))) & 3; in ieee80211_verify_sta_he_mcs_support()
4561 * P802.11-REVme/D0.3 in ieee80211_verify_sta_he_mcs_support()
4564 * An HE STA shall not attempt to join * (MLME-JOIN.request primitive) in ieee80211_verify_sta_he_mcs_support()
4566 * receive using) all of the <HE-MCS, NSS> tuples in the basic in ieee80211_verify_sta_he_mcs_support()
4567 * HE-MCS and NSS set. in ieee80211_verify_sta_he_mcs_support()
4590 struct ieee80211_local *local = sdata->local; in ieee80211_prep_channel() local
4599 bool is_6ghz = cbss->channel->band == NL80211_BAND_6GHZ; in ieee80211_prep_channel()
4600 bool is_5ghz = cbss->channel->band == NL80211_BAND_5GHZ; in ieee80211_prep_channel()
4601 struct ieee80211_bss *bss = (void *)cbss->priv; in ieee80211_prep_channel()
4604 .link_id = -1, in ieee80211_prep_channel()
4615 ies = rcu_dereference(cbss->ies); in ieee80211_prep_channel()
4616 parse_params.start = ies->data; in ieee80211_prep_channel()
4617 parse_params.len = ies->len; in ieee80211_prep_channel()
4621 return -ENOMEM; in ieee80211_prep_channel()
4624 sband = local->hw.wiphy->bands[cbss->channel->band]; in ieee80211_prep_channel()
4631 if (!sband->ht_cap.ht_supported && !is_6ghz) { in ieee80211_prep_channel()
4639 if (!sband->vht_cap.vht_supported && is_5ghz) { in ieee80211_prep_channel()
4647 ieee80211_vif_type_p2p(&sdata->vif))) { in ieee80211_prep_channel()
4654 ieee80211_vif_type_p2p(&sdata->vif))) { in ieee80211_prep_channel()
4660 ht_oper = elems->ht_operation; in ieee80211_prep_channel()
4661 ht_cap = elems->ht_cap_elem; in ieee80211_prep_channel()
4670 vht_oper = elems->vht_operation; in ieee80211_prep_channel()
4681 if (!elems->vht_cap_elem) { in ieee80211_prep_channel()
4688 he_oper = elems->he_operation; in ieee80211_prep_channel()
4694 bss_conf = link->conf; in ieee80211_prep_channel()
4696 if (elems->pwr_constr_elem) in ieee80211_prep_channel()
4697 bss_conf->pwr_reduction = *elems->pwr_constr_elem; in ieee80211_prep_channel()
4699 BUILD_BUG_ON(ARRAY_SIZE(bss_conf->tx_pwr_env) != in ieee80211_prep_channel()
4700 ARRAY_SIZE(elems->tx_pwr_env)); in ieee80211_prep_channel()
4702 for (i = 0; i < elems->tx_pwr_env_num; i++) { in ieee80211_prep_channel()
4703 if (elems->tx_pwr_env_len[i] > in ieee80211_prep_channel()
4704 sizeof(bss_conf->tx_pwr_env[j])) in ieee80211_prep_channel()
4707 bss_conf->tx_pwr_env_num++; in ieee80211_prep_channel()
4708 memcpy(&bss_conf->tx_pwr_env[j], elems->tx_pwr_env[i], in ieee80211_prep_channel()
4709 elems->tx_pwr_env_len[i]); in ieee80211_prep_channel()
4733 cbss_ies = rcu_dereference(cbss->ies); in ieee80211_prep_channel()
4735 cbss_ies->data, cbss_ies->len); in ieee80211_prep_channel()
4745 for (i = 0; i < sband->n_channels; i++) { in ieee80211_prep_channel()
4746 if (sband->channels[i].flags & (IEEE80211_CHAN_DISABLED | in ieee80211_prep_channel()
4759 if (sband->band == NL80211_BAND_S1GHZ) { in ieee80211_prep_channel()
4760 s1g_oper = elems->s1g_oper; in ieee80211_prep_channel()
4769 cbss->channel, in ieee80211_prep_channel()
4770 bss->vht_cap_info, in ieee80211_prep_channel()
4777 link->needed_rx_chains = in ieee80211_prep_channel()
4779 local->rx_chains); in ieee80211_prep_channel()
4787 sdata_info(sdata, "Rejecting non-HE 6/7 GHz connection"); in ieee80211_prep_channel()
4788 return -EINVAL; in ieee80211_prep_channel()
4795 link->smps_mode = IEEE80211_SMPS_OFF; in ieee80211_prep_channel()
4797 mutex_lock(&local->mtx); in ieee80211_prep_channel()
4818 mutex_unlock(&local->mtx); in ieee80211_prep_channel()
4825 const u8 *tim_ie = cfg80211_find_ie(WLAN_EID_TIM, ies->data, ies->len); in ieee80211_get_dtim()
4826 const u8 *idx_ie = cfg80211_find_ie(WLAN_EID_MULTI_BSSID_IDX, ies->data, in ieee80211_get_dtim()
4827 ies->len); in ieee80211_get_dtim()
4836 *dtim_count = valid ? tim->dtim_count : 0; in ieee80211_get_dtim()
4839 *dtim_period = valid ? tim->dtim_period : 0; in ieee80211_get_dtim()
4841 /* Check if value is overridden by non-transmitted profile */ in ieee80211_get_dtim()
4848 *dtim_count = idx->dtim_count; in ieee80211_get_dtim()
4851 *dtim_period = idx->dtim_period; in ieee80211_get_dtim()
4861 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_assoc_success()
4862 struct ieee80211_mgd_assoc_data *assoc_data = ifmgd->assoc_data; in ieee80211_assoc_success()
4863 struct ieee80211_local *local = sdata->local; in ieee80211_assoc_success() local
4869 mutex_lock(&sdata->local->sta_mtx); in ieee80211_assoc_success()
4874 sta = sta_info_get(sdata, assoc_data->ap_addr); in ieee80211_assoc_success()
4878 if (sdata->vif.valid_links) { in ieee80211_assoc_success()
4882 if (!assoc_data->link[link_id].bss) in ieee80211_assoc_success()
4886 if (link_id != assoc_data->assoc_link_id) { in ieee80211_assoc_success()
4900 if (!assoc_data->link[link_id].bss) in ieee80211_assoc_success()
4903 link = sdata_dereference(sdata->link[link_id], sdata); in ieee80211_assoc_success()
4907 if (sdata->vif.valid_links) in ieee80211_assoc_success()
4909 "local address %pM, AP link address %pM\n", in ieee80211_assoc_success()
4910 link->conf->addr, in ieee80211_assoc_success()
4911 assoc_data->link[link_id].bss->bssid); in ieee80211_assoc_success()
4913 link_sta = rcu_dereference_protected(sta->link[link_id], in ieee80211_assoc_success()
4914 lockdep_is_held(&local->sta_mtx)); in ieee80211_assoc_success()
4918 if (link_id != assoc_data->assoc_link_id) { in ieee80211_assoc_success()
4919 struct cfg80211_bss *cbss = assoc_data->link[link_id].bss; in ieee80211_assoc_success()
4923 ies = rcu_dereference(cbss->ies); in ieee80211_assoc_success()
4925 &link->conf->sync_dtim_count, in ieee80211_assoc_success()
4926 &link->u.mgd.dtim_period); in ieee80211_assoc_success()
4927 link->conf->dtim_period = link->u.mgd.dtim_period ?: 1; in ieee80211_assoc_success()
4928 link->conf->beacon_int = cbss->beacon_interval; in ieee80211_assoc_success()
4932 &link->u.mgd.conn_flags); in ieee80211_assoc_success()
4940 assoc_data->link[link_id].bss); in ieee80211_assoc_success()
4945 assoc_data->link[link_id].bss, in ieee80211_assoc_success()
4950 if (link_id != assoc_data->assoc_link_id) { in ieee80211_assoc_success()
4959 if (ifmgd->flags & IEEE80211_STA_MFP_ENABLED) { in ieee80211_assoc_success()
4961 sta->sta.mfp = true; in ieee80211_assoc_success()
4963 sta->sta.mfp = false; in ieee80211_assoc_success()
4966 ieee80211_sta_set_max_amsdu_subframes(sta, elems->ext_capab, in ieee80211_assoc_success()
4967 elems->ext_capab_len); in ieee80211_assoc_success()
4969 sta->sta.wme = (elems->wmm_param || elems->s1g_capab) && in ieee80211_assoc_success()
4970 local->hw.queues >= IEEE80211_NUM_ACS; in ieee80211_assoc_success()
4973 if (!err && !(ifmgd->flags & IEEE80211_STA_CONTROL_PORT)) in ieee80211_assoc_success()
4978 sta->sta.addr); in ieee80211_assoc_success()
4983 if (sdata->wdev.use_4addr) in ieee80211_assoc_success()
4984 drv_sta_set_4addr(local, sdata, &sta->sta, true); in ieee80211_assoc_success()
4986 mutex_unlock(&sdata->local->sta_mtx); in ieee80211_assoc_success()
4991 * If we're using 4-addr mode, let the AP know that we're in ieee80211_assoc_success()
4994 if (ifmgd->use_4addr) in ieee80211_assoc_success()
4995 ieee80211_send_4addr_nullfunc(local, sdata); in ieee80211_assoc_success()
5006 eth_zero_addr(sdata->vif.cfg.ap_addr); in ieee80211_assoc_success()
5007 mutex_unlock(&sdata->local->sta_mtx); in ieee80211_assoc_success()
5015 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_rx_mgmt_assoc_resp()
5016 struct ieee80211_mgd_assoc_data *assoc_data = ifmgd->assoc_data; in ieee80211_rx_mgmt_assoc_resp()
5020 .link_id = -1, in ieee80211_rx_mgmt_assoc_resp()
5034 .uapsd_queues = -1, in ieee80211_rx_mgmt_assoc_resp()
5043 if (!ether_addr_equal(assoc_data->ap_addr, mgmt->bssid) || in ieee80211_rx_mgmt_assoc_resp()
5044 !ether_addr_equal(assoc_data->ap_addr, mgmt->sa)) in ieee80211_rx_mgmt_assoc_resp()
5055 reassoc = ieee80211_is_reassoc_resp(mgmt->frame_control); in ieee80211_rx_mgmt_assoc_resp()
5056 capab_info = le16_to_cpu(mgmt->u.assoc_resp.capab_info); in ieee80211_rx_mgmt_assoc_resp()
5057 status_code = le16_to_cpu(mgmt->u.assoc_resp.status_code); in ieee80211_rx_mgmt_assoc_resp()
5058 if (assoc_data->s1g) in ieee80211_rx_mgmt_assoc_resp()
5059 elem_start = mgmt->u.s1g_assoc_resp.variable; in ieee80211_rx_mgmt_assoc_resp()
5061 elem_start = mgmt->u.assoc_resp.variable; in ieee80211_rx_mgmt_assoc_resp()
5064 * Note: this may not be perfect, AP might misbehave - if in ieee80211_rx_mgmt_assoc_resp()
5072 if (assoc_data->fils_kek_len && in ieee80211_rx_mgmt_assoc_resp()
5076 elem_len = len - (elem_start - (u8 *)mgmt); in ieee80211_rx_mgmt_assoc_resp()
5083 if (elems->aid_resp) in ieee80211_rx_mgmt_assoc_resp()
5084 aid = le16_to_cpu(elems->aid_resp->aid); in ieee80211_rx_mgmt_assoc_resp()
5085 else if (assoc_data->s1g) in ieee80211_rx_mgmt_assoc_resp()
5088 aid = le16_to_cpu(mgmt->u.assoc_resp.aid); in ieee80211_rx_mgmt_assoc_resp()
5092 * (802.11-2016 9.4.1.8 AID field) in ieee80211_rx_mgmt_assoc_resp()
5098 reassoc ? "Rea" : "A", assoc_data->ap_addr, in ieee80211_rx_mgmt_assoc_resp()
5101 ifmgd->broken_ap = false; in ieee80211_rx_mgmt_assoc_resp()
5104 elems->timeout_int && in ieee80211_rx_mgmt_assoc_resp()
5105 elems->timeout_int->type == WLAN_TIMEOUT_ASSOC_COMEBACK) { in ieee80211_rx_mgmt_assoc_resp()
5108 cfg80211_assoc_comeback(sdata->dev, assoc_data->ap_addr, in ieee80211_rx_mgmt_assoc_resp()
5109 le32_to_cpu(elems->timeout_int->value)); in ieee80211_rx_mgmt_assoc_resp()
5111 tu = le32_to_cpu(elems->timeout_int->value); in ieee80211_rx_mgmt_assoc_resp()
5115 assoc_data->ap_addr, tu, ms); in ieee80211_rx_mgmt_assoc_resp()
5116 assoc_data->timeout = jiffies + msecs_to_jiffies(ms); in ieee80211_rx_mgmt_assoc_resp()
5117 assoc_data->timeout_started = true; in ieee80211_rx_mgmt_assoc_resp()
5119 run_again(sdata, assoc_data->timeout); in ieee80211_rx_mgmt_assoc_resp()
5125 assoc_data->ap_addr, status_code); in ieee80211_rx_mgmt_assoc_resp()
5128 drv_event_callback(sdata->local, sdata, &event); in ieee80211_rx_mgmt_assoc_resp()
5135 ifmgd->broken_ap = true; in ieee80211_rx_mgmt_assoc_resp()
5138 if (sdata->vif.valid_links) { in ieee80211_rx_mgmt_assoc_resp()
5139 if (!elems->multi_link) { in ieee80211_rx_mgmt_assoc_resp()
5141 "MLO association with %pM but no multi-link element in response!\n", in ieee80211_rx_mgmt_assoc_resp()
5142 assoc_data->ap_addr); in ieee80211_rx_mgmt_assoc_resp()
5146 if (le16_get_bits(elems->multi_link->control, in ieee80211_rx_mgmt_assoc_resp()
5150 "bad multi-link element (control=0x%x)\n", in ieee80211_rx_mgmt_assoc_resp()
5151 le16_to_cpu(elems->multi_link->control)); in ieee80211_rx_mgmt_assoc_resp()
5156 common = (void *)elems->multi_link->variable; in ieee80211_rx_mgmt_assoc_resp()
5158 if (memcmp(assoc_data->ap_addr, in ieee80211_rx_mgmt_assoc_resp()
5159 common->mld_mac_addr, ETH_ALEN)) { in ieee80211_rx_mgmt_assoc_resp()
5162 common->mld_mac_addr, in ieee80211_rx_mgmt_assoc_resp()
5163 assoc_data->ap_addr); in ieee80211_rx_mgmt_assoc_resp()
5169 sdata->vif.cfg.aid = aid; in ieee80211_rx_mgmt_assoc_resp()
5173 /* oops -- internal error -- send timeout for now */ in ieee80211_rx_mgmt_assoc_resp()
5178 drv_event_callback(sdata->local, sdata, &event); in ieee80211_rx_mgmt_assoc_resp()
5187 link = sdata_dereference(sdata->link[link_id], sdata); in ieee80211_rx_mgmt_assoc_resp()
5190 if (!assoc_data->link[link_id].bss) in ieee80211_rx_mgmt_assoc_resp()
5192 resp.links[link_id].bss = assoc_data->link[link_id].bss; in ieee80211_rx_mgmt_assoc_resp()
5193 resp.links[link_id].addr = link->conf->addr; in ieee80211_rx_mgmt_assoc_resp()
5195 /* get uapsd queues configuration - same for all links */ in ieee80211_rx_mgmt_assoc_resp()
5198 if (link->tx_conf[ac].uapsd) in ieee80211_rx_mgmt_assoc_resp()
5209 resp.req_ies = ifmgd->assoc_req_ies; in ieee80211_rx_mgmt_assoc_resp()
5210 resp.req_ies_len = ifmgd->assoc_req_ies_len; in ieee80211_rx_mgmt_assoc_resp()
5211 if (sdata->vif.valid_links) in ieee80211_rx_mgmt_assoc_resp()
5212 resp.ap_mld_addr = sdata->vif.cfg.ap_addr; in ieee80211_rx_mgmt_assoc_resp()
5213 cfg80211_rx_assoc_resp(sdata->dev, &resp); in ieee80211_rx_mgmt_assoc_resp()
5215 drv_mgd_complete_tx(sdata->local, sdata, &info); in ieee80211_rx_mgmt_assoc_resp()
5227 struct ieee80211_sub_if_data *sdata = link->sdata; in ieee80211_rx_bss_info()
5228 struct ieee80211_local *local = sdata->local; in ieee80211_rx_bss_info() local
5234 channel = ieee80211_get_channel_khz(local->hw.wiphy, in ieee80211_rx_bss_info()
5239 bss = ieee80211_bss_info_update(local, rx_status, mgmt, len, channel); in ieee80211_rx_bss_info()
5241 link->conf->beacon_rate = bss->beacon_rate; in ieee80211_rx_bss_info()
5242 ieee80211_rx_bss_put(local, bss); in ieee80211_rx_bss_info()
5250 struct ieee80211_sub_if_data *sdata = link->sdata; in ieee80211_rx_mgmt_probe_resp()
5251 struct ieee80211_mgmt *mgmt = (void *)skb->data; in ieee80211_rx_mgmt_probe_resp()
5253 struct ieee80211_rx_status *rx_status = (void *) skb->cb; in ieee80211_rx_mgmt_probe_resp()
5255 size_t baselen, len = skb->len; in ieee80211_rx_mgmt_probe_resp()
5257 ifmgd = &sdata->u.mgd; in ieee80211_rx_mgmt_probe_resp()
5268 channel = ieee80211_get_channel(sdata->local->hw.wiphy, in ieee80211_rx_mgmt_probe_resp()
5269 rx_status->freq); in ieee80211_rx_mgmt_probe_resp()
5273 if (!ether_addr_equal(mgmt->da, sdata->vif.addr) && in ieee80211_rx_mgmt_probe_resp()
5274 (channel->band != NL80211_BAND_6GHZ || in ieee80211_rx_mgmt_probe_resp()
5275 !is_broadcast_ether_addr(mgmt->da))) in ieee80211_rx_mgmt_probe_resp()
5278 baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt; in ieee80211_rx_mgmt_probe_resp()
5284 if (ifmgd->associated && in ieee80211_rx_mgmt_probe_resp()
5285 ether_addr_equal(mgmt->bssid, link->u.mgd.bssid)) in ieee80211_rx_mgmt_probe_resp()
5300 * XXX: This list needs to be dynamic -- userspace needs to be able to
5316 struct ieee80211_local *local, in ieee80211_handle_beacon_sig() argument
5319 struct ieee80211_sub_if_data *sdata = link->sdata; in ieee80211_handle_beacon_sig()
5323 if (!link->u.mgd.tracking_signal_avg) { in ieee80211_handle_beacon_sig()
5324 link->u.mgd.tracking_signal_avg = true; in ieee80211_handle_beacon_sig()
5325 ewma_beacon_signal_init(&link->u.mgd.ave_beacon_signal); in ieee80211_handle_beacon_sig()
5326 link->u.mgd.last_cqm_event_signal = 0; in ieee80211_handle_beacon_sig()
5327 link->u.mgd.count_beacon_signal = 1; in ieee80211_handle_beacon_sig()
5328 link->u.mgd.last_ave_beacon_signal = 0; in ieee80211_handle_beacon_sig()
5330 link->u.mgd.count_beacon_signal++; in ieee80211_handle_beacon_sig()
5333 ewma_beacon_signal_add(&link->u.mgd.ave_beacon_signal, in ieee80211_handle_beacon_sig()
5334 -rx_status->signal); in ieee80211_handle_beacon_sig()
5336 if (ifmgd->rssi_min_thold != ifmgd->rssi_max_thold && in ieee80211_handle_beacon_sig()
5337 link->u.mgd.count_beacon_signal >= IEEE80211_SIGNAL_AVE_MIN_COUNT) { in ieee80211_handle_beacon_sig()
5338 int sig = -ewma_beacon_signal_read(&link->u.mgd.ave_beacon_signal); in ieee80211_handle_beacon_sig()
5339 int last_sig = link->u.mgd.last_ave_beacon_signal; in ieee80211_handle_beacon_sig()
5348 if (sig > ifmgd->rssi_max_thold && in ieee80211_handle_beacon_sig()
5349 (last_sig <= ifmgd->rssi_min_thold || last_sig == 0)) { in ieee80211_handle_beacon_sig()
5350 link->u.mgd.last_ave_beacon_signal = sig; in ieee80211_handle_beacon_sig()
5352 drv_event_callback(local, sdata, &event); in ieee80211_handle_beacon_sig()
5353 } else if (sig < ifmgd->rssi_min_thold && in ieee80211_handle_beacon_sig()
5354 (last_sig >= ifmgd->rssi_max_thold || in ieee80211_handle_beacon_sig()
5356 link->u.mgd.last_ave_beacon_signal = sig; in ieee80211_handle_beacon_sig()
5358 drv_event_callback(local, sdata, &event); in ieee80211_handle_beacon_sig()
5362 if (bss_conf->cqm_rssi_thold && in ieee80211_handle_beacon_sig()
5363 link->u.mgd.count_beacon_signal >= IEEE80211_SIGNAL_AVE_MIN_COUNT && in ieee80211_handle_beacon_sig()
5364 !(sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI)) { in ieee80211_handle_beacon_sig()
5365 int sig = -ewma_beacon_signal_read(&link->u.mgd.ave_beacon_signal); in ieee80211_handle_beacon_sig()
5366 int last_event = link->u.mgd.last_cqm_event_signal; in ieee80211_handle_beacon_sig()
5367 int thold = bss_conf->cqm_rssi_thold; in ieee80211_handle_beacon_sig()
5368 int hyst = bss_conf->cqm_rssi_hyst; in ieee80211_handle_beacon_sig()
5371 (last_event == 0 || sig < last_event - hyst)) { in ieee80211_handle_beacon_sig()
5372 link->u.mgd.last_cqm_event_signal = sig; in ieee80211_handle_beacon_sig()
5374 &sdata->vif, in ieee80211_handle_beacon_sig()
5379 link->u.mgd.last_cqm_event_signal = sig; in ieee80211_handle_beacon_sig()
5381 &sdata->vif, in ieee80211_handle_beacon_sig()
5387 if (bss_conf->cqm_rssi_low && in ieee80211_handle_beacon_sig()
5388 link->u.mgd.count_beacon_signal >= IEEE80211_SIGNAL_AVE_MIN_COUNT) { in ieee80211_handle_beacon_sig()
5389 int sig = -ewma_beacon_signal_read(&link->u.mgd.ave_beacon_signal); in ieee80211_handle_beacon_sig()
5390 int last_event = link->u.mgd.last_cqm_event_signal; in ieee80211_handle_beacon_sig()
5391 int low = bss_conf->cqm_rssi_low; in ieee80211_handle_beacon_sig()
5392 int high = bss_conf->cqm_rssi_high; in ieee80211_handle_beacon_sig()
5396 link->u.mgd.last_cqm_event_signal = sig; in ieee80211_handle_beacon_sig()
5398 &sdata->vif, in ieee80211_handle_beacon_sig()
5403 link->u.mgd.last_cqm_event_signal = sig; in ieee80211_handle_beacon_sig()
5405 &sdata->vif, in ieee80211_handle_beacon_sig()
5415 if (ether_addr_equal(tx_bssid, bss->bssid)) in ieee80211_rx_our_beacon()
5417 if (!bss->transmitted_bss) in ieee80211_rx_our_beacon()
5419 return ether_addr_equal(tx_bssid, bss->transmitted_bss->bssid); in ieee80211_rx_our_beacon()
5426 struct ieee80211_sub_if_data *sdata = link->sdata; in ieee80211_rx_mgmt_beacon()
5427 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_rx_mgmt_beacon()
5428 struct ieee80211_bss_conf *bss_conf = &sdata->vif.bss_conf; in ieee80211_rx_mgmt_beacon()
5429 struct ieee80211_vif_cfg *vif_cfg = &sdata->vif.cfg; in ieee80211_rx_mgmt_beacon()
5433 struct ieee80211_local *local = sdata->local; in ieee80211_rx_mgmt_beacon() local
5442 u8 *bssid, *variable = mgmt->u.beacon.variable; in ieee80211_rx_mgmt_beacon()
5445 .link_id = -1, in ieee80211_rx_mgmt_beacon()
5452 bssid = ieee80211_get_bssid(hdr, len, sdata->vif.type); in ieee80211_rx_mgmt_beacon()
5453 if (ieee80211_is_s1g_beacon(mgmt->frame_control)) { in ieee80211_rx_mgmt_beacon()
5456 if (ieee80211_is_s1g_short_beacon(ext->frame_control)) in ieee80211_rx_mgmt_beacon()
5457 variable = ext->u.s1g_short_beacon.variable; in ieee80211_rx_mgmt_beacon()
5459 variable = ext->u.s1g_beacon.variable; in ieee80211_rx_mgmt_beacon()
5462 baselen = (u8 *) variable - (u8 *) mgmt; in ieee80211_rx_mgmt_beacon()
5467 parse_params.len = len - baselen; in ieee80211_rx_mgmt_beacon()
5470 chanctx_conf = rcu_dereference(link->conf->chanctx_conf); in ieee80211_rx_mgmt_beacon()
5477 ieee80211_channel_to_khz(chanctx_conf->def.chan)) { in ieee80211_rx_mgmt_beacon()
5481 chan = chanctx_conf->def.chan; in ieee80211_rx_mgmt_beacon()
5484 if (ifmgd->assoc_data && ifmgd->assoc_data->need_beacon && in ieee80211_rx_mgmt_beacon()
5485 !WARN_ON(sdata->vif.valid_links) && in ieee80211_rx_mgmt_beacon()
5486 ieee80211_rx_our_beacon(bssid, ifmgd->assoc_data->link[0].bss)) { in ieee80211_rx_mgmt_beacon()
5487 parse_params.bss = ifmgd->assoc_data->link[0].bss; in ieee80211_rx_mgmt_beacon()
5494 if (elems->dtim_period) in ieee80211_rx_mgmt_beacon()
5495 link->u.mgd.dtim_period = elems->dtim_period; in ieee80211_rx_mgmt_beacon()
5496 link->u.mgd.have_beacon = true; in ieee80211_rx_mgmt_beacon()
5497 ifmgd->assoc_data->need_beacon = false; in ieee80211_rx_mgmt_beacon()
5498 if (ieee80211_hw_check(&local->hw, TIMING_BEACON_ONLY)) { in ieee80211_rx_mgmt_beacon()
5499 link->conf->sync_tsf = in ieee80211_rx_mgmt_beacon()
5500 le64_to_cpu(mgmt->u.beacon.timestamp); in ieee80211_rx_mgmt_beacon()
5501 link->conf->sync_device_ts = in ieee80211_rx_mgmt_beacon()
5502 rx_status->device_timestamp; in ieee80211_rx_mgmt_beacon()
5503 link->conf->sync_dtim_count = elems->dtim_count; in ieee80211_rx_mgmt_beacon()
5506 if (elems->mbssid_config_ie) in ieee80211_rx_mgmt_beacon()
5507 bss_conf->profile_periodicity = in ieee80211_rx_mgmt_beacon()
5508 elems->mbssid_config_ie->profile_periodicity; in ieee80211_rx_mgmt_beacon()
5510 bss_conf->profile_periodicity = 0; in ieee80211_rx_mgmt_beacon()
5512 if (elems->ext_capab_len >= 11 && in ieee80211_rx_mgmt_beacon()
5513 (elems->ext_capab[10] & WLAN_EXT_CAPA11_EMA_SUPPORT)) in ieee80211_rx_mgmt_beacon()
5514 bss_conf->ema_ap = true; in ieee80211_rx_mgmt_beacon()
5516 bss_conf->ema_ap = false; in ieee80211_rx_mgmt_beacon()
5519 ifmgd->assoc_data->timeout = jiffies; in ieee80211_rx_mgmt_beacon()
5520 ifmgd->assoc_data->timeout_started = true; in ieee80211_rx_mgmt_beacon()
5521 run_again(sdata, ifmgd->assoc_data->timeout); in ieee80211_rx_mgmt_beacon()
5526 if (!ifmgd->associated || in ieee80211_rx_mgmt_beacon()
5527 !ieee80211_rx_our_beacon(bssid, link->u.mgd.bss)) in ieee80211_rx_mgmt_beacon()
5529 bssid = link->u.mgd.bssid; in ieee80211_rx_mgmt_beacon()
5531 if (!(rx_status->flag & RX_FLAG_NO_SIGNAL_VAL)) in ieee80211_rx_mgmt_beacon()
5533 local, rx_status); in ieee80211_rx_mgmt_beacon()
5535 if (ifmgd->flags & IEEE80211_STA_CONNECTION_POLL) { in ieee80211_rx_mgmt_beacon()
5552 if (!ieee80211_is_s1g_beacon(hdr->frame_control)) in ieee80211_rx_mgmt_beacon()
5553 ncrc = crc32_be(0, (void *)&mgmt->u.beacon.beacon_int, 4); in ieee80211_rx_mgmt_beacon()
5554 parse_params.bss = link->u.mgd.bss; in ieee80211_rx_mgmt_beacon()
5560 ncrc = elems->crc; in ieee80211_rx_mgmt_beacon()
5562 if (ieee80211_hw_check(&local->hw, PS_NULLFUNC_STACK) && in ieee80211_rx_mgmt_beacon()
5563 ieee80211_check_tim(elems->tim, elems->tim_len, vif_cfg->aid)) { in ieee80211_rx_mgmt_beacon()
5564 if (local->hw.conf.dynamic_ps_timeout > 0) { in ieee80211_rx_mgmt_beacon()
5565 if (local->hw.conf.flags & IEEE80211_CONF_PS) { in ieee80211_rx_mgmt_beacon()
5566 local->hw.conf.flags &= ~IEEE80211_CONF_PS; in ieee80211_rx_mgmt_beacon()
5567 ieee80211_hw_config(local, in ieee80211_rx_mgmt_beacon()
5570 ieee80211_send_nullfunc(local, sdata, false); in ieee80211_rx_mgmt_beacon()
5571 } else if (!local->pspolling && sdata->u.mgd.powersave) { in ieee80211_rx_mgmt_beacon()
5572 local->pspolling = true; in ieee80211_rx_mgmt_beacon()
5576 * able to send ps-poll frame and receive a in ieee80211_rx_mgmt_beacon()
5582 ieee80211_send_pspoll(local, sdata); in ieee80211_rx_mgmt_beacon()
5586 if (sdata->vif.p2p || in ieee80211_rx_mgmt_beacon()
5587 sdata->vif.driver_flags & IEEE80211_VIF_GET_NOA_UPDATE) { in ieee80211_rx_mgmt_beacon()
5592 len - baselen, in ieee80211_rx_mgmt_beacon()
5596 if (link->u.mgd.p2p_noa_index != noa.index) { in ieee80211_rx_mgmt_beacon()
5598 link->u.mgd.p2p_noa_index = noa.index; in ieee80211_rx_mgmt_beacon()
5599 memcpy(&bss_conf->p2p_noa_attr, &noa, sizeof(noa)); in ieee80211_rx_mgmt_beacon()
5605 link->u.mgd.beacon_crc_valid = false; in ieee80211_rx_mgmt_beacon()
5607 } else if (link->u.mgd.p2p_noa_index != -1) { in ieee80211_rx_mgmt_beacon()
5609 link->u.mgd.p2p_noa_index = -1; in ieee80211_rx_mgmt_beacon()
5610 memset(&bss_conf->p2p_noa_attr, 0, sizeof(bss_conf->p2p_noa_attr)); in ieee80211_rx_mgmt_beacon()
5612 link->u.mgd.beacon_crc_valid = false; in ieee80211_rx_mgmt_beacon()
5616 if (link->u.mgd.csa_waiting_bcn) in ieee80211_rx_mgmt_beacon()
5627 if (ieee80211_hw_check(&local->hw, TIMING_BEACON_ONLY) && in ieee80211_rx_mgmt_beacon()
5628 !ieee80211_is_s1g_beacon(hdr->frame_control)) { in ieee80211_rx_mgmt_beacon()
5629 link->conf->sync_tsf = in ieee80211_rx_mgmt_beacon()
5630 le64_to_cpu(mgmt->u.beacon.timestamp); in ieee80211_rx_mgmt_beacon()
5631 link->conf->sync_device_ts = in ieee80211_rx_mgmt_beacon()
5632 rx_status->device_timestamp; in ieee80211_rx_mgmt_beacon()
5633 link->conf->sync_dtim_count = elems->dtim_count; in ieee80211_rx_mgmt_beacon()
5636 if ((ncrc == link->u.mgd.beacon_crc && link->u.mgd.beacon_crc_valid) || in ieee80211_rx_mgmt_beacon()
5637 ieee80211_is_s1g_short_beacon(mgmt->frame_control)) in ieee80211_rx_mgmt_beacon()
5639 link->u.mgd.beacon_crc = ncrc; in ieee80211_rx_mgmt_beacon()
5640 link->u.mgd.beacon_crc_valid = true; in ieee80211_rx_mgmt_beacon()
5644 ieee80211_sta_process_chanswitch(link, rx_status->mactime, in ieee80211_rx_mgmt_beacon()
5645 rx_status->device_timestamp, in ieee80211_rx_mgmt_beacon()
5648 if (!link->u.mgd.disable_wmm_tracking && in ieee80211_rx_mgmt_beacon()
5649 ieee80211_sta_wmm_params(local, link, elems->wmm_param, in ieee80211_rx_mgmt_beacon()
5650 elems->wmm_param_len, in ieee80211_rx_mgmt_beacon()
5651 elems->mu_edca_param_set)) in ieee80211_rx_mgmt_beacon()
5658 if (!link->u.mgd.have_beacon) { in ieee80211_rx_mgmt_beacon()
5660 bss_conf->dtim_period = elems->dtim_period ?: 1; in ieee80211_rx_mgmt_beacon()
5663 link->u.mgd.have_beacon = true; in ieee80211_rx_mgmt_beacon()
5665 mutex_lock(&local->iflist_mtx); in ieee80211_rx_mgmt_beacon()
5666 ieee80211_recalc_ps(local); in ieee80211_rx_mgmt_beacon()
5667 mutex_unlock(&local->iflist_mtx); in ieee80211_rx_mgmt_beacon()
5672 if (elems->erp_info) { in ieee80211_rx_mgmt_beacon()
5674 erp_value = elems->erp_info[0]; in ieee80211_rx_mgmt_beacon()
5679 if (!ieee80211_is_s1g_beacon(hdr->frame_control)) in ieee80211_rx_mgmt_beacon()
5681 le16_to_cpu(mgmt->u.beacon.capab_info), in ieee80211_rx_mgmt_beacon()
5684 mutex_lock(&local->sta_mtx); in ieee80211_rx_mgmt_beacon()
5685 sta = sta_info_get(sdata, sdata->vif.cfg.ap_addr); in ieee80211_rx_mgmt_beacon()
5687 mutex_unlock(&local->sta_mtx); in ieee80211_rx_mgmt_beacon()
5690 link_sta = rcu_dereference_protected(sta->link[link->link_id], in ieee80211_rx_mgmt_beacon()
5691 lockdep_is_held(&local->sta_mtx)); in ieee80211_rx_mgmt_beacon()
5693 mutex_unlock(&local->sta_mtx); in ieee80211_rx_mgmt_beacon()
5699 if (ieee80211_config_bw(link, elems->ht_cap_elem, in ieee80211_rx_mgmt_beacon()
5700 elems->vht_cap_elem, elems->ht_operation, in ieee80211_rx_mgmt_beacon()
5701 elems->vht_operation, elems->he_operation, in ieee80211_rx_mgmt_beacon()
5702 elems->eht_operation, in ieee80211_rx_mgmt_beacon()
5703 elems->s1g_oper, bssid, &changed)) { in ieee80211_rx_mgmt_beacon()
5704 mutex_unlock(&local->sta_mtx); in ieee80211_rx_mgmt_beacon()
5718 if (sta && elems->opmode_notif) in ieee80211_rx_mgmt_beacon()
5720 *elems->opmode_notif, in ieee80211_rx_mgmt_beacon()
5721 rx_status->band); in ieee80211_rx_mgmt_beacon()
5722 mutex_unlock(&local->sta_mtx); in ieee80211_rx_mgmt_beacon()
5725 elems->country_elem, in ieee80211_rx_mgmt_beacon()
5726 elems->country_elem_len, in ieee80211_rx_mgmt_beacon()
5727 elems->pwr_constr_elem, in ieee80211_rx_mgmt_beacon()
5728 elems->cisco_dtpc_elem); in ieee80211_rx_mgmt_beacon()
5738 struct ieee80211_link_data *link = &sdata->deflink; in ieee80211_sta_rx_queued_ext()
5743 rx_status = (struct ieee80211_rx_status *) skb->cb; in ieee80211_sta_rx_queued_ext()
5744 hdr = (struct ieee80211_hdr *) skb->data; in ieee80211_sta_rx_queued_ext()
5745 fc = le16_to_cpu(hdr->frame_control); in ieee80211_sta_rx_queued_ext()
5750 ieee80211_rx_mgmt_beacon(link, hdr, skb->len, rx_status); in ieee80211_sta_rx_queued_ext()
5759 struct ieee80211_link_data *link = &sdata->deflink; in ieee80211_sta_rx_queued_mgmt()
5765 rx_status = (struct ieee80211_rx_status *) skb->cb; in ieee80211_sta_rx_queued_mgmt()
5766 mgmt = (struct ieee80211_mgmt *) skb->data; in ieee80211_sta_rx_queued_mgmt()
5767 fc = le16_to_cpu(mgmt->frame_control); in ieee80211_sta_rx_queued_mgmt()
5771 if (rx_status->link_valid) { in ieee80211_sta_rx_queued_mgmt()
5772 link = sdata_dereference(sdata->link[rx_status->link_id], in ieee80211_sta_rx_queued_mgmt()
5781 skb->len, rx_status); in ieee80211_sta_rx_queued_mgmt()
5787 ieee80211_rx_mgmt_auth(sdata, mgmt, skb->len); in ieee80211_sta_rx_queued_mgmt()
5790 ieee80211_rx_mgmt_deauth(sdata, mgmt, skb->len); in ieee80211_sta_rx_queued_mgmt()
5793 ieee80211_rx_mgmt_disassoc(sdata, mgmt, skb->len); in ieee80211_sta_rx_queued_mgmt()
5797 ieee80211_rx_mgmt_assoc_resp(sdata, mgmt, skb->len); in ieee80211_sta_rx_queued_mgmt()
5800 if (mgmt->u.action.category == WLAN_CATEGORY_SPECTRUM_MGMT) { in ieee80211_sta_rx_queued_mgmt()
5803 ies_len = skb->len - in ieee80211_sta_rx_queued_mgmt()
5812 mgmt->u.action.u.chan_switch.variable, in ieee80211_sta_rx_queued_mgmt()
5815 if (elems && !elems->parse_error) in ieee80211_sta_rx_queued_mgmt()
5817 rx_status->mactime, in ieee80211_sta_rx_queued_mgmt()
5818 rx_status->device_timestamp, in ieee80211_sta_rx_queued_mgmt()
5821 } else if (mgmt->u.action.category == WLAN_CATEGORY_PUBLIC) { in ieee80211_sta_rx_queued_mgmt()
5824 ies_len = skb->len - in ieee80211_sta_rx_queued_mgmt()
5836 mgmt->u.action.u.ext_chan_switch.variable, in ieee80211_sta_rx_queued_mgmt()
5839 if (elems && !elems->parse_error) { in ieee80211_sta_rx_queued_mgmt()
5841 elems->ext_chansw_ie = in ieee80211_sta_rx_queued_mgmt()
5842 &mgmt->u.action.u.ext_chan_switch.data; in ieee80211_sta_rx_queued_mgmt()
5845 rx_status->mactime, in ieee80211_sta_rx_queued_mgmt()
5846 rx_status->device_timestamp, in ieee80211_sta_rx_queued_mgmt()
5863 ieee80211_queue_work(&sdata->local->hw, &sdata->work); in ieee80211_sta_timer()
5880 struct ieee80211_local *local = sdata->local; in ieee80211_auth() local
5881 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_auth()
5882 struct ieee80211_mgd_auth_data *auth_data = ifmgd->auth_data; in ieee80211_auth()
5893 return -EINVAL; in ieee80211_auth()
5895 auth_data->tries++; in ieee80211_auth()
5897 if (auth_data->tries > IEEE80211_AUTH_MAX_TRIES) { in ieee80211_auth()
5899 auth_data->ap_addr); in ieee80211_auth()
5905 cfg80211_unlink_bss(local->hw.wiphy, auth_data->bss); in ieee80211_auth()
5907 return -ETIMEDOUT; in ieee80211_auth()
5910 if (auth_data->algorithm == WLAN_AUTH_SAE) in ieee80211_auth()
5913 drv_mgd_prepare_tx(local, sdata, &info); in ieee80211_auth()
5916 auth_data->ap_addr, auth_data->tries, in ieee80211_auth()
5919 auth_data->expected_transaction = 2; in ieee80211_auth()
5921 if (auth_data->algorithm == WLAN_AUTH_SAE) { in ieee80211_auth()
5922 trans = auth_data->sae_trans; in ieee80211_auth()
5923 status = auth_data->sae_status; in ieee80211_auth()
5924 auth_data->expected_transaction = trans; in ieee80211_auth()
5927 if (ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS)) in ieee80211_auth()
5931 ieee80211_send_auth(sdata, trans, auth_data->algorithm, status, in ieee80211_auth()
5932 auth_data->data, auth_data->data_len, in ieee80211_auth()
5933 auth_data->ap_addr, auth_data->ap_addr, in ieee80211_auth()
5937 if (auth_data->algorithm == WLAN_AUTH_SAE) in ieee80211_auth()
5938 auth_data->timeout = jiffies + in ieee80211_auth()
5941 auth_data->timeout = jiffies + IEEE80211_AUTH_TIMEOUT; in ieee80211_auth()
5943 auth_data->timeout = in ieee80211_auth()
5947 auth_data->timeout_started = true; in ieee80211_auth()
5948 run_again(sdata, auth_data->timeout); in ieee80211_auth()
5955 struct ieee80211_mgd_assoc_data *assoc_data = sdata->u.mgd.assoc_data; in ieee80211_do_assoc()
5956 struct ieee80211_local *local = sdata->local; in ieee80211_do_assoc() local
5961 assoc_data->tries++; in ieee80211_do_assoc()
5962 if (assoc_data->tries > IEEE80211_ASSOC_MAX_TRIES) { in ieee80211_do_assoc()
5964 assoc_data->ap_addr); in ieee80211_do_assoc()
5970 cfg80211_unlink_bss(local->hw.wiphy, in ieee80211_do_assoc()
5971 assoc_data->link[assoc_data->assoc_link_id].bss); in ieee80211_do_assoc()
5973 return -ETIMEDOUT; in ieee80211_do_assoc()
5977 assoc_data->ap_addr, assoc_data->tries, in ieee80211_do_assoc()
5983 if (!ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS)) { in ieee80211_do_assoc()
5984 assoc_data->timeout = jiffies + IEEE80211_ASSOC_TIMEOUT; in ieee80211_do_assoc()
5985 assoc_data->timeout_started = true; in ieee80211_do_assoc()
5986 run_again(sdata, assoc_data->timeout); in ieee80211_do_assoc()
5988 assoc_data->timeout = in ieee80211_do_assoc()
5991 assoc_data->timeout_started = true; in ieee80211_do_assoc()
5992 run_again(sdata, assoc_data->timeout); in ieee80211_do_assoc()
6001 struct ieee80211_local *local = sdata->local; in ieee80211_mgd_conn_tx_status() local
6003 sdata->u.mgd.status_fc = fc; in ieee80211_mgd_conn_tx_status()
6004 sdata->u.mgd.status_acked = acked; in ieee80211_mgd_conn_tx_status()
6005 sdata->u.mgd.status_received = true; in ieee80211_mgd_conn_tx_status()
6007 ieee80211_queue_work(&local->hw, &sdata->work); in ieee80211_mgd_conn_tx_status()
6012 struct ieee80211_local *local = sdata->local; in ieee80211_sta_work() local
6013 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_sta_work()
6017 if (ifmgd->status_received) { in ieee80211_sta_work()
6018 __le16 fc = ifmgd->status_fc; in ieee80211_sta_work()
6019 bool status_acked = ifmgd->status_acked; in ieee80211_sta_work()
6021 ifmgd->status_received = false; in ieee80211_sta_work()
6022 if (ifmgd->auth_data && ieee80211_is_auth(fc)) { in ieee80211_sta_work()
6024 if (ifmgd->auth_data->algorithm == in ieee80211_sta_work()
6026 ifmgd->auth_data->timeout = in ieee80211_sta_work()
6030 ifmgd->auth_data->timeout = in ieee80211_sta_work()
6033 run_again(sdata, ifmgd->auth_data->timeout); in ieee80211_sta_work()
6035 ifmgd->auth_data->timeout = jiffies - 1; in ieee80211_sta_work()
6037 ifmgd->auth_data->timeout_started = true; in ieee80211_sta_work()
6038 } else if (ifmgd->assoc_data && in ieee80211_sta_work()
6042 ifmgd->assoc_data->timeout = in ieee80211_sta_work()
6044 run_again(sdata, ifmgd->assoc_data->timeout); in ieee80211_sta_work()
6046 ifmgd->assoc_data->timeout = jiffies - 1; in ieee80211_sta_work()
6048 ifmgd->assoc_data->timeout_started = true; in ieee80211_sta_work()
6052 if (ifmgd->auth_data && ifmgd->auth_data->timeout_started && in ieee80211_sta_work()
6053 time_after(jiffies, ifmgd->auth_data->timeout)) { in ieee80211_sta_work()
6054 if (ifmgd->auth_data->done || ifmgd->auth_data->waiting) { in ieee80211_sta_work()
6068 memcpy(ap_addr, ifmgd->auth_data->ap_addr, ETH_ALEN); in ieee80211_sta_work()
6072 cfg80211_auth_timeout(sdata->dev, ap_addr); in ieee80211_sta_work()
6073 drv_event_callback(sdata->local, sdata, &event); in ieee80211_sta_work()
6075 } else if (ifmgd->auth_data && ifmgd->auth_data->timeout_started) in ieee80211_sta_work()
6076 run_again(sdata, ifmgd->auth_data->timeout); in ieee80211_sta_work()
6078 if (ifmgd->assoc_data && ifmgd->assoc_data->timeout_started && in ieee80211_sta_work()
6079 time_after(jiffies, ifmgd->assoc_data->timeout)) { in ieee80211_sta_work()
6080 if ((ifmgd->assoc_data->need_beacon && in ieee80211_sta_work()
6081 !sdata->deflink.u.mgd.have_beacon) || in ieee80211_sta_work()
6090 drv_event_callback(sdata->local, sdata, &event); in ieee80211_sta_work()
6092 } else if (ifmgd->assoc_data && ifmgd->assoc_data->timeout_started) in ieee80211_sta_work()
6093 run_again(sdata, ifmgd->assoc_data->timeout); in ieee80211_sta_work()
6095 if (ifmgd->flags & IEEE80211_STA_CONNECTION_POLL && in ieee80211_sta_work()
6096 ifmgd->associated) { in ieee80211_sta_work()
6097 u8 *bssid = sdata->deflink.u.mgd.bssid; in ieee80211_sta_work()
6100 if (ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS)) in ieee80211_sta_work()
6106 if (!ifmgd->probe_send_count) in ieee80211_sta_work()
6108 else if (ifmgd->nullfunc_failed) { in ieee80211_sta_work()
6109 if (ifmgd->probe_send_count < max_tries) { in ieee80211_sta_work()
6112 bssid, ifmgd->probe_send_count, in ieee80211_sta_work()
6123 } else if (time_is_after_jiffies(ifmgd->probe_timeout)) in ieee80211_sta_work()
6124 run_again(sdata, ifmgd->probe_timeout); in ieee80211_sta_work()
6125 else if (ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS)) { in ieee80211_sta_work()
6131 } else if (ifmgd->probe_send_count < max_tries) { in ieee80211_sta_work()
6135 ifmgd->probe_send_count, max_tries); in ieee80211_sta_work()
6159 if (WARN_ON(sdata->vif.valid_links)) in ieee80211_sta_bcn_mon_timer()
6162 if (sdata->vif.bss_conf.csa_active && in ieee80211_sta_bcn_mon_timer()
6163 !sdata->deflink.u.mgd.csa_waiting_bcn) in ieee80211_sta_bcn_mon_timer()
6166 if (sdata->vif.driver_flags & IEEE80211_VIF_BEACON_FILTER) in ieee80211_sta_bcn_mon_timer()
6169 sdata->u.mgd.connection_loss = false; in ieee80211_sta_bcn_mon_timer()
6170 ieee80211_queue_work(&sdata->local->hw, in ieee80211_sta_bcn_mon_timer()
6171 &sdata->u.mgd.beacon_connection_loss_work); in ieee80211_sta_bcn_mon_timer()
6178 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_sta_conn_mon_timer()
6179 struct ieee80211_local *local = sdata->local; in ieee80211_sta_conn_mon_timer() local
6183 if (WARN_ON(sdata->vif.valid_links)) in ieee80211_sta_conn_mon_timer()
6186 if (sdata->vif.bss_conf.csa_active && in ieee80211_sta_conn_mon_timer()
6187 !sdata->deflink.u.mgd.csa_waiting_bcn) in ieee80211_sta_conn_mon_timer()
6190 sta = sta_info_get(sdata, sdata->vif.cfg.ap_addr); in ieee80211_sta_conn_mon_timer()
6194 timeout = sta->deflink.status_stats.last_ack; in ieee80211_sta_conn_mon_timer()
6195 if (time_before(sta->deflink.status_stats.last_ack, sta->deflink.rx_stats.last_rx)) in ieee80211_sta_conn_mon_timer()
6196 timeout = sta->deflink.rx_stats.last_rx; in ieee80211_sta_conn_mon_timer()
6203 mod_timer(&ifmgd->conn_mon_timer, round_jiffies_up(timeout)); in ieee80211_sta_conn_mon_timer()
6207 ieee80211_queue_work(&local->hw, &ifmgd->monitor_work); in ieee80211_sta_conn_mon_timer()
6221 if (sdata->vif.type == NL80211_IFTYPE_STATION) { in ieee80211_restart_sta_timer()
6225 if (!ieee80211_hw_check(&sdata->local->hw, CONNECTION_MONITOR)) in ieee80211_restart_sta_timer()
6226 ieee80211_queue_work(&sdata->local->hw, in ieee80211_restart_sta_timer()
6227 &sdata->u.mgd.monitor_work); in ieee80211_restart_sta_timer()
6234 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_mgd_quiesce()
6239 if (ifmgd->auth_data || ifmgd->assoc_data) { in ieee80211_mgd_quiesce()
6240 const u8 *ap_addr = ifmgd->auth_data ? in ieee80211_mgd_quiesce()
6241 ifmgd->auth_data->ap_addr : in ieee80211_mgd_quiesce()
6242 ifmgd->assoc_data->ap_addr; in ieee80211_mgd_quiesce()
6253 if (ifmgd->assoc_data) in ieee80211_mgd_quiesce()
6255 if (ifmgd->auth_data) in ieee80211_mgd_quiesce()
6257 cfg80211_tx_mlme_mgmt(sdata->dev, frame_buf, in ieee80211_mgd_quiesce()
6262 /* This is a bit of a hack - we should find a better and more generic in ieee80211_mgd_quiesce()
6279 if (ifmgd->associated && !sdata->local->wowlan) { in ieee80211_mgd_quiesce()
6286 memcpy(bssid, sdata->vif.cfg.ap_addr, ETH_ALEN); in ieee80211_mgd_quiesce()
6296 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_sta_restart()
6299 if (!ifmgd->associated) { in ieee80211_sta_restart()
6304 if (sdata->flags & IEEE80211_SDATA_DISCONNECT_RESUME) { in ieee80211_sta_restart()
6305 sdata->flags &= ~IEEE80211_SDATA_DISCONNECT_RESUME; in ieee80211_sta_restart()
6314 if (sdata->flags & IEEE80211_SDATA_DISCONNECT_HW_RESTART) { in ieee80211_sta_restart()
6315 sdata->flags &= ~IEEE80211_SDATA_DISCONNECT_HW_RESTART; in ieee80211_sta_restart()
6333 sdata_lock(link->sdata); in ieee80211_request_smps_mgd_work()
6334 __ieee80211_request_smps_mgd(link->sdata, link, in ieee80211_request_smps_mgd_work()
6335 link->u.mgd.driver_smps_mode); in ieee80211_request_smps_mgd_work()
6336 sdata_unlock(link->sdata); in ieee80211_request_smps_mgd_work()
6342 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_sta_setup_sdata()
6344 INIT_WORK(&ifmgd->monitor_work, ieee80211_sta_monitor_work); in ieee80211_sta_setup_sdata()
6345 INIT_WORK(&ifmgd->beacon_connection_loss_work, in ieee80211_sta_setup_sdata()
6347 INIT_WORK(&ifmgd->csa_connection_drop_work, in ieee80211_sta_setup_sdata()
6349 INIT_DELAYED_WORK(&ifmgd->tdls_peer_del_work, in ieee80211_sta_setup_sdata()
6351 timer_setup(&ifmgd->timer, ieee80211_sta_timer, 0); in ieee80211_sta_setup_sdata()
6352 timer_setup(&ifmgd->bcn_mon_timer, ieee80211_sta_bcn_mon_timer, 0); in ieee80211_sta_setup_sdata()
6353 timer_setup(&ifmgd->conn_mon_timer, ieee80211_sta_conn_mon_timer, 0); in ieee80211_sta_setup_sdata()
6354 INIT_DELAYED_WORK(&ifmgd->tx_tspec_wk, in ieee80211_sta_setup_sdata()
6357 ifmgd->flags = 0; in ieee80211_sta_setup_sdata()
6358 ifmgd->powersave = sdata->wdev.ps; in ieee80211_sta_setup_sdata()
6359 ifmgd->uapsd_queues = sdata->local->hw.uapsd_queues; in ieee80211_sta_setup_sdata()
6360 ifmgd->uapsd_max_sp_len = sdata->local->hw.uapsd_max_sp_len; in ieee80211_sta_setup_sdata()
6362 spin_lock_init(&ifmgd->teardown_lock); in ieee80211_sta_setup_sdata()
6363 ifmgd->teardown_skb = NULL; in ieee80211_sta_setup_sdata()
6364 ifmgd->orig_teardown_skb = NULL; in ieee80211_sta_setup_sdata()
6369 struct ieee80211_sub_if_data *sdata = link->sdata; in ieee80211_mgd_setup_link()
6370 struct ieee80211_local *local = sdata->local; in ieee80211_mgd_setup_link() local
6371 unsigned int link_id = link->link_id; in ieee80211_mgd_setup_link()
6373 link->u.mgd.p2p_noa_index = -1; in ieee80211_mgd_setup_link()
6374 link->u.mgd.conn_flags = 0; in ieee80211_mgd_setup_link()
6375 link->conf->bssid = link->u.mgd.bssid; in ieee80211_mgd_setup_link()
6377 INIT_WORK(&link->u.mgd.request_smps_work, in ieee80211_mgd_setup_link()
6379 if (local->hw.wiphy->features & NL80211_FEATURE_DYNAMIC_SMPS) in ieee80211_mgd_setup_link()
6380 link->u.mgd.req_smps = IEEE80211_SMPS_AUTOMATIC; in ieee80211_mgd_setup_link()
6382 link->u.mgd.req_smps = IEEE80211_SMPS_OFF; in ieee80211_mgd_setup_link()
6384 INIT_WORK(&link->u.mgd.chswitch_work, ieee80211_chswitch_work); in ieee80211_mgd_setup_link()
6385 timer_setup(&link->u.mgd.chswitch_timer, ieee80211_chswitch_timer, 0); in ieee80211_mgd_setup_link()
6387 if (sdata->u.mgd.assoc_data) in ieee80211_mgd_setup_link()
6388 ether_addr_copy(link->conf->addr, in ieee80211_mgd_setup_link()
6389 sdata->u.mgd.assoc_data->link[link_id].addr); in ieee80211_mgd_setup_link()
6390 else if (!is_valid_ether_addr(link->conf->addr)) in ieee80211_mgd_setup_link()
6391 eth_random_addr(link->conf->addr); in ieee80211_mgd_setup_link()
6395 void ieee80211_mlme_notify_scan_completed(struct ieee80211_local *local) in ieee80211_mlme_notify_scan_completed() argument
6401 list_for_each_entry_rcu(sdata, &local->interfaces, list) { in ieee80211_mlme_notify_scan_completed()
6413 struct ieee80211_local *local = sdata->local; in ieee80211_prep_connection() local
6414 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_prep_connection()
6415 struct ieee80211_bss *bss = (void *)cbss->priv; in ieee80211_prep_connection()
6425 return -EINVAL; in ieee80211_prep_connection()
6429 return -EINVAL; in ieee80211_prep_connection()
6430 ap_mld_addr = cbss->bssid; in ieee80211_prep_connection()
6439 link = sdata_dereference(sdata->link[link_id], sdata); in ieee80211_prep_connection()
6441 err = -ENOLINK; in ieee80211_prep_connection()
6445 if (WARN_ON(!ifmgd->auth_data && !ifmgd->assoc_data)) { in ieee80211_prep_connection()
6446 err = -EINVAL; in ieee80211_prep_connection()
6451 if (local->in_reconfig) { in ieee80211_prep_connection()
6452 err = -EBUSY; in ieee80211_prep_connection()
6465 link_id, cbss->bssid, in ieee80211_prep_connection()
6471 err = -ENOMEM; in ieee80211_prep_connection()
6475 new_sta->sta.mlo = mlo; in ieee80211_prep_connection()
6480 * new channel. We can't - completely race-free - change the basic in ieee80211_prep_connection()
6484 * call that from changing the channel - only for IDLE and perhaps in ieee80211_prep_connection()
6496 link_sta = rcu_dereference(new_sta->link[link_id]); in ieee80211_prep_connection()
6499 sta_info_free(local, new_sta); in ieee80211_prep_connection()
6500 err = -EINVAL; in ieee80211_prep_connection()
6508 sta_info_free(local, new_sta); in ieee80211_prep_connection()
6512 memcpy(link->u.mgd.bssid, cbss->bssid, ETH_ALEN); in ieee80211_prep_connection()
6515 link->conf->beacon_int = cbss->beacon_interval; in ieee80211_prep_connection()
6516 ies = rcu_dereference(cbss->beacon_ies); in ieee80211_prep_connection()
6518 link->conf->sync_tsf = ies->tsf; in ieee80211_prep_connection()
6519 link->conf->sync_device_ts = in ieee80211_prep_connection()
6520 bss->device_ts_beacon; in ieee80211_prep_connection()
6523 &link->conf->sync_dtim_count, in ieee80211_prep_connection()
6525 } else if (!ieee80211_hw_check(&sdata->local->hw, in ieee80211_prep_connection()
6527 ies = rcu_dereference(cbss->proberesp_ies); in ieee80211_prep_connection()
6528 /* must be non-NULL since beacon IEs were NULL */ in ieee80211_prep_connection()
6529 link->conf->sync_tsf = ies->tsf; in ieee80211_prep_connection()
6530 link->conf->sync_device_ts = in ieee80211_prep_connection()
6531 bss->device_ts_presp; in ieee80211_prep_connection()
6532 link->conf->sync_dtim_count = 0; in ieee80211_prep_connection()
6534 link->conf->sync_tsf = 0; in ieee80211_prep_connection()
6535 link->conf->sync_device_ts = 0; in ieee80211_prep_connection()
6536 link->conf->sync_dtim_count = 0; in ieee80211_prep_connection()
6543 &link->u.mgd.conn_flags); in ieee80211_prep_connection()
6546 sta_info_free(local, new_sta); in ieee80211_prep_connection()
6573 WARN_ON_ONCE(!ether_addr_equal(link->u.mgd.bssid, cbss->bssid)); in ieee80211_prep_connection()
6576 if (local->scanning) in ieee80211_prep_connection()
6577 ieee80211_scan_cancel(local); in ieee80211_prep_connection()
6582 ieee80211_link_release_channel(&sdata->deflink); in ieee80211_prep_connection()
6591 struct ieee80211_local *local = sdata->local; in ieee80211_mgd_auth() local
6592 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_mgd_auth()
6600 switch (req->auth_type) { in ieee80211_mgd_auth()
6606 return -EOPNOTSUPP; in ieee80211_mgd_auth()
6628 return -EOPNOTSUPP; in ieee80211_mgd_auth()
6631 if (ifmgd->assoc_data) in ieee80211_mgd_auth()
6632 return -EBUSY; in ieee80211_mgd_auth()
6634 auth_data = kzalloc(sizeof(*auth_data) + req->auth_data_len + in ieee80211_mgd_auth()
6635 req->ie_len, GFP_KERNEL); in ieee80211_mgd_auth()
6637 return -ENOMEM; in ieee80211_mgd_auth()
6639 memcpy(auth_data->ap_addr, in ieee80211_mgd_auth()
6640 req->ap_mld_addr ?: req->bss->bssid, in ieee80211_mgd_auth()
6642 auth_data->bss = req->bss; in ieee80211_mgd_auth()
6644 if (req->auth_data_len >= 4) { in ieee80211_mgd_auth()
6645 if (req->auth_type == NL80211_AUTHTYPE_SAE) { in ieee80211_mgd_auth()
6646 __le16 *pos = (__le16 *) req->auth_data; in ieee80211_mgd_auth()
6648 auth_data->sae_trans = le16_to_cpu(pos[0]); in ieee80211_mgd_auth()
6649 auth_data->sae_status = le16_to_cpu(pos[1]); in ieee80211_mgd_auth()
6651 memcpy(auth_data->data, req->auth_data + 4, in ieee80211_mgd_auth()
6652 req->auth_data_len - 4); in ieee80211_mgd_auth()
6653 auth_data->data_len += req->auth_data_len - 4; in ieee80211_mgd_auth()
6658 * removal and re-addition of the STA entry in in ieee80211_mgd_auth()
6661 cont_auth = ifmgd->auth_data && req->bss == ifmgd->auth_data->bss; in ieee80211_mgd_auth()
6663 if (req->ie && req->ie_len) { in ieee80211_mgd_auth()
6664 memcpy(&auth_data->data[auth_data->data_len], in ieee80211_mgd_auth()
6665 req->ie, req->ie_len); in ieee80211_mgd_auth()
6666 auth_data->data_len += req->ie_len; in ieee80211_mgd_auth()
6669 if (req->key && req->key_len) { in ieee80211_mgd_auth()
6670 auth_data->key_len = req->key_len; in ieee80211_mgd_auth()
6671 auth_data->key_idx = req->key_idx; in ieee80211_mgd_auth()
6672 memcpy(auth_data->key, req->key, req->key_len); in ieee80211_mgd_auth()
6675 auth_data->algorithm = auth_alg; in ieee80211_mgd_auth()
6679 if (ifmgd->auth_data) { in ieee80211_mgd_auth()
6680 if (cont_auth && req->auth_type == NL80211_AUTHTYPE_SAE) { in ieee80211_mgd_auth()
6681 auth_data->peer_confirmed = in ieee80211_mgd_auth()
6682 ifmgd->auth_data->peer_confirmed; in ieee80211_mgd_auth()
6688 ifmgd->auth_data = auth_data; in ieee80211_mgd_auth()
6695 if (cont_auth && req->auth_type == NL80211_AUTHTYPE_SAE && in ieee80211_mgd_auth()
6696 auth_data->peer_confirmed && auth_data->sae_trans == 2) in ieee80211_mgd_auth()
6699 if (ifmgd->associated) { in ieee80211_mgd_auth()
6704 sdata->vif.cfg.ap_addr, auth_data->ap_addr); in ieee80211_mgd_auth()
6715 sdata_info(sdata, "authenticate with %pM\n", auth_data->ap_addr); in ieee80211_mgd_auth()
6718 memcpy(sdata->vif.cfg.ap_addr, auth_data->ap_addr, ETH_ALEN); in ieee80211_mgd_auth()
6720 err = ieee80211_prep_connection(sdata, req->bss, req->link_id, in ieee80211_mgd_auth()
6721 req->ap_mld_addr, cont_auth, false); in ieee80211_mgd_auth()
6727 sta_info_destroy_addr(sdata, auth_data->ap_addr); in ieee80211_mgd_auth()
6732 cfg80211_ref_bss(local->hw.wiphy, auth_data->bss); in ieee80211_mgd_auth()
6736 if (!sdata->vif.valid_links) { in ieee80211_mgd_auth()
6737 eth_zero_addr(sdata->deflink.u.mgd.bssid); in ieee80211_mgd_auth()
6738 ieee80211_link_info_change_notify(sdata, &sdata->deflink, in ieee80211_mgd_auth()
6740 mutex_lock(&sdata->local->mtx); in ieee80211_mgd_auth()
6741 ieee80211_link_release_channel(&sdata->deflink); in ieee80211_mgd_auth()
6742 mutex_unlock(&sdata->local->mtx); in ieee80211_mgd_auth()
6744 ifmgd->auth_data = NULL; in ieee80211_mgd_auth()
6756 struct ieee80211_local *local = sdata->local; in ieee80211_setup_assoc_link() local
6765 cbss = assoc_data->link[link_id].bss; in ieee80211_setup_assoc_link()
6769 bss = (void *)cbss->priv; in ieee80211_setup_assoc_link()
6771 sband = local->hw.wiphy->bands[cbss->channel->band]; in ieee80211_setup_assoc_link()
6775 link = sdata_dereference(sdata->link[link_id], sdata); in ieee80211_setup_assoc_link()
6779 is_5ghz = cbss->channel->band == NL80211_BAND_5GHZ; in ieee80211_setup_assoc_link()
6780 is_6ghz = cbss->channel->band == NL80211_BAND_6GHZ; in ieee80211_setup_assoc_link()
6783 if (!req->ap_mld_addr) { in ieee80211_setup_assoc_link()
6784 assoc_data->supp_rates = bss->supp_rates; in ieee80211_setup_assoc_link()
6785 assoc_data->supp_rates_len = bss->supp_rates_len; in ieee80211_setup_assoc_link()
6789 if (req->links[link_id].elems_len) { in ieee80211_setup_assoc_link()
6790 memcpy(assoc_data->ie_pos, req->links[link_id].elems, in ieee80211_setup_assoc_link()
6791 req->links[link_id].elems_len); in ieee80211_setup_assoc_link()
6792 assoc_data->link[link_id].elems = assoc_data->ie_pos; in ieee80211_setup_assoc_link()
6793 assoc_data->link[link_id].elems_len = req->links[link_id].elems_len; in ieee80211_setup_assoc_link()
6794 assoc_data->ie_pos += req->links[link_id].elems_len; in ieee80211_setup_assoc_link()
6799 if (ht_elem && ht_elem->datalen >= sizeof(struct ieee80211_ht_operation)) in ieee80211_setup_assoc_link()
6800 assoc_data->link[link_id].ap_ht_param = in ieee80211_setup_assoc_link()
6801 ((struct ieee80211_ht_operation *)(ht_elem->data))->ht_param; in ieee80211_setup_assoc_link()
6805 if (vht_elem && vht_elem->datalen >= sizeof(struct ieee80211_vht_cap)) { in ieee80211_setup_assoc_link()
6806 memcpy(&assoc_data->link[link_id].ap_vht_cap, vht_elem->data, in ieee80211_setup_assoc_link()
6817 link->u.mgd.beacon_crc_valid = false; in ieee80211_setup_assoc_link()
6818 link->u.mgd.dtim_period = 0; in ieee80211_setup_assoc_link()
6819 link->u.mgd.have_beacon = false; in ieee80211_setup_assoc_link()
6825 memcpy(&sta_ht_cap, &sband->ht_cap, sizeof(sta_ht_cap)); in ieee80211_setup_assoc_link()
6830 beacon_ies = rcu_dereference(cbss->beacon_ies); in ieee80211_setup_assoc_link()
6836 &link->u.mgd.dtim_period); in ieee80211_setup_assoc_link()
6838 sdata->deflink.u.mgd.have_beacon = true; in ieee80211_setup_assoc_link()
6840 if (ieee80211_hw_check(&local->hw, TIMING_BEACON_ONLY)) { in ieee80211_setup_assoc_link()
6841 link->conf->sync_tsf = beacon_ies->tsf; in ieee80211_setup_assoc_link()
6842 link->conf->sync_device_ts = bss->device_ts_beacon; in ieee80211_setup_assoc_link()
6843 link->conf->sync_dtim_count = dtim_count; in ieee80211_setup_assoc_link()
6847 beacon_ies->data, beacon_ies->len); in ieee80211_setup_assoc_link()
6848 if (elem && elem->datalen >= 3) in ieee80211_setup_assoc_link()
6849 link->conf->profile_periodicity = elem->data[2]; in ieee80211_setup_assoc_link()
6851 link->conf->profile_periodicity = 0; in ieee80211_setup_assoc_link()
6854 beacon_ies->data, beacon_ies->len); in ieee80211_setup_assoc_link()
6855 if (elem && elem->datalen >= 11 && in ieee80211_setup_assoc_link()
6856 (elem->data[10] & WLAN_EXT_CAPA11_EMA_SUPPORT)) in ieee80211_setup_assoc_link()
6857 link->conf->ema_ap = true; in ieee80211_setup_assoc_link()
6859 link->conf->ema_ap = false; in ieee80211_setup_assoc_link()
6863 if (bss->corrupt_data) { in ieee80211_setup_assoc_link()
6866 if (bss->corrupt_data & IEEE80211_BSS_CORRUPT_BEACON) { in ieee80211_setup_assoc_link()
6867 if (bss->corrupt_data & IEEE80211_BSS_CORRUPT_PROBE_RESP) in ieee80211_setup_assoc_link()
6871 } else if (bss->corrupt_data & IEEE80211_BSS_CORRUPT_PROBE_RESP) { in ieee80211_setup_assoc_link()
6875 cbss->bssid, corrupt_type); in ieee80211_setup_assoc_link()
6878 if (link->u.mgd.req_smps == IEEE80211_SMPS_AUTOMATIC) { in ieee80211_setup_assoc_link()
6879 if (sdata->u.mgd.powersave) in ieee80211_setup_assoc_link()
6880 link->smps_mode = IEEE80211_SMPS_DYNAMIC; in ieee80211_setup_assoc_link()
6882 link->smps_mode = IEEE80211_SMPS_OFF; in ieee80211_setup_assoc_link()
6884 link->smps_mode = link->u.mgd.req_smps; in ieee80211_setup_assoc_link()
6893 unsigned int assoc_link_id = req->link_id < 0 ? 0 : req->link_id; in ieee80211_mgd_assoc()
6894 struct ieee80211_local *local = sdata->local; in ieee80211_mgd_assoc() local
6895 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_mgd_assoc()
6898 struct ieee80211_vif_cfg *vif_cfg = &sdata->vif.cfg; in ieee80211_mgd_assoc()
6905 size_t size = sizeof(*assoc_data) + req->ie_len; in ieee80211_mgd_assoc() local
6908 size += req->links[i].elems_len; in ieee80211_mgd_assoc()
6910 /* FIXME: no support for 4-addr MLO yet */ in ieee80211_mgd_assoc()
6911 if (sdata->u.mgd.use_4addr && req->link_id >= 0) in ieee80211_mgd_assoc()
6912 return -EOPNOTSUPP; in ieee80211_mgd_assoc()
6914 assoc_data = kzalloc(size, GFP_KERNEL); in ieee80211_mgd_assoc()
6916 return -ENOMEM; in ieee80211_mgd_assoc()
6918 cbss = req->link_id < 0 ? req->bss : req->links[req->link_id].bss; in ieee80211_mgd_assoc()
6922 if (!ssid_elem || ssid_elem->datalen > sizeof(assoc_data->ssid)) { in ieee80211_mgd_assoc()
6925 return -EINVAL; in ieee80211_mgd_assoc()
6927 memcpy(assoc_data->ssid, ssid_elem->data, ssid_elem->datalen); in ieee80211_mgd_assoc()
6928 assoc_data->ssid_len = ssid_elem->datalen; in ieee80211_mgd_assoc()
6929 memcpy(vif_cfg->ssid, assoc_data->ssid, assoc_data->ssid_len); in ieee80211_mgd_assoc()
6930 vif_cfg->ssid_len = assoc_data->ssid_len; in ieee80211_mgd_assoc()
6933 if (req->ap_mld_addr) { in ieee80211_mgd_assoc()
6935 if (!req->links[i].bss) in ieee80211_mgd_assoc()
6937 link = sdata_dereference(sdata->link[i], sdata); in ieee80211_mgd_assoc()
6939 ether_addr_copy(assoc_data->link[i].addr, in ieee80211_mgd_assoc()
6940 link->conf->addr); in ieee80211_mgd_assoc()
6942 eth_random_addr(assoc_data->link[i].addr); in ieee80211_mgd_assoc()
6945 memcpy(assoc_data->link[0].addr, sdata->vif.addr, ETH_ALEN); in ieee80211_mgd_assoc()
6948 assoc_data->s1g = cbss->channel->band == NL80211_BAND_S1GHZ; in ieee80211_mgd_assoc()
6950 memcpy(assoc_data->ap_addr, in ieee80211_mgd_assoc()
6951 req->ap_mld_addr ?: req->bss->bssid, in ieee80211_mgd_assoc()
6954 if (ifmgd->associated) { in ieee80211_mgd_assoc()
6959 sdata->vif.cfg.ap_addr, assoc_data->ap_addr); in ieee80211_mgd_assoc()
6970 if (ifmgd->auth_data && !ifmgd->auth_data->done) { in ieee80211_mgd_assoc()
6971 err = -EBUSY; in ieee80211_mgd_assoc()
6975 if (ifmgd->assoc_data) { in ieee80211_mgd_assoc()
6976 err = -EBUSY; in ieee80211_mgd_assoc()
6980 if (ifmgd->auth_data) { in ieee80211_mgd_assoc()
6984 match = ether_addr_equal(ifmgd->auth_data->ap_addr, in ieee80211_mgd_assoc()
6985 assoc_data->ap_addr); in ieee80211_mgd_assoc()
6991 bss = (void *)cbss->priv; in ieee80211_mgd_assoc()
6992 assoc_data->wmm = bss->wmm_used && in ieee80211_mgd_assoc()
6993 (local->hw.queues >= IEEE80211_NUM_ACS); in ieee80211_mgd_assoc()
6997 * We still associate in non-HT mode (11a/b/g) if any one of these in ieee80211_mgd_assoc()
6999 * We can set this to true for non-11n hardware, that'll be checked in ieee80211_mgd_assoc()
7002 for (i = 0; i < req->crypto.n_ciphers_pairwise; i++) { in ieee80211_mgd_assoc()
7003 if (req->crypto.ciphers_pairwise[i] == WLAN_CIPHER_SUITE_WEP40 || in ieee80211_mgd_assoc()
7004 req->crypto.ciphers_pairwise[i] == WLAN_CIPHER_SUITE_TKIP || in ieee80211_mgd_assoc()
7005 req->crypto.ciphers_pairwise[i] == WLAN_CIPHER_SUITE_WEP104) { in ieee80211_mgd_assoc()
7010 netdev_info(sdata->dev, in ieee80211_mgd_assoc()
7016 if (!bss->wmm_used) { in ieee80211_mgd_assoc()
7021 netdev_info(sdata->dev, in ieee80211_mgd_assoc()
7025 if (req->flags & ASSOC_REQ_DISABLE_HT) { in ieee80211_mgd_assoc()
7033 if (req->flags & ASSOC_REQ_DISABLE_VHT) { in ieee80211_mgd_assoc()
7038 if (req->flags & ASSOC_REQ_DISABLE_HE) { in ieee80211_mgd_assoc()
7044 if (req->flags & ASSOC_REQ_DISABLE_EHT) in ieee80211_mgd_assoc()
7047 memcpy(&ifmgd->ht_capa, &req->ht_capa, sizeof(ifmgd->ht_capa)); in ieee80211_mgd_assoc()
7048 memcpy(&ifmgd->ht_capa_mask, &req->ht_capa_mask, in ieee80211_mgd_assoc()
7049 sizeof(ifmgd->ht_capa_mask)); in ieee80211_mgd_assoc()
7051 memcpy(&ifmgd->vht_capa, &req->vht_capa, sizeof(ifmgd->vht_capa)); in ieee80211_mgd_assoc()
7052 memcpy(&ifmgd->vht_capa_mask, &req->vht_capa_mask, in ieee80211_mgd_assoc()
7053 sizeof(ifmgd->vht_capa_mask)); in ieee80211_mgd_assoc()
7055 memcpy(&ifmgd->s1g_capa, &req->s1g_capa, sizeof(ifmgd->s1g_capa)); in ieee80211_mgd_assoc()
7056 memcpy(&ifmgd->s1g_capa_mask, &req->s1g_capa_mask, in ieee80211_mgd_assoc()
7057 sizeof(ifmgd->s1g_capa_mask)); in ieee80211_mgd_assoc()
7059 if (req->ie && req->ie_len) { in ieee80211_mgd_assoc()
7060 memcpy(assoc_data->ie, req->ie, req->ie_len); in ieee80211_mgd_assoc()
7061 assoc_data->ie_len = req->ie_len; in ieee80211_mgd_assoc()
7062 assoc_data->ie_pos = assoc_data->ie + assoc_data->ie_len; in ieee80211_mgd_assoc()
7064 assoc_data->ie_pos = assoc_data->ie; in ieee80211_mgd_assoc()
7067 if (req->fils_kek) { in ieee80211_mgd_assoc()
7068 /* should already be checked in cfg80211 - so warn */ in ieee80211_mgd_assoc()
7069 if (WARN_ON(req->fils_kek_len > FILS_MAX_KEK_LEN)) { in ieee80211_mgd_assoc()
7070 err = -EINVAL; in ieee80211_mgd_assoc()
7073 memcpy(assoc_data->fils_kek, req->fils_kek, in ieee80211_mgd_assoc()
7074 req->fils_kek_len); in ieee80211_mgd_assoc()
7075 assoc_data->fils_kek_len = req->fils_kek_len; in ieee80211_mgd_assoc()
7078 if (req->fils_nonces) in ieee80211_mgd_assoc()
7079 memcpy(assoc_data->fils_nonces, req->fils_nonces, in ieee80211_mgd_assoc()
7083 assoc_data->timeout = jiffies; in ieee80211_mgd_assoc()
7084 assoc_data->timeout_started = true; in ieee80211_mgd_assoc()
7086 assoc_data->assoc_link_id = assoc_link_id; in ieee80211_mgd_assoc()
7088 if (req->ap_mld_addr) { in ieee80211_mgd_assoc()
7089 for (i = 0; i < ARRAY_SIZE(assoc_data->link); i++) { in ieee80211_mgd_assoc()
7090 assoc_data->link[i].conn_flags = conn_flags; in ieee80211_mgd_assoc()
7091 assoc_data->link[i].bss = req->links[i].bss; in ieee80211_mgd_assoc()
7099 assoc_data->link[0].conn_flags = conn_flags; in ieee80211_mgd_assoc()
7100 assoc_data->link[0].bss = cbss; in ieee80211_mgd_assoc()
7103 link = sdata_dereference(sdata->link[assoc_link_id], sdata); in ieee80211_mgd_assoc()
7105 err = -EINVAL; in ieee80211_mgd_assoc()
7110 conn_flags |= link->u.mgd.conn_flags; in ieee80211_mgd_assoc()
7113 override = link->u.mgd.conn_flags != conn_flags; in ieee80211_mgd_assoc()
7114 link->u.mgd.conn_flags |= conn_flags; in ieee80211_mgd_assoc()
7116 if (WARN((sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_UAPSD) && in ieee80211_mgd_assoc()
7117 ieee80211_hw_check(&local->hw, PS_NULLFUNC_STACK), in ieee80211_mgd_assoc()
7118 "U-APSD not supported with HW_PS_NULLFUNC_STACK\n")) in ieee80211_mgd_assoc()
7119 sdata->vif.driver_flags &= ~IEEE80211_VIF_SUPPORTS_UAPSD; in ieee80211_mgd_assoc()
7121 if (bss->wmm_used && bss->uapsd_supported && in ieee80211_mgd_assoc()
7122 (sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_UAPSD)) { in ieee80211_mgd_assoc()
7123 assoc_data->uapsd = true; in ieee80211_mgd_assoc()
7124 ifmgd->flags |= IEEE80211_STA_UAPSD_ENABLED; in ieee80211_mgd_assoc()
7126 assoc_data->uapsd = false; in ieee80211_mgd_assoc()
7127 ifmgd->flags &= ~IEEE80211_STA_UAPSD_ENABLED; in ieee80211_mgd_assoc()
7130 if (req->prev_bssid) in ieee80211_mgd_assoc()
7131 memcpy(assoc_data->prev_ap_addr, req->prev_bssid, ETH_ALEN); in ieee80211_mgd_assoc()
7133 if (req->use_mfp) { in ieee80211_mgd_assoc()
7134 ifmgd->mfp = IEEE80211_MFP_REQUIRED; in ieee80211_mgd_assoc()
7135 ifmgd->flags |= IEEE80211_STA_MFP_ENABLED; in ieee80211_mgd_assoc()
7137 ifmgd->mfp = IEEE80211_MFP_DISABLED; in ieee80211_mgd_assoc()
7138 ifmgd->flags &= ~IEEE80211_STA_MFP_ENABLED; in ieee80211_mgd_assoc()
7141 if (req->flags & ASSOC_REQ_USE_RRM) in ieee80211_mgd_assoc()
7142 ifmgd->flags |= IEEE80211_STA_ENABLE_RRM; in ieee80211_mgd_assoc()
7144 ifmgd->flags &= ~IEEE80211_STA_ENABLE_RRM; in ieee80211_mgd_assoc()
7146 if (req->crypto.control_port) in ieee80211_mgd_assoc()
7147 ifmgd->flags |= IEEE80211_STA_CONTROL_PORT; in ieee80211_mgd_assoc()
7149 ifmgd->flags &= ~IEEE80211_STA_CONTROL_PORT; in ieee80211_mgd_assoc()
7151 sdata->control_port_protocol = req->crypto.control_port_ethertype; in ieee80211_mgd_assoc()
7152 sdata->control_port_no_encrypt = req->crypto.control_port_no_encrypt; in ieee80211_mgd_assoc()
7153 sdata->control_port_over_nl80211 = in ieee80211_mgd_assoc()
7154 req->crypto.control_port_over_nl80211; in ieee80211_mgd_assoc()
7155 sdata->control_port_no_preauth = req->crypto.control_port_no_preauth; in ieee80211_mgd_assoc()
7158 ifmgd->assoc_data = assoc_data; in ieee80211_mgd_assoc()
7160 for (i = 0; i < ARRAY_SIZE(assoc_data->link); i++) { in ieee80211_mgd_assoc()
7161 if (!assoc_data->link[i].bss) in ieee80211_mgd_assoc()
7163 if (i == assoc_data->assoc_link_id) in ieee80211_mgd_assoc()
7166 err = ieee80211_prep_channel(sdata, NULL, assoc_data->link[i].bss, in ieee80211_mgd_assoc()
7167 &assoc_data->link[i].conn_flags); in ieee80211_mgd_assoc()
7173 memcpy(sdata->vif.cfg.ap_addr, assoc_data->ap_addr, ETH_ALEN); in ieee80211_mgd_assoc()
7175 err = ieee80211_prep_connection(sdata, cbss, req->link_id, in ieee80211_mgd_assoc()
7176 req->ap_mld_addr, true, override); in ieee80211_mgd_assoc()
7180 assoc_data->link[assoc_data->assoc_link_id].conn_flags = in ieee80211_mgd_assoc()
7181 link->u.mgd.conn_flags; in ieee80211_mgd_assoc()
7183 if (ieee80211_hw_check(&sdata->local->hw, NEED_DTIM_BEFORE_ASSOC)) { in ieee80211_mgd_assoc()
7187 beacon_ies = rcu_dereference(req->bss->beacon_ies); in ieee80211_mgd_assoc()
7195 link->u.mgd.bssid); in ieee80211_mgd_assoc()
7196 assoc_data->timeout = TU_TO_EXP_TIME(req->bss->beacon_interval); in ieee80211_mgd_assoc()
7197 assoc_data->timeout_started = true; in ieee80211_mgd_assoc()
7198 assoc_data->need_beacon = true; in ieee80211_mgd_assoc()
7203 run_again(sdata, assoc_data->timeout); in ieee80211_mgd_assoc()
7207 eth_zero_addr(sdata->deflink.u.mgd.bssid); in ieee80211_mgd_assoc()
7208 ieee80211_link_info_change_notify(sdata, &sdata->deflink, in ieee80211_mgd_assoc()
7210 ifmgd->assoc_data = NULL; in ieee80211_mgd_assoc()
7219 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_mgd_deauth()
7221 bool tx = !req->local_state_change; in ieee80211_mgd_deauth()
7226 if (ifmgd->auth_data && in ieee80211_mgd_deauth()
7227 ether_addr_equal(ifmgd->auth_data->ap_addr, req->bssid)) { in ieee80211_mgd_deauth()
7229 "aborting authentication with %pM by local choice (Reason: %u=%s)\n", in ieee80211_mgd_deauth()
7230 req->bssid, req->reason_code, in ieee80211_mgd_deauth()
7231 ieee80211_get_reason_code_string(req->reason_code)); in ieee80211_mgd_deauth()
7233 drv_mgd_prepare_tx(sdata->local, sdata, &info); in ieee80211_mgd_deauth()
7234 ieee80211_send_deauth_disassoc(sdata, req->bssid, req->bssid, in ieee80211_mgd_deauth()
7236 req->reason_code, tx, in ieee80211_mgd_deauth()
7241 req->reason_code, false); in ieee80211_mgd_deauth()
7242 drv_mgd_complete_tx(sdata->local, sdata, &info); in ieee80211_mgd_deauth()
7246 if (ifmgd->assoc_data && in ieee80211_mgd_deauth()
7247 ether_addr_equal(ifmgd->assoc_data->ap_addr, req->bssid)) { in ieee80211_mgd_deauth()
7249 "aborting association with %pM by local choice (Reason: %u=%s)\n", in ieee80211_mgd_deauth()
7250 req->bssid, req->reason_code, in ieee80211_mgd_deauth()
7251 ieee80211_get_reason_code_string(req->reason_code)); in ieee80211_mgd_deauth()
7253 drv_mgd_prepare_tx(sdata->local, sdata, &info); in ieee80211_mgd_deauth()
7254 ieee80211_send_deauth_disassoc(sdata, req->bssid, req->bssid, in ieee80211_mgd_deauth()
7256 req->reason_code, tx, in ieee80211_mgd_deauth()
7261 req->reason_code, false); in ieee80211_mgd_deauth()
7265 if (ifmgd->associated && in ieee80211_mgd_deauth()
7266 ether_addr_equal(sdata->vif.cfg.ap_addr, req->bssid)) { in ieee80211_mgd_deauth()
7268 "deauthenticating from %pM by local choice (Reason: %u=%s)\n", in ieee80211_mgd_deauth()
7269 req->bssid, req->reason_code, in ieee80211_mgd_deauth()
7270 ieee80211_get_reason_code_string(req->reason_code)); in ieee80211_mgd_deauth()
7273 req->reason_code, tx, frame_buf); in ieee80211_mgd_deauth()
7276 req->reason_code, false); in ieee80211_mgd_deauth()
7277 drv_mgd_complete_tx(sdata->local, sdata, &info); in ieee80211_mgd_deauth()
7281 return -ENOTCONN; in ieee80211_mgd_deauth()
7289 if (!sdata->u.mgd.associated || in ieee80211_mgd_disassoc()
7290 memcmp(sdata->vif.cfg.ap_addr, req->ap_addr, ETH_ALEN)) in ieee80211_mgd_disassoc()
7291 return -ENOTCONN; in ieee80211_mgd_disassoc()
7294 "disassociating from %pM by local choice (Reason: %u=%s)\n", in ieee80211_mgd_disassoc()
7295 req->ap_addr, req->reason_code, in ieee80211_mgd_disassoc()
7296 ieee80211_get_reason_code_string(req->reason_code)); in ieee80211_mgd_disassoc()
7299 req->reason_code, !req->local_state_change, in ieee80211_mgd_disassoc()
7303 req->reason_code, false); in ieee80211_mgd_disassoc()
7310 cancel_work_sync(&link->u.mgd.request_smps_work); in ieee80211_mgd_stop_link()
7311 cancel_work_sync(&link->u.mgd.chswitch_work); in ieee80211_mgd_stop_link()
7316 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_mgd_stop()
7323 cancel_work_sync(&ifmgd->monitor_work); in ieee80211_mgd_stop()
7324 cancel_work_sync(&ifmgd->beacon_connection_loss_work); in ieee80211_mgd_stop()
7325 cancel_work_sync(&ifmgd->csa_connection_drop_work); in ieee80211_mgd_stop()
7326 cancel_delayed_work_sync(&ifmgd->tdls_peer_del_work); in ieee80211_mgd_stop()
7329 if (ifmgd->assoc_data) in ieee80211_mgd_stop()
7331 if (ifmgd->auth_data) in ieee80211_mgd_stop()
7333 spin_lock_bh(&ifmgd->teardown_lock); in ieee80211_mgd_stop()
7334 if (ifmgd->teardown_skb) { in ieee80211_mgd_stop()
7335 kfree_skb(ifmgd->teardown_skb); in ieee80211_mgd_stop()
7336 ifmgd->teardown_skb = NULL; in ieee80211_mgd_stop()
7337 ifmgd->orig_teardown_skb = NULL; in ieee80211_mgd_stop()
7339 kfree(ifmgd->assoc_req_ies); in ieee80211_mgd_stop()
7340 ifmgd->assoc_req_ies = NULL; in ieee80211_mgd_stop()
7341 ifmgd->assoc_req_ies_len = 0; in ieee80211_mgd_stop()
7342 spin_unlock_bh(&ifmgd->teardown_lock); in ieee80211_mgd_stop()
7343 del_timer_sync(&ifmgd->timer); in ieee80211_mgd_stop()
7356 cfg80211_cqm_rssi_notify(sdata->dev, rssi_event, rssi_level, gfp); in ieee80211_cqm_rssi_notify()
7364 trace_api_cqm_beacon_loss_notify(sdata->local, sdata); in ieee80211_cqm_beacon_loss_notify()
7366 cfg80211_cqm_beacon_loss_notify(sdata->dev, gfp); in ieee80211_cqm_beacon_loss_notify()
7376 if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_STATION)) in _ieee80211_enable_rssi_reports()
7384 sdata->u.mgd.rssi_min_thold = rssi_min_thold*16; in _ieee80211_enable_rssi_reports()
7385 sdata->u.mgd.rssi_max_thold = rssi_max_thold*16; in _ieee80211_enable_rssi_reports()