^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * BSS client mode implementation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Copyright 2003-2008, Jouni Malinen <j@w1.fi>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright 2004, Instant802 Networks, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Copyright 2005, Devicescape Software, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * Copyright 2007, Michael Wu <flamingice@sourmilk.net>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * Copyright 2013-2014 Intel Mobile Communications GmbH
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * Copyright (C) 2015 - 2017 Intel Deutschland GmbH
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * Copyright (C) 2018 - 2020 Intel Corporation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/delay.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/fips.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/if_ether.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/skbuff.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <linux/if_arp.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <linux/etherdevice.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <linux/moduleparam.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <linux/rtnetlink.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <linux/crc32.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include <linux/export.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #include <net/mac80211.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #include <asm/unaligned.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #include "ieee80211_i.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #include "driver-ops.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #include "rate.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #include "led.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #include "fils_aead.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #define IEEE80211_AUTH_TIMEOUT (HZ / 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #define IEEE80211_AUTH_TIMEOUT_LONG (HZ / 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) #define IEEE80211_AUTH_TIMEOUT_SHORT (HZ / 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #define IEEE80211_AUTH_TIMEOUT_SAE (HZ * 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #define IEEE80211_AUTH_MAX_TRIES 3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) #define IEEE80211_AUTH_WAIT_ASSOC (HZ * 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) #define IEEE80211_AUTH_WAIT_SAE_RETRY (HZ * 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) #define IEEE80211_ASSOC_TIMEOUT (HZ / 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) #define IEEE80211_ASSOC_TIMEOUT_LONG (HZ / 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) #define IEEE80211_ASSOC_TIMEOUT_SHORT (HZ / 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) #define IEEE80211_ASSOC_MAX_TRIES 3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) static int max_nullfunc_tries = 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) module_param(max_nullfunc_tries, int, 0644);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) MODULE_PARM_DESC(max_nullfunc_tries,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) "Maximum nullfunc tx tries before disconnecting (reason 4).");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) static int max_probe_tries = 5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) module_param(max_probe_tries, int, 0644);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) MODULE_PARM_DESC(max_probe_tries,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) "Maximum probe tries before disconnecting (reason 4).");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) * Beacon loss timeout is calculated as N frames times the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) * advertised beacon interval. This may need to be somewhat
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) * higher than what hardware might detect to account for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) * delays in the host processing frames. But since we also
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) * probe on beacon miss before declaring the connection lost
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) * default to what we want.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) static int beacon_loss_count = 7;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) module_param(beacon_loss_count, int, 0644);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) MODULE_PARM_DESC(beacon_loss_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) "Number of beacon intervals before we decide beacon was lost.");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) * Time the connection can be idle before we probe
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) * it to see if we can still talk to the AP.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) #define IEEE80211_CONNECTION_IDLE_TIME (30 * HZ)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) * Time we wait for a probe response after sending
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) * a probe request because of beacon loss or for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) * checking the connection still works.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) static int probe_wait_ms = 500;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) module_param(probe_wait_ms, int, 0644);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) MODULE_PARM_DESC(probe_wait_ms,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) "Maximum time(ms) to wait for probe response"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) " before disconnecting (reason 4).");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) * How many Beacon frames need to have been used in average signal strength
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) * before starting to indicate signal change events.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) #define IEEE80211_SIGNAL_AVE_MIN_COUNT 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) * We can have multiple work items (and connection probing)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) * scheduling this timer, but we need to take care to only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) * reschedule it when it should fire _earlier_ than it was
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) * asked for before, or if it's not pending right now. This
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) * function ensures that. Note that it then is required to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) * run this function for all timeouts after the first one
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) * has happened -- the work that runs from this timer will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) * do that.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) static void run_again(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) unsigned long timeout)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) sdata_assert_lock(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) if (!timer_pending(&sdata->u.mgd.timer) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) time_before(timeout, sdata->u.mgd.timer.expires))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) mod_timer(&sdata->u.mgd.timer, timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) void ieee80211_sta_reset_beacon_monitor(struct ieee80211_sub_if_data *sdata)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) if (sdata->vif.driver_flags & IEEE80211_VIF_BEACON_FILTER)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) if (ieee80211_hw_check(&sdata->local->hw, CONNECTION_MONITOR))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) mod_timer(&sdata->u.mgd.bcn_mon_timer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) round_jiffies_up(jiffies + sdata->u.mgd.beacon_timeout));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) void ieee80211_sta_reset_conn_monitor(struct ieee80211_sub_if_data *sdata)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) if (unlikely(!ifmgd->associated))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) if (ifmgd->probe_send_count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) ifmgd->probe_send_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) if (ieee80211_hw_check(&sdata->local->hw, CONNECTION_MONITOR))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) mod_timer(&ifmgd->conn_mon_timer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) round_jiffies_up(jiffies + IEEE80211_CONNECTION_IDLE_TIME));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) static int ecw2cw(int ecw)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) return (1 << ecw) - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) static u32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) ieee80211_determine_chantype(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) struct ieee80211_supported_band *sband,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) struct ieee80211_channel *channel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) u32 vht_cap_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) const struct ieee80211_ht_operation *ht_oper,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) const struct ieee80211_vht_operation *vht_oper,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) const struct ieee80211_he_operation *he_oper,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) const struct ieee80211_s1g_oper_ie *s1g_oper,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) struct cfg80211_chan_def *chandef, bool tracking)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) struct cfg80211_chan_def vht_chandef;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) struct ieee80211_sta_ht_cap sta_ht_cap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) u32 ht_cfreq, ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) memset(chandef, 0, sizeof(struct cfg80211_chan_def));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) chandef->chan = channel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) chandef->width = NL80211_CHAN_WIDTH_20_NOHT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) chandef->center_freq1 = channel->center_freq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) chandef->freq1_offset = channel->freq_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) if (channel->band == NL80211_BAND_6GHZ) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) if (!ieee80211_chandef_he_6ghz_oper(sdata, he_oper, chandef))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) ret = IEEE80211_STA_DISABLE_HT |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) IEEE80211_STA_DISABLE_VHT |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) IEEE80211_STA_DISABLE_HE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) vht_chandef = *chandef;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) } else if (sband->band == NL80211_BAND_S1GHZ) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) if (!ieee80211_chandef_s1g_oper(s1g_oper, chandef)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) sdata_info(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) "Missing S1G Operation Element? Trying operating == primary\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) chandef->width = ieee80211_s1g_channel_width(channel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) ret = IEEE80211_STA_DISABLE_HT | IEEE80211_STA_DISABLE_40MHZ |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) IEEE80211_STA_DISABLE_VHT |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) IEEE80211_STA_DISABLE_80P80MHZ |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) IEEE80211_STA_DISABLE_160MHZ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) memcpy(&sta_ht_cap, &sband->ht_cap, sizeof(sta_ht_cap));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) ieee80211_apply_htcap_overrides(sdata, &sta_ht_cap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) if (!ht_oper || !sta_ht_cap.ht_supported) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) ret = IEEE80211_STA_DISABLE_HT |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) IEEE80211_STA_DISABLE_VHT |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) IEEE80211_STA_DISABLE_HE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) chandef->width = NL80211_CHAN_WIDTH_20;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) ht_cfreq = ieee80211_channel_to_frequency(ht_oper->primary_chan,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) channel->band);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) /* check that channel matches the right operating channel */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) if (!tracking && channel->center_freq != ht_cfreq) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) * It's possible that some APs are confused here;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) * Netgear WNDR3700 sometimes reports 4 higher than
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) * the actual channel in association responses, but
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) * since we look at probe response/beacon data here
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) * it should be OK.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) sdata_info(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) "Wrong control channel: center-freq: %d ht-cfreq: %d ht->primary_chan: %d band: %d - Disabling HT\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) channel->center_freq, ht_cfreq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) ht_oper->primary_chan, channel->band);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) ret = IEEE80211_STA_DISABLE_HT |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) IEEE80211_STA_DISABLE_VHT |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) IEEE80211_STA_DISABLE_HE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) /* check 40 MHz support, if we have it */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) if (sta_ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) ieee80211_chandef_ht_oper(ht_oper, chandef);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) /* 40 MHz (and 80 MHz) must be supported for VHT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) ret = IEEE80211_STA_DISABLE_VHT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) /* also mark 40 MHz disabled */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) ret |= IEEE80211_STA_DISABLE_40MHZ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) if (!vht_oper || !sband->vht_cap.vht_supported) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) ret = IEEE80211_STA_DISABLE_VHT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) vht_chandef = *chandef;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) if (!(ifmgd->flags & IEEE80211_STA_DISABLE_HE) && he_oper &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) (le32_to_cpu(he_oper->he_oper_params) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) IEEE80211_HE_OPERATION_VHT_OPER_INFO)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) struct ieee80211_vht_operation he_oper_vht_cap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) * Set only first 3 bytes (other 2 aren't used in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) * ieee80211_chandef_vht_oper() anyway)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) memcpy(&he_oper_vht_cap, he_oper->optional, 3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) he_oper_vht_cap.basic_mcs_set = cpu_to_le16(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) if (!ieee80211_chandef_vht_oper(&sdata->local->hw, vht_cap_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) &he_oper_vht_cap, ht_oper,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) &vht_chandef)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) if (!(ifmgd->flags & IEEE80211_STA_DISABLE_HE))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) sdata_info(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) "HE AP VHT information is invalid, disable HE\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) ret = IEEE80211_STA_DISABLE_HE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) } else if (!ieee80211_chandef_vht_oper(&sdata->local->hw,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) vht_cap_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) vht_oper, ht_oper,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) &vht_chandef)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) if (!(ifmgd->flags & IEEE80211_STA_DISABLE_VHT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) sdata_info(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) "AP VHT information is invalid, disable VHT\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) ret = IEEE80211_STA_DISABLE_VHT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) if (!cfg80211_chandef_valid(&vht_chandef)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) if (!(ifmgd->flags & IEEE80211_STA_DISABLE_VHT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) sdata_info(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) "AP VHT information is invalid, disable VHT\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) ret = IEEE80211_STA_DISABLE_VHT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) if (cfg80211_chandef_identical(chandef, &vht_chandef)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) if (!cfg80211_chandef_compatible(chandef, &vht_chandef)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) if (!(ifmgd->flags & IEEE80211_STA_DISABLE_VHT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) sdata_info(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) "AP VHT information doesn't match HT, disable VHT\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) ret = IEEE80211_STA_DISABLE_VHT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) *chandef = vht_chandef;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) * When tracking the current AP, don't do any further checks if the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) * new chandef is identical to the one we're currently using for the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) * connection. This keeps us from playing ping-pong with regulatory,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) * without it the following can happen (for example):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) * - connect to an AP with 80 MHz, world regdom allows 80 MHz
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) * - AP advertises regdom US
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) * - CRDA loads regdom US with 80 MHz prohibited (old database)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) * - the code below detects an unsupported channel, downgrades, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) * we disconnect from the AP in the caller
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) * - disconnect causes CRDA to reload world regdomain and the game
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) * starts anew.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) * (see https://bugzilla.kernel.org/show_bug.cgi?id=70881)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) * It seems possible that there are still scenarios with CSA or real
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) * bandwidth changes where a this could happen, but those cases are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) * less common and wouldn't completely prevent using the AP.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) if (tracking &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) cfg80211_chandef_identical(chandef, &sdata->vif.bss_conf.chandef))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) /* don't print the message below for VHT mismatch if VHT is disabled */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) if (ret & IEEE80211_STA_DISABLE_VHT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) vht_chandef = *chandef;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) * Ignore the DISABLED flag when we're already connected and only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) * tracking the APs beacon for bandwidth changes - otherwise we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) * might get disconnected here if we connect to an AP, update our
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) * regulatory information based on the AP's country IE and the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) * information we have is wrong/outdated and disables the channel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) * that we're actually using for the connection to the AP.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) while (!cfg80211_chandef_usable(sdata->local->hw.wiphy, chandef,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) tracking ? 0 :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) IEEE80211_CHAN_DISABLED)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) if (WARN_ON(chandef->width == NL80211_CHAN_WIDTH_20_NOHT)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) ret = IEEE80211_STA_DISABLE_HT |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) IEEE80211_STA_DISABLE_VHT |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) IEEE80211_STA_DISABLE_HE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) ret |= ieee80211_chandef_downgrade(chandef);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) if (!he_oper || !cfg80211_chandef_usable(sdata->wdev.wiphy, chandef,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) IEEE80211_CHAN_NO_HE))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) ret |= IEEE80211_STA_DISABLE_HE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) if (chandef->width != vht_chandef.width && !tracking)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) sdata_info(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) "capabilities/regulatory prevented using AP HT/VHT configuration, downgraded\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) WARN_ON_ONCE(!cfg80211_chandef_valid(chandef));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) static int ieee80211_config_bw(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) struct sta_info *sta,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) const struct ieee80211_ht_cap *ht_cap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) const struct ieee80211_vht_cap *vht_cap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) const struct ieee80211_ht_operation *ht_oper,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) const struct ieee80211_vht_operation *vht_oper,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) const struct ieee80211_he_operation *he_oper,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) const struct ieee80211_s1g_oper_ie *s1g_oper,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) const u8 *bssid, u32 *changed)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) struct ieee80211_local *local = sdata->local;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) struct ieee80211_channel *chan = sdata->vif.bss_conf.chandef.chan;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) struct ieee80211_supported_band *sband =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) local->hw.wiphy->bands[chan->band];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) struct cfg80211_chan_def chandef;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) u16 ht_opmode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) u32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) enum ieee80211_sta_rx_bandwidth new_sta_bw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) u32 vht_cap_info = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) /* if HT was/is disabled, don't track any bandwidth changes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) if (ifmgd->flags & IEEE80211_STA_DISABLE_HT || !ht_oper)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) /* don't check VHT if we associated as non-VHT station */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) if (ifmgd->flags & IEEE80211_STA_DISABLE_VHT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) vht_oper = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) /* don't check HE if we associated as non-HE station */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) if (ifmgd->flags & IEEE80211_STA_DISABLE_HE ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) !ieee80211_get_he_sta_cap(sband))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) he_oper = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) if (WARN_ON_ONCE(!sta))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) * if bss configuration changed store the new one -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) * this may be applicable even if channel is identical
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) ht_opmode = le16_to_cpu(ht_oper->operation_mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) if (sdata->vif.bss_conf.ht_operation_mode != ht_opmode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) *changed |= BSS_CHANGED_HT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) sdata->vif.bss_conf.ht_operation_mode = ht_opmode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) if (vht_cap)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) vht_cap_info = le32_to_cpu(vht_cap->vht_cap_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) /* calculate new channel (type) based on HT/VHT/HE operation IEs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) flags = ieee80211_determine_chantype(sdata, sband, chan, vht_cap_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) ht_oper, vht_oper, he_oper,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) s1g_oper, &chandef, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) * Downgrade the new channel if we associated with restricted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) * capabilities. For example, if we associated as a 20 MHz STA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) * to a 40 MHz AP (due to regulatory, capabilities or config
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) * reasons) then switching to a 40 MHz channel now won't do us
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) * any good -- we couldn't use it with the AP.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) if (ifmgd->flags & IEEE80211_STA_DISABLE_80P80MHZ &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) chandef.width == NL80211_CHAN_WIDTH_80P80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) flags |= ieee80211_chandef_downgrade(&chandef);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) if (ifmgd->flags & IEEE80211_STA_DISABLE_160MHZ &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) chandef.width == NL80211_CHAN_WIDTH_160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) flags |= ieee80211_chandef_downgrade(&chandef);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) if (ifmgd->flags & IEEE80211_STA_DISABLE_40MHZ &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) chandef.width > NL80211_CHAN_WIDTH_20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) flags |= ieee80211_chandef_downgrade(&chandef);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) if (cfg80211_chandef_identical(&chandef, &sdata->vif.bss_conf.chandef))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) sdata_info(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) "AP %pM changed bandwidth, new config is %d.%03d MHz, "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) "width %d (%d.%03d/%d MHz)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) ifmgd->bssid, chandef.chan->center_freq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) chandef.chan->freq_offset, chandef.width,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) chandef.center_freq1, chandef.freq1_offset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) chandef.center_freq2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) if (flags != (ifmgd->flags & (IEEE80211_STA_DISABLE_HT |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) IEEE80211_STA_DISABLE_VHT |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) IEEE80211_STA_DISABLE_HE |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) IEEE80211_STA_DISABLE_40MHZ |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) IEEE80211_STA_DISABLE_80P80MHZ |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) IEEE80211_STA_DISABLE_160MHZ)) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) !cfg80211_chandef_valid(&chandef)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) sdata_info(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) "AP %pM changed bandwidth in a way we can't support - disconnect\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) ifmgd->bssid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) switch (chandef.width) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) case NL80211_CHAN_WIDTH_20_NOHT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) case NL80211_CHAN_WIDTH_20:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) new_sta_bw = IEEE80211_STA_RX_BW_20;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) case NL80211_CHAN_WIDTH_40:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) new_sta_bw = IEEE80211_STA_RX_BW_40;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) case NL80211_CHAN_WIDTH_80:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) new_sta_bw = IEEE80211_STA_RX_BW_80;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) case NL80211_CHAN_WIDTH_80P80:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) case NL80211_CHAN_WIDTH_160:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) new_sta_bw = IEEE80211_STA_RX_BW_160;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) if (new_sta_bw > sta->cur_max_bandwidth)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) new_sta_bw = sta->cur_max_bandwidth;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) if (new_sta_bw < sta->sta.bandwidth) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) sta->sta.bandwidth = new_sta_bw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) rate_control_rate_update(local, sband, sta,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) IEEE80211_RC_BW_CHANGED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) ret = ieee80211_vif_change_bandwidth(sdata, &chandef, changed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) sdata_info(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) "AP %pM changed bandwidth to incompatible one - disconnect\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) ifmgd->bssid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) if (new_sta_bw > sta->sta.bandwidth) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) sta->sta.bandwidth = new_sta_bw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) rate_control_rate_update(local, sband, sta,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) IEEE80211_RC_BW_CHANGED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) /* frame sending functions */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) static void ieee80211_add_ht_ie(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) struct sk_buff *skb, u8 ap_ht_param,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) struct ieee80211_supported_band *sband,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) struct ieee80211_channel *channel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) enum ieee80211_smps_mode smps)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) u8 *pos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) u32 flags = channel->flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) u16 cap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) struct ieee80211_sta_ht_cap ht_cap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) BUILD_BUG_ON(sizeof(ht_cap) != sizeof(sband->ht_cap));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) memcpy(&ht_cap, &sband->ht_cap, sizeof(ht_cap));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) ieee80211_apply_htcap_overrides(sdata, &ht_cap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) /* determine capability flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) cap = ht_cap.cap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) switch (ap_ht_param & IEEE80211_HT_PARAM_CHA_SEC_OFFSET) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) case IEEE80211_HT_PARAM_CHA_SEC_ABOVE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) if (flags & IEEE80211_CHAN_NO_HT40PLUS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) cap &= ~IEEE80211_HT_CAP_SGI_40;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) case IEEE80211_HT_PARAM_CHA_SEC_BELOW:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) if (flags & IEEE80211_CHAN_NO_HT40MINUS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) cap &= ~IEEE80211_HT_CAP_SGI_40;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) * If 40 MHz was disabled associate as though we weren't
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) * capable of 40 MHz -- some broken APs will never fall
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) * back to trying to transmit in 20 MHz.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) if (sdata->u.mgd.flags & IEEE80211_STA_DISABLE_40MHZ) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) cap &= ~IEEE80211_HT_CAP_SGI_40;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) /* set SM PS mode properly */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) cap &= ~IEEE80211_HT_CAP_SM_PS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) switch (smps) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) case IEEE80211_SMPS_AUTOMATIC:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) case IEEE80211_SMPS_NUM_MODES:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) WARN_ON(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) case IEEE80211_SMPS_OFF:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) cap |= WLAN_HT_CAP_SM_PS_DISABLED <<
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) IEEE80211_HT_CAP_SM_PS_SHIFT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) case IEEE80211_SMPS_STATIC:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) cap |= WLAN_HT_CAP_SM_PS_STATIC <<
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) IEEE80211_HT_CAP_SM_PS_SHIFT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) case IEEE80211_SMPS_DYNAMIC:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) cap |= WLAN_HT_CAP_SM_PS_DYNAMIC <<
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) IEEE80211_HT_CAP_SM_PS_SHIFT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) /* reserve and fill IE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) pos = skb_put(skb, sizeof(struct ieee80211_ht_cap) + 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) ieee80211_ie_build_ht_cap(pos, &ht_cap, cap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) /* This function determines vht capability flags for the association
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) * and builds the IE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) * Note - the function may set the owner of the MU-MIMO capability
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) static void ieee80211_add_vht_ie(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) struct ieee80211_supported_band *sband,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) struct ieee80211_vht_cap *ap_vht_cap)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) struct ieee80211_local *local = sdata->local;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) u8 *pos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) u32 cap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) struct ieee80211_sta_vht_cap vht_cap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) u32 mask, ap_bf_sts, our_bf_sts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) BUILD_BUG_ON(sizeof(vht_cap) != sizeof(sband->vht_cap));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) memcpy(&vht_cap, &sband->vht_cap, sizeof(vht_cap));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) ieee80211_apply_vhtcap_overrides(sdata, &vht_cap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) /* determine capability flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) cap = vht_cap.cap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) if (sdata->u.mgd.flags & IEEE80211_STA_DISABLE_80P80MHZ) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) u32 bw = cap & IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) cap &= ~IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) if (bw == IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) bw == IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) cap |= IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) if (sdata->u.mgd.flags & IEEE80211_STA_DISABLE_160MHZ) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) cap &= ~IEEE80211_VHT_CAP_SHORT_GI_160;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) cap &= ~IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) * Some APs apparently get confused if our capabilities are better
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) * than theirs, so restrict what we advertise in the assoc request.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) if (!(ap_vht_cap->vht_cap_info &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) cpu_to_le32(IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) cap &= ~(IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) else if (!(ap_vht_cap->vht_cap_info &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) cpu_to_le32(IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) cap &= ~IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) * If some other vif is using the MU-MIMO capablity we cannot associate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) * using MU-MIMO - this will lead to contradictions in the group-id
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) * mechanism.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) * Ownership is defined since association request, in order to avoid
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) * simultaneous associations with MU-MIMO.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) if (cap & IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) bool disable_mu_mimo = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) struct ieee80211_sub_if_data *other;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) list_for_each_entry_rcu(other, &local->interfaces, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) if (other->vif.mu_mimo_owner) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) disable_mu_mimo = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) if (disable_mu_mimo)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) cap &= ~IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) sdata->vif.mu_mimo_owner = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) mask = IEEE80211_VHT_CAP_BEAMFORMEE_STS_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) ap_bf_sts = le32_to_cpu(ap_vht_cap->vht_cap_info) & mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) our_bf_sts = cap & mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) if (ap_bf_sts < our_bf_sts) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) cap &= ~mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) cap |= ap_bf_sts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) /* reserve and fill IE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) pos = skb_put(skb, sizeof(struct ieee80211_vht_cap) + 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) ieee80211_ie_build_vht_cap(pos, &vht_cap, cap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) /* This function determines HE capability flags for the association
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) * and builds the IE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) static void ieee80211_add_he_ie(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) struct ieee80211_supported_band *sband)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) u8 *pos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) const struct ieee80211_sta_he_cap *he_cap = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) struct ieee80211_chanctx_conf *chanctx_conf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) u8 he_cap_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) bool reg_cap = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) rcu_read_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) if (!WARN_ON_ONCE(!chanctx_conf))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) reg_cap = cfg80211_chandef_usable(sdata->wdev.wiphy,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) &chanctx_conf->def,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) IEEE80211_CHAN_NO_HE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) he_cap = ieee80211_get_he_sta_cap(sband);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) if (!he_cap || !reg_cap)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) * TODO: the 1 added is because this temporarily is under the EXTENSION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) * IE. Get rid of it when it moves.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) he_cap_size =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) 2 + 1 + sizeof(he_cap->he_cap_elem) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) ieee80211_he_mcs_nss_size(&he_cap->he_cap_elem) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) ieee80211_he_ppe_size(he_cap->ppe_thres[0],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) he_cap->he_cap_elem.phy_cap_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) pos = skb_put(skb, he_cap_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) ieee80211_ie_build_he_cap(pos, he_cap, pos + he_cap_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) ieee80211_ie_build_he_6ghz_cap(sdata, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) struct ieee80211_local *local = sdata->local;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) struct ieee80211_mgd_assoc_data *assoc_data = ifmgd->assoc_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) struct sk_buff *skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) struct ieee80211_mgmt *mgmt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) u8 *pos, qos_info, *ie_start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) size_t offset = 0, noffset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) int i, count, rates_len, supp_rates_len, shift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) u16 capab;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) struct ieee80211_supported_band *sband;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) struct ieee80211_chanctx_conf *chanctx_conf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) struct ieee80211_channel *chan;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) u32 rates = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) __le16 listen_int;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) struct element *ext_capa = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) /* we know it's writable, cast away the const */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) if (assoc_data->ie_len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) ext_capa = (void *)cfg80211_find_elem(WLAN_EID_EXT_CAPABILITY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) assoc_data->ie,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) assoc_data->ie_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) sdata_assert_lock(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) rcu_read_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) if (WARN_ON(!chanctx_conf)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) chan = chanctx_conf->def.chan;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) sband = local->hw.wiphy->bands[chan->band];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) shift = ieee80211_vif_get_shift(&sdata->vif);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) if (assoc_data->supp_rates_len) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) * Get all rates supported by the device and the AP as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) * some APs don't like getting a superset of their rates
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) * in the association request (e.g. D-Link DAP 1353 in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) * b-only mode)...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) rates_len = ieee80211_parse_bitrates(&chanctx_conf->def, sband,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) assoc_data->supp_rates,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) assoc_data->supp_rates_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) &rates);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) * In case AP not provide any supported rates information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) * before association, we send information element(s) with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) * all rates that we support.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) rates_len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) for (i = 0; i < sband->n_bitrates; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) rates |= BIT(i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) rates_len++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) skb = alloc_skb(local->hw.extra_tx_headroom +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) sizeof(*mgmt) + /* bit too much but doesn't matter */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) 2 + assoc_data->ssid_len + /* SSID */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) 4 + rates_len + /* (extended) rates */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) 4 + /* power capability */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) 2 + 2 * sband->n_channels + /* supported channels */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) 2 + sizeof(struct ieee80211_ht_cap) + /* HT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) 2 + sizeof(struct ieee80211_vht_cap) + /* VHT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) 2 + 1 + sizeof(struct ieee80211_he_cap_elem) + /* HE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) sizeof(struct ieee80211_he_mcs_nss_supp) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) IEEE80211_HE_PPE_THRES_MAX_LEN +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) 2 + 1 + sizeof(struct ieee80211_he_6ghz_capa) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) assoc_data->ie_len + /* extra IEs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) (assoc_data->fils_kek_len ? 16 /* AES-SIV */ : 0) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) 9, /* WMM */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) if (!skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) skb_reserve(skb, local->hw.extra_tx_headroom);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) capab = WLAN_CAPABILITY_ESS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) if (sband->band == NL80211_BAND_2GHZ) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) capab |= WLAN_CAPABILITY_SHORT_SLOT_TIME;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) capab |= WLAN_CAPABILITY_SHORT_PREAMBLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) if (assoc_data->capability & WLAN_CAPABILITY_PRIVACY)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) capab |= WLAN_CAPABILITY_PRIVACY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) if ((assoc_data->capability & WLAN_CAPABILITY_SPECTRUM_MGMT) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) ieee80211_hw_check(&local->hw, SPECTRUM_MGMT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) capab |= WLAN_CAPABILITY_SPECTRUM_MGMT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) if (ifmgd->flags & IEEE80211_STA_ENABLE_RRM)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) capab |= WLAN_CAPABILITY_RADIO_MEASURE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) mgmt = skb_put_zero(skb, 24);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) memcpy(mgmt->da, assoc_data->bss->bssid, ETH_ALEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) memcpy(mgmt->bssid, assoc_data->bss->bssid, ETH_ALEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) listen_int = cpu_to_le16(sband->band == NL80211_BAND_S1GHZ ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) ieee80211_encode_usf(local->hw.conf.listen_interval) :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805) local->hw.conf.listen_interval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) if (!is_zero_ether_addr(assoc_data->prev_bssid)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807) skb_put(skb, 10);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) IEEE80211_STYPE_REASSOC_REQ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) mgmt->u.reassoc_req.capab_info = cpu_to_le16(capab);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) mgmt->u.reassoc_req.listen_interval = listen_int;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) memcpy(mgmt->u.reassoc_req.current_ap, assoc_data->prev_bssid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) ETH_ALEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815) skb_put(skb, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) IEEE80211_STYPE_ASSOC_REQ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818) mgmt->u.assoc_req.capab_info = cpu_to_le16(capab);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819) mgmt->u.assoc_req.listen_interval = listen_int;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822) /* SSID */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823) pos = skb_put(skb, 2 + assoc_data->ssid_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824) ie_start = pos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825) *pos++ = WLAN_EID_SSID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826) *pos++ = assoc_data->ssid_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) memcpy(pos, assoc_data->ssid, assoc_data->ssid_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829) if (sband->band == NL80211_BAND_S1GHZ)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) goto skip_rates;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832) /* add all rates which were marked to be used above */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) supp_rates_len = rates_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) if (supp_rates_len > 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835) supp_rates_len = 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837) pos = skb_put(skb, supp_rates_len + 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) *pos++ = WLAN_EID_SUPP_RATES;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) *pos++ = supp_rates_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842) for (i = 0; i < sband->n_bitrates; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) if (BIT(i) & rates) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844) int rate = DIV_ROUND_UP(sband->bitrates[i].bitrate,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845) 5 * (1 << shift));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846) *pos++ = (u8) rate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847) if (++count == 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852) if (rates_len > count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853) pos = skb_put(skb, rates_len - count + 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854) *pos++ = WLAN_EID_EXT_SUPP_RATES;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855) *pos++ = rates_len - count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857) for (i++; i < sband->n_bitrates; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858) if (BIT(i) & rates) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859) int rate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860) rate = DIV_ROUND_UP(sband->bitrates[i].bitrate,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861) 5 * (1 << shift));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862) *pos++ = (u8) rate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 863) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 864) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 865) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 866)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 867) skip_rates:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 868) if (capab & WLAN_CAPABILITY_SPECTRUM_MGMT ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 869) capab & WLAN_CAPABILITY_RADIO_MEASURE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 870) pos = skb_put(skb, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 871) *pos++ = WLAN_EID_PWR_CAPABILITY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 872) *pos++ = 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 873) *pos++ = 0; /* min tx power */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 874) /* max tx power */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 875) *pos++ = ieee80211_chandef_max_power(&chanctx_conf->def);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 876) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 877)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 878) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 879) * Per spec, we shouldn't include the list of channels if we advertise
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 880) * support for extended channel switching, but we've always done that;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 881) * (for now?) apply this restriction only on the (new) 6 GHz band.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 882) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 883) if (capab & WLAN_CAPABILITY_SPECTRUM_MGMT &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 884) (sband->band != NL80211_BAND_6GHZ ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 885) !ext_capa || ext_capa->datalen < 1 ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 886) !(ext_capa->data[0] & WLAN_EXT_CAPA1_EXT_CHANNEL_SWITCHING))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 887) /* TODO: get this in reg domain format */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 888) pos = skb_put(skb, 2 * sband->n_channels + 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 889) *pos++ = WLAN_EID_SUPPORTED_CHANNELS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 890) *pos++ = 2 * sband->n_channels;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 891) for (i = 0; i < sband->n_channels; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 892) *pos++ = ieee80211_frequency_to_channel(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 893) sband->channels[i].center_freq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 894) *pos++ = 1; /* one channel in the subband*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 895) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 896) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 897)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 898) /* Set MBSSID support for HE AP if needed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 899) if (ieee80211_hw_check(&local->hw, SUPPORTS_ONLY_HE_MULTI_BSSID) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 900) !(ifmgd->flags & IEEE80211_STA_DISABLE_HE) && assoc_data->ie_len &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 901) ext_capa && ext_capa->datalen >= 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 902) ext_capa->data[2] |= WLAN_EXT_CAPA3_MULTI_BSSID_SUPPORT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 903)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 904) /* if present, add any custom IEs that go before HT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 905) if (assoc_data->ie_len) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 906) static const u8 before_ht[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 907) WLAN_EID_SSID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 908) WLAN_EID_SUPP_RATES,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 909) WLAN_EID_EXT_SUPP_RATES,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 910) WLAN_EID_PWR_CAPABILITY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 911) WLAN_EID_SUPPORTED_CHANNELS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 912) WLAN_EID_RSN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 913) WLAN_EID_QOS_CAPA,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 914) WLAN_EID_RRM_ENABLED_CAPABILITIES,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 915) WLAN_EID_MOBILITY_DOMAIN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 916) WLAN_EID_FAST_BSS_TRANSITION, /* reassoc only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 917) WLAN_EID_RIC_DATA, /* reassoc only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 918) WLAN_EID_SUPPORTED_REGULATORY_CLASSES,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 919) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 920) static const u8 after_ric[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 921) WLAN_EID_SUPPORTED_REGULATORY_CLASSES,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 922) WLAN_EID_HT_CAPABILITY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 923) WLAN_EID_BSS_COEX_2040,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 924) /* luckily this is almost always there */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 925) WLAN_EID_EXT_CAPABILITY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 926) WLAN_EID_QOS_TRAFFIC_CAPA,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 927) WLAN_EID_TIM_BCAST_REQ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 928) WLAN_EID_INTERWORKING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 929) /* 60 GHz (Multi-band, DMG, MMS) can't happen */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 930) WLAN_EID_VHT_CAPABILITY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 931) WLAN_EID_OPMODE_NOTIF,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 932) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 933)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 934) noffset = ieee80211_ie_split_ric(assoc_data->ie,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 935) assoc_data->ie_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 936) before_ht,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 937) ARRAY_SIZE(before_ht),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 938) after_ric,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 939) ARRAY_SIZE(after_ric),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 940) offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 941) skb_put_data(skb, assoc_data->ie + offset, noffset - offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 942) offset = noffset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 943) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 944)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 945) if (WARN_ON_ONCE((ifmgd->flags & IEEE80211_STA_DISABLE_HT) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 946) !(ifmgd->flags & IEEE80211_STA_DISABLE_VHT)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 947) ifmgd->flags |= IEEE80211_STA_DISABLE_VHT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 948)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 949) if (sband->band != NL80211_BAND_6GHZ &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 950) !(ifmgd->flags & IEEE80211_STA_DISABLE_HT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 951) ieee80211_add_ht_ie(sdata, skb, assoc_data->ap_ht_param,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 952) sband, chan, sdata->smps_mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 953)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 954) /* if present, add any custom IEs that go before VHT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 955) if (assoc_data->ie_len) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 956) static const u8 before_vht[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 957) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 958) * no need to list the ones split off before HT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 959) * or generated here
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 960) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 961) WLAN_EID_BSS_COEX_2040,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 962) WLAN_EID_EXT_CAPABILITY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 963) WLAN_EID_QOS_TRAFFIC_CAPA,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 964) WLAN_EID_TIM_BCAST_REQ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 965) WLAN_EID_INTERWORKING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 966) /* 60 GHz (Multi-band, DMG, MMS) can't happen */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 967) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 968)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 969) /* RIC already taken above, so no need to handle here anymore */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 970) noffset = ieee80211_ie_split(assoc_data->ie, assoc_data->ie_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 971) before_vht, ARRAY_SIZE(before_vht),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 972) offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 973) skb_put_data(skb, assoc_data->ie + offset, noffset - offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 974) offset = noffset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 975) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 976)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 977) /* if present, add any custom IEs that go before HE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 978) if (assoc_data->ie_len) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 979) static const u8 before_he[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 980) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 981) * no need to list the ones split off before VHT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 982) * or generated here
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 983) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 984) WLAN_EID_OPMODE_NOTIF,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 985) WLAN_EID_EXTENSION, WLAN_EID_EXT_FUTURE_CHAN_GUIDANCE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 986) /* 11ai elements */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 987) WLAN_EID_EXTENSION, WLAN_EID_EXT_FILS_SESSION,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 988) WLAN_EID_EXTENSION, WLAN_EID_EXT_FILS_PUBLIC_KEY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 989) WLAN_EID_EXTENSION, WLAN_EID_EXT_FILS_KEY_CONFIRM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 990) WLAN_EID_EXTENSION, WLAN_EID_EXT_FILS_HLP_CONTAINER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 991) WLAN_EID_EXTENSION, WLAN_EID_EXT_FILS_IP_ADDR_ASSIGN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 992) /* TODO: add 11ah/11aj/11ak elements */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 993) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 994)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 995) /* RIC already taken above, so no need to handle here anymore */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 996) noffset = ieee80211_ie_split(assoc_data->ie, assoc_data->ie_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 997) before_he, ARRAY_SIZE(before_he),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 998) offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 999) pos = skb_put(skb, noffset - offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) memcpy(pos, assoc_data->ie + offset, noffset - offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) offset = noffset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004) if (sband->band != NL80211_BAND_6GHZ &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) !(ifmgd->flags & IEEE80211_STA_DISABLE_VHT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) ieee80211_add_vht_ie(sdata, skb, sband,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) &assoc_data->ap_vht_cap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) * If AP doesn't support HT, mark HE as disabled.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) * If on the 5GHz band, make sure it supports VHT.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) if (ifmgd->flags & IEEE80211_STA_DISABLE_HT ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) (sband->band == NL80211_BAND_5GHZ &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015) ifmgd->flags & IEEE80211_STA_DISABLE_VHT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) ifmgd->flags |= IEEE80211_STA_DISABLE_HE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018) if (!(ifmgd->flags & IEEE80211_STA_DISABLE_HE))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) ieee80211_add_he_ie(sdata, skb, sband);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021) /* if present, add any custom non-vendor IEs that go after HE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) if (assoc_data->ie_len) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023) noffset = ieee80211_ie_split_vendor(assoc_data->ie,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024) assoc_data->ie_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025) offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) skb_put_data(skb, assoc_data->ie + offset, noffset - offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027) offset = noffset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) if (assoc_data->wmm) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) if (assoc_data->uapsd) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032) qos_info = ifmgd->uapsd_queues;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) qos_info |= (ifmgd->uapsd_max_sp_len <<
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) IEEE80211_WMM_IE_STA_QOSINFO_SP_SHIFT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) qos_info = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039) pos = ieee80211_add_wmm_info_ie(skb_put(skb, 9), qos_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042) if (sband->band == NL80211_BAND_S1GHZ) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) ieee80211_add_aid_request_ie(sdata, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044) ieee80211_add_s1g_capab_ie(sdata, &sband->s1g_cap, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047) /* add any remaining custom (i.e. vendor specific here) IEs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048) if (assoc_data->ie_len) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049) noffset = assoc_data->ie_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050) skb_put_data(skb, assoc_data->ie + offset, noffset - offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053) if (assoc_data->fils_kek_len &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054) fils_encrypt_assoc_req(skb, assoc_data) < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055) dev_kfree_skb(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059) pos = skb_tail_pointer(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060) kfree(ifmgd->assoc_req_ies);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061) ifmgd->assoc_req_ies = kmemdup(ie_start, pos - ie_start, GFP_ATOMIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062) ifmgd->assoc_req_ies_len = pos - ie_start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064) drv_mgd_prepare_tx(local, sdata, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1066) IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1067) if (ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1068) IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1069) IEEE80211_TX_INTFL_MLME_CONN_TX;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1070) ieee80211_tx_skb(sdata, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1071) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1072)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1073) void ieee80211_send_pspoll(struct ieee80211_local *local,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1074) struct ieee80211_sub_if_data *sdata)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1075) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1076) struct ieee80211_pspoll *pspoll;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1077) struct sk_buff *skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1078)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1079) skb = ieee80211_pspoll_get(&local->hw, &sdata->vif);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1080) if (!skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1081) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1082)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1083) pspoll = (struct ieee80211_pspoll *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1084) pspoll->frame_control |= cpu_to_le16(IEEE80211_FCTL_PM);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1085)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1086) IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1087) ieee80211_tx_skb(sdata, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1088) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1089)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1090) void ieee80211_send_nullfunc(struct ieee80211_local *local,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1091) struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1092) bool powersave)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1093) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1094) struct sk_buff *skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1095) struct ieee80211_hdr_3addr *nullfunc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1096) struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1097)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1098) skb = ieee80211_nullfunc_get(&local->hw, &sdata->vif,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1099) !ieee80211_hw_check(&local->hw, DOESNT_SUPPORT_QOS_NDP));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1100) if (!skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1101) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1103) nullfunc = (struct ieee80211_hdr_3addr *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1104) if (powersave)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1105) nullfunc->frame_control |= cpu_to_le16(IEEE80211_FCTL_PM);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1106)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1107) IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1108) IEEE80211_TX_INTFL_OFFCHAN_TX_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1109)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1110) if (ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1111) IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1113) if (ifmgd->flags & IEEE80211_STA_CONNECTION_POLL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1114) IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_CTL_USE_MINRATE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1116) ieee80211_tx_skb(sdata, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1117) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1118)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1119) void ieee80211_send_4addr_nullfunc(struct ieee80211_local *local,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1120) struct ieee80211_sub_if_data *sdata)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1121) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1122) struct sk_buff *skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1123) struct ieee80211_hdr *nullfunc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1124) __le16 fc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1126) if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_STATION))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1127) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1129) skb = dev_alloc_skb(local->hw.extra_tx_headroom + 30);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1130) if (!skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1131) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1133) skb_reserve(skb, local->hw.extra_tx_headroom);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1134)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1135) nullfunc = skb_put_zero(skb, 30);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1136) fc = cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_NULLFUNC |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1137) IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1138) nullfunc->frame_control = fc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1139) memcpy(nullfunc->addr1, sdata->u.mgd.bssid, ETH_ALEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1140) memcpy(nullfunc->addr2, sdata->vif.addr, ETH_ALEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1141) memcpy(nullfunc->addr3, sdata->u.mgd.bssid, ETH_ALEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1142) memcpy(nullfunc->addr4, sdata->vif.addr, ETH_ALEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1143)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1144) IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1145) ieee80211_tx_skb(sdata, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1146) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1147)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1148) /* spectrum management related things */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1149) static void ieee80211_chswitch_work(struct work_struct *work)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1150) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1151) struct ieee80211_sub_if_data *sdata =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1152) container_of(work, struct ieee80211_sub_if_data, u.mgd.chswitch_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1153) struct ieee80211_local *local = sdata->local;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1154) struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1155) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1157) if (!ieee80211_sdata_running(sdata))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1158) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1160) sdata_lock(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1161) mutex_lock(&local->mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1162) mutex_lock(&local->chanctx_mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1163)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1164) if (!ifmgd->associated)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1165) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1166)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1167) if (!sdata->vif.csa_active)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1168) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1169)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1170) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1171) * using reservation isn't immediate as it may be deferred until later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1172) * with multi-vif. once reservation is complete it will re-schedule the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1173) * work with no reserved_chanctx so verify chandef to check if it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1174) * completed successfully
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1175) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1176)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1177) if (sdata->reserved_chanctx) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1178) struct ieee80211_supported_band *sband = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1179) struct sta_info *mgd_sta = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1180) enum ieee80211_sta_rx_bandwidth bw = IEEE80211_STA_RX_BW_20;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1181)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1182) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1183) * with multi-vif csa driver may call ieee80211_csa_finish()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1184) * many times while waiting for other interfaces to use their
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1185) * reservations
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1186) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1187) if (sdata->reserved_ready)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1188) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1190) if (sdata->vif.bss_conf.chandef.width !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1191) sdata->csa_chandef.width) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1192) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1193) * For managed interface, we need to also update the AP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1194) * station bandwidth and align the rate scale algorithm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1195) * on the bandwidth change. Here we only consider the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1196) * bandwidth of the new channel definition (as channel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1197) * switch flow does not have the full HT/VHT/HE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1198) * information), assuming that if additional changes are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1199) * required they would be done as part of the processing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1200) * of the next beacon from the AP.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1201) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1202) switch (sdata->csa_chandef.width) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1203) case NL80211_CHAN_WIDTH_20_NOHT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1204) case NL80211_CHAN_WIDTH_20:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1205) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1206) bw = IEEE80211_STA_RX_BW_20;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1207) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1208) case NL80211_CHAN_WIDTH_40:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1209) bw = IEEE80211_STA_RX_BW_40;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1210) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1211) case NL80211_CHAN_WIDTH_80:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1212) bw = IEEE80211_STA_RX_BW_80;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1213) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1214) case NL80211_CHAN_WIDTH_80P80:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1215) case NL80211_CHAN_WIDTH_160:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1216) bw = IEEE80211_STA_RX_BW_160;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1217) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1218) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1219)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1220) mgd_sta = sta_info_get(sdata, ifmgd->bssid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1221) sband =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1222) local->hw.wiphy->bands[sdata->csa_chandef.chan->band];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1223) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1224)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1225) if (sdata->vif.bss_conf.chandef.width >
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1226) sdata->csa_chandef.width) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1227) mgd_sta->sta.bandwidth = bw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1228) rate_control_rate_update(local, sband, mgd_sta,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1229) IEEE80211_RC_BW_CHANGED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1230) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1231)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1232) ret = ieee80211_vif_use_reserved_context(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1233) if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1234) sdata_info(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1235) "failed to use reserved channel context, disconnecting (err=%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1236) ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1237) ieee80211_queue_work(&sdata->local->hw,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1238) &ifmgd->csa_connection_drop_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1239) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1240) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1241)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1242) if (sdata->vif.bss_conf.chandef.width <
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1243) sdata->csa_chandef.width) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1244) mgd_sta->sta.bandwidth = bw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1245) rate_control_rate_update(local, sband, mgd_sta,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1246) IEEE80211_RC_BW_CHANGED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1247) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1248)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1249) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1250) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1251)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1252) if (!cfg80211_chandef_identical(&sdata->vif.bss_conf.chandef,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1253) &sdata->csa_chandef)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1254) sdata_info(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1255) "failed to finalize channel switch, disconnecting\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1256) ieee80211_queue_work(&sdata->local->hw,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1257) &ifmgd->csa_connection_drop_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1258) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1259) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1260)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1261) ifmgd->csa_waiting_bcn = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1262)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1263) ieee80211_sta_reset_beacon_monitor(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1264) ieee80211_sta_reset_conn_monitor(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1265)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1266) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1267) mutex_unlock(&local->chanctx_mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1268) mutex_unlock(&local->mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1269) sdata_unlock(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1270) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1271)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1272) static void ieee80211_chswitch_post_beacon(struct ieee80211_sub_if_data *sdata)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1273) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1274) struct ieee80211_local *local = sdata->local;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1275) struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1276) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1277)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1278) sdata_assert_lock(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1279)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1280) WARN_ON(!sdata->vif.csa_active);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1281)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1282) if (sdata->csa_block_tx) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1283) ieee80211_wake_vif_queues(local, sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1284) IEEE80211_QUEUE_STOP_REASON_CSA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1285) sdata->csa_block_tx = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1286) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1287)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1288) sdata->vif.csa_active = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1289) ifmgd->csa_waiting_bcn = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1290) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1291) * If the CSA IE is still present on the beacon after the switch,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1292) * we need to consider it as a new CSA (possibly to self).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1293) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1294) ifmgd->beacon_crc_valid = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1295)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1296) ret = drv_post_channel_switch(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1297) if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1298) sdata_info(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1299) "driver post channel switch failed, disconnecting\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1300) ieee80211_queue_work(&local->hw,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1301) &ifmgd->csa_connection_drop_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1302) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1303) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1304)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1305) cfg80211_ch_switch_notify(sdata->dev, &sdata->reserved_chandef);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1306) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1307)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1308) void ieee80211_chswitch_done(struct ieee80211_vif *vif, bool success)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1309) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1310) struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1311) struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1312)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1313) trace_api_chswitch_done(sdata, success);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1314) if (!success) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1315) sdata_info(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1316) "driver channel switch failed, disconnecting\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1317) ieee80211_queue_work(&sdata->local->hw,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1318) &ifmgd->csa_connection_drop_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1319) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1320) ieee80211_queue_work(&sdata->local->hw, &ifmgd->chswitch_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1321) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1322) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1323) EXPORT_SYMBOL(ieee80211_chswitch_done);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1324)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1325) static void ieee80211_chswitch_timer(struct timer_list *t)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1326) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1327) struct ieee80211_sub_if_data *sdata =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1328) from_timer(sdata, t, u.mgd.chswitch_timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1329)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1330) ieee80211_queue_work(&sdata->local->hw, &sdata->u.mgd.chswitch_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1331) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1332)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1333) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1334) ieee80211_sta_abort_chanswitch(struct ieee80211_sub_if_data *sdata)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1335) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1336) struct ieee80211_local *local = sdata->local;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1337)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1338) if (!local->ops->abort_channel_switch)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1339) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1340)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1341) mutex_lock(&local->mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1342)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1343) mutex_lock(&local->chanctx_mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1344) ieee80211_vif_unreserve_chanctx(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1345) mutex_unlock(&local->chanctx_mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1346)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1347) if (sdata->csa_block_tx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1348) ieee80211_wake_vif_queues(local, sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1349) IEEE80211_QUEUE_STOP_REASON_CSA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1350)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1351) sdata->csa_block_tx = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1352) sdata->vif.csa_active = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1353)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1354) mutex_unlock(&local->mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1355)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1356) drv_abort_channel_switch(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1357) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1358)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1359) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1360) ieee80211_sta_process_chanswitch(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1361) u64 timestamp, u32 device_timestamp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1362) struct ieee802_11_elems *elems,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1363) bool beacon)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1364) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1365) struct ieee80211_local *local = sdata->local;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1366) struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1367) struct cfg80211_bss *cbss = ifmgd->associated;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1368) struct ieee80211_chanctx_conf *conf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1369) struct ieee80211_chanctx *chanctx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1370) enum nl80211_band current_band;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1371) struct ieee80211_csa_ie csa_ie;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1372) struct ieee80211_channel_switch ch_switch;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1373) struct ieee80211_bss *bss;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1374) int res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1375)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1376) sdata_assert_lock(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1377)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1378) if (!cbss)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1379) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1380)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1381) if (local->scanning)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1382) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1383)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1384) current_band = cbss->channel->band;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1385) bss = (void *)cbss->priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1386) res = ieee80211_parse_ch_switch_ie(sdata, elems, current_band,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1387) bss->vht_cap_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1388) ifmgd->flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1389) ifmgd->associated->bssid, &csa_ie);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1390)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1391) if (!res) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1392) ch_switch.timestamp = timestamp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1393) ch_switch.device_timestamp = device_timestamp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1394) ch_switch.block_tx = csa_ie.mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1395) ch_switch.chandef = csa_ie.chandef;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1396) ch_switch.count = csa_ie.count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1397) ch_switch.delay = csa_ie.max_switch_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1398) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1399)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1400) if (res < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1401) ieee80211_queue_work(&local->hw,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1402) &ifmgd->csa_connection_drop_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1403) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1404) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1405)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1406) if (beacon && sdata->vif.csa_active && !ifmgd->csa_waiting_bcn) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1407) if (res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1408) ieee80211_sta_abort_chanswitch(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1409) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1410) drv_channel_switch_rx_beacon(sdata, &ch_switch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1411) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1412) } else if (sdata->vif.csa_active || res) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1413) /* disregard subsequent announcements if already processing */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1414) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1415) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1416)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1417) if (!cfg80211_chandef_usable(local->hw.wiphy, &csa_ie.chandef,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1418) IEEE80211_CHAN_DISABLED)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1419) sdata_info(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1420) "AP %pM switches to unsupported channel "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1421) "(%d.%03d MHz, width:%d, CF1/2: %d.%03d/%d MHz), "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1422) "disconnecting\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1423) ifmgd->associated->bssid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1424) csa_ie.chandef.chan->center_freq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1425) csa_ie.chandef.chan->freq_offset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1426) csa_ie.chandef.width, csa_ie.chandef.center_freq1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1427) csa_ie.chandef.freq1_offset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1428) csa_ie.chandef.center_freq2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1429) ieee80211_queue_work(&local->hw,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1430) &ifmgd->csa_connection_drop_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1431) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1432) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1433)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1434) if (cfg80211_chandef_identical(&csa_ie.chandef,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1435) &sdata->vif.bss_conf.chandef) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1436) (!csa_ie.mode || !beacon)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1437) if (ifmgd->csa_ignored_same_chan)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1438) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1439) sdata_info(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1440) "AP %pM tries to chanswitch to same channel, ignore\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1441) ifmgd->associated->bssid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1442) ifmgd->csa_ignored_same_chan = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1443) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1444) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1445)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1446) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1447) * Drop all TDLS peers - either we disconnect or move to a different
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1448) * channel from this point on. There's no telling what our peer will do.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1449) * The TDLS WIDER_BW scenario is also problematic, as peers might now
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1450) * have an incompatible wider chandef.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1451) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1452) ieee80211_teardown_tdls_peers(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1453)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1454) mutex_lock(&local->mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1455) mutex_lock(&local->chanctx_mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1456) conf = rcu_dereference_protected(sdata->vif.chanctx_conf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1457) lockdep_is_held(&local->chanctx_mtx));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1458) if (!conf) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1459) sdata_info(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1460) "no channel context assigned to vif?, disconnecting\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1461) goto drop_connection;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1462) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1463)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1464) chanctx = container_of(conf, struct ieee80211_chanctx, conf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1465)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1466) if (local->use_chanctx &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1467) !ieee80211_hw_check(&local->hw, CHANCTX_STA_CSA)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1468) sdata_info(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1469) "driver doesn't support chan-switch with channel contexts\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1470) goto drop_connection;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1471) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1472)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1473) if (drv_pre_channel_switch(sdata, &ch_switch)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1474) sdata_info(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1475) "preparing for channel switch failed, disconnecting\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1476) goto drop_connection;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1477) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1478)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1479) res = ieee80211_vif_reserve_chanctx(sdata, &csa_ie.chandef,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1480) chanctx->mode, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1481) if (res) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1482) sdata_info(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1483) "failed to reserve channel context for channel switch, disconnecting (err=%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1484) res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1485) goto drop_connection;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1486) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1487) mutex_unlock(&local->chanctx_mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1488)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1489) sdata->vif.csa_active = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1490) sdata->csa_chandef = csa_ie.chandef;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1491) sdata->csa_block_tx = csa_ie.mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1492) ifmgd->csa_ignored_same_chan = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1493)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1494) if (sdata->csa_block_tx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1495) ieee80211_stop_vif_queues(local, sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1496) IEEE80211_QUEUE_STOP_REASON_CSA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1497) mutex_unlock(&local->mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1498)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1499) cfg80211_ch_switch_started_notify(sdata->dev, &csa_ie.chandef,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1500) csa_ie.count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1501)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1502) if (local->ops->channel_switch) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1503) /* use driver's channel switch callback */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1504) drv_channel_switch(local, sdata, &ch_switch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1505) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1506) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1507)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1508) /* channel switch handled in software */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1509) if (csa_ie.count <= 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1510) ieee80211_queue_work(&local->hw, &ifmgd->chswitch_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1511) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1512) mod_timer(&ifmgd->chswitch_timer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1513) TU_TO_EXP_TIME((csa_ie.count - 1) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1514) cbss->beacon_interval));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1515) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1516) drop_connection:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1517) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1518) * This is just so that the disconnect flow will know that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1519) * we were trying to switch channel and failed. In case the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1520) * mode is 1 (we are not allowed to Tx), we will know not to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1521) * send a deauthentication frame. Those two fields will be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1522) * reset when the disconnection worker runs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1523) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1524) sdata->vif.csa_active = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1525) sdata->csa_block_tx = csa_ie.mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1526)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1527) ieee80211_queue_work(&local->hw, &ifmgd->csa_connection_drop_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1528) mutex_unlock(&local->chanctx_mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1529) mutex_unlock(&local->mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1530) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1531)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1532) static bool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1533) ieee80211_find_80211h_pwr_constr(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1534) struct ieee80211_channel *channel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1535) const u8 *country_ie, u8 country_ie_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1536) const u8 *pwr_constr_elem,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1537) int *chan_pwr, int *pwr_reduction)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1538) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1539) struct ieee80211_country_ie_triplet *triplet;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1540) int chan = ieee80211_frequency_to_channel(channel->center_freq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1541) int i, chan_increment;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1542) bool have_chan_pwr = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1543)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1544) /* Invalid IE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1545) if (country_ie_len % 2 || country_ie_len < IEEE80211_COUNTRY_IE_MIN_LEN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1546) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1547)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1548) triplet = (void *)(country_ie + 3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1549) country_ie_len -= 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1550)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1551) switch (channel->band) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1552) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1553) WARN_ON_ONCE(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1554) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1555) case NL80211_BAND_2GHZ:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1556) case NL80211_BAND_60GHZ:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1557) chan_increment = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1558) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1559) case NL80211_BAND_5GHZ:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1560) case NL80211_BAND_6GHZ:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1561) chan_increment = 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1562) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1563) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1564)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1565) /* find channel */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1566) while (country_ie_len >= 3) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1567) u8 first_channel = triplet->chans.first_channel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1568)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1569) if (first_channel >= IEEE80211_COUNTRY_EXTENSION_ID)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1570) goto next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1571)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1572) for (i = 0; i < triplet->chans.num_channels; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1573) if (first_channel + i * chan_increment == chan) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1574) have_chan_pwr = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1575) *chan_pwr = triplet->chans.max_power;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1576) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1577) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1578) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1579) if (have_chan_pwr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1580) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1581)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1582) next:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1583) triplet++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1584) country_ie_len -= 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1585) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1586)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1587) if (have_chan_pwr && pwr_constr_elem)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1588) *pwr_reduction = *pwr_constr_elem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1589) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1590) *pwr_reduction = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1591)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1592) return have_chan_pwr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1593) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1594)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1595) static void ieee80211_find_cisco_dtpc(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1596) struct ieee80211_channel *channel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1597) const u8 *cisco_dtpc_ie,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1598) int *pwr_level)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1599) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1600) /* From practical testing, the first data byte of the DTPC element
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1601) * seems to contain the requested dBm level, and the CLI on Cisco
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1602) * APs clearly state the range is -127 to 127 dBm, which indicates
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1603) * a signed byte, although it seemingly never actually goes negative.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1604) * The other byte seems to always be zero.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1605) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1606) *pwr_level = (__s8)cisco_dtpc_ie[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1607) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1608)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1609) static u32 ieee80211_handle_pwr_constr(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1610) struct ieee80211_channel *channel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1611) struct ieee80211_mgmt *mgmt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1612) const u8 *country_ie, u8 country_ie_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1613) const u8 *pwr_constr_ie,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1614) const u8 *cisco_dtpc_ie)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1615) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1616) bool has_80211h_pwr = false, has_cisco_pwr = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1617) int chan_pwr = 0, pwr_reduction_80211h = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1618) int pwr_level_cisco, pwr_level_80211h;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1619) int new_ap_level;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1620) __le16 capab = mgmt->u.probe_resp.capab_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1621)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1622) if (ieee80211_is_s1g_beacon(mgmt->frame_control))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1623) return 0; /* TODO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1624)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1625) if (country_ie &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1626) (capab & cpu_to_le16(WLAN_CAPABILITY_SPECTRUM_MGMT) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1627) capab & cpu_to_le16(WLAN_CAPABILITY_RADIO_MEASURE))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1628) has_80211h_pwr = ieee80211_find_80211h_pwr_constr(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1629) sdata, channel, country_ie, country_ie_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1630) pwr_constr_ie, &chan_pwr, &pwr_reduction_80211h);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1631) pwr_level_80211h =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1632) max_t(int, 0, chan_pwr - pwr_reduction_80211h);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1633) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1634)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1635) if (cisco_dtpc_ie) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1636) ieee80211_find_cisco_dtpc(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1637) sdata, channel, cisco_dtpc_ie, &pwr_level_cisco);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1638) has_cisco_pwr = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1639) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1640)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1641) if (!has_80211h_pwr && !has_cisco_pwr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1642) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1643)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1644) /* If we have both 802.11h and Cisco DTPC, apply both limits
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1645) * by picking the smallest of the two power levels advertised.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1646) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1647) if (has_80211h_pwr &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1648) (!has_cisco_pwr || pwr_level_80211h <= pwr_level_cisco)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1649) new_ap_level = pwr_level_80211h;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1650)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1651) if (sdata->ap_power_level == new_ap_level)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1652) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1653)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1654) sdata_dbg(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1655) "Limiting TX power to %d (%d - %d) dBm as advertised by %pM\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1656) pwr_level_80211h, chan_pwr, pwr_reduction_80211h,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1657) sdata->u.mgd.bssid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1658) } else { /* has_cisco_pwr is always true here. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1659) new_ap_level = pwr_level_cisco;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1660)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1661) if (sdata->ap_power_level == new_ap_level)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1662) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1663)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1664) sdata_dbg(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1665) "Limiting TX power to %d dBm as advertised by %pM\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1666) pwr_level_cisco, sdata->u.mgd.bssid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1667) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1668)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1669) sdata->ap_power_level = new_ap_level;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1670) if (__ieee80211_recalc_txpower(sdata))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1671) return BSS_CHANGED_TXPOWER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1672) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1673) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1674)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1675) /* powersave */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1676) static void ieee80211_enable_ps(struct ieee80211_local *local,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1677) struct ieee80211_sub_if_data *sdata)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1678) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1679) struct ieee80211_conf *conf = &local->hw.conf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1680)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1681) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1682) * If we are scanning right now then the parameters will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1683) * take effect when scan finishes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1684) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1685) if (local->scanning)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1686) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1687)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1688) if (conf->dynamic_ps_timeout > 0 &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1689) !ieee80211_hw_check(&local->hw, SUPPORTS_DYNAMIC_PS)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1690) mod_timer(&local->dynamic_ps_timer, jiffies +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1691) msecs_to_jiffies(conf->dynamic_ps_timeout));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1692) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1693) if (ieee80211_hw_check(&local->hw, PS_NULLFUNC_STACK))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1694) ieee80211_send_nullfunc(local, sdata, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1695)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1696) if (ieee80211_hw_check(&local->hw, PS_NULLFUNC_STACK) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1697) ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1698) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1699)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1700) conf->flags |= IEEE80211_CONF_PS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1701) ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1702) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1703) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1704)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1705) static void ieee80211_change_ps(struct ieee80211_local *local)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1706) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1707) struct ieee80211_conf *conf = &local->hw.conf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1708)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1709) if (local->ps_sdata) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1710) ieee80211_enable_ps(local, local->ps_sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1711) } else if (conf->flags & IEEE80211_CONF_PS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1712) conf->flags &= ~IEEE80211_CONF_PS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1713) ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1714) del_timer_sync(&local->dynamic_ps_timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1715) cancel_work_sync(&local->dynamic_ps_enable_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1716) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1717) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1718)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1719) static bool ieee80211_powersave_allowed(struct ieee80211_sub_if_data *sdata)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1720) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1721) struct ieee80211_if_managed *mgd = &sdata->u.mgd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1722) struct sta_info *sta = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1723) bool authorized = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1724)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1725) if (!mgd->powersave)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1726) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1727)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1728) if (mgd->broken_ap)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1729) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1730)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1731) if (!mgd->associated)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1732) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1733)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1734) if (mgd->flags & IEEE80211_STA_CONNECTION_POLL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1735) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1736)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1737) if (!mgd->have_beacon)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1738) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1739)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1740) rcu_read_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1741) sta = sta_info_get(sdata, mgd->bssid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1742) if (sta)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1743) authorized = test_sta_flag(sta, WLAN_STA_AUTHORIZED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1744) rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1745)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1746) return authorized;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1747) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1748)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1749) /* need to hold RTNL or interface lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1750) void ieee80211_recalc_ps(struct ieee80211_local *local)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1751) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1752) struct ieee80211_sub_if_data *sdata, *found = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1753) int count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1754) int timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1755)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1756) if (!ieee80211_hw_check(&local->hw, SUPPORTS_PS)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1757) local->ps_sdata = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1758) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1759) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1760)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1761) list_for_each_entry(sdata, &local->interfaces, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1762) if (!ieee80211_sdata_running(sdata))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1763) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1764) if (sdata->vif.type == NL80211_IFTYPE_AP) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1765) /* If an AP vif is found, then disable PS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1766) * by setting the count to zero thereby setting
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1767) * ps_sdata to NULL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1768) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1769) count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1770) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1771) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1772) if (sdata->vif.type != NL80211_IFTYPE_STATION)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1773) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1774) found = sdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1775) count++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1776) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1777)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1778) if (count == 1 && ieee80211_powersave_allowed(found)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1779) u8 dtimper = found->u.mgd.dtim_period;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1780)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1781) timeout = local->dynamic_ps_forced_timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1782) if (timeout < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1783) timeout = 100;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1784) local->hw.conf.dynamic_ps_timeout = timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1785)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1786) /* If the TIM IE is invalid, pretend the value is 1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1787) if (!dtimper)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1788) dtimper = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1789)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1790) local->hw.conf.ps_dtim_period = dtimper;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1791) local->ps_sdata = found;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1792) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1793) local->ps_sdata = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1794) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1795)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1796) ieee80211_change_ps(local);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1797) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1798)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1799) void ieee80211_recalc_ps_vif(struct ieee80211_sub_if_data *sdata)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1800) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1801) bool ps_allowed = ieee80211_powersave_allowed(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1802)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1803) if (sdata->vif.bss_conf.ps != ps_allowed) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1804) sdata->vif.bss_conf.ps = ps_allowed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1805) ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_PS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1806) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1807) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1808)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1809) void ieee80211_dynamic_ps_disable_work(struct work_struct *work)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1810) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1811) struct ieee80211_local *local =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1812) container_of(work, struct ieee80211_local,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1813) dynamic_ps_disable_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1814)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1815) if (local->hw.conf.flags & IEEE80211_CONF_PS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1816) local->hw.conf.flags &= ~IEEE80211_CONF_PS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1817) ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1818) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1819)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1820) ieee80211_wake_queues_by_reason(&local->hw,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1821) IEEE80211_MAX_QUEUE_MAP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1822) IEEE80211_QUEUE_STOP_REASON_PS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1823) false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1824) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1825)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1826) void ieee80211_dynamic_ps_enable_work(struct work_struct *work)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1827) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1828) struct ieee80211_local *local =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1829) container_of(work, struct ieee80211_local,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1830) dynamic_ps_enable_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1831) struct ieee80211_sub_if_data *sdata = local->ps_sdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1832) struct ieee80211_if_managed *ifmgd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1833) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1834) int q;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1835)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1836) /* can only happen when PS was just disabled anyway */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1837) if (!sdata)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1838) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1839)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1840) ifmgd = &sdata->u.mgd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1841)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1842) if (local->hw.conf.flags & IEEE80211_CONF_PS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1843) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1844)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1845) if (local->hw.conf.dynamic_ps_timeout > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1846) /* don't enter PS if TX frames are pending */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1847) if (drv_tx_frames_pending(local)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1848) mod_timer(&local->dynamic_ps_timer, jiffies +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1849) msecs_to_jiffies(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1850) local->hw.conf.dynamic_ps_timeout));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1851) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1852) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1853)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1854) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1855) * transmission can be stopped by others which leads to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1856) * dynamic_ps_timer expiry. Postpone the ps timer if it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1857) * is not the actual idle state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1858) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1859) spin_lock_irqsave(&local->queue_stop_reason_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1860) for (q = 0; q < local->hw.queues; q++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1861) if (local->queue_stop_reasons[q]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1862) spin_unlock_irqrestore(&local->queue_stop_reason_lock,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1863) flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1864) mod_timer(&local->dynamic_ps_timer, jiffies +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1865) msecs_to_jiffies(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1866) local->hw.conf.dynamic_ps_timeout));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1867) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1868) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1869) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1870) spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1871) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1872)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1873) if (ieee80211_hw_check(&local->hw, PS_NULLFUNC_STACK) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1874) !(ifmgd->flags & IEEE80211_STA_NULLFUNC_ACKED)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1875) if (drv_tx_frames_pending(local)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1876) mod_timer(&local->dynamic_ps_timer, jiffies +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1877) msecs_to_jiffies(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1878) local->hw.conf.dynamic_ps_timeout));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1879) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1880) ieee80211_send_nullfunc(local, sdata, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1881) /* Flush to get the tx status of nullfunc frame */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1882) ieee80211_flush_queues(local, sdata, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1883) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1884) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1885)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1886) if (!(ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1887) ieee80211_hw_check(&local->hw, PS_NULLFUNC_STACK)) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1888) (ifmgd->flags & IEEE80211_STA_NULLFUNC_ACKED)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1889) ifmgd->flags &= ~IEEE80211_STA_NULLFUNC_ACKED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1890) local->hw.conf.flags |= IEEE80211_CONF_PS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1891) ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1892) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1893) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1894)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1895) void ieee80211_dynamic_ps_timer(struct timer_list *t)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1896) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1897) struct ieee80211_local *local = from_timer(local, t, dynamic_ps_timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1898)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1899) ieee80211_queue_work(&local->hw, &local->dynamic_ps_enable_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1900) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1901)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1902) void ieee80211_dfs_cac_timer_work(struct work_struct *work)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1903) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1904) struct delayed_work *delayed_work = to_delayed_work(work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1905) struct ieee80211_sub_if_data *sdata =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1906) container_of(delayed_work, struct ieee80211_sub_if_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1907) dfs_cac_timer_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1908) struct cfg80211_chan_def chandef = sdata->vif.bss_conf.chandef;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1909)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1910) mutex_lock(&sdata->local->mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1911) if (sdata->wdev.cac_started) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1912) ieee80211_vif_release_channel(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1913) cfg80211_cac_event(sdata->dev, &chandef,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1914) NL80211_RADAR_CAC_FINISHED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1915) GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1916) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1917) mutex_unlock(&sdata->local->mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1918) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1919)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1920) static bool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1921) __ieee80211_sta_handle_tspec_ac_params(struct ieee80211_sub_if_data *sdata)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1922) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1923) struct ieee80211_local *local = sdata->local;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1924) struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1925) bool ret = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1926) int ac;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1927)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1928) if (local->hw.queues < IEEE80211_NUM_ACS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1929) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1930)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1931) for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1932) struct ieee80211_sta_tx_tspec *tx_tspec = &ifmgd->tx_tspec[ac];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1933) int non_acm_ac;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1934) unsigned long now = jiffies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1935)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1936) if (tx_tspec->action == TX_TSPEC_ACTION_NONE &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1937) tx_tspec->admitted_time &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1938) time_after(now, tx_tspec->time_slice_start + HZ)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1939) tx_tspec->consumed_tx_time = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1940) tx_tspec->time_slice_start = now;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1941)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1942) if (tx_tspec->downgraded)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1943) tx_tspec->action =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1944) TX_TSPEC_ACTION_STOP_DOWNGRADE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1945) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1946)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1947) switch (tx_tspec->action) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1948) case TX_TSPEC_ACTION_STOP_DOWNGRADE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1949) /* take the original parameters */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1950) if (drv_conf_tx(local, sdata, ac, &sdata->tx_conf[ac]))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1951) sdata_err(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1952) "failed to set TX queue parameters for queue %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1953) ac);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1954) tx_tspec->action = TX_TSPEC_ACTION_NONE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1955) tx_tspec->downgraded = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1956) ret = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1957) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1958) case TX_TSPEC_ACTION_DOWNGRADE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1959) if (time_after(now, tx_tspec->time_slice_start + HZ)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1960) tx_tspec->action = TX_TSPEC_ACTION_NONE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1961) ret = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1962) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1963) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1964) /* downgrade next lower non-ACM AC */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1965) for (non_acm_ac = ac + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1966) non_acm_ac < IEEE80211_NUM_ACS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1967) non_acm_ac++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1968) if (!(sdata->wmm_acm & BIT(7 - 2 * non_acm_ac)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1969) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1970) /* Usually the loop will result in using BK even if it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1971) * requires admission control, but such a configuration
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1972) * makes no sense and we have to transmit somehow - the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1973) * AC selection does the same thing.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1974) * If we started out trying to downgrade from BK, then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1975) * the extra condition here might be needed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1976) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1977) if (non_acm_ac >= IEEE80211_NUM_ACS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1978) non_acm_ac = IEEE80211_AC_BK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1979) if (drv_conf_tx(local, sdata, ac,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1980) &sdata->tx_conf[non_acm_ac]))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1981) sdata_err(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1982) "failed to set TX queue parameters for queue %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1983) ac);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1984) tx_tspec->action = TX_TSPEC_ACTION_NONE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1985) ret = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1986) schedule_delayed_work(&ifmgd->tx_tspec_wk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1987) tx_tspec->time_slice_start + HZ - now + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1988) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1989) case TX_TSPEC_ACTION_NONE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1990) /* nothing now */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1991) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1992) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1993) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1994)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1995) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1996) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1997)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1998) void ieee80211_sta_handle_tspec_ac_params(struct ieee80211_sub_if_data *sdata)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1999) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2000) if (__ieee80211_sta_handle_tspec_ac_params(sdata))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2001) ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_QOS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2002) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2003)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2004) static void ieee80211_sta_handle_tspec_ac_params_wk(struct work_struct *work)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2005) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2006) struct ieee80211_sub_if_data *sdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2007)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2008) sdata = container_of(work, struct ieee80211_sub_if_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2009) u.mgd.tx_tspec_wk.work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2010) ieee80211_sta_handle_tspec_ac_params(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2011) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2012)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2013) /* MLME */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2014) static bool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2015) ieee80211_sta_wmm_params(struct ieee80211_local *local,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2016) struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2017) const u8 *wmm_param, size_t wmm_param_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2018) const struct ieee80211_mu_edca_param_set *mu_edca)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2019) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2020) struct ieee80211_tx_queue_params params[IEEE80211_NUM_ACS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2021) struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2022) size_t left;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2023) int count, mu_edca_count, ac;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2024) const u8 *pos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2025) u8 uapsd_queues = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2026)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2027) if (!local->ops->conf_tx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2028) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2029)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2030) if (local->hw.queues < IEEE80211_NUM_ACS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2031) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2032)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2033) if (!wmm_param)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2034) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2035)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2036) if (wmm_param_len < 8 || wmm_param[5] /* version */ != 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2037) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2038)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2039) if (ifmgd->flags & IEEE80211_STA_UAPSD_ENABLED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2040) uapsd_queues = ifmgd->uapsd_queues;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2041)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2042) count = wmm_param[6] & 0x0f;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2043) /* -1 is the initial value of ifmgd->mu_edca_last_param_set.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2044) * if mu_edca was preset before and now it disappeared tell
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2045) * the driver about it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2046) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2047) mu_edca_count = mu_edca ? mu_edca->mu_qos_info & 0x0f : -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2048) if (count == ifmgd->wmm_last_param_set &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2049) mu_edca_count == ifmgd->mu_edca_last_param_set)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2050) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2051) ifmgd->wmm_last_param_set = count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2052) ifmgd->mu_edca_last_param_set = mu_edca_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2053)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2054) pos = wmm_param + 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2055) left = wmm_param_len - 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2056)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2057) memset(¶ms, 0, sizeof(params));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2058)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2059) sdata->wmm_acm = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2060) for (; left >= 4; left -= 4, pos += 4) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2061) int aci = (pos[0] >> 5) & 0x03;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2062) int acm = (pos[0] >> 4) & 0x01;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2063) bool uapsd = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2064)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2065) switch (aci) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2066) case 1: /* AC_BK */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2067) ac = IEEE80211_AC_BK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2068) if (acm)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2069) sdata->wmm_acm |= BIT(1) | BIT(2); /* BK/- */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2070) if (uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_BK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2071) uapsd = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2072) params[ac].mu_edca = !!mu_edca;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2073) if (mu_edca)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2074) params[ac].mu_edca_param_rec = mu_edca->ac_bk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2075) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2076) case 2: /* AC_VI */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2077) ac = IEEE80211_AC_VI;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2078) if (acm)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2079) sdata->wmm_acm |= BIT(4) | BIT(5); /* CL/VI */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2080) if (uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_VI)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2081) uapsd = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2082) params[ac].mu_edca = !!mu_edca;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2083) if (mu_edca)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2084) params[ac].mu_edca_param_rec = mu_edca->ac_vi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2085) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2086) case 3: /* AC_VO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2087) ac = IEEE80211_AC_VO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2088) if (acm)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2089) sdata->wmm_acm |= BIT(6) | BIT(7); /* VO/NC */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2090) if (uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_VO)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2091) uapsd = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2092) params[ac].mu_edca = !!mu_edca;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2093) if (mu_edca)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2094) params[ac].mu_edca_param_rec = mu_edca->ac_vo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2095) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2096) case 0: /* AC_BE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2097) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2098) ac = IEEE80211_AC_BE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2099) if (acm)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2100) sdata->wmm_acm |= BIT(0) | BIT(3); /* BE/EE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2101) if (uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_BE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2102) uapsd = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2103) params[ac].mu_edca = !!mu_edca;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2104) if (mu_edca)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2105) params[ac].mu_edca_param_rec = mu_edca->ac_be;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2106) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2107) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2109) params[ac].aifs = pos[0] & 0x0f;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2110)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2111) if (params[ac].aifs < 2) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2112) sdata_info(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2113) "AP has invalid WMM params (AIFSN=%d for ACI %d), will use 2\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2114) params[ac].aifs, aci);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2115) params[ac].aifs = 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2116) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2117) params[ac].cw_max = ecw2cw((pos[1] & 0xf0) >> 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2118) params[ac].cw_min = ecw2cw(pos[1] & 0x0f);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2119) params[ac].txop = get_unaligned_le16(pos + 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2120) params[ac].acm = acm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2121) params[ac].uapsd = uapsd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2122)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2123) if (params[ac].cw_min == 0 ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2124) params[ac].cw_min > params[ac].cw_max) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2125) sdata_info(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2126) "AP has invalid WMM params (CWmin/max=%d/%d for ACI %d), using defaults\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2127) params[ac].cw_min, params[ac].cw_max, aci);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2128) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2129) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2130) ieee80211_regulatory_limit_wmm_params(sdata, ¶ms[ac], ac);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2131) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2133) /* WMM specification requires all 4 ACIs. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2134) for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2135) if (params[ac].cw_min == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2136) sdata_info(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2137) "AP has invalid WMM params (missing AC %d), using defaults\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2138) ac);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2139) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2140) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2141) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2142)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2143) for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2144) mlme_dbg(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2145) "WMM AC=%d acm=%d aifs=%d cWmin=%d cWmax=%d txop=%d uapsd=%d, downgraded=%d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2146) ac, params[ac].acm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2147) params[ac].aifs, params[ac].cw_min, params[ac].cw_max,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2148) params[ac].txop, params[ac].uapsd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2149) ifmgd->tx_tspec[ac].downgraded);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2150) sdata->tx_conf[ac] = params[ac];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2151) if (!ifmgd->tx_tspec[ac].downgraded &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2152) drv_conf_tx(local, sdata, ac, ¶ms[ac]))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2153) sdata_err(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2154) "failed to set TX queue parameters for AC %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2155) ac);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2156) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2157)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2158) /* enable WMM or activate new settings */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2159) sdata->vif.bss_conf.qos = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2160) return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2161) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2162)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2163) static void __ieee80211_stop_poll(struct ieee80211_sub_if_data *sdata)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2164) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2165) lockdep_assert_held(&sdata->local->mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2166)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2167) sdata->u.mgd.flags &= ~IEEE80211_STA_CONNECTION_POLL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2168) ieee80211_run_deferred_scan(sdata->local);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2169) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2170)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2171) static void ieee80211_stop_poll(struct ieee80211_sub_if_data *sdata)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2172) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2173) mutex_lock(&sdata->local->mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2174) __ieee80211_stop_poll(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2175) mutex_unlock(&sdata->local->mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2176) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2178) static u32 ieee80211_handle_bss_capability(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2179) u16 capab, bool erp_valid, u8 erp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2180) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2181) struct ieee80211_bss_conf *bss_conf = &sdata->vif.bss_conf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2182) struct ieee80211_supported_band *sband;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2183) u32 changed = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2184) bool use_protection;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2185) bool use_short_preamble;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2186) bool use_short_slot;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2187)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2188) sband = ieee80211_get_sband(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2189) if (!sband)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2190) return changed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2191)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2192) if (erp_valid) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2193) use_protection = (erp & WLAN_ERP_USE_PROTECTION) != 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2194) use_short_preamble = (erp & WLAN_ERP_BARKER_PREAMBLE) == 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2195) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2196) use_protection = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2197) use_short_preamble = !!(capab & WLAN_CAPABILITY_SHORT_PREAMBLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2198) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2199)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2200) use_short_slot = !!(capab & WLAN_CAPABILITY_SHORT_SLOT_TIME);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2201) if (sband->band == NL80211_BAND_5GHZ ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2202) sband->band == NL80211_BAND_6GHZ)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2203) use_short_slot = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2205) if (use_protection != bss_conf->use_cts_prot) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2206) bss_conf->use_cts_prot = use_protection;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2207) changed |= BSS_CHANGED_ERP_CTS_PROT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2208) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2210) if (use_short_preamble != bss_conf->use_short_preamble) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2211) bss_conf->use_short_preamble = use_short_preamble;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2212) changed |= BSS_CHANGED_ERP_PREAMBLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2213) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2214)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2215) if (use_short_slot != bss_conf->use_short_slot) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2216) bss_conf->use_short_slot = use_short_slot;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2217) changed |= BSS_CHANGED_ERP_SLOT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2218) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2219)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2220) return changed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2221) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2222)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2223) static void ieee80211_set_associated(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2224) struct cfg80211_bss *cbss,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2225) u32 bss_info_changed)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2226) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2227) struct ieee80211_bss *bss = (void *)cbss->priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2228) struct ieee80211_local *local = sdata->local;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2229) struct ieee80211_bss_conf *bss_conf = &sdata->vif.bss_conf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2230)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2231) bss_info_changed |= BSS_CHANGED_ASSOC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2232) bss_info_changed |= ieee80211_handle_bss_capability(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2233) bss_conf->assoc_capability, bss->has_erp_value, bss->erp_value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2234)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2235) sdata->u.mgd.beacon_timeout = usecs_to_jiffies(ieee80211_tu_to_usec(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2236) beacon_loss_count * bss_conf->beacon_int));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2237)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2238) sdata->u.mgd.associated = cbss;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2239) memcpy(sdata->u.mgd.bssid, cbss->bssid, ETH_ALEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2240)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2241) ieee80211_check_rate_mask(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2243) sdata->u.mgd.flags |= IEEE80211_STA_RESET_SIGNAL_AVE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2244)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2245) if (sdata->vif.p2p ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2246) sdata->vif.driver_flags & IEEE80211_VIF_GET_NOA_UPDATE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2247) const struct cfg80211_bss_ies *ies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2248)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2249) rcu_read_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2250) ies = rcu_dereference(cbss->ies);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2251) if (ies) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2252) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2253)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2254) ret = cfg80211_get_p2p_attr(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2255) ies->data, ies->len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2256) IEEE80211_P2P_ATTR_ABSENCE_NOTICE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2257) (u8 *) &bss_conf->p2p_noa_attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2258) sizeof(bss_conf->p2p_noa_attr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2259) if (ret >= 2) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2260) sdata->u.mgd.p2p_noa_index =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2261) bss_conf->p2p_noa_attr.index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2262) bss_info_changed |= BSS_CHANGED_P2P_PS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2263) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2264) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2265) rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2266) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2267)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2268) /* just to be sure */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2269) ieee80211_stop_poll(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2270)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2271) ieee80211_led_assoc(local, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2272)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2273) if (sdata->u.mgd.have_beacon) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2274) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2275) * If the AP is buggy we may get here with no DTIM period
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2276) * known, so assume it's 1 which is the only safe assumption
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2277) * in that case, although if the TIM IE is broken powersave
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2278) * probably just won't work at all.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2279) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2280) bss_conf->dtim_period = sdata->u.mgd.dtim_period ?: 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2281) bss_conf->beacon_rate = bss->beacon_rate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2282) bss_info_changed |= BSS_CHANGED_BEACON_INFO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2283) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2284) bss_conf->beacon_rate = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2285) bss_conf->dtim_period = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2286) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2287)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2288) bss_conf->assoc = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2289)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2290) /* Tell the driver to monitor connection quality (if supported) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2291) if (sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2292) bss_conf->cqm_rssi_thold)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2293) bss_info_changed |= BSS_CHANGED_CQM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2294)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2295) /* Enable ARP filtering */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2296) if (bss_conf->arp_addr_cnt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2297) bss_info_changed |= BSS_CHANGED_ARP_FILTER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2298)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2299) ieee80211_bss_info_change_notify(sdata, bss_info_changed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2300)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2301) mutex_lock(&local->iflist_mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2302) ieee80211_recalc_ps(local);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2303) mutex_unlock(&local->iflist_mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2304)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2305) ieee80211_recalc_smps(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2306) ieee80211_recalc_ps_vif(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2307)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2308) netif_carrier_on(sdata->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2309) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2310)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2311) static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2312) u16 stype, u16 reason, bool tx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2313) u8 *frame_buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2314) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2315) struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2316) struct ieee80211_local *local = sdata->local;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2317) u32 changed = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2318)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2319) sdata_assert_lock(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2320)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2321) if (WARN_ON_ONCE(tx && !frame_buf))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2322) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2323)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2324) if (WARN_ON(!ifmgd->associated))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2325) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2326)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2327) ieee80211_stop_poll(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2328)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2329) ifmgd->associated = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2330) netif_carrier_off(sdata->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2331)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2332) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2333) * if we want to get out of ps before disassoc (why?) we have
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2334) * to do it before sending disassoc, as otherwise the null-packet
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2335) * won't be valid.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2336) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2337) if (local->hw.conf.flags & IEEE80211_CONF_PS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2338) local->hw.conf.flags &= ~IEEE80211_CONF_PS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2339) ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2340) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2341) local->ps_sdata = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2342)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2343) /* disable per-vif ps */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2344) ieee80211_recalc_ps_vif(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2345)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2346) /* make sure ongoing transmission finishes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2347) synchronize_net();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2348)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2349) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2350) * drop any frame before deauth/disassoc, this can be data or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2351) * management frame. Since we are disconnecting, we should not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2352) * insist sending these frames which can take time and delay
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2353) * the disconnection and possible the roaming.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2354) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2355) if (tx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2356) ieee80211_flush_queues(local, sdata, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2357)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2358) /* deauthenticate/disassociate now */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2359) if (tx || frame_buf) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2360) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2361) * In multi channel scenarios guarantee that the virtual
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2362) * interface is granted immediate airtime to transmit the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2363) * deauthentication frame by calling mgd_prepare_tx, if the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2364) * driver requested so.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2365) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2366) if (ieee80211_hw_check(&local->hw, DEAUTH_NEED_MGD_TX_PREP) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2367) !ifmgd->have_beacon)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2368) drv_mgd_prepare_tx(sdata->local, sdata, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2369)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2370) ieee80211_send_deauth_disassoc(sdata, ifmgd->bssid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2371) ifmgd->bssid, stype, reason,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2372) tx, frame_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2373) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2374)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2375) /* flush out frame - make sure the deauth was actually sent */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2376) if (tx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2377) ieee80211_flush_queues(local, sdata, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2378)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2379) /* clear bssid only after building the needed mgmt frames */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2380) eth_zero_addr(ifmgd->bssid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2381)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2382) /* remove AP and TDLS peers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2383) sta_info_flush(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2384)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2385) /* finally reset all BSS / config parameters */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2386) changed |= ieee80211_reset_erp_info(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2387)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2388) ieee80211_led_assoc(local, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2389) changed |= BSS_CHANGED_ASSOC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2390) sdata->vif.bss_conf.assoc = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2391)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2392) ifmgd->p2p_noa_index = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2393) memset(&sdata->vif.bss_conf.p2p_noa_attr, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2394) sizeof(sdata->vif.bss_conf.p2p_noa_attr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2395)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2396) /* on the next assoc, re-program HT/VHT parameters */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2397) memset(&ifmgd->ht_capa, 0, sizeof(ifmgd->ht_capa));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2398) memset(&ifmgd->ht_capa_mask, 0, sizeof(ifmgd->ht_capa_mask));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2399) memset(&ifmgd->vht_capa, 0, sizeof(ifmgd->vht_capa));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2400) memset(&ifmgd->vht_capa_mask, 0, sizeof(ifmgd->vht_capa_mask));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2401)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2402) /* reset MU-MIMO ownership and group data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2403) memset(sdata->vif.bss_conf.mu_group.membership, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2404) sizeof(sdata->vif.bss_conf.mu_group.membership));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2405) memset(sdata->vif.bss_conf.mu_group.position, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2406) sizeof(sdata->vif.bss_conf.mu_group.position));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2407) changed |= BSS_CHANGED_MU_GROUPS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2408) sdata->vif.mu_mimo_owner = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2409)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2410) sdata->ap_power_level = IEEE80211_UNSET_POWER_LEVEL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2411)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2412) del_timer_sync(&local->dynamic_ps_timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2413) cancel_work_sync(&local->dynamic_ps_enable_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2414)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2415) /* Disable ARP filtering */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2416) if (sdata->vif.bss_conf.arp_addr_cnt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2417) changed |= BSS_CHANGED_ARP_FILTER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2418)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2419) sdata->vif.bss_conf.qos = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2420) changed |= BSS_CHANGED_QOS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2421)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2422) /* The BSSID (not really interesting) and HT changed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2423) changed |= BSS_CHANGED_BSSID | BSS_CHANGED_HT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2424) ieee80211_bss_info_change_notify(sdata, changed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2425)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2426) /* disassociated - set to defaults now */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2427) ieee80211_set_wmm_default(sdata, false, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2428)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2429) del_timer_sync(&sdata->u.mgd.conn_mon_timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2430) del_timer_sync(&sdata->u.mgd.bcn_mon_timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2431) del_timer_sync(&sdata->u.mgd.timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2432) del_timer_sync(&sdata->u.mgd.chswitch_timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2433)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2434) sdata->vif.bss_conf.dtim_period = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2435) sdata->vif.bss_conf.beacon_rate = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2436)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2437) ifmgd->have_beacon = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2438)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2439) ifmgd->flags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2440) mutex_lock(&local->mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2441) ieee80211_vif_release_channel(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2442)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2443) sdata->vif.csa_active = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2444) ifmgd->csa_waiting_bcn = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2445) ifmgd->csa_ignored_same_chan = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2446) if (sdata->csa_block_tx) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2447) ieee80211_wake_vif_queues(local, sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2448) IEEE80211_QUEUE_STOP_REASON_CSA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2449) sdata->csa_block_tx = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2450) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2451) mutex_unlock(&local->mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2452)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2453) /* existing TX TSPEC sessions no longer exist */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2454) memset(ifmgd->tx_tspec, 0, sizeof(ifmgd->tx_tspec));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2455) cancel_delayed_work_sync(&ifmgd->tx_tspec_wk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2456)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2457) sdata->encrypt_headroom = IEEE80211_ENCRYPT_HEADROOM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2458) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2459)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2460) static void ieee80211_reset_ap_probe(struct ieee80211_sub_if_data *sdata)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2461) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2462) struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2463) struct ieee80211_local *local = sdata->local;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2464)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2465) mutex_lock(&local->mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2466) if (!(ifmgd->flags & IEEE80211_STA_CONNECTION_POLL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2467) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2468)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2469) __ieee80211_stop_poll(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2470)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2471) mutex_lock(&local->iflist_mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2472) ieee80211_recalc_ps(local);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2473) mutex_unlock(&local->iflist_mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2474)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2475) if (ieee80211_hw_check(&sdata->local->hw, CONNECTION_MONITOR))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2476) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2477)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2478) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2479) * We've received a probe response, but are not sure whether
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2480) * we have or will be receiving any beacons or data, so let's
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2481) * schedule the timers again, just in case.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2482) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2483) ieee80211_sta_reset_beacon_monitor(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2484)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2485) mod_timer(&ifmgd->conn_mon_timer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2486) round_jiffies_up(jiffies +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2487) IEEE80211_CONNECTION_IDLE_TIME));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2488) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2489) mutex_unlock(&local->mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2490) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2491)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2492) static void ieee80211_sta_tx_wmm_ac_notify(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2493) struct ieee80211_hdr *hdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2494) u16 tx_time)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2495) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2496) struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2497) u16 tid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2498) int ac;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2499) struct ieee80211_sta_tx_tspec *tx_tspec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2500) unsigned long now = jiffies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2501)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2502) if (!ieee80211_is_data_qos(hdr->frame_control))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2503) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2504)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2505) tid = ieee80211_get_tid(hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2506) ac = ieee80211_ac_from_tid(tid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2507) tx_tspec = &ifmgd->tx_tspec[ac];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2508)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2509) if (likely(!tx_tspec->admitted_time))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2510) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2511)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2512) if (time_after(now, tx_tspec->time_slice_start + HZ)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2513) tx_tspec->consumed_tx_time = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2514) tx_tspec->time_slice_start = now;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2515)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2516) if (tx_tspec->downgraded) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2517) tx_tspec->action = TX_TSPEC_ACTION_STOP_DOWNGRADE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2518) schedule_delayed_work(&ifmgd->tx_tspec_wk, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2519) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2520) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2521)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2522) if (tx_tspec->downgraded)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2523) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2524)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2525) tx_tspec->consumed_tx_time += tx_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2526)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2527) if (tx_tspec->consumed_tx_time >= tx_tspec->admitted_time) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2528) tx_tspec->downgraded = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2529) tx_tspec->action = TX_TSPEC_ACTION_DOWNGRADE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2530) schedule_delayed_work(&ifmgd->tx_tspec_wk, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2531) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2532) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2533)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2534) void ieee80211_sta_tx_notify(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2535) struct ieee80211_hdr *hdr, bool ack, u16 tx_time)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2536) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2537) ieee80211_sta_tx_wmm_ac_notify(sdata, hdr, tx_time);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2538)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2539) if (!ieee80211_is_any_nullfunc(hdr->frame_control) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2540) !sdata->u.mgd.probe_send_count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2541) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2542)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2543) if (ack)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2544) sdata->u.mgd.probe_send_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2545) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2546) sdata->u.mgd.nullfunc_failed = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2547) ieee80211_queue_work(&sdata->local->hw, &sdata->work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2548) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2549)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2550) static void ieee80211_mlme_send_probe_req(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2551) const u8 *src, const u8 *dst,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2552) const u8 *ssid, size_t ssid_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2553) struct ieee80211_channel *channel)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2554) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2555) struct sk_buff *skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2556)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2557) skb = ieee80211_build_probe_req(sdata, src, dst, (u32)-1, channel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2558) ssid, ssid_len, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2559) IEEE80211_PROBE_FLAG_DIRECTED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2560) if (skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2561) ieee80211_tx_skb(sdata, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2562) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2563)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2564) static void ieee80211_mgd_probe_ap_send(struct ieee80211_sub_if_data *sdata)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2565) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2566) struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2567) const u8 *ssid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2568) u8 *dst = ifmgd->associated->bssid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2569) u8 unicast_limit = max(1, max_probe_tries - 3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2570) struct sta_info *sta;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2571)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2572) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2573) * Try sending broadcast probe requests for the last three
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2574) * probe requests after the first ones failed since some
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2575) * buggy APs only support broadcast probe requests.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2576) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2577) if (ifmgd->probe_send_count >= unicast_limit)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2578) dst = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2579)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2580) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2581) * When the hardware reports an accurate Tx ACK status, it's
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2582) * better to send a nullfunc frame instead of a probe request,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2583) * as it will kick us off the AP quickly if we aren't associated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2584) * anymore. The timeout will be reset if the frame is ACKed by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2585) * the AP.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2586) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2587) ifmgd->probe_send_count++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2588)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2589) if (dst) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2590) mutex_lock(&sdata->local->sta_mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2591) sta = sta_info_get(sdata, dst);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2592) if (!WARN_ON(!sta))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2593) ieee80211_check_fast_rx(sta);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2594) mutex_unlock(&sdata->local->sta_mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2595) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2596)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2597) if (ieee80211_hw_check(&sdata->local->hw, REPORTS_TX_ACK_STATUS)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2598) ifmgd->nullfunc_failed = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2599) if (!(ifmgd->flags & IEEE80211_STA_DISABLE_HE))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2600) ifmgd->probe_send_count--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2601) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2602) ieee80211_send_nullfunc(sdata->local, sdata, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2603) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2604) int ssid_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2605)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2606) rcu_read_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2607) ssid = ieee80211_bss_get_ie(ifmgd->associated, WLAN_EID_SSID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2608) if (WARN_ON_ONCE(ssid == NULL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2609) ssid_len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2610) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2611) ssid_len = ssid[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2612)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2613) ieee80211_mlme_send_probe_req(sdata, sdata->vif.addr, dst,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2614) ssid + 2, ssid_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2615) ifmgd->associated->channel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2616) rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2617) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2618)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2619) ifmgd->probe_timeout = jiffies + msecs_to_jiffies(probe_wait_ms);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2620) run_again(sdata, ifmgd->probe_timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2621) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2622)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2623) static void ieee80211_mgd_probe_ap(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2624) bool beacon)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2625) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2626) struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2627) bool already = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2628)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2629) if (!ieee80211_sdata_running(sdata))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2630) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2631)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2632) sdata_lock(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2633)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2634) if (!ifmgd->associated)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2635) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2636)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2637) mutex_lock(&sdata->local->mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2638)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2639) if (sdata->local->tmp_channel || sdata->local->scanning) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2640) mutex_unlock(&sdata->local->mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2641) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2642) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2643)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2644) if (beacon) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2645) mlme_dbg_ratelimited(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2646) "detected beacon loss from AP (missed %d beacons) - probing\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2647) beacon_loss_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2648)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2649) ieee80211_cqm_beacon_loss_notify(&sdata->vif, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2650) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2651)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2652) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2653) * The driver/our work has already reported this event or the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2654) * connection monitoring has kicked in and we have already sent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2655) * a probe request. Or maybe the AP died and the driver keeps
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2656) * reporting until we disassociate...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2657) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2658) * In either case we have to ignore the current call to this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2659) * function (except for setting the correct probe reason bit)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2660) * because otherwise we would reset the timer every time and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2661) * never check whether we received a probe response!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2662) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2663) if (ifmgd->flags & IEEE80211_STA_CONNECTION_POLL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2664) already = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2665)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2666) ifmgd->flags |= IEEE80211_STA_CONNECTION_POLL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2667)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2668) mutex_unlock(&sdata->local->mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2669)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2670) if (already)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2671) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2672)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2673) mutex_lock(&sdata->local->iflist_mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2674) ieee80211_recalc_ps(sdata->local);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2675) mutex_unlock(&sdata->local->iflist_mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2676)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2677) ifmgd->probe_send_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2678) ieee80211_mgd_probe_ap_send(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2679) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2680) sdata_unlock(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2681) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2682)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2683) struct sk_buff *ieee80211_ap_probereq_get(struct ieee80211_hw *hw,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2684) struct ieee80211_vif *vif)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2685) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2686) struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2687) struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2688) struct cfg80211_bss *cbss;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2689) struct sk_buff *skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2690) const u8 *ssid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2691) int ssid_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2692)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2693) if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_STATION))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2694) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2695)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2696) sdata_assert_lock(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2697)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2698) if (ifmgd->associated)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2699) cbss = ifmgd->associated;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2700) else if (ifmgd->auth_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2701) cbss = ifmgd->auth_data->bss;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2702) else if (ifmgd->assoc_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2703) cbss = ifmgd->assoc_data->bss;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2704) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2705) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2706)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2707) rcu_read_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2708) ssid = ieee80211_bss_get_ie(cbss, WLAN_EID_SSID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2709) if (WARN_ONCE(!ssid || ssid[1] > IEEE80211_MAX_SSID_LEN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2710) "invalid SSID element (len=%d)", ssid ? ssid[1] : -1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2711) ssid_len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2712) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2713) ssid_len = ssid[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2714)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2715) skb = ieee80211_build_probe_req(sdata, sdata->vif.addr, cbss->bssid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2716) (u32) -1, cbss->channel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2717) ssid + 2, ssid_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2718) NULL, 0, IEEE80211_PROBE_FLAG_DIRECTED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2719) rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2720)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2721) return skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2722) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2723) EXPORT_SYMBOL(ieee80211_ap_probereq_get);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2724)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2725) static void ieee80211_report_disconnect(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2726) const u8 *buf, size_t len, bool tx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2727) u16 reason)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2728) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2729) struct ieee80211_event event = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2730) .type = MLME_EVENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2731) .u.mlme.data = tx ? DEAUTH_TX_EVENT : DEAUTH_RX_EVENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2732) .u.mlme.reason = reason,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2733) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2734)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2735) if (tx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2736) cfg80211_tx_mlme_mgmt(sdata->dev, buf, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2737) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2738) cfg80211_rx_mlme_mgmt(sdata->dev, buf, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2739)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2740) drv_event_callback(sdata->local, sdata, &event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2741) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2742)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2743) static void __ieee80211_disconnect(struct ieee80211_sub_if_data *sdata)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2744) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2745) struct ieee80211_local *local = sdata->local;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2746) struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2747) u8 frame_buf[IEEE80211_DEAUTH_FRAME_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2748) bool tx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2749)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2750) sdata_lock(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2751) if (!ifmgd->associated) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2752) sdata_unlock(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2753) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2754) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2755)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2756) tx = !sdata->csa_block_tx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2757)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2758) /* AP is probably out of range (or not reachable for another reason) so
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2759) * remove the bss struct for that AP.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2760) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2761) cfg80211_unlink_bss(local->hw.wiphy, ifmgd->associated);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2762)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2763) ieee80211_set_disassoc(sdata, IEEE80211_STYPE_DEAUTH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2764) WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2765) tx, frame_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2766) mutex_lock(&local->mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2767) sdata->vif.csa_active = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2768) ifmgd->csa_waiting_bcn = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2769) if (sdata->csa_block_tx) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2770) ieee80211_wake_vif_queues(local, sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2771) IEEE80211_QUEUE_STOP_REASON_CSA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2772) sdata->csa_block_tx = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2773) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2774) mutex_unlock(&local->mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2775)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2776) ieee80211_report_disconnect(sdata, frame_buf, sizeof(frame_buf), tx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2777) WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2778)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2779) sdata_unlock(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2780) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2781)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2782) static void ieee80211_beacon_connection_loss_work(struct work_struct *work)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2783) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2784) struct ieee80211_sub_if_data *sdata =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2785) container_of(work, struct ieee80211_sub_if_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2786) u.mgd.beacon_connection_loss_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2787) struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2788)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2789) if (ifmgd->associated)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2790) ifmgd->beacon_loss_count++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2791)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2792) if (ifmgd->connection_loss) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2793) sdata_info(sdata, "Connection to AP %pM lost\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2794) ifmgd->bssid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2795) __ieee80211_disconnect(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2796) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2797) ieee80211_mgd_probe_ap(sdata, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2798) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2799) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2800)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2801) static void ieee80211_csa_connection_drop_work(struct work_struct *work)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2802) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2803) struct ieee80211_sub_if_data *sdata =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2804) container_of(work, struct ieee80211_sub_if_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2805) u.mgd.csa_connection_drop_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2806)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2807) __ieee80211_disconnect(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2808) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2809)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2810) void ieee80211_beacon_loss(struct ieee80211_vif *vif)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2811) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2812) struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2813) struct ieee80211_hw *hw = &sdata->local->hw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2814)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2815) trace_api_beacon_loss(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2816)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2817) sdata->u.mgd.connection_loss = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2818) ieee80211_queue_work(hw, &sdata->u.mgd.beacon_connection_loss_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2819) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2820) EXPORT_SYMBOL(ieee80211_beacon_loss);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2821)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2822) void ieee80211_connection_loss(struct ieee80211_vif *vif)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2823) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2824) struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2825) struct ieee80211_hw *hw = &sdata->local->hw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2826)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2827) trace_api_connection_loss(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2828)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2829) sdata->u.mgd.connection_loss = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2830) ieee80211_queue_work(hw, &sdata->u.mgd.beacon_connection_loss_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2831) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2832) EXPORT_SYMBOL(ieee80211_connection_loss);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2833)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2834)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2835) static void ieee80211_destroy_auth_data(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2836) bool assoc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2837) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2838) struct ieee80211_mgd_auth_data *auth_data = sdata->u.mgd.auth_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2839)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2840) sdata_assert_lock(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2841)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2842) if (!assoc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2843) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2844) * we are not authenticated yet, the only timer that could be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2845) * running is the timeout for the authentication response which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2846) * which is not relevant anymore.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2847) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2848) del_timer_sync(&sdata->u.mgd.timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2849) sta_info_destroy_addr(sdata, auth_data->bss->bssid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2850)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2851) eth_zero_addr(sdata->u.mgd.bssid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2852) ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BSSID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2853) sdata->u.mgd.flags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2854) mutex_lock(&sdata->local->mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2855) ieee80211_vif_release_channel(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2856) mutex_unlock(&sdata->local->mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2857) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2858)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2859) cfg80211_put_bss(sdata->local->hw.wiphy, auth_data->bss);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2860) kfree(auth_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2861) sdata->u.mgd.auth_data = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2862) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2863)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2864) static void ieee80211_destroy_assoc_data(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2865) bool assoc, bool abandon)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2866) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2867) struct ieee80211_mgd_assoc_data *assoc_data = sdata->u.mgd.assoc_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2868)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2869) sdata_assert_lock(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2870)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2871) if (!assoc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2872) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2873) * we are not associated yet, the only timer that could be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2874) * running is the timeout for the association response which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2875) * which is not relevant anymore.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2876) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2877) del_timer_sync(&sdata->u.mgd.timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2878) sta_info_destroy_addr(sdata, assoc_data->bss->bssid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2879)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2880) eth_zero_addr(sdata->u.mgd.bssid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2881) ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BSSID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2882) sdata->u.mgd.flags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2883) sdata->vif.mu_mimo_owner = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2884)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2885) mutex_lock(&sdata->local->mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2886) ieee80211_vif_release_channel(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2887) mutex_unlock(&sdata->local->mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2888)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2889) if (abandon)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2890) cfg80211_abandon_assoc(sdata->dev, assoc_data->bss);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2891) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2892)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2893) kfree(assoc_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2894) sdata->u.mgd.assoc_data = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2895) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2896)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2897) static void ieee80211_auth_challenge(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2898) struct ieee80211_mgmt *mgmt, size_t len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2899) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2900) struct ieee80211_local *local = sdata->local;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2901) struct ieee80211_mgd_auth_data *auth_data = sdata->u.mgd.auth_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2902) u8 *pos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2903) struct ieee802_11_elems elems;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2904) u32 tx_flags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2905)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2906) pos = mgmt->u.auth.variable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2907) ieee802_11_parse_elems(pos, len - (pos - (u8 *)mgmt), false, &elems,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2908) mgmt->bssid, auth_data->bss->bssid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2909) if (!elems.challenge)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2910) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2911) auth_data->expected_transaction = 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2912) drv_mgd_prepare_tx(sdata->local, sdata, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2913) if (ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2914) tx_flags = IEEE80211_TX_CTL_REQ_TX_STATUS |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2915) IEEE80211_TX_INTFL_MLME_CONN_TX;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2916) ieee80211_send_auth(sdata, 3, auth_data->algorithm, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2917) elems.challenge - 2, elems.challenge_len + 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2918) auth_data->bss->bssid, auth_data->bss->bssid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2919) auth_data->key, auth_data->key_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2920) auth_data->key_idx, tx_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2921) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2922)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2923) static bool ieee80211_mark_sta_auth(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2924) const u8 *bssid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2925) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2926) struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2927) struct sta_info *sta;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2928) bool result = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2929)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2930) sdata_info(sdata, "authenticated\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2931) ifmgd->auth_data->done = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2932) ifmgd->auth_data->timeout = jiffies + IEEE80211_AUTH_WAIT_ASSOC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2933) ifmgd->auth_data->timeout_started = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2934) run_again(sdata, ifmgd->auth_data->timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2935)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2936) /* move station state to auth */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2937) mutex_lock(&sdata->local->sta_mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2938) sta = sta_info_get(sdata, bssid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2939) if (!sta) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2940) WARN_ONCE(1, "%s: STA %pM not found", sdata->name, bssid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2941) result = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2942) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2943) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2944) if (sta_info_move_state(sta, IEEE80211_STA_AUTH)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2945) sdata_info(sdata, "failed moving %pM to auth\n", bssid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2946) result = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2947) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2948) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2949)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2950) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2951) mutex_unlock(&sdata->local->sta_mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2952) return result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2953) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2954)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2955) static void ieee80211_rx_mgmt_auth(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2956) struct ieee80211_mgmt *mgmt, size_t len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2957) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2958) struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2959) u8 bssid[ETH_ALEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2960) u16 auth_alg, auth_transaction, status_code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2961) struct ieee80211_event event = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2962) .type = MLME_EVENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2963) .u.mlme.data = AUTH_EVENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2964) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2965)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2966) sdata_assert_lock(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2967)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2968) if (len < 24 + 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2969) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2970)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2971) if (!ifmgd->auth_data || ifmgd->auth_data->done)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2972) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2973)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2974) memcpy(bssid, ifmgd->auth_data->bss->bssid, ETH_ALEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2975)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2976) if (!ether_addr_equal(bssid, mgmt->bssid))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2977) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2978)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2979) auth_alg = le16_to_cpu(mgmt->u.auth.auth_alg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2980) auth_transaction = le16_to_cpu(mgmt->u.auth.auth_transaction);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2981) status_code = le16_to_cpu(mgmt->u.auth.status_code);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2982)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2983) if (auth_alg != ifmgd->auth_data->algorithm ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2984) (auth_alg != WLAN_AUTH_SAE &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2985) auth_transaction != ifmgd->auth_data->expected_transaction) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2986) (auth_alg == WLAN_AUTH_SAE &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2987) (auth_transaction < ifmgd->auth_data->expected_transaction ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2988) auth_transaction > 2))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2989) sdata_info(sdata, "%pM unexpected authentication state: alg %d (expected %d) transact %d (expected %d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2990) mgmt->sa, auth_alg, ifmgd->auth_data->algorithm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2991) auth_transaction,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2992) ifmgd->auth_data->expected_transaction);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2993) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2994) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2995)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2996) if (status_code != WLAN_STATUS_SUCCESS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2997) cfg80211_rx_mlme_mgmt(sdata->dev, (u8 *)mgmt, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2998)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2999) if (auth_alg == WLAN_AUTH_SAE &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3000) (status_code == WLAN_STATUS_ANTI_CLOG_REQUIRED ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3001) (auth_transaction == 1 &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3002) (status_code == WLAN_STATUS_SAE_HASH_TO_ELEMENT ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3003) status_code == WLAN_STATUS_SAE_PK)))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3004) /* waiting for userspace now */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3005) ifmgd->auth_data->waiting = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3006) ifmgd->auth_data->timeout =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3007) jiffies + IEEE80211_AUTH_WAIT_SAE_RETRY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3008) ifmgd->auth_data->timeout_started = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3009) run_again(sdata, ifmgd->auth_data->timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3010) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3011) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3012)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3013) sdata_info(sdata, "%pM denied authentication (status %d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3014) mgmt->sa, status_code);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3015) ieee80211_destroy_auth_data(sdata, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3016) event.u.mlme.status = MLME_DENIED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3017) event.u.mlme.reason = status_code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3018) drv_event_callback(sdata->local, sdata, &event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3019) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3020) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3021)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3022) switch (ifmgd->auth_data->algorithm) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3023) case WLAN_AUTH_OPEN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3024) case WLAN_AUTH_LEAP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3025) case WLAN_AUTH_FT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3026) case WLAN_AUTH_SAE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3027) case WLAN_AUTH_FILS_SK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3028) case WLAN_AUTH_FILS_SK_PFS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3029) case WLAN_AUTH_FILS_PK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3030) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3031) case WLAN_AUTH_SHARED_KEY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3032) if (ifmgd->auth_data->expected_transaction != 4) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3033) ieee80211_auth_challenge(sdata, mgmt, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3034) /* need another frame */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3035) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3036) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3037) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3038) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3039) WARN_ONCE(1, "invalid auth alg %d",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3040) ifmgd->auth_data->algorithm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3041) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3042) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3043)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3044) event.u.mlme.status = MLME_SUCCESS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3045) drv_event_callback(sdata->local, sdata, &event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3046) if (ifmgd->auth_data->algorithm != WLAN_AUTH_SAE ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3047) (auth_transaction == 2 &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3048) ifmgd->auth_data->expected_transaction == 2)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3049) if (!ieee80211_mark_sta_auth(sdata, bssid))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3050) return; /* ignore frame -- wait for timeout */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3051) } else if (ifmgd->auth_data->algorithm == WLAN_AUTH_SAE &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3052) auth_transaction == 2) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3053) sdata_info(sdata, "SAE peer confirmed\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3054) ifmgd->auth_data->peer_confirmed = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3055) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3056)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3057) cfg80211_rx_mlme_mgmt(sdata->dev, (u8 *)mgmt, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3058) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3059)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3060) #define case_WLAN(type) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3061) case WLAN_REASON_##type: return #type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3062)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3063) const char *ieee80211_get_reason_code_string(u16 reason_code)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3064) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3065) switch (reason_code) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3066) case_WLAN(UNSPECIFIED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3067) case_WLAN(PREV_AUTH_NOT_VALID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3068) case_WLAN(DEAUTH_LEAVING);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3069) case_WLAN(DISASSOC_DUE_TO_INACTIVITY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3070) case_WLAN(DISASSOC_AP_BUSY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3071) case_WLAN(CLASS2_FRAME_FROM_NONAUTH_STA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3072) case_WLAN(CLASS3_FRAME_FROM_NONASSOC_STA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3073) case_WLAN(DISASSOC_STA_HAS_LEFT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3074) case_WLAN(STA_REQ_ASSOC_WITHOUT_AUTH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3075) case_WLAN(DISASSOC_BAD_POWER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3076) case_WLAN(DISASSOC_BAD_SUPP_CHAN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3077) case_WLAN(INVALID_IE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3078) case_WLAN(MIC_FAILURE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3079) case_WLAN(4WAY_HANDSHAKE_TIMEOUT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3080) case_WLAN(GROUP_KEY_HANDSHAKE_TIMEOUT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3081) case_WLAN(IE_DIFFERENT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3082) case_WLAN(INVALID_GROUP_CIPHER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3083) case_WLAN(INVALID_PAIRWISE_CIPHER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3084) case_WLAN(INVALID_AKMP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3085) case_WLAN(UNSUPP_RSN_VERSION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3086) case_WLAN(INVALID_RSN_IE_CAP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3087) case_WLAN(IEEE8021X_FAILED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3088) case_WLAN(CIPHER_SUITE_REJECTED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3089) case_WLAN(DISASSOC_UNSPECIFIED_QOS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3090) case_WLAN(DISASSOC_QAP_NO_BANDWIDTH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3091) case_WLAN(DISASSOC_LOW_ACK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3092) case_WLAN(DISASSOC_QAP_EXCEED_TXOP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3093) case_WLAN(QSTA_LEAVE_QBSS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3094) case_WLAN(QSTA_NOT_USE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3095) case_WLAN(QSTA_REQUIRE_SETUP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3096) case_WLAN(QSTA_TIMEOUT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3097) case_WLAN(QSTA_CIPHER_NOT_SUPP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3098) case_WLAN(MESH_PEER_CANCELED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3099) case_WLAN(MESH_MAX_PEERS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3100) case_WLAN(MESH_CONFIG);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3101) case_WLAN(MESH_CLOSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3102) case_WLAN(MESH_MAX_RETRIES);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3103) case_WLAN(MESH_CONFIRM_TIMEOUT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3104) case_WLAN(MESH_INVALID_GTK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3105) case_WLAN(MESH_INCONSISTENT_PARAM);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3106) case_WLAN(MESH_INVALID_SECURITY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3107) case_WLAN(MESH_PATH_ERROR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3108) case_WLAN(MESH_PATH_NOFORWARD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3109) case_WLAN(MESH_PATH_DEST_UNREACHABLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3110) case_WLAN(MAC_EXISTS_IN_MBSS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3111) case_WLAN(MESH_CHAN_REGULATORY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3112) case_WLAN(MESH_CHAN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3113) default: return "<unknown>";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3114) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3115) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3117) static void ieee80211_rx_mgmt_deauth(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3118) struct ieee80211_mgmt *mgmt, size_t len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3119) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3120) struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3121) u16 reason_code = le16_to_cpu(mgmt->u.deauth.reason_code);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3122)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3123) sdata_assert_lock(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3124)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3125) if (len < 24 + 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3126) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3127)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3128) if (!ether_addr_equal(mgmt->bssid, mgmt->sa)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3129) ieee80211_tdls_handle_disconnect(sdata, mgmt->sa, reason_code);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3130) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3131) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3133) if (ifmgd->associated &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3134) ether_addr_equal(mgmt->bssid, ifmgd->associated->bssid)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3135) const u8 *bssid = ifmgd->associated->bssid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3137) sdata_info(sdata, "deauthenticated from %pM (Reason: %u=%s)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3138) bssid, reason_code,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3139) ieee80211_get_reason_code_string(reason_code));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3140)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3141) ieee80211_set_disassoc(sdata, 0, 0, false, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3142)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3143) ieee80211_report_disconnect(sdata, (u8 *)mgmt, len, false,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3144) reason_code);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3145) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3146) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3147)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3148) if (ifmgd->assoc_data &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3149) ether_addr_equal(mgmt->bssid, ifmgd->assoc_data->bss->bssid)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3150) const u8 *bssid = ifmgd->assoc_data->bss->bssid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3152) sdata_info(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3153) "deauthenticated from %pM while associating (Reason: %u=%s)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3154) bssid, reason_code,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3155) ieee80211_get_reason_code_string(reason_code));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3157) ieee80211_destroy_assoc_data(sdata, false, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3159) cfg80211_rx_mlme_mgmt(sdata->dev, (u8 *)mgmt, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3160) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3161) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3162) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3163)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3164)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3165) static void ieee80211_rx_mgmt_disassoc(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3166) struct ieee80211_mgmt *mgmt, size_t len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3167) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3168) struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3169) u16 reason_code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3170)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3171) sdata_assert_lock(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3172)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3173) if (len < 24 + 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3174) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3176) if (!ifmgd->associated ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3177) !ether_addr_equal(mgmt->bssid, ifmgd->associated->bssid))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3178) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3179)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3180) reason_code = le16_to_cpu(mgmt->u.disassoc.reason_code);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3181)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3182) if (!ether_addr_equal(mgmt->bssid, mgmt->sa)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3183) ieee80211_tdls_handle_disconnect(sdata, mgmt->sa, reason_code);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3184) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3185) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3187) sdata_info(sdata, "disassociated from %pM (Reason: %u=%s)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3188) mgmt->sa, reason_code,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3189) ieee80211_get_reason_code_string(reason_code));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3190)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3191) ieee80211_set_disassoc(sdata, 0, 0, false, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3193) ieee80211_report_disconnect(sdata, (u8 *)mgmt, len, false, reason_code);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3194) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3195)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3196) static void ieee80211_get_rates(struct ieee80211_supported_band *sband,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3197) u8 *supp_rates, unsigned int supp_rates_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3198) u32 *rates, u32 *basic_rates,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3199) bool *have_higher_than_11mbit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3200) int *min_rate, int *min_rate_index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3201) int shift)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3202) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3203) int i, j;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3205) for (i = 0; i < supp_rates_len; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3206) int rate = supp_rates[i] & 0x7f;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3207) bool is_basic = !!(supp_rates[i] & 0x80);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3208)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3209) if ((rate * 5 * (1 << shift)) > 110)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3210) *have_higher_than_11mbit = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3211)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3212) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3213) * Skip HT, VHT and HE BSS membership selectors since they're
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3214) * not rates.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3215) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3216) * Note: Even though the membership selector and the basic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3217) * rate flag share the same bit, they are not exactly
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3218) * the same.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3219) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3220) if (supp_rates[i] == (0x80 | BSS_MEMBERSHIP_SELECTOR_HT_PHY) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3221) supp_rates[i] == (0x80 | BSS_MEMBERSHIP_SELECTOR_VHT_PHY) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3222) supp_rates[i] == (0x80 | BSS_MEMBERSHIP_SELECTOR_HE_PHY))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3223) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3224)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3225) for (j = 0; j < sband->n_bitrates; j++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3226) struct ieee80211_rate *br;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3227) int brate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3228)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3229) br = &sband->bitrates[j];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3230)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3231) brate = DIV_ROUND_UP(br->bitrate, (1 << shift) * 5);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3232) if (brate == rate) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3233) *rates |= BIT(j);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3234) if (is_basic)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3235) *basic_rates |= BIT(j);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3236) if ((rate * 5) < *min_rate) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3237) *min_rate = rate * 5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3238) *min_rate_index = j;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3239) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3240) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3241) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3242) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3243) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3244) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3245)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3246) static bool ieee80211_twt_req_supported(const struct sta_info *sta,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3247) const struct ieee802_11_elems *elems)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3248) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3249) if (elems->ext_capab_len < 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3250) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3251)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3252) if (!(elems->ext_capab[9] & WLAN_EXT_CAPA10_TWT_RESPONDER_SUPPORT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3253) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3254)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3255) return sta->sta.he_cap.he_cap_elem.mac_cap_info[0] &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3256) IEEE80211_HE_MAC_CAP0_TWT_RES;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3257) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3258)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3259) static int ieee80211_recalc_twt_req(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3260) struct sta_info *sta,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3261) struct ieee802_11_elems *elems)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3262) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3263) bool twt = ieee80211_twt_req_supported(sta, elems);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3264)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3265) if (sdata->vif.bss_conf.twt_requester != twt) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3266) sdata->vif.bss_conf.twt_requester = twt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3267) return BSS_CHANGED_TWT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3268) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3269) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3270) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3271)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3272) static bool ieee80211_assoc_success(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3273) struct cfg80211_bss *cbss,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3274) struct ieee80211_mgmt *mgmt, size_t len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3275) struct ieee802_11_elems *elems)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3276) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3277) struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3278) struct ieee80211_local *local = sdata->local;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3279) struct ieee80211_supported_band *sband;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3280) struct sta_info *sta;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3281) u16 capab_info, aid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3282) struct ieee80211_bss_conf *bss_conf = &sdata->vif.bss_conf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3283) const struct cfg80211_bss_ies *bss_ies = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3284) struct ieee80211_mgd_assoc_data *assoc_data = ifmgd->assoc_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3285) bool is_6ghz = cbss->channel->band == NL80211_BAND_6GHZ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3286) bool is_s1g = cbss->channel->band == NL80211_BAND_S1GHZ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3287) u32 changed = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3288) u8 *pos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3289) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3290) bool ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3291)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3292) /* AssocResp and ReassocResp have identical structure */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3293)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3294) pos = mgmt->u.assoc_resp.variable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3295) aid = le16_to_cpu(mgmt->u.assoc_resp.aid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3296) if (is_s1g) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3297) pos = (u8 *) mgmt->u.s1g_assoc_resp.variable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3298) aid = 0; /* TODO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3299) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3300) capab_info = le16_to_cpu(mgmt->u.assoc_resp.capab_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3301) ieee802_11_parse_elems(pos, len - (pos - (u8 *)mgmt), false, elems,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3302) mgmt->bssid, assoc_data->bss->bssid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3303)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3304) if (elems->aid_resp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3305) aid = le16_to_cpu(elems->aid_resp->aid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3306)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3307) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3308) * The 5 MSB of the AID field are reserved
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3309) * (802.11-2016 9.4.1.8 AID field)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3310) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3311) aid &= 0x7ff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3312)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3313) ifmgd->broken_ap = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3314)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3315) if (aid == 0 || aid > IEEE80211_MAX_AID) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3316) sdata_info(sdata, "invalid AID value %d (out of range), turn off PS\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3317) aid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3318) aid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3319) ifmgd->broken_ap = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3320) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3321)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3322) if (!is_s1g && !elems->supp_rates) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3323) sdata_info(sdata, "no SuppRates element in AssocResp\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3324) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3325) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3326)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3327) sdata->vif.bss_conf.aid = aid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3328) ifmgd->tdls_chan_switch_prohibited =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3329) elems->ext_capab && elems->ext_capab_len >= 5 &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3330) (elems->ext_capab[4] & WLAN_EXT_CAPA5_TDLS_CH_SW_PROHIBITED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3331)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3332) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3333) * Some APs are erroneously not including some information in their
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3334) * (re)association response frames. Try to recover by using the data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3335) * from the beacon or probe response. This seems to afflict mobile
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3336) * 2G/3G/4G wifi routers, reported models include the "Onda PN51T",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3337) * "Vodafone PocketWiFi 2", "ZTE MF60" and a similar T-Mobile device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3338) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3339) if (!is_6ghz &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3340) ((assoc_data->wmm && !elems->wmm_param) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3341) (!(ifmgd->flags & IEEE80211_STA_DISABLE_HT) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3342) (!elems->ht_cap_elem || !elems->ht_operation)) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3343) (!(ifmgd->flags & IEEE80211_STA_DISABLE_VHT) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3344) (!elems->vht_cap_elem || !elems->vht_operation)))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3345) const struct cfg80211_bss_ies *ies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3346) struct ieee802_11_elems bss_elems;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3347)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3348) rcu_read_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3349) ies = rcu_dereference(cbss->ies);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3350) if (ies)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3351) bss_ies = kmemdup(ies, sizeof(*ies) + ies->len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3352) GFP_ATOMIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3353) rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3354) if (!bss_ies)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3355) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3356)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3357) ieee802_11_parse_elems(bss_ies->data, bss_ies->len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3358) false, &bss_elems,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3359) mgmt->bssid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3360) assoc_data->bss->bssid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3361) if (assoc_data->wmm &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3362) !elems->wmm_param && bss_elems.wmm_param) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3363) elems->wmm_param = bss_elems.wmm_param;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3364) sdata_info(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3365) "AP bug: WMM param missing from AssocResp\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3366) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3367)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3368) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3369) * Also check if we requested HT/VHT, otherwise the AP doesn't
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3370) * have to include the IEs in the (re)association response.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3371) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3372) if (!elems->ht_cap_elem && bss_elems.ht_cap_elem &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3373) !(ifmgd->flags & IEEE80211_STA_DISABLE_HT)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3374) elems->ht_cap_elem = bss_elems.ht_cap_elem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3375) sdata_info(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3376) "AP bug: HT capability missing from AssocResp\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3377) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3378) if (!elems->ht_operation && bss_elems.ht_operation &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3379) !(ifmgd->flags & IEEE80211_STA_DISABLE_HT)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3380) elems->ht_operation = bss_elems.ht_operation;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3381) sdata_info(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3382) "AP bug: HT operation missing from AssocResp\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3383) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3384) if (!elems->vht_cap_elem && bss_elems.vht_cap_elem &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3385) !(ifmgd->flags & IEEE80211_STA_DISABLE_VHT)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3386) elems->vht_cap_elem = bss_elems.vht_cap_elem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3387) sdata_info(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3388) "AP bug: VHT capa missing from AssocResp\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3389) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3390) if (!elems->vht_operation && bss_elems.vht_operation &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3391) !(ifmgd->flags & IEEE80211_STA_DISABLE_VHT)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3392) elems->vht_operation = bss_elems.vht_operation;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3393) sdata_info(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3394) "AP bug: VHT operation missing from AssocResp\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3395) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3396) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3397)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3398) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3399) * We previously checked these in the beacon/probe response, so
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3400) * they should be present here. This is just a safety net.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3401) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3402) if (!is_6ghz && !(ifmgd->flags & IEEE80211_STA_DISABLE_HT) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3403) (!elems->wmm_param || !elems->ht_cap_elem || !elems->ht_operation)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3404) sdata_info(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3405) "HT AP is missing WMM params or HT capability/operation\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3406) ret = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3407) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3408) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3409)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3410) if (!is_6ghz && !(ifmgd->flags & IEEE80211_STA_DISABLE_VHT) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3411) (!elems->vht_cap_elem || !elems->vht_operation)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3412) sdata_info(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3413) "VHT AP is missing VHT capability/operation\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3414) ret = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3415) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3416) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3417)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3418) if (is_6ghz && !(ifmgd->flags & IEEE80211_STA_DISABLE_HE) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3419) !elems->he_6ghz_capa) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3420) sdata_info(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3421) "HE 6 GHz AP is missing HE 6 GHz band capability\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3422) ret = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3423) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3424) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3425)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3426) mutex_lock(&sdata->local->sta_mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3427) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3428) * station info was already allocated and inserted before
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3429) * the association and should be available to us
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3430) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3431) sta = sta_info_get(sdata, cbss->bssid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3432) if (WARN_ON(!sta)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3433) mutex_unlock(&sdata->local->sta_mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3434) ret = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3435) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3436) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3437)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3438) sband = ieee80211_get_sband(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3439) if (!sband) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3440) mutex_unlock(&sdata->local->sta_mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3441) ret = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3442) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3443) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3444)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3445) if (!(ifmgd->flags & IEEE80211_STA_DISABLE_HE) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3446) (!elems->he_cap || !elems->he_operation)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3447) mutex_unlock(&sdata->local->sta_mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3448) sdata_info(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3449) "HE AP is missing HE capability/operation\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3450) ret = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3451) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3452) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3453)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3454) /* Set up internal HT/VHT capabilities */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3455) if (elems->ht_cap_elem && !(ifmgd->flags & IEEE80211_STA_DISABLE_HT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3456) ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3457) elems->ht_cap_elem, sta);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3458)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3459) if (elems->vht_cap_elem && !(ifmgd->flags & IEEE80211_STA_DISABLE_VHT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3460) ieee80211_vht_cap_ie_to_sta_vht_cap(sdata, sband,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3461) elems->vht_cap_elem, sta);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3462)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3463) if (elems->he_operation && !(ifmgd->flags & IEEE80211_STA_DISABLE_HE) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3464) elems->he_cap) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3465) ieee80211_he_cap_ie_to_sta_he_cap(sdata, sband,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3466) elems->he_cap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3467) elems->he_cap_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3468) elems->he_6ghz_capa,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3469) sta);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3470)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3471) bss_conf->he_support = sta->sta.he_cap.has_he;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3472) if (elems->rsnx && elems->rsnx_len &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3473) (elems->rsnx[0] & WLAN_RSNX_CAPA_PROTECTED_TWT) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3474) wiphy_ext_feature_isset(local->hw.wiphy,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3475) NL80211_EXT_FEATURE_PROTECTED_TWT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3476) bss_conf->twt_protected = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3477) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3478) bss_conf->twt_protected = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3479)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3480) changed |= ieee80211_recalc_twt_req(sdata, sta, elems);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3481) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3482) bss_conf->he_support = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3483) bss_conf->twt_requester = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3484) bss_conf->twt_protected = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3485) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3486)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3487) if (bss_conf->he_support) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3488) bss_conf->he_bss_color.color =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3489) le32_get_bits(elems->he_operation->he_oper_params,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3490) IEEE80211_HE_OPERATION_BSS_COLOR_MASK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3491) bss_conf->he_bss_color.partial =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3492) le32_get_bits(elems->he_operation->he_oper_params,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3493) IEEE80211_HE_OPERATION_PARTIAL_BSS_COLOR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3494) bss_conf->he_bss_color.enabled =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3495) !le32_get_bits(elems->he_operation->he_oper_params,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3496) IEEE80211_HE_OPERATION_BSS_COLOR_DISABLED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3497)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3498) if (bss_conf->he_bss_color.enabled)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3499) changed |= BSS_CHANGED_HE_BSS_COLOR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3500)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3501) bss_conf->htc_trig_based_pkt_ext =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3502) le32_get_bits(elems->he_operation->he_oper_params,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3503) IEEE80211_HE_OPERATION_DFLT_PE_DURATION_MASK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3504) bss_conf->frame_time_rts_th =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3505) le32_get_bits(elems->he_operation->he_oper_params,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3506) IEEE80211_HE_OPERATION_RTS_THRESHOLD_MASK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3507)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3508) bss_conf->multi_sta_back_32bit =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3509) sta->sta.he_cap.he_cap_elem.mac_cap_info[2] &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3510) IEEE80211_HE_MAC_CAP2_32BIT_BA_BITMAP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3511)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3512) bss_conf->ack_enabled =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3513) sta->sta.he_cap.he_cap_elem.mac_cap_info[2] &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3514) IEEE80211_HE_MAC_CAP2_ACK_EN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3515)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3516) bss_conf->uora_exists = !!elems->uora_element;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3517) if (elems->uora_element)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3518) bss_conf->uora_ocw_range = elems->uora_element[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3519)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3520) ieee80211_he_op_ie_to_bss_conf(&sdata->vif, elems->he_operation);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3521) ieee80211_he_spr_ie_to_bss_conf(&sdata->vif, elems->he_spr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3522) /* TODO: OPEN: what happens if BSS color disable is set? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3523) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3524)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3525) if (cbss->transmitted_bss) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3526) bss_conf->nontransmitted = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3527) ether_addr_copy(bss_conf->transmitter_bssid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3528) cbss->transmitted_bss->bssid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3529) bss_conf->bssid_indicator = cbss->max_bssid_indicator;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3530) bss_conf->bssid_index = cbss->bssid_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3531) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3532)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3533) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3534) * Some APs, e.g. Netgear WNDR3700, report invalid HT operation data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3535) * in their association response, so ignore that data for our own
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3536) * configuration. If it changed since the last beacon, we'll get the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3537) * next beacon and update then.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3538) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3539)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3540) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3541) * If an operating mode notification IE is present, override the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3542) * NSS calculation (that would be done in rate_control_rate_init())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3543) * and use the # of streams from that element.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3544) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3545) if (elems->opmode_notif &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3546) !(*elems->opmode_notif & IEEE80211_OPMODE_NOTIF_RX_NSS_TYPE_BF)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3547) u8 nss;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3548)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3549) nss = *elems->opmode_notif & IEEE80211_OPMODE_NOTIF_RX_NSS_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3550) nss >>= IEEE80211_OPMODE_NOTIF_RX_NSS_SHIFT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3551) nss += 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3552) sta->sta.rx_nss = nss;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3553) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3554)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3555) rate_control_rate_init(sta);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3556)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3557) if (ifmgd->flags & IEEE80211_STA_MFP_ENABLED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3558) set_sta_flag(sta, WLAN_STA_MFP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3559) sta->sta.mfp = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3560) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3561) sta->sta.mfp = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3562) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3563)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3564) sta->sta.wme = (elems->wmm_param || elems->s1g_capab) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3565) local->hw.queues >= IEEE80211_NUM_ACS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3566)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3567) err = sta_info_move_state(sta, IEEE80211_STA_ASSOC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3568) if (!err && !(ifmgd->flags & IEEE80211_STA_CONTROL_PORT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3569) err = sta_info_move_state(sta, IEEE80211_STA_AUTHORIZED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3570) if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3571) sdata_info(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3572) "failed to move station %pM to desired state\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3573) sta->sta.addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3574) WARN_ON(__sta_info_destroy(sta));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3575) mutex_unlock(&sdata->local->sta_mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3576) ret = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3577) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3578) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3579)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3580) if (sdata->wdev.use_4addr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3581) drv_sta_set_4addr(local, sdata, &sta->sta, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3582)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3583) mutex_unlock(&sdata->local->sta_mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3584)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3585) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3586) * Always handle WMM once after association regardless
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3587) * of the first value the AP uses. Setting -1 here has
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3588) * that effect because the AP values is an unsigned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3589) * 4-bit value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3590) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3591) ifmgd->wmm_last_param_set = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3592) ifmgd->mu_edca_last_param_set = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3593)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3594) if (ifmgd->flags & IEEE80211_STA_DISABLE_WMM) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3595) ieee80211_set_wmm_default(sdata, false, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3596) } else if (!ieee80211_sta_wmm_params(local, sdata, elems->wmm_param,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3597) elems->wmm_param_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3598) elems->mu_edca_param_set)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3599) /* still enable QoS since we might have HT/VHT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3600) ieee80211_set_wmm_default(sdata, false, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3601) /* set the disable-WMM flag in this case to disable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3602) * tracking WMM parameter changes in the beacon if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3603) * the parameters weren't actually valid. Doing so
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3604) * avoids changing parameters very strangely when
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3605) * the AP is going back and forth between valid and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3606) * invalid parameters.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3607) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3608) ifmgd->flags |= IEEE80211_STA_DISABLE_WMM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3609) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3610) changed |= BSS_CHANGED_QOS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3611)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3612) if (elems->max_idle_period_ie) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3613) bss_conf->max_idle_period =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3614) le16_to_cpu(elems->max_idle_period_ie->max_idle_period);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3615) bss_conf->protected_keep_alive =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3616) !!(elems->max_idle_period_ie->idle_options &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3617) WLAN_IDLE_OPTIONS_PROTECTED_KEEP_ALIVE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3618) changed |= BSS_CHANGED_KEEP_ALIVE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3619) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3620) bss_conf->max_idle_period = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3621) bss_conf->protected_keep_alive = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3622) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3623)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3624) /* set assoc capability (AID was already set earlier),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3625) * ieee80211_set_associated() will tell the driver */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3626) bss_conf->assoc_capability = capab_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3627) ieee80211_set_associated(sdata, cbss, changed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3628)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3629) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3630) * If we're using 4-addr mode, let the AP know that we're
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3631) * doing so, so that it can create the STA VLAN on its side
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3632) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3633) if (ifmgd->use_4addr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3634) ieee80211_send_4addr_nullfunc(local, sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3635)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3636) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3637) * Start timer to probe the connection to the AP now.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3638) * Also start the timer that will detect beacon loss.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3639) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3640) ieee80211_sta_reset_beacon_monitor(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3641) ieee80211_sta_reset_conn_monitor(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3642)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3643) ret = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3644) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3645) kfree(bss_ies);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3646) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3647) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3648)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3649) static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3650) struct ieee80211_mgmt *mgmt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3651) size_t len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3652) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3653) struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3654) struct ieee80211_mgd_assoc_data *assoc_data = ifmgd->assoc_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3655) u16 capab_info, status_code, aid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3656) struct ieee802_11_elems elems;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3657) int ac, uapsd_queues = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3658) u8 *pos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3659) bool reassoc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3660) struct cfg80211_bss *cbss;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3661) struct ieee80211_event event = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3662) .type = MLME_EVENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3663) .u.mlme.data = ASSOC_EVENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3664) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3665)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3666) sdata_assert_lock(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3667)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3668) if (!assoc_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3669) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3670)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3671) if (!ether_addr_equal(assoc_data->bss->bssid, mgmt->bssid))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3672) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3673)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3674) cbss = assoc_data->bss;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3675)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3676) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3677) * AssocResp and ReassocResp have identical structure, so process both
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3678) * of them in this function.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3679) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3680)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3681) if (len < 24 + 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3682) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3683)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3684) reassoc = ieee80211_is_reassoc_resp(mgmt->frame_control);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3685) capab_info = le16_to_cpu(mgmt->u.assoc_resp.capab_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3686) status_code = le16_to_cpu(mgmt->u.assoc_resp.status_code);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3687) pos = mgmt->u.assoc_resp.variable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3688) aid = le16_to_cpu(mgmt->u.assoc_resp.aid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3689) if (cbss->channel->band == NL80211_BAND_S1GHZ) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3690) pos = (u8 *) mgmt->u.s1g_assoc_resp.variable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3691) aid = 0; /* TODO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3692) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3693)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3694) sdata_info(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3695) "RX %sssocResp from %pM (capab=0x%x status=%d aid=%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3696) reassoc ? "Rea" : "A", mgmt->sa,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3697) capab_info, status_code, (u16)(aid & ~(BIT(15) | BIT(14))));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3698)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3699) if (assoc_data->fils_kek_len &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3700) fils_decrypt_assoc_resp(sdata, (u8 *)mgmt, &len, assoc_data) < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3701) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3702)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3703) ieee802_11_parse_elems(pos, len - (pos - (u8 *)mgmt), false, &elems,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3704) mgmt->bssid, assoc_data->bss->bssid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3705)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3706) if (status_code == WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3707) elems.timeout_int &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3708) elems.timeout_int->type == WLAN_TIMEOUT_ASSOC_COMEBACK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3709) u32 tu, ms;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3710) tu = le32_to_cpu(elems.timeout_int->value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3711) ms = tu * 1024 / 1000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3712) sdata_info(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3713) "%pM rejected association temporarily; comeback duration %u TU (%u ms)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3714) mgmt->sa, tu, ms);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3715) assoc_data->timeout = jiffies + msecs_to_jiffies(ms);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3716) assoc_data->timeout_started = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3717) if (ms > IEEE80211_ASSOC_TIMEOUT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3718) run_again(sdata, assoc_data->timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3719) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3720) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3721)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3722) if (status_code != WLAN_STATUS_SUCCESS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3723) sdata_info(sdata, "%pM denied association (code=%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3724) mgmt->sa, status_code);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3725) ieee80211_destroy_assoc_data(sdata, false, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3726) event.u.mlme.status = MLME_DENIED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3727) event.u.mlme.reason = status_code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3728) drv_event_callback(sdata->local, sdata, &event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3729) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3730) if (!ieee80211_assoc_success(sdata, cbss, mgmt, len, &elems)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3731) /* oops -- internal error -- send timeout for now */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3732) ieee80211_destroy_assoc_data(sdata, false, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3733) cfg80211_assoc_timeout(sdata->dev, cbss);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3734) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3735) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3736) event.u.mlme.status = MLME_SUCCESS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3737) drv_event_callback(sdata->local, sdata, &event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3738) sdata_info(sdata, "associated\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3739)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3740) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3741) * destroy assoc_data afterwards, as otherwise an idle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3742) * recalc after assoc_data is NULL but before associated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3743) * is set can cause the interface to go idle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3744) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3745) ieee80211_destroy_assoc_data(sdata, true, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3746)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3747) /* get uapsd queues configuration */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3748) uapsd_queues = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3749) for (ac = 0; ac < IEEE80211_NUM_ACS; ac++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3750) if (sdata->tx_conf[ac].uapsd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3751) uapsd_queues |= ieee80211_ac_to_qos_mask[ac];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3752) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3753)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3754) cfg80211_rx_assoc_resp(sdata->dev, cbss, (u8 *)mgmt, len, uapsd_queues,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3755) ifmgd->assoc_req_ies, ifmgd->assoc_req_ies_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3756) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3757)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3758) static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3759) struct ieee80211_mgmt *mgmt, size_t len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3760) struct ieee80211_rx_status *rx_status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3761) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3762) struct ieee80211_local *local = sdata->local;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3763) struct ieee80211_bss *bss;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3764) struct ieee80211_channel *channel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3765)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3766) sdata_assert_lock(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3767)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3768) channel = ieee80211_get_channel_khz(local->hw.wiphy,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3769) ieee80211_rx_status_to_khz(rx_status));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3770) if (!channel)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3771) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3772)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3773) bss = ieee80211_bss_info_update(local, rx_status, mgmt, len, channel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3774) if (bss) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3775) sdata->vif.bss_conf.beacon_rate = bss->beacon_rate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3776) ieee80211_rx_bss_put(local, bss);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3777) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3778) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3779)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3780)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3781) static void ieee80211_rx_mgmt_probe_resp(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3782) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3783) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3784) struct ieee80211_mgmt *mgmt = (void *)skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3785) struct ieee80211_if_managed *ifmgd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3786) struct ieee80211_rx_status *rx_status = (void *) skb->cb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3787) struct ieee80211_channel *channel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3788) size_t baselen, len = skb->len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3789)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3790) ifmgd = &sdata->u.mgd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3791)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3792) sdata_assert_lock(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3793)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3794) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3795) * According to Draft P802.11ax D6.0 clause 26.17.2.3.2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3796) * "If a 6 GHz AP receives a Probe Request frame and responds with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3797) * a Probe Response frame [..], the Address 1 field of the Probe
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3798) * Response frame shall be set to the broadcast address [..]"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3799) * So, on 6GHz band we should also accept broadcast responses.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3800) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3801) channel = ieee80211_get_channel(sdata->local->hw.wiphy,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3802) rx_status->freq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3803) if (!channel)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3804) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3805)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3806) if (!ether_addr_equal(mgmt->da, sdata->vif.addr) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3807) (channel->band != NL80211_BAND_6GHZ ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3808) !is_broadcast_ether_addr(mgmt->da)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3809) return; /* ignore ProbeResp to foreign address */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3810)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3811) baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3812) if (baselen > len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3813) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3814)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3815) ieee80211_rx_bss_info(sdata, mgmt, len, rx_status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3816)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3817) if (ifmgd->associated &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3818) ether_addr_equal(mgmt->bssid, ifmgd->associated->bssid))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3819) ieee80211_reset_ap_probe(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3820) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3821)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3822) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3823) * This is the canonical list of information elements we care about,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3824) * the filter code also gives us all changes to the Microsoft OUI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3825) * (00:50:F2) vendor IE which is used for WMM which we need to track,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3826) * as well as the DTPC IE (part of the Cisco OUI) used for signaling
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3827) * changes to requested client power.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3828) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3829) * We implement beacon filtering in software since that means we can
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3830) * avoid processing the frame here and in cfg80211, and userspace
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3831) * will not be able to tell whether the hardware supports it or not.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3832) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3833) * XXX: This list needs to be dynamic -- userspace needs to be able to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3834) * add items it requires. It also needs to be able to tell us to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3835) * look out for other vendor IEs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3836) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3837) static const u64 care_about_ies =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3838) (1ULL << WLAN_EID_COUNTRY) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3839) (1ULL << WLAN_EID_ERP_INFO) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3840) (1ULL << WLAN_EID_CHANNEL_SWITCH) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3841) (1ULL << WLAN_EID_PWR_CONSTRAINT) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3842) (1ULL << WLAN_EID_HT_CAPABILITY) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3843) (1ULL << WLAN_EID_HT_OPERATION) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3844) (1ULL << WLAN_EID_EXT_CHANSWITCH_ANN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3845)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3846) static void ieee80211_handle_beacon_sig(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3847) struct ieee80211_if_managed *ifmgd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3848) struct ieee80211_bss_conf *bss_conf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3849) struct ieee80211_local *local,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3850) struct ieee80211_rx_status *rx_status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3851) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3852) /* Track average RSSI from the Beacon frames of the current AP */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3853)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3854) if (ifmgd->flags & IEEE80211_STA_RESET_SIGNAL_AVE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3855) ifmgd->flags &= ~IEEE80211_STA_RESET_SIGNAL_AVE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3856) ewma_beacon_signal_init(&ifmgd->ave_beacon_signal);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3857) ifmgd->last_cqm_event_signal = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3858) ifmgd->count_beacon_signal = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3859) ifmgd->last_ave_beacon_signal = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3860) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3861) ifmgd->count_beacon_signal++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3862) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3863)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3864) ewma_beacon_signal_add(&ifmgd->ave_beacon_signal, -rx_status->signal);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3865)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3866) if (ifmgd->rssi_min_thold != ifmgd->rssi_max_thold &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3867) ifmgd->count_beacon_signal >= IEEE80211_SIGNAL_AVE_MIN_COUNT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3868) int sig = -ewma_beacon_signal_read(&ifmgd->ave_beacon_signal);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3869) int last_sig = ifmgd->last_ave_beacon_signal;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3870) struct ieee80211_event event = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3871) .type = RSSI_EVENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3872) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3873)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3874) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3875) * if signal crosses either of the boundaries, invoke callback
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3876) * with appropriate parameters
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3877) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3878) if (sig > ifmgd->rssi_max_thold &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3879) (last_sig <= ifmgd->rssi_min_thold || last_sig == 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3880) ifmgd->last_ave_beacon_signal = sig;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3881) event.u.rssi.data = RSSI_EVENT_HIGH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3882) drv_event_callback(local, sdata, &event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3883) } else if (sig < ifmgd->rssi_min_thold &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3884) (last_sig >= ifmgd->rssi_max_thold ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3885) last_sig == 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3886) ifmgd->last_ave_beacon_signal = sig;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3887) event.u.rssi.data = RSSI_EVENT_LOW;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3888) drv_event_callback(local, sdata, &event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3889) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3890) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3891)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3892) if (bss_conf->cqm_rssi_thold &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3893) ifmgd->count_beacon_signal >= IEEE80211_SIGNAL_AVE_MIN_COUNT &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3894) !(sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3895) int sig = -ewma_beacon_signal_read(&ifmgd->ave_beacon_signal);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3896) int last_event = ifmgd->last_cqm_event_signal;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3897) int thold = bss_conf->cqm_rssi_thold;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3898) int hyst = bss_conf->cqm_rssi_hyst;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3899)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3900) if (sig < thold &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3901) (last_event == 0 || sig < last_event - hyst)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3902) ifmgd->last_cqm_event_signal = sig;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3903) ieee80211_cqm_rssi_notify(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3904) &sdata->vif,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3905) NL80211_CQM_RSSI_THRESHOLD_EVENT_LOW,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3906) sig, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3907) } else if (sig > thold &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3908) (last_event == 0 || sig > last_event + hyst)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3909) ifmgd->last_cqm_event_signal = sig;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3910) ieee80211_cqm_rssi_notify(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3911) &sdata->vif,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3912) NL80211_CQM_RSSI_THRESHOLD_EVENT_HIGH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3913) sig, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3914) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3915) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3916)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3917) if (bss_conf->cqm_rssi_low &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3918) ifmgd->count_beacon_signal >= IEEE80211_SIGNAL_AVE_MIN_COUNT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3919) int sig = -ewma_beacon_signal_read(&ifmgd->ave_beacon_signal);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3920) int last_event = ifmgd->last_cqm_event_signal;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3921) int low = bss_conf->cqm_rssi_low;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3922) int high = bss_conf->cqm_rssi_high;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3923)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3924) if (sig < low &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3925) (last_event == 0 || last_event >= low)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3926) ifmgd->last_cqm_event_signal = sig;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3927) ieee80211_cqm_rssi_notify(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3928) &sdata->vif,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3929) NL80211_CQM_RSSI_THRESHOLD_EVENT_LOW,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3930) sig, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3931) } else if (sig > high &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3932) (last_event == 0 || last_event <= high)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3933) ifmgd->last_cqm_event_signal = sig;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3934) ieee80211_cqm_rssi_notify(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3935) &sdata->vif,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3936) NL80211_CQM_RSSI_THRESHOLD_EVENT_HIGH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3937) sig, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3938) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3939) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3940) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3941)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3942) static bool ieee80211_rx_our_beacon(const u8 *tx_bssid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3943) struct cfg80211_bss *bss)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3944) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3945) if (ether_addr_equal(tx_bssid, bss->bssid))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3946) return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3947) if (!bss->transmitted_bss)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3948) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3949) return ether_addr_equal(tx_bssid, bss->transmitted_bss->bssid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3950) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3951)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3952) static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3953) struct ieee80211_hdr *hdr, size_t len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3954) struct ieee80211_rx_status *rx_status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3955) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3956) struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3957) struct ieee80211_bss_conf *bss_conf = &sdata->vif.bss_conf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3958) struct ieee80211_mgmt *mgmt = (void *) hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3959) size_t baselen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3960) struct ieee802_11_elems elems;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3961) struct ieee80211_local *local = sdata->local;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3962) struct ieee80211_chanctx_conf *chanctx_conf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3963) struct ieee80211_channel *chan;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3964) struct sta_info *sta;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3965) u32 changed = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3966) bool erp_valid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3967) u8 erp_value = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3968) u32 ncrc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3969) u8 *bssid, *variable = mgmt->u.beacon.variable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3970) u8 deauth_buf[IEEE80211_DEAUTH_FRAME_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3971)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3972) sdata_assert_lock(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3973)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3974) /* Process beacon from the current BSS */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3975) bssid = ieee80211_get_bssid(hdr, len, sdata->vif.type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3976) if (ieee80211_is_s1g_beacon(mgmt->frame_control)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3977) struct ieee80211_ext *ext = (void *) mgmt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3978)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3979) if (ieee80211_is_s1g_short_beacon(ext->frame_control))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3980) variable = ext->u.s1g_short_beacon.variable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3981) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3982) variable = ext->u.s1g_beacon.variable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3983) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3984)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3985) baselen = (u8 *) variable - (u8 *) mgmt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3986) if (baselen > len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3987) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3988)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3989) rcu_read_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3990) chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3991) if (!chanctx_conf) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3992) rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3993) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3994) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3995)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3996) if (ieee80211_rx_status_to_khz(rx_status) !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3997) ieee80211_channel_to_khz(chanctx_conf->def.chan)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3998) rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3999) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4000) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4001) chan = chanctx_conf->def.chan;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4002) rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4003)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4004) if (ifmgd->assoc_data && ifmgd->assoc_data->need_beacon &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4005) ieee80211_rx_our_beacon(bssid, ifmgd->assoc_data->bss)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4006) ieee802_11_parse_elems(variable,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4007) len - baselen, false, &elems,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4008) bssid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4009) ifmgd->assoc_data->bss->bssid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4010)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4011) ieee80211_rx_bss_info(sdata, mgmt, len, rx_status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4012)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4013) if (elems.dtim_period)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4014) ifmgd->dtim_period = elems.dtim_period;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4015) ifmgd->have_beacon = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4016) ifmgd->assoc_data->need_beacon = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4017) if (ieee80211_hw_check(&local->hw, TIMING_BEACON_ONLY)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4018) sdata->vif.bss_conf.sync_tsf =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4019) le64_to_cpu(mgmt->u.beacon.timestamp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4020) sdata->vif.bss_conf.sync_device_ts =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4021) rx_status->device_timestamp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4022) sdata->vif.bss_conf.sync_dtim_count = elems.dtim_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4023) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4024)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4025) if (elems.mbssid_config_ie)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4026) bss_conf->profile_periodicity =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4027) elems.mbssid_config_ie->profile_periodicity;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4028) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4029) bss_conf->profile_periodicity = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4030)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4031) if (elems.ext_capab_len >= 11 &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4032) (elems.ext_capab[10] & WLAN_EXT_CAPA11_EMA_SUPPORT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4033) bss_conf->ema_ap = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4034) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4035) bss_conf->ema_ap = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4036)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4037) /* continue assoc process */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4038) ifmgd->assoc_data->timeout = jiffies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4039) ifmgd->assoc_data->timeout_started = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4040) run_again(sdata, ifmgd->assoc_data->timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4041) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4042) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4043)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4044) if (!ifmgd->associated ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4045) !ieee80211_rx_our_beacon(bssid, ifmgd->associated))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4046) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4047) bssid = ifmgd->associated->bssid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4048)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4049) if (!(rx_status->flag & RX_FLAG_NO_SIGNAL_VAL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4050) ieee80211_handle_beacon_sig(sdata, ifmgd, bss_conf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4051) local, rx_status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4052)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4053) if (ifmgd->flags & IEEE80211_STA_CONNECTION_POLL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4054) mlme_dbg_ratelimited(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4055) "cancelling AP probe due to a received beacon\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4056) ieee80211_reset_ap_probe(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4057) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4058)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4059) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4060) * Push the beacon loss detection into the future since
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4061) * we are processing a beacon from the AP just now.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4062) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4063) ieee80211_sta_reset_beacon_monitor(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4064)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4065) /* TODO: CRC urrently not calculated on S1G Beacon Compatibility
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4066) * element (which carries the beacon interval). Don't forget to add a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4067) * bit to care_about_ies[] above if mac80211 is interested in a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4068) * changing S1G element.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4069) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4070) if (!ieee80211_is_s1g_beacon(hdr->frame_control))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4071) ncrc = crc32_be(0, (void *)&mgmt->u.beacon.beacon_int, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4072) ncrc = ieee802_11_parse_elems_crc(variable,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4073) len - baselen, false, &elems,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4074) care_about_ies, ncrc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4075) mgmt->bssid, bssid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4076)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4077) if (ieee80211_hw_check(&local->hw, PS_NULLFUNC_STACK) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4078) ieee80211_check_tim(elems.tim, elems.tim_len, bss_conf->aid)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4079) if (local->hw.conf.dynamic_ps_timeout > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4080) if (local->hw.conf.flags & IEEE80211_CONF_PS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4081) local->hw.conf.flags &= ~IEEE80211_CONF_PS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4082) ieee80211_hw_config(local,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4083) IEEE80211_CONF_CHANGE_PS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4084) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4085) ieee80211_send_nullfunc(local, sdata, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4086) } else if (!local->pspolling && sdata->u.mgd.powersave) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4087) local->pspolling = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4088)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4089) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4090) * Here is assumed that the driver will be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4091) * able to send ps-poll frame and receive a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4092) * response even though power save mode is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4093) * enabled, but some drivers might require
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4094) * to disable power save here. This needs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4095) * to be investigated.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4096) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4097) ieee80211_send_pspoll(local, sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4098) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4099) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4101) if (sdata->vif.p2p ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4102) sdata->vif.driver_flags & IEEE80211_VIF_GET_NOA_UPDATE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4103) struct ieee80211_p2p_noa_attr noa = {};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4104) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4106) ret = cfg80211_get_p2p_attr(variable,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4107) len - baselen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4108) IEEE80211_P2P_ATTR_ABSENCE_NOTICE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4109) (u8 *) &noa, sizeof(noa));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4110) if (ret >= 2) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4111) if (sdata->u.mgd.p2p_noa_index != noa.index) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4112) /* valid noa_attr and index changed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4113) sdata->u.mgd.p2p_noa_index = noa.index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4114) memcpy(&bss_conf->p2p_noa_attr, &noa, sizeof(noa));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4115) changed |= BSS_CHANGED_P2P_PS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4116) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4117) * make sure we update all information, the CRC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4118) * mechanism doesn't look at P2P attributes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4119) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4120) ifmgd->beacon_crc_valid = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4121) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4122) } else if (sdata->u.mgd.p2p_noa_index != -1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4123) /* noa_attr not found and we had valid noa_attr before */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4124) sdata->u.mgd.p2p_noa_index = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4125) memset(&bss_conf->p2p_noa_attr, 0, sizeof(bss_conf->p2p_noa_attr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4126) changed |= BSS_CHANGED_P2P_PS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4127) ifmgd->beacon_crc_valid = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4128) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4129) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4131) if (ifmgd->csa_waiting_bcn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4132) ieee80211_chswitch_post_beacon(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4133)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4134) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4135) * Update beacon timing and dtim count on every beacon appearance. This
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4136) * will allow the driver to use the most updated values. Do it before
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4137) * comparing this one with last received beacon.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4138) * IMPORTANT: These parameters would possibly be out of sync by the time
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4139) * the driver will use them. The synchronized view is currently
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4140) * guaranteed only in certain callbacks.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4141) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4142) if (ieee80211_hw_check(&local->hw, TIMING_BEACON_ONLY) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4143) !ieee80211_is_s1g_beacon(hdr->frame_control)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4144) sdata->vif.bss_conf.sync_tsf =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4145) le64_to_cpu(mgmt->u.beacon.timestamp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4146) sdata->vif.bss_conf.sync_device_ts =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4147) rx_status->device_timestamp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4148) sdata->vif.bss_conf.sync_dtim_count = elems.dtim_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4149) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4150)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4151) if ((ncrc == ifmgd->beacon_crc && ifmgd->beacon_crc_valid) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4152) ieee80211_is_s1g_short_beacon(mgmt->frame_control))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4153) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4154) ifmgd->beacon_crc = ncrc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4155) ifmgd->beacon_crc_valid = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4157) ieee80211_rx_bss_info(sdata, mgmt, len, rx_status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4159) ieee80211_sta_process_chanswitch(sdata, rx_status->mactime,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4160) rx_status->device_timestamp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4161) &elems, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4162)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4163) if (!(ifmgd->flags & IEEE80211_STA_DISABLE_WMM) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4164) ieee80211_sta_wmm_params(local, sdata, elems.wmm_param,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4165) elems.wmm_param_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4166) elems.mu_edca_param_set))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4167) changed |= BSS_CHANGED_QOS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4169) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4170) * If we haven't had a beacon before, tell the driver about the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4171) * DTIM period (and beacon timing if desired) now.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4172) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4173) if (!ifmgd->have_beacon) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4174) /* a few bogus AP send dtim_period = 0 or no TIM IE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4175) bss_conf->dtim_period = elems.dtim_period ?: 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4176)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4177) changed |= BSS_CHANGED_BEACON_INFO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4178) ifmgd->have_beacon = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4179)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4180) mutex_lock(&local->iflist_mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4181) ieee80211_recalc_ps(local);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4182) mutex_unlock(&local->iflist_mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4183)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4184) ieee80211_recalc_ps_vif(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4185) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4187) if (elems.erp_info) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4188) erp_valid = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4189) erp_value = elems.erp_info[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4190) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4191) erp_valid = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4192) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4193)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4194) if (!ieee80211_is_s1g_beacon(hdr->frame_control))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4195) changed |= ieee80211_handle_bss_capability(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4196) le16_to_cpu(mgmt->u.beacon.capab_info),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4197) erp_valid, erp_value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4198)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4199) mutex_lock(&local->sta_mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4200) sta = sta_info_get(sdata, bssid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4201)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4202) changed |= ieee80211_recalc_twt_req(sdata, sta, &elems);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4203)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4204) if (ieee80211_config_bw(sdata, sta, elems.ht_cap_elem,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4205) elems.vht_cap_elem, elems.ht_operation,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4206) elems.vht_operation, elems.he_operation,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4207) elems.s1g_oper, bssid, &changed)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4208) mutex_unlock(&local->sta_mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4209) sdata_info(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4210) "failed to follow AP %pM bandwidth change, disconnect\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4211) bssid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4212) ieee80211_set_disassoc(sdata, IEEE80211_STYPE_DEAUTH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4213) WLAN_REASON_DEAUTH_LEAVING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4214) true, deauth_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4215) ieee80211_report_disconnect(sdata, deauth_buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4216) sizeof(deauth_buf), true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4217) WLAN_REASON_DEAUTH_LEAVING);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4218) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4219) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4220)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4221) if (sta && elems.opmode_notif)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4222) ieee80211_vht_handle_opmode(sdata, sta, *elems.opmode_notif,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4223) rx_status->band);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4224) mutex_unlock(&local->sta_mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4225)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4226) changed |= ieee80211_handle_pwr_constr(sdata, chan, mgmt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4227) elems.country_elem,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4228) elems.country_elem_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4229) elems.pwr_constr_elem,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4230) elems.cisco_dtpc_elem);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4231)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4232) ieee80211_bss_info_change_notify(sdata, changed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4233) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4234)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4235) void ieee80211_sta_rx_queued_ext(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4236) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4237) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4238) struct ieee80211_rx_status *rx_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4239) struct ieee80211_hdr *hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4240) u16 fc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4241)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4242) rx_status = (struct ieee80211_rx_status *) skb->cb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4243) hdr = (struct ieee80211_hdr *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4244) fc = le16_to_cpu(hdr->frame_control);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4245)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4246) sdata_lock(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4247) switch (fc & IEEE80211_FCTL_STYPE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4248) case IEEE80211_STYPE_S1G_BEACON:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4249) ieee80211_rx_mgmt_beacon(sdata, hdr, skb->len, rx_status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4250) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4251) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4252) sdata_unlock(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4253) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4254)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4255) void ieee80211_sta_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4256) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4257) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4258) struct ieee80211_rx_status *rx_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4259) struct ieee80211_mgmt *mgmt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4260) u16 fc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4261) struct ieee802_11_elems elems;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4262) int ies_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4263)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4264) rx_status = (struct ieee80211_rx_status *) skb->cb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4265) mgmt = (struct ieee80211_mgmt *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4266) fc = le16_to_cpu(mgmt->frame_control);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4267)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4268) sdata_lock(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4269)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4270) switch (fc & IEEE80211_FCTL_STYPE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4271) case IEEE80211_STYPE_BEACON:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4272) ieee80211_rx_mgmt_beacon(sdata, (void *)mgmt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4273) skb->len, rx_status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4274) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4275) case IEEE80211_STYPE_PROBE_RESP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4276) ieee80211_rx_mgmt_probe_resp(sdata, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4277) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4278) case IEEE80211_STYPE_AUTH:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4279) ieee80211_rx_mgmt_auth(sdata, mgmt, skb->len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4280) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4281) case IEEE80211_STYPE_DEAUTH:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4282) ieee80211_rx_mgmt_deauth(sdata, mgmt, skb->len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4283) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4284) case IEEE80211_STYPE_DISASSOC:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4285) ieee80211_rx_mgmt_disassoc(sdata, mgmt, skb->len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4286) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4287) case IEEE80211_STYPE_ASSOC_RESP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4288) case IEEE80211_STYPE_REASSOC_RESP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4289) ieee80211_rx_mgmt_assoc_resp(sdata, mgmt, skb->len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4290) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4291) case IEEE80211_STYPE_ACTION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4292) if (mgmt->u.action.category == WLAN_CATEGORY_SPECTRUM_MGMT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4293) ies_len = skb->len -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4294) offsetof(struct ieee80211_mgmt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4295) u.action.u.chan_switch.variable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4296)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4297) if (ies_len < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4298) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4299)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4300) /* CSA IE cannot be overridden, no need for BSSID */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4301) ieee802_11_parse_elems(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4302) mgmt->u.action.u.chan_switch.variable,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4303) ies_len, true, &elems, mgmt->bssid, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4304)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4305) if (elems.parse_error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4306) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4307)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4308) ieee80211_sta_process_chanswitch(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4309) rx_status->mactime,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4310) rx_status->device_timestamp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4311) &elems, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4312) } else if (mgmt->u.action.category == WLAN_CATEGORY_PUBLIC) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4313) ies_len = skb->len -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4314) offsetof(struct ieee80211_mgmt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4315) u.action.u.ext_chan_switch.variable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4316)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4317) if (ies_len < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4318) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4319)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4320) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4321) * extended CSA IE can't be overridden, no need for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4322) * BSSID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4323) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4324) ieee802_11_parse_elems(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4325) mgmt->u.action.u.ext_chan_switch.variable,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4326) ies_len, true, &elems, mgmt->bssid, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4327)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4328) if (elems.parse_error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4329) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4330)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4331) /* for the handling code pretend this was also an IE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4332) elems.ext_chansw_ie =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4333) &mgmt->u.action.u.ext_chan_switch.data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4334)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4335) ieee80211_sta_process_chanswitch(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4336) rx_status->mactime,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4337) rx_status->device_timestamp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4338) &elems, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4339) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4340) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4341) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4342) sdata_unlock(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4343) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4344)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4345) static void ieee80211_sta_timer(struct timer_list *t)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4346) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4347) struct ieee80211_sub_if_data *sdata =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4348) from_timer(sdata, t, u.mgd.timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4349)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4350) ieee80211_queue_work(&sdata->local->hw, &sdata->work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4351) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4352)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4353) static void ieee80211_sta_connection_lost(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4354) u8 *bssid, u8 reason, bool tx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4355) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4356) u8 frame_buf[IEEE80211_DEAUTH_FRAME_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4357)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4358) ieee80211_set_disassoc(sdata, IEEE80211_STYPE_DEAUTH, reason,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4359) tx, frame_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4360)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4361) ieee80211_report_disconnect(sdata, frame_buf, sizeof(frame_buf), true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4362) reason);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4363) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4364)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4365) static int ieee80211_auth(struct ieee80211_sub_if_data *sdata)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4366) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4367) struct ieee80211_local *local = sdata->local;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4368) struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4369) struct ieee80211_mgd_auth_data *auth_data = ifmgd->auth_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4370) u32 tx_flags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4371) u16 trans = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4372) u16 status = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4373) u16 prepare_tx_duration = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4374)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4375) sdata_assert_lock(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4376)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4377) if (WARN_ON_ONCE(!auth_data))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4378) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4379)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4380) auth_data->tries++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4381)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4382) if (auth_data->tries > IEEE80211_AUTH_MAX_TRIES) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4383) sdata_info(sdata, "authentication with %pM timed out\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4384) auth_data->bss->bssid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4385)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4386) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4387) * Most likely AP is not in the range so remove the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4388) * bss struct for that AP.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4389) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4390) cfg80211_unlink_bss(local->hw.wiphy, auth_data->bss);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4391)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4392) return -ETIMEDOUT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4393) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4394)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4395) if (auth_data->algorithm == WLAN_AUTH_SAE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4396) prepare_tx_duration =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4397) jiffies_to_msecs(IEEE80211_AUTH_TIMEOUT_SAE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4398)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4399) drv_mgd_prepare_tx(local, sdata, prepare_tx_duration);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4400)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4401) sdata_info(sdata, "send auth to %pM (try %d/%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4402) auth_data->bss->bssid, auth_data->tries,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4403) IEEE80211_AUTH_MAX_TRIES);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4404)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4405) auth_data->expected_transaction = 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4406)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4407) if (auth_data->algorithm == WLAN_AUTH_SAE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4408) trans = auth_data->sae_trans;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4409) status = auth_data->sae_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4410) auth_data->expected_transaction = trans;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4411) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4412)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4413) if (ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4414) tx_flags = IEEE80211_TX_CTL_REQ_TX_STATUS |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4415) IEEE80211_TX_INTFL_MLME_CONN_TX;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4416)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4417) ieee80211_send_auth(sdata, trans, auth_data->algorithm, status,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4418) auth_data->data, auth_data->data_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4419) auth_data->bss->bssid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4420) auth_data->bss->bssid, NULL, 0, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4421) tx_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4422)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4423) if (tx_flags == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4424) if (auth_data->algorithm == WLAN_AUTH_SAE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4425) auth_data->timeout = jiffies +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4426) IEEE80211_AUTH_TIMEOUT_SAE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4427) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4428) auth_data->timeout = jiffies + IEEE80211_AUTH_TIMEOUT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4429) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4430) auth_data->timeout =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4431) round_jiffies_up(jiffies + IEEE80211_AUTH_TIMEOUT_LONG);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4432) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4433)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4434) auth_data->timeout_started = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4435) run_again(sdata, auth_data->timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4436)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4437) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4438) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4439)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4440) static int ieee80211_do_assoc(struct ieee80211_sub_if_data *sdata)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4441) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4442) struct ieee80211_mgd_assoc_data *assoc_data = sdata->u.mgd.assoc_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4443) struct ieee80211_local *local = sdata->local;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4444)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4445) sdata_assert_lock(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4446)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4447) assoc_data->tries++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4448) if (assoc_data->tries > IEEE80211_ASSOC_MAX_TRIES) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4449) sdata_info(sdata, "association with %pM timed out\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4450) assoc_data->bss->bssid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4451)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4452) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4453) * Most likely AP is not in the range so remove the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4454) * bss struct for that AP.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4455) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4456) cfg80211_unlink_bss(local->hw.wiphy, assoc_data->bss);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4457)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4458) return -ETIMEDOUT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4459) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4460)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4461) sdata_info(sdata, "associate with %pM (try %d/%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4462) assoc_data->bss->bssid, assoc_data->tries,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4463) IEEE80211_ASSOC_MAX_TRIES);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4464) ieee80211_send_assoc(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4465)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4466) if (!ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4467) assoc_data->timeout = jiffies + IEEE80211_ASSOC_TIMEOUT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4468) assoc_data->timeout_started = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4469) run_again(sdata, assoc_data->timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4470) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4471) assoc_data->timeout =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4472) round_jiffies_up(jiffies +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4473) IEEE80211_ASSOC_TIMEOUT_LONG);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4474) assoc_data->timeout_started = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4475) run_again(sdata, assoc_data->timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4476) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4477)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4478) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4479) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4480)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4481) void ieee80211_mgd_conn_tx_status(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4482) __le16 fc, bool acked)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4483) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4484) struct ieee80211_local *local = sdata->local;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4485)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4486) sdata->u.mgd.status_fc = fc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4487) sdata->u.mgd.status_acked = acked;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4488) sdata->u.mgd.status_received = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4489)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4490) ieee80211_queue_work(&local->hw, &sdata->work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4491) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4492)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4493) void ieee80211_sta_work(struct ieee80211_sub_if_data *sdata)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4494) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4495) struct ieee80211_local *local = sdata->local;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4496) struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4497)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4498) sdata_lock(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4499)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4500) if (ifmgd->status_received) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4501) __le16 fc = ifmgd->status_fc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4502) bool status_acked = ifmgd->status_acked;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4503)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4504) ifmgd->status_received = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4505) if (ifmgd->auth_data && ieee80211_is_auth(fc)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4506) if (status_acked) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4507) if (ifmgd->auth_data->algorithm ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4508) WLAN_AUTH_SAE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4509) ifmgd->auth_data->timeout =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4510) jiffies +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4511) IEEE80211_AUTH_TIMEOUT_SAE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4512) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4513) ifmgd->auth_data->timeout =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4514) jiffies +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4515) IEEE80211_AUTH_TIMEOUT_SHORT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4516) run_again(sdata, ifmgd->auth_data->timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4517) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4518) ifmgd->auth_data->timeout = jiffies - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4519) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4520) ifmgd->auth_data->timeout_started = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4521) } else if (ifmgd->assoc_data &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4522) (ieee80211_is_assoc_req(fc) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4523) ieee80211_is_reassoc_req(fc))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4524) if (status_acked) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4525) ifmgd->assoc_data->timeout =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4526) jiffies + IEEE80211_ASSOC_TIMEOUT_SHORT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4527) run_again(sdata, ifmgd->assoc_data->timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4528) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4529) ifmgd->assoc_data->timeout = jiffies - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4530) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4531) ifmgd->assoc_data->timeout_started = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4532) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4533) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4534)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4535) if (ifmgd->auth_data && ifmgd->auth_data->timeout_started &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4536) time_after(jiffies, ifmgd->auth_data->timeout)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4537) if (ifmgd->auth_data->done || ifmgd->auth_data->waiting) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4538) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4539) * ok ... we waited for assoc or continuation but
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4540) * userspace didn't do it, so kill the auth data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4541) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4542) ieee80211_destroy_auth_data(sdata, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4543) } else if (ieee80211_auth(sdata)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4544) u8 bssid[ETH_ALEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4545) struct ieee80211_event event = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4546) .type = MLME_EVENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4547) .u.mlme.data = AUTH_EVENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4548) .u.mlme.status = MLME_TIMEOUT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4549) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4550)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4551) memcpy(bssid, ifmgd->auth_data->bss->bssid, ETH_ALEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4552)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4553) ieee80211_destroy_auth_data(sdata, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4554)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4555) cfg80211_auth_timeout(sdata->dev, bssid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4556) drv_event_callback(sdata->local, sdata, &event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4557) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4558) } else if (ifmgd->auth_data && ifmgd->auth_data->timeout_started)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4559) run_again(sdata, ifmgd->auth_data->timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4560)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4561) if (ifmgd->assoc_data && ifmgd->assoc_data->timeout_started &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4562) time_after(jiffies, ifmgd->assoc_data->timeout)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4563) if ((ifmgd->assoc_data->need_beacon && !ifmgd->have_beacon) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4564) ieee80211_do_assoc(sdata)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4565) struct cfg80211_bss *bss = ifmgd->assoc_data->bss;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4566) struct ieee80211_event event = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4567) .type = MLME_EVENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4568) .u.mlme.data = ASSOC_EVENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4569) .u.mlme.status = MLME_TIMEOUT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4570) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4571)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4572) ieee80211_destroy_assoc_data(sdata, false, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4573) cfg80211_assoc_timeout(sdata->dev, bss);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4574) drv_event_callback(sdata->local, sdata, &event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4575) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4576) } else if (ifmgd->assoc_data && ifmgd->assoc_data->timeout_started)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4577) run_again(sdata, ifmgd->assoc_data->timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4578)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4579) if (ifmgd->flags & IEEE80211_STA_CONNECTION_POLL &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4580) ifmgd->associated) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4581) u8 bssid[ETH_ALEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4582) int max_tries;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4583)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4584) memcpy(bssid, ifmgd->associated->bssid, ETH_ALEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4585)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4586) if (ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4587) max_tries = max_nullfunc_tries;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4588) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4589) max_tries = max_probe_tries;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4590)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4591) /* ACK received for nullfunc probing frame */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4592) if (!ifmgd->probe_send_count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4593) ieee80211_reset_ap_probe(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4594) else if (ifmgd->nullfunc_failed) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4595) if (ifmgd->probe_send_count < max_tries) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4596) mlme_dbg(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4597) "No ack for nullfunc frame to AP %pM, try %d/%i\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4598) bssid, ifmgd->probe_send_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4599) max_tries);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4600) ieee80211_mgd_probe_ap_send(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4601) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4602) mlme_dbg(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4603) "No ack for nullfunc frame to AP %pM, disconnecting.\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4604) bssid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4605) ieee80211_sta_connection_lost(sdata, bssid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4606) WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4607) false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4608) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4609) } else if (time_is_after_jiffies(ifmgd->probe_timeout))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4610) run_again(sdata, ifmgd->probe_timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4611) else if (ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4612) mlme_dbg(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4613) "Failed to send nullfunc to AP %pM after %dms, disconnecting\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4614) bssid, probe_wait_ms);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4615) ieee80211_sta_connection_lost(sdata, bssid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4616) WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4617) } else if (ifmgd->probe_send_count < max_tries) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4618) mlme_dbg(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4619) "No probe response from AP %pM after %dms, try %d/%i\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4620) bssid, probe_wait_ms,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4621) ifmgd->probe_send_count, max_tries);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4622) ieee80211_mgd_probe_ap_send(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4623) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4624) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4625) * We actually lost the connection ... or did we?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4626) * Let's make sure!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4627) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4628) mlme_dbg(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4629) "No probe response from AP %pM after %dms, disconnecting.\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4630) bssid, probe_wait_ms);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4631)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4632) ieee80211_sta_connection_lost(sdata, bssid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4633) WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4634) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4635) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4636)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4637) sdata_unlock(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4638) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4639)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4640) static void ieee80211_sta_bcn_mon_timer(struct timer_list *t)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4641) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4642) struct ieee80211_sub_if_data *sdata =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4643) from_timer(sdata, t, u.mgd.bcn_mon_timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4644) struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4645)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4646) if (sdata->vif.csa_active && !ifmgd->csa_waiting_bcn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4647) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4648)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4649) if (sdata->vif.driver_flags & IEEE80211_VIF_BEACON_FILTER)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4650) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4651)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4652) sdata->u.mgd.connection_loss = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4653) ieee80211_queue_work(&sdata->local->hw,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4654) &sdata->u.mgd.beacon_connection_loss_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4655) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4656)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4657) static void ieee80211_sta_conn_mon_timer(struct timer_list *t)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4658) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4659) struct ieee80211_sub_if_data *sdata =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4660) from_timer(sdata, t, u.mgd.conn_mon_timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4661) struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4662) struct ieee80211_local *local = sdata->local;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4663) struct sta_info *sta;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4664) unsigned long timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4665)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4666) if (sdata->vif.csa_active && !ifmgd->csa_waiting_bcn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4667) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4668)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4669) sta = sta_info_get(sdata, ifmgd->bssid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4670) if (!sta)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4671) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4672)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4673) timeout = sta->status_stats.last_ack;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4674) if (time_before(sta->status_stats.last_ack, sta->rx_stats.last_rx))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4675) timeout = sta->rx_stats.last_rx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4676) timeout += IEEE80211_CONNECTION_IDLE_TIME;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4677)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4678) /* If timeout is after now, then update timer to fire at
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4679) * the later date, but do not actually probe at this time.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4680) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4681) if (time_is_after_jiffies(timeout)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4682) mod_timer(&ifmgd->conn_mon_timer, round_jiffies_up(timeout));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4683) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4684) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4685)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4686) ieee80211_queue_work(&local->hw, &ifmgd->monitor_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4687) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4688)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4689) static void ieee80211_sta_monitor_work(struct work_struct *work)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4690) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4691) struct ieee80211_sub_if_data *sdata =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4692) container_of(work, struct ieee80211_sub_if_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4693) u.mgd.monitor_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4694)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4695) ieee80211_mgd_probe_ap(sdata, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4696) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4697)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4698) static void ieee80211_restart_sta_timer(struct ieee80211_sub_if_data *sdata)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4699) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4700) if (sdata->vif.type == NL80211_IFTYPE_STATION) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4701) __ieee80211_stop_poll(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4702)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4703) /* let's probe the connection once */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4704) if (!ieee80211_hw_check(&sdata->local->hw, CONNECTION_MONITOR))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4705) ieee80211_queue_work(&sdata->local->hw,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4706) &sdata->u.mgd.monitor_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4707) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4708) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4709)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4710) #ifdef CONFIG_PM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4711) void ieee80211_mgd_quiesce(struct ieee80211_sub_if_data *sdata)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4712) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4713) struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4714) u8 frame_buf[IEEE80211_DEAUTH_FRAME_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4715)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4716) sdata_lock(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4717)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4718) if (ifmgd->auth_data || ifmgd->assoc_data) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4719) const u8 *bssid = ifmgd->auth_data ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4720) ifmgd->auth_data->bss->bssid :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4721) ifmgd->assoc_data->bss->bssid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4722)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4723) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4724) * If we are trying to authenticate / associate while suspending,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4725) * cfg80211 won't know and won't actually abort those attempts,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4726) * thus we need to do that ourselves.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4727) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4728) ieee80211_send_deauth_disassoc(sdata, bssid, bssid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4729) IEEE80211_STYPE_DEAUTH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4730) WLAN_REASON_DEAUTH_LEAVING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4731) false, frame_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4732) if (ifmgd->assoc_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4733) ieee80211_destroy_assoc_data(sdata, false, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4734) if (ifmgd->auth_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4735) ieee80211_destroy_auth_data(sdata, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4736) cfg80211_tx_mlme_mgmt(sdata->dev, frame_buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4737) IEEE80211_DEAUTH_FRAME_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4738) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4739)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4740) /* This is a bit of a hack - we should find a better and more generic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4741) * solution to this. Normally when suspending, cfg80211 will in fact
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4742) * deauthenticate. However, it doesn't (and cannot) stop an ongoing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4743) * auth (not so important) or assoc (this is the problem) process.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4744) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4745) * As a consequence, it can happen that we are in the process of both
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4746) * associating and suspending, and receive an association response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4747) * after cfg80211 has checked if it needs to disconnect, but before
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4748) * we actually set the flag to drop incoming frames. This will then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4749) * cause the workqueue flush to process the association response in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4750) * the suspend, resulting in a successful association just before it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4751) * tries to remove the interface from the driver, which now though
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4752) * has a channel context assigned ... this results in issues.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4753) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4754) * To work around this (for now) simply deauth here again if we're
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4755) * now connected.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4756) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4757) if (ifmgd->associated && !sdata->local->wowlan) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4758) u8 bssid[ETH_ALEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4759) struct cfg80211_deauth_request req = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4760) .reason_code = WLAN_REASON_DEAUTH_LEAVING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4761) .bssid = bssid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4762) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4763)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4764) memcpy(bssid, ifmgd->associated->bssid, ETH_ALEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4765) ieee80211_mgd_deauth(sdata, &req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4766) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4767)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4768) sdata_unlock(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4769) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4770)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4771) void ieee80211_sta_restart(struct ieee80211_sub_if_data *sdata)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4772) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4773) struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4774)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4775) sdata_lock(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4776) if (!ifmgd->associated) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4777) sdata_unlock(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4778) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4779) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4780)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4781) if (sdata->flags & IEEE80211_SDATA_DISCONNECT_RESUME) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4782) sdata->flags &= ~IEEE80211_SDATA_DISCONNECT_RESUME;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4783) mlme_dbg(sdata, "driver requested disconnect after resume\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4784) ieee80211_sta_connection_lost(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4785) ifmgd->associated->bssid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4786) WLAN_REASON_UNSPECIFIED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4787) true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4788) sdata_unlock(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4789) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4790) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4791) sdata_unlock(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4792) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4793) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4794)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4795) /* interface setup */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4796) void ieee80211_sta_setup_sdata(struct ieee80211_sub_if_data *sdata)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4797) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4798) struct ieee80211_if_managed *ifmgd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4799)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4800) ifmgd = &sdata->u.mgd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4801) INIT_WORK(&ifmgd->monitor_work, ieee80211_sta_monitor_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4802) INIT_WORK(&ifmgd->chswitch_work, ieee80211_chswitch_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4803) INIT_WORK(&ifmgd->beacon_connection_loss_work,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4804) ieee80211_beacon_connection_loss_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4805) INIT_WORK(&ifmgd->csa_connection_drop_work,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4806) ieee80211_csa_connection_drop_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4807) INIT_WORK(&ifmgd->request_smps_work, ieee80211_request_smps_mgd_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4808) INIT_DELAYED_WORK(&ifmgd->tdls_peer_del_work,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4809) ieee80211_tdls_peer_del_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4810) timer_setup(&ifmgd->timer, ieee80211_sta_timer, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4811) timer_setup(&ifmgd->bcn_mon_timer, ieee80211_sta_bcn_mon_timer, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4812) timer_setup(&ifmgd->conn_mon_timer, ieee80211_sta_conn_mon_timer, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4813) timer_setup(&ifmgd->chswitch_timer, ieee80211_chswitch_timer, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4814) INIT_DELAYED_WORK(&ifmgd->tx_tspec_wk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4815) ieee80211_sta_handle_tspec_ac_params_wk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4816)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4817) ifmgd->flags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4818) ifmgd->powersave = sdata->wdev.ps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4819) ifmgd->uapsd_queues = sdata->local->hw.uapsd_queues;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4820) ifmgd->uapsd_max_sp_len = sdata->local->hw.uapsd_max_sp_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4821) ifmgd->p2p_noa_index = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4822)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4823) if (sdata->local->hw.wiphy->features & NL80211_FEATURE_DYNAMIC_SMPS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4824) ifmgd->req_smps = IEEE80211_SMPS_AUTOMATIC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4825) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4826) ifmgd->req_smps = IEEE80211_SMPS_OFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4827)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4828) /* Setup TDLS data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4829) spin_lock_init(&ifmgd->teardown_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4830) ifmgd->teardown_skb = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4831) ifmgd->orig_teardown_skb = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4832) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4833)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4834) /* scan finished notification */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4835) void ieee80211_mlme_notify_scan_completed(struct ieee80211_local *local)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4836) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4837) struct ieee80211_sub_if_data *sdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4838)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4839) /* Restart STA timers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4840) rcu_read_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4841) list_for_each_entry_rcu(sdata, &local->interfaces, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4842) if (ieee80211_sdata_running(sdata))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4843) ieee80211_restart_sta_timer(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4844) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4845) rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4846) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4847)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4848) static u8 ieee80211_ht_vht_rx_chains(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4849) struct cfg80211_bss *cbss)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4850) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4851) struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4852) const u8 *ht_cap_ie, *vht_cap_ie;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4853) const struct ieee80211_ht_cap *ht_cap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4854) const struct ieee80211_vht_cap *vht_cap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4855) u8 chains = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4856)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4857) if (ifmgd->flags & IEEE80211_STA_DISABLE_HT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4858) return chains;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4859)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4860) ht_cap_ie = ieee80211_bss_get_ie(cbss, WLAN_EID_HT_CAPABILITY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4861) if (ht_cap_ie && ht_cap_ie[1] >= sizeof(*ht_cap)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4862) ht_cap = (void *)(ht_cap_ie + 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4863) chains = ieee80211_mcs_to_chains(&ht_cap->mcs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4864) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4865) * TODO: use "Tx Maximum Number Spatial Streams Supported" and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4866) * "Tx Unequal Modulation Supported" fields.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4867) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4868) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4869)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4870) if (ifmgd->flags & IEEE80211_STA_DISABLE_VHT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4871) return chains;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4872)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4873) vht_cap_ie = ieee80211_bss_get_ie(cbss, WLAN_EID_VHT_CAPABILITY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4874) if (vht_cap_ie && vht_cap_ie[1] >= sizeof(*vht_cap)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4875) u8 nss;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4876) u16 tx_mcs_map;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4877)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4878) vht_cap = (void *)(vht_cap_ie + 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4879) tx_mcs_map = le16_to_cpu(vht_cap->supp_mcs.tx_mcs_map);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4880) for (nss = 8; nss > 0; nss--) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4881) if (((tx_mcs_map >> (2 * (nss - 1))) & 3) !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4882) IEEE80211_VHT_MCS_NOT_SUPPORTED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4883) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4884) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4885) /* TODO: use "Tx Highest Supported Long GI Data Rate" field? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4886) chains = max(chains, nss);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4887) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4888)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4889) return chains;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4890) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4891)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4892) static bool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4893) ieee80211_verify_sta_he_mcs_support(struct ieee80211_supported_band *sband,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4894) const struct ieee80211_he_operation *he_op)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4895) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4896) const struct ieee80211_sta_he_cap *sta_he_cap =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4897) ieee80211_get_he_sta_cap(sband);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4898) u16 ap_min_req_set;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4899) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4900)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4901) if (!sta_he_cap || !he_op)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4902) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4903)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4904) ap_min_req_set = le16_to_cpu(he_op->he_mcs_nss_set);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4905)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4906) /* Need to go over for 80MHz, 160MHz and for 80+80 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4907) for (i = 0; i < 3; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4908) const struct ieee80211_he_mcs_nss_supp *sta_mcs_nss_supp =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4909) &sta_he_cap->he_mcs_nss_supp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4910) u16 sta_mcs_map_rx =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4911) le16_to_cpu(((__le16 *)sta_mcs_nss_supp)[2 * i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4912) u16 sta_mcs_map_tx =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4913) le16_to_cpu(((__le16 *)sta_mcs_nss_supp)[2 * i + 1]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4914) u8 nss;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4915) bool verified = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4916)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4917) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4918) * For each band there is a maximum of 8 spatial streams
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4919) * possible. Each of the sta_mcs_map_* is a 16-bit struct built
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4920) * of 2 bits per NSS (1-8), with the values defined in enum
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4921) * ieee80211_he_mcs_support. Need to make sure STA TX and RX
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4922) * capabilities aren't less than the AP's minimum requirements
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4923) * for this HE BSS per SS.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4924) * It is enough to find one such band that meets the reqs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4925) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4926) for (nss = 8; nss > 0; nss--) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4927) u8 sta_rx_val = (sta_mcs_map_rx >> (2 * (nss - 1))) & 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4928) u8 sta_tx_val = (sta_mcs_map_tx >> (2 * (nss - 1))) & 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4929) u8 ap_val = (ap_min_req_set >> (2 * (nss - 1))) & 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4930)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4931) if (ap_val == IEEE80211_HE_MCS_NOT_SUPPORTED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4932) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4933)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4934) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4935) * Make sure the HE AP doesn't require MCSs that aren't
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4936) * supported by the client
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4937) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4938) if (sta_rx_val == IEEE80211_HE_MCS_NOT_SUPPORTED ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4939) sta_tx_val == IEEE80211_HE_MCS_NOT_SUPPORTED ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4940) (ap_val > sta_rx_val) || (ap_val > sta_tx_val)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4941) verified = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4942) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4943) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4944) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4945)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4946) if (verified)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4947) return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4948) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4949)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4950) /* If here, STA doesn't meet AP's HE min requirements */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4951) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4952) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4953)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4954) static int ieee80211_prep_channel(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4955) struct cfg80211_bss *cbss)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4956) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4957) struct ieee80211_local *local = sdata->local;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4958) struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4959) const struct ieee80211_ht_cap *ht_cap = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4960) const struct ieee80211_ht_operation *ht_oper = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4961) const struct ieee80211_vht_operation *vht_oper = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4962) const struct ieee80211_he_operation *he_oper = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4963) const struct ieee80211_s1g_oper_ie *s1g_oper = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4964) struct ieee80211_supported_band *sband;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4965) struct cfg80211_chan_def chandef;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4966) bool is_6ghz = cbss->channel->band == NL80211_BAND_6GHZ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4967) bool is_5ghz = cbss->channel->band == NL80211_BAND_5GHZ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4968) struct ieee80211_bss *bss = (void *)cbss->priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4969) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4970) u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4971) bool have_80mhz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4972)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4973) sband = local->hw.wiphy->bands[cbss->channel->band];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4974)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4975) ifmgd->flags &= ~(IEEE80211_STA_DISABLE_40MHZ |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4976) IEEE80211_STA_DISABLE_80P80MHZ |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4977) IEEE80211_STA_DISABLE_160MHZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4978)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4979) /* disable HT/VHT/HE if we don't support them */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4980) if (!sband->ht_cap.ht_supported && !is_6ghz) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4981) ifmgd->flags |= IEEE80211_STA_DISABLE_HT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4982) ifmgd->flags |= IEEE80211_STA_DISABLE_VHT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4983) ifmgd->flags |= IEEE80211_STA_DISABLE_HE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4984) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4985)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4986) if (!sband->vht_cap.vht_supported && is_5ghz) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4987) ifmgd->flags |= IEEE80211_STA_DISABLE_VHT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4988) ifmgd->flags |= IEEE80211_STA_DISABLE_HE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4989) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4990)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4991) if (!ieee80211_get_he_sta_cap(sband))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4992) ifmgd->flags |= IEEE80211_STA_DISABLE_HE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4993)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4994) rcu_read_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4995)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4996) if (!(ifmgd->flags & IEEE80211_STA_DISABLE_HT) && !is_6ghz) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4997) const u8 *ht_oper_ie, *ht_cap_ie;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4998)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4999) ht_oper_ie = ieee80211_bss_get_ie(cbss, WLAN_EID_HT_OPERATION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5000) if (ht_oper_ie && ht_oper_ie[1] >= sizeof(*ht_oper))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5001) ht_oper = (void *)(ht_oper_ie + 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5002)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5003) ht_cap_ie = ieee80211_bss_get_ie(cbss, WLAN_EID_HT_CAPABILITY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5004) if (ht_cap_ie && ht_cap_ie[1] >= sizeof(*ht_cap))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5005) ht_cap = (void *)(ht_cap_ie + 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5006)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5007) if (!ht_cap) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5008) ifmgd->flags |= IEEE80211_STA_DISABLE_HT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5009) ht_oper = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5010) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5011) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5012)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5013) if (!(ifmgd->flags & IEEE80211_STA_DISABLE_VHT) && !is_6ghz) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5014) const u8 *vht_oper_ie, *vht_cap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5015)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5016) vht_oper_ie = ieee80211_bss_get_ie(cbss,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5017) WLAN_EID_VHT_OPERATION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5018) if (vht_oper_ie && vht_oper_ie[1] >= sizeof(*vht_oper))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5019) vht_oper = (void *)(vht_oper_ie + 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5020) if (vht_oper && !ht_oper) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5021) vht_oper = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5022) sdata_info(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5023) "AP advertised VHT without HT, disabling HT/VHT/HE\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5024) ifmgd->flags |= IEEE80211_STA_DISABLE_HT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5025) ifmgd->flags |= IEEE80211_STA_DISABLE_VHT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5026) ifmgd->flags |= IEEE80211_STA_DISABLE_HE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5027) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5028)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5029) vht_cap = ieee80211_bss_get_ie(cbss, WLAN_EID_VHT_CAPABILITY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5030) if (!vht_cap || vht_cap[1] < sizeof(struct ieee80211_vht_cap)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5031) ifmgd->flags |= IEEE80211_STA_DISABLE_VHT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5032) vht_oper = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5033) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5034) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5035)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5036) if (!(ifmgd->flags & IEEE80211_STA_DISABLE_HE)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5037) const struct cfg80211_bss_ies *ies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5038) const u8 *he_oper_ie;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5039)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5040) ies = rcu_dereference(cbss->ies);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5041) he_oper_ie = cfg80211_find_ext_ie(WLAN_EID_EXT_HE_OPERATION,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5042) ies->data, ies->len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5043) if (he_oper_ie &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5044) he_oper_ie[1] >= ieee80211_he_oper_size(&he_oper_ie[3]))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5045) he_oper = (void *)(he_oper_ie + 3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5046) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5047) he_oper = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5048)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5049) if (!ieee80211_verify_sta_he_mcs_support(sband, he_oper))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5050) ifmgd->flags |= IEEE80211_STA_DISABLE_HE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5051) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5052)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5053) /* Allow VHT if at least one channel on the sband supports 80 MHz */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5054) have_80mhz = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5055) for (i = 0; i < sband->n_channels; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5056) if (sband->channels[i].flags & (IEEE80211_CHAN_DISABLED |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5057) IEEE80211_CHAN_NO_80MHZ))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5058) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5059)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5060) have_80mhz = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5061) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5062) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5063)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5064) if (!have_80mhz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5065) ifmgd->flags |= IEEE80211_STA_DISABLE_VHT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5066)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5067) if (sband->band == NL80211_BAND_S1GHZ) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5068) const u8 *s1g_oper_ie;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5069)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5070) s1g_oper_ie = ieee80211_bss_get_ie(cbss,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5071) WLAN_EID_S1G_OPERATION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5072) if (s1g_oper_ie && s1g_oper_ie[1] >= sizeof(*s1g_oper))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5073) s1g_oper = (void *)(s1g_oper_ie + 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5074) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5075) sdata_info(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5076) "AP missing S1G operation element?\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5077) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5078)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5079) ifmgd->flags |= ieee80211_determine_chantype(sdata, sband,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5080) cbss->channel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5081) bss->vht_cap_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5082) ht_oper, vht_oper, he_oper,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5083) s1g_oper,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5084) &chandef, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5085)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5086) sdata->needed_rx_chains = min(ieee80211_ht_vht_rx_chains(sdata, cbss),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5087) local->rx_chains);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5088)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5089) rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5090)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5091) if (ifmgd->flags & IEEE80211_STA_DISABLE_HE && is_6ghz) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5092) sdata_info(sdata, "Rejecting non-HE 6/7 GHz connection");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5093) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5094) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5095)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5096) /* will change later if needed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5097) sdata->smps_mode = IEEE80211_SMPS_OFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5098)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5099) mutex_lock(&local->mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5100) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5101) * If this fails (possibly due to channel context sharing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5102) * on incompatible channels, e.g. 80+80 and 160 sharing the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5103) * same control channel) try to use a smaller bandwidth.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5104) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5105) ret = ieee80211_vif_use_channel(sdata, &chandef,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5106) IEEE80211_CHANCTX_SHARED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5107)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5108) /* don't downgrade for 5 and 10 MHz channels, though. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5109) if (chandef.width == NL80211_CHAN_WIDTH_5 ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5110) chandef.width == NL80211_CHAN_WIDTH_10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5111) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5113) while (ret && chandef.width != NL80211_CHAN_WIDTH_20_NOHT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5114) ifmgd->flags |= ieee80211_chandef_downgrade(&chandef);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5115) ret = ieee80211_vif_use_channel(sdata, &chandef,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5116) IEEE80211_CHANCTX_SHARED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5117) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5118) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5119) mutex_unlock(&local->mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5120) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5121) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5122)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5123) static bool ieee80211_get_dtim(const struct cfg80211_bss_ies *ies,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5124) u8 *dtim_count, u8 *dtim_period)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5125) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5126) const u8 *tim_ie = cfg80211_find_ie(WLAN_EID_TIM, ies->data, ies->len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5127) const u8 *idx_ie = cfg80211_find_ie(WLAN_EID_MULTI_BSSID_IDX, ies->data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5128) ies->len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5129) const struct ieee80211_tim_ie *tim = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5130) const struct ieee80211_bssid_index *idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5131) bool valid = tim_ie && tim_ie[1] >= 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5133) if (valid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5134) tim = (void *)(tim_ie + 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5136) if (dtim_count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5137) *dtim_count = valid ? tim->dtim_count : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5139) if (dtim_period)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5140) *dtim_period = valid ? tim->dtim_period : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5142) /* Check if value is overridden by non-transmitted profile */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5143) if (!idx_ie || idx_ie[1] < 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5144) return valid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5146) idx = (void *)(idx_ie + 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5147)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5148) if (dtim_count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5149) *dtim_count = idx->dtim_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5150)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5151) if (dtim_period)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5152) *dtim_period = idx->dtim_period;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5153)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5154) return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5155) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5157) static int ieee80211_prep_connection(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5158) struct cfg80211_bss *cbss, bool assoc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5159) bool override)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5160) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5161) struct ieee80211_local *local = sdata->local;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5162) struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5163) struct ieee80211_bss *bss = (void *)cbss->priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5164) struct sta_info *new_sta = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5165) struct ieee80211_supported_band *sband;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5166) bool have_sta = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5167) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5169) sband = local->hw.wiphy->bands[cbss->channel->band];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5170)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5171) if (WARN_ON(!ifmgd->auth_data && !ifmgd->assoc_data))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5172) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5173)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5174) /* If a reconfig is happening, bail out */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5175) if (local->in_reconfig)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5176) return -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5178) if (assoc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5179) rcu_read_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5180) have_sta = sta_info_get(sdata, cbss->bssid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5181) rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5182) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5183)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5184) if (!have_sta) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5185) new_sta = sta_info_alloc(sdata, cbss->bssid, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5186) if (!new_sta)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5187) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5188) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5190) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5191) * Set up the information for the new channel before setting the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5192) * new channel. We can't - completely race-free - change the basic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5193) * rates bitmap and the channel (sband) that it refers to, but if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5194) * we set it up before we at least avoid calling into the driver's
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5195) * bss_info_changed() method with invalid information (since we do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5196) * call that from changing the channel - only for IDLE and perhaps
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5197) * some others, but ...).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5198) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5199) * So to avoid that, just set up all the new information before the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5200) * channel, but tell the driver to apply it only afterwards, since
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5201) * it might need the new channel for that.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5202) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5203) if (new_sta) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5204) u32 rates = 0, basic_rates = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5205) bool have_higher_than_11mbit = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5206) int min_rate = INT_MAX, min_rate_index = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5207) const struct cfg80211_bss_ies *ies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5208) int shift = ieee80211_vif_get_shift(&sdata->vif);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5210) /* TODO: S1G Basic Rate Set is expressed elsewhere */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5211) if (cbss->channel->band == NL80211_BAND_S1GHZ) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5212) ieee80211_s1g_sta_rate_init(new_sta);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5213) goto skip_rates;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5214) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5215)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5216) ieee80211_get_rates(sband, bss->supp_rates,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5217) bss->supp_rates_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5218) &rates, &basic_rates,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5219) &have_higher_than_11mbit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5220) &min_rate, &min_rate_index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5221) shift);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5222)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5223) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5224) * This used to be a workaround for basic rates missing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5225) * in the association response frame. Now that we no
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5226) * longer use the basic rates from there, it probably
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5227) * doesn't happen any more, but keep the workaround so
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5228) * in case some *other* APs are buggy in different ways
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5229) * we can connect -- with a warning.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5230) * Allow this workaround only in case the AP provided at least
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5231) * one rate.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5232) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5233) if (min_rate_index < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5234) sdata_info(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5235) "No legacy rates in association response\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5236)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5237) sta_info_free(local, new_sta);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5238) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5239) } else if (!basic_rates) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5240) sdata_info(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5241) "No basic rates, using min rate instead\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5242) basic_rates = BIT(min_rate_index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5243) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5244)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5245) if (rates)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5246) new_sta->sta.supp_rates[cbss->channel->band] = rates;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5247) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5248) sdata_info(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5249) "No rates found, keeping mandatory only\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5250)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5251) sdata->vif.bss_conf.basic_rates = basic_rates;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5252)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5253) /* cf. IEEE 802.11 9.2.12 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5254) if (cbss->channel->band == NL80211_BAND_2GHZ &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5255) have_higher_than_11mbit)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5256) sdata->flags |= IEEE80211_SDATA_OPERATING_GMODE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5257) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5258) sdata->flags &= ~IEEE80211_SDATA_OPERATING_GMODE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5259)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5260) skip_rates:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5261) memcpy(ifmgd->bssid, cbss->bssid, ETH_ALEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5262)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5263) /* set timing information */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5264) sdata->vif.bss_conf.beacon_int = cbss->beacon_interval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5265) rcu_read_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5266) ies = rcu_dereference(cbss->beacon_ies);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5267) if (ies) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5268) sdata->vif.bss_conf.sync_tsf = ies->tsf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5269) sdata->vif.bss_conf.sync_device_ts =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5270) bss->device_ts_beacon;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5271)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5272) ieee80211_get_dtim(ies,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5273) &sdata->vif.bss_conf.sync_dtim_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5274) NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5275) } else if (!ieee80211_hw_check(&sdata->local->hw,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5276) TIMING_BEACON_ONLY)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5277) ies = rcu_dereference(cbss->proberesp_ies);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5278) /* must be non-NULL since beacon IEs were NULL */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5279) sdata->vif.bss_conf.sync_tsf = ies->tsf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5280) sdata->vif.bss_conf.sync_device_ts =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5281) bss->device_ts_presp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5282) sdata->vif.bss_conf.sync_dtim_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5283) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5284) sdata->vif.bss_conf.sync_tsf = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5285) sdata->vif.bss_conf.sync_device_ts = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5286) sdata->vif.bss_conf.sync_dtim_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5287) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5288) rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5289) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5290)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5291) if (new_sta || override) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5292) err = ieee80211_prep_channel(sdata, cbss);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5293) if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5294) if (new_sta)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5295) sta_info_free(local, new_sta);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5296) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5297) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5298) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5299)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5300) if (new_sta) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5301) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5302) * tell driver about BSSID, basic rates and timing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5303) * this was set up above, before setting the channel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5304) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5305) ieee80211_bss_info_change_notify(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5306) BSS_CHANGED_BSSID | BSS_CHANGED_BASIC_RATES |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5307) BSS_CHANGED_BEACON_INT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5308)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5309) if (assoc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5310) sta_info_pre_move_state(new_sta, IEEE80211_STA_AUTH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5311)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5312) err = sta_info_insert(new_sta);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5313) new_sta = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5314) if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5315) sdata_info(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5316) "failed to insert STA entry for the AP (error %d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5317) err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5318) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5319) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5320) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5321) WARN_ON_ONCE(!ether_addr_equal(ifmgd->bssid, cbss->bssid));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5322)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5323) /* Cancel scan to ensure that nothing interferes with connection */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5324) if (local->scanning)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5325) ieee80211_scan_cancel(local);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5326)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5327) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5328) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5329)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5330) /* config hooks */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5331) int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5332) struct cfg80211_auth_request *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5333) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5334) struct ieee80211_local *local = sdata->local;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5335) struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5336) struct ieee80211_mgd_auth_data *auth_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5337) u16 auth_alg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5338) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5339) bool cont_auth;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5340)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5341) /* prepare auth data structure */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5342)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5343) switch (req->auth_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5344) case NL80211_AUTHTYPE_OPEN_SYSTEM:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5345) auth_alg = WLAN_AUTH_OPEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5346) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5347) case NL80211_AUTHTYPE_SHARED_KEY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5348) if (fips_enabled)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5349) return -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5350) auth_alg = WLAN_AUTH_SHARED_KEY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5351) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5352) case NL80211_AUTHTYPE_FT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5353) auth_alg = WLAN_AUTH_FT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5354) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5355) case NL80211_AUTHTYPE_NETWORK_EAP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5356) auth_alg = WLAN_AUTH_LEAP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5357) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5358) case NL80211_AUTHTYPE_SAE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5359) auth_alg = WLAN_AUTH_SAE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5360) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5361) case NL80211_AUTHTYPE_FILS_SK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5362) auth_alg = WLAN_AUTH_FILS_SK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5363) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5364) case NL80211_AUTHTYPE_FILS_SK_PFS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5365) auth_alg = WLAN_AUTH_FILS_SK_PFS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5366) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5367) case NL80211_AUTHTYPE_FILS_PK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5368) auth_alg = WLAN_AUTH_FILS_PK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5369) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5370) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5371) return -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5372) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5373)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5374) if (ifmgd->assoc_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5375) return -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5376)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5377) auth_data = kzalloc(sizeof(*auth_data) + req->auth_data_len +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5378) req->ie_len, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5379) if (!auth_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5380) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5381)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5382) auth_data->bss = req->bss;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5383)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5384) if (req->auth_data_len >= 4) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5385) if (req->auth_type == NL80211_AUTHTYPE_SAE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5386) __le16 *pos = (__le16 *) req->auth_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5387)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5388) auth_data->sae_trans = le16_to_cpu(pos[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5389) auth_data->sae_status = le16_to_cpu(pos[1]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5390) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5391) memcpy(auth_data->data, req->auth_data + 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5392) req->auth_data_len - 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5393) auth_data->data_len += req->auth_data_len - 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5394) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5395)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5396) /* Check if continuing authentication or trying to authenticate with the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5397) * same BSS that we were in the process of authenticating with and avoid
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5398) * removal and re-addition of the STA entry in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5399) * ieee80211_prep_connection().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5400) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5401) cont_auth = ifmgd->auth_data && req->bss == ifmgd->auth_data->bss;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5402)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5403) if (req->ie && req->ie_len) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5404) memcpy(&auth_data->data[auth_data->data_len],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5405) req->ie, req->ie_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5406) auth_data->data_len += req->ie_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5407) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5408)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5409) if (req->key && req->key_len) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5410) auth_data->key_len = req->key_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5411) auth_data->key_idx = req->key_idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5412) memcpy(auth_data->key, req->key, req->key_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5413) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5414)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5415) auth_data->algorithm = auth_alg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5416)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5417) /* try to authenticate/probe */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5418)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5419) if (ifmgd->auth_data) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5420) if (cont_auth && req->auth_type == NL80211_AUTHTYPE_SAE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5421) auth_data->peer_confirmed =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5422) ifmgd->auth_data->peer_confirmed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5423) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5424) ieee80211_destroy_auth_data(sdata, cont_auth);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5425) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5426)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5427) /* prep auth_data so we don't go into idle on disassoc */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5428) ifmgd->auth_data = auth_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5429)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5430) /* If this is continuation of an ongoing SAE authentication exchange
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5431) * (i.e., request to send SAE Confirm) and the peer has already
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5432) * confirmed, mark authentication completed since we are about to send
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5433) * out SAE Confirm.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5434) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5435) if (cont_auth && req->auth_type == NL80211_AUTHTYPE_SAE &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5436) auth_data->peer_confirmed && auth_data->sae_trans == 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5437) ieee80211_mark_sta_auth(sdata, req->bss->bssid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5438)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5439) if (ifmgd->associated) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5440) u8 frame_buf[IEEE80211_DEAUTH_FRAME_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5441)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5442) sdata_info(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5443) "disconnect from AP %pM for new auth to %pM\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5444) ifmgd->associated->bssid, req->bss->bssid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5445) ieee80211_set_disassoc(sdata, IEEE80211_STYPE_DEAUTH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5446) WLAN_REASON_UNSPECIFIED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5447) false, frame_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5448)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5449) ieee80211_report_disconnect(sdata, frame_buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5450) sizeof(frame_buf), true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5451) WLAN_REASON_UNSPECIFIED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5452) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5453)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5454) sdata_info(sdata, "authenticate with %pM\n", req->bss->bssid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5455)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5456) err = ieee80211_prep_connection(sdata, req->bss, cont_auth, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5457) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5458) goto err_clear;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5459)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5460) err = ieee80211_auth(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5461) if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5462) sta_info_destroy_addr(sdata, req->bss->bssid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5463) goto err_clear;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5464) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5465)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5466) /* hold our own reference */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5467) cfg80211_ref_bss(local->hw.wiphy, auth_data->bss);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5468) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5469)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5470) err_clear:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5471) eth_zero_addr(ifmgd->bssid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5472) ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BSSID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5473) ifmgd->auth_data = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5474) mutex_lock(&sdata->local->mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5475) ieee80211_vif_release_channel(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5476) mutex_unlock(&sdata->local->mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5477) kfree(auth_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5478) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5479) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5480)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5481) int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5482) struct cfg80211_assoc_request *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5483) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5484) bool is_6ghz = req->bss->channel->band == NL80211_BAND_6GHZ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5485) bool is_5ghz = req->bss->channel->band == NL80211_BAND_5GHZ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5486) struct ieee80211_local *local = sdata->local;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5487) struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5488) struct ieee80211_bss *bss = (void *)req->bss->priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5489) struct ieee80211_mgd_assoc_data *assoc_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5490) const struct cfg80211_bss_ies *beacon_ies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5491) struct ieee80211_supported_band *sband;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5492) const u8 *ssidie, *ht_ie, *vht_ie;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5493) int i, err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5494) bool override = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5495)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5496) assoc_data = kzalloc(sizeof(*assoc_data) + req->ie_len, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5497) if (!assoc_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5498) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5499)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5500) rcu_read_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5501) ssidie = ieee80211_bss_get_ie(req->bss, WLAN_EID_SSID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5502) if (!ssidie || ssidie[1] > sizeof(assoc_data->ssid)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5503) rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5504) kfree(assoc_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5505) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5506) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5507) memcpy(assoc_data->ssid, ssidie + 2, ssidie[1]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5508) assoc_data->ssid_len = ssidie[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5509) rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5510)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5511) if (ifmgd->associated) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5512) u8 frame_buf[IEEE80211_DEAUTH_FRAME_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5513)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5514) sdata_info(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5515) "disconnect from AP %pM for new assoc to %pM\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5516) ifmgd->associated->bssid, req->bss->bssid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5517) ieee80211_set_disassoc(sdata, IEEE80211_STYPE_DEAUTH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5518) WLAN_REASON_UNSPECIFIED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5519) false, frame_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5520)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5521) ieee80211_report_disconnect(sdata, frame_buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5522) sizeof(frame_buf), true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5523) WLAN_REASON_UNSPECIFIED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5524) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5525)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5526) if (ifmgd->auth_data && !ifmgd->auth_data->done) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5527) err = -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5528) goto err_free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5529) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5530)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5531) if (ifmgd->assoc_data) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5532) err = -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5533) goto err_free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5534) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5535)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5536) if (ifmgd->auth_data) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5537) bool match;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5538)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5539) /* keep sta info, bssid if matching */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5540) match = ether_addr_equal(ifmgd->bssid, req->bss->bssid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5541) ieee80211_destroy_auth_data(sdata, match);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5542) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5543)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5544) /* prepare assoc data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5545)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5546) ifmgd->beacon_crc_valid = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5547)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5548) assoc_data->wmm = bss->wmm_used &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5549) (local->hw.queues >= IEEE80211_NUM_ACS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5550)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5551) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5552) * IEEE802.11n does not allow TKIP/WEP as pairwise ciphers in HT mode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5553) * We still associate in non-HT mode (11a/b/g) if any one of these
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5554) * ciphers is configured as pairwise.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5555) * We can set this to true for non-11n hardware, that'll be checked
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5556) * separately along with the peer capabilities.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5557) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5558) for (i = 0; i < req->crypto.n_ciphers_pairwise; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5559) if (req->crypto.ciphers_pairwise[i] == WLAN_CIPHER_SUITE_WEP40 ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5560) req->crypto.ciphers_pairwise[i] == WLAN_CIPHER_SUITE_TKIP ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5561) req->crypto.ciphers_pairwise[i] == WLAN_CIPHER_SUITE_WEP104) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5562) ifmgd->flags |= IEEE80211_STA_DISABLE_HT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5563) ifmgd->flags |= IEEE80211_STA_DISABLE_VHT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5564) ifmgd->flags |= IEEE80211_STA_DISABLE_HE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5565) netdev_info(sdata->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5566) "disabling HT/VHT/HE due to WEP/TKIP use\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5567) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5568) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5569)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5570) sband = local->hw.wiphy->bands[req->bss->channel->band];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5571)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5572) /* also disable HT/VHT/HE if the AP doesn't use WMM */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5573) if (!bss->wmm_used) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5574) ifmgd->flags |= IEEE80211_STA_DISABLE_HT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5575) ifmgd->flags |= IEEE80211_STA_DISABLE_VHT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5576) ifmgd->flags |= IEEE80211_STA_DISABLE_HE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5577) netdev_info(sdata->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5578) "disabling HT/VHT/HE as WMM/QoS is not supported by the AP\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5579) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5580)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5581) memcpy(&ifmgd->ht_capa, &req->ht_capa, sizeof(ifmgd->ht_capa));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5582) memcpy(&ifmgd->ht_capa_mask, &req->ht_capa_mask,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5583) sizeof(ifmgd->ht_capa_mask));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5584)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5585) memcpy(&ifmgd->vht_capa, &req->vht_capa, sizeof(ifmgd->vht_capa));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5586) memcpy(&ifmgd->vht_capa_mask, &req->vht_capa_mask,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5587) sizeof(ifmgd->vht_capa_mask));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5588)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5589) memcpy(&ifmgd->s1g_capa, &req->s1g_capa, sizeof(ifmgd->s1g_capa));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5590) memcpy(&ifmgd->s1g_capa_mask, &req->s1g_capa_mask,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5591) sizeof(ifmgd->s1g_capa_mask));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5592)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5593) if (req->ie && req->ie_len) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5594) memcpy(assoc_data->ie, req->ie, req->ie_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5595) assoc_data->ie_len = req->ie_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5596) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5597)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5598) if (req->fils_kek) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5599) /* should already be checked in cfg80211 - so warn */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5600) if (WARN_ON(req->fils_kek_len > FILS_MAX_KEK_LEN)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5601) err = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5602) goto err_free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5603) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5604) memcpy(assoc_data->fils_kek, req->fils_kek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5605) req->fils_kek_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5606) assoc_data->fils_kek_len = req->fils_kek_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5607) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5608)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5609) if (req->fils_nonces)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5610) memcpy(assoc_data->fils_nonces, req->fils_nonces,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5611) 2 * FILS_NONCE_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5612)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5613) assoc_data->bss = req->bss;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5614)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5615) if (ifmgd->req_smps == IEEE80211_SMPS_AUTOMATIC) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5616) if (ifmgd->powersave)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5617) sdata->smps_mode = IEEE80211_SMPS_DYNAMIC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5618) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5619) sdata->smps_mode = IEEE80211_SMPS_OFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5620) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5621) sdata->smps_mode = ifmgd->req_smps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5622)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5623) assoc_data->capability = req->bss->capability;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5624) assoc_data->supp_rates = bss->supp_rates;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5625) assoc_data->supp_rates_len = bss->supp_rates_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5626)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5627) rcu_read_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5628) ht_ie = ieee80211_bss_get_ie(req->bss, WLAN_EID_HT_OPERATION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5629) if (ht_ie && ht_ie[1] >= sizeof(struct ieee80211_ht_operation))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5630) assoc_data->ap_ht_param =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5631) ((struct ieee80211_ht_operation *)(ht_ie + 2))->ht_param;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5632) else if (!is_6ghz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5633) ifmgd->flags |= IEEE80211_STA_DISABLE_HT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5634) vht_ie = ieee80211_bss_get_ie(req->bss, WLAN_EID_VHT_CAPABILITY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5635) if (vht_ie && vht_ie[1] >= sizeof(struct ieee80211_vht_cap))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5636) memcpy(&assoc_data->ap_vht_cap, vht_ie + 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5637) sizeof(struct ieee80211_vht_cap));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5638) else if (is_5ghz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5639) ifmgd->flags |= IEEE80211_STA_DISABLE_VHT |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5640) IEEE80211_STA_DISABLE_HE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5641) rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5642)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5643) if (WARN((sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_UAPSD) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5644) ieee80211_hw_check(&local->hw, PS_NULLFUNC_STACK),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5645) "U-APSD not supported with HW_PS_NULLFUNC_STACK\n"))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5646) sdata->vif.driver_flags &= ~IEEE80211_VIF_SUPPORTS_UAPSD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5647)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5648) if (bss->wmm_used && bss->uapsd_supported &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5649) (sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_UAPSD)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5650) assoc_data->uapsd = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5651) ifmgd->flags |= IEEE80211_STA_UAPSD_ENABLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5652) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5653) assoc_data->uapsd = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5654) ifmgd->flags &= ~IEEE80211_STA_UAPSD_ENABLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5655) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5656)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5657) if (req->prev_bssid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5658) memcpy(assoc_data->prev_bssid, req->prev_bssid, ETH_ALEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5659)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5660) if (req->use_mfp) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5661) ifmgd->mfp = IEEE80211_MFP_REQUIRED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5662) ifmgd->flags |= IEEE80211_STA_MFP_ENABLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5663) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5664) ifmgd->mfp = IEEE80211_MFP_DISABLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5665) ifmgd->flags &= ~IEEE80211_STA_MFP_ENABLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5666) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5667)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5668) if (req->flags & ASSOC_REQ_USE_RRM)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5669) ifmgd->flags |= IEEE80211_STA_ENABLE_RRM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5670) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5671) ifmgd->flags &= ~IEEE80211_STA_ENABLE_RRM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5672)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5673) if (req->crypto.control_port)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5674) ifmgd->flags |= IEEE80211_STA_CONTROL_PORT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5675) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5676) ifmgd->flags &= ~IEEE80211_STA_CONTROL_PORT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5677)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5678) sdata->control_port_protocol = req->crypto.control_port_ethertype;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5679) sdata->control_port_no_encrypt = req->crypto.control_port_no_encrypt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5680) sdata->control_port_over_nl80211 =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5681) req->crypto.control_port_over_nl80211;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5682) sdata->control_port_no_preauth = req->crypto.control_port_no_preauth;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5683) sdata->encrypt_headroom = ieee80211_cs_headroom(local, &req->crypto,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5684) sdata->vif.type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5685)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5686) /* kick off associate process */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5687)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5688) ifmgd->assoc_data = assoc_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5689) ifmgd->dtim_period = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5690) ifmgd->have_beacon = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5691)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5692) /* override HT/VHT configuration only if the AP and we support it */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5693) if (!(ifmgd->flags & IEEE80211_STA_DISABLE_HT)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5694) struct ieee80211_sta_ht_cap sta_ht_cap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5695)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5696) if (req->flags & ASSOC_REQ_DISABLE_HT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5697) override = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5698)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5699) memcpy(&sta_ht_cap, &sband->ht_cap, sizeof(sta_ht_cap));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5700) ieee80211_apply_htcap_overrides(sdata, &sta_ht_cap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5701)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5702) /* check for 40 MHz disable override */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5703) if (!(ifmgd->flags & IEEE80211_STA_DISABLE_40MHZ) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5704) sband->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40 &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5705) !(sta_ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5706) override = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5707)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5708) if (!(ifmgd->flags & IEEE80211_STA_DISABLE_VHT) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5709) req->flags & ASSOC_REQ_DISABLE_VHT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5710) override = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5711) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5712)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5713) if (req->flags & ASSOC_REQ_DISABLE_HT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5714) ifmgd->flags |= IEEE80211_STA_DISABLE_HT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5715) ifmgd->flags |= IEEE80211_STA_DISABLE_VHT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5716) ifmgd->flags |= IEEE80211_STA_DISABLE_HE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5717) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5718)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5719) if (req->flags & ASSOC_REQ_DISABLE_VHT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5720) ifmgd->flags |= IEEE80211_STA_DISABLE_VHT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5721)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5722) err = ieee80211_prep_connection(sdata, req->bss, true, override);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5723) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5724) goto err_clear;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5725)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5726) rcu_read_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5727) beacon_ies = rcu_dereference(req->bss->beacon_ies);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5728)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5729) if (ieee80211_hw_check(&sdata->local->hw, NEED_DTIM_BEFORE_ASSOC) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5730) !beacon_ies) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5731) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5732) * Wait up to one beacon interval ...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5733) * should this be more if we miss one?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5734) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5735) sdata_info(sdata, "waiting for beacon from %pM\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5736) ifmgd->bssid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5737) assoc_data->timeout = TU_TO_EXP_TIME(req->bss->beacon_interval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5738) assoc_data->timeout_started = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5739) assoc_data->need_beacon = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5740) } else if (beacon_ies) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5741) const struct element *elem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5742) u8 dtim_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5743)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5744) ieee80211_get_dtim(beacon_ies, &dtim_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5745) &ifmgd->dtim_period);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5746)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5747) ifmgd->have_beacon = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5748) assoc_data->timeout = jiffies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5749) assoc_data->timeout_started = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5750)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5751) if (ieee80211_hw_check(&local->hw, TIMING_BEACON_ONLY)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5752) sdata->vif.bss_conf.sync_tsf = beacon_ies->tsf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5753) sdata->vif.bss_conf.sync_device_ts =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5754) bss->device_ts_beacon;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5755) sdata->vif.bss_conf.sync_dtim_count = dtim_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5756) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5757)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5758) elem = cfg80211_find_ext_elem(WLAN_EID_EXT_MULTIPLE_BSSID_CONFIGURATION,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5759) beacon_ies->data, beacon_ies->len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5760) if (elem && elem->datalen >= 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5761) sdata->vif.bss_conf.profile_periodicity = elem->data[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5762) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5763) sdata->vif.bss_conf.profile_periodicity = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5764)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5765) elem = cfg80211_find_elem(WLAN_EID_EXT_CAPABILITY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5766) beacon_ies->data, beacon_ies->len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5767) if (elem && elem->datalen >= 11 &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5768) (elem->data[10] & WLAN_EXT_CAPA11_EMA_SUPPORT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5769) sdata->vif.bss_conf.ema_ap = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5770) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5771) sdata->vif.bss_conf.ema_ap = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5772) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5773) assoc_data->timeout = jiffies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5774) assoc_data->timeout_started = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5775) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5776) rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5777)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5778) run_again(sdata, assoc_data->timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5779)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5780) if (bss->corrupt_data) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5781) char *corrupt_type = "data";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5782) if (bss->corrupt_data & IEEE80211_BSS_CORRUPT_BEACON) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5783) if (bss->corrupt_data &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5784) IEEE80211_BSS_CORRUPT_PROBE_RESP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5785) corrupt_type = "beacon and probe response";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5786) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5787) corrupt_type = "beacon";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5788) } else if (bss->corrupt_data & IEEE80211_BSS_CORRUPT_PROBE_RESP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5789) corrupt_type = "probe response";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5790) sdata_info(sdata, "associating with AP with corrupt %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5791) corrupt_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5792) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5793)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5794) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5795) err_clear:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5796) eth_zero_addr(ifmgd->bssid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5797) ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BSSID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5798) ifmgd->assoc_data = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5799) err_free:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5800) kfree(assoc_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5801) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5802) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5803)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5804) int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5805) struct cfg80211_deauth_request *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5806) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5807) struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5808) u8 frame_buf[IEEE80211_DEAUTH_FRAME_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5809) bool tx = !req->local_state_change;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5810)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5811) if (ifmgd->auth_data &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5812) ether_addr_equal(ifmgd->auth_data->bss->bssid, req->bssid)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5813) sdata_info(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5814) "aborting authentication with %pM by local choice (Reason: %u=%s)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5815) req->bssid, req->reason_code,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5816) ieee80211_get_reason_code_string(req->reason_code));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5817)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5818) drv_mgd_prepare_tx(sdata->local, sdata, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5819) ieee80211_send_deauth_disassoc(sdata, req->bssid, req->bssid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5820) IEEE80211_STYPE_DEAUTH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5821) req->reason_code, tx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5822) frame_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5823) ieee80211_destroy_auth_data(sdata, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5824) ieee80211_report_disconnect(sdata, frame_buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5825) sizeof(frame_buf), true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5826) req->reason_code);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5827)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5828) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5829) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5830)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5831) if (ifmgd->assoc_data &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5832) ether_addr_equal(ifmgd->assoc_data->bss->bssid, req->bssid)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5833) sdata_info(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5834) "aborting association with %pM by local choice (Reason: %u=%s)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5835) req->bssid, req->reason_code,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5836) ieee80211_get_reason_code_string(req->reason_code));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5837)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5838) drv_mgd_prepare_tx(sdata->local, sdata, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5839) ieee80211_send_deauth_disassoc(sdata, req->bssid, req->bssid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5840) IEEE80211_STYPE_DEAUTH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5841) req->reason_code, tx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5842) frame_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5843) ieee80211_destroy_assoc_data(sdata, false, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5844) ieee80211_report_disconnect(sdata, frame_buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5845) sizeof(frame_buf), true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5846) req->reason_code);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5847) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5848) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5849)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5850) if (ifmgd->associated &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5851) ether_addr_equal(ifmgd->associated->bssid, req->bssid)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5852) sdata_info(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5853) "deauthenticating from %pM by local choice (Reason: %u=%s)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5854) req->bssid, req->reason_code,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5855) ieee80211_get_reason_code_string(req->reason_code));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5856)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5857) ieee80211_set_disassoc(sdata, IEEE80211_STYPE_DEAUTH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5858) req->reason_code, tx, frame_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5859) ieee80211_report_disconnect(sdata, frame_buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5860) sizeof(frame_buf), true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5861) req->reason_code);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5862) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5863) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5864)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5865) return -ENOTCONN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5866) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5867)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5868) int ieee80211_mgd_disassoc(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5869) struct cfg80211_disassoc_request *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5870) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5871) struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5872) u8 bssid[ETH_ALEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5873) u8 frame_buf[IEEE80211_DEAUTH_FRAME_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5874)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5875) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5876) * cfg80211 should catch this ... but it's racy since
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5877) * we can receive a disassoc frame, process it, hand it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5878) * to cfg80211 while that's in a locked section already
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5879) * trying to tell us that the user wants to disconnect.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5880) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5881) if (ifmgd->associated != req->bss)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5882) return -ENOLINK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5883)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5884) sdata_info(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5885) "disassociating from %pM by local choice (Reason: %u=%s)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5886) req->bss->bssid, req->reason_code, ieee80211_get_reason_code_string(req->reason_code));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5887)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5888) memcpy(bssid, req->bss->bssid, ETH_ALEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5889) ieee80211_set_disassoc(sdata, IEEE80211_STYPE_DISASSOC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5890) req->reason_code, !req->local_state_change,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5891) frame_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5892)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5893) ieee80211_report_disconnect(sdata, frame_buf, sizeof(frame_buf), true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5894) req->reason_code);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5895)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5896) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5897) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5898)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5899) void ieee80211_mgd_stop(struct ieee80211_sub_if_data *sdata)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5900) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5901) struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5902)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5903) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5904) * Make sure some work items will not run after this,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5905) * they will not do anything but might not have been
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5906) * cancelled when disconnecting.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5907) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5908) cancel_work_sync(&ifmgd->monitor_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5909) cancel_work_sync(&ifmgd->beacon_connection_loss_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5910) cancel_work_sync(&ifmgd->request_smps_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5911) cancel_work_sync(&ifmgd->csa_connection_drop_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5912) cancel_work_sync(&ifmgd->chswitch_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5913) cancel_delayed_work_sync(&ifmgd->tdls_peer_del_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5914)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5915) sdata_lock(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5916) if (ifmgd->assoc_data) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5917) struct cfg80211_bss *bss = ifmgd->assoc_data->bss;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5918) ieee80211_destroy_assoc_data(sdata, false, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5919) cfg80211_assoc_timeout(sdata->dev, bss);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5920) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5921) if (ifmgd->auth_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5922) ieee80211_destroy_auth_data(sdata, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5923) spin_lock_bh(&ifmgd->teardown_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5924) if (ifmgd->teardown_skb) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5925) kfree_skb(ifmgd->teardown_skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5926) ifmgd->teardown_skb = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5927) ifmgd->orig_teardown_skb = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5928) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5929) kfree(ifmgd->assoc_req_ies);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5930) ifmgd->assoc_req_ies = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5931) ifmgd->assoc_req_ies_len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5932) spin_unlock_bh(&ifmgd->teardown_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5933) del_timer_sync(&ifmgd->timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5934) sdata_unlock(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5935) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5936)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5937) void ieee80211_cqm_rssi_notify(struct ieee80211_vif *vif,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5938) enum nl80211_cqm_rssi_threshold_event rssi_event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5939) s32 rssi_level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5940) gfp_t gfp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5941) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5942) struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5943)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5944) trace_api_cqm_rssi_notify(sdata, rssi_event, rssi_level);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5945)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5946) cfg80211_cqm_rssi_notify(sdata->dev, rssi_event, rssi_level, gfp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5947) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5948) EXPORT_SYMBOL(ieee80211_cqm_rssi_notify);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5949)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5950) void ieee80211_cqm_beacon_loss_notify(struct ieee80211_vif *vif, gfp_t gfp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5951) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5952) struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5953)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5954) trace_api_cqm_beacon_loss_notify(sdata->local, sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5955)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5956) cfg80211_cqm_beacon_loss_notify(sdata->dev, gfp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5957) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5958) EXPORT_SYMBOL(ieee80211_cqm_beacon_loss_notify);