Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions band_steering.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -96,4 +107,4 @@ void usteer_band_steering_perform_steer(struct usteer_local_node *ln)

si->band_steering.below_snr = false;
}
}
}
25 changes: 20 additions & 5 deletions policy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
6 changes: 4 additions & 2 deletions sta.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
1 change: 1 addition & 0 deletions ubus.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
1 change: 1 addition & 0 deletions usteer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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];
};
Expand Down
16 changes: 16 additions & 0 deletions utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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