From eb083f33468f0bdac426b8502dc93f319e83338b Mon Sep 17 00:00:00 2001 From: Lincoln Tran Date: Wed, 24 Jun 2020 13:40:00 -0700 Subject: [PATCH] qcacld-3.0: Add logic to check if channel is disabled Currently, when the country code changes, there is no logic to restart the SAP on a new channel. Add a case to check if the channel is not allowed, then calculate a new safe channel and update the SAP restart reason. Change-Id: I679ce6f72228b431530953a631c8c8afa4597187 CRs-fixed: 2718324 --- .../policy_mgr/inc/wlan_policy_mgr_api.h | 2 ++ core/hdd/src/wlan_hdd_hostapd.c | 7 +++---- core/sap/inc/sap_api.h | 6 +++++- core/sap/src/sap_module.c | 16 +++++++++++++++- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/components/cmn_services/policy_mgr/inc/wlan_policy_mgr_api.h b/components/cmn_services/policy_mgr/inc/wlan_policy_mgr_api.h index fd9e78d26bdc..5e53e0911e5f 100644 --- a/components/cmn_services/policy_mgr/inc/wlan_policy_mgr_api.h +++ b/components/cmn_services/policy_mgr/inc/wlan_policy_mgr_api.h @@ -75,6 +75,7 @@ typedef const enum policy_mgr_conc_next_action * @CSA_REASON_CONCURRENT_NAN_EVENT: NAN concurrency. * @CSA_REASON_BAND_RESTRICTED: band disabled or re-enabled * @CSA_REASON_DCS: DCS + * @CSA_REASON_CHAN_DISABLED: channel is disabled * */ enum sap_csa_reason_code { @@ -89,6 +90,7 @@ enum sap_csa_reason_code { CSA_REASON_CONCURRENT_NAN_EVENT, CSA_REASON_BAND_RESTRICTED, CSA_REASON_DCS, + CSA_REASON_CHAN_DISABLED, }; /** diff --git a/core/hdd/src/wlan_hdd_hostapd.c b/core/hdd/src/wlan_hdd_hostapd.c index 9398935adaea..548e1b8a2da8 100644 --- a/core/hdd/src/wlan_hdd_hostapd.c +++ b/core/hdd/src/wlan_hdd_hostapd.c @@ -3229,11 +3229,10 @@ QDF_STATUS wlan_hdd_get_channel_for_sap_restart( return QDF_STATUS_E_FAILURE; } - intf_ch_freq = wlansap_get_chan_band_restrict(sap_context); - if (intf_ch_freq) { - csa_reason = CSA_REASON_BAND_RESTRICTED; + intf_ch_freq = wlansap_get_chan_band_restrict(sap_context, &csa_reason); + if (intf_ch_freq) goto sap_restart; - } + /* * If STA+SAP sessions are on DFS channel and STA+SAP SCC is * enabled on DFS channel then move the SAP out of DFS channel diff --git a/core/sap/inc/sap_api.h b/core/sap/inc/sap_api.h index 403835abd046..4679bf3e17a6 100644 --- a/core/sap/inc/sap_api.h +++ b/core/sap/inc/sap_api.h @@ -1477,14 +1477,18 @@ wlansap_get_safe_channel_from_pcl_and_acs_range(struct sap_context *sap_ctx); /** * wlansap_get_chan_band_restrict() - get new chan for band change * @sap_ctx: sap context pointer + * @csa_reason: channel switch reason to update * * 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 channel when 5G band enabled. + * Note: csa_reason is only updated when channel is disabled or band is + * restricted, so it must be initialized to a default value beforehand * * Return - restart channel in MHZ */ -qdf_freq_t wlansap_get_chan_band_restrict(struct sap_context *sap_ctx); +qdf_freq_t wlansap_get_chan_band_restrict(struct sap_context *sap_ctx, + enum sap_csa_reason_code *csa_reason); #ifdef DCS_INTERFERENCE_DETECTION /** diff --git a/core/sap/src/sap_module.c b/core/sap/src/sap_module.c index cac263222dcc..02cc3596ec16 100644 --- a/core/sap/src/sap_module.c +++ b/core/sap/src/sap_module.c @@ -2979,7 +2979,8 @@ err: return freq; } -qdf_freq_t wlansap_get_chan_band_restrict(struct sap_context *sap_ctx) +qdf_freq_t wlansap_get_chan_band_restrict(struct sap_context *sap_ctx, + enum sap_csa_reason_code *csa_reason) { uint32_t restart_freq; enum phy_ch_width restart_ch_width; @@ -2995,6 +2996,12 @@ qdf_freq_t wlansap_get_chan_band_restrict(struct sap_context *sap_ctx) sap_err("sap_ctx NULL parameter"); return 0; } + + if (!csa_reason) { + sap_err("csa_reason is NULL"); + return 0; + } + if (cds_is_driver_recovering()) return 0; @@ -3004,6 +3011,12 @@ qdf_freq_t wlansap_get_chan_band_restrict(struct sap_context *sap_ctx) return 0; } + if (wlan_reg_is_disable_for_freq(mac->pdev, sap_ctx->chan_freq)) { + sap_debug("channel is disabled"); + *csa_reason = CSA_REASON_CHAN_DISABLED; + return wlansap_get_safe_channel_from_pcl_and_acs_range(sap_ctx); + } + if (ucfg_reg_get_band(mac->pdev, &band) != QDF_STATUS_SUCCESS) { sap_err("Failed to get current band config"); return 0; @@ -3034,6 +3047,7 @@ qdf_freq_t wlansap_get_chan_band_restrict(struct sap_context *sap_ctx) restart_ch_width = sap_ctx->chan_width_before_switch_band; sap_debug("Restore chan freq: %d, width: %d", restart_freq, restart_ch_width); + *csa_reason = CSA_REASON_BAND_RESTRICTED; } else { sap_debug("No need switch SAP/Go channel"); return 0;