OpenWrt Forum Archive

Topic: unlock all supports frequencies of my device

The content of this topic has been archived on 14 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

hi, im looking for a way to unlock superchannel of my nanostation m2 with opwnwrt firmware.


root@OpenWrt:~# iwinfo wlan0 freqlist
  2.312 GHz (Channel 237)
  2.317 GHz (Channel 238)
  2.322 GHz (Channel 239)
  2.327 GHz (Channel 240)
  2.332 GHz (Channel 241)
  2.337 GHz (Channel 242)
  2.342 GHz (Channel 243)
  2.347 GHz (Channel 244)
  2.352 GHz (Channel 245)
  2.357 GHz (Channel 246)
  2.362 GHz (Channel 247)
  2.367 GHz (Channel 248)
  2.372 GHz (Channel 249)
  2.377 GHz (Channel 250)
  2.382 GHz (Channel 251)
  2.387 GHz (Channel 252)
  2.392 GHz (Channel 253)
  2.397 GHz (Channel 254)
  2.402 GHz (Channel 255)
  2.407 GHz (Channel unknown)
  2.412 GHz (Channel 1)
  2.417 GHz (Channel 2)
  2.422 GHz (Channel 3)
  2.427 GHz (Channel 4)
  2.432 GHz (Channel 5)
  2.437 GHz (Channel 6)
  2.442 GHz (Channel 7)
  2.447 GHz (Channel 8)
  2.452 GHz (Channel 9)
  2.457 GHz (Channel 10)
  2.462 GHz (Channel 11)
  2.467 GHz (Channel 12)
* 2.472 GHz (Channel 13)
  2.484 GHz (Channel 14)

this is what shoud show

  2.412 GHz (Channel 1)
  2.417 GHz (Channel 2)
  2.422 GHz (Channel 3)
  2.427 GHz (Channel 4)
  2.432 GHz (Channel 5)
  2.437 GHz (Channel 6)
  2.442 GHz (Channel 7)
  2.447 GHz (Channel 8)
  2.452 GHz (Channel 9)
  2.457 GHz (Channel 10)
  2.462 GHz (Channel 11)
  2.467 GHz (Channel 12)
* 2.472 GHz (Channel 13)
  2.484 GHz (Channel 14)

but this is what shows intead.

You would need a hacked ath9k driver.  OpenWrt uses the driver from the mainstream kernel, which is strict about using only legal (unlicensed) frequencies.

use these two patches to get part of the band unlocked. do similar channel hardcode patching if need full band (up to 2.7GHz) (the patch might be broken or not apply correctly depending on checkout revison so your best chance is to patch manually)

it will also allow running channel 14 at 300Mbps

mac80211

diff -pur a/drivers/net/wireless/ath/ath9k/common-init.c b/drivers/net/wireless/ath/ath9k/common-init.c
--- a/drivers/net/wireless/ath/ath9k/common-init.c    2017-01-27 03:12:57.878225039 +0100
+++ b/drivers/net/wireless/ath/ath9k/common-init.c    2017-01-27 02:12:25.667393000 +0100
@@ -22,7 +22,7 @@
     .band = NL80211_BAND_2GHZ, \
     .center_freq = (_freq), \
     .hw_value = (_idx), \
-    .max_power = 20, \
+    .max_power = 30, \
 }
 
 #define CHAN5G(_freq, _idx) { \
@@ -37,6 +37,50 @@
  * we have calibration data for all cards though to make
  * this static */
 static const struct ieee80211_channel ath9k_2ghz_chantable[] = {
+    CHAN2G(2192, 58), /* Channel 213 */
+    CHAN2G(2197, 57), /* Channel 214 */
+    CHAN2G(2202, 56), /* Channel 215 */
+    CHAN2G(2207, 55), /* Channel 216 */
+    CHAN2G(2212, 54), /* Channel 217 */
+    CHAN2G(2217, 53), /* Channel 218 */
+    CHAN2G(2222, 52), /* Channel 219 */
+    CHAN2G(2227, 51), /* Channel 220 */
+    CHAN2G(2232, 50), /* Channel 221 */
+    CHAN2G(2237, 49), /* Channel 222 */
+    CHAN2G(2242, 48), /* Channel 223 */
+    CHAN2G(2247, 47), /* Channel 224 */
+    CHAN2G(2252, 46), /* Channel 225 */
+    CHAN2G(2257, 45), /* Channel 226 */
+    CHAN2G(2262, 44), /* Channel 227 */
+    CHAN2G(2267, 43), /* Channel 228 */
+    CHAN2G(2272, 42), /* Channel 229 */
+    CHAN2G(2277, 41), /* Channel 230 */
+    CHAN2G(2282, 40), /* Channel 231 */
+    CHAN2G(2287, 39), /* Channel 232 */
+    CHAN2G(2292, 38), /* Channel 233 */
+    CHAN2G(2297, 37), /* Channel 234 */
+    CHAN2G(2302, 36), /* Channel 235 */
+    CHAN2G(2307, 35), /* Channel 236 */
+    CHAN2G(2312, 34), /* Channel 237 */
+    CHAN2G(2317, 33), /* Channel 238 */
+    CHAN2G(2322, 32), /* Channel 239 */
+    CHAN2G(2327, 31), /* Channel 240 */
+    CHAN2G(2332, 30), /* Channel 241 */
+    CHAN2G(2337, 29), /* Channel 242 */
+    CHAN2G(2342, 28), /* Channel 243 */
+    CHAN2G(2347, 27), /* Channel 244 */
+    CHAN2G(2352, 26), /* Channel 245 */
+    CHAN2G(2357, 25), /* Channel 246 */
+    CHAN2G(2362, 24), /* Channel 247 */
+    CHAN2G(2367, 23), /* Channel 248 */
+    CHAN2G(2372, 22), /* Channel 249 */
+    CHAN2G(2377, 21), /* Channel 250 */
+    CHAN2G(2382, 20), /* Channel 251 */
+    CHAN2G(2387, 19), /* Channel 252 */
+    CHAN2G(2392, 18), /* Channel 253 */
+    CHAN2G(2397, 17), /* Channel 254 */
+    CHAN2G(2402, 16), /* Channel 255 */
+    CHAN2G(2407, 15), /* Channel 0 */
     CHAN2G(2412, 0), /* Channel 1 */
     CHAN2G(2417, 1), /* Channel 2 */
     CHAN2G(2422, 2), /* Channel 3 */
@@ -48,6 +92,7 @@ static const struct ieee80211_channel at
     CHAN2G(2452, 8), /* Channel 9 */
     CHAN2G(2457, 9), /* Channel 10 */
     CHAN2G(2462, 10), /* Channel 11 */
+    CHAN2G(2464, 14), /* Channel 11 */
     CHAN2G(2467, 11), /* Channel 12 */
     CHAN2G(2472, 12), /* Channel 13 */
     CHAN2G(2484, 13), /* Channel 14 */
diff -pur a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
--- a/drivers/net/wireless/ath/ath9k/hw.h    2017-01-27 03:12:44.230158313 +0100
+++ b/drivers/net/wireless/ath/ath9k/hw.h    2017-01-27 02:12:29.919414000 +0100
@@ -74,7 +74,7 @@
 
 #define ATH9K_RSSI_BAD            -128
 
-#define ATH9K_NUM_CHANNELS    38
+#define ATH9K_NUM_CHANNELS    83
 
 /* Register read/write primitives */
 #define REG_WRITE(_ah, _reg, _val) \
diff -pur a/drivers/net/wireless/ath/regd.c b/drivers/net/wireless/ath/regd.c
--- a/drivers/net/wireless/ath/regd.c    2017-01-27 03:34:37.760579834 +0100
+++ b/drivers/net/wireless/ath/regd.c    2017-01-27 01:39:28.073725000 +0100
@@ -33,29 +33,16 @@ static int __ath_regd_init(struct ath_re
  */
 
 /* Only these channels all allow active scan on all world regulatory domains */
-#define ATH9K_2GHZ_CH01_11    REG_RULE(2412-10, 2462+10, 40, 0, 20, 0)
-
-/* We enable active scan on these a case by case basis by regulatory domain */
-#define ATH9K_2GHZ_CH12_13    REG_RULE(2467-10, 2472+10, 40, 0, 20,\
-                     NL80211_RRF_NO_IR)
-#define ATH9K_2GHZ_CH14        REG_RULE(2484-10, 2484+10, 40, 0, 20,\
-                     NL80211_RRF_NO_IR | \
-                     NL80211_RRF_NO_OFDM)
+#define ATH9K_2GHZ_2224        REG_RULE(2192-10, 2472+10, 40, 0, 30, 0)
+#define ATH9K_2GHZ_CH14        REG_RULE(2484-10, 2484+10, 40, 0, 30, 0)
+#define ATH9K_2GHZ_2527        REG_RULE(2492-10, 2732+10, 40, 0, 30, 0)
+
+#define ATH9K_2GHZ        ATH9K_2GHZ_2224, \
+                ATH9K_2GHZ_CH14, \
+                ATH9K_2GHZ_2527
 
 /* We allow IBSS on these on a case by case basis by regulatory domain */
-#define ATH9K_5GHZ_5150_5350    REG_RULE(5150-10, 5350+10, 80, 0, 30,\
-                     NL80211_RRF_NO_IR)
-#define ATH9K_5GHZ_5470_5850    REG_RULE(5470-10, 5850+10, 80, 0, 30,\
-                     NL80211_RRF_NO_IR)
-#define ATH9K_5GHZ_5725_5850    REG_RULE(5725-10, 5850+10, 80, 0, 30,\
-                     NL80211_RRF_NO_IR)
-
-#define ATH9K_2GHZ_ALL        ATH9K_2GHZ_CH01_11, \
-                ATH9K_2GHZ_CH12_13, \
-                ATH9K_2GHZ_CH14
-
-#define ATH9K_5GHZ_ALL        ATH9K_5GHZ_5150_5350, \
-                ATH9K_5GHZ_5470_5850
+#define ATH9K_5GHZ        REG_RULE(4900-10, 6100+10, 80, 0, 30, 0)
 
 /* This one skips what we call "mid band" */
 #define ATH9K_5GHZ_NO_MIDBAND    ATH9K_5GHZ_5150_5350, \
@@ -70,8 +57,8 @@ static int __ath_regd_init(struct ath_re
 static const struct ieee80211_regdomain ath_world_regdom_60_61_62 = {
     .alpha2 =  "99",
     REGD_RULES(
-        ATH9K_2GHZ_ALL,
-        ATH9K_5GHZ_ALL,
+        ATH9K_2GHZ,
+        ATH9K_5GHZ,
     )
 };
 
@@ -79,9 +66,8 @@ static const struct ieee80211_regdomain 
 static const struct ieee80211_regdomain ath_world_regdom_63_65 = {
     .alpha2 =  "99",
     REGD_RULES(
-        ATH9K_2GHZ_CH01_11,
-        ATH9K_2GHZ_CH12_13,
-        ATH9K_5GHZ_NO_MIDBAND,
+        ATH9K_2GHZ,
+        ATH9K_5GHZ,
     )
 };
 
@@ -89,8 +75,8 @@ static const struct ieee80211_regdomain 
 static const struct ieee80211_regdomain ath_world_regdom_64 = {
     .alpha2 =  "99",
     REGD_RULES(
-        ATH9K_2GHZ_CH01_11,
-        ATH9K_5GHZ_NO_MIDBAND,
+        ATH9K_2GHZ,
+        ATH9K_5GHZ,
     )
 };
 
@@ -98,8 +84,8 @@ static const struct ieee80211_regdomain 
 static const struct ieee80211_regdomain ath_world_regdom_66_69 = {
     .alpha2 =  "99",
     REGD_RULES(
-        ATH9K_2GHZ_CH01_11,
-        ATH9K_5GHZ_ALL,
+        ATH9K_2GHZ,
+        ATH9K_5GHZ,
     )
 };
 
@@ -107,9 +93,8 @@ static const struct ieee80211_regdomain 
 static const struct ieee80211_regdomain ath_world_regdom_67_68_6A_6C = {
     .alpha2 =  "99",
     REGD_RULES(
-        ATH9K_2GHZ_CH01_11,
-        ATH9K_2GHZ_CH12_13,
-        ATH9K_5GHZ_ALL,
+        ATH9K_2GHZ,
+        ATH9K_5GHZ,
     )
 };
 
diff -pur a/net/wireless/reg.c b/net/wireless/reg.c
--- a/net/wireless/reg.c    2017-01-24 21:54:57.121925000 +0100
+++ b/net/wireless/reg.c    2017-01-27 02:07:42.950011000 +0100
@@ -220,15 +220,8 @@ static const struct ieee80211_regdomain 
     .alpha2 =  "00",
     .reg_rules = {
         /* IEEE 802.11b/g, channels 1..11 */
-        REG_RULE(2412-10, 2462+10, 40, 6, 20, 0),
-        /* IEEE 802.11b/g, channels 12..13. */
-        REG_RULE(2467-10, 2472+10, 20, 6, 20,
-            NL80211_RRF_NO_IR | NL80211_RRF_AUTO_BW),
-        /* IEEE 802.11 channel 14 - Only JP enables
-         * this and for 802.11b only */
-        REG_RULE(2484-10, 2484+10, 20, 6, 20,
-            NL80211_RRF_NO_IR |
-            NL80211_RRF_NO_OFDM),
+        REG_RULE(2192-10, 2472+10, 40, 6, 30, 0),
+        REG_RULE(2484-10, 2484+10, 40, 6, 30, 0),
         /* IEEE 802.11a, channel 36..48 */
         REG_RULE(5180-10, 5240+10, 80, 6, 20,
                         NL80211_RRF_NO_IR |
@@ -2812,13 +2805,6 @@ static int reg_set_rd_user(const struct 
     if (!regdom_changes(rd->alpha2))
         return -EALREADY;
 
-    if (!is_valid_rd(rd)) {
-        pr_err("Invalid regulatory domain detected: %c%c\n",
-               rd->alpha2[0], rd->alpha2[1]);
-        print_regdomain_info(rd);
-        return -EINVAL;
-    }
-
     if (!user_request->intersect) {
         reset_regdomains(false, rd);
         return 0;
@@ -2849,13 +2835,6 @@ static int reg_set_rd_driver(const struc
     if (!regdom_changes(rd->alpha2))
         return -EALREADY;
 
-    if (!is_valid_rd(rd)) {
-        pr_err("Invalid regulatory domain detected: %c%c\n",
-               rd->alpha2[0], rd->alpha2[1]);
-        print_regdomain_info(rd);
-        return -EINVAL;
-    }
-
     request_wiphy = wiphy_idx_to_wiphy(driver_request->wiphy_idx);
     if (!request_wiphy)
         return -ENODEV;
@@ -2908,13 +2887,6 @@ static int reg_set_rd_country_ie(const s
      * and the pending request came in from a country IE
      */
 
-    if (!is_valid_rd(rd)) {
-        pr_err("Invalid regulatory domain detected: %c%c\n",
-               rd->alpha2[0], rd->alpha2[1]);
-        print_regdomain_info(rd);
-        return -EINVAL;
-    }
-
     request_wiphy = wiphy_idx_to_wiphy(country_ie_request->wiphy_idx);
     if (!request_wiphy)
         return -ENODEV;
@@ -3013,11 +2985,6 @@ static int __regulatory_set_wiphy_regd(s
          "wiphy should have REGULATORY_WIPHY_SELF_MANAGED\n"))
         return -EPERM;
 
-    if (WARN(!is_valid_rd(rd), "Invalid regulatory domain detected\n")) {
-        print_regdomain_info(rd);
-        return -EINVAL;
-    }
-
     regd = reg_copy_regd(rd);
     if (IS_ERR(regd))
         return PTR_ERR(regd);
diff -pur a/net/wireless/util.c b/net/wireless/util.c
--- a/net/wireless/util.c    2017-01-27 03:07:40.868675258 +0100
+++ b/net/wireless/util.c    2017-01-27 00:53:41.599777000 +0100
@@ -73,6 +73,7 @@ int ieee80211_channel_to_frequency(int c
         return 0; /* not supported */
     switch (band) {
     case NL80211_BAND_2GHZ:
+        chan = (int)(char)chan;
         if (chan == 14)
             return 2484;
         else if (chan < 14)
@@ -1449,7 +1450,14 @@ bool ieee80211_chandef_to_operating_clas
         if (chandef->width > NL80211_CHAN_WIDTH_40)
             return false;
 
-        *op_class = 82; /* channel 14 */
+        if (chandef->width == NL80211_CHAN_WIDTH_40) {
+            if (freq > chandef->chan->center_freq)
+                *op_class = 83; /* HT40+ */
+            else
+                *op_class = 84; /* HT40- */
+        } else {
+            *op_class = 81;
+        }
         return true;
     }
 

hostapd

diff -pur a/src/ap/hw_features.c b/src/ap/hw_features.c
--- a/src/ap/hw_features.c    2017-01-27 00:09:12.314728000 +0100
+++ b/src/ap/hw_features.c    2017-01-27 02:56:05.813277300 +0100
@@ -911,10 +911,7 @@ int hostapd_select_hw_mode(struct hostap
     if ((iface->conf->hw_mode == HOSTAPD_MODE_IEEE80211G ||
          iface->conf->ieee80211n || iface->conf->ieee80211ac) &&
         iface->conf->channel == 14) {
-        wpa_printf(MSG_INFO, "Disable OFDM/HT/VHT on channel 14");
-        iface->conf->hw_mode = HOSTAPD_MODE_IEEE80211B;
-        iface->conf->ieee80211n = 0;
-        iface->conf->ieee80211ac = 0;
+        iface->conf->hw_mode = HOSTAPD_MODE_IEEE80211G;
     }
 
     iface->current_mode = NULL;
diff -pur a/src/common/ieee802_11_common.c b/src/common/ieee802_11_common.c
--- a/src/common/ieee802_11_common.c    2017-01-27 02:01:29.732186000 +0100
+++ b/src/common/ieee802_11_common.c    2017-01-27 02:59:54.902397265 +0100
@@ -629,13 +629,498 @@ enum hostapd_hw_mode ieee80211_freq_to_c
         return HOSTAPD_MODE_IEEE80211G;
     }
 
-    if (freq == 2484) {
-        if (sec_channel || vht)
-            return NUM_HOSTAPD_MODES;
+    if (freq == 2192) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 213;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
 
-        *op_class = 82; /* channel 14 */
-        *channel = 14;
+    if (freq == 2197) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 214;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2202) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 215;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2207) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 216;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2212) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 217;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2217) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 218;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2222) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 219;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2227) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 220;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2232) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 221;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2237) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 222;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2242) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 223;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2247) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 224;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2252) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 225;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2257) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 226;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2262) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 227;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2267) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 228;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2272) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 229;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2277) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 230;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2282) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 231;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2287) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 232;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2292) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 233;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2297) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 234;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2302) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 235;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2307) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 236;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2312) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 237;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2317) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 238;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2322) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 239;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2327) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 240;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
 
+    if (freq == 2332) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 241;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2337) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 242;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2342) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 243;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2347) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 244;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2352) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 245;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2357) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 246;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2362) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 247;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2367) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 248;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2372) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 249;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2377) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 250;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2382) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 251;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2387) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 252;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2392) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 253;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2397) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 254;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2402) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 255;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2407) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 0;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2484) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 14;
         return HOSTAPD_MODE_IEEE80211G;
     }
 
@@ -1188,12 +1673,12 @@ struct wpabuf * mb_ies_by_info(struct mb
 
 
 const struct oper_class_map global_op_class[] = {
-    { HOSTAPD_MODE_IEEE80211G, 81, 1, 13, 1, BW20, P2P_SUPP },
-    { HOSTAPD_MODE_IEEE80211G, 82, 14, 14, 1, BW20, NO_P2P_SUPP },
+    { HOSTAPD_MODE_IEEE80211G, 81, 1, 14, 1, BW20, P2P_SUPP },
+    { HOSTAPD_MODE_IEEE80211G, 82, 14, 14, 1, BW20, P2P_SUPP },
 
     /* Do not enable HT40 on 2.4 GHz for P2P use for now */
-    { HOSTAPD_MODE_IEEE80211G, 83, 1, 9, 1, BW40PLUS, NO_P2P_SUPP },
-    { HOSTAPD_MODE_IEEE80211G, 84, 5, 13, 1, BW40MINUS, NO_P2P_SUPP },
+    { HOSTAPD_MODE_IEEE80211G, 83, 1, 14, 1, BW40PLUS, P2P_SUPP },
+    { HOSTAPD_MODE_IEEE80211G, 84, 1, 14, 1, BW40MINUS, P2P_SUPP },
 
     { HOSTAPD_MODE_IEEE80211A, 115, 36, 48, 4, BW20, P2P_SUPP },
     { HOSTAPD_MODE_IEEE80211A, 116, 36, 44, 8, BW40PLUS, P2P_SUPP },
anarchy99 wrote:

use these two patches to get part of the band unlocked. do similar channel hardcode patching if need full band (up to 2.7GHz) (the patch might be broken or not apply correctly depending on checkout revison so your best chance is to patch manually)

it will also allow running channel 14 at 300Mbps

mac80211

diff -pur a/drivers/net/wireless/ath/ath9k/common-init.c b/drivers/net/wireless/ath/ath9k/common-init.c
--- a/drivers/net/wireless/ath/ath9k/common-init.c    2017-01-27 03:12:57.878225039 +0100
+++ b/drivers/net/wireless/ath/ath9k/common-init.c    2017-01-27 02:12:25.667393000 +0100
@@ -22,7 +22,7 @@
     .band = NL80211_BAND_2GHZ, \
     .center_freq = (_freq), \
     .hw_value = (_idx), \
-    .max_power = 20, \
+    .max_power = 30, \
 }
 
 #define CHAN5G(_freq, _idx) { \
@@ -37,6 +37,50 @@
  * we have calibration data for all cards though to make
  * this static */
 static const struct ieee80211_channel ath9k_2ghz_chantable[] = {
+    CHAN2G(2192, 58), /* Channel 213 */
+    CHAN2G(2197, 57), /* Channel 214 */
+    CHAN2G(2202, 56), /* Channel 215 */
+    CHAN2G(2207, 55), /* Channel 216 */
+    CHAN2G(2212, 54), /* Channel 217 */
+    CHAN2G(2217, 53), /* Channel 218 */
+    CHAN2G(2222, 52), /* Channel 219 */
+    CHAN2G(2227, 51), /* Channel 220 */
+    CHAN2G(2232, 50), /* Channel 221 */
+    CHAN2G(2237, 49), /* Channel 222 */
+    CHAN2G(2242, 48), /* Channel 223 */
+    CHAN2G(2247, 47), /* Channel 224 */
+    CHAN2G(2252, 46), /* Channel 225 */
+    CHAN2G(2257, 45), /* Channel 226 */
+    CHAN2G(2262, 44), /* Channel 227 */
+    CHAN2G(2267, 43), /* Channel 228 */
+    CHAN2G(2272, 42), /* Channel 229 */
+    CHAN2G(2277, 41), /* Channel 230 */
+    CHAN2G(2282, 40), /* Channel 231 */
+    CHAN2G(2287, 39), /* Channel 232 */
+    CHAN2G(2292, 38), /* Channel 233 */
+    CHAN2G(2297, 37), /* Channel 234 */
+    CHAN2G(2302, 36), /* Channel 235 */
+    CHAN2G(2307, 35), /* Channel 236 */
+    CHAN2G(2312, 34), /* Channel 237 */
+    CHAN2G(2317, 33), /* Channel 238 */
+    CHAN2G(2322, 32), /* Channel 239 */
+    CHAN2G(2327, 31), /* Channel 240 */
+    CHAN2G(2332, 30), /* Channel 241 */
+    CHAN2G(2337, 29), /* Channel 242 */
+    CHAN2G(2342, 28), /* Channel 243 */
+    CHAN2G(2347, 27), /* Channel 244 */
+    CHAN2G(2352, 26), /* Channel 245 */
+    CHAN2G(2357, 25), /* Channel 246 */
+    CHAN2G(2362, 24), /* Channel 247 */
+    CHAN2G(2367, 23), /* Channel 248 */
+    CHAN2G(2372, 22), /* Channel 249 */
+    CHAN2G(2377, 21), /* Channel 250 */
+    CHAN2G(2382, 20), /* Channel 251 */
+    CHAN2G(2387, 19), /* Channel 252 */
+    CHAN2G(2392, 18), /* Channel 253 */
+    CHAN2G(2397, 17), /* Channel 254 */
+    CHAN2G(2402, 16), /* Channel 255 */
+    CHAN2G(2407, 15), /* Channel 0 */
     CHAN2G(2412, 0), /* Channel 1 */
     CHAN2G(2417, 1), /* Channel 2 */
     CHAN2G(2422, 2), /* Channel 3 */
@@ -48,6 +92,7 @@ static const struct ieee80211_channel at
     CHAN2G(2452, 8), /* Channel 9 */
     CHAN2G(2457, 9), /* Channel 10 */
     CHAN2G(2462, 10), /* Channel 11 */
+    CHAN2G(2464, 14), /* Channel 11 */
     CHAN2G(2467, 11), /* Channel 12 */
     CHAN2G(2472, 12), /* Channel 13 */
     CHAN2G(2484, 13), /* Channel 14 */
diff -pur a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
--- a/drivers/net/wireless/ath/ath9k/hw.h    2017-01-27 03:12:44.230158313 +0100
+++ b/drivers/net/wireless/ath/ath9k/hw.h    2017-01-27 02:12:29.919414000 +0100
@@ -74,7 +74,7 @@
 
 #define ATH9K_RSSI_BAD            -128
 
-#define ATH9K_NUM_CHANNELS    38
+#define ATH9K_NUM_CHANNELS    83
 
 /* Register read/write primitives */
 #define REG_WRITE(_ah, _reg, _val) \
diff -pur a/drivers/net/wireless/ath/regd.c b/drivers/net/wireless/ath/regd.c
--- a/drivers/net/wireless/ath/regd.c    2017-01-27 03:34:37.760579834 +0100
+++ b/drivers/net/wireless/ath/regd.c    2017-01-27 01:39:28.073725000 +0100
@@ -33,29 +33,16 @@ static int __ath_regd_init(struct ath_re
  */
 
 /* Only these channels all allow active scan on all world regulatory domains */
-#define ATH9K_2GHZ_CH01_11    REG_RULE(2412-10, 2462+10, 40, 0, 20, 0)
-
-/* We enable active scan on these a case by case basis by regulatory domain */
-#define ATH9K_2GHZ_CH12_13    REG_RULE(2467-10, 2472+10, 40, 0, 20,\
-                     NL80211_RRF_NO_IR)
-#define ATH9K_2GHZ_CH14        REG_RULE(2484-10, 2484+10, 40, 0, 20,\
-                     NL80211_RRF_NO_IR | \
-                     NL80211_RRF_NO_OFDM)
+#define ATH9K_2GHZ_2224        REG_RULE(2192-10, 2472+10, 40, 0, 30, 0)
+#define ATH9K_2GHZ_CH14        REG_RULE(2484-10, 2484+10, 40, 0, 30, 0)
+#define ATH9K_2GHZ_2527        REG_RULE(2492-10, 2732+10, 40, 0, 30, 0)
+
+#define ATH9K_2GHZ        ATH9K_2GHZ_2224, \
+                ATH9K_2GHZ_CH14, \
+                ATH9K_2GHZ_2527
 
 /* We allow IBSS on these on a case by case basis by regulatory domain */
-#define ATH9K_5GHZ_5150_5350    REG_RULE(5150-10, 5350+10, 80, 0, 30,\
-                     NL80211_RRF_NO_IR)
-#define ATH9K_5GHZ_5470_5850    REG_RULE(5470-10, 5850+10, 80, 0, 30,\
-                     NL80211_RRF_NO_IR)
-#define ATH9K_5GHZ_5725_5850    REG_RULE(5725-10, 5850+10, 80, 0, 30,\
-                     NL80211_RRF_NO_IR)
-
-#define ATH9K_2GHZ_ALL        ATH9K_2GHZ_CH01_11, \
-                ATH9K_2GHZ_CH12_13, \
-                ATH9K_2GHZ_CH14
-
-#define ATH9K_5GHZ_ALL        ATH9K_5GHZ_5150_5350, \
-                ATH9K_5GHZ_5470_5850
+#define ATH9K_5GHZ        REG_RULE(4900-10, 6100+10, 80, 0, 30, 0)
 
 /* This one skips what we call "mid band" */
 #define ATH9K_5GHZ_NO_MIDBAND    ATH9K_5GHZ_5150_5350, \
@@ -70,8 +57,8 @@ static int __ath_regd_init(struct ath_re
 static const struct ieee80211_regdomain ath_world_regdom_60_61_62 = {
     .alpha2 =  "99",
     REGD_RULES(
-        ATH9K_2GHZ_ALL,
-        ATH9K_5GHZ_ALL,
+        ATH9K_2GHZ,
+        ATH9K_5GHZ,
     )
 };
 
@@ -79,9 +66,8 @@ static const struct ieee80211_regdomain 
 static const struct ieee80211_regdomain ath_world_regdom_63_65 = {
     .alpha2 =  "99",
     REGD_RULES(
-        ATH9K_2GHZ_CH01_11,
-        ATH9K_2GHZ_CH12_13,
-        ATH9K_5GHZ_NO_MIDBAND,
+        ATH9K_2GHZ,
+        ATH9K_5GHZ,
     )
 };
 
@@ -89,8 +75,8 @@ static const struct ieee80211_regdomain 
 static const struct ieee80211_regdomain ath_world_regdom_64 = {
     .alpha2 =  "99",
     REGD_RULES(
-        ATH9K_2GHZ_CH01_11,
-        ATH9K_5GHZ_NO_MIDBAND,
+        ATH9K_2GHZ,
+        ATH9K_5GHZ,
     )
 };
 
@@ -98,8 +84,8 @@ static const struct ieee80211_regdomain 
 static const struct ieee80211_regdomain ath_world_regdom_66_69 = {
     .alpha2 =  "99",
     REGD_RULES(
-        ATH9K_2GHZ_CH01_11,
-        ATH9K_5GHZ_ALL,
+        ATH9K_2GHZ,
+        ATH9K_5GHZ,
     )
 };
 
@@ -107,9 +93,8 @@ static const struct ieee80211_regdomain 
 static const struct ieee80211_regdomain ath_world_regdom_67_68_6A_6C = {
     .alpha2 =  "99",
     REGD_RULES(
-        ATH9K_2GHZ_CH01_11,
-        ATH9K_2GHZ_CH12_13,
-        ATH9K_5GHZ_ALL,
+        ATH9K_2GHZ,
+        ATH9K_5GHZ,
     )
 };
 
diff -pur a/net/wireless/reg.c b/net/wireless/reg.c
--- a/net/wireless/reg.c    2017-01-24 21:54:57.121925000 +0100
+++ b/net/wireless/reg.c    2017-01-27 02:07:42.950011000 +0100
@@ -220,15 +220,8 @@ static const struct ieee80211_regdomain 
     .alpha2 =  "00",
     .reg_rules = {
         /* IEEE 802.11b/g, channels 1..11 */
-        REG_RULE(2412-10, 2462+10, 40, 6, 20, 0),
-        /* IEEE 802.11b/g, channels 12..13. */
-        REG_RULE(2467-10, 2472+10, 20, 6, 20,
-            NL80211_RRF_NO_IR | NL80211_RRF_AUTO_BW),
-        /* IEEE 802.11 channel 14 - Only JP enables
-         * this and for 802.11b only */
-        REG_RULE(2484-10, 2484+10, 20, 6, 20,
-            NL80211_RRF_NO_IR |
-            NL80211_RRF_NO_OFDM),
+        REG_RULE(2192-10, 2472+10, 40, 6, 30, 0),
+        REG_RULE(2484-10, 2484+10, 40, 6, 30, 0),
         /* IEEE 802.11a, channel 36..48 */
         REG_RULE(5180-10, 5240+10, 80, 6, 20,
                         NL80211_RRF_NO_IR |
@@ -2812,13 +2805,6 @@ static int reg_set_rd_user(const struct 
     if (!regdom_changes(rd->alpha2))
         return -EALREADY;
 
-    if (!is_valid_rd(rd)) {
-        pr_err("Invalid regulatory domain detected: %c%c\n",
-               rd->alpha2[0], rd->alpha2[1]);
-        print_regdomain_info(rd);
-        return -EINVAL;
-    }
-
     if (!user_request->intersect) {
         reset_regdomains(false, rd);
         return 0;
@@ -2849,13 +2835,6 @@ static int reg_set_rd_driver(const struc
     if (!regdom_changes(rd->alpha2))
         return -EALREADY;
 
-    if (!is_valid_rd(rd)) {
-        pr_err("Invalid regulatory domain detected: %c%c\n",
-               rd->alpha2[0], rd->alpha2[1]);
-        print_regdomain_info(rd);
-        return -EINVAL;
-    }
-
     request_wiphy = wiphy_idx_to_wiphy(driver_request->wiphy_idx);
     if (!request_wiphy)
         return -ENODEV;
@@ -2908,13 +2887,6 @@ static int reg_set_rd_country_ie(const s
      * and the pending request came in from a country IE
      */
 
-    if (!is_valid_rd(rd)) {
-        pr_err("Invalid regulatory domain detected: %c%c\n",
-               rd->alpha2[0], rd->alpha2[1]);
-        print_regdomain_info(rd);
-        return -EINVAL;
-    }
-
     request_wiphy = wiphy_idx_to_wiphy(country_ie_request->wiphy_idx);
     if (!request_wiphy)
         return -ENODEV;
@@ -3013,11 +2985,6 @@ static int __regulatory_set_wiphy_regd(s
          "wiphy should have REGULATORY_WIPHY_SELF_MANAGED\n"))
         return -EPERM;
 
-    if (WARN(!is_valid_rd(rd), "Invalid regulatory domain detected\n")) {
-        print_regdomain_info(rd);
-        return -EINVAL;
-    }
-
     regd = reg_copy_regd(rd);
     if (IS_ERR(regd))
         return PTR_ERR(regd);
diff -pur a/net/wireless/util.c b/net/wireless/util.c
--- a/net/wireless/util.c    2017-01-27 03:07:40.868675258 +0100
+++ b/net/wireless/util.c    2017-01-27 00:53:41.599777000 +0100
@@ -73,6 +73,7 @@ int ieee80211_channel_to_frequency(int c
         return 0; /* not supported */
     switch (band) {
     case NL80211_BAND_2GHZ:
+        chan = (int)(char)chan;
         if (chan == 14)
             return 2484;
         else if (chan < 14)
@@ -1449,7 +1450,14 @@ bool ieee80211_chandef_to_operating_clas
         if (chandef->width > NL80211_CHAN_WIDTH_40)
             return false;
 
-        *op_class = 82; /* channel 14 */
+        if (chandef->width == NL80211_CHAN_WIDTH_40) {
+            if (freq > chandef->chan->center_freq)
+                *op_class = 83; /* HT40+ */
+            else
+                *op_class = 84; /* HT40- */
+        } else {
+            *op_class = 81;
+        }
         return true;
     }
 

hostapd

diff -pur a/src/ap/hw_features.c b/src/ap/hw_features.c
--- a/src/ap/hw_features.c    2017-01-27 00:09:12.314728000 +0100
+++ b/src/ap/hw_features.c    2017-01-27 02:56:05.813277300 +0100
@@ -911,10 +911,7 @@ int hostapd_select_hw_mode(struct hostap
     if ((iface->conf->hw_mode == HOSTAPD_MODE_IEEE80211G ||
          iface->conf->ieee80211n || iface->conf->ieee80211ac) &&
         iface->conf->channel == 14) {
-        wpa_printf(MSG_INFO, "Disable OFDM/HT/VHT on channel 14");
-        iface->conf->hw_mode = HOSTAPD_MODE_IEEE80211B;
-        iface->conf->ieee80211n = 0;
-        iface->conf->ieee80211ac = 0;
+        iface->conf->hw_mode = HOSTAPD_MODE_IEEE80211G;
     }
 
     iface->current_mode = NULL;
diff -pur a/src/common/ieee802_11_common.c b/src/common/ieee802_11_common.c
--- a/src/common/ieee802_11_common.c    2017-01-27 02:01:29.732186000 +0100
+++ b/src/common/ieee802_11_common.c    2017-01-27 02:59:54.902397265 +0100
@@ -629,13 +629,498 @@ enum hostapd_hw_mode ieee80211_freq_to_c
         return HOSTAPD_MODE_IEEE80211G;
     }
 
-    if (freq == 2484) {
-        if (sec_channel || vht)
-            return NUM_HOSTAPD_MODES;
+    if (freq == 2192) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 213;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
 
-        *op_class = 82; /* channel 14 */
-        *channel = 14;
+    if (freq == 2197) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 214;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2202) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 215;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2207) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 216;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2212) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 217;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2217) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 218;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2222) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 219;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2227) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 220;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2232) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 221;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2237) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 222;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2242) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 223;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2247) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 224;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2252) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 225;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2257) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 226;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2262) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 227;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2267) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 228;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2272) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 229;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2277) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 230;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2282) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 231;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2287) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 232;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2292) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 233;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2297) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 234;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2302) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 235;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2307) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 236;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2312) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 237;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2317) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 238;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2322) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 239;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2327) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 240;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
 
+    if (freq == 2332) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 241;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2337) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 242;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2342) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 243;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2347) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 244;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2352) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 245;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2357) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 246;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2362) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 247;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2367) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 248;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2372) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 249;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2377) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 250;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2382) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 251;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2387) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 252;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2392) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 253;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2397) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 254;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2402) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 255;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2407) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 0;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2484) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 14;
         return HOSTAPD_MODE_IEEE80211G;
     }
 
@@ -1188,12 +1673,12 @@ struct wpabuf * mb_ies_by_info(struct mb
 
 
 const struct oper_class_map global_op_class[] = {
-    { HOSTAPD_MODE_IEEE80211G, 81, 1, 13, 1, BW20, P2P_SUPP },
-    { HOSTAPD_MODE_IEEE80211G, 82, 14, 14, 1, BW20, NO_P2P_SUPP },
+    { HOSTAPD_MODE_IEEE80211G, 81, 1, 14, 1, BW20, P2P_SUPP },
+    { HOSTAPD_MODE_IEEE80211G, 82, 14, 14, 1, BW20, P2P_SUPP },
 
     /* Do not enable HT40 on 2.4 GHz for P2P use for now */
-    { HOSTAPD_MODE_IEEE80211G, 83, 1, 9, 1, BW40PLUS, NO_P2P_SUPP },
-    { HOSTAPD_MODE_IEEE80211G, 84, 5, 13, 1, BW40MINUS, NO_P2P_SUPP },
+    { HOSTAPD_MODE_IEEE80211G, 83, 1, 14, 1, BW40PLUS, P2P_SUPP },
+    { HOSTAPD_MODE_IEEE80211G, 84, 1, 14, 1, BW40MINUS, P2P_SUPP },
 
     { HOSTAPD_MODE_IEEE80211A, 115, 36, 48, 4, BW20, P2P_SUPP },
     { HOSTAPD_MODE_IEEE80211A, 116, 36, 44, 8, BW40PLUS, P2P_SUPP },

You can expain how to apply this patch?
There is something updated for lede trunk?

I have modified the 2 patches and applied to my wr841nd v11. But the channel list is ever the same, only 13 channel. Should be i have to make other modification in the art partition?

diff -pur a/src/ap/hw_features.c b/src/ap/hw_features.c
--- a/src/ap/hw_features.c    2017-01-27 00:09:12.314728000 +0100
+++ b/src/ap/hw_features.c    2017-01-27 02:56:05.813277300 +0100
@@ -911,10 +911,7 @@ int hostapd_select_hw_mode(struct hostap
     if ((iface->conf->hw_mode == HOSTAPD_MODE_IEEE80211G ||
          iface->conf->ieee80211n || iface->conf->ieee80211ac) &&
         iface->conf->channel == 14) {
-        wpa_printf(MSG_INFO, "Disable OFDM/HT/VHT on channel 14");
-        iface->conf->hw_mode = HOSTAPD_MODE_IEEE80211B;
-        iface->conf->ieee80211n = 0;
-        iface->conf->ieee80211ac = 0;
+        iface->conf->hw_mode = HOSTAPD_MODE_IEEE80211G;
     }
 
     iface->current_mode = NULL;
diff -pur a/src/common/ieee802_11_common.c b/src/common/ieee802_11_common.c
--- a/src/common/ieee802_11_common.c    2017-01-27 02:01:29.732186000 +0100
+++ b/src/common/ieee802_11_common.c    2017-01-27 02:59:54.902397265 +0100
@@ -629,13 +629,498 @@ enum hostapd_hw_mode ieee80211_freq_to_c
         return HOSTAPD_MODE_IEEE80211G;
     }
 
-    if (freq == 2484) {
-        if (sec_channel || vht)
-            return NUM_HOSTAPD_MODES;
+    if (freq == 2192) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 213;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
 
-        *op_class = 82; /* channel 14 */
-        *channel = 14;
+    if (freq == 2197) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 214;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2202) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 215;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2207) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 216;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2212) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 217;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2217) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 218;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2222) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 219;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2227) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 220;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2232) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 221;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2237) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 222;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2242) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 223;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2247) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 224;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2252) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 225;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2257) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 226;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2262) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 227;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2267) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 228;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2272) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 229;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2277) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 230;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2282) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 231;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2287) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 232;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2292) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 233;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2297) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 234;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2302) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 235;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2307) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 236;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2312) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 237;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2317) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 238;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2322) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 239;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2327) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 240;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
 
+    if (freq == 2332) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 241;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2337) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 242;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2342) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 243;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2347) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 244;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2352) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 245;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2357) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 246;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2362) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 247;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2367) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 248;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2372) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 249;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2377) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 250;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2382) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 251;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2387) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 252;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2392) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 253;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2397) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 254;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2402) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 255;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2407) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 0;
+        return HOSTAPD_MODE_IEEE80211G;
+    }
+
+    if (freq == 2484) {
+        if (sec_channel == 1)
+            *op_class = 83;
+        else if (sec_channel == -1)
+            *op_class = 84;
+        else
+            *op_class = 81;
+        *channel = 14;
         return HOSTAPD_MODE_IEEE80211B;
     }
 
@@ -1188,12 +1673,12 @@ struct wpabuf * mb_ies_by_info(struct mb
 
 
 const struct oper_class_map global_op_class[] = {
-    { HOSTAPD_MODE_IEEE80211G, 81, 1, 13, 1, BW20, P2P_SUPP },
-    { HOSTAPD_MODE_IEEE80211G, 82, 14, 14, 1, BW20, NO_P2P_SUPP },
+    { HOSTAPD_MODE_IEEE80211G, 81, 1, 14, 1, BW20, P2P_SUPP },
+    { HOSTAPD_MODE_IEEE80211G, 82, 14, 14, 1, BW20, P2P_SUPP },
 
     /* Do not enable HT40 on 2.4 GHz for P2P use for now */
-    { HOSTAPD_MODE_IEEE80211G, 83, 1, 9, 1, BW40PLUS, NO_P2P_SUPP },
-    { HOSTAPD_MODE_IEEE80211G, 84, 5, 13, 1, BW40MINUS, NO_P2P_SUPP },
+    { HOSTAPD_MODE_IEEE80211G, 83, 1, 14, 1, BW40PLUS, P2P_SUPP },
+    { HOSTAPD_MODE_IEEE80211G, 84, 1, 14, 1, BW40MINUS, P2P_SUPP },
 
     { HOSTAPD_MODE_IEEE80211A, 115, 36, 48, 4, BW20, P2P_SUPP },
     { HOSTAPD_MODE_IEEE80211A, 116, 36, 44, 8, BW40PLUS, P2P_SUPP },
diff -pur a/drivers/net/wireless/ath/ath9k/common-init.c b/drivers/net/wireless/ath/ath9k/common-init.c
--- a/drivers/net/wireless/ath/ath9k/common-init.c    2017-01-27 03:12:57.878225039 +0100
+++ b/drivers/net/wireless/ath/ath9k/common-init.c    2017-01-27 02:12:25.667393000 +0100
@@ -22,7 +22,7 @@
     .band = NL80211_BAND_2GHZ, \
     .center_freq = (_freq), \
     .hw_value = (_idx), \
-    .max_power = 20, \
+    .max_power = 30, \
 }
 
 #define CHAN5G(_freq, _idx) { \
@@ -37,6 +37,50 @@
  * we have calibration data for all cards though to make
  * this static */
 static const struct ieee80211_channel ath9k_2ghz_chantable[] = {
+    CHAN2G(2192, 58), /* Channel 213 */
+    CHAN2G(2197, 57), /* Channel 214 */
+    CHAN2G(2202, 56), /* Channel 215 */
+    CHAN2G(2207, 55), /* Channel 216 */
+    CHAN2G(2212, 54), /* Channel 217 */
+    CHAN2G(2217, 53), /* Channel 218 */
+    CHAN2G(2222, 52), /* Channel 219 */
+    CHAN2G(2227, 51), /* Channel 220 */
+    CHAN2G(2232, 50), /* Channel 221 */
+    CHAN2G(2237, 49), /* Channel 222 */
+    CHAN2G(2242, 48), /* Channel 223 */
+    CHAN2G(2247, 47), /* Channel 224 */
+    CHAN2G(2252, 46), /* Channel 225 */
+    CHAN2G(2257, 45), /* Channel 226 */
+    CHAN2G(2262, 44), /* Channel 227 */
+    CHAN2G(2267, 43), /* Channel 228 */
+    CHAN2G(2272, 42), /* Channel 229 */
+    CHAN2G(2277, 41), /* Channel 230 */
+    CHAN2G(2282, 40), /* Channel 231 */
+    CHAN2G(2287, 39), /* Channel 232 */
+    CHAN2G(2292, 38), /* Channel 233 */
+    CHAN2G(2297, 37), /* Channel 234 */
+    CHAN2G(2302, 36), /* Channel 235 */
+    CHAN2G(2307, 35), /* Channel 236 */
+    CHAN2G(2312, 34), /* Channel 237 */
+    CHAN2G(2317, 33), /* Channel 238 */
+    CHAN2G(2322, 32), /* Channel 239 */
+    CHAN2G(2327, 31), /* Channel 240 */
+    CHAN2G(2332, 30), /* Channel 241 */
+    CHAN2G(2337, 29), /* Channel 242 */
+    CHAN2G(2342, 28), /* Channel 243 */
+    CHAN2G(2347, 27), /* Channel 244 */
+    CHAN2G(2352, 26), /* Channel 245 */
+    CHAN2G(2357, 25), /* Channel 246 */
+    CHAN2G(2362, 24), /* Channel 247 */
+    CHAN2G(2367, 23), /* Channel 248 */
+    CHAN2G(2372, 22), /* Channel 249 */
+    CHAN2G(2377, 21), /* Channel 250 */
+    CHAN2G(2382, 20), /* Channel 251 */
+    CHAN2G(2387, 19), /* Channel 252 */
+    CHAN2G(2392, 18), /* Channel 253 */
+    CHAN2G(2397, 17), /* Channel 254 */
+    CHAN2G(2402, 16), /* Channel 255 */
+    CHAN2G(2407, 15), /* Channel 0 */
     CHAN2G(2412, 0), /* Channel 1 */
     CHAN2G(2417, 1), /* Channel 2 */
     CHAN2G(2422, 2), /* Channel 3 */
@@ -48,6 +92,7 @@ static const struct ieee80211_channel at
     CHAN2G(2452, 8), /* Channel 9 */
     CHAN2G(2457, 9), /* Channel 10 */
     CHAN2G(2462, 10), /* Channel 11 */
+    CHAN2G(2464, 14), /* Channel 11 */
     CHAN2G(2467, 11), /* Channel 12 */
     CHAN2G(2472, 12), /* Channel 13 */
     CHAN2G(2484, 13), /* Channel 14 */
diff -pur a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
--- a/drivers/net/wireless/ath/ath9k/hw.h    2017-01-27 03:12:44.230158313 +0100
+++ b/drivers/net/wireless/ath/ath9k/hw.h    2017-01-27 02:12:29.919414000 +0100
@@ -74,7 +74,7 @@
 
 #define ATH9K_RSSI_BAD            -128
 
-#define ATH9K_NUM_CHANNELS    38
+#define ATH9K_NUM_CHANNELS    83
 
 /* Register read/write primitives */
 #define REG_WRITE(_ah, _reg, _val) \
diff -pur a/drivers/net/wireless/ath/regd.c b/drivers/net/wireless/ath/regd.c
--- a/drivers/net/wireless/ath/regd.c    2017-01-27 03:34:37.760579834 +0100
+++ b/drivers/net/wireless/ath/regd.c    2017-01-27 01:39:28.073725000 +0100
@@ -33,29 +33,16 @@ static int __ath_regd_init(struct ath_re
  */
 
 /* Only these channels all allow active scan on all world regulatory domains */
-#define ATH9K_2GHZ_CH01_11    REG_RULE(2412-10, 2462+10, 40, 0, 20, 0)
-
-/* We enable active scan on these a case by case basis by regulatory domain */
-#define ATH9K_2GHZ_CH12_13    REG_RULE(2467-10, 2472+10, 40, 0, 20,\
-                     NL80211_RRF_NO_IR)
-#define ATH9K_2GHZ_CH14        REG_RULE(2484-10, 2484+10, 40, 0, 20,\
-                     NL80211_RRF_NO_IR | \
-                     NL80211_RRF_NO_OFDM)
+#define ATH9K_2GHZ_2224        REG_RULE(2192-10, 2472+10, 40, 0, 30, 0)
+#define ATH9K_2GHZ_CH14        REG_RULE(2484-10, 2484+10, 40, 0, 30, 0)
+#define ATH9K_2GHZ_2527        REG_RULE(2492-10, 2732+10, 40, 0, 30, 0)
+
+#define ATH9K_2GHZ        ATH9K_2GHZ_2224, \
+                ATH9K_2GHZ_CH14, \
+                ATH9K_2GHZ_2527
 
 /* We allow IBSS on these on a case by case basis by regulatory domain */
-#define ATH9K_5GHZ_5150_5350    REG_RULE(5150-10, 5350+10, 80, 0, 30,\
-                     NL80211_RRF_NO_IR)
-#define ATH9K_5GHZ_5470_5850    REG_RULE(5470-10, 5850+10, 80, 0, 30,\
-                     NL80211_RRF_NO_IR)
-#define ATH9K_5GHZ_5725_5850    REG_RULE(5725-10, 5850+10, 80, 0, 30,\
-                     NL80211_RRF_NO_IR)
-
-#define ATH9K_2GHZ_ALL        ATH9K_2GHZ_CH01_11, \
-                ATH9K_2GHZ_CH12_13, \
-                ATH9K_2GHZ_CH14
-
-#define ATH9K_5GHZ_ALL        ATH9K_5GHZ_5150_5350, \
-                ATH9K_5GHZ_5470_5850
+#define ATH9K_5GHZ        REG_RULE(4900-10, 6100+10, 80, 0, 30, 0)
 
 /* This one skips what we call "mid band" */
 #define ATH9K_5GHZ_NO_MIDBAND    ATH9K_5GHZ_5150_5350, \
@@ -70,8 +57,8 @@ static int __ath_regd_init(struct ath_re
 static const struct ieee80211_regdomain ath_world_regdom_60_61_62 = {
     .alpha2 =  "99",
    .reg_rules = {
-        ATH9K_2GHZ_ALL,
-        ATH9K_5GHZ_ALL,
+        ATH9K_2GHZ,
+        ATH9K_5GHZ,
     }
 };
 
@@ -79,9 +66,8 @@ static const struct ieee80211_regdomain 
 static const struct ieee80211_regdomain ath_world_regdom_63_65 = {
     .alpha2 =  "99",
     .reg_rules = {
-        ATH9K_2GHZ_CH01_11,
-        ATH9K_2GHZ_CH12_13,
-        ATH9K_5GHZ_NO_MIDBAND,
+        ATH9K_2GHZ,
+        ATH9K_5GHZ,
     }
 };
 
@@ -89,8 +75,8 @@ static const struct ieee80211_regdomain 
 static const struct ieee80211_regdomain ath_world_regdom_64 = {
     .alpha2 =  "99",
     .reg_rules = {
-        ATH9K_2GHZ_CH01_11,
-        ATH9K_5GHZ_NO_MIDBAND,
+        ATH9K_2GHZ,
+        ATH9K_5GHZ,
     }
 };
 
@@ -98,8 +84,8 @@ static const struct ieee80211_regdomain 
 static const struct ieee80211_regdomain ath_world_regdom_66_69 = {
     .alpha2 =  "99",
     .reg_rules = {
-        ATH9K_2GHZ_CH01_11,
-        ATH9K_5GHZ_ALL,
+        ATH9K_2GHZ,
+        ATH9K_5GHZ,
     }
 };
 
@@ -107,9 +93,8 @@ static const struct ieee80211_regdomain 
 static const struct ieee80211_regdomain ath_world_regdom_67_68_6A_6C = {
     .alpha2 =  "99",
     .reg_rules = {
-        ATH9K_2GHZ_CH01_11,
-        ATH9K_2GHZ_CH12_13,
-        ATH9K_5GHZ_ALL,
+        ATH9K_2GHZ,
+        ATH9K_5GHZ,
     }
 };
 
diff -pur a/net/wireless/reg.c b/net/wireless/reg.c
--- a/net/wireless/reg.c    2017-01-24 21:54:57.121925000 +0100
+++ b/net/wireless/reg.c    2017-01-27 02:07:42.950011000 +0100
@@ -220,15 +220,8 @@ static const struct ieee80211_regdomain world_regdom = {
    .n_reg_rules = 8,
    .alpha2 =  "00",
    .reg_rules = {
        /* IEEE 802.11b/g, channels 1..11 */
-        REG_RULE(2412-10, 2462+10, 40, 6, 20, 0),
-        /* IEEE 802.11b/g, channels 12..13. */
-        REG_RULE(2467-10, 2472+10, 40, 6, 20,
-            NL80211_RRF_NO_IR),
-        /* IEEE 802.11 channel 14 - Only JP enables
-         * this and for 802.11b only */
-        REG_RULE(2484-10, 2484+10, 20, 6, 20,
-            NL80211_RRF_NO_IR |
-            NL80211_RRF_NO_OFDM),
+        REG_RULE(2192-10, 2472+10, 40, 6, 30, 0),
+        REG_RULE(2484-10, 2484+10, 40, 6, 30, 0),
         /* IEEE 802.11a, channel 36..48 */
        REG_RULE(5180-10, 5240+10, 160, 6, 20,
                        NL80211_RRF_NO_IR),

@@ -2812,13 +2805,6 @@ static int reg_set_rd_user(const struct 
     if (!regdom_changes(rd->alpha2))
         return -EALREADY;
 
-    if (!is_valid_rd(rd)) {
-        pr_err("Invalid regulatory domain detected: %c%c\n",
-               rd->alpha2[0], rd->alpha2[1]);
-        print_regdomain_info(rd);
-        return -EINVAL;
-    }
-
     if (!user_request->intersect) {
         reset_regdomains(false, rd);
         return 0;
@@ -2849,13 +2835,6 @@ static int reg_set_rd_driver(const struc
     if (!regdom_changes(rd->alpha2))
         return -EALREADY;
 
-    if (!is_valid_rd(rd)) {
-        pr_err("Invalid regulatory domain detected: %c%c\n",
-               rd->alpha2[0], rd->alpha2[1]);
-        print_regdomain_info(rd);
-        return -EINVAL;
-    }
-
     request_wiphy = wiphy_idx_to_wiphy(driver_request->wiphy_idx);
     if (!request_wiphy)
         return -ENODEV;
@@ -2908,13 +2887,6 @@ static int reg_set_rd_country_ie(const s
      * and the pending request came in from a country IE
      */
 
-    if (!is_valid_rd(rd)) {
-        pr_err("Invalid regulatory domain detected: %c%c\n",
-               rd->alpha2[0], rd->alpha2[1]);
-        print_regdomain_info(rd);
-        return -EINVAL;
-    }
-
     request_wiphy = wiphy_idx_to_wiphy(country_ie_request->wiphy_idx);
     if (!request_wiphy)
         return -ENODEV;
@@ -3013,11 +2985,6 @@ static int __regulatory_set_wiphy_regd(s
          "wiphy should have REGULATORY_WIPHY_SELF_MANAGED\n"))
         return -EPERM;
 
-    if (WARN(!is_valid_rd(rd), "Invalid regulatory domain detected\n")) {
-        print_regdomain_info(rd);
-        return -EINVAL;
-    }
-
     regd = reg_copy_regd(rd);
     if (IS_ERR(regd))
         return PTR_ERR(regd);
diff -pur a/net/wireless/util.c b/net/wireless/util.c
--- a/net/wireless/util.c    2017-01-27 03:07:40.868675258 +0100
+++ b/net/wireless/util.c    2017-01-27 00:53:41.599777000 +0100
@@ -73,6 +73,7 @@ int ieee80211_channel_to_frequency(int c
    
        return 0; /* not supported */
    switch (band) {
    case IEEE80211_BAND_2GHZ:
+        chan = (int)(char)chan;
         if (chan == 14)
            return 2484;
        else if (chan < 14)
            return 2407 + chan * 5;
        break;
@@ -1449,7 +1450,14 @@ bool ieee80211_chandef_to_operating_clas
         if (chandef->width > NL80211_CHAN_WIDTH_40)
             return false;
 
-        *op_class = 82; /* channel 14 */
+        if (chandef->width == NL80211_CHAN_WIDTH_40) {
+            if (freq > chandef->chan->center_freq)
+                *op_class = 83; /* HT40+ */
+            else
+                *op_class = 84; /* HT40- */
+        } else {
+            *op_class = 81;
+        }
         return true;
     }

The discussion might have continued from here.