ath9k: add a separate debug level for stuck beacons
PATCH 1/4 ath9k: add a separate debug level for stuck beacons
Stuck beacons are a useful indicator for debugging various PHY issues such as calibration. Putting them on the same debug level as the other beacon stuff makes it hard to spot them in huge amounts of spam.
--- drivers/net/wireless/ath/ath9k/beacon.c | 6 +++--- drivers/net/wireless/ath/debug.h | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-)
drivers/net/wireless/ath/ath9k/beacon.c +3 -3
@@ -359,11 +359,11 @@ void ath_beacon_tasklet(unsigned long data) sc->beacon.bmisscnt++;if (sc->beacon.bmisscnt <BSTUCK_THRESH ) { -ath_print (common,ATH_DBG_BEACON , +ath_print (common,ATH_DBG_BSTUCK ,"missed %u consecutive beacons\n" , sc->beacon.bmisscnt); }else if (sc->beacon.bmisscnt >=BSTUCK_THRESH ) { -ath_print (common,ATH_DBG_BEACON , +ath_print (common,ATH_DBG_BSTUCK ,"beacon is officially stuck\n" ); sc->sc_flags |=SC_OP_TSF_RESET ;ath_reset (sc, false);
@@ -373,7 +373,7 @@ void ath_beacon_tasklet(unsigned long data) }if (sc->beacon.bmisscnt !=0 ) { -ath_print (common,ATH_DBG_BEACON , +ath_print (common,ATH_DBG_BSTUCK ,"resume beacon xmit after %u misses\n" , sc->beacon.bmisscnt); sc->beacon.bmisscnt =0 ;
drivers/net/wireless/ath/debug.h +2 -0
@@ -36,6 +36,7 @@* @ATH_DBG_PS: power save processing * @ATH_DBG_HWTIMER: hardware timer handling * @ATH_DBG_BTCOEX: bluetooth coexistance +* @ATH_DBG_BSTUCK: stuck beacons * @ATH_DBG_ANY: enable all debugging * * The debug level is used to control the amount and type of debugging output
@@ -60,6 +61,7 @@ enum ATH_DEBUG {ATH_DBG_HWTIMER =0x00001000 ,ATH_DBG_BTCOEX =0x00002000 ,ATH_DBG_WMI =0x00004000 , +ATH_DBG_BSTUCK =0x00008000 , ATH_DBG_ANY = 0xffffffff };
Signature · 1 line
1.6.4.2
PATCH 2/4 ath9k_hw: apply the noise floor validation to the median instead of single
--- drivers/net/wireless/ath/ath9k/calib.c | 51 ++++++++++++++++++++------------ 1 files changed, 32 insertions(+), 19 deletions(-)
drivers/net/wireless/ath/ath9k/calib.c +32 -19
@@ -19,8 +19,7 @@/* Common calibration code */ -/* We can tune this as we go by monitoring really low values */ -#define ATH9K_NF_TOO_LOW -60 +#define ATH9K_NF_TOO_HIGH -60static int16_t ath9k_hw_get_nf_hist_mid (int16_t *nfCalBuffer) {
@@ -45,11 +44,35 @@ static int16_t ath9k_hw_get_nf_hist_mid(int16_t *nfCalBuffer)return nfval; } -static void ath9k_hw_update_nfcal_hist_buffer (struct ath9k_nfcal_hist *h, +static struct ath_nf_limits *ath9k_hw_get_nf_limits (struct ath_hw *ah, +struct ath9k_channel *chan) +{ +struct ath_nf_limits *limit; + +if (!chan ||IS_CHAN_2GHZ (chan)) + limit = &ah->nf_2g; +else + limit = &ah->nf_5g; + +return limit; +} + +static s16 ath9k_hw_get_default_nf (struct ath_hw *ah, +struct ath9k_channel *chan) +{ +return ath9k_hw_get_nf_limits (ah, chan)->nominal; +} + + +static void ath9k_hw_update_nfcal_hist_buffer (struct ath_hw *ah, +struct ath9k_nfcal_hist *h,int16_t *nfarray) { +struct ath_nf_limits *limit;int i; + limit =ath9k_hw_get_nf_limits (ah, ah->curchan); +for (i =0 ; i <NUM_NF_READINGS ; i++) { h[i].nfCalBuffer[h[i].currIndex] = nfarray[i];
@@ -63,6 +86,9 @@ static void ath9k_hw_update_nfcal_hist_buffer(struct ath9k_nfcal_hist *h, h[i].privNF =ath9k_hw_get_nf_hist_mid (h[i].nfCalBuffer); } + +if (h[i].privNF > limit->max) + h[i].privNF = limit->max; } }
@@ -104,19 +130,6 @@ void ath9k_hw_reset_calibration(struct ath_hw *ah, ah->cal_samples =0 ; } -static s16 ath9k_hw_get_default_nf (struct ath_hw *ah, -struct ath9k_channel *chan) -{ -struct ath_nf_limits *limit; - -if (!chan ||IS_CHAN_2GHZ (chan)) - limit = &ah->nf_2g; -else - limit = &ah->nf_5g; - -return limit->nominal; -} -/* This is done for the currently configured channel */ bool ath9k_hw_reset_calvalid (struct ath_hw *ah) {
@@ -277,10 +290,10 @@ static void ath9k_hw_nf_sanitize(struct ath_hw *ah, s16 *nf)"NF calibrated [%s] [chain %d] is %d\n" , (i >= 3 ? "ext" : "ctl"), i % 3, nf[i]); -if (nf[i] > limit->max) { +if (nf[i] >ATH9K_NF_TOO_HIGH ) {ath_print (common,ATH_DBG_CALIBRATE ,"NF[%d] (%d) > MAX (%d), correcting to MAX" , - i, nf[i], limit->max); + i, nf[i],ATH9K_NF_TOO_HIGH ); nf[i] = limit->max; }else if (nf[i] < limit->min) { ath_print(common, ATH_DBG_CALIBRATE,
@@ -326,7 +339,7 @@ bool ath9k_hw_getnf(struct ath_hw *ah, struct ath9k_channel *chan) h = caldata->nfCalHist; caldata->nfcal_pending = false; -ath9k_hw_update_nfcal_hist_buffer (h, nfarray); +ath9k_hw_update_nfcal_hist_buffer (ah, h, nfarray); caldata->rawNoiseFloor = h[0 ].privNF;return true; }
Signature · 1 line
1.6.4.2
PATCH 3/4 ath9k: use AP beacon miss as a trigger for fast recalibration
When beacons get stuck in AP mode, the most likely cause is interference. Such interference can often go on for a while, and too many consecutive beacon misses can lead to connected clients getting dropped.
Since connected clients might not be subjected to the same interference if that happens to be very local, the AP should try to deal with it as good as it can. One way to do this is to trigger an NF calibration with automatic baseband update right after the beacon miss. In my tests with very strong interference, this allowed the AP to continue transmitting beacons after only 2-3 misses, which allows a normal client to stay connected.
With some of the newer - really sensitive - chips, the maximum noise floor limit is very low, which can be problematic during very strong interference. To avoid an endless loop of stuck beacons -> nfcal -> periodic calibration -> stuck beacons, the beacon miss event also sets a flag, which allows the calibration code to bypass the chip specific maximum NF value. This flag is automatically cleared, as soon as the first NF median goes back below the limits for all chains.
In my tests, this allowed an ath9k AP to survive very strong interference (measured NF: -68, or sometimes even higher) without losing connectivity to its clients. Even under these conditions, I was able to transmit several mbits/s through the interface.
--- drivers/net/wireless/ath/ath9k/beacon.c | 1 + drivers/net/wireless/ath/ath9k/calib.c | 66 +++++++++++++++++++++++++++++-- drivers/net/wireless/ath/ath9k/calib.h | 1 + drivers/net/wireless/ath/ath9k/hw.h | 1 + 4 files changed, 65 insertions(+), 4 deletions(-)
drivers/net/wireless/ath/ath9k/beacon.c +1 -0
@@ -362,6 +362,7 @@ void ath_beacon_tasklet(unsigned long data)ath_print (common,ATH_DBG_BSTUCK ,"missed %u consecutive beacons\n" , sc->beacon.bmisscnt); +ath9k_hw_bstuck_nfcal (ah); }else if (sc->beacon.bmisscnt >=BSTUCK_THRESH ) {ath_print (common,ATH_DBG_BSTUCK ,"beacon is officially stuck\n" );
drivers/net/wireless/ath/ath9k/calib.c +62 -4
93 lines not on this page · raw message
drivers/net/wireless/ath/ath9k/calib.h +1 -0
@@ -113,6 +113,7 @@ void ath9k_hw_loadnf(struct ath_hw *ah, struct ath9k_channel *chan);bool ath9k_hw_getnf (struct ath_hw *ah,struct ath9k_channel *chan);void ath9k_init_nfcal_hist_buffer (struct ath_hw *ah,struct ath9k_channel *chan); +void ath9k_hw_bstuck_nfcal (struct ath_hw *ah);s16 ath9k_hw_getchan_noise (struct ath_hw *ah,struct ath9k_channel *chan);void ath9k_hw_reset_calibration (struct ath_hw *ah,struct ath9k_cal_list *currCal);
drivers/net/wireless/ath/ath9k/hw.h +1 -0
@@ -355,6 +355,7 @@ struct ath9k_hw_cal_data {int16_t rawNoiseFloor;bool paprd_done;bool nfcal_pending; +bool nfcal_interference;u16 small_signal_gain[AR9300_MAX_CHAINS ];u32 pa_table[AR9300_MAX_CHAINS ][PAPRD_TABLE_SZ ];struct ath9k_nfcal_hist nfCalHist[NUM_NF_READINGS ];
Signature · 1 line
1.6.4.2
PATCH 4/4 ath9k: shorten the calibration interval during strong interference
When the noise floor limits are being bypassed because of strong interference, sensitivity is also reduced.
In order to recover from this as quickly as possible, trigger a long periodic calibration every second instead of every 30 seconds, until the NF median is within limits again. This is especially important if the interference lasts for a while, since it takes multiple clean NF calibrations to bring the median back to normal.
--- drivers/net/wireless/ath/ath9k/ath9k.h | 1 + drivers/net/wireless/ath/ath9k/main.c | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath9k/ath9k.h +1 -0
@@ -423,6 +423,7 @@ int ath_beaconq_config(struct ath_softc *sc);#define ATH_AP_SHORT_CALINTERVAL 100/* 100 ms */ #define ATH_ANI_POLLINTERVAL_OLD 100/* 100 ms */ #define ATH_ANI_POLLINTERVAL_NEW 1000/* 1000 ms */ +#define ATH_LONG_CALINTERVAL_INT 1000/* 1000 ms */ #define ATH_LONG_CALINTERVAL 30000/* 30 seconds */ #define ATH_RESTART_CALINTERVAL 1200000/* 20 minutes */
drivers/net/wireless/ath/ath9k/main.c +7 -2
@@ -395,7 +395,12 @@ void ath_ani_calibrate(unsigned long data)bool shortcal = false;bool aniflag = false;unsigned int timestamp =jiffies_to_msecs (jiffies); -u32 cal_interval, short_cal_interval; +u32 cal_interval, short_cal_interval, long_cal_interval; + +if (ah->caldata && ah->caldata->nfcal_interference) + long_cal_interval =ATH_LONG_CALINTERVAL_INT ; +else + long_cal_interval =ATH_LONG_CALINTERVAL ; short_cal_interval = (ah->opmode ==NL80211_IFTYPE_AP ) ?ATH_AP_SHORT_CALINTERVAL :ATH_STA_SHORT_CALINTERVAL ;
@@ -407,7 +412,7 @@ void ath_ani_calibrate(unsigned long data)ath9k_ps_wakeup (sc);/* Long calibration runs independently of short calibration. */ -if ((timestamp - common->ani.longcal_timer) >=ATH_LONG_CALINTERVAL ) { +if ((timestamp - common->ani.longcal_timer) >= long_cal_interval) { longcal = true;ath_print (common,ATH_DBG_ANI ,"longcal @%lu\n" , jiffies); common->ani.longcal_timer = timestamp;
Signature · 1 line
1.6.4.2