ath9k: move struct ath_ani to common area
This can be shared between ath9k and ath9k_htc. It will also help with sharing routine helpers on the RX path. Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
This commit is contained in:
parent
30cbd42265
commit
3d536acf45
@ -23,6 +23,16 @@
|
|||||||
|
|
||||||
static const u8 ath_bcast_mac[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
|
static const u8 ath_bcast_mac[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
|
||||||
|
|
||||||
|
struct ath_ani {
|
||||||
|
bool caldone;
|
||||||
|
int16_t noise_floor;
|
||||||
|
unsigned int longcal_timer;
|
||||||
|
unsigned int shortcal_timer;
|
||||||
|
unsigned int resetcal_timer;
|
||||||
|
unsigned int checkani_timer;
|
||||||
|
struct timer_list timer;
|
||||||
|
};
|
||||||
|
|
||||||
enum ath_device_state {
|
enum ath_device_state {
|
||||||
ATH_HW_UNAVAILABLE,
|
ATH_HW_UNAVAILABLE,
|
||||||
ATH_HW_INITIALIZED,
|
ATH_HW_INITIALIZED,
|
||||||
@ -66,6 +76,8 @@ struct ath_common {
|
|||||||
int debug_mask;
|
int debug_mask;
|
||||||
enum ath_device_state state;
|
enum ath_device_state state;
|
||||||
|
|
||||||
|
struct ath_ani ani;
|
||||||
|
|
||||||
u16 cachelsz;
|
u16 cachelsz;
|
||||||
u16 curaid;
|
u16 curaid;
|
||||||
u8 macaddr[ETH_ALEN];
|
u8 macaddr[ETH_ALEN];
|
||||||
|
@ -434,16 +434,6 @@ void ath_beacon_return(struct ath_softc *sc, struct ath_vif *avp);
|
|||||||
#define ATH_LONG_CALINTERVAL 30000 /* 30 seconds */
|
#define ATH_LONG_CALINTERVAL 30000 /* 30 seconds */
|
||||||
#define ATH_RESTART_CALINTERVAL 1200000 /* 20 minutes */
|
#define ATH_RESTART_CALINTERVAL 1200000 /* 20 minutes */
|
||||||
|
|
||||||
struct ath_ani {
|
|
||||||
bool caldone;
|
|
||||||
int16_t noise_floor;
|
|
||||||
unsigned int longcal_timer;
|
|
||||||
unsigned int shortcal_timer;
|
|
||||||
unsigned int resetcal_timer;
|
|
||||||
unsigned int checkani_timer;
|
|
||||||
struct timer_list timer;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Defines the BT AR_BT_COEX_WGHT used */
|
/* Defines the BT AR_BT_COEX_WGHT used */
|
||||||
enum ath_stomp_type {
|
enum ath_stomp_type {
|
||||||
ATH_BTCOEX_NO_STOMP,
|
ATH_BTCOEX_NO_STOMP,
|
||||||
@ -601,7 +591,6 @@ struct ath_softc {
|
|||||||
|
|
||||||
int beacon_interval;
|
int beacon_interval;
|
||||||
|
|
||||||
struct ath_ani ani;
|
|
||||||
#ifdef CONFIG_ATH9K_DEBUG
|
#ifdef CONFIG_ATH9K_DEBUG
|
||||||
struct ath9k_debug debug;
|
struct ath9k_debug debug;
|
||||||
#endif
|
#endif
|
||||||
|
@ -405,34 +405,34 @@ static void ath_ani_calibrate(unsigned long data)
|
|||||||
ath9k_ps_wakeup(sc);
|
ath9k_ps_wakeup(sc);
|
||||||
|
|
||||||
/* Long calibration runs independently of short calibration. */
|
/* Long calibration runs independently of short calibration. */
|
||||||
if ((timestamp - sc->ani.longcal_timer) >= ATH_LONG_CALINTERVAL) {
|
if ((timestamp - common->ani.longcal_timer) >= ATH_LONG_CALINTERVAL) {
|
||||||
longcal = true;
|
longcal = true;
|
||||||
ath_print(common, ATH_DBG_ANI, "longcal @%lu\n", jiffies);
|
ath_print(common, ATH_DBG_ANI, "longcal @%lu\n", jiffies);
|
||||||
sc->ani.longcal_timer = timestamp;
|
common->ani.longcal_timer = timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Short calibration applies only while caldone is false */
|
/* Short calibration applies only while caldone is false */
|
||||||
if (!sc->ani.caldone) {
|
if (!common->ani.caldone) {
|
||||||
if ((timestamp - sc->ani.shortcal_timer) >= short_cal_interval) {
|
if ((timestamp - common->ani.shortcal_timer) >= short_cal_interval) {
|
||||||
shortcal = true;
|
shortcal = true;
|
||||||
ath_print(common, ATH_DBG_ANI,
|
ath_print(common, ATH_DBG_ANI,
|
||||||
"shortcal @%lu\n", jiffies);
|
"shortcal @%lu\n", jiffies);
|
||||||
sc->ani.shortcal_timer = timestamp;
|
common->ani.shortcal_timer = timestamp;
|
||||||
sc->ani.resetcal_timer = timestamp;
|
common->ani.resetcal_timer = timestamp;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ((timestamp - sc->ani.resetcal_timer) >=
|
if ((timestamp - common->ani.resetcal_timer) >=
|
||||||
ATH_RESTART_CALINTERVAL) {
|
ATH_RESTART_CALINTERVAL) {
|
||||||
sc->ani.caldone = ath9k_hw_reset_calvalid(ah);
|
common->ani.caldone = ath9k_hw_reset_calvalid(ah);
|
||||||
if (sc->ani.caldone)
|
if (common->ani.caldone)
|
||||||
sc->ani.resetcal_timer = timestamp;
|
common->ani.resetcal_timer = timestamp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Verify whether we must check ANI */
|
/* Verify whether we must check ANI */
|
||||||
if ((timestamp - sc->ani.checkani_timer) >= ATH_ANI_POLLINTERVAL) {
|
if ((timestamp - common->ani.checkani_timer) >= ATH_ANI_POLLINTERVAL) {
|
||||||
aniflag = true;
|
aniflag = true;
|
||||||
sc->ani.checkani_timer = timestamp;
|
common->ani.checkani_timer = timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Skip all processing if there's nothing to do. */
|
/* Skip all processing if there's nothing to do. */
|
||||||
@ -443,21 +443,21 @@ static void ath_ani_calibrate(unsigned long data)
|
|||||||
|
|
||||||
/* Perform calibration if necessary */
|
/* Perform calibration if necessary */
|
||||||
if (longcal || shortcal) {
|
if (longcal || shortcal) {
|
||||||
sc->ani.caldone =
|
common->ani.caldone =
|
||||||
ath9k_hw_calibrate(ah,
|
ath9k_hw_calibrate(ah,
|
||||||
ah->curchan,
|
ah->curchan,
|
||||||
common->rx_chainmask,
|
common->rx_chainmask,
|
||||||
longcal);
|
longcal);
|
||||||
|
|
||||||
if (longcal)
|
if (longcal)
|
||||||
sc->ani.noise_floor = ath9k_hw_getchan_noise(ah,
|
common->ani.noise_floor = ath9k_hw_getchan_noise(ah,
|
||||||
ah->curchan);
|
ah->curchan);
|
||||||
|
|
||||||
ath_print(common, ATH_DBG_ANI,
|
ath_print(common, ATH_DBG_ANI,
|
||||||
" calibrate chan %u/%x nf: %d\n",
|
" calibrate chan %u/%x nf: %d\n",
|
||||||
ah->curchan->channel,
|
ah->curchan->channel,
|
||||||
ah->curchan->channelFlags,
|
ah->curchan->channelFlags,
|
||||||
sc->ani.noise_floor);
|
common->ani.noise_floor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -473,21 +473,21 @@ set_timer:
|
|||||||
cal_interval = ATH_LONG_CALINTERVAL;
|
cal_interval = ATH_LONG_CALINTERVAL;
|
||||||
if (sc->sc_ah->config.enable_ani)
|
if (sc->sc_ah->config.enable_ani)
|
||||||
cal_interval = min(cal_interval, (u32)ATH_ANI_POLLINTERVAL);
|
cal_interval = min(cal_interval, (u32)ATH_ANI_POLLINTERVAL);
|
||||||
if (!sc->ani.caldone)
|
if (!common->ani.caldone)
|
||||||
cal_interval = min(cal_interval, (u32)short_cal_interval);
|
cal_interval = min(cal_interval, (u32)short_cal_interval);
|
||||||
|
|
||||||
mod_timer(&sc->ani.timer, jiffies + msecs_to_jiffies(cal_interval));
|
mod_timer(&common->ani.timer, jiffies + msecs_to_jiffies(cal_interval));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ath_start_ani(struct ath_softc *sc)
|
static void ath_start_ani(struct ath_common *common)
|
||||||
{
|
{
|
||||||
unsigned long timestamp = jiffies_to_msecs(jiffies);
|
unsigned long timestamp = jiffies_to_msecs(jiffies);
|
||||||
|
|
||||||
sc->ani.longcal_timer = timestamp;
|
common->ani.longcal_timer = timestamp;
|
||||||
sc->ani.shortcal_timer = timestamp;
|
common->ani.shortcal_timer = timestamp;
|
||||||
sc->ani.checkani_timer = timestamp;
|
common->ani.checkani_timer = timestamp;
|
||||||
|
|
||||||
mod_timer(&sc->ani.timer,
|
mod_timer(&common->ani.timer,
|
||||||
jiffies + msecs_to_jiffies(ATH_ANI_POLLINTERVAL));
|
jiffies + msecs_to_jiffies(ATH_ANI_POLLINTERVAL));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1023,12 +1023,12 @@ static void ath9k_bss_assoc_info(struct ath_softc *sc,
|
|||||||
/* Reset rssi stats */
|
/* Reset rssi stats */
|
||||||
sc->sc_ah->stats.avgbrssi = ATH_RSSI_DUMMY_MARKER;
|
sc->sc_ah->stats.avgbrssi = ATH_RSSI_DUMMY_MARKER;
|
||||||
|
|
||||||
ath_start_ani(sc);
|
ath_start_ani(common);
|
||||||
} else {
|
} else {
|
||||||
ath_print(common, ATH_DBG_CONFIG, "Bss Info DISASSOC\n");
|
ath_print(common, ATH_DBG_CONFIG, "Bss Info DISASSOC\n");
|
||||||
common->curaid = 0;
|
common->curaid = 0;
|
||||||
/* Stop ANI */
|
/* Stop ANI */
|
||||||
del_timer_sync(&sc->ani.timer);
|
del_timer_sync(&common->ani.timer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1761,8 +1761,8 @@ static int ath_init_softc(u16 devid, struct ath_softc *sc, u16 subsysid,
|
|||||||
/* Initializes the noise floor to a reasonable default value.
|
/* Initializes the noise floor to a reasonable default value.
|
||||||
* Later on this will be updated during ANI processing. */
|
* Later on this will be updated during ANI processing. */
|
||||||
|
|
||||||
sc->ani.noise_floor = ATH_DEFAULT_NOISE_FLOOR;
|
common->ani.noise_floor = ATH_DEFAULT_NOISE_FLOOR;
|
||||||
setup_timer(&sc->ani.timer, ath_ani_calibrate, (unsigned long)sc);
|
setup_timer(&common->ani.timer, ath_ani_calibrate, (unsigned long)sc);
|
||||||
|
|
||||||
if (ath9k_hw_getcapability(ah, ATH9K_CAP_CIPHER,
|
if (ath9k_hw_getcapability(ah, ATH9K_CAP_CIPHER,
|
||||||
ATH9K_CIPHER_TKIP, NULL)) {
|
ATH9K_CIPHER_TKIP, NULL)) {
|
||||||
@ -2634,7 +2634,7 @@ static int ath9k_add_interface(struct ieee80211_hw *hw,
|
|||||||
if (conf->type == NL80211_IFTYPE_AP ||
|
if (conf->type == NL80211_IFTYPE_AP ||
|
||||||
conf->type == NL80211_IFTYPE_ADHOC ||
|
conf->type == NL80211_IFTYPE_ADHOC ||
|
||||||
conf->type == NL80211_IFTYPE_MONITOR)
|
conf->type == NL80211_IFTYPE_MONITOR)
|
||||||
ath_start_ani(sc);
|
ath_start_ani(common);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
mutex_unlock(&sc->mutex);
|
mutex_unlock(&sc->mutex);
|
||||||
@ -2655,7 +2655,7 @@ static void ath9k_remove_interface(struct ieee80211_hw *hw,
|
|||||||
mutex_lock(&sc->mutex);
|
mutex_lock(&sc->mutex);
|
||||||
|
|
||||||
/* Stop ANI */
|
/* Stop ANI */
|
||||||
del_timer_sync(&sc->ani.timer);
|
del_timer_sync(&common->ani.timer);
|
||||||
|
|
||||||
/* Reclaim beacon resources */
|
/* Reclaim beacon resources */
|
||||||
if ((sc->sc_ah->opmode == NL80211_IFTYPE_AP) ||
|
if ((sc->sc_ah->opmode == NL80211_IFTYPE_AP) ||
|
||||||
|
@ -102,6 +102,7 @@ static int ath_rx_prepare(struct ieee80211_hw *hw,
|
|||||||
struct ieee80211_sta *sta;
|
struct ieee80211_sta *sta;
|
||||||
struct ath_node *an;
|
struct ath_node *an;
|
||||||
int last_rssi = ATH_RSSI_DUMMY_MARKER;
|
int last_rssi = ATH_RSSI_DUMMY_MARKER;
|
||||||
|
struct ath_common *common = ath9k_hw_common(sc->sc_ah);
|
||||||
|
|
||||||
hdr = (struct ieee80211_hdr *)skb->data;
|
hdr = (struct ieee80211_hdr *)skb->data;
|
||||||
fc = hdr->frame_control;
|
fc = hdr->frame_control;
|
||||||
@ -212,7 +213,7 @@ static int ath_rx_prepare(struct ieee80211_hw *hw,
|
|||||||
rx_status->mactime = ath9k_hw_extend_tsf(sc->sc_ah, rx_stats->rs_tstamp);
|
rx_status->mactime = ath9k_hw_extend_tsf(sc->sc_ah, rx_stats->rs_tstamp);
|
||||||
rx_status->band = hw->conf.channel->band;
|
rx_status->band = hw->conf.channel->band;
|
||||||
rx_status->freq = hw->conf.channel->center_freq;
|
rx_status->freq = hw->conf.channel->center_freq;
|
||||||
rx_status->noise = sc->ani.noise_floor;
|
rx_status->noise = common->ani.noise_floor;
|
||||||
rx_status->signal = ATH_DEFAULT_NOISE_FLOOR + rx_stats->rs_rssi;
|
rx_status->signal = ATH_DEFAULT_NOISE_FLOOR + rx_stats->rs_rssi;
|
||||||
rx_status->antenna = rx_stats->rs_antenna;
|
rx_status->antenna = rx_stats->rs_antenna;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user