From 6b9c86466c36ffd35460009deb9e6f4bdfcabfc9 Mon Sep 17 00:00:00 2001 From: Avraham Stern Date: Mon, 2 Jan 2023 11:17:26 +0200 Subject: [PATCH] nl80211: Replace the channel flags for VHT support The flags that indicate that a channel is allowed for 80/160 MHz use are divided according to the position of the control channel (e.g., HOSTAPD_CHAN_VHT_10_70, HOSTAPD_CHAN_VHT_30_50, etc.). However, the position of the control channel does not add any extra regulatory information because when trying to use a 80/160 MHz channel all the desired bandwidth has to be allowed for 80/160 MHz use, regardless of the control channel position. In addition, these flags are set only if the driver reports one regulatory rule that allows the entire 80/160 MHz bandwidth. However, even when a 80/160 MHz channel is allowed, in some cases the bandwidth will be split into several regulatory rules because different segments of the bandwidth differ in other flags (that don't affect the use of the bandwidth for VHT channels). So, in such cases these flags will not be set, although VHT channels are allowed. As the result, VHT channels will not be used although they are allowed by the regulatory domain. Fix this by introducing new flags that indicate if a 2 0MHz channel is allowed to be used as a part of a wider (80/160 MHz) channel. The new flags are set for each 20 MHz channel independently and thus will be set even if the regulatory rules for the bandwidth are split. A 80/160 MHz channel is allowed if all its 20 MHz sub-channels are allowed for 80/160 MHz usage. Signed-off-by: Avraham Stern Signed-off-by: Andrei Otcheretianski --- src/drivers/driver.h | 15 ++---------- src/drivers/driver_nl80211_capa.c | 40 +++++-------------------------- wpa_supplicant/op_classes.c | 15 +++--------- wpa_supplicant/p2p_supplicant.c | 25 +++---------------- 4 files changed, 14 insertions(+), 81 deletions(-) diff --git a/src/drivers/driver.h b/src/drivers/driver.h index 96a54ef2a..46182552d 100644 --- a/src/drivers/driver.h +++ b/src/drivers/driver.h @@ -41,23 +41,12 @@ #define HOSTAPD_CHAN_DFS_AVAILABLE 0x00000300 #define HOSTAPD_CHAN_DFS_MASK 0x00000300 -#define HOSTAPD_CHAN_VHT_10_70 0x00000800 -#define HOSTAPD_CHAN_VHT_30_50 0x00001000 -#define HOSTAPD_CHAN_VHT_50_30 0x00002000 -#define HOSTAPD_CHAN_VHT_70_10 0x00004000 +#define HOSTAPD_CHAN_VHT_80MHZ_SUBCHANNEL 0x00000800 +#define HOSTAPD_CHAN_VHT_160MHZ_SUBCHANNEL 0x00001000 #define HOSTAPD_CHAN_INDOOR_ONLY 0x00010000 #define HOSTAPD_CHAN_GO_CONCURRENT 0x00020000 -#define HOSTAPD_CHAN_VHT_10_150 0x00100000 -#define HOSTAPD_CHAN_VHT_30_130 0x00200000 -#define HOSTAPD_CHAN_VHT_50_110 0x00400000 -#define HOSTAPD_CHAN_VHT_70_90 0x00800000 -#define HOSTAPD_CHAN_VHT_90_70 0x01000000 -#define HOSTAPD_CHAN_VHT_110_50 0x02000000 -#define HOSTAPD_CHAN_VHT_130_30 0x04000000 -#define HOSTAPD_CHAN_VHT_150_10 0x08000000 - /* Allowed bandwidth mask */ enum hostapd_chan_width_attr { HOSTAPD_CHAN_WIDTH_10 = BIT(0), diff --git a/src/drivers/driver_nl80211_capa.c b/src/drivers/driver_nl80211_capa.c index 959f7f37d..53b50045c 100644 --- a/src/drivers/driver_nl80211_capa.c +++ b/src/drivers/driver_nl80211_capa.c @@ -2318,43 +2318,15 @@ static void nl80211_set_vht_mode(struct hostapd_hw_modes *mode, int start, for (c = 0; c < mode->num_channels; c++) { struct hostapd_channel_data *chan = &mode->channels[c]; - if (chan->freq - 10 >= start && chan->freq + 70 <= end) - chan->flag |= HOSTAPD_CHAN_VHT_10_70; - if (chan->freq - 30 >= start && chan->freq + 50 <= end) - chan->flag |= HOSTAPD_CHAN_VHT_30_50; + if (chan->freq - 10 < start || chan->freq + 10 > end) + continue; - if (chan->freq - 50 >= start && chan->freq + 30 <= end) - chan->flag |= HOSTAPD_CHAN_VHT_50_30; + if (max_bw >= 80) + chan->flag |= HOSTAPD_CHAN_VHT_80MHZ_SUBCHANNEL; - if (chan->freq - 70 >= start && chan->freq + 10 <= end) - chan->flag |= HOSTAPD_CHAN_VHT_70_10; - - if (max_bw >= 160) { - if (chan->freq - 10 >= start && chan->freq + 150 <= end) - chan->flag |= HOSTAPD_CHAN_VHT_10_150; - - if (chan->freq - 30 >= start && chan->freq + 130 <= end) - chan->flag |= HOSTAPD_CHAN_VHT_30_130; - - if (chan->freq - 50 >= start && chan->freq + 110 <= end) - chan->flag |= HOSTAPD_CHAN_VHT_50_110; - - if (chan->freq - 70 >= start && chan->freq + 90 <= end) - chan->flag |= HOSTAPD_CHAN_VHT_70_90; - - if (chan->freq - 90 >= start && chan->freq + 70 <= end) - chan->flag |= HOSTAPD_CHAN_VHT_90_70; - - if (chan->freq - 110 >= start && chan->freq + 50 <= end) - chan->flag |= HOSTAPD_CHAN_VHT_110_50; - - if (chan->freq - 130 >= start && chan->freq + 30 <= end) - chan->flag |= HOSTAPD_CHAN_VHT_130_30; - - if (chan->freq - 150 >= start && chan->freq + 10 <= end) - chan->flag |= HOSTAPD_CHAN_VHT_150_10; - } + if (max_bw >= 160) + chan->flag |= HOSTAPD_CHAN_VHT_160MHZ_SUBCHANNEL; } } diff --git a/wpa_supplicant/op_classes.c b/wpa_supplicant/op_classes.c index 5dca8f723..b4ad3caef 100644 --- a/wpa_supplicant/op_classes.c +++ b/wpa_supplicant/op_classes.c @@ -103,10 +103,7 @@ static enum chan_allowed verify_80mhz(struct hostapd_hw_modes *mode, NOT_ALLOWED) return NOT_ALLOWED; - if ((i == 0 && !(flags & HOSTAPD_CHAN_VHT_10_70)) || - (i == 1 && !(flags & HOSTAPD_CHAN_VHT_30_50)) || - (i == 2 && !(flags & HOSTAPD_CHAN_VHT_50_30)) || - (i == 3 && !(flags & HOSTAPD_CHAN_VHT_70_10))) + if (!(flags & HOSTAPD_CHAN_VHT_80MHZ_SUBCHANNEL)) return NOT_ALLOWED; if (flags & HOSTAPD_CHAN_NO_IR) @@ -175,14 +172,8 @@ static enum chan_allowed verify_160mhz(struct hostapd_hw_modes *mode, NOT_ALLOWED) return NOT_ALLOWED; - if ((i == 0 && !(flags & HOSTAPD_CHAN_VHT_10_150)) || - (i == 1 && !(flags & HOSTAPD_CHAN_VHT_30_130)) || - (i == 2 && !(flags & HOSTAPD_CHAN_VHT_50_110)) || - (i == 3 && !(flags & HOSTAPD_CHAN_VHT_70_90)) || - (i == 4 && !(flags & HOSTAPD_CHAN_VHT_90_70)) || - (i == 5 && !(flags & HOSTAPD_CHAN_VHT_110_50)) || - (i == 6 && !(flags & HOSTAPD_CHAN_VHT_130_30)) || - (i == 7 && !(flags & HOSTAPD_CHAN_VHT_150_10))) + if (!(flags & HOSTAPD_CHAN_VHT_80MHZ_SUBCHANNEL) || + !(flags & HOSTAPD_CHAN_VHT_160MHZ_SUBCHANNEL)) return NOT_ALLOWED; if (flags & HOSTAPD_CHAN_NO_IR) diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c index 4263ee9f3..aa4ce0964 100644 --- a/wpa_supplicant/p2p_supplicant.c +++ b/wpa_supplicant/p2p_supplicant.c @@ -3784,13 +3784,7 @@ static enum chan_allowed wpas_p2p_verify_80mhz(struct wpa_supplicant *wpa_s, if (res == NO_IR) ret = NO_IR; if (!is_6ghz) { - if (i == 0 && !(flags & HOSTAPD_CHAN_VHT_10_70)) - return NOT_ALLOWED; - if (i == 1 && !(flags & HOSTAPD_CHAN_VHT_30_50)) - return NOT_ALLOWED; - if (i == 2 && !(flags & HOSTAPD_CHAN_VHT_50_30)) - return NOT_ALLOWED; - if (i == 3 && !(flags & HOSTAPD_CHAN_VHT_70_10)) + if (!(flags & HOSTAPD_CHAN_VHT_80MHZ_SUBCHANNEL)) return NOT_ALLOWED; } else if (is_6ghz && (!(wpas_get_6ghz_he_chwidth_capab(mode) & @@ -3868,21 +3862,8 @@ static enum chan_allowed wpas_p2p_verify_160mhz(struct wpa_supplicant *wpa_s, ret = NO_IR; if (!is_6ghz_op_class(op_class)) { - if (i == 0 && !(flags & HOSTAPD_CHAN_VHT_10_150)) - return NOT_ALLOWED; - if (i == 1 && !(flags & HOSTAPD_CHAN_VHT_30_130)) - return NOT_ALLOWED; - if (i == 2 && !(flags & HOSTAPD_CHAN_VHT_50_110)) - return NOT_ALLOWED; - if (i == 3 && !(flags & HOSTAPD_CHAN_VHT_70_90)) - return NOT_ALLOWED; - if (i == 4 && !(flags & HOSTAPD_CHAN_VHT_90_70)) - return NOT_ALLOWED; - if (i == 5 && !(flags & HOSTAPD_CHAN_VHT_110_50)) - return NOT_ALLOWED; - if (i == 6 && !(flags & HOSTAPD_CHAN_VHT_130_30)) - return NOT_ALLOWED; - if (i == 7 && !(flags & HOSTAPD_CHAN_VHT_150_10)) + if (!(flags & HOSTAPD_CHAN_VHT_80MHZ_SUBCHANNEL) || + !(flags & HOSTAPD_CHAN_VHT_160MHZ_SUBCHANNEL)) return NOT_ALLOWED; } else if (is_6ghz_op_class(op_class) && (!(wpas_get_6ghz_he_chwidth_capab(mode) &