2009-02-09 15:56:54 +08:00
|
|
|
/*
|
2011-05-17 16:06:18 +08:00
|
|
|
* Copyright (c) 2008-2011 Atheros Communications Inc.
|
2009-02-09 15:56:54 +08:00
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef CALIB_H
|
|
|
|
#define CALIB_H
|
|
|
|
|
2009-09-13 17:42:02 +08:00
|
|
|
#include "hw.h"
|
|
|
|
|
2009-02-09 15:56:54 +08:00
|
|
|
#define AR_PHY_CCA_FILTERWINDOW_LENGTH 5
|
|
|
|
|
2012-12-10 21:03:17 +08:00
|
|
|
/* Internal noise floor can vary by about 6db depending on the frequency */
|
|
|
|
#define ATH9K_NF_CAL_NOISE_THRESH 6
|
|
|
|
|
2009-02-09 15:56:54 +08:00
|
|
|
#define NUM_NF_READINGS 6
|
|
|
|
#define ATH9K_NF_CAL_HIST_MAX 5
|
|
|
|
|
|
|
|
struct ar5416IniArray {
|
|
|
|
u32 *ia_array;
|
|
|
|
u32 ia_rows;
|
|
|
|
u32 ia_columns;
|
|
|
|
};
|
|
|
|
|
2013-04-08 06:04:08 +08:00
|
|
|
#define STATIC_INI_ARRAY(array) { \
|
|
|
|
.ia_array = (u32 *)(array), \
|
|
|
|
.ia_rows = ARRAY_SIZE(array), \
|
|
|
|
.ia_columns = ARRAY_SIZE(array[0]), \
|
|
|
|
}
|
|
|
|
|
2012-07-16 01:53:33 +08:00
|
|
|
#define INIT_INI_ARRAY(iniarray, array) do { \
|
2009-02-09 15:56:54 +08:00
|
|
|
(iniarray)->ia_array = (u32 *)(array); \
|
2012-07-16 01:53:33 +08:00
|
|
|
(iniarray)->ia_rows = ARRAY_SIZE(array); \
|
|
|
|
(iniarray)->ia_columns = ARRAY_SIZE(array[0]); \
|
2009-02-09 15:56:54 +08:00
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define INI_RA(iniarray, row, column) \
|
|
|
|
(((iniarray)->ia_array)[(row) * ((iniarray)->ia_columns) + (column)])
|
|
|
|
|
|
|
|
#define INIT_CAL(_perCal) do { \
|
|
|
|
(_perCal)->calState = CAL_WAITING; \
|
|
|
|
(_perCal)->calNext = NULL; \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define INSERT_CAL(_ahp, _perCal) \
|
|
|
|
do { \
|
2009-02-09 15:57:26 +08:00
|
|
|
if ((_ahp)->cal_list_last == NULL) { \
|
|
|
|
(_ahp)->cal_list = \
|
|
|
|
(_ahp)->cal_list_last = (_perCal); \
|
|
|
|
((_ahp)->cal_list_last)->calNext = (_perCal); \
|
2009-02-09 15:56:54 +08:00
|
|
|
} else { \
|
2009-02-09 15:57:26 +08:00
|
|
|
((_ahp)->cal_list_last)->calNext = (_perCal); \
|
|
|
|
(_ahp)->cal_list_last = (_perCal); \
|
|
|
|
(_perCal)->calNext = (_ahp)->cal_list; \
|
2009-02-09 15:56:54 +08:00
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
2009-04-14 00:26:56 +08:00
|
|
|
enum ath9k_cal_state {
|
2009-02-09 15:56:54 +08:00
|
|
|
CAL_INACTIVE,
|
|
|
|
CAL_WAITING,
|
|
|
|
CAL_RUNNING,
|
|
|
|
CAL_DONE
|
|
|
|
};
|
|
|
|
|
|
|
|
#define MIN_CAL_SAMPLES 1
|
|
|
|
#define MAX_CAL_SAMPLES 64
|
|
|
|
#define INIT_LOG_COUNT 5
|
|
|
|
#define PER_MIN_LOG_COUNT 2
|
|
|
|
#define PER_MAX_LOG_COUNT 10
|
|
|
|
|
2009-04-14 00:26:56 +08:00
|
|
|
struct ath9k_percal_data {
|
2010-10-04 01:07:16 +08:00
|
|
|
u32 calType;
|
2009-02-09 15:56:54 +08:00
|
|
|
u32 calNumSamples;
|
|
|
|
u32 calCountMax;
|
2009-02-09 15:57:12 +08:00
|
|
|
void (*calCollect) (struct ath_hw *);
|
|
|
|
void (*calPostProc) (struct ath_hw *, u8);
|
2009-02-09 15:56:54 +08:00
|
|
|
};
|
|
|
|
|
2009-04-14 00:26:56 +08:00
|
|
|
struct ath9k_cal_list {
|
|
|
|
const struct ath9k_percal_data *calData;
|
|
|
|
enum ath9k_cal_state calState;
|
|
|
|
struct ath9k_cal_list *calNext;
|
2009-02-09 15:56:54 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ath9k_nfcal_hist {
|
|
|
|
int16_t nfCalBuffer[ATH9K_NF_CAL_HIST_MAX];
|
|
|
|
u8 currIndex;
|
|
|
|
int16_t privNF;
|
|
|
|
u8 invalidNFcount;
|
|
|
|
};
|
|
|
|
|
2009-08-26 11:09:40 +08:00
|
|
|
#define MAX_PACAL_SKIPCOUNT 8
|
|
|
|
struct ath9k_pacal_info{
|
|
|
|
int32_t prev_offset; /* Previous value of PA offset value */
|
|
|
|
int8_t max_skipcount; /* Max No. of times PACAL can be skipped */
|
|
|
|
int8_t skipcount; /* No. of times the PACAL to be skipped */
|
|
|
|
};
|
|
|
|
|
2009-02-09 15:57:12 +08:00
|
|
|
bool ath9k_hw_reset_calvalid(struct ath_hw *ah);
|
2010-07-31 03:02:09 +08:00
|
|
|
void ath9k_hw_start_nfcal(struct ath_hw *ah, bool update);
|
2014-10-25 23:19:30 +08:00
|
|
|
int ath9k_hw_loadnf(struct ath_hw *ah, struct ath9k_channel *chan);
|
2010-07-31 06:12:01 +08:00
|
|
|
bool ath9k_hw_getnf(struct ath_hw *ah, struct ath9k_channel *chan);
|
2010-07-31 06:12:00 +08:00
|
|
|
void ath9k_init_nfcal_hist_buffer(struct ath_hw *ah,
|
|
|
|
struct ath9k_channel *chan);
|
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.
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-08-02 21:53:14 +08:00
|
|
|
void ath9k_hw_bstuck_nfcal(struct ath_hw *ah);
|
2010-04-16 05:39:00 +08:00
|
|
|
void ath9k_hw_reset_calibration(struct ath_hw *ah,
|
|
|
|
struct ath9k_cal_list *currCal);
|
2013-10-11 20:09:54 +08:00
|
|
|
s16 ath9k_hw_getchan_noise(struct ath_hw *ah, struct ath9k_channel *chan,
|
|
|
|
s16 nf);
|
2010-04-16 05:39:00 +08:00
|
|
|
|
2009-02-09 15:56:54 +08:00
|
|
|
|
|
|
|
#endif /* CALIB_H */
|