From patchwork Thu Oct 31 10:08:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maharaja Kennadyrajan X-Patchwork-Id: 11220849 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A54631668 for ; Thu, 31 Oct 2019 10:07:36 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7FF6120862 for ; Thu, 31 Oct 2019 10:07:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="oF9L4MT7"; dkim=fail reason="key not found in DNS" (0-bit key) header.d=codeaurora.org header.i=@codeaurora.org header.b="RLsAv7Jd"; dkim=fail reason="key not found in DNS" (0-bit key) header.d=codeaurora.org header.i=@codeaurora.org header.b="eV1unOPU" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7FF6120862 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=ath11k-bounces+patchwork-ath11k=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=+40OEQCV03tOQw1g85sb7MsyaZ5eTtLjUuN2TR5gm30=; b=oF9 L4MT7cOJHsU847yqQ/xpwXV1YpYLew6nSGxtWTmmnrnVj159YVs9klIdU1HVZ4TlLzAiJ0cXzsJ2c UbkExHhhnw3Q7mgaqhapmLOQm0EmKkF1TLdStcISNJBNlqqF6GPlm5ZI2GTyxITAKtfeygDoAnF7o wwbwsJzi3nukNOVkeCvMSB/VJ+kXJwgsZ77lJ0M5k3zZcYoIqlTtjMq7YZp9GAalyLGFdnVpxzRfV WhQE5FStsRdXAVPqCgvXCCafk8xqUtbKqlAp5lyeDa1jBXH+SBQH2p7v/GE5Kd+DA7R3S/IyKELle SVZi+bQh5Dd9Snm+CmgepRWBV3GC55A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iQ7Mb-0003BM-L7; Thu, 31 Oct 2019 10:07:33 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iQ7MY-0003AB-81 for ath11k@lists.infradead.org; Thu, 31 Oct 2019 10:07:31 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 8898860AD0; Thu, 31 Oct 2019 10:07:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1572516449; bh=5KIc8A2UZKGwQY2b7VIp+LKlDdS/Q0zHXnmVg2XRFX0=; h=From:To:Cc:Subject:Date:From; b=RLsAv7Jdt3ytFKOjyF0a5wIZ4/PE5xw7vOtnHpWgVazctrtwH+bP2OjC72S845fu7 47A651oVJg/+CoH4v2e3XhMHBgHXKGoTOIieMeb2kHIXKRo1Pz/UxrCfxHIVgo/6BN pQvn1Tq8cXnW3Ft9sHbINewiL2PLTxtZ0NDBApKg= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_INVALID,DKIM_SIGNED,SPF_NONE autolearn=no autolearn_force=no version=3.4.0 Received: from che-swdbs-01.qca.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: mkenna@codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id D4C7D60A74; Thu, 31 Oct 2019 10:07:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1572516447; bh=5KIc8A2UZKGwQY2b7VIp+LKlDdS/Q0zHXnmVg2XRFX0=; h=From:To:Cc:Subject:Date:From; b=eV1unOPUrigWsfuybRKQlr1Vq8nC0t3EBu9b6+gBCUPy0J621TG3r56txZ8IsooX9 Fjdeju4K6RF7wooIVbuIjjh0NYs+6OBWn6Fr/0bQIgnL+iPJm0rFb0Vn8pYNC12jY7 ZzPLGRinftgx9/nlttECv8ZrOi9WlyVQofpQ9j+k= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org D4C7D60A74 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=mkenna@codeaurora.org From: Maharaja Kennadyrajan To: ath11k@lists.infradead.org Subject: [PATCH] ath11k: add support for controlling tx power to a station Date: Thu, 31 Oct 2019 15:38:11 +0530 Message-Id: <1572516491-18745-1-git-send-email-mkenna@codeaurora.org> X-Mailer: git-send-email 1.7.9.5 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191031_030730_329301_5F6E7A00 X-CRM114-Status: GOOD ( 15.57 ) X-Spam-Score: -2.5 (--) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-2.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [198.145.29.96 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: ath11k@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maharaja Kennadyrajan MIME-Version: 1.0 Sender: "ath11k" Errors-To: ath11k-bounces+patchwork-ath11k=patchwork.kernel.org@lists.infradead.org This patch will add the support to control the transmit power for traffic to a station associated with the AP. Underlying firmware 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 firmware will use the maximum tx power in the same channel. Max and Min tx power values will depends on number of tx chain masks. The allowed tx power range values are from 6 to 23. When 0 is sent to the firmware as tx power, it will revert to the default tx power for the station. Note: mac80211/cfg80211 patches are merged in master branch in ath.git. Patchwork links for mac80211/cfg80211 patches are given below. https://patchwork.kernel.org/patch/10876853/ https://patchwork.kernel.org/patch/10876859/ Signed-off-by: Maharaja Kennadyrajan --- drivers/net/wireless/ath/ath11k/debug.h | 3 ++ drivers/net/wireless/ath/ath11k/mac.c | 37 +++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/drivers/net/wireless/ath/ath11k/debug.h b/drivers/net/wireless/ath/ath11k/debug.h index aef33f83c9b1..a317a7bdb9a2 100644 --- a/drivers/net/wireless/ath/ath11k/debug.h +++ b/drivers/net/wireless/ath/ath11k/debug.h @@ -9,6 +9,9 @@ #include "hal_tx.h" #include "trace.h" +#define ATH11K_TX_POWER_MAX_VAL 70 +#define ATH11K_TX_POWER_MIN_VAL 0 + enum ath11k_debug_mask { ATH11K_DBG_AHB = 0x00000001, ATH11K_DBG_WMI = 0x00000002, diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c index 6f82fdbbd358..2dc5f63b9446 100644 --- a/drivers/net/wireless/ath/ath11k/mac.c +++ b/drivers/net/wireless/ath/ath11k/mac.c @@ -2842,6 +2842,41 @@ static int ath11k_mac_op_sta_state(struct ieee80211_hw *hw, return ret; } +static int ath11k_mac_op_sta_set_txpwr(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + struct ieee80211_sta *sta) +{ + struct ath11k *ar = hw->priv; + struct ath11k_vif *arvif = (void *)vif->drv_priv; + int ret = 0; + s16 txpwr; + + if (sta->txpwr.type == NL80211_TX_POWER_AUTOMATIC) { + txpwr = 0; + } else { + txpwr = sta->txpwr.power; + if (!txpwr) + return -EINVAL; + } + + if (txpwr > ATH11K_TX_POWER_MAX_VAL || txpwr < ATH11K_TX_POWER_MIN_VAL) + return -EINVAL; + + mutex_lock(&ar->conf_mutex); + + ret = ath11k_wmi_set_peer_param(ar, sta->addr, arvif->vdev_id, + WMI_PEER_USE_FIXED_PWR, txpwr); + if (ret) { + ath11k_warn(ar->ab, "failed to set tx power for station ret: %d\n", + ret); + goto out; + } + +out: + mutex_unlock(&ar->conf_mutex); + return ret; +} + static void ath11k_mac_op_sta_rc_update(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_sta *sta, @@ -5316,6 +5351,7 @@ static const struct ieee80211_ops ath11k_ops = { .cancel_hw_scan = ath11k_mac_op_cancel_hw_scan, .set_key = ath11k_mac_op_set_key, .sta_state = ath11k_mac_op_sta_state, + .sta_set_txpwr = ath11k_mac_op_sta_set_txpwr, .sta_rc_update = ath11k_mac_op_sta_rc_update, .conf_tx = ath11k_mac_op_conf_tx, .set_antenna = ath11k_mac_op_set_antenna, @@ -5576,6 +5612,7 @@ static int ath11k_mac_register(struct ath11k *ar) ar->hw->wiphy->n_iface_combinations = ARRAY_SIZE(ath11k_if_comb); wiphy_ext_feature_set(ar->hw->wiphy, NL80211_EXT_FEATURE_CQM_RSSI_LIST); + wiphy_ext_feature_set(ar->hw->wiphy, NL80211_EXT_FEATURE_STA_TX_PWR); ar->hw->wiphy->cipher_suites = cipher_suites; ar->hw->wiphy->n_cipher_suites = ARRAY_SIZE(cipher_suites);