]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
wifi: rtw89: regd: block 6 GHz if marked as N/A in regd map
authorZong-Zhe Yang <kevin_yang@realtek.com>
Wed, 16 Oct 2024 13:44:57 +0000 (21:44 +0800)
committerPing-Ke Shih <pkshih@realtek.com>
Fri, 25 Oct 2024 02:10:26 +0000 (10:10 +0800)
If 6 GHz of a country is marked as N/A in our regd map,
we block 6 GHz channels now.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241016134457.9375-1-pkshih@realtek.com
drivers/net/wireless/realtek/rtw89/regd.c

index bb064a086970bbbe4c66641273c32e4173b3c97f..cad5189708e7948e4e2a8e1594d4219c37b1d662 100644 (file)
@@ -646,22 +646,44 @@ static void rtw89_regd_apply_policy_unii4(struct rtw89_dev *rtwdev,
                sband->channels[i].flags |= IEEE80211_CHAN_DISABLED;
 }
 
-static void rtw89_regd_apply_policy_6ghz(struct rtw89_dev *rtwdev,
-                                        struct wiphy *wiphy)
+static bool regd_is_6ghz_blocked(struct rtw89_dev *rtwdev)
 {
        struct rtw89_regulatory_info *regulatory = &rtwdev->regulatory;
        const struct rtw89_regd *regd = regulatory->regd;
-       struct ieee80211_supported_band *sband;
        u8 index;
-       int i;
 
        index = rtw89_regd_get_index(regd);
        if (index != RTW89_REGD_MAX_COUNTRY_NUM &&
            !test_bit(index, regulatory->block_6ghz))
-               return;
+               return false;
 
        rtw89_debug(rtwdev, RTW89_DBG_REGD, "%c%c 6 GHz is blocked by policy\n",
                    regd->alpha2[0], regd->alpha2[1]);
+       return true;
+}
+
+static bool regd_is_6ghz_not_applicable(struct rtw89_dev *rtwdev)
+{
+       struct rtw89_regulatory_info *regulatory = &rtwdev->regulatory;
+       const struct rtw89_regd *regd = regulatory->regd;
+
+       if (regd->txpwr_regd[RTW89_BAND_6G] != RTW89_NA)
+               return false;
+
+       rtw89_debug(rtwdev, RTW89_DBG_REGD, "%c%c 6 GHz is N/A in regd map\n",
+                   regd->alpha2[0], regd->alpha2[1]);
+       return true;
+}
+
+static void rtw89_regd_apply_policy_6ghz(struct rtw89_dev *rtwdev,
+                                        struct wiphy *wiphy)
+{
+       struct ieee80211_supported_band *sband;
+       int i;
+
+       if (!regd_is_6ghz_blocked(rtwdev) &&
+           !regd_is_6ghz_not_applicable(rtwdev))
+               return;
 
        sband = wiphy->bands[NL80211_BAND_6GHZ];
        if (!sband)