diff options
author | Felix Fietkau <nbd@openwrt.org> | 2010-11-19 16:55:38 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2010-11-24 16:19:34 -0500 |
commit | 7ccc8bd7593634d827e8bc55898a5038e29848b5 (patch) | |
tree | c01c231a2f7448be34796c4c11358ffec42225aa | |
parent | c8a7972c3b3633bf90daf50b135665d8ca4838c4 (diff) |
mac80211: calculate beacon loss time accurately
Instead of using a fixed 2 second timeout, calculate beacon loss interval
from the advertised beacon interval and a frame count. With this beacon
loss happens after N (default 7) consecutive frames are missed which
for a typical setup (100TU beacon interval) is ~700ms (or ~1/3 previous).
Signed-off-by: Sam Leffler <sleffler@chromium.org>
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r-- | net/mac80211/ieee80211_i.h | 1 | ||||
-rw-r--r-- | net/mac80211/mlme.c | 16 |
2 files changed, 13 insertions, 4 deletions
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index 3598abf21844..ff7bc307827b 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h | |||
@@ -349,6 +349,7 @@ struct ieee80211_if_managed { | |||
349 | struct work_struct chswitch_work; | 349 | struct work_struct chswitch_work; |
350 | struct work_struct beacon_connection_loss_work; | 350 | struct work_struct beacon_connection_loss_work; |
351 | 351 | ||
352 | unsigned long beacon_timeout; | ||
352 | unsigned long probe_timeout; | 353 | unsigned long probe_timeout; |
353 | int probe_send_count; | 354 | int probe_send_count; |
354 | 355 | ||
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index 84e24df234e2..729aba49cf98 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c | |||
@@ -31,10 +31,15 @@ | |||
31 | #define IEEE80211_MAX_PROBE_TRIES 5 | 31 | #define IEEE80211_MAX_PROBE_TRIES 5 |
32 | 32 | ||
33 | /* | 33 | /* |
34 | * beacon loss detection timeout | 34 | * Beacon loss timeout is calculated as N frames times the |
35 | * XXX: should depend on beacon interval | 35 | * advertised beacon interval. This may need to be somewhat |
36 | * higher than what hardware might detect to account for | ||
37 | * delays in the host processing frames. But since we also | ||
38 | * probe on beacon miss before declaring the connection lost | ||
39 | * default to what we want. | ||
36 | */ | 40 | */ |
37 | #define IEEE80211_BEACON_LOSS_TIME (2 * HZ) | 41 | #define IEEE80211_BEACON_LOSS_COUNT 7 |
42 | |||
38 | /* | 43 | /* |
39 | * Time the connection can be idle before we probe | 44 | * Time the connection can be idle before we probe |
40 | * it to see if we can still talk to the AP. | 45 | * it to see if we can still talk to the AP. |
@@ -121,7 +126,7 @@ void ieee80211_sta_reset_beacon_monitor(struct ieee80211_sub_if_data *sdata) | |||
121 | return; | 126 | return; |
122 | 127 | ||
123 | mod_timer(&sdata->u.mgd.bcn_mon_timer, | 128 | mod_timer(&sdata->u.mgd.bcn_mon_timer, |
124 | round_jiffies_up(jiffies + IEEE80211_BEACON_LOSS_TIME)); | 129 | round_jiffies_up(jiffies + sdata->u.mgd.beacon_timeout)); |
125 | } | 130 | } |
126 | 131 | ||
127 | void ieee80211_sta_reset_conn_monitor(struct ieee80211_sub_if_data *sdata) | 132 | void ieee80211_sta_reset_conn_monitor(struct ieee80211_sub_if_data *sdata) |
@@ -871,6 +876,9 @@ static void ieee80211_set_associated(struct ieee80211_sub_if_data *sdata, | |||
871 | bss_info_changed |= ieee80211_handle_bss_capability(sdata, | 876 | bss_info_changed |= ieee80211_handle_bss_capability(sdata, |
872 | cbss->capability, bss->has_erp_value, bss->erp_value); | 877 | cbss->capability, bss->has_erp_value, bss->erp_value); |
873 | 878 | ||
879 | sdata->u.mgd.beacon_timeout = usecs_to_jiffies(ieee80211_tu_to_usec( | ||
880 | IEEE80211_BEACON_LOSS_COUNT * bss_conf->beacon_int)); | ||
881 | |||
874 | sdata->u.mgd.associated = cbss; | 882 | sdata->u.mgd.associated = cbss; |
875 | memcpy(sdata->u.mgd.bssid, cbss->bssid, ETH_ALEN); | 883 | memcpy(sdata->u.mgd.bssid, cbss->bssid, ETH_ALEN); |
876 | 884 | ||