Skip to contentSkip to conversation

ath5k: Allow user/driver to set txpower

PATCH In review Nick Kossifidis 4 participants 7 messages Apr 16, 2009 – Apr 29, 2009 Atheros ATH5K wireless driver

lore
Share & tools
lore
#0 lore raw

PATCH 1/7 ath5k: Allow user/driver to set txpower

* Now that we have regulatory control enable the driver to set txpower on hw
* Also use txpower table offset so that we can match power range set by user/driver with indices on power table.

Tested 2 different cards (a CM9 and an RF5112-based ubnt) and got the same output using a remote machine to measure per-packet rssi (conected the cards using attenuators). I also switched between various tx power levels and i saw an equal power change on the remote machine (so txpower changes as expected) and verified that we have the same output on each rate.

---
 drivers/net/wireless/ath/ath5k/ath5k.h |    7 +++--
 drivers/net/wireless/ath/ath5k/base.c  |   10 ++++++-
 drivers/net/wireless/ath/ath5k/phy.c   |   45 ++++++++++++++++++++++++++-----
 drivers/net/wireless/ath/ath5k/reset.c |    2 +-
 4 files changed, 51 insertions(+), 13 deletions(-)
drivers/net/wireless/ath/ath5k/ath5k.h +4 -3
index 60c6d2e..04b7345 100644
@@ -1100,11 +1100,12 @@ struct ath5k_hw {
 		/* Values in 0.25dB units */
 		s16		txp_min_pwr;
 		s16		txp_max_pwr;
+		/* Values in 0.5dB units */
 		s16		txp_offset;
 		s16		txp_ofdm;
-		/* Values in dB units */
-		s16		txp_cck_ofdm_pwr_delta;
 		s16		txp_cck_ofdm_gainf_delta;
+		/* Value in dB units */
+		s16		txp_cck_ofdm_pwr_delta;
 	} ah_txpower;
 
 	struct {
@@ -1271,7 +1272,7 @@ extern unsigned int ath5k_hw_get_def_antenna(struct ath5k_hw *ah);
 extern int ath5k_hw_phy_disable(struct ath5k_hw *ah);
 /* TX power setup */
 extern int ath5k_hw_txpower(struct ath5k_hw *ah, struct ieee80211_channel *channel, u8 ee_mode, u8 txpower);
-extern int ath5k_hw_set_txpower_limit(struct ath5k_hw *ah, u8 ee_mode, u8 txpower);
+extern int ath5k_hw_set_txpower_limit(struct ath5k_hw *ah, u8 txpower);
 
 /*
  * Functions used internaly
drivers/net/wireless/ath/ath5k/base.c +9 -1
index ff6d4f8..3390603 100644
@@ -2768,13 +2768,21 @@ static int
 ath5k_config(struct ieee80211_hw *hw, u32 changed)
 {
 	struct ath5k_softc *sc = hw->priv;
+	struct ath5k_hw *ah = sc->ah;
 	struct ieee80211_conf *conf = &hw->conf;
 	int ret;
 
 	mutex_lock(&sc->lock);
 
 	sc->bintval = conf->beacon_int;
-	sc->power_level = conf->power_level;
+
+	if ((changed & IEEE80211_CONF_CHANGE_POWER) &&
+	(sc->power_level != conf->power_level)) {
+		sc->power_level = conf->power_level;
+
+		/* Half dB steps */
+		ath5k_hw_set_txpower_limit(ah, (conf->power_level * 2));
+	}
 
 	ret = ath5k_chan_set(sc, conf->channel);
 
drivers/net/wireless/ath/ath5k/phy.c +37 -8

77 lines not on this page · raw message

drivers/net/wireless/ath/ath5k/reset.c +1 -1
index faede82..23d6fc8 100644
@@ -1001,7 +1001,7 @@ int ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode,
 		 * Set TX power (FIXME)
 		 */
 		ret = ath5k_hw_txpower(ah, channel, ee_mode,
-					AR5K_TUNE_DEFAULT_TXPOWER);
+					ah->ah_txpower.txp_max_pwr / 2);
 		if (ret)
 			return ret;
 
#1 lore raw
Quoted 1 line · Nick Kossifidis

* Now that we have regulatory control enable the driver to set txpower on hw

I assume this needs my patch for the CTLs (reproduced below). Any objections to it?

From: Bob Copeland <[email protected]>
Subject: [PATCH] ath5k: use ctl settings based on current regdomain

Update ath5k to use the ctl settings for tx power based on current regulatory domain.

---
 drivers/net/wireless/ath/ath5k/phy.c |   19 +++++++------------
 1 files changed, 7 insertions(+), 12 deletions(-)
drivers/net/wireless/ath/ath5k/phy.c +7 -12
index 9e2faae..0ecd16f 100644
@@ -1743,8 +1743,6 @@ done:
  * Get the max edge power for this channel if
  * we have such data from EEPROM's Conformance Test
  * Limits (CTL), and limit max power if needed.
- *
- * FIXME: Only works for world regulatory domains
  */
 static void
 ath5k_get_max_ctl_power(struct ath5k_hw *ah,
@@ -1760,26 +1758,23 @@ ath5k_get_max_ctl_power(struct ath5k_hw *ah,
 	u8 ctl_idx = 0xFF;
 	u32 target = channel->center_freq;
 
-	/* Find out a CTL for our mode that's not mapped
-	 * on a specific reg domain.
-	 *
-	 * TODO: Map our current reg domain to one of the 3 available
-	 * reg domain ids so that we can support more CTLs. */
+	ctl_mode = ath_regd_get_band_ctl(&ah->ah_regulatory, channel->band);
+
 	switch (channel->hw_value & CHANNEL_MODES) {
 	case CHANNEL_A:
-		ctl_mode = AR5K_CTL_11A | AR5K_CTL_NO_REGDOMAIN;
+		ctl_mode |= AR5K_CTL_11A;
 		break;
 	case CHANNEL_G:
-		ctl_mode = AR5K_CTL_11G | AR5K_CTL_NO_REGDOMAIN;
+		ctl_mode |= AR5K_CTL_11G;
 		break;
 	case CHANNEL_B:
-		ctl_mode = AR5K_CTL_11B | AR5K_CTL_NO_REGDOMAIN;
+		ctl_mode |= AR5K_CTL_11B;
 		break;
 	case CHANNEL_T:
-		ctl_mode = AR5K_CTL_TURBO | AR5K_CTL_NO_REGDOMAIN;
+		ctl_mode |= AR5K_CTL_TURBO;
 		break;
 	case CHANNEL_TG:
-		ctl_mode = AR5K_CTL_TURBOG | AR5K_CTL_NO_REGDOMAIN;
+		ctl_mode |= AR5K_CTL_TURBOG;
 		break;
 	case CHANNEL_XR:
 		/* Fall through */
Signature · 4 lines
1.6.0.6

-- 
Bob Copeland %% www.bobcopeland.com
maintainer Acked-by
#2 lore raw

2009/4/19 Bob Copeland <[email protected]>:

Quoted 2 lines · Nick Kossifidis
Quoted 1 line

=C2=A0* Now that we have regulatory control enable the driver to set=

txpower on hw

Quoted 2 lines

I assume this needs my patch for the CTLs (reproduced below). =C2=A0A=

ny

Quoted 11 lines

objections to it?

From: Bob Copeland <[email protected]>
Subject: [PATCH] ath5k: use ctl settings based on current regdomain

Update ath5k to use the ctl settings for tx power based on current regulatory domain.

---
=C2=A0drivers/net/wireless/ath/ath5k/phy.c | =C2=A0 19 +++++++-------=

-----

drivers/net/wirel=

Quoted 3 lines

=C2=A01 files changed, 7 insertions(+), 12 deletions(-)

drivers/net/wirel= renamed from drivers/net/wireless/ath/ath5k/phy.c +0 -0

ess/ath/ath5k/phy.c

Quoted 13 lines

index 9e2faae..0ecd16f 100644

drivers/net/wireless/ath/ath5k/phy.c +0 -0
@@ -1743,8 +1743,6 @@ done:

=C2=A0* Get the max edge power for this channel if =C2=A0* we have such data from EEPROM's Conformance Test =C2=A0* Limits (CTL), and limit max power if needed.
- *
- * FIXME: Only works for world regulatory domains =C2=A0*/
=C2=A0static void =C2=A0ath5k_get_max_ctl_power(struct ath5k_hw *ah,

drivers/net/wireless/ath/ath5k/phy.c ath5k_get_max_ctl_power(struct ath5k_hw *ah, · line 1763

Quoted 4 lines
drivers/net/wireless/ath/ath5k/phy.c +0 -1
@@ -1760,26 +1758,23 @@ ath5k_get_max_ctl_power(struct ath5k_hw *ah,
 =C2=A0 =C2=A0 =C2=A0 =C2=A0u8 ctl_idx =3D 0xFF;
 =C2=A0 =C2=A0 =C2=A0 =C2=A0u32 target =3D channel->center_freq;
 
- =C2=A0 =C2=A0 =C2=A0 /* Find out a CTL for our mode that's not mapp=

ed

drivers/net/wireless/ath/ath5k/phy.c ath5k_get_max_ctl_power(struct ath5k_hw *ah, · line 1766

Quoted 3 lines
drivers/net/wireless/ath/ath5k/phy.c +0 -3
- =C2=A0 =C2=A0 =C2=A0 =C2=A0* on a specific reg domain.
- =C2=A0 =C2=A0 =C2=A0 =C2=A0*
- =C2=A0 =C2=A0 =C2=A0 =C2=A0* TODO: Map our current reg domain to on=

e of the 3 available

drivers/net/wireless/ath/ath5k/phy.c ath5k_get_max_ctl_power(struct ath5k_hw *ah, · line 1767

Quoted 1 line
drivers/net/wireless/ath/ath5k/phy.c +0 -1
- =C2=A0 =C2=A0 =C2=A0 =C2=A0* reg domain ids so that we can support =

more CTLs. */

drivers/net/wireless/ath/ath5k/phy.c ath5k_get_max_ctl_power(struct ath5k_hw *ah, · line 1761

Quoted 1 line
drivers/net/wireless/ath/ath5k/phy.c +1 -0
+ =C2=A0 =C2=A0 =C2=A0 ctl_mode =3D ath_regd_get_band_ctl(&ah->ah_reg=

ulatory, channel->band);

Quoted 2 lines
drivers/net/wireless/ath/ath5k/phy.c +1 -0
+

=C2=A0 =C2=A0 =C2=A0 =C2=A0switch (channel->hw_value & CHANNEL_MODES)=

{

Quoted 2 lines

=C2=A0 =C2=A0 =C2=A0 =C2=A0case CHANNEL_A:
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ctl_mode =3D AR5K_=

CTL_11A | AR5K_CTL_NO_REGDOMAIN;

Quoted 1 line

+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ctl_mode |=3D AR5K=

_CTL_11A;

Quoted 3 lines

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0break; =C2=A0 =C2=A0 =C2=A0 =C2=A0case CHANNEL_G:
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ctl_mode =3D AR5K_=

CTL_11G | AR5K_CTL_NO_REGDOMAIN;

Quoted 1 line

+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ctl_mode |=3D AR5K=

_CTL_11G;

Quoted 3 lines

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0break; =C2=A0 =C2=A0 =C2=A0 =C2=A0case CHANNEL_B:
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ctl_mode =3D AR5K_=

CTL_11B | AR5K_CTL_NO_REGDOMAIN;

Quoted 1 line

+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ctl_mode |=3D AR5K=

_CTL_11B;

Quoted 3 lines

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0break; =C2=A0 =C2=A0 =C2=A0 =C2=A0case CHANNEL_T:
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ctl_mode =3D AR5K_=

CTL_TURBO | AR5K_CTL_NO_REGDOMAIN;

Quoted 1 line

+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ctl_mode |=3D AR5K=

_CTL_TURBO;

Quoted 3 lines

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0break; =C2=A0 =C2=A0 =C2=A0 =C2=A0case CHANNEL_TG:
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ctl_mode =3D AR5K_=

CTL_TURBOG | AR5K_CTL_NO_REGDOMAIN;

Quoted 1 line

+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ctl_mode |=3D AR5K=

_CTL_TURBOG;

Quoted 3 lines

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0break; =C2=A0 =C2=A0 =C2=A0 =C2=A0case CHANNEL_XR:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0/* Fall throug=

h */

--=20
GPG ID: 0xD21DB2DB
As you read this post global entropy rises. Have Fun ;-) Nick
--
To unsubscribe from this list: send the line "unsubscribe linux-wireles= s" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
In reply to Nick Kossifidis
Quoted 2 lines · Nick Kossifidis

* Now that we have regulatory control enable the driver to set txpower on hw
* Also use txpower table offset so that we can match power range set by user/driver with indices on power table.

BTW I gave this patchset a spin on my rf 5413 and it works fine here, so feel free to add my Acked-By on the series. Does it need anything besides a reposting with 72-col changelogs?

Signature · 1 line
Bob Copeland %% www.bobcopeland.com
#4 lore raw
Quoted 7 lines · Bob Copeland
Quoted 2 lines · Nick Kossifidis

* Now that we have regulatory control enable the driver to set txpower on hw
* Also use txpower table offset so that we can match power range set by user/driver with indices on power table.

BTW I gave this patchset a spin on my rf 5413 and it works fine here, so feel free to add my Acked-By on the series. Does it need anything besides a reposting with 72-col changelogs?

The series seems fine, but I was waiting for a repost with the narrower changelogs...?

John

Signature · 2 lines
John W. Linville		Someday the world will need a hero, and you
[email protected]			might be all we have.  Be ready.
maintainer
#5 lore raw

2009/4/28 John W. Linville <[email protected]>:

Quoted 3 lines · Bob Copeland
Quoted 2 lines · Nick Kossifidis
Quoted 1 line

=C2=A0* Now that we have regulatory control enable the driver to s=

et txpower on hw

Quoted 1 line
Quoted 1 line
Quoted 1 line

=C2=A0* Also use txpower table offset so that we can match power r=

ange set by user/driver with indices on power table.

Quoted 2 lines
Quoted 2 lines

BTW I gave this patchset a spin on my rf 5413 and it works fine here=

,

Quoted 1 line
Quoted 1 line

so feel free to add my Acked-By on the series. =C2=A0Does it need an=

ything

Quoted 6 lines
Quoted 1 line

besides a reposting with 72-col changelogs?

The series seems fine, but I was waiting for a repost with the narrower changelogs...?

John

Is this really needed ? I'm full right now ;-(
Can anyone else resend this plz ?

--=20
GPG ID: 0xD21DB2DB
As you read this post global entropy rises. Have Fun ;-) Nick
--
To unsubscribe from this list: send the line "unsubscribe linux-wireles= s" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#6 lore raw

On Wed, 29 Apr 2009 19:48:35 +0300, Nick Kossifidis wrote

Quoted 7 lines
Quoted 4 lines

The series seems fine, but I was waiting for a repost with the narrower changelogs...?

John

Is this really needed ? I'm full right now ;-(
Can anyone else resend this plz ?

No worries, I'll fix and resend them.

Signature · 1 line
Bob Copeland %% www.bobcopeland.com