Переглянути джерело

qcacld-3.0: Optimize force SCC API

Optimize force SCC API, to use PCL to get the required channel.

Change-Id: I440790e21dcb6437fe633316caf85bbf11a69f9a
CRs-Fixed: 3430837
Abhishek Singh 2 роки тому
батько
коміт
d055aed7bb

+ 12 - 13
components/cmn_services/policy_mgr/inc/wlan_policy_mgr_api.h

@@ -1462,25 +1462,24 @@ bool policy_mgr_allow_concurrency(struct wlan_objmgr_psoc *psoc,
 				  uint32_t ext_flags, uint8_t vdev_id);
 
 /**
- * policy_mgr_check_scc_sbs_channel() - Check for allowed
- * concurrency combination
+ * policy_mgr_check_scc_channel() - Check if SAP/GO freq need to be updated
+ * as per exiting concurrency
  * @psoc: PSOC object information
- * @intf_ch_freq: channel frequency on which new connection is coming up
- * @sap_ch_freq: SoftAp channel frequency
- * @vdev_id: Vdev Id
+ * @intf_ch_freq: Channel frequency of existing concurrency
+ * @sap_ch_freq: Given SAP/GO channel frequency
+ * @vdev_id: Vdev id of the SAP/GO
  * @cc_mode: concurrent switch mode
  *
- * 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
+ * When SAP/GO is starting or re-starting, check SAP/GO freq need to be
+ * aligned with the existing concurrencies. i.e. Forced to be on same freq as
+ * exiting concurrency.
  *
  * Return: True/False
  */
-void policy_mgr_check_scc_sbs_channel(struct wlan_objmgr_psoc *psoc,
-				      qdf_freq_t *intf_ch_freq,
-				      qdf_freq_t sap_ch_freq,
-				      uint8_t vdev_id, uint8_t cc_mode);
+void policy_mgr_check_scc_channel(struct wlan_objmgr_psoc *psoc,
+				  qdf_freq_t *intf_ch_freq,
+				  qdf_freq_t sap_ch_freq,
+				  uint8_t vdev_id, uint8_t cc_mode);
 
 /**
  * policy_mgr_nan_sap_pre_enable_conc_check() - Check if NAN+SAP SCC is

+ 140 - 385
components/cmn_services/policy_mgr/src/wlan_policy_mgr_core.c

@@ -3965,7 +3965,6 @@ bool policy_mgr_is_5g_channel_allowed(struct wlan_objmgr_psoc *psoc,
  * @sap_ch_freq: sap/go channel starting channel frequency
  * @acs_band: acs band
  * @allow_6ghz: allow 6 Ghz channel or not
- * @allow_non_scc: allow non SCC channel or not
  *
  * This API will consider protocol 6ghz allow flag - allow_6ghz.
  * Also for regdomain, it will consider PCL allow or not.
@@ -3981,8 +3980,7 @@ policy_mgr_get_pref_force_scc_freq(struct wlan_objmgr_psoc *psoc,
 				   qdf_freq_t *intf_ch_freq,
 				   qdf_freq_t sap_ch_freq,
 				   uint32_t acs_band,
-				   bool allow_6ghz,
-				   bool allow_non_scc)
+				   bool allow_6ghz)
 {
 	struct policy_mgr_psoc_priv_obj *pm_ctx;
 	enum policy_mgr_con_mode mode;
@@ -3990,13 +3988,15 @@ policy_mgr_get_pref_force_scc_freq(struct wlan_objmgr_psoc *psoc,
 	uint32_t i;
 	struct policy_mgr_pcl_list pcl;
 	bool allow_2ghz_only = false;
-	qdf_freq_t scc_ch_freq_on_same_band = 0;
-	qdf_freq_t scc_ch_freq_on_diff_band_freq = 0;
+	qdf_freq_t scc_ch_freq_on_same_mac = 0;
+	qdf_freq_t scc_ch_freq_on_diff_mac = 0;
 	qdf_freq_t scc_ch_freq_same_as_sap = 0;
-	qdf_freq_t non_scc_ch_freq_on_same_band = 0;
-	qdf_freq_t non_scc_ch_freq_on_diff_band_freq = 0;
+	qdf_freq_t non_scc_ch_freq_on_same_mac = 0;
+	qdf_freq_t non_scc_ch_freq_on_diff_mac = 0;
+	qdf_freq_t non_scc_ch_freq_same_as_sap = 0;
 	enum QDF_OPMODE op_mode;
 	qdf_freq_t pcl_freq;
+	bool same_mac, sbs_ml_sta_present = false, dbs_ml_sta_present = false;
 
 	pm_ctx = policy_mgr_get_context(psoc);
 	if (!pm_ctx) {
@@ -4004,6 +4004,11 @@ policy_mgr_get_pref_force_scc_freq(struct wlan_objmgr_psoc *psoc,
 		return QDF_STATUS_E_INVAL;
 	}
 
+	if (policy_mgr_is_mlo_in_mode_dbs(psoc, PM_STA_MODE, NULL, NULL))
+		dbs_ml_sta_present = true;
+	else if (policy_mgr_is_mlo_in_mode_sbs(psoc, PM_STA_MODE, NULL, NULL))
+		sbs_ml_sta_present = true;
+
 	op_mode = wlan_get_opmode_vdev_id(pm_ctx->pdev, vdev_id);
 	mode = policy_mgr_convert_device_mode_to_qdf_type(op_mode);
 
@@ -4023,11 +4028,11 @@ policy_mgr_get_pref_force_scc_freq(struct wlan_objmgr_psoc *psoc,
 	     WLAN_REG_IS_24GHZ_CH_FREQ(sap_ch_freq))
 		allow_2ghz_only = true;
 
-	/* qdf_conc_list_lock has been locked by caller.
+	/*
 	 * The preferred force SCC channel is SAP original channel,
-	 * and then the SCC channel on the same band, and then the SCC
-	 * channel on the different band.
-	 * We will make sure the PCL only contains valid channels - not
+	 * and then the SCC channel on the same mac, and then the SCC
+	 * channel on the different mac.
+	 * Make sure the PCL only contains valid channels - not
 	 * causing 3 vif on same mac.
 	 * If none of channels are available, we have to keep SAP channel
 	 * unchanged, and that may cause SAP MCC.
@@ -4040,275 +4045,155 @@ policy_mgr_get_pref_force_scc_freq(struct wlan_objmgr_psoc *psoc,
 		if (allow_2ghz_only && !WLAN_REG_IS_24GHZ_CH_FREQ(pcl_freq))
 			continue;
 
+		/*
+		 * If ML STA is present, as ML STA cannot be on same mac,
+		 * check same band logic as per the ML hw mode, else
+		 * use the API which is hw mode agnostic.
+		 */
+		if (dbs_ml_sta_present)
+			same_mac = policy_mgr_2_freq_same_mac_in_dbs(pm_ctx,
+								sap_ch_freq,
+								pcl_freq);
+		else if (sbs_ml_sta_present)
+			same_mac = policy_mgr_2_freq_same_mac_in_sbs(pm_ctx,
+								sap_ch_freq,
+								pcl_freq);
+		else
+			same_mac = policy_mgr_2_freq_always_on_same_mac(psoc,
+								sap_ch_freq,
+								pcl_freq);
 		if (!((pm_conc_connection_list[0].in_use &&
 		       (pcl_freq == pm_conc_connection_list[0].freq)) ||
 		      (pm_conc_connection_list[1].in_use &&
 		       (pcl_freq == pm_conc_connection_list[1].freq)) ||
 		      (pm_conc_connection_list[2].in_use &&
 		       (pcl_freq == pm_conc_connection_list[2].freq)))) {
-			if (!non_scc_ch_freq_on_same_band &&
-			    WLAN_REG_IS_SAME_BAND_FREQS(sap_ch_freq, pcl_freq))
-				non_scc_ch_freq_on_same_band = pcl_freq;
-			else if (!non_scc_ch_freq_on_diff_band_freq)
-				non_scc_ch_freq_on_diff_band_freq = pcl_freq;
+			if (sap_ch_freq == pcl_freq)
+				non_scc_ch_freq_same_as_sap = pcl_freq;
+			else if (!non_scc_ch_freq_on_same_mac && same_mac)
+				non_scc_ch_freq_on_same_mac = pcl_freq;
+			else if (!non_scc_ch_freq_on_diff_mac && !same_mac)
+				non_scc_ch_freq_on_diff_mac = pcl_freq;
 			continue;
 		}
 
 		if (sap_ch_freq == pcl_freq)
 			scc_ch_freq_same_as_sap = pcl_freq;
-		else if (!scc_ch_freq_on_same_band &&
-			 WLAN_REG_IS_SAME_BAND_FREQS(sap_ch_freq, pcl_freq))
-			scc_ch_freq_on_same_band = pcl_freq;
-		else if (!scc_ch_freq_on_diff_band_freq)
-			scc_ch_freq_on_diff_band_freq = pcl_freq;
+		else if (!scc_ch_freq_on_same_mac && same_mac)
+			scc_ch_freq_on_same_mac = pcl_freq;
+		else if (!scc_ch_freq_on_diff_mac && !same_mac)
+			scc_ch_freq_on_diff_mac = pcl_freq;
 	}
 
 	if (scc_ch_freq_same_as_sap)
 		*intf_ch_freq = scc_ch_freq_same_as_sap;
-	else if (scc_ch_freq_on_same_band)
-		*intf_ch_freq = scc_ch_freq_on_same_band;
-	else if (scc_ch_freq_on_diff_band_freq)
-		*intf_ch_freq = scc_ch_freq_on_diff_band_freq;
-	else if (allow_non_scc && non_scc_ch_freq_on_same_band)
-		*intf_ch_freq = non_scc_ch_freq_on_same_band;
-	else if (allow_non_scc && non_scc_ch_freq_on_diff_band_freq)
-		*intf_ch_freq = non_scc_ch_freq_on_diff_band_freq;
+	else if (scc_ch_freq_on_same_mac)
+		*intf_ch_freq = scc_ch_freq_on_same_mac;
+	else if (non_scc_ch_freq_same_as_sap)
+		*intf_ch_freq = non_scc_ch_freq_same_as_sap;
+	else if (scc_ch_freq_on_diff_mac)
+		*intf_ch_freq = scc_ch_freq_on_diff_mac;
+	else if (non_scc_ch_freq_on_same_mac)
+		*intf_ch_freq = non_scc_ch_freq_on_same_mac;
+	else if (non_scc_ch_freq_on_diff_mac)
+		*intf_ch_freq = non_scc_ch_freq_on_diff_mac;
 	else
 		*intf_ch_freq = 0;
 
+	policy_mgr_debug("2ghz_only %d allow_6ghz %d, ml sta SBS:%d DBS:%d, SCC: same_as_sap %d same_mac %d on_diff_mac %d, NON-SCC: same_as_sap %d same_mac %d on_diff_mac %d. intf_ch_freq %d",
+			 allow_2ghz_only, allow_6ghz, sbs_ml_sta_present,
+			 dbs_ml_sta_present, scc_ch_freq_same_as_sap,
+			 scc_ch_freq_on_same_mac, scc_ch_freq_on_diff_mac,
+			 non_scc_ch_freq_same_as_sap,
+			 non_scc_ch_freq_on_same_mac,
+			 non_scc_ch_freq_on_diff_mac, *intf_ch_freq);
+
 	return QDF_STATUS_SUCCESS;
 }
 
 /**
- * policy_mgr_check_force_scc_three_connection() - Check 3 connection cases
- * to find the force SCC channel for SAP/GO
+ * policy_mgr_handle_sta_sap_fav_channel() - Get preferred force SCC
+ * channel frequency using favorite mandatory channel list
  * @psoc: Pointer to Psoc
- * @vdev_id: vdev id of SAP/GO
- * @intf_ch_freq: interference channel frequency
- * @sap_ch_freq: SAP/GO current home channel frequency
- * @acs_band: acs band preference
- * @allow_6ghz: interface supports 6Ghz band
- *
- * This function gets the force SCC channel in 3 connections case.
+ * @pm_ctx: pm ctx
+ * @vdev_id: vdev id
+ * @intf_ch_freq: prefer force scc frequency
+ * @sap_ch_freq: sap/go channel starting channel frequency
+ * @acs_band: acs band
  *
- * Return: QDF_STATUS_SUCCESS if success
+ * Return: QDF_STATUS_SUCCESS if a valid favorite mandatory force scc channel
+ * is found.
  */
 static QDF_STATUS
-policy_mgr_check_force_scc_three_connection(struct wlan_objmgr_psoc *psoc,
-					    uint8_t vdev_id,
-					    qdf_freq_t *intf_ch_freq,
-					    qdf_freq_t sap_ch_freq,
-					    uint32_t acs_band,
-					    bool allow_6ghz)
+policy_mgr_handle_sta_sap_fav_channel(struct wlan_objmgr_psoc *psoc,
+				      struct policy_mgr_psoc_priv_obj *pm_ctx,
+				      uint8_t vdev_id, qdf_freq_t sap_ch_freq,
+				      qdf_freq_t *intf_ch_freq,
+				      uint32_t acs_band)
 {
-	return policy_mgr_get_pref_force_scc_freq(psoc,
-						  vdev_id,
-						  intf_ch_freq,
-						  sap_ch_freq,
-						  acs_band,
-						  allow_6ghz,
-						  false);
-}
+	bool sta_sap_scc_on_indoor_channel_allowed;
+	QDF_STATUS status = QDF_STATUS_E_FAILURE;
+	qdf_freq_t user_config_freq;
 
-static void
-policy_mgr_check_force_scc_two_connection(struct wlan_objmgr_psoc *psoc,
-					  uint8_t vdev_id,
-					  qdf_freq_t *intf_ch_freq,
-					  qdf_freq_t sap_ch_freq,
-					  uint8_t cc_mode,
-					  bool same_band_present,
-					  uint32_t acs_band,
-					  bool allow_6ghz)
-{
-	bool sbs_mlo_present = false;
-	bool dbs_mlo_present = false;
+	 /* intf_ch_freq and SAP freq in same band */
+	if (WLAN_REG_IS_24GHZ_CH_FREQ(*intf_ch_freq) ==
+	    WLAN_REG_IS_24GHZ_CH_FREQ(sap_ch_freq))
+		return policy_mgr_get_sap_mandatory_channel(psoc, sap_ch_freq,
+							intf_ch_freq, vdev_id);
 
+	/* intf_ch_freq and SAP freq in different band */
 	/*
-	 * 1st:    2nd:           3rd(SAP):      Action:
-	 * -------------------------------------------------
-	 * 2Ghz    2Ghz(SMM/DBS)  5Ghz           Start on 5Ghz
-	 * 2Ghz    5Ghz(DBS)      5Ghz           Force SCC to 5Ghz
-	 * 2Ghz    5Ghz(DBS)      2Ghz           Force SCC to 5Ghz
-	 * 5Ghz    5Ghz(SBS)      2Ghz           If acs is ALL band force SCC
-	 *                                       else start on 2.4Ghz
-	 * 5Ghz    5Ghz(SBS)      5Ghz           Force SCC to one of 5Ghz
-	 * 5Ghz    5Ghz(SMM)      2Ghz           Start on 2.4Ghz
-	 * 5Ghz    5Ghz(SMM)      5Ghz           Allow SAP on sap_ch_freq if all
-	 *                                       3, 5Ghz freq doesn't end up
-	 *                                       on same mac, ie 2 of them lead
-	 *                                       to SBS. Else force SCC on
-	 *                                       one of the freq (3 home channel
-	 *                                       will not be allowed)
-	 * 2Ghz    2Ghz(SMM/DBS)  2Ghz           force SCC on one of the freq
-	 *                                       (3 home channel
-	 *                                       will not be allowed)
+	 * STA + SAP where doing SCC on 5 GHz indoor channel.
+	 * STA moved/roamed to 2.4 GHz. Move SAP to initially
+	 * started channel.
+	 *
+	 * STA+SAP where STA is moved/roamed to 5GHz indoor
+	 * and SAP is on 2.4 GHz due to previous concurrency.
+	 * Move SAP to STA channel on SCC.
 	 */
+	sta_sap_scc_on_indoor_channel_allowed =
+		policy_mgr_get_sta_sap_scc_allowed_on_indoor_chnl(psoc);
 
-	/* Check if STA or SAP SBS MLO is present */
-	if (policy_mgr_is_hw_sbs_capable(psoc) &&
-	    (policy_mgr_is_mlo_in_mode_sbs(psoc, PM_STA_MODE,
-					   NULL, NULL) ||
-	     policy_mgr_is_mlo_in_mode_sbs(psoc, PM_SAP_MODE,
-					   NULL, NULL)))
-		sbs_mlo_present = true;
-
-	/*
-	 * Check for SBS mlo present as if 1 link is inactive the
-	 * HW mode will be SMM and not SBS.
-	 */
-	if (policy_mgr_is_current_hwmode_sbs(psoc) || sbs_mlo_present) {
-		/*
-		 * 1st:    2nd:        3rd(SAP):   Action:
-		 * -------------------------------------------------
-		 * 5Ghz    5Ghz(SBS)   2Ghz        If acs is ALL band force SCC
-		 *                                 else start on 2.4Ghz
-		 * 5Ghz    5Ghz(SBS)   5Ghz        Force SCC to one of 5Ghz
-		 *
-		 * Need to consider protocol 6ghz allow flag - allow_6ghz.
-		 * Also for regdomain, need to consider PCL if STA is on 6ghz
-		 * LPI mode, SAP is not allowed started on 6ghz, see API
-		 * policy_mgr_modify_sap_pcl_for_6G_channels.
-		 */
-		policy_mgr_get_pref_force_scc_freq(psoc,
-						   vdev_id,
-						   intf_ch_freq,
-						   sap_ch_freq,
-						   acs_band,
-						   allow_6ghz,
-						   true);
-		return;
-	}
 	/*
-	 * Check for dbs mlo present as if 1 link is inactive the
-	 * HW mode will be SMM and not dbs.
+	 * SAP and interface freq in different band and 5 GHz freq is
+	 * indoor
 	 */
-	if (policy_mgr_is_hw_dbs_capable(psoc) &&
-	    (policy_mgr_is_mlo_in_mode_dbs(psoc, PM_STA_MODE,
-					   NULL, NULL) ||
-	     policy_mgr_is_mlo_in_mode_dbs(psoc, PM_SAP_MODE,
-					   NULL, NULL)))
-		dbs_mlo_present = true;
-
-	if (policy_mgr_is_current_hwmode_dbs(psoc) || dbs_mlo_present) {
-		/*
-		 * 1st:    2nd:           3rd(SAP):      Action:
-		 * -------------------------------------------------
-		 * 2Ghz    2Ghz(DBS)      5Ghz           Start on 5Ghz
-		 * 2Ghz    5Ghz(DBS)      5Ghz           Force SCC to 5Ghz
-		 * 2Ghz    5Ghz(DBS)      2Ghz           Force SCC to 5Ghz
-		 * 2Ghz    2Ghz(DBS)      2Ghz           force SCC on one of
-		 *                                       the freq (3 home
-		 *                                       channel will not be
-		 *                                       allowed)
-		 *
-		 * Need to consider protocol 6ghz allow flag - allow_6ghz.
-		 * Also for regdomain, need to consider PCL if STA is on 6ghz
-		 * LPI mode, SAP is not allowed started on 6ghz, see API
-		 * policy_mgr_modify_sap_pcl_for_6G_channels.
-		 */
-		policy_mgr_get_pref_force_scc_freq(psoc,
-						   vdev_id,
-						   intf_ch_freq,
-						   sap_ch_freq,
-						   acs_band,
-						   allow_6ghz,
-						   true);
-		return;
+	if (sta_sap_scc_on_indoor_channel_allowed &&
+	    ((wlan_reg_is_freq_indoor(pm_ctx->pdev, sap_ch_freq) &&
+	    WLAN_REG_IS_24GHZ_CH_FREQ(*intf_ch_freq)) ||
+	    (wlan_reg_is_freq_indoor(pm_ctx->pdev, *intf_ch_freq) &&
+	     WLAN_REG_IS_24GHZ_CH_FREQ(sap_ch_freq) &&
+	     !(acs_band == QCA_ACS_MODE_IEEE80211B ||
+	       acs_band == QCA_ACS_MODE_IEEE80211G)))) {
+		status = policy_mgr_get_sap_mandatory_channel(psoc, sap_ch_freq,
+							      intf_ch_freq,
+							      vdev_id);
+		if (QDF_IS_STATUS_SUCCESS(status))
+			return status;
 	}
 
-	if (!same_band_present) {
-		/*
-		 * 1st:    2nd:           3rd(SAP):      Action:
-		 * -------------------------------------------------
-		 * 2Ghz    2Ghz(SMM)      5Ghz           Start on 5Ghz(DBS)
-		 * 5Ghz    5Ghz(SMM)      2Ghz           Start on 2.4Ghz(DBS)
-		 */
-		if (policy_mgr_is_hw_dbs_capable(psoc))
-			*intf_ch_freq = 0;
-		return;
-	}
+	user_config_freq =
+		policy_mgr_get_user_config_sap_freq(psoc, vdev_id);
 
-	if (!policy_mgr_3_freq_always_on_same_mac(psoc, sap_ch_freq,
-					pm_conc_connection_list[0].freq,
-					pm_conc_connection_list[1].freq)) {
-		/*
-		 * 1st:    2nd:           3rd(SAP):     Action:
-		 * -------------------------------------------------
-		 * 5Ghz    5Ghz(SMM)      5Ghz          Allow SAP on sap_ch_freq
-		 *                                      if all 3, 5Ghz freq
-		 *                                      doesn't end up, on same
-		 *                                      mac, ie 2 of them lead
-		 *                                      to SBS, ie at least one
-		 *                                      of them is high 5Ghz and
-		 *                                      one low 5Ghz.
-		 */
-		*intf_ch_freq = 0;
-		return;
+	if (WLAN_REG_IS_24GHZ_CH_FREQ(sap_ch_freq) &&
+	    user_config_freq &&
+	    !WLAN_REG_IS_24GHZ_CH_FREQ(user_config_freq) &&
+	    (wlan_reg_get_channel_state_for_pwrmode(pm_ctx->pdev, *intf_ch_freq,
+			REG_CURRENT_PWR_MODE) == CHANNEL_STATE_ENABLE)) {
+		status = policy_mgr_get_sap_mandatory_channel(psoc, sap_ch_freq,
+							      intf_ch_freq,
+							      vdev_id);
+		if (QDF_IS_STATUS_SUCCESS(status))
+			return status;
 	}
 
-	/*
-	 * 1st:    2nd:           3rd(SAP):     Action:
-	 * -------------------------------------------------
-	 * 5Ghz    5Ghz(SMM)      5Ghz          force SCC on one of the freq
-	 *                                      (3 home channel will not be
-	 *                                      allowed)
-	 * 2Ghz    2Ghz(SMM)      2Ghz          force SCC on one of the freq
-	 *                                      (3 home channel will not be
-	 *                                      allowed)
-	 */
-	policy_mgr_debug("%d Can lead to 3 home channel on same MAC",
-			 sap_ch_freq);
-}
-
-static void
-policy_mgr_check_force_scc_one_connection(struct wlan_objmgr_psoc *psoc,
-					  qdf_freq_t *intf_ch_freq,
-					  qdf_freq_t sap_ch_freq,
-					  bool same_band_present,
-					  uint8_t cc_mode)
-{
-	/*
-	 * 1st:    2nd(SAP):      Action:
-	 * ------------------------------------
-	 * 2Ghz     2Ghz          Force SCC on 2Ghz
-	 * 5Ghz     5Ghz          Force SCC on 5Ghz for non SBS, for SBS freq
-	 *                        allow sap freq
-	 * 2Ghz     5Ghz          Start on 5Ghz (DBS)
-	 * 5Ghz     2Ghz          Start on 2.4Ghz(DBS)
-	 */
-
-	if (same_band_present) {
-		/*
-		 * 1st:    2nd(SAP):      Action:
-		 * ------------------------------------
-		 * 2Ghz     2Ghz          Force SCC on 2Ghz
-		 * 5Ghz     5Ghz          Force SCC on 5Ghz for non SBS,
-		 *                        for SBS freq allow sap freq
-		 */
-		if (policy_mgr_are_sbs_chan(psoc, sap_ch_freq, *intf_ch_freq)) {
-			policy_mgr_debug("Do not overwrite as sap_ch_freq %d intf_ch_freq %d are SBS freq",
-					 sap_ch_freq, *intf_ch_freq);
-			*intf_ch_freq = 0;
-		}
-		return;
-	}
-	if (policy_mgr_is_hw_dbs_capable(psoc) ||
-	    cc_mode ==  QDF_MCC_TO_SCC_WITH_PREFERRED_BAND) {
-		/*
-		 * 1st:    2nd(SAP):      Action:
-		 * ------------------------------------
-		 * 2Ghz     5Ghz          Start on 5Ghz (DBS)
-		 * 5Ghz     2Ghz          Start on 2.4Ghz(DBS)
-		 */
-		/* Different bands can do DBS so dont overwrite */
-		*intf_ch_freq = 0;
-	}
+	return status;
 }
 
-void policy_mgr_check_scc_sbs_channel(struct wlan_objmgr_psoc *psoc,
-				      qdf_freq_t *intf_ch_freq,
-				      qdf_freq_t sap_ch_freq,
-				      uint8_t vdev_id, uint8_t cc_mode)
+void policy_mgr_check_scc_channel(struct wlan_objmgr_psoc *psoc,
+				  qdf_freq_t *intf_ch_freq,
+				  qdf_freq_t sap_ch_freq,
+				  uint8_t vdev_id, uint8_t cc_mode)
 {
 	uint32_t num_connections, acs_band = QCA_ACS_MODE_IEEE80211ANY;
 	struct policy_mgr_psoc_priv_obj *pm_ctx;
@@ -4316,11 +4201,8 @@ void policy_mgr_check_scc_sbs_channel(struct wlan_objmgr_psoc *psoc,
 	struct policy_mgr_conc_connection_info
 			info[MAX_NUMBER_OF_CONC_CONNECTIONS] = { {0} };
 	uint8_t num_cxn_del = 0;
-	bool same_band_present = false;
-	bool sbs_mlo_present = false;
-	bool allow_6ghz = true, sta_sap_scc_on_indoor_channel_allowed;
+	bool allow_6ghz = true;
 	uint8_t sta_count;
-	qdf_freq_t user_config_freq;
 
 	pm_ctx = policy_mgr_get_context(psoc);
 	if (!pm_ctx) {
@@ -4335,25 +4217,6 @@ void policy_mgr_check_scc_sbs_channel(struct wlan_objmgr_psoc *psoc,
 
 	sta_count = policy_mgr_mode_specific_connection_count(psoc, PM_STA_MODE,
 							      NULL);
-	/*
-	 * If same band interface is present, as
-	 * csr_check_concurrent_channel_overlap try to find same band vdev
-	 * if available
-	 */
-	if ((WLAN_REG_IS_24GHZ_CH_FREQ(sap_ch_freq) &&
-	     WLAN_REG_IS_24GHZ_CH_FREQ(*intf_ch_freq)) ||
-	    (!WLAN_REG_IS_24GHZ_CH_FREQ(*intf_ch_freq) &&
-	     !WLAN_REG_IS_24GHZ_CH_FREQ(sap_ch_freq)))
-		same_band_present = true;
-
-	/* Check if STA or SAP SBS MLO is present */
-	if (policy_mgr_is_hw_sbs_capable(psoc) &&
-	    (policy_mgr_is_mlo_in_mode_sbs(psoc, PM_STA_MODE,
-					   NULL, NULL) ||
-	     policy_mgr_is_mlo_in_mode_sbs(psoc, PM_SAP_MODE,
-					   NULL, NULL)))
-		sbs_mlo_present = true;
-
 	if (pm_ctx->hdd_cbacks.wlan_get_sap_acs_band) {
 		status = pm_ctx->hdd_cbacks.wlan_get_sap_acs_band(psoc,
 								  vdev_id,
@@ -4362,106 +4225,17 @@ void policy_mgr_check_scc_sbs_channel(struct wlan_objmgr_psoc *psoc,
 			policy_mgr_debug("acs_band: %d", acs_band);
 	}
 
-	/*
-	 * Different band, this also mean that there is no other interface on
-	 * on same band as csr_check_concurrent_channel_overlap
-	 * try to find same band vdev if available.
-	 * this mean for DBS HW we can use the other available band and thus
-	 * set *intf_ch_freq = 0, to bring sap on sap_ch_freq.
-	 */
-	if (!same_band_present) {
-		/*
-		 * STA + SAP where doing SCC on 5 GHz indoor channel.
-		 * STA moved/roamed to 2.4 GHz. Move SAP to initially
-		 * started channel.
-		 *
-		 * STA+SAP where STA is moved/roamed to 5GHz indoor
-		 * and SAP is on 2.4GHz due to previous concurrency.
-		 * Move SAP to STA channel on SCC.
-		 */
-		sta_sap_scc_on_indoor_channel_allowed =
-			policy_mgr_get_sta_sap_scc_allowed_on_indoor_chnl(psoc);
-
-		if (sta_count && cc_mode ==
-				QDF_MCC_TO_SCC_SWITCH_WITH_FAVORITE_CHANNEL &&
-		    sta_sap_scc_on_indoor_channel_allowed &&
-		    ((wlan_reg_is_freq_indoor(pm_ctx->pdev, sap_ch_freq) &&
-		    WLAN_REG_IS_24GHZ_CH_FREQ(*intf_ch_freq)) ||
-		    (wlan_reg_is_freq_indoor(pm_ctx->pdev, *intf_ch_freq) &&
-		     WLAN_REG_IS_24GHZ_CH_FREQ(sap_ch_freq) &&
-		     !(acs_band == QCA_ACS_MODE_IEEE80211B ||
-		       acs_band == QCA_ACS_MODE_IEEE80211G)))) {
-			status = policy_mgr_get_sap_mandatory_channel(
-							psoc, sap_ch_freq,
-							intf_ch_freq, vdev_id);
-			if (QDF_IS_STATUS_SUCCESS(status))
-				return;
-
-			policy_mgr_err("No mandatory channels");
-		}
-
-		user_config_freq =
-			policy_mgr_get_user_config_sap_freq(psoc, vdev_id);
-
-		if (sta_count && cc_mode ==
-				QDF_MCC_TO_SCC_SWITCH_WITH_FAVORITE_CHANNEL &&
-			WLAN_REG_IS_24GHZ_CH_FREQ(sap_ch_freq) &&
-		    user_config_freq &&
-		    !WLAN_REG_IS_24GHZ_CH_FREQ(user_config_freq) &&
-		    (wlan_reg_get_channel_state_for_pwrmode(
-			pm_ctx->pdev,
-			*intf_ch_freq,
-			REG_CURRENT_PWR_MODE) == CHANNEL_STATE_ENABLE)) {
-			status = policy_mgr_get_sap_mandatory_channel(
-							psoc, sap_ch_freq,
-							intf_ch_freq, vdev_id);
-			if (QDF_IS_STATUS_SUCCESS(status))
-				return;
-		}
-
-		if (policy_mgr_is_current_hwmode_sbs(psoc) || sbs_mlo_present)
-			goto sbs_check;
-		/*
-		 * #1 port:
-		 * 1st:    2nd(SAP):      Action:
-		 * ------------------------------------
-		 * 2Ghz     5Ghz          Start on 5Ghz(DBS)
-		 * 5Ghz     2Ghz          Start on 2.4Ghz(DBS)
-		 *
-		 * #2 port:
-		 * 1st:    2nd:           3rd(SAP):      Action:
-		 * -------------------------------------------------
-		 * 2Ghz    2Ghz(SMM/DBS)  5Ghz           Start on 5Ghz(DBS)
-		 * 5Ghz    5Ghz(SMM)      2Ghz           Start on 2.4Ghz(DBS)
-		 *
-		 * #3 port:
-		 * 1st:    2nd:    3rd:    4th(SAP)      Action:
-		 * -------------------------------------------------
-		 * 2Ghz    2Ghz    2Ghz   5Ghz           Start on 5Ghz(DBS)
-		 * 5Ghz    5Ghz    5Ghz   2Ghz           Start on 2.4Ghz(DBS)
-		 */
-		if (policy_mgr_is_hw_dbs_capable(psoc) ||
-		    cc_mode ==  QDF_MCC_TO_SCC_WITH_PREFERRED_BAND) {
-			*intf_ch_freq = 0;
-			return;
-		}
-	} else if (sta_count && sta_count < 2 &&
-		   policy_mgr_is_hw_dbs_capable(psoc) &&
-		   cc_mode == QDF_MCC_TO_SCC_SWITCH_WITH_FAVORITE_CHANNEL) {
-		/* Same band with Fav channel if STA is present */
-		status = policy_mgr_get_sap_mandatory_channel(psoc,
-							      sap_ch_freq,
-							      intf_ch_freq,
-							      vdev_id);
+	/* Handle STA + SAP mandaory freq cases */
+	if (sta_count && sta_count < 2 &&
+	    cc_mode == QDF_MCC_TO_SCC_SWITCH_WITH_FAVORITE_CHANNEL) {
+		status = policy_mgr_handle_sta_sap_fav_channel(psoc, pm_ctx,
+				vdev_id, sap_ch_freq, intf_ch_freq, acs_band);
 		if (QDF_IS_STATUS_SUCCESS(status))
 			return;
-
 		policy_mgr_debug("no mandatory channels (%d, %d)", sap_ch_freq,
 				 *intf_ch_freq);
 	}
 
-sbs_check:
-
 	/* Get allow 6Gz before interface entry is temporary deleted */
 	if (sap_ch_freq && !WLAN_REG_IS_6GHZ_CHAN_FREQ(sap_ch_freq) &&
 	    !policy_mgr_get_ap_6ghz_capable(psoc, vdev_id, NULL))
@@ -4475,44 +4249,25 @@ sbs_check:
 	policy_mgr_store_and_del_conn_info_by_vdev_id(psoc, vdev_id, info,
 						      &num_cxn_del);
 
-	/*
-	 * If at least one interface is in same band OR HW mode is SBS OR
-	 * SBS MLO is present, try set SBS/DBS/SCC.
-	 */
 	num_connections = policy_mgr_get_connection_count(psoc);
-	policy_mgr_dump_sbs_freq_range(pm_ctx);
 	switch (num_connections) {
 	case 0:
 		/* use sap channel */
 		*intf_ch_freq = 0;
 		break;
-	case 1:
-		policy_mgr_check_force_scc_one_connection(psoc, intf_ch_freq,
-							  sap_ch_freq,
-							  same_band_present,
-							  cc_mode);
-		break;
-	case 2:
-		policy_mgr_check_force_scc_two_connection(psoc, vdev_id,
-							  intf_ch_freq,
-							  sap_ch_freq,
-							  cc_mode,
-							  same_band_present,
-							  acs_band,
-							  allow_6ghz);
-		break;
-	case 3:
-		policy_mgr_check_force_scc_three_connection(psoc, vdev_id,
-							    intf_ch_freq,
-							    sap_ch_freq,
-							    acs_band,
-							    allow_6ghz);
-		break;
 	default:
-		policy_mgr_debug("invalid num_connections: %d",
-				 num_connections);
+		if (num_connections > 3) {
+			policy_mgr_debug("invalid num_connections: %d",
+					 num_connections);
+			break;
+		}
+		/* Use PCL and concurrency combo to get the best channel */
+		policy_mgr_get_pref_force_scc_freq(psoc, vdev_id, intf_ch_freq,
+						   sap_ch_freq, acs_band,
+						   allow_6ghz);
 		break;
 	}
+
 	/* Restore the connection entry */
 	if (num_cxn_del > 0)
 		policy_mgr_restore_deleted_conn_info(psoc, info, num_cxn_del);

+ 16 - 9
components/cmn_services/policy_mgr/src/wlan_policy_mgr_get_set_utils.c

@@ -1762,6 +1762,21 @@ policy_mgr_sbs_24_shared_with_low_5(struct policy_mgr_psoc_priv_obj *pm_ctx)
 	return false;
 }
 
+bool
+policy_mgr_2_freq_same_mac_in_dbs(struct policy_mgr_psoc_priv_obj *pm_ctx,
+				  qdf_freq_t freq_1, qdf_freq_t freq_2)
+{
+	struct policy_mgr_freq_range *freq_range;
+
+	/* Return true if non DBS capable HW */
+	if (!policy_mgr_is_hw_dbs_capable(pm_ctx->psoc))
+		return true;
+
+	freq_range = pm_ctx->hw_mode.freq_range_caps[MODE_DBS];
+	return policy_mgr_2_freq_same_mac_in_freq_range(pm_ctx, freq_range,
+							 freq_1, freq_2);
+}
+
 bool
 policy_mgr_2_freq_same_mac_in_sbs(struct policy_mgr_psoc_priv_obj *pm_ctx,
 				  qdf_freq_t freq_1, qdf_freq_t freq_2)
@@ -1821,7 +1836,6 @@ bool policy_mgr_2_freq_always_on_same_mac(struct wlan_objmgr_psoc *psoc,
 					  qdf_freq_t freq_1, qdf_freq_t freq_2)
 {
 	struct policy_mgr_psoc_priv_obj *pm_ctx;
-	struct policy_mgr_freq_range *freq_range;
 	bool is_dbs_mode_same_mac = true;
 	bool is_sbs_mode_same_mac = true;
 
@@ -1829,15 +1843,8 @@ bool policy_mgr_2_freq_always_on_same_mac(struct wlan_objmgr_psoc *psoc,
 	if (!pm_ctx)
 		return false;
 
-	/* if HW is not DBS return true*/
-	if (!policy_mgr_is_hw_dbs_capable(psoc))
-		return true;
-
-	/* Check for DBS mode first */
-	freq_range = pm_ctx->hw_mode.freq_range_caps[MODE_DBS];
 	is_dbs_mode_same_mac =
-		policy_mgr_2_freq_same_mac_in_freq_range(pm_ctx, freq_range,
-							 freq_1, freq_2);
+		policy_mgr_2_freq_same_mac_in_dbs(pm_ctx, freq_1, freq_2);
 
 	/* if DBS mode leading to same mac, check for SBS mode */
 	if (is_dbs_mode_same_mac)

+ 16 - 0
components/cmn_services/policy_mgr/src/wlan_policy_mgr_i.h

@@ -1132,6 +1132,22 @@ policy_mgr_sbs_24_shared_with_high_5(struct policy_mgr_psoc_priv_obj *pm_ctx);
 bool
 policy_mgr_sbs_24_shared_with_low_5(struct policy_mgr_psoc_priv_obj *pm_ctx);
 
+/**
+ * policy_mgr_2_freq_same_mac_in_dbs() - to check provided frequencies are
+ * in dbs freq range or not
+ *
+ * @pm_ctx: policy mgr psoc priv object
+ * @freq_1: first frequency
+ * @freq_2: second frequency
+ *
+ * This API is used to check provided frequencies are in dbs freq range or not
+ *
+ * Return: true/false.
+ */
+bool
+policy_mgr_2_freq_same_mac_in_dbs(struct policy_mgr_psoc_priv_obj *pm_ctx,
+				  qdf_freq_t freq_1, qdf_freq_t freq_2);
+
 /**
  * policy_mgr_2_freq_same_mac_in_sbs() - to check provided frequencies are
  * in sbs freq range or not

+ 15 - 4
core/sme/inc/csr_internal.h

@@ -486,10 +486,21 @@ uint32_t csr_get_beaconing_concurrent_channel(struct mac_context *mac_ctx,
 					      uint8_t vdev_id_to_skip);
 
 #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
-uint16_t csr_check_concurrent_channel_overlap(
-		struct mac_context *mac,
-		uint32_t sap_ch_freq, eCsrPhyMode sap_phymode,
-		uint8_t cc_switch_mode, uint8_t vdev_id);
+/**
+ * csr_check_concurrent_channel_overlap() - To check concurrent overlap chnls
+ * @mac: Pointer to mac context
+ * @sap_freq: Requested SAP freq
+ * @sap_phymode: SAP phy mode
+ * @cc_switch_mode: concurrent switch mode
+ * @vdev_id: vdev id of SAP/GO requesting
+ *
+ * This routine will be called to check concurrent overlap channels
+ *
+ * Return: uint16_t
+ */
+uint16_t csr_check_concurrent_channel_overlap(struct mac_context *mac,
+				uint32_t sap_freq, eCsrPhyMode sap_phymode,
+				uint8_t cc_switch_mode, uint8_t vdev_id);
 #endif
 
 /* Returns whether the current association is a 11r assoc or not */

+ 7 - 0
core/sme/inc/sme_api.h

@@ -1333,6 +1333,13 @@ QDF_STATUS sme_update_add_ie(mac_handle_t mac_handle,
 		tSirUpdateIE *pUpdateIE, eUpdateIEsType updateType);
 QDF_STATUS sme_update_connect_debug(mac_handle_t mac_handle,
 				    uint32_t set_value);
+
+/**
+ * sme_bss_type_to_string() - converts bss type to string.
+ * @bss_type: bss type enum
+ *
+ * Return: printable string for bss type
+ */
 const char *sme_bss_type_to_string(const uint8_t bss_type);
 QDF_STATUS sme_ap_disable_intra_bss_fwd(mac_handle_t mac_handle,
 					uint8_t sessionId,

+ 3 - 21
core/sme/src/csr/csr_util.c

@@ -589,18 +589,6 @@ static void csr_handle_conc_chnl_overlap_for_sap_go(
 	}
 }
 
-
-/**
- * csr_check_concurrent_channel_overlap() - To check concurrent overlap chnls
- * @mac_ctx: Pointer to mac context
- * @sap_ch: SAP channel
- * @sap_phymode: SAP phy mode
- * @cc_switch_mode: concurrent switch mode
- *
- * This routine will be called to check concurrent overlap channels
- *
- * Return: uint16_t
- */
 uint16_t csr_check_concurrent_channel_overlap(struct mac_context *mac_ctx,
 			uint32_t sap_ch_freq, eCsrPhyMode sap_phymode,
 			uint8_t cc_switch_mode, uint8_t vdev_id)
@@ -700,9 +688,9 @@ uint16_t csr_check_concurrent_channel_overlap(struct mac_context *mac_ctx,
 			intf_ch_freq = 0;
 	} else if (intf_ch_freq && sap_ch_freq != intf_ch_freq &&
 		   (policy_mgr_is_force_scc(mac_ctx->psoc))) {
-		policy_mgr_check_scc_sbs_channel(mac_ctx->psoc, &intf_ch_freq,
-						 sap_ch_freq, vdev_id,
-						 cc_switch_mode);
+		policy_mgr_check_scc_channel(mac_ctx->psoc, &intf_ch_freq,
+					     sap_ch_freq, vdev_id,
+					     cc_switch_mode);
 	} else if ((intf_ch_freq == sap_ch_freq) && (cc_switch_mode ==
 				QDF_MCC_TO_SCC_SWITCH_WITH_FAVORITE_CHANNEL)) {
 		if (WLAN_REG_IS_24GHZ_CH_FREQ(intf_ch_freq) ||
@@ -1198,12 +1186,6 @@ uint16_t sme_chn_to_freq(uint8_t chanNum)
 	return 0;
 }
 
-/**
- * sme_bsstype_to_string() - converts bss type to string.
- * @bss_type: bss type enum
- *
- * Return: printable string for bss type
- */
 const char *sme_bss_type_to_string(const uint8_t bss_type)
 {
 	switch (bss_type) {