diff options
author | Thomas Pedersen <twpedersen@gmail.com> | 2013-12-19 13:25:15 -0500 |
---|---|---|
committer | Johannes Berg <johannes.berg@intel.com> | 2014-01-06 14:10:47 -0500 |
commit | 057d5f4ba1e421185a8e7e0b7fadf253d41a3e83 (patch) | |
tree | 32417b8a78ea735667c46213446079e7729fde48 /net/mac80211/util.c | |
parent | 60a4fe0ae97b515f174f9bcb157cbaeff0dab8ac (diff) |
mac80211: sync dtim_count to TSF
On starting a mesh or AP BSS, the interface dtim_count
countdown should match that of the driver TSF.
Signed-off-by: Thomas Pedersen <twpedersen@gmail.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/mac80211/util.c')
-rw-r--r-- | net/mac80211/util.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/net/mac80211/util.c b/net/mac80211/util.c index df00f1978a77..676dc0967f37 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c | |||
@@ -2734,3 +2734,44 @@ int ieee80211_parse_p2p_noa(const struct ieee80211_p2p_noa_attr *attr, | |||
2734 | return ret; | 2734 | return ret; |
2735 | } | 2735 | } |
2736 | EXPORT_SYMBOL(ieee80211_parse_p2p_noa); | 2736 | EXPORT_SYMBOL(ieee80211_parse_p2p_noa); |
2737 | |||
2738 | void ieee80211_recalc_dtim(struct ieee80211_local *local, | ||
2739 | struct ieee80211_sub_if_data *sdata) | ||
2740 | { | ||
2741 | u64 tsf = drv_get_tsf(local, sdata); | ||
2742 | u64 dtim_count = 0; | ||
2743 | u16 beacon_int = sdata->vif.bss_conf.beacon_int * 1024; | ||
2744 | u8 dtim_period = sdata->vif.bss_conf.dtim_period; | ||
2745 | struct ps_data *ps; | ||
2746 | u8 bcns_from_dtim; | ||
2747 | |||
2748 | if (tsf == -1ULL || !beacon_int || !dtim_period) | ||
2749 | return; | ||
2750 | |||
2751 | if (sdata->vif.type == NL80211_IFTYPE_AP || | ||
2752 | sdata->vif.type == NL80211_IFTYPE_AP_VLAN) { | ||
2753 | if (!sdata->bss) | ||
2754 | return; | ||
2755 | |||
2756 | ps = &sdata->bss->ps; | ||
2757 | } else if (ieee80211_vif_is_mesh(&sdata->vif)) { | ||
2758 | ps = &sdata->u.mesh.ps; | ||
2759 | } else { | ||
2760 | return; | ||
2761 | } | ||
2762 | |||
2763 | /* | ||
2764 | * actually finds last dtim_count, mac80211 will update in | ||
2765 | * __beacon_add_tim(). | ||
2766 | * dtim_count = dtim_period - (tsf / bcn_int) % dtim_period | ||
2767 | */ | ||
2768 | do_div(tsf, beacon_int); | ||
2769 | bcns_from_dtim = do_div(tsf, dtim_period); | ||
2770 | /* just had a DTIM */ | ||
2771 | if (!bcns_from_dtim) | ||
2772 | dtim_count = 0; | ||
2773 | else | ||
2774 | dtim_count = dtim_period - bcns_from_dtim; | ||
2775 | |||
2776 | ps->dtim_count = dtim_count; | ||
2777 | } | ||