hostapd: Add average channel utilization in STATUS
This allows external programs to get the average channel utilization. The average channel utilization is calculated and reported through STATUS command. Users need to configure chan_util_avg_period and bss_load_update_period in hostapd config to get the average channel utilization. Signed-off-by: Bhagavathi Perumal S <bperumal@qti.qualcomm.com>
This commit is contained in:
parent
802c0fd0c3
commit
af832aa998
6 changed files with 46 additions and 0 deletions
|
@ -2863,6 +2863,16 @@ static int hostapd_config_fill(struct hostapd_config *conf,
|
|||
return 1;
|
||||
}
|
||||
bss->bss_load_update_period = val;
|
||||
} else if (os_strcmp(buf, "chan_util_avg_period") == 0) {
|
||||
int val = atoi(pos);
|
||||
|
||||
if (val < 0) {
|
||||
wpa_printf(MSG_ERROR,
|
||||
"Line %d: invalid chan_util_avg_period",
|
||||
line);
|
||||
return 1;
|
||||
}
|
||||
bss->chan_util_avg_period = val;
|
||||
} else if (os_strcmp(buf, "rts_threshold") == 0) {
|
||||
conf->rts_threshold = atoi(pos);
|
||||
if (conf->rts_threshold < -1 || conf->rts_threshold > 65535) {
|
||||
|
|
|
@ -511,6 +511,12 @@ wmm_ac_vo_acm=0
|
|||
# Beacon and Probe Response frames.
|
||||
#bss_load_update_period=50
|
||||
|
||||
# Channel utilization averaging period (in BUs)
|
||||
# This field is used to enable and configure channel utilization average
|
||||
# calculation with bss_load_update_period. This should be in multiples of
|
||||
# bss_load_update_period for more accurate calculation.
|
||||
#chan_util_avg_period=600
|
||||
|
||||
# Fixed BSS Load value for testing purposes
|
||||
# This field can be used to configure hostapd to add a fixed BSS Load element
|
||||
# into Beacon and Probe Response frames for testing purposes. The format is
|
||||
|
|
|
@ -249,6 +249,7 @@ struct hostapd_bss_config {
|
|||
|
||||
int dtim_period;
|
||||
unsigned int bss_load_update_period;
|
||||
unsigned int chan_util_avg_period;
|
||||
|
||||
int ieee802_1x; /* use IEEE 802.1X */
|
||||
int eapol_version;
|
||||
|
|
|
@ -44,6 +44,7 @@ static void update_channel_utilization(void *eloop_data, void *user_data)
|
|||
struct hostapd_data *hapd = eloop_data;
|
||||
unsigned int sec, usec;
|
||||
int err;
|
||||
struct hostapd_iface *iface = hapd->iface;
|
||||
|
||||
if (!(hapd->beacon_set_done && hapd->started))
|
||||
return;
|
||||
|
@ -59,6 +60,21 @@ static void update_channel_utilization(void *eloop_data, void *user_data)
|
|||
if (get_bss_load_update_timeout(hapd, &sec, &usec) < 0)
|
||||
return;
|
||||
|
||||
if (hapd->conf->chan_util_avg_period) {
|
||||
iface->chan_util_samples_sum += iface->channel_utilization;
|
||||
iface->chan_util_num_sample_periods +=
|
||||
hapd->conf->bss_load_update_period;
|
||||
if (iface->chan_util_num_sample_periods >=
|
||||
hapd->conf->chan_util_avg_period) {
|
||||
iface->chan_util_average =
|
||||
iface->chan_util_samples_sum /
|
||||
(iface->chan_util_num_sample_periods /
|
||||
hapd->conf->bss_load_update_period);
|
||||
iface->chan_util_samples_sum = 0;
|
||||
iface->chan_util_num_sample_periods = 0;
|
||||
}
|
||||
}
|
||||
|
||||
eloop_register_timeout(sec, usec, update_channel_utilization, hapd,
|
||||
NULL);
|
||||
}
|
||||
|
|
|
@ -795,6 +795,15 @@ int hostapd_ctrl_iface_status(struct hostapd_data *hapd, char *buf,
|
|||
len += ret;
|
||||
}
|
||||
|
||||
if (hapd->conf->chan_util_avg_period) {
|
||||
ret = os_snprintf(buf + len, buflen - len,
|
||||
"chan_util_avg=%u\n",
|
||||
iface->chan_util_average);
|
||||
if (os_snprintf_error(buflen - len, ret))
|
||||
return len;
|
||||
len += ret;
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
|
|
|
@ -497,6 +497,10 @@ struct hostapd_iface {
|
|||
u64 last_channel_time_busy;
|
||||
u8 channel_utilization;
|
||||
|
||||
unsigned int chan_util_samples_sum;
|
||||
unsigned int chan_util_num_sample_periods;
|
||||
unsigned int chan_util_average;
|
||||
|
||||
/* eCSA IE will be added only if operating class is specified */
|
||||
u8 cs_oper_class;
|
||||
|
||||
|
|
Loading…
Reference in a new issue