2008-12-23 23:59:00

by Luis R. Rodriguez

[permalink] [raw]
Subject: [PATCH v3 00/16] ath9k: first series for regulatory cleanup

This is the first series of general cleanup to get us into
abandon our complex internal regulatory infrastructure. This is
quite a lot of work as we rely on our own internal "mode" stuff
and our own ath9k_channel heavily.

We start this work by ditching the mode stuff where we can
and set a staging ground for us to abandon our own internal
ath9k_channel. The values which we want to actually keep from
ath9k_channel are the calibration data. To make use of this
we will eventually map channels to our private channel structure
by indexing on their position on the static array.

The next series will deal more with this and then slowly start
to nuke our complex regulatory infrastructure in favor for
internal generic CRDA/cfg80211 regulatory infrastructure.

This work is all being done so we won't have to malloc() all
over again our new set of channels on country IE changes as
doing that would be a bit messy. We will instead prefer to use
static channels.

This should not have any major functional changes, its mostly
cleanup stuff.

This v3 abandones the private void pointer in ieee80211_channel
based on Johannes's recommendations.

Luis R. Rodriguez (16):
mac80211: add HT conf helpers
ath9k: use hw->conf on ath_setcurmode()
ath9k: remove cache of rate preference when using 11g protection
ath9k: Rename ath_setcurmode() to ath_cache_conf_rate()
ath9k: consolidate arguments on hw reset
ath9k: make request to get the noisefloor threshold band specific
ath9k: use ieee80211_conf on ath9k_hw_iscal_supported()
ath9k: make use of conf_is_ht*() in the rest of the driver
iwlwifi: make use of conf_is_ht*() helpers
mac80211: no need for ht.enabled
ath9k: Make ANI CCK and OFDM error triggers band specific
ath9k: remove mode specific default noise floor values
ath9k: remove ath9k_hw_chan2wmode()
ath9k: remove ath9k_hw_check_chan()
ath9k: remove superfluous check on changing channel
ath9k: fix sparse warnings

drivers/net/wireless/ath9k/ani.c | 12 +-
drivers/net/wireless/ath9k/ath9k.h | 9 +-
drivers/net/wireless/ath9k/calib.c | 93 ++++------
drivers/net/wireless/ath9k/core.h | 1 -
drivers/net/wireless/ath9k/eeprom.c | 30 ++--
drivers/net/wireless/ath9k/hw.c | 154 +++++------------
drivers/net/wireless/ath9k/hw.h | 8 +
drivers/net/wireless/ath9k/main.c | 268 +++++++++++++----------------
drivers/net/wireless/ath9k/rc.c | 4 +-
drivers/net/wireless/ath9k/xmit.c | 31 ++--
drivers/net/wireless/iwlwifi/iwl-agn-rs.c | 6 +-
drivers/net/wireless/iwlwifi/iwl-agn.c | 6 +-
include/net/mac80211.h | 31 ++++-
net/mac80211/ht.c | 3 +-
net/mac80211/main.c | 10 -
net/mac80211/mlme.c | 1 -
16 files changed, 289 insertions(+), 378 deletions(-)



2008-12-29 04:40:10

by Sujith

[permalink] [raw]
Subject: [PATCH v3 02/16] ath9k: use hw->conf on ath_setcurmode()

Luis Rodriguez wrote:
> + switch (conf->channel->band) {
> + case IEEE80211_BAND_2GHZ:
> + if (conf_is_ht20(conf))
> + sc->cur_rate_table =
> + sc->hw_rate_table[ATH9K_MODE_11NG_HT20];
> + else if (conf_is_ht40_minus(conf))
> + sc->cur_rate_table =
> + sc->hw_rate_table[ATH9K_MODE_11NG_HT40MINUS];
> + else if (conf_is_ht40_plus(conf))
> + sc->cur_rate_table =
> + sc->hw_rate_table[ATH9K_MODE_11NG_HT40PLUS];
> + else {
> + sc->sc_protrix = 1;
> + sc->cur_rate_table =
> + sc->hw_rate_table[ATH9K_MODE_11G];
> + }
> + break;
> + case IEEE80211_BAND_5GHZ:
> + if (conf_is_ht20(conf))
> + sc->cur_rate_table =
> + sc->hw_rate_table[ATH9K_MODE_11NA_HT20];
> + else if (conf_is_ht40_minus(conf))
> + sc->cur_rate_table =
> + sc->hw_rate_table[ATH9K_MODE_11NA_HT40MINUS];
> + else if (conf_is_ht40_plus(conf))
> + sc->cur_rate_table =
> + sc->hw_rate_table[ATH9K_MODE_11NA_HT40PLUS];
> + else
> + sc->cur_rate_table = sc->hw_rate_table[ATH9K_MODE_11A];
> + break;
> + default:
> + break;
> + }
> }

We don't have separate rate tables for ht20, ht40+, ht40-.
Setting cur_rate_table just once using conf_is_ht() to any HT mode would suffice.

Sujith

2008-12-23 23:59:26

by Luis R. Rodriguez

[permalink] [raw]
Subject: [PATCH v3 10/16] mac80211: no need for ht.enabled

We can simply use conf_is_ht() check where needed.

Signed-off-by: Luis R. Rodriguez <[email protected]>
Acked-by: Johannes Berg <[email protected]>
---
include/net/mac80211.h | 1 -
net/mac80211/ht.c | 3 +--
net/mac80211/main.c | 10 ----------
net/mac80211/mlme.c | 1 -
4 files changed, 1 insertions(+), 14 deletions(-)

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index ee2b75e..b51caab 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -509,7 +509,6 @@ static inline int __deprecated __IEEE80211_CONF_SHORT_SLOT_TIME(void)
#define IEEE80211_CONF_SHORT_SLOT_TIME (__IEEE80211_CONF_SHORT_SLOT_TIME())

struct ieee80211_ht_conf {
- bool enabled;
enum nl80211_channel_type channel_type;
};

diff --git a/net/mac80211/ht.c b/net/mac80211/ht.c
index 55bfe48..6314289 100644
--- a/net/mac80211/ht.c
+++ b/net/mac80211/ht.c
@@ -130,11 +130,10 @@ u32 ieee80211_enable_ht(struct ieee80211_sub_if_data *sdata,
}
}

- ht_changed = local->hw.conf.ht.enabled != enable_ht ||
+ ht_changed = conf_is_ht(&local->hw.conf) != enable_ht ||
channel_type != local->hw.conf.ht.channel_type;

local->oper_channel_type = channel_type;
- local->hw.conf.ht.enabled = enable_ht;

if (ht_changed)
ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_HT);
diff --git a/net/mac80211/main.c b/net/mac80211/main.c
index 24b1436..a6cb480 100644
--- a/net/mac80211/main.c
+++ b/net/mac80211/main.c
@@ -211,16 +211,6 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
channel_type != local->hw.conf.ht.channel_type) {
local->hw.conf.channel = chan;
local->hw.conf.ht.channel_type = channel_type;
- switch (channel_type) {
- case NL80211_CHAN_NO_HT:
- local->hw.conf.ht.enabled = false;
- break;
- case NL80211_CHAN_HT20:
- case NL80211_CHAN_HT40MINUS:
- case NL80211_CHAN_HT40PLUS:
- local->hw.conf.ht.enabled = true;
- break;
- }
changed |= IEEE80211_CONF_CHANGE_CHANNEL;
}

diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index e317c6d..d108c12 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -907,7 +907,6 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata,

rcu_read_unlock();

- local->hw.conf.ht.enabled = false;
local->oper_channel_type = NL80211_CHAN_NO_HT;
config_changed |= IEEE80211_CONF_CHANGE_HT;

--
1.6.1.rc3.51.g5832d


2008-12-23 23:59:07

by Luis R. Rodriguez

[permalink] [raw]
Subject: [PATCH v3 03/16] ath9k: remove cache of rate preference when using 11g protection

No need to cache when we want to use 2Mbit/s for all protection
frames for 802.11g as we can determine that dynamically on
ath_buf_set_rate() itself.

Signed-off-by: Luis R. Rodriguez <[email protected]>
---
drivers/net/wireless/ath9k/core.h | 1 -
drivers/net/wireless/ath9k/main.c | 13 +++----------
drivers/net/wireless/ath9k/xmit.c | 13 ++++++++++---
3 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/drivers/net/wireless/ath9k/core.h b/drivers/net/wireless/ath9k/core.h
index 4ca2aed..2bb35dd 100644
--- a/drivers/net/wireless/ath9k/core.h
+++ b/drivers/net/wireless/ath9k/core.h
@@ -718,7 +718,6 @@ struct ath_softc {
u32 sc_keymax;
DECLARE_BITMAP(sc_keymap, ATH_KEYMAX);
u8 sc_splitmic;
- u8 sc_protrix;
enum ath9k_int sc_imask;
enum PROT_MODE sc_protmode;
enum ath9k_ht_extprotspacing sc_ht_extprotspacing;
diff --git a/drivers/net/wireless/ath9k/main.c b/drivers/net/wireless/ath9k/main.c
index 2bf2b3f..28d9de1 100644
--- a/drivers/net/wireless/ath9k/main.c
+++ b/drivers/net/wireless/ath9k/main.c
@@ -61,12 +61,6 @@ static void bus_read_cachesize(struct ath_softc *sc, int *csz)

static void ath_setcurmode(struct ath_softc *sc, struct ieee80211_conf *conf)
{
- /*
- * All protection frames are transmited at 2Mb/s for
- * 11g, otherwise at 1Mb/s.
- * XXX select protection rate index from rate table.
- */
- sc->sc_protrix = 0;
switch (conf->channel->band) {
case IEEE80211_BAND_2GHZ:
if (conf_is_ht20(conf))
@@ -78,11 +72,9 @@ static void ath_setcurmode(struct ath_softc *sc, struct ieee80211_conf *conf)
else if (conf_is_ht40_plus(conf))
sc->cur_rate_table =
sc->hw_rate_table[ATH9K_MODE_11NG_HT40PLUS];
- else {
- sc->sc_protrix = 1;
+ else
sc->cur_rate_table =
sc->hw_rate_table[ATH9K_MODE_11G];
- }
break;
case IEEE80211_BAND_5GHZ:
if (conf_is_ht20(conf))
@@ -95,7 +87,8 @@ static void ath_setcurmode(struct ath_softc *sc, struct ieee80211_conf *conf)
sc->cur_rate_table =
sc->hw_rate_table[ATH9K_MODE_11NA_HT40PLUS];
else
- sc->cur_rate_table = sc->hw_rate_table[ATH9K_MODE_11A];
+ sc->cur_rate_table =
+ sc->hw_rate_table[ATH9K_MODE_11A];
break;
default:
break;
diff --git a/drivers/net/wireless/ath9k/xmit.c b/drivers/net/wireless/ath9k/xmit.c
index c92f0c6..3e192fd 100644
--- a/drivers/net/wireless/ath9k/xmit.c
+++ b/drivers/net/wireless/ath9k/xmit.c
@@ -546,7 +546,8 @@ static void ath_buf_set_rate(struct ath_softc *sc, struct ath_buf *bf)
struct ieee80211_tx_info *tx_info;
struct ieee80211_tx_rate *rates;
struct ieee80211_hdr *hdr;
- int i, flags, rtsctsena = 0;
+ struct ieee80211_hw *hw = sc->hw;
+ int i, flags, rtsctsena = 0, enable_g_protection = 0;
u32 ctsduration = 0;
u8 rix = 0, cix, ctsrate = 0;
__le16 fc;
@@ -578,6 +579,12 @@ static void ath_buf_set_rate(struct ath_softc *sc, struct ath_buf *bf)
flags = (bf->bf_flags & (ATH9K_TXDESC_RTSENA | ATH9K_TXDESC_CTSENA));
cix = rt->info[rix].ctrl_rate;

+ /* All protection frames are transmited at 2Mb/s for 802.11g,
+ * otherwise we transmit them at 1Mb/s */
+ if (hw->conf.channel->band == IEEE80211_BAND_2GHZ &&
+ !conf_is_ht(&hw->conf))
+ enable_g_protection = 1;
+
/*
* If 802.11g protection is enabled, determine whether to use RTS/CTS or
* just CTS. Note that this is only done for OFDM/HT unicast frames.
@@ -590,7 +597,7 @@ static void ath_buf_set_rate(struct ath_softc *sc, struct ath_buf *bf)
else if (sc->sc_protmode == PROT_M_CTSONLY)
flags = ATH9K_TXDESC_CTSENA;

- cix = rt->info[sc->sc_protrix].ctrl_rate;
+ cix = rt->info[enable_g_protection].ctrl_rate;
rtsctsena = 1;
}

@@ -608,7 +615,7 @@ static void ath_buf_set_rate(struct ath_softc *sc, struct ath_buf *bf)
if (sc->sc_config.ath_aggr_prot &&
(!bf_isaggr(bf) || (bf_isaggr(bf) && bf->bf_al < 8192))) {
flags = ATH9K_TXDESC_RTSENA;
- cix = rt->info[sc->sc_protrix].ctrl_rate;
+ cix = rt->info[enable_g_protection].ctrl_rate;
rtsctsena = 1;
}

--
1.6.1.rc3.51.g5832d


2008-12-23 23:59:21

by Luis R. Rodriguez

[permalink] [raw]
Subject: [PATCH v3 08/16] ath9k: make use of conf_is_ht*() in the rest of the driver

Use shiny new conf_is_ht*() helpers, we can later remove ht.enabled if
desired.

Signed-off-by: Luis R. Rodriguez <[email protected]>
---
drivers/net/wireless/ath9k/main.c | 7 +++----
drivers/net/wireless/ath9k/rc.c | 4 ++--
drivers/net/wireless/ath9k/xmit.c | 2 +-
3 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/ath9k/main.c b/drivers/net/wireless/ath9k/main.c
index 5455d3c..99de021 100644
--- a/drivers/net/wireless/ath9k/main.c
+++ b/drivers/net/wireless/ath9k/main.c
@@ -2134,9 +2134,8 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed)
(curchan->band == IEEE80211_BAND_2GHZ) ?
CHANNEL_G : CHANNEL_A;

- if (conf->ht.enabled) {
- if (conf->ht.channel_type == NL80211_CHAN_HT40PLUS ||
- conf->ht.channel_type == NL80211_CHAN_HT40MINUS)
+ if (conf_is_ht(conf)) {
+ if (conf_is_ht40(conf))
sc->tx_chan_width = ATH9K_HT_MACMODE_2040;

sc->sc_ah->ah_channels[pos].chanmode =
@@ -2150,7 +2149,7 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed)
return -EINVAL;
}

- ath_update_chainmask(sc, conf->ht.enabled);
+ ath_update_chainmask(sc, conf_is_ht(conf));
}

if (changed & IEEE80211_CONF_CHANGE_POWER)
diff --git a/drivers/net/wireless/ath9k/rc.c b/drivers/net/wireless/ath9k/rc.c
index 04ab457..469b374 100644
--- a/drivers/net/wireless/ath9k/rc.c
+++ b/drivers/net/wireless/ath9k/rc.c
@@ -875,7 +875,7 @@ static void ath_rc_ratefind(struct ath_softc *sc,
* above conditions.
*/
if ((sc->hw->conf.channel->band == IEEE80211_BAND_2GHZ) &&
- (sc->hw->conf.ht.enabled)) {
+ (conf_is_ht(&sc->hw->conf))) {
u8 dot11rate = rate_table->info[rix].dot11rate;
u8 phy = rate_table->info[rix].phy;
if (i == 4 &&
@@ -1511,7 +1511,7 @@ static void ath_get_rate(void *priv, struct ieee80211_sta *sta, void *priv_sta,
tx_info, &is_probe, false);

/* Check if aggregation has to be enabled for this tid */
- if (hw->conf.ht.enabled) {
+ if (conf_is_ht(&hw->conf)) {
if (ieee80211_is_data_qos(fc)) {
u8 *qc, tid;
struct ath_node *an;
diff --git a/drivers/net/wireless/ath9k/xmit.c b/drivers/net/wireless/ath9k/xmit.c
index e28889b..9e910f7 100644
--- a/drivers/net/wireless/ath9k/xmit.c
+++ b/drivers/net/wireless/ath9k/xmit.c
@@ -1690,7 +1690,7 @@ static int ath_tx_setup_buffer(struct ath_softc *sc, struct ath_buf *bf,
(sc->sc_flags & SC_OP_PREAMBLE_SHORT) ?
(bf->bf_state.bf_type |= BUF_SHORT_PREAMBLE) :
(bf->bf_state.bf_type &= ~BUF_SHORT_PREAMBLE);
- (sc->hw->conf.ht.enabled && !is_pae(skb) &&
+ (conf_is_ht(&sc->hw->conf) && !is_pae(skb) &&
(tx_info->flags & IEEE80211_TX_CTL_AMPDU)) ?
(bf->bf_state.bf_type |= BUF_HT) :
(bf->bf_state.bf_type &= ~BUF_HT);
--
1.6.1.rc3.51.g5832d


2008-12-29 04:41:17

by Sujith

[permalink] [raw]
Subject: [PATCH v3 07/16] ath9k: use ieee80211_conf on ath9k_hw_iscal_supported()

Luis Rodriguez wrote:
> - case IQ_MISMATCH_CAL:
> - if (!IS_CHAN_B(chan))
> - retval = true;
> - break;
> + case IQ_MISMATCH_CAL: /* Both 2 GHz and 5 GHz support OFDM */
> + return true;
> case ADC_GAIN_CAL:
> case ADC_DC_CAL:
> - if (!IS_CHAN_B(chan)
> - && !(IS_CHAN_2GHZ(chan) && IS_CHAN_HT20(chan)))
> - retval = true;
> + if (conf->channel->band == IEEE80211_BAND_5GHZ &&
> + conf_is_ht20(conf))
> + return true;
> break;
> }

Why are the IS_CHAN_B() checks removed ?

Sujith

2008-12-29 15:47:12

by Luis R. Rodriguez

[permalink] [raw]
Subject: Re: [PATCH v3 07/16] ath9k: use ieee80211_conf on ath9k_hw_iscal_supported()

On Sun, Dec 28, 2008 at 08:38:10PM -0800, Sujith Manoharan wrote:
> Luis Rodriguez wrote:
> > - case IQ_MISMATCH_CAL:
> > - if (!IS_CHAN_B(chan))
> > - retval = true;
> > - break;
> > + case IQ_MISMATCH_CAL: /* Both 2 GHz and 5 GHz support OFDM */
> > + return true;
> > case ADC_GAIN_CAL:
> > case ADC_DC_CAL:
> > - if (!IS_CHAN_B(chan)
> > - && !(IS_CHAN_2GHZ(chan) && IS_CHAN_HT20(chan)))
> > - retval = true;
> > + if (conf->channel->band == IEEE80211_BAND_5GHZ &&
> > + conf_is_ht20(conf))
> > + return true;
> > break;
> > }
>
> Why are the IS_CHAN_B() checks removed ?

Because 1) it will currently never happen 2) we need a better check for is CCK in mac80211, not
an internal check.

Luis

2008-12-23 23:59:29

by Luis R. Rodriguez

[permalink] [raw]
Subject: [PATCH v3 11/16] ath9k: Make ANI CCK and OFDM error triggers band specific

The CCK and OFDM ANI error triggers are not mode specific but rather
band specific so just make use of the already available band from
ieee80211_conf.

Signed-off-by: Luis R. Rodriguez <[email protected]>
---
drivers/net/wireless/ath9k/ani.c | 12 ++++--------
1 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/ath9k/ani.c b/drivers/net/wireless/ath9k/ani.c
index 251e2d9..4dd0860 100644
--- a/drivers/net/wireless/ath9k/ani.c
+++ b/drivers/net/wireless/ath9k/ani.c
@@ -279,9 +279,8 @@ static void ath9k_ani_restart(struct ath_hal *ah)
static void ath9k_hw_ani_ofdm_err_trigger(struct ath_hal *ah)
{
struct ath_hal_5416 *ahp = AH5416(ah);
- struct ath9k_channel *chan = ah->ah_curchan;
+ struct ieee80211_conf *conf = &ah->ah_sc->hw->conf;
struct ar5416AniState *aniState;
- enum wireless_mode mode;
int32_t rssi;

if (!DO_ANI(ah))
@@ -336,8 +335,7 @@ static void ath9k_hw_ani_ofdm_err_trigger(struct ath_hal *ah)
aniState->firstepLevel + 1);
return;
} else {
- mode = ath9k_hw_chan2wmode(ah, chan);
- if (mode == ATH9K_MODE_11G || mode == ATH9K_MODE_11B) {
+ if (conf->channel->band == IEEE80211_BAND_2GHZ) {
if (!aniState->ofdmWeakSigDetectOff)
ath9k_hw_ani_control(ah,
ATH9K_ANI_OFDM_WEAK_SIGNAL_DETECTION,
@@ -353,9 +351,8 @@ static void ath9k_hw_ani_ofdm_err_trigger(struct ath_hal *ah)
static void ath9k_hw_ani_cck_err_trigger(struct ath_hal *ah)
{
struct ath_hal_5416 *ahp = AH5416(ah);
- struct ath9k_channel *chan = ah->ah_curchan;
+ struct ieee80211_conf *conf = &ah->ah_sc->hw->conf;
struct ar5416AniState *aniState;
- enum wireless_mode mode;
int32_t rssi;

if (!DO_ANI(ah))
@@ -381,8 +378,7 @@ static void ath9k_hw_ani_cck_err_trigger(struct ath_hal *ah)
ath9k_hw_ani_control(ah, ATH9K_ANI_FIRSTEP_LEVEL,
aniState->firstepLevel + 1);
} else {
- mode = ath9k_hw_chan2wmode(ah, chan);
- if (mode == ATH9K_MODE_11G || mode == ATH9K_MODE_11B) {
+ if (conf->channel->band == IEEE80211_BAND_2GHZ) {
if (aniState->firstepLevel > 0)
ath9k_hw_ani_control(ah,
ATH9K_ANI_FIRSTEP_LEVEL, 0);
--
1.6.1.rc3.51.g5832d


2008-12-23 23:59:18

by Luis R. Rodriguez

[permalink] [raw]
Subject: [PATCH v3 07/16] ath9k: use ieee80211_conf on ath9k_hw_iscal_supported()

ath9k_hw_iscal_supported() just needs to be aware of your band
and if HT20 is being used so lets abandon our internal channel,
HT appended values and internal mode values and use ieee80211_conf
which already carries this information. This works as calibration
is being done for the currently configured channel.

Signed-off-by: Luis R. Rodriguez <[email protected]>
---
drivers/net/wireless/ath9k/ath9k.h | 3 +-
drivers/net/wireless/ath9k/calib.c | 63 ++++++++++++++---------------------
drivers/net/wireless/ath9k/main.c | 3 +-
3 files changed, 27 insertions(+), 42 deletions(-)

diff --git a/drivers/net/wireless/ath9k/ath9k.h b/drivers/net/wireless/ath9k/ath9k.h
index 78fffdf..adcd342 100644
--- a/drivers/net/wireless/ath9k/ath9k.h
+++ b/drivers/net/wireless/ath9k/ath9k.h
@@ -949,8 +949,7 @@ void ath9k_hw_ani_detach(struct ath_hal *ah);

/* Calibration */

-void ath9k_hw_reset_calvalid(struct ath_hal *ah, struct ath9k_channel *chan,
- bool *isCalDone);
+bool ath9k_hw_reset_calvalid(struct ath_hal *ah);
void ath9k_hw_start_nfcal(struct ath_hal *ah);
void ath9k_hw_loadnf(struct ath_hal *ah, struct ath9k_channel *chan);
int16_t ath9k_hw_getnf(struct ath_hal *ah,
diff --git a/drivers/net/wireless/ath9k/calib.c b/drivers/net/wireless/ath9k/calib.c
index 2a6b8a4..7072896 100644
--- a/drivers/net/wireless/ath9k/calib.c
+++ b/drivers/net/wireless/ath9k/calib.c
@@ -277,27 +277,24 @@ static void ath9k_hw_per_calibration(struct ath_hal *ah,
}
}

+/* Assumes you are talking about the currently configured channel */
static bool ath9k_hw_iscal_supported(struct ath_hal *ah,
- struct ath9k_channel *chan,
enum hal_cal_types calType)
{
struct ath_hal_5416 *ahp = AH5416(ah);
- bool retval = false;
+ struct ieee80211_conf *conf = &ah->ah_sc->hw->conf;

switch (calType & ahp->ah_suppCals) {
- case IQ_MISMATCH_CAL:
- if (!IS_CHAN_B(chan))
- retval = true;
- break;
+ case IQ_MISMATCH_CAL: /* Both 2 GHz and 5 GHz support OFDM */
+ return true;
case ADC_GAIN_CAL:
case ADC_DC_CAL:
- if (!IS_CHAN_B(chan)
- && !(IS_CHAN_2GHZ(chan) && IS_CHAN_HT20(chan)))
- retval = true;
+ if (conf->channel->band == IEEE80211_BAND_5GHZ &&
+ conf_is_ht20(conf))
+ return true;
break;
}
-
- return retval;
+ return false;
}

static void ath9k_hw_iqcal_collect(struct ath_hal *ah)
@@ -565,50 +562,40 @@ static void ath9k_hw_adc_dccal_calibrate(struct ath_hal *ah, u8 numChains)
AR_PHY_NEW_ADC_DC_OFFSET_CORR_ENABLE);
}

-void ath9k_hw_reset_calvalid(struct ath_hal *ah, struct ath9k_channel *chan,
- bool *isCalDone)
+/* This is done for the currently configured channel */
+bool ath9k_hw_reset_calvalid(struct ath_hal *ah)
{
struct ath_hal_5416 *ahp = AH5416(ah);
- struct ath9k_channel *ichan =
- ath9k_regd_check_channel(ah, chan);
+ struct ieee80211_conf *conf = &ah->ah_sc->hw->conf;
struct hal_cal_list *currCal = ahp->ah_cal_list_curr;

- *isCalDone = true;
+ if (!ah->ah_curchan)
+ return true;

if (!AR_SREV_9100(ah) && !AR_SREV_9160_10_OR_LATER(ah))
- return;
+ return true;

if (currCal == NULL)
- return;
-
- if (ichan == NULL) {
- DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
- "invalid channel %u/0x%x; no mapping\n",
- chan->channel, chan->channelFlags);
- return;
- }
-
+ return true;

if (currCal->calState != CAL_DONE) {
DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
"Calibration state incorrect, %d\n",
currCal->calState);
- return;
+ return true;
}

-
- if (!ath9k_hw_iscal_supported(ah, chan, currCal->calData->calType))
- return;
+ if (!ath9k_hw_iscal_supported(ah, currCal->calData->calType))
+ return true;

DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
- "Resetting Cal %d state for channel %u/0x%x\n",
- currCal->calData->calType, chan->channel,
- chan->channelFlags);
+ "Resetting Cal %d state for channel %u\n",
+ currCal->calData->calType, conf->channel->center_freq);

- ichan->CalValid &= ~currCal->calData->calType;
+ ah->ah_curchan->CalValid &= ~currCal->calData->calType;
currCal->calState = CAL_WAITING;

- *isCalDone = false;
+ return false;
}

void ath9k_hw_start_nfcal(struct ath_hal *ah)
@@ -933,19 +920,19 @@ bool ath9k_hw_init_cal(struct ath_hal *ah,
ahp->ah_cal_list = ahp->ah_cal_list_last = ahp->ah_cal_list_curr = NULL;

if (AR_SREV_9100(ah) || AR_SREV_9160_10_OR_LATER(ah)) {
- if (ath9k_hw_iscal_supported(ah, chan, ADC_GAIN_CAL)) {
+ if (ath9k_hw_iscal_supported(ah, ADC_GAIN_CAL)) {
INIT_CAL(&ahp->ah_adcGainCalData);
INSERT_CAL(ahp, &ahp->ah_adcGainCalData);
DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
"enabling ADC Gain Calibration.\n");
}
- if (ath9k_hw_iscal_supported(ah, chan, ADC_DC_CAL)) {
+ if (ath9k_hw_iscal_supported(ah, ADC_DC_CAL)) {
INIT_CAL(&ahp->ah_adcDcCalData);
INSERT_CAL(ahp, &ahp->ah_adcDcCalData);
DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
"enabling ADC DC Calibration.\n");
}
- if (ath9k_hw_iscal_supported(ah, chan, IQ_MISMATCH_CAL)) {
+ if (ath9k_hw_iscal_supported(ah, IQ_MISMATCH_CAL)) {
INIT_CAL(&ahp->ah_iqCalData);
INSERT_CAL(ahp, &ahp->ah_iqCalData);
DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
diff --git a/drivers/net/wireless/ath9k/main.c b/drivers/net/wireless/ath9k/main.c
index 7507d9a..5455d3c 100644
--- a/drivers/net/wireless/ath9k/main.c
+++ b/drivers/net/wireless/ath9k/main.c
@@ -372,8 +372,7 @@ static void ath_ani_calibrate(unsigned long data)
} else {
if ((timestamp - sc->sc_ani.sc_resetcal_timer) >=
ATH_RESTART_CALINTERVAL) {
- ath9k_hw_reset_calvalid(ah, ah->ah_curchan,
- &sc->sc_ani.sc_caldone);
+ sc->sc_ani.sc_caldone = ath9k_hw_reset_calvalid(ah);
if (sc->sc_ani.sc_caldone)
sc->sc_ani.sc_resetcal_timer = timestamp;
}
--
1.6.1.rc3.51.g5832d


2008-12-23 23:59:34

by Luis R. Rodriguez

[permalink] [raw]
Subject: [PATCH v3 13/16] ath9k: remove ath9k_hw_chan2wmode()

The only left users are for timing for ACK timeout, slotime and
CTS timeout. We currently use an array CLOCK_RATE to keep
these values per mode and since as only will use A and G
we can depend on the band to get the appropriate values.

We note that we should be using a different clock rate value
for CCK, we can do this in separate patch, currently this is
being disregarded and should only affect when we want to
change the default ACK/CTS timeout or slot time and stuck
with using using 802.11b.

Signed-off-by: Luis R. Rodriguez <[email protected]>
---
drivers/net/wireless/ath9k/hw.c | 46 ++++++++++++++++----------------------
1 files changed, 19 insertions(+), 27 deletions(-)

diff --git a/drivers/net/wireless/ath9k/hw.c b/drivers/net/wireless/ath9k/hw.c
index 85da799..3b61bfa 100644
--- a/drivers/net/wireless/ath9k/hw.c
+++ b/drivers/net/wireless/ath9k/hw.c
@@ -23,7 +23,9 @@
#include "phy.h"
#include "initvals.h"

-static const u8 CLOCK_RATE[] = { 40, 80, 22, 44, 88, 40 };
+#define ATH9K_CLOCK_RATE_CCK 22
+#define ATH9K_CLOCK_RATE_5GHZ_OFDM 40
+#define ATH9K_CLOCK_RATE_2GHZ_OFDM 44

extern struct hal_percal_data iq_cal_multi_sample;
extern struct hal_percal_data iq_cal_single_sample;
@@ -48,17 +50,18 @@ static void ath9k_hw_spur_mitigate(struct ath_hal *ah, struct ath9k_channel *cha

static u32 ath9k_hw_mac_usec(struct ath_hal *ah, u32 clks)
{
- if (ah->ah_curchan != NULL)
- return clks / CLOCK_RATE[ath9k_hw_chan2wmode(ah, ah->ah_curchan)];
- else
- return clks / CLOCK_RATE[ATH9K_MODE_11B];
+ struct ieee80211_conf *conf = &ah->ah_sc->hw->conf;
+ if (!ah->ah_curchan) /* should really check for CCK instead */
+ return clks / ATH9K_CLOCK_RATE_CCK;
+ if (conf->channel->band == IEEE80211_BAND_2GHZ)
+ return clks / ATH9K_CLOCK_RATE_2GHZ_OFDM;
+ return clks / ATH9K_CLOCK_RATE_5GHZ_OFDM;
}

static u32 ath9k_hw_mac_to_usec(struct ath_hal *ah, u32 clks)
{
- struct ath9k_channel *chan = ah->ah_curchan;
-
- if (chan && IS_CHAN_HT40(chan))
+ struct ieee80211_conf *conf = &ah->ah_sc->hw->conf;
+ if (conf_is_ht40(conf))
return ath9k_hw_mac_usec(ah, clks) / 2;
else
return ath9k_hw_mac_usec(ah, clks);
@@ -66,34 +69,23 @@ static u32 ath9k_hw_mac_to_usec(struct ath_hal *ah, u32 clks)

static u32 ath9k_hw_mac_clks(struct ath_hal *ah, u32 usecs)
{
- if (ah->ah_curchan != NULL)
- return usecs * CLOCK_RATE[ath9k_hw_chan2wmode(ah,
- ah->ah_curchan)];
- else
- return usecs * CLOCK_RATE[ATH9K_MODE_11B];
+ struct ieee80211_conf *conf = &ah->ah_sc->hw->conf;
+ if (!ah->ah_curchan) /* should really check for CCK instead */
+ return usecs *ATH9K_CLOCK_RATE_CCK;
+ if (conf->channel->band == IEEE80211_BAND_2GHZ)
+ return usecs *ATH9K_CLOCK_RATE_2GHZ_OFDM;
+ return usecs *ATH9K_CLOCK_RATE_5GHZ_OFDM;
}

static u32 ath9k_hw_mac_to_clks(struct ath_hal *ah, u32 usecs)
{
- struct ath9k_channel *chan = ah->ah_curchan;
-
- if (chan && IS_CHAN_HT40(chan))
+ struct ieee80211_conf *conf = &ah->ah_sc->hw->conf;
+ if (conf_is_ht40(conf))
return ath9k_hw_mac_clks(ah, usecs) * 2;
else
return ath9k_hw_mac_clks(ah, usecs);
}

-enum wireless_mode ath9k_hw_chan2wmode(struct ath_hal *ah,
- const struct ath9k_channel *chan)
-{
- if (IS_CHAN_B(chan))
- return ATH9K_MODE_11B;
- if (IS_CHAN_G(chan))
- return ATH9K_MODE_11G;
-
- return ATH9K_MODE_11A;
-}
-
bool ath9k_hw_wait(struct ath_hal *ah, u32 reg, u32 mask, u32 val)
{
int i;
--
1.6.1.rc3.51.g5832d


2008-12-23 23:59:13

by Luis R. Rodriguez

[permalink] [raw]
Subject: [PATCH v3 05/16] ath9k: consolidate arguments on hw reset

HW reset calls pass the same variables or structs
which we can obtain easily from ah. Although this also applies
during channel changes as we will keep around the ath9k_channel
passed as an argument for now.

We now also now propagate the hw reset errors down.

Signed-off-by: Luis R. Rodriguez <[email protected]>
---
drivers/net/wireless/ath9k/ath9k.h | 7 +--
drivers/net/wireless/ath9k/hw.c | 68 ++++++++--------------
drivers/net/wireless/ath9k/main.c | 110 ++++++++++++++----------------------
drivers/net/wireless/ath9k/xmit.c | 16 ++---
4 files changed, 74 insertions(+), 127 deletions(-)

diff --git a/drivers/net/wireless/ath9k/ath9k.h b/drivers/net/wireless/ath9k/ath9k.h
index d278135..0f6a99a 100644
--- a/drivers/net/wireless/ath9k/ath9k.h
+++ b/drivers/net/wireless/ath9k/ath9k.h
@@ -843,11 +843,8 @@ void ath9k_hw_rfdetach(struct ath_hal *ah);

/* HW Reset */

-bool ath9k_hw_reset(struct ath_hal *ah, struct ath9k_channel *chan,
- enum ath9k_ht_macmode macmode,
- u8 txchainmask, u8 rxchainmask,
- enum ath9k_ht_extprotspacing extprotspacing,
- bool bChannelChange, int *status);
+int ath9k_hw_reset(struct ath_hal *ah, struct ath9k_channel *chan,
+ bool bChannelChange);

/* Key Cache Management */

diff --git a/drivers/net/wireless/ath9k/hw.c b/drivers/net/wireless/ath9k/hw.c
index d2b0ecf..85da799 100644
--- a/drivers/net/wireless/ath9k/hw.c
+++ b/drivers/net/wireless/ath9k/hw.c
@@ -2223,23 +2223,20 @@ static void ath9k_hw_spur_mitigate(struct ath_hal *ah, struct ath9k_channel *cha
REG_WRITE(ah, AR_PHY_MASK2_P_61_45, tmp_mask);
}

-bool ath9k_hw_reset(struct ath_hal *ah, struct ath9k_channel *chan,
- enum ath9k_ht_macmode macmode,
- u8 txchainmask, u8 rxchainmask,
- enum ath9k_ht_extprotspacing extprotspacing,
- bool bChannelChange, int *status)
+int ath9k_hw_reset(struct ath_hal *ah, struct ath9k_channel *chan,
+ bool bChannelChange)
{
u32 saveLedState;
+ struct ath_softc *sc = ah->ah_sc;
struct ath_hal_5416 *ahp = AH5416(ah);
struct ath9k_channel *curchan = ah->ah_curchan;
u32 saveDefAntenna;
u32 macStaId1;
- int ecode;
- int i, rx_chainmask;
+ int i, rx_chainmask, r;

- ahp->ah_extprotspacing = extprotspacing;
- ahp->ah_txchainmask = txchainmask;
- ahp->ah_rxchainmask = rxchainmask;
+ ahp->ah_extprotspacing = sc->sc_ht_extprotspacing;
+ ahp->ah_txchainmask = sc->sc_tx_chainmask;
+ ahp->ah_rxchainmask = sc->sc_rx_chainmask;

if (AR_SREV_9280(ah)) {
ahp->ah_txchainmask &= 0x3;
@@ -2250,14 +2247,11 @@ bool ath9k_hw_reset(struct ath_hal *ah, struct ath9k_channel *chan,
DPRINTF(ah->ah_sc, ATH_DBG_CHANNEL,
"invalid channel %u/0x%x; no mapping\n",
chan->channel, chan->channelFlags);
- ecode = -EINVAL;
- goto bad;
+ return -EINVAL;
}

- if (!ath9k_hw_setpower(ah, ATH9K_PM_AWAKE)) {
- ecode = -EIO;
- goto bad;
- }
+ if (!ath9k_hw_setpower(ah, ATH9K_PM_AWAKE))
+ return -EIO;

if (curchan)
ath9k_hw_getnf(ah, curchan);
@@ -2271,10 +2265,10 @@ bool ath9k_hw_reset(struct ath_hal *ah, struct ath9k_channel *chan,
(!AR_SREV_9280(ah) || (!IS_CHAN_A_5MHZ_SPACED(chan) &&
!IS_CHAN_A_5MHZ_SPACED(ah->ah_curchan)))) {

- if (ath9k_hw_channel_change(ah, chan, macmode)) {
+ if (ath9k_hw_channel_change(ah, chan, sc->tx_chan_width)) {
ath9k_hw_loadnf(ah, ah->ah_curchan);
ath9k_hw_start_nfcal(ah);
- return true;
+ return 0;
}
}

@@ -2292,8 +2286,7 @@ bool ath9k_hw_reset(struct ath_hal *ah, struct ath9k_channel *chan,

if (!ath9k_hw_chip_reset(ah, chan)) {
DPRINTF(ah->ah_sc, ATH_DBG_RESET, "chip reset failed\n");
- ecode = -EINVAL;
- goto bad;
+ return -EINVAL;
}

if (AR_SREV_9280(ah)) {
@@ -2309,11 +2302,9 @@ bool ath9k_hw_reset(struct ath_hal *ah, struct ath9k_channel *chan,
ath9k_hw_cfg_output(ah, 9, AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
}

- ecode = ath9k_hw_process_ini(ah, chan, macmode);
- if (ecode != 0) {
- ecode = -EINVAL;
- goto bad;
- }
+ r = ath9k_hw_process_ini(ah, chan, sc->tx_chan_width);
+ if (r)
+ return r;

if (IS_CHAN_OFDM(chan) || IS_CHAN_HT(chan))
ath9k_hw_set_delta_slope(ah, chan);
@@ -2326,8 +2317,7 @@ bool ath9k_hw_reset(struct ath_hal *ah, struct ath9k_channel *chan,
if (!ath9k_hw_eeprom_set_board_values(ah, chan)) {
DPRINTF(ah->ah_sc, ATH_DBG_EEPROM,
"error setting board options\n");
- ecode = -EIO;
- goto bad;
+ return -EIO;
}

ath9k_hw_decrease_chain_power(ah, chan);
@@ -2355,15 +2345,11 @@ bool ath9k_hw_reset(struct ath_hal *ah, struct ath9k_channel *chan,
REG_WRITE(ah, AR_RSSI_THR, INIT_RSSI_THR);

if (AR_SREV_9280_10_OR_LATER(ah)) {
- if (!(ath9k_hw_ar9280_set_channel(ah, chan))) {
- ecode = -EIO;
- goto bad;
- }
+ if (!(ath9k_hw_ar9280_set_channel(ah, chan)))
+ return -EIO;
} else {
- if (!(ath9k_hw_set_channel(ah, chan))) {
- ecode = -EIO;
- goto bad;
- }
+ if (!(ath9k_hw_set_channel(ah, chan)))
+ return -EIO;
}

for (i = 0; i < AR_NUM_DCU; i++)
@@ -2397,10 +2383,8 @@ bool ath9k_hw_reset(struct ath_hal *ah, struct ath9k_channel *chan,

ath9k_hw_init_bb(ah, chan);

- if (!ath9k_hw_init_cal(ah, chan)){
- ecode = -EIO;;
- goto bad;
- }
+ if (!ath9k_hw_init_cal(ah, chan))
+ return -EIO;;

rx_chainmask = ahp->ah_rxchainmask;
if ((rx_chainmask == 0x5) || (rx_chainmask == 0x3)) {
@@ -2429,11 +2413,7 @@ bool ath9k_hw_reset(struct ath_hal *ah, struct ath9k_channel *chan,
#endif
}

- return true;
-bad:
- if (status)
- *status = ecode;
- return false;
+ return 0;
}

/************************/
diff --git a/drivers/net/wireless/ath9k/main.c b/drivers/net/wireless/ath9k/main.c
index 8127257..bbd7d06 100644
--- a/drivers/net/wireless/ath9k/main.c
+++ b/drivers/net/wireless/ath9k/main.c
@@ -260,6 +260,8 @@ static int ath_set_channel(struct ath_softc *sc, struct ath9k_channel *hchan)
struct ath_hal *ah = sc->sc_ah;
bool fastcc = true, stopped;
struct ieee80211_hw *hw = sc->hw;
+ struct ieee80211_channel *channel = hw->conf.channel;
+ int r;

if (sc->sc_flags & SC_OP_INVALID)
return -EIO;
@@ -268,7 +270,6 @@ static int ath_set_channel(struct ath_softc *sc, struct ath9k_channel *hchan)
hchan->channelFlags != sc->sc_ah->ah_curchan->channelFlags ||
(sc->sc_flags & SC_OP_CHAINMASK_UPDATE) ||
(sc->sc_flags & SC_OP_FULL_RESET)) {
- int status;
/*
* This is only performed if the channel settings have
* actually changed.
@@ -290,22 +291,20 @@ static int ath_set_channel(struct ath_softc *sc, struct ath9k_channel *hchan)
fastcc = false;

DPRINTF(sc, ATH_DBG_CONFIG,
- "(%u MHz) -> (%u MHz), cflags:%x, chanwidth: %d\n",
+ "(%u MHz) -> (%u MHz), chanwidth: %d\n",
sc->sc_ah->ah_curchan->channel,
- hchan->channel, hchan->channelFlags, sc->tx_chan_width);
+ channel->center_freq, sc->tx_chan_width);

spin_lock_bh(&sc->sc_resetlock);
- if (!ath9k_hw_reset(ah, hchan, sc->tx_chan_width,
- sc->sc_tx_chainmask, sc->sc_rx_chainmask,
- sc->sc_ht_extprotspacing, fastcc, &status)) {
+
+ r = ath9k_hw_reset(ah, hchan, fastcc);
+ if (r) {
DPRINTF(sc, ATH_DBG_FATAL,
- "Unable to reset channel %u (%uMhz) "
- "flags 0x%x hal status %u\n",
- ath9k_hw_mhz2ieee(ah, hchan->channel,
- hchan->channelFlags),
- hchan->channel, hchan->channelFlags, status);
+ "Unable to reset channel (%u Mhz) "
+ "reset status %u\n",
+ channel->center_freq, r);
spin_unlock_bh(&sc->sc_resetlock);
- return -EIO;
+ return r;
}
spin_unlock_bh(&sc->sc_resetlock);

@@ -1071,23 +1070,18 @@ fail:
static void ath_radio_enable(struct ath_softc *sc)
{
struct ath_hal *ah = sc->sc_ah;
- int status;
+ struct ieee80211_channel *channel = sc->hw->conf.channel;
+ int r;

spin_lock_bh(&sc->sc_resetlock);
- if (!ath9k_hw_reset(ah, ah->ah_curchan,
- sc->tx_chan_width,
- sc->sc_tx_chainmask,
- sc->sc_rx_chainmask,
- sc->sc_ht_extprotspacing,
- false, &status)) {
+
+ r = ath9k_hw_reset(ah, ah->ah_curchan, false);
+
+ if (r) {
DPRINTF(sc, ATH_DBG_FATAL,
- "Unable to reset channel %u (%uMhz) "
- "flags 0x%x hal status %u\n",
- ath9k_hw_mhz2ieee(ah,
- ah->ah_curchan->channel,
- ah->ah_curchan->channelFlags),
- ah->ah_curchan->channel,
- ah->ah_curchan->channelFlags, status);
+ "Unable to reset channel %u (%uMhz) ",
+ "reset status %u\n",
+ channel->center_freq, r);
}
spin_unlock_bh(&sc->sc_resetlock);

@@ -1115,8 +1109,8 @@ static void ath_radio_enable(struct ath_softc *sc)
static void ath_radio_disable(struct ath_softc *sc)
{
struct ath_hal *ah = sc->sc_ah;
- int status;
-
+ struct ieee80211_channel *channel = sc->hw->conf.channel;
+ int r;

ieee80211_stop_queues(sc->hw);

@@ -1132,20 +1126,12 @@ static void ath_radio_disable(struct ath_softc *sc)
ath_flushrecv(sc); /* flush recv queue */

spin_lock_bh(&sc->sc_resetlock);
- if (!ath9k_hw_reset(ah, ah->ah_curchan,
- sc->tx_chan_width,
- sc->sc_tx_chainmask,
- sc->sc_rx_chainmask,
- sc->sc_ht_extprotspacing,
- false, &status)) {
+ r = ath9k_hw_reset(ah, ah->ah_curchan, false);
+ if (r) {
DPRINTF(sc, ATH_DBG_FATAL,
"Unable to reset channel %u (%uMhz) "
- "flags 0x%x hal status %u\n",
- ath9k_hw_mhz2ieee(ah,
- ah->ah_curchan->channel,
- ah->ah_curchan->channelFlags),
- ah->ah_curchan->channel,
- ah->ah_curchan->channelFlags, status);
+ "reset status %u\n",
+ channel->center_freq, r);
}
spin_unlock_bh(&sc->sc_resetlock);

@@ -1624,8 +1610,7 @@ int ath_reset(struct ath_softc *sc, bool retry_tx)
{
struct ath_hal *ah = sc->sc_ah;
struct ieee80211_hw *hw = sc->hw;
- int status;
- int error = 0;
+ int r;

ath9k_hw_set_interrupts(ah, 0);
ath_draintxq(sc, retry_tx);
@@ -1633,14 +1618,10 @@ int ath_reset(struct ath_softc *sc, bool retry_tx)
ath_flushrecv(sc);

spin_lock_bh(&sc->sc_resetlock);
- if (!ath9k_hw_reset(ah, sc->sc_ah->ah_curchan,
- sc->tx_chan_width,
- sc->sc_tx_chainmask, sc->sc_rx_chainmask,
- sc->sc_ht_extprotspacing, false, &status)) {
+ r = ath9k_hw_reset(ah, sc->sc_ah->ah_curchan, false);
+ if (r)
DPRINTF(sc, ATH_DBG_FATAL,
- "Unable to reset hardware; hal status %u\n", status);
- error = -EIO;
- }
+ "Unable to reset hardware; reset status %u\n", r);
spin_unlock_bh(&sc->sc_resetlock);

if (ath_startrecv(sc) != 0)
@@ -1671,7 +1652,7 @@ int ath_reset(struct ath_softc *sc, bool retry_tx)
}
}

- return error;
+ return r;
}

/*
@@ -1854,7 +1835,7 @@ static int ath9k_start(struct ieee80211_hw *hw)
struct ath_softc *sc = hw->priv;
struct ieee80211_channel *curchan = hw->conf.channel;
struct ath9k_channel *init_channel;
- int error = 0, pos, status;
+ int r, pos;

DPRINTF(sc, ATH_DBG_CONFIG, "Starting driver with "
"initial channel: %d MHz\n", curchan->center_freq);
@@ -1864,8 +1845,7 @@ static int ath9k_start(struct ieee80211_hw *hw)
pos = ath_get_channel(sc, curchan);
if (pos == -1) {
DPRINTF(sc, ATH_DBG_FATAL, "Invalid channel: %d\n", curchan->center_freq);
- error = -EINVAL;
- goto error;
+ return -EINVAL;
}

sc->tx_chan_width = ATH9K_HT_MACMODE_20;
@@ -1884,17 +1864,14 @@ static int ath9k_start(struct ieee80211_hw *hw)
* and then setup of the interrupt mask.
*/
spin_lock_bh(&sc->sc_resetlock);
- if (!ath9k_hw_reset(sc->sc_ah, init_channel,
- sc->tx_chan_width,
- sc->sc_tx_chainmask, sc->sc_rx_chainmask,
- sc->sc_ht_extprotspacing, false, &status)) {
+ r = ath9k_hw_reset(sc->sc_ah, init_channel, false);
+ if (r) {
DPRINTF(sc, ATH_DBG_FATAL,
- "Unable to reset hardware; hal status %u "
- "(freq %u flags 0x%x)\n", status,
- init_channel->channel, init_channel->channelFlags);
- error = -EIO;
+ "Unable to reset hardware; reset status %u "
+ "(freq %u MHz)\n", r,
+ curchan->center_freq);
spin_unlock_bh(&sc->sc_resetlock);
- goto error;
+ return r;
}
spin_unlock_bh(&sc->sc_resetlock);

@@ -1914,8 +1891,7 @@ static int ath9k_start(struct ieee80211_hw *hw)
if (ath_startrecv(sc) != 0) {
DPRINTF(sc, ATH_DBG_FATAL,
"Unable to start recv logic\n");
- error = -EIO;
- goto error;
+ return -EIO;
}

/* Setup our intr mask. */
@@ -1959,11 +1935,9 @@ static int ath9k_start(struct ieee80211_hw *hw)
ieee80211_wake_queues(sc->hw);

#if defined(CONFIG_RFKILL) || defined(CONFIG_RFKILL_MODULE)
- error = ath_start_rfkill_poll(sc);
+ r = ath_start_rfkill_poll(sc);
#endif
-
-error:
- return error;
+ return r;
}

static int ath9k_tx(struct ieee80211_hw *hw,
diff --git a/drivers/net/wireless/ath9k/xmit.c b/drivers/net/wireless/ath9k/xmit.c
index 3e192fd..e28889b 100644
--- a/drivers/net/wireless/ath9k/xmit.c
+++ b/drivers/net/wireless/ath9k/xmit.c
@@ -1140,7 +1140,7 @@ static void ath_tx_stopdma(struct ath_softc *sc, struct ath_txq *txq)
static void ath_drain_txdataq(struct ath_softc *sc, bool retry_tx)
{
struct ath_hal *ah = sc->sc_ah;
- int i, status, npend = 0;
+ int i, npend = 0;

if (!(sc->sc_flags & SC_OP_INVALID)) {
for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) {
@@ -1155,20 +1155,16 @@ static void ath_drain_txdataq(struct ath_softc *sc, bool retry_tx)
}

if (npend) {
+ int r;
/* TxDMA not stopped, reset the hal */
DPRINTF(sc, ATH_DBG_XMIT, "Unable to stop TxDMA. Reset HAL!\n");

spin_lock_bh(&sc->sc_resetlock);
- if (!ath9k_hw_reset(ah,
- sc->sc_ah->ah_curchan,
- sc->tx_chan_width,
- sc->sc_tx_chainmask, sc->sc_rx_chainmask,
- sc->sc_ht_extprotspacing, true, &status)) {
-
+ r = ath9k_hw_reset(ah, sc->sc_ah->ah_curchan, true);
+ if (r)
DPRINTF(sc, ATH_DBG_FATAL,
- "Unable to reset hardware; hal status %u\n",
- status);
- }
+ "Unable to reset hardware; reset status %u\n",
+ r);
spin_unlock_bh(&sc->sc_resetlock);
}

--
1.6.1.rc3.51.g5832d


2008-12-23 23:59:02

by Luis R. Rodriguez

[permalink] [raw]
Subject: [PATCH v3 01/16] mac80211: add HT conf helpers

In HT capable drivers you often need to check if you
are currently using HT20 or HT40. This adds a few small
helpers to let drivers figure that out.

Signed-off-by: Luis R. Rodriguez <[email protected]>
Acked-by: Johannes Berg <[email protected]>
---
include/net/mac80211.h | 30 ++++++++++++++++++++++++++++++
1 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index b3bd00a..ee2b75e 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -1963,4 +1963,34 @@ rate_lowest_index(struct ieee80211_supported_band *sband,
int ieee80211_rate_control_register(struct rate_control_ops *ops);
void ieee80211_rate_control_unregister(struct rate_control_ops *ops);

+static inline bool
+conf_is_ht20(struct ieee80211_conf *conf)
+{
+ return conf->ht.channel_type == NL80211_CHAN_HT20;
+}
+
+static inline bool
+conf_is_ht40_minus(struct ieee80211_conf *conf)
+{
+ return conf->ht.channel_type == NL80211_CHAN_HT40MINUS;
+}
+
+static inline bool
+conf_is_ht40_plus(struct ieee80211_conf *conf)
+{
+ return conf->ht.channel_type == NL80211_CHAN_HT40PLUS;
+}
+
+static inline bool
+conf_is_ht40(struct ieee80211_conf *conf)
+{
+ return conf_is_ht40_minus(conf) || conf_is_ht40_plus(conf);
+}
+
+static inline bool
+conf_is_ht(struct ieee80211_conf *conf)
+{
+ return conf->ht.channel_type != NL80211_CHAN_NO_HT;
+}
+
#endif /* MAC80211_H */
--
1.6.1.rc3.51.g5832d


2008-12-23 23:59:32

by Luis R. Rodriguez

[permalink] [raw]
Subject: [PATCH v3 12/16] ath9k: remove mode specific default noise floor values

The NOISE_FLOOR array we have is mode specific, and the only
possible indexed values are A, B and G. The mode routine only
can return G or A, so this is band specific. Then since the
values for A and G (5ghz or 2ghz) are the same (-96) we simply
remove the array and use a static value.

If we later determine we want to use special values for
HT configurations we can use the new mac80211 conf_is_ht*()
helpers.

Signed-off-by: Luis R. Rodriguez <[email protected]>
---
drivers/net/wireless/ath9k/calib.c | 9 +++------
1 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/ath9k/calib.c b/drivers/net/wireless/ath9k/calib.c
index 7072896..8e073d6 100644
--- a/drivers/net/wireless/ath9k/calib.c
+++ b/drivers/net/wireless/ath9k/calib.c
@@ -19,8 +19,6 @@
#include "reg.h"
#include "phy.h"

-static const int16_t NOISE_FLOOR[] = { -96, -93, -98, -96, -93, -96 };
-
/* We can tune this as we go by monitoring really low values */
#define ATH9K_NF_TOO_LOW -60

@@ -740,10 +738,9 @@ s16 ath9k_hw_getchan_noise(struct ath_hal *ah, struct ath9k_channel *chan)
chan->channel, chan->channelFlags);
return ATH_DEFAULT_NOISE_FLOOR;
}
- if (ichan->rawNoiseFloor == 0) {
- enum wireless_mode mode = ath9k_hw_chan2wmode(ah, chan);
- nf = NOISE_FLOOR[mode];
- } else
+ if (ichan->rawNoiseFloor == 0)
+ nf = -96;
+ else
nf = ichan->rawNoiseFloor;

if (!ath9k_hw_nf_in_range(ah, nf))
--
1.6.1.rc3.51.g5832d


2008-12-23 23:59:16

by Luis R. Rodriguez

[permalink] [raw]
Subject: [PATCH v3 06/16] ath9k: make request to get the noisefloor threshold band specific

Lets make the request to get the current noise floor threshold
from the EEPROM band specific as it is band specific, not mode
specific.

This also adds a backpointer on the private channel structure
back to the ieee80211_channel structure as this is now needed during
ath9k_hw_getnf().

Signed-off-by: Luis R. Rodriguez <[email protected]>
---
drivers/net/wireless/ath9k/ath9k.h | 1 +
drivers/net/wireless/ath9k/calib.c | 21 +++++++--------------
drivers/net/wireless/ath9k/main.c | 2 ++
3 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/drivers/net/wireless/ath9k/ath9k.h b/drivers/net/wireless/ath9k/ath9k.h
index 0f6a99a..78fffdf 100644
--- a/drivers/net/wireless/ath9k/ath9k.h
+++ b/drivers/net/wireless/ath9k/ath9k.h
@@ -453,6 +453,7 @@ struct ath9k_11n_rate_series {
CHANNEL_HT40MINUS)

struct ath9k_channel {
+ struct ieee80211_channel *chan;
u16 channel;
u32 channelFlags;
u8 privFlags;
diff --git a/drivers/net/wireless/ath9k/calib.c b/drivers/net/wireless/ath9k/calib.c
index 3c7454f..2a6b8a4 100644
--- a/drivers/net/wireless/ath9k/calib.c
+++ b/drivers/net/wireless/ath9k/calib.c
@@ -168,26 +168,18 @@ static void ath9k_hw_do_getnf(struct ath_hal *ah,
}

static bool getNoiseFloorThresh(struct ath_hal *ah,
- const struct ath9k_channel *chan,
+ enum ieee80211_band band,
int16_t *nft)
{
- switch (chan->chanmode) {
- case CHANNEL_A:
- case CHANNEL_A_HT20:
- case CHANNEL_A_HT40PLUS:
- case CHANNEL_A_HT40MINUS:
+ switch (band) {
+ case IEEE80211_BAND_5GHZ:
*nft = (int8_t)ath9k_hw_get_eeprom(ah, EEP_NFTHRESH_5);
break;
- case CHANNEL_B:
- case CHANNEL_G:
- case CHANNEL_G_HT20:
- case CHANNEL_G_HT40PLUS:
- case CHANNEL_G_HT40MINUS:
+ case IEEE80211_BAND_2GHZ:
*nft = (int8_t)ath9k_hw_get_eeprom(ah, EEP_NFTHRESH_2);
break;
default:
- DPRINTF(ah->ah_sc, ATH_DBG_CHANNEL,
- "invalid channel flags 0x%x\n", chan->channelFlags);
+ BUG_ON(1);
return false;
}

@@ -692,6 +684,7 @@ int16_t ath9k_hw_getnf(struct ath_hal *ah,
int16_t nf, nfThresh;
int16_t nfarray[NUM_NF_READINGS] = { 0 };
struct ath9k_nfcal_hist *h;
+ struct ieee80211_channel *c = chan->chan;
u8 chainmask;

if (AR_SREV_9280(ah))
@@ -709,7 +702,7 @@ int16_t ath9k_hw_getnf(struct ath_hal *ah,
} else {
ath9k_hw_do_getnf(ah, nfarray);
nf = nfarray[0];
- if (getNoiseFloorThresh(ah, chan, &nfThresh)
+ if (getNoiseFloorThresh(ah, c->band, &nfThresh)
&& nf > nfThresh) {
DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
"noise floor failed detected; "
diff --git a/drivers/net/wireless/ath9k/main.c b/drivers/net/wireless/ath9k/main.c
index bbd7d06..7507d9a 100644
--- a/drivers/net/wireless/ath9k/main.c
+++ b/drivers/net/wireless/ath9k/main.c
@@ -218,6 +218,7 @@ static int ath_setup_channels(struct ath_softc *sc)
chan_2ghz[a].band = IEEE80211_BAND_2GHZ;
chan_2ghz[a].center_freq = c->channel;
chan_2ghz[a].max_power = c->maxTxPower;
+ c->chan = &chan_2ghz[a];

if (c->privFlags & CHANNEL_DISALLOW_ADHOC)
chan_2ghz[a].flags |= IEEE80211_CHAN_NO_IBSS;
@@ -233,6 +234,7 @@ static int ath_setup_channels(struct ath_softc *sc)
chan_5ghz[b].band = IEEE80211_BAND_5GHZ;
chan_5ghz[b].center_freq = c->channel;
chan_5ghz[b].max_power = c->maxTxPower;
+ c->chan = &chan_5ghz[a];

if (c->privFlags & CHANNEL_DISALLOW_ADHOC)
chan_5ghz[b].flags |= IEEE80211_CHAN_NO_IBSS;
--
1.6.1.rc3.51.g5832d


2008-12-23 23:59:42

by Luis R. Rodriguez

[permalink] [raw]
Subject: [PATCH v3 16/16] ath9k: fix sparse warnings

Fix sparse warnings:

drivers/net/wireless/ath9k/hw.c:1850:17: warning: symbol 'tmp' shadows an earlier one
drivers/net/wireless/ath9k/hw.c:1713:6: originally declared here
drivers/net/wireless/ath9k/hw.c:2051:17: warning: symbol 'tmp' shadows an earlier one
drivers/net/wireless/ath9k/hw.c:1961:6: originally declared here

drivers/net/wireless/ath9k/eeprom.c:195:6: warning: symbol 'ath9k_fill_eeprom' was not declared. Should it be static?
drivers/net/wireless/ath9k/eeprom.c:463:5: warning: symbol 'ath9k_check_eeprom' was not declared. Should it be static?
drivers/net/wireless/ath9k/eeprom.c:1219:6: warning: symbol 'ath9k_hw_set_def_power_per_rate_table' was not declared. Should it be static?
drivers/net/wireless/ath9k/eeprom.c:1510:6: warning: symbol 'ath9k_hw_set_4k_power_per_rate_table' was not declared. Should it be static?
drivers/net/wireless/ath9k/eeprom.c:2007:5: warning: symbol 'ath9k_set_txpower' was not declared. Should it be static?
drivers/net/wireless/ath9k/eeprom.c:2106:6: warning: symbol 'ath9k_set_addac' was not declared. Should it be static?
drivers/net/wireless/ath9k/eeprom.c:2543:6: warning: symbol 'ath9k_eeprom_set_board_values' was not declared. Should it be static?
drivers/net/wireless/ath9k/eeprom.c:2606:5: warning: symbol 'ath9k_get_eeprom_antenna_cfg' was not declared. Should it be static?
drivers/net/wireless/ath9k/eeprom.c:2622:4: warning: symbol 'ath9k_hw_get_4k_num_ant_config' was not declared. Should it be static?
drivers/net/wireless/ath9k/eeprom.c:2628:4: warning: symbol 'ath9k_hw_get_def_num_ant_config' was not declared. Should it be static?
drivers/net/wireless/ath9k/eeprom.c:2647:4: warning: symbol 'ath9k_get_num_ant_config' was not declared. Should it be static?
drivers/net/wireless/ath9k/eeprom.c:2790:5: warning: symbol 'ath9k_get_eeprom' was not declared. Should it be static?

drivers/net/wireless/ath9k/calib.c:962:30: warning: symbol 'iq_cal_multi_sample' was not declared. Should it be static?
drivers/net/wireless/ath9k/calib.c:969:30: warning: symbol 'iq_cal_single_sample' was not declared. Should it be static?
drivers/net/wireless/ath9k/calib.c:976:30: warning: symbol 'adc_gain_cal_multi_sample' was not declared. Should it be static?
drivers/net/wireless/ath9k/calib.c:983:30: warning: symbol 'adc_gain_cal_single_sample' was not declared. Should it be static?
drivers/net/wireless/ath9k/calib.c:990:30: warning: symbol 'adc_dc_cal_multi_sample' was not declared. Should it be static?
drivers/net/wireless/ath9k/calib.c:997:30: warning: symbol 'adc_dc_cal_single_sample' was not declared. Should it be static?
drivers/net/wireless/ath9k/calib.c:1004:30: warning: symbol 'adc_init_dc_cal' was not declared. Should it be static?

Signed-off-by: Luis R. Rodriguez <[email protected]>
---
drivers/net/wireless/ath9k/eeprom.c | 30 ++++++++++++++++--------------
drivers/net/wireless/ath9k/hw.c | 16 ++++------------
drivers/net/wireless/ath9k/hw.h | 8 ++++++++
3 files changed, 28 insertions(+), 26 deletions(-)

diff --git a/drivers/net/wireless/ath9k/eeprom.c b/drivers/net/wireless/ath9k/eeprom.c
index 14f8d40..ccf57c3 100644
--- a/drivers/net/wireless/ath9k/eeprom.c
+++ b/drivers/net/wireless/ath9k/eeprom.c
@@ -192,7 +192,7 @@ static bool ath9k_hw_fill_def_eeprom(struct ath_hal *ah)
#undef SIZE_EEPROM_DEF
}

-bool (*ath9k_fill_eeprom[]) (struct ath_hal *) = {
+static bool (*ath9k_fill_eeprom[]) (struct ath_hal *) = {
ath9k_hw_fill_def_eeprom,
ath9k_hw_fill_4k_eeprom
};
@@ -460,7 +460,7 @@ static int ath9k_hw_check_4k_eeprom(struct ath_hal *ah)
#undef EEPROM_4K_SIZE
}

-int (*ath9k_check_eeprom[]) (struct ath_hal *) = {
+static int (*ath9k_check_eeprom[]) (struct ath_hal *) = {
ath9k_hw_check_def_eeprom,
ath9k_hw_check_4k_eeprom
};
@@ -1216,7 +1216,7 @@ static bool ath9k_hw_set_4k_power_cal_table(struct ath_hal *ah,
return true;
}

-bool ath9k_hw_set_def_power_per_rate_table(struct ath_hal *ah,
+static bool ath9k_hw_set_def_power_per_rate_table(struct ath_hal *ah,
struct ath9k_channel *chan,
int16_t *ratesArray,
u16 cfgCtl,
@@ -1507,7 +1507,7 @@ bool ath9k_hw_set_def_power_per_rate_table(struct ath_hal *ah,
return true;
}

-bool ath9k_hw_set_4k_power_per_rate_table(struct ath_hal *ah,
+static bool ath9k_hw_set_4k_power_per_rate_table(struct ath_hal *ah,
struct ath9k_channel *chan,
int16_t *ratesArray,
u16 cfgCtl,
@@ -2004,7 +2004,7 @@ static int ath9k_hw_4k_set_txpower(struct ath_hal *ah,
return 0;
}

-int (*ath9k_set_txpower[]) (struct ath_hal *,
+static int (*ath9k_set_txpower[]) (struct ath_hal *,
struct ath9k_channel *,
u16, u8, u8, u8) = {
ath9k_hw_def_set_txpower,
@@ -2103,7 +2103,7 @@ static void ath9k_hw_set_4k_addac(struct ath_hal *ah,
}
}

-void (*ath9k_set_addac[]) (struct ath_hal *, struct ath9k_channel *) = {
+static void (*ath9k_set_addac[]) (struct ath_hal *, struct ath9k_channel *) = {
ath9k_hw_set_def_addac,
ath9k_hw_set_4k_addac
};
@@ -2540,7 +2540,7 @@ static bool ath9k_hw_eeprom_set_4k_board_values(struct ath_hal *ah,
return true;
}

-bool (*ath9k_eeprom_set_board_values[])(struct ath_hal *,
+static bool (*ath9k_eeprom_set_board_values[])(struct ath_hal *,
struct ath9k_channel *) = {
ath9k_hw_eeprom_set_def_board_values,
ath9k_hw_eeprom_set_4k_board_values
@@ -2603,7 +2603,8 @@ static int ath9k_hw_get_4k_eeprom_antenna_cfg(struct ath_hal *ah,
return -EINVAL;
}

-int (*ath9k_get_eeprom_antenna_cfg[])(struct ath_hal *, struct ath9k_channel *,
+static int (*ath9k_get_eeprom_antenna_cfg[])(struct ath_hal *,
+ struct ath9k_channel *,
u8, u16 *) = {
ath9k_hw_get_def_eeprom_antenna_cfg,
ath9k_hw_get_4k_eeprom_antenna_cfg
@@ -2619,13 +2620,13 @@ int ath9k_hw_get_eeprom_antenna_cfg(struct ath_hal *ah,
index, config);
}

-u8 ath9k_hw_get_4k_num_ant_config(struct ath_hal *ah,
+static u8 ath9k_hw_get_4k_num_ant_config(struct ath_hal *ah,
enum ieee80211_band freq_band)
{
return 1;
}

-u8 ath9k_hw_get_def_num_ant_config(struct ath_hal *ah,
+static u8 ath9k_hw_get_def_num_ant_config(struct ath_hal *ah,
enum ieee80211_band freq_band)
{
struct ath_hal_5416 *ahp = AH5416(ah);
@@ -2644,9 +2645,10 @@ u8 ath9k_hw_get_def_num_ant_config(struct ath_hal *ah,
return num_ant_config;
}

-u8 (*ath9k_get_num_ant_config[])(struct ath_hal *, enum ieee80211_band) = {
- ath9k_hw_get_def_num_ant_config,
- ath9k_hw_get_4k_num_ant_config
+static u8 (*ath9k_get_num_ant_config[])(struct ath_hal *,
+ enum ieee80211_band) = {
+ ath9k_hw_get_def_num_ant_config,
+ ath9k_hw_get_4k_num_ant_config
};

u8 ath9k_hw_get_num_ant_config(struct ath_hal *ah,
@@ -2787,7 +2789,7 @@ static u32 ath9k_hw_get_eeprom_def(struct ath_hal *ah,
}
}

-u32 (*ath9k_get_eeprom[])(struct ath_hal *, enum eeprom_param) = {
+static u32 (*ath9k_get_eeprom[])(struct ath_hal *, enum eeprom_param) = {
ath9k_hw_get_eeprom_def,
ath9k_hw_get_eeprom_4k
};
diff --git a/drivers/net/wireless/ath9k/hw.c b/drivers/net/wireless/ath9k/hw.c
index a6b0301..ff133c4 100644
--- a/drivers/net/wireless/ath9k/hw.c
+++ b/drivers/net/wireless/ath9k/hw.c
@@ -27,14 +27,6 @@
#define ATH9K_CLOCK_RATE_5GHZ_OFDM 40
#define ATH9K_CLOCK_RATE_2GHZ_OFDM 44

-extern struct hal_percal_data iq_cal_multi_sample;
-extern struct hal_percal_data iq_cal_single_sample;
-extern struct hal_percal_data adc_gain_cal_multi_sample;
-extern struct hal_percal_data adc_gain_cal_single_sample;
-extern struct hal_percal_data adc_dc_cal_multi_sample;
-extern struct hal_percal_data adc_dc_cal_single_sample;
-extern struct hal_percal_data adc_init_dc_cal;
-
static bool ath9k_hw_set_reset_reg(struct ath_hal *ah, u32 type);
static void ath9k_hw_set_regs(struct ath_hal *ah, struct ath9k_channel *chan,
enum ath9k_ht_macmode macmode);
@@ -1887,9 +1879,9 @@ static void ath9k_hw_9280_spur_mitigate(struct ath_hal *ah, struct ath9k_channel
if ((cur_vit_mask > lower) && (cur_vit_mask < upper)) {

/* workaround for gcc bug #37014 */
- volatile int tmp = abs(cur_vit_mask - bin);
+ volatile int tmp_v = abs(cur_vit_mask - bin);

- if (tmp < 75)
+ if (tmp_v < 75)
mask_amt = 1;
else
mask_amt = 0;
@@ -2088,9 +2080,9 @@ static void ath9k_hw_spur_mitigate(struct ath_hal *ah, struct ath9k_channel *cha
if ((cur_vit_mask > lower) && (cur_vit_mask < upper)) {

/* workaround for gcc bug #37014 */
- volatile int tmp = abs(cur_vit_mask - bin);
+ volatile int tmp_v = abs(cur_vit_mask - bin);

- if (tmp < 75)
+ if (tmp_v < 75)
mask_amt = 1;
else
mask_amt = 0;
diff --git a/drivers/net/wireless/ath9k/hw.h b/drivers/net/wireless/ath9k/hw.h
index 91d8f59..3ae3b88 100644
--- a/drivers/net/wireless/ath9k/hw.h
+++ b/drivers/net/wireless/ath9k/hw.h
@@ -20,6 +20,14 @@
#include <linux/if_ether.h>
#include <linux/delay.h>

+extern const struct hal_percal_data iq_cal_multi_sample;
+extern const struct hal_percal_data iq_cal_single_sample;
+extern const struct hal_percal_data adc_gain_cal_multi_sample;
+extern const struct hal_percal_data adc_gain_cal_single_sample;
+extern const struct hal_percal_data adc_dc_cal_multi_sample;
+extern const struct hal_percal_data adc_dc_cal_single_sample;
+extern const struct hal_percal_data adc_init_dc_cal;
+
struct ar5416_desc {
u32 ds_link;
u32 ds_data;
--
1.6.1.rc3.51.g5832d


2008-12-23 23:59:10

by Luis R. Rodriguez

[permalink] [raw]
Subject: [PATCH v3 04/16] ath9k: Rename ath_setcurmode() to ath_cache_conf_rate()

ath_setcurmode() is a bit misleading, all we are doing is
caching the rate for the corresponding configuration we
are using.

Signed-off-by: Luis R. Rodriguez <[email protected]>
---
drivers/net/wireless/ath9k/main.c | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/ath9k/main.c b/drivers/net/wireless/ath9k/main.c
index 28d9de1..8127257 100644
--- a/drivers/net/wireless/ath9k/main.c
+++ b/drivers/net/wireless/ath9k/main.c
@@ -59,7 +59,8 @@ static void bus_read_cachesize(struct ath_softc *sc, int *csz)
*csz = DEFAULT_CACHELINE >> 2; /* Use the default size */
}

-static void ath_setcurmode(struct ath_softc *sc, struct ieee80211_conf *conf)
+static void ath_cache_conf_rate(struct ath_softc *sc,
+ struct ieee80211_conf *conf)
{
switch (conf->channel->band) {
case IEEE80211_BAND_2GHZ:
@@ -91,6 +92,7 @@ static void ath_setcurmode(struct ath_softc *sc, struct ieee80211_conf *conf)
sc->hw_rate_table[ATH9K_MODE_11A];
break;
default:
+ BUG_ON(1);
break;
}
}
@@ -316,7 +318,7 @@ static int ath_set_channel(struct ath_softc *sc, struct ath9k_channel *hchan)
return -EIO;
}

- ath_setcurmode(sc, &hw->conf);
+ ath_cache_conf_rate(sc, &hw->conf);
ath_update_txpow(sc);
ath9k_hw_set_interrupts(ah, sc->sc_imask);
}
@@ -1649,7 +1651,7 @@ int ath_reset(struct ath_softc *sc, bool retry_tx)
* that changes the channel so update any state that
* might change as a result.
*/
- ath_setcurmode(sc, &hw->conf);
+ ath_cache_conf_rate(sc, &hw->conf);

ath_update_txpow(sc);

@@ -1946,7 +1948,7 @@ static int ath9k_start(struct ieee80211_hw *hw)
!sc->sc_config.swBeaconProcess)
sc->sc_imask |= ATH9K_INT_TIM;

- ath_setcurmode(sc, &hw->conf);
+ ath_cache_conf_rate(sc, &hw->conf);

sc->sc_flags &= ~SC_OP_INVALID;

--
1.6.1.rc3.51.g5832d


2008-12-23 23:59:39

by Luis R. Rodriguez

[permalink] [raw]
Subject: [PATCH v3 15/16] ath9k: remove superfluous check on changing channel

When we try to change the channel in ath9k its because
either the configuration indicates we *have* changed
channels or HT configuration has changed. In both cases
we want to do a reset. Either way mac80211 will inform us
when we want to actually change the channel so trust those
calls.

Although in the patch it may seem as I am doing more code
changes I am not, all I am doing is removing the initial
branch conditional and shifting the code to the left.

Signed-off-by: Luis R. Rodriguez <[email protected]>
---
drivers/net/wireless/ath9k/main.c | 97 +++++++++++++++++-------------------
1 files changed, 46 insertions(+), 51 deletions(-)

diff --git a/drivers/net/wireless/ath9k/main.c b/drivers/net/wireless/ath9k/main.c
index 99de021..6d1a1c2 100644
--- a/drivers/net/wireless/ath9k/main.c
+++ b/drivers/net/wireless/ath9k/main.c
@@ -268,61 +268,56 @@ static int ath_set_channel(struct ath_softc *sc, struct ath9k_channel *hchan)
if (sc->sc_flags & SC_OP_INVALID)
return -EIO;

- if (hchan->channel != sc->sc_ah->ah_curchan->channel ||
- hchan->channelFlags != sc->sc_ah->ah_curchan->channelFlags ||
- (sc->sc_flags & SC_OP_CHAINMASK_UPDATE) ||
- (sc->sc_flags & SC_OP_FULL_RESET)) {
- /*
- * This is only performed if the channel settings have
- * actually changed.
- *
- * To switch channels clear any pending DMA operations;
- * wait long enough for the RX fifo to drain, reset the
- * hardware at the new frequency, and then re-enable
- * the relevant bits of the h/w.
- */
- ath9k_hw_set_interrupts(ah, 0);
- ath_draintxq(sc, false);
- stopped = ath_stoprecv(sc);
+ /*
+ * This is only performed if the channel settings have
+ * actually changed.
+ *
+ * To switch channels clear any pending DMA operations;
+ * wait long enough for the RX fifo to drain, reset the
+ * hardware at the new frequency, and then re-enable
+ * the relevant bits of the h/w.
+ */
+ ath9k_hw_set_interrupts(ah, 0);
+ ath_draintxq(sc, false);
+ stopped = ath_stoprecv(sc);

- /* XXX: do not flush receive queue here. We don't want
- * to flush data frames already in queue because of
- * changing channel. */
+ /* XXX: do not flush receive queue here. We don't want
+ * to flush data frames already in queue because of
+ * changing channel. */

- if (!stopped || (sc->sc_flags & SC_OP_FULL_RESET))
- fastcc = false;
+ if (!stopped || (sc->sc_flags & SC_OP_FULL_RESET))
+ fastcc = false;

- DPRINTF(sc, ATH_DBG_CONFIG,
- "(%u MHz) -> (%u MHz), chanwidth: %d\n",
- sc->sc_ah->ah_curchan->channel,
- channel->center_freq, sc->tx_chan_width);
+ DPRINTF(sc, ATH_DBG_CONFIG,
+ "(%u MHz) -> (%u MHz), chanwidth: %d\n",
+ sc->sc_ah->ah_curchan->channel,
+ channel->center_freq, sc->tx_chan_width);

- spin_lock_bh(&sc->sc_resetlock);
+ spin_lock_bh(&sc->sc_resetlock);

- r = ath9k_hw_reset(ah, hchan, fastcc);
- if (r) {
- DPRINTF(sc, ATH_DBG_FATAL,
- "Unable to reset channel (%u Mhz) "
- "reset status %u\n",
- channel->center_freq, r);
- spin_unlock_bh(&sc->sc_resetlock);
- return r;
- }
+ r = ath9k_hw_reset(ah, hchan, fastcc);
+ if (r) {
+ DPRINTF(sc, ATH_DBG_FATAL,
+ "Unable to reset channel (%u Mhz) "
+ "reset status %u\n",
+ channel->center_freq, r);
spin_unlock_bh(&sc->sc_resetlock);
+ return r;
+ }
+ spin_unlock_bh(&sc->sc_resetlock);

- sc->sc_flags &= ~SC_OP_CHAINMASK_UPDATE;
- sc->sc_flags &= ~SC_OP_FULL_RESET;
-
- if (ath_startrecv(sc) != 0) {
- DPRINTF(sc, ATH_DBG_FATAL,
- "Unable to restart recv logic\n");
- return -EIO;
- }
+ sc->sc_flags &= ~SC_OP_CHAINMASK_UPDATE;
+ sc->sc_flags &= ~SC_OP_FULL_RESET;

- ath_cache_conf_rate(sc, &hw->conf);
- ath_update_txpow(sc);
- ath9k_hw_set_interrupts(ah, sc->sc_imask);
+ if (ath_startrecv(sc) != 0) {
+ DPRINTF(sc, ATH_DBG_FATAL,
+ "Unable to restart recv logic\n");
+ return -EIO;
}
+
+ ath_cache_conf_rate(sc, &hw->conf);
+ ath_update_txpow(sc);
+ ath9k_hw_set_interrupts(ah, sc->sc_imask);
return 0;
}

--
1.6.1.rc3.51.g5832d


2008-12-23 23:59:37

by Luis R. Rodriguez

[permalink] [raw]
Subject: [PATCH v3 14/16] ath9k: remove ath9k_hw_check_chan()

The only check we care about in ath9k_hw_check_chan() is
the internal regulatory check so use that.

Signed-off-by: Luis R. Rodriguez <[email protected]>
---
drivers/net/wireless/ath9k/hw.c | 26 +-------------------------
1 files changed, 1 insertions(+), 25 deletions(-)

diff --git a/drivers/net/wireless/ath9k/hw.c b/drivers/net/wireless/ath9k/hw.c
index 3b61bfa..a6b0301 100644
--- a/drivers/net/wireless/ath9k/hw.c
+++ b/drivers/net/wireless/ath9k/hw.c
@@ -1667,30 +1667,6 @@ static bool ath9k_hw_chip_reset(struct ath_hal *ah,
return true;
}

-static struct ath9k_channel *ath9k_hw_check_chan(struct ath_hal *ah,
- struct ath9k_channel *chan)
-{
- if (!(IS_CHAN_2GHZ(chan) ^ IS_CHAN_5GHZ(chan))) {
- DPRINTF(ah->ah_sc, ATH_DBG_CHANNEL,
- "invalid channel %u/0x%x; not marked as "
- "2GHz or 5GHz\n", chan->channel, chan->channelFlags);
- return NULL;
- }
-
- if (!IS_CHAN_OFDM(chan) &&
- !IS_CHAN_B(chan) &&
- !IS_CHAN_HT20(chan) &&
- !IS_CHAN_HT40(chan)) {
- DPRINTF(ah->ah_sc, ATH_DBG_CHANNEL,
- "invalid channel %u/0x%x; not marked as "
- "OFDM or CCK or HT20 or HT40PLUS or HT40MINUS\n",
- chan->channel, chan->channelFlags);
- return NULL;
- }
-
- return ath9k_regd_check_channel(ah, chan);
-}
-
static bool ath9k_hw_channel_change(struct ath_hal *ah,
struct ath9k_channel *chan,
enum ath9k_ht_macmode macmode)
@@ -2235,7 +2211,7 @@ int ath9k_hw_reset(struct ath_hal *ah, struct ath9k_channel *chan,
ahp->ah_rxchainmask &= 0x3;
}

- if (ath9k_hw_check_chan(ah, chan) == NULL) {
+ if (ath9k_regd_check_channel(ah, chan) == NULL) {
DPRINTF(ah->ah_sc, ATH_DBG_CHANNEL,
"invalid channel %u/0x%x; no mapping\n",
chan->channel, chan->channelFlags);
--
1.6.1.rc3.51.g5832d


2008-12-23 23:59:05

by Luis R. Rodriguez

[permalink] [raw]
Subject: [PATCH v3 02/16] ath9k: use hw->conf on ath_setcurmode()

We don't need to use our own mode for setting the
the routine tries to do, in fact lets remove ath_chan2mode() now as
we can simply use the currently set band and the HT configuration
provided by mac80211 through the ieee80211_conf. This works on
changing channels as well as the internal ath9k_channel we use is
based on the ieee80211_channel in the config.

Signed-off-by: Luis R. Rodriguez <[email protected]>
---
drivers/net/wireless/ath9k/main.c | 72 ++++++++++++++++++++----------------
1 files changed, 40 insertions(+), 32 deletions(-)

diff --git a/drivers/net/wireless/ath9k/main.c b/drivers/net/wireless/ath9k/main.c
index 70affb7..2bf2b3f 100644
--- a/drivers/net/wireless/ath9k/main.c
+++ b/drivers/net/wireless/ath9k/main.c
@@ -59,41 +59,47 @@ static void bus_read_cachesize(struct ath_softc *sc, int *csz)
*csz = DEFAULT_CACHELINE >> 2; /* Use the default size */
}

-static void ath_setcurmode(struct ath_softc *sc, enum wireless_mode mode)
+static void ath_setcurmode(struct ath_softc *sc, struct ieee80211_conf *conf)
{
- sc->cur_rate_table = sc->hw_rate_table[mode];
/*
* All protection frames are transmited at 2Mb/s for
* 11g, otherwise at 1Mb/s.
* XXX select protection rate index from rate table.
*/
- sc->sc_protrix = (mode == ATH9K_MODE_11G ? 1 : 0);
-}
-
-static enum wireless_mode ath_chan2mode(struct ath9k_channel *chan)
-{
- if (chan->chanmode == CHANNEL_A)
- return ATH9K_MODE_11A;
- else if (chan->chanmode == CHANNEL_G)
- return ATH9K_MODE_11G;
- else if (chan->chanmode == CHANNEL_B)
- return ATH9K_MODE_11B;
- else if (chan->chanmode == CHANNEL_A_HT20)
- return ATH9K_MODE_11NA_HT20;
- else if (chan->chanmode == CHANNEL_G_HT20)
- return ATH9K_MODE_11NG_HT20;
- else if (chan->chanmode == CHANNEL_A_HT40PLUS)
- return ATH9K_MODE_11NA_HT40PLUS;
- else if (chan->chanmode == CHANNEL_A_HT40MINUS)
- return ATH9K_MODE_11NA_HT40MINUS;
- else if (chan->chanmode == CHANNEL_G_HT40PLUS)
- return ATH9K_MODE_11NG_HT40PLUS;
- else if (chan->chanmode == CHANNEL_G_HT40MINUS)
- return ATH9K_MODE_11NG_HT40MINUS;
-
- WARN_ON(1); /* should not get here */
-
- return ATH9K_MODE_11B;
+ sc->sc_protrix = 0;
+ switch (conf->channel->band) {
+ case IEEE80211_BAND_2GHZ:
+ if (conf_is_ht20(conf))
+ sc->cur_rate_table =
+ sc->hw_rate_table[ATH9K_MODE_11NG_HT20];
+ else if (conf_is_ht40_minus(conf))
+ sc->cur_rate_table =
+ sc->hw_rate_table[ATH9K_MODE_11NG_HT40MINUS];
+ else if (conf_is_ht40_plus(conf))
+ sc->cur_rate_table =
+ sc->hw_rate_table[ATH9K_MODE_11NG_HT40PLUS];
+ else {
+ sc->sc_protrix = 1;
+ sc->cur_rate_table =
+ sc->hw_rate_table[ATH9K_MODE_11G];
+ }
+ break;
+ case IEEE80211_BAND_5GHZ:
+ if (conf_is_ht20(conf))
+ sc->cur_rate_table =
+ sc->hw_rate_table[ATH9K_MODE_11NA_HT20];
+ else if (conf_is_ht40_minus(conf))
+ sc->cur_rate_table =
+ sc->hw_rate_table[ATH9K_MODE_11NA_HT40MINUS];
+ else if (conf_is_ht40_plus(conf))
+ sc->cur_rate_table =
+ sc->hw_rate_table[ATH9K_MODE_11NA_HT40PLUS];
+ else
+ sc->cur_rate_table = sc->hw_rate_table[ATH9K_MODE_11A];
+ break;
+ default:
+ break;
+ }
}

static void ath_update_txpow(struct ath_softc *sc)
@@ -258,6 +264,7 @@ static int ath_set_channel(struct ath_softc *sc, struct ath9k_channel *hchan)
{
struct ath_hal *ah = sc->sc_ah;
bool fastcc = true, stopped;
+ struct ieee80211_hw *hw = sc->hw;

if (sc->sc_flags & SC_OP_INVALID)
return -EIO;
@@ -316,7 +323,7 @@ static int ath_set_channel(struct ath_softc *sc, struct ath9k_channel *hchan)
return -EIO;
}

- ath_setcurmode(sc, ath_chan2mode(hchan));
+ ath_setcurmode(sc, &hw->conf);
ath_update_txpow(sc);
ath9k_hw_set_interrupts(ah, sc->sc_imask);
}
@@ -1621,6 +1628,7 @@ detach:
int ath_reset(struct ath_softc *sc, bool retry_tx)
{
struct ath_hal *ah = sc->sc_ah;
+ struct ieee80211_hw *hw = sc->hw;
int status;
int error = 0;

@@ -1648,7 +1656,7 @@ int ath_reset(struct ath_softc *sc, bool retry_tx)
* that changes the channel so update any state that
* might change as a result.
*/
- ath_setcurmode(sc, ath_chan2mode(sc->sc_ah->ah_curchan));
+ ath_setcurmode(sc, &hw->conf);

ath_update_txpow(sc);

@@ -1945,7 +1953,7 @@ static int ath9k_start(struct ieee80211_hw *hw)
!sc->sc_config.swBeaconProcess)
sc->sc_imask |= ATH9K_INT_TIM;

- ath_setcurmode(sc, ath_chan2mode(init_channel));
+ ath_setcurmode(sc, &hw->conf);

sc->sc_flags &= ~SC_OP_INVALID;

--
1.6.1.rc3.51.g5832d


2008-12-29 15:45:09

by Luis R. Rodriguez

[permalink] [raw]
Subject: Re: [PATCH v3 02/16] ath9k: use hw->conf on ath_setcurmode()

On Sun, Dec 28, 2008 at 08:37:01PM -0800, Sujith Manoharan wrote:
> Luis Rodriguez wrote:
> > + switch (conf->channel->band) {
> > + case IEEE80211_BAND_2GHZ:
> > + if (conf_is_ht20(conf))
> > + sc->cur_rate_table =
> > + sc->hw_rate_table[ATH9K_MODE_11NG_HT20];
> > + else if (conf_is_ht40_minus(conf))
> > + sc->cur_rate_table =
> > + sc->hw_rate_table[ATH9K_MODE_11NG_HT40MINUS];
> > + else if (conf_is_ht40_plus(conf))
> > + sc->cur_rate_table =
> > + sc->hw_rate_table[ATH9K_MODE_11NG_HT40PLUS];
> > + else {
> > + sc->sc_protrix = 1;
> > + sc->cur_rate_table =
> > + sc->hw_rate_table[ATH9K_MODE_11G];
> > + }
> > + break;
> > + case IEEE80211_BAND_5GHZ:
> > + if (conf_is_ht20(conf))
> > + sc->cur_rate_table =
> > + sc->hw_rate_table[ATH9K_MODE_11NA_HT20];
> > + else if (conf_is_ht40_minus(conf))
> > + sc->cur_rate_table =
> > + sc->hw_rate_table[ATH9K_MODE_11NA_HT40MINUS];
> > + else if (conf_is_ht40_plus(conf))
> > + sc->cur_rate_table =
> > + sc->hw_rate_table[ATH9K_MODE_11NA_HT40PLUS];
> > + else
> > + sc->cur_rate_table = sc->hw_rate_table[ATH9K_MODE_11A];
> > + break;
> > + default:
> > + break;
> > + }
> > }
>
> We don't have separate rate tables for ht20, ht40+, ht40-.
> Setting cur_rate_table just once using conf_is_ht() to any HT mode would suffice.

I do see we have different rate tables for these though, do you mean we can
consolidate on the rate tables?

Luis

2008-12-23 23:59:24

by Luis R. Rodriguez

[permalink] [raw]
Subject: [PATCH v3 09/16] iwlwifi: make use of conf_is_ht*() helpers

Signed-off-by: Luis R. Rodriguez <[email protected]>
Acked-by: Johannes Berg <[email protected]>
---
drivers/net/wireless/iwlwifi/iwl-agn-rs.c | 6 +++---
drivers/net/wireless/iwlwifi/iwl-agn.c | 6 +++---
2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
index f032167..59d4e11 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
@@ -1131,7 +1131,7 @@ static int rs_switch_to_mimo2(struct iwl_priv *priv,
s32 rate;
s8 is_green = lq_sta->is_green;

- if (!conf->ht.enabled || !sta->ht_cap.ht_supported)
+ if (!conf_is_ht(conf) || !sta->ht_cap.ht_supported)
return -1;

if (((sta->ht_cap.cap & IEEE80211_HT_CAP_SM_PS) >> 2)
@@ -1198,7 +1198,7 @@ static int rs_switch_to_siso(struct iwl_priv *priv,
u8 is_green = lq_sta->is_green;
s32 rate;

- if (!conf->ht.enabled || !sta->ht_cap.ht_supported)
+ if (!conf_is_ht(conf) || !sta->ht_cap.ht_supported)
return -1;

IWL_DEBUG_RATE("LQ: try to switch to SISO\n");
@@ -1998,7 +1998,7 @@ lq_update:
* stay with best antenna legacy modulation for a while
* before next round of mode comparisons. */
tbl1 = &(lq_sta->lq_info[lq_sta->active_tbl]);
- if (is_legacy(tbl1->lq_type) && !conf->ht.enabled &&
+ if (is_legacy(tbl1->lq_type) && !conf_is_ht(conf) &&
lq_sta->action_counter >= 1) {
lq_sta->action_counter = 0;
IWL_DEBUG_RATE("LQ: STAY in legacy table\n");
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index 002a151..b2b566e 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -523,9 +523,9 @@ static void iwl_ht_conf(struct iwl_priv *priv,
*/

iwl_conf->extension_chan_offset = IEEE80211_HT_PARAM_CHA_SEC_NONE;
- if (priv->hw->conf.ht.channel_type == NL80211_CHAN_HT40MINUS)
+ if (conf_is_ht40_minus(&priv->hw->conf))
iwl_conf->extension_chan_offset = IEEE80211_HT_PARAM_CHA_SEC_BELOW;
- else if(priv->hw->conf.ht.channel_type == NL80211_CHAN_HT40PLUS)
+ else if (conf_is_ht40_plus(&priv->hw->conf))
iwl_conf->extension_chan_offset = IEEE80211_HT_PARAM_CHA_SEC_ABOVE;

/* If no above or below channel supplied disable FAT channel */
@@ -2553,7 +2553,7 @@ static int iwl_mac_config(struct ieee80211_hw *hw, u32 changed)
mutex_lock(&priv->mutex);
IWL_DEBUG_MAC80211("enter to channel %d\n", conf->channel->hw_value);

- priv->current_ht_config.is_ht = conf->ht.enabled;
+ priv->current_ht_config.is_ht = conf_is_ht(conf);

if (conf->radio_enabled && iwl_radio_kill_sw_enable_radio(priv)) {
IWL_DEBUG_MAC80211("leave - RF-KILL - waiting for uCode\n");
--
1.6.1.rc3.51.g5832d