blob: 8da58560ecc05123363be2b8e0304abefd541579 [file] [log] [blame]
developer1a173672023-12-21 14:49:33 +08001From a615aa302064919791f3912a5cf1a908390414df Mon Sep 17 00:00:00 2001
2From: Nicolas Escande <nico.escande@gmail.com>
3Date: Wed, 27 Apr 2022 15:37:02 +0200
4Subject: [PATCH 04/50] ACS: Allow selecting a better channel when using
5 40/80/160 MHz
6
7When considering a channel for a bandwidth of 40/80/160 MHZ on the 5 GHz
8or 6 GHz band, allow selecting one of the other channels in the segment
9instead of the first one. This is done only if the other channel's
10interference_factor is lower than the first one's.
11
12Signed-off-by: Nicolas Escande <nico.escande@gmail.com>
13---
14 src/ap/acs.c | 25 +++++++++++++++++++++++--
15 1 file changed, 23 insertions(+), 2 deletions(-)
16
17diff --git a/src/ap/acs.c b/src/ap/acs.c
18index 78d1feb..130e135 100644
19--- a/src/ap/acs.c
20+++ b/src/ap/acs.c
21@@ -712,7 +712,7 @@ acs_find_ideal_chan_mode(struct hostapd_iface *iface,
22 struct hostapd_channel_data **ideal_chan,
23 long double *ideal_factor)
24 {
25- struct hostapd_channel_data *chan, *adj_chan = NULL;
26+ struct hostapd_channel_data *chan, *adj_chan = NULL, *best;
27 long double factor;
28 int i, j;
29 unsigned int k;
30@@ -720,8 +720,9 @@ acs_find_ideal_chan_mode(struct hostapd_iface *iface,
31 for (i = 0; i < mode->num_channels; i++) {
32 double total_weight;
33 struct acs_bias *bias, tmp_bias;
34+ bool update_best = true;
35
36- chan = &mode->channels[i];
37+ best = chan = &mode->channels[i];
38
39 /* Since in the current ACS implementation the first channel is
40 * always a primary channel, skip channels not available as
41@@ -807,7 +808,15 @@ acs_find_ideal_chan_mode(struct hostapd_iface *iface,
42 if (acs_usable_chan(adj_chan)) {
43 factor += adj_chan->interference_factor;
44 total_weight += 1;
45+ } else {
46+ update_best = false;
47 }
48+
49+ /* find the best channel in this segment */
50+ if (update_best &&
51+ adj_chan->interference_factor <
52+ best->interference_factor)
53+ best = adj_chan;
54 }
55
56 if (j != n_chans) {
57@@ -816,6 +825,18 @@ acs_find_ideal_chan_mode(struct hostapd_iface *iface,
58 continue;
59 }
60
61+ /* If the AP is in the 5 GHz or 6 GHz band, lets prefer a less
62+ * crowded primary channel if one was found in the segment */
63+ if (iface->current_mode->mode == HOSTAPD_MODE_IEEE80211A &&
64+ chan != best) {
65+ wpa_printf(MSG_DEBUG,
66+ "ACS: promoting channel %d over %d (less interference %Lg/%Lg)",
67+ best->chan, chan->chan,
68+ chan->interference_factor,
69+ best->interference_factor);
70+ chan = best;
71+ }
72+
73 /* 2.4 GHz has overlapping 20 MHz channels. Include adjacent
74 * channel interference factor. */
75 if (is_24ghz_mode(mode->mode)) {
76--
772.18.0
78