Skip to contentSkip to conversation

wifi: mt76: mt7925: apply ACPI MTCL/MTVP to regd and 6G usage

PATCH New JB Tsai 1 participant 1 message Nov 12

Subsystems (2)
lore
Share & tools
lore

JB Tsai

author
#0 lore raw

PATCH 1/1 wifi: mt76: mt7925: apply ACPI MTCL/MTVP to regd and 6G usage

From: Charlie-cy Wu <[email protected]>

Read the ACPI MTVP table and use it together with MTCL to decide which 5.9G/6G/EHT capabilities and 6G VLP operation are allowed.

MTCL:
- Accept the V1 short table (6G only) and cross-check the version against the table length so a short table cannot be read beyond its end. V1 has no 5.9G block, report 5.9G as depending on the driver (0x2) instead of forcing it enabled.
- Reject MTCL tables with an unknown version (0 or > 3).
- Add Table 8 List 5 (India, Nicaragua) to the country list and limit Australia 6G to Ch1-93, or Ch1-125 when the Australia_Ex bit is set.
- Fix the cc_list_be country order to match Table 9.

MTVP:
- Reject MTVP tables with an unknown version (0 or > 2).
- Add mt792x_acpi_vlp_allowed() to disallow STA connection to 6G VLP APs (IEEE80211_CHAN_NO_6GHZ_VLP_CLIENT) in countries not allowed by MTVP.
- Add mt792x_acpi_ap_6g_allowed() (MTVP V2) and reject 6G SoftAP in mt7925_start_ap() with -EOPNOTSUPP when not allowed.

Self-managed regd:
cfg80211 rebuilds the channel flags from the self-managed regd, so channel flags set by the driver are overwritten. Apply MTCL/MTVP to the regd rules built from MT792x_CLC_REGD instead:
- Remove the 5.9G/6G ranges disabled by MTCL from the rules, splitting a rule when needed. The max bandwidth of a trimmed rule is limited to 20/40/80/160 MHz within the rule width, and a rule narrower than 20 MHz is dropped.
- Set NL80211_RRF_NO_EHT when MTCL disables BE.
- Set NL80211_RRF_NO_6GHZ_VLP_CLIENT on 6G rules when MTVP disallows VLP.

Sync the FW with the self-managed regd, so the FW uses exactly the channels and EHT setting cfg80211 built from it:
- Set WIPHY_FLAG_NOTIFY_REGDOM_BY_DRIVER and resend SET_DOMAIN_INFO and the tx power from mt7925_regd_notifier() once cfg80211 has rebuilt the channel flags (NL80211_REGDOM_SET_BY_DRIVER). Before, the FW got the flags of the previous country plus the CLC restrictions.
- Skip mt7925_regd_channel_update() for a self-managed regd, the channel flags come from the regd only.
- Take has_eht from MTCL only, not from the CLC BE_CTRL table, like NL80211_RRF_NO_EHT.
- Send the 6G rate tx power only when cfg80211 has a 6G channel enabled, instead of checking clc_chan_conf.

---
 .../net/wireless/mediatek/mt76/mt7925/main.c  |   6 +
 .../net/wireless/mediatek/mt76/mt7925/mcu.c   |  22 ++-
 .../net/wireless/mediatek/mt76/mt7925/regd.c  | 169 +++++++++++++++++-
 drivers/net/wireless/mediatek/mt76/mt792x.h   |  18 ++
 .../wireless/mediatek/mt76/mt792x_acpi_sar.c  | 165 +++++++++++++++--
 .../wireless/mediatek/mt76/mt792x_acpi_sar.h  |  12 ++
 6 files changed, 375 insertions(+), 17 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/main.c +6 -0
index 289663fb84d7..33ef279a7145 100644
@@ -1964,6 +1964,12 @@ mt7925_start_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
 	struct mt792x_dev *dev = mt792x_hw_dev(hw);
 	int err;
 
+	/* MTVP: SoftAP on 6G not allowed in this country */
+	if (link_conf->chanreq.oper.chan &&
+	    link_conf->chanreq.oper.chan->band == NL80211_BAND_6GHZ &&
+	    !mt792x_acpi_ap_6g_allowed(&dev->phy, dev->mt76.alpha2))
+		return -EOPNOTSUPP;
+
 	mt792x_mutex_acquire(dev);
 
 	err = mt7925_mcu_add_bss_info(&dev->phy, mvif->bss_conf.mt76.ctx,
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +21 -1
index 14d346c4ff5a..f7d34e0ad96c 100644
@@ -4435,12 +4435,32 @@ int mt7925_mcu_send_ant_sar(struct mt76_phy *phy)
 				 &req, sizeof(req), true);
 }
 
+/* any 6G channel left enabled by cfg80211 */
+static bool mt7925_mcu_6g_enabled(struct mt76_phy *phy)
+{
+	struct ieee80211_supported_band *sband = &phy->sband_6g.sband;
+	int i;
+
+	for (i = 0; i < sband->n_channels; i++)
+		if (!(sband->channels[i].flags & IEEE80211_CHAN_DISABLED))
+			return true;
+
+	return false;
+}
+
 int mt7925_mcu_set_rate_txpower(struct mt76_phy *phy)
 {
 	struct mt76_dev *mdev = phy->dev;
 	struct mt792x_dev *dev = mt792x_hw_dev(mdev->hw);
+	bool en_6g;
 	int err;
 
+	/* self-managed: follow the channel flags cfg80211 built from the regd */
+	if (MT7925_REGD_SUPPORTED(&dev->phy))
+		en_6g = mt7925_mcu_6g_enabled(phy);
+	else
+		en_6g = dev->phy.clc_chan_conf;
+
 	if (phy->cap.has_2ghz) {
 		err = mt7925_mcu_rate_txpower_band(phy,
 						   NL80211_BAND_2GHZ);
@@ -4455,7 +4475,7 @@ int mt7925_mcu_set_rate_txpower(struct mt76_phy *phy)
 			return err;
 	}
 
-	if (phy->cap.has_6ghz && dev->phy.clc_chan_conf) {
+	if (phy->cap.has_6ghz && en_6g) {
 		err = mt7925_mcu_rate_txpower_band(phy,
 						   NL80211_BAND_6GHZ);
 		if (err < 0)
drivers/net/wireless/mediatek/mt76/mt7925/regd.c +164 -5

235 lines not on this page · raw message

drivers/net/wireless/mediatek/mt76/mt792x.h +18 -0
index c491f5a42cb4..98fb03ff0df3 100644
@@ -685,6 +685,9 @@ int mt792x_init_acpi_sar(struct mt792x_dev *dev);
 int mt792x_init_acpi_sar_power(struct mt792x_phy *phy, bool set_default);
 u8 mt792x_acpi_get_flags(struct mt792x_phy *phy);
 u32 mt792x_acpi_get_mtcl_conf(struct mt792x_phy *phy, char *alpha2);
+u16 mt792x_acpi_get_mtcl_6g_end(struct mt792x_phy *phy, char *alpha2);
+bool mt792x_acpi_vlp_allowed(struct mt792x_phy *phy, char *alpha2);
+bool mt792x_acpi_ap_6g_allowed(struct mt792x_phy *phy, char *alpha2);
 #else
 static inline int mt792x_init_acpi_sar(struct mt792x_dev *dev)
 {
@@ -706,6 +709,21 @@ static inline u32 mt792x_acpi_get_mtcl_conf(struct mt792x_phy *phy, char *alpha2
 {
 	return MT792X_ACPI_MTCL_INVALID;
 }
+
+static inline u16 mt792x_acpi_get_mtcl_6g_end(struct mt792x_phy *phy, char *alpha2)
+{
+	return 7125;
+}
+
+static inline bool mt792x_acpi_vlp_allowed(struct mt792x_phy *phy, char *alpha2)
+{
+	return true;
+}
+
+static inline bool mt792x_acpi_ap_6g_allowed(struct mt792x_phy *phy, char *alpha2)
+{
+	return true;
+}
 #endif
 
 #endif /* __MT7925_H */
drivers/net/wireless/mediatek/mt76/mt792x_acpi_sar.c +154 -11

216 lines not on this page · raw message

drivers/net/wireless/mediatek/mt76/mt792x_acpi_sar.h +12 -0
index 474033073831..dc63c60b3907 100644
@@ -14,6 +14,7 @@
 #define MT792x_ACPI_MTDS		"MTDS"
 #define MT792x_ACPI_MTGS		"MTGS"
 #define MT792x_ACPI_MTFG		"MTFG"
+#define MT792x_ACPI_MTVP		"MTVP"
 
 #define MT792X_ACPI_MTCL_INVALID	0xffffffff
 
@@ -94,6 +95,16 @@ struct mt792x_asar_cl {
 	u8 cl5g9[6];
 } __packed;
 
+/* V1 ends at clvlp[], V2 appends the SoftAP 6G block */
+struct mt792x_asar_vp {
+	u8 names[4];
+	u8 version;
+	u8 mode_vlp;
+	u8 clvlp[6];
+	u8 mode_ap;
+	u8 clap[6];
+} __packed;
+
 struct mt792x_asar_fg {
 	u8 names[4];
 	u8 version;
@@ -118,6 +129,7 @@ struct mt792x_acpi_sar {
 		struct mt792x_asar_cl_v3 *countrylist_v3;
 	};
 	struct mt792x_asar_fg *fg;
+	struct mt792x_asar_vp *vp;
 };
 
 #endif
Signature · 1 line
2.18.0