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
7 Note: DFS is assumed to be usable if a country code has been set
9 Signed-off-by: Benjamin Berg <benjamin@sipsolutions.net>
10 Signed-off-by: Peter Oh <peter.oh@bowerswilkins.com>
12 wpa_supplicant/wpa_supplicant.c | 25 +++++++++++++++++++------
13 1 file changed, 19 insertions(+), 6 deletions(-)
15 --- a/wpa_supplicant/wpa_supplicant.c
16 +++ b/wpa_supplicant/wpa_supplicant.c
17 @@ -2621,7 +2621,7 @@ static int drv_supports_vht(struct wpa_s
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)
26 @@ -2630,7 +2630,10 @@ static bool ibss_mesh_is_80mhz_avail(int
28 chan = hw_get_channel_chan(mode, i, NULL);
30 - chan->flag & (HOSTAPD_CHAN_DISABLED | HOSTAPD_CHAN_NO_IR))
31 + chan->flag & HOSTAPD_CHAN_DISABLED)
34 + if (!dfs_enabled && chan->flag & (HOSTAPD_CHAN_RADAR | HOSTAPD_CHAN_NO_IR))
38 @@ -2757,7 +2760,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,
43 + int obss_scan, bool dfs_enabled) {
45 struct hostapd_channel_data *pri_chan = NULL, *sec_chan = NULL;
47 @@ -2781,8 +2784,11 @@ static void ibss_mesh_select_40mhz(struc
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)
54 + if (pri_chan->flag & (HOSTAPD_CHAN_RADAR | HOSTAPD_CHAN_NO_IR))
58 #ifdef CONFIG_HT_OVERRIDES
59 if (ssid->disable_ht40)
60 @@ -2808,8 +2814,11 @@ static void ibss_mesh_select_40mhz(struc
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)
67 + if (sec_chan->flag & (HOSTAPD_CHAN_RADAR | HOSTAPD_CHAN_NO_IR))
72 if (!(pri_chan->flag & HOSTAPD_CHAN_HT40MINUS))
73 @@ -2863,7 +2872,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 @@ -2908,7 +2917,7 @@ static bool ibss_mesh_select_80_160mhz(s
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))
90 chwidth = CONF_OPER_CHWIDTH_80MHZ;
91 @@ -2922,7 +2931,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 @@ -2950,10 +2959,12 @@ static bool ibss_mesh_select_80_160mhz(s
104 - if (chan->flag & (HOSTAPD_CHAN_DISABLED |
105 - HOSTAPD_CHAN_NO_IR |
106 - HOSTAPD_CHAN_RADAR))
107 + if (chan->flag & HOSTAPD_CHAN_DISABLED)
109 + if (chan->flag & (HOSTAPD_CHAN_RADAR |
110 + HOSTAPD_CHAN_NO_IR))
114 /* Found a suitable second segment for 80+80 */
115 chwidth = CONF_OPER_CHWIDTH_80P80MHZ;
116 @@ -3008,6 +3019,7 @@ void ibss_mesh_setup_freq(struct wpa_sup
117 int i, obss_scan = 1;
120 + bool dfs_enabled = wpa_s->conf->country[0] && (wpa_s->drv_flags & WPA_DRIVER_FLAGS_RADAR);
122 freq->freq = ssid->frequency;
124 @@ -3053,9 +3065,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;