6bc48abfb9508ebc444ee318df8f239529f0f428
[openwrt/staging/blogic.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 | 25 +++++++++++++++++++------
13 1 file changed, 19 insertions(+), 6 deletions(-)
14
15 --- a/wpa_supplicant/wpa_supplicant.c
16 +++ b/wpa_supplicant/wpa_supplicant.c
17 @@ -2436,7 +2436,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 @@ -2445,7 +2445,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 @@ -2474,6 +2477,8 @@ void ibss_mesh_setup_freq(struct wpa_sup
39 int chwidth, seg0, seg1;
40 u32 vht_caps = 0;
41 bool is_24ghz, is_6ghz;
42 + bool dfs_enabled = wpa_s->conf->country[0] &&
43 + (wpa_s->drv_flags & WPA_DRIVER_FLAGS_RADAR);
44
45 freq->freq = ssid->frequency;
46
47 @@ -2570,8 +2575,11 @@ void ibss_mesh_setup_freq(struct wpa_sup
48 return;
49
50 /* Check primary channel flags */
51 - if (pri_chan->flag & (HOSTAPD_CHAN_DISABLED | HOSTAPD_CHAN_NO_IR))
52 + if (pri_chan->flag & HOSTAPD_CHAN_DISABLED)
53 return;
54 + if (pri_chan->flag & (HOSTAPD_CHAN_RADAR | HOSTAPD_CHAN_NO_IR))
55 + if (!dfs_enabled)
56 + return;
57
58 freq->channel = pri_chan->chan;
59
60 @@ -2604,8 +2612,11 @@ void ibss_mesh_setup_freq(struct wpa_sup
61 return;
62
63 /* Check secondary channel flags */
64 - if (sec_chan->flag & (HOSTAPD_CHAN_DISABLED | HOSTAPD_CHAN_NO_IR))
65 + if (sec_chan->flag & HOSTAPD_CHAN_DISABLED)
66 return;
67 + if (sec_chan->flag & (HOSTAPD_CHAN_RADAR | HOSTAPD_CHAN_NO_IR))
68 + if (!dfs_enabled)
69 + return;
70
71 if (ht40 == -1) {
72 if (!(pri_chan->flag & HOSTAPD_CHAN_HT40MINUS))
73 @@ -2694,7 +2705,7 @@ skip_to_6ghz:
74 return;
75
76 /* Back to HT configuration if channel not usable */
77 - if (!ibss_mesh_is_80mhz_avail(channel, mode))
78 + if (!ibss_mesh_is_80mhz_avail(channel, mode, dfs_enabled))
79 return;
80
81 chwidth = CONF_OPER_CHWIDTH_80MHZ;
82 @@ -2708,7 +2719,7 @@ skip_to_6ghz:
83 * above; check the remaining four 20 MHz channels for the total
84 * of 160 MHz bandwidth.
85 */
86 - if (!ibss_mesh_is_80mhz_avail(channel + 16, mode))
87 + if (!ibss_mesh_is_80mhz_avail(channel + 16, mode, dfs_enabled))
88 return;
89
90 for (j = 0; j < ARRAY_SIZE(bw160); j++) {
91 @@ -2738,10 +2749,12 @@ skip_to_6ghz:
92 if (!chan)
93 continue;
94
95 - if (chan->flag & (HOSTAPD_CHAN_DISABLED |
96 - HOSTAPD_CHAN_NO_IR |
97 - HOSTAPD_CHAN_RADAR))
98 + if (chan->flag & HOSTAPD_CHAN_DISABLED)
99 continue;
100 + if (chan->flag & (HOSTAPD_CHAN_RADAR |
101 + HOSTAPD_CHAN_NO_IR))
102 + if (!dfs_enabled)
103 + continue;
104
105 /* Found a suitable second segment for 80+80 */
106 chwidth = CONF_OPER_CHWIDTH_80P80MHZ;