qcacld-3.0: Add DFS master feature flag

Add config flag to enable / disable DFS master feature

Change-Id: Ibb0bc715c70b471b5e73626cf75ce9785a8eb567
CRs-Fixed: 2222562
diff --git a/Kbuild b/Kbuild
index a8e5d6e..a9ca683 100644
--- a/Kbuild
+++ b/Kbuild
@@ -477,6 +477,9 @@
 #Flag to enable p2p debug feature
 CONFIG_WLAN_FEATURE_P2P_DEBUG := y
 
+#Flag to enable DFS Master feature
+CONFIG_WLAN_DFS_MASTER_ENABLE := y
+
 #Flag to enable nud tracking feature
 CONFIG_WLAN_NUD_TRACKING := y
 
@@ -1350,8 +1353,7 @@
 	    $(WMI_OBJ_DIR)/wmi_unified_tlv.o \
 	    $(WMI_OBJ_DIR)/wmi_unified_api.o \
 	    $(WMI_OBJ_DIR)/wmi_unified_pmo_api.o \
-	    $(WMI_OBJ_DIR)/wmi_unified_reg_api.o \
-	    $(WMI_OBJ_DIR)/wmi_unified_dfs_api.o
+	    $(WMI_OBJ_DIR)/wmi_unified_reg_api.o
 
 ifeq ($(CONFIG_WLAN_FEATURE_DSRC), y)
 ifeq ($(CONFIG_OCB_UT_FRAMEWORK), y)
@@ -1359,6 +1361,10 @@
 endif
 endif
 
+ifeq ($(CONFIG_WLAN_DFS_MASTER_ENABLE), y)
+WMI_OBJS += $(WMI_OBJ_DIR)/wmi_unified_dfs_api.o
+endif
+
 ########### FWLOG ###########
 FWLOG_DIR := $(WLAN_COMMON_ROOT)/utils/fwlog
 
@@ -1886,7 +1892,6 @@
 		$(SYS_OBJS) \
 		$(QDF_OBJS) \
 		$(CDS_OBJS) \
-		$(DFS_OBJS) \
 		$(FTM_OBJS)
 
 OBJS +=		$(WMA_OBJS) \
@@ -1896,8 +1901,7 @@
 		$(HTC_OBJS) \
 		$(INIT_DEINIT_OBJS) \
 		$(SCHEDULER_OBJS) \
-		$(REGULATORY_OBJS) \
-		$(DFS_OBJS)
+		$(REGULATORY_OBJS)
 
 OBJS +=		$(HIF_OBJS) \
 		$(BMI_OBJS) \
@@ -1915,6 +1919,9 @@
 OBJS += 	$(EPPING_OBJS)
 endif
 
+ifeq ($(CONFIG_WLAN_DFS_MASTER_ENABLE), y)
+OBJS +=		$(DFS_OBJS)
+endif
 
 OBJS +=		$(UMAC_OBJMGR_OBJS)
 OBJS +=		$(WIFI_POS_OBJS)
@@ -2399,15 +2406,15 @@
 #endof dummy flags
 
 # DFS component
-cppflags-y += -DQCA_MCL_DFS_SUPPORT
+cppflags-$(CONFIG_WLAN_DFS_MASTER_ENABLE) += -DQCA_MCL_DFS_SUPPORT
 ifeq ($(CONFIG_WLAN_FEATURE_DFS_OFFLOAD), y)
-cppflags-y += -DWLAN_DFS_FULL_OFFLOAD
+cppflags-$(CONFIG_WLAN_DFS_MASTER_ENABLE) += -DWLAN_DFS_FULL_OFFLOAD
 else
-cppflags-y += -DWLAN_DFS_PARTIAL_OFFLOAD
+cppflags-$(CONFIG_WLAN_DFS_MASTER_ENABLE) += -DWLAN_DFS_PARTIAL_OFFLOAD
 endif
-cppflags-y += -DDFS_COMPONENT_ENABLE
-cppflags-y += -DQCA_DFS_USE_POLICY_MANAGER
-cppflags-y += -DQCA_DFS_NOL_PLATFORM_DRV_SUPPORT
+cppflags-$(CONFIG_WLAN_DFS_MASTER_ENABLE) += -DDFS_COMPONENT_ENABLE
+cppflags-$(CONFIG_WLAN_DFS_MASTER_ENABLE) += -DQCA_DFS_USE_POLICY_MANAGER
+cppflags-$(CONFIG_WLAN_DFS_MASTER_ENABLE) += -DQCA_DFS_NOL_PLATFORM_DRV_SUPPORT
 
 cppflags-$(CONFIG_WLAN_DEBUGFS) += -DWLAN_DEBUGFS
 
diff --git a/core/sap/inc/sap_api.h b/core/sap/inc/sap_api.h
index 4019499..039cecd 100644
--- a/core/sap/inc/sap_api.h
+++ b/core/sap/inc/sap_api.h
@@ -1323,8 +1323,16 @@
  *
  * Return: QDF_STATUS
  */
+#ifdef DFS_COMPONENT_ENABLE
 QDF_STATUS wlansap_set_dfs_nol(struct sap_context *sap_ctx,
 			       eSapDfsNolType conf);
+#else
+static inline QDF_STATUS wlansap_set_dfs_nol(struct sap_context *sap_ctx,
+			       eSapDfsNolType conf)
+{
+	return QDF_STATUS_SUCCESS;
+}
+#endif
 
 /**
  * wlan_sap_set_vendor_acs() - Set vendor specific acs in sap context
diff --git a/core/sap/src/sap_fsm.c b/core/sap/src/sap_fsm.c
index 0475a63..0a9a57a 100644
--- a/core/sap/src/sap_fsm.c
+++ b/core/sap/src/sap_fsm.c
@@ -213,6 +213,7 @@
 	sapEvent->u2 = 0;
 }
 
+#ifdef DFS_COMPONENT_ENABLE
 /**
  * sap_random_channel_sel() - This function randomly pick up an available
  * channel
@@ -288,6 +289,12 @@
 	sap_ctx->ch_params.center_freq_seg1 = ch_params->center_freq_seg1;
 	return ch;
 }
+#else
+static uint8_t sap_random_channel_sel(struct sap_context *sap_ctx)
+{
+	return 0;
+}
+#endif
 
 /**
  * sap_is_channel_bonding_etsi_weather_channel() - check weather chan bonding.
@@ -3410,6 +3417,7 @@
 }
 #endif
 
+#ifdef DFS_COMPONENT_ENABLE
 uint8_t sap_indicate_radar(struct sap_context *sap_ctx)
 {
 	uint8_t target_channel = 0;
@@ -3467,6 +3475,7 @@
 
 	return target_channel;
 }
+#endif
 
 /*
  * CAC timer callback function.
diff --git a/core/sap/src/sap_module.c b/core/sap/src/sap_module.c
index 59a1fdb..ffd37c5 100644
--- a/core/sap/src/sap_module.c
+++ b/core/sap/src/sap_module.c
@@ -2352,6 +2352,7 @@
 	return QDF_STATUS_SUCCESS;
 }
 
+#ifdef DFS_COMPONENT_ENABLE
 QDF_STATUS wlansap_set_dfs_nol(struct sap_context *sap_ctx,
 			       eSapDfsNolType conf)
 {
@@ -2397,6 +2398,7 @@
 
 	return QDF_STATUS_SUCCESS;
 }
+#endif
 
 /**
  * wlansap_populate_del_sta_params() - populate delete station parameter