From e75eb51af1e08185f9e527362666e81852f3fe8d Mon Sep 17 00:00:00 2001 From: Jianmin Zhu Date: Wed, 18 Dec 2019 17:38:03 +0800 Subject: [PATCH] qcacld-3.0: 5G SAP failed to channel switch for sta connecting When 5G band is disabled by set band, need SAP switch channel to 2G. When 5G band is enabled again, need SAP switch back to original 5G channel. When sta connecting, SAP can't switch channel. Merge logic of SAP channel switch for band change and for force scc with sta, both are implemented in: policy_mgr_check_concurrent_intf_and_restart_sap now. After sta associate succeed or fail, policy_mgr_check_concurrent_intf_and_restart_sap is called again to check and try SAP CSA for band capability change. Change-Id: I8574209aac3cabb748a8ec05050244f480e1a0e9 CRs-Fixed: 2589021 --- .../policy_mgr/src/wlan_policy_mgr_action.c | 45 ++++++++----------- core/hdd/src/wlan_hdd_assoc.c | 2 + core/hdd/src/wlan_hdd_hostapd.c | 35 +++++++-------- core/hdd/src/wlan_hdd_regulatory.c | 23 ++-------- core/sap/inc/sap_api.h | 12 +++-- core/sap/src/sap_module.c | 40 ++++++++--------- 6 files changed, 64 insertions(+), 93 deletions(-) diff --git a/components/cmn_services/policy_mgr/src/wlan_policy_mgr_action.c b/components/cmn_services/policy_mgr/src/wlan_policy_mgr_action.c index 0b2129d1c78ad..91be79c3a1007 100644 --- a/components/cmn_services/policy_mgr/src/wlan_policy_mgr_action.c +++ b/components/cmn_services/policy_mgr/src/wlan_policy_mgr_action.c @@ -1265,42 +1265,25 @@ void policy_mgr_update_user_config_sap_chan( } /** - * policy_mgr_is_restart_sap_allowed() - Check if restart SAP - * allowed during SCC -> MCC switch + * policy_mgr_is_sap_go_existed() - Check if restart SAP/Go exist * @psoc: PSOC object data - * @mcc_to_scc_switch: MCC to SCC switch enabled user config - * - * Check if restart SAP allowed during SCC->MCC switch * + * To simplify, if SAP/P2P Go exist, they may need switch channel for + * forcing scc with sta or band capability change. * Restart: true or false */ -static bool policy_mgr_is_restart_sap_allowed( - struct wlan_objmgr_psoc *psoc, - uint32_t mcc_to_scc_switch) +static bool policy_mgr_is_sap_go_existed(struct wlan_objmgr_psoc *psoc) { - uint32_t sta_ap_bit_mask = QDF_STA_MASK | QDF_SAP_MASK; - uint32_t sta_go_bit_mask = QDF_STA_MASK | QDF_P2P_GO_MASK; uint32_t ap_present, go_present; - bool sta_ap_coexist, sta_go_coexist; - if ((mcc_to_scc_switch == QDF_MCC_TO_SCC_SWITCH_DISABLE) || - !policy_mgr_concurrent_open_sessions_running(psoc)) { - policy_mgr_debug("MCC switch disabled or not concurrent STA/SAP, STA/GO"); - return false; - } ap_present = policy_mgr_mode_specific_connection_count( psoc, PM_SAP_MODE, NULL); - sta_ap_coexist = (policy_mgr_get_concurrency_mode(psoc) & - sta_ap_bit_mask) == sta_ap_bit_mask; - if (ap_present && sta_ap_coexist) + if (ap_present) return true; go_present = policy_mgr_mode_specific_connection_count( psoc, PM_P2P_GO_MODE, NULL); - sta_go_coexist = (policy_mgr_get_concurrency_mode(psoc) & - sta_go_bit_mask) == sta_go_bit_mask; - if (go_present && sta_go_coexist && - policy_mgr_go_scc_enforced(psoc)) + if (go_present) return true; return false; @@ -1770,7 +1753,7 @@ static void __policy_mgr_check_sta_ap_concurrent_ch_intf(void *data) policy_mgr_info("Concurrent open sessions running: %d", policy_mgr_concurrent_open_sessions_running(psoc)); - if (!policy_mgr_is_restart_sap_allowed(psoc, mcc_to_scc_switch)) + if (!policy_mgr_is_sap_go_existed(psoc)) goto end; cc_count = policy_mgr_get_mode_specific_conn_info( @@ -1980,6 +1963,12 @@ void policy_mgr_check_concurrent_intf_and_restart_sap( uint32_t cc_count = 0; bool restart_sap = false; uint32_t sap_freq; + /* + * if no sta, sap/p2p go may need switch channel for band + * capability change. + * If sta exist, sap/p2p go may need switch channel to force scc + */ + bool sta_check; pm_ctx = policy_mgr_get_context(psoc); if (!pm_ctx) { @@ -2014,15 +2003,17 @@ void policy_mgr_check_concurrent_intf_and_restart_sap( &vdev_id[cc_count], PM_STA_MODE); if (!cc_count) { policy_mgr_debug("Could not get STA operating channel&vdevid"); - return; } + sta_check = !cc_count || + policy_mgr_valid_sta_channel_check(psoc, op_ch_freq_list[0]); + mcc_to_scc_switch = policy_mgr_get_mcc_to_scc_switch_mode(psoc); policy_mgr_info("MCC to SCC switch: %d chan: %d", mcc_to_scc_switch, op_ch_freq_list[0]); - if (!policy_mgr_is_restart_sap_allowed(psoc, mcc_to_scc_switch)) { + if (!policy_mgr_is_sap_go_existed(psoc)) { policy_mgr_debug( "No action taken at check_concurrent_intf_and_restart_sap"); return; @@ -2040,7 +2031,7 @@ sap_restart: */ if (restart_sap || ((mcc_to_scc_switch != QDF_MCC_TO_SCC_SWITCH_DISABLE) && - policy_mgr_valid_sta_channel_check(psoc, op_ch_freq_list[0]))) { + sta_check)) { if (pm_ctx->sta_ap_intf_check_work_info) { qdf_sched_work(0, &pm_ctx->sta_ap_intf_check_work); policy_mgr_info( diff --git a/core/hdd/src/wlan_hdd_assoc.c b/core/hdd/src/wlan_hdd_assoc.c index e74528eb53fdd..828a200207630 100644 --- a/core/hdd/src/wlan_hdd_assoc.c +++ b/core/hdd/src/wlan_hdd_assoc.c @@ -3706,6 +3706,8 @@ hdd_association_completion_handler(struct hdd_adapter *adapter, roam_status == eCSR_ROAM_CANCELLED) && hddDisconInProgress) complete(&adapter->disconnect_comp_var); + + policy_mgr_check_concurrent_intf_and_restart_sap(hdd_ctx->psoc); } return QDF_STATUS_SUCCESS; diff --git a/core/hdd/src/wlan_hdd_hostapd.c b/core/hdd/src/wlan_hdd_hostapd.c index 02d09e2b3498f..c404223d157a9 100644 --- a/core/hdd/src/wlan_hdd_hostapd.c +++ b/core/hdd/src/wlan_hdd_hostapd.c @@ -3088,8 +3088,6 @@ QDF_STATUS wlan_hdd_get_channel_for_sap_restart( struct hdd_ap_ctx *hdd_ap_ctx; uint8_t intf_ch = 0, sap_ch = 0; struct hdd_context *hdd_ctx; - struct hdd_station_ctx *hdd_sta_ctx; - struct hdd_adapter *sta_adapter; uint8_t mcc_to_scc_switch = 0; struct ch_params ch_params; struct hdd_adapter *ap_adapter = wlan_hdd_get_adapter_from_vdev( @@ -3107,13 +3105,6 @@ QDF_STATUS wlan_hdd_get_channel_for_sap_restart( return QDF_STATUS_E_FAILURE; } - /* TODO: need work for 3 port case with sta+sta */ - sta_adapter = hdd_get_adapter(hdd_ctx, QDF_STA_MODE); - if (!sta_adapter) { - hdd_err("sta_adapter is NULL"); - return QDF_STATUS_E_FAILURE; - } - if (!ch_freq) { hdd_err("Null parameters"); return QDF_STATUS_E_FAILURE; @@ -3125,7 +3116,6 @@ QDF_STATUS wlan_hdd_get_channel_for_sap_restart( } hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); - hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(sta_adapter); mac_handle = hdd_ctx->mac_handle; if (!mac_handle) { @@ -3156,15 +3146,16 @@ QDF_STATUS wlan_hdd_get_channel_for_sap_restart( */ intf_ch = wlansap_check_cc_intf(hdd_ap_ctx->sap_context); intf_ch_freq = wlan_reg_chan_to_freq(hdd_ctx->pdev, intf_ch); - hdd_info("sap_vdev %d intf_ch: %d", vdev_id, intf_ch); + policy_mgr_get_chan_by_session_id(psoc, vdev_id, &sap_ch_freq); + hdd_info("sap_vdev %d intf_ch: %d, orig freq: %d", + vdev_id, intf_ch, sap_ch_freq); if (QDF_MCC_TO_SCC_SWITCH_FORCE_PREFERRED_WITHOUT_DISCONNECTION != mcc_to_scc_switch) { - policy_mgr_get_chan_by_session_id(psoc, vdev_id, &sap_ch_freq); if (QDF_IS_STATUS_ERROR( policy_mgr_valid_sap_conc_channel_check( hdd_ctx->psoc, &intf_ch_freq, sap_ch_freq, vdev_id))) { hdd_debug("can't move sap to chan(freq): %u", - hdd_sta_ctx->conn_info.chan_freq); + intf_ch_freq); return QDF_STATUS_E_FAILURE; } sap_ch = wlan_freq_to_chan(sap_ch_freq); @@ -3172,24 +3163,28 @@ QDF_STATUS wlan_hdd_get_channel_for_sap_restart( } sap_restart: - if (intf_ch == 0) { + if (!intf_ch_freq) { + intf_ch_freq = wlansap_get_chan_band_restrict(hdd_ap_ctx->sap_context); + if (intf_ch_freq == sap_ch_freq) + intf_ch_freq = 0; + } else if (hdd_ap_ctx->sap_context) + hdd_ap_ctx->sap_context->csa_reason = + CSA_REASON_CONCURRENT_STA_CHANGED_CHANNEL; + if (!intf_ch_freq) { hdd_debug("interface channel is 0"); return QDF_STATUS_E_FAILURE; } - hdd_info("SAP restart orig chan freq: %d, new chan: %d", - hdd_ap_ctx->sap_config.chan_freq, intf_ch); + hdd_info("SAP restart orig chan freq: %d, new freq: %d", + hdd_ap_ctx->sap_config.chan_freq, intf_ch_freq); ch_params.ch_width = CH_WIDTH_MAX; hdd_ap_ctx->bss_stop_reason = BSS_STOP_DUE_TO_MCC_SCC_SWITCH; - if (hdd_ap_ctx->sap_context) - hdd_ap_ctx->sap_context->csa_reason = - CSA_REASON_CONCURRENT_STA_CHANGED_CHANNEL; wlan_reg_set_channel_params_for_freq(hdd_ctx->pdev, intf_ch_freq, 0, &ch_params); - *ch_freq = wlan_chan_to_freq(intf_ch); + *ch_freq = intf_ch_freq; hdd_info("SAP channel change with CSA/ECSA"); hdd_sap_restart_chan_switch_cb(psoc, vdev_id, *ch_freq, ch_params.ch_width, false); diff --git a/core/hdd/src/wlan_hdd_regulatory.c b/core/hdd/src/wlan_hdd_regulatory.c index 7150cf1174291..22d54b0941717 100644 --- a/core/hdd/src/wlan_hdd_regulatory.c +++ b/core/hdd/src/wlan_hdd_regulatory.c @@ -1425,9 +1425,6 @@ static void hdd_regulatory_dyn_cbk(struct wlan_objmgr_psoc *psoc, struct hdd_context *hdd_ctx; enum country_src cc_src; uint8_t alpha2[REG_ALPHA2_LEN + 1]; - struct hdd_adapter *adapter = NULL; - struct hdd_ap_ctx *ap_ctx; - enum band_info current_band; pdev_priv = wlan_pdev_get_ospriv(pdev); wiphy = pdev_priv->wiphy; @@ -1453,26 +1450,14 @@ static void hdd_regulatory_dyn_cbk(struct wlan_objmgr_psoc *psoc, hdd_send_wiphy_regd_sync_event(hdd_ctx); #endif - if (avoid_freq_ind) + if (avoid_freq_ind) { hdd_ch_avoid_ind(hdd_ctx, &avoid_freq_ind->chan_list, &avoid_freq_ind->freq_list); - else + } else { sme_generic_change_country_code(hdd_ctx->mac_handle, hdd_ctx->reg.alpha2); - - if (ucfg_reg_get_curr_band(hdd_ctx->pdev, ¤t_band) != - QDF_STATUS_SUCCESS) { - hdd_err("Failed to get current band config"); - return; - } - hdd_for_each_adapter(hdd_ctx, adapter) { - ap_ctx = &adapter->session.ap; - if ((adapter->device_mode == QDF_SAP_MODE || - adapter->device_mode == QDF_P2P_GO_MODE)) { - wlansap_set_band_csa(ap_ctx->sap_context, - &ap_ctx->sap_config, - current_band); - } + /*Check whether need restart SAP/P2p Go*/ + policy_mgr_check_concurrent_intf_and_restart_sap(hdd_ctx->psoc); } } diff --git a/core/sap/inc/sap_api.h b/core/sap/inc/sap_api.h index 1605502efb669..83bdc7c978852 100644 --- a/core/sap/inc/sap_api.h +++ b/core/sap/inc/sap_api.h @@ -1461,19 +1461,17 @@ uint32_t wlansap_get_safe_channel_from_pcl_and_acs_range(struct sap_context *sap_ctx); /** - * wlansap_set_band_csa() - sap channel switch for band change + * wlansap_get_chan_band_restrict() - get new chan for band change * @sap_ctx: sap context pointer - * @sap_config: sap config pointer * * Sap/p2p go channel switch from 5G to 2G by CSA when 5G band disabled to * avoid conflict with modem N79. - * Sap/p2p go channel restore to 5G when 5G band enabled. + * Sap/p2p go channel restore to 5G channel when 5G band enabled. * - * Return - none + * Return - restart channel in MHZ */ -void wlansap_set_band_csa(struct sap_context *sap_ctx, - struct sap_config *sap_config, - enum band_info band); +qdf_freq_t wlansap_get_chan_band_restrict(struct sap_context *sap_ctx); + #ifdef __cplusplus } #endif diff --git a/core/sap/src/sap_module.c b/core/sap/src/sap_module.c index ae42f4a31a04f..c35a71314f26d 100644 --- a/core/sap/src/sap_module.c +++ b/core/sap/src/sap_module.c @@ -3151,9 +3151,7 @@ err: return freq; } -void wlansap_set_band_csa(struct sap_context *sap_ctx, - struct sap_config *sap_config, - enum band_info band) +qdf_freq_t wlansap_get_chan_band_restrict(struct sap_context *sap_ctx) { uint8_t restart_chan; uint32_t restart_freq; @@ -3164,23 +3162,30 @@ void wlansap_set_band_csa(struct sap_context *sap_ctx, uint8_t cc_mode; uint8_t vdev_id; enum reg_wifi_band sap_band; + enum band_info band; if (cds_is_driver_recovering()) - return; + return 0; + mac = cds_get_context(QDF_MODULE_ID_PE); + if (ucfg_reg_get_curr_band(mac->pdev, &band) != QDF_STATUS_SUCCESS) { + sap_err("Failed to get current band config"); + return 0; + } sap_band = wlan_reg_freq_to_band(sap_ctx->chan_freq); sap_debug("SAP/Go current band: %d, pdev band capability: %d", sap_band, band); if (sap_band == REG_BAND_5G && band == BAND_2G) { - if (sap_ctx->chan_freq_before_switch_band == - sap_ctx->chan_freq) - return; sap_ctx->chan_freq_before_switch_band = sap_ctx->chan_freq; sap_ctx->chan_width_before_switch_band = sap_ctx->ch_params.ch_width; sap_debug("Save chan info before switch: %d, width: %d", sap_ctx->chan_freq, sap_ctx->ch_params.ch_width); restart_freq = wlansap_get_2g_first_safe_chan_freq(sap_ctx); + if (restart_freq == 0) { + sap_debug("use default chan 6"); + restart_freq = TWOG_CHAN_6_IN_MHZ; + } restart_ch_width = sap_ctx->ch_params.ch_width; if (restart_ch_width > CH_WIDTH_40MHZ) { sap_debug("set 40M when switch SAP to 2G"); @@ -3189,20 +3194,16 @@ void wlansap_set_band_csa(struct sap_context *sap_ctx, } else if (sap_band == REG_BAND_2G && (band == BAND_ALL || band == BAND_5G)) { if (sap_ctx->chan_freq_before_switch_band == 0) - return; + return 0; restart_freq = sap_ctx->chan_freq_before_switch_band; restart_ch_width = sap_ctx->chan_width_before_switch_band; sap_debug("Restore chan freq: %d, width: %d", restart_freq, restart_ch_width); - sap_ctx->chan_freq_before_switch_band = 0; - sap_ctx->chan_width_before_switch_band = CH_WIDTH_INVALID; - } else { sap_debug("No need switch SAP/Go channel"); - return; + return 0; } - mac = cds_get_context(QDF_MODULE_ID_PE); restart_chan = wlan_reg_freq_to_chan(mac->pdev, restart_freq); cc_mode = sap_ctx->cc_switch_mode; phy_mode = sap_ctx->csr_roamProfile.phyMode; @@ -3212,12 +3213,11 @@ void wlansap_set_band_csa(struct sap_context *sap_ctx, cc_mode); if (intf_ch) restart_chan = intf_ch; - sap_ctx->csa_reason = CSA_REASON_BAND_RESTRICTED; vdev_id = sap_ctx->vdev->vdev_objmgr.vdev_id; - restart_freq = wlan_chan_to_freq(restart_chan); - sap_debug("vdev: %d, CSA target channel: %d, width: %d", - vdev_id, restart_freq, restart_ch_width); - policy_mgr_change_sap_channel_with_csa(mac->psoc, vdev_id, - restart_freq, - restart_ch_width, true); + restart_freq = wlan_reg_chan_to_freq(mac->pdev, restart_chan); + sap_debug("vdev: %d, CSA target freq: %d", vdev_id, restart_freq); + sap_ctx->csa_reason = CSA_REASON_BAND_RESTRICTED; + + return restart_freq; } +