qcacmn: Converge the Spectral feature

Add Spectral TxOps and RxOps interfaces in
psoc towards converging the Spectral feature.

CRs-Fixed: 2028657
Change-Id: If5b46fb9d71529060df6e5b242fcc8976fce82f8
diff --git a/global_lmac_if/inc/wlan_global_lmac_if_api.h b/global_lmac_if/inc/wlan_global_lmac_if_api.h
index d492721..4f0e6dc 100644
--- a/global_lmac_if/inc/wlan_global_lmac_if_api.h
+++ b/global_lmac_if/inc/wlan_global_lmac_if_api.h
@@ -69,4 +69,17 @@
 QDF_STATUS wlan_global_lmac_if_set_txops_registration_cb(WLAN_DEV_TYPE dev_type,
 		QDF_STATUS (*handler)(struct wlan_lmac_if_tx_ops *));
 
+#ifdef WLAN_CONV_SPECTRAL_ENABLE
+/**
+ * wlan_lmac_if_sptrl_set_rx_ops_register_cb ()- Spectral LMAC Rx ops
+ * registration callback assignment
+ * @handler: Handler to be called for spectral LMAC rx ops registration
+ *
+ * API to assign appropriate Spectral LMAC rx ops registration callback handler
+ *
+ * Return: QDF_STATUS_SUCCESS - in case of success
+ */
+QDF_STATUS wlan_lmac_if_sptrl_set_rx_ops_register_cb(void (*handler)
+				(struct wlan_lmac_if_rx_ops *));
+#endif /* WLAN_CONV_SPECTRAL_ENABLE */
 #endif /* _WLAN_LMAC_IF_API_H */
diff --git a/global_lmac_if/src/wlan_global_lmac_if.c b/global_lmac_if/src/wlan_global_lmac_if.c
index c5642c8..8ff2ed2 100644
--- a/global_lmac_if/src/wlan_global_lmac_if.c
+++ b/global_lmac_if/src/wlan_global_lmac_if.c
@@ -29,6 +29,43 @@
 QDF_STATUS (*wlan_global_lmac_if_tx_ops_register[MAX_DEV_TYPE])
 				(struct wlan_lmac_if_tx_ops *tx_ops);
 
+#ifdef WLAN_CONV_SPECTRAL_ENABLE
+/* Function pointer for spectral rx_ops registration function */
+void (*wlan_lmac_if_sptrl_rx_ops)(struct wlan_lmac_if_rx_ops *rx_ops);
+
+QDF_STATUS wlan_lmac_if_sptrl_set_rx_ops_register_cb(void (*handler)
+				(struct wlan_lmac_if_rx_ops *))
+{
+	wlan_lmac_if_sptrl_rx_ops = handler;
+
+	return QDF_STATUS_SUCCESS;
+}
+EXPORT_SYMBOL(wlan_lmac_if_sptrl_set_rx_ops_register_cb);
+#endif /* WLAN_CONV_SPECTRAL_ENABLE */
+
+#ifdef WLAN_CONV_SPECTRAL_ENABLE
+/**
+ * wlan_spectral_register_rx_ops() - Register spectral component RX OPS
+ * @rx_ops: lmac if receive ops
+ *
+ * Return: None
+ */
+static void wlan_spectral_register_rx_ops(struct wlan_lmac_if_rx_ops *rx_ops)
+{
+	wlan_lmac_if_sptrl_rx_ops(rx_ops);
+}
+#else
+/**
+ * wlan_spectral_register_rx_ops() - Dummy api to register spectral RX OPS
+ * @rx_ops: lmac if receive ops
+ *
+ * Return: None
+ */
+static void wlan_spectral_register_rx_ops(struct wlan_lmac_if_rx_ops *rx_ops)
+{
+}
+#endif
+
 #ifdef WLAN_PMO_ENABLE
 /**
  * wlan_pmo_register_rx_ops() - Register PMO component RX OPS
@@ -79,9 +116,12 @@
 	/* Registeration for UMAC componets */
 	wlan_lmac_if_umac_rx_ops_register(rx_ops);
 
-       /* Registeration for componets outside UMAC */
+	/* Registeration for componets outside UMAC */
 	wlan_pmo_register_rx_ops(rx_ops);
 
+	/* spectral rx_ops registration*/
+	wlan_spectral_register_rx_ops(rx_ops);
+
 	return QDF_STATUS_SUCCESS;
 }
 
diff --git a/qdf/inc/qdf_types.h b/qdf/inc/qdf_types.h
index 24be729..b217580 100644
--- a/qdf/inc/qdf_types.h
+++ b/qdf/inc/qdf_types.h
@@ -303,6 +303,7 @@
  * @QDF_MODULE_ID_CONFIG: CONFIG module ID
  * @QDF_MODULE_ID_REGULATORY    : REGULATORY module ID
  * @QDF_MODULE_ID_NAN: NAN module ID
+ * @QDF_MODULE_ID_SPECTRAL: Spectral module ID
  * @QDF_MODULE_ID_ANY: anything
  * @QDF_MODULE_ID_MAX: Max place holder module ID
  */
@@ -392,6 +393,7 @@
 	QDF_MODULE_ID_NAN,
 	QDF_MODULE_ID_OFFCHAN_TXRX,
 	QDF_MODULE_ID_SON,
+	QDF_MODULE_ID_SPECTRAL,
 	QDF_MODULE_ID_ANY,
 	QDF_MODULE_ID_MAX,
 } QDF_MODULE_ID;
diff --git a/qdf/linux/src/qdf_trace.c b/qdf/linux/src/qdf_trace.c
index eac5b00..40b7c8e 100644
--- a/qdf/linux/src/qdf_trace.c
+++ b/qdf/linux/src/qdf_trace.c
@@ -1809,6 +1809,7 @@
 	[QDF_MODULE_ID_PMO] = {"PMO"},
 	[QDF_MODULE_ID_POLICY_MGR] = {"POLICY_MGR"},
 	[QDF_MODULE_ID_NAN] = {"NAN"},
+	[QDF_MODULE_ID_SPECTRAL] = {"SPECTRAL"},
 	[QDF_MODULE_ID_P2P] = {"P2P"},
 	[QDF_MODULE_ID_OFFCHAN_TXRX] = {"OFFCHAN"},
 	[QDF_MODULE_ID_ANY] = {"ANY"},
diff --git a/target_if/core/src/target_if_main.c b/target_if/core/src/target_if_main.c
index c2c2cf1..30a15b2 100644
--- a/target_if/core/src/target_if_main.c
+++ b/target_if/core/src/target_if_main.c
@@ -31,6 +31,9 @@
 #ifdef WLAN_SA_API_ENABLE
 #include "target_if_sa_api.h"
 #endif
+#ifdef WLAN_CONV_SPECTRAL_ENABLE
+#include "target_if_spectral.h"
+#endif
 #include <target_if_reg.h>
 #include <target_if_scan.h>
 #ifdef DFS_COMPONENT_ENABLE
@@ -192,6 +195,19 @@
 }
 #endif /* DFS_COMPONENT_ENABLE */
 
+#ifdef WLAN_CONV_SPECTRAL_ENABLE
+static void target_if_sptrl_tx_ops_register(
+				struct wlan_lmac_if_tx_ops *tx_ops)
+{
+	target_if_sptrl_register_tx_ops(tx_ops);
+}
+#else
+static void target_if_sptrl_tx_ops_register(
+				struct wlan_lmac_if_tx_ops *tx_ops)
+{
+}
+#endif /* WLAN_CONV_SPECTRAL_ENABLE */
+
 static
 QDF_STATUS target_if_register_umac_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops)
 {
@@ -253,6 +269,7 @@
 
 	/* Components parallel to UMAC to register their TX-ops here */
 	target_if_pmo_register_tx_ops_req(tx_ops);
+	target_if_sptrl_tx_ops_register(tx_ops);
 
 #ifdef CONVERGED_P2P_ENABLE
 	/* Converged UMAC components to register P2P TX-ops */
diff --git a/umac/cmn_services/inc/wlan_cmn.h b/umac/cmn_services/inc/wlan_cmn.h
index 2cc452e..f86e5a6 100644
--- a/umac/cmn_services/inc/wlan_cmn.h
+++ b/umac/cmn_services/inc/wlan_cmn.h
@@ -111,6 +111,7 @@
  * @WLAN_UMAC_COMP_CRYPTO:        CRYPTO
  * @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
  *
@@ -136,6 +137,7 @@
 	WLAN_UMAC_COMP_DFS,
 	WLAN_UMAC_COMP_OFFCHAN_TXRX,
 	WLAN_UMAC_COMP_SON,
+	WLAN_UMAC_COMP_SPECTRAL,
 	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 88573ac..5add6c4 100644
--- a/umac/cmn_services/obj_mgr/inc/wlan_objmgr_cmn.h
+++ b/umac/cmn_services/obj_mgr/inc/wlan_objmgr_cmn.h
@@ -176,6 +176,7 @@
  * @WLAN_REGULATORY_SB_ID:      SB regulatory operations
  * @WLAN_REGULATORY_NB_ID:      NB regulatory operations
  * @WLAN_POLICY_MGR_ID:         Policy Manager operations
+ * @WLAN_SPECTRAL_ID:           Spectral operations
  * @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
@@ -209,6 +210,7 @@
 	WLAN_POLICY_MGR_ID    = 24,
 	WLAN_SON_ID           = 25,
 	WLAN_SA_API_ID        = 26,
+	WLAN_SPECTRAL_ID      = 27,
 	WLAN_REF_ID_MAX,
 } wlan_objmgr_ref_dbgid;
 
@@ -246,6 +248,7 @@
 					"WLAN_REGULATORY_SB_ID",
 					"WLAN_REGULATORY_NB_ID",
 					"WLAN_SON_ID",
+					"WLAN_SPECTRAL_ID",
 					"WLAN_REF_ID_MAX" };
 
     return (char *)strings[id];
diff --git a/umac/cmn_services/obj_mgr/src/wlan_objmgr_global_obj.c b/umac/cmn_services/obj_mgr/src/wlan_objmgr_global_obj.c
index 5ca3772..a65a0bb 100644
--- a/umac/cmn_services/obj_mgr/src/wlan_objmgr_global_obj.c
+++ b/umac/cmn_services/obj_mgr/src/wlan_objmgr_global_obj.c
@@ -113,6 +113,7 @@
 	qdf_spin_unlock_bh(&g_umac_glb_obj->global_lock);
 	return QDF_STATUS_SUCCESS;
 }
+EXPORT_SYMBOL(wlan_objmgr_register_psoc_create_handler);
 
 QDF_STATUS wlan_objmgr_unregister_psoc_create_handler(
 		enum wlan_umac_comp_id id,
@@ -139,6 +140,7 @@
 	qdf_spin_unlock_bh(&g_umac_glb_obj->global_lock);
 	return QDF_STATUS_SUCCESS;
 }
+EXPORT_SYMBOL(wlan_objmgr_unregister_psoc_create_handler);
 
 QDF_STATUS wlan_objmgr_register_psoc_destroy_handler(
 		enum wlan_umac_comp_id id,
@@ -165,6 +167,7 @@
 	qdf_spin_unlock_bh(&g_umac_glb_obj->global_lock);
 	return QDF_STATUS_SUCCESS;
 }
+EXPORT_SYMBOL(wlan_objmgr_register_psoc_destroy_handler);
 
 QDF_STATUS wlan_objmgr_unregister_psoc_destroy_handler(
 		enum wlan_umac_comp_id id,
@@ -191,6 +194,7 @@
 	qdf_spin_unlock_bh(&g_umac_glb_obj->global_lock);
 	return QDF_STATUS_SUCCESS;
 }
+EXPORT_SYMBOL(wlan_objmgr_unregister_psoc_destroy_handler);
 
 QDF_STATUS wlan_objmgr_register_psoc_status_handler(
 		enum wlan_umac_comp_id id,
@@ -270,6 +274,7 @@
 	qdf_spin_unlock_bh(&g_umac_glb_obj->global_lock);
 	return QDF_STATUS_SUCCESS;
 }
+EXPORT_SYMBOL(wlan_objmgr_register_pdev_create_handler);
 
 QDF_STATUS wlan_objmgr_unregister_pdev_create_handler(
 		enum wlan_umac_comp_id id,
@@ -296,6 +301,7 @@
 	qdf_spin_unlock_bh(&g_umac_glb_obj->global_lock);
 	return QDF_STATUS_SUCCESS;
 }
+EXPORT_SYMBOL(wlan_objmgr_unregister_pdev_create_handler);
 
 QDF_STATUS wlan_objmgr_register_pdev_destroy_handler(
 		enum wlan_umac_comp_id id,
@@ -322,6 +328,7 @@
 	qdf_spin_unlock_bh(&g_umac_glb_obj->global_lock);
 	return QDF_STATUS_SUCCESS;
 }
+EXPORT_SYMBOL(wlan_objmgr_register_pdev_destroy_handler);
 
 QDF_STATUS wlan_objmgr_unregister_pdev_destroy_handler(
 		enum wlan_umac_comp_id id,
@@ -348,6 +355,7 @@
 	qdf_spin_unlock_bh(&g_umac_glb_obj->global_lock);
 	return QDF_STATUS_SUCCESS;
 }
+EXPORT_SYMBOL(wlan_objmgr_unregister_pdev_destroy_handler);
 
 QDF_STATUS wlan_objmgr_register_pdev_status_handler(
 		enum wlan_umac_comp_id id,
diff --git a/umac/cmn_services/obj_mgr/src/wlan_objmgr_pdev_obj.c b/umac/cmn_services/obj_mgr/src/wlan_objmgr_pdev_obj.c
index d65ee49..a9e49ec 100644
--- a/umac/cmn_services/obj_mgr/src/wlan_objmgr_pdev_obj.c
+++ b/umac/cmn_services/obj_mgr/src/wlan_objmgr_pdev_obj.c
@@ -288,6 +288,7 @@
 	}
 	return QDF_STATUS_SUCCESS;
 }
+EXPORT_SYMBOL(wlan_objmgr_pdev_component_obj_attach);
 
 QDF_STATUS wlan_objmgr_pdev_component_obj_detach(
 		struct wlan_objmgr_pdev *pdev,
@@ -355,6 +356,7 @@
 	}
 	return QDF_STATUS_SUCCESS;
 }
+EXPORT_SYMBOL(wlan_objmgr_pdev_component_obj_detach);
 
 /**
  ** APIs to operations on pdev objects
diff --git a/umac/cmn_services/obj_mgr/src/wlan_objmgr_psoc_obj.c b/umac/cmn_services/obj_mgr/src/wlan_objmgr_psoc_obj.c
index b2ee683..baca628 100644
--- a/umac/cmn_services/obj_mgr/src/wlan_objmgr_psoc_obj.c
+++ b/umac/cmn_services/obj_mgr/src/wlan_objmgr_psoc_obj.c
@@ -311,6 +311,7 @@
 
 	return QDF_STATUS_SUCCESS;
 }
+EXPORT_SYMBOL(wlan_objmgr_psoc_component_obj_attach);
 
 QDF_STATUS wlan_objmgr_psoc_component_obj_detach(
 		struct wlan_objmgr_psoc *psoc,
@@ -382,6 +383,7 @@
 
 	return QDF_STATUS_SUCCESS;
 }
+EXPORT_SYMBOL(wlan_objmgr_psoc_component_obj_detach);
 
 QDF_STATUS wlan_objmgr_iterate_obj_list(
 		struct wlan_objmgr_psoc *psoc,
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 d6679d0..59a6bbc 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
@@ -37,6 +37,9 @@
 #ifdef WLAN_SA_API_ENABLE
 #include "wlan_sa_api_utils_defs.h"
 #endif
+#ifdef WLAN_CONV_SPECTRAL_ENABLE
+#include "wlan_spectral_public_structs.h"
+#endif
 #include <reg_services_public_struct.h>
 
 #ifdef WLAN_CONV_CRYPTO_SUPPORTED
@@ -398,6 +401,58 @@
 
 #endif
 
+#ifdef WLAN_CONV_SPECTRAL_ENABLE
+/**
+ * struct wlan_lmac_if_sptrl_tx_ops - Spectral south bound Tx operations
+ * @sptrlto_spectral_init:          Initialize LMAC/target_if Spectral
+ * @sptrlto_spectral_deinit:        De-initialize LMAC/target_if Spectral
+ * @sptrlto_set_spectral_config:    Set Spectral configuration
+ * @sptrlto_get_spectral_config:    Get Spectral configuration
+ * @sptrlto_start_spectral_scan:    Start Spectral Scan
+ * @sptrlto_stop_spectral_scan:     Stop Spectral Scan
+ * @sptrlto_is_spectral_active:     Get whether Spectral is active
+ * @sptrlto_is_spectral_enabled:    Get whether Spectral is enabled
+ * @sptrlto_set_icm_active:         Set whether ICM is active or inactive
+ * @sptrlto_get_icm_active:         Get whether ICM is active or inactive
+ * @sptrlto_get_nominal_nf:         Get Nominal Noise Floor for the current
+ *                                  frequency band
+ * @sptrlto_set_debug_level:        Set Spectral debug level
+ * @sptrlto_get_debug_level:        Get Spectral debug level
+ * @sptrlto_get_chaninfo:           Get channel information
+ * @sptrlto_clear_chaninfo:         Clear channel information
+ * @sptrlto_get_spectral_capinfo:   Get Spectral capability information
+ * @sptrlto_get_spectral_diagstats: Get Spectral diagnostic statistics
+ **/
+struct wlan_lmac_if_sptrl_tx_ops {
+	void * (*sptrlto_pdev_spectral_init)(struct wlan_objmgr_pdev *pdev);
+	void (*sptrlto_pdev_spectral_deinit)(struct wlan_objmgr_pdev *pdev);
+	int (*sptrlto_set_spectral_config)(struct wlan_objmgr_pdev *pdev,
+					   const u_int32_t threshtype,
+					   const u_int32_t value);
+	void (*sptrlto_get_spectral_config)(struct wlan_objmgr_pdev *pdev,
+					    struct spectral_config *sptrl_config
+					    );
+	int (*sptrlto_start_spectral_scan)(struct wlan_objmgr_pdev *pdev);
+	void (*sptrlto_stop_spectral_scan)(struct wlan_objmgr_pdev *pdev);
+	bool (*sptrlto_is_spectral_active)(struct wlan_objmgr_pdev *pdev);
+	bool (*sptrlto_is_spectral_enabled)(struct wlan_objmgr_pdev *pdev);
+	int (*sptrlto_set_icm_active)(struct wlan_objmgr_pdev *pdev,
+				      bool isactive);
+	bool (*sptrlto_get_icm_active)(struct wlan_objmgr_pdev *pdev);
+	int16_t (*sptrlto_get_nominal_nf)(struct wlan_objmgr_pdev *pdev);
+	int (*sptrlto_set_debug_level)(struct wlan_objmgr_pdev *pdev,
+				       u_int32_t debug_level);
+	u_int32_t (*sptrlto_get_debug_level)(struct wlan_objmgr_pdev *pdev);
+	void (*sptrlto_get_chaninfo)(struct wlan_objmgr_pdev *pdev,
+				     void *outdata);
+	void (*sptrlto_clear_chaninfo)(struct wlan_objmgr_pdev *pdev);
+	void (*sptrlto_get_spectral_capinfo)(struct wlan_objmgr_pdev *pdev,
+					     void *outdata);
+	void (*sptrlto_get_spectral_diagstats)(struct wlan_objmgr_pdev *pdev,
+					       void *outdata);
+};
+#endif /* WLAN_CONV_SPECTRAL_ENABLE */
+
 #ifdef WIFI_POS_CONVERGED
 /*
  * struct wlan_lmac_if_wifi_pos_tx_ops - structure of firmware tx function
@@ -593,6 +648,10 @@
 	struct wlan_lmac_if_sa_api_tx_ops sa_api_tx_ops;
 #endif
 
+#ifdef WLAN_CONV_SPECTRAL_ENABLE
+	struct wlan_lmac_if_sptrl_tx_ops sptrl_tx_ops;
+#endif
+
 #ifdef WLAN_CONV_CRYPTO_SUPPORTED
 	struct wlan_lmac_if_crypto_tx_ops crypto_tx_ops;
 #endif
@@ -815,6 +874,19 @@
 };
 #endif
 
+#ifdef WLAN_CONV_SPECTRAL_ENABLE
+/**
+ * struct wlan_lmac_if_sptrl_rx_ops - Spectral south bound Rx operations
+ *
+ * @sptrl_send_phydata:        Send Spectral PHY Data
+ * @sptrlro_get_target_handle: Get Spectral handle for target/LMAC private data
+ */
+struct wlan_lmac_if_sptrl_rx_ops {
+	int (*sptrlro_send_phydata)(struct wlan_objmgr_pdev *pdev,
+				    struct sock *sock, qdf_nbuf_t nbuf);
+	void * (*sptrlro_get_target_handle)(struct wlan_objmgr_pdev *pdev);
+};
+#endif /* WLAN_CONV_SPECTRAL_ENABLE */
 
 #ifdef WIFI_POS_CONVERGED
 /**
@@ -1010,6 +1082,11 @@
 #ifdef WLAN_SA_API_ENABLE
 	struct wlan_lmac_if_sa_api_rx_ops sa_api_rx_ops;
 #endif
+
+#ifdef WLAN_CONV_SPECTRAL_ENABLE
+	struct wlan_lmac_if_sptrl_rx_ops sptrl_rx_ops;
+#endif
+
 #ifdef WLAN_CONV_CRYPTO_SUPPORTED
 	struct wlan_lmac_if_crypto_rx_ops crypto_rx_ops;
 #endif
diff --git a/wmi/src/wmi_unified_non_tlv.c b/wmi/src/wmi_unified_non_tlv.c
index a85e360..e49ed83 100644
--- a/wmi/src/wmi_unified_non_tlv.c
+++ b/wmi/src/wmi_unified_non_tlv.c
@@ -7008,7 +7008,7 @@
 		phyerr->rf_info.rssi_comb =
 			WMI_UNIFIED_RSSI_COMB_GET(&ev->hdr);
 
-#if ATH_SUPPORT_SPECTRAL
+#ifdef WLAN_CONV_SPECTRAL_ENABLE
 
 	   /*
 		* If required, pass spectral events to the spectral module
@@ -7077,7 +7077,7 @@
 
 			}
 		}
-#endif  /* ATH_SUPPORT_SPECTRAL */
+#endif  /* WLAN_CONV_SPECTRAL_ENABLE */
 
 		/*
 		 * Advance the buffer pointer to the next PHY error.
@@ -7138,7 +7138,7 @@
 
 	/* Handle Spectral PHY Error */
 	if ((ph->phy_err_mask0 & WMI_HOST_AR900B_SPECTRAL_PHYERR_MASK)) {
-#if ATH_SUPPORT_SPECTRAL
+#ifdef WLAN_CONV_SPECTRAL_ENABLE
 		if (ph->buf_len > 0) {
 
 			/* Initialize the NF values to Zero. */
@@ -7199,7 +7199,7 @@
 			    WMI_UNIFIED_FREQ_INFO_GET(ph, 2);
 
 		}
-#endif  /* ATH_SUPPORT_SPECTRAL */
+#endif  /* WLAN_CONV_SPECTRAL_ENABLE */
 
 	}
 	return QDF_STATUS_SUCCESS;