qcacmn: monitor RXDMA drop feature

Adds new INI variable for threshold control.
Host sends message to target with new threshold info.
If buffer reaches threshold then MAC drops incoming monitor frames.

Change-Id: Id659d7df68a5ec0b22fb571dc1ffa4990f8fcc4f
diff --git a/dp/wifi3.0/dp_htt.c b/dp/wifi3.0/dp_htt.c
index 8b0f85d..b05fe27 100644
--- a/dp/wifi3.0/dp_htt.c
+++ b/dp/wifi3.0/dp_htt.c
@@ -1013,6 +1013,8 @@
 	uint32_t htt_ring_type, htt_ring_id;
 	uint32_t tlv_filter;
 	uint8_t *htt_logger_bufp;
+	struct wlan_cfg_dp_soc_ctxt *wlan_cfg_ctx = soc->dp_soc->wlan_cfg_ctx;
+	uint32_t mon_drop_th = wlan_cfg_get_mon_drop_thresh(wlan_cfg_ctx);
 
 	htt_msg = qdf_nbuf_alloc(soc->osdev,
 		HTT_MSG_BUF_SIZE(HTT_RX_RING_SELECTION_CFG_SZ),
@@ -1101,6 +1103,13 @@
 	HTT_RX_RING_SELECTION_CFG_RX_OFFSETS_VALID_SET(*msg_word,
 						htt_tlv_filter->offset_valid);
 
+	if (mon_drop_th > 0)
+		HTT_RX_RING_SELECTION_CFG_DROP_THRESHOLD_VALID_SET(*msg_word,
+								   1);
+	else
+		HTT_RX_RING_SELECTION_CFG_DROP_THRESHOLD_VALID_SET(*msg_word,
+								   0);
+
 	/* word 1 */
 	msg_word++;
 	*msg_word = 0;
@@ -1664,8 +1673,17 @@
 		*msg_word = 0;
 		HTT_RX_RING_SELECTION_CFG_RX_ATTENTION_OFFSET_SET(*msg_word,
 					htt_tlv_filter->rx_attn_offset);
+		msg_word++;
+		*msg_word = 0;
+	} else {
+		msg_word += 4;
+		*msg_word = 0;
 	}
 
+	if (mon_drop_th > 0)
+		HTT_RX_RING_SELECTION_CFG_RX_DROP_THRESHOLD_SET(*msg_word,
+								mon_drop_th);
+
 	/* "response_required" field should be set if a HTT response message is
 	 * required after setting up the ring.
 	 */
diff --git a/wlan_cfg/cfg_dp.h b/wlan_cfg/cfg_dp.h
index 781acee..9c990d0 100644
--- a/wlan_cfg/cfg_dp.h
+++ b/wlan_cfg/cfg_dp.h
@@ -277,6 +277,10 @@
 #define WLAN_CFG_RXDMA_ERR_DST_RING_SIZE_MIN 1024
 #define WLAN_CFG_RXDMA_ERR_DST_RING_SIZE_MAX 8192
 
+#define WLAN_CFG_RXDMA_MONITOR_RX_DROP_THRESH_SIZE 32
+#define WLAN_CFG_RXDMA_MONITOR_RX_DROP_THRESH_SIZE_MIN 0
+#define WLAN_CFG_RXDMA_MONITOR_RX_DROP_THRESH_SIZE_MAX 256
+
 /**
  * Allocate as many RX descriptors as buffers in the SW2RXDMA
  * ring. This value may need to be tuned later.
@@ -744,6 +748,13 @@
 	CFG_INI_BOOL("dp_rx_monitor_protocol_flow_tag_enable", true, \
 		     "Enable/Disable Rx Protocol & Flow tags in Monitor mode")
 
+#define CFG_DP_RXDMA_MONITOR_RX_DROP_THRESHOLD \
+		CFG_INI_UINT("mon_drop_thresh", \
+		WLAN_CFG_RXDMA_MONITOR_RX_DROP_THRESH_SIZE_MIN, \
+		WLAN_CFG_RXDMA_MONITOR_RX_DROP_THRESH_SIZE_MAX, \
+		WLAN_CFG_RXDMA_MONITOR_RX_DROP_THRESH_SIZE, \
+		CFG_VALUE_OR_DEFAULT, "RXDMA monitor rx drop theshold")
+
 #define CFG_DP \
 		CFG(CFG_DP_HTT_PACKET_TYPE) \
 		CFG(CFG_DP_INT_BATCH_THRESHOLD_OTHER) \
@@ -813,6 +824,6 @@
 		CFG(CFG_DP_RX_FLOW_SEARCH_TABLE_SIZE) \
 		CFG(CFG_DP_RX_FLOW_TAG_ENABLE) \
 		CFG(CFG_DP_RX_FLOW_SEARCH_TABLE_PER_PDEV) \
-		CFG(CFG_DP_RX_MON_PROTOCOL_FLOW_TAG_ENABLE)
-
+		CFG(CFG_DP_RX_MON_PROTOCOL_FLOW_TAG_ENABLE) \
+		CFG(CFG_DP_RXDMA_MONITOR_RX_DROP_THRESHOLD)
 #endif /* _CFG_DP_H_ */
diff --git a/wlan_cfg/wlan_cfg.c b/wlan_cfg/wlan_cfg.c
index b578463..09e4915 100644
--- a/wlan_cfg/wlan_cfg.c
+++ b/wlan_cfg/wlan_cfg.c
@@ -440,7 +440,8 @@
 			cfg_get(psoc, CFG_DP_RX_FLOW_SEARCH_TABLE_SIZE);
 	wlan_cfg_ctx->is_rx_mon_protocol_flow_tag_enabled =
 			cfg_get(psoc, CFG_DP_RX_MON_PROTOCOL_FLOW_TAG_ENABLE);
-
+	wlan_cfg_ctx->mon_drop_thresh =
+		cfg_get(psoc, CFG_DP_RXDMA_MONITOR_RX_DROP_THRESHOLD);
 	return wlan_cfg_ctx;
 }
 
@@ -479,6 +480,11 @@
 		qdf_mem_free(wlan_cfg_ctx);
 }
 
+int wlan_cfg_get_mon_drop_thresh(struct wlan_cfg_dp_soc_ctxt *cfg)
+{
+	return cfg->mon_drop_thresh;
+}
+
 void wlan_cfg_set_num_contexts(struct wlan_cfg_dp_soc_ctxt *cfg, int num)
 {
 	cfg->num_int_ctxts = num;
diff --git a/wlan_cfg/wlan_cfg.h b/wlan_cfg/wlan_cfg.h
index 1d0b6a2..250b872 100644
--- a/wlan_cfg/wlan_cfg.h
+++ b/wlan_cfg/wlan_cfg.h
@@ -252,6 +252,7 @@
 	int tx_desc_limit_2;
 	int tx_device_limit;
 	int tx_sw_internode_queue;
+	int mon_drop_thresh;
 #ifdef WLAN_FEATURE_RX_SOFTIRQ_TIME_LIMIT
 	uint32_t tx_comp_loop_pkt_limit;
 	uint32_t rx_reap_loop_pkt_limit;
@@ -344,6 +345,7 @@
 void wlan_cfg_set_max_peer_id(struct wlan_cfg_dp_soc_ctxt *cfg, uint32_t val);
 void wlan_cfg_set_max_ast_idx(struct wlan_cfg_dp_soc_ctxt *cfg, uint32_t val);
 int wlan_cfg_get_max_ast_idx(struct wlan_cfg_dp_soc_ctxt *cfg);
+int wlan_cfg_get_mon_drop_thresh(struct wlan_cfg_dp_soc_ctxt *cfg);
 int wlan_cfg_set_rx_err_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,
 				int context, int mask);
 int wlan_cfg_set_rx_wbm_rel_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,