qcacmn: Do not invoke get_pcl multiple times during set_pcl to FW

Do not invoke get_pcl when calculating weightage of channels sent to FW
as part of set_pcl WMI command.

Change-Id: I62b39aaf0943cf10deab380d8030d1ef08fbbcb3
CRs-Fixed: 2287649
diff --git a/umac/cmn_services/policy_mgr/inc/wlan_policy_mgr_api.h b/umac/cmn_services/policy_mgr/inc/wlan_policy_mgr_api.h
index 2fa1cd6..d0e6ee9 100644
--- a/umac/cmn_services/policy_mgr/inc/wlan_policy_mgr_api.h
+++ b/umac/cmn_services/policy_mgr/inc/wlan_policy_mgr_api.h
@@ -379,7 +379,7 @@
 
 /**
  * policy_mgr_allow_concurrency() - Check for allowed concurrency
- * combination
+ * combination consulting the PCL
  * @psoc: PSOC object information
  * @mode:	new connection mode
  * @channel: channel on which new connection is coming up
diff --git a/umac/cmn_services/policy_mgr/src/wlan_policy_mgr_core.c b/umac/cmn_services/policy_mgr/src/wlan_policy_mgr_core.c
index 7882bf2..7bd923e 100644
--- a/umac/cmn_services/policy_mgr/src/wlan_policy_mgr_core.c
+++ b/umac/cmn_services/policy_mgr/src/wlan_policy_mgr_core.c
@@ -2264,9 +2264,11 @@
 		policy_mgr_debug("pcl len (%d) and weight list len mismatch (%d)",
 			*len, i);
 
-	/* check the channel avoidance list */
-	policy_mgr_update_with_safe_channel_list(psoc, pcl_channels, len,
-				pcl_weights, weight_len);
+	/* check the channel avoidance list for beaconing entities */
+	if ((mode == PM_SAP_MODE) || (mode == PM_P2P_GO_MODE))
+		policy_mgr_update_with_safe_channel_list(psoc, pcl_channels,
+							 len, pcl_weights,
+							 weight_len);
 
 	policy_mgr_set_weight_of_dfs_passive_channels_to_zero(psoc,
 			pcl_channels, len, pcl_weights, weight_len);
diff --git a/umac/cmn_services/policy_mgr/src/wlan_policy_mgr_get_set_utils.c b/umac/cmn_services/policy_mgr/src/wlan_policy_mgr_get_set_utils.c
index d81e6d1..816f3c6 100644
--- a/umac/cmn_services/policy_mgr/src/wlan_policy_mgr_get_set_utils.c
+++ b/umac/cmn_services/policy_mgr/src/wlan_policy_mgr_get_set_utils.c
@@ -1544,16 +1544,15 @@
 	return pm_ctx->user_cfg.sub_20_mhz_enabled;
 }
 
-bool policy_mgr_allow_concurrency(struct wlan_objmgr_psoc *psoc,
-				enum policy_mgr_con_mode mode,
-				uint8_t channel, enum hw_mode_bandwidth bw)
+bool policy_mgr_is_concurrency_allowed(struct wlan_objmgr_psoc *psoc,
+				       enum policy_mgr_con_mode mode,
+				       uint8_t channel,
+				       enum hw_mode_bandwidth bw)
 {
 	uint32_t num_connections = 0, count = 0, index = 0;
 	bool status = false, match = false;
 	uint32_t list[MAX_NUMBER_OF_CONC_CONNECTIONS];
 	struct policy_mgr_psoc_priv_obj *pm_ctx;
-	QDF_STATUS ret;
-	struct policy_mgr_pcl_list pcl;
 	bool sta_sap_scc_on_dfs_chan;
 
 	pm_ctx = policy_mgr_get_context(psoc);
@@ -1561,16 +1560,6 @@
 		policy_mgr_err("Invalid Context");
 		return status;
 	}
-
-
-	qdf_mem_zero(&pcl, sizeof(pcl));
-	ret = policy_mgr_get_pcl(psoc, mode, pcl.pcl_list, &pcl.pcl_len,
-			pcl.weight_list, QDF_ARRAY_SIZE(pcl.weight_list));
-	if (QDF_IS_STATUS_ERROR(ret)) {
-		policy_mgr_err("disallow connection:%d", ret);
-		goto done;
-	}
-
 	/* find the current connection state from pm_conc_connection_list*/
 	num_connections = policy_mgr_get_connection_count(psoc);
 
@@ -1748,6 +1737,25 @@
 	return status;
 }
 
+bool policy_mgr_allow_concurrency(struct wlan_objmgr_psoc *psoc,
+				  enum policy_mgr_con_mode mode,
+				  uint8_t channel, enum hw_mode_bandwidth bw)
+{
+	QDF_STATUS status;
+	struct policy_mgr_pcl_list pcl;
+
+	qdf_mem_zero(&pcl, sizeof(pcl));
+	status = policy_mgr_get_pcl(psoc, mode, pcl.pcl_list, &pcl.pcl_len,
+				    pcl.weight_list,
+				    QDF_ARRAY_SIZE(pcl.weight_list));
+	if (QDF_IS_STATUS_ERROR(status)) {
+		policy_mgr_err("disallow connection:%d", status);
+		return false;
+	}
+
+	return policy_mgr_is_concurrency_allowed(psoc, mode, channel, bw);
+}
+
 /**
  * policy_mgr_get_concurrency_mode() - return concurrency mode
  * @psoc: PSOC object information
diff --git a/umac/cmn_services/policy_mgr/src/wlan_policy_mgr_i.h b/umac/cmn_services/policy_mgr/src/wlan_policy_mgr_i.h
index 15c9d9b..73d5490 100644
--- a/umac/cmn_services/policy_mgr/src/wlan_policy_mgr_i.h
+++ b/umac/cmn_services/policy_mgr/src/wlan_policy_mgr_i.h
@@ -474,4 +474,24 @@
 		uint8_t  new_nss, uint8_t next_action,
 		enum policy_mgr_band band,
 		enum policy_mgr_conn_update_reason reason);
+
+/**
+ * policy_mgr_is_concurrency_allowed() - Check for allowed
+ * concurrency combination
+ * @psoc: PSOC object information
+ * @mode: new connection mode
+ * @channel: channel on which new connection is coming up
+ * @bw: Bandwidth requested by the connection (optional)
+ *
+ * When a new connection is about to come up check if current
+ * concurrency combination including the new connection is
+ * allowed or not based on the HW capability, but no need to
+ * invoke get_pcl
+ *
+ * Return: True/False
+ */
+bool policy_mgr_is_concurrency_allowed(struct wlan_objmgr_psoc *psoc,
+				       enum policy_mgr_con_mode mode,
+				       uint8_t channel,
+				       enum hw_mode_bandwidth bw);
 #endif
diff --git a/umac/cmn_services/policy_mgr/src/wlan_policy_mgr_pcl.c b/umac/cmn_services/policy_mgr/src/wlan_policy_mgr_pcl.c
index 5303ee8..1a4c8f4 100644
--- a/umac/cmn_services/policy_mgr/src/wlan_policy_mgr_pcl.c
+++ b/umac/cmn_services/policy_mgr/src/wlan_policy_mgr_pcl.c
@@ -222,7 +222,7 @@
 				pm_ctx->unsafe_channel_list[j]) {
 				/* Found unsafe channel, update it */
 				is_unsafe = 1;
-				policy_mgr_warn("CH %d is not safe",
+				policy_mgr_debug("CH %d is not safe",
 					current_channel_list[i]);
 				break;
 			}
@@ -1646,9 +1646,9 @@
 		 * below!
 		 */
 		for (i = 0; i < weight->saved_num_chan; i++) {
-			if (policy_mgr_allow_concurrency(psoc, PM_STA_MODE,
-					weight->saved_chan_list[i],
-					HW_MODE_20_MHZ)) {
+			if (policy_mgr_is_concurrency_allowed
+				(psoc, PM_STA_MODE, weight->saved_chan_list[i],
+				HW_MODE_20_MHZ)) {
 				weight->weighed_valid_list[i] =
 					WEIGHT_OF_NON_PCL_CHANNELS;
 			}