From patchwork Wed Dec 18 15:48:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kalle Valo X-Patchwork-Id: 11301113 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 63FF814B7 for ; Wed, 18 Dec 2019 15:48:56 +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 40FDF20684 for ; Wed, 18 Dec 2019 15:48:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="DyDYBGrN"; dkim=fail reason="key not found in DNS" (0-bit key) header.d=mg.codeaurora.org header.i=@mg.codeaurora.org header.b="gNiVMtF5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 40FDF20684 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=ath10k-bounces+patchwork-ath10k=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:References: In-Reply-To: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:List-Owner; bh=SMjK9uavm1UGm8ts8Abhr8x230LyvWjBzpp+PCQbQwk=; b=DyDYBGrN7I7oATH9gxwtZV+5pU hHj4ocGfwpIubAn0MEStckjDNbIHz00rT3wlLj10hf++A3YOoBSoXdTkF4IllFsbxF/yQzpQ3HpQ1 GFlO+8NudACFnfsmapiBlMAedkiEY2rcrU7S9G9Jh8JFq4c6kJT+ptiOoA2sfZUIj9xcT3Gc6yi3J 3k2vYGqKYh/aJFRWokHsKLfsetfHqSvTQ78b4auLhjWHLH0FJs8AfntfPpCBjlfnD9OyZ59W8swFn YDPZ9pQ/FDwRTQsC2pRJts/bv5UuvVQ6VZQWN2VrJTvG90d2CMfHturyM6PQ8Zl0njYRM6VH6rYWN gVP3WKxw==; 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 1ihbZ3-0000FI-PE; Wed, 18 Dec 2019 15:48:41 +0000 Received: from mail26.static.mailgun.info ([104.130.122.26]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ihbYz-0000Cn-Om for ath10k@lists.infradead.org; Wed, 18 Dec 2019 15:48:39 +0000 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1576684117; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=Ts/SoN8mMCn5XP7ft2oCeu5tzE14MHymrYQPG4etVSE=; b=gNiVMtF5an2TUASK7yPLV4FuYUpAGQTOtMZReJQF6RE4ltpVM2lFFVx1qIOmeyen4NCmJASc /W9Zs0JxsfLWTXLvkkL5sXrOoGoUATeLxlzwcMnu2DmgKVon+Z3D5Xv8X2+UzscjFUeRmoHw R1ZjgDIIxjHoswOiASrh641UWCk= X-Mailgun-Sending-Ip: 104.130.122.26 X-Mailgun-Sid: WyJiZDQ3OSIsICJhdGgxMGtAbGlzdHMuaW5mcmFkZWFkLm9yZyIsICJiZTllNGEiXQ== Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by mxa.mailgun.org with ESMTP id 5dfa4a53.7f1154914c70-smtp-out-n01; Wed, 18 Dec 2019 15:48:35 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id E1CD1C43383; Wed, 18 Dec 2019 15:48:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from potku.adurom.net (88-114-240-156.elisa-laajakaista.fi [88.114.240.156]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: kvalo) by smtp.codeaurora.org (Postfix) with ESMTPSA id 7214EC433CB; Wed, 18 Dec 2019 15:48:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 7214EC433CB Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=kvalo@codeaurora.org From: Kalle Valo To: ath10k@lists.infradead.org Subject: [PATCH 1/2] nl80211: vendor-cmd: qca: add dynamic SAR power limits Date: Wed, 18 Dec 2019 17:48:27 +0200 Message-Id: <1576684108-30177-2-git-send-email-kvalo@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1576684108-30177-1-git-send-email-kvalo@codeaurora.org> References: <1576684108-30177-1-git-send-email-kvalo@codeaurora.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191218_074838_063716_8EAA2A60 X-CRM114-Status: GOOD ( 16.86 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [104.130.122.26 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [104.130.122.26 listed in wl.mailspike.net] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: ath10k@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-wireless@vger.kernel.org MIME-Version: 1.0 Sender: "ath10k" Errors-To: ath10k-bounces+patchwork-ath10k=patchwork.kernel.org@lists.infradead.org From: Wen Gong The vendor commands is to add API for user to configure dynamic SAR power limits, it will not replace the existing power control functionality, it is to make more convenient to configure power. An example of usage(wlan0 is the wireless interface dev name): iw dev wlan0 vendor send 0x1374 0x92 0x2C 0x00 0x03 0x00 0x14 0x00 0x01 0x00 0x08 0x00 0x07 0x00 0x22 0x00 0x00 0x00 0x08 0x00 0x04 0x00 0x00 0x00 0x00 0x00 0x14 0x00 0x02 0x00 0x08 0x00 0x07 0x00 0x11 0x00 0x00 0x00 0x08 0x00 0x04 0x00 0x01 0x00 0x00 0x00 means of bytes: 0x1374: vendor id 0x92: vendor subcmd id 0x22: 2.4G power limit 0x11: 5G power limit Tested with QCA6174 SDIO with firmware WLAN.RMH.4.4.1-00029. Signed-off-by: Wen Gong Signed-off-by: Kalle Valo --- include/uapi/nl80211-vnd-qca.h | 68 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 include/uapi/nl80211-vnd-qca.h diff --git a/include/uapi/nl80211-vnd-qca.h b/include/uapi/nl80211-vnd-qca.h new file mode 100644 index 000000000000..482c9409a2c0 --- /dev/null +++ b/include/uapi/nl80211-vnd-qca.h @@ -0,0 +1,68 @@ +/* SPDX-License-Identifier: ISC */ +/* + * Copyright (c) 2019 The Linux Foundation. All rights reserved. + */ + +#ifndef _UAPI_NL80211_VND_QCA_H +#define _UAPI_NL80211_VND_QCA_H + +/* Vendor id to be used in vendor specific command and events to user space + * NOTE: The authoritative place for definition of QCA_NL80211_VENDOR_ID, + * vendor subcmd definitions prefixed with QCA_NL80211_VENDOR_SUBCMD, and + * qca_wlan_vendor_attr is open source file src/common/qca-vendor.h in + * git://w1.fi/srv/git/hostap.git; the values here are just a copy of that + */ +#define QCA_NL80211_VENDOR_ID 0x001374 + +/** + * enum qca_nl80211_vendor_subcmds - QCA nl80211 vendor command identifiers + * + *@QCA_NL80211_VENDOR_SUBCMD_SET_SAR_LIMITS and is used to retrieve the + * settings currently in use. The attributes returned by this command are + * defined by enum qca_vendor_attr_sar_limits. + */ +enum qca_nl80211_vendor_subcmds { + QCA_NL80211_VENDOR_SUBCMD_SET_SAR_LIMITS = 146, + }; + +/** + * enum qca_vendor_attr_sar_limits - Attributes for SAR power limits + * + * @QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC: Nested array of SAR power + * limit specifications. The number of specifications is + * specified by @QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_NUM_SPECS. Each + * specification contains a set of + * QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC_* attributes. A + * specification is uniquely identified by the attributes + * %QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC_BAND and always + * contains as a payload the attribute + * %QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC_POWER_LIMIT. + * + * @QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC_BAND: Optional (u32) value to + * indicate for which band this specification applies. Valid + * values are enumerated in enum %nl80211_band (although not all + * bands may be supported by a given device). If the attribute is + * not supplied then the specification will be applied to all + * supported bands. + * + * @QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC_POWER_LIMIT: Required (u32) + * value to specify the actual power limit value in units of 0.5 + * dBm (i.e., a value of 11 represents 5.5 dBm). + * This is required, when %QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SELECT is + * %QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SELECT_USER. + * + * These attributes are used with %QCA_NL80211_VENDOR_SUBCMD_SET_SAR_LIMITS + * and %QCA_NL80211_VENDOR_SUBCMD_GET_SAR_LIMITS. + */ +enum qca_vendor_attr_sar_limits { + QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_INVALID = 0, + QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC = 3, + QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC_BAND = 4, + QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC_POWER_LIMIT = 7, + + QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_AFTER_LAST, + QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_MAX = + QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_AFTER_LAST - 1 +}; + +#endif /* _UAPI_NL80211_VND_QCA_H_ */ From patchwork Wed Dec 18 15:48:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kalle Valo X-Patchwork-Id: 11301111 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 B618514B7 for ; Wed, 18 Dec 2019 15:48:45 +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 8D85E20684 for ; Wed, 18 Dec 2019 15:48:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="rYQ7kWai"; dkim=fail reason="key not found in DNS" (0-bit key) header.d=mg.codeaurora.org header.i=@mg.codeaurora.org header.b="XUCXrzZP" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8D85E20684 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=ath10k-bounces+patchwork-ath10k=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:References: In-Reply-To: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:List-Owner; bh=r8xDon+J2guUAK5q0bIWiTQwq25K764m/FI9NKv6HzA=; b=rYQ7kWaiYoPXIY1hjIIcJvspkz q3O4yNbBZPvgXYEh4c3n3f0F23IsHsRPj5musaqi3JPj3LwdPMAQfJy/YrKHqOz0ZpzNEY+KvkD24 PmGWi/GrwpXNggGwkfw9RBF7VWMomnAuv0irItC3qkROUxGbZc+O7IF+v3sInEG/zrbbbMJpJsyg/ n4z81q+vJZwUZGqX9fWokMO2kf3+oZe79qrXevE0FC08iGGIX5mjcKXfK/3K8+eeb8of+kvhnTRGB ENunnWaVyA22p4LVI9S/ARijliBFTR8RaSGmVtKtWgF3KXOlLRK7/DeNNScjqwLZLW4TOvgb5Fwsf zZHq2cQA==; 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 1ihbZ6-0000J5-Jy; Wed, 18 Dec 2019 15:48:44 +0000 Received: from mail26.static.mailgun.info ([104.130.122.26]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ihbZ1-0000Ca-R3 for ath10k@lists.infradead.org; Wed, 18 Dec 2019 15:48:42 +0000 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1576684120; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=ZbA/dfYpPCzni0YnfHb/A1A+QgKAg444uelme3/TLcw=; b=XUCXrzZP1LBDOukT82+bM6wiiMplPfvvap4m80XE9JWu/1pfYavghZdqwmj7rNu7+VWiRJa1 Y0UXOKUlM2vyfd98+OSNlrDIUUokI+KYgdtTsZ1YE+x3fW9J6loXbR+J7yTQ+FYeZTdfv3UP O8h+z6QqXgur/rXG5Xe7hkr06d0= X-Mailgun-Sending-Ip: 104.130.122.26 X-Mailgun-Sid: WyJiZDQ3OSIsICJhdGgxMGtAbGlzdHMuaW5mcmFkZWFkLm9yZyIsICJiZTllNGEiXQ== Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by mxa.mailgun.org with ESMTP id 5dfa4a55.7f3f0203a6f8-smtp-out-n02; Wed, 18 Dec 2019 15:48:37 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 7E7C2C43383; Wed, 18 Dec 2019 15:48:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE autolearn=ham autolearn_force=no version=3.4.0 Received: from potku.adurom.net (88-114-240-156.elisa-laajakaista.fi [88.114.240.156]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: kvalo) by smtp.codeaurora.org (Postfix) with ESMTPSA id BF2FDC4479F; Wed, 18 Dec 2019 15:48:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org BF2FDC4479F Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=kvalo@codeaurora.org From: Kalle Valo To: ath10k@lists.infradead.org Subject: [PATCH 2/2] ath10k: allow dynamic SAR power limits to be configured Date: Wed, 18 Dec 2019 17:48:28 +0200 Message-Id: <1576684108-30177-3-git-send-email-kvalo@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1576684108-30177-1-git-send-email-kvalo@codeaurora.org> References: <1576684108-30177-1-git-send-email-kvalo@codeaurora.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191218_074840_469996_30A78485 X-CRM114-Status: GOOD ( 23.24 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [104.130.122.26 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [104.130.122.26 listed in wl.mailspike.net] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: ath10k@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-wireless@vger.kernel.org MIME-Version: 1.0 Sender: "ath10k" Errors-To: ath10k-bounces+patchwork-ath10k=patchwork.kernel.org@lists.infradead.org From: Wen Gong Add support for a vendor command for STATION, the command QCA_NL80211_VENDOR_SUBCMD_SET_SAR_LIMITS which is already defined in git://w1.fi/hostap.git (src/command/qca-vendor.h). This allows user space to configure power limits for 2.4 GHz and 5 GHz bands. ath10k set pdev parameter WMI_PDEV_PARAM_TXPOWER_LIMIT2G and WMI_PDEV_PARAM_TXPOWER_LIMIT5G to firmware, the 2 value will be used as one input source to affect the tx power. When QCA_NL80211_VENDOR_SUBCMD_SET_SAR_LIMITS set to ath10k, it will be saved the 2.4G and 5G limit value, If STATION is connected meanwhile, then the 2.4G and 5G WMI command will be set to firmware, otherwise it will not set to firmware at this moment. When STATION connect next time, it will set to firmware. Tested with QCA6174 SDIO with firmware WLAN.RMH.4.4.1-00029. Signed-off-by: Wen Gong Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath10k/Makefile | 1 + drivers/net/wireless/ath/ath10k/core.c | 2 + drivers/net/wireless/ath/ath10k/core.h | 2 + drivers/net/wireless/ath/ath10k/hw.h | 3 + drivers/net/wireless/ath/ath10k/mac.c | 64 +++++++++++++++++ drivers/net/wireless/ath/ath10k/mac.h | 2 +- drivers/net/wireless/ath/ath10k/vendor.c | 114 +++++++++++++++++++++++++++++++ drivers/net/wireless/ath/ath10k/vendor.h | 13 ++++ drivers/net/wireless/ath/ath10k/wmi.h | 6 ++ 9 files changed, 206 insertions(+), 1 deletion(-) create mode 100644 drivers/net/wireless/ath/ath10k/vendor.c create mode 100644 drivers/net/wireless/ath/ath10k/vendor.h diff --git a/drivers/net/wireless/ath/ath10k/Makefile b/drivers/net/wireless/ath/ath10k/Makefile index 142c777b287f..6cdc7eba5d25 100644 --- a/drivers/net/wireless/ath/ath10k/Makefile +++ b/drivers/net/wireless/ath/ath10k/Makefile @@ -13,6 +13,7 @@ ath10k_core-y += mac.o \ bmi.o \ hw.o \ p2p.o \ + vendor.o \ swap.o ath10k_core-$(CONFIG_ATH10K_SPECTRAL) += spectral.o diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c index 5ec16ce19b69..e882d2f2e399 100644 --- a/drivers/net/wireless/ath/ath10k/core.c +++ b/drivers/net/wireless/ath/ath10k/core.c @@ -25,6 +25,7 @@ #include "testmode.h" #include "wmi-ops.h" #include "coredump.h" +#include "vendor.h" unsigned int ath10k_debug_mask; EXPORT_SYMBOL(ath10k_debug_mask); @@ -190,6 +191,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = { .uart_pin_workaround = true, .tx_stats_over_pktlog = false, .bmi_large_size_download = true, + .dynamic_sar_support = true, }, { .id = QCA6174_HW_2_1_VERSION, diff --git a/drivers/net/wireless/ath/ath10k/core.h b/drivers/net/wireless/ath/ath10k/core.h index 5101bf2b5b15..b661e0eee0f8 100644 --- a/drivers/net/wireless/ath/ath10k/core.h +++ b/drivers/net/wireless/ath/ath10k/core.h @@ -983,6 +983,8 @@ struct ath10k { u8 ps_state_enable; bool nlo_enabled; + u32 tx_power_2g_limit; + u32 tx_power_5g_limit; bool p2p; struct { diff --git a/drivers/net/wireless/ath/ath10k/hw.h b/drivers/net/wireless/ath/ath10k/hw.h index 21b7a2a873b0..8cee355098e3 100644 --- a/drivers/net/wireless/ath/ath10k/hw.h +++ b/drivers/net/wireless/ath/ath10k/hw.h @@ -623,6 +623,9 @@ struct ath10k_hw_params { /* tx stats support over pktlog */ bool tx_stats_over_pktlog; + + /* support dynamic sar */ + bool dynamic_sar_support; }; struct htt_rx_desc; diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c index 7fee35ff966b..75c600e8fff2 100644 --- a/drivers/net/wireless/ath/ath10k/mac.c +++ b/drivers/net/wireless/ath/ath10k/mac.c @@ -24,6 +24,7 @@ #include "wmi-tlv.h" #include "wmi-ops.h" #include "wow.h" +#include "vendor.h" /*********/ /* Rates */ @@ -2843,6 +2844,65 @@ static int ath10k_mac_vif_recalc_txbf(struct ath10k *ar, return 0; } +static bool ath10k_mac_get_connected(struct ath10k *ar) +{ + struct ath10k_vif *arvif; + + list_for_each_entry(arvif, &ar->arvifs, list) { + if (arvif->is_up && arvif->vdev_type == WMI_VDEV_TYPE_STA) + return true; + } + + return false; +} + +int ath10k_mac_set_sar_power_limit(struct ath10k *ar) +{ + u32 ret, param, pwr_limit_2G, pwr_limit_5G; + bool connected, tx_power_valid; + + if (!ar->hw_params.dynamic_sar_support) + return 0; + + connected = ath10k_mac_get_connected(ar); + tx_power_valid = (ar->tx_power_2g_limit != 0 && ar->tx_power_5g_limit != 0); + + ath10k_dbg(ar, ATH10K_DBG_MAC, "mac connected %d sar power valid %d\n", + connected, tx_power_valid); + + if (!connected || !tx_power_valid) + return 0; + + pwr_limit_2G = ar->tx_power_2g_limit; + pwr_limit_5G = ar->tx_power_5g_limit; + + ath10k_dbg(ar, ATH10K_DBG_MAC, "mac sar limits max %d 2.4G %d 5G %d\n", + ar->hw_max_tx_power, + pwr_limit_2G, + pwr_limit_5G); + + param = ar->wmi.pdev_param->txpower_limit2g; + ret = ath10k_wmi_pdev_set_param(ar, param, pwr_limit_2G); + if (ret) { + ath10k_warn(ar, "failed to set 2.4G txpower %d: %d\n", + pwr_limit_2G, ret); + return ret; + } + ath10k_dbg(ar, ATH10K_DBG_MAC, "mac set 2.4G txpower %d success\n", pwr_limit_2G); + + param = ar->wmi.pdev_param->txpower_limit5g; + ret = ath10k_wmi_pdev_set_param(ar, param, pwr_limit_5G); + if (ret) { + ath10k_warn(ar, "failed to set 5G txpower %d: %d\n", + pwr_limit_5G, ret); + return ret; + } + + ath10k_dbg(ar, ATH10K_DBG_MAC, "mac set 5G txpower %d success\n", pwr_limit_5G); + + return 0; +} + /* can be called only in mac80211 callbacks due to `key_count` usage */ static void ath10k_bss_assoc(struct ieee80211_hw *hw, struct ieee80211_vif *vif, @@ -2926,6 +2986,8 @@ static void ath10k_bss_assoc(struct ieee80211_hw *hw, arvif->is_up = true; + ath10k_mac_set_sar_power_limit(ar); + /* Workaround: Some firmware revisions (tested with qca6174 * WLAN.RM.2.0-00073) have buggy powersave state machine and must be * poked with peer param command. @@ -9074,6 +9136,8 @@ int ath10k_mac_register(struct ath10k *ar) NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR; } + ath10k_vendor_register(ar); + ar->hw->wiphy->cipher_suites = cipher_suites; /* QCA988x and QCA6174 family chips do not support CCMP-256, GCMP-128 diff --git a/drivers/net/wireless/ath/ath10k/mac.h b/drivers/net/wireless/ath/ath10k/mac.h index 98d83a26ea60..54c8cfcef611 100644 --- a/drivers/net/wireless/ath/ath10k/mac.h +++ b/drivers/net/wireless/ath/ath10k/mac.h @@ -58,7 +58,7 @@ u8 ath10k_mac_hw_rate_to_idx(const struct ieee80211_supported_band *sband, u8 hw_rate, bool cck); u8 ath10k_mac_bitrate_to_idx(const struct ieee80211_supported_band *sband, u32 bitrate); - +int ath10k_mac_set_sar_power_limit(struct ath10k *ar); void ath10k_mac_tx_lock(struct ath10k *ar, int reason); void ath10k_mac_tx_unlock(struct ath10k *ar, int reason); void ath10k_mac_vif_tx_lock(struct ath10k_vif *arvif, int reason); diff --git a/drivers/net/wireless/ath/ath10k/vendor.c b/drivers/net/wireless/ath/ath10k/vendor.c new file mode 100644 index 000000000000..755dbf7146cb --- /dev/null +++ b/drivers/net/wireless/ath/ath10k/vendor.c @@ -0,0 +1,114 @@ +// SPDX-License-Identifier: ISC +/* + * Copyright (c) 2019, The Linux Foundation. All rights reserved. + */ + +#include +#include + +#include "mac.h" +#include "debug.h" +#include "vendor.h" + +static const struct nla_policy +sar_limits_policy[QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_MAX + 1] = { + [QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC_BAND] = {.type = NLA_U32}, + [QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC_POWER_LIMIT] = {.type = NLA_U32}, +}; + +static int ath10k_vendor_set_dynamic_sar_power_limits(struct wiphy *wiphy, + struct wireless_dev *wdev, + const void *data, + int data_len) +{ + int rem; + struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy); + struct ath10k *ar = hw->priv; + struct nlattr *spec[QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_MAX + 1]; + struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_MAX + 1]; + struct nlattr *spec_list; + u32 limit; + enum nl80211_band band; + bool sar_valid = false; + + if (!ar->hw_params.dynamic_sar_support) + return -ENOTSUPP; + + if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_MAX, data, data_len, + sar_limits_policy, NULL)) { + ath10k_warn(ar, "invalid SAR attr\n"); + return -EINVAL; + } + + if (!tb[QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC]) { + ath10k_warn(ar, "invalid SAR specification list\n"); + return -EINVAL; + } + + nla_for_each_nested(spec_list, tb[QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC], rem) { + if (nla_parse(spec, + QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_MAX, + nla_data(spec_list), + nla_len(spec_list), + sar_limits_policy, + NULL)) { + ath10k_warn(ar, "nla_parse failed for SAR Spec list\n"); + return -EINVAL; + } + + if (spec[QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC_POWER_LIMIT]) { + limit = nla_get_u32( + spec[QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC_POWER_LIMIT]); + } else { + ath10k_warn(ar, "not have spec power limit\n"); + return -EINVAL; + } + + if (spec[QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC_BAND]) { + band = nla_get_u32( + spec[QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC_BAND]); + } else { + /* if QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC_BAND is + * unset the limit applies to both bands + */ + if (limit <= ar->hw_max_tx_power) { + ar->tx_power_2g_limit = limit; + ar->tx_power_5g_limit = limit; + sar_valid = true; + } + + break; + } + + sar_valid = true; + if (band == NL80211_BAND_2GHZ && limit <= ar->hw_max_tx_power) + ar->tx_power_2g_limit = limit; + else if (band == NL80211_BAND_5GHZ && limit <= ar->hw_max_tx_power) + ar->tx_power_5g_limit = limit; + } + + if (sar_valid) + return ath10k_mac_set_sar_power_limit(ar); + + return 0; +} + +static const struct wiphy_vendor_command ath10k_vendor_commands[] = { + { + .info = { + .vendor_id = QCA_NL80211_VENDOR_ID, + .subcmd = QCA_NL80211_VENDOR_SUBCMD_SET_SAR_LIMITS, + }, + .flags = WIPHY_VENDOR_CMD_NEED_WDEV | + WIPHY_VENDOR_CMD_NEED_RUNNING, + .doit = ath10k_vendor_set_dynamic_sar_power_limits, + .policy = sar_limits_policy, + } +}; + +void ath10k_vendor_register(struct ath10k *ar) +{ + ar->hw->wiphy->vendor_commands = ath10k_vendor_commands; + ar->hw->wiphy->n_vendor_commands = ARRAY_SIZE(ath10k_vendor_commands); +} + diff --git a/drivers/net/wireless/ath/ath10k/vendor.h b/drivers/net/wireless/ath/ath10k/vendor.h new file mode 100644 index 000000000000..827614cb6991 --- /dev/null +++ b/drivers/net/wireless/ath/ath10k/vendor.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: ISC */ +/* + * Copyright (c) 2019 The Linux Foundation. All rights reserved. + */ + +#ifndef _VENDOR_H_ +#define _VENDOR_H_ + +#include + +void ath10k_vendor_register(struct ath10k *ar); + +#endif /* _VENDOR_H_ */ diff --git a/drivers/net/wireless/ath/ath10k/wmi.h b/drivers/net/wireless/ath/ath10k/wmi.h index 972d53d77654..f0cadaa12399 100644 --- a/drivers/net/wireless/ath/ath10k/wmi.h +++ b/drivers/net/wireless/ath/ath10k/wmi.h @@ -3695,6 +3695,12 @@ struct wmi_csa_event { #define VDEV_DEFAULT_STATS_UPDATE_PERIOD 500 #define PEER_DEFAULT_STATS_UPDATE_PERIOD 500 +/* the mask of 4 sub band of 5G for SAR parameters */ +#define ATH10K_WMI_SAR_5G_0_MASK GENMASK(7, 0) +#define ATH10K_WMI_SAR_5G_1_MASK GENMASK(15, 8) +#define ATH10K_WMI_SAR_5G_2_MASK GENMASK(23, 16) +#define ATH10K_WMI_SAR_5G_3_MASK GENMASK(31, 24) + struct wmi_pdev_param_map { u32 tx_chain_mask; u32 rx_chain_mask;