qcacld-3.0: fix ipa mcc tx_desc pool size

A list of ipa tx_desc is created to have a one-to-one mapping between
tx_desc from ipa driver and tx_desc in wlan. The list pool size is now
set to IpaUcTxBufCount, which is IPA wlan FW tx comp ring size and is
more like a HW resource. But the list is used only for SW MCC TX path.

Fix is to define a new INI to set hdd_ipa_tx_desc pool size. But real
size is minumum of this INI and the global tx_desc pool size.

Change-Id: I3216a4c14ac624cc313d11226909efd4f63841d0
CRs-Fixed: 2076672
diff --git a/core/hdd/src/wlan_hdd_ipa.c b/core/hdd/src/wlan_hdd_ipa.c
index aaa14b4..0561606 100644
--- a/core/hdd/src/wlan_hdd_ipa.c
+++ b/core/hdd/src/wlan_hdd_ipa.c
@@ -439,6 +439,7 @@
 	qdf_spinlock_t q_lock;
 
 	struct list_head pend_desc_head;
+	uint16_t tx_desc_size;
 	struct hdd_ipa_tx_desc *tx_desc_list;
 	struct list_head free_tx_desc_head;
 
@@ -4442,12 +4443,22 @@
 	int i;
 	uint32_t max_desc_cnt;
 	struct hdd_ipa_tx_desc *tmp_desc;
+	struct ol_txrx_pdev_t *pdev;
 
-	max_desc_cnt = hdd_ipa->hdd_ctx->config->IpaUcTxBufCount;
+	pdev = cds_get_context(QDF_MODULE_ID_TXRX);
+	if (!pdev) {
+		HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, "pdev is NULL");
+		return -ENODEV;
+	}
+
+	hdd_ipa->tx_desc_size = QDF_MIN(
+			hdd_ipa->hdd_ctx->config->IpaMccTxDescSize,
+			pdev->tx_desc.pool_size);
 
 	INIT_LIST_HEAD(&hdd_ipa->free_tx_desc_head);
 
-	tmp_desc = qdf_mem_malloc(sizeof(struct hdd_ipa_tx_desc)*max_desc_cnt);
+	tmp_desc = qdf_mem_malloc(sizeof(struct hdd_ipa_tx_desc) *
+			hdd_ipa->tx_desc_size);
 
 	if (!tmp_desc) {
 		HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR,
@@ -4458,7 +4469,7 @@
 	hdd_ipa->tx_desc_list = tmp_desc;
 
 	qdf_spin_lock_bh(&hdd_ipa->q_lock);
-	for (i = 0; i < max_desc_cnt; i++) {
+	for (i = 0; i < hdd_ipa->tx_desc_size; i++) {
 		tmp_desc->id = i;
 		tmp_desc->ipa_tx_desc_ptr = NULL;
 		list_add_tail(&tmp_desc->link,
@@ -4564,7 +4575,7 @@
 		hdd_ipa->sys_pipe[HDD_IPA_RX_PIPE].conn_hdl_valid = 1;
 	}
 
-       /* Allocate free Tx desc list */
+	/* Allocate free Tx desc list */
 	ret = hdd_ipa_alloc_tx_desc_list(hdd_ipa);
 	if (ret)
 		goto setup_sys_pipe_fail;
@@ -4591,7 +4602,6 @@
 static void hdd_ipa_teardown_sys_pipe(struct hdd_ipa_priv *hdd_ipa)
 {
 	int ret = 0, i;
-	uint32_t max_desc_cnt;
 	struct hdd_ipa_tx_desc *tmp_desc;
 	struct ipa_rx_data *ipa_tx_desc;
 
@@ -4608,10 +4618,8 @@
 	}
 
 	if (hdd_ipa->tx_desc_list) {
-		max_desc_cnt = hdd_ipa->hdd_ctx->config->IpaUcTxBufCount;
-
 		qdf_spin_lock_bh(&hdd_ipa->q_lock);
-		for (i = 0; i < max_desc_cnt; i++) {
+		for (i = 0; i < hdd_ipa->tx_desc_size; i++) {
 			tmp_desc = hdd_ipa->tx_desc_list + i;
 			ipa_tx_desc = tmp_desc->ipa_tx_desc_ptr;
 			if (ipa_tx_desc)