wlan: Update gEnableMacAddrSpoof ini parameter

Added support for mac spoofing of firmware initiated scans only.

gEnableMacAddrSpoof can now take the following values:
0 -> disable mac spoofing
1 -> Enable mac spoofing for host and firmware scans
2 -> Enable mac spoofing for firmware scans only (disabled in host scans)

Change-Id: Ieeb407cb6c08695a73fafe9bef08813b86ac4a0a
CRs-Fixed: 930151
diff --git a/CORE/HDD/src/wlan_hdd_cfg80211.c b/CORE/HDD/src/wlan_hdd_cfg80211.c
index 9c5642c..1d43e6d 100644
--- a/CORE/HDD/src/wlan_hdd_cfg80211.c
+++ b/CORE/HDD/src/wlan_hdd_cfg80211.c
@@ -173,6 +173,14 @@
  */
 #define EXTTDLS_EVENT_BUF_SIZE 4096
 
+/*
+ * Values for Mac spoofing feature
+ *
+ */
+#define MAC_ADDR_SPOOFING_FW_HOST_DISABLE           0
+#define MAC_ADDR_SPOOFING_FW_HOST_ENABLE            1
+#define MAC_ADDR_SPOOFING_FW_ENABLE_HOST_DISABLE    2
+
 static const u32 hdd_cipher_suites[] =
 {
     WLAN_CIPHER_SUITE_WEP40,
@@ -5053,7 +5061,7 @@
     if (0 != wlan_hdd_validate_context(pHddCtx)){
         return -EINVAL;
     }
-    if (FALSE == pHddCtx->cfg_ini->enableMacSpoofing) {
+    if (0 == pHddCtx->cfg_ini->enableMacSpoofing) {
         hddLog(VOS_TRACE_LEVEL_INFO, FL("MAC_SPOOFED_SCAN disabled in ini"));
         return -ENOTSUPP;
     }
@@ -12617,7 +12625,9 @@
     cfg80211_scan_done(req, aborted);
     complete(&pScanInfo->abortscan_event_var);
 
-    if (pHddCtx->spoofMacAddr.isEnabled || pHddCtx->spoofMacAddr.isReqDeferred) {
+    if ((pHddCtx->cfg_ini->enableMacSpoofing == MAC_ADDR_SPOOFING_FW_HOST_ENABLE
+       ) && (pHddCtx->spoofMacAddr.isEnabled
+         ||  pHddCtx->spoofMacAddr.isReqDeferred)) {
         /* Generate new random mac addr for next scan */
         hddLog(VOS_TRACE_LEVEL_INFO, "scan completed - generate new spoof mac addr");
         hdd_processSpoofMacAddrRequest(pHddCtx);
@@ -13183,7 +13193,8 @@
            scanRequest.minChnTime, scanRequest.maxChnTime,
            scanRequest.p2pSearch, scanRequest.skipDfsChnlInP2pSearch);
 
-    if (pHddCtx->spoofMacAddr.isEnabled)
+    if (pHddCtx->spoofMacAddr.isEnabled &&
+        pHddCtx->cfg_ini->enableMacSpoofing == 1)
     {
         hddLog(VOS_TRACE_LEVEL_INFO,
                         "%s: MAC Spoofing enabled for current scan", __func__);