Skip to content

Commit 75e296e

Browse files
committed
mac80211: simplify and improve HT/VHT/HE disable code
Check early on that a device has support for QoS (at least 4 queues) when it supports HT/VHT/HE, so we don't have to check this while connecting. This lets us clean up the code there: move some of it into channel preparation to clean up a bit more, and then change the logic to only check the "wmm_used" flag. Additionally, disable HE consistently when VHT is disabled. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Luca Coelho <luciano.coelho@intel.com> Link: https://lore.kernel.org/r/20200131111300.891737-3-luca@coelho.fi Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1 parent d6039a3 commit 75e296e

2 files changed

Lines changed: 38 additions & 29 deletions

File tree

‎net/mac80211/main.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -981,6 +981,11 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
981981
if (!supp_he)
982982
supp_he = !!ieee80211_get_he_sta_cap(sband);
983983

984+
/* HT, VHT, HE require QoS, thus >= 4 queues */
985+
if (WARN_ON(local->hw.queues < IEEE80211_NUM_ACS &&
986+
(supp_ht || supp_vht || supp_he)))
987+
return -EINVAL;
988+
984989
if (!sband->ht_cap.ht_supported)
985990
continue;
986991

‎net/mac80211/mlme.c‎

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,9 @@ ieee80211_determine_chantype(struct ieee80211_sub_if_data *sdata,
164164
chandef->center_freq1 = channel->center_freq;
165165

166166
if (!ht_oper || !sta_ht_cap.ht_supported) {
167-
ret = IEEE80211_STA_DISABLE_HT | IEEE80211_STA_DISABLE_VHT;
167+
ret = IEEE80211_STA_DISABLE_HT |
168+
IEEE80211_STA_DISABLE_VHT |
169+
IEEE80211_STA_DISABLE_HE;
168170
goto out;
169171
}
170172

@@ -185,7 +187,9 @@ ieee80211_determine_chantype(struct ieee80211_sub_if_data *sdata,
185187
"Wrong control channel: center-freq: %d ht-cfreq: %d ht->primary_chan: %d band: %d - Disabling HT\n",
186188
channel->center_freq, ht_cfreq,
187189
ht_oper->primary_chan, channel->band);
188-
ret = IEEE80211_STA_DISABLE_HT | IEEE80211_STA_DISABLE_VHT;
190+
ret = IEEE80211_STA_DISABLE_HT |
191+
IEEE80211_STA_DISABLE_VHT |
192+
IEEE80211_STA_DISABLE_HE;
189193
goto out;
190194
}
191195

@@ -301,7 +305,8 @@ ieee80211_determine_chantype(struct ieee80211_sub_if_data *sdata,
301305
IEEE80211_CHAN_DISABLED)) {
302306
if (WARN_ON(chandef->width == NL80211_CHAN_WIDTH_20_NOHT)) {
303307
ret = IEEE80211_STA_DISABLE_HT |
304-
IEEE80211_STA_DISABLE_VHT;
308+
IEEE80211_STA_DISABLE_VHT |
309+
IEEE80211_STA_DISABLE_HE;
305310
break;
306311
}
307312

@@ -393,6 +398,7 @@ static int ieee80211_config_bw(struct ieee80211_sub_if_data *sdata,
393398

394399
if (flags != (ifmgd->flags & (IEEE80211_STA_DISABLE_HT |
395400
IEEE80211_STA_DISABLE_VHT |
401+
IEEE80211_STA_DISABLE_HE |
396402
IEEE80211_STA_DISABLE_40MHZ |
397403
IEEE80211_STA_DISABLE_80P80MHZ |
398404
IEEE80211_STA_DISABLE_160MHZ)) ||
@@ -4760,10 +4766,22 @@ static int ieee80211_prep_channel(struct ieee80211_sub_if_data *sdata,
47604766
IEEE80211_STA_DISABLE_80P80MHZ |
47614767
IEEE80211_STA_DISABLE_160MHZ);
47624768

4769+
/* disable HT/VHT/HE if we don't support them */
4770+
if (!sband->ht_cap.ht_supported) {
4771+
ifmgd->flags |= IEEE80211_STA_DISABLE_HT;
4772+
ifmgd->flags |= IEEE80211_STA_DISABLE_VHT;
4773+
ifmgd->flags |= IEEE80211_STA_DISABLE_HE;
4774+
}
4775+
4776+
if (!sband->vht_cap.vht_supported)
4777+
ifmgd->flags |= IEEE80211_STA_DISABLE_VHT;
4778+
4779+
if (!ieee80211_get_he_sta_cap(sband))
4780+
ifmgd->flags |= IEEE80211_STA_DISABLE_HE;
4781+
47634782
rcu_read_lock();
47644783

4765-
if (!(ifmgd->flags & IEEE80211_STA_DISABLE_HT) &&
4766-
sband->ht_cap.ht_supported) {
4784+
if (!(ifmgd->flags & IEEE80211_STA_DISABLE_HT)) {
47674785
const u8 *ht_oper_ie, *ht_cap_ie;
47684786

47694787
ht_oper_ie = ieee80211_bss_get_ie(cbss, WLAN_EID_HT_OPERATION);
@@ -4780,8 +4798,7 @@ static int ieee80211_prep_channel(struct ieee80211_sub_if_data *sdata,
47804798
}
47814799
}
47824800

4783-
if (!(ifmgd->flags & IEEE80211_STA_DISABLE_VHT) &&
4784-
sband->vht_cap.vht_supported) {
4801+
if (!(ifmgd->flags & IEEE80211_STA_DISABLE_VHT)) {
47854802
const u8 *vht_oper_ie, *vht_cap;
47864803

47874804
vht_oper_ie = ieee80211_bss_get_ie(cbss,
@@ -4791,9 +4808,10 @@ static int ieee80211_prep_channel(struct ieee80211_sub_if_data *sdata,
47914808
if (vht_oper && !ht_oper) {
47924809
vht_oper = NULL;
47934810
sdata_info(sdata,
4794-
"AP advertised VHT without HT, disabling both\n");
4811+
"AP advertised VHT without HT, disabling HT/VHT/HE\n");
47954812
ifmgd->flags |= IEEE80211_STA_DISABLE_HT;
47964813
ifmgd->flags |= IEEE80211_STA_DISABLE_VHT;
4814+
ifmgd->flags |= IEEE80211_STA_DISABLE_HE;
47974815
}
47984816

47994817
vht_cap = ieee80211_bss_get_ie(cbss, WLAN_EID_VHT_CAPABILITY);
@@ -4803,9 +4821,6 @@ static int ieee80211_prep_channel(struct ieee80211_sub_if_data *sdata,
48034821
}
48044822
}
48054823

4806-
if (!ieee80211_get_he_sta_cap(sband))
4807-
ifmgd->flags |= IEEE80211_STA_DISABLE_HE;
4808-
48094824
if (!(ifmgd->flags & IEEE80211_STA_DISABLE_HE)) {
48104825
const struct cfg80211_bss_ies *ies;
48114826
const u8 *he_oper_ie;
@@ -5304,27 +5319,15 @@ int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata,
53045319
}
53055320
}
53065321

5307-
/* Also disable HT if we don't support it or the AP doesn't use WMM */
53085322
sband = local->hw.wiphy->bands[req->bss->channel->band];
5309-
if (!sband->ht_cap.ht_supported ||
5310-
local->hw.queues < IEEE80211_NUM_ACS || !bss->wmm_used ||
5311-
ifmgd->flags & IEEE80211_STA_DISABLE_WMM) {
5312-
ifmgd->flags |= IEEE80211_STA_DISABLE_HT;
5313-
if (!bss->wmm_used &&
5314-
!(ifmgd->flags & IEEE80211_STA_DISABLE_WMM))
5315-
netdev_info(sdata->dev,
5316-
"disabling HT as WMM/QoS is not supported by the AP\n");
5317-
}
53185323

5319-
/* disable VHT if we don't support it or the AP doesn't use WMM */
5320-
if (!sband->vht_cap.vht_supported ||
5321-
local->hw.queues < IEEE80211_NUM_ACS || !bss->wmm_used ||
5322-
ifmgd->flags & IEEE80211_STA_DISABLE_WMM) {
5324+
/* also disable HT/VHT/HE if the AP doesn't use WMM */
5325+
if (!bss->wmm_used) {
5326+
ifmgd->flags |= IEEE80211_STA_DISABLE_HT;
53235327
ifmgd->flags |= IEEE80211_STA_DISABLE_VHT;
5324-
if (!bss->wmm_used &&
5325-
!(ifmgd->flags & IEEE80211_STA_DISABLE_WMM))
5326-
netdev_info(sdata->dev,
5327-
"disabling VHT as WMM/QoS is not supported by the AP\n");
5328+
ifmgd->flags |= IEEE80211_STA_DISABLE_HE;
5329+
netdev_info(sdata->dev,
5330+
"disabling HT/VHT/HE as WMM/QoS is not supported by the AP\n");
53285331
}
53295332

53305333
memcpy(&ifmgd->ht_capa, &req->ht_capa, sizeof(ifmgd->ht_capa));
@@ -5456,6 +5459,7 @@ int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata,
54565459
if (req->flags & ASSOC_REQ_DISABLE_HT) {
54575460
ifmgd->flags |= IEEE80211_STA_DISABLE_HT;
54585461
ifmgd->flags |= IEEE80211_STA_DISABLE_VHT;
5462+
ifmgd->flags |= IEEE80211_STA_DISABLE_HE;
54595463
}
54605464

54615465
if (req->flags & ASSOC_REQ_DISABLE_VHT)

0 commit comments

Comments
 (0)