Linux wireless drivers development
 help / color / mirror / Atom feed
* Re: question about ieee80211_tx.c (fwd)
From: Zhu Yi @ 2009-08-18  1:13 UTC (permalink / raw)
  To: Gábor Stefanik
  Cc: Julia Lawall, linux-wireless@vger.kernel.org, gregkh@suse.de
In-Reply-To: <69e28c910908170450l65d493dbnb1d2e8f14d29dadc@mail.gmail.com>

On Mon, 2009-08-17 at 19:50 +0800, Gábor Stefanik wrote:
> On Mon, Aug 17, 2009 at 10:03 AM, Julia Lawall<julia@diku.dk> wrote:
> > The files ieee80211_tx.c in the directories
> > drivers/staging/rtl8192su/ieee80211 and
> drivers/staging/rtl8192e/ieee80211
> > both contain the following code in the function
> > ieee80211_query_protectionmode:
> >
> >       if (ieee->mode == IW_MODE_MASTER)
> >                        goto NO_PROTECTION;
> >
> > Elsewhere in these files when there is a comparison against an
> IW_MODE
> > value, the field that is compared is iw_mode.  Should that be the
> case
> > here as well?
> >
> > thanks,
> > julia
> 
> I don't know; rtl8192su & rtl8192e use a modified version of the
> libipw stack, rather than the mac80211 stack found behind non-staging
> drivers.

This is clearly a bug. The question is: who is maintaining this driver
and why it doesn't use/extend ieee80211/libipw?

Thanks,
-yi


^ permalink raw reply

* [PATCH] ath: move regulatory info into shared common structure
From: Luis R. Rodriguez @ 2009-08-18  1:07 UTC (permalink / raw)
  To: linux-wireless; +Cc: Luis R. Rodriguez

This moves the shared regulatory structure into the
common structure. We will use this ongoing for common
data.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
---

OK this goes now tested on ath5k, ath9k, and ar9170.

 drivers/net/wireless/ath/ar9170/ar9170.h     |    2 +-
 drivers/net/wireless/ath/ar9170/main.c       |   14 ++++---
 drivers/net/wireless/ath/ath.h               |   18 +++++++++
 drivers/net/wireless/ath/ath5k/ath5k.h       |    3 -
 drivers/net/wireless/ath/ath5k/base.c        |   14 +++---
 drivers/net/wireless/ath/ath5k/base.h        |   13 ++++++
 drivers/net/wireless/ath/ath5k/phy.c         |    3 +-
 drivers/net/wireless/ath/ath9k/ath9k.h       |   10 +++++
 drivers/net/wireless/ath/ath9k/eeprom_4k.c   |    8 ++-
 drivers/net/wireless/ath/ath9k/eeprom_9287.c |   16 ++++----
 drivers/net/wireless/ath/ath9k/eeprom_def.c  |   14 ++++---
 drivers/net/wireless/ath/ath9k/hw.c          |   53 +++++++++++++++-----------
 drivers/net/wireless/ath/ath9k/hw.h          |    1 -
 drivers/net/wireless/ath/ath9k/main.c        |    6 +-
 drivers/net/wireless/ath/regd.h              |   20 +---------
 15 files changed, 116 insertions(+), 79 deletions(-)

diff --git a/drivers/net/wireless/ath/ar9170/ar9170.h b/drivers/net/wireless/ath/ar9170/ar9170.h
index e6c3ee3..95f8256 100644
--- a/drivers/net/wireless/ath/ar9170/ar9170.h
+++ b/drivers/net/wireless/ath/ar9170/ar9170.h
@@ -157,6 +157,7 @@ struct ar9170_sta_tid {
 
 struct ar9170 {
 	struct ieee80211_hw *hw;
+	struct ath_common common;
 	struct mutex mutex;
 	enum ar9170_device_state state;
 	unsigned long bad_hw_nagger;
@@ -222,7 +223,6 @@ struct ar9170 {
 
 	/* EEPROM */
 	struct ar9170_eeprom eeprom;
-	struct ath_regulatory regulatory;
 
 	/* tx queues - as seen by hw - */
 	struct sk_buff_head tx_pending[__AR9170_NUM_TXQ];
diff --git a/drivers/net/wireless/ath/ar9170/main.c b/drivers/net/wireless/ath/ar9170/main.c
index 6a9462e..d30f33d 100644
--- a/drivers/net/wireless/ath/ar9170/main.c
+++ b/drivers/net/wireless/ath/ar9170/main.c
@@ -2641,6 +2641,7 @@ static int ar9170_read_eeprom(struct ar9170 *ar)
 {
 #define RW	8	/* number of words to read at once */
 #define RB	(sizeof(u32) * RW)
+	struct ath_regulatory *regulatory = &ar->common.regulatory;
 	u8 *eeprom = (void *)&ar->eeprom;
 	u8 *addr = ar->eeprom.mac_address;
 	__le32 offsets[RW];
@@ -2707,8 +2708,8 @@ static int ar9170_read_eeprom(struct ar9170 *ar)
 	else
 		ar->hw->channel_change_time = 80 * 1000;
 
-	ar->regulatory.current_rd = le16_to_cpu(ar->eeprom.reg_domain[0]);
-	ar->regulatory.current_rd_ext = le16_to_cpu(ar->eeprom.reg_domain[1]);
+	regulatory->current_rd = le16_to_cpu(ar->eeprom.reg_domain[0]);
+	regulatory->current_rd_ext = le16_to_cpu(ar->eeprom.reg_domain[1]);
 
 	/* second part of wiphy init */
 	SET_IEEE80211_PERM_ADDR(ar->hw, addr);
@@ -2722,11 +2723,12 @@ static int ar9170_reg_notifier(struct wiphy *wiphy,
 	struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
 	struct ar9170 *ar = hw->priv;
 
-	return ath_reg_notifier_apply(wiphy, request, &ar->regulatory);
+	return ath_reg_notifier_apply(wiphy, request, &ar->common.regulatory);
 }
 
 int ar9170_register(struct ar9170 *ar, struct device *pdev)
 {
+	struct ath_regulatory *regulatory = &ar->common.regulatory;
 	int err;
 
 	/* try to read EEPROM, init MAC addr */
@@ -2734,7 +2736,7 @@ int ar9170_register(struct ar9170 *ar, struct device *pdev)
 	if (err)
 		goto err_out;
 
-	err = ath_regd_init(&ar->regulatory, ar->hw->wiphy,
+	err = ath_regd_init(regulatory, ar->hw->wiphy,
 			    ar9170_reg_notifier);
 	if (err)
 		goto err_out;
@@ -2743,8 +2745,8 @@ int ar9170_register(struct ar9170 *ar, struct device *pdev)
 	if (err)
 		goto err_out;
 
-	if (!ath_is_world_regd(&ar->regulatory))
-		regulatory_hint(ar->hw->wiphy, ar->regulatory.alpha2);
+	if (!ath_is_world_regd(regulatory))
+		regulatory_hint(ar->hw->wiphy, regulatory->alpha2);
 
 	err = ar9170_init_leds(ar);
 	if (err)
diff --git a/drivers/net/wireless/ath/ath.h b/drivers/net/wireless/ath/ath.h
index e284cd3..a63e90c 100644
--- a/drivers/net/wireless/ath/ath.h
+++ b/drivers/net/wireless/ath/ath.h
@@ -19,8 +19,26 @@
 
 #include <linux/skbuff.h>
 
+struct reg_dmn_pair_mapping {
+	u16 regDmnEnum;
+	u16 reg_5ghz_ctl;
+	u16 reg_2ghz_ctl;
+};
+
+struct ath_regulatory {
+	char alpha2[2];
+	u16 country_code;
+	u16 max_power_level;
+	u32 tp_scale;
+	u16 current_rd;
+	u16 current_rd_ext;
+	int16_t power_limit;
+	struct reg_dmn_pair_mapping *regpair;
+};
+
 struct ath_common {
 	u16 cachelsz;
+	struct ath_regulatory regulatory;
 };
 
 struct sk_buff *ath_rxbuf_alloc(struct ath_common *common,
diff --git a/drivers/net/wireless/ath/ath5k/ath5k.h b/drivers/net/wireless/ath/ath5k/ath5k.h
index c09402e..862762c 100644
--- a/drivers/net/wireless/ath/ath5k/ath5k.h
+++ b/drivers/net/wireless/ath/ath5k/ath5k.h
@@ -27,8 +27,6 @@
 #include <linux/types.h>
 #include <net/mac80211.h>
 
-#include "../regd.h"
-
 /* RX/TX descriptor hw structs
  * TODO: Driver part should only see sw structs */
 #include "desc.h"
@@ -1077,7 +1075,6 @@ struct ath5k_hw {
 
 	int			ah_gpio_npins;
 
-	struct ath_regulatory	ah_regulatory;
 	struct ath5k_capabilities ah_capabilities;
 
 	struct ath5k_txq_info	ah_txq[AR5K_NUM_TX_QUEUES];
diff --git a/drivers/net/wireless/ath/ath5k/base.c b/drivers/net/wireless/ath/ath5k/base.c
index 3951b5b..5056410 100644
--- a/drivers/net/wireless/ath/ath5k/base.c
+++ b/drivers/net/wireless/ath/ath5k/base.c
@@ -718,9 +718,9 @@ static int ath5k_reg_notifier(struct wiphy *wiphy, struct regulatory_request *re
 {
 	struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
 	struct ath5k_softc *sc = hw->priv;
-	struct ath_regulatory *reg = &sc->ah->ah_regulatory;
+	struct ath_regulatory *regulatory = &sc->common.regulatory;
 
-	return ath_reg_notifier_apply(wiphy, request, reg);
+	return ath_reg_notifier_apply(wiphy, request, regulatory);
 }
 
 static int
@@ -728,6 +728,7 @@ ath5k_attach(struct pci_dev *pdev, struct ieee80211_hw *hw)
 {
 	struct ath5k_softc *sc = hw->priv;
 	struct ath5k_hw *ah = sc->ah;
+	struct ath_regulatory *regulatory = &sc->common.regulatory;
 	u8 mac[ETH_ALEN] = {};
 	int ret;
 
@@ -817,9 +818,8 @@ ath5k_attach(struct pci_dev *pdev, struct ieee80211_hw *hw)
 	memset(sc->bssidmask, 0xff, ETH_ALEN);
 	ath5k_hw_set_bssid_mask(sc->ah, sc->bssidmask);
 
-	ah->ah_regulatory.current_rd =
-		ah->ah_capabilities.cap_eeprom.ee_regdomain;
-	ret = ath_regd_init(&ah->ah_regulatory, hw->wiphy, ath5k_reg_notifier);
+	regulatory->current_rd = ah->ah_capabilities.cap_eeprom.ee_regdomain;
+	ret = ath_regd_init(regulatory, hw->wiphy, ath5k_reg_notifier);
 	if (ret) {
 		ATH5K_ERR(sc, "can't initialize regulatory system\n");
 		goto err_queues;
@@ -831,8 +831,8 @@ ath5k_attach(struct pci_dev *pdev, struct ieee80211_hw *hw)
 		goto err_queues;
 	}
 
-	if (!ath_is_world_regd(&sc->ah->ah_regulatory))
-		regulatory_hint(hw->wiphy, sc->ah->ah_regulatory.alpha2);
+	if (!ath_is_world_regd(regulatory))
+		regulatory_hint(hw->wiphy, regulatory->alpha2);
 
 	ath5k_init_leds(sc);
 
diff --git a/drivers/net/wireless/ath/ath5k/base.h b/drivers/net/wireless/ath/ath5k/base.h
index 25a72a8..a28c42f 100644
--- a/drivers/net/wireless/ath/ath5k/base.h
+++ b/drivers/net/wireless/ath/ath5k/base.h
@@ -50,6 +50,8 @@
 
 #include "ath5k.h"
 #include "debug.h"
+
+#include "../regd.h"
 #include "../ath.h"
 
 #define	ATH_RXBUF	40		/* number of RX buffers */
@@ -200,4 +202,15 @@ struct ath5k_softc {
 #define ath5k_hw_hasveol(_ah) \
 	(ath5k_hw_get_capability(_ah, AR5K_CAP_VEOL, 0, NULL) == 0)
 
+static inline struct ath_common *ath5k_hw_common(struct ath5k_hw *ah)
+{
+	return &ah->ah_sc->common;
+}
+
+static inline struct ath_regulatory *ath5k_hw_regulatory(struct ath5k_hw *ah)
+{
+	return &(ath5k_hw_common(ah)->regulatory);
+
+}
+
 #endif
diff --git a/drivers/net/wireless/ath/ath5k/phy.c b/drivers/net/wireless/ath/ath5k/phy.c
index 298fcf0..1a039f2 100644
--- a/drivers/net/wireless/ath/ath5k/phy.c
+++ b/drivers/net/wireless/ath/ath5k/phy.c
@@ -2198,6 +2198,7 @@ static void
 ath5k_get_max_ctl_power(struct ath5k_hw *ah,
 			struct ieee80211_channel *channel)
 {
+	struct ath_regulatory *regulatory = ath5k_hw_regulatory(ah);
 	struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom;
 	struct ath5k_edge_power *rep = ee->ee_ctl_pwr;
 	u8 *ctl_val = ee->ee_ctl;
@@ -2208,7 +2209,7 @@ ath5k_get_max_ctl_power(struct ath5k_hw *ah,
 	u8 ctl_idx = 0xFF;
 	u32 target = channel->center_freq;
 
-	ctl_mode = ath_regd_get_band_ctl(&ah->ah_regulatory, channel->band);
+	ctl_mode = ath_regd_get_band_ctl(regulatory, channel->band);
 
 	switch (channel->hw_value & CHANNEL_MODES) {
 	case CHANNEL_A:
diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h
index 2c9f662..0e444a6 100644
--- a/drivers/net/wireless/ath/ath9k/ath9k.h
+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
@@ -631,6 +631,16 @@ int ath_get_hal_qnum(u16 queue, struct ath_softc *sc);
 int ath_get_mac80211_qnum(u32 queue, struct ath_softc *sc);
 int ath_cabq_update(struct ath_softc *);
 
+static inline struct ath_common *ath9k_hw_common(struct ath_hw *ah)
+{
+	return &ah->ah_sc->common;
+}
+
+static inline struct ath_regulatory *ath9k_hw_regulatory(struct ath_hw *ah)
+{
+	return &(ath9k_hw_common(ah)->regulatory);
+}
+
 static inline void ath_read_cachesize(struct ath_softc *sc, int *csz)
 {
 	sc->bus_ops->read_cachesize(sc, csz);
diff --git a/drivers/net/wireless/ath/ath9k/eeprom_4k.c b/drivers/net/wireless/ath/ath9k/eeprom_4k.c
index d34dd23..b8eca7b 100644
--- a/drivers/net/wireless/ath/ath9k/eeprom_4k.c
+++ b/drivers/net/wireless/ath/ath9k/eeprom_4k.c
@@ -508,6 +508,7 @@ static void ath9k_hw_set_4k_power_per_rate_table(struct ath_hw *ah,
 	|| (((cfgCtl & ~CTL_MODE_M) | (pCtlMode[ctlMode] & CTL_MODE_M)) == \
 	    ((pEepData->ctlIndex[i] & CTL_MODE_M) | SD_NO_CTL))
 
+	struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
 	int i;
 	int16_t twiceLargestAntenna;
 	u16 twiceMinEdgePower;
@@ -541,9 +542,9 @@ static void ath9k_hw_set_4k_power_per_rate_table(struct ath_hw *ah,
 					   twiceLargestAntenna, 0);
 
 	maxRegAllowedPower = twiceMaxRegulatoryPower + twiceLargestAntenna;
-	if (ah->regulatory.tp_scale != ATH9K_TP_SCALE_MAX) {
+	if (regulatory->tp_scale != ATH9K_TP_SCALE_MAX) {
 		maxRegAllowedPower -=
-			(tpScaleReductionTable[(ah->regulatory.tp_scale)] * 2);
+			(tpScaleReductionTable[(regulatory->tp_scale)] * 2);
 	}
 
 	scaledPower = min(powerLimit, maxRegAllowedPower);
@@ -707,6 +708,7 @@ static void ath9k_hw_4k_set_txpower(struct ath_hw *ah,
 				    u8 twiceMaxRegulatoryPower,
 				    u8 powerLimit)
 {
+	struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
 	struct ar5416_eeprom_4k *pEepData = &ah->eeprom.map4k;
 	struct modal_eep_4k_header *pModal = &pEepData->modalHeader;
 	int16_t ratesArray[Ar5416RateSize];
@@ -744,7 +746,7 @@ static void ath9k_hw_4k_set_txpower(struct ath_hw *ah,
 	else if (IS_CHAN_HT20(chan))
 		i = rateHt20_0;
 
-	ah->regulatory.max_power_level = ratesArray[i];
+	regulatory->max_power_level = ratesArray[i];
 
 	if (AR_SREV_9280_10_OR_LATER(ah)) {
 		for (i = 0; i < Ar5416RateSize; i++)
diff --git a/drivers/net/wireless/ath/ath9k/eeprom_9287.c b/drivers/net/wireless/ath/ath9k/eeprom_9287.c
index 9590979..c20c21a 100644
--- a/drivers/net/wireless/ath/ath9k/eeprom_9287.c
+++ b/drivers/net/wireless/ath/ath9k/eeprom_9287.c
@@ -599,7 +599,7 @@ static void ath9k_hw_set_AR9287_power_per_rate_table(struct ath_hw *ah,
 {
 #define REDUCE_SCALED_POWER_BY_TWO_CHAIN     6
 #define REDUCE_SCALED_POWER_BY_THREE_CHAIN   10
-
+	struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
 	u16 twiceMaxEdgePower = AR5416_MAX_RATE_POWER;
 	static const u16 tpScaleReductionTable[5] =
 		{ 0, 3, 6, 9, AR5416_MAX_RATE_POWER };
@@ -632,9 +632,9 @@ static void ath9k_hw_set_AR9287_power_per_rate_table(struct ath_hw *ah,
 					    twiceLargestAntenna, 0);
 
 	maxRegAllowedPower = twiceMaxRegulatoryPower + twiceLargestAntenna;
-	if (ah->regulatory.tp_scale != ATH9K_TP_SCALE_MAX)
+	if (regulatory->tp_scale != ATH9K_TP_SCALE_MAX)
 		maxRegAllowedPower -=
-			(tpScaleReductionTable[(ah->regulatory.tp_scale)] * 2);
+			(tpScaleReductionTable[(regulatory->tp_scale)] * 2);
 
 	scaledPower = min(powerLimit, maxRegAllowedPower);
 
@@ -831,7 +831,7 @@ static void ath9k_hw_AR9287_set_txpower(struct ath_hw *ah,
 {
 #define INCREASE_MAXPOW_BY_TWO_CHAIN     6
 #define INCREASE_MAXPOW_BY_THREE_CHAIN   10
-
+	struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
 	struct ar9287_eeprom *pEepData = &ah->eeprom.map9287;
 	struct modal_eep_ar9287_header *pModal = &pEepData->modalHeader;
 	int16_t ratesArray[Ar5416RateSize];
@@ -949,20 +949,20 @@ static void ath9k_hw_AR9287_set_txpower(struct ath_hw *ah,
 		i = rate6mb;
 
 	if (AR_SREV_9280_10_OR_LATER(ah))
-		ah->regulatory.max_power_level =
+		regulatory->max_power_level =
 			ratesArray[i] + AR9287_PWR_TABLE_OFFSET_DB * 2;
 	else
-		ah->regulatory.max_power_level = ratesArray[i];
+		regulatory->max_power_level = ratesArray[i];
 
 	switch (ar5416_get_ntxchains(ah->txchainmask)) {
 	case 1:
 		break;
 	case 2:
-		ah->regulatory.max_power_level +=
+		regulatory->max_power_level +=
 			INCREASE_MAXPOW_BY_TWO_CHAIN;
 		break;
 	case 3:
-		ah->regulatory.max_power_level +=
+		regulatory->max_power_level +=
 			INCREASE_MAXPOW_BY_THREE_CHAIN;
 		break;
 	default:
diff --git a/drivers/net/wireless/ath/ath9k/eeprom_def.c b/drivers/net/wireless/ath/ath9k/eeprom_def.c
index 5211ad9..ae7fb5d 100644
--- a/drivers/net/wireless/ath/ath9k/eeprom_def.c
+++ b/drivers/net/wireless/ath/ath9k/eeprom_def.c
@@ -904,6 +904,7 @@ static void ath9k_hw_set_def_power_per_rate_table(struct ath_hw *ah,
 #define REDUCE_SCALED_POWER_BY_TWO_CHAIN     6  /* 10*log10(2)*2 */
 #define REDUCE_SCALED_POWER_BY_THREE_CHAIN   10 /* 10*log10(3)*2 */
 
+	struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
 	struct ar5416_eeprom_def *pEepData = &ah->eeprom.def;
 	u16 twiceMaxEdgePower = AR5416_MAX_RATE_POWER;
 	static const u16 tpScaleReductionTable[5] =
@@ -953,9 +954,9 @@ static void ath9k_hw_set_def_power_per_rate_table(struct ath_hw *ah,
 
 	maxRegAllowedPower = twiceMaxRegulatoryPower + twiceLargestAntenna;
 
-	if (ah->regulatory.tp_scale != ATH9K_TP_SCALE_MAX) {
+	if (regulatory->tp_scale != ATH9K_TP_SCALE_MAX) {
 		maxRegAllowedPower -=
-			(tpScaleReductionTable[(ah->regulatory.tp_scale)] * 2);
+			(tpScaleReductionTable[(regulatory->tp_scale)] * 2);
 	}
 
 	scaledPower = min(powerLimit, maxRegAllowedPower);
@@ -1163,6 +1164,7 @@ static void ath9k_hw_def_set_txpower(struct ath_hw *ah,
 				    u8 powerLimit)
 {
 #define RT_AR_DELTA(x) (ratesArray[x] - cck_ofdm_delta)
+	struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
 	struct ar5416_eeprom_def *pEepData = &ah->eeprom.def;
 	struct modal_eep_header *pModal =
 		&(pEepData->modalHeader[IS_CHAN_2GHZ(chan)]);
@@ -1292,19 +1294,19 @@ static void ath9k_hw_def_set_txpower(struct ath_hw *ah,
 		i = rateHt20_0;
 
 	if (AR_SREV_9280_10_OR_LATER(ah))
-		ah->regulatory.max_power_level =
+		regulatory->max_power_level =
 			ratesArray[i] + AR5416_PWR_TABLE_OFFSET * 2;
 	else
-		ah->regulatory.max_power_level = ratesArray[i];
+		regulatory->max_power_level = ratesArray[i];
 
 	switch(ar5416_get_ntxchains(ah->txchainmask)) {
 	case 1:
 		break;
 	case 2:
-		ah->regulatory.max_power_level += INCREASE_MAXPOW_BY_TWO_CHAIN;
+		regulatory->max_power_level += INCREASE_MAXPOW_BY_TWO_CHAIN;
 		break;
 	case 3:
-		ah->regulatory.max_power_level += INCREASE_MAXPOW_BY_THREE_CHAIN;
+		regulatory->max_power_level += INCREASE_MAXPOW_BY_THREE_CHAIN;
 		break;
 	default:
 		DPRINTF(ah->ah_sc, ATH_DBG_EEPROM,
diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c
index df62113..4f3d5ea 100644
--- a/drivers/net/wireless/ath/ath9k/hw.c
+++ b/drivers/net/wireless/ath/ath9k/hw.c
@@ -439,8 +439,13 @@ static void ath9k_hw_init_config(struct ath_hw *ah)
 
 static void ath9k_hw_init_defaults(struct ath_hw *ah)
 {
+	struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
+
+	regulatory->country_code = CTRY_DEFAULT;
+	regulatory->power_limit = MAX_RATE_POWER;
+	regulatory->tp_scale = ATH9K_TP_SCALE_MAX;
+
 	ah->hw_version.magic = AR5416_MAGIC;
-	ah->regulatory.country_code = CTRY_DEFAULT;
 	ah->hw_version.subvendorid = 0;
 
 	ah->ah_flags = 0;
@@ -449,8 +454,6 @@ static void ath9k_hw_init_defaults(struct ath_hw *ah)
 	if (!AR_SREV_9100(ah))
 		ah->ah_flags = AH_USE_EEPROM;
 
-	ah->regulatory.power_limit = MAX_RATE_POWER;
-	ah->regulatory.tp_scale = ATH9K_TP_SCALE_MAX;
 	ah->atim_window = 0;
 	ah->sta_id1_defaults = AR_STA_ID1_CRPT_MIC_ENABLE;
 	ah->beacon_interval = 100;
@@ -1368,6 +1371,7 @@ static int ath9k_hw_process_ini(struct ath_hw *ah,
 				struct ath9k_channel *chan,
 				enum ath9k_ht_macmode macmode)
 {
+	struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
 	int i, regWrites = 0;
 	struct ieee80211_channel *channel = chan->chan;
 	u32 modesIndex, freqIndex;
@@ -1474,11 +1478,11 @@ static int ath9k_hw_process_ini(struct ath_hw *ah,
 		ath9k_olc_init(ah);
 
 	ah->eep_ops->set_txpower(ah, chan,
-				 ath9k_regd_get_ctl(&ah->regulatory, chan),
+				 ath9k_regd_get_ctl(regulatory, chan),
 				 channel->max_antenna_gain * 2,
 				 channel->max_power * 2,
 				 min((u32) MAX_RATE_POWER,
-				 (u32) ah->regulatory.power_limit));
+				 (u32) regulatory->power_limit));
 
 	if (!ath9k_hw_set_rf_regs(ah, chan, freqIndex)) {
 		DPRINTF(ah->ah_sc, ATH_DBG_FATAL,
@@ -1796,6 +1800,7 @@ static bool ath9k_hw_channel_change(struct ath_hw *ah,
 				    struct ath9k_channel *chan,
 				    enum ath9k_ht_macmode macmode)
 {
+	struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
 	struct ieee80211_channel *channel = chan->chan;
 	u32 synthDelay, qnum;
 
@@ -1828,11 +1833,11 @@ static bool ath9k_hw_channel_change(struct ath_hw *ah,
 	}
 
 	ah->eep_ops->set_txpower(ah, chan,
-			     ath9k_regd_get_ctl(&ah->regulatory, chan),
+			     ath9k_regd_get_ctl(regulatory, chan),
 			     channel->max_antenna_gain * 2,
 			     channel->max_power * 2,
 			     min((u32) MAX_RATE_POWER,
-			     (u32) ah->regulatory.power_limit));
+			     (u32) regulatory->power_limit));
 
 	synthDelay = REG_READ(ah, AR_PHY_RX_DELAY) & AR_PHY_RX_DELAY_DELAY;
 	if (IS_CHAN_B(chan))
@@ -3480,27 +3485,29 @@ void ath9k_hw_set_sta_beacon_timers(struct ath_hw *ah,
 void ath9k_hw_fill_cap_info(struct ath_hw *ah)
 {
 	struct ath9k_hw_capabilities *pCap = &ah->caps;
+	struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
+
 	u16 capField = 0, eeval;
 
 	eeval = ah->eep_ops->get_eeprom(ah, EEP_REG_0);
-	ah->regulatory.current_rd = eeval;
+	regulatory->current_rd = eeval;
 
 	eeval = ah->eep_ops->get_eeprom(ah, EEP_REG_1);
 	if (AR_SREV_9285_10_OR_LATER(ah))
 		eeval |= AR9285_RDEXT_DEFAULT;
-	ah->regulatory.current_rd_ext = eeval;
+	regulatory->current_rd_ext = eeval;
 
 	capField = ah->eep_ops->get_eeprom(ah, EEP_OP_CAP);
 
 	if (ah->opmode != NL80211_IFTYPE_AP &&
 	    ah->hw_version.subvendorid == AR_SUBVENDOR_ID_NEW_A) {
-		if (ah->regulatory.current_rd == 0x64 ||
-		    ah->regulatory.current_rd == 0x65)
-			ah->regulatory.current_rd += 5;
-		else if (ah->regulatory.current_rd == 0x41)
-			ah->regulatory.current_rd = 0x43;
+		if (regulatory->current_rd == 0x64 ||
+		    regulatory->current_rd == 0x65)
+			regulatory->current_rd += 5;
+		else if (regulatory->current_rd == 0x41)
+			regulatory->current_rd = 0x43;
 		DPRINTF(ah->ah_sc, ATH_DBG_REGULATORY,
-			"regdomain mapped to 0x%x\n", ah->regulatory.current_rd);
+			"regdomain mapped to 0x%x\n", regulatory->current_rd);
 	}
 
 	eeval = ah->eep_ops->get_eeprom(ah, EEP_OP_MODE);
@@ -3635,7 +3642,7 @@ void ath9k_hw_fill_cap_info(struct ath_hw *ah)
 	else
 		pCap->hw_caps |= ATH9K_HW_CAP_4KB_SPLITTRANS;
 
-	if (ah->regulatory.current_rd_ext & (1 << REG_EXT_JAPAN_MIDBAND)) {
+	if (regulatory->current_rd_ext & (1 << REG_EXT_JAPAN_MIDBAND)) {
 		pCap->reg_cap =
 			AR_EEPROM_EEREGCAP_EN_KK_NEW_11A |
 			AR_EEPROM_EEREGCAP_EN_KK_U1_EVEN |
@@ -3664,6 +3671,7 @@ void ath9k_hw_fill_cap_info(struct ath_hw *ah)
 bool ath9k_hw_getcapability(struct ath_hw *ah, enum ath9k_capability_type type,
 			    u32 capability, u32 *result)
 {
+	struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
 	switch (type) {
 	case ATH9K_CAP_CIPHER:
 		switch (capability) {
@@ -3712,13 +3720,13 @@ bool ath9k_hw_getcapability(struct ath_hw *ah, enum ath9k_capability_type type,
 		case 0:
 			return 0;
 		case 1:
-			*result = ah->regulatory.power_limit;
+			*result = regulatory->power_limit;
 			return 0;
 		case 2:
-			*result = ah->regulatory.max_power_level;
+			*result = regulatory->max_power_level;
 			return 0;
 		case 3:
-			*result = ah->regulatory.tp_scale;
+			*result = regulatory->tp_scale;
 			return 0;
 		}
 		return false;
@@ -3956,17 +3964,18 @@ bool ath9k_hw_disable(struct ath_hw *ah)
 
 void ath9k_hw_set_txpowerlimit(struct ath_hw *ah, u32 limit)
 {
+	struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
 	struct ath9k_channel *chan = ah->curchan;
 	struct ieee80211_channel *channel = chan->chan;
 
-	ah->regulatory.power_limit = min(limit, (u32) MAX_RATE_POWER);
+	regulatory->power_limit = min(limit, (u32) MAX_RATE_POWER);
 
 	ah->eep_ops->set_txpower(ah, chan,
-				 ath9k_regd_get_ctl(&ah->regulatory, chan),
+				 ath9k_regd_get_ctl(regulatory, chan),
 				 channel->max_antenna_gain * 2,
 				 channel->max_power * 2,
 				 min((u32) MAX_RATE_POWER,
-				 (u32) ah->regulatory.power_limit));
+				 (u32) regulatory->power_limit));
 }
 
 void ath9k_hw_setmac(struct ath_hw *ah, const u8 *mac)
diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
index de31a15..24b3063 100644
--- a/drivers/net/wireless/ath/ath9k/hw.h
+++ b/drivers/net/wireless/ath/ath9k/hw.h
@@ -396,7 +396,6 @@ struct ath_hw {
 	struct ath9k_hw_version hw_version;
 	struct ath9k_ops_config config;
 	struct ath9k_hw_capabilities caps;
-	struct ath_regulatory regulatory;
 	struct ath9k_channel channels[38];
 	struct ath9k_channel *curchan;
 
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
index 2f9c149..55fbce2 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -1293,7 +1293,7 @@ static int ath9k_reg_notifier(struct wiphy *wiphy,
 	struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
 	struct ath_wiphy *aphy = hw->priv;
 	struct ath_softc *sc = aphy->sc;
-	struct ath_regulatory *reg = &sc->sc_ah->regulatory;
+	struct ath_regulatory *reg = &sc->common.regulatory;
 
 	return ath_reg_notifier_apply(wiphy, request, reg);
 }
@@ -1586,12 +1586,12 @@ int ath_init_device(u16 devid, struct ath_softc *sc)
 
 	ath_set_hw_capab(sc, hw);
 
-	error = ath_regd_init(&sc->sc_ah->regulatory, sc->hw->wiphy,
+	error = ath_regd_init(&sc->common.regulatory, sc->hw->wiphy,
 			      ath9k_reg_notifier);
 	if (error)
 		return error;
 
-	reg = &sc->sc_ah->regulatory;
+	reg = &sc->common.regulatory;
 
 	if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_HT) {
 		setup_ht_cap(sc, &sc->sbands[IEEE80211_BAND_2GHZ].ht_cap);
diff --git a/drivers/net/wireless/ath/regd.h b/drivers/net/wireless/ath/regd.h
index 07291cc..4d3c536 100644
--- a/drivers/net/wireless/ath/regd.h
+++ b/drivers/net/wireless/ath/regd.h
@@ -18,9 +18,10 @@
 #define REGD_H
 
 #include <linux/nl80211.h>
-
 #include <net/cfg80211.h>
 
+#include "ath.h"
+
 #define NO_CTL 0xff
 #define SD_NO_CTL               0xE0
 #define NO_CTL                  0xff
@@ -47,29 +48,12 @@
 #define CHANNEL_HALF_BW         10
 #define CHANNEL_QUARTER_BW      5
 
-struct reg_dmn_pair_mapping {
-	u16 regDmnEnum;
-	u16 reg_5ghz_ctl;
-	u16 reg_2ghz_ctl;
-};
-
 struct country_code_to_enum_rd {
 	u16 countryCode;
 	u16 regDmnEnum;
 	const char *isoName;
 };
 
-struct ath_regulatory {
-	char alpha2[2];
-	u16 country_code;
-	u16 max_power_level;
-	u32 tp_scale;
-	u16 current_rd;
-	u16 current_rd_ext;
-	int16_t power_limit;
-	struct reg_dmn_pair_mapping *regpair;
-};
-
 enum CountryCode {
 	CTRY_ALBANIA = 8,
 	CTRY_ALGERIA = 12,
-- 
1.6.3.3


^ permalink raw reply related

* Re: [RFT] ath: move regulatory info into shared common structure
From: Luis R. Rodriguez @ 2009-08-18  1:06 UTC (permalink / raw)
  To: linux-wireless; +Cc: Luis R. Rodriguez
In-Reply-To: <1250554510-5793-1-git-send-email-lrodriguez@atheros.com>

On Mon, Aug 17, 2009 at 5:15 PM, Luis R.
Rodriguez<lrodriguez@atheros.com> wrote:

> I may not have time to test all the hardware so it would be nice if
> others can give this a spin.

I managed to test ath5k, ath9k and ar9170 and all seem happy except
for the warnings I posted on linux-wireless which are unrelated.

  Luis

^ permalink raw reply

* Few warnings from master-2009-08-17
From: Luis R. Rodriguez @ 2009-08-18  1:04 UTC (permalink / raw)
  To: linux-wireless

This happens with ar9170 and ath9k:

First the driver/firmware/connect info:

Aug 17 17:45:06 tux kernel: [  380.596120] usb 1-3: firmware:
requesting ar9170.fw
Aug 17 17:45:06 tux kernel: [  381.024647] cfg80211: Calling CRDA for
country: US
Aug 17 17:45:06 tux kernel: [  381.026543] Registered led device:
ar9170-phy0::tx
Aug 17 17:45:06 tux kernel: [  381.027168] Registered led device:
ar9170-phy0::assoc
Aug 17 17:45:06 tux kernel: [  381.027177] usb 1-3: Atheros AR9170 is
registered as 'phy0'
Aug 17 17:45:06 tux kernel: [  381.027531] usbcore: registered new
interface driver ar9170usb
Aug 17 17:45:06 tux kernel: [  381.034544] cfg80211: Regulatory domain
changed to country: US
Aug 17 17:45:06 tux kernel: [  381.034550]      (start_freq - end_freq
@ bandwidth), (max_antenna_gain, max_eirp)
Aug 17 17:45:06 tux kernel: [  381.034554]      (2402000 KHz - 2472000
KHz @ 40000 KHz), (300 mBi, 2700 mBm)
Aug 17 17:45:06 tux kernel: [  381.034557]      (5170000 KHz - 5250000
KHz @ 40000 KHz), (300 mBi, 1700 mBm)
Aug 17 17:45:06 tux kernel: [  381.034561]      (5250000 KHz - 5330000
KHz @ 40000 KHz), (300 mBi, 2000 mBm)
Aug 17 17:45:06 tux kernel: [  381.034564]      (5490000 KHz - 5710000
KHz @ 40000 KHz), (300 mBi, 2000 mBm)
Aug 17 17:45:06 tux kernel: [  381.034568]      (5735000 KHz - 5835000
KHz @ 40000 KHz), (300 mBi, 3000 mBm)
Aug 17 17:45:13 tux kernel: [  381.165048] udev: renamed network
interface wlan0 to wlan4
Aug 17 17:45:13 tux kernel: [  386.880442] ADDRCONF(NETDEV_UP): wlan4:
link is not ready
Aug 17 17:45:46 tux kernel: [  420.943787] ADDRCONF(NETDEV_CHANGE):
wlan4: link becomes ready
Aug 17 17:45:46 tux kernel: [  420.944740] cfg80211: Calling CRDA for
country: US
Aug 17 17:45:46 tux kernel: [  420.955876] cfg80211: Regulatory domain: US
Aug 17 17:45:46 tux kernel: [  420.955881]      (start_freq - end_freq
@ bandwidth), (max_antenna_gain, max_eirp)
Aug 17 17:45:46 tux kernel: [  420.955889]      (2402000 KHz - 2477000
KHz @ 40000 KHz), (10000 mBi, 10000 mBm)
Aug 17 17:45:46 tux kernel: [  420.955901] cfg80211: Regulatory domain: US
Aug 17 17:45:46 tux kernel: [  420.955905]      (start_freq - end_freq
@ bandwidth), (max_antenna_gain, max_eirp)
Aug 17 17:45:46 tux kernel: [  420.955913]      (2402000 KHz - 2472000
KHz @ 40000 KHz), (300 mBi, 2700 mBm)
Aug 17 17:45:46 tux kernel: [  420.955921]      (5170000 KHz - 5250000
KHz @ 40000 KHz), (300 mBi, 1700 mBm)
Aug 17 17:45:46 tux kernel: [  420.955928]      (5250000 KHz - 5330000
KHz @ 40000 KHz), (300 mBi, 2000 mBm)
Aug 17 17:45:46 tux kernel: [  420.955936]      (5490000 KHz - 5710000
KHz @ 40000 KHz), (300 mBi, 2000 mBm)
Aug 17 17:45:46 tux kernel: [  420.955943]      (5735000 KHz - 5835000
KHz @ 40000 KHz), (300 mBi, 3000 mBm)
Aug 17 17:45:46 tux kernel: [  420.955954] cfg80211: Regulatory domain: 98
Aug 17 17:45:46 tux kernel: [  420.955959]      (start_freq - end_freq
@ bandwidth), (max_antenna_gain, max_eirp)
Aug 17 17:45:46 tux kernel: [  420.955966]      (2402000 KHz - 2472000
KHz @ 40000 KHz), (300 mBi, 2700 mBm)
Aug 17 17:45:46 tux kernel: [  420.956346] cfg80211: Current
regulatory domain updated by AP to: US
Aug 17 17:45:46 tux kernel: [  420.956351]      (start_freq - end_freq
@ bandwidth), (max_antenna_gain, max_eirp)
Aug 17 17:45:50 tux kernel: [  420.956359]      (2402000 KHz - 2472000
KHz @ 40000 KHz), (300 mBi, 2700 mBm)


First warning:

Aug 17 17:45:50 tux kernel: [  424.812910] ------------[ cut here ]------------
Aug 17 17:45:50 tux kernel: [  424.812928] WARNING: at
net/wireless/sme.c:610 __cfg80211_disconnected+0x1fb/0x260
[cfg80211]()
Aug 17 17:45:50 tux kernel: [  424.812931] Hardware name: 7660A14
Aug 17 17:45:50 tux kernel: [  424.812933] deauth failed: -67
Aug 17 17:45:50 tux kernel: [  424.812935] Modules linked in:
ar9170usb mac80211 ath cfg80211 <bleh> [last unloaded: cfg80211]
Aug 17 17:45:50 tux kernel: [  424.813002] Pid: 5018, comm: phy0 Not
tainted 2.6.31-rc6-wl #139
Aug 17 17:45:50 tux kernel: [  424.813005] Call Trace:
Aug 17 17:45:50 tux kernel: [  424.813016]  [<ffffffff810585a8>]
warn_slowpath_common+0x78/0xb0
Aug 17 17:45:50 tux kernel: [  424.813020]  [<ffffffff8105863c>]
warn_slowpath_fmt+0x3c/0x40
Aug 17 17:45:50 tux kernel: [  424.813032]  [<ffffffffa00c782b>]
__cfg80211_disconnected+0x1fb/0x260 [cfg80211]
Aug 17 17:45:50 tux kernel: [  424.813043]  [<ffffffffa00c59f2>] ?
cfg80211_send_deauth+0x62/0x80 [cfg80211]
Aug 17 17:45:50 tux kernel: [  424.813054]  [<ffffffffa00c5918>]
__cfg80211_send_deauth+0x228/0x2a0 [cfg80211]
Aug 17 17:45:50 tux kernel: [  424.813064]  [<ffffffffa00c5a01>]
cfg80211_send_deauth+0x71/0x80 [cfg80211]
Aug 17 17:45:50 tux kernel: [  424.813084]  [<ffffffffa021cbc0>]
ieee80211_sta_work+0x380/0x1100 [mac80211]
Aug 17 17:45:50 tux kernel: [  424.813098]  [<ffffffffa021c840>] ?
ieee80211_sta_work+0x0/0x1100 [mac80211]
Aug 17 17:45:50 tux kernel: [  424.813103]  [<ffffffff8106de80>]
worker_thread+0x1d0/0x380
Aug 17 17:45:50 tux kernel: [  424.813107]  [<ffffffff8106de2e>] ?
worker_thread+0x17e/0x380
Aug 17 17:45:50 tux kernel: [  424.813113]  [<ffffffff81073630>] ?
autoremove_wake_function+0x0/0x40
Aug 17 17:45:50 tux kernel: [  424.813117]  [<ffffffff8106dcb0>] ?
worker_thread+0x0/0x380
Aug 17 17:45:50 tux kernel: [  424.813121]  [<ffffffff81073266>]
kthread+0xa6/0xb0
Aug 17 17:45:50 tux kernel: [  424.813126]  [<ffffffff810130ca>]
child_rip+0xa/0x20
Aug 17 17:45:50 tux kernel: [  424.813132]  [<ffffffff81012a50>] ?
restore_args+0x0/0x30
Aug 17 17:45:50 tux kernel: [  424.813136]  [<ffffffff810731c0>] ?
kthread+0x0/0xb0
Aug 17 17:45:50 tux kernel: [  424.813140]  [<ffffffff810130c0>] ?
child_rip+0x0/0x20
Aug 17 17:45:54 tux kernel: [  424.813143] ---[ end trace 7ef91a8a6ee731a1 ]---
Aug 17 17:45:57 tux kernel: [  432.637525] ------------[ cut here ]------------

And it seems right after:

Aug 17 17:45:57 tux kernel: [  432.637557] WARNING: at
net/wireless/sme.c:610 __cfg80211_disconnected+0x1fb/0x260
[cfg80211]()
Aug 17 17:45:57 tux kernel: [  432.637564] Hardware name: 7660A14
Aug 17 17:45:57 tux kernel: [  432.637569] deauth failed: -67
Aug 17 17:45:57 tux kernel: [  432.637573] Modules linked in:
ar9170usb mac80211 ath cfg80211 <bleh> [last unloaded: cfg80211]
Aug 17 17:45:57 tux kernel: [  432.637726] Pid: 5018, comm: phy0
Tainted: G        W  2.6.31-rc6-wl #139
Aug 17 17:45:57 tux kernel: [  432.637732] Call Trace:
Aug 17 17:45:57 tux kernel: [  432.637749]  [<ffffffff810585a8>]
warn_slowpath_common+0x78/0xb0
Aug 17 17:45:57 tux kernel: [  432.637759]  [<ffffffff8105863c>]
warn_slowpath_fmt+0x3c/0x40
Aug 17 17:45:57 tux kernel: [  432.637784]  [<ffffffffa00c782b>]
__cfg80211_disconnected+0x1fb/0x260 [cfg80211]
Aug 17 17:45:57 tux kernel: [  432.637809]  [<ffffffffa00c59f2>] ?
cfg80211_send_deauth+0x62/0x80 [cfg80211]
Aug 17 17:45:57 tux kernel: [  432.637832]  [<ffffffffa00c5918>]
__cfg80211_send_deauth+0x228/0x2a0 [cfg80211]
Aug 17 17:45:57 tux kernel: [  432.637856]  [<ffffffffa00c5a01>]
cfg80211_send_deauth+0x71/0x80 [cfg80211]
Aug 17 17:45:57 tux kernel: [  432.637892]  [<ffffffffa021cbc0>]
ieee80211_sta_work+0x380/0x1100 [mac80211]
Aug 17 17:45:57 tux kernel: [  432.637923]  [<ffffffffa021c840>] ?
ieee80211_sta_work+0x0/0x1100 [mac80211]
Aug 17 17:45:57 tux kernel: [  432.637934]  [<ffffffff8106de80>]
worker_thread+0x1d0/0x380
Aug 17 17:45:57 tux kernel: [  432.637943]  [<ffffffff8106de2e>] ?
worker_thread+0x17e/0x380
Aug 17 17:45:57 tux kernel: [  432.637954]  [<ffffffff81073630>] ?
autoremove_wake_function+0x0/0x40
Aug 17 17:45:57 tux kernel: [  432.637964]  [<ffffffff8106dcb0>] ?
worker_thread+0x0/0x380
Aug 17 17:45:57 tux kernel: [  432.637973]  [<ffffffff81073266>]
kthread+0xa6/0xb0
Aug 17 17:45:57 tux kernel: [  432.637983]  [<ffffffff810130ca>]
child_rip+0xa/0x20
Aug 17 17:45:57 tux kernel: [  432.637995]  [<ffffffff81012a50>] ?
restore_args+0x0/0x30
Aug 17 17:46:06 tux kernel: [  432.638004]  [<ffffffff810731c0>] ?
kthread+0x0/0xb0
Aug 17 17:46:06 tux kernel: [  432.638013]  [<ffffffff810130c0>] ?
child_rip+0x0/0x20
Aug 17 17:46:06 tux kernel: [  432.638019] ---[ end trace 7ef91a8a6ee731a2 ]---


It seems I can get the second warning triggered when I disconnect due
to no probe response from AP:


[ 1060.261105] No probe response from AP <AP-MAC-ADDRESS>after 500ms,
disconnecting.
[ 1060.264257] phy1: device now idle
[ 1060.268293] phy1: Removed STA <AP-MAC-ADDRESS>
[ 1060.290788] phy1: Destroyed STA <AP-MAC-ADDRESS>
[ 1060.290961] wlan6: deauthenticating by local choice (reason=3)
[ 1060.291025] ------------[ cut here ]------------
[ 1060.291057] WARNING: at net/wireless/sme.c:610
__cfg80211_disconnected+0x1fb/0x260 [cfg80211]()
[ 1060.291064] Hardware name: 7660A14
[ 1060.291069] deauth failed: -67
[ 1060.291073] Modules linked in: ar9170usb mac80211 ath cfg80211
<bleh> [last unloaded: ar9170usb]
[ 1060.291230] Pid: 5525, comm: phy1 Tainted: G        W  2.6.31-rc6-wl #139
[ 1060.291237] Call Trace:
[ 1060.291252]  [<ffffffff810585a8>] warn_slowpath_common+0x78/0xb0
[ 1060.291262]  [<ffffffff8105863c>] warn_slowpath_fmt+0x3c/0x40
[ 1060.291287]  [<ffffffffa018682b>]
__cfg80211_disconnected+0x1fb/0x260 [cfg80211]
[ 1060.291312]  [<ffffffffa01849f2>] ? cfg80211_send_deauth+0x62/0x80 [cfg80211]
[ 1060.291336]  [<ffffffffa0184918>]
__cfg80211_send_deauth+0x228/0x2a0 [cfg80211]
[ 1060.291359]  [<ffffffffa0184a01>] cfg80211_send_deauth+0x71/0x80 [cfg80211]
[ 1060.291394]  [<ffffffffa03d9c1f>]
ieee80211_send_deauth_disassoc+0x14f/0x170 [mac80211]
[ 1060.291425]  [<ffffffffa03dd52b>] ieee80211_sta_work+0xceb/0x1100 [mac80211]
[ 1060.291456]  [<ffffffffa03dc840>] ? ieee80211_sta_work+0x0/0x1100 [mac80211]
[ 1060.291466]  [<ffffffff8106de80>] worker_thread+0x1d0/0x380
[ 1060.291475]  [<ffffffff8106de2e>] ? worker_thread+0x17e/0x380
[ 1060.291487]  [<ffffffff8152977b>] ? _spin_unlock_irqrestore+0x3b/0x70
[ 1060.291499]  [<ffffffff81073630>] ? autoremove_wake_function+0x0/0x40
[ 1060.291509]  [<ffffffff8106dcb0>] ? worker_thread+0x0/0x380
[ 1060.291518]  [<ffffffff81073266>] kthread+0xa6/0xb0
[ 1060.291529]  [<ffffffff810130ca>] child_rip+0xa/0x20
[ 1060.291540]  [<ffffffff81012a50>] ? restore_args+0x0/0x30
[ 1060.291549]  [<ffffffff810731c0>] ? kthread+0x0/0xb0
[ 1060.291557]  [<ffffffff810130c0>] ? child_rip+0x0/0
[ 1060.291564] ---[ end trace 7ef91a8a6ee731a3 ]---
[ 1060.428931] phy1: device no longer idle - scanning
[ 1068.424002] phy1: device now idle
[ 1073.259516] phy1: device no longer idle - scanning
[ 1081.234199] phy1: device now idle
[ 1086.357427] phy1: device no longer idle - scanning
[ 1094.366167] phy1: device now idle
[ 1099.247884] phy1: device no longer idle - scanning

Then I got this one with ath9k:

[ 1354.441346] wlan3: deauthenticating by local choice (reason=3)
[ 1354.442954] phy0: Removed STA <AP-MAC-ADDRESS>
[ 1354.454405] phy0: Destroyed STA <AP-MAC-ADDRESS>
[ 1354.489555] phy0: device now idle
[ 1354.569311] ------------[ cut here ]------------
[ 1354.569323] WARNING: at kernel/mutex.c:207 __mutex_lock_common+0x39b/0x3d0()
[ 1354.569326] Hardware name: 7660A14
[ 1354.569329] Modules linked in: ath9k(-) mac80211 ath cfg80211
<bleh>  [last unloaded: cfg80211]
[ 1354.569402] Pid: 10, comm: events/1 Tainted: G        W  2.6.31-rc6-wl #139
[ 1354.569406] Call Trace:
[ 1354.569412]  [<ffffffff810585a8>] warn_slowpath_common+0x78/0xb0
[ 1354.569416]  [<ffffffff810585ef>] warn_slowpath_null+0xf/0x20
[ 1354.569421]  [<ffffffff81527f7b>] __mutex_lock_common+0x39b/0x3d0
[ 1354.569435]  [<ffffffffa00c752a>] ?
cfg80211_sme_scan_done+0x4a/0x150 [cfg80211]
[ 1354.569445]  [<ffffffffa00c752a>] ?
cfg80211_sme_scan_done+0x4a/0x150 [cfg80211]
[ 1354.569450]  [<ffffffff81528091>] mutex_lock_nested+0x41/0x50
[ 1354.569459]  [<ffffffffa00c752a>] cfg80211_sme_scan_done+0x4a/0x150
[cfg80211]
[ 1354.569469]  [<ffffffffa00b9b9a>] ___cfg80211_scan_done+0x3a/0xd0 [cfg80211]
[ 1354.569479]  [<ffffffffa00b9c30>] ? __cfg80211_scan_done+0x0/0x50 [cfg80211]
[ 1354.569488]  [<ffffffffa00b9c30>] ? __cfg80211_scan_done+0x0/0x50 [cfg80211]
[ 1354.569497]  [<ffffffffa00b9c54>] __cfg80211_scan_done+0x24/0x50 [cfg80211]
[ 1354.569502]  [<ffffffff8106de80>] worker_thread+0x1d0/0x380
[ 1354.569506]  [<ffffffff8106de2e>] ? worker_thread+0x17e/0x380
[ 1354.569510]  [<ffffffff81073630>] ? autoremove_wake_function+0x0/0x40
[ 1354.569514]  [<ffffffff8106dcb0>] ? worker_thread+0x0/0x380
[ 1354.569518]  [<ffffffff81073266>] kthread+0xa6/0xb0
[ 1354.569523]  [<ffffffff810130ca>] child_rip+0xa/0x20
[ 1354.569528]  [<ffffffff81012a50>] ? restore_args+0x0/0x30
[ 1354.569532]  [<ffffffff810731c0>] ? kthread+0x0/0xb0
[ 1354.569535]  [<ffffffff810130c0>] ? child_rip+0x0/0x20
[ 1354.569538] ---[ end trace 7ef91a8a6ee731a4 ]---
[ 1354.816457] ath9k 0000:16:00.0: PCI INT A disabled
[ 1354.816833] ath9k: Driver unloaded

  Luis

^ permalink raw reply

* Re: [PATCH v4 32/34] wireless: make mac80211 select cfg80211
From: Luis R. Rodriguez @ 2009-08-18  0:35 UTC (permalink / raw)
  To: Johannes Berg
  Cc: Luis Rodriguez, linville@tuxdriver.com,
	linux-wireless@vger.kernel.org, Larry.Finger@lwfinger.net
In-Reply-To: <1250545069.25876.0.camel@johannes.local>

On Mon, Aug 17, 2009 at 02:37:49PM -0700, Johannes Berg wrote:
> On Mon, 2009-08-17 at 10:00 -0700, Luis R. Rodriguez wrote:
> > On Fri, Aug 14, 2009 at 2:06 PM, Johannes Berg<johannes@sipsolutions.net> wrote:
> > > On Fri, 2009-08-14 at 16:25 -0400, Luis R. Rodriguez wrote:
> > >> We can now remove that comment about mac80211 requiring
> > >> cfg80211 and do that for the user.
> > >
> > > "now"? What changed to make this possible?
> > >
> > > NAK this change, because with it, it's possible to select
> > > mac80211 = Y
> > > -> cfg80211 = Y
> > > while rfkill = M
> > >
> > > which will break the kernel build.
> > 
> > I'm able to do this with current kconfig, does this need to be fixed?
> 
> I don't think you can select this with the current config since cfg80211
> depends on RFKILL == CFG80211 || RFKILL == n.
> 
> So you can do
> CFG80211 = m
> RFKILL = m
> 
> CFG80211 = *
> RFKILL = n
> 
> CFG80211 = *
> RFKILL = y
> 
> but NOT
> 
> CFG80211 = y
> RFKILL = m


Ah I see, thanks. OK how about this then:

From: Luis R. Rodriguez <lrodriguez@atheros.com>
Subject: [PATCH] wireless: make mac80211 select cfg80211

This lets us keep mac80211 on the menu map even if cfg80211
is not enabled. We now remove that pesky comment about this.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
---
 net/mac80211/Kconfig |    5 +----
 net/rfkill/Kconfig   |    1 +
 net/wireless/Kconfig |    1 -
 3 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/net/mac80211/Kconfig b/net/mac80211/Kconfig
index 8300d19..8fc6ae6 100644
--- a/net/mac80211/Kconfig
+++ b/net/mac80211/Kconfig
@@ -1,6 +1,6 @@
 config MAC80211
 	tristate "mac80211 - SoftMAC device support"
-	depends on CFG80211
+	select CFG80211
 	select CRYPTO
 	select CRYPTO_ECB
 	select CRYPTO_ARC4
@@ -23,9 +23,6 @@ config MAC80211
 	  When built as a module mac80211 will be built as mac80211, if not sure
 	  you should build this as a module.
 
-comment "CFG80211 needs to be enabled for MAC80211"
-	depends on CFG80211=n
-
 if MAC80211 != n
 
 config MAC80211_RC_PID
diff --git a/net/rfkill/Kconfig b/net/rfkill/Kconfig
index eaf7658..65e98b8 100644
--- a/net/rfkill/Kconfig
+++ b/net/rfkill/Kconfig
@@ -3,6 +3,7 @@
 #
 menuconfig RFKILL
 	tristate "RF switch subsystem support"
+	depends on CFG80211 || !CFG80211
 	help
 	  Say Y here if you want to have control over RF switches
 	  found on many WiFi and Bluetooth cards.
diff --git a/net/wireless/Kconfig b/net/wireless/Kconfig
index 982004b..524aeaf 100644
--- a/net/wireless/Kconfig
+++ b/net/wireless/Kconfig
@@ -1,6 +1,5 @@
 config CFG80211
 	tristate "cfg80211 - wireless configuration API"
-	depends on RFKILL || !RFKILL
 	---help---
 	  cfg80211 is the Linux wireless LAN (802.11) configuration API.
 	  Enable this if you have a wireless device.
-- 
1.6.3.3


^ permalink raw reply related

* [PATCH] mac80211: Decouple fail_avg stats used by mesh from rate control algorithm.
From: Javier Cardona @ 2009-08-18  0:15 UTC (permalink / raw)
  To: linux-wireless; +Cc: Javier Cardona, andrey, johannes, linville, devel
In-Reply-To: <1250554180-30646-1-git-send-email-javier@cozybit.com>

Mesh uses the tx failure average to compute the (m)path metric.  This used to
be done inside the rate control module.  This patch breaks the dependency
between the mesh stack and the rate control algorithm.  Mesh will now work
independently of the chosen rate control algorithm.

The mesh stack keeps a moving average of the average transmission losses for
each mesh peer station.  If the fail average exceeds a certain threshold, the
peer link is marked as broken.

Signed-off-by: Javier Cardona <javier@cozybit.com>
---
 net/mac80211/main.c             |    2 ++
 net/mac80211/mesh.h             |    2 ++
 net/mac80211/mesh_hwmp.c        |   18 ++++++++++++++++++
 net/mac80211/rc80211_minstrel.c |   16 +---------------
 net/mac80211/rc80211_pid_algo.c |   15 +--------------
 5 files changed, 24 insertions(+), 29 deletions(-)

diff --git a/net/mac80211/main.c b/net/mac80211/main.c
index 3302df9..f80efd7 100644
--- a/net/mac80211/main.c
+++ b/net/mac80211/main.c
@@ -482,6 +482,8 @@ void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb)
 		}
 
 		rate_control_tx_status(local, sband, sta, skb);
+		if (ieee80211_vif_is_mesh(&sta->sdata->vif))
+			ieee80211s_update_metric(local, sta, skb);
 	}
 
 	rcu_read_unlock();
diff --git a/net/mac80211/mesh.h b/net/mac80211/mesh.h
index eb23fc6..dd1c193 100644
--- a/net/mac80211/mesh.h
+++ b/net/mac80211/mesh.h
@@ -226,6 +226,8 @@ void mesh_mgmt_ies_add(struct sk_buff *skb,
 void mesh_rmc_free(struct ieee80211_sub_if_data *sdata);
 int mesh_rmc_init(struct ieee80211_sub_if_data *sdata);
 void ieee80211s_init(void);
+void ieee80211s_update_metric(struct ieee80211_local *local,
+		struct sta_info *stainfo, struct sk_buff *skb);
 void ieee80211s_stop(void);
 void ieee80211_mesh_init_sdata(struct ieee80211_sub_if_data *sdata);
 ieee80211_rx_result
diff --git a/net/mac80211/mesh_hwmp.c b/net/mac80211/mesh_hwmp.c
index ef1efd3..7aeba00 100644
--- a/net/mac80211/mesh_hwmp.c
+++ b/net/mac80211/mesh_hwmp.c
@@ -201,6 +201,24 @@ int mesh_path_error_tx(u8 *dst, __le32 dst_dsn, u8 *ra,
 	return 0;
 }
 
+void ieee80211s_update_metric(struct ieee80211_local *local,
+		struct sta_info *stainfo, struct sk_buff *skb)
+{
+	struct ieee80211_tx_info *txinfo = IEEE80211_SKB_CB(skb);
+	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
+	int failed;
+
+	if (!ieee80211_is_data(hdr->frame_control))
+		return;
+
+	failed = !(txinfo->flags & IEEE80211_TX_STAT_ACK);
+
+	/* moving average, scaled to 100 */
+	stainfo->fail_avg = ((80 * stainfo->fail_avg + 5) / 100 + 20 * failed);
+	if (stainfo->fail_avg > 95)
+		mesh_plink_broken(stainfo);
+}
+
 static u32 airtime_link_metric_get(struct ieee80211_local *local,
 				   struct sta_info *sta)
 {
diff --git a/net/mac80211/rc80211_minstrel.c b/net/mac80211/rc80211_minstrel.c
index 0071649..7c51429 100644
--- a/net/mac80211/rc80211_minstrel.c
+++ b/net/mac80211/rc80211_minstrel.c
@@ -51,7 +51,6 @@
 #include <linux/random.h>
 #include <linux/ieee80211.h>
 #include <net/mac80211.h>
-#include "mesh.h"
 #include "rate.h"
 #include "rc80211_minstrel.h"
 
@@ -156,16 +155,12 @@ minstrel_tx_status(void *priv, struct ieee80211_supported_band *sband,
 		   struct sk_buff *skb)
 {
 	struct minstrel_sta_info *mi = priv_sta;
-	struct minstrel_priv *mp = (struct minstrel_priv *)priv;
 	struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
 	struct ieee80211_tx_rate *ar = info->status.rates;
-	struct ieee80211_local *local = hw_to_local(mp->hw);
-	struct sta_info *si;
 	int i, ndx;
 	int success;
 
 	success = !!(info->flags & IEEE80211_TX_STAT_ACK);
-	si = sta_info_get(local, sta->addr);
 
 	for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) {
 		if (ar[i].idx < 0)
@@ -177,17 +172,8 @@ minstrel_tx_status(void *priv, struct ieee80211_supported_band *sband,
 
 		mi->r[ndx].attempts += ar[i].count;
 
-		if ((i != IEEE80211_TX_MAX_RATES - 1) && (ar[i + 1].idx < 0)) {
+		if ((i != IEEE80211_TX_MAX_RATES - 1) && (ar[i + 1].idx < 0))
 			mi->r[ndx].success += success;
-			if (si) {
-				si->fail_avg = (18050 - mi->r[ndx].probability)
-					/ 180;
-				WARN_ON(si->fail_avg > 100);
-				if (si->fail_avg == 100 &&
-					ieee80211_vif_is_mesh(&si->sdata->vif))
-					mesh_plink_broken(si);
-			}
-		}
 	}
 
 	if ((info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE) && (i >= 0))
diff --git a/net/mac80211/rc80211_pid_algo.c b/net/mac80211/rc80211_pid_algo.c
index 8c053be..f6e25d7 100644
--- a/net/mac80211/rc80211_pid_algo.c
+++ b/net/mac80211/rc80211_pid_algo.c
@@ -169,19 +169,9 @@ static void rate_control_pid_sample(struct rc_pid_info *pinfo,
 	 * still a good measurement and copy it. */
 	if (unlikely(spinfo->tx_num_xmit == 0))
 		pf = spinfo->last_pf;
-	else {
-		/* XXX: BAD HACK!!! */
-		struct sta_info *si = container_of(sta, struct sta_info, sta);
-
+	else
 		pf = spinfo->tx_num_failed * 100 / spinfo->tx_num_xmit;
 
-		if (ieee80211_vif_is_mesh(&si->sdata->vif) && pf == 100)
-			mesh_plink_broken(si);
-		pf <<= RC_PID_ARITH_SHIFT;
-		si->fail_avg = ((pf + (spinfo->last_pf << 3)) / 9)
-					>> RC_PID_ARITH_SHIFT;
-	}
-
 	spinfo->tx_num_xmit = 0;
 	spinfo->tx_num_failed = 0;
 
@@ -348,9 +338,6 @@ rate_control_pid_rate_init(void *priv, struct ieee80211_supported_band *sband,
 	}
 
 	spinfo->txrate_idx = rate_lowest_index(sband, sta);
-	/* HACK */
-	si = container_of(sta, struct sta_info, sta);
-	si->fail_avg = 0;
 }
 
 static void *rate_control_pid_alloc(struct ieee80211_hw *hw,
-- 
1.5.4.3


^ permalink raw reply related

* [PATCH] mac80211: Decouple fail_avg stats used by mesh from rate control algorithm.
From: Javier Cardona @ 2009-08-18  0:09 UTC (permalink / raw)
  To: linux-wireless; +Cc: Javier Cardona, andrey, johannes, linville, devel

Mesh uses the tx failure average to compute the (m)path metric.  This used to
be done inside the rate control module.  This patch breaks the dependency
between the mesh stack and the rate control algorithm.  Mesh will now work
independently of the chosen rate control algorithm.

The mesh stack keeps a moving average of the average transmission losses for
each mesh peer station.  If the fail average exceeds a certain threshold, the
peer link is marked as broken.
---
 net/mac80211/main.c             |    2 ++
 net/mac80211/mesh.h             |    2 ++
 net/mac80211/mesh_hwmp.c        |   18 ++++++++++++++++++
 net/mac80211/rc80211_minstrel.c |   16 +---------------
 net/mac80211/rc80211_pid_algo.c |   15 +--------------
 5 files changed, 24 insertions(+), 29 deletions(-)

diff --git a/net/mac80211/main.c b/net/mac80211/main.c
index 3302df9..f80efd7 100644
--- a/net/mac80211/main.c
+++ b/net/mac80211/main.c
@@ -482,6 +482,8 @@ void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb)
 		}
 
 		rate_control_tx_status(local, sband, sta, skb);
+		if (ieee80211_vif_is_mesh(&sta->sdata->vif))
+			ieee80211s_update_metric(local, sta, skb);
 	}
 
 	rcu_read_unlock();
diff --git a/net/mac80211/mesh.h b/net/mac80211/mesh.h
index eb23fc6..dd1c193 100644
--- a/net/mac80211/mesh.h
+++ b/net/mac80211/mesh.h
@@ -226,6 +226,8 @@ void mesh_mgmt_ies_add(struct sk_buff *skb,
 void mesh_rmc_free(struct ieee80211_sub_if_data *sdata);
 int mesh_rmc_init(struct ieee80211_sub_if_data *sdata);
 void ieee80211s_init(void);
+void ieee80211s_update_metric(struct ieee80211_local *local,
+		struct sta_info *stainfo, struct sk_buff *skb);
 void ieee80211s_stop(void);
 void ieee80211_mesh_init_sdata(struct ieee80211_sub_if_data *sdata);
 ieee80211_rx_result
diff --git a/net/mac80211/mesh_hwmp.c b/net/mac80211/mesh_hwmp.c
index ef1efd3..7aeba00 100644
--- a/net/mac80211/mesh_hwmp.c
+++ b/net/mac80211/mesh_hwmp.c
@@ -201,6 +201,24 @@ int mesh_path_error_tx(u8 *dst, __le32 dst_dsn, u8 *ra,
 	return 0;
 }
 
+void ieee80211s_update_metric(struct ieee80211_local *local,
+		struct sta_info *stainfo, struct sk_buff *skb)
+{
+	struct ieee80211_tx_info *txinfo = IEEE80211_SKB_CB(skb);
+	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
+	int failed;
+
+	if (!ieee80211_is_data(hdr->frame_control))
+		return;
+
+	failed = !(txinfo->flags & IEEE80211_TX_STAT_ACK);
+
+	/* moving average, scaled to 100 */
+	stainfo->fail_avg = ((80 * stainfo->fail_avg + 5) / 100 + 20 * failed);
+	if (stainfo->fail_avg > 95)
+		mesh_plink_broken(stainfo);
+}
+
 static u32 airtime_link_metric_get(struct ieee80211_local *local,
 				   struct sta_info *sta)
 {
diff --git a/net/mac80211/rc80211_minstrel.c b/net/mac80211/rc80211_minstrel.c
index 0071649..7c51429 100644
--- a/net/mac80211/rc80211_minstrel.c
+++ b/net/mac80211/rc80211_minstrel.c
@@ -51,7 +51,6 @@
 #include <linux/random.h>
 #include <linux/ieee80211.h>
 #include <net/mac80211.h>
-#include "mesh.h"
 #include "rate.h"
 #include "rc80211_minstrel.h"
 
@@ -156,16 +155,12 @@ minstrel_tx_status(void *priv, struct ieee80211_supported_band *sband,
 		   struct sk_buff *skb)
 {
 	struct minstrel_sta_info *mi = priv_sta;
-	struct minstrel_priv *mp = (struct minstrel_priv *)priv;
 	struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
 	struct ieee80211_tx_rate *ar = info->status.rates;
-	struct ieee80211_local *local = hw_to_local(mp->hw);
-	struct sta_info *si;
 	int i, ndx;
 	int success;
 
 	success = !!(info->flags & IEEE80211_TX_STAT_ACK);
-	si = sta_info_get(local, sta->addr);
 
 	for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) {
 		if (ar[i].idx < 0)
@@ -177,17 +172,8 @@ minstrel_tx_status(void *priv, struct ieee80211_supported_band *sband,
 
 		mi->r[ndx].attempts += ar[i].count;
 
-		if ((i != IEEE80211_TX_MAX_RATES - 1) && (ar[i + 1].idx < 0)) {
+		if ((i != IEEE80211_TX_MAX_RATES - 1) && (ar[i + 1].idx < 0))
 			mi->r[ndx].success += success;
-			if (si) {
-				si->fail_avg = (18050 - mi->r[ndx].probability)
-					/ 180;
-				WARN_ON(si->fail_avg > 100);
-				if (si->fail_avg == 100 &&
-					ieee80211_vif_is_mesh(&si->sdata->vif))
-					mesh_plink_broken(si);
-			}
-		}
 	}
 
 	if ((info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE) && (i >= 0))
diff --git a/net/mac80211/rc80211_pid_algo.c b/net/mac80211/rc80211_pid_algo.c
index 8c053be..f6e25d7 100644
--- a/net/mac80211/rc80211_pid_algo.c
+++ b/net/mac80211/rc80211_pid_algo.c
@@ -169,19 +169,9 @@ static void rate_control_pid_sample(struct rc_pid_info *pinfo,
 	 * still a good measurement and copy it. */
 	if (unlikely(spinfo->tx_num_xmit == 0))
 		pf = spinfo->last_pf;
-	else {
-		/* XXX: BAD HACK!!! */
-		struct sta_info *si = container_of(sta, struct sta_info, sta);
-
+	else
 		pf = spinfo->tx_num_failed * 100 / spinfo->tx_num_xmit;
 
-		if (ieee80211_vif_is_mesh(&si->sdata->vif) && pf == 100)
-			mesh_plink_broken(si);
-		pf <<= RC_PID_ARITH_SHIFT;
-		si->fail_avg = ((pf + (spinfo->last_pf << 3)) / 9)
-					>> RC_PID_ARITH_SHIFT;
-	}
-
 	spinfo->tx_num_xmit = 0;
 	spinfo->tx_num_failed = 0;
 
@@ -348,9 +338,6 @@ rate_control_pid_rate_init(void *priv, struct ieee80211_supported_band *sband,
 	}
 
 	spinfo->txrate_idx = rate_lowest_index(sband, sta);
-	/* HACK */
-	si = container_of(sta, struct sta_info, sta);
-	si->fail_avg = 0;
 }
 
 static void *rate_control_pid_alloc(struct ieee80211_hw *hw,
-- 
1.5.4.3


^ permalink raw reply related

* [RFT] ath: move regulatory info into shared common structure
From: Luis R. Rodriguez @ 2009-08-18  0:15 UTC (permalink / raw)
  To: linux-wireless; +Cc: Luis R. Rodriguez

This moves the shared regulatory structure into the
common structure. We will use this ongoing for common
data.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
---

I may not have time to test all the hardware so it would be nice if
others can give this a spin.

 drivers/net/wireless/ath/ar9170/ar9170.h     |    2 +-
 drivers/net/wireless/ath/ar9170/main.c       |   14 ++++---
 drivers/net/wireless/ath/ath.h               |   18 +++++++++
 drivers/net/wireless/ath/ath5k/ath5k.h       |    3 -
 drivers/net/wireless/ath/ath5k/base.c        |   14 +++---
 drivers/net/wireless/ath/ath5k/base.h        |   13 ++++++
 drivers/net/wireless/ath/ath5k/phy.c         |    3 +-
 drivers/net/wireless/ath/ath9k/ath9k.h       |   10 +++++
 drivers/net/wireless/ath/ath9k/eeprom_4k.c   |    8 ++-
 drivers/net/wireless/ath/ath9k/eeprom_9287.c |   16 ++++----
 drivers/net/wireless/ath/ath9k/eeprom_def.c  |   14 ++++---
 drivers/net/wireless/ath/ath9k/hw.c          |   53 +++++++++++++++-----------
 drivers/net/wireless/ath/ath9k/hw.h          |    1 -
 drivers/net/wireless/ath/ath9k/main.c        |    6 +-
 drivers/net/wireless/ath/regd.h              |   20 +---------
 15 files changed, 116 insertions(+), 79 deletions(-)

diff --git a/drivers/net/wireless/ath/ar9170/ar9170.h b/drivers/net/wireless/ath/ar9170/ar9170.h
index e6c3ee3..95f8256 100644
--- a/drivers/net/wireless/ath/ar9170/ar9170.h
+++ b/drivers/net/wireless/ath/ar9170/ar9170.h
@@ -157,6 +157,7 @@ struct ar9170_sta_tid {
 
 struct ar9170 {
 	struct ieee80211_hw *hw;
+	struct ath_common common;
 	struct mutex mutex;
 	enum ar9170_device_state state;
 	unsigned long bad_hw_nagger;
@@ -222,7 +223,6 @@ struct ar9170 {
 
 	/* EEPROM */
 	struct ar9170_eeprom eeprom;
-	struct ath_regulatory regulatory;
 
 	/* tx queues - as seen by hw - */
 	struct sk_buff_head tx_pending[__AR9170_NUM_TXQ];
diff --git a/drivers/net/wireless/ath/ar9170/main.c b/drivers/net/wireless/ath/ar9170/main.c
index 6a9462e..d30f33d 100644
--- a/drivers/net/wireless/ath/ar9170/main.c
+++ b/drivers/net/wireless/ath/ar9170/main.c
@@ -2641,6 +2641,7 @@ static int ar9170_read_eeprom(struct ar9170 *ar)
 {
 #define RW	8	/* number of words to read at once */
 #define RB	(sizeof(u32) * RW)
+	struct ath_regulatory *regulatory = &ar->common.regulatory;
 	u8 *eeprom = (void *)&ar->eeprom;
 	u8 *addr = ar->eeprom.mac_address;
 	__le32 offsets[RW];
@@ -2707,8 +2708,8 @@ static int ar9170_read_eeprom(struct ar9170 *ar)
 	else
 		ar->hw->channel_change_time = 80 * 1000;
 
-	ar->regulatory.current_rd = le16_to_cpu(ar->eeprom.reg_domain[0]);
-	ar->regulatory.current_rd_ext = le16_to_cpu(ar->eeprom.reg_domain[1]);
+	regulatory->current_rd = le16_to_cpu(ar->eeprom.reg_domain[0]);
+	regulatory->current_rd_ext = le16_to_cpu(ar->eeprom.reg_domain[1]);
 
 	/* second part of wiphy init */
 	SET_IEEE80211_PERM_ADDR(ar->hw, addr);
@@ -2722,11 +2723,12 @@ static int ar9170_reg_notifier(struct wiphy *wiphy,
 	struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
 	struct ar9170 *ar = hw->priv;
 
-	return ath_reg_notifier_apply(wiphy, request, &ar->regulatory);
+	return ath_reg_notifier_apply(wiphy, request, &ar->common.regulatory);
 }
 
 int ar9170_register(struct ar9170 *ar, struct device *pdev)
 {
+	struct ath_regulatory *regulatory = &ar->common.regulatory;
 	int err;
 
 	/* try to read EEPROM, init MAC addr */
@@ -2734,7 +2736,7 @@ int ar9170_register(struct ar9170 *ar, struct device *pdev)
 	if (err)
 		goto err_out;
 
-	err = ath_regd_init(&ar->regulatory, ar->hw->wiphy,
+	err = ath_regd_init(regulatory, ar->hw->wiphy,
 			    ar9170_reg_notifier);
 	if (err)
 		goto err_out;
@@ -2743,8 +2745,8 @@ int ar9170_register(struct ar9170 *ar, struct device *pdev)
 	if (err)
 		goto err_out;
 
-	if (!ath_is_world_regd(&ar->regulatory))
-		regulatory_hint(ar->hw->wiphy, ar->regulatory.alpha2);
+	if (!ath_is_world_regd(regulatory))
+		regulatory_hint(ar->hw->wiphy, regulatory->alpha2);
 
 	err = ar9170_init_leds(ar);
 	if (err)
diff --git a/drivers/net/wireless/ath/ath.h b/drivers/net/wireless/ath/ath.h
index e284cd3..a63e90c 100644
--- a/drivers/net/wireless/ath/ath.h
+++ b/drivers/net/wireless/ath/ath.h
@@ -19,8 +19,26 @@
 
 #include <linux/skbuff.h>
 
+struct reg_dmn_pair_mapping {
+	u16 regDmnEnum;
+	u16 reg_5ghz_ctl;
+	u16 reg_2ghz_ctl;
+};
+
+struct ath_regulatory {
+	char alpha2[2];
+	u16 country_code;
+	u16 max_power_level;
+	u32 tp_scale;
+	u16 current_rd;
+	u16 current_rd_ext;
+	int16_t power_limit;
+	struct reg_dmn_pair_mapping *regpair;
+};
+
 struct ath_common {
 	u16 cachelsz;
+	struct ath_regulatory regulatory;
 };
 
 struct sk_buff *ath_rxbuf_alloc(struct ath_common *common,
diff --git a/drivers/net/wireless/ath/ath5k/ath5k.h b/drivers/net/wireless/ath/ath5k/ath5k.h
index c09402e..862762c 100644
--- a/drivers/net/wireless/ath/ath5k/ath5k.h
+++ b/drivers/net/wireless/ath/ath5k/ath5k.h
@@ -27,8 +27,6 @@
 #include <linux/types.h>
 #include <net/mac80211.h>
 
-#include "../regd.h"
-
 /* RX/TX descriptor hw structs
  * TODO: Driver part should only see sw structs */
 #include "desc.h"
@@ -1077,7 +1075,6 @@ struct ath5k_hw {
 
 	int			ah_gpio_npins;
 
-	struct ath_regulatory	ah_regulatory;
 	struct ath5k_capabilities ah_capabilities;
 
 	struct ath5k_txq_info	ah_txq[AR5K_NUM_TX_QUEUES];
diff --git a/drivers/net/wireless/ath/ath5k/base.c b/drivers/net/wireless/ath/ath5k/base.c
index 3951b5b..5056410 100644
--- a/drivers/net/wireless/ath/ath5k/base.c
+++ b/drivers/net/wireless/ath/ath5k/base.c
@@ -718,9 +718,9 @@ static int ath5k_reg_notifier(struct wiphy *wiphy, struct regulatory_request *re
 {
 	struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
 	struct ath5k_softc *sc = hw->priv;
-	struct ath_regulatory *reg = &sc->ah->ah_regulatory;
+	struct ath_regulatory *regulatory = &sc->common.regulatory;
 
-	return ath_reg_notifier_apply(wiphy, request, reg);
+	return ath_reg_notifier_apply(wiphy, request, regulatory);
 }
 
 static int
@@ -728,6 +728,7 @@ ath5k_attach(struct pci_dev *pdev, struct ieee80211_hw *hw)
 {
 	struct ath5k_softc *sc = hw->priv;
 	struct ath5k_hw *ah = sc->ah;
+	struct ath_regulatory *regulatory = &sc->common.regulatory;
 	u8 mac[ETH_ALEN] = {};
 	int ret;
 
@@ -817,9 +818,8 @@ ath5k_attach(struct pci_dev *pdev, struct ieee80211_hw *hw)
 	memset(sc->bssidmask, 0xff, ETH_ALEN);
 	ath5k_hw_set_bssid_mask(sc->ah, sc->bssidmask);
 
-	ah->ah_regulatory.current_rd =
-		ah->ah_capabilities.cap_eeprom.ee_regdomain;
-	ret = ath_regd_init(&ah->ah_regulatory, hw->wiphy, ath5k_reg_notifier);
+	regulatory->current_rd = ah->ah_capabilities.cap_eeprom.ee_regdomain;
+	ret = ath_regd_init(regulatory, hw->wiphy, ath5k_reg_notifier);
 	if (ret) {
 		ATH5K_ERR(sc, "can't initialize regulatory system\n");
 		goto err_queues;
@@ -831,8 +831,8 @@ ath5k_attach(struct pci_dev *pdev, struct ieee80211_hw *hw)
 		goto err_queues;
 	}
 
-	if (!ath_is_world_regd(&sc->ah->ah_regulatory))
-		regulatory_hint(hw->wiphy, sc->ah->ah_regulatory.alpha2);
+	if (!ath_is_world_regd(regulatory))
+		regulatory_hint(hw->wiphy, regulatory->alpha2);
 
 	ath5k_init_leds(sc);
 
diff --git a/drivers/net/wireless/ath/ath5k/base.h b/drivers/net/wireless/ath/ath5k/base.h
index 25a72a8..a28c42f 100644
--- a/drivers/net/wireless/ath/ath5k/base.h
+++ b/drivers/net/wireless/ath/ath5k/base.h
@@ -50,6 +50,8 @@
 
 #include "ath5k.h"
 #include "debug.h"
+
+#include "../regd.h"
 #include "../ath.h"
 
 #define	ATH_RXBUF	40		/* number of RX buffers */
@@ -200,4 +202,15 @@ struct ath5k_softc {
 #define ath5k_hw_hasveol(_ah) \
 	(ath5k_hw_get_capability(_ah, AR5K_CAP_VEOL, 0, NULL) == 0)
 
+static inline struct ath_common *ath5k_hw_common(struct ath5k_hw *ah)
+{
+	return &ah->ah_sc->common;
+}
+
+static inline struct ath_regulatory *ath5k_hw_regulatory(struct ath5k_hw *ah)
+{
+	return &(ath5k_hw_common(ah)->regulatory);
+
+}
+
 #endif
diff --git a/drivers/net/wireless/ath/ath5k/phy.c b/drivers/net/wireless/ath/ath5k/phy.c
index 298fcf0..1a039f2 100644
--- a/drivers/net/wireless/ath/ath5k/phy.c
+++ b/drivers/net/wireless/ath/ath5k/phy.c
@@ -2198,6 +2198,7 @@ static void
 ath5k_get_max_ctl_power(struct ath5k_hw *ah,
 			struct ieee80211_channel *channel)
 {
+	struct ath_regulatory *regulatory = ath5k_hw_regulatory(ah);
 	struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom;
 	struct ath5k_edge_power *rep = ee->ee_ctl_pwr;
 	u8 *ctl_val = ee->ee_ctl;
@@ -2208,7 +2209,7 @@ ath5k_get_max_ctl_power(struct ath5k_hw *ah,
 	u8 ctl_idx = 0xFF;
 	u32 target = channel->center_freq;
 
-	ctl_mode = ath_regd_get_band_ctl(&ah->ah_regulatory, channel->band);
+	ctl_mode = ath_regd_get_band_ctl(regulatory, channel->band);
 
 	switch (channel->hw_value & CHANNEL_MODES) {
 	case CHANNEL_A:
diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h
index 2c9f662..0e444a6 100644
--- a/drivers/net/wireless/ath/ath9k/ath9k.h
+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
@@ -631,6 +631,16 @@ int ath_get_hal_qnum(u16 queue, struct ath_softc *sc);
 int ath_get_mac80211_qnum(u32 queue, struct ath_softc *sc);
 int ath_cabq_update(struct ath_softc *);
 
+static inline struct ath_common *ath9k_hw_common(struct ath_hw *ah)
+{
+	return &ah->ah_sc->common;
+}
+
+static inline struct ath_regulatory *ath9k_hw_regulatory(struct ath_hw *ah)
+{
+	return &(ath9k_hw_common(ah)->regulatory);
+}
+
 static inline void ath_read_cachesize(struct ath_softc *sc, int *csz)
 {
 	sc->bus_ops->read_cachesize(sc, csz);
diff --git a/drivers/net/wireless/ath/ath9k/eeprom_4k.c b/drivers/net/wireless/ath/ath9k/eeprom_4k.c
index d34dd23..b8eca7b 100644
--- a/drivers/net/wireless/ath/ath9k/eeprom_4k.c
+++ b/drivers/net/wireless/ath/ath9k/eeprom_4k.c
@@ -508,6 +508,7 @@ static void ath9k_hw_set_4k_power_per_rate_table(struct ath_hw *ah,
 	|| (((cfgCtl & ~CTL_MODE_M) | (pCtlMode[ctlMode] & CTL_MODE_M)) == \
 	    ((pEepData->ctlIndex[i] & CTL_MODE_M) | SD_NO_CTL))
 
+	struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
 	int i;
 	int16_t twiceLargestAntenna;
 	u16 twiceMinEdgePower;
@@ -541,9 +542,9 @@ static void ath9k_hw_set_4k_power_per_rate_table(struct ath_hw *ah,
 					   twiceLargestAntenna, 0);
 
 	maxRegAllowedPower = twiceMaxRegulatoryPower + twiceLargestAntenna;
-	if (ah->regulatory.tp_scale != ATH9K_TP_SCALE_MAX) {
+	if (regulatory->tp_scale != ATH9K_TP_SCALE_MAX) {
 		maxRegAllowedPower -=
-			(tpScaleReductionTable[(ah->regulatory.tp_scale)] * 2);
+			(tpScaleReductionTable[(regulatory->tp_scale)] * 2);
 	}
 
 	scaledPower = min(powerLimit, maxRegAllowedPower);
@@ -707,6 +708,7 @@ static void ath9k_hw_4k_set_txpower(struct ath_hw *ah,
 				    u8 twiceMaxRegulatoryPower,
 				    u8 powerLimit)
 {
+	struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
 	struct ar5416_eeprom_4k *pEepData = &ah->eeprom.map4k;
 	struct modal_eep_4k_header *pModal = &pEepData->modalHeader;
 	int16_t ratesArray[Ar5416RateSize];
@@ -744,7 +746,7 @@ static void ath9k_hw_4k_set_txpower(struct ath_hw *ah,
 	else if (IS_CHAN_HT20(chan))
 		i = rateHt20_0;
 
-	ah->regulatory.max_power_level = ratesArray[i];
+	regulatory->max_power_level = ratesArray[i];
 
 	if (AR_SREV_9280_10_OR_LATER(ah)) {
 		for (i = 0; i < Ar5416RateSize; i++)
diff --git a/drivers/net/wireless/ath/ath9k/eeprom_9287.c b/drivers/net/wireless/ath/ath9k/eeprom_9287.c
index 9590979..c20c21a 100644
--- a/drivers/net/wireless/ath/ath9k/eeprom_9287.c
+++ b/drivers/net/wireless/ath/ath9k/eeprom_9287.c
@@ -599,7 +599,7 @@ static void ath9k_hw_set_AR9287_power_per_rate_table(struct ath_hw *ah,
 {
 #define REDUCE_SCALED_POWER_BY_TWO_CHAIN     6
 #define REDUCE_SCALED_POWER_BY_THREE_CHAIN   10
-
+	struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
 	u16 twiceMaxEdgePower = AR5416_MAX_RATE_POWER;
 	static const u16 tpScaleReductionTable[5] =
 		{ 0, 3, 6, 9, AR5416_MAX_RATE_POWER };
@@ -632,9 +632,9 @@ static void ath9k_hw_set_AR9287_power_per_rate_table(struct ath_hw *ah,
 					    twiceLargestAntenna, 0);
 
 	maxRegAllowedPower = twiceMaxRegulatoryPower + twiceLargestAntenna;
-	if (ah->regulatory.tp_scale != ATH9K_TP_SCALE_MAX)
+	if (regulatory->tp_scale != ATH9K_TP_SCALE_MAX)
 		maxRegAllowedPower -=
-			(tpScaleReductionTable[(ah->regulatory.tp_scale)] * 2);
+			(tpScaleReductionTable[(regulatory->tp_scale)] * 2);
 
 	scaledPower = min(powerLimit, maxRegAllowedPower);
 
@@ -831,7 +831,7 @@ static void ath9k_hw_AR9287_set_txpower(struct ath_hw *ah,
 {
 #define INCREASE_MAXPOW_BY_TWO_CHAIN     6
 #define INCREASE_MAXPOW_BY_THREE_CHAIN   10
-
+	struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
 	struct ar9287_eeprom *pEepData = &ah->eeprom.map9287;
 	struct modal_eep_ar9287_header *pModal = &pEepData->modalHeader;
 	int16_t ratesArray[Ar5416RateSize];
@@ -949,20 +949,20 @@ static void ath9k_hw_AR9287_set_txpower(struct ath_hw *ah,
 		i = rate6mb;
 
 	if (AR_SREV_9280_10_OR_LATER(ah))
-		ah->regulatory.max_power_level =
+		regulatory->max_power_level =
 			ratesArray[i] + AR9287_PWR_TABLE_OFFSET_DB * 2;
 	else
-		ah->regulatory.max_power_level = ratesArray[i];
+		regulatory->max_power_level = ratesArray[i];
 
 	switch (ar5416_get_ntxchains(ah->txchainmask)) {
 	case 1:
 		break;
 	case 2:
-		ah->regulatory.max_power_level +=
+		regulatory->max_power_level +=
 			INCREASE_MAXPOW_BY_TWO_CHAIN;
 		break;
 	case 3:
-		ah->regulatory.max_power_level +=
+		regulatory->max_power_level +=
 			INCREASE_MAXPOW_BY_THREE_CHAIN;
 		break;
 	default:
diff --git a/drivers/net/wireless/ath/ath9k/eeprom_def.c b/drivers/net/wireless/ath/ath9k/eeprom_def.c
index 5211ad9..ae7fb5d 100644
--- a/drivers/net/wireless/ath/ath9k/eeprom_def.c
+++ b/drivers/net/wireless/ath/ath9k/eeprom_def.c
@@ -904,6 +904,7 @@ static void ath9k_hw_set_def_power_per_rate_table(struct ath_hw *ah,
 #define REDUCE_SCALED_POWER_BY_TWO_CHAIN     6  /* 10*log10(2)*2 */
 #define REDUCE_SCALED_POWER_BY_THREE_CHAIN   10 /* 10*log10(3)*2 */
 
+	struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
 	struct ar5416_eeprom_def *pEepData = &ah->eeprom.def;
 	u16 twiceMaxEdgePower = AR5416_MAX_RATE_POWER;
 	static const u16 tpScaleReductionTable[5] =
@@ -953,9 +954,9 @@ static void ath9k_hw_set_def_power_per_rate_table(struct ath_hw *ah,
 
 	maxRegAllowedPower = twiceMaxRegulatoryPower + twiceLargestAntenna;
 
-	if (ah->regulatory.tp_scale != ATH9K_TP_SCALE_MAX) {
+	if (regulatory->tp_scale != ATH9K_TP_SCALE_MAX) {
 		maxRegAllowedPower -=
-			(tpScaleReductionTable[(ah->regulatory.tp_scale)] * 2);
+			(tpScaleReductionTable[(regulatory->tp_scale)] * 2);
 	}
 
 	scaledPower = min(powerLimit, maxRegAllowedPower);
@@ -1163,6 +1164,7 @@ static void ath9k_hw_def_set_txpower(struct ath_hw *ah,
 				    u8 powerLimit)
 {
 #define RT_AR_DELTA(x) (ratesArray[x] - cck_ofdm_delta)
+	struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
 	struct ar5416_eeprom_def *pEepData = &ah->eeprom.def;
 	struct modal_eep_header *pModal =
 		&(pEepData->modalHeader[IS_CHAN_2GHZ(chan)]);
@@ -1292,19 +1294,19 @@ static void ath9k_hw_def_set_txpower(struct ath_hw *ah,
 		i = rateHt20_0;
 
 	if (AR_SREV_9280_10_OR_LATER(ah))
-		ah->regulatory.max_power_level =
+		regulatory->max_power_level =
 			ratesArray[i] + AR5416_PWR_TABLE_OFFSET * 2;
 	else
-		ah->regulatory.max_power_level = ratesArray[i];
+		regulatory->max_power_level = ratesArray[i];
 
 	switch(ar5416_get_ntxchains(ah->txchainmask)) {
 	case 1:
 		break;
 	case 2:
-		ah->regulatory.max_power_level += INCREASE_MAXPOW_BY_TWO_CHAIN;
+		regulatory->max_power_level += INCREASE_MAXPOW_BY_TWO_CHAIN;
 		break;
 	case 3:
-		ah->regulatory.max_power_level += INCREASE_MAXPOW_BY_THREE_CHAIN;
+		regulatory->max_power_level += INCREASE_MAXPOW_BY_THREE_CHAIN;
 		break;
 	default:
 		DPRINTF(ah->ah_sc, ATH_DBG_EEPROM,
diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c
index df62113..4f3d5ea 100644
--- a/drivers/net/wireless/ath/ath9k/hw.c
+++ b/drivers/net/wireless/ath/ath9k/hw.c
@@ -439,8 +439,13 @@ static void ath9k_hw_init_config(struct ath_hw *ah)
 
 static void ath9k_hw_init_defaults(struct ath_hw *ah)
 {
+	struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
+
+	regulatory->country_code = CTRY_DEFAULT;
+	regulatory->power_limit = MAX_RATE_POWER;
+	regulatory->tp_scale = ATH9K_TP_SCALE_MAX;
+
 	ah->hw_version.magic = AR5416_MAGIC;
-	ah->regulatory.country_code = CTRY_DEFAULT;
 	ah->hw_version.subvendorid = 0;
 
 	ah->ah_flags = 0;
@@ -449,8 +454,6 @@ static void ath9k_hw_init_defaults(struct ath_hw *ah)
 	if (!AR_SREV_9100(ah))
 		ah->ah_flags = AH_USE_EEPROM;
 
-	ah->regulatory.power_limit = MAX_RATE_POWER;
-	ah->regulatory.tp_scale = ATH9K_TP_SCALE_MAX;
 	ah->atim_window = 0;
 	ah->sta_id1_defaults = AR_STA_ID1_CRPT_MIC_ENABLE;
 	ah->beacon_interval = 100;
@@ -1368,6 +1371,7 @@ static int ath9k_hw_process_ini(struct ath_hw *ah,
 				struct ath9k_channel *chan,
 				enum ath9k_ht_macmode macmode)
 {
+	struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
 	int i, regWrites = 0;
 	struct ieee80211_channel *channel = chan->chan;
 	u32 modesIndex, freqIndex;
@@ -1474,11 +1478,11 @@ static int ath9k_hw_process_ini(struct ath_hw *ah,
 		ath9k_olc_init(ah);
 
 	ah->eep_ops->set_txpower(ah, chan,
-				 ath9k_regd_get_ctl(&ah->regulatory, chan),
+				 ath9k_regd_get_ctl(regulatory, chan),
 				 channel->max_antenna_gain * 2,
 				 channel->max_power * 2,
 				 min((u32) MAX_RATE_POWER,
-				 (u32) ah->regulatory.power_limit));
+				 (u32) regulatory->power_limit));
 
 	if (!ath9k_hw_set_rf_regs(ah, chan, freqIndex)) {
 		DPRINTF(ah->ah_sc, ATH_DBG_FATAL,
@@ -1796,6 +1800,7 @@ static bool ath9k_hw_channel_change(struct ath_hw *ah,
 				    struct ath9k_channel *chan,
 				    enum ath9k_ht_macmode macmode)
 {
+	struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
 	struct ieee80211_channel *channel = chan->chan;
 	u32 synthDelay, qnum;
 
@@ -1828,11 +1833,11 @@ static bool ath9k_hw_channel_change(struct ath_hw *ah,
 	}
 
 	ah->eep_ops->set_txpower(ah, chan,
-			     ath9k_regd_get_ctl(&ah->regulatory, chan),
+			     ath9k_regd_get_ctl(regulatory, chan),
 			     channel->max_antenna_gain * 2,
 			     channel->max_power * 2,
 			     min((u32) MAX_RATE_POWER,
-			     (u32) ah->regulatory.power_limit));
+			     (u32) regulatory->power_limit));
 
 	synthDelay = REG_READ(ah, AR_PHY_RX_DELAY) & AR_PHY_RX_DELAY_DELAY;
 	if (IS_CHAN_B(chan))
@@ -3480,27 +3485,29 @@ void ath9k_hw_set_sta_beacon_timers(struct ath_hw *ah,
 void ath9k_hw_fill_cap_info(struct ath_hw *ah)
 {
 	struct ath9k_hw_capabilities *pCap = &ah->caps;
+	struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
+
 	u16 capField = 0, eeval;
 
 	eeval = ah->eep_ops->get_eeprom(ah, EEP_REG_0);
-	ah->regulatory.current_rd = eeval;
+	regulatory->current_rd = eeval;
 
 	eeval = ah->eep_ops->get_eeprom(ah, EEP_REG_1);
 	if (AR_SREV_9285_10_OR_LATER(ah))
 		eeval |= AR9285_RDEXT_DEFAULT;
-	ah->regulatory.current_rd_ext = eeval;
+	regulatory->current_rd_ext = eeval;
 
 	capField = ah->eep_ops->get_eeprom(ah, EEP_OP_CAP);
 
 	if (ah->opmode != NL80211_IFTYPE_AP &&
 	    ah->hw_version.subvendorid == AR_SUBVENDOR_ID_NEW_A) {
-		if (ah->regulatory.current_rd == 0x64 ||
-		    ah->regulatory.current_rd == 0x65)
-			ah->regulatory.current_rd += 5;
-		else if (ah->regulatory.current_rd == 0x41)
-			ah->regulatory.current_rd = 0x43;
+		if (regulatory->current_rd == 0x64 ||
+		    regulatory->current_rd == 0x65)
+			regulatory->current_rd += 5;
+		else if (regulatory->current_rd == 0x41)
+			regulatory->current_rd = 0x43;
 		DPRINTF(ah->ah_sc, ATH_DBG_REGULATORY,
-			"regdomain mapped to 0x%x\n", ah->regulatory.current_rd);
+			"regdomain mapped to 0x%x\n", regulatory->current_rd);
 	}
 
 	eeval = ah->eep_ops->get_eeprom(ah, EEP_OP_MODE);
@@ -3635,7 +3642,7 @@ void ath9k_hw_fill_cap_info(struct ath_hw *ah)
 	else
 		pCap->hw_caps |= ATH9K_HW_CAP_4KB_SPLITTRANS;
 
-	if (ah->regulatory.current_rd_ext & (1 << REG_EXT_JAPAN_MIDBAND)) {
+	if (regulatory->current_rd_ext & (1 << REG_EXT_JAPAN_MIDBAND)) {
 		pCap->reg_cap =
 			AR_EEPROM_EEREGCAP_EN_KK_NEW_11A |
 			AR_EEPROM_EEREGCAP_EN_KK_U1_EVEN |
@@ -3664,6 +3671,7 @@ void ath9k_hw_fill_cap_info(struct ath_hw *ah)
 bool ath9k_hw_getcapability(struct ath_hw *ah, enum ath9k_capability_type type,
 			    u32 capability, u32 *result)
 {
+	struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
 	switch (type) {
 	case ATH9K_CAP_CIPHER:
 		switch (capability) {
@@ -3712,13 +3720,13 @@ bool ath9k_hw_getcapability(struct ath_hw *ah, enum ath9k_capability_type type,
 		case 0:
 			return 0;
 		case 1:
-			*result = ah->regulatory.power_limit;
+			*result = regulatory->power_limit;
 			return 0;
 		case 2:
-			*result = ah->regulatory.max_power_level;
+			*result = regulatory->max_power_level;
 			return 0;
 		case 3:
-			*result = ah->regulatory.tp_scale;
+			*result = regulatory->tp_scale;
 			return 0;
 		}
 		return false;
@@ -3956,17 +3964,18 @@ bool ath9k_hw_disable(struct ath_hw *ah)
 
 void ath9k_hw_set_txpowerlimit(struct ath_hw *ah, u32 limit)
 {
+	struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
 	struct ath9k_channel *chan = ah->curchan;
 	struct ieee80211_channel *channel = chan->chan;
 
-	ah->regulatory.power_limit = min(limit, (u32) MAX_RATE_POWER);
+	regulatory->power_limit = min(limit, (u32) MAX_RATE_POWER);
 
 	ah->eep_ops->set_txpower(ah, chan,
-				 ath9k_regd_get_ctl(&ah->regulatory, chan),
+				 ath9k_regd_get_ctl(regulatory, chan),
 				 channel->max_antenna_gain * 2,
 				 channel->max_power * 2,
 				 min((u32) MAX_RATE_POWER,
-				 (u32) ah->regulatory.power_limit));
+				 (u32) regulatory->power_limit));
 }
 
 void ath9k_hw_setmac(struct ath_hw *ah, const u8 *mac)
diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
index de31a15..24b3063 100644
--- a/drivers/net/wireless/ath/ath9k/hw.h
+++ b/drivers/net/wireless/ath/ath9k/hw.h
@@ -396,7 +396,6 @@ struct ath_hw {
 	struct ath9k_hw_version hw_version;
 	struct ath9k_ops_config config;
 	struct ath9k_hw_capabilities caps;
-	struct ath_regulatory regulatory;
 	struct ath9k_channel channels[38];
 	struct ath9k_channel *curchan;
 
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
index 2f9c149..55fbce2 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -1293,7 +1293,7 @@ static int ath9k_reg_notifier(struct wiphy *wiphy,
 	struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
 	struct ath_wiphy *aphy = hw->priv;
 	struct ath_softc *sc = aphy->sc;
-	struct ath_regulatory *reg = &sc->sc_ah->regulatory;
+	struct ath_regulatory *reg = &sc->common.regulatory;
 
 	return ath_reg_notifier_apply(wiphy, request, reg);
 }
@@ -1586,12 +1586,12 @@ int ath_init_device(u16 devid, struct ath_softc *sc)
 
 	ath_set_hw_capab(sc, hw);
 
-	error = ath_regd_init(&sc->sc_ah->regulatory, sc->hw->wiphy,
+	error = ath_regd_init(&sc->common.regulatory, sc->hw->wiphy,
 			      ath9k_reg_notifier);
 	if (error)
 		return error;
 
-	reg = &sc->sc_ah->regulatory;
+	reg = &sc->common.regulatory;
 
 	if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_HT) {
 		setup_ht_cap(sc, &sc->sbands[IEEE80211_BAND_2GHZ].ht_cap);
diff --git a/drivers/net/wireless/ath/regd.h b/drivers/net/wireless/ath/regd.h
index 07291cc..4d3c536 100644
--- a/drivers/net/wireless/ath/regd.h
+++ b/drivers/net/wireless/ath/regd.h
@@ -18,9 +18,10 @@
 #define REGD_H
 
 #include <linux/nl80211.h>
-
 #include <net/cfg80211.h>
 
+#include "ath.h"
+
 #define NO_CTL 0xff
 #define SD_NO_CTL               0xE0
 #define NO_CTL                  0xff
@@ -47,29 +48,12 @@
 #define CHANNEL_HALF_BW         10
 #define CHANNEL_QUARTER_BW      5
 
-struct reg_dmn_pair_mapping {
-	u16 regDmnEnum;
-	u16 reg_5ghz_ctl;
-	u16 reg_2ghz_ctl;
-};
-
 struct country_code_to_enum_rd {
 	u16 countryCode;
 	u16 regDmnEnum;
 	const char *isoName;
 };
 
-struct ath_regulatory {
-	char alpha2[2];
-	u16 country_code;
-	u16 max_power_level;
-	u32 tp_scale;
-	u16 current_rd;
-	u16 current_rd_ext;
-	int16_t power_limit;
-	struct reg_dmn_pair_mapping *regpair;
-};
-
 enum CountryCode {
 	CTRY_ALBANIA = 8,
 	CTRY_ALGERIA = 12,
-- 
1.6.3.3


^ permalink raw reply related

* Re: [rt2x00-users] [PATCH 4/7] rt2x00: Set SKBDESC_L2_PADDED in RX path
From: Ivo van Doorn @ 2009-08-17 23:33 UTC (permalink / raw)
  To: users; +Cc: Benoit PAPILLAULT, linux-wireless
In-Reply-To: <4A89C19E.6080906@free.fr>

On Monday 17 August 2009, Benoit PAPILLAULT wrote:
> Ivo van Doorn a écrit :
> > When the RX descriptor indicates the frame was L2 padded,
> > the SKBDESC_L2_PADDED flag should be set to make sure the
> > L2 padding is removed before it is send to mac80211.
> >
> > Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
> > ---
> >  drivers/net/wireless/rt2x00/rt2800usb.c |    4 +++-
> >  1 files changed, 3 insertions(+), 1 deletions(-)
> >
> > diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c
> b/drivers/net/wireless/rt2x00/rt2800usb.c
> > index c82474e..6de2eda 100644
> > --- a/drivers/net/wireless/rt2x00/rt2800usb.c
> > +++ b/drivers/net/wireless/rt2x00/rt2800usb.c
> > @@ -2163,8 +2163,10 @@ static void rt2800usb_fill_rxdone(struct
> queue_entry *entry,
> >      if (rt2x00_get_field32(rxd0, RXD_W0_MY_BSS))
> >          rxdesc->dev_flags |= RXDONE_MY_BSS;
> >
> > -    if (rt2x00_get_field32(rxd0, RXD_W0_L2PAD))
> > +    if (rt2x00_get_field32(rxd0, RXD_W0_L2PAD)) {
> >          rxdesc->dev_flags |= RXDONE_L2PAD;
> > +        skbdesc->flags |= SKBDESC_L2_PADDED;
> > +    }
> >
> >      if (rt2x00_get_field32(rxwi1, RXWI_W1_SHORT_GI))
> >          rxdesc->flags |= RX_FLAG_SHORT_GI;
> I have tested this patch as well and it looks correct. However, during
> my test, the hardware does not set L2PAD flag, even if padding is
> present (for some frames). I did the same test with the rt2870sta
> driver from Ralink and the L2PAD was indeed set.

But when the flag is set, it is being set correctly?
Perhaps we can just set the flag at all times, because rt2x00lib
checks how much padding is required anyway. Unless of course
the device doesn't always add L2 padding when it actually should have.

> Ivo : what happens during your tests?

Tests?

I don't really have time to perform any testing, so all patches are
only checked by me for 'code correctness'.

^ permalink raw reply

* Regulatory problems with ath5k in AP mode
From: Simon Farnsworth @ 2009-08-17 20:27 UTC (permalink / raw)
  To: linux-wireless

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello,

I'm facing problems using two ath5k miniPCI cards in a single box as a
dual-band access point. I'm using wireless-testing as of commit
d5a88a192e556a7c30f9d425bb6673b5bff5e3f3.

As I'm trying to use the cards for AP mode, I cannot rely on beacons with
regulatory data being present; instead, I have modprobe configured to run
"iw reg set GB" after cfg80211 is loaded, and hostapd.conf files containing
the line "country_code=GB".

My cards both have a regdomain in the EEPROM of 0x0, which my vendor assures
me is the correct regdomain for cards which don't claim any particular
regulatory compliance, and which rely on the host OS getting regulatory
compliance right. I am seeing two problems; firstly, the regulatory
infrastructure insists that I'm in the United States, thus preventing legal
use of the WiFi bands, but allowing me illegal use.

Secondly, I'm seeing different regulatory settings on each card. "iw list"
shows me that in the 2GHz band, phy1 is being allowed to use 27.0 dBm on
channels 1-11, whereas I'm only allowed to use 20.0 dBm, but I'm allowed
channels 1-13. In the 5GHz band, phy1 is allowed 17.0 dBm on channels 36-48,
to my local regulation's 20.0 dBm, reduced power in the (unusable as yet due
to driver limitations) DFS-only channels between 5.490 GHz and 5.710 GHz,
and 30 dBm in the illegal channels for my region of 149 to 165.

On phy0, I see that I'm being permitted 20.0 dBm in the 2GHz band (but still
only channels 1-11, and no beaconing permitted in the 5GHz band.

How do I persuade the Atheros drivers that, since I'm using AP mode, the
user-set regulatory domain is correct, and that the domain it selects for
EEPROM regdomain 0x0 is wrong?

Ideally, I would expect both cards to have the same regulatory rules
applied; I would further expect to be able to select a different country's
regulations to the ones selected by default, without losing the card's
calibration settings (which I believe are stored in a way that depends on
the EEPROM regdomain setting). I should note that I'm happy to run a
privately patched kernel, if that's the only way to do what I want, but I'm
still concerned about the differing regulatory rules between the two cards.

The relevant chunk of dmesg follows, and I can provide any other needed
information upon request:

[    1.857433] cfg80211: Calling CRDA to update world regulatory domain
[    1.891579] cfg80211: Calling CRDA for country: GB
[    2.015975] ath5k 0000:02:04.0: PCI INT A -> GSI 18 (level, low) -> IRQ 18
[    2.016204] ath5k 0000:02:04.0: registered as 'phy0'
[    2.152564] ath: EEPROM regdomain: 0x0
[    2.152574] ath: EEPROM indicates default country code should be used
[    2.152580] ath: doing EEPROM country->regdmn map search
[    2.152589] ath: country maps to regdmn code: 0x3a
[    2.152595] ath: Country alpha2 being used: US
[    2.152601] ath: Regpair used: 0x3a
[    2.264328] phy0: Selected rate control algorithm 'minstrel'
[    2.264822] ath5k phy0: Atheros AR5414 chip found (MAC: 0xa5, PHY: 0x61)
[    2.265041]   alloc irq_desc for 17 on node -1
[    2.265048]   alloc kstat_irqs on node -1
[    2.265066] ath5k 0000:02:08.0: PCI INT A -> GSI 17 (level, low) -> IRQ 17
[    2.265276] ath5k 0000:02:08.0: registered as 'phy1'
[    2.400795] ath: EEPROM regdomain: 0x0
[    2.400805] ath: EEPROM indicates default country code should be used
[    2.400812] ath: doing EEPROM country->regdmn map search
[    2.400821] ath: country maps to regdmn code: 0x3a
[    2.400827] ath: Country alpha2 being used: US
[    2.400832] ath: Regpair used: 0x3a
[    2.400924] cfg80211: Calling CRDA for country: US
[    2.403133] phy1: Selected rate control algorithm 'minstrel'
[    2.403636] ath5k phy1: Atheros AR5414 chip found (MAC: 0xa5, PHY: 0x61)
[    2.403867] cfg80211: Calling CRDA for country: US
[    3.076972] cfg80211: Current regulatory domain intersected:
[    3.077089]  (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp)
[    3.077277]  (2402000 KHz - 2472000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)
[    3.077386]  (2457000 KHz - 2472000 KHz @ 15000 KHz), (300 mBi, 2000 mBm)
[    3.077494]  (5170000 KHz - 5250000 KHz @ 40000 KHz), (300 mBi, 1700 mBm)
[    3.077602]  (5735000 KHz - 5835000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)
[    3.082954] cfg80211: Current regulatory domain intersected:
[    3.083078]  (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp)
[    3.083278]  (2402000 KHz - 2472000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)
[    3.083392]  (2457000 KHz - 2472000 KHz @ 15000 KHz), (300 mBi, 2000 mBm)
[    3.083504]  (5170000 KHz - 5250000 KHz @ 40000 KHz), (300 mBi, 1700 mBm)
[    3.083616]  (5735000 KHz - 5835000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)

- -- 
Thanks in advance for your help,

Simon Farnsworth
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkqJvRoACgkQSWe+XpRKvi0LrwCfVEMPoShTcFGE3SMTJyv0tT6u
IHQAnjCelYIVpCaxEoZIvKpUzQB9tJn1
=FGOO
-----END PGP SIGNATURE-----



^ permalink raw reply

* Re: [PATCH v4 32/34] wireless: make mac80211 select cfg80211
From: Johannes Berg @ 2009-08-17 21:37 UTC (permalink / raw)
  To: Luis R. Rodriguez; +Cc: linville, linux-wireless, Larry.Finger
In-Reply-To: <43e72e890908171000r52f59cb6tbfef751324bf9968@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 890 bytes --]

On Mon, 2009-08-17 at 10:00 -0700, Luis R. Rodriguez wrote:
> On Fri, Aug 14, 2009 at 2:06 PM, Johannes Berg<johannes@sipsolutions.net> wrote:
> > On Fri, 2009-08-14 at 16:25 -0400, Luis R. Rodriguez wrote:
> >> We can now remove that comment about mac80211 requiring
> >> cfg80211 and do that for the user.
> >
> > "now"? What changed to make this possible?
> >
> > NAK this change, because with it, it's possible to select
> > mac80211 = Y
> > -> cfg80211 = Y
> > while rfkill = M
> >
> > which will break the kernel build.
> 
> I'm able to do this with current kconfig, does this need to be fixed?

I don't think you can select this with the current config since cfg80211
depends on RFKILL == CFG80211 || RFKILL == n.

So you can do
CFG80211 = m
RFKILL = m

CFG80211 = *
RFKILL = n

CFG80211 = *
RFKILL = y

but NOT

CFG80211 = y
RFKILL = m

johannes

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

^ permalink raw reply

* Re: [PATCH] b43: LP-PHY: Fix reading old mode in the set TX power control routine
From: Larry Finger @ 2009-08-17 21:18 UTC (permalink / raw)
  To: Gábor Stefanik
  Cc: John W. Linville, Michael Buesch, Mark Huijgen, Broadcom Wireless,
	linux-wireless
In-Reply-To: <69e28c910908171303m69a575f0kad6e32592d3184ea@mail.gmail.com>

Gábor Stefanik wrote:
> 2009/8/17 John W. Linville <linville@tuxdriver.com>:
>> On Mon, Aug 17, 2009 at 09:33:06PM +0200, Gábor Stefanik wrote:
>>> 2009/8/14 Gábor Stefanik <netrolller.3d@gmail.com>:
>>>> Check the mode the hardware is in, not the mode we used the last time.
>>>>
>>>> Signed-off-by: Gábor Stefanik <netrolller.3d@gmail.com>
>>>> ---
>>>> Mark, please test if this fixes the TX power control WARN_ON you were
>>>> seeing.
>>>>
>>>> drivers/net/wireless/b43/phy_lp.c |    4 ++--
>>>> 1 files changed, 2 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/drivers/net/wireless/b43/phy_lp.c
>>>> b/drivers/net/wireless/b43/phy_lp.c
>>>> index 292ee51..76457f7 100644
>>>> --- a/drivers/net/wireless/b43/phy_lp.c
>>>> +++ b/drivers/net/wireless/b43/phy_lp.c
>>>> @@ -1015,9 +1015,9 @@ static void lpphy_set_tx_power_control(struct
>>>> b43_wldev *dev,
>>>>        struct b43_phy_lp *lpphy = dev->phy.lp;
>>>>        enum b43_lpphy_txpctl_mode oldmode;
>>>>
>>>> -       oldmode = lpphy->txpctl_mode;
>>>>        lpphy_read_tx_pctl_mode_from_hardware(dev);
>>>> -       if (lpphy->txpctl_mode == mode)
>>>> +       oldmode = lpphy->txpctl_mode;
>>>> +       if (oldmode == mode)
>>>>                return;
>>>>        lpphy->txpctl_mode = mode;
>>>>
>>>> --
>>>> 1.6.2.4
>>>>
>>> John, any news on this one? I can't see it in wireless testing.
>> Larry said "It does not fix it here. I'll take a look at the specs"...
> 
> It did not fix the warning, but it is nevertheless a legitimate fix.
> (I found this bug when I was looking for the source of the WARN_ON -
> this is not the source of the WARN_ON, but still a bug.)

This patch is OK.

Larry

^ permalink raw reply

* Re: [PATCH] b43: LP-PHY: Fix setting TX power control mode during RC  calibration
From: Larry Finger @ 2009-08-17 21:17 UTC (permalink / raw)
  To: Gábor Stefanik
  Cc: John W. Linville, Michael Buesch, Mark Huijgen, Broadcom Wireless,
	linux-wireless
In-Reply-To: <69e28c910908171302s3aed3181w38ba402ca7dfa13d@mail.gmail.com>

Gábor Stefanik wrote:
> 2009/8/17 John W. Linville <linville@tuxdriver.com>:
>> On Mon, Aug 17, 2009 at 09:32:42PM +0200, Gábor Stefanik wrote:
>>> 2009/8/14 Gábor Stefanik <netrolller.3d@gmail.com>:
>>>> Call set_tx_power_control with a LPPHY_TXPCTL rather than an
>>>> LPPHY_TX_PWR_CTL_CMD_MODE.
>>>>
>>>> Signed-off-by: Gábor Stefanik <netrolller.3d@gmail.com>
>>>> ---
>>>> This should fix the WARN_ON testers were seeing during init.
>>>>
>>>> drivers/net/wireless/b43/phy_lp.c |    2 +-
>>>> 1 files changed, 1 insertions(+), 1 deletions(-)
>>>>
>>>> diff --git a/drivers/net/wireless/b43/phy_lp.c
>>>> b/drivers/net/wireless/b43/phy_lp.c
>>>> index adfa7bf..558224b 100644
>>>> --- a/drivers/net/wireless/b43/phy_lp.c
>>>> +++ b/drivers/net/wireless/b43/phy_lp.c
>>>> @@ -1080,7 +1080,7 @@ static void lpphy_rev0_1_rc_calib(struct b43_wldev
>>>> *dev)
>>>>        old_txpctl = b43_phy_read(dev, B43_LPPHY_TX_PWR_CTL_CMD) &
>>>>                                        B43_LPPHY_TX_PWR_CTL_CMD_MODE;
>>>>
>>>> -       lpphy_set_tx_power_control(dev, B43_LPPHY_TX_PWR_CTL_CMD_MODE_OFF);
>>>> +       lpphy_set_tx_power_control(dev, B43_LPPHY_TXPCTL_OFF);
>>>>        lpphy_disable_crs(dev);
>>>>        loopback = lpphy_loopback(dev);
>>>>        if (loopback == -1)
>>>> --
>>>> 1.6.2.4
>>>>
>>> John, any news on this one? I can't see it in wireless testing.
>> Larry said:
>>
>> With this one, I still get WARNING: at
>> drivers/net/wireless/b43/phy_lp.c:1006
>> lpphy_set_tx_power_control+0xbf/0xdd [b43]().
>>
> 
> Previously, he was getting 2 warnings. This fixes one of them, the
> other one is handled by commit
> 1181d724fc2897f11f95bf6ebc86ae111390929c ("Fix another TX power
> control abuse").
> 

I need to be more careful with my comments. This pack is needed and
OK. Because of my involvement with the RE, I cannot ack any of these
LP PHY patches.

Larry

^ permalink raw reply

* status of AP mode in iwlwifi?
From: Andrey Yurovsky @ 2009-08-17 21:13 UTC (permalink / raw)
  To: linux-wireless

Hi folks.  What's the status of AP mode in iwlwifi?  I used it some
time in the past but I see that it's disabled in wireless-testing now.
 Is there an issue with AP mode in this driver?  Can it be re-enabled?
 Thanks,

  -Andrey

^ permalink raw reply

* Re: [rt2x00-users] [PATCH 4/7] rt2x00: Set SKBDESC_L2_PADDED in RX path
From: Benoit PAPILLAULT @ 2009-08-17 20:46 UTC (permalink / raw)
  To: rt2x00 Users List; +Cc: John Linville, linux-wireless
In-Reply-To: <200908171854.50790.IvDoorn@gmail.com>

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ivo van Doorn a écrit :
> When the RX descriptor indicates the frame was L2 padded,
> the SKBDESC_L2_PADDED flag should be set to make sure the
> L2 padding is removed before it is send to mac80211.
>
> Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
> ---
>  drivers/net/wireless/rt2x00/rt2800usb.c |    4 +++-
>  1 files changed, 3 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c
b/drivers/net/wireless/rt2x00/rt2800usb.c
> index c82474e..6de2eda 100644
> --- a/drivers/net/wireless/rt2x00/rt2800usb.c
> +++ b/drivers/net/wireless/rt2x00/rt2800usb.c
> @@ -2163,8 +2163,10 @@ static void rt2800usb_fill_rxdone(struct
queue_entry *entry,
>      if (rt2x00_get_field32(rxd0, RXD_W0_MY_BSS))
>          rxdesc->dev_flags |= RXDONE_MY_BSS;
> 
> -    if (rt2x00_get_field32(rxd0, RXD_W0_L2PAD))
> +    if (rt2x00_get_field32(rxd0, RXD_W0_L2PAD)) {
>          rxdesc->dev_flags |= RXDONE_L2PAD;
> +        skbdesc->flags |= SKBDESC_L2_PADDED;
> +    }
> 
>      if (rt2x00_get_field32(rxwi1, RXWI_W1_SHORT_GI))
>          rxdesc->flags |= RX_FLAG_SHORT_GI;
I have tested this patch as well and it looks correct. However, during
my test, the hardware does not set L2PAD flag, even if padding is
present (for some frames). I did the same test with the rt2870sta
driver from Ralink and the L2PAD was indeed set.

Ivo : what happens during your tests?

Regards,
Benoit

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkqJwZkACgkQOR6EySwP7oLcEACcDDUaE5oeOhF8CsC1hdg6cKQ6
7K4An2DKy76bVP2CpfhOJePGNrSWDI2v
=3ymH
-----END PGP SIGNATURE-----


^ permalink raw reply

* Re: [PATCH] b43: Fix sparse warnings
From: Pavel Roskin @ 2009-08-17 20:30 UTC (permalink / raw)
  To: Michael Buesch
  Cc: Gábor Stefanik, linux-wireless, bcm43xx-dev, Larry Finger
In-Reply-To: <200908151204.11024.mb@bu3sch.de>

On Sat, 2009-08-15 at 12:04 +0200, Michael Buesch wrote:

> I still do not understand why it does complain about an _explicit_ truncation.
> That's simply stupid. If I program an explicit truncation I _do_ mean to truncate the value.

Actually, it's a bug in sparse.  Sparse acts inconsistently.

This causes a warning:

void mask(unsigned short mask);
static void test(void)
{
        mask((unsigned short)0xffff0000);
}

test.c:4:30: warning: cast truncates bits from constant value (ffff0000
becomes 0)

But this is OK:

void mask(unsigned short mask);
static void test(void)
{
        mask((unsigned short)0xfffff000);
}

Moreover, this is OK, even though the cast changes the value of the
constant:

void mask(unsigned short mask);
static void test(void)
{
        mask((unsigned short)0xfffff000U);
}

I suggest that we take no action until sparse is fixed.  I'm going to
report the issue to the sparse mailing list now.

-- 
Regards,
Pavel Roskin

^ permalink raw reply

* Re: [PATCH] b43: LP-PHY: Fix reading old mode in the set TX power control routine
From: Gábor Stefanik @ 2009-08-17 20:03 UTC (permalink / raw)
  To: John W. Linville
  Cc: Michael Buesch, Larry Finger, Mark Huijgen, Broadcom Wireless,
	linux-wireless
In-Reply-To: <20090817195607.GJ5500@tuxdriver.com>

2009/8/17 John W. Linville <linville@tuxdriver.com>:
> On Mon, Aug 17, 2009 at 09:33:06PM +0200, Gábor Stefanik wrote:
>> 2009/8/14 Gábor Stefanik <netrolller.3d@gmail.com>:
>> > Check the mode the hardware is in, not the mode we used the last time.
>> >
>> > Signed-off-by: Gábor Stefanik <netrolller.3d@gmail.com>
>> > ---
>> > Mark, please test if this fixes the TX power control WARN_ON you were
>> > seeing.
>> >
>> > drivers/net/wireless/b43/phy_lp.c |    4 ++--
>> > 1 files changed, 2 insertions(+), 2 deletions(-)
>> >
>> > diff --git a/drivers/net/wireless/b43/phy_lp.c
>> > b/drivers/net/wireless/b43/phy_lp.c
>> > index 292ee51..76457f7 100644
>> > --- a/drivers/net/wireless/b43/phy_lp.c
>> > +++ b/drivers/net/wireless/b43/phy_lp.c
>> > @@ -1015,9 +1015,9 @@ static void lpphy_set_tx_power_control(struct
>> > b43_wldev *dev,
>> >        struct b43_phy_lp *lpphy = dev->phy.lp;
>> >        enum b43_lpphy_txpctl_mode oldmode;
>> >
>> > -       oldmode = lpphy->txpctl_mode;
>> >        lpphy_read_tx_pctl_mode_from_hardware(dev);
>> > -       if (lpphy->txpctl_mode == mode)
>> > +       oldmode = lpphy->txpctl_mode;
>> > +       if (oldmode == mode)
>> >                return;
>> >        lpphy->txpctl_mode = mode;
>> >
>> > --
>> > 1.6.2.4
>> >
>>
>> John, any news on this one? I can't see it in wireless testing.
>
> Larry said "It does not fix it here. I'll take a look at the specs"...

It did not fix the warning, but it is nevertheless a legitimate fix.
(I found this bug when I was looking for the source of the WARN_ON -
this is not the source of the WARN_ON, but still a bug.)

>
> --
> John W. Linville                Someday the world will need a hero, and you
> linville@tuxdriver.com                  might be all we have.  Be ready.
>



-- 
Vista: [V]iruses, [I]ntruders, [S]pyware, [T]rojans and [A]dware. :-)

^ permalink raw reply

* Re: [PATCH] b43: LP-PHY: Fix setting TX power control mode during RC calibration
From: Gábor Stefanik @ 2009-08-17 20:02 UTC (permalink / raw)
  To: John W. Linville
  Cc: Michael Buesch, Larry Finger, Mark Huijgen, Broadcom Wireless,
	linux-wireless
In-Reply-To: <20090817195718.GK5500@tuxdriver.com>

2009/8/17 John W. Linville <linville@tuxdriver.com>:
> On Mon, Aug 17, 2009 at 09:32:42PM +0200, Gábor Stefanik wrote:
>> 2009/8/14 Gábor Stefanik <netrolller.3d@gmail.com>:
>> > Call set_tx_power_control with a LPPHY_TXPCTL rather than an
>> > LPPHY_TX_PWR_CTL_CMD_MODE.
>> >
>> > Signed-off-by: Gábor Stefanik <netrolller.3d@gmail.com>
>> > ---
>> > This should fix the WARN_ON testers were seeing during init.
>> >
>> > drivers/net/wireless/b43/phy_lp.c |    2 +-
>> > 1 files changed, 1 insertions(+), 1 deletions(-)
>> >
>> > diff --git a/drivers/net/wireless/b43/phy_lp.c
>> > b/drivers/net/wireless/b43/phy_lp.c
>> > index adfa7bf..558224b 100644
>> > --- a/drivers/net/wireless/b43/phy_lp.c
>> > +++ b/drivers/net/wireless/b43/phy_lp.c
>> > @@ -1080,7 +1080,7 @@ static void lpphy_rev0_1_rc_calib(struct b43_wldev
>> > *dev)
>> >        old_txpctl = b43_phy_read(dev, B43_LPPHY_TX_PWR_CTL_CMD) &
>> >                                        B43_LPPHY_TX_PWR_CTL_CMD_MODE;
>> >
>> > -       lpphy_set_tx_power_control(dev, B43_LPPHY_TX_PWR_CTL_CMD_MODE_OFF);
>> > +       lpphy_set_tx_power_control(dev, B43_LPPHY_TXPCTL_OFF);
>> >        lpphy_disable_crs(dev);
>> >        loopback = lpphy_loopback(dev);
>> >        if (loopback == -1)
>> > --
>> > 1.6.2.4
>> >
>>
>> John, any news on this one? I can't see it in wireless testing.
>
> Larry said:
>
> With this one, I still get WARNING: at
> drivers/net/wireless/b43/phy_lp.c:1006
> lpphy_set_tx_power_control+0xbf/0xdd [b43]().
>

Previously, he was getting 2 warnings. This fixes one of them, the
other one is handled by commit
1181d724fc2897f11f95bf6ebc86ae111390929c ("Fix another TX power
control abuse").

> --
> John W. Linville                Someday the world will need a hero, and you
> linville@tuxdriver.com                  might be all we have.  Be ready.
>



-- 
Vista: [V]iruses, [I]ntruders, [S]pyware, [T]rojans and [A]dware. :-)

^ permalink raw reply

* Re: [PATCH] b43: LP-PHY: Fix setting TX power control mode during RC calibration
From: John W. Linville @ 2009-08-17 19:57 UTC (permalink / raw)
  To: Gábor Stefanik
  Cc: Michael Buesch, Larry Finger, Mark Huijgen, Broadcom Wireless,
	linux-wireless
In-Reply-To: <69e28c910908171232i6828d42bh3aac1d236f789c91@mail.gmail.com>

On Mon, Aug 17, 2009 at 09:32:42PM +0200, Gábor Stefanik wrote:
> 2009/8/14 Gábor Stefanik <netrolller.3d@gmail.com>:
> > Call set_tx_power_control with a LPPHY_TXPCTL rather than an
> > LPPHY_TX_PWR_CTL_CMD_MODE.
> >
> > Signed-off-by: Gábor Stefanik <netrolller.3d@gmail.com>
> > ---
> > This should fix the WARN_ON testers were seeing during init.
> >
> > drivers/net/wireless/b43/phy_lp.c |    2 +-
> > 1 files changed, 1 insertions(+), 1 deletions(-)
> >
> > diff --git a/drivers/net/wireless/b43/phy_lp.c
> > b/drivers/net/wireless/b43/phy_lp.c
> > index adfa7bf..558224b 100644
> > --- a/drivers/net/wireless/b43/phy_lp.c
> > +++ b/drivers/net/wireless/b43/phy_lp.c
> > @@ -1080,7 +1080,7 @@ static void lpphy_rev0_1_rc_calib(struct b43_wldev
> > *dev)
> >        old_txpctl = b43_phy_read(dev, B43_LPPHY_TX_PWR_CTL_CMD) &
> >                                        B43_LPPHY_TX_PWR_CTL_CMD_MODE;
> >
> > -       lpphy_set_tx_power_control(dev, B43_LPPHY_TX_PWR_CTL_CMD_MODE_OFF);
> > +       lpphy_set_tx_power_control(dev, B43_LPPHY_TXPCTL_OFF);
> >        lpphy_disable_crs(dev);
> >        loopback = lpphy_loopback(dev);
> >        if (loopback == -1)
> > --
> > 1.6.2.4
> >
> 
> John, any news on this one? I can't see it in wireless testing.

Larry said:

With this one, I still get WARNING: at
drivers/net/wireless/b43/phy_lp.c:1006
lpphy_set_tx_power_control+0xbf/0xdd [b43]().

-- 
John W. Linville		Someday the world will need a hero, and you
linville@tuxdriver.com			might be all we have.  Be ready.

^ permalink raw reply

* Re: [PATCH] b43: LP-PHY: Fix reading old mode in the set TX power control routine
From: John W. Linville @ 2009-08-17 19:56 UTC (permalink / raw)
  To: Gábor Stefanik
  Cc: Michael Buesch, Larry Finger, Mark Huijgen, Broadcom Wireless,
	linux-wireless
In-Reply-To: <69e28c910908171233l75b4f72cq8981fb048ad8ffbb@mail.gmail.com>

On Mon, Aug 17, 2009 at 09:33:06PM +0200, Gábor Stefanik wrote:
> 2009/8/14 Gábor Stefanik <netrolller.3d@gmail.com>:
> > Check the mode the hardware is in, not the mode we used the last time.
> >
> > Signed-off-by: Gábor Stefanik <netrolller.3d@gmail.com>
> > ---
> > Mark, please test if this fixes the TX power control WARN_ON you were
> > seeing.
> >
> > drivers/net/wireless/b43/phy_lp.c |    4 ++--
> > 1 files changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/net/wireless/b43/phy_lp.c
> > b/drivers/net/wireless/b43/phy_lp.c
> > index 292ee51..76457f7 100644
> > --- a/drivers/net/wireless/b43/phy_lp.c
> > +++ b/drivers/net/wireless/b43/phy_lp.c
> > @@ -1015,9 +1015,9 @@ static void lpphy_set_tx_power_control(struct
> > b43_wldev *dev,
> >        struct b43_phy_lp *lpphy = dev->phy.lp;
> >        enum b43_lpphy_txpctl_mode oldmode;
> >
> > -       oldmode = lpphy->txpctl_mode;
> >        lpphy_read_tx_pctl_mode_from_hardware(dev);
> > -       if (lpphy->txpctl_mode == mode)
> > +       oldmode = lpphy->txpctl_mode;
> > +       if (oldmode == mode)
> >                return;
> >        lpphy->txpctl_mode = mode;
> >
> > --
> > 1.6.2.4
> >
> 
> John, any news on this one? I can't see it in wireless testing.

Larry said "It does not fix it here. I'll take a look at the specs"...

-- 
John W. Linville		Someday the world will need a hero, and you
linville@tuxdriver.com			might be all we have.  Be ready.

^ permalink raw reply

* [PATCH v5 13/33] wireless: move AIRO_CS closer to AIRO
From: Luis R. Rodriguez @ 2009-08-17 19:46 UTC (permalink / raw)
  To: linville; +Cc: linux-wireless, Luis R. Rodriguez

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
---
 drivers/net/wireless/Kconfig |   40 ++++++++++++++++++++--------------------
 1 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/drivers/net/wireless/Kconfig b/drivers/net/wireless/Kconfig
index b489d9c..b03035f 100644
--- a/drivers/net/wireless/Kconfig
+++ b/drivers/net/wireless/Kconfig
@@ -213,6 +213,26 @@ config AIRO
 
 	  The driver can be compiled as a module and will be named "airo".
 
+config AIRO_CS
+	tristate "Cisco/Aironet 34X/35X/4500/4800 PCMCIA cards"
+	depends on PCMCIA && (BROKEN || !M32R) && WLAN_80211
+	select WIRELESS_EXT
+	select CRYPTO
+	select CRYPTO_AES
+	---help---
+	  This is the standard Linux driver to support Cisco/Aironet PCMCIA
+	  802.11 wireless cards.  This driver is the same as the Aironet
+	  driver part of the Linux Pcmcia package.
+	  It supports the new 802.11b cards from Cisco (Cisco 34X, Cisco 35X
+	  - with or without encryption) as well as card before the Cisco
+	  acquisition (Aironet 4500, Aironet 4800, Aironet 4800B). It also
+	  supports OEM of Cisco such as the DELL TrueMobile 4800 and Xircom
+	  802.11b cards.
+
+	  This driver support both the standard Linux Wireless Extensions
+	  and Cisco proprietary API, so both the Linux Wireless Tools and the
+	  Cisco Linux utilities can be used to configure the card.
+
 config ATMEL_80211
 	bool "Atmel"
 	depends on WLAN_80211
@@ -265,26 +285,6 @@ config AT76C50X_USB
 
 endif # ATMEL_80211
 
-config AIRO_CS
-	tristate "Cisco/Aironet 34X/35X/4500/4800 PCMCIA cards"
-	depends on PCMCIA && (BROKEN || !M32R) && WLAN_80211
-	select WIRELESS_EXT
-	select CRYPTO
-	select CRYPTO_AES
-	---help---
-	  This is the standard Linux driver to support Cisco/Aironet PCMCIA
-	  802.11 wireless cards.  This driver is the same as the Aironet
-	  driver part of the Linux Pcmcia package.
-	  It supports the new 802.11b cards from Cisco (Cisco 34X, Cisco 35X
-	  - with or without encryption) as well as card before the Cisco
-	  acquisition (Aironet 4500, Aironet 4800, Aironet 4800B). It also
-	  supports OEM of Cisco such as the DELL TrueMobile 4800 and Xircom
-	  802.11b cards.
-
-	  This driver support both the standard Linux Wireless Extensions
-	  and Cisco proprietary API, so both the Linux Wireless Tools and the
-	  Cisco Linux utilities can be used to configure the card.
-
 config PCMCIA_WL3501
       tristate "Planet WL3501 PCMCIA cards"
       depends on EXPERIMENTAL && PCMCIA && WLAN_80211
-- 
1.6.2.5


^ permalink raw reply related

* Re: [PATCH v5 13/33] wireless: move AIRO_CS closer to AIRO_CS
From: Luis R. Rodriguez @ 2009-08-17 19:45 UTC (permalink / raw)
  To: Gábor Stefanik; +Cc: linville, linux-wireless
In-Reply-To: <69e28c910908171222g17e9563csd38dadfcc8fe0bae@mail.gmail.com>

2009/8/17 Gábor Stefanik <netrolller.3d@gmail.com>:
> On Mon, Aug 17, 2009 at 7:27 PM, Luis R.
> Rodriguez<lrodriguez@atheros.com> wrote:
>> Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
>> ---
>>  drivers/net/wireless/Kconfig |   40 ++++++++++++++++++++--------------------
>>  1 files changed, 20 insertions(+), 20 deletions(-)
>>
>> diff --git a/drivers/net/wireless/Kconfig b/drivers/net/wireless/Kconfig
>> index b489d9c..b03035f 100644
>> --- a/drivers/net/wireless/Kconfig
>> +++ b/drivers/net/wireless/Kconfig
>> @@ -213,6 +213,26 @@ config AIRO
>>
>>          The driver can be compiled as a module and will be named "airo".
>>
>> +config AIRO_CS
>> +       tristate "Cisco/Aironet 34X/35X/4500/4800 PCMCIA cards"
>> +       depends on PCMCIA && (BROKEN || !M32R) && WLAN_80211
>> +       select WIRELESS_EXT
>> +       select CRYPTO
>> +       select CRYPTO_AES
>> +       ---help---
>> +         This is the standard Linux driver to support Cisco/Aironet PCMCIA
>> +         802.11 wireless cards.  This driver is the same as the Aironet
>> +         driver part of the Linux Pcmcia package.
>> +         It supports the new 802.11b cards from Cisco (Cisco 34X, Cisco 35X
>> +         - with or without encryption) as well as card before the Cisco
>> +         acquisition (Aironet 4500, Aironet 4800, Aironet 4800B). It also
>> +         supports OEM of Cisco such as the DELL TrueMobile 4800 and Xircom
>> +         802.11b cards.
>> +
>> +         This driver support both the standard Linux Wireless Extensions
>> +         and Cisco proprietary API, so both the Linux Wireless Tools and the
>> +         Cisco Linux utilities can be used to configure the card.
>> +
>>  config ATMEL_80211
>>        bool "Atmel"
>>        depends on WLAN_80211
>> @@ -265,26 +285,6 @@ config AT76C50X_USB
>>
>>  endif # ATMEL_80211
>>
>> -config AIRO_CS
>> -       tristate "Cisco/Aironet 34X/35X/4500/4800 PCMCIA cards"
>> -       depends on PCMCIA && (BROKEN || !M32R) && WLAN_80211
>> -       select WIRELESS_EXT
>> -       select CRYPTO
>> -       select CRYPTO_AES
>> -       ---help---
>> -         This is the standard Linux driver to support Cisco/Aironet PCMCIA
>> -         802.11 wireless cards.  This driver is the same as the Aironet
>> -         driver part of the Linux Pcmcia package.
>> -         It supports the new 802.11b cards from Cisco (Cisco 34X, Cisco 35X
>> -         - with or without encryption) as well as card before the Cisco
>> -         acquisition (Aironet 4500, Aironet 4800, Aironet 4800B). It also
>> -         supports OEM of Cisco such as the DELL TrueMobile 4800 and Xircom
>> -         802.11b cards.
>> -
>> -         This driver support both the standard Linux Wireless Extensions
>> -         and Cisco proprietary API, so both the Linux Wireless Tools and the
>> -         Cisco Linux utilities can be used to configure the card.
>> -
>>  config PCMCIA_WL3501
>>       tristate "Planet WL3501 PCMCIA cards"
>>       depends on EXPERIMENTAL && PCMCIA && WLAN_80211
>> --
>> 1.6.2.5
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>
>
> AIRO_CS has an identity crisis again...

Heh, will resend with a fix in the commit log entry.

Thanks,

  Luis

^ permalink raw reply

* [RFT/RFC] p54: fix broadcast buffering in AP mode
From: Christian Lamparter @ 2009-08-17 19:24 UTC (permalink / raw)
  To: linux-wireless; +Cc: John Linville, Johannes Berg

The patch "mac80211: fix PS-poll response race" somehow broke
broadcast buffering in a funny way.

During normal operation - stations are awake - the firmware refused
to transmit broadcast frames and reported P54_TX_PSM_CANCELLED.
But everything worked as soon as one station entered PSM.

The best explanation I could come up with is:
The stack sets IEEE80211_TX_CTL_SEND_AFTER_DTIM for outgoing
broadcast frames as soon as a station is marked as sleeping.
This flag triggers a path which will reroute these frames
into p54's "content after beacon" queue.

The most likely reason why this worked before is because mac80211
always sets IEEE80211_TX_CTL_CLEAR_PS_FILT flag for outgoing
broadcast frames. This once - before the PS-poll patch -
was used to signalize the firmware to overwrite the
ps canceling for this special frame.

Signed-off-by: Christian Lamparter <chunkeey@web.de>
---
diff --git a/drivers/net/wireless/p54/fwio.c b/drivers/net/wireless/p54/fwio.c
index e7b9e9c..57a0ffd 100644
--- a/drivers/net/wireless/p54/fwio.c
+++ b/drivers/net/wireless/p54/fwio.c
@@ -283,7 +283,10 @@ int p54_sta_unlock(struct p54_common *priv, u8 *addr)
 		return -ENOMEM;
 
 	sta = (struct p54_sta_unlock *)skb_put(skb, sizeof(*sta));
-	memcpy(sta->addr, addr, ETH_ALEN);
+	if (addr)
+		memcpy(sta->addr, addr, ETH_ALEN);
+	else
+		memset(sta->addr, ~0, ETH_ALEN);
 	p54_tx(priv, skb);
 	return 0;
 }
diff --git a/drivers/net/wireless/p54/main.c b/drivers/net/wireless/p54/main.c
index 77203e3..db415c2 100644
--- a/drivers/net/wireless/p54/main.c
+++ b/drivers/net/wireless/p54/main.c
@@ -38,20 +38,42 @@ static void p54_sta_notify(struct ieee80211_hw *dev, struct ieee80211_vif *vif,
 			      struct ieee80211_sta *sta)
 {
 	struct p54_common *priv = dev->priv;
+	struct p54_sta_info *sta_info = (void *) sta->drv_priv;
+
 	switch (notify_cmd) {
 	case STA_NOTIFY_ADD:
 	case STA_NOTIFY_REMOVE:
+	case STA_NOTIFY_AWAKE:
 		/*
 		 * Notify the firmware that we don't want or we don't
 		 * need to buffer frames for this station anymore.
 		 */
 
 		p54_sta_unlock(priv, sta->addr);
+
+		if (sta_info->state & STA_DOZING) {
+			if (atomic_dec_and_test(&priv->num_sta_ps)) {
+				/*
+				 * The last station has woken up.
+				 *
+				 * Disable broadcast ps filter, which has
+				 * been secretly set by firmware.
+				 */
+
+				p54_sta_unlock(priv, NULL);
+			}
+		}
+
+		sta_info->state &= ~STA_DOZING;
 		break;
-	case STA_NOTIFY_AWAKE:
-		/* update the firmware's filter table */
-		p54_sta_unlock(priv, sta->addr);
+
+	case STA_NOTIFY_SLEEP:
+		if (!(sta_info->state & STA_DOZING))
+			atomic_inc(&priv->num_sta_ps);
+
+		sta_info->state |= STA_DOZING;
 		break;
+
 	default:
 		break;
 	}
@@ -185,6 +207,8 @@ static int p54_start(struct ieee80211_hw *dev)
 	priv->softled_state = 0;
 	err = p54_set_leds(priv);
 
+	atomic_set(&priv->num_sta_ps, 0);
+
 out:
 	mutex_unlock(&priv->conf_mutex);
 	return err;
@@ -581,6 +605,8 @@ struct ieee80211_hw *p54_init_common(size_t priv_data_len)
 	 */
 	dev->wiphy->ps_default = false;
 
+	dev->sta_data_size = sizeof(struct p54_sta_info);
+
 	mutex_init(&priv->conf_mutex);
 	mutex_init(&priv->eeprom_mutex);
 	init_completion(&priv->eeprom_comp);
diff --git a/drivers/net/wireless/p54/p54.h b/drivers/net/wireless/p54/p54.h
index 1afc394..8cacb7a 100644
--- a/drivers/net/wireless/p54/p54.h
+++ b/drivers/net/wireless/p54/p54.h
@@ -228,6 +228,7 @@ struct p54_common {
 	/* statistics */
 	struct ieee80211_low_level_stats stats;
 	struct delayed_work work;
+	atomic_t num_sta_ps;
 
 	/* eeprom handling */
 	void *eeprom;
@@ -235,6 +236,14 @@ struct p54_common {
 	struct mutex eeprom_mutex;
 };
 
+enum p54_sta_state_t {
+	STA_DOZING	= BIT(0),
+};
+
+struct p54_sta_info {
+	enum p54_sta_state_t state;
+};
+
 /* interfaces for the drivers */
 int p54_rx(struct ieee80211_hw *dev, struct sk_buff *skb);
 void p54_free_skb(struct ieee80211_hw *dev, struct sk_buff *skb);
---

Of course, instead of the big patch above we could restore the
original behavior with:

diff --git a/drivers/net/wireless/p54/txrx.c b/drivers/net/wireless/p54/txrx.c
index 6fc0b61..b6dda2b 100644
--- a/drivers/net/wireless/p54/txrx.c
+++ b/drivers/net/wireless/p54/txrx.c
@@ -623,6 +623,9 @@ static void p54_tx_80211_header(struct p54_common *priv, struct sk_buff *skb,
 	if (info->flags & IEEE80211_TX_CTL_PSPOLL_RESPONSE)
 		*flags |= P54_HDR_FLAG_DATA_OUT_NOCANCEL;
 
+	if (info->flags & IEEE80211_TX_CTL_CLEAR_PS_FILT)
+		*flags |= P54_HDR_FLAG_DATA_OUT_NOCANCEL;
+
 	*queue = skb_get_queue_mapping(skb) + P54_QUEUE_DATA;
 
 	switch (priv->mode) {
---

pools are open! Didn't have a chance to test them on real HW & setup.
Please report if these patches fix/break anything...

Regards,
   Chr

^ permalink raw reply related

* Re: [PATCH] b43: LP-PHY: Fix reading old mode in the set TX power control routine
From: Gábor Stefanik @ 2009-08-17 19:33 UTC (permalink / raw)
  To: John Linville, Michael Buesch, Larry Finger, Mark Huijgen
  Cc: Broadcom Wireless, linux-wireless
In-Reply-To: <4A85AD1B.1060008@gmail.com>

2009/8/14 Gábor Stefanik <netrolller.3d@gmail.com>:
> Check the mode the hardware is in, not the mode we used the last time.
>
> Signed-off-by: Gábor Stefanik <netrolller.3d@gmail.com>
> ---
> Mark, please test if this fixes the TX power control WARN_ON you were
> seeing.
>
> drivers/net/wireless/b43/phy_lp.c |    4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/wireless/b43/phy_lp.c
> b/drivers/net/wireless/b43/phy_lp.c
> index 292ee51..76457f7 100644
> --- a/drivers/net/wireless/b43/phy_lp.c
> +++ b/drivers/net/wireless/b43/phy_lp.c
> @@ -1015,9 +1015,9 @@ static void lpphy_set_tx_power_control(struct
> b43_wldev *dev,
>        struct b43_phy_lp *lpphy = dev->phy.lp;
>        enum b43_lpphy_txpctl_mode oldmode;
>
> -       oldmode = lpphy->txpctl_mode;
>        lpphy_read_tx_pctl_mode_from_hardware(dev);
> -       if (lpphy->txpctl_mode == mode)
> +       oldmode = lpphy->txpctl_mode;
> +       if (oldmode == mode)
>                return;
>        lpphy->txpctl_mode = mode;
>
> --
> 1.6.2.4
>

John, any news on this one? I can't see it in wireless testing.

-- 
Vista: [V]iruses, [I]ntruders, [S]pyware, [T]rojans and [A]dware. :-)

^ permalink raw reply

* Re: [PATCH] b43: LP-PHY: Fix setting TX power control mode during RC calibration
From: Gábor Stefanik @ 2009-08-17 19:32 UTC (permalink / raw)
  To: John Linville, Michael Buesch, Larry Finger, Mark Huijgen
  Cc: Broadcom Wireless, linux-wireless
In-Reply-To: <4A85B8DE.3000704@gmail.com>

2009/8/14 Gábor Stefanik <netrolller.3d@gmail.com>:
> Call set_tx_power_control with a LPPHY_TXPCTL rather than an
> LPPHY_TX_PWR_CTL_CMD_MODE.
>
> Signed-off-by: Gábor Stefanik <netrolller.3d@gmail.com>
> ---
> This should fix the WARN_ON testers were seeing during init.
>
> drivers/net/wireless/b43/phy_lp.c |    2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/net/wireless/b43/phy_lp.c
> b/drivers/net/wireless/b43/phy_lp.c
> index adfa7bf..558224b 100644
> --- a/drivers/net/wireless/b43/phy_lp.c
> +++ b/drivers/net/wireless/b43/phy_lp.c
> @@ -1080,7 +1080,7 @@ static void lpphy_rev0_1_rc_calib(struct b43_wldev
> *dev)
>        old_txpctl = b43_phy_read(dev, B43_LPPHY_TX_PWR_CTL_CMD) &
>                                        B43_LPPHY_TX_PWR_CTL_CMD_MODE;
>
> -       lpphy_set_tx_power_control(dev, B43_LPPHY_TX_PWR_CTL_CMD_MODE_OFF);
> +       lpphy_set_tx_power_control(dev, B43_LPPHY_TXPCTL_OFF);
>        lpphy_disable_crs(dev);
>        loopback = lpphy_loopback(dev);
>        if (loopback == -1)
> --
> 1.6.2.4
>

John, any news on this one? I can't see it in wireless testing.

-- 
Vista: [V]iruses, [I]ntruders, [S]pyware, [T]rojans and [A]dware. :-)

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox