qcacld-3.0: Make tx resource hi/low threshold configurable

Make tx resource hi/low threshold configurable through
config files and update hi threashold from 7.5% to 8%.

Change-Id: I2e52b7910caedf6e0af24242b79e1e9d42c6b85b
CRs-Fixed: 2548100
diff --git a/Kbuild b/Kbuild
index b3fab26..622a66f 100644
--- a/Kbuild
+++ b/Kbuild
@@ -2889,6 +2889,14 @@
 ccflags-y += -DCFG_TGT_AST_SKID_LIMIT=$(CONFIG_CFG_TGT_AST_SKID_LIMIT)
 endif
 
+ifdef CONFIG_TX_RESOURCE_HIGH_TH_IN_PER
+ccflags-y += -DTX_RESOURCE_HIGH_TH_IN_PER=$(CONFIG_TX_RESOURCE_HIGH_TH_IN_PER)
+endif
+
+ifdef CONFIG_TX_RESOURCE_LOW_TH_IN_PER
+ccflags-y += -DTX_RESOURCE_LOW_TH_IN_PER=$(CONFIG_TX_RESOURCE_LOW_TH_IN_PER)
+endif
+
 CONFIG_WLAN_MAX_PSOCS ?= 1
 ccflags-y += -DWLAN_MAX_PSOCS=$(CONFIG_WLAN_MAX_PSOCS)
 
diff --git a/configs/genoa.sdio.debug_defconfig b/configs/genoa.sdio.debug_defconfig
index 9784ac5..bc5038e 100644
--- a/configs/genoa.sdio.debug_defconfig
+++ b/configs/genoa.sdio.debug_defconfig
@@ -13,6 +13,8 @@
 # Data Path specific features
 CONFIG_ATH_11AC_TXCOMPACT := n
 CONFIG_QCA_HL_NETDEV_FLOW_CONTROL := y
+CONFIG_TX_RESOURCE_HIGH_TH_IN_PER := 8
+CONFIG_TX_RESOURCE_LOW_TH_IN_PER := 2
 CONFIG_FEATURE_HL_GROUP_CREDIT_FLOW_CONTROL := y
 CONFIG_FEATURE_HL_DBS_GROUP_CREDIT_SHARING := y
 CONFIG_CREDIT_REP_THROUGH_CREDIT_UPDATE := y
diff --git a/configs/genoa.sdio.perf_defconfig b/configs/genoa.sdio.perf_defconfig
index e8b73d7..7faff21 100644
--- a/configs/genoa.sdio.perf_defconfig
+++ b/configs/genoa.sdio.perf_defconfig
@@ -13,6 +13,8 @@
 # Data Path specific features
 CONFIG_ATH_11AC_TXCOMPACT := n
 CONFIG_QCA_HL_NETDEV_FLOW_CONTROL := y
+CONFIG_TX_RESOURCE_HIGH_TH_IN_PER := 8
+CONFIG_TX_RESOURCE_LOW_TH_IN_PER := 2
 CONFIG_FEATURE_HL_GROUP_CREDIT_FLOW_CONTROL := y
 CONFIG_FEATURE_HL_DBS_GROUP_CREDIT_SHARING := y
 CONFIG_CREDIT_REP_THROUGH_CREDIT_UPDATE := y
diff --git a/configs/genoa.usb.debug_defconfig b/configs/genoa.usb.debug_defconfig
index 15fe2c7..c8475b6 100644
--- a/configs/genoa.usb.debug_defconfig
+++ b/configs/genoa.usb.debug_defconfig
@@ -10,6 +10,8 @@
 # Data Path specific features
 CONFIG_ATH_11AC_TXCOMPACT := n
 CONFIG_QCA_HL_NETDEV_FLOW_CONTROL := y
+CONFIG_TX_RESOURCE_HIGH_TH_IN_PER := 8
+CONFIG_TX_RESOURCE_LOW_TH_IN_PER := 2
 CONFIG_FEATURE_HL_GROUP_CREDIT_FLOW_CONTROL := y
 CONFIG_FEATURE_HL_DBS_GROUP_CREDIT_SHARING := y
 CONFIG_CREDIT_REP_THROUGH_CREDIT_UPDATE := y
diff --git a/configs/genoa.usb.perf_defconfig b/configs/genoa.usb.perf_defconfig
index 1b54255..c0cbeca 100644
--- a/configs/genoa.usb.perf_defconfig
+++ b/configs/genoa.usb.perf_defconfig
@@ -10,6 +10,8 @@
 # Data Path specific features
 CONFIG_ATH_11AC_TXCOMPACT := n
 CONFIG_QCA_HL_NETDEV_FLOW_CONTROL := y
+CONFIG_TX_RESOURCE_HIGH_TH_IN_PER := 8
+CONFIG_TX_RESOURCE_LOW_TH_IN_PER := 2
 CONFIG_FEATURE_HL_GROUP_CREDIT_FLOW_CONTROL := y
 CONFIG_FEATURE_HL_DBS_GROUP_CREDIT_SHARING := y
 CONFIG_CREDIT_REP_THROUGH_CREDIT_UPDATE := y
diff --git a/core/dp/txrx/ol_tx_hl.c b/core/dp/txrx/ol_tx_hl.c
index 1f1e5d5..ec4201d 100644
--- a/core/dp/txrx/ol_tx_hl.c
+++ b/core/dp/txrx/ol_tx_hl.c
@@ -56,6 +56,17 @@
 #include <wlan_reg_services_api.h>
 #include "qdf_hrtimer.h"
 
+/* High/Low tx resource count in percentage */
+/* Set default high threashold to 15% */
+#ifndef TX_RESOURCE_HIGH_TH_IN_PER
+#define TX_RESOURCE_HIGH_TH_IN_PER 15
+#endif
+
+/* Set default low threshold to 5% */
+#ifndef TX_RESOURCE_LOW_TH_IN_PER
+#define TX_RESOURCE_LOW_TH_IN_PER 5
+#endif
+
 #ifdef QCA_HL_NETDEV_FLOW_CONTROL
 static u16 ol_txrx_tx_desc_alloc_table[TXRX_FC_MAX] = {
 	[TXRX_FC_5GH_80M_2x2] = 2000,
@@ -228,56 +239,14 @@
 }
 #endif
 
-#ifdef QCA_HL_NETDEV_FLOW_CONTROL
-/**
- * ol_txrx_rsrc_threshold_lo() - set threshold low - when to start tx desc
- *				 margin replenishment
- * @desc_pool_size: tx desc pool size
- *
- * Return: threshold low
- */
 static inline uint16_t
 ol_txrx_rsrc_threshold_lo(int desc_pool_size)
 {
 	int threshold_low;
 
-	/*
-	 * 5% margin of unallocated desc is too much for per
-	 * vdev mechanism.
-	 * Define the value separately.
-	 */
-	threshold_low = TXRX_HL_TX_FLOW_CTRL_MGMT_RESERVED;
-
-	return threshold_low;
-}
-
-/**
- * ol_txrx_rsrc_threshold_hi() - set threshold high - where to stop
- *				 during tx desc margin replenishment
- * @desc_pool_size: tx desc pool size
- *
- * Return: threshold high
- */
-static inline uint16_t
-ol_txrx_rsrc_threshold_hi(int desc_pool_size)
-{
-	int threshold_high;
-	/* when freeing up descriptors,
-	 * keep going until there's a 7.5% margin
-	 */
-	threshold_high = ((15 * desc_pool_size) / 100) / 2;
-
-	return threshold_high;
-}
-
-#else
-
-static inline uint16_t
-ol_txrx_rsrc_threshold_lo(int desc_pool_size)
-{
-	int threshold_low;
 	/* always maintain a 5% margin of unallocated descriptors */
-	threshold_low = (5 * desc_pool_size) / 100;
+	threshold_low = ((TX_RESOURCE_LOW_TH_IN_PER) *
+			 desc_pool_size) / 100;
 
 	return threshold_low;
 }
@@ -289,11 +258,11 @@
 	/* when freeing up descriptors, keep going until
 	 * there's a 15% margin
 	 */
-	threshold_high = (15 * desc_pool_size) / 100;
+	threshold_high = ((TX_RESOURCE_HIGH_TH_IN_PER) *
+			  desc_pool_size) / 100;
 
 	return threshold_high;
 }
-#endif
 
 void ol_tx_init_pdev(ol_txrx_pdev_handle pdev)
 {