Skip to contentSkip to conversation

ath9k: first series for regulatory cleanup

PATCH Superseded Luis R. Rodriguez 2 participants 23 messages Dec 22, 2008

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover 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. Since it seems other drivers can make use of this we add a priv section to ieee80211_channel and start making use of this in ath9k.

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 v2 addresses some of the comments made about the new HT conf helpers. I also keep the HT40 in 2 GHz band for ath9k as it is actually handled in mac80211. While at it I remove ht.enabled users as conf_is_ht() suffices now.

Luis R. Rodriguez (18):
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()
wireless: allow for private channel area
ath9k: start making use of channel->priv
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        |   13 +-
 drivers/net/wireless/ath9k/calib.c        |  103 ++++-----
 drivers/net/wireless/ath9k/core.h         |    1 -
 drivers/net/wireless/ath9k/eeprom.c       |   30 ++--
 drivers/net/wireless/ath9k/hw.c           |  210 ++++++--------------
 drivers/net/wireless/ath9k/hw.h           |    8 +
 drivers/net/wireless/ath9k/main.c         |  324 +++++++++++++----------------
 drivers/net/wireless/ath9k/rc.c           |    4 +-
 drivers/net/wireless/ath9k/xmit.c         |   29 ++--
 drivers/net/wireless/iwlwifi/iwl-agn-rs.c |    6 +-
 drivers/net/wireless/iwlwifi/iwl-agn.c    |    6 +-
 include/net/mac80211.h                    |   31 +++-
 include/net/wireless.h                    |    3 +
 net/mac80211/ht.c                         |    3 +-
 net/mac80211/main.c                       |   10 -
 net/mac80211/mlme.c                       |    1 -
 17 files changed, 339 insertions(+), 455 deletions(-)
#1 lore raw

PATCH v2 1/18 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.

---
 include/net/mac80211.h |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)
include/net/mac80211.h +30 -0
index b3bd00a..ee2b75e 100644
@@ -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 */
Signature · 1 line
1.6.1.rc3.51.g5832d
#2 lore raw

PATCH v2 2/18 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.

---
 drivers/net/wireless/ath9k/main.c |   72 ++++++++++++++++++++----------------
 1 files changed, 40 insertions(+), 32 deletions(-)
drivers/net/wireless/ath9k/main.c +40 -32
index 70affb7..2bf2b3f 100644
@@ -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;
 
Signature · 1 line
1.6.1.rc3.51.g5832d
#3 lore raw

PATCH v2 3/18 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.

---
 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(-)
drivers/net/wireless/ath9k/core.h +0 -1
index 4ca2aed..2bb35dd 100644
@@ -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;
drivers/net/wireless/ath9k/main.c +3 -10
index 2bf2b3f..28d9de1 100644
@@ -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;
drivers/net/wireless/ath9k/xmit.c +10 -3
index 3bfc3b9..b724ca2 100644
@@ -557,7 +557,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;
@@ -589,6 +590,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.
@@ -601,7 +608,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;
 	}
 
@@ -619,7 +626,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;
 	}
 
Signature · 1 line
1.6.1.rc3.51.g5832d
#4 lore raw

PATCH v2 4/18 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.

---
 drivers/net/wireless/ath9k/main.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)
drivers/net/wireless/ath9k/main.c +6 -4
index 28d9de1..8127257 100644
@@ -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;
 
Signature · 1 line
1.6.1.rc3.51.g5832d
#5 lore raw

PATCH v2 5/18 wireless: allow for private channel area

Wireless drivers tend to require calibration or noise floor checks. Some of these operations are channel specific. Instead of forcing each driver to keep a separate map for these values per channel allow for a private area on the ieee80211_channel to reduce code overhead and size.

---
 include/net/wireless.h |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
include/net/wireless.h +3 -0
index aedefa5..ecb5cf1 100644
@@ -71,6 +71,8 @@ enum ieee80211_channel_flags {
  * @max_power: maximum transmission power (in dBm)
  * @orig_mag: internal use
  * @orig_mpwr: internal use
+ * @priv: used by the driver for any of its own needs,
+ * 	could be used for example for calibration data.
  */
 struct ieee80211_channel {
 	enum ieee80211_band band;
@@ -82,6 +84,7 @@ struct ieee80211_channel {
 	int max_power;
 	u32 orig_flags;
 	int orig_mag, orig_mpwr;
+	void *priv;
 };
 
 /**
Signature · 1 line
1.6.1.rc3.51.g5832d
#6 lore raw

PATCH v2 6/18 ath9k: start making use of channel->priv

We start consolidating our internal channel by linking it to the standard ieee80211_channel in the private area. We can now slowly start removing redundant data.

---
 drivers/net/wireless/ath9k/ath9k.h |    2 +-
 drivers/net/wireless/ath9k/hw.c    |   50 +++--------------
 drivers/net/wireless/ath9k/main.c  |  106 ++++++++++++++++--------------------
 drivers/net/wireless/ath9k/xmit.c  |    2 +-
 4 files changed, 59 insertions(+), 101 deletions(-)
drivers/net/wireless/ath9k/ath9k.h +1 -1
index d278135..cd11eaf 100644
@@ -843,7 +843,7 @@ void ath9k_hw_rfdetach(struct ath_hal *ah);
 
 /* HW Reset */
 
-bool ath9k_hw_reset(struct ath_hal *ah, struct ath9k_channel *chan,
+bool ath9k_hw_reset(struct ath_hal *ah, struct ieee80211_channel *channel,
 		    enum ath9k_ht_macmode macmode,
 		    u8 txchainmask, u8 rxchainmask,
 		    enum ath9k_ht_extprotspacing extprotspacing,
drivers/net/wireless/ath9k/hw.c +9 -41

73 lines not on this page · raw message

drivers/net/wireless/ath9k/main.c +48 -58

258 lines not on this page · raw message

drivers/net/wireless/ath9k/xmit.c +1 -1
index b724ca2..249a8e5 100644
@@ -1171,7 +1171,7 @@ static void ath_drain_txdataq(struct ath_softc *sc, bool retry_tx)
 
 		spin_lock_bh(&sc->sc_resetlock);
 		if (!ath9k_hw_reset(ah,
-				    sc->sc_ah->ah_curchan,
+				    sc->hw->conf.channel,
 				    sc->tx_chan_width,
 				    sc->sc_tx_chainmask, sc->sc_rx_chainmask,
 				    sc->sc_ht_extprotspacing, true, &status)) {
Signature · 1 line
1.6.1.rc3.51.g5832d
#7 lore raw

PATCH v2 7/18 ath9k: consolidate arguments on hw reset

HW reset calls pass the same variables or structs which we can obtain easily from ah, this also applies during channel changes as we always follow the ieee80211_conf channel so consolidate the arguments.

We now also now propagate the hw reset errors down.

---
 drivers/net/wireless/ath9k/ath9k.h |    7 +---
 drivers/net/wireless/ath9k/hw.c    |   76 +++++++++++++----------------------
 drivers/net/wireless/ath9k/main.c  |   78 +++++++++++++-----------------------
 drivers/net/wireless/ath9k/xmit.c  |   14 ++-----
 4 files changed, 61 insertions(+), 114 deletions(-)
drivers/net/wireless/ath9k/ath9k.h +1 -6
index cd11eaf..823f1d6 100644
@@ -842,12 +842,7 @@ void ath9k_hw_rfdetach(struct ath_hal *ah);
 
 
 /* HW Reset */
-
-bool ath9k_hw_reset(struct ath_hal *ah, struct ieee80211_channel *channel,
-		    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, bool bChannelChange);
 
 /* Key Cache Management */
 
drivers/net/wireless/ath9k/hw.c +28 -48

146 lines not on this page · raw message

drivers/net/wireless/ath9k/main.c +28 -50

186 lines not on this page · raw message

drivers/net/wireless/ath9k/xmit.c +4 -10
index 249a8e5..16456dc 100644
@@ -1151,7 +1151,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, r, npend = 0;
 
 	if (!(sc->sc_flags & SC_OP_INVALID)) {
 		for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) {
@@ -1170,16 +1170,10 @@ static void ath_drain_txdataq(struct ath_softc *sc, bool retry_tx)
 		DPRINTF(sc, ATH_DBG_XMIT, "Unable to stop TxDMA. Reset HAL!\n");
 
 		spin_lock_bh(&sc->sc_resetlock);
-		if (!ath9k_hw_reset(ah,
-				    sc->hw->conf.channel,
-				    sc->tx_chan_width,
-				    sc->sc_tx_chainmask, sc->sc_rx_chainmask,
-				    sc->sc_ht_extprotspacing, true, &status)) {
-
+		r = ath9k_hw_reset(ah, true);
+		if (r)
 			DPRINTF(sc, ATH_DBG_FATAL,
-				"Unable to reset hardware; hal status %u\n",
-				status);
-		}
+				"Unable to reset hardware; hal status %u\n", r);
 		spin_unlock_bh(&sc->sc_resetlock);
 	}
 
Signature · 1 line
1.6.1.rc3.51.g5832d
#8 lore raw

PATCH v2 8/18 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 hw reset when it tries to get the current EEPROM noise floor threshold.

Finally we note that calibration always works on the current channel and because of this the "internal" channel will always be the current channel. Because this is true we don't need to clear the CHANNEL_CW_INT flag anymore. This is currently unused but can be used later in AP mode.

---
 drivers/net/wireless/ath9k/ath9k.h |    3 ++-
 drivers/net/wireless/ath9k/calib.c |   27 ++++++++++-----------------
 drivers/net/wireless/ath9k/hw.c    |    2 +-
 drivers/net/wireless/ath9k/main.c  |    2 ++
 4 files changed, 15 insertions(+), 19 deletions(-)
drivers/net/wireless/ath9k/ath9k.h +2 -1
index 823f1d6..8e47802 100644
@@ -453,6 +453,7 @@ struct ath9k_11n_rate_series {
 	 CHANNEL_HT40MINUS)
 
 struct ath9k_channel {
+	struct ieee80211_channel *chan;
 	u16 channel;
 	u32 channelFlags;
 	u8 privFlags;
@@ -951,7 +952,7 @@ void ath9k_hw_reset_calvalid(struct ath_hal *ah, struct ath9k_channel *chan,
 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,
-		       struct ath9k_channel *chan);
+		       struct ieee80211_channel *c);
 void ath9k_init_nfcal_hist_buffer(struct ath_hal *ah);
 s16 ath9k_hw_getchan_noise(struct ath_hal *ah, struct ath9k_channel *chan);
 bool ath9k_hw_calibrate(struct ath_hal *ah, struct ath9k_channel *chan,
drivers/net/wireless/ath9k/calib.c +10 -17
index 3c7454f..c72bf10 100644
@@ -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;
 	}
 
@@ -687,11 +679,12 @@ void ath9k_hw_loadnf(struct ath_hal *ah, struct ath9k_channel *chan)
 }
 
 int16_t ath9k_hw_getnf(struct ath_hal *ah,
-		       struct ath9k_channel *chan)
+		       struct ieee80211_channel *c)
 {
 	int16_t nf, nfThresh;
 	int16_t nfarray[NUM_NF_READINGS] = { 0 };
 	struct ath9k_nfcal_hist *h;
+	struct ath9k_channel *chan = (struct ath9k_channel *) c->priv;
 	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; "
@@ -805,13 +798,13 @@ bool ath9k_hw_calibrate(struct ath_hal *ah, struct ath9k_channel *chan,
 	}
 
 	if (longcal) {
-		ath9k_hw_getnf(ah, ichan);
+		BUG_ON(chan != ichan);
+		ath9k_hw_getnf(ah, ichan->chan);
 		ath9k_hw_loadnf(ah, ah->ah_curchan);
 		ath9k_hw_start_nfcal(ah);
 
 		if ((ichan->channelFlags & CHANNEL_CW_INT) != 0) {
 			chan->channelFlags |= CHANNEL_CW_INT;
-			ichan->channelFlags &= ~CHANNEL_CW_INT;
 		}
 	}
 
drivers/net/wireless/ath9k/hw.c +1 -1
index 60cc0ba..eb0ec06 100644
@@ -2222,7 +2222,7 @@ int ath9k_hw_reset(struct ath_hal *ah, bool bChannelChange)
 		return -EIO;
 
 	if (curchan)
-		ath9k_hw_getnf(ah, curchan);
+		ath9k_hw_getnf(ah, curchan->chan);
 
 	if (bChannelChange &&
 	    (ahp->ah_chipFullSleep != true) &&
drivers/net/wireless/ath9k/main.c +2 -0
index f7302a5..e7b2677 100644
@@ -219,6 +219,7 @@ static int ath_setup_channels(struct ath_softc *sc)
 			chan_2ghz[a].center_freq = c->channel;
 			chan_2ghz[a].max_power = c->maxTxPower;
 			chan_2ghz[a].priv = c;
+			c->chan = &chan_2ghz[a];
 
 			if (c->privFlags & CHANNEL_DISALLOW_ADHOC)
 				chan_2ghz[a].flags |= IEEE80211_CHAN_NO_IBSS;
@@ -234,6 +235,7 @@ static int ath_setup_channels(struct ath_softc *sc)
 			chan_5ghz[b].center_freq = c->channel;
 			chan_5ghz[b].max_power = c->maxTxPower;
 			chan_5ghz[b].priv = c;
+			c->chan = &chan_5ghz[a];
 
 			if (c->privFlags & CHANNEL_DISALLOW_ADHOC)
 				chan_5ghz[b].flags |= IEEE80211_CHAN_NO_IBSS;
Signature · 1 line
1.6.1.rc3.51.g5832d
#9 lore raw

PATCH v2 9/18 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.

---
 drivers/net/wireless/ath9k/ath9k.h |    3 +-
 drivers/net/wireless/ath9k/calib.c |   67 +++++++++++++++++------------------
 drivers/net/wireless/ath9k/main.c  |    3 +-
 3 files changed, 35 insertions(+), 38 deletions(-)
drivers/net/wireless/ath9k/ath9k.h +1 -2
index 8e47802..10c61ed 100644
@@ -947,8 +947,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,
drivers/net/wireless/ath9k/calib.c +33 -34

129 lines not on this page · raw message

drivers/net/wireless/ath9k/main.c +1 -2
index e7b2677..0c2f6d0 100644
@@ -379,8 +379,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;
 		}
Signature · 1 line
1.6.1.rc3.51.g5832d
#10 lore raw

PATCH v2 10/18 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.

---
 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(-)
drivers/net/wireless/ath9k/main.c +3 -4
index 0c2f6d0..1299f52 100644
@@ -2128,9 +2128,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;
 
 			priv_channel->chanmode =
@@ -2144,7 +2143,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)
drivers/net/wireless/ath9k/rc.c +2 -2
index 04ab457..469b374 100644
@@ -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;
drivers/net/wireless/ath9k/xmit.c +1 -1
index 16456dc..986e527 100644
@@ -1699,7 +1699,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);
Signature · 1 line
1.6.1.rc3.51.g5832d
#11 lore raw

PATCH v2 11/18 iwlwifi: make use of conf_is_ht*() helpers

---
 drivers/net/wireless/iwlwifi/iwl-agn-rs.c |    6 +++---
 drivers/net/wireless/iwlwifi/iwl-agn.c    |    6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)
drivers/net/wireless/iwlwifi/iwl-agn-rs.c +3 -3
index f032167..59d4e11 100644
@@ -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");
drivers/net/wireless/iwlwifi/iwl-agn.c +3 -3
index 05cd04c..99a17d8 100644
@@ -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");
Signature · 1 line
1.6.1.rc3.51.g5832d
#12 lore raw

PATCH v2 12/18 mac80211: no need for ht.enabled

We can simply use conf_is_ht() check where needed.

---
 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(-)
include/net/mac80211.h +0 -1
index ee2b75e..b51caab 100644
@@ -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;
 };
 
net/mac80211/ht.c +1 -2
index 55bfe48..6314289 100644
@@ -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);
net/mac80211/main.c +0 -10
index 24b1436..a6cb480 100644
@@ -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;
 	}
 
net/mac80211/mlme.c +0 -1
index c75d0ea..6558209 100644
@@ -874,7 +874,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;
 
Signature · 1 line
1.6.1.rc3.51.g5832d
#13 lore raw

PATCH v2 13/18 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.

---
 drivers/net/wireless/ath9k/ani.c |   12 ++++--------
 1 files changed, 4 insertions(+), 8 deletions(-)
drivers/net/wireless/ath9k/ani.c +4 -8
index 251e2d9..4dd0860 100644
@@ -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);
Signature · 1 line
1.6.1.rc3.51.g5832d
#14 lore raw

PATCH v2 14/18 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.

---
 drivers/net/wireless/ath9k/calib.c |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)
drivers/net/wireless/ath9k/calib.c +3 -6
index 74369c1..f82554b 100644
@@ -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
 
@@ -752,10 +750,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))
Signature · 1 line
1.6.1.rc3.51.g5832d
#15 lore raw

PATCH v2 15/18 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.

---
 drivers/net/wireless/ath9k/hw.c |   46 ++++++++++++++++----------------------
 1 files changed, 19 insertions(+), 27 deletions(-)
drivers/net/wireless/ath9k/hw.c +19 -27
index eb0ec06..436fbc8 100644
@@ -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;
Signature · 1 line
1.6.1.rc3.51.g5832d
#16 lore raw

PATCH v2 16/18 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.

---
 drivers/net/wireless/ath9k/hw.c |   30 +++---------------------------
 1 files changed, 3 insertions(+), 27 deletions(-)
drivers/net/wireless/ath9k/hw.c +3 -27
index 436fbc8..7d5ca81 100644
@@ -1627,30 +1627,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)
@@ -2203,10 +2179,10 @@ int ath9k_hw_reset(struct ath_hal *ah, bool bChannelChange)
 		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);
+			"invalid channel %u; no mapping\n",
+			channel->center_freq);
 		return -EINVAL;
 	}
 
Signature · 1 line
1.6.1.rc3.51.g5832d
#17 lore raw

PATCH v2 17/18 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.

---
 drivers/net/wireless/ath9k/main.c |  101 +++++++++++++++++-------------------
 1 files changed, 48 insertions(+), 53 deletions(-)
drivers/net/wireless/ath9k/main.c +43 -48
index 1299f52..1d916db 100644
@@ -273,63 +273,58 @@ static int ath_set_channel(struct ath_softc *sc, struct ieee80211_channel *c)
 
 	hchan = (struct ath9k_channel *) c->priv;
 
-	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,
-			c->center_freq, sc->tx_chan_width);
+	DPRINTF(sc, ATH_DBG_CONFIG,
+		"(%u MHz) -> (%u MHz), chanwidth: %d\n",
+		sc->sc_ah->ah_curchan->channel,
+		c->center_freq, sc->tx_chan_width);
 
-		spin_lock_bh(&sc->sc_resetlock);
+	spin_lock_bh(&sc->sc_resetlock);
 
-		r = ath9k_hw_reset(ah, fastcc);
-		if (r) {
-			DPRINTF(sc, ATH_DBG_FATAL,
-				"Unable to reset channel %u (%uMhz) "
-				"hal status %u\n",
-				ieee80211_frequency_to_channel(c->center_freq),
-				c->center_freq,
-				r);
-			spin_unlock_bh(&sc->sc_resetlock);
-			return r;
-		}
+	r = ath9k_hw_reset(ah, fastcc);
+	if (r) {
+		DPRINTF(sc, ATH_DBG_FATAL,
+		  "Unable to reset channel %u (%uMhz) "
+		  "hal status %u\n",
+		  ieee80211_frequency_to_channel(c->center_freq),
+		  c->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;
 }
 
Signature · 1 line
1.6.1.rc3.51.g5832d
#18 lore raw

PATCH v2 18/18 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?

---
 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(-)
drivers/net/wireless/ath9k/eeprom.c +16 -14
index 14f8d40..ccf57c3 100644
@@ -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
 };
drivers/net/wireless/ath9k/hw.c +4 -12
index 7d5ca81..75ab052 100644
@@ -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);
@@ -1847,9 +1839,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;
@@ -2048,9 +2040,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;
drivers/net/wireless/ath9k/hw.h +8 -0
index 91d8f59..3ae3b88 100644
@@ -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;
Signature · 1 line
1.6.1.rc3.51.g5832d
maintainer
#19 lore raw

PATCH v2 12/18 mac80211: no need for ht.enabled

In reply to Luis R. Rodriguez
Quoted 3 lines · Luis Rodriguez

We can simply use conf_is_ht() check where needed.

Quoted 70 lines
---
 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(-)
include/net/mac80211.h +0 -1
index ee2b75e..b51caab 100644
@@ -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;
 };
 
net/mac80211/ht.c +1 -2
index 55bfe48..6314289 100644
@@ -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);
net/mac80211/main.c +0 -10
index 24b1436..a6cb480 100644
@@ -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;
        }
 
net/mac80211/mlme.c +0 -2
index c75d0ea..6558209 100644
@@ -874,7 +874,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;
 
--
Quoted 3 lines

1.6.1.rc3.51.g5832d

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part
Url : http://lists.ath9k.org/pipermail/ath9k-devel/attachments/20081222/343e1177/attachment.pgp

maintainer
#20 lore raw

PATCH v2 11/18 iwlwifi: make use of conf_is_ht*() helpers

In reply to Luis R. Rodriguez
Quoted 1 line · Luis Rodriguez
Quoted 65 lines
---
 drivers/net/wireless/iwlwifi/iwl-agn-rs.c |    6 +++---
 drivers/net/wireless/iwlwifi/iwl-agn.c    |    6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)
drivers/net/wireless/iwlwifi/iwl-agn-rs.c +3 -3
index f032167..59d4e11 100644
@@ -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");
drivers/net/wireless/iwlwifi/iwl-agn.c +3 -4
index 05cd04c..99a17d8 100644
@@ -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

maintainer
#21 lore raw

PATCH v2 1/18 mac80211: add HT conf helpers

In reply to Luis R. Rodriguez
Quoted 5 lines · Luis Rodriguez

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.

Quoted 44 lines
---
 include/net/mac80211.h |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)
include/net/mac80211.h +30 -1
index b3bd00a..ee2b75e 100644
@@ -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 */
--
Quoted 3 lines

1.6.1.rc3.51.g5832d

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part
Url : http://lists.ath9k.org/pipermail/ath9k-devel/attachments/20081222/9bfdf839/attachment.pgp

#22 lore raw

v2 cover ath9k: first series for regulatory cleanup

In reply to Luis R. Rodriguez
Quoted 11 lines · Luis R. Rodriguez

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. Since it seems other drivers can make use of this we add a priv section to ieee80211_channel and start making use of this in ath9k.

John,

I will go back and try to redo this series without the channel->priv addition as the calibration data is band specific so in reality there should be no need to have a private section per channel for calibration that I can see so far. Additionally as Johannes has pointed out to me we should be able to index into our own tables for whatever private data later once we have a static declaration of the channels.

Luis