]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commitdiff
ath9k_htc: Add TSF adjust capability
authorSujith Manoharan <Sujith.Manoharan@atheros.com>
Wed, 13 Apr 2011 05:53:17 +0000 (11:23 +0530)
committerJohn W. Linville <linville@tuxdriver.com>
Wed, 13 Apr 2011 19:22:18 +0000 (15:22 -0400)
In multi-interface mode, beacons/probe responses that are
sent out must have their timestamp field updated. Calculate
the TSF adjustment value for each beaconing interface and set it
in the frame properly.

Signed-off-by: Sujith Manoharan <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/ath/ath9k/htc.h
drivers/net/wireless/ath/ath9k/htc_drv_beacon.c
drivers/net/wireless/ath/ath9k/htc_drv_main.c
drivers/net/wireless/ath/ath9k/htc_drv_txrx.c

index 31c649605d7955df12f70fedf81e31be9e2cc76c..87e4ca911a5804305bc4bd7c61a836644a9a0c54 100644 (file)
@@ -245,6 +245,7 @@ struct ath9k_htc_vif {
        u16 seq_no;
        bool beacon_configured;
        int bslot;
+       __le64 tsfadjust;
 };
 
 struct ath9k_vif_iter_data {
@@ -480,6 +481,8 @@ void ath9k_htc_assign_bslot(struct ath9k_htc_priv *priv,
                            struct ieee80211_vif *vif);
 void ath9k_htc_remove_bslot(struct ath9k_htc_priv *priv,
                            struct ieee80211_vif *vif);
+void ath9k_htc_set_tsfadjust(struct ath9k_htc_priv *priv,
+                            struct ieee80211_vif *vif);
 void ath9k_htc_beaconq_config(struct ath9k_htc_priv *priv);
 void ath9k_htc_beacon_config(struct ath9k_htc_priv *priv,
                             struct ieee80211_vif *vif);
index b561f703e467b3620398e7a62e310db237601294..2fad613add5105c997e650d587f05d39290318a1 100644 (file)
@@ -234,6 +234,7 @@ static void ath9k_htc_send_beacon(struct ath9k_htc_priv *priv,
        struct tx_beacon_header beacon_hdr;
        struct ath9k_htc_tx_ctl tx_ctl;
        struct ieee80211_tx_info *info;
+       struct ieee80211_mgmt *mgmt;
        struct sk_buff *beacon;
        u8 *tx_fhdr;
 
@@ -257,6 +258,13 @@ static void ath9k_htc_send_beacon(struct ath9k_htc_priv *priv,
                return;
        }
 
+       /*
+        * Update the TSF adjust value here, the HW will
+        * add this value for every beacon.
+        */
+       mgmt = (struct ieee80211_mgmt *)beacon->data;
+       mgmt->u.beacon.timestamp = avp->tsfadjust;
+
        info = IEEE80211_SKB_CB(beacon);
        if (info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) {
                struct ieee80211_hdr *hdr =
@@ -406,6 +414,34 @@ void ath9k_htc_remove_bslot(struct ath9k_htc_priv *priv,
                "Removed interface at beacon slot: %d\n", avp->bslot);
 }
 
+/*
+ * Calculate the TSF adjustment value for all slots
+ * other than zero.
+ */
+void ath9k_htc_set_tsfadjust(struct ath9k_htc_priv *priv,
+                            struct ieee80211_vif *vif)
+{
+       struct ath_common *common = ath9k_hw_common(priv->ah);
+       struct ath9k_htc_vif *avp = (struct ath9k_htc_vif *)vif->drv_priv;
+       struct htc_beacon_config *cur_conf = &priv->cur_beacon_conf;
+       u64 tsfadjust;
+
+       if (avp->bslot == 0)
+               return;
+
+       /*
+        * The beacon interval cannot be different for multi-AP mode,
+        * and we reach here only for VIF slots greater than zero,
+        * so beacon_interval is guaranteed to be set in cur_conf.
+        */
+       tsfadjust = cur_conf->beacon_interval * avp->bslot / ATH9K_HTC_MAX_BCN_VIF;
+       avp->tsfadjust = cpu_to_le64(TU_TO_USEC(tsfadjust));
+
+       ath_dbg(common, ATH_DBG_CONFIG,
+               "tsfadjust is: %llu for bslot: %d\n",
+               (unsigned long long)tsfadjust, avp->bslot);
+}
+
 static void ath9k_htc_beacon_iter(void *data, u8 *mac, struct ieee80211_vif *vif)
 {
        bool *beacon_configured = (bool *)data;
index 293a9b38e22e0a255ffa29e3446d34153409b7d5..6926ac0d5e5ce00f7321391ee4ebc2a3c82d2f7a 100644 (file)
@@ -1291,8 +1291,10 @@ static int ath9k_htc_add_interface(struct ieee80211_hw *hw,
        ath9k_htc_set_opmode(priv);
 
        if ((priv->ah->opmode == NL80211_IFTYPE_AP) &&
-           !(priv->op_flags & OP_ANI_RUNNING))
+           !(priv->op_flags & OP_ANI_RUNNING)) {
+               ath9k_hw_set_tsfadjust(priv->ah, 1);
                ath9k_htc_start_ani(priv);
+       }
 
        ath_dbg(common, ATH_DBG_CONFIG,
                "Attach a VIF of type: %d at idx: %d\n", vif->type, avp->index);
@@ -1652,6 +1654,7 @@ static void ath9k_htc_bss_info_changed(struct ieee80211_hw *hw,
        if ((changed & BSS_CHANGED_BEACON_ENABLED) && bss_conf->enable_beacon) {
                ath_dbg(common, ATH_DBG_CONFIG,
                        "Beacon enabled for BSS: %pM\n", bss_conf->bssid);
+               ath9k_htc_set_tsfadjust(priv, vif);
                priv->op_flags |= OP_ENABLE_BEACON;
                ath9k_htc_beacon_config(priv, vif);
        }
index 4a4f27ba96afdbbba1f47632203464815122e316..b3f94850821ef34f868ace956fe3daef11670c85 100644 (file)
@@ -82,11 +82,12 @@ int ath_htc_txq_update(struct ath9k_htc_priv *priv, int qnum,
 int ath9k_htc_tx_start(struct ath9k_htc_priv *priv, struct sk_buff *skb)
 {
        struct ieee80211_hdr *hdr;
+       struct ieee80211_mgmt *mgmt;
        struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
        struct ieee80211_sta *sta = tx_info->control.sta;
        struct ieee80211_vif *vif = tx_info->control.vif;
        struct ath9k_htc_sta *ista;
-       struct ath9k_htc_vif *avp;
+       struct ath9k_htc_vif *avp = NULL;
        struct ath9k_htc_tx_ctl tx_ctl;
        enum htc_endpoint_id epid;
        u16 qnum;
@@ -195,6 +196,15 @@ int ath9k_htc_tx_start(struct ath9k_htc_priv *priv, struct sk_buff *skb)
 
                memset(&mgmt_hdr, 0, sizeof(struct tx_mgmt_hdr));
 
+               /*
+                * Set the TSF adjust value for probe response
+                * frame also.
+                */
+               if (avp && unlikely(ieee80211_is_probe_resp(fc))) {
+                       mgmt = (struct ieee80211_mgmt *)skb->data;
+                       mgmt->u.probe_resp.timestamp = avp->tsfadjust;
+               }
+
                tx_ctl.type = ATH9K_HTC_NORMAL;
 
                mgmt_hdr.node_idx = sta_idx;