Commit 283dd119 authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Kalle Valo

ath9k: add per-vif TX power capability

Configure the HW with highest TX power among all vif when HW TPC has been
enabled in order to add support to per-vif TX power capability. Use lowest
configured power among all interfaces when TPC is disabled
Signed-off-by: default avatarLorenzo Bianconi <lorenzo.bianconi83@gmail.com>
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
parent be1f8d31
...@@ -645,6 +645,7 @@ void ath9k_calculate_iter_data(struct ath_softc *sc, ...@@ -645,6 +645,7 @@ void ath9k_calculate_iter_data(struct ath_softc *sc,
struct ath9k_vif_iter_data *iter_data); struct ath9k_vif_iter_data *iter_data);
void ath9k_calculate_summary_state(struct ath_softc *sc, void ath9k_calculate_summary_state(struct ath_softc *sc,
struct ath_chanctx *ctx); struct ath_chanctx *ctx);
void ath9k_set_txpower(struct ath_softc *sc, struct ieee80211_vif *vif);
/*******************/ /*******************/
/* Beacon Handling */ /* Beacon Handling */
......
...@@ -1156,7 +1156,10 @@ static ssize_t write_file_tpc(struct file *file, const char __user *user_buf, ...@@ -1156,7 +1156,10 @@ static ssize_t write_file_tpc(struct file *file, const char __user *user_buf,
if (tpc_enabled != ah->tpc_enabled) { if (tpc_enabled != ah->tpc_enabled) {
ah->tpc_enabled = tpc_enabled; ah->tpc_enabled = tpc_enabled;
ath9k_hw_set_txpowerlimit(ah, sc->cur_chan->txpower, false);
mutex_lock(&sc->mutex);
ath9k_set_txpower(sc, NULL);
mutex_unlock(&sc->mutex);
} }
return count; return count;
......
...@@ -1172,6 +1172,38 @@ void ath9k_calculate_summary_state(struct ath_softc *sc, ...@@ -1172,6 +1172,38 @@ void ath9k_calculate_summary_state(struct ath_softc *sc,
ath9k_ps_restore(sc); ath9k_ps_restore(sc);
} }
static void ath9k_tpc_vif_iter(void *data, u8 *mac, struct ieee80211_vif *vif)
{
int *power = (int *)data;
if (*power < vif->bss_conf.txpower)
*power = vif->bss_conf.txpower;
}
/* Called with sc->mutex held. */
void ath9k_set_txpower(struct ath_softc *sc, struct ieee80211_vif *vif)
{
int power;
struct ath_hw *ah = sc->sc_ah;
struct ath_regulatory *reg = ath9k_hw_regulatory(ah);
ath9k_ps_wakeup(sc);
if (ah->tpc_enabled) {
power = (vif) ? vif->bss_conf.txpower : -1;
ieee80211_iterate_active_interfaces_atomic(
sc->hw, IEEE80211_IFACE_ITER_RESUME_ALL,
ath9k_tpc_vif_iter, &power);
if (power == -1)
power = sc->hw->conf.power_level;
} else {
power = sc->hw->conf.power_level;
}
sc->cur_chan->txpower = 2 * power;
ath9k_hw_set_txpowerlimit(ah, sc->cur_chan->txpower, false);
sc->cur_chan->cur_txpower = reg->max_power_level;
ath9k_ps_restore(sc);
}
static void ath9k_assign_hw_queues(struct ieee80211_hw *hw, static void ath9k_assign_hw_queues(struct ieee80211_hw *hw,
struct ieee80211_vif *vif) struct ieee80211_vif *vif)
{ {
...@@ -1225,6 +1257,8 @@ static int ath9k_add_interface(struct ieee80211_hw *hw, ...@@ -1225,6 +1257,8 @@ static int ath9k_add_interface(struct ieee80211_hw *hw,
ath9k_assign_hw_queues(hw, vif); ath9k_assign_hw_queues(hw, vif);
ath9k_set_txpower(sc, vif);
an->sc = sc; an->sc = sc;
an->sta = NULL; an->sta = NULL;
an->vif = vif; an->vif = vif;
...@@ -1265,6 +1299,8 @@ static int ath9k_change_interface(struct ieee80211_hw *hw, ...@@ -1265,6 +1299,8 @@ static int ath9k_change_interface(struct ieee80211_hw *hw,
ath9k_assign_hw_queues(hw, vif); ath9k_assign_hw_queues(hw, vif);
ath9k_calculate_summary_state(sc, avp->chanctx); ath9k_calculate_summary_state(sc, avp->chanctx);
ath9k_set_txpower(sc, vif);
mutex_unlock(&sc->mutex); mutex_unlock(&sc->mutex);
return 0; return 0;
} }
...@@ -1294,6 +1330,8 @@ static void ath9k_remove_interface(struct ieee80211_hw *hw, ...@@ -1294,6 +1330,8 @@ static void ath9k_remove_interface(struct ieee80211_hw *hw,
ath9k_calculate_summary_state(sc, avp->chanctx); ath9k_calculate_summary_state(sc, avp->chanctx);
ath9k_set_txpower(sc, NULL);
mutex_unlock(&sc->mutex); mutex_unlock(&sc->mutex);
} }
...@@ -1397,14 +1435,6 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed) ...@@ -1397,14 +1435,6 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed)
ath_chanctx_set_channel(sc, ctx, &hw->conf.chandef); ath_chanctx_set_channel(sc, ctx, &hw->conf.chandef);
} }
if (changed & IEEE80211_CONF_CHANGE_POWER) {
ath_dbg(common, CONFIG, "Set power: %d\n", conf->power_level);
sc->cur_chan->txpower = 2 * conf->power_level;
ath9k_cmn_update_txpow(ah, sc->cur_chan->cur_txpower,
sc->cur_chan->txpower,
&sc->cur_chan->cur_txpower);
}
mutex_unlock(&sc->mutex); mutex_unlock(&sc->mutex);
ath9k_ps_restore(sc); ath9k_ps_restore(sc);
...@@ -1764,6 +1794,12 @@ static void ath9k_bss_info_changed(struct ieee80211_hw *hw, ...@@ -1764,6 +1794,12 @@ static void ath9k_bss_info_changed(struct ieee80211_hw *hw,
if (changed & CHECK_ANI) if (changed & CHECK_ANI)
ath_check_ani(sc); ath_check_ani(sc);
if (changed & BSS_CHANGED_TXPOWER) {
ath_dbg(common, CONFIG, "vif %pM power %d dbm power_type %d\n",
vif->addr, bss_conf->txpower, bss_conf->txpower_type);
ath9k_set_txpower(sc, vif);
}
mutex_unlock(&sc->mutex); mutex_unlock(&sc->mutex);
ath9k_ps_restore(sc); ath9k_ps_restore(sc);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment