ath5k: ATIM and timer fixes
cover ath5k: ATIM and timer fixes
The following series adds a check for a hardware condition which can cause an unwanted ATIM window configuration and some other smaller improvements for TSF related things.
---
Bruno Randolf (4):
ath5k: Remove unused variable for atim window
ath5k: Check and fix ATIM window
ath5k: Increase "fudge" for beacon timers
ath5k: Disable interrupts in ath5k_hw_get_tsf64
drivers/net/wireless/ath/ath5k/ath5k.h | 2 - drivers/net/wireless/ath/ath5k/attach.c | 1 drivers/net/wireless/ath/ath5k/base.c | 16 ++++- drivers/net/wireless/ath/ath5k/pcu.c | 99 +++++++++++++++++++++++++++++++ 4 files changed, 113 insertions(+), 5 deletions(-)
--
Signature
PATCH 1/4 ath5k: Remove unused variable for atim window
It's not used and it's unlikely we will ever implement ATIM.
--- drivers/net/wireless/ath/ath5k/ath5k.h | 1 - drivers/net/wireless/ath/ath5k/attach.c | 1 - drivers/net/wireless/ath/ath5k/pcu.c | 2 +- 3 files changed, 1 insertions(+), 3 deletions(-)
drivers/net/wireless/ath/ath5k/ath5k.h +0 -1
@@ -1041,7 +1041,6 @@ struct ath5k_hw {#define ah_modes ah_capabilities.cap_mode#define ah_ee_version ah_capabilities.cap_eeprom.ee_version -u32 ah_atim_window;u32 ah_limit_tx_retries;u8 ah_coverage_class;
drivers/net/wireless/ath/ath5k/attach.c +0 -1
@@ -118,7 +118,6 @@ int ath5k_hw_attach(struct ath5k_softc *sc) ah->ah_turbo = false; ah->ah_txpower.txp_tpc =AR5K_TUNE_TPC_TXPOWER ; ah->ah_imr =0 ; - ah->ah_atim_window =0 ; ah->ah_limit_tx_retries =AR5K_INIT_TX_RETRY ; ah->ah_software_retry = false; ah->ah_ant_mode =AR5K_ANTMODE_DEFAULT ;
drivers/net/wireless/ath/ath5k/pcu.c +1 -1
@@ -600,7 +600,7 @@ void ath5k_hw_init_beacon(struct ath5k_hw *ah, u32 next_beacon, u32 interval)/* Timer3 marks the end of our ATIM window * a zero length window is not allowed because * we 'll get no beacons */ - timer3 = next_beacon + (ah->ah_atim_window ? ah->ah_atim_window :1 ); + timer3 = next_beacon +1 ;/* * Set the beacon register and enable all timers.
PATCH 2/4 ath5k: Check and fix ATIM window
In reply to Bruno RandolfThis patch adds sanity-checks for the beacon timers and especially the ATIM window to ath5k. It is basically the same what i did for madwifi two years ago and fixes a problem in IBSS mode which has been described as "ramping" pings.
See the code comments for a more detailed description and these links:
http://madwifi-project.org/ticket/1154
http://madwifi-project.org/changeset/3867
http://thread.gmane.org/gmane.linux.drivers.madwifi.devel/6066
--- drivers/net/wireless/ath/ath5k/ath5k.h | 1 drivers/net/wireless/ath/ath5k/base.c | 9 +++ drivers/net/wireless/ath/ath5k/pcu.c | 91 ++++++++++++++++++++++++++++++++ 3 files changed, 101 insertions(+), 0 deletions(-)
drivers/net/wireless/ath/ath5k/ath5k.h +1 -0
@@ -1195,6 +1195,7 @@ u64 ath5k_hw_get_tsf64(struct ath5k_hw *ah);void ath5k_hw_set_tsf64 (struct ath5k_hw *ah,u64 tsf64);void ath5k_hw_reset_tsf (struct ath5k_hw *ah);void ath5k_hw_init_beacon (struct ath5k_hw *ah,u32 next_beacon,u32 interval); +bool ath5k_hw_check_beacon_timers (struct ath5k_hw *ah,int intval);/* ACK bit rate */ void ath5k_hw_set_ack_bitrate_high (struct ath5k_hw *ah,bool high);/* Clock rate related functions */
drivers/net/wireless/ath/ath5k/base.c +9 -0
@@ -1191,6 +1191,15 @@ ath5k_check_ibss_tsf(struct ath5k_softc *sc, struct sk_buff *skb,*/ if (hw_tu >= sc->nexttbtt)ath5k_beacon_update_timers (sc, bc_tstamp); + +/* Check if the beacon timers are still correct, because a TSF +* update might have created a window between them - for a +* longer description see the comment of this function: */ +if (!ath5k_hw_check_beacon_timers (sc->ah, sc->bintval)) { +ath5k_beacon_update_timers (sc, bc_tstamp); +ATH5K_DBG_UNLIMIT (sc,ATH5K_DEBUG_BEACON , +"fixed beacon timers after beacon receive\n" ); + } } }
drivers/net/wireless/ath/ath5k/pcu.c +91 -0
97 lines not on this page · raw message
PATCH 3/4 ath5k: Increase "fudge" for beacon timers
In reply to Bruno RandolfWe use FUDGE to make sure the next TBTT is ahead of the current TU. Since we later substract AR5K_TUNE_SW_BEACON_RESP (10) in the timer configuration we need to make sure it is bigger than that.
--- drivers/net/wireless/ath/ath5k/base.c | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath5k/base.c +5 -2
@@ -1886,8 +1886,11 @@ ath5k_beacon_update_timers(struct ath5k_softc *sc, u64 bc_tsf) hw_tsf =ath5k_hw_get_tsf64 (ah); hw_tu =TSF_TO_TU (hw_tsf); -#define FUDGE 3 -/* we use FUDGE to make sure the next TBTT is ahead of the current TU */ +#define FUDGE AR5K_TUNE_SW_BEACON_RESP + 3 +/* We use FUDGE to make sure the next TBTT is ahead of the current TU. +* Since we later substract AR5K_TUNE_SW_BEACON_RESP (10) in the timer +* configuration we need to make sure it is bigger than that. */ +if (bc_tsf ==-1 ) {/* * no beacons received, called internally.
PATCH 4/4 ath5k: Disable interrupts in ath5k_hw_get_tsf64
In reply to Bruno RandolfThe code in ath5k_hw_get_tsf64() is time critical and will return wrong results if we get interrupted, so disable local interrupts.
--- drivers/net/wireless/ath/ath5k/pcu.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
drivers/net/wireless/ath/ath5k/pcu.c +6 -0
@@ -495,6 +495,10 @@ u64 ath5k_hw_get_tsf64(struct ath5k_hw *ah) {u32 tsf_lower, tsf_upper1, tsf_upper2;int i; +unsigned long flags; + +/* This code is time critical - we don't want to be interrupted here */ +local_irq_save (flags);/* * While reading TSF upper and then lower part, the clock is still
@@ -517,6 +521,8 @@ u64 ath5k_hw_get_tsf64(struct ath5k_hw *ah) tsf_upper1 = tsf_upper2; } +local_irq_restore (flags); +WARN_ON ( i ==ATH5K_MAX_TSF_READ );return (((u64 )tsf_upper1 <<32 ) | tsf_lower);