qcacmn: Flush REO descriptors entirely

To avoid race conditions where BA window size can change, always
flush entire REO descriptor from HW cache irrespective of current
BA window size.

Change-Id: I608996722e7dc2dc6acfd145b8c190b58ce09822
CRs-Fixed: 2251811
diff --git a/dp/wifi3.0/dp_peer.c b/dp/wifi3.0/dp_peer.c
index 43a6c3f..a958405 100644
--- a/dp/wifi3.0/dp_peer.c
+++ b/dp/wifi3.0/dp_peer.c
@@ -1495,9 +1495,7 @@
 	rx_tid->delba_tx_success_cnt = 0;
 	rx_tid->delba_tx_fail_cnt = 0;
 	rx_tid->statuscode = 0;
-#ifdef notyet
-	hw_qdesc_size = hal_get_reo_qdesc_size(soc->hal_soc, ba_window_size);
-#else
+
 	/* TODO: Allocating HW queue descriptors based on max BA window size
 	 * for all QOS TIDs so that same descriptor can be used later when
 	 * ADDBA request is recevied. This should be changed to allocate HW
@@ -1508,11 +1506,10 @@
 	 */
 	if (tid != DP_NON_QOS_TID)
 		hw_qdesc_size = hal_get_reo_qdesc_size(soc->hal_soc,
-			HAL_RX_MAX_BA_WINDOW);
+			HAL_RX_MAX_BA_WINDOW, tid);
 	else
 		hw_qdesc_size = hal_get_reo_qdesc_size(soc->hal_soc,
-			ba_window_size);
-#endif
+			ba_window_size, tid);
 
 	hw_qdesc_align = hal_get_reo_qdesc_align(soc->hal_soc);
 	/* To avoid unnecessary extra allocation for alignment, try allocating
@@ -1670,9 +1667,10 @@
 
 		/* Flush and invalidate REO descriptor from HW cache: Base and
 		 * extension descriptors should be flushed separately */
-		tot_desc_size = hal_get_reo_qdesc_size(soc->hal_soc,
-			rx_tid->ba_win_size);
-		desc_size = hal_get_reo_qdesc_size(soc->hal_soc, 0);
+		tot_desc_size = rx_tid->hw_qdesc_alloc_size;
+		/* Get base descriptor size by passing non-qos TID */
+		desc_size = hal_get_reo_qdesc_size(soc->hal_soc, 0,
+						   DP_NON_QOS_TID);
 
 		/* Flush reo extension descriptors */
 		while ((tot_desc_size -= desc_size) > 0) {
diff --git a/hal/wifi3.0/hal_hw_headers.h b/hal/wifi3.0/hal_hw_headers.h
index 2907a47..5f516bd 100644
--- a/hal/wifi3.0/hal_hw_headers.h
+++ b/hal/wifi3.0/hal_hw_headers.h
@@ -76,6 +76,7 @@
 
 #define HAL_SRNG_REO_EXCEPTION HAL_SRNG_REO2SW1
 #define HAL_SRNG_REO_ALTERNATE_SELECT 0x7
+#define HAL_NON_QOS_TID 16
 
 /* calculate the register address offset from bar0 of shadow register x */
 #ifdef QCA_WIFI_QCA6390
@@ -320,13 +321,24 @@
  *
  * @hal_soc: Opaque HAL SOC handle
  * @ba_window_size: BlockAck window size
+ * @tid: TID number
  *
  */
 static inline uint32_t hal_get_reo_qdesc_size(void *hal_soc,
-					      uint32_t ba_window_size)
+	uint32_t ba_window_size, int tid)
 {
-	if (ba_window_size <= 1)
-		return sizeof(struct rx_reo_queue);
+	/* Return descriptor size corresponding to window size of 2 since
+	 * we set ba_window_size to 2 while setting up REO descriptors as
+	 * a WAR to get 2k jump exception aggregates are received without
+	 * a BA session.
+	 */
+	if (ba_window_size <= 1) {
+		if (tid != HAL_NON_QOS_TID)
+			return sizeof(struct rx_reo_queue) +
+				sizeof(struct rx_reo_queue_ext);
+		else
+			return sizeof(struct rx_reo_queue);
+	}
 
 	if (ba_window_size <= 105)
 		return sizeof(struct rx_reo_queue) +
diff --git a/hal/wifi3.0/hal_reo.c b/hal/wifi3.0/hal_reo.c
index 867023e..ea766e9 100644
--- a/hal/wifi3.0/hal_reo.c
+++ b/hal/wifi3.0/hal_reo.c
@@ -112,7 +112,12 @@
 
 	if (ba_window_size < 1)
 		ba_window_size = 1;
-
+	/* WAR to get 2k exception in Non BA case.
+	 * Setting window size to 2 to get 2k jump exception
+	 * when we receive aggregates in Non BA case
+	 */
+	if ((ba_window_size == 1) && (tid != HAL_NON_QOS_TID))
+		ba_window_size++;
 	/* Set RTY bit for non-BA case. Duplicate detection is currently not
 	 * done by HW in non-BA case if RTY bit is not set.
 	 * TODO: This is a temporary War and should be removed once HW fix is
diff --git a/wlan_cfg/cfg_dp.h b/wlan_cfg/cfg_dp.h
index 8e0d8dd..0f91262 100644
--- a/wlan_cfg/cfg_dp.h
+++ b/wlan_cfg/cfg_dp.h
@@ -246,13 +246,13 @@
 #define WLAN_CFG_REO_EXCEPTION_RING_SIZE_MIN 128
 #define WLAN_CFG_REO_EXCEPTION_RING_SIZE_MAX 128
 
-#define WLAN_CFG_REO_CMD_RING_SIZE 64
+#define WLAN_CFG_REO_CMD_RING_SIZE 128
 #define WLAN_CFG_REO_CMD_RING_SIZE_MIN 64
-#define WLAN_CFG_REO_CMD_RING_SIZE_MAX 64
+#define WLAN_CFG_REO_CMD_RING_SIZE_MAX 128
 
-#define WLAN_CFG_REO_STATUS_RING_SIZE 128
+#define WLAN_CFG_REO_STATUS_RING_SIZE 256
 #define WLAN_CFG_REO_STATUS_RING_SIZE_MIN 128
-#define WLAN_CFG_REO_STATUS_RING_SIZE_MAX 128
+#define WLAN_CFG_REO_STATUS_RING_SIZE_MAX 256
 
 #define WLAN_CFG_RXDMA_BUF_RING_SIZE 1024
 #define WLAN_CFG_RXDMA_BUF_RING_SIZE_MIN 1024