blob: 0a51c84d2158b277b52a6a1db2431a6bc089db1c [file] [log] [blame]
developer29c4d2d2022-12-26 19:41:22 +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
developer8bff6472023-07-17 11:11:44 +080017@@ -2638,7 +2638,7 @@ static int drv_supports_vht(struct wpa_s
developer29c4d2d2022-12-26 19:41:22 +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
developer8bff6472023-07-17 11:11:44 +080026@@ -2647,7 +2647,10 @@ static bool ibss_mesh_is_80mhz_avail(int
developer29c4d2d2022-12-26 19:41:22 +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
developer8bff6472023-07-17 11:11:44 +080038@@ -2774,7 +2777,7 @@ static void ibss_mesh_select_40mhz(struc
developer505c9432023-05-12 18:58:17 +080039 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;
developer8bff6472023-07-17 11:11:44 +080047@@ -2798,8 +2801,11 @@ static void ibss_mesh_select_40mhz(struc
developer29c4d2d2022-12-26 19:41:22 +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
developer505c9432023-05-12 18:58:17 +080058 #ifdef CONFIG_HT_OVERRIDES
59 if (ssid->disable_ht40)
developer8bff6472023-07-17 11:11:44 +080060@@ -2825,8 +2831,11 @@ static void ibss_mesh_select_40mhz(struc
developer29c4d2d2022-12-26 19:41:22 +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))
developer8bff6472023-07-17 11:11:44 +080073@@ -2880,7 +2889,7 @@ static bool ibss_mesh_select_80_160mhz(s
developer505c9432023-05-12 18:58:17 +080074 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,
developer8bff6472023-07-17 11:11:44 +080082@@ -2925,7 +2934,7 @@ static bool ibss_mesh_select_80_160mhz(s
developer505c9432023-05-12 18:58:17 +080083 goto skip_80mhz;
developer29c4d2d2022-12-26 19:41:22 +080084
developer505c9432023-05-12 18:58:17 +080085 /* Use 40 MHz if channel not usable */
developer29c4d2d2022-12-26 19:41:22 +080086- if (!ibss_mesh_is_80mhz_avail(channel, mode))
87+ if (!ibss_mesh_is_80mhz_avail(channel, mode, dfs_enabled))
developer505c9432023-05-12 18:58:17 +080088 goto skip_80mhz;
developer29c4d2d2022-12-26 19:41:22 +080089
90 chwidth = CONF_OPER_CHWIDTH_80MHZ;
developer8bff6472023-07-17 11:11:44 +080091@@ -2939,7 +2948,7 @@ static bool ibss_mesh_select_80_160mhz(s
developer505c9432023-05-12 18:58:17 +080092 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)) {
developer29c4d2d2022-12-26 19:41:22 +080097 for (j = 0; j < ARRAY_SIZE(bw160); j++) {
developer505c9432023-05-12 18:58:17 +080098 if (freq->freq == bw160[j]) {
99 chwidth = CONF_OPER_CHWIDTH_160MHZ;
developer8bff6472023-07-17 11:11:44 +0800100@@ -2967,10 +2976,12 @@ static bool ibss_mesh_select_80_160mhz(s
developer29c4d2d2022-12-26 19:41:22 +0800101 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;
developer8bff6472023-07-17 11:11:44 +0800116@@ -3025,6 +3036,7 @@ void ibss_mesh_setup_freq(struct wpa_sup
developer505c9432023-05-12 18:58:17 +0800117 int i, obss_scan = 1;
118 u8 channel;
119 bool is_6ghz;
120+ bool dfs_enabled = wpa_s->conf->country[0] && (wpa_s->drv_flags & WPA_DRIVER_FLAGS_RADAR);
121
122 freq->freq = ssid->frequency;
123
developer8bff6472023-07-17 11:11:44 +0800124@@ -3070,9 +3082,9 @@ void ibss_mesh_setup_freq(struct wpa_sup
developer505c9432023-05-12 18:58:17 +0800125 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