linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ath9k: fix per-packet tx power configuration
@ 2015-04-08 18:51 Lorenzo Bianconi
  2015-04-28 15:52 ` Kalle Valo
  2015-05-03 20:54 ` Kalle Valo
  0 siblings, 2 replies; 4+ messages in thread
From: Lorenzo Bianconi @ 2015-04-08 18:51 UTC (permalink / raw)
  To: linux-wireless; +Cc: nbd

Do not use ieee80211_vif pointer in ath_get_rate_txpower() since it has been
overwritten by setup_frame_info() and it will result in a corrupted tx power
configuration. Set per-packet tx power in setup_frame_info() according to
current vif tx power.

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
---
 drivers/net/wireless/ath/ath9k/xmit.c | 52 +++++++++++++++++------------------
 1 file changed, 25 insertions(+), 27 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c
index 0acd079..3ad79bb 100644
--- a/drivers/net/wireless/ath/ath9k/xmit.c
+++ b/drivers/net/wireless/ath/ath9k/xmit.c
@@ -1103,28 +1103,14 @@ static u8 ath_get_rate_txpower(struct ath_softc *sc, struct ath_buf *bf,
 	struct sk_buff *skb;
 	struct ath_frame_info *fi;
 	struct ieee80211_tx_info *info;
-	struct ieee80211_vif *vif;
 	struct ath_hw *ah = sc->sc_ah;
 
 	if (sc->tx99_state || !ah->tpc_enabled)
 		return MAX_RATE_POWER;
 
 	skb = bf->bf_mpdu;
-	info = IEEE80211_SKB_CB(skb);
-	vif = info->control.vif;
-
-	if (!vif) {
-		max_power = sc->cur_chan->cur_txpower;
-		goto out;
-	}
-
-	if (vif->bss_conf.txpower_type != NL80211_TX_POWER_LIMITED) {
-		max_power = min_t(u8, sc->cur_chan->cur_txpower,
-				  2 * vif->bss_conf.txpower);
-		goto out;
-	}
-
 	fi = get_frame_info(skb);
+	info = IEEE80211_SKB_CB(skb);
 
 	if (!AR_SREV_9300_20_OR_LATER(ah)) {
 		int txpower = fi->tx_power;
@@ -1161,25 +1147,26 @@ static u8 ath_get_rate_txpower(struct ath_softc *sc, struct ath_buf *bf,
 			txpower -= 2;
 
 		txpower = max(txpower, 0);
-		max_power = min_t(u8, ah->tx_power[rateidx],
-				  2 * vif->bss_conf.txpower);
-		max_power = min_t(u8, max_power, txpower);
+		max_power = min_t(u8, ah->tx_power[rateidx], txpower);
+
+		/* XXX: clamp minimum TX power at 1 for AR9160 since if
+		 * max_power is set to 0, frames are transmitted at max
+		 * TX power
+		 */
+		if (!max_power && !AR_SREV_9280_20_OR_LATER(ah))
+			max_power = 1;
 	} else if (!bf->bf_state.bfs_paprd) {
 		if (rateidx < 8 && (info->flags & IEEE80211_TX_CTL_STBC))
 			max_power = min_t(u8, ah->tx_power_stbc[rateidx],
-					  2 * vif->bss_conf.txpower);
+					  fi->tx_power);
 		else
 			max_power = min_t(u8, ah->tx_power[rateidx],
-					  2 * vif->bss_conf.txpower);
-		max_power = min(max_power, fi->tx_power);
+					  fi->tx_power);
 	} else {
 		max_power = ah->paprd_training_power;
 	}
-out:
-	/* XXX: clamp minimum TX power at 1 for AR9160 since if max_power
-	 * is set to 0, frames are transmitted at max TX power
-	 */
-	return (!max_power && !AR_SREV_9280_20_OR_LATER(ah)) ? 1 : max_power;
+
+	return max_power;
 }
 
 static void ath_buf_set_rate(struct ath_softc *sc, struct ath_buf *bf,
@@ -2129,6 +2116,7 @@ static void setup_frame_info(struct ieee80211_hw *hw,
 	struct ath_node *an = NULL;
 	enum ath9k_key_type keytype;
 	bool short_preamble = false;
+	u8 txpower;
 
 	/*
 	 * We check if Short Preamble is needed for the CTS rate by
@@ -2145,6 +2133,16 @@ static void setup_frame_info(struct ieee80211_hw *hw,
 	if (sta)
 		an = (struct ath_node *) sta->drv_priv;
 
+	if (tx_info->control.vif) {
+		struct ieee80211_vif *vif = tx_info->control.vif;
+
+		txpower = 2 * vif->bss_conf.txpower;
+	} else {
+		struct ath_softc *sc = hw->priv;
+
+		txpower = sc->cur_chan->cur_txpower;
+	}
+
 	memset(fi, 0, sizeof(*fi));
 	fi->txq = -1;
 	if (hw_key)
@@ -2155,7 +2153,7 @@ static void setup_frame_info(struct ieee80211_hw *hw,
 		fi->keyix = ATH9K_TXKEYIX_INVALID;
 	fi->keytype = keytype;
 	fi->framelen = framelen;
-	fi->tx_power = MAX_RATE_POWER;
+	fi->tx_power = txpower;
 
 	if (!rate)
 		return;
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] ath9k: fix per-packet tx power configuration
  2015-04-08 18:51 [PATCH] ath9k: fix per-packet tx power configuration Lorenzo Bianconi
@ 2015-04-28 15:52 ` Kalle Valo
  2015-04-29  8:06   ` Lorenzo Bianconi
  2015-05-03 20:54 ` Kalle Valo
  1 sibling, 1 reply; 4+ messages in thread
From: Kalle Valo @ 2015-04-28 15:52 UTC (permalink / raw)
  To: Lorenzo Bianconi; +Cc: linux-wireless, nbd

Lorenzo Bianconi <lorenzo.bianconi83@gmail.com> writes:

> Do not use ieee80211_vif pointer in ath_get_rate_txpower() since it has been
> overwritten by setup_frame_info() and it will result in a corrupted tx power
> configuration. Set per-packet tx power in setup_frame_info() according to
> current vif tx power.
>
> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>

I'm planning to send this fix to 4.1, is that ok?

-- 
Kalle Valo

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ath9k: fix per-packet tx power configuration
  2015-04-28 15:52 ` Kalle Valo
@ 2015-04-29  8:06   ` Lorenzo Bianconi
  0 siblings, 0 replies; 4+ messages in thread
From: Lorenzo Bianconi @ 2015-04-29  8:06 UTC (permalink / raw)
  To: Kalle Valo; +Cc: linux-wireless, Felix Fietkau

>> Do not use ieee80211_vif pointer in ath_get_rate_txpower() since it has been
>> overwritten by setup_frame_info() and it will result in a corrupted tx power
>> configuration. Set per-packet tx power in setup_frame_info() according to
>> current vif tx power.
>>
>> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
>
> I'm planning to send this fix to 4.1, is that ok?
>

I agree. That patch has been tested on an urban noisy link and the RX
signal strength is solid. The throughput is stable as well. The patch
hopefully fixes the issue reported in the commit
'c09396eb8e5a8df668174993c6400763022b2466 - ath9k: disable TPC support
again (for now)'

Best regards,
Lorenzo

> --
> Kalle Valo



-- 
UNIX is Sexy: who | grep -i blonde | talk; cd ~; wine; talk; touch;
unzip; touch; strip; gasp; finger; gasp; mount; fsck; more; yes; gasp;
umount; make clean; sleep

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: ath9k: fix per-packet tx power configuration
  2015-04-08 18:51 [PATCH] ath9k: fix per-packet tx power configuration Lorenzo Bianconi
  2015-04-28 15:52 ` Kalle Valo
@ 2015-05-03 20:54 ` Kalle Valo
  1 sibling, 0 replies; 4+ messages in thread
From: Kalle Valo @ 2015-05-03 20:54 UTC (permalink / raw)
  To: Lorenzo Bianconi; +Cc: linux-wireless, nbd


> Do not use ieee80211_vif pointer in ath_get_rate_txpower() since it has been
> overwritten by setup_frame_info() and it will result in a corrupted tx power
> configuration. Set per-packet tx power in setup_frame_info() according to
> current vif tx power.
> 
> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>

Thanks, applied to wireless-drivers.git.

Kalle Valo

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-05-03 20:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-08 18:51 [PATCH] ath9k: fix per-packet tx power configuration Lorenzo Bianconi
2015-04-28 15:52 ` Kalle Valo
2015-04-29  8:06   ` Lorenzo Bianconi
2015-05-03 20:54 ` Kalle Valo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).