Skip to contentSkip to conversation

mac80211: Let VHT work on 2.4Ghz

PATCH In review [email protected] 2 participants 2 messages Mar 10, 2016 – Mar 15, 2016 mac80211

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 mac80211: Let VHT work on 2.4Ghz

From: Ben Greear <[email protected]>

ath10k supports VHT on 2.4Ghz band.
If supplicant and hostapd and radio think VHT should be allowed, then kernel should let them try, as long as at least one band can do 80Mhz.

If no bands can do 80Mhz, then that is an indication that VHT is not enabled in this regulatory domain.

---
v2: Only allow VHT on 2.4 if 80Mhz is available on at least one band.

 net/mac80211/ieee80211_i.h |  1 +
 net/mac80211/mlme.c        | 15 +--------------
 net/mac80211/util.c        | 33 +++++++++++++++++++++++----------
 net/mac80211/vht.c         | 15 ++-------------
 4 files changed, 27 insertions(+), 37 deletions(-)
net/mac80211/ieee80211_i.h +1 -0
index 19de36f..c0dc0e2 100644
@@ -1800,6 +1800,7 @@ static inline int __ieee80211_resume(struct ieee80211_hw *hw)
 }
 
 /* utility functions/constants */
+bool ieee80211_any_band_supports_80mhz(struct ieee80211_local *local);
 extern const void *const mac80211_wiphy_privid; /* for wiphy privid */
 int ieee80211_frame_duration(enum ieee80211_band band, size_t len,
 			     int rate, int erp, int short_preamble,
net/mac80211/mlme.c +1 -14
index b63cd7d..d6e9bdc 100644
@@ -4228,8 +4228,6 @@ static int ieee80211_prep_channel(struct ieee80211_sub_if_data *sdata,
 	struct ieee80211_supported_band *sband;
 	struct cfg80211_chan_def chandef;
 	int ret;
-	u32 i;
-	bool have_80mhz;
 
 	sband = local->hw.wiphy->bands[cbss->channel->band];
 
@@ -4280,18 +4278,7 @@ static int ieee80211_prep_channel(struct ieee80211_sub_if_data *sdata,
 		}
 	}
 
-	/* Allow VHT if at least one channel on the sband supports 80 MHz */
-	have_80mhz = false;
-	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)
+	if (!ieee80211_any_band_supports_80mhz(local))
 		ifmgd->flags |= IEEE80211_STA_DISABLE_VHT;
 
 	ifmgd->flags |= ieee80211_determine_chantype(sdata, sband,
net/mac80211/util.c +23 -10
index 56b2c27..ae90c4f 100644
@@ -762,6 +762,27 @@ void ieee80211_queue_delayed_work(struct ieee80211_hw *hw,
 }
 EXPORT_SYMBOL(ieee80211_queue_delayed_work);
 
+bool ieee80211_any_band_supports_80mhz(struct ieee80211_local *local)
+{
+	int i;
+	struct ieee80211_supported_band *sband;
+
+	for (i = 0; i < IEEE80211_NUM_BANDS; i++) {
+		int q;
+		sband = local->hw.wiphy->bands[i];
+		if (!sband)
+			continue;
+		for (q = 0; q < sband->n_channels; q++) {
+			if (sband->channels[q].flags &
+			    (IEEE80211_CHAN_DISABLED | IEEE80211_CHAN_NO_80MHZ))
+				continue;
+
+			return true;
+		}
+	}
+	return false;
+}
+
 u32 ieee802_11_parse_elems_crc(const u8 *start, size_t len, bool action,
 			       struct ieee802_11_elems *elems,
 			       u64 filter, u32 crc)
@@ -1375,7 +1396,7 @@ static int ieee80211_build_preq_ies_band(struct ieee80211_local *local,
 	int ext_rates_len;
 	int shift;
 	u32 rate_flags;
-	bool have_80mhz = false;
+	bool have_80mhz;
 
 	*offset = 0;
 
@@ -1504,15 +1525,7 @@ static int ieee80211_build_preq_ies_band(struct ieee80211_local *local,
 		*offset = noffset;
 	}
 
-	/* Check if any channel in this sband supports at least 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;
-	}
+	have_80mhz = ieee80211_any_band_supports_80mhz(local);
 
 	if (sband->vht_cap.vht_supported && have_80mhz) {
 		if (end - pos < 2 + sizeof(struct ieee80211_vht_cap))
net/mac80211/vht.c +2 -13
index c38b2f0..a08a77f 100644
@@ -120,7 +120,7 @@ ieee80211_vht_cap_ie_to_sta_vht_cap(struct ieee80211_sub_if_data *sdata,
 	struct ieee80211_sta_vht_cap *vht_cap = &sta->sta.vht_cap;
 	struct ieee80211_sta_vht_cap own_cap;
 	u32 cap_info, i;
-	bool have_80mhz;
+	struct ieee80211_local *local = sdata->local;
 
 	memset(vht_cap, 0, sizeof(*vht_cap));
 
@@ -130,18 +130,7 @@ ieee80211_vht_cap_ie_to_sta_vht_cap(struct ieee80211_sub_if_data *sdata,
 	if (!vht_cap_ie || !sband->vht_cap.vht_supported)
 		return;
 
-	/* Allow VHT if at least one channel on the sband supports 80 MHz */
-	have_80mhz = false;
-	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)
+	if (!ieee80211_any_band_supports_80mhz(local))
 		return;
 
 	/*
Signature · 1 line
2.4.3
maintainer
#1 lore raw
Quoted 3 lines · On Thu, 2016-03-10 at 10:08 -0800, [email protected] wrote:

From: Ben Greear <[email protected]>

ath10k supports VHT on 2.4Ghz band.

I still don't think this is the right thing to do.

Most implementations seem to use the BRCM vendor IE to advertise "VHT" features on 2.4 GHz, since the spec requires 5 GHz for the real ones.

The combination of ath10k with mac80211 seems to be broken in that regard right now, since mac80211 didn't expect drivers to set the capabilities for 2.4 GHz band.

I guess we can get away with using the regular capabilities towards userspace, but as far as the IEs are concerned we should probably use the BRCM ones.

johannes