ANI support for ath5k
Subsystems (3)
cover ANI support for ath5k
Hi all,
I spent a day reorganizing the ath9k ANI code so that it can also be used by ath5k. So here's a first version that actually boots, though I can't say yet whether it is better or not compared to with no ANI. Please test and let us know how it goes.
TODO
- Need to somehow fix the registers that ath5k does not have. Right now, patch 4 just ifdefs that code out.
- The rxfilter callback is kind of cheesy, maybe that can be a shared implementation too.
- Should we do it this way, or would a parallel implementation in each driver be better?
- What about ar9170/other atheros gear? Do the phy registers line up enough to have it in the shared module?
Bob Copeland (4):
ath: move opmode into ath_common struct
ath: add macros for other ath9k register functions
ath9k: move ANI into ath common module
ath5k: implement ANI
drivers/net/wireless/ath/Makefile | 3 +-
drivers/net/wireless/ath/{ath9k => }/ani.c | 444 +++++++++++++++-------------
drivers/net/wireless/ath/ani.h | 57 ++++
drivers/net/wireless/ath/ath.h | 90 ++++++-
drivers/net/wireless/ath/ath5k/ath5k.h | 4 +
drivers/net/wireless/ath/ath5k/attach.c | 7 +
drivers/net/wireless/ath/ath5k/base.c | 111 ++++----
drivers/net/wireless/ath/ath5k/base.h | 1 -
drivers/net/wireless/ath/ath5k/pcu.c | 24 ++-
drivers/net/wireless/ath/ath5k/phy.c | 24 ++-
drivers/net/wireless/ath/ath9k/Makefile | 1 -
drivers/net/wireless/ath/ath9k/ani.h | 123 --------
drivers/net/wireless/ath/ath9k/beacon.c | 10 +-
drivers/net/wireless/ath/ath9k/common.c | 6 +-
drivers/net/wireless/ath/ath9k/hw.c | 40 ++-
drivers/net/wireless/ath/ath9k/hw.h | 16 +-
drivers/net/wireless/ath/ath9k/mac.c | 6 +-
drivers/net/wireless/ath/ath9k/main.c | 21 +-
drivers/net/wireless/ath/ath9k/rc.c | 10 +-
drivers/net/wireless/ath/ath9k/recv.c | 11 +-
drivers/net/wireless/ath/ath9k/xmit.c | 4 +-
drivers/net/wireless/ath/hw.c | 4 +-
drivers/net/wireless/ath/hw.h | 32 ++
drivers/net/wireless/ath/reg.h | 134 +++++++++
24 files changed, 720 insertions(+), 463 deletions(-)
rename drivers/net/wireless/ath/{ath9k => }/ani.c (62%)
create mode 100644 drivers/net/wireless/ath/ani.h
delete mode 100644 drivers/net/wireless/ath/ath9k/ani.h
create mode 100644 drivers/net/wireless/ath/hw.hPATCH 1/4 ath: move opmode into ath_common struct
In order to access the operating mode in common code, move opmode to the ath_common struct from the respective context structs in ath5k/ath9k.
--- drivers/net/wireless/ath/ath.h | 1 + drivers/net/wireless/ath/ath5k/base.c | 42 +++++++++++++++--------------- drivers/net/wireless/ath/ath5k/base.h | 1 - drivers/net/wireless/ath/ath9k/ani.c | 19 ++++++++------ drivers/net/wireless/ath/ath9k/beacon.c | 10 +++--- drivers/net/wireless/ath/ath9k/common.c | 3 +- drivers/net/wireless/ath/ath9k/hw.c | 15 ++++++----- drivers/net/wireless/ath/ath9k/hw.h | 1 - drivers/net/wireless/ath/ath9k/main.c | 14 +++++----- drivers/net/wireless/ath/ath9k/rc.c | 10 ++++--- drivers/net/wireless/ath/ath9k/recv.c | 11 ++++--- drivers/net/wireless/ath/ath9k/xmit.c | 4 ++- 12 files changed, 69 insertions(+), 62 deletions(-)
drivers/net/wireless/ath/ath.h +1 -0
@@ -85,6 +85,7 @@ struct ath_common {struct ieee80211_hw *hw;int debug_mask;enum ath_device_state state; +enum nl80211_iftype opmode;struct ath_ani ani;
drivers/net/wireless/ath/ath5k/base.c +21 -21
162 lines not on this page · raw message
drivers/net/wireless/ath/ath5k/base.h +0 -1
@@ -124,7 +124,6 @@ struct ath5k_softc {struct ieee80211_channel channels[ATH_CHAN_MAX ];struct ieee80211_rate rates[IEEE80211_NUM_BANDS ][AR5K_MAX_RATES ];s8 rate_idx[IEEE80211_NUM_BANDS ][AR5K_MAX_RATES ]; -enum nl80211_iftype opmode;struct ath5k_hw *ah;/* Atheros HW */ struct ieee80211_supported_band *curband;
drivers/net/wireless/ath/ath9k/ani.c +11 -8
@@ -276,6 +276,7 @@ static void ath9k_ani_restart(struct ath_hw *ah)static void ath9k_hw_ani_ofdm_err_trigger (struct ath_hw *ah) {struct ieee80211_conf *conf = &ath9k_hw_common (ah)->hw->conf; +struct ath_common *common =ath9k_hw_common (ah);struct ar5416AniState *aniState;int32_t rssi;
@@ -298,7 +299,7 @@ static void ath9k_hw_ani_ofdm_err_trigger(struct ath_hw *ah) } } -if (ah->opmode ==NL80211_IFTYPE_AP ) { +if (common->opmode ==NL80211_IFTYPE_AP ) {if (aniState->firstepLevel <HAL_FIRST_STEP_MAX ) {ath9k_hw_ani_control (ah,ATH9K_ANI_FIRSTEP_LEVEL , aniState->firstepLevel +1 );
@@ -348,6 +349,7 @@ static void ath9k_hw_ani_ofdm_err_trigger(struct ath_hw *ah)static void ath9k_hw_ani_cck_err_trigger (struct ath_hw *ah) {struct ieee80211_conf *conf = &ath9k_hw_common (ah)->hw->conf; +struct ath_common *common =ath9k_hw_common (ah);struct ar5416AniState *aniState;int32_t rssi;
@@ -361,7 +363,7 @@ static void ath9k_hw_ani_cck_err_trigger(struct ath_hw *ah)return ; } } -if (ah->opmode ==NL80211_IFTYPE_AP ) { +if (common->opmode ==NL80211_IFTYPE_AP ) {if (aniState->firstepLevel <HAL_FIRST_STEP_MAX ) {ath9k_hw_ani_control (ah,ATH9K_ANI_FIRSTEP_LEVEL , aniState->firstepLevel +1 );
@@ -387,10 +389,11 @@ static void ath9k_hw_ani_lower_immunity(struct ath_hw *ah) {struct ar5416AniState *aniState;int32_t rssi; +struct ath_common *common =ath9k_hw_common (ah); aniState = ah->curani; -if (ah->opmode ==NL80211_IFTYPE_AP ) { +if (common->opmode ==NL80211_IFTYPE_AP ) {if (aniState->firstepLevel >0 ) {if (ath9k_hw_ani_control (ah,ATH9K_ANI_FIRSTEP_LEVEL , aniState->firstepLevel -1 ))
@@ -478,13 +481,13 @@ void ath9k_ani_reset(struct ath_hw *ah) aniState = &ah->ani[index]; ah->curani = aniState; -if (DO_ANI (ah) && ah->opmode !=NL80211_IFTYPE_STATION - && ah->opmode !=NL80211_IFTYPE_ADHOC ) { +if (DO_ANI (ah) && common->opmode !=NL80211_IFTYPE_STATION + && common->opmode !=NL80211_IFTYPE_ADHOC ) {ath_print (common,ATH_DBG_ANI , -"Reset ANI state opmode %u\n" , ah->opmode); +"Reset ANI state opmode %u\n" , common->opmode); ah->stats.ast_ani_reset++; -if (ah->opmode ==NL80211_IFTYPE_AP ) { +if (common->opmode ==NL80211_IFTYPE_AP ) {/* * ath9k_hw_ani_control() will only process items set on * ah->ani_function
@@ -507,7 +510,7 @@ void ath9k_ani_reset(struct ath_hw *ah)ath9k_hw_setrxfilter (ah,ath9k_hw_getrxfilter (ah) |ATH9K_RX_FILTER_PHYERR ); -if (ah->opmode ==NL80211_IFTYPE_AP ) { +if (common->opmode ==NL80211_IFTYPE_AP ) { ah->curani->ofdmTrigHigh = ah->config.ofdm_trig_high; ah->curani->ofdmTrigLow =
drivers/net/wireless/ath/ath9k/beacon.c +5 -5
@@ -31,7 +31,7 @@ int ath_beaconq_config(struct ath_softc *sc)int qnum;ath9k_hw_get_txq_props (ah, sc->beacon.beaconq, &qi); -if (sc->sc_ah->opmode ==NL80211_IFTYPE_AP ) { +if (common->opmode ==NL80211_IFTYPE_AP ) {/* Always burst out beacon and CAB traffic. */ qi.tqi_aifs =1 ; qi.tqi_cwmin =0 ;
@@ -76,8 +76,8 @@ static void ath_beacon_setup(struct ath_softc *sc, struct ath_vif *avp, ds = bf->bf_desc; flags =ATH9K_TXDESC_NOACK ; -if (((sc->sc_ah->opmode ==NL80211_IFTYPE_ADHOC ) || - (sc->sc_ah->opmode ==NL80211_IFTYPE_MESH_POINT )) && +if (((common->opmode ==NL80211_IFTYPE_ADHOC ) || + (common->opmode ==NL80211_IFTYPE_MESH_POINT )) && (ah->caps.hw_caps &ATH9K_HW_CAP_VEOL )) { ds->ds_link = bf->bf_daddr;/* self-linked */ flags |=ATH9K_TXDESC_VEOL ;
@@ -265,7 +265,7 @@ int ath_beacon_alloc(struct ath_wiphy *aphy, struct ieee80211_vif *vif) struct ath_buf, list);list_del (&avp->av_bcbuf->list); -if (sc->sc_ah->opmode ==NL80211_IFTYPE_AP || +if (common->opmode ==NL80211_IFTYPE_AP || !(sc->sc_ah->caps.hw_caps &ATH9K_HW_CAP_VEOL )) {int slot;/*
@@ -751,7 +751,7 @@ void ath_beacon_config(struct ath_softc *sc, struct ieee80211_vif *vif) cur_conf->bmiss_timeout =ATH_DEFAULT_BMISS_LIMIT * cur_conf->beacon_interval; }else { - iftype = sc->sc_ah->opmode; + iftype = common->opmode; }/*
drivers/net/wireless/ath/ath9k/common.c +1 -2
@@ -36,7 +36,6 @@ static bool ath9k_rx_accept(struct ath_common *common,struct ath_rx_status *rx_stats, bool *decrypt_error) { - struct ath_hw *ah = common->ah; struct ieee80211_hdr *hdr;__le16 fc;
@@ -87,7 +86,7 @@ static bool ath9k_rx_accept(struct ath_common *common,* decryption and MIC failures. For monitor mode, * we also ignore the CRC error. */ -if (ah->opmode ==NL80211_IFTYPE_MONITOR ) { +if (common->opmode ==NL80211_IFTYPE_MONITOR ) {if (rx_stats->rs_status & ~(ATH9K_RXERR_DECRYPT |ATH9K_RXERR_MIC |ATH9K_RXERR_CRC ))
drivers/net/wireless/ath/ath9k/hw.c +8 -7
@@ -2032,7 +2032,7 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan, | (ah->config. ack_6mb ?AR_STA_ID1_ACKCTS_6MB :0 ) | ah->sta_id1_defaults); -ath9k_hw_set_operating_mode (ah, ah->opmode); +ath9k_hw_set_operating_mode (ah, common->opmode);ath_hw_setbssidmask (common);
@@ -2055,7 +2055,7 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,for (i =0 ; i < ah->caps.total_queues; i++)ath9k_hw_resettxqueue (ah, i); -ath9k_hw_init_interrupt_masks (ah, ah->opmode); +ath9k_hw_init_interrupt_masks (ah, common->opmode);ath9k_hw_init_qos (ah);if (ah->caps.hw_caps &ATH9K_HW_CAP_RFSILENT )
@@ -2962,10 +2962,10 @@ EXPORT_SYMBOL(ath9k_hw_set_interrupts);void ath9k_hw_beaconinit (struct ath_hw *ah,u32 next_beacon,u32 beacon_period) {int flags =0 ; - +struct ath_common *common =ath9k_hw_common (ah); ah->beacon_interval = beacon_period; -switch (ah->opmode) { +switch (common->opmode) {case NL80211_IFTYPE_STATION :case NL80211_IFTYPE_MONITOR :REG_WRITE (ah,AR_NEXT_TBTT_TIMER ,TU_TO_USEC (next_beacon));
@@ -2998,7 +2998,7 @@ void ath9k_hw_beaconinit(struct ath_hw *ah, u32 next_beacon, u32 beacon_period)default :ath_print (ath9k_hw_common (ah),ATH_DBG_BEACON ,"%s: unsupported opmode: %d\n" , - __func__, ah->opmode); + __func__, common->opmode);return ;break ; }
@@ -3104,7 +3104,7 @@ int ath9k_hw_fill_cap_info(struct ath_hw *ah) capField = ah->eep_ops->get_eeprom (ah,EEP_OP_CAP ); -if (ah->opmode !=NL80211_IFTYPE_AP && +if (common->opmode !=NL80211_IFTYPE_AP && ah->hw_version.subvendorid ==AR_SUBVENDOR_ID_NEW_A ) {if (regulatory->current_rd ==0x64 || regulatory->current_rd ==0x65 )
@@ -3584,7 +3584,8 @@ EXPORT_SYMBOL(ath9k_hw_setmac);void ath9k_hw_setopmode (struct ath_hw *ah) { -ath9k_hw_set_operating_mode (ah, ah->opmode); +struct ath_common *common =ath9k_hw_common (ah); +ath9k_hw_set_operating_mode (ah, common->opmode); }EXPORT_SYMBOL (ath9k_hw_setopmode);
drivers/net/wireless/ath/ath9k/hw.h +0 -1
@@ -468,7 +468,6 @@ struct ath_hw {bool htc_reset_init; -enum nl80211_iftype opmode;enum ath9k_power_mode power_mode;struct ath9k_nfcal_hist nfCalHist[NUM_NF_READINGS ];
drivers/net/wireless/ath/ath9k/main.c +7 -7
@@ -360,7 +360,7 @@ static void ath_ani_calibrate(unsigned long data)unsigned int timestamp =jiffies_to_msecs (jiffies);u32 cal_interval, short_cal_interval; - short_cal_interval = (ah->opmode ==NL80211_IFTYPE_AP ) ? + short_cal_interval = (common->opmode ==NL80211_IFTYPE_AP ) ?ATH_AP_SHORT_CALINTERVAL :ATH_STA_SHORT_CALINTERVAL ;/* Only calibrate if awake */
@@ -1662,7 +1662,7 @@ static int ath_init_softc(u16 devid, struct ath_softc *sc, u16 subsysid,ath9k_hw_keyreset (ah, (u16 ) i);/* default to MONITOR mode */ - sc->sc_ah->opmode =NL80211_IFTYPE_MONITOR ; + common->opmode =NL80211_IFTYPE_MONITOR ;/* * Allocate hardware transmit queues: one queue for
@@ -2592,7 +2592,7 @@ static int ath9k_add_interface(struct ieee80211_hw *hw, }/* Set the device opmode */ - sc->sc_ah->opmode = ic_opmode; + common->opmode = ic_opmode;/* * Enable MIB interrupts when there are hardware phy counters.
@@ -2634,9 +2634,9 @@ static void ath9k_remove_interface(struct ieee80211_hw *hw,del_timer_sync (&common->ani.timer);/* Reclaim beacon resources */ -if ((sc->sc_ah->opmode ==NL80211_IFTYPE_AP ) || - (sc->sc_ah->opmode ==NL80211_IFTYPE_ADHOC ) || - (sc->sc_ah->opmode ==NL80211_IFTYPE_MESH_POINT )) { +if ((common->opmode ==NL80211_IFTYPE_AP ) || + (common->opmode ==NL80211_IFTYPE_ADHOC ) || + (common->opmode ==NL80211_IFTYPE_MESH_POINT )) {ath9k_hw_stoptxdma (sc->sc_ah, sc->beacon.beaconq);ath_beacon_return (sc, avp); }
@@ -2884,7 +2884,7 @@ static int ath9k_conf_tx(struct ieee80211_hw *hw, u16 queue,if (ret)ath_print (common,ATH_DBG_FATAL ,"TXQ Update failed\n" ); -if (sc->sc_ah->opmode ==NL80211_IFTYPE_ADHOC ) +if (common->opmode ==NL80211_IFTYPE_ADHOC )if ((qnum == sc->tx.hwq_map[ATH9K_WME_AC_BE ]) && !ret)ath_beaconq_config (sc);
drivers/net/wireless/ath/ath9k/rc.c +6 -4
@@ -1282,6 +1282,7 @@ static void ath_rate_init(void *priv, struct ieee80211_supported_band *sband,struct ath_softc *sc = priv;struct ath_rate_priv *ath_rc_priv = priv_sta;const struct ath_rate_table *rate_table; +struct ath_common *common =ath9k_hw_common (sc->sc_ah);bool is_cw40, is_sgi40;int i, j =0 ;
@@ -1309,9 +1310,9 @@ static void ath_rate_init(void *priv, struct ieee80211_supported_band *sband,/* Choose rate table first */ -if ((sc->sc_ah->opmode ==NL80211_IFTYPE_STATION ) || - (sc->sc_ah->opmode ==NL80211_IFTYPE_MESH_POINT ) || - (sc->sc_ah->opmode ==NL80211_IFTYPE_ADHOC )) { +if ((common->opmode ==NL80211_IFTYPE_STATION ) || + (common->opmode ==NL80211_IFTYPE_MESH_POINT ) || + (common->opmode ==NL80211_IFTYPE_ADHOC )) { rate_table =ath_choose_rate_table (sc, sband->band, sta->ht_cap.ht_supported, is_cw40); }else {
@@ -1328,6 +1329,7 @@ static void ath_rate_update(void *priv, struct ieee80211_supported_band *sband, {struct ath_softc *sc = priv;struct ath_rate_priv *ath_rc_priv = priv_sta; +struct ath_common *common =ath9k_hw_common (sc->sc_ah);const struct ath_rate_table *rate_table =NULL ;bool oper_cw40 = false, oper_sgi40; bool local_cw40 = (ath_rc_priv->ht_cap & WLAN_RC_40_FLAG) ?
@@ -1338,7 +1340,7 @@ static void ath_rate_update(void *priv, struct ieee80211_supported_band *sband,/* FIXME: Handle AP mode later when we support CWM */ if (changed &IEEE80211_RC_HT_CHANGED ) { -if (sc->sc_ah->opmode !=NL80211_IFTYPE_STATION ) +if (common->opmode !=NL80211_IFTYPE_STATION )return ; if (sc->hw->conf.channel_type == NL80211_CHAN_HT40MINUS ||
drivers/net/wireless/ath/ath9k/recv.c +6 -5
@@ -216,6 +216,7 @@ u32 ath_calcrxfilter(struct ath_softc *sc) {#define RX_FILTER_PRESERVE (ATH9K_RX_FILTER_PHYERR | ATH9K_RX_FILTER_PHYRADAR) +struct ath_common *common =ath9k_hw_common (sc->sc_ah);u32 rfilt; rfilt = (ath9k_hw_getrxfilter (sc->sc_ah) &RX_FILTER_PRESERVE )
@@ -223,7 +224,7 @@ u32 ath_calcrxfilter(struct ath_softc *sc) | ATH9K_RX_FILTER_MCAST;/* If not a STA, enable processing of Probe Requests */ -if (sc->sc_ah->opmode !=NL80211_IFTYPE_STATION ) +if (common->opmode !=NL80211_IFTYPE_STATION ) rfilt |=ATH9K_RX_FILTER_PROBEREQ ;/*
@@ -231,15 +232,15 @@ u32 ath_calcrxfilter(struct ath_softc *sc)* mode interface or when in monitor mode. AP mode does not need this * since it receives all in-BSS frames anyway. */ -if (((sc->sc_ah->opmode !=NL80211_IFTYPE_AP ) && +if (((common->opmode !=NL80211_IFTYPE_AP ) && (sc->rx.rxfilter &FIF_PROMISC_IN_BSS )) || - (sc->sc_ah->opmode ==NL80211_IFTYPE_MONITOR )) + (common->opmode ==NL80211_IFTYPE_MONITOR )) rfilt |=ATH9K_RX_FILTER_PROM ;if (sc->rx.rxfilter &FIF_CONTROL ) rfilt |=ATH9K_RX_FILTER_CONTROL ; -if ((sc->sc_ah->opmode ==NL80211_IFTYPE_STATION ) && +if ((common->opmode ==NL80211_IFTYPE_STATION ) && !(sc->rx.rxfilter &FIF_BCN_PRBRESP_PROMISC )) rfilt |=ATH9K_RX_FILTER_MYBEACON ;else
@@ -247,7 +248,7 @@ u32 ath_calcrxfilter(struct ath_softc *sc)if ((AR_SREV_9280_10_OR_LATER (sc->sc_ah) ||AR_SREV_9285_10_OR_LATER (sc->sc_ah)) && - (sc->sc_ah->opmode ==NL80211_IFTYPE_AP ) && + (common->opmode ==NL80211_IFTYPE_AP ) && (sc->rx.rxfilter &FIF_PSPOLL )) rfilt |=ATH9K_RX_FILTER_PSPOLL ;
drivers/net/wireless/ath/ath9k/xmit.c +3 -1
@@ -298,6 +298,8 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq,struct ath_buf *bf_next, *bf_last = bf->bf_lastbf;struct ath_desc *ds = bf_last->bf_desc;struct list_head bf_head, bf_pending; +struct ath_common *common =ath9k_hw_common (sc->sc_ah); +u16 seq_st =0 , acked_cnt =0 , txfail_cnt =0 ;u32 ba[WME_BA_BMP_SIZE >>5 ];int isaggr, txfail, txpending, sendbar =0 , needreset =0 , nbad =0 ;
@@ -337,7 +339,7 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq,* when perform internal reset in this routine. * Only enable reset in STA mode for now. */ -if (sc->sc_ah->opmode ==NL80211_IFTYPE_STATION ) +if (common->opmode ==NL80211_IFTYPE_STATION ) needreset =1 ; } }
Signature · 1 line
1.6.3.3
PATCH 2/4 ath: add macros for other ath9k register functions
In reply to Bob CopelandThis adds other macros such as REG_RMW to the common ath module in preparation for moving the ani routines to common code.
--- drivers/net/wireless/ath/hw.c | 4 +--- drivers/net/wireless/ath/hw.h | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 drivers/net/wireless/ath/hw.h
drivers/net/wireless/ath/hw.c +1 -3
@@ -18,9 +18,7 @@#include "ath.h" #include "reg.h" - -#define REG_READ common->ops->read -#define REG_WRITE common->ops->write +#include "hw.h" /** * ath_hw_set_bssid_mask - filter out bssids we listen
drivers/net/wireless/ath/hw.h new file +32 -0
@@ -0,0 +1,32 @@ +/* +* Copyright (c) 2008-2009 Atheros Communications Inc. +* +* 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 HW_H +#define HW_H + +#define REG_READ common->ops->read +#define REG_WRITE common->ops->write + +#define REG_RMW (_a, _r, _set, _clr) \ + REG_WRITE(_a, _r, (REG_READ(_a, _r) & ~(_clr)) | (_set)) +#define REG_RMW_FIELD (_a, _r, _f, _v) \ + REG_WRITE(_a, _r, \ + (REG_READ(_a, _r) & ~_f) | (((_v) << _f##_S) & _f)) +#define REG_SET_BIT (_a, _r, _f) \ + REG_WRITE(_a, _r, REG_READ(_a, _r) | _f) +#define REG_CLR_BIT (_a, _r, _f) \ + REG_WRITE(_a, _r, REG_READ(_a, _r) & ~_f) + +#endif /* HW_H */
Signature · 1 line
1.6.3.3
PATCH 3/4 ath9k: move ANI into ath common module
In reply to Bob CopelandThis change moves the Automatic Noise Immunity code from ath9k into the common atheros module. This will enable ath5k and potentially other Atheros modules to re-use the ANI code.
The patch introduces a new callback to the ath_ops structure for setting the phy error flag in the RX filter since the filter details are slightly different between different parts.
---
drivers/net/wireless/ath/Makefile | 3 +-
drivers/net/wireless/ath/{ath9k => }/ani.c | 423 ++++++++++++++--------------
drivers/net/wireless/ath/ani.h | 57 ++++
drivers/net/wireless/ath/ath.h | 89 ++++++-
drivers/net/wireless/ath/ath9k/Makefile | 1 -
drivers/net/wireless/ath/ath9k/ani.h | 123 --------
drivers/net/wireless/ath/ath9k/common.c | 3 +-
drivers/net/wireless/ath/ath9k/hw.c | 25 ++-
drivers/net/wireless/ath/ath9k/hw.h | 15 +-
drivers/net/wireless/ath/ath9k/mac.c | 6 +-
drivers/net/wireless/ath/ath9k/main.c | 7 +-
drivers/net/wireless/ath/reg.h | 134 +++++++++
12 files changed, 525 insertions(+), 361 deletions(-)
rename drivers/net/wireless/ath/{ath9k => }/ani.c (63%)
create mode 100644 drivers/net/wireless/ath/ani.h
delete mode 100644 drivers/net/wireless/ath/ath9k/ani.hdrivers/net/wireless/ath/Makefile +2 -1
@@ -6,6 +6,7 @@ obj-$(CONFIG_ATH_COMMON) += ath.o ath-objs := main.o \ regd.o \ - hw.o + hw.o \ + ani.o ath-$(CONFIG_ATH_DEBUG) += debug.o
drivers/net/wireless/ath/ani.c renamed from drivers/net/wireless/ath/ath9k/ani.c +218 -205
849 lines not on this page · raw message
drivers/net/wireless/ath/ani.h new file +57 -0
57 lines not on this page · raw message
drivers/net/wireless/ath/ath.h +84 -5
105 lines not on this page · raw message
drivers/net/wireless/ath/ath9k/Makefile +0 -1
@@ -17,7 +17,6 @@ ath9k_hw-y:= hw.o \ eeprom_4k.o \ eeprom_9287.o \ calib.o \ - ani.o \ phy.o \ btcoex.o \ mac.o \
drivers/net/wireless/ath/ath9k/ani.h deleted +0 -123
123 lines not on this page · raw message
drivers/net/wireless/ath/ath9k/common.c +1 -2
@@ -147,7 +147,6 @@ static void ath9k_process_rssi(struct ath_common *common,struct sk_buff *skb, struct ath_rx_status *rx_stats) { - struct ath_hw *ah = common->ah; struct ieee80211_sta *sta;struct ieee80211_hdr *hdr;struct ath_node *an;
@@ -183,7 +182,7 @@ static void ath9k_process_rssi(struct ath_common *common,/* Update Beacon RSSI, this is used by ANI. */ if (ieee80211_is_beacon (fc)) - ah->stats.avgbrssi = rx_stats->rs_rssi; + common->ani.stats.avgbrssi = rx_stats->rs_rssi; }/*
drivers/net/wireless/ath/ath9k/hw.c +20 -5
@@ -546,8 +546,8 @@ static int ath9k_hw_post_init(struct ath_hw *ah) }if (!AR_SREV_9100 (ah)) { -ath9k_hw_ani_setup (ah); -ath9k_hw_ani_init (ah); +ath_hw_ani_setup (ath9k_hw_common (ah)); +ath_hw_ani_init (ath9k_hw_common (ah)); }return 0 ;
@@ -920,9 +920,9 @@ int ath9k_hw_init(struct ath_hw *ah)ath9k_hw_init_cal_settings (ah); - ah->ani_function =ATH9K_ANI_ALL ; + common->ani.ani_function =ATH_ANI_ALL ;if (AR_SREV_9280_10_OR_LATER (ah)) { - ah->ani_function &= ~ATH9K_ANI_NOISE_IMMUNITY_LEVEL ; + common->ani.ani_function &= ~ATH_ANI_NOISE_IMMUNITY_LEVEL ; ah->ath9k_hw_rf_set_freq = &ath9k_hw_ar9280_set_channel; ah->ath9k_hw_spur_mitigate_freq = &ath9k_hw_9280_spur_mitigate; }else {
@@ -1250,7 +1250,7 @@ void ath9k_hw_detach(struct ath_hw *ah) goto free_hw;if (!AR_SREV_9100 (ah)) -ath9k_hw_ani_disable (ah); +ath_hw_ani_disable (common);ath9k_hw_setpower (ah,ATH9K_PM_FULL_SLEEP );
@@ -3536,6 +3536,21 @@ void ath9k_hw_setrxfilter(struct ath_hw *ah, u32 bits) }EXPORT_SYMBOL (ath9k_hw_setrxfilter); +void ath9k_hw_setrxfilter_phy_err (void *hw,bool enable) +{ +struct ath_hw *ah = hw; + +u32 filt =ath9k_hw_getrxfilter (ah); + +if (enable) + filt |=ATH9K_RX_FILTER_PHYERR ; +else + filt &= ~ATH9K_RX_FILTER_PHYERR ; + +ath9k_hw_setrxfilter (ah, filt); +} +EXPORT_SYMBOL (ath9k_hw_setrxfilter_phy_err); +bool ath9k_hw_phy_disable (struct ath_hw *ah) {if (!ath9k_hw_set_reset_reg (ah,ATH9K_RESET_WARM ))
drivers/net/wireless/ath/ath9k/hw.h +2 -13
@@ -22,7 +22,6 @@#include <linux/io.h> #include "mac.h" -#include "ani.h" #include "eeprom.h" #include "calib.h" #include "reg.h"
@@ -31,6 +30,7 @@#include "../regd.h" #include "../debug.h" +#include "../ani.h" #define ATHEROS_VENDOR_ID 0x168c
@@ -472,7 +472,6 @@ struct ath_hw {struct ath9k_nfcal_hist nfCalHist[NUM_NF_READINGS ];struct ath9k_pacal_info pacal_info; -struct ar5416Stats stats;struct ath9k_tx_queue_info txq[ATH9K_NUM_TX_QUEUES ];int16_t curchan_rad_index;
@@ -556,17 +555,6 @@ struct ath_hw {u32 ctstimeout;u32 globaltxtimeout; -/* ANI */ -u32 proc_phyerr; -u32 aniperiod; -struct ar5416AniState *curani; -struct ar5416AniState ani[255 ]; -int totalSizeDesired[5 ]; -int coarse_high[5 ]; -int coarse_low[5 ]; -int firpwr[5 ]; -enum ath9k_ani_cmd ani_function; -/* Bluetooth coexistance */ struct ath_btcoex_hw btcoex_hw;
@@ -654,6 +642,7 @@ void ath9k_hw_get_channel_centers(struct ath_hw *ah, struct chan_centers *centers);u32 ath9k_hw_getrxfilter (struct ath_hw *ah);void ath9k_hw_setrxfilter (struct ath_hw *ah,u32 bits); +void ath9k_hw_setrxfilter_phy_err (void *hw,bool enable);bool ath9k_hw_phy_disable (struct ath_hw *ah);bool ath9k_hw_disable (struct ath_hw *ah);void ath9k_hw_set_txpowerlimit (struct ath_hw *ah,u32 limit);
drivers/net/wireless/ath/ath9k/mac.c +3 -3
@@ -1004,9 +1004,9 @@ EXPORT_SYMBOL(ath9k_hw_rxena);void ath9k_hw_startpcureceive (struct ath_hw *ah) { -ath9k_enable_mib_counters (ah); +ath_enable_mib_counters (ath9k_hw_common (ah)); -ath9k_ani_reset (ah); +ath_ani_reset (ath9k_hw_common (ah), ah->curchan->chan);REG_CLR_BIT (ah,AR_DIAG_SW , (AR_DIAG_RX_DIS |AR_DIAG_RX_ABORT )); }
@@ -1016,7 +1016,7 @@ void ath9k_hw_stoppcurecv(struct ath_hw *ah) {REG_SET_BIT (ah,AR_DIAG_SW ,AR_DIAG_RX_DIS ); -ath9k_hw_disable_mib_counters (ah); +ath_hw_disable_mib_counters (ath9k_hw_common (ah)); }EXPORT_SYMBOL (ath9k_hw_stoppcurecv);
drivers/net/wireless/ath/ath9k/main.c +4 -3
@@ -404,7 +404,7 @@ static void ath_ani_calibrate(unsigned long data)if (longcal || shortcal || aniflag) {/* Call ANI routine if necessary */ if (aniflag) -ath9k_hw_ani_monitor (ah, ah->curchan); +ath_hw_ani_monitor (ath9k_hw_common (ah));/* Perform calibration if necessary */ if (longcal || shortcal) {
@@ -627,7 +627,7 @@ irqreturn_t ath_isr(int irq, void *dev)* it will clear whatever condition caused * the interrupt. */ -ath9k_hw_procmibevent (ah); +ath_hw_procmibevent (ath9k_hw_common (ah));ath9k_hw_set_interrupts (ah, sc->imask); }
@@ -989,7 +989,7 @@ static void ath9k_bss_assoc_info(struct ath_softc *sc,ath_beacon_config (sc, vif);/* Reset rssi stats */ - sc->sc_ah->stats.avgbrssi =ATH_RSSI_DUMMY_MARKER ; + common->ani.stats.avgbrssi =ATH_RSSI_DUMMY_MARKER ;ath_start_ani (common); }else {
@@ -1578,6 +1578,7 @@ static unsigned int ath9k_ioread32(void *hw_priv, u32 reg_offset)static const struct ath_ops ath9k_common_ops = { .read = ath9k_ioread32, .write = ath9k_iowrite32, + .setrxfilter_phy_err = ath9k_hw_setrxfilter_phy_err, };/*
drivers/net/wireless/ath/reg.h +134 -0
144 lines not on this page · raw message
Signature · 1 line
1.6.3.3
PATCH 4/4 ath5k: implement ANI
In reply to Bob CopelandThis change updates ath5k to do ANI adjustments every 100 ms using the common ANI code in the ath module.
--- drivers/net/wireless/ath/ani.c | 6 +++ drivers/net/wireless/ath/ath5k/ath5k.h | 4 ++ drivers/net/wireless/ath/ath5k/attach.c | 7 +++ drivers/net/wireless/ath/ath5k/base.c | 69 +++++++++++++++++-------------- drivers/net/wireless/ath/ath5k/pcu.c | 24 +++++++++- drivers/net/wireless/ath/ath5k/phy.c | 24 ++++++++-- 6 files changed, 95 insertions(+), 39 deletions(-)
drivers/net/wireless/ath/ani.c +6 -0
@@ -107,6 +107,7 @@ static bool ath_hw_ani_control(struct ath_common *common, m2CountThrLow[on]);/* FIXME not ath5k? */ +#if 0 REG_RMW_FIELD (ah,AR_PHY_SFCORR_EXT ,AR_PHY_SFCORR_EXT_M1_THRESH_LOW , m1ThreshLow[on]);
@@ -119,6 +120,7 @@ static bool ath_hw_ani_control(struct ath_common *common,REG_RMW_FIELD (ah,AR_PHY_SFCORR_EXT ,AR_PHY_SFCORR_EXT_M2_THRESH , m2Thresh[on]); +#endif if (on) REG_SET_BIT(ah, AR_PHY_SFCORR_LOW,
@@ -727,8 +729,12 @@ void ath_hw_procmibevent(struct ath_common *common)/* Reset these counters regardless */ REG_WRITE (ah,AR_FILT_OFDM ,0 );REG_WRITE (ah,AR_FILT_CCK ,0 ); + +/* FIXME not ath5k? */ +#if 0 if (!(REG_READ (ah,AR_SLP_MIB_CTRL ) &AR_SLP_MIB_PENDING ))REG_WRITE (ah,AR_SLP_MIB_CTRL ,AR_SLP_MIB_CLEAR ); +#endif /* Clear the mib counters and save them in the stats */ ath_hw_update_mibstats (common, &common->mib_stats);
drivers/net/wireless/ath/ath5k/ath5k.h +4 -0
@@ -203,6 +203,8 @@#define AR5K_TUNE_DEFAULT_TXPOWER 25#define AR5K_TUNE_TPC_TXPOWER false#define AR5K_TUNE_HWTXTRIES 4 +/* ANI poll interval in ms */ +#define AR5K_TUNE_ANI_POLL_INTERVAL 100#define AR5K_INIT_CARR_SENSE_EN 1
@@ -917,6 +919,7 @@ enum ath5k_int {enum ath5k_software_interrupt {AR5K_SWI_FULL_CALIBRATION =0x01 ,AR5K_SWI_SHORT_CALIBRATION =0x02 , +AR5K_SWI_ANI_CALIBRATION =0x03 , };/*
@@ -1213,6 +1216,7 @@ extern int ath5k_hw_set_mcast_filter_idx(struct ath5k_hw *ah, u32 index);extern int ath5k_hw_clear_mcast_filter_idx (struct ath5k_hw *ah,u32 index);extern u32 ath5k_hw_get_rx_filter (struct ath5k_hw *ah);extern void ath5k_hw_set_rx_filter (struct ath5k_hw *ah,u32 filter); +extern void ath5k_hw_set_rx_filter_phy_err (void *hw,bool enable);/* Beacon control functions */ extern u32 ath5k_hw_get_tsf32 (struct ath5k_hw *ah);extern u64 ath5k_hw_get_tsf64 (struct ath5k_hw *ah);
drivers/net/wireless/ath/ath5k/attach.c +7 -0
@@ -25,6 +25,7 @@#include "reg.h" #include "debug.h" #include "base.h" +#include "../ani.h" /** * ath5k_hw_post - Power On Self Test helper function
@@ -336,6 +337,10 @@ int ath5k_hw_attach(struct ath5k_softc *sc)/* turn on HW LEDs */ ath5k_hw_set_ledstate (ah,AR5K_LED_INIT ); + common->ani.ani_function =ATH_ANI_ALL ; +ath_hw_ani_setup (common); +ath_hw_ani_init (common); +return 0 ; err_free:kfree (ah);
@@ -351,6 +356,8 @@ void ath5k_hw_detach(struct ath5k_hw *ah) {ATH5K_TRACE (ah->ah_sc); +ath_hw_ani_disable (ath5k_hw_common (ah)); +__set_bit (ATH_STAT_INVALID , ah->ah_sc->status);if (ah->ah_rf_banks !=NULL )
drivers/net/wireless/ath/ath5k/base.c +38 -31
127 lines not on this page · raw message
drivers/net/wireless/ath/ath5k/pcu.c +21 -3
@@ -30,6 +30,7 @@#include "reg.h" #include "debug.h" #include "base.h" +#include "../ani.h" /*******************\ * Generic functions *
@@ -337,11 +338,16 @@ void ath5k_hw_set_bssid_mask(struct ath5k_hw *ah, const u8 *mask)* (ACK etc). * * NOTE: RX DMA should be already enabled using ath5k_hw_start_rx_dma -* TODO: Init ANI here */ void ath5k_hw_start_rx_pcu (struct ath5k_hw *ah) { +struct ath_common *common =ath5k_hw_common (ah); +ATH5K_TRACE (ah->ah_sc); + +ath_enable_mib_counters (common); +ath_ani_reset (common, ah->ah_current_channel); +AR5K_REG_DISABLE_BITS (ah,AR5K_DIAG_SW ,AR5K_DIAG_SW_DIS_RX ); }
@@ -352,11 +358,11 @@ void ath5k_hw_start_rx_pcu(struct ath5k_hw *ah)* * Stops RX engine on PCU * -* TODO: Detach ANI here */ void ath5k_hw_stop_rx_pcu (struct ath5k_hw *ah) {ATH5K_TRACE (ah->ah_sc); +ath_hw_disable_mib_counters (ath5k_hw_common (ah));AR5K_REG_ENABLE_BITS (ah,AR5K_DIAG_SW ,AR5K_DIAG_SW_DIS_RX ); }
@@ -483,9 +489,21 @@ void ath5k_hw_set_rx_filter(struct ath5k_hw *ah, u32 filter)/*Write PHY error filter register on 5212*/ if (ah->ah_version ==AR5K_AR5212 )ath5k_hw_reg_write (ah, data,AR5K_PHY_ERR_FIL ); - } +EXPORT_SYMBOL (ath5k_hw_set_rx_filter_phy_err); +void ath5k_hw_set_rx_filter_phy_err (void *hw,bool enable) +{ +struct ath5k_hw *ah = hw; + +u32 filt =ath5k_hw_get_rx_filter (ah); +if (enable) + filt |=AR5K_RX_FILTER_PHYERR ; +else + filt &= ~AR5K_RX_FILTER_PHYERR ; + +ath5k_hw_set_rx_filter (ah, filt); +}/****************\ * Beacon control *
drivers/net/wireless/ath/ath5k/phy.c +19 -5
@@ -1107,23 +1107,37 @@ int ath5k_hw_channel(struct ath5k_hw *ah, struct ieee80211_channel *channel)void ath5k_hw_calibration_poll (struct ath5k_hw *ah) { +struct ath_common *common =ath5k_hw_common (ah); +/* Calibration interval in jiffies */ -unsigned long cal_intval; +unsigned long cal_intval, ani_intval; cal_intval =msecs_to_jiffies (ah->ah_cal_intval *1000 ); + ani_intval =msecs_to_jiffies (AR5K_TUNE_ANI_POLL_INTERVAL ); -/* Initialize timestamp if needed */ -if (!ah->ah_cal_tstamp) +/* Initialize timestamps if needed */ +if (!ah->ah_cal_tstamp || !common->ani.checkani_timer) { ah->ah_cal_tstamp = jiffies; + common->ani.checkani_timer = jiffies; + } + +/* do ani if past ANI calibration window */ +if (time_is_before_eq_jiffies (common->ani.checkani_timer + + ani_intval)) { + common->ani.checkani_timer = jiffies; + ah->ah_swi_mask |=AR5K_SWI_ANI_CALIBRATION ; + }/* For now we always do full calibration * Mark software interrupt mask and fire software * interrupt (bit gets auto-cleared) */ if (time_is_before_eq_jiffies (ah->ah_cal_tstamp + cal_intval)) { ah->ah_cal_tstamp = jiffies; - ah->ah_swi_mask =AR5K_SWI_FULL_CALIBRATION ; -AR5K_REG_ENABLE_BITS (ah,AR5K_CR ,AR5K_CR_SWI ); + ah->ah_swi_mask |=AR5K_SWI_FULL_CALIBRATION ; } + +/* fire software interrupt (bit gets auto-cleared) */ +AR5K_REG_ENABLE_BITS (ah,AR5K_CR ,AR5K_CR_SWI ); }static int sign_extend (int val,const int nbits)
Signature · 1 line
1.6.3.3
cover ANI support for ath5k
In reply to Bob CopelandQuoted 2 lines · Bob Copeland
I can't say yet whether it is better or not compared to with no ANI. Please test and let us know how it goes.
So I can at least now say that there are lots more interrupts. Partly because we assert SWI frequently, but also maybe because of MIB counters etc. So I think this needs to be addressed in my patchset before going forward.
Signature · 1 line
Bob Copeland %% www.bobcopeland.com