/* get special S1G case out of the way */ if (sband->band == NL80211_BAND_S1GHZ) { if (!ieee80211_chandef_s1g_oper(elems->s1g_oper, chandef)) {
sdata_info(sdata, "Missing S1G Operation Element? Trying operating == primary\n");
chandef->width = ieee80211_s1g_channel_width(channel);
}
return IEEE80211_CONN_MODE_S1G;
}
/* get special 6 GHz case out of the way */ if (sband->band == NL80211_BAND_6GHZ) { enum ieee80211_conn_mode mode = IEEE80211_CONN_MODE_EHT;
/* this is an error */ if (conn->mode < IEEE80211_CONN_MODE_HE) return IEEE80211_CONN_MODE_LEGACY;
if (!elems->he_6ghz_capa || !elems->he_cap) {
sdata_info(sdata, "HE 6 GHz AP is missing HE/HE 6 GHz band capability\n"); return IEEE80211_CONN_MODE_LEGACY;
}
if (!ieee80211_chandef_vht_oper(&sdata->local->hw, vht_cap_info,
&he_oper_vht_cap, ht_oper,
&vht_chandef)) {
sdata_info(sdata, "HE AP VHT information is invalid, disabling HE\n"); /* this will cause us to re-parse as VHT STA */ return IEEE80211_CONN_MODE_VHT;
}
} elseif (!vht_oper || !elems->vht_cap_elem) { if (sband->band == NL80211_BAND_5GHZ) {
sdata_info(sdata, "VHT information is missing, disabling VHT\n"); return IEEE80211_CONN_MODE_HT;
}
no_vht = true;
} elseif (sband->band == NL80211_BAND_2GHZ) {
no_vht = true;
} elseif (!ieee80211_chandef_vht_oper(&sdata->local->hw,
vht_cap_info,
vht_oper, ht_oper,
&vht_chandef)) {
sdata_info(sdata, "AP VHT information is invalid, disabling VHT\n"); return IEEE80211_CONN_MODE_HT;
}
if (!cfg80211_chandef_compatible(chandef, &vht_chandef)) {
sdata_info(sdata, "AP VHT information doesn't match HT, disabling VHT\n"); return IEEE80211_CONN_MODE_HT;
}
*chandef = vht_chandef;
/* stick to current max mode if we or the AP don't have HE */ if (conn->mode < IEEE80211_CONN_MODE_HE ||
!elems->he_operation || !elems->he_cap) { if (no_vht) return IEEE80211_CONN_MODE_HT; return IEEE80211_CONN_MODE_VHT;
}
/* stick to HE if we or the AP don't have EHT */ if (conn->mode < IEEE80211_CONN_MODE_EHT ||
!eht_oper || !elems->eht_cap) return IEEE80211_CONN_MODE_HE;
/* Simply check that all basic rates are in the STA RX mask */ for (i = 0; i < IEEE80211_HT_MCS_MASK_LEN; i++) { if ((ht_op->basic_set[i] & sta_ht_cap.mcs.rx_mask[i]) !=
ht_op->basic_set[i]) returnfalse;
}
/* Need to go over for 80MHz, 160MHz and for 80+80 */ for (i = 0; i < 3; i++) { conststruct ieee80211_he_mcs_nss_supp *sta_mcs_nss_supp =
&sta_he_cap->he_mcs_nss_supp;
u16 sta_mcs_map_rx =
le16_to_cpu(((__le16 *)sta_mcs_nss_supp)[2 * i]);
u16 sta_mcs_map_tx =
le16_to_cpu(((__le16 *)sta_mcs_nss_supp)[2 * i + 1]);
u8 nss; bool verified = true;
/* handle us being a 20 MHz-only EHT STA - with four values *forMCS0-7,8-9,10-11,12-13.
*/ if (!(he_phy_cap0 & IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_MASK_ALL)) return sta_eht_cap->eht_mcs_nss_supp.only_20mhz.rx_tx_max_nss[idx];
/* the others have MCS 0-9 together, rather than separately from 0-7 */ if (idx > 0)
idx--;
/* *Skipmembershipselectorssincethey'renotrates. * *Note:Eventhoughthemembershipselectorandthebasic *rateflagsharethesamebit,theyarenotexactly *thesame.
*/ if (is_basic && rate >= BSS_MEMBERSHIP_SELECTOR_MIN) { if (unknown_rates_selectors)
set_bit(rate, unknown_rates_selectors); continue;
}
for (j = 0; j < sband->n_bitrates; j++) { struct ieee80211_rate *br; int brate;
br = &sband->bitrates[j];
brate = DIV_ROUND_UP(br->bitrate, 5); if (brate == rate) { if (rates)
*rates |= BIT(j); if (is_basic && basic_rates)
*basic_rates |= BIT(j); if (min_rate && (rate * 5) < *min_rate) {
*min_rate = rate * 5; if (min_rate_index)
*min_rate_index = j;
} break;
}
}
/* Handle an unknown entry as if it is an unknown selector */ if (is_basic && unknown_rates_selectors && j == sband->n_bitrates)
set_bit(rate, unknown_rates_selectors);
}
}
staticint ieee80211_chandef_num_widths(conststruct cfg80211_chan_def *c)
{ switch (c->width) { case NL80211_CHAN_WIDTH_20: case NL80211_CHAN_WIDTH_20_NOHT: return1; case NL80211_CHAN_WIDTH_40: return2; case NL80211_CHAN_WIDTH_80P80: case NL80211_CHAN_WIDTH_80: return3; case NL80211_CHAN_WIDTH_160: return4; case NL80211_CHAN_WIDTH_320: return5; default:
WARN_ON(1); return0;
}
}
VISIBLE_IF_MAC80211_KUNIT int
ieee80211_calc_chandef_subchan_offset(conststruct cfg80211_chan_def *ap,
u8 n_partial_subchans)
{ int n = ieee80211_chandef_num_subchans(ap); struct cfg80211_chan_def tmp = *ap; int offset = 0;
/* first reorder according to AP channel */
offset = ieee80211_calc_chandef_subchan_offset(ap, psd->n); for (int i = 0; i < have; i++) { if (i < offset)
tmp[i] = psd->power[i + psd->n]; elseif (i < offset + psd->n)
tmp[i] = psd->power[i - offset]; else
tmp[i] = psd->power[i];
}
/* *andthenselectthesubsetfortheusedchannel *(seteverythingtodefaultsfirstincaseadriverisconfused)
*/
memset(psd->power, IEEE80211_TPE_PSD_NO_LIMIT, sizeof(psd->power));
offset = ieee80211_calc_chandef_subchan_offset(ap, needed); for (int i = 0; i < needed; i++)
psd->power[i] = tmp[offset + i];
out: /* limit, but don't lie if there are defaults in the data */ if (needed < psd->count)
psd->count = needed;
}
EXPORT_SYMBOL_IF_MAC80211_KUNIT(ieee80211_rearrange_tpe_psd);
staticvoid ieee80211_rearrange_tpe(struct ieee80211_parsed_tpe *tpe, conststruct cfg80211_chan_def *ap, conststruct cfg80211_chan_def *used)
{ /* ignore this completely for narrow/invalid channels */ if (!ieee80211_chandef_num_subchans(ap) ||
!ieee80211_chandef_num_subchans(used)) {
ieee80211_clear_tpe(tpe); return;
}
for (int i = 0; i < 2; i++) { int needed_pwr_count;
/* limit this to the widths we actually need */
needed_pwr_count = ieee80211_chandef_num_widths(used); if (needed_pwr_count < tpe->max_local[i].count)
tpe->max_local[i].count = needed_pwr_count; if (needed_pwr_count < tpe->max_reg_client[i].count)
tpe->max_reg_client[i].count = needed_pwr_count;
}
}
/* Check if we support all required features */ if (!bitmap_subset(unknown_rates_selectors, sta_selectors, 128)) {
link_id_info(sdata, link_id, "required basic rate or BSS membership selectors not supported or disabled, rejecting connection\n");
ret = -EINVAL; goto free;
}
/* TPE element is not present in (re)assoc/ML reconfig response */ if (stype == IEEE80211_STYPE_BEACON &&
ap_chandef.chan->band == NL80211_BAND_6GHZ &&
link->u.mgd.conn.mode >= IEEE80211_CONN_MODE_HE) {
ieee80211_rearrange_tpe(&elems->tpe, &ap_chandef,
&chanreq.oper); if (memcmp(&link->conf->tpe, &elems->tpe, sizeof(elems->tpe))) {
link->conf->tpe = elems->tpe;
*changed |= BSS_CHANGED_TPE;
}
}
if (ieee80211_chanreq_identical(&chanreq, &link->conf->chanreq)) return0;
link_info(link, "AP %pM changed bandwidth in %s, new used config is %d.%03d MHz, width %d (%d.%03d/%d MHz)\n",
link->u.mgd.bssid, frame, chanreq.oper.chan->center_freq,
chanreq.oper.chan->freq_offset, chanreq.oper.width,
chanreq.oper.center_freq1, chanreq.oper.freq1_offset,
chanreq.oper.center_freq2);
if (!cfg80211_chandef_valid(&chanreq.oper)) {
sdata_info(sdata, "AP %pM changed caps/bw in %s in a way we can't support - disconnect\n",
link->u.mgd.bssid, frame); return -EINVAL;
}
if (!update) {
link->conf->chanreq = chanreq; return0;
}
ret = ieee80211_link_change_chanreq(link, &chanreq, changed); if (ret) {
sdata_info(sdata, "AP %pM changed bandwidth in %s to incompatible one - disconnect\n",
link->u.mgd.bssid, frame); return ret;
}
/* determine capability flags */
cap = ht_cap.cap;
switch (ap_ht_param & IEEE80211_HT_PARAM_CHA_SEC_OFFSET) { case IEEE80211_HT_PARAM_CHA_SEC_ABOVE: if (flags & IEEE80211_CHAN_NO_HT40PLUS) {
cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
cap &= ~IEEE80211_HT_CAP_SGI_40;
} break; case IEEE80211_HT_PARAM_CHA_SEC_BELOW: if (flags & IEEE80211_CHAN_NO_HT40MINUS) {
cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
cap &= ~IEEE80211_HT_CAP_SGI_40;
} break;
}
/* *If40MHzwasdisabledassociateasthoughweweren't *capableof40MHz--somebrokenAPswillneverfall *backtotryingtotransmitin20MHz.
*/ if (conn->bw_limit <= IEEE80211_CONN_BW_LIMIT_20) {
cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
cap &= ~IEEE80211_HT_CAP_SGI_40;
}
/* set SM PS mode properly */
cap &= ~IEEE80211_HT_CAP_SM_PS; switch (smps) { case IEEE80211_SMPS_AUTOMATIC: case IEEE80211_SMPS_NUM_MODES:
WARN_ON(1);
fallthrough; case IEEE80211_SMPS_OFF:
cap |= WLAN_HT_CAP_SM_PS_DISABLED <<
IEEE80211_HT_CAP_SM_PS_SHIFT; break; case IEEE80211_SMPS_STATIC:
cap |= WLAN_HT_CAP_SM_PS_STATIC <<
IEEE80211_HT_CAP_SM_PS_SHIFT; break; case IEEE80211_SMPS_DYNAMIC:
cap |= WLAN_HT_CAP_SM_PS_DYNAMIC <<
IEEE80211_HT_CAP_SM_PS_SHIFT; break;
}
/* reserve and fill IE */
pos = skb_put(skb, sizeof(struct ieee80211_ht_cap) + 2);
ieee80211_ie_build_ht_cap(pos, &ht_cap, cap);
}
/* This function determines vht capability flags for the association *andbuildstheIE. *Note-thefunctionreturnstruetoowntheMU-MIMOcapability
*/ staticbool ieee80211_add_vht_ie(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb, struct ieee80211_supported_band *sband, struct ieee80211_vht_cap *ap_vht_cap, conststruct ieee80211_conn_settings *conn)
{ struct ieee80211_local *local = sdata->local;
u8 *pos;
u32 cap; struct ieee80211_sta_vht_cap vht_cap;
u32 mask, ap_bf_sts, our_bf_sts; bool mu_mimo_owner = false;
#define ADD_PRESENT_ELEM(id) do { \ /* need a last for termination - we use 0 == SSID */ \ if (!WARN_ON(present_elems_len >= PRESENT_ELEMS_MAX - 1)) \
present_elems[present_elems_len++] = (id); \
} while (0) #define ADD_PRESENT_EXT_ELEM(id) ADD_PRESENT_ELEM(PRESENT_ELEM_EXT_OFFS | (id))
/* should be the same across all BSSes */ if (cbss->capability & WLAN_CAPABILITY_PRIVACY)
capab |= WLAN_CAPABILITY_PRIVACY;
}
if (ieee80211_vif_is_mld(&sdata->vif)) { /* consider the multi-link element with STA profile */
size += sizeof(struct ieee80211_multi_link_elem); /* max common info field in basic multi-link element */
size += sizeof(struct ieee80211_mle_basic_common_info) + 2 + /* capa & op */ 2 + /* ext capa & op */ 2; /* EML capa */
/* *Thecapabilityelementswerealreadyconsideredabove; *notethisover-estimatesabitbecausethere'sno *STAprofilefortheassoclink.
*/
size += (n_links - 1) *
(1 + 1 + /* subelement ID/length */ 2 + /* STA control */ 1 + ETH_ALEN + 2/* STA Info field */);
}
link = sdata_dereference(sdata->link[assoc_data->assoc_link_id], sdata); if (WARN_ON(!link)) return -EINVAL;
if (WARN_ON(!assoc_data->link[assoc_data->assoc_link_id].bss)) return -EINVAL;
skb = alloc_skb(size, GFP_KERNEL); if (!skb) return -ENOMEM;
skb_reserve(skb, local->hw.extra_tx_headroom);
if (ifmgd->flags & IEEE80211_STA_ENABLE_RRM)
capab |= WLAN_CAPABILITY_RADIO_MEASURE;
/* Set MBSSID support for HE AP if needed */ if (ieee80211_hw_check(&local->hw, SUPPORTS_ONLY_HE_MULTI_BSSID) &&
link->u.mgd.conn.mode >= IEEE80211_CONN_MODE_HE &&
ext_capa && ext_capa->datalen >= 3)
ext_capa->data[2] |= WLAN_EXT_CAPA3_MULTI_BSSID_SUPPORT;
if (type != IEEE80211_TBTT_INFO_TYPE_TBTT) return RNR_ITER_CONTINUE;
if (tbtt_info_len < sizeof(*ti)) return RNR_ITER_CONTINUE;
ti = (constvoid *)tbtt_info;
if (ti->mld_params.mld_id != data->mld_id) return RNR_ITER_CONTINUE;
link_id = le16_get_bits(ti->mld_params.params,
IEEE80211_RNR_MLD_PARAMS_LINK_ID); if (link_id != data->link->link_id) return RNR_ITER_CONTINUE;
/* we found the entry for our link! */
/* this AP is confused, it had this right before ... just disconnect */ if (!ieee80211_operating_class_to_band(info->op_class, &band)) {
link_info(link, "AP now has invalid operating class in RNR, disconnect\n");
wiphy_work_queue(sdata->local->hw.wiphy,
&ifmgd->csa_connection_drop_work); return RNR_ITER_BREAK;
}
if (res < 0) { /* ignore this case, not a protected frame */ if (source == IEEE80211_CSA_SOURCE_UNPROT_ACTION) return; goto drop_connection;
}
if (link->conf->csa_active) { switch (source) { case IEEE80211_CSA_SOURCE_PROT_ACTION: case IEEE80211_CSA_SOURCE_UNPROT_ACTION: /* already processing - disregard action frames */ return; case IEEE80211_CSA_SOURCE_BEACON: if (link->u.mgd.csa.waiting_bcn) {
ieee80211_chswitch_post_beacon(link); /* *IftheCSAisstillpresentaftertheswitch *weneedtoconsideritasanewCSA(possibly *toself).Thishappensbynotreturninghere *sowe'llgettothecheckbelow.
*/
} elseif (res) {
ieee80211_sta_abort_chanswitch(link); return;
} else {
drv_channel_switch_rx_beacon(sdata, &ch_switch); return;
} break; case IEEE80211_CSA_SOURCE_OTHER_LINK: /* active link: we want to see the beacon to continue */ if (ieee80211_vif_link_active(&sdata->vif,
link->link_id)) return;
/* switch work ran, so just complete the process */ if (link->u.mgd.csa.waiting_bcn) {
ieee80211_chswitch_post_beacon(link); /* *IftheCSAisstillpresentaftertheswitch *weneedtoconsideritasanewCSA(possibly *toself).Thishappensbynotreturninghere *sowe'llgettothecheckbelow.
*/ break;
}
/* link still has CSA but we already know, do nothing */ if (!res) return;
/* check in the RNR if the CSA aborted */
ieee80211_sta_other_link_csa_disappeared(link,
full_elems); return;
}
}
/* no active CSA nor a new one */ if (res) { /* *However,wemayhavestoppedqueueswhenreceivingapublic *actionframethatcouldn'tbeprotected,ifithadthequiet *bitset.Thisisatrade-off,wewanttobequietassoonas *possible,butalsodon'ttrustthepublicactionframemuch, *asitcan'tbeprotected.
*/ if (unlikely(link->u.mgd.csa.blocked_tx)) {
link->u.mgd.csa.blocked_tx = false;
ieee80211_vif_unblock_queues_csa(sdata);
} return;
}
conf = rcu_dereference_protected(link->conf->chanctx_conf,
lockdep_is_held(&local->hw.wiphy->mtx)); if (ieee80211_vif_link_active(&sdata->vif, link->link_id) && !conf) {
link_info(link, "no channel context assigned to vif?, disconnecting\n"); goto drop_connection;
}
if (conf)
chanctx = container_of(conf, struct ieee80211_chanctx, conf);
if (!ieee80211_hw_check(&local->hw, CHANCTX_STA_CSA)) {
link_info(link, "driver doesn't support chan-switch with channel contexts\n"); goto drop_connection;
}
if (drv_pre_channel_switch(sdata, &ch_switch)) {
link_info(link, "preparing for channel switch failed, disconnecting\n"); goto drop_connection;
}
/* we may have to handle timeout for deactivated link in software */
now = ktime_get_boottime();
csa_time_tu = (max_t(int, csa_ie.count, 1) - 1) * link->conf->beacon_int;
link->u.mgd.csa.time = now + us_to_ktime(ieee80211_tu_to_usec(csa_time_tu));
/*
* Update bss_param_ch_cnt_link_id even if bss_param_ch_cnt
* didn't change to indicate that we got a beacon on our own
* link.
*/
if (bss_param_ch_cnt >= 0 && bss_param_ch_cnt != 255) {
bss_conf->bss_param_ch_cnt = bss_param_ch_cnt;
bss_conf->bss_param_ch_cnt_link_id =
bss_conf->link_id;
}
}
static bool
ieee80211_find_80211h_pwr_constr(struct ieee80211_channel *channel,
const u8 *country_ie, u8 country_ie_len,
const u8 *pwr_constr_elem,
int *chan_pwr, int *pwr_reduction)
{
struct ieee80211_country_ie_triplet *triplet;
int chan = ieee80211_frequency_to_channel(channel->center_freq);
int i, chan_increment;
bool have_chan_pwr = false;
switch (channel->band) {
default:
WARN_ON_ONCE(1);
fallthrough;
case NL80211_BAND_2GHZ:
case NL80211_BAND_60GHZ:
case NL80211_BAND_LC:
chan_increment = 1;
break;
case NL80211_BAND_5GHZ:
chan_increment = 4;
break;
case NL80211_BAND_6GHZ:
/*
* In the 6 GHz band, the "maximum transmit power level"
* field in the triplets is reserved, and thus will be
* zero and we shouldn't use it to control TX power.
* The actual TX power will be given in the transmit
* power envelope element instead.
*/
return false;
}
if (first_channel >= IEEE80211_COUNTRY_EXTENSION_ID)
goto next;
for (i = 0; i < triplet->chans.num_channels; i++) {
if (first_channel + i * chan_increment == chan) {
have_chan_pwr = true;
*chan_pwr = triplet->chans.max_power;
break;
}
}
if (have_chan_pwr)
break;
static void ieee80211_find_cisco_dtpc(struct ieee80211_channel *channel,
const u8 *cisco_dtpc_ie,
int *pwr_level)
{
/* From practical testing, the first data byte of the DTPC element
* seems to contain the requested dBm level, and the CLI on Cisco
* APs clearly state the range is -127 to 127 dBm, which indicates
* a signed byte, although it seemingly never actually goes negative.
* The other byte seems to always be zero.
*/
*pwr_level = (__s8)cisco_dtpc_ie[4];
}
/* If we have both 802.11h and Cisco DTPC, apply both limits
* by picking the smallest of the two power levels advertised.
*/
if (has_80211h_pwr &&
(!has_cisco_pwr || pwr_level_80211h <= pwr_level_cisco)) {
new_ap_level = pwr_level_80211h;
if (link->ap_power_level == new_ap_level)
return 0;
sdata_dbg(sdata,
"Limiting TX power to %d (%d - %d) dBm as advertised by %pM\n",
pwr_level_80211h, chan_pwr, pwr_reduction_80211h,
link->u.mgd.bssid);
} else { /* has_cisco_pwr is always true here. */
new_ap_level = pwr_level_cisco;
if (link->ap_power_level == new_ap_level)
return 0;
sdata_dbg(sdata,
"Limiting TX power to %d dBm as advertised by %pM\n",
pwr_level_cisco, link->u.mgd.bssid);
}
link->ap_power_level = new_ap_level;
if (__ieee80211_recalc_txpower(link))
return BSS_CHANGED_TXPOWER;
return 0;
}
if (mgd->flags & IEEE80211_STA_CONNECTION_POLL)
return false;
if (!(local->hw.wiphy->flags & WIPHY_FLAG_SUPPORTS_MLO) &&
!sdata->deflink.u.mgd.have_beacon)
return false;
rcu_read_lock();
sta = sta_info_get(sdata, sdata->vif.cfg.ap_addr);
if (sta)
authorized = test_sta_flag(sta, WLAN_STA_AUTHORIZED);
rcu_read_unlock();
return authorized;
}
/* need to hold RTNL or interface lock */
void ieee80211_recalc_ps(struct ieee80211_local *local)
{
struct ieee80211_sub_if_data *sdata, *found = NULL;
int count = 0;
int timeout;
list_for_each_entry(sdata, &local->interfaces, list) {
if (!ieee80211_sdata_running(sdata))
continue;
if (sdata->vif.type == NL80211_IFTYPE_AP) {
/* If an AP vif is found, then disable PS
* by setting the count to zero thereby setting
* ps_sdata to NULL.
*/
count = 0;
break;
}
if (sdata->vif.type != NL80211_IFTYPE_STATION)
continue;
found = sdata;
count++;
}
/* can only happen when PS was just disabled anyway */
if (!sdata)
return;
ifmgd = &sdata->u.mgd;
if (local->hw.conf.flags & IEEE80211_CONF_PS)
return;
if (local->hw.conf.dynamic_ps_timeout > 0) {
/* don't enter PS if TX frames are pending */
if (drv_tx_frames_pending(local)) {
mod_timer(&local->dynamic_ps_timer, jiffies +
msecs_to_jiffies(
local->hw.conf.dynamic_ps_timeout));
return;
}
/*
* transmission can be stopped by others which leads to
* dynamic_ps_timer expiry. Postpone the ps timer if it
* is not the actual idle state.
*/
spin_lock_irqsave(&local->queue_stop_reason_lock, flags);
for (q = 0; q < local->hw.queues; q++) {
if (local->queue_stop_reasons[q]) {
spin_unlock_irqrestore(&local->queue_stop_reason_lock,
flags);
mod_timer(&local->dynamic_ps_timer, jiffies +
msecs_to_jiffies(
local->hw.conf.dynamic_ps_timeout));
return;
}
}
spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
}
if (ieee80211_hw_check(&local->hw, PS_NULLFUNC_STACK) &&
!(ifmgd->flags & IEEE80211_STA_NULLFUNC_ACKED)) {
if (drv_tx_frames_pending(local)) {
mod_timer(&local->dynamic_ps_timer, jiffies +
msecs_to_jiffies(
local->hw.conf.dynamic_ps_timeout));
} else {
ieee80211_send_nullfunc(local, sdata, true);
/* Flush to get the tx status of nullfunc frame */
ieee80211_flush_queues(local, sdata, false);
}
}
if (local->hw.queues < IEEE80211_NUM_ACS)
return false;
for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) {
struct ieee80211_sta_tx_tspec *tx_tspec = &ifmgd->tx_tspec[ac];
int non_acm_ac;
unsigned long now = jiffies;
if (tx_tspec->downgraded)
tx_tspec->action =
TX_TSPEC_ACTION_STOP_DOWNGRADE;
}
switch (tx_tspec->action) {
case TX_TSPEC_ACTION_STOP_DOWNGRADE:
/* take the original parameters */
if (drv_conf_tx(local, &sdata->deflink, ac,
&sdata->deflink.tx_conf[ac]))
link_err(&sdata->deflink,
"failed to set TX queue parameters for queue %d\n",
ac);
tx_tspec->action = TX_TSPEC_ACTION_NONE;
tx_tspec->downgraded = false;
ret = true;
break;
case TX_TSPEC_ACTION_DOWNGRADE:
if (time_after(now, tx_tspec->time_slice_start + HZ)) {
tx_tspec->action = TX_TSPEC_ACTION_NONE;
ret = true;
break;
}
/* downgrade next lower non-ACM AC */
for (non_acm_ac = ac + 1;
non_acm_ac < IEEE80211_NUM_ACS;
non_acm_ac++)
if (!(sdata->wmm_acm & BIT(7 - 2 * non_acm_ac)))
break;
/* Usually the loop will result in using BK even if it
* requires admission control, but such a configuration
* makes no sense and we have to transmit somehow - the
* AC selection does the same thing.
* If we started out trying to downgrade from BK, then
* the extra condition here might be needed.
*/
if (non_acm_ac >= IEEE80211_NUM_ACS)
non_acm_ac = IEEE80211_AC_BK;
if (drv_conf_tx(local, &sdata->deflink, ac,
&sdata->deflink.tx_conf[non_acm_ac]))
link_err(&sdata->deflink,
"failed to set TX queue parameters for queue %d\n",
ac);
tx_tspec->action = TX_TSPEC_ACTION_NONE;
ret = true;
wiphy_delayed_work_queue(local->hw.wiphy,
&ifmgd->tx_tspec_wk,
tx_tspec->time_slice_start +
HZ - now + 1);
break;
case TX_TSPEC_ACTION_NONE:
/* nothing now */
break;
}
}
if (local->hw.queues < IEEE80211_NUM_ACS)
return false;
if (!wmm_param)
return false;
if (wmm_param_len < 8 || wmm_param[5] /* version */ != 1)
return false;
if (ifmgd->flags & IEEE80211_STA_UAPSD_ENABLED)
uapsd_queues = ifmgd->uapsd_queues;
count = wmm_param[6] & 0x0f;
/* -1 is the initial value of ifmgd->mu_edca_last_param_set.
* if mu_edca was preset before and now it disappeared tell
* the driver about it.
*/
mu_edca_count = mu_edca ? mu_edca->mu_qos_info & 0x0f : -1;
if (count == link->u.mgd.wmm_last_param_set &&
mu_edca_count == link->u.mgd.mu_edca_last_param_set)
return false;
link->u.mgd.wmm_last_param_set = count;
link->u.mgd.mu_edca_last_param_set = mu_edca_count;
pos = wmm_param + 8;
left = wmm_param_len - 8;
memset(¶ms, 0, sizeof(params));
sdata->wmm_acm = 0;
for (; left >= 4; left -= 4, pos += 4) {
int aci = (pos[0] >> 5) & 0x03;
int acm = (pos[0] >> 4) & 0x01;
bool uapsd = false;
switch (aci) {
case 1: /* AC_BK */
ac = IEEE80211_AC_BK;
if (acm)
sdata->wmm_acm |= BIT(1) | BIT(2); /* BK/- */
if (uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_BK)
uapsd = true;
params[ac].mu_edca = !!mu_edca;
if (mu_edca)
params[ac].mu_edca_param_rec = mu_edca->ac_bk;
break;
case 2: /* AC_VI */
ac = IEEE80211_AC_VI;
if (acm)
sdata->wmm_acm |= BIT(4) | BIT(5); /* CL/VI */
if (uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_VI)
uapsd = true;
params[ac].mu_edca = !!mu_edca;
if (mu_edca)
params[ac].mu_edca_param_rec = mu_edca->ac_vi;
break;
case 3: /* AC_VO */
ac = IEEE80211_AC_VO;
if (acm)
sdata->wmm_acm |= BIT(6) | BIT(7); /* VO/NC */
if (uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_VO)
uapsd = true;
params[ac].mu_edca = !!mu_edca;
if (mu_edca)
params[ac].mu_edca_param_rec = mu_edca->ac_vo;
break;
case 0: /* AC_BE */
default:
ac = IEEE80211_AC_BE;
if (acm)
sdata->wmm_acm |= BIT(0) | BIT(3); /* BE/EE */
if (uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_BE)
uapsd = true;
params[ac].mu_edca = !!mu_edca;
if (mu_edca)
params[ac].mu_edca_param_rec = mu_edca->ac_be;
break;
}
params[ac].aifs = pos[0] & 0x0f;
if (params[ac].aifs < 2) {
link_info(link,
"AP has invalid WMM params (AIFSN=%d for ACI %d), will use 2\n",
params[ac].aifs, aci);
params[ac].aifs = 2;
}
params[ac].cw_max = ecw2cw((pos[1] & 0xf0) >> 4);
params[ac].cw_min = ecw2cw(pos[1] & 0x0f);
params[ac].txop = get_unaligned_le16(pos + 2);
params[ac].acm = acm;
params[ac].uapsd = uapsd;
if (params[ac].cw_min == 0 ||
params[ac].cw_min > params[ac].cw_max) {
link_info(link,
"AP has invalid WMM params (CWmin/max=%d/%d for ACI %d), using defaults\n",
params[ac].cw_min, params[ac].cw_max, aci);
return false;
}
ieee80211_regulatory_limit_wmm_params(sdata, ¶ms[ac], ac);
}
/* WMM specification requires all 4 ACIs. */
for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) {
if (params[ac].cw_min == 0) {
link_info(link,
"AP has invalid WMM params (missing AC %d), using defaults\n",
ac);
return false;
}
}
for (ac = 0; ac < IEEE80211_NUM_ACS; ac++)
link->tx_conf[ac] = params[ac];
/* leave this here to not change ordering in non-MLO cases */
if (!ieee80211_vif_is_mld(&sdata->vif))
ieee80211_recalc_smps(sdata, &sdata->deflink);
ieee80211_recalc_ps_vif(sdata);
if (!ieee80211_vif_link_active(&sdata->vif, link_id))
continue;
link = sdata_dereference(sdata->link[link_id], sdata);
if (WARN_ON_ONCE(!link))
continue;
if (link->u.mgd.csa.blocked_tx)
continue;
tx_link_found = true;
break;
}
tx = tx_link_found;
}
/* other links will be destroyed */
sdata->deflink.conf->bss = NULL;
sdata->deflink.conf->epcs_support = false;
sdata->deflink.smps_mode = IEEE80211_SMPS_OFF;
netif_carrier_off(sdata->dev);
/*
* if we want to get out of ps before disassoc (why?) we have
* to do it before sending disassoc, as otherwise the null-packet
* won't be valid.
*/
if (local->hw.conf.flags & IEEE80211_CONF_PS) {
local->hw.conf.flags &= ~IEEE80211_CONF_PS;
ieee80211_hw_config(local, -1, IEEE80211_CONF_CHANGE_PS);
}
local->ps_sdata = NULL;
/* make sure ongoing transmission finishes */
synchronize_net();
/*
* drop any frame before deauth/disassoc, this can be data or
* management frame. Since we are disconnecting, we should not
* insist sending these frames which can take time and delay
* the disconnection and possible the roaming.
*/
ieee80211_flush_queues(local, sdata, true);
if (tx) {
drv_mgd_prepare_tx(sdata->local, sdata, &info);
if (sdata->vif.driver_flags & IEEE80211_VIF_REMOVE_AP_AFTER_DISASSOC) {
/* Only move the AP state */
sta_info_move_state(ap_sta, IEEE80211_STA_NONE);
} else {
/* Remove AP peer */
sta_info_flush(sdata, -1);
}
/* finally reset all BSS / config parameters */
if (!ieee80211_vif_is_mld(&sdata->vif))
changed |= ieee80211_reset_erp_info(sdata);
/* on the next assoc, re-program HT/VHT parameters */
memset(&ifmgd->ht_capa, 0, sizeof(ifmgd->ht_capa));
memset(&ifmgd->ht_capa_mask, 0, sizeof(ifmgd->ht_capa_mask));
memset(&ifmgd->vht_capa, 0, sizeof(ifmgd->vht_capa));
memset(&ifmgd->vht_capa_mask, 0, sizeof(ifmgd->vht_capa_mask));
/*
* reset MU-MIMO ownership and group data in default link,
* if used, other links are destroyed
*/
memset(sdata->vif.bss_conf.mu_group.membership, 0,
sizeof(sdata->vif.bss_conf.mu_group.membership));
memset(sdata->vif.bss_conf.mu_group.position, 0,
sizeof(sdata->vif.bss_conf.mu_group.position));
if (!ieee80211_vif_is_mld(&sdata->vif))
changed |= BSS_CHANGED_MU_GROUPS;
sdata->vif.bss_conf.mu_mimo_owner = false;
if (sdata->vif.driver_flags & IEEE80211_VIF_REMOVE_AP_AFTER_DISASSOC) {
/*
* After notifying the driver about the disassoc,
* remove the ap sta.
*/
sta_info_flush(sdata, -1);
}
/* disassociated - set to defaults now */
ieee80211_set_wmm_default(&sdata->deflink, false, false);
/* if disconnection happens in the middle of the ML reconfiguration
* flow, cfg80211 must called to release the BSS references obtained
* when the flow started.
*/
ieee80211_ml_reconf_reset(sdata);
if (!(ifmgd->flags & IEEE80211_STA_CONNECTION_POLL))
return;
__ieee80211_stop_poll(sdata);
ieee80211_recalc_ps(local);
if (ieee80211_hw_check(&sdata->local->hw, CONNECTION_MONITOR))
return;
/*
* We've received a probe response, but are not sure whether
* we have or will be receiving any beacons or data, so let's
* schedule the timers again, just in case.
*/
ieee80211_sta_reset_beacon_monitor(sdata);
/*
* Try sending broadcast probe requests for the last three
* probe requests after the first ones failed since some
* buggy APs only support broadcast probe requests.
*/
if (ifmgd->probe_send_count >= unicast_limit)
dst = NULL;
/*
* When the hardware reports an accurate Tx ACK status, it's
* better to send a nullfunc frame instead of a probe request,
* as it will kick us off the AP quickly if we aren't associated
* anymore. The timeout will be reset if the frame is ACKed by
* the AP.
*/
ifmgd->probe_send_count++;
if (dst) {
sta = sta_info_get(sdata, dst);
if (!WARN_ON(!sta))
ieee80211_check_fast_rx(sta);
}
/*
* The driver/our work has already reported this event or the
* connection monitoring has kicked in and we have already sent
* a probe request. Or maybe the AP died and the driver keeps
* reporting until we disassociate...
*
* In either case we have to ignore the current call to this
* function (except for setting the correct probe reason bit)
* because otherwise we would reset the timer every time and
* never check whether we received a probe response!
*/
if (ifmgd->flags & IEEE80211_STA_CONNECTION_POLL)
already = true;
if (!ifmgd->driver_disconnect) {
unsigned int link_id;
/*
* AP is probably out of range (or not reachable for another
* reason) so remove the bss structs for that AP. In the case
* of multi-link, it's not clear that all of them really are
* out of range, but if they weren't the driver likely would
* have switched to just have a single link active?
*/
for (link_id = 0;
link_id < ARRAY_SIZE(sdata->link);
link_id++) {
struct ieee80211_link_data *link;
link = sdata_dereference(sdata->link[link_id], sdata);
if (!link || !link->conf->bss)
continue;
cfg80211_unlink_bss(local->hw.wiphy, link->conf->bss);
link->conf->bss = NULL;
}
}
ieee80211_set_disassoc(sdata, IEEE80211_STYPE_DEAUTH,
ifmgd->driver_disconnect ?
WLAN_REASON_DEAUTH_LEAVING :
WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY,
true, frame_buf);
/* the other links will be destroyed */
sdata->vif.bss_conf.csa_active = false;
sdata->deflink.u.mgd.csa.waiting_bcn = false;
sdata->deflink.u.mgd.csa.blocked_tx = false;
ieee80211_vif_unblock_queues_csa(sdata);
if (!assoc) {
/*
* we are not authenticated yet, the only timer that could be
* running is the timeout for the authentication response which
* which is not relevant anymore.
*/
timer_delete_sync(&sdata->u.mgd.timer);
sta_info_destroy_addr(sdata, auth_data->ap_addr);
/* other links are destroyed */
eth_zero_addr(sdata->deflink.u.mgd.bssid);
ieee80211_link_info_change_notify(sdata, &sdata->deflink,
BSS_CHANGED_BSSID);
sdata->u.mgd.flags = 0;
if (status != ASSOC_SUCCESS) {
/*
* we are not associated yet, the only timer that could be
* running is the timeout for the association response which
* which is not relevant anymore.
*/
timer_delete_sync(&sdata->u.mgd.timer);
sta_info_destroy_addr(sdata, assoc_data->ap_addr);
/* move station state to auth */
sta = sta_info_get(sdata, ap_addr);
if (!sta) {
WARN_ONCE(1, "%s: STA %pM not found", sdata->name, ap_addr);
return false;
}
if (sta_info_move_state(sta, IEEE80211_STA_AUTH)) {
sdata_info(sdata, "failed moving %pM to auth\n", ap_addr);
return false;
}
switch (ifmgd->auth_data->algorithm) {
case WLAN_AUTH_OPEN:
case WLAN_AUTH_LEAP:
case WLAN_AUTH_FT:
case WLAN_AUTH_SAE:
case WLAN_AUTH_FILS_SK:
case WLAN_AUTH_FILS_SK_PFS:
case WLAN_AUTH_FILS_PK:
break;
case WLAN_AUTH_SHARED_KEY:
if (ifmgd->auth_data->expected_transaction != 4) {
ieee80211_auth_challenge(sdata, mgmt, len);
/* need another frame */
return;
}
break;
default:
WARN_ONCE(1, "invalid auth alg %d",
ifmgd->auth_data->algorithm);
goto notify_driver;
}
static void ieee80211_epcs_changed(struct ieee80211_sub_if_data *sdata,
bool enabled)
{
/* in any case this is called, dialog token should be reset */
sdata->u.mgd.epcs.dialog_token = 0;
elems = ieee802_11_parse_elems_full(&parse_params);
if (!elems)
return false;
if (link_id == assoc_data->assoc_link_id) {
capab_info = le16_to_cpu(mgmt->u.assoc_resp.capab_info);
/*
* we should not get to this flow unless the association was
* successful, so set the status directly to success
*/
assoc_data->link[link_id].status = WLAN_STATUS_SUCCESS;
if (elems->ml_basic) {
int bss_param_ch_cnt =
ieee80211_mle_get_bss_param_ch_cnt((const void *)elems->ml_basic);
if (bss_param_ch_cnt < 0) {
ret = false;
goto out;
}
bss_conf->bss_param_ch_cnt = bss_param_ch_cnt;
bss_conf->bss_param_ch_cnt_link_id = link_id;
}
} else if (elems->parse_error & IEEE80211_PARSE_ERR_DUP_NEST_ML_BASIC ||
!elems->prof ||
!(elems->prof->control & prof_bss_param_ch_present)) {
ret = false;
goto out;
} else {
const u8 *ptr = elems->prof->variable +
elems->prof->sta_info_len - 1;
int bss_param_ch_cnt;
/*
* During parsing, we validated that these fields exist,
* otherwise elems->prof would have been set to NULL.
*/
capab_info = get_unaligned_le16(ptr);
assoc_data->link[link_id].status = get_unaligned_le16(ptr + 2);
bss_param_ch_cnt =
ieee80211_mle_basic_sta_prof_bss_param_ch_cnt(elems->prof);
bss_conf->bss_param_ch_cnt = bss_param_ch_cnt;
bss_conf->bss_param_ch_cnt_link_id = link_id;
if (assoc_data->link[link_id].status != WLAN_STATUS_SUCCESS) {
link_info(link, "association response status code=%u\n",
assoc_data->link[link_id].status);
ret = true;
goto out;
}
}
if (!is_s1g && !elems->supp_rates) {
sdata_info(sdata, "no SuppRates element in AssocResp\n");
ret = false;
goto out;
}
/*
* Some APs are erroneously not including some information in their
* (re)association response frames. Try to recover by using the data
* from the beacon or probe response. This seems to afflict mobile
* 2G/3G/4G wifi routers, reported models include the "Onda PN51T",
* "Vodafone PocketWiFi 2", "ZTE MF60" and a similar T-Mobile device.
*/
if (!ieee80211_hw_check(&local->hw, STRICT) && !is_6ghz &&
((assoc_data->wmm && !elems->wmm_param) ||
(link->u.mgd.conn.mode >= IEEE80211_CONN_MODE_HT &&
(!elems->ht_cap_elem || !elems->ht_operation)) ||
(is_5ghz && link->u.mgd.conn.mode >= IEEE80211_CONN_MODE_VHT &&
(!elems->vht_cap_elem || !elems->vht_operation)))) {
const struct cfg80211_bss_ies *ies;
struct ieee802_11_elems *bss_elems;
rcu_read_lock();
ies = rcu_dereference(cbss->ies);
if (ies)
bss_ies = kmemdup(ies, sizeof(*ies) + ies->len,
GFP_ATOMIC);
rcu_read_unlock();
if (!bss_ies) {
ret = false;
goto out;
}
if (assoc_data->wmm &&
!elems->wmm_param && bss_elems->wmm_param) {
elems->wmm_param = bss_elems->wmm_param;
sdata_info(sdata,
"AP bug: WMM param missing from AssocResp\n");
}
/*
* Also check if we requested HT/VHT, otherwise the AP doesn't
* have to include the IEs in the (re)association response.
*/
if (!elems->ht_cap_elem && bss_elems->ht_cap_elem &&
link->u.mgd.conn.mode >= IEEE80211_CONN_MODE_HT) {
elems->ht_cap_elem = bss_elems->ht_cap_elem;
sdata_info(sdata,
"AP bug: HT capability missing from AssocResp\n");
}
if (!elems->ht_operation && bss_elems->ht_operation &&
link->u.mgd.conn.mode >= IEEE80211_CONN_MODE_HT) {
elems->ht_operation = bss_elems->ht_operation;
sdata_info(sdata,
"AP bug: HT operation missing from AssocResp\n");
}
if (is_5ghz) {
if (!elems->vht_cap_elem && bss_elems->vht_cap_elem &&
link->u.mgd.conn.mode >= IEEE80211_CONN_MODE_VHT) {
elems->vht_cap_elem = bss_elems->vht_cap_elem;
sdata_info(sdata,
"AP bug: VHT capa missing from AssocResp\n");
}
/*
* We previously checked these in the beacon/probe response, so
* they should be present here. This is just a safety net.
* Note that the ieee80211_config_bw() below would also check
* for this (and more), but this has better error reporting.
*/
if (!is_6ghz && link->u.mgd.conn.mode >= IEEE80211_CONN_MODE_HT &&
(!elems->wmm_param || !elems->ht_cap_elem || !elems->ht_operation)) {
sdata_info(sdata,
"HT AP is missing WMM params or HT capability/operation\n");
ret = false;
goto out;
}
if (is_5ghz && link->u.mgd.conn.mode >= IEEE80211_CONN_MODE_VHT &&
(!elems->vht_cap_elem || !elems->vht_operation)) {
sdata_info(sdata,
"VHT AP is missing VHT capability/operation\n");
ret = false;
goto out;
}
/* check/update if AP changed anything in assoc response vs. scan */
if (ieee80211_config_bw(link, elems,
link_id == assoc_data->assoc_link_id,
changed,
le16_to_cpu(mgmt->frame_control) &
IEEE80211_FCTL_STYPE)) {
ret = false;
goto out;
}
if (WARN_ON(!link->conf->chanreq.oper.chan)) {
ret = false;
goto out;
}
sband = local->hw.wiphy->bands[link->conf->chanreq.oper.chan->band];
/* Set up internal HT/VHT capabilities */
if (elems->ht_cap_elem && link->u.mgd.conn.mode >= IEEE80211_CONN_MODE_HT)
ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband,
elems->ht_cap_elem,
link_sta);
/*
* Cisco AP module 9115 with FW 17.3 has a bug and sends a
* too large maximum MPDU length in the association response
* (indicating 12k) that it cannot actually process ...
* Work around that.
*/
rcu_read_lock();
ies = rcu_dereference(cbss->ies);
if (ies) {
const struct element *elem;
/* EPCS might be already enabled but a new added link
* does not support EPCS. This should not really happen
* in practice.
*/
if (sdata->u.mgd.epcs.enabled &&
!bss_conf->epcs_support)
ieee80211_epcs_teardown(sdata);
} else {
bss_conf->eht_support = false;
bss_conf->epcs_support = false;
}
} else {
bss_conf->he_support = false;
bss_conf->twt_requester = false;
bss_conf->twt_protected = false;
bss_conf->eht_support = false;
bss_conf->epcs_support = false;
}
bss_conf->uora_exists = !!elems->uora_element; if (elems->uora_element)
bss_conf->uora_ocw_range = elems->uora_element[0];
ieee80211_he_op_ie_to_bss_conf(&sdata->vif, elems->he_operation);
ieee80211_he_spr_ie_to_bss_conf(&sdata->vif, elems->he_spr); /* TODO: OPEN: what happens if BSS color disable is set? */
}
if (conn->bw_limit == IEEE80211_CONN_BW_LIMIT_20) {
mlme_link_id_dbg(sdata, link_id, "no 40 MHz support on 5 GHz, limiting to HT\n"); goto out;
}
/* Allow VHT if at least one channel on the sband supports 80 MHz */ for (i = 0; i < sband->n_channels; i++) { if (sband->channels[i].flags & (IEEE80211_CHAN_DISABLED |
IEEE80211_CHAN_NO_80MHZ)) continue;
have_80mhz = true; break;
}
if (!have_80mhz) {
mlme_link_id_dbg(sdata, link_id, "no 80 MHz channel support on 5 GHz, limiting to HT\n"); goto out;
}
} elseif (is_5ghz) { /* !vht_supported but on 5 GHz */
mlme_link_id_dbg(sdata, link_id, "no VHT support on 5 GHz, limiting to HT\n"); goto out;
}
/* VHT - if we have - is fine, including 80 MHz, check 160 below again */ if (sband->band != NL80211_BAND_2GHZ) {
conn->mode = IEEE80211_CONN_MODE_VHT;
conn->bw_limit = IEEE80211_CONN_BW_LIMIT_160;
}
if (is_5ghz &&
!(vht_cap.cap & (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ |
IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ))) {
conn->bw_limit = IEEE80211_CONN_BW_LIMIT_80;
mlme_link_id_dbg(sdata, link_id, "no VHT 160 MHz capability on 5 GHz, limiting to 80 MHz");
}
if (req && req->flags & ASSOC_REQ_DISABLE_HE) {
mlme_link_id_dbg(sdata, link_id, "HE disabled by flag, limiting to HT/VHT\n"); goto out;
}
he_cap = ieee80211_get_he_iftype_cap_vif(sband, &sdata->vif); if (!he_cap) {
WARN_ON(is_6ghz);
mlme_link_id_dbg(sdata, link_id, "no HE support, limiting to HT/VHT\n"); goto out;
}
/* so we have HE */
conn->mode = IEEE80211_CONN_MODE_HE;
/* check bandwidth */ switch (sband->band) { default: case NL80211_BAND_2GHZ: if (he_cap->he_cap_elem.phy_cap_info[0] &
IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_IN_2G) break;
conn->bw_limit = IEEE80211_CONN_BW_LIMIT_20;
mlme_link_id_dbg(sdata, link_id, "no 40 MHz HE cap in 2.4 GHz, limiting to 20 MHz\n"); break; case NL80211_BAND_5GHZ: if (!(he_cap->he_cap_elem.phy_cap_info[0] &
IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_80MHZ_IN_5G)) {
conn->bw_limit = IEEE80211_CONN_BW_LIMIT_20;
mlme_link_id_dbg(sdata, link_id, "no 40/80 MHz HE cap in 5 GHz, limiting to 20 MHz\n"); break;
} if (!(he_cap->he_cap_elem.phy_cap_info[0] &
IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_160MHZ_IN_5G)) {
conn->bw_limit = min_t(enum ieee80211_conn_bw_limit,
conn->bw_limit,
IEEE80211_CONN_BW_LIMIT_80);
mlme_link_id_dbg(sdata, link_id, "no 160 MHz HE cap in 5 GHz, limiting to 80 MHz\n");
} break; case NL80211_BAND_6GHZ: if (he_cap->he_cap_elem.phy_cap_info[0] &
IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_160MHZ_IN_5G) break;
conn->bw_limit = min_t(enum ieee80211_conn_bw_limit,
conn->bw_limit,
IEEE80211_CONN_BW_LIMIT_80);
mlme_link_id_dbg(sdata, link_id, "no 160 MHz HE cap in 6 GHz, limiting to 80 MHz\n"); break;
}
if (req && req->flags & ASSOC_REQ_DISABLE_EHT) {
mlme_link_id_dbg(sdata, link_id, "EHT disabled by flag, limiting to HE\n"); goto out;
}
eht_cap = ieee80211_get_eht_iftype_cap_vif(sband, &sdata->vif); if (!eht_cap) {
mlme_link_id_dbg(sdata, link_id, "no EHT support, limiting to HE\n"); goto out;
}
/* we have EHT */
conn->mode = IEEE80211_CONN_MODE_EHT;
/* check bandwidth */ if (is_6ghz &&
eht_cap->eht_cap_elem.phy_cap_info[0] & IEEE80211_EHT_PHY_CAP0_320MHZ_IN_6GHZ)
conn->bw_limit = IEEE80211_CONN_BW_LIMIT_320; elseif (is_6ghz)
mlme_link_id_dbg(sdata, link_id, "no EHT 320 MHz cap in 6 GHz, limiting to 160 MHz\n");
out:
mlme_link_id_dbg(sdata, link_id, "determined local STA to be %s, BW limited to %d MHz\n",
ieee80211_conn_mode_str(conn->mode), 20 * (1 << conn->bw_limit));
}
link->conf->tpe = elems->tpe;
ieee80211_rearrange_tpe(&link->conf->tpe, &ap_chandef,
&chanreq.oper);
}
rcu_read_unlock(); /* the element data was RCU protected so no longer valid anyway */
kfree(elems);
elems = NULL;
lockdep_assert_wiphy(sdata->local->hw.wiphy); /* *stationinfowasalreadyallocatedandinsertedbefore *theassociationandshouldbeavailabletous
*/
sta = sta_info_get(sdata, assoc_data->ap_addr); if (WARN_ON(!sta)) goto out_err;
sta->sta.spp_amsdu = assoc_data->spp_amsdu;
if (ieee80211_vif_is_mld(&sdata->vif)) { for (link_id = 0; link_id < IEEE80211_MLD_MAX_NUM_LINKS; link_id++) { if (!assoc_data->link[link_id].bss) continue;
valid_links |= BIT(link_id); if (assoc_data->link[link_id].disabled)
dormant_links |= BIT(link_id);
if (link_id != assoc_data->assoc_link_id) {
err = ieee80211_sta_allocate_link(sta, link_id); if (err) goto out_err;
}
}
if (elems->aid_resp)
aid = le16_to_cpu(elems->aid_resp->aid); elseif (assoc_data->s1g)
aid = 0; /* TODO */ else
aid = le16_to_cpu(mgmt->u.assoc_resp.aid);
/* *The5MSBoftheAIDfieldarereserved *(802.11-20169.4.1.8AIDfield)
*/
aid &= 0x7ff;
tu = le32_to_cpu(elems->timeout_int->value);
ms = tu * 1024 / 1000;
sdata_info(sdata, "%pM rejected association temporarily; comeback duration %u TU (%u ms)\n",
assoc_data->ap_addr, tu, ms);
assoc_data->timeout = jiffies + msecs_to_jiffies(ms);
assoc_data->timeout_started = true;
assoc_data->comeback = true; if (ms > IEEE80211_ASSOC_TIMEOUT)
run_again(sdata, assoc_data->timeout); goto notify_driver;
}
if (status_code != WLAN_STATUS_SUCCESS) {
sdata_info(sdata, "%pM denied association (code=%d)\n",
assoc_data->ap_addr, status_code);
event.u.mlme.status = MLME_DENIED;
event.u.mlme.reason = status_code;
drv_event_callback(sdata->local, sdata, &event);
} else { if (aid == 0 || aid > IEEE80211_MAX_AID) {
sdata_info(sdata, "invalid AID value %d (out of range), turn off PS\n",
aid);
aid = 0;
ifmgd->broken_ap = true;
}
if (ieee80211_vif_is_mld(&sdata->vif)) { struct ieee80211_mle_basic_common_info *common;
if (!elems->ml_basic) {
sdata_info(sdata, "MLO association with %pM but no (basic) multi-link element in response!\n",
assoc_data->ap_addr); goto abandon_assoc;
}
common = (void *)elems->ml_basic->variable;
if (memcmp(assoc_data->ap_addr,
common->mld_mac_addr, ETH_ALEN)) {
sdata_info(sdata, "AP MLD MAC address mismatch: got %pM expected %pM\n",
common->mld_mac_addr,
assoc_data->ap_addr); goto abandon_assoc;
}
link = sdata_dereference(sdata->link[link_id], sdata); if (!link) continue;
/* get uapsd queues configuration - same for all links */
resp.uapsd_queues = 0; for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) if (link->tx_conf[ac].uapsd)
resp.uapsd_queues |= ieee80211_ac_to_qos_mask[ac];
}
if (ieee80211_vif_is_mld(&sdata->vif)) {
ether_addr_copy(ap_mld_addr, sdata->vif.cfg.ap_addr);
resp.ap_mld_addr = ap_mld_addr;
}
if (bss_conf->cqm_rssi_thold &&
link->u.mgd.count_beacon_signal >= IEEE80211_SIGNAL_AVE_MIN_COUNT &&
!(sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI)) { int sig = -ewma_beacon_signal_read(&link->u.mgd.ave_beacon_signal); int last_event = link->u.mgd.last_cqm_event_signal; int thold = bss_conf->cqm_rssi_thold; int hyst = bss_conf->cqm_rssi_hyst;
if (bss_conf->cqm_rssi_low &&
link->u.mgd.count_beacon_signal >= IEEE80211_SIGNAL_AVE_MIN_COUNT) { int sig = -ewma_beacon_signal_read(&link->u.mgd.ave_beacon_signal); int last_event = link->u.mgd.last_cqm_event_signal; int low = bss_conf->cqm_rssi_low; int high = bss_conf->cqm_rssi_high;
new_valid_links = sdata->vif.valid_links & ~sdata->u.mgd.removed_links; if (new_valid_links == sdata->vif.valid_links) return;
if (!new_valid_links ||
!(new_valid_links & ~sdata->vif.dormant_links)) {
sdata_info(sdata, "No valid links after reconfiguration\n");
ret = -EINVAL; goto out;
}
new_active_links = sdata->vif.active_links & ~sdata->u.mgd.removed_links; if (new_active_links != sdata->vif.active_links) { if (!new_active_links)
new_active_links =
BIT(ffs(new_valid_links &
~sdata->vif.dormant_links) - 1);
ret = ieee80211_set_active_links(&sdata->vif, new_active_links); if (ret) {
sdata_info(sdata, "Failed setting active links\n"); goto out;
}
}
if (!ieee80211_vif_is_mld(&sdata->vif) || !elems->ml_reconf) return;
/* Directly parse the sub elements as the common information doesn't *holdanyusefulinformation.
*/
for_each_mle_subelement(sub, (const u8 *)elems->ml_reconf,
elems->ml_reconf_len) { struct ieee80211_mle_per_sta_profile *prof = (void *)sub->data;
u8 *pos = prof->variable;
u16 control;
if (sub->id != IEEE80211_MLE_SUBELEM_PER_STA_PROFILE) continue;
if (!ieee80211_mle_reconf_sta_prof_size_ok(sub->data,
sub->datalen)) return;
control = le16_to_cpu(prof->control);
link_id = control & IEEE80211_MLE_STA_RECONF_CONTROL_LINK_ID;
removed_links |= BIT(link_id);
/* the MAC address should not be included, but handle it */ if (control &
IEEE80211_MLE_STA_RECONF_CONTROL_STA_MAC_ADDR_PRESENT)
pos += 6;
/* According to Draft P802.11be_D3.0, the control should *includetheAPRemovalTimerpresent.IftheAPRemovalTimer *isnotpresentassumeimmediateremoval.
*/ if (control &
IEEE80211_MLE_STA_RECONF_CONTROL_AP_REM_TIMER_PRESENT)
link_removal_timeout[link_id] = get_unaligned_le16(pos);
}
removed_links &= sdata->vif.valid_links; if (!removed_links) { /* In case the removal was cancelled, abort it */ if (sdata->u.mgd.removed_links) {
sdata->u.mgd.removed_links = 0;
wiphy_hrtimer_work_cancel(sdata->local->hw.wiphy,
&sdata->u.mgd.ml_reconf_work);
} return;
}
/* If there is an active negotiated TTLM, it should be discarded by *thenewnegotiated/advertisedTTLM.
*/ if (sdata->vif.neg_ttlm.valid) {
memset(&sdata->vif.neg_ttlm, 0, sizeof(sdata->vif.neg_ttlm));
sdata->vif.suspended_links = 0;
changed = BSS_CHANGED_MLD_TTLM;
}
if (sdata->vif.active_links != active_links) { /* usable links are affected when active_links are changed, *sonotifythedriveraboutthestatuschange
*/
changed |= BSS_CHANGED_MLD_VALID_LINKS;
active_links &= sdata->vif.active_links; if (!active_links)
active_links =
BIT(__ffs(sdata->vif.valid_links &
~dormant_links));
ret = ieee80211_set_active_links(&sdata->vif, active_links); if (ret) {
sdata_info(sdata, "Failed to set TTLM active links\n"); goto out;
}
}
ret = ieee80211_vif_set_links(sdata, sdata->vif.valid_links,
dormant_links); if (ret) {
sdata_info(sdata, "Failed to set TTLM dormant links\n"); goto out;
}
sdata->vif.suspended_links = suspended_links; if (sdata->vif.suspended_links)
changed |= BSS_CHANGED_MLD_TTLM;
ieee80211_vif_cfg_change_notify(sdata, changed);
out: if (ret)
ieee80211_disconnect(&sdata->vif, false);
if (!elems->ttlm_num) { if (sdata->u.mgd.ttlm_info.switch_time) { /* if a planned TID-to-link mapping was cancelled - *abortit
*/
wiphy_hrtimer_work_cancel(sdata->local->hw.wiphy,
&sdata->u.mgd.ttlm_work);
} elseif (sdata->u.mgd.ttlm_info.active) { /* if no TID-to-link element, set to default mapping in *whichallTIDsaremappedtoallsetuplinks
*/
ret = ieee80211_vif_set_links(sdata,
sdata->vif.valid_links, 0); if (ret) {
sdata_info(sdata, "Failed setting valid/dormant links\n"); return;
}
ieee80211_vif_cfg_change_notify(sdata,
BSS_CHANGED_MLD_VALID_LINKS);
}
memset(&sdata->u.mgd.ttlm_info, 0, sizeof(sdata->u.mgd.ttlm_info)); return;
}
for (i = 0; i < elems->ttlm_num; i++) { struct ieee80211_adv_ttlm_info ttlm_info;
u32 res;
res = ieee80211_parse_adv_t2l(sdata, elems->ttlm[i],
&ttlm_info);
if (res) {
__ieee80211_disconnect(sdata); return;
}
/* Link switching can take time, so schedule it *100msbeforetobereadyontime
*/ if (delay_usec > IEEE80211_ADV_TTLM_SAFETY_BUFFER_MS)
delay_usec -=
IEEE80211_ADV_TTLM_SAFETY_BUFFER_MS; else
delay_usec = 0;
if (!ieee80211_mle_basic_sta_prof_size_ok(sub->data,
sub->datalen)) continue;
link_id = le16_get_bits(prof->control,
IEEE80211_MLE_STA_CONTROL_LINK_ID); /* need a valid link ID, but also not our own, both AP bugs */ if (link_id == reporting_link_id ||
link_id >= IEEE80211_MLD_MAX_NUM_LINKS) continue;
link = sdata_dereference(sdata->link[link_id], sdata); if (!link) continue;
len = cfg80211_defragment_element(sub, subelems, subelems_len,
NULL, 0,
IEEE80211_MLE_SUBELEM_FRAGMENT); if (WARN_ON(len < 0)) continue;
link = sdata_dereference(sdata->link[link_id], sdata); if (!link) continue;
if (!sta_profiles[link_id]) {
prof_elems = NULL; goto handle;
}
/* we can defragment in-place, won't use the buffer again */
len = cfg80211_defragment_element(sta_profiles[link_id],
subelems, subelems_len,
(void *)sta_profiles[link_id],
sta_profiles_len[link_id],
IEEE80211_MLE_SUBELEM_FRAGMENT); if (WARN_ON(len != sta_profiles_len[link_id])) continue;
if (!ifmgd->associated ||
!ieee80211_rx_our_beacon(bssid, bss_conf->bss)) return;
bssid = link->u.mgd.bssid;
if (!(rx_status->flag & RX_FLAG_NO_SIGNAL_VAL))
ieee80211_handle_beacon_sig(link, ifmgd, bss_conf,
local, rx_status);
if (ifmgd->flags & IEEE80211_STA_CONNECTION_POLL) {
mlme_dbg_ratelimited(sdata, "cancelling AP probe due to a received beacon\n");
ieee80211_reset_ap_probe(sdata);
}
/* TODO: CRC urrently not calculated on S1G Beacon Compatibility *element(whichcarriesthebeaconinterval).Don'tforgettoadda *bittocare_about_ies[]aboveifmac80211isinterestedina *changingS1Gelement.
*/ if (!ieee80211_is_s1g_beacon(hdr->frame_control))
ncrc = crc32_be(0, (void *)&mgmt->u.beacon.beacon_int, 4);
parse_params.bss = bss_conf->bss;
parse_params.filter = care_about_ies;
parse_params.crc = ncrc;
elems = ieee802_11_parse_elems_full(&parse_params); if (!elems) return;
if (rx_status->flag & RX_FLAG_DECRYPTED &&
ieee80211_mgd_ssid_mismatch(sdata, elems)) {
sdata_info(sdata, "SSID mismatch for AP %pM, disconnect\n",
sdata->vif.cfg.ap_addr);
__ieee80211_disconnect(sdata); return;
}
ncrc = elems->crc;
if (ieee80211_hw_check(&local->hw, PS_NULLFUNC_STACK) &&
ieee80211_check_tim(elems->tim, elems->tim_len, vif_cfg->aid)) {
if (local->hw.conf.dynamic_ps_timeout > 0) {
if (local->hw.conf.flags & IEEE80211_CONF_PS) {
local->hw.conf.flags &= ~IEEE80211_CONF_PS;
ieee80211_hw_config(local, -1,
IEEE80211_CONF_CHANGE_PS);
}
ieee80211_send_nullfunc(local, sdata, false);
} else if (!local->pspolling && sdata->u.mgd.powersave) {
local->pspolling = true;
/*
* Here is assumed that the driver will be
* able to send ps-poll frame and receive a
* response even though power save mode is
* enabled, but some drivers might require
* to disable power save here. This needs
* to be investigated.
*/
ieee80211_send_pspoll(local, sdata);
}
}
if (sdata->vif.p2p ||
sdata->vif.driver_flags & IEEE80211_VIF_GET_NOA_UPDATE) {
struct ieee80211_p2p_noa_attr noa = {};
int ret;
ret = cfg80211_get_p2p_attr(variable,
len - baselen,
IEEE80211_P2P_ATTR_ABSENCE_NOTICE,
(u8 *) &noa, sizeof(noa));
if (ret >= 2) {
if (link->u.mgd.p2p_noa_index != noa.index) {
/* valid noa_attr and index changed */ link->u.mgd.p2p_noa_index = noa.index;
memcpy(&bss_conf->p2p_noa_attr, &noa, sizeof(noa));
changed |= BSS_CHANGED_P2P_PS;
/*
* make sure we update all information, the CRC
* mechanism doesn't look at P2P attributes.
*/ link->u.mgd.beacon_crc_valid = false;
}
} else if (link->u.mgd.p2p_noa_index != -1) {
/* noa_attr not found and we had valid noa_attr before */ link->u.mgd.p2p_noa_index = -1;
memset(&bss_conf->p2p_noa_attr, 0, sizeof(bss_conf->p2p_noa_attr));
changed |= BSS_CHANGED_P2P_PS; link->u.mgd.beacon_crc_valid = false;
}
}
/*
* Update beacon timing and dtim count on every beacon appearance. This
* will allow the driver to use the most updated values. Do it before
* comparing this one with last received beacon.
* IMPORTANT: These parameters would possibly be out of sync by the time
* the driver will use them. The synchronized view is currently
* guaranteed only in certain callbacks.
*/
if (ieee80211_hw_check(&local->hw, TIMING_BEACON_ONLY) &&
!ieee80211_is_s1g_beacon(hdr->frame_control)) {
bss_conf->sync_tsf =
le64_to_cpu(mgmt->u.beacon.timestamp);
bss_conf->sync_device_ts =
rx_status->device_timestamp;
bss_conf->sync_dtim_count = elems->dtim_count;
}
/*
* If we haven't had a beacon before, tell the driver about the
* DTIM period (and beacon timing if desired) now.
*/
if (!link->u.mgd.have_beacon) {
/* a few bogus AP send dtim_period = 0 or no TIM IE */
bss_conf->dtim_period = elems->dtim_period ?: 1;
for (i = 0; i < IEEE80211_TTLM_NUM_TIDS; i++) map |= neg_ttlm.downlink[i] | neg_ttlm.uplink[i];
/* If there is an active TTLM, unset previously suspended links */
if (sdata->vif.neg_ttlm.valid)
sdata->vif.dormant_links &= ~sdata->vif.suspended_links;
/* exclude links that are already disabled by advertised TTLM */
new_active_links = map & sdata->vif.valid_links & ~sdata->vif.dormant_links;
new_suspended_links =
(~map & sdata->vif.valid_links) & ~sdata->vif.dormant_links;
new_dormant_links = sdata->vif.dormant_links | new_suspended_links;
if (ieee80211_ttlm_set_links(sdata, new_active_links,
new_dormant_links, new_suspended_links))
return;
if (!ieee80211_vif_is_mld(&sdata->vif) ||
!(sdata->vif.cfg.mld_capa_op &
IEEE80211_MLD_CAP_OP_TID_TO_LINK_MAP_NEG_SUPP))
return -EINVAL;
for (i = 0; i < IEEE80211_TTLM_NUM_TIDS; i++) {
if ((params->dlink[i] & ~sdata->vif.valid_links) ||
(params->ulink[i] & ~sdata->vif.valid_links))
return -EINVAL;
/* The element size was already validated in
* ieee80211_tid_to_link_map_size_ok()
*/
pos = (void *)ttlm->optional;
control = ttlm->control;
/* mapping switch time and expected duration fields are not expected
* in case of negotiated TTLM
*/
if (control & (IEEE80211_TTLM_CONTROL_SWITCH_TIME_PRESENT |
IEEE80211_TTLM_CONTROL_EXPECTED_DUR_PRESENT)) {
mlme_dbg(sdata, "Invalid TTLM element in negotiated TTLM request\n");
return -EINVAL;
}
if (control & IEEE80211_TTLM_CONTROL_DEF_LINK_MAP) {
for (tid = 0; tid < IEEE80211_TTLM_NUM_TIDS; tid++) {
neg_ttlm->downlink[tid] = sdata->vif.valid_links;
neg_ttlm->uplink[tid] = sdata->vif.valid_links;
}
*direction = IEEE80211_TTLM_DIRECTION_BOTH;
return 0;
}
for (tid = 0; tid < IEEE80211_TTLM_NUM_TIDS; tid++) {
u16 map;
if (link_map_presence & BIT(tid)) { map = ieee80211_get_ttlm(map_size, pos);
if (!map) {
mlme_dbg(sdata, "No active links for TID %d", tid);
return -EINVAL;
}
} else { map = 0;
}
/* MLD station sends a TID to link mapping request, mainly to handle
* BTM (BSS transition management) request, in which case it needs to
* restrict the active links set.
* In this case it's not expected that the MLD AP will reject the
* negotiated TTLM request.
* This can be better implemented in the future, to handle request
* rejections.
*/
if (le16_to_cpu(mgmt->u.action.u.ttlm_res.status_code) != WLAN_STATUS_SUCCESS)
__ieee80211_disconnect(sdata);
}
static int ieee80211_do_assoc(struct ieee80211_sub_if_data *sdata)
{
struct ieee80211_mgd_assoc_data *assoc_data = sdata->u.mgd.assoc_data;
struct ieee80211_local *local = sdata->local;
int ret;
lockdep_assert_wiphy(sdata->local->hw.wiphy);
assoc_data->tries++;
assoc_data->comeback = false;
if (assoc_data->tries > IEEE80211_ASSOC_MAX_TRIES) {
sdata_info(sdata, "association with %pM timed out\n",
assoc_data->ap_addr);
/*
* Most likely AP is not in the range so remove the
* bss struct for that AP.
*/
cfg80211_unlink_bss(local->hw.wiphy,
assoc_data->link[assoc_data->assoc_link_id].bss);
return -ETIMEDOUT;
}
sdata_info(sdata, "associate with %pM (try %d/%d)\n",
assoc_data->ap_addr, assoc_data->tries,
IEEE80211_ASSOC_MAX_TRIES);
ret = ieee80211_send_assoc(sdata);
if (ret)
return ret;
if (ifmgd->status_received) {
__le16 fc = ifmgd->status_fc;
bool status_acked = ifmgd->status_acked;
ifmgd->status_received = false;
if (ifmgd->auth_data && ieee80211_is_auth(fc)) {
if (status_acked) {
if (ifmgd->auth_data->algorithm ==
WLAN_AUTH_SAE)
ifmgd->auth_data->timeout =
jiffies +
IEEE80211_AUTH_TIMEOUT_SAE;
else
ifmgd->auth_data->timeout =
jiffies +
IEEE80211_AUTH_TIMEOUT_SHORT;
run_again(sdata, ifmgd->auth_data->timeout);
} else {
ifmgd->auth_data->timeout = jiffies - 1;
}
ifmgd->auth_data->timeout_started = true;
} else if (ifmgd->assoc_data &&
!ifmgd->assoc_data->comeback &&
(ieee80211_is_assoc_req(fc) ||
ieee80211_is_reassoc_req(fc))) {
/*
* Update association timeout based on the TX status
* for the (Re)Association Request frame. Skip this if
* we have already processed a (Re)Association Response
* frame that indicated need for association comeback
* at a specific time in the future. This could happen
* if the TX status information is delayed enough for
* the response to be received and processed first.
*/
if (status_acked) {
ifmgd->assoc_data->timeout =
jiffies + IEEE80211_ASSOC_TIMEOUT_SHORT;
run_again(sdata, ifmgd->assoc_data->timeout);
} else {
ifmgd->assoc_data->timeout = jiffies - 1;
}
ifmgd->assoc_data->timeout_started = true;
}
}
if (ifmgd->auth_data && ifmgd->auth_data->timeout_started &&
time_after(jiffies, ifmgd->auth_data->timeout)) {
if (ifmgd->auth_data->done || ifmgd->auth_data->waiting) {
/*
* ok ... we waited for assoc or continuation but
* userspace didn't do it, so kill the auth data
*/
ieee80211_destroy_auth_data(sdata, false);
} else if (ieee80211_auth(sdata)) {
u8 ap_addr[ETH_ALEN];
struct ieee80211_event event = {
.type = MLME_EVENT,
.u.mlme.data = AUTH_EVENT,
.u.mlme.status = MLME_TIMEOUT,
};
if (ifmgd->flags & IEEE80211_STA_CONNECTION_POLL &&
ifmgd->associated) {
u8 *bssid = sdata->deflink.u.mgd.bssid;
int max_tries;
if (ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS))
max_tries = max_nullfunc_tries;
else
max_tries = max_probe_tries;
/* ACK received for nullfunc probing frame */
if (!ifmgd->probe_send_count)
ieee80211_reset_ap_probe(sdata);
else if (ifmgd->nullfunc_failed) {
if (ifmgd->probe_send_count < max_tries) {
mlme_dbg(sdata, "No ack for nullfunc frame to AP %pM, try %d/%i\n",
bssid, ifmgd->probe_send_count,
max_tries);
ieee80211_mgd_probe_ap_send(sdata);
} else {
mlme_dbg(sdata, "No ack for nullfunc frame to AP %pM, disconnecting.\n",
bssid);
ieee80211_sta_connection_lost(sdata,
WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY,
false);
}
} else if (time_is_after_jiffies(ifmgd->probe_timeout))
run_again(sdata, ifmgd->probe_timeout);
else if (ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS)) {
mlme_dbg(sdata, "Failed to send nullfunc to AP %pM after %dms, disconnecting\n",
bssid, probe_wait_ms);
ieee80211_sta_connection_lost(sdata,
WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY, false);
} else if (ifmgd->probe_send_count < max_tries) {
mlme_dbg(sdata, "No probe response from AP %pM after %dms, try %d/%i\n",
bssid, probe_wait_ms,
ifmgd->probe_send_count, max_tries);
ieee80211_mgd_probe_ap_send(sdata);
} else {
/*
* We actually lost the connection ... or did we?
* Let's make sure!
*/
mlme_dbg(sdata, "No probe response from AP %pM after %dms, disconnecting.\n",
bssid, probe_wait_ms);
static bool
ieee80211_is_csa_in_progress(struct ieee80211_sub_if_data *sdata)
{
/*
* In MLO, check the CSA flags 'active' and 'waiting_bcn' for all
* the links.
*/
struct ieee80211_link_data *link;
guard(rcu)();
for_each_link_data_rcu(sdata, link) {
if (!(link->conf->csa_active &&
!link->u.mgd.csa.waiting_bcn))
return false;
}
static unsigned long
ieee80211_latest_active_link_conn_timeout(struct ieee80211_sub_if_data *sdata)
{
unsigned long latest_timeout = jiffies;
unsigned int link_id;
struct sta_info *sta;
guard(rcu)();
sta = sta_info_get(sdata, sdata->vif.cfg.ap_addr);
if (!sta)
return 0;
for (link_id = 0; link_id < ARRAY_SIZE(sta->link);
link_id++) {
struct link_sta_info *link_sta;
unsigned long timeout;
link_sta = rcu_dereference(sta->link[link_id]);
if (!link_sta)
continue;
timeout = link_sta->status_stats.last_ack;
if (time_before(timeout, link_sta->rx_stats.last_rx))
timeout = link_sta->rx_stats.last_rx;
timeout += IEEE80211_CONNECTION_IDLE_TIME;
/*
* latest_timeout holds the timeout of the link
* that will expire last among all links in an
* non-AP MLD STA. This ensures that the connection
* monitor timer is only reset if at least one link
* is still active, and it is scheduled to fire at
* the latest possible timeout.
*/
if (time_after(timeout, latest_timeout))
latest_timeout = timeout;
}
/*
* If latest timeout is after now, then update timer to fire at
* the later date, but do not actually probe at this time.
*/
if (time_is_after_jiffies(latest_timeout)) {
mod_timer(&ifmgd->conn_mon_timer,
round_jiffies_up(latest_timeout));
return;
}
/* let's probe the connection once */
if (!ieee80211_hw_check(&sdata->local->hw, CONNECTION_MONITOR))
wiphy_work_queue(sdata->local->hw.wiphy,
&sdata->u.mgd.monitor_work);
}
}
/*
* If we are trying to authenticate / associate while suspending,
* cfg80211 won't know and won't actually abort those attempts,
* thus we need to do that ourselves.
*/
ieee80211_send_deauth_disassoc(sdata, ap_addr, ap_addr,
IEEE80211_STYPE_DEAUTH,
WLAN_REASON_DEAUTH_LEAVING,
false, frame_buf);
if (ifmgd->assoc_data)
ieee80211_destroy_assoc_data(sdata, ASSOC_ABANDON);
if (ifmgd->auth_data)
ieee80211_destroy_auth_data(sdata, false);
cfg80211_tx_mlme_mgmt(sdata->dev, frame_buf,
IEEE80211_DEAUTH_FRAME_LEN,
false);
}
/* This is a bit of a hack - we should find a better and more generic
* solution to this. Normally when suspending, cfg80211 will in fact
* deauthenticate. However, it doesn't (and cannot) stop an ongoing
* auth (not so important) or assoc (this is the problem) process.
*
* As a consequence, it can happen that we are in the process of both
* associating and suspending, and receive an association response
* after cfg80211 has checked if it needs to disconnect, but before
* we actually set the flag to drop incoming frames. This will then
* cause the workqueue flush to process the association response in
* the suspend, resulting in a successful association just before it
* tries to remove the interface from the driver, which now though
* has a channel context assigned ... this results in issues.
*
* To work around this (for now) simply deauth here again if we're
* now connected.
*/
if (ifmgd->associated && !sdata->local->wowlan) {
u8 bssid[ETH_ALEN];
struct cfg80211_deauth_request req = {
.reason_code = WLAN_REASON_DEAUTH_LEAVING,
.bssid = bssid,
};
if (sdata->u.mgd.assoc_data)
ether_addr_copy(link->conf->addr,
sdata->u.mgd.assoc_data->link[link_id].addr);
else if (sdata->u.mgd.reconf.add_links_data)
ether_addr_copy(link->conf->addr,
sdata->u.mgd.reconf.add_links_data->link[link_id].addr);
else if (!is_valid_ether_addr(link->conf->addr))
eth_random_addr(link->conf->addr);
}
/* If a reconfig is happening, bail out */
if (local->in_reconfig) {
err = -EBUSY;
goto out_err;
}
if (!have_sta) {
if (mlo)
new_sta = sta_info_alloc_with_link(sdata, ap_mld_addr,
link_id, cbss->bssid,
GFP_KERNEL);
else
new_sta = sta_info_alloc(sdata, ap_mld_addr, GFP_KERNEL);
if (!new_sta) {
err = -ENOMEM;
goto out_err;
}
new_sta->sta.mlo = mlo;
}
/*
* Set up the information for the new channel before setting the
* new channel. We can't - completely race-free - change the basic
* rates bitmap and the channel (sband) that it refers to, but if
* we set it up before we at least avoid calling into the driver's
* bss_info_changed() method with invalid information (since we do
* call that from changing the channel - only for IDLE and perhaps
* some others, but ...).
*
* So to avoid that, just set up all the new information before the
* channel, but tell the driver to apply it only afterwards, since
* it might need the new channel for that.
*/
if (new_sta) {
const struct cfg80211_bss_ies *ies;
struct link_sta_info *link_sta;
/* set timing information */ link->conf->beacon_int = cbss->beacon_interval;
ies = rcu_dereference(cbss->beacon_ies);
if (ies) { link->conf->sync_tsf = ies->tsf; link->conf->sync_device_ts =
bss->device_ts_beacon;
ieee80211_get_dtim(ies,
&link->conf->sync_dtim_count,
NULL);
} else if (!ieee80211_hw_check(&sdata->local->hw,
TIMING_BEACON_ONLY)) {
ies = rcu_dereference(cbss->proberesp_ies);
/* must be non-NULL since beacon IEs were NULL */ link->conf->sync_tsf = ies->tsf; link->conf->sync_device_ts =
bss->device_ts_presp; link->conf->sync_dtim_count = 0;
} else { link->conf->sync_tsf = 0; link->conf->sync_device_ts = 0; link->conf->sync_dtim_count = 0;
}
rcu_read_unlock();
}
if (new_sta || override) {
/*
* Only set this if we're also going to calculate the AP
* settings etc., otherwise this was set before in a
* previous call. Note override is set to %true in assoc
* if the settings were changed.
*/ link->u.mgd.conn = *conn;
err = ieee80211_prep_channel(sdata, link, link->link_id, cbss,
mlo, &link->u.mgd.conn,
userspace_selectors);
if (err) {
if (new_sta)
sta_info_free(local, new_sta);
goto out_err;
}
/* pass out for use in assoc */
*conn = link->u.mgd.conn;
}
if (new_sta) {
/*
* tell driver about BSSID, basic rates and timing
* this was set up above, before setting the channel
*/
ieee80211_link_info_change_notify(sdata, link,
BSS_CHANGED_BSSID |
BSS_CHANGED_BASIC_RATES |
BSS_CHANGED_BEACON_INT);
if (assoc)
sta_info_pre_move_state(new_sta, IEEE80211_STA_AUTH);
err = sta_info_insert(new_sta);
new_sta = NULL;
if (err) {
sdata_info(sdata, "failed to insert STA entry for the AP (error %d)\n",
err);
goto out_release_chan;
}
} else
WARN_ON_ONCE(!ether_addr_equal(link->u.mgd.bssid, cbss->bssid));
/* Cancel scan to ensure that nothing interferes with connection */
if (local->scanning)
ieee80211_scan_cancel(local);
/* Check if continuing authentication or trying to authenticate with the
* same BSS that we were in the process of authenticating with and avoid
* removal and re-addition of the STA entry in
* ieee80211_prep_connection().
*/
cont_auth = ifmgd->auth_data && req->bss == ifmgd->auth_data->bss &&
ifmgd->auth_data->link_id == req->link_id;
if (ifmgd->auth_data) {
if (cont_auth && req->auth_type == NL80211_AUTHTYPE_SAE) {
auth_data->peer_confirmed =
ifmgd->auth_data->peer_confirmed;
}
ieee80211_destroy_auth_data(sdata, cont_auth);
}
/* prep auth_data so we don't go into idle on disassoc */
ifmgd->auth_data = auth_data;
/* If this is continuation of an ongoing SAE authentication exchange
* (i.e., request to send SAE Confirm) and the peer has already
* confirmed, mark authentication completed since we are about to send
* out SAE Confirm.
*/
if (cont_auth && req->auth_type == NL80211_AUTHTYPE_SAE &&
auth_data->peer_confirmed && auth_data->sae_trans == 2)
ieee80211_mark_sta_auth(sdata);
if (ifmgd->associated) {
u8 frame_buf[IEEE80211_DEAUTH_FRAME_LEN];
sdata_info(sdata, "disconnect from AP %pM for new auth to %pM\n",
sdata->vif.cfg.ap_addr, auth_data->ap_addr);
ieee80211_set_disassoc(sdata, IEEE80211_STYPE_DEAUTH,
WLAN_REASON_UNSPECIFIED,
false, frame_buf);
cbss = assoc_data->link[link_id].bss;
if (WARN_ON(!cbss))
return;
bss = (void *)cbss->priv;
sband = local->hw.wiphy->bands[cbss->channel->band];
if (WARN_ON(!sband))
return;
link = sdata_dereference(sdata->link[link_id], sdata);
if (WARN_ON(!link))
return;
/* for MLO connections assume advertising all rates is OK */
if (!req->ap_mld_addr) {
assoc_data->supp_rates = bss->supp_rates;
assoc_data->supp_rates_len = bss->supp_rates_len;
}
/* copy and link elems for the STA profile */
if (req->links[link_id].elems_len) {
memcpy(assoc_data->ie_pos, req->links[link_id].elems,
req->links[link_id].elems_len);
assoc_data->link[link_id].elems = assoc_data->ie_pos;
assoc_data->link[link_id].elems_len = req->links[link_id].elems_len;
assoc_data->ie_pos += req->links[link_id].elems_len;
}
if (assoc_data->link[link_id].conn.mode < IEEE80211_CONN_MODE_VHT)
return 0;
/* some drivers want to support VHT on 2.4 GHz even */
sband = sdata->local->hw.wiphy->bands[band];
if (!sband->vht_cap.vht_supported)
return 0;
rcu_read_lock();
elem = ieee80211_bss_get_elem(cbss, WLAN_EID_VHT_CAPABILITY);
/* but even then accept it not being present on the AP */
if (!elem && band == NL80211_BAND_2GHZ) {
err = 0;
goto out_rcu;
}
if (!elem || elem->datalen < sizeof(struct ieee80211_vht_cap)) {
mlme_link_id_dbg(sdata, link_id, "no VHT capa on BSS %pM\n",
cbss->bssid);
err = -EINVAL;
goto out_rcu;
}
memcpy(&assoc_data->link[link_id].ap_vht_cap, elem->data,
sizeof(struct ieee80211_vht_cap));
rcu_read_unlock();
if (req->ap_mld_addr)
memcpy(assoc_data->ap_addr, req->ap_mld_addr, ETH_ALEN);
else
memcpy(assoc_data->ap_addr, cbss->bssid, ETH_ALEN);
/*
* Many APs have broken parsing of the extended MLD capa/ops field,
* dropping (re-)association request frames or replying with association
* response with a failure status if it's present.
* Set our value from the userspace request only in strict mode or if
* the AP also had that field present.
*/
if (ieee80211_hw_check(&local->hw, STRICT) ||
ieee80211_mgd_assoc_bss_has_mld_ext_capa_ops(req))
assoc_data->ext_mld_capa_ops =
cpu_to_le16(req->ext_mld_capa_ops);
if (ifmgd->associated) {
u8 frame_buf[IEEE80211_DEAUTH_FRAME_LEN];
sdata_info(sdata, "disconnect from AP %pM for new assoc to %pM\n",
sdata->vif.cfg.ap_addr, assoc_data->ap_addr);
ieee80211_set_disassoc(sdata, IEEE80211_STYPE_DEAUTH,
WLAN_REASON_UNSPECIFIED,
false, frame_buf);
if (req->ap_mld_addr) {
/* if there was no authentication, set up the link */
err = ieee80211_vif_set_links(sdata, BIT(assoc_link_id), 0);
if (err)
goto err_clear;
}
link = sdata_dereference(sdata->link[assoc_link_id], sdata);
if (WARN_ON(!link)) {
err = -EINVAL;
goto err_clear;
}
if (WARN((sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_UAPSD) &&
ieee80211_hw_check(&local->hw, PS_NULLFUNC_STACK), "U-APSD not supported with HW_PS_NULLFUNC_STACK\n"))
sdata->vif.driver_flags &= ~IEEE80211_VIF_SUPPORTS_UAPSD;
/* kick off associate process */
ifmgd->assoc_data = assoc_data;
for (i = 0; i < ARRAY_SIZE(assoc_data->link); i++) {
if (!assoc_data->link[i].bss)
continue;
if (i == assoc_data->assoc_link_id)
continue;
/* only calculate the mode, hence link == NULL */
err = ieee80211_prep_channel(sdata, NULL, i,
assoc_data->link[i].bss, true,
&assoc_data->link[i].conn,
sdata->u.mgd.userspace_selectors);
if (err) {
req->links[i].error = err;
goto err_clear;
}
}
if (ieee80211_hw_check(&sdata->local->hw, NEED_DTIM_BEFORE_ASSOC)) {
const struct cfg80211_bss_ies *beacon_ies;
rcu_read_lock();
beacon_ies = rcu_dereference(req->bss->beacon_ies);
if (!beacon_ies) {
/*
* Wait up to one beacon interval ...
* should this be more if we miss one?
*/
sdata_info(sdata, "waiting for beacon from %pM\n", link->u.mgd.bssid);
assoc_data->timeout = TU_TO_EXP_TIME(req->bss->beacon_interval);
assoc_data->timeout_started = true;
assoc_data->need_beacon = true;
}
rcu_read_unlock();
}
run_again(sdata, assoc_data->timeout);
/* We are associating, clean up auth_data */
if (ifmgd->auth_data)
ieee80211_destroy_auth_data(sdata, true);
if (ifmgd->auth_data &&
ether_addr_equal(ifmgd->auth_data->ap_addr, req->bssid)) {
sdata_info(sdata, "aborting authentication with %pM by local choice (Reason: %u=%s)\n",
req->bssid, req->reason_code,
ieee80211_get_reason_code_string(req->reason_code));
if (ifmgd->assoc_data &&
ether_addr_equal(ifmgd->assoc_data->ap_addr, req->bssid)) {
sdata_info(sdata, "aborting association with %pM by local choice (Reason: %u=%s)\n",
req->bssid, req->reason_code,
ieee80211_get_reason_code_string(req->reason_code));
if (ifmgd->associated &&
ether_addr_equal(sdata->vif.cfg.ap_addr, req->bssid)) {
sdata_info(sdata, "deauthenticating from %pM by local choice (Reason: %u=%s)\n",
req->bssid, req->reason_code,
ieee80211_get_reason_code_string(req->reason_code));
int ieee80211_mgd_disassoc(struct ieee80211_sub_if_data *sdata,
struct cfg80211_disassoc_request *req)
{
u8 frame_buf[IEEE80211_DEAUTH_FRAME_LEN];
if (!sdata->u.mgd.associated ||
memcmp(sdata->vif.cfg.ap_addr, req->ap_addr, ETH_ALEN))
return -ENOTCONN;
sdata_info(sdata, "disassociating from %pM by local choice (Reason: %u=%s)\n",
req->ap_addr, req->reason_code,
ieee80211_get_reason_code_string(req->reason_code));
/*
* Make sure some work items will not run after this,
* they will not do anything but might not have been
* cancelled when disconnecting.
*/
wiphy_work_cancel(sdata->local->hw.wiphy,
&ifmgd->monitor_work);
wiphy_work_cancel(sdata->local->hw.wiphy,
&ifmgd->beacon_connection_loss_work);
wiphy_work_cancel(sdata->local->hw.wiphy,
&ifmgd->csa_connection_drop_work);
wiphy_delayed_work_cancel(sdata->local->hw.wiphy,
&ifmgd->tdls_peer_del_work);
if (ifmgd->assoc_data)
ieee80211_destroy_assoc_data(sdata, ASSOC_TIMEOUT);
if (ifmgd->auth_data)
ieee80211_destroy_auth_data(sdata, false);
spin_lock_bh(&ifmgd->teardown_lock);
if (ifmgd->teardown_skb) {
kfree_skb(ifmgd->teardown_skb);
ifmgd->teardown_skb = NULL;
ifmgd->orig_teardown_skb = NULL;
}
kfree(ifmgd->assoc_req_ies);
ifmgd->assoc_req_ies = NULL;
ifmgd->assoc_req_ies_len = 0;
spin_unlock_bh(&ifmgd->teardown_lock);
timer_delete_sync(&ifmgd->timer);
}
static void _ieee80211_enable_rssi_reports(struct ieee80211_sub_if_data *sdata,
int rssi_min_thold,
int rssi_max_thold)
{
trace_api_enable_rssi_reports(sdata, rssi_min_thold, rssi_max_thold);
if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_STATION))
return;
/*
* Scale up threshold values before storing it, as the RSSI averaging
* algorithm uses a scaled up value as well. Change this scaling
* factor if the RSSI averaging algorithm changes.
*/
sdata->u.mgd.rssi_min_thold = rssi_min_thold*16;
sdata->u.mgd.rssi_max_thold = rssi_max_thold*16;
}
void ieee80211_enable_rssi_reports(struct ieee80211_vif *vif,
int rssi_min_thold,
int rssi_max_thold)
{
struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
/* clear the corresponding link, to detect the case that
* the same link was included more than one time
*/
link_mask &= ~BIT(link_id);
/* Handle failure to remove links here. Failure to remove added
* links will be done later in the flow.
*/
if (status != WLAN_STATUS_SUCCESS) {
sdata_info(sdata, "mlo: reconf: failed on link=%u, status=%u\n",
link_id, status);
/* The AP MLD failed to remove alink that was already
* removed locally. As this is not expected behavior,
* disconnect
*/
if (sdata->u.mgd.reconf.removed_links & BIT(link_id))
goto disconnect;
/* The AP MLD failed to add alink. Remove it from the
* added links.
*/
sdata->u.mgd.reconf.added_links &= ~BIT(link_id);
}
pos += 3;
len -= 3;
}
if (link_mask) {
sdata_info(sdata, "mlo: reconf: no response for links=0x%x\n",
link_mask);
goto disconnect;
}
if (!sdata->u.mgd.reconf.added_links)
goto out;
if (len < 1 || len < 1 + *pos) {
sdata_info(sdata, "mlo: reconf: invalid group key data length");
goto disconnect;
}
/* The Group Key Data field must be present when links are added. This
* field should be processed by userland.
*/
group_key_data_len = *pos++;
pos += group_key_data_len;
len -= group_key_data_len + 1;
/* Process the information for the added links */
sta = sta_info_get(sdata, sdata->vif.cfg.ap_addr);
if (WARN_ON(!sta))
goto disconnect;
valid_links = sdata->vif.valid_links;
for (link_id = 0; link_id < IEEE80211_MLD_MAX_NUM_LINKS; link_id++) {
if (!add_links_data->link[link_id].bss ||
!(sdata->u.mgd.reconf.added_links & BIT(link_id)))
continue;
valid_links |= BIT(link_id);
if (ieee80211_sta_allocate_link(sta, link_id))
goto disconnect;
}
link = sdata_dereference(sdata->link[link_id], sdata);
if (WARN_ON(!link))
goto disconnect;
link_info(link, "mlo: reconf: local address %pM, AP link address %pM\n",
add_links_data->link[link_id].addr,
add_links_data->link[link_id].bss->bssid);
link_sta = rcu_dereference_protected(sta->link[link_id],
lockdep_is_held(&local->hw.wiphy->mtx));
if (WARN_ON(!link_sta))
goto disconnect;
if (!link->u.mgd.have_beacon) {
const struct cfg80211_bss_ies *ies;
if (ieee80211_mgd_setup_link_sta(link, sta, link_sta,
add_links_data->link[link_id].bss))
goto disconnect;
if (!ieee80211_assoc_config_link(link, link_sta,
add_links_data->link[link_id].bss,
mgmt, pos, len,
&changed))
goto disconnect;
/* The AP MLD indicated success for this link, but the station
* profile status indicated otherwise. Since there is an
* inconsistency in the ML reconfiguration response, disconnect
*/
if (add_links_data->link[link_id].status != WLAN_STATUS_SUCCESS)
goto disconnect;
ieee80211_sta_init_nss(link_sta);
if (ieee80211_sta_activate_link(sta, link_id))
goto disconnect;
sdata_info(sdata, "mlo: reconf: current valid_links=0x%x, added=0x%x\n",
valid_links, link_mask);
/* links might have changed due to rejected ones, set them again */
ieee80211_vif_set_links(sdata, valid_links, sdata->vif.dormant_links);
ieee80211_vif_cfg_change_notify(sdata, BSS_CHANGED_MLD_VALID_LINKS);
/* Consider the maximal length of the reconfiguration ML element */
size += sizeof(struct ieee80211_multi_link_elem);
/* The Basic ML element and the Reconfiguration ML element have the same
* fixed common information fields in the context of ML reconfiguration
* action frame. The AP MLD MAC address must always be present
*/
common_size = sizeof(*common);
/* when adding links, the MLD capabilities must be present */
var_common_size = 0;
if (add_links_data) {
const struct wiphy_iftype_ext_capab *ift_ext_capa =
cfg80211_get_iftype_ext_capa(local->hw.wiphy,
ieee80211_vif_type_p2p(&sdata->vif));
if (ift_ext_capa) {
eml_capa = cpu_to_le16(ift_ext_capa->eml_capabilities);
mld_capa_ops =
cpu_to_le16(ift_ext_capa->mld_capa_and_ops);
}
/* MLD capabilities and operation */
var_common_size += 2;
/* allocate adialog token and store it */
sdata->u.mgd.reconf.dialog_token = ++sdata->u.mgd.dialog_token_alloc;
mgmt->u.action.u.ml_reconf_req.dialog_token =
sdata->u.mgd.reconf.dialog_token;
/* Add the ML reconfiguration element and the common information */
skb_put_u8(skb, WLAN_EID_EXTENSION);
ml_elem_len = skb_put(skb, 1);
skb_put_u8(skb, WLAN_EID_EXT_EHT_MULTI_LINK);
ml_elem = skb_put(skb, sizeof(*ml_elem));
ml_elem->control =
cpu_to_le16(IEEE80211_ML_CONTROL_TYPE_RECONF |
IEEE80211_MLC_RECONF_PRES_MLD_MAC_ADDR);
common = skb_put(skb, common_size);
common->len = common_size + var_common_size;
memcpy(common->mld_mac_addr, sdata->vif.addr, ETH_ALEN);
if (add_links_data) {
if (eml_capa &
cpu_to_le16((IEEE80211_EML_CAP_EMLSR_SUPP |
IEEE80211_EML_CAP_EMLMR_SUPPORT))) {
ml_elem->control |=
cpu_to_le16(IEEE80211_MLC_RECONF_PRES_EML_CAPA);
skb_put_data(skb, &eml_capa, sizeof(eml_capa));
}
if (!ieee80211_vif_is_mld(&sdata->vif) ||
!(sdata->vif.cfg.mld_capa_op &
IEEE80211_MLD_CAP_OP_LINK_RECONF_SUPPORT))
return -EINVAL;
/* No support for concurrent ML reconfiguration operation */
if (sdata->u.mgd.reconf.added_links ||
sdata->u.mgd.reconf.removed_links)
return -EBUSY;
added_links = 0;
for (link_id = 0; link_id < IEEE80211_MLD_MAX_NUM_LINKS; link_id++) {
if (!req->add_links[link_id].bss)
continue;
added_links |= BIT(link_id);
}
sta = sta_info_get(sdata, sdata->vif.cfg.ap_addr);
if (WARN_ON(!sta))
return -ENOLINK;
/* Adding links to the set of valid link is done only after a successful
* ML reconfiguration frame exchange. Here prepare the data for the ML
* reconfiguration frame construction and allocate the required
* resources
*/
if (added_links) {
bool uapsd_supported;
data = kzalloc(sizeof(*data), GFP_KERNEL);
if (!data)
return -ENOMEM;
/* Require U-APSD support if we enabled it */
if (sdata->u.mgd.flags & IEEE80211_STA_UAPSD_ENABLED &&
!uapsd_supported) {
err = -EINVAL;
sdata_info(sdata, "U-APSD on but not available on (all) new links\n");
goto err_free;
}
for (link_id = 0; link_id < IEEE80211_MLD_MAX_NUM_LINKS;
link_id++) {
if (!data->link[link_id].bss)
continue;
/* only used to verify the mode, nothing is allocated */
err = ieee80211_prep_channel(sdata, NULL, link_id,
data->link[link_id].bss,
true,
&data->link[link_id].conn,
sdata->u.mgd.userspace_selectors);
if (err)
goto err_free;
}
}
/* link removal is done before the ML reconfiguration frame exchange so
* that these links will not be used between their removal by the AP MLD
* and before the station got the ML reconfiguration response. Based on
* Section35.3.6.4 in Draft P802.11be_D7.0 the AP MLD should accept the
* link removal request.
*/
if (req->rem_links) {
u16 new_active_links =
sdata->vif.active_links & ~req->rem_links;
/* Should not be left with no valid links to perform the
* ML reconfiguration
*/
if (!new_valid_links ||
!(new_valid_links & ~sdata->vif.dormant_links)) {
sdata_info(sdata, "mlo: reconf: no valid links\n");
err = -EINVAL;
goto err_free;
}
if (new_active_links != sdata->vif.active_links) {
if (!new_active_links)
new_active_links =
BIT(__ffs(new_valid_links &
~sdata->vif.dormant_links));
err = ieee80211_set_active_links(&sdata->vif,
new_active_links);
if (err) {
sdata_info(sdata, "mlo: reconf: failed set active links\n");
goto err_free;
}
}
}
/* Build the SKB before the link removal as the construction of the
* station info for removed links requires the local address.
* Invalidate the removed links, so that the transmission of the ML
* reconfiguration request frame would not be done using them, as the AP
* is expected to send the ML reconfiguration response frame on the link
* on which the request was received.
*/
skb = ieee80211_build_ml_reconf_req(sdata, data, req->rem_links,
cpu_to_le16(req->ext_mld_capa_ops));
if (!skb) {
err = -ENOMEM;
goto err_free;
}
if (req->rem_links) {
u16 new_dormant_links =
sdata->vif.dormant_links & ~req->rem_links;
err = ieee80211_vif_set_links(sdata, new_valid_links,
new_dormant_links);
if (err) {
sdata_info(sdata, "mlo: reconf: failed set valid links\n");
kfree_skb(skb);
goto err_free;
}
for (link_id = 0; link_id < IEEE80211_MLD_MAX_NUM_LINKS;
link_id++) {
if (!(req->rem_links & BIT(link_id)))
continue;
ieee80211_sta_remove_link(sta, link_id);
}
/* notify the driver and upper layers */
ieee80211_vif_cfg_change_notify(sdata,
BSS_CHANGED_MLD_VALID_LINKS);
cfg80211_links_removed(sdata->dev, req->rem_links);
}
if (!ieee80211_mgd_epcs_supp(sdata))
return -EINVAL;
if (sdata->u.mgd.epcs.enabled == enable &&
!sdata->u.mgd.epcs.dialog_token)
return 0;
/* Do not allow enabling EPCS if the AP didn't respond yet.
* However, allow disabling EPCS in such a case.
*/
if (sdata->u.mgd.epcs.dialog_token && enable)
return -EALREADY;
skb = dev_alloc_skb(local->hw.extra_tx_headroom + frame_len);
if (!skb)
return -ENOBUFS;
if (!ieee80211_vif_is_mld(&sdata->vif) || !elems->ml_epcs)
return;
if (WARN_ON(!scratch))
return;
/* Directly parse the sub elements as the common information doesn't
* hold any useful information.
*/
for_each_mle_subelement(sub, (const u8 *)elems->ml_epcs,
elems->ml_epcs_len) {
struct ieee802_11_elems *link_elems __free(kfree) = NULL;
struct ieee80211_link_data *link;
u8 *pos = (void *)sub->data;
u16 control;
ssize_t len;
u8 link_id;
if (sub->id != IEEE80211_MLE_SUBELEM_PER_STA_PROFILE)
continue;
if (sub->datalen < sizeof(control))
break;
control = get_unaligned_le16(pos);
link_id = control & IEEE80211_MLE_STA_EPCS_CONTROL_LINK_ID;
link = sdata_dereference(sdata->link[link_id], sdata);
if (!link)
continue;
len = cfg80211_defragment_element(sub, (u8 *)elems->ml_epcs,
elems->ml_epcs_len,
scratch, scratch_len,
IEEE80211_MLE_SUBELEM_FRAGMENT);
if (len < (ssize_t)sizeof(control))
continue;
pos = scratch + sizeof(control);
len -= sizeof(control);
link_elems = ieee802_11_parse_elems(pos, len, false, NULL);
if (!link_elems)
continue;
/* Handle dialog token and status code */
pos = mgmt->u.action.u.epcs.variable;
dialog_token = *pos;
status_code = get_unaligned_le16(pos + 1);
/* An EPCS enable response with dialog token == 0 is an unsolicited
* notification from the AP MLD. In such a case, EPCS should already be
* enabled and status must be success
*/
if (!dialog_token &&
(!sdata->u.mgd.epcs.enabled ||
status_code != WLAN_STATUS_SUCCESS))
return;
if (sdata->u.mgd.epcs.dialog_token != dialog_token)
return;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.