blob: 6bc48abfb9508ebc444ee318df8f239529f0f428 [file] [log] [blame]
developerfaf1ea22022-04-29 17:53:25 +08001From 8de8cd8380af0c43d4fde67a668d79ef73b26b26 Mon Sep 17 00:00:00 2001
2From: Peter Oh <peter.oh@bowerswilkins.com>
3Date: Tue, 30 Jun 2020 14:18:58 +0200
4Subject: [PATCH 10/19] mesh: Allow DFS channels to be selected if dfs is
5 enabled
6
7Note: DFS is assumed to be usable if a country code has been set
8
9Signed-off-by: Benjamin Berg <benjamin@sipsolutions.net>
10Signed-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
developer842205d2022-09-22 17:12:54 +080017@@ -2436,7 +2436,7 @@ static int drv_supports_vht(struct wpa_s
developerfaf1ea22022-04-29 17:53:25 +080018 }
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
developer842205d2022-09-22 17:12:54 +080026@@ -2445,7 +2445,10 @@ static bool ibss_mesh_is_80mhz_avail(int
developerfaf1ea22022-04-29 17:53:25 +080027
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
developer842205d2022-09-22 17:12:54 +080038@@ -2474,6 +2477,8 @@ void ibss_mesh_setup_freq(struct wpa_sup
developerfaf1ea22022-04-29 17:53:25 +080039 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
developer842205d2022-09-22 17:12:54 +080047@@ -2570,8 +2575,11 @@ void ibss_mesh_setup_freq(struct wpa_sup
developerfaf1ea22022-04-29 17:53:25 +080048 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
developer842205d2022-09-22 17:12:54 +080060@@ -2604,8 +2612,11 @@ void ibss_mesh_setup_freq(struct wpa_sup
developerfaf1ea22022-04-29 17:53:25 +080061 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))
developer842205d2022-09-22 17:12:54 +080073@@ -2694,7 +2705,7 @@ skip_to_6ghz:
developerfaf1ea22022-04-29 17:53:25 +080074 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
developer842205d2022-09-22 17:12:54 +080081 chwidth = CONF_OPER_CHWIDTH_80MHZ;
82@@ -2708,7 +2719,7 @@ skip_to_6ghz:
developerfaf1ea22022-04-29 17:53:25 +080083 * 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++) {
developer842205d2022-09-22 17:12:54 +080091@@ -2738,10 +2749,12 @@ skip_to_6ghz:
developerfaf1ea22022-04-29 17:53:25 +080092 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 */
developer842205d2022-09-22 17:12:54 +0800106 chwidth = CONF_OPER_CHWIDTH_80P80MHZ;