qcacld-3.0: Add spectral scan feature flag

Add spectral scan feature flag which can be
used to control the feature through build options.

Change-Id: Ide13e958cffff610626c891041307b40ac94c47d
CRs-Fixed: 2232167
diff --git a/Kbuild b/Kbuild
index 57da02d..50ee1ce 100644
--- a/Kbuild
+++ b/Kbuild
@@ -57,7 +57,6 @@
 		$(HDD_SRC_DIR)/wlan_hdd_request_manager.o \
 		$(HDD_SRC_DIR)/wlan_hdd_scan.o \
 		$(HDD_SRC_DIR)/wlan_hdd_softap_tx_rx.o \
-		$(HDD_SRC_DIR)/wlan_hdd_spectralscan.o \
 		$(HDD_SRC_DIR)/wlan_hdd_stats.o \
 		$(HDD_SRC_DIR)/wlan_hdd_sysfs.o \
 		$(HDD_SRC_DIR)/wlan_hdd_trace.o \
@@ -71,6 +70,10 @@
 HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_debugfs_llstat.o
 endif
 
+ifeq ($(CONFIG_WLAN_CONV_SPECTRAL_ENABLE),y)
+HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_spectralscan.o
+endif
+
 ifeq ($(CONFIG_WLAN_FEATURE_DSRC), y)
 HDD_OBJS+=	$(HDD_SRC_DIR)/wlan_hdd_ocb.o
 endif
@@ -513,6 +516,7 @@
 UMAC_SPECTRAL_INC := -I$(WLAN_COMMON_INC)/$(UMAC_SPECTRAL_DISP_INC_DIR) \
 			-I$(WLAN_COMMON_INC)/$(UMAC_SPECTRAL_CORE_INC_DIR) \
 			-I$(WLAN_COMMON_INC)/target_if/direct_buf_rx/inc
+ifeq ($(CONFIG_WLAN_CONV_SPECTRAL_ENABLE),y)
 UMAC_SPECTRAL_OBJS := $(UMAC_SPECTRAL_CORE_DIR)/spectral_offload.o \
 		$(UMAC_SPECTRAL_CORE_DIR)/spectral_common.o \
 		$(UMAC_SPECTRAL_DISP_DIR)/wlan_spectral_ucfg_api.o \
@@ -524,7 +528,7 @@
 		$(WLAN_COMMON_ROOT)/target_if/spectral/target_if_spectral_phyerr.o \
 		$(WLAN_COMMON_ROOT)/target_if/spectral/target_if_spectral.o \
 		$(WLAN_COMMON_ROOT)/target_if/spectral/target_if_spectral_sim.o
-
+endif
 ############# UMAC_GREEN_AP ############
 UMAC_GREEN_AP_DIR := umac/green_ap
 UMAC_GREEN_AP_DISP_INC_DIR := $(UMAC_GREEN_AP_DIR)/dispatcher/inc
@@ -1438,6 +1442,7 @@
 OBJS +=		$(UMAC_SCAN_OBJS)
 OBJS +=		$(UMAC_COMMON_OBJS)
 OBJS +=		$(WCFG_OBJS)
+
 OBJS +=		$(UMAC_SPECTRAL_OBJS)
 
 ifeq ($(CONFIG_QCACLD_FEATURE_GREEN_AP), y)
@@ -1481,7 +1486,6 @@
 cppflags-$(CONFIG_HDD_INIT_WITH_RTNL_LOCK) += -DCONFIG_HDD_INIT_WITH_RTNL_LOCK
 cppflags-$(CONFIG_CONVERGED_TDLS_ENABLE) += -DCONVERGED_TDLS_ENABLE
 cppflags-$(CONFIG_WLAN_CONV_SPECTRAL_ENABLE) += -DWLAN_CONV_SPECTRAL_ENABLE
-cppflags-$(CONFIG_WLAN_SPECTRAL_ENABLE) += -DWLAN_SPECTRAL_ENABLE
 cppflags-$(CONFIG_WMI_CMD_STRINGS) += -DWMI_CMD_STRINGS
 
 cppflags-$(CONFIG_WLAN_DISABLE_EXPORT_SYMBOL) += -DWLAN_DISABLE_EXPORT_SYMBOL
diff --git a/core/hdd/inc/wlan_hdd_spectralscan.h b/core/hdd/inc/wlan_hdd_spectralscan.h
index 9abbbc1..63fa1ee 100644
--- a/core/hdd/inc/wlan_hdd_spectralscan.h
+++ b/core/hdd/inc/wlan_hdd_spectralscan.h
@@ -26,6 +26,7 @@
 #if !defined(WLAN_HDD_SPECTRALSCAN_H)
 #define WLAN_HDD_SPECTRALSCAN_H
 
+#ifdef WLAN_CONV_SPECTRAL_ENABLE
 /*
  * enum spectral_scan_msg_type - spectral scan registration
  * @SPECTRAL_SCAN_REGISTER_REQ: spectral scan app register request
@@ -185,7 +186,11 @@
 						struct wireless_dev *wdev,
 						const void *data,
 						int data_len);
+#else
+#define FEATURE_SPECTRAL_SCAN_VENDOR_COMMANDS
+#endif
 
+#if defined(CNSS_GENL) && defined(WLAN_CONV_SPECTRAL_ENABLE)
 /**
  * spectral_scan_activate_service() - Activate spectral scan  message handler
  *
@@ -195,5 +200,10 @@
  * Return - 0 for success, non zero for failure
  */
 int spectral_scan_activate_service(void);
-
+#else
+static inline int spectral_scan_activate_service(void)
+{
+	return 0;
+}
+#endif
 #endif
diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c
index 6bb6e2b..09256a1 100644
--- a/core/hdd/src/wlan_hdd_main.c
+++ b/core/hdd/src/wlan_hdd_main.c
@@ -136,7 +136,6 @@
 #endif
 #include "wlan_reg_ucfg_api.h"
 #include "wlan_ocb_ucfg_api.h"
-
 #include <wlan_hdd_spectralscan.h>
 #ifdef MODULE
 #define WLAN_MODULE_NAME  module_name(THIS_MODULE)
@@ -6638,7 +6637,7 @@
 
 	ret = spectral_scan_activate_service();
 	if (ret) {
-		hdd_alert("spectral_scan_activate_service failed: %d", ret);
+		hdd_err("spectral service initialization failed: %d", ret);
 		goto err_close_cesium;
 	}
 
diff --git a/core/hdd/src/wlan_hdd_spectralscan.c b/core/hdd/src/wlan_hdd_spectralscan.c
index f044d17..0dbd7d6 100644
--- a/core/hdd/src/wlan_hdd_spectralscan.c
+++ b/core/hdd/src/wlan_hdd_spectralscan.c
@@ -359,7 +359,7 @@
 	return ret;
 }
 
-#ifdef CNSS_GENL
+#if defined(CNSS_GENL) && defined(WLAN_CONV_SPECTRAL_ENABLE)
 static void send_spectral_scan_reg_rsp_msg(struct hdd_context *hdd_ctx)
 {
 	struct sk_buff *skb;
@@ -479,9 +479,4 @@
 				spectral_scan_msg_handler, NULL);
 	return 0;
 }
-#else
-int spectral_scan_activate_service(void)
-{
-	return 0;
-}
 #endif
diff --git a/core/sme/src/common/sme_api.c b/core/sme/src/common/sme_api.c
index 60e9b90..caf5403 100644
--- a/core/sme/src/common/sme_api.c
+++ b/core/sme/src/common/sme_api.c
@@ -1205,6 +1205,25 @@
 	return status;
 }
 
+#ifdef WLAN_CONV_SPECTRAL_ENABLE
+static QDF_STATUS sme_register_spectral_cb(tpAniSirGlobal mac_ctx)
+{
+	struct spectral_legacy_cbacks spectral_cb;
+	QDF_STATUS status;
+
+	spectral_cb.vdev_get_chan_freq = sme_get_oper_chan_freq;
+	spectral_cb.vdev_get_ch_width = sme_get_oper_ch_width;
+	spectral_cb.vdev_get_sec20chan_freq_mhz = sme_get_sec20chan_freq_mhz;
+	status = spectral_register_legacy_cb(mac_ctx->psoc, &spectral_cb);
+
+	return status;
+}
+#else
+static QDF_STATUS sme_register_spectral_cb(tpAniSirGlobal mac_ctx)
+{
+	return QDF_STATUS_SUCCESS;
+}
+#endif
 /*
  * sme_start() - Put all SME modules at ready state.
  *  The function starts each module in SME, PMC, CSR, etc. . Upon
@@ -1220,7 +1239,6 @@
 	QDF_STATUS status = QDF_STATUS_E_FAILURE;
 	tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
 	struct policy_mgr_sme_cbacks sme_cbacks;
-	struct spectral_legacy_cbacks spectral_cb;
 
 	do {
 		status = csr_start(pMac);
@@ -1246,10 +1264,7 @@
 				status);
 			break;
 		}
-		spectral_cb.vdev_get_chan_freq = sme_get_oper_chan_freq;
-		spectral_cb.vdev_get_ch_width = sme_get_oper_ch_width;
-		spectral_cb.vdev_get_sec20chan_freq_mhz = sme_get_sec20chan_freq_mhz;
-		spectral_register_legacy_cb(pMac->psoc, &spectral_cb);
+		sme_register_spectral_cb(pMac);
 		pMac->sme.state = SME_STATE_START;
 
 		/* START RRM */
diff --git a/core/wma/src/wma_main.c b/core/wma/src/wma_main.c
index e87e68d..548472e 100644
--- a/core/wma/src/wma_main.c
+++ b/core/wma/src/wma_main.c
@@ -2567,6 +2567,8 @@
 			WLAN_LOG_INDICATOR_FIRMWARE, reason_code);
 	return QDF_STATUS_E_FAILURE;
 }
+
+#ifdef WLAN_CONV_SPECTRAL_ENABLE
 /**
  * wma_extract_single_phyerr_spectral() - extract single phy error from event
  * @handle: wma handle
@@ -2783,7 +2785,8 @@
  * Return:  QDF_STATUS
  */
 static QDF_STATUS spectral_phyerr_event_handler(void *handle,
-					uint8_t *data, uint32_t datalen)
+						uint8_t *data,
+						uint32_t datalen)
 {
 	tp_wma_handle wma = (tp_wma_handle) handle;
 	QDF_STATUS status = QDF_STATUS_SUCCESS;
@@ -2844,6 +2847,13 @@
 
 	return status;
 }
+#else
+static QDF_STATUS spectral_phyerr_event_handler(void *handle,
+					uint8_t *data, uint32_t datalen)
+{
+	return QDF_STATUS_SUCCESS;
+}
+#endif
 
 /**
  * dfs_phyerr_event_handler() - dfs phyerr event handler
@@ -4113,6 +4123,22 @@
 		WMA_LOGE("Failed to start the firmware time sync timer");
 }
 
+#ifdef WLAN_CONV_SPECTRAL_ENABLE
+static void wma_register_spectral_cmds(tp_wma_handle wma_handle)
+{
+	struct wmi_spectral_cmd_ops cmd_ops;
+
+	cmd_ops.wmi_spectral_configure_cmd_send =
+			wmi_unified_vdev_spectral_configure_cmd_send;
+	cmd_ops.wmi_spectral_enable_cmd_send =
+			wmi_unified_vdev_spectral_enable_cmd_send;
+	wlan_register_wmi_spectral_cmd_ops(wma_handle->pdev, &cmd_ops);
+}
+#else
+static void wma_register_spectral_cmds(tp_wma_handle wma_handle)
+{
+}
+#endif
 /**
  * wma_start() - wma start function.
  *               Initialize event handlers and timers.
@@ -4124,7 +4150,6 @@
 	QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
 	tp_wma_handle wma_handle;
 	int status;
-	struct wmi_spectral_cmd_ops cmd_ops;
 	struct wmi_unified *wmi_handle;
 
 	WMA_LOGD("%s: Enter", __func__);
@@ -4372,12 +4397,7 @@
 		qdf_status = QDF_STATUS_E_FAILURE;
 		goto end;
 	}
-
-	cmd_ops.wmi_spectral_configure_cmd_send =
-			wmi_unified_vdev_spectral_configure_cmd_send;
-	cmd_ops.wmi_spectral_enable_cmd_send =
-			wmi_unified_vdev_spectral_enable_cmd_send;
-	wlan_register_wmi_spectral_cmd_ops(wma_handle->pdev, &cmd_ops);
+	wma_register_spectral_cmds(wma_handle);
 
 end:
 	WMA_LOGD("%s: Exit", __func__);