diff --git a/components/mlme/dispatcher/inc/wlan_mlme_api.h b/components/mlme/dispatcher/inc/wlan_mlme_api.h index 71a9d05994..eb0b7ab453 100644 --- a/components/mlme/dispatcher/inc/wlan_mlme_api.h +++ b/components/mlme/dispatcher/inc/wlan_mlme_api.h @@ -1,6 +1,6 @@ /* * Copyright (c) 2018-2021 The Linux Foundation. All rights reserved. - * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved. + * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. 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 @@ -3661,6 +3661,23 @@ QDF_STATUS mlme_clear_mcs_rate(struct wlan_objmgr_vdev *vdev); */ bool wlan_mlme_is_sta_mon_conc_supported(struct wlan_objmgr_psoc *psoc); +/** + * wlan_mlme_get_phy_max_freq_range() - Get phy supported max channel + * frequency range + * @psoc: psoc for country information + * @low_2ghz_chan: 2.4 GHz low channel frequency + * @high_2ghz_chan: 2.4 GHz high channel frequency + * @low_5ghz_chan: 5 GHz low channel frequency + * @high_5ghz_chan: 5 GHz high channel frequency + * + * Return: QDF status + */ +QDF_STATUS wlan_mlme_get_phy_max_freq_range(struct wlan_objmgr_psoc *psoc, + uint32_t *low_2ghz_chan, + uint32_t *high_2ghz_chan, + uint32_t *low_5ghz_chan, + uint32_t *high_5ghz_chan); + #ifdef FEATURE_WDS /** * wlan_mlme_get_wds_mode() - Check wds mode supported diff --git a/components/mlme/dispatcher/inc/wlan_mlme_ucfg_api.h b/components/mlme/dispatcher/inc/wlan_mlme_ucfg_api.h index e19e5ae2e3..ed19071a66 100644 --- a/components/mlme/dispatcher/inc/wlan_mlme_ucfg_api.h +++ b/components/mlme/dispatcher/inc/wlan_mlme_ucfg_api.h @@ -138,6 +138,31 @@ uint8_t ucfg_get_tx_power(struct wlan_objmgr_psoc *psoc, uint8_t band) return wlan_mlme_get_tx_power(psoc, band); } +/** + * ucfg_mlme_get_phy_max_freq_range() - Get phy supported max channel + * frequency range + * @psoc: psoc for country information + * @low_2ghz_chan: 2.4 GHz low channel frequency + * @high_2ghz_chan: 2.4 GHz high channel frequency + * @low_5ghz_chan: 5 GHz low channel frequency + * @high_5ghz_chan: 5 GHz high channel frequency + * + * Return: QDF status + */ +static inline +QDF_STATUS ucfg_mlme_get_phy_max_freq_range(struct wlan_objmgr_psoc *psoc, + uint32_t *low_2ghz_chan, + uint32_t *high_2ghz_chan, + uint32_t *low_5ghz_chan, + uint32_t *high_5ghz_chan) +{ + return wlan_mlme_get_phy_max_freq_range(psoc, + low_2ghz_chan, + high_2ghz_chan, + low_5ghz_chan, + high_5ghz_chan); +} + /** * ucfg_mlme_get_ht_cap_info() - Get the HT cap info config * @psoc: pointer to psoc object diff --git a/components/mlme/dispatcher/src/wlan_mlme_api.c b/components/mlme/dispatcher/src/wlan_mlme_api.c index 6299bf6948..34ca955997 100644 --- a/components/mlme/dispatcher/src/wlan_mlme_api.c +++ b/components/mlme/dispatcher/src/wlan_mlme_api.c @@ -1,6 +1,6 @@ /* * Copyright (c) 2018-2021 The Linux Foundation. All rights reserved. - * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved. + * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. 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 @@ -34,6 +34,7 @@ #include <../../core/src/wlan_cm_vdev_api.h> #include "wlan_psoc_mlme_api.h" #include "wlan_action_oui_main.h" +#include "target_if.h" /* quota in milliseconds */ #define MCC_DUTY_CYCLE 70 @@ -5948,6 +5949,86 @@ bool mlme_get_user_ps(struct wlan_objmgr_psoc *psoc, uint8_t vdev_id) return usr_ps_enable; } +QDF_STATUS wlan_mlme_get_phy_max_freq_range(struct wlan_objmgr_psoc *psoc, + uint32_t *low_2ghz_chan, + uint32_t *high_2ghz_chan, + uint32_t *low_5ghz_chan, + uint32_t *high_5ghz_chan) +{ + uint32_t i; + uint32_t reg_low_2ghz_chan; + uint32_t reg_high_2ghz_chan; + uint32_t reg_low_5ghz_chan; + uint32_t reg_high_5ghz_chan; + struct target_psoc_info *info; + struct wlan_psoc_host_mac_phy_caps *mac_phy_cap; + struct wlan_psoc_host_hal_reg_cap_ext *reg_cap_ext; + + info = wlan_psoc_get_tgt_if_handle(psoc); + if (!info) { + mlme_legacy_err("target_psoc_info is null"); + return QDF_STATUS_E_FAILURE; + } + mac_phy_cap = info->info.mac_phy_cap; + reg_cap_ext = &mac_phy_cap->reg_cap_ext; + reg_low_2ghz_chan = reg_cap_ext->low_2ghz_chan; + reg_high_2ghz_chan = reg_cap_ext->high_2ghz_chan; + reg_low_5ghz_chan = reg_cap_ext->low_5ghz_chan; + reg_high_5ghz_chan = reg_cap_ext->high_5ghz_chan; + for (i = 1; i < PSOC_MAX_MAC_PHY_CAP; i++) { + mac_phy_cap = &info->info.mac_phy_cap[i]; + reg_cap_ext = &mac_phy_cap->reg_cap_ext; + + if (reg_cap_ext->low_2ghz_chan) { + reg_low_2ghz_chan = reg_low_2ghz_chan ? + QDF_MIN(reg_cap_ext->low_2ghz_chan, + reg_low_2ghz_chan) : + reg_cap_ext->low_2ghz_chan; + } + if (reg_cap_ext->high_2ghz_chan) { + reg_high_2ghz_chan = reg_high_2ghz_chan ? + QDF_MAX(reg_cap_ext->high_2ghz_chan, + reg_high_2ghz_chan) : + reg_cap_ext->high_2ghz_chan; + } + if (reg_cap_ext->low_5ghz_chan) { + reg_low_5ghz_chan = reg_low_5ghz_chan ? + QDF_MIN(reg_cap_ext->low_5ghz_chan, + reg_low_5ghz_chan) : + reg_cap_ext->low_5ghz_chan; + } + if (reg_cap_ext->high_5ghz_chan) { + reg_high_5ghz_chan = reg_high_5ghz_chan ? + QDF_MAX(reg_cap_ext->high_5ghz_chan, + reg_high_5ghz_chan) : + reg_cap_ext->high_5ghz_chan; + } + } + /* For old hw, no reg_cap_ext reported from service ready ext, + * fill the low/high with default of regulatory. + */ + if (!reg_low_2ghz_chan && !reg_high_2ghz_chan && + !reg_low_5ghz_chan && !reg_high_5ghz_chan) { + mlme_legacy_debug("no reg_cap_ext in mac_phy_cap"); + reg_low_2ghz_chan = TWOG_STARTING_FREQ - 10; + reg_high_2ghz_chan = TWOG_CHAN_14_IN_MHZ + 10; + reg_low_5ghz_chan = FIVEG_STARTING_FREQ - 10; + reg_high_5ghz_chan = SIXG_CHAN_233_IN_MHZ + 10; + } + if (!wlan_reg_is_6ghz_supported(psoc)) { + mlme_legacy_debug("disabling 6ghz channels"); + reg_high_5ghz_chan = FIVEG_CHAN_177_IN_MHZ + 10; + } + mlme_legacy_debug("%d %d %d %d", reg_low_2ghz_chan, reg_high_2ghz_chan, + reg_low_5ghz_chan, reg_high_5ghz_chan); + *low_2ghz_chan = reg_low_2ghz_chan; + *high_2ghz_chan = reg_high_2ghz_chan; + *low_5ghz_chan = reg_low_5ghz_chan; + *high_5ghz_chan = reg_high_5ghz_chan; + + return QDF_STATUS_SUCCESS; +} + #ifdef WLAN_FEATURE_P2P_P2P_STA bool wlan_mlme_get_p2p_p2p_conc_support(struct wlan_objmgr_psoc *psoc) diff --git a/core/hdd/src/wlan_hdd_object_manager.c b/core/hdd/src/wlan_hdd_object_manager.c index d42b4e38f0..55a8b75f89 100644 --- a/core/hdd/src/wlan_hdd_object_manager.c +++ b/core/hdd/src/wlan_hdd_object_manager.c @@ -1,6 +1,6 @@ /* * Copyright (c) 2017-2021 The Linux Foundation. All rights reserved. - * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. + * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. 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 @@ -28,18 +28,6 @@ #include #include -#define LOW_2GHZ_FREQ 2312 -#define HIGH_2GHZ_FREQ 2732 -#define LOW_5GHZ_FREQ 4912 - -#ifdef CONFIG_BAND_6GHZ -#define HIGH_5GHZ_FREQ 7200 -#else -#define HIGH_5GHZ_FREQ 5920 -#endif - -#define HIGH_5GHZ_FREQ_NO_6GHZ 5920 - static void hdd_init_pdev_os_priv(struct hdd_context *hdd_ctx, struct pdev_osif_priv *os_priv) { @@ -153,6 +141,10 @@ int hdd_objmgr_create_and_store_pdev(struct hdd_context *hdd_ctx) struct wlan_objmgr_pdev *pdev; struct pdev_osif_priv *priv; struct wlan_psoc_host_hal_reg_capabilities_ext *reg_cap_ptr; + uint32_t low_2ghz_chan = 0; + uint32_t high_2ghz_chan = 0; + uint32_t low_5ghz_chan = 0; + uint32_t high_5ghz_chan = 0; if (!psoc) { hdd_err("Psoc NULL"); @@ -169,17 +161,17 @@ int hdd_objmgr_create_and_store_pdev(struct hdd_context *hdd_ctx) status = QDF_STATUS_E_INVAL; goto free_priv; } + ucfg_mlme_get_phy_max_freq_range(psoc, &low_2ghz_chan, + &high_2ghz_chan, &low_5ghz_chan, + &high_5ghz_chan); reg_cap_ptr->phy_id = 0; - reg_cap_ptr->low_2ghz_chan = LOW_2GHZ_FREQ; - reg_cap_ptr->high_2ghz_chan = HIGH_2GHZ_FREQ; - reg_cap_ptr->low_5ghz_chan = LOW_5GHZ_FREQ; - reg_cap_ptr->high_5ghz_chan = HIGH_5GHZ_FREQ; - - if (!wlan_reg_is_6ghz_supported(psoc)) { - hdd_debug("disabling 6ghz channels"); - reg_cap_ptr->high_5ghz_chan = HIGH_5GHZ_FREQ_NO_6GHZ; - } - + reg_cap_ptr->low_2ghz_chan = low_2ghz_chan; + reg_cap_ptr->high_2ghz_chan = high_2ghz_chan; + reg_cap_ptr->low_5ghz_chan = low_5ghz_chan; + reg_cap_ptr->high_5ghz_chan = high_5ghz_chan; + hdd_debug("pdev freq range %d %d %d %d", reg_cap_ptr->low_2ghz_chan, + reg_cap_ptr->high_2ghz_chan, reg_cap_ptr->low_5ghz_chan, + reg_cap_ptr->high_5ghz_chan); priv->osif_check_netdev_state = hdd_check_internal_netdev_state; pdev = wlan_objmgr_pdev_obj_create(psoc, priv); if (!pdev) {