From: Sven Eckelmann <sven@narfation.org>
Date: Mon, 18 Jun 2018 21:03:37 +0200
Subject: ath10k-ct: reduce memory consumption

ath10k uses a rather high number of buffers to communicate with the QCA
firmware. Especially the HTC (host-target-communication) and HTT
(host-target-transport) can take up a lot of memory when data is
transferred over a ath10k wifi link.

This problem was already worked around in commit cc189c0b7fa0 ("mac80211:
enable ath10k AHB support for QCA4019") for the ath10k driver from
mac80211. But this change was forgotton for the ath10k-ct driver.

Signed-off-by: Sven Eckelmann <sven@narfation.org>

Forwarded: https://github.com/openwrt/openwrt/pull/1077

diff --git a/package/kernel/ath10k-ct/patches/960-0010-ath10k-limit-htt-rx-ring-size.patch b/package/kernel/ath10k-ct/patches/960-0010-ath10k-limit-htt-rx-ring-size.patch
new file mode 100644
index 0000000000000000000000000000000000000000..7ee89be9cc4c7602db10dc6c118b803e3b130192
--- /dev/null
+++ b/package/kernel/ath10k-ct/patches/960-0010-ath10k-limit-htt-rx-ring-size.patch
@@ -0,0 +1,11 @@
+--- a/ath10k-4.13/htt.h
++++ b/ath10k-4.13/htt.h
+@@ -199,7 +199,7 @@ enum htt_rx_ring_flags {
+ };
+ 
+ #define HTT_RX_RING_SIZE_MIN 128
+-#define HTT_RX_RING_SIZE_MAX 2048
++#define HTT_RX_RING_SIZE_MAX 512
+ 
+ struct htt_rx_ring_setup_ring {
+ 	__le32 fw_idx_shadow_reg_paddr;
diff --git a/package/kernel/ath10k-ct/patches/960-0011-ath10k-limit-pci-buffer-size.patch b/package/kernel/ath10k-ct/patches/960-0011-ath10k-limit-pci-buffer-size.patch
new file mode 100644
index 0000000000000000000000000000000000000000..82ccb88ccbf341ab63da8fd12aeb13ff468cc98a
--- /dev/null
+++ b/package/kernel/ath10k-ct/patches/960-0011-ath10k-limit-pci-buffer-size.patch
@@ -0,0 +1,38 @@
+--- a/ath10k-4.13/pci.c
++++ b/ath10k-4.13/pci.c
+@@ -128,7 +128,7 @@ static struct ce_attr host_ce_config_wla
+ 		.flags = CE_ATTR_FLAGS,
+ 		.src_nentries = 0,
+ 		.src_sz_max = 2048,
+-		.dest_nentries = 512,
++		.dest_nentries = 128,
+ 		.recv_cb = ath10k_pci_htt_htc_rx_cb,
+ 	},
+ 
+@@ -137,7 +137,7 @@ static struct ce_attr host_ce_config_wla
+ 		.flags = CE_ATTR_FLAGS,
+ 		.src_nentries = 0,
+ 		.src_sz_max = 2048,
+-		.dest_nentries = 128,
++		.dest_nentries = 64,
+ 		.recv_cb = ath10k_pci_htc_rx_cb,
+ 	},
+ 
+@@ -164,7 +164,7 @@ static struct ce_attr host_ce_config_wla
+ 		.flags = CE_ATTR_FLAGS,
+ 		.src_nentries = 0,
+ 		.src_sz_max = 512,
+-		.dest_nentries = 512,
++		.dest_nentries = 128,
+ 		.recv_cb = ath10k_pci_htt_rx_cb,
+ 	},
+ 
+@@ -189,7 +189,7 @@ static struct ce_attr host_ce_config_wla
+ 		.flags = CE_ATTR_FLAGS,
+ 		.src_nentries = 0,
+ 		.src_sz_max = 2048,
+-		.dest_nentries = 128,
++		.dest_nentries = 96,
+ 		.recv_cb = ath10k_pci_pktlog_rx_cb,
+ 	},
+ 
