Skip to contentSkip to conversation

mac80211: connect with HT20 if HT40 is not permitted

RFC In review Johannes Berg 1 participant 3 messages Oct 1, 2012 – Oct 16, 2012 mac80211

lore
Share & tools
lore

Johannes Berg

author maintainer
#0 lore raw

RFC 1/1 mac80211: connect with HT20 if HT40 is not permitted

From: Johannes Berg <[email protected]>

Some changes to fix issues with HT40 APs in Korea and follow-up changes to allow using HT40 even if the local regulatory database disallows it caused issues with iwlwifi (and could cause issues with other devices); iwlwifi firmware would assert if you tried to connect to an AP that has an invalid configuration (e.g. using HT40- on channel 140.)

Fix this, while avoiding the "Korean AP" issue by disabling HT40 and advertising HT20 to the AP when connecting.

---
 net/mac80211/mlme.c |   40 ++++++++++++++++++++++++++--------------
 1 file changed, 26 insertions(+), 14 deletions(-)
net/mac80211/mlme.c +26 -14
index fe4b744..3b05952 100644
@@ -3199,27 +3199,39 @@ static int ieee80211_prep_channel(struct ieee80211_sub_if_data *sdata,
 				   ht_cfreq, ht_oper->primary_chan,
 				   cbss->channel->band);
 			ht_oper = NULL;
+		} else {
+			channel_type = NL80211_CHAN_HT20;
 		}
 	}
 
-	if (ht_oper) {
-		const u8 *ht_cap_ie;
-		const struct ieee80211_ht_cap *ht_cap;
-		u8 chains = 1;
-
-		channel_type = NL80211_CHAN_HT20;
+	if (ht_oper && sband->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40) {
+		/*
+		 * cfg80211 already verified that the channel itself can
+		 * be used, but it didn't check that we can do the right
+		 * HT type, so do that here as well. If HT40 isn't allowed
+		 * on this channel, disable 40 MHz operation.
+		 */
 
-		if (sband->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40) {
-			switch (ht_oper->ht_param &
-					IEEE80211_HT_PARAM_CHA_SEC_OFFSET) {
-			case IEEE80211_HT_PARAM_CHA_SEC_ABOVE:
+		switch (ht_oper->ht_param & IEEE80211_HT_PARAM_CHA_SEC_OFFSET) {
+		case IEEE80211_HT_PARAM_CHA_SEC_ABOVE:
+			if (cbss->channel->flags & IEEE80211_CHAN_NO_HT40PLUS)
+				ifmgd->flags |= IEEE80211_STA_DISABLE_40MHZ;
+			else
 				channel_type = NL80211_CHAN_HT40PLUS;
-				break;
-			case IEEE80211_HT_PARAM_CHA_SEC_BELOW:
+			break;
+		case IEEE80211_HT_PARAM_CHA_SEC_BELOW:
+			if (cbss->channel->flags & IEEE80211_CHAN_NO_HT40MINUS)
+				ifmgd->flags |= IEEE80211_STA_DISABLE_40MHZ;
+			else
 				channel_type = NL80211_CHAN_HT40MINUS;
-				break;
-			}
+			break;
 		}
+	}
+
+	if (ht_oper) {
+		const u8 *ht_cap_ie;
+		const struct ieee80211_ht_cap *ht_cap;
+		u8 chains = 1;
 
 		ht_cap_ie = cfg80211_find_ie(WLAN_EID_HT_CAPABILITY,
 					     cbss->information_elements,
Signature · 1 line
1.7.10.4
author maintainer
#1 lore raw

net/mac80211/mlme.c static int ieee80211_prep_channel(struct ieee80211_sub_if_data *sdata, · line 3217

Quoted 6 lines · Johannes Berg

Fix this, while avoiding the "Korean AP" issue by
disabling HT40 and advertising HT20 to the AP
when connecting.

net/mac80211/mlme.c +2 -0
+		case IEEE80211_HT_PARAM_CHA_SEC_ABOVE:
+			if (cbss->channel->flags & IEEE80211_CHAN_NO_HT40PLUS)

What we *could* do instead is use "channel->orig_flags" here instead to fix the iwlwifi issue, and allow HT40 RX for when the driver/device has no limitations (and the HT40 restriction would be regulatory only), but I'm not sure I see much value in that? That might enable HT40 RX (not TX) for some devices on those Korean HT40 APs though, but it'd also be somewhat tricky in the code and more or less relying on cfg80211 internals ... I'd prefer not to introduce these kinds of subtle differences between devices but if somebody has strong objections to the patch as is I'd be willing to change it.

johannes

author maintainer
#2 lore raw
In reply to Johannes Berg
Quoted 10 lines · Johannes Berg

From: Johannes Berg <[email protected]>

Some changes to fix issues with HT40 APs in Korea and follow-up changes to allow using HT40 even if the local regulatory database disallows it caused issues with iwlwifi (and could cause issues with other devices); iwlwifi firmware would assert if you tried to connect to an AP that has an invalid configuration (e.g. using HT40- on channel 140.)

Quoted 3 lines

Fix this, while avoiding the "Korean AP" issue by disabling HT40 and advertising HT20 to the AP when connecting.

No comments, so I'm applying this :)

johannes