From patchwork Fri Feb 6 14:39:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 5792081 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 8390BBF440 for ; Fri, 6 Feb 2015 14:39:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A117E20166 for ; Fri, 6 Feb 2015 14:39:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B80112015E for ; Fri, 6 Feb 2015 14:39:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754337AbbBFOjw (ORCPT ); Fri, 6 Feb 2015 09:39:52 -0500 Received: from mail-we0-f176.google.com ([74.125.82.176]:53794 "EHLO mail-we0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752535AbbBFOju (ORCPT ); Fri, 6 Feb 2015 09:39:50 -0500 Received: by mail-we0-f176.google.com with SMTP id p10so2545277wes.7 for ; Fri, 06 Feb 2015 06:39:49 -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=PYdCBFCUo/GofW1tV6D0Uuft/MvwObPCz4r1Zo2HXm8=; b=jU84nLF2SDP5DyRsSZ9Co7UkTgSV2hCCl5lotca/CeX+uKXaiTU1/Ug/eRqZVCDAEa gsROvVazRam2HPxnLno3h92kOTykZ39hCYYQSu2/tGl9ia/KOHot69Ljk5Hp81JBsH9K T5m5qyIyWHGqSTngZNS5pupDjtM4fyibHMovKIa88/E9qA/kB3bENdmHDiFaQ6gaNagd lmGR1+WaaKvniN3ZVheSQll3NX+tjS/7OquYxIaTyOrfXCwanVpMwI/GDAX9mcGWDwP0 o29tLGHnjKtXCMGeHa321/J3I6+bWFdpOT7He8HAT8DkGFbtzSolVO5TMsqZm1LsCxlo rWJQ== X-Received: by 10.195.17.137 with SMTP id ge9mr8573866wjd.44.1423233589036; Fri, 06 Feb 2015 06:39:49 -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 x10sm1745966wif.15.2015.02.06.06.39.48 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 06 Feb 2015 06:39:48 -0800 (PST) From: Lorenzo Bianconi To: linux-wireless@vger.kernel.org Cc: nbd@openwrt.org, thomas@net.t-labs.tu-berlin.de Subject: [RFC 2/2] ath9k: add per-vif TX power capability to TX path Date: Fri, 6 Feb 2015 15:39:46 +0100 Message-Id: <1423233586-9258-3-git-send-email-lorenzo.bianconi83@gmail.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1423233586-9258-1-git-send-email-lorenzo.bianconi83@gmail.com> References: <1423233586-9258-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 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,