2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License.
6 * This program is distributed in the hope that it will be useful,
7 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 * GNU General Public License for more details.
11 * You should have received a copy of the GNU General Public License
12 * along with this program; if not, write to the Free Software
13 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
15 * Copyright (C) 2022 David Bauer <mail@david-bauer.net>
21 void usteer_band_steering_sta_update(struct sta_info
*si
)
23 if (si
->signal
< usteer_snr_to_signal(si
->node
, config
.band_steering_min_snr
))
24 si
->band_steering
.below_snr
= true;
27 bool usteer_band_steering_is_target(struct usteer_local_node
*ln
, struct usteer_node
*node
)
29 if (&ln
->node
== node
)
32 if (strcmp(ln
->node
.ssid
, node
->ssid
))
35 if (node
->freq
< 4000)
38 if (!usteer_policy_node_below_max_assoc(node
))
41 /* ToDo: Skip nodes with active load-kick */
47 static bool usteer_band_steering_has_target_iface(struct usteer_local_node
*ln
)
49 struct usteer_node
*node
;
51 for_each_local_node(node
) {
52 if (usteer_band_steering_is_target(ln
, node
))
59 void usteer_band_steering_perform_steer(struct usteer_local_node
*ln
)
61 unsigned int min_count
= DIV_ROUND_UP(config
.band_steering_interval
, config
.local_sta_update
);
64 if (!config
.band_steering_interval
)
67 /* Band-Steering is only available on 2.4 GHz interfaces */
68 if (ln
->node
.freq
> 4000)
71 /* Check if we have an interface we can steer to */
72 if (!usteer_band_steering_has_target_iface(ln
))
75 /* Only steer every interval */
76 if (ln
->band_steering_interval
< min_count
) {
77 ln
->band_steering_interval
++;
81 ln
->band_steering_interval
= 0;
83 list_for_each_entry(si
, &ln
->node
.sta_info
, node_list
) {
84 if (si
->connected
!= STA_CONNECTED
)
87 /* Skip clients with insufficient SNR-state */
88 if (si
->band_steering
.below_snr
) {
89 si
->band_steering
.below_snr
= false;
93 if (si
->bss_transition
)
94 usteer_ubus_band_steering_request(si
);
96 si
->band_steering
.below_snr
= false;