developer | f2e3f56 | 2022-12-26 19:41:22 +0800 | [diff] [blame] | 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 |
developer | 9a58788 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 17 | @@ -2638,7 +2638,7 @@ static int drv_supports_vht(struct wpa_s |
developer | f2e3f56 | 2022-12-26 19:41:22 +0800 | [diff] [blame] | 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 | |
developer | 9a58788 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 26 | @@ -2647,7 +2647,10 @@ static bool ibss_mesh_is_80mhz_avail(int |
developer | f2e3f56 | 2022-12-26 19:41:22 +0800 | [diff] [blame] | 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 | |
developer | 9a58788 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 38 | @@ -2774,7 +2777,7 @@ static void ibss_mesh_select_40mhz(struc |
developer | 5e0a8d7 | 2023-05-12 18:58:17 +0800 | [diff] [blame] | 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; |
developer | 9a58788 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 47 | @@ -2798,8 +2801,11 @@ static void ibss_mesh_select_40mhz(struc |
developer | f2e3f56 | 2022-12-26 19:41:22 +0800 | [diff] [blame] | 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 | |
developer | 5e0a8d7 | 2023-05-12 18:58:17 +0800 | [diff] [blame] | 58 | #ifdef CONFIG_HT_OVERRIDES |
| 59 | if (ssid->disable_ht40) |
developer | 9a58788 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 60 | @@ -2825,8 +2831,11 @@ static void ibss_mesh_select_40mhz(struc |
developer | f2e3f56 | 2022-12-26 19:41:22 +0800 | [diff] [blame] | 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)) |
developer | 9a58788 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 73 | @@ -2880,7 +2889,7 @@ static bool ibss_mesh_select_80_160mhz(s |
developer | 5e0a8d7 | 2023-05-12 18:58:17 +0800 | [diff] [blame] | 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, |
developer | 9a58788 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 82 | @@ -2925,7 +2934,7 @@ static bool ibss_mesh_select_80_160mhz(s |
developer | 5e0a8d7 | 2023-05-12 18:58:17 +0800 | [diff] [blame] | 83 | goto skip_80mhz; |
developer | f2e3f56 | 2022-12-26 19:41:22 +0800 | [diff] [blame] | 84 | |
developer | 5e0a8d7 | 2023-05-12 18:58:17 +0800 | [diff] [blame] | 85 | /* Use 40 MHz if channel not usable */ |
developer | f2e3f56 | 2022-12-26 19:41:22 +0800 | [diff] [blame] | 86 | - if (!ibss_mesh_is_80mhz_avail(channel, mode)) |
| 87 | + if (!ibss_mesh_is_80mhz_avail(channel, mode, dfs_enabled)) |
developer | 5e0a8d7 | 2023-05-12 18:58:17 +0800 | [diff] [blame] | 88 | goto skip_80mhz; |
developer | f2e3f56 | 2022-12-26 19:41:22 +0800 | [diff] [blame] | 89 | |
| 90 | chwidth = CONF_OPER_CHWIDTH_80MHZ; |
developer | 9a58788 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 91 | @@ -2939,7 +2948,7 @@ static bool ibss_mesh_select_80_160mhz(s |
developer | 5e0a8d7 | 2023-05-12 18:58:17 +0800 | [diff] [blame] | 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)) { |
developer | f2e3f56 | 2022-12-26 19:41:22 +0800 | [diff] [blame] | 97 | for (j = 0; j < ARRAY_SIZE(bw160); j++) { |
developer | 5e0a8d7 | 2023-05-12 18:58:17 +0800 | [diff] [blame] | 98 | if (freq->freq == bw160[j]) { |
| 99 | chwidth = CONF_OPER_CHWIDTH_160MHZ; |
developer | 9a58788 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 100 | @@ -2967,10 +2976,12 @@ static bool ibss_mesh_select_80_160mhz(s |
developer | f2e3f56 | 2022-12-26 19:41:22 +0800 | [diff] [blame] | 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; |
developer | 9a58788 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 116 | @@ -3025,6 +3036,7 @@ void ibss_mesh_setup_freq(struct wpa_sup |
developer | 5e0a8d7 | 2023-05-12 18:58:17 +0800 | [diff] [blame] | 117 | 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 | |
developer | 9a58788 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 124 | @@ -3070,9 +3082,9 @@ void ibss_mesh_setup_freq(struct wpa_sup |
developer | 5e0a8d7 | 2023-05-12 18:58:17 +0800 | [diff] [blame] | 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 | |