From patchwork Tue Feb 17 09:12:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 5838091 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7AD59BF440 for ; Tue, 17 Feb 2015 09:12:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A5F4D200E8 for ; Tue, 17 Feb 2015 09:12:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 86FFF20145 for ; Tue, 17 Feb 2015 09:12:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933306AbbBQJM0 (ORCPT ); Tue, 17 Feb 2015 04:12:26 -0500 Received: from mail-wg0-f54.google.com ([74.125.82.54]:43932 "EHLO mail-wg0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754990AbbBQJMY (ORCPT ); Tue, 17 Feb 2015 04:12:24 -0500 Received: by mail-wg0-f54.google.com with SMTP id y19so33771067wgg.13 for ; Tue, 17 Feb 2015 01:12:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4GAJ9whROcZKecx82pKWMGrWvRHHVDTd1U+a+58WRsw=; b=iu0OXCS2Esz/XnhqcEJ3Cserg8v0s8CDmsN7VoDWNdsaw4ofxeNWhYvz5R9YxYkikK cO20hNXeKlOUhQ1cIrTiKvR9FdBfT7j4aQid9tOWQQi7f9QXRllaJZxZ8RI+b91lkjbk ZL8TKgK6/Hzd01ofzCwZqSzjjXMrJk/rRdT1WQKQEez0IKhH1bRDepeJBbuw9gxsKLOo Irul5zc/P1ah0BiTSTxv0AHU1WyqP+1ROj9HHOXwzzFm0xo00ewVkeEnk6qZzAve8oYW vK/IcYOeXkakHJWVqqyxiHtuSgJDA/DmGXyjVk9iUy/Z3jIm3y45HvLUgMxcMQtLiRql jIVA== X-Received: by 10.180.211.45 with SMTP id mz13mr45397098wic.20.1424164343189; Tue, 17 Feb 2015 01:12:23 -0800 (PST) Received: from kxps.ediliziamodernaterza.it (93-51-177-218.ip268.fastwebnet.it. [93.51.177.218]) by mx.google.com with ESMTPSA id kj8sm26414446wjc.29.2015.02.17.01.12.21 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 17 Feb 2015 01:12:22 -0800 (PST) From: Lorenzo Bianconi To: linux-wireless@vger.kernel.org Cc: nbd@openwrt.org, thomas@net.t-labs.tu-berlin.de Subject: [PATCH 2/2] ath9k: add per-vif TX power capability to TX path Date: Tue, 17 Feb 2015 10:12:18 +0100 Message-Id: <1424164338-10547-3-git-send-email-lorenzo.bianconi83@gmail.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1424164338-10547-1-git-send-email-lorenzo.bianconi83@gmail.com> References: <1424164338-10547-1-git-send-email-lorenzo.bianconi83@gmail.com> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In order to add per-vif TX power capability cap per-packet TX power to vif configured power if the latter is lower than per-rate TX power and mac80211 per-frame power. Use vif TX power if TPC has been disabled for current the interface Signed-off-by: Lorenzo Bianconi --- drivers/net/wireless/ath/ath9k/xmit.c | 42 +++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c index 1b8e75c..0acd079 100644 --- a/drivers/net/wireless/ath/ath9k/xmit.c +++ b/drivers/net/wireless/ath/ath9k/xmit.c @@ -1103,14 +1103,28 @@ 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; - fi = get_frame_info(skb); 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); if (!AR_SREV_9300_20_OR_LATER(ah)) { int txpower = fi->tx_power; @@ -1147,25 +1161,25 @@ 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], 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; + max_power = min_t(u8, ah->tx_power[rateidx], + 2 * vif->bss_conf.txpower); + max_power = min_t(u8, max_power, txpower); } else if (!bf->bf_state.bfs_paprd) { if (rateidx < 8 && (info->flags & IEEE80211_TX_CTL_STBC)) - max_power = min(ah->tx_power_stbc[rateidx], - fi->tx_power); + max_power = min_t(u8, ah->tx_power_stbc[rateidx], + 2 * vif->bss_conf.txpower); else - max_power = min(ah->tx_power[rateidx], fi->tx_power); + max_power = min_t(u8, ah->tx_power[rateidx], + 2 * vif->bss_conf.txpower); + max_power = min(max_power, fi->tx_power); } else { max_power = ah->paprd_training_power; } - - return max_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; } static void ath_buf_set_rate(struct ath_softc *sc, struct ath_buf *bf,