qcacmn: Add helper functions to fetch ini config for flow tagging

Add helper functions to fetch ini settings for flow tag enable,
flow search table size, global/pdev table selection, monitor mode
enable/disable of protocol & flow tags

CRs-Fixed: 2475913
Change-Id: I66d477d145ea04809bfc17ba3b88a6b8580854a1
diff --git a/wlan_cfg/cfg_dp.h b/wlan_cfg/cfg_dp.h
index ef0172b..bc51ed8 100644
--- a/wlan_cfg/cfg_dp.h
+++ b/wlan_cfg/cfg_dp.h
@@ -307,6 +307,10 @@
 #define WLAN_CFG_RX_SW_DESC_WEIGHT_SIZE_MAX 3
 #endif //QCA_HOST2FW_RXBUF_RING
 
+#define WLAN_CFG_RX_FLOW_SEARCH_TABLE_SIZE 16384
+#define WLAN_CFG_RX_FLOW_SEARCH_TABLE_SIZE_MIN 1
+#define WLAN_CFG_RX_FLOW_SEARCH_TABLE_SIZE_MAX 16384
+
 /* DP INI Declerations */
 #define CFG_DP_HTT_PACKET_TYPE \
 		CFG_INI_UINT("dp_htt_packet_type", \
@@ -720,6 +724,26 @@
 		WLAN_CFG_RX_SW_DESC_WEIGHT_SIZE, \
 		CFG_VALUE_OR_DEFAULT, "DP RX SW DESC weight")
 
+#define CFG_DP_RX_FLOW_SEARCH_TABLE_SIZE \
+	CFG_INI_UINT("dp_rx_flow_search_table_size", \
+		WLAN_CFG_RX_FLOW_SEARCH_TABLE_SIZE_MIN, \
+		WLAN_CFG_RX_FLOW_SEARCH_TABLE_SIZE_MAX, \
+		WLAN_CFG_RX_FLOW_SEARCH_TABLE_SIZE, \
+		CFG_VALUE_OR_DEFAULT, \
+		"DP Rx Flow Search Table Size in number of entries")
+
+#define CFG_DP_RX_FLOW_TAG_ENABLE \
+	CFG_INI_BOOL("dp_rx_flow_tag_enable", false, \
+		     "Enable/Disable DP Rx Flow Tag")
+
+#define CFG_DP_RX_FLOW_SEARCH_TABLE_PER_PDEV \
+	CFG_INI_BOOL("dp_rx_per_pdev_flow_search", false, \
+			"DP Rx Flow Search Table Is Per PDev")
+
+#define CFG_DP_RX_MON_PROTOCOL_FLOW_TAG_ENABLE \
+	CFG_INI_BOOL("dp_rx_monitor_protocol_flow_tag_enable", true, \
+		     "Enable/Disable Rx Protocol & Flow tags in Monitor mode")
+
 #define CFG_DP \
 		CFG(CFG_DP_HTT_PACKET_TYPE) \
 		CFG(CFG_DP_INT_BATCH_THRESHOLD_OTHER) \
@@ -785,7 +809,10 @@
 		CFG(CFG_DP_REORDER_OFFLOAD_SUPPORT) \
 		CFG(CFG_DP_AP_STA_SECURITY_SEPERATION) \
 		CFG(CFG_DP_ENABLE_DATA_STALL_DETECTION) \
-		CFG(CFG_DP_RX_SW_DESC_WEIGHT)
-
+		CFG(CFG_DP_RX_SW_DESC_WEIGHT) \
+		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)
 
 #endif /* _CFG_DP_H_ */
diff --git a/wlan_cfg/wlan_cfg.c b/wlan_cfg/wlan_cfg.c
index ae2598e..b578463 100644
--- a/wlan_cfg/wlan_cfg.c
+++ b/wlan_cfg/wlan_cfg.c
@@ -279,6 +279,14 @@
 	*wlan_cfg = g_wlan_srng_cfg;
 }
 
+static const uint8_t rx_fst_toeplitz_key[WLAN_CFG_RX_FST_TOEPLITZ_KEYLEN] = {
+	0x6d, 0x5a, 0x56, 0xda, 0x25, 0x5b, 0x0e, 0xc2,
+	0x41, 0x67, 0x25, 0x3d, 0x43, 0xa3, 0x8f, 0xb0,
+	0xd0, 0xca, 0x2b, 0xcb, 0xae, 0x7b, 0x30, 0xb4,
+	0x77, 0xcb, 0x2d, 0xa3, 0x80, 0x30, 0xf2, 0x0c,
+	0x6a, 0x42, 0xb7, 0x3b, 0xbe, 0xac, 0x01, 0xfa
+};
+
 /**
  * wlan_cfg_soc_attach() - Allocate and prepare SoC configuration
  * @psoc - Object manager psoc
@@ -422,6 +430,17 @@
 		cfg_get(psoc, CFG_DP_AP_STA_SECURITY_SEPERATION);
 	wlan_cfg_ctx->rx_sw_desc_weight = cfg_get(psoc,
 						   CFG_DP_RX_SW_DESC_WEIGHT);
+	wlan_cfg_ctx->rx_toeplitz_hash_key = (uint8_t *)rx_fst_toeplitz_key;
+	wlan_cfg_ctx->rx_flow_max_search = WLAN_CFG_RX_FST_MAX_SEARCH;
+	wlan_cfg_ctx->is_rx_flow_tag_enabled =
+			cfg_get(psoc, CFG_DP_RX_FLOW_TAG_ENABLE);
+	wlan_cfg_ctx->is_rx_flow_search_table_per_pdev =
+			cfg_get(psoc, CFG_DP_RX_FLOW_SEARCH_TABLE_PER_PDEV);
+	wlan_cfg_ctx->rx_flow_search_table_size =
+			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);
+
 	return wlan_cfg_ctx;
 }
 
@@ -1035,3 +1054,61 @@
 	return cfg->tx_flow_start_queue_offset;
 }
 #endif /* QCA_LL_TX_FLOW_CONTROL_V2 */
+
+void wlan_cfg_set_rx_flow_tag_enabled(struct wlan_cfg_dp_soc_ctxt *cfg,
+				      bool val)
+{
+	cfg->is_rx_flow_tag_enabled = val;
+}
+
+uint8_t *wlan_cfg_rx_fst_get_hash_key(struct wlan_cfg_dp_soc_ctxt *cfg)
+{
+	return cfg->rx_toeplitz_hash_key;
+}
+
+uint8_t wlan_cfg_rx_fst_get_max_search(struct wlan_cfg_dp_soc_ctxt *cfg)
+{
+	return cfg->rx_flow_max_search;
+}
+
+bool wlan_cfg_is_rx_flow_tag_enabled(struct wlan_cfg_dp_soc_ctxt *cfg)
+{
+	return cfg->is_rx_flow_tag_enabled;
+}
+
+void
+wlan_cfg_set_rx_flow_search_table_per_pdev(struct wlan_cfg_dp_soc_ctxt *cfg,
+					   bool val)
+{
+	cfg->is_rx_flow_search_table_per_pdev = val;
+}
+
+bool wlan_cfg_is_rx_flow_search_table_per_pdev(struct wlan_cfg_dp_soc_ctxt *cfg)
+{
+	return cfg->is_rx_flow_search_table_per_pdev;
+}
+
+void wlan_cfg_set_rx_flow_search_table_size(struct wlan_cfg_dp_soc_ctxt *cfg,
+					    uint16_t val)
+{
+	cfg->rx_flow_search_table_size = val;
+}
+
+uint16_t
+wlan_cfg_get_rx_flow_search_table_size(struct wlan_cfg_dp_soc_ctxt *cfg)
+{
+	return  cfg->rx_flow_search_table_size;
+}
+
+void
+wlan_cfg_set_rx_mon_protocol_flow_tag_enabled(struct wlan_cfg_dp_soc_ctxt *cfg,
+					      bool val)
+{
+	cfg->is_rx_mon_protocol_flow_tag_enabled = val;
+}
+
+bool
+wlan_cfg_is_rx_mon_protocol_flow_tag_enabled(struct wlan_cfg_dp_soc_ctxt *cfg)
+{
+	return cfg->is_rx_mon_protocol_flow_tag_enabled;
+}
diff --git a/wlan_cfg/wlan_cfg.h b/wlan_cfg/wlan_cfg.h
index e27b8d3..1d0b6a2 100644
--- a/wlan_cfg/wlan_cfg.h
+++ b/wlan_cfg/wlan_cfg.h
@@ -74,6 +74,9 @@
 #define DP_MAX_TIDS 17
 #define DP_NON_QOS_TID 16
 
+#define WLAN_CFG_RX_FST_MAX_SEARCH 2
+#define WLAN_CFG_RX_FST_TOEPLITZ_KEYLEN 40
+
 struct wlan_cfg_dp_pdev_ctxt;
 
 /**
@@ -157,9 +160,19 @@
  * @rx_hp_oos_update_limit: Max # of HP OOS (out of sync) updates
  * @rx_enable_eol_data_check: flag to enable check for more ring data at end of
  *                            dp_rx_process loop
- * tx_comp_enable_eol_data_check: flag to enable/disable checking for more data
+ * @tx_comp_enable_eol_data_check: flag to enable/disable checking for more data
  *                                at end of tx_comp_handler loop.
  * @rx_sw_desc_weight: rx sw descriptor weight configuration
+ * @is_rx_mon_protocol_flow_tag_enabled: flag to enable/disable RX protocol or
+ *                                       flow tagging in monitor/mon-lite mode
+ * @is_rx_flow_tag_enabled: flag to enable/disable RX flow tagging using FSE
+ * @is_rx_flow_search_table_per_pdev: flag to indicate if a per-SOC or per-pdev
+ *                                    table should be used
+ * @rx_flow_search_table_size: indicates the number of flows in the flow search
+ *                             table
+ * @rx_flow_max_search: max skid length for each hash entry
+ * @rx_toeplitz_hash_key: toeplitz key pointer used for hash computation over
+ *                        5 tuple flow entry
  */
 struct wlan_cfg_dp_soc_ctxt {
 	int num_int_ctxts;
@@ -247,6 +260,12 @@
 	bool tx_comp_enable_eol_data_check;
 #endif /* WLAN_FEATURE_RX_SOFTIRQ_TIME_LIMIT */
 	int rx_sw_desc_weight;
+	bool is_rx_mon_protocol_flow_tag_enabled;
+	bool is_rx_flow_tag_enabled;
+	bool is_rx_flow_search_table_per_pdev;
+	uint16_t rx_flow_search_table_size;
+	uint16_t rx_flow_max_search;
+	uint8_t *rx_toeplitz_hash_key;
 };
 
 /**
@@ -1104,4 +1123,108 @@
 
 int wlan_cfg_get_defrag_timeout_check(struct wlan_cfg_dp_soc_ctxt *cfg);
 
+/**
+ * wlan_cfg_get_rx_flow_search_table_size() - Return the size of Rx FST
+ *                                            in number of entries
+ *
+ * @wlan_cfg_dp_soc_ctxt: soc configuration context
+ *
+ * Return: rx_fst_size
+ */
+uint16_t
+wlan_cfg_get_rx_flow_search_table_size(struct wlan_cfg_dp_soc_ctxt *cfg);
+
+/**
+ * wlan_cfg_rx_fst_get_max_search() - Return the max skid length for FST search
+ *
+ * @wlan_cfg_dp_soc_ctxt: soc configuration context
+ *
+ * Return: max_search
+ */
+uint8_t wlan_cfg_rx_fst_get_max_search(struct wlan_cfg_dp_soc_ctxt *cfg);
+
+/**
+ * wlan_cfg_rx_fst_get_hash_key() - Return Toeplitz Hash Key used for FST
+ *                                  search
+ *
+ * @wlan_cfg_dp_soc_ctxt: soc configuration context
+ *
+ * Return: 320-bit Hash Key
+ */
+uint8_t *wlan_cfg_rx_fst_get_hash_key(struct wlan_cfg_dp_soc_ctxt *cfg);
+
+/**
+ * wlan_cfg_set_rx_flow_tag_enabled() - set rx flow tag enabled flag in
+ *                                      DP soc context
+ * @wlan_cfg_dp_soc_ctxt: soc configuration context
+ * @val: Rx flow tag feature flag value
+ *
+ * Return: None
+ */
+void wlan_cfg_set_rx_flow_tag_enabled(struct wlan_cfg_dp_soc_ctxt *cfg,
+				      bool val);
+
+/**
+ * wlan_cfg_is_rx_flow_tag_enabled() - get rx flow tag enabled flag from
+ *                                     DP soc context
+ * @wlan_cfg_dp_soc_ctxt: soc configuration context
+ *
+ * Return: true if feature is enabled, else false
+ */
+bool wlan_cfg_is_rx_flow_tag_enabled(struct wlan_cfg_dp_soc_ctxt *cfg);
+
+/**
+ * wlan_cfg_set_rx_flow_search_table_per_pdev() - Set flag to indicate that
+ *                                                Rx FST is per pdev
+ * @wlan_cfg_dp_soc_ctxt: soc configuration context
+ * @val: boolean flag indicating Rx FST per pdev or per SOC
+ *
+ * Return: None
+ */
+void
+wlan_cfg_set_rx_flow_search_table_per_pdev(struct wlan_cfg_dp_soc_ctxt *cfg,
+					   bool val);
+
+/**
+ * wlan_cfg_is_rx_flow_search_table_per_pdev() - get RX FST flag for per pdev
+ * @wlan_cfg_dp_soc_ctxt: soc configuration context
+ *
+ * Return: true if Rx FST is per pdev, else false
+ */
+bool
+wlan_cfg_is_rx_flow_search_table_per_pdev(struct wlan_cfg_dp_soc_ctxt *cfg);
+
+/**
+ * wlan_cfg_set_rx_flow_search_table_size() - set RX FST size in DP SoC context
+ * @wlan_cfg_dp_soc_ctxt: soc configuration context
+ * @val: Rx FST size in number of entries
+ *
+ * Return: None
+ */
+void
+wlan_cfg_set_rx_flow_search_table_size(struct wlan_cfg_dp_soc_ctxt *cfg,
+				       uint16_t val);
+
+/**
+ * wlan_cfg_set_rx_mon_protocol_flow_tag_enabled() - set mon rx tag enabled flag
+ *                                                   in DP soc context
+ * @wlan_cfg_dp_soc_ctxt: soc configuration context
+ * @val: Rx protocol or flow tag feature flag value in monitor mode from INI
+ *
+ * Return: None
+ */
+void
+wlan_cfg_set_rx_mon_protocol_flow_tag_enabled(struct wlan_cfg_dp_soc_ctxt *cfg,
+					      bool val);
+
+/**
+ * wlan_cfg_is_rx_mon_protocol_flow_tag_enabled() - get mon rx tag enabled flag
+ *                                                  from DP soc context
+ * @wlan_cfg_dp_soc_ctxt: soc configuration context
+ *
+ * Return: true if feature is enabled in monitor mode for protocol or flow
+ * tagging in INI, false otherwise
+ */
+bool
+wlan_cfg_is_rx_mon_protocol_flow_tag_enabled(struct wlan_cfg_dp_soc_ctxt *cfg);
 #endif