developer | c1498a3 | 2022-06-07 16:14:30 +0800 | [diff] [blame^] | 1 | From 18111f0a47b33da2f75cebd65f9201150bc3a1a9 Mon Sep 17 00:00:00 2001 |
| 2 | From: dzou <dzou@company.com> |
| 3 | Date: Sun, 5 Jun 2022 23:18:45 +0800 |
| 4 | Subject: [PATCH 903/911] DFS: Rely on channel_type in |
| 5 | dfs_downgrade_bandwidth() |
| 6 | |
| 7 | Add the capability to specify all 3 channel type possibilities in |
| 8 | dfs_downgrade_bandwidth(). This is a preliminary change to introduce |
| 9 | radar/CAC background detection support. |
| 10 | |
| 11 | Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> |
| 12 | --- |
| 13 | src/ap/dfs.c | 32 +++++++++++++++----------------- |
| 14 | 1 file changed, 15 insertions(+), 17 deletions(-) |
| 15 | |
| 16 | diff --git a/src/ap/dfs.c b/src/ap/dfs.c |
| 17 | index 56564b901..05cb63ac4 100644 |
| 18 | --- a/src/ap/dfs.c |
| 19 | +++ b/src/ap/dfs.c |
| 20 | @@ -987,7 +987,8 @@ int hostapd_dfs_pre_cac_expired(struct hostapd_iface *iface, int freq, |
| 21 | static struct hostapd_channel_data * |
| 22 | dfs_downgrade_bandwidth(struct hostapd_iface *iface, int *secondary_channel, |
| 23 | u8 *oper_centr_freq_seg0_idx, |
| 24 | - u8 *oper_centr_freq_seg1_idx, int *skip_radar) |
| 25 | + u8 *oper_centr_freq_seg1_idx, |
| 26 | + enum dfs_channel_type *channel_type) |
| 27 | { |
| 28 | struct hostapd_channel_data *channel; |
| 29 | |
| 30 | @@ -995,23 +996,22 @@ dfs_downgrade_bandwidth(struct hostapd_iface *iface, int *secondary_channel, |
| 31 | channel = dfs_get_valid_channel(iface, secondary_channel, |
| 32 | oper_centr_freq_seg0_idx, |
| 33 | oper_centr_freq_seg1_idx, |
| 34 | - *skip_radar ? DFS_AVAILABLE : |
| 35 | - DFS_ANY_CHANNEL); |
| 36 | + *channel_type); |
| 37 | if (channel) { |
| 38 | wpa_printf(MSG_DEBUG, "DFS: Selected channel: %d", |
| 39 | channel->chan); |
| 40 | return channel; |
| 41 | } |
| 42 | |
| 43 | - if (*skip_radar) { |
| 44 | - *skip_radar = 0; |
| 45 | + if (*channel_type != DFS_ANY_CHANNEL) { |
| 46 | + *channel_type = DFS_ANY_CHANNEL; |
| 47 | } else { |
| 48 | int oper_chwidth; |
| 49 | |
| 50 | oper_chwidth = hostapd_get_oper_chwidth(iface->conf); |
| 51 | if (oper_chwidth == CHANWIDTH_USE_HT) |
| 52 | break; |
| 53 | - *skip_radar = 1; |
| 54 | + *channel_type = DFS_AVAILABLE; |
| 55 | hostapd_set_oper_chwidth(iface->conf, oper_chwidth - 1); |
| 56 | } |
| 57 | } |
| 58 | @@ -1029,7 +1029,7 @@ static int hostapd_dfs_start_channel_switch_cac(struct hostapd_iface *iface) |
| 59 | int secondary_channel; |
| 60 | u8 oper_centr_freq_seg0_idx = 0; |
| 61 | u8 oper_centr_freq_seg1_idx = 0; |
| 62 | - int skip_radar = 0; |
| 63 | + enum dfs_channel_type channel_type = DFS_ANY_CHANNEL; |
| 64 | int err = 1; |
| 65 | |
| 66 | /* Radar detected during active CAC */ |
| 67 | @@ -1037,14 +1037,13 @@ static int hostapd_dfs_start_channel_switch_cac(struct hostapd_iface *iface) |
| 68 | channel = dfs_get_valid_channel(iface, &secondary_channel, |
| 69 | &oper_centr_freq_seg0_idx, |
| 70 | &oper_centr_freq_seg1_idx, |
| 71 | - skip_radar ? DFS_AVAILABLE : |
| 72 | - DFS_ANY_CHANNEL); |
| 73 | + channel_type); |
| 74 | |
| 75 | if (!channel) { |
| 76 | channel = dfs_downgrade_bandwidth(iface, &secondary_channel, |
| 77 | &oper_centr_freq_seg0_idx, |
| 78 | &oper_centr_freq_seg1_idx, |
| 79 | - &skip_radar); |
| 80 | + &channel_type); |
| 81 | if (!channel) { |
| 82 | wpa_printf(MSG_ERROR, "No valid channel available"); |
| 83 | return err; |
| 84 | @@ -1078,7 +1077,7 @@ static int hostapd_dfs_start_channel_switch(struct hostapd_iface *iface) |
| 85 | u8 oper_centr_freq_seg0_idx; |
| 86 | u8 oper_centr_freq_seg1_idx; |
| 87 | u8 new_vht_oper_chwidth; |
| 88 | - int skip_radar = 1; |
| 89 | + enum dfs_channel_type channel_type = DFS_AVAILABLE; |
| 90 | struct csa_settings csa_settings; |
| 91 | unsigned int i; |
| 92 | int err = 1; |
| 93 | @@ -1103,14 +1102,13 @@ static int hostapd_dfs_start_channel_switch(struct hostapd_iface *iface) |
| 94 | * uniform spreading. |
| 95 | */ |
| 96 | if (iface->dfs_domain == HOSTAPD_DFS_REGION_ETSI) |
| 97 | - skip_radar = 0; |
| 98 | + channel_type = DFS_ANY_CHANNEL; |
| 99 | |
| 100 | /* Perform channel switch/CSA */ |
| 101 | channel = dfs_get_valid_channel(iface, &secondary_channel, |
| 102 | &oper_centr_freq_seg0_idx, |
| 103 | &oper_centr_freq_seg1_idx, |
| 104 | - skip_radar ? DFS_AVAILABLE : |
| 105 | - DFS_ANY_CHANNEL); |
| 106 | + channel_type); |
| 107 | |
| 108 | if (!channel) { |
| 109 | /* |
| 110 | @@ -1118,11 +1116,11 @@ static int hostapd_dfs_start_channel_switch(struct hostapd_iface *iface) |
| 111 | * there is another channel where we can switch even if it |
| 112 | * requires to perform a CAC first. |
| 113 | */ |
| 114 | - skip_radar = 0; |
| 115 | + channel_type = DFS_ANY_CHANNEL; |
| 116 | channel = dfs_downgrade_bandwidth(iface, &secondary_channel, |
| 117 | &oper_centr_freq_seg0_idx, |
| 118 | &oper_centr_freq_seg1_idx, |
| 119 | - &skip_radar); |
| 120 | + &channel_type); |
| 121 | if (!channel) { |
| 122 | /* |
| 123 | * Toggle interface state to enter DFS state |
| 124 | @@ -1133,7 +1131,7 @@ static int hostapd_dfs_start_channel_switch(struct hostapd_iface *iface) |
| 125 | return 0; |
| 126 | } |
| 127 | |
| 128 | - if (!skip_radar) { |
| 129 | + if (channel_type == DFS_ANY_CHANNEL) { |
| 130 | iface->freq = channel->freq; |
| 131 | iface->conf->channel = channel->chan; |
| 132 | iface->conf->secondary_channel = secondary_channel; |
| 133 | -- |
| 134 | 2.29.2 |
| 135 | |