]> git.ipfire.org Git - thirdparty/iw.git/commitdiff
util: add support for 320MHz bandwidth without cf1
authorMordechay Goodstein <mordechay.goodstein@intel.com>
Sun, 29 May 2022 16:29:55 +0000 (19:29 +0300)
committerJohannes Berg <johannes.berg@intel.com>
Fri, 14 Apr 2023 10:53:59 +0000 (12:53 +0200)
Based on user input for control central freq and 320 BW find the data
central freq (cf1).

Signed-off-by: Mordechay Goodstein <mordechay.goodstein@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
phy.c
util.c

diff --git a/phy.c b/phy.c
index 0a57ecbff45667afed216658c8a69ead6db60445..15cea32321bff757ba0a74d0b2830c982111887f 100644 (file)
--- a/phy.c
+++ b/phy.c
@@ -199,13 +199,13 @@ static int handle_freq(struct nl80211_state *state, struct nl_msg *msg,
 }
 
 COMMAND(set, freq,
-       "<freq> [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz|160MHz]\n"
+       "<freq> [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz|160MHz|320MHz]\n"
        "<control freq> [5|10|20|40|80|80+80|160] [<center1_freq> [<center2_freq>]]",
        NL80211_CMD_SET_WIPHY, 0, CIB_PHY, handle_freq,
        "Set frequency/channel the hardware is using, including HT\n"
        "configuration.");
 COMMAND(set, freq,
-       "<freq> [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz|160MHz]\n"
+       "<freq> [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz|160MHz|320MHz]\n"
        "<control freq> [5|10|20|40|80|80+80|160] [<center1_freq> [<center2_freq>]]",
        NL80211_CMD_SET_WIPHY, 0, CIB_NETDEV, handle_freq, NULL);
 
diff --git a/util.c b/util.c
index 93269abc7d5a4789d43ace1efa2cbe4379e8ac11..80dc30170a6e8248f6bd5b5b1dba6aa948dc2738 100644 (file)
--- a/util.c
+++ b/util.c
@@ -583,7 +583,7 @@ static int parse_freqs(struct chandef *chandef, int argc, char **argv,
  *   <channel> [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz|160MHz]
  *
  * And if frequency is set:
- *   <freq> [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz|160MHz]
+ *   <freq> [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz|160MHz|320MHz]
  *   <control freq> [5|10|20|40|80|80+80|160] [<center1_freq> [<center2_freq>]]
  *
  * If the mode/channel width is not given the NOHT is assumed.
@@ -1696,6 +1696,8 @@ int get_cf1(const struct chanmode *chanmode, unsigned long freq)
                                6195, 6995 };
        unsigned int bw160[] = { 5180, 5500, 5955, 6115, 6275, 6435,
                                  6595, 6755, 6915 };
+       /* based on 11be D2 E.1 Country information and operating classes */
+       unsigned int bw320[] = {5955, 6115, 6275, 6435, 6595, 6755};
 
        switch (chanmode->width) {
        case NL80211_CHAN_WIDTH_80:
@@ -1722,6 +1724,18 @@ int get_cf1(const struct chanmode *chanmode, unsigned long freq)
 
                cf1 = bw160[j] + 70;
                break;
+       case NL80211_CHAN_WIDTH_320:
+               /* setup center_freq1 */
+               for (j = 0; j < ARRAY_SIZE(bw320); j++) {
+                       if (freq >= bw320[j] && freq < bw320[j] + 160)
+                               break;
+               }
+
+               if (j == ARRAY_SIZE(bw320))
+                       break;
+
+               cf1 = bw320[j] + 150;
+               break;
        default:
                cf1 = freq + chanmode->freq1_diff;
                break;