From patchwork Wed Feb 8 11:58:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ashok Raj Nagarajan X-Patchwork-Id: 9562407 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 36A4760574 for ; Wed, 8 Feb 2017 12:04:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 28F6A2845E for ; Wed, 8 Feb 2017 12:04:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1DEDA284D1; Wed, 8 Feb 2017 12:04:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B5CC828479 for ; Wed, 8 Feb 2017 12:04:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754173AbdBHMEU (ORCPT ); Wed, 8 Feb 2017 07:04:20 -0500 Received: from wolverine02.qualcomm.com ([199.106.114.251]:11030 "EHLO wolverine02.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752848AbdBHMES (ORCPT ); Wed, 8 Feb 2017 07:04:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=qti.qualcomm.com; i=@qti.qualcomm.com; q=dns/txt; s=qcdkim; t=1486555458; x=1518091458; h=from:to:cc:subject:date:message-id:mime-version; bh=Be3imIebsHWE1zTzMLPyRX/7DMk3mFb2qwb35eVzzGc=; b=mBhLFgz0JIKgeBk2aUWhO63eK53eRtJ6PXVvMdMt4gkPgEcLqAksuMEv 3KUSG2QuoSIY9i9dS2yYd5L6zfHvy5ijD5oxcWsR9N3uO9lZP4icBnsr7 apvx9J5K+e7LapED9/scxkS7CiVhFFJw6nyE4cFDFngCCb4uD+xBnePp8 s=; X-IronPort-AV: E=Sophos;i="5.33,346,1477983600"; d="scan'208";a="356569405" Received: from unknown (HELO Ironmsg04-R.qualcomm.com) ([10.53.140.108]) by wolverine02.qualcomm.com with ESMTP; 08 Feb 2017 04:03:52 -0800 X-IronPort-AV: E=McAfee;i="5800,7501,8432"; a="1359604857" Received: from nasanexm02f.na.qualcomm.com ([10.85.0.87]) by Ironmsg04-R.qualcomm.com with ESMTP/TLS/RC4-SHA; 08 Feb 2017 04:03:52 -0800 Received: from aphydexm01f.ap.qualcomm.com (10.252.127.15) by nasanexm02f.na.qualcomm.com (10.85.0.87) with Microsoft SMTP Server (TLS) id 15.0.1178.4; Wed, 8 Feb 2017 04:03:51 -0800 Received: from qcmail1.qualcomm.com (10.80.80.8) by aphydexm01f.ap.qualcomm.com (10.252.127.15) with Microsoft SMTP Server (TLS) id 15.0.1178.4; Wed, 8 Feb 2017 17:33:42 +0530 Received: by qcmail1.qualcomm.com (sSMTP sendmail emulation); Wed, 08 Feb 2017 17:28:39 +0530 From: Ashok Raj Nagarajan To: CC: , , "Ashok Raj Nagarajan" Subject: [PATCH v3] ath10k: add support for controlling tx power to a station Date: Wed, 8 Feb 2017 17:28:37 +0530 Message-ID: <1486555117-25196-1-git-send-email-arnagara@qti.qualcomm.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: NASANEXM01B.na.qualcomm.com (10.85.0.82) To aphydexm01f.ap.qualcomm.com (10.252.127.15) Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch will add the support to control the transmit power for traffic to a station associated with the AP. Userspace provide the transmit power value in mBm units. ath10k firmware expects the value to be in dBm and hence will convert the value from to dBm before passing down to firmware. Underlying FW will enforce that the maximum tx power will be based on the regulatory requirements. If the user given transmit power is greater than the allowed tx power in the given channel, then the FW will use the maximum tx power in the same channel. When 0 is sent to the FW as tx power, it will revert to the automatic tx power for the station. Signed-off-by: Ashok Raj Nagarajan --- v3: - reword commit log - remove range check for the input from user. (Ben Greear) drivers/net/wireless/ath/ath10k/mac.c | 31 +++++++++++++++++++++++++++++++ drivers/net/wireless/ath/ath10k/wmi.h | 1 + 2 files changed, 32 insertions(+) diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c index 9977829..3b91468 100644 --- a/drivers/net/wireless/ath/ath10k/mac.c +++ b/drivers/net/wireless/ath/ath10k/mac.c @@ -5985,6 +5985,32 @@ static int ath10k_mac_tdls_vifs_count(struct ieee80211_hw *hw) return num_tdls_vifs; } +static int ath10k_sta_set_txpwr(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + struct ieee80211_sta *sta) +{ + struct ath10k *ar = hw->priv; + struct ath10k_vif *arvif = ath10k_vif_to_arvif(vif); + int ret = 0; + u16 txpwr; + + txpwr = MBM_TO_DBM(sta->txpwr); + + mutex_lock(&ar->conf_mutex); + + ret = ath10k_wmi_peer_set_param(ar, arvif->vdev_id, sta->addr, + WMI_PEER_USE_FIXED_PWR, txpwr); + if (ret) { + ath10k_warn(ar, "failed to set tx power for station ret: %d\n", + ret); + goto out; + } + +out: + mutex_unlock(&ar->conf_mutex); + return ret; +} + static int ath10k_sta_state(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_sta *sta, @@ -7550,6 +7576,7 @@ static void ath10k_mac_op_sta_pre_rcu_remove(struct ieee80211_hw *hw, .set_key = ath10k_set_key, .set_default_unicast_key = ath10k_set_default_unicast_key, .sta_state = ath10k_sta_state, + .sta_set_txpwr = ath10k_sta_set_txpwr, .conf_tx = ath10k_conf_tx, .remain_on_channel = ath10k_remain_on_channel, .cancel_remain_on_channel = ath10k_cancel_remain_on_channel, @@ -8193,11 +8220,15 @@ int ath10k_mac_register(struct ath10k *ar) ar->hw->wiphy->iface_combinations = ath10k_10x_if_comb; ar->hw->wiphy->n_iface_combinations = ARRAY_SIZE(ath10k_10x_if_comb); + wiphy_ext_feature_set(ar->hw->wiphy, + NL80211_EXT_FEATURE_STA_TX_PWR); break; case ATH10K_FW_WMI_OP_VERSION_10_4: ar->hw->wiphy->iface_combinations = ath10k_10_4_if_comb; ar->hw->wiphy->n_iface_combinations = ARRAY_SIZE(ath10k_10_4_if_comb); + wiphy_ext_feature_set(ar->hw->wiphy, + NL80211_EXT_FEATURE_STA_TX_PWR); break; case ATH10K_FW_WMI_OP_VERSION_UNSET: case ATH10K_FW_WMI_OP_VERSION_MAX: diff --git a/drivers/net/wireless/ath/ath10k/wmi.h b/drivers/net/wireless/ath/ath10k/wmi.h index 861c2d8..1ccb6bf 100644 --- a/drivers/net/wireless/ath/ath10k/wmi.h +++ b/drivers/net/wireless/ath/ath10k/wmi.h @@ -5811,6 +5811,7 @@ enum wmi_peer_param { WMI_PEER_CHAN_WIDTH = 0x4, WMI_PEER_NSS = 0x5, WMI_PEER_USE_4ADDR = 0x6, + WMI_PEER_USE_FIXED_PWR = 0x8, WMI_PEER_DUMMY_VAR = 0xff, /* dummy parameter for STA PS workaround */ };