diff --git a/band_steering.c b/band_steering.c index 7fce1df..89246e7 100644 --- a/band_steering.c +++ b/band_steering.c @@ -32,8 +32,19 @@ bool usteer_band_steering_is_target(struct usteer_local_node *ln, struct usteer_ if (strcmp(ln->node.ssid, node->ssid)) return false; - if (node->freq < 4000) + /* Progressive band steering: 2.4 GHz → 5 GHz → 6 GHz */ + if (is_2ghz_freq(ln->node.freq)) { + /* From 2.4 GHz, target 5 GHz only */ + if (!is_5ghz_freq(node->freq)) + return false; + } else if (is_5ghz_freq(ln->node.freq)) { + /* From 5 GHz, target 6 GHz only */ + if (!is_6ghz_freq(node->freq)) + return false; + } else { + /* From 6 GHz, no steering (already on highest band) */ return false; + } if (!usteer_policy_node_below_max_assoc(node)) return false; @@ -64,8 +75,8 @@ void usteer_band_steering_perform_steer(struct usteer_local_node *ln) if (!config.band_steering_interval) return; - /* Band-Steering is only available on 2.4 GHz interfaces */ - if (ln->node.freq > 4000) + /* Band-Steering is available on 2.4 GHz (to 5 GHz) and 5 GHz (to 6 GHz) interfaces */ + if (is_6ghz_freq(ln->node.freq)) return; /* Check if we have an interface we can steer to */ @@ -96,4 +107,4 @@ void usteer_band_steering_perform_steer(struct usteer_local_node *ln) si->band_steering.below_snr = false; } -} \ No newline at end of file +} diff --git a/policy.c b/policy.c index 8c5d244..36205bf 100644 --- a/policy.c +++ b/policy.c @@ -26,16 +26,31 @@ below_assoc_threshold(struct usteer_node *node_cur, struct usteer_node *node_new { int n_assoc_cur = node_cur->n_assoc; int n_assoc_new = node_new->n_assoc; - bool ref_5g = node_cur->freq > 4000; - bool node_5g = node_new->freq > 4000; + int band_cur, band_new; if (!config.load_balancing_threshold) return false; - if (ref_5g && !node_5g) - n_assoc_new += config.band_steering_threshold; - else if (!ref_5g && node_5g) + /* Determine band priorities: 2.4 GHz = 0, 5 GHz = 1, 6 GHz = 2 */ + if (is_2ghz_freq(node_cur->freq)) + band_cur = 0; + else if (is_5ghz_freq(node_cur->freq)) + band_cur = 1; + else + band_cur = 2; + + if (is_2ghz_freq(node_new->freq)) + band_new = 0; + else if (is_5ghz_freq(node_new->freq)) + band_new = 1; + else + band_new = 2; + + /* Apply band steering threshold: prefer higher bands */ + if (band_new > band_cur) n_assoc_cur += config.band_steering_threshold; + else if (band_cur > band_new) + n_assoc_new += config.band_steering_threshold; n_assoc_new += config.load_balancing_threshold; diff --git a/sta.c b/sta.c index ed7e40e..340ef30 100644 --- a/sta.c +++ b/sta.c @@ -168,10 +168,12 @@ usteer_sta_info_update(struct sta_info *si, int signal, bool avg) si->seen = current_time; - if (si->node->freq < 4000) + if (is_2ghz_freq(si->node->freq)) si->sta->seen_2ghz = 1; - else + else if (is_5ghz_freq(si->node->freq)) si->sta->seen_5ghz = 1; + else if (is_6ghz_freq(si->node->freq)) + si->sta->seen_6ghz = 1; usteer_sta_info_update_timeout(si, config.local_sta_timeout); } diff --git a/ubus.c b/ubus.c index 40daf74..3fbea47 100644 --- a/ubus.c +++ b/ubus.c @@ -106,6 +106,7 @@ usteer_ubus_get_client_info(struct ubus_context *ctx, struct ubus_object *obj, blob_buf_init(&b, 0); blobmsg_add_u8(&b, "2ghz", sta->seen_2ghz); blobmsg_add_u8(&b, "5ghz", sta->seen_5ghz); + blobmsg_add_u8(&b, "6ghz", sta->seen_6ghz); _n = blobmsg_open_table(&b, "nodes"); list_for_each_entry(si, &sta->nodes, list) { _cur_n = blobmsg_open_table(&b, usteer_node_name(si->node)); diff --git a/usteer.h b/usteer.h index f692fb8..17e3010 100644 --- a/usteer.h +++ b/usteer.h @@ -284,6 +284,7 @@ struct sta { uint8_t seen_2ghz : 1; uint8_t seen_5ghz : 1; + uint8_t seen_6ghz : 1; uint8_t addr[6]; }; diff --git a/utils.h b/utils.h index 75e1e2d..fd37aa4 100644 --- a/utils.h +++ b/utils.h @@ -47,4 +47,20 @@ extern void debug_msg_cont(int level, const char *format, ...); #define __usteer_init __attribute__((constructor)) +/* WiFi band detection helpers */ +static inline bool is_2ghz_freq(int freq) +{ + return freq < 4000; +} + +static inline bool is_5ghz_freq(int freq) +{ + return freq >= 4000 && freq < 5900; +} + +static inline bool is_6ghz_freq(int freq) +{ + return freq >= 5900; +} + #endif