qcacld-3.0: add support to remove the ftm from configuration

Phase 1, after ftm componentization, we could now support to remove
the ftm related components when FTM is disable from the build
configuration.

Size changes: after removing the ftm related binaries, we could save
15KB from module size.

Change-Id: Ib363f1d6204b07947a46f32673c4f8ad6fb3dbd3
CRs-fixed: 2258441
diff --git a/Kbuild b/Kbuild
index d5816ee..0b94998 100755
--- a/Kbuild
+++ b/Kbuild
@@ -682,16 +682,22 @@
 	   -I$(OS_IF_FTM_INC)	\
 	   -I$(TARGET_IF_FTM_INC)
 
+ifeq ($(CONFIG_QCA_WIFI_FTM), y)
 FTM_OBJS := $(FTM_DISP_SRC)/wlan_ftm_init_deinit.o \
 	    $(FTM_DISP_SRC)/wlan_ftm_ucfg_api.o \
 	    $(FTM_CORE_SRC)/wlan_ftm_svc.o \
-	    $(OS_IF_FTM_SRC)/wlan_cfg80211_ftm.o \
 	    $(TARGET_IF_FTM_SRC)/target_if_ftm.o
 
+ifeq ($(QCA_WIFI_FTM_NL80211), y)
+FTM_OBJS += $(OS_IF_FTM_SRC)/wlan_cfg80211_ftm.o
+endif
+
 ifeq ($(CONFIG_LINUX_QCMBR), y)
 FTM_OBJS += $(OS_IF_FTM_SRC)/wlan_ioctl_ftm.o
 endif
 
+endif
+
 ############# UMAC_CMN_SERVICES ############
 UMAC_COMMON_INC := -I$(WLAN_COMMON_INC)/umac/cmn_services/cmn_defs/inc \
 		-I$(WLAN_COMMON_INC)/umac/cmn_services/utils/inc
@@ -2031,6 +2037,8 @@
 
 #Enable FTM support
 cppflags-$(CONFIG_QCA_WIFI_FTM) += -DQCA_WIFI_FTM
+cppflags-$(CONFIG_NL80211_TESTMODE) += -DQCA_WIFI_FTM_NL80211
+cppflags-$(CONFIG_LINUX_QCMBR) += -DLINUX_QCMBR -DQCA_WIFI_FTM_IOCTL
 
 #Enable Checksum Offload support
 cppflags-$(CONFIG_CHECKSUM_OFFLOAD) += -DCHECKSUM_OFFLOAD
diff --git a/configs/default_defconfig b/configs/default_defconfig
index e55b94b..98d1e82 100644
--- a/configs/default_defconfig
+++ b/configs/default_defconfig
@@ -448,6 +448,21 @@
 #Enable FTM support
 CONFIG_QCA_WIFI_FTM := y
 
+ifeq ($(CONFIG_QCA_WIFI_FTM), y)
+
+ifeq ($(CONFIG_NL80211_TESTMODE), y)
+	QCA_WIFI_FTM_NL80211 :=y
+else
+	QCA_WIFI_FTM_NL80211 :=n
+endif
+	CONFIG_LINUX_QCMBR :=y
+
+else
+	QCA_WIFI_FTM_NL80211 :=n
+	CONFIG_LINUX_QCMBR :=n
+endif
+
+
 #Enable Checksum Offload
 CONFIG_CHECKSUM_OFFLOAD := y
 
diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c
index 0c86007..aa2dd10 100644
--- a/core/hdd/src/wlan_hdd_main.c
+++ b/core/hdd/src/wlan_hdd_main.c
@@ -12876,6 +12876,19 @@
 }
 #endif
 
+#ifdef QCA_WIFI_FTM
+static bool is_ftm_mode_supported(void)
+{
+	return true;
+}
+#else
+static bool is_ftm_mode_supported(void)
+{
+	pr_err("FTM mode not supported!");
+	return false;
+}
+#endif
+
 /**
  * is_con_mode_valid() check con mode is valid or not
  * @mode: global con mode
@@ -12890,6 +12903,7 @@
 	case QDF_GLOBAL_EPPING_MODE:
 		return is_epping_mode_supported();
 	case QDF_GLOBAL_FTM_MODE:
+		return is_ftm_mode_supported();
 	case QDF_GLOBAL_MISSION_MODE:
 		return true;
 	default: