Linux wireless drivers development
 help / color / mirror / Atom feed
From: "Luis R. Rodriguez" <lrodriguez@atheros.com>
To: linville@tuxdriver.com
Cc: linux-wireless@vger.kernel.org, Felix Fietkau <nbd@openwrt.org>
Subject: [PATCH 16/24] ath9k: fix extending the rx timestamp with the hardware TSF
Date: Sat, 12 Jun 2010 00:33:54 -0400	[thread overview]
Message-ID: <1276317242-15540-17-git-send-email-lrodriguez@atheros.com> (raw)
In-Reply-To: <1276317242-15540-1-git-send-email-lrodriguez@atheros.com>

From: Felix Fietkau <nbd@openwrt.org>

AR5416 and all newer chipsets use a 32 bit rx timestamp, so there
is no need to keep the 15 bit timestamp extending logic around.

This patch removes ath9k_hw_extend_tsf (replaced by a call to
ath9k_hw_gettsf64), and reduces the frequency of TSF reads, which
can improve performance in some cases.

This change also has the side effect of making rx timestamps
more accurate.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
---
 drivers/net/wireless/ath/ath9k/hw.c   |   15 ---------------
 drivers/net/wireless/ath/ath9k/hw.h   |    1 -
 drivers/net/wireless/ath/ath9k/recv.c |   17 ++++++++++++++---
 3 files changed, 14 insertions(+), 19 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c
index 874c4e9..1fa3fe7 100644
--- a/drivers/net/wireless/ath/ath9k/hw.c
+++ b/drivers/net/wireless/ath/ath9k/hw.c
@@ -2616,21 +2616,6 @@ void ath9k_hw_set_tsfadjust(struct ath_hw *ah, u32 setting)
 }
 EXPORT_SYMBOL(ath9k_hw_set_tsfadjust);
 
-/*
- *  Extend 15-bit time stamp from rx descriptor to
- *  a full 64-bit TSF using the current h/w TSF.
-*/
-u64 ath9k_hw_extend_tsf(struct ath_hw *ah, u32 rstamp)
-{
-	u64 tsf;
-
-	tsf = ath9k_hw_gettsf64(ah);
-	if ((tsf & 0x7fff) < rstamp)
-		tsf -= 0x8000;
-	return (tsf & ~0x7fff) | rstamp;
-}
-EXPORT_SYMBOL(ath9k_hw_extend_tsf);
-
 void ath9k_hw_set11nmac2040(struct ath_hw *ah)
 {
 	struct ieee80211_conf *conf = &ath9k_hw_common(ah)->hw->conf;
diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
index 009f0fa..ba84ac7 100644
--- a/drivers/net/wireless/ath/ath9k/hw.h
+++ b/drivers/net/wireless/ath/ath9k/hw.h
@@ -894,7 +894,6 @@ u64 ath9k_hw_gettsf64(struct ath_hw *ah);
 void ath9k_hw_settsf64(struct ath_hw *ah, u64 tsf64);
 void ath9k_hw_reset_tsf(struct ath_hw *ah);
 void ath9k_hw_set_tsfadjust(struct ath_hw *ah, u32 setting);
-u64 ath9k_hw_extend_tsf(struct ath_hw *ah, u32 rstamp);
 void ath9k_hw_init_global_settings(struct ath_hw *ah);
 void ath9k_hw_set11nmac2040(struct ath_hw *ah);
 void ath9k_hw_beaconinit(struct ath_hw *ah, u32 next_beacon, u32 beacon_period);
diff --git a/drivers/net/wireless/ath/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c
index 5141cd8..78ef1ae 100644
--- a/drivers/net/wireless/ath/ath9k/recv.c
+++ b/drivers/net/wireless/ath/ath9k/recv.c
@@ -1002,8 +1002,6 @@ static int ath9k_rx_skb_preprocess(struct ath_common *common,
 				   struct ieee80211_rx_status *rx_status,
 				   bool *decrypt_error)
 {
-	struct ath_hw *ah = common->ah;
-
 	memset(rx_status, 0, sizeof(struct ieee80211_rx_status));
 
 	/*
@@ -1018,7 +1016,6 @@ static int ath9k_rx_skb_preprocess(struct ath_common *common,
 	if (ath9k_process_rate(common, hw, rx_stats, rx_status))
 		return -EINVAL;
 
-	rx_status->mactime = ath9k_hw_extend_tsf(ah, rx_stats->rs_tstamp);
 	rx_status->band = hw->conf.channel->band;
 	rx_status->freq = hw->conf.channel->center_freq;
 	rx_status->signal = ATH_DEFAULT_NOISE_FLOOR + rx_stats->rs_rssi;
@@ -1100,6 +1097,8 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp)
 	bool edma = !!(ah->caps.hw_caps & ATH9K_HW_CAP_EDMA);
 	int dma_type;
 	u8 rx_status_len = ah->caps.rx_status_len;
+	u64 tsf = 0;
+	u32 tsf_lower = 0;
 
 	if (edma)
 		dma_type = DMA_BIDIRECTIONAL;
@@ -1109,6 +1108,9 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp)
 	qtype = hp ? ATH9K_RX_QUEUE_HP : ATH9K_RX_QUEUE_LP;
 	spin_lock_bh(&sc->rx.rxbuflock);
 
+	tsf = ath9k_hw_gettsf64(ah);
+	tsf_lower = tsf & 0xffffffff;
+
 	do {
 		/* If handling rx interrupt and flush is in progress => exit */
 		if ((sc->sc_flags & SC_OP_RXFLUSH) && (flush == 0))
@@ -1141,6 +1143,15 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp)
 		if (flush)
 			goto requeue;
 
+		rxs->mactime = (tsf & ~0xffffffffULL) | rs.rs_tstamp;
+		if (rs.rs_tstamp > tsf_lower &&
+		    unlikely(rs.rs_tstamp - tsf_lower > 0x10000000))
+			rxs->mactime -= 0x100000000ULL;
+
+		if (rs.rs_tstamp < tsf_lower &&
+		    unlikely(tsf_lower - rs.rs_tstamp > 0x10000000))
+			rxs->mactime += 0x100000000ULL;
+
 		retval = ath9k_rx_skb_preprocess(common, hw, hdr, &rs,
 						 rxs, &decrypt_error);
 		if (retval)
-- 
1.6.3.3


  parent reply	other threads:[~2010-06-12  4:34 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-12  4:33 [PATCH 00/24] ath9k: new ANI, PAPrD and few fixes and cleanups Luis R. Rodriguez
2010-06-12  4:33 ` [PATCH 01/24] ath9k_hw: move clock definitions from hw.c to hw.h Luis R. Rodriguez
2010-06-12  4:33 ` [PATCH 02/24] ath9k_hw: fix clock rate calculations for ANI Luis R. Rodriguez
2010-06-12  4:33 ` [PATCH 03/24] ath9k_hw: clear MIB interrupt causes when skipping ANI adjustments Luis R. Rodriguez
2010-06-12  4:33 ` [PATCH 04/24] ath9k_hw: allow for spliting up ANI operations by family Luis R. Rodriguez
2010-06-12  4:33 ` [PATCH 05/24] ath9k_hw: add register definitions for the new ANI Luis R. Rodriguez
2010-06-12  4:33 ` [PATCH 06/24] ath9k_hw: inform ANI calibration when scanning Luis R. Rodriguez
2010-06-12  4:33 ` [PATCH 07/24] ath9k: add new ANI implementation for AR9003 Luis R. Rodriguez
2010-06-12  4:33 ` [PATCH 08/24] ath9k_hw: enable ANI " Luis R. Rodriguez
2010-06-12  4:33 ` [PATCH 09/24] ath9k_hw: reduce delay on programming INI on AR9003 Luis R. Rodriguez
2010-06-12  4:33 ` [PATCH 10/24] ath9k_hw: update 5 GHz tx gain tables for femless and high power PA Luis R. Rodriguez
2010-06-12  4:33 ` [PATCH 11/24] ath9k: fix mac80211 queue lookup for waking up queues Luis R. Rodriguez
2010-06-12  4:33 ` [PATCH 12/24] ath9k_htc: use common WMM AC definitions instead of ath9k ones Luis R. Rodriguez
2010-06-12  4:33 ` [PATCH 13/24] ath9k: remove duplicate WMM AC definitions Luis R. Rodriguez
2010-06-12  4:33 ` [PATCH 14/24] ath9k: remove declarations of some nonexistant functions Luis R. Rodriguez
2010-06-12  4:33 ` [PATCH 15/24] ath9k: make ath_get_hal_qnum static Luis R. Rodriguez
2010-06-12  4:33 ` Luis R. Rodriguez [this message]
2010-06-12  4:33 ` [PATCH 17/24] ath9k: fix queue stopping threshold Luis R. Rodriguez
2010-06-12  4:33 ` [PATCH 18/24] ath9k: add a debugfs entry for ignoring CCA on the extension channel in HT40 Luis R. Rodriguez
2010-06-12  4:33 ` [PATCH 19/24] ath9k_hw: remove a useless function for setting the mac address Luis R. Rodriguez
2010-06-12  4:33 ` [PATCH 20/24] ath9k_hw: add register definitions related to PA predistortion Luis R. Rodriguez
2010-06-12  4:33 ` [PATCH 21/24] ath9k_hw: add support for parsing PA predistortion related EEPROM fields Luis R. Rodriguez
2010-06-12  4:34 ` [PATCH 22/24] ath9k_hw: add functions for controlling PA predistortion calibration Luis R. Rodriguez
2010-06-12  4:34 ` [PATCH 23/24] ath9k: implement PA predistortion support Luis R. Rodriguez
2010-06-12  4:34 ` [PATCH 24/24] ath9k: enable AR9003 PCI IDs Luis R. Rodriguez

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1276317242-15540-17-git-send-email-lrodriguez@atheros.com \
    --to=lrodriguez@atheros.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    --cc=nbd@openwrt.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox