[DTV00841433] misc: Add option in Makefile to disable roaming feature

[Description]
Add option in Makefile to disable roaming feature
If wiphy is registered with WIPHY_FLAG_SUPPORTS_FW_ROAM, wpa_supplicant
does not set frequency while selecting AP. When STA and P2P is running
simultaneously, wpa_supplicant will detect frequency conflict always.
On most Android devices, wpa_supplicant initiates scanning and AP
selection. It is better to disable roaming feature by default.

1. To link WIPHY_FLAG_SUPPORTS_FW_ROAM with CFG_SUPPORT_ROAMING.
2. To disable roaming feature by set CFG_SUPPORT_ROAMING=0 in Makefile.

Change-Id: I528321e25a81e64088327ca4fdcb89f1adf10587
CR-Id: DTV00841433
Signed-off-by: guo-jie.wang <guo-jie.wang@mediatek.com>
diff --git a/Makefile.ce b/Makefile.ce
index d6054bf..47ce0af 100644
--- a/Makefile.ce
+++ b/Makefile.ce
@@ -146,6 +146,8 @@
 
 #CFG_SUPPORT_DFS_MASTER=1
 
+CFG_SUPPORT_ROAMING=0
+
 # Support to change sta, p2p, ap interface names
 # y: enable, n: disable
 # eg. insmod wlan_mt7668_usb.ko sta=wlan p2p=p2p ap=ap
@@ -188,6 +190,10 @@
 PLATFORM_FLAGS += -DCFG_USB_REQ_RX_DATA_CNT=$(CFG_USB_REQ_RX_DATA_CNT)
 endif
 
+ifneq ($(CFG_SUPPORT_ROAMING),)
+PLATFORM_FLAGS += -DCFG_SUPPORT_ROAMING=$(CFG_SUPPORT_ROAMING)
+endif
+
 ifneq ($(CFG_ENABLE_EFUSE_MAC_ADDR),)
 PLATFORM_FLAGS += -DCFG_ENABLE_EFUSE_MAC_ADDR=$(CFG_ENABLE_EFUSE_MAC_ADDR)
 endif
diff --git a/include/config.h b/include/config.h
index 3d278f6..42d6e71 100644
--- a/include/config.h
+++ b/include/config.h
@@ -663,7 +663,9 @@
 #define CFG_SUPPORT_UAPSD           1
 #define CFG_SUPPORT_UL_PSMP         0
 
+#ifndef CFG_SUPPORT_ROAMING
 #define CFG_SUPPORT_ROAMING         1	/* Roaming System */
+#endif
 #if (CFG_SUPPORT_ROAMING == 1)
 
 /* Roaming feature: skip roaming when only one ESSID AP
diff --git a/os/linux/gl_init.c b/os/linux/gl_init.c
index 33a56ab..1d13ea5 100644
--- a/os/linux/gl_init.c
+++ b/os/linux/gl_init.c
@@ -1477,15 +1477,22 @@
 	prWiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
 	prWiphy->cipher_suites = (const u32 *)mtk_cipher_suites;
 	prWiphy->n_cipher_suites = ARRAY_SIZE(mtk_cipher_suites);
+
+	/* CFG80211_VERSION_CODE >= 3.3 */
+	prWiphy->flags = WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL;
+
+	/* CFG80211_VERSION_CODE >= 3.2 */
+#if (CFG_SUPPORT_ROAMING == 1)
+	prWiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM;
+#endif /* CFG_SUPPORT_ROAMING */
+
 #if KERNEL_VERSION(3, 14, 0) > CFG80211_VERSION_CODE
-	prWiphy->flags = WIPHY_FLAG_CUSTOM_REGULATORY | WIPHY_FLAG_SUPPORTS_FW_ROAM | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL;
+	prWiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY;
 #else
-#if (CFG_SUPPORT_DFS_MASTER == 1)
-	prWiphy->flags = WIPHY_FLAG_SUPPORTS_FW_ROAM | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL | WIPHY_FLAG_HAS_CHANNEL_SWITCH;
-#else
-	prWiphy->flags = WIPHY_FLAG_SUPPORTS_FW_ROAM | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL;
-#endif
 	prWiphy->regulatory_flags = REGULATORY_CUSTOM_REG;
+#if (CFG_SUPPORT_DFS_MASTER == 1)
+	prWiphy->flags |= WIPHY_FLAG_HAS_CHANNEL_SWITCH;
+#endif /* CFG_SUPPORT_DFS_MASTER */
 #endif
 
 	cfg80211_regd_set_wiphy(prWiphy);