qcacld-3.0: Set ACS weight to max for channels not in scan list

When gApAutoChannelSelection is set to 1 in ini, HOST driver ACS
runs in wlan_hdd_cfg80211_start_bss() with all the channel width,
hw mode and start and end channel parameters overridden with the
values from ini. After scan on all the channels, a weight is
assigned to all the channels based on rssi and no. of BSS present
on that channel. Weights of all the channels not present in the
scan list remains 0 as no scan happened on those channels and so
BSS count is 0 and RSSI is max. As the channel with lowest weight
is selected, channel which is not even present in scan list is getting
selected.

Assign SAP_ACS_WEIGHT_MAX to all the channels not in the scan list so
only one of the channel present in scan list gets selected after ACS
algorithm is completed.

Change-Id: Ic567c412ec7f68e2bb5d12e8e982650e56fd0488
CRs-Fixed: 2164979
diff --git a/core/sap/src/sap_ch_select.c b/core/sap/src/sap_ch_select.c
index 0e353d1..cb05559 100644
--- a/core/sap/src/sap_ch_select.c
+++ b/core/sap/src/sap_ch_select.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012-2017 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2012-2018 The Linux Foundation. All rights reserved.
  *
  * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  *
@@ -604,6 +604,7 @@
 #endif
 	uint32_t dfs_master_cap_enabled;
 	bool include_dfs_ch = true;
+	uint8_t chan_num;
 
 	QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_HIGH, "In %s",
 		  __func__);
@@ -693,6 +694,21 @@
 			pSpectCh->valid = true;
 			pSpectCh->rssiAgr = SOFTAP_MIN_RSSI;    /* Initialise for all channels */
 			pSpectCh->channelWidth = SOFTAP_HT20_CHANNELWIDTH;      /* Initialise 20MHz for all the Channels */
+			/* Initialise max ACS weight for all channels */
+			pSpectCh->weight = SAP_ACS_WEIGHT_MAX;
+			for (chan_num = 0; chan_num < sap_ctx->num_of_channel;
+			     chan_num++) {
+				if (pSpectCh->chNum !=
+				    sap_ctx->channelList[chan_num])
+					continue;
+
+				/*
+				 * Initialize ACS weight to 0 for channels
+				 * present in sap context scan channel list
+				 */
+				pSpectCh->weight = 0;
+				break;
+			}
 		}
 	}
 	return true;
@@ -1649,6 +1665,9 @@
 		if (ch_in_pcl(sap_ctx, chn_num))
 			rssi -= PCL_RSSI_DISCOUNT;
 
+		if (pSpectCh->weight == SAP_ACS_WEIGHT_MAX)
+			goto debug_info;
+
 		pSpectCh->weight =
 			SAPDFS_NORMALISE_1000 *
 			(sapweight_rssi_count(sap_ctx, rssi,
@@ -1659,6 +1678,7 @@
 			pSpectCh->weight = SAP_ACS_WEIGHT_MAX;
 		pSpectCh->weight_copy = pSpectCh->weight;
 
+debug_info:
 		/* ------ Debug Info ------ */
 		QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_HIGH,
 			  "In %s, Chan=%d Weight= %d rssiAgr=%d bssCount=%d",