ath9k: interpret requested txpower in EIRP domain
authorZefir Kurtisi <zefir.kurtisi@neratec.com>
Fri, 1 Apr 2016 09:37:08 +0000 (11:37 +0200)
committerKalle Valo <kvalo@qca.qualcomm.com>
Tue, 19 Apr 2016 15:10:47 +0000 (18:10 +0300)
Tx power limitations at upper layers are interpreted in
the EIRP domain. When the user requests a given maximum
txpower, e.g. with: 'iw phy0 set txpower fixed 1500',
he expects the EIRP to be at or below 15dBm.

In ath9k_hw_apply_txpower(), the interpretation is
different: the antenna-gain is capped against the
current txpower limit in the regulatory, but not
against the user set value. It ensures that the
resulting EIRP is below the limit defined by the
active countrycode, but not below the value the
user requested.

In a scenario like e.g.
 a) antenna_gain=6
 b) countrycode limits to eirp=18
 c) user set txpower=15
this will cause a setting for AR_PHY_POWER_TX_RATE
regs resulting in an EIRP > 15.

This patch ensures that antenna-gain is considered
whenever the txpower limit is adjusted and with that
the user set limits are kept.

Signed-off-by: Zefir Kurtisi <zefir.kurtisi@neratec.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
drivers/net/wireless/ath/ath9k/hw.c

index 4200906..8b2895f 100644 (file)
@@ -2914,8 +2914,7 @@ void ath9k_hw_apply_txpower(struct ath_hw *ah, struct ath9k_channel *chan,
 {
        struct ath_regulatory *reg = ath9k_hw_regulatory(ah);
        struct ieee80211_channel *channel;
-       int chan_pwr, new_pwr, max_gain;
-       int ant_gain, ant_reduction = 0;
+       int chan_pwr, new_pwr;
 
        if (!chan)
                return;
@@ -2923,15 +2922,10 @@ void ath9k_hw_apply_txpower(struct ath_hw *ah, struct ath9k_channel *chan,
        channel = chan->chan;
        chan_pwr = min_t(int, channel->max_power * 2, MAX_RATE_POWER);
        new_pwr = min_t(int, chan_pwr, reg->power_limit);
-       max_gain = chan_pwr - new_pwr + channel->max_antenna_gain * 2;
-
-       ant_gain = get_antenna_gain(ah, chan);
-       if (ant_gain > max_gain)
-               ant_reduction = ant_gain - max_gain;
 
        ah->eep_ops->set_txpower(ah, chan,
                                 ath9k_regd_get_ctl(reg, chan),
-                                ant_reduction, new_pwr, test);
+                                get_antenna_gain(ah, chan), new_pwr, test);
 }
 
 void ath9k_hw_set_txpowerlimit(struct ath_hw *ah, u32 limit, bool test)