Skip to content
Snippets Groups Projects

add ubus trigger_channel_acs

Merged Janusz Dziedzic requested to merge acs into devel
9 files
+ 181
17
Compare changes
  • Side-by-side
  • Inline
Files
9
+ 39
14
@@ -105,7 +105,7 @@ uint8_t ctrl_radio_cur_opclass_id(struct wifi_radio_element *radio)
@@ -105,7 +105,7 @@ uint8_t ctrl_radio_cur_opclass_id(struct wifi_radio_element *radio)
uint8_t id = 0;
uint8_t id = 0;
int ret;
int ret;
ret = wifi_opclass_get_max_bw(&radio->cur_opclass, NULL, NULL, &id);
ret = wifi_opclass_get_max_bw(&radio->cur_opclass, NULL, NULL, &id, NULL);
if (ret)
if (ret)
return 0;
return 0;
return id;
return id;
@@ -116,18 +116,29 @@ uint8_t ctrl_radio_cur_opclass_ctrl_chan(struct wifi_radio_element *radio)
@@ -116,18 +116,29 @@ uint8_t ctrl_radio_cur_opclass_ctrl_chan(struct wifi_radio_element *radio)
uint8_t ctrl_chan = 0;
uint8_t ctrl_chan = 0;
int ret;
int ret;
ret = wifi_opclass_get_max_bw(&radio->cur_opclass, &ctrl_chan, NULL, NULL);
ret = wifi_opclass_get_max_bw(&radio->cur_opclass, &ctrl_chan, NULL, NULL, NULL);
if (ret)
if (ret)
return 0;
return 0;
return ctrl_chan;
return ctrl_chan;
}
}
 
uint8_t ctrl_radio_cur_opclass_chan(struct wifi_radio_element *radio)
 
{
 
uint8_t chan = 0;
 
int ret;
 
 
ret = wifi_opclass_get_max_bw(&radio->cur_opclass, NULL, NULL, NULL, &chan);
 
if (ret)
 
return 0;
 
return chan;
 
}
 
uint8_t ctrl_radio_cur_opclass_max_bw(struct wifi_radio_element *radio)
uint8_t ctrl_radio_cur_opclass_max_bw(struct wifi_radio_element *radio)
{
{
uint32_t bw = 0;
uint32_t bw = 0;
int ret;
int ret;
ret = wifi_opclass_get_max_bw(&radio->cur_opclass, NULL, &bw, NULL);
ret = wifi_opclass_get_max_bw(&radio->cur_opclass, NULL, &bw, NULL, NULL);
if (ret)
if (ret)
return 0;
return 0;
return bw;
return bw;
@@ -179,6 +190,12 @@ int cntlr_acs_radio_channel_recalc(struct wifi_radio_element *radio, struct acs_
@@ -179,6 +190,12 @@ int cntlr_acs_radio_channel_recalc(struct wifi_radio_element *radio, struct acs_
MAC2STR(radio->macaddr),
MAC2STR(radio->macaddr),
params->opclass, params->bw, params->skip_dfs);
params->opclass, params->bw, params->skip_dfs);
 
if (!opclass->num_opclass) {
 
cntlr_dbg(LOG_CHANNEL, "acs radio channel recalc " MACFMT " - no pref opclass - skip recalc\n",
 
MAC2STR(radio->macaddr));
 
return -1;
 
}
 
for (i = 0; i < opclass->num_opclass; i++) {
for (i = 0; i < opclass->num_opclass; i++) {
entry = &opclass->opclass[i];
entry = &opclass->opclass[i];
@@ -195,7 +212,7 @@ int cntlr_acs_radio_channel_recalc(struct wifi_radio_element *radio, struct acs_
@@ -195,7 +212,7 @@ int cntlr_acs_radio_channel_recalc(struct wifi_radio_element *radio, struct acs_
pref = (entry->channel[j].preference & CHANNEL_PREF_MASK) >> 4;
pref = (entry->channel[j].preference & CHANNEL_PREF_MASK) >> 4;
reas = entry->channel[j].preference & CHANNEL_PREF_REASON;
reas = entry->channel[j].preference & CHANNEL_PREF_REASON;
trace("\tacs check/cmp chan %d pref %d reas %d\n", chan, pref, reas);
cntlr_trace(LOG_CHANNEL, "\tacs check/cmp chan %d pref %d reas %d\n", chan, pref, reas);
/* Always skip disabled channels */
/* Always skip disabled channels */
if (reas == CHANNEL_PREF_REASON_DFS_NOP)
if (reas == CHANNEL_PREF_REASON_DFS_NOP)
@@ -203,6 +220,10 @@ int cntlr_acs_radio_channel_recalc(struct wifi_radio_element *radio, struct acs_
@@ -203,6 +220,10 @@ int cntlr_acs_radio_channel_recalc(struct wifi_radio_element *radio, struct acs_
if (reas == CHANNEL_PREF_REASON_REG_DISALLOWED)
if (reas == CHANNEL_PREF_REASON_REG_DISALLOWED)
continue;
continue;
 
/* Current channel preference */
 
if (chan == params->best_channel)
 
pref_cur = pref;
 
/* Skip DFS channels if requested */
/* Skip DFS channels if requested */
if (params->skip_dfs) {
if (params->skip_dfs) {
if (reas == CHANNEL_PREF_REASON_DFS_AVAILABLE ||
if (reas == CHANNEL_PREF_REASON_DFS_AVAILABLE ||
@@ -217,10 +238,6 @@ int cntlr_acs_radio_channel_recalc(struct wifi_radio_element *radio, struct acs_
@@ -217,10 +238,6 @@ int cntlr_acs_radio_channel_recalc(struct wifi_radio_element *radio, struct acs_
if (WARN_ON(acs_params_num >= ARRAY_SIZE(acs_params)))
if (WARN_ON(acs_params_num >= ARRAY_SIZE(acs_params)))
break;
break;
/* Current channel preference */
if (chan == params->best_channel)
pref_cur = pref;
/* Kick best value */
/* Kick best value */
if (pref > pref_best)
if (pref > pref_best)
pref_best = pref;
pref_best = pref;
@@ -310,14 +327,14 @@ static int cntlr_get_current_acs_params(struct wifi_radio_element *radio, struct
@@ -310,14 +327,14 @@ static int cntlr_get_current_acs_params(struct wifi_radio_element *radio, struct
params->opclass = ctrl_radio_cur_opclass_id(radio);
params->opclass = ctrl_radio_cur_opclass_id(radio);
params->bw = ctrl_radio_cur_opclass_max_bw(radio);
params->bw = ctrl_radio_cur_opclass_max_bw(radio);
params->best_channel = ctrl_radio_cur_opclass_ctrl_chan(radio);
params->best_channel = ctrl_radio_cur_opclass_chan(radio);
params->best_bw = params->bw;
params->best_bw = params->bw;
params->best_opclass = params->opclass;
params->best_opclass = params->opclass;
return 0;
return 0;
}
}
void cntlr_acs_node_channel_recalc(struct node *node, bool skip_dfs)
void cntlr_acs_node_channel_recalc(struct node *node, enum wifi_band band, bool skip_dfs)
{
{
struct acs_params cur_acs_params = {};
struct acs_params cur_acs_params = {};
struct acs_params acs_params = {};
struct acs_params acs_params = {};
@@ -330,7 +347,15 @@ void cntlr_acs_node_channel_recalc(struct node *node, bool skip_dfs)
@@ -330,7 +347,15 @@ void cntlr_acs_node_channel_recalc(struct node *node, bool skip_dfs)
MAC2STR(node->almacaddr), acs_params.skip_dfs);
MAC2STR(node->almacaddr), acs_params.skip_dfs);
list_for_each_entry(r, &node->radiolist, list) {
list_for_each_entry(r, &node->radiolist, list) {
WARN_ON(cntlr_get_current_acs_params(r->radio_el, &cur_acs_params));
 
if (band && band != BAND_ANY && band != r->radio_el->band)
 
continue;
 
 
if (cntlr_get_current_acs_params(r->radio_el, &cur_acs_params)) {
 
cntlr_dbg(LOG_CHANNEL, "acs node " MACFMT " " MACFMT " - current channel not known\n",
 
MAC2STR(node->almacaddr), MAC2STR(r->radio_el->macaddr));
 
continue;
 
}
/* Use current opclass - TODO: if no opclass check 80/40/20 */
/* Use current opclass - TODO: if no opclass check 80/40/20 */
acs_params.opclass = cur_acs_params.opclass;
acs_params.opclass = cur_acs_params.opclass;
@@ -348,7 +373,7 @@ void cntlr_acs_node_channel_recalc(struct node *node, bool skip_dfs)
@@ -348,7 +373,7 @@ void cntlr_acs_node_channel_recalc(struct node *node, bool skip_dfs)
if (cntlr_acs_radio_is_bsta_connected(r))
if (cntlr_acs_radio_is_bsta_connected(r))
continue;
continue;
warn("acs switch to best channel %d/%d\n", acs_params.best_channel, acs_params.best_bw);
cntlr_warn(LOG_CHANNEL, "acs switch to best channel %d/%d\n", acs_params.best_channel, acs_params.best_bw);
ret = cntlr_send_channel_selection(node->cntlr, node->almacaddr,
ret = cntlr_send_channel_selection(node->cntlr, node->almacaddr,
r->radio_el->macaddr,
r->radio_el->macaddr,
acs_params.best_channel,
acs_params.best_channel,
@@ -356,7 +381,7 @@ void cntlr_acs_node_channel_recalc(struct node *node, bool skip_dfs)
@@ -356,7 +381,7 @@ void cntlr_acs_node_channel_recalc(struct node *node, bool skip_dfs)
14);
14);
if (ret)
if (ret)
warn("acs switch failed\n");
cntlr_warn(LOG_CHANNEL, "acs send channel switch request failed\n");
}
}
}
}
@@ -365,7 +390,7 @@ void cntlr_acs_recalc(struct controller *c, bool skip_dfs)
@@ -365,7 +390,7 @@ void cntlr_acs_recalc(struct controller *c, bool skip_dfs)
struct node *n = NULL;
struct node *n = NULL;
list_for_each_entry(n, &c->nodelist, list) {
list_for_each_entry(n, &c->nodelist, list) {
cntlr_acs_node_channel_recalc(n, skip_dfs);
cntlr_acs_node_channel_recalc(n, BAND_ANY, skip_dfs);
}
}
}
}
Loading