ath9k: Set the TSF adjust value properly
authorSujith Manoharan <c_manoha@qca.qualcomm.com>
Tue, 17 Jul 2012 11:46:16 +0000 (17:16 +0530)
committerJohn W. Linville <linville@tuxdriver.com>
Tue, 17 Jul 2012 19:11:39 +0000 (15:11 -0400)
Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/ath/ath9k/ath9k.h
drivers/net/wireless/ath/ath9k/beacon.c
drivers/net/wireless/ath/ath9k/main.c

index 00a22683981a66d85471191eba505aa4438133b6..4aca1e5dd7127a37374232e647249030df1404fa 100644 (file)
@@ -421,6 +421,7 @@ void ath9k_beacon_config(struct ath_softc *sc, struct ieee80211_vif *vif,
                         u32 changed);
 void ath9k_beacon_assign_slot(struct ath_softc *sc, struct ieee80211_vif *vif);
 void ath9k_beacon_remove_slot(struct ath_softc *sc, struct ieee80211_vif *vif);
+void ath9k_set_tsfadjust(struct ath_softc *sc, struct ieee80211_vif *vif);
 void ath9k_set_beacon(struct ath_softc *sc);
 void ath9k_set_beaconing_status(struct ath_softc *sc, bool status);
 
index 02fbd3eebc2bdaa1c2b33de31ebcc04bab113e5b..f2a2131c5ce53f0ab2e6226479f7b68aa78c5c08 100644 (file)
@@ -268,6 +268,23 @@ void ath9k_beacon_remove_slot(struct ath_softc *sc, struct ieee80211_vif *vif)
        tasklet_enable(&sc->bcon_tasklet);
 }
 
+void ath9k_set_tsfadjust(struct ath_softc *sc, struct ieee80211_vif *vif)
+{
+       struct ath_common *common = ath9k_hw_common(sc->sc_ah);
+       struct ath_beacon_config *cur_conf = &sc->cur_beacon_conf;
+       struct ath_vif *avp = (void *)vif->drv_priv;
+       u64 tsfadjust;
+
+       if (avp->av_bslot == 0)
+               return;
+
+       tsfadjust = cur_conf->beacon_interval * avp->av_bslot / ATH_BCBUF;
+       avp->tsf_adjust = cpu_to_le64(TU_TO_USEC(tsfadjust));
+
+       ath_dbg(common, CONFIG, "tsfadjust is: %llu for bslot: %d\n",
+               (unsigned long long)tsfadjust, avp->av_bslot);
+}
+
 void ath_beacon_tasklet(unsigned long data)
 {
        struct ath_softc *sc = (struct ath_softc *)data;
index d8ae0f5e3da7fdbf19bf3d85869660bc9a4b5dbb..915bd4881b3f60b6ad956963ef4bb71fa64792b8 100644 (file)
@@ -1531,6 +1531,9 @@ static void ath9k_bss_info_changed(struct ieee80211_hw *hw,
 
        if ((changed & BSS_CHANGED_BEACON_ENABLED) ||
            (changed & BSS_CHANGED_BEACON_INT)) {
+               if (ah->opmode == NL80211_IFTYPE_AP &&
+                   bss_conf->enable_beacon)
+                       ath9k_set_tsfadjust(sc, vif);
                if (ath9k_allow_beacon_config(sc, vif))
                        ath9k_beacon_config(sc, vif, changed);
        }