From patchwork Tue Nov 8 15:02:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: c_traja@qti.qualcomm.com X-Patchwork-Id: 9417619 X-Patchwork-Delegate: kvalo@adurom.com 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 E29F660512 for ; Tue, 8 Nov 2016 15:02:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D37482880F for ; Tue, 8 Nov 2016 15:02:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C7FFF28AB7; Tue, 8 Nov 2016 15:02:46 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 375C92880F for ; Tue, 8 Nov 2016 15:02:46 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1c47v7-0008DS-Dx; Tue, 08 Nov 2016 15:02:41 +0000 Received: from wolverine01.qualcomm.com ([199.106.114.254]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1c47v5-0008AQ-5S for ath10k@lists.infradead.org; Tue, 08 Nov 2016 15:02:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=qti.qualcomm.com; i=@qti.qualcomm.com; q=dns/txt; s=qcdkim; t=1478617359; x=1510153359; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=3k9YQZQXSjnZSFV/0xAEkFDA5gc9cFNCg4j5WEykSYw=; b=v1JKXru7nk5Eo4Sz0RpJe+r9bw1KAqWsDWhcoAFSLcXtIpTjgvcV6Ixb kPZNhGFpV60b+mmffMpvJrNJJRrTdvXXcfdBydySnr/qhU6SWO9UE0329 yGfZK/IpQ1Z2slisGG4xGoTzkI1ADjSefy8Bn4U/sQjyPGcTzhsvfUCRM 0=; X-IronPort-AV: E=Sophos;i="5.31,462,1473145200"; d="scan'208";a="238450455" Received: from unknown (HELO ironmsg02-L.qualcomm.com) ([10.53.140.109]) by wolverine01.qualcomm.com with ESMTP; 08 Nov 2016 07:02:18 -0800 X-IronPort-AV: E=McAfee;i="5700,7163,8342"; a="809413075" Received: from nasanexm02b.na.qualcomm.com ([10.85.0.42]) by ironmsg02-L.qualcomm.com with ESMTP/TLS/RC4-SHA; 08 Nov 2016 07:02:18 -0800 Received: from aphydexm01f.ap.qualcomm.com (10.252.127.15) by nasanexm02b.na.qualcomm.com (10.85.0.42) with Microsoft SMTP Server (TLS) id 15.0.1178.4; Tue, 8 Nov 2016 07:02:17 -0800 Received: from localhost (10.80.80.8) by aphydexm01f.ap.qualcomm.com (10.252.127.15) with Microsoft SMTP Server (TLS) id 15.0.1178.4; Tue, 8 Nov 2016 20:32:11 +0530 From: To: Subject: [PATCH 1/4] ath10k: Add support to enable or disable btcoex via nl80211 Date: Tue, 8 Nov 2016 20:32:31 +0530 Message-ID: <1478617354-28146-2-git-send-email-c_traja@qti.qualcomm.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1478617354-28146-1-git-send-email-c_traja@qti.qualcomm.com> References: <1478617354-28146-1-git-send-email-c_traja@qti.qualcomm.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: NASANEXM01F.na.qualcomm.com (10.85.0.32) To aphydexm01f.ap.qualcomm.com (10.252.127.15) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161108_070239_422254_D632DADF X-CRM114-Status: GOOD ( 13.36 ) X-BeenThere: ath10k@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tamizh chelvam , tamizhchelvam@codeaurora.org, linux-wireless@vger.kernel.org Sender: "ath10k" Errors-To: ath10k-bounces+patchwork-ath10k=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Tamizh chelvam This patch add support to enable or disable btcoex via nl80211. The firmware support this feature since 10.2.4.54 on 2G-only board, dual band or 5G boards don't support this. WMI service WMI_SERVICE_COEX_GPIO is used to identify the firmware support of this feature. Signed-off-by: Tamizh chelvam --- drivers/net/wireless/ath/ath10k/debug.c | 37 ++------------------ drivers/net/wireless/ath/ath10k/mac.c | 58 +++++++++++++++++++++++++++++++ drivers/net/wireless/ath/ath10k/mac.h | 1 + 3 files changed, 62 insertions(+), 34 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/debug.c b/drivers/net/wireless/ath/ath10k/debug.c index 82a4c67..ea30fbe 100644 --- a/drivers/net/wireless/ath/ath10k/debug.c +++ b/drivers/net/wireless/ath/ath10k/debug.c @@ -26,6 +26,7 @@ #include "debug.h" #include "hif.h" #include "wmi-ops.h" +#include "mac.h" /* ms */ #define ATH10K_DEBUG_HTT_STATS_INTERVAL 1000 @@ -2138,7 +2139,6 @@ static ssize_t ath10k_write_btcoex(struct file *file, size_t buf_size; int ret; bool val; - u32 pdev_param; buf_size = min(count, (sizeof(buf) - 1)); if (copy_from_user(buf, ubuf, buf_size)) @@ -2150,40 +2150,9 @@ static ssize_t ath10k_write_btcoex(struct file *file, return -EINVAL; mutex_lock(&ar->conf_mutex); - - if (ar->state != ATH10K_STATE_ON && - ar->state != ATH10K_STATE_RESTARTED) { - ret = -ENETDOWN; - goto exit; - } - - if (!(test_bit(ATH10K_FLAG_BTCOEX, &ar->dev_flags) ^ val)) { + ret = ath10k_mac_set_btcoex(ar, val); + if (!ret) ret = count; - goto exit; - } - - pdev_param = ar->wmi.pdev_param->enable_btcoex; - if (test_bit(ATH10K_FW_FEATURE_BTCOEX_PARAM, - ar->running_fw->fw_file.fw_features)) { - ret = ath10k_wmi_pdev_set_param(ar, pdev_param, val); - if (ret) { - ath10k_warn(ar, "failed to enable btcoex: %d\n", ret); - ret = count; - goto exit; - } - } else { - ath10k_info(ar, "restarting firmware due to btcoex change"); - queue_work(ar->workqueue, &ar->restart_work); - } - - if (val) - set_bit(ATH10K_FLAG_BTCOEX, &ar->dev_flags); - else - clear_bit(ATH10K_FLAG_BTCOEX, &ar->dev_flags); - - ret = count; - -exit: mutex_unlock(&ar->conf_mutex); return ret; diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c index a1a9ba1..f276391 100644 --- a/drivers/net/wireless/ath/ath10k/mac.c +++ b/drivers/net/wireless/ath/ath10k/mac.c @@ -7447,6 +7447,63 @@ struct ath10k_mac_change_chanctx_arg { return 0; } +static inline void ath10k_mac_update_btcoex_flag(struct ath10k *ar, bool val) +{ + if (val) + set_bit(ATH10K_FLAG_BTCOEX, &ar->dev_flags); + else + clear_bit(ATH10K_FLAG_BTCOEX, &ar->dev_flags); +} + +int ath10k_mac_set_btcoex(struct ath10k *ar, bool val) +{ + u32 pdev_param; + int ret; + + lockdep_assert_held(&ar->conf_mutex); + + if (ar->state != ATH10K_STATE_ON && + ar->state != ATH10K_STATE_RESTARTED) + return -ENETDOWN; + + if (!(test_bit(ATH10K_FLAG_BTCOEX, &ar->dev_flags) ^ val)) + return 0; + + pdev_param = ar->wmi.pdev_param->enable_btcoex; + if (test_bit(ATH10K_FW_FEATURE_BTCOEX_PARAM, + ar->running_fw->fw_file.fw_features)) { + ret = ath10k_wmi_pdev_set_param(ar, pdev_param, val); + + if (ret) { + ath10k_warn(ar, + "failed to modify btcoex state: %d\n", ret); + return ret; + } + ath10k_mac_update_btcoex_flag(ar, val); + } else { + ath10k_info(ar, "restarting firmware due to btcoex change"); + ath10k_mac_update_btcoex_flag(ar, val); + queue_work(ar->workqueue, &ar->restart_work); + } + + return 0; +} + +static int ath10k_mac_op_set_btcoex(struct ieee80211_hw *hw, bool enabled) +{ + int ret; + struct ath10k *ar = hw->priv; + + if (!test_bit(WMI_SERVICE_COEX_GPIO, ar->wmi.svc_map)) + return -EOPNOTSUPP; + + mutex_lock(&ar->conf_mutex); + ret = ath10k_mac_set_btcoex(ar, enabled); + mutex_unlock(&ar->conf_mutex); + + return ret; +} + static const struct ieee80211_ops ath10k_ops = { .tx = ath10k_mac_op_tx, .wake_tx_queue = ath10k_mac_op_wake_tx_queue, @@ -7488,6 +7545,7 @@ struct ath10k_mac_change_chanctx_arg { .assign_vif_chanctx = ath10k_mac_op_assign_vif_chanctx, .unassign_vif_chanctx = ath10k_mac_op_unassign_vif_chanctx, .switch_vif_chanctx = ath10k_mac_op_switch_vif_chanctx, + .set_btcoex = ath10k_mac_op_set_btcoex, CFG80211_TESTMODE_CMD(ath10k_tm_cmd) diff --git a/drivers/net/wireless/ath/ath10k/mac.h b/drivers/net/wireless/ath/ath10k/mac.h index 1bd29ec..de1fa72 100644 --- a/drivers/net/wireless/ath/ath10k/mac.h +++ b/drivers/net/wireless/ath/ath10k/mac.h @@ -82,6 +82,7 @@ struct ieee80211_txq *ath10k_mac_txq_lookup(struct ath10k *ar, u16 peer_id, u8 tid); int ath10k_mac_ext_resource_config(struct ath10k *ar, u32 val); +int ath10k_mac_set_btcoex(struct ath10k *ar, bool val); static inline struct ath10k_vif *ath10k_vif_to_arvif(struct ieee80211_vif *vif) {