diff mbox

[1/4] ath10k: Add support to enable or disable btcoex via nl80211

Message ID 1478617354-28146-2-git-send-email-c_traja@qti.qualcomm.com (mailing list archive)
State Changes Requested
Delegated to: Kalle Valo
Headers show

Commit Message

c_traja@qti.qualcomm.com Nov. 8, 2016, 3:02 p.m. UTC
From: Tamizh chelvam <c_traja@qti.qualcomm.com>

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 <c_traja@qti.qualcomm.com>
---
 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(-)

Comments

kernel test robot Nov. 8, 2016, 10:34 p.m. UTC | #1
Hi Tamizh,

[auto build test ERROR on ath6kl/ath-next]
[also build test ERROR on v4.9-rc4 next-20161108]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/c_traja-qti-qualcomm-com/ath10k-Add-support-for-BTCOEX-feature/20161109-043718
base:   https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git ath-next
config: x86_64-allmodconfig (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

>> drivers/net/wireless/ath/ath10k/mac.c:7548:2: error: unknown field 'set_btcoex' specified in initializer
     .set_btcoex                     = ath10k_mac_op_set_btcoex,
     ^
>> drivers/net/wireless/ath/ath10k/mac.c:7548:36: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
     .set_btcoex                     = ath10k_mac_op_set_btcoex,
                                       ^~~~~~~~~~~~~~~~~~~~~~~~
   drivers/net/wireless/ath/ath10k/mac.c:7548:36: note: (near initialization for 'ath10k_ops.reconfig_complete')
   cc1: some warnings being treated as errors

vim +/set_btcoex +7548 drivers/net/wireless/ath/ath10k/mac.c

  7542		.add_chanctx			= ath10k_mac_op_add_chanctx,
  7543		.remove_chanctx			= ath10k_mac_op_remove_chanctx,
  7544		.change_chanctx			= ath10k_mac_op_change_chanctx,
  7545		.assign_vif_chanctx		= ath10k_mac_op_assign_vif_chanctx,
  7546		.unassign_vif_chanctx		= ath10k_mac_op_unassign_vif_chanctx,
  7547		.switch_vif_chanctx		= ath10k_mac_op_switch_vif_chanctx,
> 7548		.set_btcoex                     = ath10k_mac_op_set_btcoex,
  7549	
  7550		CFG80211_TESTMODE_CMD(ath10k_tm_cmd)
  7551	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
kernel test robot Nov. 8, 2016, 11:20 p.m. UTC | #2
Hi Tamizh,

[auto build test WARNING on ath6kl/ath-next]
[also build test WARNING on v4.9-rc4 next-20161108]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/c_traja-qti-qualcomm-com/ath10k-Add-support-for-BTCOEX-feature/20161109-043718
base:   https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git ath-next
config: xtensa-allmodconfig (attached as .config)
compiler: xtensa-linux-gcc (GCC) 4.9.0
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=xtensa 

All warnings (new ones prefixed by >>):

   drivers/net/wireless/ath/ath10k/mac.c:7548:2: error: unknown field 'set_btcoex' specified in initializer
     .set_btcoex                     = ath10k_mac_op_set_btcoex,
     ^
>> drivers/net/wireless/ath/ath10k/mac.c:7548:2: warning: initialization from incompatible pointer type
   drivers/net/wireless/ath/ath10k/mac.c:7548:2: warning: (near initialization for 'ath10k_ops.reconfig_complete')

vim +7548 drivers/net/wireless/ath/ath10k/mac.c

  7532		.reconfig_complete		= ath10k_reconfig_complete,
  7533		.get_survey			= ath10k_get_survey,
  7534		.set_bitrate_mask		= ath10k_mac_op_set_bitrate_mask,
  7535		.sta_rc_update			= ath10k_sta_rc_update,
  7536		.get_tsf			= ath10k_get_tsf,
  7537		.set_tsf			= ath10k_set_tsf,
  7538		.ampdu_action			= ath10k_ampdu_action,
  7539		.get_et_sset_count		= ath10k_debug_get_et_sset_count,
  7540		.get_et_stats			= ath10k_debug_get_et_stats,
  7541		.get_et_strings			= ath10k_debug_get_et_strings,
  7542		.add_chanctx			= ath10k_mac_op_add_chanctx,
  7543		.remove_chanctx			= ath10k_mac_op_remove_chanctx,
  7544		.change_chanctx			= ath10k_mac_op_change_chanctx,
  7545		.assign_vif_chanctx		= ath10k_mac_op_assign_vif_chanctx,
  7546		.unassign_vif_chanctx		= ath10k_mac_op_unassign_vif_chanctx,
  7547		.switch_vif_chanctx		= ath10k_mac_op_switch_vif_chanctx,
> 7548		.set_btcoex                     = ath10k_mac_op_set_btcoex,
  7549	
  7550		CFG80211_TESTMODE_CMD(ath10k_tm_cmd)
  7551	
  7552	#ifdef CONFIG_PM
  7553		.suspend			= ath10k_wow_op_suspend,
  7554		.resume				= ath10k_wow_op_resume,
  7555	#endif
  7556	#ifdef CONFIG_MAC80211_DEBUGFS

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
tamizhchelvam@codeaurora.org Nov. 9, 2016, 10:45 a.m. UTC | #3
On 2016-11-09 04:50, kbuild test robot wrote:
> Hi Tamizh,
> 
> [auto build test WARNING on ath6kl/ath-next]
> [also build test WARNING on v4.9-rc4 next-20161108]
> [if your patch is applied to the wrong git tree, please drop us a note
> to help improve the system]
> 
> url:
> https://github.com/0day-ci/linux/commits/c_traja-qti-qualcomm-com/ath10k-Add-support-for-BTCOEX-feature/20161109-043718
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git 
> ath-next
> config: xtensa-allmodconfig (attached as .config)
> compiler: xtensa-linux-gcc (GCC) 4.9.0
> reproduce:
>         wget
> https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
> -O ~/bin/make.cross
>         chmod +x ~/bin/make.cross
>         # save the attached .config to linux build tree
>         make.cross ARCH=xtensa
> 
> All warnings (new ones prefixed by >>):
> 
>    drivers/net/wireless/ath/ath10k/mac.c:7548:2: error: unknown field
> 'set_btcoex' specified in initializer
>      .set_btcoex                     = ath10k_mac_op_set_btcoex,
>      ^
>>> drivers/net/wireless/ath/ath10k/mac.c:7548:2: warning: initialization 
>>> from incompatible pointer type
>    drivers/net/wireless/ath/ath10k/mac.c:7548:2: warning: (near
> initialization for 'ath10k_ops.reconfig_complete')

This patch has dependency of "cfg80211: mac80211: BTCOEX feature 
support" patchset.
> 
> vim +7548 drivers/net/wireless/ath/ath10k/mac.c
> 
>   7532		.reconfig_complete		= ath10k_reconfig_complete,
>   7533		.get_survey			= ath10k_get_survey,
>   7534		.set_bitrate_mask		= ath10k_mac_op_set_bitrate_mask,
>   7535		.sta_rc_update			= ath10k_sta_rc_update,
>   7536		.get_tsf			= ath10k_get_tsf,
>   7537		.set_tsf			= ath10k_set_tsf,
>   7538		.ampdu_action			= ath10k_ampdu_action,
>   7539		.get_et_sset_count		= ath10k_debug_get_et_sset_count,
>   7540		.get_et_stats			= ath10k_debug_get_et_stats,
>   7541		.get_et_strings			= ath10k_debug_get_et_strings,
>   7542		.add_chanctx			= ath10k_mac_op_add_chanctx,
>   7543		.remove_chanctx			= ath10k_mac_op_remove_chanctx,
>   7544		.change_chanctx			= ath10k_mac_op_change_chanctx,
>   7545		.assign_vif_chanctx		= ath10k_mac_op_assign_vif_chanctx,
>   7546		.unassign_vif_chanctx		= ath10k_mac_op_unassign_vif_chanctx,
>   7547		.switch_vif_chanctx		= ath10k_mac_op_switch_vif_chanctx,
>> 7548		.set_btcoex                     = ath10k_mac_op_set_btcoex,
>   7549
>   7550		CFG80211_TESTMODE_CMD(ath10k_tm_cmd)
>   7551
>   7552	#ifdef CONFIG_PM
>   7553		.suspend			= ath10k_wow_op_suspend,
>   7554		.resume				= ath10k_wow_op_resume,
>   7555	#endif
>   7556	#ifdef CONFIG_MAC80211_DEBUGFS
> 
> ---
> 0-DAY kernel test infrastructure                Open Source Technology 
> Center
> https://lists.01.org/pipermail/kbuild-all                   Intel 
> Corporation
diff mbox

Patch

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)
 {