summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--net/mac80211/ieee80211_i.h10
-rw-r--r--net/mac80211/mlme.c20
-rw-r--r--net/mac80211/util.c2
3 files changed, 10 insertions, 22 deletions
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index 9482f323fd19..f0aee764d9cd 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -419,6 +419,8 @@ struct ieee80211_sta_tx_tspec {
419 bool downgraded; 419 bool downgraded;
420}; 420};
421 421
422DECLARE_EWMA(beacon_signal, 16, 4)
423
422struct ieee80211_if_managed { 424struct ieee80211_if_managed {
423 struct timer_list timer; 425 struct timer_list timer;
424 struct timer_list conn_mon_timer; 426 struct timer_list conn_mon_timer;
@@ -490,13 +492,7 @@ struct ieee80211_if_managed {
490 492
491 s16 p2p_noa_index; 493 s16 p2p_noa_index;
492 494
493 /* 495 struct ewma_beacon_signal ave_beacon_signal;
494 * Weighted average of the signal strength from Beacon frames in the
495 * current BSS. This is in units of 1/16 of the signal unit to maintain
496 * accuracy and to speed up calculations, i.e., the value need to be
497 * divided by 16 to get the actual value.
498 */
499 int ave_beacon_signal;
500 496
501 /* 497 /*
502 * Number of Beacon frames used in ave_beacon_signal. This can be used 498 * Number of Beacon frames used in ave_beacon_signal. This can be used
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index 79cfc2b35ef0..c7d316b440ef 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -82,13 +82,6 @@ MODULE_PARM_DESC(probe_wait_ms,
82 " before disconnecting (reason 4)."); 82 " before disconnecting (reason 4).");
83 83
84/* 84/*
85 * Weight given to the latest Beacon frame when calculating average signal
86 * strength for Beacon frames received in the current BSS. This must be
87 * between 1 and 15.
88 */
89#define IEEE80211_SIGNAL_AVE_WEIGHT 3
90
91/*
92 * How many Beacon frames need to have been used in average signal strength 85 * How many Beacon frames need to have been used in average signal strength
93 * before starting to indicate signal change events. 86 * before starting to indicate signal change events.
94 */ 87 */
@@ -3366,21 +3359,19 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata,
3366 /* Track average RSSI from the Beacon frames of the current AP */ 3359 /* Track average RSSI from the Beacon frames of the current AP */
3367 if (ifmgd->flags & IEEE80211_STA_RESET_SIGNAL_AVE) { 3360 if (ifmgd->flags & IEEE80211_STA_RESET_SIGNAL_AVE) {
3368 ifmgd->flags &= ~IEEE80211_STA_RESET_SIGNAL_AVE; 3361 ifmgd->flags &= ~IEEE80211_STA_RESET_SIGNAL_AVE;
3369 ifmgd->ave_beacon_signal = rx_status->signal * 16; 3362 ewma_beacon_signal_init(&ifmgd->ave_beacon_signal);
3370 ifmgd->last_cqm_event_signal = 0; 3363 ifmgd->last_cqm_event_signal = 0;
3371 ifmgd->count_beacon_signal = 1; 3364 ifmgd->count_beacon_signal = 1;
3372 ifmgd->last_ave_beacon_signal = 0; 3365 ifmgd->last_ave_beacon_signal = 0;
3373 } else { 3366 } else {
3374 ifmgd->ave_beacon_signal =
3375 (IEEE80211_SIGNAL_AVE_WEIGHT * rx_status->signal * 16 +
3376 (16 - IEEE80211_SIGNAL_AVE_WEIGHT) *
3377 ifmgd->ave_beacon_signal) / 16;
3378 ifmgd->count_beacon_signal++; 3367 ifmgd->count_beacon_signal++;
3379 } 3368 }
3380 3369
3370 ewma_beacon_signal_add(&ifmgd->ave_beacon_signal, -rx_status->signal);
3371
3381 if (ifmgd->rssi_min_thold != ifmgd->rssi_max_thold && 3372 if (ifmgd->rssi_min_thold != ifmgd->rssi_max_thold &&
3382 ifmgd->count_beacon_signal >= IEEE80211_SIGNAL_AVE_MIN_COUNT) { 3373 ifmgd->count_beacon_signal >= IEEE80211_SIGNAL_AVE_MIN_COUNT) {
3383 int sig = ifmgd->ave_beacon_signal / 16; 3374 int sig = -ewma_beacon_signal_read(&ifmgd->ave_beacon_signal);
3384 int last_sig = ifmgd->last_ave_beacon_signal; 3375 int last_sig = ifmgd->last_ave_beacon_signal;
3385 struct ieee80211_event event = { 3376 struct ieee80211_event event = {
3386 .type = RSSI_EVENT, 3377 .type = RSSI_EVENT,
@@ -3407,10 +3398,11 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata,
3407 if (bss_conf->cqm_rssi_thold && 3398 if (bss_conf->cqm_rssi_thold &&
3408 ifmgd->count_beacon_signal >= IEEE80211_SIGNAL_AVE_MIN_COUNT && 3399 ifmgd->count_beacon_signal >= IEEE80211_SIGNAL_AVE_MIN_COUNT &&
3409 !(sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI)) { 3400 !(sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI)) {
3410 int sig = ifmgd->ave_beacon_signal / 16; 3401 int sig = -ewma_beacon_signal_read(&ifmgd->ave_beacon_signal);
3411 int last_event = ifmgd->last_cqm_event_signal; 3402 int last_event = ifmgd->last_cqm_event_signal;
3412 int thold = bss_conf->cqm_rssi_thold; 3403 int thold = bss_conf->cqm_rssi_thold;
3413 int hyst = bss_conf->cqm_rssi_hyst; 3404 int hyst = bss_conf->cqm_rssi_hyst;
3405
3414 if (sig < thold && 3406 if (sig < thold &&
3415 (last_event == 0 || sig < last_event - hyst)) { 3407 (last_event == 0 || sig < last_event - hyst)) {
3416 ifmgd->last_cqm_event_signal = sig; 3408 ifmgd->last_cqm_event_signal = sig;
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index f16705675339..9cabf076d718 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -2543,7 +2543,7 @@ int ieee80211_ave_rssi(struct ieee80211_vif *vif)
2543 /* non-managed type inferfaces */ 2543 /* non-managed type inferfaces */
2544 return 0; 2544 return 0;
2545 } 2545 }
2546 return ifmgd->ave_beacon_signal / 16; 2546 return -ewma_beacon_signal_read(&ifmgd->ave_beacon_signal);
2547} 2547}
2548EXPORT_SYMBOL_GPL(ieee80211_ave_rssi); 2548EXPORT_SYMBOL_GPL(ieee80211_ave_rssi);
2549 2549