Parcourir la source

qcacld-3.0: Fix unexpected 2.4G channel selected

In sap standalone on 5G channel, when LTE unsafe event
shows the SAP working on unsafe channel, SAP moves to
2G channel because the current logic will select
safe channel from ACS list.
The preference is 5G safe channel if available.
This change will select safe channel in same band firstly
from the list.

Change-Id: Ibc45a05845692b0dd8a02fd98aef2f7b15d00729
CRs-Fixed: 2996401
Liangwei Dong il y a 3 ans
Parent
commit
d294cd7a6f
1 fichiers modifiés avec 14 ajouts et 7 suppressions
  1. 14 7
      core/sap/src/sap_module.c

+ 14 - 7
core/sap/src/sap_module.c

@@ -2928,7 +2928,7 @@ wlansap_get_safe_channel(struct sap_context *sap_ctx)
 	uint32_t pcl_freqs[NUM_CHANNELS];
 	QDF_STATUS status;
 	mac_handle_t mac_handle;
-	uint32_t pcl_len = 0;
+	uint32_t pcl_len = 0, i;
 
 	if (!sap_ctx) {
 		sap_err("NULL parameter");
@@ -2961,16 +2961,23 @@ wlansap_get_safe_channel(struct sap_context *sap_ctx)
 							       pcl_freqs,
 							       &pcl_len,
 							       PM_SAP_MODE);
-		if (QDF_IS_STATUS_ERROR(status)) {
-			sap_err("failed to get valid channel: %d", status);
+		if (QDF_IS_STATUS_ERROR(status) || !pcl_len) {
+			sap_err("failed to get valid channel: %d len %d",
+				status, pcl_len);
 			return INVALID_CHANNEL_ID;
 		}
 
-		if (pcl_len) {
-			sap_debug("select %d from valid channel list",
-				  pcl_freqs[0]);
-			return pcl_freqs[0];
+		for (i = 0; i < pcl_len; i++) {
+			if (WLAN_REG_IS_SAME_BAND_FREQS(sap_ctx->chan_freq,
+							pcl_freqs[i])) {
+				sap_debug("select %d from valid channel list",
+					  pcl_freqs[i]);
+				return pcl_freqs[i];
+			}
 		}
+		sap_debug("select first %d from valid channel list",
+			  pcl_freqs[0]);
+		return pcl_freqs[0];
 	}
 
 	return INVALID_CHANNEL_ID;