qcacmn: Converge FTM feature

Support for FTM to make it common between WIN and MCL.

Change-Id: I4a65ca6d73d83e71f6a04405b5c41cdddb0a3c71
CRs-fixed: 2148283
diff --git a/umac/cmn_services/inc/wlan_cmn.h b/umac/cmn_services/inc/wlan_cmn.h
index 73d487a..062d9be 100644
--- a/umac/cmn_services/inc/wlan_cmn.h
+++ b/umac/cmn_services/inc/wlan_cmn.h
@@ -118,11 +118,13 @@
  * @WLAN_UMAC_COMP_NAN:           Neighbor Aware Networking
  * @WLAN_UMAC_COMP_DFS:           DFS
  * @WLAN_UMAC_COMP_SPECTRAL:      Spectral
- * @WLAN_UMAC_COMP_ID_MAX:        Maximum components in UMAC
  * @WLAN_UMAC_COMP_OFFCHAN_TXRX:  Offchan TxRx
  * @WLAN_UMAC_COMP_SPLITMAC:      SplitMAC
  * @WLAN_UMAC_COMP_DISA:          DISA encryption test
  * @WLAN_UMAC_COMP_GREEN_AP:      Green AP
+ * @WLAN_UMAC_COMP_FTM:           FTM component
+ *
+ * @WLAN_UMAC_COMP_ID_MAX:        Maximum components in UMAC
  *
  * This id is static.
  * On Adding new component, new id has to be assigned
@@ -151,6 +153,7 @@
 	WLAN_UMAC_COMP_SPLITMAC,
 	WLAN_UMAC_COMP_DISA,
 	WLAN_UMAC_COMP_GREEN_AP,
+	WLAN_UMAC_COMP_FTM,
 	WLAN_UMAC_COMP_ID_MAX,
 };
 
diff --git a/umac/cmn_services/obj_mgr/inc/wlan_objmgr_cmn.h b/umac/cmn_services/obj_mgr/inc/wlan_objmgr_cmn.h
index 1fb88b5..3c3da3a 100644
--- a/umac/cmn_services/obj_mgr/inc/wlan_objmgr_cmn.h
+++ b/umac/cmn_services/obj_mgr/inc/wlan_objmgr_cmn.h
@@ -203,6 +203,7 @@
  * @WLAN_DEBUG_ID:              Debug operations
  * @WLAN_DIRECT_BUF_RX_ID:      Direct Buffer Receive operations
  * @WLAN_DISA_ID:               DISA (encryption test) operations
+ * @WLAN_FTM_ID:                FTM module
  * @WLAN_REF_ID_MAX:            Max id used to generate ref count tracking array
  */
  /* New value added to the enum must also be reflected in function
@@ -241,6 +242,7 @@
 	WLAN_DEBUG_ID         = 29,
 	WLAN_DIRECT_BUF_RX_ID = 30,
 	WLAN_DISA_ID          = 31,
+	WLAN_FTM_ID           = 31,
 	WLAN_REF_ID_MAX,
 } wlan_objmgr_ref_dbgid;
 
@@ -286,6 +288,7 @@
 					"WLAN_DEBUG_ID",
 					"WLAN_DIRECT_BUF_RX_ID",
 					"WLAN_DISA_ID",
+					"WLAN_FTM_ID",
 					"WLAN_REF_ID_MAX" };
 
 	return (char *)strings[id];
diff --git a/umac/global_umac_dispatcher/lmac_if/inc/wlan_lmac_if_def.h b/umac/global_umac_dispatcher/lmac_if/inc/wlan_lmac_if_def.h
index f5d9305..98ca158 100644
--- a/umac/global_umac_dispatcher/lmac_if/inc/wlan_lmac_if_def.h
+++ b/umac/global_umac_dispatcher/lmac_if/inc/wlan_lmac_if_def.h
@@ -112,6 +112,21 @@
 	QDF_STATUS (*set_chan_list)(struct wlan_objmgr_pdev *pdev, void *arg);
 };
 
+/**
+ * struct wlan_lmac_if_ftm_tx_ops - south bound tx function pointers for ftm
+ * @ftm_attach: function to register event handlers with FW
+ * @ftm_detach: function to de-register event handlers with FW
+ * @ftm_cmd_send: function to send FTM commands to FW
+ *
+ * ftm module uses these functions to avail ol/da lmac services
+ */
+struct wlan_lmac_if_ftm_tx_ops {
+	QDF_STATUS (*ftm_attach)(struct wlan_objmgr_psoc *psoc);
+	QDF_STATUS (*ftm_detach)(struct wlan_objmgr_psoc *psoc);
+	QDF_STATUS (*ftm_cmd_send)(struct wlan_objmgr_pdev *pdev,
+				uint8_t *buf, uint32_t len, uint8_t mac_id);
+};
+
 
 struct wlan_lmac_if_mlme_tx_ops {
 	void (*scan_sta_power_events)(struct wlan_objmgr_pdev *pdev,
@@ -420,6 +435,17 @@
 #endif
 
 /**
+ * struct wlan_lmac_if_ftm_rx_ops  - south bound rx function pointers for FTM
+ * @ftm_ev_handler: function to handle FTM event
+ *
+ * lmac modules uses this API to post FTM events to FTM module
+ */
+struct wlan_lmac_if_ftm_rx_ops {
+	QDF_STATUS (*ftm_ev_handler)(struct wlan_objmgr_pdev *pdev,
+					uint8_t *event_buf, uint32_t len);
+};
+
+/**
  * struct wlan_lmac_reg_if_tx_ops - structure of tx function
  *                  pointers for regulatory component
  * @register_master_handler: pointer to register event handler
@@ -614,15 +640,20 @@
 #endif
 	 struct wlan_lmac_if_mlme_tx_ops mops;
 	 struct wlan_lmac_if_target_tx_ops target_tx_ops;
+
 #ifdef WLAN_OFFCHAN_TXRX_ENABLE
 	struct wlan_lmac_if_offchan_txrx_ops offchan_txrx_ops;
 #endif
+
 #ifdef DIRECT_BUF_RX_ENABLE
 	struct wlan_lmac_if_direct_buf_rx_tx_ops dbr_tx_ops;
 #endif
+
 #ifdef WLAN_SUPPORT_GREEN_AP
 	 struct wlan_lmac_if_green_ap_tx_ops green_ap_tx_ops;
 #endif
+
+	struct wlan_lmac_if_ftm_tx_ops ftm_tx_ops;
 };
 
 /**
@@ -1066,9 +1097,12 @@
 	struct wlan_lmac_if_tdls_rx_ops tdls_rx_ops;
 #endif
 	struct wlan_lmac_if_mlme_rx_ops mops;
+
 #ifdef WLAN_SUPPORT_GREEN_AP
 	struct wlan_lmac_if_green_ap_rx_ops green_ap_rx_ops;
 #endif
+
+	struct wlan_lmac_if_ftm_rx_ops ftm_rx_ops;
 };
 
 /* Function pointer to call legacy tx_ops registration in OL/WMA.
diff --git a/umac/global_umac_dispatcher/lmac_if/src/wlan_lmac_if.c b/umac/global_umac_dispatcher/lmac_if/src/wlan_lmac_if.c
index 01bad79..b2670b8 100644
--- a/umac/global_umac_dispatcher/lmac_if/src/wlan_lmac_if.c
+++ b/umac/global_umac_dispatcher/lmac_if/src/wlan_lmac_if.c
@@ -51,10 +51,12 @@
 #include <wlan_dfs_tgt_api.h>
 #include <wlan_dfs_utils_api.h>
 #endif
+
 #ifdef WLAN_SUPPORT_GREEN_AP
 #include <wlan_green_ap_api.h>
 #include <wlan_green_ap_ucfg_api.h>
 #endif
+#include <wlan_ftm_ucfg_api.h>
 
 /* Function pointer for OL/WMA specific UMAC tx_ops
  * registration.
@@ -324,6 +326,18 @@
 }
 #endif
 
+static QDF_STATUS
+wlan_lmac_if_umac_ftm_rx_ops_register(struct wlan_lmac_if_rx_ops *rx_ops)
+{
+	struct wlan_lmac_if_ftm_rx_ops *ftm_rx_ops;
+
+	ftm_rx_ops = &rx_ops->ftm_rx_ops;
+
+	ftm_rx_ops->ftm_ev_handler = wlan_ftm_process_utf_event;
+
+	return QDF_STATUS_SUCCESS;
+}
+
 /**
  * wlan_lmac_if_umac_rx_ops_register() - UMAC rx handler register
  * @rx_ops: Pointer to rx_ops structure to be populated
@@ -389,6 +403,9 @@
 
 	wlan_lmac_if_umac_green_ap_rx_ops_register(rx_ops);
 
+	/* FTM rx_ops */
+	wlan_lmac_if_umac_ftm_rx_ops_register(rx_ops);
+
 	return QDF_STATUS_SUCCESS;
 }