Skip to contentSkip to conversation

wifi: brcmfmac: probe VHT80-capable regrev on, BCM43602 ISO3166 fallback

PATCH New Richard Lane 1 participant 1 message Nov 26 Broadcom BRCM80211 IEEE802.11 wireless drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 wifi: brcmfmac: probe VHT80-capable regrev on, BCM43602 ISO3166 fallback

On platforms without a platform/DT country_codes mapping (such as x86 Apple iMac and MacBook Pro systems), brcmf_translate_country_code() falls back to passing the ISO 3166 alpha2 country code with rev = 0 to the BCM43602 firmware.

In the BCM43602 firmware shipped by linux-firmware (7.35.177.61, r598657, PCI 14e4:43ba), rev = 0 enables 80 MHz VHT channels for US, but disables all 80 MHz channels for European/ETSI country codes such as DE, GB, and EU. As a result, 802.11ac links in affected regions are capped at 40 MHz even when both the firmware and AP support 80 MHz.

Probing the firmware's embedded CLM table via the "country" iovar on 7.35.177.61 shows why neither rev = -1, a fixed non-zero rev, nor selecting the highest accepted rev is safe:

  req     fw      2.4G ch  5G ch  80MHz ch  DFS ch  Notes
  ------  ------  -------  -----  --------  ------  ----------------------
  DE/0    DE/0    13       19     0         15      40 MHz only (current)
  DE/2    DE/2    13       19     16        15      first VHT80 rev
  DE/3    DE/3    13       19     0         15      regresses to 40 MHz
  DE/7    DE/7    13       19     16        15      VHT80
  GB/-1   GB/0    13       19     0         15      40 MHz only
  GB/0    GB/0    13       19     0         15      40 MHz only (current)
  GB/1    GB/1    13       19     0         15      40 MHz only
  GB/2    GB/2    13       19     16        15      first VHT80 rev
  GB/3    GB/3    13       23     20        15      adds 4 UNII-3 ch
  GB/6    GB/6    13       19     16        15      VHT80
  EU/0    EU/0    13       4      0         0       40 MHz only
  EU/13   EU/13   13       16     12        12      first VHT80 rev
  US/0    US/0    11       25     24        16      already VHT80
  US/1,2  US/1,2  14/11    0      0         0       5 GHz disabled
  US/9    US/9    13       25     24        16      opens 2.4G ch 12-13

Keep rev = 0 as the initial request so countries such as US/0 succeed without extra firmware commands. On BRCM_CC_43602_CHIP_ID without a platform country_codes table, if rev = 0 leaves a VHT-capable 5 GHz band with no 80 MHz channels, probe ascending revisions (1..15) for the same alpha2 and compare per-band channel bitmasks via brcmf_chan_mask() to select the first revision that:

1. enables at least one 80 MHz 5 GHz channel,
2. enables no 2.4 GHz channel disabled under rev = 0, and
3. disables no 5 GHz channel enabled under rev = 0.

If no revision satisfies these constraints (e.g. E0), restore rev = 0. cfg80211 continues enforcing Linux wireless-regdb rules on top of the firmware channel list.

Tested on Apple iMac17,1 (BCM43602/1, 14e4:43ba, firmware 7.35.177.61) against a 2x2 80 MHz 5 GHz AP on channel 48 (5240 MHz, GB/DE regdom):

  Metric                 Before (rev=0)        After (probed rev=2)
  ---------------------  --------------------  -----------------------
  Channel width          40 MHz (5230 MHz)     80 MHz (5210 MHz)
  5240 MHz iw flags      20MHz HT40-           20MHz HT40- VHT80
  RX / TX PHY bitrate    400.0 / 400.0 MBit/s  866 / 866 MBit/s
  iperf3 TCP TX / RX     325.0 / 315.8 Mbps    635 / 599 Mbps
Fixes 21947f3a74d6 ("brcmfmac: use ISO3166 country code and 0 rev as fallback on brcmfmac43602 chips")
---
 .../broadcom/brcm80211/brcmfmac/cfg80211.c    | 59 +++++++++++++++++++
 1 file changed, 59 insertions(+)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c +59 -0
index 57689026525e..a90a7c1cdad1 100644
@@ -8442,6 +8442,62 @@ brcmf_cfg80211_dump_survey(struct wiphy *wiphy, struct net_device *ndev,
 	return err;
 }
 
+static u64 brcmf_chan_mask(struct ieee80211_supported_band *band, u32 reject)
+{
+	u64 mask = 0;
+	int i;
+
+	if (!band)
+		return 0;
+
+	for (i = 0; i < band->n_channels && i < 64; i++) {
+		if (!(band->channels[i].flags & reject))
+			mask |= BIT_ULL(i);
+	}
+	return mask;
+}
+
+static void brcmf_probe_vht80_regrev(struct wiphy *wiphy,
+				     struct brcmf_if *ifp,
+				     struct brcmf_cfg80211_info *cfg,
+				     const struct brcmf_fil_country_le *base_cc)
+{
+	struct ieee80211_supported_band *b2 = wiphy->bands[NL80211_BAND_2GHZ];
+	struct ieee80211_supported_band *b5 = wiphy->bands[NL80211_BAND_5GHZ];
+	const u32 no80 = IEEE80211_CHAN_DISABLED | IEEE80211_CHAN_NO_80MHZ;
+	struct brcmf_fil_country_le probe;
+	u64 base_2g, base_5g;
+	bool dirty = false;
+	int rev;
+
+	if (!b5 || !b5->vht_cap.vht_supported || brcmf_chan_mask(b5, no80))
+		return;
+
+	base_2g = brcmf_chan_mask(b2, IEEE80211_CHAN_DISABLED);
+	base_5g = brcmf_chan_mask(b5, IEEE80211_CHAN_DISABLED);
+
+	for (rev = 1; rev <= 15; rev++) {
+		probe = *base_cc;
+		probe.rev = cpu_to_le32(rev);
+		if (brcmf_fil_iovar_data_set(ifp, "country", &probe,
+					     sizeof(probe)))
+			continue;
+
+		dirty = true;
+		brcmf_setup_wiphybands(cfg);
+		if (brcmf_chan_mask(b5, no80) &&
+		    !(brcmf_chan_mask(b2, IEEE80211_CHAN_DISABLED) & ~base_2g) &&
+		    !(base_5g & ~brcmf_chan_mask(b5, IEEE80211_CHAN_DISABLED)))
+			return;
+	}
+
+	if (dirty) {
+		probe = *base_cc;
+		brcmf_fil_iovar_data_set(ifp, "country", &probe, sizeof(probe));
+		brcmf_setup_wiphybands(cfg);
+	}
+}
+
 static void brcmf_cfg80211_reg_notifier(struct wiphy *wiphy,
 					struct regulatory_request *req)
 {
@@ -8483,6 +8539,9 @@ static void brcmf_cfg80211_reg_notifier(struct wiphy *wiphy,
 		return;
 	}
 	brcmf_setup_wiphybands(cfg);
+	if (ifp->drvr->bus_if->chip == BRCM_CC_43602_CHIP_ID &&
+	    !ifp->drvr->settings->country_codes && !ccreq.rev)
+		brcmf_probe_vht80_regrev(wiphy, ifp, cfg, &ccreq);
 }
 
 static void brcmf_free_wiphy(struct wiphy *wiphy)

base-commit: 18d0bedbb5f0538396cb7f763ed9cd1dd69c5b23

Signature · 1 line
2.55.0