]> git.ipfire.org Git - thirdparty/iw.git/commitdiff
iw: sync frequency to channel mapping with kernel for 6GHz band
authorPradeep Kumar Chitrapu <pradeepc@codeaurora.org>
Fri, 15 May 2020 17:51:45 +0000 (10:51 -0700)
committerJohannes Berg <johannes.berg@intel.com>
Thu, 28 May 2020 09:27:54 +0000 (11:27 +0200)
This enables support for channel to frequency conversion and vice versa
for 6GHz channels and frequencies. Channel numbers of 6GHz band might
overlap with those of 5G and 2G bands.

Signed-off-by: Pradeep Kumar Chitrapu <pradeepc@codeaurora.org>
Link: https://lore.kernel.org/r/20200515175145.30080-1-pradeepc@codeaurora.org
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
util.c

diff --git a/util.c b/util.c
index 886fef2b5e2c8ecdc9d40b620ea18cef11399167..ac6a96dc2851a36ff6fd5c8fe03d42dc8532d03f 100644 (file)
--- a/util.c
+++ b/util.c
@@ -180,6 +180,11 @@ int ieee80211_channel_to_frequency(int chan, enum nl80211_band band)
                else
                        return 5000 + chan * 5;
                break;
+       case NL80211_BAND_6GHZ:
+       /* see 802.11ax D4.1 27.3.22.2 */
+               if (chan <= 253)
+                       return 5940 + chan * 5;
+               break;
        case NL80211_BAND_60GHZ:
                if (chan < 5)
                        return 56160 + chan * 2160;
@@ -199,9 +204,12 @@ int ieee80211_frequency_to_channel(int freq)
                return (freq - 2407) / 5;
        else if (freq >= 4910 && freq <= 4980)
                return (freq - 4000) / 5;
-       else if (freq <= 45000) /* DMG band lower limit */
+       else if (freq < 5945)
                return (freq - 5000) / 5;
-       else if (freq >= 58320 && freq <= 64800)
+       else if (freq <= 45000) /* DMG band lower limit */
+               /* see 802.11ax D4.1 27.3.22.2 */
+               return (freq - 5940) / 5;
+       else if (freq >= 58320 && freq <= 70200)
                return (freq - 56160) / 2160;
        else
                return 0;