diff --git a/umac/regulatory/core/src/reg_utils.c b/umac/regulatory/core/src/reg_utils.c index 479bfaec20f4..10dd2cb43c10 100644 --- a/umac/regulatory/core/src/reg_utils.c +++ b/umac/regulatory/core/src/reg_utils.c @@ -1,6 +1,6 @@ /* * Copyright (c) 2014-2020 The Linux Foundation. All rights reserved. - * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved. + * Copyright (c) 2021-2024 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 @@ -376,12 +376,10 @@ QDF_STATUS reg_get_domain_from_country_code(v_REGDOMAIN_t *reg_domain_ptr, #ifdef CONFIG_REG_CLIENT #ifdef CONFIG_BAND_6GHZ QDF_STATUS -reg_get_6g_power_type_for_ctry(struct wlan_objmgr_psoc *psoc, - struct wlan_objmgr_pdev *pdev, - uint8_t *ap_ctry, uint8_t *sta_ctry, - enum reg_6g_ap_type *pwr_type_6g, - bool *ctry_code_match, - enum reg_6g_ap_type ap_pwr_type) +reg_get_best_6g_power_type(struct wlan_objmgr_psoc *psoc, + struct wlan_objmgr_pdev *pdev, + enum reg_6g_ap_type *pwr_type_6g, + enum reg_6g_ap_type ap_pwr_type) { struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj; @@ -392,63 +390,42 @@ reg_get_6g_power_type_for_ctry(struct wlan_objmgr_psoc *psoc, return QDF_STATUS_E_FAILURE; } - reg_debug("STA country: %c%c, AP country: %c%c, AP power type: %d", - sta_ctry[0], sta_ctry[1], ap_ctry[0], ap_ctry[1], - ap_pwr_type); - - if (!qdf_mem_cmp(ap_ctry, sta_ctry, REG_ALPHA2_LEN)) { - *ctry_code_match = true; - if (ap_pwr_type == REG_VERY_LOW_POWER_AP) { - if (!pdev_priv_obj->reg_rules.num_of_6g_client_reg_rules[ap_pwr_type]) { - reg_err("VLP not supported, can't connect"); - return QDF_STATUS_E_NOSUPPORT; - } - } + if (pdev_priv_obj->reg_rules.num_of_6g_client_reg_rules[ap_pwr_type]) { + reg_debug("AP power type: %d , is supported by client", + ap_pwr_type); return QDF_STATUS_SUCCESS; } - *ctry_code_match = false; - /* - * If reg_info=0 not included, STA should operate in VLP mode. - * If STA country doesn't support VLP, do not return if Wi-Fi - * safe mode or RF test mode or enable relaxed connection policy, - * rather STA should operate in LPI mode. - * wlan_cm_get_check_6ghz_security API returns true if - * neither Safe mode nor RF test mode are enabled. - */ - if (ap_pwr_type != REG_INDOOR_AP) { - if (wlan_reg_ctry_support_vlp(sta_ctry)) + if (ap_pwr_type == REG_INDOOR_AP) { + if (pdev_priv_obj->reg_rules.num_of_6g_client_reg_rules[REG_VERY_LOW_POWER_AP]) { *pwr_type_6g = REG_VERY_LOW_POWER_AP; - if (!wlan_reg_ctry_support_vlp(sta_ctry) && - wlan_cm_get_check_6ghz_security(psoc)) { - reg_err("VLP not supported, can't connect"); - return QDF_STATUS_E_NOSUPPORT; + reg_debug("AP power type = %d, selected power type = %d", + ap_pwr_type, *pwr_type_6g); + return QDF_STATUS_SUCCESS; + } else { + goto no_support; + } + } else if (ap_pwr_type == REG_STANDARD_POWER_AP) { + if (pdev_priv_obj->reg_rules.num_of_6g_client_reg_rules[REG_VERY_LOW_POWER_AP]) { + *pwr_type_6g = REG_VERY_LOW_POWER_AP; + reg_debug("AP power type = %d, selected power type = %d", + ap_pwr_type, *pwr_type_6g); + return QDF_STATUS_SUCCESS; + } else { + goto no_support; } } - if (wlan_reg_ctry_support_vlp(sta_ctry) && - wlan_reg_ctry_support_vlp(ap_ctry) && - ap_pwr_type == REG_INDOOR_AP) { - reg_debug("STA ctry doesn't match with AP ctry, switch to VLP"); - *pwr_type_6g = REG_VERY_LOW_POWER_AP; - } - - if (!wlan_reg_ctry_support_vlp(ap_ctry) && - ap_pwr_type == REG_INDOOR_AP) { - reg_debug("VLP not supported by AP, allow STA IN LPI"); - *pwr_type_6g = REG_INDOOR_AP; - } - - return QDF_STATUS_SUCCESS; +no_support: + reg_err("AP power type = %d, not supported", ap_pwr_type); + return QDF_STATUS_E_NOSUPPORT; } #else QDF_STATUS -reg_get_6g_power_type_for_ctry(struct wlan_objmgr_psoc *psoc, - struct wlan_objmgr_pdev *pdev, - uint8_t *ap_ctry, uint8_t *sta_ctry, - enum reg_6g_ap_type *pwr_type_6g, - bool *ctry_code_match, - enum reg_6g_ap_type ap_pwr_type) +reg_get_best_6g_power_type(struct wlan_objmgr_psoc *psoc, + struct wlan_objmgr_pdev *pdev, + enum reg_6g_ap_type *pwr_type_6g, + enum reg_6g_ap_type ap_pwr_type) { return QDF_STATUS_SUCCESS; } diff --git a/umac/regulatory/core/src/reg_utils.h b/umac/regulatory/core/src/reg_utils.h index 069a04220aed..4e26b3cfb64f 100644 --- a/umac/regulatory/core/src/reg_utils.h +++ b/umac/regulatory/core/src/reg_utils.h @@ -1,6 +1,6 @@ /* * Copyright (c) 2017-2021 The Linux Foundation. All rights reserved. - * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved. + * Copyright (c) 2021-2024 Qualcomm Innovation Center, Inc. All rights reserved. * * * Permission to use, copy, modify, and/or distribute this software for @@ -299,23 +299,27 @@ QDF_STATUS reg_get_domain_from_country_code(v_REGDOMAIN_t *reg_domain_ptr, #ifdef CONFIG_REG_CLIENT /** - * reg_get_6g_power_type_for_ctry() - Return power type for 6G based on cntry IE + * reg_get_best_6g_power_type() - Return best power type for 6 GHz connection * @psoc: pointer to psoc * @pdev: pointer to pdev - * @ap_ctry: ptr to country string in country IE - * @sta_ctry: ptr to sta programmed country * @pwr_type_6g: ptr to 6G power type - * @ctry_code_match: Check for country IE and sta country code match * @ap_pwr_type: AP's power type as advertised in HE ops IE + * + * This function computes best power type for 6 GHz connection. + * SP power type is selected only if AP advertises SP and client supports SP. + * LPI power type is selected only if AP advertises LPI and client supports LPI. + * VLP power type is selected for the below cases, + * a) AP advertises VLP and client supports VLP. + * b) AP advertises SP but client doesn't support SP but supports VLP. + * c) AP advertises LPI but client doesn't support LPI but supports VLP. + * * Return: QDF_STATUS */ QDF_STATUS -reg_get_6g_power_type_for_ctry(struct wlan_objmgr_psoc *psoc, - struct wlan_objmgr_pdev *pdev, - uint8_t *ap_ctry, uint8_t *sta_ctry, - enum reg_6g_ap_type *pwr_type_6g, - bool *ctry_code_match, - enum reg_6g_ap_type ap_pwr_type); +reg_get_best_6g_power_type(struct wlan_objmgr_psoc *psoc, + struct wlan_objmgr_pdev *pdev, + enum reg_6g_ap_type *pwr_type_6g, + enum reg_6g_ap_type ap_pwr_type); #endif /** diff --git a/umac/regulatory/dispatcher/inc/wlan_reg_services_api.h b/umac/regulatory/dispatcher/inc/wlan_reg_services_api.h index 5019ea4e8afe..2e67a4b432e2 100644 --- a/umac/regulatory/dispatcher/inc/wlan_reg_services_api.h +++ b/umac/regulatory/dispatcher/inc/wlan_reg_services_api.h @@ -1,6 +1,6 @@ /* * Copyright (c) 2017-2021 The Linux Foundation. All rights reserved. - * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved. + * Copyright (c) 2021-2024 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 @@ -541,7 +541,8 @@ QDF_STATUS wlan_reg_read_current_country(struct wlan_objmgr_psoc *psoc, #ifdef CONFIG_REG_CLIENT /** - * wlan_reg_get_6g_power_type_for_ctry() - Return power type for 6G based + * wlan_reg_get_best_6g_power_type() - Return best power type for 6GHz + * connection * on country IE * @psoc: pointer to psoc * @pdev: pointer to pdev @@ -553,12 +554,10 @@ QDF_STATUS wlan_reg_read_current_country(struct wlan_objmgr_psoc *psoc, * Return: QDF_STATUS */ QDF_STATUS -wlan_reg_get_6g_power_type_for_ctry(struct wlan_objmgr_psoc *psoc, - struct wlan_objmgr_pdev *pdev, - uint8_t *ap_ctry, uint8_t *sta_ctry, - enum reg_6g_ap_type *pwr_type_6g, - bool *ctry_code_match, - enum reg_6g_ap_type ap_pwr_type); +wlan_reg_get_best_6g_power_type(struct wlan_objmgr_psoc *psoc, + struct wlan_objmgr_pdev *pdev, + enum reg_6g_ap_type *pwr_type_6g, + enum reg_6g_ap_type ap_pwr_type); #endif #ifdef CONFIG_CHAN_NUM_API diff --git a/umac/regulatory/dispatcher/src/wlan_reg_services_api.c b/umac/regulatory/dispatcher/src/wlan_reg_services_api.c index 95ed22420a5b..326b8cb92cb5 100644 --- a/umac/regulatory/dispatcher/src/wlan_reg_services_api.c +++ b/umac/regulatory/dispatcher/src/wlan_reg_services_api.c @@ -1,6 +1,6 @@ /* * Copyright (c) 2017-2021 The Linux Foundation. All rights reserved. - * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved. + * Copyright (c) 2021-2024 Qualcomm Innovation Center, Inc. All rights reserved. * * * Permission to use, copy, modify, and/or distribute this software for @@ -87,16 +87,13 @@ QDF_STATUS wlan_reg_get_max_5g_bw_from_regdomain(uint16_t regdmn, #ifdef CONFIG_REG_CLIENT QDF_STATUS -wlan_reg_get_6g_power_type_for_ctry(struct wlan_objmgr_psoc *psoc, - struct wlan_objmgr_pdev *pdev, - uint8_t *ap_ctry, uint8_t *sta_ctry, - enum reg_6g_ap_type *pwr_type_6g, - bool *ctry_code_match, - enum reg_6g_ap_type ap_pwr_type) +wlan_reg_get_best_6g_power_type(struct wlan_objmgr_psoc *psoc, + struct wlan_objmgr_pdev *pdev, + enum reg_6g_ap_type *pwr_type_6g, + enum reg_6g_ap_type ap_pwr_type) { - return reg_get_6g_power_type_for_ctry(psoc, pdev, ap_ctry, sta_ctry, - pwr_type_6g, ctry_code_match, - ap_pwr_type); + return reg_get_best_6g_power_type(psoc, pdev, pwr_type_6g, + ap_pwr_type); } #endif