aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211
diff options
context:
space:
mode:
authorThomas Pedersen <twpedersen@gmail.com>2013-12-19 13:25:15 -0500
committerJohannes Berg <johannes.berg@intel.com>2014-01-06 14:10:47 -0500
commit057d5f4ba1e421185a8e7e0b7fadf253d41a3e83 (patch)
tree32417b8a78ea735667c46213446079e7729fde48 /net/mac80211
parent60a4fe0ae97b515f174f9bcb157cbaeff0dab8ac (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')
-rw-r--r--net/mac80211/cfg.c1
-rw-r--r--net/mac80211/debugfs_netdev.c1
-rw-r--r--net/mac80211/ieee80211_i.h2
-rw-r--r--net/mac80211/mesh.c1
-rw-r--r--net/mac80211/util.c41
5 files changed, 46 insertions, 0 deletions
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index fd1020e791d8..f9ae9b85d4c1 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -1035,6 +1035,7 @@ static int ieee80211_start_ap(struct wiphy *wiphy, struct net_device *dev,
1035 return err; 1035 return err;
1036 } 1036 }
1037 1037
1038 ieee80211_recalc_dtim(local, sdata);
1038 ieee80211_bss_info_change_notify(sdata, changed); 1039 ieee80211_bss_info_change_notify(sdata, changed);
1039 1040
1040 netif_carrier_on(dev); 1041 netif_carrier_on(dev);
diff --git a/net/mac80211/debugfs_netdev.c b/net/mac80211/debugfs_netdev.c
index b62cbe82954c..ebf80f3abd83 100644
--- a/net/mac80211/debugfs_netdev.c
+++ b/net/mac80211/debugfs_netdev.c
@@ -474,6 +474,7 @@ static ssize_t ieee80211_if_parse_tsf(
474 } 474 }
475 } 475 }
476 476
477 ieee80211_recalc_dtim(local, sdata);
477 return buflen; 478 return buflen;
478} 479}
479IEEE80211_IF_FILE_RW(tsf); 480IEEE80211_IF_FILE_RW(tsf);
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index 953b9e294547..3701930c6649 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -1800,6 +1800,8 @@ ieee80211_cs_get(struct ieee80211_local *local, u32 cipher,
1800int ieee80211_cs_headroom(struct ieee80211_local *local, 1800int ieee80211_cs_headroom(struct ieee80211_local *local,
1801 struct cfg80211_crypto_settings *crypto, 1801 struct cfg80211_crypto_settings *crypto,
1802 enum nl80211_iftype iftype); 1802 enum nl80211_iftype iftype);
1803void ieee80211_recalc_dtim(struct ieee80211_local *local,
1804 struct ieee80211_sub_if_data *sdata);
1803 1805
1804#ifdef CONFIG_MAC80211_NOINLINE 1806#ifdef CONFIG_MAC80211_NOINLINE
1805#define debug_noinline noinline 1807#define debug_noinline noinline
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
index 5a74b249ba35..5b919cab1de0 100644
--- a/net/mac80211/mesh.c
+++ b/net/mac80211/mesh.c
@@ -807,6 +807,7 @@ int ieee80211_start_mesh(struct ieee80211_sub_if_data *sdata)
807 return -ENOMEM; 807 return -ENOMEM;
808 } 808 }
809 809
810 ieee80211_recalc_dtim(local, sdata);
810 ieee80211_bss_info_change_notify(sdata, changed); 811 ieee80211_bss_info_change_notify(sdata, changed);
811 812
812 netif_carrier_on(sdata->dev); 813 netif_carrier_on(sdata->dev);
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}
2736EXPORT_SYMBOL(ieee80211_parse_p2p_noa); 2736EXPORT_SYMBOL(ieee80211_parse_p2p_noa);
2737
2738void 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}