qcacld-3.0: Add INI parameter to enable/disable MPTA helper

Due to PTA master limitation, zigbee joining network success rate
is low while wlan is working. Wlan host driver need to configure
some parameters including Zigbee state and specific WLAN period to
enhance PTA master. This mechanism is called MPTA helper. The INI
parameter gMPTAHelperEnable is used to enable/disable this feature.

Change-Id: I070c06a00ec2c405540cc40251f5cb7fec211cbd
CRs-Fixed: 2407801
diff --git a/components/fw_offload/core/inc/wlan_fw_offload_main.h b/components/fw_offload/core/inc/wlan_fw_offload_main.h
index bae1305..84bc8eb 100644
--- a/components/fw_offload/core/inc/wlan_fw_offload_main.h
+++ b/components/fw_offload/core/inc/wlan_fw_offload_main.h
@@ -48,6 +48,7 @@
  * @bt_interference_medium_ul: Upper limit of medium level BT interference
  * @bt_interference_high_ll: Lower limit of high level BT interference
  * @bt_interference_high_ul: Upper limit of high level BT interference
+ * @btc_mpta_helper_enable: Enable/Disable tri-radio MPTA helper
  */
 struct wlan_fwol_coex_config {
 	uint8_t btc_mode;
@@ -61,6 +62,9 @@
 	int16_t bt_interference_medium_ul;
 	int16_t bt_interference_high_ll;
 	int16_t bt_interference_high_ul;
+#ifdef FEATURE_MPTA_HELPER
+	bool    btc_mpta_helper_enable;
+#endif
 };
 
 #define FWOL_THERMAL_LEVEL_MAX 4
diff --git a/components/fw_offload/core/src/wlan_fw_offload_main.c b/components/fw_offload/core/src/wlan_fw_offload_main.c
index d118919..860789e 100644
--- a/components/fw_offload/core/src/wlan_fw_offload_main.c
+++ b/components/fw_offload/core/src/wlan_fw_offload_main.c
@@ -29,6 +29,29 @@
 						     WLAN_UMAC_COMP_FWOL);
 }
 
+/**
+ * fwol_mpta_helper_config_get: Populate btc_mpta_helper_enable from cfg
+ * @psoc: The global psoc handler
+ * @coex_config: The cfg structure
+ *
+ * Return: none
+ */
+#ifdef FEATURE_MPTA_HELPER
+static void
+fwol_mpta_helper_config_get(struct wlan_objmgr_psoc *psoc,
+			    struct wlan_fwol_coex_config *coex_config)
+{
+	coex_config->btc_mpta_helper_enable =
+				cfg_get(psoc, CFG_COEX_MPTA_HELPER);
+}
+#else
+static void
+fwol_mpta_helper_config_get(struct wlan_objmgr_psoc *psoc,
+			    struct wlan_fwol_coex_config *coex_config)
+{
+}
+#endif
+
 static void
 fwol_init_coex_config_in_cfg(struct wlan_objmgr_psoc *psoc,
 			     struct wlan_fwol_coex_config *coex_config)
@@ -53,6 +76,7 @@
 				cfg_get(psoc, CFG_BT_INTERFERENCE_HIGH_LL);
 	coex_config->bt_interference_high_ul =
 				cfg_get(psoc, CFG_BT_INTERFERENCE_HIGH_UL);
+	fwol_mpta_helper_config_get(psoc, coex_config);
 }
 
 static void
diff --git a/components/fw_offload/dispatcher/inc/cfg_coex.h b/components/fw_offload/dispatcher/inc/cfg_coex.h
index 11f68c0..dcac2bf 100644
--- a/components/fw_offload/dispatcher/inc/cfg_coex.h
+++ b/components/fw_offload/dispatcher/inc/cfg_coex.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012 - 2018 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2012 - 2019 The Linux Foundation. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for
  * any purpose with or without fee is hereby granted, provided that the
@@ -236,6 +236,30 @@
 			CFG_VALUE_OR_DEFAULT, \
 			"BT Interference High UL")
 
+#ifdef FEATURE_MPTA_HELPER
+/*
+ * <ini>
+ * gMPTAHelperEnable - Enable MPTA Helper
+ * @Min: 0
+ * @Max: 1
+ * @Default: 0
+ *
+ * This ini is used to enable or disable coex MPTA Helper.
+ *
+ * Usage: External
+ *
+ * </ini>
+ */
+#define CFG_COEX_MPTA_HELPER CFG_INI_BOOL( \
+		"gMPTAHelperEnable", \
+		0, \
+		"Enable/Disable MPTA Helper")
+
+#define COEX_MPTA_HELPER_CFG CFG(CFG_COEX_MPTA_HELPER)
+#else
+#define COEX_MPTA_HELPER_CFG
+#endif
+
 #define CFG_COEX_ALL \
 	CFG(CFG_BTC_MODE) \
 	CFG(CFG_ANTENNA_ISOLATION) \
@@ -247,5 +271,6 @@
 	CFG(CFG_BT_INTERFERENCE_MEDIUM_LL) \
 	CFG(CFG_BT_INTERFERENCE_MEDIUM_UL) \
 	CFG(CFG_BT_INTERFERENCE_HIGH_LL) \
-	CFG(CFG_BT_INTERFERENCE_HIGH_UL)
+	CFG(CFG_BT_INTERFERENCE_HIGH_UL) \
+	COEX_MPTA_HELPER_CFG
 #endif
diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c
index cdb8eea..0ef8770 100644
--- a/core/hdd/src/wlan_hdd_main.c
+++ b/core/hdd/src/wlan_hdd_main.c
@@ -98,6 +98,7 @@
 #include "wlan_hdd_driver_ops.h"
 #include "epping_main.h"
 #include "wlan_hdd_data_stall_detection.h"
+#include "wlan_hdd_mpta_helper.h"
 
 #include <wlan_hdd_ipa.h>
 #include "hif.h"
@@ -4715,6 +4716,10 @@
 		hdd_err("Failed to send coex BT interference level");
 		goto err;
 	}
+
+	if (wlan_hdd_mpta_helper_enable(&coex_cfg_params, &config))
+		goto err;
+
 	return 0;
 err:
 	return -EINVAL;