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 a73f55e29e7e..b5960eeb578a 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 @@ -2012,7 +2012,8 @@ QDF_STATUS policy_mgr_get_nss_for_vdev(struct wlan_objmgr_psoc *psoc, /** * policy_mgr_get_sap_mandatory_channel() - Get the mandatory channel for SAP * @psoc: PSOC object information - * @ch_freq: Pointer to the SAP mandatory channel frequency + * @sap_ch_freq: sap current frequency in MHz + * @intf_ch_freq: input/out interference channel frequency to sap * * Gets the mandatory channel for SAP operation * @@ -2020,7 +2021,8 @@ QDF_STATUS policy_mgr_get_nss_for_vdev(struct wlan_objmgr_psoc *psoc, */ QDF_STATUS policy_mgr_get_sap_mandatory_channel(struct wlan_objmgr_psoc *psoc, - uint32_t *ch_freq); + uint32_t sap_ch_freq, + uint32_t *intf_ch_freq); /** * policy_mgr_set_sap_mandatory_channels() - Set the mandatory channel for SAP @@ -3144,15 +3146,17 @@ uint32_t policy_mgr_get_sap_mandatory_chan_list_len( struct wlan_objmgr_psoc *psoc); /** - * policy_mgr_init_sap_mandatory_2g_chan() - Init 2.4G SAP mandatory channel + * policy_mgr_init_sap_mandatory_chan() - Init 2.4G 5G 6G SAP mandatory channel * list * @psoc: Pointer to soc + * @org_ch_freq: sap initial channel frequency MHz * - * Initialize the 2.4G SAP mandatory channels + * Initialize the 2.4G 5G 6G SAP mandatory channels * * Return: None */ -void policy_mgr_init_sap_mandatory_2g_chan(struct wlan_objmgr_psoc *psoc); +void policy_mgr_init_sap_mandatory_chan(struct wlan_objmgr_psoc *psoc, + uint32_t org_ch_freq); /** * policy_mgr_remove_sap_mandatory_chan() - Remove channel from SAP mandatory diff --git a/components/cmn_services/policy_mgr/src/wlan_policy_mgr_core.c b/components/cmn_services/policy_mgr/src/wlan_policy_mgr_core.c index 450045d100a7..cd242f4b9ab6 100644 --- a/components/cmn_services/policy_mgr/src/wlan_policy_mgr_core.c +++ b/components/cmn_services/policy_mgr/src/wlan_policy_mgr_core.c @@ -3466,7 +3466,10 @@ void policy_mgr_add_sap_mandatory_chan(struct wlan_objmgr_psoc *psoc, if (ch_freq == pm_ctx->sap_mandatory_channels[i]) return; } - + if (pm_ctx->sap_mandatory_channels_len >= NUM_CHANNELS) { + policy_mgr_err("mand list overflow (%hu)", ch_freq); + return; + } policy_mgr_debug("Ch freq: %hu", ch_freq); pm_ctx->sap_mandatory_channels[pm_ctx->sap_mandatory_channels_len++] = ch_freq; @@ -3486,7 +3489,79 @@ uint32_t policy_mgr_get_sap_mandatory_chan_list_len( return pm_ctx->sap_mandatory_channels_len; } -void policy_mgr_init_sap_mandatory_2g_chan(struct wlan_objmgr_psoc *psoc) +#if defined(CONFIG_BAND_6GHZ) +/** + * policy_mgr_add_sap_mandatory_6ghz_chan() - Add 6GHz SAP mandatory channel + * list + * @psoc: Pointer to soc + * + * Add the 6GHz PSC VLP channel to SAP mandatory channel list. + * + * Return: None + */ +static +void policy_mgr_add_sap_mandatory_6ghz_chan(struct wlan_objmgr_psoc *psoc) +{ + uint32_t ch_freq_list[NUM_CHANNELS] = {0}; + uint32_t len = 0; + int i; + QDF_STATUS status; + struct policy_mgr_psoc_priv_obj *pm_ctx; + bool is_psd; + uint16_t tx_power; + uint16_t eirp_psd_power; + + pm_ctx = policy_mgr_get_context(psoc); + if (!pm_ctx) { + policy_mgr_err("Invalid Context"); + return; + } + + status = policy_mgr_get_valid_chans(psoc, ch_freq_list, &len); + if (QDF_IS_STATUS_ERROR(status)) { + policy_mgr_err("Error in getting valid channels"); + return; + } + + for (i = 0; (i < len) && (i < NUM_CHANNELS) && + (pm_ctx->sap_mandatory_channels_len < NUM_CHANNELS); i++) { + if (!WLAN_REG_IS_6GHZ_CHAN_FREQ(ch_freq_list[i])) + continue; + if (WLAN_REG_IS_6GHZ_PSC_CHAN_FREQ(ch_freq_list[i])) { + status = wlan_reg_get_6g_chan_ap_power( + pm_ctx->pdev, ch_freq_list[i], &is_psd, + &tx_power, &eirp_psd_power); + if (status != QDF_STATUS_SUCCESS || !tx_power) + continue; + + policy_mgr_debug("Add chan %hu to mandatory list", + ch_freq_list[i]); + pm_ctx->sap_mandatory_channels[ + pm_ctx->sap_mandatory_channels_len++] = + ch_freq_list[i]; + } + } +} +#else +static inline +void policy_mgr_add_sap_mandatory_6ghz_chan(struct wlan_objmgr_psoc *psoc) +{ +} +#endif + +/** + * policy_mgr_init_sap_mandatory_chan_by_band() - Init SAP mandatory channel + * list based on band + * @psoc: Pointer to soc + * @band_bitmap: band bitmap of type reg_wifi_band + * + * Initialize the 2.4G 5G 6G SAP mandatory channels based on band + * + * Return: None + */ +static void +policy_mgr_init_sap_mandatory_chan_by_band(struct wlan_objmgr_psoc *psoc, + uint32_t band_bitmap) { uint32_t ch_freq_list[NUM_CHANNELS] = {0}; uint32_t len = 0; @@ -3506,7 +3581,6 @@ void policy_mgr_init_sap_mandatory_2g_chan(struct wlan_objmgr_psoc *psoc) return; } pm_ctx->sap_mandatory_channels_len = 0; - for (i = 0; (i < len) && (i < NUM_CHANNELS); i++) { if (WLAN_REG_IS_24GHZ_CH_FREQ(ch_freq_list[i])) { policy_mgr_debug("Add chan %hu to mandatory list", @@ -3516,6 +3590,33 @@ void policy_mgr_init_sap_mandatory_2g_chan(struct wlan_objmgr_psoc *psoc) ch_freq_list[i]; } } + if (band_bitmap & BIT(REG_BAND_5G)) + policy_mgr_add_sap_mandatory_chan(psoc, + SAP_MANDATORY_5G_CH_FREQ); + if (band_bitmap & BIT(REG_BAND_6G)) + policy_mgr_add_sap_mandatory_6ghz_chan(psoc); +} + +void policy_mgr_init_sap_mandatory_chan(struct wlan_objmgr_psoc *psoc, + uint32_t org_ch_freq) +{ + if (WLAN_REG_IS_5GHZ_CH_FREQ(org_ch_freq)) { + policy_mgr_debug("channel %hu, sap mandatory chan list enabled", + org_ch_freq); + if (!policy_mgr_get_sap_mandatory_chan_list_len(psoc)) + policy_mgr_init_sap_mandatory_chan_by_band( + psoc, BIT(REG_BAND_2G)); + policy_mgr_add_sap_mandatory_chan( + psoc, org_ch_freq); + } else if (WLAN_REG_IS_6GHZ_CHAN_FREQ(org_ch_freq)) { + policy_mgr_init_sap_mandatory_chan_by_band( + psoc, + BIT(REG_BAND_2G) | BIT(REG_BAND_5G) | + BIT(REG_BAND_6G)); + } else { + policy_mgr_init_sap_mandatory_chan_by_band( + psoc, BIT(REG_BAND_2G)); + } } void policy_mgr_remove_sap_mandatory_chan(struct wlan_objmgr_psoc *psoc, diff --git a/components/cmn_services/policy_mgr/src/wlan_policy_mgr_i.h b/components/cmn_services/policy_mgr/src/wlan_policy_mgr_i.h index 9f4f47262372..068dbc7a8fb6 100644 --- a/components/cmn_services/policy_mgr/src/wlan_policy_mgr_i.h +++ b/components/cmn_services/policy_mgr/src/wlan_policy_mgr_i.h @@ -31,6 +31,8 @@ #define POLICY_MGR_SER_CMD_TIMEOUT 4000 +#define SAP_MANDATORY_5G_CH_FREQ 5745 + #ifdef QCA_WIFI_3_0_EMU #define CONNECTION_UPDATE_TIMEOUT (POLICY_MGR_SER_CMD_TIMEOUT + 3000) #else diff --git a/components/cmn_services/policy_mgr/src/wlan_policy_mgr_pcl.c b/components/cmn_services/policy_mgr/src/wlan_policy_mgr_pcl.c index b5458028a565..f1dca23919d7 100644 --- a/components/cmn_services/policy_mgr/src/wlan_policy_mgr_pcl.c +++ b/components/cmn_services/policy_mgr/src/wlan_policy_mgr_pcl.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2020 The Linux Foundation. All rights reserved. + * Copyright (c) 2012-2021 The Linux Foundation. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -2367,11 +2367,15 @@ QDF_STATUS policy_mgr_modify_sap_pcl_based_on_mandatory_channel( return QDF_STATUS_SUCCESS; } -QDF_STATUS policy_mgr_get_sap_mandatory_channel(struct wlan_objmgr_psoc *psoc, - uint32_t *ch_freq) +QDF_STATUS +policy_mgr_get_sap_mandatory_channel(struct wlan_objmgr_psoc *psoc, + uint32_t sap_ch_freq, + uint32_t *intf_ch_freq) { QDF_STATUS status; struct policy_mgr_pcl_list pcl; + uint32_t i; + uint32_t sap_new_freq; qdf_mem_zero(&pcl, sizeof(pcl)); @@ -2417,8 +2421,19 @@ QDF_STATUS policy_mgr_get_sap_mandatory_channel(struct wlan_objmgr_psoc *psoc, return QDF_STATUS_E_FAILURE; } - *ch_freq = pcl.pcl_list[0]; - policy_mgr_debug("mandatory channel:%d", *ch_freq); + sap_new_freq = pcl.pcl_list[0]; + if (WLAN_REG_IS_6GHZ_CHAN_FREQ(sap_ch_freq)) { + for (i = 0; i < pcl.pcl_len; i++) { + if (pcl.pcl_list[i] == *intf_ch_freq) { + sap_new_freq = pcl.pcl_list[i]; + break; + } + } + } + + *intf_ch_freq = sap_new_freq; + policy_mgr_debug("mandatory channel:%d org sap ch %d", *intf_ch_freq, + sap_ch_freq); return QDF_STATUS_SUCCESS; } diff --git a/core/hdd/src/wlan_hdd_hostapd.c b/core/hdd/src/wlan_hdd_hostapd.c index dce087e71630..f8254fd10da2 100644 --- a/core/hdd/src/wlan_hdd_hostapd.c +++ b/core/hdd/src/wlan_hdd_hostapd.c @@ -6506,22 +6506,9 @@ static int __wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy, if (QDF_STATUS_SUCCESS != ucfg_policy_mgr_get_sap_mandt_chnl(hdd_ctx->psoc, &mandt_chnl_list)) hdd_err("can't get mandatory channel list"); - if (mandt_chnl_list) { - if (WLAN_REG_IS_5GHZ_CH(channel)) { - hdd_debug("channel %hu, sap mandatory chan list enabled", - channel); - if (!policy_mgr_get_sap_mandatory_chan_list_len( - hdd_ctx->psoc)) - policy_mgr_init_sap_mandatory_2g_chan( - hdd_ctx->psoc); - - policy_mgr_add_sap_mandatory_chan( - hdd_ctx->psoc, wlan_chan_to_freq(channel)); - } else { - policy_mgr_init_sap_mandatory_2g_chan( - hdd_ctx->psoc); - } - } + if (mandt_chnl_list) + policy_mgr_init_sap_mandatory_chan(hdd_ctx->psoc, + chandef->chan->center_freq); adapter->session.ap.sap_config.ch_params.center_freq_seg0 = cds_freq_to_chan(chandef->center_freq1); diff --git a/core/sme/src/csr/csr_util.c b/core/sme/src/csr/csr_util.c index aebc6e85aebf..0092710309d3 100644 --- a/core/sme/src/csr/csr_util.c +++ b/core/sme/src/csr/csr_util.c @@ -1109,17 +1109,20 @@ uint16_t csr_check_concurrent_channel_overlap(struct mac_context *mac_ctx, } else if (cc_switch_mode == QDF_MCC_TO_SCC_SWITCH_WITH_FAVORITE_CHANNEL) { status = policy_mgr_get_sap_mandatory_channel( - mac_ctx->psoc, + mac_ctx->psoc, sap_ch_freq, &intf_ch_freq); if (QDF_IS_STATUS_ERROR(status)) - sme_err("no mandatory channel"); + sme_err("no mandatory channels (%d, %d)", + sap_ch_freq, intf_ch_freq); } } 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)) { + if (WLAN_REG_IS_24GHZ_CH_FREQ(intf_ch_freq) || + WLAN_REG_IS_6GHZ_CHAN_FREQ(sap_ch_freq)) { status = policy_mgr_get_sap_mandatory_channel( - mac_ctx->psoc, &intf_ch_freq); + mac_ctx->psoc, sap_ch_freq, + &intf_ch_freq); if (QDF_IS_STATUS_ERROR(status)) sme_err("no mandatory channel"); } @@ -1128,7 +1131,8 @@ uint16_t csr_check_concurrent_channel_overlap(struct mac_context *mac_ctx, if (intf_ch_freq == sap_ch_freq) intf_ch_freq = 0; - sme_debug("##Concurrent Channels %s Interfering", + sme_debug("##Concurrent Channels (%d, %d) %s Interfering", sap_ch_freq, + intf_ch_freq, intf_ch_freq == 0 ? "Not" : "Are"); return intf_ch_freq;