cbb91ddeabfdabb4db7b00d050006bf619c6a3ab
[openwrt/staging/linusw.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 @@ -2809,7 +2809,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 @@ -2818,7 +2818,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 @@ -2945,7 +2948,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) {
43 + int obss_scan, bool dfs_enabled) {
44 int chan_idx;
45 struct hostapd_channel_data *pri_chan = NULL, *sec_chan = NULL;
46 int i, res;
47 @@ -2969,8 +2972,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 + 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 #ifdef CONFIG_HT_OVERRIDES
59 if (ssid->disable_ht40)
60 @@ -2996,8 +3002,11 @@ static void ibss_mesh_select_40mhz(struc
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 @@ -3052,7 +3061,7 @@ static bool ibss_mesh_select_80_160mhz(s
74 const struct wpa_ssid *ssid,
75 struct hostapd_hw_modes *mode,
76 struct hostapd_freq_params *freq,
77 - int ieee80211_mode, bool is_6ghz) {
78 + int ieee80211_mode, bool is_6ghz, bool dfs_enabled) {
79 static const int bw80[] = {
80 5180, 5260, 5500, 5580, 5660, 5745, 5825,
81 5955, 6035, 6115, 6195, 6275, 6355, 6435,
82 @@ -3097,7 +3106,7 @@ static bool ibss_mesh_select_80_160mhz(s
83 goto skip_80mhz;
84
85 /* Use 40 MHz if channel not usable */
86 - if (!ibss_mesh_is_80mhz_avail(channel, mode))
87 + if (!ibss_mesh_is_80mhz_avail(channel, mode, dfs_enabled))
88 goto skip_80mhz;
89
90 chwidth = CONF_OPER_CHWIDTH_80MHZ;
91 @@ -3111,7 +3120,7 @@ static bool ibss_mesh_select_80_160mhz(s
92 if ((mode->he_capab[ieee80211_mode].phy_cap[
93 HE_PHYCAP_CHANNEL_WIDTH_SET_IDX] &
94 HE_PHYCAP_CHANNEL_WIDTH_SET_160MHZ_IN_5G) && is_6ghz &&
95 - ibss_mesh_is_80mhz_avail(channel + 16, mode)) {
96 + ibss_mesh_is_80mhz_avail(channel + 16, mode, dfs_enabled)) {
97 for (j = 0; j < ARRAY_SIZE(bw160); j++) {
98 if (freq->freq == bw160[j]) {
99 chwidth = CONF_OPER_CHWIDTH_160MHZ;
100 @@ -3139,10 +3148,12 @@ static bool ibss_mesh_select_80_160mhz(s
101 if (!chan)
102 continue;
103
104 - if (chan->flag & (HOSTAPD_CHAN_DISABLED |
105 - HOSTAPD_CHAN_NO_IR |
106 - HOSTAPD_CHAN_RADAR))
107 + if (chan->flag & HOSTAPD_CHAN_DISABLED)
108 continue;
109 + if (chan->flag & (HOSTAPD_CHAN_RADAR |
110 + HOSTAPD_CHAN_NO_IR))
111 + if (!dfs_enabled)
112 + continue;
113
114 /* Found a suitable second segment for 80+80 */
115 chwidth = CONF_OPER_CHWIDTH_80P80MHZ;
116 @@ -3197,6 +3208,7 @@ void ibss_mesh_setup_freq(struct wpa_sup
117 int obss_scan = 1;
118 u8 channel;
119 bool is_6ghz, is_24ghz;
120 + bool dfs_enabled = wpa_s->conf->country[0] && (wpa_s->drv_flags & WPA_DRIVER_FLAGS_RADAR);
121
122 freq->freq = ssid->frequency;
123
124 @@ -3239,9 +3251,9 @@ void ibss_mesh_setup_freq(struct wpa_sup
125 freq->channel = channel;
126 /* Setup higher BW only for 5 GHz */
127 if (mode->mode == HOSTAPD_MODE_IEEE80211A) {
128 - ibss_mesh_select_40mhz(wpa_s, ssid, mode, freq, obss_scan);
129 + ibss_mesh_select_40mhz(wpa_s, ssid, mode, freq, obss_scan, dfs_enabled);
130 if (!ibss_mesh_select_80_160mhz(wpa_s, ssid, mode, freq,
131 - ieee80211_mode, is_6ghz))
132 + ieee80211_mode, is_6ghz, dfs_enabled))
133 freq->he_enabled = freq->vht_enabled = false;
134 }
135