sap: Scan band preference

For AP auto channel selection, customers should be able to:
1.Only choose 2.4G for scan
2.Only choose 5G for scan
3.Scan both bands
a.Start with 2.4G, if ACS detects a suitable channel,
setup SoftAP in 2.4G itself do not waste time scanning 5G
b.Start with 5G, if ACS detects a suitable channel,
setup SoftAP in 5G itself, do not waste time scanning 2.4G

Two iwpriv commands are added to set and get scan band
preference. When scan preference is set, the preferred
band will be scanned first, if a channel is selected then
the scan is finished, otherwise the next band will be scanned.
Command format:
iwpriv wlan0 scan_band_pref <0|1|2>  0 --- no preference,
                                      1 --- prefer 2.4G band
                                      2 --- prefer 5G band
iwpriv wlan0 get_scan_pref

Change-Id: I1c99af02c7c6b5c79f3bc86c78d4b19ed71067c5
CRs-fixed: 722413
diff --git a/CORE/HDD/src/wlan_hdd_wext.c b/CORE/HDD/src/wlan_hdd_wext.c
index aee7049..cc75c16 100644
--- a/CORE/HDD/src/wlan_hdd_wext.c
+++ b/CORE/HDD/src/wlan_hdd_wext.c
@@ -167,6 +167,7 @@
 #define WE_SET_TDLS_SEC_OFF_CHAN_OFFSET  15
 #define WE_SET_TDLS_OFF_CHAN_MODE        16
 #endif
+#define  WE_SET_SCAN_BAND_PREFERENCE     17
 
 /* Private ioctls and their sub-ioctls */
 #define WLAN_PRIV_SET_NONE_GET_INT    (SIOCIWFIRSTPRIV + 1)
@@ -178,6 +179,7 @@
 #define WE_GET_WDI_DBG       7
 #define WE_GET_SAP_AUTO_CHANNEL_SELECTION 8
 #define WE_GET_CONCURRENCY_MODE 9
+#define WE_GET_SCAN_BAND_PREFERENCE     10
 /* Private ioctls and their sub-ioctls */
 #define WLAN_PRIV_SET_INT_GET_INT     (SIOCIWFIRSTPRIV + 2)
 
@@ -4795,6 +4797,32 @@
            break;
         }
 #endif
+        case WE_SET_SCAN_BAND_PREFERENCE:
+        {
+            tSmeConfigParams smeConfig;
+            memset(&smeConfig, 0x00, sizeof(smeConfig));
+            if(pAdapter->device_mode != WLAN_HDD_INFRA_STATION) {
+                ret = -EINVAL;
+                break;
+            }
+            hddLog(LOG1, "WE_SET_BAND_PREFERRENCE val %d ", set_value);
+
+            if (eCSR_BAND_ALL == set_value ||
+                    eCSR_BAND_24 == set_value || eCSR_BAND_5G == set_value) {
+                sme_GetConfigParam(hHal, &smeConfig);
+                smeConfig.csrConfig.scanBandPreference = set_value;
+
+                VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
+                        "set band scan preference = %d\n",
+                        smeConfig.csrConfig.scanBandPreference);
+
+                sme_UpdateConfig(hHal, &smeConfig);
+            }
+            else {
+                ret = -EINVAL;
+            }
+            break;
+        }
 
         default:
         {
@@ -4955,6 +4983,7 @@
     hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
     int *value = (int *)extra;
     int ret = 0; /* success */
+    tSmeConfigParams smeConfig;
 
     if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
     {
@@ -5054,6 +5083,16 @@
            break;
         }
 
+        case WE_GET_SCAN_BAND_PREFERENCE:
+        {
+            sme_GetConfigParam(hHal, &smeConfig);
+            *value = smeConfig.csrConfig.scanBandPreference;
+
+            VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
+                      "scanBandPreference = %d\n", *value);
+            break;
+        }
+
         default:
         {
             hddLog(LOGE, "Invalid IOCTL get_value command %d ",value[0]);
@@ -5774,7 +5813,6 @@
             break;
         }
 #endif
-
         case WE_ENABLE_DXE_STALL_DETECT:
         {
             tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
@@ -8344,7 +8382,6 @@
                 __func__, offchanmode);
     return 0;
 }
-
 #endif
 
 
@@ -8551,6 +8588,10 @@
         "tdlsoffchnmode" },
 #endif
 
+    {   WE_SET_SCAN_BAND_PREFERENCE,
+        IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
+        0, "set_scan_pref" },
+
     /* handlers for main ioctl */
     {   WLAN_PRIV_SET_NONE_GET_INT,
         0,
@@ -8598,6 +8639,11 @@
         IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
         "getconcurrency" },
 
+    {   WE_GET_SCAN_BAND_PREFERENCE,
+        0,
+        IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
+        "get_scan_pref"},
+
     /* handlers for main ioctl */
     {   WLAN_PRIV_SET_CHAR_GET_NONE,
         IW_PRIV_TYPE_CHAR| 512,