Browse Source

qcacld-3.0: Check previous N freq based on BW to select Best channel

As per current logic previous N-1 frequencies are passed by caller
to validate considering the current frequency as Nth freq. But
instead of comparing previous_n_freq - 1, index - min_index
is compared with previous_n_freq . Due to this current frequency
will not be selected as best frequency even if previous 3 or 4
freq depending on BW are free.

Fix is to pass previous N frequencies based on BW instead of N-1 and
compare index - min_index < prev_n_freq.

Change-Id: Ib78a6774f8d33b264fa2941255f043ea76c6e08b
CRs-Fixed: 3409806
Sheenam Monga 2 years ago
parent
commit
672e0a7766
1 changed files with 8 additions and 6 deletions
  1. 8 6
      core/sap/src/sap_api_link_cntl.c

+ 8 - 6
core/sap/src/sap_api_link_cntl.c

@@ -1537,10 +1537,12 @@ bool sap_is_prev_n_freqs_free(bool *clean_channel_array, uint32_t curr_index,
 	 */
 	for (index = min_index; index > 0 && index <= max_index;
 	     index++) {
-		if (!clean_channel_array[index])
+		if (!clean_channel_array[index]) {
+			sap_debug("chan_index %d not free", index);
 			return false;
+		}
 	}
-	if ((index - min_index) != prev_n_freq_count) {
+	if ((index - min_index) < prev_n_freq_count) {
 		sap_debug("previous %d are not validated", prev_n_freq_count);
 		return false;
 	}
@@ -1616,19 +1618,19 @@ bool is_freq_allowed_for_sap(struct wlan_objmgr_pdev *pdev,
 	switch (ch_width) {
 	case CH_WIDTH_40MHZ:
 		return sap_is_prev_n_freqs_free(clean_channel_array,
-						curr_index, 40/20 - 1,
+						curr_index, 40/20,
 						range);
 	case CH_WIDTH_80MHZ:
 		return sap_is_prev_n_freqs_free(clean_channel_array,
-						curr_index, 80/20 - 1,
+						curr_index, 80/20,
 						range);
 	case CH_WIDTH_160MHZ:
 		return sap_is_prev_n_freqs_free(clean_channel_array,
-						curr_index, 160/20 - 1,
+						curr_index, 160/20,
 						range);
 	case CH_WIDTH_320MHZ:
 		return sap_is_prev_n_freqs_free(clean_channel_array,
-						curr_index, 320/20 - 1,
+						curr_index, 320/20,
 						range);
 	default:
 		return false;