blob: 5edd2d11bb36662b5bd8299c00daf42cff2ffef9 [file] [log] [blame]
developerc1498a32022-06-07 16:14:30 +08001From 3ebfdca86d2d4e45d8c72239819086e244cbd4f2 Mon Sep 17 00:00:00 2001
2From: Lorenzo Bianconi <lorenzo@kernel.org>
3Date: Mon, 20 Dec 2021 16:48:17 +0100
4Subject: [PATCH 900/911] DFS: Introduce dfs_set_valid_channel() utility
5 routine
6
7This is a preliminary change to introduce radar/CAC background detection
8support.
9
10Tested-by: Owen Peng <owen.peng@mediatek.com>
11Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
12---
13 src/ap/dfs.c | 38 ++++++++++++++++++++++++--------------
14 1 file changed, 24 insertions(+), 14 deletions(-)
15
16diff --git a/src/ap/dfs.c b/src/ap/dfs.c
17index 53a50653b..09b2bb7d4 100644
18--- a/src/ap/dfs.c
19+++ b/src/ap/dfs.c
20@@ -586,6 +586,29 @@ dfs_get_valid_channel(struct hostapd_iface *iface,
21 }
22
23
24+static int dfs_set_valid_channel(struct hostapd_iface *iface, int skip_radar)
25+{
26+ struct hostapd_channel_data *channel;
27+ u8 cf1 = 0, cf2 = 0;
28+ int sec = 0;
29+
30+ channel = dfs_get_valid_channel(iface, &sec, &cf1, &cf2,
31+ skip_radar);
32+ if (!channel) {
33+ wpa_printf(MSG_ERROR, "could not get valid channel");
34+ return -1;
35+ }
36+
37+ iface->freq = channel->freq;
38+ iface->conf->channel = channel->chan;
39+ iface->conf->secondary_channel = sec;
40+ hostapd_set_oper_centr_freq_seg0_idx(iface->conf, cf1);
41+ hostapd_set_oper_centr_freq_seg1_idx(iface->conf, cf2);
42+
43+ return 0;
44+}
45+
46+
47 static int set_dfs_state_freq(struct hostapd_iface *iface, int freq, u32 state)
48 {
49 struct hostapd_hw_modes *mode;
50@@ -773,7 +796,6 @@ static unsigned int dfs_get_cac_time(struct hostapd_iface *iface,
51 */
52 int hostapd_handle_dfs(struct hostapd_iface *iface)
53 {
54- struct hostapd_channel_data *channel;
55 int res, n_chans, n_chans1, start_chan_idx, start_chan_idx1;
56 int skip_radar = 0;
57
58@@ -828,22 +850,10 @@ int hostapd_handle_dfs(struct hostapd_iface *iface)
59 wpa_printf(MSG_DEBUG, "DFS %d chans unavailable - choose other channel: %s",
60 res, res ? "yes": "no");
61 if (res) {
62- int sec = 0;
63- u8 cf1 = 0, cf2 = 0;
64-
65- channel = dfs_get_valid_channel(iface, &sec, &cf1, &cf2,
66- skip_radar);
67- if (!channel) {
68- wpa_printf(MSG_ERROR, "could not get valid channel");
69+ if (dfs_set_valid_channel(iface, skip_radar) < 0) {
70 hostapd_set_state(iface, HAPD_IFACE_DFS);
71 return 0;
72 }
73-
74- iface->freq = channel->freq;
75- iface->conf->channel = channel->chan;
76- iface->conf->secondary_channel = sec;
77- hostapd_set_oper_centr_freq_seg0_idx(iface->conf, cf1);
78- hostapd_set_oper_centr_freq_seg1_idx(iface->conf, cf2);
79 }
80 } while (res);
81
82--
832.29.2
84