aba2ff08bc29606e7d2306d71280ce8281d2544e
[openwrt/staging/thess.git] /
1 From 8de8cd8380af0c43d4fde67a668d79ef73b26b26 Mon Sep 17 00:00:00 2001
2 From: Peter Oh <peter.oh@bowerswilkins.com>
3 Date: Tue, 30 Jun 2020 14:18:58 +0200
4 Subject: [PATCH 10/19] mesh: Allow DFS channels to be selected if dfs is
5 enabled
6
7 Note: DFS is assumed to be usable if a country code has been set
8
9 Signed-off-by: Benjamin Berg <benjamin@sipsolutions.net>
10 Signed-off-by: Peter Oh <peter.oh@bowerswilkins.com>
11 ---
12 wpa_supplicant/wpa_supplicant.c | 38 ++++++++++++++++++++++-----------
13 1 file changed, 25 insertions(+), 13 deletions(-)
14
15 --- a/wpa_supplicant/wpa_supplicant.c
16 +++ b/wpa_supplicant/wpa_supplicant.c
17 @@ -2974,7 +2974,7 @@ static int drv_supports_vht(struct wpa_s
18 }
19
20
21 -static bool ibss_mesh_is_80mhz_avail(int channel, struct hostapd_hw_modes *mode)
22 +static bool ibss_mesh_is_80mhz_avail(int channel, struct hostapd_hw_modes *mode, bool dfs_enabled)
23 {
24 int i;
25
26 @@ -2983,7 +2983,10 @@ static bool ibss_mesh_is_80mhz_avail(int
27
28 chan = hw_get_channel_chan(mode, i, NULL);
29 if (!chan ||
30 - chan->flag & (HOSTAPD_CHAN_DISABLED | HOSTAPD_CHAN_NO_IR))
31 + chan->flag & HOSTAPD_CHAN_DISABLED)
32 + return false;
33 +
34 + if (!dfs_enabled && chan->flag & (HOSTAPD_CHAN_RADAR | HOSTAPD_CHAN_NO_IR))
35 return false;
36 }
37
38 @@ -3110,7 +3113,7 @@ static void ibss_mesh_select_40mhz(struc
39 const struct wpa_ssid *ssid,
40 struct hostapd_hw_modes *mode,
41 struct hostapd_freq_params *freq,
42 - int obss_scan, bool is_6ghz)
43 + int obss_scan, bool is_6ghz, bool dfs_enabled)
44 {
45 int chan_idx;
46 struct hostapd_channel_data *pri_chan = NULL, *sec_chan = NULL;
47 @@ -3141,8 +3144,11 @@ static void ibss_mesh_select_40mhz(struc
48 return;
49
50 /* Check primary channel flags */
51 - if (pri_chan->flag & (HOSTAPD_CHAN_DISABLED | HOSTAPD_CHAN_NO_IR))
52 - return;
53 + if (pri_chan->flag & HOSTAPD_CHAN_DISABLED)
54 + return;
55 + if (pri_chan->flag & (HOSTAPD_CHAN_RADAR | HOSTAPD_CHAN_NO_IR))
56 + if (!dfs_enabled)
57 + return;
58
59 #ifdef CONFIG_HT_OVERRIDES
60 if (ssid->disable_ht40)
61 @@ -3177,8 +3183,11 @@ static void ibss_mesh_select_40mhz(struc
62 return;
63
64 /* Check secondary channel flags */
65 - if (sec_chan->flag & (HOSTAPD_CHAN_DISABLED | HOSTAPD_CHAN_NO_IR))
66 - return;
67 + if (sec_chan->flag & HOSTAPD_CHAN_DISABLED)
68 + return;
69 + if (sec_chan->flag & (HOSTAPD_CHAN_RADAR | HOSTAPD_CHAN_NO_IR))
70 + if (!dfs_enabled)
71 + return;
72
73 if (freq->ht_enabled) {
74 if (ht40 == -1) {
75 @@ -3256,7 +3265,7 @@ static bool ibss_mesh_select_80_160mhz(s
76 const struct wpa_ssid *ssid,
77 struct hostapd_hw_modes *mode,
78 struct hostapd_freq_params *freq,
79 - int ieee80211_mode, bool is_6ghz) {
80 + int ieee80211_mode, bool is_6ghz, bool dfs_enabled) {
81 static const int bw80[] = {
82 5180, 5260, 5500, 5580, 5660, 5745, 5825,
83 5955, 6035, 6115, 6195, 6275, 6355, 6435,
84 @@ -3309,7 +3318,7 @@ static bool ibss_mesh_select_80_160mhz(s
85 goto skip_80mhz;
86
87 /* Use 40 MHz if channel not usable */
88 - if (!ibss_mesh_is_80mhz_avail(channel, mode))
89 + if (!ibss_mesh_is_80mhz_avail(channel, mode, dfs_enabled))
90 goto skip_80mhz;
91
92 chwidth = CONF_OPER_CHWIDTH_80MHZ;
93 @@ -3351,7 +3360,7 @@ static bool ibss_mesh_select_80_160mhz(s
94 HE_PHYCAP_CHANNEL_WIDTH_SET_160MHZ_IN_5G) &&
95 (ssid->max_oper_chwidth == CONF_OPER_CHWIDTH_160MHZ ||
96 ssid->max_oper_chwidth == CONF_OPER_CHWIDTH_320MHZ) &&
97 - ibss_mesh_is_80mhz_avail(channel + 16 * offset_in_160, mode)) {
98 + ibss_mesh_is_80mhz_avail(channel + 16 * offset_in_160, mode, dfs_enabled)) {
99 for (j = 0; j < ARRAY_SIZE(bw160); j++) {
100 u8 start_chan;
101
102 @@ -3374,11 +3383,11 @@ static bool ibss_mesh_select_80_160mhz(s
103 EHT_PHYCAP_320MHZ_IN_6GHZ_SUPPORT_MASK) && is_6ghz &&
104 ssid->max_oper_chwidth == CONF_OPER_CHWIDTH_320MHZ &&
105 ibss_mesh_is_80mhz_avail(channel + 16 -
106 - 64 * ((offset_in_320 + 1) / 4), mode) &&
107 + 64 * ((offset_in_320 + 1) / 4), mode, dfs_enabled) &&
108 ibss_mesh_is_80mhz_avail(channel + 32 -
109 - 64 * ((offset_in_320 + 2) / 4), mode) &&
110 + 64 * ((offset_in_320 + 2) / 4), mode, dfs_enabled) &&
111 ibss_mesh_is_80mhz_avail(channel + 48 -
112 - 64 * ((offset_in_320 + 3) / 4), mode)) {
113 + 64 * ((offset_in_320 + 3) / 4), mode, dfs_enabled)) {
114 for (j = 0; j < ARRAY_SIZE(bw320); j += 2) {
115 if (freq->freq >= bw320[j] &&
116 freq->freq <= bw320[j + 1]) {
117 @@ -3407,10 +3416,12 @@ static bool ibss_mesh_select_80_160mhz(s
118 if (!chan)
119 continue;
120
121 - if (chan->flag & (HOSTAPD_CHAN_DISABLED |
122 - HOSTAPD_CHAN_NO_IR |
123 - HOSTAPD_CHAN_RADAR))
124 - continue;
125 + if (chan->flag & HOSTAPD_CHAN_DISABLED)
126 + continue;
127 + if (chan->flag & (HOSTAPD_CHAN_RADAR |
128 + HOSTAPD_CHAN_NO_IR))
129 + if (!dfs_enabled)
130 + continue;
131
132 /* Found a suitable second segment for 80+80 */
133 chwidth = CONF_OPER_CHWIDTH_80P80MHZ;
134 @@ -3465,6 +3476,7 @@ void ibss_mesh_setup_freq(struct wpa_sup
135 int obss_scan = 1;
136 u8 channel;
137 bool is_6ghz, is_24ghz;
138 + bool dfs_enabled = wpa_s->conf->country[0] && (wpa_s->drv_flags & WPA_DRIVER_FLAGS_RADAR);
139
140 freq->freq = ssid->frequency;
141
142 @@ -3508,9 +3520,9 @@ void ibss_mesh_setup_freq(struct wpa_sup
143 /* Setup higher BW only for 5 and 6 GHz */
144 if (mode->mode == HOSTAPD_MODE_IEEE80211A) {
145 ibss_mesh_select_40mhz(wpa_s, ssid, mode, freq, obss_scan,
146 - is_6ghz);
147 + is_6ghz, dfs_enabled);
148 if (!ibss_mesh_select_80_160mhz(wpa_s, ssid, mode, freq,
149 - ieee80211_mode, is_6ghz))
150 + ieee80211_mode, is_6ghz, dfs_enabled))
151 freq->he_enabled = freq->vht_enabled = false;
152 }
153