From patchwork Thu Jan 17 11:29:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Balaji Pothunoori X-Patchwork-Id: 10767935 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E1F3C13A4 for ; Thu, 17 Jan 2019 11:30:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF1E12EDAB for ; Thu, 17 Jan 2019 11:30:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C35002EDE2; Thu, 17 Jan 2019 11:30:10 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 45AE32EDAB for ; Thu, 17 Jan 2019 11:30:10 +0000 (UTC) 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=aImG8TgkPvOFg/anVntuBKwcL73j3sHLjyrZYN7NFxA=; b=bVt qt7BiuWZqh9dRMHcJZhxSmnnY1OS0rbCl8AN/z9J7+swaTwTqoSghP9vzSTfzxAQrSn7Eaouk0A1j GBC2F2wRuqlEw22/qJDWGJYjg1CZEph6EkRFchiVPcpyZKUeLAVY6ilZzjvm4/vgBpJ6GrUPU6ket CPpap+9wh4EITeSVkF1dEzUYEs1gZfaTz/8CMQy82MtixMw23dwB6TT/Ra4ktMUnqVIuAi9RWoUCP sDWXvTBxYyj5+/WMPieUrgQLX+ZQ7wfKXGOOQt3v3lO8SFnGFp2IrbrUqoN5ICmX/stE3m6Hbuw67 1rg962IKKHi7djjgmqyMqKB/fbrDKWA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gk5s8-0005N2-EL; Thu, 17 Jan 2019 11:30:08 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gk5s5-0004yJ-AY for ath10k@lists.infradead.org; Thu, 17 Jan 2019 11:30:06 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 591DC6087D; Thu, 17 Jan 2019 11:30:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1547724604; bh=klBJGSkacXRlfrcnAT3/uwvKK7TrHdnMtRU6XixNqlk=; h=From:To:Cc:Subject:Date:From; b=AXXBmzacEH3RrdbXTEbXDXI5/O1VN6RGvdDH9woOPkRssqP0rx52IcBth2dTW5GdA APojHL2rpcdEs1xGGUTqnd/8JU99MG24DLCH3/MUr7rVuDtrLutG7pU0JkoAQrI/Xp 3/NZAnEDN6dE06ZKKvo2FB231gt6dimnW+36Tj/s= Received: from checstex0244823-lin.qca.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: bpothuno@codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 6CD27606E1; Thu, 17 Jan 2019 11:30:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1547724603; bh=klBJGSkacXRlfrcnAT3/uwvKK7TrHdnMtRU6XixNqlk=; h=From:To:Cc:Subject:Date:From; b=jGxziGI48infUQuMqhpRhENCbhXGbZcDX4hdzZoYhlan+WdDhkfAYX4VcD6UWbB6c yd9dcQolJ3giGvecRfUJqBpAjWdAA4fV4ziwt3hInvZwdwO9rlyzYvGmt7GlOteOMA VxcOEnIA+vQ+7VCVmi1JqOfKeGzJj1PIFMZinYgI= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 6CD27606E1 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=bpothuno@codeaurora.org From: Balaji Pothunoori To: ath10k@lists.infradead.org Subject: [PATCH 3/3] ath10k: add support for controlling tx power to a station Date: Thu, 17 Jan 2019 16:59:35 +0530 Message-Id: <1547724575-11666-1-git-send-email-bpothuno@codeaurora.org> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190117_033005_416340_8AF2974A X-CRM114-Status: GOOD ( 16.96 ) X-BeenThere: ath10k@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Balaji Pothunoori , Ashok Raj Nagarajan , linux-wireless@vger.kernel.org MIME-Version: 1.0 Sender: "ath10k" Errors-To: ath10k-bounces+patchwork-ath10k=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Ashok Raj Nagarajan 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 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. When 0 is sent to the firmware as tx power, it will revert to the default tx power for the station. Tested Hardware : QCA9984 Tested Firmware : 10.4-3.9.0.1-00013 Co-developed-by: Balaji Pothunoori Signed-off-by: Ashok Raj Nagarajan Signed-off-by: Balaji Pothunoori --- drivers/net/wireless/ath/ath10k/debug.h | 3 +++ drivers/net/wireless/ath/ath10k/mac.c | 40 +++++++++++++++++++++++++++++++++ drivers/net/wireless/ath/ath10k/wmi.h | 18 +++++++++++++++ 3 files changed, 61 insertions(+) diff --git a/drivers/net/wireless/ath/ath10k/debug.h b/drivers/net/wireless/ath/ath10k/debug.h index 5cf16d6..1a01093 100644 --- a/drivers/net/wireless/ath/ath10k/debug.h +++ b/drivers/net/wireless/ath/ath10k/debug.h @@ -82,6 +82,9 @@ struct ath10k_pktlog_hdr { /* FIXME: How to calculate the buffer size sanely? */ #define ATH10K_FW_STATS_BUF_SIZE (1024 * 1024) +#define ATH10K_TX_POWER_MAX_VAL 70 +#define ATH10K_TX_POWER_MIN_VAL 0 + extern unsigned int ath10k_debug_mask; __printf(2, 3) void ath10k_info(struct ath10k *ar, const char *fmt, ...); diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c index e49b367..abf3805 100644 --- a/drivers/net/wireless/ath/ath10k/mac.c +++ b/drivers/net/wireless/ath/ath10k/mac.c @@ -6281,6 +6281,41 @@ static void ath10k_mac_dec_num_stations(struct ath10k_vif *arvif, ar->num_stations--; } +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 = (void *)vif->drv_priv; + int ret = 0; + s16 txpwr; + + if (sta->type == NL80211_TX_POWER_AUTOMATIC) { + txpwr = 0; + } else { + txpwr = MBM_TO_DBM(sta->txpwr); + if (!txpwr) + return -EINVAL; + } + + if (txpwr > ATH10K_TX_POWER_MAX_VAL || txpwr < ATH10K_TX_POWER_MIN_VAL) + return -EINVAL; + + 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, @@ -7938,6 +7973,7 @@ static const struct ieee80211_ops ath10k_ops = { .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, @@ -8617,6 +8653,10 @@ int ath10k_mac_register(struct ath10k *ar) wiphy_ext_feature_set(ar->hw->wiphy, NL80211_EXT_FEATURE_ACK_SIGNAL_SUPPORT); + if (test_bit(WMI_SERVICE_TX_PWR_PER_PEER, ar->wmi.svc_map)) + wiphy_ext_feature_set(ar->hw->wiphy, + NL80211_EXT_FEATURE_STA_TX_PWR); + /* * on LL hardware queues are managed entirely by the FW * so we only advertise to mac we can do the queues thing diff --git a/drivers/net/wireless/ath/ath10k/wmi.h b/drivers/net/wireless/ath/ath10k/wmi.h index 2034ccc..2c5509a 100644 --- a/drivers/net/wireless/ath/ath10k/wmi.h +++ b/drivers/net/wireless/ath/ath10k/wmi.h @@ -208,6 +208,14 @@ enum wmi_service { WMI_SERVICE_VDEV_DISABLE_4_ADDR_SRC_LRN_SUPPORT, WMI_SERVICE_BB_TIMING_CONFIG_SUPPORT, WMI_SERVICE_THERM_THROT, + WMI_SERVICE_HTT_ASSERT_TRIGGER_SUPPORT, + WMI_SERVICE_VDEV_FILTER_NEIGHBOR_RX_PACKETS, + WMI_SERVICE_PEER_CHWIDTH_CHANGE, + WMI_SERVICE_RX_FILTER_OUT_COUNT, + WMI_SERVICE_RTT_RESPONDER_ROLE, + WMI_SERVICE_EXT_PEER_TID_CONFIGS_SUPPORT, + WMI_SERVICE_REPORT_AIRTIME, + WMI_SERVICE_TX_PWR_PER_PEER, /* keep last */ WMI_SERVICE_MAX, @@ -368,6 +376,12 @@ enum wmi_10_4_service { WMI_10_4_SERVICE_HTT_ASSERT_TRIGGER_SUPPORT, WMI_10_4_SERVICE_VDEV_FILTER_NEIGHBOR_RX_PACKETS, WMI_10_4_SERVICE_VDEV_DISABLE_4_ADDR_SRC_LRN_SUPPORT, + WMI_10_4_SERVICE_PEER_CHWIDTH_CHANGE, + WMI_10_4_SERVICE_RX_FILTER_OUT_COUNT, + WMI_10_4_SERVICE_RTT_RESPONDER_ROLE, + WMI_10_4_SERVICE_EXT_PEER_TID_CONFIGS_SUPPORT, + WMI_10_4_SERVICE_REPORT_AIRTIME, + WMI_10_4_SERVICE_TX_PWR_PER_PEER, }; static inline char *wmi_service_name(int service_id) @@ -483,6 +497,7 @@ static inline char *wmi_service_name(int service_id) SVCSTR(WMI_SERVICE_RESET_CHIP); SVCSTR(WMI_SERVICE_TX_DATA_ACK_RSSI); SVCSTR(WMI_SERVICE_VDEV_DIFFERENT_BEACON_INTERVAL_SUPPORT); + SVCSTR(WMI_SERVICE_TX_PWR_PER_PEER); default: return NULL; } @@ -799,6 +814,8 @@ static inline void wmi_10_4_svc_map(const __le32 *in, unsigned long *out, WMI_SERVICE_VDEV_DIFFERENT_BEACON_INTERVAL_SUPPORT, len); SVCMAP(WMI_10_4_SERVICE_VDEV_DISABLE_4_ADDR_SRC_LRN_SUPPORT, WMI_SERVICE_VDEV_DISABLE_4_ADDR_SRC_LRN_SUPPORT, len); + SVCMAP(WMI_10_4_SERVICE_TX_PWR_PER_PEER, + WMI_SERVICE_TX_PWR_PER_PEER, len); } #undef SVCMAP @@ -6210,6 +6227,7 @@ enum wmi_peer_param { WMI_PEER_USE_4ADDR = 0x6, WMI_PEER_DEBUG = 0xa, WMI_PEER_PHYMODE = 0xd, + WMI_PEER_USE_FIXED_PWR = 0x8, WMI_PEER_DUMMY_VAR = 0xff, /* dummy parameter for STA PS workaround */ };